2014-12-12 10:24:44 +00:00
|
|
|
/* packet-bluetooth.h
|
2006-05-09 09:13:20 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2006-05-09 09:13:20 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-12 11:23:27 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2006-05-09 09:13:20 +00:00
|
|
|
*/
|
|
|
|
|
2014-12-12 10:24:44 +00:00
|
|
|
#ifndef __PACKET_BLUETOOTH_H__
|
|
|
|
#define __PACKET_BLUETOOTH_H__
|
2006-05-09 09:13:20 +00:00
|
|
|
|
2015-01-22 11:27:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2013-06-20 16:31:53 +00:00
|
|
|
#include <epan/wmem/wmem.h>
|
|
|
|
|
2014-12-20 23:00:57 +00:00
|
|
|
#include "packet-usb.h"
|
|
|
|
#include "packet-ubertooth.h"
|
2014-12-12 10:24:44 +00:00
|
|
|
|
2015-07-13 17:01:48 +00:00
|
|
|
#define PROTO_DATA_BLUETOOTH_SERVICE_UUID 0
|
|
|
|
|
2014-12-12 10:24:44 +00:00
|
|
|
#define BLUETOOTH_DATA_SRC 0
|
|
|
|
#define BLUETOOTH_DATA_DST 1
|
|
|
|
|
2013-07-23 04:15:23 +00:00
|
|
|
#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
|
2006-05-09 09:13:20 +00:00
|
|
|
|
2014-08-22 13:33:17 +00:00
|
|
|
#define HCI_VENDOR_DEFAULT 0
|
|
|
|
|
2013-08-18 02:11:36 +00:00
|
|
|
#define DID_VENDOR_ID_SOURCE_BLUETOOTH_SIG 1
|
|
|
|
#define DID_VENDOR_ID_SOURCE_USB_FORUM 2
|
2006-05-14 06:24:57 +00:00
|
|
|
|
2013-12-23 18:56:06 +00:00
|
|
|
#define ACCESS_ADDRESS_ADVERTISING 0x8e89bed6
|
|
|
|
|
2014-12-12 10:24:44 +00:00
|
|
|
extern int proto_bluetooth;
|
|
|
|
|
2014-12-29 07:53:15 +00:00
|
|
|
extern const value_string bluetooth_address_type_vals[];
|
|
|
|
|
2014-12-29 08:45:40 +00:00
|
|
|
#define STATUS_SUCCESS 0x00
|
2012-11-29 13:21:10 +00:00
|
|
|
|
2014-12-31 09:52:28 +00:00
|
|
|
#define UUID_GATT_PRIMARY_SERVICE_DECLARATION 0x2800
|
|
|
|
#define UUID_GATT_SECONDARY_SERVICE_DECLARATION 0x2801
|
|
|
|
#define UUID_GATT_INCLUDE_DECLARATION 0x2802
|
|
|
|
#define UUID_GATT_CHARACTERISTIC_DECLARATION 0x2803
|
|
|
|
|
2013-02-14 15:29:25 +00:00
|
|
|
/* 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
|
2014-03-03 07:51:04 +00:00
|
|
|
RFCOMM channel, transaction_id, frame number etc. )
|
2012-11-29 13:21:10 +00:00
|
|
|
|
2014-03-03 07:51:04 +00:00
|
|
|
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
|
2012-11-29 13:21:10 +00:00
|
|
|
|
2015-06-16 03:23:24 +00:00
|
|
|
typedef enum {
|
|
|
|
BT_PD_NONE, /* no protocol data */
|
|
|
|
BT_PD_BTHCI, /* struct bthci_phdr * */
|
|
|
|
BT_PD_BTMON, /* struct btmon_phdr * */
|
|
|
|
BT_PD_USB_CONV_INFO, /* usb_conv_info_t * */
|
|
|
|
BT_PD_UBERTOOTH_DATA /* ubertooth_data_t * */
|
|
|
|
} bt_protocol_data_type;
|
|
|
|
|
2014-12-12 10:24:44 +00:00
|
|
|
/* 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 */
|
2012-11-29 13:21:10 +00:00
|
|
|
/* localhost_bdaddr: interface_id + adapter_id + frame_number -> bd_addr[6] */
|
|
|
|
/* localhost_name: interface_id + adapter_id + frame_number -> name */
|
2014-12-12 10:24:44 +00:00
|
|
|
typedef struct _bluetooth_data_t {
|
2014-06-02 15:05:31 +00:00
|
|
|
guint32 interface_id;
|
|
|
|
guint32 adapter_id;
|
|
|
|
guint32 *adapter_disconnect_in_frame;
|
|
|
|
wmem_tree_t *chandle_sessions;
|
2014-12-12 10:24:44 +00:00
|
|
|
wmem_tree_t *chandle_to_bdaddr;
|
|
|
|
wmem_tree_t *chandle_to_mode;
|
|
|
|
wmem_tree_t *bdaddr_to_name;
|
|
|
|
wmem_tree_t *bdaddr_to_role;
|
2013-06-20 16:31:53 +00:00
|
|
|
wmem_tree_t *localhost_bdaddr;
|
|
|
|
wmem_tree_t *localhost_name;
|
2014-12-29 08:45:40 +00:00
|
|
|
wmem_tree_t *hci_vendors;
|
2014-12-12 10:24:44 +00:00
|
|
|
|
2015-06-16 03:23:24 +00:00
|
|
|
bt_protocol_data_type previous_protocol_data_type;
|
2014-12-12 10:24:44 +00:00
|
|
|
union {
|
2015-06-16 03:24:35 +00:00
|
|
|
void *none;
|
|
|
|
struct bthci_phdr *bthci;
|
|
|
|
struct btmon_phdr *btmon;
|
2014-12-12 10:24:44 +00:00
|
|
|
usb_conv_info_t *usb_conv_info;
|
|
|
|
ubertooth_data_t *ubertooth_data;
|
|
|
|
} previous_protocol_data;
|
|
|
|
|
|
|
|
} bluetooth_data_t;
|
2012-11-29 13:21:10 +00:00
|
|
|
|
2018-10-31 09:48:58 +00:00
|
|
|
#define BT_LINK_TYPE_UNKNOWN 0
|
|
|
|
#define BT_LINK_TYPE_ACL 1
|
|
|
|
#define BT_LINK_TYPE_SCO 2
|
|
|
|
#define BT_LINK_TYPE_LL 3
|
|
|
|
|
2014-06-02 15:05:31 +00:00
|
|
|
typedef struct _chandle_session_t {
|
|
|
|
guint32 connect_in_frame;
|
|
|
|
guint32 disconnect_in_frame;
|
2018-10-31 09:48:58 +00:00
|
|
|
guint32 link_type;
|
2014-06-02 15:05:31 +00:00
|
|
|
} chandle_session_t;
|
|
|
|
|
2012-11-29 13:21:10 +00:00
|
|
|
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;
|
|
|
|
|
2014-12-12 10:24:44 +00:00
|
|
|
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
|
|
|
|
|
2012-11-29 13:21:10 +00:00
|
|
|
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;
|
|
|
|
|
2014-12-12 10:24:44 +00:00
|
|
|
typedef struct _bluetooth_tap_data_t {
|
|
|
|
guint32 interface_id;
|
|
|
|
guint32 adapter_id;
|
|
|
|
} bluetooth_tap_data_t;
|
|
|
|
|
2014-12-29 08:45:40 +00:00
|
|
|
typedef struct _hci_vendor_data_t {
|
|
|
|
guint16 manufacturer;
|
|
|
|
guint16 hci_revision;
|
|
|
|
guint16 lmp_subversion;
|
|
|
|
guint32 change_in_frame;
|
|
|
|
struct _hci_vendor_data_t *previous;
|
|
|
|
} hci_vendor_data_t;
|
2014-12-12 10:24:44 +00:00
|
|
|
|
2014-12-31 09:52:28 +00:00
|
|
|
typedef struct _uuid_t {
|
|
|
|
guint16 bt_uuid;
|
|
|
|
guint8 size;
|
|
|
|
guint8 data[16];
|
2015-02-07 22:51:06 +00:00
|
|
|
} bluetooth_uuid_t;
|
2014-12-31 09:52:28 +00:00
|
|
|
|
2015-05-13 15:33:28 +00:00
|
|
|
enum bluetooth_device_type {
|
|
|
|
BLUETOOTH_DEVICE_BD_ADDR,
|
|
|
|
BLUETOOTH_DEVICE_NAME,
|
|
|
|
BLUETOOTH_DEVICE_LOCAL_ADAPTER,
|
|
|
|
BLUETOOTH_DEVICE_LOCAL_VERSION,
|
2015-05-19 09:55:01 +00:00
|
|
|
BLUETOOTH_DEVICE_REMOTE_VERSION,
|
|
|
|
BLUETOOTH_DEVICE_RESET,
|
|
|
|
BLUETOOTH_DEVICE_SCAN,
|
|
|
|
BLUETOOTH_DEVICE_VOICE_SETTING,
|
|
|
|
BLUETOOTH_DEVICE_AUTHENTICATION,
|
|
|
|
BLUETOOTH_DEVICE_ENCRYPTION,
|
|
|
|
BLUETOOTH_DEVICE_CLASS_OF_DEVICE,
|
|
|
|
BLUETOOTH_DEVICE_SIMPLE_PAIRING_MODE,
|
|
|
|
BLUETOOTH_DEVICE_PAGE_TIMEOUT,
|
|
|
|
BLUETOOTH_DEVICE_INQUIRY_MODE,
|
|
|
|
BLUETOOTH_DEVICE_MTUS,
|
|
|
|
BLUETOOTH_DEVICE_LE_MTU
|
2015-05-13 15:33:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _bluetooth_device_tap_t {
|
|
|
|
guint32 interface_id;
|
|
|
|
guint32 adapter_id;
|
|
|
|
|
|
|
|
gboolean is_local;
|
|
|
|
gboolean has_bd_addr;
|
|
|
|
guint8 bd_addr[6];
|
|
|
|
enum bluetooth_device_type type;
|
|
|
|
union {
|
|
|
|
char *name;
|
|
|
|
struct {
|
|
|
|
guint8 hci_version;
|
|
|
|
guint16 hci_revision;
|
|
|
|
guint8 lmp_version;
|
|
|
|
guint16 lmp_subversion;
|
|
|
|
guint16 manufacturer;
|
|
|
|
} local_version;
|
|
|
|
struct {
|
|
|
|
guint8 lmp_version;
|
|
|
|
guint16 lmp_subversion;
|
|
|
|
guint16 manufacturer;
|
|
|
|
} remote_version;
|
2015-05-19 09:55:01 +00:00
|
|
|
guint8 scan;
|
|
|
|
guint16 page_timeout;
|
|
|
|
guint8 authentication;
|
|
|
|
guint8 encryption;
|
|
|
|
guint32 class_of_device;
|
|
|
|
guint16 voice_setting;
|
|
|
|
guint8 simple_pairing_mode;
|
|
|
|
guint8 inquiry_mode;
|
|
|
|
struct {
|
|
|
|
guint16 acl_mtu;
|
|
|
|
guint8 sco_mtu;
|
|
|
|
guint16 acl_packets;
|
|
|
|
guint16 sco_packets;
|
|
|
|
} mtus;
|
|
|
|
struct {
|
|
|
|
guint16 acl_mtu;
|
|
|
|
guint16 acl_packets;
|
|
|
|
} le_mtus;
|
2015-05-13 15:33:28 +00:00
|
|
|
} data;
|
|
|
|
} bluetooth_device_tap_t;
|
|
|
|
|
2015-06-08 17:38:48 +00:00
|
|
|
enum bluetooth_hci_summary_type {
|
|
|
|
BLUETOOTH_HCI_SUMMARY_OPCODE,
|
|
|
|
BLUETOOTH_HCI_SUMMARY_EVENT_OPCODE,
|
|
|
|
BLUETOOTH_HCI_SUMMARY_EVENT,
|
2016-10-24 13:49:29 +00:00
|
|
|
BLUETOOTH_HCI_SUMMARY_SUBEVENT,
|
2015-06-08 17:38:48 +00:00
|
|
|
BLUETOOTH_HCI_SUMMARY_VENDOR_OPCODE,
|
|
|
|
BLUETOOTH_HCI_SUMMARY_VENDOR_EVENT_OPCODE,
|
|
|
|
BLUETOOTH_HCI_SUMMARY_VENDOR_EVENT,
|
|
|
|
BLUETOOTH_HCI_SUMMARY_STATUS,
|
|
|
|
BLUETOOTH_HCI_SUMMARY_STATUS_PENDING,
|
|
|
|
BLUETOOTH_HCI_SUMMARY_REASON,
|
|
|
|
BLUETOOTH_HCI_SUMMARY_HARDWARE_ERROR
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _bluetooth_hci_summary_tap_t {
|
|
|
|
guint32 interface_id;
|
|
|
|
guint32 adapter_id;
|
|
|
|
|
2015-07-17 16:01:27 +00:00
|
|
|
guint16 ocf;
|
2015-06-08 17:38:48 +00:00
|
|
|
guint8 ogf;
|
|
|
|
guint8 event;
|
2016-10-24 13:49:29 +00:00
|
|
|
guint8 subevent;
|
2015-06-08 17:38:48 +00:00
|
|
|
guint8 status;
|
|
|
|
guint8 reason;
|
|
|
|
guint8 hardware_error;
|
|
|
|
|
|
|
|
const gchar *name;
|
|
|
|
enum bluetooth_hci_summary_type type;
|
|
|
|
} bluetooth_hci_summary_tap_t;
|
|
|
|
|
2015-12-14 16:28:06 +00:00
|
|
|
typedef struct _bluetooth_eir_ad_data_t {
|
|
|
|
guint32 interface_id;
|
|
|
|
guint32 adapter_id;
|
|
|
|
|
|
|
|
guint8 *bd_addr;
|
|
|
|
} bluetooth_eir_ad_data_t;
|
|
|
|
|
|
|
|
|
2015-05-13 15:33:28 +00:00
|
|
|
extern int bluetooth_device_tap;
|
2015-06-08 17:38:48 +00:00
|
|
|
extern int bluetooth_hci_summary_tap;
|
2015-05-13 15:33:28 +00:00
|
|
|
|
2015-01-22 11:27:23 +00:00
|
|
|
WS_DLL_PUBLIC const value_string bluetooth_uuid_vals[];
|
2014-12-31 09:52:28 +00:00
|
|
|
|
2015-07-13 17:01:48 +00:00
|
|
|
extern dissector_table_t bluetooth_uuid_table;
|
|
|
|
|
2015-10-18 13:06:30 +00:00
|
|
|
WS_DLL_PUBLIC wmem_tree_t *bluetooth_uuids;
|
|
|
|
|
2015-01-22 11:27:23 +00:00
|
|
|
WS_DLL_PUBLIC value_string_ext bluetooth_uuid_vals_ext;
|
2015-05-13 15:33:28 +00:00
|
|
|
WS_DLL_PUBLIC value_string_ext bluetooth_company_id_vals_ext;
|
2014-12-12 10:24:44 +00:00
|
|
|
extern guint32 max_disconnect_in_frame;
|
|
|
|
|
2015-05-13 15:33:28 +00:00
|
|
|
extern gint dissect_bd_addr(gint hf_bd_addr, packet_info *pinfo, proto_tree *tree,
|
|
|
|
tvbuff_t *tvb, gint offset, gboolean is_local_bd_addr,
|
|
|
|
guint32 interface_id, guint32 adapter_id, guint8 *bdaddr);
|
2014-01-12 00:50:41 +00:00
|
|
|
|
2015-02-07 22:51:06 +00:00
|
|
|
extern bluetooth_uuid_t get_uuid(tvbuff_t *tvb, gint offset, gint size);
|
2015-11-25 06:21:15 +00:00
|
|
|
WS_DLL_PUBLIC const gchar *print_uuid(bluetooth_uuid_t *uuid);
|
|
|
|
WS_DLL_PUBLIC const gchar *print_numeric_uuid(bluetooth_uuid_t *uuid);
|
2014-12-31 09:52:28 +00:00
|
|
|
|
2014-12-23 13:57:45 +00:00
|
|
|
extern void save_local_device_name_from_eir_ad(tvbuff_t *tvb, gint offset,
|
|
|
|
packet_info *pinfo, guint8 size, bluetooth_data_t *bluetooth_data);
|
|
|
|
|
2015-01-22 11:27:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2012-11-29 16:46:41 +00:00
|
|
|
#endif
|
2014-09-28 23:25:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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:
|
|
|
|
*/
|