3417b5ac3c3f2e5fbea85ab2ab96302c84200676
[openwrt/staging/lynxis.git] /
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
5
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.
11
12 Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
13 ---
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(-)
21
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
26 endif
27
28 +ifdef CONFIG_DEBUG_SYSLOG
29 +L_CFLAGS += -DCONFIG_DEBUG_SYSLOG
30 +endif
31 +
32 ifdef CONFIG_DEBUG_LINUX_TRACING
33 L_CFLAGS += -DCONFIG_DEBUG_LINUX_TRACING
34 endif
35 --- a/hostapd/Makefile
36 +++ b/hostapd/Makefile
37 @@ -997,6 +997,10 @@ ifdef CONFIG_NO_STDOUT_DEBUG
38 CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
39 endif
40
41 +ifdef CONFIG_DEBUG_SYSLOG
42 +CFLAGS += -DCONFIG_DEBUG_SYSLOG
43 +endif
44 +
45 ifdef CONFIG_DEBUG_LINUX_TRACING
46 CFLAGS += -DCONFIG_DEBUG_LINUX_TRACING
47 endif
48 --- a/hostapd/defconfig
49 +++ b/hostapd/defconfig
50 @@ -166,6 +166,9 @@ CONFIG_IPV6=y
51 # Disabled by default.
52 #CONFIG_DEBUG_FILE=y
53
54 +# Send debug messages to syslog instead of stdout
55 +#CONFIG_DEBUG_SYSLOG=y
56 +
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
60 --- a/hostapd/main.c
61 +++ b/hostapd/main.c
62 @@ -108,6 +108,10 @@ static void hostapd_logger_cb(void *ctx,
63 module_str ? module_str : "",
64 module_str ? ": " : "", txt);
65
66 +#ifdef CONFIG_DEBUG_SYSLOG
67 + if (wpa_debug_syslog)
68 + conf_stdout = 0;
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);
85
86 for (;;) {
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:");
89 if (c < 0)
90 break;
91 switch (c) {
92 @@ -718,6 +725,11 @@ int main(int argc, char *argv[])
93 bss_config = tmp_bss;
94 bss_config[num_bss_configs++] = optarg;
95 break;
96 +#ifdef CONFIG_DEBUG_SYSLOG
97 + case 's':
98 + wpa_debug_syslog = 1;
99 + break;
100 +#endif /* CONFIG_DEBUG_SYSLOG */
101 case 'S':
102 start_ifaces_in_sync = 1;
103 break;
104 @@ -746,6 +758,10 @@ int main(int argc, char *argv[])
105 wpa_debug_open_file(log_file);
106 else
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);
117 os_free(pid_file);
118
119 + wpa_debug_close_syslog();
120 if (log_file)
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
125 @@ -13,7 +13,7 @@
126 #ifdef CONFIG_DEBUG_SYSLOG
127 #include <syslog.h>
128
129 -static int wpa_debug_syslog = 0;
130 +int wpa_debug_syslog = 0;
131 #endif /* CONFIG_DEBUG_SYSLOG */
132
133 #ifdef CONFIG_DEBUG_LINUX_TRACING
134 --- a/src/utils/wpa_debug.h
135 +++ b/src/utils/wpa_debug.h
136 @@ -14,6 +14,9 @@
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 */
143
144 /* Debugging function - conditional printf and hex dump. Driver wrappers can
145 * use these for debugging purposes. */