1 /****************************************************************************** 2 * 3 * Copyright 1999-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 /****************************************************************************** 20 * 21 * this file contains the main Bluetooth Manager (BTM) internal 22 * definitions. 23 * 24 ******************************************************************************/ 25 #ifndef BTM_INT_H 26 #define BTM_INT_H 27 28 #include "bt_common.h" 29 #include "bt_target.h" 30 #include "hcidefs.h" 31 32 #include "osi/include/alarm.h" 33 #include "osi/include/fixed_queue.h" 34 #include "osi/include/list.h" 35 #include "rfcdefs.h" 36 37 #include "btm_api.h" 38 #include "device/include/esco_parameters.h" 39 40 #include "btm_ble_int.h" 41 #include "btm_int_types.h" 42 #include "l2cdefs.h" 43 #include "smp_api.h" 44 45 extern tBTM_CB btm_cb; 46 47 /* Internal functions provided by btm_main.cc 48 ******************************************* 49 */ 50 extern void btm_init(void); 51 extern void btm_free(void); 52 53 /* Internal functions provided by btm_inq.cc 54 ****************************************** 55 */ 56 extern tBTM_STATUS btm_initiate_rem_name(const RawAddress& remote_bda, 57 uint8_t origin, uint64_t timeout_ms, 58 tBTM_CMPL_CB* p_cb); 59 60 extern void btm_process_remote_name(const RawAddress* bda, BD_NAME name, 61 uint16_t evt_len, uint8_t hci_status); 62 extern void btm_inq_rmt_name_failed_cancelled(void); 63 extern void btm_inq_remote_name_timer_timeout(void* data); 64 65 /* Inquiry related functions */ 66 extern void btm_clr_inq_db(const RawAddress* p_bda); 67 extern void btm_inq_db_init(void); 68 extern void btm_process_inq_results(uint8_t* p, uint8_t hci_evt_len, 69 uint8_t inq_res_mode); 70 extern void btm_process_inq_complete(uint8_t status, uint8_t mode); 71 extern void btm_process_cancel_complete(uint8_t status, uint8_t mode); 72 extern void btm_event_filter_complete(uint8_t* p); 73 extern void btm_inq_stop_on_ssp(void); 74 extern void btm_inq_clear_ssp(void); 75 extern tINQ_DB_ENT* btm_inq_db_find(const RawAddress& p_bda); 76 extern bool btm_inq_find_bdaddr(const RawAddress& p_bda); 77 78 /* Internal functions provided by btm_acl.cc 79 ******************************************* 80 */ 81 extern void btm_acl_init(void); 82 extern void btm_acl_created(const RawAddress& bda, DEV_CLASS dc, BD_NAME bdn, 83 uint16_t hci_handle, uint8_t link_role, 84 tBT_TRANSPORT transport); 85 extern void btm_acl_removed(const RawAddress& bda, tBT_TRANSPORT transport); 86 extern void btm_acl_device_down(void); 87 extern void btm_acl_update_busy_level(tBTM_BLI_EVENT event); 88 89 extern void btm_cont_rswitch(tACL_CONN* p, tBTM_SEC_DEV_REC* p_dev_rec, 90 uint8_t hci_status); 91 92 extern uint8_t btm_handle_to_acl_index(uint16_t hci_handle); 93 extern void btm_read_link_policy_complete(uint8_t* p); 94 95 extern void btm_read_rssi_timeout(void* data); 96 extern void btm_read_rssi_complete(uint8_t* p); 97 98 extern void btm_read_failed_contact_counter_timeout(void* data); 99 extern void btm_read_failed_contact_counter_complete(uint8_t* p); 100 101 extern void btm_read_automatic_flush_timeout_timeout(void* data); 102 extern void btm_read_automatic_flush_timeout_complete(uint8_t* p); 103 104 extern void btm_read_tx_power_timeout(void* data); 105 extern void btm_read_tx_power_complete(uint8_t* p, bool is_ble); 106 107 extern void btm_read_link_quality_timeout(void* data); 108 extern void btm_read_link_quality_complete(uint8_t* p); 109 110 extern tBTM_STATUS btm_set_packet_types(tACL_CONN* p, uint16_t pkt_types); 111 extern void btm_process_clk_off_comp_evt(uint16_t hci_handle, 112 uint16_t clock_offset); 113 extern void btm_acl_role_changed(uint8_t hci_status, const RawAddress* bd_addr, 114 uint8_t new_role); 115 extern void btm_blacklist_role_change_device(const RawAddress& bd_addr, 116 uint8_t hci_status); 117 extern void btm_acl_encrypt_change(uint16_t handle, uint8_t status, 118 uint8_t encr_enable); 119 extern uint16_t btm_get_acl_disc_reason_code(void); 120 extern tBTM_STATUS btm_remove_acl(const RawAddress& bd_addr, 121 tBT_TRANSPORT transport); 122 extern void btm_read_remote_features_complete(uint8_t* p); 123 extern void btm_read_remote_ext_features_complete(uint8_t* p, uint8_t evt_len); 124 extern void btm_read_remote_ext_features_failed(uint8_t status, 125 uint16_t handle); 126 extern void btm_read_remote_version_complete(uint8_t* p); 127 extern void btm_establish_continue(tACL_CONN* p_acl_cb); 128 129 extern void btm_acl_chk_peer_pkt_type_support(tACL_CONN* p, 130 uint16_t* p_pkt_type); 131 /* Read maximum data packet that can be sent over current connection */ 132 extern uint16_t btm_get_max_packet_size(const RawAddress& addr); 133 extern tACL_CONN* btm_bda_to_acl(const RawAddress& bda, 134 tBT_TRANSPORT transport); 135 extern bool btm_acl_notif_conn_collision(const RawAddress& bda); 136 extern void btm_acl_update_conn_addr(uint16_t conn_handle, 137 const RawAddress& address); 138 139 extern void btm_pm_reset(void); 140 extern void btm_pm_sm_alloc(uint8_t ind); 141 extern void btm_pm_proc_cmd_status(uint8_t status); 142 extern void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle, 143 uint8_t mode, uint16_t interval); 144 extern void btm_pm_proc_ssr_evt(uint8_t* p, uint16_t evt_len); 145 extern tBTM_STATUS btm_read_power_mode_state(const RawAddress& remote_bda, 146 tBTM_PM_STATE* pmState); 147 extern void btm_sco_chk_pend_unpark(uint8_t hci_status, uint16_t hci_handle); 148 extern void btm_qos_setup_timeout(void* data); 149 extern void btm_qos_setup_complete(uint8_t status, uint16_t handle, 150 FLOW_SPEC* p_flow); 151 152 /* Internal functions provided by btm_sco.cc 153 ******************************************* 154 */ 155 extern void btm_sco_init(void); 156 extern void btm_sco_connected(uint8_t hci_status, const RawAddress* bda, 157 uint16_t hci_handle, tBTM_ESCO_DATA* p_esco_data); 158 extern void btm_esco_proc_conn_chg(uint8_t status, uint16_t handle, 159 uint8_t tx_interval, uint8_t retrans_window, 160 uint16_t rx_pkt_len, uint16_t tx_pkt_len); 161 extern void btm_sco_conn_req(const RawAddress& bda, DEV_CLASS dev_class, 162 uint8_t link_type); 163 extern void btm_sco_removed(uint16_t hci_handle, uint8_t reason); 164 extern void btm_sco_acl_removed(const RawAddress* bda); 165 extern void btm_route_sco_data(BT_HDR* p_msg); 166 extern bool btm_is_sco_active(uint16_t handle); 167 extern void btm_remove_sco_links(const RawAddress& bda); 168 extern bool btm_is_sco_active_by_bdaddr(const RawAddress& remote_bda); 169 170 extern void btm_read_def_esco_mode(enh_esco_params_t* p_parms); 171 extern uint16_t btm_find_scb_by_handle(uint16_t handle); 172 extern void btm_sco_flush_sco_data(uint16_t sco_inx); 173 174 /* Internal functions provided by btm_devctl.cc 175 ********************************************* 176 */ 177 extern void btm_dev_init(void); 178 extern void btm_read_local_name_timeout(void* data); 179 extern void btm_read_local_name_complete(uint8_t* p, uint16_t evt_len); 180 181 extern void btm_ble_create_conn_cancel_complete(uint8_t* p); 182 extern bool btm_ble_addr_resolvable(const RawAddress& rpa, 183 tBTM_SEC_DEV_REC* p_dev_rec); 184 extern tBTM_STATUS btm_ble_read_resolving_list_entry( 185 tBTM_SEC_DEV_REC* p_dev_rec); 186 extern bool btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC* p_dev_rec); 187 extern void btm_ble_resolving_list_remove_dev(tBTM_SEC_DEV_REC* p_dev_rec); 188 189 /* Vendor Specific Command complete evt handler */ 190 extern void btm_vsc_complete(uint8_t* p, uint16_t cc_opcode, uint16_t evt_len, 191 tBTM_VSC_CMPL_CB* p_vsc_cplt_cback); 192 extern void btm_inq_db_reset(void); 193 extern void btm_vendor_specific_evt(uint8_t* p, uint8_t evt_len); 194 extern void btm_delete_stored_link_key_complete(uint8_t* p); 195 extern void btm_report_device_status(tBTM_DEV_STATUS status); 196 extern tBTM_STATUS BTM_BT_Quality_Report_VSE_Register( 197 bool is_register, tBTM_BT_QUALITY_REPORT_RECEIVER* p_bqr_report_receiver); 198 199 /* Internal functions provided by btm_dev.cc 200 ********************************************* 201 */ 202 extern bool btm_dev_support_switch(const RawAddress& bd_addr); 203 204 extern tBTM_SEC_DEV_REC* btm_sec_allocate_dev_rec(void); 205 extern tBTM_SEC_DEV_REC* btm_sec_alloc_dev(const RawAddress& bd_addr); 206 extern void wipe_secrets_and_remove(tBTM_SEC_DEV_REC* p_dev_rec); 207 extern tBTM_SEC_DEV_REC* btm_find_dev(const RawAddress& bd_addr); 208 extern tBTM_SEC_DEV_REC* btm_find_or_alloc_dev(const RawAddress& bd_addr); 209 extern tBTM_SEC_DEV_REC* btm_find_dev_by_handle(uint16_t handle); 210 extern tBTM_BOND_TYPE btm_get_bond_type_dev(const RawAddress& bd_addr); 211 extern bool btm_set_bond_type_dev(const RawAddress& bd_addr, 212 tBTM_BOND_TYPE bond_type); 213 214 /* Internal functions provided by btm_sec.cc 215 ********************************************* 216 */ 217 extern bool btm_dev_support_switch(const RawAddress& bd_addr); 218 extern tBTM_STATUS btm_sec_l2cap_access_req(const RawAddress& bd_addr, 219 uint16_t psm, uint16_t handle, 220 CONNECTION_TYPE conn_type, 221 tBTM_SEC_CALLBACK* p_callback, 222 void* p_ref_data); 223 extern tBTM_STATUS btm_sec_mx_access_request(const RawAddress& bd_addr, 224 uint16_t psm, bool is_originator, 225 uint32_t mx_proto_id, 226 uint32_t mx_chan_id, 227 tBTM_SEC_CALLBACK* p_callback, 228 void* p_ref_data); 229 extern void btm_sec_conn_req(const RawAddress& bda, uint8_t* dc); 230 extern void btm_create_conn_cancel_complete(uint8_t* p); 231 232 extern void btm_read_inq_tx_power_timeout(void* data); 233 extern void btm_read_inq_tx_power_complete(uint8_t* p); 234 235 extern void btm_sec_init(uint8_t sec_mode); 236 extern void btm_sec_dev_reset(void); 237 extern void btm_sec_abort_access_req(const RawAddress& bd_addr); 238 extern void btm_sec_auth_complete(uint16_t handle, uint8_t status); 239 extern void btm_sec_encrypt_change(uint16_t handle, uint8_t status, 240 uint8_t encr_enable); 241 extern void btm_sec_connected(const RawAddress& bda, uint16_t handle, 242 uint8_t status, uint8_t enc_mode); 243 extern tBTM_STATUS btm_sec_disconnect(uint16_t handle, uint8_t reason); 244 extern void btm_sec_disconnected(uint16_t handle, uint8_t reason); 245 extern void btm_sec_rmt_name_request_complete(const RawAddress* bd_addr, 246 uint8_t* bd_name, uint8_t status); 247 extern void btm_sec_rmt_host_support_feat_evt(uint8_t* p); 248 extern void btm_io_capabilities_req(const RawAddress& p); 249 extern void btm_io_capabilities_rsp(uint8_t* p); 250 extern void btm_proc_sp_req_evt(tBTM_SP_EVT event, uint8_t* p); 251 extern void btm_keypress_notif_evt(uint8_t* p); 252 extern void btm_simple_pair_complete(uint8_t* p); 253 extern void btm_sec_link_key_notification(const RawAddress& p_bda, 254 const Octet16& link_key, 255 uint8_t key_type); 256 extern void btm_sec_link_key_request(const RawAddress& p_bda); 257 extern void btm_sec_pin_code_request(const RawAddress& p_bda); 258 extern void btm_sec_update_clock_offset(uint16_t handle, uint16_t clock_offset); 259 extern void btm_sec_dev_rec_cback_event(tBTM_SEC_DEV_REC* p_dev_rec, 260 uint8_t res, bool is_le_trasnport); 261 extern void btm_sec_set_peer_sec_caps(tACL_CONN* p_acl_cb, 262 tBTM_SEC_DEV_REC* p_dev_rec); 263 264 extern void btm_sec_clear_ble_keys(tBTM_SEC_DEV_REC* p_dev_rec); 265 extern bool btm_sec_is_a_bonded_dev(const RawAddress& bda); 266 extern void btm_consolidate_dev(tBTM_SEC_DEV_REC* p_target_rec); 267 extern bool btm_sec_is_le_capable_dev(const RawAddress& bda); 268 extern bool btm_ble_init_pseudo_addr(tBTM_SEC_DEV_REC* p_dev_rec, 269 const RawAddress& new_pseudo_addr); 270 extern tBTM_SEC_SERV_REC* btm_sec_find_first_serv(CONNECTION_TYPE conn_type, 271 uint16_t psm); 272 extern tL2CAP_LE_RESULT_CODE btm_ble_start_sec_check( 273 const RawAddress& bd_addr, uint16_t psm, bool is_originator, 274 tBTM_SEC_CALLBACK* p_callback, void* p_ref_data); 275 276 extern tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda); 277 278 extern void btm_rem_oob_req(uint8_t* p); 279 extern void btm_read_local_oob_complete(uint8_t* p); 280 281 extern void btm_acl_resubmit_page(void); 282 extern void btm_acl_reset_paging(void); 283 extern void btm_acl_paging(BT_HDR* p, const RawAddress& dest); 284 extern uint8_t btm_sec_clr_service_by_psm(uint16_t psm); 285 extern void btm_sec_clr_temp_auth_service(const RawAddress& bda); 286 extern tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec); 287 288 #endif 289