diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 27e2cc0f5..bc59705dc 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -631,6 +631,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) struct wpa_driver_scan_params params; struct wpa_driver_scan_params *scan_params; size_t max_ssids; + int connect_without_scan = 0; if (wpa_s->pno || wpa_s->pno_sched_pending) { wpa_dbg(wpa_s, MSG_DEBUG, "Skip scan - PNO is in progress"); @@ -678,8 +679,20 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) return; } + ssid = NULL; + if (wpa_s->last_scan_req != MANUAL_SCAN_REQ && + wpa_s->connect_without_scan) { + connect_without_scan = 1; + for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { + if (ssid == wpa_s->connect_without_scan) + break; + } + } + p2p_in_prog = wpas_p2p_in_progress(wpa_s); - if (p2p_in_prog && p2p_in_prog != 2) { + if (p2p_in_prog && p2p_in_prog != 2 && + (!ssid || + (ssid->mode != WPAS_MODE_AP && ssid->mode != WPAS_MODE_P2P_GO))) { wpa_dbg(wpa_s, MSG_DEBUG, "Delay station mode scan while P2P operation is in progress"); wpa_supplicant_req_scan(wpa_s, 5, 0); return; @@ -696,6 +709,16 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) wpa_s->last_scan_req = wpa_s->scan_req; wpa_s->scan_req = NORMAL_SCAN_REQ; + if (connect_without_scan) { + wpa_s->connect_without_scan = NULL; + if (ssid) { + wpa_printf(MSG_DEBUG, "Start a pre-selected network " + "without scan step"); + wpa_supplicant_associate(wpa_s, NULL, ssid); + return; + } + } + os_memset(¶ms, 0, sizeof(params)); wpa_s->scan_prev_wpa_state = wpa_s->wpa_state; @@ -711,21 +734,6 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) goto scan; } - if (wpa_s->last_scan_req != MANUAL_SCAN_REQ && - wpa_s->connect_without_scan) { - for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { - if (ssid == wpa_s->connect_without_scan) - break; - } - wpa_s->connect_without_scan = NULL; - if (ssid) { - wpa_printf(MSG_DEBUG, "Start a pre-selected network " - "without scan step"); - wpa_supplicant_associate(wpa_s, NULL, ssid); - return; - } - } - #ifdef CONFIG_P2P if ((wpa_s->p2p_in_provisioning || wpa_s->show_group_started) && wpa_s->go_params && !wpa_s->conf->passive_scan) {