Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c524cf9 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

LE COC: Let L2cap send connect rsp

No need to send connect rsp from client

Tag: #gd-refactor
Bug: 141555841
Test: cert/run --host
Change-Id: I2adf73b8086d297930d3e32cab98dd90bc2d9ff1
parent e5d867f1
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -617,9 +617,6 @@ static void gap_connect_ind(const RawAddress& bd_addr, uint16_t l2cap_cid,
  p_ccb->connection_id = l2cap_cid;

  if (p_ccb->transport == BT_TRANSPORT_LE) {
    L2CA_ConnectLECocRsp(bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_OK,
                         L2CAP_CONN_OK, &p_ccb->local_coc_cfg);

    /* get the remote coc configuration */
    L2CA_GetPeerLECocConfig(l2cap_cid, &p_ccb->peer_coc_cfg);
    p_ccb->rem_mtu_size = p_ccb->peer_coc_cfg.mtu;
+0 −15
Original line number Diff line number Diff line
@@ -439,21 +439,6 @@ extern uint16_t L2CA_ConnectLECocReq(uint16_t psm, const RawAddress& p_bd_addr,
                                     tL2CAP_LE_CFG_INFO* p_cfg,
                                     uint16_t sec_level);

/*******************************************************************************
 *
 * Function         L2CA_ConnectLECocRsp
 *
 * Description      Higher layers call this function to accept an incoming
 *                  L2CAP LE COC connection, for which they had gotten a connect
 *                  indication callback.
 *
 * Returns          true for success, false for failure
 *
 ******************************************************************************/
extern bool L2CA_ConnectLECocRsp(const RawAddress& p_bd_addr, uint8_t id,
                                 uint16_t lcid, uint16_t result,
                                 uint16_t status, tL2CAP_LE_CFG_INFO* p_cfg);

/*******************************************************************************
 *
 *  Function         L2CA_GetPeerLECocConfig
+0 −63
Original line number Diff line number Diff line
@@ -573,69 +573,6 @@ uint16_t L2CA_ConnectLECocReq(uint16_t psm, const RawAddress& p_bd_addr,
  return p_ccb->local_cid;
}

/*******************************************************************************
 *
 * Function         L2CA_ConnectLECocRsp
 *
 * Description      Higher layers call this function to accept an incoming
 *                  L2CAP COC connection, for which they had gotten an connect
 *                  indication callback.
 *
 * Returns          true for success, false for failure
 *
 ******************************************************************************/
bool L2CA_ConnectLECocRsp(const RawAddress& p_bd_addr, uint8_t id,
                          uint16_t lcid, uint16_t result, uint16_t status,
                          tL2CAP_LE_CFG_INFO* p_cfg) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    return bluetooth::shim::L2CA_ConnectLECocRsp(p_bd_addr, id, lcid, result,
                                                 status, p_cfg);
  }

  VLOG(1) << __func__ << " BDA: " << p_bd_addr
          << StringPrintf(" CID: 0x%04x Result: %d Status: %d", lcid, result,
                          status);

  /* First, find the link control block */
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(p_bd_addr, BT_TRANSPORT_LE);
  if (p_lcb == NULL) {
    /* No link. Get an LCB and start link establishment */
    L2CAP_TRACE_WARNING("%s no LCB", __func__);
    return false;
  }

  /* Now, find the channel control block */
  tL2C_CCB* p_ccb = l2cu_find_ccb_by_cid(p_lcb, lcid);
  if (p_ccb == NULL) {
    L2CAP_TRACE_WARNING("%s no CCB", __func__);
    return false;
  }

  /* The IDs must match */
  if (p_ccb->remote_id != id) {
    L2CAP_TRACE_WARNING("%s bad id. Expected: %d  Got: %d", __func__,
                        p_ccb->remote_id, id);
    return false;
  }

  if (p_cfg) {
    p_ccb->local_conn_cfg = *p_cfg;
    p_ccb->remote_credit_count = p_cfg->credits;
  }

  if (result == L2CAP_CONN_OK)
    l2c_csm_execute(p_ccb, L2CEVT_L2CA_CONNECT_RSP, NULL);
  else {
    tL2C_CONN_INFO conn_info;
    conn_info.bd_addr = p_bd_addr;
    conn_info.l2cap_result = result;
    conn_info.l2cap_status = status;
    l2c_csm_execute(p_ccb, L2CEVT_L2CA_CONNECT_RSP_NEG, &conn_info);
  }

  return true;
}

/*******************************************************************************
 *
 *  Function         L2CA_GetPeerLECocConfig
+3 −0
Original line number Diff line number Diff line
@@ -603,6 +603,9 @@ static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, uint16_t event,
        alarm_cancel(p_ccb->l2c_ccb_timer);
        p_ccb->chnl_state = CST_OPEN;
        l2c_csm_indicate_connection_open(p_ccb);
        p_ccb->local_conn_cfg = p_ccb->p_rcb->coc_cfg;
        p_ccb->remote_credit_count = p_ccb->p_rcb->coc_cfg.credits;
        l2c_csm_execute(p_ccb, L2CEVT_L2CA_CONNECT_RSP, NULL);
      } else {
        p_ccb->chnl_state = CST_CONFIG;
        alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,