diff mbox series

[BlueZ,2/4] monitor: Add decoding support for BIGInfo mgmt event

Message ID 20230821120353.28711-3-iulia.tanasescu@nxp.com (mailing list archive)
State Superseded
Headers show
Series Add mgmt event for BIGInfo report | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Iulia Tanasescu Aug. 21, 2023, 12:03 p.m. UTC
This adds btmon support for decoding BIGInfo MGMT events.

---
 monitor/control.c | 25 +++++++++++++++++++++++++
 monitor/packet.c  | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
diff mbox series

Patch

diff --git a/monitor/control.c b/monitor/control.c
index 009cf1520..b843d076f 100644
--- a/monitor/control.c
+++ b/monitor/control.c
@@ -5,6 +5,7 @@ 
  *
  *  Copyright (C) 2011-2014  Intel Corporation
  *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
+ *  Copyright 2023 NXP
  *
  *
  */
@@ -788,6 +789,27 @@  static void mgmt_advertising_removed(uint16_t len, const void *buf)
 	packet_hexdump(buf, len);
 }
 
+static void mgmt_big_info_adv_report(uint16_t len, const void *buf)
+{
+	const struct mgmt_ev_le_big_info_adv_report *ev = buf;
+	uint16_t sync_handle;
+
+	if (len < sizeof(*ev)) {
+		printf("* Malformed BIGInfo advertising report control\n");
+		return;
+	}
+
+	sync_handle = le16_to_cpu(ev->sync_handle);
+
+	printf("@ BIGInfo Advertising Report: sync_handle 0x%4.4x num_bis %u "
+		"encryption %u\n", sync_handle, ev->num_bis, ev->encryption);
+
+	buf += sizeof(*ev);
+	len -= sizeof(*ev);
+
+	packet_hexdump(buf, len);
+}
+
 void control_message(uint16_t opcode, const void *data, uint16_t size)
 {
 	if (!decode_control)
@@ -893,6 +915,9 @@  void control_message(uint16_t opcode, const void *data, uint16_t size)
 	case MGMT_EV_ADVERTISING_REMOVED:
 		mgmt_advertising_removed(size, data);
 		break;
+	case MGMT_EV_LE_BIG_INFO_ADV_REPORT:
+		mgmt_big_info_adv_report(size, data);
+		break;
 	default:
 		printf("* Unknown control (code %d len %d)\n", opcode, size);
 		packet_hexdump(data, size);
diff --git a/monitor/packet.c b/monitor/packet.c
index 8eae8c9ea..96fc2662e 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -15396,6 +15396,37 @@  static void mgmt_mesh_device_found_evt(const void *data, uint16_t size)
 	print_hex_field("EIR Data", eir_data, size);
 }
 
+static void mgmt_big_info_adv_report(const void *data, uint16_t size)
+{
+	uint16_t sync_handle = get_le16(data);
+	uint8_t num_bis = get_u8(data + 2);
+	uint8_t nse = get_u8(data + 3);
+	uint16_t iso_interval = get_le16(data + 4);
+	uint8_t bn = get_u8(data + 6);
+	uint8_t pto = get_u8(data + 7);
+	uint8_t irc = get_u8(data + 8);
+	uint16_t max_pdu = get_le16(data + 9);
+	const uint8_t *sdu_interval = data + 11;
+	uint16_t max_sdu = get_le16(data + 14);
+	uint8_t phy = get_u8(data + 16);
+	uint8_t framing = get_u8(data + 17);
+	uint8_t encryption = get_u8(data + 18);
+
+	print_field("Sync Handle: 0x%4.4x", sync_handle);
+	print_field("Number BIS: %u", num_bis);
+	print_field("NSE: %u", nse);
+	print_slot_125("ISO Interval", iso_interval);
+	print_field("BN: %u", bn);
+	print_field("PTO: %u", pto);
+	print_field("IRC: %u", irc);
+	print_field("Maximum PDU: %u", max_pdu);
+	print_usec_interval("SDU Interval", sdu_interval);
+	print_field("Maximum SDU: %u", max_sdu);
+	print_le_phy("PHY", phy);
+	print_framing(framing);
+	print_field("Encryption: 0x%02x", encryption);
+}
+
 static void mgmt_mesh_packet_cmplt_evt(const void *data, uint16_t size)
 {
 	uint8_t handle = get_u8(data);
@@ -15500,6 +15531,8 @@  static const struct mgmt_data mgmt_event_table[] = {
 			mgmt_mesh_device_found_evt, 22, false },
 	{ 0x0032, "Mesh Packet Complete",
 			mgmt_mesh_packet_cmplt_evt, 1, true },
+	{ 0x0033, "BIGInfo advertising report",
+			mgmt_big_info_adv_report, 19, false },
 	{ }
 };