From 8b4bce98f1de19ad6427c9ca7b3be10638e606ff Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Fri, 20 Jul 2012 10:00:35 +0300 Subject: P2P: Defer p2p scan if scanning on other interfaces (BRCM) The current defer p2p scan until scan complete works only when the scanning is done on the same interface. However in Android case there are scans in progress on the STA interface so these would fail the p2p_scan and consequently the p2p find. Signed-off-by: Eyal Shapira --- wpa_supplicant/p2p_supplicant.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 3adca69..fa9627a 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -58,6 +58,9 @@ #endif /* P2P_MAX_INITIAL_CONN_WAIT */ +#ifdef ANDROID +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, @@ -77,6 +80,22 @@ 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 +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,8 +181,13 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq, wpabuf_free(ies); if (ret) { +#ifdef ANDROID + if (wpa_s->scanning || wpa_s->scan_res_handler == wpas_p2p_scan_res_handler + || wpas_global_scan_in_progress(wpa_s)) { +#else if (wpa_s->scanning || wpa_s->scan_res_handler == wpas_p2p_scan_res_handler) { +#endif wpa_s->p2p_cb_on_scan_complete = 1; ret = 1; } -- cgit v1.1