OSDN Git Service

Let L2CAP send ConfigRsp for you
authorHansong Zhang <hsz@google.com>
Fri, 25 Sep 2020 03:05:07 +0000 (20:05 -0700)
committerHansong Zhang <hsz@google.com>
Fri, 25 Sep 2020 22:36:24 +0000 (15:36 -0700)
Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I4767af7032b9c22fc297cca0877a1bc7e8c8607b

stack/avct/avct_l2c.cc
stack/avct/avct_l2c_br.cc
stack/avdt/avdt_l2c.cc
stack/bnep/bnep_main.cc
stack/gap/gap_conn.cc
stack/gatt/gatt_main.cc
stack/hid/hidd_conn.cc
stack/hid/hidh_conn.cc
stack/l2cap/l2c_csm.cc
stack/rfcomm/rfc_mx_fsm.cc
stack/sdp/sdp_main.cc

index 1b1fc0d..23e8659 100644 (file)
@@ -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 */
index 96fb81d..56eec6d 100644 (file)
@@ -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 */
index 682aa70..ac042e1 100644 (file)
@@ -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 */
index 892fc88..4712e66 100644 (file)
@@ -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) {
index 4d69f08..e937f7d 100644 (file)
@@ -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);
index 2a0f75e..7e1e6d6 100644 (file)
@@ -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;
 
index e1480f0..a47db4a 100644 (file)
@@ -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;
index a6d2c83..18c72c1 100644 (file)
@@ -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) &&
index a21a046..1be0fc9 100644 (file)
@@ -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 */
index 93537b6..853ba0f 100644 (file)
@@ -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) {
index 3622a08..9a6a357 100644 (file)
@@ -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;