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

Commit c9e768bc authored by Myles Watson's avatar Myles Watson Committed by Gerrit Code Review
Browse files

Merge "Remove l2c_link_hci_conn_req and dependencies"

parents a62dc3ac d97b780e
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -2732,11 +2732,6 @@ void btm_connection_request(const RawAddress& bda,
  btm_sec_conn_req(bda, dc);
}

void btm_acl_connection_request(const RawAddress& bda, uint8_t* dc) {
  btm_sec_conn_req(bda, dc);
  l2c_link_hci_conn_req(bda);
}

void acl_accept_connection_request(const RawAddress& bd_addr, uint8_t role) {
  btsnd_hcic_accept_conn(bd_addr, role);
}
+0 −1
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@
//
void btm_connection_request(const RawAddress& bda,
                            const bluetooth::types::ClassOfDevice& cod);
void btm_acl_connection_request(const RawAddress& bda, uint8_t* dc);
void btm_acl_connected(const RawAddress& bda, uint16_t handle,
                       tHCI_STATUS status, uint8_t enc_mode);
void on_acl_br_edr_connected(const RawAddress& bda, uint16_t handle,
+0 −2
Original line number Diff line number Diff line
@@ -45,8 +45,6 @@ void l2c_rcv_acl_data(BT_HDR* p_msg);
// Segments is sent to HCI-ACL
void l2c_link_segments_xmitted(BT_HDR* p_msg);

void l2c_link_hci_conn_req(const RawAddress& bd_addr);

void l2cu_resubmit_pending_sec_req(const RawAddress* p_bda);

void l2c_packets_completed(uint16_t handle, uint16_t num_sent);
+0 −79
Original line number Diff line number Diff line
@@ -58,85 +58,6 @@ void btm_sco_acl_removed(const RawAddress* bda);
static void l2c_link_send_to_lower(tL2C_LCB* p_lcb, BT_HDR* p_buf);
static BT_HDR* l2cu_get_next_buffer_to_send(tL2C_LCB* p_lcb);

/*******************************************************************************
 *
 * Function         l2c_link_hci_conn_req
 *
 * Description      This function is called when an HCI Connection Request
 *                  event is received.
 *
 ******************************************************************************/
void l2c_link_hci_conn_req(const RawAddress& bd_addr) {
  tL2C_LCB* p_lcb;
  tL2C_LCB* p_lcb_cur;
  int xx;
  bool no_links;

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

  /* If we don't have one, create one and accept the connection. */
  if (!p_lcb) {
    p_lcb = l2cu_allocate_lcb(bd_addr, false, BT_TRANSPORT_BR_EDR);
    if (!p_lcb) {
      btsnd_hcic_reject_conn(bd_addr, HCI_ERR_HOST_REJECT_RESOURCES);
      LOG_ERROR("L2CAP failed to allocate LCB");
      return;
    }

    no_links = true;

    /* If we already have connection, accept as a central */
    for (xx = 0, p_lcb_cur = &l2cb.lcb_pool[0]; xx < MAX_L2CAP_LINKS;
         xx++, p_lcb_cur++) {
      if (p_lcb_cur == p_lcb) continue;

      if (p_lcb_cur->in_use) {
        no_links = false;
        p_lcb->SetLinkRoleAsCentral();
        break;
      }
    }

    if (no_links) {
      if (!btm_dev_support_role_switch(bd_addr))
        p_lcb->SetLinkRoleAsPeripheral();
      else
        p_lcb->SetLinkRoleAsCentral();
    }

    /* Tell the other side we accept the connection */
    acl_accept_connection_request(bd_addr, p_lcb->LinkRole());

    p_lcb->link_state = LST_CONNECTING;

    /* Start a timer waiting for connect complete */
    alarm_set_on_mloop(p_lcb->l2c_lcb_timer, L2CAP_LINK_CONNECT_TIMEOUT_MS,
                       l2c_lcb_timer_timeout, p_lcb);
    return;
  }

  /* We already had a link control block. Check what state it is in
   */
  if ((p_lcb->link_state == LST_CONNECTING) ||
      (p_lcb->link_state == LST_CONNECT_HOLDING)) {
    if (!btm_dev_support_role_switch(bd_addr))
      p_lcb->SetLinkRoleAsPeripheral();
    else
      p_lcb->SetLinkRoleAsCentral();

    acl_accept_connection_request(bd_addr, p_lcb->LinkRole());

    p_lcb->link_state = LST_CONNECTING;
  } else if (p_lcb->link_state == LST_DISCONNECTING) {
    acl_reject_connection_request(bd_addr, HCI_ERR_HOST_REJECT_DEVICE);
  } else {
    LOG_ERROR("L2CAP got conn_req while connected (state:%d). Reject it",
              p_lcb->link_state);
    acl_reject_connection_request(bd_addr, HCI_ERR_CONNECTION_EXISTS);
  }
}

void l2c_link_hci_conn_comp(tHCI_STATUS status, uint16_t handle,
                            const RawAddress& p_bda) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
+0 −5
Original line number Diff line number Diff line
@@ -124,7 +124,6 @@ struct acl_send_data_packet_ble acl_send_data_packet_ble;
struct acl_set_disconnect_reason acl_set_disconnect_reason;
struct acl_write_automatic_flush_timeout acl_write_automatic_flush_timeout;
struct btm_acl_connected btm_acl_connected;
struct btm_acl_connection_request btm_acl_connection_request;
struct btm_acl_created btm_acl_created;
struct btm_acl_device_down btm_acl_device_down;
struct btm_acl_disconnected btm_acl_disconnected;
@@ -520,10 +519,6 @@ void btm_acl_connected(const RawAddress& bda, uint16_t handle,
  inc_func_call_count(__func__);
  test::mock::stack_acl::btm_acl_connected(bda, handle, status, enc_mode);
}
void btm_acl_connection_request(const RawAddress& bda, uint8_t* dc) {
  inc_func_call_count(__func__);
  test::mock::stack_acl::btm_acl_connection_request(bda, dc);
}
void btm_acl_created(const RawAddress& bda, uint16_t hci_handle,
                     tHCI_ROLE link_role, tBT_TRANSPORT transport) {
  inc_func_call_count(__func__);
Loading