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

Syed Asifful Dayyan Rafiuddeen syedd
Wed Jul 3 06:04:31 PDT 2013


> Any reason to assume this is Android specific? Maybe it is better to fix 
> it in p2p_state_timeout().

It need not be android specific, here is updated patch without android_p2p. wpas_p2p_cancel_remain_on_channel_cb() would be a better place to fix, as it will get to know first when listen is over, moreover p2p_state_timeout() would not be able to access 'p2p_long_listen', it is not visible to p2p.c.

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                   |    5 +++++
 src/p2p/p2p.h                   |    6 ++++++
 wpa_supplicant/p2p_supplicant.c |    2 ++
 3 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 54f5ee8..2c6b967 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -1113,6 +1113,11 @@ 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)
+{
+	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