]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
Add send callbacks with optional debug handler
authorSean Robinson <seankrobinson@gmail.com>
Thu, 17 Mar 2011 14:58:41 +0000 (07:58 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 17 Mar 2011 19:49:42 +0000 (20:49 +0100)
libnl supports callbacks for send and recv.  This patch enables callbacks
for sent messages and uses the debug callback for the --debug option, as
the recv callbacks do.

Signed-off-by: Sean Robinson <seankrobinson@gmail.com>
iw.c

diff --git a/iw.c b/iw.c
index 2593481451ea54f545cec7c7b6994aa601fdf95a..50c3a4205515dba18bfafae5311e76aea1c5c7da 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -259,6 +259,7 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
 {
        const struct cmd *cmd, *match = NULL, *sectcmd;
        struct nl_cb *cb;
+       struct nl_cb *s_cb;
        struct nl_msg *msg;
        int devidx = 0;
        int err, o_argc;
@@ -380,7 +381,8 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
        }
 
        cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
-       if (!cb) {
+       s_cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
+       if (!cb || !s_cb) {
                fprintf(stderr, "failed to allocate netlink callbacks\n");
                err = 2;
                goto out_free_msg;
@@ -404,6 +406,8 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
        if (err)
                goto out;
 
+       nl_socket_set_cb(state->nl_sock, s_cb);
+
        err = nl_send_auto_complete(state->nl_sock, msg);
        if (err < 0)
                goto out;