diff options
-rw-r--r-- | wpa_supplicant/events.c | 28 | ||||
-rw-r--r-- | wpa_supplicant/interworking.c | 2 | ||||
-rw-r--r-- | wpa_supplicant/p2p_supplicant.c | 52 | ||||
-rw-r--r-- | wpa_supplicant/scan.c | 2 | ||||
-rw-r--r-- | wpa_supplicant/wpa_supplicant.c | 8 | ||||
-rw-r--r-- | wpa_supplicant/wpa_supplicant_i.h | 2 |
6 files changed, 38 insertions, 56 deletions
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index b304c09..fdcbcc2 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1033,7 +1033,7 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, } -/* Return < 0 if no scan results could be fetched or if scan results should not +/* Return != 0 if no scan results could be fetched or if scan results should not * be shared with other virtual interfaces. */ #ifdef ANDROID_P2P static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, @@ -1057,12 +1057,15 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, wpa_supplicant_notify_scanning(wpa_s, 0); #ifdef CONFIG_P2P - if (wpa_s->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled && + if (wpa_s->global->p2p_cb_on_scan_complete && + !wpa_s->global->p2p_disabled && wpa_s->global->p2p != NULL && !wpa_s->sta_scan_pending) { - wpa_s->p2p_cb_on_scan_complete = 0; + wpa_s->global->p2p_cb_on_scan_complete = 0; if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) { wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation " "stopped scan processing"); + wpa_s->sta_scan_pending = 1; + wpa_supplicant_req_scan(wpa_s, 5, 0); return -1; } } @@ -1188,6 +1191,11 @@ int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s) return -1; } wpa_supplicant_rsn_preauth_scan_results(wpa_s); + /* + * Do not notify other virtual radios of scan results since we do not + * want them to start other associations at the same time. + */ + return 1; } else { wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found"); ssid = wpa_supplicant_pick_new_network(wpa_s); @@ -1224,7 +1232,7 @@ int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s) wpa_s->network_select = 1; wpa_s->auto_network_select = 1; interworking_start_fetch_anqp(wpa_s); - return 0; + return 1; } #endif /* CONFIG_INTERWORKING */ if (wpa_supplicant_req_sched_scan(wpa_s)) @@ -1242,14 +1250,16 @@ static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, const char *rn, *rn2; struct wpa_supplicant *ifs; #ifdef ANDROID_P2P - if (_wpa_supplicant_event_scan_results(wpa_s, data, 0) < 0) { + if (_wpa_supplicant_event_scan_results(wpa_s, data, 0) != 0) { #else - if (_wpa_supplicant_event_scan_results(wpa_s, data) < 0) { + if (_wpa_supplicant_event_scan_results(wpa_s, data) != 0) { #endif /* * If no scan results could be fetched, then no need to * notify those interfaces that did not actually request - * this scan. + * this scan. Similarly, if scan results started a new operation on this + * interface, do not notify other interfaces to avoid concurrent + * operations during a connection attempt. */ return; } @@ -2455,11 +2465,11 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, case EVENT_SCAN_RESULTS: wpa_supplicant_event_scan_results(wpa_s, data); #ifdef CONFIG_P2P - if (wpa_s->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled && + if (wpa_s->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled && wpa_s->global->p2p != NULL && wpa_s->wpa_state != WPA_AUTHENTICATING && wpa_s->wpa_state != WPA_ASSOCIATING) { - wpa_s->p2p_cb_on_scan_complete = 0; + wpa_s->global->p2p_cb_on_scan_complete = 0; if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) { wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation " "continued after scan result processing"); diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c index b362bcb..22f709f 100644 --- a/wpa_supplicant/interworking.c +++ b/wpa_supplicant/interworking.c @@ -59,7 +59,7 @@ static void interworking_reconnect(struct wpa_supplicant *wpa_s) if (now.sec - wpa_s->last_scan.sec <= 5) { wpa_printf(MSG_DEBUG, "Interworking: Old scan results " "are fresh - connect without new scan"); - if (wpas_select_network_from_last_scan(wpa_s) == 0) + if (wpas_select_network_from_last_scan(wpa_s) >= 0) return; } } diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 76f50c7..f8db14e 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -78,9 +78,7 @@ enum p2p_group_removal_reason { #endif }; -#ifdef ANDROID_P2P -static int wpas_global_scan_in_progress(struct wpa_supplicant *wpa_s); -#endif + static void wpas_p2p_long_listen_timeout(void *eloop_ctx, void *timeout_ctx); static struct wpa_supplicant * wpas_p2p_get_group_iface(struct wpa_supplicant *wpa_s, int addr_allocated, @@ -100,22 +98,6 @@ static void wpas_p2p_set_group_idle_timeout(struct wpa_supplicant *wpa_s); static void wpas_p2p_fallback_to_go_neg(struct wpa_supplicant *wpa_s, int group_added); -#ifdef ANDROID_P2P -static int wpas_global_scan_in_progress(struct wpa_supplicant *wpa_s) -{ - struct wpa_supplicant *iface = NULL; - - for (iface = wpa_s->global->ifaces; iface; iface = iface->next) { - if(iface->scanning || iface->wpa_state == WPA_SCANNING) { - wpa_printf(MSG_DEBUG, "P2P: Scan in progress on %s," - "defer P2P SEARCH", iface->ifname); - return 1; - } - } - - return 0; -} -#endif static void wpas_p2p_scan_res_handler(struct wpa_supplicant *wpa_s, struct wpa_scan_results *scan_res) @@ -162,23 +144,10 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq, wpa_printf(MSG_DEBUG, "Delaying P2P scan to allow " "pending station mode scan to be " "completed on interface %s", ifs->ifname); -#ifdef ANDROID_P2P - ifs->p2p_cb_on_scan_complete = 1; -#else - wpa_s->p2p_cb_on_scan_complete = 1; -#endif + wpa_s->global->p2p_cb_on_scan_complete = 1; wpa_supplicant_req_scan(ifs, 0, 0); return 1; } -#ifdef ANDROID_P2P - else if(ifs->scanning) { - wpa_printf(MSG_DEBUG, "Wait for the STA scan" - "to be " - "completed on interface %s", ifs->ifname); - ifs->p2p_cb_on_scan_complete = 1; - return 1; - } -#endif } os_memset(¶ms, 0, sizeof(params)); @@ -232,10 +201,13 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq, wpabuf_free(ies); if (ret) { - if (wpa_s->scanning || - wpa_s->scan_res_handler == wpas_p2p_scan_res_handler) { - wpa_s->p2p_cb_on_scan_complete = 1; - ret = 1; + for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) { + if (ifs->scanning || + ifs->scan_res_handler == wpas_p2p_scan_res_handler) { + wpa_s->global->p2p_cb_on_scan_complete = 1; + ret = 1; + break; + } } } else wpa_s->scan_res_handler = wpas_p2p_scan_res_handler; @@ -4287,7 +4259,7 @@ void wpas_p2p_stop_find(struct wpa_supplicant *wpa_s) wpa_s->p2p_long_listen = 0; eloop_cancel_timeout(wpas_p2p_long_listen_timeout, wpa_s, NULL); eloop_cancel_timeout(wpas_p2p_join_scan, wpa_s, NULL); - wpa_s->p2p_cb_on_scan_complete = 0; + wpa_s->global->p2p_cb_on_scan_complete = 0; if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) { wpa_drv_p2p_stop_find(wpa_s); @@ -4620,9 +4592,9 @@ void wpas_p2p_completed(struct wpa_supplicant *wpa_s) wpas_notify_p2p_group_started(wpa_s, ssid, network_id, 1); done: - if (wpa_s->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled && + if (wpa_s->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled && wpa_s->global->p2p != NULL) { - wpa_s->p2p_cb_on_scan_complete = 0; + wpa_s->global->p2p_cb_on_scan_complete = 0; if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) { wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation " "continued after successful connection"); diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 8c548b3..bf55f5e 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -484,7 +484,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) if (wpas_p2p_in_progress(wpa_s)) { if (wpa_s->sta_scan_pending && wpas_p2p_in_progress(wpa_s) == 2 && - wpa_s->p2p_cb_on_scan_complete) { + wpa_s->global->p2p_cb_on_scan_complete) { wpa_dbg(wpa_s, MSG_DEBUG, "Process pending station " "mode scan during P2P search"); } else { diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 8730e0f..49830d6 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -200,9 +200,9 @@ static void wpa_supplicant_timeout(void *eloop_ctx, void *timeout_ctx) wpa_supplicant_req_scan(wpa_s, 1, 0); #ifdef CONFIG_P2P - if (wpa_s->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled && + if (wpa_s->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled && wpa_s->global->p2p != NULL) { - wpa_s->p2p_cb_on_scan_complete = 0; + wpa_s->global->p2p_cb_on_scan_complete = 0; if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) { wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation " "continued after timed out authentication"); @@ -3471,9 +3471,9 @@ void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid) 1000 * (timeout % 1000)); #ifdef CONFIG_P2P - if (wpa_s->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled && + if (wpa_s->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled && wpa_s->global->p2p != NULL) { - wpa_s->p2p_cb_on_scan_complete = 0; + wpa_s->global->p2p_cb_on_scan_complete = 0; if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) { wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation " "continued after failed association"); diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 0bc2880..55f3d88 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -239,6 +239,7 @@ struct wpa_global { WPA_CONC_PREF_STA, WPA_CONC_PREF_P2P } conc_pref; + unsigned int p2p_cb_on_scan_complete:1; #ifdef CONFIG_WIFI_DISPLAY int wifi_display; @@ -541,7 +542,6 @@ struct wpa_supplicant { */ char cross_connect_uplink[100]; - unsigned int p2p_cb_on_scan_complete:1; unsigned int sta_scan_pending:1; unsigned int p2p_auto_join:1; unsigned int p2p_auto_pd:1; |