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