diff mbox series

[1/8] iw: scan: parse measurement pilot element

Message ID 20200209165902.44110-2-markus.theil@tu-ilmenau.de (mailing list archive)
State Accepted
Delegated to: Johannes Berg
Headers show
Series iw: parse measurement pilot and fix scan bugs | expand

Commit Message

Markus Theil Feb. 9, 2020, 4:58 p.m. UTC
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
---
 scan.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
diff mbox series

Patch

diff --git a/scan.c b/scan.c
index 50a4147..a6cb3bb 100644
--- a/scan.c
+++ b/scan.c
@@ -1530,6 +1530,47 @@  static void print_supp_op_classes(const uint8_t type, uint8_t len,
 		}
 }
 
+static void print_measurement_pilot_tx(const uint8_t type, uint8_t len,
+				       const uint8_t *data,
+				       const struct print_ies_data *ie_buffer)
+{
+	printf("\n");
+	printf("\t\t * interval: %d TUs\n", data[0]);
+
+	if(len <= 1)
+		return;
+
+	uint8_t *p = (uint8_t *) data + 1;
+	uint8_t len_remaining = len - 1;
+	
+	while (len_remaining >=5) {
+		uint8_t subelement_id = *p;
+		++p;
+		uint8_t len = *p;
+		++p;
+
+		len_remaining -= 2;
+
+		/* 802.11-2016 only allows vendor specific elements */
+		if (subelement_id != 221) {
+			printf("\t\t * <Invalid subelement ID %d>\n", subelement_id);
+			return;
+		}
+
+		printf("\t\t * vendor specific: OUI %.2x:%.2x:%.2x, data:",
+			p[0], p[1], p[2]);
+		len_remaining -= 3;
+
+		if (len > len_remaining)
+			printf(" <Parse error, element too short>\n");
+			return;
+
+		while (p < p + len)
+			printf(" %.2x", *p);
+		printf("\n");
+	}
+}
+
 static void print_obss_scan_params(const uint8_t type, uint8_t len,
 				   const uint8_t *data,
 				   const struct print_ies_data *ie_buffer)
@@ -1652,6 +1693,7 @@  static const struct ie_print ieprinters[] = {
 	[45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), },
 	[47] = { "ERP D4.0", print_erp, 1, 255, BIT(PRINT_SCAN), },
 	[59] = { "Supported operating classes", print_supp_op_classes, 1, 255, BIT(PRINT_SCAN), },
+	[66] = { "Measurement Pilot Transmission", print_measurement_pilot_tx, 1, 255, BIT(PRINT_SCAN), },
 	[74] = { "Overlapping BSS scan params", print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), },
 	[61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
 	[62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },