+ char *phy;
+ int count = 0, bands_remain, freqs_remain;
+ struct nl80211_msg_conveyor *req, *res;
+ struct nlattr *bands[NL80211_BAND_ATTR_MAX + 1];
+ struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1];
+ struct nlattr *band, *freq;
+ struct iwinfo_freqlist_entry *e = (struct iwinfo_freqlist_entry *)buf;
+
+ static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
+ [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
+ [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
+ [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
+ };
+
+ if( !wext_get_freqlist(ifname, buf, len) )
+ return 0;
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
+ if( req )
+ {
+ res = nl80211_send(req);
+ if( res )
+ {
+ nla_for_each_nested(band,
+ res->attr[NL80211_ATTR_WIPHY_BANDS], bands_remain)
+ {
+ nla_parse(bands, NL80211_BAND_ATTR_MAX, nla_data(band),
+ nla_len(band), NULL);
+
+ nla_for_each_nested(freq,
+ bands[NL80211_BAND_ATTR_FREQS], freqs_remain)
+ {
+ nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX,
+ nla_data(freq), nla_len(freq), freq_policy);
+
+ e->mhz = nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]);
+ e->channel = nl80211_freq2channel(e->mhz);
+
+ e++;
+ count++;
+ }
+ }
+ nl80211_free(res);
+ }
+ nl80211_free(req);
+ }
+
+ if( count > 0 )
+ {
+ *len = count * sizeof(struct iwinfo_freqlist_entry);
+ return 0;
+ }
+
+ return -1;