• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "smp_api.h"
43 
44 extern tBTM_CB btm_cb;
45 
46 /* Internal functions provided by btm_main.cc
47  *******************************************
48 */
49 extern void btm_init(void);
50 extern void btm_free(void);
51 
52 /* Internal functions provided by btm_inq.cc
53  ******************************************
54 */
55 extern tBTM_STATUS btm_initiate_rem_name(const RawAddress& remote_bda,
56                                          uint8_t origin, period_ms_t timeout_ms,
57                                          tBTM_CMPL_CB* p_cb);
58 
59 extern void btm_process_remote_name(const RawAddress* bda, BD_NAME name,
60                                     uint16_t evt_len, uint8_t hci_status);
61 extern void btm_inq_rmt_name_failed(void);
62 extern void btm_inq_remote_name_timer_timeout(void* data);
63 
64 /* Inquiry related functions */
65 extern void btm_clr_inq_db(const RawAddress* p_bda);
66 extern void btm_inq_db_init(void);
67 extern void btm_process_inq_results(uint8_t* p, uint8_t inq_res_mode);
68 extern void btm_process_inq_complete(uint8_t status, uint8_t mode);
69 extern void btm_process_cancel_complete(uint8_t status, uint8_t mode);
70 extern void btm_event_filter_complete(uint8_t* p);
71 extern void btm_inq_stop_on_ssp(void);
72 extern void btm_inq_clear_ssp(void);
73 extern tINQ_DB_ENT* btm_inq_db_find(const RawAddress& p_bda);
74 extern bool btm_inq_find_bdaddr(const RawAddress& p_bda);
75 
76 /* Internal functions provided by btm_acl.cc
77  *******************************************
78 */
79 extern void btm_acl_init(void);
80 extern void btm_acl_created(const RawAddress& bda, DEV_CLASS dc, BD_NAME bdn,
81                             uint16_t hci_handle, uint8_t link_role,
82                             tBT_TRANSPORT transport);
83 extern void btm_acl_removed(const RawAddress& bda, tBT_TRANSPORT transport);
84 extern void btm_acl_device_down(void);
85 extern void btm_acl_update_busy_level(tBTM_BLI_EVENT event);
86 
87 extern void btm_cont_rswitch(tACL_CONN* p, tBTM_SEC_DEV_REC* p_dev_rec,
88                              uint8_t hci_status);
89 
90 extern uint8_t btm_handle_to_acl_index(uint16_t hci_handle);
91 extern void btm_read_link_policy_complete(uint8_t* p);
92 
93 extern void btm_read_rssi_timeout(void* data);
94 extern void btm_read_rssi_complete(uint8_t* p);
95 
96 extern void btm_read_failed_contact_counter_timeout(void* data);
97 extern void btm_read_failed_contact_counter_complete(uint8_t* p);
98 
99 extern void btm_read_automatic_flush_timeout_timeout(void* data);
100 extern void btm_read_automatic_flush_timeout_complete(uint8_t* p);
101 
102 extern void btm_read_tx_power_timeout(void* data);
103 extern void btm_read_tx_power_complete(uint8_t* p, bool is_ble);
104 
105 extern void btm_read_link_quality_timeout(void* data);
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 #if (BTM_SCO_INCLUDED == TRUE)
146 extern void btm_sco_chk_pend_unpark(uint8_t hci_status, uint16_t hci_handle);
147 #else
148 #define btm_sco_chk_pend_unpark(hci_status, hci_handle)
149 #endif /* BTM_SCO_INCLUDED */
150 
151 extern void btm_qos_setup_timeout(void* data);
152 extern void btm_qos_setup_complete(uint8_t status, uint16_t handle,
153                                    FLOW_SPEC* p_flow);
154 
155 /* Internal functions provided by btm_sco.cc
156  *******************************************
157 */
158 extern void btm_sco_init(void);
159 extern void btm_sco_connected(uint8_t hci_status, const RawAddress* bda,
160                               uint16_t hci_handle, tBTM_ESCO_DATA* p_esco_data);
161 extern void btm_esco_proc_conn_chg(uint8_t status, uint16_t handle,
162                                    uint8_t tx_interval, uint8_t retrans_window,
163                                    uint16_t rx_pkt_len, uint16_t tx_pkt_len);
164 extern void btm_sco_conn_req(const RawAddress& bda, DEV_CLASS dev_class,
165                              uint8_t link_type);
166 extern void btm_sco_removed(uint16_t hci_handle, uint8_t reason);
167 extern void btm_sco_acl_removed(const RawAddress* bda);
168 extern void btm_route_sco_data(BT_HDR* p_msg);
169 extern bool btm_is_sco_active(uint16_t handle);
170 extern void btm_remove_sco_links(const RawAddress& bda);
171 extern bool btm_is_sco_active_by_bdaddr(const RawAddress& remote_bda);
172 
173 extern void btm_read_def_esco_mode(enh_esco_params_t* p_parms);
174 extern uint16_t btm_find_scb_by_handle(uint16_t handle);
175 extern void btm_sco_flush_sco_data(uint16_t sco_inx);
176 
177 /* Internal functions provided by btm_devctl.cc
178  *********************************************
179 */
180 extern void btm_dev_init(void);
181 extern void btm_read_local_name_timeout(void* data);
182 extern void btm_read_local_name_complete(uint8_t* p, uint16_t evt_len);
183 
184 extern void btm_ble_add_2_white_list_complete(uint8_t status);
185 extern void btm_ble_remove_from_white_list_complete(uint8_t* p,
186                                                     uint16_t evt_len);
187 extern void btm_ble_clear_white_list_complete(uint8_t* p, uint16_t evt_len);
188 extern void btm_ble_create_conn_cancel_complete(uint8_t* p);
189 extern bool btm_ble_addr_resolvable(const RawAddress& rpa,
190                                     tBTM_SEC_DEV_REC* p_dev_rec);
191 extern tBTM_STATUS btm_ble_read_resolving_list_entry(
192     tBTM_SEC_DEV_REC* p_dev_rec);
193 extern bool btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC* p_dev_rec);
194 extern void btm_ble_resolving_list_remove_dev(tBTM_SEC_DEV_REC* p_dev_rec);
195 
196 /* Vendor Specific Command complete evt handler */
197 extern void btm_vsc_complete(uint8_t* p, uint16_t cc_opcode, uint16_t evt_len,
198                              tBTM_VSC_CMPL_CB* p_vsc_cplt_cback);
199 extern void btm_inq_db_reset(void);
200 extern void btm_vendor_specific_evt(uint8_t* p, uint8_t evt_len);
201 extern void btm_delete_stored_link_key_complete(uint8_t* p);
202 extern void btm_report_device_status(tBTM_DEV_STATUS status);
203 
204 /* Internal functions provided by btm_dev.cc
205  *********************************************
206 */
207 extern bool btm_dev_support_switch(const RawAddress& bd_addr);
208 
209 extern tBTM_SEC_DEV_REC* btm_sec_allocate_dev_rec(void);
210 extern tBTM_SEC_DEV_REC* btm_sec_alloc_dev(const RawAddress& bd_addr);
211 extern void btm_sec_free_dev(tBTM_SEC_DEV_REC* p_dev_rec);
212 extern tBTM_SEC_DEV_REC* btm_find_dev(const RawAddress& bd_addr);
213 extern tBTM_SEC_DEV_REC* btm_find_or_alloc_dev(const RawAddress& bd_addr);
214 extern tBTM_SEC_DEV_REC* btm_find_dev_by_handle(uint16_t handle);
215 extern tBTM_BOND_TYPE btm_get_bond_type_dev(const RawAddress& bd_addr);
216 extern bool btm_set_bond_type_dev(const RawAddress& bd_addr,
217                                   tBTM_BOND_TYPE bond_type);
218 
219 /* Internal functions provided by btm_sec.cc
220  *********************************************
221 */
222 extern bool btm_dev_support_switch(const RawAddress& bd_addr);
223 extern tBTM_STATUS btm_sec_l2cap_access_req(const RawAddress& bd_addr,
224                                             uint16_t psm, uint16_t handle,
225                                             CONNECTION_TYPE conn_type,
226                                             tBTM_SEC_CALLBACK* p_callback,
227                                             void* p_ref_data);
228 extern tBTM_STATUS btm_sec_mx_access_request(const RawAddress& bd_addr,
229                                              uint16_t psm, bool is_originator,
230                                              uint32_t mx_proto_id,
231                                              uint32_t mx_chan_id,
232                                              tBTM_SEC_CALLBACK* p_callback,
233                                              void* p_ref_data);
234 extern void btm_sec_conn_req(const RawAddress& bda, uint8_t* dc);
235 extern void btm_create_conn_cancel_complete(uint8_t* p);
236 
237 extern void btm_read_inq_tx_power_timeout(void* data);
238 extern void btm_read_inq_tx_power_complete(uint8_t* p);
239 
240 extern void btm_sec_init(uint8_t sec_mode);
241 extern void btm_sec_dev_reset(void);
242 extern void btm_sec_abort_access_req(const RawAddress& bd_addr);
243 extern void btm_sec_auth_complete(uint16_t handle, uint8_t status);
244 extern void btm_sec_encrypt_change(uint16_t handle, uint8_t status,
245                                    uint8_t encr_enable);
246 extern void btm_sec_connected(const RawAddress& bda, uint16_t handle,
247                               uint8_t status, uint8_t enc_mode);
248 extern tBTM_STATUS btm_sec_disconnect(uint16_t handle, uint8_t reason);
249 extern void btm_sec_disconnected(uint16_t handle, uint8_t reason);
250 extern void btm_sec_rmt_name_request_complete(const RawAddress* bd_addr,
251                                               uint8_t* bd_name, uint8_t status);
252 extern void btm_sec_rmt_host_support_feat_evt(uint8_t* p);
253 extern void btm_io_capabilities_req(const RawAddress& p);
254 extern void btm_io_capabilities_rsp(uint8_t* p);
255 extern void btm_proc_sp_req_evt(tBTM_SP_EVT event, uint8_t* p);
256 extern void btm_keypress_notif_evt(uint8_t* p);
257 extern void btm_simple_pair_complete(uint8_t* p);
258 extern void btm_sec_link_key_notification(const RawAddress& p_bda,
259                                           uint8_t* p_link_key,
260                                           uint8_t key_type);
261 extern void btm_sec_link_key_request(const RawAddress& p_bda);
262 extern void btm_sec_pin_code_request(const RawAddress& p_bda);
263 extern void btm_sec_update_clock_offset(uint16_t handle, uint16_t clock_offset);
264 extern void btm_sec_dev_rec_cback_event(tBTM_SEC_DEV_REC* p_dev_rec,
265                                         uint8_t res, bool is_le_trasnport);
266 extern void btm_sec_set_peer_sec_caps(tACL_CONN* p_acl_cb,
267                                       tBTM_SEC_DEV_REC* p_dev_rec);
268 
269 extern void btm_sec_clear_ble_keys(tBTM_SEC_DEV_REC* p_dev_rec);
270 extern bool btm_sec_is_a_bonded_dev(const RawAddress& bda);
271 extern void btm_consolidate_dev(tBTM_SEC_DEV_REC* p_target_rec);
272 extern bool btm_sec_is_le_capable_dev(const RawAddress& bda);
273 extern bool btm_ble_init_pseudo_addr(tBTM_SEC_DEV_REC* p_dev_rec,
274                                      const RawAddress& new_pseudo_addr);
275 extern tBTM_SEC_SERV_REC* btm_sec_find_first_serv(CONNECTION_TYPE conn_type,
276                                                   uint16_t psm);
277 extern bool btm_ble_start_sec_check(const RawAddress& bd_addr, uint16_t psm,
278                                     bool is_originator,
279                                     tBTM_SEC_CALLBACK* p_callback,
280                                     void* p_ref_data);
281 
282 extern tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda);
283 
284 extern void btm_rem_oob_req(uint8_t* p);
285 extern void btm_read_local_oob_complete(uint8_t* p);
286 
287 extern void btm_acl_resubmit_page(void);
288 extern void btm_acl_reset_paging(void);
289 extern void btm_acl_paging(BT_HDR* p, const RawAddress& dest);
290 extern uint8_t btm_sec_clr_service_by_psm(uint16_t psm);
291 extern void btm_sec_clr_temp_auth_service(const RawAddress& bda);
292 extern tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec);
293 
294 #endif
295