From 50178335bff450829729c91c8af798a1d3a7b408 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 18 Dec 2012 10:39:34 +0200 Subject: [PATCH] P2P: Allow p2p_cancel to be used to stop p2p_connect-join operation p2p_cancel did not properly cancel a pending p2p_connect-join operation. Address the different steps in that process: initial scan, Provision Discovery exchange before connection, and WPS provisioning step (including the scans before WPS). Signed-hostap: Jouni Malinen --- wpa_supplicant/p2p_supplicant.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index e44bb3aaf..dc4d99a54 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3479,6 +3479,7 @@ static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s) } group->p2p_in_provisioning = 1; + wpa_s->global->p2p_group_formation = wpa_s; group->p2p_fallback_to_go_neg = wpa_s->p2p_fallback_to_go_neg; os_memset(&res, 0, sizeof(res)); @@ -5190,6 +5191,13 @@ void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s) } +static void wpas_p2p_scan_res_ignore(struct wpa_supplicant *wpa_s, + struct wpa_scan_results *scan_res) +{ + wpa_printf(MSG_DEBUG, "P2P: Ignore scan results"); +} + + int wpas_p2p_cancel(struct wpa_supplicant *wpa_s) { struct wpa_global *global = wpa_s->global; @@ -5213,6 +5221,18 @@ int wpas_p2p_cancel(struct wpa_supplicant *wpa_s) found = 1; } + if (wpa_s->scan_res_handler == wpas_p2p_scan_res_join) { + wpa_printf(MSG_DEBUG, "P2P: Stop pending scan for join"); + wpa_s->scan_res_handler = wpas_p2p_scan_res_ignore; + found = 1; + } + + if (wpa_s->pending_pd_before_join) { + wpa_printf(MSG_DEBUG, "P2P: Stop pending PD before join"); + wpa_s->pending_pd_before_join = 0; + found = 1; + } + wpas_p2p_stop_find(wpa_s); for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {