]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: remove cb from arguments and simplify valid handler
authorJohannes Berg <johannes.berg@intel.com>
Fri, 26 Jun 2015 09:42:28 +0000 (11:42 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 13 Aug 2015 08:39:58 +0000 (10:39 +0200)
Just provide our own valid handler and let the command
functions assign it without going through the cb.

(With the event handling fixed by Eliad Peller)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
27 files changed:
bitrate.c
coalesce.c
connect.c
cqm.c
event.c
hwsim.c
ibss.c
info.c
interface.c
iw.c
iw.h
link.c
mesh.c
mpath.c
mpp.c
ocb.c
offch.c
p2p.c
phy.c
ps.c
reg.c
roc.c
scan.c
station.c
survey.c
vendor.c
wowlan.c

index 4df6185329aaba3c84897b4d6642599feba11c5c..87288583f3387c81ba102d91518c5bb2c1ca7847 100644 (file)
--- a/bitrate.c
+++ b/bitrate.c
@@ -77,7 +77,6 @@ static int setup_vht(struct nl80211_txrate_vht *txrate_vht,
 #define VHT_ARGC_MAX   100
 
 static int handle_bitrates(struct nl80211_state *state,
-                          struct nl_cb *cb,
                           struct nl_msg *msg,
                           int argc, char **argv,
                           enum id_input id)
index 0d80cebcfaca51695e8d392df8dac1ba209a20fd..6cdc4694a5ead1bda6a7decf842327f4f7a3eb09 100644 (file)
@@ -16,7 +16,7 @@
 
 SECTION(coalesce);
 
-static int handle_coalesce_enable(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_coalesce_enable(struct nl80211_state *state,
                                  struct nl_msg *msg, int argc, char **argv,
                                  enum id_input id)
 {
@@ -185,7 +185,7 @@ COMMAND(coalesce, enable, "<config-file>",
        "match '43:34:00:12' after 18 bytes of offset in Rx packet.\n");
 
 static int
-handle_coalesce_disable(struct nl80211_state *state, struct nl_cb *cb,
+handle_coalesce_disable(struct nl80211_state *state,
                        struct nl_msg *msg, int argc, char **argv,
                        enum id_input id)
 {
@@ -274,12 +274,11 @@ static int print_coalesce_handler(struct nl_msg *msg, void *arg)
        return NL_SKIP;
 }
 
-static int handle_coalesce_show(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_coalesce_show(struct nl80211_state *state,
                              struct nl_msg *msg, int argc, char **argv,
                              enum id_input id)
 {
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
-                 print_coalesce_handler, NULL);
+       register_handler(print_coalesce_handler, NULL);
 
        return 0;
 }
index fb3b2fe2fc1cb8137a129eea10e42ac89bd20e98..56771249e234bc14bd5234a68b5565f08688eb14 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -9,7 +9,7 @@
 #include "nl80211.h"
 #include "iw.h"
 
-static int iw_conn(struct nl80211_state *state, struct nl_cb *cb,
+static int iw_conn(struct nl80211_state *state,
                   struct nl_msg *msg, int argc, char **argv,
                   enum id_input id)
 {
@@ -59,7 +59,6 @@ static int iw_conn(struct nl80211_state *state, struct nl_cb *cb,
 }
 
 static int disconnect(struct nl80211_state *state,
-                     struct nl_cb *cb,
                      struct nl_msg *msg,
                      int argc, char **argv,
                      enum id_input id)
@@ -70,7 +69,7 @@ TOPLEVEL(disconnect, NULL,
        NL80211_CMD_DISCONNECT, 0, CIB_NETDEV, disconnect,
        "Disconnect from the current network.");
 
-static int iw_connect(struct nl80211_state *state, struct nl_cb *cb,
+static int iw_connect(struct nl80211_state *state,
                      struct nl_msg *msg, int argc, char **argv,
                      enum id_input id)
 {
@@ -146,7 +145,7 @@ TOPLEVEL(connect, "[-w] <SSID> [<freq in MHz>] [<bssid>] [key 0:abcde d:1:616263
        "With -w, wait for the connect to finish or fail.");
 HIDDEN(connect, establish, "", NL80211_CMD_CONNECT, 0, CIB_NETDEV, iw_conn);
 
-static int iw_auth(struct nl80211_state *state, struct nl_cb *cb,
+static int iw_auth(struct nl80211_state *state,
                   struct nl_msg *msg, int argc, char **argv,
                   enum id_input id)
 {
diff --git a/cqm.c b/cqm.c
index 65876afadd13000ae7705633fea9c1b13c58e14c..dddd36e8689c2eaf55a18cbc41a816c15aeea58e 100644 (file)
--- a/cqm.c
+++ b/cqm.c
@@ -9,7 +9,7 @@
 #include "nl80211.h"
 #include "iw.h"
 
-static int iw_cqm_rssi(struct nl80211_state *state, struct nl_cb *cb,
+static int iw_cqm_rssi(struct nl80211_state *state,
                       struct nl_msg *msg, int argc, char **argv,
                       enum id_input id)
 {
diff --git a/event.c b/event.c
index f73e078d4aea80109b4f986e6ec29f05587865ba..5fb5afc6c4dd95a804abd75e463e05d5997de971 100644 (file)
--- a/event.c
+++ b/event.c
@@ -703,14 +703,15 @@ __u32 __do_listen_events(struct nl80211_state *state,
 
        /* no sequence checking for multicast messages */
        nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);
+       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, NULL);
 
        if (n_waits && waits) {
                wait_ev.cmds = waits;
                wait_ev.n_cmds = n_waits;
                wait_ev.pargs = args;
-               nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, wait_event, &wait_ev);
+               register_handler(wait_event, &wait_ev);
        } else
-               nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_event, args);
+               register_handler(print_event, args);
 
        wait_ev.cmd = 0;
 
@@ -735,7 +736,6 @@ __u32 listen_events(struct nl80211_state *state,
 }
 
 static int print_events(struct nl80211_state *state,
-                       struct nl_cb *cb,
                        struct nl_msg *msg,
                        int argc, char **argv,
                        enum id_input id)
diff --git a/hwsim.c b/hwsim.c
index 08c9c2e62ee3825d9cea25ff17edf70c9b80b53a..faa197b154569b86fb4740b2e00245eeb531ad6d 100644 (file)
--- a/hwsim.c
+++ b/hwsim.c
@@ -52,7 +52,7 @@ static int print_hwsim_ps_handler(struct nl_msg *msg, void *arg)
        return NL_SKIP;
 }
 
-static int handle_hwsim_getps(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_hwsim_getps(struct nl80211_state *state,
                              struct nl_msg *msg, int argc, char **argv,
                              enum id_input id)
 {
@@ -66,15 +66,14 @@ static int handle_hwsim_getps(struct nl80211_state *state, struct nl_cb *cb,
 
        nla_nest_end(msg, tmdata);
 
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
-                 print_hwsim_ps_handler, NULL);
+       register_handler(print_hwsim_ps_handler, NULL);
        return 0;
  nla_put_failure:
        return -ENOBUFS;
 }
 COMMAND(hwsim, getps, "", NL80211_CMD_TESTMODE, 0, CIB_PHY, handle_hwsim_getps, "");
 
-static int handle_hwsim_setps(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_hwsim_setps(struct nl80211_state *state,
                              struct nl_msg *msg, int argc, char **argv,
                              enum id_input id)
 {
@@ -98,15 +97,14 @@ static int handle_hwsim_setps(struct nl80211_state *state, struct nl_cb *cb,
 
        nla_nest_end(msg, tmdata);
 
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
-                 print_hwsim_ps_handler, NULL);
+       register_handler(print_hwsim_ps_handler, NULL);
        return 0;
  nla_put_failure:
        return -ENOBUFS;
 }
 COMMAND(hwsim, setps, "<value>", NL80211_CMD_TESTMODE, 0, CIB_PHY, handle_hwsim_setps, "");
 
-static int handle_hwsim_stop_queues(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_hwsim_stop_queues(struct nl80211_state *state,
                                    struct nl_msg *msg, int argc, char **argv,
                                    enum id_input id)
 {
@@ -128,7 +126,7 @@ static int handle_hwsim_stop_queues(struct nl80211_state *state, struct nl_cb *c
 }
 COMMAND(hwsim, stopqueues, "", NL80211_CMD_TESTMODE, 0, CIB_PHY, handle_hwsim_stop_queues, "");
 
-static int handle_hwsim_wake_queues(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_hwsim_wake_queues(struct nl80211_state *state,
                                    struct nl_msg *msg, int argc, char **argv,
                                    enum id_input id)
 {
diff --git a/ibss.c b/ibss.c
index 1bf1bab5f5b5fb29d0a67ef8f7900d783476421e..7a0b707f5ad35fb3082d3ef840b7ea7be3237e36 100644 (file)
--- a/ibss.c
+++ b/ibss.c
@@ -17,7 +17,6 @@
 SECTION(ibss);
 
 static int join_ibss(struct nl80211_state *state,
-                    struct nl_cb *cb,
                     struct nl_msg *msg,
                     int argc, char **argv,
                     enum id_input id)
@@ -183,7 +182,6 @@ static int join_ibss(struct nl80211_state *state,
 }
 
 static int leave_ibss(struct nl80211_state *state,
-                     struct nl_cb *cb,
                      struct nl_msg *msg,
                      int argc, char **argv,
                      enum id_input id)
diff --git a/info.c b/info.c
index 91dff158d043756b2b33951d0656b06fd37d54ca..4ce997e3c67047e85b1df6817a828c4b726cfc75 100644 (file)
--- a/info.c
+++ b/info.c
@@ -645,7 +645,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)
@@ -659,7 +658,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;
 }
@@ -669,8 +668,7 @@ 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;
@@ -705,12 +703,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;
 }
 
index 80437bd917f406cfa489556203227fea22c8a260..73ccecde6b05b52658d7ae90ffa02eef5cf8ceb1 100644 (file)
@@ -165,7 +165,6 @@ nla_put_failure:
 }
 
 static int handle_interface_add(struct nl80211_state *state,
-                               struct nl_cb *cb,
                                struct nl_msg *msg,
                                int argc, char **argv,
                                enum id_input id)
@@ -256,7 +255,6 @@ COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [f
        NL80211_CMD_NEW_INTERFACE, 0, CIB_NETDEV, handle_interface_add, NULL);
 
 static int handle_interface_del(struct nl80211_state *state,
-                               struct nl_cb *cb,
                                struct nl_msg *msg,
                                int argc, char **argv,
                                enum id_input id)
@@ -374,19 +372,17 @@ static int print_iface_handler(struct nl_msg *msg, void *arg)
 }
 
 static int handle_interface_info(struct nl80211_state *state,
-                                struct nl_cb *cb,
                                 struct nl_msg *msg,
                                 int argc, char **argv,
                                 enum id_input id)
 {
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_iface_handler, NULL);
+       register_handler(print_iface_handler, NULL);
        return 0;
 }
 TOPLEVEL(info, NULL, NL80211_CMD_GET_INTERFACE, 0, CIB_NETDEV, handle_interface_info,
         "Show information for this interface.");
 
 static int handle_interface_set(struct nl80211_state *state,
-                               struct nl_cb *cb,
                                struct nl_msg *msg,
                                int argc, char **argv,
                                enum id_input id)
@@ -417,7 +413,6 @@ COMMAND(set, monitor, "<flag>*",
        VALID_FLAGS);
 
 static int handle_interface_meshid(struct nl80211_state *state,
-                                  struct nl_cb *cb,
                                   struct nl_msg *msg,
                                   int argc, char **argv,
                                   enum id_input id)
@@ -441,20 +436,18 @@ COMMAND(set, meshid, "<meshid>",
 static unsigned int dev_dump_wiphy;
 
 static int handle_dev_dump(struct nl80211_state *state,
-                          struct nl_cb *cb,
                           struct nl_msg *msg,
                           int argc, char **argv,
                           enum id_input id)
 {
        dev_dump_wiphy = -1;
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_iface_handler, &dev_dump_wiphy);
+       register_handler(print_iface_handler, &dev_dump_wiphy);
        return 0;
 }
 TOPLEVEL(dev, NULL, NL80211_CMD_GET_INTERFACE, NLM_F_DUMP, CIB_NONE, handle_dev_dump,
         "List all network interfaces for wireless hardware.");
 
 static int handle_interface_type(struct nl80211_state *state,
-                                struct nl_cb *cb,
                                 struct nl_msg *msg,
                                 int argc, char **argv,
                                 enum id_input id)
@@ -481,7 +474,6 @@ COMMAND(set, type, "<type>",
        IFACE_TYPES);
 
 static int handle_interface_4addr(struct nl80211_state *state,
-                                 struct nl_cb *cb,
                                  struct nl_msg *msg,
                                  int argc, char **argv,
                                  enum id_input id)
@@ -495,7 +487,6 @@ COMMAND(set, 4addr, "<on|off>",
        "Set interface 4addr (WDS) mode.");
 
 static int handle_interface_noack_map(struct nl80211_state *state,
-                                     struct nl_cb *cb,
                                      struct nl_msg *msg,
                                      int argc, char **argv,
                                      enum id_input id)
@@ -523,7 +514,6 @@ COMMAND(set, noack_map, "<map>",
 
 
 static int handle_interface_wds_peer(struct nl80211_state *state,
-                                    struct nl_cb *cb,
                                     struct nl_msg *msg,
                                     int argc, char **argv,
                                     enum id_input id)
@@ -555,7 +545,6 @@ COMMAND(set, peer, "<MAC address>",
        "Set interface WDS peer.");
 
 static int set_mcast_rate(struct nl80211_state *state,
-                         struct nl_cb *cb,
                          struct nl_msg *msg,
                          int argc, char **argv,
                          enum id_input id)
diff --git a/iw.c b/iw.c
index dc99566653cadbd2c3f98b78b0b13b93e97510f0..ec5673619559243d11885e9bed3e708f550677ab 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -228,7 +228,6 @@ static void usage(int argc, char **argv)
 }
 
 static int print_help(struct nl80211_state *state,
-                     struct nl_cb *cb,
                      struct nl_msg *msg,
                      int argc, char **argv,
                      enum id_input id)
@@ -293,6 +292,23 @@ static int ack_handler(struct nl_msg *msg, void *arg)
        return NL_STOP;
 }
 
+static int (*registered_handler)(struct nl_msg *, void *);
+static void *registered_handler_data;
+
+void register_handler(int (*handler)(struct nl_msg *, void *), void *data)
+{
+       registered_handler = handler;
+       registered_handler_data = data;
+}
+
+int valid_handler(struct nl_msg *msg, void *arg)
+{
+       if (registered_handler)
+               return registered_handler(msg, registered_handler_data);
+
+       return NL_OK;
+}
+
 static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
                        int argc, char **argv, const struct cmd **cmdout)
 {
@@ -424,7 +440,7 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
        if (!cmd->cmd) {
                argc = o_argc;
                argv = o_argv;
-               return cmd->handler(state, NULL, NULL, argc, argv, idby);
+               return cmd->handler(state, NULL, argc, argv, idby);
        }
 
        msg = nlmsg_alloc();
@@ -458,7 +474,7 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
                break;
        }
 
-       err = cmd->handler(state, cb, msg, argc, argv, idby);
+       err = cmd->handler(state, msg, argc, argv, idby);
        if (err)
                goto out;
 
@@ -473,6 +489,7 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
        nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err);
        nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
        nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
+       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, NULL);
 
        while (err > 0)
                nl_recvmsgs(state->nl_sock, cb);
diff --git a/iw.h b/iw.h
index 78195eaab546cd5e58730a86e4d9aefc44fc3c20..cef9da87aa85c497148470902252714d928e9652 100644 (file)
--- a/iw.h
+++ b/iw.h
@@ -52,7 +52,6 @@ struct cmd {
         * and the usage message should and 2 otherwise.
         */
        int (*handler)(struct nl80211_state *state,
-                      struct nl_cb *cb,
                       struct nl_msg *msg,
                       int argc, char **argv,
                       enum id_input id);
@@ -130,6 +129,8 @@ __u32 __do_listen_events(struct nl80211_state *state,
                         const int n_waits, const __u32 *waits,
                         struct print_event_args *args);
 
+int valid_handler(struct nl_msg *msg, void *arg);
+void register_handler(int (*handler)(struct nl_msg *, void *), void *data);
 
 int mac_addr_a2n(unsigned char *mac_addr, char *arg);
 void mac_addr_n2a(char *mac_addr, unsigned char *arg);
diff --git a/link.c b/link.c
index f7818f5fc296098f67e020988453e2fc8d5f1e9d..f3bde514e5c395a55dbfad2c0a197da6ac1bb4b1 100644 (file)
--- a/link.c
+++ b/link.c
@@ -98,7 +98,6 @@ static int link_bss_handler(struct nl_msg *msg, void *arg)
 }
 
 static int handle_scan_for_link(struct nl80211_state *state,
-                               struct nl_cb *cb,
                                struct nl_msg *msg,
                                int argc, char **argv,
                                enum id_input id)
@@ -106,7 +105,7 @@ static int handle_scan_for_link(struct nl80211_state *state,
        if (argc > 0)
                return 1;
 
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, link_bss_handler, &lr);
+       register_handler(link_bss_handler, &lr);
        return 0;
 }
 
@@ -199,7 +198,6 @@ static int print_link_sta(struct nl_msg *msg, void *arg)
 }
 
 static int handle_link_sta(struct nl80211_state *state,
-                          struct nl_cb *cb,
                           struct nl_msg *msg,
                           int argc, char **argv,
                           enum id_input id)
@@ -222,14 +220,14 @@ static int handle_link_sta(struct nl80211_state *state,
 
        NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
 
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_link_sta, NULL);
+       register_handler(print_link_sta, NULL);
 
        return 0;
  nla_put_failure:
        return -ENOBUFS;
 }
 
-static int handle_link(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_link(struct nl80211_state *state,
                       struct nl_msg *msg, int argc, char **argv,
                       enum id_input id)
 {
diff --git a/mesh.c b/mesh.c
index 8d69fca92bf5411ee5f8336b1b982149c9a34f90..0090530569154482ecd5ec1006f3fd7a57804414 100644 (file)
--- a/mesh.c
+++ b/mesh.c
@@ -293,7 +293,6 @@ static const struct mesh_param_descr *find_mesh_param(const char *name)
 
 /* Setter */
 static int set_interface_meshparam(struct nl80211_state *state,
-                                  struct nl_cb *cb,
                                   struct nl_msg *msg,
                                   int argc, char **argv,
                                   enum id_input id)
@@ -407,7 +406,6 @@ static int print_mesh_param_handler(struct nl_msg *msg, void *arg)
 }
 
 static int get_interface_meshparam(struct nl80211_state *state,
-                                  struct nl_cb *cb,
                                   struct nl_msg *msg,
                                   int argc, char **argv,
                                   enum id_input id)
@@ -423,8 +421,7 @@ static int get_interface_meshparam(struct nl80211_state *state,
                        return 2;
        }
 
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
-                 print_mesh_param_handler, (void *)mdescr);
+       register_handler(print_mesh_param_handler, (void *)mdescr);
        return 0;
 }
 
@@ -432,7 +429,7 @@ COMMAND(get, mesh_param, "[<param>]",
        NL80211_CMD_GET_MESH_PARAMS, 0, CIB_NETDEV, get_interface_meshparam,
        "Retrieve mesh parameter (run command without any to see available ones).");
 
-static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
+static int join_mesh(struct nl80211_state *state,
                     struct nl_msg *msg, int argc, char **argv,
                     enum id_input id)
 {
@@ -598,7 +595,7 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
 
        if (!argc)
                return 0;
-       return set_interface_meshparam(state, cb, msg, argc, argv, id);
+       return set_interface_meshparam(state, msg, argc, argv, id);
  nla_put_failure:
        return -ENOBUFS;
 }
@@ -611,7 +608,7 @@ COMMAND(mesh, join, "<mesh ID> [[freq <freq in MHz> <HT20|HT40+|HT40-|NOHT>]"
        "mcast-rate and mesh parameters. Basic-rates are applied only if\n"
        "frequency is provided.");
 
-static int leave_mesh(struct nl80211_state *state, struct nl_cb *cb,
+static int leave_mesh(struct nl80211_state *state,
                      struct nl_msg *msg, int argc, char **argv,
                      enum id_input id)
 {
diff --git a/mpath.c b/mpath.c
index 25c538af0443c75b8d20b79d3a64b3d74749a815..ff0b7419fd2be08888b7801956f9967a36b6fbb0 100644 (file)
--- a/mpath.c
+++ b/mpath.c
@@ -91,7 +91,6 @@ static int print_mpath_handler(struct nl_msg *msg, void *arg)
 }
 
 static int handle_mpath_get(struct nl80211_state *state,
-                           struct nl_cb *cb,
                            struct nl_msg *msg,
                            int argc, char **argv,
                            enum id_input id)
@@ -113,7 +112,7 @@ static int handle_mpath_get(struct nl80211_state *state,
 
        NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst);
 
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_mpath_handler, NULL);
+       register_handler(print_mpath_handler, NULL);
 
        return 0;
  nla_put_failure:
@@ -127,7 +126,6 @@ COMMAND(mpath, del, "<MAC address>",
        "Remove the mesh path to the given node.");
 
 static int handle_mpath_set(struct nl80211_state *state,
-                           struct nl_cb *cb,
                            struct nl_msg *msg,
                            int argc, char **argv,
                            enum id_input id)
@@ -163,7 +161,7 @@ static int handle_mpath_set(struct nl80211_state *state,
        NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst);
        NLA_PUT(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop);
 
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_mpath_handler, NULL);
+       register_handler(print_mpath_handler, NULL);
        return 0;
  nla_put_failure:
        return -ENOBUFS;
