[PATCH v3 14/25] P2P: Add support for go negotiation action wrapper format for p2p2

Shivani Baranwal quic_shivbara at quicinc.com
Mon Aug 5 02:33:12 PDT 2024


Changes to support p2p2 go negotiation action wrapper format

Signed-off-by: Shivani Baranwal <quic_shivbara at quicinc.com>
---
 src/p2p/p2p.c        |  2 +-
 src/p2p/p2p_go_neg.c | 25 ++++++++++++++++---------
 src/p2p/p2p_i.h      |  6 +++---
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index d61f769..01490e2 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -1933,7 +1933,7 @@ static void p2p_rx_p2p_action(struct p2p_data *p2p, const u8 *sa,
 		p2p_handle_go_neg_resp(p2p, sa, data + 1, len - 1, rx_freq);
 		break;
 	case P2P_GO_NEG_CONF:
-		p2p_handle_go_neg_conf(p2p, sa, data + 1, len - 1);
+		p2p_handle_go_neg_conf(p2p, sa, data + 1, len - 1, false);
 		break;
 	case P2P_INVITATION_REQ:
 		p2p_handle_invitation_req(p2p, sa, data + 1, len - 1, rx_freq);
diff --git a/src/p2p/p2p_go_neg.c b/src/p2p/p2p_go_neg.c
index 0308216..58ea89c 100644
--- a/src/p2p/p2p_go_neg.c
+++ b/src/p2p/p2p_go_neg.c
@@ -802,7 +802,7 @@ void p2p_check_pref_chan(struct p2p_data *p2p, int go,
 
 
 int p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
-			   const u8 *data, size_t len, int rx_freq)
+			   const u8 *data, size_t len, int rx_freq, bool p2p2)
 {
 	struct p2p_device *dev = NULL;
 	struct p2p_message msg;
@@ -920,7 +920,7 @@ int p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
 		p2p_dbg(p2p, "User has rejected this peer");
 		status = P2P_SC_FAIL_REJECTED_BY_USER;
 	} else if (dev == NULL ||
-		   (dev->wps_method == WPS_NOT_READY &&
+		   (dev->wps_method == WPS_NOT_READY && !p2p2 &&
 		    (p2p->authorized_oob_dev_pw_id == 0 ||
 		     p2p->authorized_oob_dev_pw_id !=
 		     msg.dev_password_id))) {
@@ -991,6 +991,9 @@ int p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
 			goto fail;
 		}
 
+		if (p2p2)
+			goto skip;
+
 		switch (msg.dev_password_id) {
 		case DEV_PW_REGISTRAR_SPECIFIED:
 			p2p_dbg(p2p, "PIN from peer Display");
@@ -1057,7 +1060,7 @@ int p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
 			status = P2P_SC_FAIL_INCOMPATIBLE_PROV_METHOD;
 			goto fail;
 		}
-
+skip:
 		if (go && p2p_go_select_channel(p2p, dev, &status) < 0)
 			goto fail;
 
@@ -1128,7 +1131,7 @@ void p2p_handle_go_neg_req(struct p2p_data *p2p, const u8 *sa, const u8 *data,
 {
 	int freq;
 
-	if (p2p_process_go_neg_req(p2p, sa, data, len, rx_freq))
+	if (p2p_process_go_neg_req(p2p, sa, data, len, rx_freq, false))
 		return;
 
 	p2p_dbg(p2p, "Sending GO Negotiation Response");
@@ -1231,7 +1234,7 @@ static struct wpabuf * p2p_build_go_neg_conf(struct p2p_data *p2p,
 
 
 int p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa, const u8 *data,
-			    size_t len, int rx_freq)
+			    size_t len, int rx_freq, bool p2p2)
 {
 	struct p2p_device *dev;
 	int go = -1;
@@ -1242,7 +1245,7 @@ int p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa, const u8 *data,
 	p2p_dbg(p2p, "Received GO Negotiation Response from " MACSTR
 		" (freq=%d)", MAC2STR(sa), rx_freq);
 	dev = p2p_get_device(p2p, sa);
-	if (dev == NULL || dev->wps_method == WPS_NOT_READY ||
+	if (dev == NULL || (!p2p2 && dev->wps_method == WPS_NOT_READY) ||
 	    dev != p2p->go_neg_peer) {
 		p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
 			MAC2STR(sa));
@@ -1394,6 +1397,9 @@ int p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa, const u8 *data,
 	} else
 		dev->oper_freq = 0;
 
+	if (p2p2)
+		goto skip;
+
 	switch (msg.dev_password_id) {
 	case DEV_PW_REGISTRAR_SPECIFIED:
 		p2p_dbg(p2p, "PIN from peer Display");
@@ -1449,6 +1455,7 @@ int p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa, const u8 *data,
 		goto fail;
 	}
 
+skip:
 	if (go && p2p_go_select_channel(p2p, dev, &status) < 0)
 		goto fail;
 
@@ -1516,7 +1523,7 @@ void p2p_handle_go_neg_resp(struct p2p_data *p2p, const u8 *sa, const u8 *data,
 		return;
 	}
 
-	if (p2p_process_go_neg_resp(p2p, sa, data, len, rx_freq))
+	if (p2p_process_go_neg_resp(p2p, sa, data, len, rx_freq, false))
 		return;
 
 	p2p_dbg(p2p, "Sending GO Negotiation Confirm");
@@ -1545,7 +1552,7 @@ void p2p_handle_go_neg_resp(struct p2p_data *p2p, const u8 *sa, const u8 *data,
 
 
 void p2p_handle_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
-			    const u8 *data, size_t len)
+			    const u8 *data, size_t len, bool p2p2)
 {
 	struct p2p_device *dev;
 	struct p2p_message msg;
@@ -1553,7 +1560,7 @@ void p2p_handle_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
 	p2p_dbg(p2p, "Received GO Negotiation Confirm from " MACSTR,
 		MAC2STR(sa));
 	dev = p2p_get_device(p2p, sa);
-	if (dev == NULL || dev->wps_method == WPS_NOT_READY ||
+	if (dev == NULL || (!p2p2 && dev->wps_method == WPS_NOT_READY) ||
 	    dev != p2p->go_neg_peer) {
 		p2p_dbg(p2p, "Not ready for GO negotiation with " MACSTR,
 			MAC2STR(sa));
diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h
index 95bdd19..c3dfcea 100644
--- a/src/p2p/p2p_i.h
+++ b/src/p2p/p2p_i.h
@@ -925,11 +925,11 @@ void p2p_handle_go_neg_req(struct p2p_data *p2p, const u8 *sa, const u8 *data,
 void p2p_handle_go_neg_resp(struct p2p_data *p2p, const u8 *sa, const u8 *data,
 			    size_t len, int rx_freq);
 void p2p_handle_go_neg_conf(struct p2p_data *p2p, const u8 *sa, const u8 *data,
-			    size_t len);
+			    size_t len, bool p2p2);
 int p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa, const u8 *data,
-			   size_t len, int rx_freq);
+			   size_t len, int rx_freq, bool p2p2);
 int p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa, const u8 *data,
-			    size_t len, int rx_freq);
+			    size_t len, int rx_freq, bool p2p2);
 int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev);
 u16 p2p_wps_method_pw_id(enum p2p_wps_method wps_method);
 void p2p_reselect_channel(struct p2p_data *p2p,
-- 
2.7.4




More information about the Hostap mailing list