]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
split out multicast group adding
authorJohannes Berg <johannes@sipsolutions.net>
Wed, 9 Jun 2010 09:50:07 +0000 (11:50 +0200)
committerJohannes Berg <johannes@sipsolutions.net>
Wed, 9 Jun 2010 09:50:07 +0000 (11:50 +0200)
event.c

diff --git a/event.c b/event.c
index 8133cb87babe8cabc2fbba1fe0908b9994ec4d75..2f61f511d1c3ed1ba73fef22cae73639dfd8600e 100644 (file)
--- a/event.c
+++ b/event.c
@@ -377,18 +377,9 @@ static int wait_event(struct nl_msg *msg, void *arg)
        return NL_SKIP;
 }
 
-__u32 __listen_events(struct nl80211_state *state,
-                     const int n_waits, const __u32 *waits,
-                     struct print_event_args *args)
+static int __prepare_listen_events(struct nl80211_state *state)
 {
        int mcid, ret;
-       struct nl_cb *cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
-       struct wait_event wait_ev;
-
-       if (!cb) {
-               fprintf(stderr, "failed to allocate netlink callbacks\n");
-               return -ENOMEM;
-       }
 
        /* Configuration multicast group */
        mcid = nl_get_multicast_id(state->nl_sock, "nl80211", "config");
@@ -423,6 +414,26 @@ __u32 __listen_events(struct nl80211_state *state,
                        return ret;
        }
 
+       return 0;
+}
+
+__u32 __listen_events(struct nl80211_state *state,
+                     const int n_waits, const __u32 *waits,
+                     struct print_event_args *args)
+{
+       struct nl_cb *cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
+       struct wait_event wait_ev;
+       int ret;
+
+       if (!cb) {
+               fprintf(stderr, "failed to allocate netlink callbacks\n");
+               return -ENOMEM;
+       }
+
+       ret = __prepare_listen_events(state);
+       if (ret)
+               return ret;
+
        /* no sequence checking for multicast messages */
        nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);