From 0b5fb86a24109361d96ec9f2f4cc6f74ddb1a0d3 Mon Sep 17 00:00:00 2001 From: Syed Asifful Dayyan Rafiuddeen Date: Sat, 31 Aug 2013 18:09:15 +0300 Subject: [PATCH] P2P: Stop listen state when listen-only duration is over Even after listen duration is over, P2P module remained in P2P_LISTEN_ONLY state, which is blocking station mode scans. Fix this by stopping P2P listen explicitly to update p2p_state to IDLE when listen duration expires. Signed-hostap: Syed Asifful Dayyan --- src/p2p/p2p.c | 12 ++++++++++++ src/p2p/p2p.h | 6 ++++++ wpa_supplicant/p2p_supplicant.c | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index f3414dd9e..178a8f6da 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -1120,6 +1120,18 @@ void p2p_stop_listen_for_freq(struct p2p_data *p2p, int freq) } +void p2p_stop_listen(struct p2p_data *p2p) +{ + if (p2p->state != P2P_LISTEN_ONLY) { + p2p_dbg(p2p, "Skip stop_listen since not in listen_only state."); + return; + } + + p2p_stop_listen_for_freq(p2p, 0); + p2p_set_state(p2p, P2P_IDLE); +} + + void p2p_stop_find(struct p2p_data *p2p) { p2p_stop_find_for_freq(p2p, 0); diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 1f1fa6712..9b6921e55 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -903,6 +903,12 @@ void p2p_stop_find_for_freq(struct p2p_data *p2p, int freq); */ int p2p_listen(struct p2p_data *p2p, unsigned int timeout); +/** + * p2p_stop_listen - Stop P2P Listen + * @p2p: P2P module context from p2p_init() + */ +void p2p_stop_listen(struct p2p_data *p2p); + /** * p2p_connect - Start P2P group formation (GO negotiation) * @p2p: P2P module context from p2p_init() diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 4b0e0eeb2..f8c8b0ae6 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -4130,6 +4130,12 @@ void wpas_p2p_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s, if (wpa_s->p2p_long_listen > 0) { wpa_printf(MSG_DEBUG, "P2P: Continuing long Listen state"); wpas_p2p_listen_start(wpa_s, wpa_s->p2p_long_listen); + } else { + /* + * When listen duration is over, stop listen & update p2p_state + * to IDLE. + */ + p2p_stop_listen(wpa_s->global->p2p); } }