From 90799f6da988723a7d100610f51f2b7f30f40d4f Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 7 Oct 2015 22:42:29 +0200 Subject: [PATCH] monitor: Add support for Broadcom diagnostic channel decoding --- Makefile.tools | 3 +- android/Android.mk | 1 + monitor/broadcom.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++ monitor/broadcom.h | 27 +++++++++++++ monitor/packet.c | 11 +++++- 5 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 monitor/broadcom.c create mode 100644 monitor/broadcom.h diff --git a/Makefile.tools b/Makefile.tools index 330cc6b2d..249b2949f 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -32,7 +32,8 @@ monitor_btmon_SOURCES = monitor/main.c monitor/bt.h \ monitor/uuid.h monitor/uuid.c \ monitor/hwdb.h monitor/hwdb.c \ monitor/keys.h monitor/keys.c \ - monitor/analyze.h monitor/analyze.c + monitor/analyze.h monitor/analyze.c \ + monitor/broadcom.h monitor/broadcom.c monitor_btmon_LDADD = lib/libbluetooth-internal.la \ src/libshared-mainloop.la @UDEV_LIBS@ endif diff --git a/android/Android.mk b/android/Android.mk index 33f5e0748..d50fd2327 100644 --- a/android/Android.mk +++ b/android/Android.mk @@ -351,6 +351,7 @@ LOCAL_SRC_FILES := \ bluez/monitor/keys.c \ bluez/monitor/ellisys.c \ bluez/monitor/analyze.c \ + bluez/monitor/broadcom.c \ bluez/src/shared/util.c \ bluez/src/shared/queue.c \ bluez/src/shared/crypto.c \ diff --git a/monitor/broadcom.c b/monitor/broadcom.c new file mode 100644 index 000000000..b9c70b4bb --- /dev/null +++ b/monitor/broadcom.c @@ -0,0 +1,98 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2011-2014 Intel Corporation + * Copyright (C) 2002-2010 Marcel Holtmann + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "src/shared/util.h" +#include "display.h" +#include "packet.h" +#include "lmp.h" +#include "ll.h" +#include "broadcom.h" + +void broadcom_lm_diag(const void *data, uint8_t size) +{ + uint8_t type; + uint32_t clock; + const uint8_t *addr; + const char *str; + + if (size != 63) { + packet_hexdump(data, size); + return; + } + + type = *((uint8_t *) data); + clock = get_be32(data + 1); + + switch (type) { + case 0x00: + str = "LMP sent"; + break; + case 0x01: + str = "LMP receive"; + break; + case 0x80: + str = "LL sent"; + break; + case 0x81: + str = "LL receive"; + break; + default: + str = "Unknown"; + break; + } + + print_field("Type: %s (%u)", str, type); + print_field("Clock: 0x%8.8x", clock); + + switch (type) { + case 0x00: + addr = data + 5; + print_field("Address: --:--:%2.2X:%2.2X:%2.2X:%2.2X", + addr[0], addr[1], addr[2], addr[3]); + packet_hexdump(data + 9, 1); + lmp_packet(data + 10, size - 10, true); + break; + case 0x01: + addr = data + 5; + print_field("Address: --:--:%2.2X:%2.2X:%2.2X:%2.2X", + addr[0], addr[1], addr[2], addr[3]); + packet_hexdump(data + 9, 4); + lmp_packet(data + 13, size - 13, true); + break; + case 0x80: + case 0x81: + packet_hexdump(data + 5, 7); + llcp_packet(data + 12, size - 12, true); + break; + default: + packet_hexdump(data + 9, size - 9); + break; + } +} diff --git a/monitor/broadcom.h b/monitor/broadcom.h new file mode 100644 index 000000000..2aec9128f --- /dev/null +++ b/monitor/broadcom.h @@ -0,0 +1,27 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2011-2014 Intel Corporation + * Copyright (C) 2002-2010 Marcel Holtmann + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include + +void broadcom_lm_diag(const void *data, uint8_t size); diff --git a/monitor/packet.c b/monitor/packet.c index f8bde976a..264662791 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -52,6 +52,7 @@ #include "l2cap.h" #include "control.h" #include "vendor.h" +#include "broadcom.h" #include "packet.h" #define COLOR_INDEX_LABEL COLOR_WHITE @@ -8535,7 +8536,15 @@ void packet_vendor_diag(struct timeval *tv, uint16_t index, print_packet(tv, index, '=', COLOR_VENDOR_DIAG, "Vendor Diagnostic", NULL, extra_str); - packet_hexdump(data, size); + + switch (manufacturer) { + case 15: + broadcom_lm_diag(data, size); + break; + default: + packet_hexdump(data, size); + break; + } } void packet_hci_command(struct timeval *tv, uint16_t index, -- 2.47.3