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

Commit 1730619a authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

l2cap: Improve ECOC creation handling

With this patch we make sure that L2CA_ConnectCreditBasedReq will fail
if there is ongoing connection request.
Also, handling of the peer ConnectCreditBasedResponse is improved in the
way, that user can call connect already in the
pL2CA_CreditBasedConnectCfm_Cb or pL2CA_Error_Cb

Found during PTS testing

Bug: 242032465
Test: PTS Testing
Test: atest BluetoothInstrumentationTests
Tag: #feature
Change-Id: I80347b1281947a4830020fe9a1f70f21a57400fc
parent 2633d351
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -780,6 +780,12 @@ std::vector<uint16_t> L2CA_ConnectCreditBasedReq(uint16_t psm,

  L2CAP_TRACE_DEBUG("%s LE Link is up", __func__);

  /* Check if there is no ongoing connection request */
  if (p_lcb->pending_ecoc_conn_cnt > 0) {
    LOG_WARN("There is ongoing connection request, PSM: 0x%04x", psm);
    return allocated_cids;
  }

  tL2C_CCB* p_ccb_primary;

  /* Make sure user set proper value for number of cids */
+11 −6
Original line number Diff line number Diff line
@@ -743,8 +743,17 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) {

      con_info.peer_mtu = mtu;

      for (int i = 0; i < p_lcb->pending_ecoc_conn_cnt; i++) {
        uint16_t cid = p_lcb->pending_ecoc_connection_cids[i];
      /* Copy request data and clear it so user can perform another connect if
       * needed in the callback. */
      p_lcb->pending_ecoc_conn_cnt = 0;
      uint16_t cids[L2CAP_CREDIT_BASED_MAX_CIDS];
      std::copy_n(p_lcb->pending_ecoc_connection_cids,
                  L2CAP_CREDIT_BASED_MAX_CIDS, cids);
      std::fill_n(p_lcb->pending_ecoc_connection_cids,
                  L2CAP_CREDIT_BASED_MAX_CIDS, 0);

      for (int i = 0; i < num_of_channels; i++) {
        uint16_t cid = cids[i];
        STREAM_TO_UINT16(rcid, p);

        if (rcid != 0) {
@@ -799,10 +808,6 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) {
        }
      }

      p_lcb->pending_ecoc_conn_cnt = 0;
      memset(p_lcb->pending_ecoc_connection_cids, 0,
             L2CAP_CREDIT_BASED_MAX_CIDS);

      break;
    case L2CAP_CMD_CREDIT_BASED_RECONFIG_REQ: {
      if (p + 6 > p_pkt_end) {