Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet-bluetooth.h
1/* packet-bluetooth.h
2 *
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10#ifndef __PACKET_BLUETOOTH_H__
11#define __PACKET_BLUETOOTH_H__
12
13#include <epan/packet.h>
14#include "packet-usb.h"
15#include "packet-ubertooth.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21#define PROTO_DATA_BLUETOOTH_SERVICE_UUID 0
22#define PROTO_DATA_BLUETOOTH_EIR_AD_APPLE 1
23
24#define BLUETOOTH_DATA_SRC 0
25#define BLUETOOTH_DATA_DST 1
26
27#define HCI_H4_TYPE_CMD 0x01
28#define HCI_H4_TYPE_ACL 0x02
29#define HCI_H4_TYPE_SCO 0x03
30#define HCI_H4_TYPE_EVT 0x04
31#define HCI_H4_TYPE_ISO 0x05
32
33#define HCI_OGF_LINK_CONTROL 0x01
34#define HCI_OGF_LINK_POLICY 0x02
35#define HCI_OGF_HOST_CONTROLLER 0x03
36#define HCI_OGF_INFORMATIONAL 0x04
37#define HCI_OGF_STATUS 0x05
38#define HCI_OGF_TESTING 0x06
39#define HCI_OGF_LOW_ENERGY 0x08
40#define HCI_OGF_LOGO_TESTING 0x3e
41#define HCI_OGF_VENDOR_SPECIFIC 0x3f
42
43#define HCI_VENDOR_DEFAULT 0
44
45#define DID_VENDOR_ID_SOURCE_BLUETOOTH_SIG 1
46#define DID_VENDOR_ID_SOURCE_USB_FORUM 2
47
48#define ACCESS_ADDRESS_ADVERTISING 0x8e89bed6
49
50extern int proto_bluetooth;
51
52extern const value_string bluetooth_address_type_vals[];
53
54#define STATUS_SUCCESS 0x00
55
56#define UUID_GATT_PRIMARY_SERVICE_DECLARATION 0x2800
57#define UUID_GATT_SECONDARY_SERVICE_DECLARATION 0x2801
58#define UUID_GATT_INCLUDE_DECLARATION 0x2802
59#define UUID_GATT_CHARACTERISTIC_DECLARATION 0x2803
60
61/* We support Bluetooth over various interfaces, interface_id and adapter_id
62 is used to decode further payload. Case: there is a host. Host has X
63 interfaces. Each interface has Y adapter. Each adapter has ACL handle or
64 L2CAP CID. ACL handle has L2CAP CID and/or L2CAP PSM. L2CAP CID or
65 L2CAP PSM has RFCOMM channel or other end-protocol like OBEX, AVRCP, HID,
66 AVDTP, BNEP etc. RFCOMM channel has end-protocol like OBEX, HFP, etc.
67 Important note: correct payload decoding should store needed data using
68 key contain interface_id, adapter_id, ..., last_channel_type (for example
69 RFCOMM channel, transaction_id, frame number etc. )
70
71 interface_id - interface id provided by Wireshark, see "frame.interface_id",
72 in case where is only one interface id HCI_INTERFACE_DEFAULT
73 is used (for example open BTSNOOP file with HCI H4 protocol)
74 adapter_id - identified Bluetooth device (interface, for example Linux
75 hci0, hci1, etc.)
76*/
77#define HCI_INTERFACE_DEFAULT 0
78#define HCI_ADAPTER_DEFAULT 0
79
80typedef enum {
81 BT_PD_NONE, /* no protocol data */
82 BT_PD_BTHCI, /* struct bthci_phdr * */
83 BT_PD_BTMON, /* struct btmon_phdr * */
84 BT_PD_URB_INFO, /* urb_info_t * */
85 BT_PD_UBERTOOTH_DATA /* ubertooth_data_t * */
86} bt_protocol_data_type;
87
88/* chandle_sessions: interface_id + adapter_id + connection_handle + frame_number -> connect_in_frame, disconnect_in_frame */
89/* chandle_to_bdaddr: interface_id + adapter_id + connection_handle + frame_number -> bd_addr[6] */
90/* chandle_to_mode: interface_id + adapter_id + connection_handle + frame_number -> mode */
91/* shandle_to_chandle: interface_id + adapter_id + stream_handle + frame_number -> connection_handle */
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 */
96typedef struct _bluetooth_data_t {
97 uint32_t interface_id;
98 uint32_t adapter_id;
99 uint32_t *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 *cs_configurations;
104 wmem_tree_t *shandle_to_chandle;
105 wmem_tree_t *bdaddr_to_name;
106 wmem_tree_t *bdaddr_to_role;
107 wmem_tree_t *localhost_bdaddr;
108 wmem_tree_t *localhost_name;
109 wmem_tree_t *hci_vendors;
110
111 bt_protocol_data_type previous_protocol_data_type;
112 union {
113 void *none;
114 struct bthci_phdr *bthci;
115 struct btmon_phdr *btmon;
116 urb_info_t *urb;
117 ubertooth_data_t *ubertooth_data;
118 } previous_protocol_data;
119
120} bluetooth_data_t;
121
122#define BT_LINK_TYPE_UNKNOWN 0
123#define BT_LINK_TYPE_ACL 1
124#define BT_LINK_TYPE_SCO 2
125#define BT_LINK_TYPE_LL 3
126#define BT_LINK_TYPE_ISO 4
127
128typedef struct _chandle_session_t {
129 uint32_t connect_in_frame;
130 uint32_t disconnect_in_frame;
131 uint32_t link_type;
132} chandle_session_t;
133
134typedef struct _remote_bdaddr_t {
135 uint32_t interface_id;
136 uint32_t adapter_id;
137 uint16_t chandle;
138 uint8_t bd_addr[6];
139} remote_bdaddr_t;
140
141typedef struct _device_name_t {
142 uint32_t bd_addr_oui;
143 uint32_t bd_addr_id;
144 char *name;
145} device_name_t;
146
147typedef struct _device_role_t {
148 uint32_t role;
149 uint32_t change_in_frame;
150} device_role_t;
151
152typedef struct _connection_mode_t {
153 int32_t mode;
154 uint32_t change_in_frame;
155} connection_mode_t;
156
158 int32_t chandle;
159 uint32_t change_in_frame;
160} stream_connection_handle_pair_t;
161
162typedef struct _cs_configuration_t {
163 uint8_t cs_role;
164 uint8_t rtt_type;
165} cs_configuration_t;
166
167#define ROLE_UNKNOWN 0
168#define ROLE_CENTRAL 1
169#define ROLE_PERIPHERAL 2
170
172 uint32_t interface_id;
173 uint32_t adapter_id;
174 uint8_t bd_addr[6];
175} localhost_bdaddr_entry_t;
176
178 uint32_t interface_id;
179 uint32_t adapter_id;
180 char *name;
181} localhost_name_entry_t;
182
183typedef struct _bluetooth_tap_data_t {
184 uint32_t interface_id;
185 uint32_t adapter_id;
186} bluetooth_tap_data_t;
187
188typedef struct _hci_vendor_data_t {
189 uint16_t manufacturer;
190 uint16_t hci_revision;
191 uint16_t lmp_subversion;
192 uint32_t change_in_frame;
193 struct _hci_vendor_data_t *previous;
194} hci_vendor_data_t;
195
196typedef struct _uuid_t {
197 uint16_t bt_uuid;
198 uint8_t size;
199 uint8_t data[16];
200} bluetooth_uuid_t;
201
202enum bluetooth_device_type {
203 BLUETOOTH_DEVICE_BD_ADDR,
204 BLUETOOTH_DEVICE_NAME,
205 BLUETOOTH_DEVICE_LOCAL_ADAPTER,
206 BLUETOOTH_DEVICE_LOCAL_VERSION,
207 BLUETOOTH_DEVICE_REMOTE_VERSION,
208 BLUETOOTH_DEVICE_RESET,
209 BLUETOOTH_DEVICE_SCAN,
210 BLUETOOTH_DEVICE_VOICE_SETTING,
211 BLUETOOTH_DEVICE_AUTHENTICATION,
212 BLUETOOTH_DEVICE_ENCRYPTION,
213 BLUETOOTH_DEVICE_CLASS_OF_DEVICE,
214 BLUETOOTH_DEVICE_SIMPLE_PAIRING_MODE,
215 BLUETOOTH_DEVICE_PAGE_TIMEOUT,
216 BLUETOOTH_DEVICE_INQUIRY_MODE,
217 BLUETOOTH_DEVICE_MTUS,
218 BLUETOOTH_DEVICE_LE_MTU
219};
220
222 uint32_t interface_id;
223 uint32_t adapter_id;
224
225 bool is_local;
226 bool has_bd_addr;
227 uint8_t bd_addr[6];
228 enum bluetooth_device_type type;
229 union {
230 char *name;
231 struct {
232 uint8_t hci_version;
233 uint16_t hci_revision;
234 uint8_t lmp_version;
235 uint16_t lmp_subversion;
236 uint16_t manufacturer;
237 } local_version;
238 struct {
239 uint8_t lmp_version;
240 uint16_t lmp_subversion;
241 uint16_t manufacturer;
242 } remote_version;
243 uint8_t scan;
244 uint16_t page_timeout;
245 uint8_t authentication;
246 uint8_t encryption;
247 uint32_t class_of_device;
248 uint16_t voice_setting;
249 uint8_t simple_pairing_mode;
250 uint8_t inquiry_mode;
251 struct {
252 uint16_t acl_mtu;
253 uint8_t sco_mtu;
254 uint16_t acl_packets;
255 uint16_t sco_packets;
256 } mtus;
257 struct {
258 uint16_t acl_mtu;
259 uint16_t iso_mtu;
260 uint16_t acl_packets;
261 uint16_t iso_packets;
262 } le_mtus;
263 } data;
264} bluetooth_device_tap_t;
265
266enum bluetooth_hci_summary_type {
267 BLUETOOTH_HCI_SUMMARY_OPCODE,
268 BLUETOOTH_HCI_SUMMARY_EVENT_OPCODE,
269 BLUETOOTH_HCI_SUMMARY_EVENT,
270 BLUETOOTH_HCI_SUMMARY_SUBEVENT,
271 BLUETOOTH_HCI_SUMMARY_VENDOR_OPCODE,
272 BLUETOOTH_HCI_SUMMARY_VENDOR_EVENT_OPCODE,
273 BLUETOOTH_HCI_SUMMARY_VENDOR_EVENT,
274 BLUETOOTH_HCI_SUMMARY_STATUS,
275 BLUETOOTH_HCI_SUMMARY_STATUS_PENDING,
276 BLUETOOTH_HCI_SUMMARY_REASON,
277 BLUETOOTH_HCI_SUMMARY_HARDWARE_ERROR
278};
279
281 uint32_t interface_id;
282 uint32_t adapter_id;
283
284 uint16_t ocf;
285 uint8_t ogf;
286 uint8_t event;
287 uint8_t subevent;
288 uint8_t status;
289 uint8_t reason;
290 uint8_t hardware_error;
291
292 const char *name;
293 enum bluetooth_hci_summary_type type;
294} bluetooth_hci_summary_tap_t;
295
297 uint32_t interface_id;
298 uint32_t adapter_id;
299
300 uint8_t *bd_addr;
301} bluetooth_eir_ad_data_t;
302
303/* Apple vendor specific data */
305 uint32_t apple_os_flag;
306 uint32_t ios_13_flag;
307} bluetooth_eir_ad_apple_data_t;
308
309extern int bluetooth_device_tap;
310extern int bluetooth_hci_summary_tap;
311
312WS_DLL_PUBLIC const value_string bluetooth_uuid_vals[];
313
314extern dissector_table_t bluetooth_uuid_table;
315
316WS_DLL_PUBLIC void bluetooth_add_custom_uuid(const char *uuid, const char *label, bool long_attr);
317WS_DLL_PUBLIC bool bluetooth_get_custom_uuid_long_attr(const bluetooth_uuid_t *uuid);
318WS_DLL_PUBLIC const char* bluetooth_get_custom_uuid_description(const bluetooth_uuid_t *uuid);
319
320WS_DLL_PUBLIC value_string_ext bluetooth_uuid_vals_ext;
321WS_DLL_PUBLIC value_string_ext bluetooth_company_id_vals_ext;
322
324 uint32_t value;
325 const char *name;
326 const char *short_name;
327 const char *abbrev;
328} btatt_handle_strings_t;
329
330WS_DLL_PUBLIC const btatt_handle_strings_t btatt_handle_strings[];
331
332extern uint32_t bluetooth_max_disconnect_in_frame;
333
334extern int dissect_bd_addr(int hf_bd_addr, packet_info *pinfo, proto_tree *tree,
335 tvbuff_t *tvb, int offset, bool is_local_bd_addr,
336 uint32_t interface_id, uint32_t adapter_id, uint8_t *bdaddr);
337
338extern void bluetooth_unit_0p625_ms(char *buf, uint32_t value);
339extern void bluetooth_unit_1p25_ms(char *buf, uint32_t value);
340extern void bluetooth_unit_0p01_sec(char *buf, uint32_t value);
341extern void bluetooth_unit_0p125_ms(char *buf, uint32_t value);
342
343extern bluetooth_uuid_t get_bluetooth_uuid(tvbuff_t *tvb, int offset, int size);
344extern bluetooth_uuid_t get_bluetooth_uuid_be(tvbuff_t *tvb, int offset, int size);
345WS_DLL_PUBLIC const char *try_print_bluetooth_uuid(const bluetooth_uuid_t *uuid);
346WS_DLL_PUBLIC const char *print_bluetooth_uuid(const bluetooth_uuid_t *uuid);
347WS_DLL_PUBLIC const char *print_numeric_bluetooth_uuid(wmem_allocator_t *pool, const bluetooth_uuid_t *uuid);
348
349WS_DLL_PUBLIC const value_string bluetooth_procedure_count_special[];
350WS_DLL_PUBLIC const value_string bluetooth_not_supported_0x00_special[];
351WS_DLL_PUBLIC const value_string bluetooth_not_used_0xff_special[];
352WS_DLL_PUBLIC const true_false_string tfs_rtt_accuracy;
353
354extern void save_local_device_name_from_eir_ad(tvbuff_t *tvb, int offset,
355 packet_info *pinfo, uint8_t size, bluetooth_data_t *bluetooth_data);
356
357WS_DLL_PUBLIC bluetooth_data_t *
358dissect_bluetooth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
359
360#ifdef __cplusplus
361}
362#endif /* __cplusplus */
363
364#endif
365
366/*
367 * Editor modelines - https://www.wireshark.org/tools/modelines.html
368 *
369 * Local variables:
370 * c-basic-offset: 4
371 * tab-width: 8
372 * indent-tabs-mode: nil
373 * End:
374 *
375 * vi: set shiftwidth=4 tabstop=8 expandtab:
376 * :indentSize=4:tabSize=8:noTabs=true:
377 */
struct _packet_info packet_info
Represents the metadata and indexing information for a single captured frame.
struct _wmem_tree_t wmem_tree_t
Opaque type representing a red-black tree in the wmem system.
Definition wmem_tree.h:49
struct _wmem_allocator_t wmem_allocator_t
Definition wmem_core.h:44
Definition packet-bluetooth.h:96
Definition packet-bluetooth.h:221
Definition packet-bluetooth.h:304
Definition packet-bluetooth.h:296
Definition packet-bluetooth.h:280
Definition packet-bluetooth.h:183
Definition packet-bluetooth.h:323
Definition packet-bluetooth.h:128
Definition packet-bluetooth.h:152
Definition packet-bluetooth.h:162
Definition packet-bluetooth.h:141
Definition packet-bluetooth.h:147
Definition packet-bluetooth.h:188
Definition packet-bluetooth.h:171
Definition packet-bluetooth.h:177
Definition packet-bluetooth.h:134
Definition packet-bluetooth.h:157
Definition packet-bluetooth.h:196
Pseudo-header for Bluetooth HCI capture files carrying direction and channel metadata.
Definition wtap.h:1185
Pseudo-header for Linux Bluetooth Monitor (WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR) capture files.
Definition wtap.h:1199
Definition tfs.h:24
struct _value_string value_string
Mapping between a 32-bit integer value and its string representation.