diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c index 4e6d30189..12ccaaa08 100644 --- a/src/ap/sta_info.c +++ b/src/ap/sta_info.c @@ -883,8 +883,8 @@ void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta, if (hapd->msg_ctx_parent && hapd->msg_ctx_parent != hapd->msg_ctx) - wpa_msg(hapd->msg_ctx_parent, MSG_INFO, - AP_STA_CONNECTED "%s", buf); + wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO, + AP_STA_CONNECTED "%s", buf); sta->flags |= WLAN_STA_AUTHORIZED; } else { @@ -892,8 +892,8 @@ void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta, if (hapd->msg_ctx_parent && hapd->msg_ctx_parent != hapd->msg_ctx) - wpa_msg(hapd->msg_ctx_parent, MSG_INFO, - AP_STA_DISCONNECTED "%s", buf); + wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO, + AP_STA_DISCONNECTED "%s", buf); sta->flags &= ~WLAN_STA_AUTHORIZED; } diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c index 75cb473e1..38ea8aa38 100644 --- a/src/utils/wpa_debug.c +++ b/src/utils/wpa_debug.c @@ -671,6 +671,29 @@ void wpa_msg_global(void *ctx, int level, const char *fmt, ...) os_free(buf); } + +void wpa_msg_no_global(void *ctx, int level, const char *fmt, ...) +{ + va_list ap; + char *buf; + const int buflen = 2048; + int len; + + buf = os_malloc(buflen); + if (buf == NULL) { + wpa_printf(MSG_ERROR, "wpa_msg_no_global: Failed to allocate " + "message buffer"); + return; + } + va_start(ap, fmt); + len = vsnprintf(buf, buflen, fmt, ap); + va_end(ap); + wpa_printf(level, "%s", buf); + if (wpa_msg_cb) + wpa_msg_cb(ctx, level, 2, buf, len); + os_free(buf); +} + #endif /* CONFIG_NO_WPA_MSG */ diff --git a/src/utils/wpa_debug.h b/src/utils/wpa_debug.h index 4b60898fe..2ed1bd8ec 100644 --- a/src/utils/wpa_debug.h +++ b/src/utils/wpa_debug.h @@ -156,6 +156,7 @@ void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf, #define wpa_msg(args...) do { } while (0) #define wpa_msg_ctrl(args...) do { } while (0) #define wpa_msg_global(args...) do { } while (0) +#define wpa_msg_no_global(args...) do { } while (0) #define wpa_msg_register_cb(f) do { } while (0) #define wpa_msg_register_ifname_cb(f) do { } while (0) #else /* CONFIG_NO_WPA_MSG */ @@ -206,6 +207,20 @@ PRINTF_FORMAT(3, 4); void wpa_msg_global(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4); +/** + * wpa_msg_no_global - Conditional printf for ctrl_iface monitors + * @ctx: Pointer to context data; this is the ctx variable registered + * with struct wpa_driver_ops::init() + * @level: priority level (MSG_*) of the message + * @fmt: printf format string, followed by optional arguments + * + * This function is used to print conditional debugging and error messages. + * This function is like wpa_msg(), but it does not send the output as a global + * event. + */ +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, const char *txt, size_t len); diff --git a/wpa_supplicant/ctrl_iface_unix.c b/wpa_supplicant/ctrl_iface_unix.c index aa71aff3d..1b4b9b0c3 100644 --- a/wpa_supplicant/ctrl_iface_unix.c +++ b/wpa_supplicant/ctrl_iface_unix.c @@ -258,7 +258,7 @@ static void wpa_supplicant_ctrl_iface_msg_cb(void *ctx, int level, int global, if (wpa_s == NULL) return; - if (wpa_s->global->ctrl_iface) { + if (global != 2 && 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(global ? NULL :