]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - info.c
iw: bump version to 4.7
[thirdparty/iw.git] / info.c
diff --git a/info.c b/info.c
index b72801bc65030837e684c33debfa968a04209e62..32de0af1bba18b932f34852fb8895bc4c15734f1 100644 (file)
--- a/info.c
+++ b/info.c
@@ -1,6 +1,4 @@
 #include <stdbool.h>
-#include <errno.h>
-#include <net/if.h>
 
 #include <netlink/genl/genl.h>
 #include <netlink/genl/family.h>
@@ -63,6 +61,18 @@ static char *dfs_state_name(enum nl80211_dfs_state state)
        }
 }
 
+static int ext_feature_isset(const unsigned char *ext_features, int ext_features_len,
+                            enum nl80211_ext_feature_index ftidx)
+{
+       unsigned char ft_byte;
+
+       if ((int) ftidx / 8 >= ext_features_len)
+               return 0;
+
+       ft_byte = ext_features[ftidx / 8];
+       return (ft_byte & BIT(ftidx % 8)) != 0;
+}
+
 static int print_phy_handler(struct nl_msg *msg, void *arg)
 {
        struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
@@ -232,6 +242,21 @@ next:
        if (tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN])
                printf("\tmax scan IEs length: %d bytes\n",
                       nla_get_u16(tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN]));
+       if (tb_msg[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS])
+               printf("\tmax # sched scan SSIDs: %d\n",
+                      nla_get_u8(tb_msg[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS]));
+       if (tb_msg[NL80211_ATTR_MAX_MATCH_SETS])
+               printf("\tmax # match sets: %d\n",
+                      nla_get_u8(tb_msg[NL80211_ATTR_MAX_MATCH_SETS]));
+       if (tb_msg[NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS])
+               printf("\tmax # scan plans: %d\n",
+                      nla_get_u32(tb_msg[NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS]));
+       if (tb_msg[NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL])
+               printf("\tmax scan plan interval: %d\n",
+                      nla_get_u32(tb_msg[NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL]));
+       if (tb_msg[NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS])
+               printf("\tmax scan plan iterations: %d\n",
+                      nla_get_u32(tb_msg[NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS]));
 
        if (tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) {
                unsigned int frag;
@@ -455,6 +480,7 @@ broken_combination:
                        [NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST] = { .type = NLA_FLAG },
                        [NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE] = { .type = NLA_FLAG },
                        [NL80211_WOWLAN_TRIG_RFKILL_RELEASE] = { .type = NLA_FLAG },
+                       [NL80211_WOWLAN_TRIG_NET_DETECT] = { .type = NLA_U32 },
                        [NL80211_WOWLAN_TRIG_TCP_CONNECTION] = { .type = NLA_NESTED },
                };
                struct nl80211_pattern_support *pat;
@@ -475,12 +501,13 @@ broken_combination:
                        if (tb_wowlan[NL80211_WOWLAN_TRIG_MAGIC_PKT])
                                printf("\t\t * wake up on magic packet\n");
                        if (tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]) {
+                               unsigned int len = nla_len(tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]);
+
                                pat = nla_data(tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]);
                                printf("\t\t * wake up on pattern match, up to %u patterns of %u-%u bytes,\n"
                                        "\t\t   maximum packet offset %u bytes\n",
                                        pat->max_patterns, pat->min_pattern_len, pat->max_pattern_len,
-                                       (nla_len(tb_wowlan[NL80211_WOWLAN_TRIG_PKT_PATTERN]) <
-                                       sizeof(*pat)) ? 0 : pat->max_pkt_offset);
+                                       len < sizeof(*pat) ? 0 : pat->max_pkt_offset);
                        }
                        if (tb_wowlan[NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED])
                                printf("\t\t * can do GTK rekeying\n");
@@ -492,6 +519,9 @@ broken_combination:
                                printf("\t\t * wake up on 4-way handshake\n");
                        if (tb_wowlan[NL80211_WOWLAN_TRIG_RFKILL_RELEASE])
                                printf("\t\t * wake up on rfkill release\n");
+                       if (tb_wowlan[NL80211_WOWLAN_TRIG_NET_DETECT])
+                               printf("\t\t * wake up on network detection, up to %d match sets\n",
+                                      nla_get_u32(tb_wowlan[NL80211_WOWLAN_TRIG_NET_DETECT]));
                        if (tb_wowlan[NL80211_WOWLAN_TRIG_TCP_CONNECTION])
                                printf("\t\t * wake up on TCP connection\n");
                }
@@ -505,8 +535,10 @@ broken_combination:
 
        if (tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]) {
                struct ieee80211_ht_cap *cm;
+               unsigned int len = nla_len(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]);
+
                printf("\tHT Capability overrides:\n");
