[PATCH v2 2/3] NAN: Add pairing parameters to discovery result notifications
Junyu Lai
junyulai at google.com
Mon Nov 2 22:38:04 PST 2026
Upper-layer notification consumers need the peer's NAN pairing
configuration, supported bootstrap methods, and NAN Identity Resolution
Attribute (NIRA) nonce and tag when a service is discovered. During
Unsynchronized Service Discovery (USD) on non-NAN interfaces (such as
p2p0 for Wi-Fi Direct R2), wpa_s->nan is NULL, so discovery result
processing must fall back to default pairing values instead of aborting.
- Query peer pairing configuration and supported bootstrap methods in
wpas_nan_de_discovery_result() when wpa_s->nan is non-NULL.
- Forward the pairing flags, bootstrap methods, and NIRA nonce and tag
to wpas_notify_nan_discovery_result().
Signed-off-by: Junyu Lai <junyulai at google.com>
---
v2:
- Rebase onto latest main.
---
wpa_supplicant/nan_supplicant.c | 39 ++++++++++++++++++++++++++++++++-
wpa_supplicant/notify.c | 8 ++++++-
wpa_supplicant/notify.h | 8 ++++++-
3 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index 60d0c4ae0..cc4d1a678 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -4957,6 +4957,12 @@ static void
wpas_nan_de_discovery_result(void *ctx, struct nan_discovery_result *res)
{
struct wpa_supplicant *wpa_s = ctx;
+ const u8 *nonce = NULL;
+ const u8 *tag = NULL;
+ u16 bootstrap_methods = 0;
+ bool pairing_setup = false;
+ bool npk_caching = false;
+ bool pairing_verification = false;
#ifdef CONFIG_NAN
if (wpa_s->nan && !nan_get_peer(wpa_s->nan, res->peer_addr)) {
@@ -4972,9 +4978,40 @@ wpas_nan_de_discovery_result(void *ctx, struct nan_discovery_result *res)
"NAN: No raw buffer to add peer");
}
}
+
+ if (wpa_s->nan != NULL) {
+ const struct nan_pairing_cfg *pairing_cfg;
+
+ pairing_cfg = nan_peer_get_pairing_cfg(wpa_s->nan,
+ res->peer_addr,
+ &nonce, &tag);
+ if (!pairing_cfg) {
+ wpa_printf(MSG_DEBUG,
+ "NAN: Pairing config not available for peer "
+ MACSTR, MAC2STR(res->peer_addr));
+ } else {
+ pairing_setup = pairing_cfg->pairing_setup;
+ npk_caching = pairing_cfg->npk_caching;
+ pairing_verification =
+ pairing_cfg->pairing_verification;
+ }
+
+ if (nan_bootstrap_get_supported_methods(
+ wpa_s->nan, res->peer_addr,
+ &bootstrap_methods) < 0) {
+ wpa_printf(MSG_DEBUG,
+ "NAN: Failed to get bootstrap methods for peer "
+ MACSTR, MAC2STR(res->peer_addr));
+ }
+ }
#endif /* CONFIG_NAN */
- wpas_notify_nan_discovery_result(wpa_s, res);
+ wpas_notify_nan_discovery_result(wpa_s, res,
+ pairing_setup,
+ npk_caching,
+ pairing_verification,
+ bootstrap_methods,
+ nonce, tag);
}
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 88ca92206..f4daba6b9 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -1101,7 +1101,13 @@ void wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s,
#if defined(CONFIG_NAN) || defined(CONFIG_NAN_USD)
void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s,
- struct nan_discovery_result *res)
+ struct nan_discovery_result *res,
+ bool pairing_setup,
+ bool pairing_cache,
+ bool pairing_verification,
+ u16 pbm,
+ const u8 *nonce,
+ const u8 *tag)
{
char *ssi_hex, *pmkid_hex = NULL;
char *cipher_suites_str = NULL;
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index 00e2fdafc..b2e1c8c26 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -187,7 +187,13 @@ void wpas_notify_signal_change(struct wpa_supplicant *wpa_s);
void wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s,
const char *url);
void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s,
- struct nan_discovery_result *res);
+ struct nan_discovery_result *res,
+ bool pairing_setup,
+ bool pairing_cache,
+ bool pairing_verification,
+ u16 pbm,
+ const u8 *nonce,
+ const u8 *tag);
void wpas_notify_nan_replied(struct wpa_supplicant *wpa_s,
enum nan_service_protocol_type srv_proto_type,
int publish_id, int peer_subscribe_id,
--
2.56.0.385.gac671c819a-goog
More information about the Hostap
mailing list