@@ -176,14 +174,13 @@ COMMAND(mpath, set, "<destination MAC address> next_hop <next hop MAC address>",
        "Set an existing mesh path's next hop.");
 
 static int handle_mpath_dump(struct nl80211_state *state,
-                            struct nl_cb *cb,
                             struct nl_msg *msg,
                             int argc, char **argv,
                             enum id_input id)
 {
        printf("DEST ADDR         NEXT HOP          IFACE\tSN\tMETRIC\tQLEN\t"
               "EXPTIME\t\tDTIM\tDRET\tFLAGS\n");
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_mpath_handler, NULL);
+       register_handler(print_mpath_handler, NULL);
        return 0;
 }
 COMMAND(mpath, dump, NULL,
diff --git a/mpp.c b/mpp.c
index 2d20d6bf98027e7294211e873db416598329c344..8859fd542cf6bf7d6b3a9cc7ea3fba13f130f54d 100644 (file)
--- a/mpp.c
+++ b/mpp.c
@@ -37,7 +37,6 @@ static int print_mpp_handler(struct nl_msg *msg, void *arg)
 }
 
 static int handle_mpp_get(struct nl80211_state *state,
-                         struct nl_cb *cb,
                          struct nl_msg *msg,
                          int argc, char **argv,
                          enum id_input id)
