From 0de52f95ec9b9512165174c7f4b2c5fe84c33dc0 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 2 Nov 2012 20:23:59 +0100 Subject: [PATCH] monitor: Read logs with data link type 1002 --- monitor/btsnoop.c | 17 ++++++++++++++++- monitor/packet.c | 32 +++++++++++++++++++++++++------- monitor/packet.h | 2 +- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/monitor/btsnoop.c b/monitor/btsnoop.c index c07eb2d7e..0b3e4125a 100644 --- a/monitor/btsnoop.c +++ b/monitor/btsnoop.c @@ -207,6 +207,7 @@ int btsnoop_read(struct timeval *tv, uint16_t *index, uint16_t *opcode, struct btsnoop_pkt pkt; uint32_t toread, flags; uint64_t ts; + uint8_t pkt_type; ssize_t len; if (btsnoop_fd < 0) @@ -233,7 +234,21 @@ int btsnoop_read(struct timeval *tv, uint16_t *index, uint16_t *opcode, switch (btsnoop_type) { case 1001: *index = 0; - *opcode = packet_get_opcode(flags); + *opcode = packet_get_opcode(0xff, flags); + break; + + case 1002: + len = read(btsnoop_fd, &pkt_type, 1); + if (len < 0) { + perror("Failed to read packet type"); + close(btsnoop_fd); + btsnoop_fd = -1; + return -1; + } + toread--; + + *index = 0; + *opcode = packet_get_opcode(pkt_type, flags); break; case 2001: diff --git a/monitor/packet.c b/monitor/packet.c index eb1387ea5..0c4d360ad 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -867,18 +867,36 @@ uint32_t packet_get_flags(uint16_t opcode) return 0xff; } -uint16_t packet_get_opcode(uint32_t flags) +uint16_t packet_get_opcode(uint8_t type, uint32_t flags) { - if (flags & 0x02) { - if (flags & 0x01) - return MONITOR_EVENT_PKT; - else - return MONITOR_COMMAND_PKT; - } else { + switch (type) { + case HCI_COMMAND_PKT: + return MONITOR_COMMAND_PKT; + case HCI_ACLDATA_PKT: if (flags & 0x01) return MONITOR_ACL_RX_PKT; else return MONITOR_ACL_TX_PKT; + case HCI_SCODATA_PKT: + if (flags & 0x01) + return MONITOR_SCO_RX_PKT; + else + return MONITOR_SCO_TX_PKT; + case HCI_EVENT_PKT: + return MONITOR_EVENT_PKT; + case 0xff: + if (flags & 0x02) { + if (flags & 0x01) + return MONITOR_EVENT_PKT; + else + return MONITOR_COMMAND_PKT; + } else { + if (flags & 0x01) + return MONITOR_ACL_RX_PKT; + else + return MONITOR_ACL_TX_PKT; + } + break; } return 0xff; diff --git a/monitor/packet.h b/monitor/packet.h index dd2f5e3c6..ea21bd7f6 100644 --- a/monitor/packet.h +++ b/monitor/packet.h @@ -42,7 +42,7 @@ void packet_monitor(struct timeval *tv, uint16_t index, uint16_t opcode, const void *data, uint16_t size); uint32_t packet_get_flags(uint16_t opcode); -uint16_t packet_get_opcode(uint32_t flags); +uint16_t packet_get_opcode(uint8_t type, uint32_t flags); void packet_new_index(struct timeval *tv, uint16_t index, const char *label, uint8_t type, uint8_t bus, const char *name); -- 2.47.3