From da95d9da51a17d65f5255aa9b75b7c48ec1c3eb0 Mon Sep 17 00:00:00 2001 From: Peddolla Harshavardhan Reddy Date: Sun, 27 Apr 2025 02:38:45 +0530 Subject: [PATCH] PR: Deliver received PR PASN auth frames for processing If a Proximity Ranging element is present in the PASN frame, it is processed by proximity ranging implementation. Deliver the frame there instead of the generic PASN processing. The actual PR processing will be added in separate commits. Signed-off-by: Peddolla Harshavardhan Reddy --- src/common/ieee802_11_common.c | 5 +++++ src/common/ieee802_11_common.h | 2 ++ src/common/proximity_ranging.c | 33 +++++++++++++++++++++++++++++++++ src/common/proximity_ranging.h | 2 ++ wpa_supplicant/events.c | 6 +++++- wpa_supplicant/pr_supplicant.c | 13 +++++++++++++ wpa_supplicant/pr_supplicant.h | 10 ++++++++++ 7 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c index ae7a7647a..82a4c1f73 100644 --- a/src/common/ieee802_11_common.c +++ b/src/common/ieee802_11_common.c @@ -165,6 +165,11 @@ static int ieee802_11_parse_vendor_specific(const u8 *pos, size_t elen, elems->p2p2_ie = pos; elems->p2p2_ie_len = elen; break; + case PR_OUI_TYPE: + /* Wi-Fi Alliance - Proximity Ranging element */ + elems->proximity_ranging = pos; + elems->proximity_ranging_len = elen; + break; default: wpa_printf(MSG_MSGDUMP, "Unknown WFA " "information element ignored " diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h index 5f52b573c..906c13854 100644 --- a/src/common/ieee802_11_common.h +++ b/src/common/ieee802_11_common.h @@ -122,6 +122,7 @@ struct ieee802_11_elems { const u8 *rsnxe_override; const u8 *rsn_selection; const u8 *wfa_capab; + const u8 *proximity_ranging; u8 ssid_len; u8 supp_rates_len; @@ -191,6 +192,7 @@ struct ieee802_11_elems { size_t rsnxe_override_len; size_t rsn_selection_len; u8 wfa_capab_len; + size_t proximity_ranging_len; struct mb_ies_info mb_ies; diff --git a/src/common/proximity_ranging.c b/src/common/proximity_ranging.c index 79a6f3a2d..a88492918 100644 --- a/src/common/proximity_ranging.c +++ b/src/common/proximity_ranging.c @@ -1570,4 +1570,37 @@ int pr_pasn_auth_tx_status(struct pr_data *pr, const u8 *data, size_t data_len, return ret; } + +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_INFO, "PR: Peer not found " MACSTR, + MAC2STR(mgmt->sa)); + return -1; + } + + if (!ether_addr_equal(mgmt->da, pr->cfg->dev_addr)) { + wpa_printf(MSG_INFO, "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_INFO, + "PR: Unexpected Authentication 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 9dc75719b..736c626bf 100644 --- a/src/common/proximity_ranging.h +++ b/src/common/proximity_ranging.h @@ -469,5 +469,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 0d6244026..a4cb85b23 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -6205,7 +6205,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; size_t auth_length; @@ -6231,9 +6230,14 @@ 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 */ +#ifdef CONFIG_PR + if (elems.proximity_ranging && elems.proximity_ranging_len) + return wpas_pr_pasn_auth_rx(wpa_s, mgmt, len, freq); +#endif /* CONFIG_PR */ return wpas_pasn_auth_rx(wpa_s, mgmt, len); } diff --git a/wpa_supplicant/pr_supplicant.c b/wpa_supplicant/pr_supplicant.c index 5bdb121c9..c12013707 100644 --- a/wpa_supplicant/pr_supplicant.c +++ b/wpa_supplicant/pr_supplicant.c @@ -10,6 +10,7 @@ #include "utils/common.h" #include "utils/eloop.h" +#include "common/ieee802_11_defs.h" #include "common/proximity_ranging.h" #include "p2p/p2p.h" #include "wpa_supplicant_i.h" @@ -538,4 +539,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 b4c128305..891fef0df 100644 --- a/wpa_supplicant/pr_supplicant.h +++ b/wpa_supplicant/pr_supplicant.h @@ -27,6 +27,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 */ @@ -72,6 +75,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.47.3