]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Add possibility to send debug messages to syslog
authorWojciech Dubowik <Wojciech.Dubowik@neratec.com>
Mon, 23 Jan 2017 12:55:04 +0000 (13:55 +0100)
committerJouni Malinen <j@w1.fi>
Sun, 29 Jan 2017 22:57:13 +0000 (00:57 +0200)
We can only send module specific messages to syslog and not debug
messages printed with wpa_printf. Add an extra command line parameter
'-s' to allow it. The feature is enabled with compile flag
CONFIG_DEBUG_SYSLOG as for wpa_supplicant and behaves in the same manner
as the wpa_supplicant -s command line argument.

Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
hostapd/Android.mk
hostapd/Makefile
hostapd/defconfig
hostapd/main.c
src/utils/wpa_debug.c
src/utils/wpa_debug.h

index 9a14be4b9025de268f7700604fb637caf0084779..ec2d55a9fae2d02f96828211637489456a3ea459 100644 (file)
@@ -952,6 +952,10 @@ ifdef CONFIG_NO_STDOUT_DEBUG
 L_CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
 endif
 
+ifdef CONFIG_DEBUG_SYSLOG
+L_CFLAGS += -DCONFIG_DEBUG_SYSLOG
+endif
+
 ifdef CONFIG_DEBUG_LINUX_TRACING
 L_CFLAGS += -DCONFIG_DEBUG_LINUX_TRACING
 endif
index 52c72dc45ae512005c911dd70fa584e6fd894f45..d9bb72a0a8c45db4c6d879a2d07ab9a5f1cc227f 100644 (file)
@@ -997,6 +997,10 @@ ifdef CONFIG_NO_STDOUT_DEBUG
 CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
 endif
 
+ifdef CONFIG_DEBUG_SYSLOG
+CFLAGS += -DCONFIG_DEBUG_SYSLOG
+endif
+
 ifdef CONFIG_DEBUG_LINUX_TRACING
 CFLAGS += -DCONFIG_DEBUG_LINUX_TRACING
 endif
index e25ec320f1980fbdbb55ff64b12de58578f93d16..bf6e646639b4b37b5297cd1bc4013bcb2f0ee895 100644 (file)
@@ -166,6 +166,9 @@ CONFIG_IPV6=y
 # Disabled by default.
 #CONFIG_DEBUG_FILE=y
 
+# Send debug messages to syslog instead of stdout
+#CONFIG_DEBUG_SYSLOG=y
+
 # Add support for sending all debug messages (regardless of debug verbosity)
 # to the Linux kernel tracing facility. This helps debug the entire stack by
 # making it easy to record everything happening from the driver up into the
index 6911232ebd0b468488eada005f51ec47fbd436cd..593267c96f660f516be9181afb3b6a5c14d8ade8 100644 (file)
@@ -108,6 +108,10 @@ static void hostapd_logger_cb(void *ctx, const u8 *addr, unsigned int module,
                            module_str ? module_str : "",
                            module_str ? ": " : "", txt);
 
+#ifdef CONFIG_DEBUG_SYSLOG
+       if (wpa_debug_syslog)
+               conf_stdout = 0;
+#endif /* CONFIG_DEBUG_SYSLOG */
        if ((conf_stdout & module) && level >= conf_stdout_level) {
                wpa_debug_print_timestamp();
                wpa_printf(MSG_INFO, "%s", format);
@@ -484,6 +488,9 @@ static void usage(void)
                "        (records all messages regardless of debug verbosity)\n"
 #endif /* CONFIG_DEBUG_LINUX_TRACING */
                "   -i   list of interface names to use\n"
+#ifdef CONFIG_DEBUG_SYSLOG
+               "   -s   log output to syslog instead of stdout\n"
+#endif /* CONFIG_DEBUG_SYSLOG */
                "   -S   start all the interfaces synchronously\n"
                "   -t   include timestamps in some debug messages\n"
                "   -v   show hostapd version\n");
@@ -661,7 +668,7 @@ int main(int argc, char *argv[])
        dl_list_init(&interfaces.global_ctrl_dst);
 
        for (;;) {
-               c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:vg:G:");
+               c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:vg:G:");
                if (c < 0)
                        break;
                switch (c) {
@@ -718,6 +725,11 @@ int main(int argc, char *argv[])
                        bss_config = tmp_bss;
                        bss_config[num_bss_configs++] = optarg;
                        break;
+#ifdef CONFIG_DEBUG_SYSLOG
+               case 's':
+                       wpa_debug_syslog = 1;
+                       break;
+#endif /* CONFIG_DEBUG_SYSLOG */
                case 'S':
                        start_ifaces_in_sync = 1;
                        break;
@@ -746,6 +758,10 @@ int main(int argc, char *argv[])
                wpa_debug_open_file(log_file);
        else
                wpa_debug_setup_stdout();
+#ifdef CONFIG_DEBUG_SYSLOG
+       if (wpa_debug_syslog)
+               wpa_debug_open_syslog();
+#endif /* CONFIG_DEBUG_SYSLOG */
 #ifdef CONFIG_DEBUG_LINUX_TRACING
        if (enable_trace_dbg) {
                int tret = wpa_debug_open_linux_tracing();
@@ -882,6 +898,7 @@ int main(int argc, char *argv[])
        hostapd_global_deinit(pid_file, interfaces.eloop_initialized);
        os_free(pid_file);
 
+       wpa_debug_close_syslog();
        if (log_file)
                wpa_debug_close_file();
        wpa_debug_close_linux_tracing();
index f7acf6b9f6984b528296d0708a74f240ba85fc38..62758d864737aa498760ad63bd400e12daacf6bf 100644 (file)
@@ -13,7 +13,7 @@
 #ifdef CONFIG_DEBUG_SYSLOG
 #include <syslog.h>
 
-static int wpa_debug_syslog = 0;
+int wpa_debug_syslog = 0;
 #endif /* CONFIG_DEBUG_SYSLOG */
 
 #ifdef CONFIG_DEBUG_LINUX_TRACING
index 17d8f963802e4145fe8e52431b4ab8c5602ab2ca..1fe0b7db7482b0825d00f109e1d2ae28216e8dc5 100644 (file)
@@ -14,6 +14,9 @@
 extern int wpa_debug_level;
 extern int wpa_debug_show_keys;
 extern int wpa_debug_timestamp;
+#ifdef CONFIG_DEBUG_SYSLOG
+extern int wpa_debug_syslog;
+#endif /* CONFIG_DEBUG_SYSLOG */
 
 /* Debugging function - conditional printf and hex dump. Driver wrappers can
  * use these for debugging purposes. */