All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] monitor: add support for parsing RRM Requests
@ 2019-11-14 23:41 James Prestwood
  2019-11-14 23:41 ` [PATCH 2/2] monitor: add support for parsing RRM Reports James Prestwood
  2019-11-14 23:49 ` [PATCH 1/2] monitor: add support for parsing RRM Requests Denis Kenzior
  0 siblings, 2 replies; 3+ messages in thread
From: James Prestwood @ 2019-11-14 23:41 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 4425 bytes --]

Only beacon requests are parsed for now
---
 monitor/nlmon.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 124 insertions(+)

diff --git a/monitor/nlmon.c b/monitor/nlmon.c
index 15ff4ecb..b5734052 100644
--- a/monitor/nlmon.c
+++ b/monitor/nlmon.c
@@ -1861,6 +1861,110 @@ static void print_qos_map(unsigned int level, const char *label,
 	print_attr(level, "QoS Map");
 }
 
+static void print_measurement_request_beacon(unsigned int level,
+						const void *data,
+						uint16_t size)
+{
+	uint8_t mode;
+
+	if (size < 13)
+		return;
+
+	print_attr(level, "Operating Class: %u", l_get_u8(data));
+	print_attr(level, "Channel: %u", l_get_u8(data + 1));
+	print_attr(level, "Randomization Interval: %u", l_get_le16(data + 2));
+	print_attr(level, "Duration: %u", l_get_le16(data + 4));
+
+	mode = l_get_u8(data + 6);
+
+	switch (mode) {
+	case 0:
+		print_attr(level, "Measurement: Passive");
+		break;
+	case 1:
+		print_attr(level, "Measurement: Active");
+		break;
+	case 2:
+		print_attr(level, "Measurement: Table");
+		break;
+	default:
+		print_attr(level, "Measurement: Invalid (%u)", mode);
+		return;
+	}
+
+	print_attr(level, "BSSID: "MAC, MAC_STR(((const uint8_t *)data + 7)));
+}
+
+static const char *rrm_measurement_types[] = {
+	[0] = "Basic",
+	[1] = "Clear Channel Assessment",
+	[2] = "Receive Power Indication",
+	[3] = "Channel Load",
+	[4] = "Noise Histogram",
+	[5] = "Beacon",
+	[6] = "Frame",
+	[7] = "STA Statistics",
+	[8] = "LCI",
+	[9] = "Transmit Stream/Category Measurement",
+	[10] = "Multicast Diagnostics",
+	[11] = "Location Civic",
+	[12] = "Location Identifier",
+	[13] = "Directional Channel Quality",
+	[14] = "Directional Measurement",
+	[15] = "Directional Statistics",
+	[16] = "Fine Timing Measurement Range",
+	[255] = "Measurement Pause"
+};
+
+static void print_measurement_request(unsigned int level, const char *label,
+							const void *data,
+							uint16_t size)
+{
+	uint8_t mode;
+	uint8_t type;
+
+	print_attr(level, "Measurement Request");
+
+	if (size < 3)
+		return;
+
+	print_attr(level + 1, "Token: %u", l_get_u8(data));
+
+	mode = l_get_u8(data + 1);
+
+	print_attr(level + 1, "Request Mode: %u", mode);
+
+	if (util_is_bit_set(mode, 0))
+		print_attr(level + 2, "Parallel bit set");
+
+	if (util_is_bit_set(mode, 1))
+		print_attr(level + 2, "Enable bit set");
+
+	if (util_is_bit_set(mode, 2))
+		print_attr(level + 2, "Request bit set");
+
+	if (util_is_bit_set(mode, 3))
+		print_attr(level + 2, "Report bit set");
+
+	if (util_is_bit_set(mode, 4))
+		print_attr(level + 2, "Duration Mandatory set");
+
+	type = l_get_u8(data + 2);
+
+	if (type > 16 && type != 255) {
+		print_attr(level + 1, "Type: Invalid (%u)", type);
+		return;
+	}
+
+	print_attr(level + 1, "Type: %s", rrm_measurement_types[type]);
+
+	switch (type) {
+	case 5:
+		print_measurement_request_beacon(level + 1, data + 3, size - 3);
+		break;
+	}
+}
+
 static struct attr_entry ie_entry[] = {
 	{ IE_TYPE_SSID,				"SSID",
 		ATTR_CUSTOM,	{ .function = print_ie_ssid } },
@@ -1911,6 +2015,8 @@ static struct attr_entry ie_entry[] = {
 		{ .function = print_ie_supported_operating_classes } },
 	{ IE_TYPE_QOS_MAP_SET,			"QoS Map",
 		ATTR_CUSTOM,	{ .function = print_qos_map } },
+	{ IE_TYPE_MEASUREMENT_REQUEST,		"Measurement Request",
+		ATTR_CUSTOM,	{ .function = print_measurement_request } },
 	{ },
 };
 
