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