[PATCH 08/35] wpa_supplicant: Add control interface commands for NAN

Andrei Otcheretianski andrei.otcheretianski at intel.com
Mon Oct 20 05:27:43 PDT 2025


From: Ilan Peer <ilan.peer at intel.com>

- 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 at intel.com>
---
 wpa_supplicant/ctrl_iface.c | 32 ++++++++++++++++++++++++++++----
 wpa_supplicant/wpa_cli.c    |  6 ++++++
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index c415047e79..505cea7292 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -62,6 +62,7 @@
 #include "sme.h"
 #include "nan_usd.h"
 #include "pr_supplicant.h"
+#include "nan_supplicant.h"
 
 #ifdef __NetBSD__
 #include <net/if_ether.h>
@@ -4926,14 +4927,29 @@ 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, " NAN");
+			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 &&
@@ -14188,6 +14204,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;
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index e62ea2ddf0..784d6c7f1d 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -4187,6 +4187,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 }
-- 
2.49.0




More information about the Hostap mailing list