[PATCH 14/23] P2PS: Process channels in PD response

Ilan Peer ilan.peer at intel.com
Thu Sep 24 13:38:04 EDT 2015


In case that the P2PS PD response includes the P2P channel
list attribute, update the peer device supported channels
and verify that the local device has common channels with
the peer (only a sanity check).

If the operating channel attribute is included in the
response, check that it is included in the intersection
and store it as the peer's operating frequency (so it
could later be used in the join flow etc.).

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/p2p/p2p_pd.c | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/src/p2p/p2p_pd.c b/src/p2p/p2p_pd.c
index 54db139..13f2c32 100644
--- a/src/p2p/p2p_pd.c
+++ b/src/p2p/p2p_pd.c
@@ -1366,10 +1366,40 @@ void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa,
 		passwd_id = DEV_PW_P2PS_DEFAULT;
 	}
 
-	if ((msg.conn_cap || msg.persistent_dev) &&
-	    (status == P2P_SC_SUCCESS || status == P2P_SC_SUCCESS_DEFERRED) &&
+	if ((status == P2P_SC_SUCCESS || status == P2P_SC_SUCCESS_DEFERRED) &&
 	    p2p->p2ps_prov) {
-		if (p2p->cfg->p2ps_prov_complete) {
+		dev->oper_freq = 0;
+
+		/* Save the reported channel list and operating frequency.
+		 * Note that the spec mandates that the responder should
+		 * include in the channel list only channels reported by the
+		 * initiator, so this is only a sanity check, and if this
+		 * fails the flow would continue, although it would probably
+		 * fail. Same is true for the operating channel.
+		 */
+		if (msg.channel_list && msg.channel_list_len &&
+		    p2p_peer_channels_check(p2p, &p2p->channels, dev,
+					    msg.channel_list,
+					    msg.channel_list_len) < 0)
+			p2p_dbg(p2p, "P2PS PD resp - No common channels");
+
+		if (msg.operating_channel) {
+			if (p2p_channels_includes(&p2p->channels,
+						  msg.operating_channel[3],
+						  msg.operating_channel[4]) &&
+			    p2p_channels_includes(&dev->channels,
+						  msg.operating_channel[3],
+						  msg.operating_channel[4])) {
+				dev->oper_freq =
+					p2p_channel_to_freq(msg.operating_channel[3],
+							    msg.operating_channel[4]);
+			}  else {
+				p2p_dbg(p2p,
+					"P2PS PD resp - invalid operating channel");
+			}
+		}
+
+		if (p2p->cfg->p2ps_prov_complete)
 			p2p->cfg->p2ps_prov_complete(
 				p2p->cfg->cb_ctx, status, sa, adv_mac,
 				p2p->p2ps_prov->session_mac,
@@ -1377,7 +1407,6 @@ void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa,
 				conncap, passwd_id, msg.persistent_ssid,
 				msg.persistent_ssid_len, 1, 0, NULL,
 				msg.feature_cap, msg.feature_cap_len);
-		}
 		p2ps_prov_free(p2p);
 	} else if (status != P2P_SC_SUCCESS &&
 		   status != P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE &&
-- 
1.9.1



More information about the HostAP mailing list