[PATCH 5/8] search bss list from back to front
Nathan Williams
njw
Thu Mar 17 15:39:44 PDT 2011
This fixes an issue seen in the wifi testbed, where we frequently
switch the SSID of the AP. wpa_supplicant's BSS list will have, for
example both <bssid, "Check11b"> (from the previous test) and <bssid,
"Check11g"> (from the current test) - note that the bssid is the same for
both. The (old) DBus API for fetching scan responses from wpa_supplicant
is fetch-by-bssid, so the caller (flimflam) incorrectly believes we're
associated with <bssid, "Check11b">.
---
src/utils/list.h | 5 +++++
wpa_supplicant/bss.c | 2 +-
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/utils/list.h b/src/utils/list.h
index ded7846..43e5a5f 100644
--- a/src/utils/list.h
+++ b/src/utils/list.h
@@ -84,6 +84,11 @@ static inline unsigned int dl_list_len(struct dl_list *list)
&item->member != (list); \
item = dl_list_entry(item->member.next, type, member))
+#define dl_list_for_each_reverse(item, list, type, member) \
+ for (item = dl_list_entry((list)->prev, type, member); \
+ &item->member != (list); \
+ item = dl_list_entry(item->member.prev, type, member))
+
#define dl_list_for_each_safe(item, n, list, type, member) \
for (item = dl_list_entry((list)->next, type, member), \
n = dl_list_entry(item->member.next, type, member); \
diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index b521f94..ab77094 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -485,7 +485,7 @@ struct wpa_bss * wpa_bss_get_bssid(struct wpa_supplicant *wpa_s,
const u8 *bssid)
{
struct wpa_bss *bss;
- dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
+ dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) {
if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0)
return bss;
}
--
1.7.3.1
More information about the Hostap
mailing list