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 94 extern void btm_read_rssi_timeout(void* data); 95 extern void btm_read_rssi_complete(uint8_t* p); 96 97 extern void btm_read_failed_contact_counter_timeout(void* data); 98 extern void btm_read_failed_contact_counter_complete(uint8_t* p); 99 100 extern void btm_read_automatic_flush_timeout_timeout(void* data); 101 extern void btm_read_automatic_flush_timeout_complete(uint8_t* p); 102 103 extern void btm_read_tx_power_timeout(void* data); 104 extern void btm_read_tx_power_complete(uint8_t* p, bool is_ble); 105 106 extern void btm_read_link_quality_complete(uint8_t* p); 107 108 extern tBTM_STATUS btm_set_packet_types(tACL_CONN* p, uint16_t pkt_types); 109 extern void btm_process_clk_off_comp_evt(uint16_t hci_handle, 110 uint16_t clock_offset); 111 extern void btm_acl_role_changed(uint8_t hci_status, const RawAddress* bd_addr, 112 uint8_t new_role); 113 extern void btm_blacklist_role_change_device(const RawAddress& bd_addr, 114 uint8_t hci_status); 115 extern void btm_acl_encrypt_change(uint16_t handle, uint8_t status, 116 uint8_t encr_enable); 117 extern uint16_t btm_get_acl_disc_reason_code(void); 118 extern tBTM_STATUS btm_remove_acl(const RawAddress& bd_addr, 119 tBT_TRANSPORT transport); 120 extern void btm_read_remote_features_complete(uint8_t* p); 121 extern void btm_read_remote_ext_features_complete(uint8_t* p, uint8_t evt_len); 122 extern void btm_read_remote_ext_features_failed(uint8_t status, 123 uint16_t handle); 124 extern void btm_read_remote_version_complete(uint8_t* p); 125 extern void btm_establish_continue(tACL_CONN* p_acl_cb); 126 127 extern void btm_acl_chk_peer_pkt_type_support(tACL_CONN* p, 128 uint16_t* p_pkt_type); 129 /* Read maximum data packet that can be sent over current connection */ 130 extern uint16_t btm_get_max_packet_size(const RawAddress& addr); 131 extern tACL_CONN* btm_bda_to_acl(const RawAddress& bda, 132 tBT_TRANSPORT transport); 133 extern bool btm_acl_notif_conn_collision(const RawAddress& bda); 134 extern void btm_acl_update_conn_addr(uint16_t conn_handle, 135 const RawAddress& address); 136 137 extern void btm_pm_reset(void); 138 extern void btm_pm_sm_alloc(uint8_t ind); 139 extern void btm_pm_proc_cmd_status(uint8_t status); 140 extern void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle, 141 uint8_t mode, uint16_t interval); 142 extern void btm_pm_proc_ssr_evt(uint8_t* p, uint16_t evt_len); 143 extern tBTM_STATUS btm_read_power_mode_state(const RawAddress& remote_bda, 144 tBTM_PM_STATE* pmState); 145 extern void btm_sco_chk_pend_unpark(uint8_t hci_status, uint16_t hci_handle); 146 extern void btm_qos_setup_complete(uint8_t status, uint16_t handle, 147 FLOW_SPEC* p_flow); 148 149 /* Internal functions provided by btm_sco.cc 150 ******************************************* 151 */ 152 extern void btm_sco_init(void); 153 extern void btm_sco_connected(uint8_t hci_status, const RawAddress* bda, 154 uint16_t hci_handle, tBTM_ESCO_DATA* p_esco_data); 155 extern void btm_esco_proc_conn_chg(uint8_t status, uint16_t handle, 156 uint8_t tx_interval, uint8_t retrans_window, 157 uint16_t rx_pkt_len, uint16_t tx_pkt_len); 158 extern void btm_sco_conn_req(const RawAddress& bda, DEV_CLASS dev_class, 159 uint8_t link_type); 160 extern void btm_sco_removed(uint16_t hci_handle, uint8_t reason); 161 extern void btm_sco_acl_removed(const RawAddress* bda); 162 extern void btm_route_sco_data(BT_HDR* p_msg); 163 extern bool btm_is_sco_active(uint16_t handle); 164 extern void btm_remove_sco_links(const RawAddress& bda); 165 extern bool btm_is_sco_active_by_bdaddr(const RawAddress& remote_bda); 166 167 extern void btm_read_def_esco_mode(enh_esco_params_t* p_parms); 168 extern uint16_t btm_find_scb_by_handle(uint16_t handle); 169 extern void btm_sco_flush_sco_data(uint16_t sco_inx); 170 171 /* Internal functions provided by btm_devctl.cc 172 ********************************************* 173 */ 174 extern void btm_dev_init(void); 175 extern void btm_read_local_name_timeout(void* data); 176 extern void btm_read_local_name_complete(uint8_t* p, uint16_t evt_len); 177 178 extern void btm_ble_create_conn_cancel_complete(uint8_t* p); 179 extern bool btm_ble_addr_resolvable(const RawAddress& rpa, 180 tBTM_SEC_DEV_REC* p_dev_rec); 181 extern tBTM_STATUS btm_ble_read_resolving_list_entry( 182 tBTM_SEC_DEV_REC* p_dev_rec); 183 extern bool btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC* p_dev_rec); 184 extern void btm_ble_resolving_list_remove_dev(tBTM_SEC_DEV_REC* p_dev_rec); 185 186 /* Vendor Specific Command complete evt handler */ 187 extern void btm_vsc_complete(uint8_t* p, uint16_t cc_opcode, uint16_t evt_len, 188 tBTM_VSC_CMPL_CB* p_vsc_cplt_cback); 189 extern void btm_inq_db_reset(void); 190 extern void btm_vendor_specific_evt(uint8_t* p, uint8_t evt_len); 191 extern void btm_delete_stored_link_key_complete(uint8_t* p); 192 extern void btm_report_device_status(tBTM_DEV_STATUS status); 193 extern tBTM_STATUS BTM_BT_Quality_Report_VSE_Register( 194 bool is_register, tBTM_BT_QUALITY_REPORT_RECEIVER* p_bqr_report_receiver); 195 196 /* Internal functions provided by btm_dev.cc 197 ********************************************* 198 */ 199 extern bool btm_dev_support_switch(const RawAddress& bd_addr); 200 201 extern tBTM_SEC_DEV_REC* btm_sec_allocate_dev_rec(void); 202 extern tBTM_SEC_DEV_REC* btm_sec_alloc_dev(const RawAddress& bd_addr); 203 extern void wipe_secrets_and_remove(tBTM_SEC_DEV_REC* p_dev_rec); 204 extern tBTM_SEC_DEV_REC* btm_find_dev(const RawAddress& bd_addr); 205 extern tBTM_SEC_DEV_REC* btm_find_or_alloc_dev(const RawAddress& bd_addr); 206 extern tBTM_SEC_DEV_REC* btm_find_dev_by_handle(uint16_t handle); 207 extern tBTM_BOND_TYPE btm_get_bond_type_dev(const RawAddress& bd_addr); 208 extern bool btm_set_bond_type_dev(const RawAddress& bd_addr, 209 tBTM_BOND_TYPE bond_type); 210 211 /* Internal functions provided by btm_sec.cc 212 ********************************************* 213 */ 214 extern bool btm_dev_support_switch(const RawAddress& bd_addr); 215 extern tBTM_STATUS btm_sec_l2cap_access_req(const RawAddress& bd_addr, 216 uint16_t psm, uint16_t handle, 217 CONNECTION_TYPE conn_type, 218 tBTM_SEC_CALLBACK* p_callback, 219 void* p_ref_data); 220 extern tBTM_STATUS btm_sec_mx_access_request(const RawAddress& bd_addr, 221 uint16_t psm, bool is_originator, 222 uint32_t mx_proto_id, 223 uint32_t mx_chan_id, 224 tBTM_SEC_CALLBACK* p_callback, 225 void* p_ref_data); 226 extern void btm_sec_conn_req(const RawAddress& bda, uint8_t* dc); 227 extern void btm_create_conn_cancel_complete(uint8_t* p); 228 229 extern void btm_read_inq_tx_power_complete(uint8_t* p); 230 231 extern void btm_sec_init(uint8_t sec_mode); 232 extern void btm_sec_dev_reset(void); 233 extern void btm_sec_abort_access_req(const RawAddress& bd_addr); 234 extern void btm_sec_auth_complete(uint16_t handle, uint8_t status); 235 extern void btm_sec_encrypt_change(uint16_t handle, uint8_t status, 236 uint8_t encr_enable); 237 extern void btm_sec_connected(const RawAddress& bda, uint16_t handle, 238 uint8_t status, uint8_t enc_mode); 239 extern tBTM_STATUS btm_sec_disconnect(uint16_t handle, uint8_t reason); 240 extern void btm_sec_disconnected(uint16_t handle, uint8_t reason); 241 extern void btm_sec_rmt_name_request_complete(const RawAddress* bd_addr, 242 uint8_t* bd_name, uint8_t status); 243 extern void btm_sec_rmt_host_support_feat_evt(uint8_t* p); 244 extern void btm_io_capabilities_req(const RawAddress& p); 245 extern void btm_io_capabilities_rsp(uint8_t* p); 246 extern void btm_proc_sp_req_evt(tBTM_SP_EVT event, uint8_t* p); 247 extern void btm_keypress_notif_evt(uint8_t* p); 248 extern void btm_simple_pair_complete(uint8_t* p); 249 extern void btm_sec_link_key_notification(const RawAddress& p_bda, 250 const Octet16& link_key, 251 uint8_t key_type); 252 extern void btm_sec_link_key_request(const RawAddress& p_bda); 253 extern void btm_sec_pin_code_request(const RawAddress& p_bda); 254 extern void btm_sec_update_clock_offset(uint16_t handle, uint16_t clock_offset); 255 extern void btm_sec_dev_rec_cback_event(tBTM_SEC_DEV_REC* p_dev_rec, 256 uint8_t res, bool is_le_trasnport); 257 extern void btm_sec_set_peer_sec_caps(tACL_CONN* p_acl_cb, 258 tBTM_SEC_DEV_REC* p_dev_rec); 259 260 extern void btm_sec_clear_ble_keys(tBTM_SEC_DEV_REC* p_dev_rec); 261 extern bool btm_sec_is_a_bonded_dev(const RawAddress& bda); 262 extern void btm_consolidate_dev(tBTM_SEC_DEV_REC* p_target_rec); 263 extern bool btm_ble_init_pseudo_addr(tBTM_SEC_DEV_REC* p_dev_rec, 264 const RawAddress& new_pseudo_addr); 265 extern tBTM_SEC_SERV_REC* btm_sec_find_first_serv(CONNECTION_TYPE conn_type, 266 uint16_t psm); 267 extern tL2CAP_LE_RESULT_CODE btm_ble_start_sec_check( 268 const RawAddress& bd_addr, uint16_t psm, bool is_originator, 269 tBTM_SEC_CALLBACK* p_callback, void* p_ref_data); 270 271 extern tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda); 272 273 extern void btm_rem_oob_req(uint8_t* p); 274 extern void btm_read_local_oob_complete(uint8_t* p); 275 276 extern void btm_acl_resubmit_page(void); 277 extern void btm_acl_paging(BT_HDR* p, const RawAddress& dest); 278 extern uint8_t btm_sec_clr_service_by_psm(uint16_t psm); 279 extern void btm_sec_clr_temp_auth_service(const RawAddress& bda); 280 extern tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec); 281 282 #endif 283