]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - include/net/bluetooth/hci.h
b59971c5cb71c2659ae278f0742cc3b28d745eaa
[karo-tx-linux.git] / include / net / bluetooth / hci.h
1 /*
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
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
18    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20    ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21    COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
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
33 #define HCI_LINK_KEY_SIZE       16
34 #define HCI_AMP_LINK_KEY_SIZE   (2 * HCI_LINK_KEY_SIZE)
35
36 #define HCI_MAX_AMP_ASSOC_SIZE  672
37
38 #define HCI_MAX_CSB_DATA_SIZE   252
39
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 #define HCI_DEV_OPEN                    7
48 #define HCI_DEV_CLOSE                   8
49
50 /* HCI notify events */
51 #define HCI_NOTIFY_CONN_ADD             1
52 #define HCI_NOTIFY_CONN_DEL             2
53 #define HCI_NOTIFY_VOICE_SETTING        3
54
55 /* HCI bus types */
56 #define HCI_VIRTUAL     0
57 #define HCI_USB         1
58 #define HCI_PCCARD      2
59 #define HCI_UART        3
60 #define HCI_RS232       4
61 #define HCI_PCI         5
62 #define HCI_SDIO        6
63
64 /* HCI controller types */
65 #define HCI_BREDR       0x00
66 #define HCI_AMP         0x01
67
68 /* First BR/EDR Controller shall have ID = 0 */
69 #define AMP_ID_BREDR    0x00
70
71 /* AMP controller types */
72 #define AMP_TYPE_BREDR  0x00
73 #define AMP_TYPE_80211  0x01
74
75 /* AMP controller status */
76 #define AMP_STATUS_POWERED_DOWN                 0x00
77 #define AMP_STATUS_BLUETOOTH_ONLY               0x01
78 #define AMP_STATUS_NO_CAPACITY                  0x02
79 #define AMP_STATUS_LOW_CAPACITY                 0x03
80 #define AMP_STATUS_MEDIUM_CAPACITY              0x04
81 #define AMP_STATUS_HIGH_CAPACITY                0x05
82 #define AMP_STATUS_FULL_CAPACITY                0x06
83
84 /* HCI device quirks */
85 enum {
86         /* When this quirk is set, the HCI Reset command is send when
87          * closing the transport instead of when opening it.
88          *
89          * This quirk must be set before hci_register_dev is called.
90          */
91         HCI_QUIRK_RESET_ON_CLOSE,
92
93         /* When this quirk is set, the device is turned into a raw-only
94          * device and it will stay in unconfigured state.
95          *
96          * This quirk must be set before hci_register_dev is called.
97          */
98         HCI_QUIRK_RAW_DEVICE,
99
100         /* When this quirk is set, the buffer sizes reported by
101          * HCI Read Buffer Size command are corrected if invalid.
102          *
103          * This quirk must be set before hci_register_dev is called.
104          */
105         HCI_QUIRK_FIXUP_BUFFER_SIZE,
106
107         /* When this quirk is set, then a controller that does not
108          * indicate support for Inquiry Result with RSSI is assumed to
109          * support it anyway. Some early Bluetooth 1.2 controllers had
110          * wrongly configured local features that will require forcing
111          * them to enable this mode. Getting RSSI information with the
112          * inquiry responses is preferred since it allows for a better
113          * user expierence.
114          *
115          * This quirk must be set before hci_register_dev is called.
116          */
117         HCI_QUIRK_FIXUP_INQUIRY_MODE,
118
119         /* When this quirk is set, then the HCI Read Local Supported
120          * Commands command is not supported. In general Bluetooth 1.2
121          * and later controllers should support this command. However
122          * some controllers indicate Bluetooth 1.2 support, but do
123          * not support this command.
124          *
125          * This quirk must be set before hci_register_dev is called.
126          */
127         HCI_QUIRK_BROKEN_LOCAL_COMMANDS,
128
129         /* When this quirk is set, then no stored link key handling
130          * is performed. This is mainly due to the fact that the
131          * HCI Delete Stored Link Key command is advertised, but
132          * not supported.
133          *
134          * This quirk must be set before hci_register_dev is called.
135          */
136         HCI_QUIRK_BROKEN_STORED_LINK_KEY,
137
138         /* When this quirk is set, an external configuration step
139          * is required and will be indicated with the controller
140          * configuation.
141          *
142          * This quirk can be set before hci_register_dev is called or
143          * during the hdev->setup vendor callback.
144          */
145         HCI_QUIRK_EXTERNAL_CONFIG,
146
147         /* When this quirk is set, the public Bluetooth address
148          * initially reported by HCI Read BD Address command
149          * is considered invalid. Controller configuration is
150          * required before this device can be used.
151          *
152          * This quirk can be set before hci_register_dev is called or
153          * during the hdev->setup vendor callback.
154          */
155         HCI_QUIRK_INVALID_BDADDR,
156
157         /* When this quirk is set, the duplicate filtering during
158          * scanning is based on Bluetooth devices addresses. To allow
159          * RSSI based updates, restart scanning if needed.
160          *
161          * This quirk can be set before hci_register_dev is called or
162          * during the hdev->setup vendor callback.
163          */
164         HCI_QUIRK_STRICT_DUPLICATE_FILTER,
165
166         /* When this quirk is set, LE scan and BR/EDR inquiry is done
167          * simultaneously, otherwise it's interleaved.
168          *
169          * This quirk can be set before hci_register_dev is called or
170          * during the hdev->setup vendor callback.
171          */
172         HCI_QUIRK_SIMULTANEOUS_DISCOVERY,
173
174         /* When this quirk is set, the enabling of diagnostic mode is
175          * not persistent over HCI Reset. Every time the controller
176          * is brought up it needs to be reprogrammed.
177          *
178          * This quirk can be set before hci_register_dev is called or
179          * during the hdev->setup vendor callback.
180          */
181         HCI_QUIRK_NON_PERSISTENT_DIAG,
182 };
183
184 /* HCI device flags */
185 enum {
186         HCI_UP,
187         HCI_INIT,
188         HCI_RUNNING,
189
190         HCI_PSCAN,
191         HCI_ISCAN,
192         HCI_AUTH,
193         HCI_ENCRYPT,
194         HCI_INQUIRY,
195
196         HCI_RAW,
197
198         HCI_RESET,
199 };
200
201 /* HCI socket flags */
202 enum {
203         HCI_SOCK_TRUSTED,
204         HCI_MGMT_INDEX_EVENTS,
205         HCI_MGMT_UNCONF_INDEX_EVENTS,
206         HCI_MGMT_EXT_INDEX_EVENTS,
207         HCI_MGMT_GENERIC_EVENTS,
208         HCI_MGMT_OOB_DATA_EVENTS,
209 };
210
211 /*
212  * BR/EDR and/or LE controller flags: the flags defined here should represent
213  * states from the controller.
214  */
215 enum {
216         HCI_SETUP,
217         HCI_CONFIG,
218         HCI_AUTO_OFF,
219         HCI_RFKILLED,
220         HCI_MGMT,
221         HCI_BONDABLE,
222         HCI_SERVICE_CACHE,
223         HCI_KEEP_DEBUG_KEYS,
224         HCI_USE_DEBUG_KEYS,
225         HCI_UNREGISTER,
226         HCI_UNCONFIGURED,
227         HCI_USER_CHANNEL,
228         HCI_EXT_CONFIGURED,
229         HCI_LE_ADV,
230         HCI_LE_SCAN,
231         HCI_SSP_ENABLED,
232         HCI_SC_ENABLED,
233         HCI_SC_ONLY,
234         HCI_PRIVACY,
235         HCI_RPA_EXPIRED,
236         HCI_RPA_RESOLVING,
237         HCI_HS_ENABLED,
238         HCI_LE_ENABLED,
239         HCI_ADVERTISING,
240         HCI_ADVERTISING_CONNECTABLE,
241         HCI_ADVERTISING_INSTANCE,
242         HCI_CONNECTABLE,
243         HCI_DISCOVERABLE,
244         HCI_LIMITED_DISCOVERABLE,
245         HCI_LINK_SECURITY,
246         HCI_PERIODIC_INQ,
247         HCI_FAST_CONNECTABLE,
248         HCI_BREDR_ENABLED,
249         HCI_LE_SCAN_INTERRUPTED,
250
251         HCI_DUT_MODE,
252         HCI_VENDOR_DIAG,
253         HCI_FORCE_BREDR_SMP,
254         HCI_FORCE_STATIC_ADDR,
255
256         __HCI_NUM_FLAGS,
257 };
258
259 /* HCI timeouts */
260 #define HCI_DISCONN_TIMEOUT     msecs_to_jiffies(2000)  /* 2 seconds */
261 #define HCI_PAIRING_TIMEOUT     msecs_to_jiffies(60000) /* 60 seconds */
262 #define HCI_INIT_TIMEOUT        msecs_to_jiffies(10000) /* 10 seconds */
263 #define HCI_CMD_TIMEOUT         msecs_to_jiffies(2000)  /* 2 seconds */
264 #define HCI_ACL_TX_TIMEOUT      msecs_to_jiffies(45000) /* 45 seconds */
265 #define HCI_AUTO_OFF_TIMEOUT    msecs_to_jiffies(2000)  /* 2 seconds */
266 #define HCI_POWER_OFF_TIMEOUT   msecs_to_jiffies(5000)  /* 5 seconds */
267 #define HCI_LE_CONN_TIMEOUT     msecs_to_jiffies(20000) /* 20 seconds */
268 #define HCI_LE_AUTOCONN_TIMEOUT msecs_to_jiffies(2000)  /* 2 seconds */
269
270 /* HCI data types */
271 #define HCI_COMMAND_PKT         0x01
272 #define HCI_ACLDATA_PKT         0x02
273 #define HCI_SCODATA_PKT         0x03
274 #define HCI_EVENT_PKT           0x04
275 #define HCI_DIAG_PKT            0xf0
276 #define HCI_VENDOR_PKT          0xff
277
278 /* HCI packet types */
279 #define HCI_DM1         0x0008
280 #define HCI_DM3         0x0400
281 #define HCI_DM5         0x4000
282 #define HCI_DH1         0x0010
283 #define HCI_DH3         0x0800
284 #define HCI_DH5         0x8000
285
286 #define HCI_HV1         0x0020
287 #define HCI_HV2         0x0040
288 #define HCI_HV3         0x0080
289
290 #define SCO_PTYPE_MASK  (HCI_HV1 | HCI_HV2 | HCI_HV3)
291 #define ACL_PTYPE_MASK  (~SCO_PTYPE_MASK)
292
293 /* eSCO packet types */
294 #define ESCO_HV1        0x0001
295 #define ESCO_HV2        0x0002
296 #define ESCO_HV3        0x0004
297 #define ESCO_EV3        0x0008
298 #define ESCO_EV4        0x0010
299 #define ESCO_EV5        0x0020
300 #define ESCO_2EV3       0x0040
301 #define ESCO_3EV3       0x0080
302 #define ESCO_2EV5       0x0100
303 #define ESCO_3EV5       0x0200
304
305 #define SCO_ESCO_MASK  (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
306 #define EDR_ESCO_MASK  (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
307
308 /* ACL flags */
309 #define ACL_START_NO_FLUSH      0x00
310 #define ACL_CONT                0x01
311 #define ACL_START               0x02
312 #define ACL_COMPLETE            0x03
313 #define ACL_ACTIVE_BCAST        0x04
314 #define ACL_PICO_BCAST          0x08
315
316 /* Baseband links */
317 #define SCO_LINK        0x00
318 #define ACL_LINK        0x01
319 #define ESCO_LINK       0x02
320 /* Low Energy links do not have defined link type. Use invented one */
321 #define LE_LINK         0x80
322 #define AMP_LINK        0x81
323 #define INVALID_LINK    0xff
324
325 /* LMP features */
326 #define LMP_3SLOT       0x01
327 #define LMP_5SLOT       0x02
328 #define LMP_ENCRYPT     0x04
329 #define LMP_SOFFSET     0x08
330 #define LMP_TACCURACY   0x10
331 #define LMP_RSWITCH     0x20
332 #define LMP_HOLD        0x40
333 #define LMP_SNIFF       0x80
334
335 #define LMP_PARK        0x01
336 #define LMP_RSSI        0x02
337 #define LMP_QUALITY     0x04
338 #define LMP_SCO         0x08
339 #define LMP_HV2         0x10
340 #define LMP_HV3         0x20
341 #define LMP_ULAW        0x40
342 #define LMP_ALAW        0x80
343
344 #define LMP_CVSD        0x01
345 #define LMP_PSCHEME     0x02
346 #define LMP_PCONTROL    0x04
347 #define LMP_TRANSPARENT 0x08
348
349 #define LMP_RSSI_INQ    0x40
350 #define LMP_ESCO        0x80
351
352 #define LMP_EV4         0x01
353 #define LMP_EV5         0x02
354 #define LMP_NO_BREDR    0x20
355 #define LMP_LE          0x40
356
357 #define LMP_SNIFF_SUBR  0x02
358 #define LMP_PAUSE_ENC   0x04
359 #define LMP_EDR_ESCO_2M 0x20
360 #define LMP_EDR_ESCO_3M 0x40
361 #define LMP_EDR_3S_ESCO 0x80
362
363 #define LMP_EXT_INQ     0x01
364 #define LMP_SIMUL_LE_BR 0x02
365 #define LMP_SIMPLE_PAIR 0x08
366 #define LMP_NO_FLUSH    0x40
367
368 #define LMP_LSTO        0x01
369 #define LMP_INQ_TX_PWR  0x02
370 #define LMP_EXTFEATURES 0x80
371
372 /* Extended LMP features */
373 #define LMP_CSB_MASTER  0x01
374 #define LMP_CSB_SLAVE   0x02
375 #define LMP_SYNC_TRAIN  0x04
376 #define LMP_SYNC_SCAN   0x08
377
378 #define LMP_SC          0x01
379 #define LMP_PING        0x02
380
381 /* Host features */
382 #define LMP_HOST_SSP            0x01
383 #define LMP_HOST_LE             0x02
384 #define LMP_HOST_LE_BREDR       0x04
385 #define LMP_HOST_SC             0x08
386
387 /* LE features */
388 #define HCI_LE_ENCRYPTION               0x01
389 #define HCI_LE_CONN_PARAM_REQ_PROC      0x02
390 #define HCI_LE_SLAVE_FEATURES           0x08
391 #define HCI_LE_PING                     0x10
392 #define HCI_LE_DATA_LEN_EXT             0x20
393 #define HCI_LE_EXT_SCAN_POLICY          0x80
394
395 /* Connection modes */
396 #define HCI_CM_ACTIVE   0x0000
397 #define HCI_CM_HOLD     0x0001
398 #define HCI_CM_SNIFF    0x0002
399 #define HCI_CM_PARK     0x0003
400
401 /* Link policies */
402 #define HCI_LP_RSWITCH  0x0001
403 #define HCI_LP_HOLD     0x0002
404 #define HCI_LP_SNIFF    0x0004
405 #define HCI_LP_PARK     0x0008
406
407 /* Link modes */
408 #define HCI_LM_ACCEPT   0x8000
409 #define HCI_LM_MASTER   0x0001
410 #define HCI_LM_AUTH     0x0002
411 #define HCI_LM_ENCRYPT  0x0004
412 #define HCI_LM_TRUSTED  0x0008
413 #define HCI_LM_RELIABLE 0x0010
414 #define HCI_LM_SECURE   0x0020
415 #define HCI_LM_FIPS     0x0040
416
417 /* Authentication types */
418 #define HCI_AT_NO_BONDING               0x00
419 #define HCI_AT_NO_BONDING_MITM          0x01
420 #define HCI_AT_DEDICATED_BONDING        0x02
421 #define HCI_AT_DEDICATED_BONDING_MITM   0x03
422 #define HCI_AT_GENERAL_BONDING          0x04
423 #define HCI_AT_GENERAL_BONDING_MITM     0x05
424
425 /* I/O capabilities */
426 #define HCI_IO_DISPLAY_ONLY     0x00
427 #define HCI_IO_DISPLAY_YESNO    0x01
428 #define HCI_IO_KEYBOARD_ONLY    0x02
429 #define HCI_IO_NO_INPUT_OUTPUT  0x03
430
431 /* Link Key types */
432 #define HCI_LK_COMBINATION              0x00
433 #define HCI_LK_LOCAL_UNIT               0x01
434 #define HCI_LK_REMOTE_UNIT              0x02
435 #define HCI_LK_DEBUG_COMBINATION        0x03
436 #define HCI_LK_UNAUTH_COMBINATION_P192  0x04
437 #define HCI_LK_AUTH_COMBINATION_P192    0x05
438 #define HCI_LK_CHANGED_COMBINATION      0x06
439 #define HCI_LK_UNAUTH_COMBINATION_P256  0x07
440 #define HCI_LK_AUTH_COMBINATION_P256    0x08
441
442 /* ---- HCI Error Codes ---- */
443 #define HCI_ERROR_UNKNOWN_CONN_ID       0x02
444 #define HCI_ERROR_AUTH_FAILURE          0x05
445 #define HCI_ERROR_MEMORY_EXCEEDED       0x07
446 #define HCI_ERROR_CONNECTION_TIMEOUT    0x08
447 #define HCI_ERROR_REJ_LIMITED_RESOURCES 0x0d
448 #define HCI_ERROR_REJ_BAD_ADDR          0x0f
449 #define HCI_ERROR_REMOTE_USER_TERM      0x13
450 #define HCI_ERROR_REMOTE_LOW_RESOURCES  0x14
451 #define HCI_ERROR_REMOTE_POWER_OFF      0x15
452 #define HCI_ERROR_LOCAL_HOST_TERM       0x16
453 #define HCI_ERROR_PAIRING_NOT_ALLOWED   0x18
454 #define HCI_ERROR_INVALID_LL_PARAMS     0x1E
455 #define HCI_ERROR_ADVERTISING_TIMEOUT   0x3c
456
457 /* Flow control modes */
458 #define HCI_FLOW_CTL_MODE_PACKET_BASED  0x00
459 #define HCI_FLOW_CTL_MODE_BLOCK_BASED   0x01
460
461 /* The core spec defines 127 as the "not available" value */
462 #define HCI_TX_POWER_INVALID    127
463 #define HCI_RSSI_INVALID        127
464
465 #define HCI_ROLE_MASTER         0x00
466 #define HCI_ROLE_SLAVE          0x01
467
468 /* Extended Inquiry Response field types */
469 #define EIR_FLAGS               0x01 /* flags */
470 #define EIR_UUID16_SOME         0x02 /* 16-bit UUID, more available */
471 #define EIR_UUID16_ALL          0x03 /* 16-bit UUID, all listed */
472 #define EIR_UUID32_SOME         0x04 /* 32-bit UUID, more available */
473 #define EIR_UUID32_ALL          0x05 /* 32-bit UUID, all listed */
474 #define EIR_UUID128_SOME        0x06 /* 128-bit UUID, more available */
475 #define EIR_UUID128_ALL         0x07 /* 128-bit UUID, all listed */
476 #define EIR_NAME_SHORT          0x08 /* shortened local name */
477 #define EIR_NAME_COMPLETE       0x09 /* complete local name */
478 #define EIR_TX_POWER            0x0A /* transmit power level */
479 #define EIR_CLASS_OF_DEV        0x0D /* Class of Device */
480 #define EIR_SSP_HASH_C192       0x0E /* Simple Pairing Hash C-192 */
481 #define EIR_SSP_RAND_R192       0x0F /* Simple Pairing Randomizer R-192 */
482 #define EIR_DEVICE_ID           0x10 /* device ID */
483 #define EIR_APPEARANCE          0x19 /* Device appearance */
484 #define EIR_LE_BDADDR           0x1B /* LE Bluetooth device address */
485 #define EIR_LE_ROLE             0x1C /* LE role */
486 #define EIR_SSP_HASH_C256       0x1D /* Simple Pairing Hash C-256 */
487 #define EIR_SSP_RAND_R256       0x1E /* Simple Pairing Rand R-256 */
488 #define EIR_LE_SC_CONFIRM       0x22 /* LE SC Confirmation Value */
489 #define EIR_LE_SC_RANDOM        0x23 /* LE SC Random Value */
490
491 /* Low Energy Advertising Flags */
492 #define LE_AD_LIMITED           0x01 /* Limited Discoverable */
493 #define LE_AD_GENERAL           0x02 /* General Discoverable */
494 #define LE_AD_NO_BREDR          0x04 /* BR/EDR not supported */
495 #define LE_AD_SIM_LE_BREDR_CTRL 0x08 /* Simultaneous LE & BR/EDR Controller */
496 #define LE_AD_SIM_LE_BREDR_HOST 0x10 /* Simultaneous LE & BR/EDR Host */
497
498 /* -----  HCI Commands ---- */
499 #define HCI_OP_NOP                      0x0000
500
501 #define HCI_OP_INQUIRY                  0x0401
502 struct hci_cp_inquiry {
503         __u8     lap[3];
504         __u8     length;
505         __u8     num_rsp;
506 } __packed;
507
508 #define HCI_OP_INQUIRY_CANCEL           0x0402
509
510 #define HCI_OP_PERIODIC_INQ             0x0403
511
512 #define HCI_OP_EXIT_PERIODIC_INQ        0x0404
513
514 #define HCI_OP_CREATE_CONN              0x0405
515 struct hci_cp_create_conn {
516         bdaddr_t bdaddr;
517         __le16   pkt_type;
518         __u8     pscan_rep_mode;
519         __u8     pscan_mode;
520         __le16   clock_offset;
521         __u8     role_switch;
522 } __packed;
523
524 #define HCI_OP_DISCONNECT               0x0406
525 struct hci_cp_disconnect {
526         __le16   handle;
527         __u8     reason;
528 } __packed;
529
530 #define HCI_OP_ADD_SCO                  0x0407
531 struct hci_cp_add_sco {
532         __le16   handle;
533         __le16   pkt_type;
534 } __packed;
535
536 #define HCI_OP_CREATE_CONN_CANCEL       0x0408
537 struct hci_cp_create_conn_cancel {
538         bdaddr_t bdaddr;
539 } __packed;
540
541 #define HCI_OP_ACCEPT_CONN_REQ          0x0409
542 struct hci_cp_accept_conn_req {
543         bdaddr_t bdaddr;
544         __u8     role;
545 } __packed;
546
547 #define HCI_OP_REJECT_CONN_REQ          0x040a
548 struct hci_cp_reject_conn_req {
549         bdaddr_t bdaddr;
550         __u8     reason;
551 } __packed;
552
553 #define HCI_OP_LINK_KEY_REPLY           0x040b
554 struct hci_cp_link_key_reply {
555         bdaddr_t bdaddr;
556         __u8     link_key[HCI_LINK_KEY_SIZE];
557 } __packed;
558
559 #define HCI_OP_LINK_KEY_NEG_REPLY       0x040c
560 struct hci_cp_link_key_neg_reply {
561         bdaddr_t bdaddr;
562 } __packed;
563
564 #define HCI_OP_PIN_CODE_REPLY           0x040d
565 struct hci_cp_pin_code_reply {
566         bdaddr_t bdaddr;
567         __u8     pin_len;
568         __u8     pin_code[16];
569 } __packed;
570 struct hci_rp_pin_code_reply {
571         __u8     status;
572         bdaddr_t bdaddr;
573 } __packed;
574
575 #define HCI_OP_PIN_CODE_NEG_REPLY       0x040e
576 struct hci_cp_pin_code_neg_reply {
577         bdaddr_t bdaddr;
578 } __packed;
579 struct hci_rp_pin_code_neg_reply {
580         __u8     status;
581         bdaddr_t bdaddr;
582 } __packed;
583
584 #define HCI_OP_CHANGE_CONN_PTYPE        0x040f
585 struct hci_cp_change_conn_ptype {
586         __le16   handle;
587         __le16   pkt_type;
588 } __packed;
589
590 #define HCI_OP_AUTH_REQUESTED           0x0411
591 struct hci_cp_auth_requested {
592         __le16   handle;
593 } __packed;
594
595 #define HCI_OP_SET_CONN_ENCRYPT         0x0413
596 struct hci_cp_set_conn_encrypt {
597         __le16   handle;
598         __u8     encrypt;
599 } __packed;
600
601 #define HCI_OP_CHANGE_CONN_LINK_KEY     0x0415
602 struct hci_cp_change_conn_link_key {
603         __le16   handle;
604 } __packed;
605
606 #define HCI_OP_REMOTE_NAME_REQ          0x0419
607 struct hci_cp_remote_name_req {
608         bdaddr_t bdaddr;
609         __u8     pscan_rep_mode;
610         __u8     pscan_mode;
611         __le16   clock_offset;
612 } __packed;
613
614 #define HCI_OP_REMOTE_NAME_REQ_CANCEL   0x041a
615 struct hci_cp_remote_name_req_cancel {
616         bdaddr_t bdaddr;
617 } __packed;
618
619 #define HCI_OP_READ_REMOTE_FEATURES     0x041b
620 struct hci_cp_read_remote_features {
621         __le16   handle;
622 } __packed;
623
624 #define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c
625 struct hci_cp_read_remote_ext_features {
626         __le16   handle;
627         __u8     page;
628 } __packed;
629
630 #define HCI_OP_READ_REMOTE_VERSION      0x041d
631 struct hci_cp_read_remote_version {
632         __le16   handle;
633 } __packed;
634
635 #define HCI_OP_READ_CLOCK_OFFSET        0x041f
636 struct hci_cp_read_clock_offset {
637         __le16   handle;
638 } __packed;
639
640 #define HCI_OP_SETUP_SYNC_CONN          0x0428
641 struct hci_cp_setup_sync_conn {
642         __le16   handle;
643         __le32   tx_bandwidth;
644         __le32   rx_bandwidth;
645         __le16   max_latency;
646         __le16   voice_setting;
647         __u8     retrans_effort;
648         __le16   pkt_type;
649 } __packed;
650
651 #define HCI_OP_ACCEPT_SYNC_CONN_REQ     0x0429
652 struct hci_cp_accept_sync_conn_req {
653         bdaddr_t bdaddr;
654         __le32   tx_bandwidth;
655         __le32   rx_bandwidth;
656         __le16   max_latency;
657         __le16   content_format;
658         __u8     retrans_effort;
659         __le16   pkt_type;
660 } __packed;
661
662 #define HCI_OP_REJECT_SYNC_CONN_REQ     0x042a
663 struct hci_cp_reject_sync_conn_req {
664         bdaddr_t bdaddr;
665         __u8     reason;
666 } __packed;
667
668 #define HCI_OP_IO_CAPABILITY_REPLY      0x042b
669 struct hci_cp_io_capability_reply {
670         bdaddr_t bdaddr;
671         __u8     capability;
672         __u8     oob_data;
673         __u8     authentication;
674 } __packed;
675
676 #define HCI_OP_USER_CONFIRM_REPLY               0x042c
677 struct hci_cp_user_confirm_reply {
678         bdaddr_t bdaddr;
679 } __packed;
680 struct hci_rp_user_confirm_reply {
681         __u8     status;
682         bdaddr_t bdaddr;
683 } __packed;
684
685 #define HCI_OP_USER_CONFIRM_NEG_REPLY   0x042d
686
687 #define HCI_OP_USER_PASSKEY_REPLY               0x042e
688 struct hci_cp_user_passkey_reply {
689         bdaddr_t bdaddr;
690         __le32  passkey;
691 } __packed;
692
693 #define HCI_OP_USER_PASSKEY_NEG_REPLY   0x042f
694
695 #define HCI_OP_REMOTE_OOB_DATA_REPLY    0x0430
696 struct hci_cp_remote_oob_data_reply {
697         bdaddr_t bdaddr;
698         __u8     hash[16];
699         __u8     rand[16];
700 } __packed;
701
702 #define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY        0x0433
703 struct hci_cp_remote_oob_data_neg_reply {
704         bdaddr_t bdaddr;
705 } __packed;
706
707 #define HCI_OP_IO_CAPABILITY_NEG_REPLY  0x0434
708 struct hci_cp_io_capability_neg_reply {
709         bdaddr_t bdaddr;
710         __u8     reason;
711 } __packed;
712
713 #define HCI_OP_CREATE_PHY_LINK          0x0435
714 struct hci_cp_create_phy_link {
715         __u8     phy_handle;
716         __u8     key_len;
717         __u8     key_type;
718         __u8     key[HCI_AMP_LINK_KEY_SIZE];
719 } __packed;
720
721 #define HCI_OP_ACCEPT_PHY_LINK          0x0436
722 struct hci_cp_accept_phy_link {
723         __u8     phy_handle;
724         __u8     key_len;
725         __u8     key_type;
726         __u8     key[HCI_AMP_LINK_KEY_SIZE];
727 } __packed;
728
729 #define HCI_OP_DISCONN_PHY_LINK         0x0437
730 struct hci_cp_disconn_phy_link {
731         __u8     phy_handle;
732         __u8     reason;
733 } __packed;
734
735 struct ext_flow_spec {
736         __u8       id;
737         __u8       stype;
738         __le16     msdu;
739         __le32     sdu_itime;
740         __le32     acc_lat;
741         __le32     flush_to;
742 } __packed;
743
744 #define HCI_OP_CREATE_LOGICAL_LINK      0x0438
745 #define HCI_OP_ACCEPT_LOGICAL_LINK      0x0439
746 struct hci_cp_create_accept_logical_link {
747         __u8                  phy_handle;
748         struct ext_flow_spec  tx_flow_spec;
749         struct ext_flow_spec  rx_flow_spec;
750 } __packed;
751
752 #define HCI_OP_DISCONN_LOGICAL_LINK     0x043a
753 struct hci_cp_disconn_logical_link {
754         __le16   log_handle;
755 } __packed;
756
757 #define HCI_OP_LOGICAL_LINK_CANCEL      0x043b
758 struct hci_cp_logical_link_cancel {
759         __u8     phy_handle;
760         __u8     flow_spec_id;
761 } __packed;
762
763 struct hci_rp_logical_link_cancel {
764         __u8     status;
765         __u8     phy_handle;
766         __u8     flow_spec_id;
767 } __packed;
768
769 #define HCI_OP_SET_CSB                  0x0441
770 struct hci_cp_set_csb {
771         __u8    enable;
772         __u8    lt_addr;
773         __u8    lpo_allowed;
774         __le16  packet_type;
775         __le16  interval_min;
776         __le16  interval_max;
777         __le16  csb_sv_tout;
778 } __packed;
779 struct hci_rp_set_csb {
780         __u8    status;
781         __u8    lt_addr;
782         __le16  interval;
783 } __packed;
784
785 #define HCI_OP_START_SYNC_TRAIN         0x0443
786
787 #define HCI_OP_REMOTE_OOB_EXT_DATA_REPLY        0x0445
788 struct hci_cp_remote_oob_ext_data_reply {
789         bdaddr_t bdaddr;
790         __u8     hash192[16];
791         __u8     rand192[16];
792         __u8     hash256[16];
793         __u8     rand256[16];
794 } __packed;
795
796 #define HCI_OP_SNIFF_MODE               0x0803
797 struct hci_cp_sniff_mode {
798         __le16   handle;
799         __le16   max_interval;
800         __le16   min_interval;
801         __le16   attempt;
802         __le16   timeout;
803 } __packed;
804
805 #define HCI_OP_EXIT_SNIFF_MODE          0x0804
806 struct hci_cp_exit_sniff_mode {
807         __le16   handle;
808 } __packed;
809
810 #define HCI_OP_ROLE_DISCOVERY           0x0809
811 struct hci_cp_role_discovery {
812         __le16   handle;
813 } __packed;
814 struct hci_rp_role_discovery {
815         __u8     status;
816         __le16   handle;
817         __u8     role;
818 } __packed;
819
820 #define HCI_OP_SWITCH_ROLE              0x080b
821 struct hci_cp_switch_role {
822         bdaddr_t bdaddr;
823         __u8     role;
824 } __packed;
825
826 #define HCI_OP_READ_LINK_POLICY         0x080c
827 struct hci_cp_read_link_policy {
828         __le16   handle;
829 } __packed;
830 struct hci_rp_read_link_policy {
831         __u8     status;
832         __le16   handle;
833         __le16   policy;
834 } __packed;
835
836 #define HCI_OP_WRITE_LINK_POLICY        0x080d
837 struct hci_cp_write_link_policy {
838         __le16   handle;
839         __le16   policy;
840 } __packed;
841 struct hci_rp_write_link_policy {
842         __u8     status;
843         __le16   handle;
844 } __packed;
845
846 #define HCI_OP_READ_DEF_LINK_POLICY     0x080e
847 struct hci_rp_read_def_link_policy {
848         __u8     status;
849         __le16   policy;
850 } __packed;
851
852 #define HCI_OP_WRITE_DEF_LINK_POLICY    0x080f
853 struct hci_cp_write_def_link_policy {
854         __le16   policy;
855 } __packed;
856
857 #define HCI_OP_SNIFF_SUBRATE            0x0811
858 struct hci_cp_sniff_subrate {
859         __le16   handle;
860         __le16   max_latency;
861         __le16   min_remote_timeout;
862         __le16   min_local_timeout;
863 } __packed;
864
865 #define HCI_OP_SET_EVENT_MASK           0x0c01
866
867 #define HCI_OP_RESET                    0x0c03
868
869 #define HCI_OP_SET_EVENT_FLT            0x0c05
870 struct hci_cp_set_event_flt {
871         __u8     flt_type;
872         __u8     cond_type;
873         __u8     condition[0];
874 } __packed;
875
876 /* Filter types */
877 #define HCI_FLT_CLEAR_ALL       0x00
878 #define HCI_FLT_INQ_RESULT      0x01
879 #define HCI_FLT_CONN_SETUP      0x02
880
881 /* CONN_SETUP Condition types */
882 #define HCI_CONN_SETUP_ALLOW_ALL        0x00
883 #define HCI_CONN_SETUP_ALLOW_CLASS      0x01
884 #define HCI_CONN_SETUP_ALLOW_BDADDR     0x02
885
886 /* CONN_SETUP Conditions */
887 #define HCI_CONN_SETUP_AUTO_OFF 0x01
888 #define HCI_CONN_SETUP_AUTO_ON  0x02
889
890 #define HCI_OP_READ_STORED_LINK_KEY     0x0c0d
891 struct hci_cp_read_stored_link_key {
892         bdaddr_t bdaddr;
893         __u8     read_all;
894 } __packed;
895 struct hci_rp_read_stored_link_key {
896         __u8     status;
897         __u8     max_keys;
898         __u8     num_keys;
899 } __packed;
900
901 #define HCI_OP_DELETE_STORED_LINK_KEY   0x0c12
902 struct hci_cp_delete_stored_link_key {
903         bdaddr_t bdaddr;
904         __u8     delete_all;
905 } __packed;
906 struct hci_rp_delete_stored_link_key {
907         __u8     status;
908         __u8     num_keys;
909 } __packed;
910
911 #define HCI_MAX_NAME_LENGTH             248
912
913 #define HCI_OP_WRITE_LOCAL_NAME         0x0c13
914 struct hci_cp_write_local_name {
915         __u8     name[HCI_MAX_NAME_LENGTH];
916 } __packed;
917
918 #define HCI_OP_READ_LOCAL_NAME          0x0c14
919 struct hci_rp_read_local_name {
920         __u8     status;
921         __u8     name[HCI_MAX_NAME_LENGTH];
922 } __packed;
923
924 #define HCI_OP_WRITE_CA_TIMEOUT         0x0c16
925
926 #define HCI_OP_WRITE_PG_TIMEOUT         0x0c18
927
928 #define HCI_OP_WRITE_SCAN_ENABLE        0x0c1a
929         #define SCAN_DISABLED           0x00
930         #define SCAN_INQUIRY            0x01
931         #define SCAN_PAGE               0x02
932
933 #define HCI_OP_READ_AUTH_ENABLE         0x0c1f
934
935 #define HCI_OP_WRITE_AUTH_ENABLE        0x0c20
936         #define AUTH_DISABLED           0x00
937         #define AUTH_ENABLED            0x01
938
939 #define HCI_OP_READ_ENCRYPT_MODE        0x0c21
940
941 #define HCI_OP_WRITE_ENCRYPT_MODE       0x0c22
942         #define ENCRYPT_DISABLED        0x00
943         #define ENCRYPT_P2P             0x01
944         #define ENCRYPT_BOTH            0x02
945
946 #define HCI_OP_READ_CLASS_OF_DEV        0x0c23
947 struct hci_rp_read_class_of_dev {
948         __u8     status;
949         __u8     dev_class[3];
950 } __packed;
951
952 #define HCI_OP_WRITE_CLASS_OF_DEV       0x0c24
953 struct hci_cp_write_class_of_dev {
954         __u8     dev_class[3];
955 } __packed;
956
957 #define HCI_OP_READ_VOICE_SETTING       0x0c25
958 struct hci_rp_read_voice_setting {
959         __u8     status;
960         __le16   voice_setting;
961 } __packed;
962
963 #define HCI_OP_WRITE_VOICE_SETTING      0x0c26
964 struct hci_cp_write_voice_setting {
965         __le16   voice_setting;
966 } __packed;
967
968 #define HCI_OP_HOST_BUFFER_SIZE         0x0c33
969 struct hci_cp_host_buffer_size {
970         __le16   acl_mtu;
971         __u8     sco_mtu;
972         __le16   acl_max_pkt;
973         __le16   sco_max_pkt;
974 } __packed;
975
976 #define HCI_OP_READ_NUM_SUPPORTED_IAC   0x0c38
977 struct hci_rp_read_num_supported_iac {
978         __u8    status;
979         __u8    num_iac;
980 } __packed;
981
982 #define HCI_OP_READ_CURRENT_IAC_LAP     0x0c39
983
984 #define HCI_OP_WRITE_CURRENT_IAC_LAP    0x0c3a
985 struct hci_cp_write_current_iac_lap {
986         __u8    num_iac;
987         __u8    iac_lap[6];
988 } __packed;
989
990 #define HCI_OP_WRITE_INQUIRY_MODE       0x0c45
991
992 #define HCI_MAX_EIR_LENGTH              240
993
994 #define HCI_OP_WRITE_EIR                0x0c52
995 struct hci_cp_write_eir {
996         __u8    fec;
997         __u8    data[HCI_MAX_EIR_LENGTH];
998 } __packed;
999
1000 #define HCI_OP_READ_SSP_MODE            0x0c55
1001 struct hci_rp_read_ssp_mode {
1002         __u8     status;
1003         __u8     mode;
1004 } __packed;
1005
1006 #define HCI_OP_WRITE_SSP_MODE           0x0c56
1007 struct hci_cp_write_ssp_mode {
1008         __u8     mode;
1009 } __packed;
1010
1011 #define HCI_OP_READ_LOCAL_OOB_DATA              0x0c57
1012 struct hci_rp_read_local_oob_data {
1013         __u8     status;
1014         __u8     hash[16];
1015         __u8     rand[16];
1016 } __packed;
1017
1018 #define HCI_OP_READ_INQ_RSP_TX_POWER    0x0c58
1019 struct hci_rp_read_inq_rsp_tx_power {
1020         __u8     status;
1021         __s8     tx_power;
1022 } __packed;
1023
1024 #define HCI_OP_SET_EVENT_MASK_PAGE_2    0x0c63
1025
1026 #define HCI_OP_READ_LOCATION_DATA       0x0c64
1027
1028 #define HCI_OP_READ_FLOW_CONTROL_MODE   0x0c66
1029 struct hci_rp_read_flow_control_mode {
1030         __u8     status;
1031         __u8     mode;
1032 } __packed;
1033
1034 #define HCI_OP_WRITE_LE_HOST_SUPPORTED  0x0c6d
1035 struct hci_cp_write_le_host_supported {
1036         __u8    le;
1037         __u8    simul;
1038 } __packed;
1039
1040 #define HCI_OP_SET_RESERVED_LT_ADDR     0x0c74
1041 struct hci_cp_set_reserved_lt_addr {
1042         __u8    lt_addr;
1043 } __packed;
1044 struct hci_rp_set_reserved_lt_addr {
1045         __u8    status;
1046         __u8    lt_addr;
1047 } __packed;
1048
1049 #define HCI_OP_DELETE_RESERVED_LT_ADDR  0x0c75
1050 struct hci_cp_delete_reserved_lt_addr {
1051         __u8    lt_addr;
1052 } __packed;
1053 struct hci_rp_delete_reserved_lt_addr {
1054         __u8    status;
1055         __u8    lt_addr;
1056 } __packed;
1057
1058 #define HCI_OP_SET_CSB_DATA             0x0c76
1059 struct hci_cp_set_csb_data {
1060         __u8    lt_addr;
1061         __u8    fragment;
1062         __u8    data_length;
1063         __u8    data[HCI_MAX_CSB_DATA_SIZE];
1064 } __packed;
1065 struct hci_rp_set_csb_data {
1066         __u8    status;
1067         __u8    lt_addr;
1068 } __packed;
1069
1070 #define HCI_OP_READ_SYNC_TRAIN_PARAMS   0x0c77
1071
1072 #define HCI_OP_WRITE_SYNC_TRAIN_PARAMS  0x0c78
1073 struct hci_cp_write_sync_train_params {
1074         __le16  interval_min;
1075         __le16  interval_max;
1076         __le32  sync_train_tout;
1077         __u8    service_data;
1078 } __packed;
1079 struct hci_rp_write_sync_train_params {
1080         __u8    status;
1081         __le16  sync_train_int;
1082 } __packed;
1083
1084 #define HCI_OP_READ_SC_SUPPORT          0x0c79
1085 struct hci_rp_read_sc_support {
1086         __u8    status;
1087         __u8    support;
1088 } __packed;
1089
1090 #define HCI_OP_WRITE_SC_SUPPORT         0x0c7a
1091 struct hci_cp_write_sc_support {
1092         __u8    support;
1093 } __packed;
1094
1095 #define HCI_OP_READ_LOCAL_OOB_EXT_DATA  0x0c7d
1096 struct hci_rp_read_local_oob_ext_data {
1097         __u8     status;
1098         __u8     hash192[16];
1099         __u8     rand192[16];
1100         __u8     hash256[16];
1101         __u8     rand256[16];
1102 } __packed;
1103
1104 #define HCI_OP_READ_LOCAL_VERSION       0x1001
1105 struct hci_rp_read_local_version {
1106         __u8     status;
1107         __u8     hci_ver;
1108         __le16   hci_rev;
1109         __u8     lmp_ver;
1110         __le16   manufacturer;
1111         __le16   lmp_subver;
1112 } __packed;
1113
1114 #define HCI_OP_READ_LOCAL_COMMANDS      0x1002
1115 struct hci_rp_read_local_commands {
1116         __u8     status;
1117         __u8     commands[64];
1118 } __packed;
1119
1120 #define HCI_OP_READ_LOCAL_FEATURES      0x1003
1121 struct hci_rp_read_local_features {
1122         __u8     status;
1123         __u8     features[8];
1124 } __packed;
1125
1126 #define HCI_OP_READ_LOCAL_EXT_FEATURES  0x1004
1127 struct hci_cp_read_local_ext_features {
1128         __u8     page;
1129 } __packed;
1130 struct hci_rp_read_local_ext_features {
1131         __u8     status;
1132         __u8     page;
1133         __u8     max_page;
1134         __u8     features[8];
1135 } __packed;
1136
1137 #define HCI_OP_READ_BUFFER_SIZE         0x1005
1138 struct hci_rp_read_buffer_size {
1139         __u8     status;
1140         __le16   acl_mtu;
1141         __u8     sco_mtu;
1142         __le16   acl_max_pkt;
1143         __le16   sco_max_pkt;
1144 } __packed;
1145
1146 #define HCI_OP_READ_BD_ADDR             0x1009
1147 struct hci_rp_read_bd_addr {
1148         __u8     status;
1149         bdaddr_t bdaddr;
1150 } __packed;
1151
1152 #define HCI_OP_READ_DATA_BLOCK_SIZE     0x100a
1153 struct hci_rp_read_data_block_size {
1154         __u8     status;
1155         __le16   max_acl_len;
1156         __le16   block_len;
1157         __le16   num_blocks;
1158 } __packed;
1159
1160 #define HCI_OP_READ_LOCAL_CODECS        0x100b
1161
1162 #define HCI_OP_READ_PAGE_SCAN_ACTIVITY  0x0c1b
1163 struct hci_rp_read_page_scan_activity {
1164         __u8     status;
1165         __le16   interval;
1166         __le16   window;
1167 } __packed;
1168
1169 #define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c
1170 struct hci_cp_write_page_scan_activity {
1171         __le16   interval;
1172         __le16   window;
1173 } __packed;
1174
1175 #define HCI_OP_READ_TX_POWER            0x0c2d
1176 struct hci_cp_read_tx_power {
1177         __le16   handle;
1178         __u8     type;
1179 } __packed;
1180 struct hci_rp_read_tx_power {
1181         __u8     status;
1182         __le16   handle;
1183         __s8     tx_power;
1184 } __packed;
1185
1186 #define HCI_OP_READ_PAGE_SCAN_TYPE      0x0c46
1187 struct hci_rp_read_page_scan_type {
1188         __u8     status;
1189         __u8     type;
1190 } __packed;
1191
1192 #define HCI_OP_WRITE_PAGE_SCAN_TYPE     0x0c47
1193         #define PAGE_SCAN_TYPE_STANDARD         0x00
1194         #define PAGE_SCAN_TYPE_INTERLACED       0x01
1195
1196 #define HCI_OP_READ_RSSI                0x1405
1197 struct hci_cp_read_rssi {
1198         __le16   handle;
1199 } __packed;
1200 struct hci_rp_read_rssi {
1201         __u8     status;
1202         __le16   handle;
1203         __s8     rssi;
1204 } __packed;
1205
1206 #define HCI_OP_READ_CLOCK               0x1407
1207 struct hci_cp_read_clock {
1208         __le16   handle;
1209         __u8     which;
1210 } __packed;
1211 struct hci_rp_read_clock {
1212         __u8     status;
1213         __le16   handle;
1214         __le32   clock;
1215         __le16   accuracy;
1216 } __packed;
1217
1218 #define HCI_OP_READ_ENC_KEY_SIZE        0x1408
1219 struct hci_cp_read_enc_key_size {
1220         __le16   handle;
1221 } __packed;
1222 struct hci_rp_read_enc_key_size {
1223         __u8     status;
1224         __le16   handle;
1225         __u8     key_size;
1226 } __packed;
1227
1228 #define HCI_OP_READ_LOCAL_AMP_INFO      0x1409
1229 struct hci_rp_read_local_amp_info {
1230         __u8     status;
1231         __u8     amp_status;
1232         __le32   total_bw;
1233         __le32   max_bw;
1234         __le32   min_latency;
1235         __le32   max_pdu;
1236         __u8     amp_type;
1237         __le16   pal_cap;
1238         __le16   max_assoc_size;
1239         __le32   max_flush_to;
1240         __le32   be_flush_to;
1241 } __packed;
1242
1243 #define HCI_OP_READ_LOCAL_AMP_ASSOC     0x140a
1244 struct hci_cp_read_local_amp_assoc {
1245         __u8     phy_handle;
1246         __le16   len_so_far;
1247         __le16   max_len;
1248 } __packed;
1249 struct hci_rp_read_local_amp_assoc {
1250         __u8     status;
1251         __u8     phy_handle;
1252         __le16   rem_len;
1253         __u8     frag[0];
1254 } __packed;
1255
1256 #define HCI_OP_WRITE_REMOTE_AMP_ASSOC   0x140b
1257 struct hci_cp_write_remote_amp_assoc {
1258         __u8     phy_handle;
1259         __le16   len_so_far;
1260         __le16   rem_len;
1261         __u8     frag[0];
1262 } __packed;
1263 struct hci_rp_write_remote_amp_assoc {
1264         __u8     status;
1265         __u8     phy_handle;
1266 } __packed;
1267
1268 #define HCI_OP_GET_MWS_TRANSPORT_CONFIG 0x140c
1269
1270 #define HCI_OP_ENABLE_DUT_MODE          0x1803
1271
1272 #define HCI_OP_WRITE_SSP_DEBUG_MODE     0x1804
1273
1274 #define HCI_OP_LE_SET_EVENT_MASK        0x2001
1275 struct hci_cp_le_set_event_mask {
1276         __u8     mask[8];
1277 } __packed;
1278
1279 #define HCI_OP_LE_READ_BUFFER_SIZE      0x2002
1280 struct hci_rp_le_read_buffer_size {
1281         __u8     status;
1282         __le16   le_mtu;
1283         __u8     le_max_pkt;
1284 } __packed;
1285
1286 #define HCI_OP_LE_READ_LOCAL_FEATURES   0x2003
1287 struct hci_rp_le_read_local_features {
1288         __u8     status;
1289         __u8     features[8];
1290 } __packed;
1291
1292 #define HCI_OP_LE_SET_RANDOM_ADDR       0x2005
1293
1294 #define HCI_OP_LE_SET_ADV_PARAM         0x2006
1295 struct hci_cp_le_set_adv_param {
1296         __le16   min_interval;
1297         __le16   max_interval;
1298         __u8     type;
1299         __u8     own_address_type;
1300         __u8     direct_addr_type;
1301         bdaddr_t direct_addr;
1302         __u8     channel_map;
1303         __u8     filter_policy;
1304 } __packed;
1305
1306 #define HCI_OP_LE_READ_ADV_TX_POWER     0x2007
1307 struct hci_rp_le_read_adv_tx_power {
1308         __u8    status;
1309         __s8    tx_power;
1310 } __packed;
1311
1312 #define HCI_MAX_AD_LENGTH               31
1313
1314 #define HCI_OP_LE_SET_ADV_DATA          0x2008
1315 struct hci_cp_le_set_adv_data {
1316         __u8    length;
1317         __u8    data[HCI_MAX_AD_LENGTH];
1318 } __packed;
1319
1320 #define HCI_OP_LE_SET_SCAN_RSP_DATA     0x2009
1321 struct hci_cp_le_set_scan_rsp_data {
1322         __u8    length;
1323         __u8    data[HCI_MAX_AD_LENGTH];
1324 } __packed;
1325
1326 #define HCI_OP_LE_SET_ADV_ENABLE        0x200a
1327
1328 #define LE_SCAN_PASSIVE                 0x00
1329 #define LE_SCAN_ACTIVE                  0x01
1330
1331 #define HCI_OP_LE_SET_SCAN_PARAM        0x200b
1332 struct hci_cp_le_set_scan_param {
1333         __u8    type;
1334         __le16  interval;
1335         __le16  window;
1336         __u8    own_address_type;
1337         __u8    filter_policy;
1338 } __packed;
1339
1340 #define LE_SCAN_DISABLE                 0x00
1341 #define LE_SCAN_ENABLE                  0x01
1342 #define LE_SCAN_FILTER_DUP_DISABLE      0x00
1343 #define LE_SCAN_FILTER_DUP_ENABLE       0x01
1344
1345 #define HCI_OP_LE_SET_SCAN_ENABLE       0x200c
1346 struct hci_cp_le_set_scan_enable {
1347         __u8     enable;
1348         __u8     filter_dup;
1349 } __packed;
1350
1351 #define HCI_LE_USE_PEER_ADDR            0x00
1352 #define HCI_LE_USE_WHITELIST            0x01
1353
1354 #define HCI_OP_LE_CREATE_CONN           0x200d
1355 struct hci_cp_le_create_conn {
1356         __le16   scan_interval;
1357         __le16   scan_window;
1358         __u8     filter_policy;
1359         __u8     peer_addr_type;
1360         bdaddr_t peer_addr;
1361         __u8     own_address_type;
1362         __le16   conn_interval_min;
1363         __le16   conn_interval_max;
1364         __le16   conn_latency;
1365         __le16   supervision_timeout;
1366         __le16   min_ce_len;
1367         __le16   max_ce_len;
1368 } __packed;
1369
1370 #define HCI_OP_LE_CREATE_CONN_CANCEL    0x200e
1371
1372 #define HCI_OP_LE_READ_WHITE_LIST_SIZE  0x200f
1373 struct hci_rp_le_read_white_list_size {
1374         __u8    status;
1375         __u8    size;
1376 } __packed;
1377
1378 #define HCI_OP_LE_CLEAR_WHITE_LIST      0x2010
1379
1380 #define HCI_OP_LE_ADD_TO_WHITE_LIST     0x2011
1381 struct hci_cp_le_add_to_white_list {
1382         __u8     bdaddr_type;
1383         bdaddr_t bdaddr;
1384 } __packed;
1385
1386 #define HCI_OP_LE_DEL_FROM_WHITE_LIST   0x2012
1387 struct hci_cp_le_del_from_white_list {
1388         __u8     bdaddr_type;
1389         bdaddr_t bdaddr;
1390 } __packed;
1391
1392 #define HCI_OP_LE_CONN_UPDATE           0x2013
1393 struct hci_cp_le_conn_update {
1394         __le16   handle;
1395         __le16   conn_interval_min;
1396         __le16   conn_interval_max;
1397         __le16   conn_latency;
1398         __le16   supervision_timeout;
1399         __le16   min_ce_len;
1400         __le16   max_ce_len;
1401 } __packed;
1402
1403 #define HCI_OP_LE_READ_REMOTE_FEATURES  0x2016
1404 struct hci_cp_le_read_remote_features {
1405         __le16   handle;
1406 } __packed;
1407
1408 #define HCI_OP_LE_START_ENC             0x2019
1409 struct hci_cp_le_start_enc {
1410         __le16  handle;
1411         __le64  rand;
1412         __le16  ediv;
1413         __u8    ltk[16];
1414 } __packed;
1415
1416 #define HCI_OP_LE_LTK_REPLY             0x201a
1417 struct hci_cp_le_ltk_reply {
1418         __le16  handle;
1419         __u8    ltk[16];
1420 } __packed;
1421 struct hci_rp_le_ltk_reply {
1422         __u8    status;
1423         __le16  handle;
1424 } __packed;
1425
1426 #define HCI_OP_LE_LTK_NEG_REPLY         0x201b
1427 struct hci_cp_le_ltk_neg_reply {
1428         __le16  handle;
1429 } __packed;
1430 struct hci_rp_le_ltk_neg_reply {
1431         __u8    status;
1432         __le16  handle;
1433 } __packed;
1434
1435 #define HCI_OP_LE_READ_SUPPORTED_STATES 0x201c
1436 struct hci_rp_le_read_supported_states {
1437         __u8    status;
1438         __u8    le_states[8];
1439 } __packed;
1440
1441 #define HCI_OP_LE_CONN_PARAM_REQ_REPLY  0x2020
1442 struct hci_cp_le_conn_param_req_reply {
1443         __le16  handle;
1444         __le16  interval_min;
1445         __le16  interval_max;
1446         __le16  latency;
1447         __le16  timeout;
1448         __le16  min_ce_len;
1449         __le16  max_ce_len;
1450 } __packed;
1451
1452 #define HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY      0x2021
1453 struct hci_cp_le_conn_param_req_neg_reply {
1454         __le16  handle;
1455         __u8    reason;
1456 } __packed;
1457
1458 #define HCI_OP_LE_SET_DATA_LEN          0x2022
1459 struct hci_cp_le_set_data_len {
1460         __le16  handle;
1461         __le16  tx_len;
1462         __le16  tx_time;
1463 } __packed;
1464 struct hci_rp_le_set_data_len {
1465         __u8    status;
1466         __le16  handle;
1467 } __packed;
1468
1469 #define HCI_OP_LE_READ_DEF_DATA_LEN     0x2023
1470 struct hci_rp_le_read_def_data_len {
1471         __u8    status;
1472         __le16  tx_len;
1473         __le16  tx_time;
1474 } __packed;
1475
1476 #define HCI_OP_LE_WRITE_DEF_DATA_LEN    0x2024
1477 struct hci_cp_le_write_def_data_len {
1478         __le16  tx_len;
1479         __le16  tx_time;
1480 } __packed;
1481
1482 #define HCI_OP_LE_READ_MAX_DATA_LEN     0x202f
1483 struct hci_rp_le_read_max_data_len {
1484         __u8    status;
1485         __le16  tx_len;
1486         __le16  tx_time;
1487         __le16  rx_len;
1488         __le16  rx_time;
1489 } __packed;
1490
1491 /* ---- HCI Events ---- */
1492 #define HCI_EV_INQUIRY_COMPLETE         0x01
1493
1494 #define HCI_EV_INQUIRY_RESULT           0x02
1495 struct inquiry_info {
1496         bdaddr_t bdaddr;
1497         __u8     pscan_rep_mode;
1498         __u8     pscan_period_mode;
1499         __u8     pscan_mode;
1500         __u8     dev_class[3];
1501         __le16   clock_offset;
1502 } __packed;
1503
1504 #define HCI_EV_CONN_COMPLETE            0x03
1505 struct hci_ev_conn_complete {
1506         __u8     status;
1507         __le16   handle;
1508         bdaddr_t bdaddr;
1509         __u8     link_type;
1510         __u8     encr_mode;
1511 } __packed;
1512
1513 #define HCI_EV_CONN_REQUEST             0x04
1514 struct hci_ev_conn_request {
1515         bdaddr_t bdaddr;
1516         __u8     dev_class[3];
1517         __u8     link_type;
1518 } __packed;
1519
1520 #define HCI_EV_DISCONN_COMPLETE         0x05
1521 struct hci_ev_disconn_complete {
1522         __u8     status;
1523         __le16   handle;
1524         __u8     reason;
1525 } __packed;
1526
1527 #define HCI_EV_AUTH_COMPLETE            0x06
1528 struct hci_ev_auth_complete {
1529         __u8     status;
1530         __le16   handle;
1531 } __packed;
1532
1533 #define HCI_EV_REMOTE_NAME              0x07
1534 struct hci_ev_remote_name {
1535         __u8     status;
1536         bdaddr_t bdaddr;
1537         __u8     name[HCI_MAX_NAME_LENGTH];
1538 } __packed;
1539
1540 #define HCI_EV_ENCRYPT_CHANGE           0x08
1541 struct hci_ev_encrypt_change {
1542         __u8     status;
1543         __le16   handle;
1544         __u8     encrypt;
1545 } __packed;
1546
1547 #define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09
1548 struct hci_ev_change_link_key_complete {
1549         __u8     status;
1550         __le16   handle;
1551 } __packed;
1552
1553 #define HCI_EV_REMOTE_FEATURES          0x0b
1554 struct hci_ev_remote_features {
1555         __u8     status;
1556         __le16   handle;
1557         __u8     features[8];
1558 } __packed;
1559
1560 #define HCI_EV_REMOTE_VERSION           0x0c
1561 struct hci_ev_remote_version {
1562         __u8     status;
1563         __le16   handle;
1564         __u8     lmp_ver;
1565         __le16   manufacturer;
1566         __le16   lmp_subver;
1567 } __packed;
1568
1569 #define HCI_EV_QOS_SETUP_COMPLETE       0x0d
1570 struct hci_qos {
1571         __u8     service_type;
1572         __u32    token_rate;
1573         __u32    peak_bandwidth;
1574         __u32    latency;
1575         __u32    delay_variation;
1576 } __packed;
1577 struct hci_ev_qos_setup_complete {
1578         __u8     status;
1579         __le16   handle;
1580         struct   hci_qos qos;
1581 } __packed;
1582
1583 #define HCI_EV_CMD_COMPLETE             0x0e
1584 struct hci_ev_cmd_complete {
1585         __u8     ncmd;
1586         __le16   opcode;
1587 } __packed;
1588
1589 #define HCI_EV_CMD_STATUS               0x0f
1590 struct hci_ev_cmd_status {
1591         __u8     status;
1592         __u8     ncmd;
1593         __le16   opcode;
1594 } __packed;
1595
1596 #define HCI_EV_HARDWARE_ERROR           0x10
1597 struct hci_ev_hardware_error {
1598         __u8     code;
1599 } __packed;
1600
1601 #define HCI_EV_ROLE_CHANGE              0x12
1602 struct hci_ev_role_change {
1603         __u8     status;
1604         bdaddr_t bdaddr;
1605         __u8     role;
1606 } __packed;
1607
1608 #define HCI_EV_NUM_COMP_PKTS            0x13
1609 struct hci_comp_pkts_info {
1610         __le16   handle;
1611         __le16   count;
1612 } __packed;
1613
1614 struct hci_ev_num_comp_pkts {
1615         __u8     num_hndl;
1616         struct hci_comp_pkts_info handles[0];
1617 } __packed;
1618
1619 #define HCI_EV_MODE_CHANGE              0x14
1620 struct hci_ev_mode_change {
1621         __u8     status;
1622         __le16   handle;
1623         __u8     mode;
1624         __le16   interval;
1625 } __packed;
1626
1627 #define HCI_EV_PIN_CODE_REQ             0x16
1628 struct hci_ev_pin_code_req {
1629         bdaddr_t bdaddr;
1630 } __packed;
1631
1632 #define HCI_EV_LINK_KEY_REQ             0x17
1633 struct hci_ev_link_key_req {
1634         bdaddr_t bdaddr;
1635 } __packed;
1636
1637 #define HCI_EV_LINK_KEY_NOTIFY          0x18
1638 struct hci_ev_link_key_notify {
1639         bdaddr_t bdaddr;
1640         __u8     link_key[HCI_LINK_KEY_SIZE];
1641         __u8     key_type;
1642 } __packed;
1643
1644 #define HCI_EV_CLOCK_OFFSET             0x1c
1645 struct hci_ev_clock_offset {
1646         __u8     status;
1647         __le16   handle;
1648         __le16   clock_offset;
1649 } __packed;
1650
1651 #define HCI_EV_PKT_TYPE_CHANGE          0x1d
1652 struct hci_ev_pkt_type_change {
1653         __u8     status;
1654         __le16   handle;
1655         __le16   pkt_type;
1656 } __packed;
1657
1658 #define HCI_EV_PSCAN_REP_MODE           0x20
1659 struct hci_ev_pscan_rep_mode {
1660         bdaddr_t bdaddr;
1661         __u8     pscan_rep_mode;
1662 } __packed;
1663
1664 #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
1665 struct inquiry_info_with_rssi {
1666         bdaddr_t bdaddr;
1667         __u8     pscan_rep_mode;
1668         __u8     pscan_period_mode;
1669         __u8     dev_class[3];
1670         __le16   clock_offset;
1671         __s8     rssi;
1672 } __packed;
1673 struct inquiry_info_with_rssi_and_pscan_mode {
1674         bdaddr_t bdaddr;
1675         __u8     pscan_rep_mode;
1676         __u8     pscan_period_mode;
1677         __u8     pscan_mode;
1678         __u8     dev_class[3];
1679         __le16   clock_offset;
1680         __s8     rssi;
1681 } __packed;
1682
1683 #define HCI_EV_REMOTE_EXT_FEATURES      0x23
1684 struct hci_ev_remote_ext_features {
1685         __u8     status;
1686         __le16   handle;
1687         __u8     page;
1688         __u8     max_page;
1689         __u8     features[8];
1690 } __packed;
1691
1692 #define HCI_EV_SYNC_CONN_COMPLETE       0x2c
1693 struct hci_ev_sync_conn_complete {
1694         __u8     status;
1695         __le16   handle;
1696         bdaddr_t bdaddr;
1697         __u8     link_type;
1698         __u8     tx_interval;
1699         __u8     retrans_window;
1700         __le16   rx_pkt_len;
1701         __le16   tx_pkt_len;
1702         __u8     air_mode;
1703 } __packed;
1704
1705 #define HCI_EV_SYNC_CONN_CHANGED        0x2d
1706 struct hci_ev_sync_conn_changed {
1707         __u8     status;
1708         __le16   handle;
1709         __u8     tx_interval;
1710         __u8     retrans_window;
1711         __le16   rx_pkt_len;
1712         __le16   tx_pkt_len;
1713 } __packed;
1714
1715 #define HCI_EV_SNIFF_SUBRATE            0x2e
1716 struct hci_ev_sniff_subrate {
1717         __u8     status;
1718         __le16   handle;
1719         __le16   max_tx_latency;
1720         __le16   max_rx_latency;
1721         __le16   max_remote_timeout;
1722         __le16   max_local_timeout;
1723 } __packed;
1724
1725 #define HCI_EV_EXTENDED_INQUIRY_RESULT  0x2f
1726 struct extended_inquiry_info {
1727         bdaddr_t bdaddr;
1728         __u8     pscan_rep_mode;
1729         __u8     pscan_period_mode;
1730         __u8     dev_class[3];
1731         __le16   clock_offset;
1732         __s8     rssi;
1733         __u8     data[240];
1734 } __packed;
1735
1736 #define HCI_EV_KEY_REFRESH_COMPLETE     0x30
1737 struct hci_ev_key_refresh_complete {
1738         __u8    status;
1739         __le16  handle;
1740 } __packed;
1741
1742 #define HCI_EV_IO_CAPA_REQUEST          0x31
1743 struct hci_ev_io_capa_request {
1744         bdaddr_t bdaddr;
1745 } __packed;
1746
1747 #define HCI_EV_IO_CAPA_REPLY            0x32
1748 struct hci_ev_io_capa_reply {
1749         bdaddr_t bdaddr;
1750         __u8     capability;
1751         __u8     oob_data;
1752         __u8     authentication;
1753 } __packed;
1754
1755 #define HCI_EV_USER_CONFIRM_REQUEST     0x33
1756 struct hci_ev_user_confirm_req {
1757         bdaddr_t        bdaddr;
1758         __le32          passkey;
1759 } __packed;
1760
1761 #define HCI_EV_USER_PASSKEY_REQUEST     0x34
1762 struct hci_ev_user_passkey_req {
1763         bdaddr_t        bdaddr;
1764 } __packed;
1765
1766 #define HCI_EV_REMOTE_OOB_DATA_REQUEST  0x35
1767 struct hci_ev_remote_oob_data_request {
1768         bdaddr_t bdaddr;
1769 } __packed;
1770
1771 #define HCI_EV_SIMPLE_PAIR_COMPLETE     0x36
1772 struct hci_ev_simple_pair_complete {
1773         __u8     status;
1774         bdaddr_t bdaddr;
1775 } __packed;
1776
1777 #define HCI_EV_USER_PASSKEY_NOTIFY      0x3b
1778 struct hci_ev_user_passkey_notify {
1779         bdaddr_t        bdaddr;
1780         __le32          passkey;
1781 } __packed;
1782
1783 #define HCI_KEYPRESS_STARTED            0
1784 #define HCI_KEYPRESS_ENTERED            1
1785 #define HCI_KEYPRESS_ERASED             2
1786 #define HCI_KEYPRESS_CLEARED            3
1787 #define HCI_KEYPRESS_COMPLETED          4
1788
1789 #define HCI_EV_KEYPRESS_NOTIFY          0x3c
1790 struct hci_ev_keypress_notify {
1791         bdaddr_t        bdaddr;
1792         __u8            type;
1793 } __packed;
1794
1795 #define HCI_EV_REMOTE_HOST_FEATURES     0x3d
1796 struct hci_ev_remote_host_features {
1797         bdaddr_t bdaddr;
1798         __u8     features[8];
1799 } __packed;
1800
1801 #define HCI_EV_LE_META                  0x3e
1802 struct hci_ev_le_meta {
1803         __u8     subevent;
1804 } __packed;
1805
1806 #define HCI_EV_PHY_LINK_COMPLETE        0x40
1807 struct hci_ev_phy_link_complete {
1808         __u8     status;
1809         __u8     phy_handle;
1810 } __packed;
1811
1812 #define HCI_EV_CHANNEL_SELECTED         0x41
1813 struct hci_ev_channel_selected {
1814         __u8     phy_handle;
1815 } __packed;
1816
1817 #define HCI_EV_DISCONN_PHY_LINK_COMPLETE        0x42
1818 struct hci_ev_disconn_phy_link_complete {
1819         __u8     status;
1820         __u8     phy_handle;
1821         __u8     reason;
1822 } __packed;
1823
1824 #define HCI_EV_LOGICAL_LINK_COMPLETE            0x45
1825 struct hci_ev_logical_link_complete {
1826         __u8     status;
1827         __le16   handle;
1828         __u8     phy_handle;
1829         __u8     flow_spec_id;
1830 } __packed;
1831
1832 #define HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE    0x46
1833 struct hci_ev_disconn_logical_link_complete {
1834         __u8     status;
1835         __le16   handle;
1836         __u8     reason;
1837 } __packed;
1838
1839 #define HCI_EV_NUM_COMP_BLOCKS          0x48
1840 struct hci_comp_blocks_info {
1841         __le16   handle;
1842         __le16   pkts;
1843         __le16   blocks;
1844 } __packed;
1845
1846 struct hci_ev_num_comp_blocks {
1847         __le16   num_blocks;
1848         __u8     num_hndl;
1849         struct hci_comp_blocks_info handles[0];
1850 } __packed;
1851
1852 #define HCI_EV_SYNC_TRAIN_COMPLETE      0x4F
1853 struct hci_ev_sync_train_complete {
1854         __u8    status;
1855 } __packed;
1856
1857 #define HCI_EV_SLAVE_PAGE_RESP_TIMEOUT  0x54
1858
1859 #define HCI_EV_LE_CONN_COMPLETE         0x01
1860 struct hci_ev_le_conn_complete {
1861         __u8     status;
1862         __le16   handle;
1863         __u8     role;
1864         __u8     bdaddr_type;
1865         bdaddr_t bdaddr;
1866         __le16   interval;
1867         __le16   latency;
1868         __le16   supervision_timeout;
1869         __u8     clk_accurancy;
1870 } __packed;
1871
1872 /* Advertising report event types */
1873 #define LE_ADV_IND              0x00
1874 #define LE_ADV_DIRECT_IND       0x01
1875 #define LE_ADV_SCAN_IND         0x02
1876 #define LE_ADV_NONCONN_IND      0x03
1877 #define LE_ADV_SCAN_RSP         0x04
1878
1879 #define ADDR_LE_DEV_PUBLIC      0x00
1880 #define ADDR_LE_DEV_RANDOM      0x01
1881
1882 #define HCI_EV_LE_ADVERTISING_REPORT    0x02
1883 struct hci_ev_le_advertising_info {
1884         __u8     evt_type;
1885         __u8     bdaddr_type;
1886         bdaddr_t bdaddr;
1887         __u8     length;
1888         __u8     data[0];
1889 } __packed;
1890
1891 #define HCI_EV_LE_CONN_UPDATE_COMPLETE  0x03
1892 struct hci_ev_le_conn_update_complete {
1893         __u8     status;
1894         __le16   handle;
1895         __le16   interval;
1896         __le16   latency;
1897         __le16   supervision_timeout;
1898 } __packed;
1899
1900 #define HCI_EV_LE_REMOTE_FEAT_COMPLETE  0x04
1901 struct hci_ev_le_remote_feat_complete {
1902         __u8     status;
1903         __le16   handle;
1904         __u8     features[8];
1905 } __packed;
1906
1907 #define HCI_EV_LE_LTK_REQ               0x05
1908 struct hci_ev_le_ltk_req {
1909         __le16  handle;
1910         __le64  rand;
1911         __le16  ediv;
1912 } __packed;
1913
1914 #define HCI_EV_LE_REMOTE_CONN_PARAM_REQ 0x06
1915 struct hci_ev_le_remote_conn_param_req {
1916         __le16 handle;
1917         __le16 interval_min;
1918         __le16 interval_max;
1919         __le16 latency;
1920         __le16 timeout;
1921 } __packed;
1922
1923 #define HCI_EV_LE_DATA_LEN_CHANGE       0x07
1924 struct hci_ev_le_data_len_change {
1925         __le16  handle;
1926         __le16  tx_len;
1927         __le16  tx_time;
1928         __le16  rx_len;
1929         __le16  rx_time;
1930 } __packed;
1931
1932 #define HCI_EV_LE_DIRECT_ADV_REPORT     0x0B
1933 struct hci_ev_le_direct_adv_info {
1934         __u8     evt_type;
1935         __u8     bdaddr_type;
1936         bdaddr_t bdaddr;
1937         __u8     direct_addr_type;
1938         bdaddr_t direct_addr;
1939         __s8     rssi;
1940 } __packed;
1941
1942 /* Internal events generated by Bluetooth stack */
1943 #define HCI_EV_STACK_INTERNAL   0xfd
1944 struct hci_ev_stack_internal {
1945         __u16    type;
1946         __u8     data[0];
1947 } __packed;
1948
1949 #define HCI_EV_SI_DEVICE        0x01
1950 struct hci_ev_si_device {
1951         __u16    event;
1952         __u16    dev_id;
1953 } __packed;
1954
1955 #define HCI_EV_SI_SECURITY      0x02
1956 struct hci_ev_si_security {
1957         __u16    event;
1958         __u16    proto;
1959         __u16    subproto;
1960         __u8     incoming;
1961 } __packed;
1962
1963 /* ---- HCI Packet structures ---- */
1964 #define HCI_COMMAND_HDR_SIZE 3
1965 #define HCI_EVENT_HDR_SIZE   2
1966 #define HCI_ACL_HDR_SIZE     4
1967 #define HCI_SCO_HDR_SIZE     3
1968
1969 struct hci_command_hdr {
1970         __le16  opcode;         /* OCF & OGF */
1971         __u8    plen;
1972 } __packed;
1973
1974 struct hci_event_hdr {
1975         __u8    evt;
1976         __u8    plen;
1977 } __packed;
1978
1979 struct hci_acl_hdr {
1980         __le16  handle;         /* Handle & Flags(PB, BC) */
1981         __le16  dlen;
1982 } __packed;
1983
1984 struct hci_sco_hdr {
1985         __le16  handle;
1986         __u8    dlen;
1987 } __packed;
1988
1989 static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
1990 {
1991         return (struct hci_event_hdr *) skb->data;
1992 }
1993
1994 static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
1995 {
1996         return (struct hci_acl_hdr *) skb->data;
1997 }
1998
1999 static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
2000 {
2001         return (struct hci_sco_hdr *) skb->data;
2002 }
2003
2004 /* Command opcode pack/unpack */
2005 #define hci_opcode_pack(ogf, ocf)       ((__u16) ((ocf & 0x03ff)|(ogf << 10)))
2006 #define hci_opcode_ogf(op)              (op >> 10)
2007 #define hci_opcode_ocf(op)              (op & 0x03ff)
2008
2009 /* ACL handle and flags pack/unpack */
2010 #define hci_handle_pack(h, f)   ((__u16) ((h & 0x0fff)|(f << 12)))
2011 #define hci_handle(h)           (h & 0x0fff)
2012 #define hci_flags(h)            (h >> 12)
2013
2014 #endif /* __HCI_H */