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/* 26 * $Id: hci.h,v 1.1.1.1 2008/10/15 03:29:28 james26_jang Exp $ 27 */ 28 29#ifndef __HCI_H 30#define __HCI_H 31 32#define HCI_MAX_ACL_SIZE 1024 33#define HCI_MAX_SCO_SIZE 255 34#define HCI_MAX_EVENT_SIZE 260 35#define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) 36 37/* HCI dev events */ 38#define HCI_DEV_REG 1 39#define HCI_DEV_UNREG 2 40#define HCI_DEV_UP 3 41#define HCI_DEV_DOWN 4 42 43/* HCI device types */ 44#define HCI_VHCI 0 45#define HCI_USB 1 46#define HCI_PCCARD 2 47#define HCI_UART 3 48#define HCI_RS232 4 49 50/* HCI device flags */ 51enum { 52 HCI_UP, 53 HCI_INIT, 54 HCI_RUNNING, 55 56 HCI_PSCAN, 57 HCI_ISCAN, 58 HCI_AUTH, 59 HCI_ENCRYPT, 60 HCI_INQUIRY, 61 62 HCI_RAW 63}; 64 65/* HCI ioctl defines */ 66#define HCIDEVUP _IOW('H', 201, int) 67#define HCIDEVDOWN _IOW('H', 202, int) 68#define HCIDEVRESET _IOW('H', 203, int) 69#define HCIDEVRESTAT _IOW('H', 204, int) 70 71#define HCIGETDEVLIST _IOR('H', 210, int) 72#define HCIGETDEVINFO _IOR('H', 211, int) 73#define HCIGETCONNLIST _IOR('H', 212, int) 74#define HCIGETCONNINFO _IOR('H', 213, int) 75 76#define HCISETRAW _IOW('H', 220, int) 77#define HCISETSCAN _IOW('H', 221, int) 78#define HCISETAUTH _IOW('H', 222, int) 79#define HCISETENCRYPT _IOW('H', 223, int) 80#define HCISETPTYPE _IOW('H', 224, int) 81#define HCISETLINKPOL _IOW('H', 225, int) 82#define HCISETLINKMODE _IOW('H', 226, int) 83#define HCISETACLMTU _IOW('H', 227, int) 84#define HCISETSCOMTU _IOW('H', 228, int) 85 86#define HCIINQUIRY _IOR('H', 240, int) 87 88/* HCI timeouts */ 89#define HCI_CONN_TIMEOUT (HZ * 40) 90#define HCI_DISCONN_TIMEOUT (HZ * 2) 91#define HCI_CONN_IDLE_TIMEOUT (HZ * 60) 92 93/* HCI Packet types */ 94#define HCI_COMMAND_PKT 0x01 95#define HCI_ACLDATA_PKT 0x02 96#define HCI_SCODATA_PKT 0x03 97#define HCI_EVENT_PKT 0x04 98#define HCI_UNKNOWN_PKT 0xff 99 100/* HCI Packet types */ 101#define HCI_DM1 0x0008 102#define HCI_DM3 0x0400 103#define HCI_DM5 0x4000 104#define HCI_DH1 0x0010 105#define HCI_DH3 0x0800 106#define HCI_DH5 0x8000 107 108#define HCI_HV1 0x0020 109#define HCI_HV2 0x0040 110#define HCI_HV3 0x0080 111 112#define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3) 113#define ACL_PTYPE_MASK (~SCO_PTYPE_MASK) 114 115/* ACL flags */ 116#define ACL_CONT 0x01 117#define ACL_START 0x02 118#define ACL_ACTIVE_BCAST 0x04 119#define ACL_PICO_BCAST 0x08 120 121/* Baseband links */ 122#define SCO_LINK 0x00 123#define ACL_LINK 0x01 124 125/* LMP features */ 126#define LMP_3SLOT 0x01 127#define LMP_5SLOT 0x02 128#define LMP_ENCRYPT 0x04 129#define LMP_SOFFSET 0x08 130#define LMP_TACCURACY 0x10 131#define LMP_RSWITCH 0x20 132#define LMP_HOLD 0x40 133#define LMP_SNIF 0x80 134 135#define LMP_PARK 0x01 136#define LMP_RSSI 0x02 137#define LMP_QUALITY 0x04 138#define LMP_SCO 0x08 139#define LMP_HV2 0x10 140#define LMP_HV3 0x20 141#define LMP_ULAW 0x40 142#define LMP_ALAW 0x80 143 144#define LMP_CVSD 0x01 145#define LMP_PSCHEME 0x02 146#define LMP_PCONTROL 0x04 147 148/* Link policies */ 149#define HCI_LP_RSWITCH 0x0001 150#define HCI_LP_HOLD 0x0002 151#define HCI_LP_SNIFF 0x0004 152#define HCI_LP_PARK 0x0008 153 154/* Link mode */ 155#define HCI_LM_ACCEPT 0x8000 156#define HCI_LM_MASTER 0x0001 157#define HCI_LM_AUTH 0x0002 158#define HCI_LM_ENCRYPT 0x0004 159#define HCI_LM_TRUSTED 0x0008 160 161/* ----- HCI Commands ----- */ 162/* OGF & OCF values */ 163 164/* Informational Parameters */ 165#define OGF_INFO_PARAM 0x04 166 167#define OCF_READ_LOCAL_VERSION 0x0001 168typedef struct { 169 __u8 status; 170 __u8 hci_ver; 171 __u16 hci_rev; 172 __u8 lmp_ver; 173 __u16 manufacturer; 174 __u16 lmp_subver; 175} __attribute__ ((packed)) read_local_version_rp; 176#define READ_LOCAL_VERSION_RP_SIZE 9 177 178#define OCF_READ_LOCAL_FEATURES 0x0003 179typedef struct { 180 __u8 status; 181 __u8 features[8]; 182} __attribute__ ((packed)) read_local_features_rp; 183 184#define OCF_READ_BUFFER_SIZE 0x0005 185typedef struct { 186 __u8 status; 187 __u16 acl_mtu; 188 __u8 sco_mtu; 189 __u16 acl_max_pkt; 190 __u16 sco_max_pkt; 191} __attribute__ ((packed)) read_buffer_size_rp; 192 193#define OCF_READ_BD_ADDR 0x0009 194typedef struct { 195 __u8 status; 196 bdaddr_t bdaddr; 197} __attribute__ ((packed)) read_bd_addr_rp; 198 199/* Host Controller and Baseband */ 200#define OGF_HOST_CTL 0x03 201#define OCF_RESET 0x0003 202#define OCF_READ_AUTH_ENABLE 0x001F 203#define OCF_WRITE_AUTH_ENABLE 0x0020 204 #define AUTH_DISABLED 0x00 205 #define AUTH_ENABLED 0x01 206 207#define OCF_READ_ENCRYPT_MODE 0x0021 208#define OCF_WRITE_ENCRYPT_MODE 0x0022 209 #define ENCRYPT_DISABLED 0x00 210 #define ENCRYPT_P2P 0x01 211 #define ENCRYPT_BOTH 0x02 212 213#define OCF_WRITE_CA_TIMEOUT 0x0016 214#define OCF_WRITE_PG_TIMEOUT 0x0018 215 216#define OCF_WRITE_SCAN_ENABLE 0x001A 217 #define SCAN_DISABLED 0x00 218 #define SCAN_INQUIRY 0x01 219 #define SCAN_PAGE 0x02 220 221#define OCF_SET_EVENT_FLT 0x0005 222typedef struct { 223 __u8 flt_type; 224 __u8 cond_type; 225 __u8 condition[0]; 226} __attribute__ ((packed)) set_event_flt_cp; 227#define SET_EVENT_FLT_CP_SIZE 2 228 229/* Filter types */ 230#define FLT_CLEAR_ALL 0x00 231#define FLT_INQ_RESULT 0x01 232#define FLT_CONN_SETUP 0x02 233 234/* CONN_SETUP Condition types */ 235#define CONN_SETUP_ALLOW_ALL 0x00 236#define CONN_SETUP_ALLOW_CLASS 0x01 237#define CONN_SETUP_ALLOW_BDADDR 0x02 238 239/* CONN_SETUP Conditions */ 240#define CONN_SETUP_AUTO_OFF 0x01 241#define CONN_SETUP_AUTO_ON 0x02 242 243#define OCF_CHANGE_LOCAL_NAME 0x0013 244typedef struct { 245 __u8 name[248]; 246} __attribute__ ((packed)) change_local_name_cp; 247#define CHANGE_LOCAL_NAME_CP_SIZE 248 248 249#define OCF_READ_LOCAL_NAME 0x0014 250typedef struct { 251 __u8 status; 252 __u8 name[248]; 253} __attribute__ ((packed)) read_local_name_rp; 254#define READ_LOCAL_NAME_RP_SIZE 249 255 256#define OCF_READ_CLASS_OF_DEV 0x0023 257typedef struct { 258 __u8 status; 259 __u8 dev_class[3]; 260} __attribute__ ((packed)) read_class_of_dev_rp; 261#define READ_CLASS_OF_DEV_RP_SIZE 4 262 263#define OCF_WRITE_CLASS_OF_DEV 0x0024 264typedef struct { 265 __u8 dev_class[3]; 266} __attribute__ ((packed)) write_class_of_dev_cp; 267#define WRITE_CLASS_OF_DEV_CP_SIZE 3 268 269#define OCF_HOST_BUFFER_SIZE 0x0033 270typedef struct { 271 __u16 acl_mtu; 272 __u8 sco_mtu; 273 __u16 acl_max_pkt; 274 __u16 sco_max_pkt; 275} __attribute__ ((packed)) host_buffer_size_cp; 276#define HOST_BUFFER_SIZE_CP_SIZE 7 277 278/* Link Control */ 279#define OGF_LINK_CTL 0x01 280#define OCF_CREATE_CONN 0x0005 281typedef struct { 282 bdaddr_t bdaddr; 283 __u16 pkt_type; 284 __u8 pscan_rep_mode; 285 __u8 pscan_mode; 286 __u16 clock_offset; 287 __u8 role_switch; 288} __attribute__ ((packed)) create_conn_cp; 289#define CREATE_CONN_CP_SIZE 13 290 291#define OCF_ACCEPT_CONN_REQ 0x0009 292typedef struct { 293 bdaddr_t bdaddr; 294 __u8 role; 295} __attribute__ ((packed)) accept_conn_req_cp; 296#define ACCEPT_CONN_REQ_CP_SIZE 7 297 298#define OCF_REJECT_CONN_REQ 0x000a 299typedef struct { 300 bdaddr_t bdaddr; 301 __u8 reason; 302} __attribute__ ((packed)) reject_conn_req_cp; 303#define REJECT_CONN_REQ_CP_SIZE 7 304 305#define OCF_DISCONNECT 0x0006 306typedef struct { 307 __u16 handle; 308 __u8 reason; 309} __attribute__ ((packed)) disconnect_cp; 310#define DISCONNECT_CP_SIZE 3 311 312#define OCF_ADD_SCO 0x0007 313typedef struct { 314 __u16 handle; 315 __u16 pkt_type; 316} __attribute__ ((packed)) add_sco_cp; 317#define ADD_SCO_CP_SIZE 4 318 319#define OCF_INQUIRY 0x0001 320typedef struct { 321 __u8 lap[3]; 322 __u8 length; 323 __u8 num_rsp; 324} __attribute__ ((packed)) inquiry_cp; 325#define INQUIRY_CP_SIZE 5 326 327typedef struct { 328 __u8 status; 329 bdaddr_t bdaddr; 330} __attribute__ ((packed)) status_bdaddr_rp; 331#define STATUS_BDADDR_RP_SIZE 7 332 333#define OCF_LINK_KEY_REPLY 0x000B 334#define OCF_LINK_KEY_NEG_REPLY 0x000C 335typedef struct { 336 bdaddr_t bdaddr; 337 __u8 link_key[16]; 338} __attribute__ ((packed)) link_key_reply_cp; 339#define LINK_KEY_REPLY_CP_SIZE 22 340 341#define OCF_PIN_CODE_REPLY 0x000D 342#define OCF_PIN_CODE_NEG_REPLY 0x000E 343typedef struct { 344 bdaddr_t bdaddr; 345 __u8 pin_len; 346 __u8 pin_code[16]; 347} __attribute__ ((packed)) pin_code_reply_cp; 348#define PIN_CODE_REPLY_CP_SIZE 23 349 350#define OCF_CHANGE_CONN_PTYPE 0x000F 351typedef struct { 352 __u16 handle; 353 __u16 pkt_type; 354} __attribute__ ((packed)) change_conn_ptype_cp; 355#define CHANGE_CONN_PTYPE_CP_SIZE 4 356 357#define OCF_AUTH_REQUESTED 0x0011 358typedef struct { 359 __u16 handle; 360} __attribute__ ((packed)) auth_requested_cp; 361#define AUTH_REQUESTED_CP_SIZE 2 362 363#define OCF_SET_CONN_ENCRYPT 0x0013 364typedef struct { 365 __u16 handle; 366 __u8 encrypt; 367} __attribute__ ((packed)) set_conn_encrypt_cp; 368#define SET_CONN_ENCRYPT_CP_SIZE 3 369 370#define OCF_REMOTE_NAME_REQ 0x0019 371typedef struct { 372 bdaddr_t bdaddr; 373 __u8 pscan_rep_mode; 374 __u8 pscan_mode; 375 __u16 clock_offset; 376} __attribute__ ((packed)) remote_name_req_cp; 377#define REMOTE_NAME_REQ_CP_SIZE 10 378 379#define OCF_READ_REMOTE_FEATURES 0x001B 380typedef struct { 381 __u16 handle; 382} __attribute__ ((packed)) read_remote_features_cp; 383#define READ_REMOTE_FEATURES_CP_SIZE 2 384 385#define OCF_READ_REMOTE_VERSION 0x001D 386typedef struct { 387 __u16 handle; 388} __attribute__ ((packed)) read_remote_version_cp; 389#define READ_REMOTE_VERSION_CP_SIZE 2 390 391/* Link Policy */ 392#define OGF_LINK_POLICY 0x02 393#define OCF_ROLE_DISCOVERY 0x0009 394typedef struct { 395 __u16 handle; 396} __attribute__ ((packed)) role_discovery_cp; 397#define ROLE_DISCOVERY_CP_SIZE 2 398typedef struct { 399 __u8 status; 400 __u16 handle; 401 __u8 role; 402} __attribute__ ((packed)) role_discovery_rp; 403#define ROLE_DISCOVERY_RP_SIZE 4 404 405#define OCF_READ_LINK_POLICY 0x000C 406typedef struct { 407 __u16 handle; 408} __attribute__ ((packed)) read_link_policy_cp; 409#define READ_LINK_POLICY_CP_SIZE 2 410typedef struct { 411 __u8 status; 412 __u16 handle; 413 __u16 policy; 414} __attribute__ ((packed)) read_link_policy_rp; 415#define READ_LINK_POLICY_RP_SIZE 5 416 417#define OCF_SWITCH_ROLE 0x000B 418typedef struct { 419 bdaddr_t bdaddr; 420 __u8 role; 421} __attribute__ ((packed)) switch_role_cp; 422#define SWITCH_ROLE_CP_SIZE 7 423 424#define OCF_WRITE_LINK_POLICY 0x000D 425typedef struct { 426 __u16 handle; 427 __u16 policy; 428} __attribute__ ((packed)) write_link_policy_cp; 429#define WRITE_LINK_POLICY_CP_SIZE 4 430typedef struct { 431 __u8 status; 432 __u16 handle; 433} __attribute__ ((packed)) write_link_policy_rp; 434#define WRITE_LINK_POLICY_RP_SIZE 3 435 436/* Status params */ 437#define OGF_STATUS_PARAM 0x05 438 439/* ---- HCI Events ---- */ 440#define EVT_INQUIRY_COMPLETE 0x01 441 442#define EVT_INQUIRY_RESULT 0x02 443typedef struct { 444 bdaddr_t bdaddr; 445 __u8 pscan_rep_mode; 446 __u8 pscan_period_mode; 447 __u8 pscan_mode; 448 __u8 dev_class[3]; 449 __u16 clock_offset; 450} __attribute__ ((packed)) inquiry_info; 451#define INQUIRY_INFO_SIZE 14 452 453#define EVT_CONN_COMPLETE 0x03 454typedef struct { 455 __u8 status; 456 __u16 handle; 457 bdaddr_t bdaddr; 458 __u8 link_type; 459 __u8 encr_mode; 460} __attribute__ ((packed)) evt_conn_complete; 461#define EVT_CONN_COMPLETE_SIZE 13 462 463#define EVT_CONN_REQUEST 0x04 464typedef struct { 465 bdaddr_t bdaddr; 466 __u8 dev_class[3]; 467 __u8 link_type; 468} __attribute__ ((packed)) evt_conn_request; 469#define EVT_CONN_REQUEST_SIZE 10 470 471#define EVT_DISCONN_COMPLETE 0x05 472typedef struct { 473 __u8 status; 474 __u16 handle; 475 __u8 reason; 476} __attribute__ ((packed)) evt_disconn_complete; 477#define EVT_DISCONN_COMPLETE_SIZE 4 478 479#define EVT_AUTH_COMPLETE 0x06 480typedef struct { 481 __u8 status; 482 __u16 handle; 483} __attribute__ ((packed)) evt_auth_complete; 484#define EVT_AUTH_COMPLETE_SIZE 3 485 486#define EVT_REMOTE_NAME_REQ_COMPLETE 0x07 487typedef struct { 488 __u8 status; 489 bdaddr_t bdaddr; 490 __u8 name[248]; 491} __attribute__ ((packed)) evt_remote_name_req_complete; 492#define EVT_REMOTE_NAME_REQ_COMPLETE_SIZE 255 493 494#define EVT_ENCRYPT_CHANGE 0x08 495typedef struct { 496 __u8 status; 497 __u16 handle; 498 __u8 encrypt; 499} __attribute__ ((packed)) evt_encrypt_change; 500#define EVT_ENCRYPT_CHANGE_SIZE 5 501 502#define EVT_QOS_SETUP_COMPLETE 0x0D 503typedef struct { 504 __u8 service_type; 505 __u32 token_rate; 506 __u32 peak_bandwidth; 507 __u32 latency; 508 __u32 delay_variation; 509} __attribute__ ((packed)) hci_qos; 510typedef struct { 511 __u8 status; 512 __u16 handle; 513 hci_qos qos; 514} __attribute__ ((packed)) evt_qos_setup_complete; 515#define EVT_QOS_SETUP_COMPLETE_SIZE 20 516 517#define EVT_CMD_COMPLETE 0x0e 518typedef struct { 519 __u8 ncmd; 520 __u16 opcode; 521} __attribute__ ((packed)) evt_cmd_complete; 522#define EVT_CMD_COMPLETE_SIZE 3 523 524#define EVT_CMD_STATUS 0x0f 525typedef struct { 526 __u8 status; 527 __u8 ncmd; 528 __u16 opcode; 529} __attribute__ ((packed)) evt_cmd_status; 530#define EVT_CMD_STATUS_SIZE 4 531 532#define EVT_NUM_COMP_PKTS 0x13 533typedef struct { 534 __u8 num_hndl; 535 /* variable length part */ 536} __attribute__ ((packed)) evt_num_comp_pkts; 537#define EVT_NUM_COMP_PKTS_SIZE 1 538 539#define EVT_ROLE_CHANGE 0x12 540typedef struct { 541 __u8 status; 542 bdaddr_t bdaddr; 543 __u8 role; 544} __attribute__ ((packed)) evt_role_change; 545#define EVT_ROLE_CHANGE_SIZE 1 546 547#define EVT_PIN_CODE_REQ 0x16 548typedef struct { 549 bdaddr_t bdaddr; 550} __attribute__ ((packed)) evt_pin_code_req; 551#define EVT_PIN_CODE_REQ_SIZE 6 552 553#define EVT_LINK_KEY_REQ 0x17 554typedef struct { 555 bdaddr_t bdaddr; 556} __attribute__ ((packed)) evt_link_key_req; 557#define EVT_LINK_KEY_REQ_SIZE 6 558 559#define EVT_LINK_KEY_NOTIFY 0x18 560typedef struct { 561 bdaddr_t bdaddr; 562 __u8 link_key[16]; 563 __u8 key_type; 564} __attribute__ ((packed)) evt_link_key_notify; 565#define EVT_LINK_KEY_NOTIFY_SIZE 23 566 567#define EVT_READ_REMOTE_FEATURES_COMPLETE 0x0B 568typedef struct { 569 __u8 status; 570 __u16 handle; 571 __u8 features[8]; 572} __attribute__ ((packed)) evt_read_remote_features_complete; 573#define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11 574 575#define EVT_READ_REMOTE_VERSION_COMPLETE 0x0C 576typedef struct { 577 __u8 status; 578 __u16 handle; 579 __u8 lmp_ver; 580 __u16 manufacturer; 581 __u16 lmp_subver; 582} __attribute__ ((packed)) evt_read_remote_version_complete; 583#define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8 584 585/* Internal events generated by BlueZ stack */ 586#define EVT_STACK_INTERNAL 0xfd 587typedef struct { 588 __u16 type; 589 __u8 data[0]; 590} __attribute__ ((packed)) evt_stack_internal; 591#define EVT_STACK_INTERNAL_SIZE 2 592 593#define EVT_SI_DEVICE 0x01 594typedef struct { 595 __u16 event; 596 __u16 dev_id; 597} __attribute__ ((packed)) evt_si_device; 598#define EVT_SI_DEVICE_SIZE 4 599 600#define EVT_SI_SECURITY 0x02 601typedef struct { 602 __u16 event; 603 __u16 proto; 604 __u16 subproto; 605 __u8 incomming; 606} __attribute__ ((packed)) evt_si_security; 607 608/* -------- HCI Packet structures -------- */ 609#define HCI_TYPE_LEN 1 610 611typedef struct { 612 __u16 opcode; /* OCF & OGF */ 613 __u8 plen; 614} __attribute__ ((packed)) hci_command_hdr; 615#define HCI_COMMAND_HDR_SIZE 3 616 617typedef struct { 618 __u8 evt; 619 __u8 plen; 620} __attribute__ ((packed)) hci_event_hdr; 621#define HCI_EVENT_HDR_SIZE 2 622 623typedef struct { 624 __u16 handle; /* Handle & Flags(PB, BC) */ 625 __u16 dlen; 626} __attribute__ ((packed)) hci_acl_hdr; 627#define HCI_ACL_HDR_SIZE 4 628 629typedef struct { 630 __u16 handle; 631 __u8 dlen; 632} __attribute__ ((packed)) hci_sco_hdr; 633#define HCI_SCO_HDR_SIZE 3 634 635/* Command opcode pack/unpack */ 636#define cmd_opcode_pack(ogf, ocf) (__u16)((ocf & 0x03ff)|(ogf << 10)) 637#define cmd_opcode_ogf(op) (op >> 10) 638#define cmd_opcode_ocf(op) (op & 0x03ff) 639 640/* ACL handle and flags pack/unpack */ 641#define acl_handle_pack(h, f) (__u16)((h & 0x0fff)|(f << 12)) 642#define acl_handle(h) (h & 0x0fff) 643#define acl_flags(h) (h >> 12) 644 645/* HCI Socket options */ 646#define HCI_DATA_DIR 1 647#define HCI_FILTER 2 648#define HCI_TIME_STAMP 3 649 650/* HCI CMSG flags */ 651#define HCI_CMSG_DIR 0x0001 652#define HCI_CMSG_TSTAMP 0x0002 653 654struct sockaddr_hci { 655 sa_family_t hci_family; 656 unsigned short hci_dev; 657}; 658#define HCI_DEV_NONE 0xffff 659 660struct hci_filter { 661 __u32 type_mask; 662 __u32 event_mask[2]; 663 __u16 opcode; 664}; 665 666#define HCI_FLT_TYPE_BITS 31 667#define HCI_FLT_EVENT_BITS 63 668#define HCI_FLT_OGF_BITS 63 669#define HCI_FLT_OCF_BITS 127 670 671#if BITS_PER_LONG == 64 672static inline void hci_set_bit(int nr, void *addr) 673{ 674 *((__u32 *) addr + (nr >> 5)) |= ((__u32) 1 << (nr & 31)); 675} 676static inline int hci_test_bit(int nr, void *addr) 677{ 678 return *((__u32 *) addr + (nr >> 5)) & ((__u32) 1 << (nr & 31)); 679} 680#else 681#define hci_set_bit set_bit 682#define hci_test_bit test_bit 683#endif 684 685/* Ioctl requests structures */ 686struct hci_dev_stats { 687 __u32 err_rx; 688 __u32 err_tx; 689 __u32 cmd_tx; 690 __u32 evt_rx; 691 __u32 acl_tx; 692 __u32 acl_rx; 693 __u32 sco_tx; 694 __u32 sco_rx; 695 __u32 byte_rx; 696 __u32 byte_tx; 697}; 698 699struct hci_dev_info { 700 __u16 dev_id; 701 char name[8]; 702 703 bdaddr_t bdaddr; 704 705 __u32 flags; 706 __u8 type; 707 708 __u8 features[8]; 709 710 __u32 pkt_type; 711 __u32 link_policy; 712 __u32 link_mode; 713 714 __u16 acl_mtu; 715 __u16 acl_pkts; 716 __u16 sco_mtu; 717 __u16 sco_pkts; 718 719 struct hci_dev_stats stat; 720}; 721 722struct hci_conn_info { 723 __u16 handle; 724 bdaddr_t bdaddr; 725 __u8 type; 726 __u8 out; 727 __u16 state; 728 __u32 link_mode; 729}; 730 731struct hci_dev_req { 732 __u16 dev_id; 733 __u32 dev_opt; 734}; 735 736struct hci_dev_list_req { 737 __u16 dev_num; 738 struct hci_dev_req dev_req[0]; /* hci_dev_req structures */ 739}; 740 741struct hci_conn_list_req { 742 __u16 dev_id; 743 __u16 conn_num; 744 struct hci_conn_info conn_info[0]; 745}; 746 747struct hci_conn_info_req { 748 bdaddr_t bdaddr; 749 __u8 type; 750 struct hci_conn_info conn_info[0]; 751}; 752 753struct hci_inquiry_req { 754 __u16 dev_id; 755 __u16 flags; 756 __u8 lap[3]; 757 __u8 length; 758 __u8 num_rsp; 759}; 760#define IREQ_CACHE_FLUSH 0x0001 761 762struct hci_remotename_req { 763 __u16 dev_id; 764 __u16 flags; 765 bdaddr_t bdaddr; 766 __u8 name[248]; 767}; 768 769#endif /* __HCI_H */ 770