LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
wpa_debug.h
Go to the documentation of this file.
1 /*
2  * wpa_supplicant/hostapd / Debug prints
3  * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14 
15 #ifndef WPA_DEBUG_H
16 #define WPA_DEBUG_H
17 
18 #include "wpabuf.h"
19 
20 /* Debugging function - conditional printf and hex dump. Driver wrappers can
21  * use these for debugging purposes. */
22 
24 
25 #ifdef CONFIG_NO_STDOUT_DEBUG
26 
27 #define wpa_debug_print_timestamp() do { } while (0)
28 #define wpa_printf(args...) do { } while (0)
29 #define wpa_hexdump(l,t,b,le) do { } while (0)
30 #define wpa_hexdump_buf(l,t,b) do { } while (0)
31 #define wpa_hexdump_key(l,t,b,le) do { } while (0)
32 #define wpa_hexdump_buf_key(l,t,b) do { } while (0)
33 #define wpa_hexdump_ascii(l,t,b,le) do { } while (0)
34 #define wpa_hexdump_ascii_key(l,t,b,le) do { } while (0)
35 #define wpa_debug_open_file(p) do { } while (0)
36 #define wpa_debug_close_file() do { } while (0)
37 
38 #else /* CONFIG_NO_STDOUT_DEBUG */
39 
40 int wpa_debug_open_file(const char *path);
41 void wpa_debug_close_file(void);
42 
50 void wpa_debug_print_timestamp(void);
51 
63 void wpa_printf(int level, const char *fmt, ...)
64 PRINTF_FORMAT(2, 3);
65 
77 void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len);
78 
79 static inline void wpa_hexdump_buf(int level, const char *title,
80  const struct wpabuf *buf)
81 {
82  wpa_hexdump(level, title, wpabuf_head(buf), wpabuf_len(buf));
83 }
84 
98 void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len);
99 
100 static inline void wpa_hexdump_buf_key(int level, const char *title,
101  const struct wpabuf *buf)
102 {
103  wpa_hexdump_key(level, title, wpabuf_head(buf), wpabuf_len(buf));
104 }
105 
119 void wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
120  size_t len);
121 
136 void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
137  size_t len);
138 
139 #endif /* CONFIG_NO_STDOUT_DEBUG */
140 
141 
142 #ifdef CONFIG_NO_WPA_MSG
143 #define wpa_msg(args...) do { } while (0)
144 #define wpa_msg_ctrl(args...) do { } while (0)
145 #define wpa_msg_register_cb(f) do { } while (0)
146 #else /* CONFIG_NO_WPA_MSG */
147 
161 void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
162 
175 void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
176 PRINTF_FORMAT(3, 4);
177 
178 typedef void (*wpa_msg_cb_func)(void *ctx, int level, const char *txt,
179  size_t len);
180 
186 #endif /* CONFIG_NO_WPA_MSG */
187 
188 
189 #ifdef CONFIG_NO_HOSTAPD_LOGGER
190 #define hostapd_logger(args...) do { } while (0)
191 #define hostapd_logger_register_cb(f) do { } while (0)
192 #else /* CONFIG_NO_HOSTAPD_LOGGER */
193 void hostapd_logger(void *ctx, const u8 *addr, unsigned int module, int level,
194  const char *fmt, ...) PRINTF_FORMAT(5, 6);
195 
196 typedef void (*hostapd_logger_cb_func)(void *ctx, const u8 *addr,
197  unsigned int module, int level,
198  const char *txt, size_t len);
199 
205 #endif /* CONFIG_NO_HOSTAPD_LOGGER */
206 
207 #define HOSTAPD_MODULE_IEEE80211 0x00000001
208 #define HOSTAPD_MODULE_IEEE8021X 0x00000002
209 #define HOSTAPD_MODULE_RADIUS 0x00000004
210 #define HOSTAPD_MODULE_WPA 0x00000008
211 #define HOSTAPD_MODULE_DRIVER 0x00000010
212 #define HOSTAPD_MODULE_IAPP 0x00000020
213 #define HOSTAPD_MODULE_MLME 0x00000040
214 
221 };
222 
223 
224 #ifdef CONFIG_DEBUG_SYSLOG
225 
226 void wpa_debug_open_syslog(void);
227 void wpa_debug_close_syslog(void);
228 
229 #else /* CONFIG_DEBUG_SYSLOG */
230 
231 static inline void wpa_debug_open_syslog(void)
232 {
233 }
234 
235 static inline void wpa_debug_close_syslog(void)
236 {
237 }
238 
239 #endif /* CONFIG_DEBUG_SYSLOG */
240 
241 
242 #ifdef EAPOL_TEST
243 #define WPA_ASSERT(a) \
244  do { \
245  if (!(a)) { \
246  printf("WPA_ASSERT FAILED '" #a "' " \
247  "%s %s:%d\n", \
248  __FUNCTION__, __FILE__, __LINE__); \
249  exit(1); \
250  } \
251  } while (0)
252 #else
253 #define WPA_ASSERT(a) do { } while (0)
254 #endif
255 
256 #endif /* WPA_DEBUG_H */
int wpa_debug_open_file(const char *path)
void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len)
void void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len)
void wpa_debug_print_timestamp(void)
uint8_t u8
Definition: common.h:160
#define PRINTF_FORMAT(a, b)
Definition: common.h:341
void typedef void(* hostapd_logger_cb_func)(void *ctx, const u8 *addr, unsigned int module, int level, const char *txt, size_t len)
Definition: wpa_debug.h:196
Definition: wpabuf.h:23
void hostapd_logger(void *ctx, const u8 *addr, unsigned int module, int level, const char *fmt,...) PRINTF_FORMAT(5
void wpa_hexdump_ascii(int level, const char *title, const u8 *buf, size_t len)
void wpa_debug_close_file(void)
void void typedef void(* wpa_msg_cb_func)(void *ctx, int level, const char *txt, size_t len)
Definition: wpa_debug.h:178
void wpa_msg(void *ctx, int level, const char *fmt,...) PRINTF_FORMAT(3
void void wpa_msg_ctrl(void *ctx, int level, const char *fmt,...) PRINTF_FORMAT(3
void hostapd_logger_register_cb(hostapd_logger_cb_func func)
void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf, size_t len)
hostapd_logger_level
Definition: wpa_debug.h:215
void wpa_msg_register_cb(wpa_msg_cb_func func)
void wpa_printf(int level, const char *fmt,...) PRINTF_FORMAT(2