1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 *
4 * BlueZ - Bluetooth protocol stack for Linux
5 *
6 * Copyright (C) 2000-2001 Qualcomm Incorporated
7 * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
8 * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
9 *
10 *
11 */
12
13#ifndef __HCI_H
14#define __HCI_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20#include <sys/socket.h>
21
22#define HCI_MAX_DEV 16
23
24#define HCI_MAX_AMP_SIZE (1492 + 4)
25#define HCI_MAX_ACL_SIZE 1024
26#define HCI_MAX_SCO_SIZE 255
27#define HCI_MAX_EVENT_SIZE 260
28#define HCI_MAX_FRAME_SIZE (HCI_MAX_AMP_SIZE + 4)
29
30/* HCI dev events */
31#define HCI_DEV_REG 1
32#define HCI_DEV_UNREG 2
33#define HCI_DEV_UP 3
34#define HCI_DEV_DOWN 4
35#define HCI_DEV_SUSPEND 5
36#define HCI_DEV_RESUME 6
37
38/* HCI bus types */
39#define HCI_VIRTUAL 0
40#define HCI_USB 1
41#define HCI_PCCARD 2
42#define HCI_UART 3
43#define HCI_RS232 4
44#define HCI_PCI 5
45#define HCI_SDIO 6
46#define HCI_SPI 7
47#define HCI_I2C 8
48#define HCI_SMD 9
49#define HCI_VIRTIO 10
50
51/* HCI controller types */
52#define HCI_PRIMARY 0x00
53#define HCI_AMP 0x01
54#define HCI_BREDR HCI_PRIMARY
55
56/* HCI device flags */
57enum {
58 HCI_UP,
59 HCI_INIT,
60 HCI_RUNNING,
61
62 HCI_PSCAN,
63 HCI_ISCAN,
64 HCI_AUTH,
65 HCI_ENCRYPT,
66 HCI_INQUIRY,
67
68 HCI_RAW,
69};
70
71/* LE address type */
72enum {
73 LE_PUBLIC_ADDRESS = 0x00,
74 LE_RANDOM_ADDRESS = 0x01
75};
76
77/* HCI ioctl defines */
78#define HCIDEVUP _IOW('H', 201, int)
79#define HCIDEVDOWN _IOW('H', 202, int)
80#define HCIDEVRESET _IOW('H', 203, int)
81#define HCIDEVRESTAT _IOW('H', 204, int)
82
83#define HCIGETDEVLIST _IOR('H', 210, int)
84#define HCIGETDEVINFO _IOR('H', 211, int)
85#define HCIGETCONNLIST _IOR('H', 212, int)
86#define HCIGETCONNINFO _IOR('H', 213, int)
87#define HCIGETAUTHINFO _IOR('H', 215, int)
88
89#define HCISETRAW _IOW('H', 220, int)
90#define HCISETSCAN _IOW('H', 221, int)
91#define HCISETAUTH _IOW('H', 222, int)
92#define HCISETENCRYPT _IOW('H', 223, int)
93#define HCISETPTYPE _IOW('H', 224, int)
94#define HCISETLINKPOL _IOW('H', 225, int)
95#define HCISETLINKMODE _IOW('H', 226, int)
96#define HCISETACLMTU _IOW('H', 227, int)
97#define HCISETSCOMTU _IOW('H', 228, int)
98
99#define HCIBLOCKADDR _IOW('H', 230, int)
100#define HCIUNBLOCKADDR _IOW('H', 231, int)
101
102#define HCIINQUIRY _IOR('H', 240, int)
103
104#ifndef __NO_HCI_DEFS
105
106/* HCI Packet types */
107#define HCI_COMMAND_PKT 0x01
108#define HCI_ACLDATA_PKT 0x02
109#define HCI_SCODATA_PKT 0x03
110#define HCI_EVENT_PKT 0x04
111#define HCI_ISODATA_PKT 0x05
112#define HCI_VENDOR_PKT 0xff
113
114/* HCI Packet types */
115#define HCI_2DH1 0x0002
116#define HCI_3DH1 0x0004
117#define HCI_DM1 0x0008
118#define HCI_DH1 0x0010
119#define HCI_2DH3 0x0100
120#define HCI_3DH3 0x0200
121#define HCI_DM3 0x0400
122#define HCI_DH3 0x0800
123#define HCI_2DH5 0x1000
124#define HCI_3DH5 0x2000
125#define HCI_DM5 0x4000
126#define HCI_DH5 0x8000
127
128#define HCI_HV1 0x0020
129#define HCI_HV2 0x0040
130#define HCI_HV3 0x0080
131
132#define HCI_EV3 0x0008
133#define HCI_EV4 0x0010
134#define HCI_EV5 0x0020
135#define HCI_2EV3 0x0040
136#define HCI_3EV3 0x0080
137#define HCI_2EV5 0x0100
138#define HCI_3EV5 0x0200
139
140#define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
141#define ACL_PTYPE_MASK (HCI_DM1 | HCI_DH1 | HCI_DM3 | HCI_DH3 | HCI_DM5 | HCI_DH5)
142
143/* HCI Error codes */
144#define HCI_UNKNOWN_COMMAND 0x01
145#define HCI_NO_CONNECTION 0x02
146#define HCI_HARDWARE_FAILURE 0x03
147#define HCI_PAGE_TIMEOUT 0x04
148#define HCI_AUTHENTICATION_FAILURE 0x05
149#define HCI_PIN_OR_KEY_MISSING 0x06
150#define HCI_MEMORY_FULL 0x07
151#define HCI_CONNECTION_TIMEOUT 0x08
152#define HCI_MAX_NUMBER_OF_CONNECTIONS 0x09
153#define HCI_MAX_NUMBER_OF_SCO_CONNECTIONS 0x0a
154#define HCI_ACL_CONNECTION_EXISTS 0x0b
155#define HCI_COMMAND_DISALLOWED 0x0c
156#define HCI_REJECTED_LIMITED_RESOURCES 0x0d
157#define HCI_REJECTED_SECURITY 0x0e
158#define HCI_REJECTED_PERSONAL 0x0f
159#define HCI_HOST_TIMEOUT 0x10
160#define HCI_UNSUPPORTED_FEATURE 0x11
161#define HCI_INVALID_PARAMETERS 0x12
162#define HCI_OE_USER_ENDED_CONNECTION 0x13
163#define HCI_OE_LOW_RESOURCES 0x14
164#define HCI_OE_POWER_OFF 0x15
165#define HCI_CONNECTION_TERMINATED 0x16
166#define HCI_REPEATED_ATTEMPTS 0x17
167#define HCI_PAIRING_NOT_ALLOWED 0x18
168#define HCI_UNKNOWN_LMP_PDU 0x19
169#define HCI_UNSUPPORTED_REMOTE_FEATURE 0x1a
170#define HCI_SCO_OFFSET_REJECTED 0x1b
171#define HCI_SCO_INTERVAL_REJECTED 0x1c
172#define HCI_AIR_MODE_REJECTED 0x1d
173#define HCI_INVALID_LMP_PARAMETERS 0x1e
174#define HCI_UNSPECIFIED_ERROR 0x1f
175#define HCI_UNSUPPORTED_LMP_PARAMETER_VALUE 0x20
176#define HCI_ROLE_CHANGE_NOT_ALLOWED 0x21
177#define HCI_LMP_RESPONSE_TIMEOUT 0x22
178#define HCI_LMP_ERROR_TRANSACTION_COLLISION 0x23
179#define HCI_LMP_PDU_NOT_ALLOWED 0x24
180#define HCI_ENCRYPTION_MODE_NOT_ACCEPTED 0x25
181#define HCI_UNIT_LINK_KEY_USED 0x26
182#define HCI_QOS_NOT_SUPPORTED 0x27
183#define HCI_INSTANT_PASSED 0x28
184#define HCI_PAIRING_NOT_SUPPORTED 0x29
185#define HCI_TRANSACTION_COLLISION 0x2a
186#define HCI_QOS_UNACCEPTABLE_PARAMETER 0x2c
187#define HCI_QOS_REJECTED 0x2d
188#define HCI_CLASSIFICATION_NOT_SUPPORTED 0x2e
189#define HCI_INSUFFICIENT_SECURITY 0x2f
190#define HCI_PARAMETER_OUT_OF_RANGE 0x30
191#define HCI_ROLE_SWITCH_PENDING 0x32
192#define HCI_SLOT_VIOLATION 0x34
193#define HCI_ROLE_SWITCH_FAILED 0x35
194#define HCI_EIR_TOO_LARGE 0x36
195#define HCI_SIMPLE_PAIRING_NOT_SUPPORTED 0x37
196#define HCI_HOST_BUSY_PAIRING 0x38
197
198/* ACL flags */
199#define ACL_START_NO_FLUSH 0x00
200#define ACL_CONT 0x01
201#define ACL_START 0x02
202#define ACL_ACTIVE_BCAST 0x04
203#define ACL_PICO_BCAST 0x08
204
205/* Baseband links */
206#define SCO_LINK 0x00
207#define ACL_LINK 0x01
208#define ESCO_LINK 0x02
209
210/* LMP features */
211#define LMP_3SLOT 0x01
212#define LMP_5SLOT 0x02
213#define LMP_ENCRYPT 0x04
214#define LMP_SOFFSET 0x08
215#define LMP_TACCURACY 0x10
216#define LMP_RSWITCH 0x20
217#define LMP_HOLD 0x40
218#define LMP_SNIFF 0x80
219
220#define LMP_PARK 0x01
221#define LMP_RSSI 0x02
222#define LMP_QUALITY 0x04
223#define LMP_SCO 0x08
224#define LMP_HV2 0x10
225#define LMP_HV3 0x20
226#define LMP_ULAW 0x40
227#define LMP_ALAW 0x80
228
229#define LMP_CVSD 0x01
230#define LMP_PSCHEME 0x02
231#define LMP_PCONTROL 0x04
232#define LMP_TRSP_SCO 0x08
233#define LMP_BCAST_ENC 0x80
234
235#define LMP_EDR_ACL_2M 0x02
236#define LMP_EDR_ACL_3M 0x04
237#define LMP_ENH_ISCAN 0x08
238#define LMP_ILACE_ISCAN 0x10
239#define LMP_ILACE_PSCAN 0x20
240#define LMP_RSSI_INQ 0x40
241#define LMP_ESCO 0x80
242
243#define LMP_EV4 0x01
244#define LMP_EV5 0x02
245#define LMP_AFH_CAP_SLV 0x08
246#define LMP_AFH_CLS_SLV 0x10
247#define LMP_NO_BREDR 0x20
248#define LMP_LE 0x40
249#define LMP_EDR_3SLOT 0x80
250
251#define LMP_EDR_5SLOT 0x01
252#define LMP_SNIFF_SUBR 0x02
253#define LMP_PAUSE_ENC 0x04
254#define LMP_AFH_CAP_MST 0x08
255#define LMP_AFH_CLS_MST 0x10
256#define LMP_EDR_ESCO_2M 0x20
257#define LMP_EDR_ESCO_3M 0x40
258#define LMP_EDR_3S_ESCO 0x80
259
260#define LMP_EXT_INQ 0x01
261#define LMP_LE_BREDR 0x02
262#define LMP_SIMPLE_PAIR 0x08
263#define LMP_ENCAPS_PDU 0x10
264#define LMP_ERR_DAT_REP 0x20
265#define LMP_NFLUSH_PKTS 0x40
266
267#define LMP_LSTO 0x01
268#define LMP_INQ_TX_PWR 0x02
269#define LMP_EPC 0x04
270#define LMP_EXT_FEAT 0x80
271
272/* Extended LMP features */
273#define LMP_HOST_SSP 0x01
274#define LMP_HOST_LE 0x02
275#define LMP_HOST_LE_BREDR 0x04
276
277/* Link policies */
278#define HCI_LP_RSWITCH 0x0001
279#define HCI_LP_HOLD 0x0002
280#define HCI_LP_SNIFF 0x0004
281#define HCI_LP_PARK 0x0008
282
283/* Link mode */
284#define HCI_LM_ACCEPT 0x8000
285#define HCI_LM_MASTER 0x0001
286#define HCI_LM_AUTH 0x0002
287#define HCI_LM_ENCRYPT 0x0004
288#define HCI_LM_TRUSTED 0x0008
289#define HCI_LM_RELIABLE 0x0010
290#define HCI_LM_SECURE 0x0020
291
292/* Link Key types */
293#define HCI_LK_COMBINATION 0x00
294#define HCI_LK_LOCAL_UNIT 0x01
295#define HCI_LK_REMOTE_UNIT 0x02
296#define HCI_LK_DEBUG_COMBINATION 0x03
297#define HCI_LK_UNAUTH_COMBINATION 0x04
298#define HCI_LK_AUTH_COMBINATION 0x05
299#define HCI_LK_CHANGED_COMBINATION 0x06
300#define HCI_LK_INVALID 0xFF
301
302/* ----- HCI Commands ----- */
303
304/* Link Control */
305#define OGF_LINK_CTL 0x01
306
307#define OCF_INQUIRY 0x0001
308typedef struct {
309 uint8_t lap[3];
310 uint8_t length; /* 1.28s units */
311 uint8_t num_rsp;
312} __attribute__ ((packed)) inquiry_cp;
313#define INQUIRY_CP_SIZE 5
314
315typedef struct {
316 uint8_t status;
317 bdaddr_t bdaddr;
318} __attribute__ ((packed)) status_bdaddr_rp;
319#define STATUS_BDADDR_RP_SIZE 7
320
321#define OCF_INQUIRY_CANCEL 0x0002
322
323#define OCF_PERIODIC_INQUIRY 0x0003
324typedef struct {
325 uint16_t max_period; /* 1.28s units */
326 uint16_t min_period; /* 1.28s units */
327 uint8_t lap[3];
328 uint8_t length; /* 1.28s units */
329 uint8_t num_rsp;
330} __attribute__ ((packed)) periodic_inquiry_cp;
331#define PERIODIC_INQUIRY_CP_SIZE 9
332
333#define OCF_EXIT_PERIODIC_INQUIRY 0x0004
334
335#define OCF_CREATE_CONN 0x0005
336typedef struct {
337 bdaddr_t bdaddr;
338 uint16_t pkt_type;
339 uint8_t pscan_rep_mode;
340 uint8_t pscan_mode;
341 uint16_t clock_offset;
342 uint8_t role_switch;
343} __attribute__ ((packed)) create_conn_cp;
344#define CREATE_CONN_CP_SIZE 13
345
346#define OCF_DISCONNECT 0x0006
347typedef struct {
348 uint16_t handle;
349 uint8_t reason;
350} __attribute__ ((packed)) disconnect_cp;
351#define DISCONNECT_CP_SIZE 3
352
353#define OCF_ADD_SCO 0x0007
354typedef struct {
355 uint16_t handle;
356 uint16_t pkt_type;
357} __attribute__ ((packed)) add_sco_cp;
358#define ADD_SCO_CP_SIZE 4
359
360#define OCF_CREATE_CONN_CANCEL 0x0008
361typedef struct {
362 bdaddr_t bdaddr;
363} __attribute__ ((packed)) create_conn_cancel_cp;
364#define CREATE_CONN_CANCEL_CP_SIZE 6
365
366#define OCF_ACCEPT_CONN_REQ 0x0009
367typedef struct {
368 bdaddr_t bdaddr;
369 uint8_t role;
370} __attribute__ ((packed)) accept_conn_req_cp;
371#define ACCEPT_CONN_REQ_CP_SIZE 7
372
373#define OCF_REJECT_CONN_REQ 0x000A
374typedef struct {
375 bdaddr_t bdaddr;
376 uint8_t reason;
377} __attribute__ ((packed)) reject_conn_req_cp;
378#define REJECT_CONN_REQ_CP_SIZE 7
379
380#define OCF_LINK_KEY_REPLY 0x000B
381typedef struct {
382 bdaddr_t bdaddr;
383 uint8_t link_key[16];
384} __attribute__ ((packed)) link_key_reply_cp;
385#define LINK_KEY_REPLY_CP_SIZE 22
386
387#define OCF_LINK_KEY_NEG_REPLY 0x000C
388
389#define OCF_PIN_CODE_REPLY 0x000D
390typedef struct {
391 bdaddr_t bdaddr;
392 uint8_t pin_len;
393 uint8_t pin_code[16];
394} __attribute__ ((packed)) pin_code_reply_cp;
395#define PIN_CODE_REPLY_CP_SIZE 23
396
397#define OCF_PIN_CODE_NEG_REPLY 0x000E
398
399#define OCF_SET_CONN_PTYPE 0x000F
400typedef struct {
401 uint16_t handle;
402 uint16_t pkt_type;
403} __attribute__ ((packed)) set_conn_ptype_cp;
404#define SET_CONN_PTYPE_CP_SIZE 4
405
406#define OCF_AUTH_REQUESTED 0x0011
407typedef struct {
408 uint16_t handle;
409} __attribute__ ((packed)) auth_requested_cp;
410#define AUTH_REQUESTED_CP_SIZE 2
411
412#define OCF_SET_CONN_ENCRYPT 0x0013
413typedef struct {
414 uint16_t handle;
415 uint8_t encrypt;
416} __attribute__ ((packed)) set_conn_encrypt_cp;
417#define SET_CONN_ENCRYPT_CP_SIZE 3
418
419#define OCF_CHANGE_CONN_LINK_KEY 0x0015
420typedef struct {
421 uint16_t handle;
422} __attribute__ ((packed)) change_conn_link_key_cp;
423#define CHANGE_CONN_LINK_KEY_CP_SIZE 2
424
425#define OCF_MASTER_LINK_KEY 0x0017
426typedef struct {
427 uint8_t key_flag;
428} __attribute__ ((packed)) master_link_key_cp;
429#define MASTER_LINK_KEY_CP_SIZE 1
430
431#define OCF_REMOTE_NAME_REQ 0x0019
432typedef struct {
433 bdaddr_t bdaddr;
434 uint8_t pscan_rep_mode;
435 uint8_t pscan_mode;
436 uint16_t clock_offset;
437} __attribute__ ((packed)) remote_name_req_cp;
438#define REMOTE_NAME_REQ_CP_SIZE 10
439
440#define OCF_REMOTE_NAME_REQ_CANCEL 0x001A
441typedef struct {
442 bdaddr_t bdaddr;
443} __attribute__ ((packed)) remote_name_req_cancel_cp;
444#define REMOTE_NAME_REQ_CANCEL_CP_SIZE 6
445
446#define OCF_READ_REMOTE_FEATURES 0x001B
447typedef struct {
448 uint16_t handle;
449} __attribute__ ((packed)) read_remote_features_cp;
450#define READ_REMOTE_FEATURES_CP_SIZE 2
451
452#define OCF_READ_REMOTE_EXT_FEATURES 0x001C
453typedef struct {
454 uint16_t handle;
455 uint8_t page_num;
456} __attribute__ ((packed)) read_remote_ext_features_cp;
457#define READ_REMOTE_EXT_FEATURES_CP_SIZE 3
458
459#define OCF_READ_REMOTE_VERSION 0x001D
460typedef struct {
461 uint16_t handle;
462} __attribute__ ((packed)) read_remote_version_cp;
463#define READ_REMOTE_VERSION_CP_SIZE 2
464
465#define OCF_READ_CLOCK_OFFSET 0x001F
466typedef struct {
467 uint16_t handle;
468} __attribute__ ((packed)) read_clock_offset_cp;
469#define READ_CLOCK_OFFSET_CP_SIZE 2
470
471#define OCF_READ_LMP_HANDLE 0x0020
472
473#define OCF_SETUP_SYNC_CONN 0x0028
474typedef struct {
475 uint16_t handle;
476 uint32_t tx_bandwith;
477 uint32_t rx_bandwith;
478 uint16_t max_latency;
479 uint16_t voice_setting;
480 uint8_t retrans_effort;
481 uint16_t pkt_type;
482} __attribute__ ((packed)) setup_sync_conn_cp;
483#define SETUP_SYNC_CONN_CP_SIZE 17
484
485#define OCF_ACCEPT_SYNC_CONN_REQ 0x0029
486typedef struct {
487 bdaddr_t bdaddr;
488 uint32_t tx_bandwith;
489 uint32_t rx_bandwith;
490 uint16_t max_latency;
491 uint16_t voice_setting;
492 uint8_t retrans_effort;
493 uint16_t pkt_type;
494} __attribute__ ((packed)) accept_sync_conn_req_cp;
495#define ACCEPT_SYNC_CONN_REQ_CP_SIZE 21
496
497#define OCF_REJECT_SYNC_CONN_REQ 0x002A
498typedef struct {
499 bdaddr_t bdaddr;
500 uint8_t reason;
501} __attribute__ ((packed)) reject_sync_conn_req_cp;
502#define REJECT_SYNC_CONN_REQ_CP_SIZE 7
503
504#define OCF_IO_CAPABILITY_REPLY 0x002B
505typedef struct {
506 bdaddr_t bdaddr;
507 uint8_t capability;
508 uint8_t oob_data;
509 uint8_t authentication;
510} __attribute__ ((packed)) io_capability_reply_cp;
511#define IO_CAPABILITY_REPLY_CP_SIZE 9
512
513#define OCF_USER_CONFIRM_REPLY 0x002C
514typedef struct {
515 bdaddr_t bdaddr;
516} __attribute__ ((packed)) user_confirm_reply_cp;
517#define USER_CONFIRM_REPLY_CP_SIZE 6
518
519#define OCF_USER_CONFIRM_NEG_REPLY 0x002D
520
521#define OCF_USER_PASSKEY_REPLY 0x002E
522typedef struct {
523 bdaddr_t bdaddr;
524 uint32_t passkey;
525} __attribute__ ((packed)) user_passkey_reply_cp;
526#define USER_PASSKEY_REPLY_CP_SIZE 10
527
528#define OCF_USER_PASSKEY_NEG_REPLY 0x002F
529
530#define OCF_REMOTE_OOB_DATA_REPLY 0x0030
531typedef struct {
532 bdaddr_t bdaddr;
533 uint8_t hash[16];
534 uint8_t randomizer[16];
535} __attribute__ ((packed)) remote_oob_data_reply_cp;
536#define REMOTE_OOB_DATA_REPLY_CP_SIZE 38
537
538#define OCF_REMOTE_OOB_DATA_NEG_REPLY 0x0033
539
540#define OCF_IO_CAPABILITY_NEG_REPLY 0x0034
541typedef struct {
542 bdaddr_t bdaddr;
543 uint8_t reason;
544} __attribute__ ((packed)) io_capability_neg_reply_cp;
545#define IO_CAPABILITY_NEG_REPLY_CP_SIZE 7
546
547#define OCF_CREATE_PHYSICAL_LINK 0x0035
548typedef struct {
549 uint8_t handle;
550 uint8_t key_length;
551 uint8_t key_type;
552 uint8_t key[32];
553} __attribute__ ((packed)) create_physical_link_cp;
554#define CREATE_PHYSICAL_LINK_CP_SIZE 35
555
556#define OCF_ACCEPT_PHYSICAL_LINK 0x0036
557typedef struct {
558 uint8_t handle;
559 uint8_t key_length;
560 uint8_t key_type;
561 uint8_t key[32];
562} __attribute__ ((packed)) accept_physical_link_cp;
563#define ACCEPT_PHYSICAL_LINK_CP_SIZE 35
564
565#define OCF_DISCONNECT_PHYSICAL_LINK 0x0037
566typedef struct {
567 uint8_t handle;
568 uint8_t reason;
569} __attribute__ ((packed)) disconnect_physical_link_cp;
570#define DISCONNECT_PHYSICAL_LINK_CP_SIZE 2
571
572#define OCF_CREATE_LOGICAL_LINK 0x0038
573typedef struct {
574 uint8_t handle;
575 uint8_t tx_flow[16];
576 uint8_t rx_flow[16];
577} __attribute__ ((packed)) create_logical_link_cp;
578#define CREATE_LOGICAL_LINK_CP_SIZE 33
579
580#define OCF_ACCEPT_LOGICAL_LINK 0x0039
581
582#define OCF_DISCONNECT_LOGICAL_LINK 0x003A
583typedef struct {
584 uint16_t handle;
585} __attribute__ ((packed)) disconnect_logical_link_cp;
586#define DISCONNECT_LOGICAL_LINK_CP_SIZE 2
587
588#define OCF_LOGICAL_LINK_CANCEL 0x003B
589typedef struct {
590 uint8_t handle;
591 uint8_t tx_flow_id;
592} __attribute__ ((packed)) cancel_logical_link_cp;
593#define LOGICAL_LINK_CANCEL_CP_SIZE 2
594typedef struct {
595 uint8_t status;
596 uint8_t handle;
597 uint8_t tx_flow_id;
598} __attribute__ ((packed)) cancel_logical_link_rp;
599#define LOGICAL_LINK_CANCEL_RP_SIZE 3
600
601#define OCF_FLOW_SPEC_MODIFY 0x003C
602
603/* Link Policy */
604#define OGF_LINK_POLICY 0x02
605
606#define OCF_HOLD_MODE 0x0001
607typedef struct {
608 uint16_t handle;
609 uint16_t max_interval;
610 uint16_t min_interval;
611} __attribute__ ((packed)) hold_mode_cp;
612#define HOLD_MODE_CP_SIZE 6
613
614#define OCF_SNIFF_MODE 0x0003
615typedef struct {
616 uint16_t handle;
617 uint16_t max_interval;
618 uint16_t min_interval;
619 uint16_t attempt;
620 uint16_t timeout;
621} __attribute__ ((packed)) sniff_mode_cp;
622#define SNIFF_MODE_CP_SIZE 10
623
624#define OCF_EXIT_SNIFF_MODE 0x0004
625typedef struct {
626 uint16_t handle;
627} __attribute__ ((packed)) exit_sniff_mode_cp;
628#define EXIT_SNIFF_MODE_CP_SIZE 2
629
630#define OCF_PARK_MODE 0x0005
631typedef struct {
632 uint16_t handle;
633 uint16_t max_interval;
634 uint16_t min_interval;
635} __attribute__ ((packed)) park_mode_cp;
636#define PARK_MODE_CP_SIZE 6
637
638#define OCF_EXIT_PARK_MODE 0x0006
639typedef struct {
640 uint16_t handle;
641} __attribute__ ((packed)) exit_park_mode_cp;
642#define EXIT_PARK_MODE_CP_SIZE 2
643
644#define OCF_QOS_SETUP 0x0007
645typedef struct {
646 uint8_t service_type; /* 1 = best effort */
647 uint32_t token_rate; /* Byte per seconds */
648 uint32_t peak_bandwidth; /* Byte per seconds */
649 uint32_t latency; /* Microseconds */
650 uint32_t delay_variation; /* Microseconds */
651} __attribute__ ((packed)) hci_qos;
652#define HCI_QOS_CP_SIZE 17
653typedef struct {
654 uint16_t handle;
655 uint8_t flags; /* Reserved */
656 hci_qos qos;
657} __attribute__ ((packed)) qos_setup_cp;
658#define QOS_SETUP_CP_SIZE (3 + HCI_QOS_CP_SIZE)
659
660#define OCF_ROLE_DISCOVERY 0x0009
661typedef struct {
662 uint16_t handle;
663} __attribute__ ((packed)) role_discovery_cp;
664#define ROLE_DISCOVERY_CP_SIZE 2
665typedef struct {
666 uint8_t status;
667 uint16_t handle;
668 uint8_t role;
669} __attribute__ ((packed)) role_discovery_rp;
670#define ROLE_DISCOVERY_RP_SIZE 4
671
672#define OCF_SWITCH_ROLE 0x000B
673typedef struct {
674 bdaddr_t bdaddr;
675 uint8_t role;
676} __attribute__ ((packed)) switch_role_cp;
677#define SWITCH_ROLE_CP_SIZE 7
678
679#define OCF_READ_LINK_POLICY 0x000C
680typedef struct {
681 uint16_t handle;
682} __attribute__ ((packed)) read_link_policy_cp;
683#define READ_LINK_POLICY_CP_SIZE 2
684typedef struct {
685 uint8_t status;
686 uint16_t handle;
687 uint16_t policy;
688} __attribute__ ((packed)) read_link_policy_rp;
689#define READ_LINK_POLICY_RP_SIZE 5
690
691#define OCF_WRITE_LINK_POLICY 0x000D
692typedef struct {
693 uint16_t handle;
694 uint16_t policy;
695} __attribute__ ((packed)) write_link_policy_cp;
696#define WRITE_LINK_POLICY_CP_SIZE 4
697typedef struct {
698 uint8_t status;
699 uint16_t handle;
700} __attribute__ ((packed)) write_link_policy_rp;
701#define WRITE_LINK_POLICY_RP_SIZE 3
702
703#define OCF_READ_DEFAULT_LINK_POLICY 0x000E
704
705#define OCF_WRITE_DEFAULT_LINK_POLICY 0x000F
706
707#define OCF_FLOW_SPECIFICATION 0x0010
708
709#define OCF_SNIFF_SUBRATING 0x0011
710typedef struct {
711 uint16_t handle;
712 uint16_t max_latency;
713 uint16_t min_remote_timeout;
714 uint16_t min_local_timeout;
715} __attribute__ ((packed)) sniff_subrating_cp;
716#define SNIFF_SUBRATING_CP_SIZE 8
717
718/* Host Controller and Baseband */
719#define OGF_HOST_CTL 0x03
720
721#define OCF_SET_EVENT_MASK 0x0001
722typedef struct {
723 uint8_t mask[8];
724} __attribute__ ((packed)) set_event_mask_cp;
725#define SET_EVENT_MASK_CP_SIZE 8
726
727#define OCF_RESET 0x0003
728
729#define OCF_SET_EVENT_FLT 0x0005
730typedef struct {
731 uint8_t flt_type;
732 uint8_t cond_type;
733 uint8_t condition[];
734} __attribute__ ((packed)) set_event_flt_cp;
735#define SET_EVENT_FLT_CP_SIZE 2
736
737/* Filter types */
738#define FLT_CLEAR_ALL 0x00
739#define FLT_INQ_RESULT 0x01
740#define FLT_CONN_SETUP 0x02
741/* INQ_RESULT Condition types */
742#define INQ_RESULT_RETURN_ALL 0x00
743#define INQ_RESULT_RETURN_CLASS 0x01
744#define INQ_RESULT_RETURN_BDADDR 0x02
745/* CONN_SETUP Condition types */
746#define CONN_SETUP_ALLOW_ALL 0x00
747#define CONN_SETUP_ALLOW_CLASS 0x01
748#define CONN_SETUP_ALLOW_BDADDR 0x02
749/* CONN_SETUP Conditions */
750#define CONN_SETUP_AUTO_OFF 0x01
751#define CONN_SETUP_AUTO_ON 0x02
752
753#define OCF_FLUSH 0x0008
754
755#define OCF_READ_PIN_TYPE 0x0009
756typedef struct {
757 uint8_t status;
758 uint8_t pin_type;
759} __attribute__ ((packed)) read_pin_type_rp;
760#define READ_PIN_TYPE_RP_SIZE 2
761
762#define OCF_WRITE_PIN_TYPE 0x000A
763typedef struct {
764 uint8_t pin_type;
765} __attribute__ ((packed)) write_pin_type_cp;
766#define WRITE_PIN_TYPE_CP_SIZE 1
767
768#define OCF_CREATE_NEW_UNIT_KEY 0x000B
769
770#define OCF_READ_STORED_LINK_KEY 0x000D
771typedef struct {
772 bdaddr_t bdaddr;
773 uint8_t read_all;
774} __attribute__ ((packed)) read_stored_link_key_cp;
775#define READ_STORED_LINK_KEY_CP_SIZE 7
776typedef struct {
777 uint8_t status;
778 uint16_t max_keys;
779 uint16_t num_keys;
780} __attribute__ ((packed)) read_stored_link_key_rp;
781#define READ_STORED_LINK_KEY_RP_SIZE 5
782
783#define OCF_WRITE_STORED_LINK_KEY 0x0011
784typedef struct {
785 uint8_t num_keys;
786 /* variable length part */
787} __attribute__ ((packed)) write_stored_link_key_cp;
788#define WRITE_STORED_LINK_KEY_CP_SIZE 1
789typedef struct {
790 uint8_t status;
791 uint8_t num_keys;
792} __attribute__ ((packed)) write_stored_link_key_rp;
793#define READ_WRITE_LINK_KEY_RP_SIZE 2
794
795#define OCF_DELETE_STORED_LINK_KEY 0x0012
796typedef struct {
797 bdaddr_t bdaddr;
798 uint8_t delete_all;
799} __attribute__ ((packed)) delete_stored_link_key_cp;
800#define DELETE_STORED_LINK_KEY_CP_SIZE 7
801typedef struct {
802 uint8_t status;
803 uint16_t num_keys;
804} __attribute__ ((packed)) delete_stored_link_key_rp;
805#define DELETE_STORED_LINK_KEY_RP_SIZE 3
806
807#define HCI_MAX_NAME_LENGTH 248
808
809#define OCF_CHANGE_LOCAL_NAME 0x0013
810typedef struct {
811 uint8_t name[HCI_MAX_NAME_LENGTH];
812} __attribute__ ((packed)) change_local_name_cp;
813#define CHANGE_LOCAL_NAME_CP_SIZE 248
814
815#define OCF_READ_LOCAL_NAME 0x0014
816typedef struct {
817 uint8_t status;
818 uint8_t name[HCI_MAX_NAME_LENGTH];
819} __attribute__ ((packed)) read_local_name_rp;
820#define READ_LOCAL_NAME_RP_SIZE 249
821
822#define OCF_READ_CONN_ACCEPT_TIMEOUT 0x0015
823typedef struct {
824 uint8_t status;
825 uint16_t timeout;
826} __attribute__ ((packed)) read_conn_accept_timeout_rp;
827#define READ_CONN_ACCEPT_TIMEOUT_RP_SIZE 3
828
829#define OCF_WRITE_CONN_ACCEPT_TIMEOUT 0x0016
830typedef struct {
831 uint16_t timeout;
832} __attribute__ ((packed)) write_conn_accept_timeout_cp;
833#define WRITE_CONN_ACCEPT_TIMEOUT_CP_SIZE 2
834
835#define OCF_READ_PAGE_TIMEOUT 0x0017
836typedef struct {
837 uint8_t status;
838 uint16_t timeout;
839} __attribute__ ((packed)) read_page_timeout_rp;
840#define READ_PAGE_TIMEOUT_RP_SIZE 3
841
842#define OCF_WRITE_PAGE_TIMEOUT 0x0018
843typedef struct {
844 uint16_t timeout;
845} __attribute__ ((packed)) write_page_timeout_cp;
846#define WRITE_PAGE_TIMEOUT_CP_SIZE 2
847
848#define OCF_READ_SCAN_ENABLE 0x0019
849typedef struct {
850 uint8_t status;
851 uint8_t enable;
852} __attribute__ ((packed)) read_scan_enable_rp;
853#define READ_SCAN_ENABLE_RP_SIZE 2
854
855#define OCF_WRITE_SCAN_ENABLE 0x001A
856 #define SCAN_DISABLED 0x00
857 #define SCAN_INQUIRY 0x01
858 #define SCAN_PAGE 0x02
859
860#define OCF_READ_PAGE_ACTIVITY 0x001B
861typedef struct {
862 uint8_t status;
863 uint16_t interval;
864 uint16_t window;
865} __attribute__ ((packed)) read_page_activity_rp;
866#define READ_PAGE_ACTIVITY_RP_SIZE 5
867
868#define OCF_WRITE_PAGE_ACTIVITY 0x001C
869typedef struct {
870 uint16_t interval;
871 uint16_t window;
872} __attribute__ ((packed)) write_page_activity_cp;
873#define WRITE_PAGE_ACTIVITY_CP_SIZE 4
874
875#define OCF_READ_INQ_ACTIVITY 0x001D
876typedef struct {
877 uint8_t status;
878 uint16_t interval;
879 uint16_t window;
880} __attribute__ ((packed)) read_inq_activity_rp;
881#define READ_INQ_ACTIVITY_RP_SIZE 5
882
883#define OCF_WRITE_INQ_ACTIVITY 0x001E
884typedef struct {
885 uint16_t interval;
886 uint16_t window;
887} __attribute__ ((packed)) write_inq_activity_cp;
888#define WRITE_INQ_ACTIVITY_CP_SIZE 4
889
890#define OCF_READ_AUTH_ENABLE 0x001F
891
892#define OCF_WRITE_AUTH_ENABLE 0x0020
893 #define AUTH_DISABLED 0x00
894 #define AUTH_ENABLED 0x01
895
896#define OCF_READ_ENCRYPT_MODE 0x0021
897
898#define OCF_WRITE_ENCRYPT_MODE 0x0022
899 #define ENCRYPT_DISABLED 0x00
900 #define ENCRYPT_P2P 0x01
901 #define ENCRYPT_BOTH 0x02
902
903#define OCF_READ_CLASS_OF_DEV 0x0023
904typedef struct {
905 uint8_t status;
906 uint8_t dev_class[3];
907} __attribute__ ((packed)) read_class_of_dev_rp;
908#define READ_CLASS_OF_DEV_RP_SIZE 4
909
910#define OCF_WRITE_CLASS_OF_DEV 0x0024
911typedef struct {
912 uint8_t dev_class[3];
913} __attribute__ ((packed)) write_class_of_dev_cp;
914#define WRITE_CLASS_OF_DEV_CP_SIZE 3
915
916#define OCF_READ_VOICE_SETTING 0x0025
917typedef struct {
918 uint8_t status;
919 uint16_t voice_setting;
920} __attribute__ ((packed)) read_voice_setting_rp;
921#define READ_VOICE_SETTING_RP_SIZE 3
922
923#define OCF_WRITE_VOICE_SETTING 0x0026
924typedef struct {
925 uint16_t voice_setting;
926} __attribute__ ((packed)) write_voice_setting_cp;
927#define WRITE_VOICE_SETTING_CP_SIZE 2
928
929#define OCF_READ_AUTOMATIC_FLUSH_TIMEOUT 0x0027
930
931#define OCF_WRITE_AUTOMATIC_FLUSH_TIMEOUT 0x0028
932
933#define OCF_READ_NUM_BROADCAST_RETRANS 0x0029
934
935#define OCF_WRITE_NUM_BROADCAST_RETRANS 0x002A
936
937#define OCF_READ_HOLD_MODE_ACTIVITY 0x002B
938
939#define OCF_WRITE_HOLD_MODE_ACTIVITY 0x002C
940
941#define OCF_READ_TRANSMIT_POWER_LEVEL 0x002D
942typedef struct {
943 uint16_t handle;
944 uint8_t type;
945} __attribute__ ((packed)) read_transmit_power_level_cp;
946#define READ_TRANSMIT_POWER_LEVEL_CP_SIZE 3
947typedef struct {
948 uint8_t status;
949 uint16_t handle;
950 int8_t level;
951} __attribute__ ((packed)) read_transmit_power_level_rp;
952#define READ_TRANSMIT_POWER_LEVEL_RP_SIZE 4
953
954#define OCF_READ_SYNC_FLOW_ENABLE 0x002E
955
956#define OCF_WRITE_SYNC_FLOW_ENABLE 0x002F
957
958#define OCF_SET_CONTROLLER_TO_HOST_FC 0x0031
959
960#define OCF_HOST_BUFFER_SIZE 0x0033
961typedef struct {
962 uint16_t acl_mtu;
963 uint8_t sco_mtu;
964 uint16_t acl_max_pkt;
965 uint16_t sco_max_pkt;
966} __attribute__ ((packed)) host_buffer_size_cp;
967#define HOST_BUFFER_SIZE_CP_SIZE 7
968
969#define OCF_HOST_NUM_COMP_PKTS 0x0035
970typedef struct {
971 uint8_t num_hndl;
972 /* variable length part */
973} __attribute__ ((packed)) host_num_comp_pkts_cp;
974#define HOST_NUM_COMP_PKTS_CP_SIZE 1
975
976#define OCF_READ_LINK_SUPERVISION_TIMEOUT 0x0036
977typedef struct {
978 uint8_t status;
979 uint16_t handle;
980 uint16_t timeout;
981} __attribute__ ((packed)) read_link_supervision_timeout_rp;
982#define READ_LINK_SUPERVISION_TIMEOUT_RP_SIZE 5
983
984#define OCF_WRITE_LINK_SUPERVISION_TIMEOUT 0x0037
985typedef struct {
986 uint16_t handle;
987 uint16_t timeout;
988} __attribute__ ((packed)) write_link_supervision_timeout_cp;
989#define WRITE_LINK_SUPERVISION_TIMEOUT_CP_SIZE 4
990typedef struct {
991 uint8_t status;
992 uint16_t handle;
993} __attribute__ ((packed)) write_link_supervision_timeout_rp;
994#define WRITE_LINK_SUPERVISION_TIMEOUT_RP_SIZE 3
995
996#define OCF_READ_NUM_SUPPORTED_IAC 0x0038
997
998#define MAX_IAC_LAP 0x40
999#define OCF_READ_CURRENT_IAC_LAP 0x0039
1000typedef struct {
1001 uint8_t status;
1002 uint8_t num_current_iac;
1003 uint8_t lap[MAX_IAC_LAP][3];
1004} __attribute__ ((packed)) read_current_iac_lap_rp;
1005#define READ_CURRENT_IAC_LAP_RP_SIZE 2+3*MAX_IAC_LAP
1006
1007#define OCF_WRITE_CURRENT_IAC_LAP 0x003A
1008typedef struct {
1009 uint8_t num_current_iac;
1010 uint8_t lap[MAX_IAC_LAP][3];
1011} __attribute__ ((packed)) write_current_iac_lap_cp;
1012#define WRITE_CURRENT_IAC_LAP_CP_SIZE 1+3*MAX_IAC_LAP
1013
1014#define OCF_READ_PAGE_SCAN_PERIOD_MODE 0x003B
1015
1016#define OCF_WRITE_PAGE_SCAN_PERIOD_MODE 0x003C
1017
1018#define OCF_READ_PAGE_SCAN_MODE 0x003D
1019
1020#define OCF_WRITE_PAGE_SCAN_MODE 0x003E
1021
1022#define OCF_SET_AFH_CLASSIFICATION 0x003F
1023typedef struct {
1024 uint8_t map[10];
1025} __attribute__ ((packed)) set_afh_classification_cp;
1026#define SET_AFH_CLASSIFICATION_CP_SIZE 10
1027typedef struct {
1028 uint8_t status;
1029} __attribute__ ((packed)) set_afh_classification_rp;
1030#define SET_AFH_CLASSIFICATION_RP_SIZE 1
1031
1032#define OCF_READ_INQUIRY_SCAN_TYPE 0x0042
1033typedef struct {
1034 uint8_t status;
1035 uint8_t type;
1036} __attribute__ ((packed)) read_inquiry_scan_type_rp;
1037#define READ_INQUIRY_SCAN_TYPE_RP_SIZE 2
1038
1039#define OCF_WRITE_INQUIRY_SCAN_TYPE 0x0043
1040typedef struct {
1041 uint8_t type;
1042} __attribute__ ((packed)) write_inquiry_scan_type_cp;
1043#define WRITE_INQUIRY_SCAN_TYPE_CP_SIZE 1
1044typedef struct {
1045 uint8_t status;
1046} __attribute__ ((packed)) write_inquiry_scan_type_rp;
1047#define WRITE_INQUIRY_SCAN_TYPE_RP_SIZE 1
1048
1049#define OCF_READ_INQUIRY_MODE 0x0044
1050typedef struct {
1051 uint8_t status;
1052 uint8_t mode;
1053} __attribute__ ((packed)) read_inquiry_mode_rp;
1054#define READ_INQUIRY_MODE_RP_SIZE 2
1055
1056#define OCF_WRITE_INQUIRY_MODE 0x0045
1057typedef struct {
1058 uint8_t mode;
1059} __attribute__ ((packed)) write_inquiry_mode_cp;
1060#define WRITE_INQUIRY_MODE_CP_SIZE 1
1061typedef struct {
1062 uint8_t status;
1063} __attribute__ ((packed)) write_inquiry_mode_rp;
1064#define WRITE_INQUIRY_MODE_RP_SIZE 1
1065
1066#define OCF_READ_PAGE_SCAN_TYPE 0x0046
1067
1068#define OCF_WRITE_PAGE_SCAN_TYPE 0x0047
1069 #define PAGE_SCAN_TYPE_STANDARD 0x00
1070 #define PAGE_SCAN_TYPE_INTERLACED 0x01
1071
1072#define OCF_READ_AFH_MODE 0x0048
1073typedef struct {
1074 uint8_t status;
1075 uint8_t mode;
1076} __attribute__ ((packed)) read_afh_mode_rp;
1077#define READ_AFH_MODE_RP_SIZE 2
1078
1079#define OCF_WRITE_AFH_MODE 0x0049
1080typedef struct {
1081 uint8_t mode;
1082} __attribute__ ((packed)) write_afh_mode_cp;
1083#define WRITE_AFH_MODE_CP_SIZE 1
1084typedef struct {
1085 uint8_t status;
1086} __attribute__ ((packed)) write_afh_mode_rp;
1087#define WRITE_AFH_MODE_RP_SIZE 1
1088
1089#define HCI_MAX_EIR_LENGTH 240
1090
1091#define OCF_READ_EXT_INQUIRY_RESPONSE 0x0051
1092typedef struct {
1093 uint8_t status;
1094 uint8_t fec;
1095 uint8_t data[HCI_MAX_EIR_LENGTH];
1096} __attribute__ ((packed)) read_ext_inquiry_response_rp;
1097#define READ_EXT_INQUIRY_RESPONSE_RP_SIZE 242
1098
1099#define OCF_WRITE_EXT_INQUIRY_RESPONSE 0x0052
1100typedef struct {
1101 uint8_t fec;
1102 uint8_t data[HCI_MAX_EIR_LENGTH];
1103} __attribute__ ((packed)) write_ext_inquiry_response_cp;
1104#define WRITE_EXT_INQUIRY_RESPONSE_CP_SIZE 241
1105typedef struct {
1106 uint8_t status;
1107} __attribute__ ((packed)) write_ext_inquiry_response_rp;
1108#define WRITE_EXT_INQUIRY_RESPONSE_RP_SIZE 1
1109
1110#define OCF_REFRESH_ENCRYPTION_KEY 0x0053
1111typedef struct {
1112 uint16_t handle;
1113} __attribute__ ((packed)) refresh_encryption_key_cp;
1114#define REFRESH_ENCRYPTION_KEY_CP_SIZE 2
1115typedef struct {
1116 uint8_t status;
1117} __attribute__ ((packed)) refresh_encryption_key_rp;
1118#define REFRESH_ENCRYPTION_KEY_RP_SIZE 1
1119
1120#define OCF_READ_SIMPLE_PAIRING_MODE 0x0055
1121typedef struct {
1122 uint8_t status;
1123 uint8_t mode;
1124} __attribute__ ((packed)) read_simple_pairing_mode_rp;
1125#define READ_SIMPLE_PAIRING_MODE_RP_SIZE 2
1126
1127#define OCF_WRITE_SIMPLE_PAIRING_MODE 0x0056
1128typedef struct {
1129 uint8_t mode;
1130} __attribute__ ((packed)) write_simple_pairing_mode_cp;
1131#define WRITE_SIMPLE_PAIRING_MODE_CP_SIZE 1
1132typedef struct {
1133 uint8_t status;
1134} __attribute__ ((packed)) write_simple_pairing_mode_rp;
1135#define WRITE_SIMPLE_PAIRING_MODE_RP_SIZE 1
1136
1137#define OCF_READ_LOCAL_OOB_DATA 0x0057
1138typedef struct {
1139 uint8_t status;
1140 uint8_t hash[16];
1141 uint8_t randomizer[16];
1142} __attribute__ ((packed)) read_local_oob_data_rp;
1143#define READ_LOCAL_OOB_DATA_RP_SIZE 33
1144
1145#define OCF_READ_INQ_RESPONSE_TX_POWER_LEVEL 0x0058
1146typedef struct {
1147 uint8_t status;
1148 int8_t level;
1149} __attribute__ ((packed)) read_inq_response_tx_power_level_rp;
1150#define READ_INQ_RESPONSE_TX_POWER_LEVEL_RP_SIZE 2
1151
1152#define OCF_READ_INQUIRY_TRANSMIT_POWER_LEVEL 0x0058
1153typedef struct {
1154 uint8_t status;
1155 int8_t level;
1156} __attribute__ ((packed)) read_inquiry_transmit_power_level_rp;
1157#define READ_INQUIRY_TRANSMIT_POWER_LEVEL_RP_SIZE 2
1158
1159#define OCF_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL 0x0059
1160typedef struct {
1161 int8_t level;
1162} __attribute__ ((packed)) write_inquiry_transmit_power_level_cp;
1163#define WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_CP_SIZE 1
1164typedef struct {
1165 uint8_t status;
1166} __attribute__ ((packed)) write_inquiry_transmit_power_level_rp;
1167#define WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_RP_SIZE 1
1168
1169#define OCF_READ_DEFAULT_ERROR_DATA_REPORTING 0x005A
1170typedef struct {
1171 uint8_t status;
1172 uint8_t reporting;
1173} __attribute__ ((packed)) read_default_error_data_reporting_rp;
1174#define READ_DEFAULT_ERROR_DATA_REPORTING_RP_SIZE 2
1175
1176#define OCF_WRITE_DEFAULT_ERROR_DATA_REPORTING 0x005B
1177typedef struct {
1178 uint8_t reporting;
1179} __attribute__ ((packed)) write_default_error_data_reporting_cp;
1180#define WRITE_DEFAULT_ERROR_DATA_REPORTING_CP_SIZE 1
1181typedef struct {
1182 uint8_t status;
1183} __attribute__ ((packed)) write_default_error_data_reporting_rp;
1184#define WRITE_DEFAULT_ERROR_DATA_REPORTING_RP_SIZE 1
1185
1186#define OCF_ENHANCED_FLUSH 0x005F
1187typedef struct {
1188 uint16_t handle;
1189 uint8_t type;
1190} __attribute__ ((packed)) enhanced_flush_cp;
1191#define ENHANCED_FLUSH_CP_SIZE 3
1192
1193#define OCF_SEND_KEYPRESS_NOTIFY 0x0060
1194typedef struct {
1195 bdaddr_t bdaddr;
1196 uint8_t type;
1197} __attribute__ ((packed)) send_keypress_notify_cp;
1198#define SEND_KEYPRESS_NOTIFY_CP_SIZE 7
1199typedef struct {
1200 uint8_t status;
1201} __attribute__ ((packed)) send_keypress_notify_rp;
1202#define SEND_KEYPRESS_NOTIFY_RP_SIZE 1
1203
1204#define OCF_READ_LOGICAL_LINK_ACCEPT_TIMEOUT 0x0061
1205typedef struct {
1206 uint8_t status;
1207 uint16_t timeout;
1208} __attribute__ ((packed)) read_log_link_accept_timeout_rp;
1209#define READ_LOGICAL_LINK_ACCEPT_TIMEOUT_RP_SIZE 3
1210
1211#define OCF_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT 0x0062
1212typedef struct {
1213 uint16_t timeout;
1214} __attribute__ ((packed)) write_log_link_accept_timeout_cp;
1215#define WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT_CP_SIZE 2
1216
1217#define OCF_SET_EVENT_MASK_PAGE_2 0x0063
1218
1219#define OCF_READ_LOCATION_DATA 0x0064
1220
1221#define OCF_WRITE_LOCATION_DATA 0x0065
1222
1223#define OCF_READ_FLOW_CONTROL_MODE 0x0066
1224
1225#define OCF_WRITE_FLOW_CONTROL_MODE 0x0067
1226
1227#define OCF_READ_ENHANCED_TRANSMIT_POWER_LEVEL 0x0068
1228typedef struct {
1229 uint8_t status;
1230 uint16_t handle;
1231 int8_t level_gfsk;
1232 int8_t level_dqpsk;
1233 int8_t level_8dpsk;
1234} __attribute__ ((packed)) read_enhanced_transmit_power_level_rp;
1235#define READ_ENHANCED_TRANSMIT_POWER_LEVEL_RP_SIZE 6
1236
1237#define OCF_READ_BEST_EFFORT_FLUSH_TIMEOUT 0x0069
1238typedef struct {
1239 uint8_t status;
1240 uint32_t timeout;
1241} __attribute__ ((packed)) read_best_effort_flush_timeout_rp;
1242#define READ_BEST_EFFORT_FLUSH_TIMEOUT_RP_SIZE 5
1243
1244#define OCF_WRITE_BEST_EFFORT_FLUSH_TIMEOUT 0x006A
1245typedef struct {
1246 uint16_t handle;
1247 uint32_t timeout;
1248} __attribute__ ((packed)) write_best_effort_flush_timeout_cp;
1249#define WRITE_BEST_EFFORT_FLUSH_TIMEOUT_CP_SIZE 6
1250typedef struct {
1251 uint8_t status;
1252} __attribute__ ((packed)) write_best_effort_flush_timeout_rp;
1253#define WRITE_BEST_EFFORT_FLUSH_TIMEOUT_RP_SIZE 1
1254
1255#define OCF_READ_LE_HOST_SUPPORTED 0x006C
1256typedef struct {
1257 uint8_t status;
1258 uint8_t le;
1259 uint8_t simul;
1260} __attribute__ ((packed)) read_le_host_supported_rp;
1261#define READ_LE_HOST_SUPPORTED_RP_SIZE 3
1262
1263#define OCF_WRITE_LE_HOST_SUPPORTED 0x006D
1264typedef struct {
1265 uint8_t le;
1266 uint8_t simul;
1267} __attribute__ ((packed)) write_le_host_supported_cp;
1268#define WRITE_LE_HOST_SUPPORTED_CP_SIZE 2
1269
1270/* Informational Parameters */
1271#define OGF_INFO_PARAM 0x04
1272
1273#define OCF_READ_LOCAL_VERSION 0x0001
1274typedef struct {
1275 uint8_t status;
1276 uint8_t hci_ver;
1277 uint16_t hci_rev;
1278 uint8_t lmp_ver;
1279 uint16_t manufacturer;
1280 uint16_t lmp_subver;
1281} __attribute__ ((packed)) read_local_version_rp;
1282#define READ_LOCAL_VERSION_RP_SIZE 9
1283
1284#define OCF_READ_LOCAL_COMMANDS 0x0002
1285typedef struct {
1286 uint8_t status;
1287 uint8_t commands[64];
1288} __attribute__ ((packed)) read_local_commands_rp;
1289#define READ_LOCAL_COMMANDS_RP_SIZE 65
1290
1291#define OCF_READ_LOCAL_FEATURES 0x0003
1292typedef struct {
1293 uint8_t status;
1294 uint8_t features[8];
1295} __attribute__ ((packed)) read_local_features_rp;
1296#define READ_LOCAL_FEATURES_RP_SIZE 9
1297
1298#define OCF_READ_LOCAL_EXT_FEATURES 0x0004
1299typedef struct {
1300 uint8_t page_num;
1301} __attribute__ ((packed)) read_local_ext_features_cp;
1302#define READ_LOCAL_EXT_FEATURES_CP_SIZE 1
1303typedef struct {
1304 uint8_t status;
1305 uint8_t page_num;
1306 uint8_t max_page_num;
1307 uint8_t features[8];
1308} __attribute__ ((packed)) read_local_ext_features_rp;
1309#define READ_LOCAL_EXT_FEATURES_RP_SIZE 11
1310
1311#define OCF_READ_BUFFER_SIZE 0x0005
1312typedef struct {
1313 uint8_t status;
1314 uint16_t acl_mtu;
1315 uint8_t sco_mtu;
1316 uint16_t acl_max_pkt;
1317 uint16_t sco_max_pkt;
1318} __attribute__ ((packed)) read_buffer_size_rp;
1319#define READ_BUFFER_SIZE_RP_SIZE 8
1320
1321#define OCF_READ_COUNTRY_CODE 0x0007
1322
1323#define OCF_READ_BD_ADDR 0x0009
1324typedef struct {
1325 uint8_t status;
1326 bdaddr_t bdaddr;
1327} __attribute__ ((packed)) read_bd_addr_rp;
1328#define READ_BD_ADDR_RP_SIZE 7
1329
1330#define OCF_READ_DATA_BLOCK_SIZE 0x000A
1331typedef struct {
1332 uint8_t status;
1333 uint16_t max_acl_len;
1334 uint16_t data_block_len;
1335 uint16_t num_blocks;
1336} __attribute__ ((packed)) read_data_block_size_rp;
1337
1338/* Status params */
1339#define OGF_STATUS_PARAM 0x05
1340
1341#define OCF_READ_FAILED_CONTACT_COUNTER 0x0001
1342typedef struct {
1343 uint8_t status;
1344 uint16_t handle;
1345 uint8_t counter;
1346} __attribute__ ((packed)) read_failed_contact_counter_rp;
1347#define READ_FAILED_CONTACT_COUNTER_RP_SIZE 4
1348
1349#define OCF_RESET_FAILED_CONTACT_COUNTER 0x0002
1350typedef struct {
1351 uint8_t status;
1352 uint16_t handle;
1353} __attribute__ ((packed)) reset_failed_contact_counter_rp;
1354#define RESET_FAILED_CONTACT_COUNTER_RP_SIZE 3
1355
1356#define OCF_READ_LINK_QUALITY 0x0003
1357typedef struct {
1358 uint8_t status;
1359 uint16_t handle;
1360 uint8_t link_quality;
1361} __attribute__ ((packed)) read_link_quality_rp;
1362#define READ_LINK_QUALITY_RP_SIZE 4
1363
1364#define OCF_READ_RSSI 0x0005
1365typedef struct {
1366 uint8_t status;
1367 uint16_t handle;
1368 int8_t rssi;
1369} __attribute__ ((packed)) read_rssi_rp;
1370#define READ_RSSI_RP_SIZE 4
1371
1372#define OCF_READ_AFH_MAP 0x0006
1373typedef struct {
1374 uint8_t status;
1375 uint16_t handle;
1376 uint8_t mode;
1377 uint8_t map[10];
1378} __attribute__ ((packed)) read_afh_map_rp;
1379#define READ_AFH_MAP_RP_SIZE 14
1380
1381#define OCF_READ_CLOCK 0x0007
1382typedef struct {
1383 uint16_t handle;
1384 uint8_t which_clock;
1385} __attribute__ ((packed)) read_clock_cp;
1386#define READ_CLOCK_CP_SIZE 3
1387typedef struct {
1388 uint8_t status;
1389 uint16_t handle;
1390 uint32_t clock;
1391 uint16_t accuracy;
1392} __attribute__ ((packed)) read_clock_rp;
1393#define READ_CLOCK_RP_SIZE 9
1394
1395#define OCF_READ_LOCAL_AMP_INFO 0x0009
1396typedef struct {
1397 uint8_t status;
1398 uint8_t amp_status;
1399 uint32_t total_bandwidth;
1400 uint32_t max_guaranteed_bandwidth;
1401 uint32_t min_latency;
1402 uint32_t max_pdu_size;
1403 uint8_t controller_type;
1404 uint16_t pal_caps;
1405 uint16_t max_amp_assoc_length;
1406 uint32_t max_flush_timeout;
1407 uint32_t best_effort_flush_timeout;
1408} __attribute__ ((packed)) read_local_amp_info_rp;
1409#define READ_LOCAL_AMP_INFO_RP_SIZE 31
1410
1411#define OCF_READ_LOCAL_AMP_ASSOC 0x000A
1412typedef struct {
1413 uint8_t handle;
1414 uint16_t length_so_far;
1415 uint16_t assoc_length;
1416} __attribute__ ((packed)) read_local_amp_assoc_cp;
1417#define READ_LOCAL_AMP_ASSOC_CP_SIZE 5
1418typedef struct {
1419 uint8_t status;
1420 uint8_t handle;
1421 uint16_t length;
1422 uint8_t fragment[HCI_MAX_NAME_LENGTH];
1423} __attribute__ ((packed)) read_local_amp_assoc_rp;
1424#define READ_LOCAL_AMP_ASSOC_RP_SIZE 252
1425
1426#define OCF_WRITE_REMOTE_AMP_ASSOC 0x000B
1427typedef struct {
1428 uint8_t handle;
1429 uint16_t length_so_far;
1430 uint16_t remaining_length;
1431 uint8_t fragment[HCI_MAX_NAME_LENGTH];
1432} __attribute__ ((packed)) write_remote_amp_assoc_cp;
1433#define WRITE_REMOTE_AMP_ASSOC_CP_SIZE 253
1434typedef struct {
1435 uint8_t status;
1436 uint8_t handle;
1437} __attribute__ ((packed)) write_remote_amp_assoc_rp;
1438#define WRITE_REMOTE_AMP_ASSOC_RP_SIZE 2
1439
1440/* Testing commands */
1441#define OGF_TESTING_CMD 0x3e
1442
1443#define OCF_READ_LOOPBACK_MODE 0x0001
1444
1445#define OCF_WRITE_LOOPBACK_MODE 0x0002
1446
1447#define OCF_ENABLE_DEVICE_UNDER_TEST_MODE 0x0003
1448
1449#define OCF_WRITE_SIMPLE_PAIRING_DEBUG_MODE 0x0004
1450typedef struct {
1451 uint8_t mode;
1452} __attribute__ ((packed)) write_simple_pairing_debug_mode_cp;
1453#define WRITE_SIMPLE_PAIRING_DEBUG_MODE_CP_SIZE 1
1454typedef struct {
1455 uint8_t status;
1456} __attribute__ ((packed)) write_simple_pairing_debug_mode_rp;
1457#define WRITE_SIMPLE_PAIRING_DEBUG_MODE_RP_SIZE 1
1458
1459/* LE commands */
1460#define OGF_LE_CTL 0x08
1461
1462#define OCF_LE_SET_EVENT_MASK 0x0001
1463typedef struct {
1464 uint8_t mask[8];
1465} __attribute__ ((packed)) le_set_event_mask_cp;
1466#define LE_SET_EVENT_MASK_CP_SIZE 8
1467
1468#define OCF_LE_READ_BUFFER_SIZE 0x0002
1469typedef struct {
1470 uint8_t status;
1471 uint16_t pkt_len;
1472 uint8_t max_pkt;
1473} __attribute__ ((packed)) le_read_buffer_size_rp;
1474#define LE_READ_BUFFER_SIZE_RP_SIZE 4
1475
1476#define OCF_LE_READ_LOCAL_SUPPORTED_FEATURES 0x0003
1477typedef struct {
1478 uint8_t status;
1479 uint8_t features[8];
1480} __attribute__ ((packed)) le_read_local_supported_features_rp;
1481#define LE_READ_LOCAL_SUPPORTED_FEATURES_RP_SIZE 9
1482
1483#define OCF_LE_SET_RANDOM_ADDRESS 0x0005
1484typedef struct {
1485 bdaddr_t bdaddr;
1486} __attribute__ ((packed)) le_set_random_address_cp;
1487#define LE_SET_RANDOM_ADDRESS_CP_SIZE 6
1488
1489#define OCF_LE_SET_ADVERTISING_PARAMETERS 0x0006
1490typedef struct {
1491 uint16_t min_interval;
1492 uint16_t max_interval;
1493 uint8_t advtype;
1494 uint8_t own_bdaddr_type;
1495 uint8_t direct_bdaddr_type;
1496 bdaddr_t direct_bdaddr;
1497 uint8_t chan_map;
1498 uint8_t filter;
1499} __attribute__ ((packed)) le_set_advertising_parameters_cp;
1500#define LE_SET_ADVERTISING_PARAMETERS_CP_SIZE 15
1501
1502#define OCF_LE_READ_ADVERTISING_CHANNEL_TX_POWER 0x0007
1503typedef struct {
1504 uint8_t status;
1505 int8_t level;
1506} __attribute__ ((packed)) le_read_advertising_channel_tx_power_rp;
1507#define LE_READ_ADVERTISING_CHANNEL_TX_POWER_RP_SIZE 2
1508
1509#define OCF_LE_SET_ADVERTISING_DATA 0x0008
1510typedef struct {
1511 uint8_t length;
1512 uint8_t data[31];
1513} __attribute__ ((packed)) le_set_advertising_data_cp;
1514#define LE_SET_ADVERTISING_DATA_CP_SIZE 32
1515
1516#define OCF_LE_SET_SCAN_RESPONSE_DATA 0x0009
1517typedef struct {
1518 uint8_t length;
1519 uint8_t data[31];
1520} __attribute__ ((packed)) le_set_scan_response_data_cp;
1521#define LE_SET_SCAN_RESPONSE_DATA_CP_SIZE 32
1522
1523#define OCF_LE_SET_ADVERTISE_ENABLE 0x000A
1524typedef struct {
1525 uint8_t enable;
1526} __attribute__ ((packed)) le_set_advertise_enable_cp;
1527#define LE_SET_ADVERTISE_ENABLE_CP_SIZE 1
1528
1529#define OCF_LE_SET_SCAN_PARAMETERS 0x000B
1530typedef struct {
1531 uint8_t type;
1532 uint16_t interval;
1533 uint16_t window;
1534 uint8_t own_bdaddr_type;
1535 uint8_t filter;
1536} __attribute__ ((packed)) le_set_scan_parameters_cp;
1537#define LE_SET_SCAN_PARAMETERS_CP_SIZE 7
1538
1539#define OCF_LE_SET_SCAN_ENABLE 0x000C
1540typedef struct {
1541 uint8_t enable;
1542 uint8_t filter_dup;
1543} __attribute__ ((packed)) le_set_scan_enable_cp;
1544#define LE_SET_SCAN_ENABLE_CP_SIZE 2
1545
1546#define OCF_LE_CREATE_CONN 0x000D
1547typedef struct {
1548 uint16_t interval;
1549 uint16_t window;
1550 uint8_t initiator_filter;
1551 uint8_t peer_bdaddr_type;
1552 bdaddr_t peer_bdaddr;
1553 uint8_t own_bdaddr_type;
1554 uint16_t min_interval;
1555 uint16_t max_interval;
1556 uint16_t latency;
1557 uint16_t supervision_timeout;
1558 uint16_t min_ce_length;
1559 uint16_t max_ce_length;
1560} __attribute__ ((packed)) le_create_connection_cp;
1561#define LE_CREATE_CONN_CP_SIZE 25
1562
1563#define OCF_LE_CREATE_CONN_CANCEL 0x000E
1564
1565#define OCF_LE_READ_WHITE_LIST_SIZE 0x000F
1566typedef struct {
1567 uint8_t status;
1568 uint8_t size;
1569} __attribute__ ((packed)) le_read_white_list_size_rp;
1570#define LE_READ_WHITE_LIST_SIZE_RP_SIZE 2
1571
1572#define OCF_LE_CLEAR_WHITE_LIST 0x0010
1573
1574#define OCF_LE_ADD_DEVICE_TO_WHITE_LIST 0x0011
1575typedef struct {
1576 uint8_t bdaddr_type;
1577 bdaddr_t bdaddr;
1578} __attribute__ ((packed)) le_add_device_to_white_list_cp;
1579#define LE_ADD_DEVICE_TO_WHITE_LIST_CP_SIZE 7
1580
1581#define OCF_LE_REMOVE_DEVICE_FROM_WHITE_LIST 0x0012
1582typedef struct {
1583 uint8_t bdaddr_type;
1584 bdaddr_t bdaddr;
1585} __attribute__ ((packed)) le_remove_device_from_white_list_cp;
1586#define LE_REMOVE_DEVICE_FROM_WHITE_LIST_CP_SIZE 7
1587
1588#define OCF_LE_CONN_UPDATE 0x0013
1589typedef struct {
1590 uint16_t handle;
1591 uint16_t min_interval;
1592 uint16_t max_interval;
1593 uint16_t latency;
1594 uint16_t supervision_timeout;
1595 uint16_t min_ce_length;
1596 uint16_t max_ce_length;
1597} __attribute__ ((packed)) le_connection_update_cp;
1598#define LE_CONN_UPDATE_CP_SIZE 14
1599
1600#define OCF_LE_SET_HOST_CHANNEL_CLASSIFICATION 0x0014
1601typedef struct {
1602 uint8_t map[5];
1603} __attribute__ ((packed)) le_set_host_channel_classification_cp;
1604#define LE_SET_HOST_CHANNEL_CLASSIFICATION_CP_SIZE 5
1605
1606#define OCF_LE_READ_CHANNEL_MAP 0x0015
1607typedef struct {
1608 uint16_t handle;
1609} __attribute__ ((packed)) le_read_channel_map_cp;
1610#define LE_READ_CHANNEL_MAP_CP_SIZE 2
1611typedef struct {
1612 uint8_t status;
1613 uint16_t handle;
1614 uint8_t map[5];
1615} __attribute__ ((packed)) le_read_channel_map_rp;
1616#define LE_READ_CHANNEL_MAP_RP_SIZE 8
1617
1618#define OCF_LE_READ_REMOTE_USED_FEATURES 0x0016
1619typedef struct {
1620 uint16_t handle;
1621} __attribute__ ((packed)) le_read_remote_used_features_cp;
1622#define LE_READ_REMOTE_USED_FEATURES_CP_SIZE 2
1623
1624#define OCF_LE_ENCRYPT 0x0017
1625typedef struct {
1626 uint8_t key[16];
1627 uint8_t plaintext[16];
1628} __attribute__ ((packed)) le_encrypt_cp;
1629#define LE_ENCRYPT_CP_SIZE 32
1630typedef struct {
1631 uint8_t status;
1632 uint8_t data[16];
1633} __attribute__ ((packed)) le_encrypt_rp;
1634#define LE_ENCRYPT_RP_SIZE 17
1635
1636#define OCF_LE_RAND 0x0018
1637typedef struct {
1638 uint8_t status;
1639 uint64_t random;
1640} __attribute__ ((packed)) le_rand_rp;
1641#define LE_RAND_RP_SIZE 9
1642
1643#define OCF_LE_START_ENCRYPTION 0x0019
1644typedef struct {
1645 uint16_t handle;
1646 uint64_t random;
1647 uint16_t diversifier;
1648 uint8_t key[16];
1649} __attribute__ ((packed)) le_start_encryption_cp;
1650#define LE_START_ENCRYPTION_CP_SIZE 28
1651
1652#define OCF_LE_LTK_REPLY 0x001A
1653typedef struct {
1654 uint16_t handle;
1655 uint8_t key[16];
1656} __attribute__ ((packed)) le_ltk_reply_cp;
1657#define LE_LTK_REPLY_CP_SIZE 18
1658typedef struct {
1659 uint8_t status;
1660 uint16_t handle;
1661} __attribute__ ((packed)) le_ltk_reply_rp;
1662#define LE_LTK_REPLY_RP_SIZE 3
1663
1664#define OCF_LE_LTK_NEG_REPLY 0x001B
1665typedef struct {
1666 uint16_t handle;
1667} __attribute__ ((packed)) le_ltk_neg_reply_cp;
1668#define LE_LTK_NEG_REPLY_CP_SIZE 2
1669typedef struct {
1670 uint8_t status;
1671 uint16_t handle;
1672} __attribute__ ((packed)) le_ltk_neg_reply_rp;
1673#define LE_LTK_NEG_REPLY_RP_SIZE 3
1674
1675#define OCF_LE_READ_SUPPORTED_STATES 0x001C
1676typedef struct {
1677 uint8_t status;
1678 uint64_t states;
1679} __attribute__ ((packed)) le_read_supported_states_rp;
1680#define LE_READ_SUPPORTED_STATES_RP_SIZE 9
1681
1682#define OCF_LE_RECEIVER_TEST 0x001D
1683typedef struct {
1684 uint8_t frequency;
1685} __attribute__ ((packed)) le_receiver_test_cp;
1686#define LE_RECEIVER_TEST_CP_SIZE 1
1687
1688#define OCF_LE_TRANSMITTER_TEST 0x001E
1689typedef struct {
1690 uint8_t frequency;
1691 uint8_t length;
1692 uint8_t payload;
1693} __attribute__ ((packed)) le_transmitter_test_cp;
1694#define LE_TRANSMITTER_TEST_CP_SIZE 3
1695
1696#define OCF_LE_TEST_END 0x001F
1697typedef struct {
1698 uint8_t status;
1699 uint16_t num_pkts;
1700} __attribute__ ((packed)) le_test_end_rp;
1701#define LE_TEST_END_RP_SIZE 3
1702
1703#define OCF_LE_ADD_DEVICE_TO_RESOLV_LIST 0x0027
1704typedef struct {
1705 uint8_t bdaddr_type;
1706 bdaddr_t bdaddr;
1707 uint8_t peer_irk[16];
1708 uint8_t local_irk[16];
1709} __attribute__ ((packed)) le_add_device_to_resolv_list_cp;
1710#define LE_ADD_DEVICE_TO_RESOLV_LIST_CP_SIZE 39
1711
1712#define OCF_LE_REMOVE_DEVICE_FROM_RESOLV_LIST 0x0028
1713typedef struct {
1714 uint8_t bdaddr_type;
1715 bdaddr_t bdaddr;
1716} __attribute__ ((packed)) le_remove_device_from_resolv_list_cp;
1717#define LE_REMOVE_DEVICE_FROM_RESOLV_LIST_CP_SIZE 7
1718
1719#define OCF_LE_CLEAR_RESOLV_LIST 0x0029
1720
1721#define OCF_LE_READ_RESOLV_LIST_SIZE 0x002A
1722typedef struct {
1723 uint8_t status;
1724 uint8_t size;
1725} __attribute__ ((packed)) le_read_resolv_list_size_rp;
1726#define LE_READ_RESOLV_LIST_SIZE_RP_SIZE 2
1727
1728#define OCF_LE_SET_ADDRESS_RESOLUTION_ENABLE 0x002D
1729typedef struct {
1730 uint8_t enable;
1731} __attribute__ ((packed)) le_set_address_resolution_enable_cp;
1732#define LE_SET_ADDRESS_RESOLUTION_ENABLE_CP_SIZE 1
1733
1734/* Vendor specific commands */
1735#define OGF_VENDOR_CMD 0x3f
1736
1737/* ---- HCI Events ---- */
1738
1739#define EVT_INQUIRY_COMPLETE 0x01
1740
1741#define EVT_INQUIRY_RESULT 0x02
1742typedef struct {
1743 bdaddr_t bdaddr;
1744 uint8_t pscan_rep_mode;
1745 uint8_t pscan_period_mode;
1746 uint8_t pscan_mode;
1747 uint8_t dev_class[3];
1748 uint16_t clock_offset;
1749} __attribute__ ((packed)) inquiry_info;
1750#define INQUIRY_INFO_SIZE 14
1751
1752#define EVT_CONN_COMPLETE 0x03
1753typedef struct {
1754 uint8_t status;
1755 uint16_t handle;
1756 bdaddr_t bdaddr;
1757 uint8_t link_type;
1758 uint8_t encr_mode;
1759} __attribute__ ((packed)) evt_conn_complete;
1760#define EVT_CONN_COMPLETE_SIZE 11
1761
1762#define EVT_CONN_REQUEST 0x04
1763typedef struct {
1764 bdaddr_t bdaddr;
1765 uint8_t dev_class[3];
1766 uint8_t link_type;
1767} __attribute__ ((packed)) evt_conn_request;
1768#define EVT_CONN_REQUEST_SIZE 10
1769
1770#define EVT_DISCONN_COMPLETE 0x05
1771typedef struct {
1772 uint8_t status;
1773 uint16_t handle;
1774 uint8_t reason;
1775} __attribute__ ((packed)) evt_disconn_complete;
1776#define EVT_DISCONN_COMPLETE_SIZE 4
1777
1778#define EVT_AUTH_COMPLETE 0x06
1779typedef struct {
1780 uint8_t status;
1781 uint16_t handle;
1782} __attribute__ ((packed)) evt_auth_complete;
1783#define EVT_AUTH_COMPLETE_SIZE 3
1784
1785#define EVT_REMOTE_NAME_REQ_COMPLETE 0x07
1786typedef struct {
1787 uint8_t status;
1788 bdaddr_t bdaddr;
1789 uint8_t name[HCI_MAX_NAME_LENGTH];
1790} __attribute__ ((packed)) evt_remote_name_req_complete;
1791#define EVT_REMOTE_NAME_REQ_COMPLETE_SIZE 255
1792
1793#define EVT_ENCRYPT_CHANGE 0x08
1794typedef struct {
1795 uint8_t status;
1796 uint16_t handle;
1797 uint8_t encrypt;
1798} __attribute__ ((packed)) evt_encrypt_change;
1799#define EVT_ENCRYPT_CHANGE_SIZE 4
1800
1801#define EVT_CHANGE_CONN_LINK_KEY_COMPLETE 0x09
1802typedef struct {
1803 uint8_t status;
1804 uint16_t handle;
1805} __attribute__ ((packed)) evt_change_conn_link_key_complete;
1806#define EVT_CHANGE_CONN_LINK_KEY_COMPLETE_SIZE 3
1807
1808#define EVT_MASTER_LINK_KEY_COMPLETE 0x0A
1809typedef struct {
1810 uint8_t status;
1811 uint16_t handle;
1812 uint8_t key_flag;
1813} __attribute__ ((packed)) evt_master_link_key_complete;
1814#define EVT_MASTER_LINK_KEY_COMPLETE_SIZE 4
1815
1816#define EVT_READ_REMOTE_FEATURES_COMPLETE 0x0B
1817typedef struct {
1818 uint8_t status;
1819 uint16_t handle;
1820 uint8_t features[8];
1821} __attribute__ ((packed)) evt_read_remote_features_complete;
1822#define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11
1823
1824#define EVT_READ_REMOTE_VERSION_COMPLETE 0x0C
1825typedef struct {
1826 uint8_t status;
1827 uint16_t handle;
1828 uint8_t lmp_ver;
1829 uint16_t manufacturer;
1830 uint16_t lmp_subver;
1831} __attribute__ ((packed)) evt_read_remote_version_complete;
1832#define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8
1833
1834#define EVT_QOS_SETUP_COMPLETE 0x0D
1835typedef struct {
1836 uint8_t status;
1837 uint16_t handle;
1838 uint8_t flags; /* Reserved */
1839 hci_qos qos;
1840} __attribute__ ((packed)) evt_qos_setup_complete;
1841#define EVT_QOS_SETUP_COMPLETE_SIZE (4 + HCI_QOS_CP_SIZE)
1842
1843#define EVT_CMD_COMPLETE 0x0E
1844typedef struct {
1845 uint8_t ncmd;
1846 uint16_t opcode;
1847} __attribute__ ((packed)) evt_cmd_complete;
1848#define EVT_CMD_COMPLETE_SIZE 3
1849
1850#define EVT_CMD_STATUS 0x0F
1851typedef struct {
1852 uint8_t status;
1853 uint8_t ncmd;
1854 uint16_t opcode;
1855} __attribute__ ((packed)) evt_cmd_status;
1856#define EVT_CMD_STATUS_SIZE 4
1857
1858#define EVT_HARDWARE_ERROR 0x10
1859typedef struct {
1860 uint8_t code;
1861} __attribute__ ((packed)) evt_hardware_error;
1862#define EVT_HARDWARE_ERROR_SIZE 1
1863
1864#define EVT_FLUSH_OCCURRED 0x11
1865typedef struct {
1866 uint16_t handle;
1867} __attribute__ ((packed)) evt_flush_occured;
1868#define EVT_FLUSH_OCCURRED_SIZE 2
1869
1870#define EVT_ROLE_CHANGE 0x12
1871typedef struct {
1872 uint8_t status;
1873 bdaddr_t bdaddr;
1874 uint8_t role;
1875} __attribute__ ((packed)) evt_role_change;
1876#define EVT_ROLE_CHANGE_SIZE 8
1877
1878#define EVT_NUM_COMP_PKTS 0x13
1879typedef struct {
1880 uint8_t num_hndl;
1881 /* variable length part */
1882} __attribute__ ((packed)) evt_num_comp_pkts;
1883#define EVT_NUM_COMP_PKTS_SIZE 1
1884
1885#define EVT_MODE_CHANGE 0x14
1886typedef struct {
1887 uint8_t status;
1888 uint16_t handle;
1889 uint8_t mode;
1890 uint16_t interval;
1891} __attribute__ ((packed)) evt_mode_change;
1892#define EVT_MODE_CHANGE_SIZE 6
1893
1894#define EVT_RETURN_LINK_KEYS 0x15
1895typedef struct {
1896 uint8_t num_keys;
1897 /* variable length part */
1898} __attribute__ ((packed)) evt_return_link_keys;
1899#define EVT_RETURN_LINK_KEYS_SIZE 1
1900
1901#define EVT_PIN_CODE_REQ 0x16
1902typedef struct {
1903 bdaddr_t bdaddr;
1904} __attribute__ ((packed)) evt_pin_code_req;
1905#define EVT_PIN_CODE_REQ_SIZE 6
1906
1907#define EVT_LINK_KEY_REQ 0x17
1908typedef struct {
1909 bdaddr_t bdaddr;
1910} __attribute__ ((packed)) evt_link_key_req;
1911#define EVT_LINK_KEY_REQ_SIZE 6
1912
1913#define EVT_LINK_KEY_NOTIFY 0x18
1914typedef struct {
1915 bdaddr_t bdaddr;
1916 uint8_t link_key[16];
1917 uint8_t key_type;
1918} __attribute__ ((packed)) evt_link_key_notify;
1919#define EVT_LINK_KEY_NOTIFY_SIZE 23
1920
1921#define EVT_LOOPBACK_COMMAND 0x19
1922
1923#define EVT_DATA_BUFFER_OVERFLOW 0x1A
1924typedef struct {
1925 uint8_t link_type;
1926} __attribute__ ((packed)) evt_data_buffer_overflow;
1927#define EVT_DATA_BUFFER_OVERFLOW_SIZE 1
1928
1929#define EVT_MAX_SLOTS_CHANGE 0x1B
1930typedef struct {
1931 uint16_t handle;
1932 uint8_t max_slots;
1933} __attribute__ ((packed)) evt_max_slots_change;
1934#define EVT_MAX_SLOTS_CHANGE_SIZE 3
1935
1936#define EVT_READ_CLOCK_OFFSET_COMPLETE 0x1C
1937typedef struct {
1938 uint8_t status;
1939 uint16_t handle;
1940 uint16_t clock_offset;
1941} __attribute__ ((packed)) evt_read_clock_offset_complete;
1942#define EVT_READ_CLOCK_OFFSET_COMPLETE_SIZE 5
1943
1944#define EVT_CONN_PTYPE_CHANGED 0x1D
1945typedef struct {
1946 uint8_t status;
1947 uint16_t handle;
1948 uint16_t ptype;
1949} __attribute__ ((packed)) evt_conn_ptype_changed;
1950#define EVT_CONN_PTYPE_CHANGED_SIZE 5
1951
1952#define EVT_QOS_VIOLATION 0x1E
1953typedef struct {
1954 uint16_t handle;
1955} __attribute__ ((packed)) evt_qos_violation;
1956#define EVT_QOS_VIOLATION_SIZE 2
1957
1958#define EVT_PSCAN_REP_MODE_CHANGE 0x20
1959typedef struct {
1960 bdaddr_t bdaddr;
1961 uint8_t pscan_rep_mode;
1962} __attribute__ ((packed)) evt_pscan_rep_mode_change;
1963#define EVT_PSCAN_REP_MODE_CHANGE_SIZE 7
1964
1965#define EVT_FLOW_SPEC_COMPLETE 0x21
1966typedef struct {
1967 uint8_t status;
1968 uint16_t handle;
1969 uint8_t flags;
1970 uint8_t direction;
1971 hci_qos qos;
1972} __attribute__ ((packed)) evt_flow_spec_complete;
1973#define EVT_FLOW_SPEC_COMPLETE_SIZE (5 + HCI_QOS_CP_SIZE)
1974
1975#define EVT_INQUIRY_RESULT_WITH_RSSI 0x22
1976typedef struct {
1977 bdaddr_t bdaddr;
1978 uint8_t pscan_rep_mode;
1979 uint8_t pscan_period_mode;
1980 uint8_t dev_class[3];
1981 uint16_t clock_offset;
1982 int8_t rssi;
1983} __attribute__ ((packed)) inquiry_info_with_rssi;
1984#define INQUIRY_INFO_WITH_RSSI_SIZE 14
1985typedef struct {
1986 bdaddr_t bdaddr;
1987 uint8_t pscan_rep_mode;
1988 uint8_t pscan_period_mode;
1989 uint8_t pscan_mode;
1990 uint8_t dev_class[3];
1991 uint16_t clock_offset;
1992 int8_t rssi;
1993} __attribute__ ((packed)) inquiry_info_with_rssi_and_pscan_mode;
1994#define INQUIRY_INFO_WITH_RSSI_AND_PSCAN_MODE_SIZE 15
1995
1996#define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE 0x23
1997typedef struct {
1998 uint8_t status;
1999 uint16_t handle;
2000 uint8_t page_num;
2001 uint8_t max_page_num;
2002 uint8_t features[8];
2003} __attribute__ ((packed)) evt_read_remote_ext_features_complete;
2004#define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE_SIZE 13
2005
2006#define EVT_SYNC_CONN_COMPLETE 0x2C
2007typedef struct {
2008 uint8_t status;
2009 uint16_t handle;
2010 bdaddr_t bdaddr;
2011 uint8_t link_type;
2012 uint8_t trans_interval;
2013 uint8_t retrans_window;
2014 uint16_t rx_pkt_len;
2015 uint16_t tx_pkt_len;
2016 uint8_t air_mode;
2017} __attribute__ ((packed)) evt_sync_conn_complete;
2018#define EVT_SYNC_CONN_COMPLETE_SIZE 17
2019
2020#define EVT_SYNC_CONN_CHANGED 0x2D
2021typedef struct {
2022 uint8_t status;
2023 uint16_t handle;
2024 uint8_t trans_interval;
2025 uint8_t retrans_window;
2026 uint16_t rx_pkt_len;
2027 uint16_t tx_pkt_len;
2028} __attribute__ ((packed)) evt_sync_conn_changed;
2029#define EVT_SYNC_CONN_CHANGED_SIZE 9
2030
2031#define EVT_SNIFF_SUBRATING 0x2E
2032typedef struct {
2033 uint8_t status;
2034 uint16_t handle;
2035 uint16_t max_tx_latency;
2036 uint16_t max_rx_latency;
2037 uint16_t min_remote_timeout;
2038 uint16_t min_local_timeout;
2039} __attribute__ ((packed)) evt_sniff_subrating;
2040#define EVT_SNIFF_SUBRATING_SIZE 11
2041
2042#define EVT_EXTENDED_INQUIRY_RESULT 0x2F
2043typedef struct {
2044 bdaddr_t bdaddr;
2045 uint8_t pscan_rep_mode;
2046 uint8_t pscan_period_mode;
2047 uint8_t dev_class[3];
2048 uint16_t clock_offset;
2049 int8_t rssi;
2050 uint8_t data[HCI_MAX_EIR_LENGTH];
2051} __attribute__ ((packed)) extended_inquiry_info;
2052#define EXTENDED_INQUIRY_INFO_SIZE 254
2053
2054#define EVT_ENCRYPTION_KEY_REFRESH_COMPLETE 0x30
2055typedef struct {
2056 uint8_t status;
2057 uint16_t handle;
2058} __attribute__ ((packed)) evt_encryption_key_refresh_complete;
2059#define EVT_ENCRYPTION_KEY_REFRESH_COMPLETE_SIZE 3
2060
2061#define EVT_IO_CAPABILITY_REQUEST 0x31
2062typedef struct {
2063 bdaddr_t bdaddr;
2064} __attribute__ ((packed)) evt_io_capability_request;
2065#define EVT_IO_CAPABILITY_REQUEST_SIZE 6
2066
2067#define EVT_IO_CAPABILITY_RESPONSE 0x32
2068typedef struct {
2069 bdaddr_t bdaddr;
2070 uint8_t capability;
2071 uint8_t oob_data;
2072 uint8_t authentication;
2073} __attribute__ ((packed)) evt_io_capability_response;
2074#define EVT_IO_CAPABILITY_RESPONSE_SIZE 9
2075
2076#define EVT_USER_CONFIRM_REQUEST 0x33
2077typedef struct {
2078 bdaddr_t bdaddr;
2079 uint32_t passkey;
2080} __attribute__ ((packed)) evt_user_confirm_request;
2081#define EVT_USER_CONFIRM_REQUEST_SIZE 10
2082
2083#define EVT_USER_PASSKEY_REQUEST 0x34
2084typedef struct {
2085 bdaddr_t bdaddr;
2086} __attribute__ ((packed)) evt_user_passkey_request;
2087#define EVT_USER_PASSKEY_REQUEST_SIZE 6
2088
2089#define EVT_REMOTE_OOB_DATA_REQUEST 0x35
2090typedef struct {
2091 bdaddr_t bdaddr;
2092} __attribute__ ((packed)) evt_remote_oob_data_request;
2093#define EVT_REMOTE_OOB_DATA_REQUEST_SIZE 6
2094
2095#define EVT_SIMPLE_PAIRING_COMPLETE 0x36
2096typedef struct {
2097 uint8_t status;
2098 bdaddr_t bdaddr;
2099} __attribute__ ((packed)) evt_simple_pairing_complete;
2100#define EVT_SIMPLE_PAIRING_COMPLETE_SIZE 7
2101
2102#define EVT_LINK_SUPERVISION_TIMEOUT_CHANGED 0x38
2103typedef struct {
2104 uint16_t handle;
2105 uint16_t timeout;
2106} __attribute__ ((packed)) evt_link_supervision_timeout_changed;
2107#define EVT_LINK_SUPERVISION_TIMEOUT_CHANGED_SIZE 4
2108
2109#define EVT_ENHANCED_FLUSH_COMPLETE 0x39
2110typedef struct {
2111 uint16_t handle;
2112} __attribute__ ((packed)) evt_enhanced_flush_complete;
2113#define EVT_ENHANCED_FLUSH_COMPLETE_SIZE 2
2114
2115#define EVT_USER_PASSKEY_NOTIFY 0x3B
2116typedef struct {
2117 bdaddr_t bdaddr;
2118 uint32_t passkey;
2119} __attribute__ ((packed)) evt_user_passkey_notify;
2120#define EVT_USER_PASSKEY_NOTIFY_SIZE 10
2121
2122#define EVT_KEYPRESS_NOTIFY 0x3C
2123typedef struct {
2124 bdaddr_t bdaddr;
2125 uint8_t type;
2126} __attribute__ ((packed)) evt_keypress_notify;
2127#define EVT_KEYPRESS_NOTIFY_SIZE 7
2128
2129#define EVT_REMOTE_HOST_FEATURES_NOTIFY 0x3D
2130typedef struct {
2131 bdaddr_t bdaddr;
2132 uint8_t features[8];
2133} __attribute__ ((packed)) evt_remote_host_features_notify;
2134#define EVT_REMOTE_HOST_FEATURES_NOTIFY_SIZE 14
2135
2136#define EVT_LE_META_EVENT 0x3E
2137typedef struct {
2138 uint8_t subevent;
2139 uint8_t data[];
2140} __attribute__ ((packed)) evt_le_meta_event;
2141#define EVT_LE_META_EVENT_SIZE 1
2142
2143#define EVT_LE_CONN_COMPLETE 0x01
2144typedef struct {
2145 uint8_t status;
2146 uint16_t handle;
2147 uint8_t role;
2148 uint8_t peer_bdaddr_type;
2149 bdaddr_t peer_bdaddr;
2150 uint16_t interval;
2151 uint16_t latency;
2152 uint16_t supervision_timeout;
2153 uint8_t master_clock_accuracy;
2154} __attribute__ ((packed)) evt_le_connection_complete;
2155#define EVT_LE_CONN_COMPLETE_SIZE 18
2156
2157#define EVT_LE_ADVERTISING_REPORT 0x02
2158typedef struct {
2159 uint8_t evt_type;
2160 uint8_t bdaddr_type;
2161 bdaddr_t bdaddr;
2162 uint8_t length;
2163 uint8_t data[];
2164} __attribute__ ((packed)) le_advertising_info;
2165#define LE_ADVERTISING_INFO_SIZE 9
2166
2167#define EVT_LE_CONN_UPDATE_COMPLETE 0x03
2168typedef struct {
2169 uint8_t status;
2170 uint16_t handle;
2171 uint16_t interval;
2172 uint16_t latency;
2173 uint16_t supervision_timeout;
2174} __attribute__ ((packed)) evt_le_connection_update_complete;
2175#define EVT_LE_CONN_UPDATE_COMPLETE_SIZE 9
2176
2177#define EVT_LE_READ_REMOTE_USED_FEATURES_COMPLETE 0x04
2178typedef struct {
2179 uint8_t status;
2180 uint16_t handle;
2181 uint8_t features[8];
2182} __attribute__ ((packed)) evt_le_read_remote_used_features_complete;
2183#define EVT_LE_READ_REMOTE_USED_FEATURES_COMPLETE_SIZE 11
2184
2185#define EVT_LE_LTK_REQUEST 0x05
2186typedef struct {
2187 uint16_t handle;
2188 uint64_t random;
2189 uint16_t diversifier;
2190} __attribute__ ((packed)) evt_le_long_term_key_request;
2191#define EVT_LE_LTK_REQUEST_SIZE 12
2192
2193#define EVT_PHYSICAL_LINK_COMPLETE 0x40
2194typedef struct {
2195 uint8_t status;
2196 uint8_t handle;
2197} __attribute__ ((packed)) evt_physical_link_complete;
2198#define EVT_PHYSICAL_LINK_COMPLETE_SIZE 2
2199
2200#define EVT_CHANNEL_SELECTED 0x41
2201
2202#define EVT_DISCONNECT_PHYSICAL_LINK_COMPLETE 0x42
2203typedef struct {
2204 uint8_t status;
2205 uint8_t handle;
2206 uint8_t reason;
2207} __attribute__ ((packed)) evt_disconn_physical_link_complete;
2208#define EVT_DISCONNECT_PHYSICAL_LINK_COMPLETE_SIZE 3
2209
2210#define EVT_PHYSICAL_LINK_LOSS_EARLY_WARNING 0x43
2211typedef struct {
2212 uint8_t handle;
2213 uint8_t reason;
2214} __attribute__ ((packed)) evt_physical_link_loss_warning;
2215#define EVT_PHYSICAL_LINK_LOSS_WARNING_SIZE 2
2216
2217#define EVT_PHYSICAL_LINK_RECOVERY 0x44
2218typedef struct {
2219 uint8_t handle;
2220} __attribute__ ((packed)) evt_physical_link_recovery;
2221#define EVT_PHYSICAL_LINK_RECOVERY_SIZE 1
2222
2223#define EVT_LOGICAL_LINK_COMPLETE 0x45
2224typedef struct {
2225 uint8_t status;
2226 uint16_t log_handle;
2227 uint8_t handle;
2228 uint8_t tx_flow_id;
2229} __attribute__ ((packed)) evt_logical_link_complete;
2230#define EVT_LOGICAL_LINK_COMPLETE_SIZE 5
2231
2232#define EVT_DISCONNECT_LOGICAL_LINK_COMPLETE 0x46
2233
2234#define EVT_FLOW_SPEC_MODIFY_COMPLETE 0x47
2235typedef struct {
2236 uint8_t status;
2237 uint16_t handle;
2238} __attribute__ ((packed)) evt_flow_spec_modify_complete;
2239#define EVT_FLOW_SPEC_MODIFY_COMPLETE_SIZE 3
2240
2241#define EVT_NUMBER_COMPLETED_BLOCKS 0x48
2242typedef struct {
2243 uint16_t handle;
2244 uint16_t num_cmplt_pkts;
2245 uint16_t num_cmplt_blks;
2246} __attribute__ ((packed)) cmplt_handle;
2247typedef struct {
2248 uint16_t total_num_blocks;
2249 uint8_t num_handles;
2250 cmplt_handle handles[];
2251} __attribute__ ((packed)) evt_num_completed_blocks;
2252
2253#define EVT_AMP_STATUS_CHANGE 0x4D
2254typedef struct {
2255 uint8_t status;
2256 uint8_t amp_status;
2257} __attribute__ ((packed)) evt_amp_status_change;
2258#define EVT_AMP_STATUS_CHANGE_SIZE 2
2259
2260#define EVT_TESTING 0xFE
2261
2262#define EVT_VENDOR 0xFF
2263
2264/* Internal events generated by BlueZ stack */
2265#define EVT_STACK_INTERNAL 0xFD
2266typedef struct {
2267 uint16_t type;
2268 uint8_t data[];
2269} __attribute__ ((packed)) evt_stack_internal;
2270#define EVT_STACK_INTERNAL_SIZE 2
2271
2272#define EVT_SI_DEVICE 0x01
2273typedef struct {
2274 uint16_t event;
2275 uint16_t dev_id;
2276} __attribute__ ((packed)) evt_si_device;
2277#define EVT_SI_DEVICE_SIZE 4
2278
2279/* -------- HCI Packet structures -------- */
2280#define HCI_TYPE_LEN 1
2281
2282typedef struct {
2283 uint16_t opcode; /* OCF & OGF */
2284 uint8_t plen;
2285} __attribute__ ((packed)) hci_command_hdr;
2286#define HCI_COMMAND_HDR_SIZE 3
2287
2288typedef struct {
2289 uint8_t evt;
2290 uint8_t plen;
2291} __attribute__ ((packed)) hci_event_hdr;
2292#define HCI_EVENT_HDR_SIZE 2
2293
2294typedef struct {
2295 uint16_t handle; /* Handle & Flags(PB, BC) */
2296 uint16_t dlen;
2297} __attribute__ ((packed)) hci_acl_hdr;
2298#define HCI_ACL_HDR_SIZE 4
2299
2300typedef struct {
2301 uint16_t handle;
2302 uint8_t dlen;
2303} __attribute__ ((packed)) hci_sco_hdr;
2304#define HCI_SCO_HDR_SIZE 3
2305
2306typedef struct {
2307 uint16_t device;
2308 uint16_t type;
2309 uint16_t plen;
2310} __attribute__ ((packed)) hci_msg_hdr;
2311#define HCI_MSG_HDR_SIZE 6
2312
2313/* Command opcode pack/unpack */
2314#define cmd_opcode_pack(ogf, ocf) (uint16_t)((ocf & 0x03ff)|(ogf << 10))
2315#define cmd_opcode_ogf(op) (op >> 10)
2316#define cmd_opcode_ocf(op) (op & 0x03ff)
2317
2318/* ACL handle and flags pack/unpack */
2319#define acl_handle_pack(h, f) (uint16_t)((h & 0x0fff)|(f << 12))
2320#define acl_handle(h) (h & 0x0fff)
2321#define acl_flags(h) (h >> 12)
2322
2323#endif /* _NO_HCI_DEFS */
2324
2325/* HCI Socket options */
2326#define HCI_DATA_DIR 1
2327#define HCI_FILTER 2
2328#define HCI_TIME_STAMP 3
2329
2330/* HCI CMSG flags */
2331#define HCI_CMSG_DIR 0x0001
2332#define HCI_CMSG_TSTAMP 0x0002
2333
2334struct sockaddr_hci {
2335 sa_family_t hci_family;
2336 unsigned short hci_dev;
2337 unsigned short hci_channel;
2338};
2339#define HCI_DEV_NONE 0xffff
2340
2341#define HCI_CHANNEL_RAW 0
2342#define HCI_CHANNEL_USER 1
2343#define HCI_CHANNEL_MONITOR 2
2344#define HCI_CHANNEL_CONTROL 3
2345#define HCI_CHANNEL_LOGGING 4
2346
2347struct hci_filter {
2348 uint32_t type_mask;
2349 uint32_t event_mask[2];
2350 uint16_t opcode;
2351};
2352
2353#define HCI_FLT_TYPE_BITS 31
2354#define HCI_FLT_EVENT_BITS 63
2355#define HCI_FLT_OGF_BITS 63
2356#define HCI_FLT_OCF_BITS 127
2357
2358/* Ioctl requests structures */
2359struct hci_dev_stats {
2360 uint32_t err_rx;
2361 uint32_t err_tx;
2362 uint32_t cmd_tx;
2363 uint32_t evt_rx;
2364 uint32_t acl_tx;
2365 uint32_t acl_rx;
2366 uint32_t sco_tx;
2367 uint32_t sco_rx;
2368 uint32_t byte_rx;
2369 uint32_t byte_tx;
2370};
2371
2372struct hci_dev_info {
2373 uint16_t dev_id;
2374 char name[8];
2375
2376 bdaddr_t bdaddr;
2377
2378 uint32_t flags;
2379 uint8_t type;
2380
2381 uint8_t features[8];
2382
2383 uint32_t pkt_type;
2384 uint32_t link_policy;
2385 uint32_t link_mode;
2386
2387 uint16_t acl_mtu;
2388 uint16_t acl_pkts;
2389 uint16_t sco_mtu;
2390 uint16_t sco_pkts;
2391
2392 struct hci_dev_stats stat;
2393};
2394
2395struct hci_conn_info {
2396 uint16_t handle;
2397 bdaddr_t bdaddr;
2398 uint8_t type;
2399 uint8_t out;
2400 uint16_t state;
2401 uint32_t link_mode;
2402};
2403
2404struct hci_dev_req {
2405 uint16_t dev_id;
2406 uint32_t dev_opt;
2407};
2408
2409struct hci_dev_list_req {
2410 uint16_t dev_num;
2411 struct hci_dev_req dev_req[]; /* hci_dev_req structures */
2412};
2413
2414struct hci_conn_list_req {
2415 uint16_t dev_id;
2416 uint16_t conn_num;
2417 struct hci_conn_info conn_info[];
2418};
2419
2420struct hci_conn_info_req {
2421 bdaddr_t bdaddr;
2422 uint8_t type;
2423 struct hci_conn_info conn_info[];
2424};
2425
2426struct hci_auth_info_req {
2427 bdaddr_t bdaddr;
2428 uint8_t type;
2429};
2430
2431struct hci_inquiry_req {
2432 uint16_t dev_id;
2433 uint16_t flags;
2434 uint8_t lap[3];
2435 uint8_t length;
2436 uint8_t num_rsp;
2437};
2438#define IREQ_CACHE_FLUSH 0x0001
2439
2440#ifdef __cplusplus
2441}
2442#endif
2443
2444#endif /* __HCI_H */
2445

source code of include/bluetooth/hci.h