1dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/****************************************************************************** 2dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * 3dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * Copyright (C) 1999-2012 Broadcom Corporation 4dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * 5dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * Licensed under the Apache License, Version 2.0 (the "License"); 6dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * you may not use this file except in compliance with the License. 7dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * You may obtain a copy of the License at: 8dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * 9dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * http://www.apache.org/licenses/LICENSE-2.0 10dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * 11dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * Unless required by applicable law or agreed to in writing, software 12dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * distributed under the License is distributed on an "AS IS" BASIS, 13dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * See the License for the specific language governing permissions and 15dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * limitations under the License. 16dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski * 17dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski ******************************************************************************/ 18dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#ifndef BTM_INT_TYPES_H 19dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#define BTM_INT_TYPES_H 20dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 21dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#include "btm_api_types.h" 22dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#include "btm_ble_api_types.h" 23dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#include "btm_ble_int_types.h" 24911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#include "hcidefs.h" 25dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#include "osi/include/alarm.h" 26dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#include "osi/include/list.h" 27dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#include "rfcdefs.h" 28dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 29dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowskitypedef char tBTM_LOC_BD_NAME[BTM_MAX_LOC_BD_NAME_LEN + 1]; 30dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 31911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_IS_CONNECTED(bda) \ 32911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson (btm_bda_to_acl(bda, BT_TRANSPORT_BR_EDR) != NULL) 33dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 34dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Definitions for Server Channel Number (SCN) management 35dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 36911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_MAX_SCN PORT_MAX_RFC_PORTS 37dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 38dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Define masks for supported and exception 2.0 ACL packet types 39dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 40911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_SUPPORTED_PKTS_MASK \ 41911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson (HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1 | HCI_PKT_TYPES_MASK_DM3 | \ 42911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson HCI_PKT_TYPES_MASK_DH3 | HCI_PKT_TYPES_MASK_DM5 | HCI_PKT_TYPES_MASK_DH5) 43911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 44911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_EXCEPTION_PKTS_MASK \ 45911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson (HCI_PKT_TYPES_MASK_NO_2_DH1 | HCI_PKT_TYPES_MASK_NO_3_DH1 | \ 46911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson HCI_PKT_TYPES_MASK_NO_2_DH3 | HCI_PKT_TYPES_MASK_NO_3_DH3 | \ 47911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson HCI_PKT_TYPES_MASK_NO_2_DH5 | HCI_PKT_TYPES_MASK_NO_3_DH5) 48911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 49911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_EPR_AVAILABLE(p) \ 50f6ac424a81bad038bbf9a90c7c569dba81978f51Venkata Jagadeesh Garaga ((HCI_ATOMIC_ENCRYPT_SUPPORTED((p)->peer_lmp_feature_pages[0]) && \ 51911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson HCI_ATOMIC_ENCRYPT_SUPPORTED( \ 52911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson controller_get_interface()->get_features_classic(0)->as_array)) \ 53911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ? true \ 54911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson : false) 55911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 56911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_IS_BRCM_CONTROLLER() \ 57911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson (controller_get_interface()->get_bt_version()->manufacturer == \ 58911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson LMP_COMPID_BROADCOM) 59dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 60dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Define the ACL Management control structure 61dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 62911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 63911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t hci_handle; 64911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t pkt_types_mask; 65911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t clock_offset; 66911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR remote_addr; 67911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson DEV_CLASS remote_dc; 68911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_NAME remote_name; 69911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 70911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t manufacturer; 71911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t lmp_subversion; 72911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t link_super_tout; 73911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_FEATURES 74f6ac424a81bad038bbf9a90c7c569dba81978f51Venkata Jagadeesh Garaga peer_lmp_feature_pages[HCI_EXT_FEATURES_PAGE_MAX + 1]; /* Peer LMP Extended 75f6ac424a81bad038bbf9a90c7c569dba81978f51Venkata Jagadeesh Garaga features mask table 76f6ac424a81bad038bbf9a90c7c569dba81978f51Venkata Jagadeesh Garaga for the device */ 77911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t num_read_pages; 78911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t lmp_version; 79911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 80911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool in_use; 81911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t link_role; 82911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool link_up_issued; /* True if busy_level link up has been issued */ 83911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 84911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_SWKEY_STATE_IDLE 0 85911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_SWKEY_STATE_MODE_CHANGE 1 86911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_SWKEY_STATE_ENCRYPTION_OFF 2 87911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_SWKEY_STATE_SWITCHING 3 88911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_SWKEY_STATE_ENCRYPTION_ON 4 89911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_SWKEY_STATE_IN_PROGRESS 5 90911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t switch_role_state; 91911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 92911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_ENCRYPT_STATE_IDLE 0 93911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_ENCRYPT_STATE_ENCRYPT_OFF 1 /* encryption turning off */ 94911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_ENCRYPT_STATE_TEMP_FUNC \ 95911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 2 /* temporarily off for change link key or role switch */ 96911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ACL_ENCRYPT_STATE_ENCRYPT_ON 3 /* encryption turning on */ 97911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t encrypt_state; /* overall BTM encryption state */ 98911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 99911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBT_TRANSPORT transport; 100911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR conn_addr; /* local device address used for this connection */ 101911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t conn_addr_type; /* local device address type for this connection */ 102911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR active_remote_addr; /* remote address used on this connection */ 103911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t active_remote_addr_type; /* local device address type for this 104911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson connection */ 105911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_FEATURES peer_le_features; /* Peer LE Used features mask for the device */ 106dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 107dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tACL_CONN; 108dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 109dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Define the Device Management control structure 110dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 111911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 112911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_DEV_STATUS_CB* p_dev_status_cb; /* Device status change callback */ 113911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_VS_EVT_CB* p_vend_spec_cb 114911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson [BTM_MAX_VSE_CALLBACKS]; /* Register for vendor specific events */ 115dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 116911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* 117911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p_stored_link_key_cmpl_cb; /* Read/Write/Delete stored link key */ 118dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 119911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson alarm_t* read_local_name_timer; /* Read local name timer */ 120911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* p_rln_cmpl_cb; /* Callback function to be called when */ 121911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* read local name function complete */ 122911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson alarm_t* read_rssi_timer; /* Read RSSI timer */ 123911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* p_rssi_cmpl_cb; /* Callback function to be called when */ 124911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* read RSSI function completes */ 125911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson alarm_t* read_link_quality_timer; 126911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* p_link_qual_cmpl_cb; /* Callback function to be called when */ 127911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* read link quality function completes */ 128dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 129911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson alarm_t* read_inq_tx_power_timer; 130911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* 131911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p_inq_tx_power_cmpl_cb; /* Callback function to be called when */ 132911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* read inq tx power function completes */ 133dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 134911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson alarm_t* qos_setup_timer; /* QoS setup timer */ 135911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* p_qos_setup_cmpl_cb; /* Callback function to be called when */ 136911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* qos setup function completes */ 137dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 138911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_ROLE_SWITCH_CMPL switch_role_ref_data; 139911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* p_switch_role_cb; /* Callback function to be called when */ 140911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* requested switch role is completed */ 141dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 142911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson alarm_t* read_tx_power_timer; /* Read tx power timer */ 143911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* p_tx_power_cmpl_cb; /* Callback function to be called */ 144dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 145911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson DEV_CLASS dev_class; /* Local device class */ 146dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 147911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* 148911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p_le_test_cmd_cmpl_cb; /* Callback function to be called when 149911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson LE test mode command has been sent successfully */ 150dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 151911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR read_tx_pwr_addr; /* read TX power target address */ 152dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 153911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_LE_SUPPORT_STATE_SIZE 8 154911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t le_supported_states[BTM_LE_SUPPORT_STATE_SIZE]; 155dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 156911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_BLE_LOCAL_ID_KEYS id_keys; /* local BLE ID keys */ 157911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_OCTET16 ble_encryption_key_value; /* BLE encryption key */ 158dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 159dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if (BTM_BLE_CONFORMANCE_TESTING == TRUE) 160911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool no_disc_if_pair_fail; 161911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool enable_test_mac_val; 162911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_OCTET8 test_mac; 163911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool enable_test_local_sign_cntr; 164911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t test_local_sign_cntr; 165dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#endif 166dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 167911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_IO_CAP loc_io_caps; /* IO capability of the local device */ 168911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_AUTH_REQ loc_auth_req; /* the auth_req flag */ 169911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool secure_connections_only; /* Rejects service level 0 connections if */ 170911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* itself or peer device doesn't support */ 171911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* secure connections */ 172dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_DEVCB; 173dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 174dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Define the structures and constants used for inquiry 175dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 176dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 177dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Definitions of limits for inquiries */ 178911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_PER_INQ_MIN_MAX_PERIOD HCI_PER_INQ_MIN_MAX_PERIOD 179911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_PER_INQ_MAX_MAX_PERIOD HCI_PER_INQ_MAX_MAX_PERIOD 180911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_PER_INQ_MIN_MIN_PERIOD HCI_PER_INQ_MIN_MIN_PERIOD 181911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_PER_INQ_MAX_MIN_PERIOD HCI_PER_INQ_MAX_MIN_PERIOD 182911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_MAX_INQUIRY_LENGTH HCI_MAX_INQUIRY_LENGTH 183911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_MIN_INQUIRY_LEN 0x01 184911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 185911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_MIN_INQ_TX_POWER (-70) 186911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_MAX_INQ_TX_POWER 20 187911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 188911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 189911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t inq_count; /* Used for determining if a response has already been */ 190911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* received for the current inquiry operation. (We do not */ 191911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* want to flood the caller with multiple responses from */ 192911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* the same device. */ 193911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR bd_addr; 194dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tINQ_BDADDR; 195dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 196911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 197911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t time_of_resp; 198911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t 199911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson inq_count; /* "timestamps" the entry with a particular inquiry count */ 200911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* Used for determining if a response has already been */ 201911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* received for the current inquiry operation. (We do not */ 202911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* want to flood the caller with multiple responses from */ 203911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* the same device. */ 204911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_INQ_INFO inq_info; 205911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool in_use; 206911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool scan_rsp; 207dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tINQ_DB_ENT; 208dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 209911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonenum { INQ_NONE, INQ_LE_OBSERVE, INQ_GENERAL }; 210dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowskitypedef uint8_t tBTM_INQ_TYPE; 211dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 212911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 213911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* p_remname_cmpl_cb; 214dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 215dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#define BTM_EXT_RMT_NAME_TIMEOUT_MS (40 * 1000) /* 40 seconds */ 216dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 217911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson alarm_t* remote_name_timer; 218911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 219911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t discoverable_mode; 220911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t connectable_mode; 221911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t page_scan_window; 222911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t page_scan_period; 223911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t inq_scan_window; 224911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t inq_scan_period; 225911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t inq_scan_type; 226911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t page_scan_type; /* current page scan type */ 227911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_INQ_TYPE scan_type; 228911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 229911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR remname_bda; /* Name of bd addr for active remote name request */ 230911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_RMT_NAME_INACTIVE 0 231911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_RMT_NAME_EXT 0x1 /* Initiated through API */ 232911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_RMT_NAME_SEC 0x2 /* Initiated internally by security manager */ 233911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_RMT_NAME_INQ 0x4 /* Remote name initiated internally by inquiry */ 234911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool remname_active; /* State of a remote name request by external API */ 235911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 236911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* p_inq_cmpl_cb; 237911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_INQ_RESULTS_CB* p_inq_results_cb; 238911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* 239911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p_inq_ble_cmpl_cb; /*completion callback exclusively for LE Observe*/ 240911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_INQ_RESULTS_CB* 241911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p_inq_ble_results_cb; /*results callback exclusively for LE observe*/ 242911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CMPL_CB* p_inqfilter_cmpl_cb; /* Called (if not NULL) after inquiry 243911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson filter completed */ 244911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t inq_counter; /* Counter incremented each time an inquiry completes */ 245911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* Used for determining whether or not duplicate devices */ 246911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* have responded to the same inquiry */ 247911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tINQ_BDADDR* p_bd_db; /* Pointer to memory that holds bdaddrs */ 248911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t num_bd_entries; /* Number of entries in database */ 249911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t max_bd_entries; /* Maximum number of entries that can be stored */ 250911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tINQ_DB_ENT inq_db[BTM_INQ_DB_SIZE]; 251911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_INQ_PARMS inqparms; /* Contains the parameters for the current inquiry */ 252911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_INQUIRY_CMPL 253911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson inq_cmpl_info; /* Status and number of responses from the last inquiry */ 254911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 255911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t per_min_delay; /* Current periodic minimum delay */ 256911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t per_max_delay; /* Current periodic maximum delay */ 257911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool inqfilt_active; 258911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t pending_filt_complete_event; /* to take care of 259911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btm_event_filter_complete 260911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson corresponding to */ 261911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* inquiry that has been cancelled*/ 262911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t inqfilt_type; /* Contains the inquiry filter type (BD ADDR, COD, or 263911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson Clear) */ 264911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 265911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_INQ_INACTIVE_STATE 0 266911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_INQ_CLR_FILT_STATE \ 267911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 1 /* Currently clearing the inquiry filter preceeding the inquiry request */ 268911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* (bypassed if filtering is not used) */ 269911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_INQ_SET_FILT_STATE \ 270911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 2 /* Sets the new filter (or turns off filtering) in this state */ 271911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_INQ_ACTIVE_STATE \ 272911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 3 /* Actual inquiry or periodic inquiry is in progress */ 273911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_INQ_REMNAME_STATE 4 /* Remote name requests are active */ 274911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 275911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t state; /* Current state that the inquiry process is in */ 276911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t inq_active; /* Bit Mask indicating type of inquiry is active */ 277911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool no_inc_ssp; /* true, to stop inquiry on incoming SSP */ 278dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if (BTA_HOST_INTERLEAVE_SEARCH == TRUE) 279911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btm_inq_state 280911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson next_state; /*interleaving state to determine next mode to be inquired*/ 281dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#endif 282dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_INQUIRY_VAR_ST; 283dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 2849ca07091a1f07ea201cee0504dab6a1d7073d429Myles Watson/* The MSB of the clock offset field indicates whether the offset is valid. */ 285911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_CLOCK_OFFSET_VALID 0x8000 286dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 287dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Define the structures needed by security management 288dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 289dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 290911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_INVALID_HANDLE 0xFFFF 291dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 292911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef uint8_t* BTM_BD_NAME_PTR; /* Pointer to Device name */ 293dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 294dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Security callback is called by this unit when security 295ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * procedures are completed. Parameters are 296ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * BD Address of remote 297ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Result of the operation 298dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 299dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowskitypedef tBTM_SEC_CBACK tBTM_SEC_CALLBACK; 300dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 301911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef void(tBTM_SCO_IND_CBACK)(uint16_t sco_inx); 302dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 303dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* MACROs to convert from SCO packet types mask to ESCO and back */ 304911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SCO_PKT_TYPE_MASK \ 305911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson (HCI_PKT_TYPES_MASK_HV1 | HCI_PKT_TYPES_MASK_HV2 | HCI_PKT_TYPES_MASK_HV3) 306dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 307dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Mask defining only the SCO types of an esco packet type */ 308181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth#define BTM_ESCO_PKT_TYPE_MASK \ 309181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 | ESCO_PKT_TYPES_MASK_HV3) 310dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 311911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SCO_2_ESCO(scotype) \ 312911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ((uint16_t)(((scotype)&BTM_SCO_PKT_TYPE_MASK) >> 5)) 313911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_ESCO_2_SCO(escotype) \ 314911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ((uint16_t)(((escotype)&BTM_ESCO_PKT_TYPE_MASK) << 5)) 315dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 316dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Define masks for supported and exception 2.0 SCO packet types 317dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 318181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth#define BTM_SCO_SUPPORTED_PKTS_MASK \ 319181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 | \ 320181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth ESCO_PKT_TYPES_MASK_HV3 | ESCO_PKT_TYPES_MASK_EV3 | \ 321181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth ESCO_PKT_TYPES_MASK_EV4 | ESCO_PKT_TYPES_MASK_EV5) 322dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 323181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth#define BTM_SCO_EXCEPTION_PKTS_MASK \ 324181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth (ESCO_PKT_TYPES_MASK_NO_2_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 | \ 325181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5) 326dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 327911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SCO_ROUTE_UNKNOWN 0xff 328dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 329dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Define the structure that contains (e)SCO data */ 330911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 331911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_ESCO_CBACK* p_esco_cback; /* Callback for eSCO events */ 332181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth enh_esco_params_t setup; 333911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_ESCO_DATA data; /* Connection complete information */ 334911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t hci_status; 335dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_ESCO_INFO; 336dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 337dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Define the structure used for SCO Management 338dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 339911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 340911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_ESCO_INFO esco; /* Current settings */ 341dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if (BTM_SCO_HCI_INCLUDED == TRUE) 342911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson fixed_queue_t* xmit_data_q; /* SCO data transmitting queue */ 343dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#endif 344911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SCO_CB* p_conn_cb; /* Callback for when connected */ 345911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SCO_CB* p_disc_cb; /* Callback for when disconnect */ 346911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t state; /* The state of the SCO link */ 347911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t hci_handle; /* HCI Handle */ 348911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool is_orig; /* true if the originator */ 349911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool rem_bd_known; /* true if remote BD addr known */ 350dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 351dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tSCO_CONN; 352dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 353dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* SCO Management control block */ 354911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 355911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SCO_IND_CBACK* app_sco_ind_cb; 356dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if (BTM_SCO_HCI_INCLUDED == TRUE) 357911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SCO_DATA_CB* p_data_cb; /* Callback for SCO data over HCI */ 358dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#endif 359911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tSCO_CONN sco_db[BTM_MAX_SCO_LINKS]; 360181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth enh_esco_params_t def_esco_parms; 361911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t sco_disc_reason; 362181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth bool esco_supported; /* true if 1.2 cntlr AND supports eSCO links */ 363181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananth esco_data_path_t sco_route; /* HCI, PCM, or TEST */ 364dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tSCO_CB; 365dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 366dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if (BTM_SCO_INCLUDED == TRUE) 367911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonextern void btm_set_sco_ind_cback(tBTM_SCO_IND_CBACK* sco_ind_cb); 368181863e6c2a5f2575334bef5489d0e2a85132756Mudumba Ananthextern void btm_accept_sco_link(uint16_t sco_inx, enh_esco_params_t* p_setup, 369911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SCO_CB* p_conn_cb, tBTM_SCO_CB* p_disc_cb); 370911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonextern void btm_reject_sco_link(uint16_t sco_inx); 371911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonextern void btm_sco_chk_pend_rolechange(uint16_t hci_handle); 372911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonextern void btm_sco_disc_chk_pend_for_modechange(uint16_t hci_handle); 373dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 374dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#else 375dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#define btm_accept_sco_link(sco_inx, p_setup, p_conn_cb, p_disc_cb) 376dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#define btm_reject_sco_link(sco_inx) 377dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#define btm_set_sco_ind_cback(sco_ind_cb) 378dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#define btm_sco_chk_pend_rolechange(hci_handle) 379911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#endif /* BTM_SCO_INCLUDED */ 380dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 381dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* 382ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Define structure for Security Service Record. 383ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * A record exists for each service registered with the Security Manager 384dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 385911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_OUT_FLAGS \ 386911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson (BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT | BTM_SEC_OUT_AUTHORIZE) 387911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_IN_FLAGS \ 388911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT | BTM_SEC_IN_AUTHORIZE) 389911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 390911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_OUT_LEVEL4_FLAGS \ 391911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson (BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT | BTM_SEC_OUT_MITM | \ 392911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_SEC_MODE4_LEVEL4) 393911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 394911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_IN_LEVEL4_FLAGS \ 395911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT | BTM_SEC_IN_MITM | \ 396911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_SEC_MODE4_LEVEL4) 397911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 398911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t mx_proto_id; /* Service runs over this multiplexer protocol */ 399911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t orig_mx_chan_id; /* Channel on the multiplexer protocol */ 400911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t term_mx_chan_id; /* Channel on the multiplexer protocol */ 401911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t psm; /* L2CAP PSM value */ 402911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t security_flags; /* Bitmap of required security features */ 403911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t service_id; /* Passed in authorization callback */ 404dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if (L2CAP_UCD_INCLUDED == TRUE) 405911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t 406911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ucd_security_flags; /* Bitmap of required security features for UCD */ 407dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#endif 408dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if BTM_SEC_SERVICE_NAME_LEN > 0 409911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t orig_service_name[BTM_SEC_SERVICE_NAME_LEN + 1]; 410911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t term_service_name[BTM_SEC_SERVICE_NAME_LEN + 1]; 411dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#endif 412dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_SEC_SERV_REC; 413dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 414dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* LE Security information of device in Slave Role */ 415911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 416911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_OCTET16 irk; /* peer diverified identity root */ 417911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_OCTET16 pltk; /* peer long term key */ 418911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_OCTET16 pcsrk; /* peer SRK peer device used to secured sign local data */ 419911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 420911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_OCTET16 lltk; /* local long term key */ 421911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_OCTET16 lcsrk; /* local SRK peer device used to secured sign local data */ 422911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 423911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_OCTET8 rand; /* random vector for LTK generation */ 424911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t ediv; /* LTK diversifier of this slave device */ 425911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t div; /* local DIV to generate local LTK=d1(ER,DIV,0) and 426911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson CSRK=d1(ER,DIV,1) */ 427911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t sec_level; /* local pairing security level */ 428911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t key_size; /* key size of the LTK delivered to peer device */ 429911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t srk_sec_level; /* security property of peer SRK for this device */ 430911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t local_csrk_sec_level; /* security property of local CSRK for this 431911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson device */ 432911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 433911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t counter; /* peer sign counter for verifying rcv signed cmd */ 434911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t local_counter; /* local sign counter for sending signed write cmd*/ 435911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson} tBTM_SEC_BLE_KEYS; 436911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 437911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 438911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR pseudo_addr; /* LE pseudo address of the device if different from 439911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson device address */ 440911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBLE_ADDR_TYPE ble_addr_type; /* LE device type: public or random address */ 441911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBLE_ADDR_TYPE static_addr_type; /* static address type */ 442911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR static_addr; /* static address */ 443911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 444911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_WHITE_LIST_BIT 0x01 445911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_RESOLVING_LIST_BIT 0x02 446911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t in_controller_list; /* in controller resolving list or not */ 447911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t resolving_list_index; 448dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if (BLE_PRIVACY_SPT == TRUE) 449911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR cur_rand_addr; /* current random address */ 450dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 451911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_BLE_ADDR_PSEUDO 0 /* address index device record */ 452911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_BLE_ADDR_RRA 1 /* cur_rand_addr */ 453911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_BLE_ADDR_STATIC 2 /* static_addr */ 454911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t active_addr_type; 455dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#endif 456dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 457911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_LE_KEY_TYPE key_type; /* bit mask of valid key types in record */ 458911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SEC_BLE_KEYS keys; /* LE device security info in slave rode */ 459dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_SEC_BLE; 460dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 461dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Peering bond type */ 462911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonenum { BOND_TYPE_UNKNOWN, BOND_TYPE_PERSISTENT, BOND_TYPE_TEMPORARY }; 463dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowskitypedef uint8_t tBTM_BOND_TYPE; 464dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 465dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* 466ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Define structure for Security Device Record. 467ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * A record exists for each device authenticated with this device 468dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 469911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 470911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SEC_SERV_REC* p_cur_service; 471911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SEC_CALLBACK* p_callback; 472911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson void* p_ref_data; 473911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t timestamp; /* Timestamp of the last connection */ 474911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t trusted_mask[BTM_SEC_SERVICE_ARRAY_SIZE]; /* Bitwise OR of trusted 475911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson services */ 476911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t hci_handle; /* Handle to connection when exists */ 477911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t clock_offset; /* Latest known clock offset */ 478911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR bd_addr; /* BD_ADDR of the device */ 479911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson DEV_CLASS dev_class; /* DEV_CLASS of the device */ 480911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson LINK_KEY link_key; /* Device link key */ 481911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t pin_code_length; /* Length of the pin_code used for paring */ 482911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 483911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_AUTHORIZED BTM_SEC_FLAG_AUTHORIZED /* 0x01 */ 484911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_AUTHENTICATED BTM_SEC_FLAG_AUTHENTICATED /* 0x02 */ 485911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_ENCRYPTED BTM_SEC_FLAG_ENCRYPTED /* 0x04 */ 486911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_NAME_KNOWN 0x08 487911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_LINK_KEY_KNOWN BTM_SEC_FLAG_LKEY_KNOWN /* 0x10 */ 488911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_LINK_KEY_AUTHED BTM_SEC_FLAG_LKEY_AUTHED /* 0x20 */ 489911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_ROLE_SWITCHED 0x40 490911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_IN_USE 0x80 491911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson/* LE link security flag */ 492911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_LE_AUTHENTICATED \ 493911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x0200 /* LE link is encrypted after pairing with MITM */ 494911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_LE_ENCRYPTED 0x0400 /* LE link is encrypted */ 495911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_LE_NAME_KNOWN 0x0800 /* not used */ 496911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_LE_LINK_KEY_KNOWN \ 497911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x1000 /* bonded with peer (peer LTK and/or SRK is saved) */ 498911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_LE_LINK_KEY_AUTHED 0x2000 /* pairing is done with MITM */ 499911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_16_DIGIT_PIN_AUTHED \ 500911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x4000 /* pairing is done with 16 digit pin */ 501911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 502911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t sec_flags; /* Current device security state */ 503911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 504911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_BD_NAME sec_bd_name; /* User friendly name of the device. (may be 505911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson truncated to save space in dev_rec table) */ 506f6ac424a81bad038bbf9a90c7c569dba81978f51Venkata Jagadeesh Garaga BD_FEATURES feature_pages[HCI_EXT_FEATURES_PAGE_MAX + 507f6ac424a81bad038bbf9a90c7c569dba81978f51Venkata Jagadeesh Garaga 1]; /* Features supported by the device */ 508911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t num_read_pages; 509911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 510911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_STATE_IDLE 0 511911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_STATE_AUTHENTICATING 1 512911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_STATE_ENCRYPTING 2 513911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_STATE_GETTING_NAME 3 514911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_STATE_AUTHORIZING 4 515911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_STATE_SWITCHING_ROLE 5 516911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_STATE_DISCONNECTING 6 /* disconnecting BR/EDR */ 517911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_STATE_DELAY_FOR_ENC \ 518911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 7 /* delay to check for encryption to work around */ 519911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* controller problems */ 520911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_STATE_DISCONNECTING_BLE 8 /* disconnecting BLE */ 521dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#define BTM_SEC_STATE_DISCONNECTING_BOTH 9 /* disconnecting BR/EDR and BLE */ 522dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 523911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t sec_state; /* Operating state */ 524911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool is_originator; /* true if device is originating connection */ 525dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if (L2CAP_UCD_INCLUDED == TRUE) 526911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool is_ucd; /* true if device is sending or receiving UCD */ 527911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* if incoming security failed, received UCD will be discarded */ 528dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#endif 529911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool role_master; /* true if current mode is master */ 530911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t security_required; /* Security required for connection */ 531911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool link_key_not_sent; /* link key notification has not been sent waiting for 532911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson name */ 533911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t link_key_type; /* Type of key used in pairing */ 534911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool link_key_changed; /* Changed link key during current connection */ 535911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 536911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_MAX_PRE_SM4_LKEY_TYPE \ 537911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_LKEY_TYPE_REMOTE_UNIT /* the link key type used by legacy pairing */ 538911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 539911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SM4_UNKNOWN 0x00 540911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SM4_KNOWN 0x10 541911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SM4_TRUE 0x11 542911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SM4_REQ_PEND 0x08 /* set this bit when getting remote features */ 543911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SM4_UPGRADE 0x04 /* set this bit when upgrading link key */ 544911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SM4_RETRY \ 545911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x02 /* set this bit to retry on HCI_ERR_KEY_MISSING or \ 546911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson HCI_ERR_LMP_ERR_TRANS_COLLISION */ 547911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SM4_DD_ACP \ 548911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x20 /* set this bit to indicate peer initiated dedicated bonding */ 549911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SM4_CONN_PEND \ 550911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x40 /* set this bit to indicate accepting acl conn; to be cleared on \ 551911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btm_acl_created */ 552911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t sm4; /* BTM_SM4_TRUE, if the peer supports SM4 */ 553911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_IO_CAP rmt_io_caps; /* IO capability of the peer device */ 554911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_AUTH_REQ rmt_auth_req; /* the auth_req flag as in the IO caps rsp evt */ 555911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool remote_supports_secure_connections; 556911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool remote_features_needed; /* set to true if the local device is in */ 557911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* "Secure Connections Only" mode and it receives */ 558911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* HCI_IO_CAPABILITY_REQUEST_EVT from the peer before */ 559911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* it knows peer's support for Secure Connections */ 560911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 561911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t ble_hci_handle; /* use in DUMO connection */ 562911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t enc_key_size; /* current link encryption key size */ 563911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBT_DEVICE_TYPE device_type; 564911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool new_encryption_key_is_p256; /* Set to true when the newly generated LK 565911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ** is generated from P-256. 566911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ** Link encrypted with such LK can be used 567911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ** for SM over BR/EDR. 568911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson */ 569911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool no_smp_on_br; /* if set to true then SMP on BR/EDR doesn't */ 570911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* work, i.e. link keys crosspairing */ 571911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* SC BR/EDR->SC LE doesn't happen */ 572911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_BOND_TYPE bond_type; /* peering bond type */ 573911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 574911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SEC_BLE ble; 575911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_LE_CONN_PRAMS conn_params; 576dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 577dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if (BTM_DISC_DURING_RS == TRUE) 578911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_RS_NOT_PENDING 0 /* Role Switch not in progress */ 579911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_RS_PENDING 1 /* Role Switch in progress */ 580911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_DISC_PENDING 2 /* Disconnect is pending */ 581911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t rs_disc_pending; 582dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#endif 583911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_NO_LAST_SERVICE_ID 0 584911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t last_author_service_id; /* ID of last serviced authorized: Reset after 585911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson each l2cap connection */ 586dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 587dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_SEC_DEV_REC; 588dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 589911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_IS_SM4(sm) ((bool)(BTM_SM4_TRUE == ((sm)&BTM_SM4_TRUE))) 590911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_IS_SM4_LEGACY(sm) ((bool)(BTM_SM4_KNOWN == ((sm)&BTM_SM4_TRUE))) 591911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_IS_SM4_UNKNOWN(sm) \ 592911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ((bool)(BTM_SM4_UNKNOWN == ((sm)&BTM_SM4_TRUE))) 593dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 594911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_LE_MASK \ 595911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson (BTM_SEC_LE_AUTHENTICATED | BTM_SEC_LE_ENCRYPTED | \ 596911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_SEC_LE_LINK_KEY_KNOWN | BTM_SEC_LE_LINK_KEY_AUTHED) 597dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 598dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* 599ee96a3c60fca590d38025925c072d264e06493c4Myles Watson * Define device configuration structure 600dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 601911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 602911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_LOC_BD_NAME bd_name; /* local Bluetooth device name */ 603911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool pin_type; /* true if PIN type is fixed */ 604911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t pin_code_len; /* Bonding information */ 605911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson PIN_CODE pin_code; /* PIN CODE if pin type is fixed */ 606911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool connectable; /* If true page scan should be enabled */ 607911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t def_inq_scan_mode; /* ??? limited/general/none */ 608dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_CFG; 609dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 610911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonenum { 611911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PM_ST_ACTIVE = BTM_PM_STS_ACTIVE, 612911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PM_ST_HOLD = BTM_PM_STS_HOLD, 613911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PM_ST_SNIFF = BTM_PM_STS_SNIFF, 614911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PM_ST_PARK = BTM_PM_STS_PARK, 615911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PM_ST_PENDING = BTM_PM_STS_PENDING, 616911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PM_ST_INVALID = 0xFF 617dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski}; 618dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowskitypedef uint8_t tBTM_PM_STATE; 619dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 620911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonenum { 621911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PM_SET_MODE_EVT, /* Set power mode API is called. */ 622911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PM_UPDATE_EVT, 623911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PM_RD_MODE_EVT /* Read power mode API is called. */ 624dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski}; 625dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowskitypedef uint8_t tBTM_PM_EVENT; 626dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 627911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 628911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t event; 629911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t len; 630911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t link_ind; 631dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_PM_MSG_DATA; 632dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 633911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 634911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t hci_status; 635911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t mode; 636911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t interval; 637dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_PM_MD_CHG_DATA; 638dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 639911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 640911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t pm_id; /* the entity that calls SetPowerMode API */ 641911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_PM_PWR_MD* p_pmd; 642dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_PM_SET_MD_DATA; 643dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 644911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 645911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson void* p_data; 646911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t link_ind; 647dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_PM_SM_DATA; 648dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 649911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 650911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_PM_PWR_MD req_mode[BTM_MAX_PM_RECORDS + 1]; /* the desired mode and 651911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson parameters of the 652911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson connection*/ 653911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_PM_PWR_MD 654911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson set_mode; /* the mode and parameters sent down to the host controller. */ 655911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t interval; /* the interval from last mode change event. */ 656dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if (BTM_SSR_INCLUDED == TRUE) 657911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t max_lat; /* stored SSR maximum latency */ 658911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t min_rmt_to; /* stored SSR minimum remote timeout */ 659911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t min_loc_to; /* stored SSR minimum local timeout */ 660dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#endif 661911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_PM_STATE state; /* contains the current mode of the connection */ 662911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool chg_ind; /* a request change indication */ 663dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_PM_MCB; 664dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 665dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#define BTM_PM_REC_NOT_USED 0 666911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 667911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_PM_STATUS_CBACK* 668911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson cback; /* to notify the registered party of mode change event */ 669911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t mask; /* registered request mask. 0, if this entry is not used */ 670dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_PM_RCB; 671dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 672911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonenum { 673911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_BLI_ACL_UP_EVT, 674911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_BLI_ACL_DOWN_EVT, 675911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_BLI_PAGE_EVT, 676911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_BLI_PAGE_DONE_EVT, 677911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_BLI_INQ_EVT, 678911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_BLI_INQ_CANCEL_EVT, 679911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_BLI_INQ_DONE_EVT 680dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski}; 681dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowskitypedef uint8_t tBTM_BLI_EVENT; 682dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 683dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Pairing State */ 684911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonenum { 685911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PAIR_STATE_IDLE, /* Idle */ 686911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PAIR_STATE_GET_REM_NAME, /* Getting the remote name (to check for SM4) */ 687911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PAIR_STATE_WAIT_PIN_REQ, /* Started authentication, waiting for PIN req 688911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson (PIN is pre-fetched) */ 689911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PAIR_STATE_WAIT_LOCAL_PIN, /* Waiting for local PIN code */ 690911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PAIR_STATE_WAIT_NUMERIC_CONFIRM, /* Waiting user 'yes' to numeric 691911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson confirmation */ 692911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PAIR_STATE_KEY_ENTRY, /* Key entry state (we are a keyboard) */ 693911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PAIR_STATE_WAIT_LOCAL_OOB_RSP, /* Waiting for local response to peer OOB 694911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson data */ 695911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PAIR_STATE_WAIT_LOCAL_IOCAPS, /* Waiting for local IO capabilities and OOB 696911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson data */ 697911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PAIR_STATE_INCOMING_SSP, /* Incoming SSP (got peer IO caps when idle) */ 698911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PAIR_STATE_WAIT_AUTH_COMPLETE, /* All done, waiting authentication 699911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson cpmplete */ 700911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BTM_PAIR_STATE_WAIT_DISCONNECT /* Waiting to disconnect the ACL */ 701dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski}; 702dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowskitypedef uint8_t tBTM_PAIRING_STATE; 703dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 704911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_PAIR_FLAGS_WE_STARTED_DD \ 705911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x01 /* We want to do dedicated bonding */ 706911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_PAIR_FLAGS_PEER_STARTED_DD \ 707911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x02 /* Peer initiated dedicated bonding */ 708911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_PAIR_FLAGS_DISC_WHEN_DONE 0x04 /* Disconnect when done */ 709911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_PAIR_FLAGS_PIN_REQD \ 710911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x08 /* set this bit when pin_callback is called */ 711911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_PAIR_FLAGS_PRE_FETCH_PIN \ 712911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x10 /* set this bit when pre-fetch pin */ 713911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_PAIR_FLAGS_REJECTED_CONNECT \ 714911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x20 /* set this bit when rejected incoming connection */ 715911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_PAIR_FLAGS_WE_CANCEL_DD \ 716911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x40 /* set this bit when cancelling a bonding procedure */ 717911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_PAIR_FLAGS_LE_ACTIVE \ 718911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x80 /* use this bit when SMP pairing is active */ 719911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 720911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 721911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool is_mux; 722911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR bd_addr; 723911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t psm; 724911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool is_orig; 725911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SEC_CALLBACK* p_callback; 726911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson void* p_ref_data; 727911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t mx_proto_id; 728911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t mx_chan_id; 729911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBT_TRANSPORT transport; 730911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_BLE_SEC_ACT sec_act; 731dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_SEC_QUEUE_ENTRY; 732dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 733dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if (L2CAP_UCD_INCLUDED == TRUE) 734dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 735911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define CONN_ORIENT_TERM 0x00 /* incoming connection oriented */ 736911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define CONN_ORIENT_ORIG 0x01 /* outgoing connection oriented */ 737911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define CONNLESS_TERM 0x02 /* incoming connectionless */ 738911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define CONNLESS_ORIG 0x03 /* outgoing connectionless */ 739911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define CONNECTION_TYPE_ORIG_MASK 0x01 /* mask for direction */ 740911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define CONNECTION_TYPE_CONNLESS_MASK \ 741911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 0x02 /* mask for connectionless or not \ 742911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson */ 743dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowskitypedef uint8_t CONNECTION_TYPE; 744dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 745dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#else 746dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 747911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define CONN_ORIENT_TERM false 748911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define CONN_ORIENT_ORIG true 749911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef bool CONNECTION_TYPE; 750dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 751dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#endif /* (L2CAP_UCD_INCLUDED == TRUE) */ 752dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 753dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* Define a structure to hold all the BTM data 754dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski*/ 755dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 756911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_STATE_BUFFER_SIZE 5 /* size of state buffer */ 757911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 758911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsontypedef struct { 759911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_CFG cfg; /* Device configuration */ 760911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 761911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /**************************************************** 762911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ** ACL Management 763911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ****************************************************/ 764911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tACL_CONN acl_db[MAX_L2CAP_LINKS]; 765911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t btm_scn[BTM_MAX_SCN]; /* current SCNs: true if SCN is in use */ 766911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t btm_def_link_policy; 767911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t btm_def_link_super_tout; 768911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 769911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_BL_EVENT_MASK bl_evt_mask; 770911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_BL_CHANGE_CB* p_bl_changed_cb; /* Callback for when Busy Level changed */ 771911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 772911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /**************************************************** 773911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ** Power Management 774911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ****************************************************/ 775911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_PM_MCB pm_mode_db[MAX_L2CAP_LINKS]; /* per ACL link */ 776911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_PM_RCB pm_reg_db[BTM_MAX_PM_RECORDS + 1]; /* per application/module */ 777911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t pm_pend_link; /* the index of acl_db, which has a pending PM cmd */ 778911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t pm_pend_id; /* the id pf the module, which has a pending PM cmd */ 779911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 780911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /***************************************************** 781911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ** Device control 782911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson *****************************************************/ 783911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_DEVCB devcb; 784911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 785911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /***************************************************** 786911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ** BLE Device controllers 787911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson *****************************************************/ 788911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_BLE_CB ble_ctr_cb; 789911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 790911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t enc_handle; 791911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_OCTET8 enc_rand; /* received rand value from LTK request*/ 792911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t ediv; /* received ediv value from LTK request */ 793911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t key_size; 794911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_BLE_VSC_CB cmn_ble_vsc_cb; 795911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 796911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /* Packet types supported by the local device */ 797911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t btm_acl_pkt_types_supported; 798911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t btm_sco_pkt_types_supported; 799911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 800911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /***************************************************** 801911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ** Inquiry 802911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson *****************************************************/ 803911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_INQUIRY_VAR_ST btm_inq_vars; 804911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 805911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson/***************************************************** 806911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson** SCO Management 807911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson*****************************************************/ 808dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#if (BTM_SCO_INCLUDED == TRUE) 809911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tSCO_CB sco_cb; 810dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski#endif 811dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 812911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson /***************************************************** 813911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ** Security Management 814911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson *****************************************************/ 815911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_APPL_INFO api; 816911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 817911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_MAX_RMT_NAME_CALLBACKS 2 818911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_RMT_NAME_CALLBACK* p_rmt_name_callback[BTM_SEC_MAX_RMT_NAME_CALLBACKS]; 819911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 820911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SEC_DEV_REC* p_collided_dev_rec; 821911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson alarm_t* sec_collision_timer; 822911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t collision_start_time; 823911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t max_collision_delay; 824911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint32_t dev_rec_count; /* Counter used for device record timestamp */ 825911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t security_mode; 826911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool pairing_disabled; 827911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool connect_only_paired; 828911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool security_mode_changed; /* mode changed during bonding */ 829911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool pin_type_changed; /* pin type changed during bonding */ 830911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool sec_req_pending; /* true if a request is pending */ 831911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 832911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t pin_code_len; /* for legacy devices */ 833911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson PIN_CODE pin_code; /* for legacy devices */ 834911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_PAIRING_STATE pairing_state; /* The current pairing state */ 835911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t pairing_flags; /* The current pairing flags */ 836911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR pairing_bda; /* The device currently pairing */ 837911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson alarm_t* pairing_timer; /* Timer for pairing process */ 838911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t disc_handle; /* for legacy devices */ 839911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t disc_reason; /* for legacy devices */ 840911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SEC_SERV_REC sec_serv_rec[BTM_SEC_MAX_SERVICE_RECORDS]; 841911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson list_t* sec_dev_rec; /* list of tBTM_SEC_DEV_REC */ 842911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SEC_SERV_REC* p_out_serv; 843911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_MKEY_CALLBACK* mkey_cback; 844911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 845911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR connecting_bda; 846911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson DEV_CLASS connecting_dc; 847911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 848911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t acl_disc_reason; 849911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t trace_level; 850911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t busy_level; /* the current busy level */ 851911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool is_paging; /* true, if paging is in progess */ 852911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool is_inquiry; /* true, if inquiry is in progess */ 853911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson fixed_queue_t* page_queue; 854911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool paging; 855911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson bool discing; 856911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson fixed_queue_t* sec_pending_q; /* pending sequrity requests in 857911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson tBTM_SEC_QUEUE_ENTRY format */ 858911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson 859911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson char state_temp_buffer[BTM_STATE_BUFFER_SIZE]; 860dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski} tBTM_CB; 861dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 862dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski/* security action for L2CAP COC channels */ 863911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_OK 1 864911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_ENCRYPT 2 /* encrypt the link with current key */ 865911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_ENCRYPT_NO_MITM 3 /* unauthenticated encryption or better */ 866911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_ENCRYPT_MITM 4 /* authenticated encryption */ 867911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#define BTM_SEC_ENC_PENDING 5 /* wait for link encryption pending */ 868dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 869dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowskitypedef uint8_t tBTM_SEC_ACTION; 870dc3c1f2afa2d5f311c3ea42bda432089a7f303a4Jakub Pawlowski 871911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#endif // BTM_INT_TYPES_H 872