From 40b23cc4ab05fd28c77b72f50a11cf99dda4d170 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Sun, 27 Sep 2020 15:53:12 -0700 Subject: [PATCH] We always send pL2CA_ConfigCfm_Cb with status OK Bug: 159815595 Tag: #refactor Test: compile & verify basic functions working Change-Id: I4865330b4c48fe507bd6df72a5e362a616744ef4 --- stack/avct/avct_l2c.cc | 15 +++------ stack/avct/avct_l2c_br.cc | 11 ++---- stack/avdt/avdt_l2c.cc | 9 +---- stack/bnep/bnep_main.cc | 19 ++++------- stack/gap/gap_conn.cc | 8 ++--- stack/gatt/gatt_main.cc | 6 ---- stack/hid/hidd_conn.cc | 7 +--- stack/hid/hidh_conn.cc | 9 +---- stack/l2cap/l2c_csm.cc | 84 ++++++++++++++++++++++------------------------ stack/rfcomm/rfc_mx_fsm.cc | 6 ---- stack/sdp/sdp_main.cc | 19 ++++------- 11 files changed, 67 insertions(+), 126 deletions(-) diff --git a/stack/avct/avct_l2c.cc b/stack/avct/avct_l2c.cc index cbdf406df..33b0028cf 100644 --- a/stack/avct/avct_l2c.cc +++ b/stack/avct/avct_l2c.cc @@ -222,19 +222,12 @@ void avct_l2c_config_cfm_cback(uint16_t lcid, uint16_t result) { /* look up lcb for this channel */ p_lcb = avct_lcb_by_lcid(lcid); if (p_lcb != NULL) { - AVCT_TRACE_DEBUG("avct_l2c_config_cfm_cback: 0x%x, ch_state: %d, res: %d", - lcid, p_lcb->ch_state, result); + AVCT_TRACE_DEBUG("avct_l2c_config_cfm_cback: 0x%x, ch_state: %d,", lcid, + p_lcb->ch_state); /* if in correct state */ if (p_lcb->ch_state == AVCT_CH_CFG) { - /* if result successful */ - if (result == L2CAP_CFG_OK) { - p_lcb->ch_state = AVCT_CH_OPEN; - avct_lcb_event(p_lcb, AVCT_LCB_LL_OPEN_EVT, NULL); - } - /* else failure */ - else { - LOG(ERROR) << __func__ << ": invoked with non OK status"; - } + p_lcb->ch_state = AVCT_CH_OPEN; + avct_lcb_event(p_lcb, AVCT_LCB_LL_OPEN_EVT, NULL); } AVCT_TRACE_DEBUG("ch_state cfc: %d ", p_lcb->ch_state); } diff --git a/stack/avct/avct_l2c_br.cc b/stack/avct/avct_l2c_br.cc index b3f14043c..1db9ec8b0 100644 --- a/stack/avct/avct_l2c_br.cc +++ b/stack/avct/avct_l2c_br.cc @@ -155,15 +155,8 @@ void avct_l2c_br_config_cfm_cback(uint16_t lcid, uint16_t result) { p_lcb = avct_bcb_by_lcid(lcid); if ((p_lcb == NULL) || (p_lcb->ch_state != AVCT_CH_CFG)) return; - /* if result successful */ - if (result == L2CAP_CFG_OK) { - p_lcb->ch_state = AVCT_CH_OPEN; - avct_bcb_event(p_lcb, AVCT_LCB_LL_OPEN_EVT, NULL); - } - /* else failure */ - else { - LOG(ERROR) << __func__ << ": invoked with non OK status"; - } + p_lcb->ch_state = AVCT_CH_OPEN; + avct_bcb_event(p_lcb, AVCT_LCB_LL_OPEN_EVT, NULL); } /******************************************************************************* diff --git a/stack/avdt/avdt_l2c.cc b/stack/avdt/avdt_l2c.cc index 3b86437f0..fa2dfb183 100644 --- a/stack/avdt/avdt_l2c.cc +++ b/stack/avdt/avdt_l2c.cc @@ -301,14 +301,7 @@ void avdt_l2c_config_cfm_cback(uint16_t lcid, uint16_t result) { /* if in correct state */ if (p_tbl->state == AVDT_AD_ST_CFG) { - /* if result successful */ - if (result == L2CAP_CONN_OK) { - avdt_ad_tc_open_ind(p_tbl); - } - /* else failure */ - else { - LOG(ERROR) << __func__ << ": invoked with non OK status"; - } + avdt_ad_tc_open_ind(p_tbl); } } } diff --git a/stack/bnep/bnep_main.cc b/stack/bnep/bnep_main.cc index f8e76f5a8..7469dba9e 100644 --- a/stack/bnep/bnep_main.cc +++ b/stack/bnep/bnep_main.cc @@ -214,8 +214,7 @@ static void bnep_config_ind(uint16_t l2cap_cid, tL2CAP_CFG_INFO* p_cfg) { static void bnep_config_cfm(uint16_t l2cap_cid, uint16_t result) { tBNEP_CONN* p_bcb; - BNEP_TRACE_EVENT("BNEP - Rcvd cfg cfm, CID: 0x%x Result: %d", l2cap_cid, - result); + BNEP_TRACE_EVENT("BNEP - Rcvd cfg cfm, CID: 0x%x", l2cap_cid); /* Find CCB based on CID */ p_bcb = bnepu_find_bcb_by_cid(l2cap_cid); @@ -226,18 +225,14 @@ static void bnep_config_cfm(uint16_t l2cap_cid, uint16_t result) { } /* For now, always accept configuration from the other side */ - if (result == L2CAP_CFG_OK) { - p_bcb->con_state = BNEP_STATE_SEC_CHECKING; + p_bcb->con_state = BNEP_STATE_SEC_CHECKING; - /* Start timer waiting for setup or response */ - alarm_set_on_mloop(p_bcb->conn_timer, BNEP_HOST_TIMEOUT_MS, - bnep_conn_timer_timeout, p_bcb); + /* Start timer waiting for setup or response */ + alarm_set_on_mloop(p_bcb->conn_timer, BNEP_HOST_TIMEOUT_MS, + 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); - } - } else { - LOG(ERROR) << __func__ << ": invoked with non OK status"; + if (p_bcb->con_flags & BNEP_FLAGS_IS_ORIG) { + bnep_sec_check_complete(&p_bcb->rem_bda, BT_TRANSPORT_BR_EDR, p_bcb); } } diff --git a/stack/gap/gap_conn.cc b/stack/gap/gap_conn.cc index 4ad4158ad..bfda3d0ba 100644 --- a/stack/gap/gap_conn.cc +++ b/stack/gap/gap_conn.cc @@ -790,11 +790,9 @@ static void gap_config_cfm(uint16_t l2cap_cid, uint16_t result) { p_ccb = gap_find_ccb_by_cid(l2cap_cid); if (p_ccb == NULL) return; - if (result == L2CAP_CFG_OK) { - p_ccb->con_flags |= GAP_CCB_FLAGS_MY_CFG_DONE; - p_ccb->con_flags |= GAP_CCB_FLAGS_HIS_CFG_DONE; - gap_checks_con_flags(p_ccb); - } + p_ccb->con_flags |= GAP_CCB_FLAGS_MY_CFG_DONE; + p_ccb->con_flags |= GAP_CCB_FLAGS_HIS_CFG_DONE; + gap_checks_con_flags(p_ccb); } /******************************************************************************* diff --git a/stack/gatt/gatt_main.cc b/stack/gatt/gatt_main.cc index 967dc31ed..5c0ad3bcb 100644 --- a/stack/gatt/gatt_main.cc +++ b/stack/gatt/gatt_main.cc @@ -622,12 +622,6 @@ void gatt_l2cif_config_cfm_cback(uint16_t lcid, uint16_t result) { /* if in incorrect state */ if (gatt_get_ch_state(p_tcb) != GATT_CH_CFG) return; - /* if result not successful */ - if (result != L2CAP_CFG_OK) { - LOG(ERROR) << __func__ << ": invoked with non OK status"; - return; - } - gatt_set_ch_state(p_tcb, GATT_CH_OPEN); tGATTS_SRV_CHG* p_srv_chg_clt = diff --git a/stack/hid/hidd_conn.cc b/stack/hid/hidd_conn.cc index dc84cd9e6..4518d3e88 100644 --- a/stack/hid/hidd_conn.cc +++ b/stack/hid/hidd_conn.cc @@ -270,7 +270,7 @@ static void hidd_l2cif_config_ind(uint16_t cid, tL2CAP_CFG_INFO* p_cfg) { static void hidd_l2cif_config_cfm(uint16_t cid, uint16_t result) { tHID_CONN* p_hcon; - HIDD_TRACE_EVENT("%s: cid=%04x pcfg->result=%d", __func__, cid, result); + HIDD_TRACE_EVENT("%s: cid=%04x", __func__, cid); p_hcon = &hd_cb.device.conn; @@ -279,11 +279,6 @@ static void hidd_l2cif_config_cfm(uint16_t cid, uint16_t result) { return; } - if (result != L2CAP_CFG_OK) { - LOG(ERROR) << __func__ << ": invoked with non OK status"; - return; - } - // update flags if (cid == p_hcon->ctrl_cid) { if (p_hcon->conn_flags & HID_CONN_FLAGS_IS_ORIG) { diff --git a/stack/hid/hidh_conn.cc b/stack/hid/hidh_conn.cc index 11f19e2f3..e7d90b0ab 100644 --- a/stack/hid/hidh_conn.cc +++ b/stack/hid/hidh_conn.cc @@ -381,8 +381,7 @@ static void hidh_l2cif_config_cfm(uint16_t l2cap_cid, uint16_t result) { tHID_CONN* p_hcon = NULL; uint32_t reason; - HIDH_TRACE_EVENT("HID-Host Rcvd cfg cfm, CID: 0x%x Result: %d", l2cap_cid, - result); + HIDH_TRACE_EVENT("HID-Host Rcvd cfg cfm, CID: 0x%x", l2cap_cid); /* Find CCB based on CID */ dhandle = find_conn_by_cid(l2cap_cid); @@ -394,12 +393,6 @@ static void hidh_l2cif_config_cfm(uint16_t l2cap_cid, uint16_t result) { return; } - /* If configuration failed, disconnect the channel(s) */ - if (result != L2CAP_CFG_OK) { - LOG(ERROR) << __func__ << ": invoked with non OK status"; - return; - } - if (l2cap_cid == p_hcon->ctrl_cid) { if (p_hcon->conn_flags & HID_CONN_FLAGS_IS_ORIG) { /* Connect interrupt channel */ diff --git a/stack/l2cap/l2c_csm.cc b/stack/l2cap/l2c_csm.cc index 39579da26..bb2e69eb4 100644 --- a/stack/l2cap/l2c_csm.cc +++ b/stack/l2cap/l2c_csm.cc @@ -778,52 +778,50 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data) { case L2CEVT_L2CAP_CONFIG_RSP: /* Peer config response */ l2cu_process_peer_cfg_rsp(p_ccb, p_cfg); - if (p_cfg->result != L2CAP_CFG_PENDING) { - /* TBD: When config options grow beyong minimum MTU (48 bytes) - * logic needs to be added to handle responses with - * continuation bit set in flags field. - * 1. Send additional config request out until C-bit is cleared in - * response - */ - p_ccb->config_done |= OB_CFG_DONE; - - if (p_ccb->config_done & IB_CFG_DONE) { - /* Verify two sides are in compatible modes before continuing */ - if (p_ccb->our_cfg.fcr.mode != p_ccb->peer_cfg.fcr.mode) { - l2cu_send_peer_disc_req(p_ccb); - L2CAP_TRACE_WARNING( - "L2CAP - Calling Disconnect_Ind_Cb(Incompatible CFG), CID: " - "0x%04x No Conf Needed", - p_ccb->local_cid); - l2cu_release_ccb(p_ccb); - (*disconnect_ind)(local_cid, false); - break; - } + /* TBD: When config options grow beyong minimum MTU (48 bytes) + * logic needs to be added to handle responses with + * continuation bit set in flags field. + * 1. Send additional config request out until C-bit is cleared in + * response + */ + p_ccb->config_done |= OB_CFG_DONE; - p_ccb->config_done |= RECONFIG_FLAG; - p_ccb->chnl_state = CST_OPEN; - l2c_link_adjust_chnl_allocation(); - alarm_cancel(p_ccb->l2c_ccb_timer); + if (p_ccb->config_done & IB_CFG_DONE) { + /* Verify two sides are in compatible modes before continuing */ + if (p_ccb->our_cfg.fcr.mode != p_ccb->peer_cfg.fcr.mode) { + l2cu_send_peer_disc_req(p_ccb); + L2CAP_TRACE_WARNING( + "L2CAP - Calling Disconnect_Ind_Cb(Incompatible CFG), CID: " + "0x%04x No Conf Needed", + p_ccb->local_cid); + l2cu_release_ccb(p_ccb); + (*disconnect_ind)(local_cid, false); + break; + } - /* If using eRTM and waiting for an ACK, restart the ACK timer */ - if (p_ccb->fcrb.wait_ack) l2c_fcr_start_timer(p_ccb); - - /* - ** check p_ccb->our_cfg.fcr.mon_tout and - *p_ccb->our_cfg.fcr.rtrans_tout - ** we may set them to zero when sending config request during - *renegotiation - */ - if ((p_ccb->our_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) && - ((p_ccb->our_cfg.fcr.mon_tout == 0) || - (p_ccb->our_cfg.fcr.rtrans_tout))) { - l2c_fcr_adj_monitor_retran_timeout(p_ccb); - } + p_ccb->config_done |= RECONFIG_FLAG; + p_ccb->chnl_state = CST_OPEN; + l2c_link_adjust_chnl_allocation(); + alarm_cancel(p_ccb->l2c_ccb_timer); - /* See if we can forward anything on the hold queue */ - if (!fixed_queue_is_empty(p_ccb->xmit_hold_q)) { - l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL); - } + /* If using eRTM and waiting for an ACK, restart the ACK timer */ + if (p_ccb->fcrb.wait_ack) l2c_fcr_start_timer(p_ccb); + + /* + ** check p_ccb->our_cfg.fcr.mon_tout and + *p_ccb->our_cfg.fcr.rtrans_tout + ** we may set them to zero when sending config request during + *renegotiation + */ + if ((p_ccb->our_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) && + ((p_ccb->our_cfg.fcr.mon_tout == 0) || + (p_ccb->our_cfg.fcr.rtrans_tout))) { + l2c_fcr_adj_monitor_retran_timeout(p_ccb); + } + + /* See if we can forward anything on the hold queue */ + if (!fixed_queue_is_empty(p_ccb->xmit_hold_q)) { + l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL); } } diff --git a/stack/rfcomm/rfc_mx_fsm.cc b/stack/rfcomm/rfc_mx_fsm.cc index d8977a5dc..05ac96074 100644 --- a/stack/rfcomm/rfc_mx_fsm.cc +++ b/stack/rfcomm/rfc_mx_fsm.cc @@ -611,12 +611,6 @@ void rfc_on_l2cap_error(uint16_t lcid, uint16_t result) { * ******************************************************************************/ static void rfc_mx_conf_cnf(tRFC_MCB* p_mcb, uint16_t result) { - RFCOMM_TRACE_EVENT("rfc_mx_conf_cnf result:%d ", result); - - if (result != L2CAP_CFG_OK) { - return; - } - if (p_mcb->state == RFC_MX_STATE_CONFIGURE) { if (p_mcb->is_initiator) { p_mcb->state = RFC_MX_STATE_SABME_WAIT_UA; diff --git a/stack/sdp/sdp_main.cc b/stack/sdp/sdp_main.cc index 14f8bc099..71e27571b 100644 --- a/stack/sdp/sdp_main.cc +++ b/stack/sdp/sdp_main.cc @@ -212,8 +212,7 @@ static void sdp_config_ind(uint16_t l2cap_cid, tL2CAP_CFG_INFO* p_cfg) { static void sdp_config_cfm(uint16_t l2cap_cid, uint16_t result) { tCONN_CB* p_ccb; - SDP_TRACE_EVENT("SDP - Rcvd cfg cfm, CID: 0x%x Result: %d", l2cap_cid, - result); + SDP_TRACE_EVENT("SDP - Rcvd cfg cfm, CID: 0x%x", l2cap_cid); /* Find CCB based on CID */ p_ccb = sdpu_find_ccb_by_cid(l2cap_cid); @@ -223,18 +222,14 @@ static void sdp_config_cfm(uint16_t l2cap_cid, uint16_t result) { } /* For now, always accept configuration from the other side */ - if (result == L2CAP_CFG_OK) { - p_ccb->con_state = SDP_STATE_CONNECTED; + p_ccb->con_state = SDP_STATE_CONNECTED; - if (p_ccb->con_flags & SDP_FLAGS_IS_ORIG) { - sdp_disc_connected(p_ccb); - } else { - /* Start inactivity timer */ - alarm_set_on_mloop(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS, - sdp_conn_timer_timeout, p_ccb); - } + if (p_ccb->con_flags & SDP_FLAGS_IS_ORIG) { + sdp_disc_connected(p_ccb); } else { - LOG(ERROR) << __func__ << ": invoked with non OK status"; + /* Start inactivity timer */ + alarm_set_on_mloop(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS, + sdp_conn_timer_timeout, p_ccb); } } -- 2.11.0