+
+static int nl80211_get_channel_cb(struct nl_msg *msg, void *arg)
+{
+ int *channel = arg;
+ struct nlattr **attr = nl80211_parse(msg);
+ struct nlattr *binfo[NL80211_BSS_MAX + 1];
+
+ static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
+ [NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
+ };
+
+ if (attr[NL80211_ATTR_BSS] &&
+ !nla_parse_nested(binfo, NL80211_BSS_MAX,
+ attr[NL80211_ATTR_BSS], bss_policy))
+ {
+ if (binfo[NL80211_BSS_FREQUENCY])
+ *channel =
+ nl80211_freq2channel(nla_get_u32(binfo[NL80211_BSS_FREQUENCY]));
+ }
+
+ return NL_SKIP;
+}
+