@@ -59,7 +58,7 @@ static int handle_mpp_get(struct nl80211_state *state,
 
        NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst);
 
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_mpp_handler, NULL);
+       register_handler(print_mpp_handler, NULL);
 
        return 0;
  nla_put_failure:
@@ -70,13 +69,12 @@ COMMAND(mpp, get, "<MAC address>",
        "Get information on mesh proxy path to the given node.");
 
 static int handle_mpp_dump(struct nl80211_state *state,
-                            struct nl_cb *cb,
                             struct nl_msg *msg,
                             int argc, char **argv,
                             enum id_input id)
 {
        printf("DEST ADDR         PROXY NODE        IFACE\n");
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_mpp_handler, NULL);
+       register_handler(print_mpp_handler, NULL);
        return 0;
 }
 COMMAND(mpp, dump, NULL,
diff --git a/ocb.c b/ocb.c
index 7da05d164d1e82006d5833db99a4711377a3a7e9..fc48ecfcf29b7713fa79b2b0dedc8393830470a2 100644 (file)
--- a/ocb.c
+++ b/ocb.c
@@ -7,7 +7,7 @@
 
 SECTION(ocb);
 
-static int join_ocb(struct nl80211_state *state, struct nl_cb *cb,
+static int join_ocb(struct nl80211_state *state,
                    struct nl_msg *msg, int argc, char **argv,
                    enum id_input id)
 {
@@ -63,7 +63,7 @@ COMMAND(ocb, join, "<freq in MHz> <5MHZ|10MHZ>",
        NL80211_CMD_JOIN_OCB, 0, CIB_NETDEV, join_ocb,
        "Join the OCB mode network.");
 
-static int leave_ocb(struct nl80211_state *state, struct nl_cb *cb,
+static int leave_ocb(struct nl80211_state *state,
                     struct nl_msg *msg, int argc, char **argv,
                     enum id_input id)
 {
diff --git a/offch.c b/offch.c
index d8c67c0328af638b8e6f82517234676690cc6fc2..49b101a66001ded5e7cfe0622d7ca025084ea678 100644 (file)
--- a/offch.c
+++ b/offch.c
@@ -9,7 +9,7 @@
 #include "nl80211.h"
 #include "iw.h"
 
-static int offchannel(struct nl80211_state *state, struct nl_cb *cb,
+static int offchannel(struct nl80211_state *state,
                      struct nl_msg *msg, int argc, char **argv,
                      enum id_input id)
 {
diff --git a/p2p.c b/p2p.c
index addb740fad18d45ec3070a733af06628c50b1348..bcfa01c5ad880835141e7c93e5c0e00b672424c0 100644 (file)
--- a/p2p.c
+++ b/p2p.c
@@ -13,7 +13,7 @@
 
 SECTION(p2p);
 
-static int handle_p2p_start(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_p2p_start(struct nl80211_state *state,
                            struct nl_msg *msg, int argc, char **argv,
                            enum id_input id)
 {
@@ -21,7 +21,7 @@ static int handle_p2p_start(struct nl80211_state *state, struct nl_cb *cb,
 }
 COMMAND(p2p, start, "", NL80211_CMD_START_P2P_DEVICE, 0, CIB_WDEV, handle_p2p_start, "");
 
-static int handle_p2p_stop(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_p2p_stop(struct nl80211_state *state,
                           struct nl_msg *msg, int argc, char **argv,
                           enum id_input id)
 {
diff --git a/phy.c b/phy.c
index 271c9d9429eb96411e0b63b27d4f072a4c6ec4f8..19f9cebd2587fd15d1b37fd1def403700afb55ca 100644 (file)
--- a/phy.c
+++ b/phy.c
@@ -16,7 +16,6 @@
 #include "iw.h"
 
 static int handle_name(struct nl80211_state *state,
-                      struct nl_cb *cb,
                       struct nl_msg *msg,
                       int argc, char **argv,
                       enum id_input id)
@@ -144,8 +143,7 @@ static int handle_freqchan(struct nl_msg *msg, bool chan,
        return -ENOBUFS;
 }
 
-static int handle_freq(struct nl80211_state *state,
-                      struct nl_cb *cb, struct nl_msg *msg,
+static int handle_freq(struct nl80211_state *state, struct nl_msg *msg,
                       int argc, char **argv,
                       enum id_input id)
 {
@@ -159,8 +157,7 @@ COMMAND(set, freq, "<freq> [HT20|HT40+|HT40-]\n"
                   "<control freq> [20|40|80|80+80|160] [<center freq 1>] [<center freq 2>]",
        NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_freq, NULL);
 
-static int handle_chan(struct nl80211_state *state,
-                      struct nl_cb *cb, struct nl_msg *msg,
+static int handle_chan(struct nl80211_state *state, struct nl_msg *msg,
                       int argc, char **argv,
                       enum id_input id)
 {
@@ -172,7 +169,7 @@ COMMAND(set, channel, "<channel> [HT20|HT40+|HT40-]",
        NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_chan, NULL);
 
 static int handle_fragmentation(struct nl80211_state *state,
-                               struct nl_cb *cb, struct nl_msg *msg,
+                               struct nl_msg *msg,
                                int argc, char **argv,
                                enum id_input id)
 {
@@ -204,7 +201,7 @@ COMMAND(set, frag, "<fragmentation threshold|off>",
        "Set fragmentation threshold.");
 
 static int handle_rts(struct nl80211_state *state,
-                     struct nl_cb *cb, struct nl_msg *msg,
+                     struct nl_msg *msg,
                      int argc, char **argv,
                      enum id_input id)
 {
@@ -236,7 +233,7 @@ COMMAND(set, rts, "<rts threshold|off>",
        "Set rts threshold.");
 
 static int handle_retry(struct nl80211_state *state,
-                       struct nl_cb *cb, struct nl_msg *msg,
+                       struct nl_msg *msg,
                        int argc, char **argv, enum id_input id)
 {
        unsigned int retry_short = 0, retry_long = 0;
@@ -318,7 +315,6 @@ int netns_get_fd(const char *name)
 }
 
 static int handle_netns(struct nl80211_state *state,
-                       struct nl_cb *cb,
                        struct nl_msg *msg,
                        int argc, char **argv,
                        enum id_input id)
@@ -362,7 +358,6 @@ COMMAND(set, netns, "{ <pid> | name <nsname> }",
        "               or by absolute path (man ip-netns)\n");
 
 static int handle_coverage(struct nl80211_state *state,
-                       struct nl_cb *cb,
                        struct nl_msg *msg,
                        int argc, char **argv,
                        enum id_input id)
@@ -394,7 +389,6 @@ COMMAND(set, coverage, "<coverage class>",
        "Valid values: 0 - 255.");
 
 static int handle_distance(struct nl80211_state *state,
-                       struct nl_cb *cb,
                        struct nl_msg *msg,
                        int argc, char **argv,
                        enum id_input id)
@@ -442,7 +436,6 @@ COMMAND(set, distance, "<auto|distance>",
        "Valid values: 0 - 114750");
 
 static int handle_txpower(struct nl80211_state *state,
-                         struct nl_cb *cb,
                          struct nl_msg *msg,
                          int argc, char **argv,
                          enum id_input id)
@@ -494,7 +487,6 @@ COMMAND(set, txpower, "<auto|fixed|limit> [<tx power in mBm>]",
        "Specify transmit power level and setting type.");
 
 static int handle_antenna(struct nl80211_state *state,
-                         struct nl_cb *cb,
                          struct nl_msg *msg,
                          int argc, char **argv,
                          enum id_input id)
diff --git a/ps.c b/ps.c
index 4c8e2d1904859384d2cf81998ee0888f63651129..b774b7e5da22d93e0d7c340adadced2f47dcb60a 100644 (file)
--- a/ps.c
+++ b/ps.c
@@ -9,7 +9,6 @@
 #include "iw.h"
 
 static int set_power_save(struct nl80211_state *state,
-                         struct nl_cb *cb,
                          struct nl_msg *msg,
                          int argc, char **argv,
                          enum id_input id)
@@ -70,13 +69,11 @@ static int print_power_save_handler(struct nl_msg *msg, void *arg)
 }
 
 static int get_power_save(struct nl80211_state *state,
-                                  struct nl_cb *cb,
-                                  struct nl_msg *msg,
-                                  int argc, char **argv,
-                                  enum id_input id)
+                         struct nl_msg *msg,
+                         int argc, char **argv,
+                         enum id_input id)
 {
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
-                 print_power_save_handler, NULL);
+       register_handler(print_power_save_handler, NULL);
        return 0;
 }
 
diff --git a/reg.c b/reg.c
index 0aef7baa39929bd720c0fa03c5f61a01f68ad9d7..79843aac7e0e1d7dae2dab2103972e86ad60bd73 100644 (file)
--- a/reg.c
+++ b/reg.c
@@ -76,7 +76,6 @@ static const char *dfs_domain_name(enum nl80211_dfs_regions region)
 }
 
 static int handle_reg_set(struct nl80211_state *state,
-                         struct nl_cb *cb,
                          struct nl_msg *msg,
                          int argc, char **argv,
                          enum id_input id)
@@ -229,17 +228,15 @@ static int print_reg_handler(struct nl_msg *msg, void *arg)
 }
 
 static int handle_reg_dump(struct nl80211_state *state,
-                          struct nl_cb *cb,
                           struct nl_msg *msg,
                           int argc, char **argv,
                           enum id_input id)
 {
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_reg_handler, NULL);
+       register_handler(print_reg_handler, NULL);
        return 0;
 }
 
 static int handle_reg_get(struct nl80211_state *state,
-                         struct nl_cb *cb,
                          struct nl_msg *msg,
                          int argc, char **argv,
                          enum id_input id)
@@ -250,7 +247,7 @@ static int handle_reg_get(struct nl80211_state *state,
        err = handle_cmd(state, CIB_NONE, 2, dump_args);
        /* dump might fail since it's not supported on older kernels */
        if (err == -EOPNOTSUPP) {
-               nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_reg_handler,
+               register_handler(print_reg_handler,
                          NULL);
                return 0;
        }
diff --git a/roc.c b/roc.c
index c2beb96e56326a81a52c1cc155ef6b4af513a005..ef2bf166a3cb89cf2f8a0e13f2fcb78d6d1b7876 100644 (file)
--- a/roc.c
+++ b/roc.c
@@ -13,7 +13,7 @@
 
 SECTION(roc);
 
-static int handle_roc_start(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_roc_start(struct nl80211_state *state,
                            struct nl_msg *msg, int argc, char **argv,
                            enum id_input id)
 {
diff --git a/scan.c b/scan.c
index bf39f34be3141a4de01922ae6443e0932e3ad51a..5f0a2a9fd469aeaafa89b9fbdbaef7bcca722590 100644 (file)
--- a/scan.c
+++ b/scan.c
@@ -337,7 +337,6 @@ out:
 }
 
 static int handle_scan(struct nl80211_state *state,
-                      struct nl_cb *cb,
                       struct nl_msg *msg,
                       int argc, char **argv,
                       enum id_input id)
@@ -1970,7 +1969,6 @@ static int print_bss_handler(struct nl_msg *msg, void *arg)
 static struct scan_params scan_params;
 
 static int handle_scan_dump(struct nl80211_state *state,
-                           struct nl_cb *cb,
                            struct nl_msg *msg,
                            int argc, char **argv,
                            enum id_input id)
@@ -1987,13 +1985,12 @@ static int handle_scan_dump(struct nl80211_state *state,
 
        scan_params.type = PRINT_SCAN;
 
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_bss_handler,
+       register_handler(print_bss_handler,
                  &scan_params);
        return 0;
 }
 
 static int handle_scan_combined(struct nl80211_state *state,
-                               struct nl_cb *cb,
                                struct nl_msg *msg,
                                int argc, char **argv,
                                enum id_input id)
@@ -2085,13 +2082,13 @@ COMMAND(scan, trigger, "[freq <freq>*] [ies <hex as 00:11:..>] [meshid <meshid>]
 
 
 static int handle_start_sched_scan(struct nl80211_state *state,
-                                  struct nl_cb *cb, struct nl_msg *msg,
+                                  struct nl_msg *msg,
                                   int argc, char **argv, enum id_input id)
 {
        return parse_sched_scan(msg, &argc, &argv);
 }
 
-static int handle_stop_sched_scan(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_stop_sched_scan(struct nl80211_state *state,
                                  struct nl_msg *msg, int argc, char **argv,
                                  enum id_input id)
 {
index 894d978f049110770fc955b3225a6c525fbfccb3..b5ccf4a6f65a0435816509c2bde92be70a2fa334 100644 (file)
--- a/station.c
+++ b/station.c
@@ -347,7 +347,6 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
 }
 
 static int handle_station_get(struct nl80211_state *state,
-                             struct nl_cb *cb,
                              struct nl_msg *msg,
                              int argc, char **argv,
                              enum id_input id)
@@ -370,7 +369,7 @@ static int handle_station_get(struct nl80211_state *state,
 
        NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
 
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_sta_handler, NULL);
+       register_handler(print_sta_handler, NULL);
 
        return 0;
  nla_put_failure:
@@ -401,7 +400,6 @@ static const struct cmd *select_station_cmd(int argc, char **argv)
 }
 
 static int handle_station_set_plink(struct nl80211_state *state,
-                             struct nl_cb *cb,
                              struct nl_msg *msg,
                              int argc, char **argv,
                              enum id_input id)
@@ -451,7 +449,6 @@ COMMAND_ALIAS(station, set, "<MAC address> plink_action <open|block>",
        select_station_cmd, station_set_plink);
 
 static int handle_station_set_vlan(struct nl80211_state *state,
-                                  struct nl_cb *cb,
                                   struct nl_msg *msg,
                                   int argc, char **argv,
                                   enum id_input id)
@@ -499,7 +496,6 @@ COMMAND_ALIAS(station, set, "<MAC address> vlan <ifindex>",
        select_station_cmd, station_set_vlan);
 
 static int handle_station_set_mesh_power_mode(struct nl80211_state *state,
-                                             struct nl_cb *cb,
                                              struct nl_msg *msg,
                                              int argc, char **argv,
                                              enum id_input id)
@@ -552,12 +548,11 @@ COMMAND_ALIAS(station, set, "<MAC address> mesh_power_mode "
        select_station_cmd, station_set_mesh_power_mode);
 
 static int handle_station_dump(struct nl80211_state *state,
-                              struct nl_cb *cb,
                               struct nl_msg *msg,
                               int argc, char **argv,
                               enum id_input id)
 {
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_sta_handler, NULL);
+       register_handler(print_sta_handler, NULL);
        return 0;
 }
 COMMAND(station, dump, NULL,
index 39cd7b8cd1531dfa8b48318ac4dde1903f2a987d..3e875a83c6155426323fcb46bf89aa601f550952 100644 (file)
--- a/survey.c
+++ b/survey.c
@@ -69,12 +69,11 @@ static int print_survey_handler(struct nl_msg *msg, void *arg)
 }
 
 static int handle_survey_dump(struct nl80211_state *state,
-                             struct nl_cb *cb,
                              struct nl_msg *msg,
                              int argc, char **argv,
                              enum id_input id)
 {
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_survey_handler, NULL);
+       register_handler(print_survey_handler, NULL);
        return 0;
 }
 COMMAND(survey, dump, NULL,
index f32c00b7cbfcbcc3b424c06fcbfc5f201feb6715..5a693753f9498890309ab3376a167a2273c575de 100644 (file)
--- a/vendor.c
+++ b/vendor.c
@@ -45,7 +45,7 @@ static int read_hex(int argc, char **argv, char *buf, size_t size)
        return argc;
 }
 
-static int handle_vendor(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_vendor(struct nl80211_state *state,
                         struct nl_msg *msg, int argc, char **argv,
                         enum id_input id)
 {
index 203014babc4a3945757501d7b7ee420e898f2c87..d3b565c3958ac9dcb95a0426f8bb33ae3e675e06 100644 (file)
--- a/wowlan.c
+++ b/wowlan.c
@@ -197,7 +197,7 @@ static int wowlan_parse_net_detect(struct nl_msg *msg, int *argc, char ***argv)
        return err;
 }
 
-static int handle_wowlan_enable(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_wowlan_enable(struct nl80211_state *state,
                                struct nl_msg *msg, int argc, char **argv,
                                enum id_input id)
 {
@@ -334,7 +334,7 @@ COMMAND(wowlan, enable, "[any] [disconnect] [magic-packet] [gtk-rekey-failure] [
        " iw phy0 wowlan enable net-detect interval 5000 delay 30 freqs 2412 2422 matches ssid foo ssid bar");
 
 
-static int handle_wowlan_disable(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_wowlan_disable(struct nl80211_state *state,
                                 struct nl_msg *msg, int argc, char **argv,
                                 enum id_input id)
 {
@@ -470,12 +470,11 @@ static int print_wowlan_handler(struct nl_msg *msg, void *arg)
        return NL_SKIP;
 }
 
-static int handle_wowlan_show(struct nl80211_state *state, struct nl_cb *cb,
+static int handle_wowlan_show(struct nl80211_state *state,
                              struct nl_msg *msg, int argc, char **argv,
                              enum id_input id)
 {
-       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
-                 print_wowlan_handler, NULL);
+       register_handler(print_wowlan_handler, NULL);
 
        return 0;
 }