[PATCH 08/15] NAN: Add a test hook to override the Discovery Engine Cluster ID
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Thu Oct 8 09:05:17 PDT 2026
From: Ilan Peer <ilan.peer at intel.com>
Add a test configuration 'NAN_SET test_cluster_id' command, that
overrides the Discovery Engine (DE) Cluster ID. The override will
be used in later patch for testing NAN synchronize service discovery
with mismatched cluster ID.
While at it, fix an issue where NAN DE is configured, without checking
if it is initialized.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/common/nan_de.c | 3 +++
wpa_supplicant/nan_supplicant.c | 19 +++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/src/common/nan_de.c b/src/common/nan_de.c
index 4a49164e6e..150b0b153c 100644
--- a/src/common/nan_de.c
+++ b/src/common/nan_de.c
@@ -3956,6 +3956,9 @@ void nan_de_dw_trigger(struct nan_de *de, int freq)
void nan_de_set_cluster_id(struct nan_de *de, const u8 *cluster_id)
{
if (cluster_id) {
+ wpa_printf(MSG_DEBUG, "NAN: Set cluster ID " MACSTR,
+ MAC2STR(cluster_id));
+
os_memcpy(de->cluster_id, cluster_id, ETH_ALEN);
de->cluster_id_set = true;
} else {
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index 0b5148dff8..bcc5c35b5b 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -2168,6 +2168,9 @@ int wpas_nan_set(struct wpa_supplicant *wpa_s, char *cmd)
if (os_strcmp("tx_mcast_follow_up_prot", cmd) == 0) {
bool val = !!atoi(param);
+ if (!wpa_s->nan_de)
+ return -1;
+
nan_de_set_tx_mcast_follow_up_prot(wpa_s->nan_de, val);
return 0;
}
@@ -2176,6 +2179,22 @@ int wpas_nan_set(struct wpa_supplicant *wpa_s, char *cmd)
wpa_s->nan_force_conditional_sched = !!atoi(param);
return 0;
}
+
+ if (os_strcmp("test_cluster_id", cmd) == 0) {
+ u8 cluster_id[ETH_ALEN] = { 0x50, 0x6f, 0x9a, 0x01, 0, 0 };
+
+ if (os_strlen(param) != 4 ||
+ hexstr2bin(param, &cluster_id[4], 2) < 0) {
+ wpa_printf(MSG_INFO, "NAN: Invalid cluster ID");
+ return -1;
+ }
+
+ if (!wpa_s->nan_de)
+ return -1;
+
+ nan_de_set_cluster_id(wpa_s->nan_de, cluster_id);
+ return 0;
+ }
#endif /* CONFIG_TESTING_OPTIONS */
if (os_strcmp("max_ndl_idle_period", cmd) == 0) {
--
2.53.0
More information about the Hostap
mailing list