[PATCH 57/97] NAN: Add support for including max idle period in NDL

Andrei Otcheretianski andrei.otcheretianski at intel.com
Tue Apr 28 13:05:58 PDT 2026


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

Extend the NAN configuration to include max idle
period (see WiFi Aware specification section 6.2.4).

If configured with max idle period, include it in the
NDL attribute added to NAFs.

In addition print the max idle period included in the
peer NAFs.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/nan/nan.h     |  8 ++++++++
 src/nan/nan_ndl.c | 19 ++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/nan/nan.h b/src/nan/nan.h
index 1cded92519..aaa77259ee 100644
--- a/src/nan/nan.h
+++ b/src/nan/nan.h
@@ -456,6 +456,14 @@ struct nan_config {
 	/* in seconds */
 	u32 nik_lifetime;
 
+	/*
+	 * The local maximal NDL idle period in seconds. This value should be
+	 * set in the NDL attribute included in NAFs to indicate to the peers
+	 * that the NDL (and all corresponding NDPs) may be terminated if there
+	 * is no data traffic with the peer for max_ndl_idle_period seconds.
+	 */
+	u16 max_ndl_idle_period;
+
 	/*
 	 * Supported Pairing Bootstrapping Methods (PBM).
 	 * See Wi-Fi Aware spec v4.0, Table 128 (NPBA format).
diff --git a/src/nan/nan_ndl.c b/src/nan/nan_ndl.c
index cef11c0916..ca69b6ec06 100644
--- a/src/nan/nan_ndl.c
+++ b/src/nan/nan_ndl.c
@@ -1245,6 +1245,9 @@ int nan_ndl_handle_ndl_attr(struct nan_data *nan, struct nan_peer *peer,
 		params.max_idle_period = WPA_GET_LE16(ndl_attr_ext);
 		ndl_attr_ext += 2;
 		ndl_attr_ext_len -= 2;
+
+		wpa_printf(MSG_DEBUG, "NAN: NDL: max_idle_period=%u",
+			   params.max_idle_period);
 	}
 
 	ndc_ok = 1;
@@ -1395,6 +1398,7 @@ int nan_ndl_add_ndl_attr(struct nan_data *nan, const struct nan_peer *peer,
 {
 	struct nan_ndl *ndl;
 	u16 ndl_ctrl = 0;
+	u8 *len_ptr;
 	u8 type;
 
 	if (!peer || !peer->ndl)
@@ -1405,6 +1409,14 @@ int nan_ndl_add_ndl_attr(struct nan_data *nan, const struct nan_peer *peer,
 	wpa_printf(MSG_DEBUG, "NAN: Add NDL attribute. state=%s, status=%u",
 		   nan_ndl_state_str(ndl->state), ndl->status);
 
+	if (nan->cfg->max_ndl_idle_period) {
+		wpa_printf(MSG_DEBUG,
+			   "NAN: NDL: max idle period=%u",
+			   nan->cfg->max_ndl_idle_period);
+
+		ndl_ctrl |= NAN_NDL_CTRL_MAX_IDLE_PERIOD_PRESENT;
+	}
+
 	switch (ndl->state) {
 	case NAN_NDL_STATE_NONE:
 	case NAN_NDL_STATE_REQ_SENT:
@@ -1441,13 +1453,18 @@ int nan_ndl_add_ndl_attr(struct nan_data *nan, const struct nan_peer *peer,
 		ndl_ctrl |= NAN_NDL_CTRL_NDL_QOS_ATTR_PRESENT;
 
 	wpabuf_put_u8(buf, NAN_ATTR_NDL);
-	wpabuf_put_le16(buf, sizeof(struct ieee80211_ndl));
+	len_ptr = wpabuf_put(buf, 2);
 
 	wpabuf_put_u8(buf, ndl->dialog_token);
 	wpabuf_put_u8(buf, type | (ndl->status << NAN_NDL_STATUS_POS));
 	wpabuf_put_u8(buf, ndl->reason);
 	wpabuf_put_u8(buf, ndl_ctrl);
 
+	if (nan->cfg->max_ndl_idle_period)
+		wpabuf_put_le16(buf, nan->cfg->max_ndl_idle_period);
+
+	WPA_PUT_LE16(len_ptr, (u8 *)wpabuf_put(buf, 0) - len_ptr - 2);
+
 	return 0;
 }
 
-- 
2.53.0




More information about the Hostap mailing list