wpa_supplicant / hostapd 2.0

wpa_debug.h

Go to the documentation of this file.
00001 
00010 #ifndef WPA_DEBUG_H
00011 #define WPA_DEBUG_H
00012 
00013 #include "wpabuf.h"
00014 
00015 /* Debugging function - conditional printf and hex dump. Driver wrappers can
00016  * use these for debugging purposes. */
00017 
00018 enum {
00019         MSG_EXCESSIVE, MSG_MSGDUMP, MSG_DEBUG, MSG_INFO, MSG_WARNING, MSG_ERROR
00020 };
00021 
00022 #ifdef CONFIG_NO_STDOUT_DEBUG
00023 
00024 #define wpa_debug_print_timestamp() do { } while (0)
00025 #define wpa_printf(args...) do { } while (0)
00026 #define wpa_hexdump(l,t,b,le) do { } while (0)
00027 #define wpa_hexdump_buf(l,t,b) do { } while (0)
00028 #define wpa_hexdump_key(l,t,b,le) do { } while (0)
00029 #define wpa_hexdump_buf_key(l,t,b) do { } while (0)
00030 #define wpa_hexdump_ascii(l,t,b,le) do { } while (0)
00031 #define wpa_hexdump_ascii_key(l,t,b,le) do { } while (0)
00032 #define wpa_debug_open_file(p) do { } while (0)
00033 #define wpa_debug_close_file() do { } while (0)
00034 #define wpa_dbg(args...) do { } while (0)
00035 
00036 static inline int wpa_debug_reopen_file(void)
00037 {
00038         return 0;
00039 }
00040 
00041 #else /* CONFIG_NO_STDOUT_DEBUG */
00042 
00043 int wpa_debug_open_file(const char *path);
00044 int wpa_debug_reopen_file(void);
00045 void wpa_debug_close_file(void);
00046 
00055 void wpa_debug_print_timestamp(void);
00056 
00069 void wpa_printf(int level, const char *fmt, ...)
00070 PRINTF_FORMAT(2, 3);
00071 
00084 void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len);
00085 
00086 static inline void wpa_hexdump_buf(int level, const char *title,
00087                                    const struct wpabuf *buf)
00088 {
00089         wpa_hexdump(level, title, buf ? wpabuf_head(buf) : NULL,
00090                     buf ? wpabuf_len(buf) : 0);
00091 }
00092 
00107 void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len);
00108 
00109 static inline void wpa_hexdump_buf_key(int level, const char *title,
00110                                        const struct wpabuf *buf)
00111 {
00112         wpa_hexdump_key(level, title, buf ? wpabuf_head(buf) : NULL,
00113                         buf ? wpabuf_len(buf) : 0);
00114 }
00115 
00130 void wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
00131                        size_t len);
00132 
00148 void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
00149                            size_t len);
00150 
00151 /*
00152  * wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce
00153  * binary size. As such, it should be used with debugging messages that are not
00154  * needed in the control interface while wpa_msg() has to be used for anything
00155  * that needs to shown to control interface monitors.
00156  */
00157 #define wpa_dbg(args...) wpa_msg(args)
00158 
00159 #endif /* CONFIG_NO_STDOUT_DEBUG */
00160 
00161 
00162 #ifdef CONFIG_NO_WPA_MSG
00163 #define wpa_msg(args...) do { } while (0)
00164 #define wpa_msg_ctrl(args...) do { } while (0)
00165 #define wpa_msg_register_cb(f) do { } while (0)
00166 #define wpa_msg_register_ifname_cb(f) do { } while (0)
00167 #else /* CONFIG_NO_WPA_MSG */
00168 
00183 void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
00184 
00198 void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
00199 PRINTF_FORMAT(3, 4);
00200 
00201 typedef void (*wpa_msg_cb_func)(void *ctx, int level, const char *txt,
00202                                 size_t len);
00203 
00209 void wpa_msg_register_cb(wpa_msg_cb_func func);
00210 
00211 typedef const char * (*wpa_msg_get_ifname_func)(void *ctx);
00212 void wpa_msg_register_ifname_cb(wpa_msg_get_ifname_func func);
00213 
00214 #endif /* CONFIG_NO_WPA_MSG */
00215 
00216 #ifdef CONFIG_NO_HOSTAPD_LOGGER
00217 #define hostapd_logger(args...) do { } while (0)
00218 #define hostapd_logger_register_cb(f) do { } while (0)
00219 #else /* CONFIG_NO_HOSTAPD_LOGGER */
00220 void hostapd_logger(void *ctx, const u8 *addr, unsigned int module, int level,
00221                     const char *fmt, ...) PRINTF_FORMAT(5, 6);
00222 
00223 typedef void (*hostapd_logger_cb_func)(void *ctx, const u8 *addr,
00224                                        unsigned int module, int level,
00225                                        const char *txt, size_t len);
00226 
00232 void hostapd_logger_register_cb(hostapd_logger_cb_func func);
00233 #endif /* CONFIG_NO_HOSTAPD_LOGGER */
00234 
00235 #define HOSTAPD_MODULE_IEEE80211        0x00000001
00236 #define HOSTAPD_MODULE_IEEE8021X        0x00000002
00237 #define HOSTAPD_MODULE_RADIUS           0x00000004
00238 #define HOSTAPD_MODULE_WPA              0x00000008
00239 #define HOSTAPD_MODULE_DRIVER           0x00000010
00240 #define HOSTAPD_MODULE_IAPP             0x00000020
00241 #define HOSTAPD_MODULE_MLME             0x00000040
00242 
00243 enum hostapd_logger_level {
00244         HOSTAPD_LEVEL_DEBUG_VERBOSE = 0,
00245         HOSTAPD_LEVEL_DEBUG = 1,
00246         HOSTAPD_LEVEL_INFO = 2,
00247         HOSTAPD_LEVEL_NOTICE = 3,
00248         HOSTAPD_LEVEL_WARNING = 4
00249 };
00250 
00251 
00252 #ifdef CONFIG_DEBUG_SYSLOG
00253 
00254 void wpa_debug_open_syslog(void);
00255 void wpa_debug_close_syslog(void);
00256 
00257 #else /* CONFIG_DEBUG_SYSLOG */
00258 
00259 static inline void wpa_debug_open_syslog(void)
00260 {
00261 }
00262 
00263 static inline void wpa_debug_close_syslog(void)
00264 {
00265 }
00266 
00267 #endif /* CONFIG_DEBUG_SYSLOG */
00268 
00269 #ifdef CONFIG_DEBUG_LINUX_TRACING
00270 
00271 int wpa_debug_open_linux_tracing(void);
00272 void wpa_debug_close_linux_tracing(void);
00273 
00274 #else /* CONFIG_DEBUG_LINUX_TRACING */
00275 
00276 static inline int wpa_debug_open_linux_tracing(void)
00277 {
00278         return 0;
00279 }
00280 
00281 static inline void wpa_debug_close_linux_tracing(void)
00282 {
00283 }
00284 
00285 #endif /* CONFIG_DEBUG_LINUX_TRACING */
00286 
00287 
00288 #ifdef EAPOL_TEST
00289 #define WPA_ASSERT(a)                                                  \
00290         do {                                                           \
00291                 if (!(a)) {                                            \
00292                         printf("WPA_ASSERT FAILED '" #a "' "           \
00293                                "%s %s:%d\n",                           \
00294                                __FUNCTION__, __FILE__, __LINE__);      \
00295                         exit(1);                                       \
00296                 }                                                      \
00297         } while (0)
00298 #else
00299 #define WPA_ASSERT(a) do { } while (0)
00300 #endif
00301 
00302 #endif /* WPA_DEBUG_H */
00303 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines