]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
add support for showing NL80211_ATTR_SUPPORTED_COMMANDS
authorMarcel Holtmann <marcel@holtmann.org>
Sat, 14 Nov 2009 19:10:21 +0000 (20:10 +0100)
committerJohannes Berg <johannes@sipsolutions.net>
Sun, 15 Nov 2009 08:40:28 +0000 (09:40 +0100)
info.c
iw.h
util.c

diff --git a/info.c b/info.c
index 7bca69dc6e83fe1ecbc0a7461fb255c02981a045..ddff78b7c4683e666b035c0f4e7f26c20a92369f 100644 (file)
--- a/info.c
+++ b/info.c
@@ -66,8 +66,9 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
        struct nlattr *nl_freq;
        struct nlattr *nl_rate;
        struct nlattr *nl_mode;
+       struct nlattr *nl_cmd;
        int bandidx = 1;
-       int rem_band, rem_freq, rem_rate, rem_mode;
+       int rem_band, rem_freq, rem_rate, rem_mode, rem_cmd;
        int open;
 
        nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
@@ -264,12 +265,20 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
        }
 
        if (!tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES])
-               return NL_SKIP;
+               goto commands;
 
        printf("\tSupported interface modes:\n");
        nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES], rem_mode)
                printf("\t\t * %s\n", iftype_name(nl_mode->nla_type));
 
+ commands:
+       if (!tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS])
+               return NL_SKIP;
+
+       printf("\tSupported commands:\n");
+       nla_for_each_nested(nl_cmd, tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS], rem_cmd)
+               printf("\t\t * %s\n", command_name(nla_get_u32(nl_cmd)));
+
        return NL_SKIP;
 }
 
diff --git a/iw.h b/iw.h
index 511a1db2a395843f6a9b78aff93a674c6a877936..e22a2819708fcf38acba4d308b4d7e6704518b66 100644 (file)
--- a/iw.h
+++ b/iw.h
@@ -121,6 +121,7 @@ void mac_addr_n2a(char *mac_addr, unsigned char *arg);
 int parse_keys(struct nl_msg *msg, char **argv, int argc);
 
 const char *iftype_name(enum nl80211_iftype iftype);
+const char *command_name(enum nl80211_commands cmd);
 int ieee80211_channel_to_frequency(int chan);
 int ieee80211_frequency_to_channel(int freq);
 
diff --git a/util.c b/util.c
index 1968526decabfc20f6d6a9d02cb8ba4f75943a05..6a3fcc0043efdbaa32575b92572565d150446497 100644 (file)
--- a/util.c
+++ b/util.c
@@ -69,6 +69,69 @@ const char *iftype_name(enum nl80211_iftype iftype)
        return modebuf;
 }
 
+static const char *commands[NL80211_CMD_MAX + 1] = {
+       "unspecified",
+       "get_wiphy",
+       "set_wiphy",
+       "new_wiphy",
+       "del_wiphy",
+       "get_interface",
+       "set_interface",
+       "new_interface",
+       "del_interface",
+       "get_key",
+       "set_key",
+       "new_key",
+       "del_key",
+       "get_beacon",
+       "set_beacon",
+       "new_beacon",
+       "del_beacon",
+       "get_station",
+       "set_station",
+       "new_station",
+       "del_station",
+       "get_mpath",
+       "set_mpath",
+       "new_mpath",
+       "del_mpath",
+       "set_bss",
+       "set_reg",
+       "reg_set_reg",
+       "get_mesh_params",
+       "set_mesh_params",
+       "set_mgmt_extra_ie",
+       "get_reg",
+       "get_scan",
+       "trigger_scan",
+       "new_scan_results",
+       "scan_aborted",
+       "reg_change",
+       "authenticate",
+       "associate",
+       "deauthenticate",
+       "disassociate",
+       "michael_mic_failure",
+       "reg_beacon_hint",
+       "join_ibss",
+       "leave_ibss",
+       "testmode",
+       "connect",
+       "roam",
+       "disconnect",
+       "set_wiphy_netns"
+};
+
+static char cmdbuf[100];
+
+const char *command_name(enum nl80211_commands cmd)
+{
+       if (cmd <= NL80211_CMD_MAX)
+               return commands[cmd];
+       sprintf(cmdbuf, "Unknown command (%d)", cmd);
+       return cmdbuf;
+}
+
 int ieee80211_channel_to_frequency(int chan)
 {
        if (chan < 14)