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

Commit e692e720 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "[24/25] stack::smp Use stack::l2cap::get_interface()" into main am: 62b5b95c

parents 3e68e7e0 62b5b95c
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -31,10 +31,10 @@

#include "l2c_api.h"
#include "l2cdefs.h"
#include "os/log.h"
#include "smp_int.h"
#include "stack/include/bt_octets.h"
#include "stack/include/btm_sec_api_types.h"
#include "stack/include/l2cap_interface.h"
#include "types/raw_address.h"

using namespace bluetooth;
@@ -100,7 +100,7 @@ tSMP_STATUS SMP_Pair(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type) {
            .type = addr_type,
            .bda = bd_addr,
    };
    if (!L2CA_ConnectFixedChnl(L2CAP_SMP_CID, bd_addr)) {
    if (!stack::l2cap::get_interface().L2CA_ConnectFixedChnl(L2CAP_SMP_CID, bd_addr)) {
      tSMP_INT_DATA smp_int_data;
      smp_int_data.status = SMP_PAIR_INTERNAL_ERR;
      p_cb->status = SMP_PAIR_INTERNAL_ERR;
@@ -145,7 +145,7 @@ tSMP_STATUS SMP_BR_PairWith(const RawAddress& bd_addr) {
  p_cb->smp_over_br = true;
  p_cb->pairing_bda = bd_addr;

  if (!L2CA_ConnectFixedChnl(L2CAP_SMP_BR_CID, bd_addr)) {
  if (!stack::l2cap::get_interface().L2CA_ConnectFixedChnl(L2CAP_SMP_BR_CID, bd_addr)) {
    log::error("L2C connect fixed channel failed.");
    tSMP_INT_DATA smp_int_data;
    smp_int_data.status = SMP_PAIR_INTERNAL_ERR;
+6 −6
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@
#include "stack/btm/btm_dev.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_types.h"
#include "stack/include/l2c_api.h"
#include "stack/include/l2cap_interface.h"
#include "stack/include/l2cdefs.h"
#include "types/raw_address.h"

@@ -68,14 +68,14 @@ void smp_l2cap_if_init(void) {
  fixed_reg.pL2CA_FixedCong_Cb = NULL; /* do not handle congestion on this channel */
  fixed_reg.default_idle_tout = 60;    /* set 60 seconds timeout, 0xffff default idle timeout */

  if (!L2CA_RegisterFixedChannel(L2CAP_SMP_CID, &fixed_reg)) {
  if (!stack::l2cap::get_interface().L2CA_RegisterFixedChannel(L2CAP_SMP_CID, &fixed_reg)) {
    log::error("Unable to register with L2CAP fixed channel profile SMP psm:{}", L2CAP_SMP_CID);
  }

  fixed_reg.pL2CA_FixedConn_Cb = smp_br_connect_callback;
  fixed_reg.pL2CA_FixedData_Cb = smp_br_data_received;

  if (!L2CA_RegisterFixedChannel(L2CAP_SMP_BR_CID, &fixed_reg)) {
  if (!stack::l2cap::get_interface().L2CA_RegisterFixedChannel(L2CAP_SMP_BR_CID, &fixed_reg)) {
    log::error("Unable to register with L2CAP fixed channel profile SMP_BR psm:{}",
               L2CAP_SMP_BR_CID);
  }
@@ -115,7 +115,7 @@ static void smp_connect_callback(uint16_t /* channel */, const RawAddress& bd_ad
      if (!p_cb->connect_initialized) {
        p_cb->connect_initialized = true;
        /* initiating connection established */
        p_cb->role = L2CA_GetBleConnRole(bd_addr);
        p_cb->role = stack::l2cap::get_interface().L2CA_GetBleConnRole(bd_addr);

        /* initialize local i/r key to be default keys */
        p_cb->local_r_key = p_cb->local_i_key = SMP_SEC_DEFAULT_KEY;
@@ -167,7 +167,7 @@ static void smp_data_received(uint16_t channel, const RawAddress& bd_addr, BT_HD
  if (SMP_OPCODE_PAIRING_REQ == cmd || SMP_OPCODE_SEC_REQ == cmd) {
    if ((p_cb->state == SMP_STATE_IDLE) && (p_cb->br_state == SMP_BR_STATE_IDLE) &&
        !(p_cb->flags & SMP_PAIR_FLAGS_WE_STARTED_DD)) {
      p_cb->role = L2CA_GetBleConnRole(bd_addr);
      p_cb->role = bluetooth::stack::l2cap::get_interface().L2CA_GetBleConnRole(bd_addr);
      p_cb->pairing_bda = bd_addr;
    } else if (bd_addr != p_cb->pairing_bda) {
      osi_free(p_buf);
@@ -199,7 +199,7 @@ static void smp_data_received(uint16_t channel, const RawAddress& bd_addr, BT_HD
    smp_int_data.p_data = p;
    smp_sm_event(p_cb, static_cast<tSMP_EVENT>(cmd), &smp_int_data);
  } else {
    if (!L2CA_RemoveFixedChnl(channel, bd_addr)) {
    if (!stack::l2cap::get_interface().L2CA_RemoveFixedChnl(channel, bd_addr)) {
      log::error("Unable to remove fixed channel peer:{} cid:{}", bd_addr, channel);
    }
  }
+7 −6
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@
#include "stack/include/btm_ble_api.h"
#include "stack/include/btm_ble_sec_api.h"
#include "stack/include/btm_log_history.h"
#include "stack/include/l2c_api.h"
#include "stack/include/l2cap_interface.h"
#include "stack/include/l2cdefs.h"
#include "stack/include/smp_status.h"
#include "stack/include/stack_metrics_logging.h"
@@ -354,7 +354,7 @@ bool smp_send_msg_to_L2CAP(const RawAddress& rem_bda, BT_HDR* p_toL2CAP) {
  if (com::android::bluetooth::flags::l2cap_tx_complete_cb_info()) {
    /* Unacked needs to be incremented before calling SendFixedChnlData */
    smp_cb.total_tx_unacked++;
    l2cap_ret = L2CA_SendFixedChnlData(fixed_cid, rem_bda, p_toL2CAP);
    l2cap_ret = stack::l2cap::get_interface().L2CA_SendFixedChnlData(fixed_cid, rem_bda, p_toL2CAP);
    if (l2cap_ret == tL2CAP_DW_RESULT::FAILED) {
      smp_cb.total_tx_unacked--;
      log::error("SMP failed to pass msg to L2CAP");
@@ -364,7 +364,7 @@ bool smp_send_msg_to_L2CAP(const RawAddress& rem_bda, BT_HDR* p_toL2CAP) {
    return true;
  }

  l2cap_ret = L2CA_SendFixedChnlData(fixed_cid, rem_bda, p_toL2CAP);
  l2cap_ret = stack::l2cap::get_interface().L2CA_SendFixedChnlData(fixed_cid, rem_bda, p_toL2CAP);
  if (l2cap_ret == tL2CAP_DW_RESULT::FAILED) {
    log::error("SMP failed to pass msg to L2CAP");
    return false;
@@ -915,12 +915,12 @@ void smp_remove_fixed_channel(tSMP_CB* p_cb) {
  log::verbose("addr:{}", p_cb->pairing_bda);

  if (p_cb->smp_over_br) {
    if (!L2CA_RemoveFixedChnl(L2CAP_SMP_BR_CID, p_cb->pairing_bda)) {
    if (!stack::l2cap::get_interface().L2CA_RemoveFixedChnl(L2CAP_SMP_BR_CID, p_cb->pairing_bda)) {
      log::error("Unable to remove L2CAP fixed channel peer:{} cid:{}", p_cb->pairing_bda,
                 L2CAP_SMP_BR_CID);
    }
  } else {
    if (!L2CA_RemoveFixedChnl(L2CAP_SMP_CID, p_cb->pairing_bda)) {
    if (!stack::l2cap::get_interface().L2CA_RemoveFixedChnl(L2CAP_SMP_CID, p_cb->pairing_bda)) {
      log::error("Unable to remove L2CAP fixed channel peer:{} cid:{}", p_cb->pairing_bda,
                 L2CAP_SMP_CID);
    }
@@ -947,7 +947,8 @@ void smp_reset_control_value(tSMP_CB* p_cb) {
     usually service discovery will follow authentication complete, to avoid
     racing condition for a link down/up, set link idle timer to be
     SMP_LINK_TOUT_MIN to guarantee SMP key exchange */
  if (!L2CA_SetIdleTimeoutByBdAddr(p_cb->pairing_bda, SMP_LINK_TOUT_MIN, BT_TRANSPORT_LE)) {
  if (!stack::l2cap::get_interface().L2CA_SetIdleTimeoutByBdAddr(
              p_cb->pairing_bda, SMP_LINK_TOUT_MIN, BT_TRANSPORT_LE)) {
    log::warn("Unable to set L2CAP idle timeout peer:{} transport:{} timeout:{}", p_cb->pairing_bda,
              BT_TRANSPORT_LE, SMP_LINK_TOUT_MIN);
  }