1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Mon, 20 Feb 2012 23:41:52 +0000
3 Subject: [PATCH] hostapd: add configurable debug message minimum priority to
4 cut down on bloat generated by excessive debug messages
6 --- a/src/utils/wpa_debug.c
7 +++ b/src/utils/wpa_debug.c
8 @@ -206,7 +206,7 @@ void wpa_debug_close_linux_tracing(void)
10 * Note: New line '\n' is added to the end of the text when printing to stdout.
12 -void wpa_printf(int level, const char *fmt, ...)
13 +void _wpa_printf(int level, const char *fmt, ...)
17 @@ -255,7 +255,7 @@ void wpa_printf(int level, const char *f
21 -static void _wpa_hexdump(int level, const char *title, const u8 *buf,
22 +void _wpa_hexdump(int level, const char *title, const u8 *buf,
23 size_t len, int show, int only_syslog)
26 @@ -382,19 +382,7 @@ static void _wpa_hexdump(int level, cons
27 #endif /* CONFIG_ANDROID_LOG */
30 -void wpa_hexdump(int level, const char *title, const void *buf, size_t len)
32 - _wpa_hexdump(level, title, buf, len, 1, 0);
36 -void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len)
38 - _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys, 0);
42 -static void _wpa_hexdump_ascii(int level, const char *title, const void *buf,
43 +void _wpa_hexdump_ascii(int level, const char *title, const void *buf,
47 @@ -507,20 +495,6 @@ file_done:
51 -void wpa_hexdump_ascii(int level, const char *title, const void *buf,
54 - _wpa_hexdump_ascii(level, title, buf, len, 1);
58 -void wpa_hexdump_ascii_key(int level, const char *title, const void *buf,
61 - _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
65 #ifdef CONFIG_DEBUG_FILE
66 static char *last_path = NULL;
67 #endif /* CONFIG_DEBUG_FILE */
68 @@ -644,7 +618,7 @@ void wpa_msg_register_ifname_cb(wpa_msg_
72 -void wpa_msg(void *ctx, int level, const char *fmt, ...)
73 +void _wpa_msg(void *ctx, int level, const char *fmt, ...)
77 @@ -682,7 +656,7 @@ void wpa_msg(void *ctx, int level, const
81 -void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
82 +void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
86 --- a/src/utils/wpa_debug.h
87 +++ b/src/utils/wpa_debug.h
88 @@ -51,6 +51,17 @@ void wpa_debug_close_file(void);
89 void wpa_debug_setup_stdout(void);
90 void wpa_debug_stop_log(void);
93 +void _wpa_hexdump(int level, const char *title, const u8 *buf,
94 + size_t len, int show, int only_syslog);
95 +void _wpa_hexdump_ascii(int level, const char *title, const void *buf,
96 + size_t len, int show);
97 +extern int wpa_debug_show_keys;
99 +#ifndef CONFIG_MSG_MIN_PRIORITY
100 +#define CONFIG_MSG_MIN_PRIORITY 0
104 * wpa_debug_printf_timestamp - Print timestamp for debug output
106 @@ -71,9 +82,15 @@ void wpa_debug_print_timestamp(void);
108 * Note: New line '\n' is added to the end of the text when printing to stdout.
110 -void wpa_printf(int level, const char *fmt, ...)
111 +void _wpa_printf(int level, const char *fmt, ...)
114 +#define wpa_printf(level, ...) \
116 + if (level >= CONFIG_MSG_MIN_PRIORITY) \
117 + _wpa_printf(level, __VA_ARGS__); \
121 * wpa_hexdump - conditional hex dump
122 * @level: priority level (MSG_*) of the message
123 @@ -85,7 +102,13 @@ PRINTF_FORMAT(2, 3);
124 * output may be directed to stdout, stderr, and/or syslog based on
125 * configuration. The contents of buf is printed out has hex dump.
127 -void wpa_hexdump(int level, const char *title, const void *buf, size_t len);
128 +static inline void wpa_hexdump(int level, const char *title, const void *buf, size_t len)
130 + if (level < CONFIG_MSG_MIN_PRIORITY)
133 + _wpa_hexdump(level, title, buf, len, 1, 1);
136 static inline void wpa_hexdump_buf(int level, const char *title,
137 const struct wpabuf *buf)
138 @@ -107,7 +130,13 @@ static inline void wpa_hexdump_buf(int l
139 * like wpa_hexdump(), but by default, does not include secret keys (passwords,
140 * etc.) in debug output.
142 -void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len);
143 +static inline void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
145 + if (level < CONFIG_MSG_MIN_PRIORITY)
148 + _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys, 1);
151 static inline void wpa_hexdump_buf_key(int level, const char *title,
152 const struct wpabuf *buf)
153 @@ -129,8 +158,14 @@ static inline void wpa_hexdump_buf_key(i
154 * the hex numbers and ASCII characters (for printable range) are shown. 16
155 * bytes per line will be shown.
157 -void wpa_hexdump_ascii(int level, const char *title, const void *buf,
159 +static inline void wpa_hexdump_ascii(int level, const char *title,
160 + const u8 *buf, size_t len)
162 + if (level < CONFIG_MSG_MIN_PRIORITY)
165 + _wpa_hexdump_ascii(level, title, buf, len, 1);
169 * wpa_hexdump_ascii_key - conditional hex dump, hide keys
170 @@ -146,8 +181,14 @@ void wpa_hexdump_ascii(int level, const
171 * bytes per line will be shown. This works like wpa_hexdump_ascii(), but by
172 * default, does not include secret keys (passwords, etc.) in debug output.
174 -void wpa_hexdump_ascii_key(int level, const char *title, const void *buf,
176 +static inline void wpa_hexdump_ascii_key(int level, const char *title,
177 + const u8 *buf, size_t len)
179 + if (level < CONFIG_MSG_MIN_PRIORITY)
182 + _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
186 * wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce
187 @@ -184,7 +225,12 @@ void wpa_hexdump_ascii_key(int level, co
189 * Note: New line '\n' is added to the end of the text when printing to stdout.
191 -void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
192 +void _wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
193 +#define wpa_msg(ctx, level, ...) \
195 + if (level >= CONFIG_MSG_MIN_PRIORITY) \
196 + _wpa_msg(ctx, level, __VA_ARGS__); \
200 * wpa_msg_ctrl - Conditional printf for ctrl_iface monitors
201 @@ -198,8 +244,13 @@ void wpa_msg(void *ctx, int level, const
202 * attached ctrl_iface monitors. In other words, it can be used for frequent
203 * events that do not need to be sent to syslog.
205 -void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
206 +void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
208 +#define wpa_msg_ctrl(ctx, level, ...) \
210 + if (level >= CONFIG_MSG_MIN_PRIORITY) \
211 + _wpa_msg_ctrl(ctx, level, __VA_ARGS__); \
215 * wpa_msg_global - Global printf for ctrl_iface monitors