1 /* 2 BlueZ - Bluetooth protocol stack for Linux 3 Copyright (C) 2000-2001 Qualcomm Incorporated 4 5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License version 2 as 9 published by the Free Software Foundation; 10 11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 22 SOFTWARE IS DISCLAIMED. 23 */ 24 25 #ifndef __HCI_H 26 #define __HCI_H 27 28 #define HCI_MAX_ACL_SIZE 1024 29 #define HCI_MAX_SCO_SIZE 255 30 #define HCI_MAX_EVENT_SIZE 260 31 #define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) 32 33 /* HCI dev events */ 34 #define HCI_DEV_REG 1 35 #define HCI_DEV_UNREG 2 36 #define HCI_DEV_UP 3 37 #define HCI_DEV_DOWN 4 38 #define HCI_DEV_SUSPEND 5 39 #define HCI_DEV_RESUME 6 40 41 /* HCI notify events */ 42 #define HCI_NOTIFY_CONN_ADD 1 43 #define HCI_NOTIFY_CONN_DEL 2 44 #define HCI_NOTIFY_VOICE_SETTING 3 45 46 /* HCI bus types */ 47 #define HCI_VIRTUAL 0 48 #define HCI_USB 1 49 #define HCI_PCCARD 2 50 #define HCI_UART 3 51 #define HCI_RS232 4 52 #define HCI_PCI 5 53 #define HCI_SDIO 6 54 55 /* HCI controller types */ 56 #define HCI_BREDR 0x00 57 #define HCI_AMP 0x01 58 59 /* HCI device quirks */ 60 enum { 61 HCI_QUIRK_NO_RESET, 62 HCI_QUIRK_RAW_DEVICE, 63 HCI_QUIRK_FIXUP_BUFFER_SIZE 64 }; 65 66 /* HCI device flags */ 67 enum { 68 HCI_UP, 69 HCI_INIT, 70 HCI_RUNNING, 71 72 HCI_PSCAN, 73 HCI_ISCAN, 74 HCI_AUTH, 75 HCI_ENCRYPT, 76 HCI_INQUIRY, 77 78 HCI_RAW, 79 }; 80 81 /* HCI ioctl defines */ 82 #define HCIDEVUP _IOW('H', 201, int) 83 #define HCIDEVDOWN _IOW('H', 202, int) 84 #define HCIDEVRESET _IOW('H', 203, int) 85 #define HCIDEVRESTAT _IOW('H', 204, int) 86 87 #define HCIGETDEVLIST _IOR('H', 210, int) 88 #define HCIGETDEVINFO _IOR('H', 211, int) 89 #define HCIGETCONNLIST _IOR('H', 212, int) 90 #define HCIGETCONNINFO _IOR('H', 213, int) 91 #define HCIGETAUTHINFO _IOR('H', 215, int) 92 93 #define HCISETRAW _IOW('H', 220, int) 94 #define HCISETSCAN _IOW('H', 221, int) 95 #define HCISETAUTH _IOW('H', 222, int) 96 #define HCISETENCRYPT _IOW('H', 223, int) 97 #define HCISETPTYPE _IOW('H', 224, int) 98 #define HCISETLINKPOL _IOW('H', 225, int) 99 #define HCISETLINKMODE _IOW('H', 226, int) 100 #define HCISETACLMTU _IOW('H', 227, int) 101 #define HCISETSCOMTU _IOW('H', 228, int) 102 103 #define HCIBLOCKADDR _IOW('H', 230, int) 104 #define HCIUNBLOCKADDR _IOW('H', 231, int) 105 106 #define HCIINQUIRY _IOR('H', 240, int) 107 108 /* HCI timeouts */ 109 #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */ 110 #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ 111 #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ 112 #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ 113 #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ 114 115 /* HCI data types */ 116 #define HCI_COMMAND_PKT 0x01 117 #define HCI_ACLDATA_PKT 0x02 118 #define HCI_SCODATA_PKT 0x03 119 #define HCI_EVENT_PKT 0x04 120 #define HCI_VENDOR_PKT 0xff 121 122 /* HCI packet types */ 123 #define HCI_DM1 0x0008 124 #define HCI_DM3 0x0400 125 #define HCI_DM5 0x4000 126 #define HCI_DH1 0x0010 127 #define HCI_DH3 0x0800 128 #define HCI_DH5 0x8000 129 130 #define HCI_HV1 0x0020 131 #define HCI_HV2 0x0040 132 #define HCI_HV3 0x0080 133 134 #define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3) 135 #define ACL_PTYPE_MASK (~SCO_PTYPE_MASK) 136 137 /* eSCO packet types */ 138 #define ESCO_HV1 0x0001 139 #define ESCO_HV2 0x0002 140 #define ESCO_HV3 0x0004 141 #define ESCO_EV3 0x0008 142 #define ESCO_EV4 0x0010 143 #define ESCO_EV5 0x0020 144 #define ESCO_2EV3 0x0040 145 #define ESCO_3EV3 0x0080 146 #define ESCO_2EV5 0x0100 147 #define ESCO_3EV5 0x0200 148 149 #define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3) 150 #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5) 151 152 /* ACL flags */ 153 #define ACL_START_NO_FLUSH 0x00 154 #define ACL_CONT 0x01 155 #define ACL_START 0x02 156 #define ACL_ACTIVE_BCAST 0x04 157 #define ACL_PICO_BCAST 0x08 158 159 /* Baseband links */ 160 #define SCO_LINK 0x00 161 #define ACL_LINK 0x01 162 #define ESCO_LINK 0x02 163 164 /* LMP features */ 165 #define LMP_3SLOT 0x01 166 #define LMP_5SLOT 0x02 167 #define LMP_ENCRYPT 0x04 168 #define LMP_SOFFSET 0x08 169 #define LMP_TACCURACY 0x10 170 #define LMP_RSWITCH 0x20 171 #define LMP_HOLD 0x40 172 #define LMP_SNIFF 0x80 173 174 #define LMP_PARK 0x01 175 #define LMP_RSSI 0x02 176 #define LMP_QUALITY 0x04 177 #define LMP_SCO 0x08 178 #define LMP_HV2 0x10 179 #define LMP_HV3 0x20 180 #define LMP_ULAW 0x40 181 #define LMP_ALAW 0x80 182 183 #define LMP_CVSD 0x01 184 #define LMP_PSCHEME 0x02 185 #define LMP_PCONTROL 0x04 186 187 #define LMP_ESCO 0x80 188 189 #define LMP_EV4 0x01 190 #define LMP_EV5 0x02 191 192 #define LMP_SNIFF_SUBR 0x02 193 #define LMP_EDR_ESCO_2M 0x20 194 #define LMP_EDR_ESCO_3M 0x40 195 #define LMP_EDR_3S_ESCO 0x80 196 197 #define LMP_SIMPLE_PAIR 0x08 198 #define LMP_NO_FLUSH 0x40 199 200 /* Connection modes */ 201 #define HCI_CM_ACTIVE 0x0000 202 #define HCI_CM_HOLD 0x0001 203 #define HCI_CM_SNIFF 0x0002 204 #define HCI_CM_PARK 0x0003 205 206 /* Link policies */ 207 #define HCI_LP_RSWITCH 0x0001 208 #define HCI_LP_HOLD 0x0002 209 #define HCI_LP_SNIFF 0x0004 210 #define HCI_LP_PARK 0x0008 211 212 /* Link modes */ 213 #define HCI_LM_ACCEPT 0x8000 214 #define HCI_LM_MASTER 0x0001 215 #define HCI_LM_AUTH 0x0002 216 #define HCI_LM_ENCRYPT 0x0004 217 #define HCI_LM_TRUSTED 0x0008 218 #define HCI_LM_RELIABLE 0x0010 219 #define HCI_LM_SECURE 0x0020 220 221 /* Authentication types */ 222 #define HCI_AT_NO_BONDING 0x00 223 #define HCI_AT_NO_BONDING_MITM 0x01 224 #define HCI_AT_DEDICATED_BONDING 0x02 225 #define HCI_AT_DEDICATED_BONDING_MITM 0x03 226 #define HCI_AT_GENERAL_BONDING 0x04 227 #define HCI_AT_GENERAL_BONDING_MITM 0x05 228 229 /* ----- HCI Commands ---- */ 230 #define HCI_OP_INQUIRY 0x0401 231 struct hci_cp_inquiry { 232 __u8 lap[3]; 233 __u8 length; 234 __u8 num_rsp; 235 } __packed; 236 237 #define HCI_OP_INQUIRY_CANCEL 0x0402 238 239 #define HCI_OP_EXIT_PERIODIC_INQ 0x0404 240 241 #define HCI_OP_CREATE_CONN 0x0405 242 struct hci_cp_create_conn { 243 bdaddr_t bdaddr; 244 __le16 pkt_type; 245 __u8 pscan_rep_mode; 246 __u8 pscan_mode; 247 __le16 clock_offset; 248 __u8 role_switch; 249 } __packed; 250 251 #define HCI_OP_DISCONNECT 0x0406 252 struct hci_cp_disconnect { 253 __le16 handle; 254 __u8 reason; 255 } __packed; 256 257 #define HCI_OP_ADD_SCO 0x0407 258 struct hci_cp_add_sco { 259 __le16 handle; 260 __le16 pkt_type; 261 } __packed; 262 263 #define HCI_OP_CREATE_CONN_CANCEL 0x0408 264 struct hci_cp_create_conn_cancel { 265 bdaddr_t bdaddr; 266 } __packed; 267 268 #define HCI_OP_ACCEPT_CONN_REQ 0x0409 269 struct hci_cp_accept_conn_req { 270 bdaddr_t bdaddr; 271 __u8 role; 272 } __packed; 273 274 #define HCI_OP_REJECT_CONN_REQ 0x040a 275 struct hci_cp_reject_conn_req { 276 bdaddr_t bdaddr; 277 __u8 reason; 278 } __packed; 279 280 #define HCI_OP_LINK_KEY_REPLY 0x040b 281 struct hci_cp_link_key_reply { 282 bdaddr_t bdaddr; 283 __u8 link_key[16]; 284 } __packed; 285 286 #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c 287 struct hci_cp_link_key_neg_reply { 288 bdaddr_t bdaddr; 289 } __packed; 290 291 #define HCI_OP_PIN_CODE_REPLY 0x040d 292 struct hci_cp_pin_code_reply { 293 bdaddr_t bdaddr; 294 __u8 pin_len; 295 __u8 pin_code[16]; 296 } __packed; 297 298 #define HCI_OP_PIN_CODE_NEG_REPLY 0x040e 299 struct hci_cp_pin_code_neg_reply { 300 bdaddr_t bdaddr; 301 } __packed; 302 303 #define HCI_OP_CHANGE_CONN_PTYPE 0x040f 304 struct hci_cp_change_conn_ptype { 305 __le16 handle; 306 __le16 pkt_type; 307 } __packed; 308 309 #define HCI_OP_AUTH_REQUESTED 0x0411 310 struct hci_cp_auth_requested { 311 __le16 handle; 312 } __packed; 313 314 #define HCI_OP_SET_CONN_ENCRYPT 0x0413 315 struct hci_cp_set_conn_encrypt { 316 __le16 handle; 317 __u8 encrypt; 318 } __packed; 319 320 #define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415 321 struct hci_cp_change_conn_link_key { 322 __le16 handle; 323 } __packed; 324 325 #define HCI_OP_REMOTE_NAME_REQ 0x0419 326 struct hci_cp_remote_name_req { 327 bdaddr_t bdaddr; 328 __u8 pscan_rep_mode; 329 __u8 pscan_mode; 330 __le16 clock_offset; 331 } __packed; 332 333 #define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a 334 struct hci_cp_remote_name_req_cancel { 335 bdaddr_t bdaddr; 336 } __packed; 337 338 #define HCI_OP_READ_REMOTE_FEATURES 0x041b 339 struct hci_cp_read_remote_features { 340 __le16 handle; 341 } __packed; 342 343 #define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c 344 struct hci_cp_read_remote_ext_features { 345 __le16 handle; 346 __u8 page; 347 } __packed; 348 349 #define HCI_OP_READ_REMOTE_VERSION 0x041d 350 struct hci_cp_read_remote_version { 351 __le16 handle; 352 } __packed; 353 354 #define HCI_OP_SETUP_SYNC_CONN 0x0428 355 struct hci_cp_setup_sync_conn { 356 __le16 handle; 357 __le32 tx_bandwidth; 358 __le32 rx_bandwidth; 359 __le16 max_latency; 360 __le16 voice_setting; 361 __u8 retrans_effort; 362 __le16 pkt_type; 363 } __packed; 364 365 #define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429 366 struct hci_cp_accept_sync_conn_req { 367 bdaddr_t bdaddr; 368 __le32 tx_bandwidth; 369 __le32 rx_bandwidth; 370 __le16 max_latency; 371 __le16 content_format; 372 __u8 retrans_effort; 373 __le16 pkt_type; 374 } __packed; 375 376 #define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a 377 struct hci_cp_reject_sync_conn_req { 378 bdaddr_t bdaddr; 379 __u8 reason; 380 } __packed; 381 382 #define HCI_OP_SNIFF_MODE 0x0803 383 struct hci_cp_sniff_mode { 384 __le16 handle; 385 __le16 max_interval; 386 __le16 min_interval; 387 __le16 attempt; 388 __le16 timeout; 389 } __packed; 390 391 #define HCI_OP_EXIT_SNIFF_MODE 0x0804 392 struct hci_cp_exit_sniff_mode { 393 __le16 handle; 394 } __packed; 395 396 #define HCI_OP_ROLE_DISCOVERY 0x0809 397 struct hci_cp_role_discovery { 398 __le16 handle; 399 } __packed; 400 struct hci_rp_role_discovery { 401 __u8 status; 402 __le16 handle; 403 __u8 role; 404 } __packed; 405 406 #define HCI_OP_SWITCH_ROLE 0x080b 407 struct hci_cp_switch_role { 408 bdaddr_t bdaddr; 409 __u8 role; 410 } __packed; 411 412 #define HCI_OP_READ_LINK_POLICY 0x080c 413 struct hci_cp_read_link_policy { 414 __le16 handle; 415 } __packed; 416 struct hci_rp_read_link_policy { 417 __u8 status; 418 __le16 handle; 419 __le16 policy; 420 } __packed; 421 422 #define HCI_OP_WRITE_LINK_POLICY 0x080d 423 struct hci_cp_write_link_policy { 424 __le16 handle; 425 __le16 policy; 426 } __packed; 427 struct hci_rp_write_link_policy { 428 __u8 status; 429 __le16 handle; 430 } __packed; 431 432 #define HCI_OP_READ_DEF_LINK_POLICY 0x080e 433 struct hci_rp_read_def_link_policy { 434 __u8 status; 435 __le16 policy; 436 } __packed; 437 438 #define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f 439 struct hci_cp_write_def_link_policy { 440 __le16 policy; 441 } __packed; 442 443 #define HCI_OP_SNIFF_SUBRATE 0x0811 444 struct hci_cp_sniff_subrate { 445 __le16 handle; 446 __le16 max_latency; 447 __le16 min_remote_timeout; 448 __le16 min_local_timeout; 449 } __packed; 450 451 #define HCI_OP_SET_EVENT_MASK 0x0c01 452 struct hci_cp_set_event_mask { 453 __u8 mask[8]; 454 } __packed; 455 456 #define HCI_OP_RESET 0x0c03 457 458 #define HCI_OP_SET_EVENT_FLT 0x0c05 459 struct hci_cp_set_event_flt { 460 __u8 flt_type; 461 __u8 cond_type; 462 __u8 condition[0]; 463 } __packed; 464 465 /* Filter types */ 466 #define HCI_FLT_CLEAR_ALL 0x00 467 #define HCI_FLT_INQ_RESULT 0x01 468 #define HCI_FLT_CONN_SETUP 0x02 469 470 /* CONN_SETUP Condition types */ 471 #define HCI_CONN_SETUP_ALLOW_ALL 0x00 472 #define HCI_CONN_SETUP_ALLOW_CLASS 0x01 473 #define HCI_CONN_SETUP_ALLOW_BDADDR 0x02 474 475 /* CONN_SETUP Conditions */ 476 #define HCI_CONN_SETUP_AUTO_OFF 0x01 477 #define HCI_CONN_SETUP_AUTO_ON 0x02 478 479 #define HCI_OP_WRITE_LOCAL_NAME 0x0c13 480 struct hci_cp_write_local_name { 481 __u8 name[248]; 482 } __packed; 483 484 #define HCI_OP_READ_LOCAL_NAME 0x0c14 485 struct hci_rp_read_local_name { 486 __u8 status; 487 __u8 name[248]; 488 } __packed; 489 490 #define HCI_OP_WRITE_CA_TIMEOUT 0x0c16 491 492 #define HCI_OP_WRITE_PG_TIMEOUT 0x0c18 493 494 #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a 495 #define SCAN_DISABLED 0x00 496 #define SCAN_INQUIRY 0x01 497 #define SCAN_PAGE 0x02 498 499 #define HCI_OP_READ_AUTH_ENABLE 0x0c1f 500 501 #define HCI_OP_WRITE_AUTH_ENABLE 0x0c20 502 #define AUTH_DISABLED 0x00 503 #define AUTH_ENABLED 0x01 504 505 #define HCI_OP_READ_ENCRYPT_MODE 0x0c21 506 507 #define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22 508 #define ENCRYPT_DISABLED 0x00 509 #define ENCRYPT_P2P 0x01 510 #define ENCRYPT_BOTH 0x02 511 512 #define HCI_OP_READ_CLASS_OF_DEV 0x0c23 513 struct hci_rp_read_class_of_dev { 514 __u8 status; 515 __u8 dev_class[3]; 516 } __packed; 517 518 #define HCI_OP_WRITE_CLASS_OF_DEV 0x0c24 519 struct hci_cp_write_class_of_dev { 520 __u8 dev_class[3]; 521 } __packed; 522 523 #define HCI_OP_READ_VOICE_SETTING 0x0c25 524 struct hci_rp_read_voice_setting { 525 __u8 status; 526 __le16 voice_setting; 527 } __packed; 528 529 #define HCI_OP_WRITE_VOICE_SETTING 0x0c26 530 struct hci_cp_write_voice_setting { 531 __le16 voice_setting; 532 } __packed; 533 534 #define HCI_OP_HOST_BUFFER_SIZE 0x0c33 535 struct hci_cp_host_buffer_size { 536 __le16 acl_mtu; 537 __u8 sco_mtu; 538 __le16 acl_max_pkt; 539 __le16 sco_max_pkt; 540 } __packed; 541 542 #define HCI_OP_READ_SSP_MODE 0x0c55 543 struct hci_rp_read_ssp_mode { 544 __u8 status; 545 __u8 mode; 546 } __packed; 547 548 #define HCI_OP_WRITE_SSP_MODE 0x0c56 549 struct hci_cp_write_ssp_mode { 550 __u8 mode; 551 } __packed; 552 553 #define HCI_OP_READ_LOCAL_VERSION 0x1001 554 struct hci_rp_read_local_version { 555 __u8 status; 556 __u8 hci_ver; 557 __le16 hci_rev; 558 __u8 lmp_ver; 559 __le16 manufacturer; 560 __le16 lmp_subver; 561 } __packed; 562 563 #define HCI_OP_READ_LOCAL_COMMANDS 0x1002 564 struct hci_rp_read_local_commands { 565 __u8 status; 566 __u8 commands[64]; 567 } __packed; 568 569 #define HCI_OP_READ_LOCAL_FEATURES 0x1003 570 struct hci_rp_read_local_features { 571 __u8 status; 572 __u8 features[8]; 573 } __packed; 574 575 #define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004 576 struct hci_rp_read_local_ext_features { 577 __u8 status; 578 __u8 page; 579 __u8 max_page; 580 __u8 features[8]; 581 } __packed; 582 583 #define HCI_OP_READ_BUFFER_SIZE 0x1005 584 struct hci_rp_read_buffer_size { 585 __u8 status; 586 __le16 acl_mtu; 587 __u8 sco_mtu; 588 __le16 acl_max_pkt; 589 __le16 sco_max_pkt; 590 } __packed; 591 592 #define HCI_OP_READ_BD_ADDR 0x1009 593 struct hci_rp_read_bd_addr { 594 __u8 status; 595 bdaddr_t bdaddr; 596 } __packed; 597 598 /* ---- HCI Events ---- */ 599 #define HCI_EV_INQUIRY_COMPLETE 0x01 600 601 #define HCI_EV_INQUIRY_RESULT 0x02 602 struct inquiry_info { 603 bdaddr_t bdaddr; 604 __u8 pscan_rep_mode; 605 __u8 pscan_period_mode; 606 __u8 pscan_mode; 607 __u8 dev_class[3]; 608 __le16 clock_offset; 609 } __packed; 610 611 #define HCI_EV_CONN_COMPLETE 0x03 612 struct hci_ev_conn_complete { 613 __u8 status; 614 __le16 handle; 615 bdaddr_t bdaddr; 616 __u8 link_type; 617 __u8 encr_mode; 618 } __packed; 619 620 #define HCI_EV_CONN_REQUEST 0x04 621 struct hci_ev_conn_request { 622 bdaddr_t bdaddr; 623 __u8 dev_class[3]; 624 __u8 link_type; 625 } __packed; 626 627 #define HCI_EV_DISCONN_COMPLETE 0x05 628 struct hci_ev_disconn_complete { 629 __u8 status; 630 __le16 handle; 631 __u8 reason; 632 } __packed; 633 634 #define HCI_EV_AUTH_COMPLETE 0x06 635 struct hci_ev_auth_complete { 636 __u8 status; 637 __le16 handle; 638 } __packed; 639 640 #define HCI_EV_REMOTE_NAME 0x07 641 struct hci_ev_remote_name { 642 __u8 status; 643 bdaddr_t bdaddr; 644 __u8 name[248]; 645 } __packed; 646 647 #define HCI_EV_ENCRYPT_CHANGE 0x08 648 struct hci_ev_encrypt_change { 649 __u8 status; 650 __le16 handle; 651 __u8 encrypt; 652 } __packed; 653 654 #define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09 655 struct hci_ev_change_link_key_complete { 656 __u8 status; 657 __le16 handle; 658 } __packed; 659 660 #define HCI_EV_REMOTE_FEATURES 0x0b 661 struct hci_ev_remote_features { 662 __u8 status; 663 __le16 handle; 664 __u8 features[8]; 665 } __packed; 666 667 #define HCI_EV_REMOTE_VERSION 0x0c 668 struct hci_ev_remote_version { 669 __u8 status; 670 __le16 handle; 671 __u8 lmp_ver; 672 __le16 manufacturer; 673 __le16 lmp_subver; 674 } __packed; 675 676 #define HCI_EV_QOS_SETUP_COMPLETE 0x0d 677 struct hci_qos { 678 __u8 service_type; 679 __u32 token_rate; 680 __u32 peak_bandwidth; 681 __u32 latency; 682 __u32 delay_variation; 683 } __packed; 684 struct hci_ev_qos_setup_complete { 685 __u8 status; 686 __le16 handle; 687 struct hci_qos qos; 688 } __packed; 689 690 #define HCI_EV_CMD_COMPLETE 0x0e 691 struct hci_ev_cmd_complete { 692 __u8 ncmd; 693 __le16 opcode; 694 } __packed; 695 696 #define HCI_EV_CMD_STATUS 0x0f 697 struct hci_ev_cmd_status { 698 __u8 status; 699 __u8 ncmd; 700 __le16 opcode; 701 } __packed; 702 703 #define HCI_EV_ROLE_CHANGE 0x12 704 struct hci_ev_role_change { 705 __u8 status; 706 bdaddr_t bdaddr; 707 __u8 role; 708 } __packed; 709 710 #define HCI_EV_NUM_COMP_PKTS 0x13 711 struct hci_ev_num_comp_pkts { 712 __u8 num_hndl; 713 /* variable length part */ 714 } __packed; 715 716 #define HCI_EV_MODE_CHANGE 0x14 717 struct hci_ev_mode_change { 718 __u8 status; 719 __le16 handle; 720 __u8 mode; 721 __le16 interval; 722 } __packed; 723 724 #define HCI_EV_PIN_CODE_REQ 0x16 725 struct hci_ev_pin_code_req { 726 bdaddr_t bdaddr; 727 } __packed; 728 729 #define HCI_EV_LINK_KEY_REQ 0x17 730 struct hci_ev_link_key_req { 731 bdaddr_t bdaddr; 732 } __packed; 733 734 #define HCI_EV_LINK_KEY_NOTIFY 0x18 735 struct hci_ev_link_key_notify { 736 bdaddr_t bdaddr; 737 __u8 link_key[16]; 738 __u8 key_type; 739 } __packed; 740 741 #define HCI_EV_CLOCK_OFFSET 0x1c 742 struct hci_ev_clock_offset { 743 __u8 status; 744 __le16 handle; 745 __le16 clock_offset; 746 } __packed; 747 748 #define HCI_EV_PKT_TYPE_CHANGE 0x1d 749 struct hci_ev_pkt_type_change { 750 __u8 status; 751 __le16 handle; 752 __le16 pkt_type; 753 } __packed; 754 755 #define HCI_EV_PSCAN_REP_MODE 0x20 756 struct hci_ev_pscan_rep_mode { 757 bdaddr_t bdaddr; 758 __u8 pscan_rep_mode; 759 } __packed; 760 761 #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22 762 struct inquiry_info_with_rssi { 763 bdaddr_t bdaddr; 764 __u8 pscan_rep_mode; 765 __u8 pscan_period_mode; 766 __u8 dev_class[3]; 767 __le16 clock_offset; 768 __s8 rssi; 769 } __packed; 770 struct inquiry_info_with_rssi_and_pscan_mode { 771 bdaddr_t bdaddr; 772 __u8 pscan_rep_mode; 773 __u8 pscan_period_mode; 774 __u8 pscan_mode; 775 __u8 dev_class[3]; 776 __le16 clock_offset; 777 __s8 rssi; 778 } __packed; 779 780 #define HCI_EV_REMOTE_EXT_FEATURES 0x23 781 struct hci_ev_remote_ext_features { 782 __u8 status; 783 __le16 handle; 784 __u8 page; 785 __u8 max_page; 786 __u8 features[8]; 787 } __packed; 788 789 #define HCI_EV_SYNC_CONN_COMPLETE 0x2c 790 struct hci_ev_sync_conn_complete { 791 __u8 status; 792 __le16 handle; 793 bdaddr_t bdaddr; 794 __u8 link_type; 795 __u8 tx_interval; 796 __u8 retrans_window; 797 __le16 rx_pkt_len; 798 __le16 tx_pkt_len; 799 __u8 air_mode; 800 } __packed; 801 802 #define HCI_EV_SYNC_CONN_CHANGED 0x2d 803 struct hci_ev_sync_conn_changed { 804 __u8 status; 805 __le16 handle; 806 __u8 tx_interval; 807 __u8 retrans_window; 808 __le16 rx_pkt_len; 809 __le16 tx_pkt_len; 810 } __packed; 811 812 #define HCI_EV_SNIFF_SUBRATE 0x2e 813 struct hci_ev_sniff_subrate { 814 __u8 status; 815 __le16 handle; 816 __le16 max_tx_latency; 817 __le16 max_rx_latency; 818 __le16 max_remote_timeout; 819 __le16 max_local_timeout; 820 } __packed; 821 822 #define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f 823 struct extended_inquiry_info { 824 bdaddr_t bdaddr; 825 __u8 pscan_rep_mode; 826 __u8 pscan_period_mode; 827 __u8 dev_class[3]; 828 __le16 clock_offset; 829 __s8 rssi; 830 __u8 data[240]; 831 } __packed; 832 833 #define HCI_EV_IO_CAPA_REQUEST 0x31 834 struct hci_ev_io_capa_request { 835 bdaddr_t bdaddr; 836 } __packed; 837 838 #define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36 839 struct hci_ev_simple_pair_complete { 840 __u8 status; 841 bdaddr_t bdaddr; 842 } __packed; 843 844 #define HCI_EV_REMOTE_HOST_FEATURES 0x3d 845 struct hci_ev_remote_host_features { 846 bdaddr_t bdaddr; 847 __u8 features[8]; 848 } __packed; 849 850 /* Internal events generated by Bluetooth stack */ 851 #define HCI_EV_STACK_INTERNAL 0xfd 852 struct hci_ev_stack_internal { 853 __u16 type; 854 __u8 data[0]; 855 } __packed; 856 857 #define HCI_EV_SI_DEVICE 0x01 858 struct hci_ev_si_device { 859 __u16 event; 860 __u16 dev_id; 861 } __packed; 862 863 #define HCI_EV_SI_SECURITY 0x02 864 struct hci_ev_si_security { 865 __u16 event; 866 __u16 proto; 867 __u16 subproto; 868 __u8 incoming; 869 } __packed; 870 871 /* ---- HCI Packet structures ---- */ 872 #define HCI_COMMAND_HDR_SIZE 3 873 #define HCI_EVENT_HDR_SIZE 2 874 #define HCI_ACL_HDR_SIZE 4 875 #define HCI_SCO_HDR_SIZE 3 876 877 struct hci_command_hdr { 878 __le16 opcode; /* OCF & OGF */ 879 __u8 plen; 880 } __packed; 881 882 struct hci_event_hdr { 883 __u8 evt; 884 __u8 plen; 885 } __packed; 886 887 struct hci_acl_hdr { 888 __le16 handle; /* Handle & Flags(PB, BC) */ 889 __le16 dlen; 890 } __packed; 891 892 struct hci_sco_hdr { 893 __le16 handle; 894 __u8 dlen; 895 } __packed; 896 897 #ifdef __KERNEL__ 898 #include <linux/skbuff.h> 899 static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) 900 { 901 return (struct hci_event_hdr *) skb->data; 902 } 903 904 static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb) 905 { 906 return (struct hci_acl_hdr *) skb->data; 907 } 908 909 static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb) 910 { 911 return (struct hci_sco_hdr *) skb->data; 912 } 913 #endif 914 915 /* Command opcode pack/unpack */ 916 #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) 917 #define hci_opcode_ogf(op) (op >> 10) 918 #define hci_opcode_ocf(op) (op & 0x03ff) 919 920 /* ACL handle and flags pack/unpack */ 921 #define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12)) 922 #define hci_handle(h) (h & 0x0fff) 923 #define hci_flags(h) (h >> 12) 924 925 /* ---- HCI Sockets ---- */ 926 927 /* Socket options */ 928 #define HCI_DATA_DIR 1 929 #define HCI_FILTER 2 930 #define HCI_TIME_STAMP 3 931 932 /* CMSG flags */ 933 #define HCI_CMSG_DIR 0x0001 934 #define HCI_CMSG_TSTAMP 0x0002 935 936 struct sockaddr_hci { 937 sa_family_t hci_family; 938 unsigned short hci_dev; 939 unsigned short hci_channel; 940 }; 941 #define HCI_DEV_NONE 0xffff 942 943 #define HCI_CHANNEL_RAW 0 944 #define HCI_CHANNEL_CONTROL 1 945 946 struct hci_filter { 947 unsigned long type_mask; 948 unsigned long event_mask[2]; 949 __le16 opcode; 950 }; 951 952 struct hci_ufilter { 953 __u32 type_mask; 954 __u32 event_mask[2]; 955 __le16 opcode; 956 }; 957 958 #define HCI_FLT_TYPE_BITS 31 959 #define HCI_FLT_EVENT_BITS 63 960 #define HCI_FLT_OGF_BITS 63 961 #define HCI_FLT_OCF_BITS 127 962 963 /* ---- HCI Ioctl requests structures ---- */ 964 struct hci_dev_stats { 965 __u32 err_rx; 966 __u32 err_tx; 967 __u32 cmd_tx; 968 __u32 evt_rx; 969 __u32 acl_tx; 970 __u32 acl_rx; 971 __u32 sco_tx; 972 __u32 sco_rx; 973 __u32 byte_rx; 974 __u32 byte_tx; 975 }; 976 977 struct hci_dev_info { 978 __u16 dev_id; 979 char name[8]; 980 981 bdaddr_t bdaddr; 982 983 __u32 flags; 984 __u8 type; 985 986 __u8 features[8]; 987 988 __u32 pkt_type; 989 __u32 link_policy; 990 __u32 link_mode; 991 992 __u16 acl_mtu; 993 __u16 acl_pkts; 994 __u16 sco_mtu; 995 __u16 sco_pkts; 996 997 struct hci_dev_stats stat; 998 }; 999 1000 struct hci_conn_info { 1001 __u16 handle; 1002 bdaddr_t bdaddr; 1003 __u8 type; 1004 __u8 out; 1005 __u16 state; 1006 __u32 link_mode; 1007 }; 1008 1009 struct hci_dev_req { 1010 __u16 dev_id; 1011 __u32 dev_opt; 1012 }; 1013 1014 struct hci_dev_list_req { 1015 __u16 dev_num; 1016 struct hci_dev_req dev_req[0]; /* hci_dev_req structures */ 1017 }; 1018 1019 struct hci_conn_list_req { 1020 __u16 dev_id; 1021 __u16 conn_num; 1022 struct hci_conn_info conn_info[0]; 1023 }; 1024 1025 struct hci_conn_info_req { 1026 bdaddr_t bdaddr; 1027 __u8 type; 1028 struct hci_conn_info conn_info[0]; 1029 }; 1030 1031 struct hci_auth_info_req { 1032 bdaddr_t bdaddr; 1033 __u8 type; 1034 }; 1035 1036 struct hci_inquiry_req { 1037 __u16 dev_id; 1038 __u16 flags; 1039 __u8 lap[3]; 1040 __u8 length; 1041 __u8 num_rsp; 1042 }; 1043 #define IREQ_CACHE_FLUSH 0x0001 1044 1045 #endif /* __HCI_H */ 1046