1 From cc3dae85bd694506cdea66ae532d452fb8716297 Mon Sep 17 00:00:00 2001
2 From: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
3 Date: Mon, 23 Jan 2017 13:55:04 +0100
4 Subject: [PATCH] hostapd: Add possibility to send debug messages to syslog
6 We can only send module specific messages to syslog and not debug
7 messages printed with wpa_printf. Add an extra command line parameter
8 '-s' to allow it. The feature is enabled with compile flag
9 CONFIG_DEBUG_SYSLOG as for wpa_supplicant and behaves in the same manner
10 as the wpa_supplicant -s command line argument.
12 Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
14 hostapd/Android.mk | 4 ++++
15 hostapd/Makefile | 4 ++++
16 hostapd/defconfig | 3 +++
17 hostapd/main.c | 19 ++++++++++++++++++-
18 src/utils/wpa_debug.c | 2 +-
19 src/utils/wpa_debug.h | 3 +++
20 6 files changed, 33 insertions(+), 2 deletions(-)
22 --- a/hostapd/Android.mk
23 +++ b/hostapd/Android.mk
24 @@ -952,6 +952,10 @@ ifdef CONFIG_NO_STDOUT_DEBUG
25 L_CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
28 +ifdef CONFIG_DEBUG_SYSLOG
29 +L_CFLAGS += -DCONFIG_DEBUG_SYSLOG
32 ifdef CONFIG_DEBUG_LINUX_TRACING
33 L_CFLAGS += -DCONFIG_DEBUG_LINUX_TRACING
35 --- a/hostapd/Makefile
36 +++ b/hostapd/Makefile
37 @@ -997,6 +997,10 @@ ifdef CONFIG_NO_STDOUT_DEBUG
38 CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
41 +ifdef CONFIG_DEBUG_SYSLOG
42 +CFLAGS += -DCONFIG_DEBUG_SYSLOG
45 ifdef CONFIG_DEBUG_LINUX_TRACING
46 CFLAGS += -DCONFIG_DEBUG_LINUX_TRACING
48 --- a/hostapd/defconfig
49 +++ b/hostapd/defconfig
50 @@ -166,6 +166,9 @@ CONFIG_IPV6=y
51 # Disabled by default.
54 +# Send debug messages to syslog instead of stdout
55 +#CONFIG_DEBUG_SYSLOG=y
57 # Add support for sending all debug messages (regardless of debug verbosity)
58 # to the Linux kernel tracing facility. This helps debug the entire stack by
59 # making it easy to record everything happening from the driver up into the
62 @@ -108,6 +108,10 @@ static void hostapd_logger_cb(void *ctx,
63 module_str ? module_str : "",
64 module_str ? ": " : "", txt);
66 +#ifdef CONFIG_DEBUG_SYSLOG
67 + if (wpa_debug_syslog)
69 +#endif /* CONFIG_DEBUG_SYSLOG */
70 if ((conf_stdout & module) && level >= conf_stdout_level) {
71 wpa_debug_print_timestamp();
72 wpa_printf(MSG_INFO, "%s", format);
73 @@ -484,6 +488,9 @@ static void usage(void)
74 " (records all messages regardless of debug verbosity)\n"
75 #endif /* CONFIG_DEBUG_LINUX_TRACING */
76 " -i list of interface names to use\n"
77 +#ifdef CONFIG_DEBUG_SYSLOG
78 + " -s log output to syslog instead of stdout\n"
79 +#endif /* CONFIG_DEBUG_SYSLOG */
80 " -S start all the interfaces synchronously\n"
81 " -t include timestamps in some debug messages\n"
82 " -v show hostapd version\n");
83 @@ -661,7 +668,7 @@ int main(int argc, char *argv[])
84 dl_list_init(&interfaces.global_ctrl_dst);
87 - c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:vg:G:");
88 + c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:vg:G:");
92 @@ -718,6 +725,11 @@ int main(int argc, char *argv[])
94 bss_config[num_bss_configs++] = optarg;
96 +#ifdef CONFIG_DEBUG_SYSLOG
98 + wpa_debug_syslog = 1;
100 +#endif /* CONFIG_DEBUG_SYSLOG */
102 start_ifaces_in_sync = 1;
104 @@ -746,6 +758,10 @@ int main(int argc, char *argv[])
105 wpa_debug_open_file(log_file);
107 wpa_debug_setup_stdout();
108 +#ifdef CONFIG_DEBUG_SYSLOG
109 + if (wpa_debug_syslog)
110 + wpa_debug_open_syslog();
111 +#endif /* CONFIG_DEBUG_SYSLOG */
112 #ifdef CONFIG_DEBUG_LINUX_TRACING
113 if (enable_trace_dbg) {
114 int tret = wpa_debug_open_linux_tracing();
115 @@ -882,6 +898,7 @@ int main(int argc, char *argv[])
116 hostapd_global_deinit(pid_file, interfaces.eloop_initialized);
119 + wpa_debug_close_syslog();
121 wpa_debug_close_file();
122 wpa_debug_close_linux_tracing();
123 --- a/src/utils/wpa_debug.c
124 +++ b/src/utils/wpa_debug.c
126 #ifdef CONFIG_DEBUG_SYSLOG
129 -static int wpa_debug_syslog = 0;
130 +int wpa_debug_syslog = 0;
131 #endif /* CONFIG_DEBUG_SYSLOG */
133 #ifdef CONFIG_DEBUG_LINUX_TRACING
134 --- a/src/utils/wpa_debug.h
135 +++ b/src/utils/wpa_debug.h
137 extern int wpa_debug_level;
138 extern int wpa_debug_show_keys;
139 extern int wpa_debug_timestamp;
140 +#ifdef CONFIG_DEBUG_SYSLOG
141 +extern int wpa_debug_syslog;
142 +#endif /* CONFIG_DEBUG_SYSLOG */
144 /* Debugging function - conditional printf and hex dump. Driver wrappers can
145 * use these for debugging purposes. */