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