]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
OWE: Enable roaming between OWE APs
authorDavid Bauer <mail@david-bauer.net>
Sun, 28 Apr 2024 13:13:41 +0000 (15:13 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 1 Aug 2024 15:06:54 +0000 (18:06 +0300)
This allows to use the ROAM control interface command to force roaming
on a transition network. Previously, this was not possible, as the open
SSID is stored for the connection profile. Add a new function to also
return OWE transition networks if the profile SSID is set as the
transition-ssid for the OWE RSN network.

Signed-off-by: David Bauer <mail@david-bauer.net>
wpa_supplicant/bss.c
wpa_supplicant/bss.h
wpa_supplicant/ctrl_iface.c

index cf94d4be5c0fa9fd6fd69ac5c003b0138ebd7971..39de8bac350f30aa691d7ad3a57d1c977e9217c8 100644 (file)
@@ -273,6 +273,57 @@ struct wpa_bss * wpa_bss_get(struct wpa_supplicant *wpa_s, const u8 *bssid,
        return NULL;
 }
 
+/**
+ * wpa_bss_get_connection - Fetch a BSS table entry based on BSSID and SSID.
+ * @wpa_s: Pointer to wpa_supplicant data
+ * @bssid: BSSID, or %NULL to match any BSSID
+ * @ssid: SSID
+ * @ssid_len: Length of @ssid
+ * Returns: Pointer to the BSS entry or %NULL if not found
+ *
+ * This function is similar to wpa_bss_get() but it will also return OWE
+ * transition mode encrypted networks for which transition-element matches
+ * @ssid.
+ */
+struct wpa_bss * wpa_bss_get_connection(struct wpa_supplicant *wpa_s,
+                                       const u8 *bssid,
+                                       const u8 *ssid, size_t ssid_len)
+{
+       struct wpa_bss *bss;
+#ifdef CONFIG_OWE
+       const u8 *owe, *owe_bssid, *owe_ssid;
+       size_t owe_ssid_len;
+#endif /* CONFIG_OWE */
+
+       if (bssid && !wpa_supplicant_filter_bssid_match(wpa_s, bssid))
+               return NULL;
+       dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
+               if (bssid && !ether_addr_equal(bss->bssid, bssid))
+                       continue;
+
+               if (bss->ssid_len == ssid_len &&
+                   os_memcmp(bss->ssid, ssid, ssid_len) == 0)
+                       return bss;
+
+#ifdef CONFIG_OWE
+               /* Check if OWE transition mode element is present and matches
+                * the SSID */
+               owe = wpa_bss_get_vendor_ie(bss, OWE_IE_VENDOR_TYPE);
+               if (!owe)
+                       continue;
+
+               if (wpas_get_owe_trans_network(owe, &owe_bssid, &owe_ssid,
+                                              &owe_ssid_len))
+                       continue;
+
+               if (owe_ssid_len == ssid_len &&
+                   os_memcmp(owe_ssid, ssid, ssid_len) == 0)
+                       return bss;
+#endif /* CONFIG_OWE */
+       }
+       return NULL;
+}
+
 
 void calculate_update_time(const struct os_reltime *fetch_time,
                           unsigned int age_ms,
index 508129c3d7475f3e65e019ba4c605d2d9e831e0c..31688fa541246d9a850f8482e421586344516063 100644 (file)
@@ -165,6 +165,9 @@ void wpa_bss_flush(struct wpa_supplicant *wpa_s);
 void wpa_bss_flush_by_age(struct wpa_supplicant *wpa_s, int age);
 struct wpa_bss * wpa_bss_get(struct wpa_supplicant *wpa_s, const u8 *bssid,
                             const u8 *ssid, size_t ssid_len);
+struct wpa_bss * wpa_bss_get_connection(struct wpa_supplicant *wpa_s,
+                                       const u8 *bssid,
+                                       const u8 *ssid, size_t ssid_len);
 struct wpa_bss * wpa_bss_get_bssid(struct wpa_supplicant *wpa_s,
                                   const u8 *bssid);
 struct wpa_bss * wpa_bss_get_bssid_latest(struct wpa_supplicant *wpa_s,
index d245531cd07891e13ab7b459f2d6e0bfb2557994..0f00eb2e527e3e8d1e03af5f1b4fe48a59f35a76 100644 (file)
@@ -6035,7 +6035,7 @@ static int wpa_supplicant_ctrl_iface_roam(struct wpa_supplicant *wpa_s,
                return -1;
        }
 
-       bss = wpa_bss_get(wpa_s, bssid, ssid->ssid, ssid->ssid_len);
+       bss = wpa_bss_get_connection(wpa_s, bssid, ssid->ssid, ssid->ssid_len);
        if (!bss) {
                wpa_printf(MSG_DEBUG, "CTRL_IFACE ROAM: Target AP not found "
                           "from BSS table");