aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/bss.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2010-01-03 08:55:31 (GMT)
committerJouni Malinen <j@w1.fi>2010-01-03 08:55:31 (GMT)
commit7d7d57b2dcd864122fb1a958cbb7b0f4a337b159 (patch)
treef211f12e901918c83e30e2ca14dfa67a9d307ea9 /wpa_supplicant/bss.c
parent9078adfc8ca02ec158ac2c298fc1f84691e80a2b (diff)
downloadhostap-7d7d57b2dcd864122fb1a958cbb7b0f4a337b159.zip
hostap-7d7d57b2dcd864122fb1a958cbb7b0f4a337b159.tar.gz
hostap-7d7d57b2dcd864122fb1a958cbb7b0f4a337b159.tar.bz2
Use shared function for figuring out if BSS is in use
The BSS that is currently in use must not be freed even if it does not show up in scan results.
Diffstat (limited to 'wpa_supplicant/bss.c')
-rw-r--r--wpa_supplicant/bss.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index 6446c05..d069d04 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -162,6 +162,14 @@ static void wpa_bss_update(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
}
+static int wpa_bss_in_use(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
+{
+ return bss == wpa_s->current_bss ||
+ os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 ||
+ os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0;
+}
+
+
void wpa_bss_update_start(struct wpa_supplicant *wpa_s)
{
wpa_s->bss_update_idx++;
@@ -248,6 +256,8 @@ void wpa_bss_update_end(struct wpa_supplicant *wpa_s, struct scan_info *info,
return; /* do not expire entries without new scan */
dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
+ if (wpa_bss_in_use(wpa_s, bss))
+ continue;
if (!wpa_bss_included_in_scan(bss, info))
continue; /* expire only BSSes that were scanned */
if (bss->last_update_idx < wpa_s->bss_update_idx)
@@ -274,10 +284,8 @@ static void wpa_bss_timeout(void *eloop_ctx, void *timeout_ctx)
t.sec -= WPA_BSS_EXPIRATION_AGE;
dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
- if (bss == wpa_s->current_bss ||
- os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 ||
- os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0)
- continue; /* do not expire BSSes that are in use */
+ if (wpa_bss_in_use(wpa_s, bss))
+ continue;
if (os_time_before(&bss->last_update, &t)) {
wpa_printf(MSG_DEBUG, "BSS: Expire BSS %u due to age",