]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add CONFIG_ANDROID_LOG support
authorDmitry Shmidt <dimitrysh@google.com>
Fri, 25 Feb 2011 14:44:34 +0000 (16:44 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 25 Feb 2011 14:44:34 +0000 (16:44 +0200)
This makes wpa_printf() calls use __android_log_vprint(). In addition,
hexdumps are commented out.

src/utils/wpa_debug.c
src/utils/wpa_debug.h

index 27a61c0f2394b0143098778ef2b853b1afc4537d..ba554efd3a4efd17e756f7c110008c64de26ff61 100644 (file)
@@ -28,6 +28,30 @@ int wpa_debug_show_keys = 0;
 int wpa_debug_timestamp = 0;
 
 
+#ifdef CONFIG_ANDROID_LOG
+
+#include <android/log.h>
+
+void android_printf(int level, char *format, ...)
+{
+       if (level >= wpa_debug_level) {
+               va_list ap;
+               if (level == MSG_ERROR)
+                       level = ANDROID_LOG_ERROR;
+               else if (level == MSG_WARNING)
+                       level = ANDROID_LOG_WARN;
+               else if (level == MSG_INFO)
+                       level = ANDROID_LOG_INFO;
+               else
+                       level = ANDROID_LOG_DEBUG;
+               va_start(ap, format);
+               __android_log_vprint(level, "wpa_supplicant", format, ap);
+               va_end(ap);
+       }
+}
+
+#else /* CONFIG_ANDROID_LOG */
+
 #ifndef CONFIG_NO_STDOUT_DEBUG
 
 #ifdef CONFIG_DEBUG_FILE
@@ -340,6 +364,7 @@ void wpa_debug_close_file(void)
 
 #endif /* CONFIG_NO_STDOUT_DEBUG */
 
+#endif /* CONFIG_ANDROID_LOG */
 
 #ifndef CONFIG_NO_WPA_MSG
 static wpa_msg_cb_func wpa_msg_cb = NULL;
index 0c8cdf2bcb2cda6893394662c495225cb4255274..ae36afec50d06a4ff2f97fb1e9c35a16fd032fe9 100644 (file)
@@ -24,6 +24,32 @@ enum {
        MSG_EXCESSIVE, MSG_MSGDUMP, MSG_DEBUG, MSG_INFO, MSG_WARNING, MSG_ERROR
 };
 
+#ifdef CONFIG_ANDROID_LOG
+
+#define wpa_debug_print_timestamp() do {} while (0)
+#define wpa_hexdump(...)            do {} while (0)
+#define wpa_hexdump_key(...)        do {} while (0)
+#define wpa_hexdump_buf(l,t,b)      do {} while (0)
+#define wpa_hexdump_buf_key(l,t,b)  do {} while (0)
+#define wpa_hexdump_ascii(...)      do {} while (0)
+#define wpa_hexdump_ascii_key(...)  do {} while (0)
+#define wpa_debug_open_file(...)    do {} while (0)
+#define wpa_debug_close_file()      do {} while (0)
+#define wpa_dbg(...)                do {} while (0)
+
+static inline int wpa_debug_reopen_file(void)
+{
+       return 0;
+}
+
+
+void android_printf(int level, char *format, ...)
+PRINTF_FORMAT(2, 3);
+
+#define wpa_printf android_printf
+
+#else /* CONFIG_ANDROID_LOG */
+
 #ifdef CONFIG_NO_STDOUT_DEBUG
 
 #define wpa_debug_print_timestamp() do { } while (0)
@@ -157,6 +183,8 @@ void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
 
 #endif /* CONFIG_NO_STDOUT_DEBUG */
 
+#endif /* CONFIG_ANDROID_LOG */
+
 
 #ifdef CONFIG_NO_WPA_MSG
 #define wpa_msg(args...) do { } while (0)