[PATCH] P2P: Stop p2p listen when listen duration is over.

Syed Asifful Dayyan Rafiuddeen syedd
Tue Jul 9 06:07:56 PDT 2013


The previous patch would break p2p_find as p2p_stop_listen() will called while search is in progress, this updated patch fixes it by restricting p2p_stop_listen() only to listen_only state.

Thanks,
Syed

Even after listen duration is over, supplicant stays in
 p2p_listen_only state, which is blocking the STA scan. This
 patch will stop p2p listen and update p2p_state to idle
 when listen duration expires.

Signed-hostap: Syed Asifful Dayyan <syedd at broadcom.com>
---
 src/p2p/p2p.c                   |   10 ++++++++++
 src/p2p/p2p.h                   |    6 ++++++
 wpa_supplicant/p2p_supplicant.c |    2 ++
 3 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 54f5ee8..d2c17ec 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -1113,6 +1113,16 @@ void p2p_stop_listen_for_freq(struct p2p_data *p2p, int freq)
 	p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
 }
 
+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)
 {
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index e911474..6af23b5 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -904,6 +904,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()
  * @peer_addr: MAC address of the peer P2P client
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index cbc0a38..b77a701 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -4055,6 +4055,8 @@ void wpas_p2p_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
 		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);
 }
 
 
-- 
1.7.6





More information about the Hostap mailing list