From: Ilan Peer Date: Tue, 23 Dec 2025 11:45:57 +0000 (+0200) Subject: NAN: Add wpa_supplicant control interface commands for NAN X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e920445d7bc61ea3070a6894ece02e6e6318ec29;p=thirdparty%2Fhostap.git NAN: Add wpa_supplicant control interface commands for NAN 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 --- diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 8d5683c52..1c1298d95 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -63,6 +63,7 @@ #include "sme.h" #include "nan_usd.h" #include "pr_supplicant.h" +#include "nan_supplicant.h" #ifdef __NetBSD__ #include @@ -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; diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index caa417049..1ecd3fdc0 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -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 }