[PATCH 1/3] P2P: rejecting provision discovery request for single p2p interface as GC

Avichal Agarwal avichal.a at samsung.com
Wed Aug 5 04:28:52 EDT 2015


From: Avichal Agarwal <avichal.a at samsung.com>
Date: Wed, 5 Aug 2015 12:13:25 +0530
Subject: [PATCH 1/3] P2P: rejecting provision discovery request for single
p2p interface as GC

This patch will work when there is only single p2p interface (which act as both  GC and GO).
It rejects provision discovery request when single p2p interface is already connected as group client.

Signed-off-by: Avichal Agarwal <avichal.a at samsung.com>
Signed-off-by: Kyeong-Chae Lim <kcya.lim at samsung.com>
---
 src/p2p/p2p_pd.c |   24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/p2p/p2p_pd.c b/src/p2p/p2p_pd.c
index 065321c..f54c093 100644
--- a/src/p2p/p2p_pd.c
+++ b/src/p2p/p2p_pd.c
@@ -431,8 +431,8 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
 			       const u8 *data, size_t len, int rx_freq)
 {
 	struct p2p_message msg;
-	struct p2p_device *dev;
-	int freq;
+	struct p2p_device *dev,*n;
+	int freq,failflag=0;
 	enum p2p_status_code reject = P2P_SC_FAIL_INCOMPATIBLE_PARAMS;
 	struct wpabuf *resp;
 	u32 adv_id = 0;
@@ -456,7 +456,24 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
 		" with config methods 0x%x (freq=%d)",
 		MAC2STR(sa), msg.wps_config_methods, rx_freq);
 
+	#ifdef SINGLE_P2P_INTERAFCE	
+	dl_list_for_each_safe(dev, n, &p2p->devices, struct p2p_device, list) {
+		if (p2p->cfg->go_connected &&
+			p2p->cfg->go_connected(p2p->cfg->cb_ctx,
+				dev->info.p2p_device_addr)) {
+				p2p_dbg(p2p, " Already connected  Provision Discovery Request  Ignored\n");
+				reject = P2P_SC_FAIL_REJECTED_BY_USER;
+				failflag=1;
+				break;
+			}
+	}
+	#endif	
+
 	dev = p2p_get_device(p2p, sa);
+
+	if(dev && failflag)
+		goto out;
+
 	if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
 		p2p_dbg(p2p, "Provision Discovery Request from unknown peer "
 			MACSTR, MAC2STR(sa));
@@ -471,6 +488,9 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
 		dev->info.wfd_subelems = wpabuf_dup(msg.wfd_subelems);
 	}
 
+	if(failflag) 
+		goto out;
+
 	if (msg.adv_id)
 		allowed_config_methods |= WPS_CONFIG_P2PS;
 	else
-- 
1.7.9.5


More information about the HostAP mailing list