blob: 5d033dc9d43bede0e9b36f033372f3af5a6881f7 [file] [log] [blame]
Andrei Emeltchenkobe218712010-12-01 16:58:26 +02001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated
4
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation;
10
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
Andrei Emeltchenkobe218712010-12-01 16:58:26 +020015 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
Andrei Emeltchenkobe218712010-12-01 16:58:26 +020020 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 SOFTWARE IS DISCLAIMED.
23*/
24
25#ifndef __HCI_H
26#define __HCI_H
27
28#define HCI_MAX_ACL_SIZE 1024
29#define HCI_MAX_SCO_SIZE 255
30#define HCI_MAX_EVENT_SIZE 260
31#define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4)
32
33/* HCI dev events */
34#define HCI_DEV_REG 1
35#define HCI_DEV_UNREG 2
36#define HCI_DEV_UP 3
37#define HCI_DEV_DOWN 4
38#define HCI_DEV_SUSPEND 5
39#define HCI_DEV_RESUME 6
40
41/* HCI notify events */
42#define HCI_NOTIFY_CONN_ADD 1
43#define HCI_NOTIFY_CONN_DEL 2
44#define HCI_NOTIFY_VOICE_SETTING 3
45
Marcel Holtmannc13854ce2010-02-08 15:27:07 +010046/* HCI bus types */
Marcel Holtmann0ac53932006-07-08 13:57:15 +020047#define HCI_VIRTUAL 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#define HCI_USB 1
49#define HCI_PCCARD 2
50#define HCI_UART 3
51#define HCI_RS232 4
52#define HCI_PCI 5
Marcel Holtmann0ac53932006-07-08 13:57:15 +020053#define HCI_SDIO 6
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Marcel Holtmann943da252010-02-13 02:28:41 +010055/* HCI controller types */
56#define HCI_BREDR 0x00
David Vrabel8f1e1742010-08-09 17:38:10 -040057#define HCI_AMP 0x01
Marcel Holtmann943da252010-02-13 02:28:41 +010058
Linus Torvalds1da177e2005-04-16 15:20:36 -070059/* HCI device quirks */
60enum {
Marcel Holtmann7a9d4022008-11-30 12:17:26 +010061 HCI_QUIRK_NO_RESET,
Marcel Holtmannda1f5192006-07-03 10:02:29 +020062 HCI_QUIRK_RAW_DEVICE,
63 HCI_QUIRK_FIXUP_BUFFER_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070064};
65
66/* HCI device flags */
67enum {
68 HCI_UP,
69 HCI_INIT,
70 HCI_RUNNING,
71
72 HCI_PSCAN,
73 HCI_ISCAN,
74 HCI_AUTH,
75 HCI_ENCRYPT,
76 HCI_INQUIRY,
77
78 HCI_RAW,
Linus Torvalds1da177e2005-04-16 15:20:36 -070079};
80
81/* HCI ioctl defines */
82#define HCIDEVUP _IOW('H', 201, int)
83#define HCIDEVDOWN _IOW('H', 202, int)
84#define HCIDEVRESET _IOW('H', 203, int)
85#define HCIDEVRESTAT _IOW('H', 204, int)
86
87#define HCIGETDEVLIST _IOR('H', 210, int)
88#define HCIGETDEVINFO _IOR('H', 211, int)
89#define HCIGETCONNLIST _IOR('H', 212, int)
90#define HCIGETCONNINFO _IOR('H', 213, int)
Marcel Holtmann40be4922008-07-14 20:13:50 +020091#define HCIGETAUTHINFO _IOR('H', 215, int)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93#define HCISETRAW _IOW('H', 220, int)
94#define HCISETSCAN _IOW('H', 221, int)
95#define HCISETAUTH _IOW('H', 222, int)
96#define HCISETENCRYPT _IOW('H', 223, int)
97#define HCISETPTYPE _IOW('H', 224, int)
98#define HCISETLINKPOL _IOW('H', 225, int)
99#define HCISETLINKMODE _IOW('H', 226, int)
100#define HCISETACLMTU _IOW('H', 227, int)
101#define HCISETSCOMTU _IOW('H', 228, int)
102
Johan Hedbergf0358562010-05-18 13:20:32 +0200103#define HCIBLOCKADDR _IOW('H', 230, int)
104#define HCIUNBLOCKADDR _IOW('H', 231, int)
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106#define HCIINQUIRY _IOR('H', 240, int)
107
108/* HCI timeouts */
Marcel Holtmann04837f62006-07-03 10:02:33 +0200109#define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */
110#define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */
Marcel Holtmann052b30b2009-04-26 20:01:22 +0200111#define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */
Marcel Holtmann04837f62006-07-03 10:02:33 +0200112#define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */
113#define HCI_INIT_TIMEOUT (10000) /* 10 seconds */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200115/* HCI data types */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116#define HCI_COMMAND_PKT 0x01
117#define HCI_ACLDATA_PKT 0x02
118#define HCI_SCODATA_PKT 0x03
119#define HCI_EVENT_PKT 0x04
120#define HCI_VENDOR_PKT 0xff
121
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200122/* HCI packet types */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123#define HCI_DM1 0x0008
124#define HCI_DM3 0x0400
125#define HCI_DM5 0x4000
126#define HCI_DH1 0x0010
127#define HCI_DH3 0x0800
128#define HCI_DH5 0x8000
129
130#define HCI_HV1 0x0020
131#define HCI_HV2 0x0040
132#define HCI_HV3 0x0080
133
134#define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
135#define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
136
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200137/* eSCO packet types */
138#define ESCO_HV1 0x0001
139#define ESCO_HV2 0x0002
140#define ESCO_HV3 0x0004
141#define ESCO_EV3 0x0008
142#define ESCO_EV4 0x0010
143#define ESCO_EV5 0x0020
Marcel Holtmannefc76882009-02-06 09:13:37 +0100144#define ESCO_2EV3 0x0040
145#define ESCO_3EV3 0x0080
146#define ESCO_2EV5 0x0100
147#define ESCO_3EV5 0x0200
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200148
Marcel Holtmanna8746412008-07-14 20:13:46 +0200149#define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
Marcel Holtmannefc76882009-02-06 09:13:37 +0100150#define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
Marcel Holtmanna8746412008-07-14 20:13:46 +0200151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152/* ACL flags */
Andrei Emeltchenkoe7021122011-01-03 11:14:36 +0200153#define ACL_START_NO_FLUSH 0x00
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#define ACL_CONT 0x01
155#define ACL_START 0x02
156#define ACL_ACTIVE_BCAST 0x04
157#define ACL_PICO_BCAST 0x08
158
159/* Baseband links */
160#define SCO_LINK 0x00
161#define ACL_LINK 0x01
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200162#define ESCO_LINK 0x02
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
164/* LMP features */
165#define LMP_3SLOT 0x01
166#define LMP_5SLOT 0x02
167#define LMP_ENCRYPT 0x04
168#define LMP_SOFFSET 0x08
169#define LMP_TACCURACY 0x10
170#define LMP_RSWITCH 0x20
171#define LMP_HOLD 0x40
Marcel Holtmann04837f62006-07-03 10:02:33 +0200172#define LMP_SNIFF 0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
174#define LMP_PARK 0x01
175#define LMP_RSSI 0x02
176#define LMP_QUALITY 0x04
177#define LMP_SCO 0x08
178#define LMP_HV2 0x10
179#define LMP_HV3 0x20
180#define LMP_ULAW 0x40
181#define LMP_ALAW 0x80
182
183#define LMP_CVSD 0x01
184#define LMP_PSCHEME 0x02
185#define LMP_PCONTROL 0x04
186
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200187#define LMP_ESCO 0x80
188
189#define LMP_EV4 0x01
190#define LMP_EV5 0x02
191
Marcel Holtmann04837f62006-07-03 10:02:33 +0200192#define LMP_SNIFF_SUBR 0x02
Marcel Holtmannefc76882009-02-06 09:13:37 +0100193#define LMP_EDR_ESCO_2M 0x20
194#define LMP_EDR_ESCO_3M 0x40
195#define LMP_EDR_3S_ESCO 0x80
Marcel Holtmann04837f62006-07-03 10:02:33 +0200196
Marcel Holtmann769be972008-07-14 20:13:49 +0200197#define LMP_SIMPLE_PAIR 0x08
Andrei Emeltchenkoe7021122011-01-03 11:14:36 +0200198#define LMP_NO_FLUSH 0x40
Marcel Holtmann769be972008-07-14 20:13:49 +0200199
Marcel Holtmann04837f62006-07-03 10:02:33 +0200200/* Connection modes */
201#define HCI_CM_ACTIVE 0x0000
202#define HCI_CM_HOLD 0x0001
203#define HCI_CM_SNIFF 0x0002
204#define HCI_CM_PARK 0x0003
205
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206/* Link policies */
207#define HCI_LP_RSWITCH 0x0001
208#define HCI_LP_HOLD 0x0002
209#define HCI_LP_SNIFF 0x0004
210#define HCI_LP_PARK 0x0008
211
Marcel Holtmann04837f62006-07-03 10:02:33 +0200212/* Link modes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213#define HCI_LM_ACCEPT 0x8000
214#define HCI_LM_MASTER 0x0001
215#define HCI_LM_AUTH 0x0002
216#define HCI_LM_ENCRYPT 0x0004
217#define HCI_LM_TRUSTED 0x0008
218#define HCI_LM_RELIABLE 0x0010
219#define HCI_LM_SECURE 0x0020
220
Marcel Holtmann40be4922008-07-14 20:13:50 +0200221/* Authentication types */
222#define HCI_AT_NO_BONDING 0x00
223#define HCI_AT_NO_BONDING_MITM 0x01
224#define HCI_AT_DEDICATED_BONDING 0x02
225#define HCI_AT_DEDICATED_BONDING_MITM 0x03
226#define HCI_AT_GENERAL_BONDING 0x04
227#define HCI_AT_GENERAL_BONDING_MITM 0x05
228
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229/* ----- HCI Commands ---- */
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200230#define HCI_OP_INQUIRY 0x0401
231struct hci_cp_inquiry {
232 __u8 lap[3];
233 __u8 length;
234 __u8 num_rsp;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300235} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200237#define HCI_OP_INQUIRY_CANCEL 0x0402
238
239#define HCI_OP_EXIT_PERIODIC_INQ 0x0404
240
241#define HCI_OP_CREATE_CONN 0x0405
242struct hci_cp_create_conn {
243 bdaddr_t bdaddr;
244 __le16 pkt_type;
245 __u8 pscan_rep_mode;
246 __u8 pscan_mode;
247 __le16 clock_offset;
248 __u8 role_switch;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300249} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200251#define HCI_OP_DISCONNECT 0x0406
252struct hci_cp_disconnect {
253 __le16 handle;
254 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300255} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200257#define HCI_OP_ADD_SCO 0x0407
258struct hci_cp_add_sco {
259 __le16 handle;
260 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300261} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200262
263#define HCI_OP_CREATE_CONN_CANCEL 0x0408
264struct hci_cp_create_conn_cancel {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300266} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200268#define HCI_OP_ACCEPT_CONN_REQ 0x0409
269struct hci_cp_accept_conn_req {
270 bdaddr_t bdaddr;
271 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300272} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200274#define HCI_OP_REJECT_CONN_REQ 0x040a
275struct hci_cp_reject_conn_req {
276 bdaddr_t bdaddr;
277 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300278} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200280#define HCI_OP_LINK_KEY_REPLY 0x040b
281struct hci_cp_link_key_reply {
282 bdaddr_t bdaddr;
283 __u8 link_key[16];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300284} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200286#define HCI_OP_LINK_KEY_NEG_REPLY 0x040c
287struct hci_cp_link_key_neg_reply {
288 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300289} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200291#define HCI_OP_PIN_CODE_REPLY 0x040d
292struct hci_cp_pin_code_reply {
293 bdaddr_t bdaddr;
294 __u8 pin_len;
295 __u8 pin_code[16];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300296} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200297
298#define HCI_OP_PIN_CODE_NEG_REPLY 0x040e
299struct hci_cp_pin_code_neg_reply {
300 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300301} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200302
303#define HCI_OP_CHANGE_CONN_PTYPE 0x040f
304struct hci_cp_change_conn_ptype {
305 __le16 handle;
306 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300307} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200308
309#define HCI_OP_AUTH_REQUESTED 0x0411
310struct hci_cp_auth_requested {
311 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300312} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200313
314#define HCI_OP_SET_CONN_ENCRYPT 0x0413
315struct hci_cp_set_conn_encrypt {
316 __le16 handle;
317 __u8 encrypt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300318} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200319
320#define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415
321struct hci_cp_change_conn_link_key {
322 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300323} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200324
325#define HCI_OP_REMOTE_NAME_REQ 0x0419
326struct hci_cp_remote_name_req {
327 bdaddr_t bdaddr;
328 __u8 pscan_rep_mode;
329 __u8 pscan_mode;
330 __le16 clock_offset;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300331} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200332
333#define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a
334struct hci_cp_remote_name_req_cancel {
335 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300336} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200337
338#define HCI_OP_READ_REMOTE_FEATURES 0x041b
339struct hci_cp_read_remote_features {
340 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300341} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200342
343#define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c
344struct hci_cp_read_remote_ext_features {
345 __le16 handle;
346 __u8 page;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300347} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200348
349#define HCI_OP_READ_REMOTE_VERSION 0x041d
350struct hci_cp_read_remote_version {
351 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300352} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200353
354#define HCI_OP_SETUP_SYNC_CONN 0x0428
355struct hci_cp_setup_sync_conn {
356 __le16 handle;
357 __le32 tx_bandwidth;
358 __le32 rx_bandwidth;
359 __le16 max_latency;
360 __le16 voice_setting;
361 __u8 retrans_effort;
362 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300363} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200364
365#define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429
366struct hci_cp_accept_sync_conn_req {
367 bdaddr_t bdaddr;
368 __le32 tx_bandwidth;
369 __le32 rx_bandwidth;
370 __le16 max_latency;
371 __le16 content_format;
372 __u8 retrans_effort;
373 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300374} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200375
376#define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a
377struct hci_cp_reject_sync_conn_req {
378 bdaddr_t bdaddr;
379 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300380} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200381
382#define HCI_OP_SNIFF_MODE 0x0803
383struct hci_cp_sniff_mode {
384 __le16 handle;
385 __le16 max_interval;
386 __le16 min_interval;
387 __le16 attempt;
388 __le16 timeout;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300389} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200390
391#define HCI_OP_EXIT_SNIFF_MODE 0x0804
392struct hci_cp_exit_sniff_mode {
393 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300394} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200395
396#define HCI_OP_ROLE_DISCOVERY 0x0809
397struct hci_cp_role_discovery {
398 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300399} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200400struct hci_rp_role_discovery {
401 __u8 status;
402 __le16 handle;
403 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300404} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200405
406#define HCI_OP_SWITCH_ROLE 0x080b
407struct hci_cp_switch_role {
408 bdaddr_t bdaddr;
409 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300410} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200411
412#define HCI_OP_READ_LINK_POLICY 0x080c
413struct hci_cp_read_link_policy {
414 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300415} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200416struct hci_rp_read_link_policy {
417 __u8 status;
418 __le16 handle;
419 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300420} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200421
422#define HCI_OP_WRITE_LINK_POLICY 0x080d
423struct hci_cp_write_link_policy {
424 __le16 handle;
425 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300426} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200427struct hci_rp_write_link_policy {
428 __u8 status;
429 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300430} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200431
Marcel Holtmanne4e8e372008-07-14 20:13:47 +0200432#define HCI_OP_READ_DEF_LINK_POLICY 0x080e
433struct hci_rp_read_def_link_policy {
434 __u8 status;
435 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300436} __packed;
Marcel Holtmanne4e8e372008-07-14 20:13:47 +0200437
438#define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f
439struct hci_cp_write_def_link_policy {
440 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300441} __packed;
Marcel Holtmanne4e8e372008-07-14 20:13:47 +0200442
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200443#define HCI_OP_SNIFF_SUBRATE 0x0811
444struct hci_cp_sniff_subrate {
445 __le16 handle;
446 __le16 max_latency;
447 __le16 min_remote_timeout;
448 __le16 min_local_timeout;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300449} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200450
451#define HCI_OP_SET_EVENT_MASK 0x0c01
452struct hci_cp_set_event_mask {
453 __u8 mask[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300454} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200455
456#define HCI_OP_RESET 0x0c03
457
458#define HCI_OP_SET_EVENT_FLT 0x0c05
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459struct hci_cp_set_event_flt {
460 __u8 flt_type;
461 __u8 cond_type;
462 __u8 condition[0];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300463} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464
465/* Filter types */
466#define HCI_FLT_CLEAR_ALL 0x00
467#define HCI_FLT_INQ_RESULT 0x01
468#define HCI_FLT_CONN_SETUP 0x02
469
470/* CONN_SETUP Condition types */
471#define HCI_CONN_SETUP_ALLOW_ALL 0x00
472#define HCI_CONN_SETUP_ALLOW_CLASS 0x01
473#define HCI_CONN_SETUP_ALLOW_BDADDR 0x02
474
475/* CONN_SETUP Conditions */
476#define HCI_CONN_SETUP_AUTO_OFF 0x01
477#define HCI_CONN_SETUP_AUTO_ON 0x02
478
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200479#define HCI_OP_WRITE_LOCAL_NAME 0x0c13
480struct hci_cp_write_local_name {
481 __u8 name[248];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300482} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200483
484#define HCI_OP_READ_LOCAL_NAME 0x0c14
485struct hci_rp_read_local_name {
486 __u8 status;
487 __u8 name[248];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300488} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200489
490#define HCI_OP_WRITE_CA_TIMEOUT 0x0c16
491
492#define HCI_OP_WRITE_PG_TIMEOUT 0x0c18
493
Andrei Emeltchenko70f230202010-12-01 16:58:25 +0200494#define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200495 #define SCAN_DISABLED 0x00
496 #define SCAN_INQUIRY 0x01
497 #define SCAN_PAGE 0x02
498
499#define HCI_OP_READ_AUTH_ENABLE 0x0c1f
500
501#define HCI_OP_WRITE_AUTH_ENABLE 0x0c20
502 #define AUTH_DISABLED 0x00
503 #define AUTH_ENABLED 0x01
504
505#define HCI_OP_READ_ENCRYPT_MODE 0x0c21
506
507#define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22
508 #define ENCRYPT_DISABLED 0x00
509 #define ENCRYPT_P2P 0x01
510 #define ENCRYPT_BOTH 0x02
511
512#define HCI_OP_READ_CLASS_OF_DEV 0x0c23
513struct hci_rp_read_class_of_dev {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 __u8 status;
515 __u8 dev_class[3];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300516} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200518#define HCI_OP_WRITE_CLASS_OF_DEV 0x0c24
519struct hci_cp_write_class_of_dev {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 __u8 dev_class[3];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300521} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200523#define HCI_OP_READ_VOICE_SETTING 0x0c25
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524struct hci_rp_read_voice_setting {
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800525 __u8 status;
526 __le16 voice_setting;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300527} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200529#define HCI_OP_WRITE_VOICE_SETTING 0x0c26
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530struct hci_cp_write_voice_setting {
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800531 __le16 voice_setting;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300532} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200534#define HCI_OP_HOST_BUFFER_SIZE 0x0c33
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535struct hci_cp_host_buffer_size {
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800536 __le16 acl_mtu;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 __u8 sco_mtu;
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800538 __le16 acl_max_pkt;
539 __le16 sco_max_pkt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300540} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541
Marcel Holtmann333140b2008-07-14 20:13:48 +0200542#define HCI_OP_READ_SSP_MODE 0x0c55
543struct hci_rp_read_ssp_mode {
544 __u8 status;
545 __u8 mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300546} __packed;
Marcel Holtmann333140b2008-07-14 20:13:48 +0200547
548#define HCI_OP_WRITE_SSP_MODE 0x0c56
549struct hci_cp_write_ssp_mode {
550 __u8 mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300551} __packed;
Marcel Holtmann333140b2008-07-14 20:13:48 +0200552
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200553#define HCI_OP_READ_LOCAL_VERSION 0x1001
554struct hci_rp_read_local_version {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 __u8 status;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200556 __u8 hci_ver;
557 __le16 hci_rev;
558 __u8 lmp_ver;
559 __le16 manufacturer;
560 __le16 lmp_subver;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300561} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200563#define HCI_OP_READ_LOCAL_COMMANDS 0x1002
564struct hci_rp_read_local_commands {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 __u8 status;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200566 __u8 commands[64];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300567} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200569#define HCI_OP_READ_LOCAL_FEATURES 0x1003
570struct hci_rp_read_local_features {
571 __u8 status;
572 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300573} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200574
575#define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004
576struct hci_rp_read_local_ext_features {
577 __u8 status;
578 __u8 page;
579 __u8 max_page;
580 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300581} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200582
583#define HCI_OP_READ_BUFFER_SIZE 0x1005
584struct hci_rp_read_buffer_size {
585 __u8 status;
586 __le16 acl_mtu;
587 __u8 sco_mtu;
588 __le16 acl_max_pkt;
589 __le16 sco_max_pkt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300590} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200591
592#define HCI_OP_READ_BD_ADDR 0x1009
593struct hci_rp_read_bd_addr {
594 __u8 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300596} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598/* ---- HCI Events ---- */
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200599#define HCI_EV_INQUIRY_COMPLETE 0x01
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200601#define HCI_EV_INQUIRY_RESULT 0x02
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602struct inquiry_info {
603 bdaddr_t bdaddr;
604 __u8 pscan_rep_mode;
605 __u8 pscan_period_mode;
606 __u8 pscan_mode;
607 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800608 __le16 clock_offset;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300609} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200611#define HCI_EV_CONN_COMPLETE 0x03
612struct hci_ev_conn_complete {
613 __u8 status;
614 __le16 handle;
615 bdaddr_t bdaddr;
616 __u8 link_type;
617 __u8 encr_mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300618} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200619
620#define HCI_EV_CONN_REQUEST 0x04
621struct hci_ev_conn_request {
622 bdaddr_t bdaddr;
623 __u8 dev_class[3];
624 __u8 link_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300625} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200626
627#define HCI_EV_DISCONN_COMPLETE 0x05
628struct hci_ev_disconn_complete {
629 __u8 status;
630 __le16 handle;
631 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300632} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200633
634#define HCI_EV_AUTH_COMPLETE 0x06
635struct hci_ev_auth_complete {
636 __u8 status;
637 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300638} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200639
640#define HCI_EV_REMOTE_NAME 0x07
641struct hci_ev_remote_name {
642 __u8 status;
643 bdaddr_t bdaddr;
644 __u8 name[248];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300645} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200646
647#define HCI_EV_ENCRYPT_CHANGE 0x08
648struct hci_ev_encrypt_change {
649 __u8 status;
650 __le16 handle;
651 __u8 encrypt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300652} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200653
654#define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09
655struct hci_ev_change_link_key_complete {
656 __u8 status;
657 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300658} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200659
660#define HCI_EV_REMOTE_FEATURES 0x0b
661struct hci_ev_remote_features {
662 __u8 status;
663 __le16 handle;
664 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300665} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200666
667#define HCI_EV_REMOTE_VERSION 0x0c
668struct hci_ev_remote_version {
669 __u8 status;
670 __le16 handle;
671 __u8 lmp_ver;
672 __le16 manufacturer;
673 __le16 lmp_subver;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300674} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200675
676#define HCI_EV_QOS_SETUP_COMPLETE 0x0d
677struct hci_qos {
678 __u8 service_type;
679 __u32 token_rate;
680 __u32 peak_bandwidth;
681 __u32 latency;
682 __u32 delay_variation;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300683} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200684struct hci_ev_qos_setup_complete {
685 __u8 status;
686 __le16 handle;
687 struct hci_qos qos;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300688} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200689
690#define HCI_EV_CMD_COMPLETE 0x0e
691struct hci_ev_cmd_complete {
692 __u8 ncmd;
693 __le16 opcode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300694} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200695
696#define HCI_EV_CMD_STATUS 0x0f
697struct hci_ev_cmd_status {
698 __u8 status;
699 __u8 ncmd;
700 __le16 opcode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300701} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200702
703#define HCI_EV_ROLE_CHANGE 0x12
704struct hci_ev_role_change {
705 __u8 status;
706 bdaddr_t bdaddr;
707 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300708} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200709
710#define HCI_EV_NUM_COMP_PKTS 0x13
711struct hci_ev_num_comp_pkts {
712 __u8 num_hndl;
713 /* variable length part */
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300714} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200715
716#define HCI_EV_MODE_CHANGE 0x14
717struct hci_ev_mode_change {
718 __u8 status;
719 __le16 handle;
720 __u8 mode;
721 __le16 interval;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300722} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200723
724#define HCI_EV_PIN_CODE_REQ 0x16
725struct hci_ev_pin_code_req {
726 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300727} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200728
729#define HCI_EV_LINK_KEY_REQ 0x17
730struct hci_ev_link_key_req {
731 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300732} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200733
734#define HCI_EV_LINK_KEY_NOTIFY 0x18
735struct hci_ev_link_key_notify {
736 bdaddr_t bdaddr;
737 __u8 link_key[16];
738 __u8 key_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300739} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200740
741#define HCI_EV_CLOCK_OFFSET 0x1c
742struct hci_ev_clock_offset {
743 __u8 status;
744 __le16 handle;
745 __le16 clock_offset;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300746} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200747
Marcel Holtmanna8746412008-07-14 20:13:46 +0200748#define HCI_EV_PKT_TYPE_CHANGE 0x1d
749struct hci_ev_pkt_type_change {
750 __u8 status;
751 __le16 handle;
752 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300753} __packed;
Marcel Holtmanna8746412008-07-14 20:13:46 +0200754
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200755#define HCI_EV_PSCAN_REP_MODE 0x20
756struct hci_ev_pscan_rep_mode {
757 bdaddr_t bdaddr;
758 __u8 pscan_rep_mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300759} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200760
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761#define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
762struct inquiry_info_with_rssi {
763 bdaddr_t bdaddr;
764 __u8 pscan_rep_mode;
765 __u8 pscan_period_mode;
766 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800767 __le16 clock_offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 __s8 rssi;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300769} __packed;
Marcel Holtmann45bb4bf2005-08-09 20:27:49 -0700770struct inquiry_info_with_rssi_and_pscan_mode {
771 bdaddr_t bdaddr;
772 __u8 pscan_rep_mode;
773 __u8 pscan_period_mode;
774 __u8 pscan_mode;
775 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800776 __le16 clock_offset;
Marcel Holtmann45bb4bf2005-08-09 20:27:49 -0700777 __s8 rssi;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300778} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200780#define HCI_EV_REMOTE_EXT_FEATURES 0x23
781struct hci_ev_remote_ext_features {
782 __u8 status;
783 __le16 handle;
784 __u8 page;
785 __u8 max_page;
786 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300787} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200788
789#define HCI_EV_SYNC_CONN_COMPLETE 0x2c
790struct hci_ev_sync_conn_complete {
791 __u8 status;
792 __le16 handle;
793 bdaddr_t bdaddr;
794 __u8 link_type;
795 __u8 tx_interval;
796 __u8 retrans_window;
797 __le16 rx_pkt_len;
798 __le16 tx_pkt_len;
799 __u8 air_mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300800} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200801
802#define HCI_EV_SYNC_CONN_CHANGED 0x2d
803struct hci_ev_sync_conn_changed {
804 __u8 status;
805 __le16 handle;
806 __u8 tx_interval;
807 __u8 retrans_window;
808 __le16 rx_pkt_len;
809 __le16 tx_pkt_len;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300810} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200811
812#define HCI_EV_SNIFF_SUBRATE 0x2e
813struct hci_ev_sniff_subrate {
814 __u8 status;
815 __le16 handle;
816 __le16 max_tx_latency;
817 __le16 max_rx_latency;
818 __le16 max_remote_timeout;
819 __le16 max_local_timeout;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300820} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200821
822#define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f
Marcel Holtmann21d9e302005-09-13 01:32:25 +0200823struct extended_inquiry_info {
824 bdaddr_t bdaddr;
825 __u8 pscan_rep_mode;
826 __u8 pscan_period_mode;
827 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800828 __le16 clock_offset;
Marcel Holtmann21d9e302005-09-13 01:32:25 +0200829 __s8 rssi;
830 __u8 data[240];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300831} __packed;
Marcel Holtmann21d9e302005-09-13 01:32:25 +0200832
Marcel Holtmann04936842008-07-14 20:13:48 +0200833#define HCI_EV_IO_CAPA_REQUEST 0x31
834struct hci_ev_io_capa_request {
835 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300836} __packed;
Marcel Holtmann04936842008-07-14 20:13:48 +0200837
838#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
839struct hci_ev_simple_pair_complete {
840 __u8 status;
841 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300842} __packed;
Marcel Holtmann04936842008-07-14 20:13:48 +0200843
Marcel Holtmann41a96212008-07-14 20:13:48 +0200844#define HCI_EV_REMOTE_HOST_FEATURES 0x3d
845struct hci_ev_remote_host_features {
846 bdaddr_t bdaddr;
847 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300848} __packed;
Marcel Holtmann41a96212008-07-14 20:13:48 +0200849
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850/* Internal events generated by Bluetooth stack */
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200851#define HCI_EV_STACK_INTERNAL 0xfd
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852struct hci_ev_stack_internal {
853 __u16 type;
854 __u8 data[0];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300855} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200857#define HCI_EV_SI_DEVICE 0x01
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858struct hci_ev_si_device {
859 __u16 event;
860 __u16 dev_id;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300861} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862
863#define HCI_EV_SI_SECURITY 0x02
864struct hci_ev_si_security {
865 __u16 event;
866 __u16 proto;
867 __u16 subproto;
868 __u8 incoming;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300869} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870
871/* ---- HCI Packet structures ---- */
872#define HCI_COMMAND_HDR_SIZE 3
873#define HCI_EVENT_HDR_SIZE 2
874#define HCI_ACL_HDR_SIZE 4
875#define HCI_SCO_HDR_SIZE 3
876
877struct hci_command_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200878 __le16 opcode; /* OCF & OGF */
Andrei Emeltchenko70f230202010-12-01 16:58:25 +0200879 __u8 plen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300880} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881
882struct hci_event_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200883 __u8 evt;
884 __u8 plen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300885} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886
887struct hci_acl_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200888 __le16 handle; /* Handle & Flags(PB, BC) */
889 __le16 dlen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300890} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891
892struct hci_sco_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200893 __le16 handle;
894 __u8 dlen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300895} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -0300897#ifdef __KERNEL__
898#include <linux/skbuff.h>
899static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
900{
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200901 return (struct hci_event_hdr *) skb->data;
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -0300902}
903
904static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
905{
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200906 return (struct hci_acl_hdr *) skb->data;
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -0300907}
908
909static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
910{
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200911 return (struct hci_sco_hdr *) skb->data;
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -0300912}
913#endif
914
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915/* Command opcode pack/unpack */
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800916#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917#define hci_opcode_ogf(op) (op >> 10)
918#define hci_opcode_ocf(op) (op & 0x03ff)
919
920/* ACL handle and flags pack/unpack */
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800921#define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922#define hci_handle(h) (h & 0x0fff)
923#define hci_flags(h) (h >> 12)
924
925/* ---- HCI Sockets ---- */
926
927/* Socket options */
928#define HCI_DATA_DIR 1
929#define HCI_FILTER 2
930#define HCI_TIME_STAMP 3
931
932/* CMSG flags */
933#define HCI_CMSG_DIR 0x0001
934#define HCI_CMSG_TSTAMP 0x0002
935
936struct sockaddr_hci {
937 sa_family_t hci_family;
938 unsigned short hci_dev;
Johan Hedbergc02178d2010-12-08 00:21:05 +0200939 unsigned short hci_channel;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940};
941#define HCI_DEV_NONE 0xffff
942
Johan Hedbergc02178d2010-12-08 00:21:05 +0200943#define HCI_CHANNEL_RAW 0
944#define HCI_CHANNEL_CONTROL 1
945
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946struct hci_filter {
947 unsigned long type_mask;
948 unsigned long event_mask[2];
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200949 __le16 opcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950};
951
952struct hci_ufilter {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200953 __u32 type_mask;
954 __u32 event_mask[2];
955 __le16 opcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956};
957
958#define HCI_FLT_TYPE_BITS 31
959#define HCI_FLT_EVENT_BITS 63
960#define HCI_FLT_OGF_BITS 63
961#define HCI_FLT_OCF_BITS 127
962
963/* ---- HCI Ioctl requests structures ---- */
964struct hci_dev_stats {
965 __u32 err_rx;
966 __u32 err_tx;
967 __u32 cmd_tx;
968 __u32 evt_rx;
969 __u32 acl_tx;
970 __u32 acl_rx;
971 __u32 sco_tx;
972 __u32 sco_rx;
973 __u32 byte_rx;
974 __u32 byte_tx;
975};
976
977struct hci_dev_info {
978 __u16 dev_id;
979 char name[8];
980
981 bdaddr_t bdaddr;
982
983 __u32 flags;
984 __u8 type;
985
986 __u8 features[8];
987
988 __u32 pkt_type;
989 __u32 link_policy;
990 __u32 link_mode;
991
992 __u16 acl_mtu;
993 __u16 acl_pkts;
994 __u16 sco_mtu;
995 __u16 sco_pkts;
996
997 struct hci_dev_stats stat;
998};
999
1000struct hci_conn_info {
1001 __u16 handle;
1002 bdaddr_t bdaddr;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001003 __u8 type;
1004 __u8 out;
1005 __u16 state;
1006 __u32 link_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007};
1008
1009struct hci_dev_req {
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001010 __u16 dev_id;
1011 __u32 dev_opt;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012};
1013
1014struct hci_dev_list_req {
1015 __u16 dev_num;
1016 struct hci_dev_req dev_req[0]; /* hci_dev_req structures */
1017};
1018
1019struct hci_conn_list_req {
1020 __u16 dev_id;
1021 __u16 conn_num;
1022 struct hci_conn_info conn_info[0];
1023};
1024
1025struct hci_conn_info_req {
1026 bdaddr_t bdaddr;
1027 __u8 type;
1028 struct hci_conn_info conn_info[0];
1029};
1030
Marcel Holtmann40be4922008-07-14 20:13:50 +02001031struct hci_auth_info_req {
1032 bdaddr_t bdaddr;
1033 __u8 type;
1034};
1035
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036struct hci_inquiry_req {
1037 __u16 dev_id;
1038 __u16 flags;
1039 __u8 lap[3];
1040 __u8 length;
1041 __u8 num_rsp;
1042};
1043#define IREQ_CACHE_FLUSH 0x0001
1044
1045#endif /* __HCI_H */