summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Manton <cmanton@google.com> 2024-06-20 17:11:19 -0700
committer Chris Manton <cmanton@google.com> 2024-09-10 08:41:00 -0700
commitc8ea9b7a1da5af677c7bf11df42a10fbf8c141c4 (patch)
treede5610b6981999aac8a4d31926b0b916193ae21f
parent3525c228c2ebd7725afa0f8bb5bf495324cac96b (diff)
[21/25] stack::rfcomm Use stack::l2cap::get_interface()
Bug: 343808590 Test: m . Flag: EXEMPT, Mechanical Refactor Change-Id: I1abfc4ef9ac0ecce1a70e1101eda4d29862ace11
-rw-r--r--system/stack/rfcomm/port_int.h2
-rw-r--r--system/stack/rfcomm/rfc_int.h4
-rw-r--r--system/stack/rfcomm/rfc_l2cap_if.cc11
-rw-r--r--system/stack/rfcomm/rfc_mx_fsm.cc33
-rw-r--r--system/stack/rfcomm/rfc_ts_frames.cc3
-rw-r--r--system/stack/rfcomm/rfc_utils.cc2
6 files changed, 29 insertions, 26 deletions
diff --git a/system/stack/rfcomm/port_int.h b/system/stack/rfcomm/port_int.h
index a074696956..3505763b56 100644
--- a/system/stack/rfcomm/port_int.h
+++ b/system/stack/rfcomm/port_int.h
@@ -31,7 +31,7 @@
#include "internal_include/bt_target.h"
#include "osi/include/alarm.h"
#include "osi/include/fixed_queue.h"
-#include "stack/include/l2c_api.h"
+#include "stack/include/l2cap_types.h"
#include "stack/include/port_api.h"
#include "stack/include/rfcdefs.h"
#include "stack/rfcomm/rfc_state.h"
diff --git a/system/stack/rfcomm/rfc_int.h b/system/stack/rfcomm/rfc_int.h
index 5be534ab45..ddd38d5b4e 100644
--- a/system/stack/rfcomm/rfc_int.h
+++ b/system/stack/rfcomm/rfc_int.h
@@ -31,10 +31,10 @@
#include "stack/include/bt_hdr.h"
#include "stack/include/btm_status.h"
-#include "stack/include/l2c_api.h"
+#include "stack/include/l2cap_interface.h"
#include "stack/rfcomm/port_int.h"
#include "stack/rfcomm/rfc_event.h"
-#include "stack/rfcomm/rfc_state.h"
+#include "types/bt_transport.h"
#include "types/raw_address.h"
/*
diff --git a/system/stack/rfcomm/rfc_l2cap_if.cc b/system/stack/rfcomm/rfc_l2cap_if.cc
index fd39f0b4a3..8b96d26301 100644
--- a/system/stack/rfcomm/rfc_l2cap_if.cc
+++ b/system/stack/rfcomm/rfc_l2cap_if.cc
@@ -32,7 +32,7 @@
#include "osi/include/allocator.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_psm_types.h"
-#include "stack/include/l2c_api.h"
+#include "stack/include/l2cap_interface.h"
#include "stack/include/l2cdefs.h"
#include "stack/rfcomm/port_int.h"
#include "stack/rfcomm/rfc_int.h"
@@ -72,8 +72,9 @@ void rfcomm_l2cap_if_init(void) {
p_l2c->pL2CA_TxComplete_Cb = NULL;
p_l2c->pL2CA_Error_Cb = rfc_on_l2cap_error;
- if (!L2CA_Register(BT_PSM_RFCOMM, rfc_cb.rfc.reg_info, true /* enable_snoop */, nullptr,
- L2CAP_MTU_SIZE, 0, 0)) {
+ if (!stack::l2cap::get_interface().L2CA_Register(BT_PSM_RFCOMM, rfc_cb.rfc.reg_info,
+ true /* enable_snoop */, nullptr, L2CAP_MTU_SIZE,
+ 0, 0)) {
log::error("Unable to register with L2CAP profile RFCOMM psm:{}", BT_PSM_RFCOMM);
}
}
@@ -118,7 +119,7 @@ void RFCOMM_ConnectInd(const RawAddress& bd_addr, uint16_t lcid, uint16_t /* psm
}
if (p_mcb == nullptr) {
- if (!L2CA_DisconnectReq(lcid)) {
+ if (!stack::l2cap::get_interface().L2CA_DisconnectReq(lcid)) {
log::warn("Unable to disconnect L2CAP cid:{}", lcid);
}
return;
@@ -155,7 +156,7 @@ void RFCOMM_ConnectCnf(uint16_t lcid, tL2CAP_CONN result) {
/* Peer gave up its connection request, make sure cleaning up L2CAP
* channel */
- if (!L2CA_DisconnectReq(p_mcb->pending_lcid)) {
+ if (!stack::l2cap::get_interface().L2CA_DisconnectReq(p_mcb->pending_lcid)) {
log::warn("Unable to send L2CAP disconnect request peer:{} cid:{}", p_mcb->bd_addr,
p_mcb->lcid);
}
diff --git a/system/stack/rfcomm/rfc_mx_fsm.cc b/system/stack/rfcomm/rfc_mx_fsm.cc
index 87ad3bf1f6..c9890023d5 100644
--- a/system/stack/rfcomm/rfc_mx_fsm.cc
+++ b/system/stack/rfcomm/rfc_mx_fsm.cc
@@ -30,7 +30,7 @@
#include "osi/include/allocator.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_psm_types.h"
-#include "stack/include/l2c_api.h"
+#include "stack/include/l2cap_interface.h"
#include "stack/include/l2cdefs.h"
#include "stack/rfcomm/port_int.h"
#include "stack/rfcomm/rfc_int.h"
@@ -122,7 +122,7 @@ void rfc_mx_sm_state_idle(tRFC_MCB* p_mcb, tRFC_MX_EVENT event, void* /* p_data
/* Initialize L2CAP MTU */
p_mcb->peer_l2cap_mtu = L2CAP_DEFAULT_MTU - RFCOMM_MIN_OFFSET - 1;
- uint16_t lcid = L2CA_ConnectReq(BT_PSM_RFCOMM, p_mcb->bd_addr);
+ uint16_t lcid = stack::l2cap::get_interface().L2CA_ConnectReq(BT_PSM_RFCOMM, p_mcb->bd_addr);
if (lcid == 0) {
log::error("failed to open L2CAP channel for {}", p_mcb->bd_addr);
rfc_save_lcid_mcb(nullptr, p_mcb->lcid);
@@ -210,8 +210,8 @@ void rfc_mx_sm_state_wait_conn_cnf(tRFC_MCB* p_mcb, tRFC_MX_EVENT event, void* p
case RFC_MX_EVENT_TIMEOUT:
p_mcb->state = RFC_MX_STATE_IDLE;
- if (!L2CA_DisconnectReq(p_mcb->lcid)) {
- log::warn("Unable to send L2CAP disconnect request peer:{} cid:{}", p_mcb->bd_addr,
+ if (!stack::l2cap::get_interface().L2CA_DisconnectReq(p_mcb->lcid)) {
+ log::warn("Unable to send L2CAP disonnect request peer:{} cid:{}", p_mcb->bd_addr,
p_mcb->lcid);
}
@@ -287,8 +287,8 @@ void rfc_mx_sm_state_configure(tRFC_MCB* p_mcb, tRFC_MX_EVENT event, void* p_dat
case RFC_MX_EVENT_TIMEOUT:
log::error("L2CAP configuration timeout for {}", p_mcb->bd_addr);
p_mcb->state = RFC_MX_STATE_IDLE;
- if (!L2CA_DisconnectReq(p_mcb->lcid)) {
- log::warn("Unable to send L2CAP disconnect request peer:{} cid:{}", p_mcb->bd_addr,
+ if (!stack::l2cap::get_interface().L2CA_DisconnectReq(p_mcb->lcid)) {
+ log::warn("Unable to send L2CAP disonnect request peer:{} cid:{}", p_mcb->bd_addr,
p_mcb->lcid);
}
@@ -352,8 +352,8 @@ void rfc_mx_sm_sabme_wait_ua(tRFC_MCB* p_mcb, tRFC_MX_EVENT event, void* /* p_da
case RFC_MX_EVENT_CONF_CNF: /* workaround: we don't support reconfig */
case RFC_MX_EVENT_TIMEOUT:
p_mcb->state = RFC_MX_STATE_IDLE;
- if (!L2CA_DisconnectReq(p_mcb->lcid)) {
- log::warn("Unable to send L2CAP disconnect request peer:{} cid:{}", p_mcb->bd_addr,
+ if (!stack::l2cap::get_interface().L2CA_DisconnectReq(p_mcb->lcid)) {
+ log::warn("Unable to send L2CAP disonnect request peer:{} cid:{}", p_mcb->bd_addr,
p_mcb->lcid);
}
@@ -420,8 +420,8 @@ void rfc_mx_sm_state_wait_sabme(tRFC_MCB* p_mcb, tRFC_MX_EVENT event, void* p_da
case RFC_MX_EVENT_CONF_CNF: /* workaround: we don't support reconfig */
case RFC_MX_EVENT_TIMEOUT:
p_mcb->state = RFC_MX_STATE_IDLE;
- if (!L2CA_DisconnectReq(p_mcb->lcid)) {
- log::warn("Unable to send L2CAP disconnect request peer:{} cid:{}", p_mcb->bd_addr,
+ if (!stack::l2cap::get_interface().L2CA_DisconnectReq(p_mcb->lcid)) {
+ log::warn("Unable to send L2CAP disonnect request peer:{} cid:{}", p_mcb->bd_addr,
p_mcb->lcid);
}
@@ -465,8 +465,8 @@ void rfc_mx_sm_state_connected(tRFC_MCB* p_mcb, tRFC_MX_EVENT event, void* /* p_
/* If server wait for some time if client decide to reinitiate channel */
rfc_send_ua(p_mcb, RFCOMM_MX_DLCI);
if (p_mcb->is_initiator) {
- if (!L2CA_DisconnectReq(p_mcb->lcid)) {
- log::warn("Unable to send L2CAP disconnect request peer:{} cid:{}", p_mcb->bd_addr,
+ if (!stack::l2cap::get_interface().L2CA_DisconnectReq(p_mcb->lcid)) {
+ log::warn("Unable to send L2CAP disonnect request peer:{} cid:{}", p_mcb->bd_addr,
p_mcb->lcid);
}
}
@@ -497,14 +497,15 @@ void rfc_mx_sm_state_disc_wait_ua(tRFC_MCB* p_mcb, tRFC_MX_EVENT event, void* p_
case RFC_MX_EVENT_UA:
case RFC_MX_EVENT_DM:
case RFC_MX_EVENT_TIMEOUT:
- if (!L2CA_DisconnectReq(p_mcb->lcid)) {
- log::warn("Unable to send L2CAP disconnect request peer:{} cid:{}", p_mcb->bd_addr,
+ if (!stack::l2cap::get_interface().L2CA_DisconnectReq(p_mcb->lcid)) {
+ log::warn("Unable to send L2CAP disonnect request peer:{} cid:{}", p_mcb->bd_addr,
p_mcb->lcid);
}
if (p_mcb->restart_required) {
/* Start Request was received while disconnecting. Execute it again */
- uint16_t lcid = L2CA_ConnectReq(BT_PSM_RFCOMM, p_mcb->bd_addr);
+ uint16_t lcid =
+ stack::l2cap::get_interface().L2CA_ConnectReq(BT_PSM_RFCOMM, p_mcb->bd_addr);
if (lcid == 0) {
rfc_save_lcid_mcb(NULL, p_mcb->lcid);
p_mcb->lcid = 0;
@@ -614,7 +615,7 @@ void rfc_on_l2cap_error(uint16_t lcid, uint16_t result) {
if (p_mcb->is_initiator) {
log::error("disconnect L2CAP due to config failure for {}", p_mcb->bd_addr);
PORT_StartCnf(p_mcb, static_cast<uint16_t>(result));
- if (!L2CA_DisconnectReq(p_mcb->lcid)) {
+ if (!stack::l2cap::get_interface().L2CA_DisconnectReq(p_mcb->lcid)) {
log::warn("Unable to send L2CAP disconnect request peer:{} cid:{}", p_mcb->bd_addr,
p_mcb->lcid);
}
diff --git a/system/stack/rfcomm/rfc_ts_frames.cc b/system/stack/rfcomm/rfc_ts_frames.cc
index 3a44afd061..7dfff833c6 100644
--- a/system/stack/rfcomm/rfc_ts_frames.cc
+++ b/system/stack/rfcomm/rfc_ts_frames.cc
@@ -199,7 +199,8 @@ void rfc_send_buf_uih(tRFC_MCB* p_mcb, uint8_t dlci, BT_HDR* p_buf) {
if (dlci == RFCOMM_MX_DLCI) {
rfc_check_send_cmd(p_mcb, p_buf);
} else {
- if (L2CA_DataWrite(p_mcb->lcid, p_buf) != tL2CAP_DW_RESULT::SUCCESS) {
+ if (stack::l2cap::get_interface().L2CA_DataWrite(p_mcb->lcid, p_buf) !=
+ tL2CAP_DW_RESULT::SUCCESS) {
log::warn("Unable to write L2CAP data peer:{} cid:{} len:{}", p_mcb->bd_addr, p_mcb->lcid,
p_buf->len);
}
diff --git a/system/stack/rfcomm/rfc_utils.cc b/system/stack/rfcomm/rfc_utils.cc
index b86fed3b53..23420892cb 100644
--- a/system/stack/rfcomm/rfc_utils.cc
+++ b/system/stack/rfcomm/rfc_utils.cc
@@ -428,7 +428,7 @@ void rfc_check_send_cmd(tRFC_MCB* p_mcb, BT_HDR* p_buf) {
if (p == NULL) {
break;
}
- if (L2CA_DataWrite(p_mcb->lcid, p) != tL2CAP_DW_RESULT::SUCCESS) {
+ if (stack::l2cap::get_interface().L2CA_DataWrite(p_mcb->lcid, p) != tL2CAP_DW_RESULT::SUCCESS) {
log::warn("Unable to write L2CAP data peer:{} cid:{} len:{}", p_mcb->bd_addr, p_mcb->lcid,
p->len);
}