]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
NAN: Add wpa_supplicant control interface commands for NAN
authorIlan Peer <ilan.peer@intel.com>
Tue, 23 Dec 2025 11:45:57 +0000 (13:45 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 29 Jan 2026 10:31:55 +0000 (12:31 +0200)
Add control interface commands to start/stop NAN operation. All the NAN
commands should be handled only on the control interface associated with
the NAN Device interface.

Add indication for NAN support when querying for capabilities.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/wpa_cli.c

index 8d5683c52fff204087071110bb964ba1c74d90cb..1c1298d956ca428f6e56fe50e278f43dbbbfe986 100644 (file)
@@ -63,6 +63,7 @@
 #include "sme.h"
 #include "nan_usd.h"
 #include "pr_supplicant.h"
+#include "nan_supplicant.h"
 
 #ifdef __NetBSD__
 #include <net/if_ether.h>
@@ -4941,14 +4942,30 @@ static int wpa_supplicant_ctrl_iface_get_capability(
        }
 #endif /* CONFIG_DPP */
 
-#ifdef CONFIG_NAN_USD
        if (os_strcmp(field, "nan") == 0) {
-               res = os_snprintf(buf, buflen, "USD");
+               char *pos = buf;
+
+#ifdef CONFIG_NAN_USD
+               res = os_snprintf(pos, buflen, "USD");
                if (os_snprintf_error(buflen, res))
                        return -1;
-               return res;
-       }
+
+               pos += res;
+               buflen -= res;
 #endif /* CONFIG_NAN_USD */
+#ifdef CONFIG_NAN
+               if ((wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_SUPPORT_NAN)) {
+                       res = os_snprintf(pos, buflen, "%sNAN",
+                                         pos == buf ? "" : " ");
+                       if (os_snprintf_error(buflen, res))
+                               return -1;
+
+                       pos += res;
+                       buflen -= res;
+               }
+#endif /* CONFIG_NAN */
+               return pos - buf;
+       }
 
 #ifdef CONFIG_SAE
        if (os_strcmp(field, "sae") == 0 &&
@@ -14275,6 +14292,14 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
                if (wpas_update_random_addr_disassoc(wpa_s) != 1)
                        reply_len = -1;
                wpa_s->conf->preassoc_mac_addr = mac_addr_style;
+#ifdef CONFIG_NAN
+       } else if (os_strncmp(buf, "NAN_START", 9) == 0) {
+               if (wpas_nan_start(wpa_s) < 0)
+                       reply_len = -1;
+       } else if (os_strncmp(buf, "NAN_STOP", 8) == 0) {
+               if (wpas_nan_stop(wpa_s) < 0)
+                       reply_len = -1;
+#endif /* CONFIG_NAN */
        } else {
                os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
                reply_len = 16;
index caa41704919e946eb788d61c98c8d7acf6030d35..1ecd3fdc01126d89c0340eb60f9d6aad88c86b75 100644 (file)
@@ -3391,6 +3391,24 @@ static int wpa_cli_cmd_nan_flush(struct wpa_ctrl *ctrl, int argc,
 #endif /* CONFIG_NAN_USD */
 
 
+#ifdef CONFIG_NAN
+
+static int wpa_cli_cmd_nan_start(struct wpa_ctrl *ctrl, int argc,
+                                char *argv[])
+{
+       return wpa_cli_cmd(ctrl, "NAN_START", 0, argc, argv);
+}
+
+
+static int wpa_cli_cmd_nan_stop(struct wpa_ctrl *ctrl, int argc,
+                               char *argv[])
+{
+       return wpa_cli_cmd(ctrl, "NAN_STOP", 0, argc, argv);
+}
+
+#endif /* CONFIG_NAN */
+
+
 static int wpa_cli_cmd_generate_new_mac(struct wpa_ctrl *ctrl, int argc,
                                        char *argv[])
 {
@@ -4170,6 +4188,12 @@ static const struct wpa_cli_cmd wpa_cli_commands[] = {
        { "nan_flush", wpa_cli_cmd_nan_flush, NULL,
          cli_cmd_flag_none, "= Flush all NAN USD services" },
 #endif /* CONFIG_NAN_USD */
+#ifdef CONFIG_NAN
+       { "nan_start", wpa_cli_cmd_nan_start, NULL, cli_cmd_flag_none,
+         "= start/join NAN cluster with current configuration" },
+       { "nan_stop", wpa_cli_cmd_nan_stop, NULL, cli_cmd_flag_none,
+         "= stop NAN operation" },
+#endif /* CONFIG_NAN */
        { "new_random_mac_address", wpa_cli_cmd_generate_new_mac, NULL,
          cli_cmd_flag_none, "= Generate new random MAC address" },
        { NULL, NULL, NULL, cli_cmd_flag_none, NULL }