From: Andrei Otcheretianski Date: Tue, 23 Dec 2025 11:46:00 +0000 (+0200) Subject: NAN: Handle cluster join and next DW events X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8dd034b2b63765d263ebb7624ca3006b3dc27528;p=thirdparty%2Fhostap.git NAN: Handle cluster join and next DW events To support synchronized NAN Discovery Engine (DE) in wpa_supplicant, the driver will report two new events: NAN_CLUSTER_JOIN: This event is sent whenever a new NAN cluster is started or joined. This event carries the new cluster id, which will be used to construct SDFs. NAN_NEXT_DW: A notification about an upcoming Discovery Window (DW). This event is optional and may be turned on and off. It is used to trigger multicast SDF transmissions during the upcoming DW. Define these events and add the functions needed for delivering thenm to nan_supplicant.c Signed-off-by: Andrei Otcheretianski --- diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 018c9792f..b91d4fc6e 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -6221,6 +6221,30 @@ enum wpa_event_type { * EVENT_SETUP_LINK_RECONFIG - Notification that new AP links added */ EVENT_SETUP_LINK_RECONFIG, + + /** + * EVENT_NAN_CLUSTER_JOIN - Notification of a new cluster having been + * joined or started. + * + * This event is used to notify wpa_supplicant that a NAN cluster has + * been joined or started. The event data includes the NAN cluster ID + * and a boolean indicating whether a new cluster was started or an + * existing cluster was joined. + * + * Described in wpa_event_data.nan_cluster_join_info. + */ + EVENT_NAN_CLUSTER_JOIN, + + /** + * EVENT_NAN_NEXT_DW - Notification of NAN next Discovery Window + * + * This event is used to notify wpa_supplicant that the device/driver + * is ready for the next Discovery Window (DW) frames. It may be used + * to trigger transmission of multicast SDFs (active subscribe and + * unsolicited publish). + * The event data includes the DW frequency. + */ + EVENT_NAN_NEXT_DW, }; @@ -7220,6 +7244,15 @@ union wpa_event_data { const u8 *resp_ie; /* Starting from Group Key Data */ size_t resp_ie_len; } reconfig_info; + + struct nan_cluster_join_info { + const u8 *bssid; + bool new_cluster; + } nan_cluster_join_info; + + struct nan_next_dw_info { + int freq; + } nan_next_dw_info; }; /** diff --git a/src/drivers/driver_common.c b/src/drivers/driver_common.c index 045c82967..cff25b446 100644 --- a/src/drivers/driver_common.c +++ b/src/drivers/driver_common.c @@ -102,6 +102,8 @@ const char * event_to_string(enum wpa_event_type event) E2S(LINK_RECONFIG); E2S(MLD_INTERFACE_FREED); E2S(SETUP_LINK_RECONFIG); + E2S(NAN_CLUSTER_JOIN); + E2S(NAN_NEXT_DW); } return "UNKNOWN"; diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index b9ae7fa5c..016f60153 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -7352,6 +7352,15 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, if (data) wpas_setup_link_reconfig(wpa_s, &data->reconfig_info); break; +#ifdef CONFIG_NAN + case EVENT_NAN_CLUSTER_JOIN: + wpas_nan_cluster_join(wpa_s, data->nan_cluster_join_info.bssid, + data->nan_cluster_join_info.new_cluster); + break; + case EVENT_NAN_NEXT_DW: + wpas_nan_next_dw(wpa_s, data->nan_next_dw_info.freq); + break; +#endif /* CONFIG_NAN */ default: wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event); break; diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c index dc37e4c44..f25e0bf96 100644 --- a/wpa_supplicant/nan_supplicant.c +++ b/wpa_supplicant/nan_supplicant.c @@ -109,3 +109,26 @@ void wpas_nan_flush(struct wpa_supplicant *wpa_s) nan_flush(wpa_s->nan); } + + +void wpas_nan_cluster_join(struct wpa_supplicant *wpa_s, + const u8 *cluster_id, + bool new_cluster) +{ + 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); +} + + +void wpas_nan_next_dw(struct wpa_supplicant *wpa_s, u32 freq) +{ + if (!wpas_nan_ready(wpa_s)) + return; + + /* TODO: Handle DW notification */ + wpa_printf(MSG_DEBUG, "NAN: Next DW notification freq=%d", freq); +} diff --git a/wpa_supplicant/nan_supplicant.h b/wpa_supplicant/nan_supplicant.h index 615c6f64a..2c2d7ff7a 100644 --- a/wpa_supplicant/nan_supplicant.h +++ b/wpa_supplicant/nan_supplicant.h @@ -16,6 +16,10 @@ void wpas_nan_deinit(struct wpa_supplicant *wpa_s); int wpas_nan_start(struct wpa_supplicant *wpa_s); int wpas_nan_stop(struct wpa_supplicant *wpa_s); void wpas_nan_flush(struct wpa_supplicant *wpa_s); +void wpas_nan_cluster_join(struct wpa_supplicant *wpa_s, + const u8 *cluster_id, + bool new_cluster); +void wpas_nan_next_dw(struct wpa_supplicant *wpa_s, u32 freq); #else /* CONFIG_NAN */