-               if (nla_len(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]) >= sizeof(*cm)) {
+               if (len >= sizeof(*cm)) {
                        cm = nla_data(tb_msg[NL80211_ATTR_HT_CAPABILITY_MASK]);
                        printf("\t\t * MCS: %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx"
                               " %02hhx %02hhx %02hhx %02hhx\n",
@@ -545,14 +577,58 @@ broken_combination:
                        printf("\tDevice accepts cell base station regulatory hints.\n");
                if (features & NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL)
                        printf("\tP2P Device uses a channel (of the concurrent ones)\n");
+               if (features & NL80211_FEATURE_SAE)
+                       printf("\tDevice supports SAE with AUTHENTICATE command\n");
                if (features & NL80211_FEATURE_LOW_PRIORITY_SCAN)
                        printf("\tDevice supports low priority scan.\n");
                if (features & NL80211_FEATURE_SCAN_FLUSH)
                        printf("\tDevice supports scan flush.\n");
                if (features & NL80211_FEATURE_AP_SCAN)
                        printf("\tDevice supports AP scan.\n");
+               if (features & NL80211_FEATURE_VIF_TXPOWER)
+                       printf("\tDevice supports per-vif TX power setting\n");
+               if (features & NL80211_FEATURE_NEED_OBSS_SCAN)
+                       printf("\tUserspace should do OBSS scan and generate 20/40 coex reports\n");
+               if (features & NL80211_FEATURE_P2P_GO_CTWIN)
+                       printf("\tP2P GO supports CT window setting\n");
+               if (features & NL80211_FEATURE_P2P_GO_OPPPS)
+                       printf("\tP2P GO supports opportunistic powersave setting\n");
+               if (features & NL80211_FEATURE_FULL_AP_CLIENT_STATE)
+                       printf("\tDriver supports full state transitions for AP/GO clients\n");
+               if (features & NL80211_FEATURE_USERSPACE_MPM)
+                       printf("\tDriver supports a userspace MPM\n");
+               if (features & NL80211_FEATURE_ACTIVE_MONITOR)
+                       printf("\tDevice supports active monitor (which will ACK incoming frames)\n");
+               if (features & NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE)
+                       printf("\tDriver/device bandwidth changes during BSS lifetime (AP/GO mode)\n");
+               if (features & NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES)
+                       printf("\tDevice adds DS IE to probe requests\n");
+               if (features & NL80211_FEATURE_WFA_TPC_IE_IN_PROBES)
+                       printf("\tDevice adds WFA TPC Report IE to probe requests\n");
+               if (features & NL80211_FEATURE_QUIET)
+                       printf("\tDevice supports quiet requests from AP\n");
+               if (features & NL80211_FEATURE_TX_POWER_INSERTION)
+                       printf("\tDevice can update TPC Report IE\n");
                if (features & NL80211_FEATURE_ACKTO_ESTIMATION)
                        printf("\tDevice supports ACK timeout estimation.\n");
+               if (features & NL80211_FEATURE_STATIC_SMPS)
+                       printf("\tDevice supports static SMPS\n");
+               if (features & NL80211_FEATURE_DYNAMIC_SMPS)
+                       printf("\tDevice supports dynamic SMPS\n");
+               if (features & NL80211_FEATURE_SUPPORTS_WMM_ADMISSION)
+                       printf("\tDevice supports WMM-AC admission (TSPECs)\n");
+               if (features & NL80211_FEATURE_MAC_ON_CREATE)
+                       printf("\tDevice supports configuring vdev MAC-addr on create.\n");
+               if (features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH)
+                       printf("\tDevice supports TDLS channel switching\n");
+       }
+
+       if (tb_msg[NL80211_ATTR_EXT_FEATURES]) {
+               struct nlattr *tb = tb_msg[NL80211_ATTR_EXT_FEATURES];
+
+               if (ext_feature_isset(nla_data(tb), nla_len(tb),
+                                     NL80211_EXT_FEATURE_VHT_IBSS))
+                       printf("\tDevice supports VHT-IBSS.\n");
        }
 
        if (tb_msg[NL80211_ATTR_TDLS_SUPPORT])
@@ -579,7 +655,6 @@ broken_combination:
 static bool nl80211_has_split_wiphy = false;
 
 static int handle_info(struct nl80211_state *state,
-                      struct nl_cb *cb,
                       struct nl_msg *msg,
                       int argc, char **argv,
                       enum id_input id)
@@ -593,7 +668,7 @@ static int handle_info(struct nl80211_state *state,
                nlmsg_hdr(msg)->nlmsg_flags |= NLM_F_DUMP;
        }
 
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_phy_handler, NULL);
+       register_handler(print_phy_handler, NULL);
 
        return 0;
 }
@@ -603,12 +678,11 @@ TOPLEVEL(list, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info,
         "List all wireless devices and their capabilities.");
 TOPLEVEL(phy, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, NULL);
 
-static int handle_commands(struct nl80211_state *state,
-                          struct nl_cb *cb, struct nl_msg *msg,
+static int handle_commands(struct nl80211_state *state, struct nl_msg *msg,
                           int argc, char **argv, enum id_input id)
 {
        int i;
-       for (i = 1; i < NL80211_CMD_MAX; i++)
+       for (i = 1; i <= NL80211_CMD_MAX; i++)
                printf("%d (0x%x): %s\n", i, i, command_name(i));
        /* don't send netlink messages */
        return 2;
@@ -639,12 +713,11 @@ static int print_feature_handler(struct nl_msg *msg, void *arg)
        return NL_SKIP;
 }
 
-static int handle_features(struct nl80211_state *state,
-                          struct nl_cb *cb, struct nl_msg *msg,
+static int handle_features(struct nl80211_state *state, struct nl_msg *msg,
                           int argc, char **argv, enum id_input id)
 {
        unsigned long print = argc == 0 || strcmp(argv[0], "-q");
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_feature_handler, (void *)print);
+       register_handler(print_feature_handler, (void *)print);
        return 0;
 }