@@ -3974,6 +4080,18 @@ static void print_public_action_frame(unsigned int level, const uint8_t *body,
 	}
 }
 
+static void print_rm_request(unsigned int level, const uint8_t *body,
+				size_t body_len)
+{
+	if (body_len < 3)
+		return;
+
+	print_attr(level, "Dialog Token: %u", body[0]);
+	print_attr(level, "Repetitions: %u", l_get_le16(body + 1));
+
+	print_ie(level, "IEs", body + 3, body_len - 3);
+}
+
 static void print_rm_action_frame(unsigned int level, const uint8_t *body,
 					size_t body_len)
 {
@@ -3998,6 +4116,12 @@ static void print_rm_action_frame(unsigned int level, const uint8_t *body,
 		category = "Unknown";
 
 	print_attr(level, "Radio Measurement Action: %s (%u)", category, body[0]);
+
+	switch (body[0]) {
+	case 0:
+		print_rm_request(level + 1, body + 1, body_len - 1);
+		break;
+	}
 }
 
 static void print_action_mgmt_frame(unsigned int level,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] monitor: add support for parsing RRM Reports
  2019-11-14 23:41 [PATCH 1/2] monitor: add support for parsing RRM Requests James Prestwood
@ 2019-11-14 23:41 ` James Prestwood
  2019-11-14 23:49 ` [PATCH 1/2] monitor: add support for parsing RRM Requests Denis Kenzior
  1 sibling, 0 replies; 3+ messages in thread
From: James Prestwood @ 2019-11-14 23:41 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 3566 bytes --]

Only beacon reports are parsed for now
---
 monitor/nlmon.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/monitor/nlmon.c b/monitor/nlmon.c
index b5734052..4053879f 100644
--- a/monitor/nlmon.c
+++ b/monitor/nlmon.c
@@ -1965,6 +1965,74 @@ static void print_measurement_request(unsigned int level, const char *label,
 	}
 }
 
