From cba48786c0940fd6a5438d8436346a5e0bb5d49b Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 9 Oct 2015 13:39:00 -0700 Subject: [PATCH] monitor: Add support for decoding Intel LMP / LL traces --- Makefile.tools | 1 + android/Android.mk | 1 + monitor/intel.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++ monitor/intel.h | 27 ++++++++++++++ monitor/packet.c | 10 +++++- 5 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 monitor/intel.c create mode 100644 monitor/intel.h diff --git a/Makefile.tools b/Makefile.tools index 249b2949f..d849bd94e 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -33,6 +33,7 @@ monitor_btmon_SOURCES = monitor/main.c monitor/bt.h \ monitor/hwdb.h monitor/hwdb.c \ monitor/keys.h monitor/keys.c \ monitor/analyze.h monitor/analyze.c \ + monitor/intel.h monitor/intel.c \ monitor/broadcom.h monitor/broadcom.c monitor_btmon_LDADD = lib/libbluetooth-internal.la \ src/libshared-mainloop.la @UDEV_LIBS@ diff --git a/android/Android.mk b/android/Android.mk index d50fd2327..89ca2c268 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/intel.c \ bluez/monitor/broadcom.c \ bluez/src/shared/util.c \ bluez/src/shared/queue.c \ diff --git a/monitor/intel.c b/monitor/intel.c new file mode 100644 index 000000000..1013246ed --- /dev/null +++ b/monitor/intel.c @@ -0,0 +1,87 @@ +/* + * + * 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 "intel.h" + +void intel_vendor_event(const void *data, uint8_t size) +{ + uint8_t evt, type, len; + + evt = *((uint8_t *) data); + + print_field("Event: 0x%2.2x", evt); + + switch (evt) { + case 0x17: + type = *((uint8_t *) (data + 1)); + + switch (type) { + case 0x00: + len = size - 9; + print_field("Type: RX LMP (0x%2.2x)", type); + packet_hexdump(data + 2, 3); + lmp_packet(data + 5, len, false); + packet_hexdump(data + 5 + len, size - 5 - len); + break; + case 0x01: + len = size - 10; + print_field("Type: TX LMP (0x%2.2x)", type); + packet_hexdump(data + 2, 3); + lmp_packet(data + 5, len, false); + packet_hexdump(data + 5 + len, size - 5 - len); + break; + case 0x03: + len = size - 9; + print_field("Type: RX LL (0x%2.2x)", type); + packet_hexdump(data + 2, 7); + llcp_packet(data + 9, len, false); + break; + case 0x04: + len = size - 9; + print_field("Type: TX LL (0x%2.2x)", type); + packet_hexdump(data + 2, 7); + llcp_packet(data + 9, len, false); + break; + default: + print_field("Type: 0x%2.2x", type); + packet_hexdump(data + 2, size - 2); + break; + } + break; + default: + packet_hexdump(data + 1, size - 1); + break; + } +} diff --git a/monitor/intel.h b/monitor/intel.h new file mode 100644 index 000000000..828d855b8 --- /dev/null +++ b/monitor/intel.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 intel_vendor_event(const void *data, uint8_t size); diff --git a/monitor/packet.c b/monitor/packet.c index cdd0b87ca..2e82cfacc 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -52,6 +52,7 @@ #include "l2cap.h" #include "control.h" #include "vendor.h" +#include "intel.h" #include "broadcom.h" #include "packet.h" @@ -8324,7 +8325,14 @@ static void vendor_evt(const void *data, uint8_t size) else manufacturer = UNKNOWN_MANUFACTURER; - vendor_event(manufacturer, data, size); + switch (manufacturer) { + case 2: + intel_vendor_event(data, size); + break; + default: + vendor_event(manufacturer, data, size); + break; + } } struct event_data { -- 2.47.3