]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
add basics for identify wireless devs
authorJohannes Berg <johannes.berg@intel.com>
Thu, 19 Jul 2012 06:15:41 +0000 (08:15 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 19 Jul 2012 06:15:41 +0000 (08:15 +0200)
iw.c
iw.h

diff --git a/iw.c b/iw.c
index 6f51f1a89cdea877285dd2020384c572ecf98776..cdfd00e4b915a10ee79e608a10eaaf550a4fd3d5 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -98,6 +98,9 @@ static void __usage_cmd(const struct cmd *cmd, char *indent, bool full)
        case CIB_NETDEV:
                printf("dev <devname> ");
                break;
+       case CIB_WDEV:
+               printf("wdev <idx> ");
+               break;
        }
        if (cmd->parent && cmd->parent->name)
                printf("%s ", cmd->parent->name);
@@ -255,7 +258,7 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
        struct nl_cb *cb;
        struct nl_cb *s_cb;
        struct nl_msg *msg;
-       int devidx = 0;
+       signed long long devidx = 0;
        int err, o_argc;
        const char *command, *section;
        char *tmp, **o_argv;
@@ -290,6 +293,13 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
                argc--;
                argv++;
                break;
+       case II_WDEV:
+               command_idby = CIB_WDEV;
+               devidx = strtoll(*argv, &tmp, 0);
+               if (*tmp != '\0')
+                       return 1;
+               argc--;
+               argv++;
        default:
                break;
        }
@@ -392,6 +402,9 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
        case CIB_NETDEV:
                NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, devidx);
                break;
+       case CIB_WDEV:
+               NLA_PUT_U64(msg, NL80211_ATTR_WDEV, devidx);
+               break;
        default:
                break;
        }
@@ -476,6 +489,10 @@ int main(int argc, char **argv)
                        err = __handle_cmd(&nlstate, II_PHY_IDX, argc, argv, &cmd);
                else
                        goto detect;
+       } else if (strcmp(*argv, "wdev") == 0 && argc > 1) {
+               argc--;
+               argv++;
+               err = __handle_cmd(&nlstate, II_WDEV, argc, argv, &cmd);
        } else {
                int idx;
                enum id_input idby = II_NONE;
diff --git a/iw.h b/iw.h
index 3379a7fd673bca5fe7f08cf75dd25f917d79a2dd..1d7c4ea19077dee6c8bc48cffe49f0b33911da58 100644 (file)
--- a/iw.h
+++ b/iw.h
@@ -27,6 +27,7 @@ enum command_identify_by {
        CIB_NONE,
        CIB_PHY,
        CIB_NETDEV,
+       CIB_WDEV,
 };
 
 enum id_input {
@@ -34,6 +35,7 @@ enum id_input {
        II_NETDEV,
        II_PHY_NAME,
        II_PHY_IDX,
+       II_WDEV,
 };
 
 struct cmd {