From: Andrei Otcheretianski Date: Tue, 23 Dec 2025 11:46:06 +0000 (+0200) Subject: NAN: Handle cluster join notification X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44ab0cad5c9e2b3594a584a10545aba0ec5ecca1;p=thirdparty%2Fhostap.git NAN: Handle cluster join notification Store cluster ID and send a notification over the control interface. Signed-off-by: Andrei Otcheretianski --- diff --git a/src/common/nan_de.c b/src/common/nan_de.c index 9d2f6bc04..e31ab715c 100644 --- a/src/common/nan_de.c +++ b/src/common/nan_de.c @@ -73,6 +73,8 @@ struct nan_de_service { struct nan_de { u8 nmi[ETH_ALEN]; + u8 cluster_id[ETH_ALEN]; + bool cluster_id_set; bool offload; bool ap; unsigned int max_listen; @@ -1748,3 +1750,14 @@ int nan_de_config(struct nan_de *de, struct nan_de_cfg *cfg) return 0; } + + +void nan_de_set_cluster_id(struct nan_de *de, const u8 *cluster_id) +{ + if (cluster_id) { + os_memcpy(de->cluster_id, cluster_id, ETH_ALEN); + de->cluster_id_set = true; + } else { + de->cluster_id_set = false; + } +} diff --git a/src/common/nan_de.h b/src/common/nan_de.h index 506188eda..3d5d34844 100644 --- a/src/common/nan_de.h +++ b/src/common/nan_de.h @@ -169,6 +169,7 @@ void nan_de_cancel_subscribe(struct nan_de *de, int subscribe_id); int nan_de_transmit(struct nan_de *de, int handle, const struct wpabuf *ssi, const struct wpabuf *elems, const u8 *peer_addr, u8 req_instance_id); +void nan_de_set_cluster_id(struct nan_de *de, const u8 *cluster_id); int nan_de_stop_listen(struct nan_de *de, int handle); diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h index 3d1735eca..963d30421 100644 --- a/src/common/wpa_ctrl.h +++ b/src/common/wpa_ctrl.h @@ -240,12 +240,13 @@ extern "C" { #define DPP_EVENT_PB_RESULT "DPP-PB-RESULT " #define DPP_EVENT_RELAY_NEEDS_CONTROLLER "DPP-RELAY-NEEDS-CONTROLLER " -/* Wi-Fi Aware (NAN USD) events */ +/* Wi-Fi Aware (NAN) events */ #define NAN_DISCOVERY_RESULT "NAN-DISCOVERY-RESULT " #define NAN_REPLIED "NAN-REPLIED " #define NAN_PUBLISH_TERMINATED "NAN-PUBLISH-TERMINATED " #define NAN_SUBSCRIBE_TERMINATED "NAN-SUBSCRIBE-TERMINATED " #define NAN_RECEIVE "NAN-RECEIVE " +#define NAN_CLUSTER_JOIN "NAN-CLUSTER-JOIN " /* MESH events */ #define MESH_GROUP_STARTED "MESH-GROUP-STARTED " diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c index 4e281a2c6..cfe417373 100644 --- a/wpa_supplicant/nan_supplicant.c +++ b/wpa_supplicant/nan_supplicant.c @@ -106,6 +106,7 @@ int wpas_nan_stop(struct wpa_supplicant *wpa_s) return -1; nan_stop(wpa_s->nan); + nan_de_set_cluster_id(wpa_s->nan_de, NULL); return 0; } @@ -127,9 +128,10 @@ void wpas_nan_cluster_join(struct wpa_supplicant *wpa_s, if (!wpas_nan_ready(wpa_s)) return; - /* TODO: Handle cluster merge */ - wpa_printf(MSG_DEBUG, "NAN: Joined cluster " MACSTR " (new: %d)", - MAC2STR(cluster_id), new_cluster); + wpa_msg_global(wpa_s, MSG_INFO, NAN_CLUSTER_JOIN "cluster_id=" MACSTR + " new=%d", MAC2STR(cluster_id), new_cluster); + + nan_de_set_cluster_id(wpa_s->nan_de, cluster_id); }