Start autoscan for first connection attempt
authorJouni Malinen <j@w1.fi>
Tue, 26 Jun 2012 16:52:46 +0000 (19:52 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 26 Jun 2012 16:52:46 +0000 (19:52 +0300)
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>

wpa_supplicant/autoscan.c
wpa_supplicant/autoscan.h
wpa_supplicant/ctrl_iface.c
wpa_supplicant/dbus/dbus_new_handlers.c
wpa_supplicant/wpa_supplicant.c

index bac8df6..d0c040a 100644 (file)
@@ -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.
index e2fde8e..e2a7652 100644 (file)
@@ -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;
 }
index 5bd1559..612e258 100644 (file)
@@ -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;
 }
index 4ac6716..eb902f6 100644 (file)
@@ -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);
index a043208..78118d4 100644 (file)
@@ -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;
 }