$search
00001 /* 00002 * wpa_supplicant/hostapd / Debug prints 00003 * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation. 00008 * 00009 * Alternatively, this software may be distributed under the terms of BSD 00010 * license. 00011 * 00012 * See README and COPYING for more details. 00013 */ 00014 00015 #ifndef WPA_DEBUG_H 00016 #define WPA_DEBUG_H 00017 00018 #include "wpabuf.h" 00019 00020 /* Debugging function - conditional printf and hex dump. Driver wrappers can 00021 * use these for debugging purposes. */ 00022 00023 enum { MSG_MSGDUMP, MSG_DEBUG, MSG_INFO, MSG_WARNING, MSG_ERROR }; 00024 00025 #ifdef CONFIG_NO_STDOUT_DEBUG 00026 00027 #define wpa_debug_print_timestamp() do { } while (0) 00028 #define wpa_printf(args...) do { } while (0) 00029 #define wpa_hexdump(l,t,b,le) do { } while (0) 00030 #define wpa_hexdump_buf(l,t,b) do { } while (0) 00031 #define wpa_hexdump_key(l,t,b,le) do { } while (0) 00032 #define wpa_hexdump_buf_key(l,t,b) do { } while (0) 00033 #define wpa_hexdump_ascii(l,t,b,le) do { } while (0) 00034 #define wpa_hexdump_ascii_key(l,t,b,le) do { } while (0) 00035 #define wpa_debug_open_file(p) do { } while (0) 00036 #define wpa_debug_close_file() do { } while (0) 00037 00038 #else /* CONFIG_NO_STDOUT_DEBUG */ 00039 00040 int wpa_debug_open_file(const char *path); 00041 void wpa_debug_close_file(void); 00042 00050 void wpa_debug_print_timestamp(void); 00051 00063 void wpa_printf(int level, const char *fmt, ...) 00064 PRINTF_FORMAT(2, 3); 00065 00077 void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len); 00078 00079 static inline void wpa_hexdump_buf(int level, const char *title, 00080 const struct wpabuf *buf) 00081 { 00082 wpa_hexdump(level, title, (const u8 *) wpabuf_head(buf), wpabuf_len(buf)); 00083 } 00084 00098 void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len); 00099 00100 static inline void wpa_hexdump_buf_key(int level, const char *title, 00101 const struct wpabuf *buf) 00102 { 00103 wpa_hexdump_key(level, title, (const u8 *) wpabuf_head(buf), wpabuf_len(buf)); 00104 } 00105 00119 void wpa_hexdump_ascii(int level, const char *title, const u8 *buf, 00120 size_t len); 00121 00136 void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf, 00137 size_t len); 00138 00139 #endif /* CONFIG_NO_STDOUT_DEBUG */ 00140 00141 00142 #ifdef CONFIG_NO_WPA_MSG 00143 #define wpa_msg(args...) do { } while (0) 00144 #define wpa_msg_ctrl(args...) do { } while (0) 00145 #define wpa_msg_register_cb(f) do { } while (0) 00146 #else /* CONFIG_NO_WPA_MSG */ 00147 00161 void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4); 00162 00175 void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...) 00176 PRINTF_FORMAT(3, 4); 00177 00178 typedef void (*wpa_msg_cb_func)(void *ctx, int level, const char *txt, 00179 size_t len); 00180 00185 void wpa_msg_register_cb(wpa_msg_cb_func func); 00186 #endif /* CONFIG_NO_WPA_MSG */ 00187 00188 00189 #ifdef CONFIG_NO_HOSTAPD_LOGGER 00190 #define hostapd_logger(args...) do { } while (0) 00191 #define hostapd_logger_register_cb(f) do { } while (0) 00192 #else /* CONFIG_NO_HOSTAPD_LOGGER */ 00193 void hostapd_logger(void *ctx, const u8 *addr, unsigned int module, int level, 00194 const char *fmt, ...) PRINTF_FORMAT(5, 6); 00195 00196 typedef void (*hostapd_logger_cb_func)(void *ctx, const u8 *addr, 00197 unsigned int module, int level, 00198 const char *txt, size_t len); 00199 00204 void hostapd_logger_register_cb(hostapd_logger_cb_func func); 00205 #endif /* CONFIG_NO_HOSTAPD_LOGGER */ 00206 00207 #define HOSTAPD_MODULE_IEEE80211 0x00000001 00208 #define HOSTAPD_MODULE_IEEE8021X 0x00000002 00209 #define HOSTAPD_MODULE_RADIUS 0x00000004 00210 #define HOSTAPD_MODULE_WPA 0x00000008 00211 #define HOSTAPD_MODULE_DRIVER 0x00000010 00212 #define HOSTAPD_MODULE_IAPP 0x00000020 00213 #define HOSTAPD_MODULE_MLME 0x00000040 00214 00215 enum hostapd_logger_level { 00216 HOSTAPD_LEVEL_DEBUG_VERBOSE = 0, 00217 HOSTAPD_LEVEL_DEBUG = 1, 00218 HOSTAPD_LEVEL_INFO = 2, 00219 HOSTAPD_LEVEL_NOTICE = 3, 00220 HOSTAPD_LEVEL_WARNING = 4 00221 }; 00222 00223 00224 #ifdef CONFIG_DEBUG_SYSLOG 00225 00226 void wpa_debug_open_syslog(void); 00227 void wpa_debug_close_syslog(void); 00228 00229 #else /* CONFIG_DEBUG_SYSLOG */ 00230 00231 static inline void wpa_debug_open_syslog(void) 00232 { 00233 } 00234 00235 static inline void wpa_debug_close_syslog(void) 00236 { 00237 } 00238 00239 #endif /* CONFIG_DEBUG_SYSLOG */ 00240 00241 00242 #ifdef EAPOL_TEST 00243 #define WPA_ASSERT(a) \ 00244 do { \ 00245 if (!(a)) { \ 00246 printf("WPA_ASSERT FAILED '" #a "' " \ 00247 "%s %s:%d\n", \ 00248 __FUNCTION__, __FILE__, __LINE__); \ 00249 exit(1); \ 00250 } \ 00251 } while (0) 00252 #else 00253 #define WPA_ASSERT(a) do { } while (0) 00254 #endif 00255 00256 #endif /* WPA_DEBUG_H */