[RFC PATCH 21/34] Add support to handle PR PASN auth rx frame

Peddolla Harshavardhan Reddy peddolla at qti.qualcomm.com
Thu May 15 00:17:44 PDT 2025


Signed-off-by: Peddolla Harshavardhan Reddy <peddolla at qti.qualcomm.com>
---
 src/common/proximity_ranging.c | 32 ++++++++++++++++++++++++++++++++
 src/common/proximity_ranging.h |  2 ++
 wpa_supplicant/events.c        |  4 +++-
 wpa_supplicant/pr_supplicant.c | 12 ++++++++++++
 wpa_supplicant/pr_supplicant.h | 10 ++++++++++
 5 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/src/common/proximity_ranging.c b/src/common/proximity_ranging.c
index 9c2f47627..a94c51bf0 100644
--- a/src/common/proximity_ranging.c
+++ b/src/common/proximity_ranging.c
@@ -1496,4 +1496,36 @@ int pr_pasn_auth_tx_status(struct pr_data *pr, const u8 *data, size_t data_len,
 	return 0;
 }
 
+
+int pr_pasn_auth_rx(struct pr_data *pr, const struct ieee80211_mgmt *mgmt,
+		    size_t len, int freq)
+{
+	struct pr_device *dev;
+	u16 auth_alg;
+
+	dev = pr_get_device(pr, mgmt->sa);
+	if (!dev) {
+		wpa_printf(MSG_ERROR, "PR: Peer not found " MACSTR,
+			   MAC2STR(mgmt->sa));
+		return -1;
+	}
+
+	if (os_memcmp(mgmt->da, pr->cfg->dev_addr, ETH_ALEN) != 0) {
+		wpa_printf(MSG_ERROR, "PR PASN: Not our frame");
+		return -1;
+	}
+
+	if (len < offsetof(struct ieee80211_mgmt, u.auth.variable))
+		return -1;
+
+	auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
+	if (auth_alg != WLAN_AUTH_PASN) {
+		wpa_printf(MSG_ERROR,
+			   "PR: Unexpected AUTH frame, auth_alg=%d", auth_alg);
+		return -1;
+	}
+
+	return 0;
+}
+
 #endif /* CONFIG_PASN */
diff --git a/src/common/proximity_ranging.h b/src/common/proximity_ranging.h
index 6c44505f3..3a351821a 100644
--- a/src/common/proximity_ranging.h
+++ b/src/common/proximity_ranging.h
@@ -407,5 +407,7 @@ int pr_initiate_pasn_auth(struct pr_data *pr, const u8 *addr, int freq,
 			  int forced_pr_freq);
 int pr_pasn_auth_tx_status(struct pr_data *pr, const u8 *data, size_t data_len,
 			   bool acked);
+int pr_pasn_auth_rx(struct pr_data *pr, const struct ieee80211_mgmt *mgmt,
+		    size_t len, int freq);
 
 #endif /* PROXIMITY_RANGING_H */
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index ccd7ee1e9..99e20a110 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -6150,7 +6150,6 @@ static int wpas_pasn_auth(struct wpa_supplicant *wpa_s,
 			  const struct ieee80211_mgmt *mgmt, size_t len,
 			  int freq)
 {
-#ifdef CONFIG_P2P
 	struct ieee802_11_elems elems;
 
 	if (len < 24) {
@@ -6167,9 +6166,12 @@ static int wpas_pasn_auth(struct wpa_supplicant *wpa_s,
 		return -2;
 	}
 
+#ifdef CONFIG_P2P
 	if (elems.p2p2_ie && elems.p2p2_ie_len)
 		return wpas_p2p_pasn_auth_rx(wpa_s, mgmt, len, freq);
 #endif /* CONFIG_P2P */
+	if (elems.proximity_ranging && elems.proximity_ranging_len)
+		return wpas_pr_pasn_auth_rx(wpa_s, mgmt, len, freq);
 
 	return wpas_pasn_auth_rx(wpa_s, mgmt, len);
 }
diff --git a/wpa_supplicant/pr_supplicant.c b/wpa_supplicant/pr_supplicant.c
index 19ed04d0c..e9f0e7ef7 100644
--- a/wpa_supplicant/pr_supplicant.c
+++ b/wpa_supplicant/pr_supplicant.c
@@ -359,4 +359,16 @@ int wpas_pr_pasn_auth_tx_status(struct wpa_supplicant *wpa_s, const u8 *data,
 	return pr_pasn_auth_tx_status(pr, data, data_len, acked);
 }
 
+
+int wpas_pr_pasn_auth_rx(struct wpa_supplicant *wpa_s,
+			 const struct ieee80211_mgmt *mgmt, size_t len,
+			 int freq)
+{
+	struct pr_data *pr = wpa_s->global->pr;
+
+	if (!pr)
+		return -2;
+	return pr_pasn_auth_rx(pr, mgmt, len, freq);
+}
+
 #endif /* CONFIG_PASN */
diff --git a/wpa_supplicant/pr_supplicant.h b/wpa_supplicant/pr_supplicant.h
index df5251c3b..22df69050 100644
--- a/wpa_supplicant/pr_supplicant.h
+++ b/wpa_supplicant/pr_supplicant.h
@@ -28,6 +28,9 @@ int wpas_pr_initiate_pasn_auth(struct wpa_supplicant *wpa_s,
 			       int forced_pr_freq);
 int wpas_pr_pasn_auth_tx_status(struct wpa_supplicant *wpa_s, const u8 *data,
 				size_t data_len, bool acked);
+int wpas_pr_pasn_auth_rx(struct wpa_supplicant *wpa_s,
+			 const struct ieee80211_mgmt *mgmt, size_t len,
+			 int freq);
 #else /* CONFIG_PR */
 static inline int wpas_pr_init(struct wpa_global *global,
 			       struct wpa_supplicant *wpa_s)
@@ -71,6 +74,13 @@ static inline int wpas_pr_pasn_auth_tx_status(struct wpa_supplicant *wpa_s,
 	return 0;
 }
 
+static inline int wpas_pr_pasn_auth_rx(struct wpa_supplicant *wpa_s,
+				       const struct ieee80211_mgmt *mgmt,
+				       size_t len, int freq)
+{
+	return 0;
+}
+
 #endif /* CONFIG_PR */
 
 #endif /*PR_SUPPLICANT_H */
-- 
2.34.1




More information about the Hostap mailing list