blob: c97cf0872ac9fdb971c71ef5c63ab7383144ad03 [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
Gustavo F. Padovan10572132011-03-16 15:36:29 -030080 HCI_RESET,
Linus Torvalds1da177e2005-04-16 15:20:36 -070081};
82
Andre Guedesd23264a2011-11-25 20:53:38 -030083/*
84 * BR/EDR and/or LE controller flags: the flags defined here should represent
85 * states from the controller.
86 */
87enum {
Johan Hedberga8b2d5c2012-01-08 23:11:15 +020088 HCI_SETUP,
89 HCI_AUTO_OFF,
90 HCI_MGMT,
91 HCI_PAIRABLE,
92 HCI_SERVICE_CACHE,
93 HCI_LINK_KEYS,
94 HCI_DEBUG_KEYS,
95
Andre Guedesd23264a2011-11-25 20:53:38 -030096 HCI_LE_SCAN,
Johan Hedberg84bde9d2012-01-25 14:21:06 +020097 HCI_SSP_ENABLED,
Johan Hedberg6d80dfd2012-02-20 23:50:38 +020098 HCI_HS_ENABLED,
Johan Hedberg06199cf2012-02-22 16:37:11 +020099 HCI_LE_ENABLED,
Johan Hedberg5e5282b2012-02-21 16:01:30 +0200100 HCI_CONNECTABLE,
101 HCI_DISCOVERABLE,
Johan Hedberg47990ea2012-02-22 11:58:37 +0200102 HCI_LINK_SECURITY,
Andre Guedesd23264a2011-11-25 20:53:38 -0300103};
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105/* HCI ioctl defines */
106#define HCIDEVUP _IOW('H', 201, int)
107#define HCIDEVDOWN _IOW('H', 202, int)
108#define HCIDEVRESET _IOW('H', 203, int)
109#define HCIDEVRESTAT _IOW('H', 204, int)
110
111#define HCIGETDEVLIST _IOR('H', 210, int)
112#define HCIGETDEVINFO _IOR('H', 211, int)
113#define HCIGETCONNLIST _IOR('H', 212, int)
114#define HCIGETCONNINFO _IOR('H', 213, int)
Marcel Holtmann40be4922008-07-14 20:13:50 +0200115#define HCIGETAUTHINFO _IOR('H', 215, int)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
117#define HCISETRAW _IOW('H', 220, int)
118#define HCISETSCAN _IOW('H', 221, int)
119#define HCISETAUTH _IOW('H', 222, int)
120#define HCISETENCRYPT _IOW('H', 223, int)
121#define HCISETPTYPE _IOW('H', 224, int)
122#define HCISETLINKPOL _IOW('H', 225, int)
123#define HCISETLINKMODE _IOW('H', 226, int)
124#define HCISETACLMTU _IOW('H', 227, int)
125#define HCISETSCOMTU _IOW('H', 228, int)
126
Johan Hedbergf0358562010-05-18 13:20:32 +0200127#define HCIBLOCKADDR _IOW('H', 230, int)
128#define HCIUNBLOCKADDR _IOW('H', 231, int)
129
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130#define HCIINQUIRY _IOR('H', 240, int)
131
132/* HCI timeouts */
Marcel Holtmann04837f62006-07-03 10:02:33 +0200133#define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */
134#define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */
Marcel Holtmann052b30b2009-04-26 20:01:22 +0200135#define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */
Marcel Holtmann04837f62006-07-03 10:02:33 +0200136#define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */
137#define HCI_INIT_TIMEOUT (10000) /* 10 seconds */
Ville Tervo6bd32322011-02-16 16:32:41 +0200138#define HCI_CMD_TIMEOUT (1000) /* 1 seconds */
Andrei Emeltchenkocc48dc02012-01-04 16:42:26 +0200139#define HCI_ACL_TX_TIMEOUT (45000) /* 45 seconds */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200141/* HCI data types */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142#define HCI_COMMAND_PKT 0x01
143#define HCI_ACLDATA_PKT 0x02
144#define HCI_SCODATA_PKT 0x03
145#define HCI_EVENT_PKT 0x04
146#define HCI_VENDOR_PKT 0xff
147
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200148/* HCI packet types */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149#define HCI_DM1 0x0008
150#define HCI_DM3 0x0400
151#define HCI_DM5 0x4000
152#define HCI_DH1 0x0010
153#define HCI_DH3 0x0800
154#define HCI_DH5 0x8000
155
156#define HCI_HV1 0x0020
157#define HCI_HV2 0x0040
158#define HCI_HV3 0x0080
159
160#define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
161#define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
162
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200163/* eSCO packet types */
164#define ESCO_HV1 0x0001
165#define ESCO_HV2 0x0002
166#define ESCO_HV3 0x0004
167#define ESCO_EV3 0x0008
168#define ESCO_EV4 0x0010
169#define ESCO_EV5 0x0020
Marcel Holtmannefc76882009-02-06 09:13:37 +0100170#define ESCO_2EV3 0x0040
171#define ESCO_3EV3 0x0080
172#define ESCO_2EV5 0x0100
173#define ESCO_3EV5 0x0200
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200174
Marcel Holtmanna8746412008-07-14 20:13:46 +0200175#define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
Marcel Holtmannefc76882009-02-06 09:13:37 +0100176#define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
Marcel Holtmanna8746412008-07-14 20:13:46 +0200177
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178/* ACL flags */
Andrei Emeltchenkoe7021122011-01-03 11:14:36 +0200179#define ACL_START_NO_FLUSH 0x00
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180#define ACL_CONT 0x01
181#define ACL_START 0x02
182#define ACL_ACTIVE_BCAST 0x04
183#define ACL_PICO_BCAST 0x08
184
185/* Baseband links */
186#define SCO_LINK 0x00
187#define ACL_LINK 0x01
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200188#define ESCO_LINK 0x02
Ville Tervofcd89c02011-02-10 22:38:47 -0300189/* Low Energy links do not have defined link type. Use invented one */
190#define LE_LINK 0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191
192/* LMP features */
193#define LMP_3SLOT 0x01
194#define LMP_5SLOT 0x02
195#define LMP_ENCRYPT 0x04
196#define LMP_SOFFSET 0x08
197#define LMP_TACCURACY 0x10
198#define LMP_RSWITCH 0x20
199#define LMP_HOLD 0x40
Marcel Holtmann04837f62006-07-03 10:02:33 +0200200#define LMP_SNIFF 0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
202#define LMP_PARK 0x01
203#define LMP_RSSI 0x02
204#define LMP_QUALITY 0x04
205#define LMP_SCO 0x08
206#define LMP_HV2 0x10
207#define LMP_HV3 0x20
208#define LMP_ULAW 0x40
209#define LMP_ALAW 0x80
210
211#define LMP_CVSD 0x01
212#define LMP_PSCHEME 0x02
213#define LMP_PCONTROL 0x04
214
Johan Hedbergd5859e22011-01-25 01:19:58 +0200215#define LMP_RSSI_INQ 0x40
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200216#define LMP_ESCO 0x80
217
218#define LMP_EV4 0x01
219#define LMP_EV5 0x02
Johan Hedberg69ab39e2011-12-15 00:47:35 +0200220#define LMP_NO_BREDR 0x20
Johan Hedbergd5859e22011-01-25 01:19:58 +0200221#define LMP_LE 0x40
Marcel Holtmann5b7f9902007-07-11 09:51:55 +0200222
Marcel Holtmann04837f62006-07-03 10:02:33 +0200223#define LMP_SNIFF_SUBR 0x02
Johan Hedbergd5859e22011-01-25 01:19:58 +0200224#define LMP_PAUSE_ENC 0x04
Marcel Holtmannefc76882009-02-06 09:13:37 +0100225#define LMP_EDR_ESCO_2M 0x20
226#define LMP_EDR_ESCO_3M 0x40
227#define LMP_EDR_3S_ESCO 0x80
Marcel Holtmann04837f62006-07-03 10:02:33 +0200228
Johan Hedbergd5859e22011-01-25 01:19:58 +0200229#define LMP_EXT_INQ 0x01
Andre Guedese6100a22011-06-30 19:20:54 -0300230#define LMP_SIMUL_LE_BR 0x02
Marcel Holtmann769be972008-07-14 20:13:49 +0200231#define LMP_SIMPLE_PAIR 0x08
Andrei Emeltchenkoe7021122011-01-03 11:14:36 +0200232#define LMP_NO_FLUSH 0x40
Marcel Holtmann769be972008-07-14 20:13:49 +0200233
Johan Hedbergd5859e22011-01-25 01:19:58 +0200234#define LMP_LSTO 0x01
235#define LMP_INQ_TX_PWR 0x02
Andre Guedes971e3a42011-06-30 19:20:52 -0300236#define LMP_EXTFEATURES 0x80
Johan Hedbergd5859e22011-01-25 01:19:58 +0200237
Andre Guedeseead27d2011-06-30 19:20:55 -0300238/* Extended LMP features */
239#define LMP_HOST_LE 0x02
240
Marcel Holtmann04837f62006-07-03 10:02:33 +0200241/* Connection modes */
242#define HCI_CM_ACTIVE 0x0000
243#define HCI_CM_HOLD 0x0001
244#define HCI_CM_SNIFF 0x0002
245#define HCI_CM_PARK 0x0003
246
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247/* Link policies */
248#define HCI_LP_RSWITCH 0x0001
249#define HCI_LP_HOLD 0x0002
250#define HCI_LP_SNIFF 0x0004
251#define HCI_LP_PARK 0x0008
252
Marcel Holtmann04837f62006-07-03 10:02:33 +0200253/* Link modes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254#define HCI_LM_ACCEPT 0x8000
255#define HCI_LM_MASTER 0x0001
256#define HCI_LM_AUTH 0x0002
257#define HCI_LM_ENCRYPT 0x0004
258#define HCI_LM_TRUSTED 0x0008
259#define HCI_LM_RELIABLE 0x0010
260#define HCI_LM_SECURE 0x0020
261
Marcel Holtmann40be4922008-07-14 20:13:50 +0200262/* Authentication types */
263#define HCI_AT_NO_BONDING 0x00
264#define HCI_AT_NO_BONDING_MITM 0x01
265#define HCI_AT_DEDICATED_BONDING 0x02
266#define HCI_AT_DEDICATED_BONDING_MITM 0x03
267#define HCI_AT_GENERAL_BONDING 0x04
268#define HCI_AT_GENERAL_BONDING_MITM 0x05
269
Waldemar Rymarkiewiczb6020ba2011-04-28 12:07:53 +0200270/* Link Key types */
271#define HCI_LK_COMBINATION 0x00
272#define HCI_LK_LOCAL_UNIT 0x01
273#define HCI_LK_REMOTE_UNIT 0x02
274#define HCI_LK_DEBUG_COMBINATION 0x03
275#define HCI_LK_UNAUTH_COMBINATION 0x04
276#define HCI_LK_AUTH_COMBINATION 0x05
277#define HCI_LK_CHANGED_COMBINATION 0x06
Vinicius Costa Gomesb899efa2012-02-02 21:08:00 -0300278/* The spec doesn't define types for SMP keys, the _MASTER suffix is implied */
279#define HCI_SMP_STK 0x80
280#define HCI_SMP_STK_SLAVE 0x81
281#define HCI_SMP_LTK 0x82
282#define HCI_SMP_LTK_SLAVE 0x83
Waldemar Rymarkiewiczb6020ba2011-04-28 12:07:53 +0200283
Andrei Emeltchenko9f5a0d72011-11-07 14:20:25 +0200284/* ---- HCI Error Codes ---- */
285#define HCI_ERROR_AUTH_FAILURE 0x05
286#define HCI_ERROR_REJ_BAD_ADDR 0x0f
287#define HCI_ERROR_REMOTE_USER_TERM 0x13
288#define HCI_ERROR_LOCAL_HOST_TERM 0x16
289#define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18
290
Andrei Emeltchenko2455a3e2011-12-19 16:31:28 +0200291/* Flow control modes */
292#define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00
293#define HCI_FLOW_CTL_MODE_BLOCK_BASED 0x01
294
Johan Hedberg32748db2011-12-30 14:57:23 +0200295/* Extended Inquiry Response field types */
296#define EIR_FLAGS 0x01 /* flags */
297#define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */
298#define EIR_UUID16_ALL 0x03 /* 16-bit UUID, all listed */
299#define EIR_UUID32_SOME 0x04 /* 32-bit UUID, more available */
300#define EIR_UUID32_ALL 0x05 /* 32-bit UUID, all listed */
301#define EIR_UUID128_SOME 0x06 /* 128-bit UUID, more available */
302#define EIR_UUID128_ALL 0x07 /* 128-bit UUID, all listed */
303#define EIR_NAME_SHORT 0x08 /* shortened local name */
304#define EIR_NAME_COMPLETE 0x09 /* complete local name */
305#define EIR_TX_POWER 0x0A /* transmit power level */
Johan Hedberg9ec9fc82012-01-15 20:46:33 +0200306#define EIR_CLASS_OF_DEV 0x0D /* Class of Device */
307#define EIR_SSP_HASH_C 0x0E /* Simple Pairing Hash C */
308#define EIR_SSP_RAND_R 0x0F /* Simple Pairing Randomizer R */
Johan Hedberg32748db2011-12-30 14:57:23 +0200309#define EIR_DEVICE_ID 0x10 /* device ID */
310
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311/* ----- HCI Commands ---- */
Ville Tervo6bd32322011-02-16 16:32:41 +0200312#define HCI_OP_NOP 0x0000
313
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200314#define HCI_OP_INQUIRY 0x0401
315struct hci_cp_inquiry {
316 __u8 lap[3];
317 __u8 length;
318 __u8 num_rsp;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300319} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200321#define HCI_OP_INQUIRY_CANCEL 0x0402
322
323#define HCI_OP_EXIT_PERIODIC_INQ 0x0404
324
325#define HCI_OP_CREATE_CONN 0x0405
326struct hci_cp_create_conn {
327 bdaddr_t bdaddr;
328 __le16 pkt_type;
329 __u8 pscan_rep_mode;
330 __u8 pscan_mode;
331 __le16 clock_offset;
332 __u8 role_switch;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300333} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200335#define HCI_OP_DISCONNECT 0x0406
336struct hci_cp_disconnect {
337 __le16 handle;
338 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300339} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200341#define HCI_OP_ADD_SCO 0x0407
342struct hci_cp_add_sco {
343 __le16 handle;
344 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300345} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200346
347#define HCI_OP_CREATE_CONN_CANCEL 0x0408
348struct hci_cp_create_conn_cancel {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300350} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200352#define HCI_OP_ACCEPT_CONN_REQ 0x0409
353struct hci_cp_accept_conn_req {
354 bdaddr_t bdaddr;
355 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300356} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200358#define HCI_OP_REJECT_CONN_REQ 0x040a
359struct hci_cp_reject_conn_req {
360 bdaddr_t bdaddr;
361 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300362} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200364#define HCI_OP_LINK_KEY_REPLY 0x040b
365struct hci_cp_link_key_reply {
366 bdaddr_t bdaddr;
367 __u8 link_key[16];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300368} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200370#define HCI_OP_LINK_KEY_NEG_REPLY 0x040c
371struct hci_cp_link_key_neg_reply {
372 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300373} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200375#define HCI_OP_PIN_CODE_REPLY 0x040d
376struct hci_cp_pin_code_reply {
377 bdaddr_t bdaddr;
378 __u8 pin_len;
379 __u8 pin_code[16];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300380} __packed;
Johan Hedberg980e1a52011-01-22 06:10:07 +0200381struct hci_rp_pin_code_reply {
382 __u8 status;
383 bdaddr_t bdaddr;
384} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200385
386#define HCI_OP_PIN_CODE_NEG_REPLY 0x040e
387struct hci_cp_pin_code_neg_reply {
388 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300389} __packed;
Johan Hedberg980e1a52011-01-22 06:10:07 +0200390struct hci_rp_pin_code_neg_reply {
391 __u8 status;
392 bdaddr_t bdaddr;
393} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200394
395#define HCI_OP_CHANGE_CONN_PTYPE 0x040f
396struct hci_cp_change_conn_ptype {
397 __le16 handle;
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_AUTH_REQUESTED 0x0411
402struct hci_cp_auth_requested {
403 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300404} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200405
406#define HCI_OP_SET_CONN_ENCRYPT 0x0413
407struct hci_cp_set_conn_encrypt {
408 __le16 handle;
409 __u8 encrypt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300410} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200411
412#define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415
413struct hci_cp_change_conn_link_key {
414 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300415} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200416
417#define HCI_OP_REMOTE_NAME_REQ 0x0419
418struct hci_cp_remote_name_req {
419 bdaddr_t bdaddr;
420 __u8 pscan_rep_mode;
421 __u8 pscan_mode;
422 __le16 clock_offset;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300423} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200424
425#define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a
426struct hci_cp_remote_name_req_cancel {
427 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300428} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200429
430#define HCI_OP_READ_REMOTE_FEATURES 0x041b
431struct hci_cp_read_remote_features {
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_READ_REMOTE_EXT_FEATURES 0x041c
436struct hci_cp_read_remote_ext_features {
437 __le16 handle;
438 __u8 page;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300439} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200440
441#define HCI_OP_READ_REMOTE_VERSION 0x041d
442struct hci_cp_read_remote_version {
443 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300444} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200445
446#define HCI_OP_SETUP_SYNC_CONN 0x0428
447struct hci_cp_setup_sync_conn {
448 __le16 handle;
449 __le32 tx_bandwidth;
450 __le32 rx_bandwidth;
451 __le16 max_latency;
452 __le16 voice_setting;
453 __u8 retrans_effort;
454 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300455} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200456
457#define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429
458struct hci_cp_accept_sync_conn_req {
459 bdaddr_t bdaddr;
460 __le32 tx_bandwidth;
461 __le32 rx_bandwidth;
462 __le16 max_latency;
463 __le16 content_format;
464 __u8 retrans_effort;
465 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300466} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200467
468#define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a
469struct hci_cp_reject_sync_conn_req {
470 bdaddr_t bdaddr;
471 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300472} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200473
Johan Hedberg17fa4b92011-01-25 13:28:33 +0200474#define HCI_OP_IO_CAPABILITY_REPLY 0x042b
475struct hci_cp_io_capability_reply {
476 bdaddr_t bdaddr;
477 __u8 capability;
478 __u8 oob_data;
479 __u8 authentication;
480} __packed;
481
Johan Hedberga5c29682011-02-19 12:05:57 -0300482#define HCI_OP_USER_CONFIRM_REPLY 0x042c
483struct hci_cp_user_confirm_reply {
484 bdaddr_t bdaddr;
485} __packed;
486struct hci_rp_user_confirm_reply {
487 __u8 status;
488 bdaddr_t bdaddr;
489} __packed;
490
491#define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d
492
Brian Gix9ad40192011-11-12 22:01:11 -0800493#define HCI_OP_USER_PASSKEY_REPLY 0x042e
494struct hci_cp_user_passkey_reply {
495 bdaddr_t bdaddr;
496 __le32 passkey;
497} __packed;
498
499#define HCI_OP_USER_PASSKEY_NEG_REPLY 0x042f
500
Szymon Janc2763eda2011-03-22 13:12:22 +0100501#define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430
502struct hci_cp_remote_oob_data_reply {
503 bdaddr_t bdaddr;
504 __u8 hash[16];
505 __u8 randomizer[16];
506} __packed;
507
508#define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY 0x0433
509struct hci_cp_remote_oob_data_neg_reply {
510 bdaddr_t bdaddr;
511} __packed;
512
Johan Hedberg03b555e2011-01-04 15:40:05 +0200513#define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
514struct hci_cp_io_capability_neg_reply {
515 bdaddr_t bdaddr;
516 __u8 reason;
517} __packed;
518
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200519#define HCI_OP_SNIFF_MODE 0x0803
520struct hci_cp_sniff_mode {
521 __le16 handle;
522 __le16 max_interval;
523 __le16 min_interval;
524 __le16 attempt;
525 __le16 timeout;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300526} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200527
528#define HCI_OP_EXIT_SNIFF_MODE 0x0804
529struct hci_cp_exit_sniff_mode {
530 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300531} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200532
533#define HCI_OP_ROLE_DISCOVERY 0x0809
534struct hci_cp_role_discovery {
535 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300536} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200537struct hci_rp_role_discovery {
538 __u8 status;
539 __le16 handle;
540 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300541} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200542
543#define HCI_OP_SWITCH_ROLE 0x080b
544struct hci_cp_switch_role {
545 bdaddr_t bdaddr;
546 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300547} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200548
549#define HCI_OP_READ_LINK_POLICY 0x080c
550struct hci_cp_read_link_policy {
551 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300552} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200553struct hci_rp_read_link_policy {
554 __u8 status;
555 __le16 handle;
556 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300557} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200558
559#define HCI_OP_WRITE_LINK_POLICY 0x080d
560struct hci_cp_write_link_policy {
561 __le16 handle;
562 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300563} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200564struct hci_rp_write_link_policy {
565 __u8 status;
566 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300567} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200568
Marcel Holtmanne4e8e372008-07-14 20:13:47 +0200569#define HCI_OP_READ_DEF_LINK_POLICY 0x080e
570struct hci_rp_read_def_link_policy {
571 __u8 status;
572 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300573} __packed;
Marcel Holtmanne4e8e372008-07-14 20:13:47 +0200574
575#define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f
576struct hci_cp_write_def_link_policy {
577 __le16 policy;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300578} __packed;
Marcel Holtmanne4e8e372008-07-14 20:13:47 +0200579
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200580#define HCI_OP_SNIFF_SUBRATE 0x0811
581struct hci_cp_sniff_subrate {
582 __le16 handle;
583 __le16 max_latency;
584 __le16 min_remote_timeout;
585 __le16 min_local_timeout;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300586} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200587
588#define HCI_OP_SET_EVENT_MASK 0x0c01
589struct hci_cp_set_event_mask {
590 __u8 mask[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300591} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200592
593#define HCI_OP_RESET 0x0c03
594
595#define HCI_OP_SET_EVENT_FLT 0x0c05
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596struct hci_cp_set_event_flt {
597 __u8 flt_type;
598 __u8 cond_type;
599 __u8 condition[0];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300600} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601
602/* Filter types */
603#define HCI_FLT_CLEAR_ALL 0x00
604#define HCI_FLT_INQ_RESULT 0x01
605#define HCI_FLT_CONN_SETUP 0x02
606
607/* CONN_SETUP Condition types */
608#define HCI_CONN_SETUP_ALLOW_ALL 0x00
609#define HCI_CONN_SETUP_ALLOW_CLASS 0x01
610#define HCI_CONN_SETUP_ALLOW_BDADDR 0x02
611
612/* CONN_SETUP Conditions */
613#define HCI_CONN_SETUP_AUTO_OFF 0x01
614#define HCI_CONN_SETUP_AUTO_ON 0x02
615
Johan Hedbergb0916ea2011-01-10 13:44:55 +0200616#define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
617struct hci_cp_delete_stored_link_key {
618 bdaddr_t bdaddr;
619 __u8 delete_all;
620} __packed;
621
Johan Hedberg1f6c6372011-03-16 14:29:35 +0200622#define HCI_MAX_NAME_LENGTH 248
623
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200624#define HCI_OP_WRITE_LOCAL_NAME 0x0c13
625struct hci_cp_write_local_name {
Johan Hedberg1f6c6372011-03-16 14:29:35 +0200626 __u8 name[HCI_MAX_NAME_LENGTH];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300627} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200628
629#define HCI_OP_READ_LOCAL_NAME 0x0c14
630struct hci_rp_read_local_name {
631 __u8 status;
Johan Hedberg1f6c6372011-03-16 14:29:35 +0200632 __u8 name[HCI_MAX_NAME_LENGTH];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300633} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200634
635#define HCI_OP_WRITE_CA_TIMEOUT 0x0c16
636
637#define HCI_OP_WRITE_PG_TIMEOUT 0x0c18
638
Andrei Emeltchenko70f230202010-12-01 16:58:25 +0200639#define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200640 #define SCAN_DISABLED 0x00
641 #define SCAN_INQUIRY 0x01
642 #define SCAN_PAGE 0x02
643
644#define HCI_OP_READ_AUTH_ENABLE 0x0c1f
645
646#define HCI_OP_WRITE_AUTH_ENABLE 0x0c20
647 #define AUTH_DISABLED 0x00
648 #define AUTH_ENABLED 0x01
649
650#define HCI_OP_READ_ENCRYPT_MODE 0x0c21
651
652#define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22
653 #define ENCRYPT_DISABLED 0x00
654 #define ENCRYPT_P2P 0x01
655 #define ENCRYPT_BOTH 0x02
656
657#define HCI_OP_READ_CLASS_OF_DEV 0x0c23
658struct hci_rp_read_class_of_dev {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 __u8 status;
660 __u8 dev_class[3];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300661} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200663#define HCI_OP_WRITE_CLASS_OF_DEV 0x0c24
664struct hci_cp_write_class_of_dev {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 __u8 dev_class[3];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300666} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200668#define HCI_OP_READ_VOICE_SETTING 0x0c25
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669struct hci_rp_read_voice_setting {
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800670 __u8 status;
671 __le16 voice_setting;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300672} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200674#define HCI_OP_WRITE_VOICE_SETTING 0x0c26
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675struct hci_cp_write_voice_setting {
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800676 __le16 voice_setting;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300677} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200679#define HCI_OP_HOST_BUFFER_SIZE 0x0c33
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680struct hci_cp_host_buffer_size {
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800681 __le16 acl_mtu;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 __u8 sco_mtu;
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800683 __le16 acl_max_pkt;
684 __le16 sco_max_pkt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300685} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686
Johan Hedbergd5859e22011-01-25 01:19:58 +0200687#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
688
Johan Hedberg80a1e1d2011-03-28 14:07:23 +0300689#define HCI_MAX_EIR_LENGTH 240
690
691#define HCI_OP_WRITE_EIR 0x0c52
692struct hci_cp_write_eir {
693 uint8_t fec;
694 uint8_t data[HCI_MAX_EIR_LENGTH];
695} __packed;
696
Marcel Holtmann333140b2008-07-14 20:13:48 +0200697#define HCI_OP_READ_SSP_MODE 0x0c55
698struct hci_rp_read_ssp_mode {
699 __u8 status;
700 __u8 mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300701} __packed;
Marcel Holtmann333140b2008-07-14 20:13:48 +0200702
703#define HCI_OP_WRITE_SSP_MODE 0x0c56
704struct hci_cp_write_ssp_mode {
705 __u8 mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300706} __packed;
Marcel Holtmann333140b2008-07-14 20:13:48 +0200707
Szymon Jancc35938b2011-03-22 13:12:21 +0100708#define HCI_OP_READ_LOCAL_OOB_DATA 0x0c57
709struct hci_rp_read_local_oob_data {
710 __u8 status;
711 __u8 hash[16];
712 __u8 randomizer[16];
713} __packed;
714
Johan Hedbergd5859e22011-01-25 01:19:58 +0200715#define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
716
Andrei Emeltchenko1e89cff2011-11-24 14:52:02 +0200717#define HCI_OP_READ_FLOW_CONTROL_MODE 0x0c66
718struct hci_rp_read_flow_control_mode {
719 __u8 status;
720 __u8 mode;
721} __packed;
722
Andre Guedesf9b49302011-06-30 19:20:53 -0300723#define HCI_OP_WRITE_LE_HOST_SUPPORTED 0x0c6d
724struct hci_cp_write_le_host_supported {
725 __u8 le;
726 __u8 simul;
727} __packed;
728
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200729#define HCI_OP_READ_LOCAL_VERSION 0x1001
730struct hci_rp_read_local_version {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 __u8 status;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200732 __u8 hci_ver;
733 __le16 hci_rev;
734 __u8 lmp_ver;
735 __le16 manufacturer;
736 __le16 lmp_subver;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300737} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200739#define HCI_OP_READ_LOCAL_COMMANDS 0x1002
740struct hci_rp_read_local_commands {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 __u8 status;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200742 __u8 commands[64];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300743} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200745#define HCI_OP_READ_LOCAL_FEATURES 0x1003
746struct hci_rp_read_local_features {
747 __u8 status;
748 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300749} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200750
751#define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004
Andre Guedes971e3a42011-06-30 19:20:52 -0300752struct hci_cp_read_local_ext_features {
753 __u8 page;
754} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200755struct hci_rp_read_local_ext_features {
756 __u8 status;
757 __u8 page;
758 __u8 max_page;
759 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300760} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200761
762#define HCI_OP_READ_BUFFER_SIZE 0x1005
763struct hci_rp_read_buffer_size {
764 __u8 status;
765 __le16 acl_mtu;
766 __u8 sco_mtu;
767 __le16 acl_max_pkt;
768 __le16 sco_max_pkt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300769} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200770
771#define HCI_OP_READ_BD_ADDR 0x1009
772struct hci_rp_read_bd_addr {
773 __u8 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300775} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776
Andrei Emeltchenko350ee4c2011-12-07 15:56:51 +0200777#define HCI_OP_READ_DATA_BLOCK_SIZE 0x100a
778struct hci_rp_read_data_block_size {
779 __u8 status;
780 __le16 max_acl_len;
781 __le16 block_len;
782 __le16 num_blocks;
783} __packed;
784
Antti Julkuf6422ec2011-06-22 13:11:56 +0300785#define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c
786struct hci_cp_write_page_scan_activity {
787 __le16 interval;
788 __le16 window;
789} __packed;
790
791#define HCI_OP_WRITE_PAGE_SCAN_TYPE 0x0c47
792 #define PAGE_SCAN_TYPE_STANDARD 0x00
793 #define PAGE_SCAN_TYPE_INTERLACED 0x01
794
Andrei Emeltchenko928abaa2011-10-12 10:53:57 +0300795#define HCI_OP_READ_LOCAL_AMP_INFO 0x1409
796struct hci_rp_read_local_amp_info {
797 __u8 status;
798 __u8 amp_status;
799 __le32 total_bw;
800 __le32 max_bw;
801 __le32 min_latency;
802 __le32 max_pdu;
803 __u8 amp_type;
804 __le16 pal_cap;
805 __le16 max_assoc_size;
806 __le32 max_flush_to;
807 __le32 be_flush_to;
808} __packed;
809
Ville Tervo63185f62011-02-10 22:38:46 -0300810#define HCI_OP_LE_SET_EVENT_MASK 0x2001
811struct hci_cp_le_set_event_mask {
812 __u8 mask[8];
813} __packed;
814
815#define HCI_OP_LE_READ_BUFFER_SIZE 0x2002
816struct hci_rp_le_read_buffer_size {
817 __u8 status;
818 __le16 le_mtu;
819 __u8 le_max_pkt;
820} __packed;
821
Andre Guedes07f7fa52011-12-02 21:13:31 +0900822#define HCI_OP_LE_SET_SCAN_PARAM 0x200b
823struct hci_cp_le_set_scan_param {
824 __u8 type;
825 __le16 interval;
826 __le16 window;
827 __u8 own_address_type;
828 __u8 filter_policy;
829} __packed;
830
Andrei Emeltchenko68a8aea2011-12-19 16:14:18 +0200831#define LE_SCANNING_DISABLED 0x00
832#define LE_SCANNING_ENABLED 0x01
833
Andre Guedeseb9d91f2011-05-26 16:23:52 -0300834#define HCI_OP_LE_SET_SCAN_ENABLE 0x200c
835struct hci_cp_le_set_scan_enable {
836 __u8 enable;
837 __u8 filter_dup;
838} __packed;
839
Ville Tervo63185f62011-02-10 22:38:46 -0300840#define HCI_OP_LE_CREATE_CONN 0x200d
841struct hci_cp_le_create_conn {
842 __le16 scan_interval;
843 __le16 scan_window;
844 __u8 filter_policy;
845 __u8 peer_addr_type;
846 bdaddr_t peer_addr;
847 __u8 own_address_type;
848 __le16 conn_interval_min;
849 __le16 conn_interval_max;
850 __le16 conn_latency;
851 __le16 supervision_timeout;
852 __le16 min_ce_len;
853 __le16 max_ce_len;
854} __packed;
855
856#define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e
857
Claudio Takahasi2ce603e2011-02-16 20:44:53 -0200858#define HCI_OP_LE_CONN_UPDATE 0x2013
859struct hci_cp_le_conn_update {
860 __le16 handle;
861 __le16 conn_interval_min;
862 __le16 conn_interval_max;
863 __le16 conn_latency;
864 __le16 supervision_timeout;
865 __le16 min_ce_len;
866 __le16 max_ce_len;
867} __packed;
868
Vinicius Costa Gomesa7a595f2011-06-09 18:50:47 -0300869#define HCI_OP_LE_START_ENC 0x2019
870struct hci_cp_le_start_enc {
871 __le16 handle;
872 __u8 rand[8];
873 __le16 ediv;
874 __u8 ltk[16];
875} __packed;
876
877#define HCI_OP_LE_LTK_REPLY 0x201a
878struct hci_cp_le_ltk_reply {
879 __le16 handle;
880 __u8 ltk[16];
881} __packed;
882struct hci_rp_le_ltk_reply {
883 __u8 status;
884 __le16 handle;
885} __packed;
886
887#define HCI_OP_LE_LTK_NEG_REPLY 0x201b
888struct hci_cp_le_ltk_neg_reply {
889 __le16 handle;
890} __packed;
891struct hci_rp_le_ltk_neg_reply {
892 __u8 status;
893 __le16 handle;
894} __packed;
895
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896/* ---- HCI Events ---- */
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200897#define HCI_EV_INQUIRY_COMPLETE 0x01
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200899#define HCI_EV_INQUIRY_RESULT 0x02
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900struct inquiry_info {
901 bdaddr_t bdaddr;
902 __u8 pscan_rep_mode;
903 __u8 pscan_period_mode;
904 __u8 pscan_mode;
905 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -0800906 __le16 clock_offset;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300907} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200909#define HCI_EV_CONN_COMPLETE 0x03
910struct hci_ev_conn_complete {
911 __u8 status;
912 __le16 handle;
913 bdaddr_t bdaddr;
914 __u8 link_type;
915 __u8 encr_mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300916} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200917
918#define HCI_EV_CONN_REQUEST 0x04
919struct hci_ev_conn_request {
920 bdaddr_t bdaddr;
921 __u8 dev_class[3];
922 __u8 link_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300923} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200924
925#define HCI_EV_DISCONN_COMPLETE 0x05
926struct hci_ev_disconn_complete {
927 __u8 status;
928 __le16 handle;
929 __u8 reason;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300930} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200931
932#define HCI_EV_AUTH_COMPLETE 0x06
933struct hci_ev_auth_complete {
934 __u8 status;
935 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300936} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200937
938#define HCI_EV_REMOTE_NAME 0x07
939struct hci_ev_remote_name {
940 __u8 status;
941 bdaddr_t bdaddr;
Johan Hedberg1f6c6372011-03-16 14:29:35 +0200942 __u8 name[HCI_MAX_NAME_LENGTH];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300943} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200944
945#define HCI_EV_ENCRYPT_CHANGE 0x08
946struct hci_ev_encrypt_change {
947 __u8 status;
948 __le16 handle;
949 __u8 encrypt;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300950} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200951
952#define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09
953struct hci_ev_change_link_key_complete {
954 __u8 status;
955 __le16 handle;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300956} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200957
958#define HCI_EV_REMOTE_FEATURES 0x0b
959struct hci_ev_remote_features {
960 __u8 status;
961 __le16 handle;
962 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300963} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200964
965#define HCI_EV_REMOTE_VERSION 0x0c
966struct hci_ev_remote_version {
967 __u8 status;
968 __le16 handle;
969 __u8 lmp_ver;
970 __le16 manufacturer;
971 __le16 lmp_subver;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300972} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200973
974#define HCI_EV_QOS_SETUP_COMPLETE 0x0d
975struct hci_qos {
976 __u8 service_type;
977 __u32 token_rate;
978 __u32 peak_bandwidth;
979 __u32 latency;
980 __u32 delay_variation;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300981} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200982struct hci_ev_qos_setup_complete {
983 __u8 status;
984 __le16 handle;
985 struct hci_qos qos;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300986} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200987
988#define HCI_EV_CMD_COMPLETE 0x0e
989struct hci_ev_cmd_complete {
990 __u8 ncmd;
991 __le16 opcode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300992} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +0200993
994#define HCI_EV_CMD_STATUS 0x0f
995struct hci_ev_cmd_status {
996 __u8 status;
997 __u8 ncmd;
998 __le16 opcode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -0300999} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001000
1001#define HCI_EV_ROLE_CHANGE 0x12
1002struct hci_ev_role_change {
1003 __u8 status;
1004 bdaddr_t bdaddr;
1005 __u8 role;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001006} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001007
1008#define HCI_EV_NUM_COMP_PKTS 0x13
Andrei Emeltchenko613a1c02011-12-19 16:31:30 +02001009struct hci_comp_pkts_info {
1010 __le16 handle;
1011 __le16 count;
1012} __packed;
1013
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001014struct hci_ev_num_comp_pkts {
1015 __u8 num_hndl;
Andrei Emeltchenko613a1c02011-12-19 16:31:30 +02001016 struct hci_comp_pkts_info handles[0];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001017} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001018
1019#define HCI_EV_MODE_CHANGE 0x14
1020struct hci_ev_mode_change {
1021 __u8 status;
1022 __le16 handle;
1023 __u8 mode;
1024 __le16 interval;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001025} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001026
1027#define HCI_EV_PIN_CODE_REQ 0x16
1028struct hci_ev_pin_code_req {
1029 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001030} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001031
1032#define HCI_EV_LINK_KEY_REQ 0x17
1033struct hci_ev_link_key_req {
1034 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001035} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001036
1037#define HCI_EV_LINK_KEY_NOTIFY 0x18
1038struct hci_ev_link_key_notify {
1039 bdaddr_t bdaddr;
1040 __u8 link_key[16];
1041 __u8 key_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001042} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001043
1044#define HCI_EV_CLOCK_OFFSET 0x1c
1045struct hci_ev_clock_offset {
1046 __u8 status;
1047 __le16 handle;
1048 __le16 clock_offset;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001049} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001050
Marcel Holtmanna8746412008-07-14 20:13:46 +02001051#define HCI_EV_PKT_TYPE_CHANGE 0x1d
1052struct hci_ev_pkt_type_change {
1053 __u8 status;
1054 __le16 handle;
1055 __le16 pkt_type;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001056} __packed;
Marcel Holtmanna8746412008-07-14 20:13:46 +02001057
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001058#define HCI_EV_PSCAN_REP_MODE 0x20
1059struct hci_ev_pscan_rep_mode {
1060 bdaddr_t bdaddr;
1061 __u8 pscan_rep_mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001062} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001063
Linus Torvalds1da177e2005-04-16 15:20:36 -07001064#define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
1065struct inquiry_info_with_rssi {
1066 bdaddr_t bdaddr;
1067 __u8 pscan_rep_mode;
1068 __u8 pscan_period_mode;
1069 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -08001070 __le16 clock_offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071 __s8 rssi;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001072} __packed;
Marcel Holtmann45bb4bf2005-08-09 20:27:49 -07001073struct inquiry_info_with_rssi_and_pscan_mode {
1074 bdaddr_t bdaddr;
1075 __u8 pscan_rep_mode;
1076 __u8 pscan_period_mode;
1077 __u8 pscan_mode;
1078 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -08001079 __le16 clock_offset;
Marcel Holtmann45bb4bf2005-08-09 20:27:49 -07001080 __s8 rssi;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001081} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001083#define HCI_EV_REMOTE_EXT_FEATURES 0x23
1084struct hci_ev_remote_ext_features {
1085 __u8 status;
1086 __le16 handle;
1087 __u8 page;
1088 __u8 max_page;
1089 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001090} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001091
1092#define HCI_EV_SYNC_CONN_COMPLETE 0x2c
1093struct hci_ev_sync_conn_complete {
1094 __u8 status;
1095 __le16 handle;
1096 bdaddr_t bdaddr;
1097 __u8 link_type;
1098 __u8 tx_interval;
1099 __u8 retrans_window;
1100 __le16 rx_pkt_len;
1101 __le16 tx_pkt_len;
1102 __u8 air_mode;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001103} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001104
1105#define HCI_EV_SYNC_CONN_CHANGED 0x2d
1106struct hci_ev_sync_conn_changed {
1107 __u8 status;
1108 __le16 handle;
1109 __u8 tx_interval;
1110 __u8 retrans_window;
1111 __le16 rx_pkt_len;
1112 __le16 tx_pkt_len;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001113} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001114
1115#define HCI_EV_SNIFF_SUBRATE 0x2e
1116struct hci_ev_sniff_subrate {
1117 __u8 status;
1118 __le16 handle;
1119 __le16 max_tx_latency;
1120 __le16 max_rx_latency;
1121 __le16 max_remote_timeout;
1122 __le16 max_local_timeout;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001123} __packed;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001124
1125#define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f
Marcel Holtmann21d9e302005-09-13 01:32:25 +02001126struct extended_inquiry_info {
1127 bdaddr_t bdaddr;
1128 __u8 pscan_rep_mode;
1129 __u8 pscan_period_mode;
1130 __u8 dev_class[3];
Marcel Holtmann1ebb9252005-11-08 09:57:21 -08001131 __le16 clock_offset;
Marcel Holtmann21d9e302005-09-13 01:32:25 +02001132 __s8 rssi;
1133 __u8 data[240];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001134} __packed;
Marcel Holtmann21d9e302005-09-13 01:32:25 +02001135
Marcel Holtmann04936842008-07-14 20:13:48 +02001136#define HCI_EV_IO_CAPA_REQUEST 0x31
1137struct hci_ev_io_capa_request {
1138 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001139} __packed;
Marcel Holtmann04936842008-07-14 20:13:48 +02001140
Johan Hedberg03b555e2011-01-04 15:40:05 +02001141#define HCI_EV_IO_CAPA_REPLY 0x32
1142struct hci_ev_io_capa_reply {
1143 bdaddr_t bdaddr;
1144 __u8 capability;
1145 __u8 oob_data;
1146 __u8 authentication;
1147} __packed;
1148
Johan Hedberga5c29682011-02-19 12:05:57 -03001149#define HCI_EV_USER_CONFIRM_REQUEST 0x33
1150struct hci_ev_user_confirm_req {
1151 bdaddr_t bdaddr;
1152 __le32 passkey;
1153} __packed;
1154
Brian Gix9ad40192011-11-12 22:01:11 -08001155#define HCI_EV_USER_PASSKEY_REQUEST 0x34
1156struct hci_ev_user_passkey_req {
1157 bdaddr_t bdaddr;
1158} __packed;
1159
Szymon Janc2763eda2011-03-22 13:12:22 +01001160#define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35
1161struct hci_ev_remote_oob_data_request {
1162 bdaddr_t bdaddr;
1163} __packed;
1164
Marcel Holtmann04936842008-07-14 20:13:48 +02001165#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
1166struct hci_ev_simple_pair_complete {
1167 __u8 status;
1168 bdaddr_t bdaddr;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001169} __packed;
Marcel Holtmann04936842008-07-14 20:13:48 +02001170
Marcel Holtmann41a96212008-07-14 20:13:48 +02001171#define HCI_EV_REMOTE_HOST_FEATURES 0x3d
1172struct hci_ev_remote_host_features {
1173 bdaddr_t bdaddr;
1174 __u8 features[8];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001175} __packed;
Marcel Holtmann41a96212008-07-14 20:13:48 +02001176
Ville Tervo63185f62011-02-10 22:38:46 -03001177#define HCI_EV_LE_META 0x3e
1178struct hci_ev_le_meta {
1179 __u8 subevent;
1180} __packed;
1181
Andrei Emeltchenko25e89e92012-01-04 12:41:58 +02001182#define HCI_EV_NUM_COMP_BLOCKS 0x48
1183struct hci_comp_blocks_info {
1184 __le16 handle;
1185 __le16 pkts;
1186 __le16 blocks;
1187} __packed;
1188
1189struct hci_ev_num_comp_blocks {
1190 __le16 num_blocks;
1191 __u8 num_hndl;
1192 struct hci_comp_blocks_info handles[0];
1193} __packed;
1194
Ville Tervo63185f62011-02-10 22:38:46 -03001195/* Low energy meta events */
1196#define HCI_EV_LE_CONN_COMPLETE 0x01
1197struct hci_ev_le_conn_complete {
1198 __u8 status;
1199 __le16 handle;
1200 __u8 role;
1201 __u8 bdaddr_type;
1202 bdaddr_t bdaddr;
1203 __le16 interval;
1204 __le16 latency;
1205 __le16 supervision_timeout;
1206 __u8 clk_accurancy;
1207} __packed;
1208
Vinicius Costa Gomesa7a595f2011-06-09 18:50:47 -03001209#define HCI_EV_LE_LTK_REQ 0x05
1210struct hci_ev_le_ltk_req {
1211 __le16 handle;
1212 __u8 random[8];
1213 __le16 ediv;
1214} __packed;
1215
Anderson Briglia57a56fd2011-05-26 16:23:49 -03001216/* Advertising report event types */
1217#define ADV_IND 0x00
1218#define ADV_DIRECT_IND 0x01
1219#define ADV_SCAN_IND 0x02
1220#define ADV_NONCONN_IND 0x03
1221#define ADV_SCAN_RSP 0x04
1222
1223#define ADDR_LE_DEV_PUBLIC 0x00
1224#define ADDR_LE_DEV_RANDOM 0x01
1225
1226#define HCI_EV_LE_ADVERTISING_REPORT 0x02
1227struct hci_ev_le_advertising_info {
1228 __u8 evt_type;
1229 __u8 bdaddr_type;
1230 bdaddr_t bdaddr;
1231 __u8 length;
1232 __u8 data[0];
1233} __packed;
1234
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235/* Internal events generated by Bluetooth stack */
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001236#define HCI_EV_STACK_INTERNAL 0xfd
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237struct hci_ev_stack_internal {
1238 __u16 type;
1239 __u8 data[0];
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001240} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001242#define HCI_EV_SI_DEVICE 0x01
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243struct hci_ev_si_device {
1244 __u16 event;
1245 __u16 dev_id;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001246} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001247
1248#define HCI_EV_SI_SECURITY 0x02
1249struct hci_ev_si_security {
1250 __u16 event;
1251 __u16 proto;
1252 __u16 subproto;
1253 __u8 incoming;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001254} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255
1256/* ---- HCI Packet structures ---- */
1257#define HCI_COMMAND_HDR_SIZE 3
1258#define HCI_EVENT_HDR_SIZE 2
1259#define HCI_ACL_HDR_SIZE 4
1260#define HCI_SCO_HDR_SIZE 3
1261
1262struct hci_command_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001263 __le16 opcode; /* OCF & OGF */
Andrei Emeltchenko70f230202010-12-01 16:58:25 +02001264 __u8 plen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001265} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001266
1267struct hci_event_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001268 __u8 evt;
1269 __u8 plen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001270} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271
1272struct hci_acl_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001273 __le16 handle; /* Handle & Flags(PB, BC) */
1274 __le16 dlen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001275} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276
1277struct hci_sco_hdr {
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001278 __le16 handle;
1279 __u8 dlen;
Gustavo F. Padovan66c853c2010-07-19 02:00:13 -03001280} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -03001282#include <linux/skbuff.h>
1283static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
1284{
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001285 return (struct hci_event_hdr *) skb->data;
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -03001286}
1287
1288static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
1289{
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001290 return (struct hci_acl_hdr *) skb->data;
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -03001291}
1292
1293static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
1294{
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001295 return (struct hci_sco_hdr *) skb->data;
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -03001296}
Arnaldo Carvalho de Melo2a123b82007-03-27 18:38:07 -03001297
Linus Torvalds1da177e2005-04-16 15:20:36 -07001298/* Command opcode pack/unpack */
Marcel Holtmann1ebb9252005-11-08 09:57:21 -08001299#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300#define hci_opcode_ogf(op) (op >> 10)
1301#define hci_opcode_ocf(op) (op & 0x03ff)
1302
1303/* ACL handle and flags pack/unpack */
Marcel Holtmann1ebb9252005-11-08 09:57:21 -08001304#define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305#define hci_handle(h) (h & 0x0fff)
1306#define hci_flags(h) (h >> 12)
1307
1308/* ---- HCI Sockets ---- */
1309
1310/* Socket options */
1311#define HCI_DATA_DIR 1
1312#define HCI_FILTER 2
1313#define HCI_TIME_STAMP 3
1314
1315/* CMSG flags */
1316#define HCI_CMSG_DIR 0x0001
1317#define HCI_CMSG_TSTAMP 0x0002
1318
1319struct sockaddr_hci {
1320 sa_family_t hci_family;
1321 unsigned short hci_dev;
Johan Hedbergc02178d2010-12-08 00:21:05 +02001322 unsigned short hci_channel;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323};
1324#define HCI_DEV_NONE 0xffff
1325
Johan Hedbergc02178d2010-12-08 00:21:05 +02001326#define HCI_CHANNEL_RAW 0
1327#define HCI_CHANNEL_CONTROL 1
Marcel Holtmanncd82e612012-02-20 20:34:38 +01001328#define HCI_CHANNEL_MONITOR 2
Johan Hedbergc02178d2010-12-08 00:21:05 +02001329
Linus Torvalds1da177e2005-04-16 15:20:36 -07001330struct hci_filter {
1331 unsigned long type_mask;
1332 unsigned long event_mask[2];
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001333 __le16 opcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334};
1335
1336struct hci_ufilter {
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001337 __u32 type_mask;
1338 __u32 event_mask[2];
1339 __le16 opcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001340};
1341
1342#define HCI_FLT_TYPE_BITS 31
1343#define HCI_FLT_EVENT_BITS 63
1344#define HCI_FLT_OGF_BITS 63
1345#define HCI_FLT_OCF_BITS 127
1346
1347/* ---- HCI Ioctl requests structures ---- */
1348struct hci_dev_stats {
1349 __u32 err_rx;
1350 __u32 err_tx;
1351 __u32 cmd_tx;
1352 __u32 evt_rx;
1353 __u32 acl_tx;
1354 __u32 acl_rx;
1355 __u32 sco_tx;
1356 __u32 sco_rx;
1357 __u32 byte_rx;
1358 __u32 byte_tx;
1359};
1360
1361struct hci_dev_info {
1362 __u16 dev_id;
1363 char name[8];
1364
1365 bdaddr_t bdaddr;
1366
1367 __u32 flags;
1368 __u8 type;
1369
1370 __u8 features[8];
1371
1372 __u32 pkt_type;
1373 __u32 link_policy;
1374 __u32 link_mode;
1375
1376 __u16 acl_mtu;
1377 __u16 acl_pkts;
1378 __u16 sco_mtu;
1379 __u16 sco_pkts;
1380
1381 struct hci_dev_stats stat;
1382};
1383
1384struct hci_conn_info {
1385 __u16 handle;
1386 bdaddr_t bdaddr;
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001387 __u8 type;
1388 __u8 out;
1389 __u16 state;
1390 __u32 link_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391};
1392
1393struct hci_dev_req {
Marcel Holtmanna9de9242007-10-20 13:33:56 +02001394 __u16 dev_id;
1395 __u32 dev_opt;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396};
1397
1398struct hci_dev_list_req {
1399 __u16 dev_num;
1400 struct hci_dev_req dev_req[0]; /* hci_dev_req structures */
1401};
1402
1403struct hci_conn_list_req {
1404 __u16 dev_id;
1405 __u16 conn_num;
1406 struct hci_conn_info conn_info[0];
1407};
1408
1409struct hci_conn_info_req {
1410 bdaddr_t bdaddr;
1411 __u8 type;
1412 struct hci_conn_info conn_info[0];
1413};
1414
Marcel Holtmann40be4922008-07-14 20:13:50 +02001415struct hci_auth_info_req {
1416 bdaddr_t bdaddr;
1417 __u8 type;
1418};
1419
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420struct hci_inquiry_req {
1421 __u16 dev_id;
1422 __u16 flags;
1423 __u8 lap[3];
1424 __u8 length;
1425 __u8 num_rsp;
1426};
1427#define IREQ_CACHE_FLUSH 0x0001
1428
Fabio Estevam8b281b92012-01-10 18:33:50 -02001429extern bool enable_hs;
Marcel Holtmannd7b7e792012-02-20 21:47:49 +01001430extern bool enable_le;
Andrei Emeltchenko8830f512011-11-11 17:02:14 +02001431
Linus Torvalds1da177e2005-04-16 15:20:36 -07001432#endif /* __HCI_H */