Patchwork P2P: Stop p2p listen when listen duration is over.

login
register
mail settings
Submitter Syed Asifful Dayyan Rafiuddeen
Date July 9, 2013, 1:07 p.m.
Message ID <2F87FC9B7C2FB34287BB37749ED494361C067EDD@SJEXCHMB12.corp.ad.broadcom.com>
Download mbox | patch
Permalink /patch/257716/
State Accepted
Commit 0b5fb86a24109361d96ec9f2f4cc6f74ddb1a0d3
Headers show

Comments

Syed Asifful Dayyan Rafiuddeen - July 9, 2013, 1:07 p.m.
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@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(-)
Jouni Malinen - Aug. 31, 2013, 3:11 p.m.
On Tue, Jul 09, 2013 at 01:07:56PM +0000, Syed Asifful Dayyan Rafiuddeen wrote:
> 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.

Thanks, applied.

Patch

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