Loading tools/rootcanal/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ cc_library_static { "model/hci/h4_packetizer.cc", "model/hci/h4_parser.cc", "model/hci/hci_protocol.cc", "model/hci/hci_sniffer.cc", "model/hci/hci_socket_transport.cc", "model/setup/async_manager.cc", "model/setup/device_boutique.cc", Loading Loading @@ -178,6 +179,7 @@ cc_binary_host { "libbt-rootcanal", ], static_libs: [ "libc++fs", "libjsoncpp", "libprotobuf-cpp-lite", "libscriptedbeaconpayload-protos-lite", Loading tools/rootcanal/desktop/root_canal_main.cc +3 −1 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ DEFINE_string(controller_properties_file, "", "controller_properties.json file path"); DEFINE_string(default_commands_file, "", "commands file which root-canal runs it as default"); DEFINE_bool(enable_hci_sniffer, false, "enable hci sniffer"); constexpr uint16_t kTestPort = 6401; constexpr uint16_t kHciServerPort = 6402; Loading Loading @@ -125,7 +126,8 @@ int main(int argc, char** argv) { std::make_shared<PosixAsyncSocketServer>(link_server_port, &am), std::make_shared<PosixAsyncSocketServer>(link_ble_server_port, &am), std::make_shared<PosixAsyncSocketConnector>(&am), FLAGS_controller_properties_file, FLAGS_default_commands_file); FLAGS_controller_properties_file, FLAGS_default_commands_file, FLAGS_enable_hci_sniffer); std::promise<void> barrier; std::future<void> barrier_future = barrier.get_future(); root_canal.initialize(std::move(barrier)); Loading tools/rootcanal/desktop/test_environment.cc +16 −2 Original line number Diff line number Diff line Loading @@ -16,11 +16,13 @@ #include "test_environment.h" #include <filesystem> // for exists #include <type_traits> // for remove_extent_t #include <utility> // for move #include <vector> // for vector #include "model/devices/link_layer_socket_device.h" // for LinkLayerSocketDevice #include "model/hci/hci_sniffer.h" // for HciSniffer #include "model/hci/hci_socket_transport.h" // for HciSocketTransport #include "net/async_data_channel.h" // for AsyncDataChannel #include "net/async_data_channel_connector.h" // for AsyncDataChannelConnector Loading @@ -32,6 +34,7 @@ namespace root_canal { using rootcanal::AsyncTaskId; using rootcanal::HciDevice; using rootcanal::HciSniffer; using rootcanal::HciSocketTransport; using rootcanal::LinkLayerSocketDevice; using rootcanal::TaskCallback; Loading Loading @@ -59,8 +62,19 @@ void TestEnvironment::initialize(std::promise<void> barrier) { SetUpHciServer([this](std::shared_ptr<AsyncDataChannel> socket, AsyncDataChannelServer* srv) { auto transport = HciSocketTransport::Create(socket); test_model_.AddHciConnection( HciDevice::Create(transport, controller_properties_file_)); if (enable_hci_sniffer_) { transport = HciSniffer::Create(transport); } auto device = HciDevice::Create(transport, controller_properties_file_); test_model_.AddHciConnection(device); if (enable_hci_sniffer_) { auto filename = device->GetAddress().ToString() + ".pcap"; for (auto i = 0; std::filesystem::exists(filename); i++) { filename = device->GetAddress().ToString() + "_" + std::to_string(i) + ".pcap"; } std::static_pointer_cast<HciSniffer>(transport)->Open(filename.c_str()); } srv->StartListening(); }); SetUpLinkLayerServer(); Loading tools/rootcanal/desktop/test_environment.h +4 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,8 @@ class TestEnvironment { std::shared_ptr<AsyncDataChannelServer> link_ble_server_port, std::shared_ptr<AsyncDataChannelConnector> connector, const std::string& controller_properties_file = "", const std::string& default_commands_file = "") const std::string& default_commands_file = "", bool enable_hci_sniffer = false) : test_socket_server_(test_port), hci_socket_server_(hci_server_port), link_socket_server_(link_server_port), Loading @@ -62,6 +63,7 @@ class TestEnvironment { connector_(connector), controller_properties_file_(controller_properties_file), default_commands_file_(default_commands_file), enable_hci_sniffer_(enable_hci_sniffer), controller_(std::make_shared<rootcanal::DualModeController>( controller_properties_file)) {} Loading @@ -78,6 +80,7 @@ class TestEnvironment { std::shared_ptr<AsyncDataChannelConnector> connector_; std::string controller_properties_file_; std::string default_commands_file_; bool enable_hci_sniffer_; bool test_channel_open_{false}; std::promise<void> barrier_; Loading tools/rootcanal/model/controller/dual_mode_controller.cc +4 −0 Original line number Diff line number Diff line Loading @@ -2770,4 +2770,8 @@ void DualModeController::SetAddress(Address address) { properties_.SetAddress(address); } const Address& DualModeController::GetAddress() { return properties_.GetAddress(); } } // namespace rootcanal Loading
tools/rootcanal/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ cc_library_static { "model/hci/h4_packetizer.cc", "model/hci/h4_parser.cc", "model/hci/hci_protocol.cc", "model/hci/hci_sniffer.cc", "model/hci/hci_socket_transport.cc", "model/setup/async_manager.cc", "model/setup/device_boutique.cc", Loading Loading @@ -178,6 +179,7 @@ cc_binary_host { "libbt-rootcanal", ], static_libs: [ "libc++fs", "libjsoncpp", "libprotobuf-cpp-lite", "libscriptedbeaconpayload-protos-lite", Loading
tools/rootcanal/desktop/root_canal_main.cc +3 −1 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ DEFINE_string(controller_properties_file, "", "controller_properties.json file path"); DEFINE_string(default_commands_file, "", "commands file which root-canal runs it as default"); DEFINE_bool(enable_hci_sniffer, false, "enable hci sniffer"); constexpr uint16_t kTestPort = 6401; constexpr uint16_t kHciServerPort = 6402; Loading Loading @@ -125,7 +126,8 @@ int main(int argc, char** argv) { std::make_shared<PosixAsyncSocketServer>(link_server_port, &am), std::make_shared<PosixAsyncSocketServer>(link_ble_server_port, &am), std::make_shared<PosixAsyncSocketConnector>(&am), FLAGS_controller_properties_file, FLAGS_default_commands_file); FLAGS_controller_properties_file, FLAGS_default_commands_file, FLAGS_enable_hci_sniffer); std::promise<void> barrier; std::future<void> barrier_future = barrier.get_future(); root_canal.initialize(std::move(barrier)); Loading
tools/rootcanal/desktop/test_environment.cc +16 −2 Original line number Diff line number Diff line Loading @@ -16,11 +16,13 @@ #include "test_environment.h" #include <filesystem> // for exists #include <type_traits> // for remove_extent_t #include <utility> // for move #include <vector> // for vector #include "model/devices/link_layer_socket_device.h" // for LinkLayerSocketDevice #include "model/hci/hci_sniffer.h" // for HciSniffer #include "model/hci/hci_socket_transport.h" // for HciSocketTransport #include "net/async_data_channel.h" // for AsyncDataChannel #include "net/async_data_channel_connector.h" // for AsyncDataChannelConnector Loading @@ -32,6 +34,7 @@ namespace root_canal { using rootcanal::AsyncTaskId; using rootcanal::HciDevice; using rootcanal::HciSniffer; using rootcanal::HciSocketTransport; using rootcanal::LinkLayerSocketDevice; using rootcanal::TaskCallback; Loading Loading @@ -59,8 +62,19 @@ void TestEnvironment::initialize(std::promise<void> barrier) { SetUpHciServer([this](std::shared_ptr<AsyncDataChannel> socket, AsyncDataChannelServer* srv) { auto transport = HciSocketTransport::Create(socket); test_model_.AddHciConnection( HciDevice::Create(transport, controller_properties_file_)); if (enable_hci_sniffer_) { transport = HciSniffer::Create(transport); } auto device = HciDevice::Create(transport, controller_properties_file_); test_model_.AddHciConnection(device); if (enable_hci_sniffer_) { auto filename = device->GetAddress().ToString() + ".pcap"; for (auto i = 0; std::filesystem::exists(filename); i++) { filename = device->GetAddress().ToString() + "_" + std::to_string(i) + ".pcap"; } std::static_pointer_cast<HciSniffer>(transport)->Open(filename.c_str()); } srv->StartListening(); }); SetUpLinkLayerServer(); Loading
tools/rootcanal/desktop/test_environment.h +4 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,8 @@ class TestEnvironment { std::shared_ptr<AsyncDataChannelServer> link_ble_server_port, std::shared_ptr<AsyncDataChannelConnector> connector, const std::string& controller_properties_file = "", const std::string& default_commands_file = "") const std::string& default_commands_file = "", bool enable_hci_sniffer = false) : test_socket_server_(test_port), hci_socket_server_(hci_server_port), link_socket_server_(link_server_port), Loading @@ -62,6 +63,7 @@ class TestEnvironment { connector_(connector), controller_properties_file_(controller_properties_file), default_commands_file_(default_commands_file), enable_hci_sniffer_(enable_hci_sniffer), controller_(std::make_shared<rootcanal::DualModeController>( controller_properties_file)) {} Loading @@ -78,6 +80,7 @@ class TestEnvironment { std::shared_ptr<AsyncDataChannelConnector> connector_; std::string controller_properties_file_; std::string default_commands_file_; bool enable_hci_sniffer_; bool test_channel_open_{false}; std::promise<void> barrier_; Loading
tools/rootcanal/model/controller/dual_mode_controller.cc +4 −0 Original line number Diff line number Diff line Loading @@ -2770,4 +2770,8 @@ void DualModeController::SetAddress(Address address) { properties_.SetAddress(address); } const Address& DualModeController::GetAddress() { return properties_.GetAddress(); } } // namespace rootcanal