[PATCH v3 27/46] PR: Add PR_PASN_NEGOTIATION_STARTED event
Kavita Kavita
kavita.kavita at oss.qualcomm.com
Wed May 13 02:59:51 PDT 2026
From: Peddolla Harshavardhan Reddy <peddolla.reddy at oss.qualcomm.com>
Add a new supplicant event to signal the start of PASN negotiation
for proximity ranging.
Fire the event at the earliest point where both peers have committed
to the exchange:
- Initiator: after Auth frame 1 (M1) is successfully sent
- Responder: after M1 is received and Auth frame 2 (M2) is sent back
This allows the upper layer to know when a peer has initiated PASN
on the responder side, since the ROC runs silently in the background
without any prior indication.
Signed-off-by: Peddolla Harshavardhan Reddy <peddolla.reddy at oss.qualcomm.com>
---
src/common/proximity_ranging.c | 15 ++++++++++++++-
src/common/proximity_ranging.h | 13 +++++++++++++
src/common/wpa_ctrl.h | 5 +++++
wpa_supplicant/notify.c | 10 ++++++++++
wpa_supplicant/notify.h | 3 +++
wpa_supplicant/pr_supplicant.c | 11 +++++++++++
6 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/src/common/proximity_ranging.c b/src/common/proximity_ranging.c
index 4aa8ebee0..0ca9c95fe 100644
--- a/src/common/proximity_ranging.c
+++ b/src/common/proximity_ranging.c
@@ -1975,8 +1975,15 @@ int pr_initiate_pasn_auth(struct pr_data *pr, const u8 *addr, int freq,
pasn->group, pasn->freq, NULL, 0, NULL, 0,
NULL);
}
- if (ret)
+ if (ret) {
wpa_printf(MSG_INFO, "PR PASN: Failed to start PASN");
+ } else {
+ /* M1 sent successfully — notify that negotiation has started */
+ if (pr->cfg->negotiation_started)
+ pr->cfg->negotiation_started(pr->cfg->cb_ctx, addr,
+ ranging_role,
+ ranging_type);
+ }
out:
wpabuf_free(extra_ies);
@@ -2394,6 +2401,12 @@ static int pr_pasn_handle_auth_1(struct pr_data *pr, struct pr_device *dev,
pr->cfg->set_keys(pr->cfg->cb_ctx, pr->cfg->dev_addr,
dev->pr_device_addr, dev->pasn->cipher,
dev->pasn->akmp, &dev->pasn->ptk);
+
+ /* M1 received and M2 sent — notify that negotiation has started */
+ if (pr->cfg->negotiation_started)
+ pr->cfg->negotiation_started(pr->cfg->cb_ctx, mgmt->sa,
+ dev->ranging_role,
+ dev->protocol_type);
ret = 0;
fail:
diff --git a/src/common/proximity_ranging.h b/src/common/proximity_ranging.h
index 91fa3f652..a9d7ed16a 100644
--- a/src/common/proximity_ranging.h
+++ b/src/common/proximity_ranging.h
@@ -468,6 +468,19 @@ struct pr_config {
int (*pasn_send_mgmt)(void *ctx, const u8 *data, size_t data_len,
int noack, unsigned int freq, unsigned int wait);
+ /**
+ * negotiation_started - Called when PASN negotiation begins
+ * @ctx: Callback context from cb_ctx
+ * @peer_addr: MAC address of the peer
+ * @role: Ranging role (initiator or responder)
+ * @protocol_type: Ranging protocol type
+ *
+ * Fired on the initiator after Auth frame 1 (M1) is sent, and on the
+ * responder after Auth frame 1 (M1) is received and M2 is sent back.
+ */
+ void (*negotiation_started)(void *ctx, const u8 *peer_addr, u8 role,
+ u8 protocol_type);
+
void (*pasn_result)(void *ctx, u8 role, u8 protocol_type, u8 op_class,
u8 op_channel, const char *country);
diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h
index b16790fe6..922d5f82a 100644
--- a/src/common/wpa_ctrl.h
+++ b/src/common/wpa_ctrl.h
@@ -494,6 +494,11 @@ extern "C" {
/* PASN authentication status */
#define PASN_AUTH_STATUS "PASN-AUTH-STATUS "
+/* Proximity Ranging PASN negotiation started
+ * peer_addr=<MAC> role=<role> protocol=<protocol type>
+ */
+#define PR_PASN_NEGOTIATION_STARTED "PR-PASN-NEGOTIATION-STARTED "
+
/* Result of PASN performed for Proximity Ranging
* <result> role=<role> protocol=<protocol type> opclass=<op class> channel=<op channel> cc=<country>
*/
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index d0b317ee1..59fce8e9b 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -1539,6 +1539,16 @@ void wpas_notify_pr_pasn_result(struct wpa_supplicant *wpa_s, u8 role,
}
+void wpas_notify_pr_negotiation_started(struct wpa_supplicant *wpa_s,
+ const u8 *peer_addr, u8 role,
+ u8 protocol_type)
+{
+ wpa_msg_global(wpa_s, MSG_INFO, PR_PASN_NEGOTIATION_STARTED
+ "peer_addr=" MACSTR " role=%u protocol=%u",
+ MAC2STR(peer_addr), role, protocol_type);
+}
+
+
void wpas_notify_pr_ranging_params(struct wpa_supplicant *wpa_s,
const u8 *dev_addr, const u8 *peer_addr,
u8 ranging_role, u8 protocol_type, int freq,
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index f779a613a..eb4ce89a7 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -209,6 +209,9 @@ void wpas_notify_nan_nik_received(struct wpa_supplicant *wpa_s,
void wpas_notify_pr_pasn_result(struct wpa_supplicant *wpa_s, u8 role,
u8 protocol_type, u8 op_class, u8 op_channel,
const char *country);
+void wpas_notify_pr_negotiation_started(struct wpa_supplicant *wpa_s,
+ const u8 *peer_addr, u8 role,
+ u8 protocol_type);
void wpas_notify_pr_ranging_params(struct wpa_supplicant *wpa_s,
const u8 *dev_addr, const u8 *peer_addr,
u8 role, u8 protocol, int freq, int channel,
diff --git a/wpa_supplicant/pr_supplicant.c b/wpa_supplicant/pr_supplicant.c
index b47434eae..77e35aa1a 100644
--- a/wpa_supplicant/pr_supplicant.c
+++ b/wpa_supplicant/pr_supplicant.c
@@ -271,6 +271,16 @@ static int wpas_pr_pasn_send_mgmt(void *ctx, const u8 *data, size_t data_len,
}
+static void wpas_pr_pasn_negotiation_started(void *ctx, const u8 *peer_addr,
+ u8 role, u8 protocol_type)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ wpas_notify_pr_negotiation_started(wpa_s, peer_addr, role,
+ protocol_type);
+}
+
+
static void wpas_pr_pasn_result(void *ctx, u8 role, u8 protocol_type,
u8 op_class, u8 op_channel, const char *country)
{
@@ -433,6 +443,7 @@ int wpas_pr_init(struct wpa_global *global, struct wpa_supplicant *wpa_s,
pr.support_6ghz = capa->support_6ghz;
pr.pasn_send_mgmt = wpas_pr_pasn_send_mgmt;
+ pr.negotiation_started = wpas_pr_pasn_negotiation_started;
pr.pasn_result = wpas_pr_pasn_result;
pr.get_ranging_params = wpas_pr_ranging_params;
pr.set_keys = wpas_pr_pasn_set_keys;
--
2.34.1
More information about the Hostap
mailing list