2012-02-20 23:41:52 +00:00
|
|
|
--- a/src/utils/wpa_debug.c
|
|
|
|
+++ b/src/utils/wpa_debug.c
|
2012-04-29 11:14:53 +00:00
|
|
|
@@ -201,7 +201,7 @@ void wpa_debug_close_linux_tracing(void)
|
2012-02-20 23:41:52 +00:00
|
|
|
*
|
|
|
|
* Note: New line '\n' is added to the end of the text when printing to stdout.
|
|
|
|
*/
|
|
|
|
-void wpa_printf(int level, const char *fmt, ...)
|
|
|
|
+void _wpa_printf(int level, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
2012-04-29 11:14:53 +00:00
|
|
|
@@ -248,8 +248,8 @@ void wpa_printf(int level, const char *f
|
2012-02-20 23:41:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-static void _wpa_hexdump(int level, const char *title, const u8 *buf,
|
|
|
|
- size_t len, int show)
|
|
|
|
+void _wpa_hexdump(int level, const char *title, const u8 *buf,
|
|
|
|
+ size_t len, int show)
|
|
|
|
{
|
|
|
|
size_t i;
|
2012-04-29 11:14:53 +00:00
|
|
|
|
|
|
|
@@ -375,20 +375,9 @@ static void _wpa_hexdump(int level, cons
|
2012-03-27 10:42:47 +00:00
|
|
|
#endif /* CONFIG_ANDROID_LOG */
|
2012-02-20 23:41:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len)
|
|
|
|
-{
|
|
|
|
- _wpa_hexdump(level, title, buf, len, 1);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
|
|
|
|
-{
|
|
|
|
- _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys);
|
|
|
|
-}
|
|
|
|
|
|
|
|
-
|
|
|
|
-static void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
|
|
|
|
- size_t len, int show)
|
|
|
|
+void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
|
|
|
|
+ size_t len, int show)
|
|
|
|
{
|
|
|
|
size_t i, llen;
|
|
|
|
const u8 *pos = buf;
|
2012-04-29 11:14:53 +00:00
|
|
|
@@ -495,19 +484,6 @@ static void _wpa_hexdump_ascii(int level
|
2012-02-20 23:41:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-void wpa_hexdump_ascii(int level, const char *title, const u8 *buf, size_t len)
|
|
|
|
-{
|
|
|
|
- _wpa_hexdump_ascii(level, title, buf, len, 1);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
|
|
|
|
- size_t len)
|
|
|
|
-{
|
|
|
|
- _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
#ifdef CONFIG_DEBUG_FILE
|
|
|
|
static char *last_path = NULL;
|
|
|
|
#endif /* CONFIG_DEBUG_FILE */
|
2012-04-29 11:14:53 +00:00
|
|
|
@@ -591,7 +567,7 @@ void wpa_msg_register_ifname_cb(wpa_msg_
|
2012-02-20 23:41:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-void wpa_msg(void *ctx, int level, const char *fmt, ...)
|
|
|
|
+void _wpa_msg(void *ctx, int level, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
char *buf;
|
2012-04-29 11:14:53 +00:00
|
|
|
@@ -625,7 +601,7 @@ void wpa_msg(void *ctx, int level, const
|
2012-02-20 23:41:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
|
|
|
|
+void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
char *buf;
|
|
|
|
--- a/src/utils/wpa_debug.h
|
|
|
|
+++ b/src/utils/wpa_debug.h
|
2012-03-27 10:42:47 +00:00
|
|
|
@@ -43,6 +43,17 @@ int wpa_debug_open_file(const char *path
|
2012-02-20 23:41:52 +00:00
|
|
|
int wpa_debug_reopen_file(void);
|
|
|
|
void wpa_debug_close_file(void);
|
|
|
|
|
|
|
|
+/* internal */
|
|
|
|
+void _wpa_hexdump(int level, const char *title, const u8 *buf,
|
|
|
|
+ size_t len, int show);
|
|
|
|
+void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
|
|
|
|
+ size_t len, int show);
|
|
|
|
+extern int wpa_debug_show_keys;
|
|
|
|
+
|
|
|
|
+#ifndef CONFIG_MSG_MIN_PRIORITY
|
|
|
|
+#define CONFIG_MSG_MIN_PRIORITY 0
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
/**
|
|
|
|
* wpa_debug_printf_timestamp - Print timestamp for debug output
|
|
|
|
*
|
2012-03-27 10:42:47 +00:00
|
|
|
@@ -63,9 +74,15 @@ void wpa_debug_print_timestamp(void);
|
2012-02-20 23:41:52 +00:00
|
|
|
*
|
|
|
|
* Note: New line '\n' is added to the end of the text when printing to stdout.
|
|
|
|
*/
|
|
|
|
-void wpa_printf(int level, const char *fmt, ...)
|
|
|
|
+void _wpa_printf(int level, const char *fmt, ...)
|
|
|
|
PRINTF_FORMAT(2, 3);
|
|
|
|
|
|
|
|
+#define wpa_printf(level, ...) \
|
|
|
|
+ do { \
|
|
|
|
+ if (level >= CONFIG_MSG_MIN_PRIORITY) \
|
|
|
|
+ _wpa_printf(level, __VA_ARGS__); \
|
|
|
|
+ } while(0)
|
|
|
|
+
|
|
|
|
/**
|
|
|
|
* wpa_hexdump - conditional hex dump
|
|
|
|
* @level: priority level (MSG_*) of the message
|
2012-03-27 10:42:47 +00:00
|
|
|
@@ -77,7 +94,13 @@ PRINTF_FORMAT(2, 3);
|
2012-02-20 23:41:52 +00:00
|
|
|
* output may be directed to stdout, stderr, and/or syslog based on
|
|
|
|
* configuration. The contents of buf is printed out has hex dump.
|
|
|
|
*/
|
|
|
|
-void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len);
|
|
|
|
+static inline void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len)
|
|
|
|
+{
|
|
|
|
+ if (level < CONFIG_MSG_MIN_PRIORITY)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ _wpa_hexdump(level, title, buf, len, 1);
|
|
|
|
+}
|
|
|
|
|
|
|
|
static inline void wpa_hexdump_buf(int level, const char *title,
|
|
|
|
const struct wpabuf *buf)
|
2012-03-27 10:42:47 +00:00
|
|
|
@@ -99,7 +122,13 @@ static inline void wpa_hexdump_buf(int l
|
2012-02-20 23:41:52 +00:00
|
|
|
* like wpa_hexdump(), but by default, does not include secret keys (passwords,
|
|
|
|
* etc.) in debug output.
|
|
|
|
*/
|
|
|
|
-void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len);
|
|
|
|
+static inline void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
|
|
|
|
+{
|
|
|
|
+ if (level < CONFIG_MSG_MIN_PRIORITY)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys);
|
|
|
|
+}
|
|
|
|
|
|
|
|
static inline void wpa_hexdump_buf_key(int level, const char *title,
|
|
|
|
const struct wpabuf *buf)
|
2012-03-27 10:42:47 +00:00
|
|
|
@@ -121,8 +150,14 @@ static inline void wpa_hexdump_buf_key(i
|
2012-02-20 23:41:52 +00:00
|
|
|
* the hex numbers and ASCII characters (for printable range) are shown. 16
|
|
|
|
* bytes per line will be shown.
|
|
|
|
*/
|
|
|
|
-void wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
|
|
|
|
- size_t len);
|
|
|
|
+static inline void wpa_hexdump_ascii(int level, const char *title,
|
|
|
|
+ const u8 *buf, size_t len)
|
|
|
|
+{
|
|
|
|
+ if (level < CONFIG_MSG_MIN_PRIORITY)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ _wpa_hexdump_ascii(level, title, buf, len, 1);
|
|
|
|
+}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpa_hexdump_ascii_key - conditional hex dump, hide keys
|
2012-03-27 10:42:47 +00:00
|
|
|
@@ -138,8 +173,14 @@ void wpa_hexdump_ascii(int level, const
|
2012-02-20 23:41:52 +00:00
|
|
|
* bytes per line will be shown. This works like wpa_hexdump_ascii(), but by
|
|
|
|
* default, does not include secret keys (passwords, etc.) in debug output.
|
|
|
|
*/
|
|
|
|
-void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
|
|
|
|
- size_t len);
|
|
|
|
+static inline void wpa_hexdump_ascii_key(int level, const char *title,
|
|
|
|
+ const u8 *buf, size_t len)
|
|
|
|
+{
|
|
|
|
+ if (level < CONFIG_MSG_MIN_PRIORITY)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
|
|
|
|
+}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce
|
2012-03-27 10:42:47 +00:00
|
|
|
@@ -172,7 +213,12 @@ void wpa_hexdump_ascii_key(int level, co
|
2012-02-20 23:41:52 +00:00
|
|
|
*
|
|
|
|
* Note: New line '\n' is added to the end of the text when printing to stdout.
|
|
|
|
*/
|
|
|
|
-void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
|
|
|
|
+void _wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
|
|
|
|
+#define wpa_msg(ctx, level, ...) \
|
|
|
|
+ do { \
|
|
|
|
+ if (level >= CONFIG_MSG_MIN_PRIORITY) \
|
|
|
|
+ _wpa_msg(ctx, level, __VA_ARGS__); \
|
|
|
|
+ } while(0)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpa_msg_ctrl - Conditional printf for ctrl_iface monitors
|
2012-03-27 10:42:47 +00:00
|
|
|
@@ -186,8 +232,13 @@ void wpa_msg(void *ctx, int level, const
|
2012-02-20 23:41:52 +00:00
|
|
|
* attached 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_ctrl(void *ctx, int level, const char *fmt, ...)
|
|
|
|
+void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
|
|
|
|
PRINTF_FORMAT(3, 4);
|
|
|
|
+#define wpa_msg_ctrl(ctx, level, ...) \
|
|
|
|
+ do { \
|
|
|
|
+ if (level >= CONFIG_MSG_MIN_PRIORITY) \
|
|
|
|
+ _wpa_msg_ctrl(ctx, level, __VA_ARGS__); \
|
|
|
|
+ } while(0)
|
|
|
|
|
|
|
|
typedef void (*wpa_msg_cb_func)(void *ctx, int level, const char *txt,
|
|
|
|
size_t len);
|