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