From: Sai Pratyusha Magam Date: Fri, 11 Nov 2022 12:44:10 +0000 (+0530) Subject: Add hostapd control interface command to stop logging to file X-Git-Tag: hostap_2_11~1506 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=080afc03d5c8389a15aeb3ae91c8f97f655abf50;p=thirdparty%2Fhostap.git Add hostapd control interface command to stop logging to file Add CLOSE_LOG command to stop hostapd logging to file. This can be followed with RELOG to restart logging to the same file path. Signed-off-by: Sai Pratyusha Magam --- diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 558293095..30c44f1a8 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -3195,6 +3195,8 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, } else if (os_strncmp(buf, "RELOG", 5) == 0) { if (wpa_debug_reopen_file() < 0) reply_len = -1; + } else if (os_strcmp(buf, "CLOSE_LOG") == 0) { + wpa_debug_stop_log(); } else if (os_strncmp(buf, "NOTE ", 5) == 0) { wpa_printf(MSG_INFO, "NOTE: %s", buf + 5); } else if (os_strcmp(buf, "STATUS") == 0) { diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c index 6376b78bc..b3799e9db 100644 --- a/hostapd/hostapd_cli.c +++ b/hostapd/hostapd_cli.c @@ -252,6 +252,13 @@ static int hostapd_cli_cmd_relog(struct wpa_ctrl *ctrl, int argc, char *argv[]) } +static int hostapd_cli_cmd_close_log(struct wpa_ctrl *ctrl, int argc, + char *argv[]) +{ + return wpa_ctrl_command(ctrl, "CLOSE_LOG"); +} + + static int hostapd_cli_cmd_status(struct wpa_ctrl *ctrl, int argc, char *argv[]) { if (argc > 0 && os_strcmp(argv[0], "driver") == 0) @@ -1572,6 +1579,8 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = { "= get MIB variables (dot1x, dot11, radius)" }, { "relog", hostapd_cli_cmd_relog, NULL, "= reload/truncate debug log output file" }, + { "close_log", hostapd_cli_cmd_close_log, NULL, + "= disable debug log output file" }, { "status", hostapd_cli_cmd_status, NULL, "= show interface status info" }, { "sta", hostapd_cli_cmd_sta, hostapd_complete_stations, diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c index a338a2039..7f3dd185f 100644 --- a/src/utils/wpa_debug.c +++ b/src/utils/wpa_debug.c @@ -596,13 +596,21 @@ int wpa_debug_open_file(const char *path) } -void wpa_debug_close_file(void) +void wpa_debug_stop_log(void) { #ifdef CONFIG_DEBUG_FILE if (!out_file) return; fclose(out_file); out_file = NULL; +#endif /* CONFIG_DEBUG_FILE */ +} + + +void wpa_debug_close_file(void) +{ +#ifdef CONFIG_DEBUG_FILE + wpa_debug_stop_log(); os_free(last_path); last_path = NULL; #endif /* CONFIG_DEBUG_FILE */ diff --git a/src/utils/wpa_debug.h b/src/utils/wpa_debug.h index c6d5cc647..4c02ad3c7 100644 --- a/src/utils/wpa_debug.h +++ b/src/utils/wpa_debug.h @@ -49,6 +49,7 @@ int wpa_debug_open_file(const char *path); int wpa_debug_reopen_file(void); void wpa_debug_close_file(void); void wpa_debug_setup_stdout(void); +void wpa_debug_stop_log(void); /** * wpa_debug_printf_timestamp - Print timestamp for debug output