blob: e756f82a29e5d1ebea19e19ca7da935d960b0e5c [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,
Johan Hedberg55ed8ca12011-01-17 14:41:05 +020085 HCI_LINK_KEYS,
86 HCI_DEBUG_KEYS,
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
89/* HCI ioctl defines */
90#define HCIDEVUP _IOW('H', 201, int)
91#define HCIDEVDOWN _IOW('H', 202, int)
92#define HCIDEVRESET _IOW('H', 203, int)
93#define HCIDEVRESTAT _IOW('H', 204, int)
94
95#define HCIGETDEVLIST _IOR('H', 210, int)
96#define HCIGETDEVINFO _IOR('H', 211, int)
97#define HCIGETCONNLIST _IOR('H', 212, int)
98#define HCIGETCONNINFO _IOR('H', 213, int)
Marcel Holtmann40be4922008-07-14 20:13:50 +020099#define HCIGETAUTHINFO _IOR('H', 215, int)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
101#define HCISETRAW _IOW('H', 220, int)
102#define HCISETSCAN _IOW('H', 221, int)
103#define HCISETAUTH _IOW('H', 222, int)
104#define HCISETENCRYPT _IOW('H', 223, int)
105#define HCISETPTYPE _IOW('H', 224, int)
106#define HCISETLINKPOL _IOW('H', 225, int)
107#define HCISETLINKMODE _IOW('H', 226, int)
108#define HCISETACLMTU _IOW('H', 227, int)
109#define HCISETSCOMTU _IOW('H', 228, int)
110
Johan Hedbergf0358562010-05-18 13:20:32 +0200111#define HCIBLOCKADDR _IOW('H', 230, int)
112#define HCIUNBLOCKADDR _IOW('H', 231, int)
113
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114#define HCIINQUIRY _IOR('H', 240, int)
115
116/* HCI timeouts */
Marcel Holtmann04837f62006-07-03 10:02:33 +0200117#define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */
118#define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */
Marcel Holtmann052b30b2009-04-26 20:01:22 +0200119#define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */
Marcel Holtmann04837f62006-07-03 10:02:33 +0200120#define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */
121#define HCI_INIT_TIMEOUT (10000) /* 10 seconds */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200123/* HCI data types */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124#define HCI_COMMAND_PKT 0x01
125#define HCI_ACLDATA_PKT 0x02
126#define HCI_SCODATA_PKT 0x03
127#define HCI_EVENT_PKT 0x04
128#define HCI_VENDOR_PKT 0xff
129
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200130/* HCI packet types */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131#define HCI_DM1 0x0008
132#define HCI_DM3 0x0400
133#define HCI_DM5 0x4000
134#define HCI_DH1 0x0010
135#define HCI_DH3 0x0800
136#define HCI_DH5 0x8000
137
138#define HCI_HV1 0x0020
139#define HCI_HV2 0x0040
140#define HCI_HV3 0x0080
141
142#define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
143#define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
144
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200145/* eSCO packet types */
146#define ESCO_HV1 0x0001
147#define ESCO_HV2 0x0002
148#define ESCO_HV3 0x0004
149#define ESCO_EV3 0x0008
150#define ESCO_EV4 0x0010
151#define ESCO_EV5 0x0020
Marcel Holtmannefc76882009-02-06 09:13:37 +0100152#define ESCO_2EV3 0x0040
153#define ESCO_3EV3 0x0080
154#define ESCO_2EV5 0x0100
155#define ESCO_3EV5 0x0200
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200156
Marcel Holtmanna8746412008-07-14 20:13:46 +0200157#define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
Marcel Holtmannefc76882009-02-06 09:13:37 +0100158#define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
Marcel Holtmanna8746412008-07-14 20:13:46 +0200159
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160/* ACL flags */
Andrei Emeltchenkoe7021122011-01-03 11:14:36 +0200161#define ACL_START_NO_FLUSH 0x00
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162#define ACL_CONT 0x01
163#define ACL_START 0x02
164#define ACL_ACTIVE_BCAST 0x04
165#define ACL_PICO_BCAST 0x08
166
167/* Baseband links */
168#define SCO_LINK 0x00
169#define ACL_LINK 0x01
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200170#define ESCO_LINK 0x02
Ville Tervofcd89c02011-02-10 22:38:47 -0300171/* Low Energy links do not have defined link type. Use invented one */
172#define LE_LINK 0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
174/* LMP features */
175#define LMP_3SLOT 0x01
176#define LMP_5SLOT 0x02
177#define LMP_ENCRYPT 0x04
178#define LMP_SOFFSET 0x08
179#define LMP_TACCURACY 0x10
180#define LMP_RSWITCH 0x20
181#define LMP_HOLD 0x40
Marcel Holtmann04837f62006-07-03 10:02:33 +0200182#define LMP_SNIFF 0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
184#define LMP_PARK 0x01
185#define LMP_RSSI 0x02
186#define LMP_QUALITY 0x04
187#define LMP_SCO 0x08
188#define LMP_HV2 0x10
189#define LMP_HV3 0x20
190#define LMP_ULAW 0x40
191#define LMP_ALAW 0x80
192
193#define LMP_CVSD 0x01
194#define LMP_PSCHEME 0x02
195#define LMP_PCONTROL 0x04
196
Johan Hedbergd5859e22011-01-25 01:19:58 +0200197#define LMP_RSSI_INQ 0x40
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200198#define LMP_ESCO 0x80
199
200#define LMP_EV4 0x01
201#define LMP_EV5 0x02
Johan Hedbergd5859e22011-01-25 01:19:58 +0200202#define LMP_LE 0x40
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200203
Marcel Holtmann04837f62006-07-03 10:02:33 +0200204#define LMP_SNIFF_SUBR 0x02
Johan Hedbergd5859e22011-01-25 01:19:58 +0200205#define LMP_PAUSE_ENC 0x04
Marcel Holtmannefc76882009-02-06 09:13:37 +0100206#define LMP_EDR_ESCO_2M 0x20
207#define LMP_EDR_ESCO_3M 0x40
208#define LMP_EDR_3S_ESCO 0x80
Marcel Holtmann04837f62006-07-03 10:02:33 +0200209
Johan Hedbergd5859e22011-01-25 01:19:58 +0200210#define LMP_EXT_INQ 0x01
Marcel Holtmann769be972008-07-14 20:13:49 +0200211#define LMP_SIMPLE_PAIR 0x08
Andrei Emeltchenkoe7021122011-01-03 11:14:36 +0200212#define LMP_NO_FLUSH 0x40
Marcel Holtmann769be972008-07-14 20:13:49 +0200213
Johan Hedbergd5859e22011-01-25 01:19:58 +0200214#define LMP_LSTO 0x01
215#define LMP_INQ_TX_PWR 0x02
216
Marcel Holtmann04837f62006-07-03 10:02:33 +0200217/* Connection modes */
218#define HCI_CM_ACTIVE 0x0000
219#define HCI_CM_HOLD 0x0001
220#define HCI_CM_SNIFF 0x0002
221#define HCI_CM_PARK 0x0003
222
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223/* Link policies */
224#define HCI_LP_RSWITCH 0x0001
225#define HCI_LP_HOLD 0x0002
226#define HCI_LP_SNIFF 0x0004
227#define HCI_LP_PARK 0x0008
228
Marcel Holtmann04837f62006-07-03 10:02:33 +0200229/* Link modes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230#define HCI_LM_ACCEPT 0x8000
231#define HCI_LM_MASTER 0x0001
232#define HCI_LM_AUTH 0x0002
233#define HCI_LM_ENCRYPT 0x0004
234#define HCI_LM_TRUSTED 0x0008
235#define HCI_LM_RELIABLE 0x0010
236#define HCI_LM_SECURE 0x0020
237
Marcel Holtmann40be4922008-07-14 20:13:50 +0200238/* Authentication types */
239#define HCI_AT_NO_BONDING 0x00
240#define HCI_AT_NO_BONDING_MITM 0x01
241#define HCI_AT_DEDICATED_BONDING 0x02
242#define HCI_AT_DEDICATED_BONDING_MITM 0x03
243#define HCI_AT_GENERAL_BONDING 0x04
244#define HCI_AT_GENERAL_BONDING_MITM 0x05
245
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246/* ----- HCI Commands ---- */
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200247#define HCI_OP_INQUIRY 0x0401
248struct hci_cp_inquiry {
249 __u8 lap[3];
250 __u8 length;
251 __u8 num_rsp;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300252} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200254#define HCI_OP_INQUIRY_CANCEL 0x0402
255
256#define HCI_OP_EXIT_PERIODIC_INQ 0x0404
257
258#define HCI_OP_CREATE_CONN 0x0405
259struct hci_cp_create_conn {
260 bdaddr_t bdaddr;
261 __le16 pkt_type;
262 __u8 pscan_rep_mode;
263 __u8 pscan_mode;
264 __le16 clock_offset;
265 __u8 role_switch;
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_DISCONNECT 0x0406
269struct hci_cp_disconnect {
270 __le16 handle;
271 __u8 reason;
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_ADD_SCO 0x0407
275struct hci_cp_add_sco {
276 __le16 handle;
277 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300278} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200279
280#define HCI_OP_CREATE_CONN_CANCEL 0x0408
281struct hci_cp_create_conn_cancel {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300283} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200285#define HCI_OP_ACCEPT_CONN_REQ 0x0409
286struct hci_cp_accept_conn_req {
287 bdaddr_t bdaddr;
288 __u8 role;
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_REJECT_CONN_REQ 0x040a
292struct hci_cp_reject_conn_req {
293 bdaddr_t bdaddr;
294 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300295} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200297#define HCI_OP_LINK_KEY_REPLY 0x040b
298struct hci_cp_link_key_reply {
299 bdaddr_t bdaddr;
300 __u8 link_key[16];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300301} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200303#define HCI_OP_LINK_KEY_NEG_REPLY 0x040c
304struct hci_cp_link_key_neg_reply {
305 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300306} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200308#define HCI_OP_PIN_CODE_REPLY 0x040d
309struct hci_cp_pin_code_reply {
310 bdaddr_t bdaddr;
311 __u8 pin_len;
312 __u8 pin_code[16];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300313} __packed;
Johan Hedberg980e1a52011-01-22 06:10:07 +0200314struct hci_rp_pin_code_reply {
315 __u8 status;
316 bdaddr_t bdaddr;
317} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200318
319#define HCI_OP_PIN_CODE_NEG_REPLY 0x040e
320struct hci_cp_pin_code_neg_reply {
321 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300322} __packed;
Johan Hedberg980e1a52011-01-22 06:10:07 +0200323struct hci_rp_pin_code_neg_reply {
324 __u8 status;
325 bdaddr_t bdaddr;
326} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200327
328#define HCI_OP_CHANGE_CONN_PTYPE 0x040f
329struct hci_cp_change_conn_ptype {
330 __le16 handle;
331 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300332} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200333
334#define HCI_OP_AUTH_REQUESTED 0x0411
335struct hci_cp_auth_requested {
336 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300337} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200338
339#define HCI_OP_SET_CONN_ENCRYPT 0x0413
340struct hci_cp_set_conn_encrypt {
341 __le16 handle;
342 __u8 encrypt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300343} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200344
345#define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415
346struct hci_cp_change_conn_link_key {
347 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300348} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200349
350#define HCI_OP_REMOTE_NAME_REQ 0x0419
351struct hci_cp_remote_name_req {
352 bdaddr_t bdaddr;
353 __u8 pscan_rep_mode;
354 __u8 pscan_mode;
355 __le16 clock_offset;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300356} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200357
358#define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a
359struct hci_cp_remote_name_req_cancel {
360 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300361} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200362
363#define HCI_OP_READ_REMOTE_FEATURES 0x041b
364struct hci_cp_read_remote_features {
365 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300366} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200367
368#define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c
369struct hci_cp_read_remote_ext_features {
370 __le16 handle;
371 __u8 page;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300372} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200373
374#define HCI_OP_READ_REMOTE_VERSION 0x041d
375struct hci_cp_read_remote_version {
376 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300377} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200378
379#define HCI_OP_SETUP_SYNC_CONN 0x0428
380struct hci_cp_setup_sync_conn {
381 __le16 handle;
382 __le32 tx_bandwidth;
383 __le32 rx_bandwidth;
384 __le16 max_latency;
385 __le16 voice_setting;
386 __u8 retrans_effort;
387 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300388} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200389
390#define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429
391struct hci_cp_accept_sync_conn_req {
392 bdaddr_t bdaddr;
393 __le32 tx_bandwidth;
394 __le32 rx_bandwidth;
395 __le16 max_latency;
396 __le16 content_format;
397 __u8 retrans_effort;
398 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300399} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200400
401#define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a
402struct hci_cp_reject_sync_conn_req {
403 bdaddr_t bdaddr;
404 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300405} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200406
Johan Hedberg17fa4b92011-01-25 13:28:33 +0200407#define HCI_OP_IO_CAPABILITY_REPLY 0x042b
408struct hci_cp_io_capability_reply {
409 bdaddr_t bdaddr;
410 __u8 capability;
411 __u8 oob_data;
412 __u8 authentication;
413} __packed;
414
Johan Hedberg03b555e2011-01-04 15:40:05 +0200415#define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
416struct hci_cp_io_capability_neg_reply {
417 bdaddr_t bdaddr;
418 __u8 reason;
419} __packed;
420
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200421#define HCI_OP_SNIFF_MODE 0x0803
422struct hci_cp_sniff_mode {
423 __le16 handle;
424 __le16 max_interval;
425 __le16 min_interval;
426 __le16 attempt;
427 __le16 timeout;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300428} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200429
430#define HCI_OP_EXIT_SNIFF_MODE 0x0804
431struct hci_cp_exit_sniff_mode {
432 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300433} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200434
435#define HCI_OP_ROLE_DISCOVERY 0x0809
436struct hci_cp_role_discovery {
437 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300438} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200439struct hci_rp_role_discovery {
440 __u8 status;
441 __le16 handle;
442 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300443} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200444
445#define HCI_OP_SWITCH_ROLE 0x080b
446struct hci_cp_switch_role {
447 bdaddr_t bdaddr;
448 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300449} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200450
451#define HCI_OP_READ_LINK_POLICY 0x080c
452struct hci_cp_read_link_policy {
453 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300454} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200455struct hci_rp_read_link_policy {
456 __u8 status;
457 __le16 handle;
458 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300459} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200460
461#define HCI_OP_WRITE_LINK_POLICY 0x080d
462struct hci_cp_write_link_policy {
463 __le16 handle;
464 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300465} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200466struct hci_rp_write_link_policy {
467 __u8 status;
468 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300469} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200470
Marcel Holtmanne4e8e372008-07-14 20:13:47 +0200471#define HCI_OP_READ_DEF_LINK_POLICY 0x080e
472struct hci_rp_read_def_link_policy {
473 __u8 status;
474 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300475} __packed;
Marcel Holtmanne4e8e372008-07-14 20:13:47 +0200476
477#define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f
478struct hci_cp_write_def_link_policy {
479 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300480} __packed;
Marcel Holtmanne4e8e372008-07-14 20:13:47 +0200481
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200482#define HCI_OP_SNIFF_SUBRATE 0x0811
483struct hci_cp_sniff_subrate {
484 __le16 handle;
485 __le16 max_latency;
486 __le16 min_remote_timeout;
487 __le16 min_local_timeout;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300488} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200489
490#define HCI_OP_SET_EVENT_MASK 0x0c01
491struct hci_cp_set_event_mask {
492 __u8 mask[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300493} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200494
495#define HCI_OP_RESET 0x0c03
496
497#define HCI_OP_SET_EVENT_FLT 0x0c05
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498struct hci_cp_set_event_flt {
499 __u8 flt_type;
500 __u8 cond_type;
501 __u8 condition[0];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300502} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503
504/* Filter types */
505#define HCI_FLT_CLEAR_ALL 0x00
506#define HCI_FLT_INQ_RESULT 0x01
507#define HCI_FLT_CONN_SETUP 0x02
508
509/* CONN_SETUP Condition types */
510#define HCI_CONN_SETUP_ALLOW_ALL 0x00
511#define HCI_CONN_SETUP_ALLOW_CLASS 0x01
512#define HCI_CONN_SETUP_ALLOW_BDADDR 0x02
513
514/* CONN_SETUP Conditions */
515#define HCI_CONN_SETUP_AUTO_OFF 0x01
516#define HCI_CONN_SETUP_AUTO_ON 0x02
517
Johan Hedbergb0916ea2011-01-10 13:44:55 +0200518#define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
519struct hci_cp_delete_stored_link_key {
520 bdaddr_t bdaddr;
521 __u8 delete_all;
522} __packed;
523
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200524#define HCI_OP_WRITE_LOCAL_NAME 0x0c13
525struct hci_cp_write_local_name {
526 __u8 name[248];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300527} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200528
529#define HCI_OP_READ_LOCAL_NAME 0x0c14
530struct hci_rp_read_local_name {
531 __u8 status;
532 __u8 name[248];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300533} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200534
535#define HCI_OP_WRITE_CA_TIMEOUT 0x0c16
536
537#define HCI_OP_WRITE_PG_TIMEOUT 0x0c18
538
Andrei Emeltchenko70f230202010-12-01 16:58:25 +0200539#define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200540 #define SCAN_DISABLED 0x00
541 #define SCAN_INQUIRY 0x01
542 #define SCAN_PAGE 0x02
543
544#define HCI_OP_READ_AUTH_ENABLE 0x0c1f
545
546#define HCI_OP_WRITE_AUTH_ENABLE 0x0c20
547 #define AUTH_DISABLED 0x00
548 #define AUTH_ENABLED 0x01
549
550#define HCI_OP_READ_ENCRYPT_MODE 0x0c21
551
552#define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22
553 #define ENCRYPT_DISABLED 0x00
554 #define ENCRYPT_P2P 0x01
555 #define ENCRYPT_BOTH 0x02
556
557#define HCI_OP_READ_CLASS_OF_DEV 0x0c23
558struct hci_rp_read_class_of_dev {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 __u8 status;
560 __u8 dev_class[3];
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_WRITE_CLASS_OF_DEV 0x0c24
564struct hci_cp_write_class_of_dev {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 __u8 dev_class[3];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300566} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200568#define HCI_OP_READ_VOICE_SETTING 0x0c25
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569struct hci_rp_read_voice_setting {
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800570 __u8 status;
571 __le16 voice_setting;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300572} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200574#define HCI_OP_WRITE_VOICE_SETTING 0x0c26
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575struct hci_cp_write_voice_setting {
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800576 __le16 voice_setting;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300577} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200579#define HCI_OP_HOST_BUFFER_SIZE 0x0c33
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580struct hci_cp_host_buffer_size {
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800581 __le16 acl_mtu;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 __u8 sco_mtu;
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800583 __le16 acl_max_pkt;
584 __le16 sco_max_pkt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300585} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586
Johan Hedbergd5859e22011-01-25 01:19:58 +0200587#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
588
Marcel Holtmann333140b2008-07-14 20:13:48 +0200589#define HCI_OP_READ_SSP_MODE 0x0c55
590struct hci_rp_read_ssp_mode {
591 __u8 status;
592 __u8 mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300593} __packed;
Marcel Holtmann333140b2008-07-14 20:13:48 +0200594
595#define HCI_OP_WRITE_SSP_MODE 0x0c56
596struct hci_cp_write_ssp_mode {
597 __u8 mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300598} __packed;
Marcel Holtmann333140b2008-07-14 20:13:48 +0200599
Johan Hedbergd5859e22011-01-25 01:19:58 +0200600#define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
601
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200602#define HCI_OP_READ_LOCAL_VERSION 0x1001
603struct hci_rp_read_local_version {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 __u8 status;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200605 __u8 hci_ver;
606 __le16 hci_rev;
607 __u8 lmp_ver;
608 __le16 manufacturer;
609 __le16 lmp_subver;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300610} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200612#define HCI_OP_READ_LOCAL_COMMANDS 0x1002
613struct hci_rp_read_local_commands {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 __u8 status;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200615 __u8 commands[64];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300616} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200618#define HCI_OP_READ_LOCAL_FEATURES 0x1003
619struct hci_rp_read_local_features {
620 __u8 status;
621 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300622} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200623
624#define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004
625struct hci_rp_read_local_ext_features {
626 __u8 status;
627 __u8 page;
628 __u8 max_page;
629 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300630} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200631
632#define HCI_OP_READ_BUFFER_SIZE 0x1005
633struct hci_rp_read_buffer_size {
634 __u8 status;
635 __le16 acl_mtu;
636 __u8 sco_mtu;
637 __le16 acl_max_pkt;
638 __le16 sco_max_pkt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300639} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200640
641#define HCI_OP_READ_BD_ADDR 0x1009
642struct hci_rp_read_bd_addr {
643 __u8 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300645} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646
Ville Tervo63185f62011-02-10 22:38:46 -0300647#define HCI_OP_LE_SET_EVENT_MASK 0x2001
648struct hci_cp_le_set_event_mask {
649 __u8 mask[8];
650} __packed;
651
652#define HCI_OP_LE_READ_BUFFER_SIZE 0x2002
653struct hci_rp_le_read_buffer_size {
654 __u8 status;
655 __le16 le_mtu;
656 __u8 le_max_pkt;
657} __packed;
658
659#define HCI_OP_LE_CREATE_CONN 0x200d
660struct hci_cp_le_create_conn {
661 __le16 scan_interval;
662 __le16 scan_window;
663 __u8 filter_policy;
664 __u8 peer_addr_type;
665 bdaddr_t peer_addr;
666 __u8 own_address_type;
667 __le16 conn_interval_min;
668 __le16 conn_interval_max;
669 __le16 conn_latency;
670 __le16 supervision_timeout;
671 __le16 min_ce_len;
672 __le16 max_ce_len;
673} __packed;
674
675#define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e
676
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677/* ---- HCI Events ---- */
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200678#define HCI_EV_INQUIRY_COMPLETE 0x01
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200680#define HCI_EV_INQUIRY_RESULT 0x02
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681struct inquiry_info {
682 bdaddr_t bdaddr;
683 __u8 pscan_rep_mode;
684 __u8 pscan_period_mode;
685 __u8 pscan_mode;
686 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800687 __le16 clock_offset;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300688} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200690#define HCI_EV_CONN_COMPLETE 0x03
691struct hci_ev_conn_complete {
692 __u8 status;
693 __le16 handle;
694 bdaddr_t bdaddr;
695 __u8 link_type;
696 __u8 encr_mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300697} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200698
699#define HCI_EV_CONN_REQUEST 0x04
700struct hci_ev_conn_request {
701 bdaddr_t bdaddr;
702 __u8 dev_class[3];
703 __u8 link_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300704} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200705
706#define HCI_EV_DISCONN_COMPLETE 0x05
707struct hci_ev_disconn_complete {
708 __u8 status;
709 __le16 handle;
710 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300711} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200712
713#define HCI_EV_AUTH_COMPLETE 0x06
714struct hci_ev_auth_complete {
715 __u8 status;
716 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300717} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200718
719#define HCI_EV_REMOTE_NAME 0x07
720struct hci_ev_remote_name {
721 __u8 status;
722 bdaddr_t bdaddr;
723 __u8 name[248];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300724} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200725
726#define HCI_EV_ENCRYPT_CHANGE 0x08
727struct hci_ev_encrypt_change {
728 __u8 status;
729 __le16 handle;
730 __u8 encrypt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300731} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200732
733#define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09
734struct hci_ev_change_link_key_complete {
735 __u8 status;
736 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300737} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200738
739#define HCI_EV_REMOTE_FEATURES 0x0b
740struct hci_ev_remote_features {
741 __u8 status;
742 __le16 handle;
743 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300744} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200745
746#define HCI_EV_REMOTE_VERSION 0x0c
747struct hci_ev_remote_version {
748 __u8 status;
749 __le16 handle;
750 __u8 lmp_ver;
751 __le16 manufacturer;
752 __le16 lmp_subver;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300753} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200754
755#define HCI_EV_QOS_SETUP_COMPLETE 0x0d
756struct hci_qos {
757 __u8 service_type;
758 __u32 token_rate;
759 __u32 peak_bandwidth;
760 __u32 latency;
761 __u32 delay_variation;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300762} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200763struct hci_ev_qos_setup_complete {
764 __u8 status;
765 __le16 handle;
766 struct hci_qos qos;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300767} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200768
769#define HCI_EV_CMD_COMPLETE 0x0e
770struct hci_ev_cmd_complete {
771 __u8 ncmd;
772 __le16 opcode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300773} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200774
775#define HCI_EV_CMD_STATUS 0x0f
776struct hci_ev_cmd_status {
777 __u8 status;
778 __u8 ncmd;
779 __le16 opcode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300780} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200781
782#define HCI_EV_ROLE_CHANGE 0x12
783struct hci_ev_role_change {
784 __u8 status;
785 bdaddr_t bdaddr;
786 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300787} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200788
789#define HCI_EV_NUM_COMP_PKTS 0x13
790struct hci_ev_num_comp_pkts {
791 __u8 num_hndl;
792 /* variable length part */
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300793} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200794
795#define HCI_EV_MODE_CHANGE 0x14
796struct hci_ev_mode_change {
797 __u8 status;
798 __le16 handle;
799 __u8 mode;
800 __le16 interval;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300801} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200802
803#define HCI_EV_PIN_CODE_REQ 0x16
804struct hci_ev_pin_code_req {
805 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300806} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200807
808#define HCI_EV_LINK_KEY_REQ 0x17
809struct hci_ev_link_key_req {
810 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300811} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200812
813#define HCI_EV_LINK_KEY_NOTIFY 0x18
814struct hci_ev_link_key_notify {
815 bdaddr_t bdaddr;
816 __u8 link_key[16];
817 __u8 key_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300818} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200819
820#define HCI_EV_CLOCK_OFFSET 0x1c
821struct hci_ev_clock_offset {
822 __u8 status;
823 __le16 handle;
824 __le16 clock_offset;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300825} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200826
Marcel Holtmanna8746412008-07-14 20:13:46 +0200827#define HCI_EV_PKT_TYPE_CHANGE 0x1d
828struct hci_ev_pkt_type_change {
829 __u8 status;
830 __le16 handle;
831 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300832} __packed;
Marcel Holtmanna8746412008-07-14 20:13:46 +0200833
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200834#define HCI_EV_PSCAN_REP_MODE 0x20
835struct hci_ev_pscan_rep_mode {
836 bdaddr_t bdaddr;
837 __u8 pscan_rep_mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300838} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200839
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840#define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
841struct inquiry_info_with_rssi {
842 bdaddr_t bdaddr;
843 __u8 pscan_rep_mode;
844 __u8 pscan_period_mode;
845 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800846 __le16 clock_offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 __s8 rssi;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300848} __packed;
Marcel Holtmann45bb4bf2005-08-09 20:27:49 -0700849struct inquiry_info_with_rssi_and_pscan_mode {
850 bdaddr_t bdaddr;
851 __u8 pscan_rep_mode;
852 __u8 pscan_period_mode;
853 __u8 pscan_mode;
854 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800855 __le16 clock_offset;
Marcel Holtmann45bb4bf2005-08-09 20:27:49 -0700856 __s8 rssi;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300857} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200859#define HCI_EV_REMOTE_EXT_FEATURES 0x23
860struct hci_ev_remote_ext_features {
861 __u8 status;
862 __le16 handle;
863 __u8 page;
864 __u8 max_page;
865 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300866} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200867
868#define HCI_EV_SYNC_CONN_COMPLETE 0x2c
869struct hci_ev_sync_conn_complete {
870 __u8 status;
871 __le16 handle;
872 bdaddr_t bdaddr;
873 __u8 link_type;
874 __u8 tx_interval;
875 __u8 retrans_window;
876 __le16 rx_pkt_len;
877 __le16 tx_pkt_len;
878 __u8 air_mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300879} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200880
881#define HCI_EV_SYNC_CONN_CHANGED 0x2d
882struct hci_ev_sync_conn_changed {
883 __u8 status;
884 __le16 handle;
885 __u8 tx_interval;
886 __u8 retrans_window;
887 __le16 rx_pkt_len;
888 __le16 tx_pkt_len;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300889} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200890
891#define HCI_EV_SNIFF_SUBRATE 0x2e
892struct hci_ev_sniff_subrate {
893 __u8 status;
894 __le16 handle;
895 __le16 max_tx_latency;
896 __le16 max_rx_latency;
897 __le16 max_remote_timeout;
898 __le16 max_local_timeout;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300899} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200900
901#define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f
Marcel Holtmann21d9e302005-09-13 01:32:25 +0200902struct extended_inquiry_info {
903 bdaddr_t bdaddr;
904 __u8 pscan_rep_mode;
905 __u8 pscan_period_mode;
906 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800907 __le16 clock_offset;
Marcel Holtmann21d9e302005-09-13 01:32:25 +0200908 __s8 rssi;
909 __u8 data[240];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300910} __packed;
Marcel Holtmann21d9e302005-09-13 01:32:25 +0200911
Marcel Holtmann04936842008-07-14 20:13:48 +0200912#define HCI_EV_IO_CAPA_REQUEST 0x31
913struct hci_ev_io_capa_request {
914 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300915} __packed;
Marcel Holtmann04936842008-07-14 20:13:48 +0200916
Johan Hedberg03b555e2011-01-04 15:40:05 +0200917#define HCI_EV_IO_CAPA_REPLY 0x32
918struct hci_ev_io_capa_reply {
919 bdaddr_t bdaddr;
920 __u8 capability;
921 __u8 oob_data;
922 __u8 authentication;
923} __packed;
924
Marcel Holtmann04936842008-07-14 20:13:48 +0200925#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
926struct hci_ev_simple_pair_complete {
927 __u8 status;
928 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300929} __packed;
Marcel Holtmann04936842008-07-14 20:13:48 +0200930
Marcel Holtmann41a96212008-07-14 20:13:48 +0200931#define HCI_EV_REMOTE_HOST_FEATURES 0x3d
932struct hci_ev_remote_host_features {
933 bdaddr_t bdaddr;
934 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300935} __packed;
Marcel Holtmann41a96212008-07-14 20:13:48 +0200936
Ville Tervo63185f62011-02-10 22:38:46 -0300937#define HCI_EV_LE_META 0x3e
938struct hci_ev_le_meta {
939 __u8 subevent;
940} __packed;
941
942/* Low energy meta events */
943#define HCI_EV_LE_CONN_COMPLETE 0x01
944struct hci_ev_le_conn_complete {
945 __u8 status;
946 __le16 handle;
947 __u8 role;
948 __u8 bdaddr_type;
949 bdaddr_t bdaddr;
950 __le16 interval;
951 __le16 latency;
952 __le16 supervision_timeout;
953 __u8 clk_accurancy;
954} __packed;
955
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956/* Internal events generated by Bluetooth stack */
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200957#define HCI_EV_STACK_INTERNAL 0xfd
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958struct hci_ev_stack_internal {
959 __u16 type;
960 __u8 data[0];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300961} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200963#define HCI_EV_SI_DEVICE 0x01
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964struct hci_ev_si_device {
965 __u16 event;
966 __u16 dev_id;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300967} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968
969#define HCI_EV_SI_SECURITY 0x02
970struct hci_ev_si_security {
971 __u16 event;
972 __u16 proto;
973 __u16 subproto;
974 __u8 incoming;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300975} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700976
977/* ---- HCI Packet structures ---- */
978#define HCI_COMMAND_HDR_SIZE 3
979#define HCI_EVENT_HDR_SIZE 2
980#define HCI_ACL_HDR_SIZE 4
981#define HCI_SCO_HDR_SIZE 3
982
983struct hci_command_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200984 __le16 opcode; /* OCF & OGF */
Andrei Emeltchenko70f230202010-12-01 16:58:25 +0200985 __u8 plen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300986} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987
988struct hci_event_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200989 __u8 evt;
990 __u8 plen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300991} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992
993struct hci_acl_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200994 __le16 handle; /* Handle & Flags(PB, BC) */
995 __le16 dlen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300996} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997
998struct hci_sco_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200999 __le16 handle;
1000 __u8 dlen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001001} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -03001003#ifdef __KERNEL__
1004#include <linux/skbuff.h>
1005static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
1006{
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001007 return (struct hci_event_hdr *) skb->data;
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -03001008}
1009
1010static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
1011{
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001012 return (struct hci_acl_hdr *) skb->data;
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -03001013}
1014
1015static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
1016{
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001017 return (struct hci_sco_hdr *) skb->data;
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -03001018}
1019#endif
1020
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021/* Command opcode pack/unpack */
Marcel Holtmann1ebb9252005-11-08 09:57:21 -08001022#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023#define hci_opcode_ogf(op) (op >> 10)
1024#define hci_opcode_ocf(op) (op & 0x03ff)
1025
1026/* ACL handle and flags pack/unpack */
Marcel Holtmann1ebb9252005-11-08 09:57:21 -08001027#define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001028#define hci_handle(h) (h & 0x0fff)
1029#define hci_flags(h) (h >> 12)
1030
1031/* ---- HCI Sockets ---- */
1032
1033/* Socket options */
1034#define HCI_DATA_DIR 1
1035#define HCI_FILTER 2
1036#define HCI_TIME_STAMP 3
1037
1038/* CMSG flags */
1039#define HCI_CMSG_DIR 0x0001
1040#define HCI_CMSG_TSTAMP 0x0002
1041
1042struct sockaddr_hci {
1043 sa_family_t hci_family;
1044 unsigned short hci_dev;
Johan Hedbergc02178d2010-12-08 00:21:05 +02001045 unsigned short hci_channel;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046};
1047#define HCI_DEV_NONE 0xffff
1048
Johan Hedbergc02178d2010-12-08 00:21:05 +02001049#define HCI_CHANNEL_RAW 0
1050#define HCI_CHANNEL_CONTROL 1
1051
Linus Torvalds1da177e2005-04-16 15:20:36 -07001052struct hci_filter {
1053 unsigned long type_mask;
1054 unsigned long event_mask[2];
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001055 __le16 opcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056};
1057
1058struct hci_ufilter {
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001059 __u32 type_mask;
1060 __u32 event_mask[2];
1061 __le16 opcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001062};
1063
1064#define HCI_FLT_TYPE_BITS 31
1065#define HCI_FLT_EVENT_BITS 63
1066#define HCI_FLT_OGF_BITS 63
1067#define HCI_FLT_OCF_BITS 127
1068
1069/* ---- HCI Ioctl requests structures ---- */
1070struct hci_dev_stats {
1071 __u32 err_rx;
1072 __u32 err_tx;
1073 __u32 cmd_tx;
1074 __u32 evt_rx;
1075 __u32 acl_tx;
1076 __u32 acl_rx;
1077 __u32 sco_tx;
1078 __u32 sco_rx;
1079 __u32 byte_rx;
1080 __u32 byte_tx;
1081};
1082
1083struct hci_dev_info {
1084 __u16 dev_id;
1085 char name[8];
1086
1087 bdaddr_t bdaddr;
1088
1089 __u32 flags;
1090 __u8 type;
1091
1092 __u8 features[8];
1093
1094 __u32 pkt_type;
1095 __u32 link_policy;
1096 __u32 link_mode;
1097
1098 __u16 acl_mtu;
1099 __u16 acl_pkts;
1100 __u16 sco_mtu;
1101 __u16 sco_pkts;
1102
1103 struct hci_dev_stats stat;
1104};
1105
1106struct hci_conn_info {
1107 __u16 handle;
1108 bdaddr_t bdaddr;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001109 __u8 type;
1110 __u8 out;
1111 __u16 state;
1112 __u32 link_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113};
1114
1115struct hci_dev_req {
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001116 __u16 dev_id;
1117 __u32 dev_opt;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118};
1119
1120struct hci_dev_list_req {
1121 __u16 dev_num;
1122 struct hci_dev_req dev_req[0]; /* hci_dev_req structures */
1123};
1124
1125struct hci_conn_list_req {
1126 __u16 dev_id;
1127 __u16 conn_num;
1128 struct hci_conn_info conn_info[0];
1129};
1130
1131struct hci_conn_info_req {
1132 bdaddr_t bdaddr;
1133 __u8 type;
1134 struct hci_conn_info conn_info[0];
1135};
1136
Marcel Holtmann40be4922008-07-14 20:13:50 +02001137struct hci_auth_info_req {
1138 bdaddr_t bdaddr;
1139 __u8 type;
1140};
1141
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142struct hci_inquiry_req {
1143 __u16 dev_id;
1144 __u16 flags;
1145 __u8 lap[3];
1146 __u8 length;
1147 __u8 num_rsp;
1148};
1149#define IREQ_CACHE_FLUSH 0x0001
1150
1151#endif /* __HCI_H */