aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/bss.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-03-31 14:52:23 (GMT)
committerJouni Malinen <j@w1.fi>2013-03-31 15:05:42 (GMT)
commit4342326fc7032a2b8fb84a1e535a3690226a6d0b (patch)
tree2004f922642a34ea1403d9e8ee1511afc3917116 /wpa_supplicant/bss.c
parent9599ccc2dd069fa06f93f118cea17b7af177aa53 (diff)
downloadhostap-4342326fc7032a2b8fb84a1e535a3690226a6d0b.zip
hostap-4342326fc7032a2b8fb84a1e535a3690226a6d0b.tar.gz
hostap-4342326fc7032a2b8fb84a1e535a3690226a6d0b.tar.bz2
Add ignore_old_scan_res configuration parameter
This can be used to configure wpa_supplicant to ignore old scan results from the driver cache in cases where such results were not updated after the scan trigger from wpa_supplicant. This can be useful in some cases where the driver may cache information for a significant time and the AP configuration is changing. Many such cases are for testing scripts, but this could potentially be useful for some WPS use cases, too. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/bss.c')
-rw-r--r--wpa_supplicant/bss.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index 602d349..0e1576b 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -224,11 +224,27 @@ struct wpa_bss * wpa_bss_get(struct wpa_supplicant *wpa_s, const u8 *bssid,
}
-static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
- struct os_time *fetch_time)
+static void calculate_update_time(const struct os_time *fetch_time,
+ unsigned int age_ms,
+ struct os_time *update_time)
{
os_time_t usec;
+ update_time->sec = fetch_time->sec;
+ update_time->usec = fetch_time->usec;
+ update_time->sec -= age_ms / 1000;
+ usec = (age_ms % 1000) * 1000;
+ if (update_time->usec < usec) {
+ update_time->sec--;
+ update_time->usec += 1000000;
+ }
+ update_time->usec -= usec;
+}
+
+
+static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
+ struct os_time *fetch_time)
+{
dst->flags = src->flags;
os_memcpy(dst->bssid, src->bssid, ETH_ALEN);
dst->freq = src->freq;
@@ -239,15 +255,7 @@ static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,
dst->level = src->level;
dst->tsf = src->tsf;
- dst->last_update.sec = fetch_time->sec;
- dst->last_update.usec = fetch_time->usec;
- dst->last_update.sec -= src->age / 1000;
- usec = (src->age % 1000) * 1000;
- if (dst->last_update.usec < usec) {
- dst->last_update.sec--;
- dst->last_update.usec += 1000000;
- }
- dst->last_update.usec -= usec;
+ calculate_update_time(fetch_time, src->age, &dst->last_update);
}
@@ -567,6 +575,21 @@ void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s,
const u8 *ssid, *p2p;
struct wpa_bss *bss;
+ if (wpa_s->conf->ignore_old_scan_res) {
+ struct os_time update;
+ calculate_update_time(fetch_time, res->age, &update);
+ if (os_time_before(&update, &wpa_s->scan_trigger_time)) {
+ struct os_time age;
+ os_time_sub(&wpa_s->scan_trigger_time, &update, &age);
+ wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Ignore driver BSS "
+ "table entry that is %u.%06u seconds older "
+ "than our scan trigger",
+ (unsigned int) age.sec,
+ (unsigned int) age.usec);
+ return;
+ }
+ }
+
ssid = wpa_scan_get_ie(res, WLAN_EID_SSID);
if (ssid == NULL) {
wpa_dbg(wpa_s, MSG_DEBUG, "BSS: No SSID IE included for "