[PATCH 1/2] NAN: Parse peer's maximum SSI length from DCEA
Paul Hu
paulhu at google.com
Tue Nov 10 20:51:56 PST 2026
Wi-Fi Aware R5 defines the Maximum Service Specific Info length for SDEA
in a follow-up unicast frame that a device can receive in bits b22-b37
of the Capability Info field of the Device Capability Extension
attribute (DCEA). This value is already advertised in DCEA, but the
value indicated by a peer was not parsed.
Parse the value from a 5-octet Capability Info field of the publisher's
DCEA, store it in the discovery result, and indicate it as max_ssi_len
in the NAN-DISCOVERY-RESULT event when it is nonzero. This allows an
upper layer to limit the length of Service Specific Info it sends to the
peer in follow-up frames.
Signed-off-by: Paul Hu <paulhu at google.com>
---
src/common/nan_de.c | 22 ++++++++++++++++------
src/common/nan_de.h | 1 +
src/common/nan_defs.h | 8 ++++++++
wpa_supplicant/notify.c | 11 +++++++++--
4 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/src/common/nan_de.c b/src/common/nan_de.c
index f070d82aa..6765979b9 100644
--- a/src/common/nan_de.c
+++ b/src/common/nan_de.c
@@ -2107,28 +2107,36 @@ static void nan_de_process_elem_container(struct nan_de *de, const u8 *buf,
static void nan_de_parse_dcea(const u8 *buf, size_t len, bool *pairing_setup,
- bool *npk_nik_caching)
+ bool *npk_nik_caching, u16 *peer_max_ssi_len)
{
const u8 *dcea;
u16 dcea_len;
*pairing_setup = false;
*npk_nik_caching = false;
+ *peer_max_ssi_len = 0;
dcea = nan_de_get_attr(buf, len, NAN_ATTR_DCEA, 0);
if (!dcea)
return;
dcea_len = WPA_GET_LE16(dcea + 1);
- if (dcea_len < 2) {
+ if (dcea_len < NAN_DEV_CAPA_EXT_MIN_LEN) {
wpa_printf(MSG_DEBUG, "NAN: DCEA length=%u too short",
dcea_len);
return;
}
- *pairing_setup = !!(dcea[4] & NAN_DEV_CAPA_EXT_INFO_1_PAIRING_SETUP);
- *npk_nik_caching = !!(dcea[4] &
+ /* Skip the attribute ID and length */
+ dcea += NAN_ATTR_HDR_LEN;
+
+ *pairing_setup = !!(dcea[1] & NAN_DEV_CAPA_EXT_INFO_1_PAIRING_SETUP);
+ *npk_nik_caching = !!(dcea[1] &
NAN_DEV_CAPA_EXT_INFO_1_NPK_NIK_CACHING);
+
+ /* Wi-Fi Aware R5: Capability Info bits b22-b37 specify max SSI length */
+ if (dcea_len >= NAN_DEV_CAPA_EXT_R5_LEN)
+ *peer_max_ssi_len = NAN_DEV_CAPA_EXT_GET_MAX_SSI_LEN(dcea);
}
@@ -2329,11 +2337,13 @@ send_event:
/*
* Parse Device Capability Extension attribute for pairing
- * setup and NPK/NIK caching support
+ * setup and NPK/NIK caching support and the maximum Service
+ * Specific Info length
*/
nan_de_parse_dcea(buf, buf_len,
&res.pairing_setup_supp,
- &res.npk_nik_caching_supp);
+ &res.npk_nik_caching_supp,
+ &res.peer_max_ssi_len);
/* Get the bootstrapping methods */
res.pbm = nan_de_get_advertise_pbm(buf, buf_len);
diff --git a/src/common/nan_de.h b/src/common/nan_de.h
index 17efd8552..9392fba54 100644
--- a/src/common/nan_de.h
+++ b/src/common/nan_de.h
@@ -47,6 +47,7 @@ struct nan_discovery_result {
const char *psi_vendor_name;
const char *psi_model_name;
const char *psi_pairing_name;
+ u16 peer_max_ssi_len;
};
struct nan_callbacks {
diff --git a/src/common/nan_defs.h b/src/common/nan_defs.h
index e5acd824c..641100a43 100644
--- a/src/common/nan_defs.h
+++ b/src/common/nan_defs.h
@@ -669,6 +669,14 @@ struct nan_shared_key {
/* b22-b37: Maximum Service Specific Info length for SDEA in follow up unicast
* frame the device can receive */
+#define NAN_DEV_CAPA_EXT_GET_MAX_SSI_LEN(info) \
+ ((((info)[2] >> 6) & 0x03) | \
+ (((u16) (info)[3]) << 2) | \
+ (((u16) ((info)[4] & 0x3F)) << 10))
+
+/* Capability Info field length with b0-b15 and with b0-b39 */
+#define NAN_DEV_CAPA_EXT_MIN_LEN 2
+#define NAN_DEV_CAPA_EXT_R5_LEN 5
/* Wi-Fi Aware spec v4.0, Table 22 (NIRA Cryptographic Parameters and Methods)
*/
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 2b198c386..a552cdb54 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -1106,6 +1106,7 @@ void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s,
char *ssi_hex, *pmkid_hex = NULL;
char *cipher_suites_str = NULL;
char proxied[100];
+ char max_ssi[30];
const char *locale;
const char *vendor;
const char *model;
@@ -1173,9 +1174,15 @@ err:
else
proxied[0] = '\0';
+ if (res->peer_max_ssi_len)
+ os_snprintf(max_ssi, sizeof(max_ssi), " max_ssi_len=%u",
+ res->peer_max_ssi_len);
+ else
+ max_ssi[0] = '\0';
+
wpa_msg_global(wpa_s, MSG_INFO, NAN_DISCOVERY_RESULT
"subscribe_id=%d publish_id=%d address=" MACSTR
- " fsd=%d fsd_gas=%d srv_proto_type=%u ssi=%s%s%s%s%s pairing_setup_supp=%d npk_nik_caching_supp=%d pbm=0x%04x data_path=%d%s%s%s%s%s%s%s%s%s",
+ " fsd=%d fsd_gas=%d srv_proto_type=%u ssi=%s%s%s%s%s pairing_setup_supp=%d npk_nik_caching_supp=%d pbm=0x%04x data_path=%d%s%s%s%s%s%s%s%s%s%s",
res->subscribe_id, res->peer_publish_id,
MAC2STR(res->peer_addr),
res->fsd, res->fsd_gas, res->srv_proto_type, ssi_hex,
@@ -1184,7 +1191,7 @@ err:
cipher_suites_str ? " cipher_suites=" : "",
cipher_suites_str ? cipher_suites_str : "",
res->pairing_setup_supp, res->npk_nik_caching_supp,
- res->pbm, res->data_path, proxied,
+ res->pbm, res->data_path, proxied, max_ssi,
res->psi_locale ? " locale=" : "", locale,
res->psi_vendor_name ? " vendorName=" : "", vendor,
res->psi_model_name ? " modelName=" : "", model,
--
2.56.0.542.g3ef89b7020-goog
More information about the Hostap
mailing list