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

Commit ebad2f29 authored by Chris Manton's avatar Chris Manton
Browse files

Incoming ACL packets stop at acl layer first

Bug: 166280067
Tag: #refactor
Test: act.py -tc BleCocTest

Change-Id: Icbc0193a0db19c05f1edd5d4c3ea168819bae17b
parent 920fee2c
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -75,6 +75,11 @@ namespace {
StackAclBtmAcl internal_;
}

typedef struct {
  uint16_t handle;
  uint16_t hci_len;
} __attribute__((packed)) acl_header_t;

#define BTM_MAX_SW_ROLE_FAILED_ATTEMPTS 3

/* Define masks for supported and exception 2.0 ACL packet types
@@ -2917,3 +2922,28 @@ bool acl_create_le_connection(const RawAddress& bd_addr) {
void acl_cancel_le_connection(const RawAddress& bd_addr) {
  connection_manager::direct_connect_remove(CONN_MGR_ID_L2CAP, bd_addr);
}

void acl_rcv_acl_data(BT_HDR* p_msg) {
  acl_header_t acl_header{
      .handle = HCI_INVALID_HANDLE,
      .hci_len = 0,
  };
  const uint8_t* p = (uint8_t*)(p_msg + 1) + p_msg->offset;

  STREAM_TO_UINT16(acl_header.handle, p);
  acl_header.handle = HCID_GET_HANDLE(acl_header.handle);

  STREAM_TO_UINT16(acl_header.hci_len, p);
  if (acl_header.hci_len < L2CAP_PKT_OVERHEAD ||
      acl_header.hci_len != p_msg->len - sizeof(acl_header)) {
    LOG_WARN("Received mismatched hci header length:%u data_len:%zu",
             acl_header.hci_len, p_msg->len - sizeof(acl_header));
    osi_free(p_msg);
    return;
  }
  l2c_rcv_acl_data(p_msg);
}

void acl_link_segments_xmitted(BT_HDR* p_msg) {
  l2c_link_segments_xmitted(p_msg);
}
+4 −4
Original line number Diff line number Diff line
@@ -31,8 +31,8 @@
#include "common/message_loop_thread.h"
#include "osi/include/osi.h"
#include "stack/btm/btm_int.h"
#include "stack/include/acl_hci_link_interface.h"
#include "stack/include/btu.h"
#include "stack/include/l2cap_acl_interface.h"

#include <base/bind.h>
#include <base/logging.h>
@@ -53,13 +53,13 @@ void btu_hci_msg_process(BT_HDR* p_msg) {
  /* Determine the input message type. */
  switch (p_msg->event & BT_EVT_MASK) {
    case BT_EVT_TO_BTU_HCI_ACL:
      /* All Acl Data goes to L2CAP */
      l2c_rcv_acl_data(p_msg);
      /* All Acl Data goes to ACL */
      acl_rcv_acl_data(p_msg);
      break;

    case BT_EVT_TO_BTU_L2C_SEG_XMIT:
      /* L2CAP segment transmit complete */
      l2c_link_segments_xmitted(p_msg);
      acl_link_segments_xmitted(p_msg);
      break;

    case BT_EVT_TO_BTU_HCI_SCO:
+5 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@

#include <cstdint>

#include "stack/include/bt_types.h"

// This header contains functions for HCIF-Acl Management to invoke
//
void btm_acl_connection_request(const RawAddress& bda, uint8_t* dc);
@@ -46,3 +48,6 @@ void btm_read_remote_features_complete(uint8_t* p);
void btm_read_remote_version_complete(uint8_t* p);
void btm_read_rssi_complete(uint8_t* p);
void btm_read_tx_power_complete(uint8_t* p, bool is_ble);

void acl_rcv_acl_data(BT_HDR* p_msg);
void acl_link_segments_xmitted(BT_HDR* p_msg);