From 75d1c63ba5be0546180ddf0d6d8a57d47e293760 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Thu, 24 Sep 2020 20:05:07 -0700 Subject: [PATCH] Let L2CAP send ConfigRsp for you Bug: 159815595 Tag: #refactor Test: compile & verify basic functions working Change-Id: I4767af7032b9c22fc297cca0877a1bc7e8c8607b --- stack/avct/avct_l2c.cc | 5 ----- stack/avct/avct_l2c_br.cc | 20 ++------------------ stack/avdt/avdt_l2c.cc | 5 ----- stack/bnep/bnep_main.cc | 7 ------- stack/gap/gap_conn.cc | 8 -------- stack/gatt/gatt_main.cc | 5 ----- stack/hid/hidd_conn.cc | 12 ------------ stack/hid/hidh_conn.cc | 7 ------- stack/l2cap/l2c_csm.cc | 6 ++++++ stack/rfcomm/rfc_mx_fsm.cc | 8 -------- stack/sdp/sdp_main.cc | 7 ------- 11 files changed, 8 insertions(+), 82 deletions(-) diff --git a/stack/avct/avct_l2c.cc b/stack/avct/avct_l2c.cc index 1b1fc0d32..23e8659c8 100644 --- a/stack/avct/avct_l2c.cc +++ b/stack/avct/avct_l2c.cc @@ -285,11 +285,6 @@ void avct_l2c_config_ind_cback(uint16_t lcid, tL2CAP_CFG_INFO* p_cfg) { p_lcb->peer_mtu = L2CAP_DEFAULT_MTU; } - /* send L2CAP configure response */ - memset(p_cfg, 0, sizeof(tL2CAP_CFG_INFO)); - p_cfg->result = L2CAP_CFG_OK; - L2CA_ConfigRsp(lcid, p_cfg); - /* if first config ind */ if ((p_lcb->ch_flags & AVCT_L2C_CFG_IND_DONE) == 0) { /* update flags */ diff --git a/stack/avct/avct_l2c_br.cc b/stack/avct/avct_l2c_br.cc index 96fb81dab..56eec6daa 100644 --- a/stack/avct/avct_l2c_br.cc +++ b/stack/avct/avct_l2c_br.cc @@ -260,13 +260,6 @@ void avct_l2c_br_config_ind_cback(uint16_t lcid, tL2CAP_CFG_INFO* p_cfg) { tAVCT_BCB* p_lcb; uint16_t max_mtu = BT_DEFAULT_BUFFER_SIZE - L2CAP_MIN_OFFSET - BT_HDR_SIZE; - /* Don't include QoS nor flush timeout in the response since we - currently always accept these values. Note: fcr_present is left - untouched since l2cap negotiates this internally - */ - p_cfg->flush_to_present = false; - p_cfg->qos_present = false; - /* look up lcb for this channel */ p_lcb = avct_bcb_by_lcid(lcid); if (p_lcb == NULL) return; @@ -278,20 +271,11 @@ void avct_l2c_br_config_ind_cback(uint16_t lcid, tL2CAP_CFG_INFO* p_cfg) { } if (p_lcb->peer_mtu > max_mtu) { - p_lcb->peer_mtu = p_cfg->mtu = max_mtu; - - /* Must tell the peer what the adjusted value is */ - p_cfg->mtu_present = true; - } else /* Don't include in the response */ - p_cfg->mtu_present = false; + p_lcb->peer_mtu = max_mtu; + } AVCT_TRACE_DEBUG("%s peer_mtu:%d use:%d", __func__, p_lcb->peer_mtu, max_mtu); - p_cfg->result = L2CAP_CFG_OK; - - /* send L2CAP configure response */ - L2CA_ConfigRsp(lcid, p_cfg); - /* if first config ind */ if ((p_lcb->ch_flags & AVCT_L2C_CFG_IND_DONE) == 0) { /* update flags */ diff --git a/stack/avdt/avdt_l2c.cc b/stack/avdt/avdt_l2c.cc index 682aa70f0..ac042e1dd 100644 --- a/stack/avdt/avdt_l2c.cc +++ b/stack/avdt/avdt_l2c.cc @@ -383,11 +383,6 @@ void avdt_l2c_config_ind_cback(uint16_t lcid, tL2CAP_CFG_INFO* p_cfg) { AVDT_TRACE_DEBUG("%s: peer_mtu: %d, lcid: %d", __func__, p_tbl->peer_mtu, lcid); - /* send L2CAP configure response */ - memset(p_cfg, 0, sizeof(tL2CAP_CFG_INFO)); - p_cfg->result = L2CAP_CFG_OK; - L2CA_ConfigRsp(lcid, p_cfg); - /* if first config ind */ if ((p_tbl->cfg_flags & AVDT_L2C_CFG_IND_DONE) == 0) { /* update cfg_flags */ diff --git a/stack/bnep/bnep_main.cc b/stack/bnep/bnep_main.cc index 892fc888a..4712e6669 100644 --- a/stack/bnep/bnep_main.cc +++ b/stack/bnep/bnep_main.cc @@ -216,13 +216,6 @@ static void bnep_config_ind(uint16_t l2cap_cid, tL2CAP_CFG_INFO* p_cfg) { BNEP_TRACE_EVENT("BNEP - Rcvd cfg ind, CID: 0x%x", l2cap_cid); - /* For now, always accept configuration from the other side */ - p_cfg->flush_to_present = false; - p_cfg->mtu_present = false; - p_cfg->result = L2CAP_CFG_OK; - - L2CA_ConfigRsp(l2cap_cid, p_cfg); - p_bcb->con_flags |= BNEP_FLAGS_HIS_CFG_DONE; if (p_bcb->con_flags & BNEP_FLAGS_MY_CFG_DONE) { diff --git a/stack/gap/gap_conn.cc b/stack/gap/gap_conn.cc index 4d69f0800..e937f7d97 100644 --- a/stack/gap/gap_conn.cc +++ b/stack/gap/gap_conn.cc @@ -781,14 +781,6 @@ static void gap_config_ind(uint16_t l2cap_cid, tL2CAP_CFG_INFO* p_cfg) { } else p_ccb->rem_mtu_size = p_cfg->mtu; - /* For now, always accept configuration from the other side */ - p_cfg->flush_to_present = false; - p_cfg->mtu_present = false; - p_cfg->result = L2CAP_CFG_OK; - p_cfg->fcs_present = false; - - L2CA_ConfigRsp(l2cap_cid, p_cfg); - 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 2a0f75ef9..7e1e6d62b 100644 --- a/stack/gatt/gatt_main.cc +++ b/stack/gatt/gatt_main.cc @@ -690,11 +690,6 @@ void gatt_l2cif_config_ind_cback(uint16_t lcid, tL2CAP_CFG_INFO* p_cfg) { else p_tcb->payload_size = L2CAP_DEFAULT_MTU; - /* send L2CAP configure response */ - memset(p_cfg, 0, sizeof(tL2CAP_CFG_INFO)); - p_cfg->result = L2CAP_CFG_OK; - L2CA_ConfigRsp(lcid, p_cfg); - /* if not first config ind */ if ((p_tcb->ch_flags & GATT_L2C_CFG_IND_DONE)) return; diff --git a/stack/hid/hidd_conn.cc b/stack/hid/hidd_conn.cc index e1480f07e..a47db4a78 100644 --- a/stack/hid/hidd_conn.cc +++ b/stack/hid/hidd_conn.cc @@ -340,18 +340,6 @@ static void hidd_l2cif_config_ind(uint16_t cid, tL2CAP_CFG_INFO* p_cfg) { else p_hcon->rem_mtu_size = p_cfg->mtu; - // accept without changes - p_cfg->flush_to_present = FALSE; - p_cfg->mtu_present = FALSE; - p_cfg->result = L2CAP_CFG_OK; - - if (cid == p_hcon->intr_cid && hd_cb.use_in_qos && !p_cfg->qos_present) { - p_cfg->qos_present = TRUE; - memcpy(&p_cfg->qos, &hd_cb.in_qos, sizeof(FLOW_SPEC)); - } - - L2CA_ConfigRsp(cid, p_cfg); - // update flags if (cid == p_hcon->ctrl_cid) { p_hcon->conn_flags |= HID_CONN_FLAGS_HIS_CTRL_CFG_DONE; diff --git a/stack/hid/hidh_conn.cc b/stack/hid/hidh_conn.cc index a6d2c83c2..18c72c1d3 100644 --- a/stack/hid/hidh_conn.cc +++ b/stack/hid/hidh_conn.cc @@ -463,13 +463,6 @@ static void hidh_l2cif_config_ind(uint16_t l2cap_cid, tL2CAP_CFG_INFO* p_cfg) { else p_hcon->rem_mtu_size = p_cfg->mtu; - /* For now, always accept configuration from the other side */ - p_cfg->flush_to_present = false; - p_cfg->mtu_present = false; - p_cfg->result = L2CAP_CFG_OK; - - L2CA_ConfigRsp(l2cap_cid, p_cfg); - if (l2cap_cid == p_hcon->ctrl_cid) { p_hcon->conn_flags |= HID_CONN_FLAGS_HIS_CTRL_CFG_DONE; if ((p_hcon->conn_flags & HID_CONN_FLAGS_IS_ORIG) && diff --git a/stack/l2cap/l2c_csm.cc b/stack/l2cap/l2c_csm.cc index a21a04623..1be0fc9d7 100644 --- a/stack/l2cap/l2c_csm.cc +++ b/stack/l2cap/l2c_csm.cc @@ -742,6 +742,9 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data) { "L2CAP - Calling Config_Req_Cb(), CID: 0x%04x, C-bit %d", p_ccb->local_cid, (p_cfg->flags & L2CAP_CFG_FLAGS_MASK_CONT)); (*p_ccb->p_rcb->api.pL2CA_ConfigInd_Cb)(p_ccb->local_cid, p_cfg); + tL2CAP_CFG_INFO response = {}; + response.result = L2CAP_CFG_OK; + L2CA_ConfigRsp(p_ccb->local_cid, &response); } else if (cfg_result == L2CAP_PEER_CFG_DISCONNECT) { /* Disconnect if channels are incompatible */ L2CAP_TRACE_EVENT("L2CAP - incompatible configurations disconnect"); @@ -988,6 +991,9 @@ static void l2c_csm_open(tL2C_CCB* p_ccb, uint16_t event, void* p_data) { cfg_result = l2cu_process_peer_cfg_req(p_ccb, p_cfg); if (cfg_result == L2CAP_PEER_CFG_OK) { (*p_ccb->p_rcb->api.pL2CA_ConfigInd_Cb)(p_ccb->local_cid, p_cfg); + tL2CAP_CFG_INFO response = {}; + response.result = L2CAP_CFG_OK; + L2CA_ConfigRsp(p_ccb->local_cid, &response); } /* Error in config parameters: reset state and config flag */ diff --git a/stack/rfcomm/rfc_mx_fsm.cc b/stack/rfcomm/rfc_mx_fsm.cc index 93537b686..853ba0f34 100644 --- a/stack/rfcomm/rfc_mx_fsm.cc +++ b/stack/rfcomm/rfc_mx_fsm.cc @@ -629,14 +629,6 @@ static void rfc_mx_conf_ind(tRFC_MCB* p_mcb, tL2CAP_CFG_INFO* p_cfg) { p_mcb->peer_l2cap_mtu = L2CAP_DEFAULT_MTU - RFCOMM_MIN_OFFSET - 1; } - p_cfg->mtu_present = false; - p_cfg->flush_to_present = false; - p_cfg->qos_present = false; - - p_cfg->result = L2CAP_CFG_OK; - - L2CA_ConfigRsp(p_mcb->lcid, p_cfg); - p_mcb->peer_cfg_rcvd = true; if ((p_mcb->state == RFC_MX_STATE_CONFIGURE) && p_mcb->local_cfg_sent) { if (p_mcb->is_initiator) { diff --git a/stack/sdp/sdp_main.cc b/stack/sdp/sdp_main.cc index 3622a0869..9a6a3575f 100644 --- a/stack/sdp/sdp_main.cc +++ b/stack/sdp/sdp_main.cc @@ -224,13 +224,6 @@ static void sdp_config_ind(uint16_t l2cap_cid, tL2CAP_CFG_INFO* p_cfg) { p_ccb->rem_mtu_size = p_cfg->mtu; } - /* For now, always accept configuration from the other side */ - p_cfg->flush_to_present = false; - p_cfg->mtu_present = false; - p_cfg->result = L2CAP_CFG_OK; - - L2CA_ConfigRsp(l2cap_cid, p_cfg); - SDP_TRACE_EVENT("SDP - Rcvd cfg ind, sent cfg cfm, CID: 0x%x", l2cap_cid); p_ccb->con_flags |= SDP_FLAGS_HIS_CFG_DONE; -- 2.11.0