3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef __PACKET_BLUETOOTH_H__
23 #define __PACKET_BLUETOOTH_H__
27 #endif /* __cplusplus */
29 #include <epan/wmem/wmem.h>
31 #include "packet-usb.h"
32 #include "packet-ubertooth.h"
34 #define BLUETOOTH_DATA_SRC 0
35 #define BLUETOOTH_DATA_DST 1
37 #define HCI_H4_TYPE_CMD 0x01
38 #define HCI_H4_TYPE_ACL 0x02
39 #define HCI_H4_TYPE_SCO 0x03
40 #define HCI_H4_TYPE_EVT 0x04
42 #define HCI_OGF_LINK_CONTROL 0x01
43 #define HCI_OGF_LINK_POLICY 0x02
44 #define HCI_OGF_HOST_CONTROLLER 0x03
45 #define HCI_OGF_INFORMATIONAL 0x04
46 #define HCI_OGF_STATUS 0x05
47 #define HCI_OGF_TESTING 0x06
48 #define HCI_OGF_LOW_ENERGY 0x08
49 #define HCI_OGF_LOGO_TESTING 0x3e
50 #define HCI_OGF_VENDOR_SPECIFIC 0x3f
52 #define HCI_VENDOR_DEFAULT 0
54 #define DID_VENDOR_ID_SOURCE_BLUETOOTH_SIG 1
55 #define DID_VENDOR_ID_SOURCE_USB_FORUM 2
57 #define ACCESS_ADDRESS_ADVERTISING 0x8e89bed6
59 extern int proto_bluetooth;
61 extern const value_string bluetooth_address_type_vals[];
63 #define STATUS_SUCCESS 0x00
65 #define UUID_GATT_PRIMARY_SERVICE_DECLARATION 0x2800
66 #define UUID_GATT_SECONDARY_SERVICE_DECLARATION 0x2801
67 #define UUID_GATT_INCLUDE_DECLARATION 0x2802
68 #define UUID_GATT_CHARACTERISTIC_DECLARATION 0x2803
70 /* We support Bluetooth over various interfaces, interface_id and adapter_id
71 is used to decode further payload. Case: there is a host. Host has X
72 interfaces. Each interface has Y adapter. Each adapter has ACL handle or
73 L2CAP CID. ACL handle has L2CAP CID and/or L2CAP PSM. L2CAP CID or
74 L2CAP PSM has RFCOMM channel or other end-protocol like OBEX, AVRCP, HID,
75 AVDTP, BNEP etc. RFCOMM channel has end-protocol like OBEX, HFP, etc.
76 Important note: correct payload decoding should store needed data using
77 key contain interface_id, adapter_id, ..., last_channel_type (for example
78 RFCOMM channel, transaction_id, frame number etc. )
80 interface_id - interface id provided by Wireshark, see "frame.interface_id",
81 in case where is only one interface id HCI_INTERFACE_DEFAULT
82 is used (for example open BTSNOOP file with HCI H4 protocol)
83 adapter_id - identified Bluetooth device (interface, for example Linux
86 #define HCI_INTERFACE_DEFAULT 0
87 #define HCI_ADAPTER_DEFAULT 0
89 /* chandle_sessions: interface_id + adapter_id + connection_handle + frame_number -> connect_in_frame, disconnect_in_frame */
90 /* chandle_to_bdaddr: interface_id + adapter_id + connection_handle + frame_number -> bd_addr[6] */
91 /* chandle_to_mode: interface_id + adapter_id + connection_handle + frame_number -> mode */
92 /* bdaddr_to_name: bd_addr[6] + frame_number -> name */
93 /* bdaddr_to_role: bd_addr[6] + frame_number -> role */
94 /* localhost_bdaddr: interface_id + adapter_id + frame_number -> bd_addr[6] */
95 /* localhost_name: interface_id + adapter_id + frame_number -> name */
96 typedef struct _bluetooth_data_t {
99 guint32 *adapter_disconnect_in_frame;
100 wmem_tree_t *chandle_sessions;
101 wmem_tree_t *chandle_to_bdaddr;
102 wmem_tree_t *chandle_to_mode;
103 wmem_tree_t *bdaddr_to_name;
104 wmem_tree_t *bdaddr_to_role;
105 wmem_tree_t *localhost_bdaddr;
106 wmem_tree_t *localhost_name;
107 wmem_tree_t *hci_vendors;
111 usb_conv_info_t *usb_conv_info;
112 ubertooth_data_t *ubertooth_data;
113 } previous_protocol_data;
117 typedef struct _chandle_session_t {
118 guint32 connect_in_frame;
119 guint32 disconnect_in_frame;
122 typedef struct _remote_bdaddr_t {
123 guint32 interface_id;
129 typedef struct _device_name_t {
135 typedef struct _device_role_t {
137 guint32 change_in_frame;
140 typedef struct _connection_mode_t {
142 guint32 change_in_frame;
145 #define ROLE_UNKNOWN 0
146 #define ROLE_MASTER 1
149 typedef struct _localhost_bdaddr_entry_t {
150 guint32 interface_id;
153 } localhost_bdaddr_entry_t;
155 typedef struct _localhost_name_entry_t {
156 guint32 interface_id;
159 } localhost_name_entry_t;
161 typedef struct _bluetooth_tap_data_t {
162 guint32 interface_id;
164 } bluetooth_tap_data_t;
166 typedef struct _hci_vendor_data_t {
167 guint16 manufacturer;
168 guint16 hci_revision;
169 guint16 lmp_subversion;
170 guint32 change_in_frame;
171 struct _hci_vendor_data_t *previous;
174 typedef struct _uuid_t {
180 typedef struct _bluetooth_uuid_custom {
181 const guint8 uuid[16];
184 } bluetooth_uuid_custom_t;
186 enum bluetooth_device_type {
187 BLUETOOTH_DEVICE_BD_ADDR,
188 BLUETOOTH_DEVICE_NAME,
189 BLUETOOTH_DEVICE_LOCAL_ADAPTER,
190 BLUETOOTH_DEVICE_LOCAL_VERSION,
191 BLUETOOTH_DEVICE_REMOTE_VERSION
194 typedef struct _bluetooth_device_tap_t {
195 guint32 interface_id;
199 gboolean has_bd_addr;
201 enum bluetooth_device_type type;
206 guint16 hci_revision;
208 guint16 lmp_subversion;
209 guint16 manufacturer;
213 guint16 lmp_subversion;
214 guint16 manufacturer;
217 } bluetooth_device_tap_t;
219 extern int bluetooth_device_tap;
221 WS_DLL_PUBLIC const value_string bluetooth_uuid_vals[];
222 WS_DLL_PUBLIC const bluetooth_uuid_custom_t bluetooth_uuid_custom[];
224 WS_DLL_PUBLIC value_string_ext bluetooth_uuid_vals_ext;
225 WS_DLL_PUBLIC value_string_ext bluetooth_company_id_vals_ext;
226 extern guint32 max_disconnect_in_frame;
228 extern gint dissect_bd_addr(gint hf_bd_addr, packet_info *pinfo, proto_tree *tree,
229 tvbuff_t *tvb, gint offset, gboolean is_local_bd_addr,
230 guint32 interface_id, guint32 adapter_id, guint8 *bdaddr);
232 extern bluetooth_uuid_t get_uuid(tvbuff_t *tvb, gint offset, gint size);
233 extern gchar *print_uuid(bluetooth_uuid_t *uuid);
234 extern gchar *print_numeric_uuid(bluetooth_uuid_t *uuid);
236 extern void save_local_device_name_from_eir_ad(tvbuff_t *tvb, gint offset,
237 packet_info *pinfo, guint8 size, bluetooth_data_t *bluetooth_data);
241 #endif /* __cplusplus */
246 * Editor modelines - http://www.wireshark.org/tools/modelines.html
251 * indent-tabs-mode: nil
254 * vi: set shiftwidth=4 tabstop=8 expandtab:
255 * :indentSize=4:tabSize=8:noTabs=true: