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); } }