1 --- a/src/utils/wpa_debug.c
2 +++ b/src/utils/wpa_debug.c
3 @@ -201,7 +201,7 @@ void wpa_debug_close_linux_tracing(void)
5 * Note: New line '\n' is added to the end of the text when printing to stdout.
7 -void wpa_printf(int level, const char *fmt, ...)
8 +void _wpa_printf(int level, const char *fmt, ...)
12 @@ -248,8 +248,8 @@ void wpa_printf(int level, const char *f
16 -static void _wpa_hexdump(int level, const char *title, const u8 *buf,
17 - size_t len, int show)
18 +void _wpa_hexdump(int level, const char *title, const u8 *buf,
19 + size_t len, int show)
23 @@ -375,20 +375,9 @@ static void _wpa_hexdump(int level, cons
24 #endif /* CONFIG_ANDROID_LOG */
27 -void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len)
29 - _wpa_hexdump(level, title, buf, len, 1);
33 -void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
35 - _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys);
39 -static void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
40 - size_t len, int show)
41 +void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
42 + size_t len, int show)
46 @@ -495,19 +484,6 @@ static void _wpa_hexdump_ascii(int level
50 -void wpa_hexdump_ascii(int level, const char *title, const u8 *buf, size_t len)
52 - _wpa_hexdump_ascii(level, title, buf, len, 1);
56 -void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
59 - _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
63 #ifdef CONFIG_DEBUG_FILE
64 static char *last_path = NULL;
65 #endif /* CONFIG_DEBUG_FILE */
66 @@ -591,7 +567,7 @@ void wpa_msg_register_ifname_cb(wpa_msg_
70 -void wpa_msg(void *ctx, int level, const char *fmt, ...)
71 +void _wpa_msg(void *ctx, int level, const char *fmt, ...)
75 @@ -625,7 +601,7 @@ void wpa_msg(void *ctx, int level, const
79 -void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
80 +void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
84 --- a/src/utils/wpa_debug.h
85 +++ b/src/utils/wpa_debug.h
86 @@ -43,6 +43,17 @@ int wpa_debug_open_file(const char *path
87 int wpa_debug_reopen_file(void);
88 void wpa_debug_close_file(void);
91 +void _wpa_hexdump(int level, const char *title, const u8 *buf,
92 + size_t len, int show);
93 +void _wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
94 + size_t len, int show);
95 +extern int wpa_debug_show_keys;
97 +#ifndef CONFIG_MSG_MIN_PRIORITY
98 +#define CONFIG_MSG_MIN_PRIORITY 0
102 * wpa_debug_printf_timestamp - Print timestamp for debug output
104 @@ -63,9 +74,15 @@ void wpa_debug_print_timestamp(void);
106 * Note: New line '\n' is added to the end of the text when printing to stdout.
108 -void wpa_printf(int level, const char *fmt, ...)
109 +void _wpa_printf(int level, const char *fmt, ...)
112 +#define wpa_printf(level, ...) \
114 + if (level >= CONFIG_MSG_MIN_PRIORITY) \
115 + _wpa_printf(level, __VA_ARGS__); \
119 * wpa_hexdump - conditional hex dump
120 * @level: priority level (MSG_*) of the message
121 @@ -77,7 +94,13 @@ PRINTF_FORMAT(2, 3);
122 * output may be directed to stdout, stderr, and/or syslog based on
123 * configuration. The contents of buf is printed out has hex dump.
125 -void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len);
126 +static inline void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len)
128 + if (level < CONFIG_MSG_MIN_PRIORITY)
131 + _wpa_hexdump(level, title, buf, len, 1);
134 static inline void wpa_hexdump_buf(int level, const char *title,
135 const struct wpabuf *buf)
136 @@ -99,7 +122,13 @@ static inline void wpa_hexdump_buf(int l
137 * like wpa_hexdump(), but by default, does not include secret keys (passwords,
138 * etc.) in debug output.
140 -void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len);
141 +static inline void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
143 + if (level < CONFIG_MSG_MIN_PRIORITY)
146 + _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys);
149 static inline void wpa_hexdump_buf_key(int level, const char *title,
150 const struct wpabuf *buf)
151 @@ -121,8 +150,14 @@ static inline void wpa_hexdump_buf_key(i
152 * the hex numbers and ASCII characters (for printable range) are shown. 16
153 * bytes per line will be shown.
155 -void wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
157 +static inline void wpa_hexdump_ascii(int level, const char *title,
158 + const u8 *buf, size_t len)
160 + if (level < CONFIG_MSG_MIN_PRIORITY)
163 + _wpa_hexdump_ascii(level, title, buf, len, 1);
167 * wpa_hexdump_ascii_key - conditional hex dump, hide keys
168 @@ -138,8 +173,14 @@ void wpa_hexdump_ascii(int level, const
169 * bytes per line will be shown. This works like wpa_hexdump_ascii(), but by
170 * default, does not include secret keys (passwords, etc.) in debug output.
172 -void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
174 +static inline void wpa_hexdump_ascii_key(int level, const char *title,
175 + const u8 *buf, size_t len)
177 + if (level < CONFIG_MSG_MIN_PRIORITY)
180 + _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
184 * wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce
185 @@ -174,7 +215,12 @@ void wpa_hexdump_ascii_key(int level, co
187 * Note: New line '\n' is added to the end of the text when printing to stdout.
189 -void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
190 +void _wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
191 +#define wpa_msg(ctx, level, ...) \
193 + if (level >= CONFIG_MSG_MIN_PRIORITY) \
194 + _wpa_msg(ctx, level, __VA_ARGS__); \
198 * wpa_msg_ctrl - Conditional printf for ctrl_iface monitors
199 @@ -188,8 +234,13 @@ void wpa_msg(void *ctx, int level, const
200 * attached ctrl_iface monitors. In other words, it can be used for frequent
201 * events that do not need to be sent to syslog.
203 -void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
204 +void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
206 +#define wpa_msg_ctrl(ctx, level, ...) \
208 + if (level >= CONFIG_MSG_MIN_PRIORITY) \
209 + _wpa_msg_ctrl(ctx, level, __VA_ARGS__); \
213 * wpa_msg_global - Global printf for ctrl_iface monitors