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