]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/net/bluetooth/hci.h
Bluetooth: Track Secure Connections support of remote devices
[mirror_ubuntu-bionic-kernel.git] / include / net / bluetooth / hci.h
CommitLineData
be21871f 1/*
1da177e4
LT
2 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
be21871f
AE
15 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
1da177e4
LT
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
be21871f
AE
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
1da177e4
LT
22 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
9b3b4460 33#define HCI_LINK_KEY_SIZE 16
523e93cd 34#define HCI_AMP_LINK_KEY_SIZE (2 * HCI_LINK_KEY_SIZE)
9b3b4460 35
903e4541
AE
36#define HCI_MAX_AMP_ASSOC_SIZE 672
37
7d1dab49
DP
38#define HCI_MAX_CSB_DATA_SIZE 252
39
1da177e4
LT
40/* HCI dev events */
41#define HCI_DEV_REG 1
42#define HCI_DEV_UNREG 2
43#define HCI_DEV_UP 3
44#define HCI_DEV_DOWN 4
45#define HCI_DEV_SUSPEND 5
46#define HCI_DEV_RESUME 6
47
48/* HCI notify events */
49#define HCI_NOTIFY_CONN_ADD 1
50#define HCI_NOTIFY_CONN_DEL 2
51#define HCI_NOTIFY_VOICE_SETTING 3
52
c13854ce 53/* HCI bus types */
0ac53939 54#define HCI_VIRTUAL 0
1da177e4
LT
55#define HCI_USB 1
56#define HCI_PCCARD 2
57#define HCI_UART 3
58#define HCI_RS232 4
59#define HCI_PCI 5
0ac53939 60#define HCI_SDIO 6
1da177e4 61
943da25d
MH
62/* HCI controller types */
63#define HCI_BREDR 0x00
8f1e1742 64#define HCI_AMP 0x01
943da25d 65
8598d064 66/* First BR/EDR Controller shall have ID = 0 */
6ed971ca 67#define AMP_ID_BREDR 0x00
8598d064 68
7c13823d
MH
69/* AMP controller types */
70#define AMP_TYPE_BREDR 0x00
71#define AMP_TYPE_80211 0x01
72
ab846ec4 73/* AMP controller status */
536619e8
MH
74#define AMP_STATUS_POWERED_DOWN 0x00
75#define AMP_STATUS_BLUETOOTH_ONLY 0x01
76#define AMP_STATUS_NO_CAPACITY 0x02
77#define AMP_STATUS_LOW_CAPACITY 0x03
78#define AMP_STATUS_MEDIUM_CAPACITY 0x04
79#define AMP_STATUS_HIGH_CAPACITY 0x05
80#define AMP_STATUS_FULL_CAPACITY 0x06
ab846ec4 81
1da177e4
LT
82/* HCI device quirks */
83enum {
a6c511c6 84 HCI_QUIRK_RESET_ON_CLOSE,
da1f5198 85 HCI_QUIRK_RAW_DEVICE,
f9f462fa
MH
86 HCI_QUIRK_FIXUP_BUFFER_SIZE,
87 HCI_QUIRK_BROKEN_STORED_LINK_KEY,
1da177e4
LT
88};
89
90/* HCI device flags */
91enum {
92 HCI_UP,
93 HCI_INIT,
94 HCI_RUNNING,
95
96 HCI_PSCAN,
97 HCI_ISCAN,
98 HCI_AUTH,
99 HCI_ENCRYPT,
100 HCI_INQUIRY,
101
102 HCI_RAW,
ab81cbf9 103
10572132 104 HCI_RESET,
1da177e4
LT
105};
106
d23264a8
AG
107/*
108 * BR/EDR and/or LE controller flags: the flags defined here should represent
109 * states from the controller.
110 */
111enum {
a8b2d5c2
JH
112 HCI_SETUP,
113 HCI_AUTO_OFF,
5e130367 114 HCI_RFKILLED,
a8b2d5c2
JH
115 HCI_MGMT,
116 HCI_PAIRABLE,
117 HCI_SERVICE_CACHE,
a8b2d5c2 118 HCI_DEBUG_KEYS,
4b4148e9 119 HCI_DUT_MODE,
5afeac14 120 HCI_FORCE_SC,
94324962 121 HCI_UNREGISTER,
0736cfa8 122 HCI_USER_CHANNEL,
a8b2d5c2 123
d23264a8 124 HCI_LE_SCAN,
84bde9d6 125 HCI_SSP_ENABLED,
e98d2ce2 126 HCI_SC_ENABLED,
6d80dfd0 127 HCI_HS_ENABLED,
06199cf8 128 HCI_LE_ENABLED,
f3d3444a 129 HCI_ADVERTISING,
5e5282bb
JH
130 HCI_CONNECTABLE,
131 HCI_DISCOVERABLE,
6acd7db4 132 HCI_LIMITED_DISCOVERABLE,
47990ea0 133 HCI_LINK_SECURITY,
21693c15 134 HCI_PERIODIC_INQ,
1a4d3c4b 135 HCI_FAST_CONNECTABLE,
56f87901 136 HCI_BREDR_ENABLED,
18722c24 137 HCI_6LOWPAN_ENABLED,
d23264a8
AG
138};
139
2cc6fb00
JH
140/* A mask for the flags that are supposed to remain when a reset happens
141 * or the HCI device is closed.
142 */
1a4d3c4b
JH
143#define HCI_PERSISTENT_MASK (BIT(HCI_LE_SCAN) | BIT(HCI_PERIODIC_INQ) | \
144 BIT(HCI_FAST_CONNECTABLE))
2cc6fb00 145
1da177e4
LT
146/* HCI ioctl defines */
147#define HCIDEVUP _IOW('H', 201, int)
148#define HCIDEVDOWN _IOW('H', 202, int)
149#define HCIDEVRESET _IOW('H', 203, int)
150#define HCIDEVRESTAT _IOW('H', 204, int)
151
152#define HCIGETDEVLIST _IOR('H', 210, int)
153#define HCIGETDEVINFO _IOR('H', 211, int)
154#define HCIGETCONNLIST _IOR('H', 212, int)
155#define HCIGETCONNINFO _IOR('H', 213, int)
40be492f 156#define HCIGETAUTHINFO _IOR('H', 215, int)
1da177e4
LT
157
158#define HCISETRAW _IOW('H', 220, int)
159#define HCISETSCAN _IOW('H', 221, int)
160#define HCISETAUTH _IOW('H', 222, int)
161#define HCISETENCRYPT _IOW('H', 223, int)
162#define HCISETPTYPE _IOW('H', 224, int)
163#define HCISETLINKPOL _IOW('H', 225, int)
164#define HCISETLINKMODE _IOW('H', 226, int)
165#define HCISETACLMTU _IOW('H', 227, int)
166#define HCISETSCOMTU _IOW('H', 228, int)
167
f0358568
JH
168#define HCIBLOCKADDR _IOW('H', 230, int)
169#define HCIUNBLOCKADDR _IOW('H', 231, int)
170
1da177e4
LT
171#define HCIINQUIRY _IOR('H', 240, int)
172
173/* HCI timeouts */
5f246e89
AE
174#define HCI_DISCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
175#define HCI_PAIRING_TIMEOUT msecs_to_jiffies(60000) /* 60 seconds */
176#define HCI_INIT_TIMEOUT msecs_to_jiffies(10000) /* 10 seconds */
d1244adc 177#define HCI_CMD_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
5f246e89 178#define HCI_ACL_TX_TIMEOUT msecs_to_jiffies(45000) /* 45 seconds */
9345d40c 179#define HCI_AUTO_OFF_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
1da177e4 180
5b7f9909 181/* HCI data types */
1da177e4
LT
182#define HCI_COMMAND_PKT 0x01
183#define HCI_ACLDATA_PKT 0x02
184#define HCI_SCODATA_PKT 0x03
185#define HCI_EVENT_PKT 0x04
186#define HCI_VENDOR_PKT 0xff
187
5b7f9909 188/* HCI packet types */
1da177e4
LT
189#define HCI_DM1 0x0008
190#define HCI_DM3 0x0400
191#define HCI_DM5 0x4000
192#define HCI_DH1 0x0010
193#define HCI_DH3 0x0800
194#define HCI_DH5 0x8000
195
196#define HCI_HV1 0x0020
197#define HCI_HV2 0x0040
198#define HCI_HV3 0x0080
199
200#define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
201#define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
202
5b7f9909
MH
203/* eSCO packet types */
204#define ESCO_HV1 0x0001
205#define ESCO_HV2 0x0002
206#define ESCO_HV3 0x0004
207#define ESCO_EV3 0x0008
208#define ESCO_EV4 0x0010
209#define ESCO_EV5 0x0020
efc7688b
MH
210#define ESCO_2EV3 0x0040
211#define ESCO_3EV3 0x0080
212#define ESCO_2EV5 0x0100
213#define ESCO_3EV5 0x0200
5b7f9909 214
a8746417 215#define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
efc7688b 216#define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
a8746417 217
1da177e4 218/* ACL flags */
e702112f 219#define ACL_START_NO_FLUSH 0x00
1da177e4
LT
220#define ACL_CONT 0x01
221#define ACL_START 0x02
d73a0988 222#define ACL_COMPLETE 0x03
1da177e4
LT
223#define ACL_ACTIVE_BCAST 0x04
224#define ACL_PICO_BCAST 0x08
225
226/* Baseband links */
227#define SCO_LINK 0x00
228#define ACL_LINK 0x01
5b7f9909 229#define ESCO_LINK 0x02
fcd89c09
VT
230/* Low Energy links do not have defined link type. Use invented one */
231#define LE_LINK 0x80
3161ae1c 232#define AMP_LINK 0x81
1da177e4
LT
233
234/* LMP features */
235#define LMP_3SLOT 0x01
236#define LMP_5SLOT 0x02
237#define LMP_ENCRYPT 0x04
238#define LMP_SOFFSET 0x08
239#define LMP_TACCURACY 0x10
240#define LMP_RSWITCH 0x20
241#define LMP_HOLD 0x40
04837f64 242#define LMP_SNIFF 0x80
1da177e4
LT
243
244#define LMP_PARK 0x01
245#define LMP_RSSI 0x02
246#define LMP_QUALITY 0x04
247#define LMP_SCO 0x08
248#define LMP_HV2 0x10
249#define LMP_HV3 0x20
250#define LMP_ULAW 0x40
251#define LMP_ALAW 0x80
252
253#define LMP_CVSD 0x01
254#define LMP_PSCHEME 0x02
255#define LMP_PCONTROL 0x04
07a5c61e 256#define LMP_TRANSPARENT 0x08
1da177e4 257
d5859e22 258#define LMP_RSSI_INQ 0x40
5b7f9909
MH
259#define LMP_ESCO 0x80
260
261#define LMP_EV4 0x01
262#define LMP_EV5 0x02
69ab39ea 263#define LMP_NO_BREDR 0x20
d5859e22 264#define LMP_LE 0x40
5b7f9909 265
04837f64 266#define LMP_SNIFF_SUBR 0x02
d5859e22 267#define LMP_PAUSE_ENC 0x04
efc7688b
MH
268#define LMP_EDR_ESCO_2M 0x20
269#define LMP_EDR_ESCO_3M 0x40
270#define LMP_EDR_3S_ESCO 0x80
04837f64 271
d5859e22 272#define LMP_EXT_INQ 0x01
e6100a25 273#define LMP_SIMUL_LE_BR 0x02
769be974 274#define LMP_SIMPLE_PAIR 0x08
e702112f 275#define LMP_NO_FLUSH 0x40
769be974 276
d5859e22
JH
277#define LMP_LSTO 0x01
278#define LMP_INQ_TX_PWR 0x02
971e3a4b 279#define LMP_EXTFEATURES 0x80
d5859e22 280
eead27da 281/* Extended LMP features */
53b834d2
MH
282#define LMP_CSB_MASTER 0x01
283#define LMP_CSB_SLAVE 0x02
284#define LMP_SYNC_TRAIN 0x04
285#define LMP_SYNC_SCAN 0x08
286
d5991585
MH
287#define LMP_SC 0x01
288#define LMP_PING 0x02
289
53b834d2 290/* Host features */
cc2c04ec
JH
291#define LMP_HOST_SSP 0x01
292#define LMP_HOST_LE 0x02
293#define LMP_HOST_LE_BREDR 0x04
d5991585 294#define LMP_HOST_SC 0x08
eead27da 295
04837f64
MH
296/* Connection modes */
297#define HCI_CM_ACTIVE 0x0000
298#define HCI_CM_HOLD 0x0001
299#define HCI_CM_SNIFF 0x0002
300#define HCI_CM_PARK 0x0003
301
1da177e4
LT
302/* Link policies */
303#define HCI_LP_RSWITCH 0x0001
304#define HCI_LP_HOLD 0x0002
305#define HCI_LP_SNIFF 0x0004
306#define HCI_LP_PARK 0x0008
307
04837f64 308/* Link modes */
1da177e4
LT
309#define HCI_LM_ACCEPT 0x8000
310#define HCI_LM_MASTER 0x0001
311#define HCI_LM_AUTH 0x0002
312#define HCI_LM_ENCRYPT 0x0004
313#define HCI_LM_TRUSTED 0x0008
314#define HCI_LM_RELIABLE 0x0010
315#define HCI_LM_SECURE 0x0020
316
40be492f
MH
317/* Authentication types */
318#define HCI_AT_NO_BONDING 0x00
319#define HCI_AT_NO_BONDING_MITM 0x01
320#define HCI_AT_DEDICATED_BONDING 0x02
321#define HCI_AT_DEDICATED_BONDING_MITM 0x03
322#define HCI_AT_GENERAL_BONDING 0x04
323#define HCI_AT_GENERAL_BONDING_MITM 0x05
324
a77b15a6
MA
325/* I/O capabilities */
326#define HCI_IO_DISPLAY_ONLY 0x00
327#define HCI_IO_DISPLAY_YESNO 0x01
328#define HCI_IO_KEYBOARD_ONLY 0x02
329#define HCI_IO_NO_INPUT_OUTPUT 0x03
330
b6020ba0
WR
331/* Link Key types */
332#define HCI_LK_COMBINATION 0x00
333#define HCI_LK_LOCAL_UNIT 0x01
334#define HCI_LK_REMOTE_UNIT 0x02
335#define HCI_LK_DEBUG_COMBINATION 0x03
11015c79
MH
336#define HCI_LK_UNAUTH_COMBINATION_P192 0x04
337#define HCI_LK_AUTH_COMBINATION_P192 0x05
b6020ba0 338#define HCI_LK_CHANGED_COMBINATION 0x06
11015c79
MH
339#define HCI_LK_UNAUTH_COMBINATION_P256 0x07
340#define HCI_LK_AUTH_COMBINATION_P256 0x08
b899efaf
VCG
341/* The spec doesn't define types for SMP keys, the _MASTER suffix is implied */
342#define HCI_SMP_STK 0x80
343#define HCI_SMP_STK_SLAVE 0x81
344#define HCI_SMP_LTK 0x82
345#define HCI_SMP_LTK_SLAVE 0x83
b6020ba0 346
9f5a0d7b
AE
347/* ---- HCI Error Codes ---- */
348#define HCI_ERROR_AUTH_FAILURE 0x05
cdcba7c6 349#define HCI_ERROR_CONNECTION_TIMEOUT 0x08
9f5a0d7b
AE
350#define HCI_ERROR_REJ_BAD_ADDR 0x0f
351#define HCI_ERROR_REMOTE_USER_TERM 0x13
cdcba7c6
MA
352#define HCI_ERROR_REMOTE_LOW_RESOURCES 0x14
353#define HCI_ERROR_REMOTE_POWER_OFF 0x15
9f5a0d7b
AE
354#define HCI_ERROR_LOCAL_HOST_TERM 0x16
355#define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18
356
2455a3ea
AE
357/* Flow control modes */
358#define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00
359#define HCI_FLOW_CTL_MODE_BLOCK_BASED 0x01
360
bbaf444a
JH
361/* The core spec defines 127 as the "not available" value */
362#define HCI_TX_POWER_INVALID 127
363
32748db0
JH
364/* Extended Inquiry Response field types */
365#define EIR_FLAGS 0x01 /* flags */
366#define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */
367#define EIR_UUID16_ALL 0x03 /* 16-bit UUID, all listed */
368#define EIR_UUID32_SOME 0x04 /* 32-bit UUID, more available */
369#define EIR_UUID32_ALL 0x05 /* 32-bit UUID, all listed */
370#define EIR_UUID128_SOME 0x06 /* 128-bit UUID, more available */
371#define EIR_UUID128_ALL 0x07 /* 128-bit UUID, all listed */
372#define EIR_NAME_SHORT 0x08 /* shortened local name */
373#define EIR_NAME_COMPLETE 0x09 /* complete local name */
374#define EIR_TX_POWER 0x0A /* transmit power level */
9ec9fc8a
JH
375#define EIR_CLASS_OF_DEV 0x0D /* Class of Device */
376#define EIR_SSP_HASH_C 0x0E /* Simple Pairing Hash C */
377#define EIR_SSP_RAND_R 0x0F /* Simple Pairing Randomizer R */
32748db0
JH
378#define EIR_DEVICE_ID 0x10 /* device ID */
379
3f0f524b
JH
380/* Low Energy Advertising Flags */
381#define LE_AD_LIMITED 0x01 /* Limited Discoverable */
382#define LE_AD_GENERAL 0x02 /* General Discoverable */
383#define LE_AD_NO_BREDR 0x04 /* BR/EDR not supported */
384#define LE_AD_SIM_LE_BREDR_CTRL 0x08 /* Simultaneous LE & BR/EDR Controller */
385#define LE_AD_SIM_LE_BREDR_HOST 0x10 /* Simultaneous LE & BR/EDR Host */
386
1da177e4 387/* ----- HCI Commands ---- */
6bd32326
VT
388#define HCI_OP_NOP 0x0000
389
a9de9248
MH
390#define HCI_OP_INQUIRY 0x0401
391struct hci_cp_inquiry {
392 __u8 lap[3];
393 __u8 length;
394 __u8 num_rsp;
66c853cc 395} __packed;
1da177e4 396
a9de9248 397#define HCI_OP_INQUIRY_CANCEL 0x0402
1da177e4 398
79d6e068
AG
399#define HCI_OP_PERIODIC_INQ 0x0403
400
a9de9248 401#define HCI_OP_EXIT_PERIODIC_INQ 0x0404
6ac59344 402
a9de9248 403#define HCI_OP_CREATE_CONN 0x0405
1da177e4
LT
404struct hci_cp_create_conn {
405 bdaddr_t bdaddr;
1ebb9252 406 __le16 pkt_type;
1da177e4
LT
407 __u8 pscan_rep_mode;
408 __u8 pscan_mode;
1ebb9252 409 __le16 clock_offset;
1da177e4 410 __u8 role_switch;
66c853cc 411} __packed;
1da177e4 412
a9de9248 413#define HCI_OP_DISCONNECT 0x0406
1da177e4 414struct hci_cp_disconnect {
1ebb9252 415 __le16 handle;
1da177e4 416 __u8 reason;
66c853cc 417} __packed;
1da177e4 418
a9de9248 419#define HCI_OP_ADD_SCO 0x0407
1da177e4 420struct hci_cp_add_sco {
1ebb9252
MH
421 __le16 handle;
422 __le16 pkt_type;
66c853cc 423} __packed;
1da177e4 424
a9de9248
MH
425#define HCI_OP_CREATE_CONN_CANCEL 0x0408
426struct hci_cp_create_conn_cancel {
427 bdaddr_t bdaddr;
66c853cc 428} __packed;
1da177e4 429
a9de9248
MH
430#define HCI_OP_ACCEPT_CONN_REQ 0x0409
431struct hci_cp_accept_conn_req {
432 bdaddr_t bdaddr;
433 __u8 role;
66c853cc 434} __packed;
1da177e4 435
a9de9248
MH
436#define HCI_OP_REJECT_CONN_REQ 0x040a
437struct hci_cp_reject_conn_req {
438 bdaddr_t bdaddr;
439 __u8 reason;
66c853cc 440} __packed;
defc761b 441
a9de9248 442#define HCI_OP_LINK_KEY_REPLY 0x040b
1da177e4
LT
443struct hci_cp_link_key_reply {
444 bdaddr_t bdaddr;
9b3b4460 445 __u8 link_key[HCI_LINK_KEY_SIZE];
66c853cc 446} __packed;
1da177e4 447
a9de9248 448#define HCI_OP_LINK_KEY_NEG_REPLY 0x040c
1da177e4
LT
449struct hci_cp_link_key_neg_reply {
450 bdaddr_t bdaddr;
66c853cc 451} __packed;
1da177e4 452
a9de9248 453#define HCI_OP_PIN_CODE_REPLY 0x040d
1da177e4
LT
454struct hci_cp_pin_code_reply {
455 bdaddr_t bdaddr;
456 __u8 pin_len;
457 __u8 pin_code[16];
66c853cc 458} __packed;
980e1a53
JH
459struct hci_rp_pin_code_reply {
460 __u8 status;
461 bdaddr_t bdaddr;
462} __packed;
1da177e4 463
a9de9248 464#define HCI_OP_PIN_CODE_NEG_REPLY 0x040e
1da177e4
LT
465struct hci_cp_pin_code_neg_reply {
466 bdaddr_t bdaddr;
66c853cc 467} __packed;
980e1a53
JH
468struct hci_rp_pin_code_neg_reply {
469 __u8 status;
470 bdaddr_t bdaddr;
471} __packed;
1da177e4 472
a9de9248 473#define HCI_OP_CHANGE_CONN_PTYPE 0x040f
1da177e4 474struct hci_cp_change_conn_ptype {
1ebb9252
MH
475 __le16 handle;
476 __le16 pkt_type;
66c853cc 477} __packed;
1da177e4 478
a9de9248 479#define HCI_OP_AUTH_REQUESTED 0x0411
1da177e4 480struct hci_cp_auth_requested {
1ebb9252 481 __le16 handle;
66c853cc 482} __packed;
1da177e4 483
a9de9248 484#define HCI_OP_SET_CONN_ENCRYPT 0x0413
1da177e4 485struct hci_cp_set_conn_encrypt {
1ebb9252 486 __le16 handle;
1da177e4 487 __u8 encrypt;
66c853cc 488} __packed;
1da177e4 489
a9de9248 490#define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415
1da177e4 491struct hci_cp_change_conn_link_key {
1ebb9252 492 __le16 handle;
66c853cc 493} __packed;
1da177e4 494
a9de9248
MH
495#define HCI_OP_REMOTE_NAME_REQ 0x0419
496struct hci_cp_remote_name_req {
497 bdaddr_t bdaddr;
498 __u8 pscan_rep_mode;
499 __u8 pscan_mode;
500 __le16 clock_offset;
66c853cc 501} __packed;
a9de9248
MH
502
503#define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a
504struct hci_cp_remote_name_req_cancel {
505 bdaddr_t bdaddr;
66c853cc 506} __packed;
a9de9248
MH
507
508#define HCI_OP_READ_REMOTE_FEATURES 0x041b
04837f64 509struct hci_cp_read_remote_features {
1ebb9252 510 __le16 handle;
66c853cc 511} __packed;
1da177e4 512
a9de9248
MH
513#define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c
514struct hci_cp_read_remote_ext_features {
515 __le16 handle;
516 __u8 page;
66c853cc 517} __packed;
a9de9248
MH
518
519#define HCI_OP_READ_REMOTE_VERSION 0x041d
04837f64 520struct hci_cp_read_remote_version {
1ebb9252 521 __le16 handle;
66c853cc 522} __packed;
1da177e4 523
a9de9248
MH
524#define HCI_OP_SETUP_SYNC_CONN 0x0428
525struct hci_cp_setup_sync_conn {
526 __le16 handle;
527 __le32 tx_bandwidth;
528 __le32 rx_bandwidth;
529 __le16 max_latency;
530 __le16 voice_setting;
531 __u8 retrans_effort;
532 __le16 pkt_type;
66c853cc 533} __packed;
04837f64 534
a9de9248
MH
535#define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429
536struct hci_cp_accept_sync_conn_req {
537 bdaddr_t bdaddr;
538 __le32 tx_bandwidth;
539 __le32 rx_bandwidth;
540 __le16 max_latency;
541 __le16 content_format;
542 __u8 retrans_effort;
543 __le16 pkt_type;
66c853cc 544} __packed;
a9de9248
MH
545
546#define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a
547struct hci_cp_reject_sync_conn_req {
548 bdaddr_t bdaddr;
549 __u8 reason;
66c853cc 550} __packed;
a9de9248 551
17fa4b9d
JH
552#define HCI_OP_IO_CAPABILITY_REPLY 0x042b
553struct hci_cp_io_capability_reply {
554 bdaddr_t bdaddr;
555 __u8 capability;
556 __u8 oob_data;
557 __u8 authentication;
558} __packed;
559
a5c29683
JH
560#define HCI_OP_USER_CONFIRM_REPLY 0x042c
561struct hci_cp_user_confirm_reply {
562 bdaddr_t bdaddr;
563} __packed;
564struct hci_rp_user_confirm_reply {
565 __u8 status;
566 bdaddr_t bdaddr;
567} __packed;
568
569#define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d
570
9ad4019a
BG
571#define HCI_OP_USER_PASSKEY_REPLY 0x042e
572struct hci_cp_user_passkey_reply {
573 bdaddr_t bdaddr;
574 __le32 passkey;
575} __packed;
576
577#define HCI_OP_USER_PASSKEY_NEG_REPLY 0x042f
578
2763eda6
SJ
579#define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430
580struct hci_cp_remote_oob_data_reply {
581 bdaddr_t bdaddr;
582 __u8 hash[16];
583 __u8 randomizer[16];
584} __packed;
585
586#define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY 0x0433
587struct hci_cp_remote_oob_data_neg_reply {
588 bdaddr_t bdaddr;
589} __packed;
590
03b555e1
JH
591#define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
592struct hci_cp_io_capability_neg_reply {
593 bdaddr_t bdaddr;
594 __u8 reason;
595} __packed;
596
523e93cd
AE
597#define HCI_OP_CREATE_PHY_LINK 0x0435
598struct hci_cp_create_phy_link {
599 __u8 phy_handle;
600 __u8 key_len;
601 __u8 key_type;
602 __u8 key[HCI_AMP_LINK_KEY_SIZE];
603} __packed;
604
605#define HCI_OP_ACCEPT_PHY_LINK 0x0436
606struct hci_cp_accept_phy_link {
607 __u8 phy_handle;
608 __u8 key_len;
609 __u8 key_type;
610 __u8 key[HCI_AMP_LINK_KEY_SIZE];
611} __packed;
612
b078b564 613#define HCI_OP_DISCONN_PHY_LINK 0x0437
523e93cd
AE
614struct hci_cp_disconn_phy_link {
615 __u8 phy_handle;
616 __u8 reason;
617} __packed;
618
b078b564
AE
619struct ext_flow_spec {
620 __u8 id;
621 __u8 stype;
622 __le16 msdu;
623 __le32 sdu_itime;
624 __le32 acc_lat;
625 __le32 flush_to;
626} __packed;
627
628#define HCI_OP_CREATE_LOGICAL_LINK 0x0438
629#define HCI_OP_ACCEPT_LOGICAL_LINK 0x0439
630struct hci_cp_create_accept_logical_link {
631 __u8 phy_handle;
632 struct ext_flow_spec tx_flow_spec;
633 struct ext_flow_spec rx_flow_spec;
634} __packed;
635
636#define HCI_OP_DISCONN_LOGICAL_LINK 0x043a
637struct hci_cp_disconn_logical_link {
638 __le16 log_handle;
639} __packed;
640
641#define HCI_OP_LOGICAL_LINK_CANCEL 0x043b
642struct hci_cp_logical_link_cancel {
643 __u8 phy_handle;
644 __u8 flow_spec_id;
645} __packed;
646
647struct hci_rp_logical_link_cancel {
648 __u8 status;
649 __u8 phy_handle;
650 __u8 flow_spec_id;
651} __packed;
652
8c9a041b
DP
653#define HCI_OP_SET_CSB 0x0441
654struct hci_cp_set_csb {
655 __u8 enable;
656 __u8 lt_addr;
657 __u8 lpo_allowed;
658 __le16 packet_type;
659 __le16 interval_min;
660 __le16 interval_max;
661 __le16 csb_sv_tout;
662} __packed;
663struct hci_rp_set_csb {
664 __u8 status;
665 __u8 lt_addr;
666 __le16 interval;
667} __packed;
668
cefded98
DP
669#define HCI_OP_START_SYNC_TRAIN 0x0443
670
e2f99131
MH
671#define HCI_OP_REMOTE_OOB_EXT_DATA_REPLY 0x0445
672struct hci_cp_remote_oob_ext_data_reply {
673 bdaddr_t bdaddr;
674 __u8 hash192[16];
675 __u8 randomizer192[16];
676 __u8 hash256[16];
677 __u8 randomizer256[16];
678} __packed;
679
a9de9248 680#define HCI_OP_SNIFF_MODE 0x0803
04837f64
MH
681struct hci_cp_sniff_mode {
682 __le16 handle;
683 __le16 max_interval;
684 __le16 min_interval;
685 __le16 attempt;
686 __le16 timeout;
66c853cc 687} __packed;
04837f64 688
a9de9248 689#define HCI_OP_EXIT_SNIFF_MODE 0x0804
04837f64
MH
690struct hci_cp_exit_sniff_mode {
691 __le16 handle;
66c853cc 692} __packed;
04837f64 693
a9de9248 694#define HCI_OP_ROLE_DISCOVERY 0x0809
1da177e4 695struct hci_cp_role_discovery {
1ebb9252 696 __le16 handle;
66c853cc 697} __packed;
1da177e4
LT
698struct hci_rp_role_discovery {
699 __u8 status;
1ebb9252 700 __le16 handle;
1da177e4 701 __u8 role;
66c853cc 702} __packed;
1da177e4 703
a9de9248
MH
704#define HCI_OP_SWITCH_ROLE 0x080b
705struct hci_cp_switch_role {
706 bdaddr_t bdaddr;
707 __u8 role;
66c853cc 708} __packed;
a9de9248
MH
709
710#define HCI_OP_READ_LINK_POLICY 0x080c
1da177e4 711struct hci_cp_read_link_policy {
1ebb9252 712 __le16 handle;
66c853cc 713} __packed;
1da177e4
LT
714struct hci_rp_read_link_policy {
715 __u8 status;
1ebb9252
MH
716 __le16 handle;
717 __le16 policy;
66c853cc 718} __packed;
1da177e4 719
a9de9248 720#define HCI_OP_WRITE_LINK_POLICY 0x080d
1da177e4 721struct hci_cp_write_link_policy {
1ebb9252
MH
722 __le16 handle;
723 __le16 policy;
66c853cc 724} __packed;
1da177e4
LT
725struct hci_rp_write_link_policy {
726 __u8 status;
1ebb9252 727 __le16 handle;
66c853cc 728} __packed;
e4e8e37c
MH
729
730#define HCI_OP_READ_DEF_LINK_POLICY 0x080e
731struct hci_rp_read_def_link_policy {
732 __u8 status;
733 __le16 policy;
66c853cc 734} __packed;
e4e8e37c
MH
735
736#define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f
737struct hci_cp_write_def_link_policy {
738 __le16 policy;
66c853cc 739} __packed;
1da177e4 740
a9de9248 741#define HCI_OP_SNIFF_SUBRATE 0x0811
04837f64
MH
742struct hci_cp_sniff_subrate {
743 __le16 handle;
744 __le16 max_latency;
745 __le16 min_remote_timeout;
746 __le16 min_local_timeout;
66c853cc 747} __packed;
04837f64 748
a9de9248 749#define HCI_OP_SET_EVENT_MASK 0x0c01
1da177e4 750
a9de9248 751#define HCI_OP_RESET 0x0c03
1da177e4 752
a9de9248
MH
753#define HCI_OP_SET_EVENT_FLT 0x0c05
754struct hci_cp_set_event_flt {
755 __u8 flt_type;
756 __u8 cond_type;
757 __u8 condition[0];
66c853cc 758} __packed;
1da177e4 759
a9de9248
MH
760/* Filter types */
761#define HCI_FLT_CLEAR_ALL 0x00
762#define HCI_FLT_INQ_RESULT 0x01
763#define HCI_FLT_CONN_SETUP 0x02
1da177e4 764
a9de9248
MH
765/* CONN_SETUP Condition types */
766#define HCI_CONN_SETUP_ALLOW_ALL 0x00
767#define HCI_CONN_SETUP_ALLOW_CLASS 0x01
768#define HCI_CONN_SETUP_ALLOW_BDADDR 0x02
769
770/* CONN_SETUP Conditions */
771#define HCI_CONN_SETUP_AUTO_OFF 0x01
772#define HCI_CONN_SETUP_AUTO_ON 0x02
773
b0916ea0
JH
774#define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
775struct hci_cp_delete_stored_link_key {
776 bdaddr_t bdaddr;
777 __u8 delete_all;
778} __packed;
779
1f6c6378
JH
780#define HCI_MAX_NAME_LENGTH 248
781
a9de9248
MH
782#define HCI_OP_WRITE_LOCAL_NAME 0x0c13
783struct hci_cp_write_local_name {
1f6c6378 784 __u8 name[HCI_MAX_NAME_LENGTH];
66c853cc 785} __packed;
a9de9248
MH
786
787#define HCI_OP_READ_LOCAL_NAME 0x0c14
788struct hci_rp_read_local_name {
789 __u8 status;
1f6c6378 790 __u8 name[HCI_MAX_NAME_LENGTH];
66c853cc 791} __packed;
a9de9248
MH
792
793#define HCI_OP_WRITE_CA_TIMEOUT 0x0c16
794
795#define HCI_OP_WRITE_PG_TIMEOUT 0x0c18
796
70f23020 797#define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a
a9de9248
MH
798 #define SCAN_DISABLED 0x00
799 #define SCAN_INQUIRY 0x01
800 #define SCAN_PAGE 0x02
801
802#define HCI_OP_READ_AUTH_ENABLE 0x0c1f
803
804#define HCI_OP_WRITE_AUTH_ENABLE 0x0c20
805 #define AUTH_DISABLED 0x00
806 #define AUTH_ENABLED 0x01
807
808#define HCI_OP_READ_ENCRYPT_MODE 0x0c21
809
810#define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22
811 #define ENCRYPT_DISABLED 0x00
812 #define ENCRYPT_P2P 0x01
813 #define ENCRYPT_BOTH 0x02
814
815#define HCI_OP_READ_CLASS_OF_DEV 0x0c23
816struct hci_rp_read_class_of_dev {
817 __u8 status;
1da177e4 818 __u8 dev_class[3];
66c853cc 819} __packed;
1da177e4 820
a9de9248
MH
821#define HCI_OP_WRITE_CLASS_OF_DEV 0x0c24
822struct hci_cp_write_class_of_dev {
1da177e4 823 __u8 dev_class[3];
66c853cc 824} __packed;
a9de9248
MH
825
826#define HCI_OP_READ_VOICE_SETTING 0x0c25
827struct hci_rp_read_voice_setting {
828 __u8 status;
829 __le16 voice_setting;
66c853cc 830} __packed;
a9de9248
MH
831
832#define HCI_OP_WRITE_VOICE_SETTING 0x0c26
833struct hci_cp_write_voice_setting {
834 __le16 voice_setting;
66c853cc 835} __packed;
a9de9248
MH
836
837#define HCI_OP_HOST_BUFFER_SIZE 0x0c33
838struct hci_cp_host_buffer_size {
839 __le16 acl_mtu;
840 __u8 sco_mtu;
841 __le16 acl_max_pkt;
842 __le16 sco_max_pkt;
66c853cc 843} __packed;
a9de9248 844
b4cb9fb2
MH
845#define HCI_OP_READ_NUM_SUPPORTED_IAC 0x0c38
846struct hci_rp_read_num_supported_iac {
847 __u8 status;
848 __u8 num_iac;
849} __packed;
850
4b836f39
MH
851#define HCI_OP_READ_CURRENT_IAC_LAP 0x0c39
852
3d505312
MH
853#define HCI_OP_WRITE_CURRENT_IAC_LAP 0x0c3a
854struct hci_cp_write_current_iac_lap {
855 __u8 num_iac;
856 __u8 iac_lap[6];
857} __packed;
858
d5859e22
JH
859#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
860
80a1e1db
JH
861#define HCI_MAX_EIR_LENGTH 240
862
863#define HCI_OP_WRITE_EIR 0x0c52
864struct hci_cp_write_eir {
f64b993f
GP
865 __u8 fec;
866 __u8 data[HCI_MAX_EIR_LENGTH];
80a1e1db
JH
867} __packed;
868
333140b5
MH
869#define HCI_OP_READ_SSP_MODE 0x0c55
870struct hci_rp_read_ssp_mode {
871 __u8 status;
872 __u8 mode;
66c853cc 873} __packed;
333140b5
MH
874
875#define HCI_OP_WRITE_SSP_MODE 0x0c56
876struct hci_cp_write_ssp_mode {
877 __u8 mode;
66c853cc 878} __packed;
333140b5 879
c35938b2
SJ
880#define HCI_OP_READ_LOCAL_OOB_DATA 0x0c57
881struct hci_rp_read_local_oob_data {
882 __u8 status;
883 __u8 hash[16];
884 __u8 randomizer[16];
885} __packed;
886
d5859e22 887#define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
91c4e9b1
MH
888struct hci_rp_read_inq_rsp_tx_power {
889 __u8 status;
890 __s8 tx_power;
891} __packed;
d5859e22 892
d62e6d67
JH
893#define HCI_OP_SET_EVENT_MASK_PAGE_2 0x0c63
894
7528ca1c
MH
895#define HCI_OP_READ_LOCATION_DATA 0x0c64
896
1e89cffb
AE
897#define HCI_OP_READ_FLOW_CONTROL_MODE 0x0c66
898struct hci_rp_read_flow_control_mode {
899 __u8 status;
900 __u8 mode;
901} __packed;
902
f9b49306
AG
903#define HCI_OP_WRITE_LE_HOST_SUPPORTED 0x0c6d
904struct hci_cp_write_le_host_supported {
f64b993f
GP
905 __u8 le;
906 __u8 simul;
f9b49306
AG
907} __packed;
908
d0bf75a5
DP
909#define HCI_OP_SET_RESERVED_LT_ADDR 0x0c74
910struct hci_cp_set_reserved_lt_addr {
911 __u8 lt_addr;
912} __packed;
913struct hci_rp_set_reserved_lt_addr {
914 __u8 status;
915 __u8 lt_addr;
916} __packed;
917
6a20eaf4
DP
918#define HCI_OP_DELETE_RESERVED_LT_ADDR 0x0c75
919struct hci_cp_delete_reserved_lt_addr {
920 __u8 lt_addr;
921} __packed;
922struct hci_rp_delete_reserved_lt_addr {
923 __u8 status;
924 __u8 lt_addr;
925} __packed;
926
7d1dab49
DP
927#define HCI_OP_SET_CSB_DATA 0x0c76
928struct hci_cp_set_csb_data {
929 __u8 lt_addr;
930 __u8 fragment;
931 __u8 data_length;
932 __u8 data[HCI_MAX_CSB_DATA_SIZE];
933} __packed;
934struct hci_rp_set_csb_data {
935 __u8 status;
936 __u8 lt_addr;
937} __packed;
938
5d4e7e8d
JH
939#define HCI_OP_READ_SYNC_TRAIN_PARAMS 0x0c77
940
a9b07a64
DP
941#define HCI_OP_WRITE_SYNC_TRAIN_PARAMS 0x0c78
942struct hci_cp_write_sync_train_params {
943 __le16 interval_min;
944 __le16 interval_max;
945 __le32 sync_train_tout;
946 __u8 service_data;
947} __packed;
948struct hci_rp_write_sync_train_params {
949 __u8 status;
950 __le16 sync_train_int;
951} __packed;
952
eb4b95c6
MH
953#define HCI_OP_READ_SC_SUPPORT 0x0c79
954struct hci_rp_read_sc_support {
955 __u8 status;
956 __u8 support;
957} __packed;
958
959#define HCI_OP_WRITE_SC_SUPPORT 0x0c7a
960struct hci_cp_write_sc_support {
961 __u8 support;
962} __packed;
963
e2f99131
MH
964#define HCI_OP_READ_LOCAL_OOB_EXT_DATA 0x0c7d
965struct hci_rp_read_local_oob_ext_data {
966 __u8 status;
967 __u8 hash192[16];
968 __u8 randomizer192[16];
969 __u8 hash256[16];
970 __u8 randomizer256[16];
971} __packed;
972
a9de9248
MH
973#define HCI_OP_READ_LOCAL_VERSION 0x1001
974struct hci_rp_read_local_version {
975 __u8 status;
976 __u8 hci_ver;
977 __le16 hci_rev;
978 __u8 lmp_ver;
979 __le16 manufacturer;
980 __le16 lmp_subver;
66c853cc 981} __packed;
a9de9248
MH
982
983#define HCI_OP_READ_LOCAL_COMMANDS 0x1002
984struct hci_rp_read_local_commands {
985 __u8 status;
986 __u8 commands[64];
66c853cc 987} __packed;
a9de9248
MH
988
989#define HCI_OP_READ_LOCAL_FEATURES 0x1003
990struct hci_rp_read_local_features {
991 __u8 status;
992 __u8 features[8];
66c853cc 993} __packed;
a9de9248
MH
994
995#define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004
971e3a4b
AG
996struct hci_cp_read_local_ext_features {
997 __u8 page;
998} __packed;
a9de9248
MH
999struct hci_rp_read_local_ext_features {
1000 __u8 status;
1001 __u8 page;
1002 __u8 max_page;
1003 __u8 features[8];
66c853cc 1004} __packed;
a9de9248
MH
1005
1006#define HCI_OP_READ_BUFFER_SIZE 0x1005
1007struct hci_rp_read_buffer_size {
1008 __u8 status;
1009 __le16 acl_mtu;
1010 __u8 sco_mtu;
1011 __le16 acl_max_pkt;
1012 __le16 sco_max_pkt;
66c853cc 1013} __packed;
a9de9248
MH
1014
1015#define HCI_OP_READ_BD_ADDR 0x1009
1016struct hci_rp_read_bd_addr {
1017 __u8 status;
45bb4bf0 1018 bdaddr_t bdaddr;
66c853cc 1019} __packed;
1da177e4 1020
350ee4cf
AE
1021#define HCI_OP_READ_DATA_BLOCK_SIZE 0x100a
1022struct hci_rp_read_data_block_size {
1023 __u8 status;
1024 __le16 max_acl_len;
1025 __le16 block_len;
1026 __le16 num_blocks;
1027} __packed;
1028
f332ec66
JH
1029#define HCI_OP_READ_PAGE_SCAN_ACTIVITY 0x0c1b
1030struct hci_rp_read_page_scan_activity {
1031 __u8 status;
1032 __le16 interval;
1033 __le16 window;
1034} __packed;
1035
f6422ec6
AJ
1036#define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c
1037struct hci_cp_write_page_scan_activity {
1038 __le16 interval;
1039 __le16 window;
1040} __packed;
1041
f332ec66
JH
1042#define HCI_OP_READ_PAGE_SCAN_TYPE 0x0c46
1043struct hci_rp_read_page_scan_type {
1044 __u8 status;
1045 __u8 type;
1046} __packed;
1047
f6422ec6
AJ
1048#define HCI_OP_WRITE_PAGE_SCAN_TYPE 0x0c47
1049 #define PAGE_SCAN_TYPE_STANDARD 0x00
1050 #define PAGE_SCAN_TYPE_INTERLACED 0x01
1051
928abaa7
AE
1052#define HCI_OP_READ_LOCAL_AMP_INFO 0x1409
1053struct hci_rp_read_local_amp_info {
1054 __u8 status;
1055 __u8 amp_status;
1056 __le32 total_bw;
1057 __le32 max_bw;
1058 __le32 min_latency;
1059 __le32 max_pdu;
1060 __u8 amp_type;
1061 __le16 pal_cap;
1062 __le16 max_assoc_size;
1063 __le32 max_flush_to;
1064 __le32 be_flush_to;
1065} __packed;
1066
523e93cd
AE
1067#define HCI_OP_READ_LOCAL_AMP_ASSOC 0x140a
1068struct hci_cp_read_local_amp_assoc {
1069 __u8 phy_handle;
1070 __le16 len_so_far;
1071 __le16 max_len;
1072} __packed;
1073struct hci_rp_read_local_amp_assoc {
1074 __u8 status;
1075 __u8 phy_handle;
1076 __le16 rem_len;
1077 __u8 frag[0];
1078} __packed;
1079
1080#define HCI_OP_WRITE_REMOTE_AMP_ASSOC 0x140b
1081struct hci_cp_write_remote_amp_assoc {
1082 __u8 phy_handle;
1083 __le16 len_so_far;
1084 __le16 rem_len;
1085 __u8 frag[0];
1086} __packed;
1087struct hci_rp_write_remote_amp_assoc {
1088 __u8 status;
1089 __u8 phy_handle;
1090} __packed;
1091
4b4148e9
MH
1092#define HCI_OP_ENABLE_DUT_MODE 0x1803
1093
06f5b778
MH
1094#define HCI_OP_WRITE_SSP_DEBUG_MODE 0x1804
1095
63185f64
VT
1096#define HCI_OP_LE_SET_EVENT_MASK 0x2001
1097struct hci_cp_le_set_event_mask {
1098 __u8 mask[8];
1099} __packed;
1100
1101#define HCI_OP_LE_READ_BUFFER_SIZE 0x2002
1102struct hci_rp_le_read_buffer_size {
1103 __u8 status;
1104 __le16 le_mtu;
1105 __u8 le_max_pkt;
1106} __packed;
1107
60e77321
JH
1108#define HCI_OP_LE_READ_LOCAL_FEATURES 0x2003
1109struct hci_rp_le_read_local_features {
1110 __u8 status;
1111 __u8 features[8];
1112} __packed;
1113
d13eafce
MH
1114#define HCI_OP_LE_SET_RANDOM_ADDR 0x2005
1115
1e191893
MH
1116#define HCI_OP_LE_SET_ADV_PARAM 0x2006
1117struct hci_cp_le_set_adv_param {
1118 __le16 min_interval;
1119 __le16 max_interval;
1120 __u8 type;
1121 __u8 own_address_type;
1122 __u8 direct_addr_type;
1123 bdaddr_t direct_addr;
1124 __u8 channel_map;
1125 __u8 filter_policy;
1126} __packed;
1127
8fa19098
JH
1128#define HCI_OP_LE_READ_ADV_TX_POWER 0x2007
1129struct hci_rp_le_read_adv_tx_power {
1130 __u8 status;
1131 __s8 tx_power;
1132} __packed;
1133
3f0f524b
JH
1134#define HCI_MAX_AD_LENGTH 31
1135
1136#define HCI_OP_LE_SET_ADV_DATA 0x2008
1137struct hci_cp_le_set_adv_data {
1138 __u8 length;
1139 __u8 data[HCI_MAX_AD_LENGTH];
1140} __packed;
1141
f14d8f64
MH
1142#define HCI_OP_LE_SET_SCAN_RSP_DATA 0x2009
1143struct hci_cp_le_set_scan_rsp_data {
1144 __u8 length;
1145 __u8 data[HCI_MAX_AD_LENGTH];
1146} __packed;
1147
c1d5dc4a
JH
1148#define HCI_OP_LE_SET_ADV_ENABLE 0x200a
1149
5df480b5
AG
1150#define LE_SCAN_PASSIVE 0x00
1151#define LE_SCAN_ACTIVE 0x01
1152
07f7fa5d
AG
1153#define HCI_OP_LE_SET_SCAN_PARAM 0x200b
1154struct hci_cp_le_set_scan_param {
1155 __u8 type;
1156 __le16 interval;
1157 __le16 window;
1158 __u8 own_address_type;
1159 __u8 filter_policy;
1160} __packed;
1161
76a388be
AG
1162#define LE_SCAN_DISABLE 0x00
1163#define LE_SCAN_ENABLE 0x01
525e296a
AG
1164#define LE_SCAN_FILTER_DUP_DISABLE 0x00
1165#define LE_SCAN_FILTER_DUP_ENABLE 0x01
68a8aea4 1166
eb9d91f5
AG
1167#define HCI_OP_LE_SET_SCAN_ENABLE 0x200c
1168struct hci_cp_le_set_scan_enable {
1169 __u8 enable;
1170 __u8 filter_dup;
1171} __packed;
1172
63185f64
VT
1173#define HCI_OP_LE_CREATE_CONN 0x200d
1174struct hci_cp_le_create_conn {
1175 __le16 scan_interval;
1176 __le16 scan_window;
1177 __u8 filter_policy;
1178 __u8 peer_addr_type;
1179 bdaddr_t peer_addr;
1180 __u8 own_address_type;
1181 __le16 conn_interval_min;
1182 __le16 conn_interval_max;
1183 __le16 conn_latency;
1184 __le16 supervision_timeout;
1185 __le16 min_ce_len;
1186 __le16 max_ce_len;
1187} __packed;
1188
1189#define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e
1190
cf1d081f
JH
1191#define HCI_OP_LE_READ_WHITE_LIST_SIZE 0x200f
1192struct hci_rp_le_read_white_list_size {
1193 __u8 status;
1194 __u8 size;
1195} __packed;
1196
2ce603eb
CT
1197#define HCI_OP_LE_CONN_UPDATE 0x2013
1198struct hci_cp_le_conn_update {
1199 __le16 handle;
1200 __le16 conn_interval_min;
1201 __le16 conn_interval_max;
1202 __le16 conn_latency;
1203 __le16 supervision_timeout;
1204 __le16 min_ce_len;
1205 __le16 max_ce_len;
1206} __packed;
1207
a7a595f6
VCG
1208#define HCI_OP_LE_START_ENC 0x2019
1209struct hci_cp_le_start_enc {
1210 __le16 handle;
1211 __u8 rand[8];
1212 __le16 ediv;
1213 __u8 ltk[16];
1214} __packed;
1215
1216#define HCI_OP_LE_LTK_REPLY 0x201a
1217struct hci_cp_le_ltk_reply {
1218 __le16 handle;
1219 __u8 ltk[16];
1220} __packed;
1221struct hci_rp_le_ltk_reply {
1222 __u8 status;
1223 __le16 handle;
1224} __packed;
1225
1226#define HCI_OP_LE_LTK_NEG_REPLY 0x201b
1227struct hci_cp_le_ltk_neg_reply {
1228 __le16 handle;
1229} __packed;
1230struct hci_rp_le_ltk_neg_reply {
1231 __u8 status;
1232 __le16 handle;
1233} __packed;
1234
9b008c04
JH
1235#define HCI_OP_LE_READ_SUPPORTED_STATES 0x201c
1236struct hci_rp_le_read_supported_states {
1237 __u8 status;
1238 __u8 le_states[8];
1239} __packed;
1240
a9de9248
MH
1241/* ---- HCI Events ---- */
1242#define HCI_EV_INQUIRY_COMPLETE 0x01
1243
1244#define HCI_EV_INQUIRY_RESULT 0x02
1245struct inquiry_info {
21d9e30e
MH
1246 bdaddr_t bdaddr;
1247 __u8 pscan_rep_mode;
1248 __u8 pscan_period_mode;
a9de9248 1249 __u8 pscan_mode;
21d9e30e 1250 __u8 dev_class[3];
1ebb9252 1251 __le16 clock_offset;
66c853cc 1252} __packed;
21d9e30e 1253
a9de9248 1254#define HCI_EV_CONN_COMPLETE 0x03
1da177e4
LT
1255struct hci_ev_conn_complete {
1256 __u8 status;
1ebb9252 1257 __le16 handle;
1da177e4
LT
1258 bdaddr_t bdaddr;
1259 __u8 link_type;
1260 __u8 encr_mode;
66c853cc 1261} __packed;
1da177e4 1262
a9de9248 1263#define HCI_EV_CONN_REQUEST 0x04
1da177e4
LT
1264struct hci_ev_conn_request {
1265 bdaddr_t bdaddr;
1266 __u8 dev_class[3];
1267 __u8 link_type;
66c853cc 1268} __packed;
1da177e4 1269
a9de9248 1270#define HCI_EV_DISCONN_COMPLETE 0x05
1da177e4
LT
1271struct hci_ev_disconn_complete {
1272 __u8 status;
1ebb9252 1273 __le16 handle;
1da177e4 1274 __u8 reason;
66c853cc 1275} __packed;
1da177e4 1276
a9de9248 1277#define HCI_EV_AUTH_COMPLETE 0x06
1da177e4
LT
1278struct hci_ev_auth_complete {
1279 __u8 status;
1ebb9252 1280 __le16 handle;
66c853cc 1281} __packed;
1da177e4 1282
a9de9248
MH
1283#define HCI_EV_REMOTE_NAME 0x07
1284struct hci_ev_remote_name {
1285 __u8 status;
1286 bdaddr_t bdaddr;
1f6c6378 1287 __u8 name[HCI_MAX_NAME_LENGTH];
66c853cc 1288} __packed;
a9de9248
MH
1289
1290#define HCI_EV_ENCRYPT_CHANGE 0x08
1da177e4
LT
1291struct hci_ev_encrypt_change {
1292 __u8 status;
1ebb9252 1293 __le16 handle;
1da177e4 1294 __u8 encrypt;
66c853cc 1295} __packed;
1da177e4 1296
a9de9248
MH
1297#define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09
1298struct hci_ev_change_link_key_complete {
1299 __u8 status;
1300 __le16 handle;
66c853cc 1301} __packed;
a9de9248
MH
1302
1303#define HCI_EV_REMOTE_FEATURES 0x0b
1304struct hci_ev_remote_features {
1305 __u8 status;
1306 __le16 handle;
1307 __u8 features[8];
66c853cc 1308} __packed;
a9de9248
MH
1309
1310#define HCI_EV_REMOTE_VERSION 0x0c
1311struct hci_ev_remote_version {
1da177e4 1312 __u8 status;
1ebb9252 1313 __le16 handle;
a9de9248
MH
1314 __u8 lmp_ver;
1315 __le16 manufacturer;
1316 __le16 lmp_subver;
66c853cc 1317} __packed;
1da177e4 1318
a9de9248 1319#define HCI_EV_QOS_SETUP_COMPLETE 0x0d
1da177e4
LT
1320struct hci_qos {
1321 __u8 service_type;
1322 __u32 token_rate;
1323 __u32 peak_bandwidth;
1324 __u32 latency;
1325 __u32 delay_variation;
66c853cc 1326} __packed;
1da177e4
LT
1327struct hci_ev_qos_setup_complete {
1328 __u8 status;
1ebb9252 1329 __le16 handle;
1da177e4 1330 struct hci_qos qos;
66c853cc 1331} __packed;
1da177e4 1332
a9de9248 1333#define HCI_EV_CMD_COMPLETE 0x0e
1da177e4
LT
1334struct hci_ev_cmd_complete {
1335 __u8 ncmd;
1ebb9252 1336 __le16 opcode;
66c853cc 1337} __packed;
1da177e4 1338
a9de9248 1339#define HCI_EV_CMD_STATUS 0x0f
1da177e4
LT
1340struct hci_ev_cmd_status {
1341 __u8 status;
1342 __u8 ncmd;
1ebb9252 1343 __le16 opcode;
66c853cc 1344} __packed;
1da177e4 1345
a9de9248 1346#define HCI_EV_ROLE_CHANGE 0x12
1da177e4
LT
1347struct hci_ev_role_change {
1348 __u8 status;
1349 bdaddr_t bdaddr;
1350 __u8 role;
66c853cc 1351} __packed;
1da177e4 1352
a9de9248 1353#define HCI_EV_NUM_COMP_PKTS 0x13
613a1c0c
AE
1354struct hci_comp_pkts_info {
1355 __le16 handle;
1356 __le16 count;
1357} __packed;
1358
a9de9248
MH
1359struct hci_ev_num_comp_pkts {
1360 __u8 num_hndl;
613a1c0c 1361 struct hci_comp_pkts_info handles[0];
66c853cc 1362} __packed;
a9de9248
MH
1363
1364#define HCI_EV_MODE_CHANGE 0x14
1da177e4
LT
1365struct hci_ev_mode_change {
1366 __u8 status;
1ebb9252 1367 __le16 handle;
1da177e4 1368 __u8 mode;
1ebb9252 1369 __le16 interval;
66c853cc 1370} __packed;
1da177e4 1371
a9de9248 1372#define HCI_EV_PIN_CODE_REQ 0x16
1da177e4
LT
1373struct hci_ev_pin_code_req {
1374 bdaddr_t bdaddr;
66c853cc 1375} __packed;
1da177e4 1376
a9de9248 1377#define HCI_EV_LINK_KEY_REQ 0x17
1da177e4
LT
1378struct hci_ev_link_key_req {
1379 bdaddr_t bdaddr;
66c853cc 1380} __packed;
1da177e4 1381
a9de9248 1382#define HCI_EV_LINK_KEY_NOTIFY 0x18
1da177e4
LT
1383struct hci_ev_link_key_notify {
1384 bdaddr_t bdaddr;
9b3b4460 1385 __u8 link_key[HCI_LINK_KEY_SIZE];
a9de9248 1386 __u8 key_type;
66c853cc 1387} __packed;
1da177e4 1388
a9de9248
MH
1389#define HCI_EV_CLOCK_OFFSET 0x1c
1390struct hci_ev_clock_offset {
1da177e4 1391 __u8 status;
1ebb9252 1392 __le16 handle;
a9de9248 1393 __le16 clock_offset;
66c853cc 1394} __packed;
1da177e4 1395
a8746417
MH
1396#define HCI_EV_PKT_TYPE_CHANGE 0x1d
1397struct hci_ev_pkt_type_change {
1398 __u8 status;
1399 __le16 handle;
1400 __le16 pkt_type;
66c853cc 1401} __packed;
a8746417 1402
a9de9248
MH
1403#define HCI_EV_PSCAN_REP_MODE 0x20
1404struct hci_ev_pscan_rep_mode {
1405 bdaddr_t bdaddr;
1406 __u8 pscan_rep_mode;
66c853cc 1407} __packed;
a9de9248
MH
1408
1409#define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
1410struct inquiry_info_with_rssi {
1411 bdaddr_t bdaddr;
1412 __u8 pscan_rep_mode;
1413 __u8 pscan_period_mode;
1414 __u8 dev_class[3];
1415 __le16 clock_offset;
1416 __s8 rssi;
66c853cc 1417} __packed;
a9de9248
MH
1418struct inquiry_info_with_rssi_and_pscan_mode {
1419 bdaddr_t bdaddr;
1420 __u8 pscan_rep_mode;
1421 __u8 pscan_period_mode;
1422 __u8 pscan_mode;
1423 __u8 dev_class[3];
1424 __le16 clock_offset;
1425 __s8 rssi;
66c853cc 1426} __packed;
a9de9248
MH
1427
1428#define HCI_EV_REMOTE_EXT_FEATURES 0x23
1429struct hci_ev_remote_ext_features {
1da177e4 1430 __u8 status;
1ebb9252 1431 __le16 handle;
a9de9248
MH
1432 __u8 page;
1433 __u8 max_page;
1434 __u8 features[8];
66c853cc 1435} __packed;
1da177e4 1436
a9de9248
MH
1437#define HCI_EV_SYNC_CONN_COMPLETE 0x2c
1438struct hci_ev_sync_conn_complete {
1da177e4 1439 __u8 status;
1ebb9252 1440 __le16 handle;
a9de9248
MH
1441 bdaddr_t bdaddr;
1442 __u8 link_type;
1443 __u8 tx_interval;
1444 __u8 retrans_window;
1445 __le16 rx_pkt_len;
1446 __le16 tx_pkt_len;
1447 __u8 air_mode;
66c853cc 1448} __packed;
1da177e4 1449
a9de9248
MH
1450#define HCI_EV_SYNC_CONN_CHANGED 0x2d
1451struct hci_ev_sync_conn_changed {
1452 __u8 status;
1453 __le16 handle;
1454 __u8 tx_interval;
1455 __u8 retrans_window;
1456 __le16 rx_pkt_len;
1457 __le16 tx_pkt_len;
66c853cc 1458} __packed;
85a1e930 1459
a9de9248 1460#define HCI_EV_SNIFF_SUBRATE 0x2e
04837f64
MH
1461struct hci_ev_sniff_subrate {
1462 __u8 status;
1463 __le16 handle;
1464 __le16 max_tx_latency;
1465 __le16 max_rx_latency;
1466 __le16 max_remote_timeout;
1467 __le16 max_local_timeout;
66c853cc 1468} __packed;
04837f64 1469
a9de9248
MH
1470#define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f
1471struct extended_inquiry_info {
1472 bdaddr_t bdaddr;
1473 __u8 pscan_rep_mode;
1474 __u8 pscan_period_mode;
1475 __u8 dev_class[3];
1476 __le16 clock_offset;
1477 __s8 rssi;
1478 __u8 data[240];
66c853cc 1479} __packed;
a9de9248 1480
1c2e0041
JH
1481#define HCI_EV_KEY_REFRESH_COMPLETE 0x30
1482struct hci_ev_key_refresh_complete {
1483 __u8 status;
1484 __le16 handle;
1485} __packed;
1486
0493684e
MH
1487#define HCI_EV_IO_CAPA_REQUEST 0x31
1488struct hci_ev_io_capa_request {
1489 bdaddr_t bdaddr;
66c853cc 1490} __packed;
0493684e 1491
03b555e1
JH
1492#define HCI_EV_IO_CAPA_REPLY 0x32
1493struct hci_ev_io_capa_reply {
1494 bdaddr_t bdaddr;
1495 __u8 capability;
1496 __u8 oob_data;
1497 __u8 authentication;
1498} __packed;
1499
a5c29683
JH
1500#define HCI_EV_USER_CONFIRM_REQUEST 0x33
1501struct hci_ev_user_confirm_req {
1502 bdaddr_t bdaddr;
1503 __le32 passkey;
1504} __packed;
1505
9ad4019a
BG
1506#define HCI_EV_USER_PASSKEY_REQUEST 0x34
1507struct hci_ev_user_passkey_req {
1508 bdaddr_t bdaddr;
1509} __packed;
1510
2763eda6
SJ
1511#define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35
1512struct hci_ev_remote_oob_data_request {
1513 bdaddr_t bdaddr;
1514} __packed;
1515
0493684e
MH
1516#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
1517struct hci_ev_simple_pair_complete {
1518 __u8 status;
1519 bdaddr_t bdaddr;
66c853cc 1520} __packed;
0493684e 1521
92a25256
JH
1522#define HCI_EV_USER_PASSKEY_NOTIFY 0x3b
1523struct hci_ev_user_passkey_notify {
1524 bdaddr_t bdaddr;
1525 __le32 passkey;
1526} __packed;
1527
1528#define HCI_KEYPRESS_STARTED 0
1529#define HCI_KEYPRESS_ENTERED 1
1530#define HCI_KEYPRESS_ERASED 2
1531#define HCI_KEYPRESS_CLEARED 3
1532#define HCI_KEYPRESS_COMPLETED 4
1533
1534#define HCI_EV_KEYPRESS_NOTIFY 0x3c
1535struct hci_ev_keypress_notify {
1536 bdaddr_t bdaddr;
1537 __u8 type;
1538} __packed;
1539
41a96212
MH
1540#define HCI_EV_REMOTE_HOST_FEATURES 0x3d
1541struct hci_ev_remote_host_features {
1542 bdaddr_t bdaddr;
1543 __u8 features[8];
66c853cc 1544} __packed;
41a96212 1545
63185f64
VT
1546#define HCI_EV_LE_META 0x3e
1547struct hci_ev_le_meta {
1548 __u8 subevent;
1549} __packed;
1550
523e93cd
AE
1551#define HCI_EV_PHY_LINK_COMPLETE 0x40
1552struct hci_ev_phy_link_complete {
1553 __u8 status;
1554 __u8 phy_handle;
1555} __packed;
1556
1557#define HCI_EV_CHANNEL_SELECTED 0x41
1558struct hci_ev_channel_selected {
1559 __u8 phy_handle;
1560} __packed;
1561
1562#define HCI_EV_DISCONN_PHY_LINK_COMPLETE 0x42
1563struct hci_ev_disconn_phy_link_complete {
1564 __u8 status;
1565 __u8 phy_handle;
1566 __u8 reason;
1567} __packed;
1568
1569#define HCI_EV_LOGICAL_LINK_COMPLETE 0x45
1570struct hci_ev_logical_link_complete {
1571 __u8 status;
1572 __le16 handle;
1573 __u8 phy_handle;
1574 __u8 flow_spec_id;
1575} __packed;
1576
1577#define HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE 0x46
1578struct hci_ev_disconn_logical_link_complete {
1579 __u8 status;
1580 __le16 handle;
1581 __u8 reason;
1582} __packed;
1583
25e89e99
AE
1584#define HCI_EV_NUM_COMP_BLOCKS 0x48
1585struct hci_comp_blocks_info {
1586 __le16 handle;
1587 __le16 pkts;
1588 __le16 blocks;
1589} __packed;
1590
1591struct hci_ev_num_comp_blocks {
1592 __le16 num_blocks;
1593 __u8 num_hndl;
1594 struct hci_comp_blocks_info handles[0];
1595} __packed;
1596
2b359445
DP
1597#define HCI_EV_SYNC_TRAIN_COMPLETE 0x4F
1598struct hci_ev_sync_train_complete {
1599 __u8 status;
1600} __packed;
1601
2ed01805
DP
1602#define HCI_EV_SLAVE_PAGE_RESP_TIMEOUT 0x54
1603
63185f64 1604/* Low energy meta events */
b9b343d2
AG
1605#define LE_CONN_ROLE_MASTER 0x00
1606
63185f64
VT
1607#define HCI_EV_LE_CONN_COMPLETE 0x01
1608struct hci_ev_le_conn_complete {
1609 __u8 status;
1610 __le16 handle;
1611 __u8 role;
1612 __u8 bdaddr_type;
1613 bdaddr_t bdaddr;
1614 __le16 interval;
1615 __le16 latency;
1616 __le16 supervision_timeout;
1617 __u8 clk_accurancy;
1618} __packed;
1619
a7a595f6
VCG
1620#define HCI_EV_LE_LTK_REQ 0x05
1621struct hci_ev_le_ltk_req {
1622 __le16 handle;
1623 __u8 random[8];
1624 __le16 ediv;
1625} __packed;
1626
57a56fd4 1627/* Advertising report event types */
db3aebf4
MH
1628#define LE_ADV_IND 0x00
1629#define LE_ADV_DIRECT_IND 0x01
1630#define LE_ADV_SCAN_IND 0x02
1631#define LE_ADV_NONCONN_IND 0x03
1632#define LE_ADV_SCAN_RSP 0x04
57a56fd4
AB
1633
1634#define ADDR_LE_DEV_PUBLIC 0x00
1635#define ADDR_LE_DEV_RANDOM 0x01
1636
1637#define HCI_EV_LE_ADVERTISING_REPORT 0x02
1638struct hci_ev_le_advertising_info {
1639 __u8 evt_type;
1640 __u8 bdaddr_type;
1641 bdaddr_t bdaddr;
1642 __u8 length;
1643 __u8 data[0];
1644} __packed;
1645
1da177e4 1646/* Internal events generated by Bluetooth stack */
a9de9248 1647#define HCI_EV_STACK_INTERNAL 0xfd
1da177e4
LT
1648struct hci_ev_stack_internal {
1649 __u16 type;
1650 __u8 data[0];
66c853cc 1651} __packed;
1da177e4 1652
a9de9248 1653#define HCI_EV_SI_DEVICE 0x01
1da177e4
LT
1654struct hci_ev_si_device {
1655 __u16 event;
1656 __u16 dev_id;
66c853cc 1657} __packed;
1da177e4
LT
1658
1659#define HCI_EV_SI_SECURITY 0x02
1660struct hci_ev_si_security {
1661 __u16 event;
1662 __u16 proto;
1663 __u16 subproto;
1664 __u8 incoming;
66c853cc 1665} __packed;
1da177e4
LT
1666
1667/* ---- HCI Packet structures ---- */
1668#define HCI_COMMAND_HDR_SIZE 3
1669#define HCI_EVENT_HDR_SIZE 2
1670#define HCI_ACL_HDR_SIZE 4
1671#define HCI_SCO_HDR_SIZE 3
1672
1673struct hci_command_hdr {
a9de9248 1674 __le16 opcode; /* OCF & OGF */
70f23020 1675 __u8 plen;
66c853cc 1676} __packed;
1da177e4
LT
1677
1678struct hci_event_hdr {
a9de9248
MH
1679 __u8 evt;
1680 __u8 plen;
66c853cc 1681} __packed;
1da177e4
LT
1682
1683struct hci_acl_hdr {
a9de9248
MH
1684 __le16 handle; /* Handle & Flags(PB, BC) */
1685 __le16 dlen;
66c853cc 1686} __packed;
1da177e4
LT
1687
1688struct hci_sco_hdr {
a9de9248
MH
1689 __le16 handle;
1690 __u8 dlen;
66c853cc 1691} __packed;
1da177e4 1692
2a123b86
ACM
1693static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
1694{
a9de9248 1695 return (struct hci_event_hdr *) skb->data;
2a123b86
ACM
1696}
1697
1698static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
1699{
a9de9248 1700 return (struct hci_acl_hdr *) skb->data;
2a123b86
ACM
1701}
1702
1703static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
1704{
a9de9248 1705 return (struct hci_sco_hdr *) skb->data;
2a123b86 1706}
2a123b86 1707
1da177e4 1708/* Command opcode pack/unpack */
c3c7ea65 1709#define hci_opcode_pack(ogf, ocf) ((__u16) ((ocf & 0x03ff)|(ogf << 10)))
1da177e4
LT
1710#define hci_opcode_ogf(op) (op >> 10)
1711#define hci_opcode_ocf(op) (op & 0x03ff)
1712
1713/* ACL handle and flags pack/unpack */
c3c7ea65 1714#define hci_handle_pack(h, f) ((__u16) ((h & 0x0fff)|(f << 12)))
1da177e4
LT
1715#define hci_handle(h) (h & 0x0fff)
1716#define hci_flags(h) (h >> 12)
1717
1718/* ---- HCI Sockets ---- */
1719
1720/* Socket options */
1721#define HCI_DATA_DIR 1
1722#define HCI_FILTER 2
1723#define HCI_TIME_STAMP 3
1724
1725/* CMSG flags */
1726#define HCI_CMSG_DIR 0x0001
1727#define HCI_CMSG_TSTAMP 0x0002
1728
1729struct sockaddr_hci {
1730 sa_family_t hci_family;
1731 unsigned short hci_dev;
c02178d2 1732 unsigned short hci_channel;
1da177e4
LT
1733};
1734#define HCI_DEV_NONE 0xffff
1735
c02178d2 1736#define HCI_CHANNEL_RAW 0
23500189 1737#define HCI_CHANNEL_USER 1
cd82e61c 1738#define HCI_CHANNEL_MONITOR 2
66f3b913 1739#define HCI_CHANNEL_CONTROL 3
c02178d2 1740
1da177e4
LT
1741struct hci_filter {
1742 unsigned long type_mask;
1743 unsigned long event_mask[2];
a9de9248 1744 __le16 opcode;
1da177e4
LT
1745};
1746
1747struct hci_ufilter {
a9de9248
MH
1748 __u32 type_mask;
1749 __u32 event_mask[2];
1750 __le16 opcode;
1da177e4
LT
1751};
1752
1753#define HCI_FLT_TYPE_BITS 31
1754#define HCI_FLT_EVENT_BITS 63
1755#define HCI_FLT_OGF_BITS 63
1756#define HCI_FLT_OCF_BITS 127
1757
1758/* ---- HCI Ioctl requests structures ---- */
1759struct hci_dev_stats {
1760 __u32 err_rx;
1761 __u32 err_tx;
1762 __u32 cmd_tx;
1763 __u32 evt_rx;
1764 __u32 acl_tx;
1765 __u32 acl_rx;
1766 __u32 sco_tx;
1767 __u32 sco_rx;
1768 __u32 byte_rx;
1769 __u32 byte_tx;
1770};
1771
1772struct hci_dev_info {
1773 __u16 dev_id;
1774 char name[8];
1775
1776 bdaddr_t bdaddr;
1777
1778 __u32 flags;
1779 __u8 type;
1780
1781 __u8 features[8];
1782
1783 __u32 pkt_type;
1784 __u32 link_policy;
1785 __u32 link_mode;
1786
1787 __u16 acl_mtu;
1788 __u16 acl_pkts;
1789 __u16 sco_mtu;
1790 __u16 sco_pkts;
1791
1792 struct hci_dev_stats stat;
1793};
1794
1795struct hci_conn_info {
1796 __u16 handle;
1797 bdaddr_t bdaddr;
a9de9248
MH
1798 __u8 type;
1799 __u8 out;
1800 __u16 state;
1801 __u32 link_mode;
1da177e4
LT
1802};
1803
1804struct hci_dev_req {
a9de9248
MH
1805 __u16 dev_id;
1806 __u32 dev_opt;
1da177e4
LT
1807};
1808
1809struct hci_dev_list_req {
1810 __u16 dev_num;
1811 struct hci_dev_req dev_req[0]; /* hci_dev_req structures */
1812};
1813
1814struct hci_conn_list_req {
1815 __u16 dev_id;
1816 __u16 conn_num;
1817 struct hci_conn_info conn_info[0];
1818};
1819
1820struct hci_conn_info_req {
1821 bdaddr_t bdaddr;
1822 __u8 type;
1823 struct hci_conn_info conn_info[0];
1824};
1825
40be492f
MH
1826struct hci_auth_info_req {
1827 bdaddr_t bdaddr;
1828 __u8 type;
1829};
1830
1da177e4
LT
1831struct hci_inquiry_req {
1832 __u16 dev_id;
1833 __u16 flags;
1834 __u8 lap[3];
1835 __u8 length;
1836 __u8 num_rsp;
1837};
1838#define IREQ_CACHE_FLUSH 0x0001
1839
1840#endif /* __HCI_H */