aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2012-06-26 16:52:46 (GMT)
committerJouni Malinen <j@w1.fi>2012-06-26 16:52:46 (GMT)
commit992189991ca99e89208a1bad4cb4305e115dd66f (patch)
tree3f80d58ceb305bfdb6cbfdc34c2697bf92c895bc
parent460b36d0c0c30c42ed5337378959a88e9a108213 (diff)
downloadhostap-992189991ca99e89208a1bad4cb4305e115dd66f.zip
hostap-992189991ca99e89208a1bad4cb4305e115dd66f.tar.gz
hostap-992189991ca99e89208a1bad4cb4305e115dd66f.tar.bz2
Start autoscan for first connection attempt
Use wpa_supplicant_set_state() to initialize state to DISCONNECT so that autoscan gets initialized properly. This needs a change in autoscan_init() to avoid extra scan request that would postpone the first scan request when an interface is added. Signed-hostap: Jouni Malinen <j@w1.fi>
-rw-r--r--wpa_supplicant/autoscan.c4
-rw-r--r--wpa_supplicant/autoscan.h4
-rw-r--r--wpa_supplicant/ctrl_iface.c2
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers.c2
-rw-r--r--wpa_supplicant/wpa_supplicant.c5
5 files changed, 10 insertions, 7 deletions
diff --git a/wpa_supplicant/autoscan.c b/wpa_supplicant/autoscan.c
index bac8df6..d0c040a 100644
--- a/wpa_supplicant/autoscan.c
+++ b/wpa_supplicant/autoscan.c
@@ -43,7 +43,7 @@ static void request_scan(struct wpa_supplicant *wpa_s)
}
-int autoscan_init(struct wpa_supplicant *wpa_s)
+int autoscan_init(struct wpa_supplicant *wpa_s, int req_scan)
{
const char *name = wpa_s->conf->autoscan;
const char *params;
@@ -88,6 +88,8 @@ int autoscan_init(struct wpa_supplicant *wpa_s)
wpa_printf(MSG_DEBUG, "autoscan: Initialized module '%s' with "
"parameters '%s'", ops->name, params);
+ if (!req_scan)
+ return 0;
/*
* Cancelling existing scan requests, if any.
diff --git a/wpa_supplicant/autoscan.h b/wpa_supplicant/autoscan.h
index e2fde8e..e2a7652 100644
--- a/wpa_supplicant/autoscan.h
+++ b/wpa_supplicant/autoscan.h
@@ -22,14 +22,14 @@ struct autoscan_ops {
#ifdef CONFIG_AUTOSCAN
-int autoscan_init(struct wpa_supplicant *wpa_s);
+int autoscan_init(struct wpa_supplicant *wpa_s, int req_scan);
void autoscan_deinit(struct wpa_supplicant *wpa_s);
int autoscan_notify_scan(struct wpa_supplicant *wpa_s,
struct wpa_scan_results *scan_res);
#else /* CONFIG_AUTOSCAN */
-static inline int autoscan_init(struct wpa_supplicant *wpa_s)
+static inline int autoscan_init(struct wpa_supplicant *wpa_s, int req_scan)
{
return 0;
}
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 5bd1559..612e258 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -3890,7 +3890,7 @@ static int wpa_supplicant_ctrl_iface_autoscan(struct wpa_supplicant *wpa_s,
if (wpa_s->conf->autoscan == NULL)
autoscan_deinit(wpa_s);
else if (state == WPA_DISCONNECTED || state == WPA_INACTIVE)
- autoscan_init(wpa_s);
+ autoscan_init(wpa_s, 1);
return 0;
}
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 4ac6716..eb902f6 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -1841,7 +1841,7 @@ DBusMessage * wpas_dbus_handler_autoscan(DBusMessage *message,
os_free(wpa_s->conf->autoscan);
wpa_s->conf->autoscan = tmp;
if (state == WPA_DISCONNECTED || state == WPA_INACTIVE)
- autoscan_init(wpa_s);
+ autoscan_init(wpa_s, 1);
}
} else if (arg != NULL && os_strlen(arg) == 0) {
os_free(wpa_s->conf->autoscan);
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index a043208..78118d4 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -574,7 +574,7 @@ static void wpa_supplicant_stop_bgscan(struct wpa_supplicant *wpa_s)
static void wpa_supplicant_start_autoscan(struct wpa_supplicant *wpa_s)
{
- if (autoscan_init(wpa_s))
+ if (autoscan_init(wpa_s, 0))
wpa_dbg(wpa_s, MSG_DEBUG, "Failed to initialize autoscan");
}
@@ -694,7 +694,7 @@ void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s)
wpa_s->mgmt_group_cipher = 0;
wpa_s->key_mgmt = 0;
if (wpa_s->wpa_state != WPA_INTERFACE_DISABLED)
- wpa_s->wpa_state = WPA_DISCONNECTED;
+ wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
if (wpa_s->wpa_state != old_state)
wpas_notify_state_changed(wpa_s, wpa_s->wpa_state, old_state);
@@ -2826,6 +2826,7 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
global->ifaces = wpa_s;
wpa_dbg(wpa_s, MSG_DEBUG, "Added interface %s", wpa_s->ifname);
+ wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
return wpa_s;
}