Loading system/stack/btm/btm_sec.cc +10 −31 Original line number Diff line number Diff line Loading @@ -27,27 +27,22 @@ #include <frameworks/base/core/proto/android/bluetooth/enums.pb.h> #include <frameworks/base/core/proto/android/bluetooth/hci/enums.pb.h> #include <log/log.h> #include <stdarg.h> #include <stdio.h> #include <string.h> #include "common/metrics.h" #include "common/time_util.h" #include "device/include/controller.h" #include "l2c_api.h" #include "main/shim/btm_api.h" #include "main/shim/shim.h" #include "osi/include/log.h" #include "osi/include/osi.h" #include "stack/include/l2cap_security_interface.h" #include "bt_types.h" #include "bt_utils.h" #include "btif_storage.h" #include "btm_int.h" #include "btu.h" #include "hcimsgs.h" #include "l2c_int.h" #include "gatt_int.h" #define BTM_SEC_MAX_COLLISION_DELAY (5000) Loading Loading @@ -2281,16 +2276,12 @@ void btm_sec_conn_req(const RawAddress& bda, uint8_t* dc) { btm_cb.connecting_bda = bda; memcpy(btm_cb.connecting_dc, dc, DEV_CLASS_LEN); if (l2c_link_hci_conn_req(bda)) { if (!p_dev_rec) { /* accept the connection -> allocate a device record */ p_dev_rec = btm_sec_alloc_dev(bda); } if (p_dev_rec) { p_dev_rec->sm4 |= BTM_SM4_CONN_PEND; } } } /******************************************************************************* * Loading Loading @@ -2512,29 +2503,17 @@ void btm_sec_abort_access_req(const RawAddress& bd_addr) { * ******************************************************************************/ static tBTM_STATUS btm_sec_dd_create_conn(tBTM_SEC_DEV_REC* p_dev_rec) { tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR); if (p_lcb && (p_lcb->link_state == LST_CONNECTED || p_lcb->link_state == LST_CONNECTING)) { BTM_TRACE_WARNING("%s Connection already exists", __func__); tBTM_STATUS status = l2cu_ConnectAclForSecurity(p_dev_rec->bd_addr); if (status == BTM_CMD_STARTED) { btm_sec_change_pairing_state(BTM_PAIR_STATE_WAIT_PIN_REQ); return BTM_CMD_STARTED; } /* Make sure an L2cap link control block is available */ if (!p_lcb && (p_lcb = l2cu_allocate_lcb(p_dev_rec->bd_addr, true, BT_TRANSPORT_BR_EDR)) == NULL) { LOG(WARNING) << "Security Manager: failed allocate LCB " << p_dev_rec->bd_addr; return (BTM_NO_RESOURCES); } else if (status == BTM_NO_RESOURCES) { return BTM_NO_RESOURCES; } /* set up the control block to indicated dedicated bonding */ btm_cb.pairing_flags |= BTM_PAIR_FLAGS_DISC_WHEN_DONE; l2cu_create_conn_br_edr(p_lcb); btm_acl_update_busy_level(BTM_BLI_PAGE_EVT); VLOG(1) << "Security Manager: " << p_dev_rec->bd_addr; Loading system/stack/btu/btu_hcif.cc +1 −0 Original line number Diff line number Diff line Loading @@ -989,6 +989,7 @@ static void btu_hcif_connection_request_evt(uint8_t* p) { /* passing request to l2cap */ if (link_type == HCI_LINK_TYPE_ACL) { btm_sec_conn_req(bda, dc); l2c_link_hci_conn_req(bda); } else { btm_sco_conn_req(bda, dc, link_type); } Loading system/stack/include/l2cap_hci_link_interface.h +2 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ // This header contains functions for HCI-LinkManagement to invoke extern bool l2c_link_hci_conn_req(const RawAddress& bd_addr); extern void l2c_link_process_num_completed_pkts(uint8_t* p, uint8_t evt_len); extern bool l2c_link_hci_conn_comp(uint8_t status, uint16_t handle, Loading @@ -31,8 +33,6 @@ extern bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason); extern void l2c_link_role_changed(const RawAddress* bd_addr, uint8_t new_role, uint8_t hci_status); extern void l2c_pin_code_request(const RawAddress& bd_addr); extern void l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda, tBLE_ADDR_TYPE type, uint16_t conn_interval, uint16_t conn_latency, Loading system/stack/include/l2cap_security_interface.h 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #pragma once #include "bt_common.h" // This header contains functions for Security Module to invoke extern void l2cu_update_lcb_4_bonding(const RawAddress& p_bd_addr, bool is_bonding); extern bool l2cu_start_post_bond_timer(uint16_t handle); extern void l2c_pin_code_request(const RawAddress& bd_addr); extern void l2cu_resubmit_pending_sec_req(const RawAddress* p_bda); // Establish ACL link to remote device for Security Manager/Pairing. // Returns BTM_CMD_STARTED if already connecting, BTM_NO_RESOURCES if can't // allocate lcb, BTM_SUCCESS if initiated the connection tBTM_STATUS l2cu_ConnectAclForSecurity(const RawAddress& bd_addr); No newline at end of file system/stack/l2cap/l2c_int.h +1 −5 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include "l2cap_acl_interface.h" #include "l2cap_controller_interface.h" #include "l2cap_hci_link_interface.h" #include "l2cap_security_interface.h" #include "l2cdefs.h" #include "osi/include/alarm.h" #include "osi/include/fixed_queue.h" Loading Loading @@ -533,13 +534,10 @@ extern void l2c_process_held_packets(bool timed_out); extern tL2C_LCB* l2cu_allocate_lcb(const RawAddress& p_bd_addr, bool is_bonding, tBT_TRANSPORT transport); extern bool l2cu_start_post_bond_timer(uint16_t handle); extern void l2cu_release_lcb(tL2C_LCB* p_lcb); extern tL2C_LCB* l2cu_find_lcb_by_bd_addr(const RawAddress& p_bd_addr, tBT_TRANSPORT transport); extern tL2C_LCB* l2cu_find_lcb_by_handle(uint16_t handle); extern void l2cu_update_lcb_4_bonding(const RawAddress& p_bd_addr, bool is_bonding); extern uint8_t l2cu_get_conn_role(tL2C_LCB* p_this_lcb); extern bool l2cu_set_acl_priority(const RawAddress& bd_addr, uint8_t priority, Loading Loading @@ -634,13 +632,11 @@ extern bool l2cu_create_conn_le(tL2C_LCB* p_lcb, uint8_t initiating_phys); extern void l2cu_create_conn_after_switch(tL2C_LCB* p_lcb); extern BT_HDR* l2cu_get_next_buffer_to_send(tL2C_LCB* p_lcb, tL2C_TX_COMPLETE_CB_INFO* p_cbi); extern void l2cu_resubmit_pending_sec_req(const RawAddress* p_bda); extern void l2cu_adjust_out_mps(tL2C_CCB* p_ccb); /* Functions provided by l2c_link.cc *********************************** */ extern bool l2c_link_hci_conn_req(const RawAddress& bd_addr); extern void l2c_link_timeout(tL2C_LCB* p_lcb); extern void l2c_info_resp_timer_timeout(void* data); extern void l2c_link_check_send_pkts(tL2C_LCB* p_lcb, tL2C_CCB* p_ccb, Loading Loading
system/stack/btm/btm_sec.cc +10 −31 Original line number Diff line number Diff line Loading @@ -27,27 +27,22 @@ #include <frameworks/base/core/proto/android/bluetooth/enums.pb.h> #include <frameworks/base/core/proto/android/bluetooth/hci/enums.pb.h> #include <log/log.h> #include <stdarg.h> #include <stdio.h> #include <string.h> #include "common/metrics.h" #include "common/time_util.h" #include "device/include/controller.h" #include "l2c_api.h" #include "main/shim/btm_api.h" #include "main/shim/shim.h" #include "osi/include/log.h" #include "osi/include/osi.h" #include "stack/include/l2cap_security_interface.h" #include "bt_types.h" #include "bt_utils.h" #include "btif_storage.h" #include "btm_int.h" #include "btu.h" #include "hcimsgs.h" #include "l2c_int.h" #include "gatt_int.h" #define BTM_SEC_MAX_COLLISION_DELAY (5000) Loading Loading @@ -2281,16 +2276,12 @@ void btm_sec_conn_req(const RawAddress& bda, uint8_t* dc) { btm_cb.connecting_bda = bda; memcpy(btm_cb.connecting_dc, dc, DEV_CLASS_LEN); if (l2c_link_hci_conn_req(bda)) { if (!p_dev_rec) { /* accept the connection -> allocate a device record */ p_dev_rec = btm_sec_alloc_dev(bda); } if (p_dev_rec) { p_dev_rec->sm4 |= BTM_SM4_CONN_PEND; } } } /******************************************************************************* * Loading Loading @@ -2512,29 +2503,17 @@ void btm_sec_abort_access_req(const RawAddress& bd_addr) { * ******************************************************************************/ static tBTM_STATUS btm_sec_dd_create_conn(tBTM_SEC_DEV_REC* p_dev_rec) { tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR); if (p_lcb && (p_lcb->link_state == LST_CONNECTED || p_lcb->link_state == LST_CONNECTING)) { BTM_TRACE_WARNING("%s Connection already exists", __func__); tBTM_STATUS status = l2cu_ConnectAclForSecurity(p_dev_rec->bd_addr); if (status == BTM_CMD_STARTED) { btm_sec_change_pairing_state(BTM_PAIR_STATE_WAIT_PIN_REQ); return BTM_CMD_STARTED; } /* Make sure an L2cap link control block is available */ if (!p_lcb && (p_lcb = l2cu_allocate_lcb(p_dev_rec->bd_addr, true, BT_TRANSPORT_BR_EDR)) == NULL) { LOG(WARNING) << "Security Manager: failed allocate LCB " << p_dev_rec->bd_addr; return (BTM_NO_RESOURCES); } else if (status == BTM_NO_RESOURCES) { return BTM_NO_RESOURCES; } /* set up the control block to indicated dedicated bonding */ btm_cb.pairing_flags |= BTM_PAIR_FLAGS_DISC_WHEN_DONE; l2cu_create_conn_br_edr(p_lcb); btm_acl_update_busy_level(BTM_BLI_PAGE_EVT); VLOG(1) << "Security Manager: " << p_dev_rec->bd_addr; Loading
system/stack/btu/btu_hcif.cc +1 −0 Original line number Diff line number Diff line Loading @@ -989,6 +989,7 @@ static void btu_hcif_connection_request_evt(uint8_t* p) { /* passing request to l2cap */ if (link_type == HCI_LINK_TYPE_ACL) { btm_sec_conn_req(bda, dc); l2c_link_hci_conn_req(bda); } else { btm_sco_conn_req(bda, dc, link_type); } Loading
system/stack/include/l2cap_hci_link_interface.h +2 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ // This header contains functions for HCI-LinkManagement to invoke extern bool l2c_link_hci_conn_req(const RawAddress& bd_addr); extern void l2c_link_process_num_completed_pkts(uint8_t* p, uint8_t evt_len); extern bool l2c_link_hci_conn_comp(uint8_t status, uint16_t handle, Loading @@ -31,8 +33,6 @@ extern bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason); extern void l2c_link_role_changed(const RawAddress* bd_addr, uint8_t new_role, uint8_t hci_status); extern void l2c_pin_code_request(const RawAddress& bd_addr); extern void l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda, tBLE_ADDR_TYPE type, uint16_t conn_interval, uint16_t conn_latency, Loading
system/stack/include/l2cap_security_interface.h 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #pragma once #include "bt_common.h" // This header contains functions for Security Module to invoke extern void l2cu_update_lcb_4_bonding(const RawAddress& p_bd_addr, bool is_bonding); extern bool l2cu_start_post_bond_timer(uint16_t handle); extern void l2c_pin_code_request(const RawAddress& bd_addr); extern void l2cu_resubmit_pending_sec_req(const RawAddress* p_bda); // Establish ACL link to remote device for Security Manager/Pairing. // Returns BTM_CMD_STARTED if already connecting, BTM_NO_RESOURCES if can't // allocate lcb, BTM_SUCCESS if initiated the connection tBTM_STATUS l2cu_ConnectAclForSecurity(const RawAddress& bd_addr); No newline at end of file
system/stack/l2cap/l2c_int.h +1 −5 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include "l2cap_acl_interface.h" #include "l2cap_controller_interface.h" #include "l2cap_hci_link_interface.h" #include "l2cap_security_interface.h" #include "l2cdefs.h" #include "osi/include/alarm.h" #include "osi/include/fixed_queue.h" Loading Loading @@ -533,13 +534,10 @@ extern void l2c_process_held_packets(bool timed_out); extern tL2C_LCB* l2cu_allocate_lcb(const RawAddress& p_bd_addr, bool is_bonding, tBT_TRANSPORT transport); extern bool l2cu_start_post_bond_timer(uint16_t handle); extern void l2cu_release_lcb(tL2C_LCB* p_lcb); extern tL2C_LCB* l2cu_find_lcb_by_bd_addr(const RawAddress& p_bd_addr, tBT_TRANSPORT transport); extern tL2C_LCB* l2cu_find_lcb_by_handle(uint16_t handle); extern void l2cu_update_lcb_4_bonding(const RawAddress& p_bd_addr, bool is_bonding); extern uint8_t l2cu_get_conn_role(tL2C_LCB* p_this_lcb); extern bool l2cu_set_acl_priority(const RawAddress& bd_addr, uint8_t priority, Loading Loading @@ -634,13 +632,11 @@ extern bool l2cu_create_conn_le(tL2C_LCB* p_lcb, uint8_t initiating_phys); extern void l2cu_create_conn_after_switch(tL2C_LCB* p_lcb); extern BT_HDR* l2cu_get_next_buffer_to_send(tL2C_LCB* p_lcb, tL2C_TX_COMPLETE_CB_INFO* p_cbi); extern void l2cu_resubmit_pending_sec_req(const RawAddress* p_bda); extern void l2cu_adjust_out_mps(tL2C_CCB* p_ccb); /* Functions provided by l2c_link.cc *********************************** */ extern bool l2c_link_hci_conn_req(const RawAddress& bd_addr); extern void l2c_link_timeout(tL2C_LCB* p_lcb); extern void l2c_info_resp_timer_timeout(void* data); extern void l2c_link_check_send_pkts(tL2C_LCB* p_lcb, tL2C_CCB* p_ccb, Loading