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