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

Commit 6486d350 authored by Chris Manton's avatar Chris Manton
Browse files

stack::l2cap Encapsulate L2CAP_SEND_CMD_OFFSET

Bug: 352604221
Test: m .
Flag: EXEMPT, Mechanical Refactor

Change-Id: I0af9ff41b9dea3b4f2edc90084811ce20e3f84cb
parent c96fc9cc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -524,11 +524,11 @@ TEST_F(MainShimTest, is_flushable) {
    alignas(BT_HDR) std::byte hdr_data[sizeof(BT_HDR) + sizeof(HciDataPreamble) + offset]{};
    BT_HDR* bt_hdr = reinterpret_cast<BT_HDR*>(hdr_data);

    uint8_t* p = ToPacketData<uint8_t>(bt_hdr, L2CAP_SEND_CMD_OFFSET);
    uint8_t* p = ToPacketData<uint8_t>(bt_hdr);
    UINT16_TO_STREAM(p, 0x123 | (L2CAP_PKT_START_NON_FLUSHABLE << L2CAP_PKT_TYPE_SHIFT));
    ASSERT_TRUE(!IsPacketFlushable(bt_hdr));

    p = ToPacketData<uint8_t>(bt_hdr, L2CAP_SEND_CMD_OFFSET);
    p = ToPacketData<uint8_t>(bt_hdr);
    UINT16_TO_STREAM(p, 0x123 | (L2CAP_PKT_START << L2CAP_PKT_TYPE_SHIFT));
    ASSERT_TRUE(IsPacketFlushable(bt_hdr));
  }
+0 −4
Original line number Diff line number Diff line
@@ -665,10 +665,6 @@ struct tL2C_TX_COMPLETE_CB_INFO {
  tL2CA_TX_COMPLETE_CB* cb;
};

/* The offset in a buffer that L2CAP will use when building commands.
 */
#define L2CAP_SEND_CMD_OFFSET 0

/* Number of ACL buffers to use for high priority channel
 */
#define L2CAP_HIGH_PRI_MIN_XMIT_QUOTA_A (L2CAP_HIGH_PRI_MIN_XMIT_QUOTA)
+6 −2
Original line number Diff line number Diff line
@@ -50,6 +50,10 @@ using namespace bluetooth;

tL2C_CCB* l2cu_get_next_channel_in_rr(tL2C_LCB* p_lcb);  // TODO Move

/* The offset in a buffer that L2CAP will use when building commands.
 */
#define L2CAP_SEND_CMD_OFFSET 0

/*******************************************************************************
 *
 * Function         l2cu_allocate_lcb
@@ -298,7 +302,7 @@ BT_HDR* l2cu_build_header(tL2C_LCB* p_lcb, uint16_t len, uint8_t cmd, uint8_t si

  p_buf->offset = L2CAP_SEND_CMD_OFFSET;
  p_buf->len = len + HCI_DATA_PREAMBLE_SIZE + L2CAP_PKT_OVERHEAD + L2CAP_CMD_OVERHEAD;
  p = (uint8_t*)(p_buf + 1) + L2CAP_SEND_CMD_OFFSET;
  p = (uint8_t*)(p_buf + 1) + p_buf->offset;

  /* Put in HCI header - handle + pkt boundary */
  if (p_lcb->transport == BT_TRANSPORT_LE) {
@@ -772,7 +776,7 @@ void l2cu_send_peer_config_rej(tL2C_CCB* p_ccb, uint8_t* p_data, uint16_t data_l

  BT_HDR* p_buf = (BT_HDR*)osi_malloc(len + rej_len);
  p_buf->offset = L2CAP_SEND_CMD_OFFSET;
  p = (uint8_t*)(p_buf + 1) + L2CAP_SEND_CMD_OFFSET;
  p = (uint8_t*)(p_buf + 1) + p_buf->offset;

  /* Put in HCI header - handle + pkt boundary */
  if (bluetooth::shim::GetController()->SupportsNonFlushablePb()) {