Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-bluetooth.h
blob354da6651f9d48ad5984cb4dd55acfd6a90323b5
1 /* packet-bluetooth.h
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #ifndef __PACKET_BLUETOOTH_H__
11 #define __PACKET_BLUETOOTH_H__
13 #include <epan/packet.h>
14 #include "packet-usb.h"
15 #include "packet-ubertooth.h"
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
21 #define PROTO_DATA_BLUETOOTH_SERVICE_UUID 0
23 #define BLUETOOTH_DATA_SRC 0
24 #define BLUETOOTH_DATA_DST 1
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
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
42 #define HCI_VENDOR_DEFAULT 0
44 #define DID_VENDOR_ID_SOURCE_BLUETOOTH_SIG 1
45 #define DID_VENDOR_ID_SOURCE_USB_FORUM 2
47 #define ACCESS_ADDRESS_ADVERTISING 0x8e89bed6
49 extern int proto_bluetooth;
51 extern const value_string bluetooth_address_type_vals[];
53 #define STATUS_SUCCESS 0x00
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
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. )
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.)
76 #define HCI_INTERFACE_DEFAULT 0
77 #define HCI_ADAPTER_DEFAULT 0
79 typedef 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;
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;
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;
119 } bluetooth_data_t;
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
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;
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;
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;
146 typedef struct _device_role_t {
147 uint32_t role;
148 uint32_t change_in_frame;
149 } device_role_t;
151 typedef struct _connection_mode_t {
152 int32_t mode;
153 uint32_t change_in_frame;
154 } connection_mode_t;
156 typedef struct _stream_connection_handle_pair_t {
157 int32_t chandle;
158 uint32_t change_in_frame;
159 } stream_connection_handle_pair_t;
161 typedef struct _cs_configuration_t {
162 uint8_t cs_role;
163 uint8_t rtt_type;
164 } cs_configuration_t;
166 #define ROLE_UNKNOWN 0
167 #define ROLE_CENTRAL 1
168 #define ROLE_PERIPHERAL 2
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;
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;
182 typedef struct _bluetooth_tap_data_t {
183 uint32_t interface_id;
184 uint32_t adapter_id;
185 } bluetooth_tap_data_t;
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;
195 typedef struct _uuid_t {
196 uint16_t bt_uuid;
197 uint8_t size;
198 uint8_t data[16];
199 } bluetooth_uuid_t;
201 enum 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
220 typedef struct _bluetooth_device_tap_t {
221 uint32_t interface_id;
222 uint32_t adapter_id;
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;
265 enum 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
279 typedef struct _bluetooth_hci_summary_tap_t {
280 uint32_t interface_id;
281 uint32_t adapter_id;
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;
291 const char *name;
292 enum bluetooth_hci_summary_type type;
293 } bluetooth_hci_summary_tap_t;
295 typedef struct _bluetooth_eir_ad_data_t {
296 uint32_t interface_id;
297 uint32_t adapter_id;
299 uint8_t *bd_addr;
300 } bluetooth_eir_ad_data_t;
303 extern int bluetooth_device_tap;
304 extern int bluetooth_hci_summary_tap;
306 WS_DLL_PUBLIC const value_string bluetooth_uuid_vals[];
308 extern dissector_table_t bluetooth_uuid_table;
310 WS_DLL_PUBLIC wmem_tree_t *bluetooth_uuids;
312 WS_DLL_PUBLIC value_string_ext bluetooth_uuid_vals_ext;
313 WS_DLL_PUBLIC value_string_ext bluetooth_company_id_vals_ext;
314 extern uint32_t bluetooth_max_disconnect_in_frame;
316 extern 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);
320 extern void bluetooth_unit_0p625_ms(char *buf, uint32_t value);
321 extern void bluetooth_unit_1p25_ms(char *buf, uint32_t value);
322 extern void bluetooth_unit_0p01_sec(char *buf, uint32_t value);
323 extern void bluetooth_unit_0p125_ms(char *buf, uint32_t value);
325 extern bluetooth_uuid_t get_bluetooth_uuid(tvbuff_t *tvb, int offset, int size);
326 WS_DLL_PUBLIC const char *print_bluetooth_uuid(wmem_allocator_t *pool, bluetooth_uuid_t *uuid);
327 WS_DLL_PUBLIC const char *print_numeric_bluetooth_uuid(wmem_allocator_t *pool, bluetooth_uuid_t *uuid);
329 WS_DLL_PUBLIC const value_string bluetooth_procedure_count_special[];
330 WS_DLL_PUBLIC const value_string bluetooth_not_supported_0x00_special[];
331 WS_DLL_PUBLIC const value_string bluetooth_not_used_0xff_special[];
333 extern 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);
336 WS_DLL_PUBLIC bluetooth_data_t *
337 dissect_bluetooth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
339 #ifdef __cplusplus
341 #endif /* __cplusplus */
343 #endif
346 * Editor modelines - https://www.wireshark.org/tools/modelines.html
348 * Local variables:
349 * c-basic-offset: 4
350 * tab-width: 8
351 * indent-tabs-mode: nil
352 * End:
354 * vi: set shiftwidth=4 tabstop=8 expandtab:
355 * :indentSize=4:tabSize=8:noTabs=true: