aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/bss.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-03-31 14:15:39 (GMT)
committerJouni Malinen <j@w1.fi>2013-03-31 15:05:42 (GMT)
commit702621e6dd35360543974f3674f59dcbdd1ce1af (patch)
tree17f849a6a24e53e251d3a4197ebf03e0dcd730af /wpa_supplicant/bss.c
parent347c77e6cc363b63313454ce658381d13b9f71a5 (diff)
downloadhostap-702621e6dd35360543974f3674f59dcbdd1ce1af.zip
hostap-702621e6dd35360543974f3674f59dcbdd1ce1af.tar.gz
hostap-702621e6dd35360543974f3674f59dcbdd1ce1af.tar.bz2
WPS: Use latest updated BSS entry if multiple BSSID matches found
If the AP (P2P GO) has changes its channel of SSID recently, the BSS table may have multiple entries for a BSSID. Select the one which was most recently updated for WPS/P2P operations in such case to increase the likelihood of using current information. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/bss.c')
-rw-r--r--wpa_supplicant/bss.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index c50de53..602d349 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -829,6 +829,34 @@ struct wpa_bss * wpa_bss_get_bssid(struct wpa_supplicant *wpa_s,
}
+/**
+ * wpa_bss_get_bssid_latest - Fetch the latest BSS table entry based on BSSID
+ * @wpa_s: Pointer to wpa_supplicant data
+ * @bssid: BSSID
+ * Returns: Pointer to the BSS entry or %NULL if not found
+ *
+ * This function is like wpa_bss_get_bssid(), but full BSS table is iterated to
+ * find the entry that has the most recent update. This can help in finding the
+ * correct entry in cases where the SSID of the AP may have changed recently
+ * (e.g., in WPS reconfiguration cases).
+ */
+struct wpa_bss * wpa_bss_get_bssid_latest(struct wpa_supplicant *wpa_s,
+ const u8 *bssid)
+{
+ struct wpa_bss *bss, *found = NULL;
+ if (!wpa_supplicant_filter_bssid_match(wpa_s, bssid))
+ return NULL;
+ dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) {
+ if (os_memcmp(bss->bssid, bssid, ETH_ALEN) != 0)
+ continue;
+ if (found == NULL ||
+ os_time_before(&found->last_update, &bss->last_update))
+ found = bss;
+ }
+ return found;
+}
+
+
#ifdef CONFIG_P2P
/**
* wpa_bss_get_p2p_dev_addr - Fetch a BSS table entry based on P2P Device Addr