hostapd: Allow logging to file
Also supports 'relog' CLI command to re-open the log file. Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:
parent
ac6912b5d1
commit
b41a47c03f
5 changed files with 32 additions and 1 deletions
|
@ -740,6 +740,10 @@ ifdef CONFIG_NO_STDOUT_DEBUG
|
||||||
CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
|
CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef CONFIG_DEBUG_FILE
|
||||||
|
CFLAGS += -DCONFIG_DEBUG_FILE
|
||||||
|
endif
|
||||||
|
|
||||||
ALL=hostapd hostapd_cli
|
ALL=hostapd hostapd_cli
|
||||||
|
|
||||||
all: verify_config $(ALL)
|
all: verify_config $(ALL)
|
||||||
|
|
|
@ -790,6 +790,9 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
|
||||||
if (os_strcmp(buf, "PING") == 0) {
|
if (os_strcmp(buf, "PING") == 0) {
|
||||||
os_memcpy(reply, "PONG\n", 5);
|
os_memcpy(reply, "PONG\n", 5);
|
||||||
reply_len = 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) {
|
} else if (os_strcmp(buf, "MIB") == 0) {
|
||||||
reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
|
reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
|
||||||
if (reply_len >= 0) {
|
if (reply_len >= 0) {
|
||||||
|
|
|
@ -144,6 +144,10 @@ CONFIG_IPV6=y
|
||||||
# code is not needed.
|
# code is not needed.
|
||||||
#CONFIG_NO_STDOUT_DEBUG=y
|
#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
|
# Remove support for RADIUS accounting
|
||||||
#CONFIG_NO_ACCOUNTING=y
|
#CONFIG_NO_ACCOUNTING=y
|
||||||
|
|
||||||
|
|
|
@ -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[])
|
static int hostapd_cli_cmd_mib(struct wpa_ctrl *ctrl, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
return wpa_ctrl_command(ctrl, "MIB");
|
return wpa_ctrl_command(ctrl, "MIB");
|
||||||
|
@ -698,6 +704,7 @@ struct hostapd_cli_cmd {
|
||||||
static struct hostapd_cli_cmd hostapd_cli_commands[] = {
|
static struct hostapd_cli_cmd hostapd_cli_commands[] = {
|
||||||
{ "ping", hostapd_cli_cmd_ping },
|
{ "ping", hostapd_cli_cmd_ping },
|
||||||
{ "mib", hostapd_cli_cmd_mib },
|
{ "mib", hostapd_cli_cmd_mib },
|
||||||
|
{ "relog", hostapd_cli_cmd_relog },
|
||||||
{ "sta", hostapd_cli_cmd_sta },
|
{ "sta", hostapd_cli_cmd_sta },
|
||||||
{ "all_sta", hostapd_cli_cmd_all_sta },
|
{ "all_sta", hostapd_cli_cmd_all_sta },
|
||||||
{ "new_sta", hostapd_cli_cmd_new_sta },
|
{ "new_sta", hostapd_cli_cmd_new_sta },
|
||||||
|
|
|
@ -467,6 +467,9 @@ static void usage(void)
|
||||||
" -B run daemon in the background\n"
|
" -B run daemon in the background\n"
|
||||||
" -P PID file\n"
|
" -P PID file\n"
|
||||||
" -K include key data in debug messages\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"
|
" -t include timestamps in some debug messages\n"
|
||||||
" -v show hostapd version\n");
|
" -v show hostapd version\n");
|
||||||
|
|
||||||
|
@ -481,12 +484,13 @@ int main(int argc, char *argv[])
|
||||||
size_t i;
|
size_t i;
|
||||||
int c, debug = 0, daemonize = 0;
|
int c, debug = 0, daemonize = 0;
|
||||||
char *pid_file = NULL;
|
char *pid_file = NULL;
|
||||||
|
const char *log_file = NULL;
|
||||||
|
|
||||||
if (os_program_init())
|
if (os_program_init())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = getopt(argc, argv, "BdhKP:tv");
|
c = getopt(argc, argv, "Bdf:hKP:tv");
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -501,6 +505,9 @@ int main(int argc, char *argv[])
|
||||||
case 'B':
|
case 'B':
|
||||||
daemonize++;
|
daemonize++;
|
||||||
break;
|
break;
|
||||||
|
case 'f':
|
||||||
|
log_file = optarg;
|
||||||
|
break;
|
||||||
case 'K':
|
case 'K':
|
||||||
wpa_debug_show_keys++;
|
wpa_debug_show_keys++;
|
||||||
break;
|
break;
|
||||||
|
@ -525,6 +532,9 @@ int main(int argc, char *argv[])
|
||||||
if (optind == argc)
|
if (optind == argc)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
if (log_file)
|
||||||
|
wpa_debug_open_file(log_file);
|
||||||
|
|
||||||
interfaces.count = argc - optind;
|
interfaces.count = argc - optind;
|
||||||
interfaces.iface = os_malloc(interfaces.count *
|
interfaces.iface = os_malloc(interfaces.count *
|
||||||
sizeof(struct hostapd_iface *));
|
sizeof(struct hostapd_iface *));
|
||||||
|
@ -559,6 +569,9 @@ int main(int argc, char *argv[])
|
||||||
hostapd_global_deinit(pid_file);
|
hostapd_global_deinit(pid_file);
|
||||||
os_free(pid_file);
|
os_free(pid_file);
|
||||||
|
|
||||||
|
if (log_file)
|
||||||
|
wpa_debug_close_file();
|
||||||
|
|
||||||
os_program_deinit();
|
os_program_deinit();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue