PATCH 2/3] P2P: Rejecting Go-Neg-request if the device is already connected

Avichal Agarwal avichal.a
Mon Aug 3 04:09:07 PDT 2015


From: Avichal Agarwal <avichal.a at samsung.com>
Date: Mon, 3 Aug 2015 15:55:46 +0530
Subject: [PATCH 2/3] P2P: Rejecting Go-Neg-request if the device is already  connected

According to p2p specs either GO or GC should not receive go negotiation request.

Signed-off-by: Avichal Agarwal <avichal.a at samsung.com>
---
 src/p2p/p2p_go_neg.c |   33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/p2p/p2p_go_neg.c b/src/p2p/p2p_go_neg.c
index 4322bbb..016c397 100644
--- a/src/p2p/p2p_go_neg.c
+++ b/src/p2p/p2p_go_neg.c
@@ -737,16 +737,39 @@ static void p2p_check_pref_chan(struct p2p_data *p2p, int go,
 void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
 			    const u8 *data, size_t len, int rx_freq)
 {
-	struct p2p_device *dev = NULL;
+	struct p2p_device *dev = NULL,*n;
 	struct wpabuf *resp;
 	struct p2p_message msg;
 	u8 status = P2P_SC_FAIL_INVALID_PARAMS;
 	int tie_breaker = 0;
-	int freq;
+	int freq,failflag=0,i;
 
 	p2p_dbg(p2p, "Received GO Negotiation Request from " MACSTR "(freq=%d)",
 		MAC2STR(sa), rx_freq);
 
+	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, "Alraedy Conncted GO-NEG-REQ IGNORED\n");
+				status = P2P_SC_FAIL_REJECTED_BY_USER;
+				failflag=1;
+				break;
+		}
+		for (i = 0; i < p2p->num_groups; i++) {
+			if (p2p_group_is_client_connected(
+			    p2p->groups[i], dev->info.p2p_device_addr))
+				break;
+		}
+		if (i < p2p->num_groups) {
+			p2p_dbg(p2p, "Alraedy Conncted GO-NEG-REQ IGNORED\n");
+			status = P2P_SC_FAIL_REJECTED_BY_USER;
+			failflag=1;
+			break;
+		}
+	}
+
 	if (p2p_parse(data, len, &msg))
 		return;
 
@@ -802,6 +825,9 @@ void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
 	}
 
 	dev = p2p_get_device(p2p, sa);
+	
+	if(dev && failflag)
+		goto fail;
 
 	if (msg.status && *msg.status) {
 		p2p_dbg(p2p, "Unexpected Status attribute (%d) in GO Negotiation Request",
@@ -844,6 +870,9 @@ void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
 			MAC2STR(dev->info.p2p_device_addr));
 		p2p_add_dev_info(p2p, sa, dev, &msg);
 	}
+	
+	if(failflag)
+		goto fail;
 
 	if (p2p->go_neg_peer && p2p->go_neg_peer == dev)
 		eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
-- 
1.7.9.5



More information about the Hostap mailing list