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

Commit 1045f6a1 authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge changes from topic "rootcanal-lmp"

* changes:
  RootCanal: Remove the legacy authentication code
  RootCanal: Cleanup build declarations in CMakeLists.txt
parents fb168aaa 68511fb9
Loading
Loading
Loading
Loading
+0 −5
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@ cc_defaults {
    tidy_checks: [
    tidy_checks: [
        "-*",
        "-*",
        "readability-*",
        "readability-*",

        "-readability-function-size",
        "-readability-function-size",
        "-readability-identifier-length",
        "-readability-identifier-length",
        "-readability-implicit-bool-conversion",
        "-readability-implicit-bool-conversion",
@@ -37,7 +36,6 @@ cc_defaults {
        "gd_defaults",
        "gd_defaults",
    ],
    ],
    cflags: [
    cflags: [
        "-DROOTCANAL_LMP",
        "-fvisibility=hidden",
        "-fvisibility=hidden",
    ],
    ],
    local_include_dirs: [
    local_include_dirs: [
@@ -82,7 +80,6 @@ cc_library_static {
        "model/controller/le_advertiser.cc",
        "model/controller/le_advertiser.cc",
        "model/controller/link_layer_controller.cc",
        "model/controller/link_layer_controller.cc",
        "model/controller/sco_connection.cc",
        "model/controller/sco_connection.cc",
        "model/controller/security_manager.cc",
        "model/devices/baseband_sniffer.cc",
        "model/devices/baseband_sniffer.cc",
        "model/devices/beacon.cc",
        "model/devices/beacon.cc",
        "model/devices/beacon_swarm.cc",
        "model/devices/beacon_swarm.cc",
@@ -148,7 +145,6 @@ cc_library_host_shared {
        "model/controller/le_advertiser.cc",
        "model/controller/le_advertiser.cc",
        "model/controller/link_layer_controller.cc",
        "model/controller/link_layer_controller.cc",
        "model/controller/sco_connection.cc",
        "model/controller/sco_connection.cc",
        "model/controller/security_manager.cc",
        "model/devices/device.cc",
        "model/devices/device.cc",
        "model/setup/async_manager.cc",
        "model/setup/async_manager.cc",
    ],
    ],
@@ -313,7 +309,6 @@ cc_test_host {
        "test/async_manager_unittest.cc",
        "test/async_manager_unittest.cc",
        "test/h4_parser_unittest.cc",
        "test/h4_parser_unittest.cc",
        "test/posix_socket_unittest.cc",
        "test/posix_socket_unittest.cc",
        "test/security_manager_unittest.cc",
    ],
    ],
    header_libs: [
    header_libs: [
        "libbluetooth_headers",
        "libbluetooth_headers",
+7 −23
Original line number Original line Diff line number Diff line
@@ -136,8 +136,7 @@ target_link_libraries(libscriptedbeaconpayload-protos-lite
                      PRIVATE protobuf::libprotobuf)
                      PRIVATE protobuf::libprotobuf)


add_library(libbt-rootcanal.headers INTERFACE)
add_library(libbt-rootcanal.headers INTERFACE)
target_include_directories(libbt-rootcanal.headers INTERFACE .
target_include_directories(libbt-rootcanal.headers INTERFACE ${ROOTCANAL_ROOT})
                                                             ${ROOTCANAL_ROOT})
target_link_libraries(libbt-rootcanal.headers
target_link_libraries(libbt-rootcanal.headers
                      INTERFACE android-emu-base-headers)
                      INTERFACE android-emu-base-headers)
android_license(TARGET "libbt-rootcanal.headers" LIBNAME None SPDX Apache-2.0
android_license(TARGET "libbt-rootcanal.headers" LIBNAME None SPDX Apache-2.0
@@ -164,32 +163,17 @@ target_include_directories(
    ${ROOTCANAL_ROOT}/include
    ${ROOTCANAL_ROOT}/include
    ${BT_ROOT}/gd
    ${BT_ROOT}/gd
    ${BT_ROOT})
    ${BT_ROOT})

target_compile_options(BluetoothPacketSources
target_compile_options(BluetoothPacketSources
                       PUBLIC -Wno-inconsistent-missing-override)
                       PUBLIC -Wno-inconsistent-missing-override)


android_add_library(
  TARGET aemu-rootcanal-log-wrapper LICENSE Apache-2.0 SRC emulator/src/log.cc
  DEPS android-emu-base android-emu-base-headers android-emu-base-logging)
target_include_directories(
  aemu-rootcanal-log-wrapper
  PRIVATE ${ROOTCANAL_ROOT}/emulator ${ROOTCANAL_ROOT}/emulator/include)

android_add_library(
  TARGET libbt-hci-packets LICENSE Apache-2.0 SOURCE_DIR ${ROOTCANAL_ROOT}
  SRC model/hci/h4_parser.cc model/hci/hci_protocol.cc
  DEPS aemu-rootcanal-log-wrapper android-emu-base android-emu-base-headers)
target_include_directories(libbt-hci-packets
   PUBLIC
     ${ROOTCANAL_ROOT}/emulator
     ${ROOTCANAL_ROOT}/emulator/include
     ${ROOTCANAL_ROOT})

android_add_library(
android_add_library(
  TARGET libbt-rootcanal
  TARGET libbt-rootcanal
  LICENSE Apache-2.0
  LICENSE Apache-2.0
  SOURCE_DIR ${ROOTCANAL_ROOT}
  SOURCE_DIR ${ROOTCANAL_ROOT}
  SRC ${BluetoothGeneratedPackets_h}
  SRC ${BluetoothGeneratedPackets_h}
      ${RootCanalGeneratedPackets_h}
      ${RootCanalGeneratedPackets_h}
      emulator/src/log.cc
      lib/crypto/crypto.cc
      lib/crypto/crypto.cc
      lib/hci/address.cc
      lib/hci/address.cc
      lib/hci/class_of_device.cc
      lib/hci/class_of_device.cc
@@ -202,7 +186,6 @@ android_add_library(
      model/controller/le_advertiser.cc
      model/controller/le_advertiser.cc
      model/controller/link_layer_controller.cc
      model/controller/link_layer_controller.cc
      model/controller/sco_connection.cc
      model/controller/sco_connection.cc
      model/controller/security_manager.cc
      model/devices/beacon.cc
      model/devices/beacon.cc
      model/devices/beacon_swarm.cc
      model/devices/beacon_swarm.cc
      model/devices/device.cc
      model/devices/device.cc
@@ -227,14 +210,14 @@ android_add_library(
  DARWIN net/posix/posix_async_socket.cc
  DARWIN net/posix/posix_async_socket.cc
         net/posix/posix_async_socket_connector.cc
         net/posix/posix_async_socket_connector.cc
         net/posix/posix_async_socket_server.cc
         net/posix/posix_async_socket_server.cc
  DEPS aemu-rootcanal-log-wrapper
  DEPS android-emu-base
       android-emu-base
       android-emu-base-headers
       android-emu-base-headers
       android-emu-base-logging
       BluetoothPacketSources
       BluetoothPacketSources
       crypto
       crypto
       jsoncpp
       jsoncpp
       libbt-hci-packets
       libscriptedbeaconpayload-protos-lite)
       libscriptedbeaconpayload-protos-lite)

target_include_directories(
target_include_directories(
  libbt-rootcanal
  libbt-rootcanal
  PUBLIC ${ROOTCANAL_ROOT}/emulator
  PUBLIC ${ROOTCANAL_ROOT}/emulator
@@ -244,6 +227,7 @@ target_include_directories(
         ${BT_ROOT}/gd
         ${BT_ROOT}/gd
         ${BT_ROOT}
         ${BT_ROOT}
         ${CMAKE_CURRENT_BINARY_DIR}/packet_gen)
         ${CMAKE_CURRENT_BINARY_DIR}/packet_gen)

target_compile_options(libbt-rootcanal
target_compile_options(libbt-rootcanal
                       PUBLIC -Wno-inconsistent-missing-override)
                       PUBLIC -Wno-inconsistent-missing-override)


+2 −3
Original line number Original line Diff line number Diff line
@@ -23,7 +23,6 @@ add_custom_target(lmp_rust_packets DEPENDS ${LmpGeneratedPackets_rs}
add_dependencies(cargo-build_lmp lmp_rust_packets)
add_dependencies(cargo-build_lmp lmp_rust_packets)


# Enable lmp in rootcanal
# Enable lmp in rootcanal
target_link_libraries(libbt-rootcanal PRIVATE lmp)
target_link_libraries(libbt-rootcanal PUBLIC lmp)
target_compile_definitions(libbt-rootcanal PRIVATE ROOTCANAL_LMP)
target_include_directories(libbt-rootcanal
target_include_directories(libbt-rootcanal
                           PRIVATE ${ROOTCANAL_ROOT}/lmp/include)
    PUBLIC ${ROOTCANAL_ROOT}/lmp/include)
+1 −254
Original line number Original line Diff line number Diff line
@@ -61,15 +61,9 @@ void DualModeController::SendCommandCompleteUnknownOpCodeEvent(
          static_cast<uint8_t>(ErrorCode::UNKNOWN_HCI_COMMAND)})));
          static_cast<uint8_t>(ErrorCode::UNKNOWN_HCI_COMMAND)})));
}
}


