[PATCH 17/92] NAN: Save the NPBA from successful bootstrapping
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Wed Apr 22 05:23:08 PDT 2026
From: Avraham Stern <avraham.stern at intel.com>
NAN pairing PASN frames shall include the NAN Pairing Bootstrapping
attribute (NPBA) from the bootstrapping flow. Save the NPBA after a
successful bootstrapping so it can be used during pairing.
Signed-off-by: Avraham Stern <avraham.stern at intel.com>
---
src/nan/nan.c | 2 ++
src/nan/nan_bootstrap.c | 39 ++++++++++++++++++++++++++++-----------
src/nan/nan_i.h | 3 +++
3 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/src/nan/nan.c b/src/nan/nan.c
index 6bf9d5a21d..ab8b997a3c 100644
--- a/src/nan/nan.c
+++ b/src/nan/nan.c
@@ -149,6 +149,8 @@ static void nan_del_peer(struct nan_data *nan, struct nan_peer *peer)
nan_ndp_setup_stop(nan, peer);
}
+ wpabuf_free(peer->bootstrap.npba);
+ peer->bootstrap.npba = NULL;
nan_bootstrap_reset(nan, peer);
dl_list_del(&peer->list);
nan_peer_flush_avail(&peer->info);
diff --git a/src/nan/nan_bootstrap.c b/src/nan/nan_bootstrap.c
index 7ce70f5211..1288ee0470 100644
--- a/src/nan/nan_bootstrap.c
+++ b/src/nan/nan_bootstrap.c
@@ -65,7 +65,7 @@ void nan_bootstrap_reset(struct nan_data *nan, struct nan_peer *peer)
/*
* Do not use memset to reset all data to preserve the peer's
- * supported bootstrap methods.
+ * supported bootstrap methods and the NPBA buffer if present.
*/
peer->bootstrap.cookie = NULL;
peer->bootstrap.cookie_len = 0;
@@ -200,13 +200,16 @@ static void nan_bootstrap_timeout(void *eloop_data, void *user_ctx)
* @status: Status field from the request
* @handle: Follow-up handle
* @req_instance_id: Follow-up instance ID
+ * @npba: NPBA attribute from the request
+ * @npba_len: Length of the NPBA attribute
*/
static void nan_bootstrap_handle_rx_request(struct nan_data *nan,
struct nan_peer *peer,
u8 dialog_token, u16 pbm,
const u8 *cookie,
u8 cookie_len, u8 status,
- int handle, u8 req_instance_id)
+ int handle, u8 req_instance_id,
+ const u8 *npba, u16 npba_len)
{
struct wpabuf *attr = NULL;
u16 supported_methods;
@@ -335,6 +338,19 @@ send_response:
return;
}
+ if (peer->bootstrap.status == NAN_PBA_STATUS_ACCEPTED) {
+ wpabuf_free(peer->bootstrap.npba);
+ peer->bootstrap.npba = wpabuf_alloc(npba_len + 3);
+ if (peer->bootstrap.npba) {
+ wpabuf_put_u8(peer->bootstrap.npba, NAN_ATTR_NPBA);
+ wpabuf_put_le16(peer->bootstrap.npba, npba_len);
+ wpabuf_put_data(peer->bootstrap.npba, npba, npba_len);
+ } else {
+ wpa_printf(MSG_DEBUG,
+ "NAN: Bootstrap: Failed to store NPBA");
+ }
+ }
+
nan->cfg->bootstrap_completed(nan->cfg->cb_ctx,
peer->nmi_addr,
peer->bootstrap.requested_pbm,
@@ -382,6 +398,8 @@ bool nan_bootstrap_handle_rx(struct nan_data *nan, const u8 *peer_nmi,
u8 dialog_token, type, status, reason_code, cookie_len = 0;
u16 pbm, comeback_after = 0;
struct nan_peer *peer;
+ const u8 *orig_npba = npba;
+ u16 orig_npba_len = npba_len;
if (!nan_bootstrap_supported(nan)) {
wpa_printf(MSG_DEBUG,
@@ -463,10 +481,10 @@ bool nan_bootstrap_handle_rx(struct nan_data *nan, const u8 *peer_nmi,
}
}
- nan_bootstrap_handle_rx_request(nan, peer, dialog_token,
- pbm, cookie, cookie_len,
- status, handle,
- req_instance_id);
+ nan_bootstrap_handle_rx_request(nan, peer, dialog_token, pbm,
+ cookie, cookie_len, status,
+ handle, req_instance_id,
+ orig_npba, orig_npba_len);
return true;
}
@@ -562,7 +580,6 @@ int nan_bootstrap_request(struct nan_data *nan, int handle,
bool auth)
{
struct nan_peer *peer;
- struct wpabuf *npba;
int ret;
if (!nan || !nan->nan_started)
@@ -630,15 +647,15 @@ int nan_bootstrap_request(struct nan_data *nan, int handle,
peer->bootstrap.handle = handle;
peer->bootstrap.req_instance_id = req_instance_id;
- npba = nan_bootstrap_build_npba(nan, peer);
- if (!npba) {
+ peer->bootstrap.npba = nan_bootstrap_build_npba(nan, peer);
+ if (!peer->bootstrap.npba) {
nan_bootstrap_reset(nan, peer);
return -1;
}
ret = nan->cfg->transmit_followup(nan->cfg->cb_ctx, peer->nmi_addr,
- npba, handle, req_instance_id);
- wpabuf_free(npba);
+ peer->bootstrap.npba, handle,
+ req_instance_id);
if (ret) {
wpa_printf(MSG_DEBUG,
"NAN: Bootstrap: Failed to transmit follow-up");
diff --git a/src/nan/nan_i.h b/src/nan/nan_i.h
index 14eee57949..4983184690 100644
--- a/src/nan/nan_i.h
+++ b/src/nan/nan_i.h
@@ -422,6 +422,7 @@ struct nan_ndl {
* @in_progress: Whether a bootstrap exchange is in progress
* @handle: Follow-up context handle for the ongoing bootstrap request
* @req_instance_id: Instance ID of the bootstrap request
+ * @npba: The NPBA attribute from the last successful bootstrap
*/
struct nan_bootstrap {
u16 supported_methods;
@@ -441,6 +442,8 @@ struct nan_bootstrap {
int handle;
u8 req_instance_id;
+
+ struct wpabuf *npba;
};
/**
--
2.53.0
More information about the Hostap
mailing list