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