#ifdef ROOTCANAL_LMP
DualModeController::DualModeController(const std::string& properties_filename,
DualModeController::DualModeController(const std::string& properties_filename,
                                       uint16_t /*num_keys*/)
                                       uint16_t /*num_keys*/)
    : properties_(properties_filename) {
    : properties_(properties_filename) {
#else
DualModeController::DualModeController(const std::string& properties_filename,
                                       uint16_t num_keys)
    : properties_(properties_filename), security_manager_(num_keys) {
#endif
  loopback_mode_ = LoopbackMode::NO_LOOPBACK;
  loopback_mode_ = LoopbackMode::NO_LOOPBACK;


  Address public_address{};
  Address public_address{};
@@ -823,218 +817,50 @@ void DualModeController::RejectSynchronousConnection(CommandView command) {
}
}


void DualModeController::IoCapabilityRequestReply(CommandView command) {
void DualModeController::IoCapabilityRequestReply(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view = bluetooth::hci::IoCapabilityRequestReplyView::Create(
      bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());

  Address peer = command_view.GetBdAddr();
  uint8_t io_capability = static_cast<uint8_t>(command_view.GetIoCapability());
  uint8_t oob_data_present_flag =
      static_cast<uint8_t>(command_view.GetOobPresent());
  uint8_t authentication_requirements =
      static_cast<uint8_t>(command_view.GetAuthenticationRequirements());

  auto status = link_layer_controller_.IoCapabilityRequestReply(
      peer, io_capability, oob_data_present_flag, authentication_requirements);
  send_event_(bluetooth::hci::IoCapabilityRequestReplyCompleteBuilder::Create(
      kNumCommandPackets, status, peer));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::UserConfirmationRequestReply(CommandView command) {
void DualModeController::UserConfirmationRequestReply(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view = bluetooth::hci::UserConfirmationRequestReplyView::Create(
      bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());

  Address peer = command_view.GetBdAddr();

  auto status = link_layer_controller_.UserConfirmationRequestReply(peer);
  send_event_(
      bluetooth::hci::UserConfirmationRequestReplyCompleteBuilder::Create(
          kNumCommandPackets, status, peer));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::UserConfirmationRequestNegativeReply(
void DualModeController::UserConfirmationRequestNegativeReply(
    CommandView command) {
    CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view =
      bluetooth::hci::UserConfirmationRequestNegativeReplyView::Create(
          bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());

  Address peer = command_view.GetBdAddr();

  auto status =
      link_layer_controller_.UserConfirmationRequestNegativeReply(peer);
  send_event_(
      bluetooth::hci::UserConfirmationRequestNegativeReplyCompleteBuilder::
          Create(kNumCommandPackets, status, peer));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::PinCodeRequestReply(CommandView command) {
void DualModeController::PinCodeRequestReply(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view = bluetooth::hci::PinCodeRequestReplyView::Create(
      bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());
  LOG_INFO("%s", GetAddress().ToString().c_str());

  Address peer = command_view.GetBdAddr();
  uint8_t pin_length = command_view.GetPinCodeLength();
  std::array<uint8_t, 16> pin = command_view.GetPinCode();
  ErrorCode status = ErrorCode::INVALID_HCI_COMMAND_PARAMETERS;
  if (pin_length >= 1 && pin_length <= 0x10) {
    status = link_layer_controller_.PinCodeRequestReply(
        peer, std::vector<uint8_t>(pin.begin(), pin.begin() + pin_length));
  }

  send_event_(bluetooth::hci::PinCodeRequestReplyCompleteBuilder::Create(
      kNumCommandPackets, status, peer));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::PinCodeRequestNegativeReply(CommandView command) {
void DualModeController::PinCodeRequestNegativeReply(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view = bluetooth::hci::PinCodeRequestNegativeReplyView::Create(
      bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());
  LOG_INFO("%s", GetAddress().ToString().c_str());

  Address peer = command_view.GetBdAddr();

  auto status = link_layer_controller_.PinCodeRequestNegativeReply(peer);
  send_event_(
      bluetooth::hci::PinCodeRequestNegativeReplyCompleteBuilder::Create(
          kNumCommandPackets, status, peer));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::UserPasskeyRequestReply(CommandView command) {
void DualModeController::UserPasskeyRequestReply(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view = bluetooth::hci::UserPasskeyRequestReplyView::Create(
      bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());

  Address peer = command_view.GetBdAddr();
  uint32_t numeric_value = command_view.GetNumericValue();

  auto status =
      link_layer_controller_.UserPasskeyRequestReply(peer, numeric_value);
  send_event_(bluetooth::hci::UserPasskeyRequestReplyCompleteBuilder::Create(
      kNumCommandPackets, status, peer));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::UserPasskeyRequestNegativeReply(CommandView command) {
void DualModeController::UserPasskeyRequestNegativeReply(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view =
      bluetooth::hci::UserPasskeyRequestNegativeReplyView::Create(
          bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());

  Address peer = command_view.GetBdAddr();

  auto status = link_layer_controller_.UserPasskeyRequestNegativeReply(peer);
  send_event_(
      bluetooth::hci::UserPasskeyRequestNegativeReplyCompleteBuilder::Create(
          kNumCommandPackets, status, peer));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::RemoteOobDataRequestReply(CommandView command) {
void DualModeController::RemoteOobDataRequestReply(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view = bluetooth::hci::RemoteOobDataRequestReplyView::Create(
      bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());

  Address peer = command_view.GetBdAddr();

  auto status = link_layer_controller_.RemoteOobDataRequestReply(
      peer, command_view.GetC(), command_view.GetR());

  send_event_(bluetooth::hci::RemoteOobDataRequestReplyCompleteBuilder::Create(
      kNumCommandPackets, status, peer));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::RemoteOobDataRequestNegativeReply(
void DualModeController::RemoteOobDataRequestNegativeReply(
    CommandView command) {
    CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view =
      bluetooth::hci::RemoteOobDataRequestNegativeReplyView::Create(
          bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());

  Address peer = command_view.GetBdAddr();

  auto status = link_layer_controller_.RemoteOobDataRequestNegativeReply(peer);
  send_event_(
      bluetooth::hci::RemoteOobDataRequestNegativeReplyCompleteBuilder::Create(
          kNumCommandPackets, status, peer));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::IoCapabilityRequestNegativeReply(CommandView command) {
void DualModeController::IoCapabilityRequestNegativeReply(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view =
      bluetooth::hci::IoCapabilityRequestNegativeReplyView::Create(
          bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());

  Address peer = command_view.GetBdAddr();
  ErrorCode reason = command_view.GetReason();

  auto status =
      link_layer_controller_.IoCapabilityRequestNegativeReply(peer, reason);
  send_event_(
      bluetooth::hci::IoCapabilityRequestNegativeReplyCompleteBuilder::Create(
          kNumCommandPackets, status, peer));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::RemoteOobExtendedDataRequestReply(
void DualModeController::RemoteOobExtendedDataRequestReply(
    CommandView command) {
    CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view =
      bluetooth::hci::RemoteOobExtendedDataRequestReplyView::Create(
          bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());

  Address peer = command_view.GetBdAddr();

  auto status = link_layer_controller_.RemoteOobExtendedDataRequestReply(
      peer, command_view.GetC192(), command_view.GetR192(),
      command_view.GetC256(), command_view.GetR256());

  send_event_(
      bluetooth::hci::RemoteOobExtendedDataRequestReplyCompleteBuilder::Create(
          kNumCommandPackets, status, peer));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::ReadInquiryResponseTransmitPowerLevel(
void DualModeController::ReadInquiryResponseTransmitPowerLevel(
@@ -1051,20 +877,7 @@ void DualModeController::ReadInquiryResponseTransmitPowerLevel(
}
}


void DualModeController::SendKeypressNotification(CommandView command) {
void DualModeController::SendKeypressNotification(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view = bluetooth::hci::SendKeypressNotificationView::Create(
      bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());

  auto peer = command_view.GetBdAddr();

  auto status = link_layer_controller_.SendKeypressNotification(
      peer, command_view.GetNotificationType());
  send_event_(bluetooth::hci::SendKeypressNotificationCompleteBuilder::Create(
      kNumCommandPackets, status, peer));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::EnhancedFlush(CommandView command) {
void DualModeController::EnhancedFlush(CommandView command) {
@@ -1220,38 +1033,11 @@ void DualModeController::WriteInquiryScanType(CommandView command) {
}
}


void DualModeController::AuthenticationRequested(CommandView command) {
void DualModeController::AuthenticationRequested(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view = bluetooth::hci::AuthenticationRequestedView::Create(
      bluetooth::hci::ConnectionManagementCommandView::Create(
          bluetooth::hci::AclCommandView::Create(command)));
  ASSERT(command_view.IsValid());
  uint16_t handle = command_view.GetConnectionHandle();
  auto status = link_layer_controller_.AuthenticationRequested(handle);

  send_event_(bluetooth::hci::AuthenticationRequestedStatusBuilder::Create(
      status, kNumCommandPackets));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::SetConnectionEncryption(CommandView command) {
void DualModeController::SetConnectionEncryption(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view = bluetooth::hci::SetConnectionEncryptionView::Create(
      bluetooth::hci::ConnectionManagementCommandView::Create(
          bluetooth::hci::AclCommandView::Create(command)));
  ASSERT(command_view.IsValid());
  uint16_t handle = command_view.GetConnectionHandle();
  uint8_t encryption_enable =
      static_cast<uint8_t>(command_view.GetEncryptionEnable());
  auto status =
      link_layer_controller_.SetConnectionEncryption(handle, encryption_enable);

  send_event_(bluetooth::hci::SetConnectionEncryptionStatusBuilder::Create(
      status, kNumCommandPackets));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::ChangeConnectionLinkKey(CommandView command) {
void DualModeController::ChangeConnectionLinkKey(CommandView command) {
@@ -1745,33 +1531,11 @@ void DualModeController::RejectConnectionRequest(CommandView command) {
}
}


void DualModeController::LinkKeyRequestReply(CommandView command) {
void DualModeController::LinkKeyRequestReply(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view = bluetooth::hci::LinkKeyRequestReplyView::Create(
      bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());
  Address addr = command_view.GetBdAddr();
  auto key = command_view.GetLinkKey();
  auto status = link_layer_controller_.LinkKeyRequestReply(addr, key);
  send_event_(bluetooth::hci::LinkKeyRequestReplyCompleteBuilder::Create(
      kNumCommandPackets, status, addr));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::LinkKeyRequestNegativeReply(CommandView command) {
void DualModeController::LinkKeyRequestNegativeReply(CommandView command) {
#ifdef ROOTCANAL_LMP
  link_layer_controller_.ForwardToLm(command);
  link_layer_controller_.ForwardToLm(command);
#else
  auto command_view = bluetooth::hci::LinkKeyRequestNegativeReplyView::Create(
      bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());
  Address addr = command_view.GetBdAddr();
  auto status = link_layer_controller_.LinkKeyRequestNegativeReply(addr);
  send_event_(
      bluetooth::hci::LinkKeyRequestNegativeReplyCompleteBuilder::Create(
          kNumCommandPackets, status, addr));
#endif /* ROOTCANAL_LMP */
}
}


void DualModeController::DeleteStoredLinkKey(CommandView command) {
void DualModeController::DeleteStoredLinkKey(CommandView command) {
@@ -1779,25 +1543,8 @@ void DualModeController::DeleteStoredLinkKey(CommandView command) {
      bluetooth::hci::SecurityCommandView::Create(command));
      bluetooth::hci::SecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());
  ASSERT(command_view.IsValid());


  uint16_t deleted_keys = 0;

  auto flag = command_view.GetDeleteAllFlag();
  if (flag ==
      bluetooth::hci::DeleteStoredLinkKeyDeleteAllFlag::SPECIFIED_BD_ADDR) {
    Address addr = command_view.GetBdAddr();
#ifndef ROOTCANAL_LMP
    deleted_keys = security_manager_.DeleteKey(addr);
#endif /* !ROOTCANAL_LMP */
  }

  if (flag == bluetooth::hci::DeleteStoredLinkKeyDeleteAllFlag::ALL) {
#ifndef ROOTCANAL_LMP
    security_manager_.DeleteAllKeys();
#endif /* !ROOTCANAL_LMP */
  }

  send_event_(bluetooth::hci::DeleteStoredLinkKeyCompleteBuilder::Create(
  send_event_(bluetooth::hci::DeleteStoredLinkKeyCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS, deleted_keys));
      kNumCommandPackets, ErrorCode::SUCCESS, 0));
}
}


void DualModeController::RemoteNameRequest(CommandView command) {
void DualModeController::RemoteNameRequest(CommandView command) {
+0 −7
Original line number Original line Diff line number Diff line
@@ -30,9 +30,6 @@
#include "link_layer_controller.h"
#include "link_layer_controller.h"
#include "model/controller/vendor_commands/csr.h"
#include "model/controller/vendor_commands/csr.h"
#include "model/devices/device.h"
#include "model/devices/device.h"
#ifndef ROOTCANAL_LMP
#include "security_manager.h"
#endif /* !ROOTCANAL_LMP */


namespace rootcanal {
namespace rootcanal {


@@ -669,10 +666,6 @@ class DualModeController : public Device {
      std::function<void(DualModeController*, bluetooth::hci::CommandView)>;
      std::function<void(DualModeController*, bluetooth::hci::CommandView)>;
  static const std::unordered_map<OpCode, CommandHandler> hci_command_handlers_;
  static const std::unordered_map<OpCode, CommandHandler> hci_command_handlers_;


#ifndef ROOTCANAL_LMP
  SecurityManager security_manager_;
#endif /* ROOTCANAL_LMP */

  DualModeController(const DualModeController& other) = delete;
  DualModeController(const DualModeController& other) = delete;
  DualModeController& operator=(const DualModeController& other) = delete;
  DualModeController& operator=(const DualModeController& other) = delete;
};
};
Loading