[PATCH 60/71] NAN: Support publishing NPBA in SDF frames
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Wed Apr 1 15:02:09 PDT 2026
Support configuring and publishing of Pairing Bootstrapping Methods
attribute (NPBA) in SDF frames.
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
src/common/nan_de.c | 33 +++++++++++++++++++++++++++++++++
src/common/nan_de.h | 12 ++++++++++++
wpa_supplicant/ctrl_iface.c | 10 ++++++++++
3 files changed, 55 insertions(+)
diff --git a/src/common/nan_de.c b/src/common/nan_de.c
index abcabfe407..38a4245745 100644
--- a/src/common/nan_de.c
+++ b/src/common/nan_de.c
@@ -82,6 +82,10 @@ struct nan_de_service {
u8 srf_bf_idx;
struct wpabuf *srf;
bool close_proximity;
+
+ /* Bootstrapping methods */
+ u16 pbm;
+
};
#define NAN_DE_N_MIN 5
@@ -267,6 +271,25 @@ static int nan_de_tx(struct nan_de *de, unsigned int freq,
}
+static void nan_buf_add_npba(struct nan_de *de, struct nan_de_service *srv,
+ struct wpabuf *buf)
+{
+ u8 type_and_status = NAN_PBA_TYPE_ADVERTISE |
+ (NAN_PBA_STATUS_ACCEPTED << NAN_PBA_STATUS_POS);
+
+ wpa_printf(MSG_DEBUG, "NAN: Add NPBA");
+
+ wpabuf_put_u8(buf, NAN_ATTR_BPBA);
+ wpabuf_put_le16(buf, 5);
+
+ /* Dialog token is 0 for advertise */
+ wpabuf_put_u8(buf, 0);
+ wpabuf_put_u8(buf, type_and_status);
+ wpabuf_put_u8(buf, NAN_REASON_RESERVED);
+ wpabuf_put_le16(buf, srv->pbm);
+}
+
+
static void nan_de_tx_sdf(struct nan_de *de, struct nan_de_service *srv,
unsigned int wait_time,
enum nan_service_control_type type,
@@ -308,6 +331,10 @@ static void nan_de_tx_sdf(struct nan_de *de, struct nan_de_service *srv,
if (srv->elems)
len += NAN_ATTR_HDR_LEN + 1 + wpabuf_len(srv->elems);
+ /* NPBA attribute (dialog token, type and status, reason, pbm */
+ if (srv->pbm && type != NAN_SRV_CTRL_FOLLOW_UP)
+ len += NAN_ATTR_HDR_LEN + 1 + 1 + 1 + 2;
+
/* Reserve some additional space for extra attributes */
if (de->cb.add_extra_attrs)
len += 256;
@@ -379,6 +406,9 @@ static void nan_de_tx_sdf(struct nan_de *de, struct nan_de_service *srv,
/* Use per-service source address if configured, otherwise use NMI */
forced_addr = srv->forced_addr_set ? srv->forced_addr : de->nmi;
+ if (srv->pbm && type != NAN_SRV_CTRL_FOLLOW_UP)
+ nan_buf_add_npba(de, srv, buf);
+
if (de->cb.add_extra_attrs)
de->cb.add_extra_attrs(de->cb.ctx, buf);
@@ -1765,6 +1795,8 @@ int nan_de_publish(struct nan_de *de, const char *service_name,
srv->is_p2p = p2p;
srv->is_pr = params->proximity_ranging && params->solicited;
srv->close_proximity = params->close_proximity;
+ srv->pbm = params->pbm;
+
nan_de_add_srv(de, srv);
nan_de_run_timer(de);
return publish_id;
@@ -2038,6 +2070,7 @@ int nan_de_subscribe(struct nan_de *de, const char *service_name,
srv->is_pr = params->proximity_ranging && params->active;
srv->sync = params->sync;
srv->close_proximity = params->close_proximity;
+ srv->pbm = params->pbm;
nan_de_add_srv(de, srv);
nan_de_run_timer(de);
diff --git a/src/common/nan_de.h b/src/common/nan_de.h
index ea47097f3e..e0d11af85c 100644
--- a/src/common/nan_de.h
+++ b/src/common/nan_de.h
@@ -135,6 +135,12 @@ struct nan_publish_params {
/* Source MAC address for this service (optional) */
const u8 *forced_addr;
+
+ /*
+ * Pairing Bootstrapping Methods as defined in Table 128 in Wi-Fi
+ * Aware specification v4.0
+ */
+ u16 pbm;
};
/* Returns -1 on failure or >0 publish_id */
@@ -200,6 +206,12 @@ struct nan_subscribe_params {
/* Source MAC address for this service (optional) */
const u8 *forced_addr;
+
+ /*
+ * Pairing Bootstrapping Methods as defined in Table 128 in Wi-Fi
+ * Aware specification v4.0
+ */
+ u16 pbm;
};
/* Returns -1 on failure or >0 subscribe_id */
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 8044b0356a..c724097ea2 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -12883,6 +12883,11 @@ static int wpas_ctrl_nan_publish(struct wpa_supplicant *wpa_s, char *cmd,
continue;
}
+ if (os_strncmp(token, "pbm=", 4) == 0) {
+ params.pbm = strtol(token + 4, NULL, 0);
+ continue;
+ }
+
wpa_printf(MSG_INFO, "CTRL: Invalid NAN_PUBLISH parameter: %s",
token);
goto fail;
@@ -13110,6 +13115,11 @@ static int wpas_ctrl_nan_subscribe(struct wpa_supplicant *wpa_s, char *cmd,
continue;
}
+ if (os_strncmp(token, "pbm=", 4) == 0) {
+ params.pbm = strtol(token + 4, NULL, 0);
+ continue;
+ }
+
wpa_printf(MSG_INFO,
"CTRL: Invalid NAN_SUBSCRIBE parameter: %s",
token);
--
2.53.0
More information about the Hostap
mailing list