aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/bss.c
diff options
context:
space:
mode:
authorSam Leffler <sleffler@chromium.org>2011-03-20 10:02:33 (GMT)
committerJouni Malinen <j@w1.fi>2011-03-20 10:02:33 (GMT)
commit2b65b30da86f550dc8c228cb2c6456e76dbc7978 (patch)
treebea30bd5a65afb8b2b743b7bad261b658cb89c98 /wpa_supplicant/bss.c
parentd4c1ec56f11b7844a955bdf5ef4678bd0e44e121 (diff)
downloadhostap-2b65b30da86f550dc8c228cb2c6456e76dbc7978.zip
hostap-2b65b30da86f550dc8c228cb2c6456e76dbc7978.tar.gz
hostap-2b65b30da86f550dc8c228cb2c6456e76dbc7978.tar.bz2
dbus: Add D-Bus methods to flush the BSS cache
Add an "Interface.FlushBSS" method to the new D-Bus API and a "flush" method to the old API. Both take an age parameter that is a threshold (in seconds) for selecting entries to evict. Setting this parameter to zero flushes all entries from the cache. This mechanism is useful for a connection manager to clear state at startup and on resume (where the age parameter may be used to hold onto recent/valid data).
Diffstat (limited to 'wpa_supplicant/bss.c')
-rw-r--r--wpa_supplicant/bss.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index 07f92f1..5809284 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -421,9 +421,8 @@ void wpa_bss_update_end(struct wpa_supplicant *wpa_s, struct scan_info *info,
}
-static void wpa_bss_timeout(void *eloop_ctx, void *timeout_ctx)
+void wpa_bss_flush_by_age(struct wpa_supplicant *wpa_s, int age)
{
- struct wpa_supplicant *wpa_s = eloop_ctx;
struct wpa_bss *bss, *n;
struct os_time t;
@@ -431,7 +430,7 @@ static void wpa_bss_timeout(void *eloop_ctx, void *timeout_ctx)
return;
os_get_time(&t);
- t.sec -= WPA_BSS_EXPIRATION_AGE;
+ t.sec -= age;
dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
if (wpa_bss_in_use(wpa_s, bss))
@@ -444,6 +443,14 @@ static void wpa_bss_timeout(void *eloop_ctx, void *timeout_ctx)
} else
break;
}
+}
+
+
+static void wpa_bss_timeout(void *eloop_ctx, void *timeout_ctx)
+{
+ struct wpa_supplicant *wpa_s = eloop_ctx;
+
+ wpa_bss_flush_by_age(wpa_s, WPA_BSS_EXPIRATION_AGE);
eloop_register_timeout(WPA_BSS_EXPIRATION_PERIOD, 0,
wpa_bss_timeout, wpa_s, NULL);
}
@@ -459,14 +466,25 @@ int wpa_bss_init(struct wpa_supplicant *wpa_s)
}
-void wpa_bss_deinit(struct wpa_supplicant *wpa_s)
+void wpa_bss_flush(struct wpa_supplicant *wpa_s)
{
struct wpa_bss *bss, *n;
- eloop_cancel_timeout(wpa_bss_timeout, wpa_s, NULL);
+
if (wpa_s->bss.next == NULL)
return; /* BSS table not yet initialized */
- dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list)
+
+ dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {
+ if (wpa_bss_in_use(wpa_s, bss))
+ continue;
wpa_bss_remove(wpa_s, bss);
+ }
+}
+
+
+void wpa_bss_deinit(struct wpa_supplicant *wpa_s)
+{
+ eloop_cancel_timeout(wpa_bss_timeout, wpa_s, NULL);
+ wpa_bss_flush(wpa_s);
}