wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
wpa_debug.h
Go to the documentation of this file.
1 
5 #ifndef WPA_DEBUG_H
6 #define WPA_DEBUG_H
7 
8 #include "wpabuf.h"
9 
10 extern int wpa_debug_level;
11 extern int wpa_debug_show_keys;
12 extern int wpa_debug_timestamp;
13 
14 /* Debugging function - conditional printf and hex dump. Driver wrappers can
15  * use these for debugging purposes. */
16 
17 enum {
18  MSG_EXCESSIVE, MSG_MSGDUMP, MSG_DEBUG, MSG_INFO, MSG_WARNING, MSG_ERROR
19 };
20 
21 #ifdef CONFIG_NO_STDOUT_DEBUG
22 
23 #define wpa_debug_print_timestamp() do { } while (0)
24 #define wpa_printf(args...) do { } while (0)
25 #define wpa_hexdump(l,t,b,le) do { } while (0)
26 #define wpa_hexdump_buf(l,t,b) do { } while (0)
27 #define wpa_hexdump_key(l,t,b,le) do { } while (0)
28 #define wpa_hexdump_buf_key(l,t,b) do { } while (0)
29 #define wpa_hexdump_ascii(l,t,b,le) do { } while (0)
30 #define wpa_hexdump_ascii_key(l,t,b,le) do { } while (0)
31 #define wpa_debug_open_file(p) do { } while (0)
32 #define wpa_debug_close_file() do { } while (0)
33 #define wpa_debug_setup_stdout() do { } while (0)
34 #define wpa_dbg(args...) do { } while (0)
35 
36 static inline int wpa_debug_reopen_file(void)
37 {
38  return 0;
39 }
40 
41 #else /* CONFIG_NO_STDOUT_DEBUG */
42 
43 int wpa_debug_open_file(const char *path);
44 int wpa_debug_reopen_file(void);
45 void wpa_debug_close_file(void);
46 void wpa_debug_setup_stdout(void);
47 
56 void wpa_debug_print_timestamp(void);
57 
69 void wpa_printf(int level, const char *fmt, ...)
70 PRINTF_FORMAT(2, 3);
71 
83 void wpa_hexdump(int level, const char *title, const void *buf, size_t len);
84 
85 static inline void wpa_hexdump_buf(int level, const char *title,
86  const struct wpabuf *buf)
87 {
88  wpa_hexdump(level, title, buf ? wpabuf_head(buf) : NULL,
89  buf ? wpabuf_len(buf) : 0);
90 }
91 
105 void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len);
106 
107 static inline void wpa_hexdump_buf_key(int level, const char *title,
108  const struct wpabuf *buf)
109 {
110  wpa_hexdump_key(level, title, buf ? wpabuf_head(buf) : NULL,
111  buf ? wpabuf_len(buf) : 0);
112 }
113 
127 void wpa_hexdump_ascii(int level, const char *title, const void *buf,
128  size_t len);
129 
144 void wpa_hexdump_ascii_key(int level, const char *title, const void *buf,
145  size_t len);
146 
147 /*
148  * wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce
149  * binary size. As such, it should be used with debugging messages that are not
150  * needed in the control interface while wpa_msg() has to be used for anything
151  * that needs to shown to control interface monitors.
152  */
153 #define wpa_dbg(args...) wpa_msg(args)
154 
155 #endif /* CONFIG_NO_STDOUT_DEBUG */
156 
157 
158 #ifdef CONFIG_NO_WPA_MSG
159 #define wpa_msg(args...) do { } while (0)
160 #define wpa_msg_ctrl(args...) do { } while (0)
161 #define wpa_msg_global(args...) do { } while (0)
162 #define wpa_msg_global_ctrl(args...) do { } while (0)
163 #define wpa_msg_no_global(args...) do { } while (0)
164 #define wpa_msg_global_only(args...) do { } while (0)
165 #define wpa_msg_register_cb(f) do { } while (0)
166 #define wpa_msg_register_ifname_cb(f) do { } while (0)
167 #else /* CONFIG_NO_WPA_MSG */
168 
182 void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
183 
196 void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
197 PRINTF_FORMAT(3, 4);
198 
212 void wpa_msg_global(void *ctx, int level, const char *fmt, ...)
213 PRINTF_FORMAT(3, 4);
214 
227 void wpa_msg_global_ctrl(void *ctx, int level, const char *fmt, ...)
228 PRINTF_FORMAT(3, 4);
229 
241 void wpa_msg_no_global(void *ctx, int level, const char *fmt, ...)
242 PRINTF_FORMAT(3, 4);
243 
255 void wpa_msg_global_only(void *ctx, int level, const char *fmt, ...)
256 PRINTF_FORMAT(3, 4);
257 
258 enum wpa_msg_type {
259  WPA_MSG_PER_INTERFACE,
260  WPA_MSG_GLOBAL,
261  WPA_MSG_NO_GLOBAL,
262  WPA_MSG_ONLY_GLOBAL,
263 };
264 
265 typedef void (*wpa_msg_cb_func)(void *ctx, int level, enum wpa_msg_type type,
266  const char *txt, size_t len);
267 
272 void wpa_msg_register_cb(wpa_msg_cb_func func);
273 
274 typedef const char * (*wpa_msg_get_ifname_func)(void *ctx);
275 void wpa_msg_register_ifname_cb(wpa_msg_get_ifname_func func);
276 
277 #endif /* CONFIG_NO_WPA_MSG */
278 
279 #ifdef CONFIG_NO_HOSTAPD_LOGGER
280 #define hostapd_logger(args...) do { } while (0)
281 #define hostapd_logger_register_cb(f) do { } while (0)
282 #else /* CONFIG_NO_HOSTAPD_LOGGER */
283 void hostapd_logger(void *ctx, const u8 *addr, unsigned int module, int level,
284  const char *fmt, ...) PRINTF_FORMAT(5, 6);
285 
286 typedef void (*hostapd_logger_cb_func)(void *ctx, const u8 *addr,
287  unsigned int module, int level,
288  const char *txt, size_t len);
289 
294 void hostapd_logger_register_cb(hostapd_logger_cb_func func);
295 #endif /* CONFIG_NO_HOSTAPD_LOGGER */
296 
297 #define HOSTAPD_MODULE_IEEE80211 0x00000001
298 #define HOSTAPD_MODULE_IEEE8021X 0x00000002
299 #define HOSTAPD_MODULE_RADIUS 0x00000004
300 #define HOSTAPD_MODULE_WPA 0x00000008
301 #define HOSTAPD_MODULE_DRIVER 0x00000010
302 #define HOSTAPD_MODULE_IAPP 0x00000020
303 #define HOSTAPD_MODULE_MLME 0x00000040
304 
305 enum hostapd_logger_level {
306  HOSTAPD_LEVEL_DEBUG_VERBOSE = 0,
307  HOSTAPD_LEVEL_DEBUG = 1,
308  HOSTAPD_LEVEL_INFO = 2,
309  HOSTAPD_LEVEL_NOTICE = 3,
310  HOSTAPD_LEVEL_WARNING = 4
311 };
312 
313 
314 #ifdef CONFIG_DEBUG_SYSLOG
315 
316 void wpa_debug_open_syslog(void);
317 void wpa_debug_close_syslog(void);
318 
319 #else /* CONFIG_DEBUG_SYSLOG */
320 
321 static inline void wpa_debug_open_syslog(void)
322 {
323 }
324 
325 static inline void wpa_debug_close_syslog(void)
326 {
327 }
328 
329 #endif /* CONFIG_DEBUG_SYSLOG */
330 
331 #ifdef CONFIG_DEBUG_LINUX_TRACING
332 
333 int wpa_debug_open_linux_tracing(void);
334 void wpa_debug_close_linux_tracing(void);
335 
336 #else /* CONFIG_DEBUG_LINUX_TRACING */
337 
338 static inline int wpa_debug_open_linux_tracing(void)
339 {
340  return 0;
341 }
342 
343 static inline void wpa_debug_close_linux_tracing(void)
344 {
345 }
346 
347 #endif /* CONFIG_DEBUG_LINUX_TRACING */
348 
349 
350 #ifdef EAPOL_TEST
351 #define WPA_ASSERT(a) \
352  do { \
353  if (!(a)) { \
354  printf("WPA_ASSERT FAILED '" #a "' " \
355  "%s %s:%d\n", \
356  __FUNCTION__, __FILE__, __LINE__); \
357  exit(1); \
358  } \
359  } while (0)
360 #else
361 #define WPA_ASSERT(a) do { } while (0)
362 #endif
363 
364 const char * debug_level_str(int level);
365 int str_to_debug_level(const char *s);
366 
367 #endif /* WPA_DEBUG_H */
void wpa_debug_print_timestamp(void)
Print timestamp for debug output.
Definition: wpa_debug.c:61
void wpa_hexdump_ascii(int level, const char *title, const void *buf, size_t len)
conditional hex dump
Definition: wpa_debug.c:494
Definition: wpabuf.h:16
void void void void void void wpa_msg_global_only(void *ctx, int level, const char *fmt,...) PRINTF_FORMAT(3
Conditional printf for ctrl_iface monitors.
Dynamic data buffer.
void void void void void wpa_msg_no_global(void *ctx, int level, const char *fmt,...) PRINTF_FORMAT(3
Conditional printf for ctrl_iface monitors.
void void void wpa_msg_global(void *ctx, int level, const char *fmt,...) PRINTF_FORMAT(3
Global printf for ctrl_iface monitors.
void wpa_hexdump_ascii_key(int level, const char *title, const void *buf, size_t len)
conditional hex dump, hide keys
Definition: wpa_debug.c:501
void wpa_msg(void *ctx, int level, const char *fmt,...) PRINTF_FORMAT(3
Conditional printf for default target and ctrl_iface monitors.
void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len)
conditional hex dump, hide keys
Definition: wpa_debug.c:380
void void wpa_msg_ctrl(void *ctx, int level, const char *fmt,...) PRINTF_FORMAT(3
Conditional printf for ctrl_iface monitors.
void hostapd_logger_register_cb(hostapd_logger_cb_func func)
Register callback function for hostapd_logger()
Definition: wpa_debug.c:781
void void void void wpa_msg_global_ctrl(void *ctx, int level, const char *fmt,...) PRINTF_FORMAT(3
Conditional global printf for ctrl_iface monitors.
void void wpa_hexdump(int level, const char *title, const void *buf, size_t len)
conditional hex dump
Definition: wpa_debug.c:374
void wpa_msg_register_cb(wpa_msg_cb_func func)
Register callback function for wpa_msg() messages.
Definition: wpa_debug.c:587
void wpa_printf(int level, const char *fmt,...) PRINTF_FORMAT(2
conditional printf