Loading tools/rootcanal/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ cc_defaults { filegroup { name: "lib_sources", srcs: [ "lib/log.cc", "lib/crypto/crypto.cc", "lib/hci/address.cc", "lib/hci/class_of_device.cc", Loading Loading @@ -335,7 +336,6 @@ cc_test_host { "libbt-rootcanal", ], cflags: [ "-DLOG_NDEBUG=1", "-fvisibility=hidden", ], target: { Loading tools/rootcanal/CMakeLists.txt +20 −7 Original line number Diff line number Diff line Loading @@ -207,6 +207,18 @@ target_link_libraries(libbt-rootcanal.headers android_license(TARGET "libbt-rootcanal.headers" LIBNAME None SPDX Apache-2.0 LICENSE Apache-2.0 LOCAL "${BT_ROOT}/../NOTICE") android_add_library( TARGET librootcanal_log LICENSE Apache-2.0 SOURCE_DIR ${ROOTCANAL_ROOT} SRC lib/log.cc ${AOSP_ROOT}/external/fmtlib/src/format.cc) target_include_directories( librootcanal_log PUBLIC ${ROOTCANAL_ROOT}/include ${AOSP_ROOT}/external/fmtlib/include) android_add_library( TARGET BluetoothPacketSources LICENSE Apache-2.0 Loading @@ -219,12 +231,11 @@ android_add_library( packet_view.cc raw_builder.cc view.cc DEPS android-emu-base android-emu-base-headers) DEPS android-emu-base android-emu-base-headers librootcanal_log) target_include_directories( BluetoothPacketSources PUBLIC ${ROOTCANAL_ROOT}/emulator ${ROOTCANAL_ROOT}/emulator/include ${ROOTCANAL_ROOT} ${ROOTCANAL_ROOT}/include ${BT_ROOT}/gd ${BT_ROOT}) Loading @@ -238,11 +249,11 @@ android_add_library( SOURCE_DIR ${ROOTCANAL_ROOT} SRC ${BluetoothGeneratedPackets_h} ${RootCanalGeneratedPackets_h} emulator/src/log.cc lib/crypto/crypto.cc lib/hci/address.cc lib/hci/class_of_device.cc lib/hci/pcap_filter.cc lib/log.cc model/controller/acl_connection.cc model/controller/acl_connection_handler.cc model/controller/controller_properties.cc Loading Loading @@ -281,11 +292,13 @@ android_add_library( librootcanal_config libscriptedbeaconpayload-protos-lite) target_link_libraries( libbt-rootcanal PUBLIC librootcanal_log) target_include_directories( libbt-rootcanal PUBLIC ${ROOTCANAL_ROOT}/emulator ${ROOTCANAL_ROOT}/emulator/include ${ROOTCANAL_ROOT}/include PUBLIC ${ROOTCANAL_ROOT}/include ${ROOTCANAL_ROOT} ${BT_ROOT}/gd ${BT_ROOT} Loading tools/rootcanal/desktop/root_canal_main.cc +15 −13 Original line number Diff line number Diff line Loading @@ -33,16 +33,18 @@ #include "net/posix/posix_async_socket_server.h" #include "test_environment.h" using ::android::bluetooth::root_canal::TestEnvironment; using ::android::net::PosixAsyncSocketConnector; using ::android::net::PosixAsyncSocketServer; using rootcanal::AsyncManager; using rootcanal::TestEnvironment; using namespace rootcanal; DEFINE_string(controller_properties_file, "", "deprecated"); DEFINE_string(configuration, "", "controller configuration (see config.proto)"); DEFINE_string(configuration_file, "", "controller configuration file path (see config.proto)"); DEFINE_string(default_commands_file, "", "deprecated"); DEFINE_bool(enable_log_color, false, "enable log colors"); DEFINE_bool(enable_hci_sniffer, false, "enable hci sniffer"); DEFINE_bool(enable_baseband_sniffer, false, "enable baseband sniffer"); DEFINE_bool(enable_pcap_filter, false, "enable PCAP filter"); Loading @@ -67,20 +69,20 @@ bool crash_callback(const void* crash_context, size_t crash_context_size, crash_context); tid = ctx->tid; int signal_number = ctx->siginfo.si_signo; LOG_ERROR("Process crashed, signal: %s[%d], tid: %d", strsignal(signal_number), signal_number, ctx->tid); ERROR("Process crashed, signal: {}[{}], tid: {}", strsignal(signal_number), signal_number, ctx->tid); } else { LOG_ERROR("Process crashed, signal: unknown, tid: unknown"); ERROR("Process crashed, signal: unknown, tid: unknown"); } unwindstack::AndroidLocalUnwinder unwinder; unwindstack::AndroidUnwinderData data; if (!unwinder.Unwind(tid, data)) { LOG_ERROR("Unwind failed"); ERROR("Unwind failed"); return false; } LOG_ERROR("Backtrace:"); ERROR("Backtrace:"); for (const auto& frame : data.frames) { LOG_ERROR("%s", unwinder.FormatFrame(frame).c_str()); ERROR("{}", unwinder.FormatFrame(frame).c_str()); } return true; } Loading @@ -93,27 +95,27 @@ int main(int argc, char** argv) { eh.set_crash_handler(crash_callback); gflags::ParseCommandLineFlags(&argc, &argv, true); android::base::InitLogging(argv); rootcanal::log::SetLogColorEnable(FLAGS_enable_log_color); LOG_INFO("main"); INFO("starting rootcanal"); if (FLAGS_test_port > UINT16_MAX) { LOG_ERROR("test_port out of range: %" PRIu32, FLAGS_test_port); ERROR("test_port out of range: {}", FLAGS_test_port); return -1; } if (FLAGS_hci_port > UINT16_MAX) { LOG_ERROR("hci_port out of range: %" PRIu32, FLAGS_hci_port); ERROR("hci_port out of range: {}", FLAGS_hci_port); return -1; } if (FLAGS_link_port > UINT16_MAX) { LOG_ERROR("link_port out of range: %" PRIu32, FLAGS_link_port); ERROR("link_port out of range: {}", FLAGS_link_port); return -1; } if (FLAGS_link_ble_port > UINT16_MAX) { LOG_ERROR("link_ble_port out of range: %" PRIu32, FLAGS_link_ble_port); ERROR("link_ble_port out of range: {}", FLAGS_link_ble_port); return -1; } Loading tools/rootcanal/desktop/test_environment.cc +11 −15 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ #include <utility> // for move #include <vector> // for vector #include "log.h" // for LOG_INFO, LOG_ERROR, LOG_WARN #include "log.h" #include "model/devices/baseband_sniffer.h" #include "model/devices/link_layer_socket_device.h" // for LinkLayerSocketDevice #include "model/hci/hci_sniffer.h" // for HciSniffer Loading @@ -31,9 +31,7 @@ #include "net/async_data_channel.h" // for AsyncDataChannel #include "net/async_data_channel_connector.h" // for AsyncDataChannelConnector namespace android { namespace bluetooth { namespace root_canal { namespace rootcanal { using rootcanal::AsyncTaskId; using rootcanal::BaseBandSniffer; Loading Loading @@ -90,7 +88,7 @@ void TestEnvironment::SetUpHciServer( std::function<std::shared_ptr<AsyncDataChannelServer>(AsyncManager*, int)> open_server, int tcp_port, rootcanal::ControllerProperties properties) { LOG_INFO("Opening an HCI with port %d", tcp_port); INFO("Opening an HCI with port {}", tcp_port); std::shared_ptr<AsyncDataChannelServer> server = open_server(&async_manager_, tcp_port); Loading Loading @@ -135,7 +133,7 @@ void TestEnvironment::SetUpHciServer( } void TestEnvironment::initialize(std::promise<void> barrier) { LOG_INFO("Initialized barrier"); INFO("Initialized barrier"); barrier_ = std::move(barrier); Loading Loading @@ -169,11 +167,11 @@ void TestEnvironment::initialize(std::promise<void> barrier) { Phy::Type::BR_EDR); } LOG_INFO("%s: Finished", __func__); INFO("{}: Finished", __func__); } void TestEnvironment::close() { LOG_INFO("%s", __func__); INFO("{}", __func__); test_model_.Reset(); } Loading Loading @@ -214,10 +212,10 @@ void TestEnvironment::SetUpTestChannel() { bool transport_configured = test_channel_transport_.SetUp( test_socket_server_, [this](std::shared_ptr<AsyncDataChannel> conn_fd, AsyncDataChannelServer* server) { LOG_INFO("Test channel connection accepted."); INFO("Test channel connection accepted."); server->StartListening(); if (test_channel_open_) { LOG_WARN("Only one connection at a time is supported"); WARNING("Only one connection at a time is supported"); rootcanal::TestChannelTransport::SendResponse( conn_fd, "The connection is broken"); return false; Loading Loading @@ -245,13 +243,11 @@ void TestEnvironment::SetUpTestChannel() { test_channel_.StartTimer({}); if (!transport_configured) { LOG_ERROR("Test channel SetUp failed."); ERROR("Test channel SetUp failed."); return; } LOG_INFO("Test channel SetUp() successful"); INFO("Test channel SetUp() successful"); } } // namespace root_canal } // namespace bluetooth } // namespace android } // namespace rootcanal tools/rootcanal/desktop/test_environment.h +5 −8 Original line number Diff line number Diff line Loading @@ -28,14 +28,12 @@ #include "model/setup/test_model.h" // for TestModel #include "net/async_data_channel_server.h" // for AsyncDataChannelS... namespace android { namespace net { namespace android::net { class AsyncDataChannel; class AsyncDataChannelConnector; } // namespace net } // namespace android::net namespace bluetooth { namespace root_canal { namespace rootcanal { using android::net::AsyncDataChannel; using android::net::AsyncDataChannelConnector; Loading Loading @@ -115,6 +113,5 @@ class TestEnvironment { rootcanal::TestCommandHandler test_channel_{test_model_}; }; } // namespace root_canal } // namespace bluetooth } // namespace android } // namespace rootcanal Loading
tools/rootcanal/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ cc_defaults { filegroup { name: "lib_sources", srcs: [ "lib/log.cc", "lib/crypto/crypto.cc", "lib/hci/address.cc", "lib/hci/class_of_device.cc", Loading Loading @@ -335,7 +336,6 @@ cc_test_host { "libbt-rootcanal", ], cflags: [ "-DLOG_NDEBUG=1", "-fvisibility=hidden", ], target: { Loading
tools/rootcanal/CMakeLists.txt +20 −7 Original line number Diff line number Diff line Loading @@ -207,6 +207,18 @@ target_link_libraries(libbt-rootcanal.headers android_license(TARGET "libbt-rootcanal.headers" LIBNAME None SPDX Apache-2.0 LICENSE Apache-2.0 LOCAL "${BT_ROOT}/../NOTICE") android_add_library( TARGET librootcanal_log LICENSE Apache-2.0 SOURCE_DIR ${ROOTCANAL_ROOT} SRC lib/log.cc ${AOSP_ROOT}/external/fmtlib/src/format.cc) target_include_directories( librootcanal_log PUBLIC ${ROOTCANAL_ROOT}/include ${AOSP_ROOT}/external/fmtlib/include) android_add_library( TARGET BluetoothPacketSources LICENSE Apache-2.0 Loading @@ -219,12 +231,11 @@ android_add_library( packet_view.cc raw_builder.cc view.cc DEPS android-emu-base android-emu-base-headers) DEPS android-emu-base android-emu-base-headers librootcanal_log) target_include_directories( BluetoothPacketSources PUBLIC ${ROOTCANAL_ROOT}/emulator ${ROOTCANAL_ROOT}/emulator/include ${ROOTCANAL_ROOT} ${ROOTCANAL_ROOT}/include ${BT_ROOT}/gd ${BT_ROOT}) Loading @@ -238,11 +249,11 @@ android_add_library( SOURCE_DIR ${ROOTCANAL_ROOT} SRC ${BluetoothGeneratedPackets_h} ${RootCanalGeneratedPackets_h} emulator/src/log.cc lib/crypto/crypto.cc lib/hci/address.cc lib/hci/class_of_device.cc lib/hci/pcap_filter.cc lib/log.cc model/controller/acl_connection.cc model/controller/acl_connection_handler.cc model/controller/controller_properties.cc Loading Loading @@ -281,11 +292,13 @@ android_add_library( librootcanal_config libscriptedbeaconpayload-protos-lite) target_link_libraries( libbt-rootcanal PUBLIC librootcanal_log) target_include_directories( libbt-rootcanal PUBLIC ${ROOTCANAL_ROOT}/emulator ${ROOTCANAL_ROOT}/emulator/include ${ROOTCANAL_ROOT}/include PUBLIC ${ROOTCANAL_ROOT}/include ${ROOTCANAL_ROOT} ${BT_ROOT}/gd ${BT_ROOT} Loading
tools/rootcanal/desktop/root_canal_main.cc +15 −13 Original line number Diff line number Diff line Loading @@ -33,16 +33,18 @@ #include "net/posix/posix_async_socket_server.h" #include "test_environment.h" using ::android::bluetooth::root_canal::TestEnvironment; using ::android::net::PosixAsyncSocketConnector; using ::android::net::PosixAsyncSocketServer; using rootcanal::AsyncManager; using rootcanal::TestEnvironment; using namespace rootcanal; DEFINE_string(controller_properties_file, "", "deprecated"); DEFINE_string(configuration, "", "controller configuration (see config.proto)"); DEFINE_string(configuration_file, "", "controller configuration file path (see config.proto)"); DEFINE_string(default_commands_file, "", "deprecated"); DEFINE_bool(enable_log_color, false, "enable log colors"); DEFINE_bool(enable_hci_sniffer, false, "enable hci sniffer"); DEFINE_bool(enable_baseband_sniffer, false, "enable baseband sniffer"); DEFINE_bool(enable_pcap_filter, false, "enable PCAP filter"); Loading @@ -67,20 +69,20 @@ bool crash_callback(const void* crash_context, size_t crash_context_size, crash_context); tid = ctx->tid; int signal_number = ctx->siginfo.si_signo; LOG_ERROR("Process crashed, signal: %s[%d], tid: %d", strsignal(signal_number), signal_number, ctx->tid); ERROR("Process crashed, signal: {}[{}], tid: {}", strsignal(signal_number), signal_number, ctx->tid); } else { LOG_ERROR("Process crashed, signal: unknown, tid: unknown"); ERROR("Process crashed, signal: unknown, tid: unknown"); } unwindstack::AndroidLocalUnwinder unwinder; unwindstack::AndroidUnwinderData data; if (!unwinder.Unwind(tid, data)) { LOG_ERROR("Unwind failed"); ERROR("Unwind failed"); return false; } LOG_ERROR("Backtrace:"); ERROR("Backtrace:"); for (const auto& frame : data.frames) { LOG_ERROR("%s", unwinder.FormatFrame(frame).c_str()); ERROR("{}", unwinder.FormatFrame(frame).c_str()); } return true; } Loading @@ -93,27 +95,27 @@ int main(int argc, char** argv) { eh.set_crash_handler(crash_callback); gflags::ParseCommandLineFlags(&argc, &argv, true); android::base::InitLogging(argv); rootcanal::log::SetLogColorEnable(FLAGS_enable_log_color); LOG_INFO("main"); INFO("starting rootcanal"); if (FLAGS_test_port > UINT16_MAX) { LOG_ERROR("test_port out of range: %" PRIu32, FLAGS_test_port); ERROR("test_port out of range: {}", FLAGS_test_port); return -1; } if (FLAGS_hci_port > UINT16_MAX) { LOG_ERROR("hci_port out of range: %" PRIu32, FLAGS_hci_port); ERROR("hci_port out of range: {}", FLAGS_hci_port); return -1; } if (FLAGS_link_port > UINT16_MAX) { LOG_ERROR("link_port out of range: %" PRIu32, FLAGS_link_port); ERROR("link_port out of range: {}", FLAGS_link_port); return -1; } if (FLAGS_link_ble_port > UINT16_MAX) { LOG_ERROR("link_ble_port out of range: %" PRIu32, FLAGS_link_ble_port); ERROR("link_ble_port out of range: {}", FLAGS_link_ble_port); return -1; } Loading
tools/rootcanal/desktop/test_environment.cc +11 −15 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ #include <utility> // for move #include <vector> // for vector #include "log.h" // for LOG_INFO, LOG_ERROR, LOG_WARN #include "log.h" #include "model/devices/baseband_sniffer.h" #include "model/devices/link_layer_socket_device.h" // for LinkLayerSocketDevice #include "model/hci/hci_sniffer.h" // for HciSniffer Loading @@ -31,9 +31,7 @@ #include "net/async_data_channel.h" // for AsyncDataChannel #include "net/async_data_channel_connector.h" // for AsyncDataChannelConnector namespace android { namespace bluetooth { namespace root_canal { namespace rootcanal { using rootcanal::AsyncTaskId; using rootcanal::BaseBandSniffer; Loading Loading @@ -90,7 +88,7 @@ void TestEnvironment::SetUpHciServer( std::function<std::shared_ptr<AsyncDataChannelServer>(AsyncManager*, int)> open_server, int tcp_port, rootcanal::ControllerProperties properties) { LOG_INFO("Opening an HCI with port %d", tcp_port); INFO("Opening an HCI with port {}", tcp_port); std::shared_ptr<AsyncDataChannelServer> server = open_server(&async_manager_, tcp_port); Loading Loading @@ -135,7 +133,7 @@ void TestEnvironment::SetUpHciServer( } void TestEnvironment::initialize(std::promise<void> barrier) { LOG_INFO("Initialized barrier"); INFO("Initialized barrier"); barrier_ = std::move(barrier); Loading Loading @@ -169,11 +167,11 @@ void TestEnvironment::initialize(std::promise<void> barrier) { Phy::Type::BR_EDR); } LOG_INFO("%s: Finished", __func__); INFO("{}: Finished", __func__); } void TestEnvironment::close() { LOG_INFO("%s", __func__); INFO("{}", __func__); test_model_.Reset(); } Loading Loading @@ -214,10 +212,10 @@ void TestEnvironment::SetUpTestChannel() { bool transport_configured = test_channel_transport_.SetUp( test_socket_server_, [this](std::shared_ptr<AsyncDataChannel> conn_fd, AsyncDataChannelServer* server) { LOG_INFO("Test channel connection accepted."); INFO("Test channel connection accepted."); server->StartListening(); if (test_channel_open_) { LOG_WARN("Only one connection at a time is supported"); WARNING("Only one connection at a time is supported"); rootcanal::TestChannelTransport::SendResponse( conn_fd, "The connection is broken"); return false; Loading Loading @@ -245,13 +243,11 @@ void TestEnvironment::SetUpTestChannel() { test_channel_.StartTimer({}); if (!transport_configured) { LOG_ERROR("Test channel SetUp failed."); ERROR("Test channel SetUp failed."); return; } LOG_INFO("Test channel SetUp() successful"); INFO("Test channel SetUp() successful"); } } // namespace root_canal } // namespace bluetooth } // namespace android } // namespace rootcanal
tools/rootcanal/desktop/test_environment.h +5 −8 Original line number Diff line number Diff line Loading @@ -28,14 +28,12 @@ #include "model/setup/test_model.h" // for TestModel #include "net/async_data_channel_server.h" // for AsyncDataChannelS... namespace android { namespace net { namespace android::net { class AsyncDataChannel; class AsyncDataChannelConnector; } // namespace net } // namespace android::net namespace bluetooth { namespace root_canal { namespace rootcanal { using android::net::AsyncDataChannel; using android::net::AsyncDataChannelConnector; Loading Loading @@ -115,6 +113,5 @@ class TestEnvironment { rootcanal::TestCommandHandler test_channel_{test_model_}; }; } // namespace root_canal } // namespace bluetooth } // namespace android } // namespace rootcanal