From f5cd21543d332f6c14da88ebd50730750f791dd4 Mon Sep 17 00:00:00 2001 From: Michal Labedzki Date: Fri, 12 Dec 2014 11:24:44 +0100 Subject: Bluetooth: Add generic Bluetooth dissector Bluetooth dissector is used to add ability to filter all bluetooth payload from capture files (there are many transport like: hci_h4, hci_h1, hci_usb, hci_mon, btle). Also it is used to placeholder for all data tree used to store additional informations like bd_addrs, names, etc. Finally it is used to be one point for Bluetooth Endpoints/Conversation filtering what is enabled now. Also add Master/Slave Role and Connection Mode tracking. Change-Id: I67048080fb8ee16fa0f4ec429c1257de81ddd737 Reviewed-on: https://code.wireshark.org/review/5771 Petri-Dish: Michal Labedzki Tested-by: Petri Dish Buildbot Reviewed-by: Alexis La Goutte Reviewed-by: Michal Labedzki --- epan/CMakeLists.txt | 1 + epan/dissectors/Makefile.common | 4 +- epan/dissectors/packet-bluetooth-hci.h | 162 ------ epan/dissectors/packet-bluetooth.c | 951 +++++++++++++++++++++++++++++++++ epan/dissectors/packet-bluetooth.h | 202 +++++++ epan/dissectors/packet-btatt.c | 10 +- epan/dissectors/packet-btavctp.c | 4 +- epan/dissectors/packet-btavdtp.c | 11 +- epan/dissectors/packet-btbnep.c | 10 +- epan/dissectors/packet-bthci_acl.c | 141 ++++- epan/dissectors/packet-bthci_cmd.c | 547 +++++-------------- epan/dissectors/packet-bthci_evt.c | 554 +++++++++---------- epan/dissectors/packet-bthci_sco.c | 62 ++- epan/dissectors/packet-btl2cap.c | 16 +- epan/dissectors/packet-btle.c | 260 +++++++-- epan/dissectors/packet-btle.h | 7 + epan/dissectors/packet-btle_rf.c | 8 +- epan/dissectors/packet-btobex.c | 4 +- epan/dissectors/packet-btrfcomm.c | 8 +- epan/dissectors/packet-btsdp.c | 14 +- epan/dissectors/packet-hci_h1.c | 50 +- epan/dissectors/packet-hci_h4.c | 68 +-- epan/dissectors/packet-hci_mon.c | 54 +- epan/dissectors/packet-hci_usb.c | 83 +-- epan/dissectors/packet-packetlogger.c | 27 +- epan/dissectors/packet-ubertooth.c | 29 +- epan/dissectors/packet-ubertooth.h | 51 ++ epan/dissectors/packet-usb.c | 6 +- 28 files changed, 2129 insertions(+), 1215 deletions(-) delete mode 100644 epan/dissectors/packet-bluetooth-hci.h create mode 100644 epan/dissectors/packet-bluetooth.c create mode 100644 epan/dissectors/packet-bluetooth.h create mode 100644 epan/dissectors/packet-ubertooth.h (limited to 'epan') diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt index 294570549a..6a216d8554 100644 --- a/epan/CMakeLists.txt +++ b/epan/CMakeLists.txt @@ -408,6 +408,7 @@ set(DISSECTOR_SRC dissectors/packet-bitcoin.c dissectors/packet-bittorrent.c dissectors/packet-bjnp.c + dissectors/packet-bluetooth.c dissectors/packet-bmc.c dissectors/packet-bofl.c dissectors/packet-bootp.c diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common index 500345e23a..9c45b02837 100644 --- a/epan/dissectors/Makefile.common +++ b/epan/dissectors/Makefile.common @@ -323,6 +323,7 @@ DISSECTOR_SRC = \ packet-bitcoin.c \ packet-bittorrent.c \ packet-bjnp.c \ + packet-bluetooth.c \ packet-bmc.c \ packet-bofl.c \ packet-bootp.c \ @@ -1380,7 +1381,7 @@ DISSECTOR_INCLUDES = \ packet-bacapp.h \ packet-ber.h \ packet-bfd.h \ - packet-bluetooth-hci.h \ + packet-bluetooth.h \ packet-bpq.h \ packet-bssap.h \ packet-bssgp.h \ @@ -1682,6 +1683,7 @@ DISSECTOR_INCLUDES = \ packet-tte.h \ packet-ua.h \ packet-uaudp.h \ + packet-ubertooth.h \ packet-udp.h \ packet-umts_fp.h \ packet-umts_mac.h \ diff --git a/epan/dissectors/packet-bluetooth-hci.h b/epan/dissectors/packet-bluetooth-hci.h deleted file mode 100644 index 4d9f18541e..0000000000 --- a/epan/dissectors/packet-bluetooth-hci.h +++ /dev/null @@ -1,162 +0,0 @@ -/* packet-bluetooth-hci.h - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PACKET_BLUETOOTH_HCI_H__ -#define __PACKET_BLUETOOTH_HCI_H__ - -#include - -#define HCI_H4_TYPE_CMD 0x01 -#define HCI_H4_TYPE_ACL 0x02 -#define HCI_H4_TYPE_SCO 0x03 -#define HCI_H4_TYPE_EVT 0x04 - -#define HCI_OGF_LINK_CONTROL 0x01 -#define HCI_OGF_LINK_POLICY 0x02 -#define HCI_OGF_HOST_CONTROLLER 0x03 -#define HCI_OGF_INFORMATIONAL 0x04 -#define HCI_OGF_STATUS 0x05 -#define HCI_OGF_TESTING 0x06 -#define HCI_OGF_LOW_ENERGY 0x08 -#define HCI_OGF_LOGO_TESTING 0x3e -#define HCI_OGF_VENDOR_SPECIFIC 0x3f - -#define HCI_VENDOR_DEFAULT 0 - -#define DID_VENDOR_ID_SOURCE_BLUETOOTH_SIG 1 -#define DID_VENDOR_ID_SOURCE_USB_FORUM 2 - -#define ACCESS_ADDRESS_ADVERTISING 0x8e89bed6 - -extern value_string_ext bthci_cmd_opcode_vals_ext; -extern value_string_ext bthci_ogf_vals_ext; -extern value_string_ext bthci_cmd_ocf_link_control_vals_ext; -extern value_string_ext bthci_cmd_ocf_link_policy_vals_ext; -extern value_string_ext bthci_cmd_ocf_host_controller_and_baseband_vals_ext; -extern value_string_ext bthci_cmd_ocf_informational_vals_ext; -extern value_string_ext bthci_cmd_ocf_status_vals_ext; -extern value_string_ext bthci_cmd_ocf_testing_vals_ext; -extern value_string_ext bthci_cmd_ocf_low_energy_vals_ext; - -extern value_string_ext bthci_cmd_input_coding_vals_ext; -extern value_string_ext bthci_cmd_input_data_format_vals_ext; -extern value_string_ext bthci_cmd_input_sample_size_vals_ext; -extern value_string_ext bthci_cmd_air_coding_format_vals_ext; -extern value_string_ext bthci_cmd_status_vals_ext; -extern value_string_ext bthci_cmd_eir_data_type_vals_ext; -extern value_string_ext bthci_cmd_auth_req_vals_ext; -extern value_string_ext bthci_cmd_appearance_vals_ext; -extern value_string_ext bthci_evt_comp_id_ext; - -extern value_string_ext bt_sig_uuid_vals_ext; - -extern const value_string bthci_cmd_io_capability_vals[]; -extern const value_string bthci_cmd_oob_data_present_vals[]; -extern const value_string bthci_cmd_address_types_vals[]; -extern const value_string bthci_cmd_scan_enable_values[]; -extern const value_string bthci_cmd_page_scan_modes[]; -extern const value_string bthci_cmd_page_scan_repetition_modes[]; -extern const value_string bthci_cmd_page_scan_period_modes[]; -extern const value_string bthci_cmd_notification_types[]; - - -/* We support Bluetooth over various interfaces, interface_id and adapter_id - is used to decode further payload. Case: there is a host. Host has X - interfaces. Each interface has Y adapter. Each adapter has ACL handle or - L2CAP CID. ACL handle has L2CAP CID and/or L2CAP PSM. L2CAP CID or - L2CAP PSM has RFCOMM channel or other end-protocol like OBEX, AVRCP, HID, - AVDTP, BNEP etc. RFCOMM channel has end-protocol like OBEX, HFP, etc. - Important note: correct payload decoding should store needed data using - key contain interface_id, adapter_id, ..., last_channel_type (for example - RFCOMM channel, transaction_id, frame number etc. ) - - interface_id - interface id provided by Wireshark, see "frame.interface_id", - in case where is only one interface id HCI_INTERFACE_DEFAULT - is used (for example open BTSNOOP file with HCI H4 protocol) - adapter_id - identified Bluetooth device (interface, for example Linux - hci0, hci1, etc.) -*/ -#define HCI_INTERFACE_DEFAULT 0 -#define HCI_ADAPTER_DEFAULT 0 - -/* chandle_to_bdaddr_table: interface_id + adapter_id + connection_handle + frame_number -> bd_addr[6] */ -/* bdaddr_to_name_table: bd_addr[6] + frame_number -> name */ -/* localhost_bdaddr: interface_id + adapter_id + frame_number -> bd_addr[6] */ -/* localhost_name: interface_id + adapter_id + frame_number -> name */ -typedef struct _hci_data_t { - guint32 interface_id; - guint32 adapter_id; - guint32 *adapter_disconnect_in_frame; - wmem_tree_t *chandle_sessions; - wmem_tree_t *chandle_to_bdaddr_table; - wmem_tree_t *bdaddr_to_name_table; - wmem_tree_t *localhost_bdaddr; - wmem_tree_t *localhost_name; -} hci_data_t; - -typedef struct _chandle_session_t { - guint32 connect_in_frame; - guint32 disconnect_in_frame; -} chandle_session_t; - -typedef struct _remote_bdaddr_t { - guint32 interface_id; - guint32 adapter_id; - guint16 chandle; - guint8 bd_addr[6]; -} remote_bdaddr_t; - -typedef struct _device_name_t { - guint32 bd_addr_oui; - guint32 bd_addr_id; - gchar *name; -} device_name_t; - -typedef struct _localhost_bdaddr_entry_t { - guint32 interface_id; - guint32 adapter_id; - guint8 bd_addr[6]; -} localhost_bdaddr_entry_t; - -typedef struct _localhost_name_entry_t { - guint32 interface_id; - guint32 adapter_id; - gchar *name; -} localhost_name_entry_t; - -/* In "packet-btle.c" */ -extern gint dissect_bd_addr(gint hf_bd_addr, proto_tree *tree, tvbuff_t *tvb, - gint offset, guint8 *bdaddr); - -#endif - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 4 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * vi: set shiftwidth=4 tabstop=8 expandtab: - * :indentSize=4:tabSize=8:noTabs=true: - */ diff --git a/epan/dissectors/packet-bluetooth.c b/epan/dissectors/packet-bluetooth.c new file mode 100644 index 0000000000..d62f61ecaa --- /dev/null +++ b/epan/dissectors/packet-bluetooth.c @@ -0,0 +1,951 @@ +/* packet-bluetooth.c + * Routines for the Bluetooth + * + * Copyright 2014, Michal Labedzki for Tieto Corporation + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" + +#include +#include +#include +#include +#include + +#include "packet-bluetooth.h" + +int proto_bluetooth = -1; +static int proto_ubertooth = -1; + +static int hf_bluetooth_src = -1; +static int hf_bluetooth_dst = -1; +static int hf_bluetooth_addr = -1; +static int hf_bluetooth_str_src = -1; +static int hf_bluetooth_str_dst = -1; +static int hf_bluetooth_str_addr = -1; + +static gint ett_bluetooth = -1; + +static dissector_handle_t bluetooth_handle; +static dissector_handle_t btle_handle; +static dissector_handle_t data_handle; + +static dissector_table_t bluetooth_table; + +static wmem_tree_t *chandle_sessions = NULL; +static wmem_tree_t *chandle_to_bdaddr = NULL; +static wmem_tree_t *chandle_to_mode = NULL; +static wmem_tree_t *bdaddr_to_name = NULL; +static wmem_tree_t *bdaddr_to_role = NULL; +static wmem_tree_t *localhost_name = NULL; +static wmem_tree_t *localhost_bdaddr = NULL; + +static int bluetooth_tap = -1; + +static const value_string bluetooth_type_vals[] = { + {HCI_H4_TYPE_CMD, "HCI Command"}, + {HCI_H4_TYPE_ACL, "ACL Data"}, + {HCI_H4_TYPE_SCO, "SCO Data"}, + {HCI_H4_TYPE_EVT, "HCI Event"}, + {0, NULL } +}; +static const value_string bluetooth_direction_vals[] = { + {P2P_DIR_SENT, "Sent"}, + {P2P_DIR_RECV, "Rcvd"}, + {P2P_DIR_UNKNOWN, "Unspecified"}, + {0, NULL} +}; + +static const value_string bluetooth_uuid_vals[] = { + /* Protocol Identifiers - https://www.bluetooth.org/en-us/specification/assigned-numbers/service-discovery */ + { 0x0001, "SDP" }, + { 0x0002, "UDP" }, + { 0x0003, "RFCOMM" }, + { 0x0004, "TCP" }, + { 0x0005, "TCS-BIN" }, + { 0x0006, "TCS-AT" }, + { 0x0007, "ATT" }, + { 0x0008, "OBEX" }, + { 0x0009, "IP" }, + { 0x000A, "FTP" }, + { 0x000C, "HTTP" }, + { 0x000E, "WSP" }, + { 0x000F, "BNEP" }, + { 0x0010, "UPNP" }, + { 0x0011, "HIDP" }, + { 0x0012, "Hardcopy Control Channel" }, + { 0x0014, "Hardcopy Data Channel" }, + { 0x0016, "Hardcopy Notification" }, + { 0x0017, "AVCTP" }, + { 0x0019, "AVDTP" }, + { 0x001B, "CMPT" }, + { 0x001D, "UDI C-Plane" }, /* unofficial */ + { 0x001E, "MCAP Control Channel" }, + { 0x001F, "MCAP Data Channel" }, + { 0x0100, "L2CAP" }, + /* Traditional Services - https://www.bluetooth.org/en-us/specification/assigned-numbers/service-discovery */ + { 0x1000, "Service Discovery Server Service Class ID" }, + { 0x1001, "Browse Group Descriptor Service Class ID" }, + { 0x1002, "Public Browse Group" }, + { 0x1101, "Serial Port" }, + { 0x1102, "LAN Access Using PPP" }, + { 0x1103, "Dialup Networking" }, + { 0x1104, "IrMC Sync" }, + { 0x1105, "OBEX Object Push" }, + { 0x1106, "OBEX File Transfer" }, + { 0x1107, "IrMC Sync Command" }, + { 0x1108, "Headset" }, + { 0x1109, "Cordless Telephony" }, + { 0x110A, "Audio Source" }, + { 0x110B, "Audio Sink" }, + { 0x110C, "A/V Remote Control Target" }, + { 0x110D, "Advanced Audio Distribution" }, + { 0x110E, "A/V Remote Control" }, + { 0x110F, "A/V Remote Control Controller" }, + { 0x1110, "Intercom" }, + { 0x1111, "Fax" }, + { 0x1112, "Headset Audio Gateway" }, + { 0x1113, "WAP" }, + { 0x1114, "WAP Client" }, + { 0x1115, "PANU" }, + { 0x1116, "NAP" }, + { 0x1117, "GN" }, + { 0x1118, "Direct Printing" }, + { 0x1119, "Reference Printing" }, + { 0x111A, "Imaging" }, + { 0x111B, "Imaging Responder" }, + { 0x111C, "Imaging Automatic Archive" }, + { 0x111D, "Imaging Referenced Objects" }, + { 0x111E, "Handsfree" }, + { 0x111F, "Handsfree Audio Gateway" }, + { 0x1120, "Direct Printing Reference Objects Service" }, + { 0x1121, "Reflected UI" }, + { 0x1122, "Basic Printing" }, + { 0x1123, "Printing Status" }, + { 0x1124, "Human Interface Device Service" }, + { 0x1125, "Hardcopy Cable Replacement" }, + { 0x1126, "HCR Print" }, + { 0x1127, "HCR Scan" }, + { 0x1128, "Common ISDN Access" }, + { 0x1129, "Video Conferencing GW" }, + { 0x112A, "UDI MT" }, + { 0x112B, "UDI TA" }, + { 0x112C, "Audio/Video" }, + { 0x112D, "SIM Access" }, + { 0x112E, "Phonebook Access Client" }, + { 0x112F, "Phonebook Access Server" }, + { 0x1130, "Phonebook Access Profile" }, + { 0x1131, "Headset HS" }, + { 0x1132, "Message Access Server" }, + { 0x1133, "Message Notification Server" }, + { 0x1134, "Message Access Profile" }, + { 0x1135, "Global Navigation Satellite System" }, + { 0x1136, "Global Navigation Satellite System Server" }, + { 0x1137, "3D Display" }, + { 0x1138, "3D Glasses" }, + { 0x1139, "3D Synchronization Profile" }, + { 0x113A, "Multi-Profile" }, + { 0x113B, "Multi-Profile SC" }, + { 0x1200, "PnP Information" }, + { 0x1201, "Generic Networking" }, + { 0x1202, "Generic File Transfer" }, + { 0x1203, "Generic Audio" }, + { 0x1204, "Generic Telephony" }, + { 0x1205, "UPNP Service" }, + { 0x1206, "UPNP IP Service" }, + { 0x1300, "ESDP UPNP_IP PAN" }, + { 0x1301, "ESDP UPNP IP LAP" }, + { 0x1302, "ESDP UPNP L2CAP" }, + { 0x1303, "Video Source" }, + { 0x1304, "Video Sink" }, + { 0x1305, "Video Distribution" }, + { 0x1400, "Health Device Profile" }, + { 0x1401, "Health Device Source" }, + { 0x1402, "Health Device Sink" }, + /* LE Services - https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx */ + { 0x1800, "Generic Access Profile" }, + { 0x1801, "Generic Attribute Profile" }, + { 0x1802, "Immediate Alert" }, + { 0x1803, "Link Loss" }, + { 0x1804, "Tx Power" }, + { 0x1805, "Current Time Service" }, + { 0x1806, "Reference Time Update Service" }, + { 0x1807, "Next DST Change Service" }, + { 0x1808, "Glucose" }, + { 0x1809, "Health Thermometer" }, + { 0x180A, "Device Information" }, + { 0x180D, "Heart Rate" }, + { 0x180E, "Phone Alert Status Service" }, + { 0x180F, "Battery Service" }, + { 0x1810, "Blood Pressure" }, + { 0x1811, "Alert Notification Service" }, + { 0x1812, "Human Interface Device" }, + { 0x1813, "Scan Parameters" }, + { 0x1814, "Running Speed and Cadence" }, + { 0x1816, "Cycling Speed and Cadence" }, + { 0x1818, "Cycling Power" }, + { 0x1819, "Location and Navigation" }, + /* Units - http://developer.bluetooth.org/gatt/declarations/Pages/DeclarationsHome.aspx */ + { 0x2700, "unitless" }, + { 0x2701, "length (metre)" }, + { 0x2702, "mass (kilogram)" }, + { 0x2703, "time (second)" }, + { 0x2704, "electric current (ampere)" }, + { 0x2705, "thermodynamic temperature (kelvin)" }, + { 0x2706, "amount of substance (mole)" }, + { 0x2707, "luminous intensity (candela)" }, + { 0x2710, "area (square metres)" }, + { 0x2711, "volume (cubic metres)" }, + { 0x2712, "velocity (metres per second)" }, + { 0x2713, "acceleration (metres per second squared)" }, + { 0x2714, "wavenumber (reciprocal metre)" }, + { 0x2715, "density (kilogram per cubic metre)" }, + { 0x2716, "surface density (kilogram per square metre)" }, + { 0x2717, "specific volume (cubic metre per kilogram)" }, + { 0x2718, "current density (ampere per square metre)" }, + { 0x2719, "magnetic field strength (ampere per metre)" }, + { 0x271A, "amount concentration (mole per cubic metre)" }, + { 0x271B, "mass concentration (kilogram per cubic metre)" }, + { 0x271C, "luminance (candela per square metre)" }, + { 0x271D, "refractive index" }, + { 0x271E, "relative permeability" }, + { 0x2720, "plane angle (radian)" }, + { 0x2721, "solid angle (steradian)" }, + { 0x2722, "frequency (hertz)" }, + { 0x2723, "force (newton)" }, + { 0x2724, "pressure (pascal)" }, + { 0x2725, "energy (joule)" }, + { 0x2726, "power (watt)" }, + { 0x2727, "electric charge (coulomb)" }, + { 0x2728, "electric potential difference (volt)" }, + { 0x2729, "capacitance (farad)" }, + { 0x272A, "electric resistance (ohm)" }, + { 0x272B, "electric conductance (siemens)" }, + { 0x272C, "magnetic flex (weber)" }, + { 0x272D, "magnetic flex density (tesla)" }, + { 0x272E, "inductance (henry)" }, + { 0x272F, "Celsius temperature (degree Celsius)" }, + { 0x2730, "luminous flux (lumen)" }, + { 0x2731, "illuminance (lux)" }, + { 0x2732, "activity referred to a radionuclide (becquerel)" }, + { 0x2733, "absorbed dose (gray)" }, + { 0x2734, "dose equivalent (sievert)" }, + { 0x2735, "catalytic activity (katal)" }, + { 0x2740, "dynamic viscosity (pascal second)" }, + { 0x2741, "moment of force (newton metre)" }, + { 0x2742, "surface tension (newton per metre)" }, + { 0x2743, "angular velocity (radian per second)" }, + { 0x2744, "angular acceleration (radian per second squared)" }, + { 0x2745, "heat flux density (watt per square metre)" }, + { 0x2746, "heat capacity (joule per kelvin)" }, + { 0x2747, "specific heat capacity (joule per kilogram kelvin)" }, + { 0x2748, "specific energy (joule per kilogram)" }, + { 0x2749, "thermal conductivity (watt per metre kelvin)" }, + { 0x274A, "energy density (joule per cubic metre)" }, + { 0x274B, "electric field strength (volt per metre)" }, + { 0x274C, "electric charge density (coulomb per cubic metre)" }, + { 0x274D, "surface charge density (coulomb per square metre)" }, + { 0x274E, "electric flux density (coulomb per square metre)" }, + { 0x274F, "permittivity (farad per metre)" }, + { 0x2750, "permeability (henry per metre)" }, + { 0x2751, "molar energy (joule per mole)" }, + { 0x2752, "molar entropy (joule per mole kelvin)" }, + { 0x2753, "exposure (coulomb per kilogram)" }, + { 0x2754, "absorbed dose rate (gray per second)" }, + { 0x2755, "radiant intensity (watt per steradian)" }, + { 0x2756, "radiance (watt per square metre steradian)" }, + { 0x2757, "catalytic activity concentration (katal per cubic metre)" }, + { 0x2760, "time (minute)" }, + { 0x2761, "time (hour)" }, + { 0x2762, "time (day)" }, + { 0x2763, "plane angle (degree)" }, + { 0x2764, "plane angle (minute)" }, + { 0x2765, "plane angle (second)" }, + { 0x2766, "area (hectare)" }, + { 0x2767, "volume (litre)" }, + { 0x2768, "mass (tonne)" }, + { 0x2780, "pressure (bar)" }, + { 0x2781, "pressure (millimetre of mercury)" }, + { 0x2782, "length (angstrom)" }, + { 0x2783, "length (nautical mile)" }, + { 0x2784, "area (barn)" }, + { 0x2785, "velocity (knot)" }, + { 0x2786, "logarithmic radio quantity (neper)" }, + { 0x2787, "logarithmic radio quantity (bel)" }, + { 0x27A0, "length (yard)" }, + { 0x27A1, "length (parsec)" }, + { 0x27A2, "length (inch)" }, + { 0x27A3, "length (foot)" }, + { 0x27A4, "length (mile)" }, + { 0x27A5, "pressure (pound-force per square inch)" }, + { 0x27A6, "velocity (kilometre per hour)" }, + { 0x27A7, "velocity (mile per hour)" }, + { 0x27A8, "angular velocity (revolution per minute)" }, + { 0x27A9, "energy (gram calorie)" }, + { 0x27AA, "energy (kilogram calorie)" }, + { 0x27AB, "energy (kilowatt hour)" }, + { 0x27AC, "thermodynamic temperature (degree Fahrenheit)" }, + { 0x27AD, "percentage" }, + { 0x27AE, "per mille" }, + { 0x27AF, "period (beats per minute)" }, + { 0x27B0, "electric charge (ampere hours)" }, + { 0x27B1, "mass density (milligram per decilitre)" }, + { 0x27B2, "mass density (millimole per litre)" }, + { 0x27B3, "time (year)" }, + { 0x27B4, "time (month)" }, + { 0x27B5, "concentration (count per cubic metre)" }, + { 0x27B6, "irradiance (watt per square metre)" }, + { 0x27B7, "milliliter (per kilogram per minute)" }, + { 0x27B8, "mass (pound)" }, + /* Declarations - http://developer.bluetooth.org/gatt/declarations/Pages/DeclarationsHome.aspx */ + { 0x2800, "GATT Primary Service Declaration" }, + { 0x2801, "GATT Secondary Service Declaration" }, + { 0x2802, "GATT Include Declaration" }, + { 0x2803, "GATT Characteristic Declaration" }, + /* Descriptors - http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorsHomePage.aspx */ + { 0x2900, "Characteristic Extended Properties" }, + { 0x2901, "Characteristic User Description" }, + { 0x2902, "Client Characteristic Configuration" }, + { 0x2903, "Server Characteristic Configuration" }, + { 0x2904, "Characteristic Presentation Format" }, + { 0x2905, "Characteristic Aggregate Format" }, + { 0x2906, "Valid Range" }, + { 0x2907, "External Report Reference" }, + { 0x2908, "Report Reference" }, + /* Characteristics - http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicsHome.aspx */ + { 0x2A00, "Device Name" }, + { 0x2A01, "Appearance" }, + { 0x2A02, "Peripheral Privacy Flag" }, + { 0x2A03, "Reconnection Address" }, + { 0x2A04, "Peripheral Preferred Connection Parameters" }, + { 0x2A05, "Service Changed" }, + { 0x2A06, "Alert Level" }, + { 0x2A07, "Tx Power Level" }, + { 0x2A08, "Date Time" }, + { 0x2A09, "Day of Week" }, + { 0x2A0A, "Day Date Time" }, + { 0x2A0C, "Exact Time 256" }, + { 0x2A0D, "DST Offset" }, + { 0x2A0E, "Time Zone" }, + { 0x2A0F, "Local Time Information" }, + { 0x2A11, "Time with DST" }, + { 0x2A12, "Time Accuracy" }, + { 0x2A13, "Time Source" }, + { 0x2A14, "Reference Time Information" }, + { 0x2A16, "Time Update Control Point" }, + { 0x2A17, "Time Update State" }, + { 0x2A18, "Glucose Measurement" }, + { 0x2A19, "Battery Level" }, + { 0x2A1C, "Temperature Measurement" }, + { 0x2A1D, "Temperature Type" }, + { 0x2A1E, "Intermediate Temperature" }, + { 0x2A21, "Measurement Interval" }, + { 0x2A22, "Boot Keyboard Input Report" }, + { 0x2A23, "System ID" }, + { 0x2A24, "Model Number String" }, + { 0x2A25, "Serial Number String" }, + { 0x2A26, "Firmware Revision String" }, + { 0x2A27, "Hardware Revision String" }, + { 0x2A28, "Software Revision String" }, + { 0x2A29, "Manufacturer Name String" }, + { 0x2A2A, "IEEE 11073-20601 Regulatory Certification Data List" }, + { 0x2A2B, "Current Time" }, + { 0x2A31, "Scan Refresh" }, + { 0x2A32, "Boot Keyboard Output Report" }, + { 0x2A33, "Boot Mouse Input Report" }, + { 0x2A34, "Glucose Measurement Context" }, + { 0x2A35, "Blood Pressure Measurement" }, + { 0x2A36, "Intermediate Cuff Pressure" }, + { 0x2A37, "Heart Rate Measurement" }, + { 0x2A38, "Body Sensor Location" }, + { 0x2A39, "Heart Rate Control Point" }, + { 0x2A3F, "Alert Status" }, + { 0x2A40, "Ringer Control Point" }, + { 0x2A41, "Ringer Setting" }, + { 0x2A42, "Alert Category ID Bit Mask" }, + { 0x2A43, "Alert Category ID" }, + { 0x2A44, "Alert Notification Control Point" }, + { 0x2A45, "Unread Alert Status" }, + { 0x2A46, "New Alert" }, + { 0x2A47, "Supported New Alert Category" }, + { 0x2A48, "Supported Unread Alert Category" }, + { 0x2A49, "Blood Pressure Feature" }, + { 0x2A4A, "HID Information" }, + { 0x2A4B, "Report Map" }, + { 0x2A4C, "HID Control Point" }, + { 0x2A4D, "Report" }, + { 0x2A4E, "Protocol Mode" }, + { 0x2A4F, "Scan Interval Window" }, + { 0x2A50, "PnP ID" }, + { 0x2A51, "Glucose Feature" }, + { 0x2A52, "Record Access Control Point" }, + { 0x2A53, "RSC Measurement" }, + { 0x2A54, "RSC Feature" }, + { 0x2A55, "SC Control Point" }, + { 0x2A5B, "CSC Measurement" }, + { 0x2A5C, "CSC Feature" }, + { 0x2A5D, "Sensor Location" }, + { 0x2A63, "Cycling Power Measurement" }, + { 0x2A64, "Cycling Power Vector" }, + { 0x2A65, "Cycling Power Feature" }, + { 0x2A66, "Cycling Power Control Point" }, + { 0x2A67, "Location and Speed" }, + { 0x2A68, "Navigation" }, + { 0x2A69, "Position Quality" }, + { 0x2A6A, "LN Feature" }, + { 0x2A6B, "LN Control Point" }, + /* 16-bit UUID for Members - https://www.bluetooth.org/en-us/Pages/LoginRestrictedAll/16-bit-UUIDs-member.aspx */ + { 0xFEEE, "Company UUID #2: Polar Electro Oy"}, /* Allocated 06-Mar-14 */ + { 0xFEEF, "Company UUID #1: Polar Electro Oy"}, /* Allocated 06-Mar-14 */ + { 0xFEF0, "Company UUID: Intel"}, /* Allocated 06-Mar-14 */ + { 0xFEF1, "Company UUID #2: CSR"}, /* Allocated 13-Feb-14 */ + { 0xFEF2, "Company UUID #1: CSR"}, /* Allocated 13-Feb-14 */ + { 0xFEF3, "Company UUID #2: Google"}, /* Allocated 13-Feb-14 */ + { 0xFEF4, "Company UUID #1: Google"}, /* Allocated 13-Feb-14 */ + { 0xFEF5, "Company UUID: Dialog Semiconductor GmbH"}, /* Allocated 13-Feb-14 */ + { 0xFEF6, "Company UUID: Wicentric, Inc."}, /* Allocated 13-Feb-14 */ + { 0xFEF7, "Company UUID #2: Aplix Corporation"}, /* Allocated 13-Feb-14 */ + { 0xFEF8, "Company UUID #1: Aplix Corporation"}, /* Allocated 13-Feb-14 */ + { 0xFEF9, "Company UUID #2: PayPal, Inc."}, /* Allocated 13-Jan-14 */ + { 0xFEFA, "Company UUID #1: PayPal, Inc."}, /* Allocated 13-Jan-14 */ + { 0xFEFB, "Company UUID: Stollmann E+V GmbH"}, /* Allocated 06-Jan-14 */ + { 0xFEFC, "Company UUID #2: Qualcomm Retail Solutions, Inc."}, /* Allocated 20-Dec-13 */ + { 0xFEFD, "Company UUID #1: Qualcomm Retail Solutions, Inc."}, /* Allocated 20-Dec-13 */ + { 0xFEFE, "Company UUID: GN ReSound A/S"}, /* Allocated 17-Dec-13 */ + { 0xFEFF, "Company UUID: GN Netcom"}, /* Allocated 12-Dec-13 */ + /* SDO Uuids - https://www.bluetooth.org/en-us/specification/assigned-numbers/sdo-16-bit-uuids */ + { 0xFFFE, "Alliance for Wireless Power" }, + { 0, NULL } +}; +value_string_ext bluetooth_uuid_vals_ext = VALUE_STRING_EXT_INIT(bluetooth_uuid_vals); + + +/* Taken from https://www.bluetooth.org/technical/assignednumbers/identifiers.htm */ +static const value_string bluetooth_company_id_vals[] = { + {0x0000, "Ericsson Technology Licensing"}, + {0x0001, "Nokia Mobile Phones"}, + {0x0002, "Intel Corp."}, + {0x0003, "IBM Corp."}, + {0x0004, "Toshiba Corp."}, + {0x0005, "3Com"}, + {0x0006, "Microsoft"}, + {0x0007, "Lucent"}, + {0x0008, "Motorola"}, + {0x0009, "Infineon Technologies AG"}, + {0x000A, "Cambridge Silicon Radio"}, + {0x000B, "Silicon Wave"}, + {0x000C, "Digianswer A/S"}, + {0x000D, "Texas Instruments Inc."}, + {0x000E, "Ceva, Inc. (formerly Parthus Technologies, Inc.)"}, + {0x000F, "Broadcom Corporation"}, + {0x0010, "Mitel Semiconductor"}, + {0x0011, "Widcomm, Inc."}, + {0x0012, "Zeevo, Inc."}, + {0x0013, "Atmel Corporation"}, + {0x0014, "Mitsubishi Electric Corporation"}, + {0x0015, "RTX Telecom A/S"}, + {0x0016, "KC Technology Inc."}, + {0x0017, "Newlogic"}, + {0x0018, "Transilica, Inc."}, + {0x0019, "Rohde & Schwarz GmbH & Co. KG"}, + {0x001A, "TTPCom Limited"}, + {0x001B, "Signia Technologies, Inc."}, + {0x001C, "Conexant Systems Inc."}, + {0x001D, "Qualcomm"}, + {0x001E, "Inventel"}, + {0x001F, "AVM Berlin"}, + {0x0020, "BandSpeed, Inc."}, + {0x0021, "Mansella Ltd"}, + {0x0022, "NEC Corporation"}, + {0x0023, "WavePlus Technology Co., Ltd."}, + {0x0024, "Alcatel"}, + {0x0025, "Philips Semiconductors"}, + {0x0026, "C Technologies"}, + {0x0027, "Open Interface"}, + {0x0028, "R F Micro Devices"}, + {0x0029, "Hitachi Ltd"}, + {0x002A, "Symbol Technologies, Inc."}, + {0x002B, "Tenovis"}, + {0x002C, "Macronix International Co. Ltd."}, + {0x002D, "GCT Semiconductor"}, + {0x002E, "Norwood Systems"}, + {0x002F, "MewTel Technology Inc."}, + {0x0030, "ST Microelectronics"}, + {0x0031, "Synopsys"}, + {0x0032, "Red-M (Communications) Ltd"}, + {0x0033, "Commil Ltd"}, + {0x0034, "Computer Access Technology Corporation (CATC)"}, + {0x0035, "Eclipse (HQ Espana) S.L."}, + {0x0036, "Renesas Technology Corp."}, + {0x0037, "Mobilian Corporation"}, + {0x0038, "Terax"}, + {0x0039, "Integrated System Solution Corp."}, + {0x003A, "Matsushita Electric Industrial Co., Ltd."}, + {0x003B, "Gennum Corporation"}, + {0x003C, "Research In Motion"}, + {0x003D, "IPextreme, Inc."}, + {0x003E, "Systems and Chips, Inc"}, + {0x003F, "Bluetooth SIG, Inc"}, + {0x0040, "Seiko Epson Corporation"}, + {0x0041, "Integrated Silicon Solution Taiwan, Inc."}, + {0x0042, "CONWISE Technology Corporation Ltd"}, + {0x0043, "PARROT SA"}, + {0x0044, "Socket Mobile"}, + {0x0045, "Atheros Communications, Inc."}, + {0x0046, "MediaTek, Inc."}, + {0x0047, "Bluegiga"}, + {0x0048, "Marvell Technology Group Ltd."}, + {0x0049, "3DSP Corporation"}, + {0x004A, "Accel Semiconductor Ltd."}, + {0x004B, "Continental Automotive Systems"}, + {0x004C, "Apple, Inc."}, + {0x004D, "Staccato Communications, Inc."}, + {0x004E, "Avago Technologies"}, + {0x004F, "APT Licensing Ltd."}, + {0x0050, "SiRF Technology, Inc."}, + {0x0051, "Tzero Technologies, Inc."}, + {0x0052, "J&M Corporation"}, + {0x0053, "Free2move AB"}, + {0x0054, "3DiJoy Corporation"}, + {0x0055, "Plantronics, Inc."}, + {0x0056, "Sony Ericsson Mobile Communications"}, + {0x0057, "Harman International Industries, Inc."}, + {0x0058, "Vizio, Inc."}, + {0x0059, "Nordic Semiconductor ASA"}, + {0x005A, "EM Microelectronic-Marin SA"}, + {0x005B, "Ralink Technology Corporation"}, + {0x005C, "Belkin International, Inc."}, + {0x005D, "Realtek Semiconductor Corporation"}, + {0x005E, "Stonestreet One, LLC"}, + {0x005F, "Wicentric, Inc."}, + {0x0060, "RivieraWaves S.A.S"}, + {0x0061, "RDA Microelectronics"}, + {0x0062, "Gibson Guitars"}, + {0x0063, "MiCommand Inc."}, + {0x0064, "Band XI International, LLC"}, + {0x0065, "Hewlett-Packard Company"}, + {0x0066, "9Solutions Oy"}, + {0x0067, "GN Netcom A/S"}, + {0x0068, "General Motors"}, + {0x0069, "A&D Engineering, Inc."}, + {0x006A, "MindTree Ltd."}, + {0x006B, "Polar Electro OY"}, + {0x006C, "Beautiful Enterprise Co., Ltd."}, + {0x006D, "BriarTek, Inc."}, + {0x006E, "Summit Data Communications, Inc."}, + {0x006F, "Sound ID"}, + {0x0070, "Monster, LLC"}, + {0x0071, "connectBlue AB"}, + {0x0072, "ShangHai Super Smart Electronics Co. Ltd."}, + {0x0073, "Group Sense Ltd."}, + {0x0074, "Zomm, LLC"}, + {0x0075, "Samsung Electronics Co. Ltd."}, + {0x0076, "Creative Technology Ltd."}, + {0x0077, "Laird Technologies"}, + {0x0078, "Nike, Inc."}, + {0x0079, "lesswire AG"}, + {0x007A, "MStar Semiconductor, Inc."}, + {0x007B, "Hanlynn Technologies"}, + {0x007C, "A & R Cambridge"}, + {0x007D, "Seers Technology Co. Ltd."}, + {0x007E, "Sports Tracking Technologies Ltd."}, + {0x007F, "Autonet Mobile"}, + {0x0080, "DeLorme Publishing Company, Inc."}, + {0x0081, "WuXi Vimicro"}, + {0x0082, "Sennheiser Communications A/S"}, + {0x0083, "TimeKeeping Systems, Inc."}, + {0x0084, "Ludus Helsinki Ltd."}, + {0x0085, "BlueRadios, Inc."}, + {0x0086, "equinux AG"}, + {0x0087, "Garmin International, Inc."}, + {0x0088, "Ecotest"}, + {0x0089, "GN ReSound A/S"}, + {0x008A, "Jawbone"}, + {0x008B, "Topcon Positioning Systems, LLC"}, + {0x008C, "Qualcomm Labs, Inc."}, + {0x008D, "Zscan Software"}, + {0x008E, "Quintic Corp."}, + {0x008F, "Stollmann E+V GmbH"}, + {0x0090, "Funai Electric Co., Ltd."}, + {0x0091, "Advanced PANMOBIL systems GmbH & Co. KG"}, + {0x0092, "ThinkOptics, Inc."}, + {0x0093, "Universal Electronics, Inc."}, + {0x0094, "Airoha Technology Corp."}, + {0x0095, "NEC Lighting, Ltd."}, + {0x0096, "ODM Technology, Inc."}, + {0x0097, "Bluetrek Technologies Limited"}, + {0x0098, "zero1.tv GmbH"}, + {0x0099, "i.Tech Dynamic Global Distribution Ltd."}, + {0x009A, "Alpwise"}, + {0x009B, "Jiangsu Toppower Automotive Electronics Co., Ltd."}, + {0x009C, "Colorfy, Inc."}, + {0x009D, "Geoforce Inc."}, + {0x009E, "Bose Corporation"}, + {0x009F, "Suunto Oy"}, + {0x00A0, "Kensington Computer Products Group"}, + {0x00A1, "SR-Medizinelektronik"}, + {0x00A2, "Vertu Corporation Limited"}, + {0x00A3, "Meta Watch Ltd."}, + {0x00A4, "LINAK A/S"}, + {0x00A5, "OTL Dynamics LLC"}, + {0x00A6, "Panda Ocean Inc."}, + {0x00A7, "Visteon Corporation"}, + {0x00A8, "ARP Devices Limited"}, + {0x00A9, "Magneti Marelli S.p.A."}, + {0x00AA, "CAEN RFID srl"}, + {0x00AB, "Ingenieur-Systemgruppe Zahn GmbH"}, + {0x00AC, "Green Throttle Games"}, + {0x00AD, "Peter Systemtechnik GmbH"}, + {0x00AE, "Omegawave Oy"}, + {0x00AF, "Cinetix"}, + {0x00B0, "Passif Semiconductor Corp"}, + {0x00B1, "Saris Cycling Group, Inc"}, + {0x00B2, "Bekey A/S"}, + {0x00B3, "Clarinox Technologies Pty. Ltd."}, + {0x00B4, "BDE Technology Co., Ltd."}, + {0x00B5, "Swirl Networks"}, + {0x00B6, "Meso international"}, + {0x00B7, "TreLab Ltd"}, + {0x00B8, "Qualcomm Innovation Center, Inc. (QuIC)"}, + {0x00B9, "Johnson Controls, Inc."}, + {0x00BA, "Starkey Laboratories Inc."}, + {0x00BB, "S-Power Electronics Limited"}, + {0xFFFF, "For use in internal and interoperability tests."}, + {0, NULL } +}; +value_string_ext bluetooth_company_id_vals_ext = VALUE_STRING_EXT_INIT(bluetooth_company_id_vals); + +guint32 max_disconnect_in_frame = G_MAXUINT32; + + +void proto_register_bluetooth(void); +void proto_reg_handoff_bluetooth(void); + + +gint +dissect_bd_addr(gint hf_bd_addr, proto_tree *tree, tvbuff_t *tvb, gint offset, guint8 *bdaddr) +{ + guint8 bd_addr[6]; + + bd_addr[5] = tvb_get_guint8(tvb, offset); + bd_addr[4] = tvb_get_guint8(tvb, offset + 1); + bd_addr[3] = tvb_get_guint8(tvb, offset + 2); + bd_addr[2] = tvb_get_guint8(tvb, offset + 3); + bd_addr[1] = tvb_get_guint8(tvb, offset + 4); + bd_addr[0] = tvb_get_guint8(tvb, offset + 5); + + proto_tree_add_ether(tree, hf_bd_addr, tvb, offset, 6, bd_addr); + offset += 6; + + if (bdaddr) + memcpy(bdaddr, bd_addr, 6); + + return offset; +} + + +static const char* bluetooth_conv_get_filter_type(conv_item_t* conv _U_, conv_filter_type_e filter) +{ + if (filter == CONV_FT_SRC_ADDRESS) + return "bluetooth.src"; + + if (filter == CONV_FT_DST_ADDRESS) + return "bluetooth.dst"; + + if (filter == CONV_FT_ANY_ADDRESS) + return "bluetooth.addr"; + + return CONV_FILTER_INVALID; +} + +static ct_dissector_info_t bluetooth_ct_dissector_info = {&bluetooth_conv_get_filter_type}; + + +static const char* bluetooth_get_filter_type(hostlist_talker_t* host _U_, conv_filter_type_e filter) +{ + if (filter == CONV_FT_ANY_ADDRESS) + return "bluetooth.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t bluetooth_dissector_info = {&bluetooth_get_filter_type}; + + +static int +bluetooth_conversation_packet(void *pct, packet_info *pinfo, + epan_dissect_t *edt _U_, const void *vip _U_) +{ + conv_hash_t *hash = (conv_hash_t*) pct; + add_conversation_table_data(hash, &pinfo->dl_src, &pinfo->dl_dst, 0, 0, 1, + pinfo->fd->pkt_len, &pinfo->rel_ts, &pinfo->fd->abs_ts, + &bluetooth_ct_dissector_info, PT_NONE); + + return 1; +} + + +static int +bluetooth_hostlist_packet(void *pit, packet_info *pinfo, + epan_dissect_t *edt _U_, const void *vip _U_) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + + add_hostlist_table_data(hash, &pinfo->dl_src, 0, TRUE, 1, pinfo->fd->pkt_len, &bluetooth_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &pinfo->dl_dst, 0, FALSE, 1, pinfo->fd->pkt_len, &bluetooth_dissector_info, PT_NONE); + + return 1; +} + +static conversation_t * +get_conversation(packet_info *pinfo, + address *src_addr, address *dst_addr, + guint32 src_endpoint, guint32 dst_endpoint) +{ + conversation_t *conversation; + + conversation = find_conversation(pinfo->fd->num, + src_addr, dst_addr, + pinfo->ptype, + src_endpoint, dst_endpoint, 0); + if (conversation) { + return conversation; + } + + conversation = conversation_new(pinfo->fd->num, + src_addr, dst_addr, + pinfo->ptype, + src_endpoint, dst_endpoint, 0); + return conversation; +} + + +static gint +dissect_bluetooth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) +{ + proto_item *main_item; + proto_tree *main_tree; + proto_item *sub_item; + bluetooth_data_t *bluetooth_data; + address *src; + address *dst; + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "Bluetooth"); + switch (pinfo->p2p_dir) { + + case P2P_DIR_SENT: + col_add_fstr(pinfo->cinfo, COL_INFO, "Sent "); + break; + + case P2P_DIR_RECV: + col_add_fstr(pinfo->cinfo, COL_INFO, "Rcvd "); + break; + + case P2P_DIR_UNKNOWN: + break; + + default: + col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown direction %d ", + pinfo->p2p_dir); + break; + } + + pinfo->ptype = PT_BLUETOOTH; + get_conversation(pinfo, &pinfo->dl_src, &pinfo->dl_dst, pinfo->srcport, pinfo->destport); + + main_item = proto_tree_add_item(tree, proto_bluetooth, tvb, 0, tvb_length(tvb), ENC_NA); + main_tree = proto_item_add_subtree(main_item, ett_bluetooth); + + bluetooth_data = (bluetooth_data_t *) wmem_new(wmem_packet_scope(), bluetooth_data_t); + if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) + bluetooth_data->interface_id = pinfo->phdr->interface_id; + else + bluetooth_data->interface_id = HCI_INTERFACE_DEFAULT; + bluetooth_data->adapter_id = HCI_ADAPTER_DEFAULT; + bluetooth_data->adapter_disconnect_in_frame = &max_disconnect_in_frame; + bluetooth_data->chandle_sessions = chandle_sessions; + bluetooth_data->chandle_to_bdaddr = chandle_to_bdaddr; + bluetooth_data->chandle_to_mode = chandle_to_mode; + bluetooth_data->bdaddr_to_name = bdaddr_to_name; + bluetooth_data->bdaddr_to_role = bdaddr_to_role; + bluetooth_data->localhost_bdaddr = localhost_bdaddr; + bluetooth_data->localhost_name = localhost_name; + + bluetooth_data->previous_protocol_data.data = data; + + if (have_tap_listener(bluetooth_tap)) { + bluetooth_tap_data_t *bluetooth_tap_data; + + bluetooth_tap_data = wmem_new(wmem_packet_scope(), bluetooth_tap_data_t); + bluetooth_tap_data->interface_id = bluetooth_data->interface_id; + bluetooth_tap_data->adapter_id = bluetooth_data->adapter_id; + + tap_queue_packet(bluetooth_tap, pinfo, bluetooth_tap_data); + } + + src = (address *) p_get_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_SRC); + dst = (address *) p_get_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_DST); + + if (src && src->type == AT_STRINGZ) { + sub_item = proto_tree_add_string(main_tree, hf_bluetooth_str_addr, tvb, 0, 0, (const char *) src->data); + PROTO_ITEM_SET_HIDDEN(sub_item); + + sub_item = proto_tree_add_string(main_tree, hf_bluetooth_str_src, tvb, 0, 0, (const char *) src->data); + PROTO_ITEM_SET_GENERATED(sub_item); + } else if (src && src->type == AT_ETHER) { + sub_item = proto_tree_add_ether(main_tree, hf_bluetooth_addr, tvb, 0, 0, (const guint8 *) src->data); + PROTO_ITEM_SET_HIDDEN(sub_item); + + sub_item = proto_tree_add_ether(main_tree, hf_bluetooth_src, tvb, 0, 0, (const guint8 *) src->data); + PROTO_ITEM_SET_GENERATED(sub_item); + } + + if (dst && dst->type == AT_STRINGZ) { + sub_item = proto_tree_add_string(main_tree, hf_bluetooth_str_addr, tvb, 0, 0, (const char *) dst->data); + PROTO_ITEM_SET_HIDDEN(sub_item); + + sub_item = proto_tree_add_string(main_tree, hf_bluetooth_str_dst, tvb, 0, 0, (const char *) dst->data); + PROTO_ITEM_SET_GENERATED(sub_item); + } else if (dst && dst->type == AT_ETHER) { + sub_item = proto_tree_add_ether(main_tree, hf_bluetooth_addr, tvb, 0, 0, (const guint8 *) dst->data); + PROTO_ITEM_SET_HIDDEN(sub_item); + + sub_item = proto_tree_add_ether(main_tree, hf_bluetooth_dst, tvb, 0, 0, (const guint8 *) dst->data); + PROTO_ITEM_SET_GENERATED(sub_item); + } + + if (proto_ubertooth == (gint) GPOINTER_TO_UINT(wmem_list_frame_data( + wmem_list_frame_prev(wmem_list_tail(pinfo->layers))))) { + call_dissector(btle_handle, tvb, pinfo, tree); + } else if (!dissector_try_uint_new(bluetooth_table, pinfo->phdr->pkt_encap, tvb, pinfo, tree, TRUE, bluetooth_data)) { + call_dissector(data_handle, tvb, pinfo, tree); + } + + return tvb_length(tvb); +} + +void +proto_register_bluetooth(void) +{ + static hf_register_info hf[] = { + { &hf_bluetooth_src, + { "Source", "bluetooth.src", + FT_ETHER, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, + { &hf_bluetooth_dst, + { "Destination", "bluetooth.dst", + FT_ETHER, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, + { &hf_bluetooth_addr, + { "Source or Destination", "bluetooth.addr", + FT_ETHER, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, + { &hf_bluetooth_str_src, + { "Source", "bluetooth.src", + FT_STRING, STR_ASCII, NULL, 0x0, + NULL, HFILL } + }, + { &hf_bluetooth_str_dst, + { "Destination", "bluetooth.dst", + FT_STRING, STR_ASCII, NULL, 0x0, + NULL, HFILL } + }, + { &hf_bluetooth_str_addr, + { "Source or Destination", "bluetooth.addr", + FT_STRING, STR_ASCII, NULL, 0x0, + NULL, HFILL } + }, + }; + + static gint *ett[] = { + &ett_bluetooth, + }; + + proto_bluetooth = proto_register_protocol("Bluetooth", + "Bluetooth", "bluetooth"); + + bluetooth_handle = new_register_dissector("bluetooth", dissect_bluetooth, proto_bluetooth); + + proto_register_field_array(proto_bluetooth, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + + bluetooth_table = register_dissector_table("bluetooth.encap", + "Bluetooth Encapsulation", FT_UINT32, BASE_HEX); + + chandle_sessions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); + chandle_to_bdaddr = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); + chandle_to_mode = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); + bdaddr_to_name = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); + bdaddr_to_role = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); + localhost_bdaddr = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); + localhost_name = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); + + bluetooth_tap = register_tap("bluetooth"); + + register_conversation_table(proto_bluetooth, TRUE, bluetooth_conversation_packet, bluetooth_hostlist_packet, NULL); +} + +void +proto_reg_handoff_bluetooth(void) +{ + proto_ubertooth = proto_get_id_by_filter_name("ubertooth"); + btle_handle = find_dissector("btle"); + data_handle = find_dissector("data"); + + dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_HCI, bluetooth_handle); + dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_H4, bluetooth_handle); + dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR, bluetooth_handle); + dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR, bluetooth_handle); + dissector_add_uint("wtap_encap", WTAP_ENCAP_PACKETLOGGER, bluetooth_handle); + + dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_LE_LL, bluetooth_handle); + dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_LE_LL_WITH_PHDR, bluetooth_handle); + dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_BREDR_BB, bluetooth_handle); + + dissector_add_uint("usb.product", (0x0a5c << 16) | 0x21e8, bluetooth_handle); + dissector_add_uint("usb.product", (0x1131 << 16) | 0x1001, bluetooth_handle); + dissector_add_uint("usb.product", (0x050d << 16) | 0x0081, bluetooth_handle); + dissector_add_uint("usb.product", (0x0a5c << 16) | 0x2198, bluetooth_handle); + dissector_add_uint("usb.product", (0x0a5c << 16) | 0x21e8, bluetooth_handle); + dissector_add_uint("usb.product", (0x04bf << 16) | 0x0320, bluetooth_handle); + dissector_add_uint("usb.product", (0x13d3 << 16) | 0x3375, bluetooth_handle); + + dissector_add_uint("usb.protocol", 0xE00101, bluetooth_handle); + dissector_add_uint("usb.protocol", 0xE00104, bluetooth_handle); + + dissector_add_for_decode_as("usb.device", bluetooth_handle); +} + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/epan/dissectors/packet-bluetooth.h b/epan/dissectors/packet-bluetooth.h new file mode 100644 index 0000000000..9e664e4caf --- /dev/null +++ b/epan/dissectors/packet-bluetooth.h @@ -0,0 +1,202 @@ +/* packet-bluetooth.h + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __PACKET_BLUETOOTH_H__ +#define __PACKET_BLUETOOTH_H__ + +#include + +#include +#include + +#define BLUETOOTH_DATA_SRC 0 +#define BLUETOOTH_DATA_DST 1 + +#define HCI_H4_TYPE_CMD 0x01 +#define HCI_H4_TYPE_ACL 0x02 +#define HCI_H4_TYPE_SCO 0x03 +#define HCI_H4_TYPE_EVT 0x04 + +#define HCI_OGF_LINK_CONTROL 0x01 +#define HCI_OGF_LINK_POLICY 0x02 +#define HCI_OGF_HOST_CONTROLLER 0x03 +#define HCI_OGF_INFORMATIONAL 0x04 +#define HCI_OGF_STATUS 0x05 +#define HCI_OGF_TESTING 0x06 +#define HCI_OGF_LOW_ENERGY 0x08 +#define HCI_OGF_LOGO_TESTING 0x3e +#define HCI_OGF_VENDOR_SPECIFIC 0x3f + +#define HCI_VENDOR_DEFAULT 0 + +#define DID_VENDOR_ID_SOURCE_BLUETOOTH_SIG 1 +#define DID_VENDOR_ID_SOURCE_USB_FORUM 2 + +#define ACCESS_ADDRESS_ADVERTISING 0x8e89bed6 + +extern int proto_bluetooth; + +extern value_string_ext bthci_cmd_opcode_vals_ext; +extern value_string_ext bthci_ogf_vals_ext; +extern value_string_ext bthci_cmd_ocf_link_control_vals_ext; +extern value_string_ext bthci_cmd_ocf_link_policy_vals_ext; +extern value_string_ext bthci_cmd_ocf_host_controller_and_baseband_vals_ext; +extern value_string_ext bthci_cmd_ocf_informational_vals_ext; +extern value_string_ext bthci_cmd_ocf_status_vals_ext; +extern value_string_ext bthci_cmd_ocf_testing_vals_ext; +extern value_string_ext bthci_cmd_ocf_low_energy_vals_ext; + +extern value_string_ext bthci_cmd_input_coding_vals_ext; +extern value_string_ext bthci_cmd_input_data_format_vals_ext; +extern value_string_ext bthci_cmd_input_sample_size_vals_ext; +extern value_string_ext bthci_cmd_air_coding_format_vals_ext; +extern value_string_ext bthci_cmd_status_vals_ext; +extern value_string_ext bthci_cmd_eir_data_type_vals_ext; +extern value_string_ext bthci_cmd_auth_req_vals_ext; +extern value_string_ext bthci_cmd_appearance_vals_ext; + +extern const value_string bthci_cmd_io_capability_vals[]; +extern const value_string bthci_cmd_oob_data_present_vals[]; +extern const value_string bthci_cmd_address_types_vals[]; +extern const value_string bthci_cmd_scan_enable_values[]; +extern const value_string bthci_cmd_page_scan_modes[]; +extern const value_string bthci_cmd_page_scan_repetition_modes[]; +extern const value_string bthci_cmd_page_scan_period_modes[]; +extern const value_string bthci_cmd_notification_types[]; + + +/* We support Bluetooth over various interfaces, interface_id and adapter_id + is used to decode further payload. Case: there is a host. Host has X + interfaces. Each interface has Y adapter. Each adapter has ACL handle or + L2CAP CID. ACL handle has L2CAP CID and/or L2CAP PSM. L2CAP CID or + L2CAP PSM has RFCOMM channel or other end-protocol like OBEX, AVRCP, HID, + AVDTP, BNEP etc. RFCOMM channel has end-protocol like OBEX, HFP, etc. + Important note: correct payload decoding should store needed data using + key contain interface_id, adapter_id, ..., last_channel_type (for example + RFCOMM channel, transaction_id, frame number etc. ) + + interface_id - interface id provided by Wireshark, see "frame.interface_id", + in case where is only one interface id HCI_INTERFACE_DEFAULT + is used (for example open BTSNOOP file with HCI H4 protocol) + adapter_id - identified Bluetooth device (interface, for example Linux + hci0, hci1, etc.) +*/ +#define HCI_INTERFACE_DEFAULT 0 +#define HCI_ADAPTER_DEFAULT 0 + +/* chandle_sessions: interface_id + adapter_id + connection_handle + frame_number -> connect_in_frame, disconnect_in_frame */ +/* chandle_to_bdaddr: interface_id + adapter_id + connection_handle + frame_number -> bd_addr[6] */ +/* chandle_to_mode: interface_id + adapter_id + connection_handle + frame_number -> mode */ +/* bdaddr_to_name: bd_addr[6] + frame_number -> name */ +/* bdaddr_to_role: bd_addr[6] + frame_number -> role */ +/* localhost_bdaddr: interface_id + adapter_id + frame_number -> bd_addr[6] */ +/* localhost_name: interface_id + adapter_id + frame_number -> name */ +typedef struct _bluetooth_data_t { + guint32 interface_id; + guint32 adapter_id; + guint32 *adapter_disconnect_in_frame; + wmem_tree_t *chandle_sessions; + wmem_tree_t *chandle_to_bdaddr; + wmem_tree_t *chandle_to_mode; + wmem_tree_t *bdaddr_to_name; + wmem_tree_t *bdaddr_to_role; + wmem_tree_t *localhost_bdaddr; + wmem_tree_t *localhost_name; + + union { + void *data; + usb_conv_info_t *usb_conv_info; + ubertooth_data_t *ubertooth_data; + } previous_protocol_data; + +} bluetooth_data_t; + +typedef struct _chandle_session_t { + guint32 connect_in_frame; + guint32 disconnect_in_frame; +} chandle_session_t; + +typedef struct _remote_bdaddr_t { + guint32 interface_id; + guint32 adapter_id; + guint16 chandle; + guint8 bd_addr[6]; +} remote_bdaddr_t; + +typedef struct _device_name_t { + guint32 bd_addr_oui; + guint32 bd_addr_id; + gchar *name; +} device_name_t; + +typedef struct _device_role_t { + guint32 role; + guint32 change_in_frame; +} device_role_t; + +typedef struct _connection_mode_t { + gint32 mode; + guint32 change_in_frame; +} connection_mode_t; + +#define ROLE_UNKNOWN 0 +#define ROLE_MASTER 1 +#define ROLE_SLAVE 2 + +typedef struct _localhost_bdaddr_entry_t { + guint32 interface_id; + guint32 adapter_id; + guint8 bd_addr[6]; +} localhost_bdaddr_entry_t; + +typedef struct _localhost_name_entry_t { + guint32 interface_id; + guint32 adapter_id; + gchar *name; +} localhost_name_entry_t; + +typedef struct _bluetooth_tap_data_t { + guint32 interface_id; + guint32 adapter_id; +} bluetooth_tap_data_t; + + +extern value_string_ext bluetooth_uuid_vals_ext; +extern value_string_ext bluetooth_company_id_vals_ext; +extern guint32 max_disconnect_in_frame; + +extern gint dissect_bd_addr(gint hf_bd_addr, proto_tree *tree, tvbuff_t *tvb, + gint offset, guint8 *bdaddr); + +#endif + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/epan/dissectors/packet-btatt.c b/epan/dissectors/packet-btatt.c index b2f3101d8b..b12a4a63b0 100644 --- a/epan/dissectors/packet-btatt.c +++ b/epan/dissectors/packet-btatt.c @@ -32,7 +32,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" #include "packet-btl2cap.h" /* Initialize the protocol and registered fields */ @@ -243,7 +243,7 @@ dissect_btatt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U case 0x06: /* Find By Type Value Request */ col_append_fstr(pinfo->cinfo, COL_INFO, ", %s, Handles: 0x%04x..0x%04x", - val_to_str_ext_const(tvb_get_letohs(tvb, offset+4), &bt_sig_uuid_vals_ext, ""), + val_to_str_ext_const(tvb_get_letohs(tvb, offset+4), &bluetooth_uuid_vals_ext, ""), tvb_get_letohs(tvb, offset), tvb_get_letohs(tvb, offset+2)); proto_tree_add_item(st, hf_btatt_starting_handle, tvb, offset, 2, ENC_LITTLE_ENDIAN); @@ -274,7 +274,7 @@ dissect_btatt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U case 0x08: /* Read By Type Request */ case 0x10: /* Read By Group Type Request */ col_append_fstr(pinfo->cinfo, COL_INFO, ", %s, Handles: 0x%04x..0x%04x", - val_to_str_ext_const(tvb_get_letohs(tvb, offset+4), &bt_sig_uuid_vals_ext, ""), + val_to_str_ext_const(tvb_get_letohs(tvb, offset+4), &bluetooth_uuid_vals_ext, ""), tvb_get_letohs(tvb, offset), tvb_get_letohs(tvb, offset+2)); proto_tree_add_item(st, hf_btatt_starting_handle, tvb, offset, 2, ENC_LITTLE_ENDIAN); @@ -289,7 +289,7 @@ dissect_btatt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U else if (tvb_length_remaining(tvb, offset) == 16) { item = proto_tree_add_item(st, hf_btatt_uuid128, tvb, offset, 16, ENC_NA); proto_item_append_text(item, " (%s)", val_to_str_ext_const(tvb_get_letohs(tvb, offset), - &bt_sig_uuid_vals_ext, "")); + &bluetooth_uuid_vals_ext, "")); offset += 16; } break; @@ -504,7 +504,7 @@ proto_register_btatt(void) }, {&hf_btatt_uuid16, {"UUID", "btatt.uuid16", - FT_UINT16, BASE_HEX |BASE_EXT_STRING, &bt_sig_uuid_vals_ext, 0x0, + FT_UINT16, BASE_HEX |BASE_EXT_STRING, &bluetooth_uuid_vals_ext, 0x0, NULL, HFILL} }, {&hf_btatt_uuid128, diff --git a/epan/dissectors/packet-btavctp.c b/epan/dissectors/packet-btavctp.c index 97cc6535e1..d96e25d0c6 100644 --- a/epan/dissectors/packet-btavctp.c +++ b/epan/dissectors/packet-btavctp.c @@ -30,7 +30,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" #include "packet-btl2cap.h" #include "packet-btsdp.h" #include "packet-btavctp.h" @@ -456,7 +456,7 @@ proto_register_btavctp(void) }, { &hf_btavctp_pid, { "Profile Identifier", "btavctp.pid", - FT_UINT16, BASE_HEX|BASE_EXT_STRING, &bt_sig_uuid_vals_ext, 0x00, + FT_UINT16, BASE_HEX|BASE_EXT_STRING, &bluetooth_uuid_vals_ext, 0x00, NULL, HFILL } }, { &hf_btavctp_number_of_packets, diff --git a/epan/dissectors/packet-btavdtp.c b/epan/dissectors/packet-btavdtp.c index d4c6fbcfff..ea63ef335a 100644 --- a/epan/dissectors/packet-btavdtp.c +++ b/epan/dissectors/packet-btavdtp.c @@ -30,11 +30,12 @@ #include #include +#include "packet-bluetooth.h" #include "packet-btl2cap.h" #include "packet-btsdp.h" #include "packet-btavdtp.h" -#include "packet-rtp.h" #include "packet-btavrcp.h" +#include "packet-rtp.h" #define AVDTP_MESSAGE_TYPE_MASK 0x03 #define AVDTP_PACKET_TYPE_MASK 0x0C @@ -500,8 +501,6 @@ static const value_string vendor_apt_codec_vals[] = { { 0, NULL } }; -extern value_string_ext bthci_evt_comp_id_ext; - enum sep_state { SEP_STATE_FREE, SEP_STATE_OPEN, @@ -1320,7 +1319,7 @@ dissect_btavdtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) channels_info->control_remote_cid = l2cap_data->remote_cid; channels_info->media_local_cid = BTL2CAP_UNKNOWN_CID; channels_info->media_remote_cid = BTL2CAP_UNKNOWN_CID; - channels_info->disconnect_in_frame = G_MAXUINT32; + channels_info->disconnect_in_frame = max_disconnect_in_frame; channels_info->l2cap_disconnect_in_frame = l2cap_data->disconnect_in_frame; channels_info->hci_disconnect_in_frame = l2cap_data->hci_disconnect_in_frame; channels_info->adapter_disconnect_in_frame = l2cap_data->adapter_disconnect_in_frame; @@ -2510,7 +2509,7 @@ proto_register_btavdtp(void) }, { &hf_btavdtp_vendor_id, { "Vendor ID", "btavdtp.codec.vendor.vendor_id", - FT_UINT32, BASE_HEX|BASE_EXT_STRING, &bthci_evt_comp_id_ext, 0x00, + FT_UINT32, BASE_HEX|BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x00, NULL, HFILL } }, { &hf_btavdtp_vendor_specific_codec_id, @@ -2932,7 +2931,7 @@ proto_register_bta2dp(void) }, { &hf_bta2dp_vendor_id, { "Vendor ID", "bta2dp.codec.vendor.vendor_id", - FT_UINT32, BASE_HEX|BASE_EXT_STRING, &bthci_evt_comp_id_ext, 0x00, + FT_UINT32, BASE_HEX|BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x00, NULL, HFILL } }, { &hf_bta2dp_vendor_codec_id, diff --git a/epan/dissectors/packet-btbnep.c b/epan/dissectors/packet-btbnep.c index 6c430b73b1..7e9ec08886 100644 --- a/epan/dissectors/packet-btbnep.c +++ b/epan/dissectors/packet-btbnep.c @@ -29,7 +29,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" #include "packet-btl2cap.h" #include "packet-btsdp.h" @@ -179,17 +179,17 @@ dissect_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) pitem = proto_tree_add_item(tree, hf_btbnep_destination_service_uuid, tvb, offset, uuid_size, ENC_NA); uuid_dst = tvb_get_ntohs(tvb, offset); - proto_item_append_text(pitem, " (%s)", val_to_str_ext(uuid_dst, &bt_sig_uuid_vals_ext, "Unknown uuid")); + proto_item_append_text(pitem, " (%s)", val_to_str_ext(uuid_dst, &bluetooth_uuid_vals_ext, "Unknown uuid")); offset += uuid_size; pitem = proto_tree_add_item(tree, hf_btbnep_source_service_uuid, tvb, offset, uuid_size, ENC_NA); uuid_src = tvb_get_ntohs(tvb, offset); - proto_item_append_text(pitem, " (%s)", val_to_str_ext(uuid_src, &bt_sig_uuid_vals_ext, "Unknown uuid")); + proto_item_append_text(pitem, " (%s)", val_to_str_ext(uuid_src, &bluetooth_uuid_vals_ext, "Unknown uuid")); offset += uuid_size; col_append_fstr(pinfo->cinfo, COL_INFO, " - dst: <%s>, src: <%s>", - val_to_str_ext(uuid_dst, &bt_sig_uuid_vals_ext, "Unknown uuid"), - val_to_str_ext(uuid_src, &bt_sig_uuid_vals_ext, "Unknown uuid")); + val_to_str_ext(uuid_dst, &bluetooth_uuid_vals_ext, "Unknown uuid"), + val_to_str_ext(uuid_src, &bluetooth_uuid_vals_ext, "Unknown uuid")); break; case 0x02: /* Setup Connection Response */ proto_tree_add_item(tree, hf_btbnep_setup_connection_response_message, tvb, offset, 2, ENC_BIG_ENDIAN); diff --git a/epan/dissectors/packet-bthci_acl.c b/epan/dissectors/packet-bthci_acl.c index fbb9fb7051..f0d04de80f 100644 --- a/epan/dissectors/packet-bthci_acl.c +++ b/epan/dissectors/packet-bthci_acl.c @@ -33,7 +33,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" #include "packet-bthci_acl.h" /* Initialize the protocol and registered fields */ @@ -49,8 +49,13 @@ static int hf_bthci_acl_connect_in = -1; static int hf_bthci_acl_disconnect_in = -1; static int hf_bthci_acl_src_bd_addr = -1; static int hf_bthci_acl_src_name = -1; +static int hf_bthci_acl_src_role = -1; static int hf_bthci_acl_dst_bd_addr = -1; static int hf_bthci_acl_dst_name = -1; +static int hf_bthci_acl_dst_role = -1; +static int hf_bthci_acl_role_last_change_in_frame = -1; +static int hf_bthci_acl_mode = -1; +static int hf_bthci_acl_mode_last_change_in_frame = -1; /* Initialize the subtree pointers */ static gint ett_bthci_acl = -1; @@ -76,6 +81,22 @@ typedef struct _chandle_data_t { static wmem_tree_t *chandle_tree = NULL; +static const value_string role_vals[] = { + { 0, "Unknown" }, + { 1, "Master" }, + { 2, "Slave" }, + { 0, NULL } +}; + +static const value_string mode_vals[] = { + { 0, "Active Mode" }, + { 1, "Hold Mode" }, + { 2, "Sniff Mode" }, + { 3, "Park Mode" }, + {-1, "Unknown" }, + { 0, NULL } +}; + static const value_string pb_flag_vals[] = { { 0, "First Non-automatically Flushable Packet" }, { 1, "Continuing Fragment" }, @@ -111,7 +132,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat tvbuff_t *next_tvb; bthci_acl_data_t *acl_data; chandle_data_t *chandle_data; - hci_data_t *hci_data; + bluetooth_data_t *bluetooth_data; wmem_tree_t *subtree; wmem_tree_key_t key[6]; guint32 interface_id; @@ -135,11 +156,17 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat const gchar *dst_name = ""; const gchar *dst_addr_name = ""; chandle_session_t *chandle_session; + guint32 src_role = ROLE_UNKNOWN; + guint32 dst_role = ROLE_UNKNOWN; + guint32 role_last_change_in_frame = 0; + connection_mode_t *connection_mode; + gint32 mode = -1; + guint32 mode_last_change_in_frame = 0; /* Reject the packet if data is NULL */ if (data == NULL) return 0; - hci_data = (hci_data_t *) data; + bluetooth_data = (bluetooth_data_t *) data; bthci_acl_itam = proto_tree_add_item(tree, proto_bthci_acl, tvb, offset, -1, ENC_NA); bthci_acl_tree = proto_item_add_subtree(bthci_acl_itam, ett_bthci_acl); @@ -166,8 +193,8 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat proto_tree_add_item(bthci_acl_tree, hf_bthci_acl_bc_flag, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; - interface_id = hci_data->interface_id; - adapter_id = hci_data->adapter_id; + interface_id = bluetooth_data->interface_id; + adapter_id = bluetooth_data->adapter_id; connection_handle = flags & 0x0fff; direction = pinfo->p2p_dir; frame_number = pinfo->fd->num; @@ -175,7 +202,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat acl_data = wmem_new(wmem_packet_scope(), bthci_acl_data_t); acl_data->interface_id = interface_id; acl_data->adapter_id = adapter_id; - acl_data->adapter_disconnect_in_frame = hci_data->adapter_disconnect_in_frame; + acl_data->adapter_disconnect_in_frame = bluetooth_data->adapter_disconnect_in_frame; acl_data->chandle = connection_handle; key[0].length = 1; @@ -187,7 +214,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat key[3].length = 0; key[3].key = NULL; - subtree = (wmem_tree_t *) wmem_tree_lookup32_array(hci_data->chandle_sessions, key); + subtree = (wmem_tree_t *) wmem_tree_lookup32_array(bluetooth_data->chandle_sessions, key); chandle_session = (subtree) ? (chandle_session_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL; if (chandle_session && chandle_session->connect_in_frame < pinfo->fd->num && @@ -201,8 +228,15 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat acl_data->remote_bd_addr_oui = 0; acl_data->remote_bd_addr_id = 0; + subtree = (wmem_tree_t *) wmem_tree_lookup32_array(bluetooth_data->chandle_to_mode, key); + connection_mode = (subtree) ? (connection_mode_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL; + if (connection_mode) { + mode = connection_mode->mode; + mode_last_change_in_frame = connection_mode->change_in_frame; + } + /* remote bdaddr and name */ - subtree = (wmem_tree_t *) wmem_tree_lookup32_array(hci_data->chandle_to_bdaddr_table, key); + subtree = (wmem_tree_t *) wmem_tree_lookup32_array(bluetooth_data->chandle_to_bdaddr, key); remote_bdaddr = (subtree) ? (remote_bdaddr_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL; if (remote_bdaddr) { guint32 k_bd_addr_oui; @@ -210,6 +244,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat guint32 bd_addr_oui; guint32 bd_addr_id; device_name_t *device_name; + device_role_t *device_role; const gchar *remote_name; const gchar *remote_ether_addr; gchar *remote_addr_name; @@ -225,13 +260,32 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat k_bd_addr_id = bd_addr_id; key[0].length = 1; - key[0].key = &k_bd_addr_id; + key[0].key = &interface_id; key[1].length = 1; - key[1].key = &k_bd_addr_oui; - key[2].length = 0; - key[2].key = NULL; + key[1].key = &adapter_id; + key[2].length = 1; + key[2].key = &k_bd_addr_id; + key[3].length = 1; + key[3].key = &k_bd_addr_oui; + key[4].length = 0; + key[4].key = NULL; + + subtree = (wmem_tree_t *) wmem_tree_lookup32_array(bluetooth_data->bdaddr_to_role, key); + device_role = (subtree) ? (device_role_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL; + if (device_role) { + if ((pinfo->p2p_dir == P2P_DIR_SENT && device_role->role == ROLE_MASTER) || + (pinfo->p2p_dir == P2P_DIR_RECV && device_role->role == ROLE_SLAVE)) { + src_role = ROLE_SLAVE; + dst_role = ROLE_MASTER; + } else if ((pinfo->p2p_dir == P2P_DIR_SENT && device_role->role == ROLE_SLAVE) || + (pinfo->p2p_dir == P2P_DIR_RECV && device_role->role == ROLE_MASTER)) { + src_role = ROLE_MASTER; + dst_role = ROLE_SLAVE; + } + role_last_change_in_frame = device_role->change_in_frame; + } - subtree = (wmem_tree_t *) wmem_tree_lookup32_array(hci_data->bdaddr_to_name_table, key); + subtree = (wmem_tree_t *) wmem_tree_lookup32_array(bluetooth_data->bdaddr_to_name, key); device_name = (subtree) ? (device_name_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL; if (device_name) remote_name = device_name->name; @@ -269,7 +323,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat key[2].key = NULL; - subtree = (wmem_tree_t *) wmem_tree_lookup32_array(hci_data->localhost_bdaddr, key); + subtree = (wmem_tree_t *) wmem_tree_lookup32_array(bluetooth_data->localhost_bdaddr, key); localhost_bdaddr_entry = (subtree) ? (localhost_bdaddr_entry_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL; if (localhost_bdaddr_entry) { localhost_ether_addr = get_ether_name(localhost_bdaddr_entry->bd_addr); @@ -279,8 +333,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat memcpy(localhost_bdaddr, unknown_bd_addr, 6); } - - subtree = (wmem_tree_t *) wmem_tree_lookup32_array(hci_data->localhost_name, key); + subtree = (wmem_tree_t *) wmem_tree_lookup32_array(bluetooth_data->localhost_name, key); localhost_name_entry = (subtree) ? (localhost_name_entry_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL; if (localhost_name_entry) localhost_name = localhost_name_entry->name; @@ -445,18 +498,49 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, dst_bd_addr); SET_ADDRESS(&pinfo->dst, AT_STRINGZ, (int)strlen(dst_addr_name) + 1, dst_addr_name); + if (!pinfo->fd->flags.visited) { + address *addr; + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_src, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_src.data, pinfo->dl_src.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_SRC, addr); + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_dst, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_dst.data, pinfo->dl_dst.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_DST, addr); + } + sub_item = proto_tree_add_ether(bthci_acl_tree, hf_bthci_acl_src_bd_addr, tvb, 0, 0, src_bd_addr); PROTO_ITEM_SET_GENERATED(sub_item); sub_item = proto_tree_add_string(bthci_acl_tree, hf_bthci_acl_src_name, tvb, 0, 0, src_name); PROTO_ITEM_SET_GENERATED(sub_item); + sub_item = proto_tree_add_uint(bthci_acl_tree, hf_bthci_acl_src_role, tvb, 0, 0, src_role); + PROTO_ITEM_SET_GENERATED(sub_item); + sub_item = proto_tree_add_ether(bthci_acl_tree, hf_bthci_acl_dst_bd_addr, tvb, 0, 0, dst_bd_addr); PROTO_ITEM_SET_GENERATED(sub_item); sub_item = proto_tree_add_string(bthci_acl_tree, hf_bthci_acl_dst_name, tvb, 0, 0, dst_name); PROTO_ITEM_SET_GENERATED(sub_item); + sub_item = proto_tree_add_uint(bthci_acl_tree, hf_bthci_acl_dst_role, tvb, 0, 0, dst_role); + PROTO_ITEM_SET_GENERATED(sub_item); + + if (role_last_change_in_frame > 0) { + sub_item = proto_tree_add_uint(bthci_acl_tree, hf_bthci_acl_role_last_change_in_frame, tvb, 0, 0, role_last_change_in_frame); + PROTO_ITEM_SET_GENERATED(sub_item); + } + + sub_item = proto_tree_add_int(bthci_acl_tree, hf_bthci_acl_mode, tvb, 0, 0, mode); + PROTO_ITEM_SET_GENERATED(sub_item); + + if (mode_last_change_in_frame > 0) { + sub_item = proto_tree_add_uint(bthci_acl_tree, hf_bthci_acl_mode_last_change_in_frame, tvb, 0, 0, mode_last_change_in_frame); + PROTO_ITEM_SET_GENERATED(sub_item); + } + return tvb_captured_length(tvb); } @@ -523,6 +607,11 @@ proto_register_bthci_acl(void) FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL } }, + { &hf_bthci_acl_src_role, + { "Source Role", "bthci_acl.src.role", + FT_UINT32, BASE_DEC, VALS(role_vals), 0x0, + NULL, HFILL } + }, { &hf_bthci_acl_dst_bd_addr, { "Destination BD_ADDR", "bthci_acl.dst.bd_addr", FT_ETHER, BASE_NONE, NULL, 0x0, @@ -533,6 +622,26 @@ proto_register_bthci_acl(void) FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL } }, + { &hf_bthci_acl_dst_role, + { "Destination Role", "bthci_acl.dst.role", + FT_UINT32, BASE_DEC, VALS(role_vals), 0x0, + NULL, HFILL } + }, + { &hf_bthci_acl_role_last_change_in_frame, + { "Last Role Change in Frame", "bthci_acl.last_change_in_frame.role", + FT_FRAMENUM, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, + { &hf_bthci_acl_mode, + { "Current Mode", "bthci_acl.mode", + FT_INT32, BASE_DEC, VALS(mode_vals), 0x0, + NULL, HFILL } + }, + { &hf_bthci_acl_mode_last_change_in_frame, + { "Last Mode Change in Frame", "bthci_acl.last_change_in_frame.mode", + FT_FRAMENUM, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, }; /* Setup protocol subtree array */ diff --git a/epan/dissectors/packet-bthci_cmd.c b/epan/dissectors/packet-bthci_cmd.c index 4800cbcf4c..4fd223acaf 100644 --- a/epan/dissectors/packet-bthci_cmd.c +++ b/epan/dissectors/packet-bthci_cmd.c @@ -38,7 +38,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" #include "packet-btsdp.h" static int proto_bthci_cmd = -1; @@ -482,369 +482,6 @@ extern value_string_ext ext_usb_vendors_vals; extern value_string_ext ext_usb_products_vals; extern value_string_ext did_vendor_id_source_vals_ext; -static const value_string bt_sig_uuid_vals[] = { - /* Protocol Identifiers - https://www.bluetooth.org/en-us/specification/assigned-numbers/service-discovery */ - { 0x0001, "SDP" }, - { 0x0002, "UDP" }, - { 0x0003, "RFCOMM" }, - { 0x0004, "TCP" }, - { 0x0005, "TCS-BIN" }, - { 0x0006, "TCS-AT" }, - { 0x0007, "ATT" }, - { 0x0008, "OBEX" }, - { 0x0009, "IP" }, - { 0x000A, "FTP" }, - { 0x000C, "HTTP" }, - { 0x000E, "WSP" }, - { 0x000F, "BNEP" }, - { 0x0010, "UPNP" }, - { 0x0011, "HIDP" }, - { 0x0012, "Hardcopy Control Channel" }, - { 0x0014, "Hardcopy Data Channel" }, - { 0x0016, "Hardcopy Notification" }, - { 0x0017, "AVCTP" }, - { 0x0019, "AVDTP" }, - { 0x001B, "CMPT" }, - { 0x001D, "UDI C-Plane" }, /* unofficial */ - { 0x001E, "MCAP Control Channel" }, - { 0x001F, "MCAP Data Channel" }, - { 0x0100, "L2CAP" }, - /* Traditional Services - https://www.bluetooth.org/en-us/specification/assigned-numbers/service-discovery */ - { 0x1000, "Service Discovery Server Service Class ID" }, - { 0x1001, "Browse Group Descriptor Service Class ID" }, - { 0x1002, "Public Browse Group" }, - { 0x1101, "Serial Port" }, - { 0x1102, "LAN Access Using PPP" }, - { 0x1103, "Dialup Networking" }, - { 0x1104, "IrMC Sync" }, - { 0x1105, "OBEX Object Push" }, - { 0x1106, "OBEX File Transfer" }, - { 0x1107, "IrMC Sync Command" }, - { 0x1108, "Headset" }, - { 0x1109, "Cordless Telephony" }, - { 0x110A, "Audio Source" }, - { 0x110B, "Audio Sink" }, - { 0x110C, "A/V Remote Control Target" }, - { 0x110D, "Advanced Audio Distribution" }, - { 0x110E, "A/V Remote Control" }, - { 0x110F, "A/V Remote Control Controller" }, - { 0x1110, "Intercom" }, - { 0x1111, "Fax" }, - { 0x1112, "Headset Audio Gateway" }, - { 0x1113, "WAP" }, - { 0x1114, "WAP Client" }, - { 0x1115, "PANU" }, - { 0x1116, "NAP" }, - { 0x1117, "GN" }, - { 0x1118, "Direct Printing" }, - { 0x1119, "Reference Printing" }, - { 0x111A, "Imaging" }, - { 0x111B, "Imaging Responder" }, - { 0x111C, "Imaging Automatic Archive" }, - { 0x111D, "Imaging Referenced Objects" }, - { 0x111E, "Handsfree" }, - { 0x111F, "Handsfree Audio Gateway" }, - { 0x1120, "Direct Printing Reference Objects Service" }, - { 0x1121, "Reflected UI" }, - { 0x1122, "Basic Printing" }, - { 0x1123, "Printing Status" }, - { 0x1124, "Human Interface Device Service" }, - { 0x1125, "Hardcopy Cable Replacement" }, - { 0x1126, "HCR Print" }, - { 0x1127, "HCR Scan" }, - { 0x1128, "Common ISDN Access" }, - { 0x1129, "Video Conferencing GW" }, - { 0x112A, "UDI MT" }, - { 0x112B, "UDI TA" }, - { 0x112C, "Audio/Video" }, - { 0x112D, "SIM Access" }, - { 0x112E, "Phonebook Access Client" }, - { 0x112F, "Phonebook Access Server" }, - { 0x1130, "Phonebook Access Profile" }, - { 0x1131, "Headset HS" }, - { 0x1132, "Message Access Server" }, - { 0x1133, "Message Notification Server" }, - { 0x1134, "Message Access Profile" }, - { 0x1135, "Global Navigation Satellite System" }, - { 0x1136, "Global Navigation Satellite System Server" }, - { 0x1137, "3D Display" }, - { 0x1138, "3D Glasses" }, - { 0x1139, "3D Synchronization Profile" }, - { 0x113A, "Multi-Profile" }, - { 0x113B, "Multi-Profile SC" }, - { 0x1200, "PnP Information" }, - { 0x1201, "Generic Networking" }, - { 0x1202, "Generic File Transfer" }, - { 0x1203, "Generic Audio" }, - { 0x1204, "Generic Telephony" }, - { 0x1205, "UPNP Service" }, - { 0x1206, "UPNP IP Service" }, - { 0x1300, "ESDP UPNP_IP PAN" }, - { 0x1301, "ESDP UPNP IP LAP" }, - { 0x1302, "ESDP UPNP L2CAP" }, - { 0x1303, "Video Source" }, - { 0x1304, "Video Sink" }, - { 0x1305, "Video Distribution" }, - { 0x1400, "Health Device Profile" }, - { 0x1401, "Health Device Source" }, - { 0x1402, "Health Device Sink" }, - /* LE Services - https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx */ - { 0x1800, "Generic Access Profile" }, - { 0x1801, "Generic Attribute Profile" }, - { 0x1802, "Immediate Alert" }, - { 0x1803, "Link Loss" }, - { 0x1804, "Tx Power" }, - { 0x1805, "Current Time Service" }, - { 0x1806, "Reference Time Update Service" }, - { 0x1807, "Next DST Change Service" }, - { 0x1808, "Glucose" }, - { 0x1809, "Health Thermometer" }, - { 0x180A, "Device Information" }, - { 0x180D, "Heart Rate" }, - { 0x180E, "Phone Alert Status Service" }, - { 0x180F, "Battery Service" }, - { 0x1810, "Blood Pressure" }, - { 0x1811, "Alert Notification Service" }, - { 0x1812, "Human Interface Device" }, - { 0x1813, "Scan Parameters" }, - { 0x1814, "Running Speed and Cadence" }, - { 0x1816, "Cycling Speed and Cadence" }, - { 0x1818, "Cycling Power" }, - { 0x1819, "Location and Navigation" }, - /* Units - http://developer.bluetooth.org/gatt/declarations/Pages/DeclarationsHome.aspx */ - { 0x2700, "unitless" }, - { 0x2701, "length (metre)" }, - { 0x2702, "mass (kilogram)" }, - { 0x2703, "time (second)" }, - { 0x2704, "electric current (ampere)" }, - { 0x2705, "thermodynamic temperature (kelvin)" }, - { 0x2706, "amount of substance (mole)" }, - { 0x2707, "luminous intensity (candela)" }, - { 0x2710, "area (square metres)" }, - { 0x2711, "volume (cubic metres)" }, - { 0x2712, "velocity (metres per second)" }, - { 0x2713, "acceleration (metres per second squared)" }, - { 0x2714, "wavenumber (reciprocal metre)" }, - { 0x2715, "density (kilogram per cubic metre)" }, - { 0x2716, "surface density (kilogram per square metre)" }, - { 0x2717, "specific volume (cubic metre per kilogram)" }, - { 0x2718, "current density (ampere per square metre)" }, - { 0x2719, "magnetic field strength (ampere per metre)" }, - { 0x271A, "amount concentration (mole per cubic metre)" }, - { 0x271B, "mass concentration (kilogram per cubic metre)" }, - { 0x271C, "luminance (candela per square metre)" }, - { 0x271D, "refractive index" }, - { 0x271E, "relative permeability" }, - { 0x2720, "plane angle (radian)" }, - { 0x2721, "solid angle (steradian)" }, - { 0x2722, "frequency (hertz)" }, - { 0x2723, "force (newton)" }, - { 0x2724, "pressure (pascal)" }, - { 0x2725, "energy (joule)" }, - { 0x2726, "power (watt)" }, - { 0x2727, "electric charge (coulomb)" }, - { 0x2728, "electric potential difference (volt)" }, - { 0x2729, "capacitance (farad)" }, - { 0x272A, "electric resistance (ohm)" }, - { 0x272B, "electric conductance (siemens)" }, - { 0x272C, "magnetic flex (weber)" }, - { 0x272D, "magnetic flex density (tesla)" }, - { 0x272E, "inductance (henry)" }, - { 0x272F, "Celsius temperature (degree Celsius)" }, - { 0x2730, "luminous flux (lumen)" }, - { 0x2731, "illuminance (lux)" }, - { 0x2732, "activity referred to a radionuclide (becquerel)" }, - { 0x2733, "absorbed dose (gray)" }, - { 0x2734, "dose equivalent (sievert)" }, - { 0x2735, "catalytic activity (katal)" }, - { 0x2740, "dynamic viscosity (pascal second)" }, - { 0x2741, "moment of force (newton metre)" }, - { 0x2742, "surface tension (newton per metre)" }, - { 0x2743, "angular velocity (radian per second)" }, - { 0x2744, "angular acceleration (radian per second squared)" }, - { 0x2745, "heat flux density (watt per square metre)" }, - { 0x2746, "heat capacity (joule per kelvin)" }, - { 0x2747, "specific heat capacity (joule per kilogram kelvin)" }, - { 0x2748, "specific energy (joule per kilogram)" }, - { 0x2749, "thermal conductivity (watt per metre kelvin)" }, - { 0x274A, "energy density (joule per cubic metre)" }, - { 0x274B, "electric field strength (volt per metre)" }, - { 0x274C, "electric charge density (coulomb per cubic metre)" }, - { 0x274D, "surface charge density (coulomb per square metre)" }, - { 0x274E, "electric flux density (coulomb per square metre)" }, - { 0x274F, "permittivity (farad per metre)" }, - { 0x2750, "permeability (henry per metre)" }, - { 0x2751, "molar energy (joule per mole)" }, - { 0x2752, "molar entropy (joule per mole kelvin)" }, - { 0x2753, "exposure (coulomb per kilogram)" }, - { 0x2754, "absorbed dose rate (gray per second)" }, - { 0x2755, "radiant intensity (watt per steradian)" }, - { 0x2756, "radiance (watt per square metre steradian)" }, - { 0x2757, "catalytic activity concentration (katal per cubic metre)" }, - { 0x2760, "time (minute)" }, - { 0x2761, "time (hour)" }, - { 0x2762, "time (day)" }, - { 0x2763, "plane angle (degree)" }, - { 0x2764, "plane angle (minute)" }, - { 0x2765, "plane angle (second)" }, - { 0x2766, "area (hectare)" }, - { 0x2767, "volume (litre)" }, - { 0x2768, "mass (tonne)" }, - { 0x2780, "pressure (bar)" }, - { 0x2781, "pressure (millimetre of mercury)" }, - { 0x2782, "length (angstrom)" }, - { 0x2783, "length (nautical mile)" }, - { 0x2784, "area (barn)" }, - { 0x2785, "velocity (knot)" }, - { 0x2786, "logarithmic radio quantity (neper)" }, - { 0x2787, "logarithmic radio quantity (bel)" }, - { 0x27A0, "length (yard)" }, - { 0x27A1, "length (parsec)" }, - { 0x27A2, "length (inch)" }, - { 0x27A3, "length (foot)" }, - { 0x27A4, "length (mile)" }, - { 0x27A5, "pressure (pound-force per square inch)" }, - { 0x27A6, "velocity (kilometre per hour)" }, - { 0x27A7, "velocity (mile per hour)" }, - { 0x27A8, "angular velocity (revolution per minute)" }, - { 0x27A9, "energy (gram calorie)" }, - { 0x27AA, "energy (kilogram calorie)" }, - { 0x27AB, "energy (kilowatt hour)" }, - { 0x27AC, "thermodynamic temperature (degree Fahrenheit)" }, - { 0x27AD, "percentage" }, - { 0x27AE, "per mille" }, - { 0x27AF, "period (beats per minute)" }, - { 0x27B0, "electric charge (ampere hours)" }, - { 0x27B1, "mass density (milligram per decilitre)" }, - { 0x27B2, "mass density (millimole per litre)" }, - { 0x27B3, "time (year)" }, - { 0x27B4, "time (month)" }, - { 0x27B5, "concentration (count per cubic metre)" }, - { 0x27B6, "irradiance (watt per square metre)" }, - { 0x27B7, "milliliter (per kilogram per minute)" }, - { 0x27B8, "mass (pound)" }, - /* Declarations - http://developer.bluetooth.org/gatt/declarations/Pages/DeclarationsHome.aspx */ - { 0x2800, "GATT Primary Service Declaration" }, - { 0x2801, "GATT Secondary Service Declaration" }, - { 0x2802, "GATT Include Declaration" }, - { 0x2803, "GATT Characteristic Declaration" }, - /* Descriptors - http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorsHomePage.aspx */ - { 0x2900, "Characteristic Extended Properties" }, - { 0x2901, "Characteristic User Description" }, - { 0x2902, "Client Characteristic Configuration" }, - { 0x2903, "Server Characteristic Configuration" }, - { 0x2904, "Characteristic Presentation Format" }, - { 0x2905, "Characteristic Aggregate Format" }, - { 0x2906, "Valid Range" }, - { 0x2907, "External Report Reference" }, - { 0x2908, "Report Reference" }, - /* Characteristics - http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicsHome.aspx */ - { 0x2A00, "Device Name" }, - { 0x2A01, "Appearance" }, - { 0x2A02, "Peripheral Privacy Flag" }, - { 0x2A03, "Reconnection Address" }, - { 0x2A04, "Peripheral Preferred Connection Parameters" }, - { 0x2A05, "Service Changed" }, - { 0x2A06, "Alert Level" }, - { 0x2A07, "Tx Power Level" }, - { 0x2A08, "Date Time" }, - { 0x2A09, "Day of Week" }, - { 0x2A0A, "Day Date Time" }, - { 0x2A0C, "Exact Time 256" }, - { 0x2A0D, "DST Offset" }, - { 0x2A0E, "Time Zone" }, - { 0x2A0F, "Local Time Information" }, - { 0x2A11, "Time with DST" }, - { 0x2A12, "Time Accuracy" }, - { 0x2A13, "Time Source" }, - { 0x2A14, "Reference Time Information" }, - { 0x2A16, "Time Update Control Point" }, - { 0x2A17, "Time Update State" }, - { 0x2A18, "Glucose Measurement" }, - { 0x2A19, "Battery Level" }, - { 0x2A1C, "Temperature Measurement" }, - { 0x2A1D, "Temperature Type" }, - { 0x2A1E, "Intermediate Temperature" }, - { 0x2A21, "Measurement Interval" }, - { 0x2A22, "Boot Keyboard Input Report" }, - { 0x2A23, "System ID" }, - { 0x2A24, "Model Number String" }, - { 0x2A25, "Serial Number String" }, - { 0x2A26, "Firmware Revision String" }, - { 0x2A27, "Hardware Revision String" }, - { 0x2A28, "Software Revision String" }, - { 0x2A29, "Manufacturer Name String" }, - { 0x2A2A, "IEEE 11073-20601 Regulatory Certification Data List" }, - { 0x2A2B, "Current Time" }, - { 0x2A31, "Scan Refresh" }, - { 0x2A32, "Boot Keyboard Output Report" }, - { 0x2A33, "Boot Mouse Input Report" }, - { 0x2A34, "Glucose Measurement Context" }, - { 0x2A35, "Blood Pressure Measurement" }, - { 0x2A36, "Intermediate Cuff Pressure" }, - { 0x2A37, "Heart Rate Measurement" }, - { 0x2A38, "Body Sensor Location" }, - { 0x2A39, "Heart Rate Control Point" }, - { 0x2A3F, "Alert Status" }, - { 0x2A40, "Ringer Control Point" }, - { 0x2A41, "Ringer Setting" }, - { 0x2A42, "Alert Category ID Bit Mask" }, - { 0x2A43, "Alert Category ID" }, - { 0x2A44, "Alert Notification Control Point" }, - { 0x2A45, "Unread Alert Status" }, - { 0x2A46, "New Alert" }, - { 0x2A47, "Supported New Alert Category" }, - { 0x2A48, "Supported Unread Alert Category" }, - { 0x2A49, "Blood Pressure Feature" }, - { 0x2A4A, "HID Information" }, - { 0x2A4B, "Report Map" }, - { 0x2A4C, "HID Control Point" }, - { 0x2A4D, "Report" }, - { 0x2A4E, "Protocol Mode" }, - { 0x2A4F, "Scan Interval Window" }, - { 0x2A50, "PnP ID" }, - { 0x2A51, "Glucose Feature" }, - { 0x2A52, "Record Access Control Point" }, - { 0x2A53, "RSC Measurement" }, - { 0x2A54, "RSC Feature" }, - { 0x2A55, "SC Control Point" }, - { 0x2A5B, "CSC Measurement" }, - { 0x2A5C, "CSC Feature" }, - { 0x2A5D, "Sensor Location" }, - { 0x2A63, "Cycling Power Measurement" }, - { 0x2A64, "Cycling Power Vector" }, - { 0x2A65, "Cycling Power Feature" }, - { 0x2A66, "Cycling Power Control Point" }, - { 0x2A67, "Location and Speed" }, - { 0x2A68, "Navigation" }, - { 0x2A69, "Position Quality" }, - { 0x2A6A, "LN Feature" }, - { 0x2A6B, "LN Control Point" }, - /* 16-bit UUID for Members - https://www.bluetooth.org/en-us/Pages/LoginRestrictedAll/16-bit-UUIDs-member.aspx */ - { 0xFEEE, "Company UUID #2: Polar Electro Oy"}, /* Allocated 06-Mar-14 */ - { 0xFEEF, "Company UUID #1: Polar Electro Oy"}, /* Allocated 06-Mar-14 */ - { 0xFEF0, "Company UUID: Intel"}, /* Allocated 06-Mar-14 */ - { 0xFEF1, "Company UUID #2: CSR"}, /* Allocated 13-Feb-14 */ - { 0xFEF2, "Company UUID #1: CSR"}, /* Allocated 13-Feb-14 */ - { 0xFEF3, "Company UUID #2: Google"}, /* Allocated 13-Feb-14 */ - { 0xFEF4, "Company UUID #1: Google"}, /* Allocated 13-Feb-14 */ - { 0xFEF5, "Company UUID: Dialog Semiconductor GmbH"}, /* Allocated 13-Feb-14 */ - { 0xFEF6, "Company UUID: Wicentric, Inc."}, /* Allocated 13-Feb-14 */ - { 0xFEF7, "Company UUID #2: Aplix Corporation"}, /* Allocated 13-Feb-14 */ - { 0xFEF8, "Company UUID #1: Aplix Corporation"}, /* Allocated 13-Feb-14 */ - { 0xFEF9, "Company UUID #2: PayPal, Inc."}, /* Allocated 13-Jan-14 */ - { 0xFEFA, "Company UUID #1: PayPal, Inc."}, /* Allocated 13-Jan-14 */ - { 0xFEFB, "Company UUID: Stollmann E+V GmbH"}, /* Allocated 06-Jan-14 */ - { 0xFEFC, "Company UUID #2: Qualcomm Retail Solutions, Inc."}, /* Allocated 20-Dec-13 */ - { 0xFEFD, "Company UUID #1: Qualcomm Retail Solutions, Inc."}, /* Allocated 20-Dec-13 */ - { 0xFEFE, "Company UUID: GN ReSound A/S"}, /* Allocated 17-Dec-13 */ - { 0xFEFF, "Company UUID: GN Netcom"}, /* Allocated 12-Dec-13 */ - /* SDO Uuids - https://www.bluetooth.org/en-us/specification/assigned-numbers/sdo-16-bit-uuids */ - { 0xFFFE, "Alliance for Wireless Power" }, - { 0, NULL } -}; -value_string_ext bt_sig_uuid_vals_ext = VALUE_STRING_EXT_INIT(bt_sig_uuid_vals); - static const value_string bthci_ogf_vals[] = { { 0x01, "Link Control Commands" }, { 0x02, "Link Policy Commands" }, @@ -1803,7 +1440,7 @@ static gpointer bthci_cmd_vendor_value(packet_info *pinfo _U_) static void save_local_device_name(tvbuff_t *tvb, gint offset, packet_info *pinfo, - guint8 size, hci_data_t *hci_data) + guint8 size, bluetooth_data_t *bluetooth_data) { gint i = 0; guint8 length; @@ -1814,7 +1451,7 @@ save_local_device_name(tvbuff_t *tvb, gint offset, packet_info *pinfo, gchar *name; localhost_name_entry_t *localhost_name_entry; - if (!(!pinfo->fd->flags.visited && hci_data)) return; + if (!(!pinfo->fd->flags.visited && bluetooth_data)) return; while (i < size) { length = tvb_get_guint8(tvb, offset + i); @@ -1825,8 +1462,8 @@ save_local_device_name(tvbuff_t *tvb, gint offset, packet_info *pinfo, case 0x09: /* Device Name, full */ name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + i + 2, length - 1, ENC_ASCII); - k_interface_id = hci_data->interface_id; - k_adapter_id = hci_data->adapter_id; + k_interface_id = bluetooth_data->interface_id; + k_adapter_id = bluetooth_data->adapter_id; k_frame_number = pinfo->fd->num; key[0].length = 1; @@ -1843,7 +1480,7 @@ save_local_device_name(tvbuff_t *tvb, gint offset, packet_info *pinfo, localhost_name_entry->adapter_id = k_adapter_id; localhost_name_entry->name = wmem_strdup(wmem_file_scope(), name); - wmem_tree_insert32_array(hci_data->localhost_name, key, localhost_name_entry); + wmem_tree_insert32_array(bluetooth_data->localhost_name, key, localhost_name_entry); break; } @@ -1908,7 +1545,8 @@ dissect_bthci_cmd_flow_spec(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, p } static int -dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint16 cmd_ocf) +dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *tree, guint16 cmd_ocf, bluetooth_data_t *bluetooth_data) { proto_item *item; guint32 clock_value; @@ -1941,7 +1579,10 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr break; case 0x0005: /* Create Connection */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + { + guint8 bd_addr[6]; + + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, bd_addr); proto_tree_add_item(tree, hf_bthci_cmd_packet_type_2dh1, tvb, offset, 2, ENC_LITTLE_ENDIAN); proto_tree_add_item(tree, hf_bthci_cmd_packet_type_3dh1, tvb, offset, 2, ENC_LITTLE_ENDIAN); @@ -1971,6 +1612,42 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr proto_tree_add_item(tree, hf_bthci_cmd_allow_role_switch, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; + + if (!pinfo->fd->flags.visited && bluetooth_data) { + guint32 interface_id; + guint32 adapter_id; + guint32 bd_addr_oui; + guint32 bd_addr_id; + guint32 frame_number; + wmem_tree_key_t key[6]; + device_role_t *device_role; + + interface_id = bluetooth_data->interface_id; + adapter_id = bluetooth_data->adapter_id; + frame_number = pinfo->fd->num; + bd_addr_oui = bd_addr[0] << 16 | bd_addr[1] << 8 | bd_addr[2]; + bd_addr_id = bd_addr[3] << 16 | bd_addr[4] << 8 | bd_addr[5]; + + key[0].length = 1; + key[0].key = &interface_id; + key[1].length = 1; + key[1].key = &adapter_id; + key[2].length = 1; + key[2].key = &bd_addr_id; + key[3].length = 1; + key[3].key = &bd_addr_oui; + key[4].length = 1; + key[4].key = &frame_number; + key[5].length = 0; + key[5].key = NULL; + + device_role = (device_role_t *) wmem_new(wmem_file_scope(), device_role_t); + device_role->change_in_frame = frame_number; + device_role->role = ROLE_SLAVE; + + wmem_tree_insert32_array(bluetooth_data->bdaddr_to_role, key, device_role); + } + } break; case 0x0006: /* Disconnect */ @@ -1993,11 +1670,56 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); break; - case 0x0009: /* Accept Connection Request */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + case 0x0009: /* Accept Connection Request */ { + guint8 bd_addr[6]; + guint8 role; + + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, bd_addr); proto_tree_add_item(tree, hf_bthci_cmd_role, tvb, offset, 1, ENC_LITTLE_ENDIAN); - offset++; + role = tvb_get_guint8(tvb, offset); + offset += 1; + + if (!pinfo->fd->flags.visited && bluetooth_data) { + guint32 interface_id; + guint32 adapter_id; + guint32 bd_addr_oui; + guint32 bd_addr_id; + guint32 frame_number; + wmem_tree_key_t key[6]; + device_role_t *device_role; + + interface_id = bluetooth_data->interface_id; + adapter_id = bluetooth_data->adapter_id; + frame_number = pinfo->fd->num; + bd_addr_oui = bd_addr[0] << 16 | bd_addr[1] << 8 | bd_addr[2]; + bd_addr_id = bd_addr[3] << 16 | bd_addr[4] << 8 | bd_addr[5]; + + key[0].length = 1; + key[0].key = &interface_id; + key[1].length = 1; + key[1].key = &adapter_id; + key[2].length = 1; + key[2].key = &bd_addr_id; + key[3].length = 1; + key[3].key = &bd_addr_oui; + key[4].length = 1; + key[4].key = &frame_number; + key[5].length = 0; + key[5].key = NULL; + + device_role = (device_role_t *) wmem_new(wmem_file_scope(), device_role_t); + device_role->change_in_frame = frame_number; + if (role == 0) + device_role->role = ROLE_SLAVE; + else if (role == 1) + device_role->role = ROLE_MASTER; + else + device_role->role = ROLE_UNKNOWN; + + wmem_tree_insert32_array(bluetooth_data->bdaddr_to_role, key, device_role); + } + } break; case 0x000a: /* Reject Connection Request */ @@ -2401,7 +2123,7 @@ dissect_link_policy_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto static int dissect_host_controller_baseband_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, - proto_tree *tree, guint16 cmd_ocf, hci_data_t *hci_data) + proto_tree *tree, guint16 cmd_ocf, bluetooth_data_t *bluetooth_data) { proto_item *item; guint16 timeout; @@ -2584,8 +2306,8 @@ dissect_host_controller_baseband_cmd(tvbuff_t *tvb, int offset, packet_info *pin gchar *name; localhost_name_entry_t *localhost_name_entry; - k_interface_id = hci_data->interface_id; - k_adapter_id = hci_data->adapter_id; + k_interface_id = bluetooth_data->interface_id; + k_adapter_id = bluetooth_data->adapter_id; k_frame_number = pinfo->fd->num; name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 248, ENC_ASCII); @@ -2604,7 +2326,7 @@ dissect_host_controller_baseband_cmd(tvbuff_t *tvb, int offset, packet_info *pin localhost_name_entry->adapter_id = k_adapter_id; localhost_name_entry->name = wmem_strdup(wmem_file_scope(), name); - wmem_tree_insert32_array(hci_data->localhost_name, key, localhost_name_entry); + wmem_tree_insert32_array(bluetooth_data->localhost_name, key, localhost_name_entry); } offset += 248; break; @@ -2827,7 +2549,7 @@ dissect_host_controller_baseband_cmd(tvbuff_t *tvb, int offset, packet_info *pin offset++; call_dissector(btcommon_eir_handle, tvb_new_subset_length(tvb, offset, 240), pinfo, tree); - save_local_device_name(tvb, offset, pinfo, 240, hci_data); + save_local_device_name(tvb, offset, pinfo, 240, bluetooth_data); offset += 240; break; @@ -3121,7 +2843,7 @@ dissect_testing_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tre } static gint -dissect_le_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint16 cmd_ocf, hci_data_t *hci_data) +dissect_le_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint16 cmd_ocf, bluetooth_data_t *bluetooth_data) { proto_item *item; proto_item *sub_item; @@ -3170,7 +2892,7 @@ dissect_le_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, offset++; call_dissector(btcommon_ad_handle, tvb_new_subset_length(tvb, offset, 31), pinfo, tree); - save_local_device_name(tvb, offset, pinfo, 31, hci_data); + save_local_device_name(tvb, offset, pinfo, 31, bluetooth_data); offset += 31; break; @@ -3341,22 +3063,22 @@ dissect_le_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, static gint dissect_bthci_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - proto_item *ti_cmd; - proto_tree *bthci_cmd_tree; - guint16 opcode; - guint16 ocf; - guint8 param_length; - guint8 ogf; - gint offset = 0; - proto_item *ti_opcode; - proto_tree *opcode_tree; - gint hfx; - hci_data_t *hci_data; + proto_item *ti_cmd; + proto_tree *bthci_cmd_tree; + guint16 opcode; + guint16 ocf; + guint8 param_length; + guint8 ogf; + gint offset = 0; + proto_item *ti_opcode; + proto_tree *opcode_tree; + gint hfx; + bluetooth_data_t *bluetooth_data; /* Reject the packet if data is NULL */ if (data == NULL) return 0; - hci_data = (hci_data_t *) data; + bluetooth_data = (bluetooth_data_t *) data; ti_cmd = proto_tree_add_item(tree, proto_bthci_cmd, tvb, offset, -1, ENC_NA); bthci_cmd_tree = proto_item_add_subtree(ti_cmd, ett_bthci_cmd); @@ -3374,8 +3096,23 @@ dissect_bthci_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; } - SET_ADDRESS(&pinfo->src, AT_STRINGZ, 5, "host"); - SET_ADDRESS(&pinfo->dst, AT_STRINGZ, 11, "controller"); + SET_ADDRESS(&pinfo->src, AT_STRINGZ, 5, "host"); + SET_ADDRESS(&pinfo->dst, AT_STRINGZ, 11, "controller"); + SET_ADDRESS(&pinfo->net_src, AT_STRINGZ, 5, "host"); + SET_ADDRESS(&pinfo->net_dst, AT_STRINGZ, 11, "controller"); + SET_ADDRESS(&pinfo->dl_src, AT_STRINGZ, 5, "host"); + SET_ADDRESS(&pinfo->dl_dst, AT_STRINGZ, 11, "controller"); + if (!pinfo->fd->flags.visited) { + address *addr; + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_src, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_src.data, pinfo->dl_src.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_SRC, addr); + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_dst, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_dst.data, pinfo->dl_dst.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_DST, addr); + } opcode = tvb_get_letohs(tvb, offset); ocf = opcode & 0x03ff; @@ -3418,7 +3155,7 @@ dissect_bthci_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat if (ogf == HCI_OGF_VENDOR_SPECIFIC) { col_append_fstr(pinfo->cinfo, COL_INFO, "Vendor Command 0x%04X (opcode 0x%04X)", ocf, opcode); - dissector_try_uint_new(vendor_dissector_table, HCI_VENDOR_DEFAULT, tvb, pinfo, tree, TRUE, hci_data); + dissector_try_uint_new(vendor_dissector_table, HCI_VENDOR_DEFAULT, tvb, pinfo, tree, TRUE, bluetooth_data); proto_tree_add_item(bthci_cmd_tree, hf_bthci_cmd_parameter, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_NA); @@ -3430,7 +3167,7 @@ dissect_bthci_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat if (param_length > 0) { switch (ogf) { case HCI_OGF_LINK_CONTROL: - offset = dissect_link_control_cmd(tvb, offset, pinfo, bthci_cmd_tree, ocf); + offset = dissect_link_control_cmd(tvb, offset, pinfo, bthci_cmd_tree, ocf, bluetooth_data); break; case HCI_OGF_LINK_POLICY: @@ -3438,7 +3175,7 @@ dissect_bthci_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case HCI_OGF_HOST_CONTROLLER: - offset = dissect_host_controller_baseband_cmd(tvb, offset, pinfo, bthci_cmd_tree, ocf, hci_data); + offset = dissect_host_controller_baseband_cmd(tvb, offset, pinfo, bthci_cmd_tree, ocf, bluetooth_data); break; case HCI_OGF_INFORMATIONAL: @@ -3454,7 +3191,7 @@ dissect_bthci_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case HCI_OGF_LOW_ENERGY: - offset = dissect_le_cmd(tvb, offset, pinfo, bthci_cmd_tree, ocf, hci_data); + offset = dissect_le_cmd(tvb, offset, pinfo, bthci_cmd_tree, ocf, bluetooth_data); break; default: @@ -5040,7 +4777,7 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) while (offset < end_offset) { if (tvb_get_ntohs(tvb, offset) == 0x0000) { sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_uuid_32, tvb, offset, 4, ENC_BIG_ENDIAN); - proto_item_append_text(sub_item, " (%s)", val_to_str_ext_const(tvb_get_ntohs(tvb, offset + 2), &bt_sig_uuid_vals_ext, "Unknown")); + proto_item_append_text(sub_item, " (%s)", val_to_str_ext_const(tvb_get_ntohs(tvb, offset + 2), &bluetooth_uuid_vals_ext, "Unknown")); } else { sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_custom_uuid, tvb, offset, 4, ENC_NA); @@ -5074,7 +4811,7 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvb_get_ntohl(tvb, offset + 4) == 0x1000 && tvb_get_ntoh64(tvb, offset + 8) == G_GUINT64_CONSTANT(0x800000805F9B34FB)) { sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_uuid_128, tvb, offset, 16, ENC_NA); - proto_item_append_text(sub_item, " (%s)", val_to_str_ext_const(tvb_get_ntohs(tvb, offset + 2), &bt_sig_uuid_vals_ext, "Unknown")); + proto_item_append_text(sub_item, " (%s)", val_to_str_ext_const(tvb_get_ntohs(tvb, offset + 2), &bluetooth_uuid_vals_ext, "Unknown")); } else { sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_custom_uuid, tvb, offset, 16, ENC_NA); @@ -5521,7 +5258,7 @@ proto_register_btcommon(void) }, { &hf_btcommon_eir_ad_company_id, { "Company ID", "btcommon.eir_ad.entry.company_id", - FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bthci_evt_comp_id_ext, 0x0, + FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x0, NULL, HFILL } }, { &hf_btcommon_eir_ad_flags_reserved, @@ -5556,12 +5293,12 @@ proto_register_btcommon(void) }, { &hf_btcommon_eir_ad_uuid_16, { "UUID 16", "btcommon.eir_ad.entry.uuid_16", - FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bt_sig_uuid_vals_ext, 0x0, + FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_uuid_vals_ext, 0x0, NULL, HFILL } }, { &hf_btcommon_eir_ad_uuid_32, { "UUID 32", "btcommon.eir_ad.entry.uuid_32", - FT_UINT32, BASE_HEX | BASE_EXT_STRING, &bt_sig_uuid_vals_ext, 0x0, + FT_UINT32, BASE_HEX | BASE_EXT_STRING, &bluetooth_uuid_vals_ext, 0x0, NULL, HFILL } }, { &hf_btcommon_eir_ad_uuid_128, @@ -5621,7 +5358,7 @@ proto_register_btcommon(void) }, { &hf_btcommon_eir_ad_did_vendor_id_bluetooth_sig, { "Vendor ID", "btcommon.eir_ad.entry.did.vendor_id", - FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bthci_evt_comp_id_ext, 0x0, + FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x0, NULL, HFILL } }, { &hf_btcommon_eir_ad_did_vendor_id_usb_forum, diff --git a/epan/dissectors/packet-bthci_evt.c b/epan/dissectors/packet-bthci_evt.c index 2befd8317c..ae17f8e41f 100644 --- a/epan/dissectors/packet-bthci_evt.c +++ b/epan/dissectors/packet-bthci_evt.c @@ -39,7 +39,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" #include "packet-sdp.h" static dissector_handle_t bthci_cmd_handle; @@ -514,201 +514,6 @@ static const value_string evt_hci_vers_nr[] = { {0, NULL } }; -/* Taken from https://www.bluetooth.org/technical/assignednumbers/identifiers.htm */ -static const value_string bthci_evt_comp_id[] = { - {0x0000, "Ericsson Technology Licensing"}, - {0x0001, "Nokia Mobile Phones"}, - {0x0002, "Intel Corp."}, - {0x0003, "IBM Corp."}, - {0x0004, "Toshiba Corp."}, - {0x0005, "3Com"}, - {0x0006, "Microsoft"}, - {0x0007, "Lucent"}, - {0x0008, "Motorola"}, - {0x0009, "Infineon Technologies AG"}, - {0x000A, "Cambridge Silicon Radio"}, - {0x000B, "Silicon Wave"}, - {0x000C, "Digianswer A/S"}, - {0x000D, "Texas Instruments Inc."}, - {0x000E, "Ceva, Inc. (formerly Parthus Technologies, Inc.)"}, - {0x000F, "Broadcom Corporation"}, - {0x0010, "Mitel Semiconductor"}, - {0x0011, "Widcomm, Inc."}, - {0x0012, "Zeevo, Inc."}, - {0x0013, "Atmel Corporation"}, - {0x0014, "Mitsubishi Electric Corporation"}, - {0x0015, "RTX Telecom A/S"}, - {0x0016, "KC Technology Inc."}, - {0x0017, "Newlogic"}, - {0x0018, "Transilica, Inc."}, - {0x0019, "Rohde & Schwarz GmbH & Co. KG"}, - {0x001A, "TTPCom Limited"}, - {0x001B, "Signia Technologies, Inc."}, - {0x001C, "Conexant Systems Inc."}, - {0x001D, "Qualcomm"}, - {0x001E, "Inventel"}, - {0x001F, "AVM Berlin"}, - {0x0020, "BandSpeed, Inc."}, - {0x0021, "Mansella Ltd"}, - {0x0022, "NEC Corporation"}, - {0x0023, "WavePlus Technology Co., Ltd."}, - {0x0024, "Alcatel"}, - {0x0025, "Philips Semiconductors"}, - {0x0026, "C Technologies"}, - {0x0027, "Open Interface"}, - {0x0028, "R F Micro Devices"}, - {0x0029, "Hitachi Ltd"}, - {0x002A, "Symbol Technologies, Inc."}, - {0x002B, "Tenovis"}, - {0x002C, "Macronix International Co. Ltd."}, - {0x002D, "GCT Semiconductor"}, - {0x002E, "Norwood Systems"}, - {0x002F, "MewTel Technology Inc."}, - {0x0030, "ST Microelectronics"}, - {0x0031, "Synopsys"}, - {0x0032, "Red-M (Communications) Ltd"}, - {0x0033, "Commil Ltd"}, - {0x0034, "Computer Access Technology Corporation (CATC)"}, - {0x0035, "Eclipse (HQ Espana) S.L."}, - {0x0036, "Renesas Technology Corp."}, - {0x0037, "Mobilian Corporation"}, - {0x0038, "Terax"}, - {0x0039, "Integrated System Solution Corp."}, - {0x003A, "Matsushita Electric Industrial Co., Ltd."}, - {0x003B, "Gennum Corporation"}, - {0x003C, "Research In Motion"}, - {0x003D, "IPextreme, Inc."}, - {0x003E, "Systems and Chips, Inc"}, - {0x003F, "Bluetooth SIG, Inc"}, - {0x0040, "Seiko Epson Corporation"}, - {0x0041, "Integrated Silicon Solution Taiwan, Inc."}, - {0x0042, "CONWISE Technology Corporation Ltd"}, - {0x0043, "PARROT SA"}, - {0x0044, "Socket Mobile"}, - {0x0045, "Atheros Communications, Inc."}, - {0x0046, "MediaTek, Inc."}, - {0x0047, "Bluegiga"}, - {0x0048, "Marvell Technology Group Ltd."}, - {0x0049, "3DSP Corporation"}, - {0x004A, "Accel Semiconductor Ltd."}, - {0x004B, "Continental Automotive Systems"}, - {0x004C, "Apple, Inc."}, - {0x004D, "Staccato Communications, Inc."}, - {0x004E, "Avago Technologies"}, - {0x004F, "APT Licensing Ltd."}, - {0x0050, "SiRF Technology, Inc."}, - {0x0051, "Tzero Technologies, Inc."}, - {0x0052, "J&M Corporation"}, - {0x0053, "Free2move AB"}, - {0x0054, "3DiJoy Corporation"}, - {0x0055, "Plantronics, Inc."}, - {0x0056, "Sony Ericsson Mobile Communications"}, - {0x0057, "Harman International Industries, Inc."}, - {0x0058, "Vizio, Inc."}, - {0x0059, "Nordic Semiconductor ASA"}, - {0x005A, "EM Microelectronic-Marin SA"}, - {0x005B, "Ralink Technology Corporation"}, - {0x005C, "Belkin International, Inc."}, - {0x005D, "Realtek Semiconductor Corporation"}, - {0x005E, "Stonestreet One, LLC"}, - {0x005F, "Wicentric, Inc."}, - {0x0060, "RivieraWaves S.A.S"}, - {0x0061, "RDA Microelectronics"}, - {0x0062, "Gibson Guitars"}, - {0x0063, "MiCommand Inc."}, - {0x0064, "Band XI International, LLC"}, - {0x0065, "Hewlett-Packard Company"}, - {0x0066, "9Solutions Oy"}, - {0x0067, "GN Netcom A/S"}, - {0x0068, "General Motors"}, - {0x0069, "A&D Engineering, Inc."}, - {0x006A, "MindTree Ltd."}, - {0x006B, "Polar Electro OY"}, - {0x006C, "Beautiful Enterprise Co., Ltd."}, - {0x006D, "BriarTek, Inc."}, - {0x006E, "Summit Data Communications, Inc."}, - {0x006F, "Sound ID"}, - {0x0070, "Monster, LLC"}, - {0x0071, "connectBlue AB"}, - {0x0072, "ShangHai Super Smart Electronics Co. Ltd."}, - {0x0073, "Group Sense Ltd."}, - {0x0074, "Zomm, LLC"}, - {0x0075, "Samsung Electronics Co. Ltd."}, - {0x0076, "Creative Technology Ltd."}, - {0x0077, "Laird Technologies"}, - {0x0078, "Nike, Inc."}, - {0x0079, "lesswire AG"}, - {0x007A, "MStar Semiconductor, Inc."}, - {0x007B, "Hanlynn Technologies"}, - {0x007C, "A & R Cambridge"}, - {0x007D, "Seers Technology Co. Ltd."}, - {0x007E, "Sports Tracking Technologies Ltd."}, - {0x007F, "Autonet Mobile"}, - {0x0080, "DeLorme Publishing Company, Inc."}, - {0x0081, "WuXi Vimicro"}, - {0x0082, "Sennheiser Communications A/S"}, - {0x0083, "TimeKeeping Systems, Inc."}, - {0x0084, "Ludus Helsinki Ltd."}, - {0x0085, "BlueRadios, Inc."}, - {0x0086, "equinux AG"}, - {0x0087, "Garmin International, Inc."}, - {0x0088, "Ecotest"}, - {0x0089, "GN ReSound A/S"}, - {0x008A, "Jawbone"}, - {0x008B, "Topcon Positioning Systems, LLC"}, - {0x008C, "Qualcomm Labs, Inc."}, - {0x008D, "Zscan Software"}, - {0x008E, "Quintic Corp."}, - {0x008F, "Stollmann E+V GmbH"}, - {0x0090, "Funai Electric Co., Ltd."}, - {0x0091, "Advanced PANMOBIL systems GmbH & Co. KG"}, - {0x0092, "ThinkOptics, Inc."}, - {0x0093, "Universal Electronics, Inc."}, - {0x0094, "Airoha Technology Corp."}, - {0x0095, "NEC Lighting, Ltd."}, - {0x0096, "ODM Technology, Inc."}, - {0x0097, "Bluetrek Technologies Limited"}, - {0x0098, "zero1.tv GmbH"}, - {0x0099, "i.Tech Dynamic Global Distribution Ltd."}, - {0x009A, "Alpwise"}, - {0x009B, "Jiangsu Toppower Automotive Electronics Co., Ltd."}, - {0x009C, "Colorfy, Inc."}, - {0x009D, "Geoforce Inc."}, - {0x009E, "Bose Corporation"}, - {0x009F, "Suunto Oy"}, - {0x00A0, "Kensington Computer Products Group"}, - {0x00A1, "SR-Medizinelektronik"}, - {0x00A2, "Vertu Corporation Limited"}, - {0x00A3, "Meta Watch Ltd."}, - {0x00A4, "LINAK A/S"}, - {0x00A5, "OTL Dynamics LLC"}, - {0x00A6, "Panda Ocean Inc."}, - {0x00A7, "Visteon Corporation"}, - {0x00A8, "ARP Devices Limited"}, - {0x00A9, "Magneti Marelli S.p.A."}, - {0x00AA, "CAEN RFID srl"}, - {0x00AB, "Ingenieur-Systemgruppe Zahn GmbH"}, - {0x00AC, "Green Throttle Games"}, - {0x00AD, "Peter Systemtechnik GmbH"}, - {0x00AE, "Omegawave Oy"}, - {0x00AF, "Cinetix"}, - {0x00B0, "Passif Semiconductor Corp"}, - {0x00B1, "Saris Cycling Group, Inc"}, - {0x00B2, "Bekey A/S"}, - {0x00B3, "Clarinox Technologies Pty. Ltd."}, - {0x00B4, "BDE Technology Co., Ltd."}, - {0x00B5, "Swirl Networks"}, - {0x00B6, "Meso international"}, - {0x00B7, "TreLab Ltd"}, - {0x00B8, "Qualcomm Innovation Center, Inc. (QuIC)"}, - {0x00B9, "Johnson Controls, Inc."}, - {0x00BA, "Starkey Laboratories Inc."}, - {0x00BB, "S-Power Electronics Limited"}, - {0xFFFF, "For use in internal and interoperability tests."}, - {0, NULL } -}; -value_string_ext bthci_evt_comp_id_ext = VALUE_STRING_EXT_INIT(bthci_evt_comp_id); - static const value_string evt_service_types[] = { {0x00, "No Traffic Available"}, {0x01, "Best Effort Available"}, @@ -900,18 +705,23 @@ static gpointer bthci_evt_vendor_value(packet_info *pinfo _U_) static void save_remote_device_name(tvbuff_t *tvb, gint offset, packet_info *pinfo, - guint8 size, guint8 *bd_addr, hci_data_t *hci_data) + guint8 size, guint8 *bd_addr, bluetooth_data_t *bluetooth_data) { gint i = 0; guint8 length; - wmem_tree_key_t key[4]; - guint32 k_bd_addr_oui; - guint32 k_bd_addr_id; - guint32 k_frame_number; + wmem_tree_key_t key[6]; + guint32 interface_id; + guint32 adapter_id; + guint32 bd_addr_oui; + guint32 bd_addr_id; + guint32 frame_number; gchar *name; device_name_t *device_name; - if (!(!pinfo->fd->flags.visited && hci_data && bd_addr)) return; + if (!(!pinfo->fd->flags.visited && bluetooth_data && bd_addr)) return; + + interface_id = bluetooth_data->interface_id; + adapter_id = bluetooth_data->adapter_id; while (i < size) { length = tvb_get_guint8(tvb, offset + i); @@ -922,25 +732,29 @@ save_remote_device_name(tvbuff_t *tvb, gint offset, packet_info *pinfo, case 0x09: /* Device Name, full */ name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + i + 2, length - 1, ENC_ASCII); - k_frame_number = pinfo->fd->num; - k_bd_addr_oui = bd_addr[0] << 16 | bd_addr[1] << 8 | bd_addr[2]; - k_bd_addr_id = bd_addr[3] << 16 | bd_addr[4] << 8 | bd_addr[5]; + frame_number = pinfo->fd->num; + bd_addr_oui = bd_addr[0] << 16 | bd_addr[1] << 8 | bd_addr[2]; + bd_addr_id = bd_addr[3] << 16 | bd_addr[4] << 8 | bd_addr[5]; key[0].length = 1; - key[0].key = &k_bd_addr_id; + key[0].key = &interface_id; key[1].length = 1; - key[1].key = &k_bd_addr_oui; + key[1].key = &adapter_id; key[2].length = 1; - key[2].key = &k_frame_number; - key[3].length = 0; - key[3].key = NULL; + key[2].key = &bd_addr_id; + key[3].length = 1; + key[3].key = &bd_addr_oui; + key[4].length = 1; + key[4].key = &frame_number; + key[5].length = 0; + key[5].key = NULL; device_name = (device_name_t *) wmem_new(wmem_file_scope(), device_name_t); device_name->bd_addr_oui = bd_addr[0] << 16 | bd_addr[1] << 8 | bd_addr[2]; device_name->bd_addr_id = bd_addr[3] << 16 | bd_addr[4] << 8 | bd_addr[5]; device_name->name = wmem_strdup(wmem_file_scope(), name); - wmem_tree_insert32_array(hci_data->bdaddr_to_name_table, key, device_name); + wmem_tree_insert32_array(bluetooth_data->bdaddr_to_name, key, device_name); break; } @@ -950,7 +764,7 @@ save_remote_device_name(tvbuff_t *tvb, gint offset, packet_info *pinfo, } static int -dissect_bthci_evt_inq_complete(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_inquire_complete(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) { proto_tree_add_item(tree, hf_bthci_evt_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; @@ -959,10 +773,10 @@ dissect_bthci_evt_inq_complete(tvbuff_t *tvb, int offset, packet_info *pinfo _U_ } static int -dissect_bthci_evt_conn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo, - proto_tree *tree, hci_data_t *hci_data) +dissect_bthci_evt_connect_complete(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *tree, bluetooth_data_t *bluetooth_data) { - guint16 connection_handle; + guint32 connection_handle; guint8 bd_addr[6]; guint8 status; @@ -975,7 +789,7 @@ dissect_bthci_evt_conn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo, offset += 2; offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, bd_addr); - if (!pinfo->fd->flags.visited && hci_data != NULL && status == 0x00) { + if (!pinfo->fd->flags.visited && bluetooth_data != NULL && status == 0x00) { wmem_tree_key_t key[5]; guint32 k_interface_id; guint32 k_adapter_id; @@ -983,9 +797,10 @@ dissect_bthci_evt_conn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 k_frame_number; remote_bdaddr_t *remote_bdaddr; chandle_session_t *chandle_session; + connection_mode_t *connection_mode; - k_interface_id = hci_data->interface_id; - k_adapter_id = hci_data->adapter_id; + k_interface_id = bluetooth_data->interface_id; + k_adapter_id = bluetooth_data->adapter_id; k_connection_handle = connection_handle; k_frame_number = pinfo->fd->num; @@ -1001,17 +816,23 @@ dissect_bthci_evt_conn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo, key[4].key = NULL; remote_bdaddr = (remote_bdaddr_t *) wmem_new(wmem_file_scope(), remote_bdaddr_t); - remote_bdaddr->interface_id = hci_data->interface_id; - remote_bdaddr->adapter_id = hci_data->adapter_id; + remote_bdaddr->interface_id = bluetooth_data->interface_id; + remote_bdaddr->adapter_id = bluetooth_data->adapter_id; remote_bdaddr->chandle = connection_handle; memcpy(remote_bdaddr->bd_addr, bd_addr, 6); - wmem_tree_insert32_array(hci_data->chandle_to_bdaddr_table, key, remote_bdaddr); + wmem_tree_insert32_array(bluetooth_data->chandle_to_bdaddr, key, remote_bdaddr); chandle_session = (chandle_session_t *) wmem_new(wmem_file_scope(), chandle_session_t); chandle_session->connect_in_frame = k_frame_number; - chandle_session->disconnect_in_frame = G_MAXUINT32; - wmem_tree_insert32_array(hci_data->chandle_sessions, key, chandle_session); + chandle_session->disconnect_in_frame = max_disconnect_in_frame; + wmem_tree_insert32_array(bluetooth_data->chandle_sessions, key, chandle_session); + + connection_mode = (connection_mode_t *) wmem_new(wmem_file_scope(), connection_mode_t); + connection_mode->mode = 0; + connection_mode->change_in_frame = k_frame_number; + + wmem_tree_insert32_array(bluetooth_data->chandle_to_mode, key, connection_mode); } proto_tree_add_item(tree, hf_bthci_evt_link_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -1024,7 +845,7 @@ dissect_bthci_evt_conn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo, } static int -dissect_bthci_evt_conn_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) +dissect_bthci_evt_connect_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) { offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); @@ -1038,8 +859,8 @@ dissect_bthci_evt_conn_request(tvbuff_t *tvb, int offset, packet_info *pinfo, pr } static int -dissect_bthci_evt_disconn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, - proto_tree *tree, hci_data_t *hci_data) +dissect_bthci_evt_disconnect_complete(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, + proto_tree *tree, bluetooth_data_t *bluetooth_data) { guint32 connection_handle; guint8 status; @@ -1055,15 +876,15 @@ dissect_bthci_evt_disconn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo proto_tree_add_item(tree, hf_bthci_evt_reason, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - if (!pinfo->fd->flags.visited && hci_data != NULL && status == 0x00) { + if (!pinfo->fd->flags.visited && bluetooth_data != NULL && status == 0x00) { wmem_tree_key_t key[4]; guint32 interface_id; guint32 adapter_id; chandle_session_t *chandle_session; wmem_tree_t *subtree; - interface_id = hci_data->interface_id; - adapter_id = hci_data->adapter_id; + interface_id = bluetooth_data->interface_id; + adapter_id = bluetooth_data->adapter_id; key[0].length = 1; key[0].key = &interface_id; @@ -1074,7 +895,7 @@ dissect_bthci_evt_disconn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo key[3].length = 0; key[3].key = NULL; - subtree = (wmem_tree_t *) wmem_tree_lookup32_array(hci_data->chandle_sessions, key); + subtree = (wmem_tree_t *) wmem_tree_lookup32_array(bluetooth_data->chandle_sessions, key); chandle_session = (subtree) ? (chandle_session_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL; if (chandle_session && chandle_session->connect_in_frame < pinfo->fd->num) chandle_session->disconnect_in_frame = pinfo->fd->num; @@ -1275,7 +1096,7 @@ dissect_bthci_evt_read_remote_support_features_complete(tvbuff_t *tvb, int offse static int dissect_bthci_evt_remote_name_req_complete(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, hci_data_t *hci_data) + packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { guint8 bd_addr[6]; @@ -1285,36 +1106,42 @@ dissect_bthci_evt_remote_name_req_complete(tvbuff_t *tvb, int offset, offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, bd_addr); proto_tree_add_item(tree, hf_bthci_evt_remote_name, tvb, offset, 248, ENC_ASCII|ENC_NA); - if (!pinfo->fd->flags.visited && hci_data != NULL) { - - wmem_tree_key_t key[4]; - guint32 k_bd_addr_oui; - guint32 k_bd_addr_id; - guint32 k_frame_number; + if (!pinfo->fd->flags.visited && bluetooth_data != NULL) { + wmem_tree_key_t key[6]; + guint32 interface_id; + guint32 adapter_id; + guint32 bd_addr_oui; + guint32 bd_addr_id; + guint32 frame_number; gchar *name; device_name_t *device_name; - name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 248, ENC_ASCII); - - k_frame_number = pinfo->fd->num; - k_bd_addr_oui = bd_addr[0] << 16 | bd_addr[1] << 8 | bd_addr[2]; - k_bd_addr_id = bd_addr[3] << 16 | bd_addr[4] << 8 | bd_addr[5]; + name = tvb_get_string_enc(wmem_file_scope(), tvb, offset, 248, ENC_ASCII); + interface_id = bluetooth_data->interface_id; + adapter_id = bluetooth_data->adapter_id; + frame_number = pinfo->fd->num; + bd_addr_oui = bd_addr[0] << 16 | bd_addr[1] << 8 | bd_addr[2]; + bd_addr_id = bd_addr[3] << 16 | bd_addr[4] << 8 | bd_addr[5]; key[0].length = 1; - key[0].key = &k_bd_addr_id; + key[0].key = &interface_id; key[1].length = 1; - key[1].key = &k_bd_addr_oui; + key[1].key = &adapter_id; key[2].length = 1; - key[2].key = &k_frame_number; - key[3].length = 0; - key[3].key = NULL; + key[2].key = &bd_addr_id; + key[3].length = 1; + key[3].key = &bd_addr_oui; + key[4].length = 1; + key[4].key = &frame_number; + key[5].length = 0; + key[5].key = NULL; device_name = (device_name_t *) wmem_new(wmem_file_scope(), device_name_t); device_name->bd_addr_oui = bd_addr[0] << 16 | bd_addr[1] << 8 | bd_addr[2]; device_name->bd_addr_id = bd_addr[3] << 16 | bd_addr[4] << 8 | bd_addr[5]; - device_name->name = wmem_strdup(wmem_file_scope(), name); + device_name->name = name; - wmem_tree_insert32_array(hci_data->bdaddr_to_name_table, key, device_name); + wmem_tree_insert32_array(bluetooth_data->bdaddr_to_name, key, device_name); } offset += 248; @@ -1373,37 +1200,120 @@ dissect_bthci_evt_number_of_completed_packets(tvbuff_t *tvb, int offset, packet_ } static int -dissect_bthci_evt_mode_change(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_mode_change(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *tree, bluetooth_data_t *bluetooth_data) { proto_item *handle_item; + guint32 connection_handle; + guint8 mode; + guint8 status; proto_tree_add_item(tree, hf_bthci_evt_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); + status = tvb_get_guint8(tvb, offset); offset += 1; proto_tree_add_item(tree, hf_bthci_evt_connection_handle, tvb, offset, 2, ENC_LITTLE_ENDIAN); + connection_handle = tvb_get_letohs(tvb, offset) & 0x0FFF; offset += 2; proto_tree_add_item(tree, hf_bthci_evt_curr_mode, tvb, offset, 1, ENC_LITTLE_ENDIAN); + mode = tvb_get_guint8(tvb, offset); offset += 1; handle_item = proto_tree_add_item(tree, hf_bthci_evt_interval, tvb, offset, 2, ENC_LITTLE_ENDIAN); proto_item_append_text(handle_item, " Baseband slots (%f msec)", tvb_get_letohs(tvb, offset)*0.625); offset += 2; + if (!pinfo->fd->flags.visited && bluetooth_data && status == 0x00) { + wmem_tree_key_t key[5]; + guint32 interface_id; + guint32 adapter_id; + guint32 frame_number; + connection_mode_t *connection_mode; + + interface_id = bluetooth_data->interface_id; + adapter_id = bluetooth_data->adapter_id; + frame_number = pinfo->fd->num; + + key[0].length = 1; + key[0].key = &interface_id; + key[1].length = 1; + key[1].key = &adapter_id; + key[2].length = 1; + key[2].key = &connection_handle; + key[3].length = 1; + key[3].key = &frame_number; + key[4].length = 0; + key[4].key = NULL; + + connection_mode = (connection_mode_t *) wmem_new(wmem_file_scope(), connection_mode_t); + connection_mode->mode = mode; + connection_mode->change_in_frame = frame_number; + + wmem_tree_insert32_array(bluetooth_data->chandle_to_mode, key, connection_mode); + } + return offset; } static int -dissect_bthci_evt_role_change(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_role_change(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, + proto_tree *tree, bluetooth_data_t *bluetooth_data) { + guint8 bd_addr[6]; + guint8 role; + guint8 status; + proto_tree_add_item(tree, hf_bthci_evt_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); + status = tvb_get_guint8(tvb, offset); offset += 1; - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, bd_addr); proto_tree_add_item(tree, hf_bthci_evt_role, tvb, offset, 1, ENC_LITTLE_ENDIAN); + role = tvb_get_guint8(tvb, offset); offset += 1; + if (!pinfo->fd->flags.visited && bluetooth_data && status == 0) { + guint32 interface_id; + guint32 adapter_id; + guint32 bd_addr_oui; + guint32 bd_addr_id; + guint32 frame_number; + wmem_tree_key_t key[6]; + device_role_t *device_role; + + interface_id = bluetooth_data->interface_id; + adapter_id = bluetooth_data->adapter_id; + frame_number = pinfo->fd->num; + bd_addr_oui = bd_addr[0] << 16 | bd_addr[1] << 8 | bd_addr[2]; + bd_addr_id = bd_addr[3] << 16 | bd_addr[4] << 8 | bd_addr[5]; + + key[0].length = 1; + key[0].key = &interface_id; + key[1].length = 1; + key[1].key = &adapter_id; + key[2].length = 1; + key[2].key = &bd_addr_id; + key[3].length = 1; + key[3].key = &bd_addr_oui; + key[4].length = 1; + key[4].key = &frame_number; + key[5].length = 0; + key[5].key = NULL; + + device_role = (device_role_t *) wmem_new(wmem_file_scope(), device_role_t); + device_role->change_in_frame = frame_number; + if (role == 0) + device_role->role = ROLE_SLAVE; + else if (role == 1) + device_role->role = ROLE_MASTER; + else + device_role->role = ROLE_UNKNOWN; + + wmem_tree_insert32_array(bluetooth_data->bdaddr_to_role, key, device_role); + } + return offset; } @@ -1418,12 +1328,12 @@ dissect_bthci_evt_hardware_error(tvbuff_t *tvb, int offset, packet_info *pinfo _ static int dissect_bthci_evt_loopback_command(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, hci_data_t *hci_data) + packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { tvbuff_t *next_tvb; next_tvb = tvb_new_subset_remaining(tvb, offset); - call_dissector_with_data(bthci_cmd_handle, next_tvb, pinfo, tree, hci_data); + call_dissector_with_data(bthci_cmd_handle, next_tvb, pinfo, tree, bluetooth_data); offset += tvb_length_remaining(tvb, offset); @@ -1552,7 +1462,8 @@ dissect_bthci_evt_conn_packet_type_changed(tvbuff_t *tvb, int offset, packet_inf } static int -dissect_bthci_evt_command_status(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *main_tree, proto_tree *tree, hci_data_t *hci_data) +dissect_bthci_evt_command_status(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *main_tree, proto_tree *tree, bluetooth_data_t *bluetooth_data) { proto_item *ti_opcode; proto_tree *opcode_tree; @@ -1605,7 +1516,7 @@ dissect_bthci_evt_command_status(tvbuff_t *tvb, int offset, packet_info *pinfo, if (ogf == HCI_OGF_VENDOR_SPECIFIC) { col_append_fstr(pinfo->cinfo, COL_INFO, " (Vendor Command 0x%04X [(opcode 0x%04X])", opcode & 0x03ff, opcode); - dissector_try_uint_new(vendor_dissector_table, HCI_VENDOR_DEFAULT, tvb, pinfo, main_tree, TRUE, hci_data); + dissector_try_uint_new(vendor_dissector_table, HCI_VENDOR_DEFAULT, tvb, pinfo, main_tree, TRUE, bluetooth_data); return tvb_captured_length(tvb); } else { @@ -1639,7 +1550,7 @@ dissect_bthci_evt_page_scan_repetition_mode_change(tvbuff_t *tvb, int offset, pa } static int -dissect_bthci_evt_inq_result_with_rssi(tvbuff_t *tvb, int offset, +dissect_bthci_evt_inquire_result_with_rssi(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *bd_addr) { guint8 num, evt_num_responses; @@ -1767,7 +1678,7 @@ dissect_bthci_evt_remote_host_sup_feat_notification(tvbuff_t *tvb, int offset, p static int dissect_bthci_evt_le_meta(tvbuff_t *tvb, int offset, packet_info *pinfo, - proto_tree *tree, hci_data_t *hci_data) + proto_tree *tree, bluetooth_data_t *bluetooth_data) { proto_item *item; guint8 subevent_code; @@ -1815,7 +1726,7 @@ dissect_bthci_evt_le_meta(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree_add_item(tree, hf_bthci_evt_le_master_clock_accuracy, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - if (!pinfo->fd->flags.visited && hci_data != NULL && status == 0x00) { + if (!pinfo->fd->flags.visited && bluetooth_data != NULL && status == 0x00) { wmem_tree_key_t key[5]; guint32 k_interface_id; guint32 k_adapter_id; @@ -1824,8 +1735,8 @@ dissect_bthci_evt_le_meta(tvbuff_t *tvb, int offset, packet_info *pinfo, remote_bdaddr_t *remote_bdaddr; chandle_session_t *chandle_session; - k_interface_id = hci_data->interface_id; - k_adapter_id = hci_data->adapter_id; + k_interface_id = bluetooth_data->interface_id; + k_adapter_id = bluetooth_data->adapter_id; k_connection_handle = connection_handle; k_frame_number = pinfo->fd->num; @@ -1841,17 +1752,17 @@ dissect_bthci_evt_le_meta(tvbuff_t *tvb, int offset, packet_info *pinfo, key[4].key = NULL; remote_bdaddr = (remote_bdaddr_t *) wmem_new(wmem_file_scope(), remote_bdaddr_t); - remote_bdaddr->interface_id = hci_data->interface_id; - remote_bdaddr->adapter_id = hci_data->adapter_id; + remote_bdaddr->interface_id = bluetooth_data->interface_id; + remote_bdaddr->adapter_id = bluetooth_data->adapter_id; remote_bdaddr->chandle = connection_handle; memcpy(remote_bdaddr->bd_addr, bd_addr, 6); - wmem_tree_insert32_array(hci_data->chandle_to_bdaddr_table, key, remote_bdaddr); + wmem_tree_insert32_array(bluetooth_data->chandle_to_bdaddr, key, remote_bdaddr); chandle_session = (chandle_session_t *) wmem_new(wmem_file_scope(), chandle_session_t); chandle_session->connect_in_frame = k_frame_number; - chandle_session->disconnect_in_frame = G_MAXUINT32; - wmem_tree_insert32_array(hci_data->chandle_sessions, key, chandle_session); + chandle_session->disconnect_in_frame = max_disconnect_in_frame; + wmem_tree_insert32_array(bluetooth_data->chandle_sessions, key, chandle_session); } break; @@ -1874,7 +1785,7 @@ dissect_bthci_evt_le_meta(tvbuff_t *tvb, int offset, packet_info *pinfo, if (length > 0) { call_dissector(btcommon_ad_handle, tvb_new_subset_length(tvb, offset, length), pinfo, tree); - save_remote_device_name(tvb, offset, pinfo, length, bd_addr, hci_data); + save_remote_device_name(tvb, offset, pinfo, length, bd_addr, bluetooth_data); offset += length; } @@ -1998,7 +1909,7 @@ dissect_bthci_evt_flow_spec_modify_complete(tvbuff_t *tvb, int offset, packet_in } static int -dissect_bthci_evt_num_completed_data_blocks(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_number_of_completed_data_blocks(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) { guint8 evt_num_handles; @@ -2074,7 +1985,7 @@ dissect_bthci_evt_amp_status_change(tvbuff_t *tvb, int offset, packet_info *pinf static int dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *main_tree, proto_tree *tree, hci_data_t *hci_data) + packet_info *pinfo, proto_tree *main_tree, proto_tree *tree, bluetooth_data_t *bluetooth_data) { proto_item *ti_opcode; proto_tree *opcode_tree; @@ -2123,7 +2034,7 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, if (ogf == HCI_OGF_VENDOR_SPECIFIC) { col_append_fstr(pinfo->cinfo, COL_INFO, " (Vendor Command 0x%04X [opcode 0x%04X])", opcode & 0x03ff, opcode); - dissector_try_uint_new(vendor_dissector_table, HCI_VENDOR_DEFAULT, tvb, pinfo, main_tree, TRUE, hci_data); + dissector_try_uint_new(vendor_dissector_table, HCI_VENDOR_DEFAULT, tvb, pinfo, main_tree, TRUE, bluetooth_data); proto_tree_add_item(tree, hf_bthci_evt_ret_params, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_NA); @@ -2227,15 +2138,15 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, offset += 1; offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, bd_addr); - if (!pinfo->fd->flags.visited && hci_data != NULL && local_addr) { + if (!pinfo->fd->flags.visited && bluetooth_data != NULL && local_addr) { wmem_tree_key_t key[4]; guint32 k_interface_id; guint32 k_adapter_id; guint32 k_frame_number; localhost_bdaddr_entry_t *localhost_bdaddr_entry; - k_interface_id = hci_data->interface_id; - k_adapter_id = hci_data->adapter_id; + k_interface_id = bluetooth_data->interface_id; + k_adapter_id = bluetooth_data->adapter_id; k_frame_number = pinfo->fd->num; key[0].length = 1; @@ -2251,7 +2162,7 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, localhost_bdaddr_entry->interface_id = k_interface_id; localhost_bdaddr_entry->adapter_id = k_adapter_id; memcpy(localhost_bdaddr_entry->bd_addr, bd_addr, 6); - wmem_tree_insert32_array(hci_data->localhost_bdaddr, key, localhost_bdaddr_entry); + wmem_tree_insert32_array(bluetooth_data->localhost_bdaddr, key, localhost_bdaddr_entry); } break; @@ -2425,7 +2336,7 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, offset += 1; proto_tree_add_item(tree, hf_bthci_evt_device_name, tvb, offset, 248, ENC_ASCII|ENC_NA); - if (!pinfo->fd->flags.visited && hci_data != NULL) { + if (!pinfo->fd->flags.visited && bluetooth_data != NULL) { wmem_tree_key_t key[4]; guint32 k_interface_id; guint32 k_adapter_id; @@ -2433,8 +2344,8 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, gchar *name; localhost_name_entry_t *localhost_name_entry; - k_interface_id = hci_data->interface_id; - k_adapter_id = hci_data->adapter_id; + k_interface_id = bluetooth_data->interface_id; + k_adapter_id = bluetooth_data->adapter_id; k_frame_number = pinfo->fd->num; name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 248, ENC_ASCII); @@ -2453,7 +2364,7 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, localhost_name_entry->adapter_id = k_adapter_id; localhost_name_entry->name = wmem_strdup(wmem_file_scope(), name); - wmem_tree_insert32_array(hci_data->localhost_name, key, localhost_name_entry); + wmem_tree_insert32_array(bluetooth_data->localhost_name, key, localhost_name_entry); } offset += 248; @@ -3180,7 +3091,7 @@ dissect_bthci_evt_read_remote_ext_features_complete(tvbuff_t *tvb, int offset, p static int dissect_bthci_evt_sync_connection_complete(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, hci_data_t *hci_data) + packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { proto_item *item; guint16 connection_handle; @@ -3226,8 +3137,8 @@ dissect_bthci_evt_sync_connection_complete(tvbuff_t *tvb, int offset, guint32 k_frame_number; remote_bdaddr_t *remote_bdaddr; - k_interface_id = hci_data->interface_id; - k_adapter_id = hci_data->adapter_id; + k_interface_id = bluetooth_data->interface_id; + k_adapter_id = bluetooth_data->adapter_id; k_connection_handle = connection_handle; k_frame_number = pinfo->fd->num; @@ -3243,12 +3154,12 @@ dissect_bthci_evt_sync_connection_complete(tvbuff_t *tvb, int offset, key[4].key = NULL; remote_bdaddr = (remote_bdaddr_t *) wmem_new(wmem_file_scope(), remote_bdaddr_t); - remote_bdaddr->interface_id = hci_data->interface_id; - remote_bdaddr->adapter_id = hci_data->adapter_id; + remote_bdaddr->interface_id = bluetooth_data->interface_id; + remote_bdaddr->adapter_id = bluetooth_data->adapter_id; remote_bdaddr->chandle = connection_handle; memcpy(remote_bdaddr->bd_addr, bd_addr, 6); - wmem_tree_insert32_array(hci_data->chandle_to_bdaddr_table, key, remote_bdaddr); + wmem_tree_insert32_array(bluetooth_data->chandle_to_bdaddr, key, remote_bdaddr); } return offset; @@ -3382,7 +3293,7 @@ dissect_bthci_evt_link_supervision_timeout_changed(tvbuff_t *tvb, int offset, pa } static int -dissect_bthci_evt_inq_result(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) +dissect_bthci_evt_inquire_result(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) { guint8 num, evt_num_responses; @@ -3417,18 +3328,18 @@ dissect_bthci_evt_inq_result(tvbuff_t *tvb, int offset, packet_info *pinfo, prot static gint dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - proto_item *ti; - proto_tree *bthci_evt_tree; - guint8 param_length, evt_code; - guint8 bd_addr[6]; - gint offset = 0; - gint previous_offset = 0; - hci_data_t *hci_data; + proto_item *ti; + proto_tree *bthci_evt_tree; + guint8 param_length, evt_code; + guint8 bd_addr[6]; + gint offset = 0; + gint previous_offset = 0; + bluetooth_data_t *bluetooth_data; /* Reject the packet if data is NULL */ if (data == NULL) return 0; - hci_data = (hci_data_t *) data; + bluetooth_data = (bluetooth_data_t *) data; ti = proto_tree_add_item(tree, proto_bthci_evt, tvb, offset, -1, ENC_NA); bthci_evt_tree = proto_item_add_subtree(ti, ett_bthci_evt); @@ -3446,8 +3357,23 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; } - SET_ADDRESS(&pinfo->src, AT_STRINGZ, 11, "controller"); - SET_ADDRESS(&pinfo->dst, AT_STRINGZ, 5, "host"); + SET_ADDRESS(&pinfo->src, AT_STRINGZ, 11, "controller"); + SET_ADDRESS(&pinfo->dst, AT_STRINGZ, 5, "host"); + SET_ADDRESS(&pinfo->net_src, AT_STRINGZ, 11, "controller"); + SET_ADDRESS(&pinfo->net_dst, AT_STRINGZ, 5, "host"); + SET_ADDRESS(&pinfo->dl_src, AT_STRINGZ, 11, "controller"); + SET_ADDRESS(&pinfo->dl_dst, AT_STRINGZ, 5, "host"); + if (!pinfo->fd->flags.visited) { + address *addr; + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_src, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_src.data, pinfo->dl_src.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_SRC, addr); + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_dst, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_dst.data, pinfo->dl_dst.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_DST, addr); + } evt_code = tvb_get_guint8(tvb, offset); proto_tree_add_item(bthci_evt_tree, hf_bthci_evt_code, tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -3466,23 +3392,23 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat if (param_length > 0) { switch(evt_code) { case 0x01: /* Inquiry Complete */ - offset = dissect_bthci_evt_inq_complete(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_inquire_complete(tvb, offset, pinfo, bthci_evt_tree); break; case 0x02: /* Inquiry result event */ - offset = dissect_bthci_evt_inq_result(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_inquire_result(tvb, offset, pinfo, bthci_evt_tree); break; case 0x03: /* Connection Complete */ - offset = dissect_bthci_evt_conn_complete(tvb, offset, pinfo, bthci_evt_tree, hci_data); + offset = dissect_bthci_evt_connect_complete(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x04: /* Connection Request */ - offset = dissect_bthci_evt_conn_request(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_connect_request(tvb, offset, pinfo, bthci_evt_tree); break; case 0x05: /* Disconnection Complete */ - offset = dissect_bthci_evt_disconn_complete(tvb, offset, pinfo, bthci_evt_tree, hci_data); + offset = dissect_bthci_evt_disconnect_complete(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x06: /* Authentication Complete */ @@ -3490,7 +3416,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x07: /* Remote Name Request Complete */ - offset = dissect_bthci_evt_remote_name_req_complete(tvb, offset, pinfo, bthci_evt_tree, hci_data); + offset = dissect_bthci_evt_remote_name_req_complete(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x08: /* Encryption Change */ @@ -3518,11 +3444,11 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x0e: /* Command Complete */ - offset = dissect_bthci_evt_command_complete(tvb, offset, pinfo, tree, bthci_evt_tree, hci_data); + offset = dissect_bthci_evt_command_complete(tvb, offset, pinfo, tree, bthci_evt_tree, bluetooth_data); break; case 0x0f: /* Command Status */ - offset = dissect_bthci_evt_command_status(tvb, offset, pinfo, tree, bthci_evt_tree, hci_data); + offset = dissect_bthci_evt_command_status(tvb, offset, pinfo, tree, bthci_evt_tree, bluetooth_data); break; case 0x10: /* Hardware Error */ @@ -3534,7 +3460,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x12: /* Role Change */ - offset = dissect_bthci_evt_role_change(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_role_change(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x13: /* Number Of Completed Packets */ @@ -3542,7 +3468,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x14: /* Mode Change */ - offset = dissect_bthci_evt_mode_change(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_mode_change(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x15: /* Return Link Keys */ @@ -3562,7 +3488,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x19: /* Loopback Command */ - offset = dissect_bthci_evt_loopback_command(tvb, offset, pinfo, bthci_evt_tree, hci_data); + offset = dissect_bthci_evt_loopback_command(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x1a: /* Data Buffer Overflow */ @@ -3598,7 +3524,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x22: /* Inquiry Result with RSSI */ - offset = dissect_bthci_evt_inq_result_with_rssi(tvb, offset, pinfo, bthci_evt_tree, NULL); + offset = dissect_bthci_evt_inquire_result_with_rssi(tvb, offset, pinfo, bthci_evt_tree, NULL); break; case 0x23: /* Read Remote Extended Features Complete */ @@ -3606,7 +3532,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x2c: /* Synchronous Connection Complete */ - offset = dissect_bthci_evt_sync_connection_complete(tvb, offset, pinfo, bthci_evt_tree, hci_data); + offset = dissect_bthci_evt_sync_connection_complete(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x2d: /* Synchronous Connection Changed */ @@ -3619,10 +3545,10 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat case 0x2f: /* Extended Inquiry Result */ previous_offset = offset; - offset = dissect_bthci_evt_inq_result_with_rssi(tvb, offset, pinfo, bthci_evt_tree, bd_addr); + offset = dissect_bthci_evt_inquire_result_with_rssi(tvb, offset, pinfo, bthci_evt_tree, bd_addr); call_dissector(btcommon_eir_handle, tvb_new_subset_length(tvb, offset, 240), pinfo, bthci_evt_tree); - save_remote_device_name(tvb, offset, pinfo, 240, (offset - previous_offset <= 1) ? NULL : bd_addr, hci_data); + save_remote_device_name(tvb, offset, pinfo, 240, (offset - previous_offset <= 1) ? NULL : bd_addr, bluetooth_data); offset += 240; break; @@ -3676,7 +3602,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x3e: /* LE Meta */ - offset = dissect_bthci_evt_le_meta(tvb, offset, pinfo, bthci_evt_tree, hci_data); + offset = dissect_bthci_evt_le_meta(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x40: /* Physical Link Complete */ @@ -3709,7 +3635,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x48: /* Number Of Completed Data Blocks */ - offset = dissect_bthci_evt_num_completed_data_blocks(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_number_of_completed_data_blocks(tvb, offset, pinfo, bthci_evt_tree); break; case 0x49: /* AMP Start Test */ @@ -3745,7 +3671,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0xff: /* Vendor-Specific */ - dissector_try_uint_new(vendor_dissector_table, HCI_VENDOR_DEFAULT, tvb, pinfo, tree, TRUE, hci_data); + dissector_try_uint_new(vendor_dissector_table, HCI_VENDOR_DEFAULT, tvb, pinfo, tree, TRUE, bluetooth_data); proto_tree_add_expert(bthci_evt_tree, pinfo, &ei_event_undecoded, tvb, offset, tvb_captured_length_remaining(tvb, offset)); @@ -3927,7 +3853,7 @@ proto_register_bthci_evt(void) }, { &hf_bthci_evt_comp_id, { "Manufacturer Name", "bthci_evt.comp_id", - FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bthci_evt_comp_id_ext, 0x0, + FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x0, "Manufacturer Name of Bluetooth Hardware", HFILL } }, { &hf_bthci_evt_sub_vers_nr, diff --git a/epan/dissectors/packet-bthci_sco.c b/epan/dissectors/packet-bthci_sco.c index 8e9d57e96d..0bb1b02cd5 100644 --- a/epan/dissectors/packet-bthci_sco.c +++ b/epan/dissectors/packet-bthci_sco.c @@ -31,7 +31,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" /* Initialize the protocol and registered fields */ static int proto_bthci_sco = -1; @@ -51,12 +51,12 @@ void proto_reg_handoff_bthci_sco(void); static gint dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data) { - proto_item *ti; - proto_tree *bthci_sco_tree; - gint offset = 0; - guint16 flags; - hci_data_t *hci_data; - wmem_tree_key_t key[5]; + proto_item *ti; + proto_tree *bthci_sco_tree; + gint offset = 0; + guint16 flags; + bluetooth_data_t *bluetooth_data; + wmem_tree_key_t key[6]; guint32 k_connection_handle; guint32 k_frame_number; guint32 k_interface_id; @@ -93,11 +93,11 @@ dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void proto_tree_add_item(bthci_sco_tree, hf_bthci_sco_length, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; - hci_data = (hci_data_t *) data; - DISSECTOR_ASSERT(hci_data); + bluetooth_data = (bluetooth_data_t *) data; + DISSECTOR_ASSERT(bluetooth_data); - k_interface_id = hci_data->interface_id; - k_adapter_id = hci_data->adapter_id; + k_interface_id = bluetooth_data->interface_id; + k_adapter_id = bluetooth_data->adapter_id; k_connection_handle = flags & 0x0fff; k_frame_number = pinfo->fd->num; @@ -113,9 +113,9 @@ dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void key[4].key = NULL; /* remote bdaddr and name */ - remote_bdaddr = (remote_bdaddr_t *)wmem_tree_lookup32_array_le(hci_data->chandle_to_bdaddr_table, key); - if (remote_bdaddr && remote_bdaddr->interface_id == hci_data->interface_id && - remote_bdaddr->adapter_id == hci_data->adapter_id && + remote_bdaddr = (remote_bdaddr_t *)wmem_tree_lookup32_array_le(bluetooth_data->chandle_to_bdaddr, key); + if (remote_bdaddr && remote_bdaddr->interface_id == bluetooth_data->interface_id && + remote_bdaddr->adapter_id == bluetooth_data->adapter_id && remote_bdaddr->chandle == (flags & 0x0fff)) { guint32 k_bd_addr_oui; guint32 k_bd_addr_id; @@ -135,15 +135,19 @@ dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void k_frame_number = pinfo->fd->num; key[0].length = 1; - key[0].key = &k_bd_addr_id; + key[0].key = &k_interface_id; key[1].length = 1; - key[1].key = &k_bd_addr_oui; + key[1].key = &k_adapter_id; key[2].length = 1; - key[2].key = &k_frame_number; - key[3].length = 0; - key[3].key = NULL; - - device_name = (device_name_t *)wmem_tree_lookup32_array_le(hci_data->bdaddr_to_name_table, key); + key[2].key = &k_bd_addr_id; + key[3].length = 1; + key[3].key = &k_bd_addr_oui; + key[4].length = 1; + key[4].key = &k_frame_number; + key[5].length = 0; + key[5].key = NULL; + + device_name = (device_name_t *)wmem_tree_lookup32_array_le(bluetooth_data->bdaddr_to_name, key); if (device_name && device_name->bd_addr_oui == bd_addr_oui && device_name->bd_addr_id == bd_addr_id) remote_name = device_name->name; else @@ -176,8 +180,8 @@ dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void } } - k_interface_id = hci_data->interface_id; - k_adapter_id = hci_data->adapter_id; + k_interface_id = bluetooth_data->interface_id; + k_adapter_id = bluetooth_data->adapter_id; k_frame_number = pinfo->fd->num; /* localhost bdaddr and name */ @@ -191,9 +195,9 @@ dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void key[3].key = NULL; - localhost_bdaddr_entry = (localhost_bdaddr_entry_t *)wmem_tree_lookup32_array_le(hci_data->localhost_bdaddr, key); - if (localhost_bdaddr_entry && localhost_bdaddr_entry->interface_id == hci_data->interface_id && - localhost_bdaddr_entry->adapter_id == hci_data->adapter_id) { + localhost_bdaddr_entry = (localhost_bdaddr_entry_t *)wmem_tree_lookup32_array_le(bluetooth_data->localhost_bdaddr, key); + if (localhost_bdaddr_entry && localhost_bdaddr_entry->interface_id == bluetooth_data->interface_id && + localhost_bdaddr_entry->adapter_id == bluetooth_data->adapter_id) { localhost_ether_addr = get_ether_name(localhost_bdaddr_entry->bd_addr); memcpy(localhost_bdaddr, localhost_bdaddr_entry->bd_addr, 6); @@ -203,9 +207,9 @@ dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void memset(localhost_bdaddr, 0, 6); } - localhost_name_entry = (localhost_name_entry_t *)wmem_tree_lookup32_array_le(hci_data->localhost_name, key); - if (localhost_name_entry && localhost_name_entry->interface_id == hci_data->interface_id && - localhost_name_entry->adapter_id == hci_data->adapter_id) + localhost_name_entry = (localhost_name_entry_t *)wmem_tree_lookup32_array_le(bluetooth_data->localhost_name, key); + if (localhost_name_entry && localhost_name_entry->interface_id == bluetooth_data->interface_id && + localhost_name_entry->adapter_id == bluetooth_data->adapter_id) localhost_name = localhost_name_entry->name; else localhost_name = ""; diff --git a/epan/dissectors/packet-btl2cap.c b/epan/dissectors/packet-btl2cap.c index 2e30c9e5d8..054c679c11 100644 --- a/epan/dissectors/packet-btl2cap.c +++ b/epan/dissectors/packet-btl2cap.c @@ -34,7 +34,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" #include "packet-bthci_acl.h" #include "packet-btsdp.h" #include "packet-btl2cap.h" @@ -158,8 +158,6 @@ static dissector_table_t l2cap_service_dissector_table; */ static wmem_tree_t *cid_to_psm_table = NULL; -static guint32 max_disconnect_in_frame = G_MAXUINT32; - typedef struct _config_data_t { guint8 mode; guint8 txwindow; @@ -620,7 +618,7 @@ dissect_connrequest(tvbuff_t *tvb, int offset, packet_info *pinfo, uuid = get_service_uuid(pinfo, l2cap_data, psm, (pinfo->p2p_dir == P2P_DIR_RECV) ? TRUE : FALSE); if (uuid) { - psm_str = val_to_str_ext_const(uuid, &bt_sig_uuid_vals_ext, "Unknown PSM"); + psm_str = val_to_str_ext_const(uuid, &bluetooth_uuid_vals_ext, "Unknown PSM"); proto_item_append_text(item, " (%s)", psm_str); } } @@ -681,7 +679,7 @@ dissect_connrequest(tvbuff_t *tvb, int offset, packet_info *pinfo, psm_data->interface_id = k_interface_id; psm_data->adapter_id = k_adapter_id; psm_data->chandle = k_chandle; - psm_data->disconnect_in_frame = G_MAXUINT32; + psm_data->disconnect_in_frame = max_disconnect_in_frame; key[0].length = 1; key[0].key = &k_interface_id; @@ -1415,7 +1413,7 @@ dissect_disconnrequestresponse(tvbuff_t *tvb, int offset, packet_info *pinfo, psm_data->adapter_id == adapter_id && psm_data->chandle == chandle && psm_data->remote_cid == key_dcid && - psm_data->disconnect_in_frame == G_MAXUINT32) { + psm_data->disconnect_in_frame == max_disconnect_in_frame) { psm_data->disconnect_in_frame = pinfo->fd->num; } @@ -1443,7 +1441,7 @@ dissect_disconnrequestresponse(tvbuff_t *tvb, int offset, packet_info *pinfo, psm_data->adapter_id == adapter_id && psm_data->chandle == chandle && psm_data->local_cid == key_scid && - psm_data->disconnect_in_frame == G_MAXUINT32) { + psm_data->disconnect_in_frame == max_disconnect_in_frame) { psm_data->disconnect_in_frame = pinfo->fd->num; } } @@ -1494,7 +1492,7 @@ dissect_b_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, psm_item = proto_tree_add_uint(btl2cap_tree, hf_btl2cap_psm_dynamic, tvb, offset, 0, psm); if (uuid) proto_item_append_text(psm_item, ": %s", - val_to_str_ext_const(uuid, &bt_sig_uuid_vals_ext, "Unknown service")); + val_to_str_ext_const(uuid, &bluetooth_uuid_vals_ext, "Unknown service")); } PROTO_ITEM_SET_GENERATED(psm_item); @@ -1668,7 +1666,7 @@ dissect_i_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, psm_item = proto_tree_add_uint(btl2cap_tree, hf_btl2cap_psm_dynamic, tvb, offset, 0, psm); if (uuid) proto_item_append_text(psm_item, " (%s)", - val_to_str_ext_const(uuid, &bt_sig_uuid_vals_ext, "Unknown service")); + val_to_str_ext_const(uuid, &bluetooth_uuid_vals_ext, "Unknown service")); } PROTO_ITEM_SET_GENERATED(psm_item); diff --git a/epan/dissectors/packet-btle.c b/epan/dissectors/packet-btle.c index 057a09c802..5c2a626f4e 100644 --- a/epan/dissectors/packet-btle.c +++ b/epan/dissectors/packet-btle.c @@ -32,14 +32,17 @@ #include #include +#include "packet-bluetooth.h" #include "packet-btle.h" -#include "packet-bluetooth-hci.h" #include "packet-bthci_acl.h" +#include "packet-ubertooth.h" static int proto_btle = -1; static int hf_access_address = -1; static int hf_crc = -1; +static int hf_master_bd_addr = -1; +static int hf_slave_bd_addr = -1; static int hf_advertising_header = -1; static int hf_advertising_header_pdu_type = -1; static int hf_advertising_header_rfu_1 = -1; @@ -131,6 +134,17 @@ static dissector_handle_t btcommon_ad_handle; static dissector_handle_t btcommon_le_channel_map_handle; static dissector_handle_t btl2cap_handle; +static wmem_tree_t *connection_addresses = NULL; + +typedef struct _connection_address_t { + guint32 interface_id; + guint32 adapter_id; + guint32 access_address; + + guint8 master_bd_addr[6]; + guint8 slave_bd_addr[6]; +} connection_address_t; + static const value_string pdu_type_vals[] = { { 0x00, "ADV_IND" }, { 0x01, "ADV_DIRECT_IND" }, @@ -200,28 +214,6 @@ static value_string_ext ll_version_number_vals_ext = VALUE_STRING_EXT_INIT(ll_ve void proto_register_btle(void); void proto_reg_handoff_btle(void); - -gint -dissect_bd_addr(gint hf_bd_addr, proto_tree *tree, tvbuff_t *tvb, gint offset, guint8 *bdaddr) -{ - guint8 bd_addr[6]; - - bd_addr[5] = tvb_get_guint8(tvb, offset); - bd_addr[4] = tvb_get_guint8(tvb, offset + 1); - bd_addr[3] = tvb_get_guint8(tvb, offset + 2); - bd_addr[2] = tvb_get_guint8(tvb, offset + 3); - bd_addr[1] = tvb_get_guint8(tvb, offset + 4); - bd_addr[0] = tvb_get_guint8(tvb, offset + 5); - - proto_tree_add_ether(tree, hf_bd_addr, tvb, offset, 6, bd_addr); - offset += 6; - - if (bdaddr) - memcpy(bdaddr, bd_addr, 6); - - return offset; -} - /* * Implements Bluetooth Vol 6, Part B, Section 3.1.1 (ref Figure 3.2) * @@ -312,24 +304,37 @@ reverse_bits_per_byte(const guint32 val) static gint dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - proto_item *btle_item; - proto_tree *btle_tree; - proto_item *sub_item; - proto_tree *sub_tree; - gint offset = 0; - guint32 access_address; - guint8 length; - guint32 interface_id; - tvbuff_t *next_tvb; - guint8 *dst_bd_addr; - guint8 *src_bd_addr; + proto_item *btle_item; + proto_tree *btle_tree; + proto_item *sub_item; + proto_tree *sub_tree; + gint offset = 0; + guint32 access_address; + guint8 length; + tvbuff_t *next_tvb; + guint8 *dst_bd_addr; + guint8 *src_bd_addr; + connection_address_t *connection_address = NULL; + wmem_tree_t *wmem_tree; + wmem_tree_key_t key[5]; + guint32 interface_id; + guint32 adapter_id; + guint32 connection_access_address; + guint32 frame_number; enum {CRC_INDETERMINATE, CRC_CAN_BE_CALCULATED, CRC_INCORRECT, CRC_CORRECT} crc_status = CRC_INDETERMINATE; guint32 crc_init = 0x555555; /* default to advertising channel's value */ guint32 packet_crc; - const btle_context_t * btle_context = (const btle_context_t *) data; + const btle_context_t *btle_context = (const btle_context_t *) data; + bluetooth_data_t *bluetooth_data = NULL; + ubertooth_data_t *ubertooth_data = NULL; + + if (btle_context) + bluetooth_data = btle_context->previous_protocol_data.bluetooth_data; + if (bluetooth_data) + ubertooth_data = bluetooth_data->previous_protocol_data.ubertooth_data; src_bd_addr = (gchar *) wmem_alloc(pinfo->pool, 6); dst_bd_addr = (gchar *) wmem_alloc(pinfo->pool, 6); @@ -362,11 +367,22 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) } offset += 4; - if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) + if (bluetooth_data) + interface_id = bluetooth_data->interface_id; + else if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) interface_id = pinfo->phdr->interface_id; else interface_id = HCI_INTERFACE_DEFAULT; + if (bluetooth_data) + adapter_id = bluetooth_data->adapter_id; + else if (ubertooth_data) + adapter_id = ubertooth_data->bus_id << 8 | ubertooth_data->device_address; + else + adapter_id = HCI_ADAPTER_DEFAULT; + + frame_number = pinfo->fd->num; + if (access_address == ACCESS_ADDRESS_ADVERTISING) { proto_item *advertising_header_item; proto_tree *advertising_header_tree; @@ -423,6 +439,18 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) SET_ADDRESS(&pinfo->dl_dst, AT_STRINGZ, 10, "broadcast"); SET_ADDRESS(&pinfo->dst, AT_STRINGZ, 10, "broadcast"); + if (!pinfo->fd->flags.visited) { + address *addr; + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_src, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_src.data, pinfo->dl_src.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_SRC, addr); + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_dst, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_dst.data, pinfo->dl_dst.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_DST, addr); + } + if (tvb_length_remaining(tvb, offset) > 3) { next_tvb = tvb_new_subset_length(tvb, offset, tvb_length_remaining(tvb, offset) - 3); call_dissector(btcommon_ad_handle, next_tvb, pinfo, btle_tree); @@ -443,6 +471,18 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, dst_bd_addr); SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, dst_bd_addr); + if (!pinfo->fd->flags.visited) { + address *addr; + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_src, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_src.data, pinfo->dl_src.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_SRC, addr); + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_dst, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_dst.data, pinfo->dl_dst.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_DST, addr); + } + break; case 0x03: /* SCAN_REQ */ offset = dissect_bd_addr(hf_scanning_address, btle_tree, tvb, offset, src_bd_addr); @@ -456,6 +496,18 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, dst_bd_addr); SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, dst_bd_addr); + if (!pinfo->fd->flags.visited) { + address *addr; + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_src, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_src.data, pinfo->dl_src.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_SRC, addr); + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_dst, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_dst.data, pinfo->dl_dst.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_DST, addr); + } + break; case 0x04: /* SCAN_RSP */ offset = dissect_bd_addr(hf_advertising_address, btle_tree, tvb, offset, src_bd_addr); @@ -468,6 +520,18 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) SET_ADDRESS(&pinfo->dl_dst, AT_STRINGZ, 10, "broadcast"); SET_ADDRESS(&pinfo->dst, AT_STRINGZ, 10, "broadcast"); + if (!pinfo->fd->flags.visited) { + address *addr; + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_src, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_src.data, pinfo->dl_src.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_SRC, addr); + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_dst, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_dst.data, pinfo->dl_dst.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_DST, addr); + } + sub_item = proto_tree_add_item(btle_tree, hf_scan_response_data, tvb, offset, tvb_length_remaining(tvb, offset) - 3, ENC_NA); sub_tree = proto_item_add_subtree(sub_item, ett_scan_response_data); @@ -480,13 +544,34 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) break; case 0x05: /* CONNECT_REQ */ - offset = dissect_bd_addr(hf_initiator_addresss, btle_tree, tvb, offset, NULL); - offset = dissect_bd_addr(hf_advertising_address, btle_tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_initiator_addresss, btle_tree, tvb, offset, src_bd_addr); + offset = dissect_bd_addr(hf_advertising_address, btle_tree, tvb, offset, dst_bd_addr); + + SET_ADDRESS(&pinfo->net_src, AT_ETHER, 6, src_bd_addr); + SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, src_bd_addr); + SET_ADDRESS(&pinfo->src, AT_ETHER, 6, src_bd_addr); + + SET_ADDRESS(&pinfo->net_dst, AT_ETHER, 6, dst_bd_addr); + SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, dst_bd_addr); + SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, dst_bd_addr); + + if (!pinfo->fd->flags.visited) { + address *addr; + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_src, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_src.data, pinfo->dl_src.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_SRC, addr); + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_dst, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_dst.data, pinfo->dl_dst.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_DST, addr); + } link_layer_data_item = proto_tree_add_item(btle_tree, hf_link_layer_data, tvb, offset, 22, ENC_NA); link_layer_data_tree = proto_item_add_subtree(link_layer_data_item, ett_link_layer_data); proto_tree_add_item(link_layer_data_tree, hf_link_layer_data_access_address, tvb, offset, 4, ENC_LITTLE_ENDIAN); + connection_access_address = tvb_get_letohl(tvb, offset); offset += 4; proto_tree_add_item(link_layer_data_tree, hf_link_layer_data_crc_init, tvb, offset, 3, ENC_LITTLE_ENDIAN); @@ -517,6 +602,29 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) proto_tree_add_item(link_layer_data_tree, hf_link_layer_data_sleep_clock_accuracy, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; + if (!pinfo->fd->flags.visited) { + key[0].length = 1; + key[0].key = &interface_id; + key[1].length = 1; + key[1].key = &adapter_id; + key[2].length = 1; + key[2].key = &connection_access_address; + key[3].length = 1; + key[3].key = &frame_number; + key[4].length = 0; + key[4].key = NULL; + + connection_address = wmem_new(wmem_file_scope(), connection_address_t); + connection_address->interface_id = interface_id; + connection_address->adapter_id = adapter_id; + connection_address->access_address = connection_access_address; + + memcpy(connection_address->master_bd_addr, src_bd_addr, 6); + memcpy(connection_address->slave_bd_addr, dst_bd_addr, 6); + + wmem_tree_insert32_array(connection_addresses, key, connection_address); + } + break; default: if (tvb_length_remaining(tvb, offset) > 3) { @@ -530,6 +638,54 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) guint8 llid; guint8 control_opcode; + key[0].length = 1; + key[0].key = &interface_id; + key[1].length = 1; + key[1].key = &adapter_id; + key[2].length = 1; + key[2].key = &access_address; + key[3].length = 0; + key[3].key = NULL; + + wmem_tree = (wmem_tree_t *) wmem_tree_lookup32_array(connection_addresses, key); + if (wmem_tree) { + connection_address = (connection_address_t *) wmem_tree_lookup32_le(wmem_tree, pinfo->fd->num); + if (connection_address) { + gchar *str_addr; + int str_addr_len = 18 + 1; + + str_addr = (gchar *) wmem_alloc(pinfo->pool, str_addr_len); + + sub_item = proto_tree_add_ether(btle_tree, hf_master_bd_addr, tvb, 0, 0, connection_address->master_bd_addr); + PROTO_ITEM_SET_GENERATED(sub_item); + + sub_item = proto_tree_add_ether(btle_tree, hf_slave_bd_addr, tvb, 0, 0, connection_address->slave_bd_addr); + PROTO_ITEM_SET_GENERATED(sub_item); + + g_snprintf(str_addr, str_addr_len, "unknown_0x%08x", connection_address->access_address); + + SET_ADDRESS(&pinfo->net_src, AT_STRINGZ, str_addr_len, str_addr); + SET_ADDRESS(&pinfo->dl_src, AT_STRINGZ, str_addr_len, str_addr); + SET_ADDRESS(&pinfo->src, AT_STRINGZ, str_addr_len, str_addr); + + SET_ADDRESS(&pinfo->net_dst, AT_STRINGZ, str_addr_len, str_addr); + SET_ADDRESS(&pinfo->dl_dst, AT_STRINGZ, str_addr_len, str_addr); + SET_ADDRESS(&pinfo->dst, AT_STRINGZ, str_addr_len, str_addr); + + if (!pinfo->fd->flags.visited) { + address *addr; + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_src, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_src.data, pinfo->dl_src.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_SRC, addr); + + addr = (address *) wmem_memdup(wmem_file_scope(), &pinfo->dl_dst, sizeof(address)); + addr->data = wmem_memdup(wmem_file_scope(), pinfo->dl_dst.data, pinfo->dl_dst.len); + p_add_proto_data(wmem_file_scope(), pinfo, proto_bluetooth, BLUETOOTH_DATA_DST, addr); + } + } + } + data_header_item = proto_tree_add_item(btle_tree, hf_data_header, tvb, offset, 2, ENC_LITTLE_ENDIAN); data_header_tree = proto_item_add_subtree(data_header_item, ett_data_header); @@ -567,19 +723,25 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) offset += length; } else { bthci_acl_data_t *acl_data; + gint saved_p2p_dir; col_set_str(pinfo->cinfo, COL_INFO, "L2CAP Data"); -/* TODO: Temporary solution while chandle source/bd_addrs is unknown */ + acl_data = wmem_new(wmem_packet_scope(), bthci_acl_data_t); acl_data->interface_id = interface_id; - acl_data->adapter_id = 0; - acl_data->chandle = 0; + acl_data->adapter_id = adapter_id; + acl_data->chandle = 0; /* No connection handle at this layer */ acl_data->remote_bd_addr_oui = 0; acl_data->remote_bd_addr_id = 0; + saved_p2p_dir = pinfo->p2p_dir; + pinfo->p2p_dir = P2P_DIR_UNKNOWN; + next_tvb = tvb_new_subset_length(tvb, offset, length); call_dissector_with_data(btl2cap_handle, next_tvb, pinfo, tree, acl_data); offset += length; + + pinfo->p2p_dir = saved_p2p_dir; } } break; @@ -804,6 +966,16 @@ proto_register_btle(void) FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } }, + { &hf_master_bd_addr, + { "Master Address", "btle.master_bd_addr", + FT_ETHER, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, + { &hf_slave_bd_addr, + { "Slave Address", "btle.slave_bd_addr", + FT_ETHER, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, { &hf_advertising_header, { "Packet Header", "btle.advertising_header", FT_UINT16, BASE_HEX, NULL, 0x0, @@ -981,7 +1153,7 @@ proto_register_btle(void) }, { &hf_control_company_id, { "Company Id", "btle.control.company_id", - FT_UINT8, BASE_HEX | BASE_EXT_STRING, &bthci_evt_comp_id_ext, 0x0, + FT_UINT8, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x0, NULL, HFILL } }, { &hf_control_subversion_number, @@ -1183,6 +1355,8 @@ proto_register_btle(void) &ett_scan_response_data }; + connection_addresses = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); + proto_btle = proto_register_protocol("Bluetooth Low Energy Link Layer", "BT LE LL", "btle"); btle_handle = new_register_dissector("btle", dissect_btle, proto_btle); @@ -1206,7 +1380,7 @@ proto_reg_handoff_btle(void) btcommon_le_channel_map_handle = find_dissector("btcommon.le_channel_map"); btl2cap_handle = find_dissector("btl2cap"); - dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_LE_LL, btle_handle); + dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_LE_LL, btle_handle); } /* diff --git a/epan/dissectors/packet-btle.h b/epan/dissectors/packet-btle.h index 2f113b6a04..d507ab3d79 100644 --- a/epan/dissectors/packet-btle.h +++ b/epan/dissectors/packet-btle.h @@ -24,6 +24,8 @@ #ifndef __PACKET_BTLE_H__ #define __PACKET_BTLE_H__ +#include "packet-bluetooth.h" + /* * These structures are meant to support the provision of contextual * metadata to the BTLE dissector. @@ -58,6 +60,11 @@ typedef struct { gint crc_valid_at_capture: 1; gint mic_checked_at_capture: 1; gint mic_valid_at_capture: 1; + + union { + void *data; + bluetooth_data_t *bluetooth_data; + } previous_protocol_data; } btle_context_t; #endif /* __PACKET_BTLE_H__ */ diff --git a/epan/dissectors/packet-btle_rf.c b/epan/dissectors/packet-btle_rf.c index 282f8d9066..f74cf9244a 100644 --- a/epan/dissectors/packet-btle_rf.c +++ b/epan/dissectors/packet-btle_rf.c @@ -27,6 +27,7 @@ #include #include +#include "packet-bluetooth.h" #include "packet-btle.h" #define LE_DEWHITENED 0x0001 @@ -117,8 +118,10 @@ btle_rf_channel_index(guint8 rf_channel) } static gint -dissect_btle_rf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_btle_rf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { + bluetooth_data_t *bluetooth_data = (bluetooth_data_t *) data; + col_set_str(pinfo->cinfo, COL_PROTOCOL, "BTLE RF"); col_clear(pinfo->cinfo, COL_INFO); @@ -132,6 +135,7 @@ dissect_btle_rf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data guint8 aa_offenses = tvb_get_guint8(tvb, 3); guint16 flags = tvb_get_letohs(tvb, 8); + context.previous_protocol_data.bluetooth_data = bluetooth_data; context.aa_category = E_AA_NO_COMMENT; context.connection_info_valid = 0; /* TODO */ context.crc_checked_at_capture = !!(flags & LE_CRC_CHECKED); @@ -358,7 +362,7 @@ proto_register_btle_rf(void) void proto_reg_handoff_btle_rf(void) { - dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_LE_LL_WITH_PHDR, btle_rf_handle); + dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_LE_LL_WITH_PHDR, btle_rf_handle); btle_handle = find_dissector("btle"); } diff --git a/epan/dissectors/packet-btobex.c b/epan/dissectors/packet-btobex.c index 8050c2868d..4b0033cea0 100644 --- a/epan/dissectors/packet-btobex.c +++ b/epan/dissectors/packet-btobex.c @@ -31,7 +31,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" #include "packet-btrfcomm.h" #include "packet-btl2cap.h" #include "packet-btsdp.h" @@ -1988,7 +1988,7 @@ proto_register_btobex(void) }, { &hf_bip_application_parameter_data_service_id, { "Service ID", "btobex.parameter.value.service_id", - FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bt_sig_uuid_vals_ext, 0x00, + FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_uuid_vals_ext, 0x00, NULL, HFILL } }, { &hf_bip_application_parameter_data_store_flag, diff --git a/epan/dissectors/packet-btrfcomm.c b/epan/dissectors/packet-btrfcomm.c index b9e5d9de74..3d26c7b6b5 100644 --- a/epan/dissectors/packet-btrfcomm.c +++ b/epan/dissectors/packet-btrfcomm.c @@ -38,7 +38,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" #include "packet-btsdp.h" #include "packet-btl2cap.h" #include "packet-btrfcomm.h" @@ -695,7 +695,7 @@ dissect_btrfcomm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data subtree = (wmem_tree_t *) wmem_tree_lookup32_array(service_directions, key); service_direction = (subtree) ? (service_direction_t *) wmem_tree_lookup32_le(subtree, k_frame_number) : NULL; - if (service_direction && service_direction->end_in == G_MAXUINT32) { + if (service_direction && service_direction->end_in == max_disconnect_in_frame) { service_direction->end_in = k_frame_number; } @@ -706,7 +706,7 @@ dissect_btrfcomm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data service_direction = wmem_new(wmem_file_scope(), service_direction_t); service_direction->direction = (pinfo->p2p_dir == P2P_DIR_RECV) ? P2P_DIR_SENT : P2P_DIR_RECV; - service_direction->end_in = G_MAXUINT32; + service_direction->end_in = max_disconnect_in_frame; wmem_tree_insert32_array(service_directions, key, service_direction); } @@ -775,7 +775,7 @@ dissect_btrfcomm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data val_to_str_const(frame_type, vs_frame_type_short, "Unknown"), dlci >> 1); if (dlci && (frame_type == FRAME_TYPE_SABM)) col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ", - val_to_str_ext_const(service_info->uuid.bt_uuid, &bt_sig_uuid_vals_ext, "Unknown")); + val_to_str_ext_const(service_info->uuid.bt_uuid, &bluetooth_uuid_vals_ext, "Unknown")); /* UID frame */ if ((frame_type == FRAME_TYPE_UIH) && dlci && pf_flag) { diff --git a/epan/dissectors/packet-btsdp.c b/epan/dissectors/packet-btsdp.c index 76bcbfaa45..bf9aa5aa06 100644 --- a/epan/dissectors/packet-btsdp.c +++ b/epan/dissectors/packet-btsdp.c @@ -39,7 +39,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" #include "packet-btsdp.h" #include "packet-btl2cap.h" @@ -895,7 +895,7 @@ static gchar * print_uuid(uuid_t *uuid) { if (uuid->bt_uuid) { - return wmem_strdup(wmem_packet_scope(), val_to_str_ext_const(uuid->bt_uuid, &bt_sig_uuid_vals_ext, "Unknown")); + return wmem_strdup(wmem_packet_scope(), val_to_str_ext_const(uuid->bt_uuid, &bluetooth_uuid_vals_ext, "Unknown")); } else { guint i_uuid; @@ -1146,7 +1146,7 @@ dissect_uuid(proto_tree *tree, tvbuff_t *tvb, gint offset, gint size, uuid_t *uu } else if (size == 16 && tvb_get_ntohs(tvb, offset) == 0x0000 && tvb_get_ntohl(tvb, offset + 4) == 0x1000 && tvb_get_ntoh64(tvb, offset + 8) == G_GUINT64_CONSTANT(0x800000805F9B34FB)) { item = proto_tree_add_item(tree, hf_data_element_value_uuid_128, tvb, offset, size, ENC_NA); uuid->bt_uuid = tvb_get_ntohs(tvb, offset + 2); - proto_item_append_text(item, " (%s)", val_to_str_ext_const(uuid->bt_uuid, &bt_sig_uuid_vals_ext, "Unknown")); + proto_item_append_text(item, " (%s)", val_to_str_ext_const(uuid->bt_uuid, &bluetooth_uuid_vals_ext, "Unknown")); } else { guint i_uuid; item = proto_tree_add_item(tree, hf_data_element_value_uuid, tvb, offset, size, ENC_NA); @@ -1975,7 +1975,7 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, vendor_id = tvb_get_ntohs(tvb, offset); if (service_did_vendor_id_source == DID_VENDOR_ID_SOURCE_BLUETOOTH_SIG) { proto_tree_add_item(next_tree, hf_did_vendor_id_bluetooth_sig, tvb, offset, 2, ENC_BIG_ENDIAN); - str_val = val_to_str_ext_const(vendor_id, &bthci_evt_comp_id_ext, "Unknown"); + str_val = val_to_str_ext_const(vendor_id, &bluetooth_company_id_vals_ext, "Unknown"); } else if (service_did_vendor_id_source == DID_VENDOR_ID_SOURCE_USB_FORUM) { proto_tree_add_item(next_tree, hf_did_vendor_id_usb_forum, tvb, offset, 2, ENC_BIG_ENDIAN); str_val = val_to_str_ext_const(vendor_id, &ext_usb_vendors_vals, "Unknown"); @@ -4400,12 +4400,12 @@ proto_register_btsdp(void) }, { &hf_data_element_value_uuid_16, { "Value: UUID", "btsdp.data_element.value.uuid_16", - FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bt_sig_uuid_vals_ext, 0, + FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_uuid_vals_ext, 0, NULL, HFILL } }, { &hf_data_element_value_uuid_32, { "Value: UUID", "btsdp.data_element.value.uuid_32", - FT_UINT32, BASE_HEX | BASE_EXT_STRING, &bt_sig_uuid_vals_ext, 0, + FT_UINT32, BASE_HEX | BASE_EXT_STRING, &bluetooth_uuid_vals_ext, 0, NULL, HFILL } }, { &hf_data_element_value_uuid_128, @@ -4600,7 +4600,7 @@ proto_register_btsdp(void) }, { &hf_did_vendor_id_bluetooth_sig, { "Vendor ID", "btsdp.service.did.vendor_id", - FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bthci_evt_comp_id_ext, 0, + FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0, NULL, HFILL } }, { &hf_did_vendor_id_usb_forum, diff --git a/epan/dissectors/packet-hci_h1.c b/epan/dissectors/packet-hci_h1.c index 1e2ce5b6dd..bdea12dac4 100644 --- a/epan/dissectors/packet-hci_h1.c +++ b/epan/dissectors/packet-hci_h1.c @@ -27,7 +27,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" static int proto_hci_h1 = -1; @@ -40,12 +40,6 @@ static dissector_table_t hci_h1_table; static dissector_handle_t hci_h1_handle; static dissector_handle_t data_handle; -static wmem_tree_t *chandle_sessions = NULL; -static wmem_tree_t *chandle_to_bdaddr_table = NULL; -static wmem_tree_t *bdaddr_to_name_table = NULL; -static wmem_tree_t *localhost_name = NULL; -static wmem_tree_t *localhost_bdaddr = NULL; - static const value_string hci_h1_type_vals[] = { {BTHCI_CHANNEL_COMMAND, "HCI Command"}, {BTHCI_CHANNEL_ACL, "ACL Data"}, @@ -60,20 +54,19 @@ static const value_string hci_h1_direction_vals[] = { {0, NULL} }; -static guint32 max_disconnect_in_frame = G_MAXUINT32; - - void proto_register_hci_h1(void); void proto_reg_handoff_hci_h1(void); static gint -dissect_hci_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_hci_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - guint8 type; - tvbuff_t *next_tvb; - proto_item *ti = NULL; - proto_tree *hci_h1_tree = NULL; - hci_data_t *hci_data; + guint8 type; + tvbuff_t *next_tvb; + proto_item *ti = NULL; + proto_tree *hci_h1_tree = NULL; + bluetooth_data_t *bluetooth_data; + + bluetooth_data = (bluetooth_data_t *) data; col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCI"); @@ -112,26 +105,11 @@ dissect_hci_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ val_to_str(type, hci_h1_type_vals, "Unknown 0x%02x")); - hci_data = wmem_new(wmem_packet_scope(), hci_data_t); - if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) - hci_data->interface_id = pinfo->phdr->interface_id; - else - hci_data->interface_id = HCI_INTERFACE_DEFAULT; - hci_data->adapter_id = HCI_ADAPTER_DEFAULT; - hci_data->adapter_disconnect_in_frame = &max_disconnect_in_frame; - hci_data->chandle_sessions = chandle_sessions; - hci_data->chandle_to_bdaddr_table = chandle_to_bdaddr_table; - hci_data->bdaddr_to_name_table = bdaddr_to_name_table; - hci_data->localhost_bdaddr = localhost_bdaddr; - hci_data->localhost_name = localhost_name; - - pinfo->ptype = PT_BLUETOOTH; - ti = proto_tree_add_int(hci_h1_tree, hf_hci_h1_direction, tvb, 0, 0, pinfo->p2p_dir); PROTO_ITEM_SET_GENERATED(ti); next_tvb = tvb_new_subset_remaining(tvb, 0); - if (!dissector_try_uint_new(hci_h1_table, type, next_tvb, pinfo, tree, TRUE, hci_data)) { + if (!dissector_try_uint_new(hci_h1_table, type, next_tvb, pinfo, tree, TRUE, bluetooth_data)) { call_dissector(data_handle, next_tvb, pinfo, tree); } @@ -164,12 +142,6 @@ proto_register_hci_h1(void) hci_h1_table = register_dissector_table("hci_h1.type", "HCI h1 pdu type", FT_UINT8, BASE_HEX); - - chandle_sessions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); - chandle_to_bdaddr_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, chandle: bdaddr */ - bdaddr_to_name_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* bdaddr: name */ - localhost_bdaddr = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: bdaddr */ - localhost_name = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: name */ } void @@ -177,7 +149,7 @@ proto_reg_handoff_hci_h1(void) { data_handle = find_dissector("data"); - dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_HCI, hci_h1_handle); + dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_HCI, hci_h1_handle); } /* diff --git a/epan/dissectors/packet-hci_h4.c b/epan/dissectors/packet-hci_h4.c index 5b2243b784..9e1f99bf71 100644 --- a/epan/dissectors/packet-hci_h4.c +++ b/epan/dissectors/packet-hci_h4.c @@ -31,9 +31,8 @@ #include #include #include -#include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" static int proto_hci_h4 = -1; static int hf_hci_h4_type = -1; @@ -46,12 +45,6 @@ static dissector_handle_t hci_h4_handle; static dissector_table_t hci_h4_table; static dissector_handle_t data_handle; -static wmem_tree_t *chandle_sessions = NULL; -static wmem_tree_t *chandle_to_bdaddr_table = NULL; -static wmem_tree_t *bdaddr_to_name_table = NULL; -static wmem_tree_t *localhost_name = NULL; -static wmem_tree_t *localhost_bdaddr = NULL; - static const value_string hci_h4_type_vals[] = { {HCI_H4_TYPE_CMD, "HCI Command"}, {HCI_H4_TYPE_ACL, "ACL Data"}, @@ -66,20 +59,20 @@ static const value_string hci_h4_direction_vals[] = { {0, NULL} }; -static guint32 max_disconnect_in_frame = G_MAXUINT32; - - void proto_register_hci_h4(void); void proto_reg_handoff_hci_h4(void); static gint -dissect_hci_h4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_hci_h4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - guint8 type; - tvbuff_t *next_tvb; - proto_item *ti = NULL; - proto_tree *hci_h4_tree = NULL; - hci_data_t *hci_data; + guint8 type; + tvbuff_t *next_tvb; + proto_item *main_item; + proto_tree *main_tree; + proto_item *sub_item; + bluetooth_data_t *bluetooth_data; + + bluetooth_data = (bluetooth_data_t *) data; col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCI H4"); switch (pinfo->p2p_dir) { @@ -103,36 +96,19 @@ dissect_hci_h4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ type = tvb_get_guint8(tvb, 0); - if (tree) { - ti = proto_tree_add_item(tree, proto_hci_h4, tvb, 0, 1, ENC_NA); - hci_h4_tree = proto_item_add_subtree(ti, ett_hci_h4); - } + main_item = proto_tree_add_item(tree, proto_hci_h4, tvb, 0, 1, ENC_NA); + main_tree = proto_item_add_subtree(main_item, ett_hci_h4); - hci_data = (hci_data_t *) wmem_new(wmem_packet_scope(), hci_data_t); - if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) - hci_data->interface_id = pinfo->phdr->interface_id; - else - hci_data->interface_id = HCI_INTERFACE_DEFAULT; - hci_data->adapter_id = HCI_ADAPTER_DEFAULT; - hci_data->adapter_disconnect_in_frame = &max_disconnect_in_frame; - hci_data->chandle_sessions = chandle_sessions; - hci_data->chandle_to_bdaddr_table = chandle_to_bdaddr_table; - hci_data->bdaddr_to_name_table = bdaddr_to_name_table; - hci_data->localhost_bdaddr = localhost_bdaddr; - hci_data->localhost_name = localhost_name; - - pinfo->ptype = PT_BLUETOOTH; - - ti = proto_tree_add_uint(hci_h4_tree, hf_hci_h4_direction, tvb, 0, 0, pinfo->p2p_dir); - PROTO_ITEM_SET_GENERATED(ti); - - proto_tree_add_item(hci_h4_tree, hf_hci_h4_type, + sub_item = proto_tree_add_uint(main_tree, hf_hci_h4_direction, tvb, 0, 0, pinfo->p2p_dir); + PROTO_ITEM_SET_GENERATED(sub_item); + + proto_tree_add_item(main_tree, hf_hci_h4_type, tvb, 0, 1, ENC_LITTLE_ENDIAN); col_append_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str(type, hci_h4_type_vals, "Unknown HCI packet type 0x%02x")); next_tvb = tvb_new_subset_remaining(tvb, 1); - if (!dissector_try_uint_new(hci_h4_table, type, next_tvb, pinfo, tree, TRUE, hci_data)) { + if (!dissector_try_uint_new(hci_h4_table, type, next_tvb, pinfo, tree, TRUE, bluetooth_data)) { call_dissector(data_handle, next_tvb, pinfo, tree); } @@ -170,12 +146,6 @@ proto_register_hci_h4(void) hci_h4_table = register_dissector_table("hci_h4.type", "HCI H4 pdu type", FT_UINT8, BASE_HEX); - - chandle_sessions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); - chandle_to_bdaddr_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, chandle: bdaddr */ - bdaddr_to_name_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* bdaddr: name */ - localhost_bdaddr = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: bdaddr */ - localhost_name = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: name */ } void @@ -183,8 +153,8 @@ proto_reg_handoff_hci_h4(void) { data_handle = find_dissector("data"); - dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_H4, hci_h4_handle); - dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR, hci_h4_handle); + dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_H4, hci_h4_handle); + dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR, hci_h4_handle); } /* diff --git a/epan/dissectors/packet-hci_mon.c b/epan/dissectors/packet-hci_mon.c index 9b307c11d6..37744b5f7c 100644 --- a/epan/dissectors/packet-hci_mon.c +++ b/epan/dissectors/packet-hci_mon.c @@ -30,7 +30,7 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" static int proto_hci_mon = -1; @@ -46,11 +46,6 @@ static gint ett_hci_mon = -1; static expert_field ei_unknown_data = EI_INIT; static wmem_tree_t *adapter_to_disconnect_in_frame = NULL; -static wmem_tree_t *chandle_sessions = NULL; -static wmem_tree_t *chandle_to_bdaddr_table = NULL; -static wmem_tree_t *bdaddr_to_name_table = NULL; -static wmem_tree_t *localhost_name = NULL; -static wmem_tree_t *localhost_bdaddr = NULL; static dissector_handle_t hci_mon_handle; static dissector_handle_t bthci_cmd_handle; @@ -90,14 +85,11 @@ static const value_string bus_vals[] = { }; static value_string_ext(bus_vals_ext) = VALUE_STRING_EXT_INIT(bus_vals); -static guint32 max_disconnect_in_frame = G_MAXUINT32; - - void proto_register_hci_mon(void); void proto_reg_handoff_hci_mon(void); static gint -dissect_hci_mon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_hci_mon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { proto_tree *hci_mon_item; proto_item *hci_mon_tree; @@ -105,7 +97,7 @@ dissect_hci_mon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data gint offset = 0; guint16 opcode; guint16 adapter_id; - hci_data_t *hci_data; + bluetooth_data_t *bluetooth_data; tvbuff_t *next_tvb; guint32 *adapter_disconnect_in_frame; wmem_tree_t *subtree; @@ -117,6 +109,8 @@ dissect_hci_mon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data adapter_id = pinfo->pseudo_header->btmon.adapter_id; opcode = pinfo->pseudo_header->btmon.opcode; + bluetooth_data = (bluetooth_data_t *) data; + if (opcode == 0x00 || opcode == 0x01) pinfo->p2p_dir = P2P_DIR_RECV; else if (opcode % 2) @@ -155,20 +149,9 @@ dissect_hci_mon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data col_append_fstr(pinfo->cinfo, COL_INFO, "Adapter Id: %u, Opcode: %s", adapter_id, val_to_str_ext_const(opcode, &opcode_vals_ext, "Unknown")); + bluetooth_data->adapter_id = adapter_id; - hci_data = (hci_data_t *) wmem_new(wmem_packet_scope(), hci_data_t); - if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) - hci_data->interface_id = pinfo->phdr->interface_id; - else - hci_data->interface_id = HCI_INTERFACE_DEFAULT; - hci_data->adapter_id = adapter_id; - hci_data->chandle_sessions = chandle_sessions; - hci_data->chandle_to_bdaddr_table = chandle_to_bdaddr_table; - hci_data->bdaddr_to_name_table = bdaddr_to_name_table; - hci_data->localhost_bdaddr = localhost_bdaddr; - hci_data->localhost_name = localhost_name; - - k_interface_id = hci_data->interface_id; + k_interface_id = bluetooth_data->interface_id; k_adapter_id = adapter_id; k_frame_number = pinfo->fd->num; @@ -200,9 +183,9 @@ dissect_hci_mon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data subtree = (wmem_tree_t *) wmem_tree_lookup32_array(adapter_to_disconnect_in_frame, key); adapter_disconnect_in_frame = (subtree) ? (guint32 *) wmem_tree_lookup32_le(subtree, k_frame_number) : NULL; if (adapter_disconnect_in_frame) { - hci_data->adapter_disconnect_in_frame = adapter_disconnect_in_frame; + bluetooth_data->adapter_disconnect_in_frame = adapter_disconnect_in_frame; } else { - hci_data->adapter_disconnect_in_frame = &max_disconnect_in_frame; + bluetooth_data->adapter_disconnect_in_frame = &max_disconnect_in_frame; } pinfo->ptype = PT_BLUETOOTH; @@ -228,24 +211,24 @@ dissect_hci_mon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data break; case 0x02: /* HCI Command Packet */ - call_dissector_with_data(bthci_cmd_handle, next_tvb, pinfo, tree, hci_data); + call_dissector_with_data(bthci_cmd_handle, next_tvb, pinfo, tree, bluetooth_data); offset = tvb_length(tvb); break; case 0x03: /* HCI Event Packet */ - call_dissector_with_data(bthci_evt_handle, next_tvb, pinfo, tree, hci_data); + call_dissector_with_data(bthci_evt_handle, next_tvb, pinfo, tree, bluetooth_data); offset = tvb_length(tvb); break; case 0x04: /* ACL Tx Packet */ case 0x05: /* ACL Rx Packet */ - call_dissector_with_data(bthci_acl_handle, next_tvb, pinfo, tree, hci_data); + call_dissector_with_data(bthci_acl_handle, next_tvb, pinfo, tree, bluetooth_data); offset = tvb_length(tvb); break; case 0x06: /* SCO Tx Packet */ case 0x07: /* SCO Rx Packet */ - call_dissector_with_data(bthci_sco_handle, next_tvb, pinfo, tree, hci_data); + call_dissector_with_data(bthci_sco_handle, next_tvb, pinfo, tree, bluetooth_data); offset = tvb_length(tvb); break; @@ -311,13 +294,6 @@ proto_register_hci_mon(void) &ett_hci_mon, }; - adapter_to_disconnect_in_frame = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); - chandle_sessions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); - chandle_to_bdaddr_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, chandle: bdaddr */ - bdaddr_to_name_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* bdaddr: name */ - localhost_bdaddr = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: bdaddr */ - localhost_name = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: name */ - proto_hci_mon = proto_register_protocol("Bluetooth Linux Monitor Transport", "HCI_MON", "hci_mon"); proto_register_field_array(proto_hci_mon, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -326,6 +302,8 @@ proto_register_hci_mon(void) expert_module = expert_register_protocol(proto_hci_mon); expert_register_field_array(expert_module, ei, array_length(ei)); + adapter_to_disconnect_in_frame = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); + module = prefs_register_protocol(proto_hci_mon, NULL); prefs_register_static_text_preference(module, "bthci_mon.version", "Bluetooth Linux Monitor Transport introduced in BlueZ 5.x", @@ -340,7 +318,7 @@ proto_reg_handoff_hci_mon(void) bthci_acl_handle = find_dissector("bthci_acl"); bthci_sco_handle = find_dissector("bthci_sco"); - dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR, hci_mon_handle); + dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR, hci_mon_handle); } /* diff --git a/epan/dissectors/packet-hci_usb.c b/epan/dissectors/packet-hci_usb.c index d3b2cd7902..9cc4a13704 100644 --- a/epan/dissectors/packet-hci_usb.c +++ b/epan/dissectors/packet-hci_usb.c @@ -30,8 +30,7 @@ #include #include -#include "packet-usb.h" -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" static int proto_hci_usb = -1; static int hf_bthci_usb_data = -1; @@ -58,12 +57,7 @@ static int hf_msg_fragment_count = -1; static int hf_msg_reassembled_in = -1; static int hf_msg_reassembled_length = -1; -static wmem_tree_t *chandle_sessions = NULL; -static wmem_tree_t *chandle_to_bdaddr_table = NULL; -static wmem_tree_t *bdaddr_to_name_table = NULL; -static wmem_tree_t *localhost_name = NULL; -static wmem_tree_t *localhost_bdaddr = NULL; -static wmem_tree_t *fragment_info_table = NULL; +static wmem_tree_t *fragment_info_table = NULL; static reassembly_table hci_usb_reassembly_table; @@ -109,8 +103,6 @@ static const value_string request_vals[] = { }; static value_string_ext(request_vals_ext) = VALUE_STRING_EXT_INIT(request_vals); -static guint32 max_disconnect_in_frame = G_MAXUINT32; - void proto_register_hci_usb(void); void proto_reg_handoff_hci_usb(void); @@ -118,21 +110,24 @@ void proto_reg_handoff_hci_usb(void); static gint dissect_hci_usb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - proto_item *ttree = NULL; - proto_tree *titem = NULL; - proto_item *pitem = NULL; - gint offset = 0; - usb_conv_info_t *usb_conv_info; - tvbuff_t *next_tvb = NULL; - hci_data_t *hci_data; - gint p2p_dir_save; - guint32 session_id; - fragment_head *reassembled; + proto_item *ttree = NULL; + proto_tree *titem = NULL; + proto_item *pitem = NULL; + gint offset = 0; + usb_conv_info_t *usb_conv_info; + tvbuff_t *next_tvb = NULL; + bluetooth_data_t *bluetooth_data; + gint p2p_dir_save; + guint32 session_id; + fragment_head *reassembled; + + bluetooth_data = (bluetooth_data_t *) data; /* Reject the packet if data is NULL */ if (data == NULL) return 0; - usb_conv_info = (usb_conv_info_t *)data; + + usb_conv_info = bluetooth_data->previous_protocol_data.usb_conv_info; titem = proto_tree_add_item(tree, proto_hci_usb, tvb, offset, -1, ENC_NA); ttree = proto_item_add_subtree(titem, ett_hci_usb); @@ -173,21 +168,9 @@ dissect_hci_usb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) session_id = usb_conv_info->bus_id << 16 | usb_conv_info->device_address << 8 | ((pinfo->p2p_dir == P2P_DIR_RECV) ? 1 : 0 ) << 7 | usb_conv_info->endpoint; - hci_data = (hci_data_t *) wmem_new(wmem_packet_scope(), hci_data_t); - if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) - hci_data->interface_id = pinfo->phdr->interface_id; - else - hci_data->interface_id = HCI_INTERFACE_DEFAULT; - hci_data->adapter_id = usb_conv_info->bus_id << 8 | usb_conv_info->device_address; + bluetooth_data->adapter_id = usb_conv_info->bus_id << 8 | usb_conv_info->device_address; /* TODO: adapter disconnect on some USB action, for now do not support adapter disconnection */ - hci_data->adapter_disconnect_in_frame = &max_disconnect_in_frame; - hci_data->chandle_sessions = chandle_sessions; - hci_data->chandle_to_bdaddr_table = chandle_to_bdaddr_table; - hci_data->bdaddr_to_name_table = bdaddr_to_name_table; - hci_data->localhost_bdaddr = localhost_bdaddr; - hci_data->localhost_name = localhost_name; - - pinfo->ptype = PT_BLUETOOTH; + bluetooth_data->adapter_disconnect_in_frame = &max_disconnect_in_frame; next_tvb = tvb_new_subset_remaining(tvb, offset); if (!pinfo->fd->flags.visited && usb_conv_info->endpoint <= 0x02) { @@ -248,13 +231,13 @@ dissect_hci_usb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) switch(usb_conv_info->endpoint) { case 0: - call_dissector_with_data(bthci_cmd_handle, next_tvb, pinfo, tree, hci_data); + call_dissector_with_data(bthci_cmd_handle, next_tvb, pinfo, tree, bluetooth_data); break; case 1: - call_dissector_with_data(bthci_evt_handle, next_tvb, pinfo, tree, hci_data); + call_dissector_with_data(bthci_evt_handle, next_tvb, pinfo, tree, bluetooth_data); break; case 2: - call_dissector_with_data(bthci_acl_handle, next_tvb, pinfo, tree, hci_data); + call_dissector_with_data(bthci_acl_handle, next_tvb, pinfo, tree, bluetooth_data); break; } } else { @@ -263,7 +246,7 @@ dissect_hci_usb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) } if (usb_conv_info->endpoint == 0x03) { - call_dissector_with_data(bthci_sco_handle, next_tvb, pinfo, tree, hci_data); + call_dissector_with_data(bthci_sco_handle, next_tvb, pinfo, tree, bluetooth_data); } else if (usb_conv_info->endpoint > 0x03) { proto_tree_add_item(ttree, hf_bthci_usb_data, tvb, offset, -1, ENC_NA); } @@ -382,12 +365,6 @@ proto_register_hci_usb(void) &addresses_reassembly_table_functions); fragment_info_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); - chandle_sessions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); - chandle_to_bdaddr_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, chandle: bdaddr */ - bdaddr_to_name_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* bdaddr: name */ - localhost_bdaddr = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: bdaddr */ - localhost_name = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: name */ - proto_hci_usb = proto_register_protocol("Bluetooth HCI USB Transport", "HCI_USB", "hci_usb"); proto_register_field_array(proto_hci_usb, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -407,18 +384,10 @@ proto_reg_handoff_hci_usb(void) bthci_acl_handle = find_dissector("bthci_acl"); bthci_sco_handle = find_dissector("bthci_sco"); - dissector_add_uint("usb.product", (0x0a5c << 16) | 0x21e8, hci_usb_handle); - dissector_add_uint("usb.product", (0x1131 << 16) | 0x1001, hci_usb_handle); - dissector_add_uint("usb.product", (0x050d << 16) | 0x0081, hci_usb_handle); - dissector_add_uint("usb.product", (0x0a5c << 16) | 0x2198, hci_usb_handle); - dissector_add_uint("usb.product", (0x0a5c << 16) | 0x21e8, hci_usb_handle); - dissector_add_uint("usb.product", (0x04bf << 16) | 0x0320, hci_usb_handle); - dissector_add_uint("usb.product", (0x13d3 << 16) | 0x3375, hci_usb_handle); - - dissector_add_uint("usb.protocol", 0xE00101, hci_usb_handle); - dissector_add_uint("usb.protocol", 0xE00104, hci_usb_handle); - - dissector_add_for_decode_as("usb.device", hci_usb_handle); + dissector_add_uint("bluetooth.encap", WTAP_ENCAP_USB, hci_usb_handle); + dissector_add_uint("bluetooth.encap", WTAP_ENCAP_USB_LINUX, hci_usb_handle); + dissector_add_uint("bluetooth.encap", WTAP_ENCAP_USB_LINUX_MMAPPED, hci_usb_handle); + dissector_add_uint("bluetooth.encap", WTAP_ENCAP_USBPCAP, hci_usb_handle); } /* diff --git a/epan/dissectors/packet-packetlogger.c b/epan/dissectors/packet-packetlogger.c index 0a4d756deb..4bfb5cd444 100644 --- a/epan/dissectors/packet-packetlogger.c +++ b/epan/dissectors/packet-packetlogger.c @@ -27,6 +27,8 @@ #include #include +#include + void proto_register_packetlogger(void); void proto_reg_handoff_packetlogger(void); @@ -69,13 +71,17 @@ static const value_string type_vals[] = { { 0, NULL } }; -static void dissect_packetlogger (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static int dissect_packetlogger(tvbuff_t *tvb, packet_info *pinfo, + proto_tree *tree, void *data) { - proto_tree *packetlogger_tree = NULL; - tvbuff_t *next_tvb; - proto_item *ti = NULL; - guint8 pl_type; - gint len; + proto_tree *packetlogger_tree = NULL; + tvbuff_t *next_tvb; + proto_item *ti = NULL; + guint8 pl_type; + gint len; + bluetooth_data_t *bluetooth_data; + + bluetooth_data = (bluetooth_data_t *) data; col_set_str (pinfo->cinfo, COL_PROTOCOL, PSNAME); col_clear (pinfo->cinfo, COL_INFO); @@ -122,7 +128,8 @@ static void dissect_packetlogger (tvbuff_t *tvb, packet_info *pinfo, proto_tree proto_item_set_len (ti, 1); col_add_fstr (pinfo->cinfo, COL_INFO, "%s", val_to_str(pl_type, type_vals, "Unknown 0x%02x")); - if (!dissector_try_uint (hci_h1_table, pinfo->pseudo_header->bthci.channel, next_tvb, pinfo, tree)) { + if (!dissector_try_uint_new(hci_h1_table, pinfo->pseudo_header->bthci.channel, + next_tvb, pinfo, tree, TRUE, bluetooth_data)) { call_dissector (data_handle, next_tvb, pinfo, tree); } } else { @@ -140,6 +147,8 @@ static void dissect_packetlogger (tvbuff_t *tvb, packet_info *pinfo, proto_tree break; } } + + return tvb_captured_length(tvb); } void proto_register_packetlogger (void) @@ -157,7 +166,7 @@ void proto_register_packetlogger (void) proto_packetlogger = proto_register_protocol (PNAME, PSNAME, PFNAME); - packetlogger_handle = register_dissector (PFNAME, dissect_packetlogger, proto_packetlogger); + packetlogger_handle = new_register_dissector (PFNAME, dissect_packetlogger, proto_packetlogger); proto_register_field_array (proto_packetlogger, hf, array_length (hf)); proto_register_subtree_array (ett, array_length (ett)); @@ -167,7 +176,7 @@ void proto_reg_handoff_packetlogger (void) { hci_h1_table = find_dissector_table("hci_h1.type"); data_handle = find_dissector("data"); - dissector_add_uint ("wtap_encap", WTAP_ENCAP_PACKETLOGGER, packetlogger_handle); + dissector_add_uint ("bluetooth.encap", WTAP_ENCAP_PACKETLOGGER, packetlogger_handle); } /* diff --git a/epan/dissectors/packet-ubertooth.c b/epan/dissectors/packet-ubertooth.c index 9e324def9e..638d62c651 100644 --- a/epan/dissectors/packet-ubertooth.c +++ b/epan/dissectors/packet-ubertooth.c @@ -30,7 +30,8 @@ #include #include -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" +#include "packet-ubertooth.h" #include "packet-usb.h" static int proto_ubertooth = -1; @@ -333,7 +334,7 @@ static expert_field ei_unknown_data = EI_INIT; static expert_field ei_unexpected_data = EI_INIT; static dissector_handle_t ubertooth_handle; -static dissector_handle_t btle_handle; +static dissector_handle_t bluetooth_handle; static wmem_tree_t *command_info = NULL; @@ -1182,7 +1183,8 @@ dissect_cc2400_register(proto_tree *tree, tvbuff_t *tvb, gint offset, guint8 reg } static gint -dissect_usb_rx_packet(proto_tree *main_tree, proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, gint offset, gint16 command) +dissect_usb_rx_packet(proto_tree *main_tree, proto_tree *tree, packet_info *pinfo, + tvbuff_t *tvb, gint offset, gint16 command, usb_conv_info_t *usb_conv_info) { proto_item *sub_item; proto_tree *sub_tree; @@ -1196,6 +1198,9 @@ dissect_usb_rx_packet(proto_tree *main_tree, proto_tree *tree, packet_info *pinf tvbuff_t *next_tvb; guint8 packet_type; guint32 start_offset; + guint32 clock_100ns; + guint8 channel; + ubertooth_data_t *ubertooth_data; sub_item = proto_tree_add_item(tree, hf_usb_rx_packet, tvb, offset, 64, ENC_NA); sub_tree = proto_item_add_subtree(sub_item, ett_usb_rx_packet); @@ -1253,12 +1258,14 @@ dissect_usb_rx_packet(proto_tree *main_tree, proto_tree *tree, packet_info *pinf offset += 1; proto_tree_add_item(sub_tree, hf_usb_rx_packet_channel, tvb, offset, 1, ENC_NA); + channel = tvb_get_guint8(tvb, offset); offset += 1; proto_tree_add_item(sub_tree, hf_clock_ns, tvb, offset, 1, ENC_NA); offset += 1; proto_tree_add_item(sub_tree, hf_clock_100ns, tvb, offset, 4, ENC_LITTLE_ENDIAN); + clock_100ns = tvb_get_letohl(tvb, offset); offset += 4; proto_tree_add_item(sub_tree, hf_rssi_max, tvb, offset, 1, ENC_NA); @@ -1305,8 +1312,14 @@ dissect_usb_rx_packet(proto_tree *main_tree, proto_tree *tree, packet_info *pinf else length += tvb_get_guint8(tvb, offset + 5) & 0x1f; + ubertooth_data = wmem_new(wmem_packet_scope(), ubertooth_data_t); + ubertooth_data->bus_id = usb_conv_info->bus_id; + ubertooth_data->device_address = usb_conv_info->device_address; + ubertooth_data->clock_100ns = clock_100ns; + ubertooth_data->channel = channel; + next_tvb = tvb_new_subset_length(tvb, offset, length); - call_dissector(btle_handle, next_tvb, pinfo, main_tree); + call_dissector_with_data(bluetooth_handle, next_tvb, pinfo, main_tree, ubertooth_data); offset += length; if (tvb_length_remaining(tvb, offset) > 0) { @@ -1354,7 +1367,7 @@ dissect_ubertooth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat col_set_str(pinfo->cinfo, COL_PROTOCOL, "UBERTOOTH"); - DISSECTOR_ASSERT(usb_conv_info); + if (!usb_conv_info) return offset; p2p_dir_save = pinfo->p2p_dir; pinfo->p2p_dir = (usb_conv_info->is_request) ? P2P_DIR_SENT : P2P_DIR_RECV; @@ -1681,7 +1694,7 @@ dissect_ubertooth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat if (usb_conv_info->transfer_type == URB_BULK) { while (tvb_length_remaining(tvb, offset) > 0) { - offset = dissect_usb_rx_packet(tree, main_tree, pinfo, tvb, offset, command_response); + offset = dissect_usb_rx_packet(tree, main_tree, pinfo, tvb, offset, command_response, usb_conv_info); } break; } @@ -1883,7 +1896,7 @@ dissect_ubertooth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; } - offset = dissect_usb_rx_packet(tree, main_tree, pinfo, tvb, offset, command_response); + offset = dissect_usb_rx_packet(tree, main_tree, pinfo, tvb, offset, command_response, usb_conv_info); break; case 53: /* Read Register */ @@ -3391,7 +3404,7 @@ proto_register_ubertooth(void) void proto_reg_handoff_ubertooth(void) { - btle_handle = find_dissector("btle"); + bluetooth_handle = find_dissector("bluetooth"); dissector_add_uint("usb.product", (0x1d50 << 16) | 0x6000, ubertooth_handle); /* Ubertooth Zero */ dissector_add_uint("usb.product", (0x1d50 << 16) | 0x6002, ubertooth_handle); /* Ubertooth One */ diff --git a/epan/dissectors/packet-ubertooth.h b/epan/dissectors/packet-ubertooth.h new file mode 100644 index 0000000000..0bd0ebaff3 --- /dev/null +++ b/epan/dissectors/packet-ubertooth.h @@ -0,0 +1,51 @@ +/* packet-ubertooth.h + * Headers for Ubertooth USB dissection + * + * Copyright 2014, Michal Labedzki for Tieto Corporation + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __PACKET_UBERTOOTH_H__ +#define __PACKET_UBERTOOTH_H__ + + +typedef struct _ubertooth_data_t { + guint16 bus_id; + guint16 device_address; + + guint32 clock_100ns; + guint8 channel; +} ubertooth_data_t; + + +#endif + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c index a2ed1559cd..6befa27417 100644 --- a/epan/dissectors/packet-usb.c +++ b/epan/dissectors/packet-usb.c @@ -2665,7 +2665,7 @@ try_dissect_next_protocol(proto_tree *tree, tvbuff_t *next_tvb, packet_info *pin /* try dissect by "usb.device" */ ret = dissector_try_uint_new(device_to_dissector, (guint32)(usb_conv_info->bus_id<<16 | usb_conv_info->device_address), - next_tvb, pinfo, parent, FALSE, usb_conv_info); + next_tvb, pinfo, parent, TRUE, usb_conv_info); if (ret) return tvb_captured_length(next_tvb); @@ -2690,7 +2690,7 @@ try_dissect_next_protocol(proto_tree *tree, tvbuff_t *next_tvb, packet_info *pin device_protocol_data->device_address == usb_conv_info->device_address) { ret = dissector_try_uint_new(protocol_to_dissector, (guint32)device_protocol_data->protocol, - next_tvb, pinfo, parent, FALSE, usb_conv_info); + next_tvb, pinfo, parent, TRUE, usb_conv_info); if (ret) return tvb_captured_length(next_tvb); } @@ -2701,7 +2701,7 @@ try_dissect_next_protocol(proto_tree *tree, tvbuff_t *next_tvb, packet_info *pin device_product_data->device_address == usb_conv_info->device_address) { ret = dissector_try_uint_new(product_to_dissector, (guint32)(device_product_data->vendor<<16 | device_product_data->product), - next_tvb, pinfo, parent, FALSE, usb_conv_info); + next_tvb, pinfo, parent, TRUE, usb_conv_info); if (ret) return tvb_captured_length(next_tvb); } -- cgit v1.2.3