+static void print_measurement_report_beacon(unsigned int level,
+						const void *data,
+						uint16_t size)
+{
+	uint8_t frame_info;
+
+	if (size < 26)
+		return;
+
+	print_attr(level, "Operating Class: %u", l_get_u8(data));
+	print_attr(level, "Channel: %u", l_get_u8(data + 1));
+	print_attr(level, "Start Time: %"PRIu64, l_get_le64(data + 2));
+	print_attr(level, "Duration: %u", l_get_le16(data + 10));
+
+	frame_info = l_get_u8(data + 12);
+
+	print_attr(level, "PHY Type: %u", util_bit_field(frame_info, 0, 7));
+	print_attr(level, "Frame Type: %u", util_is_bit_set(frame_info, 7));
+	print_attr(level, "RCPI: %u", l_get_u8(data + 13));
+	print_attr(level, "RSNI: %u", l_get_u8(data + 14));
+	print_attr(level, "BSSID: "MAC, MAC_STR(((const uint8_t *)data + 15)));
+	print_attr(level, "Antenna ID: %u", l_get_u8(data + 21));
+	print_attr(level, "Parent TSF: %u", l_get_le32(data + 22));
+}
+
+static void print_measurement_report(unsigned int level, const char *label,
+							const void *data,
+							uint16_t size)
+{
+	uint8_t mode;
+	uint8_t type;
+
+	print_attr(level, "Measurement Report");
+
+	if (size < 3)
+		return;
+
+	print_attr(level + 1, "Token: %u", l_get_u8(data));
+
+	mode = l_get_u8(data + 1);
+
+	print_attr(level + 1, "Report Mode: %u", mode);
+
+	if (util_is_bit_set(mode, 0))
+		print_attr(level + 2, "Late bit set");
+
+	if (util_is_bit_set(mode, 1))
+		print_attr(level + 2, "Incapable bit set");
+
+	if (util_is_bit_set(mode, 2))
+		print_attr(level + 2, "Refused bit set");
+
+	type = l_get_u8(data + 2);
+
+	if (type > 16 && type != 255) {
+		print_attr(level + 1, "Type: Invalid (%u)", type);
+		return;
+	}
+
+	print_attr(level + 1, "Type: %s", rrm_measurement_types[type]);
+
+	switch (type) {
+	case 5:
+		print_measurement_report_beacon(level + 1, data + 3, size - 3);
+		break;
+	}
+}
+
 static struct attr_entry ie_entry[] = {
 	{ IE_TYPE_SSID,				"SSID",
 		ATTR_CUSTOM,	{ .function = print_ie_ssid } },
@@ -2017,6 +2085,8 @@ static struct attr_entry ie_entry[] = {
 		ATTR_CUSTOM,	{ .function = print_qos_map } },
 	{ IE_TYPE_MEASUREMENT_REQUEST,		"Measurement Request",
 		ATTR_CUSTOM,	{ .function = print_measurement_request } },
+	{ IE_TYPE_MEASUREMENT_REPORT,		"Measurement Report",
+		ATTR_CUSTOM,	{ .function = print_measurement_report } },
 	{ },
 };
 
@@ -4092,6 +4162,17 @@ static void print_rm_request(unsigned int level, const uint8_t *body,
 	print_ie(level, "IEs", body + 3, body_len - 3);
 }
 
+static void print_rm_report(unsigned int level, const uint8_t *body,
+				size_t body_len)
+{
+	if (body_len < 1)
+		return;
+
+	print_attr(level, "Dialog Token: %u", body[0]);
+
+	print_ie(level, "IEs", body + 1, body_len - 1);
+}
+
 static void print_rm_action_frame(unsigned int level, const uint8_t *body,
 					size_t body_len)
 {
@@ -4121,6 +4202,9 @@ static void print_rm_action_frame(unsigned int level, const uint8_t *body,
 	case 0:
 		print_rm_request(level + 1, body + 1, body_len - 1);
 		break;
+	case 1:
+		print_rm_report(level + 1, body + 1, body_len - 1);
+		break;
 	}
 }
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] monitor: add support for parsing RRM Requests
  2019-11-14 23:41 [PATCH 1/2] monitor: add support for parsing RRM Requests James Prestwood
  2019-11-14 23:41 ` [PATCH 2/2] monitor: add support for parsing RRM Reports James Prestwood
@ 2019-11-14 23:49 ` Denis Kenzior
  1 sibling, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2019-11-14 23:49 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 272 bytes --]

Hi James,

On 11/14/19 5:41 PM, James Prestwood wrote:
> Only beacon requests are parsed for now
> ---
>   monitor/nlmon.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 124 insertions(+)
> 

Both applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-14 23:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-14 23:41 [PATCH 1/2] monitor: add support for parsing RRM Requests James Prestwood
2019-11-14 23:41 ` [PATCH 2/2] monitor: add support for parsing RRM Reports James Prestwood
2019-11-14 23:49 ` [PATCH 1/2] monitor: add support for parsing RRM Requests Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.