[PATCH 2/3] P2P: Rejecting Go Negotiation request for single p2p interface device (GO or GC).

Avichal Agarwal avichal.a at samsung.com
Wed Aug 5 04:32:24 EDT 2015


From 4a2602f9c1c79621731f82e036cde55309e181b9 Mon Sep 17 00:00:00 2001
From: Avichal Agarwal <avichal.a at samsung.com>
Date: Wed, 5 Aug 2015 12:21:40 +0530
Subject: [PATCH 2/3] P2P: Rejecting Go Negotiation request for single p2p
-interface device (GO or GC).

This patch works when there is only single p2p interface which act as GC and GO.
It rejects Go Negotiation request when p2p interface is already connected.

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

diff --git a/src/p2p/p2p_go_neg.c b/src/p2p/p2p_go_neg.c
index 4322bbb..5e3deec 100644
--- a/src/p2p/p2p_go_neg.c
+++ b/src/p2p/p2p_go_neg.c
@@ -737,16 +737,41 @@ 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);
 
+	#ifdef SINGLE_P2P_INTERFACE
+	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;
+		}
+	}
+	#endif
+
 	if (p2p_parse(data, len, &msg))
 		return;
 
@@ -802,6 +827,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 +872,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