]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add hostapd control interface command to stop logging to file
authorSai Pratyusha Magam <quic_smagam@quicinc.com>
Fri, 11 Nov 2022 12:44:10 +0000 (18:14 +0530)
committerJouni Malinen <j@w1.fi>
Wed, 23 Nov 2022 16:24:56 +0000 (18:24 +0200)
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 <quic_smagam@quicinc.com>
hostapd/ctrl_iface.c
hostapd/hostapd_cli.c
src/utils/wpa_debug.c
src/utils/wpa_debug.h

index 558293095386a0277db14bf67c17df0aa7c15237..30c44f1a8ccddb95f5ac4df1eec33fe780ee1dc9 100644 (file)
@@ -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) {
index 6376b78bc707d5d0f983ac59fab7d47aa8c07c57..b3799e9dbcb4c47492c177252173f0b3856ed420 100644 (file)
@@ -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,
index a338a2039bb244d4a3d39862ee0372476c8f1e38..7f3dd185f100c58f21084a9174b8776fbe57e793 100644 (file)
@@ -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 */
index c6d5cc647f75d5ddcef87e854fc9fd75590d86b5..4c02ad3c775d714cb87039a37d4540ef94dcf0c9 100644 (file)
@@ -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