]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Document the wpa_msg_cb "global" parameter
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 6 Feb 2015 10:08:28 +0000 (12:08 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 10 Jun 2015 13:02:00 +0000 (16:02 +0300)
Instead of an int variable with magic values 0, 1, 2, use an enum that
gives clearer meaning to the values now that the original boolean type
global argument is not really a boolean anymore.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
hostapd/ctrl_iface.c
src/utils/wpa_debug.c
src/utils/wpa_debug.h
wpa_supplicant/ctrl_iface_named_pipe.c
wpa_supplicant/ctrl_iface_udp.c
wpa_supplicant/ctrl_iface_unix.c

index 86f1aa6dfdb2f5381a473dca1de418587c6fe0bd..8ab29412bb40a6b955f1f57e6dc62ad746471191 100644 (file)
@@ -2130,7 +2130,8 @@ static char * hostapd_ctrl_iface_path(struct hostapd_data *hapd)
 }
 
 
-static void hostapd_ctrl_iface_msg_cb(void *ctx, int level, int global,
+static void hostapd_ctrl_iface_msg_cb(void *ctx, int level,
+                                     enum wpa_msg_type type,
                                      const char *txt, size_t len)
 {
        struct hostapd_data *hapd = ctx;
index 0d11905185365692dfa3dea2c3bf7776c6e9e958..82a899988f6fb815d985ab88c67b46a0557ca460 100644 (file)
@@ -635,7 +635,7 @@ void wpa_msg(void *ctx, int level, const char *fmt, ...)
        va_end(ap);
        wpa_printf(level, "%s%s", prefix, buf);
        if (wpa_msg_cb)
-               wpa_msg_cb(ctx, level, 0, buf, len);
+               wpa_msg_cb(ctx, level, WPA_MSG_PER_INTERFACE, buf, len);
        os_free(buf);
 }
 
@@ -663,7 +663,7 @@ void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
        va_start(ap, fmt);
        len = vsnprintf(buf, buflen, fmt, ap);
        va_end(ap);
-       wpa_msg_cb(ctx, level, 0, buf, len);
+       wpa_msg_cb(ctx, level, WPA_MSG_PER_INTERFACE, buf, len);
        os_free(buf);
 }
 
@@ -690,7 +690,7 @@ void wpa_msg_global(void *ctx, int level, const char *fmt, ...)
        va_end(ap);
        wpa_printf(level, "%s", buf);
        if (wpa_msg_cb)
-               wpa_msg_cb(ctx, level, 1, buf, len);
+               wpa_msg_cb(ctx, level, WPA_MSG_GLOBAL, buf, len);
        os_free(buf);
 }
 
@@ -718,7 +718,7 @@ void wpa_msg_global_ctrl(void *ctx, int level, const char *fmt, ...)
        va_start(ap, fmt);
        len = vsnprintf(buf, buflen, fmt, ap);
        va_end(ap);
-       wpa_msg_cb(ctx, level, 1, buf, len);
+       wpa_msg_cb(ctx, level, WPA_MSG_GLOBAL, buf, len);
        os_free(buf);
 }
 
@@ -745,7 +745,7 @@ void wpa_msg_no_global(void *ctx, int level, const char *fmt, ...)
        va_end(ap);
        wpa_printf(level, "%s", buf);
        if (wpa_msg_cb)
-               wpa_msg_cb(ctx, level, 2, buf, len);
+               wpa_msg_cb(ctx, level, WPA_MSG_NO_GLOBAL, buf, len);
        os_free(buf);
 }
 
index 400bea9e599fdedc3b6964d9b1146c85a2f86f61..5fdc50ef55400a405721268717a09247ddaad6c5 100644 (file)
@@ -243,7 +243,13 @@ PRINTF_FORMAT(3, 4);
 void wpa_msg_no_global(void *ctx, int level, const char *fmt, ...)
 PRINTF_FORMAT(3, 4);
 
-typedef void (*wpa_msg_cb_func)(void *ctx, int level, int global,
+enum wpa_msg_type {
+       WPA_MSG_PER_INTERFACE,
+       WPA_MSG_GLOBAL,
+       WPA_MSG_NO_GLOBAL,
+};
+
+typedef void (*wpa_msg_cb_func)(void *ctx, int level, enum wpa_msg_type type,
                                const char *txt, size_t len);
 
 /**
index dc02db213a486c0c6bdf57ecc20f9b6512e6ec1c..54e0e2fac58384c40fd72a5ba00ef3ca520ceed6 100644 (file)
@@ -423,7 +423,8 @@ static int ctrl_iface_parse(struct ctrl_iface_priv *priv, const char *params)
 }
 
 
-static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level, int global,
+static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level,
+                                            enum wpa_msg_type type,
                                             const char *txt, size_t len)
 {
        struct wpa_supplicant *wpa_s = ctx;
index bf6a3df6c3c51468db10fce40b75721a6423ee3f..76f69f2b57bb26aef03d672f754e36f87b20885e 100644 (file)
@@ -322,7 +322,8 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
 }
 
 
-static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level, int global,
+static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level,
+                                            enum wpa_msg_type type,
                                             const char *txt, size_t len)
 {
        struct wpa_supplicant *wpa_s = ctx;
index b1ac76668897e07e2aa286156cd6856811b6eff7..22001cf686b13a55765e1ce22a4297df3ab6c289 100644 (file)
@@ -295,7 +295,8 @@ static char * wpa_supplicant_ctrl_iface_path(struct wpa_supplicant *wpa_s)
 }
 
 
-static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level, int global,
+static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level,
+                                            enum wpa_msg_type type,
                                             const char *txt, size_t len)
 {
        struct wpa_supplicant *wpa_s = ctx;
@@ -303,15 +304,14 @@ static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level, int global,
        if (wpa_s == NULL)
                return;
 
-       if (global != 2 && wpa_s->global->ctrl_iface) {
+       if (type != WPA_MSG_NO_GLOBAL && wpa_s->global->ctrl_iface) {
                struct ctrl_iface_global_priv *priv = wpa_s->global->ctrl_iface;
                if (!dl_list_empty(&priv->ctrl_dst)) {
-                       wpa_supplicant_ctrl_iface_send(wpa_s, global ? NULL :
-                                                      wpa_s->ifname,
-                                                      priv->sock,
-                                                      &priv->ctrl_dst,
-                                                      level, txt, len, NULL,
-                                                      priv);
+                       wpa_supplicant_ctrl_iface_send(
+                               wpa_s,
+                               type == WPA_MSG_GLOBAL ? NULL : wpa_s->ifname,
+                               priv->sock, &priv->ctrl_dst, level, txt, len,
+                               NULL, priv);
                }
        }