[RFC v2 87/99] NAN: Add an API to delete all NDPs of a specific peer
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Tue Dec 23 03:52:31 PST 2025
From: Ilan Peer <ilan.peer at intel.com>
Add an API to delete all NDPs associated with a specific
peer. The deletion is local, without sending a NAF to the
peer, as it is not feasible to do so since the NDPs and NDL
are being removed.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/nan/nan.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
src/nan/nan.h | 1 +
2 files changed, 45 insertions(+)
diff --git a/src/nan/nan.c b/src/nan/nan.c
index 350c2fd36c..44eaa992b2 100644
--- a/src/nan/nan.c
+++ b/src/nan/nan.c
@@ -2130,3 +2130,47 @@ bool nan_peer_npk_nik_caching_supported(struct nan_data *nan,
return peer->info.npk_nik_caching_support;
}
+
+
+/*
+ * nan_peer_del_all_ndps - Delete all NDPs with a given peer
+ *
+ * @nan: NAN module context from nan_init()
+ * @addr: NAN MAC address of the peer
+ * Return 0 on success; -1 on failure.
+ *
+ * The function deletes all NDPs with the given peer and stops any ongoing
+ * NDP setup. It also resets the NDL state machine and flushes any security
+ * context with the peer. The function doesn't delete the peer itself and
+ * doesn't send any NAFs to the peer notifying about the deletions.
+ */
+int nan_peer_del_all_ndps(struct nan_data *nan, const u8 *addr)
+{
+ struct nan_peer *peer;
+ struct nan_ndp *ndp, *tndp;
+
+ if (!nan)
+ return -1;
+
+ peer = nan_get_peer(nan, addr);
+ if (!peer)
+ return -1;
+
+ wpa_printf(MSG_DEBUG,
+ "NAN: Deleting all NDPs with peer " MACSTR,
+ MAC2STR(addr));
+
+ dl_list_for_each_safe(ndp, tndp, &peer->ndps,
+ struct nan_ndp, list) {
+ dl_list_del(&ndp->list);
+ os_free(ndp);
+ }
+
+ if (peer->ndp_setup.ndp)
+ nan_ndp_setup_stop(nan, peer);
+
+ nan_ndl_reset(nan, peer);
+ nan_peer_flush_sec(&peer->info);
+
+ return 0;
+}
diff --git a/src/nan/nan.h b/src/nan/nan.h
index 1218c800e5..3f6f840f34 100644
--- a/src/nan/nan.h
+++ b/src/nan/nan.h
@@ -549,4 +549,5 @@ int nan_crypto_derive_nd_pmk(const char *pwd, const u8 *service_id,
enum nan_cipher_suite_id csid,
const u8 *peer_nmi, u8 *nd_pmk);
void nan_add_dev_capa_attr(struct nan_data *nan, struct wpabuf *buf);
+int nan_peer_del_all_ndps(struct nan_data *nan, const u8 *addr);
#endif /* NAN_H */
--
2.49.0
More information about the Hostap
mailing list