1 // SPDX-License-Identifier: LGPL-2.1-or-later
4 * BlueZ - Bluetooth protocol stack for Linux
6 * Copyright (C) 2011-2014 Intel Corporation
7 * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
16 #ifndef TIZEN_FEATURE_BLUEZ_MODIFY
24 #include "lib/bluetooth.h"
26 #include "src/shared/util.h"
27 #include "src/shared/queue.h"
28 #include "src/shared/btsnoop.h"
29 #include "monitor/bt.h"
30 #include "monitor/display.h"
31 #include "monitor/packet.h"
32 #include "monitor/analyze.h"
34 #define TIMEVAL_MSEC(_tv) \
35 (long long)((_tv)->tv_sec * 1000 + (_tv)->tv_usec / 1000)
41 struct timeval time_added;
42 struct timeval time_removed;
43 unsigned long num_hci;
44 unsigned long num_cmd;
45 unsigned long num_evt;
46 unsigned long num_acl;
47 unsigned long num_sco;
48 unsigned long num_iso;
49 unsigned long vendor_diag;
50 unsigned long system_note;
51 unsigned long user_log;
52 unsigned long ctrl_msg;
53 unsigned long unknown;
54 uint16_t manufacturer;
55 struct queue *conn_list;
58 #define CONN_BR_ACL 0x01
59 #define CONN_BR_SCO 0x02
60 #define CONN_BR_ESCO 0x03
61 #define CONN_LE_ACL 0x04
62 #define CONN_LE_ISO 0x05
68 struct packet_latency latency;
81 struct queue *tx_queue;
82 struct timeval last_rx;
83 struct queue *chan_list;
90 struct l2cap_chan *chan;
102 struct timeval last_rx;
107 static struct queue *dev_list;
109 static void tmp_write(void *data, void *user_data)
111 struct plot *plot = data;
112 FILE *tmp = user_data;
114 fprintf(tmp, "%lld %zu\n", plot->x_msec, plot->y_count);
117 static void plot_draw(struct queue *queue, const char *tittle)
121 if (queue_length(queue) < 2)
124 gplot = popen("gnuplot", "w");
128 fprintf(gplot, "$data << EOD\n");
129 queue_foreach(queue, tmp_write, gplot);
130 fprintf(gplot, "EOD\n");
132 fprintf(gplot, "set terminal dumb enhanced ansi\n");
133 fprintf(gplot, "set xlabel 'Latency (ms)'\n");
134 fprintf(gplot, "set tics out nomirror\n");
135 fprintf(gplot, "set log y\n");
136 fprintf(gplot, "set yrange [0.5:*]\n");
137 fprintf(gplot, "plot $data using 1:2 t '%s' w impulses\n", tittle);
143 static void print_stats(struct hci_stats *stats, const char *label)
148 print_field("%s packets: %zu/%zu", label, stats->num, stats->num_comp);
149 print_field("%s Latency: %lld-%lld msec (~%lld msec)", label,
150 TV_MSEC(stats->latency.min),
151 TV_MSEC(stats->latency.max),
152 TV_MSEC(stats->latency.med));
153 print_field("%s size: %u-%u octets (~%zd octets)", label,
154 stats->min, stats->max, stats->bytes / stats->num);
156 if (TV_MSEC(stats->latency.total))
157 print_field("%s speed: ~%lld Kb/s", label,
158 stats->bytes * 8 / TV_MSEC(stats->latency.total));
160 plot_draw(stats->plot, label);
163 static void chan_destroy(void *data)
165 struct l2cap_chan *chan = data;
167 if (!chan->rx.num && !chan->tx.num)
170 printf(" Found %s L2CAP channel with CID %u\n",
171 chan->out ? "TX" : "RX", chan->cid);
173 print_field("PSM %u", chan->psm);
175 print_stats(&chan->rx, "RX");
176 print_stats(&chan->tx, "TX");
182 static struct l2cap_chan *chan_alloc(struct hci_conn *conn, uint16_t cid,
185 struct l2cap_chan *chan;
187 chan = new0(struct l2cap_chan, 1);
191 chan->rx.plot = queue_new();
192 chan->tx.plot = queue_new();
197 static bool chan_match_cid(const void *a, const void *b)
199 const struct l2cap_chan *chan = a;
200 uint32_t val = PTR_TO_UINT(b);
201 uint16_t cid = val & 0xffff;
202 bool out = val & 0x10000;
204 return chan->cid == cid && chan->out == out;
207 static struct l2cap_chan *chan_lookup(struct hci_conn *conn, uint16_t cid,
210 struct l2cap_chan *chan;
211 uint32_t val = cid | (out ? 0x10000 : 0);
213 chan = queue_find(conn->chan_list, chan_match_cid, UINT_TO_PTR(val));
215 chan = chan_alloc(conn, cid, out);
216 queue_push_tail(conn->chan_list, chan);
222 static void conn_destroy(void *data)
224 struct hci_conn *conn = data;
227 switch (conn->type) {
248 printf(" Found %s connection with handle %u\n", str, conn->handle);
249 /* TODO: Store address type */
250 packet_print_addr("Address", conn->bdaddr, 0x00);
251 if (!conn->setup_seen)
252 print_field("Connection setup missing");
253 print_stats(&conn->rx, "RX");
254 print_stats(&conn->tx, "TX");
256 queue_destroy(conn->rx.plot, free);
257 queue_destroy(conn->tx.plot, free);
258 queue_destroy(conn->chan_list, chan_destroy);
260 queue_destroy(conn->tx_queue, free);
264 static struct hci_conn *conn_alloc(struct hci_dev *dev, uint16_t handle,
267 struct hci_conn *conn;
269 conn = new0(struct hci_conn, 1);
271 conn->handle = handle;
273 conn->tx_queue = queue_new();
274 conn->tx.plot = queue_new();
275 conn->rx.plot = queue_new();
277 conn->chan_list = queue_new();
282 static bool conn_match_handle(const void *a, const void *b)
284 const struct hci_conn *conn = a;
285 uint16_t handle = PTR_TO_UINT(b);
287 return (conn->handle == handle && !conn->terminated);
290 static struct hci_conn *conn_lookup(struct hci_dev *dev, uint16_t handle)
292 return queue_find(dev->conn_list, conn_match_handle,
293 UINT_TO_PTR(handle));
296 static bool link_match_handle(const void *a, const void *b)
298 const struct hci_conn *conn = a;
299 uint16_t handle = PTR_TO_UINT(b);
301 return (conn->link == handle && !conn->terminated);
304 static struct hci_conn *link_lookup(struct hci_dev *dev, uint16_t handle)
306 return queue_find(dev->conn_list, link_match_handle,
307 UINT_TO_PTR(handle));
310 static struct hci_conn *conn_lookup_type(struct hci_dev *dev, uint16_t handle,
313 struct hci_conn *conn;
315 conn = queue_find(dev->conn_list, conn_match_handle,
316 UINT_TO_PTR(handle));
317 if (!conn || (type && conn->type != type)) {
318 conn = conn_alloc(dev, handle, type);
319 queue_push_tail(dev->conn_list, conn);
325 static void dev_destroy(void *data)
327 struct hci_dev *dev = data;
342 printf("Found %s controller with index %u\n", str, dev->index);
343 printf(" BD_ADDR %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
344 dev->bdaddr[5], dev->bdaddr[4], dev->bdaddr[3],
345 dev->bdaddr[2], dev->bdaddr[1], dev->bdaddr[0]);
346 if (dev->manufacturer != 0xffff)
347 printf(" (%s)", bt_compidtostr(dev->manufacturer));
351 printf(" %lu commands\n", dev->num_cmd);
352 printf(" %lu events\n", dev->num_evt);
353 printf(" %lu ACL packets\n", dev->num_acl);
354 printf(" %lu SCO packets\n", dev->num_sco);
355 printf(" %lu ISO packets\n", dev->num_iso);
356 printf(" %lu vendor diagnostics\n", dev->vendor_diag);
357 printf(" %lu system notes\n", dev->system_note);
358 printf(" %lu user logs\n", dev->user_log);
359 printf(" %lu control messages \n", dev->ctrl_msg);
360 printf(" %lu unknown opcodes\n", dev->unknown);
361 queue_destroy(dev->conn_list, conn_destroy);
367 static struct hci_dev *dev_alloc(uint16_t index)
371 dev = new0(struct hci_dev, 1);
374 dev->manufacturer = 0xffff;
376 dev->conn_list = queue_new();
381 static bool dev_match_index(const void *a, const void *b)
383 const struct hci_dev *dev = a;
384 uint16_t index = PTR_TO_UINT(b);
386 return dev->index == index;
389 static struct hci_dev *dev_lookup(uint16_t index)
393 dev = queue_find(dev_list, dev_match_index, UINT_TO_PTR(index));
395 dev = dev_alloc(index);
396 queue_push_tail(dev_list, dev);
402 static void l2cap_sig(struct hci_conn *conn, bool out,
403 const void *data, uint16_t size)
405 const struct bt_l2cap_hdr_sig *hdr = data;
406 struct l2cap_chan *chan;
407 uint16_t psm, scid, dcid;
410 case BT_L2CAP_PDU_CONN_REQ:
411 psm = get_le16(data + 4);
412 scid = get_le16(data + 6);
413 chan = chan_lookup(conn, scid, out);
417 case BT_L2CAP_PDU_CONN_RSP:
418 dcid = get_le16(data + 4);
419 scid = get_le16(data + 6);
420 chan = chan_lookup(conn, scid, !out);
423 chan = chan_lookup(conn, dcid, out);
431 static void new_index(struct timeval *tv, uint16_t index,
432 const void *data, uint16_t size)
434 const struct btsnoop_opcode_new_index *ni = data;
437 dev = dev_alloc(index);
439 dev->type = ni->type;
440 memcpy(dev->bdaddr, ni->bdaddr, 6);
442 queue_push_tail(dev_list, dev);
445 static void del_index(struct timeval *tv, uint16_t index,
446 const void *data, uint16_t size)
450 dev = queue_remove_if(dev_list, dev_match_index, UINT_TO_PTR(index));
452 fprintf(stderr, "Remove for an unexisting device\n");
459 static void command_pkt(struct timeval *tv, uint16_t index,
460 const void *data, uint16_t size)
464 dev = dev_lookup(index);
472 static void evt_conn_complete(struct hci_dev *dev, struct timeval *tv,
473 const void *data, uint16_t size)
475 const struct bt_hci_evt_conn_complete *evt = data;
476 struct hci_conn *conn;
481 conn = conn_lookup_type(dev, le16_to_cpu(evt->handle), CONN_BR_ACL);
485 memcpy(conn->bdaddr, evt->bdaddr, 6);
486 conn->setup_seen = true;
489 static void evt_disconnect_complete(struct hci_dev *dev, struct timeval *tv,
490 const void *data, uint16_t size)
492 const struct bt_hci_evt_disconnect_complete *evt = data;
493 struct hci_conn *conn;
498 conn = conn_lookup(dev, le16_to_cpu(evt->handle));
502 conn->terminated = true;
505 static void rsp_read_bd_addr(struct hci_dev *dev, struct timeval *tv,
506 const void *data, uint16_t size)
508 const struct bt_hci_rsp_read_bd_addr *rsp = data;
513 memcpy(dev->bdaddr, rsp->bdaddr, 6);
516 static void evt_cmd_complete(struct hci_dev *dev, struct timeval *tv,
517 const void *data, uint16_t size)
519 const struct bt_hci_evt_cmd_complete *evt = data;
522 data += sizeof(*evt);
523 size -= sizeof(*evt);
525 opcode = le16_to_cpu(evt->opcode);
528 case BT_HCI_CMD_READ_BD_ADDR:
529 rsp_read_bd_addr(dev, tv, data, size);
534 static bool match_plot_latency(const void *data, const void *user_data)
536 const struct plot *plot = data;
537 const struct timeval *latency = user_data;
539 return TIMEVAL_MSEC(latency) == plot->x_msec;
542 static void plot_add(struct queue *queue, struct timeval *latency,
547 /* Use LRU ordering */
548 plot = queue_remove_if(queue, match_plot_latency, latency);
550 plot->y_count += count;
551 queue_push_head(queue, plot);
555 plot = new0(struct plot, 1);
556 plot->x_msec = TIMEVAL_MSEC(latency);
557 plot->y_count = count;
559 queue_push_tail(queue, plot);
562 static void evt_le_conn_complete(struct hci_dev *dev, struct timeval *tv,
565 const struct bt_hci_evt_le_conn_complete *evt;
566 struct hci_conn *conn;
568 evt = util_iov_pull_mem(iov, sizeof(*evt));
569 if (!evt || evt->status)
572 conn = conn_lookup_type(dev, le16_to_cpu(evt->handle), CONN_LE_ACL);
576 memcpy(conn->bdaddr, evt->peer_addr, 6);
577 conn->setup_seen = true;
580 static void evt_le_enh_conn_complete(struct hci_dev *dev, struct timeval *tv,
583 const struct bt_hci_evt_le_enhanced_conn_complete *evt;
584 struct hci_conn *conn;
586 evt = util_iov_pull_mem(iov, sizeof(*evt));
587 if (!evt || evt->status)
590 conn = conn_lookup_type(dev, le16_to_cpu(evt->handle), CONN_LE_ACL);
594 memcpy(conn->bdaddr, evt->peer_addr, 6);
595 conn->setup_seen = true;
598 static void evt_num_completed_packets(struct hci_dev *dev, struct timeval *tv,
599 const void *data, uint16_t size)
601 uint8_t num_handles = get_u8(data);
604 data += sizeof(num_handles);
605 size -= sizeof(num_handles);
607 for (i = 0; i < num_handles; i++) {
608 uint16_t handle = get_le16(data);
609 uint16_t count = get_le16(data + 2);
610 struct hci_conn *conn;
612 struct hci_conn_tx *last_tx;
618 conn = conn_lookup(dev, handle);
622 conn->tx.num_comp += count;
624 for (j = 0; j < count; j++) {
625 last_tx = queue_pop_head(conn->tx_queue);
627 struct l2cap_chan *chan = last_tx->chan;
629 timersub(tv, &last_tx->tv, &res);
631 packet_latency_add(&conn->tx.latency, &res);
632 plot_add(conn->tx.plot, &res, 1);
635 chan->tx.num_comp += count;
636 packet_latency_add(&chan->tx.latency,
638 plot_add(chan->tx.plot, &res, 1);
647 static void evt_sync_conn_complete(struct hci_dev *dev, struct timeval *tv,
648 const void *data, uint16_t size)
650 const struct bt_hci_evt_sync_conn_complete *evt = data;
651 struct hci_conn *conn;
656 conn = conn_lookup_type(dev, le16_to_cpu(evt->handle), evt->link_type);
660 memcpy(conn->bdaddr, evt->bdaddr, 6);
661 conn->setup_seen = true;
664 static void evt_le_cis_established(struct hci_dev *dev, struct timeval *tv,
667 const struct bt_hci_evt_le_cis_established *evt;
668 struct hci_conn *conn, *link;
670 evt = util_iov_pull_mem(iov, sizeof(*evt));
671 if (!evt || evt->status)
674 conn = conn_lookup_type(dev, le16_to_cpu(evt->conn_handle),
679 conn->setup_seen = true;
681 link = link_lookup(dev, conn->handle);
683 memcpy(conn->bdaddr, link->bdaddr, 6);
686 static void evt_le_cis_req(struct hci_dev *dev, struct timeval *tv,
689 const struct bt_hci_evt_le_cis_req *evt;
690 struct hci_conn *conn;
692 evt = util_iov_pull_mem(iov, sizeof(*evt));
696 conn = conn_lookup(dev, le16_to_cpu(evt->acl_handle));
700 conn->link = le16_to_cpu(evt->cis_handle);
703 static void evt_le_big_complete(struct hci_dev *dev, struct timeval *tv,
706 const struct bt_hci_evt_le_big_complete *evt;
709 evt = util_iov_pull_mem(iov, sizeof(*evt));
710 if (!evt || evt->status)
713 for (i = 0; i < evt->num_bis; i++) {
714 struct hci_conn *conn;
717 if (!util_iov_pull_le16(iov, &handle))
720 conn = conn_lookup_type(dev, handle, CONN_LE_ISO);
722 conn->setup_seen = true;
726 static void evt_le_big_sync_established(struct hci_dev *dev, struct timeval *tv,
729 const struct bt_hci_evt_le_big_sync_estabilished *evt;
732 evt = util_iov_pull_mem(iov, sizeof(*evt));
733 if (!evt || evt->status)
736 for (i = 0; i < evt->num_bis; i++) {
737 struct hci_conn *conn;
740 if (!util_iov_pull_le16(iov, &handle))
743 conn = conn_lookup_type(dev, handle, CONN_LE_ISO);
745 conn->setup_seen = true;
749 static void evt_le_meta_event(struct hci_dev *dev, struct timeval *tv,
750 const void *data, uint16_t size)
753 .iov_base = (void *)data,
758 if (!util_iov_pull_u8(&iov, &subevt))
762 case BT_HCI_EVT_LE_CONN_COMPLETE:
763 evt_le_conn_complete(dev, tv, &iov);
765 case BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE:
766 evt_le_enh_conn_complete(dev, tv, &iov);
768 case BT_HCI_EVT_LE_CIS_ESTABLISHED:
769 evt_le_cis_established(dev, tv, &iov);
771 case BT_HCI_EVT_LE_CIS_REQ:
772 evt_le_cis_req(dev, tv, &iov);
774 case BT_HCI_EVT_LE_BIG_COMPLETE:
775 evt_le_big_complete(dev, tv, &iov);
777 case BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED:
778 evt_le_big_sync_established(dev, tv, &iov);
783 static void event_pkt(struct timeval *tv, uint16_t index,
784 const void *data, uint16_t size)
786 const struct bt_hci_evt_hdr *hdr = data;
789 data += sizeof(*hdr);
790 size -= sizeof(*hdr);
792 dev = dev_lookup(index);
800 case BT_HCI_EVT_CONN_COMPLETE:
801 evt_conn_complete(dev, tv, data, size);
803 case BT_HCI_EVT_DISCONNECT_COMPLETE:
804 evt_disconnect_complete(dev, tv, data, size);
806 case BT_HCI_EVT_CMD_COMPLETE:
807 evt_cmd_complete(dev, tv, data, size);
809 case BT_HCI_EVT_NUM_COMPLETED_PACKETS:
810 evt_num_completed_packets(dev, tv, data, size);
812 case BT_HCI_EVT_SYNC_CONN_COMPLETE:
813 evt_sync_conn_complete(dev, tv, data, size);
815 case BT_HCI_EVT_LE_META_EVENT:
816 evt_le_meta_event(dev, tv, data, size);
821 static void stats_add(struct hci_stats *stats, uint16_t size)
824 stats->bytes += size;
826 if (!stats->min || size < stats->min)
828 if (!stats->max || size > stats->max)
832 static void conn_pkt_tx(struct hci_conn *conn, struct timeval *tv,
833 uint16_t size, struct l2cap_chan *chan)
835 struct hci_conn_tx *last_tx;
837 last_tx = new0(struct hci_conn_tx, 1);
838 memcpy(last_tx, tv, sizeof(*tv));
839 last_tx->chan = chan;
840 queue_push_tail(conn->tx_queue, last_tx);
842 stats_add(&conn->tx, size);
845 stats_add(&chan->tx, size);
848 static void conn_pkt_rx(struct hci_conn *conn, struct timeval *tv,
849 uint16_t size, struct l2cap_chan *chan)
853 if (timerisset(&conn->last_rx)) {
854 timersub(tv, &conn->last_rx, &res);
855 packet_latency_add(&conn->rx.latency, &res);
856 plot_add(conn->rx.plot, &res, 1);
861 stats_add(&conn->rx, size);
865 if (timerisset(&chan->last_rx)) {
866 timersub(tv, &chan->last_rx, &res);
867 packet_latency_add(&chan->rx.latency, &res);
868 plot_add(chan->rx.plot, &res, 1);
873 stats_add(&chan->rx, size);
878 static void acl_pkt(struct timeval *tv, uint16_t index, bool out,
879 const void *data, uint16_t size)
881 const struct bt_hci_acl_hdr *hdr = data;
883 struct hci_conn *conn;
884 struct l2cap_chan *chan = NULL;
887 data += sizeof(*hdr);
888 size -= sizeof(*hdr);
890 dev = dev_lookup(index);
897 conn = conn_lookup_type(dev, le16_to_cpu(hdr->handle) & 0x0fff, 0x00);
901 switch (le16_to_cpu(hdr->handle) >> 12) {
904 cid = get_le16(data + 2);
905 chan = chan_lookup(conn, cid, out);
907 l2cap_sig(conn, out, data + 4, size - 4);
912 conn_pkt_tx(conn, tv, size, chan);
914 conn_pkt_rx(conn, tv, size, chan);
918 static void sco_pkt(struct timeval *tv, uint16_t index, bool out,
919 const void *data, uint16_t size)
921 const struct bt_hci_acl_hdr *hdr = data;
923 struct hci_conn *conn;
925 dev = dev_lookup(index);
932 conn = conn_lookup_type(dev, le16_to_cpu(hdr->handle) & 0x0fff,
938 conn_pkt_tx(conn, tv, size - sizeof(*hdr), NULL);
940 conn_pkt_rx(conn, tv, size - sizeof(*hdr), NULL);
944 static void info_index(struct timeval *tv, uint16_t index,
945 const void *data, uint16_t size)
947 const struct btsnoop_opcode_index_info *hdr = data;
950 dev = dev_lookup(index);
954 dev->manufacturer = hdr->manufacturer;
957 static void vendor_diag(struct timeval *tv, uint16_t index,
958 const void *data, uint16_t size)
962 dev = dev_lookup(index);
969 static void system_note(struct timeval *tv, uint16_t index,
970 const void *data, uint16_t size)
974 dev = dev_lookup(index);
981 static void user_log(struct timeval *tv, uint16_t index,
982 const void *data, uint16_t size)
986 dev = dev_lookup(index);
993 static void ctrl_msg(struct timeval *tv, uint16_t index,
994 const void *data, uint16_t size)
998 dev = dev_lookup(index);
1005 static void iso_pkt(struct timeval *tv, uint16_t index, bool out,
1006 const void *data, uint16_t size)
1008 const struct bt_hci_iso_hdr *hdr = data;
1009 struct hci_conn *conn;
1010 struct hci_dev *dev;
1012 dev = dev_lookup(index);
1019 conn = conn_lookup_type(dev, le16_to_cpu(hdr->handle) & 0x0fff,
1025 conn_pkt_tx(conn, tv, size - sizeof(*hdr), NULL);
1027 conn_pkt_rx(conn, tv, size - sizeof(*hdr), NULL);
1031 static void unknown_opcode(struct timeval *tv, uint16_t index,
1032 const void *data, uint16_t size)
1034 struct hci_dev *dev;
1036 dev = dev_lookup(index);
1043 void analyze_trace(const char *path)
1045 struct btsnoop *btsnoop_file;
1046 unsigned long num_packets = 0;
1049 btsnoop_file = btsnoop_open(path, BTSNOOP_FLAG_PKLG_SUPPORT);
1053 format = btsnoop_get_format(btsnoop_file);
1056 case BTSNOOP_FORMAT_HCI:
1057 case BTSNOOP_FORMAT_UART:
1058 case BTSNOOP_FORMAT_MONITOR:
1061 fprintf(stderr, "Unsupported packet format\n");
1065 dev_list = queue_new();
1068 unsigned char buf[BTSNOOP_MAX_PACKET_SIZE];
1070 uint16_t index, opcode, pktlen;
1072 if (!btsnoop_read_hci(btsnoop_file, &tv, &index, &opcode,
1077 case BTSNOOP_OPCODE_NEW_INDEX:
1078 new_index(&tv, index, buf, pktlen);
1080 case BTSNOOP_OPCODE_DEL_INDEX:
1081 del_index(&tv, index, buf, pktlen);
1083 case BTSNOOP_OPCODE_COMMAND_PKT:
1084 command_pkt(&tv, index, buf, pktlen);
1086 case BTSNOOP_OPCODE_EVENT_PKT:
1087 event_pkt(&tv, index, buf, pktlen);
1089 case BTSNOOP_OPCODE_ACL_TX_PKT:
1090 acl_pkt(&tv, index, true, buf, pktlen);
1092 case BTSNOOP_OPCODE_ACL_RX_PKT:
1093 acl_pkt(&tv, index, false, buf, pktlen);
1095 case BTSNOOP_OPCODE_SCO_TX_PKT:
1096 sco_pkt(&tv, index, true, buf, pktlen);
1098 case BTSNOOP_OPCODE_SCO_RX_PKT:
1099 sco_pkt(&tv, index, false, buf, pktlen);
1101 case BTSNOOP_OPCODE_OPEN_INDEX:
1102 case BTSNOOP_OPCODE_CLOSE_INDEX:
1104 case BTSNOOP_OPCODE_INDEX_INFO:
1105 info_index(&tv, index, buf, pktlen);
1107 case BTSNOOP_OPCODE_VENDOR_DIAG:
1108 vendor_diag(&tv, index, buf, pktlen);
1110 case BTSNOOP_OPCODE_SYSTEM_NOTE:
1111 system_note(&tv, index, buf, pktlen);
1113 case BTSNOOP_OPCODE_USER_LOGGING:
1114 user_log(&tv, index, buf, pktlen);
1116 case BTSNOOP_OPCODE_CTRL_OPEN:
1117 case BTSNOOP_OPCODE_CTRL_CLOSE:
1118 case BTSNOOP_OPCODE_CTRL_COMMAND:
1119 case BTSNOOP_OPCODE_CTRL_EVENT:
1120 ctrl_msg(&tv, index, buf, pktlen);
1122 case BTSNOOP_OPCODE_ISO_TX_PKT:
1123 iso_pkt(&tv, index, true, buf, pktlen);
1125 case BTSNOOP_OPCODE_ISO_RX_PKT:
1126 iso_pkt(&tv, index, false, buf, pktlen);
1129 unknown_opcode(&tv, index, buf, pktlen);
1136 printf("Trace contains %lu packets\n\n", num_packets);
1138 queue_destroy(dev_list, dev_destroy);
1141 btsnoop_unref(btsnoop_file);