Loading tools/rootcanal/Android.bp +1 −7 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ cc_library_static { srcs: [ "model/controller/acl_connection.cc", "model/controller/acl_connection_handler.cc", "model/controller/controller_properties.cc", "model/controller/dual_mode_controller.cc", "model/controller/isochronous_connection_handler.cc", "model/controller/le_advertiser.cc", Loading @@ -62,16 +63,9 @@ cc_library_static { "model/devices/baseband_sniffer.cc", "model/devices/beacon.cc", "model/devices/beacon_swarm.cc", "model/devices/broken_adv.cc", "model/devices/car_kit.cc", "model/devices/classic.cc", "model/devices/device.cc", "model/devices/device_properties.cc", "model/devices/hci_device.cc", "model/devices/keyboard.cc", "model/devices/link_layer_socket_device.cc", "model/devices/loopback.cc", "model/devices/remote_loopback_device.cc", "model/devices/scripted_beacon.cc", "model/devices/sniffer.cc", "model/hci/h4_data_channel_packetizer.cc", Loading tools/rootcanal/model/devices/device_properties.cc→tools/rootcanal/model/controller/controller_properties.cc +3 −4 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ * limitations under the License. */ #include "device_properties.h" #include "controller_properties.h" #include <fstream> #include <memory> Loading Loading @@ -46,7 +46,7 @@ static void ParseHex64(Json::Value value, uint64_t* field) { namespace rootcanal { DeviceProperties::DeviceProperties(const std::string& file_name) ControllerProperties::ControllerProperties(const std::string& file_name) : acl_data_packet_size_(1024), sco_data_packet_size_(255), num_acl_data_packets_(10), Loading @@ -62,7 +62,6 @@ DeviceProperties::DeviceProperties(const std::string& file_name) le_resolving_list_size_(15) { std::string properties_raw; ASSERT(Address::FromString("BB:BB:BB:BB:BB:AD", address_)); ASSERT(Address::FromString("BB:BB:BB:BB:AD:1E", le_address_)); name_ = {'D', 'e', 'f', 'a', 'u', 'l', 't'}; Loading Loading @@ -121,7 +120,7 @@ DeviceProperties::DeviceProperties(const std::string& file_name) &le_resolving_list_ignore_reasons_); } bool DeviceProperties::SetLeHostFeature(uint8_t bit_number, uint8_t bit_value) { bool ControllerProperties::SetLeHostFeature(uint8_t bit_number, uint8_t bit_value) { if (bit_number >= 64 || bit_value > 1) return false; uint64_t bit_mask = UINT64_C(1) << bit_number; Loading tools/rootcanal/model/devices/device_properties.h→tools/rootcanal/model/controller/controller_properties.h +2 −7 Original line number Diff line number Diff line Loading @@ -137,9 +137,9 @@ static constexpr uint64_t LlFeatures() { return value; } class DeviceProperties { class ControllerProperties { public: explicit DeviceProperties(const std::string& file_name = ""); explicit ControllerProperties(const std::string& file_name = ""); // Access private configuration data Loading Loading @@ -237,10 +237,6 @@ class DeviceProperties { sco_flow_control_ = sco_flow_control; } const Address& GetAddress() const { return address_; } void SetAddress(const Address& address) { address_ = address; } // Specification Version 4.2, Volume 2, Part E, Section 7.4.8 const std::vector<uint8_t>& GetSupportedCodecs() const { return supported_codecs_; Loading Loading @@ -469,7 +465,6 @@ class DeviceProperties { ClassOfDevice class_of_device_{{0, 0, 0}}; std::vector<uint8_t> extended_inquiry_data_; std::array<uint8_t, 248> name_{}; Address address_{}; uint8_t page_scan_repetition_mode_{}; uint16_t clock_offset_{}; uint8_t encryption_key_size_{10}; Loading tools/rootcanal/model/controller/dual_mode_controller.cc +12 −23 Original line number Diff line number Diff line Loading @@ -70,17 +70,17 @@ void DualModeController::SendCommandCompleteUnknownOpCodeEvent( #ifdef ROOTCANAL_LMP DualModeController::DualModeController(const std::string& properties_filename, uint16_t) : Device(properties_filename) { : Device(), properties_(properties_filename) { #else DualModeController::DualModeController(const std::string& properties_filename, uint16_t num_keys) : Device(properties_filename), security_manager_(num_keys) { : Device(), properties_(properties_filename), security_manager_(num_keys) { #endif loopback_mode_ = LoopbackMode::NO_LOOPBACK; Address public_address{}; ASSERT(Address::FromString("3C:5A:B4:04:05:06", public_address)); properties_.SetAddress(public_address); SetAddress(public_address); link_layer_controller_.RegisterRemoteChannel( [this](std::shared_ptr<model::packets::LinkLayerPacketBuilder> packet, Loading Loading @@ -562,7 +562,7 @@ void DualModeController::ReadBdAddr(CommandView command) { auto command_view = gd_hci::ReadBdAddrView::Create(command); ASSERT(command_view.IsValid()); send_event_(bluetooth::hci::ReadBdAddrCompleteBuilder::Create( kNumCommandPackets, ErrorCode::SUCCESS, properties_.GetAddress())); kNumCommandPackets, ErrorCode::SUCCESS, GetAddress())); } void DualModeController::ReadLocalSupportedCommands(CommandView command) { Loading Loading @@ -1083,7 +1083,7 @@ void DualModeController::PinCodeRequestReply(CommandView command) { auto command_view = gd_hci::PinCodeRequestReplyView::Create( gd_hci::SecurityCommandView::Create(command)); ASSERT(command_view.IsValid()); LOG_INFO("%s", properties_.GetAddress().ToString().c_str()); LOG_INFO("%s", GetAddress().ToString().c_str()); Address peer = command_view.GetBdAddr(); uint8_t pin_length = command_view.GetPinCodeLength(); Loading @@ -1106,7 +1106,7 @@ void DualModeController::PinCodeRequestNegativeReply(CommandView command) { auto command_view = gd_hci::PinCodeRequestNegativeReplyView::Create( gd_hci::SecurityCommandView::Create(command)); ASSERT(command_view.IsValid()); LOG_INFO("%s", properties_.GetAddress().ToString().c_str()); LOG_INFO("%s", GetAddress().ToString().c_str()); Address peer = command_view.GetBdAddr(); Loading Loading @@ -1831,8 +1831,7 @@ void DualModeController::WriteScanEnable(CommandView command) { bool page_scan = scan_enable == gd_hci::ScanEnable::INQUIRY_AND_PAGE_SCAN || scan_enable == gd_hci::ScanEnable::PAGE_SCAN_ONLY; LOG_INFO("%s | WriteScanEnable %s", properties_.GetAddress().ToString().c_str(), LOG_INFO("%s | WriteScanEnable %s", GetAddress().ToString().c_str(), gd_hci::ScanEnableText(scan_enable).c_str()); link_layer_controller_.SetInquiryScanEnable(inquiry_scan); Loading Loading @@ -2079,7 +2078,7 @@ void DualModeController::LeReadLocalSupportedFeatures(CommandView command) { ASSERT(command_view.IsValid()); LOG_INFO( "%s | LeReadLocalSupportedFeatures (%016llx)", properties_.GetAddress().ToString().c_str(), GetAddress().ToString().c_str(), static_cast<unsigned long long>(properties_.GetLeSupportedFeatures())); send_event_( Loading Loading @@ -2162,8 +2161,7 @@ void DualModeController::LeSetAdvertisingEnable(CommandView command) { gd_hci::LeAdvertisingCommandView::Create(command)); ASSERT(command_view.IsValid()); LOG_INFO("%s | LeSetAdvertisingEnable (%d)", properties_.GetAddress().ToString().c_str(), LOG_INFO("%s | LeSetAdvertisingEnable (%d)", GetAddress().ToString().c_str(), command_view.GetAdvertisingEnable() == gd_hci::Enable::ENABLED); auto status = link_layer_controller_.SetLeAdvertisingEnable( Loading Loading @@ -2192,8 +2190,7 @@ void DualModeController::LeSetScanEnable(CommandView command) { gd_hci::LeScanningCommandView::Create(command)); ASSERT(command_view.IsValid()); LOG_INFO("%s | LeSetScanEnable (%d)", properties_.GetAddress().ToString().c_str(), LOG_INFO("%s | LeSetScanEnable (%d)", GetAddress().ToString().c_str(), command_view.GetLeScanEnable() == gd_hci::Enable::ENABLED); if (command_view.GetLeScanEnable() == gd_hci::Enable::ENABLED) { Loading Loading @@ -3113,23 +3110,15 @@ void DualModeController::WriteLoopbackMode(CommandView command) { // ACL channel uint16_t acl_handle = 0x123; send_event_(bluetooth::hci::ConnectionCompleteBuilder::Create( ErrorCode::SUCCESS, acl_handle, properties_.GetAddress(), ErrorCode::SUCCESS, acl_handle, GetAddress(), bluetooth::hci::LinkType::ACL, bluetooth::hci::Enable::DISABLED)); // SCO channel uint16_t sco_handle = 0x345; send_event_(bluetooth::hci::ConnectionCompleteBuilder::Create( ErrorCode::SUCCESS, sco_handle, properties_.GetAddress(), ErrorCode::SUCCESS, sco_handle, GetAddress(), bluetooth::hci::LinkType::SCO, bluetooth::hci::Enable::DISABLED)); send_event_(bluetooth::hci::WriteLoopbackModeCompleteBuilder::Create( kNumCommandPackets, ErrorCode::SUCCESS)); } void DualModeController::SetAddress(Address address) { properties_.SetAddress(address); } const Address& DualModeController::GetAddress() { return properties_.GetAddress(); } } // namespace rootcanal tools/rootcanal/model/controller/dual_mode_controller.h +6 −7 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "hci/address.h" #include "hci/hci_packets.h" #include "controller_properties.h" #include "link_layer_controller.h" #include "model/devices/device.h" #include "model/setup/async_manager.h" Loading Loading @@ -108,12 +109,6 @@ class DualModeController : public Device { const std::function<void(std::shared_ptr<std::vector<uint8_t>>)>& send_iso); // Set the device's address. void SetAddress(Address address) override; // Get the device's address. const Address& GetAddress(); // Controller commands. For error codes, see the Bluetooth Core Specification, // Version 4.2, Volume 2, Part D (page 370). Loading Loading @@ -628,7 +623,11 @@ class DualModeController : public Device { void StopTimer(); protected: LinkLayerController link_layer_controller_{properties_}; // Controller configuration. ControllerProperties properties_; // Link Layer state. LinkLayerController link_layer_controller_{address_, properties_}; private: // Set a timer for a future action Loading Loading
tools/rootcanal/Android.bp +1 −7 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ cc_library_static { srcs: [ "model/controller/acl_connection.cc", "model/controller/acl_connection_handler.cc", "model/controller/controller_properties.cc", "model/controller/dual_mode_controller.cc", "model/controller/isochronous_connection_handler.cc", "model/controller/le_advertiser.cc", Loading @@ -62,16 +63,9 @@ cc_library_static { "model/devices/baseband_sniffer.cc", "model/devices/beacon.cc", "model/devices/beacon_swarm.cc", "model/devices/broken_adv.cc", "model/devices/car_kit.cc", "model/devices/classic.cc", "model/devices/device.cc", "model/devices/device_properties.cc", "model/devices/hci_device.cc", "model/devices/keyboard.cc", "model/devices/link_layer_socket_device.cc", "model/devices/loopback.cc", "model/devices/remote_loopback_device.cc", "model/devices/scripted_beacon.cc", "model/devices/sniffer.cc", "model/hci/h4_data_channel_packetizer.cc", Loading
tools/rootcanal/model/devices/device_properties.cc→tools/rootcanal/model/controller/controller_properties.cc +3 −4 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ * limitations under the License. */ #include "device_properties.h" #include "controller_properties.h" #include <fstream> #include <memory> Loading Loading @@ -46,7 +46,7 @@ static void ParseHex64(Json::Value value, uint64_t* field) { namespace rootcanal { DeviceProperties::DeviceProperties(const std::string& file_name) ControllerProperties::ControllerProperties(const std::string& file_name) : acl_data_packet_size_(1024), sco_data_packet_size_(255), num_acl_data_packets_(10), Loading @@ -62,7 +62,6 @@ DeviceProperties::DeviceProperties(const std::string& file_name) le_resolving_list_size_(15) { std::string properties_raw; ASSERT(Address::FromString("BB:BB:BB:BB:BB:AD", address_)); ASSERT(Address::FromString("BB:BB:BB:BB:AD:1E", le_address_)); name_ = {'D', 'e', 'f', 'a', 'u', 'l', 't'}; Loading Loading @@ -121,7 +120,7 @@ DeviceProperties::DeviceProperties(const std::string& file_name) &le_resolving_list_ignore_reasons_); } bool DeviceProperties::SetLeHostFeature(uint8_t bit_number, uint8_t bit_value) { bool ControllerProperties::SetLeHostFeature(uint8_t bit_number, uint8_t bit_value) { if (bit_number >= 64 || bit_value > 1) return false; uint64_t bit_mask = UINT64_C(1) << bit_number; Loading
tools/rootcanal/model/devices/device_properties.h→tools/rootcanal/model/controller/controller_properties.h +2 −7 Original line number Diff line number Diff line Loading @@ -137,9 +137,9 @@ static constexpr uint64_t LlFeatures() { return value; } class DeviceProperties { class ControllerProperties { public: explicit DeviceProperties(const std::string& file_name = ""); explicit ControllerProperties(const std::string& file_name = ""); // Access private configuration data Loading Loading @@ -237,10 +237,6 @@ class DeviceProperties { sco_flow_control_ = sco_flow_control; } const Address& GetAddress() const { return address_; } void SetAddress(const Address& address) { address_ = address; } // Specification Version 4.2, Volume 2, Part E, Section 7.4.8 const std::vector<uint8_t>& GetSupportedCodecs() const { return supported_codecs_; Loading Loading @@ -469,7 +465,6 @@ class DeviceProperties { ClassOfDevice class_of_device_{{0, 0, 0}}; std::vector<uint8_t> extended_inquiry_data_; std::array<uint8_t, 248> name_{}; Address address_{}; uint8_t page_scan_repetition_mode_{}; uint16_t clock_offset_{}; uint8_t encryption_key_size_{10}; Loading
tools/rootcanal/model/controller/dual_mode_controller.cc +12 −23 Original line number Diff line number Diff line Loading @@ -70,17 +70,17 @@ void DualModeController::SendCommandCompleteUnknownOpCodeEvent( #ifdef ROOTCANAL_LMP DualModeController::DualModeController(const std::string& properties_filename, uint16_t) : Device(properties_filename) { : Device(), properties_(properties_filename) { #else DualModeController::DualModeController(const std::string& properties_filename, uint16_t num_keys) : Device(properties_filename), security_manager_(num_keys) { : Device(), properties_(properties_filename), security_manager_(num_keys) { #endif loopback_mode_ = LoopbackMode::NO_LOOPBACK; Address public_address{}; ASSERT(Address::FromString("3C:5A:B4:04:05:06", public_address)); properties_.SetAddress(public_address); SetAddress(public_address); link_layer_controller_.RegisterRemoteChannel( [this](std::shared_ptr<model::packets::LinkLayerPacketBuilder> packet, Loading Loading @@ -562,7 +562,7 @@ void DualModeController::ReadBdAddr(CommandView command) { auto command_view = gd_hci::ReadBdAddrView::Create(command); ASSERT(command_view.IsValid()); send_event_(bluetooth::hci::ReadBdAddrCompleteBuilder::Create( kNumCommandPackets, ErrorCode::SUCCESS, properties_.GetAddress())); kNumCommandPackets, ErrorCode::SUCCESS, GetAddress())); } void DualModeController::ReadLocalSupportedCommands(CommandView command) { Loading Loading @@ -1083,7 +1083,7 @@ void DualModeController::PinCodeRequestReply(CommandView command) { auto command_view = gd_hci::PinCodeRequestReplyView::Create( gd_hci::SecurityCommandView::Create(command)); ASSERT(command_view.IsValid()); LOG_INFO("%s", properties_.GetAddress().ToString().c_str()); LOG_INFO("%s", GetAddress().ToString().c_str()); Address peer = command_view.GetBdAddr(); uint8_t pin_length = command_view.GetPinCodeLength(); Loading @@ -1106,7 +1106,7 @@ void DualModeController::PinCodeRequestNegativeReply(CommandView command) { auto command_view = gd_hci::PinCodeRequestNegativeReplyView::Create( gd_hci::SecurityCommandView::Create(command)); ASSERT(command_view.IsValid()); LOG_INFO("%s", properties_.GetAddress().ToString().c_str()); LOG_INFO("%s", GetAddress().ToString().c_str()); Address peer = command_view.GetBdAddr(); Loading Loading @@ -1831,8 +1831,7 @@ void DualModeController::WriteScanEnable(CommandView command) { bool page_scan = scan_enable == gd_hci::ScanEnable::INQUIRY_AND_PAGE_SCAN || scan_enable == gd_hci::ScanEnable::PAGE_SCAN_ONLY; LOG_INFO("%s | WriteScanEnable %s", properties_.GetAddress().ToString().c_str(), LOG_INFO("%s | WriteScanEnable %s", GetAddress().ToString().c_str(), gd_hci::ScanEnableText(scan_enable).c_str()); link_layer_controller_.SetInquiryScanEnable(inquiry_scan); Loading Loading @@ -2079,7 +2078,7 @@ void DualModeController::LeReadLocalSupportedFeatures(CommandView command) { ASSERT(command_view.IsValid()); LOG_INFO( "%s | LeReadLocalSupportedFeatures (%016llx)", properties_.GetAddress().ToString().c_str(), GetAddress().ToString().c_str(), static_cast<unsigned long long>(properties_.GetLeSupportedFeatures())); send_event_( Loading Loading @@ -2162,8 +2161,7 @@ void DualModeController::LeSetAdvertisingEnable(CommandView command) { gd_hci::LeAdvertisingCommandView::Create(command)); ASSERT(command_view.IsValid()); LOG_INFO("%s | LeSetAdvertisingEnable (%d)", properties_.GetAddress().ToString().c_str(), LOG_INFO("%s | LeSetAdvertisingEnable (%d)", GetAddress().ToString().c_str(), command_view.GetAdvertisingEnable() == gd_hci::Enable::ENABLED); auto status = link_layer_controller_.SetLeAdvertisingEnable( Loading Loading @@ -2192,8 +2190,7 @@ void DualModeController::LeSetScanEnable(CommandView command) { gd_hci::LeScanningCommandView::Create(command)); ASSERT(command_view.IsValid()); LOG_INFO("%s | LeSetScanEnable (%d)", properties_.GetAddress().ToString().c_str(), LOG_INFO("%s | LeSetScanEnable (%d)", GetAddress().ToString().c_str(), command_view.GetLeScanEnable() == gd_hci::Enable::ENABLED); if (command_view.GetLeScanEnable() == gd_hci::Enable::ENABLED) { Loading Loading @@ -3113,23 +3110,15 @@ void DualModeController::WriteLoopbackMode(CommandView command) { // ACL channel uint16_t acl_handle = 0x123; send_event_(bluetooth::hci::ConnectionCompleteBuilder::Create( ErrorCode::SUCCESS, acl_handle, properties_.GetAddress(), ErrorCode::SUCCESS, acl_handle, GetAddress(), bluetooth::hci::LinkType::ACL, bluetooth::hci::Enable::DISABLED)); // SCO channel uint16_t sco_handle = 0x345; send_event_(bluetooth::hci::ConnectionCompleteBuilder::Create( ErrorCode::SUCCESS, sco_handle, properties_.GetAddress(), ErrorCode::SUCCESS, sco_handle, GetAddress(), bluetooth::hci::LinkType::SCO, bluetooth::hci::Enable::DISABLED)); send_event_(bluetooth::hci::WriteLoopbackModeCompleteBuilder::Create( kNumCommandPackets, ErrorCode::SUCCESS)); } void DualModeController::SetAddress(Address address) { properties_.SetAddress(address); } const Address& DualModeController::GetAddress() { return properties_.GetAddress(); } } // namespace rootcanal
tools/rootcanal/model/controller/dual_mode_controller.h +6 −7 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "hci/address.h" #include "hci/hci_packets.h" #include "controller_properties.h" #include "link_layer_controller.h" #include "model/devices/device.h" #include "model/setup/async_manager.h" Loading Loading @@ -108,12 +109,6 @@ class DualModeController : public Device { const std::function<void(std::shared_ptr<std::vector<uint8_t>>)>& send_iso); // Set the device's address. void SetAddress(Address address) override; // Get the device's address. const Address& GetAddress(); // Controller commands. For error codes, see the Bluetooth Core Specification, // Version 4.2, Volume 2, Part D (page 370). Loading Loading @@ -628,7 +623,11 @@ class DualModeController : public Device { void StopTimer(); protected: LinkLayerController link_layer_controller_{properties_}; // Controller configuration. ControllerProperties properties_; // Link Layer state. LinkLayerController link_layer_controller_{address_, properties_}; private: // Set a timer for a future action Loading