[PATCH 16/16] PR: Notify upper layers when a ranging session ends
Peddolla Harshavardhan Reddy
peddolla.reddy at oss.qualcomm.com
Sun Jul 12 23:30:04 PDT 2026
Currently when a proximity ranging session ends due to a timeout,
PASN negotiation failure, user abort, or kernel measurement complete
event, no notification is sent to upper layers. The client has no
way to know the session has ended.
Introduce enum pr_session_end_reason with reason codes for
each exit path and add wpas_notify_pr_ranging_terminated() in
notify.c as a wpa_msg_global bridge. Wire the new notify function
to the five exit paths in pr_supplicant.c: session timeout, PASN
timeout, user abort, measurement complete, and PASN negotiation
failure.
Signed-off-by: Peddolla Harshavardhan Reddy <peddolla.reddy at oss.qualcomm.com>
---
src/common/proximity_ranging.h | 10 ++++++++++
src/common/wpa_ctrl.h | 1 +
wpa_supplicant/notify.c | 7 +++++++
wpa_supplicant/notify.h | 2 ++
wpa_supplicant/pr_supplicant.c | 8 ++++++++
5 files changed, 28 insertions(+)
diff --git a/src/common/proximity_ranging.h b/src/common/proximity_ranging.h
index dd1d3ab76..f13778b94 100644
--- a/src/common/proximity_ranging.h
+++ b/src/common/proximity_ranging.h
@@ -47,6 +47,16 @@
#define PR_NEGOTIATION_UPDATE 1
#define PR_NEGOTIATION_FAIL 2
+/**
+ * enum pr_session_end_reason - Reason codes for ranging session end
+ */
+enum pr_session_end_reason {
+ PR_SESSION_END_TIMEOUT = 0,
+ PR_SESSION_END_USER_ABORT = 1,
+ PR_SESSION_END_PEER_COMPLETE = 2,
+ PR_SESSION_END_NEG_FAILED = 3,
+};
+
enum pr_pasn_role {
PR_ROLE_IDLE = 0,
PR_ROLE_PASN_INITIATOR,
diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h
index b2e941d59..939b7ccd3 100644
--- a/src/common/wpa_ctrl.h
+++ b/src/common/wpa_ctrl.h
@@ -505,6 +505,7 @@ extern "C" {
* <result> role=<role> protocol=<protocol type> opclass=<op class> channel=<op channel> cc=<country>
*/
#define PR_PASN_RESULT "PR-PASN-RESULT "
+#define PR_RANGING_TERMINATED "PR-RANGING-TERMINATED "
/* Proximity Ranging parameters to use in ranging */
#define PR_RANGING_PARAMS "PR-RANGING-PARAMS "
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 71f6ce66a..1e69b9bc7 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -1640,4 +1640,11 @@ void wpas_notify_pr_device_found(struct wpa_supplicant *wpa_s,
dev->dik_valid);
}
+
+void wpas_notify_pr_ranging_terminated(struct wpa_supplicant *wpa_s, int reason)
+{
+ wpa_msg_global(wpa_s, MSG_INFO, PR_RANGING_TERMINATED "reason=%d",
+ reason);
+}
+
#endif /* CONFIG_PR */
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index c72439b03..3a0fe3e38 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -271,5 +271,7 @@ void wpas_notify_nan_pairing_status(struct wpa_supplicant *wpa_s,
void wpas_notify_nan_chan_evacuation(struct wpa_supplicant *wpa_s,
u8 map_id, int freq);
void wpas_notify_nan_stopped(struct wpa_supplicant *wpa_s);
+void wpas_notify_pr_ranging_terminated(struct wpa_supplicant *wpa_s,
+ int reason);
#endif /* NOTIFY_H */
diff --git a/wpa_supplicant/pr_supplicant.c b/wpa_supplicant/pr_supplicant.c
index fd9de5b27..c35e974fe 100644
--- a/wpa_supplicant/pr_supplicant.c
+++ b/wpa_supplicant/pr_supplicant.c
@@ -410,6 +410,7 @@ static void wpas_pr_ranging_session_timeout(void *eloop_ctx, void *timeout_ctx)
wpas_pr_clear_ranging_params(pr);
wpas_pr_pd_stop(wpa_s);
+ wpas_notify_pr_ranging_terminated(wpa_s, PR_SESSION_END_TIMEOUT);
}
@@ -875,6 +876,8 @@ void wpas_pr_measurement_complete(struct wpa_supplicant *wpa_s,
wpas_notify_pr_ranging_complete(wpa_s, complete->cookie);
wpas_pr_clear_ranging_params(pr);
wpas_pr_pd_stop(wpa_s);
+ wpas_notify_pr_ranging_terminated(wpa_s,
+ PR_SESSION_END_PEER_COMPLETE);
}
@@ -1077,6 +1080,7 @@ static void wpas_pr_pasn_roc_total_timeout(void *eloop_ctx, void *timeout_ctx)
wpas_pr_cancel_roc(wpa_s);
wpas_pr_pasn_abort_responder(wpa_s);
+ wpas_notify_pr_ranging_terminated(wpa_s, PR_SESSION_END_NEG_FAILED);
}
@@ -1213,6 +1217,7 @@ static void wpas_pr_pasn_timeout(void *eloop_ctx, void *timeout_ctx)
wpas_pr_clear_ranging_params(wpa_s->global->pr);
wpa_printf(MSG_DEBUG, "PR: PASN timed out");
+ wpas_notify_pr_ranging_terminated(wpa_s, PR_SESSION_END_NEG_FAILED);
}
@@ -1713,6 +1718,8 @@ int wpas_pr_pasn_auth_rx(struct wpa_supplicant *wpa_s,
wpas_pr_pasn_auth_work_done(wpa_s);
wpas_pr_pd_stop(wpa_s);
wpas_pr_clear_ranging_params(wpa_s->global->pr);
+ wpas_notify_pr_ranging_terminated(wpa_s,
+ PR_SESSION_END_NEG_FAILED);
}
return ret;
@@ -1753,6 +1760,7 @@ void wpas_pr_abort_ranging(struct wpa_supplicant *wpa_s)
/* Free ranging params so a new session can be started */
wpas_pr_clear_ranging_params(pr);
+ wpas_notify_pr_ranging_terminated(wpa_s, PR_SESSION_END_USER_ABORT);
}
#endif /* CONFIG_PASN */
--
2.34.1
More information about the Hostap
mailing list