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

Commit e61e10ff authored by Łukasz Rymanowski's avatar Łukasz Rymanowski Committed by Jakub Pawlowski
Browse files

stack/l2c: Add helper l2cu_reject_ble_coc_connection

New helper will take tL2C_CCB* as a parameter (when available).

This will be needed later on when this function will need more more knowledge.

Tag: #feature
Bug: 159786353
Test: compilation
Sponsor: jpawlowski@
Change-Id: I5b7c552c7c1421eaaead70d68ca017341b5363c7
parent 13c39b9b
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -587,7 +587,7 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) {
      if (p_ccb) {
        L2CAP_TRACE_WARNING("L2CAP - rcvd conn req for duplicated cid: 0x%04x",
                            rcid);
        l2cu_reject_ble_connection(
        l2cu_reject_ble_coc_connection(
            p_lcb, id, L2CAP_LE_RESULT_SOURCE_CID_ALREADY_ALLOCATED);
        break;
      }
@@ -596,14 +596,14 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) {
      if (p_rcb == NULL) {
        L2CAP_TRACE_WARNING("L2CAP - rcvd conn req for unknown PSM: 0x%04x",
                            con_info.psm);
        l2cu_reject_ble_connection(p_lcb, id, L2CAP_LE_RESULT_NO_PSM);
        l2cu_reject_ble_coc_connection(p_lcb, id, L2CAP_LE_RESULT_NO_PSM);
        break;
      } else {
        if (!p_rcb->api.pL2CA_ConnectInd_Cb) {
          L2CAP_TRACE_WARNING(
              "L2CAP - rcvd conn req for outgoing-only connection PSM: %d",
              con_info.psm);
          l2cu_reject_ble_connection(p_lcb, id, L2CAP_CONN_NO_PSM);
          l2cu_reject_ble_coc_connection(p_lcb, id, L2CAP_CONN_NO_PSM);
          break;
        }
      }
@@ -612,7 +612,7 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) {
      p_ccb = l2cu_allocate_ccb(p_lcb, 0);
      if (p_ccb == NULL) {
        L2CAP_TRACE_ERROR("L2CAP - unable to allocate CCB");
        l2cu_reject_ble_connection(p_lcb, id, L2CAP_CONN_NO_RESOURCES);
        l2cu_reject_ble_connection(p_ccb, id, L2CAP_CONN_NO_RESOURCES);
        break;
      }

@@ -620,7 +620,7 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) {
      if (mtu < L2CAP_LE_MIN_MTU || mps < L2CAP_LE_MIN_MPS ||
          mps > L2CAP_LE_MAX_MPS) {
        L2CAP_TRACE_ERROR("L2CAP don't like the params");
        l2cu_reject_ble_connection(p_lcb, id, L2CAP_CONN_NO_RESOURCES);
        l2cu_reject_ble_connection(p_ccb, id, L2CAP_CONN_NO_RESOURCES);
        break;
      }

+2 −2
Original line number Diff line number Diff line
@@ -244,7 +244,7 @@ static void l2c_csm_closed(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
          case L2CAP_LE_RESULT_INSUFFICIENT_AUTHENTICATION:
          case L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP_KEY_SIZE:
          case L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP:
            l2cu_reject_ble_connection(p_ccb->p_lcb, p_ccb->remote_id, result);
            l2cu_reject_ble_connection(p_ccb, p_ccb->remote_id, result);
            l2cu_release_ccb(p_ccb);
            break;
            // TODO: Handle the other return codes
@@ -452,7 +452,7 @@ static void l2c_csm_term_w4_sec_comp(tL2C_CCB* p_ccb, uint16_t event,
      } else {
        if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE)
          l2cu_reject_ble_connection(
              p_ccb->p_lcb, p_ccb->remote_id,
              p_ccb, p_ccb->remote_id,
              L2CAP_LE_RESULT_INSUFFICIENT_AUTHENTICATION);
        else
          l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_SECURITY_BLOCK, 0);
+3 −1
Original line number Diff line number Diff line
@@ -589,7 +589,9 @@ extern void l2cu_send_peer_ble_par_req(tL2C_LCB* p_lcb, uint16_t min_int,
                                       uint16_t timeout);
extern void l2cu_send_peer_ble_par_rsp(tL2C_LCB* p_lcb, uint16_t reason,
                                       uint8_t rem_id);
extern void l2cu_reject_ble_connection(tL2C_LCB* p_lcb, uint8_t rem_id,
extern void l2cu_reject_ble_connection(tL2C_CCB* p_ccb, uint8_t rem_id,
                                       uint16_t result);
extern void l2cu_reject_ble_coc_connection(tL2C_LCB* p_lcb, uint8_t rem_id,
                                           uint16_t result);
extern void l2cu_send_peer_ble_credit_based_conn_res(tL2C_CCB* p_ccb,
                                                     uint16_t result);
+20 −4
Original line number Diff line number Diff line
@@ -2705,7 +2705,7 @@ void l2cu_send_peer_ble_credit_based_conn_req(tL2C_CCB* p_ccb) {

/*******************************************************************************
 *
 * Function         l2cu_reject_ble_connection
 * Function         l2cu_reject_ble_coc_connection
 *
 * Description      Build and send an L2CAP "Credit based connection res"
 *                  message to the peer. This function is called for non-success
@@ -2714,7 +2714,7 @@ void l2cu_send_peer_ble_credit_based_conn_req(tL2C_CCB* p_ccb) {
 * Returns          void
 *
 ******************************************************************************/
void l2cu_reject_ble_connection(tL2C_LCB* p_lcb, uint8_t rem_id,
void l2cu_reject_ble_coc_connection(tL2C_LCB* p_lcb, uint8_t rem_id,
                                    uint16_t result) {
  BT_HDR* p_buf;
  uint8_t* p;
@@ -2722,7 +2722,7 @@ void l2cu_reject_ble_connection(tL2C_LCB* p_lcb, uint8_t rem_id,
  p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES_LEN,
                            L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES, rem_id);
  if (p_buf == NULL) {
    L2CAP_TRACE_WARNING("l2cu_reject_ble_connection - no buffer");
    L2CAP_TRACE_WARNING("l2cu_reject_ble_coc_connection - no buffer");
    return;
  }

@@ -2738,6 +2738,22 @@ void l2cu_reject_ble_connection(tL2C_LCB* p_lcb, uint8_t rem_id,
  l2c_link_check_send_pkts(p_lcb, 0, p_buf);
}

/*******************************************************************************
 *
 * Function         l2cu_reject_ble_connection
 *
 * Description      Build and send an L2CAP "Credit based connection res"
 *                  message to the peer. This function is called for non-success
 *                  cases.
 *
 * Returns          void
 *
 ******************************************************************************/
void l2cu_reject_ble_connection(tL2C_CCB* p_ccb, uint8_t rem_id,
                                uint16_t result) {
  l2cu_reject_ble_coc_connection(p_ccb->p_lcb, rem_id, result);
}

/*******************************************************************************
 *
 * Function         l2cu_send_peer_ble_credit_based_conn_res