1 /* 2 * ng_hci.h 3 * 4 * Copyright (c) 2001 Maksim Yevmenkin <m_evmenkin@yahoo.com> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $Id: ng_hci.h,v 1.2 2003/03/18 00:09:37 max Exp $ 29 * $FreeBSD$ 30 */ 31 32 /* 33 * This file contains everything that application needs to know about 34 * Host Controller Interface (HCI). All information was obtained from 35 * Bluetooth Specification Book v1.1. 36 * 37 * This file can be included by both kernel and userland applications. 38 * 39 * NOTE: Here and after Bluetooth device is called a "unit". Bluetooth 40 * specification refers to both devices and units. They are the 41 * same thing (i think), so to be consistent word "unit" will be 42 * used. 43 */ 44 45 #ifndef _NETGRAPH_HCI_H_ 46 #define _NETGRAPH_HCI_H_ 47 48 /************************************************************************** 49 ************************************************************************** 50 ** Netgraph node hook name, type name and type cookie and commands 51 ************************************************************************** 52 **************************************************************************/ 53 54 /* Node type name and type cookie */ 55 #define NG_HCI_NODE_TYPE "hci" 56 #define NGM_HCI_COOKIE 1000774184 57 58 /* Netgraph node hook names */ 59 #define NG_HCI_HOOK_DRV "drv" /* Driver <-> HCI */ 60 #define NG_HCI_HOOK_ACL "acl" /* HCI <-> Upper */ 61 #define NG_HCI_HOOK_SCO "sco" /* HCI <-> Upper */ 62 #define NG_HCI_HOOK_RAW "raw" /* HCI <-> Upper */ 63 64 /************************************************************************** 65 ************************************************************************** 66 ** Common defines and types (HCI) 67 ************************************************************************** 68 **************************************************************************/ 69 70 /* All sizes are in bytes */ 71 #define NG_HCI_BDADDR_SIZE 6 /* unit address */ 72 #define NG_HCI_LAP_SIZE 3 /* unit LAP */ 73 #define NG_HCI_KEY_SIZE 16 /* link key */ 74 #define NG_HCI_PIN_SIZE 16 /* link PIN */ 75 #define NG_HCI_EVENT_MASK_SIZE 8 /* event mask */ 76 #define NG_HCI_CLASS_SIZE 3 /* unit class */ 77 #define NG_HCI_FEATURES_SIZE 8 /* LMP features */ 78 #define NG_HCI_UNIT_NAME_SIZE 248 /* unit name size */ 79 80 /* HCI specification */ 81 #define NG_HCI_SPEC_V10 0x00 /* v1.0 */ 82 #define NG_HCI_SPEC_V11 0x01 /* v1.1 */ 83 /* 0x02 - 0xFF - reserved for future use */ 84 85 /* LMP features */ 86 /* ------------------- byte 0 --------------------*/ 87 #define NG_HCI_LMP_3SLOT 0x01 88 #define NG_HCI_LMP_5SLOT 0x02 89 #define NG_HCI_LMP_ENCRYPTION 0x04 90 #define NG_HCI_LMP_SLOT_OFFSET 0x08 91 #define NG_HCI_LMP_TIMING_ACCURACY 0x10 92 #define NG_HCI_LMP_SWITCH 0x20 93 #define NG_HCI_LMP_HOLD_MODE 0x40 94 #define NG_HCI_LMP_SNIFF_MODE 0x80 95 /* ------------------- byte 1 --------------------*/ 96 #define NG_HCI_LMP_PARK_MODE 0x01 97 #define NG_HCI_LMP_RSSI 0x02 98 #define NG_HCI_LMP_CHANNEL_QUALITY 0x04 99 #define NG_HCI_LMP_SCO_LINK 0x08 100 #define NG_HCI_LMP_HV2_PKT 0x10 101 #define NG_HCI_LMP_HV3_PKT 0x20 102 #define NG_HCI_LMP_ULAW_LOG 0x40 103 #define NG_HCI_LMP_ALAW_LOG 0x80 104 /* ------------------- byte 2 --------------------*/ 105 #define NG_HCI_LMP_CVSD 0x01 106 #define NG_HCI_LMP_PAGING_SCHEME 0x02 107 #define NG_HCI_LMP_POWER_CONTROL 0x04 108 #define NG_HCI_LMP_TRANSPARENT_SCO 0x08 109 #define NG_HCI_LMP_FLOW_CONTROL_LAG0 0x10 110 #define NG_HCI_LMP_FLOW_CONTROL_LAG1 0x20 111 #define NG_HCI_LMP_FLOW_CONTROL_LAG2 0x40 112 113 /* Link types */ 114 #define NG_HCI_LINK_SCO 0x00 /* Voice */ 115 #define NG_HCI_LINK_ACL 0x01 /* Data */ 116 /* 0x02 - 0xFF - reserved for future use */ 117 118 /* Packet types */ 119 /* 0x0001 - 0x0004 - reserved for future use */ 120 #define NG_HCI_PKT_DM1 0x0008 /* ACL link */ 121 #define NG_HCI_PKT_DH1 0x0010 /* ACL link */ 122 #define NG_HCI_PKT_HV1 0x0020 /* SCO link */ 123 #define NG_HCI_PKT_HV2 0x0040 /* SCO link */ 124 #define NG_HCI_PKT_HV3 0x0080 /* SCO link */ 125 /* 0x0100 - 0x0200 - reserved for future use */ 126 #define NG_HCI_PKT_DM3 0x0400 /* ACL link */ 127 #define NG_HCI_PKT_DH3 0x0800 /* ACL link */ 128 /* 0x1000 - 0x2000 - reserved for future use */ 129 #define NG_HCI_PKT_DM5 0x4000 /* ACL link */ 130 #define NG_HCI_PKT_DH5 0x8000 /* ACL link */ 131 132 /* 133 * Connection modes/Unit modes 134 * 135 * This is confusing. It means that one of the units change its mode 136 * for the specific connection. For example one connection was put on 137 * hold (but i could be wrong :) 138 */ 139 140 #define NG_HCI_UNIT_MODE_ACTIVE 0x00 141 #define NG_HCI_UNIT_MODE_HOLD 0x01 142 #define NG_HCI_UNIT_MODE_SNIFF 0x02 143 #define NG_HCI_UNIT_MODE_PARK 0x03 144 /* 0x04 - 0xFF - reserved for future use */ 145 146 /* Page scan modes */ 147 #define NG_HCI_MANDATORY_PAGE_SCAN_MODE 0x00 148 #define NG_HCI_OPTIONAL_PAGE_SCAN_MODE1 0x01 149 #define NG_HCI_OPTIONAL_PAGE_SCAN_MODE2 0x02 150 #define NG_HCI_OPTIONAL_PAGE_SCAN_MODE3 0x03 151 /* 0x04 - 0xFF - reserved for future use */ 152 153 /* Page scan repetition modes */ 154 #define NG_HCI_SCAN_REP_MODE0 0x00 155 #define NG_HCI_SCAN_REP_MODE1 0x01 156 #define NG_HCI_SCAN_REP_MODE2 0x02 157 /* 0x03 - 0xFF - reserved for future use */ 158 159 /* Page scan period modes */ 160 #define NG_HCI_PAGE_SCAN_PERIOD_MODE0 0x00 161 #define NG_HCI_PAGE_SCAN_PERIOD_MODE1 0x01 162 #define NG_HCI_PAGE_SCAN_PERIOD_MODE2 0x02 163 /* 0x03 - 0xFF - reserved for future use */ 164 165 /* Scan enable */ 166 #define NG_HCI_NO_SCAN_ENABLE 0x00 167 #define NG_HCI_INQUIRY_ENABLE_PAGE_DISABLE 0x01 168 #define NG_HCI_INQUIRY_DISABLE_PAGE_ENABLE 0x02 169 #define NG_HCI_INQUIRY_ENABLE_PAGE_ENABLE 0x03 170 /* 0x04 - 0xFF - reserved for future use */ 171 172 /* Hold mode activities */ 173 #define NG_HCI_HOLD_MODE_NO_CHANGE 0x00 174 #define NG_HCI_HOLD_MODE_SUSPEND_PAGE_SCAN 0x01 175 #define NG_HCI_HOLD_MODE_SUSPEND_INQUIRY_SCAN 0x02 176 #define NG_HCI_HOLD_MODE_SUSPEND_PERIOD_INQUIRY 0x04 177 /* 0x08 - 0x80 - reserved for future use */ 178 179 /* Connection roles */ 180 #define NG_HCI_ROLE_MASTER 0x00 181 #define NG_HCI_ROLE_SLAVE 0x01 182 /* 0x02 - 0xFF - reserved for future use */ 183 184 /* Key flags */ 185 #define NG_HCI_USE_SEMI_PERMANENT_LINK_KEYS 0x00 186 #define NG_HCI_USE_TEMPORARY_LINK_KEY 0x01 187 /* 0x02 - 0xFF - reserved for future use */ 188 189 /* Pin types */ 190 #define NG_HCI_PIN_TYPE_VARIABLE 0x00 191 #define NG_HCI_PIN_TYPE_FIXED 0x01 192 193 /* Link key types */ 194 #define NG_HCI_LINK_KEY_TYPE_COMBINATION_KEY 0x00 195 #define NG_HCI_LINK_KEY_TYPE_LOCAL_UNIT_KEY 0x01 196 #define NG_HCI_LINK_KEY_TYPE_REMOTE_UNIT_KEY 0x02 197 /* 0x03 - 0xFF - reserved for future use */ 198 199 /* Encryption modes */ 200 #define NG_HCI_ENCRYPTION_MODE_NONE 0x00 201 #define NG_HCI_ENCRYPTION_MODE_P2P 0x01 202 #define NG_HCI_ENCRYPTION_MODE_ALL 0x02 203 /* 0x03 - 0xFF - reserved for future use */ 204 205 /* Quality of service types */ 206 #define NG_HCI_SERVICE_TYPE_NO_TRAFFIC 0x00 207 #define NG_HCI_SERVICE_TYPE_BEST_EFFORT 0x01 208 #define NG_HCI_SERVICE_TYPE_GUARANTEED 0x02 209 /* 0x03 - 0xFF - reserved for future use */ 210 211 /* Link policy settings */ 212 #define NG_HCI_LINK_POLICY_DISABLE_ALL_LM_MODES 0x0000 213 #define NG_HCI_LINK_POLICY_ENABLE_ROLE_SWITCH 0x0001 /* Master/Slave switch */ 214 #define NG_HCI_LINK_POLICY_ENABLE_HOLD_MODE 0x0002 215 #define NG_HCI_LINK_POLICY_ENABLE_SNIFF_MODE 0x0004 216 #define NG_HCI_LINK_POLICY_ENABLE_PARK_MODE 0x0008 217 /* 0x0010 - 0x8000 - reserved for future use */ 218 219 /* Event masks */ 220 #define NG_HCI_EVMSK_ALL 0x00000000ffffffff 221 #define NG_HCI_EVMSK_NONE 0x0000000000000000 222 #define NG_HCI_EVMSK_INQUIRY_COMPL 0x0000000000000001 223 #define NG_HCI_EVMSK_INQUIRY_RESULT 0x0000000000000002 224 #define NG_HCI_EVMSK_CON_COMPL 0x0000000000000004 225 #define NG_HCI_EVMSK_CON_REQ 0x0000000000000008 226 #define NG_HCI_EVMSK_DISCON_COMPL 0x0000000000000010 227 #define NG_HCI_EVMSK_AUTH_COMPL 0x0000000000000020 228 #define NG_HCI_EVMSK_REMOTE_NAME_REQ_COMPL 0x0000000000000040 229 #define NG_HCI_EVMSK_ENCRYPTION_CHANGE 0x0000000000000080 230 #define NG_HCI_EVMSK_CHANGE_CON_LINK_KEY_COMPL 0x0000000000000100 231 #define NG_HCI_EVMSK_MASTER_LINK_KEY_COMPL 0x0000000000000200 232 #define NG_HCI_EVMSK_READ_REMOTE_FEATURES_COMPL 0x0000000000000400 233 #define NG_HCI_EVMSK_READ_REMOTE_VER_INFO_COMPL 0x0000000000000800 234 #define NG_HCI_EVMSK_QOS_SETUP_COMPL 0x0000000000001000 235 #define NG_HCI_EVMSK_COMMAND_COMPL 0x0000000000002000 236 #define NG_HCI_EVMSK_COMMAND_STATUS 0x0000000000004000 237 #define NG_HCI_EVMSK_HARDWARE_ERROR 0x0000000000008000 238 #define NG_HCI_EVMSK_FLUSH_OCCUR 0x0000000000010000 239 #define NG_HCI_EVMSK_ROLE_CHANGE 0x0000000000020000 240 #define NG_HCI_EVMSK_NUM_COMPL_PKTS 0x0000000000040000 241 #define NG_HCI_EVMSK_MODE_CHANGE 0x0000000000080000 242 #define NG_HCI_EVMSK_RETURN_LINK_KEYS 0x0000000000100000 243 #define NG_HCI_EVMSK_PIN_CODE_REQ 0x0000000000200000 244 #define NG_HCI_EVMSK_LINK_KEY_REQ 0x0000000000400000 245 #define NG_HCI_EVMSK_LINK_KEY_NOTIFICATION 0x0000000000800000 246 #define NG_HCI_EVMSK_LOOPBACK_COMMAND 0x0000000001000000 247 #define NG_HCI_EVMSK_DATA_BUFFER_OVERFLOW 0x0000000002000000 248 #define NG_HCI_EVMSK_MAX_SLOT_CHANGE 0x0000000004000000 249 #define NG_HCI_EVMSK_READ_CLOCK_OFFSET_COMLETE 0x0000000008000000 250 #define NG_HCI_EVMSK_CON_PKT_TYPE_CHANGED 0x0000000010000000 251 #define NG_HCI_EVMSK_QOS_VIOLATION 0x0000000020000000 252 #define NG_HCI_EVMSK_PAGE_SCAN_MODE_CHANGE 0x0000000040000000 253 #define NG_HCI_EVMSK_PAGE_SCAN_REP_MODE_CHANGE 0x0000000080000000 254 /* 0x0000000100000000 - 0x8000000000000000 - reserved for future use */ 255 256 /* Filter types */ 257 #define NG_HCI_FILTER_TYPE_NONE 0x00 258 #define NG_HCI_FILTER_TYPE_INQUIRY_RESULT 0x01 259 #define NG_HCI_FILTER_TYPE_CON_SETUP 0x02 260 /* 0x03 - 0xFF - reserved for future use */ 261 262 /* Filter condition types for NG_HCI_FILTER_TYPE_INQUIRY_RESULT */ 263 #define NG_HCI_FILTER_COND_INQUIRY_NEW_UNIT 0x00 264 #define NG_HCI_FILTER_COND_INQUIRY_UNIT_CLASS 0x01 265 #define NG_HCI_FILTER_COND_INQUIRY_BDADDR 0x02 266 /* 0x03 - 0xFF - reserved for future use */ 267 268 /* Filter condition types for NG_HCI_FILTER_TYPE_CON_SETUP */ 269 #define NG_HCI_FILTER_COND_CON_ANY_UNIT 0x00 270 #define NG_HCI_FILTER_COND_CON_UNIT_CLASS 0x01 271 #define NG_HCI_FILTER_COND_CON_BDADDR 0x02 272 /* 0x03 - 0xFF - reserved for future use */ 273 274 /* Xmit level types */ 275 #define NG_HCI_XMIT_LEVEL_CURRENT 0x00 276 #define NG_HCI_XMIT_LEVEL_MAXIMUM 0x01 277 /* 0x02 - 0xFF - reserved for future use */ 278 279 /* Host to Host Controller flow control */ 280 #define NG_HCI_H2HC_FLOW_CONTROL_NONE 0x00 281 #define NG_HCI_H2HC_FLOW_CONTROL_ACL 0x01 282 #define NG_HCI_H2HC_FLOW_CONTROL_SCO 0x02 283 #define NG_HCI_H2HC_FLOW_CONTROL_BOTH 0x03 /* ACL and SCO */ 284 /* 0x04 - 0xFF - reserved future use */ 285 286 /* Country codes */ 287 #define NG_HCI_COUNTRY_CODE_NAM_EUR_JP 0x00 288 #define NG_HCI_COUNTRY_CODE_FRANCE 0x01 289 /* 0x02 - 0xFF - reserved future use */ 290 291 /* Loopback modes */ 292 #define NG_HCI_LOOPBACK_NONE 0x00 293 #define NG_HCI_LOOPBACK_LOCAL 0x01 294 #define NG_HCI_LOOPBACK_REMOTE 0x02 295 /* 0x03 - 0xFF - reserved future use */ 296 297 /************************************************************************** 298 ************************************************************************** 299 ** Link level defines, headers and types 300 ************************************************************************** 301 **************************************************************************/ 302 303 /* 304 * Macro(s) to combine OpCode and extract OGF (OpCode Group Field) 305 * and OCF (OpCode Command Field) from OpCode. 306 */ 307 308 #define NG_HCI_OPCODE(gf,cf) ((((gf) & 0x3f) << 10) | ((cf) & 0x3ff)) 309 #define NG_HCI_OCF(op) ((op) & 0x3ff) 310 #define NG_HCI_OGF(op) (((op) >> 10) & 0x3f) 311 312 /* 313 * Marco(s) to extract/combine connection handle, BC (Broadcast) and 314 * PB (Packet boundary) flags. 315 */ 316 317 #define NG_HCI_CON_HANDLE(h) ((h) & 0x0fff) 318 #define NG_HCI_PB_FLAG(h) (((h) & 0x3000) >> 12) 319 #define NG_HCI_BC_FLAG(h) (((h) & 0xc000) >> 14) 320 #define NG_HCI_MK_CON_HANDLE(h, pb, bc) \ 321 (((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14)) 322 323 /* PB flag values */ 324 /* 00 - reserved for future use */ 325 #define NG_HCI_PACKET_FRAGMENT 0x1 326 #define NG_HCI_PACKET_START 0x2 327 /* 11 - reserved for future use */ 328 329 /* BC flag values */ 330 #define NG_HCI_POINT2POINT 0x0 /* only Host controller to Host */ 331 #define NG_HCI_BROADCAST_ACTIVE 0x1 /* both directions */ 332 #define NG_HCI_BROADCAST_PICONET 0x2 /* both directions */ 333 /* 11 - reserved for future use */ 334 335 /* HCI command packet header */ 336 #define NG_HCI_CMD_PKT 0x01 337 #define NG_HCI_CMD_PKT_SIZE 0xff /* without header */ 338 typedef struct { 339 u_int8_t type; /* MUST be 0x1 */ 340 u_int16_t opcode; /* OpCode */ 341 u_int8_t length; /* parameter(s) length in bytes */ 342 } __attribute__ ((packed)) ng_hci_cmd_pkt_t; 343 344 /* ACL data packet header */ 345 #define NG_HCI_ACL_DATA_PKT 0x02 346 #define NG_HCI_ACL_PKT_SIZE 0xffff /* without header */ 347 typedef struct { 348 u_int8_t type; /* MUST be 0x2 */ 349 u_int16_t con_handle; /* connection handle + PB + BC flags */ 350 u_int16_t length; /* payload length in bytes */ 351 } __attribute__ ((packed)) ng_hci_acldata_pkt_t; 352 353 /* SCO data packet header */ 354 #define NG_HCI_SCO_DATA_PKT 0x03 355 #define NG_HCI_SCO_PKT_SIZE 0xff /* without header */ 356 typedef struct { 357 u_int8_t type; /* MUST be 0x3 */ 358 u_int16_t con_handle; /* connection handle + reserved bits */ 359 u_int8_t length; /* payload length in bytes */ 360 } __attribute__ ((packed)) ng_hci_scodata_pkt_t; 361 362 /* HCI event packet header */ 363 #define NG_HCI_EVENT_PKT 0x04 364 #define NG_HCI_EVENT_PKT_SIZE 0xff /* without header */ 365 typedef struct { 366 u_int8_t type; /* MUST be 0x4 */ 367 u_int8_t event; /* event */ 368 u_int8_t length; /* parameter(s) length in bytes */ 369 } __attribute__ ((packed)) ng_hci_event_pkt_t; 370 371 /* Bluetooth unit address */ 372 typedef struct { 373 u_int8_t b[NG_HCI_BDADDR_SIZE]; 374 } __attribute__ ((packed)) bdaddr_t; 375 typedef bdaddr_t * bdaddr_p; 376 377 /* Any BD_ADDR. Note: This is actually 7 bytes (count '\0' terminator) */ 378 #define NG_HCI_BDADDR_ANY ((bdaddr_p) "\000\000\000\000\000\000") 379 380 /* HCI status return parameter */ 381 typedef struct { 382 u_int8_t status; /* 0x00 - success */ 383 } __attribute__ ((packed)) ng_hci_status_rp; 384 385 /************************************************************************** 386 ************************************************************************** 387 ** Upper layer protocol interface. LP_xxx event parameters 388 ************************************************************************** 389 **************************************************************************/ 390 391 /* Connection Request Event */ 392 #define NGM_HCI_LP_CON_REQ 1 /* Upper -> HCI */ 393 typedef struct { 394 u_int16_t link_type; /* type of connection */ 395 bdaddr_t bdaddr; /* remote unit address */ 396 } ng_hci_lp_con_req_ep; 397 398 /* 399 * XXX XXX XXX 400 * 401 * NOTE: This request is not defined by Bluetooth specification, 402 * but i find it useful :) 403 */ 404 #define NGM_HCI_LP_DISCON_REQ 2 /* Upper -> HCI */ 405 typedef struct { 406 u_int16_t con_handle; /* connection handle */ 407 u_int16_t reason; /* reason to disconnect (only low byte) */ 408 } ng_hci_lp_discon_req_ep; 409 410 /* Connection Confirmation Event */ 411 #define NGM_HCI_LP_CON_CFM 3 /* HCI -> Upper */ 412 typedef struct { 413 u_int8_t status; /* 0x00 - success */ 414 u_int8_t link_type; /* link type */ 415 u_int16_t con_handle; /* con_handle */ 416 bdaddr_t bdaddr; /* remote unit address */ 417 } ng_hci_lp_con_cfm_ep; 418 419 /* Connection Indication Event */ 420 #define NGM_HCI_LP_CON_IND 4 /* HCI -> Upper */ 421 typedef struct { 422 u_int8_t link_type; /* link type */ 423 u_int8_t uclass[NG_HCI_CLASS_SIZE]; /* unit class */ 424 bdaddr_t bdaddr; /* remote unit address */ 425 } ng_hci_lp_con_ind_ep; 426 427 /* Connection Response Event */ 428 #define NGM_HCI_LP_CON_RSP 5 /* Upper -> HCI */ 429 typedef struct { 430 u_int8_t status; /* 0x00 - accept connection */ 431 u_int8_t link_type; /* link type */ 432 bdaddr_t bdaddr; /* remote unit address */ 433 } ng_hci_lp_con_rsp_ep; 434 435 /* Disconnection Indication Event */ 436 #define NGM_HCI_LP_DISCON_IND 6 /* HCI -> Upper */ 437 typedef struct { 438 u_int8_t reason; /* reason to disconnect (only low byte) */ 439 u_int8_t link_type; /* link type */ 440 u_int16_t con_handle; /* connection handle */ 441 } ng_hci_lp_discon_ind_ep; 442 443 /* QoS Setup Request Event */ 444 #define NGM_HCI_LP_QOS_REQ 7 /* Upper -> HCI */ 445 typedef struct { 446 u_int16_t con_handle; /* connection handle */ 447 u_int8_t flags; /* reserved */ 448 u_int8_t service_type; /* service type */ 449 u_int32_t token_rate; /* bytes/sec */ 450 u_int32_t peak_bandwidth; /* bytes/sec */ 451 u_int32_t latency; /* msec */ 452 u_int32_t delay_variation; /* msec */ 453 } ng_hci_lp_qos_req_ep; 454 455 /* QoS Conformition Event */ 456 #define NGM_HCI_LP_QOS_CFM 8 /* HCI -> Upper */ 457 typedef struct { 458 u_int16_t status; /* 0x00 - success (only low byte) */ 459 u_int16_t con_handle; /* connection handle */ 460 } ng_hci_lp_qos_cfm_ep; 461 462 /* QoS Violation Indication Event */ 463 #define NGM_HCI_LP_QOS_IND 9 /* HCI -> Upper */ 464 typedef struct { 465 u_int16_t con_handle; /* connection handle */ 466 } ng_hci_lp_qos_ind_ep; 467 468 /************************************************************************** 469 ************************************************************************** 470 ** HCI node command/event parameters 471 ************************************************************************** 472 **************************************************************************/ 473 474 /* Debug levels */ 475 #define NG_HCI_ALERT_LEVEL 1 476 #define NG_HCI_ERR_LEVEL 2 477 #define NG_HCI_WARN_LEVEL 3 478 #define NG_HCI_INFO_LEVEL 4 479 480 /* Unit states */ 481 #define NG_HCI_UNIT_CONNECTED (1 << 0) 482 #define NG_HCI_UNIT_INITED (1 << 1) 483 #define NG_HCI_UNIT_READY (NG_HCI_UNIT_CONNECTED|NG_HCI_UNIT_INITED) 484 #define NG_HCI_UNIT_COMMAND_PENDING (1 << 2) 485 486 /* Connection state */ 487 #define NG_HCI_CON_CLOSED 0 /* connection closed */ 488 #define NG_HCI_CON_W4_LP_CON_RSP 1 /* wait for LP_ConnectRsp */ 489 #define NG_HCI_CON_W4_CONN_COMPLETE 2 /* wait for Connection_Complete evt */ 490 #define NG_HCI_CON_OPEN 3 /* connection open */ 491 492 /* Get HCI node (unit) state (see states above) */ 493 #define NGM_HCI_NODE_GET_STATE 100 /* HCI -> User */ 494 typedef u_int16_t ng_hci_node_state_ep; 495 496 /* Turn on "inited" bit */ 497 #define NGM_HCI_NODE_INIT 101 /* User -> HCI */ 498 /* No parameters */ 499 500 /* Get/Set node debug level (see debug levels above) */ 501 #define NGM_HCI_NODE_GET_DEBUG 102 /* HCI -> User */ 502 #define NGM_HCI_NODE_SET_DEBUG 103 /* User -> HCI */ 503 typedef u_int16_t ng_hci_node_debug_ep; 504 505 /* Get node buffer info */ 506 #define NGM_HCI_NODE_GET_BUFFER 104 /* HCI -> User */ 507 typedef struct { 508 u_int8_t cmd_free; /* number of free command packets */ 509 u_int8_t sco_size; /* max. size of SCO packet */ 510 u_int16_t sco_pkts; /* number of SCO packets */ 511 u_int16_t sco_free; /* number of free SCO packets */ 512 u_int16_t acl_size; /* max. size of ACL packet */ 513 u_int16_t acl_pkts; /* number of ACL packets */ 514 u_int16_t acl_free; /* number of free ACL packets */ 515 } ng_hci_node_buffer_ep; 516 517 /* Get BDADDR */ 518 #define NGM_HCI_NODE_GET_BDADDR 105 /* HCI -> User */ 519 /* bdaddr_t -- BDADDR */ 520 521 /* Get features */ 522 #define NGM_HCI_NODE_GET_FEATURES 106 /* HCI -> User */ 523 /* features[NG_HCI_FEATURES_SIZE] -- features */ 524 525 #define NGM_HCI_NODE_GET_STAT 107 /* HCI -> User */ 526 typedef struct { 527 u_int32_t cmd_sent; /* number of HCI commands sent */ 528 u_int32_t evnt_recv; /* number of HCI events received */ 529 u_int32_t acl_recv; /* number of ACL packets received */ 530 u_int32_t acl_sent; /* number of ACL packets sent */ 531 u_int32_t sco_recv; /* number of SCO packets received */ 532 u_int32_t sco_sent; /* number of SCO packets sent */ 533 u_int32_t bytes_recv; /* total number of bytes received */ 534 u_int32_t bytes_sent; /* total number of bytes sent */ 535 } ng_hci_node_stat_ep; 536 537 #define NGM_HCI_NODE_RESET_STAT 108 /* User -> HCI */ 538 /* No parameters */ 539 540 #define NGM_HCI_NODE_FLUSH_NEIGHBOR_CACHE 109 /* User -> HCI */ 541 542 #define NGM_HCI_NODE_GET_NEIGHBOR_CACHE 110 /* HCI -> User */ 543 typedef struct { 544 u_int32_t num_entries; /* number of entries */ 545 } ng_hci_node_get_neighbor_cache_ep; 546 547 typedef struct { 548 u_int16_t page_scan_rep_mode; /* page rep scan mode */ 549 u_int16_t page_scan_mode; /* page scan mode */ 550 u_int16_t clock_offset; /* clock offset */ 551 bdaddr_t bdaddr; /* bdaddr */ 552 u_int8_t features[NG_HCI_FEATURES_SIZE]; /* features */ 553 } ng_hci_node_neighbor_cache_entry_ep; 554 555 #define NG_HCI_MAX_NEIGHBOR_NUM \ 556 ((0xffff - sizeof(ng_hci_node_get_neighbor_cache_ep))/sizeof(ng_hci_node_neighbor_cache_entry_ep)) 557 558 #define NGM_HCI_NODE_GET_CON_LIST 111 /* HCI -> User */ 559 typedef struct { 560 u_int32_t num_connections; /* number of connections */ 561 } ng_hci_node_con_list_ep; 562 563 typedef struct { 564 u_int8_t link_type; /* ACL or SCO */ 565 u_int8_t encryption_mode; /* none, p2p, ... */ 566 u_int8_t mode; /* ACTIVE, HOLD ... */ 567 u_int8_t role; /* MASTER/SLAVE */ 568 u_int16_t state; /* connection state */ 569 u_int16_t reserved; /* place holder */ 570 u_int16_t pending; /* number of pending packets */ 571 u_int16_t queue_len; /* number of packets in queue */ 572 u_int16_t con_handle; /* connection handle */ 573 bdaddr_t bdaddr; /* remote bdaddr */ 574 } ng_hci_node_con_ep; 575 576 #define NG_HCI_MAX_CON_NUM \ 577 ((0xffff - sizeof(ng_hci_node_con_list_ep))/sizeof(ng_hci_node_con_ep)) 578 579 #define NGM_HCI_NODE_UP 112 /* HCI -> Upper */ 580 typedef struct { 581 u_int16_t pkt_size; /* max. ACL/SCO packet size (w/out header) */ 582 u_int16_t num_pkts; /* ACL/SCO packet queue size */ 583 u_int16_t reserved; /* place holder */ 584 bdaddr_t bdaddr; /* bdaddr */ 585 } ng_hci_node_up_ep; 586 587 #define NGM_HCI_SYNC_CON_QUEUE 113 /* HCI -> Upper */ 588 typedef struct { 589 u_int16_t con_handle; /* connection handle */ 590 u_int16_t completed; /* number of completed packets */ 591 } ng_hci_sync_con_queue_ep; 592 593 #define NGM_HCI_NODE_GET_LINK_POLICY_SETTINGS_MASK 114 /* HCI -> User */ 594 #define NGM_HCI_NODE_SET_LINK_POLICY_SETTINGS_MASK 115 /* User -> HCI */ 595 typedef u_int16_t ng_hci_node_link_policy_mask_ep; 596 597 #define NGM_HCI_NODE_GET_PACKET_MASK 116 /* HCI -> User */ 598 #define NGM_HCI_NODE_SET_PACKET_MASK 117 /* User -> HCI */ 599 typedef u_int16_t ng_hci_node_packet_mask_ep; 600 601 #define NGM_HCI_NODE_GET_ROLE_SWITCH 118 /* HCI -> User */ 602 #define NGM_HCI_NODE_SET_ROLE_SWITCH 119 /* User -> HCI */ 603 typedef u_int16_t ng_hci_node_role_switch_ep; 604 605 /************************************************************************** 606 ************************************************************************** 607 ** Link control commands and return parameters 608 ************************************************************************** 609 **************************************************************************/ 610 611 #define NG_HCI_OGF_LINK_CONTROL 0x01 /* OpCode Group Field */ 612 613 #define NG_HCI_OCF_INQUIRY 0x0001 614 typedef struct { 615 u_int8_t lap[NG_HCI_LAP_SIZE]; /* LAP */ 616 u_int8_t inquiry_length; /* (N x 1.28) sec */ 617 u_int8_t num_responses; /* Max. # of responses before halted */ 618 } __attribute__ ((packed)) ng_hci_inquiry_cp; 619 /* No return parameter(s) */ 620 621 #define NG_HCI_OCF_INQUIRY_CANCEL 0x0002 622 /* No command parameter(s) */ 623 typedef ng_hci_status_rp ng_hci_inquiry_cancel_rp; 624 625 #define NG_HCI_OCF_PERIODIC_INQUIRY 0x0003 626 typedef struct { 627 u_int16_t max_period_length; /* Max. and min. amount of time */ 628 u_int16_t min_period_length; /* between consecutive inquiries */ 629 u_int8_t lap[NG_HCI_LAP_SIZE]; /* LAP */ 630 u_int8_t inquiry_length; /* (inquiry_length * 1.28) sec */ 631 u_int8_t num_responses; /* Max. # of responses */ 632 } __attribute__ ((packed)) ng_hci_periodic_inquiry_cp; 633 634 typedef ng_hci_status_rp ng_hci_periodic_inquiry_rp; 635 636 #define NG_HCI_OCF_EXIT_PERIODIC_INQUIRY 0x0004 637 /* No command parameter(s) */ 638 typedef ng_hci_status_rp ng_hci_exit_periodic_inquiry_rp; 639 640 #define NG_HCI_OCF_CREATE_CON 0x0005 641 typedef struct { 642 bdaddr_t bdaddr; /* destination address */ 643 u_int16_t pkt_type; /* packet type */ 644 u_int8_t page_scan_rep_mode; /* page scan repetition mode */ 645 u_int8_t page_scan_mode; /* page scan mode */ 646 u_int16_t clock_offset; /* clock offset */ 647 u_int8_t accept_role_switch; /* accept role switch? 0x00 - no */ 648 } __attribute__ ((packed)) ng_hci_create_con_cp; 649 /* No return parameter(s) */ 650 651 #define NG_HCI_OCF_DISCON 0x0006 652 typedef struct { 653 u_int16_t con_handle; /* connection handle */ 654 u_int8_t reason; /* reason to disconnect */ 655 } __attribute__ ((packed)) ng_hci_discon_cp; 656 /* No return parameter(s) */ 657 658 #define NG_HCI_OCF_ADD_SCO_CON 0x0007 659 typedef struct { 660 u_int16_t con_handle; /* connection handle */ 661 u_int16_t pkt_type; /* packet type */ 662 } __attribute__ ((packed)) ng_hci_add_sco_con_cp; 663 /* No return parameter(s) */ 664 665 #define NG_HCI_OCF_ACCEPT_CON 0x0009 666 typedef struct { 667 bdaddr_t bdaddr; /* address of unit to be connected */ 668 u_int8_t role; /* connection role */ 669 } __attribute__ ((packed)) ng_hci_accept_con_cp; 670 /* No return parameter(s) */ 671 672 #define NG_HCI_OCF_REJECT_CON 0x000a 673 typedef struct { 674 bdaddr_t bdaddr; /* remote address */ 675 u_int8_t reason; /* reason to reject */ 676 } __attribute__ ((packed)) ng_hci_reject_con_cp; 677 /* No return parameter(s) */ 678 679 #define NG_HCI_OCF_LINK_KEY_REP 0x000b 680 typedef struct { 681 bdaddr_t bdaddr; /* remote address */ 682 u_int8_t key[NG_HCI_KEY_SIZE]; /* key */ 683 } __attribute__ ((packed)) ng_hci_link_key_rep_cp; 684 685 typedef struct { 686 u_int8_t status; /* 0x00 - success */ 687 bdaddr_t bdaddr; /* unit address */ 688 } __attribute__ ((packed)) ng_hci_link_key_rep_rp; 689 690 #define NG_HCI_OCF_LINK_KEY_NEG_REP 0x000c 691 typedef struct { 692 bdaddr_t bdaddr; /* remote address */ 693 } __attribute__ ((packed)) ng_hci_link_key_neg_rep_cp; 694 695 typedef struct { 696 u_int8_t status; /* 0x00 - success */ 697 bdaddr_t bdaddr; /* unit address */ 698 } __attribute__ ((packed)) ng_hci_link_key_neg_rep_rp; 699 700 #define NG_HCI_OCF_PIN_CODE_REP 0x000d 701 typedef struct { 702 bdaddr_t bdaddr; /* remote address */ 703 u_int8_t pin_size; /* pin code length (in bytes) */ 704 u_int8_t pin[NG_HCI_PIN_SIZE]; /* pin code */ 705 } __attribute__ ((packed)) ng_hci_pin_code_rep_cp; 706 707 typedef struct { 708 u_int8_t status; /* 0x00 - success */ 709 bdaddr_t bdaddr; /* unit address */ 710 } __attribute__ ((packed)) ng_hci_pin_code_rep_rp; 711 712 #define NG_HCI_OCF_PIN_CODE_NEG_REP 0x000e 713 typedef struct { 714 bdaddr_t bdaddr; /* remote address */ 715 } __attribute__ ((packed)) ng_hci_pin_code_neg_rep_cp; 716 717 typedef struct { 718 u_int8_t status; /* 0x00 - success */ 719 bdaddr_t bdaddr; /* unit address */ 720 } __attribute__ ((packed)) ng_hci_pin_code_neg_rep_rp; 721 722 #define NG_HCI_OCF_CHANGE_CON_PKT_TYPE 0x000f 723 typedef struct { 724 u_int16_t con_handle; /* connection handle */ 725 u_int16_t pkt_type; /* packet type */ 726 } __attribute__ ((packed)) ng_hci_change_con_pkt_type_cp; 727 /* No return parameter(s) */ 728 729 #define NG_HCI_OCF_AUTH_REQ 0x0011 730 typedef struct { 731 u_int16_t con_handle; /* connection handle */ 732 } __attribute__ ((packed)) ng_hci_auth_req_cp; 733 /* No return parameter(s) */ 734 735 #define NG_HCI_OCF_SET_CON_ENCRYPTION 0x0013 736 typedef struct { 737 u_int16_t con_handle; /* connection handle */ 738 u_int8_t encryption_enable; /* 0x00 - disable, 0x01 - enable */ 739 } __attribute__ ((packed)) ng_hci_set_con_encryption_cp; 740 /* No return parameter(s) */ 741 742 #define NG_HCI_OCF_CHANGE_CON_LINK_KEY 0x0015 743 typedef struct { 744 u_int16_t con_handle; /* connection handle */ 745 } __attribute__ ((packed)) ng_hci_change_con_link_key_cp; 746 /* No return parameter(s) */ 747 748 #define NG_HCI_OCF_MASTER_LINK_KEY 0x0017 749 typedef struct { 750 u_int8_t key_flag; /* key flag */ 751 } __attribute__ ((packed)) ng_hci_master_link_key_cp; 752 /* No return parameter(s) */ 753 754 #define NG_HCI_OCF_REMOTE_NAME_REQ 0x0019 755 typedef struct { 756 bdaddr_t bdaddr; /* remote address */ 757 u_int8_t page_scan_rep_mode; /* page scan repetition mode */ 758 u_int8_t page_scan_mode; /* page scan mode */ 759 u_int16_t clock_offset; /* clock offset */ 760 } __attribute__ ((packed)) ng_hci_remote_name_req_cp; 761 /* No return parameter(s) */ 762 763 #define NG_HCI_OCF_READ_REMOTE_FEATURES 0x001b 764 typedef struct { 765 u_int16_t con_handle; /* connection handle */ 766 } __attribute__ ((packed)) ng_hci_read_remote_features_cp; 767 /* No return parameter(s) */ 768 769 #define NG_HCI_OCF_READ_REMOTE_VER_INFO 0x001d 770 typedef struct { 771 u_int16_t con_handle; /* connection handle */ 772 } __attribute__ ((packed)) ng_hci_read_remote_ver_info_cp; 773 /* No return parameter(s) */ 774 775 #define NG_HCI_OCF_READ_CLOCK_OFFSET 0x001f 776 typedef struct { 777 u_int16_t con_handle; /* connection handle */ 778 } __attribute__ ((packed)) ng_hci_read_clock_offset_cp; 779 /* No return parameter(s) */ 780 781 /************************************************************************** 782 ************************************************************************** 783 ** Link policy commands and return parameters 784 ************************************************************************** 785 **************************************************************************/ 786 787 #define NG_HCI_OGF_LINK_POLICY 0x02 /* OpCode Group Field */ 788 789 #define NG_HCI_OCF_HOLD_MODE 0x0001 790 typedef struct { 791 u_int16_t con_handle; /* connection handle */ 792 u_int16_t max_interval; /* (max_interval * 0.625) msec */ 793 u_int16_t min_interval; /* (max_interval * 0.625) msec */ 794 } __attribute__ ((packed)) ng_hci_hold_mode_cp; 795 /* No return parameter(s) */ 796 797 #define NG_HCI_OCF_SNIFF_MODE 0x0003 798 typedef struct { 799 u_int16_t con_handle; /* connection handle */ 800 u_int16_t max_interval; /* (max_interval * 0.625) msec */ 801 u_int16_t min_interval; /* (max_interval * 0.625) msec */ 802 u_int16_t attempt; /* (2 * attempt - 1) * 0.625 msec */ 803 u_int16_t timeout; /* (2 * attempt - 1) * 0.625 msec */ 804 } __attribute__ ((packed)) ng_hci_sniff_mode_cp; 805 /* No return parameter(s) */ 806 807 #define NG_HCI_OCF_EXIT_SNIFF_MODE 0x0004 808 typedef struct { 809 u_int16_t con_handle; /* connection handle */ 810 } __attribute__ ((packed)) ng_hci_exit_sniff_mode_cp; 811 /* No return parameter(s) */ 812 813 #define NG_HCI_OCF_PARK_MODE 0x0005 814 typedef struct { 815 u_int16_t con_handle; /* connection handle */ 816 u_int16_t max_interval; /* (max_interval * 0.625) msec */ 817 u_int16_t min_interval; /* (max_interval * 0.625) msec */ 818 } __attribute__ ((packed)) ng_hci_park_mode_cp; 819 /* No return parameter(s) */ 820 821 #define NG_HCI_OCF_EXIT_PARK_MODE 0x0006 822 typedef struct { 823 u_int16_t con_handle; /* connection handle */ 824 } __attribute__ ((packed)) ng_hci_exit_park_mode_cp; 825 /* No return parameter(s) */ 826 827 #define NG_HCI_OCF_QOS_SETUP 0x0007 828 typedef struct { 829 u_int16_t con_handle; /* connection handle */ 830 u_int8_t flags; /* reserved for future use */ 831 u_int8_t service_type; /* service type */ 832 u_int32_t token_rate; /* bytes per second */ 833 u_int32_t peak_bandwidth; /* bytes per second */ 834 u_int32_t latency; /* microseconds */ 835 u_int32_t delay_variation; /* microseconds */ 836 } __attribute__ ((packed)) ng_hci_qos_setup_cp; 837 /* No return parameter(s) */ 838 839 #define NG_HCI_OCF_ROLE_DISCOVERY 0x0009 840 typedef struct { 841 u_int16_t con_handle; /* connection handle */ 842 } __attribute__ ((packed)) ng_hci_role_discovery_cp; 843 844 typedef struct { 845 u_int8_t status; /* 0x00 - success */ 846 u_int16_t con_handle; /* connection handle */ 847 u_int8_t role; /* role for the connection handle */ 848 } __attribute__ ((packed)) ng_hci_role_discovery_rp; 849 850 #define NG_HCI_OCF_SWITCH_ROLE 0x000b 851 typedef struct { 852 bdaddr_t bdaddr; /* remote address */ 853 u_int8_t role; /* new local role */ 854 } __attribute__ ((packed)) ng_hci_switch_role_cp; 855 /* No return parameter(s) */ 856 857 #define NG_HCI_OCF_READ_LINK_POLICY_SETTINGS 0x000c 858 typedef struct { 859 u_int16_t con_handle; /* connection handle */ 860 } __attribute__ ((packed)) ng_hci_read_link_policy_settings_cp; 861 862 typedef struct { 863 u_int8_t status; /* 0x00 - success */ 864 u_int16_t con_handle; /* connection handle */ 865 u_int16_t settings; /* link policy settings */ 866 } __attribute__ ((packed)) ng_hci_read_link_policy_settings_rp; 867 868 #define NG_HCI_OCF_WRITE_LINK_POLICY_SETTINGS 0x000d 869 typedef struct { 870 u_int16_t con_handle; /* connection handle */ 871 u_int16_t settings; /* link policy settings */ 872 } __attribute__ ((packed)) ng_hci_write_link_policy_settings_cp; 873 874 typedef struct { 875 u_int8_t status; /* 0x00 - success */ 876 u_int16_t con_handle; /* connection handle */ 877 } __attribute__ ((packed)) ng_hci_write_link_policy_settings_rp; 878 879 /************************************************************************** 880 ************************************************************************** 881 ** Host controller and baseband commands and return parameters 882 ************************************************************************** 883 **************************************************************************/ 884 885 #define NG_HCI_OGF_HC_BASEBAND 0x03 /* OpCode Group Field */ 886 887 #define NG_HCI_OCF_SET_EVENT_MASK 0x0001 888 typedef struct { 889 u_int8_t event_mask[NG_HCI_EVENT_MASK_SIZE]; /* event_mask */ 890 } __attribute__ ((packed)) ng_hci_set_event_mask_cp; 891 892 typedef ng_hci_status_rp ng_hci_set_event_mask_rp; 893 894 #define NG_HCI_OCF_RESET 0x0003 895 /* No command parameter(s) */ 896 typedef ng_hci_status_rp ng_hci_reset_rp; 897 898 #define NG_HCI_OCF_SET_EVENT_FILTER 0x0005 899 typedef struct { 900 u_int8_t filter_type; /* filter type */ 901 u_int8_t filter_condition_type; /* filter condition type */ 902 u_int8_t condition[0]; /* conditions - variable size */ 903 } __attribute__ ((packed)) ng_hci_set_event_filter_cp; 904 905 typedef ng_hci_status_rp ng_hci_set_event_filter_rp; 906 907 #define NG_HCI_OCF_FLUSH 0x0008 908 typedef struct { 909 u_int16_t con_handle; /* connection handle */ 910 } __attribute__ ((packed)) ng_hci_flush_cp; 911 912 typedef struct { 913 u_int8_t status; /* 0x00 - success */ 914 u_int16_t con_handle; /* connection handle */ 915 } __attribute__ ((packed)) ng_hci_flush_rp; 916 917 #define NG_HCI_OCF_READ_PIN_TYPE 0x0009 918 /* No command parameter(s) */ 919 typedef struct { 920 u_int8_t status; /* 0x00 - success */ 921 u_int8_t pin_type; /* PIN type */ 922 } __attribute__ ((packed)) ng_hci_read_pin_type_rp; 923 924 #define NG_HCI_OCF_WRITE_PIN_TYPE 0x000a 925 typedef struct { 926 u_int8_t pin_type; /* PIN type */ 927 } __attribute__ ((packed)) ng_hci_write_pin_type_cp; 928 929 typedef ng_hci_status_rp ng_hci_write_pin_type_rp; 930 931 #define NG_HCI_OCF_CREATE_NEW_UNIT_KEY 0x000b 932 /* No command parameter(s) */ 933 typedef ng_hci_status_rp ng_hci_create_new_unit_key_rp; 934 935 #define NG_HCI_OCF_READ_STORED_LINK_KEY 0x000d 936 typedef struct { 937 bdaddr_t bdaddr; /* address */ 938 u_int8_t read_all; /* read all keys? 0x01 - yes */ 939 } __attribute__ ((packed)) ng_hci_read_stored_link_key_cp; 940 941 typedef struct { 942 u_int8_t status; /* 0x00 - success */ 943 u_int16_t max_num_keys; /* Max. number of keys */ 944 u_int16_t num_keys_read; /* Number of stored keys */ 945 } __attribute__ ((packed)) ng_hci_read_stored_link_key_rp; 946 947 #define NG_HCI_OCF_WRITE_STORED_LINK_KEY 0x0011 948 typedef struct { 949 u_int8_t num_keys_write; /* # of keys to write */ 950 /* these are repeated "num_keys_write" times 951 bdaddr_t bdaddr; --- remote address(es) 952 u_int8_t key[NG_HCI_KEY_SIZE]; --- key(s) */ 953 } __attribute__ ((packed)) ng_hci_write_stored_link_key_cp; 954 955 typedef struct { 956 u_int8_t status; /* 0x00 - success */ 957 u_int8_t num_keys_written; /* # of keys successfully written */ 958 } __attribute__ ((packed)) ng_hci_write_stored_link_key_rp; 959 960 #define NG_HCI_OCF_DELETE_STORED_LINK_KEY 0x0012 961 typedef struct { 962 bdaddr_t bdaddr; /* address */ 963 u_int8_t delete_all; /* delete all keys? 0x01 - yes */ 964 } __attribute__ ((packed)) ng_hci_delete_stored_link_key_cp; 965 966 typedef struct { 967 u_int8_t status; /* 0x00 - success */ 968 u_int16_t num_keys_deleted; /* Number of keys deleted */ 969 } __attribute__ ((packed)) ng_hci_delete_stored_link_key_rp; 970 971 #define NG_HCI_OCF_CHANGE_LOCAL_NAME 0x0013 972 typedef struct { 973 char name[NG_HCI_UNIT_NAME_SIZE]; /* new unit name */ 974 } __attribute__ ((packed)) ng_hci_change_local_name_cp; 975 976 typedef ng_hci_status_rp ng_hci_change_local_name_rp; 977 978 #define NG_HCI_OCF_READ_LOCAL_NAME 0x0014 979 /* No command parameter(s) */ 980 typedef struct { 981 u_int8_t status; /* 0x00 - success */ 982 char name[NG_HCI_UNIT_NAME_SIZE]; /* unit name */ 983 } __attribute__ ((packed)) ng_hci_read_local_name_rp; 984 985 #define NG_HCI_OCF_READ_CON_ACCEPT_TIMO 0x0015 986 /* No command parameter(s) */ 987 typedef struct { 988 u_int8_t status; /* 0x00 - success */ 989 u_int16_t timeout; /* (timeout * 0.625) msec */ 990 } __attribute__ ((packed)) ng_hci_read_con_accept_timo_rp; 991 992 #define NG_HCI_OCF_WRITE_CON_ACCEPT_TIMO 0x0016 993 typedef struct { 994 u_int16_t timeout; /* (timeout * 0.625) msec */ 995 } __attribute__ ((packed)) ng_hci_write_con_accept_timo_cp; 996 997 typedef ng_hci_status_rp ng_hci_write_con_accept_timo_rp; 998 999 #define NG_HCI_OCF_READ_PAGE_TIMO 0x0017 1000 /* No command parameter(s) */ 1001 typedef struct { 1002 u_int8_t status; /* 0x00 - success */ 1003 u_int16_t timeout; /* (timeout * 0.625) msec */ 1004 } __attribute__ ((packed)) ng_hci_read_page_timo_rp; 1005 1006 #define NG_HCI_OCF_WRITE_PAGE_TIMO 0x0018 1007 typedef struct { 1008 u_int16_t timeout; /* (timeout * 0.625) msec */ 1009 } __attribute__ ((packed)) ng_hci_write_page_timo_cp; 1010 1011 typedef ng_hci_status_rp ng_hci_write_page_timo_rp; 1012 1013 #define NG_HCI_OCF_READ_SCAN_ENABLE 0x0019 1014 /* No command parameter(s) */ 1015 typedef struct { 1016 u_int8_t status; /* 0x00 - success */ 1017 u_int8_t scan_enable; /* Scan enable */ 1018 } __attribute__ ((packed)) ng_hci_read_scan_enable_rp; 1019 1020 #define NG_HCI_OCF_WRITE_SCAN_ENABLE 0x001a 1021 typedef struct { 1022 u_int8_t scan_enable; /* Scan enable */ 1023 } __attribute__ ((packed)) ng_hci_write_scan_enable_cp; 1024 1025 typedef ng_hci_status_rp ng_hci_write_scan_enable_rp; 1026 1027 #define NG_HCI_OCF_READ_PAGE_SCAN_ACTIVITY 0x001b 1028 /* No command parameter(s) */ 1029 typedef struct { 1030 u_int8_t status; /* 0x00 - success */ 1031 u_int16_t page_scan_interval; /* interval * 0.625 msec */ 1032 u_int16_t page_scan_window; /* window * 0.625 msec */ 1033 } __attribute__ ((packed)) ng_hci_read_page_scan_activity_rp; 1034 1035 #define NG_HCI_OCF_WRITE_PAGE_SCAN_ACTIVITY 0x001c 1036 typedef struct { 1037 u_int16_t page_scan_interval; /* interval * 0.625 msec */ 1038 u_int16_t page_scan_window; /* window * 0.625 msec */ 1039 } __attribute__ ((packed)) ng_hci_write_page_scan_activity_cp; 1040 1041 typedef ng_hci_status_rp ng_hci_write_page_scan_activity_rp; 1042 1043 #define NG_HCI_OCF_READ_INQUIRY_SCAN_ACTIVITY 0x001d 1044 /* No command parameter(s) */ 1045 typedef struct { 1046 u_int8_t status; /* 0x00 - success */ 1047 u_int16_t inquiry_scan_interval; /* interval * 0.625 msec */ 1048 u_int16_t inquiry_scan_window; /* window * 0.625 msec */ 1049 } __attribute__ ((packed)) ng_hci_read_inquiry_scan_activity_rp; 1050 1051 #define NG_HCI_OCF_WRITE_INQUIRY_SCAN_ACTIVITY 0x001e 1052 typedef struct { 1053 u_int16_t inquiry_scan_interval; /* interval * 0.625 msec */ 1054 u_int16_t inquiry_scan_window; /* window * 0.625 msec */ 1055 } __attribute__ ((packed)) ng_hci_write_inquiry_scan_activity_cp; 1056 1057 typedef ng_hci_status_rp ng_hci_write_inquiry_scan_activity_rp; 1058 1059 #define NG_HCI_OCF_READ_AUTH_ENABLE 0x001f 1060 /* No command parameter(s) */ 1061 typedef struct { 1062 u_int8_t status; /* 0x00 - success */ 1063 u_int8_t auth_enable; /* 0x01 - enabled */ 1064 } __attribute__ ((packed)) ng_hci_read_auth_enable_rp; 1065 1066 #define NG_HCI_OCF_WRITE_AUTH_ENABLE 0x0020 1067 typedef struct { 1068 u_int8_t auth_enable; /* 0x01 - enabled */ 1069 } __attribute__ ((packed)) ng_hci_write_auth_enable_cp; 1070 1071 typedef ng_hci_status_rp ng_hci_write_auth_enable_rp; 1072 1073 #define NG_HCI_OCF_READ_ENCRYPTION_MODE 0x0021 1074 /* No command parameter(s) */ 1075 typedef struct { 1076 u_int8_t status; /* 0x00 - success */ 1077 u_int8_t encryption_mode; /* encryption mode */ 1078 } __attribute__ ((packed)) ng_hci_read_encryption_mode_rp; 1079 1080 #define NG_HCI_OCF_WRITE_ENCRYPTION_MODE 0x0022 1081 typedef struct { 1082 u_int8_t encryption_mode; /* encryption mode */ 1083 } __attribute__ ((packed)) ng_hci_write_encryption_mode_cp; 1084 1085 typedef ng_hci_status_rp ng_hci_write_encryption_mode_rp; 1086 1087 #define NG_HCI_OCF_READ_UNIT_CLASS 0x0023 1088 /* No command parameter(s) */ 1089 typedef struct { 1090 u_int8_t status; /* 0x00 - success */ 1091 u_int8_t uclass[NG_HCI_CLASS_SIZE]; /* unit class */ 1092 } __attribute__ ((packed)) ng_hci_read_unit_class_rp; 1093 1094 #define NG_HCI_OCF_WRITE_UNIT_CLASS 0x0024 1095 typedef struct { 1096 u_int8_t uclass[NG_HCI_CLASS_SIZE]; /* unit class */ 1097 } __attribute__ ((packed)) ng_hci_write_unit_class_cp; 1098 1099 typedef ng_hci_status_rp ng_hci_write_unit_class_rp; 1100 1101 #define NG_HCI_OCF_READ_VOICE_SETTINGS 0x0025 1102 /* No command parameter(s) */ 1103 typedef struct { 1104 u_int8_t status; /* 0x00 - success */ 1105 u_int16_t settings; /* voice settings */ 1106 } __attribute__ ((packed)) ng_hci_read_voice_settings_rp; 1107 1108 #define NG_HCI_OCF_WRITE_VOICE_SETTINGS 0x0026 1109 typedef struct { 1110 u_int16_t settings; /* voice settings */ 1111 } __attribute__ ((packed)) ng_hci_write_voice_settings_cp; 1112 1113 typedef ng_hci_status_rp ng_hci_write_voice_settings_rp; 1114 1115 #define NG_HCI_OCF_READ_AUTO_FLUSH_TIMO 0x0027 1116 typedef struct { 1117 u_int16_t con_handle; /* connection handle */ 1118 } __attribute__ ((packed)) ng_hci_read_auto_flush_timo_cp; 1119 1120 typedef struct { 1121 u_int8_t status; /* 0x00 - success */ 1122 u_int16_t con_handle; /* connection handle */ 1123 u_int16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */ 1124 } __attribute__ ((packed)) ng_hci_read_auto_flush_timo_rp; 1125 1126 #define NG_HCI_OCF_WRITE_AUTO_FLUSH_TIMO 0x0028 1127 typedef struct { 1128 u_int16_t con_handle; /* connection handle */ 1129 u_int16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */ 1130 } __attribute__ ((packed)) ng_hci_write_auto_flush_timo_cp; 1131 1132 typedef struct { 1133 u_int8_t status; /* 0x00 - success */ 1134 u_int16_t con_handle; /* connection handle */ 1135 } __attribute__ ((packed)) ng_hci_write_auto_flush_timo_rp; 1136 1137 #define NG_HCI_OCF_READ_NUM_BROADCAST_RETRANS 0x0029 1138 /* No command parameter(s) */ 1139 typedef struct { 1140 u_int8_t status; /* 0x00 - success */ 1141 u_int8_t counter; /* number of broadcast retransmissions */ 1142 } __attribute__ ((packed)) ng_hci_read_num_broadcast_retrans_rp; 1143 1144 #define NG_HCI_OCF_WRITE_NUM_BROADCAST_RETRANS 0x002a 1145 typedef struct { 1146 u_int8_t counter; /* number of broadcast retransmissions */ 1147 } __attribute__ ((packed)) ng_hci_write_num_broadcast_retrans_cp; 1148 1149 typedef ng_hci_status_rp ng_hci_write_num_broadcast_retrans_rp; 1150 1151 #define NG_HCI_OCF_READ_HOLD_MODE_ACTIVITY 0x002b 1152 /* No command parameter(s) */ 1153 typedef struct { 1154 u_int8_t status; /* 0x00 - success */ 1155 u_int8_t hold_mode_activity; /* Hold mode activities */ 1156 } __attribute__ ((packed)) ng_hci_read_hold_mode_activity_rp; 1157 1158 #define NG_HCI_OCF_WRITE_HOLD_MODE_ACTIVITY 0x002c 1159 typedef struct { 1160 u_int8_t hold_mode_activity; /* Hold mode activities */ 1161 } __attribute__ ((packed)) ng_hci_write_hold_mode_activity_cp; 1162 1163 typedef ng_hci_status_rp ng_hci_write_hold_mode_activity_rp; 1164 1165 #define NG_HCI_OCF_READ_XMIT_LEVEL 0x002d 1166 typedef struct { 1167 u_int16_t con_handle; /* connection handle */ 1168 u_int8_t type; /* Xmit level type */ 1169 } __attribute__ ((packed)) ng_hci_read_xmit_level_cp; 1170 1171 typedef struct { 1172 u_int8_t status; /* 0x00 - success */ 1173 u_int16_t con_handle; /* connection handle */ 1174 char level; /* -30 <= level <= 30 dBm */ 1175 } __attribute__ ((packed)) ng_hci_read_xmit_level_rp; 1176 1177 #define NG_HCI_OCF_READ_SCO_FLOW_CONTROL 0x002e 1178 /* No command parameter(s) */ 1179 typedef struct { 1180 u_int8_t status; /* 0x00 - success */ 1181 u_int8_t flow_control; /* 0x00 - disabled */ 1182 } __attribute__ ((packed)) ng_hci_read_sco_flow_control_rp; 1183 1184 #define NG_HCI_OCF_WRITE_SCO_FLOW_CONTROL 0x002f 1185 typedef struct { 1186 u_int8_t flow_control; /* 0x00 - disabled */ 1187 } __attribute__ ((packed)) ng_hci_write_sco_flow_control_cp; 1188 1189 typedef ng_hci_status_rp ng_hci_write_sco_flow_control_rp; 1190 1191 #define NG_HCI_OCF_H2HC_FLOW_CONTROL 0x0031 1192 typedef struct { 1193 u_int8_t h2hc_flow; /* Host to Host controller flow control */ 1194 } __attribute__ ((packed)) ng_hci_h2hc_flow_control_cp; 1195 1196 typedef ng_hci_status_rp ng_hci_h2hc_flow_control_rp; 1197 1198 #define NG_HCI_OCF_HOST_BUFFER_SIZE 0x0033 1199 typedef struct { 1200 u_int16_t max_acl_size; /* Max. size of ACL packet (bytes) */ 1201 u_int8_t max_sco_size; /* Max. size of SCO packet (bytes) */ 1202 u_int16_t num_acl_pkt; /* Max. number of ACL packets */ 1203 u_int16_t num_sco_pkt; /* Max. number of SCO packets */ 1204 } __attribute__ ((packed)) ng_hci_host_buffer_size_cp; 1205 1206 typedef ng_hci_status_rp ng_hci_host_buffer_size_rp; 1207 1208 #define NG_HCI_OCF_HOST_NUM_COMPL_PKTS 0x0035 1209 typedef struct { 1210 u_int8_t num_con_handles; /* # of connection handles */ 1211 /* these are repeated "num_con_handles" times 1212 u_int16_t con_handle; --- connection handle(s) 1213 u_int16_t compl_pkt; --- # of completed packets */ 1214 } __attribute__ ((packed)) ng_hci_host_num_compl_pkts_cp; 1215 /* No return parameter(s) */ 1216 1217 #define NG_HCI_OCF_READ_LINK_SUPERVISION_TIMO 0x0036 1218 typedef struct { 1219 u_int16_t con_handle; /* connection handle */ 1220 } __attribute__ ((packed)) ng_hci_read_link_supervision_timo_cp; 1221 1222 typedef struct { 1223 u_int8_t status; /* 0x00 - success */ 1224 u_int16_t con_handle; /* connection handle */ 1225 u_int16_t timeout; /* Link supervision timeout * 0.625 msec */ 1226 } __attribute__ ((packed)) ng_hci_read_link_supervision_timo_rp; 1227 1228 #define NG_HCI_OCF_WRITE_LINK_SUPERVISION_TIMO 0x0037 1229 typedef struct { 1230 u_int16_t con_handle; /* connection handle */ 1231 u_int16_t timeout; /* Link supervision timeout * 0.625 msec */ 1232 } __attribute__ ((packed)) ng_hci_write_link_supervision_timo_cp; 1233 1234 typedef struct { 1235 u_int8_t status; /* 0x00 - success */ 1236 u_int16_t con_handle; /* connection handle */ 1237 } __attribute__ ((packed)) ng_hci_write_link_supervision_timo_rp; 1238 1239 #define NG_HCI_OCF_READ_SUPPORTED_IAC_NUM 0x0038 1240 /* No command parameter(s) */ 1241 typedef struct { 1242 u_int8_t status; /* 0x00 - success */ 1243 u_int8_t num_iac; /* # of supported IAC during scan */ 1244 } __attribute__ ((packed)) ng_hci_read_supported_iac_num_rp; 1245 1246 #define NG_HCI_OCF_READ_IAC_LAP 0x0039 1247 /* No command parameter(s) */ 1248 typedef struct { 1249 u_int8_t status; /* 0x00 - success */ 1250 u_int8_t num_iac; /* # of IAC */ 1251 /* these are repeated "num_iac" times 1252 u_int8_t laps[NG_HCI_LAP_SIZE]; --- LAPs */ 1253 } __attribute__ ((packed)) ng_hci_read_iac_lap_rp; 1254 1255 #define NG_HCI_OCF_WRITE_IAC_LAP 0x003a 1256 typedef struct { 1257 u_int8_t num_iac; /* # of IAC */ 1258 /* these are repeated "num_iac" times 1259 u_int8_t laps[NG_HCI_LAP_SIZE]; --- LAPs */ 1260 } __attribute__ ((packed)) ng_hci_write_iac_lap_cp; 1261 1262 typedef ng_hci_status_rp ng_hci_write_iac_lap_rp; 1263 1264 #define NG_HCI_OCF_READ_PAGE_SCAN_PERIOD 0x003b 1265 /* No command parameter(s) */ 1266 typedef struct { 1267 u_int8_t status; /* 0x00 - success */ 1268 u_int8_t page_scan_period_mode; /* Page scan period mode */ 1269 } __attribute__ ((packed)) ng_hci_read_page_scan_period_rp; 1270 1271 #define NG_HCI_OCF_WRITE_PAGE_SCAN_PERIOD 0x003c 1272 typedef struct { 1273 u_int8_t page_scan_period_mode; /* Page scan period mode */ 1274 } __attribute__ ((packed)) ng_hci_write_page_scan_period_cp; 1275 1276 typedef ng_hci_status_rp ng_hci_write_page_scan_period_rp; 1277 1278 #define NG_HCI_OCF_READ_PAGE_SCAN 0x003d 1279 /* No command parameter(s) */ 1280 typedef struct { 1281 u_int8_t status; /* 0x00 - success */ 1282 u_int8_t page_scan_mode; /* Page scan mode */ 1283 } __attribute__ ((packed)) ng_hci_read_page_scan_rp; 1284 1285 #define NG_HCI_OCF_WRITE_PAGE_SCAN 0x003e 1286 typedef struct { 1287 u_int8_t page_scan_mode; /* Page scan mode */ 1288 } __attribute__ ((packed)) ng_hci_write_page_scan_cp; 1289 1290 typedef ng_hci_status_rp ng_hci_write_page_scan_rp; 1291 1292 /************************************************************************** 1293 ************************************************************************** 1294 ** Informational commands and return parameters 1295 ** All commands in this category do not accept any parameters 1296 ************************************************************************** 1297 **************************************************************************/ 1298 1299 #define NG_HCI_OGF_INFO 0x04 /* OpCode Group Field */ 1300 1301 #define NG_HCI_OCF_READ_LOCAL_VER 0x0001 1302 typedef struct { 1303 u_int8_t status; /* 0x00 - success */ 1304 u_int8_t hci_version; /* HCI version */ 1305 u_int16_t hci_revision; /* HCI revision */ 1306 u_int8_t lmp_version; /* LMP version */ 1307 u_int16_t manufacturer; /* Hardware manufacturer name */ 1308 u_int16_t lmp_subversion; /* LMP sub-version */ 1309 } __attribute__ ((packed)) ng_hci_read_local_ver_rp; 1310 1311 #define NG_HCI_OCF_READ_LOCAL_FEATURES 0x0003 1312 typedef struct { 1313 u_int8_t status; /* 0x00 - success */ 1314 u_int8_t features[NG_HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ 1315 } __attribute__ ((packed)) ng_hci_read_local_features_rp; 1316 1317 #define NG_HCI_OCF_READ_BUFFER_SIZE 0x0005 1318 typedef struct { 1319 u_int8_t status; /* 0x00 - success */ 1320 u_int16_t max_acl_size; /* Max. size of ACL packet (bytes) */ 1321 u_int8_t max_sco_size; /* Max. size of SCO packet (bytes) */ 1322 u_int16_t num_acl_pkt; /* Max. number of ACL packets */ 1323 u_int16_t num_sco_pkt; /* Max. number of SCO packets */ 1324 } __attribute__ ((packed)) ng_hci_read_buffer_size_rp; 1325 1326 #define NG_HCI_OCF_READ_COUNTRY_CODE 0x0007 1327 typedef struct { 1328 u_int8_t status; /* 0x00 - success */ 1329 u_int8_t country_code; /* 0x00 - NAM, EUR, JP; 0x01 - France */ 1330 } __attribute__ ((packed)) ng_hci_read_country_code_rp; 1331 1332 #define NG_HCI_OCF_READ_BDADDR 0x0009 1333 typedef struct { 1334 u_int8_t status; /* 0x00 - success */ 1335 bdaddr_t bdaddr; /* unit address */ 1336 } __attribute__ ((packed)) ng_hci_read_bdaddr_rp; 1337 1338 /************************************************************************** 1339 ************************************************************************** 1340 ** Status commands and return parameters 1341 ************************************************************************** 1342 **************************************************************************/ 1343 1344 #define NG_HCI_OGF_STATUS 0x05 /* OpCode Group Field */ 1345 1346 #define NG_HCI_OCF_READ_FAILED_CONTACT_CNTR 0x0001 1347 typedef struct { 1348 u_int16_t con_handle; /* connection handle */ 1349 } __attribute__ ((packed)) ng_hci_read_failed_contact_cntr_cp; 1350 1351 typedef struct { 1352 u_int8_t status; /* 0x00 - success */ 1353 u_int16_t con_handle; /* connection handle */ 1354 u_int16_t counter; /* number of consecutive failed contacts */ 1355 } __attribute__ ((packed)) ng_hci_read_failed_contact_cntr_rp; 1356 1357 #define NG_HCI_OCF_RESET_FAILED_CONTACT_CNTR 0x0002 1358 typedef struct { 1359 u_int16_t con_handle; /* connection handle */ 1360 } __attribute__ ((packed)) ng_hci_reset_failed_contact_cntr_cp; 1361 1362 typedef struct { 1363 u_int8_t status; /* 0x00 - success */ 1364 u_int16_t con_handle; /* connection handle */ 1365 } __attribute__ ((packed)) ng_hci_reset_failed_contact_cntr_rp; 1366 1367 #define NG_HCI_OCF_GET_LINK_QUALITY 0x0003 1368 typedef struct { 1369 u_int16_t con_handle; /* connection handle */ 1370 } __attribute__ ((packed)) ng_hci_get_link_quality_cp; 1371 1372 typedef struct { 1373 u_int8_t status; /* 0x00 - success */ 1374 u_int16_t con_handle; /* connection handle */ 1375 u_int8_t quality; /* higher value means better quality */ 1376 } __attribute__ ((packed)) ng_hci_get_link_quality_rp; 1377 1378 #define NG_HCI_OCF_READ_RSSI 0x0005 1379 typedef struct { 1380 u_int16_t con_handle; /* connection handle */ 1381 } __attribute__ ((packed)) ng_hci_read_rssi_cp; 1382 1383 typedef struct { 1384 u_int8_t status; /* 0x00 - success */ 1385 u_int16_t con_handle; /* connection handle */ 1386 char rssi; /* -127 <= rssi <= 127 dB */ 1387 } __attribute__ ((packed)) ng_hci_read_rssi_rp; 1388 1389 /************************************************************************** 1390 ************************************************************************** 1391 ** Testing commands and return parameters 1392 ************************************************************************** 1393 **************************************************************************/ 1394 1395 #define NG_HCI_OGF_TESTING 0x06 /* OpCode Group Field */ 1396 1397 #define NG_HCI_OCF_READ_LOOPBACK_MODE 0x0001 1398 /* No command parameter(s) */ 1399 typedef struct { 1400 u_int8_t status; /* 0x00 - success */ 1401 u_int8_t lbmode; /* loopback mode */ 1402 } __attribute__ ((packed)) ng_hci_read_loopback_mode_rp; 1403 1404 #define NG_HCI_OCF_WRITE_LOOPBACK_MODE 0x0002 1405 typedef struct { 1406 u_int8_t lbmode; /* loopback mode */ 1407 } __attribute__ ((packed)) ng_hci_write_loopback_mode_cp; 1408 1409 typedef ng_hci_status_rp ng_hci_write_loopback_mode_rp; 1410 1411 #define NG_HCI_OCF_ENABLE_UNIT_UNDER_TEST 0x0003 1412 /* No command parameter(s) */ 1413 typedef ng_hci_status_rp ng_hci_enable_unit_under_test_rp; 1414 1415 /************************************************************************** 1416 ************************************************************************** 1417 ** Special HCI OpCode group field values 1418 ************************************************************************** 1419 **************************************************************************/ 1420 1421 #define NG_HCI_OGF_BT_LOGO 0x3e 1422 1423 #define NG_HCI_OGF_VENDOR 0x3f 1424 1425 /************************************************************************** 1426 ************************************************************************** 1427 ** Events and event parameters 1428 ************************************************************************** 1429 **************************************************************************/ 1430 1431 #define NG_HCI_EVENT_INQUIRY_COMPL 0x01 1432 typedef struct { 1433 u_int8_t status; /* 0x00 - success */ 1434 } __attribute__ ((packed)) ng_hci_inquiry_compl_ep; 1435 1436 #define NG_HCI_EVENT_INQUIRY_RESULT 0x02 1437 typedef struct { 1438 u_int8_t num_responses; /* number of responses */ 1439 /* ng_hci_inquiry_response[num_responses] -- see below */ 1440 } __attribute__ ((packed)) ng_hci_inquiry_result_ep; 1441 1442 typedef struct { 1443 bdaddr_t bdaddr; /* unit address */ 1444 u_int8_t page_scan_rep_mode; /* page scan rep. mode */ 1445 u_int8_t page_scan_period_mode; /* page scan period mode */ 1446 u_int8_t page_scan_mode; /* page scan mode */ 1447 u_int8_t class[NG_HCI_CLASS_SIZE]; /* unit class */ 1448 u_int16_t clock_offset; /* clock offset */ 1449 } __attribute__ ((packed)) ng_hci_inquiry_response; 1450 1451 #define NG_HCI_EVENT_CON_COMPL 0x03 1452 typedef struct { 1453 u_int8_t status; /* 0x00 - success */ 1454 u_int16_t con_handle; /* Connection handle */ 1455 bdaddr_t bdaddr; /* remote unit address */ 1456 u_int8_t link_type; /* Link type */ 1457 u_int8_t encryption_mode; /* Encryption mode */ 1458 } __attribute__ ((packed)) ng_hci_con_compl_ep; 1459 1460 #define NG_HCI_EVENT_CON_REQ 0x04 1461 typedef struct { 1462 bdaddr_t bdaddr; /* remote unit address */ 1463 u_int8_t uclass[NG_HCI_CLASS_SIZE]; /* remote unit class */ 1464 u_int8_t link_type; /* link type */ 1465 } __attribute__ ((packed)) ng_hci_con_req_ep; 1466 1467 #define NG_HCI_EVENT_DISCON_COMPL 0x05 1468 typedef struct { 1469 u_int8_t status; /* 0x00 - success */ 1470 u_int16_t con_handle; /* connection handle */ 1471 u_int8_t reason; /* reason to disconnect */ 1472 } __attribute__ ((packed)) ng_hci_discon_compl_ep; 1473 1474 #define NG_HCI_EVENT_AUTH_COMPL 0x06 1475 typedef struct { 1476 u_int8_t status; /* 0x00 - success */ 1477 u_int16_t con_handle; /* connection handle */ 1478 } __attribute__ ((packed)) ng_hci_auth_compl_ep; 1479 1480 #define NG_HCI_EVENT_REMOTE_NAME_REQ_COMPL 0x7 1481 typedef struct { 1482 u_int8_t status; /* 0x00 - success */ 1483 bdaddr_t bdaddr; /* remote unit address */ 1484 char name[NG_HCI_UNIT_NAME_SIZE]; /* remote unit name */ 1485 } __attribute__ ((packed)) ng_hci_remote_name_req_compl_ep; 1486 1487 #define NG_HCI_EVENT_ENCRYPTION_CHANGE 0x08 1488 typedef struct { 1489 u_int8_t status; /* 0x00 - success */ 1490 u_int16_t con_handle; /* Connection handle */ 1491 u_int8_t encryption_enable; /* 0x00 - disable */ 1492 } __attribute__ ((packed)) ng_hci_encryption_change_ep; 1493 1494 #define NG_HCI_EVENT_CHANGE_CON_LINK_KEY_COMPL 0x09 1495 typedef struct { 1496 u_int8_t status; /* 0x00 - success */ 1497 u_int16_t con_handle; /* Connection handle */ 1498 } __attribute__ ((packed)) ng_hci_change_con_link_key_compl_ep; 1499 1500 #define NG_HCI_EVENT_MASTER_LINK_KEY_COMPL 0x0a 1501 typedef struct { 1502 u_int8_t status; /* 0x00 - success */ 1503 u_int16_t con_handle; /* Connection handle */ 1504 u_int8_t key_flag; /* Key flag */ 1505 } __attribute__ ((packed)) ng_hci_master_link_key_compl_ep; 1506 1507 #define NG_HCI_EVENT_READ_REMOTE_FEATURES_COMPL 0x0b 1508 typedef struct { 1509 u_int8_t status; /* 0x00 - success */ 1510 u_int16_t con_handle; /* Connection handle */ 1511 u_int8_t features[NG_HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ 1512 } __attribute__ ((packed)) ng_hci_read_remote_features_compl_ep; 1513 1514 #define NG_HCI_EVENT_READ_REMOTE_VER_INFO_COMPL 0x0c 1515 typedef struct { 1516 u_int8_t status; /* 0x00 - success */ 1517 u_int16_t con_handle; /* Connection handle */ 1518 u_int8_t lmp_version; /* LMP version */ 1519 u_int16_t manufacturer; /* Hardware manufacturer name */ 1520 u_int16_t lmp_subversion; /* LMP sub-version */ 1521 } __attribute__ ((packed)) ng_hci_read_remote_ver_info_compl_ep; 1522 1523 #define NG_HCI_EVENT_QOS_SETUP_COMPL 0x0d 1524 typedef struct { 1525 u_int8_t status; /* 0x00 - success */ 1526 u_int16_t con_handle; /* connection handle */ 1527 u_int8_t flags; /* reserved for future use */ 1528 u_int8_t service_type; /* service type */ 1529 u_int32_t token_rate; /* bytes per second */ 1530 u_int32_t peak_bandwidth; /* bytes per second */ 1531 u_int32_t latency; /* microseconds */ 1532 u_int32_t delay_variation; /* microseconds */ 1533 } __attribute__ ((packed)) ng_hci_qos_setup_compl_ep; 1534 1535 #define NG_HCI_EVENT_COMMAND_COMPL 0x0e 1536 typedef struct { 1537 u_int8_t num_cmd_pkts; /* # of HCI command packets */ 1538 u_int16_t opcode; /* command OpCode */ 1539 /* command return parameters (if any) */ 1540 } __attribute__ ((packed)) ng_hci_command_compl_ep; 1541 1542 #define NG_HCI_EVENT_COMMAND_STATUS 0x0f 1543 typedef struct { 1544 u_int8_t status; /* 0x00 - pending */ 1545 u_int8_t num_cmd_pkts; /* # of HCI command packets */ 1546 u_int16_t opcode; /* command OpCode */ 1547 } __attribute__ ((packed)) ng_hci_command_status_ep; 1548 1549 #define NG_HCI_EVENT_HARDWARE_ERROR 0x10 1550 typedef struct { 1551 u_int8_t hardware_code; /* hardware error code */ 1552 } __attribute__ ((packed)) ng_hci_hardware_error_ep; 1553 1554 #define NG_HCI_EVENT_FLUSH_OCCUR 0x11 1555 typedef struct { 1556 u_int16_t con_handle; /* connection handle */ 1557 } __attribute__ ((packed)) ng_hci_flush_occur_ep; 1558 1559 #define NG_HCI_EVENT_ROLE_CHANGE 0x12 1560 typedef struct { 1561 u_int8_t status; /* 0x00 - success */ 1562 bdaddr_t bdaddr; /* address of remote unit */ 1563 u_int8_t role; /* new connection role */ 1564 } __attribute__ ((packed)) ng_hci_role_change_ep; 1565 1566 #define NG_HCI_EVENT_NUM_COMPL_PKTS 0x13 1567 typedef struct { 1568 u_int8_t num_con_handles; /* # of connection handles */ 1569 /* these are repeated "num_con_handles" times 1570 u_int16_t con_handle; --- connection handle(s) 1571 u_int16_t compl_pkt; --- # of completed packets */ 1572 } __attribute__ ((packed)) ng_hci_num_compl_pkts_ep; 1573 1574 #define NG_HCI_EVENT_MODE_CHANGE 0x14 1575 typedef struct { 1576 u_int8_t status; /* 0x00 - success */ 1577 u_int16_t con_handle; /* connection handle */ 1578 u_int8_t unit_mode; /* remote unit mode */ 1579 u_int16_t interval; /* interval * 0.625 msec */ 1580 } __attribute__ ((packed)) ng_hci_mode_change_ep; 1581 1582 #define NG_HCI_EVENT_RETURN_LINK_KEYS 0x15 1583 typedef struct { 1584 u_int8_t num_keys; /* # of keys */ 1585 /* these are repeated "num_keys" times 1586 bdaddr_t bdaddr; --- remote address(es) 1587 u_int8_t key[NG_HCI_KEY_SIZE]; --- key(s) */ 1588 } __attribute__ ((packed)) ng_hci_return_link_keys_ep; 1589 1590 #define NG_HCI_EVENT_PIN_CODE_REQ 0x16 1591 typedef struct { 1592 bdaddr_t bdaddr; /* remote unit address */ 1593 } __attribute__ ((packed)) ng_hci_pin_code_req_ep; 1594 1595 #define NG_HCI_EVENT_LINK_KEY_REQ 0x17 1596 typedef struct { 1597 bdaddr_t bdaddr; /* remote unit address */ 1598 } __attribute__ ((packed)) ng_hci_link_key_req_ep; 1599 1600 #define NG_HCI_EVENT_LINK_KEY_NOTIFICATION 0x18 1601 typedef struct { 1602 bdaddr_t bdaddr; /* remote unit address */ 1603 u_int8_t key[NG_HCI_KEY_SIZE]; /* link key */ 1604 u_int8_t key_type; /* type of the key */ 1605 } __attribute__ ((packed)) ng_hci_link_key_notification_ep; 1606 1607 #define NG_HCI_EVENT_LOOPBACK_COMMAND 0x19 1608 typedef struct { 1609 u_int8_t command[0]; /* Command packet */ 1610 } __attribute__ ((packed)) ng_hci_loopback_command_ep; 1611 1612 #define NG_HCI_EVENT_DATA_BUFFER_OVERFLOW 0x1a 1613 typedef struct { 1614 u_int8_t link_type; /* Link type */ 1615 } __attribute__ ((packed)) ng_hci_data_buffer_overflow_ep; 1616 1617 #define NG_HCI_EVENT_MAX_SLOT_CHANGE 0x1b 1618 typedef struct { 1619 u_int16_t con_handle; /* connection handle */ 1620 u_int8_t lmp_max_slots; /* Max. # of slots allowed */ 1621 } __attribute__ ((packed)) ng_hci_max_slot_change_ep; 1622 1623 #define NG_HCI_EVENT_READ_CLOCK_OFFSET_COMPL 0x1c 1624 typedef struct { 1625 u_int8_t status; /* 0x00 - success */ 1626 u_int16_t con_handle; /* Connection handle */ 1627 u_int16_t clock_offset; /* Clock offset */ 1628 } __attribute__ ((packed)) ng_hci_read_clock_offset_compl_ep; 1629 1630 #define NG_HCI_EVENT_CON_PKT_TYPE_CHANGED 0x1d 1631 typedef struct { 1632 u_int8_t status; /* 0x00 - success */ 1633 u_int16_t con_handle; /* connection handle */ 1634 u_int16_t pkt_type; /* packet type */ 1635 } __attribute__ ((packed)) ng_hci_con_pkt_type_changed_ep; 1636 1637 #define NG_HCI_EVENT_QOS_VIOLATION 0x1e 1638 typedef struct { 1639 u_int16_t con_handle; /* connection handle */ 1640 } __attribute__ ((packed)) ng_hci_qos_violation_ep; 1641 1642 #define NG_HCI_EVENT_PAGE_SCAN_MODE_CHANGE 0x1f 1643 typedef struct { 1644 bdaddr_t bdaddr; /* destination address */ 1645 u_int8_t page_scan_mode; /* page scan mode */ 1646 } __attribute__ ((packed)) ng_hci_page_scan_mode_change_ep; 1647 1648 #define NG_HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE 0x20 1649 typedef struct { 1650 bdaddr_t bdaddr; /* destination address */ 1651 u_int8_t page_scan_rep_mode; /* page scan repetition mode */ 1652 } __attribute__ ((packed)) ng_hci_page_scan_rep_mode_change_ep; 1653 1654 #define NG_HCI_EVENT_BT_LOGO 0xfe 1655 1656 #define NG_HCI_EVENT_VENDOR 0xff 1657 1658 #endif /* ndef _NETGRAPH_HCI_H_ */ 1659