]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
PR: Deliver received PR PASN auth frames for processing
authorPeddolla Harshavardhan Reddy <peddolla@qti.qualcomm.com>
Sat, 26 Apr 2025 21:08:45 +0000 (02:38 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 17 Oct 2025 10:22:51 +0000 (13:22 +0300)
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 <peddolla@qti.qualcomm.com>
src/common/ieee802_11_common.c
src/common/ieee802_11_common.h
src/common/proximity_ranging.c
src/common/proximity_ranging.h
wpa_supplicant/events.c
wpa_supplicant/pr_supplicant.c
wpa_supplicant/pr_supplicant.h

index ae7a7647a5bbfb63ef042b9dbb9db869f59d3022..82a4c1f734c431fc9ff5aafb86a4e49684b2f993 100644 (file)
@@ -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 "
index 5f52b573cf5434f88ec61a3713b7ff711d8c142b..906c13854615d9cd8ab20ef9102c55a4f153e691 100644 (file)
@@ -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;
 
index 79a6f3a2dbbcd3886bdd72ca39cc48b7ee86451d..a88492918bdc56f8588167137fccdf231e8f0df3 100644 (file)
@@ -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 */
index 9dc75719b27b8434c929a1cbb34a3dda2fdd7156..736c626bfe837243abf937c14784e72f5c679798 100644 (file)
@@ -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 */
index 0d62440267a6eda20db1608c6d518fe44a402f51..a4cb85b23b863ca5e5eb74f80a5570558691ceef 100644 (file)
@@ -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);
 }
index 5bdb121c99ff38c2405b47decd9e6f951ae37c92..c12013707bdc5afb2ad73ab18972d52350128217 100644 (file)
@@ -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 */
index b4c1283051764817459b06c565ed5027bfc42915..891fef0dfda57d88d4dbfee4d8871a224c0eff70 100644 (file)
@@ -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 */