From f85f545e71f2202f1bc7ab65235249320c05ec56 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 18 Mar 2013 16:31:09 +0200 Subject: [PATCH] P2P: Use common function for re-starting P2P scan after station scan Make the implementation more consistent and cleaner by using a single function for addressing all the cases where completion of a station mode scan operation allows a P2P operation (search) to be re-started. Signed-hostap: Jouni Malinen --- wpa_supplicant/events.c | 15 +++----------- wpa_supplicant/p2p_supplicant.c | 36 +++++++++++++++++++++++---------- wpa_supplicant/p2p_supplicant.h | 8 ++++++++ wpa_supplicant/wpa_supplicant.c | 22 ++------------------ 4 files changed, 38 insertions(+), 43 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index d91dd3142..1c48eba93 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -2505,18 +2505,9 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, #ifndef CONFIG_NO_SCAN_PROCESSING case EVENT_SCAN_RESULTS: wpa_supplicant_event_scan_results(wpa_s, data); -#ifdef CONFIG_P2P - 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->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"); - } - } -#endif /* CONFIG_P2P */ + if (wpa_s->wpa_state != WPA_AUTHENTICATING && + wpa_s->wpa_state != WPA_ASSOCIATING) + wpas_p2p_continue_after_scan(wpa_s); break; #endif /* CONFIG_NO_SCAN_PROCESSING */ case EVENT_ASSOCINFO: diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index bbcde8f37..76ddf0f25 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -4964,17 +4964,7 @@ void wpas_p2p_completed(struct wpa_supplicant *wpa_s) wpas_notify_p2p_group_started(wpa_s, ssid, network_id, 1); done: - if (wpa_s->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled && - wpa_s->global->p2p != NULL) { - 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"); - p2p_increase_search_delay( - wpa_s->global->p2p, - wpas_p2p_search_delay(wpa_s)); - } - } + wpas_p2p_continue_after_scan(wpa_s); } @@ -5748,3 +5738,27 @@ unsigned int wpas_p2p_search_delay(struct wpa_supplicant *wpa_s) return 0; } + + +void wpas_p2p_continue_after_scan(struct wpa_supplicant *wpa_s) +{ + wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Station mode scan operation not " + "pending anymore (sta_scan_pending=%d " + "p2p_cb_on_scan_complete=%d)", wpa_s->sta_scan_pending, + wpa_s->global->p2p_cb_on_scan_complete); + wpa_s->sta_scan_pending = 0; + + if (!wpa_s->global->p2p_cb_on_scan_complete) + return; + wpa_s->global->p2p_cb_on_scan_complete = 0; + + if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) + return; + + if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) { + wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation " + "continued after successful connection"); + p2p_increase_search_delay(wpa_s->global->p2p, + wpas_p2p_search_delay(wpa_s)); + } +} diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h index 5f0bfd243..0a7212ca4 100644 --- a/wpa_supplicant/p2p_supplicant.h +++ b/wpa_supplicant/p2p_supplicant.h @@ -150,4 +150,12 @@ int wpas_p2p_get_ht40_mode(struct wpa_supplicant *wpa_s, struct hostapd_hw_modes *mode, u8 channel); unsigned int wpas_p2p_search_delay(struct wpa_supplicant *wpa_s); +#ifdef CONFIG_P2P +void wpas_p2p_continue_after_scan(struct wpa_supplicant *wpa_s); +#else /* CONFIG_P2P */ +static inline void wpas_p2p_continue_after_scan(struct wpa_supplicant *wpa_s) +{ +} +#endif /* CONFIG_P2P */ + #endif /* P2P_SUPPLICANT_H */ diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 23e2da2f2..24cc8b602 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -199,16 +199,7 @@ 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->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled && - wpa_s->global->p2p != NULL) { - 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"); - } - } -#endif /* CONFIG_P2P */ + wpas_p2p_continue_after_scan(wpa_s); } @@ -3554,16 +3545,7 @@ void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid) wpa_supplicant_req_scan(wpa_s, timeout / 1000, 1000 * (timeout % 1000)); -#ifdef CONFIG_P2P - if (wpa_s->global->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled && - wpa_s->global->p2p != NULL) { - 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"); - } - } -#endif /* CONFIG_P2P */ + wpas_p2p_continue_after_scan(wpa_s); }