[RFC 27/56] NAN: Add an API to update the cluster ID

Andrei Otcheretianski andrei.otcheretianski at intel.com
Sun Dec 7 03:18:36 PST 2025


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

Add an API to the NAN module to allow updating the cluster ID
by higher layer.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/nan/nan.c                   | 11 +++++++++++
 src/nan/nan.h                   |  1 +
 src/nan/nan_i.h                 |  3 +++
 wpa_supplicant/nan_supplicant.c |  1 +
 4 files changed, 16 insertions(+)

diff --git a/src/nan/nan.c b/src/nan/nan.c
index d8f4ae9cf1..dca1bfb867 100644
--- a/src/nan/nan.c
+++ b/src/nan/nan.c
@@ -1018,3 +1018,14 @@ bool nan_publish_instance_id_valid(struct nan_data *nan, u8 instance_id,
 		   "NAN: TODO: Publish instance ID validation not implemented");
 	return true;
 }
+
+
+/*
+ * nan_set_cluster_id - Set the cluster ID
+ * @nan: NAN module context from nan_init()
+ * @cluster_id: the cluster ID (6 bytes)
+ */
+void nan_set_cluster_id(struct nan_data *nan, const u8 *cluster_id)
+{
+	os_memcpy(nan->cluster_id, cluster_id, sizeof(nan->cluster_id));
+}
diff --git a/src/nan/nan.h b/src/nan/nan.h
index b6c570bf97..7a7e893c1f 100644
--- a/src/nan/nan.h
+++ b/src/nan/nan.h
@@ -399,5 +399,6 @@ int nan_add_peer(struct nan_data *nan, const u8 *addr,
 
 bool nan_publish_instance_id_valid(struct nan_data *nan, u8 instance_id,
 				   u8 *service_id);
+void nan_set_cluster_id(struct nan_data *nan, const u8 *cluster_id);
 
 #endif /* NAN_H */
diff --git a/src/nan/nan_i.h b/src/nan/nan_i.h
index a087d76f97..13090d8625 100644
--- a/src/nan/nan_i.h
+++ b/src/nan/nan_i.h
@@ -326,6 +326,7 @@ struct nan_peer {
  *     and is used to set ndp_id in &struct nan_ndp.
  * @next_dialog_token: Dialog token for NDP and NDL negotiations. Incremented
  *     for each NDP and NDL request.
+ * @cluster_id: Current cluster ID.
  */
 struct nan_data {
 	struct nan_config *cfg;
@@ -334,6 +335,8 @@ struct nan_data {
 
 	u8 ndp_id_counter;
 	u8 next_dialog_token;
+
+	u8 cluster_id[ETH_ALEN];
 };
 
 struct nan_attrs_entry {
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index 19aa8d0cda..362d68fe0c 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -283,6 +283,7 @@ void wpas_nan_cluster_join(struct wpa_supplicant *wpa_s,
 		       " new=%d", MAC2STR(cluster_id), new_cluster);
 
 	nan_de_set_cluster_id(wpa_s->nan_de, cluster_id);
+	nan_set_cluster_id(wpa_s->nan, cluster_id);
 }
 
 
-- 
2.49.0




More information about the Hostap mailing list