include: remove kernel 6.1 version file
[openwrt/openwrt.git] / package / network / services / hostapd / patches / 410-limit_debug_messages.patch
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
5
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)
9 *
10 * Note: New line '\n' is added to the end of the text when printing to stdout.
11 */
12 -void wpa_printf(int level, const char *fmt, ...)
13 +void _wpa_printf(int level, const char *fmt, ...)
14 {
15 va_list ap;
16
17 @@ -255,7 +255,7 @@ void wpa_printf(int level, const char *f
18 }
19
20
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)
24 {
25 size_t i;
26 @@ -382,19 +382,7 @@ static void _wpa_hexdump(int level, cons
27 #endif /* CONFIG_ANDROID_LOG */
28 }
29
30 -void wpa_hexdump(int level, const char *title, const void *buf, size_t len)
31 -{
32 - _wpa_hexdump(level, title, buf, len, 1, 0);
33 -}
34 -
35 -
36 -void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len)
37 -{
38 - _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys, 0);
39 -}
40 -
41 -
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,
44 size_t len, int show)
45 {
46 size_t i, llen;
47 @@ -507,20 +495,6 @@ file_done:
48 }
49
50
51 -void wpa_hexdump_ascii(int level, const char *title, const void *buf,
52 - size_t len)
53 -{
54 - _wpa_hexdump_ascii(level, title, buf, len, 1);
55 -}
56 -
57 -
58 -void wpa_hexdump_ascii_key(int level, const char *title, const void *buf,
59 - size_t len)
60 -{
61 - _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
62 -}
63 -
64 -
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_
69 }
70
71
72 -void wpa_msg(void *ctx, int level, const char *fmt, ...)
73 +void _wpa_msg(void *ctx, int level, const char *fmt, ...)
74 {
75 va_list ap;
76 char *buf;
77 @@ -682,7 +656,7 @@ void wpa_msg(void *ctx, int level, const
78 }
79
80
81 -void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
82 +void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
83 {
84 va_list ap;
85 char *buf;
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);
91
92 +/* internal */
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;
98 +
99 +#ifndef CONFIG_MSG_MIN_PRIORITY
100 +#define CONFIG_MSG_MIN_PRIORITY 0
101 +#endif
102 +
103 /**
104 * wpa_debug_printf_timestamp - Print timestamp for debug output
105 *
106 @@ -71,9 +82,15 @@ void wpa_debug_print_timestamp(void);
107 *
108 * Note: New line '\n' is added to the end of the text when printing to stdout.
109 */
110 -void wpa_printf(int level, const char *fmt, ...)
111 +void _wpa_printf(int level, const char *fmt, ...)
112 PRINTF_FORMAT(2, 3);
113
114 +#define wpa_printf(level, ...) \
115 + do { \
116 + if (level >= CONFIG_MSG_MIN_PRIORITY) \
117 + _wpa_printf(level, __VA_ARGS__); \
118 + } while(0)
119 +
120 /**
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.
126 */
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)
129 +{
130 + if (level < CONFIG_MSG_MIN_PRIORITY)
131 + return;
132 +
133 + _wpa_hexdump(level, title, buf, len, 1, 1);
134 +}
135
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.
141 */
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)
144 +{
145 + if (level < CONFIG_MSG_MIN_PRIORITY)
146 + return;
147 +
148 + _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys, 1);
149 +}
150
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.
156 */
157 -void wpa_hexdump_ascii(int level, const char *title, const void *buf,
158 - size_t len);
159 +static inline void wpa_hexdump_ascii(int level, const char *title,
160 + const u8 *buf, size_t len)
161 +{
162 + if (level < CONFIG_MSG_MIN_PRIORITY)
163 + return;
164 +
165 + _wpa_hexdump_ascii(level, title, buf, len, 1);
166 +}
167
168 /**
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.
173 */
174 -void wpa_hexdump_ascii_key(int level, const char *title, const void *buf,
175 - size_t len);
176 +static inline void wpa_hexdump_ascii_key(int level, const char *title,
177 + const u8 *buf, size_t len)
178 +{
179 + if (level < CONFIG_MSG_MIN_PRIORITY)
180 + return;
181 +
182 + _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
183 +}
184
185 /*
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
188 *
189 * Note: New line '\n' is added to the end of the text when printing to stdout.
190 */
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, ...) \
194 + do { \
195 + if (level >= CONFIG_MSG_MIN_PRIORITY) \
196 + _wpa_msg(ctx, level, __VA_ARGS__); \
197 + } while(0)
198
199 /**
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.
204 */
205 -void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
206 +void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
207 PRINTF_FORMAT(3, 4);
208 +#define wpa_msg_ctrl(ctx, level, ...) \
209 + do { \
210 + if (level >= CONFIG_MSG_MIN_PRIORITY) \
211 + _wpa_msg_ctrl(ctx, level, __VA_ARGS__); \
212 + } while(0)
213
214 /**
215 * wpa_msg_global - Global printf for ctrl_iface monitors