]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
add "interface del" backward compat command
authorJohannes Berg <johannes@sipsolutions.net>
Wed, 17 Sep 2008 11:27:04 +0000 (13:27 +0200)
committerJohannes Berg <johannes@sipsolutions.net>
Wed, 17 Sep 2008 11:27:04 +0000 (13:27 +0200)
Some scripts out there might already be using
iw dev fish0 interface del
so don't break them. But don't advertise this
command either in the help output.

interface.c
iw.c
iw.h

index 2137665543022e72eef91e6cfbbb62ab5a88b406..92b470bafd5315b848dc523b0bbca3888ac403c0 100644 (file)
@@ -123,6 +123,7 @@ static int handle_interface_del(struct nl_cb *cb,
        return 0;
 }
 TOPLEVEL(del, NULL, NL80211_CMD_DEL_INTERFACE, 0, CIB_NETDEV, handle_interface_del);
+HIDDEN(interface, del, NULL, NL80211_CMD_DEL_INTERFACE, 0, CIB_NETDEV, handle_interface_del);
 
 static int print_iface_handler(struct nl_msg *msg, void *arg)
 {
diff --git a/iw.c b/iw.c
index e09d975e2d5b9ce1b279bbd63fd00dd8bded0233..f5fcc185d56d26b402801759908b5f1e1dc89c41 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -71,8 +71,8 @@ static void nl80211_cleanup(struct nl80211_state *state)
        nl_handle_destroy(state->nl_handle);
 }
 
-__COMMAND(NULL, NULL, NULL, 0, 0, CIB_NONE, NULL);
-__COMMAND(NULL, NULL, NULL, 1, 0, CIB_NONE, NULL);
+__COMMAND(NULL, NULL, NULL, 0, 0, 0, CIB_NONE, NULL);
+__COMMAND(NULL, NULL, NULL, 1, 0, 0, CIB_NONE, NULL);
 
 static int cmd_size;
 
@@ -87,7 +87,7 @@ static void usage(const char *argv0)
        fprintf(stderr, "Commands:\n");
        for (cmd = &__start___cmd; cmd < &__stop___cmd;
             cmd = (struct cmd *)((char *)cmd + cmd_size)) {
-               if (!cmd->handler)
+               if (!cmd->handler || cmd->hidden)
                        continue;
                switch (cmd->idby) {
                case CIB_NONE:
@@ -269,7 +269,8 @@ int main(int argc, char **argv)
        int err;
        const char *argv0;
 
-       cmd_size = abs((long)&__cmd_NULL1CIB_NONE - (long)&__cmd_NULL0CIB_NONE);
+       cmd_size = abs((long)&__cmd_NULL_1_CIB_NONE_0
+                    - (long)&__cmd_NULL_0_CIB_NONE_0);
        /* strip off self */
        argc--;
        argv0 = *argv++;
diff --git a/iw.h b/iw.h
index c9d905215dade5d8f2bb967a8041f1c9c11dc168..2cb6ebea58072227265084ce8a9bab4b03b47750 100644 (file)
--- a/iw.h
+++ b/iw.h
@@ -26,6 +26,7 @@ struct cmd {
        const char *args;
        const enum nl80211_commands cmd;
        int nl_msg_flags;
+       int hidden;
        const enum command_identify_by idby;
        /*
         * The handler should return a negative error code,
@@ -37,14 +38,17 @@ struct cmd {
                       int argc, char **argv);
 };
 
-#define __COMMAND(sect, name, args, nlcmd, flags, idby, handler)       \
-       static const struct cmd __cmd_ ## handler ## nlcmd ## idby      \
+#define __COMMAND(sect, name, args, nlcmd, flags, hidden, idby, handler)\
+       static const struct cmd                                         \
+       __cmd_ ## handler ## _ ## nlcmd ## _ ## idby ## _ ## hidden     \
        __attribute__((used)) __attribute__((section("__cmd")))         \
-       = { sect, name, args, nlcmd, flags, idby, handler }
+       = { sect, name, args, nlcmd, flags, hidden, idby, handler }
 #define COMMAND(section, name, args, cmd, flags, idby, handler)        \
-       __COMMAND(#section, #name, args, cmd, flags, idby, handler)
+       __COMMAND(#section, #name, args, cmd, flags, 0, idby, handler)
+#define HIDDEN(section, name, args, cmd, flags, idby, handler) \
+       __COMMAND(#section, #name, args, cmd, flags, 1, idby, handler)
 #define TOPLEVEL(name, args, cmd, flags, idby, handler)                \
-       __COMMAND(NULL, #name, args, cmd, flags, idby, handler)
+       __COMMAND(NULL, #name, args, cmd, flags, 0, idby, handler)
 extern struct cmd __start___cmd;
 extern struct cmd __stop___cmd;