11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds BlueZ - Bluetooth protocol stack for Linux 31da177e4SLinus Torvalds Copyright (C) 2000-2001 Qualcomm Incorporated 41da177e4SLinus Torvalds 51da177e4SLinus Torvalds Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> 61da177e4SLinus Torvalds 71da177e4SLinus Torvalds This program is free software; you can redistribute it and/or modify 81da177e4SLinus Torvalds it under the terms of the GNU General Public License version 2 as 91da177e4SLinus Torvalds published by the Free Software Foundation; 101da177e4SLinus Torvalds 111da177e4SLinus Torvalds THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 121da177e4SLinus Torvalds OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 131da177e4SLinus Torvalds FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 141da177e4SLinus Torvalds IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 151da177e4SLinus Torvalds CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 161da177e4SLinus Torvalds WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 171da177e4SLinus Torvalds ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 181da177e4SLinus Torvalds OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 191da177e4SLinus Torvalds 201da177e4SLinus Torvalds ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 211da177e4SLinus Torvalds COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 221da177e4SLinus Torvalds SOFTWARE IS DISCLAIMED. 231da177e4SLinus Torvalds */ 241da177e4SLinus Torvalds 251da177e4SLinus Torvalds #ifndef __HCI_H 261da177e4SLinus Torvalds #define __HCI_H 271da177e4SLinus Torvalds 281da177e4SLinus Torvalds #define HCI_MAX_ACL_SIZE 1024 291da177e4SLinus Torvalds #define HCI_MAX_SCO_SIZE 255 301da177e4SLinus Torvalds #define HCI_MAX_EVENT_SIZE 260 311da177e4SLinus Torvalds #define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) 321da177e4SLinus Torvalds 331da177e4SLinus Torvalds /* HCI dev events */ 341da177e4SLinus Torvalds #define HCI_DEV_REG 1 351da177e4SLinus Torvalds #define HCI_DEV_UNREG 2 361da177e4SLinus Torvalds #define HCI_DEV_UP 3 371da177e4SLinus Torvalds #define HCI_DEV_DOWN 4 381da177e4SLinus Torvalds #define HCI_DEV_SUSPEND 5 391da177e4SLinus Torvalds #define HCI_DEV_RESUME 6 401da177e4SLinus Torvalds 411da177e4SLinus Torvalds /* HCI notify events */ 421da177e4SLinus Torvalds #define HCI_NOTIFY_CONN_ADD 1 431da177e4SLinus Torvalds #define HCI_NOTIFY_CONN_DEL 2 441da177e4SLinus Torvalds #define HCI_NOTIFY_VOICE_SETTING 3 451da177e4SLinus Torvalds 461da177e4SLinus Torvalds /* HCI device types */ 470ac53939SMarcel Holtmann #define HCI_VIRTUAL 0 481da177e4SLinus Torvalds #define HCI_USB 1 491da177e4SLinus Torvalds #define HCI_PCCARD 2 501da177e4SLinus Torvalds #define HCI_UART 3 511da177e4SLinus Torvalds #define HCI_RS232 4 521da177e4SLinus Torvalds #define HCI_PCI 5 530ac53939SMarcel Holtmann #define HCI_SDIO 6 541da177e4SLinus Torvalds 551da177e4SLinus Torvalds /* HCI device quirks */ 561da177e4SLinus Torvalds enum { 571da177e4SLinus Torvalds HCI_QUIRK_RESET_ON_INIT, 58da1f5198SMarcel Holtmann HCI_QUIRK_RAW_DEVICE, 59da1f5198SMarcel Holtmann HCI_QUIRK_FIXUP_BUFFER_SIZE 601da177e4SLinus Torvalds }; 611da177e4SLinus Torvalds 621da177e4SLinus Torvalds /* HCI device flags */ 631da177e4SLinus Torvalds enum { 641da177e4SLinus Torvalds HCI_UP, 651da177e4SLinus Torvalds HCI_INIT, 661da177e4SLinus Torvalds HCI_RUNNING, 671da177e4SLinus Torvalds 681da177e4SLinus Torvalds HCI_PSCAN, 691da177e4SLinus Torvalds HCI_ISCAN, 701da177e4SLinus Torvalds HCI_AUTH, 711da177e4SLinus Torvalds HCI_ENCRYPT, 721da177e4SLinus Torvalds HCI_INQUIRY, 731da177e4SLinus Torvalds 741da177e4SLinus Torvalds HCI_RAW, 751da177e4SLinus Torvalds 761da177e4SLinus Torvalds HCI_SECMGR 771da177e4SLinus Torvalds }; 781da177e4SLinus Torvalds 791da177e4SLinus Torvalds /* HCI ioctl defines */ 801da177e4SLinus Torvalds #define HCIDEVUP _IOW('H', 201, int) 811da177e4SLinus Torvalds #define HCIDEVDOWN _IOW('H', 202, int) 821da177e4SLinus Torvalds #define HCIDEVRESET _IOW('H', 203, int) 831da177e4SLinus Torvalds #define HCIDEVRESTAT _IOW('H', 204, int) 841da177e4SLinus Torvalds 851da177e4SLinus Torvalds #define HCIGETDEVLIST _IOR('H', 210, int) 861da177e4SLinus Torvalds #define HCIGETDEVINFO _IOR('H', 211, int) 871da177e4SLinus Torvalds #define HCIGETCONNLIST _IOR('H', 212, int) 881da177e4SLinus Torvalds #define HCIGETCONNINFO _IOR('H', 213, int) 891da177e4SLinus Torvalds 901da177e4SLinus Torvalds #define HCISETRAW _IOW('H', 220, int) 911da177e4SLinus Torvalds #define HCISETSCAN _IOW('H', 221, int) 921da177e4SLinus Torvalds #define HCISETAUTH _IOW('H', 222, int) 931da177e4SLinus Torvalds #define HCISETENCRYPT _IOW('H', 223, int) 941da177e4SLinus Torvalds #define HCISETPTYPE _IOW('H', 224, int) 951da177e4SLinus Torvalds #define HCISETLINKPOL _IOW('H', 225, int) 961da177e4SLinus Torvalds #define HCISETLINKMODE _IOW('H', 226, int) 971da177e4SLinus Torvalds #define HCISETACLMTU _IOW('H', 227, int) 981da177e4SLinus Torvalds #define HCISETSCOMTU _IOW('H', 228, int) 991da177e4SLinus Torvalds 1001da177e4SLinus Torvalds #define HCISETSECMGR _IOW('H', 230, int) 1011da177e4SLinus Torvalds 1021da177e4SLinus Torvalds #define HCIINQUIRY _IOR('H', 240, int) 1031da177e4SLinus Torvalds 1041da177e4SLinus Torvalds /* HCI timeouts */ 10504837f64SMarcel Holtmann #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */ 10604837f64SMarcel Holtmann #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ 10704837f64SMarcel Holtmann #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ 10804837f64SMarcel Holtmann #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ 1091da177e4SLinus Torvalds 1101da177e4SLinus Torvalds /* HCI Packet types */ 1111da177e4SLinus Torvalds #define HCI_COMMAND_PKT 0x01 1121da177e4SLinus Torvalds #define HCI_ACLDATA_PKT 0x02 1131da177e4SLinus Torvalds #define HCI_SCODATA_PKT 0x03 1141da177e4SLinus Torvalds #define HCI_EVENT_PKT 0x04 1151da177e4SLinus Torvalds #define HCI_VENDOR_PKT 0xff 1161da177e4SLinus Torvalds 1171da177e4SLinus Torvalds /* HCI Packet types */ 1181da177e4SLinus Torvalds #define HCI_DM1 0x0008 1191da177e4SLinus Torvalds #define HCI_DM3 0x0400 1201da177e4SLinus Torvalds #define HCI_DM5 0x4000 1211da177e4SLinus Torvalds #define HCI_DH1 0x0010 1221da177e4SLinus Torvalds #define HCI_DH3 0x0800 1231da177e4SLinus Torvalds #define HCI_DH5 0x8000 1241da177e4SLinus Torvalds 1251da177e4SLinus Torvalds #define HCI_HV1 0x0020 1261da177e4SLinus Torvalds #define HCI_HV2 0x0040 1271da177e4SLinus Torvalds #define HCI_HV3 0x0080 1281da177e4SLinus Torvalds 1291da177e4SLinus Torvalds #define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3) 1301da177e4SLinus Torvalds #define ACL_PTYPE_MASK (~SCO_PTYPE_MASK) 1311da177e4SLinus Torvalds 1321da177e4SLinus Torvalds /* ACL flags */ 1331da177e4SLinus Torvalds #define ACL_CONT 0x01 1341da177e4SLinus Torvalds #define ACL_START 0x02 1351da177e4SLinus Torvalds #define ACL_ACTIVE_BCAST 0x04 1361da177e4SLinus Torvalds #define ACL_PICO_BCAST 0x08 1371da177e4SLinus Torvalds 1381da177e4SLinus Torvalds /* Baseband links */ 1391da177e4SLinus Torvalds #define SCO_LINK 0x00 1401da177e4SLinus Torvalds #define ACL_LINK 0x01 1411da177e4SLinus Torvalds 1421da177e4SLinus Torvalds /* LMP features */ 1431da177e4SLinus Torvalds #define LMP_3SLOT 0x01 1441da177e4SLinus Torvalds #define LMP_5SLOT 0x02 1451da177e4SLinus Torvalds #define LMP_ENCRYPT 0x04 1461da177e4SLinus Torvalds #define LMP_SOFFSET 0x08 1471da177e4SLinus Torvalds #define LMP_TACCURACY 0x10 1481da177e4SLinus Torvalds #define LMP_RSWITCH 0x20 1491da177e4SLinus Torvalds #define LMP_HOLD 0x40 15004837f64SMarcel Holtmann #define LMP_SNIFF 0x80 1511da177e4SLinus Torvalds 1521da177e4SLinus Torvalds #define LMP_PARK 0x01 1531da177e4SLinus Torvalds #define LMP_RSSI 0x02 1541da177e4SLinus Torvalds #define LMP_QUALITY 0x04 1551da177e4SLinus Torvalds #define LMP_SCO 0x08 1561da177e4SLinus Torvalds #define LMP_HV2 0x10 1571da177e4SLinus Torvalds #define LMP_HV3 0x20 1581da177e4SLinus Torvalds #define LMP_ULAW 0x40 1591da177e4SLinus Torvalds #define LMP_ALAW 0x80 1601da177e4SLinus Torvalds 1611da177e4SLinus Torvalds #define LMP_CVSD 0x01 1621da177e4SLinus Torvalds #define LMP_PSCHEME 0x02 1631da177e4SLinus Torvalds #define LMP_PCONTROL 0x04 1641da177e4SLinus Torvalds 16504837f64SMarcel Holtmann #define LMP_SNIFF_SUBR 0x02 16604837f64SMarcel Holtmann 16704837f64SMarcel Holtmann /* Connection modes */ 16804837f64SMarcel Holtmann #define HCI_CM_ACTIVE 0x0000 16904837f64SMarcel Holtmann #define HCI_CM_HOLD 0x0001 17004837f64SMarcel Holtmann #define HCI_CM_SNIFF 0x0002 17104837f64SMarcel Holtmann #define HCI_CM_PARK 0x0003 17204837f64SMarcel Holtmann 1731da177e4SLinus Torvalds /* Link policies */ 1741da177e4SLinus Torvalds #define HCI_LP_RSWITCH 0x0001 1751da177e4SLinus Torvalds #define HCI_LP_HOLD 0x0002 1761da177e4SLinus Torvalds #define HCI_LP_SNIFF 0x0004 1771da177e4SLinus Torvalds #define HCI_LP_PARK 0x0008 1781da177e4SLinus Torvalds 17904837f64SMarcel Holtmann /* Link modes */ 1801da177e4SLinus Torvalds #define HCI_LM_ACCEPT 0x8000 1811da177e4SLinus Torvalds #define HCI_LM_MASTER 0x0001 1821da177e4SLinus Torvalds #define HCI_LM_AUTH 0x0002 1831da177e4SLinus Torvalds #define HCI_LM_ENCRYPT 0x0004 1841da177e4SLinus Torvalds #define HCI_LM_TRUSTED 0x0008 1851da177e4SLinus Torvalds #define HCI_LM_RELIABLE 0x0010 1861da177e4SLinus Torvalds #define HCI_LM_SECURE 0x0020 1871da177e4SLinus Torvalds 1881da177e4SLinus Torvalds /* ----- HCI Commands ---- */ 1891da177e4SLinus Torvalds /* OGF & OCF values */ 1901da177e4SLinus Torvalds 1911da177e4SLinus Torvalds /* Informational Parameters */ 1921da177e4SLinus Torvalds #define OGF_INFO_PARAM 0x04 1931da177e4SLinus Torvalds 1941da177e4SLinus Torvalds #define OCF_READ_LOCAL_VERSION 0x0001 1951da177e4SLinus Torvalds struct hci_rp_read_loc_version { 1961da177e4SLinus Torvalds __u8 status; 1971da177e4SLinus Torvalds __u8 hci_ver; 1981ebb9252SMarcel Holtmann __le16 hci_rev; 1991da177e4SLinus Torvalds __u8 lmp_ver; 2001ebb9252SMarcel Holtmann __le16 manufacturer; 2011ebb9252SMarcel Holtmann __le16 lmp_subver; 2021da177e4SLinus Torvalds } __attribute__ ((packed)); 2031da177e4SLinus Torvalds 2041da177e4SLinus Torvalds #define OCF_READ_LOCAL_FEATURES 0x0003 20504837f64SMarcel Holtmann struct hci_rp_read_local_features { 2061da177e4SLinus Torvalds __u8 status; 2071da177e4SLinus Torvalds __u8 features[8]; 2081da177e4SLinus Torvalds } __attribute__ ((packed)); 2091da177e4SLinus Torvalds 2101da177e4SLinus Torvalds #define OCF_READ_BUFFER_SIZE 0x0005 2111da177e4SLinus Torvalds struct hci_rp_read_buffer_size { 2121da177e4SLinus Torvalds __u8 status; 2131ebb9252SMarcel Holtmann __le16 acl_mtu; 2141da177e4SLinus Torvalds __u8 sco_mtu; 2151ebb9252SMarcel Holtmann __le16 acl_max_pkt; 2161ebb9252SMarcel Holtmann __le16 sco_max_pkt; 2171da177e4SLinus Torvalds } __attribute__ ((packed)); 2181da177e4SLinus Torvalds 2191da177e4SLinus Torvalds #define OCF_READ_BD_ADDR 0x0009 2201da177e4SLinus Torvalds struct hci_rp_read_bd_addr { 2211da177e4SLinus Torvalds __u8 status; 2221da177e4SLinus Torvalds bdaddr_t bdaddr; 2231da177e4SLinus Torvalds } __attribute__ ((packed)); 2241da177e4SLinus Torvalds 2251da177e4SLinus Torvalds /* Host Controller and Baseband */ 2261da177e4SLinus Torvalds #define OGF_HOST_CTL 0x03 2271da177e4SLinus Torvalds #define OCF_RESET 0x0003 2281da177e4SLinus Torvalds #define OCF_READ_AUTH_ENABLE 0x001F 2291da177e4SLinus Torvalds #define OCF_WRITE_AUTH_ENABLE 0x0020 2301da177e4SLinus Torvalds #define AUTH_DISABLED 0x00 2311da177e4SLinus Torvalds #define AUTH_ENABLED 0x01 2321da177e4SLinus Torvalds 2331da177e4SLinus Torvalds #define OCF_READ_ENCRYPT_MODE 0x0021 2341da177e4SLinus Torvalds #define OCF_WRITE_ENCRYPT_MODE 0x0022 2351da177e4SLinus Torvalds #define ENCRYPT_DISABLED 0x00 2361da177e4SLinus Torvalds #define ENCRYPT_P2P 0x01 2371da177e4SLinus Torvalds #define ENCRYPT_BOTH 0x02 2381da177e4SLinus Torvalds 2391da177e4SLinus Torvalds #define OCF_WRITE_CA_TIMEOUT 0x0016 2401da177e4SLinus Torvalds #define OCF_WRITE_PG_TIMEOUT 0x0018 2411da177e4SLinus Torvalds 2421da177e4SLinus Torvalds #define OCF_WRITE_SCAN_ENABLE 0x001A 2431da177e4SLinus Torvalds #define SCAN_DISABLED 0x00 2441da177e4SLinus Torvalds #define SCAN_INQUIRY 0x01 2451da177e4SLinus Torvalds #define SCAN_PAGE 0x02 2461da177e4SLinus Torvalds 2471da177e4SLinus Torvalds #define OCF_SET_EVENT_FLT 0x0005 2481da177e4SLinus Torvalds struct hci_cp_set_event_flt { 2491da177e4SLinus Torvalds __u8 flt_type; 2501da177e4SLinus Torvalds __u8 cond_type; 2511da177e4SLinus Torvalds __u8 condition[0]; 2521da177e4SLinus Torvalds } __attribute__ ((packed)); 2531da177e4SLinus Torvalds 2541da177e4SLinus Torvalds /* Filter types */ 2551da177e4SLinus Torvalds #define HCI_FLT_CLEAR_ALL 0x00 2561da177e4SLinus Torvalds #define HCI_FLT_INQ_RESULT 0x01 2571da177e4SLinus Torvalds #define HCI_FLT_CONN_SETUP 0x02 2581da177e4SLinus Torvalds 2591da177e4SLinus Torvalds /* CONN_SETUP Condition types */ 2601da177e4SLinus Torvalds #define HCI_CONN_SETUP_ALLOW_ALL 0x00 2611da177e4SLinus Torvalds #define HCI_CONN_SETUP_ALLOW_CLASS 0x01 2621da177e4SLinus Torvalds #define HCI_CONN_SETUP_ALLOW_BDADDR 0x02 2631da177e4SLinus Torvalds 2641da177e4SLinus Torvalds /* CONN_SETUP Conditions */ 2651da177e4SLinus Torvalds #define HCI_CONN_SETUP_AUTO_OFF 0x01 2661da177e4SLinus Torvalds #define HCI_CONN_SETUP_AUTO_ON 0x02 2671da177e4SLinus Torvalds 2681da177e4SLinus Torvalds #define OCF_READ_CLASS_OF_DEV 0x0023 2691da177e4SLinus Torvalds struct hci_rp_read_dev_class { 2701da177e4SLinus Torvalds __u8 status; 2711da177e4SLinus Torvalds __u8 dev_class[3]; 2721da177e4SLinus Torvalds } __attribute__ ((packed)); 2731da177e4SLinus Torvalds 2741da177e4SLinus Torvalds #define OCF_WRITE_CLASS_OF_DEV 0x0024 2751da177e4SLinus Torvalds struct hci_cp_write_dev_class { 2761da177e4SLinus Torvalds __u8 dev_class[3]; 2771da177e4SLinus Torvalds } __attribute__ ((packed)); 2781da177e4SLinus Torvalds 2791da177e4SLinus Torvalds #define OCF_READ_VOICE_SETTING 0x0025 2801da177e4SLinus Torvalds struct hci_rp_read_voice_setting { 2811da177e4SLinus Torvalds __u8 status; 2821ebb9252SMarcel Holtmann __le16 voice_setting; 2831da177e4SLinus Torvalds } __attribute__ ((packed)); 2841da177e4SLinus Torvalds 2851da177e4SLinus Torvalds #define OCF_WRITE_VOICE_SETTING 0x0026 2861da177e4SLinus Torvalds struct hci_cp_write_voice_setting { 2871ebb9252SMarcel Holtmann __le16 voice_setting; 2881da177e4SLinus Torvalds } __attribute__ ((packed)); 2891da177e4SLinus Torvalds 2901da177e4SLinus Torvalds #define OCF_HOST_BUFFER_SIZE 0x0033 2911da177e4SLinus Torvalds struct hci_cp_host_buffer_size { 2921ebb9252SMarcel Holtmann __le16 acl_mtu; 2931da177e4SLinus Torvalds __u8 sco_mtu; 2941ebb9252SMarcel Holtmann __le16 acl_max_pkt; 2951ebb9252SMarcel Holtmann __le16 sco_max_pkt; 2961da177e4SLinus Torvalds } __attribute__ ((packed)); 2971da177e4SLinus Torvalds 2981da177e4SLinus Torvalds /* Link Control */ 2991da177e4SLinus Torvalds #define OGF_LINK_CTL 0x01 3006ac59344SMarcel Holtmann 3011da177e4SLinus Torvalds #define OCF_CREATE_CONN 0x0005 3021da177e4SLinus Torvalds struct hci_cp_create_conn { 3031da177e4SLinus Torvalds bdaddr_t bdaddr; 3041ebb9252SMarcel Holtmann __le16 pkt_type; 3051da177e4SLinus Torvalds __u8 pscan_rep_mode; 3061da177e4SLinus Torvalds __u8 pscan_mode; 3071ebb9252SMarcel Holtmann __le16 clock_offset; 3081da177e4SLinus Torvalds __u8 role_switch; 3091da177e4SLinus Torvalds } __attribute__ ((packed)); 3101da177e4SLinus Torvalds 3116ac59344SMarcel Holtmann #define OCF_CREATE_CONN_CANCEL 0x0008 3126ac59344SMarcel Holtmann struct hci_cp_create_conn_cancel { 3136ac59344SMarcel Holtmann bdaddr_t bdaddr; 3146ac59344SMarcel Holtmann } __attribute__ ((packed)); 3156ac59344SMarcel Holtmann 3161da177e4SLinus Torvalds #define OCF_ACCEPT_CONN_REQ 0x0009 3171da177e4SLinus Torvalds struct hci_cp_accept_conn_req { 3181da177e4SLinus Torvalds bdaddr_t bdaddr; 3191da177e4SLinus Torvalds __u8 role; 3201da177e4SLinus Torvalds } __attribute__ ((packed)); 3211da177e4SLinus Torvalds 3221da177e4SLinus Torvalds #define OCF_REJECT_CONN_REQ 0x000a 3231da177e4SLinus Torvalds struct hci_cp_reject_conn_req { 3241da177e4SLinus Torvalds bdaddr_t bdaddr; 3251da177e4SLinus Torvalds __u8 reason; 3261da177e4SLinus Torvalds } __attribute__ ((packed)); 3271da177e4SLinus Torvalds 3281da177e4SLinus Torvalds #define OCF_DISCONNECT 0x0006 3291da177e4SLinus Torvalds struct hci_cp_disconnect { 3301ebb9252SMarcel Holtmann __le16 handle; 3311da177e4SLinus Torvalds __u8 reason; 3321da177e4SLinus Torvalds } __attribute__ ((packed)); 3331da177e4SLinus Torvalds 3341da177e4SLinus Torvalds #define OCF_ADD_SCO 0x0007 3351da177e4SLinus Torvalds struct hci_cp_add_sco { 3361ebb9252SMarcel Holtmann __le16 handle; 3371ebb9252SMarcel Holtmann __le16 pkt_type; 3381da177e4SLinus Torvalds } __attribute__ ((packed)); 3391da177e4SLinus Torvalds 3401da177e4SLinus Torvalds #define OCF_INQUIRY 0x0001 3411da177e4SLinus Torvalds struct hci_cp_inquiry { 3421da177e4SLinus Torvalds __u8 lap[3]; 3431da177e4SLinus Torvalds __u8 length; 3441da177e4SLinus Torvalds __u8 num_rsp; 3451da177e4SLinus Torvalds } __attribute__ ((packed)); 3461da177e4SLinus Torvalds 3471da177e4SLinus Torvalds #define OCF_INQUIRY_CANCEL 0x0002 3481da177e4SLinus Torvalds 349defc761bSMarcel Holtmann #define OCF_EXIT_PERIODIC_INQ 0x0004 350defc761bSMarcel Holtmann 3511da177e4SLinus Torvalds #define OCF_LINK_KEY_REPLY 0x000B 3521da177e4SLinus Torvalds struct hci_cp_link_key_reply { 3531da177e4SLinus Torvalds bdaddr_t bdaddr; 3541da177e4SLinus Torvalds __u8 link_key[16]; 3551da177e4SLinus Torvalds } __attribute__ ((packed)); 3561da177e4SLinus Torvalds 3571da177e4SLinus Torvalds #define OCF_LINK_KEY_NEG_REPLY 0x000C 3581da177e4SLinus Torvalds struct hci_cp_link_key_neg_reply { 3591da177e4SLinus Torvalds bdaddr_t bdaddr; 3601da177e4SLinus Torvalds } __attribute__ ((packed)); 3611da177e4SLinus Torvalds 3621da177e4SLinus Torvalds #define OCF_PIN_CODE_REPLY 0x000D 3631da177e4SLinus Torvalds struct hci_cp_pin_code_reply { 3641da177e4SLinus Torvalds bdaddr_t bdaddr; 3651da177e4SLinus Torvalds __u8 pin_len; 3661da177e4SLinus Torvalds __u8 pin_code[16]; 3671da177e4SLinus Torvalds } __attribute__ ((packed)); 3681da177e4SLinus Torvalds 3691da177e4SLinus Torvalds #define OCF_PIN_CODE_NEG_REPLY 0x000E 3701da177e4SLinus Torvalds struct hci_cp_pin_code_neg_reply { 3711da177e4SLinus Torvalds bdaddr_t bdaddr; 3721da177e4SLinus Torvalds } __attribute__ ((packed)); 3731da177e4SLinus Torvalds 3741da177e4SLinus Torvalds #define OCF_CHANGE_CONN_PTYPE 0x000F 3751da177e4SLinus Torvalds struct hci_cp_change_conn_ptype { 3761ebb9252SMarcel Holtmann __le16 handle; 3771ebb9252SMarcel Holtmann __le16 pkt_type; 3781da177e4SLinus Torvalds } __attribute__ ((packed)); 3791da177e4SLinus Torvalds 3801da177e4SLinus Torvalds #define OCF_AUTH_REQUESTED 0x0011 3811da177e4SLinus Torvalds struct hci_cp_auth_requested { 3821ebb9252SMarcel Holtmann __le16 handle; 3831da177e4SLinus Torvalds } __attribute__ ((packed)); 3841da177e4SLinus Torvalds 3851da177e4SLinus Torvalds #define OCF_SET_CONN_ENCRYPT 0x0013 3861da177e4SLinus Torvalds struct hci_cp_set_conn_encrypt { 3871ebb9252SMarcel Holtmann __le16 handle; 3881da177e4SLinus Torvalds __u8 encrypt; 3891da177e4SLinus Torvalds } __attribute__ ((packed)); 3901da177e4SLinus Torvalds 3911da177e4SLinus Torvalds #define OCF_CHANGE_CONN_LINK_KEY 0x0015 3921da177e4SLinus Torvalds struct hci_cp_change_conn_link_key { 3931ebb9252SMarcel Holtmann __le16 handle; 3941da177e4SLinus Torvalds } __attribute__ ((packed)); 3951da177e4SLinus Torvalds 3961da177e4SLinus Torvalds #define OCF_READ_REMOTE_FEATURES 0x001B 39704837f64SMarcel Holtmann struct hci_cp_read_remote_features { 3981ebb9252SMarcel Holtmann __le16 handle; 3991da177e4SLinus Torvalds } __attribute__ ((packed)); 4001da177e4SLinus Torvalds 4011da177e4SLinus Torvalds #define OCF_READ_REMOTE_VERSION 0x001D 40204837f64SMarcel Holtmann struct hci_cp_read_remote_version { 4031ebb9252SMarcel Holtmann __le16 handle; 4041da177e4SLinus Torvalds } __attribute__ ((packed)); 4051da177e4SLinus Torvalds 4061da177e4SLinus Torvalds /* Link Policy */ 4071da177e4SLinus Torvalds #define OGF_LINK_POLICY 0x02 40804837f64SMarcel Holtmann 40904837f64SMarcel Holtmann #define OCF_SNIFF_MODE 0x0003 41004837f64SMarcel Holtmann struct hci_cp_sniff_mode { 41104837f64SMarcel Holtmann __le16 handle; 41204837f64SMarcel Holtmann __le16 max_interval; 41304837f64SMarcel Holtmann __le16 min_interval; 41404837f64SMarcel Holtmann __le16 attempt; 41504837f64SMarcel Holtmann __le16 timeout; 41604837f64SMarcel Holtmann } __attribute__ ((packed)); 41704837f64SMarcel Holtmann 41804837f64SMarcel Holtmann #define OCF_EXIT_SNIFF_MODE 0x0004 41904837f64SMarcel Holtmann struct hci_cp_exit_sniff_mode { 42004837f64SMarcel Holtmann __le16 handle; 42104837f64SMarcel Holtmann } __attribute__ ((packed)); 42204837f64SMarcel Holtmann 4231da177e4SLinus Torvalds #define OCF_ROLE_DISCOVERY 0x0009 4241da177e4SLinus Torvalds struct hci_cp_role_discovery { 4251ebb9252SMarcel Holtmann __le16 handle; 4261da177e4SLinus Torvalds } __attribute__ ((packed)); 4271da177e4SLinus Torvalds struct hci_rp_role_discovery { 4281da177e4SLinus Torvalds __u8 status; 4291ebb9252SMarcel Holtmann __le16 handle; 4301da177e4SLinus Torvalds __u8 role; 4311da177e4SLinus Torvalds } __attribute__ ((packed)); 4321da177e4SLinus Torvalds 4331da177e4SLinus Torvalds #define OCF_READ_LINK_POLICY 0x000C 4341da177e4SLinus Torvalds struct hci_cp_read_link_policy { 4351ebb9252SMarcel Holtmann __le16 handle; 4361da177e4SLinus Torvalds } __attribute__ ((packed)); 4371da177e4SLinus Torvalds struct hci_rp_read_link_policy { 4381da177e4SLinus Torvalds __u8 status; 4391ebb9252SMarcel Holtmann __le16 handle; 4401ebb9252SMarcel Holtmann __le16 policy; 4411da177e4SLinus Torvalds } __attribute__ ((packed)); 4421da177e4SLinus Torvalds 4431da177e4SLinus Torvalds #define OCF_SWITCH_ROLE 0x000B 4441da177e4SLinus Torvalds struct hci_cp_switch_role { 4451da177e4SLinus Torvalds bdaddr_t bdaddr; 4461da177e4SLinus Torvalds __u8 role; 4471da177e4SLinus Torvalds } __attribute__ ((packed)); 4481da177e4SLinus Torvalds 4491da177e4SLinus Torvalds #define OCF_WRITE_LINK_POLICY 0x000D 4501da177e4SLinus Torvalds struct hci_cp_write_link_policy { 4511ebb9252SMarcel Holtmann __le16 handle; 4521ebb9252SMarcel Holtmann __le16 policy; 4531da177e4SLinus Torvalds } __attribute__ ((packed)); 4541da177e4SLinus Torvalds struct hci_rp_write_link_policy { 4551da177e4SLinus Torvalds __u8 status; 4561ebb9252SMarcel Holtmann __le16 handle; 4571da177e4SLinus Torvalds } __attribute__ ((packed)); 4581da177e4SLinus Torvalds 45904837f64SMarcel Holtmann #define OCF_SNIFF_SUBRATE 0x0011 46004837f64SMarcel Holtmann struct hci_cp_sniff_subrate { 46104837f64SMarcel Holtmann __le16 handle; 46204837f64SMarcel Holtmann __le16 max_latency; 46304837f64SMarcel Holtmann __le16 min_remote_timeout; 46404837f64SMarcel Holtmann __le16 min_local_timeout; 46504837f64SMarcel Holtmann } __attribute__ ((packed)); 46604837f64SMarcel Holtmann 4671da177e4SLinus Torvalds /* Status params */ 4681da177e4SLinus Torvalds #define OGF_STATUS_PARAM 0x05 4691da177e4SLinus Torvalds 4701da177e4SLinus Torvalds /* Testing commands */ 4711da177e4SLinus Torvalds #define OGF_TESTING_CMD 0x3E 4721da177e4SLinus Torvalds 4731da177e4SLinus Torvalds /* Vendor specific commands */ 4741da177e4SLinus Torvalds #define OGF_VENDOR_CMD 0x3F 4751da177e4SLinus Torvalds 4761da177e4SLinus Torvalds /* ---- HCI Events ---- */ 4771da177e4SLinus Torvalds #define HCI_EV_INQUIRY_COMPLETE 0x01 4781da177e4SLinus Torvalds 4791da177e4SLinus Torvalds #define HCI_EV_INQUIRY_RESULT 0x02 4801da177e4SLinus Torvalds struct inquiry_info { 4811da177e4SLinus Torvalds bdaddr_t bdaddr; 4821da177e4SLinus Torvalds __u8 pscan_rep_mode; 4831da177e4SLinus Torvalds __u8 pscan_period_mode; 4841da177e4SLinus Torvalds __u8 pscan_mode; 4851da177e4SLinus Torvalds __u8 dev_class[3]; 4861ebb9252SMarcel Holtmann __le16 clock_offset; 4871da177e4SLinus Torvalds } __attribute__ ((packed)); 4881da177e4SLinus Torvalds 4891da177e4SLinus Torvalds #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22 4901da177e4SLinus Torvalds struct inquiry_info_with_rssi { 4911da177e4SLinus Torvalds bdaddr_t bdaddr; 4921da177e4SLinus Torvalds __u8 pscan_rep_mode; 4931da177e4SLinus Torvalds __u8 pscan_period_mode; 4941da177e4SLinus Torvalds __u8 dev_class[3]; 4951ebb9252SMarcel Holtmann __le16 clock_offset; 4961da177e4SLinus Torvalds __s8 rssi; 4971da177e4SLinus Torvalds } __attribute__ ((packed)); 49845bb4bf0SMarcel Holtmann struct inquiry_info_with_rssi_and_pscan_mode { 49945bb4bf0SMarcel Holtmann bdaddr_t bdaddr; 50045bb4bf0SMarcel Holtmann __u8 pscan_rep_mode; 50145bb4bf0SMarcel Holtmann __u8 pscan_period_mode; 50245bb4bf0SMarcel Holtmann __u8 pscan_mode; 50345bb4bf0SMarcel Holtmann __u8 dev_class[3]; 5041ebb9252SMarcel Holtmann __le16 clock_offset; 50545bb4bf0SMarcel Holtmann __s8 rssi; 50645bb4bf0SMarcel Holtmann } __attribute__ ((packed)); 5071da177e4SLinus Torvalds 50821d9e30eSMarcel Holtmann #define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2F 50921d9e30eSMarcel Holtmann struct extended_inquiry_info { 51021d9e30eSMarcel Holtmann bdaddr_t bdaddr; 51121d9e30eSMarcel Holtmann __u8 pscan_rep_mode; 51221d9e30eSMarcel Holtmann __u8 pscan_period_mode; 51321d9e30eSMarcel Holtmann __u8 dev_class[3]; 5141ebb9252SMarcel Holtmann __le16 clock_offset; 51521d9e30eSMarcel Holtmann __s8 rssi; 51621d9e30eSMarcel Holtmann __u8 data[240]; 51721d9e30eSMarcel Holtmann } __attribute__ ((packed)); 51821d9e30eSMarcel Holtmann 5191da177e4SLinus Torvalds #define HCI_EV_CONN_COMPLETE 0x03 5201da177e4SLinus Torvalds struct hci_ev_conn_complete { 5211da177e4SLinus Torvalds __u8 status; 5221ebb9252SMarcel Holtmann __le16 handle; 5231da177e4SLinus Torvalds bdaddr_t bdaddr; 5241da177e4SLinus Torvalds __u8 link_type; 5251da177e4SLinus Torvalds __u8 encr_mode; 5261da177e4SLinus Torvalds } __attribute__ ((packed)); 5271da177e4SLinus Torvalds 5281da177e4SLinus Torvalds #define HCI_EV_CONN_REQUEST 0x04 5291da177e4SLinus Torvalds struct hci_ev_conn_request { 5301da177e4SLinus Torvalds bdaddr_t bdaddr; 5311da177e4SLinus Torvalds __u8 dev_class[3]; 5321da177e4SLinus Torvalds __u8 link_type; 5331da177e4SLinus Torvalds } __attribute__ ((packed)); 5341da177e4SLinus Torvalds 5351da177e4SLinus Torvalds #define HCI_EV_DISCONN_COMPLETE 0x05 5361da177e4SLinus Torvalds struct hci_ev_disconn_complete { 5371da177e4SLinus Torvalds __u8 status; 5381ebb9252SMarcel Holtmann __le16 handle; 5391da177e4SLinus Torvalds __u8 reason; 5401da177e4SLinus Torvalds } __attribute__ ((packed)); 5411da177e4SLinus Torvalds 5421da177e4SLinus Torvalds #define HCI_EV_AUTH_COMPLETE 0x06 5431da177e4SLinus Torvalds struct hci_ev_auth_complete { 5441da177e4SLinus Torvalds __u8 status; 5451ebb9252SMarcel Holtmann __le16 handle; 5461da177e4SLinus Torvalds } __attribute__ ((packed)); 5471da177e4SLinus Torvalds 5481da177e4SLinus Torvalds #define HCI_EV_ENCRYPT_CHANGE 0x08 5491da177e4SLinus Torvalds struct hci_ev_encrypt_change { 5501da177e4SLinus Torvalds __u8 status; 5511ebb9252SMarcel Holtmann __le16 handle; 5521da177e4SLinus Torvalds __u8 encrypt; 5531da177e4SLinus Torvalds } __attribute__ ((packed)); 5541da177e4SLinus Torvalds 5551da177e4SLinus Torvalds #define HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE 0x09 5561da177e4SLinus Torvalds struct hci_ev_change_conn_link_key_complete { 5571da177e4SLinus Torvalds __u8 status; 5581ebb9252SMarcel Holtmann __le16 handle; 5591da177e4SLinus Torvalds } __attribute__ ((packed)); 5601da177e4SLinus Torvalds 5611da177e4SLinus Torvalds #define HCI_EV_QOS_SETUP_COMPLETE 0x0D 5621da177e4SLinus Torvalds struct hci_qos { 5631da177e4SLinus Torvalds __u8 service_type; 5641da177e4SLinus Torvalds __u32 token_rate; 5651da177e4SLinus Torvalds __u32 peak_bandwidth; 5661da177e4SLinus Torvalds __u32 latency; 5671da177e4SLinus Torvalds __u32 delay_variation; 5681da177e4SLinus Torvalds } __attribute__ ((packed)); 5691da177e4SLinus Torvalds struct hci_ev_qos_setup_complete { 5701da177e4SLinus Torvalds __u8 status; 5711ebb9252SMarcel Holtmann __le16 handle; 5721da177e4SLinus Torvalds struct hci_qos qos; 5731da177e4SLinus Torvalds } __attribute__ ((packed)); 5741da177e4SLinus Torvalds 5751da177e4SLinus Torvalds #define HCI_EV_CMD_COMPLETE 0x0E 5761da177e4SLinus Torvalds struct hci_ev_cmd_complete { 5771da177e4SLinus Torvalds __u8 ncmd; 5781ebb9252SMarcel Holtmann __le16 opcode; 5791da177e4SLinus Torvalds } __attribute__ ((packed)); 5801da177e4SLinus Torvalds 5811da177e4SLinus Torvalds #define HCI_EV_CMD_STATUS 0x0F 5821da177e4SLinus Torvalds struct hci_ev_cmd_status { 5831da177e4SLinus Torvalds __u8 status; 5841da177e4SLinus Torvalds __u8 ncmd; 5851ebb9252SMarcel Holtmann __le16 opcode; 5861da177e4SLinus Torvalds } __attribute__ ((packed)); 5871da177e4SLinus Torvalds 5881da177e4SLinus Torvalds #define HCI_EV_NUM_COMP_PKTS 0x13 5891da177e4SLinus Torvalds struct hci_ev_num_comp_pkts { 5901da177e4SLinus Torvalds __u8 num_hndl; 5911da177e4SLinus Torvalds /* variable length part */ 5921da177e4SLinus Torvalds } __attribute__ ((packed)); 5931da177e4SLinus Torvalds 5941da177e4SLinus Torvalds #define HCI_EV_ROLE_CHANGE 0x12 5951da177e4SLinus Torvalds struct hci_ev_role_change { 5961da177e4SLinus Torvalds __u8 status; 5971da177e4SLinus Torvalds bdaddr_t bdaddr; 5981da177e4SLinus Torvalds __u8 role; 5991da177e4SLinus Torvalds } __attribute__ ((packed)); 6001da177e4SLinus Torvalds 6011da177e4SLinus Torvalds #define HCI_EV_MODE_CHANGE 0x14 6021da177e4SLinus Torvalds struct hci_ev_mode_change { 6031da177e4SLinus Torvalds __u8 status; 6041ebb9252SMarcel Holtmann __le16 handle; 6051da177e4SLinus Torvalds __u8 mode; 6061ebb9252SMarcel Holtmann __le16 interval; 6071da177e4SLinus Torvalds } __attribute__ ((packed)); 6081da177e4SLinus Torvalds 6091da177e4SLinus Torvalds #define HCI_EV_PIN_CODE_REQ 0x16 6101da177e4SLinus Torvalds struct hci_ev_pin_code_req { 6111da177e4SLinus Torvalds bdaddr_t bdaddr; 6121da177e4SLinus Torvalds } __attribute__ ((packed)); 6131da177e4SLinus Torvalds 6141da177e4SLinus Torvalds #define HCI_EV_LINK_KEY_REQ 0x17 6151da177e4SLinus Torvalds struct hci_ev_link_key_req { 6161da177e4SLinus Torvalds bdaddr_t bdaddr; 6171da177e4SLinus Torvalds } __attribute__ ((packed)); 6181da177e4SLinus Torvalds 6191da177e4SLinus Torvalds #define HCI_EV_LINK_KEY_NOTIFY 0x18 6201da177e4SLinus Torvalds struct hci_ev_link_key_notify { 6211da177e4SLinus Torvalds bdaddr_t bdaddr; 6221da177e4SLinus Torvalds __u8 link_key[16]; 6231da177e4SLinus Torvalds __u8 key_type; 6241da177e4SLinus Torvalds } __attribute__ ((packed)); 6251da177e4SLinus Torvalds 62604837f64SMarcel Holtmann #define HCI_EV_REMOTE_FEATURES 0x0B 62704837f64SMarcel Holtmann struct hci_ev_remote_features { 6281da177e4SLinus Torvalds __u8 status; 6291ebb9252SMarcel Holtmann __le16 handle; 6301da177e4SLinus Torvalds __u8 features[8]; 6311da177e4SLinus Torvalds } __attribute__ ((packed)); 6321da177e4SLinus Torvalds 63304837f64SMarcel Holtmann #define HCI_EV_REMOTE_VERSION 0x0C 63404837f64SMarcel Holtmann struct hci_ev_remote_version { 6351da177e4SLinus Torvalds __u8 status; 6361ebb9252SMarcel Holtmann __le16 handle; 6371da177e4SLinus Torvalds __u8 lmp_ver; 6381ebb9252SMarcel Holtmann __le16 manufacturer; 6391ebb9252SMarcel Holtmann __le16 lmp_subver; 6401da177e4SLinus Torvalds } __attribute__ ((packed)); 6411da177e4SLinus Torvalds 6421da177e4SLinus Torvalds #define HCI_EV_CLOCK_OFFSET 0x01C 6431da177e4SLinus Torvalds struct hci_ev_clock_offset { 6441da177e4SLinus Torvalds __u8 status; 6451ebb9252SMarcel Holtmann __le16 handle; 6461ebb9252SMarcel Holtmann __le16 clock_offset; 6471da177e4SLinus Torvalds } __attribute__ ((packed)); 6481da177e4SLinus Torvalds 64985a1e930SMarcel Holtmann #define HCI_EV_PSCAN_REP_MODE 0x20 65085a1e930SMarcel Holtmann struct hci_ev_pscan_rep_mode { 65185a1e930SMarcel Holtmann bdaddr_t bdaddr; 65285a1e930SMarcel Holtmann __u8 pscan_rep_mode; 65385a1e930SMarcel Holtmann } __attribute__ ((packed)); 65485a1e930SMarcel Holtmann 65504837f64SMarcel Holtmann #define HCI_EV_SNIFF_SUBRATE 0x2E 65604837f64SMarcel Holtmann struct hci_ev_sniff_subrate { 65704837f64SMarcel Holtmann __u8 status; 65804837f64SMarcel Holtmann __le16 handle; 65904837f64SMarcel Holtmann __le16 max_tx_latency; 66004837f64SMarcel Holtmann __le16 max_rx_latency; 66104837f64SMarcel Holtmann __le16 max_remote_timeout; 66204837f64SMarcel Holtmann __le16 max_local_timeout; 66304837f64SMarcel Holtmann } __attribute__ ((packed)); 66404837f64SMarcel Holtmann 6651da177e4SLinus Torvalds /* Internal events generated by Bluetooth stack */ 6661da177e4SLinus Torvalds #define HCI_EV_STACK_INTERNAL 0xFD 6671da177e4SLinus Torvalds struct hci_ev_stack_internal { 6681da177e4SLinus Torvalds __u16 type; 6691da177e4SLinus Torvalds __u8 data[0]; 6701da177e4SLinus Torvalds } __attribute__ ((packed)); 6711da177e4SLinus Torvalds 6721da177e4SLinus Torvalds #define HCI_EV_SI_DEVICE 0x01 6731da177e4SLinus Torvalds struct hci_ev_si_device { 6741da177e4SLinus Torvalds __u16 event; 6751da177e4SLinus Torvalds __u16 dev_id; 6761da177e4SLinus Torvalds } __attribute__ ((packed)); 6771da177e4SLinus Torvalds 6781da177e4SLinus Torvalds #define HCI_EV_SI_SECURITY 0x02 6791da177e4SLinus Torvalds struct hci_ev_si_security { 6801da177e4SLinus Torvalds __u16 event; 6811da177e4SLinus Torvalds __u16 proto; 6821da177e4SLinus Torvalds __u16 subproto; 6831da177e4SLinus Torvalds __u8 incoming; 6841da177e4SLinus Torvalds } __attribute__ ((packed)); 6851da177e4SLinus Torvalds 6861da177e4SLinus Torvalds /* ---- HCI Packet structures ---- */ 6871da177e4SLinus Torvalds #define HCI_COMMAND_HDR_SIZE 3 6881da177e4SLinus Torvalds #define HCI_EVENT_HDR_SIZE 2 6891da177e4SLinus Torvalds #define HCI_ACL_HDR_SIZE 4 6901da177e4SLinus Torvalds #define HCI_SCO_HDR_SIZE 3 6911da177e4SLinus Torvalds 6921da177e4SLinus Torvalds struct hci_command_hdr { 6931ebb9252SMarcel Holtmann __le16 opcode; /* OCF & OGF */ 6941da177e4SLinus Torvalds __u8 plen; 6951da177e4SLinus Torvalds } __attribute__ ((packed)); 6961da177e4SLinus Torvalds 6971da177e4SLinus Torvalds struct hci_event_hdr { 6981da177e4SLinus Torvalds __u8 evt; 6991da177e4SLinus Torvalds __u8 plen; 7001da177e4SLinus Torvalds } __attribute__ ((packed)); 7011da177e4SLinus Torvalds 7021da177e4SLinus Torvalds struct hci_acl_hdr { 7031ebb9252SMarcel Holtmann __le16 handle; /* Handle & Flags(PB, BC) */ 7041ebb9252SMarcel Holtmann __le16 dlen; 7051da177e4SLinus Torvalds } __attribute__ ((packed)); 7061da177e4SLinus Torvalds 7071da177e4SLinus Torvalds struct hci_sco_hdr { 7081ebb9252SMarcel Holtmann __le16 handle; 7091da177e4SLinus Torvalds __u8 dlen; 7101da177e4SLinus Torvalds } __attribute__ ((packed)); 7111da177e4SLinus Torvalds 7121da177e4SLinus Torvalds /* Command opcode pack/unpack */ 7131da177e4SLinus Torvalds #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) 7141da177e4SLinus Torvalds #define hci_opcode_ogf(op) (op >> 10) 7151da177e4SLinus Torvalds #define hci_opcode_ocf(op) (op & 0x03ff) 7161da177e4SLinus Torvalds 7171da177e4SLinus Torvalds /* ACL handle and flags pack/unpack */ 7181da177e4SLinus Torvalds #define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12)) 7191da177e4SLinus Torvalds #define hci_handle(h) (h & 0x0fff) 7201da177e4SLinus Torvalds #define hci_flags(h) (h >> 12) 7211da177e4SLinus Torvalds 7221da177e4SLinus Torvalds /* ---- HCI Sockets ---- */ 7231da177e4SLinus Torvalds 7241da177e4SLinus Torvalds /* Socket options */ 7251da177e4SLinus Torvalds #define HCI_DATA_DIR 1 7261da177e4SLinus Torvalds #define HCI_FILTER 2 7271da177e4SLinus Torvalds #define HCI_TIME_STAMP 3 7281da177e4SLinus Torvalds 7291da177e4SLinus Torvalds /* CMSG flags */ 7301da177e4SLinus Torvalds #define HCI_CMSG_DIR 0x0001 7311da177e4SLinus Torvalds #define HCI_CMSG_TSTAMP 0x0002 7321da177e4SLinus Torvalds 7331da177e4SLinus Torvalds struct sockaddr_hci { 7341da177e4SLinus Torvalds sa_family_t hci_family; 7351da177e4SLinus Torvalds unsigned short hci_dev; 7361da177e4SLinus Torvalds }; 7371da177e4SLinus Torvalds #define HCI_DEV_NONE 0xffff 7381da177e4SLinus Torvalds 7391da177e4SLinus Torvalds struct hci_filter { 7401da177e4SLinus Torvalds unsigned long type_mask; 7411da177e4SLinus Torvalds unsigned long event_mask[2]; 742*905f3ed6SAl Viro __le16 opcode; 7431da177e4SLinus Torvalds }; 7441da177e4SLinus Torvalds 7451da177e4SLinus Torvalds struct hci_ufilter { 7461da177e4SLinus Torvalds __u32 type_mask; 7471da177e4SLinus Torvalds __u32 event_mask[2]; 748*905f3ed6SAl Viro __le16 opcode; 7491da177e4SLinus Torvalds }; 7501da177e4SLinus Torvalds 7511da177e4SLinus Torvalds #define HCI_FLT_TYPE_BITS 31 7521da177e4SLinus Torvalds #define HCI_FLT_EVENT_BITS 63 7531da177e4SLinus Torvalds #define HCI_FLT_OGF_BITS 63 7541da177e4SLinus Torvalds #define HCI_FLT_OCF_BITS 127 7551da177e4SLinus Torvalds 7561da177e4SLinus Torvalds /* ---- HCI Ioctl requests structures ---- */ 7571da177e4SLinus Torvalds struct hci_dev_stats { 7581da177e4SLinus Torvalds __u32 err_rx; 7591da177e4SLinus Torvalds __u32 err_tx; 7601da177e4SLinus Torvalds __u32 cmd_tx; 7611da177e4SLinus Torvalds __u32 evt_rx; 7621da177e4SLinus Torvalds __u32 acl_tx; 7631da177e4SLinus Torvalds __u32 acl_rx; 7641da177e4SLinus Torvalds __u32 sco_tx; 7651da177e4SLinus Torvalds __u32 sco_rx; 7661da177e4SLinus Torvalds __u32 byte_rx; 7671da177e4SLinus Torvalds __u32 byte_tx; 7681da177e4SLinus Torvalds }; 7691da177e4SLinus Torvalds 7701da177e4SLinus Torvalds struct hci_dev_info { 7711da177e4SLinus Torvalds __u16 dev_id; 7721da177e4SLinus Torvalds char name[8]; 7731da177e4SLinus Torvalds 7741da177e4SLinus Torvalds bdaddr_t bdaddr; 7751da177e4SLinus Torvalds 7761da177e4SLinus Torvalds __u32 flags; 7771da177e4SLinus Torvalds __u8 type; 7781da177e4SLinus Torvalds 7791da177e4SLinus Torvalds __u8 features[8]; 7801da177e4SLinus Torvalds 7811da177e4SLinus Torvalds __u32 pkt_type; 7821da177e4SLinus Torvalds __u32 link_policy; 7831da177e4SLinus Torvalds __u32 link_mode; 7841da177e4SLinus Torvalds 7851da177e4SLinus Torvalds __u16 acl_mtu; 7861da177e4SLinus Torvalds __u16 acl_pkts; 7871da177e4SLinus Torvalds __u16 sco_mtu; 7881da177e4SLinus Torvalds __u16 sco_pkts; 7891da177e4SLinus Torvalds 7901da177e4SLinus Torvalds struct hci_dev_stats stat; 7911da177e4SLinus Torvalds }; 7921da177e4SLinus Torvalds 7931da177e4SLinus Torvalds struct hci_conn_info { 7941da177e4SLinus Torvalds __u16 handle; 7951da177e4SLinus Torvalds bdaddr_t bdaddr; 7961da177e4SLinus Torvalds __u8 type; 7971da177e4SLinus Torvalds __u8 out; 7981da177e4SLinus Torvalds __u16 state; 7991da177e4SLinus Torvalds __u32 link_mode; 8001da177e4SLinus Torvalds }; 8011da177e4SLinus Torvalds 8021da177e4SLinus Torvalds struct hci_dev_req { 8031da177e4SLinus Torvalds __u16 dev_id; 8041da177e4SLinus Torvalds __u32 dev_opt; 8051da177e4SLinus Torvalds }; 8061da177e4SLinus Torvalds 8071da177e4SLinus Torvalds struct hci_dev_list_req { 8081da177e4SLinus Torvalds __u16 dev_num; 8091da177e4SLinus Torvalds struct hci_dev_req dev_req[0]; /* hci_dev_req structures */ 8101da177e4SLinus Torvalds }; 8111da177e4SLinus Torvalds 8121da177e4SLinus Torvalds struct hci_conn_list_req { 8131da177e4SLinus Torvalds __u16 dev_id; 8141da177e4SLinus Torvalds __u16 conn_num; 8151da177e4SLinus Torvalds struct hci_conn_info conn_info[0]; 8161da177e4SLinus Torvalds }; 8171da177e4SLinus Torvalds 8181da177e4SLinus Torvalds struct hci_conn_info_req { 8191da177e4SLinus Torvalds bdaddr_t bdaddr; 8201da177e4SLinus Torvalds __u8 type; 8211da177e4SLinus Torvalds struct hci_conn_info conn_info[0]; 8221da177e4SLinus Torvalds }; 8231da177e4SLinus Torvalds 8241da177e4SLinus Torvalds struct hci_inquiry_req { 8251da177e4SLinus Torvalds __u16 dev_id; 8261da177e4SLinus Torvalds __u16 flags; 8271da177e4SLinus Torvalds __u8 lap[3]; 8281da177e4SLinus Torvalds __u8 length; 8291da177e4SLinus Torvalds __u8 num_rsp; 8301da177e4SLinus Torvalds }; 8311da177e4SLinus Torvalds #define IREQ_CACHE_FLUSH 0x0001 8321da177e4SLinus Torvalds 8331da177e4SLinus Torvalds #endif /* __HCI_H */ 834