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

Commit ff70fd8c authored by Chris Manton's avatar Chris Manton Committed by Gerrit Code Review
Browse files

Merge "stack::l2cap Declare and assign tL2C_LCB::p_lcb" into main

parents 995ebbe7 829774ff
Loading
Loading
Loading
Loading
+7 −16
Original line number Diff line number Diff line
@@ -188,14 +188,13 @@ uint16_t L2CA_Register(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, bool ena
void L2CA_Deregister(uint16_t psm) {
  tL2C_RCB* p_rcb;
  tL2C_CCB* p_ccb;
  tL2C_LCB* p_lcb;
  int ii;

  log::verbose("L2CAP - L2CA_Deregister() called for PSM: 0x{:04x}", psm);

  p_rcb = l2cu_find_rcb_by_psm(psm);
  if (p_rcb != NULL) {
    p_lcb = &l2cb.lcb_pool[0];
    tL2C_LCB* p_lcb = &l2cb.lcb_pool[0];
    for (ii = 0; ii < MAX_L2CAP_LINKS; ii++, p_lcb++) {
      if (p_lcb->in_use) {
        p_ccb = p_lcb->ccb_queue.p_first_ccb;
@@ -971,10 +970,8 @@ bool L2CA_GetRemoteChannelId(uint16_t lcid, uint16_t* rcid) {
 ******************************************************************************/
bool L2CA_SetIdleTimeoutByBdAddr(const RawAddress& bd_addr, uint16_t timeout,
                                 tBT_TRANSPORT transport) {
  tL2C_LCB* p_lcb;

  if (RawAddress::kAny != bd_addr) {
    p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, transport);
    tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, transport);
    if ((p_lcb) && (p_lcb->in_use) && (p_lcb->link_state == LST_CONNECTED)) {
      p_lcb->idle_timeout = timeout;

@@ -1094,10 +1091,8 @@ bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority) {
 *
 ******************************************************************************/
bool L2CA_GetPeerFeatures(const RawAddress& bd_addr, uint32_t* p_ext_feat, uint8_t* p_chnl_mask) {
  tL2C_LCB* p_lcb;

  /* We must already have a link to the remote */
  p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_BR_EDR);
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_BR_EDR);
  if (p_lcb == NULL) {
    log::warn("No BDA: {}", bd_addr);
    return false;
@@ -1170,7 +1165,6 @@ bool L2CA_RegisterFixedChannel(uint16_t fixed_cid, tL2CAP_FIXED_CHNL_REG* p_freg
 *
 ******************************************************************************/
bool L2CA_ConnectFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {
  tL2C_LCB* p_lcb;
  tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;

  log::debug("fixed_cid:0x{:04x}", fixed_cid);
@@ -1195,7 +1189,7 @@ bool L2CA_ConnectFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {
  tL2C_BLE_FIXED_CHNLS_MASK peer_channel_mask;

  // If we already have a link to the remote, check if it supports that CID
  p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, transport);
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, transport);
  if (p_lcb != NULL) {
    // Fixed channels are mandatory on LE transports so ignore the received
    // channel mask and use the locally cached LE channel mask.
@@ -1274,7 +1268,6 @@ bool L2CA_ConnectFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {
 ******************************************************************************/
tL2CAP_DW_RESULT L2CA_SendFixedChnlData(uint16_t fixed_cid, const RawAddress& rem_bda,
                                        BT_HDR* p_buf) {
  tL2C_LCB* p_lcb;
  tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;

  if (fixed_cid >= L2CAP_ATT_CID && fixed_cid <= L2CAP_SMP_CID) {
@@ -1294,7 +1287,7 @@ tL2CAP_DW_RESULT L2CA_SendFixedChnlData(uint16_t fixed_cid, const RawAddress& re
    return tL2CAP_DW_RESULT::FAILED;
  }

  p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, transport);
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, transport);
  if (p_lcb == NULL || p_lcb->link_state == LST_DISCONNECTING) {
    /* if link is disconnecting, also report data sending failure */
    log::warn("Link is disconnecting or does not exist CID: 0x{:04x}", fixed_cid);
@@ -1373,7 +1366,6 @@ tL2CAP_DW_RESULT L2CA_SendFixedChnlData(uint16_t fixed_cid, const RawAddress& re
 *
 ******************************************************************************/
bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {
  tL2C_LCB* p_lcb;
  tL2C_CCB* p_ccb;
  tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;

@@ -1389,7 +1381,7 @@ bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {
  }

  /* Is a fixed channel connected to the remote BDA ?*/
  p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, transport);
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, transport);

  if (((p_lcb) == NULL) || (!p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL])) {
    log::warn("BDA: {} CID: 0x{:04x} not connected", rem_bda, fixed_cid);
@@ -1531,7 +1523,6 @@ bool L2CA_SetChnlFlushability(uint16_t cid, bool is_flushable) {
 ******************************************************************************/
uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush) {
  tL2C_CCB* p_ccb;
  tL2C_LCB* p_lcb;
  uint16_t num_left = 0, num_flushed1 = 0, num_flushed2 = 0;

  p_ccb = l2cu_find_ccb_by_cid(NULL, lcid);
@@ -1540,7 +1531,7 @@ uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush) {
    log::warn("L2CA_FlushChannel()  abnormally returning 0  CID: 0x{:04x}", lcid);
    return 0;
  }
  p_lcb = p_ccb->p_lcb;
  tL2C_LCB* p_lcb = p_ccb->p_lcb;

  if (num_to_flush != L2CAP_FLUSH_CHANS_GET) {
    log::verbose(
+2 −6
Original line number Diff line number Diff line
@@ -61,10 +61,8 @@ static void l2cble_start_subrate_change(tL2C_LCB* p_lcb);
bool L2CA_UpdateBleConnParams(const RawAddress& rem_bda, uint16_t min_int, uint16_t max_int,
                              uint16_t latency, uint16_t timeout, uint16_t min_ce_len,
                              uint16_t max_ce_len) {
  tL2C_LCB* p_lcb;

  /* See if we have a link control block for the remote device */
  p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, BT_TRANSPORT_LE);
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, BT_TRANSPORT_LE);

  /* If we do not have one, create one and accept the connection. */
  if (!p_lcb || !BTM_IsAclConnectionUp(rem_bda, BT_TRANSPORT_LE)) {
@@ -474,10 +472,8 @@ void L2CA_SetDefaultSubrate(uint16_t subrate_min, uint16_t subrate_max, uint16_t
 ******************************************************************************/
bool L2CA_SubrateRequest(const RawAddress& rem_bda, uint16_t subrate_min, uint16_t subrate_max,
                         uint16_t max_latency, uint16_t cont_num, uint16_t timeout) {
  tL2C_LCB* p_lcb;

  /* See if we have a link control block for the remote device */
  p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, BT_TRANSPORT_LE);
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, BT_TRANSPORT_LE);

  /* If we don't have one, create one and accept the connection. */
  if (!p_lcb || !BTM_IsAclConnectionUp(rem_bda, BT_TRANSPORT_LE)) {
+4 −8
Original line number Diff line number Diff line
@@ -61,7 +61,6 @@ static void l2c_link_send_to_lower(tL2C_LCB* p_lcb, BT_HDR* p_buf, tL2C_TX_COMPL
static BT_HDR* l2cu_get_next_buffer_to_send(tL2C_LCB* p_lcb, tL2C_TX_COMPLETE_CB_INFO* p_cbi);

void l2c_link_hci_conn_comp(tHCI_STATUS status, uint16_t handle, const RawAddress& p_bda) {
  tL2C_LCB* p_lcb;
  tL2C_CCB* p_ccb;

  /* Save the parameters */
@@ -77,10 +76,9 @@ void l2c_link_hci_conn_comp(tHCI_STATUS status, uint16_t handle, const RawAddres
  };

  /* See if we have a link control block for the remote device */
  p_lcb = l2cu_find_lcb_by_bd_addr(ci.bd_addr, BT_TRANSPORT_BR_EDR);

  /* If we don't have one, allocate one */
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(ci.bd_addr, BT_TRANSPORT_BR_EDR);
  if (p_lcb == nullptr) {
    /* If we don't have one, allocate one */
    p_lcb = l2cu_allocate_lcb(ci.bd_addr, false, BT_TRANSPORT_BR_EDR);
    if (p_lcb == nullptr) {
      log::warn("Failed to allocate an LCB");
@@ -187,7 +185,6 @@ void l2c_link_hci_conn_comp(tHCI_STATUS status, uint16_t handle, const RawAddres
 ******************************************************************************/
void l2c_link_sec_comp(RawAddress p_bda, tBT_TRANSPORT transport, void* p_ref_data,
                       tBTM_STATUS btm_status) {
  tL2C_LCB* p_lcb;
  tL2C_CCB* p_ccb;
  tL2C_CCB* p_next_ccb;

@@ -210,9 +207,8 @@ void l2c_link_sec_comp(RawAddress p_bda, tBT_TRANSPORT transport, void* p_ref_da
          .peer_mtu{},
  };

  p_lcb = l2cu_find_lcb_by_bd_addr(p_bda, transport);

  /* If we don't have one, this is an error */
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(p_bda, transport);
  if (!p_lcb) {
    log::warn("L2CAP got sec_comp for unknown BD_ADDR");
    return;
@@ -318,12 +314,12 @@ static void l2c_link_iot_store_disc_reason(RawAddress& bda, uint8_t reason) {
 *
 ******************************************************************************/
bool l2c_link_hci_disc_comp(uint16_t handle, tHCI_REASON reason) {
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_handle(handle);
  tL2C_CCB* p_ccb;
  bool status = true;
  bool lcb_is_free = true;

  /* If we don't have one, maybe an SCO link. Send to MM */
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_handle(handle);
  if (!p_lcb) {
    status = false;
  } else {
+4 −7
Original line number Diff line number Diff line
@@ -2204,12 +2204,11 @@ tL2C_LCB* l2cu_find_lcb_by_state(tL2C_LINK_STATE state) {
 *
 ******************************************************************************/
bool l2cu_lcb_disconnecting(void) {
  tL2C_LCB* p_lcb;
  tL2C_CCB* p_ccb;
  uint16_t i;
  bool status = false;

  p_lcb = &l2cb.lcb_pool[0];
  tL2C_LCB* p_lcb = &l2cb.lcb_pool[0];

  for (i = 0; i < MAX_L2CAP_LINKS; i++, p_lcb++) {
    if (p_lcb->in_use) {
@@ -2356,12 +2355,10 @@ static void l2cu_set_acl_priority_unisoc(tL2C_LCB* p_lcb, tL2CAP_PRIORITY priori

bool l2cu_set_acl_priority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority,
                           bool reset_after_rs) {
  tL2C_LCB* p_lcb;

  log::verbose("SET ACL PRIORITY {}", priority);

  /* Find the link control block for the acl channel */
  p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_BR_EDR);
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_BR_EDR);
  if (p_lcb == NULL) {
    log::warn("L2CAP - no LCB for L2CA_SetAclPriority");
    return false;
@@ -2550,7 +2547,6 @@ void l2cu_set_non_flushable_pbf(bool is_supported) {
 *
 ******************************************************************************/
void l2cu_resubmit_pending_sec_req(const RawAddress* p_bda) {
  tL2C_LCB* p_lcb;
  tL2C_CCB* p_ccb;
  tL2C_CCB* p_next_ccb;
  int xx;
@@ -2559,7 +2555,7 @@ void l2cu_resubmit_pending_sec_req(const RawAddress* p_bda) {

  /* If we are called with a BDA, only resubmit for that BDA */
  if (p_bda) {
    p_lcb = l2cu_find_lcb_by_bd_addr(*p_bda, BT_TRANSPORT_BR_EDR);
    tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(*p_bda, BT_TRANSPORT_BR_EDR);

    /* If we don't have one, this is an error */
    if (p_lcb) {
@@ -2573,6 +2569,7 @@ void l2cu_resubmit_pending_sec_req(const RawAddress* p_bda) {
    }
  } else {
    /* No BDA pasesed in, so check all links */
    tL2C_LCB* p_lcb{nullptr};
    for (xx = 0, p_lcb = &l2cb.lcb_pool[0]; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) {
      if (p_lcb->in_use) {
        /* For all channels, send the event through their FSMs */