Skip to contentSkip to conversation

ie: parse RSNXE Present bit

PATCH In review James Prestwood 2 participants 5 messages Sep 21, 2021

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/4 ie: parse RSNXE Present bit

---
 src/ie.c | 1 +
 src/ie.h | 1 +
 2 files changed, 2 insertions(+)
src/ie.c +1 -0
index 0440373c..b2a8102a 100644
@@ -1732,6 +1732,7 @@ int ie_parse_fast_bss_transition(struct ie_tlv_iter *iter, uint32_t mic_len,
 
 	memset(info, 0, sizeof(*info));
 
+	info->rsnxe_used = test_bit(data, 0);
 	info->mic_element_count = data[1];
 
 	memcpy(info->mic, data + 2, mic_len);
src/ie.h +1 -0
index f64072b3..844e9950 100644
@@ -419,6 +419,7 @@ enum ie_bss_capability {
 
 struct ie_ft_info {
 	uint8_t mic_element_count;
+	bool rsnxe_used;
 	uint8_t mic[24];
 	uint8_t anonce[32];
 	uint8_t snonce[32];
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH 2/4 nlmon: print Fast BSS Transition element

---
 monitor/nlmon.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
monitor/nlmon.c +60 -0
index 191ebf02..4cf2b856 100644
@@ -2177,6 +2177,64 @@ static void print_measurement_report(unsigned int level, const char *label,
 	}
 }
 
+static void print_fast_bss_transition(unsigned int level, const char *label,
+							const void *data,
+							uint16_t size)
+{
+	struct ie_ft_info ft_info;
+	uint32_t mic_len = 16;
+
+	/* Most likely the MIC is 16 bytes */
+	if (ie_parse_fast_bss_transition_from_data(data - 2, size + 2,
+						mic_len, &ft_info) < 0) {
+		mic_len = 24;
+
+		/* Must be FILS, try 24 */
+		if (ie_parse_fast_bss_transition_from_data(data - 2, size + 2,
+						mic_len, &ft_info) < 0) {
+			print_attr(level + 1, "error parsing");
+			return;
+		}
+	}
+
+	print_attr(level, "%s", label);
+
+	if (ft_info.rsnxe_used)
+		print_attr(level + 1, "RSNXE Used set");
+
+	print_attr(level + 1, "MIC Element Count: %u",
+			ft_info.mic_element_count);
+	print_attr(level + 1, "MIC:");
+	print_hexdump(level + 2, ft_info.mic, mic_len);
+	print_attr(level + 1, "ANONCE:");
+	print_hexdump(level + 2, ft_info.anonce, sizeof(ft_info.anonce));
+	print_attr(level + 1, "SNONCE:");
+	print_hexdump(level + 2, ft_info.snonce, sizeof(ft_info.snonce));
+	print_attr(level + 1, "R0KHID:");
+	print_hexdump(level + 2, ft_info.r0khid, ft_info.r0khid_len);
+
+	if (ft_info.r1khid_present) {
+		print_attr(level + 1, "R1KHID:");
+		print_hexdump(level + 2, ft_info.r1khid, sizeof(ft_info.r1khid));
+	}
+
+	if (ft_info.gtk_len) {
+		print_attr(level + 1, "GTK Key ID: %u", ft_info.gtk_key_id);
+		print_attr(level + 1, "GTK RSC:");
+		print_hexdump(level + 2, ft_info.gtk_rsc, sizeof(ft_info.gtk_rsc));
+		print_attr(level + 1, "GTK:");
+		print_hexdump(level + 2, ft_info.gtk, ft_info.gtk_len);
+	}
+
+	if (ft_info.igtk_len) {
+		print_attr(level + 1, "IGTK Key ID: %u", ft_info.igtk_key_id);
+		print_attr(level + 1, "IGTK IPN:");
+		print_hexdump(level + 2, ft_info.igtk_ipn, sizeof(ft_info.igtk_ipn));
+		print_attr(level + 1, "IGTK:");
+		print_hexdump(level + 2, ft_info.igtk, ft_info.igtk_len);
+	}
+}
+
 static struct attr_entry ie_entry[] = {
 	{ IE_TYPE_SSID,				"SSID",
 		ATTR_CUSTOM,	{ .function = print_ie_ssid } },
@@ -2235,6 +2293,8 @@ static struct attr_entry ie_entry[] = {
 		ATTR_CUSTOM,	{ .function = print_measurement_request } },
 	{ IE_TYPE_MEASUREMENT_REPORT,		"Measurement Report",
 		ATTR_CUSTOM,	{ .function = print_measurement_report } },
+	{ IE_TYPE_FAST_BSS_TRANSITION,		"Fast BSS Transition",
+		ATTR_CUSTOM,	{ .function = print_fast_bss_transition } },
 	{ },
 };
 
Signature · 1 line
2.31.1
author
#2 lore raw

PATCH 3/4 nlmon: print Mobility Domain element

In reply to James Prestwood
---
 monitor/nlmon.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
monitor/nlmon.c +26 -0
index 4cf2b856..ec7fc03a 100644
@@ -2235,6 +2235,30 @@ static void print_fast_bss_transition(unsigned int level, const char *label,
 	}
 }
 
+static void print_mobility_domain(unsigned int level, const char *label,
+					const void *data, uint16_t size)
+{
+	uint16_t mdid;
+	bool ft_over_ds;
+	bool resource_req;
+
+	print_attr(level, "%s", label);
+
+	if (ie_parse_mobility_domain_from_data(data - 2, size + 2, &mdid,
+					&ft_over_ds, &resource_req) < 0) {
+		print_attr(level + 1, "error parsing");
+		return;
+	}
+
+	print_attr(level + 1, "MDID: %04x", mdid);
+
+	if (ft_over_ds)
+		print_attr(level + 1, "FT-over-DS bit set");
+
+	if (resource_req)
+		print_attr(level + 1, "Resource Request Protocol bit set");
+}
+
 static struct attr_entry ie_entry[] = {
 	{ IE_TYPE_SSID,				"SSID",
 		ATTR_CUSTOM,	{ .function = print_ie_ssid } },
@@ -2295,6 +2319,8 @@ static struct attr_entry ie_entry[] = {
 		ATTR_CUSTOM,	{ .function = print_measurement_report } },
 	{ IE_TYPE_FAST_BSS_TRANSITION,		"Fast BSS Transition",
 		ATTR_CUSTOM,	{ .function = print_fast_bss_transition } },
+	{ IE_TYPE_MOBILITY_DOMAIN,		"Mobility Domain",
+		ATTR_CUSTOM,	{ .function = print_mobility_domain } },
 	{ },
 };
 
Signature · 1 line
2.31.1
author
#3 lore raw

PATCH 4/4 nlmon: print RSNXE

In reply to James Prestwood
---
 monitor/nlmon.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
monitor/nlmon.c +19 -0
index ec7fc03a..5b96a24a 100644
@@ -2259,6 +2259,23 @@ static void print_mobility_domain(unsigned int level, const char *label,
 		print_attr(level + 1, "Resource Request Protocol bit set");
 }
 
+static void print_rsnx(unsigned int level, const char *label,
+					const void *data, uint16_t size)
+{
+	const uint8_t *ptr = data;
+	uint8_t field_size = bit_field(ptr[0], 0, 4);
+
+	print_attr(level, "%s", label);
+
+	print_attr(level + 1, "Field Size: %u", field_size);
+
+	if (test_bit(ptr, 4))
+		print_attr(level + 1, "Protected TWT Operations Support");
+
+	if (test_bit(ptr, 5))
+		print_attr(level + 1, "SAE Hash-to-Element");
+}
+
 static struct attr_entry ie_entry[] = {
 	{ IE_TYPE_SSID,				"SSID",
 		ATTR_CUSTOM,	{ .function = print_ie_ssid } },
@@ -2321,6 +2338,8 @@ static struct attr_entry ie_entry[] = {
 		ATTR_CUSTOM,	{ .function = print_fast_bss_transition } },
 	{ IE_TYPE_MOBILITY_DOMAIN,		"Mobility Domain",
 		ATTR_CUSTOM,	{ .function = print_mobility_domain } },
+	{ IE_TYPE_RSNX,				"RSNX",
+		ATTR_CUSTOM,	{ .function = print_rsnx } },
 	{ },
 };
 
Signature · 1 line
2.31.1
#4 lore raw
In reply to James Prestwood

Hi James,

Quoted 5 lines · James Prestwood
---
  src/ie.c | 1 +
  src/ie.h | 1 +
  2 files changed, 2 insertions(+)

All applied, thanks.

Regards,
-Denis