From: Hansong Zhang Date: Sun, 27 Sep 2020 00:42:02 +0000 (-0700) Subject: Simplify bnep_sec_check_complete X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=86fbde4a5e;p=android-x86%2Fsystem-bt.git Simplify bnep_sec_check_complete Bug: 159815595 Tag: #refactor Test: compile & verify basic functions working Change-Id: Ifc0edea758f4d1e0847f5b00fc49b51b4ad00344 --- diff --git a/stack/bnep/bnep_api.cc b/stack/bnep/bnep_api.cc index 5cb756ee3..455dc168d 100644 --- a/stack/bnep/bnep_api.cc +++ b/stack/bnep/bnep_api.cc @@ -162,8 +162,7 @@ tBNEP_RESULT BNEP_Connect(const RawAddress& p_rem_bda, const Uuid& src_uuid, BNEP_TRACE_API("BNEP initiating security procedures for src uuid %s", p_bcb->src_uuid.ToString().c_str()); - bnep_sec_check_complete(&p_bcb->rem_bda, BT_TRANSPORT_BR_EDR, p_bcb, - BTM_SUCCESS); + bnep_sec_check_complete(&p_bcb->rem_bda, BT_TRANSPORT_BR_EDR, p_bcb); } else { /* Transition to the next appropriate state, waiting for connection confirm. */ diff --git a/stack/bnep/bnep_int.h b/stack/bnep/bnep_int.h index bd18f8c39..1675e2fc9 100644 --- a/stack/bnep/bnep_int.h +++ b/stack/bnep/bnep_int.h @@ -204,8 +204,7 @@ extern void bnep_process_setup_conn_responce(tBNEP_CONN* p_bcb, extern uint8_t* bnep_process_control_packet(tBNEP_CONN* p_bcb, uint8_t* p, uint16_t* len, bool is_ext); extern void bnep_sec_check_complete(const RawAddress* bd_addr, - tBT_TRANSPORT trasnport, void* p_ref_data, - uint8_t result); + tBT_TRANSPORT trasnport, void* p_ref_data); extern tBNEP_RESULT bnep_is_packet_allowed(tBNEP_CONN* p_bcb, const RawAddress& p_dest_addr, uint16_t protocol, diff --git a/stack/bnep/bnep_main.cc b/stack/bnep/bnep_main.cc index 61cdd6d53..f8e76f5a8 100644 --- a/stack/bnep/bnep_main.cc +++ b/stack/bnep/bnep_main.cc @@ -234,8 +234,7 @@ static void bnep_config_cfm(uint16_t l2cap_cid, uint16_t result) { bnep_conn_timer_timeout, p_bcb); if (p_bcb->con_flags & BNEP_FLAGS_IS_ORIG) { - bnep_sec_check_complete(&p_bcb->rem_bda, BT_TRANSPORT_BR_EDR, p_bcb, - BTM_SUCCESS); + bnep_sec_check_complete(&p_bcb->rem_bda, BT_TRANSPORT_BR_EDR, p_bcb); } } else { LOG(ERROR) << __func__ << ": invoked with non OK status"; diff --git a/stack/bnep/bnep_utils.cc b/stack/bnep/bnep_utils.cc index 5481af1e2..4813ce389 100644 --- a/stack/bnep/bnep_utils.cc +++ b/stack/bnep/bnep_utils.cc @@ -607,8 +607,7 @@ void bnep_process_setup_conn_req(tBNEP_CONN* p_bcb, uint8_t* p_setup, BNEP_TRACE_EVENT( "BNEP initiating security check for incoming call for uuid %s", p_bcb->src_uuid.ToString().c_str()); - bnep_sec_check_complete(&p_bcb->rem_bda, BT_TRANSPORT_BR_EDR, p_bcb, - BTM_SUCCESS); + bnep_sec_check_complete(&p_bcb->rem_bda, BT_TRANSPORT_BR_EDR, p_bcb); } /******************************************************************************* @@ -1148,14 +1147,12 @@ void bnepu_send_peer_multicast_filter_rsp(tBNEP_CONN* p_bcb, * Returns void * ******************************************************************************/ -void bnep_sec_check_complete(UNUSED_ATTR const RawAddress* bd_addr, - UNUSED_ATTR tBT_TRANSPORT trasnport, - void* p_ref_data, uint8_t result) { +void bnep_sec_check_complete(const RawAddress* bd_addr, tBT_TRANSPORT trasnport, + void* p_ref_data) { tBNEP_CONN* p_bcb = (tBNEP_CONN*)p_ref_data; uint16_t resp_code = BNEP_SETUP_CONN_OK; bool is_role_change; - BNEP_TRACE_EVENT("BNEP security callback returned result %d", result); if (p_bcb->con_flags & BNEP_FLAGS_CONN_COMPLETED) is_role_change = true; else @@ -1171,30 +1168,6 @@ void bnep_sec_check_complete(UNUSED_ATTR const RawAddress* bd_addr, /* if it is outgoing call and result is FAILURE return security fail error */ if (!(p_bcb->con_flags & BNEP_FLAGS_SETUP_RCVD)) { - if (result != BTM_SUCCESS) { - if (p_bcb->con_flags & BNEP_FLAGS_CONN_COMPLETED) { - /* Tell the user that role change is failed because of security */ - if (bnep_cb.p_conn_state_cb) - (*bnep_cb.p_conn_state_cb)(p_bcb->handle, p_bcb->rem_bda, - BNEP_SECURITY_FAIL, is_role_change); - - p_bcb->con_state = BNEP_STATE_CONNECTED; - p_bcb->src_uuid = p_bcb->prv_src_uuid; - p_bcb->dst_uuid = p_bcb->prv_dst_uuid; - return; - } - - L2CA_DisconnectReq(p_bcb->l2cap_cid); - - /* Tell the user if there is a callback */ - if (bnep_cb.p_conn_state_cb) - (*bnep_cb.p_conn_state_cb)(p_bcb->handle, p_bcb->rem_bda, - BNEP_SECURITY_FAIL, is_role_change); - - bnepu_release_bcb(p_bcb); - return; - } - /* Transition to the next appropriate state, waiting for connection confirm. */ p_bcb->con_state = BNEP_STATE_CONN_SETUP; @@ -1205,25 +1178,6 @@ void bnep_sec_check_complete(UNUSED_ATTR const RawAddress* bd_addr, return; } - /* it is an incoming call respond appropriately */ - if (result != BTM_SUCCESS) { - bnep_send_conn_responce(p_bcb, BNEP_SETUP_CONN_NOT_ALLOWED); - if (p_bcb->con_flags & BNEP_FLAGS_CONN_COMPLETED) { - /* Role change is failed because of security. Revert back to connected - * state */ - p_bcb->con_state = BNEP_STATE_CONNECTED; - p_bcb->con_flags &= (~BNEP_FLAGS_SETUP_RCVD); - p_bcb->src_uuid = p_bcb->prv_src_uuid; - p_bcb->dst_uuid = p_bcb->prv_dst_uuid; - return; - } - - L2CA_DisconnectReq(p_bcb->l2cap_cid); - - bnepu_release_bcb(p_bcb); - return; - } - if (bnep_cb.p_conn_ind_cb) { p_bcb->con_state = BNEP_STATE_CONN_SETUP; (*bnep_cb.p_conn_ind_cb)(p_bcb->handle, p_bcb->rem_bda, p_bcb->dst_uuid, @@ -1233,8 +1187,6 @@ void bnep_sec_check_complete(UNUSED_ATTR const RawAddress* bd_addr, bnep_send_conn_responce(p_bcb, resp_code); bnep_connected(p_bcb); } - - return; } /*******************************************************************************