aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Leffler <sleffler@google.com>2009-10-14 19:05:58 (GMT)
committerJouni Malinen <j@w1.fi>2010-01-09 18:01:05 (GMT)
commit244f14e19d7c9c7f308c7a42f6d4131b11010288 (patch)
tree0feb771fbde8b8a2f0030e54b69ac09fe4101150
parent5530eaef0c7a44e8986f4f24638bb64bc53e0bfd (diff)
downloadhostap-06-244f14e19d7c9c7f308c7a42f6d4131b11010288.zip
hostap-06-244f14e19d7c9c7f308c7a42f6d4131b11010288.tar.gz
hostap-06-244f14e19d7c9c7f308c7a42f6d4131b11010288.tar.bz2
Do not schedule a new scan if no networks are enabled
This avoids an extra timeout to move to INACTIVE state. (cherry picked from commit 4f34d51abe432b615629dff6f4654c9344289677) Conflicts: wpa_supplicant/events.c wpa_supplicant/scan.c
-rw-r--r--wpa_supplicant/events.c8
-rw-r--r--wpa_supplicant/scan.c27
-rw-r--r--wpa_supplicant/wpa_supplicant_i.h1
3 files changed, 25 insertions, 11 deletions
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 7d13d02..9d7f9d7 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -714,6 +714,14 @@ req_scan:
*/
wpa_s->scan_res_tried++;
timeout = 0;
+ } else if (!wpa_supplicant_enabled_networks(wpa_s->conf)) {
+ /*
+ * No networks are enabled; short-circuit request so
+ * we don't wait timeout seconds before transitioning
+ * to INACTIVE state.
+ */
+ wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
+ return;
}
wpa_supplicant_req_scan(wpa_s, timeout, 0);
}
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 49c1b5f..bbe619e 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -66,11 +66,24 @@ static int wpas_wps_in_use(struct wpa_config *conf,
}
#endif /* CONFIG_WPS */
+
+int wpa_supplicant_enabled_networks(struct wpa_config *conf)
+{
+ struct wpa_ssid *ssid = conf->ssid;
+ while (ssid) {
+ if (!ssid->disabled)
+ return 1;
+ ssid = ssid->next;
+ }
+ return 0;
+}
+
+
static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
{
struct wpa_supplicant *wpa_s = eloop_ctx;
struct wpa_ssid *ssid;
- int enabled, scan_req = 0, ret;
+ int scan_req = 0, ret;
struct wpabuf *wps_ie = NULL;
const u8 *extra_ie = NULL;
size_t extra_ie_len = 0;
@@ -82,16 +95,8 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
if (wpa_s->disconnected && !wpa_s->scan_req)
return;
- enabled = 0;
- ssid = wpa_s->conf->ssid;
- while (ssid) {
- if (!ssid->disabled) {
- enabled++;
- break;
- }
- ssid = ssid->next;
- }
- if (!enabled && !wpa_s->scan_req) {
+ if (!wpa_supplicant_enabled_networks(wpa_s->conf) &&
+ !wpa_s->scan_req) {
wpa_printf(MSG_DEBUG, "No enabled networks - do not scan");
wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
return;
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index ec29dc6..3aefcd9 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -409,6 +409,7 @@ int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
/* scan.c */
+int wpa_supplicant_enabled_networks(struct wpa_config *conf);
void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s,