blob: 9ce46cd00ba22563ddff5b7f617bcdd9cb1c47c1 [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 Holtmannc13854c2010-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,
Johan Hedbergab81cbf2010-12-15 13:53:18 +020079
80 HCI_SETUP,
81 HCI_AUTO_OFF,
Johan Hedbergebc99fe2011-01-04 11:54:26 +020082 HCI_MGMT,
Johan Hedbergc542a062011-01-26 13:11:03 +020083 HCI_PAIRABLE,
Johan Hedberg1aff6f02011-01-13 21:56:52 +020084 HCI_SERVICE_CACHE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070085};
86
87/* HCI ioctl defines */
88#define HCIDEVUP _IOW('H', 201, int)
89#define HCIDEVDOWN _IOW('H', 202, int)
90#define HCIDEVRESET _IOW('H', 203, int)
91#define HCIDEVRESTAT _IOW('H', 204, int)
92
93#define HCIGETDEVLIST _IOR('H', 210, int)
94#define HCIGETDEVINFO _IOR('H', 211, int)
95#define HCIGETCONNLIST _IOR('H', 212, int)
96#define HCIGETCONNINFO _IOR('H', 213, int)
Marcel Holtmann40be4922008-07-14 20:13:50 +020097#define HCIGETAUTHINFO _IOR('H', 215, int)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
99#define HCISETRAW _IOW('H', 220, int)
100#define HCISETSCAN _IOW('H', 221, int)
101#define HCISETAUTH _IOW('H', 222, int)
102#define HCISETENCRYPT _IOW('H', 223, int)
103#define HCISETPTYPE _IOW('H', 224, int)
104#define HCISETLINKPOL _IOW('H', 225, int)
105#define HCISETLINKMODE _IOW('H', 226, int)
106#define HCISETACLMTU _IOW('H', 227, int)
107#define HCISETSCOMTU _IOW('H', 228, int)
108
Johan Hedbergf0358562010-05-18 13:20:32 +0200109#define HCIBLOCKADDR _IOW('H', 230, int)
110#define HCIUNBLOCKADDR _IOW('H', 231, int)
111
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112#define HCIINQUIRY _IOR('H', 240, int)
113
114/* HCI timeouts */
Marcel Holtmann04837f62006-07-03 10:02:33 +0200115#define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */
116#define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */
Marcel Holtmann052b30b2009-04-26 20:01:22 +0200117#define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */
Marcel Holtmann04837f62006-07-03 10:02:33 +0200118#define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */
119#define HCI_INIT_TIMEOUT (10000) /* 10 seconds */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200121/* HCI data types */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122#define HCI_COMMAND_PKT 0x01
123#define HCI_ACLDATA_PKT 0x02
124#define HCI_SCODATA_PKT 0x03
125#define HCI_EVENT_PKT 0x04
126#define HCI_VENDOR_PKT 0xff
127
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200128/* HCI packet types */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#define HCI_DM1 0x0008
130#define HCI_DM3 0x0400
131#define HCI_DM5 0x4000
132#define HCI_DH1 0x0010
133#define HCI_DH3 0x0800
134#define HCI_DH5 0x8000
135
136#define HCI_HV1 0x0020
137#define HCI_HV2 0x0040
138#define HCI_HV3 0x0080
139
140#define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
141#define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
142
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200143/* eSCO packet types */
144#define ESCO_HV1 0x0001
145#define ESCO_HV2 0x0002
146#define ESCO_HV3 0x0004
147#define ESCO_EV3 0x0008
148#define ESCO_EV4 0x0010
149#define ESCO_EV5 0x0020
Marcel Holtmannefc76882009-02-06 09:13:37 +0100150#define ESCO_2EV3 0x0040
151#define ESCO_3EV3 0x0080
152#define ESCO_2EV5 0x0100
153#define ESCO_3EV5 0x0200
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200154
Marcel Holtmanna8746412008-07-14 20:13:46 +0200155#define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
Marcel Holtmannefc76882009-02-06 09:13:37 +0100156#define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
Marcel Holtmanna8746412008-07-14 20:13:46 +0200157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158/* ACL flags */
Andrei Emeltchenkoe7021122011-01-03 11:14:36 +0200159#define ACL_START_NO_FLUSH 0x00
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160#define ACL_CONT 0x01
161#define ACL_START 0x02
162#define ACL_ACTIVE_BCAST 0x04
163#define ACL_PICO_BCAST 0x08
164
165/* Baseband links */
166#define SCO_LINK 0x00
167#define ACL_LINK 0x01
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200168#define ESCO_LINK 0x02
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
170/* LMP features */
171#define LMP_3SLOT 0x01
172#define LMP_5SLOT 0x02
173#define LMP_ENCRYPT 0x04
174#define LMP_SOFFSET 0x08
175#define LMP_TACCURACY 0x10
176#define LMP_RSWITCH 0x20
177#define LMP_HOLD 0x40
Marcel Holtmann04837f62006-07-03 10:02:33 +0200178#define LMP_SNIFF 0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
180#define LMP_PARK 0x01
181#define LMP_RSSI 0x02
182#define LMP_QUALITY 0x04
183#define LMP_SCO 0x08
184#define LMP_HV2 0x10
185#define LMP_HV3 0x20
186#define LMP_ULAW 0x40
187#define LMP_ALAW 0x80
188
189#define LMP_CVSD 0x01
190#define LMP_PSCHEME 0x02
191#define LMP_PCONTROL 0x04
192
Johan Hedbergd5859e22011-01-25 01:19:58 +0200193#define LMP_RSSI_INQ 0x40
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200194#define LMP_ESCO 0x80
195
196#define LMP_EV4 0x01
197#define LMP_EV5 0x02
Johan Hedbergd5859e22011-01-25 01:19:58 +0200198#define LMP_LE 0x40
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200199
Marcel Holtmann04837f62006-07-03 10:02:33 +0200200#define LMP_SNIFF_SUBR 0x02
Johan Hedbergd5859e22011-01-25 01:19:58 +0200201#define LMP_PAUSE_ENC 0x04
Marcel Holtmannefc76882009-02-06 09:13:37 +0100202#define LMP_EDR_ESCO_2M 0x20
203#define LMP_EDR_ESCO_3M 0x40
204#define LMP_EDR_3S_ESCO 0x80
Marcel Holtmann04837f62006-07-03 10:02:33 +0200205
Johan Hedbergd5859e22011-01-25 01:19:58 +0200206#define LMP_EXT_INQ 0x01
Marcel Holtmann769be972008-07-14 20:13:49 +0200207#define LMP_SIMPLE_PAIR 0x08
Andrei Emeltchenkoe7021122011-01-03 11:14:36 +0200208#define LMP_NO_FLUSH 0x40
Marcel Holtmann769be972008-07-14 20:13:49 +0200209
Johan Hedbergd5859e22011-01-25 01:19:58 +0200210#define LMP_LSTO 0x01
211#define LMP_INQ_TX_PWR 0x02
212
Marcel Holtmann04837f62006-07-03 10:02:33 +0200213/* Connection modes */
214#define HCI_CM_ACTIVE 0x0000
215#define HCI_CM_HOLD 0x0001
216#define HCI_CM_SNIFF 0x0002
217#define HCI_CM_PARK 0x0003
218
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219/* Link policies */
220#define HCI_LP_RSWITCH 0x0001
221#define HCI_LP_HOLD 0x0002
222#define HCI_LP_SNIFF 0x0004
223#define HCI_LP_PARK 0x0008
224
Marcel Holtmann04837f62006-07-03 10:02:33 +0200225/* Link modes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226#define HCI_LM_ACCEPT 0x8000
227#define HCI_LM_MASTER 0x0001
228#define HCI_LM_AUTH 0x0002
229#define HCI_LM_ENCRYPT 0x0004
230#define HCI_LM_TRUSTED 0x0008
231#define HCI_LM_RELIABLE 0x0010
232#define HCI_LM_SECURE 0x0020
233
Marcel Holtmann40be4922008-07-14 20:13:50 +0200234/* Authentication types */
235#define HCI_AT_NO_BONDING 0x00
236#define HCI_AT_NO_BONDING_MITM 0x01
237#define HCI_AT_DEDICATED_BONDING 0x02
238#define HCI_AT_DEDICATED_BONDING_MITM 0x03
239#define HCI_AT_GENERAL_BONDING 0x04
240#define HCI_AT_GENERAL_BONDING_MITM 0x05
241
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242/* ----- HCI Commands ---- */
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200243#define HCI_OP_INQUIRY 0x0401
244struct hci_cp_inquiry {
245 __u8 lap[3];
246 __u8 length;
247 __u8 num_rsp;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300248} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200250#define HCI_OP_INQUIRY_CANCEL 0x0402
251
252#define HCI_OP_EXIT_PERIODIC_INQ 0x0404
253
254#define HCI_OP_CREATE_CONN 0x0405
255struct hci_cp_create_conn {
256 bdaddr_t bdaddr;
257 __le16 pkt_type;
258 __u8 pscan_rep_mode;
259 __u8 pscan_mode;
260 __le16 clock_offset;
261 __u8 role_switch;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300262} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200264#define HCI_OP_DISCONNECT 0x0406
265struct hci_cp_disconnect {
266 __le16 handle;
267 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300268} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200270#define HCI_OP_ADD_SCO 0x0407
271struct hci_cp_add_sco {
272 __le16 handle;
273 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300274} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200275
276#define HCI_OP_CREATE_CONN_CANCEL 0x0408
277struct hci_cp_create_conn_cancel {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300279} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200281#define HCI_OP_ACCEPT_CONN_REQ 0x0409
282struct hci_cp_accept_conn_req {
283 bdaddr_t bdaddr;
284 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300285} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200287#define HCI_OP_REJECT_CONN_REQ 0x040a
288struct hci_cp_reject_conn_req {
289 bdaddr_t bdaddr;
290 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300291} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200293#define HCI_OP_LINK_KEY_REPLY 0x040b
294struct hci_cp_link_key_reply {
295 bdaddr_t bdaddr;
296 __u8 link_key[16];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300297} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200299#define HCI_OP_LINK_KEY_NEG_REPLY 0x040c
300struct hci_cp_link_key_neg_reply {
301 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300302} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200304#define HCI_OP_PIN_CODE_REPLY 0x040d
305struct hci_cp_pin_code_reply {
306 bdaddr_t bdaddr;
307 __u8 pin_len;
308 __u8 pin_code[16];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300309} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200310
311#define HCI_OP_PIN_CODE_NEG_REPLY 0x040e
312struct hci_cp_pin_code_neg_reply {
313 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300314} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200315
316#define HCI_OP_CHANGE_CONN_PTYPE 0x040f
317struct hci_cp_change_conn_ptype {
318 __le16 handle;
319 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300320} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200321
322#define HCI_OP_AUTH_REQUESTED 0x0411
323struct hci_cp_auth_requested {
324 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300325} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200326
327#define HCI_OP_SET_CONN_ENCRYPT 0x0413
328struct hci_cp_set_conn_encrypt {
329 __le16 handle;
330 __u8 encrypt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300331} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200332
333#define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415
334struct hci_cp_change_conn_link_key {
335 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300336} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200337
338#define HCI_OP_REMOTE_NAME_REQ 0x0419
339struct hci_cp_remote_name_req {
340 bdaddr_t bdaddr;
341 __u8 pscan_rep_mode;
342 __u8 pscan_mode;
343 __le16 clock_offset;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300344} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200345
346#define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a
347struct hci_cp_remote_name_req_cancel {
348 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300349} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200350
351#define HCI_OP_READ_REMOTE_FEATURES 0x041b
352struct hci_cp_read_remote_features {
353 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300354} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200355
356#define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c
357struct hci_cp_read_remote_ext_features {
358 __le16 handle;
359 __u8 page;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300360} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200361
362#define HCI_OP_READ_REMOTE_VERSION 0x041d
363struct hci_cp_read_remote_version {
364 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300365} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200366
367#define HCI_OP_SETUP_SYNC_CONN 0x0428
368struct hci_cp_setup_sync_conn {
369 __le16 handle;
370 __le32 tx_bandwidth;
371 __le32 rx_bandwidth;
372 __le16 max_latency;
373 __le16 voice_setting;
374 __u8 retrans_effort;
375 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300376} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200377
378#define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429
379struct hci_cp_accept_sync_conn_req {
380 bdaddr_t bdaddr;
381 __le32 tx_bandwidth;
382 __le32 rx_bandwidth;
383 __le16 max_latency;
384 __le16 content_format;
385 __u8 retrans_effort;
386 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300387} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200388
389#define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a
390struct hci_cp_reject_sync_conn_req {
391 bdaddr_t bdaddr;
392 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300393} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200394
Johan Hedberg03b555e2011-01-04 15:40:05 +0200395#define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
396struct hci_cp_io_capability_neg_reply {
397 bdaddr_t bdaddr;
398 __u8 reason;
399} __packed;
400
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200401#define HCI_OP_SNIFF_MODE 0x0803
402struct hci_cp_sniff_mode {
403 __le16 handle;
404 __le16 max_interval;
405 __le16 min_interval;
406 __le16 attempt;
407 __le16 timeout;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300408} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200409
410#define HCI_OP_EXIT_SNIFF_MODE 0x0804
411struct hci_cp_exit_sniff_mode {
412 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300413} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200414
415#define HCI_OP_ROLE_DISCOVERY 0x0809
416struct hci_cp_role_discovery {
417 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300418} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200419struct hci_rp_role_discovery {
420 __u8 status;
421 __le16 handle;
422 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300423} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200424
425#define HCI_OP_SWITCH_ROLE 0x080b
426struct hci_cp_switch_role {
427 bdaddr_t bdaddr;
428 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300429} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200430
431#define HCI_OP_READ_LINK_POLICY 0x080c
432struct hci_cp_read_link_policy {
433 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300434} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200435struct hci_rp_read_link_policy {
436 __u8 status;
437 __le16 handle;
438 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300439} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200440
441#define HCI_OP_WRITE_LINK_POLICY 0x080d
442struct hci_cp_write_link_policy {
443 __le16 handle;
444 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300445} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200446struct hci_rp_write_link_policy {
447 __u8 status;
448 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300449} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200450
Marcel Holtmanne4e8e372008-07-14 20:13:47 +0200451#define HCI_OP_READ_DEF_LINK_POLICY 0x080e
452struct hci_rp_read_def_link_policy {
453 __u8 status;
454 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300455} __packed;
Marcel Holtmanne4e8e372008-07-14 20:13:47 +0200456
457#define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f
458struct hci_cp_write_def_link_policy {
459 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300460} __packed;
Marcel Holtmanne4e8e372008-07-14 20:13:47 +0200461
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200462#define HCI_OP_SNIFF_SUBRATE 0x0811
463struct hci_cp_sniff_subrate {
464 __le16 handle;
465 __le16 max_latency;
466 __le16 min_remote_timeout;
467 __le16 min_local_timeout;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300468} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200469
470#define HCI_OP_SET_EVENT_MASK 0x0c01
471struct hci_cp_set_event_mask {
472 __u8 mask[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300473} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200474
475#define HCI_OP_RESET 0x0c03
476
477#define HCI_OP_SET_EVENT_FLT 0x0c05
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478struct hci_cp_set_event_flt {
479 __u8 flt_type;
480 __u8 cond_type;
481 __u8 condition[0];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300482} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483
484/* Filter types */
485#define HCI_FLT_CLEAR_ALL 0x00
486#define HCI_FLT_INQ_RESULT 0x01
487#define HCI_FLT_CONN_SETUP 0x02
488
489/* CONN_SETUP Condition types */
490#define HCI_CONN_SETUP_ALLOW_ALL 0x00
491#define HCI_CONN_SETUP_ALLOW_CLASS 0x01
492#define HCI_CONN_SETUP_ALLOW_BDADDR 0x02
493
494/* CONN_SETUP Conditions */
495#define HCI_CONN_SETUP_AUTO_OFF 0x01
496#define HCI_CONN_SETUP_AUTO_ON 0x02
497
Johan Hedbergb0916ea2011-01-10 13:44:55 +0200498#define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
499struct hci_cp_delete_stored_link_key {
500 bdaddr_t bdaddr;
501 __u8 delete_all;
502} __packed;
503
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200504#define HCI_OP_WRITE_LOCAL_NAME 0x0c13
505struct hci_cp_write_local_name {
506 __u8 name[248];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300507} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200508
509#define HCI_OP_READ_LOCAL_NAME 0x0c14
510struct hci_rp_read_local_name {
511 __u8 status;
512 __u8 name[248];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300513} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200514
515#define HCI_OP_WRITE_CA_TIMEOUT 0x0c16
516
517#define HCI_OP_WRITE_PG_TIMEOUT 0x0c18
518
Andrei Emeltchenko70f230202010-12-01 16:58:25 +0200519#define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200520 #define SCAN_DISABLED 0x00
521 #define SCAN_INQUIRY 0x01
522 #define SCAN_PAGE 0x02
523
524#define HCI_OP_READ_AUTH_ENABLE 0x0c1f
525
526#define HCI_OP_WRITE_AUTH_ENABLE 0x0c20
527 #define AUTH_DISABLED 0x00
528 #define AUTH_ENABLED 0x01
529
530#define HCI_OP_READ_ENCRYPT_MODE 0x0c21
531
532#define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22
533 #define ENCRYPT_DISABLED 0x00
534 #define ENCRYPT_P2P 0x01
535 #define ENCRYPT_BOTH 0x02
536
537#define HCI_OP_READ_CLASS_OF_DEV 0x0c23
538struct hci_rp_read_class_of_dev {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 __u8 status;
540 __u8 dev_class[3];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300541} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200543#define HCI_OP_WRITE_CLASS_OF_DEV 0x0c24
544struct hci_cp_write_class_of_dev {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 __u8 dev_class[3];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300546} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200548#define HCI_OP_READ_VOICE_SETTING 0x0c25
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549struct hci_rp_read_voice_setting {
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800550 __u8 status;
551 __le16 voice_setting;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300552} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200554#define HCI_OP_WRITE_VOICE_SETTING 0x0c26
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555struct hci_cp_write_voice_setting {
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800556 __le16 voice_setting;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300557} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200559#define HCI_OP_HOST_BUFFER_SIZE 0x0c33
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560struct hci_cp_host_buffer_size {
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800561 __le16 acl_mtu;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 __u8 sco_mtu;
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800563 __le16 acl_max_pkt;
564 __le16 sco_max_pkt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300565} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566
Johan Hedbergd5859e22011-01-25 01:19:58 +0200567#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
568
Marcel Holtmann333140b2008-07-14 20:13:48 +0200569#define HCI_OP_READ_SSP_MODE 0x0c55
570struct hci_rp_read_ssp_mode {
571 __u8 status;
572 __u8 mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300573} __packed;
Marcel Holtmann333140b2008-07-14 20:13:48 +0200574
575#define HCI_OP_WRITE_SSP_MODE 0x0c56
576struct hci_cp_write_ssp_mode {
577 __u8 mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300578} __packed;
Marcel Holtmann333140b2008-07-14 20:13:48 +0200579
Johan Hedbergd5859e22011-01-25 01:19:58 +0200580#define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
581
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200582#define HCI_OP_READ_LOCAL_VERSION 0x1001
583struct hci_rp_read_local_version {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 __u8 status;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200585 __u8 hci_ver;
586 __le16 hci_rev;
587 __u8 lmp_ver;
588 __le16 manufacturer;
589 __le16 lmp_subver;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300590} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200592#define HCI_OP_READ_LOCAL_COMMANDS 0x1002
593struct hci_rp_read_local_commands {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 __u8 status;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200595 __u8 commands[64];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300596} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200598#define HCI_OP_READ_LOCAL_FEATURES 0x1003
599struct hci_rp_read_local_features {
600 __u8 status;
601 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300602} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200603
604#define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004
605struct hci_rp_read_local_ext_features {
606 __u8 status;
607 __u8 page;
608 __u8 max_page;
609 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300610} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200611
612#define HCI_OP_READ_BUFFER_SIZE 0x1005
613struct hci_rp_read_buffer_size {
614 __u8 status;
615 __le16 acl_mtu;
616 __u8 sco_mtu;
617 __le16 acl_max_pkt;
618 __le16 sco_max_pkt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300619} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200620
621#define HCI_OP_READ_BD_ADDR 0x1009
622struct hci_rp_read_bd_addr {
623 __u8 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300625} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627/* ---- HCI Events ---- */
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200628#define HCI_EV_INQUIRY_COMPLETE 0x01
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200630#define HCI_EV_INQUIRY_RESULT 0x02
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631struct inquiry_info {
632 bdaddr_t bdaddr;
633 __u8 pscan_rep_mode;
634 __u8 pscan_period_mode;
635 __u8 pscan_mode;
636 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800637 __le16 clock_offset;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300638} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200640#define HCI_EV_CONN_COMPLETE 0x03
641struct hci_ev_conn_complete {
642 __u8 status;
643 __le16 handle;
644 bdaddr_t bdaddr;
645 __u8 link_type;
646 __u8 encr_mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300647} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200648
649#define HCI_EV_CONN_REQUEST 0x04
650struct hci_ev_conn_request {
651 bdaddr_t bdaddr;
652 __u8 dev_class[3];
653 __u8 link_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300654} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200655
656#define HCI_EV_DISCONN_COMPLETE 0x05
657struct hci_ev_disconn_complete {
658 __u8 status;
659 __le16 handle;
660 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300661} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200662
663#define HCI_EV_AUTH_COMPLETE 0x06
664struct hci_ev_auth_complete {
665 __u8 status;
666 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300667} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200668
669#define HCI_EV_REMOTE_NAME 0x07
670struct hci_ev_remote_name {
671 __u8 status;
672 bdaddr_t bdaddr;
673 __u8 name[248];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300674} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200675
676#define HCI_EV_ENCRYPT_CHANGE 0x08
677struct hci_ev_encrypt_change {
678 __u8 status;
679 __le16 handle;
680 __u8 encrypt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300681} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200682
683#define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09
684struct hci_ev_change_link_key_complete {
685 __u8 status;
686 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300687} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200688
689#define HCI_EV_REMOTE_FEATURES 0x0b
690struct hci_ev_remote_features {
691 __u8 status;
692 __le16 handle;
693 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300694} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200695
696#define HCI_EV_REMOTE_VERSION 0x0c
697struct hci_ev_remote_version {
698 __u8 status;
699 __le16 handle;
700 __u8 lmp_ver;
701 __le16 manufacturer;
702 __le16 lmp_subver;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300703} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200704
705#define HCI_EV_QOS_SETUP_COMPLETE 0x0d
706struct hci_qos {
707 __u8 service_type;
708 __u32 token_rate;
709 __u32 peak_bandwidth;
710 __u32 latency;
711 __u32 delay_variation;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300712} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200713struct hci_ev_qos_setup_complete {
714 __u8 status;
715 __le16 handle;
716 struct hci_qos qos;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300717} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200718
719#define HCI_EV_CMD_COMPLETE 0x0e
720struct hci_ev_cmd_complete {
721 __u8 ncmd;
722 __le16 opcode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300723} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200724
725#define HCI_EV_CMD_STATUS 0x0f
726struct hci_ev_cmd_status {
727 __u8 status;
728 __u8 ncmd;
729 __le16 opcode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300730} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200731
732#define HCI_EV_ROLE_CHANGE 0x12
733struct hci_ev_role_change {
734 __u8 status;
735 bdaddr_t bdaddr;
736 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300737} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200738
739#define HCI_EV_NUM_COMP_PKTS 0x13
740struct hci_ev_num_comp_pkts {
741 __u8 num_hndl;
742 /* variable length part */
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300743} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200744
745#define HCI_EV_MODE_CHANGE 0x14
746struct hci_ev_mode_change {
747 __u8 status;
748 __le16 handle;
749 __u8 mode;
750 __le16 interval;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300751} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200752
753#define HCI_EV_PIN_CODE_REQ 0x16
754struct hci_ev_pin_code_req {
755 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300756} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200757
758#define HCI_EV_LINK_KEY_REQ 0x17
759struct hci_ev_link_key_req {
760 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300761} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200762
763#define HCI_EV_LINK_KEY_NOTIFY 0x18
764struct hci_ev_link_key_notify {
765 bdaddr_t bdaddr;
766 __u8 link_key[16];
767 __u8 key_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300768} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200769
770#define HCI_EV_CLOCK_OFFSET 0x1c
771struct hci_ev_clock_offset {
772 __u8 status;
773 __le16 handle;
774 __le16 clock_offset;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300775} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200776
Marcel Holtmanna8746412008-07-14 20:13:46 +0200777#define HCI_EV_PKT_TYPE_CHANGE 0x1d
778struct hci_ev_pkt_type_change {
779 __u8 status;
780 __le16 handle;
781 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300782} __packed;
Marcel Holtmanna8746412008-07-14 20:13:46 +0200783
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200784#define HCI_EV_PSCAN_REP_MODE 0x20
785struct hci_ev_pscan_rep_mode {
786 bdaddr_t bdaddr;
787 __u8 pscan_rep_mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300788} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200789
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790#define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
791struct inquiry_info_with_rssi {
792 bdaddr_t bdaddr;
793 __u8 pscan_rep_mode;
794 __u8 pscan_period_mode;
795 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800796 __le16 clock_offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 __s8 rssi;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300798} __packed;
Marcel Holtmann45bb4bf2005-08-09 20:27:49 -0700799struct inquiry_info_with_rssi_and_pscan_mode {
800 bdaddr_t bdaddr;
801 __u8 pscan_rep_mode;
802 __u8 pscan_period_mode;
803 __u8 pscan_mode;
804 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800805 __le16 clock_offset;
Marcel Holtmann45bb4bf2005-08-09 20:27:49 -0700806 __s8 rssi;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300807} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200809#define HCI_EV_REMOTE_EXT_FEATURES 0x23
810struct hci_ev_remote_ext_features {
811 __u8 status;
812 __le16 handle;
813 __u8 page;
814 __u8 max_page;
815 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300816} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200817
818#define HCI_EV_SYNC_CONN_COMPLETE 0x2c
819struct hci_ev_sync_conn_complete {
820 __u8 status;
821 __le16 handle;
822 bdaddr_t bdaddr;
823 __u8 link_type;
824 __u8 tx_interval;
825 __u8 retrans_window;
826 __le16 rx_pkt_len;
827 __le16 tx_pkt_len;
828 __u8 air_mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300829} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200830
831#define HCI_EV_SYNC_CONN_CHANGED 0x2d
832struct hci_ev_sync_conn_changed {
833 __u8 status;
834 __le16 handle;
835 __u8 tx_interval;
836 __u8 retrans_window;
837 __le16 rx_pkt_len;
838 __le16 tx_pkt_len;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300839} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200840
841#define HCI_EV_SNIFF_SUBRATE 0x2e
842struct hci_ev_sniff_subrate {
843 __u8 status;
844 __le16 handle;
845 __le16 max_tx_latency;
846 __le16 max_rx_latency;
847 __le16 max_remote_timeout;
848 __le16 max_local_timeout;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300849} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200850
851#define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f
Marcel Holtmann21d9e302005-09-13 01:32:25 +0200852struct extended_inquiry_info {
853 bdaddr_t bdaddr;
854 __u8 pscan_rep_mode;
855 __u8 pscan_period_mode;
856 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800857 __le16 clock_offset;
Marcel Holtmann21d9e302005-09-13 01:32:25 +0200858 __s8 rssi;
859 __u8 data[240];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300860} __packed;
Marcel Holtmann21d9e302005-09-13 01:32:25 +0200861
Marcel Holtmann04936842008-07-14 20:13:48 +0200862#define HCI_EV_IO_CAPA_REQUEST 0x31
863struct hci_ev_io_capa_request {
864 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300865} __packed;
Marcel Holtmann04936842008-07-14 20:13:48 +0200866
Johan Hedberg03b555e2011-01-04 15:40:05 +0200867#define HCI_EV_IO_CAPA_REPLY 0x32
868struct hci_ev_io_capa_reply {
869 bdaddr_t bdaddr;
870 __u8 capability;
871 __u8 oob_data;
872 __u8 authentication;
873} __packed;
874
Marcel Holtmann04936842008-07-14 20:13:48 +0200875#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
876struct hci_ev_simple_pair_complete {
877 __u8 status;
878 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300879} __packed;
Marcel Holtmann04936842008-07-14 20:13:48 +0200880
Marcel Holtmann41a96212008-07-14 20:13:48 +0200881#define HCI_EV_REMOTE_HOST_FEATURES 0x3d
882struct hci_ev_remote_host_features {
883 bdaddr_t bdaddr;
884 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300885} __packed;
Marcel Holtmann41a96212008-07-14 20:13:48 +0200886
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887/* Internal events generated by Bluetooth stack */
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200888#define HCI_EV_STACK_INTERNAL 0xfd
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889struct hci_ev_stack_internal {
890 __u16 type;
891 __u8 data[0];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300892} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200894#define HCI_EV_SI_DEVICE 0x01
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895struct hci_ev_si_device {
896 __u16 event;
897 __u16 dev_id;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300898} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899
900#define HCI_EV_SI_SECURITY 0x02
901struct hci_ev_si_security {
902 __u16 event;
903 __u16 proto;
904 __u16 subproto;
905 __u8 incoming;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300906} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907
908/* ---- HCI Packet structures ---- */
909#define HCI_COMMAND_HDR_SIZE 3
910#define HCI_EVENT_HDR_SIZE 2
911#define HCI_ACL_HDR_SIZE 4
912#define HCI_SCO_HDR_SIZE 3
913
914struct hci_command_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200915 __le16 opcode; /* OCF & OGF */
Andrei Emeltchenko70f230202010-12-01 16:58:25 +0200916 __u8 plen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300917} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918
919struct hci_event_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200920 __u8 evt;
921 __u8 plen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300922} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700923
924struct hci_acl_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200925 __le16 handle; /* Handle & Flags(PB, BC) */
926 __le16 dlen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300927} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928
929struct hci_sco_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200930 __le16 handle;
931 __u8 dlen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300932} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -0300934#ifdef __KERNEL__
935#include <linux/skbuff.h>
936static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
937{
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200938 return (struct hci_event_hdr *) skb->data;
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -0300939}
940
941static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
942{
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200943 return (struct hci_acl_hdr *) skb->data;
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -0300944}
945
946static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
947{
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200948 return (struct hci_sco_hdr *) skb->data;
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -0300949}
950#endif
951
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952/* Command opcode pack/unpack */
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800953#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954#define hci_opcode_ogf(op) (op >> 10)
955#define hci_opcode_ocf(op) (op & 0x03ff)
956
957/* ACL handle and flags pack/unpack */
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800958#define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959#define hci_handle(h) (h & 0x0fff)
960#define hci_flags(h) (h >> 12)
961
962/* ---- HCI Sockets ---- */
963
964/* Socket options */
965#define HCI_DATA_DIR 1
966#define HCI_FILTER 2
967#define HCI_TIME_STAMP 3
968
969/* CMSG flags */
970#define HCI_CMSG_DIR 0x0001
971#define HCI_CMSG_TSTAMP 0x0002
972
973struct sockaddr_hci {
974 sa_family_t hci_family;
975 unsigned short hci_dev;
Johan Hedbergc02178d2010-12-08 00:21:05 +0200976 unsigned short hci_channel;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977};
978#define HCI_DEV_NONE 0xffff
979
Johan Hedbergc02178d2010-12-08 00:21:05 +0200980#define HCI_CHANNEL_RAW 0
981#define HCI_CHANNEL_CONTROL 1
982
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983struct hci_filter {
984 unsigned long type_mask;
985 unsigned long event_mask[2];
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200986 __le16 opcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987};
988
989struct hci_ufilter {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200990 __u32 type_mask;
991 __u32 event_mask[2];
992 __le16 opcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993};
994
995#define HCI_FLT_TYPE_BITS 31
996#define HCI_FLT_EVENT_BITS 63
997#define HCI_FLT_OGF_BITS 63
998#define HCI_FLT_OCF_BITS 127
999
1000/* ---- HCI Ioctl requests structures ---- */
1001struct hci_dev_stats {
1002 __u32 err_rx;
1003 __u32 err_tx;
1004 __u32 cmd_tx;
1005 __u32 evt_rx;
1006 __u32 acl_tx;
1007 __u32 acl_rx;
1008 __u32 sco_tx;
1009 __u32 sco_rx;
1010 __u32 byte_rx;
1011 __u32 byte_tx;
1012};
1013
1014struct hci_dev_info {
1015 __u16 dev_id;
1016 char name[8];
1017
1018 bdaddr_t bdaddr;
1019
1020 __u32 flags;
1021 __u8 type;
1022
1023 __u8 features[8];
1024
1025 __u32 pkt_type;
1026 __u32 link_policy;
1027 __u32 link_mode;
1028
1029 __u16 acl_mtu;
1030 __u16 acl_pkts;
1031 __u16 sco_mtu;
1032 __u16 sco_pkts;
1033
1034 struct hci_dev_stats stat;
1035};
1036
1037struct hci_conn_info {
1038 __u16 handle;
1039 bdaddr_t bdaddr;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001040 __u8 type;
1041 __u8 out;
1042 __u16 state;
1043 __u32 link_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044};
1045
1046struct hci_dev_req {
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001047 __u16 dev_id;
1048 __u32 dev_opt;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049};
1050
1051struct hci_dev_list_req {
1052 __u16 dev_num;
1053 struct hci_dev_req dev_req[0]; /* hci_dev_req structures */
1054};
1055
1056struct hci_conn_list_req {
1057 __u16 dev_id;
1058 __u16 conn_num;
1059 struct hci_conn_info conn_info[0];
1060};
1061
1062struct hci_conn_info_req {
1063 bdaddr_t bdaddr;
1064 __u8 type;
1065 struct hci_conn_info conn_info[0];
1066};
1067
Marcel Holtmann40be4922008-07-14 20:13:50 +02001068struct hci_auth_info_req {
1069 bdaddr_t bdaddr;
1070 __u8 type;
1071};
1072
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073struct hci_inquiry_req {
1074 __u16 dev_id;
1075 __u16 flags;
1076 __u8 lap[3];
1077 __u8 length;
1078 __u8 num_rsp;
1079};
1080#define IREQ_CACHE_FLUSH 0x0001
1081
1082#endif /* __HCI_H */