1 /* $NetBSD: hci.h,v 1.41 2015/11/28 09:04:34 plunky Exp $ */ 2 3 /*- 4 * Copyright (c) 2005 Iain Hibbert. 5 * Copyright (c) 2006 Itronix Inc. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. The name of Itronix Inc. may not be used to endorse 17 * or promote products derived from this software without specific 18 * prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY 24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 * ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 /*- 33 * Copyright (c) 2001 Maksim Yevmenkin <m_evmenkin@yahoo.com> 34 * All rights reserved. 35 * 36 * Redistribution and use in source and binary forms, with or without 37 * modification, are permitted provided that the following conditions 38 * are met: 39 * 1. Redistributions of source code must retain the above copyright 40 * notice, this list of conditions and the following disclaimer. 41 * 2. Redistributions in binary form must reproduce the above copyright 42 * notice, this list of conditions and the following disclaimer in the 43 * documentation and/or other materials provided with the distribution. 44 * 45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 48 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 55 * SUCH DAMAGE. 56 * 57 * $Id: hci.h,v 1.41 2015/11/28 09:04:34 plunky Exp $ 58 * $FreeBSD: src/sys/netgraph/bluetooth/include/ng_hci.h,v 1.6 2005/01/07 01:45:43 imp Exp $ 59 */ 60 61 /* 62 * This file contains everything that applications need to know from 63 * Host Controller Interface (HCI). Information taken from Bluetooth 64 * Core Specifications (v1.1, v2.0, v2.1 + EDR, v3.0 + HS, 65 * v4.0 and v4.2) 66 * 67 * This file can be included by both kernel and userland applications. 68 * 69 * NOTE: Here and after Bluetooth device is called a "unit". Bluetooth 70 * specification refers to both devices and units. They are the 71 * same thing (I think), so to be consistent word "unit" will be 72 * used. 73 */ 74 75 #ifndef _NETBT_HCI_H_ 76 #define _NETBT_HCI_H_ 77 78 #include <netbt/bluetooth.h> 79 80 #include <sys/ioccom.h> 81 82 /************************************************************************** 83 ************************************************************************** 84 ** Common defines and types (HCI) 85 ************************************************************************** 86 **************************************************************************/ 87 88 #define HCI_LAP_SIZE 3 /* unit LAP */ 89 #define HCI_KEY_SIZE 16 /* link key */ 90 #define HCI_PIN_SIZE 16 /* link PIN */ 91 #define HCI_EVENT_MASK_SIZE 8 /* event mask */ 92 #define HCI_CLASS_SIZE 3 /* unit class */ 93 #define HCI_FEATURES_SIZE 8 /* LMP features */ 94 #define HCI_UNIT_NAME_SIZE 248 /* unit name size */ 95 #define HCI_DEVNAME_SIZE 16 /* same as dv_xname */ 96 #define HCI_COMMANDS_SIZE 64 /* supported commands mask */ 97 98 /* HCI specification */ 99 #define HCI_SPEC_V10 0x00 /* v1.0b */ 100 #define HCI_SPEC_V11 0x01 /* v1.1 */ 101 #define HCI_SPEC_V12 0x02 /* v1.2 */ 102 #define HCI_SPEC_V20 0x03 /* v2.0 + EDR */ 103 #define HCI_SPEC_V21 0x04 /* v2.1 + EDR */ 104 #define HCI_SPEC_V30 0x05 /* v3.0 + HS */ 105 #define HCI_SPEC_V40 0x06 /* v4.0 */ 106 #define HCI_SPEC_V41 0x07 /* v4.1 */ 107 #define HCI_SPEC_V42 0x08 /* v4.2 */ 108 /* 0x09 - 0xFF - reserved for future use */ 109 110 /* LMP features (and page 0 of extended features) */ 111 /* ------------------- byte 0 --------------------*/ 112 #define HCI_LMP_3SLOT 0x01 113 #define HCI_LMP_5SLOT 0x02 114 #define HCI_LMP_ENCRYPTION 0x04 115 #define HCI_LMP_SLOT_OFFSET 0x08 116 #define HCI_LMP_TIMIACCURACY 0x10 117 #define HCI_LMP_ROLE_SWITCH 0x20 118 #define HCI_LMP_HOLD_MODE 0x40 119 #define HCI_LMP_SNIFF_MODE 0x80 120 /* ------------------- byte 1 --------------------*/ 121 #define HCI_LMP_PARK_MODE 0x01 122 #define HCI_LMP_RSSI 0x02 123 #define HCI_LMP_CHANNEL_QUALITY 0x04 124 #define HCI_LMP_SCO_LINK 0x08 125 #define HCI_LMP_HV2_PKT 0x10 126 #define HCI_LMP_HV3_PKT 0x20 127 #define HCI_LMP_ULAW_LOG 0x40 128 #define HCI_LMP_ALAW_LOG 0x80 129 /* ------------------- byte 2 --------------------*/ 130 #define HCI_LMP_CVSD 0x01 131 #define HCI_LMP_PAGISCHEME 0x02 132 #define HCI_LMP_POWER_CONTROL 0x04 133 #define HCI_LMP_TRANSPARENT_SCO 0x08 134 #define HCI_LMP_FLOW_CONTROL_LAG0 0x10 135 #define HCI_LMP_FLOW_CONTROL_LAG1 0x20 136 #define HCI_LMP_FLOW_CONTROL_LAG2 0x40 137 #define HCI_LMP_BC_ENCRYPTION 0x80 138 /* ------------------- byte 3 --------------------*/ 139 /* reserved 0x01 */ 140 #define HCI_LMP_EDR_ACL_2MBPS 0x02 141 #define HCI_LMP_EDR_ACL_3MBPS 0x04 142 #define HCI_LMP_ENHANCED_ISCAN 0x08 143 #define HCI_LMP_INTERLACED_ISCAN 0x10 144 #define HCI_LMP_INTERLACED_PSCAN 0x20 145 #define HCI_LMP_RSSI_INQUIRY 0x40 146 #define HCI_LMP_EV3_PKT 0x80 147 /* ------------------- byte 4 --------------------*/ 148 #define HCI_LMP_EV4_PKT 0x01 149 #define HCI_LMP_EV5_PKT 0x02 150 /* reserved 0x04 */ 151 #define HCI_LMP_AFH_CAPABLE_SLAVE 0x08 152 #define HCI_LMP_AFH_CLASS_SLAVE 0x10 153 #define HCI_LMP_BR_EDR_UNSUPPORTED 0x20 154 #define HCI_LMP_LE_CONTROLLER 0x40 155 #define HCI_LMP_3SLOT_EDR_ACL 0x80 156 /* ------------------- byte 5 --------------------*/ 157 #define HCI_LMP_5SLOT_EDR_ACL 0x01 158 #define HCI_LMP_SNIFF_SUBRATING 0x02 159 #define HCI_LMP_PAUSE_ENCRYPTION 0x04 160 #define HCI_LMP_AFH_CAPABLE_MASTER 0x08 161 #define HCI_LMP_AFH_CLASS_MASTER 0x10 162 #define HCI_LMP_EDR_eSCO_2MBPS 0x20 163 #define HCI_LMP_EDR_eSCO_3MBPS 0x40 164 #define HCI_LMP_3SLOT_EDR_eSCO 0x80 165 /* ------------------- byte 6 --------------------*/ 166 #define HCI_LMP_EXTENDED_INQUIRY 0x01 167 #define HCI_LMP_LE_BR_EDR_CONTROLLER 0x02 168 /* reserved 0x04 */ 169 #define HCI_LMP_SIMPLE_PAIRING 0x08 170 #define HCI_LMP_ENCAPSULATED_PDU 0x10 171 #define HCI_LMP_ERRDATA_REPORTING 0x20 172 #define HCI_LMP_NOFLUSH_PB_FLAG 0x40 173 /* reserved 0x80 */ 174 /* ------------------- byte 7 --------------------*/ 175 #define HCI_LMP_LINK_SUPERVISION_TO 0x01 176 #define HCI_LMP_INQ_RSP_TX_POWER 0x02 177 #define HCI_LMP_ENHANCED_POWER_CONTROL 0x04 178 #define HCI_LMP_EXTENDED_FEATURES 0x80 179 180 /* page 1 of extended features */ 181 /* ------------------- byte 0 --------------------*/ 182 #define HCI_LMP_SSP 0x01 183 #define HCI_LMP_LE_HOST 0x02 184 #define HCI_LMP_LE_BR_EDR_HOST 0x04 185 #define HCI_LMP_SECURE_CONN_HOST 0x08 186 187 /* page 2 of extended features */ 188 /* ------------------- byte 0 --------------------*/ 189 #define HCI_LMP_CONNLESS_MASTER 0x01 190 #define HCI_LMP_CONNLESS_SLAVE 0x02 191 #define HCI_LMP_SYNC_TRAIN 0x04 192 #define HCI_LMP_SYNC_SCAN 0x08 193 #define HCI_LMP_INQ_RSP_NOTIFY 0x10 194 #define HCI_LMP_INTERLACE_SCAN 0x20 195 #define HCI_LMP_COARSE_CLOCK 0x40 196 /* reserved 0x80 */ 197 /* ------------------- byte 0 --------------------*/ 198 #define HCI_LMP_SECURE_CONN_CONTROLLER 0x01 199 #define HCI_LMP_PING 0x02 200 /* reserved 0x04 */ 201 #define HCI_LMP_TRAIN_NUDGING 0x08 202 203 /* Link types */ 204 #define HCI_LINK_SCO 0x00 /* Voice */ 205 #define HCI_LINK_ACL 0x01 /* Data */ 206 #define HCI_LINK_eSCO 0x02 /* eSCO */ 207 /* 0x03 - 0xFF - reserved for future use */ 208 209 /* 210 * ACL/SCO packet type bits are set to enable the 211 * packet type, except for 2MBPS and 3MBPS when they 212 * are unset to enable the packet type. 213 */ 214 /* ACL Packet types for "Create Connection" */ 215 #define HCI_PKT_2MBPS_DH1 0x0002 216 #define HCI_PKT_3MBPS_DH1 0x0004 217 #define HCI_PKT_DM1 0x0008 218 #define HCI_PKT_DH1 0x0010 219 #define HCI_PKT_2MBPS_DH3 0x0100 220 #define HCI_PKT_3MBPS_DH3 0x0200 221 #define HCI_PKT_DM3 0x0400 222 #define HCI_PKT_DH3 0x0800 223 #define HCI_PKT_2MBPS_DH5 0x1000 224 #define HCI_PKT_3MBPS_DH5 0x2000 225 #define HCI_PKT_DM5 0x4000 226 #define HCI_PKT_DH5 0x8000 227 228 /* SCO Packet types for "Setup Synchronous Connection" */ 229 #define HCI_PKT_HV1 0x0001 230 #define HCI_PKT_HV2 0x0002 231 #define HCI_PKT_HV3 0x0004 232 #define HCI_PKT_EV3 0x0008 233 #define HCI_PKT_EV4 0x0010 234 #define HCI_PKT_EV5 0x0020 235 #define HCI_PKT_2MBPS_EV3 0x0040 236 #define HCI_PKT_3MBPS_EV3 0x0080 237 #define HCI_PKT_2MBPS_EV5 0x0100 238 #define HCI_PKT_3MBPS_EV5 0x0200 239 240 /* 241 * Connection modes/Unit modes 242 * 243 * This is confusing. It means that one of the units change its mode 244 * for the specific connection. For example one connection was put on 245 * hold (but i could be wrong :) 246 */ 247 248 /* Page scan modes (are deprecated) */ 249 #define HCI_MANDATORY_PAGE_SCAN_MODE 0x00 250 #define HCI_OPTIONAL_PAGE_SCAN_MODE1 0x01 251 #define HCI_OPTIONAL_PAGE_SCAN_MODE2 0x02 252 #define HCI_OPTIONAL_PAGE_SCAN_MODE3 0x03 253 /* 0x04 - 0xFF - reserved for future use */ 254 255 /* Page scan repetition modes */ 256 #define HCI_SCAN_REP_MODE0 0x00 257 #define HCI_SCAN_REP_MODE1 0x01 258 #define HCI_SCAN_REP_MODE2 0x02 259 /* 0x03 - 0xFF - reserved for future use */ 260 261 /* Page scan period modes */ 262 #define HCI_PAGE_SCAN_PERIOD_MODE0 0x00 263 #define HCI_PAGE_SCAN_PERIOD_MODE1 0x01 264 #define HCI_PAGE_SCAN_PERIOD_MODE2 0x02 265 /* 0x03 - 0xFF - reserved for future use */ 266 267 /* Scan enable */ 268 #define HCI_NO_SCAN_ENABLE 0x00 269 #define HCI_INQUIRY_SCAN_ENABLE 0x01 270 #define HCI_PAGE_SCAN_ENABLE 0x02 271 /* 0x04 - 0xFF - reserved for future use */ 272 273 /* Hold mode activities */ 274 #define HCI_HOLD_MODE_NO_CHANGE 0x00 275 #define HCI_HOLD_MODE_SUSPEND_PAGE_SCAN 0x01 276 #define HCI_HOLD_MODE_SUSPEND_INQUIRY_SCAN 0x02 277 #define HCI_HOLD_MODE_SUSPEND_PERIOD_INQUIRY 0x04 278 /* 0x08 - 0x80 - reserved for future use */ 279 280 /* Connection roles */ 281 #define HCI_ROLE_MASTER 0x00 282 #define HCI_ROLE_SLAVE 0x01 283 /* 0x02 - 0xFF - reserved for future use */ 284 285 /* Key flags */ 286 #define HCI_USE_SEMI_PERMANENT_LINK_KEYS 0x00 287 #define HCI_USE_TEMPORARY_LINK_KEY 0x01 288 /* 0x02 - 0xFF - reserved for future use */ 289 290 /* Pin types */ 291 #define HCI_PIN_TYPE_VARIABLE 0x00 292 #define HCI_PIN_TYPE_FIXED 0x01 293 294 /* Link key types */ 295 #define HCI_LINK_KEY_TYPE_COMBINATION_KEY 0x00 296 #define HCI_LINK_KEY_TYPE_LOCAL_UNIT_KEY 0x01 297 #define HCI_LINK_KEY_TYPE_REMOTE_UNIT_KEY 0x02 298 /* 0x03 - 0xFF - reserved for future use */ 299 300 /* Encryption modes */ 301 #define HCI_ENCRYPTION_MODE_NONE 0x00 302 #define HCI_ENCRYPTION_MODE_P2P 0x01 303 #define HCI_ENCRYPTION_MODE_ALL 0x02 304 /* 0x03 - 0xFF - reserved for future use */ 305 306 /* Quality of service types */ 307 #define HCI_SERVICE_TYPE_NO_TRAFFIC 0x00 308 #define HCI_SERVICE_TYPE_BEST_EFFORT 0x01 309 #define HCI_SERVICE_TYPE_GUARANTEED 0x02 310 /* 0x03 - 0xFF - reserved for future use */ 311 312 /* Link policy settings */ 313 #define HCI_LINK_POLICY_DISABLE_ALL_LM_MODES 0x0000 314 #define HCI_LINK_POLICY_ENABLE_ROLE_SWITCH 0x0001 /* Master/Slave switch */ 315 #define HCI_LINK_POLICY_ENABLE_HOLD_MODE 0x0002 316 #define HCI_LINK_POLICY_ENABLE_SNIFF_MODE 0x0004 317 #define HCI_LINK_POLICY_ENABLE_PARK_MODE 0x0008 318 /* 0x0010 - 0x8000 - reserved for future use */ 319 320 /* Event masks */ 321 #define HCI_EVMSK_ALL 0x00000000ffffffff 322 #define HCI_EVMSK_NONE 0x0000000000000000 323 #define HCI_EVMSK_INQUIRY_COMPL 0x0000000000000001 324 #define HCI_EVMSK_INQUIRY_RESULT 0x0000000000000002 325 #define HCI_EVMSK_CON_COMPL 0x0000000000000004 326 #define HCI_EVMSK_CON_REQ 0x0000000000000008 327 #define HCI_EVMSK_DISCON_COMPL 0x0000000000000010 328 #define HCI_EVMSK_AUTH_COMPL 0x0000000000000020 329 #define HCI_EVMSK_REMOTE_NAME_REQ_COMPL 0x0000000000000040 330 #define HCI_EVMSK_ENCRYPTION_CHANGE 0x0000000000000080 331 #define HCI_EVMSK_CHANGE_CON_LINK_KEY_COMPL 0x0000000000000100 332 #define HCI_EVMSK_MASTER_LINK_KEY_COMPL 0x0000000000000200 333 #define HCI_EVMSK_READ_REMOTE_FEATURES_COMPL 0x0000000000000400 334 #define HCI_EVMSK_READ_REMOTE_VER_INFO_COMPL 0x0000000000000800 335 #define HCI_EVMSK_QOS_SETUP_COMPL 0x0000000000001000 336 #define HCI_EVMSK_COMMAND_COMPL 0x0000000000002000 337 #define HCI_EVMSK_COMMAND_STATUS 0x0000000000004000 338 #define HCI_EVMSK_HARDWARE_ERROR 0x0000000000008000 339 #define HCI_EVMSK_FLUSH_OCCUR 0x0000000000010000 340 #define HCI_EVMSK_ROLE_CHANGE 0x0000000000020000 341 #define HCI_EVMSK_NUM_COMPL_PKTS 0x0000000000040000 342 #define HCI_EVMSK_MODE_CHANGE 0x0000000000080000 343 #define HCI_EVMSK_RETURN_LINK_KEYS 0x0000000000100000 344 #define HCI_EVMSK_PIN_CODE_REQ 0x0000000000200000 345 #define HCI_EVMSK_LINK_KEY_REQ 0x0000000000400000 346 #define HCI_EVMSK_LINK_KEY_NOTIFICATION 0x0000000000800000 347 #define HCI_EVMSK_LOOPBACK_COMMAND 0x0000000001000000 348 #define HCI_EVMSK_DATA_BUFFER_OVERFLOW 0x0000000002000000 349 #define HCI_EVMSK_MAX_SLOT_CHANGE 0x0000000004000000 350 #define HCI_EVMSK_READ_CLOCK_OFFSET_COMLETE 0x0000000008000000 351 #define HCI_EVMSK_CON_PKT_TYPE_CHANGED 0x0000000010000000 352 #define HCI_EVMSK_QOS_VIOLATION 0x0000000020000000 353 #define HCI_EVMSK_PAGE_SCAN_MODE_CHANGE 0x0000000040000000 354 #define HCI_EVMSK_PAGE_SCAN_REP_MODE_CHANGE 0x0000000080000000 355 /* 0x0000000100000000 - 0x8000000000000000 - reserved for future use */ 356 357 /* Filter types */ 358 #define HCI_FILTER_TYPE_NONE 0x00 359 #define HCI_FILTER_TYPE_INQUIRY_RESULT 0x01 360 #define HCI_FILTER_TYPE_CON_SETUP 0x02 361 /* 0x03 - 0xFF - reserved for future use */ 362 363 /* Filter condition types for HCI_FILTER_TYPE_INQUIRY_RESULT */ 364 #define HCI_FILTER_COND_INQUIRY_NEW_UNIT 0x00 365 #define HCI_FILTER_COND_INQUIRY_UNIT_CLASS 0x01 366 #define HCI_FILTER_COND_INQUIRY_BDADDR 0x02 367 /* 0x03 - 0xFF - reserved for future use */ 368 369 /* Filter condition types for HCI_FILTER_TYPE_CON_SETUP */ 370 #define HCI_FILTER_COND_CON_ANY_UNIT 0x00 371 #define HCI_FILTER_COND_CON_UNIT_CLASS 0x01 372 #define HCI_FILTER_COND_CON_BDADDR 0x02 373 /* 0x03 - 0xFF - reserved for future use */ 374 375 /* Xmit level types */ 376 #define HCI_XMIT_LEVEL_CURRENT 0x00 377 #define HCI_XMIT_LEVEL_MAXIMUM 0x01 378 /* 0x02 - 0xFF - reserved for future use */ 379 380 /* Host Controller to Host flow control */ 381 #define HCI_HC2H_FLOW_CONTROL_NONE 0x00 382 #define HCI_HC2H_FLOW_CONTROL_ACL 0x01 383 #define HCI_HC2H_FLOW_CONTROL_SCO 0x02 384 #define HCI_HC2H_FLOW_CONTROL_BOTH 0x03 385 /* 0x04 - 0xFF - reserved future use */ 386 387 /* Loopback modes */ 388 #define HCI_LOOPBACK_NONE 0x00 389 #define HCI_LOOPBACK_LOCAL 0x01 390 #define HCI_LOOPBACK_REMOTE 0x02 391 /* 0x03 - 0xFF - reserved future use */ 392 393 /************************************************************************** 394 ************************************************************************** 395 ** Link level defines, headers and types 396 ************************************************************************** 397 **************************************************************************/ 398 399 /* 400 * Macro(s) to combine OpCode and extract OGF (OpCode Group Field) 401 * and OCF (OpCode Command Field) from OpCode. 402 */ 403 404 #define HCI_OPCODE(gf,cf) ((((gf) & 0x3f) << 10) | ((cf) & 0x3ff)) 405 #define HCI_OCF(op) ((op) & 0x3ff) 406 #define HCI_OGF(op) (((op) >> 10) & 0x3f) 407 408 /* 409 * Macro(s) to extract/combine connection handle, BC (Broadcast) and 410 * PB (Packet boundary) flags. 411 */ 412 413 #define HCI_CON_HANDLE(h) ((h) & 0x0fff) 414 #define HCI_PB_FLAG(h) (((h) & 0x3000) >> 12) 415 #define HCI_BC_FLAG(h) (((h) & 0xc000) >> 14) 416 #define HCI_MK_CON_HANDLE(h, pb, bc) \ 417 (((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14)) 418 419 /* PB flag values */ 420 /* 00 - reserved for future use */ 421 #define HCI_PACKET_FRAGMENT 0x1 422 #define HCI_PACKET_START 0x2 423 /* 11 - reserved for future use */ 424 425 /* BC flag values */ 426 #define HCI_POINT2POINT 0x0 /* only Host controller to Host */ 427 #define HCI_BROADCAST_ACTIVE 0x1 /* both directions */ 428 #define HCI_BROADCAST_PICONET 0x2 /* both directions */ 429 /* 11 - reserved for future use */ 430 431 /* HCI command packet header */ 432 typedef struct { 433 uint8_t type; /* MUST be 0x01 */ 434 uint16_t opcode; /* OpCode */ 435 uint8_t length; /* parameter(s) length in bytes */ 436 } __packed hci_cmd_hdr_t; 437 438 #define HCI_CMD_PKT 0x01 439 #define HCI_CMD_PKT_SIZE (sizeof(hci_cmd_hdr_t) + 0xff) 440 441 /* ACL data packet header */ 442 typedef struct { 443 uint8_t type; /* MUST be 0x02 */ 444 uint16_t con_handle; /* connection handle + PB + BC flags */ 445 uint16_t length; /* payload length in bytes */ 446 } __packed hci_acldata_hdr_t; 447 448 #define HCI_ACL_DATA_PKT 0x02 449 #define HCI_ACL_PKT_SIZE (sizeof(hci_acldata_hdr_t) + 0xffff) 450 451 /* SCO data packet header */ 452 typedef struct { 453 uint8_t type; /* MUST be 0x03 */ 454 uint16_t con_handle; /* connection handle + reserved bits */ 455 uint8_t length; /* payload length in bytes */ 456 } __packed hci_scodata_hdr_t; 457 458 #define HCI_SCO_DATA_PKT 0x03 459 #define HCI_SCO_PKT_SIZE (sizeof(hci_scodata_hdr_t) + 0xff) 460 461 /* HCI event packet header */ 462 typedef struct { 463 uint8_t type; /* MUST be 0x04 */ 464 uint8_t event; /* event */ 465 uint8_t length; /* parameter(s) length in bytes */ 466 } __packed hci_event_hdr_t; 467 468 #define HCI_EVENT_PKT 0x04 469 #define HCI_EVENT_PKT_SIZE (sizeof(hci_event_hdr_t) + 0xff) 470 471 /* HCI status return parameter */ 472 typedef struct { 473 uint8_t status; /* 0x00 - success */ 474 } __packed hci_status_rp; 475 476 /************************************************************************** 477 ************************************************************************** 478 ** OGF 0x01 Link control commands and return parameters 479 ************************************************************************** 480 **************************************************************************/ 481 482 #define HCI_OGF_LINK_CONTROL 0x01 483 484 #define HCI_OCF_INQUIRY 0x0001 485 #define HCI_CMD_INQUIRY 0x0401 486 typedef struct { 487 uint8_t lap[HCI_LAP_SIZE]; /* LAP */ 488 uint8_t inquiry_length; /* (N x 1.28) sec */ 489 uint8_t num_responses; /* Max. # of responses */ 490 } __packed hci_inquiry_cp; 491 /* No return parameter(s) */ 492 493 #define HCI_OCF_INQUIRY_CANCEL 0x0002 494 #define HCI_CMD_INQUIRY_CANCEL 0x0402 495 /* No command parameter(s) */ 496 typedef hci_status_rp hci_inquiry_cancel_rp; 497 498 #define HCI_OCF_PERIODIC_INQUIRY 0x0003 499 #define HCI_CMD_PERIODIC_INQUIRY 0x0403 500 typedef struct { 501 uint16_t max_period_length; /* Max. and min. amount of time */ 502 uint16_t min_period_length; /* between consecutive inquiries */ 503 uint8_t lap[HCI_LAP_SIZE]; /* LAP */ 504 uint8_t inquiry_length; /* (inquiry_length * 1.28) sec */ 505 uint8_t num_responses; /* Max. # of responses */ 506 } __packed hci_periodic_inquiry_cp; 507 508 typedef hci_status_rp hci_periodic_inquiry_rp; 509 510 #define HCI_OCF_EXIT_PERIODIC_INQUIRY 0x0004 511 #define HCI_CMD_EXIT_PERIODIC_INQUIRY 0x0404 512 /* No command parameter(s) */ 513 typedef hci_status_rp hci_exit_periodic_inquiry_rp; 514 515 #define HCI_OCF_CREATE_CON 0x0005 516 #define HCI_CMD_CREATE_CON 0x0405 517 typedef struct { 518 bdaddr_t bdaddr; /* destination address */ 519 uint16_t pkt_type; /* packet type */ 520 uint8_t page_scan_rep_mode; /* page scan repetition mode */ 521 uint8_t page_scan_mode; /* reserved - set to 0x00 */ 522 uint16_t clock_offset; /* clock offset */ 523 uint8_t accept_role_switch; /* accept role switch? 0x00 == No */ 524 } __packed hci_create_con_cp; 525 /* No return parameter(s) */ 526 527 #define HCI_OCF_DISCONNECT 0x0006 528 #define HCI_CMD_DISCONNECT 0x0406 529 typedef struct { 530 uint16_t con_handle; /* connection handle */ 531 uint8_t reason; /* reason to disconnect */ 532 } __packed hci_discon_cp; 533 /* No return parameter(s) */ 534 535 /* Add SCO Connection is deprecated */ 536 #define HCI_OCF_ADD_SCO_CON 0x0007 537 #define HCI_CMD_ADD_SCO_CON 0x0407 538 typedef struct { 539 uint16_t con_handle; /* connection handle */ 540 uint16_t pkt_type; /* packet type */ 541 } __packed hci_add_sco_con_cp; 542 /* No return parameter(s) */ 543 544 #define HCI_OCF_CREATE_CON_CANCEL 0x0008 545 #define HCI_CMD_CREATE_CON_CANCEL 0x0408 546 typedef struct { 547 bdaddr_t bdaddr; /* destination address */ 548 } __packed hci_create_con_cancel_cp; 549 550 typedef struct { 551 uint8_t status; /* 0x00 - success */ 552 bdaddr_t bdaddr; /* destination address */ 553 } __packed hci_create_con_cancel_rp; 554 555 #define HCI_OCF_ACCEPT_CON 0x0009 556 #define HCI_CMD_ACCEPT_CON 0x0409 557 typedef struct { 558 bdaddr_t bdaddr; /* address of unit to be connected */ 559 uint8_t role; /* connection role */ 560 } __packed hci_accept_con_cp; 561 /* No return parameter(s) */ 562 563 #define HCI_OCF_REJECT_CON 0x000a 564 #define HCI_CMD_REJECT_CON 0x040A 565 typedef struct { 566 bdaddr_t bdaddr; /* remote address */ 567 uint8_t reason; /* reason to reject */ 568 } __packed hci_reject_con_cp; 569 /* No return parameter(s) */ 570 571 #define HCI_OCF_LINK_KEY_REP 0x000b 572 #define HCI_CMD_LINK_KEY_REP 0x040B 573 typedef struct { 574 bdaddr_t bdaddr; /* remote address */ 575 uint8_t key[HCI_KEY_SIZE]; /* key */ 576 } __packed hci_link_key_rep_cp; 577 578 typedef struct { 579 uint8_t status; /* 0x00 - success */ 580 bdaddr_t bdaddr; /* unit address */ 581 } __packed hci_link_key_rep_rp; 582 583 #define HCI_OCF_LINK_KEY_NEG_REP 0x000c 584 #define HCI_CMD_LINK_KEY_NEG_REP 0x040C 585 typedef struct { 586 bdaddr_t bdaddr; /* remote address */ 587 } __packed hci_link_key_neg_rep_cp; 588 589 typedef struct { 590 uint8_t status; /* 0x00 - success */ 591 bdaddr_t bdaddr; /* unit address */ 592 } __packed hci_link_key_neg_rep_rp; 593 594 #define HCI_OCF_PIN_CODE_REP 0x000d 595 #define HCI_CMD_PIN_CODE_REP 0x040D 596 typedef struct { 597 bdaddr_t bdaddr; /* remote address */ 598 uint8_t pin_size; /* pin code length (in bytes) */ 599 uint8_t pin[HCI_PIN_SIZE]; /* pin code */ 600 } __packed hci_pin_code_rep_cp; 601 602 typedef struct { 603 uint8_t status; /* 0x00 - success */ 604 bdaddr_t bdaddr; /* unit address */ 605 } __packed hci_pin_code_rep_rp; 606 607 #define HCI_OCF_PIN_CODE_NEG_REP 0x000e 608 #define HCI_CMD_PIN_CODE_NEG_REP 0x040E 609 typedef struct { 610 bdaddr_t bdaddr; /* remote address */ 611 } __packed hci_pin_code_neg_rep_cp; 612 613 typedef struct { 614 uint8_t status; /* 0x00 - success */ 615 bdaddr_t bdaddr; /* unit address */ 616 } __packed hci_pin_code_neg_rep_rp; 617 618 #define HCI_OCF_CHANGE_CON_PACKET_TYPE 0x000f 619 #define HCI_CMD_CHANGE_CON_PACKET_TYPE 0x040F 620 typedef struct { 621 uint16_t con_handle; /* connection handle */ 622 uint16_t pkt_type; /* packet type */ 623 } __packed hci_change_con_pkt_type_cp; 624 /* No return parameter(s) */ 625 626 #define HCI_OCF_AUTH_REQ 0x0011 627 #define HCI_CMD_AUTH_REQ 0x0411 628 typedef struct { 629 uint16_t con_handle; /* connection handle */ 630 } __packed hci_auth_req_cp; 631 /* No return parameter(s) */ 632 633 #define HCI_OCF_SET_CON_ENCRYPTION 0x0013 634 #define HCI_CMD_SET_CON_ENCRYPTION 0x0413 635 typedef struct { 636 uint16_t con_handle; /* connection handle */ 637 uint8_t encryption_enable; /* 0x00 - disable, 0x01 - enable */ 638 } __packed hci_set_con_encryption_cp; 639 /* No return parameter(s) */ 640 641 #define HCI_OCF_CHANGE_CON_LINK_KEY 0x0015 642 #define HCI_CMD_CHANGE_CON_LINK_KEY 0x0415 643 typedef struct { 644 uint16_t con_handle; /* connection handle */ 645 } __packed hci_change_con_link_key_cp; 646 /* No return parameter(s) */ 647 648 #define HCI_OCF_MASTER_LINK_KEY 0x0017 649 #define HCI_CMD_MASTER_LINK_KEY 0x0417 650 typedef struct { 651 uint8_t key_flag; /* key flag */ 652 } __packed hci_master_link_key_cp; 653 /* No return parameter(s) */ 654 655 #define HCI_OCF_REMOTE_NAME_REQ 0x0019 656 #define HCI_CMD_REMOTE_NAME_REQ 0x0419 657 typedef struct { 658 bdaddr_t bdaddr; /* remote address */ 659 uint8_t page_scan_rep_mode; /* page scan repetition mode */ 660 uint8_t page_scan_mode; /* page scan mode */ 661 uint16_t clock_offset; /* clock offset */ 662 } __packed hci_remote_name_req_cp; 663 /* No return parameter(s) */ 664 665 #define HCI_OCF_REMOTE_NAME_REQ_CANCEL 0x001a 666 #define HCI_CMD_REMOTE_NAME_REQ_CANCEL 0x041A 667 typedef struct { 668 bdaddr_t bdaddr; /* remote address */ 669 } __packed hci_remote_name_req_cancel_cp; 670 671 typedef struct { 672 uint8_t status; /* 0x00 - success */ 673 bdaddr_t bdaddr; /* remote address */ 674 } __packed hci_remote_name_req_cancel_rp; 675 676 #define HCI_OCF_READ_REMOTE_FEATURES 0x001b 677 #define HCI_CMD_READ_REMOTE_FEATURES 0x041B 678 typedef struct { 679 uint16_t con_handle; /* connection handle */ 680 } __packed hci_read_remote_features_cp; 681 /* No return parameter(s) */ 682 683 #define HCI_OCF_READ_REMOTE_EXTENDED_FEATURES 0x001c 684 #define HCI_CMD_READ_REMOTE_EXTENDED_FEATURES 0x041C 685 typedef struct { 686 uint16_t con_handle; /* connection handle */ 687 uint8_t page; /* page number */ 688 } __packed hci_read_remote_extended_features_cp; 689 /* No return parameter(s) */ 690 691 #define HCI_OCF_READ_REMOTE_VER_INFO 0x001d 692 #define HCI_CMD_READ_REMOTE_VER_INFO 0x041D 693 typedef struct { 694 uint16_t con_handle; /* connection handle */ 695 } __packed hci_read_remote_ver_info_cp; 696 /* No return parameter(s) */ 697 698 #define HCI_OCF_READ_CLOCK_OFFSET 0x001f 699 #define HCI_CMD_READ_CLOCK_OFFSET 0x041F 700 typedef struct { 701 uint16_t con_handle; /* connection handle */ 702 } __packed hci_read_clock_offset_cp; 703 /* No return parameter(s) */ 704 705 #define HCI_OCF_READ_LMP_HANDLE 0x0020 706 #define HCI_CMD_READ_LMP_HANDLE 0x0420 707 typedef struct { 708 uint16_t con_handle; /* connection handle */ 709 } __packed hci_read_lmp_handle_cp; 710 711 typedef struct { 712 uint8_t status; /* 0x00 - success */ 713 uint16_t con_handle; /* connection handle */ 714 uint8_t lmp_handle; /* LMP handle */ 715 uint32_t reserved; /* reserved */ 716 } __packed hci_read_lmp_handle_rp; 717 718 #define HCI_OCF_SETUP_SCO_CON 0x0028 719 #define HCI_CMD_SETUP_SCO_CON 0x0428 720 typedef struct { 721 uint16_t con_handle; /* connection handle */ 722 uint32_t tx_bandwidth; /* transmit bandwidth */ 723 uint32_t rx_bandwidth; /* receive bandwidth */ 724 uint16_t latency; /* maximum latency */ 725 uint16_t voice; /* voice setting */ 726 uint8_t rt_effort; /* retransmission effort */ 727 uint16_t pkt_type; /* packet types */ 728 } __packed hci_setup_sco_con_cp; 729 /* No return parameter(s) */ 730 731 #define HCI_OCF_ACCEPT_SCO_CON_REQ 0x0029 732 #define HCI_CMD_ACCEPT_SCO_CON_REQ 0x0429 733 typedef struct { 734 bdaddr_t bdaddr; /* remote address */ 735 uint32_t tx_bandwidth; /* transmit bandwidth */ 736 uint32_t rx_bandwidth; /* receive bandwidth */ 737 uint16_t latency; /* maximum latency */ 738 uint16_t content; /* voice setting */ 739 uint8_t rt_effort; /* retransmission effort */ 740 uint16_t pkt_type; /* packet types */ 741 } __packed hci_accept_sco_con_req_cp; 742 /* No return parameter(s) */ 743 744 #define HCI_OCF_REJECT_SCO_CON_REQ 0x002a 745 #define HCI_CMD_REJECT_SCO_CON_REQ 0x042a 746 typedef struct { 747 bdaddr_t bdaddr; /* remote address */ 748 uint8_t reason; /* reject error code */ 749 } __packed hci_reject_sco_con_req_cp; 750 /* No return parameter(s) */ 751 752 #define HCI_OCF_IO_CAPABILITY_REP 0x002b 753 #define HCI_CMD_IO_CAPABILITY_REP 0x042a 754 typedef struct { 755 bdaddr_t bdaddr; /* remote address */ 756 uint8_t io_cap; /* IO capability */ 757 uint8_t oob_data; /* OOB data present */ 758 uint8_t auth_req; /* auth requirements */ 759 } __packed hci_io_capability_rep_cp; 760 761 typedef struct { 762 uint8_t status; /* 0x00 - success */ 763 bdaddr_t bdaddr; /* remote address */ 764 } __packed hci_io_capability_rep_rp; 765 766 #define HCI_OCF_USER_CONFIRM_REP 0x002c 767 #define HCI_CMD_USER_CONFIRM_REP 0x042c 768 typedef struct { 769 bdaddr_t bdaddr; /* remote address */ 770 } __packed hci_user_confirm_rep_cp; 771 772 typedef struct { 773 uint8_t status; /* 0x00 - success */ 774 bdaddr_t bdaddr; /* remote address */ 775 } __packed hci_user_confirm_rep_rp; 776 777 #define HCI_OCF_USER_CONFIRM_NEG_REP 0x002d 778 #define HCI_CMD_USER_CONFIRM_NEG_REP 0x042d 779 typedef struct { 780 bdaddr_t bdaddr; /* remote address */ 781 } __packed hci_user_confirm_neg_rep_cp; 782 783 typedef struct { 784 uint8_t status; /* 0x00 - success */ 785 bdaddr_t bdaddr; /* remote address */ 786 } __packed hci_user_confirm_neg_rep_rp; 787 788 #define HCI_OCF_USER_PASSKEY_REP 0x002e 789 #define HCI_CMD_USER_PASSKEY_REP 0x042e 790 typedef struct { 791 bdaddr_t bdaddr; /* remote address */ 792 uint32_t value; /* 000000 - 999999 */ 793 } __packed hci_user_passkey_rep_cp; 794 795 typedef struct { 796 uint8_t status; /* 0x00 - success */ 797 bdaddr_t bdaddr; /* remote address */ 798 } __packed hci_user_passkey_rep_rp; 799 800 #define HCI_OCF_USER_PASSKEY_NEG_REP 0x002f 801 #define HCI_CMD_USER_PASSKEY_NEG_REP 0x042f 802 typedef struct { 803 bdaddr_t bdaddr; /* remote address */ 804 } __packed hci_user_passkey_neg_rep_cp; 805 806 typedef struct { 807 uint8_t status; /* 0x00 - success */ 808 bdaddr_t bdaddr; /* remote address */ 809 } __packed hci_user_passkey_neg_rep_rp; 810 811 #define HCI_OCF_OOB_DATA_REP 0x0030 812 #define HCI_CMD_OOB_DATA_REP 0x0430 813 typedef struct { 814 bdaddr_t bdaddr; /* remote address */ 815 uint8_t c[16]; /* pairing hash */ 816 uint8_t r[16]; /* pairing randomizer */ 817 } __packed hci_user_oob_data_rep_cp; 818 819 typedef struct { 820 uint8_t status; /* 0x00 - success */ 821 bdaddr_t bdaddr; /* remote address */ 822 } __packed hci_user_oob_data_rep_rp; 823 824 #define HCI_OCF_OOB_DATA_NEG_REP 0x0033 825 #define HCI_CMD_OOB_DATA_NEG_REP 0x0433 826 typedef struct { 827 bdaddr_t bdaddr; /* remote address */ 828 } __packed hci_user_oob_data_neg_rep_cp; 829 830 typedef struct { 831 uint8_t status; /* 0x00 - success */ 832 bdaddr_t bdaddr; /* remote address */ 833 } __packed hci_user_oob_data_neg_rep_rp; 834 835 #define HCI_OCF_IO_CAPABILITY_NEG_REP 0x0034 836 #define HCI_CMD_IO_CAPABILITY_NEG_REP 0x0434 837 typedef struct { 838 bdaddr_t bdaddr; /* remote address */ 839 uint8_t reason; /* error code */ 840 } __packed hci_io_capability_neg_rep_cp; 841 842 typedef struct { 843 uint8_t status; /* 0x00 - success */ 844 bdaddr_t bdaddr; /* remote address */ 845 } __packed hci_io_capability_neg_rep_rp; 846 847 /************************************************************************** 848 ************************************************************************** 849 ** OGF 0x02 Link policy commands and return parameters 850 ************************************************************************** 851 **************************************************************************/ 852 853 #define HCI_OGF_LINK_POLICY 0x02 854 855 #define HCI_OCF_HOLD_MODE 0x0001 856 #define HCI_CMD_HOLD_MODE 0x0801 857 typedef struct { 858 uint16_t con_handle; /* connection handle */ 859 uint16_t max_interval; /* (max_interval * 0.625) msec */ 860 uint16_t min_interval; /* (max_interval * 0.625) msec */ 861 } __packed hci_hold_mode_cp; 862 /* No return parameter(s) */ 863 864 #define HCI_OCF_SNIFF_MODE 0x0003 865 #define HCI_CMD_SNIFF_MODE 0x0803 866 typedef struct { 867 uint16_t con_handle; /* connection handle */ 868 uint16_t max_interval; /* (max_interval * 0.625) msec */ 869 uint16_t min_interval; /* (max_interval * 0.625) msec */ 870 uint16_t attempt; /* (2 * attempt - 1) * 0.625 msec */ 871 uint16_t timeout; /* (2 * attempt - 1) * 0.625 msec */ 872 } __packed hci_sniff_mode_cp; 873 /* No return parameter(s) */ 874 875 #define HCI_OCF_EXIT_SNIFF_MODE 0x0004 876 #define HCI_CMD_EXIT_SNIFF_MODE 0x0804 877 typedef struct { 878 uint16_t con_handle; /* connection handle */ 879 } __packed hci_exit_sniff_mode_cp; 880 /* No return parameter(s) */ 881 882 #define HCI_OCF_PARK_MODE 0x0005 883 #define HCI_CMD_PARK_MODE 0x0805 884 typedef struct { 885 uint16_t con_handle; /* connection handle */ 886 uint16_t max_interval; /* (max_interval * 0.625) msec */ 887 uint16_t min_interval; /* (max_interval * 0.625) msec */ 888 } __packed hci_park_mode_cp; 889 /* No return parameter(s) */ 890 891 #define HCI_OCF_EXIT_PARK_MODE 0x0006 892 #define HCI_CMD_EXIT_PARK_MODE 0x0806 893 typedef struct { 894 uint16_t con_handle; /* connection handle */ 895 } __packed hci_exit_park_mode_cp; 896 /* No return parameter(s) */ 897 898 #define HCI_OCF_QOS_SETUP 0x0007 899 #define HCI_CMD_QOS_SETUP 0x0807 900 typedef struct { 901 uint16_t con_handle; /* connection handle */ 902 uint8_t flags; /* reserved for future use */ 903 uint8_t service_type; /* service type */ 904 uint32_t token_rate; /* bytes per second */ 905 uint32_t peak_bandwidth; /* bytes per second */ 906 uint32_t latency; /* microseconds */ 907 uint32_t delay_variation; /* microseconds */ 908 } __packed hci_qos_setup_cp; 909 /* No return parameter(s) */ 910 911 #define HCI_OCF_ROLE_DISCOVERY 0x0009 912 #define HCI_CMD_ROLE_DISCOVERY 0x0809 913 typedef struct { 914 uint16_t con_handle; /* connection handle */ 915 } __packed hci_role_discovery_cp; 916 917 typedef struct { 918 uint8_t status; /* 0x00 - success */ 919 uint16_t con_handle; /* connection handle */ 920 uint8_t role; /* role for the connection handle */ 921 } __packed hci_role_discovery_rp; 922 923 #define HCI_OCF_SWITCH_ROLE 0x000b 924 #define HCI_CMD_SWITCH_ROLE 0x080B 925 typedef struct { 926 bdaddr_t bdaddr; /* remote address */ 927 uint8_t role; /* new local role */ 928 } __packed hci_switch_role_cp; 929 /* No return parameter(s) */ 930 931 #define HCI_OCF_READ_LINK_POLICY_SETTINGS 0x000c 932 #define HCI_CMD_READ_LINK_POLICY_SETTINGS 0x080C 933 typedef struct { 934 uint16_t con_handle; /* connection handle */ 935 } __packed hci_read_link_policy_settings_cp; 936 937 typedef struct { 938 uint8_t status; /* 0x00 - success */ 939 uint16_t con_handle; /* connection handle */ 940 uint16_t settings; /* link policy settings */ 941 } __packed hci_read_link_policy_settings_rp; 942 943 #define HCI_OCF_WRITE_LINK_POLICY_SETTINGS 0x000d 944 #define HCI_CMD_WRITE_LINK_POLICY_SETTINGS 0x080D 945 typedef struct { 946 uint16_t con_handle; /* connection handle */ 947 uint16_t settings; /* link policy settings */ 948 } __packed hci_write_link_policy_settings_cp; 949 950 typedef struct { 951 uint8_t status; /* 0x00 - success */ 952 uint16_t con_handle; /* connection handle */ 953 } __packed hci_write_link_policy_settings_rp; 954 955 #define HCI_OCF_READ_DEFAULT_LINK_POLICY_SETTINGS 0x000e 956 #define HCI_CMD_READ_DEFAULT_LINK_POLICY_SETTINGS 0x080E 957 /* No command parameter(s) */ 958 typedef struct { 959 uint8_t status; /* 0x00 - success */ 960 uint16_t settings; /* link policy settings */ 961 } __packed hci_read_default_link_policy_settings_rp; 962 963 #define HCI_OCF_WRITE_DEFAULT_LINK_POLICY_SETTINGS 0x000f 964 #define HCI_CMD_WRITE_DEFAULT_LINK_POLICY_SETTINGS 0x080F 965 typedef struct { 966 uint16_t settings; /* link policy settings */ 967 } __packed hci_write_default_link_policy_settings_cp; 968 969 typedef hci_status_rp hci_write_default_link_policy_settings_rp; 970 971 #define HCI_OCF_FLOW_SPECIFICATION 0x0010 972 #define HCI_CMD_FLOW_SPECIFICATION 0x0810 973 typedef struct { 974 uint16_t con_handle; /* connection handle */ 975 uint8_t flags; /* reserved */ 976 uint8_t flow_direction; 977 uint8_t service_type; 978 uint32_t token_rate; 979 uint32_t token_bucket; 980 uint32_t peak_bandwidth; 981 uint32_t latency; 982 } __packed hci_flow_specification_cp; 983 /* No return parameter(s) */ 984 985 #define HCI_OCF_SNIFF_SUBRATING 0x0011 986 #define HCI_CMD_SNIFF_SUBRATING 0x0810 987 typedef struct { 988 uint16_t con_handle; /* connection handle */ 989 uint16_t max_latency; 990 uint16_t max_timeout; /* max remote timeout */ 991 uint16_t min_timeout; /* min local timeout */ 992 } __packed hci_sniff_subrating_cp; 993 994 typedef struct { 995 uint8_t status; /* 0x00 - success */ 996 uint16_t con_handle; /* connection handle */ 997 } __packed hci_sniff_subrating_rp; 998 999 /************************************************************************** 1000 ************************************************************************** 1001 ** OGF 0x03 Host Controller and Baseband commands and return parameters 1002 ************************************************************************** 1003 **************************************************************************/ 1004 1005 #define HCI_OGF_HC_BASEBAND 0x03 1006 1007 #define HCI_OCF_SET_EVENT_MASK 0x0001 1008 #define HCI_CMD_SET_EVENT_MASK 0x0C01 1009 typedef struct { 1010 uint8_t event_mask[HCI_EVENT_MASK_SIZE]; /* event_mask */ 1011 } __packed hci_set_event_mask_cp; 1012 1013 typedef hci_status_rp hci_set_event_mask_rp; 1014 1015 #define HCI_OCF_RESET 0x0003 1016 #define HCI_CMD_RESET 0x0C03 1017 /* No command parameter(s) */ 1018 typedef hci_status_rp hci_reset_rp; 1019 1020 #define HCI_OCF_SET_EVENT_FILTER 0x0005 1021 #define HCI_CMD_SET_EVENT_FILTER 0x0C05 1022 typedef struct { 1023 uint8_t filter_type; /* filter type */ 1024 uint8_t filter_condition_type; /* filter condition type */ 1025 /* variable size condition 1026 uint8_t condition[]; -- conditions */ 1027 } __packed hci_set_event_filter_cp; 1028 1029 typedef hci_status_rp hci_set_event_filter_rp; 1030 1031 #define HCI_OCF_FLUSH 0x0008 1032 #define HCI_CMD_FLUSH 0x0C08 1033 typedef struct { 1034 uint16_t con_handle; /* connection handle */ 1035 } __packed hci_flush_cp; 1036 1037 typedef struct { 1038 uint8_t status; /* 0x00 - success */ 1039 uint16_t con_handle; /* connection handle */ 1040 } __packed hci_flush_rp; 1041 1042 #define HCI_OCF_READ_PIN_TYPE 0x0009 1043 #define HCI_CMD_READ_PIN_TYPE 0x0C09 1044 /* No command parameter(s) */ 1045 typedef struct { 1046 uint8_t status; /* 0x00 - success */ 1047 uint8_t pin_type; /* PIN type */ 1048 } __packed hci_read_pin_type_rp; 1049 1050 #define HCI_OCF_WRITE_PIN_TYPE 0x000a 1051 #define HCI_CMD_WRITE_PIN_TYPE 0x0C0A 1052 typedef struct { 1053 uint8_t pin_type; /* PIN type */ 1054 } __packed hci_write_pin_type_cp; 1055 1056 typedef hci_status_rp hci_write_pin_type_rp; 1057 1058 #define HCI_OCF_CREATE_NEW_UNIT_KEY 0x000b 1059 #define HCI_CMD_CREATE_NEW_UNIT_KEY 0x0C0B 1060 /* No command parameter(s) */ 1061 typedef hci_status_rp hci_create_new_unit_key_rp; 1062 1063 #define HCI_OCF_READ_STORED_LINK_KEY 0x000d 1064 #define HCI_CMD_READ_STORED_LINK_KEY 0x0C0D 1065 typedef struct { 1066 bdaddr_t bdaddr; /* address */ 1067 uint8_t read_all; /* read all keys? 0x01 - yes */ 1068 } __packed hci_read_stored_link_key_cp; 1069 1070 typedef struct { 1071 uint8_t status; /* 0x00 - success */ 1072 uint16_t max_num_keys; /* Max. number of keys */ 1073 uint16_t num_keys_read; /* Number of stored keys */ 1074 } __packed hci_read_stored_link_key_rp; 1075 1076 #define HCI_OCF_WRITE_STORED_LINK_KEY 0x0011 1077 #define HCI_CMD_WRITE_STORED_LINK_KEY 0x0C11 1078 typedef struct { 1079 uint8_t num_keys_write; /* # of keys to write */ 1080 /* these are repeated "num_keys_write" times 1081 bdaddr_t bdaddr; --- remote address(es) 1082 uint8_t key[HCI_KEY_SIZE]; --- key(s) */ 1083 } __packed hci_write_stored_link_key_cp; 1084 1085 typedef struct { 1086 uint8_t status; /* 0x00 - success */ 1087 uint8_t num_keys_written; /* # of keys successfully written */ 1088 } __packed hci_write_stored_link_key_rp; 1089 1090 #define HCI_OCF_DELETE_STORED_LINK_KEY 0x0012 1091 #define HCI_CMD_DELETE_STORED_LINK_KEY 0x0C12 1092 typedef struct { 1093 bdaddr_t bdaddr; /* address */ 1094 uint8_t delete_all; /* delete all keys? 0x01 - yes */ 1095 } __packed hci_delete_stored_link_key_cp; 1096 1097 typedef struct { 1098 uint8_t status; /* 0x00 - success */ 1099 uint16_t num_keys_deleted; /* Number of keys deleted */ 1100 } __packed hci_delete_stored_link_key_rp; 1101 1102 #define HCI_OCF_WRITE_LOCAL_NAME 0x0013 1103 #define HCI_CMD_WRITE_LOCAL_NAME 0x0C13 1104 typedef struct { 1105 char name[HCI_UNIT_NAME_SIZE]; /* new unit name */ 1106 } __packed hci_write_local_name_cp; 1107 1108 typedef hci_status_rp hci_write_local_name_rp; 1109 1110 #define HCI_OCF_READ_LOCAL_NAME 0x0014 1111 #define HCI_CMD_READ_LOCAL_NAME 0x0C14 1112 /* No command parameter(s) */ 1113 typedef struct { 1114 uint8_t status; /* 0x00 - success */ 1115 char name[HCI_UNIT_NAME_SIZE]; /* unit name */ 1116 } __packed hci_read_local_name_rp; 1117 1118 #define HCI_OCF_READ_CON_ACCEPT_TIMEOUT 0x0015 1119 #define HCI_CMD_READ_CON_ACCEPT_TIMEOUT 0x0C15 1120 /* No command parameter(s) */ 1121 typedef struct { 1122 uint8_t status; /* 0x00 - success */ 1123 uint16_t timeout; /* (timeout * 0.625) msec */ 1124 } __packed hci_read_con_accept_timeout_rp; 1125 1126 #define HCI_OCF_WRITE_CON_ACCEPT_TIMEOUT 0x0016 1127 #define HCI_CMD_WRITE_CON_ACCEPT_TIMEOUT 0x0C16 1128 typedef struct { 1129 uint16_t timeout; /* (timeout * 0.625) msec */ 1130 } __packed hci_write_con_accept_timeout_cp; 1131 1132 typedef hci_status_rp hci_write_con_accept_timeout_rp; 1133 1134 #define HCI_OCF_READ_PAGE_TIMEOUT 0x0017 1135 #define HCI_CMD_READ_PAGE_TIMEOUT 0x0C17 1136 /* No command parameter(s) */ 1137 typedef struct { 1138 uint8_t status; /* 0x00 - success */ 1139 uint16_t timeout; /* (timeout * 0.625) msec */ 1140 } __packed hci_read_page_timeout_rp; 1141 1142 #define HCI_OCF_WRITE_PAGE_TIMEOUT 0x0018 1143 #define HCI_CMD_WRITE_PAGE_TIMEOUT 0x0C18 1144 typedef struct { 1145 uint16_t timeout; /* (timeout * 0.625) msec */ 1146 } __packed hci_write_page_timeout_cp; 1147 1148 typedef hci_status_rp hci_write_page_timeout_rp; 1149 1150 #define HCI_OCF_READ_SCAN_ENABLE 0x0019 1151 #define HCI_CMD_READ_SCAN_ENABLE 0x0C19 1152 /* No command parameter(s) */ 1153 typedef struct { 1154 uint8_t status; /* 0x00 - success */ 1155 uint8_t scan_enable; /* Scan enable */ 1156 } __packed hci_read_scan_enable_rp; 1157 1158 #define HCI_OCF_WRITE_SCAN_ENABLE 0x001a 1159 #define HCI_CMD_WRITE_SCAN_ENABLE 0x0C1A 1160 typedef struct { 1161 uint8_t scan_enable; /* Scan enable */ 1162 } __packed hci_write_scan_enable_cp; 1163 1164 typedef hci_status_rp hci_write_scan_enable_rp; 1165 1166 #define HCI_OCF_READ_PAGE_SCAN_ACTIVITY 0x001b 1167 #define HCI_CMD_READ_PAGE_SCAN_ACTIVITY 0x0C1B 1168 /* No command parameter(s) */ 1169 typedef struct { 1170 uint8_t status; /* 0x00 - success */ 1171 uint16_t page_scan_interval; /* interval * 0.625 msec */ 1172 uint16_t page_scan_window; /* window * 0.625 msec */ 1173 } __packed hci_read_page_scan_activity_rp; 1174 1175 #define HCI_OCF_WRITE_PAGE_SCAN_ACTIVITY 0x001c 1176 #define HCI_CMD_WRITE_PAGE_SCAN_ACTIVITY 0x0C1C 1177 typedef struct { 1178 uint16_t page_scan_interval; /* interval * 0.625 msec */ 1179 uint16_t page_scan_window; /* window * 0.625 msec */ 1180 } __packed hci_write_page_scan_activity_cp; 1181 1182 typedef hci_status_rp hci_write_page_scan_activity_rp; 1183 1184 #define HCI_OCF_READ_INQUIRY_SCAN_ACTIVITY 0x001d 1185 #define HCI_CMD_READ_INQUIRY_SCAN_ACTIVITY 0x0C1D 1186 /* No command parameter(s) */ 1187 typedef struct { 1188 uint8_t status; /* 0x00 - success */ 1189 uint16_t inquiry_scan_interval; /* interval * 0.625 msec */ 1190 uint16_t inquiry_scan_window; /* window * 0.625 msec */ 1191 } __packed hci_read_inquiry_scan_activity_rp; 1192 1193 #define HCI_OCF_WRITE_INQUIRY_SCAN_ACTIVITY 0x001e 1194 #define HCI_CMD_WRITE_INQUIRY_SCAN_ACTIVITY 0x0C1E 1195 typedef struct { 1196 uint16_t inquiry_scan_interval; /* interval * 0.625 msec */ 1197 uint16_t inquiry_scan_window; /* window * 0.625 msec */ 1198 } __packed hci_write_inquiry_scan_activity_cp; 1199 1200 typedef hci_status_rp hci_write_inquiry_scan_activity_rp; 1201 1202 #define HCI_OCF_READ_AUTH_ENABLE 0x001f 1203 #define HCI_CMD_READ_AUTH_ENABLE 0x0C1F 1204 /* No command parameter(s) */ 1205 typedef struct { 1206 uint8_t status; /* 0x00 - success */ 1207 uint8_t auth_enable; /* 0x01 - enabled */ 1208 } __packed hci_read_auth_enable_rp; 1209 1210 #define HCI_OCF_WRITE_AUTH_ENABLE 0x0020 1211 #define HCI_CMD_WRITE_AUTH_ENABLE 0x0C20 1212 typedef struct { 1213 uint8_t auth_enable; /* 0x01 - enabled */ 1214 } __packed hci_write_auth_enable_cp; 1215 1216 typedef hci_status_rp hci_write_auth_enable_rp; 1217 1218 /* Read Encryption Mode is deprecated */ 1219 #define HCI_OCF_READ_ENCRYPTION_MODE 0x0021 1220 #define HCI_CMD_READ_ENCRYPTION_MODE 0x0C21 1221 /* No command parameter(s) */ 1222 typedef struct { 1223 uint8_t status; /* 0x00 - success */ 1224 uint8_t encryption_mode; /* encryption mode */ 1225 } __packed hci_read_encryption_mode_rp; 1226 1227 /* Write Encryption Mode is deprecated */ 1228 #define HCI_OCF_WRITE_ENCRYPTION_MODE 0x0022 1229 #define HCI_CMD_WRITE_ENCRYPTION_MODE 0x0C22 1230 typedef struct { 1231 uint8_t encryption_mode; /* encryption mode */ 1232 } __packed hci_write_encryption_mode_cp; 1233 1234 typedef hci_status_rp hci_write_encryption_mode_rp; 1235 1236 #define HCI_OCF_READ_UNIT_CLASS 0x0023 1237 #define HCI_CMD_READ_UNIT_CLASS 0x0C23 1238 /* No command parameter(s) */ 1239 typedef struct { 1240 uint8_t status; /* 0x00 - success */ 1241 uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ 1242 } __packed hci_read_unit_class_rp; 1243 1244 #define HCI_OCF_WRITE_UNIT_CLASS 0x0024 1245 #define HCI_CMD_WRITE_UNIT_CLASS 0x0C24 1246 typedef struct { 1247 uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ 1248 } __packed hci_write_unit_class_cp; 1249 1250 typedef hci_status_rp hci_write_unit_class_rp; 1251 1252 #define HCI_OCF_READ_VOICE_SETTING 0x0025 1253 #define HCI_CMD_READ_VOICE_SETTING 0x0C25 1254 /* No command parameter(s) */ 1255 typedef struct { 1256 uint8_t status; /* 0x00 - success */ 1257 uint16_t settings; /* voice settings */ 1258 } __packed hci_read_voice_setting_rp; 1259 1260 #define HCI_OCF_WRITE_VOICE_SETTING 0x0026 1261 #define HCI_CMD_WRITE_VOICE_SETTING 0x0C26 1262 typedef struct { 1263 uint16_t settings; /* voice settings */ 1264 } __packed hci_write_voice_setting_cp; 1265 1266 typedef hci_status_rp hci_write_voice_setting_rp; 1267 1268 #define HCI_OCF_READ_AUTO_FLUSH_TIMEOUT 0x0027 1269 #define HCI_CMD_READ_AUTO_FLUSH_TIMEOUT 0x0C27 1270 typedef struct { 1271 uint16_t con_handle; /* connection handle */ 1272 } __packed hci_read_auto_flush_timeout_cp; 1273 1274 typedef struct { 1275 uint8_t status; /* 0x00 - success */ 1276 uint16_t con_handle; /* connection handle */ 1277 uint16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */ 1278 } __packed hci_read_auto_flush_timeout_rp; 1279 1280 #define HCI_OCF_WRITE_AUTO_FLUSH_TIMEOUT 0x0028 1281 #define HCI_CMD_WRITE_AUTO_FLUSH_TIMEOUT 0x0C28 1282 typedef struct { 1283 uint16_t con_handle; /* connection handle */ 1284 uint16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */ 1285 } __packed hci_write_auto_flush_timeout_cp; 1286 1287 typedef struct { 1288 uint8_t status; /* 0x00 - success */ 1289 uint16_t con_handle; /* connection handle */ 1290 } __packed hci_write_auto_flush_timeout_rp; 1291 1292 #define HCI_OCF_READ_NUM_BROADCAST_RETRANS 0x0029 1293 #define HCI_CMD_READ_NUM_BROADCAST_RETRANS 0x0C29 1294 /* No command parameter(s) */ 1295 typedef struct { 1296 uint8_t status; /* 0x00 - success */ 1297 uint8_t counter; /* number of broadcast retransmissions */ 1298 } __packed hci_read_num_broadcast_retrans_rp; 1299 1300 #define HCI_OCF_WRITE_NUM_BROADCAST_RETRANS 0x002a 1301 #define HCI_CMD_WRITE_NUM_BROADCAST_RETRANS 0x0C2A 1302 typedef struct { 1303 uint8_t counter; /* number of broadcast retransmissions */ 1304 } __packed hci_write_num_broadcast_retrans_cp; 1305 1306 typedef hci_status_rp hci_write_num_broadcast_retrans_rp; 1307 1308 #define HCI_OCF_READ_HOLD_MODE_ACTIVITY 0x002b 1309 #define HCI_CMD_READ_HOLD_MODE_ACTIVITY 0x0C2B 1310 /* No command parameter(s) */ 1311 typedef struct { 1312 uint8_t status; /* 0x00 - success */ 1313 uint8_t hold_mode_activity; /* Hold mode activities */ 1314 } __packed hci_read_hold_mode_activity_rp; 1315 1316 #define HCI_OCF_WRITE_HOLD_MODE_ACTIVITY 0x002c 1317 #define HCI_CMD_WRITE_HOLD_MODE_ACTIVITY 0x0C2C 1318 typedef struct { 1319 uint8_t hold_mode_activity; /* Hold mode activities */ 1320 } __packed hci_write_hold_mode_activity_cp; 1321 1322 typedef hci_status_rp hci_write_hold_mode_activity_rp; 1323 1324 #define HCI_OCF_READ_XMIT_LEVEL 0x002d 1325 #define HCI_CMD_READ_XMIT_LEVEL 0x0C2D 1326 typedef struct { 1327 uint16_t con_handle; /* connection handle */ 1328 uint8_t type; /* Xmit level type */ 1329 } __packed hci_read_xmit_level_cp; 1330 1331 typedef struct { 1332 uint8_t status; /* 0x00 - success */ 1333 uint16_t con_handle; /* connection handle */ 1334 char level; /* -30 <= level <= 30 dBm */ 1335 } __packed hci_read_xmit_level_rp; 1336 1337 #define HCI_OCF_READ_SCO_FLOW_CONTROL 0x002e 1338 #define HCI_CMD_READ_SCO_FLOW_CONTROL 0x0C2E 1339 /* No command parameter(s) */ 1340 typedef struct { 1341 uint8_t status; /* 0x00 - success */ 1342 uint8_t flow_control; /* 0x00 - disabled */ 1343 } __packed hci_read_sco_flow_control_rp; 1344 1345 #define HCI_OCF_WRITE_SCO_FLOW_CONTROL 0x002f 1346 #define HCI_CMD_WRITE_SCO_FLOW_CONTROL 0x0C2F 1347 typedef struct { 1348 uint8_t flow_control; /* 0x00 - disabled */ 1349 } __packed hci_write_sco_flow_control_cp; 1350 1351 typedef hci_status_rp hci_write_sco_flow_control_rp; 1352 1353 #define HCI_OCF_HC2H_FLOW_CONTROL 0x0031 1354 #define HCI_CMD_HC2H_FLOW_CONTROL 0x0C31 1355 typedef struct { 1356 uint8_t hc2h_flow; /* Host Controller to Host flow control */ 1357 } __packed hci_hc2h_flow_control_cp; 1358 1359 typedef hci_status_rp hci_h2hc_flow_control_rp; 1360 1361 #define HCI_OCF_HOST_BUFFER_SIZE 0x0033 1362 #define HCI_CMD_HOST_BUFFER_SIZE 0x0C33 1363 typedef struct { 1364 uint16_t max_acl_size; /* Max. size of ACL packet (bytes) */ 1365 uint8_t max_sco_size; /* Max. size of SCO packet (bytes) */ 1366 uint16_t num_acl_pkts; /* Max. number of ACL packets */ 1367 uint16_t num_sco_pkts; /* Max. number of SCO packets */ 1368 } __packed hci_host_buffer_size_cp; 1369 1370 typedef hci_status_rp hci_host_buffer_size_rp; 1371 1372 #define HCI_OCF_HOST_NUM_COMPL_PKTS 0x0035 1373 #define HCI_CMD_HOST_NUM_COMPL_PKTS 0x0C35 1374 typedef struct { 1375 uint8_t nu_con_handles; /* # of connection handles */ 1376 /* these are repeated "num_con_handles" times 1377 uint16_t con_handle; --- connection handle(s) 1378 uint16_t compl_pkts; --- # of completed packets */ 1379 } __packed hci_host_num_compl_pkts_cp; 1380 /* No return parameter(s) */ 1381 1382 #define HCI_OCF_READ_LINK_SUPERVISION_TIMEOUT 0x0036 1383 #define HCI_CMD_READ_LINK_SUPERVISION_TIMEOUT 0x0C36 1384 typedef struct { 1385 uint16_t con_handle; /* connection handle */ 1386 } __packed hci_read_link_supervision_timeout_cp; 1387 1388 typedef struct { 1389 uint8_t status; /* 0x00 - success */ 1390 uint16_t con_handle; /* connection handle */ 1391 uint16_t timeout; /* Link supervision timeout * 0.625 msec */ 1392 } __packed hci_read_link_supervision_timeout_rp; 1393 1394 #define HCI_OCF_WRITE_LINK_SUPERVISION_TIMEOUT 0x0037 1395 #define HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT 0x0C37 1396 typedef struct { 1397 uint16_t con_handle; /* connection handle */ 1398 uint16_t timeout; /* Link supervision timeout * 0.625 msec */ 1399 } __packed hci_write_link_supervision_timeout_cp; 1400 1401 typedef struct { 1402 uint8_t status; /* 0x00 - success */ 1403 uint16_t con_handle; /* connection handle */ 1404 } __packed hci_write_link_supervision_timeout_rp; 1405 1406 #define HCI_OCF_READ_NUM_SUPPORTED_IAC 0x0038 1407 #define HCI_CMD_READ_NUM_SUPPORTED_IAC 0x0C38 1408 /* No command parameter(s) */ 1409 typedef struct { 1410 uint8_t status; /* 0x00 - success */ 1411 uint8_t num_iac; /* # of supported IAC during scan */ 1412 } __packed hci_read_num_supported_iac_rp; 1413 1414 #define HCI_OCF_READ_IAC_LAP 0x0039 1415 #define HCI_CMD_READ_IAC_LAP 0x0C39 1416 /* No command parameter(s) */ 1417 typedef struct { 1418 uint8_t status; /* 0x00 - success */ 1419 uint8_t num_iac; /* # of IAC */ 1420 /* these are repeated "num_iac" times 1421 uint8_t laps[HCI_LAP_SIZE]; --- LAPs */ 1422 } __packed hci_read_iac_lap_rp; 1423 1424 #define HCI_OCF_WRITE_IAC_LAP 0x003a 1425 #define HCI_CMD_WRITE_IAC_LAP 0x0C3A 1426 typedef struct { 1427 uint8_t num_iac; /* # of IAC */ 1428 /* these are repeated "num_iac" times 1429 uint8_t laps[HCI_LAP_SIZE]; --- LAPs */ 1430 } __packed hci_write_iac_lap_cp; 1431 1432 typedef hci_status_rp hci_write_iac_lap_rp; 1433 1434 /* Read Page Scan Period Mode is deprecated */ 1435 #define HCI_OCF_READ_PAGE_SCAN_PERIOD 0x003b 1436 #define HCI_CMD_READ_PAGE_SCAN_PERIOD 0x0C3B 1437 /* No command parameter(s) */ 1438 typedef struct { 1439 uint8_t status; /* 0x00 - success */ 1440 uint8_t page_scan_period_mode; /* Page scan period mode */ 1441 } __packed hci_read_page_scan_period_rp; 1442 1443 /* Write Page Scan Period Mode is deprecated */ 1444 #define HCI_OCF_WRITE_PAGE_SCAN_PERIOD 0x003c 1445 #define HCI_CMD_WRITE_PAGE_SCAN_PERIOD 0x0C3C 1446 typedef struct { 1447 uint8_t page_scan_period_mode; /* Page scan period mode */ 1448 } __packed hci_write_page_scan_period_cp; 1449 1450 typedef hci_status_rp hci_write_page_scan_period_rp; 1451 1452 /* Read Page Scan Mode is deprecated */ 1453 #define HCI_OCF_READ_PAGE_SCAN 0x003d 1454 #define HCI_CMD_READ_PAGE_SCAN 0x0C3D 1455 /* No command parameter(s) */ 1456 typedef struct { 1457 uint8_t status; /* 0x00 - success */ 1458 uint8_t page_scan_mode; /* Page scan mode */ 1459 } __packed hci_read_page_scan_rp; 1460 1461 /* Write Page Scan Mode is deprecated */ 1462 #define HCI_OCF_WRITE_PAGE_SCAN 0x003e 1463 #define HCI_CMD_WRITE_PAGE_SCAN 0x0C3E 1464 typedef struct { 1465 uint8_t page_scan_mode; /* Page scan mode */ 1466 } __packed hci_write_page_scan_cp; 1467 1468 typedef hci_status_rp hci_write_page_scan_rp; 1469 1470 #define HCI_OCF_SET_AFH_CLASSIFICATION 0x003f 1471 #define HCI_CMD_SET_AFH_CLASSIFICATION 0x0C3F 1472 typedef struct { 1473 uint8_t classification[10]; 1474 } __packed hci_set_afh_classification_cp; 1475 1476 typedef hci_status_rp hci_set_afh_classification_rp; 1477 1478 #define HCI_OCF_READ_INQUIRY_SCAN_TYPE 0x0042 1479 #define HCI_CMD_READ_INQUIRY_SCAN_TYPE 0x0C42 1480 /* No command parameter(s) */ 1481 1482 typedef struct { 1483 uint8_t status; /* 0x00 - success */ 1484 uint8_t type; /* inquiry scan type */ 1485 } __packed hci_read_inquiry_scan_type_rp; 1486 1487 #define HCI_OCF_WRITE_INQUIRY_SCAN_TYPE 0x0043 1488 #define HCI_CMD_WRITE_INQUIRY_SCAN_TYPE 0x0C43 1489 typedef struct { 1490 uint8_t type; /* inquiry scan type */ 1491 } __packed hci_write_inquiry_scan_type_cp; 1492 1493 typedef hci_status_rp hci_write_inquiry_scan_type_rp; 1494 1495 #define HCI_OCF_READ_INQUIRY_MODE 0x0044 1496 #define HCI_CMD_READ_INQUIRY_MODE 0x0C44 1497 /* No command parameter(s) */ 1498 1499 typedef struct { 1500 uint8_t status; /* 0x00 - success */ 1501 uint8_t mode; /* inquiry mode */ 1502 } __packed hci_read_inquiry_mode_rp; 1503 1504 #define HCI_OCF_WRITE_INQUIRY_MODE 0x0045 1505 #define HCI_CMD_WRITE_INQUIRY_MODE 0x0C45 1506 typedef struct { 1507 uint8_t mode; /* inquiry mode */ 1508 } __packed hci_write_inquiry_mode_cp; 1509 1510 typedef hci_status_rp hci_write_inquiry_mode_rp; 1511 1512 #define HCI_OCF_READ_PAGE_SCAN_TYPE 0x0046 1513 #define HCI_CMD_READ_PAGE_SCAN_TYPE 0x0C46 1514 /* No command parameter(s) */ 1515 1516 typedef struct { 1517 uint8_t status; /* 0x00 - success */ 1518 uint8_t type; /* page scan type */ 1519 } __packed hci_read_page_scan_type_rp; 1520 1521 #define HCI_OCF_WRITE_PAGE_SCAN_TYPE 0x0047 1522 #define HCI_CMD_WRITE_PAGE_SCAN_TYPE 0x0C47 1523 typedef struct { 1524 uint8_t type; /* page scan type */ 1525 } __packed hci_write_page_scan_type_cp; 1526 1527 typedef hci_status_rp hci_write_page_scan_type_rp; 1528 1529 #define HCI_OCF_READ_AFH_ASSESSMENT 0x0048 1530 #define HCI_CMD_READ_AFH_ASSESSMENT 0x0C48 1531 /* No command parameter(s) */ 1532 1533 typedef struct { 1534 uint8_t status; /* 0x00 - success */ 1535 uint8_t mode; /* assessment mode */ 1536 } __packed hci_read_afh_assessment_rp; 1537 1538 #define HCI_OCF_WRITE_AFH_ASSESSMENT 0x0049 1539 #define HCI_CMD_WRITE_AFH_ASSESSMENT 0x0C49 1540 typedef struct { 1541 uint8_t mode; /* assessment mode */ 1542 } __packed hci_write_afh_assessment_cp; 1543 1544 typedef hci_status_rp hci_write_afh_assessment_rp; 1545 1546 #define HCI_OCF_READ_EXTENDED_INQUIRY_RSP 0x0051 1547 #define HCI_CMD_READ_EXTENDED_INQUIRY_RSP 0x0C51 1548 /* No command parameter(s) */ 1549 1550 typedef struct { 1551 uint8_t status; /* 0x00 - success */ 1552 uint8_t fec_required; 1553 uint8_t response[240]; 1554 } __packed hci_read_extended_inquiry_rsp_rp; 1555 1556 #define HCI_OCF_WRITE_EXTENDED_INQUIRY_RSP 0x0052 1557 #define HCI_CMD_WRITE_EXTENDED_INQUIRY_RSP 0x0C52 1558 typedef struct { 1559 uint8_t fec_required; 1560 uint8_t response[240]; 1561 } __packed hci_write_extended_inquiry_rsp_cp; 1562 1563 typedef hci_status_rp hci_write_extended_inquiry_rsp_rp; 1564 1565 #define HCI_OCF_REFRESH_ENCRYPTION_KEY 0x0053 1566 #define HCI_CMD_REFRESH_ENCRYPTION_KEY 0x0C53 1567 typedef struct { 1568 uint16_t con_handle; /* connection handle */ 1569 } __packed hci_refresh_encryption_key_cp; 1570 1571 typedef hci_status_rp hci_refresh_encryption_key_rp; 1572 1573 #define HCI_OCF_READ_SIMPLE_PAIRING_MODE 0x0055 1574 #define HCI_CMD_READ_SIMPLE_PAIRING_MODE 0x0C55 1575 /* No command parameter(s) */ 1576 1577 typedef struct { 1578 uint8_t status; /* 0x00 - success */ 1579 uint8_t mode; /* simple pairing mode */ 1580 } __packed hci_read_simple_pairing_mode_rp; 1581 1582 #define HCI_OCF_WRITE_SIMPLE_PAIRING_MODE 0x0056 1583 #define HCI_CMD_WRITE_SIMPLE_PAIRING_MODE 0x0C56 1584 typedef struct { 1585 uint8_t mode; /* simple pairing mode */ 1586 } __packed hci_write_simple_pairing_mode_cp; 1587 1588 typedef hci_status_rp hci_write_simple_pairing_mode_rp; 1589 1590 #define HCI_OCF_READ_LOCAL_OOB_DATA 0x0057 1591 #define HCI_CMD_READ_LOCAL_OOB_DATA 0x0C57 1592 /* No command parameter(s) */ 1593 1594 typedef struct { 1595 uint8_t status; /* 0x00 - success */ 1596 uint8_t c[16]; /* pairing hash */ 1597 uint8_t r[16]; /* pairing randomizer */ 1598 } __packed hci_read_local_oob_data_rp; 1599 1600 #define HCI_OCF_READ_INQUIRY_RSP_XMIT_POWER 0x0058 1601 #define HCI_CMD_READ_INQUIRY_RSP_XMIT_POWER 0x0C58 1602 /* No command parameter(s) */ 1603 1604 typedef struct { 1605 uint8_t status; /* 0x00 - success */ 1606 int8_t power; /* TX power */ 1607 } __packed hci_read_inquiry_rsp_xmit_power_rp; 1608 1609 #define HCI_OCF_WRITE_INQUIRY_RSP_XMIT_POWER 0x0059 1610 #define HCI_CMD_WRITE_INQUIRY_RSP_XMIT_POWER 0x0C59 1611 typedef struct { 1612 int8_t power; /* TX power */ 1613 } __packed hci_write_inquiry_rsp_xmit_power_cp; 1614 1615 typedef hci_status_rp hci_write_inquiry_rsp_xmit_power_rp; 1616 1617 #define HCI_OCF_READ_DEFAULT_ERRDATA_REPORTING 0x005A 1618 #define HCI_CMD_READ_DEFAULT_ERRDATA_REPORTING 0x0C5A 1619 /* No command parameter(s) */ 1620 1621 typedef struct { 1622 uint8_t status; /* 0x00 - success */ 1623 uint8_t reporting; /* erroneous data reporting */ 1624 } __packed hci_read_default_errdata_reporting_rp; 1625 1626 #define HCI_OCF_WRITE_DEFAULT_ERRDATA_REPORTING 0x005B 1627 #define HCI_CMD_WRITE_DEFAULT_ERRDATA_REPORTING 0x0C5B 1628 typedef struct { 1629 uint8_t reporting; /* erroneous data reporting */ 1630 } __packed hci_write_default_errdata_reporting_cp; 1631 1632 typedef hci_status_rp hci_write_default_errdata_reporting_rp; 1633 1634 #define HCI_OCF_ENHANCED_FLUSH 0x005F 1635 #define HCI_CMD_ENHANCED_FLUSH 0x0C5F 1636 typedef struct { 1637 uint16_t con_handle; /* connection handle */ 1638 uint8_t packet_type; 1639 } __packed hci_enhanced_flush_cp; 1640 1641 /* No response parameter(s) */ 1642 1643 #define HCI_OCF_SEND_KEYPRESS_NOTIFICATION 0x0060 1644 #define HCI_CMD_SEND_KEYPRESS_NOTIFICATION 0x0C60 1645 typedef struct { 1646 bdaddr_t bdaddr; /* remote address */ 1647 uint8_t type; /* notification type */ 1648 } __packed hci_send_keypress_notification_cp; 1649 1650 typedef struct { 1651 uint8_t status; /* 0x00 - success */ 1652 bdaddr_t bdaddr; /* remote address */ 1653 } __packed hci_send_keypress_notification_rp; 1654 1655 /************************************************************************** 1656 ************************************************************************** 1657 ** OGF 0x04 Informational commands and return parameters 1658 ************************************************************************** 1659 **************************************************************************/ 1660 1661 #define HCI_OGF_INFO 0x04 1662 1663 #define HCI_OCF_READ_LOCAL_VER 0x0001 1664 #define HCI_CMD_READ_LOCAL_VER 0x1001 1665 /* No command parameter(s) */ 1666 typedef struct { 1667 uint8_t status; /* 0x00 - success */ 1668 uint8_t hci_version; /* HCI version */ 1669 uint16_t hci_revision; /* HCI revision */ 1670 uint8_t lmp_version; /* LMP version */ 1671 uint16_t manufacturer; /* Hardware manufacturer name */ 1672 uint16_t lmp_subversion; /* LMP sub-version */ 1673 } __packed hci_read_local_ver_rp; 1674 1675 #define HCI_OCF_READ_LOCAL_COMMANDS 0x0002 1676 #define HCI_CMD_READ_LOCAL_COMMANDS 0x1002 1677 /* No command parameter(s) */ 1678 typedef struct { 1679 uint8_t status; /* 0x00 - success */ 1680 uint8_t commands[HCI_COMMANDS_SIZE]; /* opcode bitmask */ 1681 } __packed hci_read_local_commands_rp; 1682 1683 #define HCI_OCF_READ_LOCAL_FEATURES 0x0003 1684 #define HCI_CMD_READ_LOCAL_FEATURES 0x1003 1685 /* No command parameter(s) */ 1686 typedef struct { 1687 uint8_t status; /* 0x00 - success */ 1688 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ 1689 } __packed hci_read_local_features_rp; 1690 1691 #define HCI_OCF_READ_LOCAL_EXTENDED_FEATURES 0x0004 1692 #define HCI_CMD_READ_LOCAL_EXTENDED_FEATURES 0x1004 1693 typedef struct { 1694 uint8_t page; /* page number */ 1695 } __packed hci_read_local_extended_features_cp; 1696 1697 typedef struct { 1698 uint8_t status; /* 0x00 - success */ 1699 uint8_t page; /* page number */ 1700 uint8_t max_page; /* maximum page number */ 1701 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features */ 1702 } __packed hci_read_local_extended_features_rp; 1703 1704 #define HCI_OCF_READ_BUFFER_SIZE 0x0005 1705 #define HCI_CMD_READ_BUFFER_SIZE 0x1005 1706 /* No command parameter(s) */ 1707 typedef struct { 1708 uint8_t status; /* 0x00 - success */ 1709 uint16_t max_acl_size; /* Max. size of ACL packet (bytes) */ 1710 uint8_t max_sco_size; /* Max. size of SCO packet (bytes) */ 1711 uint16_t num_acl_pkts; /* Max. number of ACL packets */ 1712 uint16_t num_sco_pkts; /* Max. number of SCO packets */ 1713 } __packed hci_read_buffer_size_rp; 1714 1715 /* Read Country Code is deprecated */ 1716 #define HCI_OCF_READ_COUNTRY_CODE 0x0007 1717 #define HCI_CMD_READ_COUNTRY_CODE 0x1007 1718 /* No command parameter(s) */ 1719 typedef struct { 1720 uint8_t status; /* 0x00 - success */ 1721 uint8_t country_code; /* 0x00 - NAM, EUR, JP; 0x01 - France */ 1722 } __packed hci_read_country_code_rp; 1723 1724 #define HCI_OCF_READ_BDADDR 0x0009 1725 #define HCI_CMD_READ_BDADDR 0x1009 1726 /* No command parameter(s) */ 1727 typedef struct { 1728 uint8_t status; /* 0x00 - success */ 1729 bdaddr_t bdaddr; /* unit address */ 1730 } __packed hci_read_bdaddr_rp; 1731 1732 /************************************************************************** 1733 ************************************************************************** 1734 ** OGF 0x05 Status commands and return parameters 1735 ************************************************************************** 1736 **************************************************************************/ 1737 1738 #define HCI_OGF_STATUS 0x05 1739 1740 #define HCI_OCF_READ_FAILED_CONTACT_CNTR 0x0001 1741 #define HCI_CMD_READ_FAILED_CONTACT_CNTR 0x1401 1742 typedef struct { 1743 uint16_t con_handle; /* connection handle */ 1744 } __packed hci_read_failed_contact_cntr_cp; 1745 1746 typedef struct { 1747 uint8_t status; /* 0x00 - success */ 1748 uint16_t con_handle; /* connection handle */ 1749 uint16_t counter; /* number of consecutive failed contacts */ 1750 } __packed hci_read_failed_contact_cntr_rp; 1751 1752 #define HCI_OCF_RESET_FAILED_CONTACT_CNTR 0x0002 1753 #define HCI_CMD_RESET_FAILED_CONTACT_CNTR 0x1402 1754 typedef struct { 1755 uint16_t con_handle; /* connection handle */ 1756 } __packed hci_reset_failed_contact_cntr_cp; 1757 1758 typedef struct { 1759 uint8_t status; /* 0x00 - success */ 1760 uint16_t con_handle; /* connection handle */ 1761 } __packed hci_reset_failed_contact_cntr_rp; 1762 1763 #define HCI_OCF_READ_LINK_QUALITY 0x0003 1764 #define HCI_CMD_READ_LINK_QUALITY 0x1403 1765 typedef struct { 1766 uint16_t con_handle; /* connection handle */ 1767 } __packed hci_read_link_quality_cp; 1768 1769 typedef struct { 1770 uint8_t status; /* 0x00 - success */ 1771 uint16_t con_handle; /* connection handle */ 1772 uint8_t quality; /* higher value means better quality */ 1773 } __packed hci_read_link_quality_rp; 1774 1775 #define HCI_OCF_READ_RSSI 0x0005 1776 #define HCI_CMD_READ_RSSI 0x1405 1777 typedef struct { 1778 uint16_t con_handle; /* connection handle */ 1779 } __packed hci_read_rssi_cp; 1780 1781 typedef struct { 1782 uint8_t status; /* 0x00 - success */ 1783 uint16_t con_handle; /* connection handle */ 1784 char rssi; /* -127 <= rssi <= 127 dB */ 1785 } __packed hci_read_rssi_rp; 1786 1787 #define HCI_OCF_READ_AFH_CHANNEL_MAP 0x0006 1788 #define HCI_CMD_READ_AFH_CHANNEL_MAP 0x1406 1789 typedef struct { 1790 uint16_t con_handle; /* connection handle */ 1791 } __packed hci_read_afh_channel_map_cp; 1792 1793 typedef struct { 1794 uint8_t status; /* 0x00 - success */ 1795 uint16_t con_handle; /* connection handle */ 1796 uint8_t mode; /* AFH mode */ 1797 uint8_t map[10]; /* AFH Channel Map */ 1798 } __packed hci_read_afh_channel_map_rp; 1799 1800 #define HCI_OCF_READ_CLOCK 0x0007 1801 #define HCI_CMD_READ_CLOCK 0x1407 1802 typedef struct { 1803 uint16_t con_handle; /* connection handle */ 1804 uint8_t clock; /* which clock */ 1805 } __packed hci_read_clock_cp; 1806 1807 typedef struct { 1808 uint8_t status; /* 0x00 - success */ 1809 uint16_t con_handle; /* connection handle */ 1810 uint32_t clock; /* clock value */ 1811 uint16_t accuracy; /* clock accuracy */ 1812 } __packed hci_read_clock_rp; 1813 1814 1815 /************************************************************************** 1816 ************************************************************************** 1817 ** OGF 0x06 Testing commands and return parameters 1818 ************************************************************************** 1819 **************************************************************************/ 1820 1821 #define HCI_OGF_TESTING 0x06 1822 1823 #define HCI_OCF_READ_LOOPBACK_MODE 0x0001 1824 #define HCI_CMD_READ_LOOPBACK_MODE 0x1801 1825 /* No command parameter(s) */ 1826 typedef struct { 1827 uint8_t status; /* 0x00 - success */ 1828 uint8_t lbmode; /* loopback mode */ 1829 } __packed hci_read_loopback_mode_rp; 1830 1831 #define HCI_OCF_WRITE_LOOPBACK_MODE 0x0002 1832 #define HCI_CMD_WRITE_LOOPBACK_MODE 0x1802 1833 typedef struct { 1834 uint8_t lbmode; /* loopback mode */ 1835 } __packed hci_write_loopback_mode_cp; 1836 1837 typedef hci_status_rp hci_write_loopback_mode_rp; 1838 1839 #define HCI_OCF_ENABLE_UNIT_UNDER_TEST 0x0003 1840 #define HCI_CMD_ENABLE_UNIT_UNDER_TEST 0x1803 1841 /* No command parameter(s) */ 1842 typedef hci_status_rp hci_enable_unit_under_test_rp; 1843 1844 #define HCI_OCF_WRITE_SIMPLE_PAIRING_DEBUG_MODE 0x0004 1845 #define HCI_CMD_WRITE_SIMPLE_PAIRING_DEBUG_MODE 0x1804 1846 typedef struct { 1847 uint8_t mode; /* simple pairing debug mode */ 1848 } __packed hci_write_simple_pairing_debug_mode_cp; 1849 1850 typedef hci_status_rp hci_write_simple_pairing_debug_mode_rp; 1851 1852 /************************************************************************** 1853 ************************************************************************** 1854 ** OGF 0x3e Bluetooth Logo Testing 1855 ** OGF 0x3f Vendor Specific 1856 ************************************************************************** 1857 **************************************************************************/ 1858 1859 #define HCI_OGF_BT_LOGO 0x3e 1860 #define HCI_OGF_VENDOR 0x3f 1861 1862 /* Ericsson specific FC */ 1863 #define HCI_CMD_ERICSSON_WRITE_PCM_SETTINGS 0xFC07 1864 #define HCI_CMD_ERICSSON_SET_UART_BAUD_RATE 0xFC09 1865 #define HCI_CMD_ERICSSON_SET_SCO_DATA_PATH 0xFC1D 1866 1867 /* Cambridge Silicon Radio specific FC */ 1868 #define HCI_CMD_CSR_EXTN 0xFC00 1869 1870 1871 /************************************************************************** 1872 ************************************************************************** 1873 ** Events and event parameters 1874 ************************************************************************** 1875 **************************************************************************/ 1876 1877 #define HCI_EVENT_INQUIRY_COMPL 0x01 1878 typedef struct { 1879 uint8_t status; /* 0x00 - success */ 1880 } __packed hci_inquiry_compl_ep; 1881 1882 #define HCI_EVENT_INQUIRY_RESULT 0x02 1883 typedef struct { 1884 uint8_t num_responses; /* number of responses */ 1885 /* hci_inquiry_response[num_responses] -- see below */ 1886 } __packed hci_inquiry_result_ep; 1887 1888 typedef struct { 1889 bdaddr_t bdaddr; /* unit address */ 1890 uint8_t page_scan_rep_mode; /* page scan rep. mode */ 1891 uint8_t page_scan_period_mode; /* page scan period mode */ 1892 uint8_t page_scan_mode; /* page scan mode */ 1893 uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ 1894 uint16_t clock_offset; /* clock offset */ 1895 } __packed hci_inquiry_response; 1896 1897 #define HCI_EVENT_CON_COMPL 0x03 1898 typedef struct { 1899 uint8_t status; /* 0x00 - success */ 1900 uint16_t con_handle; /* Connection handle */ 1901 bdaddr_t bdaddr; /* remote unit address */ 1902 uint8_t link_type; /* Link type */ 1903 uint8_t encryption_mode; /* Encryption mode */ 1904 } __packed hci_con_compl_ep; 1905 1906 #define HCI_EVENT_CON_REQ 0x04 1907 typedef struct { 1908 bdaddr_t bdaddr; /* remote unit address */ 1909 uint8_t uclass[HCI_CLASS_SIZE]; /* remote unit class */ 1910 uint8_t link_type; /* link type */ 1911 } __packed hci_con_req_ep; 1912 1913 #define HCI_EVENT_DISCON_COMPL 0x05 1914 typedef struct { 1915 uint8_t status; /* 0x00 - success */ 1916 uint16_t con_handle; /* connection handle */ 1917 uint8_t reason; /* reason to disconnect */ 1918 } __packed hci_discon_compl_ep; 1919 1920 #define HCI_EVENT_AUTH_COMPL 0x06 1921 typedef struct { 1922 uint8_t status; /* 0x00 - success */ 1923 uint16_t con_handle; /* connection handle */ 1924 } __packed hci_auth_compl_ep; 1925 1926 #define HCI_EVENT_REMOTE_NAME_REQ_COMPL 0x07 1927 typedef struct { 1928 uint8_t status; /* 0x00 - success */ 1929 bdaddr_t bdaddr; /* remote unit address */ 1930 char name[HCI_UNIT_NAME_SIZE]; /* remote unit name */ 1931 } __packed hci_remote_name_req_compl_ep; 1932 1933 #define HCI_EVENT_ENCRYPTION_CHANGE 0x08 1934 typedef struct { 1935 uint8_t status; /* 0x00 - success */ 1936 uint16_t con_handle; /* Connection handle */ 1937 uint8_t encryption_enable; /* 0x00 - disable */ 1938 } __packed hci_encryption_change_ep; 1939 1940 #define HCI_EVENT_CHANGE_CON_LINK_KEY_COMPL 0x09 1941 typedef struct { 1942 uint8_t status; /* 0x00 - success */ 1943 uint16_t con_handle; /* Connection handle */ 1944 } __packed hci_change_con_link_key_compl_ep; 1945 1946 #define HCI_EVENT_MASTER_LINK_KEY_COMPL 0x0a 1947 typedef struct { 1948 uint8_t status; /* 0x00 - success */ 1949 uint16_t con_handle; /* Connection handle */ 1950 uint8_t key_flag; /* Key flag */ 1951 } __packed hci_master_link_key_compl_ep; 1952 1953 #define HCI_EVENT_READ_REMOTE_FEATURES_COMPL 0x0b 1954 typedef struct { 1955 uint8_t status; /* 0x00 - success */ 1956 uint16_t con_handle; /* Connection handle */ 1957 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ 1958 } __packed hci_read_remote_features_compl_ep; 1959 1960 #define HCI_EVENT_READ_REMOTE_VER_INFO_COMPL 0x0c 1961 typedef struct { 1962 uint8_t status; /* 0x00 - success */ 1963 uint16_t con_handle; /* Connection handle */ 1964 uint8_t lmp_version; /* LMP version */ 1965 uint16_t manufacturer; /* Hardware manufacturer name */ 1966 uint16_t lmp_subversion; /* LMP sub-version */ 1967 } __packed hci_read_remote_ver_info_compl_ep; 1968 1969 #define HCI_EVENT_QOS_SETUP_COMPL 0x0d 1970 typedef struct { 1971 uint8_t status; /* 0x00 - success */ 1972 uint16_t con_handle; /* connection handle */ 1973 uint8_t flags; /* reserved for future use */ 1974 uint8_t service_type; /* service type */ 1975 uint32_t token_rate; /* bytes per second */ 1976 uint32_t peak_bandwidth; /* bytes per second */ 1977 uint32_t latency; /* microseconds */ 1978 uint32_t delay_variation; /* microseconds */ 1979 } __packed hci_qos_setup_compl_ep; 1980 1981 #define HCI_EVENT_COMMAND_COMPL 0x0e 1982 typedef struct { 1983 uint8_t num_cmd_pkts; /* # of HCI command packets */ 1984 uint16_t opcode; /* command OpCode */ 1985 /* command return parameters (if any) */ 1986 } __packed hci_command_compl_ep; 1987 1988 #define HCI_EVENT_COMMAND_STATUS 0x0f 1989 typedef struct { 1990 uint8_t status; /* 0x00 - pending */ 1991 uint8_t num_cmd_pkts; /* # of HCI command packets */ 1992 uint16_t opcode; /* command OpCode */ 1993 } __packed hci_command_status_ep; 1994 1995 #define HCI_EVENT_HARDWARE_ERROR 0x10 1996 typedef struct { 1997 uint8_t hardware_code; /* hardware error code */ 1998 } __packed hci_hardware_error_ep; 1999 2000 #define HCI_EVENT_FLUSH_OCCUR 0x11 2001 typedef struct { 2002 uint16_t con_handle; /* connection handle */ 2003 } __packed hci_flush_occur_ep; 2004 2005 #define HCI_EVENT_ROLE_CHANGE 0x12 2006 typedef struct { 2007 uint8_t status; /* 0x00 - success */ 2008 bdaddr_t bdaddr; /* address of remote unit */ 2009 uint8_t role; /* new connection role */ 2010 } __packed hci_role_change_ep; 2011 2012 #define HCI_EVENT_NUM_COMPL_PKTS 0x13 2013 typedef struct { 2014 uint8_t num_con_handles; /* # of connection handles */ 2015 /* these are repeated "num_con_handles" times 2016 uint16_t con_handle; --- connection handle(s) 2017 uint16_t compl_pkts; --- # of completed packets */ 2018 } __packed hci_num_compl_pkts_ep; 2019 2020 #define HCI_EVENT_MODE_CHANGE 0x14 2021 typedef struct { 2022 uint8_t status; /* 0x00 - success */ 2023 uint16_t con_handle; /* connection handle */ 2024 uint8_t unit_mode; /* remote unit mode */ 2025 uint16_t interval; /* interval * 0.625 msec */ 2026 } __packed hci_mode_change_ep; 2027 2028 #define HCI_EVENT_RETURN_LINK_KEYS 0x15 2029 typedef struct { 2030 uint8_t num_keys; /* # of keys */ 2031 /* these are repeated "num_keys" times 2032 bdaddr_t bdaddr; --- remote address(es) 2033 uint8_t key[HCI_KEY_SIZE]; --- key(s) */ 2034 } __packed hci_return_link_keys_ep; 2035 2036 #define HCI_EVENT_PIN_CODE_REQ 0x16 2037 typedef struct { 2038 bdaddr_t bdaddr; /* remote unit address */ 2039 } __packed hci_pin_code_req_ep; 2040 2041 #define HCI_EVENT_LINK_KEY_REQ 0x17 2042 typedef struct { 2043 bdaddr_t bdaddr; /* remote unit address */ 2044 } __packed hci_link_key_req_ep; 2045 2046 #define HCI_EVENT_LINK_KEY_NOTIFICATION 0x18 2047 typedef struct { 2048 bdaddr_t bdaddr; /* remote unit address */ 2049 uint8_t key[HCI_KEY_SIZE]; /* link key */ 2050 uint8_t key_type; /* type of the key */ 2051 } __packed hci_link_key_notification_ep; 2052 2053 #define HCI_EVENT_LOOPBACK_COMMAND 0x19 2054 typedef hci_cmd_hdr_t hci_loopback_command_ep; 2055 2056 #define HCI_EVENT_DATA_BUFFER_OVERFLOW 0x1a 2057 typedef struct { 2058 uint8_t link_type; /* Link type */ 2059 } __packed hci_data_buffer_overflow_ep; 2060 2061 #define HCI_EVENT_MAX_SLOT_CHANGE 0x1b 2062 typedef struct { 2063 uint16_t con_handle; /* connection handle */ 2064 uint8_t lmp_max_slots; /* Max. # of slots allowed */ 2065 } __packed hci_max_slot_change_ep; 2066 2067 #define HCI_EVENT_READ_CLOCK_OFFSET_COMPL 0x1c 2068 typedef struct { 2069 uint8_t status; /* 0x00 - success */ 2070 uint16_t con_handle; /* Connection handle */ 2071 uint16_t clock_offset; /* Clock offset */ 2072 } __packed hci_read_clock_offset_compl_ep; 2073 2074 #define HCI_EVENT_CON_PKT_TYPE_CHANGED 0x1d 2075 typedef struct { 2076 uint8_t status; /* 0x00 - success */ 2077 uint16_t con_handle; /* connection handle */ 2078 uint16_t pkt_type; /* packet type */ 2079 } __packed hci_con_pkt_type_changed_ep; 2080 2081 #define HCI_EVENT_QOS_VIOLATION 0x1e 2082 typedef struct { 2083 uint16_t con_handle; /* connection handle */ 2084 } __packed hci_qos_violation_ep; 2085 2086 /* Page Scan Mode Change Event is deprecated */ 2087 #define HCI_EVENT_PAGE_SCAN_MODE_CHANGE 0x1f 2088 typedef struct { 2089 bdaddr_t bdaddr; /* destination address */ 2090 uint8_t page_scan_mode; /* page scan mode */ 2091 } __packed hci_page_scan_mode_change_ep; 2092 2093 #define HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE 0x20 2094 typedef struct { 2095 bdaddr_t bdaddr; /* destination address */ 2096 uint8_t page_scan_rep_mode; /* page scan repetition mode */ 2097 } __packed hci_page_scan_rep_mode_change_ep; 2098 2099 #define HCI_EVENT_FLOW_SPECIFICATION_COMPL 0x21 2100 typedef struct { 2101 uint8_t status; /* 0x00 - success */ 2102 uint16_t con_handle; /* connection handle */ 2103 uint8_t flags; /* reserved */ 2104 uint8_t direction; /* flow direction */ 2105 uint8_t type; /* service type */ 2106 uint32_t token_rate; /* token rate */ 2107 uint32_t bucket_size; /* token bucket size */ 2108 uint32_t peak_bandwidth; /* peak bandwidth */ 2109 uint32_t latency; /* access latency */ 2110 } __packed hci_flow_specification_compl_ep; 2111 2112 #define HCI_EVENT_RSSI_RESULT 0x22 2113 typedef struct { 2114 uint8_t num_responses; /* number of responses */ 2115 /* hci_rssi_response[num_responses] -- see below */ 2116 } __packed hci_rssi_result_ep; 2117 2118 typedef struct { 2119 bdaddr_t bdaddr; /* unit address */ 2120 uint8_t page_scan_rep_mode; /* page scan rep. mode */ 2121 uint8_t blank; /* reserved */ 2122 uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ 2123 uint16_t clock_offset; /* clock offset */ 2124 int8_t rssi; /* rssi */ 2125 } __packed hci_rssi_response; 2126 2127 #define HCI_EVENT_READ_REMOTE_EXTENDED_FEATURES 0x23 2128 typedef struct { 2129 uint8_t status; /* 0x00 - success */ 2130 uint16_t con_handle; /* connection handle */ 2131 uint8_t page; /* page number */ 2132 uint8_t max; /* max page number */ 2133 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ 2134 } __packed hci_read_remote_extended_features_ep; 2135 2136 #define HCI_EVENT_SCO_CON_COMPL 0x2c 2137 typedef struct { 2138 uint8_t status; /* 0x00 - success */ 2139 uint16_t con_handle; /* connection handle */ 2140 bdaddr_t bdaddr; /* unit address */ 2141 uint8_t link_type; /* link type */ 2142 uint8_t interval; /* transmission interval */ 2143 uint8_t window; /* retransmission window */ 2144 uint16_t rxlen; /* rx packet length */ 2145 uint16_t txlen; /* tx packet length */ 2146 uint8_t mode; /* air mode */ 2147 } __packed hci_sco_con_compl_ep; 2148 2149 #define HCI_EVENT_SCO_CON_CHANGED 0x2d 2150 typedef struct { 2151 uint8_t status; /* 0x00 - success */ 2152 uint16_t con_handle; /* connection handle */ 2153 uint8_t interval; /* transmission interval */ 2154 uint8_t window; /* retransmission window */ 2155 uint16_t rxlen; /* rx packet length */ 2156 uint16_t txlen; /* tx packet length */ 2157 } __packed hci_sco_con_changed_ep; 2158 2159 #define HCI_EVENT_SNIFF_SUBRATING 0x2e 2160 typedef struct { 2161 uint8_t status; /* 0x00 - success */ 2162 uint16_t con_handle; /* connection handle */ 2163 uint16_t tx_latency; /* max transmit latency */ 2164 uint16_t rx_latency; /* max receive latency */ 2165 uint16_t remote_timeout; /* remote timeout */ 2166 uint16_t local_timeout; /* local timeout */ 2167 } __packed hci_sniff_subrating_ep; 2168 2169 #define HCI_EVENT_EXTENDED_RESULT 0x2f 2170 typedef struct { 2171 uint8_t num_responses; /* must be 0x01 */ 2172 bdaddr_t bdaddr; /* remote device address */ 2173 uint8_t page_scan_rep_mode; 2174 uint8_t reserved; 2175 uint8_t uclass[HCI_CLASS_SIZE]; 2176 uint16_t clock_offset; 2177 int8_t rssi; 2178 uint8_t response[240]; /* extended inquiry response */ 2179 } __packed hci_extended_result_ep; 2180 2181 #define HCI_EVENT_ENCRYPTION_KEY_REFRESH 0x30 2182 typedef struct { 2183 uint8_t status; /* 0x00 - success */ 2184 uint16_t con_handle; /* connection handle */ 2185 } __packed hci_encryption_key_refresh_ep; 2186 2187 #define HCI_EVENT_IO_CAPABILITY_REQ 0x31 2188 typedef struct { 2189 bdaddr_t bdaddr; /* remote device address */ 2190 } __packed hci_io_capability_req_ep; 2191 2192 #define HCI_EVENT_IO_CAPABILITY_RSP 0x32 2193 typedef struct { 2194 bdaddr_t bdaddr; /* remote device address */ 2195 uint8_t io_capability; 2196 uint8_t oob_data_present; 2197 uint8_t auth_requirement; 2198 } __packed hci_io_capability_rsp_ep; 2199 2200 #define HCI_EVENT_USER_CONFIRM_REQ 0x33 2201 typedef struct { 2202 bdaddr_t bdaddr; /* remote device address */ 2203 uint32_t value; /* 000000 - 999999 */ 2204 } __packed hci_user_confirm_req_ep; 2205 2206 #define HCI_EVENT_USER_PASSKEY_REQ 0x34 2207 typedef struct { 2208 bdaddr_t bdaddr; /* remote device address */ 2209 } __packed hci_user_passkey_req_ep; 2210 2211 #define HCI_EVENT_REMOTE_OOB_DATA_REQ 0x35 2212 typedef struct { 2213 bdaddr_t bdaddr; /* remote device address */ 2214 } __packed hci_remote_oob_data_req_ep; 2215 2216 #define HCI_EVENT_SIMPLE_PAIRING_COMPL 0x36 2217 typedef struct { 2218 uint8_t status; /* 0x00 - success */ 2219 bdaddr_t bdaddr; /* remote device address */ 2220 } __packed hci_simple_pairing_compl_ep; 2221 2222 #define HCI_EVENT_LINK_SUPERVISION_TO_CHANGED 0x38 2223 typedef struct { 2224 uint16_t con_handle; /* connection handle */ 2225 uint16_t timeout; /* link supervision timeout */ 2226 } __packed hci_link_supervision_to_changed_ep; 2227 2228 #define HCI_EVENT_ENHANCED_FLUSH_COMPL 0x39 2229 typedef struct { 2230 uint16_t con_handle; /* connection handle */ 2231 } __packed hci_enhanced_flush_compl_ep; 2232 2233 #define HCI_EVENT_USER_PASSKEY_NOTIFICATION 0x3b 2234 typedef struct { 2235 bdaddr_t bdaddr; /* remote device address */ 2236 uint32_t value; /* 000000 - 999999 */ 2237 } __packed hci_user_passkey_notification_ep; 2238 2239 #define HCI_EVENT_KEYPRESS_NOTIFICATION 0x3c 2240 typedef struct { 2241 bdaddr_t bdaddr; /* remote device address */ 2242 uint8_t notification_type; 2243 } __packed hci_keypress_notification_ep; 2244 2245 #define HCI_EVENT_REMOTE_FEATURES_NOTIFICATION 0x3d 2246 typedef struct { 2247 bdaddr_t bdaddr; /* remote device address */ 2248 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ 2249 } __packed hci_remote_features_notification_ep; 2250 2251 #define HCI_EVENT_BT_LOGO 0xfe 2252 2253 #define HCI_EVENT_VENDOR 0xff 2254 2255 /************************************************************************** 2256 ************************************************************************** 2257 ** HCI Socket Definitions 2258 ************************************************************************** 2259 **************************************************************************/ 2260 2261 /* HCI socket options */ 2262 #define SO_HCI_EVT_FILTER 1 /* get/set event filter */ 2263 #define SO_HCI_PKT_FILTER 2 /* get/set packet filter */ 2264 #define SO_HCI_DIRECTION 3 /* packet direction indicator */ 2265 2266 /* Control Messages */ 2267 #define SCM_HCI_DIRECTION SO_HCI_DIRECTION 2268 2269 /* 2270 * HCI socket filter and get/set routines 2271 * 2272 * for ease of use, we filter 256 possible events/packets 2273 */ 2274 struct hci_filter { 2275 uint32_t mask[8]; /* 256 bits */ 2276 }; 2277 2278 static __inline void 2279 hci_filter_set(uint8_t bit, struct hci_filter *filter) 2280 { 2281 uint8_t off = bit - 1; 2282 2283 off >>= 5; 2284 filter->mask[off] |= (1 << ((bit - 1) & 0x1f)); 2285 } 2286 2287 static __inline void 2288 hci_filter_clr(uint8_t bit, struct hci_filter *filter) 2289 { 2290 uint8_t off = bit - 1; 2291 2292 off >>= 5; 2293 filter->mask[off] &= ~(1 << ((bit - 1) & 0x1f)); 2294 } 2295 2296 static __inline int 2297 hci_filter_test(uint8_t bit, const struct hci_filter *filter) 2298 { 2299 uint8_t off = bit - 1; 2300 2301 off >>= 5; 2302 return (filter->mask[off] & (1 << ((bit - 1) & 0x1f))); 2303 } 2304 2305 /* 2306 * HCI socket ioctl's 2307 * 2308 * Apart from GBTINFOA, these are all indexed on the unit name 2309 */ 2310 2311 #define SIOCGBTINFO _IOWR('b', 5, struct btreq) /* get unit info */ 2312 #define SIOCGBTINFOA _IOWR('b', 6, struct btreq) /* get info by address */ 2313 #define SIOCNBTINFO _IOWR('b', 7, struct btreq) /* next unit info */ 2314 2315 #define SIOCSBTFLAGS _IOWR('b', 8, struct btreq) /* set unit flags */ 2316 #define SIOCSBTPOLICY _IOWR('b', 9, struct btreq) /* set unit link policy */ 2317 #define SIOCSBTPTYPE _IOWR('b', 10, struct btreq) /* set unit packet type */ 2318 2319 #define SIOCGBTSTATS _IOWR('b', 11, struct btreq) /* get unit statistics */ 2320 #define SIOCZBTSTATS _IOWR('b', 12, struct btreq) /* zero unit statistics */ 2321 2322 #define SIOCBTDUMP _IOW('b', 13, struct btreq) /* print debug info */ 2323 #define SIOCSBTSCOMTU _IOWR('b', 17, struct btreq) /* set sco_mtu value */ 2324 2325 #define SIOCGBTFEAT _IOWR('b', 18, struct btreq) /* get unit features */ 2326 2327 struct bt_stats { 2328 uint32_t err_tx; 2329 uint32_t err_rx; 2330 uint32_t cmd_tx; 2331 uint32_t evt_rx; 2332 uint32_t acl_tx; 2333 uint32_t acl_rx; 2334 uint32_t sco_tx; 2335 uint32_t sco_rx; 2336 uint32_t byte_tx; 2337 uint32_t byte_rx; 2338 }; 2339 2340 struct btreq { 2341 char btr_name[HCI_DEVNAME_SIZE]; /* device name */ 2342 2343 union { 2344 struct { 2345 bdaddr_t btri_bdaddr; /* device bdaddr */ 2346 uint16_t btri_flags; /* flags */ 2347 uint16_t btri_num_cmd; /* # of free cmd buffers */ 2348 uint16_t btri_num_acl; /* # of free ACL buffers */ 2349 uint16_t btri_num_sco; /* # of free SCO buffers */ 2350 uint16_t btri_acl_mtu; /* ACL mtu */ 2351 uint16_t btri_sco_mtu; /* SCO mtu */ 2352 uint16_t btri_link_policy; /* Link Policy */ 2353 uint16_t btri_packet_type; /* Packet Type */ 2354 uint16_t btri_max_acl; /* max ACL buffers */ 2355 uint16_t btri_max_sco; /* max SCO buffers */ 2356 } btri; 2357 struct { 2358 uint8_t btrf_page0[HCI_FEATURES_SIZE]; /* basic */ 2359 uint8_t btrf_page1[HCI_FEATURES_SIZE]; /* extended */ 2360 uint8_t btrf_page2[HCI_FEATURES_SIZE]; /* extended */ 2361 } btrf; 2362 struct bt_stats btrs; /* unit stats */ 2363 } btru; 2364 }; 2365 2366 #define btr_flags btru.btri.btri_flags 2367 #define btr_bdaddr btru.btri.btri_bdaddr 2368 #define btr_num_cmd btru.btri.btri_num_cmd 2369 #define btr_num_acl btru.btri.btri_num_acl 2370 #define btr_num_sco btru.btri.btri_num_sco 2371 #define btr_acl_mtu btru.btri.btri_acl_mtu 2372 #define btr_sco_mtu btru.btri.btri_sco_mtu 2373 #define btr_link_policy btru.btri.btri_link_policy 2374 #define btr_packet_type btru.btri.btri_packet_type 2375 #define btr_max_acl btru.btri.btri_max_acl 2376 #define btr_max_sco btru.btri.btri_max_sco 2377 #define btr_features0 btru.btrf.btrf_page0 2378 #define btr_features1 btru.btrf.btrf_page1 2379 #define btr_features2 btru.btrf.btrf_page2 2380 #define btr_stats btru.btrs 2381 2382 /* hci_unit & btr_flags */ 2383 #define BTF_UP (1<<0) /* unit is up */ 2384 #define BTF_RUNNING (1<<1) /* unit is running */ 2385 #define BTF_XMIT_CMD (1<<2) /* unit is transmitting CMD packets */ 2386 #define BTF_XMIT_ACL (1<<3) /* unit is transmitting ACL packets */ 2387 #define BTF_XMIT_SCO (1<<4) /* unit is transmitting SCO packets */ 2388 #define BTF_XMIT (BTF_XMIT_CMD | BTF_XMIT_ACL | BTF_XMIT_SCO) 2389 #define BTF_INIT_BDADDR (1<<5) /* waiting for bdaddr */ 2390 #define BTF_INIT_BUFFER_SIZE (1<<6) /* waiting for buffer size */ 2391 #define BTF_INIT_FEATURES (1<<7) /* waiting for features */ 2392 #define BTF_POWER_UP_NOOP (1<<8) /* should wait for No-op on power up */ 2393 #define BTF_INIT_COMMANDS (1<<9) /* waiting for supported commands */ 2394 #define BTF_MASTER (1<<10) /* request Master role */ 2395 2396 #define BTF_INIT (BTF_INIT_BDADDR \ 2397 | BTF_INIT_BUFFER_SIZE \ 2398 | BTF_INIT_FEATURES \ 2399 | BTF_INIT_COMMANDS) 2400 2401 /************************************************************************** 2402 ************************************************************************** 2403 ** HCI Kernel Definitions 2404 ************************************************************************** 2405 **************************************************************************/ 2406 2407 #ifdef _KERNEL 2408 2409 #include <sys/condvar.h> 2410 #include <sys/device.h> 2411 2412 struct l2cap_channel; 2413 struct mbuf; 2414 struct sco_pcb; 2415 struct socket; 2416 struct sockopt; 2417 2418 /* global HCI kernel variables */ 2419 2420 /* sysctl variables */ 2421 extern int hci_memo_expiry; 2422 extern int hci_acl_expiry; 2423 extern int hci_sendspace, hci_recvspace; 2424 extern int hci_eventq_max, hci_aclrxq_max, hci_scorxq_max; 2425 2426 /* 2427 * HCI Connection Information 2428 */ 2429 struct hci_link { 2430 struct hci_unit *hl_unit; /* our unit */ 2431 TAILQ_ENTRY(hci_link) hl_next; /* next link on unit */ 2432 2433 /* common info */ 2434 uint16_t hl_state; /* connection state */ 2435 uint16_t hl_flags; /* link flags */ 2436 bdaddr_t hl_bdaddr; /* dest address */ 2437 uint16_t hl_handle; /* connection handle */ 2438 uint8_t hl_type; /* link type */ 2439 2440 /* ACL link info */ 2441 uint8_t hl_lastid; /* last id used */ 2442 uint16_t hl_refcnt; /* reference count */ 2443 uint16_t hl_mtu; /* signalling mtu for link */ 2444 uint16_t hl_flush; /* flush timeout */ 2445 uint16_t hl_clock; /* remote clock offset */ 2446 2447 TAILQ_HEAD(,l2cap_pdu) hl_txq; /* queue of outgoing PDUs */ 2448 int hl_txqlen; /* number of fragments */ 2449 struct mbuf *hl_rxp; /* incoming PDU (accumulating)*/ 2450 callout_t hl_expire; /* connection expiry timer */ 2451 TAILQ_HEAD(,l2cap_req) hl_reqs; /* pending requests */ 2452 2453 /* SCO link info */ 2454 struct hci_link *hl_link; /* SCO ACL link */ 2455 struct sco_pcb *hl_sco; /* SCO pcb */ 2456 MBUFQ_HEAD() hl_data; /* SCO outgoing data */ 2457 }; 2458 2459 /* hci_link state */ 2460 #define HCI_LINK_CLOSED 0 /* closed */ 2461 #define HCI_LINK_WAIT_CONNECT 1 /* waiting to connect */ 2462 #define HCI_LINK_WAIT_AUTH 2 /* waiting for auth */ 2463 #define HCI_LINK_WAIT_ENCRYPT 3 /* waiting for encrypt */ 2464 #define HCI_LINK_WAIT_SECURE 4 /* waiting for secure */ 2465 #define HCI_LINK_OPEN 5 /* ready and willing */ 2466 #define HCI_LINK_BLOCK 6 /* open but blocking (see hci_acl_start) */ 2467 2468 /* hci_link flags */ 2469 #define HCI_LINK_AUTH_REQ (1<<0) /* authentication requested */ 2470 #define HCI_LINK_ENCRYPT_REQ (1<<1) /* encryption requested */ 2471 #define HCI_LINK_SECURE_REQ (1<<2) /* secure link requested */ 2472 #define HCI_LINK_AUTH (1<<3) /* link is authenticated */ 2473 #define HCI_LINK_ENCRYPT (1<<4) /* link is encrypted */ 2474 #define HCI_LINK_SECURE (1<<5) /* link is secured */ 2475 #define HCI_LINK_CREATE_CON (1<<6) /* "Create Connection" pending */ 2476 2477 /* 2478 * Bluetooth Memo 2479 * cached device information for remote devices that this unit has seen 2480 */ 2481 struct hci_memo { 2482 struct timeval time; /* time of last response */ 2483 bdaddr_t bdaddr; 2484 uint8_t page_scan_rep_mode; 2485 uint8_t page_scan_mode; 2486 uint16_t clock_offset; 2487 LIST_ENTRY(hci_memo) next; 2488 }; 2489 2490 /* 2491 * The Bluetooth HCI interface attachment structure 2492 */ 2493 struct hci_if { 2494 int (*enable)(device_t); 2495 void (*disable)(device_t); 2496 void (*output_cmd)(device_t, struct mbuf *); 2497 void (*output_acl)(device_t, struct mbuf *); 2498 void (*output_sco)(device_t, struct mbuf *); 2499 void (*get_stats)(device_t, struct bt_stats *, int); 2500 int ipl; /* for locking */ 2501 }; 2502 2503 /* 2504 * The Bluetooth HCI device unit structure 2505 */ 2506 struct hci_unit { 2507 device_t hci_dev; /* bthci handle */ 2508 device_t hci_bthub; /* bthub(4) handle */ 2509 const struct hci_if *hci_if; /* bthci driver interface */ 2510 2511 /* device info */ 2512 bdaddr_t hci_bdaddr; /* device address */ 2513 uint16_t hci_flags; /* see BTF_ above */ 2514 kcondvar_t hci_init; /* sleep on this */ 2515 2516 uint16_t hci_packet_type; /* packet types */ 2517 uint16_t hci_acl_mask; /* ACL packet capabilities */ 2518 uint16_t hci_sco_mask; /* SCO packet capabilities */ 2519 2520 uint16_t hci_link_policy; /* link policy */ 2521 uint16_t hci_lmp_mask; /* link policy capabilities */ 2522 2523 uint8_t hci_feat0[HCI_FEATURES_SIZE]; /* features mask */ 2524 uint8_t hci_feat1[HCI_FEATURES_SIZE]; /* extended page 1 */ 2525 uint8_t hci_feat2[HCI_FEATURES_SIZE]; /* extended page 2 */ 2526 uint8_t hci_cmds[HCI_COMMANDS_SIZE]; /* opcode bitmask */ 2527 2528 /* flow control */ 2529 uint16_t hci_max_acl_size; /* ACL payload mtu */ 2530 uint16_t hci_num_acl_pkts; /* free ACL packet buffers */ 2531 uint16_t hci_max_acl_pkts; /* max ACL packet buffers */ 2532 uint8_t hci_num_cmd_pkts; /* free CMD packet buffers */ 2533 uint8_t hci_max_sco_size; /* SCO payload mtu */ 2534 uint16_t hci_num_sco_pkts; /* free SCO packet buffers */ 2535 uint16_t hci_max_sco_pkts; /* max SCO packet buffers */ 2536 2537 TAILQ_HEAD(,hci_link) hci_links; /* list of ACL/SCO links */ 2538 LIST_HEAD(,hci_memo) hci_memos; /* cached memo list */ 2539 2540 /* input queues */ 2541 void *hci_rxint; /* receive interrupt cookie */ 2542 kmutex_t hci_devlock; /* device queue lock */ 2543 MBUFQ_HEAD() hci_eventq; /* Event queue */ 2544 MBUFQ_HEAD() hci_aclrxq; /* ACL rx queue */ 2545 MBUFQ_HEAD() hci_scorxq; /* SCO rx queue */ 2546 uint16_t hci_eventqlen; /* Event queue length */ 2547 uint16_t hci_aclrxqlen; /* ACL rx queue length */ 2548 uint16_t hci_scorxqlen; /* SCO rx queue length */ 2549 2550 /* output queues */ 2551 MBUFQ_HEAD() hci_cmdwait; /* pending commands */ 2552 MBUFQ_HEAD() hci_scodone; /* SCO done queue */ 2553 2554 SIMPLEQ_ENTRY(hci_unit) hci_next; 2555 }; 2556 2557 extern SIMPLEQ_HEAD(hci_unit_list, hci_unit) hci_unit_list; 2558 2559 /* 2560 * HCI layer function prototypes 2561 */ 2562 2563 /* hci_event.c */ 2564 void hci_event(struct mbuf *, struct hci_unit *); 2565 2566 /* hci_ioctl.c */ 2567 int hci_ioctl_pcb(unsigned long, void *); 2568 2569 /* hci_link.c */ 2570 struct hci_link *hci_acl_open(struct hci_unit *, bdaddr_t *); 2571 struct hci_link *hci_acl_newconn(struct hci_unit *, bdaddr_t *); 2572 void hci_acl_close(struct hci_link *, int); 2573 void hci_acl_timeout(void *); 2574 int hci_acl_setmode(struct hci_link *); 2575 void hci_acl_linkmode(struct hci_link *); 2576 void hci_acl_recv(struct mbuf *, struct hci_unit *); 2577 int hci_acl_send(struct mbuf *, struct hci_link *, struct l2cap_channel *); 2578 void hci_acl_start(struct hci_link *); 2579 void hci_acl_complete(struct hci_link *, int); 2580 struct hci_link *hci_sco_newconn(struct hci_unit *, bdaddr_t *); 2581 void hci_sco_recv(struct mbuf *, struct hci_unit *); 2582 void hci_sco_start(struct hci_link *); 2583 void hci_sco_complete(struct hci_link *, int); 2584 struct hci_link *hci_link_alloc(struct hci_unit *, bdaddr_t *, uint8_t); 2585 void hci_link_free(struct hci_link *, int); 2586 struct hci_link *hci_link_lookup_bdaddr(struct hci_unit *, bdaddr_t *, uint8_t); 2587 struct hci_link *hci_link_lookup_handle(struct hci_unit *, uint16_t); 2588 2589 /* hci_misc.c */ 2590 int hci_route_lookup(bdaddr_t *, bdaddr_t *); 2591 struct hci_memo *hci_memo_find(struct hci_unit *, bdaddr_t *); 2592 struct hci_memo *hci_memo_new(struct hci_unit *, bdaddr_t *); 2593 void hci_memo_free(struct hci_memo *); 2594 2595 /* hci_socket.c */ 2596 void hci_drop(void *); 2597 void hci_init(void); 2598 int hci_ctloutput(int, struct socket *, struct sockopt *); 2599 void hci_mtap(struct mbuf *, struct hci_unit *); 2600 2601 /* hci_unit.c */ 2602 struct hci_unit *hci_attach_pcb(const struct hci_if *, device_t, uint16_t); 2603 void hci_detach_pcb(struct hci_unit *); 2604 int hci_enable(struct hci_unit *); 2605 void hci_disable(struct hci_unit *); 2606 struct hci_unit *hci_unit_lookup(const bdaddr_t *); 2607 int hci_send_cmd(struct hci_unit *, uint16_t, void *, uint8_t); 2608 void hci_num_cmds(struct hci_unit *, uint8_t); 2609 bool hci_input_event(struct hci_unit *, struct mbuf *); 2610 bool hci_input_acl(struct hci_unit *, struct mbuf *); 2611 bool hci_input_sco(struct hci_unit *, struct mbuf *); 2612 bool hci_complete_sco(struct hci_unit *, struct mbuf *); 2613 void hci_output_cmd(struct hci_unit *, struct mbuf *); 2614 void hci_output_acl(struct hci_unit *, struct mbuf *); 2615 void hci_output_sco(struct hci_unit *, struct mbuf *); 2616 2617 #endif /* _KERNEL */ 2618 2619 #endif /* _NETBT_HCI_H_ */ 2620