[PATCH v3 25/36] PR: Add support to handle PR IE in Auth M3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Auth M3 will contain operation mode attribute and status attribute
with value set a success attribute in case of success or just status
attribute with value set as failure in case of negotiation failure.
The received operation mode is validated. The successful M3 validation
will give the agreed upon ranging role, ranging type, ranging channel.

Signed-off-by: Peddolla Harshavardhan Reddy <peddolla@xxxxxxxxxxxxxxxx>
---
 src/common/proximity_ranging.c | 123 +++++++++++++++++++++++++++++++++
 1 file changed, 123 insertions(+)

diff --git a/src/common/proximity_ranging.c b/src/common/proximity_ranging.c
index 399856b6e..0414178dd 100644
--- a/src/common/proximity_ranging.c
+++ b/src/common/proximity_ranging.c
@@ -2087,6 +2087,105 @@ end:
 }
 
 
+static int
+pr_process_pasn_ranging_wrapper_result(struct pr_data *pr,
+				       struct pr_device *dev,
+				       const struct ieee80211_mgmt *mgmt,
+				       size_t len)
+{
+	int ret = -1;
+	const u8 *ies;
+	size_t ies_len;
+	struct pr_message msg;
+	struct operation_mode op_mode;
+	struct pr_channels common_chan;
+
+	os_memset(&msg, 0, sizeof(msg));
+	ies = mgmt->u.auth.variable;
+	ies_len = len - offsetof(struct ieee80211_mgmt, u.auth.variable);
+
+	if (pr_parse_ies(ies, ies_len, &msg) || !msg.op_mode) {
+		wpa_printf(MSG_DEBUG,
+			   "PR PASN: Failed to parse PR IE in Auth3");
+		goto fail;
+	}
+
+	if (!msg.status_ie || !msg.status_ie_len) {
+		wpa_printf(MSG_DEBUG, "PR PASN: * No status attribute");
+		goto fail;
+	}
+
+	if (*msg.status_ie == PR_NEGOTIATION_FAIL) {
+		wpa_printf(MSG_DEBUG, "PR PASN: * Ranging Negotiation status fail");
+		goto fail;
+	}
+
+	if (!msg.op_mode || !msg.op_mode_len ||
+	    !msg.status_ie || !msg.status_ie_len) {
+		goto fail;
+	}
+
+	pr_process_op_mode(msg.op_mode, msg.op_mode_len, &op_mode);
+	if (op_mode.channels.op_classes != 1) {
+		wpa_printf(MSG_DEBUG, "PR: PASN received Invalid channel list");
+		goto fail;
+	}
+
+	wpa_printf(MSG_DEBUG,
+		   "PASN: PR *  Frame 3- Operating mode data: Role=%u, protocol type=%u, "
+		   "operating class= %u, channel= %u",
+		   op_mode.role, op_mode.protocol_type,
+		   op_mode.channels.op_class[0].op_class,
+		   op_mode.channels.op_class[0].channel[0]);
+
+	if (op_mode.protocol_type & PR_NTB_SECURE_LTF_BASED_RANGING ||
+	    op_mode.protocol_type & PR_NTB_OPEN_BASED_RANGING) {
+		if (op_mode.role & PR_ISTA_SUPPORT &&
+		    !pr->cfg->ntb_rsta_support)
+			goto fail;
+
+		if (op_mode.role & PR_RSTA_SUPPORT &&
+		    !pr->cfg->ntb_ista_support)
+			goto fail;
+
+		if (op_mode.protocol_type & PR_NTB_SECURE_LTF_BASED_RANGING &&
+		    !pr->cfg->secure_he_ltf)
+			goto fail;
+
+		pr_channels_intersect(&pr->cfg->ntb_channels, &op_mode.channels,
+				      &common_chan);
+		if (common_chan.op_classes == 0)
+			goto fail;
+	} else if (op_mode.protocol_type & PR_EDCA_BASED_RANGING) {
+		if (op_mode.role & PR_ISTA_SUPPORT &&
+		    !pr->cfg->edca_rsta_support)
+			goto fail;
+
+		if (op_mode.role & PR_RSTA_SUPPORT &&
+		    !pr->cfg->edca_ista_support)
+			goto fail;
+
+		pr_channels_intersect(&pr->cfg->edca_channels,
+				      &op_mode.channels, &common_chan);
+		if (common_chan.op_classes == 0)
+			goto fail;
+	}
+
+	if (op_mode.role & PR_RSTA_SUPPORT)
+		dev->ranging_role = PR_ISTA_SUPPORT;
+	else
+		dev->ranging_role = PR_RSTA_SUPPORT;
+	dev->protocol_type = op_mode.protocol_type;
+	dev->final_op_channel = op_mode.channels.op_class[0].channel[0];
+	dev->final_op_class = op_mode.channels.op_class[0].op_class;
+	ret = 0;
+
+fail:
+	pr_parse_free(&msg);
+	return ret;
+}
+
+
 static int pr_pasn_handle_auth_1(struct pr_data *pr, struct pr_device *dev,
 				 const struct ieee80211_mgmt *mgmt, size_t len,
 				 int freq)
@@ -2195,6 +2294,27 @@ fail:
 }
 
 
+static int pr_pasn_handle_auth_3(struct pr_data *pr, struct pr_device *dev,
+				 const struct ieee80211_mgmt *mgmt, size_t len)
+{
+	if (!dev->pasn)
+		return -1;
+
+	if (pr_process_pasn_ranging_wrapper_result(pr, dev, mgmt, len)) {
+		wpa_printf(MSG_ERROR,
+			   "PR PASN: Handle Auth3 action wrapper failed");
+		return -1;
+	}
+
+	if (handle_auth_pasn_3(dev->pasn, pr->cfg->dev_addr, mgmt->sa, mgmt,
+			       len) < 0) {
+		wpa_printf(MSG_ERROR, "PR PASN: Handle Auth3 failed");
+		return -1;
+	}
+	return 0;
+}
+
+
 int pr_pasn_auth_rx(struct pr_data *pr, const struct ieee80211_mgmt *mgmt,
 		    size_t len, int freq)
 {
@@ -2229,6 +2349,9 @@ int pr_pasn_auth_rx(struct pr_data *pr, const struct ieee80211_mgmt *mgmt,
 		return pr_pasn_handle_auth_1(pr, dev, mgmt, len, freq);
 	else if (auth_transaction == 2)
 		return pr_pasn_handle_auth_2(pr, dev, mgmt, len);
+	else if (auth_transaction == 3)
+		return pr_pasn_handle_auth_3(pr, dev, mgmt, len);
+
 	return -1;
 }
 
-- 
2.34.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux