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