iwinfo: move ARRAY_SIZE macro to iwinfo/utils.h
[project/iwinfo.git] / iwinfo_nl80211.c
index 3facba9..2562492 100644 (file)
@@ -2274,9 +2274,8 @@ static int nl80211_get_freqlist_cb(struct nl_msg *msg, void *arg)
                        e->channel = nl80211_freq2channel(e->mhz);
 
                        e->restricted = (
-                               freqs[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] ||
-                               freqs[NL80211_FREQUENCY_ATTR_NO_IBSS]      ||
-                               freqs[NL80211_FREQUENCY_ATTR_RADAR]
+                               freqs[NL80211_FREQUENCY_ATTR_NO_IR] &&
+                               !freqs[NL80211_FREQUENCY_ATTR_RADAR]
                        ) ? 1 : 0;
 
                        e++;
@@ -2383,13 +2382,6 @@ static int nl80211_get_hwmodelist_cb(struct nl_msg *msg, void *arg)
                        if (caps > 0)
                                *modes |= IWINFO_80211_N;
 
-                       if (bands[NL80211_BAND_ATTR_VHT_CAPA])
-                               vht_caps = nla_get_u32(bands[NL80211_BAND_ATTR_VHT_CAPA]);
-
-                       /* Treat any nonzero capability as 11ac */
-                       if (vht_caps > 0)
-                               *modes |= IWINFO_80211_AC;
-
                        nla_for_each_nested(freq, bands[NL80211_BAND_ATTR_FREQS],
                                            freqs_remain)
                        {
@@ -2404,6 +2396,14 @@ static int nl80211_get_hwmodelist_cb(struct nl_msg *msg, void *arg)
                                        *modes |= IWINFO_80211_B;
                                        *modes |= IWINFO_80211_G;
                                }
+                               else if (bands[NL80211_BAND_ATTR_VHT_CAPA])
+                               {
+                                       vht_caps = nla_get_u32(bands[NL80211_BAND_ATTR_VHT_CAPA]);
+
+                                       /* Treat any nonzero capability as 11ac */
+                                       if (vht_caps > 0)
+                                               *modes |= IWINFO_80211_AC;
+                               }
                                else if (!(*modes & IWINFO_80211_AC))
                                {
                                        *modes |= IWINFO_80211_A;
@@ -2446,15 +2446,15 @@ static int nl80211_get_ifcomb_cb(struct nl_msg *msg, void *arg)
                        [NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED },
                        [NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 },
                };
-               struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB];
+               struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB+1];
                static struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = {
                        [NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED },
                        [NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 },
                };
-               struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT];
+               struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT+1];
                struct nlattr *limit;
 
-               nla_parse_nested(tb_comb, NL80211_BAND_ATTR_MAX, comb, iface_combination_policy);
+               nla_parse_nested(tb_comb, NUM_NL80211_IFACE_COMB, comb, iface_combination_policy);
 
                if (!tb_comb[NL80211_IFACE_COMB_LIMITS])
                        continue;
@@ -2575,6 +2575,17 @@ static int nl80211_get_frequency_offset(const char *ifname, int *buf)
        return 0;
 }
 
+static int nl80211_lookup_phyname(const char *section, char *buf)
+{
+       int idx;
+
+       if ((idx = nl80211_phy_idx_from_uci(section)) < 0)
+               return -1;
+
+       sprintf(buf, "phy%d", idx);
+       return 0;
+}
+
 const struct iwinfo_ops nl80211_ops = {
        .name             = "nl80211",
        .probe            = nl80211_probe,
@@ -2603,5 +2614,6 @@ const struct iwinfo_ops nl80211_ops = {
        .scanlist         = nl80211_get_scanlist,
        .freqlist         = nl80211_get_freqlist,
        .countrylist      = nl80211_get_countrylist,
+       .lookup_phy       = nl80211_lookup_phyname,
        .close            = nl80211_close
 };