[PATCH 15/16] PR: Notify upper layers when a PR capable peer is discovered via USD
Peddolla Harshavardhan Reddy
peddolla.reddy at oss.qualcomm.com
Sun Jul 12 23:30:03 PDT 2026
When USD discovers a peer with Proximity Ranging capabilities,
pr_process_usd_elems() parses and stores the peer's capabilities
but fires no event to upper layers. Add a device_found callback to
struct pr_config and invoke it at the end of pr_process_usd_elems()
after all three capability structures have been populated. Implement
the callback in the supplicant layer to emit a PR-PEER-FOUND control
interface event carrying the full set of discovered peer information:
PASN type, EDCA and NTB capability details, secure LTF and 6 GHz
support flags, discovery frequency, and DIRA validation status.
Signed-off-by: Peddolla Harshavardhan Reddy <peddolla.reddy at oss.qualcomm.com>
---
src/common/proximity_ranging.c | 3 +++
src/common/proximity_ranging.h | 3 +++
src/common/wpa_ctrl.h | 8 ++++++++
wpa_supplicant/notify.c | 26 ++++++++++++++++++++++++++
wpa_supplicant/notify.h | 3 +++
wpa_supplicant/pr_supplicant.c | 9 +++++++++
6 files changed, 52 insertions(+)
diff --git a/src/common/proximity_ranging.c b/src/common/proximity_ranging.c
index 2df768e1c..5711ba110 100644
--- a/src/common/proximity_ranging.c
+++ b/src/common/proximity_ranging.c
@@ -1275,6 +1275,9 @@ void pr_process_usd_elems(struct pr_data *pr, const u8 *ies, u16 ies_len,
if (msg.dira && msg.dira_len)
pr_validate_dira(pr, dev, msg.dira, msg.dira_len);
+ if (pr->cfg->device_found)
+ pr->cfg->device_found(pr->cfg->cb_ctx, dev);
+
pr_parse_free(&msg);
}
diff --git a/src/common/proximity_ranging.h b/src/common/proximity_ranging.h
index d992464c7..dd1d3ab76 100644
--- a/src/common/proximity_ranging.h
+++ b/src/common/proximity_ranging.h
@@ -12,6 +12,7 @@
#include "wpa_common.h"
#include "utils/list.h"
#include "wps/wps_defs.h"
+#include "common/ieee802_11_common.h"
#define DEVICE_IDENTITY_KEY_LEN 16
#define DEVICE_IDENTITY_TAG_LEN 8
@@ -591,6 +592,8 @@ struct pr_config {
const u8 *peer_addr, u8 ranging_role,
u8 protocol_type, u8 op_class, u8 op_channel,
u8 self_format_bw, u8 peer_format_bw);
+
+ void (*device_found)(void *ctx, const struct pr_device *dev);
};
struct pr_data {
diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h
index 69f710185..b2e941d59 100644
--- a/src/common/wpa_ctrl.h
+++ b/src/common/wpa_ctrl.h
@@ -515,6 +515,14 @@ extern "C" {
/* Proximity Ranging measurement session complete */
#define PR_EVENT_RANGING_COMPLETE "PR-RANGING-COMPLETE "
+/* Proximity Ranging capable peer discovered via USD
+ * peer_addr=<MAC> pasn_type=0x<hex> name=<string>
+ * edca=<0|1> edca_ista=<0|1> edca_rsta=<0|1>
+ * ntb=<0|1> ntb_ista=<0|1> ntb_rsta=<0|1>
+ * secure_ltf=<0|1> 6ghz=<0|1> freq=<MHz> dik_valid=<0|1>
+ */
+#define PR_PEER_FOUND "PR-PEER-FOUND "
+
/* BSS command information masks */
#define WPA_BSS_MASK_ALL 0xFFFDFFFF
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index af1b4e3da..71f6ce66a 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -11,6 +11,7 @@
#include "utils/common.h"
#include "common/wpa_ctrl.h"
#include "common/nan_de.h"
+#include "common/proximity_ranging.h"
#include "config.h"
#include "wpa_supplicant_i.h"
#include "wps_supplicant.h"
@@ -1614,4 +1615,29 @@ void wpas_notify_pr_ranging_complete(struct wpa_supplicant *wpa_s, u64 cookie)
"cookie=%llu", (unsigned long long) cookie);
}
+
+void wpas_notify_pr_device_found(struct wpa_supplicant *wpa_s,
+ const struct pr_device *dev)
+{
+ wpa_msg_global(wpa_s, MSG_INFO, PR_PEER_FOUND
+ "peer_addr=" MACSTR
+ " pasn_type=0x%02x name=%s"
+ " edca=%d edca_ista=%d edca_rsta=%d"
+ " ntb=%d ntb_ista=%d ntb_rsta=%d"
+ " secure_ltf=%d 6ghz=%d freq=%d dik_valid=%d",
+ MAC2STR(dev->pr_device_addr),
+ dev->pr_caps.pasn_type,
+ dev->pr_caps.device_name,
+ dev->pr_caps.edca_support,
+ dev->edca_caps.ista_support,
+ dev->edca_caps.rsta_support,
+ dev->pr_caps.ntb_support,
+ dev->ntb_caps.ista_support,
+ dev->ntb_caps.rsta_support,
+ dev->pr_caps.secure_he_ltf,
+ dev->pr_caps.support_6ghz,
+ dev->listen_freq,
+ dev->dik_valid);
+}
+
#endif /* CONFIG_PR */
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index 43e978aed..c72439b03 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -20,6 +20,7 @@ struct rsn_pmksa_cache_entry;
enum nan_de_reason;
enum nan_service_protocol_type;
struct nan_discovery_result;
+struct pr_device;
int wpas_notify_supplicant_initialized(struct wpa_global *global);
void wpas_notify_supplicant_deinitialized(struct wpa_global *global);
@@ -223,6 +224,8 @@ void wpas_notify_pr_measurement_result(
const struct peer_measurement_result *result);
void wpas_notify_pr_ranging_complete(struct wpa_supplicant *wpa_s,
u64 cookie);
+void wpas_notify_pr_device_found(struct wpa_supplicant *wpa_s,
+ const struct pr_device *dev);
void wpas_notify_nan_bootstrap_request(struct wpa_supplicant *wpa_s,
const u8 *peer_addr, u16 pbm,
int handle, u8 requestor_instance_id);
diff --git a/wpa_supplicant/pr_supplicant.c b/wpa_supplicant/pr_supplicant.c
index fabc8061d..fd9de5b27 100644
--- a/wpa_supplicant/pr_supplicant.c
+++ b/wpa_supplicant/pr_supplicant.c
@@ -358,6 +358,14 @@ static int wpas_pr_pasn_send_mgmt(void *ctx, const u8 *data, size_t data_len,
}
+static void wpas_pr_device_found(void *ctx, const struct pr_device *dev)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ wpas_notify_pr_device_found(wpa_s, dev);
+}
+
+
static void wpas_pr_pasn_negotiation_started(void *ctx, const u8 *peer_addr,
u8 role, u8 protocol_type)
{
@@ -702,6 +710,7 @@ int wpas_pr_init(struct wpa_global *global, struct wpa_supplicant *wpa_s,
pr.pasn_result = wpas_pr_pasn_result;
pr.get_ranging_params = wpas_pr_ranging_params;
pr.set_keys = wpas_pr_pasn_set_keys;
+ pr.device_found = wpas_pr_device_found;
pr.clear_keys = wpas_pr_pasn_clear_keys;
pr.secure_he_ltf = wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_SEC_LTF_STA;
--
2.34.1
More information about the Hostap
mailing list