Qt/Bluetooth: Add Devices dialogue
[metze/wireshark/wip.git] / epan / dissectors / 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  * 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.
11  *
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.
16  *
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.
20  */
21
22 #ifndef __PACKET_BLUETOOTH_H__
23 #define __PACKET_BLUETOOTH_H__
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28
29 #include <epan/wmem/wmem.h>
30
31 #include "packet-usb.h"
32 #include "packet-ubertooth.h"
33
34 #define BLUETOOTH_DATA_SRC 0
35 #define BLUETOOTH_DATA_DST 1
36
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
41
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
51
52 #define HCI_VENDOR_DEFAULT  0
53
54 #define DID_VENDOR_ID_SOURCE_BLUETOOTH_SIG  1
55 #define DID_VENDOR_ID_SOURCE_USB_FORUM      2
56
57 #define ACCESS_ADDRESS_ADVERTISING 0x8e89bed6
58
59 extern int proto_bluetooth;
60
61 extern const value_string bluetooth_address_type_vals[];
62
63 #define STATUS_SUCCESS 0x00
64
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
69
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. )
79
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
84                   hci0, hci1, etc.)
85 */
86 #define HCI_INTERFACE_DEFAULT  0
87 #define HCI_ADAPTER_DEFAULT    0
88
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 {
97     guint32      interface_id;
98     guint32      adapter_id;
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;
108
109     union {
110         void              *data;
111         usb_conv_info_t   *usb_conv_info;
112         ubertooth_data_t  *ubertooth_data;
113     } previous_protocol_data;
114
115 } bluetooth_data_t;
116
117 typedef struct _chandle_session_t {
118     guint32  connect_in_frame;
119     guint32  disconnect_in_frame;
120 } chandle_session_t;
121
122 typedef struct _remote_bdaddr_t {
123     guint32  interface_id;
124     guint32  adapter_id;
125     guint16  chandle;
126     guint8   bd_addr[6];
127 } remote_bdaddr_t;
128
129 typedef struct _device_name_t {
130     guint32  bd_addr_oui;
131     guint32  bd_addr_id;
132     gchar    *name;
133 } device_name_t;
134
135 typedef struct _device_role_t {
136     guint32  role;
137     guint32  change_in_frame;
138 } device_role_t;
139
140 typedef struct _connection_mode_t {
141     gint32   mode;
142     guint32  change_in_frame;
143 } connection_mode_t;
144
145 #define ROLE_UNKNOWN  0
146 #define ROLE_MASTER   1
147 #define ROLE_SLAVE    2
148
149 typedef struct _localhost_bdaddr_entry_t {
150     guint32  interface_id;
151     guint32  adapter_id;
152     guint8   bd_addr[6];
153 } localhost_bdaddr_entry_t;
154
155 typedef struct _localhost_name_entry_t {
156     guint32  interface_id;
157     guint32  adapter_id;
158     gchar    *name;
159 } localhost_name_entry_t;
160
161 typedef struct _bluetooth_tap_data_t {
162     guint32  interface_id;
163     guint32  adapter_id;
164 } bluetooth_tap_data_t;
165
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;
172 } hci_vendor_data_t;
173
174 typedef struct _uuid_t {
175     guint16  bt_uuid;
176     guint8   size;
177     guint8   data[16];
178 } bluetooth_uuid_t;
179
180 typedef struct _bluetooth_uuid_custom {
181     const guint8  uuid[16];
182     const guint8  size;
183     const gchar  *name;
184 } bluetooth_uuid_custom_t;
185
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
192 };
193
194 typedef struct _bluetooth_device_tap_t {
195     guint32                     interface_id;
196     guint32                     adapter_id;
197
198     gboolean                    is_local;
199     gboolean                    has_bd_addr;
200     guint8                      bd_addr[6];
201     enum bluetooth_device_type  type;
202     union {
203         char  *name;
204         struct {
205             guint8   hci_version;
206             guint16  hci_revision;
207             guint8   lmp_version;
208             guint16  lmp_subversion;
209             guint16  manufacturer;
210         } local_version;
211         struct {
212             guint8   lmp_version;
213             guint16  lmp_subversion;
214             guint16  manufacturer;
215         } remote_version;
216     } data;
217 } bluetooth_device_tap_t;
218
219 extern int bluetooth_device_tap;
220
221 WS_DLL_PUBLIC const value_string   bluetooth_uuid_vals[];
222 WS_DLL_PUBLIC const bluetooth_uuid_custom_t  bluetooth_uuid_custom[];
223
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;
227
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);
231
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);
235
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);
238
239 #ifdef __cplusplus
240 }
241 #endif /* __cplusplus */
242
243 #endif
244
245 /*
246  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
247  *
248  * Local variables:
249  * c-basic-offset: 4
250  * tab-width: 8
251  * indent-tabs-mode: nil
252  * End:
253  *
254  * vi: set shiftwidth=4 tabstop=8 expandtab:
255  * :indentSize=4:tabSize=8:noTabs=true:
256  */