OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --- a/src/utils/wpa_debug.c |
2 | +++ b/src/utils/wpa_debug.c |
||
3 | @@ -205,7 +205,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 | @@ -252,8 +252,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 | @@ -379,20 +379,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 | @@ -499,20 +487,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 | @@ -628,7 +602,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 | @@ -666,7 +640,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 | @@ -52,6 +52,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 | @@ -72,9 +83,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 | @@ -86,7 +103,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 | @@ -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, |
||
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 | @@ -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 |
||
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 | @@ -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 |
||
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 | @@ -185,7 +226,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 | @@ -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 |
||
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 |