hostapd: enter DFS state if no available channel is found
[openwrt/staging/dedeckeh.git] / package / network / services / hostapd / patches / 410-limit_debug_messages.patch
1 --- a/src/utils/wpa_debug.c
2 +++ b/src/utils/wpa_debug.c
3 @@ -206,7 +206,7 @@ void wpa_debug_close_linux_tracing(void)
4 *
5 * Note: New line '\n' is added to the end of the text when printing to stdout.
6 */
7 -void wpa_printf(int level, const char *fmt, ...)
8 +void _wpa_printf(int level, const char *fmt, ...)
9 {
10 va_list ap;
11
12 @@ -255,7 +255,7 @@ void wpa_printf(int level, const char *f
13 }
14
15
16 -static void _wpa_hexdump(int level, const char *title, const u8 *buf,
17 +void _wpa_hexdump(int level, const char *title, const u8 *buf,
18 size_t len, int show, int only_syslog)
19 {
20 size_t i;
21 @@ -382,19 +382,7 @@ static void _wpa_hexdump(int level, cons
22 #endif /* CONFIG_ANDROID_LOG */
23 }
24
25 -void wpa_hexdump(int level, const char *title, const void *buf, size_t len)
26 -{
27 - _wpa_hexdump(level, title, buf, len, 1, 0);
28 -}
29 -
30 -
31 -void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len)
32 -{
33 - _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys, 0);
34 -}
35 -
36 -
37 -static void _wpa_hexdump_ascii(int level, const char *title, const void *buf,
38 +void _wpa_hexdump_ascii(int level, const char *title, const void *buf,
39 size_t len, int show)
40 {
41 size_t i, llen;
42 @@ -507,20 +495,6 @@ file_done:
43 }
44
45
46 -void wpa_hexdump_ascii(int level, const char *title, const void *buf,
47 - size_t len)
48 -{
49 - _wpa_hexdump_ascii(level, title, buf, len, 1);
50 -}
51 -
52 -
53 -void wpa_hexdump_ascii_key(int level, const char *title, const void *buf,
54 - size_t len)
55 -{
56 - _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
57 -}
58 -
59 -
60 #ifdef CONFIG_DEBUG_FILE
61 static char *last_path = NULL;
62 #endif /* CONFIG_DEBUG_FILE */
63 @@ -636,7 +610,7 @@ void wpa_msg_register_ifname_cb(wpa_msg_
64 }
65
66
67 -void wpa_msg(void *ctx, int level, const char *fmt, ...)
68 +void _wpa_msg(void *ctx, int level, const char *fmt, ...)
69 {
70 va_list ap;
71 char *buf;
72 @@ -674,7 +648,7 @@ void wpa_msg(void *ctx, int level, const
73 }
74
75
76 -void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
77 +void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
78 {
79 va_list ap;
80 char *buf;
81 --- a/src/utils/wpa_debug.h
82 +++ b/src/utils/wpa_debug.h
83 @@ -50,6 +50,17 @@ int wpa_debug_reopen_file(void);
84 void wpa_debug_close_file(void);
85 void wpa_debug_setup_stdout(void);
86
87 +/* internal */
88 +void _wpa_hexdump(int level, const char *title, const u8 *buf,
89 + size_t len, int show, int only_syslog);
90 +void _wpa_hexdump_ascii(int level, const char *title, const void *buf,
91 + size_t len, int show);
92 +extern int wpa_debug_show_keys;
93 +
94 +#ifndef CONFIG_MSG_MIN_PRIORITY
95 +#define CONFIG_MSG_MIN_PRIORITY 0
96 +#endif
97 +
98 /**
99 * wpa_debug_printf_timestamp - Print timestamp for debug output
100 *
101 @@ -70,9 +81,15 @@ void wpa_debug_print_timestamp(void);
102 *
103 * Note: New line '\n' is added to the end of the text when printing to stdout.
104 */
105 -void wpa_printf(int level, const char *fmt, ...)
106 +void _wpa_printf(int level, const char *fmt, ...)
107 PRINTF_FORMAT(2, 3);
108
109 +#define wpa_printf(level, ...) \
110 + do { \
111 + if (level >= CONFIG_MSG_MIN_PRIORITY) \
112 + _wpa_printf(level, __VA_ARGS__); \
113 + } while(0)
114 +
115 /**
116 * wpa_hexdump - conditional hex dump
117 * @level: priority level (MSG_*) of the message
118 @@ -84,7 +101,13 @@ PRINTF_FORMAT(2, 3);
119 * output may be directed to stdout, stderr, and/or syslog based on
120 * configuration. The contents of buf is printed out has hex dump.
121 */
122 -void wpa_hexdump(int level, const char *title, const void *buf, size_t len);
123 +static inline void wpa_hexdump(int level, const char *title, const void *buf, size_t len)
124 +{
125 + if (level < CONFIG_MSG_MIN_PRIORITY)
126 + return;
127 +
128 + _wpa_hexdump(level, title, buf, len, 1, 1);
129 +}
130
131 static inline void wpa_hexdump_buf(int level, const char *title,
132 const struct wpabuf *buf)
133 @@ -106,7 +129,13 @@ static inline void wpa_hexdump_buf(int l
134 * like wpa_hexdump(), but by default, does not include secret keys (passwords,
135 * etc.) in debug output.
136 */
137 -void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len);
138 +static inline void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
139 +{
140 + if (level < CONFIG_MSG_MIN_PRIORITY)
141 + return;
142 +
143 + _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys, 1);
144 +}
145
146 static inline void wpa_hexdump_buf_key(int level, const char *title,
147 const struct wpabuf *buf)
148 @@ -128,8 +157,14 @@ static inline void wpa_hexdump_buf_key(i
149 * the hex numbers and ASCII characters (for printable range) are shown. 16
150 * bytes per line will be shown.
151 */
152 -void wpa_hexdump_ascii(int level, const char *title, const void *buf,
153 - size_t len);
154 +static inline void wpa_hexdump_ascii(int level, const char *title,
155 + const u8 *buf, size_t len)
156 +{
157 + if (level < CONFIG_MSG_MIN_PRIORITY)
158 + return;
159 +
160 + _wpa_hexdump_ascii(level, title, buf, len, 1);
161 +}
162
163 /**
164 * wpa_hexdump_ascii_key - conditional hex dump, hide keys
165 @@ -145,8 +180,14 @@ void wpa_hexdump_ascii(int level, const
166 * bytes per line will be shown. This works like wpa_hexdump_ascii(), but by
167 * default, does not include secret keys (passwords, etc.) in debug output.
168 */
169 -void wpa_hexdump_ascii_key(int level, const char *title, const void *buf,
170 - size_t len);
171 +static inline void wpa_hexdump_ascii_key(int level, const char *title,
172 + const u8 *buf, size_t len)
173 +{
174 + if (level < CONFIG_MSG_MIN_PRIORITY)
175 + return;
176 +
177 + _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys);
178 +}
179
180 /*
181 * wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce
182 @@ -183,7 +224,12 @@ void wpa_hexdump_ascii_key(int level, co
183 *
184 * Note: New line '\n' is added to the end of the text when printing to stdout.
185 */
186 -void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
187 +void _wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
188 +#define wpa_msg(ctx, level, ...) \
189 + do { \
190 + if (level >= CONFIG_MSG_MIN_PRIORITY) \
191 + _wpa_msg(ctx, level, __VA_ARGS__); \
192 + } while(0)
193
194 /**
195 * wpa_msg_ctrl - Conditional printf for ctrl_iface monitors
196 @@ -197,8 +243,13 @@ void wpa_msg(void *ctx, int level, const
197 * attached ctrl_iface monitors. In other words, it can be used for frequent
198 * events that do not need to be sent to syslog.
199 */
200 -void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
201 +void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
202 PRINTF_FORMAT(3, 4);
203 +#define wpa_msg_ctrl(ctx, level, ...) \
204 + do { \
205 + if (level >= CONFIG_MSG_MIN_PRIORITY) \
206 + _wpa_msg_ctrl(ctx, level, __VA_ARGS__); \
207 + } while(0)
208
209 /**
210 * wpa_msg_global - Global printf for ctrl_iface monitors