| Wireshark 4.7.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
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 */
95 typedef 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
119} bluetooth_data_t;
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
127 typedef struct _chandle_session_t {
128 uint32_t connect_in_frame;
129 uint32_t disconnect_in_frame;
130 uint32_t link_type;
131} chandle_session_t;
132
133 typedef struct _remote_bdaddr_t {
134 uint32_t interface_id;
135 uint32_t adapter_id;
136 uint16_t chandle;
137 uint8_t bd_addr[6];
138} remote_bdaddr_t;
139
140 typedef struct _device_name_t {
141 uint32_t bd_addr_oui;
142 uint32_t bd_addr_id;
143 char *name;
144} device_name_t;
145
146 typedef struct _device_role_t {
147 uint32_t role;
148 uint32_t change_in_frame;
149} device_role_t;
150
151 typedef struct _connection_mode_t {
152 int32_t mode;
153 uint32_t change_in_frame;
154} connection_mode_t;
155
156 typedef struct _stream_connection_handle_pair_t {
157 int32_t chandle;
158 uint32_t change_in_frame;
159} stream_connection_handle_pair_t;
160
161 typedef struct _cs_configuration_t {
162 uint8_t cs_role;
163 uint8_t rtt_type;
164} cs_configuration_t;
165
166#define ROLE_UNKNOWN 0
167#define ROLE_CENTRAL 1
168#define ROLE_PERIPHERAL 2
169
170 typedef struct _localhost_bdaddr_entry_t {
171 uint32_t interface_id;
172 uint32_t adapter_id;
173 uint8_t bd_addr[6];
174} localhost_bdaddr_entry_t;
175
176 typedef struct _localhost_name_entry_t {
177 uint32_t interface_id;
178 uint32_t adapter_id;
179 char *name;
180} localhost_name_entry_t;
181
182 typedef struct _bluetooth_tap_data_t {
183 uint32_t interface_id;
184 uint32_t adapter_id;
185} bluetooth_tap_data_t;
186
187 typedef 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;
193} hci_vendor_data_t;
194
195 typedef struct _uuid_t {
196 uint16_t bt_uuid;
197 uint8_t size;
198 uint8_t data[16];
199} bluetooth_uuid_t;
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
220 typedef struct _bluetooth_device_tap_t {
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;
263} bluetooth_device_tap_t;
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
279 typedef struct _bluetooth_hci_summary_tap_t {
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;
293} bluetooth_hci_summary_tap_t;
294
295 typedef struct _bluetooth_eir_ad_data_t {
296 uint32_t interface_id;
297 uint32_t adapter_id;
298
299 uint8_t *bd_addr;
300} bluetooth_eir_ad_data_t;
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 void bluetooth_add_custom_uuid(const char *uuid, const char *label, bool long_attr);
311WS_DLL_PUBLIC bool bluetooth_get_custom_uuid_long_attr(const bluetooth_uuid_t *uuid);
312WS_DLL_PUBLIC const char* bluetooth_get_custom_uuid_description(const bluetooth_uuid_t *uuid);
313
314WS_DLL_PUBLIC value_string_ext bluetooth_uuid_vals_ext;
315WS_DLL_PUBLIC value_string_ext bluetooth_company_id_vals_ext;
316
317 typedef struct _btatt_handle_strings_t {
318 uint32_t value;
319 const char *name;
320 const char *short_name;
321 const char *abbrev;
322} btatt_handle_strings_t;
323
324WS_DLL_PUBLIC const btatt_handle_strings_t btatt_handle_strings[];
325
326extern uint32_t bluetooth_max_disconnect_in_frame;
327
328extern int dissect_bd_addr(int hf_bd_addr, packet_info *pinfo, proto_tree *tree,
329 tvbuff_t *tvb, int offset, bool is_local_bd_addr,
330 uint32_t interface_id, uint32_t adapter_id, uint8_t *bdaddr);
331
332extern void bluetooth_unit_0p625_ms(char *buf, uint32_t value);
333extern void bluetooth_unit_1p25_ms(char *buf, uint32_t value);
334extern void bluetooth_unit_0p01_sec(char *buf, uint32_t value);
335extern void bluetooth_unit_0p125_ms(char *buf, uint32_t value);
336
337extern bluetooth_uuid_t get_bluetooth_uuid(tvbuff_t *tvb, int offset, int size);
338WS_DLL_PUBLIC const char *print_bluetooth_uuid(const bluetooth_uuid_t *uuid);
339WS_DLL_PUBLIC const char *print_numeric_bluetooth_uuid(wmem_allocator_t *pool, const bluetooth_uuid_t *uuid);
340
341WS_DLL_PUBLIC const value_string bluetooth_procedure_count_special[];
342WS_DLL_PUBLIC const value_string bluetooth_not_supported_0x00_special[];
343WS_DLL_PUBLIC const value_string bluetooth_not_used_0xff_special[];
344
345extern void save_local_device_name_from_eir_ad(tvbuff_t *tvb, int offset,
346 packet_info *pinfo, uint8_t size, bluetooth_data_t *bluetooth_data);
347
348WS_DLL_PUBLIC bluetooth_data_t *
349dissect_bluetooth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
350
351#ifdef __cplusplus
352}
353#endif /* __cplusplus */
354
355#endif
356
357/*
358 * Editor modelines - https://www.wireshark.org/tools/modelines.html
359 *
360 * Local variables:
361 * c-basic-offset: 4
362 * tab-width: 8
363 * indent-tabs-mode: nil
364 * End:
365 *
366 * vi: set shiftwidth=4 tabstop=8 expandtab:
367 * :indentSize=4:tabSize=8:noTabs=true:
368 */
packet.h
_bluetooth_data_t
Definition packet-bluetooth.h:95
_bluetooth_device_tap_t
Definition packet-bluetooth.h:220
_bluetooth_eir_ad_data_t
Definition packet-bluetooth.h:295
_bluetooth_hci_summary_tap_t
Definition packet-bluetooth.h:279
_bluetooth_tap_data_t
Definition packet-bluetooth.h:182
_btatt_handle_strings_t
Definition packet-bluetooth.h:317
_chandle_session_t
Definition packet-bluetooth.h:127
_connection_mode_t
Definition packet-bluetooth.h:151
_cs_configuration_t
Definition packet-bluetooth.h:161
_device_name_t
Definition packet-bluetooth.h:140
_device_role_t
Definition packet-bluetooth.h:146
_hci_vendor_data_t
Definition packet-bluetooth.h:187
_localhost_bdaddr_entry_t
Definition packet-bluetooth.h:170
_localhost_name_entry_t
Definition packet-bluetooth.h:176
_packet_info
Definition packet_info.h:43
_proto_node
Definition proto.h:907
_remote_bdaddr_t
Definition packet-bluetooth.h:133
_stream_connection_handle_pair_t
Definition packet-bluetooth.h:156
_ubertooth_data_t
Definition packet-ubertooth.h:17
_urb_info_t
Definition packet-usb.h:141
_uuid_t
Definition packet-bluetooth.h:195
_value_string_ext
Extended metadata for a value_string array.
Definition value_string.h:325
_value_string
Mapping between a 32-bit integer value and its string representation.
Definition value_string.h:33
_wmem_allocator_t
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
_wmem_tree_t
Internal representation of a wmem balanced tree.
Definition wmem_tree-int.h:81
bthci_phdr
Definition wtap.h:1143
btmon_phdr
Definition wtap.h:1155
dissector_table
Definition packet.c:97
tvbuff
Definition tvbuff-int.h:35