aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd
diff options
context:
space:
mode:
Diffstat (limited to 'hostapd')
-rw-r--r--hostapd/Makefile4
-rw-r--r--hostapd/ctrl_iface.c3
-rw-r--r--hostapd/defconfig4
-rw-r--r--hostapd/hostapd_cli.c7
-rw-r--r--hostapd/main.c15
5 files changed, 32 insertions, 1 deletions
diff --git a/hostapd/Makefile b/hostapd/Makefile
index c4ccedf..47188c2 100644
--- a/hostapd/Makefile
+++ b/hostapd/Makefile
@@ -740,6 +740,10 @@ ifdef CONFIG_NO_STDOUT_DEBUG
CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
endif
+ifdef CONFIG_DEBUG_FILE
+CFLAGS += -DCONFIG_DEBUG_FILE
+endif
+
ALL=hostapd hostapd_cli
all: verify_config $(ALL)
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index e78fba4..d3ab624 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -790,6 +790,9 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
if (os_strcmp(buf, "PING") == 0) {
os_memcpy(reply, "PONG\n", 5);
reply_len = 5;
+ } else if (os_strncmp(buf, "RELOG", 5) == 0) {
+ if (wpa_debug_reopen_file() < 0)
+ reply_len = -1;
} else if (os_strcmp(buf, "MIB") == 0) {
reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
if (reply_len >= 0) {
diff --git a/hostapd/defconfig b/hostapd/defconfig
index 8a87646..c0c4ae7 100644
--- a/hostapd/defconfig
+++ b/hostapd/defconfig
@@ -144,6 +144,10 @@ CONFIG_IPV6=y
# code is not needed.
#CONFIG_NO_STDOUT_DEBUG=y
+# Add support for writing debug log to a file: -f /tmp/hostapd.log
+# Disabled by default.
+#CONFIG_DEBUG_FILE=y
+
# Remove support for RADIUS accounting
#CONFIG_NO_ACCOUNTING=y
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index 7cc84bb..618ec26 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -221,6 +221,12 @@ static int hostapd_cli_cmd_ping(struct wpa_ctrl *ctrl, int argc, char *argv[])
}
+static int hostapd_cli_cmd_relog(struct wpa_ctrl *ctrl, int argc, char *argv[])
+{
+ return wpa_ctrl_command(ctrl, "RELOG");
+}
+
+
static int hostapd_cli_cmd_mib(struct wpa_ctrl *ctrl, int argc, char *argv[])
{
return wpa_ctrl_command(ctrl, "MIB");
@@ -698,6 +704,7 @@ struct hostapd_cli_cmd {
static struct hostapd_cli_cmd hostapd_cli_commands[] = {
{ "ping", hostapd_cli_cmd_ping },
{ "mib", hostapd_cli_cmd_mib },
+ { "relog", hostapd_cli_cmd_relog },
{ "sta", hostapd_cli_cmd_sta },
{ "all_sta", hostapd_cli_cmd_all_sta },
{ "new_sta", hostapd_cli_cmd_new_sta },
diff --git a/hostapd/main.c b/hostapd/main.c
index 9c532d4..45836df 100644
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -467,6 +467,9 @@ static void usage(void)
" -B run daemon in the background\n"
" -P PID file\n"
" -K include key data in debug messages\n"
+#ifdef CONFIG_DEBUG_FILE
+ " -f log output to debug file instead of stdout\n"
+#endif /* CONFIG_DEBUG_FILE */
" -t include timestamps in some debug messages\n"
" -v show hostapd version\n");
@@ -481,12 +484,13 @@ int main(int argc, char *argv[])
size_t i;
int c, debug = 0, daemonize = 0;
char *pid_file = NULL;
+ const char *log_file = NULL;
if (os_program_init())
return -1;
for (;;) {
- c = getopt(argc, argv, "BdhKP:tv");
+ c = getopt(argc, argv, "Bdf:hKP:tv");
if (c < 0)
break;
switch (c) {
@@ -501,6 +505,9 @@ int main(int argc, char *argv[])
case 'B':
daemonize++;
break;
+ case 'f':
+ log_file = optarg;
+ break;
case 'K':
wpa_debug_show_keys++;
break;
@@ -525,6 +532,9 @@ int main(int argc, char *argv[])
if (optind == argc)
usage();
+ if (log_file)
+ wpa_debug_open_file(log_file);
+
interfaces.count = argc - optind;
interfaces.iface = os_malloc(interfaces.count *
sizeof(struct hostapd_iface *));
@@ -559,6 +569,9 @@ int main(int argc, char *argv[])
hostapd_global_deinit(pid_file);
os_free(pid_file);
+ if (log_file)
+ wpa_debug_close_file();
+
os_program_deinit();
return ret;