]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
allow wdev in place of dev
authorJohannes Berg <johannes.berg@intel.com>
Thu, 19 Jul 2012 06:36:05 +0000 (08:36 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 19 Jul 2012 10:04:11 +0000 (12:04 +0200)
In new kernels, any virtual interface also has a wdev
identifier, allow using that in place of interface idx.

connect.c
iw.c
link.c
scan.c

index a58e44e5ba76142e35bce071cd4d84aba4cdceb2..a37435c00505673dbe16b164a5284d2e10a87066 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -108,7 +108,7 @@ static int iw_connect(struct nl80211_state *state, struct nl_cb *cb,
        conn_argv[2] = "establish";
        for (i = 0; i < argc; i++)
                conn_argv[i + 3] = argv[i];
-       err = handle_cmd(state, II_NETDEV, conn_argc, conn_argv);
+       err = handle_cmd(state, id, conn_argc, conn_argv);
        free(conn_argv);
        if (err)
                return err;
diff --git a/iw.c b/iw.c
index 98c0852153c02635cf9b85cf65bc7cbb0c76e881..af55a9bfae493bfd90161798eeca22a53694d771 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -178,6 +178,8 @@ static void usage(int argc, char **argv)
                        __usage_cmd(cmd, "\t", full);
                }
        }
+       printf("\nCommands that use the netdev ('dev') can also be given the\n"
+              "'wdev' instead to identify the device.\n");
        printf("\nYou can omit the 'phy' or 'dev' if "
                        "the identification is unique,\n"
                        "e.g. \"iw wlan0 info\" or \"iw phy0 info\". "
@@ -335,7 +337,13 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
                                continue;
                        if (cmd->parent != sectcmd)
                                continue;
-                       if (cmd->idby != command_idby)
+                       /*
+                        * ignore mismatch id by, but allow WDEV
+                        * in place of NETDEV
+                        */
+                       if (cmd->idby != command_idby &&
+                           !(cmd->idby == CIB_NETDEV &&
+                             command_idby == CIB_WDEV))
                                continue;
                        if (strcmp(cmd->name, command))
                                continue;
@@ -358,7 +366,8 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
                cmd = sectcmd;
                if (argc && !cmd->args)
                        return 1;
-               if (cmd->idby != command_idby)
+               if (cmd->idby != command_idby &&
+                   !(cmd->idby == CIB_NETDEV && command_idby == CIB_WDEV))
                        return 1;
                if (!cmd->handler)
                        return 1;
diff --git a/link.c b/link.c
index 6a803a137f1790858f3db4f1c257286720b6c6b9..3470c4da2b53be38ff971d517ac0c8bfe89abb37 100644 (file)
--- a/link.c
+++ b/link.c
@@ -276,7 +276,7 @@ static int handle_link(struct nl80211_state *state, struct nl_cb *cb,
        int err;
 
        link_argv[0] = argv[0];
-       err = handle_cmd(state, II_NETDEV, 3, link_argv);
+       err = handle_cmd(state, id, 3, link_argv);
        if (err)
                return err;
 
@@ -291,7 +291,7 @@ static int handle_link(struct nl80211_state *state, struct nl_cb *cb,
 
        station_argv[0] = argv[0];
        station_argv[3] = bssid_buf;
-       return handle_cmd(state, II_NETDEV, 4, station_argv);
+       return handle_cmd(state, id, 4, station_argv);
 }
 TOPLEVEL(link, NULL, 0, 0, CIB_NETDEV, handle_link,
         "Print information about the current link, if any.");
diff --git a/scan.c b/scan.c
index be9eaff482a5af9f018cb221e280759f790f13c8..bb84a6776d055ca392e0650e31733820be572e19 100644 (file)
--- a/scan.c
+++ b/scan.c
@@ -1306,7 +1306,7 @@ static int handle_scan_combined(struct nl80211_state *state,
        int i;
        for (i = 0; i < argc - 2 - (dump_argc - 3); i++)
                trig_argv[i + 3] = argv[i + 2 + (dump_argc - 3)];
-       err = handle_cmd(state, II_NETDEV, trig_argc, trig_argv);
+       err = handle_cmd(state, id, trig_argc, trig_argv);
        free(trig_argv);
        if (err)
                return err;
@@ -1342,7 +1342,7 @@ static int handle_scan_combined(struct nl80211_state *state,
        }
 
        dump_argv[0] = argv[0];
-       return handle_cmd(state, II_NETDEV, dump_argc, dump_argv);
+       return handle_cmd(state, id, dump_argc, dump_argv);
 }
 TOPLEVEL(scan, "[-u] [freq <freq>*] [ies <hex as 00:11:..>] [ssid <ssid>*|passive]", 0, 0,
         CIB_NETDEV, handle_scan_combined,