]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P2: Add alternative PASN RX handler
authorShivani Baranwal <quic_shivbara@quicinc.com>
Sun, 4 Aug 2024 21:13:59 +0000 (02:43 +0530)
committerJouni Malinen <j@w1.fi>
Wed, 11 Sep 2024 23:58:32 +0000 (02:58 +0300)
This is needed for P2P2 pairing using PASN. The actual processing will
be covered in separate commits.

Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
src/p2p/p2p.c
src/p2p/p2p.h
wpa_supplicant/events.c
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/p2p_supplicant.h

index cdb443cda6abb9b614e09020dd62df4d5ee20e32..923f0725c26c7c4fb72bbde017828852a9c0e078 100644 (file)
@@ -5944,3 +5944,12 @@ void p2p_process_usd_elems(struct p2p_data *p2p, const u8 *ies, u16 ies_len,
 
        p2p_parse_free(&msg);
 }
+
+
+#ifdef CONFIG_PASN
+int p2p_pasn_auth_rx(struct p2p_data *p2p, const struct ieee80211_mgmt *mgmt,
+                    size_t len, int freq)
+{
+       return -1; /* TODO */
+}
+#endif /* CONFIG_PASN */
index 7df2063f12e01cfd0758b8f5c6b9ce8ede8aa39a..56a8f9e5fae72e2806d8d2e3d086e22c07ebaa13 100644 (file)
@@ -2576,5 +2576,7 @@ int p2p_channel_to_freq(int op_class, int channel);
 struct wpabuf * p2p_usd_elems(struct p2p_data *p2p);
 void p2p_process_usd_elems(struct p2p_data *p2p, const u8 *ies, u16 ies_len,
                           const u8 *peer_addr, unsigned int freq);
+int p2p_pasn_auth_rx(struct p2p_data *p2p, const struct ieee80211_mgmt *mgmt,
+                    size_t len, int freq);
 
 #endif /* P2P_H */
index 724f2413f77ac67fed4934dde36043ed58db4060..9e767e010d1a814de976605e5f34e51f3ecf92ab 100644 (file)
@@ -6099,6 +6099,37 @@ static void wpas_link_reconfig(struct wpa_supplicant *wpa_s)
 }
 
 
+#ifdef CONFIG_PASN
+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) {
+               wpa_printf(MSG_DEBUG, "nl80211: Too short Management frame");
+               return -2;
+       }
+
+       if (ieee802_11_parse_elems(mgmt->u.auth.variable,
+                                  len - offsetof(struct ieee80211_mgmt,
+                                                 u.auth.variable),
+                                  &elems, 1) == ParseFailed) {
+               wpa_printf(MSG_DEBUG,
+                          "PASN: Failed parsing Authentication frame");
+               return -2;
+       }
+
+       if (elems.p2p2_ie && elems.p2p2_ie_len)
+               return wpas_p2p_pasn_auth_rx(wpa_s, mgmt, len, freq);
+#endif /* CONFIG_P2P */
+
+       return wpas_pasn_auth_rx(wpa_s, mgmt, len);
+}
+#endif /* CONFIG_PASN */
+
+
 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                          union wpa_event_data *data)
 {
@@ -6605,8 +6636,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                        }
 #ifdef CONFIG_PASN
                        if (stype == WLAN_FC_STYPE_AUTH &&
-                           wpas_pasn_auth_rx(wpa_s, mgmt,
-                                             data->rx_mgmt.frame_len) != -2)
+                           wpas_pasn_auth(wpa_s, mgmt, data->rx_mgmt.frame_len,
+                                          data->rx_mgmt.freq) != -2)
                                break;
 #endif /* CONFIG_PASN */
 
index 259ae47dddcfedca0a1d20110fd6c8cf87428b16..2f0d77342c67d769df5987a178617f0a064df0d1 100644 (file)
@@ -10380,3 +10380,17 @@ void wpas_p2p_process_usd_elems(struct wpa_supplicant *wpa_s, const u8 *buf,
                return;
        p2p_process_usd_elems(p2p, buf, buf_len, peer_addr, freq);
 }
+
+
+#ifdef CONFIG_PASN
+int wpas_p2p_pasn_auth_rx(struct wpa_supplicant *wpa_s,
+                         const struct ieee80211_mgmt *mgmt, size_t len,
+                         int freq)
+{
+       struct p2p_data *p2p = wpa_s->global->p2p;
+
+       if (wpa_s->global->p2p_disabled || !p2p)
+               return -2;
+       return p2p_pasn_auth_rx(p2p, mgmt, len, freq);
+}
+#endif /* CONFIG_PASN */
index a0fbddcea7fd212a4c7b0ccb114cae9822719f4f..0488de46b93d7228c49c1f9cbec05a2b16b344e0 100644 (file)
@@ -230,6 +230,9 @@ int wpas_p2p_lo_start(struct wpa_supplicant *wpa_s, unsigned int freq,
 int wpas_p2p_lo_stop(struct wpa_supplicant *wpa_s);
 int wpas_p2p_mac_setup(struct wpa_supplicant *wpa_s);
 struct wpabuf * wpas_p2p_usd_elems(struct wpa_supplicant *wpa_s);
+int wpas_p2p_pasn_auth_rx(struct wpa_supplicant *wpa_s,
+                         const struct ieee80211_mgmt *mgmt, size_t len,
+                         int freq);
 
 #else /* CONFIG_P2P */