]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add wpa_msg_global_ctrl()
authorJouni Malinen <j@w1.fi>
Sat, 26 Jul 2014 10:04:03 +0000 (13:04 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 26 Jul 2014 10:04:03 +0000 (13:04 +0300)
This is similar to wpa_msg_global() in the same way as wpa_msg_ctrl() is
to wpa_msg(). In other words, wpa_msg_global_ctrl() is used to send
global control interface events without printing them into the debug
log.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/utils/wpa_debug.c
src/utils/wpa_debug.h

index 647f6b4be72d0004c484ba38fb942d30c4cf8ada..68cbace6eba9128b21c894918d9e8de03fec9463 100644 (file)
@@ -685,6 +685,34 @@ void wpa_msg_global(void *ctx, int level, const char *fmt, ...)
 }
 
 
+void wpa_msg_global_ctrl(void *ctx, int level, const char *fmt, ...)
+{
+       va_list ap;
+       char *buf;
+       int buflen;
+       int len;
+
+       if (!wpa_msg_cb)
+               return;
+
+       va_start(ap, fmt);
+       buflen = vsnprintf(NULL, 0, fmt, ap) + 1;
+       va_end(ap);
+
+       buf = os_malloc(buflen);
+       if (buf == NULL) {
+               wpa_printf(MSG_ERROR,
+                          "wpa_msg_global_ctrl: Failed to allocate message buffer");
+               return;
+       }
+       va_start(ap, fmt);
+       len = vsnprintf(buf, buflen, fmt, ap);
+       va_end(ap);
+       wpa_msg_cb(ctx, level, 1, buf, len);
+       os_free(buf);
+}
+
+
 void wpa_msg_no_global(void *ctx, int level, const char *fmt, ...)
 {
        va_list ap;
index 50e8ae9d5589019f1fc15c11b8e8a643cb962732..391f1975011dfa1144cd79f976ce2213983d6223 100644 (file)
@@ -160,6 +160,7 @@ void wpa_hexdump_ascii_key(int level, const char *title, const void *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_global_ctrl(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)
@@ -211,6 +212,21 @@ PRINTF_FORMAT(3, 4);
 void wpa_msg_global(void *ctx, int level, const char *fmt, ...)
 PRINTF_FORMAT(3, 4);
 
+/**
+ * wpa_msg_global_ctrl - Conditional global 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_global(), but it sends the output only to the
+ * attached global ctrl_iface monitors. In other words, it can be used for
+ * frequent events that do not need to be sent to syslog.
+ */
+void wpa_msg_global_ctrl(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