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