[PATCH 14/97] NAN: Indicate if NDP disconnection is due to a failure
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Tue Apr 28 13:05:15 PDT 2026
Add failure=0/1 parameter to NAN-NDP-DISCONNECTED notification.
This allows to distinguish between gracefull NDP termination and NDP
establishment failure.
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
src/nan/nan.c | 13 ++++++++++---
src/nan/nan.h | 12 ++++++++----
src/nan/nan_module_tests.c | 4 +++-
wpa_supplicant/nan_supplicant.c | 5 +++--
wpa_supplicant/notify.c | 7 ++++---
wpa_supplicant/notify.h | 3 ++-
6 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/src/nan/nan.c b/src/nan/nan.c
index 792ef5fa20..3410313610 100644
--- a/src/nan/nan.c
+++ b/src/nan/nan.c
@@ -1543,7 +1543,7 @@ static void nan_ndp_disconnected(struct nan_data *nan, struct nan_peer *peer,
{
const u8 *local_ndi, *peer_ndi;
struct nan_ndp_id ndp_id;
- bool remove_sta;
+ bool remove_sta, fail;
os_memset(&ndp_id, 0, sizeof(ndp_id));
@@ -1570,10 +1570,17 @@ static void nan_ndp_disconnected(struct nan_data *nan, struct nan_peer *peer,
*/
remove_sta = !nan_peer_ndi_in_use(peer, peer_ndi);
+ /*
+ * NAN_NDP_STATE_NONE means the NDP was not in progress, thus
+ * the failure flag should be false.
+ */
+ fail = peer->ndp_setup.state != NAN_NDP_STATE_NONE;
+
if (nan->cfg->ndp_disconnected)
nan->cfg->ndp_disconnected(nan->cfg->cb_ctx, &ndp_id,
local_ndi, peer_ndi, reason,
- locally_generated, remove_sta);
+ locally_generated, remove_sta,
+ fail);
nan_ndp_setup_stop(nan, peer);
}
@@ -2156,7 +2163,7 @@ void nan_ndp_terminated(struct nan_data *nan, struct nan_peer *peer,
if (nan->cfg->ndp_disconnected)
nan->cfg->ndp_disconnected(nan->cfg->cb_ctx, ndp_id, local_ndi,
peer_ndi, reason, false,
- remove_sta);
+ remove_sta, false);
/* Need to also remove the NDL if it is not needed */
if (dl_list_empty(&peer->ndps) && !peer->ndp_setup.ndp)
diff --git a/src/nan/nan.h b/src/nan/nan.h
index 1188ffac77..2d9372f014 100644
--- a/src/nan/nan.h
+++ b/src/nan/nan.h
@@ -495,15 +495,19 @@ struct nan_config {
* false if triggered by the peer
* @remove_sta: true if the NDI station should be removed (no other NDPs
* using the same peer NDI)
+ * @failure: true if NDP setup failed (before connected), false if
+ * graceful disconnection after NDP was established
*
- * This callback notifies that an NDP has been disconnected. It can be
- * called both during NDP establishment (indicating failure) or after
- * successful establishment (indicating termination).
+ * This callback notifies that an NDP has been disconnected. When
+ * @failure is true, NDP setup failed before connection was established.
+ * When @failure is false, it indicates graceful termination after NDP
+ * was successfully connected.
*/
void (*ndp_disconnected)(void *ctx, struct nan_ndp_id *ndp_id,
const u8 *local_ndi, const u8 *peer_ndi,
enum nan_reason reason,
- bool locally_generated, bool remove_sta);
+ bool locally_generated, bool remove_sta,
+ bool failure);
/**
* get_chans - Get the prioritized allowed channel information to be
diff --git a/src/nan/nan_module_tests.c b/src/nan/nan_module_tests.c
index 9f376278d1..43b8a57c45 100644
--- a/src/nan/nan_module_tests.c
+++ b/src/nan/nan_module_tests.c
@@ -641,6 +641,7 @@ static int nan_test_ndp_connected_cb(void *ctx,
* @reason: Reason for disconnection
* @locally_generated: true if locally generated, false if triggered by peer
* @remove_sta: true if the NDI station should be removed
+ * @failure: true if NDP setup failed, false if graceful disconnection
*
* The handling of the event is done asynchronously through the NAN test actions
* processing.
@@ -650,7 +651,8 @@ static void nan_test_ndp_disconnected_cb(void *ctx, struct nan_ndp_id *ndp_id,
const u8 *peer_ndi,
enum nan_reason reason,
bool locally_generated,
- bool remove_sta)
+ bool remove_sta,
+ bool failure)
{
struct nan_device *dev = ctx;
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index e8c5b25c4c..a1fff99aba 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -639,14 +639,15 @@ static void wpas_nan_ndp_disconnected_cb(void *ctx, struct nan_ndp_id *ndp_id,
const u8 *peer_ndi,
enum nan_reason reason,
bool locally_generated,
- bool remove_sta)
+ bool remove_sta,
+ bool failure)
{
struct wpa_supplicant *wpa_s = ctx;
wpas_nan_remove_ndi_sta(wpa_s, local_ndi, peer_ndi, remove_sta);
wpas_notify_nan_ndp_disconnected(wpa_s, ndp_id->peer_nmi,
ndp_id->id, local_ndi, peer_ndi,
- reason, locally_generated);
+ reason, locally_generated, failure);
}
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index c445aba316..2881fddab2 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -1436,14 +1436,15 @@ void wpas_notify_nan_ndp_disconnected(struct wpa_supplicant *wpa_s,
const u8 *local_ndi,
const u8 *peer_ndi,
enum nan_reason reason,
- bool locally_generated)
+ bool locally_generated,
+ bool failure)
{
wpa_msg_global(wpa_s, MSG_INFO, NAN_NDP_DISCONNECTED
"peer=" MACSTR " ndp_id=%u local_ndi=" MACSTR
- " peer_ndi=" MACSTR " reason=%u locally_generated=%d",
+ " peer_ndi=" MACSTR " reason=%u locally_generated=%d, failure=%d",
MAC2STR(peer_nmi), ndp_id,
MAC2STR(local_ndi), MAC2STR(peer_ndi), reason,
- locally_generated);
+ locally_generated, failure);
}
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index 1a593a4fdb..3c2feece9e 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -243,7 +243,8 @@ void wpas_notify_nan_ndp_disconnected(struct wpa_supplicant *wpa_s,
const u8 *peer_nmi, u32 ndp_id,
const u8 *local_ndi, const u8 *peer_ndi,
enum nan_reason reason,
- bool locally_generated);
+ bool locally_generated,
+ bool failure);
void wpas_notify_nan_cluster_join(struct wpa_supplicant *wpa_s,
const u8 *cluster_id, bool new_cluster);
void wpas_notify_nan_pairing_status(struct wpa_supplicant *wpa_s,
--
2.53.0
More information about the Hostap
mailing list