monitor: Add support for ISO packets
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 3 Oct 2019 13:36:22 +0000 (16:36 +0300)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:48 +0000 (14:30 +0530)
This enables decoding of ISO packets.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
monitor/packet.c
monitor/packet.h
src/shared/btsnoop.h

index 9a867d9..b9acf34 100755 (executable)
@@ -3929,6 +3929,12 @@ void packet_monitor(struct timeval *tv, struct ucred *cred,
        case BTSNOOP_OPCODE_SCO_RX_PKT:
                packet_hci_scodata(tv, cred, index, true, data, size);
                break;
+       case BTSNOOP_OPCODE_ISO_TX_PKT:
+               packet_hci_isodata(tv, cred, index, false, data, size);
+               break;
+       case BTSNOOP_OPCODE_ISO_RX_PKT:
+               packet_hci_isodata(tv, cred, index, true, data, size);
+               break;
        case BTSNOOP_OPCODE_OPEN_INDEX:
                if (index < MAX_INDEX)
                        addr2str(index_list[index].bdaddr, str);
@@ -11338,6 +11344,54 @@ void packet_hci_scodata(struct timeval *tv, struct ucred *cred, uint16_t index,
                packet_hexdump(data, size);
 }
 
+void packet_hci_isodata(struct timeval *tv, struct ucred *cred, uint16_t index,
+                               bool in, const void *data, uint16_t size)
+{
+       const struct bt_hci_iso_hdr *hdr = data;
+       uint16_t handle = le16_to_cpu(hdr->handle);
+       uint8_t flags = acl_flags(handle);
+       char handle_str[16], extra_str[32];
+
+       if (index > MAX_INDEX) {
+               print_field("Invalid index (%d).", index);
+               return;
+       }
+
+       index_list[index].frame++;
+
+       if (size < sizeof(*hdr)) {
+               if (in)
+                       print_packet(tv, cred, '*', index, NULL, COLOR_ERROR,
+                               "Malformed ISO Data RX packet", NULL, NULL);
+               else
+                       print_packet(tv, cred, '*', index, NULL, COLOR_ERROR,
+                               "Malformed ISO Data TX packet", NULL, NULL);
+               packet_hexdump(data, size);
+               return;
+       }
+
+       data += sizeof(*hdr);
+       size -= sizeof(*hdr);
+
+       sprintf(handle_str, "Handle %d", acl_handle(handle));
+       sprintf(extra_str, "flags 0x%2.2x dlen %d", flags, hdr->dlen);
+
+       print_packet(tv, cred, in ? '>' : '<', index, NULL, COLOR_HCI_SCODATA,
+                               in ? "ISO Data RX" : "ISO Data TX",
+                                               handle_str, extra_str);
+
+       if (size != hdr->dlen) {
+               print_text(COLOR_ERROR, "invalid packet size (%d != %d)",
+                                                       size, hdr->dlen);
+               packet_hexdump(data, size);
+               return;
+       }
+
+       if (filter_mask & PACKET_FILTER_SHOW_SCO_DATA)
+               packet_hexdump(data, size);
+}
+
+
 void packet_ctrl_open(struct timeval *tv, struct ucred *cred, uint16_t index,
                                        const void *data, uint16_t size)
 {
index c0780cd..d0fcc71 100755 (executable)
@@ -94,6 +94,8 @@ void packet_hci_acldata(struct timeval *tv, struct ucred *cred, uint16_t index,
                                bool in, const void *data, uint16_t size);
 void packet_hci_scodata(struct timeval *tv, struct ucred *cred, uint16_t index,
                                bool in, const void *data, uint16_t size);
+void packet_hci_isodata(struct timeval *tv, struct ucred *cred, uint16_t index,
+                               bool in, const void *data, uint16_t size);
 
 void packet_ctrl_open(struct timeval *tv, struct ucred *cred, uint16_t index,
                                        const void *data, uint16_t size);
index f3a9301..5dd1023 100755 (executable)
@@ -53,6 +53,8 @@
 #define BTSNOOP_OPCODE_CTRL_CLOSE      15
 #define BTSNOOP_OPCODE_CTRL_COMMAND    16
 #define BTSNOOP_OPCODE_CTRL_EVENT      17
+#define BTSNOOP_OPCODE_ISO_TX_PKT      18
+#define BTSNOOP_OPCODE_ISO_RX_PKT      19
 
 #define BTSNOOP_MAX_PACKET_SIZE                (1486 + 4)