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>
This commit is contained in:
parent
460b36d0c0
commit
992189991c
5 changed files with 10 additions and 7 deletions
|
@ -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 *name = wpa_s->conf->autoscan;
|
||||||
const char *params;
|
const char *params;
|
||||||
|
@ -88,6 +88,8 @@ int autoscan_init(struct wpa_supplicant *wpa_s)
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "autoscan: Initialized module '%s' with "
|
wpa_printf(MSG_DEBUG, "autoscan: Initialized module '%s' with "
|
||||||
"parameters '%s'", ops->name, params);
|
"parameters '%s'", ops->name, params);
|
||||||
|
if (!req_scan)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cancelling existing scan requests, if any.
|
* Cancelling existing scan requests, if any.
|
||||||
|
|
|
@ -22,14 +22,14 @@ struct autoscan_ops {
|
||||||
|
|
||||||
#ifdef CONFIG_AUTOSCAN
|
#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);
|
void autoscan_deinit(struct wpa_supplicant *wpa_s);
|
||||||
int autoscan_notify_scan(struct wpa_supplicant *wpa_s,
|
int autoscan_notify_scan(struct wpa_supplicant *wpa_s,
|
||||||
struct wpa_scan_results *scan_res);
|
struct wpa_scan_results *scan_res);
|
||||||
|
|
||||||
#else /* CONFIG_AUTOSCAN */
|
#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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3890,7 +3890,7 @@ static int wpa_supplicant_ctrl_iface_autoscan(struct wpa_supplicant *wpa_s,
|
||||||
if (wpa_s->conf->autoscan == NULL)
|
if (wpa_s->conf->autoscan == NULL)
|
||||||
autoscan_deinit(wpa_s);
|
autoscan_deinit(wpa_s);
|
||||||
else if (state == WPA_DISCONNECTED || state == WPA_INACTIVE)
|
else if (state == WPA_DISCONNECTED || state == WPA_INACTIVE)
|
||||||
autoscan_init(wpa_s);
|
autoscan_init(wpa_s, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1841,7 +1841,7 @@ DBusMessage * wpas_dbus_handler_autoscan(DBusMessage *message,
|
||||||
os_free(wpa_s->conf->autoscan);
|
os_free(wpa_s->conf->autoscan);
|
||||||
wpa_s->conf->autoscan = tmp;
|
wpa_s->conf->autoscan = tmp;
|
||||||
if (state == WPA_DISCONNECTED || state == WPA_INACTIVE)
|
if (state == WPA_DISCONNECTED || state == WPA_INACTIVE)
|
||||||
autoscan_init(wpa_s);
|
autoscan_init(wpa_s, 1);
|
||||||
}
|
}
|
||||||
} else if (arg != NULL && os_strlen(arg) == 0) {
|
} else if (arg != NULL && os_strlen(arg) == 0) {
|
||||||
os_free(wpa_s->conf->autoscan);
|
os_free(wpa_s->conf->autoscan);
|
||||||
|
|
|
@ -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)
|
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");
|
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->mgmt_group_cipher = 0;
|
||||||
wpa_s->key_mgmt = 0;
|
wpa_s->key_mgmt = 0;
|
||||||
if (wpa_s->wpa_state != WPA_INTERFACE_DISABLED)
|
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)
|
if (wpa_s->wpa_state != old_state)
|
||||||
wpas_notify_state_changed(wpa_s, 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;
|
global->ifaces = wpa_s;
|
||||||
|
|
||||||
wpa_dbg(wpa_s, MSG_DEBUG, "Added interface %s", wpa_s->ifname);
|
wpa_dbg(wpa_s, MSG_DEBUG, "Added interface %s", wpa_s->ifname);
|
||||||
|
wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
|
||||||
|
|
||||||
return wpa_s;
|
return wpa_s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue