btm_ble_int.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. * this file contains the main Bluetooth Manager (BTM) internal
  21. * definitions.
  22. *
  23. ******************************************************************************/
  24. #ifndef BTM_BLE_INT_H
  25. #define BTM_BLE_INT_H
  26. #include "bt_common.h"
  27. #include "bt_target.h"
  28. #include "btm_ble_api.h"
  29. #include "btm_ble_int_types.h"
  30. #include "btm_int.h"
  31. #include "btm_int_types.h"
  32. #include "hcidefs.h"
  33. #include "smp_api.h"
  34. extern bool ble_evt_type_is_connectable(uint16_t evt_type);
  35. extern void btm_ble_refresh_raddr_timer_timeout(void* data);
  36. extern void btm_ble_process_adv_pkt(uint8_t len, uint8_t* p);
  37. extern void btm_ble_process_phy_update_pkt(uint8_t len, uint8_t* p);
  38. extern void btm_ble_process_ext_adv_pkt(uint8_t len, uint8_t* p);
  39. extern void btm_ble_proc_scan_rsp_rpt(uint8_t* p);
  40. extern tBTM_STATUS btm_ble_read_remote_name(const RawAddress& remote_bda,
  41. tBTM_CMPL_CB* p_cb);
  42. extern bool btm_ble_cancel_remote_name(const RawAddress& remote_bda);
  43. extern tBTM_STATUS btm_ble_set_discoverability(uint16_t combined_mode);
  44. extern tBTM_STATUS btm_ble_set_connectability(uint16_t combined_mode);
  45. extern void btm_send_hci_scan_enable(uint8_t enable, uint8_t filter_duplicates);
  46. extern void btm_send_hci_set_scan_params(uint8_t scan_type, uint16_t scan_int,
  47. uint16_t scan_win,
  48. uint8_t addr_type_own,
  49. uint8_t scan_filter_policy);
  50. extern tBTM_STATUS btm_ble_start_inquiry(uint8_t mode, uint8_t duration);
  51. extern void btm_ble_stop_scan(void);
  52. extern void btm_clear_all_pending_le_entry(void);
  53. extern void btm_ble_stop_scan();
  54. extern void btm_ble_stop_inquiry(void);
  55. extern void btm_ble_init(void);
  56. extern void btm_ble_connected(const RawAddress& bda, uint16_t handle,
  57. uint8_t enc_mode, uint8_t role,
  58. tBLE_ADDR_TYPE addr_type, bool addr_matched);
  59. extern void btm_ble_read_remote_features_complete(uint8_t* p);
  60. extern void btm_ble_write_adv_enable_complete(uint8_t* p);
  61. extern void btm_ble_conn_complete(uint8_t* p, uint16_t evt_len, bool enhanced);
  62. extern void btm_read_ble_local_supported_states_complete(uint8_t* p,
  63. uint16_t evt_len);
  64. extern tBTM_BLE_CONN_ST btm_ble_get_conn_st(void);
  65. extern tBTM_STATUS btm_ble_start_adv(void);
  66. extern tBTM_STATUS btm_ble_stop_adv(void);
  67. extern void btm_le_on_advertising_set_terminated(uint8_t* p, uint16_t length);
  68. extern tBTM_STATUS btm_ble_start_scan(void);
  69. extern void btm_ble_create_ll_conn_complete(uint8_t status);
  70. /* LE security function from btm_sec.cc */
  71. extern void btm_ble_link_sec_check(const RawAddress& bd_addr,
  72. tBTM_LE_AUTH_REQ auth_req,
  73. tBTM_BLE_SEC_REQ_ACT* p_sec_req_act);
  74. extern void btm_ble_ltk_request_reply(const RawAddress& bda, bool use_stk,
  75. const Octet16& stk);
  76. extern uint8_t btm_proc_smp_cback(tSMP_EVT event, const RawAddress& bd_addr,
  77. tSMP_EVT_DATA* p_data);
  78. extern tBTM_STATUS btm_ble_set_encryption(const RawAddress& bd_addr,
  79. tBTM_BLE_SEC_ACT sec_act,
  80. uint8_t link_role);
  81. extern void btm_ble_ltk_request(uint16_t handle, uint8_t rand[8],
  82. uint16_t ediv);
  83. extern tBTM_STATUS btm_ble_start_encrypt(const RawAddress& bda, bool use_stk,
  84. Octet16* p_stk);
  85. extern void btm_ble_link_encrypted(const RawAddress& bd_addr,
  86. uint8_t encr_enable);
  87. /* LE device management functions */
  88. extern void btm_ble_reset_id(void);
  89. /* security related functions */
  90. extern void btm_ble_increment_sign_ctr(const RawAddress& bd_addr,
  91. bool is_local);
  92. extern bool btm_get_local_div(const RawAddress& bd_addr, uint16_t* p_div);
  93. extern bool btm_ble_get_enc_key_type(const RawAddress& bd_addr,
  94. uint8_t* p_key_types);
  95. extern void btm_ble_test_command_complete(uint8_t* p);
  96. extern void btm_ble_rand_enc_complete(uint8_t* p, uint16_t op_code,
  97. tBTM_RAND_ENC_CB* p_enc_cplt_cback);
  98. extern void btm_sec_save_le_key(const RawAddress& bd_addr,
  99. tBTM_LE_KEY_TYPE key_type,
  100. tBTM_LE_KEY_VALUE* p_keys,
  101. bool pass_to_application);
  102. extern void btm_ble_update_sec_key_size(const RawAddress& bd_addr,
  103. uint8_t enc_key_size);
  104. extern uint8_t btm_ble_read_sec_key_size(const RawAddress& bd_addr);
  105. /* white list function */
  106. extern void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy);
  107. extern void btm_update_adv_filter_policy(tBTM_BLE_AFP adv_policy);
  108. extern void btm_ble_white_list_init(uint8_t white_list_size);
  109. /* background connection function */
  110. extern bool btm_ble_suspend_bg_conn(void);
  111. extern bool btm_ble_resume_bg_conn(void);
  112. extern bool btm_ble_start_auto_conn();
  113. extern bool btm_ble_stop_auto_conn();
  114. extern void btm_ble_update_mode_operation(uint8_t link_role,
  115. const RawAddress* bda,
  116. uint8_t status);
  117. extern bool btm_execute_wl_dev_operation(void);
  118. extern void btm_ble_update_link_topology_mask(uint8_t role, bool increase);
  119. extern void btm_ble_bgconn_cancel_if_disconnected(const RawAddress& bd_addr);
  120. /* BLE address management */
  121. extern void btm_gen_resolvable_private_addr(
  122. base::Callback<void(const RawAddress& rpa)> cb);
  123. extern void btm_gen_non_resolvable_private_addr(tBTM_BLE_ADDR_CBACK* p_cback,
  124. void* p);
  125. extern tBTM_SEC_DEV_REC* btm_ble_resolve_random_addr(
  126. const RawAddress& random_bda);
  127. extern void btm_gen_resolve_paddr_low(const RawAddress& address);
  128. /* privacy function */
  129. #if (BLE_PRIVACY_SPT == TRUE)
  130. /* BLE address mapping with CS feature */
  131. extern bool btm_identity_addr_to_random_pseudo(RawAddress* bd_addr,
  132. uint8_t* p_addr_type,
  133. bool refresh);
  134. extern bool btm_random_pseudo_to_identity_addr(RawAddress* random_pseudo,
  135. uint8_t* p_identity_addr_type);
  136. extern void btm_ble_refresh_peer_resolvable_private_addr(
  137. const RawAddress& pseudo_bda, const RawAddress& rra, uint8_t rra_type);
  138. extern void btm_ble_refresh_local_resolvable_private_addr(
  139. const RawAddress& pseudo_addr, const RawAddress& local_rpa);
  140. extern void btm_ble_read_resolving_list_entry_complete(uint8_t* p,
  141. uint16_t evt_len);
  142. extern void btm_ble_remove_resolving_list_entry_complete(uint8_t* p,
  143. uint16_t evt_len);
  144. extern void btm_ble_add_resolving_list_entry_complete(uint8_t* p,
  145. uint16_t evt_len);
  146. extern void btm_ble_clear_resolving_list_complete(uint8_t* p, uint16_t evt_len);
  147. extern void btm_read_ble_resolving_list_size_complete(uint8_t* p,
  148. uint16_t evt_len);
  149. extern void btm_ble_enable_resolving_list(uint8_t);
  150. extern bool btm_ble_disable_resolving_list(uint8_t rl_mask, bool to_resume);
  151. extern void btm_ble_enable_resolving_list_for_platform(uint8_t rl_mask);
  152. extern void btm_ble_resolving_list_init(uint8_t max_irk_list_sz);
  153. extern void btm_ble_resolving_list_cleanup(void);
  154. #endif
  155. extern void btm_ble_adv_init(void);
  156. extern void* btm_ble_multi_adv_get_ref(uint8_t inst_id);
  157. extern void btm_ble_multi_adv_cleanup(void);
  158. extern void btm_ble_batchscan_init(void);
  159. extern void btm_ble_batchscan_cleanup(void);
  160. extern void btm_ble_adv_filter_init(void);
  161. extern void btm_ble_adv_filter_cleanup(void);
  162. extern bool btm_ble_topology_check(tBTM_BLE_STATE_MASK request);
  163. extern bool btm_ble_clear_topology_mask(tBTM_BLE_STATE_MASK request_state);
  164. extern bool btm_ble_set_topology_mask(tBTM_BLE_STATE_MASK request_state);
  165. extern void btm_ble_set_random_address(const RawAddress& random_bda);
  166. #if (BTM_BLE_CONFORMANCE_TESTING == TRUE)
  167. extern void btm_ble_set_no_disc_if_pair_fail(bool disble_disc);
  168. extern void btm_ble_set_test_mac_value(bool enable, uint8_t* p_test_mac_val);
  169. extern void btm_ble_set_test_local_sign_cntr_value(
  170. bool enable, uint32_t test_local_sign_cntr);
  171. extern void btm_ble_set_keep_rfu_in_auth_req(bool keep_rfu);
  172. #endif
  173. #endif