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 26 #ifndef BTM_BLE_INT_H 27 #define BTM_BLE_INT_H 28 29 #include "bt_target.h" 30 #include "btm_ble_api.h" 31 #include "btm_ble_int_types.h" 32 #include "btm_int_types.h" 33 #include "smp_api.h" 34 #include "stack/include/hci_error_code.h" 35 #include "types/ble_address_with_type.h" 36 #include "types/raw_address.h" 37 38 extern void btm_ble_process_periodic_adv_sync_est_evt(uint8_t len, 39 const uint8_t* p); 40 extern void btm_ble_process_periodic_adv_pkt(uint8_t len, const uint8_t* p); 41 extern void btm_ble_process_periodic_adv_sync_lost_evt(uint8_t len, uint8_t* p); 42 extern void btm_send_hci_set_scan_params(uint8_t scan_type, uint16_t scan_int, 43 uint16_t scan_win, 44 tBLE_ADDR_TYPE addr_type_own, 45 uint8_t scan_filter_policy); 46 extern void btm_ble_stop_scan(void); 47 extern void btm_clear_all_pending_le_entry(void); 48 49 extern void btm_ble_init(void); 50 extern void btm_ble_free(); 51 extern void btm_ble_connected(const RawAddress& bda, uint16_t handle, 52 uint8_t enc_mode, uint8_t role, 53 tBLE_ADDR_TYPE addr_type, bool addr_matched); 54 extern void btm_ble_connected_from_address_with_type( 55 const tBLE_BD_ADDR& address_with_type, uint16_t handle, uint8_t enc_mode, 56 uint8_t role, bool addr_matched); 57 58 extern tBTM_STATUS btm_ble_start_adv(void); 59 extern tBTM_STATUS btm_ble_stop_adv(void); 60 extern void btm_ble_start_scan(void); 61 62 /* LE security function from btm_sec.cc */ 63 extern void btm_ble_link_sec_check(const RawAddress& bd_addr, 64 tBTM_LE_AUTH_REQ auth_req, 65 tBTM_BLE_SEC_REQ_ACT* p_sec_req_act); 66 extern void btm_ble_ltk_request_reply(const RawAddress& bda, bool use_stk, 67 const Octet16& stk); 68 extern tBTM_STATUS btm_proc_smp_cback(tSMP_EVT event, const RawAddress& bd_addr, 69 const tSMP_EVT_DATA* p_data); 70 extern tBTM_STATUS btm_ble_set_encryption(const RawAddress& bd_addr, 71 tBTM_BLE_SEC_ACT sec_act, 72 uint8_t link_role); 73 extern tBTM_STATUS btm_ble_start_encrypt(const RawAddress& bda, bool use_stk, 74 Octet16* p_stk); 75 extern void btm_ble_link_encrypted(const RawAddress& bd_addr, 76 uint8_t encr_enable); 77 78 /* LE device management functions */ 79 extern void btm_ble_reset_id(void); 80 81 extern bool btm_get_local_div(const RawAddress& bd_addr, uint16_t* p_div); 82 extern bool btm_ble_get_enc_key_type(const RawAddress& bd_addr, 83 uint8_t* p_key_types); 84 85 extern void btm_sec_save_le_key(const RawAddress& bd_addr, 86 tBTM_LE_KEY_TYPE key_type, 87 tBTM_LE_KEY_VALUE* p_keys, 88 bool pass_to_application); 89 extern void btm_ble_update_sec_key_size(const RawAddress& bd_addr, 90 uint8_t enc_key_size); 91 extern uint8_t btm_ble_read_sec_key_size(const RawAddress& bd_addr); 92 93 /* acceptlist function */ 94 extern void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy); 95 96 /* background connection function */ 97 extern bool btm_ble_suspend_bg_conn(void); 98 extern bool btm_ble_resume_bg_conn(void); 99 extern void btm_ble_update_mode_operation(uint8_t link_role, 100 const RawAddress* bda, 101 tHCI_STATUS status); 102 /* BLE address management */ 103 extern void btm_gen_resolvable_private_addr( 104 base::Callback<void(const RawAddress& rpa)> cb); 105 106 extern tBTM_SEC_DEV_REC* btm_ble_resolve_random_addr( 107 const RawAddress& random_bda); 108 extern void btm_gen_resolve_paddr_low(const RawAddress& address); 109 extern uint64_t btm_get_next_private_addrress_interval_ms(); 110 111 /* privacy function */ 112 /* BLE address mapping with CS feature */ 113 extern bool btm_random_pseudo_to_identity_addr( 114 RawAddress* random_pseudo, tBLE_ADDR_TYPE* p_identity_addr_type); 115 extern void btm_ble_refresh_peer_resolvable_private_addr( 116 const RawAddress& pseudo_bda, const RawAddress& rra, 117 tBTM_SEC_BLE::tADDRESS_TYPE type); 118 extern bool btm_ble_read_resolving_list_entry(tBTM_SEC_DEV_REC* p_dev_rec); 119 120 extern bool btm_ble_addr_resolvable(const RawAddress& rpa, 121 tBTM_SEC_DEV_REC* p_dev_rec); 122 123 extern void btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC& p_dev_rec); 124 extern void btm_ble_resolving_list_remove_dev(tBTM_SEC_DEV_REC* p_dev_rec); 125 extern void btm_ble_resolving_list_init(uint8_t max_irk_list_sz); 126 127 extern void btm_ble_adv_init(void); 128 extern void btm_ble_multi_adv_cleanup(void); 129 extern void btm_ble_batchscan_init(void); 130 extern void btm_ble_adv_filter_init(void); 131 extern bool btm_ble_topology_check(tBTM_BLE_STATE_MASK request); 132 extern bool btm_ble_clear_topology_mask(tBTM_BLE_STATE_MASK request_state); 133 extern bool btm_ble_set_topology_mask(tBTM_BLE_STATE_MASK request_state); 134 135 extern void btm_ble_scanner_init(void); 136 extern void btm_ble_scanner_cleanup(void); 137 138 #if (BTM_BLE_CONFORMANCE_TESTING == TRUE) 139 extern void btm_ble_set_no_disc_if_pair_fail(bool disble_disc); 140 extern void btm_ble_set_test_mac_value(bool enable, uint8_t* p_test_mac_val); 141 extern void btm_ble_set_test_local_sign_cntr_value( 142 bool enable, uint32_t test_local_sign_cntr); 143 extern void btm_ble_set_keep_rfu_in_auth_req(bool keep_rfu); 144 #endif 145 146 #endif 147