From 9b15da338e687b8dba72acde778cef206fc2cea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 09:18:43 +0100 Subject: [PATCH 01/20] Load Policies Lazy Load --- .gitignore | 2 + test/network_tests/CMakeLists.txt | 2 + .../lazy_load_tests/CMakeLists.txt | 106 ++++++++ .../conf/lazy_load_test_config.json.in | 109 ++++++++ .../conf/vsomeip_policy_extensions.json.in | 8 + .../extensions/1_1/vsomeip_security.json | 27 ++ .../lazy_load_tests/lazy_load_test_client.cpp | 230 +++++++++++++++++ .../lazy_load_tests/lazy_load_test_client.hpp | 61 +++++ .../lazy_load_test_lazy_client.cpp | 240 ++++++++++++++++++ .../lazy_load_test_lazy_client.hpp | 60 +++++ .../lazy_load_test_service.cpp | 195 ++++++++++++++ .../lazy_load_test_service.hpp | 53 ++++ .../lazy_load_tests/lazy_load_test_start.sh | 40 +++ test/network_tests/lazy_load_tests/readme | 112 ++++++++ 14 files changed, 1245 insertions(+) create mode 100644 test/network_tests/lazy_load_tests/CMakeLists.txt create mode 100644 test/network_tests/lazy_load_tests/conf/lazy_load_test_config.json.in create mode 100644 test/network_tests/lazy_load_tests/conf/vsomeip_policy_extensions.json.in create mode 100644 test/network_tests/lazy_load_tests/extensions/1_1/vsomeip_security.json create mode 100644 test/network_tests/lazy_load_tests/lazy_load_test_client.cpp create mode 100644 test/network_tests/lazy_load_tests/lazy_load_test_client.hpp create mode 100644 test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.cpp create mode 100644 test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.hpp create mode 100644 test/network_tests/lazy_load_tests/lazy_load_test_service.cpp create mode 100644 test/network_tests/lazy_load_tests/lazy_load_test_service.hpp create mode 100755 test/network_tests/lazy_load_tests/lazy_load_test_start.sh create mode 100644 test/network_tests/lazy_load_tests/readme diff --git a/.gitignore b/.gitignore index c219dacda..a40692934 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,8 @@ /test/network_tests/big_payload_tests/big_payload_test_tcp_service_queue_limited_specific.json /test/network_tests/big_payload_tests/big_payload_test_udp_client.json /test/network_tests/big_payload_tests/big_payload_test_udp_service.json +/test/network_tests/lazy_load_tests/lazy_load_test_config.json +/test/network_tests/lazy_load_tests/vsomeip_policy_extensions.json /test/network_tests/magic_cookies_tests/magic_cookies_test_client.json /test/network_tests/magic_cookies_tests/magic_cookies_test_service.json /test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.json diff --git a/test/network_tests/CMakeLists.txt b/test/network_tests/CMakeLists.txt index 883cc5cf8..e016e0cf7 100644 --- a/test/network_tests/CMakeLists.txt +++ b/test/network_tests/CMakeLists.txt @@ -15,6 +15,7 @@ include_directories( set(TEST_LINK_LIBRARIES gtest) set(NETWORK_TEST_BIN_DIR ${PROJECT_BINARY_DIR}/test/network_tests) set(NETWORK_TEST_SRC_DIR ${PROJECT_SOURCE_DIR}/test/network_tests) +set(HOSTNAME "$ENV{HOSTNAME}") # Function to copy files into the build directory (or anywhere else) # On unixoid systems this function will create symlinks instead @@ -67,6 +68,7 @@ function(copy_to_builddir SOURCE_PATH DESTINATION_PATH TARGET_TO_DEPEND) endif() endfunction() +add_subdirectory(lazy_load_tests) ############################################################################## # configuration-test ############################################################################## diff --git a/test/network_tests/lazy_load_tests/CMakeLists.txt b/test/network_tests/lazy_load_tests/CMakeLists.txt new file mode 100644 index 000000000..ecfa9fa03 --- /dev/null +++ b/test/network_tests/lazy_load_tests/CMakeLists.txt @@ -0,0 +1,106 @@ +# Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +cmake_minimum_required(VERSION 3.4...3.22) + +project(lazy_load_tests LANGUAGES CXX) + +if (${TEST_SECURITY}) + if(NOT ${TESTS_BAT}) + set(LAZY_LOAD_NAME lazy_load_test) + set(LAZY_LOAD_SERVICE lazy_load_test_service) + set(LAZY_LOAD_CLIENT lazy_load_test_client) + set(LAZY_LOAD_LAZY_CLIENT lazy_load_test_lazy_client) + + add_executable(${LAZY_LOAD_SERVICE} + ${LAZY_LOAD_SERVICE}.cpp) + target_link_libraries(${LAZY_LOAD_SERVICE} + ${VSOMEIP_NAME} + ${Boost_LIBRARIES} + ${DL_LIBRARY} + ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + ) + + # Copy main config file into $BUILDDIR/test and $BUILDDIR/test/vsomeip + set(LAZY_LOAD_CONFIG_FILE ${LAZY_LOAD_NAME}_config.json) + configure_file( + ${NETWORK_TEST_SRC_DIR}/lazy_load_tests/conf/${LAZY_LOAD_CONFIG_FILE}.in + ${NETWORK_TEST_SRC_DIR}/lazy_load_tests/${LAZY_LOAD_CONFIG_FILE} + @ONLY) + copy_to_builddir( + ${NETWORK_TEST_SRC_DIR}/lazy_load_tests/${LAZY_LOAD_CONFIG_FILE} + ${NETWORK_TEST_BIN_DIR}/lazy_load_tests/vsomeip/${LAZY_LOAD_CONFIG_FILE} + ${LAZY_LOAD_SERVICE} + ) + copy_to_builddir( + ${NETWORK_TEST_SRC_DIR}/lazy_load_tests/${LAZY_LOAD_CONFIG_FILE} + ${NETWORK_TEST_BIN_DIR}/lazy_load_tests/${LAZY_LOAD_CONFIG_FILE} + ${LAZY_LOAD_SERVICE} + ) + + # Copy vsomeip policy extensions file for tests into $BUILDDIR/test + set(LAZY_LOAD_POLICY_EXTENSIONS vsomeip_policy_extensions.json) + configure_file( + ${NETWORK_TEST_SRC_DIR}/lazy_load_tests/conf/${LAZY_LOAD_POLICY_EXTENSIONS}.in + ${NETWORK_TEST_SRC_DIR}/lazy_load_tests/${LAZY_LOAD_POLICY_EXTENSIONS} + @ONLY) + copy_to_builddir( + ${NETWORK_TEST_SRC_DIR}/lazy_load_tests/${LAZY_LOAD_POLICY_EXTENSIONS} + ${NETWORK_TEST_BIN_DIR}/lazy_load_tests/vsomeip/${LAZY_LOAD_POLICY_EXTENSIONS} + ${LAZY_LOAD_SERVICE} + ) + + # Copy vsomeip security extension to into $BUILDDIR/test + set(LAZY_LOAD_VSOMEIP_SECURITY vsomeip_security.json) + copy_to_builddir( + ${NETWORK_TEST_SRC_DIR}/lazy_load_tests/extensions/1_1/${LAZY_LOAD_VSOMEIP_SECURITY} + ${NETWORK_TEST_BIN_DIR}/lazy_load_tests/vsomeip/vsomeip_ext/1_1/${LAZY_LOAD_VSOMEIP_SECURITY} + ${LAZY_LOAD_SERVICE} + ) + + # Copy bashscript to start local test into $BUILDDIR/test + set(LAZY_LOAD_SERVICE_START_SCRIPT ${LAZY_LOAD_NAME}_start.sh) + copy_to_builddir( + ${NETWORK_TEST_SRC_DIR}/lazy_load_tests/${LAZY_LOAD_SERVICE_START_SCRIPT} + ${NETWORK_TEST_BIN_DIR}/lazy_load_tests/${LAZY_LOAD_SERVICE_START_SCRIPT} + ${LAZY_LOAD_SERVICE} + ) + + add_executable(${LAZY_LOAD_CLIENT} + ${LAZY_LOAD_CLIENT}.cpp + ) + target_link_libraries(${LAZY_LOAD_CLIENT} + ${VSOMEIP_NAME} + ${Boost_LIBRARIES} + ${DL_LIBRARY} + ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + ) + + add_executable(${LAZY_LOAD_LAZY_CLIENT} + ${LAZY_LOAD_LAZY_CLIENT}.cpp + ) + target_link_libraries(${LAZY_LOAD_LAZY_CLIENT} + ${VSOMEIP_NAME} + ${Boost_LIBRARIES} + ${DL_LIBRARY} + ${TEST_LINK_LIBRARIES} + ${DLT_LIBRARIES} + ) + + add_test(NAME ${LAZY_LOAD_NAME} + COMMAND ${NETWORK_TEST_BIN_DIR}/lazy_load_tests/${LAZY_LOAD_SERVICE_START_SCRIPT} + ) + + add_dependencies(${LAZY_LOAD_SERVICE} gtest) + add_dependencies(${LAZY_LOAD_CLIENT} gtest) + add_dependencies(${LAZY_LOAD_LAZY_CLIENT} gtest) + + add_dependencies(build_network_tests ${LAZY_LOAD_SERVICE}) + add_dependencies(build_network_tests ${LAZY_LOAD_CLIENT}) + add_dependencies(build_network_tests ${LAZY_LOAD_LAZY_CLIENT}) + endif() +endif() diff --git a/test/network_tests/lazy_load_tests/conf/lazy_load_test_config.json.in b/test/network_tests/lazy_load_tests/conf/lazy_load_test_config.json.in new file mode 100644 index 000000000..6cfbd80d7 --- /dev/null +++ b/test/network_tests/lazy_load_tests/conf/lazy_load_test_config.json.in @@ -0,0 +1,109 @@ +{ + "unicast" : "@TEST_IP_MASTER@", + "netmask" : "255.255.255.0", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, + "dlt" : "true" + }, + "applications" : + [ + { + "name" : "service-sample", + "id" : "0x1277" + }, + { + "name" : "client-sample-normal", + "id" : "0x1255" + }, + { + "name" : "client-sample-lazy", + "id" : "0x1256" + }, + { + "name" : "routingmanagerd", + "id" : "0x1111" + } + ], + "services" : + [ + { + "service" : "0x1234", + "instance" : "0x5678", + "unicast" : "@TEST_IP_MASTER@", + "unreliable" : "30509" + }, + { + "service" : "0x111", + "instance" : "0x5678", + "unicast" : "@TEST_IP_MASTER@", + "unreliable" : "30509" + }, + { + "service" : "0x1234", + "instance" : "0x02", + "unicast" : "@TEST_IP_MASTER@", + "unreliable" : "30509" + } + ], + "security" : + { + "check_credentials" : "true", + "allow_remote_clients" : "true", + "policies" : + [ + { + "credentials" : [ + {"uid" : "@TEST_UID@", "gid" : "@TEST_GID@"} , + {"uid" : "1", "gid" : "1"} + ], + "allow" : + { + "offers": + [ + { + "service" : "0x1234", + "instances" : ["0x5678", "0x02"] + } + ] + } + }, + { + "credentials" : {"uid" : "@TEST_UID@", "gid" : "@TEST_GID@"}, + "allow" : + { + "requests": + [ + { + "service" : "0x1234", + "instances" : + [ + { + "ids" : ["0x5678"], + "methods" : [ {"first" : "0x8421", "last" : "0x8422" }, "0x8001", "0x7777" ] + } + ] + } + ] + } + } + ] + }, + "routing" : "routingmanagerd", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.0.0.1", + "port" : "30490", + "protocol" : "udp", + "initial_delay_min" : "10", + "initial_delay_max" : "100", + "repetitions_base_delay" : "200", + "repetitions_max" : "3", + "ttl" : "3", + "cyclic_offer_delay" : "2000", + "request_response_delay" : "1500" + } +} diff --git a/test/network_tests/lazy_load_tests/conf/vsomeip_policy_extensions.json.in b/test/network_tests/lazy_load_tests/conf/vsomeip_policy_extensions.json.in new file mode 100644 index 000000000..eb45c40ea --- /dev/null +++ b/test/network_tests/lazy_load_tests/conf/vsomeip_policy_extensions.json.in @@ -0,0 +1,8 @@ +{ + "container_policy_extensions": + [ + { + "container": "@HOSTNAME@", "path": "../..@NETWORK_TEST_BIN_DIR@/lazy_load_tests/vsomeip/vsomeip_ext" + } + ] +} diff --git a/test/network_tests/lazy_load_tests/extensions/1_1/vsomeip_security.json b/test/network_tests/lazy_load_tests/extensions/1_1/vsomeip_security.json new file mode 100644 index 000000000..c1b64997e --- /dev/null +++ b/test/network_tests/lazy_load_tests/extensions/1_1/vsomeip_security.json @@ -0,0 +1,27 @@ +{ + "security" : + { + "policies" : + [ + { + "credentials" : { "uid" : "1", "gid" : "1" }, + "allow" : + { + "requests": + [ + { + "service" : "0x1234", + "instances" : + [ + { + "ids" : ["0x02"], + "methods" : [ {"first" : "0x8421", "last" : "0x8422" }, "0x8002", "0x7777" ] + } + ] + } + ] + } + } + ] + } +} diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_client.cpp b/test/network_tests/lazy_load_tests/lazy_load_test_client.cpp new file mode 100644 index 000000000..13a437322 --- /dev/null +++ b/test/network_tests/lazy_load_tests/lazy_load_test_client.cpp @@ -0,0 +1,230 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "lazy_load_test_client.hpp" + +lazy_load_test_client::lazy_load_test_client() + : app_(vsomeip::runtime::get()->create_application()), + current_service_availability_status_(false), + sender_(std::bind(&lazy_load_test_client::run, this)), + received_responses_(0), + received_allowed_events_(0) {} + +bool lazy_load_test_client::init() { + if (!app_->init()) { + ADD_FAILURE() << "Couldn't initialize application"; + return false; + } + + app_->register_state_handler( + std::bind(&lazy_load_test_client::on_state, this, + std::placeholders::_1)); + + app_->register_message_handler(vsomeip::ANY_SERVICE, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, vsomeip::ANY_METHOD, + std::bind(&lazy_load_test_client::on_message, this, + std::placeholders::_1)); + + app_->register_message_handler(vsomeip::ANY_SERVICE, + TEST_INSTANCE_LAZY, vsomeip::ANY_METHOD, + std::bind(&lazy_load_test_client::on_message, this, + std::placeholders::_1)); + + app_->register_availability_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, + std::bind(&lazy_load_test_client::on_availability, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); + + app_->register_availability_handler(SERVICE_TO_BE_REFUSED, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, + std::bind(&lazy_load_test_client::on_availability, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); + + app_->register_availability_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, + TEST_INSTANCE_LAZY, + std::bind(&lazy_load_test_client::on_availability, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); + return true; +} + +void lazy_load_test_client::start() { + VSOMEIP_INFO << "Starting..."; + + app_->start(); +} + +void lazy_load_test_client::stop() { + VSOMEIP_INFO << "Stopping..."; + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + + app_->clear_all_handler(); + app_->stop(); +} + +void lazy_load_test_client::on_state(vsomeip::state_type_e _state) { + VSOMEIP_INFO << "CLIENT ON_STATE..."; + if (_state == vsomeip::state_type_e::ST_REGISTERED) { + app_->request_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, false); + + // request not allowed service ID + app_->request_service(SERVICE_TO_BE_REFUSED, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, false); + + // request not allowed instance ID + app_->request_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, + TEST_INSTANCE_LAZY, false); + + // request events of eventgroup 0x01 which holds events 0x8001 (allowed) and 0x8002 (denied) + std::set its_eventgroups; + its_eventgroups.insert(EVENT_GROUP); + + app_->request_event(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID, + static_cast(EVENT_TO_ACCEPT), + its_eventgroups, vsomeip::event_type_e::ET_FIELD, + vsomeip::reliability_type_e::RT_UNRELIABLE); + app_->request_event(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID, + static_cast(EVENT_TO_REFUSE), + its_eventgroups, vsomeip::event_type_e::ET_FIELD, + vsomeip::reliability_type_e::RT_UNRELIABLE); + + app_->subscribe(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID, EVENT_GROUP, + vsomeip::DEFAULT_MAJOR, static_cast(EVENT_TO_ACCEPT)); + + app_->subscribe(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID, EVENT_GROUP, + vsomeip::DEFAULT_MAJOR, static_cast(EVENT_TO_REFUSE)); + + } +} + +void lazy_load_test_client::on_availability(vsomeip::service_t _service, + vsomeip::instance_t _instance, bool _is_service_available) { + + VSOMEIP_INFO << "CLIENT ON_AVAILABILITY..."; + VSOMEIP_INFO << std::hex << "Client 0x" << app_->get_client() + << " : Service [" << std::setw(4) << std::setfill('0') << std::hex + << _service << '.' << _instance << "] is " + << (_is_service_available ? "available." : "NOT available."); + + // Check that only the allowed service is available + if (_is_service_available) { + EXPECT_EQ(vsomeip_test::TEST_SERVICE_SERVICE_ID, _service) + << "Unexpected Service ID on_availability"; + EXPECT_EQ(vsomeip_test::TEST_SERVICE_INSTANCE_ID, _instance) + << "Unexpected Instance ID on_availability"; + } + if (vsomeip_test::TEST_SERVICE_SERVICE_ID == _service + && vsomeip_test::TEST_SERVICE_INSTANCE_ID == _instance) { + std::unique_lock its_lock(mutex_); + if (current_service_availability_status_ && !_is_service_available) { + current_service_availability_status_ = false; + } else if (_is_service_available && !current_service_availability_status_) { + current_service_availability_status_ = true; + condition_.notify_one(); + } + } +} + +void lazy_load_test_client::on_message(const std::shared_ptr &_response) { + VSOMEIP_INFO << "Received a response from Service [" + << std::setw(4) << std::setfill('0') << std::hex << _response->get_service() + << '.' + << std::setw(4) << std::setfill('0') << std::hex << _response->get_instance() + << "] to Client/Session [" + << std::setw(4) << std::setfill('0') << std::hex << _response->get_client() + << '/' + << std::setw(4) << std::setfill('0') << std::hex << _response->get_session() + << ']'; + + if (_response->get_message_type() == vsomeip::message_type_e::MT_RESPONSE) { + EXPECT_EQ(vsomeip_test::TEST_SERVICE_SERVICE_ID, _response->get_service()) + << "Unexpected Service ID on_message response"; + EXPECT_EQ(vsomeip_test::TEST_SERVICE_INSTANCE_ID, _response->get_instance()) + << "Unexpected Instance ID on_message response"; + EXPECT_EQ(vsomeip_test::TEST_SERVICE_METHOD_ID, _response->get_method()) + << "Unexpected Method ID on_message response"; + + + if (_response->get_service() == vsomeip_test::TEST_SERVICE_SERVICE_ID && + _response->get_instance() == vsomeip_test::TEST_SERVICE_INSTANCE_ID && + _response->get_method() == vsomeip_test::TEST_SERVICE_METHOD_ID) { + received_responses_++; + if (received_responses_ == NUMBER_OF_MESSAGES_TO_SEND) { + VSOMEIP_WARNING << std::hex << app_->get_client() + << ": Received all messages ~> going down!"; + } + } + + } else if (_response->get_message_type() == vsomeip::message_type_e::MT_NOTIFICATION) { + + // check that only allowed event 0x8001 is received for client-sample-a + EXPECT_EQ(vsomeip_test::TEST_SERVICE_SERVICE_ID, _response->get_service()) + << "Unexpected Service ID on_message notification"; + EXPECT_EQ(vsomeip_test::TEST_SERVICE_INSTANCE_ID, _response->get_instance()) + << "Unexpected Instance ID on_message notification"; + EXPECT_EQ(EVENT_TO_ACCEPT, _response->get_method()) + << "Unexpected Method ID on_message notification"; + + received_allowed_events_++; + } +} + +void lazy_load_test_client::run() { + for (std::uint32_t i = 0; i < NUMBER_OF_MESSAGES_TO_SEND; ++i) { + { + std::unique_lock its_lock(mutex_); + while (!current_service_availability_status_) { + condition_.wait(its_lock); + } + } + + auto request = vsomeip::runtime::get()->create_request(false); + + request->set_service(vsomeip_test::TEST_SERVICE_SERVICE_ID); + request->set_instance(vsomeip_test::TEST_SERVICE_INSTANCE_ID); + request->set_method(vsomeip_test::TEST_SERVICE_METHOD_ID); + + // send a request which is allowed by policy -> expect answer + app_->send(request); + + // send a request with a not allowed method ID -> expect no answer + request->set_method(METHOD_TO_BE_REFUSED); + app_->send(request); + + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + } + + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + + EXPECT_EQ(NUMBER_OF_MESSAGES_TO_SEND, received_responses_) + << "Unexpected received_responses_ run()"; + EXPECT_EQ(received_allowed_events_, static_cast(EXPECTED_EVENTS)) + << "Unexpected received_allowed_events run()"; + + stop(); +} + +void lazy_load_test_client::join_sender_thread() { + if (sender_.joinable()) { + sender_.join(); + } +} + +TEST(someip_lazy_load_test, normal_client) { + lazy_load_test_client test_client; + if (test_client.init()) { + test_client.start(); + test_client.join_sender_thread(); + } +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_client.hpp b/test/network_tests/lazy_load_tests/lazy_load_test_client.hpp new file mode 100644 index 000000000..245ac1f2f --- /dev/null +++ b/test/network_tests/lazy_load_tests/lazy_load_test_client.hpp @@ -0,0 +1,61 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef LAZY_LOAD_TEST_CLIENT_HPP +#define LAZY_LOAD_TEST_CLIENT_HPP + +#include +#include +#include +#include + +#include +#include + +#include "../someip_test_globals.hpp" + +class lazy_load_test_client { +public: + lazy_load_test_client(); + bool init(); + void start(); + void stop(); + + void on_state(vsomeip::state_type_e _state); + void on_availability(vsomeip::service_t _service, + vsomeip::instance_t _instance, bool _is_available); + void on_message(const std::shared_ptr &_response); + + void run(); + void join_sender_thread(); + +private: + void shutdown_service(); + + std::shared_ptr app_; + + std::mutex mutex_; + std::condition_variable condition_; + bool current_service_availability_status_; + + std::thread sender_; + + std::atomic received_responses_; + std::atomic received_allowed_events_; + + const std::uint16_t METHOD_TO_BE_REFUSED = 0x888; + const std::uint16_t SERVICE_TO_BE_REFUSED = 0x111; + const std::uint16_t TEST_INSTANCE_LAZY = 0x02; + const std::uint16_t EXPECTED_EVENTS = 0x01; + + const std::uint16_t EVENT_GROUP = 0x01; + const std::uint16_t EVENT_TO_ACCEPT = 0x8001; + const std::uint16_t EVENT_TO_REFUSE = 0x8002; + + const std::uint16_t NUMBER_OF_MESSAGES_TO_SEND = 10; + +}; + +#endif // LAZY_LOAD_TEST_CLIENT_HPP diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.cpp b/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.cpp new file mode 100644 index 000000000..5ab81f1f2 --- /dev/null +++ b/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.cpp @@ -0,0 +1,240 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "lazy_load_test_lazy_client.hpp" + +lazy_load_lazy_client::lazy_load_lazy_client() + : app_(vsomeip::runtime::get()->create_application()), + current_service_availability_status_(false), + sender_(std::bind(&lazy_load_lazy_client::run, this)), + received_responses_(0), + received_allowed_events_(0) {} + +bool lazy_load_lazy_client::init() { + if (!app_->init()) { + ADD_FAILURE() << "Couldn't initialize application"; + return false; + } + + app_->register_state_handler( + std::bind(&lazy_load_lazy_client::on_state, this, + std::placeholders::_1)); + + app_->register_message_handler(vsomeip::ANY_SERVICE, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, vsomeip::ANY_METHOD, + std::bind(&lazy_load_lazy_client::on_message, this, + std::placeholders::_1)); + + app_->register_message_handler(vsomeip::ANY_SERVICE, + TEST_INSTANCE_LAZY, vsomeip::ANY_METHOD, + std::bind(&lazy_load_lazy_client::on_message, this, + std::placeholders::_1)); + + app_->register_availability_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, + std::bind(&lazy_load_lazy_client::on_availability, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); + + app_->register_availability_handler(SERVICE_TO_BE_REFUSED, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, + std::bind(&lazy_load_lazy_client::on_availability, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); + + app_->register_availability_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, + TEST_INSTANCE_LAZY, + std::bind(&lazy_load_lazy_client::on_availability, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); + return true; +} + +void lazy_load_lazy_client::start() { + VSOMEIP_INFO << "Starting..."; + + app_->start(); +} + +void lazy_load_lazy_client::stop() { + VSOMEIP_INFO << "Stopping..."; + shutdown_service(); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + + app_->clear_all_handler(); + app_->stop(); +} + +void lazy_load_lazy_client::on_state(vsomeip::state_type_e _state) { + VSOMEIP_INFO << "CLIENT ON_STATE..."; + if (_state == vsomeip::state_type_e::ST_REGISTERED) { + // request not allowed instance ID + app_->request_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, false); + + // request not allowed service ID + app_->request_service(SERVICE_TO_BE_REFUSED, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, false); + + app_->request_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, + TEST_INSTANCE_LAZY, false); + + // request events of eventgroup 0x01 which holds events 0x8001 (denied) and 0x8002 (allowed) + std::set its_eventgroups; + its_eventgroups.insert(EVENT_GROUP); + + app_->request_event(vsomeip_test::TEST_SERVICE_SERVICE_ID, TEST_INSTANCE_LAZY, + static_cast(EVENT_TO_REFUSE_LAZY), + its_eventgroups, vsomeip::event_type_e::ET_FIELD, + vsomeip::reliability_type_e::RT_UNRELIABLE); + app_->request_event(vsomeip_test::TEST_SERVICE_SERVICE_ID, TEST_INSTANCE_LAZY, + static_cast(EVENT_TO_ACCEPT_LAZY), + its_eventgroups, vsomeip::event_type_e::ET_FIELD, + vsomeip::reliability_type_e::RT_UNRELIABLE); + + app_->subscribe(vsomeip_test::TEST_SERVICE_SERVICE_ID, TEST_INSTANCE_LAZY, EVENT_GROUP, + vsomeip::DEFAULT_MAJOR, static_cast(EVENT_TO_REFUSE_LAZY)); + + app_->subscribe(vsomeip_test::TEST_SERVICE_SERVICE_ID, TEST_INSTANCE_LAZY, EVENT_GROUP, + vsomeip::DEFAULT_MAJOR, static_cast(EVENT_TO_ACCEPT_LAZY)); + } +} + +void lazy_load_lazy_client::on_availability(vsomeip::service_t _service, + vsomeip::instance_t _instance, bool _is_service_available) { + + VSOMEIP_INFO << "CLIENT ON_AVAILABILITY..."; + VSOMEIP_INFO << std::hex << "Client 0x" << app_->get_client() + << " : Service [" << std::setw(4) << std::setfill('0') << std::hex + << _service << '.' << _instance << "] is " + << (_is_service_available ? "available." : "NOT available."); + + // Check that only the allowed service is available + if (_is_service_available) { + EXPECT_EQ(vsomeip_test::TEST_SERVICE_SERVICE_ID, _service) + << "Unexpected Service ID on_available"; + EXPECT_EQ(TEST_INSTANCE_LAZY, _instance) + << "Unexpected Instance ID on_available"; + } + + if (vsomeip_test::TEST_SERVICE_SERVICE_ID == _service + && TEST_INSTANCE_LAZY == _instance) { + std::unique_lock its_lock(mutex_); + if (current_service_availability_status_ && !_is_service_available) { + current_service_availability_status_ = false; + } else if (_is_service_available && !current_service_availability_status_) { + current_service_availability_status_ = true; + condition_.notify_one(); + } + } + +} + +void lazy_load_lazy_client::on_message(const std::shared_ptr &_response) { + VSOMEIP_INFO << "Received a response from Service [" + << std::setw(4) << std::setfill('0') << std::hex << _response->get_service() + << '.' + << std::setw(4) << std::setfill('0') << std::hex << _response->get_instance() + << "] to Client/Session [" + << std::setw(4) << std::setfill('0') << std::hex << _response->get_client() + << '/' + << std::setw(4) << std::setfill('0') << std::hex << _response->get_session() + << ']'; + + if (_response->get_message_type() == vsomeip::message_type_e::MT_RESPONSE) { + EXPECT_EQ(vsomeip_test::TEST_SERVICE_SERVICE_ID, _response->get_service()) + << "Unexpected Service ID on_message response"; + EXPECT_EQ(TEST_INSTANCE_LAZY, _response->get_instance()) + << "Unexpected Instance ID on_message response"; + EXPECT_EQ(vsomeip_test::TEST_SERVICE_METHOD_ID, _response->get_method()) + << "Unexpected Method ID on_message response"; + + + if (_response->get_service() == vsomeip_test::TEST_SERVICE_SERVICE_ID && + _response->get_method() == vsomeip_test::TEST_SERVICE_METHOD_ID) { + received_responses_++; + if (received_responses_ == NUMBER_OF_MESSAGES_TO_SEND) { + VSOMEIP_WARNING << std::hex << app_->get_client() + << ": Received all messages ~> going down!"; + } + } + + } else if (_response->get_message_type() == vsomeip::message_type_e::MT_NOTIFICATION) { + + // check that only allowed event 0x8002 is received for client-sample-lazy + EXPECT_EQ(vsomeip_test::TEST_SERVICE_SERVICE_ID, _response->get_service()) + << "Unexpected Service ID on_message notification"; + EXPECT_EQ(TEST_INSTANCE_LAZY, _response->get_instance()) + << "Unexpected Instance ID on_message notification"; + EXPECT_EQ(EVENT_TO_ACCEPT_LAZY, _response->get_method()) + << "Unexpected Method ID on_message notification"; + received_allowed_events_++; + } +} + +void lazy_load_lazy_client::run() { + for (std::uint32_t i = 0; i < NUMBER_OF_MESSAGES_TO_SEND; ++i) { + { + std::unique_lock its_lock(mutex_); + while (!current_service_availability_status_) { + condition_.wait(its_lock); + } + } + + auto request = vsomeip::runtime::get()->create_request(false); + + request->set_service(vsomeip_test::TEST_SERVICE_SERVICE_ID); + request->set_instance(TEST_INSTANCE_LAZY); + request->set_method(vsomeip_test::TEST_SERVICE_METHOD_ID); + + + // send a request which is allowed by policy -> expect answer + app_->send(request); + + // send a request with a not allowed method ID -> expect no answer + request->set_method(METHOD_TO_BE_REFUSED); + app_->send(request); + + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + } + + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + + EXPECT_EQ(NUMBER_OF_MESSAGES_TO_SEND,received_responses_) + << "Unexpected received_responses_ run"; + EXPECT_EQ(received_allowed_events_, static_cast(EXPECTED_EVENTS)) + << "Unexpected received_allowed_events_ run"; + + stop(); +} + +void lazy_load_lazy_client::join_sender_thread() { + if (sender_.joinable()) { + sender_.join(); + } +} + +void lazy_load_lazy_client::shutdown_service() { + VSOMEIP_INFO << "SHUTDOWN_SERVICE called from LAZY client"; + auto request = vsomeip::runtime::get()->create_request(false); + request->set_service(vsomeip_test::TEST_SERVICE_SERVICE_ID); + request->set_instance(TEST_INSTANCE_LAZY); + request->set_method(vsomeip_test::TEST_SERVICE_METHOD_ID_SHUTDOWN); + app_->send(request); +} + +TEST(someip_lazy_load_test, lazy_client) { + lazy_load_lazy_client test_lazy_client; + if (test_lazy_client.init()) { + test_lazy_client.start(); + test_lazy_client.join_sender_thread(); + } +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.hpp b/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.hpp new file mode 100644 index 000000000..0d8aaadb6 --- /dev/null +++ b/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.hpp @@ -0,0 +1,60 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef LAZY_LOAD_TEST_LAZY_CLIENT_HPP +#define LAZY_LOAD_TEST_LAZY_CLIENT_HPP + +#include +#include +#include +#include + +#include +#include + +#include "../someip_test_globals.hpp" + +class lazy_load_lazy_client { +public: + lazy_load_lazy_client(); + bool init(); + void start(); + void stop(); + + void on_state(vsomeip::state_type_e _state); + void on_availability(vsomeip::service_t _service, + vsomeip::instance_t _instance, bool _is_available); + void on_message(const std::shared_ptr &_response); + + void run(); + void join_sender_thread(); + +private: + void shutdown_service(); + + std::shared_ptr app_; + + std::mutex mutex_; + std::condition_variable condition_; + bool current_service_availability_status_; + + std::thread sender_; + + std::atomic received_responses_; + std::atomic received_allowed_events_; + + const std::uint16_t METHOD_TO_BE_REFUSED = 0x888; + const std::uint16_t SERVICE_TO_BE_REFUSED = 0x111; + const std::uint16_t TEST_INSTANCE_LAZY = 0x02; + const std::uint16_t EXPECTED_EVENTS = 0x01; + + const std::uint16_t EVENT_GROUP = 0x01; + const std::uint16_t EVENT_TO_ACCEPT_LAZY = 0x8002; + const std::uint16_t EVENT_TO_REFUSE_LAZY = 0x8001; + + const std::uint16_t NUMBER_OF_MESSAGES_TO_SEND = 10; +}; + +#endif // LAZY_LOAD_TEST_LAZY_CLIENT_HPP diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_service.cpp b/test/network_tests/lazy_load_tests/lazy_load_test_service.cpp new file mode 100644 index 000000000..935f51101 --- /dev/null +++ b/test/network_tests/lazy_load_tests/lazy_load_test_service.cpp @@ -0,0 +1,195 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "lazy_load_test_service.hpp" + +lazy_load_test_service::lazy_load_test_service() : + app_(vsomeip::runtime::get()->create_application()), + is_registered_(false), + blocked_(false), + number_of_received_messages_(0), + offer_thread_(std::bind(&lazy_load_test_service::run, this)) {} + +bool lazy_load_test_service::init() { + std::lock_guard its_lock(mutex_); + + if (!app_->init()) { + ADD_FAILURE() << "Couldn't initialize application"; + return false; + } + app_->register_message_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, vsomeip_test::TEST_SERVICE_METHOD_ID, + std::bind(&lazy_load_test_service::on_message, this, + std::placeholders::_1)); + + app_->register_message_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, + TEST_INSTANCE_LAZY, + vsomeip_test::TEST_SERVICE_METHOD_ID_SHUTDOWN, + std::bind(&lazy_load_test_service::on_message_shutdown, this, + std::placeholders::_1)); + + app_->register_message_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, + TEST_INSTANCE_LAZY, + vsomeip_test::TEST_SERVICE_METHOD_ID, + std::bind(&lazy_load_test_service::on_message, this, + std::placeholders::_1)); + + app_->register_state_handler( + std::bind(&lazy_load_test_service::on_state, this, + std::placeholders::_1)); + + // offer eventgroup 0x01 + std::set its_eventgroups; + its_eventgroups.insert(EVENT_GROUP); + + app_->offer_event(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID, + static_cast(EVENT_TO_ACCEPT_DEFAULT), its_eventgroups, + vsomeip::event_type_e::ET_FIELD, std::chrono::milliseconds::zero(), + false, true, nullptr, vsomeip::reliability_type_e::RT_UNRELIABLE); + + // also offer field 0x8002 which is not allowed to be received by client + app_->offer_event(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID, + static_cast(EVENT_TO_ACCEPT_LAZY), its_eventgroups, + vsomeip::event_type_e::ET_FIELD, std::chrono::milliseconds::zero(), + false, true, nullptr, vsomeip::reliability_type_e::RT_UNRELIABLE); + + // Used with lazy client also offer field 0x8001 which is not allowed to be received by lazy client + app_->offer_event(vsomeip_test::TEST_SERVICE_SERVICE_ID, TEST_INSTANCE_LAZY, + static_cast(EVENT_TO_ACCEPT_DEFAULT), its_eventgroups, + vsomeip::event_type_e::ET_FIELD, std::chrono::milliseconds::zero(), + false, true, nullptr, vsomeip::reliability_type_e::RT_UNRELIABLE); + + app_->offer_event(vsomeip_test::TEST_SERVICE_SERVICE_ID, TEST_INSTANCE_LAZY, + static_cast(EVENT_TO_ACCEPT_LAZY), its_eventgroups, + vsomeip::event_type_e::ET_FIELD, std::chrono::milliseconds::zero(), + false, true, nullptr, vsomeip::reliability_type_e::RT_UNRELIABLE); + + // set value to fields + std::shared_ptr its_payload = + vsomeip::runtime::get()->create_payload(); + vsomeip::byte_t its_data[2]{ + static_cast((vsomeip_test::TEST_SERVICE_SERVICE_ID & 0xFF00) >> 8), + static_cast((vsomeip_test::TEST_SERVICE_SERVICE_ID & 0xFF)) + }; + its_payload->set_data(its_data, 2); + + app_->notify(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID, + static_cast(EVENT_TO_ACCEPT_DEFAULT), its_payload); + + app_->notify(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID, + static_cast(EVENT_TO_ACCEPT_LAZY), its_payload); + + app_->notify(vsomeip_test::TEST_SERVICE_SERVICE_ID, TEST_INSTANCE_LAZY, + static_cast(EVENT_TO_ACCEPT_DEFAULT), its_payload); + + app_->notify(vsomeip_test::TEST_SERVICE_SERVICE_ID, TEST_INSTANCE_LAZY, + static_cast(EVENT_TO_ACCEPT_LAZY), its_payload); + + return true; +} + +void lazy_load_test_service::start() { + VSOMEIP_INFO << "Starting..."; + app_->start(); +} + +void lazy_load_test_service::stop() { + VSOMEIP_INFO << "Stopping..."; + stop_offer(); + app_->clear_all_handler(); + app_->stop(); +} + +void lazy_load_test_service::join_offer_thread() { + if (offer_thread_.joinable()) { + offer_thread_.join(); + } +} + +void lazy_load_test_service::offer() { + // Instance used by client a + app_->offer_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID); + + // Instance used by client b + app_->offer_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, TEST_INSTANCE_LAZY); + + // try to offer a not allowed service ID 0x111 (client requesting the service should not get available) + app_->offer_service(SERVICE_TO_BE_REFUSED, vsomeip_test::TEST_SERVICE_INSTANCE_ID); +} + +void lazy_load_test_service::stop_offer() { + app_->stop_offer_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID); + app_->stop_offer_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, TEST_INSTANCE_LAZY); +} + +void lazy_load_test_service::on_state(vsomeip::state_type_e _state) { + VSOMEIP_INFO << "Application " << app_->get_name() << " is " + << (_state == vsomeip::state_type_e::ST_REGISTERED ? "registered." : + "deregistered."); + + if (_state == vsomeip::state_type_e::ST_REGISTERED) { + if (!is_registered_) { + is_registered_ = true; + std::lock_guard its_lock(mutex_); + blocked_ = true; + // "start" the run method thread + condition_.notify_one(); + } + } else { + is_registered_ = false; + } +} + +void lazy_load_test_service::on_message(const std::shared_ptr& _request) { + ASSERT_EQ(vsomeip_test::TEST_SERVICE_SERVICE_ID, _request->get_service()); + ASSERT_EQ(vsomeip_test::TEST_SERVICE_METHOD_ID, _request->get_method()); + + VSOMEIP_INFO << "Received a message with Client/Session [" << std::setw(4) + << std::setfill('0') << std::hex << _request->get_client() << '/' + << std::setw(4) << std::setfill('0') << std::hex + << _request->get_session() << "] method: " << _request->get_method() + << " Instance ID: " << _request->get_instance(); + + // send response + std::shared_ptr its_response = + vsomeip::runtime::get()->create_response(_request); + + VSOMEIP_INFO << "service on_message response service : " << its_response->get_service(); + app_->send(its_response); + + number_of_received_messages_++; + if (number_of_received_messages_ == NUMBER_OF_MESSAGES_TO_RECEIVE) { + VSOMEIP_INFO << "Received all messages!"; + } +} + +void lazy_load_test_service::on_message_shutdown( + const std::shared_ptr&) { + VSOMEIP_INFO << "Shutdown method was called, going down now."; + stop(); +} + +void lazy_load_test_service::run() { + std::unique_lock its_lock(mutex_); + while (!blocked_) + condition_.wait(its_lock); + + offer(); +} + +TEST(someip_lazy_load_test, service) { + lazy_load_test_service test_service; + if (test_service.init()) { + test_service.start(); + test_service.join_offer_thread(); + } +} + +#ifdef __linux__ +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} +#endif diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_service.hpp b/test/network_tests/lazy_load_tests/lazy_load_test_service.hpp new file mode 100644 index 000000000..fa347b509 --- /dev/null +++ b/test/network_tests/lazy_load_tests/lazy_load_test_service.hpp @@ -0,0 +1,53 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef LAZY_LOAD_TEST_SERVICE_HPP +#define LAZY_LOAD_TEST_SERVICE_HPP + +#include +#include +#include + +#include +#include + +#include "../someip_test_globals.hpp" + +class lazy_load_test_service { +public: + lazy_load_test_service(); + bool init(); + void start(); + void stop(); + void offer(); + void stop_offer(); + void join_offer_thread(); + void on_state(vsomeip::state_type_e _state); + void on_message(const std::shared_ptr &_request); + void on_message_shutdown(const std::shared_ptr &_request); + void run(); + +private: + std::shared_ptr app_; + bool is_registered_; + + std::mutex mutex_; + std::condition_variable condition_; + bool blocked_; + std::uint32_t number_of_received_messages_; + std::thread offer_thread_; + + const std::uint16_t SERVICE_TO_BE_REFUSED = 0x111; + const std::uint16_t TEST_INSTANCE_LAZY = 0x02; + + const std::uint16_t EVENT_GROUP = 0x01; + const std::uint16_t EVENT_TO_ACCEPT_LAZY = 0x8002; + const std::uint16_t EVENT_TO_ACCEPT_DEFAULT = 0x8001; + + // Twice as big as messages to send, account for all messages from both clients + const std::uint16_t NUMBER_OF_MESSAGES_TO_RECEIVE = 20; +}; + +#endif // LAZY_LOAD_TEST_SERVICE_HPP diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_start.sh b/test/network_tests/lazy_load_tests/lazy_load_test_start.sh new file mode 100755 index 000000000..6a3b3381d --- /dev/null +++ b/test/network_tests/lazy_load_tests/lazy_load_test_start.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Copyright (C) 2015-2018 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Purpose: This script is needed to start the services with +# one command. This is necessary as ctest - which is used to run the +# tests - isn't able to start multiple binaries for one testcase. Therefore +# the testcase simply executes this script. This script then runs the services +# and checks that all exit successfully. + +export VSOMEIP_CONFIGURATION=/vsomeip/ +export VSOMEIP_APPLICATION_NAME=routingmanagerd +# start daemon +../../../examples/routingmanagerd/routingmanagerd & +PID_VSOMEIPD=$! + +sleep 1 + +export VSOMEIP_APPLICATION_NAME=service-sample +./lazy_load_test_service & + +sleep 1 + +export VSOMEIP_CONFIGURATION=lazy_load_test_service_config.json +export VSOMEIP_APPLICATION_NAME=client-sample_normal +./lazy_load_test_client & + +sleep 2 + +export VSOMEIP_CONFIGURATION=/vsomeip/ +export VSOMEIP_APPLICATION_NAME=client-sample-lazy +# start lazy client with linux user id 1 and group id 1 to use the 1_1 folder in extensions +setpriv --reuid=1 --regid=1 --clear-groups ./lazy_load_test_lazy_client + +sleep 1 + +kill $PID_VSOMEIPD +wait $PID_VSOMEIPD diff --git a/test/network_tests/lazy_load_tests/readme b/test/network_tests/lazy_load_tests/readme new file mode 100644 index 000000000..e58f99bba --- /dev/null +++ b/test/network_tests/lazy_load_tests/readme @@ -0,0 +1,112 @@ +Lazy Load Test + +Quick description: + +client-sample-normal: communicates with service id 0x1234, instance id 0x5678 without utilizing lazy loading. +client-sample-lazy: communicates with service id 0x1234, instance id 0x02. + +During the test registrations are made to the 0x01 eventgroup for both cases. +the normal client expects to receive the event 0x8001 while the lazy client expects the 0x8002 event. + +Multiple messages are then sent to the 0x8421, and the 0x888 methods of the respective service/instance for each test. Only responses from 0x8421 are expected. + +Details: + +Configs +The lazy load tests consists of 3 config jsons. +Two are configured json.in files, one is a direct json. + +-The lazy_load_test_config.json.in contains the basic app information: + --logging + + default configs + + --applications + + This tests uses 4 applications + "service-sample", "id" : "0x1277" runs the service app and will receive the requests from the clients + "client-sample-normal", "id" : "0x1255" client normal + "client-sample-lazy", "id" : "0x1256" client lazy + "routingmanagerd", "id" : "0x1111" in charge of the routing + + --services + + the list of services to be used in the app + service : "0x1234" holds 2 instance 0x5678 to interact with client a and 0x02 lazy client + service : "0x111" a dummy service which will not be permitted to be offered by policies + + --security: + + The security policy included in this json has the check_credentials set to true to enable the security feature to use Linux UserId and GroupId as credentials. + it always includes a policy that enables the offers of the service 0x1234 instances 0x5678 and 0x02 for the given credentials 0 0 and 1 1 + And holds the request part of the 0 0 credential (client sample) + + The request part of the security for lazy client is loaded subsequently by lazy loading + + --routing + + Routing will be handled by the routingmanagerd app + + --service discovery + default configs + +-The vsomeip_policy_extensions.json.in contains the container_policy_extensions which is a key value pair of the host container to the path of the vsomeip_security.json + +-The vsomeip_security.json contains the security policy for the requests allowed to credentials 1 1 (client-sample-lazy) + + + +The test + +Routingmanagerd app + The routingmanagerd app is brought up using the /vsomeip/ folder as its VSOMEIP_CONFIGURATION + Forcing it to parse the entire folder, and load the lazy_load_test_config.json + as well as the vsomeip_policy_extenions.json + The routingmanagerd is the routing manager and will handle communications between vsomeip apps. + +Service-sample app + The service-sample app is brought up using the same path as the routingmanagerd app. + The service-sample app offers 3 services + service 0x1234, instance 0x5678 (instance to interact with client-sample-normal due to security) + service 0x1234, instance 0x02 (instance to interact with client-sample-lazy due to security) + service 0x111, instance 0x5678 (dummy services offered, to be denied by security policies) + + The service 0x1234 + Contains an eventgroup 0x01 which has two offered events 0x8001 and 0x8002 + Both those events are populated with the payload 1234 and notified + Shutdown method 0x7777, used to shutdown the whole app + Method TEST_SERVICE_METHOD_ID = 0x8421 the method which will receive messages from the clients + + The service 0x111 + Offered but the security policies should prohibit the offer from happening. + Expect no interactions + + The test verifies the service-sample only receives message for the 0x1234 service and 0x8421 method + +Client-sample-normal app + The client-sample-normal app is brought up using direct injection of the lazy_load_test_config.json it will not undergo the lazy load process, used and will be used as the control case in this test. + + The app is initialized, request handlers are registered. + Upon registration of the app (app_state = registered) the client will request all three services offered by the service-sample. The on_availibity handler is the same for all 3 services. And tries to subscribe to both event of the 0x1234 0x5678 eventgroup 0x01 event 0x8001 and 0x8002 + + The first step of the test is to check that only the service 0x1234 instance 0x5678 becomes available to client-sample-normal + + The second step is to verify that only the notification from 0x8001 is received + + The third and final step is to send NUMBER_OF_MESSAGES_TO_SEND (32 as of writing this read me) messages to method 0x8421 and 0x888 of 0x1234 0x02 only responses from 0x8421 are expected. The tests expect to receive a total of NUMBER_OF_MESSAGES_TO_SEND + +Client-sample-lazy app + The client-sample-lazy app is brought up using the /vsomeip/ folder as its VSOMEIP_CONFIGURATION + Forcing it to parse the entire folder, and load the lazy_load_test_config.json + as well as the vsomeip_policy_extenions.json as well as execute the lazy loading of the vsomeip_security.json in the /vsomeip/vsomeip_ext/1_1/ folder + client-sample-lazy is the test case for lazy loading. + client-sample-lazy uses linux user-id uid: 1 and group-id gid: 1 + + The app is initialized, request handlers are registered. + Upon registration of the app (app_state = registered) the client will request all three services offered by the service-sample. The on_availibity handler is the same for all 3 services. And tries to subscribe to both event of the 0x1234 0x02 eventgroup 0x01 event 0x8001 and 0x8002 + + The first step of the test is to check that only the service 0x1234 instance 0x02 becomes available to client-sample-lazy + + The second step is to verify that only the notification from 0x8002 is received + + The third and final step is to send NUMBER_OF_MESSAGES_TO_SEND messages to method 0x8421 and 0x888 of 0x1234 0x02 only responses from 0x8421 are expected. The tests expect to receive a total of NUMBER_OF_MESSAGES_TO_SEND From 8bf7f8d053bd6753d1c2d0082b91e11cef21b6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 09:23:07 +0100 Subject: [PATCH 02/20] Test - Processing SD messages with unknown type option --- .gitignore | 2 + test/common/CMakeLists.txt | 2 + test/common/someip_lib/CMakeLists.txt | 9 + .../someip_lib/communication/CMakeLists.txt | 39 +++ .../communication/include/com/comcommon.hpp | 15 ++ .../include/com/comconstants.hpp | 29 +++ .../communication/include/com/comutils.hpp | 47 ++++ .../someip_lib/communication/src/comutils.cpp | 46 ++++ .../someip_lib/serialization/CMakeLists.txt | 33 +++ .../serialization/dynamicbytearraypayload.hpp | 103 ++++++++ .../include/serialization/fragmentpayload.hpp | 132 ++++++++++ .../include/serialization/podpayload.hpp | 104 ++++++++ .../include/serialization/serializable.hpp | 59 +++++ .../serialization/staticbytearraypayload.hpp | 148 +++++++++++ .../include/serialization/streampayload.hpp | 164 ++++++++++++ .../src/dynamicbytearraypayload.cpp | 117 +++++++++ test/common/someip_lib/someip/CMakeLists.txt | 46 ++++ .../someip/sd/options/ipv4endpointoption.hpp | 75 ++++++ .../someip/include/someip/sd/someipsd.hpp | 125 +++++++++ .../include/someip/sd/someipsdentries.hpp | 22 ++ .../someip/sd/someipsdentriesarray.hpp | 210 +++++++++++++++ .../include/someip/sd/someipsdentry.hpp | 137 ++++++++++ .../include/someip/sd/someipsdoption.hpp | 137 ++++++++++ .../include/someip/sd/someipsdoptions.hpp | 22 ++ .../someip/include/someip/someipmessage.hpp | 198 ++++++++++++++ .../include/someip/types/primitives.hpp | 91 +++++++ .../src/sd/options/ipv4endpointoption.cpp | 126 +++++++++ .../someip_lib/someip/src/sd/someipsd.cpp | 207 +++++++++++++++ .../someip/src/sd/someipsdentry.cpp | 225 ++++++++++++++++ .../someip/src/sd/someipsdoption.cpp | 71 +++++ .../someip_lib/someip/src/someipmessage.cpp | 244 ++++++++++++++++++ test/common/someip_lib/utils/CMakeLists.txt | 29 +++ .../someip_lib/utils/include/utils/logger.hpp | 53 ++++ .../someip_lib/utils/include/utils/utils.hpp | 79 ++++++ test/common/someip_lib/utils/src/logger.cpp | 90 +++++++ test/common/someip_lib/utils/src/utils.cpp | 87 +++++++ test/common/src/utility.cpp | 12 +- test/common/src/vsomeip_app_utilities.cpp | 18 +- test/network_tests/CMakeLists.txt | 79 ++++++ ...unknown_sd_option_type_test_master.json.in | 55 ++++ ...n_sd_option_type_test_master_starter.sh.in | 63 +++++ .../unknown_sd_option_type_test_client.cpp | 222 ++++++++++++++++ .../unknown_sd_option_type_test_globals.hpp | 53 ++++ .../unknown_sd_option_type_test_service.cpp | 173 +++++++++++++ 44 files changed, 3978 insertions(+), 20 deletions(-) create mode 100644 test/common/someip_lib/CMakeLists.txt create mode 100644 test/common/someip_lib/communication/CMakeLists.txt create mode 100644 test/common/someip_lib/communication/include/com/comcommon.hpp create mode 100644 test/common/someip_lib/communication/include/com/comconstants.hpp create mode 100644 test/common/someip_lib/communication/include/com/comutils.hpp create mode 100644 test/common/someip_lib/communication/src/comutils.cpp create mode 100644 test/common/someip_lib/serialization/CMakeLists.txt create mode 100644 test/common/someip_lib/serialization/include/serialization/dynamicbytearraypayload.hpp create mode 100644 test/common/someip_lib/serialization/include/serialization/fragmentpayload.hpp create mode 100644 test/common/someip_lib/serialization/include/serialization/podpayload.hpp create mode 100644 test/common/someip_lib/serialization/include/serialization/serializable.hpp create mode 100644 test/common/someip_lib/serialization/include/serialization/staticbytearraypayload.hpp create mode 100644 test/common/someip_lib/serialization/include/serialization/streampayload.hpp create mode 100644 test/common/someip_lib/serialization/src/dynamicbytearraypayload.cpp create mode 100644 test/common/someip_lib/someip/CMakeLists.txt create mode 100644 test/common/someip_lib/someip/include/someip/sd/options/ipv4endpointoption.hpp create mode 100644 test/common/someip_lib/someip/include/someip/sd/someipsd.hpp create mode 100644 test/common/someip_lib/someip/include/someip/sd/someipsdentries.hpp create mode 100644 test/common/someip_lib/someip/include/someip/sd/someipsdentriesarray.hpp create mode 100644 test/common/someip_lib/someip/include/someip/sd/someipsdentry.hpp create mode 100644 test/common/someip_lib/someip/include/someip/sd/someipsdoption.hpp create mode 100644 test/common/someip_lib/someip/include/someip/sd/someipsdoptions.hpp create mode 100644 test/common/someip_lib/someip/include/someip/someipmessage.hpp create mode 100644 test/common/someip_lib/someip/include/someip/types/primitives.hpp create mode 100644 test/common/someip_lib/someip/src/sd/options/ipv4endpointoption.cpp create mode 100644 test/common/someip_lib/someip/src/sd/someipsd.cpp create mode 100644 test/common/someip_lib/someip/src/sd/someipsdentry.cpp create mode 100644 test/common/someip_lib/someip/src/sd/someipsdoption.cpp create mode 100644 test/common/someip_lib/someip/src/someipmessage.cpp create mode 100644 test/common/someip_lib/utils/CMakeLists.txt create mode 100644 test/common/someip_lib/utils/include/utils/logger.hpp create mode 100644 test/common/someip_lib/utils/include/utils/utils.hpp create mode 100644 test/common/someip_lib/utils/src/logger.cpp create mode 100644 test/common/someip_lib/utils/src/utils.cpp create mode 100644 test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master.json.in create mode 100755 test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master_starter.sh.in create mode 100644 test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_client.cpp create mode 100644 test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_globals.hpp create mode 100644 test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_service.cpp diff --git a/.gitignore b/.gitignore index a40692934..25e0b35d2 100644 --- a/.gitignore +++ b/.gitignore @@ -149,6 +149,8 @@ /test/network_tests/security_tests/security_test_local_config.json /test/network_tests/pending_subscription_tests/pending_subscription_test_master.json /test/network_tests/pending_subscription_tests/pending_subscription_test_master_starter.sh +/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_master.json +/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_master_starter.sh /test/network_tests/malicious_data_tests/malicious_data_test_master.json /test/network_tests/malicious_data_tests/malicious_data_test_master_starter.sh /test/network_tests/e2e_tests/e2e_profile_04_test_client_external.json diff --git a/test/common/CMakeLists.txt b/test/common/CMakeLists.txt index d4d145347..b66fe3c6a 100644 --- a/test/common/CMakeLists.txt +++ b/test/common/CMakeLists.txt @@ -3,6 +3,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +add_subdirectory(someip_lib) + project (vsomeip_utilities) # ---------------------------------------------------------------------------- diff --git a/test/common/someip_lib/CMakeLists.txt b/test/common/someip_lib/CMakeLists.txt new file mode 100644 index 000000000..ad80961b0 --- /dev/null +++ b/test/common/someip_lib/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +add_subdirectory(utils) +add_subdirectory(serialization) +add_subdirectory(communication) +add_subdirectory(someip) diff --git a/test/common/someip_lib/communication/CMakeLists.txt b/test/common/someip_lib/communication/CMakeLists.txt new file mode 100644 index 000000000..1b68644f9 --- /dev/null +++ b/test/common/someip_lib/communication/CMakeLists.txt @@ -0,0 +1,39 @@ +# Copyright (C) 2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +project (communication) + +# ---------------------------------------------------------------------------- +# Include all source files (cpp/hpp) +# ---------------------------------------------------------------------------- +file (GLOB SRC src/*.cpp src/*.hpp) +file (GLOB INC include/*.hpp include/com/*.hpp) + +# ---------------------------------------------------------------------------- +# Declare the library +# ---------------------------------------------------------------------------- +add_library ( + ${PROJECT_NAME} SHARED + ${SRC} + ${INC} +) + +target_link_libraries ( + ${PROJECT_NAME} + PUBLIC + ${BOOST_LIBS} + utils + serialization +) + +# ---------------------------------------------------------------------------- +# Specify here the include directories exported +# by this library +# ---------------------------------------------------------------------------- +target_include_directories ( + ${PROJECT_NAME} + PUBLIC include + PRIVATE src +) diff --git a/test/common/someip_lib/communication/include/com/comcommon.hpp b/test/common/someip_lib/communication/include/com/comcommon.hpp new file mode 100644 index 000000000..50c2063f2 --- /dev/null +++ b/test/common/someip_lib/communication/include/com/comcommon.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __COMCOMMON_HPP__ +#define __COMCOMMON_HPP__ + +#include + +// Namespace aliasing +// In preparation for future STL's Networking TS implementation switch, if needed... +namespace asio = boost::asio; + +#endif // __COMCOMMON_HPP__ diff --git a/test/common/someip_lib/communication/include/com/comconstants.hpp b/test/common/someip_lib/communication/include/com/comconstants.hpp new file mode 100644 index 000000000..2df812dc5 --- /dev/null +++ b/test/common/someip_lib/communication/include/com/comconstants.hpp @@ -0,0 +1,29 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __COMCONSTANTS_HPP__ +#define __COMCONSTANTS_HPP__ + +#include + +namespace vsomeip_utilities { +namespace com { + +/** + * @brief Message terminator string + * + */ +constexpr std::string_view MSG_TERMINATOR = { "\n" }; + +/** + * @brief Default message buffer size + * + */ +constexpr int DEFAULT_BUFFER_SIZE = 4096; + +} // com +} // vsomeip_utilities + +#endif // __COMCONSTANTS_HPP__ diff --git a/test/common/someip_lib/communication/include/com/comutils.hpp b/test/common/someip_lib/communication/include/com/comutils.hpp new file mode 100644 index 000000000..fdfbfa518 --- /dev/null +++ b/test/common/someip_lib/communication/include/com/comutils.hpp @@ -0,0 +1,47 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __COMUTILS_HPP__ +#define __COMUTILS_HPP__ + +#include + +#include + +namespace vsomeip_utilities { +namespace com { +namespace utils { + +/** + * @brief Convert string into an asio::ip::address_v4 + * + * @param _addr String address + * @param _ec resulting error code + * @return asio::ip::address_v4 + */ +asio::ip::address_v4 ipv4AddressFromString(const std::string& _addr, std::error_code& _ec); + +/** + * @brief Convert string into an asio::ip::address_v6 + * + * @param _addr String address + * @param _ec resulting error code + * @return asio::ip::address_v6 + */ +asio::ip::address_v6 ipv6AddressFromString(const std::string& _addr, std::error_code& _ec); + +/** + * @brief Convert uint32_t into an asio::ip::address_v4 + * + * @param _addr uint32_t address + * @return asio::ip::address_v4 + */ +[[nodiscard]] asio::ip::address_v4 ipv4AddressFromInt(std::uint32_t _add); + +} // utils +} // com +} // vsomeip_utilities + +#endif // __COMUTILS_HPP__ diff --git a/test/common/someip_lib/communication/src/comutils.cpp b/test/common/someip_lib/communication/src/comutils.cpp new file mode 100644 index 000000000..119512e83 --- /dev/null +++ b/test/common/someip_lib/communication/src/comutils.cpp @@ -0,0 +1,46 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include + +#include + +namespace vsomeip_utilities { +namespace com { +namespace utils { + +asio::ip::address_v4 ipv4AddressFromString(const std::string& _addr, std::error_code& _ec) { + // Build address from string + boost::system::error_code ec; + asio::ip::address_v4 addr = asio::ip::make_address_v4(_addr, ec); + + // convert resulting error code to std::error_code + _ec = vsomeip_utilities::utils::intToStdError(ec.value()); + + return addr; +} + +asio::ip::address_v6 ipv6AddressFromString(const std::string& _addr, std::error_code& _ec) { + // Build address from string + boost::system::error_code ec; + asio::ip::address_v6 addr = asio::ip::make_address_v6(_addr, ec); + + // convert resulting error code to std::error_code + _ec = vsomeip_utilities::utils::intToStdError(ec.value()); + + return addr; +} + +asio::ip::address_v4 ipv4AddressFromInt(std::uint32_t _addr) { + // Build address from uint + return asio::ip::make_address_v4(_addr); +} + +} // utils +} // com +} // vsomeip_utilities diff --git a/test/common/someip_lib/serialization/CMakeLists.txt b/test/common/someip_lib/serialization/CMakeLists.txt new file mode 100644 index 000000000..5f8df0b5d --- /dev/null +++ b/test/common/someip_lib/serialization/CMakeLists.txt @@ -0,0 +1,33 @@ +project (serialization) + +# ---------------------------------------------------------------------------- +# Include all source files (cpp/hpp) +# ---------------------------------------------------------------------------- +file (GLOB SRC src/*.cpp src/*.hpp) +file (GLOB INC include/*.hpp include/serialization/*.hpp) + +# ---------------------------------------------------------------------------- +# Declare the library +# ---------------------------------------------------------------------------- +add_library ( + ${PROJECT_NAME} SHARED + ${SRC} + ${INC} +) + +target_link_libraries ( + ${PROJECT_NAME} + PUBLIC + ${BOOST_LIBS} + utils +) + +# ---------------------------------------------------------------------------- +# Specify here the include directories exported +# by this library +# ---------------------------------------------------------------------------- +target_include_directories ( + ${PROJECT_NAME} + PUBLIC include + PRIVATE src +) diff --git a/test/common/someip_lib/serialization/include/serialization/dynamicbytearraypayload.hpp b/test/common/someip_lib/serialization/include/serialization/dynamicbytearraypayload.hpp new file mode 100644 index 000000000..dc28364e6 --- /dev/null +++ b/test/common/someip_lib/serialization/include/serialization/dynamicbytearraypayload.hpp @@ -0,0 +1,103 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __DYNAMICBYTEARRAYPAYLOAD_HPP__ +#define __DYNAMICBYTEARRAYPAYLOAD_HPP__ + +#include + +#include + +namespace vsomeip_utilities { +namespace serialization { + +class DynamicByteArrayPayloadBuilder; + +class DynamicByteArrayPayload : public Serializable { +public: + // CTor + explicit DynamicByteArrayPayload(const std::size_t _size = 0) : m_payload(_size, 0) { } + + // Copy/Move CTors + DynamicByteArrayPayload(const DynamicByteArrayPayload &_other); + DynamicByteArrayPayload(const DynamicByteArrayPayload &&_other); + + // Copy/Move assignment operators + virtual const DynamicByteArrayPayload &operator=(const DynamicByteArrayPayload &_other); + virtual const DynamicByteArrayPayload &operator=(const DynamicByteArrayPayload &&_other); + + /** + * @brief Create Fragment Builder + * + * @return DynamicByteArrayPayload + */ + static DynamicByteArrayPayloadBuilder create(); + + /** + * @brief The Serializable object definition size + * + * @return std::size_t + */ + inline static std::size_t size() { return 0; } + + /** + * @brief The Serializable object instance actual size + * + * @return std::size_t + */ + std::size_t actualSize() const override; + + /** + * @brief Deserialize data from stream + * + * @param _stream + */ + virtual std::size_t deserialize(std::istream &_stream) override; + + /** + * @brief Serialize data to stream + * + * @param _stream + */ + virtual std::size_t serialize(std::ostream &_stream) const override; + + virtual void setPayload(std::initializer_list &_payload); + virtual const std::vector &payload() const; + + /** + * @brief Print to stdout utility method + * + */ + virtual void print() const override; + + bool operator==(const DynamicByteArrayPayload &_other) const; + +protected: + std::vector m_payload; +}; + +/** + * @brief Builder + * + */ +class DynamicByteArrayPayloadBuilder { +public: + // CTor/DTor + DynamicByteArrayPayloadBuilder() = default; + virtual ~DynamicByteArrayPayloadBuilder() = default; + + operator DynamicByteArrayPayload() const; + + // Setter Methods + DynamicByteArrayPayloadBuilder &payload(std::initializer_list &&_payload); + +private: + DynamicByteArrayPayload m_entry; +}; + +} // serialization +} // vsomeip_utilities + +#endif // __DYNAMICBYTEARRAYPAYLOAD_HPP__ diff --git a/test/common/someip_lib/serialization/include/serialization/fragmentpayload.hpp b/test/common/someip_lib/serialization/include/serialization/fragmentpayload.hpp new file mode 100644 index 000000000..d748dfd2c --- /dev/null +++ b/test/common/someip_lib/serialization/include/serialization/fragmentpayload.hpp @@ -0,0 +1,132 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __FRAGMENTPAYLOAD_HPP__ +#define __FRAGMENTPAYLOAD_HPP__ + +#include + +#include +#include + +namespace vsomeip_utilities { +namespace serialization { + +template +class FragmentPayload + : public serialization::PodPayload + , public serialization::StreamPayload { +public: + // CTor + explicit FragmentPayload() = default; + + // Copy/Move CTors + FragmentPayload(const FragmentPayload& _other) + : serialization::PodPayload { _other } + , serialization::StreamPayload { _other } {} + + FragmentPayload(const FragmentPayload&& _other) + : serialization::PodPayload { _other } + , serialization::StreamPayload { _other } {} + + // Copy/Move assignment operators + const FragmentPayload& operator=(const FragmentPayload& _other) { + serialization::PodPayload::operator=(_other); + serialization::StreamPayload::operator=(_other); + + return *this; + } + + const FragmentPayload& operator=(const FragmentPayload&& _other) { + serialization::PodPayload::operator=(_other); + serialization::StreamPayload::operator=(_other); + + return *this; + } + + /** + * @brief The Serializable object definition size + * + * @return std::size_t + */ + static std::size_t size() { + return serialization::PodPayload::size(); + } + + /** + * @brief The Serializable object instance actual size + * + * @return std::size_t + */ + virtual std::size_t actualSize() const override { + return size() + serialization::StreamPayload::streamSize(); + } + + /** + * @brief Returns the payload defined size (as referenced in the header) + * + * @return std::size_t + */ + virtual std::size_t payloadSize() const = 0; + + /** + * @brief Deserialize data from stream + * + * @param _stream + */ + virtual std::size_t deserialize(std::istream& _stream) override { + std::size_t headerBytes = 0; + std::size_t payloadBytes = 0; + + headerBytes = serialization::PodPayload::deserialize(_stream); + + if (headerBytes == serialization::PodPayload::size()) { + payloadBytes = serialization::StreamPayload::readFromStream(_stream, payloadSize()); + + if (payloadBytes != payloadSize()) { + std::cerr << __func__ + << ": Error deserializing Payload, deserialized length mismatches header length!\n"; + } + + } else { + std::cerr << __func__ + << ": Error deserializing Header, deserialized length mismatches header size!\n"; + } + + return headerBytes + payloadBytes; + } + + /** + * @brief Serialize data to stream + * + * @param _stream + */ + virtual std::size_t serialize(std::ostream& _stream) const override { + std::size_t headerBytes = 0; + std::size_t payloadBytes = 0; + + headerBytes += serialization::PodPayload::serialize(_stream); + if (headerBytes == serialization::PodPayload::size()) { + payloadBytes = serialization::StreamPayload::writeToStream(_stream); + + if (payloadBytes != payloadSize()) { + std::cerr << __func__ + << ": Error serializing Payload, serialized length mismatches header length!\n"; + } + + } else { + std::cerr << __func__ + << ": Error serializing Header, serialized length mismatches header size!\n"; + } + + + return headerBytes + payloadBytes; + } +}; + +} // serialization +} // vsomeip_utilities + +#endif // __FRAGMENTPAYLOAD_HPP__ diff --git a/test/common/someip_lib/serialization/include/serialization/podpayload.hpp b/test/common/someip_lib/serialization/include/serialization/podpayload.hpp new file mode 100644 index 000000000..968597e55 --- /dev/null +++ b/test/common/someip_lib/serialization/include/serialization/podpayload.hpp @@ -0,0 +1,104 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __PODPAYLOAD_HPP__ +#define __PODPAYLOAD_HPP__ + +#include +#include + +namespace vsomeip_utilities { +namespace serialization { + +/** + * @brief Plain old Data Payload representation + * + * @param PayloadType + */ +template +class PodPayload + : public serialization::Serializable { +public: + // CTor + PodPayload() = default; + + // Copy/Move CTors + PodPayload(const PodPayload& _other) : m_podPayload { _other.m_podPayload } {} + PodPayload(const PodPayload&& _other) : m_podPayload { std::move(_other.m_podPayload) } {} + + // Copy/Move assignment operators + virtual const PodPayload& operator=(const PodPayload& _other) { + m_podPayload = _other.m_podPayload; + return *this; + } + + virtual const PodPayload& operator=(const PodPayload&& _other) { + m_podPayload = std::move(_other.m_podPayload); + return *this; + } + + /** + * @brief The Serializable object definition size + * + * @return std::size_t + */ + static std::size_t size() { + return sizeof(PayloadType); + } + + /** + * @brief The Serializable object instance actual size + * + * @return std::size_t + */ + virtual std::size_t actualSize() const override { + return size(); + } + + /** + * @brief Deserialize data from stream + * + * @param _stream + */ + virtual std::size_t deserialize(std::istream& _stream) { + PayloadType bigEndianPayload; + _stream.read(reinterpret_cast(&bigEndianPayload), sizeof(PayloadType)); + m_podPayload = utils::swapEndianness(bigEndianPayload); + + if (_stream.fail()) { + std::cerr << __func__ << ": Failed to deserialize POD!\n"; + return 0; + } else { + return size(); + } + } + + /** + * @brief Serialize data to stream + * + * @param _stream + */ + virtual std::size_t serialize(std::ostream& _stream) const { + + PayloadType bigEndianPayload = utils::swapEndianness(m_podPayload); + _stream.write(reinterpret_cast(&bigEndianPayload), sizeof(PayloadType)); + + + if (_stream.fail()) { + std::cerr << __func__ << ": Failed to serialize POD!\n"; + return 0; + } else { + return size(); + } + } + +protected: + PayloadType m_podPayload; +}; + +} // namespace serialization +} // namespace vsomeip_utilities + +#endif // __PODPAYLOAD_HPP__ diff --git a/test/common/someip_lib/serialization/include/serialization/serializable.hpp b/test/common/someip_lib/serialization/include/serialization/serializable.hpp new file mode 100644 index 000000000..dc4868545 --- /dev/null +++ b/test/common/someip_lib/serialization/include/serialization/serializable.hpp @@ -0,0 +1,59 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __SERIALIZABLE_HPP__ +#define __SERIALIZABLE_HPP__ + +#include + +namespace vsomeip_utilities { +namespace serialization { + +/** + * @brief Abstract Serializable class + * + */ +class Serializable { +public: + + /** + * @brief The Serializable object definition size + * + * @return std::size_t + */ + static std::size_t size() { return sizeof(Serializable); }; + + /** + * @brief The Serializable object instance actual size + * + * @return std::size_t + */ + virtual std::size_t actualSize() const = 0; + + /** + * @brief Deserialize data from stream + * + * @param _stream + */ + virtual std::size_t deserialize(std::istream& _stream) = 0; + + /** + * @brief Serialize data to stream + * + * @param _stream + */ + virtual std::size_t serialize(std::ostream& _stream) const = 0; + + /** + * @brief Print to stdout utility method + * + */ + virtual void print() const = 0; +}; + +} // com +} // vsomeip_utilities + +#endif // __SERIALIZABLE_HPP__ diff --git a/test/common/someip_lib/serialization/include/serialization/staticbytearraypayload.hpp b/test/common/someip_lib/serialization/include/serialization/staticbytearraypayload.hpp new file mode 100644 index 000000000..44dd91275 --- /dev/null +++ b/test/common/someip_lib/serialization/include/serialization/staticbytearraypayload.hpp @@ -0,0 +1,148 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __STATICBYTEARRAYPAYLOAD_HPP__ +#define __STATICBYTEARRAYPAYLOAD_HPP__ + +#include +#include + +#include + + +namespace vsomeip_utilities { +namespace serialization { + +template +class StaticByteArrayPayloadBuilder; + +template +class StaticByteArrayPayload : public DynamicByteArrayPayload { +public: + // CTor + explicit StaticByteArrayPayload() + : DynamicByteArrayPayload(Size) {} + + /** + * @brief Create Fragment Builder + * + * @return StaticByteArrayPayloadBuilder + */ + static StaticByteArrayPayloadBuilder create() { + return StaticByteArrayPayloadBuilder(); + } + + /** + * @brief The Serializable object definition size + * + * @return std::size_t + */ + inline static std::size_t size() { + return Size; + } + + /** + * @brief The Serializable object instance actual size + * + * @return std::size_t + */ + std::size_t actualSize() const override { + return size(); + } + + /** + * @brief Deserialize data from stream + * + * @param _stream + */ + std::size_t deserialize(std::istream& _stream) override { + std::size_t deserializedBytes = 0; + + // Read backwards into vector to convert from Big to Little Endian byte ordering + for (std::size_t i = m_payload.size(); i > 0; --i) { + // Read byte into vector and break if operation fails + if (!_stream >> m_payload[i - 1]) { + break; + } else { + deserializedBytes++; + } + } + + if (_stream.fail()) { + std::cerr << __func__ << ": Failed to deserialize Byte Array!\n"; + } + + return deserializedBytes; + } + + virtual void setPayload(std::initializer_list& _payload) override { + // Ensure initializer list size matches the payload size + assert(_payload.size() == Size); + + DynamicByteArrayPayload::setPayload(_payload); + } + + /** + * @brief Print to stdout utility method + * + */ + virtual void print() const override { + // Store original format + std::ios_base::fmtflags prevFmt(std::cout.flags()); + + // Print payload + std::cout << "[" __FILE__ "]" + << "\n\tSize: " << Size + << "\n\t--\n\tpayload: " + << std::hex + << std::showbase + << "{\n"; + + for (auto byte : m_payload) { + std::cout << unsigned(byte) << ' '; + } + + std::cout << "}\n"; + + // Restore original format + std::cout.flags(prevFmt); + } +}; + +/** + * @brief Builder + * + */ +template +class StaticByteArrayPayloadBuilder { +public: + // CTor/DTor + StaticByteArrayPayloadBuilder() = default; + virtual ~StaticByteArrayPayloadBuilder() = default; + + // Delete default CTors and assignment operators + StaticByteArrayPayloadBuilder(const StaticByteArrayPayloadBuilder&) = delete; + StaticByteArrayPayloadBuilder(const StaticByteArrayPayloadBuilder&&) = delete; + const StaticByteArrayPayloadBuilder& operator=(const StaticByteArrayPayloadBuilder&) = delete; + const StaticByteArrayPayloadBuilder& operator=(const StaticByteArrayPayloadBuilder&&) = delete; + + operator StaticByteArrayPayload() const { + return std::move(m_entry); + } + + // Setter Methods + StaticByteArrayPayloadBuilder& payload(std::initializer_list&& _payload) { + m_entry.setPayload(_payload); + return *this; + } + +private: + StaticByteArrayPayload m_entry; +}; + +} // serialization +} // vsomeip_utilities + +#endif // __STATICBYTEARRAYPAYLOAD_HPP__ diff --git a/test/common/someip_lib/serialization/include/serialization/streampayload.hpp b/test/common/someip_lib/serialization/include/serialization/streampayload.hpp new file mode 100644 index 000000000..253b88bcd --- /dev/null +++ b/test/common/someip_lib/serialization/include/serialization/streampayload.hpp @@ -0,0 +1,164 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __STREAMPAYLOAD_HPP__ +#define __STREAMPAYLOAD_HPP__ + +#include + +#include +#include + +namespace vsomeip_utilities { +namespace serialization { + +class StreamPayload { +public: + StreamPayload() = default; + + StreamPayload(const StreamPayload &_other) { + commit(boost::asio::buffer_copy(prepareBuffer(_other.m_payloadBuffer.size()), + _other.m_payloadBuffer.data())); + } + + const StreamPayload &operator=(const StreamPayload &_other) { + commit(boost::asio::buffer_copy(prepareBuffer(_other.m_payloadBuffer.size()), + _other.m_payloadBuffer.data())); + return *this; + } + + StreamPayload(const StreamPayload &&_other) { + commit(boost::asio::buffer_copy(prepareBuffer(_other.m_payloadBuffer.size()), + _other.m_payloadBuffer.data())); + } + + const StreamPayload &operator=(const StreamPayload &&_other) { + commit(boost::asio::buffer_copy(prepareBuffer(_other.m_payloadBuffer.size()), + _other.m_payloadBuffer.data())); + + return *this; + } + + /** + * @brief Pushes the provided payload into the container + * + * @tparam T source payload type + * @param _payload source payload + * @return the size in bytes of the pushed data + */ + template + std::size_t push(const T &_payload) { + std::ostream os(&m_payloadBuffer); + std::size_t processedBytes = _payload.serialize(os); + + if (processedBytes > 0) { + commit(0); + // TODO: This needs top be assessed, if we commit a number of processed bytes greater + // than 0 the streambuf available bytes are set to 2x that number. Commiting 0 bytes + // appears to workaround this behavior. + } + + return processedBytes; + } + + /** + * @brief Populates the provided entry from the payload's next memory location + * + * @tparam T target payload type + * @param _payload target payload + * @return the size in bytes of the pulled data + */ + template + std::size_t pull(T &_payload) { + std::istream is(&m_payloadBuffer); + std::size_t processedBytes = _payload.deserialize(is); + + return processedBytes; + } + +protected: + std::size_t streamSize() const { return m_payloadBuffer.size(); } + + /** + * @brief Commits the next _size bytes into the input stream + * + * @param _size + */ + void commit(const std::size_t _size) { m_payloadBuffer.commit(_size); } + + /** + * @brief Consumes the nest _size bytes from the input stream + * + * @param _size + */ + void consume(const std::size_t _size) { m_payloadBuffer.consume(_size); } + + /** + * @brief Prepares the internal stream buffer with provided size + * + * @param _size + * @return boost::asio::mutable_buffer Returns buffer handle + */ + boost::asio::mutable_buffer prepareBuffer(std::size_t _size) { + return m_payloadBuffer.prepare(_size); + } + + /** + * @brief Get a pointer to the first byte of the stream. + * + * @return unsigned char* + */ + const unsigned char *begin() { return static_cast(m_payloadBuffer.data().data()); }; + + /** + * @brief Get a pointer to the last byte of the stream. + * + * @return unsigned char* + */ + const unsigned char *end() { return begin() + m_payloadBuffer.size(); } + + std::size_t readFromStream(std::istream &_stream, const std::size_t _size) { + std::size_t processedBytes = 0; + + // Read into payload + _stream.read(reinterpret_cast(prepareBuffer(_size).data()), _size); + + // if payload read successfully... + if (!_stream.fail()) { + // flag data as available + commit(_size); + processedBytes += _size; + + } else { + std::cerr << __func__ << ": Failed to read " << _size << " bytes from stream!\n"; + } + + return processedBytes; + } + + std::size_t writeToStream(std::ostream &_stream) const { + std::size_t processedBytes = 0; + + // Serialize payload into stream + _stream.write(static_cast(m_payloadBuffer.data().data()), streamSize()); + + // if payload serialization successfull, account payload bytes... + if (!_stream.fail()) { + processedBytes += streamSize(); + } else { + std::cerr << __func__ << ": Failed to write " << streamSize() << " bytes from stream!\n"; + } + + return processedBytes; + } + +private: + boost::asio::streambuf m_payloadBuffer; +}; + +} // someip +} // vsomeip_utilities + +#endif // __STREAMPAYLOAD_HPP__ diff --git a/test/common/someip_lib/serialization/src/dynamicbytearraypayload.cpp b/test/common/someip_lib/serialization/src/dynamicbytearraypayload.cpp new file mode 100644 index 000000000..6755b4171 --- /dev/null +++ b/test/common/someip_lib/serialization/src/dynamicbytearraypayload.cpp @@ -0,0 +1,117 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +namespace vsomeip_utilities { +namespace serialization { + +DynamicByteArrayPayload::DynamicByteArrayPayload(const DynamicByteArrayPayload &_other) + : m_payload { _other.m_payload } { +} + +DynamicByteArrayPayload::DynamicByteArrayPayload(const DynamicByteArrayPayload &&_other) + : m_payload { std::move(_other.m_payload) } { +} + +const DynamicByteArrayPayload & +DynamicByteArrayPayload::operator=(const DynamicByteArrayPayload &_other) { + m_payload = _other.m_payload; + return *this; +} + +const DynamicByteArrayPayload & +DynamicByteArrayPayload::operator=(const DynamicByteArrayPayload &&_other) { + m_payload = std::move(_other.m_payload); + return *this; +} + +DynamicByteArrayPayloadBuilder DynamicByteArrayPayload::create() { + return DynamicByteArrayPayloadBuilder(); +} + +std::size_t DynamicByteArrayPayload::actualSize() const { + return m_payload.size(); +} + +std::size_t DynamicByteArrayPayload::deserialize(std::istream &_stream) { + std::size_t deserializedBytes = 0; + + // We want to read everything available in the stream + while (!_stream.fail()) { + char byte; + if (_stream.read(&byte, sizeof(byte))) { + m_payload.emplace(m_payload.begin(), static_cast(byte)); + deserializedBytes++; + } + } + + return deserializedBytes; +} + +std::size_t DynamicByteArrayPayload::serialize(std::ostream &_stream) const { + std::size_t serializedBytes = 0; + + // Write into stream backwards to convert from Little to Big Endian byte ordering + for (std::size_t i = m_payload.size(); i > 0; --i) { + // write byte into stream and break if operation fails + if (!(_stream.write(reinterpret_cast(&m_payload[i - 1]), sizeof(std::uint8_t)))) { + break; + } else { + serializedBytes++; + } + } + + if (_stream.fail()) { + std::cerr << __func__ << ": Failed to serialize Byte Array!\n"; + } + + return serializedBytes; +} + +void DynamicByteArrayPayload::setPayload(std::initializer_list &_payload) { + // Create new vector with provided payload + m_payload = std::move(std::vector(_payload)); +} + +const std::vector &DynamicByteArrayPayload::payload() const { + return m_payload; +} + +void DynamicByteArrayPayload::print() const { + // Store original format + std::ios_base::fmtflags prevFmt(std::cout.flags()); + + // Print payload + std::cout << "[" __FILE__ "]" + << "\n\tSize: " << actualSize() + << "\n\t--\n\tpayload:" << std::hex << std::showbase; + + for (auto byte : m_payload) { + std::cout << ' ' << unsigned(byte); + } + + std::cout << '\n'; + + // Restore original format + std::cout.flags(prevFmt); +} + +bool DynamicByteArrayPayload::operator==(const DynamicByteArrayPayload &_other) const { + return m_payload == _other.payload(); +} + +DynamicByteArrayPayloadBuilder::operator DynamicByteArrayPayload() const { + return std::move(m_entry); +} + +DynamicByteArrayPayloadBuilder & +DynamicByteArrayPayloadBuilder::payload(std::initializer_list &&_payload) { + m_entry.setPayload(_payload); + return *this; +} + +} // namespace serialization +} // namespace vsomeip_utilities diff --git a/test/common/someip_lib/someip/CMakeLists.txt b/test/common/someip_lib/someip/CMakeLists.txt new file mode 100644 index 000000000..ac1fa48e5 --- /dev/null +++ b/test/common/someip_lib/someip/CMakeLists.txt @@ -0,0 +1,46 @@ +# Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +project (someip) + +# ---------------------------------------------------------------------------- +# Include all source files (cpp/hpp) +# ---------------------------------------------------------------------------- +file (GLOB + SRC + src/*.cpp src/*.hpp + src/sd/*.cpp src/sd/*.hpp + src/sd/options/*.cpp src/sd/options/*.hpp + src/generic/*.cpp src/generic/*.hpp +) + +file (GLOB INC include/*.hpp) + +# ---------------------------------------------------------------------------- +# Declare the library +# ---------------------------------------------------------------------------- +add_library ( + ${PROJECT_NAME} SHARED + ${SRC} + ${INC} +) + +TARGET_LINK_LIBRARIES ( + ${PROJECT_NAME} + PUBLIC + utils + serialization + communication +) + +# ---------------------------------------------------------------------------- +# Specify here the include directories exported +# by this library +# ---------------------------------------------------------------------------- +target_include_directories ( + ${PROJECT_NAME} + PUBLIC include + PRIVATE src +) diff --git a/test/common/someip_lib/someip/include/someip/sd/options/ipv4endpointoption.hpp b/test/common/someip_lib/someip/include/someip/sd/options/ipv4endpointoption.hpp new file mode 100644 index 000000000..cd5ab4589 --- /dev/null +++ b/test/common/someip_lib/someip/include/someip/sd/options/ipv4endpointoption.hpp @@ -0,0 +1,75 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __IPV4ENDPOINTOPTION_HPP__ +#define __IPV4ENDPOINTOPTION_HPP__ + +#include + +namespace vsomeip_utilities { +namespace someip { +namespace sd { +namespace options { + +class Ipv4EndpointOptionBuilder; + +// Inverted field representation to align with Big-Endian byte order +struct Ipv4EndpointOptionRaw_t { + std::uint16_t portNumber = { 0 }; + std::uint8_t protocol = { 0 }; + std::uint8_t reserved = { 0 }; + std::uint32_t ipv4Address = { 0 }; +}; + +class Ipv4EndpointOption + : public serialization::PodPayload { +public: + // CTor + Ipv4EndpointOption() = default; + + static Ipv4EndpointOptionBuilder create(); + + std::uint16_t portNumber() const; + std::uint8_t protocol() const; + std::uint32_t ipv4Address() const; + std::string ipv4AddressString() const; + + void setPortNumber(const std::uint16_t& _val); + void setProtocol(const std::uint8_t& _val); + void setIpv4Address(const std::uint32_t& _val); + bool setIpv4Address(const std::string& _val); + void setReserved(const std::uint8_t& _val); + + void print() const override; +}; + +/** + * @brief Entry builder + * + */ +class Ipv4EndpointOptionBuilder { +public: + // CTor/DTor + Ipv4EndpointOptionBuilder() = default; + virtual ~Ipv4EndpointOptionBuilder() = default; + + operator Ipv4EndpointOption() const; + + Ipv4EndpointOptionBuilder& portNumber(const std::uint16_t& _val); + Ipv4EndpointOptionBuilder& protocol(const std::uint8_t& _val); + Ipv4EndpointOptionBuilder& ipv4Address(const std::uint32_t& _val); + Ipv4EndpointOptionBuilder& ipv4Address(const std::string& _val); + Ipv4EndpointOptionBuilder& reserved(const std::uint8_t& _val); + +private: + Ipv4EndpointOption m_entry; +}; + +} // options +} // sd +} // someip +} // vsomeip_utilities + +#endif // __IPV4ENDPOINTOPTION_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/sd/someipsd.hpp b/test/common/someip_lib/someip/include/someip/sd/someipsd.hpp new file mode 100644 index 000000000..3691720fc --- /dev/null +++ b/test/common/someip_lib/someip/include/someip/sd/someipsd.hpp @@ -0,0 +1,125 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __SOMEIPSD_HPP__ +#define __SOMEIPSD_HPP__ + +#include +#include +#include + +namespace vsomeip_utilities { +namespace someip { +namespace sd { + +class SomeIpSdBuilder; + +// Inverted field representation to align with Big-Endian byte order +struct SomeIpSdHeaderRaw_t { + std::uint8_t reserved[3] { 0, 0, 0 }; + types::sdFlags_t flags { 0 }; +}; + +/** + * @brief Some/IP SD + * + */ +class SomeIpSd + : public serialization::PodPayload { +friend class SomeIpSdBuilder; + +public: + // Copy Ctors + SomeIpSd(const SomeIpSd&); + SomeIpSd(const SomeIpSd&&); + + // Assignment operators + const SomeIpSd& operator=(const SomeIpSd&); + const SomeIpSd& operator=(const SomeIpSd&&); + + /** + * @brief Create Fragment Builder + * + * @return SomeIpSdBuilder + */ + static SomeIpSdBuilder create(); + + /** + * @brief Deserialize data from stream + * + * @param _stream + */ + virtual std::size_t deserialize(std::istream& _stream) override; + + /** + * @brief Serialize data to stream + * + * @param _stream + */ + virtual std::size_t serialize(std::ostream& _stream) const override; + + // Message Attribute Getters + types::sdFlags_t flags() const; + bool reboot() const; + bool unicast() const; + bool controlFlag() const; + std::uint32_t reserved() const; + + SomeIpSdEntries& entries(); + SomeIpSdOptions& options(); + + // Message Attribute Setters + void setFlags(const types::sdFlags_t& _flags); + void setReboot(const bool _val); + void setUnicast(const bool _val); + void setControlFlag(const bool _val); + void setReserved(const std::array); + + /** + * @brief Print to stdout utility method + * + */ + void print() const override; + +protected: + // CTor + SomeIpSd() = default; + +private: + SomeIpSdEntries m_entries; + SomeIpSdOptions m_options; +}; + +/** + * @brief Builder + * + */ +class SomeIpSdBuilder { +public: + // CTor/DTor + SomeIpSdBuilder() = default; + virtual ~SomeIpSdBuilder() = default; + + operator SomeIpSd() const; + + // Setter Methods + SomeIpSdBuilder& flags(const types::sdFlags_t _flags); + SomeIpSdBuilder& reboot(const bool _val); + SomeIpSdBuilder& unicast(const bool _val); + SomeIpSdBuilder& controlFlag(const bool _val); + SomeIpSdBuilder& pushEntry(SomeIpSdEntry& _entry); + SomeIpSdBuilder& pushOptions(SomeIpSdOption& _entry); + SomeIpSdBuilder& pushEntry(SomeIpSdEntry&& _entry); + SomeIpSdBuilder& pushOption(SomeIpSdOption&& _entry); + +private: + SomeIpSd m_entry; +}; + +} // sd +} // someip +} // vsomeip_utilities + +#endif // __SOMEIPSD_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/sd/someipsdentries.hpp b/test/common/someip_lib/someip/include/someip/sd/someipsdentries.hpp new file mode 100644 index 000000000..4e78ba18a --- /dev/null +++ b/test/common/someip_lib/someip/include/someip/sd/someipsdentries.hpp @@ -0,0 +1,22 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __SOMEIPSDENTRIES_HPP__ +#define __SOMEIPSDENTRIES_HPP__ + +#include +#include + +namespace vsomeip_utilities { +namespace someip { +namespace sd { + +using SomeIpSdEntries = SomeIpSdEntriesArray; + +} // sd +} // someip +} // vsomeip_utilities + +#endif // __SOMEIPSDENTRIES_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/sd/someipsdentriesarray.hpp b/test/common/someip_lib/someip/include/someip/sd/someipsdentriesarray.hpp new file mode 100644 index 000000000..f5dd272e1 --- /dev/null +++ b/test/common/someip_lib/someip/include/someip/sd/someipsdentriesarray.hpp @@ -0,0 +1,210 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __SOMEIPSDENTRIESBASE_HPP__ +#define __SOMEIPSDENTRIESBASE_HPP__ + +#include + +#include + +#include + +namespace vsomeip_utilities { +namespace someip { +namespace sd { + +// Inverted field representation to align with Big-Endian byte order +struct EntriesLengthRaw_t { + types::length_t length { 0 }; +}; + +template +class SomeIpSdEntriesArray + : public serialization::PodPayload { +public: + // CTor + explicit SomeIpSdEntriesArray() {}; + + // Copy/Move CTors + SomeIpSdEntriesArray(const SomeIpSdEntriesArray& _other) + : serialization::PodPayload{ _other } + , m_entries { _other.m_entries } {} + SomeIpSdEntriesArray(const SomeIpSdEntriesArray&& _other) + : serialization::PodPayload { _other } + , m_entries { std::move(_other.m_entries) } {} + + // Copy/Move assignment operators + const SomeIpSdEntriesArray& operator=(const SomeIpSdEntriesArray& _other) { + serialization::PodPayload::operator=(_other); + m_entries = _other.m_entries; + return *this; + } + + const SomeIpSdEntriesArray& operator=(const SomeIpSdEntriesArray&& _other) { + serialization::PodPayload::operator=(_other); + m_entries = std::move(_other.m_entries); + return *this; + } + + /** + * @brief The Serializable object instance actual size + * + * @return std::size_t + */ + virtual std::size_t actualSize() const override { + return serialization::PodPayload::actualSize() + m_podPayload.length; + } + + /** + * @brief Deserialize data from stream + * + * @param _stream + */ + virtual std::size_t deserialize(std::istream& _stream) override { + std::size_t headerLen = serialization::PodPayload::deserialize(_stream); + std::size_t entriesLen = 0; + + while (entriesLen < length()) { + TEntry entry = TEntry::create(); + std::size_t len = entry.deserialize(_stream); + + // Stop parsing if unnable to deserialize an entry + if (len == 0) + break; + + m_entries.push_back(std::move(entry)); + + entriesLen += len; + } + + std::size_t totalLen = headerLen + entriesLen; + + if (totalLen != actualSize()) { + std::cerr << __func__ << ": Failed to deserialize!\n"; + totalLen = 0; + } + + return totalLen; + } + + /** + * @brief Serialize data to stream + * + * @param _stream + */ + virtual std::size_t serialize(std::ostream& _stream) const override { + std::size_t ret = 0; + + ret = serialization::PodPayload::serialize(_stream); + + for (std::uint32_t i = 0; i < m_entries.size(); ++i) { + ret += m_entries.at(i).serialize(_stream); + } + + if (ret != actualSize()) + std::cerr << __func__ << ": Failed to serialize!\n"; + + return ret; + } + + // Getters + types::length_t length() const { return m_podPayload.length; } + + // Entries management + + /** + * @brief Access entries + * + * @return std::vector& Referent to all entries + */ + std::vector& get() { + return m_entries; + } + + /** + * @brief Access entries by index + * + * @param _index + * @return TEntry& Referent to the entry at the provided index + */ + TEntry& operator[](const std::uint32_t _index) { + return m_entries[_index]; + } + + /** + * @brief Returns the number of stored entries + * + * @return uint32_t + */ + std::uint32_t entriesCount() const { + return static_cast(m_entries.size()); + } + + /** + * @brief Pushes a copy of the provided entry into the entry array + * NOTE: To keep the payload's length consistency, once an entry is pushed into the array it cannot be modified + * + * @param _entry + */ + void pushEntry(TEntry& _entry) { + m_podPayload.length += static_cast(_entry.actualSize()); + m_entries.push_back(_entry); + } + + /** + * @brief Moves an entry into the entry array + * NOTE: To keep the payload's length consistency, once an entry is pushed into the array it cannot be modified + * + * @param _entry + */ + void pushEntry(TEntry&& _entry) { + m_podPayload.length += static_cast(_entry.actualSize()); + m_entries.push_back(_entry); + } + + /** + * @brief Forces the length of the entry array to a given value. + * NOTE: This should only be used to test MALFORMED messages! + * + * @param _length + */ + void forceEntryArraySize(types::length_t _length) { + m_podPayload.length = _length; + } + + /** + * @brief Print to stdout utility method + * + */ + void print() const override { + // Store original format + std::ios_base::fmtflags prevFmt(std::cout.flags()); + + // Print payload + std::cout << "[" __FILE__ "]" + << "\n\tPOD size: " << serialization::PodPayload::size() + << "\n\t--\n\tlength: " << length() + << "\n\tEntries count: " << entriesCount() << '\n'; + + // Restore original format + std::cout.flags(prevFmt); + + for (std::uint32_t i = 0; i < m_entries.size(); ++i) { + std::cout << "[Entry " << i << "]\n"; + m_entries[i].print(); + } + + } + +private: + std::vector m_entries; +}; + +} // sd +} // someip +} // vsomeip_utilities + +#endif // __SOMEIPSDENTRIESBASE_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/sd/someipsdentry.hpp b/test/common/someip_lib/someip/include/someip/sd/someipsdentry.hpp new file mode 100644 index 000000000..6c19b8f47 --- /dev/null +++ b/test/common/someip_lib/someip/include/someip/sd/someipsdentry.hpp @@ -0,0 +1,137 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __SOMEIPSDENTRY_HPP__ +#define __SOMEIPSDENTRY_HPP__ + +#include + +#include + +namespace vsomeip_utilities { +namespace someip { +namespace sd { + +class SomeIpSdEntryBuilder; + +// Inverted field representation to align with Big-Endian byte order +struct SdEntryRaw_t { + std::uint32_t genericAttribute = { 0 }; + // std::uint8_t ttl[3]; + // types::sdMajorVersion majorVersion = { 0 }; + std::uint32_t majorVersionAndTtl = { 0 }; + types::sdInstanceId instanceId = { 0 }; + types::sdServiceId serviceId = { 0 }; + types::sdOptsCount optsCount = { 0 }; + types::sdIndex2nd index2nd = { 0 }; + types::sdIndex1st index1st = { 0 }; + types::sdEntryType type = { 0 }; +}; + +/** + * @brief SomeIpSdEntry + * + * Covers the structure for both: + * - Service Entry type + * - EventGroup Entry type + */ +class SomeIpSdEntry + : public serialization::PodPayload { +public: + // CTor + SomeIpSdEntry() = default; + + /** + * @brief Create Builder + * + * @return SomeIpSdEntryBuilder + */ + static SomeIpSdEntryBuilder create(); + + // Attribute Getters + types::sdEntryType type() const; + types::sdIndex1st index1st() const; + types::sdIndex2nd index2nd() const; + types::sdOptsCount optsCount() const; + types::sdOptsCount optsCount1st() const; + types::sdOptsCount optsCount2nd() const; + types::sdServiceId serviceId() const; + types::sdInstanceId instanceId() const; + types::sdMajorVersion majorVersion() const; + std::uint32_t ttl() const; + + // Service Entry Type specific attribute Getters + types::sdMinorVersion serviceMinorVersion() const; + + // Eventgroup Entry Type specific attribute Getters + types::sdCounter eventgroupCounter() const; + types::sdEventGroupId eventgroupId() const; + + // Message Attribute Setters + void setType(const types::sdEntryType& _val); + void setIndex1st(const types::sdIndex1st& _val); + void setIndex2nd(const types::sdIndex2nd& _val); + void setOptsCount(const types::sdOptsCount& _val); + void setOptsCount1st(const types::sdOptsCount& _val); + void setOptsCount2nd(const types::sdOptsCount& _val); + void setServiceId(const types::sdServiceId& _val); + void setInstanceId(const types::sdInstanceId& _val); + void setMajorVersion(const types::sdMajorVersion& _val); + void setTtl(const std::uint32_t& _val); // 24bit attribute, input argument will be truncated + + // Service Entry Type specific attribute Setters + void setServiceMinorVersion(const types::sdMinorVersion _val); + + // Eventgroup Entry Type specific attribute Setters + void setEventgroupCounter(const types::sdCounter _val); + void setEventgroupId(const types::sdEventGroupId _val); + + /** + * @brief Print to stdout utility method + * + */ + void print() const override; +}; + +/** + * @brief Entry builder + * + */ +class SomeIpSdEntryBuilder { +public: + // CTor/DTor + SomeIpSdEntryBuilder() = default; + virtual ~SomeIpSdEntryBuilder() = default; + + operator SomeIpSdEntry() const; + + // Setter Methods + SomeIpSdEntryBuilder& type(const types::sdEntryType& _val); + SomeIpSdEntryBuilder& index1st(const types::sdIndex1st& _val); + SomeIpSdEntryBuilder& index2nd(const types::sdIndex2nd& _val); + SomeIpSdEntryBuilder& optsCount(const types::sdOptsCount& _val); + SomeIpSdEntryBuilder& optsCount1st(const types::sdOptsCount& _val); + SomeIpSdEntryBuilder& optsCount2nd(const types::sdOptsCount& _val); + SomeIpSdEntryBuilder& serviceId(const types::sdServiceId& _val); + SomeIpSdEntryBuilder& instanceId(const types::sdInstanceId& _val); + SomeIpSdEntryBuilder& majorVersion(const types::sdMajorVersion& _val); + SomeIpSdEntryBuilder& ttl(const std::uint32_t& _val); // 24 bit attribute, input argument will be truncated + + // Service Entry Type specific attribute Setters + SomeIpSdEntryBuilder& serviceMinorVersion(const types::sdMinorVersion _val); + + // Eventgroup Entry Type specific attribute Setters + SomeIpSdEntryBuilder& eventgroupCounter(const types::sdCounter _val); + SomeIpSdEntryBuilder& eventgroupId(const types::sdEventGroupId _val); + +private: + SomeIpSdEntry m_entry; +}; + +} // sd +} // someip +} // vsomeip_utilities + +#endif // __SOMEIPSDENTRY_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/sd/someipsdoption.hpp b/test/common/someip_lib/someip/include/someip/sd/someipsdoption.hpp new file mode 100644 index 000000000..029b3e708 --- /dev/null +++ b/test/common/someip_lib/someip/include/someip/sd/someipsdoption.hpp @@ -0,0 +1,137 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __SOMEIPSDOPTION_HPP__ +#define __SOMEIPSDOPTION_HPP__ + +#include + +#include + +namespace vsomeip_utilities { +namespace someip { +namespace sd { + +class SomeIpSdOptionBuilder; + +// Inverted field representation to align with Big-Endian byte order +struct SdOptionHeaderRaw_t { + std::uint8_t reserved = { 0 }; + types::sdOptionType type = { 0 }; + types::sdOptionLength length = { 0 }; +}; + +/** + * @brief Returns the actual SomeIP length to be placed in the header + * (disregard last 8 header bytes since they are retrieved together) + * + * @return constexpr std::size_t + */ +constexpr std::size_t calcInitialSdOptionHeaderLengthAttr() { + return sizeof(std::uint8_t); +} + +class SomeIpSdOption + : public serialization::FragmentPayload { +public: + // CTor + SomeIpSdOption(); + + /** + * @brief Returns the payload defined size (as referenced in the header) + * + * @return std::size_t + */ + std::size_t payloadSize() const override; + + /** + * @brief Create Builder + * + * @return SomeIpSdEntryBuilder + */ + static SomeIpSdOptionBuilder create(); + + // Attribute Getters + types::sdOptionType type() const; + types::sdOptionLength length() const; + std::uint8_t reserved() const; + + // Message Attribute Setters + void setType(const types::sdOptionType& _val); + + template + std::size_t push(const T& _payload) { + // Push payload and update POD length attribute + std::size_t processed = serialization::FragmentPayload::push(_payload); + m_podPayload.length += static_cast(processed); + + return processed; + } + + template + std::size_t push(const T&& _payload) { + auto p(_payload); + // Push payload and update POD length attribute + std::size_t processed = serialization::FragmentPayload::push(p); + m_podPayload.length += static_cast(processed); + + return processed; + } + + /** + * @brief Forces the length of the option to a given value. + * NOTE: This should only be used to test MALFORMED messages! + * + * @param _length + */ + void forcePayloadLength(const types::sdOptionLength &_length) { + m_podPayload.length = _length; + } + + /** + * @brief Print to stdout utility method + * + */ + void print() const override; +}; + +/** + * @brief Entry builder + * + */ +class SomeIpSdOptionBuilder +{ +public: + // CTor/DTor + SomeIpSdOptionBuilder() = default; + virtual ~SomeIpSdOptionBuilder() = default; + + operator SomeIpSdOption() const; + + // Setter Methods + SomeIpSdOptionBuilder& type(const types::sdOptionType& _val); + + template + SomeIpSdOptionBuilder& push(T& _payload) { + m_entry.push(_payload); + return *this; + } + + template + SomeIpSdOptionBuilder& push(T&& _payload) { + m_entry.push(_payload); + return *this; + } + + +private: + SomeIpSdOption m_entry; +}; + +} // sd +} // someip +} // vsomeip_utilities + +#endif // __SOMEIPSDOPTION_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/sd/someipsdoptions.hpp b/test/common/someip_lib/someip/include/someip/sd/someipsdoptions.hpp new file mode 100644 index 000000000..bceb295c6 --- /dev/null +++ b/test/common/someip_lib/someip/include/someip/sd/someipsdoptions.hpp @@ -0,0 +1,22 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __SOMEIPSDOPTIONS_HPP__ +#define __SOMEIPSDOPTIONS_HPP__ + +#include +#include + +namespace vsomeip_utilities { +namespace someip { +namespace sd { + +using SomeIpSdOptions = SomeIpSdEntriesArray; + +} // sd +} // someip +} // vsomeip_utilities + +#endif // __SOMEIPSDOPTIONS_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/someipmessage.hpp b/test/common/someip_lib/someip/include/someip/someipmessage.hpp new file mode 100644 index 000000000..b3f9058e1 --- /dev/null +++ b/test/common/someip_lib/someip/include/someip/someipmessage.hpp @@ -0,0 +1,198 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __SOMEIPMESSAGE_HPP__ +#define __SOMEIPMESSAGE_HPP__ + +#include + +#include + +#include +#include + +namespace vsomeip_utilities { +namespace someip { + +// Inverted field representation to align with Big-Endian byte order +struct SomeIpHeaderRaw_t { + types::returnCode_e retCode { vsomeip_utilities::someip::types::returnCode_e::E_RC_UNKNOWN }; + types::messageType_e msgType { vsomeip_utilities::someip::types::messageType_e::E_MT_UNKNOWN }; + types::interfaceVersion_t interfaceVersion { 0 }; + types::protocolVersion_t protocolVersion { 0 }; + types::sessionId_t sessionId { 0 }; + types::clientId_t clientId { 0 }; + types::length_t length { 0 }; + types::methodId_t methodId { 0 }; + types::serviceId_t serviceId { 0 }; +}; + +/** + * @brief Returns the actual SomeIP length to be placed in the header + * (disregard last 8 header bytes since they are retrieved together) + * + * @return constexpr std::size_t + */ +constexpr std::size_t calcInitialSomeIpMsgHeaderLengthAttr() { + return sizeof(SomeIpHeaderRaw_t) - 8; +} + +class SomeIpMessageBuilder; + +/** + * @brief Some/IP Message representation + * + */ +class SomeIpMessage : public serialization::FragmentPayload { + friend class SomeIpMessageBuilder; + +public: + // CTor + SomeIpMessage(); + + // Copy/Move CTors + SomeIpMessage(const SomeIpMessage &); + SomeIpMessage(const SomeIpMessage &&); + + // Copy/Move assignment operators + const SomeIpMessage &operator=(const SomeIpMessage &); + const SomeIpMessage &operator=(const SomeIpMessage &&); + + /** + * @brief Returns the payload defined size (as referenced in the header) + * + * @return std::size_t + */ + std::size_t payloadSize() const override; + + /** + * @brief Create Message Builder + * + * @return SomeIpMessageBuilder + */ + static SomeIpMessageBuilder create(); + + // Message Attribute Getters + types::length_t length() const; + types::methodId_t methodId() const; + types::clientId_t clientId() const; + types::returnCode_e retCode() const; + types::messageType_e msgType() const; + types::serviceId_t serviceId() const; + types::sessionId_t sessionId() const; + types::protocolVersion_t protocolVersion() const; + types::interfaceVersion_t interfaceVersion() const; + + // Message Attribute Setters + void setLength(const types::length_t &_length); + void setMethodId(const types::methodId_t &_methodId); + void setClientId(const types::clientId_t &_clientId); + void setRetCode(const types::returnCode_e &_retCode); + void setMsgType(const types::messageType_e &_msgType); + void setServiceId(const types::serviceId_t &_serviceId); + void setSessionId(const types::sessionId_t &_sessionId); + void setProtocolVersion(const types::protocolVersion_t &_protocolVersion); + void setInterfaceVersion(const types::interfaceVersion_t &_interfaceVersion); + + /** + * @brief Reads SOMEIP messages from a udp socket. + * + * @param _udp_socket udp socket over which to receive the messages + * @param _expected_stream_size desired buffer size + * @param _keep_receiving& boolean + */ + static std::vector> readSomeIpMessages(boost::asio::ip::udp::socket *_udp_socket, const int _expected_stream_size, bool& _keep_receiving); + + /** + * @brief Sends SOMEIP message over udp socket. + * + * @param _udp_socket udp socket over which to send the message + * @param _target udp endpoint + * @param _message someip message to send + */ + static void sendSomeIpMessage(boost::asio::ip::udp::socket *_udp_socket , boost::asio::ip::udp::socket::endpoint_type _target_sd, SomeIpMessage _message); + + /** + * @brief Pushes the provided payload into the container + * + * @tparam T source payload type + * @param _payload source payload + * @return the size in bytes of the pushed data + */ + template + std::size_t push(const T &_payload) { + // Push payload and update POD length attribute + std::size_t processedBytes = FragmentPayload::push(_payload); + m_podPayload.length += static_cast(processedBytes); + + return processedBytes; + } + + /** + * @brief Populates the provided entry from the payload's next memory location + * + * @tparam T target payload type + * @param _payload target payload + * @return the size in bytes of the pulled data + */ + template + std::size_t pull(T &_outPayload) { + // Pull payload and update POD length attribute + std::size_t processedBytes = FragmentPayload::pull(_outPayload); + m_podPayload.length -= static_cast(processedBytes); + + return processedBytes; + } + + /** + * @brief Print to stdout utility method + * + */ + void print() const override; +}; + +/** + * @brief Message Header builder + * + */ +class SomeIpMessageBuilder { +public: + // CTor/DTor + SomeIpMessageBuilder() = default; + virtual ~SomeIpMessageBuilder() = default; + + operator SomeIpMessage() const; + + // Setter Methods + SomeIpMessageBuilder &serviceId(const types::serviceId_t _service); + SomeIpMessageBuilder &methodId(const types::methodId_t _method); + SomeIpMessageBuilder &clientId(const types::clientId_t _client); + SomeIpMessageBuilder &sessionId(const types::sessionId_t _session); + SomeIpMessageBuilder &protocolVersion(const types::protocolVersion_t _protoVer); + SomeIpMessageBuilder &interfaceVersion(const types::interfaceVersion_t _ifaceVer); + SomeIpMessageBuilder &messageType(const types::messageType_e _msgType); + SomeIpMessageBuilder &returnCode(const types::returnCode_e _retCode); + + template + SomeIpMessageBuilder &push(T &_payload) { + m_entry.push(_payload); + return *this; + } + + template + SomeIpMessageBuilder &push(T &&_payload) { + auto p(std::move(_payload)); + m_entry.push(p); + return *this; + } + +private: + SomeIpMessage m_entry; +}; + +} // someip +} // vsomeip_utilities + +#endif // __SOMEIPMESSAGE_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/types/primitives.hpp b/test/common/someip_lib/someip/include/someip/types/primitives.hpp new file mode 100644 index 000000000..07d8a5ccb --- /dev/null +++ b/test/common/someip_lib/someip/include/someip/types/primitives.hpp @@ -0,0 +1,91 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __PRIMITIVES_HPP__ +#define __PRIMITIVES_HPP__ + +#include +#include + +namespace vsomeip_utilities { +namespace someip { +namespace types { + +/** + * @brief SomeIp header types + * + */ +using serviceId_t = std::uint16_t; +using methodId_t = std::uint16_t; + +using length_t = std::uint32_t; + +using clientId_t = std::uint16_t; +using sessionId_t = std::uint16_t; + +using protocolVersion_t = std::uint8_t; +using interfaceVersion_t = std::uint8_t; + +enum class messageType_e : std::uint8_t { + E_MT_REQUEST = 0x00, + E_MT_REQUEST_NO_RETURN = 0x01, + E_MT_NOTIFICATION = 0x02, + E_MT_TRANSPORT = 0x20, + E_MT_REQUEST_ACK = 0x40, + E_MT_REQUEST_NO_RETURN_ACK = 0x41, + E_MT_NOTIFICATION_ACK = 0x42, + E_MT_RESPONSE = 0x80, + E_MT_ERROR = 0x81, + E_MT_RESPONSE_ACK = 0xC0, + E_MT_ERROR_ACK = 0xC1, + E_MT_UNKNOWN = 0xFF +}; + +enum class returnCode_e : std::uint8_t { + E_RC_OK = 0x00, + E_RC_NOT_OK = 0x01, + E_RC_UNKNOWN_SERVICE = 0x02, + E_RC_UNKNOWN_METHOD = 0x03, + E_RC_NOT_READY = 0x04, + E_RC_NOT_REACHABLE = 0x05, + E_RC_TIMEOUT = 0x06, + E_RC_WRONG_PROTOCOL_VERSION = 0x07, + E_RC_WRONG_INTERFACE_VERSION = 0x08, + E_RC_MALFORMED_MESSAGE = 0x09, + E_RC_WRONG_MESSAGE_TYPE = 0x0A, + E_RC_UNKNOWN = 0xFF +}; + +/** + * @brief SomeIp SD Entry/Option types + */ + +// Entries +using sdFlags_t = std::uint8_t; +using sdEntryType = std::uint8_t; +using sdIndex1st = std::uint8_t; +using sdIndex2nd = std::uint8_t; +using sdOptsCount = std::uint8_t; +using sdServiceId = std::uint16_t; +using sdInstanceId = std::uint16_t; +using sdMajorVersion = std::uint8_t; +using sdMinorVersion = std::uint32_t; +using sdEventGroupId = std::uint16_t; +using sdCounter = std::uint8_t; +using sdTtl = std::uint32_t; +using sdEntryLength = std::uint16_t; + +// Options +using sdOptionLength = std::uint16_t; +using sdOptionType = std::uint8_t; +using sdOptionProtocol = std::uint8_t; +using sdOptionPort = std::uint16_t; +using sdOptionReserved = std::uint8_t; + +} // namespace types +} // namespace someip +} // namespace vsomeip_utilities + +#endif // __PRIMITIVES_HPP__ diff --git a/test/common/someip_lib/someip/src/sd/options/ipv4endpointoption.cpp b/test/common/someip_lib/someip/src/sd/options/ipv4endpointoption.cpp new file mode 100644 index 000000000..1a3d796d3 --- /dev/null +++ b/test/common/someip_lib/someip/src/sd/options/ipv4endpointoption.cpp @@ -0,0 +1,126 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include + +namespace vsomeip_utilities { +namespace someip { +namespace sd { +namespace options { + +/** + * @brief Create Builder + * + * @return SomeIpSdEntryBuilder + */ +Ipv4EndpointOptionBuilder Ipv4EndpointOption::create() { + return Ipv4EndpointOptionBuilder(); +} + +// Attribute Getters +std::uint16_t Ipv4EndpointOption::portNumber() const { + return m_podPayload.portNumber; +} + +std::uint8_t Ipv4EndpointOption::protocol() const { + return m_podPayload.protocol; +} + +std::uint32_t Ipv4EndpointOption::ipv4Address() const { + return m_podPayload.ipv4Address; +} + +std::string Ipv4EndpointOption::ipv4AddressString() const { + return com::utils::ipv4AddressFromInt(m_podPayload.ipv4Address).to_string(); +} + +// Message Attribute Setters +void Ipv4EndpointOption::setPortNumber(const std::uint16_t& _val) { + m_podPayload.portNumber = _val; +} + +void Ipv4EndpointOption::setProtocol(const std::uint8_t& _val) { + m_podPayload.protocol = _val; +} + +void Ipv4EndpointOption::setIpv4Address(const std::uint32_t& _val) { + m_podPayload.ipv4Address = _val; +} + +bool Ipv4EndpointOption::setIpv4Address(const std::string& _val) { + bool ret = false; + + std::error_code ec; + asio::ip::address_v4 addr = com::utils::ipv4AddressFromString(_val, ec); + + if (!ec) { + setIpv4Address(addr.to_uint()); + ret = true; + } + + return ret; +} + +void Ipv4EndpointOption::setReserved(const std::uint8_t& _val) { + m_podPayload.reserved = _val; +} + +/** + * @brief Print to stdout utility method + * + */ +void Ipv4EndpointOption::print() const { + // Store original format + std::ios_base::fmtflags prevFmt(std::cout.flags()); + + // Print payload + std::cout << "[" __FILE__ "]" + << "\n\tPOD size: " << serialization::PodPayload::size() + << "\n\t--" << std::hex << std::showbase + << "\n\tIpv4 Address: " << unsigned(ipv4Address()) << " (" << ipv4AddressString() << ')' + << "\n\tReserved: " << unsigned(m_podPayload.reserved) + << "\n\tPort Number: " << std::dec << unsigned(portNumber()) << std::hex + << "\n\tProtocol: " << unsigned(protocol()) << '\n'; + + // Restore original format + std::cout.flags(prevFmt); +} + +Ipv4EndpointOptionBuilder::operator Ipv4EndpointOption() const { + return std::move(m_entry); +} + +// Setter Methods +Ipv4EndpointOptionBuilder& Ipv4EndpointOptionBuilder::portNumber(const std::uint16_t& _val) { + m_entry.setPortNumber(_val); + return *this; +} + +Ipv4EndpointOptionBuilder& Ipv4EndpointOptionBuilder::protocol(const std::uint8_t& _val) { + m_entry.setProtocol(_val); + return *this; +} + +Ipv4EndpointOptionBuilder& Ipv4EndpointOptionBuilder::ipv4Address(const std::uint32_t& _val) { + m_entry.setIpv4Address(_val); + return *this; +} + +Ipv4EndpointOptionBuilder& Ipv4EndpointOptionBuilder::ipv4Address(const std::string& _val) { + m_entry.setIpv4Address(_val); + return *this; +} + +Ipv4EndpointOptionBuilder& Ipv4EndpointOptionBuilder::reserved(const std::uint8_t& _val) { + m_entry.setReserved(_val); + return *this; +} + +} // namespace options +} // namespace sd +} // namespace someip +} // namespace vsomeip_utilities diff --git a/test/common/someip_lib/someip/src/sd/someipsd.cpp b/test/common/someip_lib/someip/src/sd/someipsd.cpp new file mode 100644 index 000000000..85798524e --- /dev/null +++ b/test/common/someip_lib/someip/src/sd/someipsd.cpp @@ -0,0 +1,207 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +namespace vsomeip_utilities { +namespace someip { +namespace sd { + +// Header someipSD (4bytes) + Entries length (4bytes) + Options length (4bytes) +constexpr std::size_t SD_MIN_PAYLOAD_SIZE {sizeof(vsomeip_utilities::someip::sd::SomeIpSdHeaderRaw_t) + + 2 * sizeof(vsomeip_utilities::someip::sd::EntriesLengthRaw_t)}; + +SomeIpSd::SomeIpSd(const SomeIpSd& _other) + : serialization::PodPayload { _other } + , m_entries { _other.m_entries } + , m_options { _other.m_options } {} + + +SomeIpSd::SomeIpSd(const SomeIpSd&& _other) + : serialization::PodPayload { _other } + , m_entries { std::move(_other.m_entries) } + , m_options { std::move(_other.m_options) } {} + +const SomeIpSd& SomeIpSd::operator=(const SomeIpSd& _other) { + serialization::PodPayload::operator=(_other); + m_entries = _other.m_entries; + m_options = _other.m_options; + + return *this; +} + +const SomeIpSd& SomeIpSd::operator=(const SomeIpSd&& _other) { + serialization::PodPayload::operator=(_other); + m_entries = std::move(_other.m_entries); + m_options = std::move(_other.m_options); + + return *this; +} + +SomeIpSdBuilder SomeIpSd::create() { + return SomeIpSdBuilder(); +} + +std::size_t SomeIpSd::deserialize(std::istream& _stream) { + std::size_t ret = 0; + + ret += serialization::PodPayload::deserialize(_stream); + ret += m_entries.deserialize(_stream); + ret += m_options.deserialize(_stream); + + if (ret < SD_MIN_PAYLOAD_SIZE) { + std::cerr << __func__ << ": Failed to deserialize!\n"; + ret = 0; + } + + return ret; +} + +std::size_t SomeIpSd::serialize(std::ostream& _stream) const { + std::size_t ret = 0; + + ret += serialization::PodPayload::serialize(_stream); + ret += m_entries.serialize(_stream); + ret += m_options.serialize(_stream); + + if (ret == 0) { + std::cerr << __func__ << ": Failed to serialize!\n"; + } + + return ret; +} + +types::sdFlags_t SomeIpSd::flags() const { + return m_podPayload.flags; +} + +bool SomeIpSd::reboot() const { + return m_podPayload.flags & 0x80; +} + +bool SomeIpSd::unicast() const { + return m_podPayload.flags & 0x40; +} + +bool SomeIpSd::controlFlag() const { + return m_podPayload.flags & 0x20; +} + +std::uint32_t SomeIpSd::reserved() const { + std::uint32_t ret = static_cast(m_podPayload.reserved[0] | (m_podPayload.reserved[1] >> 8) | (m_podPayload.reserved[2] >> 16)); + + return ret; +} + +SomeIpSdEntries& SomeIpSd::entries() { + return m_entries; +} + +SomeIpSdOptions& SomeIpSd::options() { + return m_options; +} + +void SomeIpSd::setFlags(const types::sdFlags_t& _flags) { + m_podPayload.flags = _flags; +} + +void SomeIpSd::setReboot(const bool _val) { + if (_val) { + m_podPayload.flags |= 0x80; + } else { + m_podPayload.flags &= 0x7F; + } +} + +void SomeIpSd::setUnicast(const bool _val) { + if (_val) { + m_podPayload.flags |= 0x40; + } else { + m_podPayload.flags &= 0xBF; + } +} + +void SomeIpSd::setControlFlag(const bool _val) { + if (_val) { + m_podPayload.flags |= 0x20; + } else { + m_podPayload.flags &= 0xDF; + } +} + +void SomeIpSd::setReserved(const std::array _val) { + m_podPayload.reserved[0] = _val[0]; + m_podPayload.reserved[1] = _val[1]; + m_podPayload.reserved[2] = _val[2]; +} + +void SomeIpSd::print() const { + // Store original format + std::ios_base::fmtflags prevFmt(std::cout.flags()); + + // Print payload + std::cout << "[" __FILE__ "]" + << "\n\tPOD size: " << serialization::PodPayload::size() + << "\n\t--\n" << std::hex << std::showbase << "[HEADER]" + << "\n\tflags: " << unsigned(flags()) + << "\n\treserved: " << unsigned(reserved()) << '\n'; + + // Restore original format + std::cout.flags(prevFmt); + + std::cout << "[ENTRIES]\n"; + m_entries.print(); + std::cout << "[OPTIONS]\n"; + m_options.print(); + +} + +SomeIpSdBuilder& SomeIpSdBuilder::flags(const types::sdFlags_t _flags) { + m_entry.setFlags(_flags); + return *this; +} + +SomeIpSdBuilder& SomeIpSdBuilder::reboot(const bool _val) { + m_entry.setReboot(_val); + return *this; +} + +SomeIpSdBuilder& SomeIpSdBuilder::unicast(const bool _val) { + m_entry.setUnicast(_val); + return *this; +} + +SomeIpSdBuilder& SomeIpSdBuilder::controlFlag(const bool _val) { + m_entry.setControlFlag(_val); + return *this; +} + +SomeIpSdBuilder& SomeIpSdBuilder::pushEntry(SomeIpSdEntry& _entry) { + m_entry.entries().pushEntry(_entry); + return *this; +} + +SomeIpSdBuilder& SomeIpSdBuilder::pushOptions(SomeIpSdOption& _entry) { + m_entry.options().pushEntry(_entry); + return *this; +} + +SomeIpSdBuilder& SomeIpSdBuilder::pushEntry(SomeIpSdEntry&& _entry) { + m_entry.entries().pushEntry(_entry); + return *this; +} + +SomeIpSdBuilder& SomeIpSdBuilder::pushOption(SomeIpSdOption&& _entry) { + m_entry.options().pushEntry(_entry); + return *this; +} + +SomeIpSdBuilder::operator SomeIpSd() const { + return std::move(m_entry); +} + +} // namespace sd +} // namespace someip +} // namespace vsomeip_utilities diff --git a/test/common/someip_lib/someip/src/sd/someipsdentry.cpp b/test/common/someip_lib/someip/src/sd/someipsdentry.cpp new file mode 100644 index 000000000..e6dc861e4 --- /dev/null +++ b/test/common/someip_lib/someip/src/sd/someipsdentry.cpp @@ -0,0 +1,225 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +namespace vsomeip_utilities { +namespace someip { +namespace sd { + +SomeIpSdEntryBuilder SomeIpSdEntry::create() { + return SomeIpSdEntryBuilder(); +} + +SomeIpSdEntryBuilder::operator SomeIpSdEntry() const { + return std::move(m_entry); +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::type(const types::sdEntryType& _val) { + m_entry.setType(_val); + return *this; +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::index1st(const types::sdIndex1st& _val) { + m_entry.setIndex1st(_val); + return *this; +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::index2nd(const types::sdIndex2nd& _val) { + m_entry.setIndex2nd(_val); + return *this; +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::optsCount(const types::sdOptsCount& _val) { + m_entry.setOptsCount(_val); + return *this; +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::optsCount1st(const types::sdOptsCount& _val) { + m_entry.setOptsCount1st(_val); + return *this; +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::optsCount2nd(const types::sdOptsCount& _val) { + m_entry.setOptsCount2nd(_val); + return *this; +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::serviceId(const types::sdServiceId& _val) { + m_entry.setServiceId(_val); + return *this; +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::instanceId(const types::sdInstanceId& _val) { + m_entry.setInstanceId(_val); + return *this; +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::majorVersion(const types::sdMajorVersion& _val) { + m_entry.setMajorVersion(_val); + return *this; +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::ttl(const std::uint32_t& _val) { + m_entry.setTtl(_val); + return *this; +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::serviceMinorVersion(const types::sdMinorVersion _val) { + m_entry.setServiceMinorVersion(_val); + return *this; +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::eventgroupCounter(const types::sdCounter _val) { + m_entry.setEventgroupCounter(_val); + return *this; +} + +SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::eventgroupId(const types::sdEventGroupId _val) { + m_entry.setEventgroupId(_val); + return *this; +} + +types::sdEntryType SomeIpSdEntry::type() const { + return m_podPayload.type; +} + +types::sdIndex1st SomeIpSdEntry::index1st() const { + return m_podPayload.index1st; +} + +types::sdIndex2nd SomeIpSdEntry::index2nd() const { + return m_podPayload.index2nd; +} + +types::sdOptsCount SomeIpSdEntry::optsCount() const { + return m_podPayload.optsCount; +} + +types::sdOptsCount SomeIpSdEntry::optsCount1st() const { + return m_podPayload.optsCount >> 4; +} + +types::sdOptsCount SomeIpSdEntry::optsCount2nd() const { + return m_podPayload.optsCount & ~(0xF << 4); +} + +types::sdServiceId SomeIpSdEntry::serviceId() const { + return m_podPayload.serviceId; +} + +types::sdInstanceId SomeIpSdEntry::instanceId() const { + return m_podPayload.instanceId; +} + +types::sdMajorVersion SomeIpSdEntry::majorVersion() const { + return static_cast(m_podPayload.majorVersionAndTtl >> 24); +} + +std::uint32_t SomeIpSdEntry::ttl() const { + return m_podPayload.majorVersionAndTtl & ~(0xFF << 24); +} + +types::sdMinorVersion SomeIpSdEntry::serviceMinorVersion() const { + return static_cast(m_podPayload.genericAttribute); +} + +types::sdCounter SomeIpSdEntry::eventgroupCounter() const { + return (m_podPayload.genericAttribute >> 16) & 0xF; +} + +types::sdEventGroupId SomeIpSdEntry::eventgroupId() const { + return static_cast(m_podPayload.genericAttribute); +} + +void SomeIpSdEntry::setType(const types::sdEntryType& _val) { + m_podPayload.type = _val; +} + +void SomeIpSdEntry::setIndex1st(const types::sdIndex1st& _val) { + m_podPayload.index1st = _val; +} + +void SomeIpSdEntry::setIndex2nd(const types::sdIndex2nd& _val) { + m_podPayload.index2nd = _val; +} + +void SomeIpSdEntry::setOptsCount(const types::sdOptsCount& _val) { + m_podPayload.optsCount = _val; +} + +void SomeIpSdEntry::setOptsCount1st(const types::sdOptsCount& _val) { + m_podPayload.optsCount = + (m_podPayload.optsCount & ~(0xF << 4)) | ((_val & ~(0xF << 4)) << 4); +} + +void SomeIpSdEntry::setOptsCount2nd(const types::sdOptsCount& _val) { + m_podPayload.optsCount = + (m_podPayload.optsCount & ~(0xF)) | (_val & ~(0xF << 4)); +} + +void SomeIpSdEntry::setServiceId(const types::sdServiceId& _val) { + m_podPayload.serviceId = _val; +} + +void SomeIpSdEntry::setInstanceId(const types::sdInstanceId& _val) { + m_podPayload.instanceId = _val; +} + +void SomeIpSdEntry::setMajorVersion(const types::sdMajorVersion& _val) { + m_podPayload.majorVersionAndTtl = + (m_podPayload.majorVersionAndTtl & ~(0xFF << 24)) | (_val << 24); +} + +void SomeIpSdEntry::setTtl(const std::uint32_t& _val) { + m_podPayload.majorVersionAndTtl = + (m_podPayload.majorVersionAndTtl & ~(0xFFFFFF)) | (_val & (0xFFFFFF)); +} + +void SomeIpSdEntry::setServiceMinorVersion(const types::sdMinorVersion _val) { + m_podPayload.genericAttribute = static_cast(_val); +} + +void SomeIpSdEntry::setEventgroupCounter(const types::sdCounter _val) { + m_podPayload.genericAttribute = + (m_podPayload.genericAttribute& ~(0xF << 16)) | ((_val & 0xF) << 16); +} + +void SomeIpSdEntry::setEventgroupId(const types::sdEventGroupId _val) { + m_podPayload.genericAttribute = + (m_podPayload.genericAttribute & ~(0xFFFF)) | _val; +} + +void SomeIpSdEntry::print() const { + // Store original format + std::ios_base::fmtflags prevFmt(std::cout.flags()); + + // Print payload + std::cout << "[" __FILE__ "]" + << "\n\tPOD size: " << serialization::PodPayload::size() + << "\n\t--" << std::hex << std::showbase + << "\n\tTTL: " << unsigned(ttl()) + << "\n\tMajor Version: " << unsigned(majorVersion()) + << "\n\tInstance Id: " << unsigned(instanceId()) + << "\n\tService Id: " << unsigned(serviceId()) + << "\n\tOptions Count: " << unsigned(optsCount()) + << "\n\tOptions 1st Count: " << unsigned(optsCount1st()) + << "\n\tOptions 2nd Count: " << unsigned(optsCount2nd()) + << "\n\t1st Index: " << unsigned(index1st()) + << "\n\t2nd Index: " << unsigned(index2nd()) + << "\n\tType: " << unsigned(type()) + << "\n\t-- Service Entry Attributes" + << "\n\tMinor Version: " << unsigned(serviceMinorVersion()) + << "\n\t-- Eventgroup Entry Attributes" + << "\n\tEventgroup ID: " << unsigned(eventgroupId()) + << "\n\tCounter: " << unsigned(eventgroupCounter()) << '\n'; + + // Restore original format + std::cout.flags(prevFmt); +} + +} // namespace sd +} // namespace someip +} // namespace vsomeip_utilities diff --git a/test/common/someip_lib/someip/src/sd/someipsdoption.cpp b/test/common/someip_lib/someip/src/sd/someipsdoption.cpp new file mode 100644 index 000000000..90ebffaea --- /dev/null +++ b/test/common/someip_lib/someip/src/sd/someipsdoption.cpp @@ -0,0 +1,71 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +namespace vsomeip_utilities { +namespace someip { +namespace sd { + +// CTor +SomeIpSdOption::SomeIpSdOption() { + m_podPayload.length = calcInitialSdOptionHeaderLengthAttr(); +} + +std::size_t SomeIpSdOption::payloadSize() const { + // SD Options length include the reserved attribute size + return static_cast(length()) - sizeof(m_podPayload.reserved); +} + +SomeIpSdOptionBuilder SomeIpSdOption::create() { + return SomeIpSdOptionBuilder(); +} + +types::sdOptionType SomeIpSdOption::type() const { + return m_podPayload.type; +} + +types::sdOptionLength SomeIpSdOption::length() const { + return m_podPayload.length; +} + +std::uint8_t SomeIpSdOption::reserved() const { + return m_podPayload.reserved; +} + +void SomeIpSdOption::setType(const types::sdOptionType& _val) { + m_podPayload.type = _val; +} + +void SomeIpSdOption::print() const { + // Store original format + std::ios_base::fmtflags prevFmt(std::cout.flags()); + + // Print payload + std::cout << "[" __FILE__ "]" + << "\n\tPOD size: " << serialization::PodPayload::size() + << "\n\t--" + << "\n\tlength: " << length() << std::hex << std::showbase + << "\n\ttype: " << unsigned(type()) + << "\n\treserved: " << unsigned(m_podPayload.reserved) + << "\n\t--" << std::dec + << "\n\tPayload Size: " << unsigned(payloadSize()) << '\n'; + + // Restore original format + std::cout.flags(prevFmt); +} + +SomeIpSdOptionBuilder::operator SomeIpSdOption() const { + return std::move(m_entry); +} + +SomeIpSdOptionBuilder& SomeIpSdOptionBuilder::type(const types::sdOptionType& _val) { + m_entry.setType(_val); + return *this; +} + +} // namespace sd +} // namespace someip +} // namespace vsomeip_utilities diff --git a/test/common/someip_lib/someip/src/someipmessage.cpp b/test/common/someip_lib/someip/src/someipmessage.cpp new file mode 100644 index 000000000..31a1b79eb --- /dev/null +++ b/test/common/someip_lib/someip/src/someipmessage.cpp @@ -0,0 +1,244 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +namespace vsomeip_utilities { +namespace someip { + +// CTor +SomeIpMessage::SomeIpMessage() { + m_podPayload.length = + calcInitialSomeIpMsgHeaderLengthAttr(); // Initialize POD's length attribute +} + +SomeIpMessage::SomeIpMessage(const SomeIpMessage &&_other) + : serialization::FragmentPayload { _other } { +} + +SomeIpMessage::SomeIpMessage(const SomeIpMessage &_other) + : serialization::FragmentPayload { _other } { +} + +const SomeIpMessage &SomeIpMessage::operator=(const SomeIpMessage &_other) { + serialization::FragmentPayload::operator=(_other); + return *this; +} + +const SomeIpMessage &SomeIpMessage::operator=(const SomeIpMessage &&_other) { + serialization::FragmentPayload::operator=(_other); + return *this; +} + +std::size_t SomeIpMessage::payloadSize() const { + // Calc real payload length + // (disregard last 8 header bytes since they were already retrieved) + return length() - 8; +} + +types::serviceId_t SomeIpMessage::serviceId() const { + return m_podPayload.serviceId; +} + +void SomeIpMessage::setServiceId(const types::serviceId_t &_serviceId) { + m_podPayload.serviceId = _serviceId; +} + +void SomeIpMessage::setMethodId(const types::methodId_t &_methodId) { + m_podPayload.methodId = _methodId; +} + +types::methodId_t SomeIpMessage::methodId() const { + return m_podPayload.methodId; +} + +// This method should not be used except to force wrong values +void SomeIpMessage::setLength(const types::length_t &_length) { + m_podPayload.length = _length; +} + +types::length_t SomeIpMessage::length() const { + return m_podPayload.length; +} + +void SomeIpMessage::setClientId(const types::clientId_t &_clientId) { + m_podPayload.clientId = _clientId; +} + +types::clientId_t SomeIpMessage::clientId() const { + return m_podPayload.clientId; +} + +void SomeIpMessage::setSessionId(const types::sessionId_t &_sessionId) { + m_podPayload.sessionId = _sessionId; +} + +types::sessionId_t SomeIpMessage::sessionId() const { + return m_podPayload.sessionId; +} + +void SomeIpMessage::setProtocolVersion(const types::protocolVersion_t &_protocolVersion) { + m_podPayload.protocolVersion = _protocolVersion; +} + +types::protocolVersion_t SomeIpMessage::protocolVersion() const { + return m_podPayload.protocolVersion; +} + +void SomeIpMessage::setInterfaceVersion(const types::interfaceVersion_t &_interfaceVersion) { + m_podPayload.interfaceVersion = _interfaceVersion; +} + +types::interfaceVersion_t SomeIpMessage::interfaceVersion() const { + return m_podPayload.interfaceVersion; +} + +void SomeIpMessage::setMsgType(const types::messageType_e &_msgType) { + m_podPayload.msgType = _msgType; +} + +types::messageType_e SomeIpMessage::msgType() const { + return m_podPayload.msgType; +} + +void SomeIpMessage::setRetCode(const types::returnCode_e &_retCode) { + m_podPayload.retCode = _retCode; +} + +types::returnCode_e SomeIpMessage::retCode() const { + return m_podPayload.retCode; +} + +void SomeIpMessage::print() const { + // Store original format + std::ios_base::fmtflags prevFmt(std::cout.flags()); + + // Print payload + std::cout << "[" __FILE__ "]" + << "\n\tPOD size: " << serialization::PodPayload::size() + << "\n\t--\n\tlength: " << length() << '\n' + << std::hex << std::showbase << "\tserviceId: " << unsigned(serviceId()) + << "\n\tmethodId: " << unsigned(methodId()) + << "\n\tclientId: " << unsigned(clientId()) + << "\n\tretCode: " << unsigned(retCode()) + << "\n\tmsgType: " << unsigned(msgType()) + << "\n\tsessionId: " << unsigned(sessionId()) + << "\n\tprotocolVersion: " << unsigned(protocolVersion()) + << "\n\tinterfaceVersion: " << unsigned(interfaceVersion()) + << "\n\t--" << std::dec + << "\n\tPayload Size: " << unsigned(payloadSize()) << '\n'; + + // Restore original format + std::cout.flags(prevFmt); +} + +std::vector> SomeIpMessage::readSomeIpMessages(boost::asio::ip::udp::socket *_udp_socket, + const int _expected_stream_size, bool& _keep_receiving) { + // Create a buffer to receive incoming messages from the socket. + std::vector receive_buffer(_expected_stream_size); + + boost::system::error_code error; + + // Read messages from the udp socket and store them in the uint8_t vector. + std::size_t bytes_transferred = _udp_socket->receive( + boost::asio::buffer(receive_buffer, receive_buffer.capacity()), 0, error); + + if (error) { + _keep_receiving = false; + std::cout << __func__ << " error: " << error.message(); + } + + // Vector of SOMEIP messages. + std::vector> messages; + + // Create a stream buffer. + std::shared_ptr pStreambuf = std::make_shared(); + pStreambuf->prepare(_expected_stream_size); + + // Create an io stream to deserialize incoming messages with someip_lib. + std::iostream ios(pStreambuf.get()); + + // Feed _bytes to the io stream. + for (int i = 0; i < int(bytes_transferred); i++) { + ios << receive_buffer[i]; + } + + // Extract all the messages in the stream. + std::size_t messageLengthSum = 0; + while (messageLengthSum < bytes_transferred) { + // Extract a Some-IP message from the stream. + auto message = std::make_shared(); + const std::size_t msgLength = message->deserialize(ios); + messages.push_back(message); + messageLengthSum += msgLength; + } + + return messages; +} + +void SomeIpMessage::sendSomeIpMessage(boost::asio::ip::udp::socket *_udp_socket , boost::asio::ip::udp::socket::endpoint_type _target, SomeIpMessage _message) { + std::size_t size_sub_msg = 0; + size_sub_msg += _message.actualSize(); + auto stream_buf_sub = std::make_shared(); + stream_buf_sub->prepare(size_sub_msg); + std::ostream os_sub(stream_buf_sub.get()); + _message.serialize(os_sub); + + // Send a subscription message. + _udp_socket->send_to(boost::asio::buffer(stream_buf_sub->data()), _target); +} + +SomeIpMessageBuilder SomeIpMessage::create() { + return SomeIpMessageBuilder(); +} + +SomeIpMessageBuilder::operator SomeIpMessage() const { + return std::move(m_entry); +} + +SomeIpMessageBuilder &SomeIpMessageBuilder::serviceId(const types::serviceId_t _service) { + m_entry.setServiceId(_service); + return *this; +} + +SomeIpMessageBuilder &SomeIpMessageBuilder::methodId(const types::methodId_t _method) { + m_entry.setMethodId(_method); + return *this; +} + +SomeIpMessageBuilder &SomeIpMessageBuilder::clientId(const types::clientId_t _client) { + m_entry.setClientId(_client); + return *this; +} + +SomeIpMessageBuilder &SomeIpMessageBuilder::sessionId(const types::sessionId_t _session) { + m_entry.setSessionId(_session); + return *this; +} + +SomeIpMessageBuilder & +SomeIpMessageBuilder::protocolVersion(const types::protocolVersion_t _protoVer) { + m_entry.setProtocolVersion(_protoVer); + return *this; +} + +SomeIpMessageBuilder & +SomeIpMessageBuilder::interfaceVersion(const types::interfaceVersion_t _ifaceVer) { + m_entry.setInterfaceVersion(_ifaceVer); + return *this; +} + +SomeIpMessageBuilder &SomeIpMessageBuilder::messageType(const types::messageType_e _msgType) { + m_entry.setMsgType(_msgType); + return *this; +} + +SomeIpMessageBuilder &SomeIpMessageBuilder::returnCode(const types::returnCode_e _retCode) { + m_entry.setRetCode(_retCode); + return *this; +} + +} // namespace someip +} // namespace vsomeip_utilities diff --git a/test/common/someip_lib/utils/CMakeLists.txt b/test/common/someip_lib/utils/CMakeLists.txt new file mode 100644 index 000000000..be92c147f --- /dev/null +++ b/test/common/someip_lib/utils/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +project (utils) + +# ---------------------------------------------------------------------------- +# Include all source files (cpp/hpp) +# ---------------------------------------------------------------------------- +file (GLOB SRC src/*.cpp src/*.hpp) +file (GLOB INC include/*.hpp) +# ---------------------------------------------------------------------------- +# Declare the library +# ---------------------------------------------------------------------------- +add_library ( + ${PROJECT_NAME} SHARED + ${SRC} + ${INC} +) +# ---------------------------------------------------------------------------- +# Specify here the include directories exported +# by this library +# ---------------------------------------------------------------------------- +target_include_directories ( + ${PROJECT_NAME} + PUBLIC include + PRIVATE src +) diff --git a/test/common/someip_lib/utils/include/utils/logger.hpp b/test/common/someip_lib/utils/include/utils/logger.hpp new file mode 100644 index 000000000..c070314fa --- /dev/null +++ b/test/common/someip_lib/utils/include/utils/logger.hpp @@ -0,0 +1,53 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __LOGGER_H__ +#define __LOGGER_H__ + +#include +#include +#include +#include +#include + +namespace vsomeip_utilities { +namespace utils { +namespace logger { + +#define LOG_FATAL vsomeip_utilities::utils::logger::message(vsomeip_utilities::utils::logger::level_e::LL_FATAL) +#define LOG_ERROR vsomeip_utilities::utils::logger::message(vsomeip_utilities::utils::logger::level_e::LL_ERROR) +#define LOG_WARNING vsomeip_utilities::utils::logger::message(vsomeip_utilities::utils::logger::level_e::LL_WARNING) +#define LOG_INFO vsomeip_utilities::utils::logger::message(vsomeip_utilities::utils::logger::level_e::LL_INFO) +#define LOG_DEBUG vsomeip_utilities::utils::logger::message(vsomeip_utilities::utils::logger::level_e::LL_DEBUG) +#define LOG_TRACE vsomeip_utilities::utils::logger::message(vsomeip_utilities::utils::logger::level_e::LL_VERBOSE) + +enum level_e { LL_FATAL, LL_ERROR, LL_WARNING, LL_INFO, LL_DEBUG, LL_VERBOSE }; + +class message + : public std::ostream { + +public: + message(level_e _level); + ~message(); + +private: + class buffer : public std::streambuf { + public: + int_type overflow(int_type); + std::streamsize xsputn(const char *, std::streamsize); + std::stringstream data_; + }; + + std::chrono::system_clock::time_point when_; + buffer buffer_; + level_e level_; + static std::mutex mutex__; +}; + +} // logger +} // utils +} // vsomeip_utilities + +#endif // __LOGGER_H__ diff --git a/test/common/someip_lib/utils/include/utils/utils.hpp b/test/common/someip_lib/utils/include/utils/utils.hpp new file mode 100644 index 000000000..8f7ce4d1a --- /dev/null +++ b/test/common/someip_lib/utils/include/utils/utils.hpp @@ -0,0 +1,79 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef __UTILS_H__ +#define __UTILS_H__ + +#include + +namespace vsomeip_utilities { +namespace utils { + +// Empty string constant +constexpr char EMPTY_STRING[] = ""; + +enum class metadataCode_e : std::uint8_t { + E_SERVICE_DISCOVERY = 0x00, + E_PAYLOAD_SERIALIZATION = 0x01, + E_PROTOCOL = 0x02 +}; + +/** + * @brief std::error_code convertion utility method + * + * @param _errc Int error + * @return std::error_code + */ +std::error_code intToStdError(int _errc); + +/** + * @brief std::error_code convertion utility method + * + * @param _errc std::errc error + * @return std::error_code + */ +std::error_code intToStdError(std::errc _errc); + +/** + * @brief Swap _x endianess + * + * @tparam T + * @param _x + * @return T + */ +template +T swapEndianness(const T &_x) { + T ret; + + char *dst = reinterpret_cast(&ret); + const char *src = reinterpret_cast(&_x); + + // Swap byte ordering + for (std::size_t i = sizeof(T); i > 0; --i) { + *dst++ = src[i - 1]; + } + + return ret; +} + +void printBinPayload(const char *_data, std::size_t _size); +void printHexPayload(const char *_data, std::size_t _size); + +/** Store an hardware address in the array. */ +void encodeHardwareAddress(const std::string _address, std::uint8_t *_array); + +/** Retrieve an hardware address from the array. */ +std::string decodeHardwareAddress(const std::uint8_t *_array); + +/** Store a protocol address in the array. */ +void encodeIpAddress(const std::string _address, std::uint8_t *_array); + +/** Retrieve a protocol address from the array. */ +std::string decodeIpAddress(const std::uint8_t *_array); + +} // utils +} // vsomeip_utilities + +#endif // __UTILS_H__ diff --git a/test/common/someip_lib/utils/src/logger.cpp b/test/common/someip_lib/utils/src/logger.cpp new file mode 100644 index 000000000..7464baa32 --- /dev/null +++ b/test/common/someip_lib/utils/src/logger.cpp @@ -0,0 +1,90 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +namespace vsomeip_utilities { +namespace utils { +namespace logger { + +constexpr char COLOR_RESET[] { "\033[0m" }; +constexpr char COLOR_RED[] { "\033[31m" }; +constexpr char COLOR_GREEN[] { "\033[32m" }; +constexpr char COLOR_YELLOW[] { "\033[33m" }; +constexpr char COLOR_BLUE[] { "\033[34m" }; +constexpr char COLOR_PURPLE[] { "\033[35m" }; +constexpr char COLOR_WHITE[] { "\033[37m" }; + +std::mutex message::mutex__; + +message::message(level_e _level) + : std::ostream(&buffer_), + level_(_level) { + when_ = std::chrono::system_clock::now(); +} + +message::~message() { + std::lock_guard its_lock(mutex__); + + // Prepare time stamp + const auto nowAsTimeT = std::chrono::system_clock::to_time_t(when_); + const auto nowMs = + std::chrono::duration_cast(when_.time_since_epoch()) % 1000; + + // Store original format + std::ios_base::fmtflags prevFmt(std::cout.flags()); + + switch (level_) { + case level_e::LL_FATAL: + std::cout << COLOR_RED; + break; + case level_e::LL_ERROR: + std::cout << COLOR_PURPLE; + break; + case level_e::LL_WARNING: + std::cout << COLOR_YELLOW; + break; + case level_e::LL_INFO: + std::cout << COLOR_GREEN; + break; + case level_e::LL_VERBOSE: + std::cout << COLOR_BLUE; + break; + case level_e::LL_DEBUG: + std::cout << COLOR_WHITE; + break; + default: + break; + } + + std::cout << '[' << std::put_time(std::localtime(&nowAsTimeT), "%T") << '.' + << std::setfill('0') << std::setw(3) << nowMs.count() + << "] " << COLOR_RESET << buffer_.data_.str() << '\n'; + + // Restore original format + std::cout.flags(prevFmt); +} + +std::streambuf::int_type +message::buffer::overflow(std::streambuf::int_type c) { + if (c != EOF) { + data_ << char(c); + } + return c; +} + +std::streamsize +message::buffer::xsputn(const char *s, std::streamsize n) { + data_.write(s, n); + return n; +} + +} // logger +} // utils +} // vsomeip_utilities diff --git a/test/common/someip_lib/utils/src/utils.cpp b/test/common/someip_lib/utils/src/utils.cpp new file mode 100644 index 000000000..2a9c9b295 --- /dev/null +++ b/test/common/someip_lib/utils/src/utils.cpp @@ -0,0 +1,87 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include +#include +#include +#include + +#include +#include + +#include + +namespace vsomeip_utilities { +namespace utils { + +std::error_code intToStdError(int _errc) { + return std::make_error_code(static_cast(_errc)); +} + +std::error_code intToStdError(std::errc _errc) { + return intToStdError(static_cast(_errc)); +} + +void printBinPayload(const char *_data, std::size_t _size) { + std::cout << "[PAYLOAD]\n"; + for (std::size_t i = 0; i < _size; ++i) { + std::cout << 'b' << std::bitset<8>(_data[i]) << ' '; + } + std::cout << "\n[!PAYLOAD]\n"; +} + +void printHexPayload(const char *_data, std::size_t _size) { + // Store original format + std::ios_base::fmtflags prevFmt(std::cout.flags()); + + // Print payload + std::cout << "[PAYLOAD]\n"; + // Set hex format + for (std::size_t i = 0; i < _size; i++) { + std::cout << std::hex << std::setfill('0') << std::setw(2) << int(_data[i] & 0xFF) << ' '; + } + std::cout << "\n[!PAYLOAD]\n"; + + // Restore original format + std::cout.flags(prevFmt); +} + +void encodeHardwareAddress(const std::string _address, std::uint8_t *_array) { + ether_addr *hardwareAddress = ether_aton(_address.c_str()); + for (auto t : boost::adaptors::reverse(hardwareAddress->ether_addr_octet)) { + *_array = t; + _array++; + } +} + +std::string decodeHardwareAddress(const std::uint8_t *_array) { + auto hardwareAddress = std::make_shared(); + for (auto &t : boost::adaptors::reverse(hardwareAddress->ether_addr_octet)) { + t = *_array; + _array++; + } + return ether_ntoa(hardwareAddress.get()); +} + +void encodeIpAddress(const std::string _address, std::uint8_t *_array) { + auto ipAddress = boost::asio::ip::make_address_v4(_address); + for (auto t : boost::adaptors::reverse(ipAddress.to_bytes())) { + *_array = t; + _array++; + } +} + +std::string decodeIpAddress(const std::uint8_t *_array) { + boost::asio::ip::address_v4::bytes_type addressBytes; + for (auto &t : boost::adaptors::reverse(addressBytes)) { + t = *_array; + _array++; + } + auto ipAddress = boost::asio::ip::make_address_v4(addressBytes); + return ipAddress.to_string(); +} + +} // utils +} // vsomeip_utilities diff --git a/test/common/src/utility.cpp b/test/common/src/utility.cpp index cdf6db8a9..defc6473e 100644 --- a/test/common/src/utility.cpp +++ b/test/common/src/utility.cpp @@ -128,8 +128,7 @@ utility::force_check_credentials( } void utility::get_policy_uids(vsomeip_v3::configuration_element &_policy_element, - std::vector &_out_uids) -{ + std::vector &_out_uids) { try { std::vector user_ids; auto policy_tree = _policy_element.tree_.get_child("security.policies"); @@ -154,8 +153,7 @@ void utility::get_policy_uids(vsomeip_v3::configuration_element &_policy_element } void utility::get_policy_services(vsomeip_v3::configuration_element &_policy_element, - std::vector &_out_services) -{ + std::vector &_out_services) { try { std::vector services; auto policy_tree = _policy_element.tree_.get_child("security.policies"); @@ -194,8 +192,7 @@ void utility::get_policy_services(vsomeip_v3::configuration_element &_policy_ele } void utility::add_security_whitelist(vsomeip_v3::configuration_element &_policy_element, - const bool _check_whitelist) -{ + const bool _check_whitelist) { std::vector user_ids; get_policy_uids(_policy_element, user_ids); @@ -208,8 +205,7 @@ void utility::add_security_whitelist(vsomeip_v3::configuration_element &_policy_ void utility::add_security_whitelist(vsomeip_v3::configuration_element &_policy_element, const std::vector &_user_ids, const std::vector &_services, - const bool _check_whitelist) -{ + const bool _check_whitelist) { // Add the user ids to the whitelist. boost::property_tree::ptree id_array_node; for (auto user_id : _user_ids) { diff --git a/test/common/src/vsomeip_app_utilities.cpp b/test/common/src/vsomeip_app_utilities.cpp index f2e00106c..b0a6c4a95 100644 --- a/test/common/src/vsomeip_app_utilities.cpp +++ b/test/common/src/vsomeip_app_utilities.cpp @@ -9,8 +9,7 @@ namespace vsomeip_utilities { std::shared_ptr create_standard_vsip_request( vsomeip::service_t _service, vsomeip::instance_t _instance, vsomeip_v3::method_t _method, - vsomeip_v3::interface_version_t _interface, vsomeip_v3::message_type_e _message_type) -{ + vsomeip_v3::interface_version_t _interface, vsomeip_v3::message_type_e _message_type) { auto its_runtime = vsomeip::runtime::get(); auto its_payload = its_runtime->create_payload(); auto its_message = its_runtime->create_request(false); @@ -26,8 +25,7 @@ std::shared_ptr create_standard_vsip_request( base_logger::base_logger(const char *dlt_application_id, const char *dlt_application_name) : _dlt_application_id(dlt_application_id), - _dlt_application_name(dlt_application_name) -{ + _dlt_application_name(dlt_application_name) { #ifdef USE_DLT #ifndef ANDROID DLT_REGISTER_APP(_dlt_application_id, _dlt_application_name); @@ -35,8 +33,7 @@ base_logger::base_logger(const char *dlt_application_id, const char *dlt_applica #endif } -base_logger::~base_logger() -{ +base_logger::~base_logger() { #ifdef USE_DLT #ifndef ANDROID DLT_UNREGISTER_APP(); @@ -44,20 +41,17 @@ base_logger::~base_logger() #endif } -base_vsip_app::base_vsip_app(const char *app_name_, const char *app_id_) : base_logger( app_name_, app_id_) -{ +base_vsip_app::base_vsip_app(const char *app_name_, const char *app_id_) : base_logger( app_name_, app_id_) { _app = vsomeip::runtime::get()->create_application(app_name_); _app->init(); _run_thread = std::thread(std::bind(&base_vsip_app::run, this)); } -void base_vsip_app::run() -{ +void base_vsip_app::run() { _app->start(); } -base_vsip_app::~base_vsip_app() -{ +base_vsip_app::~base_vsip_app() { _app->stop(); _run_thread.join(); } diff --git a/test/network_tests/CMakeLists.txt b/test/network_tests/CMakeLists.txt index e016e0cf7..d16694559 100644 --- a/test/network_tests/CMakeLists.txt +++ b/test/network_tests/CMakeLists.txt @@ -3295,6 +3295,76 @@ if(NOT ${TESTS_BAT}) ) endif() +############################################################################## +# processing unknown type option sd message test +############################################################################## +if(NOT ${TESTS_BAT}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wconversion -Wextra") + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) + set(THREADS_PREFER_PTHREAD_FLAG ON) + + set(TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME unknown_sd_option_type_test) + set(TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME}_service) + add_executable(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE} processing_unknown_sd_option_type_test/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME}_service.cpp) + target_link_libraries(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE} + ${VSOMEIP_NAME} + ${Boost_LIBRARIES} + ${DL_LIBRARY} + ${TEST_LINK_LIBRARIES} + ) + + file(GLOB sd_sources + "../../implementation/service_discovery/src/*entry*.cpp" + "../../implementation/service_discovery/src/*option*.cpp" + "../../implementation/service_discovery/src/*message*.cpp" + ) + set(TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CLIENT ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME}_client) + add_executable(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CLIENT} + processing_unknown_sd_option_type_test/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME}_client.cpp + ${PROJECT_SOURCE_DIR}/implementation/message/src/deserializer.cpp + ${PROJECT_SOURCE_DIR}/implementation/message/src/message_impl.cpp + ${PROJECT_SOURCE_DIR}/implementation/message/src/payload_impl.cpp + ${sd_sources} + ) + + target_link_libraries(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CLIENT} + ${Boost_LIBRARIES} + ${DL_LIBRARY} + ${TEST_LINK_LIBRARIES} + ${VSOMEIP_NAME} + ${VSOMEIP_NAME}-sd + utils + serialization + communication + someip + ) + + # copy starter scripts into builddir + set(TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_MASTER_STARTER ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME}_master_starter.sh) + configure_file( + ${NETWORK_TEST_SRC_DIR}/processing_unknown_sd_option_type_test/conf/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_MASTER_STARTER}.in + ${NETWORK_TEST_SRC_DIR}/processing_unknown_sd_option_type_test/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_MASTER_STARTER} + @ONLY) + copy_to_builddir(${NETWORK_TEST_SRC_DIR}/processing_unknown_sd_option_type_test/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_MASTER_STARTER} + ${NETWORK_TEST_BIN_DIR}/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_MASTER_STARTER} + ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE} + ) + + # Copy config file for local test into $BUILDDIR/test + set(TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CONFIG_FILE ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME}_master.json) + configure_file( + ${NETWORK_TEST_SRC_DIR}/processing_unknown_sd_option_type_test/conf/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CONFIG_FILE}.in + ${NETWORK_TEST_SRC_DIR}/processing_unknown_sd_option_type_test/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CONFIG_FILE} + @ONLY) + copy_to_builddir( + ${NETWORK_TEST_SRC_DIR}/processing_unknown_sd_option_type_test/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CONFIG_FILE} + ${NETWORK_TEST_BIN_DIR}/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CONFIG_FILE} + ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE} + ) +endif() + ############################################################################## # malicious data tests ############################################################################## @@ -4167,6 +4237,8 @@ if(NOT ${TESTS_BAT}) add_dependencies(${TEST_OFFERED_SERVICES_INFO_SERVICE} gtest) add_dependencies(${TEST_PENDING_SUBSCRIPTION_SERVICE} gtest) add_dependencies(${TEST_PENDING_SUBSCRIPTION_CLIENT} gtest) + add_dependencies(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE} gtest) + add_dependencies(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CLIENT} gtest) add_dependencies(${TEST_MALICIOUS_DATA_SERVICE} gtest) add_dependencies(${TEST_MALICIOUS_DATA_CLIENT} gtest) if (${TEST_SECURITY}) @@ -4276,6 +4348,8 @@ if(NOT ${TESTS_BAT}) add_dependencies(build_network_tests ${TEST_OFFERED_SERVICES_INFO_SERVICE}) add_dependencies(build_network_tests ${TEST_PENDING_SUBSCRIPTION_SERVICE}) add_dependencies(build_network_tests ${TEST_PENDING_SUBSCRIPTION_CLIENT}) + add_dependencies(build_network_tests ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE}) + add_dependencies(build_network_tests ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CLIENT}) add_dependencies(build_network_tests ${TEST_MALICIOUS_DATA_SERVICE}) add_dependencies(build_network_tests ${TEST_MALICIOUS_DATA_CLIENT}) add_dependencies(build_network_tests ${TEST_E2E_SERVICE}) @@ -4829,6 +4903,11 @@ if(NOT ${TESTS_BAT}) COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_PENDING_SUBSCRIPTION_MASTER_STARTER} REQUEST_TO_SD) set_tests_properties(${TEST_PENDING_SUBSCRIPTION_NAME}_send_request_to_sd_port PROPERTIES TIMEOUT 180) + # unknown type option sd message test + add_test(NAME ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME} + COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_MASTER_STARTER}) + set_tests_properties(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME} PROPERTIES TIMEOUT 180) + # malicious data test add_test(NAME ${TEST_MALICIOUS_DATA_NAME}_events COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_MALICIOUS_DATA_MASTER_STARTER} MALICIOUS_EVENTS) diff --git a/test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master.json.in b/test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master.json.in new file mode 100644 index 000000000..7cbe54126 --- /dev/null +++ b/test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master.json.in @@ -0,0 +1,55 @@ +{ + "unicast":"@TEST_IP_MASTER@", + "logging": + { + "level":"info", + "console":"true", + "file": + { + "enable":"false", + "path":"/tmp/vsomeip.log" + }, + "dlt":"true" + }, + "applications" : + [ + { + "name" : "unknown_sd_options_test_service", + "id" : "0xCAFE", + "max_dispatch_time" : "1000" + } + ], + "services": + [ + { + "service":"0x1122", + "instance":"0x0001", + "unreliable":"30001", + "reliable": + { + "port":"40001", + "enable-magic-cookies":"false" + }, + "events" : + [ + { + "event" : "0x1111", + "is_reliable" : "false" + }, + { + "event" : "0x1112", + "is_reliable" : "false" + } + ] + } + ], + "routing":"routingmanagerd", + "service-discovery": + { + "enable":"true", + "multicast":"224.0.23.1", + "port":"30490", + "protocol":"udp", + "cyclic_offer_delay" : "1000" + } +} diff --git a/test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master_starter.sh.in b/test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master_starter.sh.in new file mode 100755 index 000000000..1e361ecf0 --- /dev/null +++ b/test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master_starter.sh.in @@ -0,0 +1,63 @@ +#!/bin/bash +# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Purpose: This script is needed to start the services with +# one command. This is necessary as ctest - which is used to run the +# tests - isn't able to start multiple binaries for one testcase. Therefore +# the testcase simply executes this script. This script then runs the services +# and checks that all exit successfully. + +FAIL=0 + +export VSOMEIP_CONFIGURATION=unknown_sd_option_type_test_master.json +# start daemon +../../examples/routingmanagerd/routingmanagerd & +PID_VSOMEIPD=$! +# Start the services +./unknown_sd_option_type_test_service $1 & +PID_SERIVCE=$! + +sleep 1 + +if [ ! -z "$USE_LXC_TEST" ]; then + echo "Waiting for 5s" + sleep 5 + echo "starting offer test on slave LXC offer_test_external_slave_starter.sh" + ssh -tt -i $SANDBOX_ROOT_DIR/commonapi_main/lxc-config/.ssh/mgc_lxc/rsa_key_file.pub -o StrictHostKeyChecking=no root@$LXC_TEST_SLAVE_IP "bash -ci \"set -m; cd \\\$SANDBOX_TARGET_DIR/vsomeip_lib/test/network_tests; ./unknown_sd_option_type_test_client @TEST_IP_MASTER@ @TEST_IP_SLAVE@\"" & + echo "remote ssh pid: $!" +elif [ ! -z "$USE_DOCKER" ]; then + echo "Waiting for 5s" + sleep 5 + docker exec $DOCKER_IMAGE sh -c "cd $DOCKER_TESTS && ./unknown_sd_option_type_client @TEST_IP_MASTER@ @TEST_IP_SLAVE@" & +else +cat < +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "../../implementation/service_discovery/include/constants.hpp" +#include "../../implementation/service_discovery/include/enumeration_types.hpp" + +#include "unknown_sd_option_type_test_globals.hpp" + +static char* remote_address; +static char* local_address; + +using namespace unknown_sd_option_type_test; +using namespace vsomeip_utilities::someip; +using namespace vsomeip_utilities::someip::sd; + +class unknown_sd_option_type_client : public ::testing::Test { +public: + unknown_sd_option_type_client() : + work_(std::make_shared(io_)), + io_thread_(std::bind(&unknown_sd_option_type_client::io_run, this)) {} + +protected: + void TearDown() { + work_.reset(); + io_thread_.join(); + io_.stop(); + } + + void io_run() { + io_.run(); + } + + boost::asio::io_context io_; + std::shared_ptr work_; + std::thread io_thread_; +}; + +/* + * @test Send a subscription to the service and check that the + * subscription is answered with an SubscribeEventgroupAck entry by the service. + * Check that the subscription is active at the end of the test and check that + * the notifications sent by the service are received by the client + */ +TEST_F(unknown_sd_option_type_client, send_subscription) { + std::promise trigger_notifications; + + // Create UDP socket. + boost::asio::ip::udp::socket udp_socket(io_, + boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), SD_PORT)); + udp_socket.set_option(boost::asio::socket_base::reuse_address(true)); + udp_socket.set_option(boost::asio::socket_base::linger(true, 0)); + + // Create thread to receive messages. + std::thread receive_thread([&]() { + // Acknowledge counter. + std::uint32_t subscribe_acks_received = 0; + + // Read control boolean. + bool keep_receiving(true); + + while (keep_receiving) { + // Creating a vector to receive SOMEIP Messages. + std::vector> someip_msgs; + + // Read SOMEIP messages. + someip_msgs = SomeIpMessage::readSomeIpMessages(&udp_socket, vsomeip_utilities::com::DEFAULT_BUFFER_SIZE, keep_receiving); + + for (auto someip_msg : someip_msgs) { + if (someip_msg->serviceId() == vsomeip::sd::service && someip_msg->methodId() == vsomeip::sd::method) { + SomeIpSd sd_msg = SomeIpSd::create(); + EXPECT_TRUE(someip_msg->pull(sd_msg) > 0); + for (auto entry : sd_msg.entries().get()) { + EXPECT_EQ(entry.type(), SUBSCRIBE_EVENTGROUP_ACK); + EXPECT_EQ(3u, entry.ttl()); + EXPECT_EQ(entry.serviceId(), SD_SERVICE_ID); + EXPECT_EQ(entry.instanceId(), SD_INSTANCE_ID); + if (entry.type() == SUBSCRIBE_EVENTGROUP_ACK) { + EXPECT_TRUE(entry.eventgroupId() == EVENTGROUP_ID); + subscribe_acks_received++; + std::cout << "RECEIVED ACK\n"; + } + } + EXPECT_EQ(0u, sd_msg.options().length()); + } + } + + if (subscribe_acks_received) { // all subscribeAcks received + trigger_notifications.set_value(true); + keep_receiving = false; + } + } + }); + + // Create thread to send messages. + std::thread send_thread([&]() { + try { + // Create SOMEIP core of subscription message. + SomeIpMessage someip_subscription_msg = SomeIpMessage::create() + .serviceId(SD_DEFAULT_SERVICE_ID) + .methodId(SD_DEFAULT_METHOD_ID) + .clientId(SD_DEFAULT_CLIENT_ID) + .sessionId(SD_SESSION_ID) + .protocolVersion(SOMEIP_VERSION) + .interfaceVersion(SOMEIP_SD_INTERFACE_VERSION) + .messageType(types::messageType_e::E_MT_NOTIFICATION) + .returnCode(types::returnCode_e::E_RC_OK); + + // Create SOMEIP-SD header of subscription message. + SomeIpSd sd_header = SomeIpSd::create().reboot(true).unicast(true).controlFlag(false); + + // Create Eventgroup subscription entry. + SomeIpSdEntry sd_entry = SomeIpSdEntry::create() + .type(std::uint8_t(vsomeip_v3::sd::entry_type_e::SUBSCRIBE_EVENTGROUP)) + .index1st(1) + .optsCount(0x01) + .optsCount1st(0x01) + .optsCount2nd(0x00) + .serviceId(SD_SERVICE_ID) + .instanceId(SD_INSTANCE_ID) + .majorVersion(SD_MAJOR_VERSION) + .ttl(SD_TTL) + .eventgroupCounter(SD_COUNTER) + .eventgroupId(EVENTGROUP_ID); + + // Add entry to SOMEIP-SD header. + sd_header.entries().pushEntry(sd_entry); + + // Create IPV4 endpoint. + options::Ipv4EndpointOption sd_endpoint_option = + options::Ipv4EndpointOption::create() + .ipv4Address(local_address) + .portNumber(SD_PORT) + .protocol(UDP_PROTOCOL); + + // Create a working and an unknown sd option based on ipv4 endpoint. + SomeIpSdOption sd_option = SomeIpSdOption::create().type(0x04).push(sd_endpoint_option); + SomeIpSdOption sd_unknown_option = SomeIpSdOption::create().type(0xFF).push(sd_endpoint_option); + + // Add those options to the sd header. + sd_header.options().pushEntry(sd_unknown_option); + sd_header.options().pushEntry(sd_option); + + // Add sd header to the core SOMEIP message. + someip_subscription_msg.push(sd_header); + + // Create udp socket for SOME/IP-SD message. + boost::asio::ip::udp::socket::endpoint_type target_sd( + boost::asio::ip::address::from_string(remote_address), + SD_PORT); + + // Create the endpoint to be used to send SOME/IP-SD eventgroup subscription. + SomeIpMessage::sendSomeIpMessage(&udp_socket, target_sd, someip_subscription_msg); + + if (std::future_status::timeout == trigger_notifications.get_future().wait_for(std::chrono::seconds(10))) { + ADD_FAILURE() << "Didn't receive SubscribeAck within time"; + } + + // Create shutdown method call message. + SomeIpMessage shutdown_message = SomeIpMessage::create() + .serviceId(SD_SERVICE_ID) + .methodId(SHUTDOWN_METHOD_ID) + .clientId(SD_CLIENT_ID) + .protocolVersion(SOMEIP_VERSION) + .interfaceVersion(SOMEIP_INTERFACE_VERSION) + .messageType(types::messageType_e::E_MT_REQUEST) + .returnCode(types::returnCode_e::E_RC_OK); + + + // Create the endpoint to be used to send SOME/IP shutdown method call. + boost::asio::ip::udp::socket::endpoint_type target_service( + boost::asio::ip::address::from_string(remote_address), + SERVER_PORT); + + // Send shutdown method call. + SomeIpMessage::sendSomeIpMessage(&udp_socket, target_service, shutdown_message); + } catch (...) { + ASSERT_FALSE(true); + } + + }); + + send_thread.join(); + receive_thread.join(); + boost::system::error_code ec; + udp_socket.shutdown(boost::asio::socket_base::shutdown_both, ec); + udp_socket.close(ec); +} + +#if defined(__linux__) +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + if (argc < 3) { + std::cerr << "Please pass a target and local IP address and test mode to this binary like: " + << argv[0] << " 10.0.3.1 10.0.3.202" << std::endl; + exit(1); + } + remote_address = argv[1]; + local_address = argv[2]; + + return RUN_ALL_TESTS(); +} +#endif diff --git a/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_globals.hpp b/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_globals.hpp new file mode 100644 index 000000000..6852042ed --- /dev/null +++ b/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_globals.hpp @@ -0,0 +1,53 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef UNKNOWN_SD_OPTION_TYPE_TEST_GLOBALS_HPP_ +#define UNKNOWN_SD_OPTION_TYPE_TEST_GLOBALS_HPP_ + +namespace unknown_sd_option_type_test { + +// SOME/IP MESSAGE MACROS +std::uint16_t SD_DEFAULT_SERVICE_ID {0xFFFF}; +std::uint16_t SD_DEFAULT_METHOD_ID {0x8100}; +std::uint16_t SD_DEFAULT_CLIENT_ID {0x0000}; +std::uint16_t SD_CLIENT_ID {0x2222}; +std::uint16_t NOTIF_METHOD_ID {0x4242}; +std::uint16_t SHUTDOWN_METHOD_ID {0x1404}; +std::uint16_t SERVER_PORT {30001}; +std::uint8_t SOMEIP_VERSION {0x01}; +std::uint8_t SOMEIP_INTERFACE_VERSION {0x00}; +std::uint8_t SOMEIP_SD_INTERFACE_VERSION {0x01}; +std::uint8_t UDP_PROTOCOL {0x11}; + +// SD SUBSCRIPTION MESSAGE MACROS +std::uint16_t EVENTGROUP_ID {0x1000}; +std::uint16_t SD_SESSION_ID {0x0001}; +std::uint8_t INTERFACE_VERSION {0x01}; +std::uint16_t SD_SERVICE_ID {0x1122}; +std::uint16_t SD_INSTANCE_ID {0x0001}; +std::uint8_t SD_MAJOR_VERSION {0x00}; +std::uint8_t SD_COUNTER {0x00}; +std::uint32_t SD_TTL {0x00000003}; +std::uint16_t SD_PORT = 0x771A; +std::uint8_t SUBSCRIBE_EVENTGROUP_ACK {0x07}; + +std::uint8_t INDEX_1_OF_ENTRY_1_OPTION_COUNT {27}; +std::uint8_t OPTION_COUNT {0x10}; + +struct service_info { + vsomeip::service_t service_id; + vsomeip::instance_t instance_id; + vsomeip::method_t method_id; + vsomeip::event_t event_id; + vsomeip::eventgroup_t eventgroup_id; + vsomeip::method_t shutdown_method_id; + vsomeip::method_t notify_method_id; +}; + +struct service_info service = { 0x1122, 0x1, 0x1111, 0x1111, 0x1000, 0x1404, 0x4242 }; + +} + +#endif /* UNKNOWN_SD_OPTION_TYPE_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_service.cpp b/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_service.cpp new file mode 100644 index 000000000..00882a92f --- /dev/null +++ b/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_service.cpp @@ -0,0 +1,173 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "unknown_sd_option_type_test_globals.hpp" + +class unknown_sd_option_type_service { +public: + unknown_sd_option_type_service(struct unknown_sd_option_type_test::service_info _service_info) : + service_info_(_service_info), + app_(vsomeip::runtime::get()->create_application("unknown_sd_option_type_service")), + wait_until_registered_(true), + wait_until_shutdown_method_called_(true), + subscription_accepted_asynchronous_(false), + subscription_accepted_synchronous_(false), + offer_thread_(std::bind(&unknown_sd_option_type_service::run, this)) { + if (!app_->init()) { + ADD_FAILURE() << "Couldn't initialize application"; + return; + } + app_->register_state_handler( + std::bind(&unknown_sd_option_type_service::on_state, this, + std::placeholders::_1)); + + // offer field + std::set its_eventgroups; + its_eventgroups.insert(_service_info.eventgroup_id); + app_->offer_event(service_info_.service_id, 0x1, + service_info_.event_id, + its_eventgroups, vsomeip::event_type_e::ET_FIELD, + std::chrono::milliseconds::zero(), + false, true, nullptr, vsomeip::reliability_type_e::RT_UNRELIABLE); + + its_eventgroups.clear(); + its_eventgroups.insert(static_cast(_service_info.eventgroup_id + 1u)); + + app_->offer_event(service_info_.service_id, 0x1, + static_cast(service_info_.event_id + 1u), + its_eventgroups, vsomeip::event_type_e::ET_FIELD, + std::chrono::milliseconds::zero(), + false, true, nullptr, vsomeip::reliability_type_e::RT_UNRELIABLE); + + app_->register_message_handler(vsomeip::ANY_SERVICE, + vsomeip::ANY_INSTANCE, service_info_.shutdown_method_id, + std::bind(&unknown_sd_option_type_service::on_shutdown_method_called, this, + std::placeholders::_1)); + + app_->register_async_subscription_handler(service_info_.service_id, + 0x1, service_info_.eventgroup_id, + std::bind(&unknown_sd_option_type_service::subscription_handler_async, + this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, + std::placeholders::_4, std::placeholders::_5)); + + app_->start(); + } + + ~unknown_sd_option_type_service() { + offer_thread_.join(); + } + + void offer() { + app_->offer_service(service_info_.service_id, 0x1); + } + + void stop() { + app_->stop_offer_service(service_info_.service_id, 0x1); + app_->clear_all_handler(); + app_->stop(); + } + + void on_state(vsomeip::state_type_e _state) { + VSOMEIP_INFO << "Application " << app_->get_name() << " is " + << (_state == vsomeip::state_type_e::ST_REGISTERED ? + "registered." : "deregistered."); + + if (_state == vsomeip::state_type_e::ST_REGISTERED) { + std::lock_guard its_lock(mutex_); + wait_until_registered_ = false; + condition_.notify_one(); + } + } + + void on_shutdown_method_called(const std::shared_ptr &_message) { + app_->send(vsomeip::runtime::get()->create_response(_message)); + VSOMEIP_WARNING << "************************************************************"; + VSOMEIP_WARNING << "Shutdown method called -> going down!"; + VSOMEIP_WARNING << "************************************************************"; + std::lock_guard its_lock(mutex_); + wait_until_shutdown_method_called_ = false; + condition_.notify_one(); + } + + void run() { + VSOMEIP_DEBUG << '[' << std::setw(4) << std::setfill('0') << std::hex + << service_info_.service_id << "] Running"; + std::unique_lock its_lock(mutex_); + while (wait_until_registered_) { + condition_.wait(its_lock); + } + + VSOMEIP_DEBUG << '[' << std::setw(4) << std::setfill('0') << std::hex + << service_info_.service_id << "] Offering"; + offer(); + + while (!subscription_accepted_asynchronous_) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + async_subscription_handler_(true); + + while (wait_until_shutdown_method_called_) { + condition_.wait(its_lock); + } + std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + stop(); + } + + void subscription_handler_async(vsomeip::client_t _client, std::uint32_t, std::uint32_t, + bool _subscribed, const std::function& _cbk) { + VSOMEIP_WARNING << __func__ << ' ' << std::hex << _client << " subscribed." << _subscribed; + + async_subscription_handler_ = _cbk; + static int was_called = 0; + was_called++; + EXPECT_EQ(1, was_called); + EXPECT_TRUE(_subscribed); + subscription_accepted_asynchronous_ = true; + + } + +private: + struct unknown_sd_option_type_test::service_info service_info_; + std::shared_ptr app_; + + bool wait_until_registered_; + bool wait_until_shutdown_method_called_; + std::mutex mutex_; + std::condition_variable condition_; + std::atomic subscription_accepted_asynchronous_; + std::atomic subscription_accepted_synchronous_; + std::thread offer_thread_; + std::function async_subscription_handler_; +}; + +TEST(someip_unknown_sd_option_type_service, send_subscription) { + unknown_sd_option_type_service its_sample(unknown_sd_option_type_test::service); +} + + +#if defined(__linux__) +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} +#endif From 551ae0436a3b8be240f8ecbd9a6fcb1c8d32b4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 09:29:00 +0100 Subject: [PATCH 03/20] ensure endpoints before deletion --- .../endpoints/src/server_endpoint_impl.cpp | 4 ++-- implementation/routing/src/routing_manager_impl.cpp | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/implementation/endpoints/src/server_endpoint_impl.cpp b/implementation/endpoints/src/server_endpoint_impl.cpp index 120175367..a58489ac1 100644 --- a/implementation/endpoints/src/server_endpoint_impl.cpp +++ b/implementation/endpoints/src/server_endpoint_impl.cpp @@ -798,14 +798,14 @@ void server_endpoint_impl::flush_cbk( template void server_endpoint_impl::remove_stop_handler(service_t _service) { - - std::ostream&& its_services_log{VSOMEIP_INFO}; + std::stringstream its_services_log; its_services_log << __func__ << ": "; std::lock_guard its_lock{mutex_}; for (const auto &its_service : prepare_stop_handlers_) its_services_log << std::hex << std::setw(4) << std::setfill('0') << its_service.first << ' '; + VSOMEIP_INFO << its_services_log.str(); prepare_stop_handlers_.erase(_service); } diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index 79f408045..f5329e7ae 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -3797,6 +3797,13 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) { << std::hex << std::setw(4) << std::setfill('0') << its_service.first << "." << std::hex << std::setw(4) << std::setfill('0') << its_instance.first << "]"; + // Remove the service from the offer_commands_ and prepare_stop_handlers_ to force the next offer to be processed + offer_commands_.erase(std::make_pair(its_service.first, its_instance.first)); + if (has_reliable) + its_instance.second->get_endpoint(true)->remove_stop_handler(its_service.first); + if (has_unreliable) + its_instance.second->get_endpoint(false)->remove_stop_handler(its_service.first); + del_routing_info(its_service.first, its_instance.first, has_reliable, has_unreliable); std::lock_guard its_lock(pending_offers_mutex_); @@ -3804,12 +3811,6 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) { if (its_pending_offer != pending_offers_.end()) its_pending_offer->second.erase(its_instance.first); - // Remove the service from the offer_commands_ and prepare_stop_handlers_ to force the next offer to be processed - offer_commands_.erase(std::make_pair(its_service.first, its_instance.first)); - if (has_reliable) - its_instance.second->get_endpoint(true)->remove_stop_handler(its_service.first); - if (has_unreliable) - its_instance.second->get_endpoint(false)->remove_stop_handler(its_service.first); } VSOMEIP_WARNING << "Service " << std::hex << std::setfill('0') From 25b7cc1917cb37eec17fb074c2f881b4e3338eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 09:33:30 +0100 Subject: [PATCH 04/20] Improve "end of file" error handling --- .../endpoints/src/local_uds_client_endpoint_impl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp b/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp index 56c621dbc..cbe7185f0 100644 --- a/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp @@ -258,6 +258,11 @@ void local_uds_client_endpoint_impl::receive_cbk( if (_error == boost::asio::error::operation_aborted) { // endpoint was stopped return; + } else if (_error == boost::asio::error::eof) { + std::lock_guard its_lock(mutex_); + sending_blocked_ = false; + queue_.clear(); + queue_size_ = 0; } else if (_error == boost::asio::error::connection_reset || _error == boost::asio::error::bad_descriptor) { restart(true); From 40509c35d216a1854a916f1147e49fe534d476d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 09:38:04 +0100 Subject: [PATCH 05/20] Enable debouncing of events & selective events --- implementation/routing/include/event.hpp | 1 + implementation/routing/src/event.cpp | 8 +++- .../routing/src/routing_manager_base.cpp | 42 +++++++------------ 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/implementation/routing/include/event.hpp b/implementation/routing/include/event.hpp index fd43638d2..447aff84a 100644 --- a/implementation/routing/include/event.hpp +++ b/implementation/routing/include/event.hpp @@ -179,6 +179,7 @@ class event std::atomic is_cache_placeholder_; epsilon_change_func_t epsilon_change_func_; + bool has_default_epsilon_change_func_; std::atomic reliability_; diff --git a/implementation/routing/src/event.cpp b/implementation/routing/src/event.cpp index 8f5b44ce4..371cba7bd 100644 --- a/implementation/routing/src/event.cpp +++ b/implementation/routing/src/event.cpp @@ -37,6 +37,7 @@ event::event(routing_manager *_routing, bool _is_shadow) is_cache_placeholder_(false), epsilon_change_func_(std::bind(&event::has_changed, this, std::placeholders::_1, std::placeholders::_2)), + has_default_epsilon_change_func_(true), reliability_(reliability_type_e::RT_UNKNOWN) { } @@ -297,6 +298,7 @@ event::set_epsilon_change_function( std::lock_guard its_lock(mutex_); if (_epsilon_change_func) { epsilon_change_func_ = _epsilon_change_func; + has_default_epsilon_change_func_ = false; } } @@ -685,7 +687,8 @@ event::get_filtered_subscribers(bool _force) { if (filters_.empty()) { - bool must_forward = (type_ != event_type_e::ET_FIELD + bool must_forward = ((type_ != event_type_e::ET_FIELD + && has_default_epsilon_change_func_) || _force || epsilon_change_func_(its_payload, its_payload_update)); @@ -704,7 +707,8 @@ event::get_filtered_subscribers(bool _force) { its_filtered_subscribers.insert(s); } else { if (is_allowed == 0xff) { - is_allowed = (type_ != event_type_e::ET_FIELD + is_allowed = ((type_ != event_type_e::ET_FIELD + && has_default_epsilon_change_func_) || _force || epsilon_change_func_(its_payload, its_payload_update) ? 0x01 : 0x00); diff --git a/implementation/routing/src/routing_manager_base.cpp b/implementation/routing/src/routing_manager_base.cpp index 047e6566e..ec87855e2 100644 --- a/implementation/routing/src/routing_manager_base.cpp +++ b/implementation/routing/src/routing_manager_base.cpp @@ -418,12 +418,6 @@ void routing_manager_base::register_event(client_t _client, std::shared_ptr its_debounce = configuration_->get_debounce(host_->get_name(), _service, _instance, _notifier); if (its_debounce) { - VSOMEIP_WARNING << "Using debounce configuration for " - << " SOME/IP event " - << std::hex << std::setfill('0') - << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." - << std::setw(4) << _notifier << "."; std::stringstream its_debounce_parameters; its_debounce_parameters << "(on_change=" << (its_debounce->on_change_ ? "true" : "false") @@ -433,8 +427,18 @@ void routing_manager_base::register_event(client_t _client, << ", " << std::hex << (int)i.second << ") "; its_debounce_parameters << "], interval=" << std::dec << its_debounce->interval_ << ")"; - VSOMEIP_WARNING << "Debounce parameters: " + + VSOMEIP_WARNING << "Using debounce configuration for " + << " SOME/IP event " + << std::hex << std::setw(4) << std::setfill('0') + << _service << "." + << std::hex << std::setw(4) << std::setfill('0') + << _instance << "." + << std::hex << std::setw(4) << std::setfill('0') + << _notifier << "." + << " Debounce parameters: " << its_debounce_parameters.str(); + _epsilon_change_func = [its_debounce]( const std::shared_ptr &_old, const std::shared_ptr &_new) { @@ -503,28 +507,12 @@ void routing_manager_base::register_event(client_t _client, // Create a new callback for this client if filter interval is used register_debounce(its_debounce, _client, its_event); } else { - if (!_is_shadow && is_routing_manager()) { - _epsilon_change_func = [](const std::shared_ptr &_old, - const std::shared_ptr &_new) { - bool is_change = (_old->get_length() != _new->get_length()); - if (!is_change) { - std::size_t its_pos = 0; - const byte_t *its_old_data = _old->get_data(); - const byte_t *its_new_data = _new->get_data(); - while (!is_change && its_pos < _old->get_length()) { - is_change = (*its_old_data++ != *its_new_data++); - its_pos++; - } - } - return is_change; - }; - } - else { + if (_is_shadow || !is_routing_manager()) { _epsilon_change_func = [](const std::shared_ptr &_old, const std::shared_ptr &_new) { - (void)_old; - (void)_new; - return true; + (void)_old; + (void)_new; + return true; }; } } From 6df3e680e98b5fc32a7c06e154163d8e378ceb4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 10:12:22 +0100 Subject: [PATCH 06/20] Revert "Test - Processing SD messages with unknown type" --- .gitignore | 2 - test/common/CMakeLists.txt | 2 - test/common/someip_lib/CMakeLists.txt | 9 - .../someip_lib/communication/CMakeLists.txt | 39 --- .../communication/include/com/comcommon.hpp | 15 -- .../include/com/comconstants.hpp | 29 --- .../communication/include/com/comutils.hpp | 47 ---- .../someip_lib/communication/src/comutils.cpp | 46 ---- .../someip_lib/serialization/CMakeLists.txt | 33 --- .../serialization/dynamicbytearraypayload.hpp | 103 -------- .../include/serialization/fragmentpayload.hpp | 132 ---------- .../include/serialization/podpayload.hpp | 104 -------- .../include/serialization/serializable.hpp | 59 ----- .../serialization/staticbytearraypayload.hpp | 148 ----------- .../include/serialization/streampayload.hpp | 164 ------------ .../src/dynamicbytearraypayload.cpp | 117 --------- test/common/someip_lib/someip/CMakeLists.txt | 46 ---- .../someip/sd/options/ipv4endpointoption.hpp | 75 ------ .../someip/include/someip/sd/someipsd.hpp | 125 --------- .../include/someip/sd/someipsdentries.hpp | 22 -- .../someip/sd/someipsdentriesarray.hpp | 210 --------------- .../include/someip/sd/someipsdentry.hpp | 137 ---------- .../include/someip/sd/someipsdoption.hpp | 137 ---------- .../include/someip/sd/someipsdoptions.hpp | 22 -- .../someip/include/someip/someipmessage.hpp | 198 -------------- .../include/someip/types/primitives.hpp | 91 ------- .../src/sd/options/ipv4endpointoption.cpp | 126 --------- .../someip_lib/someip/src/sd/someipsd.cpp | 207 --------------- .../someip/src/sd/someipsdentry.cpp | 225 ---------------- .../someip/src/sd/someipsdoption.cpp | 71 ----- .../someip_lib/someip/src/someipmessage.cpp | 244 ------------------ test/common/someip_lib/utils/CMakeLists.txt | 29 --- .../someip_lib/utils/include/utils/logger.hpp | 53 ---- .../someip_lib/utils/include/utils/utils.hpp | 79 ------ test/common/someip_lib/utils/src/logger.cpp | 90 ------- test/common/someip_lib/utils/src/utils.cpp | 87 ------- test/common/src/utility.cpp | 12 +- test/common/src/vsomeip_app_utilities.cpp | 18 +- test/network_tests/CMakeLists.txt | 79 ------ ...unknown_sd_option_type_test_master.json.in | 55 ---- ...n_sd_option_type_test_master_starter.sh.in | 63 ----- .../unknown_sd_option_type_test_client.cpp | 222 ---------------- .../unknown_sd_option_type_test_globals.hpp | 53 ---- .../unknown_sd_option_type_test_service.cpp | 173 ------------- 44 files changed, 20 insertions(+), 3978 deletions(-) delete mode 100644 test/common/someip_lib/CMakeLists.txt delete mode 100644 test/common/someip_lib/communication/CMakeLists.txt delete mode 100644 test/common/someip_lib/communication/include/com/comcommon.hpp delete mode 100644 test/common/someip_lib/communication/include/com/comconstants.hpp delete mode 100644 test/common/someip_lib/communication/include/com/comutils.hpp delete mode 100644 test/common/someip_lib/communication/src/comutils.cpp delete mode 100644 test/common/someip_lib/serialization/CMakeLists.txt delete mode 100644 test/common/someip_lib/serialization/include/serialization/dynamicbytearraypayload.hpp delete mode 100644 test/common/someip_lib/serialization/include/serialization/fragmentpayload.hpp delete mode 100644 test/common/someip_lib/serialization/include/serialization/podpayload.hpp delete mode 100644 test/common/someip_lib/serialization/include/serialization/serializable.hpp delete mode 100644 test/common/someip_lib/serialization/include/serialization/staticbytearraypayload.hpp delete mode 100644 test/common/someip_lib/serialization/include/serialization/streampayload.hpp delete mode 100644 test/common/someip_lib/serialization/src/dynamicbytearraypayload.cpp delete mode 100644 test/common/someip_lib/someip/CMakeLists.txt delete mode 100644 test/common/someip_lib/someip/include/someip/sd/options/ipv4endpointoption.hpp delete mode 100644 test/common/someip_lib/someip/include/someip/sd/someipsd.hpp delete mode 100644 test/common/someip_lib/someip/include/someip/sd/someipsdentries.hpp delete mode 100644 test/common/someip_lib/someip/include/someip/sd/someipsdentriesarray.hpp delete mode 100644 test/common/someip_lib/someip/include/someip/sd/someipsdentry.hpp delete mode 100644 test/common/someip_lib/someip/include/someip/sd/someipsdoption.hpp delete mode 100644 test/common/someip_lib/someip/include/someip/sd/someipsdoptions.hpp delete mode 100644 test/common/someip_lib/someip/include/someip/someipmessage.hpp delete mode 100644 test/common/someip_lib/someip/include/someip/types/primitives.hpp delete mode 100644 test/common/someip_lib/someip/src/sd/options/ipv4endpointoption.cpp delete mode 100644 test/common/someip_lib/someip/src/sd/someipsd.cpp delete mode 100644 test/common/someip_lib/someip/src/sd/someipsdentry.cpp delete mode 100644 test/common/someip_lib/someip/src/sd/someipsdoption.cpp delete mode 100644 test/common/someip_lib/someip/src/someipmessage.cpp delete mode 100644 test/common/someip_lib/utils/CMakeLists.txt delete mode 100644 test/common/someip_lib/utils/include/utils/logger.hpp delete mode 100644 test/common/someip_lib/utils/include/utils/utils.hpp delete mode 100644 test/common/someip_lib/utils/src/logger.cpp delete mode 100644 test/common/someip_lib/utils/src/utils.cpp delete mode 100644 test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master.json.in delete mode 100755 test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master_starter.sh.in delete mode 100644 test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_client.cpp delete mode 100644 test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_globals.hpp delete mode 100644 test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_service.cpp diff --git a/.gitignore b/.gitignore index 25e0b35d2..a40692934 100644 --- a/.gitignore +++ b/.gitignore @@ -149,8 +149,6 @@ /test/network_tests/security_tests/security_test_local_config.json /test/network_tests/pending_subscription_tests/pending_subscription_test_master.json /test/network_tests/pending_subscription_tests/pending_subscription_test_master_starter.sh -/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_master.json -/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_master_starter.sh /test/network_tests/malicious_data_tests/malicious_data_test_master.json /test/network_tests/malicious_data_tests/malicious_data_test_master_starter.sh /test/network_tests/e2e_tests/e2e_profile_04_test_client_external.json diff --git a/test/common/CMakeLists.txt b/test/common/CMakeLists.txt index b66fe3c6a..d4d145347 100644 --- a/test/common/CMakeLists.txt +++ b/test/common/CMakeLists.txt @@ -3,8 +3,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -add_subdirectory(someip_lib) - project (vsomeip_utilities) # ---------------------------------------------------------------------------- diff --git a/test/common/someip_lib/CMakeLists.txt b/test/common/someip_lib/CMakeLists.txt deleted file mode 100644 index ad80961b0..000000000 --- a/test/common/someip_lib/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -add_subdirectory(utils) -add_subdirectory(serialization) -add_subdirectory(communication) -add_subdirectory(someip) diff --git a/test/common/someip_lib/communication/CMakeLists.txt b/test/common/someip_lib/communication/CMakeLists.txt deleted file mode 100644 index 1b68644f9..000000000 --- a/test/common/someip_lib/communication/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -project (communication) - -# ---------------------------------------------------------------------------- -# Include all source files (cpp/hpp) -# ---------------------------------------------------------------------------- -file (GLOB SRC src/*.cpp src/*.hpp) -file (GLOB INC include/*.hpp include/com/*.hpp) - -# ---------------------------------------------------------------------------- -# Declare the library -# ---------------------------------------------------------------------------- -add_library ( - ${PROJECT_NAME} SHARED - ${SRC} - ${INC} -) - -target_link_libraries ( - ${PROJECT_NAME} - PUBLIC - ${BOOST_LIBS} - utils - serialization -) - -# ---------------------------------------------------------------------------- -# Specify here the include directories exported -# by this library -# ---------------------------------------------------------------------------- -target_include_directories ( - ${PROJECT_NAME} - PUBLIC include - PRIVATE src -) diff --git a/test/common/someip_lib/communication/include/com/comcommon.hpp b/test/common/someip_lib/communication/include/com/comcommon.hpp deleted file mode 100644 index 50c2063f2..000000000 --- a/test/common/someip_lib/communication/include/com/comcommon.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __COMCOMMON_HPP__ -#define __COMCOMMON_HPP__ - -#include - -// Namespace aliasing -// In preparation for future STL's Networking TS implementation switch, if needed... -namespace asio = boost::asio; - -#endif // __COMCOMMON_HPP__ diff --git a/test/common/someip_lib/communication/include/com/comconstants.hpp b/test/common/someip_lib/communication/include/com/comconstants.hpp deleted file mode 100644 index 2df812dc5..000000000 --- a/test/common/someip_lib/communication/include/com/comconstants.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __COMCONSTANTS_HPP__ -#define __COMCONSTANTS_HPP__ - -#include - -namespace vsomeip_utilities { -namespace com { - -/** - * @brief Message terminator string - * - */ -constexpr std::string_view MSG_TERMINATOR = { "\n" }; - -/** - * @brief Default message buffer size - * - */ -constexpr int DEFAULT_BUFFER_SIZE = 4096; - -} // com -} // vsomeip_utilities - -#endif // __COMCONSTANTS_HPP__ diff --git a/test/common/someip_lib/communication/include/com/comutils.hpp b/test/common/someip_lib/communication/include/com/comutils.hpp deleted file mode 100644 index fdfbfa518..000000000 --- a/test/common/someip_lib/communication/include/com/comutils.hpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __COMUTILS_HPP__ -#define __COMUTILS_HPP__ - -#include - -#include - -namespace vsomeip_utilities { -namespace com { -namespace utils { - -/** - * @brief Convert string into an asio::ip::address_v4 - * - * @param _addr String address - * @param _ec resulting error code - * @return asio::ip::address_v4 - */ -asio::ip::address_v4 ipv4AddressFromString(const std::string& _addr, std::error_code& _ec); - -/** - * @brief Convert string into an asio::ip::address_v6 - * - * @param _addr String address - * @param _ec resulting error code - * @return asio::ip::address_v6 - */ -asio::ip::address_v6 ipv6AddressFromString(const std::string& _addr, std::error_code& _ec); - -/** - * @brief Convert uint32_t into an asio::ip::address_v4 - * - * @param _addr uint32_t address - * @return asio::ip::address_v4 - */ -[[nodiscard]] asio::ip::address_v4 ipv4AddressFromInt(std::uint32_t _add); - -} // utils -} // com -} // vsomeip_utilities - -#endif // __COMUTILS_HPP__ diff --git a/test/common/someip_lib/communication/src/comutils.cpp b/test/common/someip_lib/communication/src/comutils.cpp deleted file mode 100644 index 119512e83..000000000 --- a/test/common/someip_lib/communication/src/comutils.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -#include -#include - -#include - -namespace vsomeip_utilities { -namespace com { -namespace utils { - -asio::ip::address_v4 ipv4AddressFromString(const std::string& _addr, std::error_code& _ec) { - // Build address from string - boost::system::error_code ec; - asio::ip::address_v4 addr = asio::ip::make_address_v4(_addr, ec); - - // convert resulting error code to std::error_code - _ec = vsomeip_utilities::utils::intToStdError(ec.value()); - - return addr; -} - -asio::ip::address_v6 ipv6AddressFromString(const std::string& _addr, std::error_code& _ec) { - // Build address from string - boost::system::error_code ec; - asio::ip::address_v6 addr = asio::ip::make_address_v6(_addr, ec); - - // convert resulting error code to std::error_code - _ec = vsomeip_utilities::utils::intToStdError(ec.value()); - - return addr; -} - -asio::ip::address_v4 ipv4AddressFromInt(std::uint32_t _addr) { - // Build address from uint - return asio::ip::make_address_v4(_addr); -} - -} // utils -} // com -} // vsomeip_utilities diff --git a/test/common/someip_lib/serialization/CMakeLists.txt b/test/common/someip_lib/serialization/CMakeLists.txt deleted file mode 100644 index 5f8df0b5d..000000000 --- a/test/common/someip_lib/serialization/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -project (serialization) - -# ---------------------------------------------------------------------------- -# Include all source files (cpp/hpp) -# ---------------------------------------------------------------------------- -file (GLOB SRC src/*.cpp src/*.hpp) -file (GLOB INC include/*.hpp include/serialization/*.hpp) - -# ---------------------------------------------------------------------------- -# Declare the library -# ---------------------------------------------------------------------------- -add_library ( - ${PROJECT_NAME} SHARED - ${SRC} - ${INC} -) - -target_link_libraries ( - ${PROJECT_NAME} - PUBLIC - ${BOOST_LIBS} - utils -) - -# ---------------------------------------------------------------------------- -# Specify here the include directories exported -# by this library -# ---------------------------------------------------------------------------- -target_include_directories ( - ${PROJECT_NAME} - PUBLIC include - PRIVATE src -) diff --git a/test/common/someip_lib/serialization/include/serialization/dynamicbytearraypayload.hpp b/test/common/someip_lib/serialization/include/serialization/dynamicbytearraypayload.hpp deleted file mode 100644 index dc28364e6..000000000 --- a/test/common/someip_lib/serialization/include/serialization/dynamicbytearraypayload.hpp +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __DYNAMICBYTEARRAYPAYLOAD_HPP__ -#define __DYNAMICBYTEARRAYPAYLOAD_HPP__ - -#include - -#include - -namespace vsomeip_utilities { -namespace serialization { - -class DynamicByteArrayPayloadBuilder; - -class DynamicByteArrayPayload : public Serializable { -public: - // CTor - explicit DynamicByteArrayPayload(const std::size_t _size = 0) : m_payload(_size, 0) { } - - // Copy/Move CTors - DynamicByteArrayPayload(const DynamicByteArrayPayload &_other); - DynamicByteArrayPayload(const DynamicByteArrayPayload &&_other); - - // Copy/Move assignment operators - virtual const DynamicByteArrayPayload &operator=(const DynamicByteArrayPayload &_other); - virtual const DynamicByteArrayPayload &operator=(const DynamicByteArrayPayload &&_other); - - /** - * @brief Create Fragment Builder - * - * @return DynamicByteArrayPayload - */ - static DynamicByteArrayPayloadBuilder create(); - - /** - * @brief The Serializable object definition size - * - * @return std::size_t - */ - inline static std::size_t size() { return 0; } - - /** - * @brief The Serializable object instance actual size - * - * @return std::size_t - */ - std::size_t actualSize() const override; - - /** - * @brief Deserialize data from stream - * - * @param _stream - */ - virtual std::size_t deserialize(std::istream &_stream) override; - - /** - * @brief Serialize data to stream - * - * @param _stream - */ - virtual std::size_t serialize(std::ostream &_stream) const override; - - virtual void setPayload(std::initializer_list &_payload); - virtual const std::vector &payload() const; - - /** - * @brief Print to stdout utility method - * - */ - virtual void print() const override; - - bool operator==(const DynamicByteArrayPayload &_other) const; - -protected: - std::vector m_payload; -}; - -/** - * @brief Builder - * - */ -class DynamicByteArrayPayloadBuilder { -public: - // CTor/DTor - DynamicByteArrayPayloadBuilder() = default; - virtual ~DynamicByteArrayPayloadBuilder() = default; - - operator DynamicByteArrayPayload() const; - - // Setter Methods - DynamicByteArrayPayloadBuilder &payload(std::initializer_list &&_payload); - -private: - DynamicByteArrayPayload m_entry; -}; - -} // serialization -} // vsomeip_utilities - -#endif // __DYNAMICBYTEARRAYPAYLOAD_HPP__ diff --git a/test/common/someip_lib/serialization/include/serialization/fragmentpayload.hpp b/test/common/someip_lib/serialization/include/serialization/fragmentpayload.hpp deleted file mode 100644 index d748dfd2c..000000000 --- a/test/common/someip_lib/serialization/include/serialization/fragmentpayload.hpp +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __FRAGMENTPAYLOAD_HPP__ -#define __FRAGMENTPAYLOAD_HPP__ - -#include - -#include -#include - -namespace vsomeip_utilities { -namespace serialization { - -template -class FragmentPayload - : public serialization::PodPayload - , public serialization::StreamPayload { -public: - // CTor - explicit FragmentPayload() = default; - - // Copy/Move CTors - FragmentPayload(const FragmentPayload& _other) - : serialization::PodPayload { _other } - , serialization::StreamPayload { _other } {} - - FragmentPayload(const FragmentPayload&& _other) - : serialization::PodPayload { _other } - , serialization::StreamPayload { _other } {} - - // Copy/Move assignment operators - const FragmentPayload& operator=(const FragmentPayload& _other) { - serialization::PodPayload::operator=(_other); - serialization::StreamPayload::operator=(_other); - - return *this; - } - - const FragmentPayload& operator=(const FragmentPayload&& _other) { - serialization::PodPayload::operator=(_other); - serialization::StreamPayload::operator=(_other); - - return *this; - } - - /** - * @brief The Serializable object definition size - * - * @return std::size_t - */ - static std::size_t size() { - return serialization::PodPayload::size(); - } - - /** - * @brief The Serializable object instance actual size - * - * @return std::size_t - */ - virtual std::size_t actualSize() const override { - return size() + serialization::StreamPayload::streamSize(); - } - - /** - * @brief Returns the payload defined size (as referenced in the header) - * - * @return std::size_t - */ - virtual std::size_t payloadSize() const = 0; - - /** - * @brief Deserialize data from stream - * - * @param _stream - */ - virtual std::size_t deserialize(std::istream& _stream) override { - std::size_t headerBytes = 0; - std::size_t payloadBytes = 0; - - headerBytes = serialization::PodPayload::deserialize(_stream); - - if (headerBytes == serialization::PodPayload::size()) { - payloadBytes = serialization::StreamPayload::readFromStream(_stream, payloadSize()); - - if (payloadBytes != payloadSize()) { - std::cerr << __func__ - << ": Error deserializing Payload, deserialized length mismatches header length!\n"; - } - - } else { - std::cerr << __func__ - << ": Error deserializing Header, deserialized length mismatches header size!\n"; - } - - return headerBytes + payloadBytes; - } - - /** - * @brief Serialize data to stream - * - * @param _stream - */ - virtual std::size_t serialize(std::ostream& _stream) const override { - std::size_t headerBytes = 0; - std::size_t payloadBytes = 0; - - headerBytes += serialization::PodPayload::serialize(_stream); - if (headerBytes == serialization::PodPayload::size()) { - payloadBytes = serialization::StreamPayload::writeToStream(_stream); - - if (payloadBytes != payloadSize()) { - std::cerr << __func__ - << ": Error serializing Payload, serialized length mismatches header length!\n"; - } - - } else { - std::cerr << __func__ - << ": Error serializing Header, serialized length mismatches header size!\n"; - } - - - return headerBytes + payloadBytes; - } -}; - -} // serialization -} // vsomeip_utilities - -#endif // __FRAGMENTPAYLOAD_HPP__ diff --git a/test/common/someip_lib/serialization/include/serialization/podpayload.hpp b/test/common/someip_lib/serialization/include/serialization/podpayload.hpp deleted file mode 100644 index 968597e55..000000000 --- a/test/common/someip_lib/serialization/include/serialization/podpayload.hpp +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __PODPAYLOAD_HPP__ -#define __PODPAYLOAD_HPP__ - -#include -#include - -namespace vsomeip_utilities { -namespace serialization { - -/** - * @brief Plain old Data Payload representation - * - * @param PayloadType - */ -template -class PodPayload - : public serialization::Serializable { -public: - // CTor - PodPayload() = default; - - // Copy/Move CTors - PodPayload(const PodPayload& _other) : m_podPayload { _other.m_podPayload } {} - PodPayload(const PodPayload&& _other) : m_podPayload { std::move(_other.m_podPayload) } {} - - // Copy/Move assignment operators - virtual const PodPayload& operator=(const PodPayload& _other) { - m_podPayload = _other.m_podPayload; - return *this; - } - - virtual const PodPayload& operator=(const PodPayload&& _other) { - m_podPayload = std::move(_other.m_podPayload); - return *this; - } - - /** - * @brief The Serializable object definition size - * - * @return std::size_t - */ - static std::size_t size() { - return sizeof(PayloadType); - } - - /** - * @brief The Serializable object instance actual size - * - * @return std::size_t - */ - virtual std::size_t actualSize() const override { - return size(); - } - - /** - * @brief Deserialize data from stream - * - * @param _stream - */ - virtual std::size_t deserialize(std::istream& _stream) { - PayloadType bigEndianPayload; - _stream.read(reinterpret_cast(&bigEndianPayload), sizeof(PayloadType)); - m_podPayload = utils::swapEndianness(bigEndianPayload); - - if (_stream.fail()) { - std::cerr << __func__ << ": Failed to deserialize POD!\n"; - return 0; - } else { - return size(); - } - } - - /** - * @brief Serialize data to stream - * - * @param _stream - */ - virtual std::size_t serialize(std::ostream& _stream) const { - - PayloadType bigEndianPayload = utils::swapEndianness(m_podPayload); - _stream.write(reinterpret_cast(&bigEndianPayload), sizeof(PayloadType)); - - - if (_stream.fail()) { - std::cerr << __func__ << ": Failed to serialize POD!\n"; - return 0; - } else { - return size(); - } - } - -protected: - PayloadType m_podPayload; -}; - -} // namespace serialization -} // namespace vsomeip_utilities - -#endif // __PODPAYLOAD_HPP__ diff --git a/test/common/someip_lib/serialization/include/serialization/serializable.hpp b/test/common/someip_lib/serialization/include/serialization/serializable.hpp deleted file mode 100644 index dc4868545..000000000 --- a/test/common/someip_lib/serialization/include/serialization/serializable.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __SERIALIZABLE_HPP__ -#define __SERIALIZABLE_HPP__ - -#include - -namespace vsomeip_utilities { -namespace serialization { - -/** - * @brief Abstract Serializable class - * - */ -class Serializable { -public: - - /** - * @brief The Serializable object definition size - * - * @return std::size_t - */ - static std::size_t size() { return sizeof(Serializable); }; - - /** - * @brief The Serializable object instance actual size - * - * @return std::size_t - */ - virtual std::size_t actualSize() const = 0; - - /** - * @brief Deserialize data from stream - * - * @param _stream - */ - virtual std::size_t deserialize(std::istream& _stream) = 0; - - /** - * @brief Serialize data to stream - * - * @param _stream - */ - virtual std::size_t serialize(std::ostream& _stream) const = 0; - - /** - * @brief Print to stdout utility method - * - */ - virtual void print() const = 0; -}; - -} // com -} // vsomeip_utilities - -#endif // __SERIALIZABLE_HPP__ diff --git a/test/common/someip_lib/serialization/include/serialization/staticbytearraypayload.hpp b/test/common/someip_lib/serialization/include/serialization/staticbytearraypayload.hpp deleted file mode 100644 index 44dd91275..000000000 --- a/test/common/someip_lib/serialization/include/serialization/staticbytearraypayload.hpp +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __STATICBYTEARRAYPAYLOAD_HPP__ -#define __STATICBYTEARRAYPAYLOAD_HPP__ - -#include -#include - -#include - - -namespace vsomeip_utilities { -namespace serialization { - -template -class StaticByteArrayPayloadBuilder; - -template -class StaticByteArrayPayload : public DynamicByteArrayPayload { -public: - // CTor - explicit StaticByteArrayPayload() - : DynamicByteArrayPayload(Size) {} - - /** - * @brief Create Fragment Builder - * - * @return StaticByteArrayPayloadBuilder - */ - static StaticByteArrayPayloadBuilder create() { - return StaticByteArrayPayloadBuilder(); - } - - /** - * @brief The Serializable object definition size - * - * @return std::size_t - */ - inline static std::size_t size() { - return Size; - } - - /** - * @brief The Serializable object instance actual size - * - * @return std::size_t - */ - std::size_t actualSize() const override { - return size(); - } - - /** - * @brief Deserialize data from stream - * - * @param _stream - */ - std::size_t deserialize(std::istream& _stream) override { - std::size_t deserializedBytes = 0; - - // Read backwards into vector to convert from Big to Little Endian byte ordering - for (std::size_t i = m_payload.size(); i > 0; --i) { - // Read byte into vector and break if operation fails - if (!_stream >> m_payload[i - 1]) { - break; - } else { - deserializedBytes++; - } - } - - if (_stream.fail()) { - std::cerr << __func__ << ": Failed to deserialize Byte Array!\n"; - } - - return deserializedBytes; - } - - virtual void setPayload(std::initializer_list& _payload) override { - // Ensure initializer list size matches the payload size - assert(_payload.size() == Size); - - DynamicByteArrayPayload::setPayload(_payload); - } - - /** - * @brief Print to stdout utility method - * - */ - virtual void print() const override { - // Store original format - std::ios_base::fmtflags prevFmt(std::cout.flags()); - - // Print payload - std::cout << "[" __FILE__ "]" - << "\n\tSize: " << Size - << "\n\t--\n\tpayload: " - << std::hex - << std::showbase - << "{\n"; - - for (auto byte : m_payload) { - std::cout << unsigned(byte) << ' '; - } - - std::cout << "}\n"; - - // Restore original format - std::cout.flags(prevFmt); - } -}; - -/** - * @brief Builder - * - */ -template -class StaticByteArrayPayloadBuilder { -public: - // CTor/DTor - StaticByteArrayPayloadBuilder() = default; - virtual ~StaticByteArrayPayloadBuilder() = default; - - // Delete default CTors and assignment operators - StaticByteArrayPayloadBuilder(const StaticByteArrayPayloadBuilder&) = delete; - StaticByteArrayPayloadBuilder(const StaticByteArrayPayloadBuilder&&) = delete; - const StaticByteArrayPayloadBuilder& operator=(const StaticByteArrayPayloadBuilder&) = delete; - const StaticByteArrayPayloadBuilder& operator=(const StaticByteArrayPayloadBuilder&&) = delete; - - operator StaticByteArrayPayload() const { - return std::move(m_entry); - } - - // Setter Methods - StaticByteArrayPayloadBuilder& payload(std::initializer_list&& _payload) { - m_entry.setPayload(_payload); - return *this; - } - -private: - StaticByteArrayPayload m_entry; -}; - -} // serialization -} // vsomeip_utilities - -#endif // __STATICBYTEARRAYPAYLOAD_HPP__ diff --git a/test/common/someip_lib/serialization/include/serialization/streampayload.hpp b/test/common/someip_lib/serialization/include/serialization/streampayload.hpp deleted file mode 100644 index 253b88bcd..000000000 --- a/test/common/someip_lib/serialization/include/serialization/streampayload.hpp +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __STREAMPAYLOAD_HPP__ -#define __STREAMPAYLOAD_HPP__ - -#include - -#include -#include - -namespace vsomeip_utilities { -namespace serialization { - -class StreamPayload { -public: - StreamPayload() = default; - - StreamPayload(const StreamPayload &_other) { - commit(boost::asio::buffer_copy(prepareBuffer(_other.m_payloadBuffer.size()), - _other.m_payloadBuffer.data())); - } - - const StreamPayload &operator=(const StreamPayload &_other) { - commit(boost::asio::buffer_copy(prepareBuffer(_other.m_payloadBuffer.size()), - _other.m_payloadBuffer.data())); - return *this; - } - - StreamPayload(const StreamPayload &&_other) { - commit(boost::asio::buffer_copy(prepareBuffer(_other.m_payloadBuffer.size()), - _other.m_payloadBuffer.data())); - } - - const StreamPayload &operator=(const StreamPayload &&_other) { - commit(boost::asio::buffer_copy(prepareBuffer(_other.m_payloadBuffer.size()), - _other.m_payloadBuffer.data())); - - return *this; - } - - /** - * @brief Pushes the provided payload into the container - * - * @tparam T source payload type - * @param _payload source payload - * @return the size in bytes of the pushed data - */ - template - std::size_t push(const T &_payload) { - std::ostream os(&m_payloadBuffer); - std::size_t processedBytes = _payload.serialize(os); - - if (processedBytes > 0) { - commit(0); - // TODO: This needs top be assessed, if we commit a number of processed bytes greater - // than 0 the streambuf available bytes are set to 2x that number. Commiting 0 bytes - // appears to workaround this behavior. - } - - return processedBytes; - } - - /** - * @brief Populates the provided entry from the payload's next memory location - * - * @tparam T target payload type - * @param _payload target payload - * @return the size in bytes of the pulled data - */ - template - std::size_t pull(T &_payload) { - std::istream is(&m_payloadBuffer); - std::size_t processedBytes = _payload.deserialize(is); - - return processedBytes; - } - -protected: - std::size_t streamSize() const { return m_payloadBuffer.size(); } - - /** - * @brief Commits the next _size bytes into the input stream - * - * @param _size - */ - void commit(const std::size_t _size) { m_payloadBuffer.commit(_size); } - - /** - * @brief Consumes the nest _size bytes from the input stream - * - * @param _size - */ - void consume(const std::size_t _size) { m_payloadBuffer.consume(_size); } - - /** - * @brief Prepares the internal stream buffer with provided size - * - * @param _size - * @return boost::asio::mutable_buffer Returns buffer handle - */ - boost::asio::mutable_buffer prepareBuffer(std::size_t _size) { - return m_payloadBuffer.prepare(_size); - } - - /** - * @brief Get a pointer to the first byte of the stream. - * - * @return unsigned char* - */ - const unsigned char *begin() { return static_cast(m_payloadBuffer.data().data()); }; - - /** - * @brief Get a pointer to the last byte of the stream. - * - * @return unsigned char* - */ - const unsigned char *end() { return begin() + m_payloadBuffer.size(); } - - std::size_t readFromStream(std::istream &_stream, const std::size_t _size) { - std::size_t processedBytes = 0; - - // Read into payload - _stream.read(reinterpret_cast(prepareBuffer(_size).data()), _size); - - // if payload read successfully... - if (!_stream.fail()) { - // flag data as available - commit(_size); - processedBytes += _size; - - } else { - std::cerr << __func__ << ": Failed to read " << _size << " bytes from stream!\n"; - } - - return processedBytes; - } - - std::size_t writeToStream(std::ostream &_stream) const { - std::size_t processedBytes = 0; - - // Serialize payload into stream - _stream.write(static_cast(m_payloadBuffer.data().data()), streamSize()); - - // if payload serialization successfull, account payload bytes... - if (!_stream.fail()) { - processedBytes += streamSize(); - } else { - std::cerr << __func__ << ": Failed to write " << streamSize() << " bytes from stream!\n"; - } - - return processedBytes; - } - -private: - boost::asio::streambuf m_payloadBuffer; -}; - -} // someip -} // vsomeip_utilities - -#endif // __STREAMPAYLOAD_HPP__ diff --git a/test/common/someip_lib/serialization/src/dynamicbytearraypayload.cpp b/test/common/someip_lib/serialization/src/dynamicbytearraypayload.cpp deleted file mode 100644 index 6755b4171..000000000 --- a/test/common/someip_lib/serialization/src/dynamicbytearraypayload.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -namespace vsomeip_utilities { -namespace serialization { - -DynamicByteArrayPayload::DynamicByteArrayPayload(const DynamicByteArrayPayload &_other) - : m_payload { _other.m_payload } { -} - -DynamicByteArrayPayload::DynamicByteArrayPayload(const DynamicByteArrayPayload &&_other) - : m_payload { std::move(_other.m_payload) } { -} - -const DynamicByteArrayPayload & -DynamicByteArrayPayload::operator=(const DynamicByteArrayPayload &_other) { - m_payload = _other.m_payload; - return *this; -} - -const DynamicByteArrayPayload & -DynamicByteArrayPayload::operator=(const DynamicByteArrayPayload &&_other) { - m_payload = std::move(_other.m_payload); - return *this; -} - -DynamicByteArrayPayloadBuilder DynamicByteArrayPayload::create() { - return DynamicByteArrayPayloadBuilder(); -} - -std::size_t DynamicByteArrayPayload::actualSize() const { - return m_payload.size(); -} - -std::size_t DynamicByteArrayPayload::deserialize(std::istream &_stream) { - std::size_t deserializedBytes = 0; - - // We want to read everything available in the stream - while (!_stream.fail()) { - char byte; - if (_stream.read(&byte, sizeof(byte))) { - m_payload.emplace(m_payload.begin(), static_cast(byte)); - deserializedBytes++; - } - } - - return deserializedBytes; -} - -std::size_t DynamicByteArrayPayload::serialize(std::ostream &_stream) const { - std::size_t serializedBytes = 0; - - // Write into stream backwards to convert from Little to Big Endian byte ordering - for (std::size_t i = m_payload.size(); i > 0; --i) { - // write byte into stream and break if operation fails - if (!(_stream.write(reinterpret_cast(&m_payload[i - 1]), sizeof(std::uint8_t)))) { - break; - } else { - serializedBytes++; - } - } - - if (_stream.fail()) { - std::cerr << __func__ << ": Failed to serialize Byte Array!\n"; - } - - return serializedBytes; -} - -void DynamicByteArrayPayload::setPayload(std::initializer_list &_payload) { - // Create new vector with provided payload - m_payload = std::move(std::vector(_payload)); -} - -const std::vector &DynamicByteArrayPayload::payload() const { - return m_payload; -} - -void DynamicByteArrayPayload::print() const { - // Store original format - std::ios_base::fmtflags prevFmt(std::cout.flags()); - - // Print payload - std::cout << "[" __FILE__ "]" - << "\n\tSize: " << actualSize() - << "\n\t--\n\tpayload:" << std::hex << std::showbase; - - for (auto byte : m_payload) { - std::cout << ' ' << unsigned(byte); - } - - std::cout << '\n'; - - // Restore original format - std::cout.flags(prevFmt); -} - -bool DynamicByteArrayPayload::operator==(const DynamicByteArrayPayload &_other) const { - return m_payload == _other.payload(); -} - -DynamicByteArrayPayloadBuilder::operator DynamicByteArrayPayload() const { - return std::move(m_entry); -} - -DynamicByteArrayPayloadBuilder & -DynamicByteArrayPayloadBuilder::payload(std::initializer_list &&_payload) { - m_entry.setPayload(_payload); - return *this; -} - -} // namespace serialization -} // namespace vsomeip_utilities diff --git a/test/common/someip_lib/someip/CMakeLists.txt b/test/common/someip_lib/someip/CMakeLists.txt deleted file mode 100644 index ac1fa48e5..000000000 --- a/test/common/someip_lib/someip/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -project (someip) - -# ---------------------------------------------------------------------------- -# Include all source files (cpp/hpp) -# ---------------------------------------------------------------------------- -file (GLOB - SRC - src/*.cpp src/*.hpp - src/sd/*.cpp src/sd/*.hpp - src/sd/options/*.cpp src/sd/options/*.hpp - src/generic/*.cpp src/generic/*.hpp -) - -file (GLOB INC include/*.hpp) - -# ---------------------------------------------------------------------------- -# Declare the library -# ---------------------------------------------------------------------------- -add_library ( - ${PROJECT_NAME} SHARED - ${SRC} - ${INC} -) - -TARGET_LINK_LIBRARIES ( - ${PROJECT_NAME} - PUBLIC - utils - serialization - communication -) - -# ---------------------------------------------------------------------------- -# Specify here the include directories exported -# by this library -# ---------------------------------------------------------------------------- -target_include_directories ( - ${PROJECT_NAME} - PUBLIC include - PRIVATE src -) diff --git a/test/common/someip_lib/someip/include/someip/sd/options/ipv4endpointoption.hpp b/test/common/someip_lib/someip/include/someip/sd/options/ipv4endpointoption.hpp deleted file mode 100644 index cd5ab4589..000000000 --- a/test/common/someip_lib/someip/include/someip/sd/options/ipv4endpointoption.hpp +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __IPV4ENDPOINTOPTION_HPP__ -#define __IPV4ENDPOINTOPTION_HPP__ - -#include - -namespace vsomeip_utilities { -namespace someip { -namespace sd { -namespace options { - -class Ipv4EndpointOptionBuilder; - -// Inverted field representation to align with Big-Endian byte order -struct Ipv4EndpointOptionRaw_t { - std::uint16_t portNumber = { 0 }; - std::uint8_t protocol = { 0 }; - std::uint8_t reserved = { 0 }; - std::uint32_t ipv4Address = { 0 }; -}; - -class Ipv4EndpointOption - : public serialization::PodPayload { -public: - // CTor - Ipv4EndpointOption() = default; - - static Ipv4EndpointOptionBuilder create(); - - std::uint16_t portNumber() const; - std::uint8_t protocol() const; - std::uint32_t ipv4Address() const; - std::string ipv4AddressString() const; - - void setPortNumber(const std::uint16_t& _val); - void setProtocol(const std::uint8_t& _val); - void setIpv4Address(const std::uint32_t& _val); - bool setIpv4Address(const std::string& _val); - void setReserved(const std::uint8_t& _val); - - void print() const override; -}; - -/** - * @brief Entry builder - * - */ -class Ipv4EndpointOptionBuilder { -public: - // CTor/DTor - Ipv4EndpointOptionBuilder() = default; - virtual ~Ipv4EndpointOptionBuilder() = default; - - operator Ipv4EndpointOption() const; - - Ipv4EndpointOptionBuilder& portNumber(const std::uint16_t& _val); - Ipv4EndpointOptionBuilder& protocol(const std::uint8_t& _val); - Ipv4EndpointOptionBuilder& ipv4Address(const std::uint32_t& _val); - Ipv4EndpointOptionBuilder& ipv4Address(const std::string& _val); - Ipv4EndpointOptionBuilder& reserved(const std::uint8_t& _val); - -private: - Ipv4EndpointOption m_entry; -}; - -} // options -} // sd -} // someip -} // vsomeip_utilities - -#endif // __IPV4ENDPOINTOPTION_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/sd/someipsd.hpp b/test/common/someip_lib/someip/include/someip/sd/someipsd.hpp deleted file mode 100644 index 3691720fc..000000000 --- a/test/common/someip_lib/someip/include/someip/sd/someipsd.hpp +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __SOMEIPSD_HPP__ -#define __SOMEIPSD_HPP__ - -#include -#include -#include - -namespace vsomeip_utilities { -namespace someip { -namespace sd { - -class SomeIpSdBuilder; - -// Inverted field representation to align with Big-Endian byte order -struct SomeIpSdHeaderRaw_t { - std::uint8_t reserved[3] { 0, 0, 0 }; - types::sdFlags_t flags { 0 }; -}; - -/** - * @brief Some/IP SD - * - */ -class SomeIpSd - : public serialization::PodPayload { -friend class SomeIpSdBuilder; - -public: - // Copy Ctors - SomeIpSd(const SomeIpSd&); - SomeIpSd(const SomeIpSd&&); - - // Assignment operators - const SomeIpSd& operator=(const SomeIpSd&); - const SomeIpSd& operator=(const SomeIpSd&&); - - /** - * @brief Create Fragment Builder - * - * @return SomeIpSdBuilder - */ - static SomeIpSdBuilder create(); - - /** - * @brief Deserialize data from stream - * - * @param _stream - */ - virtual std::size_t deserialize(std::istream& _stream) override; - - /** - * @brief Serialize data to stream - * - * @param _stream - */ - virtual std::size_t serialize(std::ostream& _stream) const override; - - // Message Attribute Getters - types::sdFlags_t flags() const; - bool reboot() const; - bool unicast() const; - bool controlFlag() const; - std::uint32_t reserved() const; - - SomeIpSdEntries& entries(); - SomeIpSdOptions& options(); - - // Message Attribute Setters - void setFlags(const types::sdFlags_t& _flags); - void setReboot(const bool _val); - void setUnicast(const bool _val); - void setControlFlag(const bool _val); - void setReserved(const std::array); - - /** - * @brief Print to stdout utility method - * - */ - void print() const override; - -protected: - // CTor - SomeIpSd() = default; - -private: - SomeIpSdEntries m_entries; - SomeIpSdOptions m_options; -}; - -/** - * @brief Builder - * - */ -class SomeIpSdBuilder { -public: - // CTor/DTor - SomeIpSdBuilder() = default; - virtual ~SomeIpSdBuilder() = default; - - operator SomeIpSd() const; - - // Setter Methods - SomeIpSdBuilder& flags(const types::sdFlags_t _flags); - SomeIpSdBuilder& reboot(const bool _val); - SomeIpSdBuilder& unicast(const bool _val); - SomeIpSdBuilder& controlFlag(const bool _val); - SomeIpSdBuilder& pushEntry(SomeIpSdEntry& _entry); - SomeIpSdBuilder& pushOptions(SomeIpSdOption& _entry); - SomeIpSdBuilder& pushEntry(SomeIpSdEntry&& _entry); - SomeIpSdBuilder& pushOption(SomeIpSdOption&& _entry); - -private: - SomeIpSd m_entry; -}; - -} // sd -} // someip -} // vsomeip_utilities - -#endif // __SOMEIPSD_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/sd/someipsdentries.hpp b/test/common/someip_lib/someip/include/someip/sd/someipsdentries.hpp deleted file mode 100644 index 4e78ba18a..000000000 --- a/test/common/someip_lib/someip/include/someip/sd/someipsdentries.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __SOMEIPSDENTRIES_HPP__ -#define __SOMEIPSDENTRIES_HPP__ - -#include -#include - -namespace vsomeip_utilities { -namespace someip { -namespace sd { - -using SomeIpSdEntries = SomeIpSdEntriesArray; - -} // sd -} // someip -} // vsomeip_utilities - -#endif // __SOMEIPSDENTRIES_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/sd/someipsdentriesarray.hpp b/test/common/someip_lib/someip/include/someip/sd/someipsdentriesarray.hpp deleted file mode 100644 index f5dd272e1..000000000 --- a/test/common/someip_lib/someip/include/someip/sd/someipsdentriesarray.hpp +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __SOMEIPSDENTRIESBASE_HPP__ -#define __SOMEIPSDENTRIESBASE_HPP__ - -#include - -#include - -#include - -namespace vsomeip_utilities { -namespace someip { -namespace sd { - -// Inverted field representation to align with Big-Endian byte order -struct EntriesLengthRaw_t { - types::length_t length { 0 }; -}; - -template -class SomeIpSdEntriesArray - : public serialization::PodPayload { -public: - // CTor - explicit SomeIpSdEntriesArray() {}; - - // Copy/Move CTors - SomeIpSdEntriesArray(const SomeIpSdEntriesArray& _other) - : serialization::PodPayload{ _other } - , m_entries { _other.m_entries } {} - SomeIpSdEntriesArray(const SomeIpSdEntriesArray&& _other) - : serialization::PodPayload { _other } - , m_entries { std::move(_other.m_entries) } {} - - // Copy/Move assignment operators - const SomeIpSdEntriesArray& operator=(const SomeIpSdEntriesArray& _other) { - serialization::PodPayload::operator=(_other); - m_entries = _other.m_entries; - return *this; - } - - const SomeIpSdEntriesArray& operator=(const SomeIpSdEntriesArray&& _other) { - serialization::PodPayload::operator=(_other); - m_entries = std::move(_other.m_entries); - return *this; - } - - /** - * @brief The Serializable object instance actual size - * - * @return std::size_t - */ - virtual std::size_t actualSize() const override { - return serialization::PodPayload::actualSize() + m_podPayload.length; - } - - /** - * @brief Deserialize data from stream - * - * @param _stream - */ - virtual std::size_t deserialize(std::istream& _stream) override { - std::size_t headerLen = serialization::PodPayload::deserialize(_stream); - std::size_t entriesLen = 0; - - while (entriesLen < length()) { - TEntry entry = TEntry::create(); - std::size_t len = entry.deserialize(_stream); - - // Stop parsing if unnable to deserialize an entry - if (len == 0) - break; - - m_entries.push_back(std::move(entry)); - - entriesLen += len; - } - - std::size_t totalLen = headerLen + entriesLen; - - if (totalLen != actualSize()) { - std::cerr << __func__ << ": Failed to deserialize!\n"; - totalLen = 0; - } - - return totalLen; - } - - /** - * @brief Serialize data to stream - * - * @param _stream - */ - virtual std::size_t serialize(std::ostream& _stream) const override { - std::size_t ret = 0; - - ret = serialization::PodPayload::serialize(_stream); - - for (std::uint32_t i = 0; i < m_entries.size(); ++i) { - ret += m_entries.at(i).serialize(_stream); - } - - if (ret != actualSize()) - std::cerr << __func__ << ": Failed to serialize!\n"; - - return ret; - } - - // Getters - types::length_t length() const { return m_podPayload.length; } - - // Entries management - - /** - * @brief Access entries - * - * @return std::vector& Referent to all entries - */ - std::vector& get() { - return m_entries; - } - - /** - * @brief Access entries by index - * - * @param _index - * @return TEntry& Referent to the entry at the provided index - */ - TEntry& operator[](const std::uint32_t _index) { - return m_entries[_index]; - } - - /** - * @brief Returns the number of stored entries - * - * @return uint32_t - */ - std::uint32_t entriesCount() const { - return static_cast(m_entries.size()); - } - - /** - * @brief Pushes a copy of the provided entry into the entry array - * NOTE: To keep the payload's length consistency, once an entry is pushed into the array it cannot be modified - * - * @param _entry - */ - void pushEntry(TEntry& _entry) { - m_podPayload.length += static_cast(_entry.actualSize()); - m_entries.push_back(_entry); - } - - /** - * @brief Moves an entry into the entry array - * NOTE: To keep the payload's length consistency, once an entry is pushed into the array it cannot be modified - * - * @param _entry - */ - void pushEntry(TEntry&& _entry) { - m_podPayload.length += static_cast(_entry.actualSize()); - m_entries.push_back(_entry); - } - - /** - * @brief Forces the length of the entry array to a given value. - * NOTE: This should only be used to test MALFORMED messages! - * - * @param _length - */ - void forceEntryArraySize(types::length_t _length) { - m_podPayload.length = _length; - } - - /** - * @brief Print to stdout utility method - * - */ - void print() const override { - // Store original format - std::ios_base::fmtflags prevFmt(std::cout.flags()); - - // Print payload - std::cout << "[" __FILE__ "]" - << "\n\tPOD size: " << serialization::PodPayload::size() - << "\n\t--\n\tlength: " << length() - << "\n\tEntries count: " << entriesCount() << '\n'; - - // Restore original format - std::cout.flags(prevFmt); - - for (std::uint32_t i = 0; i < m_entries.size(); ++i) { - std::cout << "[Entry " << i << "]\n"; - m_entries[i].print(); - } - - } - -private: - std::vector m_entries; -}; - -} // sd -} // someip -} // vsomeip_utilities - -#endif // __SOMEIPSDENTRIESBASE_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/sd/someipsdentry.hpp b/test/common/someip_lib/someip/include/someip/sd/someipsdentry.hpp deleted file mode 100644 index 6c19b8f47..000000000 --- a/test/common/someip_lib/someip/include/someip/sd/someipsdentry.hpp +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __SOMEIPSDENTRY_HPP__ -#define __SOMEIPSDENTRY_HPP__ - -#include - -#include - -namespace vsomeip_utilities { -namespace someip { -namespace sd { - -class SomeIpSdEntryBuilder; - -// Inverted field representation to align with Big-Endian byte order -struct SdEntryRaw_t { - std::uint32_t genericAttribute = { 0 }; - // std::uint8_t ttl[3]; - // types::sdMajorVersion majorVersion = { 0 }; - std::uint32_t majorVersionAndTtl = { 0 }; - types::sdInstanceId instanceId = { 0 }; - types::sdServiceId serviceId = { 0 }; - types::sdOptsCount optsCount = { 0 }; - types::sdIndex2nd index2nd = { 0 }; - types::sdIndex1st index1st = { 0 }; - types::sdEntryType type = { 0 }; -}; - -/** - * @brief SomeIpSdEntry - * - * Covers the structure for both: - * - Service Entry type - * - EventGroup Entry type - */ -class SomeIpSdEntry - : public serialization::PodPayload { -public: - // CTor - SomeIpSdEntry() = default; - - /** - * @brief Create Builder - * - * @return SomeIpSdEntryBuilder - */ - static SomeIpSdEntryBuilder create(); - - // Attribute Getters - types::sdEntryType type() const; - types::sdIndex1st index1st() const; - types::sdIndex2nd index2nd() const; - types::sdOptsCount optsCount() const; - types::sdOptsCount optsCount1st() const; - types::sdOptsCount optsCount2nd() const; - types::sdServiceId serviceId() const; - types::sdInstanceId instanceId() const; - types::sdMajorVersion majorVersion() const; - std::uint32_t ttl() const; - - // Service Entry Type specific attribute Getters - types::sdMinorVersion serviceMinorVersion() const; - - // Eventgroup Entry Type specific attribute Getters - types::sdCounter eventgroupCounter() const; - types::sdEventGroupId eventgroupId() const; - - // Message Attribute Setters - void setType(const types::sdEntryType& _val); - void setIndex1st(const types::sdIndex1st& _val); - void setIndex2nd(const types::sdIndex2nd& _val); - void setOptsCount(const types::sdOptsCount& _val); - void setOptsCount1st(const types::sdOptsCount& _val); - void setOptsCount2nd(const types::sdOptsCount& _val); - void setServiceId(const types::sdServiceId& _val); - void setInstanceId(const types::sdInstanceId& _val); - void setMajorVersion(const types::sdMajorVersion& _val); - void setTtl(const std::uint32_t& _val); // 24bit attribute, input argument will be truncated - - // Service Entry Type specific attribute Setters - void setServiceMinorVersion(const types::sdMinorVersion _val); - - // Eventgroup Entry Type specific attribute Setters - void setEventgroupCounter(const types::sdCounter _val); - void setEventgroupId(const types::sdEventGroupId _val); - - /** - * @brief Print to stdout utility method - * - */ - void print() const override; -}; - -/** - * @brief Entry builder - * - */ -class SomeIpSdEntryBuilder { -public: - // CTor/DTor - SomeIpSdEntryBuilder() = default; - virtual ~SomeIpSdEntryBuilder() = default; - - operator SomeIpSdEntry() const; - - // Setter Methods - SomeIpSdEntryBuilder& type(const types::sdEntryType& _val); - SomeIpSdEntryBuilder& index1st(const types::sdIndex1st& _val); - SomeIpSdEntryBuilder& index2nd(const types::sdIndex2nd& _val); - SomeIpSdEntryBuilder& optsCount(const types::sdOptsCount& _val); - SomeIpSdEntryBuilder& optsCount1st(const types::sdOptsCount& _val); - SomeIpSdEntryBuilder& optsCount2nd(const types::sdOptsCount& _val); - SomeIpSdEntryBuilder& serviceId(const types::sdServiceId& _val); - SomeIpSdEntryBuilder& instanceId(const types::sdInstanceId& _val); - SomeIpSdEntryBuilder& majorVersion(const types::sdMajorVersion& _val); - SomeIpSdEntryBuilder& ttl(const std::uint32_t& _val); // 24 bit attribute, input argument will be truncated - - // Service Entry Type specific attribute Setters - SomeIpSdEntryBuilder& serviceMinorVersion(const types::sdMinorVersion _val); - - // Eventgroup Entry Type specific attribute Setters - SomeIpSdEntryBuilder& eventgroupCounter(const types::sdCounter _val); - SomeIpSdEntryBuilder& eventgroupId(const types::sdEventGroupId _val); - -private: - SomeIpSdEntry m_entry; -}; - -} // sd -} // someip -} // vsomeip_utilities - -#endif // __SOMEIPSDENTRY_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/sd/someipsdoption.hpp b/test/common/someip_lib/someip/include/someip/sd/someipsdoption.hpp deleted file mode 100644 index 029b3e708..000000000 --- a/test/common/someip_lib/someip/include/someip/sd/someipsdoption.hpp +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __SOMEIPSDOPTION_HPP__ -#define __SOMEIPSDOPTION_HPP__ - -#include - -#include - -namespace vsomeip_utilities { -namespace someip { -namespace sd { - -class SomeIpSdOptionBuilder; - -// Inverted field representation to align with Big-Endian byte order -struct SdOptionHeaderRaw_t { - std::uint8_t reserved = { 0 }; - types::sdOptionType type = { 0 }; - types::sdOptionLength length = { 0 }; -}; - -/** - * @brief Returns the actual SomeIP length to be placed in the header - * (disregard last 8 header bytes since they are retrieved together) - * - * @return constexpr std::size_t - */ -constexpr std::size_t calcInitialSdOptionHeaderLengthAttr() { - return sizeof(std::uint8_t); -} - -class SomeIpSdOption - : public serialization::FragmentPayload { -public: - // CTor - SomeIpSdOption(); - - /** - * @brief Returns the payload defined size (as referenced in the header) - * - * @return std::size_t - */ - std::size_t payloadSize() const override; - - /** - * @brief Create Builder - * - * @return SomeIpSdEntryBuilder - */ - static SomeIpSdOptionBuilder create(); - - // Attribute Getters - types::sdOptionType type() const; - types::sdOptionLength length() const; - std::uint8_t reserved() const; - - // Message Attribute Setters - void setType(const types::sdOptionType& _val); - - template - std::size_t push(const T& _payload) { - // Push payload and update POD length attribute - std::size_t processed = serialization::FragmentPayload::push(_payload); - m_podPayload.length += static_cast(processed); - - return processed; - } - - template - std::size_t push(const T&& _payload) { - auto p(_payload); - // Push payload and update POD length attribute - std::size_t processed = serialization::FragmentPayload::push(p); - m_podPayload.length += static_cast(processed); - - return processed; - } - - /** - * @brief Forces the length of the option to a given value. - * NOTE: This should only be used to test MALFORMED messages! - * - * @param _length - */ - void forcePayloadLength(const types::sdOptionLength &_length) { - m_podPayload.length = _length; - } - - /** - * @brief Print to stdout utility method - * - */ - void print() const override; -}; - -/** - * @brief Entry builder - * - */ -class SomeIpSdOptionBuilder -{ -public: - // CTor/DTor - SomeIpSdOptionBuilder() = default; - virtual ~SomeIpSdOptionBuilder() = default; - - operator SomeIpSdOption() const; - - // Setter Methods - SomeIpSdOptionBuilder& type(const types::sdOptionType& _val); - - template - SomeIpSdOptionBuilder& push(T& _payload) { - m_entry.push(_payload); - return *this; - } - - template - SomeIpSdOptionBuilder& push(T&& _payload) { - m_entry.push(_payload); - return *this; - } - - -private: - SomeIpSdOption m_entry; -}; - -} // sd -} // someip -} // vsomeip_utilities - -#endif // __SOMEIPSDOPTION_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/sd/someipsdoptions.hpp b/test/common/someip_lib/someip/include/someip/sd/someipsdoptions.hpp deleted file mode 100644 index bceb295c6..000000000 --- a/test/common/someip_lib/someip/include/someip/sd/someipsdoptions.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __SOMEIPSDOPTIONS_HPP__ -#define __SOMEIPSDOPTIONS_HPP__ - -#include -#include - -namespace vsomeip_utilities { -namespace someip { -namespace sd { - -using SomeIpSdOptions = SomeIpSdEntriesArray; - -} // sd -} // someip -} // vsomeip_utilities - -#endif // __SOMEIPSDOPTIONS_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/someipmessage.hpp b/test/common/someip_lib/someip/include/someip/someipmessage.hpp deleted file mode 100644 index b3f9058e1..000000000 --- a/test/common/someip_lib/someip/include/someip/someipmessage.hpp +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __SOMEIPMESSAGE_HPP__ -#define __SOMEIPMESSAGE_HPP__ - -#include - -#include - -#include -#include - -namespace vsomeip_utilities { -namespace someip { - -// Inverted field representation to align with Big-Endian byte order -struct SomeIpHeaderRaw_t { - types::returnCode_e retCode { vsomeip_utilities::someip::types::returnCode_e::E_RC_UNKNOWN }; - types::messageType_e msgType { vsomeip_utilities::someip::types::messageType_e::E_MT_UNKNOWN }; - types::interfaceVersion_t interfaceVersion { 0 }; - types::protocolVersion_t protocolVersion { 0 }; - types::sessionId_t sessionId { 0 }; - types::clientId_t clientId { 0 }; - types::length_t length { 0 }; - types::methodId_t methodId { 0 }; - types::serviceId_t serviceId { 0 }; -}; - -/** - * @brief Returns the actual SomeIP length to be placed in the header - * (disregard last 8 header bytes since they are retrieved together) - * - * @return constexpr std::size_t - */ -constexpr std::size_t calcInitialSomeIpMsgHeaderLengthAttr() { - return sizeof(SomeIpHeaderRaw_t) - 8; -} - -class SomeIpMessageBuilder; - -/** - * @brief Some/IP Message representation - * - */ -class SomeIpMessage : public serialization::FragmentPayload { - friend class SomeIpMessageBuilder; - -public: - // CTor - SomeIpMessage(); - - // Copy/Move CTors - SomeIpMessage(const SomeIpMessage &); - SomeIpMessage(const SomeIpMessage &&); - - // Copy/Move assignment operators - const SomeIpMessage &operator=(const SomeIpMessage &); - const SomeIpMessage &operator=(const SomeIpMessage &&); - - /** - * @brief Returns the payload defined size (as referenced in the header) - * - * @return std::size_t - */ - std::size_t payloadSize() const override; - - /** - * @brief Create Message Builder - * - * @return SomeIpMessageBuilder - */ - static SomeIpMessageBuilder create(); - - // Message Attribute Getters - types::length_t length() const; - types::methodId_t methodId() const; - types::clientId_t clientId() const; - types::returnCode_e retCode() const; - types::messageType_e msgType() const; - types::serviceId_t serviceId() const; - types::sessionId_t sessionId() const; - types::protocolVersion_t protocolVersion() const; - types::interfaceVersion_t interfaceVersion() const; - - // Message Attribute Setters - void setLength(const types::length_t &_length); - void setMethodId(const types::methodId_t &_methodId); - void setClientId(const types::clientId_t &_clientId); - void setRetCode(const types::returnCode_e &_retCode); - void setMsgType(const types::messageType_e &_msgType); - void setServiceId(const types::serviceId_t &_serviceId); - void setSessionId(const types::sessionId_t &_sessionId); - void setProtocolVersion(const types::protocolVersion_t &_protocolVersion); - void setInterfaceVersion(const types::interfaceVersion_t &_interfaceVersion); - - /** - * @brief Reads SOMEIP messages from a udp socket. - * - * @param _udp_socket udp socket over which to receive the messages - * @param _expected_stream_size desired buffer size - * @param _keep_receiving& boolean - */ - static std::vector> readSomeIpMessages(boost::asio::ip::udp::socket *_udp_socket, const int _expected_stream_size, bool& _keep_receiving); - - /** - * @brief Sends SOMEIP message over udp socket. - * - * @param _udp_socket udp socket over which to send the message - * @param _target udp endpoint - * @param _message someip message to send - */ - static void sendSomeIpMessage(boost::asio::ip::udp::socket *_udp_socket , boost::asio::ip::udp::socket::endpoint_type _target_sd, SomeIpMessage _message); - - /** - * @brief Pushes the provided payload into the container - * - * @tparam T source payload type - * @param _payload source payload - * @return the size in bytes of the pushed data - */ - template - std::size_t push(const T &_payload) { - // Push payload and update POD length attribute - std::size_t processedBytes = FragmentPayload::push(_payload); - m_podPayload.length += static_cast(processedBytes); - - return processedBytes; - } - - /** - * @brief Populates the provided entry from the payload's next memory location - * - * @tparam T target payload type - * @param _payload target payload - * @return the size in bytes of the pulled data - */ - template - std::size_t pull(T &_outPayload) { - // Pull payload and update POD length attribute - std::size_t processedBytes = FragmentPayload::pull(_outPayload); - m_podPayload.length -= static_cast(processedBytes); - - return processedBytes; - } - - /** - * @brief Print to stdout utility method - * - */ - void print() const override; -}; - -/** - * @brief Message Header builder - * - */ -class SomeIpMessageBuilder { -public: - // CTor/DTor - SomeIpMessageBuilder() = default; - virtual ~SomeIpMessageBuilder() = default; - - operator SomeIpMessage() const; - - // Setter Methods - SomeIpMessageBuilder &serviceId(const types::serviceId_t _service); - SomeIpMessageBuilder &methodId(const types::methodId_t _method); - SomeIpMessageBuilder &clientId(const types::clientId_t _client); - SomeIpMessageBuilder &sessionId(const types::sessionId_t _session); - SomeIpMessageBuilder &protocolVersion(const types::protocolVersion_t _protoVer); - SomeIpMessageBuilder &interfaceVersion(const types::interfaceVersion_t _ifaceVer); - SomeIpMessageBuilder &messageType(const types::messageType_e _msgType); - SomeIpMessageBuilder &returnCode(const types::returnCode_e _retCode); - - template - SomeIpMessageBuilder &push(T &_payload) { - m_entry.push(_payload); - return *this; - } - - template - SomeIpMessageBuilder &push(T &&_payload) { - auto p(std::move(_payload)); - m_entry.push(p); - return *this; - } - -private: - SomeIpMessage m_entry; -}; - -} // someip -} // vsomeip_utilities - -#endif // __SOMEIPMESSAGE_HPP__ diff --git a/test/common/someip_lib/someip/include/someip/types/primitives.hpp b/test/common/someip_lib/someip/include/someip/types/primitives.hpp deleted file mode 100644 index 07d8a5ccb..000000000 --- a/test/common/someip_lib/someip/include/someip/types/primitives.hpp +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __PRIMITIVES_HPP__ -#define __PRIMITIVES_HPP__ - -#include -#include - -namespace vsomeip_utilities { -namespace someip { -namespace types { - -/** - * @brief SomeIp header types - * - */ -using serviceId_t = std::uint16_t; -using methodId_t = std::uint16_t; - -using length_t = std::uint32_t; - -using clientId_t = std::uint16_t; -using sessionId_t = std::uint16_t; - -using protocolVersion_t = std::uint8_t; -using interfaceVersion_t = std::uint8_t; - -enum class messageType_e : std::uint8_t { - E_MT_REQUEST = 0x00, - E_MT_REQUEST_NO_RETURN = 0x01, - E_MT_NOTIFICATION = 0x02, - E_MT_TRANSPORT = 0x20, - E_MT_REQUEST_ACK = 0x40, - E_MT_REQUEST_NO_RETURN_ACK = 0x41, - E_MT_NOTIFICATION_ACK = 0x42, - E_MT_RESPONSE = 0x80, - E_MT_ERROR = 0x81, - E_MT_RESPONSE_ACK = 0xC0, - E_MT_ERROR_ACK = 0xC1, - E_MT_UNKNOWN = 0xFF -}; - -enum class returnCode_e : std::uint8_t { - E_RC_OK = 0x00, - E_RC_NOT_OK = 0x01, - E_RC_UNKNOWN_SERVICE = 0x02, - E_RC_UNKNOWN_METHOD = 0x03, - E_RC_NOT_READY = 0x04, - E_RC_NOT_REACHABLE = 0x05, - E_RC_TIMEOUT = 0x06, - E_RC_WRONG_PROTOCOL_VERSION = 0x07, - E_RC_WRONG_INTERFACE_VERSION = 0x08, - E_RC_MALFORMED_MESSAGE = 0x09, - E_RC_WRONG_MESSAGE_TYPE = 0x0A, - E_RC_UNKNOWN = 0xFF -}; - -/** - * @brief SomeIp SD Entry/Option types - */ - -// Entries -using sdFlags_t = std::uint8_t; -using sdEntryType = std::uint8_t; -using sdIndex1st = std::uint8_t; -using sdIndex2nd = std::uint8_t; -using sdOptsCount = std::uint8_t; -using sdServiceId = std::uint16_t; -using sdInstanceId = std::uint16_t; -using sdMajorVersion = std::uint8_t; -using sdMinorVersion = std::uint32_t; -using sdEventGroupId = std::uint16_t; -using sdCounter = std::uint8_t; -using sdTtl = std::uint32_t; -using sdEntryLength = std::uint16_t; - -// Options -using sdOptionLength = std::uint16_t; -using sdOptionType = std::uint8_t; -using sdOptionProtocol = std::uint8_t; -using sdOptionPort = std::uint16_t; -using sdOptionReserved = std::uint8_t; - -} // namespace types -} // namespace someip -} // namespace vsomeip_utilities - -#endif // __PRIMITIVES_HPP__ diff --git a/test/common/someip_lib/someip/src/sd/options/ipv4endpointoption.cpp b/test/common/someip_lib/someip/src/sd/options/ipv4endpointoption.cpp deleted file mode 100644 index 1a3d796d3..000000000 --- a/test/common/someip_lib/someip/src/sd/options/ipv4endpointoption.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -#include - -namespace vsomeip_utilities { -namespace someip { -namespace sd { -namespace options { - -/** - * @brief Create Builder - * - * @return SomeIpSdEntryBuilder - */ -Ipv4EndpointOptionBuilder Ipv4EndpointOption::create() { - return Ipv4EndpointOptionBuilder(); -} - -// Attribute Getters -std::uint16_t Ipv4EndpointOption::portNumber() const { - return m_podPayload.portNumber; -} - -std::uint8_t Ipv4EndpointOption::protocol() const { - return m_podPayload.protocol; -} - -std::uint32_t Ipv4EndpointOption::ipv4Address() const { - return m_podPayload.ipv4Address; -} - -std::string Ipv4EndpointOption::ipv4AddressString() const { - return com::utils::ipv4AddressFromInt(m_podPayload.ipv4Address).to_string(); -} - -// Message Attribute Setters -void Ipv4EndpointOption::setPortNumber(const std::uint16_t& _val) { - m_podPayload.portNumber = _val; -} - -void Ipv4EndpointOption::setProtocol(const std::uint8_t& _val) { - m_podPayload.protocol = _val; -} - -void Ipv4EndpointOption::setIpv4Address(const std::uint32_t& _val) { - m_podPayload.ipv4Address = _val; -} - -bool Ipv4EndpointOption::setIpv4Address(const std::string& _val) { - bool ret = false; - - std::error_code ec; - asio::ip::address_v4 addr = com::utils::ipv4AddressFromString(_val, ec); - - if (!ec) { - setIpv4Address(addr.to_uint()); - ret = true; - } - - return ret; -} - -void Ipv4EndpointOption::setReserved(const std::uint8_t& _val) { - m_podPayload.reserved = _val; -} - -/** - * @brief Print to stdout utility method - * - */ -void Ipv4EndpointOption::print() const { - // Store original format - std::ios_base::fmtflags prevFmt(std::cout.flags()); - - // Print payload - std::cout << "[" __FILE__ "]" - << "\n\tPOD size: " << serialization::PodPayload::size() - << "\n\t--" << std::hex << std::showbase - << "\n\tIpv4 Address: " << unsigned(ipv4Address()) << " (" << ipv4AddressString() << ')' - << "\n\tReserved: " << unsigned(m_podPayload.reserved) - << "\n\tPort Number: " << std::dec << unsigned(portNumber()) << std::hex - << "\n\tProtocol: " << unsigned(protocol()) << '\n'; - - // Restore original format - std::cout.flags(prevFmt); -} - -Ipv4EndpointOptionBuilder::operator Ipv4EndpointOption() const { - return std::move(m_entry); -} - -// Setter Methods -Ipv4EndpointOptionBuilder& Ipv4EndpointOptionBuilder::portNumber(const std::uint16_t& _val) { - m_entry.setPortNumber(_val); - return *this; -} - -Ipv4EndpointOptionBuilder& Ipv4EndpointOptionBuilder::protocol(const std::uint8_t& _val) { - m_entry.setProtocol(_val); - return *this; -} - -Ipv4EndpointOptionBuilder& Ipv4EndpointOptionBuilder::ipv4Address(const std::uint32_t& _val) { - m_entry.setIpv4Address(_val); - return *this; -} - -Ipv4EndpointOptionBuilder& Ipv4EndpointOptionBuilder::ipv4Address(const std::string& _val) { - m_entry.setIpv4Address(_val); - return *this; -} - -Ipv4EndpointOptionBuilder& Ipv4EndpointOptionBuilder::reserved(const std::uint8_t& _val) { - m_entry.setReserved(_val); - return *this; -} - -} // namespace options -} // namespace sd -} // namespace someip -} // namespace vsomeip_utilities diff --git a/test/common/someip_lib/someip/src/sd/someipsd.cpp b/test/common/someip_lib/someip/src/sd/someipsd.cpp deleted file mode 100644 index 85798524e..000000000 --- a/test/common/someip_lib/someip/src/sd/someipsd.cpp +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -namespace vsomeip_utilities { -namespace someip { -namespace sd { - -// Header someipSD (4bytes) + Entries length (4bytes) + Options length (4bytes) -constexpr std::size_t SD_MIN_PAYLOAD_SIZE {sizeof(vsomeip_utilities::someip::sd::SomeIpSdHeaderRaw_t) + - 2 * sizeof(vsomeip_utilities::someip::sd::EntriesLengthRaw_t)}; - -SomeIpSd::SomeIpSd(const SomeIpSd& _other) - : serialization::PodPayload { _other } - , m_entries { _other.m_entries } - , m_options { _other.m_options } {} - - -SomeIpSd::SomeIpSd(const SomeIpSd&& _other) - : serialization::PodPayload { _other } - , m_entries { std::move(_other.m_entries) } - , m_options { std::move(_other.m_options) } {} - -const SomeIpSd& SomeIpSd::operator=(const SomeIpSd& _other) { - serialization::PodPayload::operator=(_other); - m_entries = _other.m_entries; - m_options = _other.m_options; - - return *this; -} - -const SomeIpSd& SomeIpSd::operator=(const SomeIpSd&& _other) { - serialization::PodPayload::operator=(_other); - m_entries = std::move(_other.m_entries); - m_options = std::move(_other.m_options); - - return *this; -} - -SomeIpSdBuilder SomeIpSd::create() { - return SomeIpSdBuilder(); -} - -std::size_t SomeIpSd::deserialize(std::istream& _stream) { - std::size_t ret = 0; - - ret += serialization::PodPayload::deserialize(_stream); - ret += m_entries.deserialize(_stream); - ret += m_options.deserialize(_stream); - - if (ret < SD_MIN_PAYLOAD_SIZE) { - std::cerr << __func__ << ": Failed to deserialize!\n"; - ret = 0; - } - - return ret; -} - -std::size_t SomeIpSd::serialize(std::ostream& _stream) const { - std::size_t ret = 0; - - ret += serialization::PodPayload::serialize(_stream); - ret += m_entries.serialize(_stream); - ret += m_options.serialize(_stream); - - if (ret == 0) { - std::cerr << __func__ << ": Failed to serialize!\n"; - } - - return ret; -} - -types::sdFlags_t SomeIpSd::flags() const { - return m_podPayload.flags; -} - -bool SomeIpSd::reboot() const { - return m_podPayload.flags & 0x80; -} - -bool SomeIpSd::unicast() const { - return m_podPayload.flags & 0x40; -} - -bool SomeIpSd::controlFlag() const { - return m_podPayload.flags & 0x20; -} - -std::uint32_t SomeIpSd::reserved() const { - std::uint32_t ret = static_cast(m_podPayload.reserved[0] | (m_podPayload.reserved[1] >> 8) | (m_podPayload.reserved[2] >> 16)); - - return ret; -} - -SomeIpSdEntries& SomeIpSd::entries() { - return m_entries; -} - -SomeIpSdOptions& SomeIpSd::options() { - return m_options; -} - -void SomeIpSd::setFlags(const types::sdFlags_t& _flags) { - m_podPayload.flags = _flags; -} - -void SomeIpSd::setReboot(const bool _val) { - if (_val) { - m_podPayload.flags |= 0x80; - } else { - m_podPayload.flags &= 0x7F; - } -} - -void SomeIpSd::setUnicast(const bool _val) { - if (_val) { - m_podPayload.flags |= 0x40; - } else { - m_podPayload.flags &= 0xBF; - } -} - -void SomeIpSd::setControlFlag(const bool _val) { - if (_val) { - m_podPayload.flags |= 0x20; - } else { - m_podPayload.flags &= 0xDF; - } -} - -void SomeIpSd::setReserved(const std::array _val) { - m_podPayload.reserved[0] = _val[0]; - m_podPayload.reserved[1] = _val[1]; - m_podPayload.reserved[2] = _val[2]; -} - -void SomeIpSd::print() const { - // Store original format - std::ios_base::fmtflags prevFmt(std::cout.flags()); - - // Print payload - std::cout << "[" __FILE__ "]" - << "\n\tPOD size: " << serialization::PodPayload::size() - << "\n\t--\n" << std::hex << std::showbase << "[HEADER]" - << "\n\tflags: " << unsigned(flags()) - << "\n\treserved: " << unsigned(reserved()) << '\n'; - - // Restore original format - std::cout.flags(prevFmt); - - std::cout << "[ENTRIES]\n"; - m_entries.print(); - std::cout << "[OPTIONS]\n"; - m_options.print(); - -} - -SomeIpSdBuilder& SomeIpSdBuilder::flags(const types::sdFlags_t _flags) { - m_entry.setFlags(_flags); - return *this; -} - -SomeIpSdBuilder& SomeIpSdBuilder::reboot(const bool _val) { - m_entry.setReboot(_val); - return *this; -} - -SomeIpSdBuilder& SomeIpSdBuilder::unicast(const bool _val) { - m_entry.setUnicast(_val); - return *this; -} - -SomeIpSdBuilder& SomeIpSdBuilder::controlFlag(const bool _val) { - m_entry.setControlFlag(_val); - return *this; -} - -SomeIpSdBuilder& SomeIpSdBuilder::pushEntry(SomeIpSdEntry& _entry) { - m_entry.entries().pushEntry(_entry); - return *this; -} - -SomeIpSdBuilder& SomeIpSdBuilder::pushOptions(SomeIpSdOption& _entry) { - m_entry.options().pushEntry(_entry); - return *this; -} - -SomeIpSdBuilder& SomeIpSdBuilder::pushEntry(SomeIpSdEntry&& _entry) { - m_entry.entries().pushEntry(_entry); - return *this; -} - -SomeIpSdBuilder& SomeIpSdBuilder::pushOption(SomeIpSdOption&& _entry) { - m_entry.options().pushEntry(_entry); - return *this; -} - -SomeIpSdBuilder::operator SomeIpSd() const { - return std::move(m_entry); -} - -} // namespace sd -} // namespace someip -} // namespace vsomeip_utilities diff --git a/test/common/someip_lib/someip/src/sd/someipsdentry.cpp b/test/common/someip_lib/someip/src/sd/someipsdentry.cpp deleted file mode 100644 index e6dc861e4..000000000 --- a/test/common/someip_lib/someip/src/sd/someipsdentry.cpp +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -namespace vsomeip_utilities { -namespace someip { -namespace sd { - -SomeIpSdEntryBuilder SomeIpSdEntry::create() { - return SomeIpSdEntryBuilder(); -} - -SomeIpSdEntryBuilder::operator SomeIpSdEntry() const { - return std::move(m_entry); -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::type(const types::sdEntryType& _val) { - m_entry.setType(_val); - return *this; -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::index1st(const types::sdIndex1st& _val) { - m_entry.setIndex1st(_val); - return *this; -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::index2nd(const types::sdIndex2nd& _val) { - m_entry.setIndex2nd(_val); - return *this; -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::optsCount(const types::sdOptsCount& _val) { - m_entry.setOptsCount(_val); - return *this; -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::optsCount1st(const types::sdOptsCount& _val) { - m_entry.setOptsCount1st(_val); - return *this; -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::optsCount2nd(const types::sdOptsCount& _val) { - m_entry.setOptsCount2nd(_val); - return *this; -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::serviceId(const types::sdServiceId& _val) { - m_entry.setServiceId(_val); - return *this; -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::instanceId(const types::sdInstanceId& _val) { - m_entry.setInstanceId(_val); - return *this; -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::majorVersion(const types::sdMajorVersion& _val) { - m_entry.setMajorVersion(_val); - return *this; -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::ttl(const std::uint32_t& _val) { - m_entry.setTtl(_val); - return *this; -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::serviceMinorVersion(const types::sdMinorVersion _val) { - m_entry.setServiceMinorVersion(_val); - return *this; -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::eventgroupCounter(const types::sdCounter _val) { - m_entry.setEventgroupCounter(_val); - return *this; -} - -SomeIpSdEntryBuilder& SomeIpSdEntryBuilder::eventgroupId(const types::sdEventGroupId _val) { - m_entry.setEventgroupId(_val); - return *this; -} - -types::sdEntryType SomeIpSdEntry::type() const { - return m_podPayload.type; -} - -types::sdIndex1st SomeIpSdEntry::index1st() const { - return m_podPayload.index1st; -} - -types::sdIndex2nd SomeIpSdEntry::index2nd() const { - return m_podPayload.index2nd; -} - -types::sdOptsCount SomeIpSdEntry::optsCount() const { - return m_podPayload.optsCount; -} - -types::sdOptsCount SomeIpSdEntry::optsCount1st() const { - return m_podPayload.optsCount >> 4; -} - -types::sdOptsCount SomeIpSdEntry::optsCount2nd() const { - return m_podPayload.optsCount & ~(0xF << 4); -} - -types::sdServiceId SomeIpSdEntry::serviceId() const { - return m_podPayload.serviceId; -} - -types::sdInstanceId SomeIpSdEntry::instanceId() const { - return m_podPayload.instanceId; -} - -types::sdMajorVersion SomeIpSdEntry::majorVersion() const { - return static_cast(m_podPayload.majorVersionAndTtl >> 24); -} - -std::uint32_t SomeIpSdEntry::ttl() const { - return m_podPayload.majorVersionAndTtl & ~(0xFF << 24); -} - -types::sdMinorVersion SomeIpSdEntry::serviceMinorVersion() const { - return static_cast(m_podPayload.genericAttribute); -} - -types::sdCounter SomeIpSdEntry::eventgroupCounter() const { - return (m_podPayload.genericAttribute >> 16) & 0xF; -} - -types::sdEventGroupId SomeIpSdEntry::eventgroupId() const { - return static_cast(m_podPayload.genericAttribute); -} - -void SomeIpSdEntry::setType(const types::sdEntryType& _val) { - m_podPayload.type = _val; -} - -void SomeIpSdEntry::setIndex1st(const types::sdIndex1st& _val) { - m_podPayload.index1st = _val; -} - -void SomeIpSdEntry::setIndex2nd(const types::sdIndex2nd& _val) { - m_podPayload.index2nd = _val; -} - -void SomeIpSdEntry::setOptsCount(const types::sdOptsCount& _val) { - m_podPayload.optsCount = _val; -} - -void SomeIpSdEntry::setOptsCount1st(const types::sdOptsCount& _val) { - m_podPayload.optsCount = - (m_podPayload.optsCount & ~(0xF << 4)) | ((_val & ~(0xF << 4)) << 4); -} - -void SomeIpSdEntry::setOptsCount2nd(const types::sdOptsCount& _val) { - m_podPayload.optsCount = - (m_podPayload.optsCount & ~(0xF)) | (_val & ~(0xF << 4)); -} - -void SomeIpSdEntry::setServiceId(const types::sdServiceId& _val) { - m_podPayload.serviceId = _val; -} - -void SomeIpSdEntry::setInstanceId(const types::sdInstanceId& _val) { - m_podPayload.instanceId = _val; -} - -void SomeIpSdEntry::setMajorVersion(const types::sdMajorVersion& _val) { - m_podPayload.majorVersionAndTtl = - (m_podPayload.majorVersionAndTtl & ~(0xFF << 24)) | (_val << 24); -} - -void SomeIpSdEntry::setTtl(const std::uint32_t& _val) { - m_podPayload.majorVersionAndTtl = - (m_podPayload.majorVersionAndTtl & ~(0xFFFFFF)) | (_val & (0xFFFFFF)); -} - -void SomeIpSdEntry::setServiceMinorVersion(const types::sdMinorVersion _val) { - m_podPayload.genericAttribute = static_cast(_val); -} - -void SomeIpSdEntry::setEventgroupCounter(const types::sdCounter _val) { - m_podPayload.genericAttribute = - (m_podPayload.genericAttribute& ~(0xF << 16)) | ((_val & 0xF) << 16); -} - -void SomeIpSdEntry::setEventgroupId(const types::sdEventGroupId _val) { - m_podPayload.genericAttribute = - (m_podPayload.genericAttribute & ~(0xFFFF)) | _val; -} - -void SomeIpSdEntry::print() const { - // Store original format - std::ios_base::fmtflags prevFmt(std::cout.flags()); - - // Print payload - std::cout << "[" __FILE__ "]" - << "\n\tPOD size: " << serialization::PodPayload::size() - << "\n\t--" << std::hex << std::showbase - << "\n\tTTL: " << unsigned(ttl()) - << "\n\tMajor Version: " << unsigned(majorVersion()) - << "\n\tInstance Id: " << unsigned(instanceId()) - << "\n\tService Id: " << unsigned(serviceId()) - << "\n\tOptions Count: " << unsigned(optsCount()) - << "\n\tOptions 1st Count: " << unsigned(optsCount1st()) - << "\n\tOptions 2nd Count: " << unsigned(optsCount2nd()) - << "\n\t1st Index: " << unsigned(index1st()) - << "\n\t2nd Index: " << unsigned(index2nd()) - << "\n\tType: " << unsigned(type()) - << "\n\t-- Service Entry Attributes" - << "\n\tMinor Version: " << unsigned(serviceMinorVersion()) - << "\n\t-- Eventgroup Entry Attributes" - << "\n\tEventgroup ID: " << unsigned(eventgroupId()) - << "\n\tCounter: " << unsigned(eventgroupCounter()) << '\n'; - - // Restore original format - std::cout.flags(prevFmt); -} - -} // namespace sd -} // namespace someip -} // namespace vsomeip_utilities diff --git a/test/common/someip_lib/someip/src/sd/someipsdoption.cpp b/test/common/someip_lib/someip/src/sd/someipsdoption.cpp deleted file mode 100644 index 90ebffaea..000000000 --- a/test/common/someip_lib/someip/src/sd/someipsdoption.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -namespace vsomeip_utilities { -namespace someip { -namespace sd { - -// CTor -SomeIpSdOption::SomeIpSdOption() { - m_podPayload.length = calcInitialSdOptionHeaderLengthAttr(); -} - -std::size_t SomeIpSdOption::payloadSize() const { - // SD Options length include the reserved attribute size - return static_cast(length()) - sizeof(m_podPayload.reserved); -} - -SomeIpSdOptionBuilder SomeIpSdOption::create() { - return SomeIpSdOptionBuilder(); -} - -types::sdOptionType SomeIpSdOption::type() const { - return m_podPayload.type; -} - -types::sdOptionLength SomeIpSdOption::length() const { - return m_podPayload.length; -} - -std::uint8_t SomeIpSdOption::reserved() const { - return m_podPayload.reserved; -} - -void SomeIpSdOption::setType(const types::sdOptionType& _val) { - m_podPayload.type = _val; -} - -void SomeIpSdOption::print() const { - // Store original format - std::ios_base::fmtflags prevFmt(std::cout.flags()); - - // Print payload - std::cout << "[" __FILE__ "]" - << "\n\tPOD size: " << serialization::PodPayload::size() - << "\n\t--" - << "\n\tlength: " << length() << std::hex << std::showbase - << "\n\ttype: " << unsigned(type()) - << "\n\treserved: " << unsigned(m_podPayload.reserved) - << "\n\t--" << std::dec - << "\n\tPayload Size: " << unsigned(payloadSize()) << '\n'; - - // Restore original format - std::cout.flags(prevFmt); -} - -SomeIpSdOptionBuilder::operator SomeIpSdOption() const { - return std::move(m_entry); -} - -SomeIpSdOptionBuilder& SomeIpSdOptionBuilder::type(const types::sdOptionType& _val) { - m_entry.setType(_val); - return *this; -} - -} // namespace sd -} // namespace someip -} // namespace vsomeip_utilities diff --git a/test/common/someip_lib/someip/src/someipmessage.cpp b/test/common/someip_lib/someip/src/someipmessage.cpp deleted file mode 100644 index 31a1b79eb..000000000 --- a/test/common/someip_lib/someip/src/someipmessage.cpp +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -namespace vsomeip_utilities { -namespace someip { - -// CTor -SomeIpMessage::SomeIpMessage() { - m_podPayload.length = - calcInitialSomeIpMsgHeaderLengthAttr(); // Initialize POD's length attribute -} - -SomeIpMessage::SomeIpMessage(const SomeIpMessage &&_other) - : serialization::FragmentPayload { _other } { -} - -SomeIpMessage::SomeIpMessage(const SomeIpMessage &_other) - : serialization::FragmentPayload { _other } { -} - -const SomeIpMessage &SomeIpMessage::operator=(const SomeIpMessage &_other) { - serialization::FragmentPayload::operator=(_other); - return *this; -} - -const SomeIpMessage &SomeIpMessage::operator=(const SomeIpMessage &&_other) { - serialization::FragmentPayload::operator=(_other); - return *this; -} - -std::size_t SomeIpMessage::payloadSize() const { - // Calc real payload length - // (disregard last 8 header bytes since they were already retrieved) - return length() - 8; -} - -types::serviceId_t SomeIpMessage::serviceId() const { - return m_podPayload.serviceId; -} - -void SomeIpMessage::setServiceId(const types::serviceId_t &_serviceId) { - m_podPayload.serviceId = _serviceId; -} - -void SomeIpMessage::setMethodId(const types::methodId_t &_methodId) { - m_podPayload.methodId = _methodId; -} - -types::methodId_t SomeIpMessage::methodId() const { - return m_podPayload.methodId; -} - -// This method should not be used except to force wrong values -void SomeIpMessage::setLength(const types::length_t &_length) { - m_podPayload.length = _length; -} - -types::length_t SomeIpMessage::length() const { - return m_podPayload.length; -} - -void SomeIpMessage::setClientId(const types::clientId_t &_clientId) { - m_podPayload.clientId = _clientId; -} - -types::clientId_t SomeIpMessage::clientId() const { - return m_podPayload.clientId; -} - -void SomeIpMessage::setSessionId(const types::sessionId_t &_sessionId) { - m_podPayload.sessionId = _sessionId; -} - -types::sessionId_t SomeIpMessage::sessionId() const { - return m_podPayload.sessionId; -} - -void SomeIpMessage::setProtocolVersion(const types::protocolVersion_t &_protocolVersion) { - m_podPayload.protocolVersion = _protocolVersion; -} - -types::protocolVersion_t SomeIpMessage::protocolVersion() const { - return m_podPayload.protocolVersion; -} - -void SomeIpMessage::setInterfaceVersion(const types::interfaceVersion_t &_interfaceVersion) { - m_podPayload.interfaceVersion = _interfaceVersion; -} - -types::interfaceVersion_t SomeIpMessage::interfaceVersion() const { - return m_podPayload.interfaceVersion; -} - -void SomeIpMessage::setMsgType(const types::messageType_e &_msgType) { - m_podPayload.msgType = _msgType; -} - -types::messageType_e SomeIpMessage::msgType() const { - return m_podPayload.msgType; -} - -void SomeIpMessage::setRetCode(const types::returnCode_e &_retCode) { - m_podPayload.retCode = _retCode; -} - -types::returnCode_e SomeIpMessage::retCode() const { - return m_podPayload.retCode; -} - -void SomeIpMessage::print() const { - // Store original format - std::ios_base::fmtflags prevFmt(std::cout.flags()); - - // Print payload - std::cout << "[" __FILE__ "]" - << "\n\tPOD size: " << serialization::PodPayload::size() - << "\n\t--\n\tlength: " << length() << '\n' - << std::hex << std::showbase << "\tserviceId: " << unsigned(serviceId()) - << "\n\tmethodId: " << unsigned(methodId()) - << "\n\tclientId: " << unsigned(clientId()) - << "\n\tretCode: " << unsigned(retCode()) - << "\n\tmsgType: " << unsigned(msgType()) - << "\n\tsessionId: " << unsigned(sessionId()) - << "\n\tprotocolVersion: " << unsigned(protocolVersion()) - << "\n\tinterfaceVersion: " << unsigned(interfaceVersion()) - << "\n\t--" << std::dec - << "\n\tPayload Size: " << unsigned(payloadSize()) << '\n'; - - // Restore original format - std::cout.flags(prevFmt); -} - -std::vector> SomeIpMessage::readSomeIpMessages(boost::asio::ip::udp::socket *_udp_socket, - const int _expected_stream_size, bool& _keep_receiving) { - // Create a buffer to receive incoming messages from the socket. - std::vector receive_buffer(_expected_stream_size); - - boost::system::error_code error; - - // Read messages from the udp socket and store them in the uint8_t vector. - std::size_t bytes_transferred = _udp_socket->receive( - boost::asio::buffer(receive_buffer, receive_buffer.capacity()), 0, error); - - if (error) { - _keep_receiving = false; - std::cout << __func__ << " error: " << error.message(); - } - - // Vector of SOMEIP messages. - std::vector> messages; - - // Create a stream buffer. - std::shared_ptr pStreambuf = std::make_shared(); - pStreambuf->prepare(_expected_stream_size); - - // Create an io stream to deserialize incoming messages with someip_lib. - std::iostream ios(pStreambuf.get()); - - // Feed _bytes to the io stream. - for (int i = 0; i < int(bytes_transferred); i++) { - ios << receive_buffer[i]; - } - - // Extract all the messages in the stream. - std::size_t messageLengthSum = 0; - while (messageLengthSum < bytes_transferred) { - // Extract a Some-IP message from the stream. - auto message = std::make_shared(); - const std::size_t msgLength = message->deserialize(ios); - messages.push_back(message); - messageLengthSum += msgLength; - } - - return messages; -} - -void SomeIpMessage::sendSomeIpMessage(boost::asio::ip::udp::socket *_udp_socket , boost::asio::ip::udp::socket::endpoint_type _target, SomeIpMessage _message) { - std::size_t size_sub_msg = 0; - size_sub_msg += _message.actualSize(); - auto stream_buf_sub = std::make_shared(); - stream_buf_sub->prepare(size_sub_msg); - std::ostream os_sub(stream_buf_sub.get()); - _message.serialize(os_sub); - - // Send a subscription message. - _udp_socket->send_to(boost::asio::buffer(stream_buf_sub->data()), _target); -} - -SomeIpMessageBuilder SomeIpMessage::create() { - return SomeIpMessageBuilder(); -} - -SomeIpMessageBuilder::operator SomeIpMessage() const { - return std::move(m_entry); -} - -SomeIpMessageBuilder &SomeIpMessageBuilder::serviceId(const types::serviceId_t _service) { - m_entry.setServiceId(_service); - return *this; -} - -SomeIpMessageBuilder &SomeIpMessageBuilder::methodId(const types::methodId_t _method) { - m_entry.setMethodId(_method); - return *this; -} - -SomeIpMessageBuilder &SomeIpMessageBuilder::clientId(const types::clientId_t _client) { - m_entry.setClientId(_client); - return *this; -} - -SomeIpMessageBuilder &SomeIpMessageBuilder::sessionId(const types::sessionId_t _session) { - m_entry.setSessionId(_session); - return *this; -} - -SomeIpMessageBuilder & -SomeIpMessageBuilder::protocolVersion(const types::protocolVersion_t _protoVer) { - m_entry.setProtocolVersion(_protoVer); - return *this; -} - -SomeIpMessageBuilder & -SomeIpMessageBuilder::interfaceVersion(const types::interfaceVersion_t _ifaceVer) { - m_entry.setInterfaceVersion(_ifaceVer); - return *this; -} - -SomeIpMessageBuilder &SomeIpMessageBuilder::messageType(const types::messageType_e _msgType) { - m_entry.setMsgType(_msgType); - return *this; -} - -SomeIpMessageBuilder &SomeIpMessageBuilder::returnCode(const types::returnCode_e _retCode) { - m_entry.setRetCode(_retCode); - return *this; -} - -} // namespace someip -} // namespace vsomeip_utilities diff --git a/test/common/someip_lib/utils/CMakeLists.txt b/test/common/someip_lib/utils/CMakeLists.txt deleted file mode 100644 index be92c147f..000000000 --- a/test/common/someip_lib/utils/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -project (utils) - -# ---------------------------------------------------------------------------- -# Include all source files (cpp/hpp) -# ---------------------------------------------------------------------------- -file (GLOB SRC src/*.cpp src/*.hpp) -file (GLOB INC include/*.hpp) -# ---------------------------------------------------------------------------- -# Declare the library -# ---------------------------------------------------------------------------- -add_library ( - ${PROJECT_NAME} SHARED - ${SRC} - ${INC} -) -# ---------------------------------------------------------------------------- -# Specify here the include directories exported -# by this library -# ---------------------------------------------------------------------------- -target_include_directories ( - ${PROJECT_NAME} - PUBLIC include - PRIVATE src -) diff --git a/test/common/someip_lib/utils/include/utils/logger.hpp b/test/common/someip_lib/utils/include/utils/logger.hpp deleted file mode 100644 index c070314fa..000000000 --- a/test/common/someip_lib/utils/include/utils/logger.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __LOGGER_H__ -#define __LOGGER_H__ - -#include -#include -#include -#include -#include - -namespace vsomeip_utilities { -namespace utils { -namespace logger { - -#define LOG_FATAL vsomeip_utilities::utils::logger::message(vsomeip_utilities::utils::logger::level_e::LL_FATAL) -#define LOG_ERROR vsomeip_utilities::utils::logger::message(vsomeip_utilities::utils::logger::level_e::LL_ERROR) -#define LOG_WARNING vsomeip_utilities::utils::logger::message(vsomeip_utilities::utils::logger::level_e::LL_WARNING) -#define LOG_INFO vsomeip_utilities::utils::logger::message(vsomeip_utilities::utils::logger::level_e::LL_INFO) -#define LOG_DEBUG vsomeip_utilities::utils::logger::message(vsomeip_utilities::utils::logger::level_e::LL_DEBUG) -#define LOG_TRACE vsomeip_utilities::utils::logger::message(vsomeip_utilities::utils::logger::level_e::LL_VERBOSE) - -enum level_e { LL_FATAL, LL_ERROR, LL_WARNING, LL_INFO, LL_DEBUG, LL_VERBOSE }; - -class message - : public std::ostream { - -public: - message(level_e _level); - ~message(); - -private: - class buffer : public std::streambuf { - public: - int_type overflow(int_type); - std::streamsize xsputn(const char *, std::streamsize); - std::stringstream data_; - }; - - std::chrono::system_clock::time_point when_; - buffer buffer_; - level_e level_; - static std::mutex mutex__; -}; - -} // logger -} // utils -} // vsomeip_utilities - -#endif // __LOGGER_H__ diff --git a/test/common/someip_lib/utils/include/utils/utils.hpp b/test/common/someip_lib/utils/include/utils/utils.hpp deleted file mode 100644 index 8f7ce4d1a..000000000 --- a/test/common/someip_lib/utils/include/utils/utils.hpp +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef __UTILS_H__ -#define __UTILS_H__ - -#include - -namespace vsomeip_utilities { -namespace utils { - -// Empty string constant -constexpr char EMPTY_STRING[] = ""; - -enum class metadataCode_e : std::uint8_t { - E_SERVICE_DISCOVERY = 0x00, - E_PAYLOAD_SERIALIZATION = 0x01, - E_PROTOCOL = 0x02 -}; - -/** - * @brief std::error_code convertion utility method - * - * @param _errc Int error - * @return std::error_code - */ -std::error_code intToStdError(int _errc); - -/** - * @brief std::error_code convertion utility method - * - * @param _errc std::errc error - * @return std::error_code - */ -std::error_code intToStdError(std::errc _errc); - -/** - * @brief Swap _x endianess - * - * @tparam T - * @param _x - * @return T - */ -template -T swapEndianness(const T &_x) { - T ret; - - char *dst = reinterpret_cast(&ret); - const char *src = reinterpret_cast(&_x); - - // Swap byte ordering - for (std::size_t i = sizeof(T); i > 0; --i) { - *dst++ = src[i - 1]; - } - - return ret; -} - -void printBinPayload(const char *_data, std::size_t _size); -void printHexPayload(const char *_data, std::size_t _size); - -/** Store an hardware address in the array. */ -void encodeHardwareAddress(const std::string _address, std::uint8_t *_array); - -/** Retrieve an hardware address from the array. */ -std::string decodeHardwareAddress(const std::uint8_t *_array); - -/** Store a protocol address in the array. */ -void encodeIpAddress(const std::string _address, std::uint8_t *_array); - -/** Retrieve a protocol address from the array. */ -std::string decodeIpAddress(const std::uint8_t *_array); - -} // utils -} // vsomeip_utilities - -#endif // __UTILS_H__ diff --git a/test/common/someip_lib/utils/src/logger.cpp b/test/common/someip_lib/utils/src/logger.cpp deleted file mode 100644 index 7464baa32..000000000 --- a/test/common/someip_lib/utils/src/logger.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -#include -#include -#include - -namespace vsomeip_utilities { -namespace utils { -namespace logger { - -constexpr char COLOR_RESET[] { "\033[0m" }; -constexpr char COLOR_RED[] { "\033[31m" }; -constexpr char COLOR_GREEN[] { "\033[32m" }; -constexpr char COLOR_YELLOW[] { "\033[33m" }; -constexpr char COLOR_BLUE[] { "\033[34m" }; -constexpr char COLOR_PURPLE[] { "\033[35m" }; -constexpr char COLOR_WHITE[] { "\033[37m" }; - -std::mutex message::mutex__; - -message::message(level_e _level) - : std::ostream(&buffer_), - level_(_level) { - when_ = std::chrono::system_clock::now(); -} - -message::~message() { - std::lock_guard its_lock(mutex__); - - // Prepare time stamp - const auto nowAsTimeT = std::chrono::system_clock::to_time_t(when_); - const auto nowMs = - std::chrono::duration_cast(when_.time_since_epoch()) % 1000; - - // Store original format - std::ios_base::fmtflags prevFmt(std::cout.flags()); - - switch (level_) { - case level_e::LL_FATAL: - std::cout << COLOR_RED; - break; - case level_e::LL_ERROR: - std::cout << COLOR_PURPLE; - break; - case level_e::LL_WARNING: - std::cout << COLOR_YELLOW; - break; - case level_e::LL_INFO: - std::cout << COLOR_GREEN; - break; - case level_e::LL_VERBOSE: - std::cout << COLOR_BLUE; - break; - case level_e::LL_DEBUG: - std::cout << COLOR_WHITE; - break; - default: - break; - } - - std::cout << '[' << std::put_time(std::localtime(&nowAsTimeT), "%T") << '.' - << std::setfill('0') << std::setw(3) << nowMs.count() - << "] " << COLOR_RESET << buffer_.data_.str() << '\n'; - - // Restore original format - std::cout.flags(prevFmt); -} - -std::streambuf::int_type -message::buffer::overflow(std::streambuf::int_type c) { - if (c != EOF) { - data_ << char(c); - } - return c; -} - -std::streamsize -message::buffer::xsputn(const char *s, std::streamsize n) { - data_.write(s, n); - return n; -} - -} // logger -} // utils -} // vsomeip_utilities diff --git a/test/common/someip_lib/utils/src/utils.cpp b/test/common/someip_lib/utils/src/utils.cpp deleted file mode 100644 index 2a9c9b295..000000000 --- a/test/common/someip_lib/utils/src/utils.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include -#include -#include -#include - -#include -#include - -#include - -namespace vsomeip_utilities { -namespace utils { - -std::error_code intToStdError(int _errc) { - return std::make_error_code(static_cast(_errc)); -} - -std::error_code intToStdError(std::errc _errc) { - return intToStdError(static_cast(_errc)); -} - -void printBinPayload(const char *_data, std::size_t _size) { - std::cout << "[PAYLOAD]\n"; - for (std::size_t i = 0; i < _size; ++i) { - std::cout << 'b' << std::bitset<8>(_data[i]) << ' '; - } - std::cout << "\n[!PAYLOAD]\n"; -} - -void printHexPayload(const char *_data, std::size_t _size) { - // Store original format - std::ios_base::fmtflags prevFmt(std::cout.flags()); - - // Print payload - std::cout << "[PAYLOAD]\n"; - // Set hex format - for (std::size_t i = 0; i < _size; i++) { - std::cout << std::hex << std::setfill('0') << std::setw(2) << int(_data[i] & 0xFF) << ' '; - } - std::cout << "\n[!PAYLOAD]\n"; - - // Restore original format - std::cout.flags(prevFmt); -} - -void encodeHardwareAddress(const std::string _address, std::uint8_t *_array) { - ether_addr *hardwareAddress = ether_aton(_address.c_str()); - for (auto t : boost::adaptors::reverse(hardwareAddress->ether_addr_octet)) { - *_array = t; - _array++; - } -} - -std::string decodeHardwareAddress(const std::uint8_t *_array) { - auto hardwareAddress = std::make_shared(); - for (auto &t : boost::adaptors::reverse(hardwareAddress->ether_addr_octet)) { - t = *_array; - _array++; - } - return ether_ntoa(hardwareAddress.get()); -} - -void encodeIpAddress(const std::string _address, std::uint8_t *_array) { - auto ipAddress = boost::asio::ip::make_address_v4(_address); - for (auto t : boost::adaptors::reverse(ipAddress.to_bytes())) { - *_array = t; - _array++; - } -} - -std::string decodeIpAddress(const std::uint8_t *_array) { - boost::asio::ip::address_v4::bytes_type addressBytes; - for (auto &t : boost::adaptors::reverse(addressBytes)) { - t = *_array; - _array++; - } - auto ipAddress = boost::asio::ip::make_address_v4(addressBytes); - return ipAddress.to_string(); -} - -} // utils -} // vsomeip_utilities diff --git a/test/common/src/utility.cpp b/test/common/src/utility.cpp index defc6473e..cdf6db8a9 100644 --- a/test/common/src/utility.cpp +++ b/test/common/src/utility.cpp @@ -128,7 +128,8 @@ utility::force_check_credentials( } void utility::get_policy_uids(vsomeip_v3::configuration_element &_policy_element, - std::vector &_out_uids) { + std::vector &_out_uids) +{ try { std::vector user_ids; auto policy_tree = _policy_element.tree_.get_child("security.policies"); @@ -153,7 +154,8 @@ void utility::get_policy_uids(vsomeip_v3::configuration_element &_policy_element } void utility::get_policy_services(vsomeip_v3::configuration_element &_policy_element, - std::vector &_out_services) { + std::vector &_out_services) +{ try { std::vector services; auto policy_tree = _policy_element.tree_.get_child("security.policies"); @@ -192,7 +194,8 @@ void utility::get_policy_services(vsomeip_v3::configuration_element &_policy_ele } void utility::add_security_whitelist(vsomeip_v3::configuration_element &_policy_element, - const bool _check_whitelist) { + const bool _check_whitelist) +{ std::vector user_ids; get_policy_uids(_policy_element, user_ids); @@ -205,7 +208,8 @@ void utility::add_security_whitelist(vsomeip_v3::configuration_element &_policy_ void utility::add_security_whitelist(vsomeip_v3::configuration_element &_policy_element, const std::vector &_user_ids, const std::vector &_services, - const bool _check_whitelist) { + const bool _check_whitelist) +{ // Add the user ids to the whitelist. boost::property_tree::ptree id_array_node; for (auto user_id : _user_ids) { diff --git a/test/common/src/vsomeip_app_utilities.cpp b/test/common/src/vsomeip_app_utilities.cpp index b0a6c4a95..f2e00106c 100644 --- a/test/common/src/vsomeip_app_utilities.cpp +++ b/test/common/src/vsomeip_app_utilities.cpp @@ -9,7 +9,8 @@ namespace vsomeip_utilities { std::shared_ptr create_standard_vsip_request( vsomeip::service_t _service, vsomeip::instance_t _instance, vsomeip_v3::method_t _method, - vsomeip_v3::interface_version_t _interface, vsomeip_v3::message_type_e _message_type) { + vsomeip_v3::interface_version_t _interface, vsomeip_v3::message_type_e _message_type) +{ auto its_runtime = vsomeip::runtime::get(); auto its_payload = its_runtime->create_payload(); auto its_message = its_runtime->create_request(false); @@ -25,7 +26,8 @@ std::shared_ptr create_standard_vsip_request( base_logger::base_logger(const char *dlt_application_id, const char *dlt_application_name) : _dlt_application_id(dlt_application_id), - _dlt_application_name(dlt_application_name) { + _dlt_application_name(dlt_application_name) +{ #ifdef USE_DLT #ifndef ANDROID DLT_REGISTER_APP(_dlt_application_id, _dlt_application_name); @@ -33,7 +35,8 @@ base_logger::base_logger(const char *dlt_application_id, const char *dlt_applica #endif } -base_logger::~base_logger() { +base_logger::~base_logger() +{ #ifdef USE_DLT #ifndef ANDROID DLT_UNREGISTER_APP(); @@ -41,17 +44,20 @@ base_logger::~base_logger() { #endif } -base_vsip_app::base_vsip_app(const char *app_name_, const char *app_id_) : base_logger( app_name_, app_id_) { +base_vsip_app::base_vsip_app(const char *app_name_, const char *app_id_) : base_logger( app_name_, app_id_) +{ _app = vsomeip::runtime::get()->create_application(app_name_); _app->init(); _run_thread = std::thread(std::bind(&base_vsip_app::run, this)); } -void base_vsip_app::run() { +void base_vsip_app::run() +{ _app->start(); } -base_vsip_app::~base_vsip_app() { +base_vsip_app::~base_vsip_app() +{ _app->stop(); _run_thread.join(); } diff --git a/test/network_tests/CMakeLists.txt b/test/network_tests/CMakeLists.txt index d16694559..e016e0cf7 100644 --- a/test/network_tests/CMakeLists.txt +++ b/test/network_tests/CMakeLists.txt @@ -3295,76 +3295,6 @@ if(NOT ${TESTS_BAT}) ) endif() -############################################################################## -# processing unknown type option sd message test -############################################################################## -if(NOT ${TESTS_BAT}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wconversion -Wextra") - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_CXX_EXTENSIONS OFF) - set(THREADS_PREFER_PTHREAD_FLAG ON) - - set(TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME unknown_sd_option_type_test) - set(TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME}_service) - add_executable(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE} processing_unknown_sd_option_type_test/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME}_service.cpp) - target_link_libraries(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE} - ${VSOMEIP_NAME} - ${Boost_LIBRARIES} - ${DL_LIBRARY} - ${TEST_LINK_LIBRARIES} - ) - - file(GLOB sd_sources - "../../implementation/service_discovery/src/*entry*.cpp" - "../../implementation/service_discovery/src/*option*.cpp" - "../../implementation/service_discovery/src/*message*.cpp" - ) - set(TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CLIENT ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME}_client) - add_executable(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CLIENT} - processing_unknown_sd_option_type_test/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME}_client.cpp - ${PROJECT_SOURCE_DIR}/implementation/message/src/deserializer.cpp - ${PROJECT_SOURCE_DIR}/implementation/message/src/message_impl.cpp - ${PROJECT_SOURCE_DIR}/implementation/message/src/payload_impl.cpp - ${sd_sources} - ) - - target_link_libraries(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CLIENT} - ${Boost_LIBRARIES} - ${DL_LIBRARY} - ${TEST_LINK_LIBRARIES} - ${VSOMEIP_NAME} - ${VSOMEIP_NAME}-sd - utils - serialization - communication - someip - ) - - # copy starter scripts into builddir - set(TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_MASTER_STARTER ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME}_master_starter.sh) - configure_file( - ${NETWORK_TEST_SRC_DIR}/processing_unknown_sd_option_type_test/conf/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_MASTER_STARTER}.in - ${NETWORK_TEST_SRC_DIR}/processing_unknown_sd_option_type_test/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_MASTER_STARTER} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/processing_unknown_sd_option_type_test/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_MASTER_STARTER} - ${NETWORK_TEST_BIN_DIR}/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_MASTER_STARTER} - ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE} - ) - - # Copy config file for local test into $BUILDDIR/test - set(TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CONFIG_FILE ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME}_master.json) - configure_file( - ${NETWORK_TEST_SRC_DIR}/processing_unknown_sd_option_type_test/conf/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/processing_unknown_sd_option_type_test/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/processing_unknown_sd_option_type_test/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CONFIG_FILE} - ${NETWORK_TEST_BIN_DIR}/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CONFIG_FILE} - ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE} - ) -endif() - ############################################################################## # malicious data tests ############################################################################## @@ -4237,8 +4167,6 @@ if(NOT ${TESTS_BAT}) add_dependencies(${TEST_OFFERED_SERVICES_INFO_SERVICE} gtest) add_dependencies(${TEST_PENDING_SUBSCRIPTION_SERVICE} gtest) add_dependencies(${TEST_PENDING_SUBSCRIPTION_CLIENT} gtest) - add_dependencies(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE} gtest) - add_dependencies(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CLIENT} gtest) add_dependencies(${TEST_MALICIOUS_DATA_SERVICE} gtest) add_dependencies(${TEST_MALICIOUS_DATA_CLIENT} gtest) if (${TEST_SECURITY}) @@ -4348,8 +4276,6 @@ if(NOT ${TESTS_BAT}) add_dependencies(build_network_tests ${TEST_OFFERED_SERVICES_INFO_SERVICE}) add_dependencies(build_network_tests ${TEST_PENDING_SUBSCRIPTION_SERVICE}) add_dependencies(build_network_tests ${TEST_PENDING_SUBSCRIPTION_CLIENT}) - add_dependencies(build_network_tests ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_SERVICE}) - add_dependencies(build_network_tests ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_CLIENT}) add_dependencies(build_network_tests ${TEST_MALICIOUS_DATA_SERVICE}) add_dependencies(build_network_tests ${TEST_MALICIOUS_DATA_CLIENT}) add_dependencies(build_network_tests ${TEST_E2E_SERVICE}) @@ -4903,11 +4829,6 @@ if(NOT ${TESTS_BAT}) COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_PENDING_SUBSCRIPTION_MASTER_STARTER} REQUEST_TO_SD) set_tests_properties(${TEST_PENDING_SUBSCRIPTION_NAME}_send_request_to_sd_port PROPERTIES TIMEOUT 180) - # unknown type option sd message test - add_test(NAME ${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME} - COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_MASTER_STARTER}) - set_tests_properties(${TEST_UNKNOWN_TYPE_OPTION_SD_MESSAGE_NAME} PROPERTIES TIMEOUT 180) - # malicious data test add_test(NAME ${TEST_MALICIOUS_DATA_NAME}_events COMMAND ${NETWORK_TEST_BIN_DIR}/${TEST_MALICIOUS_DATA_MASTER_STARTER} MALICIOUS_EVENTS) diff --git a/test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master.json.in b/test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master.json.in deleted file mode 100644 index 7cbe54126..000000000 --- a/test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master.json.in +++ /dev/null @@ -1,55 +0,0 @@ -{ - "unicast":"@TEST_IP_MASTER@", - "logging": - { - "level":"info", - "console":"true", - "file": - { - "enable":"false", - "path":"/tmp/vsomeip.log" - }, - "dlt":"true" - }, - "applications" : - [ - { - "name" : "unknown_sd_options_test_service", - "id" : "0xCAFE", - "max_dispatch_time" : "1000" - } - ], - "services": - [ - { - "service":"0x1122", - "instance":"0x0001", - "unreliable":"30001", - "reliable": - { - "port":"40001", - "enable-magic-cookies":"false" - }, - "events" : - [ - { - "event" : "0x1111", - "is_reliable" : "false" - }, - { - "event" : "0x1112", - "is_reliable" : "false" - } - ] - } - ], - "routing":"routingmanagerd", - "service-discovery": - { - "enable":"true", - "multicast":"224.0.23.1", - "port":"30490", - "protocol":"udp", - "cyclic_offer_delay" : "1000" - } -} diff --git a/test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master_starter.sh.in b/test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master_starter.sh.in deleted file mode 100755 index 1e361ecf0..000000000 --- a/test/network_tests/processing_unknown_sd_option_type_test/conf/unknown_sd_option_type_test_master_starter.sh.in +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# Purpose: This script is needed to start the services with -# one command. This is necessary as ctest - which is used to run the -# tests - isn't able to start multiple binaries for one testcase. Therefore -# the testcase simply executes this script. This script then runs the services -# and checks that all exit successfully. - -FAIL=0 - -export VSOMEIP_CONFIGURATION=unknown_sd_option_type_test_master.json -# start daemon -../../examples/routingmanagerd/routingmanagerd & -PID_VSOMEIPD=$! -# Start the services -./unknown_sd_option_type_test_service $1 & -PID_SERIVCE=$! - -sleep 1 - -if [ ! -z "$USE_LXC_TEST" ]; then - echo "Waiting for 5s" - sleep 5 - echo "starting offer test on slave LXC offer_test_external_slave_starter.sh" - ssh -tt -i $SANDBOX_ROOT_DIR/commonapi_main/lxc-config/.ssh/mgc_lxc/rsa_key_file.pub -o StrictHostKeyChecking=no root@$LXC_TEST_SLAVE_IP "bash -ci \"set -m; cd \\\$SANDBOX_TARGET_DIR/vsomeip_lib/test/network_tests; ./unknown_sd_option_type_test_client @TEST_IP_MASTER@ @TEST_IP_SLAVE@\"" & - echo "remote ssh pid: $!" -elif [ ! -z "$USE_DOCKER" ]; then - echo "Waiting for 5s" - sleep 5 - docker exec $DOCKER_IMAGE sh -c "cd $DOCKER_TESTS && ./unknown_sd_option_type_client @TEST_IP_MASTER@ @TEST_IP_SLAVE@" & -else -cat < -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "../../implementation/service_discovery/include/constants.hpp" -#include "../../implementation/service_discovery/include/enumeration_types.hpp" - -#include "unknown_sd_option_type_test_globals.hpp" - -static char* remote_address; -static char* local_address; - -using namespace unknown_sd_option_type_test; -using namespace vsomeip_utilities::someip; -using namespace vsomeip_utilities::someip::sd; - -class unknown_sd_option_type_client : public ::testing::Test { -public: - unknown_sd_option_type_client() : - work_(std::make_shared(io_)), - io_thread_(std::bind(&unknown_sd_option_type_client::io_run, this)) {} - -protected: - void TearDown() { - work_.reset(); - io_thread_.join(); - io_.stop(); - } - - void io_run() { - io_.run(); - } - - boost::asio::io_context io_; - std::shared_ptr work_; - std::thread io_thread_; -}; - -/* - * @test Send a subscription to the service and check that the - * subscription is answered with an SubscribeEventgroupAck entry by the service. - * Check that the subscription is active at the end of the test and check that - * the notifications sent by the service are received by the client - */ -TEST_F(unknown_sd_option_type_client, send_subscription) { - std::promise trigger_notifications; - - // Create UDP socket. - boost::asio::ip::udp::socket udp_socket(io_, - boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), SD_PORT)); - udp_socket.set_option(boost::asio::socket_base::reuse_address(true)); - udp_socket.set_option(boost::asio::socket_base::linger(true, 0)); - - // Create thread to receive messages. - std::thread receive_thread([&]() { - // Acknowledge counter. - std::uint32_t subscribe_acks_received = 0; - - // Read control boolean. - bool keep_receiving(true); - - while (keep_receiving) { - // Creating a vector to receive SOMEIP Messages. - std::vector> someip_msgs; - - // Read SOMEIP messages. - someip_msgs = SomeIpMessage::readSomeIpMessages(&udp_socket, vsomeip_utilities::com::DEFAULT_BUFFER_SIZE, keep_receiving); - - for (auto someip_msg : someip_msgs) { - if (someip_msg->serviceId() == vsomeip::sd::service && someip_msg->methodId() == vsomeip::sd::method) { - SomeIpSd sd_msg = SomeIpSd::create(); - EXPECT_TRUE(someip_msg->pull(sd_msg) > 0); - for (auto entry : sd_msg.entries().get()) { - EXPECT_EQ(entry.type(), SUBSCRIBE_EVENTGROUP_ACK); - EXPECT_EQ(3u, entry.ttl()); - EXPECT_EQ(entry.serviceId(), SD_SERVICE_ID); - EXPECT_EQ(entry.instanceId(), SD_INSTANCE_ID); - if (entry.type() == SUBSCRIBE_EVENTGROUP_ACK) { - EXPECT_TRUE(entry.eventgroupId() == EVENTGROUP_ID); - subscribe_acks_received++; - std::cout << "RECEIVED ACK\n"; - } - } - EXPECT_EQ(0u, sd_msg.options().length()); - } - } - - if (subscribe_acks_received) { // all subscribeAcks received - trigger_notifications.set_value(true); - keep_receiving = false; - } - } - }); - - // Create thread to send messages. - std::thread send_thread([&]() { - try { - // Create SOMEIP core of subscription message. - SomeIpMessage someip_subscription_msg = SomeIpMessage::create() - .serviceId(SD_DEFAULT_SERVICE_ID) - .methodId(SD_DEFAULT_METHOD_ID) - .clientId(SD_DEFAULT_CLIENT_ID) - .sessionId(SD_SESSION_ID) - .protocolVersion(SOMEIP_VERSION) - .interfaceVersion(SOMEIP_SD_INTERFACE_VERSION) - .messageType(types::messageType_e::E_MT_NOTIFICATION) - .returnCode(types::returnCode_e::E_RC_OK); - - // Create SOMEIP-SD header of subscription message. - SomeIpSd sd_header = SomeIpSd::create().reboot(true).unicast(true).controlFlag(false); - - // Create Eventgroup subscription entry. - SomeIpSdEntry sd_entry = SomeIpSdEntry::create() - .type(std::uint8_t(vsomeip_v3::sd::entry_type_e::SUBSCRIBE_EVENTGROUP)) - .index1st(1) - .optsCount(0x01) - .optsCount1st(0x01) - .optsCount2nd(0x00) - .serviceId(SD_SERVICE_ID) - .instanceId(SD_INSTANCE_ID) - .majorVersion(SD_MAJOR_VERSION) - .ttl(SD_TTL) - .eventgroupCounter(SD_COUNTER) - .eventgroupId(EVENTGROUP_ID); - - // Add entry to SOMEIP-SD header. - sd_header.entries().pushEntry(sd_entry); - - // Create IPV4 endpoint. - options::Ipv4EndpointOption sd_endpoint_option = - options::Ipv4EndpointOption::create() - .ipv4Address(local_address) - .portNumber(SD_PORT) - .protocol(UDP_PROTOCOL); - - // Create a working and an unknown sd option based on ipv4 endpoint. - SomeIpSdOption sd_option = SomeIpSdOption::create().type(0x04).push(sd_endpoint_option); - SomeIpSdOption sd_unknown_option = SomeIpSdOption::create().type(0xFF).push(sd_endpoint_option); - - // Add those options to the sd header. - sd_header.options().pushEntry(sd_unknown_option); - sd_header.options().pushEntry(sd_option); - - // Add sd header to the core SOMEIP message. - someip_subscription_msg.push(sd_header); - - // Create udp socket for SOME/IP-SD message. - boost::asio::ip::udp::socket::endpoint_type target_sd( - boost::asio::ip::address::from_string(remote_address), - SD_PORT); - - // Create the endpoint to be used to send SOME/IP-SD eventgroup subscription. - SomeIpMessage::sendSomeIpMessage(&udp_socket, target_sd, someip_subscription_msg); - - if (std::future_status::timeout == trigger_notifications.get_future().wait_for(std::chrono::seconds(10))) { - ADD_FAILURE() << "Didn't receive SubscribeAck within time"; - } - - // Create shutdown method call message. - SomeIpMessage shutdown_message = SomeIpMessage::create() - .serviceId(SD_SERVICE_ID) - .methodId(SHUTDOWN_METHOD_ID) - .clientId(SD_CLIENT_ID) - .protocolVersion(SOMEIP_VERSION) - .interfaceVersion(SOMEIP_INTERFACE_VERSION) - .messageType(types::messageType_e::E_MT_REQUEST) - .returnCode(types::returnCode_e::E_RC_OK); - - - // Create the endpoint to be used to send SOME/IP shutdown method call. - boost::asio::ip::udp::socket::endpoint_type target_service( - boost::asio::ip::address::from_string(remote_address), - SERVER_PORT); - - // Send shutdown method call. - SomeIpMessage::sendSomeIpMessage(&udp_socket, target_service, shutdown_message); - } catch (...) { - ASSERT_FALSE(true); - } - - }); - - send_thread.join(); - receive_thread.join(); - boost::system::error_code ec; - udp_socket.shutdown(boost::asio::socket_base::shutdown_both, ec); - udp_socket.close(ec); -} - -#if defined(__linux__) -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - if (argc < 3) { - std::cerr << "Please pass a target and local IP address and test mode to this binary like: " - << argv[0] << " 10.0.3.1 10.0.3.202" << std::endl; - exit(1); - } - remote_address = argv[1]; - local_address = argv[2]; - - return RUN_ALL_TESTS(); -} -#endif diff --git a/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_globals.hpp b/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_globals.hpp deleted file mode 100644 index 6852042ed..000000000 --- a/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_globals.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef UNKNOWN_SD_OPTION_TYPE_TEST_GLOBALS_HPP_ -#define UNKNOWN_SD_OPTION_TYPE_TEST_GLOBALS_HPP_ - -namespace unknown_sd_option_type_test { - -// SOME/IP MESSAGE MACROS -std::uint16_t SD_DEFAULT_SERVICE_ID {0xFFFF}; -std::uint16_t SD_DEFAULT_METHOD_ID {0x8100}; -std::uint16_t SD_DEFAULT_CLIENT_ID {0x0000}; -std::uint16_t SD_CLIENT_ID {0x2222}; -std::uint16_t NOTIF_METHOD_ID {0x4242}; -std::uint16_t SHUTDOWN_METHOD_ID {0x1404}; -std::uint16_t SERVER_PORT {30001}; -std::uint8_t SOMEIP_VERSION {0x01}; -std::uint8_t SOMEIP_INTERFACE_VERSION {0x00}; -std::uint8_t SOMEIP_SD_INTERFACE_VERSION {0x01}; -std::uint8_t UDP_PROTOCOL {0x11}; - -// SD SUBSCRIPTION MESSAGE MACROS -std::uint16_t EVENTGROUP_ID {0x1000}; -std::uint16_t SD_SESSION_ID {0x0001}; -std::uint8_t INTERFACE_VERSION {0x01}; -std::uint16_t SD_SERVICE_ID {0x1122}; -std::uint16_t SD_INSTANCE_ID {0x0001}; -std::uint8_t SD_MAJOR_VERSION {0x00}; -std::uint8_t SD_COUNTER {0x00}; -std::uint32_t SD_TTL {0x00000003}; -std::uint16_t SD_PORT = 0x771A; -std::uint8_t SUBSCRIBE_EVENTGROUP_ACK {0x07}; - -std::uint8_t INDEX_1_OF_ENTRY_1_OPTION_COUNT {27}; -std::uint8_t OPTION_COUNT {0x10}; - -struct service_info { - vsomeip::service_t service_id; - vsomeip::instance_t instance_id; - vsomeip::method_t method_id; - vsomeip::event_t event_id; - vsomeip::eventgroup_t eventgroup_id; - vsomeip::method_t shutdown_method_id; - vsomeip::method_t notify_method_id; -}; - -struct service_info service = { 0x1122, 0x1, 0x1111, 0x1111, 0x1000, 0x1404, 0x4242 }; - -} - -#endif /* UNKNOWN_SD_OPTION_TYPE_TEST_GLOBALS_HPP_ */ diff --git a/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_service.cpp b/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_service.cpp deleted file mode 100644 index 00882a92f..000000000 --- a/test/network_tests/processing_unknown_sd_option_type_test/unknown_sd_option_type_test_service.cpp +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include "unknown_sd_option_type_test_globals.hpp" - -class unknown_sd_option_type_service { -public: - unknown_sd_option_type_service(struct unknown_sd_option_type_test::service_info _service_info) : - service_info_(_service_info), - app_(vsomeip::runtime::get()->create_application("unknown_sd_option_type_service")), - wait_until_registered_(true), - wait_until_shutdown_method_called_(true), - subscription_accepted_asynchronous_(false), - subscription_accepted_synchronous_(false), - offer_thread_(std::bind(&unknown_sd_option_type_service::run, this)) { - if (!app_->init()) { - ADD_FAILURE() << "Couldn't initialize application"; - return; - } - app_->register_state_handler( - std::bind(&unknown_sd_option_type_service::on_state, this, - std::placeholders::_1)); - - // offer field - std::set its_eventgroups; - its_eventgroups.insert(_service_info.eventgroup_id); - app_->offer_event(service_info_.service_id, 0x1, - service_info_.event_id, - its_eventgroups, vsomeip::event_type_e::ET_FIELD, - std::chrono::milliseconds::zero(), - false, true, nullptr, vsomeip::reliability_type_e::RT_UNRELIABLE); - - its_eventgroups.clear(); - its_eventgroups.insert(static_cast(_service_info.eventgroup_id + 1u)); - - app_->offer_event(service_info_.service_id, 0x1, - static_cast(service_info_.event_id + 1u), - its_eventgroups, vsomeip::event_type_e::ET_FIELD, - std::chrono::milliseconds::zero(), - false, true, nullptr, vsomeip::reliability_type_e::RT_UNRELIABLE); - - app_->register_message_handler(vsomeip::ANY_SERVICE, - vsomeip::ANY_INSTANCE, service_info_.shutdown_method_id, - std::bind(&unknown_sd_option_type_service::on_shutdown_method_called, this, - std::placeholders::_1)); - - app_->register_async_subscription_handler(service_info_.service_id, - 0x1, service_info_.eventgroup_id, - std::bind(&unknown_sd_option_type_service::subscription_handler_async, - this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, - std::placeholders::_4, std::placeholders::_5)); - - app_->start(); - } - - ~unknown_sd_option_type_service() { - offer_thread_.join(); - } - - void offer() { - app_->offer_service(service_info_.service_id, 0x1); - } - - void stop() { - app_->stop_offer_service(service_info_.service_id, 0x1); - app_->clear_all_handler(); - app_->stop(); - } - - void on_state(vsomeip::state_type_e _state) { - VSOMEIP_INFO << "Application " << app_->get_name() << " is " - << (_state == vsomeip::state_type_e::ST_REGISTERED ? - "registered." : "deregistered."); - - if (_state == vsomeip::state_type_e::ST_REGISTERED) { - std::lock_guard its_lock(mutex_); - wait_until_registered_ = false; - condition_.notify_one(); - } - } - - void on_shutdown_method_called(const std::shared_ptr &_message) { - app_->send(vsomeip::runtime::get()->create_response(_message)); - VSOMEIP_WARNING << "************************************************************"; - VSOMEIP_WARNING << "Shutdown method called -> going down!"; - VSOMEIP_WARNING << "************************************************************"; - std::lock_guard its_lock(mutex_); - wait_until_shutdown_method_called_ = false; - condition_.notify_one(); - } - - void run() { - VSOMEIP_DEBUG << '[' << std::setw(4) << std::setfill('0') << std::hex - << service_info_.service_id << "] Running"; - std::unique_lock its_lock(mutex_); - while (wait_until_registered_) { - condition_.wait(its_lock); - } - - VSOMEIP_DEBUG << '[' << std::setw(4) << std::setfill('0') << std::hex - << service_info_.service_id << "] Offering"; - offer(); - - while (!subscription_accepted_asynchronous_) { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - } - - async_subscription_handler_(true); - - while (wait_until_shutdown_method_called_) { - condition_.wait(its_lock); - } - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - stop(); - } - - void subscription_handler_async(vsomeip::client_t _client, std::uint32_t, std::uint32_t, - bool _subscribed, const std::function& _cbk) { - VSOMEIP_WARNING << __func__ << ' ' << std::hex << _client << " subscribed." << _subscribed; - - async_subscription_handler_ = _cbk; - static int was_called = 0; - was_called++; - EXPECT_EQ(1, was_called); - EXPECT_TRUE(_subscribed); - subscription_accepted_asynchronous_ = true; - - } - -private: - struct unknown_sd_option_type_test::service_info service_info_; - std::shared_ptr app_; - - bool wait_until_registered_; - bool wait_until_shutdown_method_called_; - std::mutex mutex_; - std::condition_variable condition_; - std::atomic subscription_accepted_asynchronous_; - std::atomic subscription_accepted_synchronous_; - std::thread offer_thread_; - std::function async_subscription_handler_; -}; - -TEST(someip_unknown_sd_option_type_service, send_subscription) { - unknown_sd_option_type_service its_sample(unknown_sd_option_type_test::service); -} - - -#if defined(__linux__) -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} -#endif From f0e9a5b0674ed31655eb16ee8c5863eb3e912b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 10:14:02 +0100 Subject: [PATCH 07/20] Logs added to points of failure on registration process --- .../routing/src/routing_manager_client.cpp | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/implementation/routing/src/routing_manager_client.cpp b/implementation/routing/src/routing_manager_client.cpp index dbb2bd2eb..9a98499f1 100644 --- a/implementation/routing/src/routing_manager_client.cpp +++ b/implementation/routing/src/routing_manager_client.cpp @@ -119,6 +119,10 @@ void routing_manager_client::init() { std::bind(&routing_manager_client::on_net_state_change, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + } else { + VSOMEIP_WARNING << __func__ << ": (" << its_guest_address.to_string() << ":" + << its_host_address.to_string() << ")" + << " local_link_connector not initialized."; } #else receiver_ = ep_mgr_->create_local_server(shared_from_this()); @@ -2072,6 +2076,7 @@ void routing_manager_client::reconnect(const std::map &_c void routing_manager_client::assign_client() { + VSOMEIP_INFO << __func__ << ": (" << std::hex << get_client() << ":" << host_->get_name() << ")"; protocol::assign_client_command its_command; its_command.set_client(get_client()); its_command.set_name(host_->get_name()); @@ -2091,8 +2096,10 @@ void routing_manager_client::assign_client() { if (is_connected_) { std::lock_guard its_lock(sender_mutex_); if (sender_) { - if (state_ != inner_state_type_e::ST_DEREGISTERED) + if (state_ != inner_state_type_e::ST_DEREGISTERED) { + VSOMEIP_WARNING << __func__ << ": (" << std::hex << get_client() << ") Non-Deregistered State Set. Returning"; return; + } state_ = inner_state_type_e::ST_ASSIGNING; sender_->send(&its_buffer[0], static_cast(its_buffer.size())); @@ -2105,8 +2112,13 @@ void routing_manager_client::assign_client() { &routing_manager_client::assign_client_timeout_cbk, std::dynamic_pointer_cast(shared_from_this()), std::placeholders::_1)); + } else { + VSOMEIP_WARNING << __func__ << ": (" << std::hex << get_client() << ") sender not initialized. Ignoring client assignment"; } } + else { + VSOMEIP_WARNING << __func__ << ": (" << std::hex << get_client() << ") not connected. Ignoring client assignment"; + } } void routing_manager_client::register_application() { @@ -2554,6 +2566,9 @@ routing_manager_client::assign_client_timeout_cbk( sender_->restart(); } } + } else { + VSOMEIP_WARNING << __func__ << ": Ignoring Client 0x" << std::hex << get_client() + << " due to error_code: " << _error.value() ; } } @@ -2869,15 +2884,21 @@ void routing_manager_client::on_client_assign_ack(const client_t &_client) { << ") successfully connected to routing ~> registering.."; register_application(); } else { + VSOMEIP_WARNING << __func__ << ": (" << host_->get_name() << ":" + << std::hex << _client << ") Receiver not started. Restarting"; state_ = inner_state_type_e::ST_DEREGISTERED; host_->set_client(VSOMEIP_CLIENT_UNSET); sender_->restart(); } + } else { + VSOMEIP_WARNING << __func__ << ": (" << host_->get_name() << ":" + << std::hex << _client << ") Not started. Discarding"; } } else { - VSOMEIP_ERROR << "Didn't receive valid clientID! Won't register application."; + VSOMEIP_ERROR << __func__ << ": (" << host_->get_name() << ":" + << std::hex << _client << ") Invalid clientID"; } } else { VSOMEIP_WARNING << "Client " << std::hex << get_client() From d85d978ceb997b973611de85c6f5ca5ae4cdf535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 10:18:48 +0100 Subject: [PATCH 08/20] One *.json to ignorem all --- .gitignore | 167 ++--------------------------------------------------- 1 file changed, 5 insertions(+), 162 deletions(-) diff --git a/.gitignore b/.gitignore index a40692934..903904fe1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,171 +9,14 @@ /daemon/CMakeFiles /examples/CMakeFiles /implementation/configuration/include/internal.hpp -/test/network_tests/application_tests/application_test.json -/test/network_tests/application_tests/application_test_daemon.json -/test/network_tests/application_tests/application_test_no_dispatch_threads.json -/test/network_tests/application_tests/application_test_no_dispatch_threads_daemon.json -/test/network_tests/big_payload_tests/big_payload_test_local_tcp_client.json -/test/network_tests/big_payload_tests/big_payload_test_local_tcp_client_limited.json -/test/network_tests/big_payload_tests/big_payload_test_local_tcp_client_queue_limited.json -/test/network_tests/big_payload_tests/big_payload_test_local_tcp_client_random.json -/test/network_tests/big_payload_tests/big_payload_test_local_tcp_service.json -/test/network_tests/big_payload_tests/big_payload_test_local_tcp_service_limited.json -/test/network_tests/big_payload_tests/big_payload_test_local_tcp_service_queue_limited.json -/test/network_tests/big_payload_tests/big_payload_test_local_tcp_service_random.json -/test/network_tests/big_payload_tests/big_payload_test_tcp_client.json -/test/network_tests/big_payload_tests/big_payload_test_tcp_service.json -/test/network_tests/big_payload_tests/big_payload_test_tcp_client_random.json -/test/network_tests/big_payload_tests/big_payload_test_tcp_service_random.json -/test/network_tests/big_payload_tests/big_payload_test_tcp_client_limited_general.json -/test/network_tests/big_payload_tests/big_payload_test_tcp_service_limited_general.json -/test/network_tests/big_payload_tests/big_payload_test_tcp_client_queue_limited_general.json -/test/network_tests/big_payload_tests/big_payload_test_tcp_client_queue_limited_specific.json -/test/network_tests/big_payload_tests/big_payload_test_tcp_service_queue_limited_general.json -/test/network_tests/big_payload_tests/big_payload_test_tcp_service_queue_limited_specific.json -/test/network_tests/big_payload_tests/big_payload_test_udp_client.json -/test/network_tests/big_payload_tests/big_payload_test_udp_service.json -/test/network_tests/lazy_load_tests/lazy_load_test_config.json -/test/network_tests/lazy_load_tests/vsomeip_policy_extensions.json -/test/network_tests/magic_cookies_tests/magic_cookies_test_client.json -/test/network_tests/magic_cookies_tests/magic_cookies_test_service.json -/test/network_tests/debounce_frequency_tests/debounce_frequency_test_client.json -/test/network_tests/debounce_frequency_tests/debounce_frequency_test_service.json -/test/network_tests/payload_tests/external_local_payload_test_client_external.json -/test/network_tests/payload_tests/external_local_payload_test_client_local.json -/test/network_tests/payload_tests/external_local_payload_test_service.json -/test/network_tests/routing_tests/external_local_routing_test_client_external.json -/test/network_tests/routing_tests/external_local_routing_test_service.json -/test/network_tests/routing_tests/local_routing_test_starter.sh -/test/network_tests/client_id_tests/client_id_test_diff_client_ids_diff_ports_master.json -/test/network_tests/client_id_tests/client_id_test_diff_client_ids_diff_ports_slave.json -/test/network_tests/client_id_tests/client_id_test_diff_client_ids_same_ports_master.json -/test/network_tests/client_id_tests/client_id_test_diff_client_ids_same_ports_slave.json -/test/network_tests/client_id_tests/client_id_test_diff_client_ids_partial_same_ports_master.json -/test/network_tests/client_id_tests/client_id_test_diff_client_ids_partial_same_ports_slave.json -/test/network_tests/client_id_tests/client_id_test_same_client_ids_diff_ports_master.json -/test/network_tests/client_id_tests/client_id_test_same_client_ids_diff_ports_slave.json -/test/network_tests/client_id_tests/client_id_test_same_client_ids_same_ports_master.json -/test/network_tests/client_id_tests/client_id_test_same_client_ids_same_ports_slave.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_partial_same_ports_master.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_partial_same_ports_slave.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_diff_ports_master.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_diff_ports_slave.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_same_ports_master.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_same_ports_slave.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_master.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_udp_slave.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_tcp_slave.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master_udp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave_udp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master_udp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave_udp.json -/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_master.json -/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_slave.json -/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_master_tcp.json -/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_tcp.json -/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_master_udp.json -/test/network_tests/subscribe_notify_one_tests/subscribe_notify_one_test_diff_client_ids_diff_ports_slave_udp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master_udp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave_udp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master_tcp_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_master_udp_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_master_udp_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_same_service_id_slave_udp_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave_tcp_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_slave_udp_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_partial_same_ports_master_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_partial_same_ports_slave_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master_tcp_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_master_udp_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave_tcp_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_same_ports_slave_udp_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_master_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_tcp_slave_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_one_event_two_eventgroups_udp_slave_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_diff_ports_master_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_diff_ports_slave_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_same_ports_master_local_tcp.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_same_client_ids_same_ports_slave_local_tcp.json -/test/network_tests/cpu_load_tests/cpu_load_test_client_slave.json -/test/network_tests/cpu_load_tests/cpu_load_test_client_master.json -/test/network_tests/cpu_load_tests/cpu_load_test_service_slave.json -/test/network_tests/cpu_load_tests/cpu_load_test_service_master.json -/tools/CMakeFiles -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_master.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_same_service_id_master.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_same_service_id_slave.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_slave.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_partial_same_ports_master.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_partial_same_ports_slave.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_same_ports_master.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_same_ports_slave.json -/test/network_tests/initial_event_tests/initial_event_test_same_client_ids_diff_ports_master.json -/test/network_tests/initial_event_tests/initial_event_test_same_client_ids_diff_ports_slave.json -/test/network_tests/initial_event_tests/initial_event_test_same_client_ids_same_ports_master.json -/test/network_tests/initial_event_tests/initial_event_test_same_client_ids_same_ports_slave.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_master_tcp.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_slave_tcp.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_same_ports_master_tcp.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_same_ports_slave_tcp.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_master_udp.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_diff_ports_slave_udp.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_same_ports_master_udp.json -/test/network_tests/initial_event_tests/initial_event_test_diff_client_ids_same_ports_slave_udp.json -/test/network_tests/offer_tests/offer_test_external_master.json -/test/network_tests/offer_tests/offer_test_external_slave.json +/test/network_tests/*/*.json +/test/network_tests/malicious_data_tests/malicious_data_test_master_starter.sh /test/network_tests/offer_tests/offer_test_external_master_starter.sh /test/network_tests/offer_tests/offer_test_big_sd_msg_master_starter.sh -/test/network_tests/offer_tests/offer_test_big_sd_msg_master.json -/test/network_tests/offer_tests/offer_test_big_sd_msg_slave.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_master.json -/test/network_tests/subscribe_notify_tests/subscribe_notify_test_diff_client_ids_diff_ports_autoconfig_slave.json -/test/network_tests/security_tests/security_test_config_client_external_allow.json -/test/network_tests/security_tests/security_test_config_client_external_deny.json -/test/network_tests/security_tests/security_test_config_service_external_allow.json -/test/network_tests/security_tests/security_test_config_service_external_deny.json -/test/network_tests/security_tests/security_test_local_config.json -/test/network_tests/pending_subscription_tests/pending_subscription_test_master.json /test/network_tests/pending_subscription_tests/pending_subscription_test_master_starter.sh -/test/network_tests/malicious_data_tests/malicious_data_test_master.json -/test/network_tests/malicious_data_tests/malicious_data_test_master_starter.sh -/test/network_tests/e2e_tests/e2e_profile_04_test_client_external.json -/test/network_tests/e2e_tests/e2e_profile_04_test_service_external.json -/test/network_tests/e2e_tests/e2e_test_client_external.json -/test/network_tests/e2e_tests/e2e_test_service_external.json -/test/network_tests/event_tests/event_test_master.json -/test/network_tests/event_tests/event_test_slave_tcp.json -/test/network_tests/event_tests/event_test_slave_udp.json -/test/network_tests/npdu_tests/npdu_test_client_no_npdu.json -/test/network_tests/npdu_tests/npdu_test_client_npdu.json -/test/network_tests/npdu_tests/npdu_test_service_no_npdu.json -/test/network_tests/npdu_tests/npdu_test_service_npdu.json -/test/network_tests/someip_tp_tests/someip_tp_test_master.json -/test/network_tests/someip_tp_tests/someip_tp_test_master_starter.sh -/test/network_tests/second_address_tests/second_address_test_master_service_udp.json -/test/network_tests/second_address_tests/second_address_test_master_client.json -/test/network_tests/second_address_tests/second_address_test_slave_client.json -/test/network_tests/second_address_tests/second_address_test_slave_service_udp.json +/test/network_tests/routing_tests/local_routing_test_starter.sh /test/network_tests/second_address_tests/second_address_test_slave_starter.sh -/test/network_tests/debounce_tests/debounce_test_client.json -/test/network_tests/debounce_tests/debounce_test_service.json -/test/network_tests/debounce_filter_tests/debounce_filter_test_client.json -/test/network_tests/debounce_filter_tests/debounce_filter_test_service.json -/test/network_tests/suspend_resume_tests/suspend_resume_test_client.json -/test/network_tests/suspend_resume_tests/suspend_resume_test_service.json +/test/network_tests/someip_tp_tests/someip_tp_test_master_starter.sh +/tools/CMakeFiles /Testing !build_qnx/* From 564a1a8930e5e74f7600f85c30e836b6484700b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 10:21:28 +0100 Subject: [PATCH 09/20] Someip-tp remote address rework --- documentation/vsomeipUserGuide | 5 +---- .../configuration/include/configuration.hpp | 4 ++-- .../include/configuration_impl.hpp | 5 ++--- .../configuration/src/configuration_impl.cpp | 8 +++---- .../include/client_endpoint_impl.hpp | 3 ++- .../local_tcp_client_endpoint_impl.hpp | 1 - .../local_tcp_server_endpoint_impl.hpp | 1 - .../local_uds_client_endpoint_impl.hpp | 1 - .../local_uds_server_endpoint_impl.hpp | 1 - .../include/server_endpoint_impl.hpp | 3 ++- .../include/tcp_client_endpoint_impl.hpp | 1 - .../include/tcp_server_endpoint_impl.hpp | 1 - .../include/udp_client_endpoint_impl.hpp | 5 ++++- .../include/udp_server_endpoint_impl.hpp | 5 ++++- .../endpoints/src/client_endpoint_impl.cpp | 13 +++++++++--- .../src/local_tcp_client_endpoint_impl.cpp | 8 ------- .../src/local_tcp_server_endpoint_impl.cpp | 8 ------- .../src/local_uds_client_endpoint_impl.cpp | 8 ------- .../src/local_uds_server_endpoint_impl.cpp | 8 ------- .../endpoints/src/server_endpoint_impl.cpp | 13 +++++++++--- .../src/tcp_client_endpoint_impl.cpp | 7 ------- .../src/tcp_server_endpoint_impl.cpp | 7 ------- .../src/udp_client_endpoint_impl.cpp | 6 ++---- .../src/udp_server_endpoint_impl.cpp | 21 ++++++++++--------- .../conf/big_payload_test_udp_client.json.in | 1 - .../conf/someip_tp_test_master.json.in | 1 - 26 files changed, 54 insertions(+), 91 deletions(-) diff --git a/documentation/vsomeipUserGuide b/documentation/vsomeipUserGuide index 4c1f9842e..ea7a6904e 100644 --- a/documentation/vsomeipUserGuide +++ b/documentation/vsomeipUserGuide @@ -689,9 +689,6 @@ Contains the IDs for requests, which are sent from the node to a remote service which can be segmented via SOME/IP-TP if they exceed the maximum message size for UDP communication. If an ID isn't listed here the message will otherwise be dropped if the maximum message size is exceeded. -Please note that the unicast key has to be set to the remote IP address of the -offering node for this setting to take effect. - * `clients` (array) + @@ -756,7 +753,7 @@ specified otherwise the allowed payload sizes are unlimited. The settings in this array only affect communication over TCP. To limit the local payload size `max-payload-size-local` can be used. -** `unicast` +** `unicast` (optional) + On client side: the IP of the remote service for which the payload size should be limited. diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp index 8b32a0c99..0260a1023 100644 --- a/implementation/configuration/include/configuration.hpp +++ b/implementation/configuration/include/configuration.hpp @@ -276,10 +276,10 @@ class configuration { // SOME/IP-TP virtual bool is_tp_client( - service_t _service, const std::string &_address, std::uint16_t _port, + service_t _service, instance_t _instance, method_t _method) const = 0; virtual bool is_tp_service( - service_t _service, const std::string &_address, std::uint16_t _port, + service_t _service, instance_t _instance, method_t _method) const = 0; virtual void get_tp_configuration( service_t _service, instance_t _instance, method_t _method, bool _is_client, diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp index f30e0ecf5..a229d8b1e 100644 --- a/implementation/configuration/include/configuration_impl.hpp +++ b/implementation/configuration/include/configuration_impl.hpp @@ -261,11 +261,10 @@ class configuration_impl: VSOMEIP_EXPORT bool is_tp_client( service_t _service, - const std::string &_address, std::uint16_t _port, + instance_t _instance, method_t _method) const; VSOMEIP_EXPORT bool is_tp_service( - service_t _service, const std::string &_ip_service, - std::uint16_t _port_service, method_t _method) const; + service_t _service, instance_t _instance, method_t _method) const; VSOMEIP_EXPORT void get_tp_configuration( service_t _service, instance_t _instance, method_t _method, bool _is_client, std::uint16_t &_max_segment_length, std::uint32_t &_separation_time) const; diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index 380b29060..4b12171b3 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -4879,13 +4879,13 @@ int configuration_impl::get_udp_receive_buffer_size() const { bool configuration_impl::is_tp_client( service_t _service, - const std::string &_address, std::uint16_t _port, + instance_t _instance, method_t _method) const { bool ret(false); const auto its_service - = find_service(_service, _address, _port); + = find_service(_service, _instance); if (its_service) { ret = (its_service->tp_client_config_.find(_method) @@ -4897,12 +4897,12 @@ bool configuration_impl::is_tp_client( bool configuration_impl::is_tp_service( service_t _service, - const std::string &_address, std::uint16_t _port, + instance_t _instance, method_t _method) const { bool ret(false); const auto its_service - = find_service(_service, _address, _port); + = find_service(_service, _instance); if (its_service) { ret = (its_service->tp_service_config_.find(_method) != its_service->tp_service_config_.end()); diff --git a/implementation/endpoints/include/client_endpoint_impl.hpp b/implementation/endpoints/include/client_endpoint_impl.hpp index 92c69aa82..4ffaf5299 100644 --- a/implementation/endpoints/include/client_endpoint_impl.hpp +++ b/implementation/endpoints/include/client_endpoint_impl.hpp @@ -153,7 +153,8 @@ class client_endpoint_impl: public endpoint_impl, public client_endpoi virtual void set_local_port() = 0; virtual std::string get_remote_information() const = 0; virtual bool tp_segmentation_enabled(service_t _service, - method_t _method) const = 0; + instance_t _instance, + method_t _method) const; virtual std::uint32_t get_max_allowed_reconnects() const = 0; virtual void max_allowed_reconnects_reached() = 0; void send_segments(const tp::tp_split_messages_t &_segments, diff --git a/implementation/endpoints/include/local_tcp_client_endpoint_impl.hpp b/implementation/endpoints/include/local_tcp_client_endpoint_impl.hpp index 9ea300756..61d3d0f52 100644 --- a/implementation/endpoints/include/local_tcp_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/local_tcp_client_endpoint_impl.hpp @@ -60,7 +60,6 @@ class local_tcp_client_endpoint_impl: public local_tcp_client_endpoint_base_impl void set_local_port(); std::string get_remote_information() const; bool check_packetizer_space(std::uint32_t _size); - bool tp_segmentation_enabled(service_t _service, method_t _method) const; std::uint32_t get_max_allowed_reconnects() const; void max_allowed_reconnects_reached(); diff --git a/implementation/endpoints/include/local_tcp_server_endpoint_impl.hpp b/implementation/endpoints/include/local_tcp_server_endpoint_impl.hpp index 49b6fcb77..a9ddef2ea 100644 --- a/implementation/endpoints/include/local_tcp_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/local_tcp_server_endpoint_impl.hpp @@ -162,7 +162,6 @@ class local_tcp_server_endpoint_impl bool check_packetizer_space(target_data_iterator_type _queue_iterator, message_buffer_ptr_t* _packetizer, std::uint32_t _size); - bool tp_segmentation_enabled(service_t _service, method_t _method) const; void send_client_identifier(const client_t &_client); }; diff --git a/implementation/endpoints/include/local_uds_client_endpoint_impl.hpp b/implementation/endpoints/include/local_uds_client_endpoint_impl.hpp index e1e1aaa23..0c218c040 100644 --- a/implementation/endpoints/include/local_uds_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/local_uds_client_endpoint_impl.hpp @@ -59,7 +59,6 @@ class local_uds_client_endpoint_impl: public local_uds_client_endpoint_base_impl void set_local_port(); std::string get_remote_information() const; bool check_packetizer_space(std::uint32_t _size); - bool tp_segmentation_enabled(service_t _service, method_t _method) const; std::uint32_t get_max_allowed_reconnects() const; void max_allowed_reconnects_reached(); diff --git a/implementation/endpoints/include/local_uds_server_endpoint_impl.hpp b/implementation/endpoints/include/local_uds_server_endpoint_impl.hpp index a4ed2eb57..e4bfdb14c 100644 --- a/implementation/endpoints/include/local_uds_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/local_uds_server_endpoint_impl.hpp @@ -185,7 +185,6 @@ class local_uds_server_endpoint_impl: public local_uds_server_endpoint_base_impl bool check_packetizer_space(target_data_iterator_type _queue_iterator, message_buffer_ptr_t* _packetizer, std::uint32_t _size); - bool tp_segmentation_enabled(service_t _service, method_t _method) const; void send_client_identifier(const client_t &_client); }; diff --git a/implementation/endpoints/include/server_endpoint_impl.hpp b/implementation/endpoints/include/server_endpoint_impl.hpp index b543d97b4..467a344be 100644 --- a/implementation/endpoints/include/server_endpoint_impl.hpp +++ b/implementation/endpoints/include/server_endpoint_impl.hpp @@ -147,7 +147,8 @@ class server_endpoint_impl: public endpoint_impl, virtual std::string get_remote_information( const endpoint_type& _remote) const = 0; virtual bool tp_segmentation_enabled(service_t _service, - method_t _method) const = 0; + instance_t _instance, + method_t _method) const; void schedule_train(endpoint_data_type &_target); void update_last_departure(endpoint_data_type &_data); diff --git a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp index 56b54e798..6c1b9e784 100644 --- a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp @@ -80,7 +80,6 @@ class tcp_client_endpoint_impl: public tcp_client_endpoint_base_impl { std::string get_remote_information() const; std::shared_ptr get_timing( const service_t& _service, const instance_t& _instance) const; - bool tp_segmentation_enabled(service_t _service, method_t _method) const; std::uint32_t get_max_allowed_reconnects() const; void max_allowed_reconnects_reached(); diff --git a/implementation/endpoints/include/tcp_server_endpoint_impl.hpp b/implementation/endpoints/include/tcp_server_endpoint_impl.hpp index 38834acfa..a1187ab1b 100644 --- a/implementation/endpoints/include/tcp_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/tcp_server_endpoint_impl.hpp @@ -148,7 +148,6 @@ class tcp_server_endpoint_impl: public tcp_server_endpoint_base_impl { std::string get_remote_information( const target_data_iterator_type _it) const; std::string get_remote_information(const endpoint_type& _remote) const; - bool tp_segmentation_enabled(service_t _service, method_t _method) const; }; } // namespace vsomeip_v3 diff --git a/implementation/endpoints/include/udp_client_endpoint_impl.hpp b/implementation/endpoints/include/udp_client_endpoint_impl.hpp index 4d02ab27a..02d7cd028 100644 --- a/implementation/endpoints/include/udp_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/udp_client_endpoint_impl.hpp @@ -65,7 +65,10 @@ class udp_client_endpoint_impl: virtual public udp_client_endpoint_base_impl { std::string get_address_port_remote() const; std::string get_address_port_local() const; std::string get_remote_information() const; - bool tp_segmentation_enabled(service_t _service, method_t _method) const; + bool tp_segmentation_enabled( + service_t _service, + instance_t _instance, + method_t _method) const; std::uint32_t get_max_allowed_reconnects() const; void max_allowed_reconnects_reached(); diff --git a/implementation/endpoints/include/udp_server_endpoint_impl.hpp b/implementation/endpoints/include/udp_server_endpoint_impl.hpp index b9b68fbc0..bf8b0f468 100644 --- a/implementation/endpoints/include/udp_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/udp_server_endpoint_impl.hpp @@ -84,7 +84,10 @@ class udp_server_endpoint_impl: public udp_server_endpoint_base_impl { std::string get_remote_information(const endpoint_type& _remote) const; std::string get_address_port_local() const; - bool tp_segmentation_enabled(service_t _service, method_t _method) const; + bool tp_segmentation_enabled( + service_t _service, + instance_t _instance, + method_t _method) const; void on_unicast_received(boost::system::error_code const &_error, std::size_t _bytes); diff --git a/implementation/endpoints/src/client_endpoint_impl.cpp b/implementation/endpoints/src/client_endpoint_impl.cpp index 58041ecae..03254a816 100644 --- a/implementation/endpoints/src/client_endpoint_impl.cpp +++ b/implementation/endpoints/src/client_endpoint_impl.cpp @@ -289,6 +289,13 @@ bool client_endpoint_impl::send(const uint8_t *_data, uint32_t _size) return true; } +template +bool client_endpoint_impl::tp_segmentation_enabled( + service_t /*_service*/, instance_t /*_instance*/, method_t /*_method*/) const { + + return false; +} + template void client_endpoint_impl::send_segments( const tp::tp_split_messages_t &_segments, std::uint32_t _separation_time) { @@ -730,9 +737,9 @@ typename endpoint_impl::cms_ret_e client_endpoint_impl::chec const method_t its_method = VSOMEIP_BYTES_TO_WORD( _data[VSOMEIP_METHOD_POS_MIN], _data[VSOMEIP_METHOD_POS_MAX]); - if (tp_segmentation_enabled(its_service, its_method)) { - instance_t its_instance = this->get_instance(its_service); - if (its_instance != 0xFFFF) { + instance_t its_instance = this->get_instance(its_service); + if (its_instance != ANY_INSTANCE) { + if (tp_segmentation_enabled(its_service, its_instance, its_method)) { std::uint16_t its_max_segment_length; std::uint32_t its_separation_time; this->configuration_->get_tp_configuration( diff --git a/implementation/endpoints/src/local_tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/local_tcp_client_endpoint_impl.cpp index 693f8f210..f0b85afdd 100644 --- a/implementation/endpoints/src/local_tcp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_tcp_client_endpoint_impl.cpp @@ -355,14 +355,6 @@ std::uint32_t local_tcp_client_endpoint_impl::get_max_allowed_reconnects() const return MAX_RECONNECTS_UNLIMITED; } -bool local_tcp_client_endpoint_impl::tp_segmentation_enabled( - service_t _service, method_t _method) const { - - (void)_service; - (void)_method; - return false; -} - void local_tcp_client_endpoint_impl::max_allowed_reconnects_reached() { VSOMEIP_ERROR << "local_client_endpoint::max_allowed_reconnects_reached: " diff --git a/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp index e9ff0ee40..9cd5ef1f9 100644 --- a/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp @@ -909,12 +909,4 @@ local_tcp_server_endpoint_impl::send_client_identifier( send(&its_buffer[0], static_cast(its_buffer.size())); } -bool local_tcp_server_endpoint_impl::tp_segmentation_enabled( - service_t _service, method_t _method) const { - - (void)_service; - (void)_method; - return false; -} - } // namespace vsomeip_v3 diff --git a/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp b/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp index cbe7185f0..96f0ecf8f 100644 --- a/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_uds_client_endpoint_impl.cpp @@ -366,14 +366,6 @@ std::uint32_t local_uds_client_endpoint_impl::get_max_allowed_reconnects() const return 13; } -bool local_uds_client_endpoint_impl::tp_segmentation_enabled( - service_t _service, method_t _method) const { - - (void)_service; - (void)_method; - return false; -} - void local_uds_client_endpoint_impl::max_allowed_reconnects_reached() { VSOMEIP_ERROR << "local_client_endpoint::max_allowed_reconnects_reached: " diff --git a/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp b/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp index 33876c56c..6d5fc6f4c 100644 --- a/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp @@ -1070,12 +1070,4 @@ local_uds_server_endpoint_impl::send_client_identifier( send(&its_buffer[0], static_cast(its_buffer.size())); } -bool local_uds_server_endpoint_impl::tp_segmentation_enabled( - service_t _service, method_t _method) const { - - (void)_service; - (void)_method; - return false; -} - } // namespace vsomeip_v3 diff --git a/implementation/endpoints/src/server_endpoint_impl.cpp b/implementation/endpoints/src/server_endpoint_impl.cpp index a58489ac1..c00e2d035 100644 --- a/implementation/endpoints/src/server_endpoint_impl.cpp +++ b/implementation/endpoints/src/server_endpoint_impl.cpp @@ -374,6 +374,13 @@ bool server_endpoint_impl::send_intern( return true; } +template +bool server_endpoint_impl::tp_segmentation_enabled( + service_t /*_service*/, instance_t /*_instance*/, method_t /*_method*/) const { + + return false; +} + template void server_endpoint_impl::send_segments( const tp::tp_split_messages_t &_segments, std::uint32_t _separation_time, @@ -468,9 +475,9 @@ typename endpoint_impl::cms_ret_e server_endpoint_impl::chec const method_t its_method = VSOMEIP_BYTES_TO_WORD( _data[VSOMEIP_METHOD_POS_MIN], _data[VSOMEIP_METHOD_POS_MAX]); - if (tp_segmentation_enabled(its_service, its_method)) { - instance_t its_instance = this->get_instance(its_service); - if (its_instance != 0xFFFF) { + instance_t its_instance = this->get_instance(its_service); + if (its_instance != ANY_INSTANCE) { + if (tp_segmentation_enabled(its_service, its_instance, its_method)) { std::uint16_t its_max_segment_length; std::uint32_t its_separation_time; diff --git a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp index e67551573..ba078a872 100644 --- a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp @@ -1002,13 +1002,6 @@ void tcp_client_endpoint_impl::send_cbk(boost::system::error_code const &_error, } } -bool tcp_client_endpoint_impl::tp_segmentation_enabled(service_t _service, - method_t _method) const { - (void)_service; - (void)_method; - return false; -} - std::uint32_t tcp_client_endpoint_impl::get_max_allowed_reconnects() const { return MAX_RECONNECTS_UNLIMITED; } diff --git a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp index 5aef72be9..499a5846f 100644 --- a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp @@ -996,13 +996,6 @@ std::string tcp_server_endpoint_impl::get_remote_information( + std::to_string(_remote.port()); } -bool tcp_server_endpoint_impl::tp_segmentation_enabled(service_t _service, - method_t _method) const { - (void)_service; - (void)_method; - return false; -} - void tcp_server_endpoint_impl::connection::wait_until_sent(const boost::system::error_code &_error) { std::shared_ptr its_server(server_.lock()); diff --git a/implementation/endpoints/src/udp_client_endpoint_impl.cpp b/implementation/endpoints/src/udp_client_endpoint_impl.cpp index f52b23540..949c33362 100644 --- a/implementation/endpoints/src/udp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_client_endpoint_impl.cpp @@ -667,11 +667,9 @@ void udp_client_endpoint_impl::send_cbk(boost::system::error_code const &_error, } bool udp_client_endpoint_impl::tp_segmentation_enabled( - service_t _service, method_t _method) const { + service_t _service, instance_t _instance, method_t _method) const { - return configuration_->is_tp_client(_service, - remote_address_.to_string(), remote_port_, - _method); + return configuration_->is_tp_client(_service, _instance, _method); } bool udp_client_endpoint_impl::is_reliable() const { diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp index 587fb94c2..b6f3feb3f 100644 --- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp @@ -650,12 +650,15 @@ void udp_server_endpoint_impl::on_message_received( if (tp::tp::tp_flag_is_set(_buffer[i + VSOMEIP_MESSAGE_TYPE_POS])) { const method_t its_method = VSOMEIP_BYTES_TO_WORD(_buffer[i + VSOMEIP_METHOD_POS_MIN], _buffer[i + VSOMEIP_METHOD_POS_MAX]); - if (!tp_segmentation_enabled(its_service, its_method)) { - VSOMEIP_WARNING << "use: Received a SomeIP/TP message for service: 0x" << std::hex << its_service - << " method: 0x" << its_method << " which is not configured for TP:" - << " local: " << get_address_port_local() - << " remote: " << its_remote_address << ":" << std::dec << its_remote_port; - return; + instance_t its_instance = this->get_instance(its_service); + if (its_instance != ANY_INSTANCE) { + if (!tp_segmentation_enabled(its_service, its_instance, its_method)) { + VSOMEIP_WARNING << "use: Received a SomeIP/TP message for service: 0x" << std::hex << its_service + << " method: 0x" << its_method << " which is not configured for TP:" + << " local: " << get_address_port_local() + << " remote: " << its_remote_address << ":" << std::dec << its_remote_port; + return; + } } const auto res = tp_reassembler_->process_tp_message( &_buffer[i], current_message_size, @@ -828,11 +831,9 @@ std::string udp_server_endpoint_impl::get_address_port_local() const { } bool udp_server_endpoint_impl::tp_segmentation_enabled( - service_t _service, method_t _method) const { + service_t _service, instance_t _instance, method_t _method) const { - return configuration_->is_tp_service(_service, - local_.address().to_string(), local_.port(), - _method); + return configuration_->is_tp_service(_service, _instance, _method); } void diff --git a/test/network_tests/big_payload_tests/conf/big_payload_test_udp_client.json.in b/test/network_tests/big_payload_tests/conf/big_payload_test_udp_client.json.in index 5a7ee365b..d28e5952a 100644 --- a/test/network_tests/big_payload_tests/conf/big_payload_test_udp_client.json.in +++ b/test/network_tests/big_payload_tests/conf/big_payload_test_udp_client.json.in @@ -25,7 +25,6 @@ { "service":"0x1240", "instance":"0x01", - "unicast":"@TEST_IP_SLAVE@", "unreliable": "30509", "someip-tp" : { "client-to-service" : [ "0x8421" ] diff --git a/test/network_tests/someip_tp_tests/conf/someip_tp_test_master.json.in b/test/network_tests/someip_tp_tests/conf/someip_tp_test_master.json.in index 6d20e54d0..b3f9ee436 100644 --- a/test/network_tests/someip_tp_tests/conf/someip_tp_test_master.json.in +++ b/test/network_tests/someip_tp_tests/conf/someip_tp_test_master.json.in @@ -25,7 +25,6 @@ { "service":"0x6767", "instance":"0x1", - "unicast" : "@TEST_IP_SLAVE@", "unreliable":"40001", "someip-tp" : { "client-to-service": [ "0x6767", "0x8001" ] From 6324e5f93b847ccbfbd6e19733cf7da4076a82f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 10:28:59 +0100 Subject: [PATCH 10/20] Fix crash in multicast_receive receive_cb --- .../include/udp_server_endpoint_impl.hpp | 2 +- .../udp_server_endpoint_impl_receive_op.hpp | 22 ++++++++++++------- .../src/udp_server_endpoint_impl.cpp | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/implementation/endpoints/include/udp_server_endpoint_impl.hpp b/implementation/endpoints/include/udp_server_endpoint_impl.hpp index bf8b0f468..851104710 100644 --- a/implementation/endpoints/include/udp_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/udp_server_endpoint_impl.hpp @@ -116,7 +116,7 @@ class udp_server_endpoint_impl: public udp_server_endpoint_base_impl { bool is_v4_; - std::unique_ptr multicast_socket_; + std::shared_ptr multicast_socket_; std::unique_ptr multicast_local_; endpoint_type multicast_remote_; message_buffer_t multicast_recv_buffer_; diff --git a/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp b/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp index 35638cd71..1690ea76b 100644 --- a/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp +++ b/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp @@ -32,7 +32,7 @@ struct storage : public std::enable_shared_from_this { std::recursive_mutex &multicast_mutex_; - socket_type_t &socket_; + std::weak_ptr socket_; endpoint_type_t &sender_; receive_handler_t handler_; byte_t *buffer_ = nullptr; @@ -44,7 +44,7 @@ struct storage : storage( std::recursive_mutex &_multicast_mutex, - socket_type_t &_socket, + std::weak_ptr _socket, endpoint_type_t &_sender, receive_handler_t _handler, byte_t *_buffer, @@ -75,15 +75,21 @@ receive_cb (std::shared_ptr _data) { std::lock_guard its_lock(_data->multicast_mutex_); - if (!_data->socket_.native_non_blocking()) - _data->socket_.native_non_blocking(true, _error); + auto multicast_socket = _data->socket_.lock(); + if (!multicast_socket) { + VSOMEIP_WARNING << "udp_endpoint_receive_op::receive_cb: multicast_socket with id " << int{_data->multicast_id_} << " has expired!"; + return; + } + + if (!multicast_socket->native_non_blocking()) + multicast_socket->native_non_blocking(true, _error); for (;;) { #ifdef _WIN32 GUID WSARecvMsg_GUID = WSAID_WSARECVMSG; LPFN_WSARECVMSG WSARecvMsg; DWORD its_bytes; - SOCKET its_socket { _data->socket_.native_handle() }; + SOCKET its_socket { multicast_socket->native_handle() }; WSAIoctl(its_socket, SIO_GET_EXTENSION_FUNCTION_POINTER, &WSARecvMsg_GUID, sizeof WSARecvMsg_GUID, @@ -146,7 +152,7 @@ receive_cb (std::shared_ptr _data) { if (_error == boost::asio::error::would_block || _error == boost::asio::error::try_again) { - _data->socket_.async_wait( + multicast_socket->async_wait( socket_type_t::wait_read, receive_cb(_data) ); @@ -263,7 +269,7 @@ receive_cb (std::shared_ptr _data) { // Call recvmsg and handle its result errno = 0; - its_result = ::recvmsg(_data->socket_.native_handle(), &its_header, its_flags); + its_result = ::recvmsg(multicast_socket->native_handle(), &its_header, its_flags); _error = boost::system::error_code(its_result < 0 ? errno : 0, boost::asio::error::get_system_category()); @@ -274,7 +280,7 @@ receive_cb (std::shared_ptr _data) { if (_error == boost::asio::error::would_block || _error == boost::asio::error::try_again) { - _data->socket_.async_wait( + multicast_socket->async_wait( socket_type_t::wait_read, receive_cb(_data) ); diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp index b6f3feb3f..70afd1b79 100644 --- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp @@ -242,7 +242,7 @@ void udp_server_endpoint_impl::receive_multicast(uint8_t _multicast_id) { #if VSOMEIP_BOOST_VERSION >= 106600 auto its_storage = std::make_shared( multicast_mutex_, - *multicast_socket_, + multicast_socket_, multicast_remote_, std::bind( &udp_server_endpoint_impl::on_multicast_received, @@ -989,7 +989,7 @@ udp_server_endpoint_impl::set_multicast_option( multicast_socket_->cancel(ec); - multicast_socket_.reset(nullptr); + multicast_socket_.reset(); multicast_local_.reset(nullptr); } } From 8acb133f3f2da3c9e43eca9b3eb267d0ec94386c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 10:30:21 +0100 Subject: [PATCH 11/20] Generate network_test configs directly to build --- .gitignore | 8 - test/network_tests/CMakeLists.txt | 1261 +++++------------------------ 2 files changed, 209 insertions(+), 1060 deletions(-) diff --git a/.gitignore b/.gitignore index 903904fe1..62cef24f6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,14 +9,6 @@ /daemon/CMakeFiles /examples/CMakeFiles /implementation/configuration/include/internal.hpp -/test/network_tests/*/*.json -/test/network_tests/malicious_data_tests/malicious_data_test_master_starter.sh -/test/network_tests/offer_tests/offer_test_external_master_starter.sh -/test/network_tests/offer_tests/offer_test_big_sd_msg_master_starter.sh -/test/network_tests/pending_subscription_tests/pending_subscription_test_master_starter.sh -/test/network_tests/routing_tests/local_routing_test_starter.sh -/test/network_tests/second_address_tests/second_address_test_slave_starter.sh -/test/network_tests/someip_tp_tests/someip_tp_test_master_starter.sh /tools/CMakeFiles /Testing !build_qnx/* diff --git a/test/network_tests/CMakeLists.txt b/test/network_tests/CMakeLists.txt index e016e0cf7..6006e7b33 100644 --- a/test/network_tests/CMakeLists.txt +++ b/test/network_tests/CMakeLists.txt @@ -165,55 +165,32 @@ endif() set(TEST_APPLICATION_CONFIGURATION_FILE ${TEST_APPLICATION}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/application_tests/conf/${TEST_APPLICATION_CONFIGURATION_FILE}.in - ${NETWORK_TEST_SRC_DIR}/application_tests/${TEST_APPLICATION_CONFIGURATION_FILE} - @ONLY) -copy_to_builddir(${NETWORK_TEST_SRC_DIR}/application_tests/${TEST_APPLICATION_CONFIGURATION_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_APPLICATION_CONFIGURATION_FILE} - ${TEST_APPLICATION} -) + @ONLY) set(TEST_APPLICATION_CONFIGURATION_FILE_DAEMON ${TEST_APPLICATION}_daemon.json) configure_file( ${NETWORK_TEST_SRC_DIR}/application_tests/conf/${TEST_APPLICATION_CONFIGURATION_FILE_DAEMON}.in - ${NETWORK_TEST_SRC_DIR}/application_tests/${TEST_APPLICATION_CONFIGURATION_FILE_DAEMON} - @ONLY) -copy_to_builddir(${NETWORK_TEST_SRC_DIR}/application_tests/${TEST_APPLICATION_CONFIGURATION_FILE_DAEMON} ${NETWORK_TEST_BIN_DIR}/${TEST_APPLICATION_CONFIGURATION_FILE_DAEMON} - ${TEST_APPLICATION} -) + @ONLY) set(TEST_APPLICATION_NO_DISPATCH_CONFIGURATION_FILE ${TEST_APPLICATION}_no_dispatch_threads.json) configure_file( ${NETWORK_TEST_SRC_DIR}/application_tests/conf/${TEST_APPLICATION_NO_DISPATCH_CONFIGURATION_FILE}.in - ${NETWORK_TEST_SRC_DIR}/application_tests/${TEST_APPLICATION_NO_DISPATCH_CONFIGURATION_FILE} - @ONLY) -copy_to_builddir(${NETWORK_TEST_SRC_DIR}/application_tests/${TEST_APPLICATION_NO_DISPATCH_CONFIGURATION_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_APPLICATION_NO_DISPATCH_CONFIGURATION_FILE} - ${TEST_APPLICATION} -) + @ONLY) set(TEST_APPLICATION_NO_DISPATCH_CONFIGURATION_FILE_DAEMON ${TEST_APPLICATION}_no_dispatch_threads_daemon.json) configure_file( ${NETWORK_TEST_SRC_DIR}/application_tests/conf/${TEST_APPLICATION_NO_DISPATCH_CONFIGURATION_FILE_DAEMON}.in - ${NETWORK_TEST_SRC_DIR}/application_tests/${TEST_APPLICATION_NO_DISPATCH_CONFIGURATION_FILE_DAEMON} - @ONLY) -copy_to_builddir(${NETWORK_TEST_SRC_DIR}/application_tests/${TEST_APPLICATION_NO_DISPATCH_CONFIGURATION_FILE_DAEMON} ${NETWORK_TEST_BIN_DIR}/${TEST_APPLICATION_NO_DISPATCH_CONFIGURATION_FILE_DAEMON} - ${TEST_APPLICATION} -) + @ONLY) set(TEST_APPLICATION_STARTER ${TEST_APPLICATION}_starter.sh) - if(${TESTS_BAT}) - configure_file( - ${NETWORK_TEST_SRC_DIR}/application_tests/conf/${TEST_APPLICATION_STARTER}.bat.in - ${NETWORK_TEST_SRC_DIR}/application_tests/${TEST_APPLICATION_STARTER} - @ONLY) - endif() - -copy_to_builddir(${NETWORK_TEST_SRC_DIR}/application_tests/${TEST_APPLICATION_STARTER} -${NETWORK_TEST_BIN_DIR}/${TEST_APPLICATION_STARTER} -${TEST_APPLICATION} -) +configure_file( + ${NETWORK_TEST_SRC_DIR}/application_tests/conf/${TEST_APPLICATION_STARTER}.bat.in + ${NETWORK_TEST_BIN_DIR}/${TEST_APPLICATION_STARTER} + @ONLY) ############################################################################## # magic-cookies-test-client @@ -249,12 +226,8 @@ if(NOT ${TESTS_BAT}) set(TEST_MAGIC_COOKIES_CLIENT_CONFIG_FILE ${TEST_MAGIC_COOKIES_CLIENT}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/magic_cookies_tests/conf/${TEST_MAGIC_COOKIES_CLIENT_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/magic_cookies_tests/${TEST_MAGIC_COOKIES_CLIENT_CONFIG_FILE} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/magic_cookies_tests/${TEST_MAGIC_COOKIES_CLIENT_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_MAGIC_COOKIES_CLIENT_CONFIG_FILE} - ${TEST_MAGIC_COOKIES_CLIENT} - ) + @ONLY) # Copy bashscript to start client into $BUILDDIR/test set(TEST_MAGIC_COOKIES_CLIENT_START_SCRIPT ${TEST_MAGIC_COOKIES_CLIENT}_start.sh) @@ -268,12 +241,8 @@ if(NOT ${TESTS_BAT}) set(TEST_MAGIC_COOKIES_SERVICE_CONFIG_FILE ${TEST_MAGIC_COOKIES_SERVICE}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/magic_cookies_tests/conf/${TEST_MAGIC_COOKIES_SERVICE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/magic_cookies_tests/${TEST_MAGIC_COOKIES_SERVICE_CONFIG_FILE} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/magic_cookies_tests/${TEST_MAGIC_COOKIES_SERVICE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_MAGIC_COOKIES_SERVICE_CONFIG_FILE} - ${TEST_MAGIC_COOKIES_SERVICE} - ) + @ONLY) # Copy bashscript to start service into $BUILDDIR/test set(TEST_MAGIC_COOKIES_SERVICE_START_SCRIPT ${TEST_MAGIC_COOKIES_SERVICE}_start.sh) @@ -364,17 +333,10 @@ copy_to_builddir(${NETWORK_TEST_SRC_DIR}/header_factory_tests/${TEST_HEADER_FACT # Copy bashscript to start client and server $BUILDDIR/test set(TEST_HEADER_FACTORY_STARTER header_factory_test_send_receive_starter.sh) -if(${TESTS_BAT}) - configure_file( - ${NETWORK_TEST_SRC_DIR}/header_factory_tests/conf/${TEST_HEADER_FACTORY_STARTER}.bat.in - ${NETWORK_TEST_SRC_DIR}/header_factory_tests/${TEST_HEADER_FACTORY_STARTER} - @ONLY) -endif() - -copy_to_builddir(${NETWORK_TEST_SRC_DIR}/header_factory_tests/${TEST_HEADER_FACTORY_STARTER} +configure_file( + ${NETWORK_TEST_SRC_DIR}/header_factory_tests/conf/${TEST_HEADER_FACTORY_STARTER}.bat.in ${NETWORK_TEST_BIN_DIR}/${TEST_HEADER_FACTORY_STARTER} - ${TEST_HEADER_FACTORY_CLIENT} -) + @ONLY) ############################################################################## # routing-test @@ -441,12 +403,8 @@ if(NOT ${TESTS_BAT}) endif() configure_file( ${NETWORK_TEST_SRC_DIR}/routing_tests/conf/${TEST_LOCAL_ROUTING_STARTER}.in - ${NETWORK_TEST_SRC_DIR}/routing_tests/${TEST_LOCAL_ROUTING_STARTER} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/routing_tests/${TEST_LOCAL_ROUTING_STARTER} ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_ROUTING_STARTER} - ${TEST_LOCAL_ROUTING_CLIENT} - ) + @ONLY) ############################################################################## set(TEST_EXTERNAL_LOCAL_ROUTING_NAME external_local_routing_test) @@ -465,13 +423,8 @@ if(NOT ${TESTS_BAT}) set(TEST_EXTERNAL_LOCAL_ROUTING_SERVICE_CONFIG_FILE ${TEST_EXTERNAL_LOCAL_ROUTING_SERVICE}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/routing_tests/conf/${TEST_EXTERNAL_LOCAL_ROUTING_SERVICE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/routing_tests/${TEST_EXTERNAL_LOCAL_ROUTING_SERVICE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/routing_tests/${TEST_EXTERNAL_LOCAL_ROUTING_SERVICE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_LOCAL_ROUTING_SERVICE_CONFIG_FILE} - ${TEST_EXTERNAL_LOCAL_ROUTING_SERVICE} - ) + @ONLY) # Copy bashscript to start service into $BUILDDIR/test set(TEST_EXTERNAL_LOCAL_ROUTING_SERVICE_START_SCRIPT ${TEST_EXTERNAL_LOCAL_ROUTING_SERVICE}_start.sh) @@ -494,12 +447,8 @@ if(NOT ${TESTS_BAT}) set(TEST_EXTERNAL_LOCAL_ROUTING_CLIENT_CONFIG_FILE ${TEST_EXTERNAL_LOCAL_ROUTING_CLIENT}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/routing_tests/conf/${TEST_EXTERNAL_LOCAL_ROUTING_CLIENT_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/routing_tests/${TEST_EXTERNAL_LOCAL_ROUTING_CLIENT_CONFIG_FILE} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/routing_tests/${TEST_EXTERNAL_LOCAL_ROUTING_CLIENT_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_LOCAL_ROUTING_CLIENT_CONFIG_FILE} - ${TEST_EXTERNAL_LOCAL_ROUTING_SERVICE} - ) + @ONLY) # Copy bashscript to start client and server $BUILDDIR/test set(TEST_EXTERNAL_LOCAL_ROUTING_STARTER external_local_routing_test_starter.sh) @@ -564,12 +513,9 @@ else() set(TEST_LOCAL_ROUTING_STARTER local_routing_test_starter.sh) configure_file( ${NETWORK_TEST_SRC_DIR}/routing_tests/conf/${TEST_LOCAL_ROUTING_STARTER}.bat.in - ${NETWORK_TEST_SRC_DIR}/routing_tests/${TEST_LOCAL_ROUTING_STARTER} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/routing_tests/${TEST_LOCAL_ROUTING_STARTER} ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_ROUTING_STARTER} - ${TEST_LOCAL_ROUTING_CLIENT} - ) + @ONLY) + endif() ############################################################################## # restart_routing-test @@ -674,61 +620,36 @@ if (${TEST_SECURITY}) set(TEST_SECURITY_LOCAL_CONFIG_FILE ${TEST_SECURITY_NAME}_local_config.json) configure_file( ${NETWORK_TEST_SRC_DIR}/security_tests/conf/${TEST_SECURITY_LOCAL_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/security_tests/${TEST_SECURITY_LOCAL_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/security_tests/${TEST_SECURITY_LOCAL_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SECURITY_LOCAL_CONFIG_FILE} - ${TEST_SECURITY_SERVICE} - ) + @ONLY) # Copy service config file for external allow tests into $BUILDDIR/test set(TEST_SECURITY_SERVICE_CONFIG_FILE_EXTERNAL ${TEST_SECURITY_NAME}_config_service_external_allow.json) configure_file( ${NETWORK_TEST_SRC_DIR}/security_tests/conf/${TEST_SECURITY_SERVICE_CONFIG_FILE_EXTERNAL}.in - ${NETWORK_TEST_SRC_DIR}/security_tests/${TEST_SECURITY_SERVICE_CONFIG_FILE_EXTERNAL} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/security_tests/${TEST_SECURITY_SERVICE_CONFIG_FILE_EXTERNAL} ${NETWORK_TEST_BIN_DIR}/${TEST_SECURITY_SERVICE_CONFIG_FILE_EXTERNAL} - ${TEST_SECURITY_SERVICE} - ) + @ONLY) # Copy client config file for external allow tests into $BUILDDIR/test set(TEST_SECURITY_CLIENT_CONFIG_FILE_EXTERNAL ${TEST_SECURITY_NAME}_config_client_external_allow.json) configure_file( ${NETWORK_TEST_SRC_DIR}/security_tests/conf/${TEST_SECURITY_CLIENT_CONFIG_FILE_EXTERNAL}.in - ${NETWORK_TEST_SRC_DIR}/security_tests/${TEST_SECURITY_CLIENT_CONFIG_FILE_EXTERNAL} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/security_tests/${TEST_SECURITY_CLIENT_CONFIG_FILE_EXTERNAL} ${NETWORK_TEST_BIN_DIR}/${TEST_SECURITY_CLIENT_CONFIG_FILE_EXTERNAL} - ${TEST_SECURITY_SERVICE} - ) + @ONLY) # Copy service config file for external deny tests into $BUILDDIR/test set(TEST_SECURITY_SERVICE_CONFIG_FILE_EXTERNAL_DENY ${TEST_SECURITY_NAME}_config_service_external_deny.json) configure_file( ${NETWORK_TEST_SRC_DIR}/security_tests/conf/${TEST_SECURITY_SERVICE_CONFIG_FILE_EXTERNAL_DENY}.in - ${NETWORK_TEST_SRC_DIR}/security_tests/${TEST_SECURITY_SERVICE_CONFIG_FILE_EXTERNAL_DENY} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/security_tests/${TEST_SECURITY_SERVICE_CONFIG_FILE_EXTERNAL_DENY} ${NETWORK_TEST_BIN_DIR}/${TEST_SECURITY_SERVICE_CONFIG_FILE_EXTERNAL_DENY} - ${TEST_SECURITY_SERVICE} - ) + @ONLY) # Copy client config file for external deny tests into $BUILDDIR/test set(TEST_SECURITY_CLIENT_CONFIG_FILE_EXTERNAL_DENY ${TEST_SECURITY_NAME}_config_client_external_deny.json) configure_file( ${NETWORK_TEST_SRC_DIR}/security_tests/conf/${TEST_SECURITY_CLIENT_CONFIG_FILE_EXTERNAL_DENY}.in - ${NETWORK_TEST_SRC_DIR}/security_tests/${TEST_SECURITY_CLIENT_CONFIG_FILE_EXTERNAL_DENY} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/security_tests/${TEST_SECURITY_CLIENT_CONFIG_FILE_EXTERNAL_DENY} ${NETWORK_TEST_BIN_DIR}/${TEST_SECURITY_CLIENT_CONFIG_FILE_EXTERNAL_DENY} - ${TEST_SECURITY_SERVICE} - ) + @ONLY) # Copy bashscript to start local test into $BUILDDIR/test set(TEST_SECURITY_SERVICE_LOCAL_START_SCRIPT ${TEST_SECURITY_NAME}_local_start.sh) @@ -834,17 +755,10 @@ copy_to_builddir( # Copy bashscript to start client and server $BUILDDIR/test set(TEST_LOCAL_PAYLOAD_STARTER local_payload_test_starter.sh) -if(${TESTS_BAT}) - configure_file( - ${NETWORK_TEST_SRC_DIR}/payload_tests/conf/${TEST_LOCAL_PAYLOAD_STARTER}.bat.in - ${NETWORK_TEST_SRC_DIR}/payload_tests/${TEST_LOCAL_PAYLOAD_STARTER} - @ONLY) -endif() - -copy_to_builddir(${NETWORK_TEST_SRC_DIR}/payload_tests/${TEST_LOCAL_PAYLOAD_STARTER} +configure_file( + ${NETWORK_TEST_SRC_DIR}/payload_tests/conf/${TEST_LOCAL_PAYLOAD_STARTER}.bat.in ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_PAYLOAD_STARTER} - ${TEST_PAYLOAD_CLIENT} -) + @ONLY) ############################################################################## set(TEST_EXTERNAL_LOCAL_PAYLOAD_NAME external_local_payload_test) @@ -854,13 +768,8 @@ set(TEST_EXTERNAL_LOCAL_PAYLOAD_SERVICE external_local_payload_test_service) set(TEST_EXTERNAL_LOCAL_PAYLOAD_SERVICE_CONFIG_FILE ${TEST_EXTERNAL_LOCAL_PAYLOAD_SERVICE}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/payload_tests/conf/${TEST_EXTERNAL_LOCAL_PAYLOAD_SERVICE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/payload_tests/${TEST_EXTERNAL_LOCAL_PAYLOAD_SERVICE_CONFIG_FILE} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/payload_tests/${TEST_EXTERNAL_LOCAL_PAYLOAD_SERVICE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_LOCAL_PAYLOAD_SERVICE_CONFIG_FILE} - ${TEST_PAYLOAD_SERVICE} -) + @ONLY) # Copy bashscript to start service into $BUILDDIR/test set(TEST_EXTERNAL_LOCAL_PAYLOAD_SERVICE_START_SCRIPT ${TEST_EXTERNAL_LOCAL_PAYLOAD_SERVICE}_start.sh) @@ -876,13 +785,8 @@ set(TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL external_local_payload_test_client_ set(TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_CONFIG_FILE ${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/payload_tests/conf/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/payload_tests/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_CONFIG_FILE} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/payload_tests/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_CONFIG_FILE} - ${TEST_PAYLOAD_CLIENT} -) + @ONLY) # Copy bashscript to start client into $BUILDDIR/test set(TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL_START_SCRIPT ${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL}_start.sh) @@ -896,17 +800,11 @@ copy_to_builddir( set(TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL_NAME external_local_payload_test_client_local) set(TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL_STARTER ${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL_NAME}_starter.sh) -if(${TESTS_BAT}) - configure_file( - ${NETWORK_TEST_SRC_DIR}/payload_tests/conf/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL_STARTER}.bat.in - ${NETWORK_TEST_SRC_DIR}/payload_tests/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL_STARTER} - @ONLY) -endif() - -copy_to_builddir(${NETWORK_TEST_SRC_DIR}/payload_tests/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL_STARTER} +configure_file( + ${NETWORK_TEST_SRC_DIR}/payload_tests/conf/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL_STARTER}.bat.in ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_LOCAL_STARTER} - ${TEST_PAYLOAD_CLIENT} -) + @ONLY) + ############################################################################## set(TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_EXTERNAL_NAME external_local_payload_test_client_external) set(TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_EXTERNAL external_local_payload_test_client_external) @@ -915,13 +813,8 @@ set(TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_EXTERNAL external_local_payload_test_clie set(TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_EXTERNAL_CONFIG_FILE ${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_EXTERNAL}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/payload_tests/conf/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_EXTERNAL_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/payload_tests/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_EXTERNAL_CONFIG_FILE} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/payload_tests/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_EXTERNAL_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_EXTERNAL_CONFIG_FILE} - ${TEST_PAYLOAD_CLIENT} -) + @ONLY) # Copy bashscript to start client into $BUILDDIR/test set(TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_EXTERNAL_START_SCRIPT ${TEST_EXTERNAL_LOCAL_PAYLOAD_CLIENT_EXTERNAL}_start.sh) @@ -962,17 +855,10 @@ set(TEST_LOCAL_PAYLOAD_HUGE_NAME local_payload_test_huge_payload) # Copy bashscript to start client and server $BUILDDIR/test set(TEST_LOCAL_PAYLOAD_HUGE_STARTER ${TEST_LOCAL_PAYLOAD_HUGE_NAME}_starter.sh) -if(${TESTS_BAT}) - configure_file( - ${NETWORK_TEST_SRC_DIR}/payload_tests/conf/${TEST_LOCAL_PAYLOAD_HUGE_STARTER}.bat.in - ${NETWORK_TEST_SRC_DIR}/payload_tests/${TEST_LOCAL_PAYLOAD_HUGE_STARTER} - @ONLY) -endif() - -copy_to_builddir(${NETWORK_TEST_SRC_DIR}/payload_tests/${TEST_LOCAL_PAYLOAD_HUGE_STARTER} +configure_file( + ${NETWORK_TEST_SRC_DIR}/payload_tests/conf/${TEST_LOCAL_PAYLOAD_HUGE_STARTER}.bat.in ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_PAYLOAD_HUGE_STARTER} - ${TEST_PAYLOAD_CLIENT} -) + @ONLY) ############################################################################## # big_payload_test @@ -1038,234 +924,136 @@ copy_to_builddir( set(TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE ${TEST_BIG_PAYLOAD_NAME}_local_tcp_client.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE} - ${TEST_BIG_PAYLOAD_CLIENT} -) + @ONLY) set(TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE ${TEST_BIG_PAYLOAD_NAME}_local_tcp_service.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE} - ${TEST_BIG_PAYLOAD_SERVICE} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_LIMITED ${TEST_BIG_PAYLOAD_NAME}_local_tcp_client_limited.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_LIMITED}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_LIMITED} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_LIMITED} ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_LIMITED} - ${TEST_BIG_PAYLOAD_CLIENT} -) + @ONLY) set(TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_LIMITED ${TEST_BIG_PAYLOAD_NAME}_local_tcp_service_limited.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_LIMITED}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_LIMITED} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_LIMITED} ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_LIMITED} - ${TEST_BIG_PAYLOAD_SERVICE} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED ${TEST_BIG_PAYLOAD_NAME}_local_tcp_client_queue_limited.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED} ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED} - ${TEST_BIG_PAYLOAD_CLIENT} -) + @ONLY) set(TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED ${TEST_BIG_PAYLOAD_NAME}_local_tcp_service_queue_limited.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED} ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED} - ${TEST_BIG_PAYLOAD_SERVICE} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_RANDOM ${TEST_BIG_PAYLOAD_NAME}_local_tcp_client_random.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_RANDOM}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_RANDOM} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_RANDOM} ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_TCP_BIG_PAYLOAD_CLIENT_CONFIG_FILE_RANDOM} - ${TEST_BIG_PAYLOAD_CLIENT} -) + @ONLY) set(TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_RANDOM ${TEST_BIG_PAYLOAD_NAME}_local_tcp_service_random.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_RANDOM}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_RANDOM} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_RANDOM} ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_TCP_BIG_PAYLOAD_SERVICE_CONFIG_FILE_RANDOM} - ${TEST_BIG_PAYLOAD_SERVICE} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE ${TEST_BIG_PAYLOAD_NAME}_tcp_client.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE} - ${TEST_BIG_PAYLOAD_CLIENT} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE ${TEST_BIG_PAYLOAD_NAME}_tcp_service.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE} - ${TEST_BIG_PAYLOAD_SERVICE} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_LIMITED ${TEST_BIG_PAYLOAD_NAME}_tcp_client_limited_general.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_LIMITED}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_LIMITED} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_LIMITED} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_LIMITED} - ${TEST_BIG_PAYLOAD_CLIENT} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_LIMITED ${TEST_BIG_PAYLOAD_NAME}_tcp_service_limited_general.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_LIMITED}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_LIMITED} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_LIMITED} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_LIMITED} - ${TEST_BIG_PAYLOAD_SERVICE} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_RANDOM ${TEST_BIG_PAYLOAD_NAME}_tcp_client_random.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_RANDOM}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_RANDOM} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_RANDOM} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_RANDOM} - ${TEST_BIG_PAYLOAD_CLIENT} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_RANDOM ${TEST_BIG_PAYLOAD_NAME}_tcp_service_random.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_RANDOM}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_RANDOM} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_RANDOM} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_RANDOM} - ${TEST_BIG_PAYLOAD_SERVICE} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED_GENERAL ${TEST_BIG_PAYLOAD_NAME}_tcp_client_queue_limited_general.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED_GENERAL}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED_GENERAL} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED_GENERAL} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED_GENERAL} - ${TEST_BIG_PAYLOAD_CLIENT} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED_GENERAL ${TEST_BIG_PAYLOAD_NAME}_tcp_service_queue_limited_general.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED_GENERAL}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED_GENERAL} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED_GENERAL} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED_GENERAL} - ${TEST_BIG_PAYLOAD_SERVICE} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED_SPECIFIC ${TEST_BIG_PAYLOAD_NAME}_tcp_client_queue_limited_specific.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED_SPECIFIC}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED_SPECIFIC} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED_SPECIFIC} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_CONFIG_FILE_QUEUE_LIMITED_SPECIFIC} - ${TEST_BIG_PAYLOAD_CLIENT} -) + @ONLY) # Copy config file for client and service into $BUILDDIR/test set(TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED_SPECIFIC ${TEST_BIG_PAYLOAD_NAME}_tcp_service_queue_limited_specific.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED_SPECIFIC}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED_SPECIFIC} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED_SPECIFIC} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_CONFIG_FILE_QUEUE_LIMITED_SPECIFIC} - ${TEST_BIG_PAYLOAD_SERVICE} -) + @ONLY) + # Copy config file for UDP client and service into $BUILDDIR/test set(TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_UDP_CONFIG_FILE ${TEST_BIG_PAYLOAD_NAME}_udp_service.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_UDP_CONFIG_FILE} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_BIG_PAYLOAD_SERVICE_UDP_CONFIG_FILE} - ${TEST_BIG_PAYLOAD_SERVICE} -) + @ONLY) + set(TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_UDP_CONFIG_FILE ${TEST_BIG_PAYLOAD_NAME}_udp_client.json) configure_file( ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_UDP_CONFIG_FILE} - @ONLY) -copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_EXTERNAL_BIG_PAYLOAD_CLIENT_UDP_CONFIG_FILE} - ${TEST_BIG_PAYLOAD_CLIENT} -) + @ONLY) # Copy bashscript to start client local to $BUILDDIR/test set(TEST_LOCAL_BIG_PAYLOAD_CLIENT_START_SCRIPT ${TEST_BIG_PAYLOAD_NAME}_client_local_start.sh) @@ -1288,17 +1076,10 @@ set(TEST_LOCAL_BIG_PAYLOAD_NAME_LIMITED big_payload_test_local_limited) set(TEST_LOCAL_BIG_PAYLOAD_NAME_QUEUE_LIMITED big_payload_test_local_queue_limited) set(TEST_LOCAL_BIG_PAYLOAD_STARTER ${TEST_LOCAL_BIG_PAYLOAD_NAME}_starter.sh) -if(${TESTS_BAT}) - configure_file( - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_LOCAL_BIG_PAYLOAD_STARTER}.bat.in - ${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_BIG_PAYLOAD_STARTER} - @ONLY) -endif() - -copy_to_builddir(${NETWORK_TEST_SRC_DIR}/big_payload_tests/${TEST_LOCAL_BIG_PAYLOAD_STARTER} +configure_file( + ${NETWORK_TEST_SRC_DIR}/big_payload_tests/conf/${TEST_LOCAL_BIG_PAYLOAD_STARTER}.bat.in ${NETWORK_TEST_BIN_DIR}/${TEST_LOCAL_BIG_PAYLOAD_STARTER} - ${TEST_BIG_PAYLOAD_SERVICE} -) + @ONLY) # Copy bashscript to start client and server $BUILDDIR/test set(TEST_LOCAL_TCP_BIG_PAYLOAD_NAME big_payload_test_local_tcp) @@ -1379,121 +1160,71 @@ if(NOT ${TESTS_BAT}) ${TEST_CLIENT_ID_NAME}_diff_client_ids_diff_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/client_id_tests/conf/${TEST_CLIENT_ID_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CLIENT_ID_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - ${TEST_CLIENT_ID_SERVICE} - ) + @ONLY) set(TEST_CLIENT_ID_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE ${TEST_CLIENT_ID_NAME}_diff_client_ids_diff_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/client_id_tests/conf/${TEST_CLIENT_ID_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CLIENT_ID_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - ${TEST_CLIENT_ID_SERVICE} - ) + @ONLY) set(TEST_CLIENT_ID_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE ${TEST_CLIENT_ID_NAME}_diff_client_ids_same_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/client_id_tests/conf/${TEST_CLIENT_ID_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CLIENT_ID_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE} - ${TEST_CLIENT_ID_SERVICE} - ) + @ONLY) set(TEST_CLIENT_ID_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE ${TEST_CLIENT_ID_NAME}_diff_client_ids_same_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/client_id_tests/conf/${TEST_CLIENT_ID_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CLIENT_ID_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} - ${TEST_CLIENT_ID_SERVICE} - ) + @ONLY) set(TEST_CLIENT_ID_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE ${TEST_CLIENT_ID_NAME}_diff_client_ids_partial_same_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/client_id_tests/conf/${TEST_CLIENT_ID_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CLIENT_ID_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE} - ${TEST_CLIENT_ID_SERVICE} - ) + @ONLY) set(TEST_CLIENT_ID_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE ${TEST_CLIENT_ID_NAME}_diff_client_ids_partial_same_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/client_id_tests/conf/${TEST_CLIENT_ID_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CLIENT_ID_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE} - ${TEST_CLIENT_ID_SERVICE} - ) + @ONLY) set(TEST_CLIENT_ID_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE ${TEST_CLIENT_ID_NAME}_same_client_ids_same_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/client_id_tests/conf/${TEST_CLIENT_ID_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CLIENT_ID_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE} - ${TEST_CLIENT_ID_SERVICE} - ) + @ONLY) set(TEST_CLIENT_ID_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE ${TEST_CLIENT_ID_NAME}_same_client_ids_same_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/client_id_tests/conf/${TEST_CLIENT_ID_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CLIENT_ID_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} - ${TEST_CLIENT_ID_SERVICE} - ) + @ONLY) set(TEST_CLIENT_ID_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE ${TEST_CLIENT_ID_NAME}_same_client_ids_diff_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/client_id_tests/conf/${TEST_CLIENT_ID_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CLIENT_ID_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - ${TEST_CLIENT_ID_SERVICE} - ) + @ONLY) set(TEST_CLIENT_ID_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE ${TEST_CLIENT_ID_NAME}_same_client_ids_diff_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/client_id_tests/conf/${TEST_CLIENT_ID_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/client_id_tests/${TEST_CLIENT_ID_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CLIENT_ID_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - ${TEST_CLIENT_ID_SERVICE} - ) + @ONLY) set(TEST_CLIENT_ID_UTILITY_CONFIG_FILE ${TEST_CLIENT_ID_NAME}_utility.json) copy_to_builddir( @@ -1588,23 +1319,14 @@ if(NOT ${TESTS_BAT}) set(TEST_DEBOUNCE_MASTER_CONFIG_FILE ${TEST_DEBOUNCE_SERVICE}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/debounce_tests/conf/${TEST_DEBOUNCE_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/debounce_tests/${TEST_DEBOUNCE_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/debounce_tests/${TEST_DEBOUNCE_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_MASTER_CONFIG_FILE} - ${TEST_DEBOUNCE_SERVICE} - ) + @ONLY) + set(TEST_DEBOUNCE_SLAVE_CONFIG_FILE ${TEST_DEBOUNCE_CLIENT}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/debounce_tests/conf/${TEST_DEBOUNCE_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/debounce_tests/${TEST_DEBOUNCE_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/debounce_tests/${TEST_DEBOUNCE_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_SLAVE_CONFIG_FILE} - ${TEST_DEBOUNCE_SERVICE} - ) + @ONLY) endif() ############################################################################## @@ -1645,23 +1367,15 @@ if(NOT ${TESTS_BAT}) set(TEST_DEBOUNCE_FILTER_MASTER_CONFIG_FILE ${TEST_DEBOUNCE_FILTER_SERVICE}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/conf/${TEST_DEBOUNCE_FILTER_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/${TEST_DEBOUNCE_FILTER_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/${TEST_DEBOUNCE_FILTER_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FILTER_MASTER_CONFIG_FILE} - ${TEST_DEBOUNCE_FILTER_SERVICE} - ) + @ONLY) + set(TEST_DEBOUNCE_FILTER_SLAVE_CONFIG_FILE ${TEST_DEBOUNCE_FILTER_CLIENT}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/conf/${TEST_DEBOUNCE_FILTER_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/${TEST_DEBOUNCE_FILTER_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/debounce_filter_tests/${TEST_DEBOUNCE_FILTER_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FILTER_SLAVE_CONFIG_FILE} - ${TEST_DEBOUNCE_FILTER_SERVICE} - ) + @ONLY) + endif() ############################################################################## @@ -1704,23 +1418,15 @@ if(NOT ${TESTS_BAT}) set(TEST_DEBOUNCE_FREQUENCY_MASTER_CONFIG_FILE ${TEST_DEBOUNCE_FREQUENCY_CLIENT}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/conf/${TEST_DEBOUNCE_FREQUENCY_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/${TEST_DEBOUNCE_FREQUENCY_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/${TEST_DEBOUNCE_FREQUENCY_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FREQUENCY_MASTER_CONFIG_FILE} - ${TEST_DEBOUNCE_FREQUENCY_CLIENT} - ) + @ONLY) + set(TEST_DEBOUNCE_FREQUENCY_SLAVE_CONFIG_FILE ${TEST_DEBOUNCE_FREQUENCY_SERVICE}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/conf/${TEST_DEBOUNCE_FREQUENCY_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/${TEST_DEBOUNCE_FREQUENCY_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/debounce_frequency_tests/${TEST_DEBOUNCE_FREQUENCY_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_FREQUENCY_SLAVE_CONFIG_FILE} - ${TEST_DEBOUNCE_FREQUENCY_SERVICE} - ) + @ONLY) + endif() ############################################################################## @@ -1761,23 +1467,15 @@ if(NOT ${TESTS_BAT}) set(TEST_DEBOUNCE_CALLBACK_MASTER_CONFIG_FILE ${TEST_DEBOUNCE_CALLBACK_SERVICE}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/debounce_callback_tests/conf/${TEST_DEBOUNCE_CALLBACK_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/debounce_callback_tests/${TEST_DEBOUNCE_CALLBACK_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/debounce_callback_tests/${TEST_DEBOUNCE_CALLBACK_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_CALLBACK_MASTER_CONFIG_FILE} - ${TEST_DEBOUNCE_CALLBACK_SERVICE} - ) + @ONLY) + set(TEST_DEBOUNCE_CALLBACK_SLAVE_CONFIG_FILE ${TEST_DEBOUNCE_CALLBACK_CLIENT}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/debounce_callback_tests/conf/${TEST_DEBOUNCE_CALLBACK_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/debounce_callback_tests/${TEST_DEBOUNCE_CALLBACK_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/debounce_callback_tests/${TEST_DEBOUNCE_CALLBACK_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_DEBOUNCE_CALLBACK_SLAVE_CONFIG_FILE} - ${TEST_DEBOUNCE_CALLBACK_CLIENT} - ) + @ONLY) + endif() ############################################################################## @@ -1801,265 +1499,155 @@ if(NOT ${TESTS_BAT}) ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_master_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_slave_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_master_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_slave_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_same_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_same_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_same_ports_master_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_same_ports_slave_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_UDP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_same_ports_master_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_UDP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_UDP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_same_ports_slave_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_UDP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_partial_same_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_partial_same_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_same_client_ids_same_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_same_client_ids_same_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_same_client_ids_diff_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_same_client_ids_diff_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_UDP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_same_service_id_master_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_UDP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_UDP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_same_service_id_slave_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_UDP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_MASTER_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_autoconfig_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_MASTER_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_SLAVE_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_autoconfig_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_SLAVE_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) # copy starter scripts into builddir if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") @@ -2109,36 +1697,22 @@ if(NOT ${TESTS_BAT}) ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_NAME}_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_MASTER_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_UDP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_NAME}_udp_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_UDP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_CLIENT} - ) + @ONLY) + set(TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_NAME}_tcp_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_CLIENT} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_MASTER_STARTER ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_NAME}_master_starter.sh) @@ -2158,265 +1732,155 @@ if(NOT ${TESTS_BAT}) ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_master_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_slave_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_TCP_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_master_tcp_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_TCP_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_TCP_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_TCP_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_TCP_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_slave_tcp_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_UDP_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_master_udp_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_UDP_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_UDP_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_UDP_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_MASTER_UDP_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_slave_udp_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_same_ports_master_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_same_ports_slave_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_TCP_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_same_ports_master_tcp_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_TCP_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_TCP_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_TCP_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_TCP_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_same_ports_slave_tcp_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_UDP_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_same_ports_master_udp_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_UDP_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_UDP_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_UDP_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_MASTER_UDP_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_same_ports_slave_udp_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_SAME_PORTS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_partial_same_ports_master_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_partial_same_ports_slave_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_same_client_ids_same_ports_master_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_same_client_ids_same_ports_slave_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_SAME_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_same_client_ids_diff_ports_master_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_MASTER_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_same_client_ids_diff_ports_slave_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_SAME_IDS_DIFF_PORTS_SLAVE_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_UDP_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_same_service_id_master_udp_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_UDP_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_UDP_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_UDP_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_UDP_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_same_service_id_slave_udp_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_MASTER_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_autoconfig_master_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_MASTER_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_MASTER_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_MASTER_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_MASTER_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_SLAVE_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_NAME}_diff_client_ids_diff_ports_autoconfig_slave_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_SLAVE_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_SLAVE_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_SLAVE_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_DIFF_IDS_DIFF_PORTS_AUTOCONFIG_SLAVE_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_SERVICE} - ) + @ONLY) # copy starter scripts into builddir set(TEST_SUBSCRIBE_NOTIFY_MASTER_STARTER ${TEST_SUBSCRIBE_NOTIFY_NAME}_master_starter.sh) @@ -2434,36 +1898,22 @@ if(NOT ${TESTS_BAT}) ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_NAME}_master_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_MASTER_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_MASTER_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_MASTER_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_MASTER_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_NAME}_udp_slave_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_UDP_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_CLIENT} - ) + @ONLY) + set(TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_NAME}_tcp_slave_local_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/conf/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SLAVE_TCP_LOCAL_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_CLIENT} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_MASTER_STARTER ${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_NAME}_master_starter.sh) @@ -2501,73 +1951,43 @@ if(NOT ${TESTS_BAT}) ${TEST_SUBSCRIBE_NOTIFY_ONE_NAME}_diff_client_ids_diff_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/conf/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_ONE_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_ONE_NAME}_diff_client_ids_diff_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/conf/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_ONE_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_ONE_NAME}_diff_client_ids_diff_ports_master_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/conf/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_ONE_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_ONE_NAME}_diff_client_ids_diff_ports_slave_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/conf/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_ONE_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_ONE_NAME}_diff_client_ids_diff_ports_master_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/conf/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_ONE_SERVICE} - ) + @ONLY) set(TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE ${TEST_SUBSCRIBE_NOTIFY_ONE_NAME}_diff_client_ids_diff_ports_slave_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/conf/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/subscribe_notify_one_tests/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUBSCRIBE_NOTIFY_ONE_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE} - ${TEST_SUBSCRIBE_NOTIFY_ONE_SERVICE} - ) + @ONLY) # copy starter scripts into builddir if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") @@ -2611,23 +2031,14 @@ if(NOT ${TESTS_BAT}) set(TEST_CPU_LOAD_SERVICE_MASTER_CONFIG_FILE ${TEST_CPU_LOAD_NAME}_service_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/cpu_load_tests/conf/${TEST_CPU_LOAD_SERVICE_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/cpu_load_tests/${TEST_CPU_LOAD_SERVICE_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/cpu_load_tests/${TEST_CPU_LOAD_SERVICE_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CPU_LOAD_SERVICE_MASTER_CONFIG_FILE} - ${TEST_CPU_LOAD_SERVICE} - ) + @ONLY) + set(TEST_CPU_LOAD_SERVICE_SLAVE_CONFIG_FILE ${TEST_CPU_LOAD_NAME}_service_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/cpu_load_tests/conf/${TEST_CPU_LOAD_SERVICE_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/cpu_load_tests/${TEST_CPU_LOAD_SERVICE_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/cpu_load_tests/${TEST_CPU_LOAD_SERVICE_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CPU_LOAD_SERVICE_SLAVE_CONFIG_FILE} - ${TEST_CPU_LOAD_SERVICE} - ) + @ONLY) ############################################################################## set(TEST_CPU_LOAD_CLIENT cpu_load_test_client) @@ -2647,23 +2058,14 @@ if(NOT ${TESTS_BAT}) set(TEST_CPU_LOAD_CLIENT_MASTER_CONFIG_FILE ${TEST_CPU_LOAD_NAME}_client_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/cpu_load_tests/conf/${TEST_CPU_LOAD_CLIENT_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/cpu_load_tests/${TEST_CPU_LOAD_CLIENT_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/cpu_load_tests/${TEST_CPU_LOAD_CLIENT_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CPU_LOAD_CLIENT_MASTER_CONFIG_FILE} - ${TEST_CPU_LOAD_CLIENT} - ) + @ONLY) + set(TEST_CPU_LOAD_CLIENT_SLAVE_CONFIG_FILE ${TEST_CPU_LOAD_NAME}_client_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/cpu_load_tests/conf/${TEST_CPU_LOAD_CLIENT_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/cpu_load_tests/${TEST_CPU_LOAD_CLIENT_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/cpu_load_tests/${TEST_CPU_LOAD_CLIENT_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_CPU_LOAD_CLIENT_SLAVE_CONFIG_FILE} - ${TEST_CPU_LOAD_CLIENT} - ) + @ONLY) ############################################################################## # copy starter scripts into builddir @@ -2733,243 +2135,144 @@ if(NOT ${TESTS_BAT}) ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_diff_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_diff_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) # Copy config files for test into $BUILDDIR/test set(TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_diff_ports_master_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_TCP_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) # Copy config files for test into $BUILDDIR/test set(TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_diff_ports_master_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_MASTER_UDP_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_diff_ports_slave_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_TCP_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_diff_ports_slave_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SLAVE_UDP_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_same_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_same_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_TCP_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_same_ports_master_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_TCP_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_TCP_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_same_ports_slave_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_TCP_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_UDP_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_same_ports_master_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_MASTER_UDP_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_UDP_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_same_ports_slave_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_SAME_PORTS_SLAVE_UDP_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_partial_same_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_PARTIAL_SAME_PORTS_MASTER_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_partial_same_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_PARTIAL_SAME_PORTS_SLAVE_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_same_client_ids_same_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_SAME_IDS_SAME_PORTS_MASTER_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_same_client_ids_same_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_SAME_IDS_SAME_PORTS_SLAVE_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_same_client_ids_diff_ports_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_SAME_IDS_DIFF_PORTS_MASTER_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) + set(TEST_INITIAL_EVENT_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_same_client_ids_diff_ports_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_SAME_IDS_DIFF_PORTS_SLAVE_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_diff_ports_same_service_id_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_MASTER_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) set(TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_CONFIG_FILE ${TEST_INITIAL_EVENT_NAME}_diff_client_ids_diff_ports_same_service_id_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/initial_event_tests/conf/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/initial_event_tests/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_INITIAL_EVENT_DIFF_IDS_DIFF_PORTS_SAME_SERVICEID_SLAVE_CONFIG_FILE} - ${TEST_INITIAL_EVENT_SERVICE} - ) + @ONLY) # copy starter scripts into builddir if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") @@ -3108,47 +2411,27 @@ if(NOT ${TESTS_BAT}) set(TEST_OFFER_SLAVE_CONFIG_FILE ${TEST_OFFER_NAME}_external_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/offer_tests/conf/${TEST_OFFER_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_SLAVE_CONFIG_FILE} - ${TEST_OFFER_SERVICE} - ) + @ONLY) set(TEST_OFFER_MASTER_CONFIG_FILE ${TEST_OFFER_NAME}_external_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/offer_tests/conf/${TEST_OFFER_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_MASTER_CONFIG_FILE} - ${TEST_OFFER_SERVICE} - ) + @ONLY) # generate and copy json files into builddir for big SD message test set(TEST_OFFER_BIG_SLAVE_CONFIG_FILE ${TEST_OFFER_BIG_NAME}_slave.json) configure_file( ${NETWORK_TEST_SRC_DIR}/offer_tests/conf/${TEST_OFFER_BIG_SLAVE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_BIG_SLAVE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_BIG_SLAVE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_BIG_SLAVE_CONFIG_FILE} - ${TEST_OFFER_BIG_SERVICE} - ) + @ONLY) set(TEST_OFFER_BIG_MASTER_CONFIG_FILE ${TEST_OFFER_BIG_NAME}_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/offer_tests/conf/${TEST_OFFER_BIG_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_BIG_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_BIG_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_BIG_MASTER_CONFIG_FILE} - ${TEST_OFFER_BIG_SERVICE} - ) + @ONLY) # Copy starter scripts for external test to $BUILDDIR/test if (${CMAKE_SYSTEM_NAME} MATCHES "QNX") @@ -3158,12 +2441,9 @@ if(NOT ${TESTS_BAT}) endif() configure_file( ${NETWORK_TEST_SRC_DIR}/offer_tests/conf/${TEST_OFFER_EXTERNAL_MASTER_STARTER}.in - ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_EXTERNAL_MASTER_STARTER} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_EXTERNAL_MASTER_STARTER} ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_EXTERNAL_MASTER_STARTER} - ${TEST_OFFER_SERVICE} - ) + @ONLY) + set(TEST_OFFER_EXTERNAL_SLAVE_STARTER ${TEST_OFFER_NAME}_external_slave_starter.sh) copy_to_builddir(${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_EXTERNAL_SLAVE_STARTER} ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_EXTERNAL_SLAVE_STARTER} @@ -3174,12 +2454,9 @@ if(NOT ${TESTS_BAT}) set(TEST_OFFER_BIG_MASTER_STARTER ${TEST_OFFER_BIG_NAME}_master_starter.sh) configure_file( ${NETWORK_TEST_SRC_DIR}/offer_tests/conf/${TEST_OFFER_BIG_MASTER_STARTER}.in - ${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_BIG_MASTER_STARTER} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_BIG_MASTER_STARTER} ${NETWORK_TEST_BIN_DIR}/${TEST_OFFER_BIG_MASTER_STARTER} - ${TEST_OFFER_BIG_SERVICE} - ) + @ONLY) + # Copy starter scripts for external test to $BUILDDIR/test set(TEST_OFFER_BIG_EXTERNAL_SLAVE_STARTER ${TEST_OFFER_BIG_NAME}_slave_starter.sh) copy_to_builddir(${NETWORK_TEST_SRC_DIR}/offer_tests/${TEST_OFFER_BIG_EXTERNAL_SLAVE_STARTER} @@ -3275,24 +2552,16 @@ if(NOT ${TESTS_BAT}) set(TEST_PENDING_SUBSCRIPTION_MASTER_STARTER ${TEST_PENDING_SUBSCRIPTION_NAME}_master_starter.sh) configure_file( ${NETWORK_TEST_SRC_DIR}/pending_subscription_tests/conf/${TEST_PENDING_SUBSCRIPTION_MASTER_STARTER}.in - ${NETWORK_TEST_SRC_DIR}/pending_subscription_tests/${TEST_PENDING_SUBSCRIPTION_MASTER_STARTER} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/pending_subscription_tests/${TEST_PENDING_SUBSCRIPTION_MASTER_STARTER} ${NETWORK_TEST_BIN_DIR}/${TEST_PENDING_SUBSCRIPTION_MASTER_STARTER} - ${TEST_PENDING_SUBSCRIPTION_SERVICE} - ) + @ONLY) # Copy config file for local test into $BUILDDIR/test set(TEST_PENDING_SUBSCRIPTION_CONFIG_FILE ${TEST_PENDING_SUBSCRIPTION_NAME}_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/pending_subscription_tests/conf/${TEST_PENDING_SUBSCRIPTION_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/pending_subscription_tests/${TEST_PENDING_SUBSCRIPTION_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/pending_subscription_tests/${TEST_PENDING_SUBSCRIPTION_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_PENDING_SUBSCRIPTION_CONFIG_FILE} - ${TEST_PENDING_SUBSCRIPTION_SERVICE} - ) + @ONLY) + endif() ############################################################################## @@ -3339,24 +2608,16 @@ if(NOT ${TESTS_BAT}) set(TEST_MALICIOUS_DATA_MASTER_STARTER ${TEST_MALICIOUS_DATA_NAME}_master_starter.sh) configure_file( ${NETWORK_TEST_SRC_DIR}/malicious_data_tests/conf/${TEST_MALICIOUS_DATA_MASTER_STARTER}.in - ${NETWORK_TEST_SRC_DIR}/malicious_data_tests/${TEST_MALICIOUS_DATA_MASTER_STARTER} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/malicious_data_tests/${TEST_MALICIOUS_DATA_MASTER_STARTER} ${NETWORK_TEST_BIN_DIR}/${TEST_MALICIOUS_DATA_MASTER_STARTER} - ${TEST_MALICIOUS_DATA_SERVICE} - ) + @ONLY) # Copy config file for local test into $BUILDDIR/test set(TEST_MALICIOUS_DATA_CONFIG_FILE ${TEST_MALICIOUS_DATA_NAME}_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/malicious_data_tests/conf/${TEST_MALICIOUS_DATA_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/malicious_data_tests/${TEST_MALICIOUS_DATA_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/malicious_data_tests/${TEST_MALICIOUS_DATA_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_MALICIOUS_DATA_CONFIG_FILE} - ${TEST_MALICIOUS_DATA_SERVICE} - ) + @ONLY) + endif() ############################################################################## @@ -3394,25 +2655,15 @@ if(NOT ${TESTS_BAT}) set(TEST_E2E_SERVICE_CONFIG_FILE_EXTERNAL ${TEST_E2E_NAME}_service_external.json) configure_file( ${NETWORK_TEST_SRC_DIR}/e2e_tests/conf/${TEST_E2E_SERVICE_CONFIG_FILE_EXTERNAL}.in - ${NETWORK_TEST_SRC_DIR}/e2e_tests/${TEST_E2E_SERVICE_CONFIG_FILE_EXTERNAL} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/e2e_tests/${TEST_E2E_SERVICE_CONFIG_FILE_EXTERNAL} ${NETWORK_TEST_BIN_DIR}/${TEST_E2E_SERVICE_CONFIG_FILE_EXTERNAL} - ${TEST_E2E_SERVICE} - ) + @ONLY) # Copy client config file for external allow tests into $BUILDDIR/test set(TEST_E2E_CLIENT_CONFIG_FILE_EXTERNAL ${TEST_E2E_NAME}_client_external.json) configure_file( ${NETWORK_TEST_SRC_DIR}/e2e_tests/conf/${TEST_E2E_CLIENT_CONFIG_FILE_EXTERNAL}.in - ${NETWORK_TEST_SRC_DIR}/e2e_tests/${TEST_E2E_CLIENT_CONFIG_FILE_EXTERNAL} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/e2e_tests/${TEST_E2E_CLIENT_CONFIG_FILE_EXTERNAL} ${NETWORK_TEST_BIN_DIR}/${TEST_E2E_CLIENT_CONFIG_FILE_EXTERNAL} - ${TEST_E2E_SERVICE} - ) + @ONLY) # Copy bashscript to start external tests (master) into $BUILDDIR/test set(TEST_E2E_EXTERNAL_MASTER_START_SCRIPT ${TEST_E2E_NAME}_external_master_start.sh) @@ -3466,25 +2717,15 @@ if(NOT ${TESTS_BAT} AND ${TEST_E2E_PROFILE_04}) set(TEST_E2E_PROFILE_04_SERVICE_CONFIG_FILE_EXTERNAL ${TEST_E2E_PROFILE_04_NAME}_service_external.json) configure_file( ${NETWORK_TEST_SRC_DIR}/e2e_tests/conf/${TEST_E2E_PROFILE_04_SERVICE_CONFIG_FILE_EXTERNAL}.in - ${NETWORK_TEST_SRC_DIR}/e2e_tests/${TEST_E2E_PROFILE_04_SERVICE_CONFIG_FILE_EXTERNAL} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/e2e_tests/${TEST_E2E_PROFILE_04_SERVICE_CONFIG_FILE_EXTERNAL} ${NETWORK_TEST_BIN_DIR}/${TEST_E2E_PROFILE_04_SERVICE_CONFIG_FILE_EXTERNAL} - ${TEST_E2E_PROFILE_04_SERVICE} - ) + @ONLY) # Copy client config file for external allow tests into $BUILDDIR/test set(TEST_E2E_PROFILE_04_CLIENT_CONFIG_FILE_EXTERNAL ${TEST_E2E_PROFILE_04_NAME}_client_external.json) configure_file( ${NETWORK_TEST_SRC_DIR}/e2e_tests/conf/${TEST_E2E_PROFILE_04_CLIENT_CONFIG_FILE_EXTERNAL}.in - ${NETWORK_TEST_SRC_DIR}/e2e_tests/${TEST_E2E_PROFILE_04_CLIENT_CONFIG_FILE_EXTERNAL} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/e2e_tests/${TEST_E2E_PROFILE_04_CLIENT_CONFIG_FILE_EXTERNAL} ${NETWORK_TEST_BIN_DIR}/${TEST_E2E_PROFILE_04_CLIENT_CONFIG_FILE_EXTERNAL} - ${TEST_E2E_PROFILE_04_SERVICE} - ) + @ONLY) # Copy bashscript to start external tests (master) into $BUILDDIR/test set(TEST_E2E_PROFILE_04_EXTERNAL_MASTER_START_SCRIPT ${TEST_E2E_PROFILE_04_NAME}_external_master_start.sh) @@ -3538,25 +2779,15 @@ if(NOT ${TESTS_BAT} AND ${TEST_E2E_PROFILE_07}) set(TEST_E2E_PROFILE_07_SERVICE_CONFIG_FILE_EXTERNAL ${TEST_E2E_PROFILE_07_NAME}_service_external.json) configure_file( ${NETWORK_TEST_SRC_DIR}/e2e_tests/conf/${TEST_E2E_PROFILE_07_SERVICE_CONFIG_FILE_EXTERNAL}.in - ${NETWORK_TEST_SRC_DIR}/e2e_tests/${TEST_E2E_PROFILE_07_SERVICE_CONFIG_FILE_EXTERNAL} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/e2e_tests/${TEST_E2E_PROFILE_07_SERVICE_CONFIG_FILE_EXTERNAL} ${NETWORK_TEST_BIN_DIR}/${TEST_E2E_PROFILE_07_SERVICE_CONFIG_FILE_EXTERNAL} - ${TEST_E2E_PROFILE_07_SERVICE} - ) + @ONLY) # Copy client config file for external allow tests into $BUILDDIR/test set(TEST_E2E_PROFILE_07_CLIENT_CONFIG_FILE_EXTERNAL ${TEST_E2E_PROFILE_07_NAME}_client_external.json) configure_file( ${NETWORK_TEST_SRC_DIR}/e2e_tests/conf/${TEST_E2E_PROFILE_07_CLIENT_CONFIG_FILE_EXTERNAL}.in - ${NETWORK_TEST_SRC_DIR}/e2e_tests/${TEST_E2E_PROFILE_07_CLIENT_CONFIG_FILE_EXTERNAL} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/e2e_tests/${TEST_E2E_PROFILE_07_CLIENT_CONFIG_FILE_EXTERNAL} ${NETWORK_TEST_BIN_DIR}/${TEST_E2E_PROFILE_07_CLIENT_CONFIG_FILE_EXTERNAL} - ${TEST_E2E_PROFILE_07_SERVICE} - ) + @ONLY) # Copy bashscript to start external tests (master) into $BUILDDIR/test set(TEST_E2E_PROFILE_07_EXTERNAL_MASTER_START_SCRIPT ${TEST_E2E_PROFILE_07_NAME}_external_master_start.sh) @@ -3609,35 +2840,20 @@ if(NOT ${TESTS_BAT}) set(TEST_EVENT_SLAVE_TCP_CONFIG_FILE ${TEST_EVENT_NAME}_slave_tcp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/event_tests/conf/${TEST_EVENT_SLAVE_TCP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/event_tests/${TEST_EVENT_SLAVE_TCP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/event_tests/${TEST_EVENT_SLAVE_TCP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_EVENT_SLAVE_TCP_CONFIG_FILE} - ${TEST_EVENT_SERVICE} - ) + @ONLY) set(TEST_EVENT_SLAVE_UDP_CONFIG_FILE ${TEST_EVENT_NAME}_slave_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/event_tests/conf/${TEST_EVENT_SLAVE_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/event_tests/${TEST_EVENT_SLAVE_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/event_tests/${TEST_EVENT_SLAVE_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_EVENT_SLAVE_UDP_CONFIG_FILE} - ${TEST_EVENT_SERVICE} - ) + @ONLY) set(TEST_EVENT_MASTER_CONFIG_FILE ${TEST_EVENT_NAME}_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/event_tests/conf/${TEST_EVENT_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/event_tests/${TEST_EVENT_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/event_tests/${TEST_EVENT_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_EVENT_MASTER_CONFIG_FILE} - ${TEST_EVENT_CLIENT} - ) + @ONLY) # Copy bashscript to start test (master) into $BUILDDIR/test set(TEST_EVENT_MASTER_START_SCRIPT ${TEST_EVENT_NAME}_master_starter.sh) @@ -3748,12 +2964,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") set(TEST_NPDU_SERVICE_CONFIG_FILE ${TEST_NPDU_SERVICE}_no_npdu.json) configure_file( ${NETWORK_TEST_SRC_DIR}/npdu_tests/conf/${TEST_NPDU_SERVICE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/npdu_tests/${TEST_NPDU_SERVICE_CONFIG_FILE} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/npdu_tests/${TEST_NPDU_SERVICE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_NPDU_SERVICE_CONFIG_FILE} - ${TEST_NPDU_SERVICE_ONE} - ) + @ONLY) # Copy bashscript to start service w/o npdu into $BUILDDIR/test set(TEST_NPDU_SERVICE_START_SCRIPT ${TEST_NPDU_SERVICE}_no_npdu_start.sh) @@ -3767,12 +2979,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") set(TEST_NPDU_SERVICE_CONFIG_FILE ${TEST_NPDU_SERVICE}_npdu.json) configure_file( ${NETWORK_TEST_SRC_DIR}/npdu_tests/conf/${TEST_NPDU_SERVICE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/npdu_tests/${TEST_NPDU_SERVICE_CONFIG_FILE} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/npdu_tests/${TEST_NPDU_SERVICE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_NPDU_SERVICE_CONFIG_FILE} - ${TEST_NPDU_SERVICE_ONE} - ) + @ONLY) # Copy bashscript to start service with npdu into $BUILDDIR/test set(TEST_NPDU_SERVICE_START_SCRIPT ${TEST_NPDU_SERVICE}_npdu_start.sh) @@ -3838,12 +3046,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") set(TEST_NPDU_CLIENT_CONFIG_FILE ${TEST_NPDU_CLIENT}_no_npdu.json) configure_file( ${NETWORK_TEST_SRC_DIR}/npdu_tests/conf/${TEST_NPDU_CLIENT_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/npdu_tests/${TEST_NPDU_CLIENT_CONFIG_FILE} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/npdu_tests/${TEST_NPDU_CLIENT_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_NPDU_CLIENT_CONFIG_FILE} - ${TEST_NPDU_CLIENT_ONE} - ) + @ONLY) # Copy bashscript to start client w/o npdu into $BUILDDIR/test set(TEST_NPDU_CLIENT_START_SCRIPT ${TEST_NPDU_CLIENT}_no_npdu_start.sh) @@ -3857,12 +3061,8 @@ if(NOT ${TESTS_BAT} AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX") set(TEST_NPDU_CLIENT_CONFIG_FILE ${TEST_NPDU_CLIENT}_npdu.json) configure_file( ${NETWORK_TEST_SRC_DIR}/npdu_tests/conf/${TEST_NPDU_CLIENT_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/npdu_tests/${TEST_NPDU_CLIENT_CONFIG_FILE} - @ONLY) - copy_to_builddir(${NETWORK_TEST_SRC_DIR}/npdu_tests/${TEST_NPDU_CLIENT_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_NPDU_CLIENT_CONFIG_FILE} - ${TEST_NPDU_CLIENT_ONE} - ) + @ONLY) # Copy bashscript to start client with npdu into $BUILDDIR/test set(TEST_NPDU_CLIENT_START_SCRIPT ${TEST_NPDU_CLIENT}_npdu_start.sh) @@ -3930,25 +3130,16 @@ if(NOT ${TESTS_BAT}) set(TEST_SOMEIPTP_MASTER_CONFIG_FILE ${TEST_SOMEIPTP_NAME}_master.json) configure_file( ${NETWORK_TEST_SRC_DIR}/someip_tp_tests/conf/${TEST_SOMEIPTP_MASTER_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/someip_tp_tests/${TEST_SOMEIPTP_MASTER_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/someip_tp_tests/${TEST_SOMEIPTP_MASTER_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SOMEIPTP_MASTER_CONFIG_FILE} - ${TEST_SOMEIPTP_CLIENT} - ) + @ONLY) # Copy bashscript to start test (master) into $BUILDDIR/test set(TEST_SOMEIPTP_MASTER_START_SCRIPT ${TEST_SOMEIPTP_NAME}_master_starter.sh) configure_file( ${NETWORK_TEST_SRC_DIR}/someip_tp_tests/conf/${TEST_SOMEIPTP_MASTER_START_SCRIPT}.in - ${NETWORK_TEST_SRC_DIR}/someip_tp_tests/${TEST_SOMEIPTP_MASTER_START_SCRIPT} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/someip_tp_tests/${TEST_SOMEIPTP_MASTER_START_SCRIPT} ${NETWORK_TEST_BIN_DIR}/${TEST_SOMEIPTP_MASTER_START_SCRIPT} - ${TEST_SOMEIPTP_SERVICE} - ) + @ONLY) + endif() ############################################################################## @@ -3987,46 +3178,26 @@ if(NOT ${TESTS_BAT} AND ${TEST_SECOND_ADDRESS}) set(TEST_SECOND_ADDRESS_MASTER_SERVICE_UDP_CONFIG_FILE ${TEST_SECOND_ADDRESS_NAME}_master_service_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/second_address_tests/conf/${TEST_SECOND_ADDRESS_MASTER_SERVICE_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/second_address_tests/${TEST_SECOND_ADDRESS_MASTER_SERVICE_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/second_address_tests/${TEST_SECOND_ADDRESS_MASTER_SERVICE_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SECOND_ADDRESS_MASTER_SERVICE_UDP_CONFIG_FILE} - ${TEST_SECOND_ADDRESS_SERVICE} - ) + @ONLY) set(TEST_SECOND_ADDRESS_SLAVE_CLIENT_CONFIG_FILE ${TEST_SECOND_ADDRESS_NAME}_slave_client.json) configure_file( ${NETWORK_TEST_SRC_DIR}/second_address_tests/conf/${TEST_SECOND_ADDRESS_SLAVE_CLIENT_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/second_address_tests/${TEST_SECOND_ADDRESS_SLAVE_CLIENT_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/second_address_tests/${TEST_SECOND_ADDRESS_SLAVE_CLIENT_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SECOND_ADDRESS_SLAVE_CLIENT_CONFIG_FILE} - ${TEST_SECOND_ADDRESS_CLIENT} - ) + @ONLY) set(TEST_SECOND_ADDRESS_MASTER_CLIENT_CONFIG_FILE ${TEST_SECOND_ADDRESS_NAME}_master_client.json) configure_file( ${NETWORK_TEST_SRC_DIR}/second_address_tests/conf/${TEST_SECOND_ADDRESS_MASTER_CLIENT_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/second_address_tests/${TEST_SECOND_ADDRESS_MASTER_CLIENT_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/second_address_tests/${TEST_SECOND_ADDRESS_MASTER_CLIENT_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SECOND_ADDRESS_MASTER_CLIENT_CONFIG_FILE} - ${TEST_SECOND_ADDRESS_CLIENT} - ) + @ONLY) set(TEST_SECOND_ADDRESS_SLAVE_SERVICE_UDP_CONFIG_FILE ${TEST_SECOND_ADDRESS_NAME}_slave_service_udp.json) configure_file( ${NETWORK_TEST_SRC_DIR}/second_address_tests/conf/${TEST_SECOND_ADDRESS_SLAVE_SERVICE_UDP_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/second_address_tests/${TEST_SECOND_ADDRESS_SLAVE_SERVICE_UDP_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/second_address_tests/${TEST_SECOND_ADDRESS_SLAVE_SERVICE_UDP_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SECOND_ADDRESS_SLAVE_SERVICE_UDP_CONFIG_FILE} - ${TEST_SECOND_ADDRESS_SERVICE} - ) + @ONLY) set(TEST_SECOND_ADDRESS_MASTER_START_SCRIPT ${TEST_SECOND_ADDRESS_NAME}_master_starter.sh) copy_to_builddir( @@ -4038,13 +3209,9 @@ if(NOT ${TESTS_BAT} AND ${TEST_SECOND_ADDRESS}) set(TEST_SECOND_ADDRESS_SLAVE_START_SCRIPT ${TEST_SECOND_ADDRESS_NAME}_slave_starter.sh) configure_file( ${NETWORK_TEST_SRC_DIR}/second_address_tests/conf/${TEST_SECOND_ADDRESS_SLAVE_START_SCRIPT}.in - ${NETWORK_TEST_SRC_DIR}/second_address_tests/${TEST_SECOND_ADDRESS_SLAVE_START_SCRIPT} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/second_address_tests/${TEST_SECOND_ADDRESS_SLAVE_START_SCRIPT} ${NETWORK_TEST_BIN_DIR}/${TEST_SECOND_ADDRESS_SLAVE_START_SCRIPT} - ${TEST_SECOND_ADDRESS_CLIENT} - ) + @ONLY) + endif() ############################################################################## @@ -4083,24 +3250,14 @@ if(NOT ${TESTS_BAT}) set(TEST_SUSPEND_RESUME_SERVICE_CONFIG_FILE ${TEST_SUSPEND_RESUME_SERVICE}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/suspend_resume_tests/conf/${TEST_SUSPEND_RESUME_SERVICE_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/suspend_resume_tests/${TEST_SUSPEND_RESUME_SERVICE_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/suspend_resume_tests/${TEST_SUSPEND_RESUME_SERVICE_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUSPEND_RESUME_SERVICE_CONFIG_FILE} - ${TEST_SUSPEND_RESUME_CLIENT} - ) + @ONLY) set(TEST_SUSPEND_RESUME_CLIENT_CONFIG_FILE ${TEST_SUSPEND_RESUME_CLIENT}.json) configure_file( ${NETWORK_TEST_SRC_DIR}/suspend_resume_tests/conf/${TEST_SUSPEND_RESUME_CLIENT_CONFIG_FILE}.in - ${NETWORK_TEST_SRC_DIR}/suspend_resume_tests/${TEST_SUSPEND_RESUME_CLIENT_CONFIG_FILE} - @ONLY) - copy_to_builddir( - ${NETWORK_TEST_SRC_DIR}/suspend_resume_tests/${TEST_SUSPEND_RESUME_CLIENT_CONFIG_FILE} ${NETWORK_TEST_BIN_DIR}/${TEST_SUSPEND_RESUME_CLIENT_CONFIG_FILE} - ${TEST_SUSPEND_RESUME_CLIENT} - ) + @ONLY) set(TEST_SUSPEND_RESUME_MASTER_START_SCRIPT ${TEST_SUSPEND_RESUME_NAME}_master_starter.sh) copy_to_builddir( From deaedebbd48c43b7654d2955b0e06e2231e87e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 10:31:27 +0100 Subject: [PATCH 12/20] Fix deadlock if binding of TCP client endpoint fails --- implementation/endpoints/src/tcp_client_endpoint_impl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp index ba078a872..067203641 100644 --- a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp @@ -137,7 +137,7 @@ void tcp_client_endpoint_impl::restart(bool _force) { void tcp_client_endpoint_impl::connect() { start_connecting_timer(); - std::lock_guard its_lock(socket_mutex_); + std::unique_lock its_lock(socket_mutex_); boost::system::error_code its_error; socket_->open(remote_.protocol(), its_error); @@ -195,6 +195,8 @@ void tcp_client_endpoint_impl::connect() { << " local: " << get_address_port_local() << " remote:" << get_address_port_remote(); + its_lock.unlock(); + std::shared_ptr its_host = endpoint_host_.lock(); if (its_host) { // set new client port depending on service / instance / remote port From fb4f01e248d3c3f26beb5b80f46035c6fdc12b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 10:33:18 +0100 Subject: [PATCH 13/20] Added missing includes of iomanip to support compilation on Mint --- .../big_payload_tests/big_payload_test_service.cpp | 2 ++ .../network_tests/cpu_load_tests/cpu_load_test_service.cpp | 7 ++++--- .../network_tests/e2e_tests/e2e_profile_04_test_client.cpp | 2 ++ .../e2e_tests/e2e_profile_04_test_service.cpp | 2 ++ .../network_tests/e2e_tests/e2e_profile_07_test_client.cpp | 2 ++ .../e2e_tests/e2e_profile_07_test_service.cpp | 2 ++ test/network_tests/e2e_tests/e2e_test_client.cpp | 2 ++ test/network_tests/e2e_tests/e2e_test_service.cpp | 2 ++ test/network_tests/event_tests/event_test_service.cpp | 5 +++-- .../header_factory_tests/header_factory_test_client.cpp | 2 ++ .../header_factory_tests/header_factory_test_service.cpp | 5 +++-- .../lazy_load_tests/lazy_load_test_client.cpp | 2 ++ .../lazy_load_tests/lazy_load_test_lazy_client.cpp | 2 ++ .../lazy_load_tests/lazy_load_test_service.cpp | 2 ++ test/network_tests/npdu_tests/npdu_test_client.cpp | 3 +++ test/network_tests/npdu_tests/npdu_test_service.cpp | 2 ++ test/network_tests/payload_tests/payload_test_client.cpp | 2 ++ test/network_tests/payload_tests/payload_test_service.cpp | 2 ++ .../restart_routing_tests/restart_routing_test_client.cpp | 2 ++ .../restart_routing_tests/restart_routing_test_service.cpp | 2 ++ .../routing_tests/external_local_routing_test_service.cpp | 2 ++ .../routing_tests/local_routing_test_client.cpp | 2 ++ .../routing_tests/local_routing_test_service.cpp | 2 ++ .../second_address_tests/second_address_test_service.cpp | 3 ++- test/network_tests/security_tests/security_test_client.cpp | 2 ++ .../network_tests/security_tests/security_test_service.cpp | 2 ++ .../suspend_resume_tests/suspend_resume_test_service.cpp | 3 ++- 27 files changed, 59 insertions(+), 9 deletions(-) diff --git a/test/network_tests/big_payload_tests/big_payload_test_service.cpp b/test/network_tests/big_payload_tests/big_payload_test_service.cpp index a6bd4d7eb..d37f3d152 100644 --- a/test/network_tests/big_payload_tests/big_payload_test_service.cpp +++ b/test/network_tests/big_payload_tests/big_payload_test_service.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "big_payload_test_service.hpp" #include "big_payload_test_globals.hpp" diff --git a/test/network_tests/cpu_load_tests/cpu_load_test_service.cpp b/test/network_tests/cpu_load_tests/cpu_load_test_service.cpp index 3d935e395..8bf00cf2f 100644 --- a/test/network_tests/cpu_load_tests/cpu_load_test_service.cpp +++ b/test/network_tests/cpu_load_tests/cpu_load_test_service.cpp @@ -7,12 +7,13 @@ #include -#include -#include +#include // for isfinite #include #include +#include +#include #include -#include // for isfinite +#include #include "cpu_load_test_globals.hpp" #include diff --git a/test/network_tests/e2e_tests/e2e_profile_04_test_client.cpp b/test/network_tests/e2e_tests/e2e_profile_04_test_client.cpp index 266865682..f97f038ab 100644 --- a/test/network_tests/e2e_tests/e2e_profile_04_test_client.cpp +++ b/test/network_tests/e2e_tests/e2e_profile_04_test_client.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "e2e_profile_04_test_common.hpp" #include "e2e_profile_04_test_client.hpp" diff --git a/test/network_tests/e2e_tests/e2e_profile_04_test_service.cpp b/test/network_tests/e2e_tests/e2e_profile_04_test_service.cpp index efd48c906..acf34779b 100644 --- a/test/network_tests/e2e_tests/e2e_profile_04_test_service.cpp +++ b/test/network_tests/e2e_tests/e2e_profile_04_test_service.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "e2e_profile_04_test_common.hpp" #include "e2e_profile_04_test_service.hpp" diff --git a/test/network_tests/e2e_tests/e2e_profile_07_test_client.cpp b/test/network_tests/e2e_tests/e2e_profile_07_test_client.cpp index 606ef9968..58faa3ec6 100644 --- a/test/network_tests/e2e_tests/e2e_profile_07_test_client.cpp +++ b/test/network_tests/e2e_tests/e2e_profile_07_test_client.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "e2e_profile_07_test_common.hpp" #include "e2e_profile_07_test_client.hpp" diff --git a/test/network_tests/e2e_tests/e2e_profile_07_test_service.cpp b/test/network_tests/e2e_tests/e2e_profile_07_test_service.cpp index 5426209f5..5e2a09293 100644 --- a/test/network_tests/e2e_tests/e2e_profile_07_test_service.cpp +++ b/test/network_tests/e2e_tests/e2e_profile_07_test_service.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "e2e_profile_07_test_common.hpp" #include "e2e_profile_07_test_service.hpp" diff --git a/test/network_tests/e2e_tests/e2e_test_client.cpp b/test/network_tests/e2e_tests/e2e_test_client.cpp index 260ad7e13..9e270cca2 100644 --- a/test/network_tests/e2e_tests/e2e_test_client.cpp +++ b/test/network_tests/e2e_tests/e2e_test_client.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "e2e_test_client.hpp" static bool is_remote_test = false; diff --git a/test/network_tests/e2e_tests/e2e_test_service.cpp b/test/network_tests/e2e_tests/e2e_test_service.cpp index 46e57ae4e..164716700 100644 --- a/test/network_tests/e2e_tests/e2e_test_service.cpp +++ b/test/network_tests/e2e_tests/e2e_test_service.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "e2e_test_service.hpp" static bool is_remote_test = false; diff --git a/test/network_tests/event_tests/event_test_service.cpp b/test/network_tests/event_tests/event_test_service.cpp index 3728a8276..5f7099ffb 100644 --- a/test/network_tests/event_tests/event_test_service.cpp +++ b/test/network_tests/event_tests/event_test_service.cpp @@ -3,13 +3,14 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include #include #include +#include #include +#include #include #include -#include -#include #include diff --git a/test/network_tests/header_factory_tests/header_factory_test_client.cpp b/test/network_tests/header_factory_tests/header_factory_test_client.cpp index 13b1111ed..59395ee66 100644 --- a/test/network_tests/header_factory_tests/header_factory_test_client.cpp +++ b/test/network_tests/header_factory_tests/header_factory_test_client.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "header_factory_test_client.hpp" header_factory_test_client::header_factory_test_client(bool _use_tcp) : diff --git a/test/network_tests/header_factory_tests/header_factory_test_service.cpp b/test/network_tests/header_factory_tests/header_factory_test_service.cpp index d647fd9b3..8f7255fe8 100644 --- a/test/network_tests/header_factory_tests/header_factory_test_service.cpp +++ b/test/network_tests/header_factory_tests/header_factory_test_service.cpp @@ -3,9 +3,10 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#include "header_factory_test_service.hpp" - #include +#include + +#include "header_factory_test_service.hpp" header_factory_test_service::header_factory_test_service(bool _use_static_routing) : app_(vsomeip::runtime::get()->create_application()), diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_client.cpp b/test/network_tests/lazy_load_tests/lazy_load_test_client.cpp index 13a437322..e078374d7 100644 --- a/test/network_tests/lazy_load_tests/lazy_load_test_client.cpp +++ b/test/network_tests/lazy_load_tests/lazy_load_test_client.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "lazy_load_test_client.hpp" lazy_load_test_client::lazy_load_test_client() diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.cpp b/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.cpp index 5ab81f1f2..7349b2d10 100644 --- a/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.cpp +++ b/test/network_tests/lazy_load_tests/lazy_load_test_lazy_client.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "lazy_load_test_lazy_client.hpp" lazy_load_lazy_client::lazy_load_lazy_client() diff --git a/test/network_tests/lazy_load_tests/lazy_load_test_service.cpp b/test/network_tests/lazy_load_tests/lazy_load_test_service.cpp index 935f51101..001bff656 100644 --- a/test/network_tests/lazy_load_tests/lazy_load_test_service.cpp +++ b/test/network_tests/lazy_load_tests/lazy_load_test_service.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "lazy_load_test_service.hpp" lazy_load_test_service::lazy_load_test_service() : diff --git a/test/network_tests/npdu_tests/npdu_test_client.cpp b/test/network_tests/npdu_tests/npdu_test_client.cpp index 08c6dbb41..cba54f281 100644 --- a/test/network_tests/npdu_tests/npdu_test_client.cpp +++ b/test/network_tests/npdu_tests/npdu_test_client.cpp @@ -2,6 +2,9 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + #include "../npdu_tests/npdu_test_client.hpp" #include diff --git a/test/network_tests/npdu_tests/npdu_test_service.cpp b/test/network_tests/npdu_tests/npdu_test_service.cpp index 5fdc87dc4..3b13802a5 100644 --- a/test/network_tests/npdu_tests/npdu_test_service.cpp +++ b/test/network_tests/npdu_tests/npdu_test_service.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "../npdu_tests/npdu_test_service.hpp" #include "../npdu_tests/npdu_test_globals.hpp" diff --git a/test/network_tests/payload_tests/payload_test_client.cpp b/test/network_tests/payload_tests/payload_test_client.cpp index 3395668b7..ef5ba631f 100644 --- a/test/network_tests/payload_tests/payload_test_client.cpp +++ b/test/network_tests/payload_tests/payload_test_client.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "payload_test_client.hpp" enum class payloadsize diff --git a/test/network_tests/payload_tests/payload_test_service.cpp b/test/network_tests/payload_tests/payload_test_service.cpp index 0aa55afed..7d4c9243a 100644 --- a/test/network_tests/payload_tests/payload_test_service.cpp +++ b/test/network_tests/payload_tests/payload_test_service.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "payload_test_service.hpp" // this variables are changed via cmdline parameters diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_client.cpp b/test/network_tests/restart_routing_tests/restart_routing_test_client.cpp index 847594eca..15be4a3b1 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_client.cpp +++ b/test/network_tests/restart_routing_tests/restart_routing_test_client.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "restart_routing_test_client.hpp" routing_restart_test_client::routing_restart_test_client() diff --git a/test/network_tests/restart_routing_tests/restart_routing_test_service.cpp b/test/network_tests/restart_routing_tests/restart_routing_test_service.cpp index 92f0ff0a2..61bb615cf 100644 --- a/test/network_tests/restart_routing_tests/restart_routing_test_service.cpp +++ b/test/network_tests/restart_routing_tests/restart_routing_test_service.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "restart_routing_test_service.hpp" routing_restart_test_service::routing_restart_test_service() : diff --git a/test/network_tests/routing_tests/external_local_routing_test_service.cpp b/test/network_tests/routing_tests/external_local_routing_test_service.cpp index ba4cdd0c1..c90f17b12 100644 --- a/test/network_tests/routing_tests/external_local_routing_test_service.cpp +++ b/test/network_tests/routing_tests/external_local_routing_test_service.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "external_local_routing_test_service.hpp" external_local_routing_test_service::external_local_routing_test_service(bool _use_static_routing) : diff --git a/test/network_tests/routing_tests/local_routing_test_client.cpp b/test/network_tests/routing_tests/local_routing_test_client.cpp index 4bde183f4..f7f83c324 100644 --- a/test/network_tests/routing_tests/local_routing_test_client.cpp +++ b/test/network_tests/routing_tests/local_routing_test_client.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "local_routing_test_client.hpp" local_routing_test_client::local_routing_test_client(bool _use_tcp) : diff --git a/test/network_tests/routing_tests/local_routing_test_service.cpp b/test/network_tests/routing_tests/local_routing_test_service.cpp index 2a819e215..5d659e264 100644 --- a/test/network_tests/routing_tests/local_routing_test_service.cpp +++ b/test/network_tests/routing_tests/local_routing_test_service.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "local_routing_test_service.hpp" local_routing_test_service::local_routing_test_service(bool _use_static_routing) : diff --git a/test/network_tests/second_address_tests/second_address_test_service.cpp b/test/network_tests/second_address_tests/second_address_test_service.cpp index fc9d0a281..e6346b704 100644 --- a/test/network_tests/second_address_tests/second_address_test_service.cpp +++ b/test/network_tests/second_address_tests/second_address_test_service.cpp @@ -5,10 +5,11 @@ #include #include +#include #include +#include #include #include -#include #include #include diff --git a/test/network_tests/security_tests/security_test_client.cpp b/test/network_tests/security_tests/security_test_client.cpp index 2890e74bf..9c3c3dd63 100644 --- a/test/network_tests/security_tests/security_test_client.cpp +++ b/test/network_tests/security_tests/security_test_client.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "security_test_client.hpp" static bool is_remote_test = false; diff --git a/test/network_tests/security_tests/security_test_service.cpp b/test/network_tests/security_tests/security_test_service.cpp index fdfb48bee..7843504b8 100644 --- a/test/network_tests/security_tests/security_test_service.cpp +++ b/test/network_tests/security_tests/security_test_service.cpp @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include "security_test_service.hpp" static bool is_remote_test = false; diff --git a/test/network_tests/suspend_resume_tests/suspend_resume_test_service.cpp b/test/network_tests/suspend_resume_tests/suspend_resume_test_service.cpp index 6f099ce7c..1f3c97cbd 100644 --- a/test/network_tests/suspend_resume_tests/suspend_resume_test_service.cpp +++ b/test/network_tests/suspend_resume_tests/suspend_resume_test_service.cpp @@ -3,10 +3,11 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include #include +#include #include #include -#include #include From 023480aa13b4243b35a6a6845142f2be881dc4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 10:35:16 +0100 Subject: [PATCH 14/20] Cache not yet registered events --- CMakeLists.txt | 5 ++ .../routing/include/routing_manager_impl.hpp | 5 ++ .../routing/src/routing_manager_impl.cpp | 57 +++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3501e02c5..9c4f70650 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,6 +109,11 @@ if (ENABLE_SIGNAL_HANDLING) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_SIGNAL_HANDLING") endif () +# Event caching +if (ENABLE_DEFAULT_EVENT_CACHING) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVSOMEIP_ENABLE_DEFAULT_EVENT_CACHING") +endif () + if (NOT MSVC) # Sanitizers diff --git a/implementation/routing/include/routing_manager_impl.hpp b/implementation/routing/include/routing_manager_impl.hpp index 987f9d3d2..38c0f25a4 100644 --- a/implementation/routing/include/routing_manager_impl.hpp +++ b/implementation/routing/include/routing_manager_impl.hpp @@ -465,6 +465,11 @@ class routing_manager_impl: public routing_manager_base, service_t _service, instance_t _instance, const boost::asio::ip::address &_remote_address) const; +#ifdef VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING + bool has_subscribed_eventgroup( + service_t _service, instance_t _instance) const; +#endif // VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING + private: std::shared_ptr stub_; std::shared_ptr discovery_; diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index f5329e7ae..c21fd2678 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -2062,6 +2062,26 @@ bool routing_manager_impl::deliver_message(const byte_t *_data, length_t _size, return is_delivered; } +#ifdef VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING +bool +routing_manager_impl::has_subscribed_eventgroup( + service_t _service, instance_t _instance) const { + + std::lock_guard its_lock(eventgroups_mutex_); + auto found_service = eventgroups_.find(_service); + if (found_service != eventgroups_.end()) { + auto found_instance = found_service->second.find(_instance); + if (found_instance != found_service->second.end()) + for (const auto &its_eventgroup : found_instance->second) + for (const auto &e : its_eventgroup.second->get_events()) + if (!e->get_subscribers().empty()) + return true; + } + + return false; +} +#endif // VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING + bool routing_manager_impl::deliver_notification( service_t _service, instance_t _instance, const byte_t *_data, length_t _length, bool _reliable, @@ -2153,6 +2173,42 @@ bool routing_manager_impl::deliver_notification( } } else { +#ifdef VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING + if (has_subscribed_eventgroup(_service, _instance)) { + if (!is_suppress_event(_service, _instance, its_event_id)) { + VSOMEIP_WARNING << __func__ << ": Caching unregistered event [" + << std::hex << std::setw(4) << std::setfill('0') << _service << "." + << std::hex << std::setw(4) << std::setfill('0') << _instance << "." + << std::hex << std::setw(4) << std::setfill('0') << its_event_id << "]"; + } + + routing_manager_base::register_event(host_->get_client(), + _service, _instance, its_event_id, { }, + event_type_e::ET_UNKNOWN, + _reliable ? reliability_type_e::RT_RELIABLE + : reliability_type_e::RT_UNRELIABLE, + std::chrono::milliseconds::zero(), false, true, nullptr, + true, true, true); + + its_event = find_event(_service, _instance, its_event_id); + if (its_event) { + auto its_length = utility::get_payload_size(_data, _length); + auto its_payload = runtime::get()->create_payload( + &_data[VSOMEIP_PAYLOAD_POS], its_length); + its_event->set_payload(its_payload, true); + } else + VSOMEIP_ERROR << __func__ << ": Event registration failed [" + << std::hex << std::setw(4) << std::setfill('0') << _service << "." + << std::hex << std::setw(4) << std::setfill('0') << _instance << "." + << std::hex << std::setw(4) << std::setfill('0') << its_event_id << "]"; + } else if (!is_suppress_event(_service, _instance, its_event_id)) { + VSOMEIP_WARNING << __func__ << ": Dropping unregistered event [" + << std::hex << std::setw(4) << std::setfill('0') << _service << "." + << std::hex << std::setw(4) << std::setfill('0') << _instance << "." + << std::hex << std::setw(4) << std::setfill('0') << its_event_id << "] " + << "Service has no subscribed eventgroup."; + } +#else if (!is_suppress_event(_service, _instance, its_event_id)) { VSOMEIP_WARNING << __func__ << ": Event [" << std::hex << std::setw(4) << std::setfill('0') << _service << "." @@ -2160,6 +2216,7 @@ bool routing_manager_impl::deliver_notification( << std::hex << std::setw(4) << std::setfill('0') << its_event_id << "]" << " is not registered. The message is dropped."; } +#endif // VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING } return true; } From ea86dba26ca0a0357a4cca6c99189613c6ae3684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 10:37:05 +0100 Subject: [PATCH 15/20] Return true to make sure endpoints are deleted --- implementation/endpoints/src/udp_server_endpoint_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp index 70afd1b79..02a856a32 100644 --- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp @@ -357,7 +357,7 @@ bool udp_server_endpoint_impl::send_queued( ) ); - return false; + return true; } void udp_server_endpoint_impl::get_configured_times_from_endpoint( From fa378eb521e9d72e0fd5cb8fbcbf35a476422481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 11:12:17 +0100 Subject: [PATCH 16/20] Byteorder implementation --- .../src/e2e/profile/profile04/checker.cpp | 10 +- .../src/e2e/profile/profile04/protector.cpp | 26 +- .../src/e2e/profile/profile05/checker.cpp | 5 +- .../src/e2e/profile/profile05/protector.cpp | 12 +- .../src/e2e/profile/profile07/checker.cpp | 18 +- .../src/e2e/profile/profile07/protector.cpp | 34 +- .../endpoints/src/client_endpoint_impl.cpp | 71 ++-- .../endpoints/src/endpoint_manager_impl.cpp | 5 +- .../src/local_tcp_server_endpoint_impl.cpp | 9 +- .../src/local_uds_server_endpoint_impl.cpp | 9 +- .../endpoints/src/server_endpoint_impl.cpp | 85 ++--- .../src/tcp_client_endpoint_impl.cpp | 51 +-- .../src/tcp_server_endpoint_impl.cpp | 30 +- implementation/endpoints/src/tp.cpp | 1 - implementation/endpoints/src/tp_message.cpp | 47 +-- .../endpoints/src/tp_reassembler.cpp | 14 +- .../src/udp_client_endpoint_impl.cpp | 34 +- .../src/udp_server_endpoint_impl.cpp | 29 +- implementation/message/src/deserializer.cpp | 13 +- .../message/src/message_base_impl.cpp | 18 +- implementation/message/src/message_impl.cpp | 1 - implementation/message/src/serializer.cpp | 19 +- .../routing/src/routing_manager_base.cpp | 8 +- .../routing/src/routing_manager_client.cpp | 313 ++++++++++-------- .../routing/src/routing_manager_impl.cpp | 124 +++---- .../routing/src/routing_manager_stub.cpp | 47 +-- implementation/security/src/policy.cpp | 23 +- .../src/service_discovery_impl.cpp | 12 +- implementation/tracing/src/connector_impl.cpp | 15 +- implementation/tracing/src/header.cpp | 19 +- implementation/utility/include/bithelper.hpp | 134 ++++++++ implementation/utility/include/byteorder.hpp | 113 +++---- implementation/utility/src/utility.cpp | 6 +- interface/vsomeip/enumeration_types.hpp | 5 + .../malicious_data_test_msg_sender.cpp | 37 +-- ...ending_subscription_test_sd_msg_sender.cpp | 116 +++---- .../someip_tp_test_msg_sender.cpp | 67 ++-- .../utility_tests/ut_ByteOperation.cpp | 170 ++++++++++ tools/vsomeip_ctrl.cpp | 21 +- 39 files changed, 861 insertions(+), 910 deletions(-) create mode 100644 implementation/utility/include/bithelper.hpp create mode 100644 test/unit_tests/utility_tests/ut_ByteOperation.cpp diff --git a/implementation/e2e_protection/src/e2e/profile/profile04/checker.cpp b/implementation/e2e_protection/src/e2e/profile/profile04/checker.cpp index 5e729766b..3e655f1d5 100644 --- a/implementation/e2e_protection/src/e2e/profile/profile04/checker.cpp +++ b/implementation/e2e_protection/src/e2e/profile/profile04/checker.cpp @@ -8,7 +8,7 @@ #include #include "../../../../include/e2e/profile/profile04/checker.hpp" -#include "../../../../../utility/include/byteorder.hpp" +#include "../../../../../utility/include/bithelper.hpp" namespace vsomeip_v3 { namespace e2e { @@ -92,8 +92,7 @@ bool profile_04_checker::read_16(const e2e_buffer &_buffer, uint16_t &_data, size_t _index) const { - _data = VSOMEIP_BYTES_TO_WORD(_buffer[config_.offset_ + _index], - _buffer[config_.offset_ + _index + 1]); + _data = bithelper::read_uint16_be(&_buffer[config_.offset_ + _index]); return true; } @@ -101,10 +100,7 @@ bool profile_04_checker::read_32(const e2e_buffer &_buffer, uint32_t &_data, size_t _index) const { - _data = VSOMEIP_BYTES_TO_LONG(_buffer[config_.offset_ + _index], - _buffer[config_.offset_ + _index + 1], - _buffer[config_.offset_ + _index + 2], - _buffer[config_.offset_ + _index + 3]); + _data = bithelper::read_uint32_be(&_buffer[config_.offset_ + _index]); return true; } diff --git a/implementation/e2e_protection/src/e2e/profile/profile04/protector.cpp b/implementation/e2e_protection/src/e2e/profile/profile04/protector.cpp index 2f9899c4c..e6abf84b9 100644 --- a/implementation/e2e_protection/src/e2e/profile/profile04/protector.cpp +++ b/implementation/e2e_protection/src/e2e/profile/profile04/protector.cpp @@ -7,7 +7,7 @@ #include #include "../../../../include/e2e/profile/profile04/protector.hpp" -#include "../../../../../utility/include/byteorder.hpp" +#include "../../../../../utility/include/bithelper.hpp" namespace vsomeip_v3 { namespace e2e { @@ -27,20 +27,20 @@ protector::protect(e2e_buffer &_buffer, instance_t _instance) { if (verify_inputs(_buffer)) { /** @req [SWS_E2E_00364] */ - write_16(_buffer, static_cast(_buffer.size()), 0); + bithelper::write_uint16_be(static_cast(_buffer.size()), &_buffer[config_.offset_]); /** @req [SWS_E2E_00365] */ - write_16(_buffer, get_counter(_instance), 2); + bithelper::write_uint16_be(get_counter(_instance), &_buffer[config_.offset_ + 2]); /** @req [SWS_E2E_00366] */ uint32_t its_data_id(uint32_t(_instance) << 24 | config_.data_id_); - write_32(_buffer, its_data_id, 4); + bithelper::write_uint32_be(its_data_id, &_buffer[config_.offset_ + 4]); /** @req [SWS_E2E_00367] */ uint32_t its_crc = profile_04::compute_crc(config_, _buffer); /** @req [SWS_E2E_0368] */ - write_32(_buffer, its_crc, 8); + bithelper::write_uint32_be(its_crc, &_buffer[config_.offset_ + 8]); /** @req [SWS_E2E_00369] */ increment_counter(_instance); @@ -54,22 +54,6 @@ protector::verify_inputs(e2e_buffer &_buffer) { && _buffer.size() <= config_.max_data_length_); } -void -protector::write_16(e2e_buffer &_buffer, uint16_t _data, size_t _index) { - - _buffer[config_.offset_ + _index] = VSOMEIP_WORD_BYTE1(_data); - _buffer[config_.offset_ + _index + 1] = VSOMEIP_WORD_BYTE0(_data); -} - -void -protector::write_32(e2e_buffer &_buffer, uint32_t _data, size_t _index) { - - _buffer[config_.offset_ + _index] = VSOMEIP_LONG_BYTE3(_data); - _buffer[config_.offset_ + _index + 1] = VSOMEIP_LONG_BYTE2(_data); - _buffer[config_.offset_ + _index + 2] = VSOMEIP_LONG_BYTE1(_data); - _buffer[config_.offset_ + _index + 3] = VSOMEIP_LONG_BYTE0(_data); -} - uint16_t protector::get_counter(instance_t _instance) const { diff --git a/implementation/e2e_protection/src/e2e/profile/profile05/checker.cpp b/implementation/e2e_protection/src/e2e/profile/profile05/checker.cpp index bb943ba72..964b73ac5 100644 --- a/implementation/e2e_protection/src/e2e/profile/profile05/checker.cpp +++ b/implementation/e2e_protection/src/e2e/profile/profile05/checker.cpp @@ -8,7 +8,7 @@ #include #include "../../../../include/e2e/profile/profile05/checker.hpp" -#include "../../../../../utility/include/byteorder.hpp" +#include "../../../../../utility/include/bithelper.hpp" namespace vsomeip_v3 { namespace e2e { @@ -78,8 +78,7 @@ bool profile_05_checker::read_16(const e2e_buffer &_buffer, uint16_t &_data, size_t _index) const { - _data = VSOMEIP_BYTES_TO_WORD(_buffer[config_.offset_ + _index + 1], - _buffer[config_.offset_ + _index]); + _data = bithelper::read_uint16_be(&_buffer[config_.offset_ + _index]); return true; } diff --git a/implementation/e2e_protection/src/e2e/profile/profile05/protector.cpp b/implementation/e2e_protection/src/e2e/profile/profile05/protector.cpp index f8ab9de4e..46843a6d4 100644 --- a/implementation/e2e_protection/src/e2e/profile/profile05/protector.cpp +++ b/implementation/e2e_protection/src/e2e/profile/profile05/protector.cpp @@ -7,7 +7,7 @@ #include #include "../../../../include/e2e/profile/profile05/protector.hpp" -#include "../../../../../utility/include/byteorder.hpp" +#include "../../../../../utility/include/bithelper.hpp" namespace vsomeip_v3 { namespace e2e { @@ -30,8 +30,7 @@ void protector::protect(e2e_buffer &_buffer, instance_t _instance) { // compute the CRC uint16_t its_crc = profile_05::compute_crc(config_, _buffer); - - write_crc(_buffer, its_crc, 0); + bithelper::write_uint16_be(its_crc, &_buffer[config_.offset_]); // increment the Counter (new value will be used in the next invocation of E2E_P05Protect()), increment_counter(_instance); @@ -44,13 +43,6 @@ protector::write_counter(e2e_buffer &_buffer, uint8_t _data, size_t _index) { _buffer[config_.offset_ + _index] = _data; } -void -protector::write_crc(e2e_buffer &_buffer, uint16_t _data, size_t _index) { - - _buffer[config_.offset_ + _index] = VSOMEIP_WORD_BYTE0(_data); - _buffer[config_.offset_ + _index + 1] = VSOMEIP_WORD_BYTE1(_data); -} - uint8_t protector::get_counter(instance_t _instance) const { diff --git a/implementation/e2e_protection/src/e2e/profile/profile07/checker.cpp b/implementation/e2e_protection/src/e2e/profile/profile07/checker.cpp index f069046bc..eab7439e7 100644 --- a/implementation/e2e_protection/src/e2e/profile/profile07/checker.cpp +++ b/implementation/e2e_protection/src/e2e/profile/profile07/checker.cpp @@ -8,7 +8,7 @@ #include #include "../../../../include/e2e/profile/profile07/checker.hpp" -#include "../../../../../utility/include/byteorder.hpp" +#include "../../../../../utility/include/bithelper.hpp" namespace vsomeip_v3 { namespace e2e { @@ -87,26 +87,16 @@ bool profile_07_checker::read_32(const e2e_buffer &_buffer, uint32_t &_data, size_t _index) const { - _data = VSOMEIP_BYTES_TO_LONG(_buffer[config_.offset_ + _index], - _buffer[config_.offset_ + _index + 1], - _buffer[config_.offset_ + _index + 2], - _buffer[config_.offset_ + _index + 3]); + _data = bithelper::read_uint32_be(&_buffer[config_.offset_ + _index]); return true; } // Read uint64_t as big-endian bool -profile_07_checker::read_64(const e2e_buffer &_buffer, +profile_07_checker::read_64(const e2e_buffer &_buffer, uint64_t &_data, size_t _index) const { - _data = VSOMEIP_BYTES_TO_LONG_LONG(_buffer[config_.offset_ + _index], - _buffer[config_.offset_ + _index + 1], - _buffer[config_.offset_ + _index + 2], - _buffer[config_.offset_ + _index + 3], - _buffer[config_.offset_ + _index + 4], - _buffer[config_.offset_ + _index + 5], - _buffer[config_.offset_ + _index + 6], - _buffer[config_.offset_ + _index + 7]); + _data = bithelper::read_uint64_be(&_buffer[config_.offset_ + _index]); return true; } diff --git a/implementation/e2e_protection/src/e2e/profile/profile07/protector.cpp b/implementation/e2e_protection/src/e2e/profile/profile07/protector.cpp index 311bc5ad5..b470245ac 100644 --- a/implementation/e2e_protection/src/e2e/profile/profile07/protector.cpp +++ b/implementation/e2e_protection/src/e2e/profile/profile07/protector.cpp @@ -7,7 +7,7 @@ #include #include "../../../../include/e2e/profile/profile07/protector.hpp" -#include "../../../../../utility/include/byteorder.hpp" +#include "../../../../../utility/include/bithelper.hpp" namespace vsomeip_v3 { namespace e2e { @@ -22,19 +22,19 @@ protector::protect(e2e_buffer &_buffer, instance_t _instance) { if (verify_inputs(_buffer)) { /** @req [SWS_E2E_00489] */ - write_32(_buffer, static_cast(_buffer.size()), PROFILE_07_SIZE_OFFSET); + bithelper::write_uint32_be(static_cast(_buffer.size()), &_buffer[config_.offset_ + PROFILE_07_SIZE_OFFSET]); /** @req [SWS_E2E_00490] */ - write_32(_buffer, get_counter(_instance), PROFILE_07_COUNTER_OFFSET); + bithelper::write_uint32_be(get_counter(_instance), &_buffer[config_.offset_ + PROFILE_07_COUNTER_OFFSET]); /** @req [SWS_E2E_00491] */ - write_32(_buffer, config_.data_id_, PROFILE_07_DATAID_OFFSET); + bithelper::write_uint32_be(config_.data_id_, &_buffer[config_.offset_ + PROFILE_07_DATAID_OFFSET]); /** @req [SWS_E2E_00492] */ uint64_t its_crc = profile_07::compute_crc(config_, _buffer); /** @req [SWS_E2E_00493] */ - write_64(_buffer, its_crc, PROFILE_07_CRC_OFFSET); + bithelper::write_uint64_be(its_crc, &_buffer[config_.offset_ + PROFILE_07_CRC_OFFSET]); /** @req [SWS_E2E_00494] */ increment_counter(_instance); @@ -48,30 +48,6 @@ protector::verify_inputs(e2e_buffer &_buffer) { && _buffer.size() <= config_.max_data_length_); } -// Write uint32_t as big-endian -void -protector::write_32(e2e_buffer &_buffer, uint32_t _data, size_t _index) { - - _buffer[config_.offset_ + _index] = VSOMEIP_LONG_BYTE3(_data); - _buffer[config_.offset_ + _index + 1] = VSOMEIP_LONG_BYTE2(_data); - _buffer[config_.offset_ + _index + 2] = VSOMEIP_LONG_BYTE1(_data); - _buffer[config_.offset_ + _index + 3] = VSOMEIP_LONG_BYTE0(_data); -} - -// Write uint64_t as big-endian -void -protector::write_64(e2e_buffer &_buffer, uint64_t _data, size_t _index) { - - _buffer[config_.offset_ + _index] = VSOMEIP_LONG_LONG_BYTE7(_data); - _buffer[config_.offset_ + _index + 1] = VSOMEIP_LONG_LONG_BYTE6(_data); - _buffer[config_.offset_ + _index + 2] = VSOMEIP_LONG_LONG_BYTE5(_data); - _buffer[config_.offset_ + _index + 3] = VSOMEIP_LONG_LONG_BYTE4(_data); - _buffer[config_.offset_ + _index + 4] = VSOMEIP_LONG_LONG_BYTE3(_data); - _buffer[config_.offset_ + _index + 5] = VSOMEIP_LONG_LONG_BYTE2(_data); - _buffer[config_.offset_ + _index + 6] = VSOMEIP_LONG_LONG_BYTE1(_data); - _buffer[config_.offset_ + _index + 7] = VSOMEIP_LONG_LONG_BYTE0(_data); -} - uint32_t protector::get_counter(instance_t _instance) const { diff --git a/implementation/endpoints/src/client_endpoint_impl.cpp b/implementation/endpoints/src/client_endpoint_impl.cpp index 03254a816..5f7e695be 100644 --- a/implementation/endpoints/src/client_endpoint_impl.cpp +++ b/implementation/endpoints/src/client_endpoint_impl.cpp @@ -20,7 +20,7 @@ #include "../include/client_endpoint_impl.hpp" #include "../include/endpoint_host.hpp" #include "../../utility/include/utility.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" namespace vsomeip_v3 { @@ -212,10 +212,9 @@ bool client_endpoint_impl::send(const uint8_t *_data, uint32_t _size) cancel_dispatch_timer(); // STEP 3: Get configured timings - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]); - const method_t its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], _data[VSOMEIP_METHOD_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + const service_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); + std::chrono::nanoseconds its_debouncing(0), its_retention(0); get_configured_times_from_endpoint(its_service, its_method, &its_debouncing, &its_retention); @@ -306,12 +305,9 @@ void client_endpoint_impl::send_segments( return; } - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - (*(_segments[0]))[VSOMEIP_SERVICE_POS_MIN], - (*(_segments[0]))[VSOMEIP_SERVICE_POS_MAX]); - const method_t its_method = VSOMEIP_BYTES_TO_WORD( - (*(_segments[0]))[VSOMEIP_METHOD_POS_MIN], - (*(_segments[0]))[VSOMEIP_METHOD_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&(*(_segments[0]))[VSOMEIP_SERVICE_POS_MIN]); + const service_t its_method = bithelper::read_uint16_be(&(*(_segments[0]))[VSOMEIP_METHOD_POS_MIN]); + std::chrono::nanoseconds its_debouncing(0), its_retention(0); get_configured_times_from_endpoint(its_service, its_method, &its_debouncing, &its_retention); @@ -545,18 +541,10 @@ void client_endpoint_impl::send_cbk( client_t its_client(0); session_t its_session(0); if (_sent_msg && _sent_msg->size() > VSOMEIP_SESSION_POS_MAX) { - its_service = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_SERVICE_POS_MIN], - (*_sent_msg)[VSOMEIP_SERVICE_POS_MAX]); - its_method = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_METHOD_POS_MIN], - (*_sent_msg)[VSOMEIP_METHOD_POS_MAX]); - its_client = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_CLIENT_POS_MIN], - (*_sent_msg)[VSOMEIP_CLIENT_POS_MAX]); - its_session = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_SESSION_POS_MIN], - (*_sent_msg)[VSOMEIP_SESSION_POS_MAX]); + its_service = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_SERVICE_POS_MIN]); + its_method = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_METHOD_POS_MIN]); + its_client = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_CLIENT_POS_MIN]); + its_session = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_SESSION_POS_MIN]); } VSOMEIP_WARNING << "cei::send_cbk received error: " << _error.message() << " (" << std::dec @@ -609,18 +597,10 @@ void client_endpoint_impl::send_cbk( client_t its_client(0); session_t its_session(0); if (_sent_msg && _sent_msg->size() > VSOMEIP_SESSION_POS_MAX) { - its_service = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_SERVICE_POS_MIN], - (*_sent_msg)[VSOMEIP_SERVICE_POS_MAX]); - its_method = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_METHOD_POS_MIN], - (*_sent_msg)[VSOMEIP_METHOD_POS_MAX]); - its_client = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_CLIENT_POS_MIN], - (*_sent_msg)[VSOMEIP_CLIENT_POS_MAX]); - its_session = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_SESSION_POS_MIN], - (*_sent_msg)[VSOMEIP_SESSION_POS_MAX]); + its_service = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_SERVICE_POS_MIN]); + its_method = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_METHOD_POS_MIN]); + its_client = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_CLIENT_POS_MIN]); + its_session = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_SESSION_POS_MIN]); } VSOMEIP_WARNING << "cei::send_cbk received error: " << _error.message() << " (" << std::dec << _error.value() << ") " @@ -731,13 +711,10 @@ typename endpoint_impl::cms_ret_e client_endpoint_impl::chec if (endpoint_impl::max_message_size_ != MESSAGE_SIZE_UNLIMITED && _size > endpoint_impl::max_message_size_) { if (endpoint_impl::is_supporting_someip_tp_ && _data != nullptr) { - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], - _data[VSOMEIP_SERVICE_POS_MAX]); - const method_t its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + const method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); instance_t its_instance = this->get_instance(its_service); + if (its_instance != ANY_INSTANCE) { if (tp_segmentation_enabled(its_service, its_instance, its_method)) { std::uint16_t its_max_segment_length; @@ -776,14 +753,10 @@ bool client_endpoint_impl::check_queue_limit(const uint8_t *_data, std // [(Command + lowerbyte sender's client ID). // highbyte sender's client ID + lowbyte command size. // lowbyte methodid + highbyte vsomeip length] - its_service = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_SERVICE_POS_MIN], - _data[VSOMEIP_SERVICE_POS_MAX]); - its_method = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); - its_client = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_CLIENT_POS_MIN], - _data[VSOMEIP_CLIENT_POS_MAX]); - its_session = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_SESSION_POS_MIN], - _data[VSOMEIP_SESSION_POS_MAX]); + its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); + its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); + its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); } VSOMEIP_ERROR << "cei::check_queue_limit: queue size limit (" << std::dec << endpoint_impl::queue_limit_ diff --git a/implementation/endpoints/src/endpoint_manager_impl.cpp b/implementation/endpoints/src/endpoint_manager_impl.cpp index d423d4590..2c685f5a1 100644 --- a/implementation/endpoints/src/endpoint_manager_impl.cpp +++ b/implementation/endpoints/src/endpoint_manager_impl.cpp @@ -21,7 +21,7 @@ #include "../../routing/include/routing_manager_impl.hpp" #include "../../routing/include/routing_host.hpp" #include "../../utility/include/utility.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #include @@ -957,8 +957,7 @@ void endpoint_manager_impl::on_error( std::uint16_t _remote_port) { instance_t its_instance = 0; if (_length >= VSOMEIP_SERVICE_POS_MAX) { - service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]); + service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); its_instance = find_instance(its_service, _receiver); } static_cast(rm_)->send_error( diff --git a/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp index 9cd5ef1f9..f5e35f64c 100644 --- a/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp @@ -21,7 +21,7 @@ #include "../../routing/include/routing_host.hpp" #include "../../security/include/policy_manager_impl.hpp" #include "../../security/include/security.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #include "../../utility/include/utility.hpp" namespace vsomeip_v3 { @@ -543,12 +543,7 @@ void local_tcp_server_endpoint_impl::connection::receive_cbk( if (!message_is_empty) { if (its_start + protocol::COMMAND_POSITION_SIZE + 3 < recv_buffer_size_ + its_iteration_gap) { - its_command_size = VSOMEIP_BYTES_TO_LONG( - recv_buffer_[its_start + protocol::COMMAND_POSITION_SIZE+3], - recv_buffer_[its_start + protocol::COMMAND_POSITION_SIZE+2], - recv_buffer_[its_start + protocol::COMMAND_POSITION_SIZE+1], - recv_buffer_[its_start + protocol::COMMAND_POSITION_SIZE]); - + its_command_size = bithelper::read_uint32_le(&recv_buffer_[its_start + protocol::COMMAND_POSITION_SIZE]); its_end = its_start + protocol::COMMAND_POSITION_SIZE + 3 + its_command_size; } else { its_end = its_start; diff --git a/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp b/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp index 6d5fc6f4c..8bf1a5537 100644 --- a/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp @@ -23,7 +23,7 @@ #include "../../protocol/include/assign_client_ack_command.hpp" #include "../../routing/include/routing_host.hpp" #include "../../security/include/policy_manager_impl.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #include "../../utility/include/utility.hpp" namespace vsomeip_v3 { @@ -677,12 +677,7 @@ void local_uds_server_endpoint_impl::connection::receive_cbk( if (!message_is_empty) { if (its_start + protocol::COMMAND_POSITION_SIZE + 3 < recv_buffer_size_ + its_iteration_gap) { - its_command_size = VSOMEIP_BYTES_TO_LONG( - recv_buffer_[its_start + protocol::COMMAND_POSITION_SIZE+3], - recv_buffer_[its_start + protocol::COMMAND_POSITION_SIZE+2], - recv_buffer_[its_start + protocol::COMMAND_POSITION_SIZE+1], - recv_buffer_[its_start + protocol::COMMAND_POSITION_SIZE]); - + its_command_size = bithelper::read_uint32_le(&recv_buffer_[its_start + protocol::COMMAND_POSITION_SIZE]); its_end = its_start + protocol::COMMAND_POSITION_SIZE + 3 + its_command_size; } else { its_end = its_start; diff --git a/implementation/endpoints/src/server_endpoint_impl.cpp b/implementation/endpoints/src/server_endpoint_impl.cpp index c00e2d035..5db9422cb 100644 --- a/implementation/endpoints/src/server_endpoint_impl.cpp +++ b/implementation/endpoints/src/server_endpoint_impl.cpp @@ -25,7 +25,7 @@ #include "../include/server_endpoint_impl.hpp" #include "../include/endpoint_definition.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #include "../../utility/include/utility.hpp" #include "../../service_discovery/include/defines.hpp" @@ -106,9 +106,7 @@ void server_endpoint_impl::prepare_stop( bool found_service_msg(false); for (const auto &t : targets_) { for (const auto &q : t.second.queue_) { - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - (*q.first)[VSOMEIP_SERVICE_POS_MIN], - (*q.first)[VSOMEIP_SERVICE_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&(*q.first)[VSOMEIP_SERVICE_POS_MIN]); if (its_service == _service) { found_service_msg = true; break; @@ -186,12 +184,9 @@ templatebool server_endpoint_impl::send(const uint8 return false; } - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]); - const client_t its_client = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_CLIENT_POS_MIN], _data[VSOMEIP_CLIENT_POS_MAX]); - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SESSION_POS_MIN], _data[VSOMEIP_SESSION_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + const client_t its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); + const session_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); clients_mutex_.lock(); auto found_client = clients_.find(its_client); @@ -205,9 +200,8 @@ templatebool server_endpoint_impl::send(const uint8 VSOMEIP_WARNING << "server_endpoint::send: session_id 0x" << std::hex << its_session << " not found for client 0x" << its_client; - const method_t its_method = - VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); + const method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); + if (its_service == VSOMEIP_SD_SERVICE && its_method == VSOMEIP_SD_METHOD) { VSOMEIP_ERROR << "Clearing clients map as a request was " @@ -254,15 +248,11 @@ bool server_endpoint_impl::send_intern( break; } if (!prepare_stop_handlers_.empty()) { - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); if (prepare_stop_handlers_.find(its_service) != prepare_stop_handlers_.end()) { - const method_t its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], _data[VSOMEIP_METHOD_POS_MAX]); - const client_t its_client = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_CLIENT_POS_MIN], _data[VSOMEIP_CLIENT_POS_MAX]); - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SESSION_POS_MIN], _data[VSOMEIP_SESSION_POS_MAX]); + const method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); + const client_t its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); + const session_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); VSOMEIP_WARNING << "server_endpoint::send: Service is stopping, ignoring message: [" << std::hex << std::setfill('0') << std::setw(4) << its_service << "." @@ -294,10 +284,8 @@ bool server_endpoint_impl::send_intern( cancel_dispatch_timer(its_target_iterator); // STEP 3: Get configured timings - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]); - const method_t its_method = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + const method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); std::chrono::nanoseconds its_debouncing(0), its_retention(0); if (its_service != VSOMEIP_SD_SERVICE && its_method != VSOMEIP_SD_METHOD) { @@ -394,10 +382,8 @@ void server_endpoint_impl::send_segments( auto its_now(std::chrono::steady_clock::now()); - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - (*(_segments[0]))[VSOMEIP_SERVICE_POS_MIN], (*(_segments[0]))[VSOMEIP_SERVICE_POS_MAX]); - const method_t its_method = VSOMEIP_BYTES_TO_WORD( - (*(_segments[0]))[VSOMEIP_METHOD_POS_MIN], (*(_segments[0]))[VSOMEIP_METHOD_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&(*(_segments[0]))[VSOMEIP_SERVICE_POS_MIN]); + const method_t its_method = bithelper::read_uint16_be(&(*(_segments[0]))[VSOMEIP_METHOD_POS_MIN]); std::chrono::nanoseconds its_debouncing(0), its_retention(0); if (its_service != VSOMEIP_SD_SERVICE && its_method != VSOMEIP_SD_METHOD) { @@ -469,13 +455,10 @@ typename endpoint_impl::cms_ret_e server_endpoint_impl::chec if (endpoint_impl::max_message_size_ != MESSAGE_SIZE_UNLIMITED && _size > endpoint_impl::max_message_size_) { if (endpoint_impl::is_supporting_someip_tp_ && _data != nullptr) { - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], - _data[VSOMEIP_SERVICE_POS_MAX]); - const method_t its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + const method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); instance_t its_instance = this->get_instance(its_service); + if (its_instance != ANY_INSTANCE) { if (tp_segmentation_enabled(its_service, its_instance, its_method)) { std::uint16_t its_max_segment_length; @@ -516,14 +499,10 @@ bool server_endpoint_impl::check_queue_limit(const uint8_t *_data, std // [(Command + lowerbyte sender's client ID). // highbyte sender's client ID + lowbyte command size. // lowbyte methodid + highbyte vsomeip length] - its_service = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_SERVICE_POS_MIN], - _data[VSOMEIP_SERVICE_POS_MAX]); - its_method = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); - its_client = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_CLIENT_POS_MIN], - _data[VSOMEIP_CLIENT_POS_MAX]); - its_session = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_SESSION_POS_MIN], - _data[VSOMEIP_SESSION_POS_MAX]); + its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); + its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); + its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); } VSOMEIP_ERROR << "sei::send_intern: queue size limit (" << std::dec << endpoint_impl::queue_limit_ @@ -634,9 +613,7 @@ void server_endpoint_impl::send_cbk( } for (const auto& t : targets_) { for (const auto& e : t.second.queue_ ) { - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - (*e.first)[VSOMEIP_SERVICE_POS_MIN], - (*e.first)[VSOMEIP_SERVICE_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&(*e.first)[VSOMEIP_SERVICE_POS_MIN]); if (its_service == its_stopped_service) { found_service_msg = true; break; @@ -705,18 +682,10 @@ void server_endpoint_impl::send_cbk( session_t& its_session ) { if (buffer && buffer->size() > VSOMEIP_SESSION_POS_MAX) { - its_service = VSOMEIP_BYTES_TO_WORD( - (*buffer)[VSOMEIP_SERVICE_POS_MIN], - (*buffer)[VSOMEIP_SERVICE_POS_MAX]); - its_method = VSOMEIP_BYTES_TO_WORD( - (*buffer)[VSOMEIP_METHOD_POS_MIN], - (*buffer)[VSOMEIP_METHOD_POS_MAX]); - its_client = VSOMEIP_BYTES_TO_WORD( - (*buffer)[VSOMEIP_CLIENT_POS_MIN], - (*buffer)[VSOMEIP_CLIENT_POS_MAX]); - its_session = VSOMEIP_BYTES_TO_WORD( - (*buffer)[VSOMEIP_SESSION_POS_MIN], - (*buffer)[VSOMEIP_SESSION_POS_MAX]); + its_service = bithelper::read_uint16_be(&(*buffer)[VSOMEIP_SERVICE_POS_MIN]); + its_method = bithelper::read_uint16_be(&(*buffer)[VSOMEIP_METHOD_POS_MIN]); + its_client = bithelper::read_uint16_be(&(*buffer)[VSOMEIP_CLIENT_POS_MIN]); + its_session = bithelper::read_uint16_be(&(*buffer)[VSOMEIP_SESSION_POS_MIN]); } }; diff --git a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp index 067203641..496349012 100644 --- a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp @@ -15,7 +15,7 @@ #include "../../routing/include/routing_host.hpp" #include "../include/tcp_client_endpoint_impl.hpp" #include "../../utility/include/utility.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" namespace ip = boost::asio::ip; @@ -102,18 +102,10 @@ void tcp_client_endpoint_impl::restart(bool _force) { { std::lock_guard its_lock(self->mutex_); for (const auto &q : self->queue_) { - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - (*q.first)[VSOMEIP_SERVICE_POS_MIN], - (*q.first)[VSOMEIP_SERVICE_POS_MAX]); - const method_t its_method = VSOMEIP_BYTES_TO_WORD( - (*q.first)[VSOMEIP_METHOD_POS_MIN], - (*q.first)[VSOMEIP_METHOD_POS_MAX]); - const client_t its_client = VSOMEIP_BYTES_TO_WORD( - (*q.first)[VSOMEIP_CLIENT_POS_MIN], - (*q.first)[VSOMEIP_CLIENT_POS_MAX]); - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - (*q.first)[VSOMEIP_SESSION_POS_MIN], - (*q.first)[VSOMEIP_SESSION_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&(*q.first)[VSOMEIP_SERVICE_POS_MIN]); + const method_t its_method = bithelper::read_uint16_be(&(*q.first)[VSOMEIP_METHOD_POS_MIN]); + const client_t its_client = bithelper::read_uint16_be(&(*q.first)[VSOMEIP_CLIENT_POS_MIN]); + const session_t its_session = bithelper::read_uint16_be(&(*q.first)[VSOMEIP_SESSION_POS_MIN]); VSOMEIP_WARNING << "tce::restart: dropping message: " << "remote:" << self->get_address_port_remote() << " (" << std::hex << std::setfill('0') @@ -329,19 +321,10 @@ void tcp_client_endpoint_impl::receive(message_buffer_ptr_t _recv_buffer, } void tcp_client_endpoint_impl::send_queued(std::pair &_entry) { - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - (*_entry.first)[VSOMEIP_SERVICE_POS_MIN], - (*_entry.first)[VSOMEIP_SERVICE_POS_MAX]); - const method_t its_method = VSOMEIP_BYTES_TO_WORD( - (*_entry.first)[VSOMEIP_METHOD_POS_MIN], - (*_entry.first)[VSOMEIP_METHOD_POS_MAX]); - const client_t its_client = VSOMEIP_BYTES_TO_WORD( - (*_entry.first)[VSOMEIP_CLIENT_POS_MIN], - (*_entry.first)[VSOMEIP_CLIENT_POS_MAX]); - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - (*_entry.first)[VSOMEIP_SESSION_POS_MIN], - (*_entry.first)[VSOMEIP_SESSION_POS_MAX]); - + const service_t its_service = bithelper::read_uint16_be(&(*_entry.first)[VSOMEIP_SERVICE_POS_MIN]); + const method_t its_method = bithelper::read_uint16_be(&(*_entry.first)[VSOMEIP_METHOD_POS_MIN]); + const client_t its_client = bithelper::read_uint16_be(&(*_entry.first)[VSOMEIP_CLIENT_POS_MIN]); + const session_t its_session = bithelper::read_uint16_be(&(*_entry.first)[VSOMEIP_SESSION_POS_MIN]); if (has_enabled_magic_cookies_) { const std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); @@ -978,18 +961,10 @@ void tcp_client_endpoint_impl::send_cbk(boost::system::error_code const &_error, client_t its_client(0); session_t its_session(0); if (_sent_msg && _sent_msg->size() > VSOMEIP_SESSION_POS_MAX) { - its_service = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_SERVICE_POS_MIN], - (*_sent_msg)[VSOMEIP_SERVICE_POS_MAX]); - its_method = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_METHOD_POS_MIN], - (*_sent_msg)[VSOMEIP_METHOD_POS_MAX]); - its_client = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_CLIENT_POS_MIN], - (*_sent_msg)[VSOMEIP_CLIENT_POS_MAX]); - its_session = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_SESSION_POS_MIN], - (*_sent_msg)[VSOMEIP_SESSION_POS_MAX]); + its_service = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_SERVICE_POS_MIN]); + its_method = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_METHOD_POS_MIN]); + its_client = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_CLIENT_POS_MIN]); + its_session = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_SESSION_POS_MIN]); } VSOMEIP_WARNING << "tce::send_cbk received error: " << _error.message() << " (" << std::dec diff --git a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp index 499a5846f..38b336e97 100644 --- a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp @@ -16,7 +16,7 @@ #include "../../routing/include/routing_host.hpp" #include "../include/tcp_server_endpoint_impl.hpp" #include "../../utility/include/utility.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" namespace ip = boost::asio::ip; @@ -175,9 +175,7 @@ bool tcp_server_endpoint_impl::send_queued(const target_data_iterator_type _it) for (const auto &its_q : _it->second.queue_) { auto its_buffer(its_q.first); if (its_buffer && its_buffer->size() > VSOMEIP_SESSION_POS_MAX) { - service_t its_service = VSOMEIP_BYTES_TO_WORD( - (*its_buffer)[VSOMEIP_SERVICE_POS_MIN], - (*its_buffer)[VSOMEIP_SERVICE_POS_MAX]); + service_t its_service = bithelper::read_uint16_be(&(*its_buffer)[VSOMEIP_SERVICE_POS_MIN]); its_services.insert(its_service); } } @@ -458,18 +456,10 @@ void tcp_server_endpoint_impl::connection::send_queued( return; } message_buffer_ptr_t its_buffer = _it->second.queue_.front().first; - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - (*its_buffer)[VSOMEIP_SERVICE_POS_MIN], - (*its_buffer)[VSOMEIP_SERVICE_POS_MAX]); - const method_t its_method = VSOMEIP_BYTES_TO_WORD( - (*its_buffer)[VSOMEIP_METHOD_POS_MIN], - (*its_buffer)[VSOMEIP_METHOD_POS_MAX]); - const client_t its_client = VSOMEIP_BYTES_TO_WORD( - (*its_buffer)[VSOMEIP_CLIENT_POS_MIN], - (*its_buffer)[VSOMEIP_CLIENT_POS_MAX]); - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - (*its_buffer)[VSOMEIP_SESSION_POS_MIN], - (*its_buffer)[VSOMEIP_SESSION_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&(*its_buffer)[VSOMEIP_SERVICE_POS_MIN]); + const method_t its_method = bithelper::read_uint16_be(&(*its_buffer)[VSOMEIP_METHOD_POS_MIN]); + const client_t its_client = bithelper::read_uint16_be(&(*its_buffer)[VSOMEIP_CLIENT_POS_MIN]); + const session_t its_session = bithelper::read_uint16_be(&(*its_buffer)[VSOMEIP_SESSION_POS_MIN]); if (magic_cookies_enabled_) { const std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); @@ -594,13 +584,9 @@ void tcp_server_endpoint_impl::connection::receive_cbk( if (utility::is_request( recv_buffer_[its_iteration_gap + VSOMEIP_MESSAGE_TYPE_POS])) { - const client_t its_client = VSOMEIP_BYTES_TO_WORD( - recv_buffer_[its_iteration_gap + VSOMEIP_CLIENT_POS_MIN], - recv_buffer_[its_iteration_gap + VSOMEIP_CLIENT_POS_MAX]); + const client_t its_client = bithelper::read_uint16_be(&recv_buffer_[its_iteration_gap + VSOMEIP_CLIENT_POS_MIN]); if (its_client != MAGIC_COOKIE_CLIENT) { - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - recv_buffer_[its_iteration_gap + VSOMEIP_SESSION_POS_MIN], - recv_buffer_[its_iteration_gap + VSOMEIP_SESSION_POS_MAX]); + const session_t its_session = bithelper::read_uint16_be(&recv_buffer_[its_iteration_gap + VSOMEIP_SESSION_POS_MIN]); its_server->clients_mutex_.lock(); its_server->clients_[its_client][its_session] = remote_; its_server->clients_mutex_.unlock(); diff --git a/implementation/endpoints/src/tp.cpp b/implementation/endpoints/src/tp.cpp index 359995086..b0879aafd 100644 --- a/implementation/endpoints/src/tp.cpp +++ b/implementation/endpoints/src/tp.cpp @@ -8,7 +8,6 @@ #include #include "../include/tp.hpp" -#include "../../utility/include/byteorder.hpp" #ifdef ANDROID #include "../../configuration/include/internal_android.hpp" diff --git a/implementation/endpoints/src/tp_message.cpp b/implementation/endpoints/src/tp_message.cpp index 986976f08..6899ebf60 100644 --- a/implementation/endpoints/src/tp_message.cpp +++ b/implementation/endpoints/src/tp_message.cpp @@ -10,7 +10,7 @@ #include "../include/tp_message.hpp" #include "../include/tp.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #ifdef ANDROID #include "../../configuration/include/internal_android.hpp" @@ -47,11 +47,7 @@ tp_message::tp_message(const byte_t* const _data, std::uint32_t _data_length, const length_t its_segment_size = _data_length - VSOMEIP_FULL_HEADER_SIZE - VSOMEIP_TP_HEADER_SIZE; - const tp_header_t its_tp_header = VSOMEIP_BYTES_TO_LONG( - _data[VSOMEIP_TP_HEADER_POS_MIN], - _data[VSOMEIP_TP_HEADER_POS_MIN + 1], - _data[VSOMEIP_TP_HEADER_POS_MIN + 2], - _data[VSOMEIP_TP_HEADER_POS_MAX]); + const tp_header_t its_tp_header = bithelper::read_uint32_be(&_data[VSOMEIP_TP_HEADER_POS_MIN]); if (check_lengths(_data, _data_length, its_segment_size, tp::more_segments(its_tp_header))) { @@ -82,11 +78,7 @@ bool tp_message::add_segment(const byte_t* const _data, const length_t its_segment_size = _data_length - VSOMEIP_FULL_HEADER_SIZE - VSOMEIP_TP_HEADER_SIZE; - const tp_header_t its_tp_header = VSOMEIP_BYTES_TO_LONG( - _data[VSOMEIP_TP_HEADER_POS_MIN], - _data[VSOMEIP_TP_HEADER_POS_MIN + 1], - _data[VSOMEIP_TP_HEADER_POS_MIN + 2], - _data[VSOMEIP_TP_HEADER_POS_MAX]); + const tp_header_t its_tp_header = bithelper::read_uint32_be(&_data[VSOMEIP_TP_HEADER_POS_MIN]); if (check_lengths(_data, _data_length, its_segment_size, tp::more_segments(its_tp_header))) { @@ -259,14 +251,11 @@ std::chrono::steady_clock::time_point tp_message::get_creation_time() const { std::string tp_message::get_message_id(const byte_t* const _data, std::uint32_t _data_length) { std::stringstream ss; if (_data_length >= VSOMEIP_FULL_HEADER_SIZE) { - const service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]); - const method_t its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], _data[VSOMEIP_METHOD_POS_MAX]); - const client_t its_client = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_CLIENT_POS_MIN], _data[VSOMEIP_CLIENT_POS_MAX]); - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SESSION_POS_MIN], _data[VSOMEIP_SESSION_POS_MAX]); + + const service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + const service_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); + const service_t its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); + const service_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); const interface_version_t its_interface_version = _data[VSOMEIP_INTERFACE_VERSION_POS]; const message_type_e its_msg_type = tp::tp_flag_unset( @@ -282,11 +271,7 @@ std::string tp_message::get_message_id(const byte_t* const _data, std::uint32_t << std::setw(4) << its_session << "] "; if (_data_length > VSOMEIP_TP_HEADER_POS_MAX) { - const tp_header_t its_tp_header = VSOMEIP_BYTES_TO_LONG( - _data[VSOMEIP_TP_HEADER_POS_MIN], - _data[VSOMEIP_TP_HEADER_POS_MIN + 1], - _data[VSOMEIP_TP_HEADER_POS_MIN + 2], - _data[VSOMEIP_TP_HEADER_POS_MAX]); + const tp_header_t its_tp_header = bithelper::read_uint32_be(&_data[VSOMEIP_TP_HEADER_POS_MIN]); const length_t its_offset = tp::get_offset(its_tp_header); ss << " TP offset: 0x" << std::hex << its_offset << " "; } @@ -297,17 +282,11 @@ std::string tp_message::get_message_id(const byte_t* const _data, std::uint32_t bool tp_message::check_lengths(const byte_t* const _data, std::uint32_t _data_length, length_t _segment_size, bool _more_fragments) { - const length_t its_length = VSOMEIP_BYTES_TO_LONG( - _data[VSOMEIP_LENGTH_POS_MIN], - _data[VSOMEIP_LENGTH_POS_MIN + 1], - _data[VSOMEIP_LENGTH_POS_MIN + 2], - _data[VSOMEIP_LENGTH_POS_MAX]); - const tp_header_t its_tp_header = VSOMEIP_BYTES_TO_LONG( - _data[VSOMEIP_TP_HEADER_POS_MIN], - _data[VSOMEIP_TP_HEADER_POS_MIN + 1], - _data[VSOMEIP_TP_HEADER_POS_MIN + 2], - _data[VSOMEIP_TP_HEADER_POS_MAX]); + + const length_t its_length = bithelper::read_uint32_be(&_data[VSOMEIP_LENGTH_POS_MIN]); + const tp_header_t its_tp_header = bithelper::read_uint32_be(&_data[VSOMEIP_TP_HEADER_POS_MIN]); bool ret(true); + if (!tp::tp_flag_is_set(_data[VSOMEIP_MESSAGE_TYPE_POS])) { VSOMEIP_ERROR << __func__ << ": TP flag not set " << get_message_id(_data, _data_length); diff --git a/implementation/endpoints/src/tp_reassembler.cpp b/implementation/endpoints/src/tp_reassembler.cpp index a1d0b45ae..42ad97b88 100644 --- a/implementation/endpoints/src/tp_reassembler.cpp +++ b/implementation/endpoints/src/tp_reassembler.cpp @@ -12,7 +12,7 @@ #include #include "../include/tp.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #ifdef ANDROID #include "../../configuration/include/internal_android.hpp" @@ -39,14 +39,10 @@ std::pair tp_reassembler::process_tp_message( cleanup_timer_start(false); - const service_t its_service = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_SERVICE_POS_MIN], - _data[VSOMEIP_SERVICE_POS_MAX]); - const method_t its_method = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); - const client_t its_client = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_CLIENT_POS_MIN], - _data[VSOMEIP_CLIENT_POS_MAX]); - const session_t its_session = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_SESSION_POS_MIN], - _data[VSOMEIP_SESSION_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + const method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); + const client_t its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); + const session_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); const interface_version_t its_interface_version = _data[VSOMEIP_INTERFACE_VERSION_POS]; const message_type_e its_msg_type = tp::tp_flag_unset(_data[VSOMEIP_MESSAGE_TYPE_POS]); diff --git a/implementation/endpoints/src/udp_client_endpoint_impl.cpp b/implementation/endpoints/src/udp_client_endpoint_impl.cpp index 949c33362..6c3c6c00b 100644 --- a/implementation/endpoints/src/udp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_client_endpoint_impl.cpp @@ -15,7 +15,7 @@ #include "../../routing/include/routing_host.hpp" #include "../include/udp_client_endpoint_impl.hpp" #include "../../utility/include/utility.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" namespace vsomeip_v3 { @@ -560,18 +560,10 @@ void udp_client_endpoint_impl::send_cbk(boost::system::error_code const &_error, client_t its_client(0); session_t its_session(0); if (_sent_msg && _sent_msg->size() > VSOMEIP_SESSION_POS_MAX) { - its_service = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_SERVICE_POS_MIN], - (*_sent_msg)[VSOMEIP_SERVICE_POS_MAX]); - its_method = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_METHOD_POS_MIN], - (*_sent_msg)[VSOMEIP_METHOD_POS_MAX]); - its_client = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_CLIENT_POS_MIN], - (*_sent_msg)[VSOMEIP_CLIENT_POS_MAX]); - its_session = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_SESSION_POS_MIN], - (*_sent_msg)[VSOMEIP_SESSION_POS_MAX]); + its_service = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_SERVICE_POS_MIN]); + its_method = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_METHOD_POS_MIN]); + its_client = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_CLIENT_POS_MIN]); + its_session = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_SESSION_POS_MIN]); } VSOMEIP_WARNING << "uce::send_cbk received error: " << _error.message() << " (" << std::dec @@ -636,18 +628,10 @@ void udp_client_endpoint_impl::send_cbk(boost::system::error_code const &_error, client_t its_client(0); session_t its_session(0); if (_sent_msg && _sent_msg->size() > VSOMEIP_SESSION_POS_MAX) { - its_service = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_SERVICE_POS_MIN], - (*_sent_msg)[VSOMEIP_SERVICE_POS_MAX]); - its_method = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_METHOD_POS_MIN], - (*_sent_msg)[VSOMEIP_METHOD_POS_MAX]); - its_client = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_CLIENT_POS_MIN], - (*_sent_msg)[VSOMEIP_CLIENT_POS_MAX]); - its_session = VSOMEIP_BYTES_TO_WORD( - (*_sent_msg)[VSOMEIP_SESSION_POS_MIN], - (*_sent_msg)[VSOMEIP_SESSION_POS_MAX]); + its_service = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_SERVICE_POS_MIN]); + its_method = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_METHOD_POS_MIN]); + its_client = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_CLIENT_POS_MIN]); + its_session = bithelper::read_uint16_be(&(*_sent_msg)[VSOMEIP_SESSION_POS_MIN]); } VSOMEIP_WARNING << "uce::send_cbk received error: " << _error.message() << " (" << std::dec << _error.value() << ") " diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp index 02a856a32..1cc3f562a 100644 --- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp @@ -24,7 +24,7 @@ #include "../../configuration/include/configuration.hpp" #include "../../routing/include/routing_host.hpp" #include "../../service_discovery/include/defines.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #include "../../utility/include/utility.hpp" namespace ip = boost::asio::ip; @@ -631,26 +631,22 @@ void udp_server_endpoint_impl::on_message_received( return; } remaining_bytes -= current_message_size; - const service_t its_service = VSOMEIP_BYTES_TO_WORD(_buffer[i + VSOMEIP_SERVICE_POS_MIN], - _buffer[i + VSOMEIP_SERVICE_POS_MAX]); + const service_t its_service = bithelper::read_uint16_be(&_buffer[i + VSOMEIP_SERVICE_POS_MIN]); + if (utility::is_request( _buffer[i + VSOMEIP_MESSAGE_TYPE_POS])) { - const client_t its_client = VSOMEIP_BYTES_TO_WORD( - _buffer[i + VSOMEIP_CLIENT_POS_MIN], - _buffer[i + VSOMEIP_CLIENT_POS_MAX]); + const client_t its_client = bithelper::read_uint16_be(&_buffer[i + VSOMEIP_CLIENT_POS_MIN]); if (its_client != MAGIC_COOKIE_CLIENT) { - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - _buffer[i + VSOMEIP_SESSION_POS_MIN], - _buffer[i + VSOMEIP_SESSION_POS_MAX]); + const session_t its_session = bithelper::read_uint16_be(&_buffer[i + VSOMEIP_SESSION_POS_MIN]); clients_mutex_.lock(); clients_[its_client][its_session] = _remote; clients_mutex_.unlock(); } } if (tp::tp::tp_flag_is_set(_buffer[i + VSOMEIP_MESSAGE_TYPE_POS])) { - const method_t its_method = VSOMEIP_BYTES_TO_WORD(_buffer[i + VSOMEIP_METHOD_POS_MIN], - _buffer[i + VSOMEIP_METHOD_POS_MAX]); + const method_t its_method = bithelper::read_uint16_be(&_buffer[i + VSOMEIP_METHOD_POS_MIN]); instance_t its_instance = this->get_instance(its_service); + if (its_instance != ANY_INSTANCE) { if (!tp_segmentation_enabled(its_service, its_instance, its_method)) { VSOMEIP_WARNING << "use: Received a SomeIP/TP message for service: 0x" << std::hex << its_service @@ -665,13 +661,9 @@ void udp_server_endpoint_impl::on_message_received( its_remote_address, its_remote_port); if (res.first) { if (utility::is_request(res.second[VSOMEIP_MESSAGE_TYPE_POS])) { - const client_t its_client = VSOMEIP_BYTES_TO_WORD( - res.second[VSOMEIP_CLIENT_POS_MIN], - res.second[VSOMEIP_CLIENT_POS_MAX]); + const client_t its_client = bithelper::read_uint16_be(&res.second[VSOMEIP_CLIENT_POS_MIN]); if (its_client != MAGIC_COOKIE_CLIENT) { - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - res.second[VSOMEIP_SESSION_POS_MIN], - res.second[VSOMEIP_SESSION_POS_MAX]); + const session_t its_session = bithelper::read_uint16_be(&res.second[VSOMEIP_SESSION_POS_MIN]); std::lock_guard its_client_lock(clients_mutex_); clients_[its_client][its_session] = _remote; } @@ -704,8 +696,7 @@ void udp_server_endpoint_impl::on_message_received( << " local: " << get_address_port_local() << " remote: " << its_remote_address << ":" << std::dec << its_remote_port; if (remaining_bytes > VSOMEIP_SERVICE_POS_MAX) { - service_t its_service = VSOMEIP_BYTES_TO_WORD(_buffer[VSOMEIP_SERVICE_POS_MIN], - _buffer[VSOMEIP_SERVICE_POS_MAX]); + service_t its_service = bithelper::read_uint16_be(&_buffer[VSOMEIP_SERVICE_POS_MIN]); if (its_service != VSOMEIP_SD_SERVICE) { if (read_message_size == 0) { VSOMEIP_ERROR << "Ignoring unreliable vSomeIP message with SomeIP message length 0!"; diff --git a/implementation/message/src/deserializer.cpp b/implementation/message/src/deserializer.cpp index bfa723d34..746b83630 100644 --- a/implementation/message/src/deserializer.cpp +++ b/implementation/message/src/deserializer.cpp @@ -13,7 +13,7 @@ #include "../include/message_impl.hpp" #include "../include/deserializer.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" namespace vsomeip_v3 { @@ -75,7 +75,8 @@ bool deserializer::deserialize(uint16_t& _value) { byte1 = *position_++; remaining_ -= 2; - _value = VSOMEIP_BYTES_TO_WORD(byte0, byte1); + uint8_t payload[2] = {byte0, byte1}; + _value = bithelper::read_uint16_be(payload); return true; } @@ -94,8 +95,8 @@ bool deserializer::deserialize(uint32_t &_value, bool _omit_last_byte) { byte3 = *position_++; remaining_ -= 3; - _value = VSOMEIP_BYTES_TO_LONG( - byte0, byte1, byte2, byte3); + uint8_t payload[4] = {byte0, byte1, byte2, byte3}; + _value = bithelper::read_uint32_be(payload); return true; } @@ -149,7 +150,7 @@ bool deserializer::look_ahead(std::size_t _index, uint16_t &_value) const { std::vector< uint8_t >::iterator i = position_ + static_cast::difference_type>(_index); - _value = VSOMEIP_BYTES_TO_WORD(*i, *(i+1)); + _value = bithelper::read_uint16_be(&(*i)); return true; } @@ -159,7 +160,7 @@ bool deserializer::look_ahead(std::size_t _index, uint32_t &_value) const { return false; std::vector< uint8_t >::const_iterator i = position_ + static_cast::difference_type>(_index); - _value = VSOMEIP_BYTES_TO_LONG(*i, *(i+1), *(i+2), *(i+3)); + _value = bithelper::read_uint32_be(&(*i)); return true; } diff --git a/implementation/message/src/message_base_impl.cpp b/implementation/message/src/message_base_impl.cpp index c1d7da7dd..c64a56f92 100644 --- a/implementation/message/src/message_base_impl.cpp +++ b/implementation/message/src/message_base_impl.cpp @@ -4,7 +4,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include "../include/message_impl.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" namespace vsomeip_v3 { @@ -19,12 +19,16 @@ message_base_impl::~message_base_impl() { // header interface message_t message_base_impl::get_message() const { - return VSOMEIP_WORDS_TO_LONG(header_.service_, header_.method_); + const uint8_t header_message[] = {static_cast((header_.service_ & 0xFF00) >> 8), + static_cast( header_.service_ & 0x00FF), + static_cast((header_.method_ & 0xFF00) >> 8), + static_cast( header_.method_ & 0x00FF)}; + return bithelper::read_uint32_be(header_message); } void message_base_impl::set_message(message_t _message) { - header_.service_ = VSOMEIP_LONG_WORD0(_message); - header_.method_ = VSOMEIP_LONG_WORD1(_message); + header_.service_ = bithelper::read_high_word(_message); + header_.method_ = bithelper::read_low_word(_message); } service_t message_base_impl::get_service() const { @@ -52,7 +56,11 @@ void message_base_impl::set_method(method_t _method) { } request_t message_base_impl::get_request() const { - return VSOMEIP_WORDS_TO_LONG(header_.client_, header_.session_); + const uint8_t header_message[] = {static_cast((header_.client_ & 0xFF00) >> 8), + static_cast( header_.client_ & 0x00FF), + static_cast((header_.session_ & 0xFF00) >> 8), + static_cast( header_.session_ & 0x00FF)}; + return bithelper::read_uint32_be(header_message); } client_t message_base_impl::get_client() const { diff --git a/implementation/message/src/message_impl.cpp b/implementation/message/src/message_impl.cpp index 47250c137..09db29722 100644 --- a/implementation/message/src/message_impl.cpp +++ b/implementation/message/src/message_impl.cpp @@ -13,7 +13,6 @@ #else #include "../../configuration/include/internal.hpp" #endif -#include "../../utility/include/byteorder.hpp" namespace vsomeip_v3 { diff --git a/implementation/message/src/serializer.cpp b/implementation/message/src/serializer.cpp index 2bdad8ff8..9f6f03427 100644 --- a/implementation/message/src/serializer.cpp +++ b/implementation/message/src/serializer.cpp @@ -13,7 +13,7 @@ #include #include "../include/serializer.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #include namespace vsomeip_v3 { @@ -37,18 +37,23 @@ bool serializer::serialize(const uint8_t _value) { } bool serializer::serialize(const uint16_t _value) { - data_.push_back(VSOMEIP_WORD_BYTE1(_value)); - data_.push_back(VSOMEIP_WORD_BYTE0(_value)); + uint8_t nvalue[2] = {0}; + bithelper::write_uint16_le(_value, nvalue); + data_.push_back(nvalue[1]); + data_.push_back(nvalue[0]); return true; } bool serializer::serialize(const uint32_t _value, bool _omit_last_byte) { + uint8_t nvalue[4] = {0}; + bithelper::write_uint32_le(_value, nvalue); + if (!_omit_last_byte) { - data_.push_back(VSOMEIP_LONG_BYTE3(_value)); + data_.push_back(nvalue[3]); } - data_.push_back(VSOMEIP_LONG_BYTE2(_value)); - data_.push_back(VSOMEIP_LONG_BYTE1(_value)); - data_.push_back(VSOMEIP_LONG_BYTE0(_value)); + data_.push_back(nvalue[2]); + data_.push_back(nvalue[1]); + data_.push_back(nvalue[0]); return true; } diff --git a/implementation/routing/src/routing_manager_base.cpp b/implementation/routing/src/routing_manager_base.cpp index ec87855e2..bfafe4eda 100644 --- a/implementation/routing/src/routing_manager_base.cpp +++ b/implementation/routing/src/routing_manager_base.cpp @@ -16,7 +16,7 @@ #ifdef USE_DLT #include "../../tracing/include/connector_impl.hpp" #endif -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #include "../../utility/include/utility.hpp" namespace vsomeip_v3 { @@ -1312,10 +1312,8 @@ bool routing_manager_base::send_local_notification(client_t _client, bool has_local(false); #endif bool has_remote(false); - method_t its_method = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); - service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]); + service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); std::shared_ptr its_event = find_event(its_service, _instance, its_method); if (its_event && !its_event->is_shadow()) { diff --git a/implementation/routing/src/routing_manager_client.cpp b/implementation/routing/src/routing_manager_client.cpp index 9a98499f1..07e0bd3da 100644 --- a/implementation/routing/src/routing_manager_client.cpp +++ b/implementation/routing/src/routing_manager_client.cpp @@ -62,7 +62,7 @@ #include "../../security/include/policy.hpp" #include "../../security/include/policy_manager_impl.hpp" #include "../../security/include/security.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #include "../../utility/include/utility.hpp" #ifdef USE_DLT #include "../../tracing/include/connector_impl.hpp" @@ -168,7 +168,8 @@ void routing_manager_client::stop() { while (state_ == inner_state_type_e::ST_REGISTERING) { std::cv_status status = state_condition_.wait_for(its_lock, its_timeout); if (status == std::cv_status::timeout) { - VSOMEIP_WARNING << std::hex << get_client() << " registering timeout on stop"; + VSOMEIP_WARNING << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " registering timeout on stop"; break; } } @@ -179,7 +180,8 @@ void routing_manager_client::stop() { while (state_ == inner_state_type_e::ST_REGISTERED) { std::cv_status status = state_condition_.wait_for(its_lock, its_timeout); if (status == std::cv_status::timeout) { - VSOMEIP_WARNING << std::hex << get_client() << " couldn't deregister application - timeout"; + VSOMEIP_WARNING << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " couldn't deregister application - timeout"; break; } } @@ -220,7 +222,7 @@ void routing_manager_client::stop() { if (configuration_->is_local_routing()) { std::stringstream its_client; its_client << utility::get_base_path(configuration_->get_network()) - << std::hex << get_client(); + << std::hex << std::setw(4) << std::setfill('0') << get_client(); #ifdef _WIN32 ::_unlink(its_client.str().c_str()); #else @@ -832,21 +834,13 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, } if (client_side_logging_) { if (_size > VSOMEIP_MESSAGE_TYPE_POS) { - service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], - _data[VSOMEIP_SERVICE_POS_MAX]); + service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); if (client_side_logging_filter_.empty() || (1 == client_side_logging_filter_.count(std::make_tuple(its_service, ANY_INSTANCE))) || (1 == client_side_logging_filter_.count(std::make_tuple(its_service, _instance)))) { - method_t its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); - session_t its_session = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SESSION_POS_MIN], - _data[VSOMEIP_SESSION_POS_MAX]); - client_t its_client = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_CLIENT_POS_MIN], - _data[VSOMEIP_CLIENT_POS_MAX]); + method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); + session_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); + client_t its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); VSOMEIP_INFO << "routing_manager_client::send: (" << std::hex << std::setfill('0') << std::setw(4) << get_client() << "): [" @@ -868,9 +862,7 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, std::shared_ptr its_target; if (utility::is_request(_data[VSOMEIP_MESSAGE_TYPE_POS])) { // Request - service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], - _data[VSOMEIP_SERVICE_POS_MAX]); + service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); client_t its_client = find_local_client(its_service, _instance); if (its_client != VSOMEIP_ROUTING_CLIENT) { if (is_client_known(its_client)) { @@ -879,9 +871,7 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, } } else if (!utility::is_notification(_data[VSOMEIP_MESSAGE_TYPE_POS])) { // Response - client_t its_client = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_CLIENT_POS_MIN], - _data[VSOMEIP_CLIENT_POS_MAX]); + client_t its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); if (its_client != VSOMEIP_ROUTING_CLIENT) { if (is_client_known(its_client)) { its_target = ep_mgr_->find_or_create_local(its_client); @@ -997,9 +987,9 @@ void routing_manager_client::on_disconnect(const std::shared_ptr& _end is_connected_ = !(_endpoint == sender_); } if (!is_connected_) { - VSOMEIP_INFO << "routing_manager_client::on_disconnect: Client 0x" << std::hex - << get_client() << " calling host_->on_state " - << "with DEREGISTERED"; + VSOMEIP_INFO << "routing_manager_client::on_disconnect: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " calling host_->on_state with DEREGISTERED"; host_->on_state(state_type_e::ST_DEREGISTERED); } } @@ -1069,12 +1059,11 @@ void routing_manager_client::on_message( if (configuration_->is_security_enabled() && configuration_->is_local_routing() && !is_from_routing && _bound_client != its_client) { - VSOMEIP_WARNING << std::hex << std::setfill('0') - << "Client " << std::setw(4) << get_client() - << " received a message with command " << int(its_id) - << " from " << std::setw(4) << its_client + VSOMEIP_WARNING << "Client " << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " received a message with command " << int(its_id) << " from " + << std::hex << std::setw(4) << std::setfill('0') << its_client << " which doesn't match the bound client " - << std::setw(4) << _bound_client + << std::hex << std::setw(4) << std::setfill('0') << _bound_client << " ~> skip message!"; return; } @@ -1104,25 +1093,27 @@ void routing_manager_client::on_message( if (utility::is_notification(its_message->get_message_type())) { if (!is_response_allowed(_bound_client, its_message->get_service(), its_message->get_instance(), its_message->get_method())) { - VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() - << " : routing_manager_client::on_message: " - << " received a notification from client 0x" << _bound_client - << " which does not offer service/instance/event " - << its_message->get_service() << "/" << its_message->get_instance() - << "/" << its_message->get_method() - << " ~> Skip message!"; + VSOMEIP_WARNING << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::on_message: " + << " received a notification from client 0x" << _bound_client + << " which does not offer service/instance/event " + << its_message->get_service() << "/" << its_message->get_instance() + << "/" << its_message->get_method() + << " ~> Skip message!"; return; } else { if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member(get_sec_client(), its_message->get_service(), its_message->get_instance(), its_message->get_method())) { - VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() - << " : routing_manager_client::on_message: " - << " isn't allowed to receive a notification from service/instance/event " - << its_message->get_service() << "/" << its_message->get_instance() - << "/" << its_message->get_method() - << " respectively from client 0x" << _bound_client - << " ~> Skip message!"; + VSOMEIP_WARNING << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::on_message: " + << " isn't allowed to receive a notification from service/instance/event " + << its_message->get_service() << "/" << its_message->get_instance() + << "/" << its_message->get_method() + << " respectively from client 0x" << _bound_client + << " ~> Skip message!"; return; } cache_event_payload(its_message); @@ -1131,49 +1122,53 @@ void routing_manager_client::on_message( if (configuration_->is_security_enabled() && configuration_->is_local_routing() && its_message->get_client() != _bound_client) { - VSOMEIP_WARNING << std::hex << std::setfill('0') - << "vSomeIP Security: Client 0x" << std::setw(4) << get_client() - << " received a request from client 0x" << std::setw(4) << its_message->get_client() - << " to service/instance/method " - << its_message->get_service() << "/" << its_message->get_instance() - << "/" << its_message->get_method() - << " which doesn't match the bound client 0x" << std::setw(4) << _bound_client - << " ~> skip message!"; + VSOMEIP_WARNING << std::hex << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " received a request from client 0x" + << std::hex << std::setw(4) << std::setfill('0') << its_message->get_client() + << " to service/instance/method " << its_message->get_service() + << "/" << its_message->get_instance() << "/" << its_message->get_method() + << " which doesn't match the bound client 0x" + << std::hex << std::setw(4) << std::setfill('0') << _bound_client + << " ~> skip message!"; return; } if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member(_sec_client, its_message->get_service(), its_message->get_instance(), its_message->get_method())) { - VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << its_message->get_client() - << " : routing_manager_client::on_message: " - << "isn't allowed to send a request to service/instance/method " - << its_message->get_service() << "/" << its_message->get_instance() - << "/" << its_message->get_method() - << " ~> Skip message!"; + VSOMEIP_WARNING << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << its_message->get_client() + << " : routing_manager_client::on_message: " + << "isn't allowed to send a request to service/instance/method " + << its_message->get_service() << "/" << its_message->get_instance() + << "/" << its_message->get_method() + << " ~> Skip message!"; return; } } else { // response if (!is_response_allowed(_bound_client, its_message->get_service(), its_message->get_instance(), its_message->get_method())) { - VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() - << " : routing_manager_client::on_message: " - << " received a response from client 0x" << _bound_client - << " which does not offer service/instance/method " - << its_message->get_service() << "/" << its_message->get_instance() - << "/" << its_message->get_method() - << " ~> Skip message!"; + VSOMEIP_WARNING << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::on_message: " + << " received a response from client 0x" << _bound_client + << " which does not offer service/instance/method " + << its_message->get_service() << "/" << its_message->get_instance() + << "/" << its_message->get_method() + << " ~> Skip message!"; return; } else { if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member(get_sec_client(), its_message->get_service(), its_message->get_instance(), its_message->get_method())) { - VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() - << " : routing_manager_client::on_message: " - << " isn't allowed to receive a response from service/instance/method " - << its_message->get_service() << "/" << its_message->get_instance() - << "/" << its_message->get_method() - << " respectively from client 0x" << _bound_client - << " ~> Skip message!"; + VSOMEIP_WARNING << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::on_message: " + << " isn't allowed to receive a response from service/instance/method " + << its_message->get_service() << "/" << its_message->get_instance() + << "/" << its_message->get_method() + << " respectively from client 0x" << _bound_client + << " ~> Skip message!"; return; } } @@ -1182,14 +1177,15 @@ void routing_manager_client::on_message( if (!configuration_->is_remote_access_allowed()) { // if the message is from routing manager, check if // policy allows remote requests. - VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() - << " : routing_manager_client::on_message: " - << std::hex << "Security: Remote clients via routing manager with client ID 0x" << its_client - << " are not allowed to communicate with service/instance/method " - << its_message->get_service() << "/" << its_message->get_instance() - << "/" << its_message->get_method() - << " respectively with client 0x" << get_client() - << " ~> Skip message!"; + VSOMEIP_WARNING << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::on_message: " + << std::hex << "Security: Remote clients via routing manager with client ID 0x" << its_client + << " are not allowed to communicate with service/instance/method " + << its_message->get_service() << "/" << its_message->get_instance() + << "/" << its_message->get_method() + << " respectively with client 0x" << get_client() + << " ~> Skip message!"; return; } else if (utility::is_notification(its_message->get_message_type())) { // As subscription is sent on eventgroup level, incoming remote event ID's @@ -1199,13 +1195,13 @@ void routing_manager_client::on_message( its_message->get_service(), its_message->get_instance(), its_message->get_method())) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() - << " : routing_manager_client::on_message: " - << " isn't allowed to receive a notification from service/instance/event " - << its_message->get_service() << "/" << its_message->get_instance() - << "/" << its_message->get_method() - << " respectively from remote clients via routing manager with client ID 0x" - << routing_host_id - << " ~> Skip message!"; + << " : routing_manager_client::on_message: " + << " isn't allowed to receive a notification from service/instance/event " + << its_message->get_service() << "/" << its_message->get_instance() + << "/" << its_message->get_method() + << " respectively from remote clients via routing manager with client ID 0x" + << routing_host_id + << " ~> Skip message!"; return; } cache_event_payload(its_message); @@ -1258,7 +1254,8 @@ void routing_manager_client::on_message( on_routing_info(_data, _size); } else { VSOMEIP_WARNING << "routing_manager_client::on_message: " - << std::hex << "Security: Client 0x" << get_client() + << "Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0')<< get_client() << " received an routing info from a client which isn't the routing manager" << " : Skip message!"; } @@ -1662,10 +1659,11 @@ void routing_manager_client::on_message( VSOMEIP_ERROR << "vSomeIP Security: Policy deserialization failed!"; } } else { - VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() - << " : routing_manager_client::on_message: " - << " received a security policy update from a client which isn't the routing manager" - << " : Skip message!"; + VSOMEIP_WARNING << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::on_message: " + << " received a security policy update from a client which isn't the routing manager" + << " : Skip message!"; } break; } @@ -1690,10 +1688,11 @@ void routing_manager_client::on_message( << static_cast(its_error) << ")"; } else - VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() - << " : routing_manager_client::on_message: " - << "received a security policy removal from a client which isn't the routing manager" - << " : Skip message!"; + VSOMEIP_WARNING << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::on_message: " + << "received a security policy removal from a client which isn't the routing manager" + << " : Skip message!"; break; } @@ -1716,10 +1715,11 @@ void routing_manager_client::on_message( << static_cast(its_error) << ")"; } else - VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() - << " : routing_manager_client::on_message: " - << " received a security policy distribution command from a client which isn't the routing manager" - << " : Skip message!"; + VSOMEIP_WARNING << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::on_message: " + << " received a security policy distribution command from a client which isn't the routing manager" + << " : Skip message!"; break; } @@ -1736,10 +1736,11 @@ void routing_manager_client::on_message( << static_cast(its_error) << ")"; } else - VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() - << " : routing_manager_client::on_message: " - << "received a security credential update from a client which isn't the routing manager" - << " : Skip message!"; + VSOMEIP_WARNING << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::on_message: " + << "received a security credential update from a client which isn't the routing manager" + << " : Skip message!"; break; } @@ -1758,7 +1759,7 @@ void routing_manager_client::on_routing_info( const byte_t *_data, uint32_t _size) { #if 0 std::stringstream msg; - msg << "rmp::on_routing_info(" << std::hex << get_client() << "): "; + msg << "rmp::on_routing_info(" << std::hex << std::setw(4) << std::setfill('0') << get_client() << "): "; for (uint32_t i = 0; i < _size; ++i) msg << std::hex << std::setw(2) << std::setfill('0') << (int)_data[i] << " "; VSOMEIP_INFO << msg.str(); @@ -1792,13 +1793,15 @@ void routing_manager_client::on_routing_info( } if (its_client == get_client()) { - VSOMEIP_INFO << std::hex << "Application/Client " << get_client() - << " (" << host_->get_name() << ") is registered."; + VSOMEIP_INFO << "Application/Client " + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " (" << host_->get_name() << ") is registered."; #if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (!its_security->check_credentials(get_client(), get_sec_client())) { - VSOMEIP_ERROR << "vSomeIP Security: Client 0x" << std::hex << get_client() - << " : routing_manager_client::on_routing_info: RIE_ADD_CLIENT: isn't allowed" - << " to use the server endpoint due to credential check failed!"; + VSOMEIP_ERROR << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::on_routing_info: RIE_ADD_CLIENT: isn't allowed" + << " to use the server endpoint due to credential check failed!"; deregister_application(); host_->on_state(static_cast(inner_state_type_e::ST_DEREGISTERED)); return; @@ -1833,8 +1836,9 @@ void routing_manager_client::on_routing_info( } if (its_client == get_client()) { its_security->remove_client_to_sec_client_mapping(its_client); - VSOMEIP_INFO << std::hex << "Application/Client " << get_client() - << " (" << host_->get_name() << ") is deregistered."; + VSOMEIP_INFO << "Application/Client " + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " (" << host_->get_name() << ") is deregistered."; // inform host about its own registration state changes host_->on_state(static_cast(inner_state_type_e::ST_DEREGISTERED)); @@ -2052,14 +2056,16 @@ void routing_manager_client::reconnect(const std::map &_c } } - VSOMEIP_INFO << std::hex << "Application/Client " << get_client() - << ": Reconnecting to routing manager."; + VSOMEIP_INFO << std::hex << "Application/Client " + << std::hex << std::setw(4) << std::setfill('0') << get_client() + <<": Reconnecting to routing manager."; #if defined(__linux__) || defined(ANDROID) || defined(__QNX__) if (!its_security->check_credentials(get_client(), get_sec_client())) { - VSOMEIP_ERROR << "vSomeIP Security: Client 0x" << std::hex << get_client() - << " : routing_manager_client::reconnect: isn't allowed" - << " to use the server endpoint due to credential check failed!"; + VSOMEIP_ERROR << "vSomeIP Security: Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::reconnect: isn't allowed" + << " to use the server endpoint due to credential check failed!"; std::lock_guard its_lock(sender_mutex_); if (sender_) { sender_->stop(); @@ -2076,7 +2082,9 @@ void routing_manager_client::reconnect(const std::map &_c void routing_manager_client::assign_client() { - VSOMEIP_INFO << __func__ << ": (" << std::hex << get_client() << ":" << host_->get_name() << ")"; + VSOMEIP_INFO << __func__ << ": (" << std::hex << std::setw(4) << std::setfill('0') + << get_client() << ":" << host_->get_name() << ")"; + protocol::assign_client_command its_command; its_command.set_client(get_client()); its_command.set_name(host_->get_name()); @@ -2097,7 +2105,8 @@ void routing_manager_client::assign_client() { std::lock_guard its_lock(sender_mutex_); if (sender_) { if (state_ != inner_state_type_e::ST_DEREGISTERED) { - VSOMEIP_WARNING << __func__ << ": (" << std::hex << get_client() << ") Non-Deregistered State Set. Returning"; + VSOMEIP_WARNING << __func__ << ": (" << std::hex << std::setw(4) << std::setfill('0') + << get_client() << ") Non-Deregistered State Set. Returning"; return; } state_ = inner_state_type_e::ST_ASSIGNING; @@ -2113,11 +2122,13 @@ void routing_manager_client::assign_client() { std::dynamic_pointer_cast(shared_from_this()), std::placeholders::_1)); } else { - VSOMEIP_WARNING << __func__ << ": (" << std::hex << get_client() << ") sender not initialized. Ignoring client assignment"; + VSOMEIP_WARNING << __func__ << ": (" << std::hex << std::setw(4) << std::setfill('0') + << get_client() << ") sender not initialized. Ignoring client assignment"; } } else { - VSOMEIP_WARNING << __func__ << ": (" << std::hex << get_client() << ") not connected. Ignoring client assignment"; + VSOMEIP_WARNING << __func__ << ": (" << std::hex << std::setw(4) << std::setfill('0') + << get_client() << ") not connected. Ignoring client assignment"; } } @@ -2341,12 +2352,12 @@ void routing_manager_client::on_subscribe_ack(client_t _client, (void)_client; #if 0 VSOMEIP_ERROR << "routing_manager_client::" << __func__ - << "(" << std::hex << host_->get_client() << "):" + << "(" << std::hex << std::setw(4) << std::setfill('0') << host_->get_client() << "):" << "event=" - << std::hex << _service << "." - << std::hex << _instance << "." - << std::hex << _eventgroup << "." - << std::hex << _event; + << std::hex << std::setw(4) << std::setfill('0') << _service << "." + << std::hex << std::setw(4) << std::setfill('0') << _instance << "." + << std::hex << std::setw(4) << std::setfill('0') << _eventgroup << "." + << std::hex << std::setw(4) << std::setfill('0') << _event; #endif if (_event == ANY_EVENT) { auto its_eventgroup = find_eventgroup(_service, _instance, _eventgroup); @@ -2555,20 +2566,26 @@ routing_manager_client::assign_client_timeout_cbk( if (state_ != inner_state_type_e::ST_REGISTERED) { state_ = inner_state_type_e::ST_DEREGISTERED; register_again = true; + } else { + VSOMEIP_INFO << __func__ << ": Will not retry registry for Client [0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << "] : already registered "; } } if (register_again) { std::lock_guard its_lock(sender_mutex_); - VSOMEIP_WARNING << std::hex << "Client 0x" << get_client() - << " request client timeout! Trying again..."; + VSOMEIP_WARNING << "Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " request client timeout! Trying again..."; if (sender_) { sender_->restart(); } } - } else { - VSOMEIP_WARNING << __func__ << ": Ignoring Client 0x" << std::hex << get_client() - << " due to error_code: " << _error.value() ; + } else if (_error != boost::asio::error::operation_aborted) { //ignore error when timer is deliberately cancelled + VSOMEIP_WARNING << __func__ << ": Ignoring Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " due to error_code: " << _error.value() ; } } @@ -2585,8 +2602,9 @@ void routing_manager_client::register_application_timeout_cbk( } if (register_again) { std::lock_guard its_lock(sender_mutex_); - VSOMEIP_WARNING << std::hex << "Client 0x" << get_client() - << " register timeout! Trying again..."; + VSOMEIP_WARNING << std::hex << "Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " register timeout! Trying again..."; if (sender_) sender_->restart(); @@ -2694,8 +2712,10 @@ void routing_manager_client::register_client_error_handler(client_t _client, void routing_manager_client::handle_client_error(client_t _client) { if (_client != VSOMEIP_ROUTING_CLIENT) { - VSOMEIP_INFO << "Client 0x" << std::hex << get_client() - << " handles a client error(" << std::hex << _client << ")"; + VSOMEIP_INFO << "Client 0x" + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " handles a client error(" + << std::hex << std::setw(4) << std::setfill('0') << _client << ")"; remove_local(_client, true); } else { bool should_reconnect(true); @@ -2879,13 +2899,14 @@ void routing_manager_client::on_client_assign_ack(const client_t &_client) { if (receiver_) { receiver_->start(); - VSOMEIP_INFO << std::hex << "Client " << get_client() - << " (" << host_->get_name() - << ") successfully connected to routing ~> registering.."; + VSOMEIP_INFO << "Client " + << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " (" << host_->get_name() << ") successfully connected to routing ~> registering.."; register_application(); } else { VSOMEIP_WARNING << __func__ << ": (" << host_->get_name() << ":" - << std::hex << _client << ") Receiver not started. Restarting"; + << std::hex << std::setw(4) << std::setfill('0') + << _client << ") Receiver not started. Restarting"; state_ = inner_state_type_e::ST_DEREGISTERED; host_->set_client(VSOMEIP_CLIENT_UNSET); @@ -2894,18 +2915,18 @@ void routing_manager_client::on_client_assign_ack(const client_t &_client) { } } else { VSOMEIP_WARNING << __func__ << ": (" << host_->get_name() << ":" - << std::hex << _client << ") Not started. Discarding"; + << std::hex << std::setw(4) << std::setfill('0') + << _client << ") Not started. Discarding"; } } else { VSOMEIP_ERROR << __func__ << ": (" << host_->get_name() << ":" - << std::hex << _client << ") Invalid clientID"; + << std::hex << std::setw(4) << std::setfill('0') + << _client << ") Invalid clientID"; } } else { - VSOMEIP_WARNING << "Client " << std::hex << get_client() - << " received another client identifier (" - << std::hex << _client - << "). Ignoring it. (" - << (int)state_ << ")"; + VSOMEIP_WARNING << "Client " << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " received another client identifier ("<< _client + << "). Ignoring it. (" << (int)state_ << ")"; } } diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index c21fd2678..9dacbde29 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -48,7 +48,7 @@ #include "../../service_discovery/include/defines.hpp" #include "../../service_discovery/include/runtime.hpp" #include "../../service_discovery/include/service_discovery.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #include "../../utility/include/utility.hpp" #ifdef USE_DLT #include "../../tracing/include/connector_impl.hpp" @@ -877,13 +877,9 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, bool is_request = utility::is_request(_data[VSOMEIP_MESSAGE_TYPE_POS]); bool is_notification = utility::is_notification(_data[VSOMEIP_MESSAGE_TYPE_POS]); bool is_response = utility::is_response(_data[VSOMEIP_MESSAGE_TYPE_POS]); - - client_t its_client = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_CLIENT_POS_MIN], - _data[VSOMEIP_CLIENT_POS_MAX]); - service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]); - method_t its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], _data[VSOMEIP_METHOD_POS_MAX]); + client_t its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); + service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); bool is_service_discovery = (its_service == sd::service && its_method == sd::method); @@ -936,10 +932,8 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, if (e2e_provider_) { if ( !is_service_discovery) { - service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]); - method_t its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], _data[VSOMEIP_METHOD_POS_MAX]); + service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); #ifndef ANDROID if (e2e_provider_->is_protected({its_service, its_method})) { // Find out where the protected area starts @@ -970,9 +964,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, #endif is_sent = its_target->send(_data, _size); } else { - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SESSION_POS_MIN], - _data[VSOMEIP_SESSION_POS_MAX]); + const session_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); VSOMEIP_ERROR<< "Routing info for remote service could not be found! (" << std::hex << std::setfill('0') << std::setw(4) << its_client << "): [" @@ -987,8 +979,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, if (is_notification && !is_service_discovery) { (void)send_local_notification(get_client(), _data, _size, _instance, _reliable, _status_check, _force); - method_t its_method = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); + method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); std::shared_ptr its_event = find_event(its_service, _instance, its_method); if (its_event) { #ifdef USE_DLT @@ -1061,9 +1052,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, && !its_info->is_local()) { // We received a response/error but neither the hosting application // nor another local client could be found --> drop - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SESSION_POS_MIN], - _data[VSOMEIP_SESSION_POS_MAX]); + const session_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); VSOMEIP_ERROR << "routing_manager_impl::send: Received response/error for unknown client (" << std::hex << std::setfill('0') @@ -1085,9 +1074,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, #endif is_sent = its_target->send(_data, _size); } else { - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SESSION_POS_MIN], - _data[VSOMEIP_SESSION_POS_MAX]); + const session_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); VSOMEIP_ERROR << "Routing error. Endpoint for service (" << std::hex << std::setfill('0') << std::setw(4) << its_client << "): [" @@ -1100,9 +1087,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, } } else { if (!is_notification) { - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SESSION_POS_MIN], - _data[VSOMEIP_SESSION_POS_MAX]); + const session_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); VSOMEIP_ERROR << "Routing error. Not hosting service (" << std::hex << std::setfill('0') << std::setw(4) << its_client << "): [" @@ -1133,12 +1118,8 @@ bool routing_manager_impl::send_to( length_t its_size = its_serializer->get_size(); e2e_buffer its_buffer; if (e2e_provider_) { - service_t its_service = VSOMEIP_BYTES_TO_WORD( - its_data[VSOMEIP_SERVICE_POS_MIN], - its_data[VSOMEIP_SERVICE_POS_MAX]); - method_t its_method = VSOMEIP_BYTES_TO_WORD( - its_data[VSOMEIP_METHOD_POS_MIN], - its_data[VSOMEIP_METHOD_POS_MAX]); + service_t its_service = bithelper::read_uint16_be(&its_data[VSOMEIP_SERVICE_POS_MIN]); + method_t its_method = bithelper::read_uint16_be(&its_data[VSOMEIP_METHOD_POS_MIN]); #ifndef ANDROID if (e2e_provider_->is_protected({its_service, its_method})) { auto its_base = e2e_provider_->get_protection_base({its_service, its_method}); @@ -1150,8 +1131,10 @@ bool routing_manager_impl::send_to( #endif } - const_cast(its_data)[VSOMEIP_CLIENT_POS_MIN] = VSOMEIP_WORD_BYTE1(_client); - const_cast(its_data)[VSOMEIP_CLIENT_POS_MAX] = VSOMEIP_WORD_BYTE0(_client); + uint8_t its_client[2] = {0}; + bithelper::write_uint16_le(_client, its_client); + const_cast(its_data)[VSOMEIP_CLIENT_POS_MIN] = its_client[1]; + const_cast(its_data)[VSOMEIP_CLIENT_POS_MAX] = its_client[0]; is_sent = send_to(_target, its_data, its_size, _message->get_instance()); @@ -1496,11 +1479,9 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, #endif if (_size >= VSOMEIP_SOMEIP_HEADER_SIZE) { its_message_type = static_cast(_data[VSOMEIP_MESSAGE_TYPE_POS]); - its_service = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_SERVICE_POS_MIN], - _data[VSOMEIP_SERVICE_POS_MAX]); + its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); if (its_service == VSOMEIP_SD_SERVICE) { - its_method = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); + its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); if (discovery_ && its_method == sd::method) { if (configuration_->get_sd_port() == _remote_port) { if (!_remote_address.is_unspecified()) { @@ -1524,15 +1505,9 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, its_instance = ep_mgr_impl_->find_instance(its_service, _receiver); } if (its_instance == 0xFFFF) { - its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); - const client_t its_client = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_CLIENT_POS_MIN], - _data[VSOMEIP_CLIENT_POS_MAX]); - const session_t its_session = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SESSION_POS_MIN], - _data[VSOMEIP_SESSION_POS_MAX]); + its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); + const client_t its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); + const session_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); boost::system::error_code ec; VSOMEIP_ERROR << "Received message on invalid port: [" << std::hex << std::setfill('0') @@ -1566,12 +1541,8 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, // Security checks if enabled! if (configuration_->is_security_enabled()) { if (utility::is_request(_data[VSOMEIP_MESSAGE_TYPE_POS])) { - client_t requester = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_CLIENT_POS_MIN], - _data[VSOMEIP_CLIENT_POS_MAX]); - its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); + client_t requester = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); + its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); if (!configuration_->is_offered_remote(its_service, its_instance)) { VSOMEIP_WARNING << std::hex << "Security: Received a remote request " << "for service/instance " << its_service << "/" << its_instance @@ -1596,9 +1567,7 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, } } if (e2e_provider_) { - its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); + its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); #ifndef ANDROID if (e2e_provider_->is_checked({its_service, its_method})) { auto its_base = e2e_provider_->get_protection_base({its_service, its_method}); @@ -1664,9 +1633,7 @@ bool routing_manager_impl::on_message(service_t _service, instance_t _instance, if (utility::is_request(_data[VSOMEIP_MESSAGE_TYPE_POS])) { its_client = find_local_client(_service, _instance); } else { - its_client = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_CLIENT_POS_MIN], - _data[VSOMEIP_CLIENT_POS_MAX]); + its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); } #if 0 @@ -1699,8 +1666,7 @@ bool routing_manager_impl::on_message(service_t _service, instance_t _instance, void routing_manager_impl::on_notification(client_t _client, service_t _service, instance_t _instance, const byte_t *_data, length_t _size, bool _notify_one) { - event_t its_event_id = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], _data[VSOMEIP_METHOD_POS_MAX]); + event_t its_event_id = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); std::shared_ptr its_event = find_event(_service, _instance, its_event_id); if (its_event) { uint32_t its_length = utility::get_payload_size(_data, _size); @@ -2088,10 +2054,8 @@ bool routing_manager_impl::deliver_notification( client_t _bound_client, const vsomeip_sec_client_t *_sec_client, uint8_t _status_check, bool _is_from_remote) { - event_t its_event_id = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], _data[VSOMEIP_METHOD_POS_MAX]); - client_t its_client_id = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_CLIENT_POS_MIN], _data[VSOMEIP_CLIENT_POS_MAX]); + event_t its_event_id = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); + client_t its_client_id = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); std::shared_ptr its_event = find_event(_service, _instance, its_event_id); if (its_event) { @@ -3240,8 +3204,7 @@ void routing_manager_impl::on_subscribe_nack(client_t _client, return_code_e routing_manager_impl::check_error(const byte_t *_data, length_t _size, instance_t _instance) { - service_t its_service = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_SERVICE_POS_MIN], - _data[VSOMEIP_SERVICE_POS_MAX]); + service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); if (_size >= VSOMEIP_PAYLOAD_POS) { if (utility::is_request(_data[VSOMEIP_MESSAGE_TYPE_POS]) @@ -3294,25 +3257,16 @@ void routing_manager_impl::send_error(return_code_e _return_code, session_t its_session = 0; major_version_t its_version = 0; - if (_size >= VSOMEIP_CLIENT_POS_MAX) { - its_client = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_CLIENT_POS_MIN], - _data[VSOMEIP_CLIENT_POS_MAX]); - } - if (_size >= VSOMEIP_SERVICE_POS_MAX) { - its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]); - } - if (_size >= VSOMEIP_METHOD_POS_MAX) { - its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], _data[VSOMEIP_METHOD_POS_MAX]); - } - if (_size >= VSOMEIP_SESSION_POS_MAX) { - its_session = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_SESSION_POS_MIN], - _data[VSOMEIP_SESSION_POS_MAX]); - } - if( _size >= VSOMEIP_INTERFACE_VERSION_POS) { + if (_size >= VSOMEIP_CLIENT_POS_MAX) + its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); + if (_size >= VSOMEIP_SERVICE_POS_MAX) + its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); + if (_size >= VSOMEIP_METHOD_POS_MAX) + its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); + if (_size >= VSOMEIP_SESSION_POS_MAX) + its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); + if( _size >= VSOMEIP_INTERFACE_VERSION_POS) its_version = _data[VSOMEIP_INTERFACE_VERSION_POS]; - } auto error_message = runtime::get()->create_message(_reliable); error_message->set_client(its_client); diff --git a/implementation/routing/src/routing_manager_stub.cpp b/implementation/routing/src/routing_manager_stub.cpp index d0015c3f7..55461aadc 100644 --- a/implementation/routing/src/routing_manager_stub.cpp +++ b/implementation/routing/src/routing_manager_stub.cpp @@ -56,7 +56,7 @@ #include "../../protocol/include/update_security_policy_response_command.hpp" #include "../../security/include/policy_manager_impl.hpp" #include "../../security/include/security.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #include "../../utility/include/utility.hpp" namespace vsomeip_v3 { @@ -553,15 +553,9 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, auto its_message_data(its_command.get_message()); if (its_message_data.size() > VSOMEIP_MESSAGE_TYPE_POS) { - its_service = VSOMEIP_BYTES_TO_WORD( - its_message_data[VSOMEIP_SERVICE_POS_MIN], - its_message_data[VSOMEIP_SERVICE_POS_MAX]); - its_method = VSOMEIP_BYTES_TO_WORD( - its_message_data[VSOMEIP_METHOD_POS_MIN], - its_message_data[VSOMEIP_METHOD_POS_MAX]); - its_client = VSOMEIP_BYTES_TO_WORD( - its_message_data[VSOMEIP_CLIENT_POS_MIN], - its_message_data[VSOMEIP_CLIENT_POS_MAX]); + its_service = bithelper::read_uint16_be(&its_message_data[VSOMEIP_SERVICE_POS_MIN]); + its_method = bithelper::read_uint16_be(&its_message_data[VSOMEIP_METHOD_POS_MIN]); + its_client = bithelper::read_uint16_be(&its_message_data[VSOMEIP_CLIENT_POS_MIN]); its_instance = its_command.get_instance(); is_reliable = its_command.is_reliable(); @@ -581,11 +575,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, } } // reduce by size of instance, flush, reliable, client and is_valid_crc flag - auto its_contained_size = VSOMEIP_BYTES_TO_LONG( - its_message_data[VSOMEIP_LENGTH_POS_MIN], - its_message_data[VSOMEIP_LENGTH_POS_MIN+1], - its_message_data[VSOMEIP_LENGTH_POS_MIN+2], - its_message_data[VSOMEIP_LENGTH_POS_MIN+3]); + uint32_t its_contained_size = bithelper::read_uint32_be(&its_message_data[VSOMEIP_LENGTH_POS_MIN]); if (its_message_data.size() != its_contained_size + VSOMEIP_SOMEIP_HEADER_SIZE) { VSOMEIP_WARNING << "Received a SEND command containing message with invalid size -> skip!"; break; @@ -609,16 +599,11 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, if (its_message_data.size() > VSOMEIP_MESSAGE_TYPE_POS) { its_client = its_command.get_target(); - its_service = VSOMEIP_BYTES_TO_WORD( - its_message_data[VSOMEIP_SERVICE_POS_MIN], - its_message_data[VSOMEIP_SERVICE_POS_MAX]); + its_service = bithelper::read_uint16_be(&its_message_data[VSOMEIP_SERVICE_POS_MIN]); its_instance = its_command.get_instance(); - auto its_contained_size = VSOMEIP_BYTES_TO_LONG( - its_message_data[VSOMEIP_LENGTH_POS_MIN], - its_message_data[VSOMEIP_LENGTH_POS_MIN+1], - its_message_data[VSOMEIP_LENGTH_POS_MIN+2], - its_message_data[VSOMEIP_LENGTH_POS_MIN+3]); + uint32_t its_contained_size = bithelper::read_uint32_be(&its_message_data[VSOMEIP_LENGTH_POS_MIN]); + if (its_message_data.size() != its_contained_size + VSOMEIP_SOMEIP_HEADER_SIZE) { VSOMEIP_WARNING << "Received a NOTIFY command containing message with invalid size -> skip!"; break; @@ -2299,17 +2284,15 @@ routing_manager_stub::send_requester_policies(const std::unordered_set its_message.push_back(0); uint32_t its_policy_size = static_cast(its_policy_data.size() + sizeof(uint32_t)); - its_message.push_back(VSOMEIP_LONG_BYTE0(its_policy_size)); - its_message.push_back(VSOMEIP_LONG_BYTE1(its_policy_size)); - its_message.push_back(VSOMEIP_LONG_BYTE2(its_policy_size)); - its_message.push_back(VSOMEIP_LONG_BYTE3(its_policy_size)); - its_policy_id = pending_security_update_add(_clients); - its_message.push_back(VSOMEIP_LONG_BYTE0(its_policy_id)); - its_message.push_back(VSOMEIP_LONG_BYTE1(its_policy_id)); - its_message.push_back(VSOMEIP_LONG_BYTE2(its_policy_id)); - its_message.push_back(VSOMEIP_LONG_BYTE3(its_policy_id)); + uint8_t new_its_policy_size[4] = {0}; + bithelper::write_uint32_le(its_policy_size, new_its_policy_size); + its_message.insert(its_message.end(), new_its_policy_size, new_its_policy_size + sizeof(new_its_policy_size)); + its_policy_id = pending_security_update_add(_clients); + uint8_t new_its_policy_id[4] = {0}; + bithelper::write_uint32_le(its_policy_id, new_its_policy_id); + its_message.insert(its_message.end(), new_its_policy_id, new_its_policy_id + sizeof(new_its_policy_id)); its_message.insert(its_message.end(), its_policy_data.begin(), its_policy_data.end()); for (const auto c : _clients) { diff --git a/implementation/security/src/policy.cpp b/implementation/security/src/policy.cpp index da0bbd869..9c30f5193 100644 --- a/implementation/security/src/policy.cpp +++ b/implementation/security/src/policy.cpp @@ -8,7 +8,7 @@ #include #include "../include/policy.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" namespace vsomeip_v3 { @@ -268,7 +268,7 @@ policy::deserialize_u16(const byte_t * &_data, uint32_t &_size, if (_size < sizeof(uint16_t)) return false; - _value = VSOMEIP_BYTES_TO_WORD(_data[0], _data[1]); + _value = bithelper::read_uint16_be(_data); _data += sizeof(uint16_t); _size -= static_cast(sizeof(uint16_t)); @@ -283,7 +283,7 @@ policy::deserialize_u32(const byte_t * &_data, uint32_t &_size, if (_size < sizeof(uint32_t)) return false; - _value = VSOMEIP_BYTES_TO_LONG(_data[0], _data[1], _data[2], _data[3]); + _value = bithelper::read_uint32_be(_data); _data += sizeof(uint32_t); _size -= static_cast(sizeof(uint32_t)); @@ -419,28 +419,25 @@ void policy::serialize_u16(uint16_t _value, std::vector &_data) const { - _data.push_back(VSOMEIP_WORD_BYTE1(_value)); - _data.push_back(VSOMEIP_WORD_BYTE0(_value)); + uint8_t new_buffer[2] = {0}; + bithelper::write_uint16_be(_value, new_buffer); + _data.insert(_data.end(), new_buffer, new_buffer + sizeof(new_buffer)); } void policy::serialize_u32(uint32_t _value, std::vector &_data) const { - _data.push_back(VSOMEIP_LONG_BYTE3(_value)); - _data.push_back(VSOMEIP_LONG_BYTE2(_value)); - _data.push_back(VSOMEIP_LONG_BYTE1(_value)); - _data.push_back(VSOMEIP_LONG_BYTE0(_value)); + uint8_t new_buffer[4] = {0}; + bithelper::write_uint32_be(_value, new_buffer); + _data.insert(_data.end(), new_buffer, new_buffer + sizeof(new_buffer)); } void policy::serialize_u32_at(uint32_t _value, std::vector &_data, size_t _pos) const { - _data[_pos] = VSOMEIP_LONG_BYTE3(_value); - _data[_pos+1] = VSOMEIP_LONG_BYTE2(_value); - _data[_pos+2] = VSOMEIP_LONG_BYTE1(_value); - _data[_pos+3] = VSOMEIP_LONG_BYTE0(_value); + bithelper::write_uint32_be(_value, &_data[_pos]); } void diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index c38804575..a15deab8f 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -40,7 +40,7 @@ #include "../../routing/include/event.hpp" #include "../../routing/include/eventgroupinfo.hpp" #include "../../routing/include/serviceinfo.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" namespace vsomeip_v3 { namespace sd { @@ -2767,12 +2767,10 @@ service_discovery_impl::check_ipv4_address( << its_address; is_valid = false; } else { - const std::uint32_t self = VSOMEIP_BYTES_TO_LONG(its_unicast_address[0], - its_unicast_address[1], its_unicast_address[2], its_unicast_address[3]); - const std::uint32_t remote = VSOMEIP_BYTES_TO_LONG(endpoint_address[0], - endpoint_address[1], endpoint_address[2], endpoint_address[3]); - const std::uint32_t netmask = VSOMEIP_BYTES_TO_LONG(its_netmask[0], - its_netmask[1], its_netmask[2], its_netmask[3]); + const std::uint32_t self = bithelper::read_uint32_be(&its_unicast_address[0]); + const std::uint32_t remote = bithelper::read_uint32_be(&endpoint_address[0]); + const std::uint32_t netmask = bithelper::read_uint32_be(&its_netmask[0]); + if ((self & netmask) != (remote & netmask)) { VSOMEIP_ERROR<< "Subscriber's IP isn't in the same subnet as host's IP: " << its_address; diff --git a/implementation/tracing/src/connector_impl.cpp b/implementation/tracing/src/connector_impl.cpp index 2f93bd098..eef8537cc 100644 --- a/implementation/tracing/src/connector_impl.cpp +++ b/implementation/tracing/src/connector_impl.cpp @@ -16,7 +16,7 @@ #include "../include/connector_impl.hpp" #include "../include/defines.hpp" #include "../../configuration/include/trace.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" #ifdef ANDROID #include @@ -220,19 +220,12 @@ void connector_impl::trace(const byte_t *_header, uint16_t _header_size, if (is_sd_message(_data, its_data_size) && !is_sd_enabled_) return; // tracing of service discovery messages is disabled! - service_t its_service = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_SERVICE_POS_MIN], - _data[VSOMEIP_SERVICE_POS_MAX]); + service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); // Instance is not part of the SOME/IP header, read it from the trace // header - instance_t its_instance = VSOMEIP_BYTES_TO_WORD( - _header[VSOMEIP_TC_INSTANCE_POS_MIN], - _header[VSOMEIP_TC_INSTANCE_POS_MAX]); - - method_t its_method = VSOMEIP_BYTES_TO_WORD( - _data[VSOMEIP_METHOD_POS_MIN], - _data[VSOMEIP_METHOD_POS_MAX]); + instance_t its_instance = bithelper::read_uint16_be(&_header[VSOMEIP_TC_INSTANCE_POS_MIN]); + method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); // Forward to channel if the filter set of the channel allows std::lock_guard its_channels_lock(channels_mutex_); diff --git a/implementation/tracing/src/header.cpp b/implementation/tracing/src/header.cpp index bea82c38e..924beab5f 100644 --- a/implementation/tracing/src/header.cpp +++ b/implementation/tracing/src/header.cpp @@ -8,7 +8,7 @@ #include "../include/header.hpp" #include "../../endpoints/include/endpoint.hpp" #include "../../endpoints/include/client_endpoint.hpp" -#include "../../utility/include/byteorder.hpp" +#include "../../utility/include/bithelper.hpp" namespace vsomeip_v3 { namespace trace { @@ -54,17 +54,12 @@ bool header::prepare(const endpoint *_endpoint, bool _is_sending, void header::prepare(const boost::asio::ip::address_v4 &_address, std::uint16_t _port, protocol_e _protocol, bool _is_sending, instance_t _instance) { - unsigned long its_address_as_long = _address.to_ulong(); - data_[0] = VSOMEIP_LONG_BYTE3(its_address_as_long); - data_[1] = VSOMEIP_LONG_BYTE2(its_address_as_long); - data_[2] = VSOMEIP_LONG_BYTE1(its_address_as_long); - data_[3] = VSOMEIP_LONG_BYTE0(its_address_as_long); - data_[4] = VSOMEIP_WORD_BYTE1(_port); - data_[5] = VSOMEIP_WORD_BYTE0(_port); - data_[6] = static_cast(_protocol); - data_[7] = static_cast(_is_sending); - data_[8] = VSOMEIP_WORD_BYTE1(_instance); - data_[9] = VSOMEIP_WORD_BYTE0(_instance); + + bithelper::write_uint32_be((uint32_t)_address.to_ulong(), data_); // [0-3] Address + bithelper::write_uint16_be(_port, &data_[4]); // [4-5] Port + data_[6] = static_cast(_protocol); // [6] Protocol + data_[7] = static_cast(_is_sending); // [7] is_sending + bithelper::write_uint16_be(_instance, &data_[8]); // [8-9] Instance } } // namespace trace diff --git a/implementation/utility/include/bithelper.hpp b/implementation/utility/include/bithelper.hpp new file mode 100644 index 000000000..eae200d3b --- /dev/null +++ b/implementation/utility/include/bithelper.hpp @@ -0,0 +1,134 @@ +// Copyright (C) 2014-2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef VSOMEIP_V3_BITHELPER_HPP +#define VSOMEIP_V3_BITHELPER_HPP + +#include +#include +#include +#include +#include + +namespace vsomeip_v3 { + +class bithelper { +public: + bithelper() = delete; + + //Write Methods + inline static void write_uint16_be(uint16_t _value, uint8_t* _buffer) { + if (get_endianness() != endianess_e::be) { + _value = swap_endianness(_value); + } + std::memcpy(_buffer, reinterpret_cast(&_value), sizeof(_value)); + } + + inline static void write_uint16_le(uint16_t _value, uint8_t* _buffer) { + if (get_endianness() != endianess_e::le) { + _value = swap_endianness(_value); + } + std::memcpy(_buffer, reinterpret_cast(&_value), sizeof(_value)); + } + + inline static void write_uint32_be(uint32_t _value, uint8_t* _buffer) { + if (get_endianness() != endianess_e::be) { + _value = swap_endianness(_value); + } + std::memcpy(_buffer, reinterpret_cast(&_value), sizeof(_value)); + } + + inline static void write_uint32_le(uint32_t _value, uint8_t* _buffer) { + if (get_endianness() != endianess_e::le) { + _value = swap_endianness(_value); + } + std::memcpy(_buffer, reinterpret_cast(&_value), sizeof(_value)); + } + + inline static void write_uint64_be(uint64_t _value, uint8_t* _buffer) { + if (get_endianness() != endianess_e::be) { + _value = swap_endianness(_value); + } + std::memcpy(_buffer, reinterpret_cast(&_value), sizeof(_value)); + } + + inline static void write_uint64_le(uint64_t _value, uint8_t* _buffer) { + if (get_endianness() != endianess_e::le) { + _value = swap_endianness(_value); + } + std::memcpy(_buffer, reinterpret_cast(&_value), sizeof(_value)); + } + + //Read Methods + inline static uint16_t read_uint16_be(const uint8_t* _buffer) { + uint16_t value = 0; + std::memcpy(&value, _buffer, sizeof(value)); + return get_endianness() == endianess_e::be ? value : swap_endianness(value); + } + + inline static uint16_t read_uint16_le(const uint8_t* _buffer) { + uint16_t value = 0; + std::memcpy(&value, _buffer, sizeof(value)); + return get_endianness() == endianess_e::le ? value : swap_endianness(value); + } + + inline static uint32_t read_uint32_be(const uint8_t* _buffer) { + uint32_t value = 0; + std::memcpy(&value, _buffer, sizeof(value)); + return get_endianness() == endianess_e::be ? value : swap_endianness(value); + } + + inline static uint32_t read_uint32_le(const uint8_t* _buffer) { + uint32_t value = 0; + std::memcpy(&value, _buffer, sizeof(value)); + return get_endianness() == endianess_e::le ? value : swap_endianness(value); + } + + inline static uint64_t read_uint64_be(const uint8_t* _buffer) { + uint64_t value = 0; + std::memcpy(&value, _buffer, sizeof(value)); + return get_endianness() == endianess_e::be ? value : swap_endianness(value); + } + + inline static uint64_t read_uint64_le(const uint8_t* _buffer) { + uint64_t value = 0; + std::memcpy(&value, _buffer, sizeof(value)); + return get_endianness() == endianess_e::le ? value : swap_endianness(value); + } + + inline static uint16_t read_high_word(uint32_t input) { + return uint16_t((input >> 16) & 0xFFFF); + } + + inline static uint16_t read_low_word(uint32_t input) { + return uint16_t((input) & 0xFFFF); + } + + template + static T swap_endianness(T _value) { + static_assert(std::is_integral::value, "Only integral types can be swapped"); + T swapped{}; + const auto src = reinterpret_cast(&_value); + auto dst = reinterpret_cast(&swapped); + std::reverse_copy(src, src + sizeof(T), dst); + return swapped; + } + +#if defined(COMPILE_TIME_ENDIAN) && (COMPILE_TIME_ENDIAN == BYTEORDER_LITTLE_ENDIAN) + static constexpr endianess_e get_endianness() { return endianess_e::le; } +#elif defined(COMPILE_TIME_ENDIAN) && (COMPILE_TIME_ENDIAN == BYTEORDER_BIG_ENDIAN) + static constexpr Endianness get_endianness() { return endianess_e::be; } +#else + // Run-time check + static endianess_e get_endianness() { + uint16_t test{0x0102}; + return (*reinterpret_cast(&test) == 1) ? endianess_e::be : endianess_e::le; + } +#endif +}; + +} + +#endif // VSOMEIP_V3_BITHELPER_HPP diff --git a/implementation/utility/include/byteorder.hpp b/implementation/utility/include/byteorder.hpp index f5ad3f024..929033fd6 100644 --- a/implementation/utility/include/byteorder.hpp +++ b/implementation/utility/include/byteorder.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. @@ -6,73 +6,44 @@ #ifndef VSOMEIP_V3_BYTEORDER_HPP #define VSOMEIP_V3_BYTEORDER_HPP -#if defined(__linux__) -#include -#elif defined(__freebsd__) -#include -#else -// TEST IF THERE COULD BE AN ERROR! -//#error "Undefined OS (only Linux/FreeBSD are currently supported)" -#endif - -#if __BYTE_ORDER == __LITTLE_ENDIAN - -#define VSOMEIP_BYTES_TO_WORD(x0, x1) (uint16_t((x0) << 8 | (x1))) -#define VSOMEIP_BYTES_TO_LONG(x0, x1, x2, x3) (uint32_t((x0) << 24 | (x1) << 16 | (x2) << 8 | (x3))) -#define VSOMEIP_BYTES_TO_LONG_LONG(x0, x1, x2, x3, x4, x5, x6, x7) (uint64_t (x0) << 56 | uint64_t (x1) << 48 | uint64_t (x2) << 40 | uint64_t (x3) << 32 | uint64_t (x4) << 24 | uint64_t (x5) << 16 | uint64_t (x6) << 8 | uint64_t (x7)) - -#define VSOMEIP_WORDS_TO_LONG(x0, x1) (uint32_t((x0) << 16 | (x1))) - -#define VSOMEIP_WORD_BYTE0(x) (uint8_t((x) & 0xFF)) -#define VSOMEIP_WORD_BYTE1(x) (uint8_t((x) >> 8)) - -#define VSOMEIP_LONG_BYTE0(x) (uint8_t((x) & 0xFF)) -#define VSOMEIP_LONG_BYTE1(x) (uint8_t(((x) >> 8) & 0xFF)) -#define VSOMEIP_LONG_BYTE2(x) (uint8_t(((x) >> 16) & 0xFF)) -#define VSOMEIP_LONG_BYTE3(x) (uint8_t(((x) >> 24) & 0xFF)) - -#define VSOMEIP_LONG_LONG_BYTE0(x) (uint8_t((x) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE1(x) (uint8_t(((x) >> 8) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE2(x) (uint8_t(((x) >> 16) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE3(x) (uint8_t(((x) >> 24) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE4(x) (uint8_t(((x) >> 32) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE5(x) (uint8_t(((x) >> 40) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE6(x) (uint8_t(((x) >> 48) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE7(x) (uint8_t(((x) >> 56) & 0xFF)) - -#define VSOMEIP_LONG_WORD0(x) (uint16_t((x) & 0xFFFF)) -#define VSOMEIP_LONG_WORD1(x) (uint16_t(((x) >> 16) & 0xFFFF)) - -#elif __BYTE_ORDER == __BIG_ENDIAN - -#define VSOMEIP_BYTES_TO_WORD(x0, x1) (uint16_t((x1) << 8 | (x0))) -#define VSOMEIP_BYTES_TO_LONG(x0, x1, x2, x3) (uint32_t((x3) << 24 | (x2) << 16 | (x1) << 8 | (x0))) -#define VSOMEIP_BYTES_TO_LONG_LONG(x0, x1, x2, x3, x4, x5, x6, x7) (uint64_t((x7) << 56 | (x6) << 48 | (x5) << 40 | (x4) << 32 | (x3) << 24 | (x2) << 16 | (x1) << 8 | (x0))) - -#define VSOMEIP_WORD_BYTE0(x) (uint8_t((x) >> 8)) -#define VSOMEIP_WORD_BYTE1(x) (uint8_t((x) & 0xFF)) - -#define VSOMEIP_LONG_BYTE0(x) (uint8_t(((x) >> 24) & 0xFF)) -#define VSOMEIP_LONG_BYTE1(x) (uint8_t(((x) >> 16) & 0xFF)) -#define VSOMEIP_LONG_BYTE2(x) (uint8_t(((x) >> 8) & 0xFF)) -#define VSOMEIP_LONG_BYTE3(x) (uint8_t((x) & 0xFF)) - -#define VSOMEIP_LONG_LONG_BYTE0(x) (uint8_t(((x) >> 56) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE1(x) (uint8_t(((x) >> 48) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE2(x) (uint8_t(((x) >> 40) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE3(x) (uint8_t(((x) >> 32) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE4(x) (uint8_t(((x) >> 24) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE5(x) (uint8_t(((x) >> 16) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE6(x) (uint8_t(((x) >> 8) & 0xFF)) -#define VSOMEIP_LONG_LONG_BYTE7(x) (uint8_t((x) & 0xFF)) - -#define VSOMEIP_LONG_WORD0(x) (uint16_t((((x) >> 16) & 0xFFFF)) -#define VSOMEIP_LONG_WORD1(x) (uint16_t(((x) & 0xFFFF)) - -#else - -#error "__BYTE_ORDER is not defined!" - -#endif - -#endif // VSOMEIP_V3_BYTEORDER_HPP_ +#define BYTEORDER_UNKNOWN 0 +#define BYTEORDER_LITTLE_ENDIAN 1 +#define BYTEORDER_BIG_ENDIAN 2 + +// Detect with GCC 4.6's macro +# ifdef __BYTE_ORDER__ +# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# define COMPILE_TIME_ENDIAN BYTEORDER_LITTLE_ENDIAN +# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +# define COMPILE_TIME_ENDIAN BYTEORDER_BIG_ENDIAN +# else +# define COMPILE_TIME_ENDIAN BYTEORDER_UNKNOWN +# endif // __BYTE_ORDER__ +// Detect with GLIBC's endian.h +# elif defined(__GLIBC__) +# include +# if (__BYTE_ORDER == __LITTLE_ENDIAN) +# define COMPILE_TIME_ENDIAN BYTEORDER_LITTLE_ENDIAN +# elif (__BYTE_ORDER == __BIG_ENDIAN) +# define COMPILE_TIME_ENDIAN BYTEORDER_BIG_ENDIAN +# else +# define COMPILE_TIME_ENDIAN BYTEORDER_UNKNOWN +# endif // __GLIBC__ +// Detect with _LITTLE_ENDIAN and _BIG_ENDIAN macro +# elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) +# define COMPILE_TIME_ENDIAN BYTEORDER_LITTLE_ENDIAN +# elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) +# define COMPILE_TIME_ENDIAN BYTEORDER_BIG_ENDIAN +// Detect with architecture macros +# elif defined(__sparc) || defined(__sparc__) || defined(_POWER) || defined(__powerpc__) || defined(__ppc__) || defined(__hpux) || defined(__hppa) || defined(_MIPSEB) || defined(_POWER) || defined(__s390__) +# define COMPILE_TIME_ENDIAN BYTEORDER_BIG_ENDIAN +# elif defined(__i386__) || defined(__alpha__) || defined(__ia64) || defined(__ia64__) || defined(_M_IX86) || defined(_M_IA64) || defined(_M_ALPHA) || defined(__amd64) || defined(__amd64__) || defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || defined(__bfin__) +# define COMPILE_TIME_ENDIAN BYTEORDER_LITTLE_ENDIAN +# elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64)) +# define COMPILE_TIME_ENDIAN BYTEORDER_LITTLE_ENDIAN +# else +# define COMPILE_TIME_ENDIAN BYTEORDER_UNKNOWN +# endif + + +#endif // VSOMEIP_V3_BYTEORDER_HPP diff --git a/implementation/utility/src/utility.cpp b/implementation/utility/src/utility.cpp index e7065f0c8..50fe3404a 100644 --- a/implementation/utility/src/utility.cpp +++ b/implementation/utility/src/utility.cpp @@ -25,7 +25,7 @@ #include #include -#include "../include/byteorder.hpp" +#include "../include/bithelper.hpp" #include "../include/utility.hpp" #include "../../configuration/include/configuration.hpp" @@ -47,7 +47,7 @@ uint64_t utility::get_message_size(const byte_t *_data, size_t _size) { uint64_t its_size(0); if (VSOMEIP_SOMEIP_HEADER_SIZE <= _size) { its_size = VSOMEIP_SOMEIP_HEADER_SIZE - + VSOMEIP_BYTES_TO_LONG(_data[4], _data[5], _data[6], _data[7]); + + bithelper::read_uint32_be(&_data[4]); } return its_size; } @@ -55,7 +55,7 @@ uint64_t utility::get_message_size(const byte_t *_data, size_t _size) { uint32_t utility::get_payload_size(const byte_t *_data, uint32_t _size) { uint32_t its_size(0); if (VSOMEIP_SOMEIP_HEADER_SIZE <= _size) { - its_size = VSOMEIP_BYTES_TO_LONG(_data[4], _data[5], _data[6], _data[7]) + its_size = bithelper::read_uint32_be(&_data[4]) - VSOMEIP_SOMEIP_HEADER_SIZE; } return its_size; diff --git a/interface/vsomeip/enumeration_types.hpp b/interface/vsomeip/enumeration_types.hpp index 09734b83b..b56690de3 100644 --- a/interface/vsomeip/enumeration_types.hpp +++ b/interface/vsomeip/enumeration_types.hpp @@ -102,6 +102,11 @@ enum class handler_registration_type_e : uint8_t { HRT_UNKNOWN = 0xFF }; +enum class endianess_e { + be, // big-endian + le // little-endian +}; + } // namespace vsomeip_v3 #endif // VSOMEIP_V3_ENUMERATION_TYPES_HPP_ diff --git a/test/network_tests/malicious_data_tests/malicious_data_test_msg_sender.cpp b/test/network_tests/malicious_data_tests/malicious_data_test_msg_sender.cpp index 4c75e9f3f..f5f15927e 100644 --- a/test/network_tests/malicious_data_tests/malicious_data_test_msg_sender.cpp +++ b/test/network_tests/malicious_data_tests/malicious_data_test_msg_sender.cpp @@ -16,7 +16,7 @@ #include -#include "../../implementation/utility/include/byteorder.hpp" +#include "../../implementation/utility/include/bithelper.hpp" #include "../../implementation/message/include/deserializer.hpp" #include "../../implementation/service_discovery/include/service_discovery.hpp" #include "../../implementation/service_discovery/include/message_impl.hpp" @@ -84,10 +84,9 @@ TEST_F(malicious_data, send_malicious_events) #endif vsomeip::deserializer its_deserializer(&receive_buffer[0], bytes_transferred, 0); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[VSOMEIP_SERVICE_POS_MIN], - receive_buffer[VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[VSOMEIP_METHOD_POS_MIN], - receive_buffer[VSOMEIP_METHOD_POS_MAX]); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[VSOMEIP_METHOD_POS_MIN]); + if (its_service == vsomeip::sd::service && its_method == vsomeip::sd::method) { vsomeip::sd::message_impl sd_msg; EXPECT_TRUE(sd_msg.deserialize(&its_deserializer)); @@ -313,10 +312,9 @@ TEST_F(malicious_data, send_wrong_protocol_version) return; } else { vsomeip::deserializer its_deserializer(&receive_buffer[0], bytes_transferred, 0); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[VSOMEIP_SERVICE_POS_MIN], - receive_buffer[VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[VSOMEIP_METHOD_POS_MIN], - receive_buffer[VSOMEIP_METHOD_POS_MAX]); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[VSOMEIP_METHOD_POS_MIN]); + if (its_service == vsomeip::sd::service && its_method == vsomeip::sd::method) { vsomeip::sd::message_impl sd_msg; EXPECT_TRUE(sd_msg.deserialize(&its_deserializer)); @@ -700,10 +698,9 @@ TEST_F(malicious_data, send_wrong_message_type) return; } else { vsomeip::deserializer its_deserializer(&receive_buffer[0], bytes_transferred, 0); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[VSOMEIP_SERVICE_POS_MIN], - receive_buffer[VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[VSOMEIP_METHOD_POS_MIN], - receive_buffer[VSOMEIP_METHOD_POS_MAX]); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[VSOMEIP_METHOD_POS_MIN]); + if (its_service == vsomeip::sd::service && its_method == vsomeip::sd::method) { vsomeip::sd::message_impl sd_msg; EXPECT_TRUE(sd_msg.deserialize(&its_deserializer)); @@ -999,10 +996,9 @@ TEST_F(malicious_data, send_wrong_return_code) return; } else { vsomeip::deserializer its_deserializer(&receive_buffer[0], bytes_transferred, 0); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[VSOMEIP_SERVICE_POS_MIN], - receive_buffer[VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[VSOMEIP_METHOD_POS_MIN], - receive_buffer[VSOMEIP_METHOD_POS_MAX]); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[VSOMEIP_METHOD_POS_MIN]); + if (its_service == vsomeip::sd::service && its_method == vsomeip::sd::method) { vsomeip::sd::message_impl sd_msg; EXPECT_TRUE(sd_msg.deserialize(&its_deserializer)); @@ -1303,10 +1299,9 @@ TEST_F(malicious_data, wrong_header_fields_udp) return; } else { vsomeip::deserializer its_deserializer(&receive_buffer[0], bytes_transferred, 0); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[VSOMEIP_SERVICE_POS_MIN], - receive_buffer[VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[VSOMEIP_METHOD_POS_MIN], - receive_buffer[VSOMEIP_METHOD_POS_MAX]); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[VSOMEIP_METHOD_POS_MIN]); + if (its_service == vsomeip::sd::service && its_method == vsomeip::sd::method) { vsomeip::sd::message_impl sd_msg; EXPECT_TRUE(sd_msg.deserialize(&its_deserializer)); diff --git a/test/network_tests/pending_subscription_tests/pending_subscription_test_sd_msg_sender.cpp b/test/network_tests/pending_subscription_tests/pending_subscription_test_sd_msg_sender.cpp index 47ac36261..ce05f66c3 100644 --- a/test/network_tests/pending_subscription_tests/pending_subscription_test_sd_msg_sender.cpp +++ b/test/network_tests/pending_subscription_tests/pending_subscription_test_sd_msg_sender.cpp @@ -16,7 +16,7 @@ #include -#include "../../implementation/utility/include/byteorder.hpp" +#include "../../implementation/utility/include/bithelper.hpp" #include "../../implementation/message/include/deserializer.hpp" #include "../../implementation/service_discovery/include/service_discovery.hpp" #include "../../implementation/service_discovery/include/message_impl.hpp" @@ -85,17 +85,13 @@ TEST_F(pending_subscription, send_multiple_subscriptions) std::uint32_t its_pos = 0; while (bytes_transferred > 0) { - const std::uint32_t its_message_size = VSOMEIP_BYTES_TO_LONG( - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 1], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 2], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 3]) + VSOMEIP_SOMEIP_HEADER_SIZE; + const std::uint32_t its_message_size = vsomeip::bithelper::read_uint32_be(&receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN]) + + VSOMEIP_SOMEIP_HEADER_SIZE; + vsomeip::deserializer its_deserializer(&receive_buffer[its_pos], its_message_size, 0); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN]); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN], - receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN], - receive_buffer[its_pos + VSOMEIP_METHOD_POS_MAX]); its_pos += its_message_size; bytes_transferred -= its_message_size; @@ -278,17 +274,13 @@ TEST_F(pending_subscription, send_alternating_subscribe_unsubscribe) std::uint32_t its_pos = 0; while (bytes_transferred > 0) { - const std::uint32_t its_message_size = VSOMEIP_BYTES_TO_LONG( - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 1], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 2], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 3]) + VSOMEIP_SOMEIP_HEADER_SIZE; + const std::uint32_t its_message_size = vsomeip::bithelper::read_uint32_be(&receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN]) + + VSOMEIP_SOMEIP_HEADER_SIZE; + vsomeip::deserializer its_deserializer(&receive_buffer[its_pos], its_message_size, 0); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN]); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN], - receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN], - receive_buffer[its_pos + VSOMEIP_METHOD_POS_MAX]); its_pos += its_message_size; bytes_transferred -= its_message_size; @@ -486,16 +478,13 @@ TEST_F(pending_subscription, send_multiple_unsubscriptions) #endif std::uint32_t its_pos = 0; while (bytes_transferred > 0) { - const std::uint32_t its_message_size = VSOMEIP_BYTES_TO_LONG( - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 1], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 2], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 3]) + VSOMEIP_SOMEIP_HEADER_SIZE; + const std::uint32_t its_message_size = vsomeip::bithelper::read_uint32_be(&receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN]) + + VSOMEIP_SOMEIP_HEADER_SIZE; + vsomeip::deserializer its_deserializer(&receive_buffer[its_pos], its_message_size, 0); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN], - receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN], - receive_buffer[its_pos + VSOMEIP_METHOD_POS_MAX]); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN]); + its_pos += its_message_size; bytes_transferred -= its_message_size; @@ -693,17 +682,13 @@ TEST_F(pending_subscription, send_alternating_subscribe_nack_unsubscribe) #endif std::uint32_t its_pos = 0; while (bytes_transferred > 0) { - const std::uint32_t its_message_size = VSOMEIP_BYTES_TO_LONG( - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 1], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 2], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 3]) + VSOMEIP_SOMEIP_HEADER_SIZE; + const std::uint32_t its_message_size = vsomeip::bithelper::read_uint32_be(&receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN]) + + VSOMEIP_SOMEIP_HEADER_SIZE; + vsomeip::deserializer its_deserializer(&receive_buffer[its_pos], its_message_size, 0); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN]); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN], - receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN], - receive_buffer[its_pos + VSOMEIP_METHOD_POS_MAX]); its_pos += its_message_size; bytes_transferred -= its_message_size; @@ -914,17 +899,13 @@ TEST_F(pending_subscription, send_alternating_subscribe_unsubscribe_same_port) std::uint32_t its_pos = 0; while (bytes_transferred > 0) { - const std::uint32_t its_message_size = VSOMEIP_BYTES_TO_LONG( - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 1], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 2], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 3]) + VSOMEIP_SOMEIP_HEADER_SIZE; + const std::uint32_t its_message_size = vsomeip::bithelper::read_uint32_be(&receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN]) + + VSOMEIP_SOMEIP_HEADER_SIZE; + vsomeip::deserializer its_deserializer(&receive_buffer[its_pos], its_message_size, 0); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN]); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN], - receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN], - receive_buffer[its_pos + VSOMEIP_METHOD_POS_MAX]); its_pos += its_message_size; bytes_transferred -= its_message_size; @@ -1125,17 +1106,12 @@ TEST_F(pending_subscription, subscribe_resubscribe_mixed) std::uint32_t its_pos = 0; while (bytes_transfered > 0) { - const std::uint32_t its_message_size = VSOMEIP_BYTES_TO_LONG( - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 1], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 2], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 3]) + VSOMEIP_SOMEIP_HEADER_SIZE; - vsomeip::deserializer its_deserializer(&receive_buffer[its_pos], its_message_size, 0); + const std::uint32_t its_message_size = vsomeip::bithelper::read_uint32_be(&receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN]) + + VSOMEIP_SOMEIP_HEADER_SIZE; - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN], - receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN], - receive_buffer[its_pos + VSOMEIP_METHOD_POS_MAX]); + vsomeip::deserializer its_deserializer(&receive_buffer[its_pos], its_message_size, 0); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN]); its_pos += its_message_size; bytes_transfered -= its_message_size; @@ -1362,17 +1338,13 @@ TEST_F(pending_subscription, send_subscribe_stop_subscribe_subscribe) std::cout << __func__ << " received: " << std::dec << bytes_transferred << " bytes: " << str.str() << std::endl; #endif - const std::uint32_t its_message_size = VSOMEIP_BYTES_TO_LONG( - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 1], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 2], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 3]) + VSOMEIP_SOMEIP_HEADER_SIZE; + const std::uint32_t its_message_size = vsomeip::bithelper::read_uint32_be(&receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN]) + + VSOMEIP_SOMEIP_HEADER_SIZE; + vsomeip::deserializer its_deserializer(&receive_buffer[its_pos], its_message_size, 0); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN]); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN], - receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN], - receive_buffer[its_pos + VSOMEIP_METHOD_POS_MAX]); its_pos += its_message_size; bytes_transferred -= its_message_size; @@ -1560,17 +1532,13 @@ TEST_F(pending_subscription, send_request_to_sd_port) } else { std::uint32_t its_pos = 0; while (bytes_transferred > 0) { - const std::uint32_t its_message_size = VSOMEIP_BYTES_TO_LONG( - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 1], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 2], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 3]) + VSOMEIP_SOMEIP_HEADER_SIZE; + const std::uint32_t its_message_size = vsomeip::bithelper::read_uint32_be(&receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN]) + + VSOMEIP_SOMEIP_HEADER_SIZE; + vsomeip::deserializer its_deserializer(&receive_buffer[its_pos], its_message_size, 0); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN]); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN], - receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN], - receive_buffer[its_pos + VSOMEIP_METHOD_POS_MAX]); its_pos += its_message_size; bytes_transferred -= its_message_size; diff --git a/test/network_tests/someip_tp_tests/someip_tp_test_msg_sender.cpp b/test/network_tests/someip_tp_tests/someip_tp_test_msg_sender.cpp index 3f79ce6ff..0c9c46a51 100644 --- a/test/network_tests/someip_tp_tests/someip_tp_test_msg_sender.cpp +++ b/test/network_tests/someip_tp_tests/someip_tp_test_msg_sender.cpp @@ -24,7 +24,7 @@ #include -#include "../../implementation/utility/include/byteorder.hpp" +#include "../../implementation/utility/include/bithelper.hpp" #include "../../implementation/message/include/deserializer.hpp" #include "../../implementation/message/include/serializer.hpp" #include "../../implementation/service_discovery/include/service_discovery.hpp" @@ -271,11 +271,7 @@ class someip_tp : public ::testing::TestWithParam { _seg->insert(_seg->begin() + VSOMEIP_TP_PAYLOAD_POS, _amount, 0xff); // decrease offset by amount - const vsomeip::tp::tp_header_t its_tp_header = VSOMEIP_BYTES_TO_LONG( - (*_seg)[VSOMEIP_TP_HEADER_POS_MIN], - (*_seg)[VSOMEIP_TP_HEADER_POS_MIN + 1], - (*_seg)[VSOMEIP_TP_HEADER_POS_MIN + 2], - (*_seg)[VSOMEIP_TP_HEADER_POS_MAX]); + const vsomeip::tp::tp_header_t its_tp_header = vsomeip::bithelper::read_uint32_be(&(*_seg)[VSOMEIP_TP_HEADER_POS_MIN]); std::uint32_t its_offset = vsomeip::tp::tp::get_offset(its_tp_header); its_offset -= _amount; const vsomeip::tp::tp_header_t its_new_tp_header = @@ -311,11 +307,7 @@ class someip_tp : public ::testing::TestWithParam { } _seg->erase(_seg->begin() + VSOMEIP_TP_PAYLOAD_POS, _seg->begin() + VSOMEIP_TP_PAYLOAD_POS + _amount); // increase offset by amount - const vsomeip::tp::tp_header_t its_tp_header = VSOMEIP_BYTES_TO_LONG( - (*_seg)[VSOMEIP_TP_HEADER_POS_MIN], - (*_seg)[VSOMEIP_TP_HEADER_POS_MIN + 1], - (*_seg)[VSOMEIP_TP_HEADER_POS_MIN + 2], - (*_seg)[VSOMEIP_TP_HEADER_POS_MAX]); + const vsomeip::tp::tp_header_t its_tp_header = vsomeip::bithelper::read_uint32_be(&(*_seg)[VSOMEIP_TP_HEADER_POS_MIN]); std::uint32_t its_offset = vsomeip::tp::tp::get_offset(its_tp_header); its_offset += _amount; const vsomeip::tp::tp_header_t its_new_tp_header = @@ -422,10 +414,9 @@ TEST_P(someip_tp, send_in_mode) return; } else { vsomeip::deserializer its_deserializer(&receive_buffer[0], bytes_transferred, 0); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[VSOMEIP_SERVICE_POS_MIN], - receive_buffer[VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[VSOMEIP_METHOD_POS_MIN], - receive_buffer[VSOMEIP_METHOD_POS_MAX]); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[VSOMEIP_METHOD_POS_MIN]); + if (its_service == vsomeip::sd::service && its_method == vsomeip::sd::method) { vsomeip::sd::message_impl sd_msg; EXPECT_TRUE(sd_msg.deserialize(&its_deserializer)); @@ -540,18 +531,15 @@ TEST_P(someip_tp, send_in_mode) std::uint32_t its_pos = 0; while (bytes_transferred > 0) { - const std::uint32_t its_message_size = VSOMEIP_BYTES_TO_LONG( - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 1], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 2], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 3]) + VSOMEIP_SOMEIP_HEADER_SIZE; + const std::uint32_t its_message_size = vsomeip::bithelper::read_uint32_be( + &receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN]) + + VSOMEIP_SOMEIP_HEADER_SIZE; + std::cout << __LINE__ << ": received response " << its_message_size << std::endl; - vsomeip::deserializer its_deserializer(&receive_buffer[its_pos], its_message_size, 0); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN], - receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN], - receive_buffer[its_pos + VSOMEIP_METHOD_POS_MAX]); + vsomeip::deserializer its_deserializer(&receive_buffer[its_pos], its_message_size, 0); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN]); vsomeip::message_impl msg; EXPECT_TRUE(msg.deserialize(&its_deserializer)); @@ -857,9 +845,7 @@ TEST_P(someip_tp, send_in_mode) EXPECT_EQ(someip_tp_test::number_of_fragments, fragments_event_from_master_.size()); // create complete message from event vsomeip::message_buffer_t its_event = create_full_message(fragments_event_from_master_); - vsomeip::session_t its_event_session = - VSOMEIP_BYTES_TO_WORD(its_event[VSOMEIP_SESSION_POS_MIN], - its_event[VSOMEIP_SESSION_POS_MAX]); + vsomeip::session_t its_event_session = vsomeip::bithelper::read_uint16_be(&its_event[VSOMEIP_SESSION_POS_MIN]); std::vector its_cmp_event_fragments; create_fragments(someip_tp_test::number_of_fragments, @@ -1095,12 +1081,9 @@ TEST_P(someip_tp, send_in_mode) someip_tp_test::number_of_fragments * someip_tp_test::max_segment_size, its_request.size()); } - const vsomeip::client_t its_request_client = - VSOMEIP_BYTES_TO_WORD(its_request[VSOMEIP_CLIENT_POS_MIN], - its_request[VSOMEIP_CLIENT_POS_MAX]); - const vsomeip::session_t its_request_session = - VSOMEIP_BYTES_TO_WORD(its_request[VSOMEIP_SESSION_POS_MIN], - its_request[VSOMEIP_SESSION_POS_MAX]); + const vsomeip::client_t its_request_client = vsomeip::bithelper::read_uint16_be(&its_request[VSOMEIP_CLIENT_POS_MIN]); + const vsomeip::session_t its_request_session = vsomeip::bithelper::read_uint16_be(&its_request[VSOMEIP_SESSION_POS_MIN]); + create_fragments(someip_tp_test::number_of_fragments, someip_tp_test::service_slave.service_id, someip_tp_test::service_slave.instance_id, @@ -1296,18 +1279,16 @@ TEST_P(someip_tp, send_in_mode) remote_client_request_port = its_remote_endpoint.port(); std::uint32_t its_pos = 0; while (bytes_transferred > 0) { - const std::uint32_t its_message_size = VSOMEIP_BYTES_TO_LONG( - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 1], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 2], - receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN + 3]) + VSOMEIP_SOMEIP_HEADER_SIZE; + const std::uint32_t its_message_size = vsomeip::bithelper::read_uint32_be( + &receive_buffer[its_pos + VSOMEIP_LENGTH_POS_MIN]) + + VSOMEIP_SOMEIP_HEADER_SIZE; + std::cout << __LINE__ << ": received request from master " << its_message_size << std::endl; + vsomeip::deserializer its_deserializer(&receive_buffer[its_pos], its_message_size, 0); + vsomeip::service_t its_service = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN]); + vsomeip::method_t its_method = vsomeip::bithelper::read_uint16_be(&receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN]); - vsomeip::service_t its_service = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MIN], - receive_buffer[its_pos + VSOMEIP_SERVICE_POS_MAX]); - vsomeip::method_t its_method = VSOMEIP_BYTES_TO_WORD(receive_buffer[its_pos + VSOMEIP_METHOD_POS_MIN], - receive_buffer[its_pos + VSOMEIP_METHOD_POS_MAX]); EXPECT_EQ(someip_tp_test::service_slave.service_id, its_service); EXPECT_EQ(someip_tp_test::service_slave.method_id, its_method); vsomeip::message_impl msg; diff --git a/test/unit_tests/utility_tests/ut_ByteOperation.cpp b/test/unit_tests/utility_tests/ut_ByteOperation.cpp new file mode 100644 index 000000000..5eee0d707 --- /dev/null +++ b/test/unit_tests/utility_tests/ut_ByteOperation.cpp @@ -0,0 +1,170 @@ +// Copyright (C) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include "../../../implementation/utility/include/bithelper.hpp" + +#include + +TEST(byte_operations, MACRO_VSOMEIP_BYTES_TO_WORD) +{ + uint8_t payload[8] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18}; + + uint16_t its_service = vsomeip_v3::bithelper::read_uint16_be(payload+VSOMEIP_SERVICE_POS_MIN); + uint16_t its_method = vsomeip_v3::bithelper::read_uint16_be(payload+VSOMEIP_METHOD_POS_MIN); + + EXPECT_EQ(its_service, 0x1112); + EXPECT_EQ(its_method, 0x1314); +} + +TEST(byte_operations, MACRO_VSOMEIP_BYTES_TO_LONG) +{ + uint8_t payload[8] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18}; + + uint32_t its_data = vsomeip_v3::bithelper::read_uint32_be(payload+2); + EXPECT_EQ(its_data, 0x13141516); + + uint32_t its_data2 = vsomeip_v3::bithelper::read_uint32_le(payload+2); + EXPECT_EQ(its_data2, 0x16151413); +} + +TEST(byte_operations, MACRO_VSOMEIP_BYTES_TO_LONG_LONG) +{ + uint8_t payload[8] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18}; + + uint64_t its_data = vsomeip_v3::bithelper::read_uint64_be(payload); + EXPECT_EQ(its_data, 0x1112131415161718); +} + +TEST(byte_operations, MACRO_VSOMEIP_WORDS_TO_LONG) { + uint16_t serviceid = 0x1111; + uint16_t methodid = 0x2222; + + const uint8_t request_message[] = {static_cast((serviceid & 0xFF00) >> 8), + static_cast( serviceid & 0x00FF), + static_cast((methodid & 0xFF00) >> 8), + static_cast( methodid & 0x00FF)}; + uint32_t header_method = vsomeip_v3::bithelper::read_uint32_be(request_message); + + EXPECT_EQ(header_method, 0x11112222); +} + +TEST(byte_operations, MACRO_VSOMEIP_WORD_BYTEx) { + uint16_t clientid = 0x1234; + uint8_t client[sizeof(clientid)] = {0}; + + vsomeip_v3::bithelper::write_uint16_be(clientid, client); + EXPECT_EQ(client[0], 0x12); + EXPECT_EQ(client[1], 0x34); + + vsomeip_v3::bithelper::write_uint16_le(clientid, client); + EXPECT_EQ(client[0], 0x34); + EXPECT_EQ(client[1], 0x12); +} + +TEST(byte_operations, MACRO_VSOMEIP_LONG_BYTEx) { + uint32_t payload = 0x12345678; + uint8_t data[sizeof(payload)] = {0}; + + vsomeip_v3::bithelper::write_uint32_be(payload, data); + EXPECT_EQ(data[0], 0x12); + EXPECT_EQ(data[1], 0x34); + EXPECT_EQ(data[2], 0x56); + EXPECT_EQ(data[3], 0x78); + + vsomeip_v3::bithelper::write_uint32_le(payload, data); + EXPECT_EQ(data[0], 0x78); + EXPECT_EQ(data[1], 0x56); + EXPECT_EQ(data[2], 0x34); + EXPECT_EQ(data[3], 0x12); +} + +TEST(byte_operations, MACRO_VSOMEIP_LONG_LONG_BYTEx) { + uint64_t payload = 0x1214161821232527; + uint8_t data[sizeof(payload)] = {0}; + + vsomeip_v3::bithelper::write_uint64_be(payload, data); + EXPECT_EQ(data[0], 0x12); + EXPECT_EQ(data[1], 0x14); + EXPECT_EQ(data[2], 0x16); + EXPECT_EQ(data[3], 0x18); + EXPECT_EQ(data[4], 0x21); + EXPECT_EQ(data[5], 0x23); + EXPECT_EQ(data[6], 0x25); + EXPECT_EQ(data[7], 0x27); + + vsomeip_v3::bithelper::write_uint64_le(payload, data); + EXPECT_EQ(data[0], 0x27); + EXPECT_EQ(data[1], 0x25); + EXPECT_EQ(data[2], 0x23); + EXPECT_EQ(data[3], 0x21); + EXPECT_EQ(data[4], 0x18); + EXPECT_EQ(data[5], 0x16); + EXPECT_EQ(data[6], 0x14); + EXPECT_EQ(data[7], 0x12); + +} + +TEST(byte_operations, MACRO_VSOMEIP_LONG_WORDx) { + uint32_t payload = 0x12345678; + uint8_t data[sizeof(payload)] = {0}; + + vsomeip_v3::bithelper::write_uint32_le(payload, data); + EXPECT_EQ(data[0], 0x78); + EXPECT_EQ(data[1], 0x56); + EXPECT_EQ(data[2], 0x34); + EXPECT_EQ(data[3], 0x12); +} + +TEST(byte_operations, TestUint16) { + uint8_t input[] = {0xab, 0xcd}; + EXPECT_EQ(0xabcd, vsomeip_v3::bithelper::read_uint16_be(input)); + + uint8_t output[sizeof(input)] = {0}; + vsomeip_v3::bithelper::write_uint16_be(0x1234, output); + EXPECT_EQ(0x12, output[0]); + EXPECT_EQ(0x34, output[1]); +} + +TEST(byte_operations, TestUint32_BigEndian) { + uint8_t input[] = {0x12, 0x34, 0x56, 0x78}; + EXPECT_EQ(0x12345678U, vsomeip_v3::bithelper::read_uint32_be(input)); + + uint8_t output[sizeof(uint32_t)] = {0}; + vsomeip_v3::bithelper::write_uint32_be(0xabcd1234, output); + EXPECT_EQ(0xab, output[0]); + EXPECT_EQ(0xcd, output[1]); + EXPECT_EQ(0x12, output[2]); + EXPECT_EQ(0x34, output[3]); +} + +TEST(byte_operations, TestUint32_LittleEndian) { + uint8_t input[] = {0x12, 0x34, 0x56, 0x78}; + EXPECT_EQ(0x78563412U, vsomeip_v3::bithelper::read_uint32_le(input)); + + uint8_t output[sizeof(uint32_t)] = {0}; + vsomeip_v3::bithelper::write_uint32_le(0xabcd1234, output); + EXPECT_EQ(0xab, output[3]); + EXPECT_EQ(0xcd, output[2]); + EXPECT_EQ(0x12, output[1]); + EXPECT_EQ(0x34, output[0]); +} + +TEST(byte_operations, TestUint64) { + uint8_t input[] = {0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef}; + EXPECT_EQ(0x1234567890ABCDEFULL, vsomeip_v3::bithelper::read_uint64_be(input)); + + uint8_t output[sizeof(input)] = {0}; + vsomeip_v3::bithelper::write_uint64_be(0x1234567890ABCDEFULL, output); + EXPECT_EQ(0x12, output[0]); + EXPECT_EQ(0x34, output[1]); + EXPECT_EQ(0x56, output[2]); + EXPECT_EQ(0x78, output[3]); + EXPECT_EQ(0x90, output[4]); + EXPECT_EQ(0xab, output[5]); + EXPECT_EQ(0xcd, output[6]); + EXPECT_EQ(0xef, output[7]); +} diff --git a/tools/vsomeip_ctrl.cpp b/tools/vsomeip_ctrl.cpp index 3e74a8322..fd7cd4102 100644 --- a/tools/vsomeip_ctrl.cpp +++ b/tools/vsomeip_ctrl.cpp @@ -7,7 +7,7 @@ #include #include "../implementation/service_discovery/include/constants.hpp" -#include "../implementation/utility/include/byteorder.hpp" +#include "../implementation/utility/include/bithelper.hpp" #include #include @@ -45,16 +45,12 @@ class vsomeip_sender { "is 16 Bytes, exiting."; exit(EXIT_FAILURE); } - service_id_ = VSOMEIP_BYTES_TO_WORD(user_message_[VSOMEIP_SERVICE_POS_MIN], - user_message_[VSOMEIP_SERVICE_POS_MAX]); - method_id_ = VSOMEIP_BYTES_TO_WORD(user_message_[VSOMEIP_METHOD_POS_MIN], - user_message_[VSOMEIP_METHOD_POS_MAX]); - length_ = VSOMEIP_BYTES_TO_LONG(user_message_[VSOMEIP_LENGTH_POS_MIN], - user_message_[VSOMEIP_LENGTH_POS_MIN+1], - user_message_[VSOMEIP_LENGTH_POS_MIN+2], - user_message_[VSOMEIP_LENGTH_POS_MAX]); - client_id_ = VSOMEIP_BYTES_TO_WORD(user_message_[VSOMEIP_CLIENT_POS_MIN], - user_message_[VSOMEIP_CLIENT_POS_MAX]); + + service_id_ = vsomeip::bithelper::read_uint16_be(&user_message_[VSOMEIP_SERVICE_POS_MIN]); + method_id_ = vsomeip::bithelper::read_uint16_be(&user_message_[VSOMEIP_METHOD_POS_MIN]); + length_ = vsomeip::bithelper::read_uint16_be(&user_message_[VSOMEIP_LENGTH_POS_MIN]); + client_id_ = vsomeip::bithelper::read_uint16_be(&user_message_[VSOMEIP_CLIENT_POS_MIN]); + interface_version_ = user_message_[VSOMEIP_INTERFACE_VERSION_POS]; message_type_ = static_cast(user_message_[VSOMEIP_MESSAGE_TYPE_POS]); return_code_ = static_cast(user_message_[VSOMEIP_RETURN_CODE_POS]); @@ -421,7 +417,8 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } } - instance = VSOMEIP_BYTES_TO_WORD(high, low); + uint8_t its_instance[2] = {high, low}; + instance = vsomeip::bithelper::read_uint16_be(its_instance); } } From 025c8f7083294d7dc6e566b2e8fed074870ef071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 11:14:13 +0100 Subject: [PATCH 17/20] Reorder of prepare_stop method --- .../endpoints/src/server_endpoint_impl.cpp | 81 +++++++++---------- .../routing/include/routing_manager_impl.hpp | 2 - .../routing/src/routing_manager_impl.cpp | 80 +++--------------- 3 files changed, 48 insertions(+), 115 deletions(-) diff --git a/implementation/endpoints/src/server_endpoint_impl.cpp b/implementation/endpoints/src/server_endpoint_impl.cpp index 5db9422cb..5e1bf820c 100644 --- a/implementation/endpoints/src/server_endpoint_impl.cpp +++ b/implementation/endpoints/src/server_endpoint_impl.cpp @@ -52,12 +52,23 @@ void server_endpoint_impl::prepare_stop( const endpoint::prepare_stop_handler_t &_handler, service_t _service) { std::lock_guard its_lock(mutex_); - bool queued_train(false); std::vector its_erased; boost::system::error_code ec; - if (_service == ANY_SERVICE) { // endpoint is shutting down completely + if (_service == ANY_SERVICE) { endpoint_impl::sending_blocked_ = true; + if (std::all_of(targets_.begin(), targets_.end(), + [&](const typename target_data_type::value_type &_t) + { return _t.second.queue_.empty(); })) { + // nothing was queued and all queues are empty -> ensure cbk is called + auto ptr = this->shared_from_this(); + endpoint_impl::io_.post([ptr, _handler, _service](){ + _handler(ptr, _service); + }); + } else { + prepare_stop_handlers_[_service] = _handler; + } + for (auto t = targets_.begin(); t != targets_.end(); t++) { auto its_train (t->second.train_); // cancel dispatch timer @@ -65,10 +76,32 @@ void server_endpoint_impl::prepare_stop( if (its_train->buffer_->size() > 0) { if (queue_train(t, its_train)) its_erased.push_back(t); - queued_train = true; } } } else { + // check if any of the queues contains a message of to be stopped service + bool found_service_msg(false); + for (const auto &t : targets_) { + for (const auto &q : t.second.queue_) { + const service_t its_service = bithelper::read_uint16_be(&(*q.first)[VSOMEIP_SERVICE_POS_MIN]); + if (its_service == _service) { + found_service_msg = true; + break; + } + } + if (found_service_msg) { + break; + } + } + if (found_service_msg) { + prepare_stop_handlers_[_service] = _handler; + } else { // no messages of the to be stopped service are or have been queued + auto ptr = this->shared_from_this(); + endpoint_impl::io_.post([ptr, _handler, _service](){ + _handler(ptr, _service); + }); + } + for (auto t = targets_.begin(); t != targets_.end(); t++) { auto its_train(t->second.train_); for (auto const& passenger_iter : its_train->passengers_) { @@ -78,7 +111,6 @@ void server_endpoint_impl::prepare_stop( // TODO: Queue all(!) trains here... if (queue_train(t, its_train)) its_erased.push_back(t); - queued_train = true; break; } } @@ -87,47 +119,6 @@ void server_endpoint_impl::prepare_stop( for (const auto t : its_erased) targets_.erase(t); - - if (!queued_train) { - if (_service == ANY_SERVICE) { - if (std::all_of(targets_.begin(), targets_.end(), - [&](const typename target_data_type::value_type &_t) - { return _t.second.queue_.empty(); })) { - // nothing was queued and all queues are empty -> ensure cbk is called - auto ptr = this->shared_from_this(); - endpoint_impl::io_.post([ptr, _handler, _service](){ - _handler(ptr, _service); - }); - } else { - prepare_stop_handlers_[_service] = _handler; - } - } else { - // check if any of the queues contains a message of to be stopped service - bool found_service_msg(false); - for (const auto &t : targets_) { - for (const auto &q : t.second.queue_) { - const service_t its_service = bithelper::read_uint16_be(&(*q.first)[VSOMEIP_SERVICE_POS_MIN]); - if (its_service == _service) { - found_service_msg = true; - break; - } - } - if (found_service_msg) { - break; - } - } - if (found_service_msg) { - prepare_stop_handlers_[_service] = _handler; - } else { // no messages of the to be stopped service are or have been queued - auto ptr = this->shared_from_this(); - endpoint_impl::io_.post([ptr, _handler, _service](){ - _handler(ptr, _service); - }); - } - } - } else { - prepare_stop_handlers_[_service] = _handler; - } } template diff --git a/implementation/routing/include/routing_manager_impl.hpp b/implementation/routing/include/routing_manager_impl.hpp index 38c0f25a4..b0c3c73b8 100644 --- a/implementation/routing/include/routing_manager_impl.hpp +++ b/implementation/routing/include/routing_manager_impl.hpp @@ -442,8 +442,6 @@ class routing_manager_impl: public routing_manager_base, client_t _client, major_version_t _major, minor_version_t _minor); bool erase_offer_command(service_t _service, instance_t _instance); - bool is_last_stop_callback(const uint32_t _callback_id); - std::string get_env(client_t _client) const; std::string get_env_unlocked(client_t _client) const; diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index 9dacbde29..f395d994a 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -1694,21 +1694,6 @@ void routing_manager_impl::on_notification(client_t _client, } } -bool routing_manager_impl::is_last_stop_callback(const uint32_t _callback_id) { - bool last_callback(false); - auto found_id = callback_counts_.find(_callback_id); - if (found_id != callback_counts_.end()) { - found_id->second--; - if (found_id->second == 0) { - last_callback = true; - } - } - if (last_callback) { - callback_counts_.erase(_callback_id); - } - return last_callback; -} - void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor) { { @@ -1765,8 +1750,6 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se if (its_info) { its_reliable_endpoint = its_info->get_endpoint(true); its_unreliable_endpoint = its_info->get_endpoint(false); - static std::atomic callback_id(0); - const uint32_t its_callback_id = ++callback_id; struct ready_to_stop_t { ready_to_stop_t() : reliable_(false), unreliable_(false){} @@ -1776,45 +1759,33 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se auto ready_to_stop = std::make_shared(); auto ptr = shared_from_this(); - auto callback = [&, its_callback_id, ptr, its_info, its_reliable_endpoint, its_unreliable_endpoint, + auto callback = [&, ptr, its_info, its_reliable_endpoint, its_unreliable_endpoint, ready_to_stop, _service, _instance, _major, _minor] (std::shared_ptr _endpoint, service_t _stopped_service) { (void)_stopped_service; - if (its_reliable_endpoint && its_reliable_endpoint == _endpoint) { + if (its_reliable_endpoint && its_reliable_endpoint == _endpoint) ready_to_stop->reliable_ = true; - } - if (its_unreliable_endpoint && its_unreliable_endpoint == _endpoint) { + if (its_unreliable_endpoint && its_unreliable_endpoint == _endpoint) ready_to_stop->unreliable_ = true; - } + if ((its_unreliable_endpoint && !ready_to_stop->unreliable_) || - (its_reliable_endpoint && !ready_to_stop->reliable_)) { - { - std::lock_guard its_lock(callback_counts_mutex_); - if (is_last_stop_callback(its_callback_id)) { - erase_offer_command(_service, _instance); - } - } + (its_reliable_endpoint && !ready_to_stop->reliable_)) { + erase_offer_command(_service, _instance); return; } if (discovery_) { - if (its_info->get_major() == _major && its_info->get_minor() == _minor) { + if (its_info->get_major() == _major && its_info->get_minor() == _minor) discovery_->stop_offer_service(its_info, true); - } } - del_routing_info(_service, _instance, (its_reliable_endpoint != nullptr), - (its_unreliable_endpoint != nullptr)); + del_routing_info(_service, _instance, (its_reliable_endpoint != nullptr), (its_unreliable_endpoint != nullptr)); for (const auto& ep: {its_reliable_endpoint, its_unreliable_endpoint}) { if (ep) { if (ep_mgr_impl_->remove_instance(_service, ep.get())) { - { - std::lock_guard its_lock(callback_counts_mutex_); - callback_counts_[its_callback_id]++; - } // last instance -> pass ANY_INSTANCE and shutdown completely ep->prepare_stop( - [&, _service, _instance, its_callback_id, ptr, its_reliable_endpoint, its_unreliable_endpoint] + [&, _service, _instance, ptr, its_reliable_endpoint, its_unreliable_endpoint] (std::shared_ptr _endpoint, service_t _stopped_service) { (void)_stopped_service; @@ -1823,49 +1794,22 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se _endpoint->is_reliable())) { _endpoint->stop(); } - { - std::lock_guard its_lock(callback_counts_mutex_); - if (is_last_stop_callback(its_callback_id)) { - erase_offer_command(_service, _instance); - } - } + erase_offer_command(_service, _instance); }, ANY_SERVICE); } // Clear service info and service group clear_service_info(_service, _instance, ep->is_reliable()); } } - { - std::lock_guard its_lock(callback_counts_mutex_); - if (is_last_stop_callback(its_callback_id)) { - erase_offer_command(_service, _instance); - } - } + erase_offer_command(_service, _instance); }; - // determine callback count - for (const auto& ep : {its_reliable_endpoint, its_unreliable_endpoint}) { - if (ep) { - std::lock_guard its_lock(callback_counts_mutex_); - auto found_id = callback_counts_.find(its_callback_id); - if (found_id != callback_counts_.end()) { - found_id->second++; - } else { - callback_counts_[its_callback_id] = 1; - } - } - } for (const auto& ep : {its_reliable_endpoint, its_unreliable_endpoint}) { - if (ep) { + if (ep) ep->prepare_stop(callback, _service); - } } if (!its_reliable_endpoint && !its_unreliable_endpoint) { - { - std::lock_guard its_lock(callback_counts_mutex_); - callback_counts_.erase(its_callback_id); - } erase_offer_command(_service, _instance); } From 0b1e3b7593d736115dc472b0b6c385a4696e1204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 11:19:05 +0100 Subject: [PATCH 18/20] Allows applications in the same process using different security configurations --- exportmap.gcc | 2 +- .../configuration/include/configuration.hpp | 4 + .../include/configuration_impl.hpp | 5 + .../include/configuration_plugin_impl.hpp | 3 - .../configuration/src/configuration_impl.cpp | 30 ++- .../src/configuration_plugin_impl.cpp | 11 +- .../src/local_tcp_server_endpoint_impl.cpp | 4 +- .../src/local_uds_server_endpoint_impl.cpp | 10 +- .../plugin/include/plugin_manager_impl.hpp | 2 +- .../routing/src/routing_manager_base.cpp | 8 +- .../routing/src/routing_manager_client.cpp | 85 ++++----- .../routing/src/routing_manager_impl.cpp | 18 +- .../routing/src/routing_manager_stub.cpp | 32 ++-- .../runtime/include/application_impl.hpp | 1 + .../runtime/src/application_impl.cpp | 8 +- .../security/include/policy_manager_impl.hpp | 2 - implementation/security/include/security.hpp | 35 ++-- .../security/src/policy_manager.cpp | 17 -- .../security/src/policy_manager_impl.cpp | 39 ---- implementation/security/src/security.cpp | 179 ++++++++++-------- interface/vsomeip/application.hpp | 15 ++ .../vsomeip/internal}/plugin_manager.hpp | 1 + interface/vsomeip/internal/policy_manager.hpp | 5 +- test/network_tests/CMakeLists.txt | 1 - .../configuration-test.cpp | 8 +- 25 files changed, 260 insertions(+), 265 deletions(-) delete mode 100644 implementation/security/src/policy_manager.cpp rename {implementation/plugin/include => interface/vsomeip/internal}/plugin_manager.hpp (93%) diff --git a/exportmap.gcc b/exportmap.gcc index 5939e6c4c..8533a761c 100644 --- a/exportmap.gcc +++ b/exportmap.gcc @@ -27,7 +27,7 @@ global: vsomeip_v3::policy_manager::*; *vsomeip_v3::policy_manager_impl; vsomeip_v3::policy_manager_impl::*; - vsomeip_v3::security::authenticate_router; + vsomeip_v3::security::*; *vsomeip_v3::runtime; vsomeip_v3::runtime::get*; vsomeip_v3::runtime::set_property*; diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp index 0260a1023..ce460152b 100644 --- a/implementation/configuration/include/configuration.hpp +++ b/implementation/configuration/include/configuration.hpp @@ -39,6 +39,8 @@ namespace vsomeip_v3 { +class policy_manager_impl; +class security; class event; struct debounce_filter_impl_t; @@ -309,6 +311,8 @@ class configuration { virtual bool is_security_external() const = 0; virtual bool is_security_audit() const = 0; virtual bool is_remote_access_allowed() const = 0; + virtual std::shared_ptr get_policy_manager() const = 0; + virtual std::shared_ptr get_security() const = 0; }; } // namespace vsomeip_v3 diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp index a229d8b1e..267368fe1 100644 --- a/implementation/configuration/include/configuration_impl.hpp +++ b/implementation/configuration/include/configuration_impl.hpp @@ -296,6 +296,8 @@ class configuration_impl: VSOMEIP_EXPORT bool is_security_audit() const; VSOMEIP_EXPORT bool is_remote_access_allowed() const; + VSOMEIP_EXPORT std::shared_ptr get_policy_manager() const; + VSOMEIP_EXPORT std::shared_ptr get_security() const; private: void read_data(const std::set &_input, std::vector &_elements, @@ -478,6 +480,9 @@ class configuration_impl: std::set mandatory_; + std::shared_ptr policy_manager_; + std::shared_ptr security_; + protected: // Configuration data boost::asio::ip::address unicast_; diff --git a/implementation/configuration/include/configuration_plugin_impl.hpp b/implementation/configuration/include/configuration_plugin_impl.hpp index 3fcfbefcd..695bc6c1b 100644 --- a/implementation/configuration/include/configuration_plugin_impl.hpp +++ b/implementation/configuration/include/configuration_plugin_impl.hpp @@ -32,10 +32,7 @@ class configuration_plugin_impl private: std::mutex mutex_; - std::shared_ptr default_; -#if 0 std::map > configurations_; -#endif }; } // namespace vsomeip_v3 diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index 4b12171b3..36f75617b 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "../include/client.hpp" #include "../include/configuration_impl.hpp" @@ -37,7 +38,6 @@ #include "../../routing/include/event.hpp" #include "../../service_discovery/include/defines.hpp" #include "../../utility/include/utility.hpp" -#include "../../plugin/include/plugin_manager.hpp" #include "../../security/include/policy_manager_impl.hpp" #include "../../security/include/security.hpp" @@ -107,6 +107,8 @@ configuration_impl::configuration_impl(const std::string &_path) is_security_audit_(false), is_remote_access_allowed_(true) { + policy_manager_ = std::make_shared(); + security_ = std::make_shared(policy_manager_); unicast_ = unicast_.from_string(VSOMEIP_UNICAST_ADDRESS); netmask_ = netmask_.from_string(VSOMEIP_NETMASK); for (auto i = 0; i < ET_MAX; i++) @@ -362,7 +364,7 @@ bool configuration_impl::load(const std::string &_name) { bool configuration_impl::lazy_load_security(const std::string &_client_host) { bool result(false); - std::string its_folder = policy_manager_impl::get()->get_policy_extension_path(_client_host); + std::string its_folder = policy_manager_->get_policy_extension_path(_client_host); if (!its_folder.empty()) { std::set its_input; std::set its_failed; @@ -370,7 +372,7 @@ bool configuration_impl::lazy_load_security(const std::string &_client_host) { its_input.insert(its_folder); // load security configuration files from UID_GID sub folder if existing - std::string its_security_config_folder = policy_manager_impl::get()->get_security_config_folder(its_folder); + std::string its_security_config_folder = policy_manager_->get_security_config_folder(its_folder); if (!its_security_config_folder.empty()) its_input.insert(its_security_config_folder); @@ -378,7 +380,7 @@ bool configuration_impl::lazy_load_security(const std::string &_client_host) { read_data(its_input, its_mandatory_elements, its_failed, true, true); for (const auto& e : its_mandatory_elements) { - policy_manager_impl::get()->load(e, true); + policy_manager_->load(e, true); } for (auto f : its_failed) @@ -387,7 +389,7 @@ bool configuration_impl::lazy_load_security(const std::string &_client_host) { result = (its_failed.empty() && !its_mandatory_elements.empty()); if (result) - policy_manager_impl::get()->set_is_policy_extension_loaded(_client_host, true); + policy_manager_->set_is_policy_extension_loaded(_client_host, true); } return result; @@ -399,7 +401,7 @@ configuration_impl::check_routing_credentials( client_t _client, const vsomeip_sec_client_t *_sec_client) const { return (_client != get_id(routing_.host_.name_) || - VSOMEIP_SEC_OK == security::authenticate_router(_sec_client)); + VSOMEIP_SEC_OK == security_->authenticate_router(_sec_client)); } bool configuration_impl::remote_offer_info_add(service_t _service, @@ -534,8 +536,8 @@ void configuration_impl::load_policy_data(const std::string &_input, bool _mandatory_only) { if (is_mandatory(_input) == _mandatory_only) { #ifndef VSOMEIP_DISABLE_SECURITY - if (policy_manager_impl::get()->is_policy_extension(_input)) { - policy_manager_impl::get()->set_policy_extension_base_path(_input); + if (policy_manager_->is_policy_extension(_input)) { + policy_manager_->set_policy_extension_base_path(_input); } #endif boost::property_tree::ptree its_tree; @@ -847,7 +849,7 @@ configuration_impl::load_routing_host(const boost::property_tree::ptree &_tree, } if (has_uid && has_gid) { - policy_manager_impl::get()->set_routing_credentials(its_uid, its_gid, _name); + policy_manager_->set_routing_credentials(its_uid, its_gid, _name); } } catch (...) { @@ -2701,7 +2703,7 @@ void configuration_impl::load_security(const configuration_element &_element) { #ifndef VSOMEIP_DISABLE_SECURITY if (!is_security_external()) - policy_manager_impl::get()->load(_element); + policy_manager_->load(_element); #endif // !VSOMEIP_DISABLE_SECURITY } @@ -5040,5 +5042,13 @@ configuration_impl::is_remote_access_allowed() const { return is_remote_access_allowed_; } +std::shared_ptr configuration_impl::get_policy_manager() const { + return policy_manager_; +} + +std::shared_ptr configuration_impl::get_security() const { + return security_; +} + } // namespace cfg } // namespace vsomeip_v3 diff --git a/implementation/configuration/src/configuration_plugin_impl.cpp b/implementation/configuration/src/configuration_plugin_impl.cpp index 89f47b6d0..729505069 100644 --- a/implementation/configuration/src/configuration_plugin_impl.cpp +++ b/implementation/configuration/src/configuration_plugin_impl.cpp @@ -25,14 +25,6 @@ std::shared_ptr configuration_plugin_impl::get_configuration(const std::string &_name, const std::string &_path) { - std::lock_guard its_lock(mutex_); - if (!default_) { - default_ = std::make_shared(_path); - default_->load(_name); - } - return default_; - -#if 0 std::shared_ptr its_configuration; auto its_iterator = configurations_.find(_name); if (its_iterator != configurations_.end()) { @@ -44,7 +36,6 @@ configuration_plugin_impl::get_configuration(const std::string &_name, } return its_configuration; -#endif -} +} } // namespace vsomeip_v3 diff --git a/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp index f5e35f64c..bec74ed81 100644 --- a/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp @@ -647,7 +647,7 @@ void local_tcp_server_endpoint_impl::connection::receive_cbk( = htonl(uint32_t(its_address.to_v4().to_ulong())); } sec_client_.port = htons(its_port); - security::sync_client(&sec_client_); + its_server->configuration_->get_security()->sync_client(&sec_client_); its_host->on_message(&recv_buffer_[its_start], uint32_t(its_end - its_start), its_server.get(), @@ -701,7 +701,7 @@ void local_tcp_server_endpoint_impl::connection::receive_cbk( || is_error) { shutdown_and_close(); its_server->remove_connection(bound_client_); - policy_manager_impl::get()->remove_client_to_sec_client_mapping(bound_client_); + its_server->configuration_->get_policy_manager()->remove_client_to_sec_client_mapping(bound_client_); } else if (_error != boost::asio::error::bad_descriptor) { start(); } diff --git a/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp b/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp index 8bf1a5537..bbc72f861 100644 --- a/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/local_uds_server_endpoint_impl.cpp @@ -341,7 +341,7 @@ void local_uds_server_endpoint_impl::accept_cbk( std::shared_ptr its_routing_host = routing_host_.lock(); its_routing_host->add_known_client(its_client, its_client_host); - if (!policy_manager_impl::get()->check_credentials(its_client, &its_sec_client)) { + if (!configuration_->get_policy_manager()->check_credentials(its_client, &its_sec_client)) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << its_host->get_client() << " received client credentials from client 0x" << its_client << " which violates the security policy : uid/gid=" @@ -358,8 +358,8 @@ void local_uds_server_endpoint_impl::accept_cbk( add_connection(its_client, _connection); } } else { - policy_manager_impl::get()->store_client_to_sec_client_mapping(its_client, &its_sec_client); - policy_manager_impl::get()->store_sec_client_to_client_mapping(&its_sec_client, its_client); + configuration_->get_policy_manager()->store_client_to_sec_client_mapping(its_client, &its_sec_client); + configuration_->get_policy_manager()->store_sec_client_to_client_mapping(&its_sec_client, its_client); if (!is_routing_endpoint_) { std::shared_ptr its_routing_host = routing_host_.lock(); @@ -776,7 +776,7 @@ void local_uds_server_endpoint_impl::connection::receive_cbk( << " because of already existing connection using same client ID"; stop(); return; - } else if (!policy_manager_impl::get()->check_credentials( + } else if (!its_server->configuration_->get_policy_manager()->check_credentials( its_client, &sec_client_)) { VSOMEIP_WARNING << std::hex << "Client 0x" << its_host->get_client() << " received client credentials from client 0x" << its_client @@ -854,7 +854,7 @@ void local_uds_server_endpoint_impl::connection::receive_cbk( || is_error) { shutdown_and_close(); its_server->remove_connection(bound_client_); - policy_manager_impl::get()->remove_client_to_sec_client_mapping(bound_client_); + its_server->configuration_->get_policy_manager()->remove_client_to_sec_client_mapping(bound_client_); } else if (_error != boost::asio::error::bad_descriptor) { start(); } diff --git a/implementation/plugin/include/plugin_manager_impl.hpp b/implementation/plugin/include/plugin_manager_impl.hpp index e88772e60..9f755d60c 100644 --- a/implementation/plugin/include/plugin_manager_impl.hpp +++ b/implementation/plugin/include/plugin_manager_impl.hpp @@ -6,7 +6,7 @@ #ifndef VSOMEIP_V3_PLUGIN_MANAGER_IMPL_HPP #define VSOMEIP_V3_PLUGIN_MANAGER_IMPL_HPP -#include "../include/plugin_manager.hpp" +#include #include #include diff --git a/implementation/routing/src/routing_manager_base.cpp b/implementation/routing/src/routing_manager_base.cpp index bfafe4eda..39026c648 100644 --- a/implementation/routing/src/routing_manager_base.cpp +++ b/implementation/routing/src/routing_manager_base.cpp @@ -700,7 +700,7 @@ bool routing_manager_base::is_subscribe_to_any_event_allowed( auto its_eventgroup = find_eventgroup(_service, _instance, _eventgroup); if (its_eventgroup) { for (const auto& e : its_eventgroup->get_events()) { - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member( + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( _sec_client, _service, _instance, e->get_event())) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << _client << " : routing_manager_base::is_subscribe_to_any_event_allowed: " @@ -722,7 +722,7 @@ void routing_manager_base::add_known_client(client_t _client, const std::string if (configuration_->is_security_enabled() && !configuration_->is_security_external()) { //Ignore if we have already loaded the policy extension policy_manager_impl::policy_loaded_e policy_loaded - = policy_manager_impl::get()->is_policy_extension_loaded(_client_host); + = configuration_->get_policy_manager()->is_policy_extension_loaded(_client_host); if (policy_loaded == policy_manager_impl::policy_loaded_e::POLICY_PATH_FOUND_AND_NOT_LOADED) { @@ -1154,10 +1154,10 @@ void routing_manager_base::remove_local(client_t _client, bool _remove_sec_client) { vsomeip_sec_client_t its_sec_client; - policy_manager_impl::get()->get_client_to_sec_client_mapping(_client, its_sec_client); + configuration_->get_policy_manager()->get_client_to_sec_client_mapping(_client, its_sec_client); if (_remove_sec_client) { - policy_manager_impl::get()->remove_client_to_sec_client_mapping(_client); + configuration_->get_policy_manager()->remove_client_to_sec_client_mapping(_client); } for (auto its_subscription : _subscribed_eventgroups) { host_->on_subscription(std::get<0>(its_subscription), std::get<1>(its_subscription), diff --git a/implementation/routing/src/routing_manager_client.cpp b/implementation/routing/src/routing_manager_client.cpp index 07e0bd3da..99d99090d 100644 --- a/implementation/routing/src/routing_manager_client.cpp +++ b/implementation/routing/src/routing_manager_client.cpp @@ -652,7 +652,7 @@ void routing_manager_client::send_subscribe(client_t _client, return; } } else { - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member( + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( get_sec_client(), _service, _instance, _event)) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << _client << " : routing_manager_proxy::subscribe: " @@ -1031,8 +1031,8 @@ void routing_manager_client::on_message( std::vector its_buffer(_data, _data + _size); protocol::error_e its_error; - auto its_security = policy_manager_impl::get(); - if (!its_security) + auto its_policy_manager = configuration_->get_policy_manager(); + if (!its_policy_manager) return; protocol::dummy_command its_dummy_command; @@ -1103,8 +1103,8 @@ void routing_manager_client::on_message( << " ~> Skip message!"; return; } else { - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member(get_sec_client(), - its_message->get_service(), its_message->get_instance(), + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( + get_sec_client(), its_message->get_service(), its_message->get_instance(), its_message->get_method())) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << std::setw(4) << std::setfill('0') << get_client() @@ -1133,8 +1133,8 @@ void routing_manager_client::on_message( << " ~> skip message!"; return; } - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member(_sec_client, - its_message->get_service(), its_message->get_instance(), + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( + _sec_client, its_message->get_service(), its_message->get_instance(), its_message->get_method())) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << std::setw(4) << std::setfill('0') << its_message->get_client() @@ -1158,8 +1158,8 @@ void routing_manager_client::on_message( << " ~> Skip message!"; return; } else { - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member(get_sec_client(), - its_message->get_service(), its_message->get_instance(), + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( + get_sec_client(), its_message->get_service(), its_message->get_instance(), its_message->get_method())) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << std::setw(4) << std::setfill('0') << get_client() @@ -1191,8 +1191,8 @@ void routing_manager_client::on_message( // As subscription is sent on eventgroup level, incoming remote event ID's // need to be checked as well if remote clients are allowed // and the local policy only allows specific events in the eventgroup to be received. - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member(get_sec_client(), - its_message->get_service(), its_message->get_instance(), + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( + get_sec_client(), its_message->get_service(), its_message->get_instance(), its_message->get_method())) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() << " : routing_manager_client::on_message: " @@ -1356,7 +1356,7 @@ void routing_manager_client::on_message( return; } } else { - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member( + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( _sec_client, its_service, its_instance, its_event)) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << its_client << " : routing_manager_client::on_message: " @@ -1648,8 +1648,8 @@ void routing_manager_client::on_message( uint32_t its_gid; if (its_policy->get_uid_gid(its_uid, its_gid)) { if (is_internal_policy_update - || its_security->is_policy_update_allowed(its_uid, its_policy)) { - its_security->update_security_policy(its_uid, its_gid, its_policy); + || its_policy_manager->is_policy_update_allowed(its_uid, its_policy)) { + its_policy_manager->update_security_policy(its_uid, its_gid, its_policy); send_update_security_policy_response(its_command.get_update_id()); } } else { @@ -1678,8 +1678,8 @@ void routing_manager_client::on_message( uid_t its_uid(its_command.get_uid()); gid_t its_gid(its_command.get_gid()); - if (its_security->is_policy_removal_allowed(its_uid)) { - its_security->remove_security_policy(its_uid, its_gid); + if (its_policy_manager->is_policy_removal_allowed(its_uid)) { + its_policy_manager->remove_security_policy(its_uid, its_gid); send_remove_security_policy_response(its_command.get_update_id()); } } else @@ -1706,8 +1706,8 @@ void routing_manager_client::on_message( uid_t its_uid; gid_t its_gid; p->get_uid_gid(its_uid, its_gid); - if (its_security->is_policy_update_allowed(its_uid, p)) - its_security->update_security_policy(its_uid, its_gid, p); + if (its_policy_manager->is_policy_update_allowed(its_uid, p)) + its_policy_manager->update_security_policy(its_uid, its_gid, p); } } else VSOMEIP_ERROR << __func__ @@ -1764,8 +1764,8 @@ void routing_manager_client::on_routing_info( msg << std::hex << std::setw(2) << std::setfill('0') << (int)_data[i] << " "; VSOMEIP_INFO << msg.str(); #endif - auto its_security = policy_manager_impl::get(); - if (!its_security) + auto its_policy_manager = configuration_->get_policy_manager(); + if (!its_policy_manager) return; std::vector its_buffer(_data, _data + _size); @@ -1797,11 +1797,10 @@ void routing_manager_client::on_routing_info( << std::hex << std::setw(4) << std::setfill('0') << get_client() << " (" << host_->get_name() << ") is registered."; #if defined(__linux__) || defined(ANDROID) || defined(__QNX__) - if (!its_security->check_credentials(get_client(), get_sec_client())) { - VSOMEIP_ERROR << "vSomeIP Security: Client 0x" - << std::hex << std::setw(4) << std::setfill('0') << get_client() - << " : routing_manager_client::on_routing_info: RIE_ADD_CLIENT: isn't allowed" - << " to use the server endpoint due to credential check failed!"; + if (!its_policy_manager->check_credentials(get_client(), get_sec_client())) { + VSOMEIP_ERROR << "vSomeIP Security: Client 0x" << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::on_routing_info: RIE_ADD_CLIENT: isn't allowed" + << " to use the server endpoint due to credential check failed!"; deregister_application(); host_->on_state(static_cast(inner_state_type_e::ST_DEREGISTERED)); return; @@ -1835,10 +1834,9 @@ void routing_manager_client::on_routing_info( known_clients_.erase(its_client); } if (its_client == get_client()) { - its_security->remove_client_to_sec_client_mapping(its_client); - VSOMEIP_INFO << "Application/Client " - << std::hex << std::setw(4) << std::setfill('0') << get_client() - << " (" << host_->get_name() << ") is deregistered."; + its_policy_manager->remove_client_to_sec_client_mapping(its_client); + VSOMEIP_INFO << "Application/Client " << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " (" << host_->get_name() << ") is deregistered."; // inform host about its own registration state changes host_->on_state(static_cast(inner_state_type_e::ST_DEREGISTERED)); @@ -2034,8 +2032,8 @@ void routing_manager_client::on_offered_services_info( } void routing_manager_client::reconnect(const std::map &_clients) { - auto its_security = policy_manager_impl::get(); - if (!its_security) + auto its_policy_manager = configuration_->get_policy_manager(); + if (!its_policy_manager) return; // inform host about its own registration state changes @@ -2061,11 +2059,10 @@ void routing_manager_client::reconnect(const std::map &_c <<": Reconnecting to routing manager."; #if defined(__linux__) || defined(ANDROID) || defined(__QNX__) - if (!its_security->check_credentials(get_client(), get_sec_client())) { - VSOMEIP_ERROR << "vSomeIP Security: Client 0x" - << std::hex << std::setw(4) << std::setfill('0') << get_client() - << " : routing_manager_client::reconnect: isn't allowed" - << " to use the server endpoint due to credential check failed!"; + if (!its_policy_manager->check_credentials(get_client(), get_sec_client())) { + VSOMEIP_ERROR << "vSomeIP Security: Client 0x" << std::hex << std::setw(4) << std::setfill('0') << get_client() + << " : routing_manager_client::reconnect: isn't allowed" + << " to use the server endpoint due to credential check failed!"; std::lock_guard its_lock(sender_mutex_); if (sender_) { sender_->stop(); @@ -2453,13 +2450,13 @@ void routing_manager_client::send_pending_commands() { } void routing_manager_client::init_receiver() { -#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) - auto its_security = policy_manager_impl::get(); - if (!its_security) +#ifdef __linux__ + auto its_policy_manager = configuration_->get_policy_manager(); + if (!its_policy_manager) return; - its_security->store_client_to_sec_client_mapping(get_client(), get_sec_client()); - its_security->store_sec_client_to_client_mapping(get_sec_client(), get_client()); + its_policy_manager->store_client_to_sec_client_mapping(get_client(), get_sec_client()); + its_policy_manager->store_sec_client_to_client_mapping(get_sec_client(), get_client()); #endif if (!receiver_) { receiver_ = ep_mgr_->create_local_server(shared_from_this()); @@ -2861,8 +2858,8 @@ void routing_manager_client::send_remove_security_policy_response( void routing_manager_client::on_update_security_credentials( const protocol::update_security_credentials_command &_command) { - auto its_security = policy_manager_impl::get(); - if (!its_security) + auto its_policy_manager = configuration_->get_policy_manager(); + if (!its_policy_manager) return; for (const auto &c : _command.get_credentials()) { @@ -2878,7 +2875,7 @@ void routing_manager_client::on_update_security_credentials( its_policy->allow_who_ = true; its_policy->allow_what_ = true; - its_security->add_security_credentials(its_uid, its_gid, its_policy, get_client()); + its_policy_manager->add_security_credentials(its_uid, its_gid, its_policy, get_client()); } } #endif diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index f395d994a..77a4d67b0 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -423,7 +423,7 @@ bool routing_manager_impl::offer_service(client_t _client, // Check if the application hosted by routing manager is allowed to offer // offer_service requests of local proxies are checked in rms::on:message if (_client == get_client()) { - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_offer( + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_offer( get_sec_client(), _service, _instance)) { VSOMEIP_WARNING << "routing_manager_impl::offer_service: " << std::hex << "Security: Client 0x" << _client @@ -1869,8 +1869,8 @@ bool routing_manager_impl::deliver_message(const byte_t *_data, length_t _size, << " ~> Skip message!"; return false; } else { - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member(get_sec_client(), - its_message->get_service(), its_message->get_instance(), + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( + get_sec_client(), its_message->get_service(), its_message->get_instance(), its_message->get_method())) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() << " : routing_manager_impl::deliver_message: " @@ -1897,8 +1897,8 @@ bool routing_manager_impl::deliver_message(const byte_t *_data, length_t _size, return false; } - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member(_sec_client, - its_message->get_service(), its_message->get_instance(), + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( + _sec_client, its_message->get_service(), its_message->get_instance(), its_message->get_method())) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() << " : routing_manager_impl::deliver_message: " @@ -1920,8 +1920,8 @@ bool routing_manager_impl::deliver_message(const byte_t *_data, length_t _size, << " ~> Skip message!"; return false; } else { - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member(get_sec_client(), - its_message->get_service(), its_message->get_instance(), + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( + get_sec_client(), its_message->get_service(), its_message->get_instance(), its_message->get_method())) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() << " : routing_manager_impl::deliver_message: " @@ -1948,8 +1948,8 @@ bool routing_manager_impl::deliver_message(const byte_t *_data, length_t _size, << " ~> Skip message!"; return false; } else if (utility::is_notification(its_message->get_message_type())) { - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member(get_sec_client(), - its_message->get_service(), its_message->get_instance(), + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( + get_sec_client(), its_message->get_service(), its_message->get_instance(), its_message->get_method())) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << get_client() << " : routing_manager_impl::deliver_message: " diff --git a/implementation/routing/src/routing_manager_stub.cpp b/implementation/routing/src/routing_manager_stub.cpp index 55461aadc..3a6d6a646 100644 --- a/implementation/routing/src/routing_manager_stub.cpp +++ b/implementation/routing/src/routing_manager_stub.cpp @@ -346,7 +346,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, its_major = its_command.get_major(); its_minor = its_command.get_minor(); - if (VSOMEIP_SEC_OK == security::is_client_allowed_to_offer( + if (VSOMEIP_SEC_OK == configuration_->get_security()->is_client_allowed_to_offer( _sec_client, its_service, its_instance)) { host_->offer_service(its_client, its_service, its_instance, its_major, its_minor); @@ -412,7 +412,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, << " which violates the security policy ~> Skip subscribe!"; } } else { - if (VSOMEIP_SEC_OK == security::is_client_allowed_to_access_member( + if (VSOMEIP_SEC_OK == configuration_->get_security()->is_client_allowed_to_access_member( _sec_client, its_service, its_instance, its_notifier)) { host_->subscribe(its_client, _sec_client, its_service, its_instance, its_eventgroup, its_major, its_notifier, its_filter); @@ -564,7 +564,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, // Allow response messages from local proxies as answer to remote requests // but check requests sent by local proxies to remote against policy. if (utility::is_request(its_message_data[VSOMEIP_MESSAGE_TYPE_POS])) { - if (VSOMEIP_SEC_OK != security::is_client_allowed_to_access_member( + if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( _sec_client, its_service, its_instance, its_method)) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << its_client << " : routing_manager_stub::on_message: " @@ -628,7 +628,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, std::set its_allowed_requests; for (const auto &r : its_requests) { - if (VSOMEIP_SEC_OK == security::is_client_allowed_to_request( + if (VSOMEIP_SEC_OK == configuration_->get_security()->is_client_allowed_to_request( _sec_client, r.service_, r.instance_)) { host_->request_service(its_client, r.service_, r.instance_, r.major_, r.minor_); @@ -821,7 +821,7 @@ void routing_manager_stub::on_register_application(client_t _client) { vsomeip_sec_client_t its_sec_client; std::set > its_policies; - bool has_mapping = policy_manager_impl::get() + bool has_mapping = configuration_->get_policy_manager() ->get_client_to_sec_client_mapping(_client, its_sec_client); if (has_mapping) { if (its_sec_client.port == VSOMEIP_SEC_PORT_UNUSED) { @@ -1207,14 +1207,14 @@ void routing_manager_stub::distribute_credentials(client_t _hoster, service_t _s // search for UID / GID linked with the client ID that offers the requested services vsomeip_sec_client_t its_sec_client; - if (policy_manager_impl::get()->get_client_to_sec_client_mapping(_hoster, its_sec_client)) { + if (configuration_->get_policy_manager()->get_client_to_sec_client_mapping(_hoster, its_sec_client)) { std::pair its_uid_gid; its_uid_gid.first = its_sec_client.user; its_uid_gid.second = its_sec_client.group; its_credentials.insert(its_uid_gid); for (auto its_requesting_client : its_requesting_clients) { vsomeip_sec_client_t its_requester_sec_client; - if (policy_manager_impl::get()->get_client_to_sec_client_mapping( + if (configuration_->get_policy_manager()->get_client_to_sec_client_mapping( its_requesting_client, its_requester_sec_client)) { if (!utility::compare(its_sec_client, its_requester_sec_client)) send_client_credentials(its_requesting_client, its_credentials); @@ -1582,8 +1582,8 @@ void routing_manager_stub::create_local_receiver() { if (local_receiver_) { return; } -#if defined(__linux__) || defined(ANDROID) - else if (!policy_manager_impl::get()->check_credentials(get_client(), host_->get_sec_client())) { +#ifdef __linux__ + else if (!configuration_->get_policy_manager()->check_credentials(get_client(), host_->get_sec_client())) { VSOMEIP_ERROR << "vSomeIP Security: Client 0x" << std::hex << get_client() << " : routing_manager_stub::create_local_receiver: isn't allowed" << " to create a server endpoint due to credential check failed!"; @@ -1779,7 +1779,7 @@ void routing_manager_stub::update_registration(client_t _client, "registering." : "deregistering."); if (_type != registration_type_e::REGISTER) { - policy_manager_impl::get()->remove_client_to_sec_client_mapping(_client); + configuration_->get_policy_manager()->remove_client_to_sec_client_mapping(_client); } else { if (_port > 0 && _port < ILLEGAL_PORT) host_->add_guest(_client, _address, _port); @@ -1830,7 +1830,7 @@ void routing_manager_stub::handle_credentials(const client_t _client, std::set

its_guard(routing_info_mutex_); std::set> its_credentials; vsomeip_sec_client_t its_requester_sec_client; - if (policy_manager_impl::get()->get_client_to_sec_client_mapping(_client, its_requester_sec_client)) { + if (configuration_->get_policy_manager()->get_client_to_sec_client_mapping(_client, its_requester_sec_client)) { // determine credentials of offering clients using current routing info std::set its_offering_clients; @@ -1846,7 +1846,7 @@ void routing_manager_stub::handle_credentials(const client_t _client, std::set

get_client_to_sec_client_mapping(its_offering_client, its_sec_client)) { + if (configuration_->get_policy_manager()->get_client_to_sec_client_mapping(its_offering_client, its_sec_client)) { if (its_sec_client.port == VSOMEIP_SEC_PORT_UNUSED && !utility::compare(its_sec_client, its_requester_sec_client)) { @@ -2197,7 +2197,7 @@ routing_manager_stub::add_requester_policies(uid_t _uid, gid_t _gid, // Check whether clients with uid/gid are already registered. // If yes, update their policy std::unordered_set its_clients; - policy_manager_impl::get()->get_clients(_uid, _gid, its_clients); + configuration_->get_policy_manager()->get_clients(_uid, _gid, its_clients); if (!its_clients.empty()) return send_requester_policies(its_clients, _policies); @@ -2374,11 +2374,11 @@ bool routing_manager_stub::update_security_policy_configuration( policy_cache_add(_uid, _payload); // update security policy from configuration - policy_manager_impl::get()->update_security_policy(_uid, _gid, _policy); + configuration_->get_policy_manager()->update_security_policy(_uid, _gid, _policy); // Build requester policies for the services offered by the new policy std::set > its_requesters; - policy_manager_impl::get()->get_requester_policies(_policy, its_requesters); + configuration_->get_policy_manager()->get_requester_policies(_policy, its_requesters); // and add them to the requester policy cache add_requester_policies(_uid, _gid, its_requesters); @@ -2437,7 +2437,7 @@ bool routing_manager_stub::remove_security_policy_configuration( // remove security policy from configuration (only if there was a updateACL call before) if (is_policy_cached(_uid)) { - if (!policy_manager_impl::get()->remove_security_policy(_uid, _gid)) { + if (!configuration_->get_policy_manager()->remove_security_policy(_uid, _gid)) { _handler(security_update_state_e::SU_UNKNOWN_USER_ID); ret = false; } else { diff --git a/implementation/runtime/include/application_impl.hpp b/implementation/runtime/include/application_impl.hpp index c647b5316..5a6ba447c 100644 --- a/implementation/runtime/include/application_impl.hpp +++ b/implementation/runtime/include/application_impl.hpp @@ -148,6 +148,7 @@ class application_impl: public application, VSOMEIP_EXPORT void set_sec_client_port(port_t _port); VSOMEIP_EXPORT diagnosis_t get_diagnosis() const; VSOMEIP_EXPORT std::shared_ptr get_configuration() const; + VSOMEIP_EXPORT std::shared_ptr get_policy_manager() const; VSOMEIP_EXPORT std::shared_ptr get_public_configuration() const; VSOMEIP_EXPORT boost::asio::io_context &get_io(); diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp index db880b42d..63b8328e8 100644 --- a/implementation/runtime/src/application_impl.cpp +++ b/implementation/runtime/src/application_impl.cpp @@ -190,9 +190,9 @@ bool application_impl::init() { // Set security mode if (configuration_->is_security_enabled()) { if (configuration_->is_security_external()) { - if (security::load()) { + if (configuration_->get_security()->load()) { VSOMEIP_INFO << "Using external security implementation!"; - auto its_result = security::initialize(); + auto its_result = configuration_->get_security()->initialize(); if (VSOMEIP_SEC_POLICY_OK != its_result) VSOMEIP_ERROR << "Intializing external security implementation failed (" << std::dec << its_result << ')'; @@ -1490,6 +1490,10 @@ std::shared_ptr application_impl::get_configuration() const { return configuration_; } +std::shared_ptr application_impl::get_policy_manager() const { + return configuration_->get_policy_manager(); +} + diagnosis_t application_impl::get_diagnosis() const { return configuration_->get_diagnosis_address(); } diff --git a/implementation/security/include/policy_manager_impl.hpp b/implementation/security/include/policy_manager_impl.hpp index 35c1108ca..6d95aa6da 100644 --- a/implementation/security/include/policy_manager_impl.hpp +++ b/implementation/security/include/policy_manager_impl.hpp @@ -37,8 +37,6 @@ class VSOMEIP_IMPORT_EXPORT policy_manager_impl POLICY_PATH_INEXISTENT = 0x2 }; - static std::shared_ptr get(); - policy_manager_impl(); #ifndef VSOMEIP_DISABLE_SECURITY diff --git a/implementation/security/include/security.hpp b/implementation/security/include/security.hpp index 0eda37f54..5736776fd 100644 --- a/implementation/security/include/security.hpp +++ b/implementation/security/include/security.hpp @@ -6,29 +6,38 @@ #ifndef VSOMEIP_V3_SECURITY_HPP_ #define VSOMEIP_V3_SECURITY_HPP_ +#include +#include + #include #include +#include "policy_manager_impl.hpp" + namespace vsomeip_v3 { class VSOMEIP_IMPORT_EXPORT security { public: - static bool load(); + security(std::shared_ptr _policy_manager); + bool load(); - static decltype(&vsomeip_sec_policy_initialize) initialize; - static decltype(&vsomeip_sec_policy_authenticate_router) authenticate_router; - static decltype(&vsomeip_sec_policy_is_client_allowed_to_offer) is_client_allowed_to_offer; - static decltype(&vsomeip_sec_policy_is_client_allowed_to_request) is_client_allowed_to_request; - static decltype(&vsomeip_sec_policy_is_client_allowed_to_access_member) is_client_allowed_to_access_member; - static decltype(&vsomeip_sec_sync_client) sync_client; + std::function initialize; + std::function authenticate_router; + std::function is_client_allowed_to_offer; + std::function is_client_allowed_to_request; + std::function is_client_allowed_to_access_member; + std::function sync_client; private: - static decltype(vsomeip_sec_policy_initialize) default_initialize; - static decltype(vsomeip_sec_policy_authenticate_router) default_authenticate_router; - static decltype(vsomeip_sec_policy_is_client_allowed_to_offer) default_is_client_allowed_to_offer; - static decltype(vsomeip_sec_policy_is_client_allowed_to_request) default_is_client_allowed_to_request; - static decltype(vsomeip_sec_policy_is_client_allowed_to_access_member) default_is_client_allowed_to_access_member; - static decltype(vsomeip_sec_sync_client) default_sync_client; + + decltype(vsomeip_sec_policy_initialize) default_initialize; + decltype(vsomeip_sec_policy_authenticate_router) default_authenticate_router; + decltype(vsomeip_sec_policy_is_client_allowed_to_offer) default_is_client_allowed_to_offer; + decltype(vsomeip_sec_policy_is_client_allowed_to_request) default_is_client_allowed_to_request; + decltype(vsomeip_sec_policy_is_client_allowed_to_access_member) default_is_client_allowed_to_access_member; + decltype(vsomeip_sec_sync_client) default_sync_client; + + std::shared_ptr policy_manager_; }; } // namespace vsomeip_v3 diff --git a/implementation/security/src/policy_manager.cpp b/implementation/security/src/policy_manager.cpp deleted file mode 100644 index ad1b52e49..000000000 --- a/implementation/security/src/policy_manager.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include "../include/policy_manager_impl.hpp" - -#ifndef VSOMEIP_DISABLE_SECURITY -namespace vsomeip_v3 { - -std::shared_ptr -policy_manager::get() { - return policy_manager_impl::get(); -} - -} // namespace vsomeip_v3 -#endif diff --git a/implementation/security/src/policy_manager_impl.cpp b/implementation/security/src/policy_manager_impl.cpp index 2dead74af..d4a376cd1 100644 --- a/implementation/security/src/policy_manager_impl.cpp +++ b/implementation/security/src/policy_manager_impl.cpp @@ -1448,43 +1448,4 @@ policy_manager_impl::get_sec_client_to_clients_mapping( return false; } -//////////////////////////////////////////////////////////////////////////////// -// Manage the security object -//////////////////////////////////////////////////////////////////////////////// -static std::shared_ptr *the_policy_manager_ptr__(nullptr); -static std::mutex the_policy_manager_mutex__; - -std::shared_ptr -policy_manager_impl::get() { -#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) - std::lock_guard its_lock(the_policy_manager_mutex__); -#endif - if(the_policy_manager_ptr__ == nullptr) { - the_policy_manager_ptr__ = new std::shared_ptr(); - } - if (the_policy_manager_ptr__ != nullptr) { - if (!(*the_policy_manager_ptr__)) { - *the_policy_manager_ptr__ = std::make_shared(); - } - return *the_policy_manager_ptr__; - } - return nullptr; -} - -#if defined(__linux__) || defined(ANDROID) || defined(__QNX__) -static void security_teardown(void) __attribute__((destructor)); -static void security_teardown(void) -{ - if (the_policy_manager_ptr__ != nullptr) { - // TODO: This mutex is causing a crash due to changes in the way mutexes are defined. - // Since this function only runs on the main thread, no mutex should be needed. Leaving a - // comment pending a refactor. - // std::lock_guard its_lock(the_policy_manager_mutex__); - the_policy_manager_ptr__->reset(); - delete the_policy_manager_ptr__; - the_policy_manager_ptr__ = nullptr; - } -} -#endif - } // namespace vsomeip_v3 diff --git a/implementation/security/src/security.cpp b/implementation/security/src/security.cpp index 19ff73dad..e17e34730 100644 --- a/implementation/security/src/security.cpp +++ b/implementation/security/src/security.cpp @@ -4,14 +4,15 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include "../include/security.hpp" -#include "../include/policy_manager_impl.hpp" #include +#include #ifdef ANDROID #include "../../configuration/include/internal_android.hpp" #else #include "../../configuration/include/internal.hpp" #endif -#include "../../plugin/include/plugin_manager.hpp" +#include "../../configuration/include/configuration_plugin.hpp" +#include "../../configuration/include/configuration_impl.hpp" #include #include @@ -21,51 +22,95 @@ #include #endif -#define VSOMEIP_SEC_POLICY_SYMDEF(sym) symdef_t{\ - "vsomeip_sec_policy_"#sym, nullptr, reinterpret_cast(&sym) \ -} +template +std::function security_load_function(void *_library, std::string const &_name) { + void *its_function; +#ifdef _WIN32 + its_function = GetProcAddress(reinterpret_cast(_library), _name.c_str()); +#else + its_function = dlsym(_library, _name.c_str()); +#endif + if (!its_function) { + VSOMEIP_ERROR << __func__ + << ": security library misses \"" + << _name + << "\" function."; + return nullptr; + } -#define VSOMEIP_SEC_SYMDEF(sym) symdef_t{\ - "vsomeip_sec_"#sym, nullptr, reinterpret_cast(&sym) \ + return reinterpret_cast(its_function); } +#define VSOMEIP_SECURITY_LOAD_IMPL(symbol, variable) \ + auto variable = security_load_function(its_library, #symbol); \ + if (!variable) { \ + its_manager->unload_library(its_library); \ + return false; \ + } + +#define VSOMEIP_SECURITY_LOAD(name) \ + VSOMEIP_SECURITY_LOAD_IMPL(vsomeip_sec_##name, loaded_##name) + +#define VSOMEIP_SECURITY_POLICY_LOAD(name) \ + VSOMEIP_SECURITY_LOAD_IMPL(vsomeip_sec_policy_##name, loaded_##name) + +#define VSOMEIP_SECURITY_ASSIGN_FUNCTION(name) \ + name = loaded_##name + namespace vsomeip_v3 { -bool -security::load() { - using symdef_t = std::tuple; - std::array symbol_table{ - VSOMEIP_SEC_POLICY_SYMDEF(initialize), - VSOMEIP_SEC_POLICY_SYMDEF(authenticate_router), - VSOMEIP_SEC_POLICY_SYMDEF(is_client_allowed_to_offer), - VSOMEIP_SEC_POLICY_SYMDEF(is_client_allowed_to_request), - VSOMEIP_SEC_POLICY_SYMDEF(is_client_allowed_to_access_member), - VSOMEIP_SEC_SYMDEF(sync_client) +security::security(std::shared_ptr _policy_manager): + policy_manager_(_policy_manager) { + + initialize = [&]() -> vsomeip_sec_policy_result_t { + return default_initialize(); }; - if (auto manager = plugin_manager::get()) { - if (auto lib = manager->load_library(VSOMEIP_SEC_LIBRARY)) { - // First we load the symbols into the 2nd tuple element - for (auto& symdef : symbol_table) { - auto name = std::get<0>(symdef); - auto& symbol = std::get<1>(symdef); - if (!(symbol = manager->load_symbol(lib, name))) { - VSOMEIP_ERROR << __func__ - << ": security library misses " - << std::quoted(name) - << " function."; - manager->unload_library(lib); - return false; - } - } - - // Now that we have all symbols loaded, - // assign the 2nd tuple element to the 3rd - for (auto& symdef : symbol_table) { - auto symbol = std::get<1>(symdef); - auto& stub = std::get<2>(symdef); - *stub = symbol; - } + authenticate_router = [&](const vsomeip_sec_client_t *_server) -> vsomeip_sec_acl_result_t { + return default_authenticate_router(_server); + }; + + is_client_allowed_to_offer = [&](const vsomeip_sec_client_t *_client, + vsomeip_sec_service_id_t _service, vsomeip_sec_instance_id_t _instance) -> vsomeip_sec_acl_result_t { + return default_is_client_allowed_to_offer(_client, _service, _instance); + }; + + is_client_allowed_to_request = [&](const vsomeip_sec_client_t *_client, + vsomeip_sec_service_id_t _service, vsomeip_sec_instance_id_t _instance) -> vsomeip_sec_acl_result_t { + return default_is_client_allowed_to_request(_client, _service, _instance); + }; + + is_client_allowed_to_access_member = [&](const vsomeip_sec_client_t *_client, + vsomeip_sec_service_id_t _service, vsomeip_sec_instance_id_t _instance, + vsomeip_sec_member_id_t _member) -> vsomeip_sec_acl_result_t { + return default_is_client_allowed_to_access_member(_client, _service, + _instance, _member); + }; + + sync_client = [&](vsomeip_sec_client_t *_client) { + return default_sync_client(_client); + }; +} + +bool +security::load() { + if (auto its_manager = plugin_manager::get()) { + if (auto its_library = its_manager->load_library(VSOMEIP_SEC_LIBRARY)) { + + VSOMEIP_SECURITY_POLICY_LOAD(initialize); + VSOMEIP_SECURITY_POLICY_LOAD(authenticate_router); + VSOMEIP_SECURITY_POLICY_LOAD(is_client_allowed_to_offer); + VSOMEIP_SECURITY_POLICY_LOAD(is_client_allowed_to_request); + VSOMEIP_SECURITY_POLICY_LOAD(is_client_allowed_to_access_member); + VSOMEIP_SECURITY_LOAD(sync_client); + + // All symbols could be loaded, assign them + VSOMEIP_SECURITY_ASSIGN_FUNCTION(initialize); + VSOMEIP_SECURITY_ASSIGN_FUNCTION(authenticate_router); + VSOMEIP_SECURITY_ASSIGN_FUNCTION(is_client_allowed_to_offer); + VSOMEIP_SECURITY_ASSIGN_FUNCTION(is_client_allowed_to_request); + VSOMEIP_SECURITY_ASSIGN_FUNCTION(is_client_allowed_to_access_member); + VSOMEIP_SECURITY_ASSIGN_FUNCTION(sync_client); // Symbol loading complete, success! return true; @@ -81,82 +126,61 @@ security::load() { return false; } -decltype(security::initialize) -security::initialize = security::default_initialize; - -decltype(security::authenticate_router) -security::authenticate_router = security::default_authenticate_router; - -decltype(security::is_client_allowed_to_offer) -security::is_client_allowed_to_offer = security::default_is_client_allowed_to_offer; - -decltype(security::is_client_allowed_to_request) -security::is_client_allowed_to_request = security::default_is_client_allowed_to_request; - -decltype(security::is_client_allowed_to_access_member) -security::is_client_allowed_to_access_member = security::default_is_client_allowed_to_access_member; - -decltype(security::sync_client) -security::sync_client = security::default_sync_client; - // // Default interface implementation // vsomeip_sec_policy_result_t -security::default_initialize(void) { +security::default_initialize() { return VSOMEIP_SEC_POLICY_OK; } vsomeip_sec_acl_result_t -security::default_authenticate_router( - const vsomeip_sec_client_t *_server) { +security::default_authenticate_router(const vsomeip_sec_client_t *_server) { + if (_server && _server->port != VSOMEIP_SEC_PORT_UNUSED) return VSOMEIP_SEC_OK; - if (policy_manager_impl::get()->check_routing_credentials(_server)) + if (policy_manager_->check_routing_credentials(_server)) return VSOMEIP_SEC_OK; else return VSOMEIP_SEC_PERM_DENIED; } vsomeip_sec_acl_result_t -security::default_is_client_allowed_to_offer( - const vsomeip_sec_client_t *_client, - vsomeip_sec_service_id_t _service, - vsomeip_sec_instance_id_t _instance) { +security::default_is_client_allowed_to_offer(const vsomeip_sec_client_t *_client, + vsomeip_sec_service_id_t _service, vsomeip_sec_instance_id_t _instance) { + if (_client && _client->port != VSOMEIP_SEC_PORT_UNUSED) return VSOMEIP_SEC_OK; - if (policy_manager_impl::get()->is_offer_allowed(_client, _service, _instance)) + if (policy_manager_->is_offer_allowed(_client, _service, _instance)) return VSOMEIP_SEC_OK; else return VSOMEIP_SEC_PERM_DENIED; } vsomeip_sec_acl_result_t -security::default_is_client_allowed_to_request( - const vsomeip_sec_client_t *_client, - vsomeip_sec_service_id_t _service, - vsomeip_sec_instance_id_t _instance) { +security::default_is_client_allowed_to_request(const vsomeip_sec_client_t *_client, + vsomeip_sec_service_id_t _service, vsomeip_sec_instance_id_t _instance) { + if (_client && _client->port != VSOMEIP_SEC_PORT_UNUSED) return VSOMEIP_SEC_OK; - if (policy_manager_impl::get()->is_client_allowed(_client, _service, _instance, 0x00, true)) + if (policy_manager_->is_client_allowed(_client, _service, _instance, 0x00, true)) return VSOMEIP_SEC_OK; else return VSOMEIP_SEC_PERM_DENIED; } vsomeip_sec_acl_result_t -security::default_is_client_allowed_to_access_member( - const vsomeip_sec_client_t *_client, - vsomeip_sec_service_id_t _service, - vsomeip_sec_instance_id_t _instance, +security::default_is_client_allowed_to_access_member(const vsomeip_sec_client_t *_client, + vsomeip_sec_service_id_t _service, vsomeip_sec_instance_id_t _instance, vsomeip_sec_member_id_t _member) { + if (_client && _client->port != VSOMEIP_SEC_PORT_UNUSED) return VSOMEIP_SEC_OK; - if (policy_manager_impl::get()->is_client_allowed(_client, _service, _instance, _member, false)) + if (policy_manager_->is_client_allowed(_client, _service, _instance, _member, false)) return VSOMEIP_SEC_OK; else return VSOMEIP_SEC_PERM_DENIED; @@ -164,7 +188,6 @@ security::default_is_client_allowed_to_access_member( void security::default_sync_client(vsomeip_sec_client_t *_client) { - (void)_client; } diff --git a/interface/vsomeip/application.hpp b/interface/vsomeip/application.hpp index 4451d4568..6f2cc98ba 100644 --- a/interface/vsomeip/application.hpp +++ b/interface/vsomeip/application.hpp @@ -27,6 +27,7 @@ class configuration_public; class event; class payload; struct policy; +class policy_manager; /** * \defgroup vsomeip @@ -1139,6 +1140,20 @@ class application { instance_t _instance, method_t _method, const message_handler_t &_handler, handler_registration_type_e _type) = 0; + + /** + * \brief Get the configuration + * + * \return configuration shared pointer + */ + virtual std::shared_ptr get_configuration() const = 0; + + /** + * \brief Get the policy_manager + * + * \return policy_manager shared pointer + */ + virtual std::shared_ptr get_policy_manager() const = 0; }; /** @} */ diff --git a/implementation/plugin/include/plugin_manager.hpp b/interface/vsomeip/internal/plugin_manager.hpp similarity index 93% rename from implementation/plugin/include/plugin_manager.hpp rename to interface/vsomeip/internal/plugin_manager.hpp index d398e2457..a8b05b227 100644 --- a/implementation/plugin/include/plugin_manager.hpp +++ b/interface/vsomeip/internal/plugin_manager.hpp @@ -23,6 +23,7 @@ class plugin_manager { VSOMEIP_EXPORT virtual void * load_library(const std::string &_path) = 0; VSOMEIP_EXPORT virtual void * load_symbol(void * _handle, const std::string &_symbol) = 0; VSOMEIP_EXPORT virtual void unload_library(void * _handle) = 0; + VSOMEIP_EXPORT virtual bool unload_plugin(plugin_type_e _type) = 0; }; } // namespace vsomeip_v3 diff --git a/interface/vsomeip/internal/policy_manager.hpp b/interface/vsomeip/internal/policy_manager.hpp index 0d610d9ef..42bfccb2a 100644 --- a/interface/vsomeip/internal/policy_manager.hpp +++ b/interface/vsomeip/internal/policy_manager.hpp @@ -19,10 +19,7 @@ struct policy; class VSOMEIP_IMPORT_EXPORT policy_manager { public: - static std::shared_ptr get(); - - virtual ~policy_manager() {}; - + virtual ~policy_manager() {} virtual std::shared_ptr create_policy() const = 0; virtual void print_policy(const std::shared_ptr &_policy) const = 0; diff --git a/test/network_tests/CMakeLists.txt b/test/network_tests/CMakeLists.txt index 6006e7b33..18f0c93d5 100644 --- a/test/network_tests/CMakeLists.txt +++ b/test/network_tests/CMakeLists.txt @@ -77,7 +77,6 @@ if(NOT ${TESTS_BAT}) add_executable(${TEST_CONFIGURATION} configuration_tests/configuration-test.cpp - ${PROJECT_SOURCE_DIR}/implementation/plugin/src/plugin_manager_impl.cpp ) target_link_libraries(${TEST_CONFIGURATION} ${VSOMEIP_NAME} diff --git a/test/network_tests/configuration_tests/configuration-test.cpp b/test/network_tests/configuration_tests/configuration-test.cpp index f2c8f8647..9544552e6 100644 --- a/test/network_tests/configuration_tests/configuration-test.cpp +++ b/test/network_tests/configuration_tests/configuration-test.cpp @@ -13,9 +13,9 @@ #include #include #include +#include #include "../implementation/configuration/include/configuration.hpp" -#include "../../implementation/plugin/include/plugin_manager_impl.hpp" #include "../../implementation/configuration/include/configuration_impl.hpp" #include "../../implementation/configuration/include/configuration_plugin.hpp" #include "../../implementation/protocol/include/protocol.hpp" @@ -167,7 +167,7 @@ void check_file(const std::string &_config_file, // 1. Create configuration object std::shared_ptr its_configuration; - auto its_plugin = vsomeip::plugin_manager_impl::get()->get_plugin( + auto its_plugin = vsomeip::plugin_manager::get()->get_plugin( vsomeip::plugin_type_e::CONFIGURATION_PLUGIN, VSOMEIP_CFG_LIBRARY); if (its_plugin) { auto its_configuration_plugin @@ -572,7 +572,7 @@ void check_file(const std::string &_config_file, vsomeip_sec_client_t its_8000_8000 = utility::create_uds_client(8000, 8000, 0); vsomeip_sec_client_t its_9000_9000 = utility::create_uds_client(9000, 9000, 0); - auto its_security = vsomeip::policy_manager_impl::get(); + auto its_security = its_configuration->get_policy_manager(); EXPECT_TRUE(its_security->is_offer_allowed(&its_1000_1000, 0x1234, 0x5678)); EXPECT_TRUE(its_security->is_offer_allowed(&its_1000_1000, 0x1235, 0x5678)); EXPECT_TRUE(its_security->is_offer_allowed(&its_1000_1000, 0x1236, 0x5678)); @@ -753,7 +753,7 @@ void check_file(const std::string &_config_file, EXPECT_TRUE(check(request_response_delay, static_cast(_expected_request_response_delay), "SD RESPONSE REQUEST DELAY")); EXPECT_EQ(1000u, its_configuration->get_sd_offer_debounce_time()); - ASSERT_TRUE(vsomeip::plugin_manager_impl::get()->unload_plugin(vsomeip::plugin_type_e::CONFIGURATION_PLUGIN)); + ASSERT_TRUE(vsomeip::plugin_manager::get()->unload_plugin(vsomeip::plugin_type_e::CONFIGURATION_PLUGIN)); } TEST(configuration_test, check_config_file) { From 8ee48ed80817d96e9c63634f0b1cd9cf1948140e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 11:21:50 +0100 Subject: [PATCH 19/20] Fix to not ignore stop offers when sd acceptance is not required --- implementation/endpoints/src/tcp_client_endpoint_impl.cpp | 1 + implementation/service_discovery/src/service_discovery_impl.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp index 496349012..ade0990ac 100644 --- a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp @@ -115,6 +115,7 @@ void tcp_client_endpoint_impl::restart(bool _force) { << std::setw(4) << its_session << "]" << " size: " << std::dec << q.first->size(); } + self->sending_blocked_ = false; self->queue_.clear(); self->queue_size_ = 0; } diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index a15deab8f..33c3046c2 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -1405,7 +1405,7 @@ service_discovery_impl::process_serviceentry( VSOMEIP_ERROR << __func__ << ": Unsupported service entry type"; } } else if (its_type != entry_type_e::FIND_SERVICE - && (_sd_ac_state.sd_acceptance_required_ || _sd_ac_state.accept_entries_)) { + && (!_sd_ac_state.sd_acceptance_required_ || _sd_ac_state.accept_entries_)) { // stop sending find service in repetition phase update_request(its_service, its_instance); From 1c17f37d95ff038c13a899a476074614ed7ecfbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Monteiro?= Date: Wed, 26 Jun 2024 14:09:42 +0100 Subject: [PATCH 20/20] Release 3.5.0 --- Android.bp | 4 ++-- Android.mk | 8 ++++---- CHANGES | 21 +++++++++++++++++++++ CMakeLists.txt | 4 ++-- libvsomeip.yaml | 2 +- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Android.bp b/Android.bp index f314f22b1..702782517 100644 --- a/Android.bp +++ b/Android.bp @@ -80,8 +80,8 @@ cc_library_shared { cflags: [ "-DWITHOUT_SYSTEMD", - "-DVSOMEIP_VERSION=\"3.4.10\"", - "-DVSOMEIP_COMPAT_VERSION=\"3.4.10\"", + "-DVSOMEIP_VERSION=\"3.5.0\"", + "-DVSOMEIP_COMPAT_VERSION=\"3.5.0\"", "-DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\"", "-DUSE_DLT", ], diff --git a/Android.mk b/Android.mk index 67530094e..cadc6e758 100644 --- a/Android.mk +++ b/Android.mk @@ -100,7 +100,7 @@ LOCAL_CFLAGS := \ -frtti \ -fexceptions \ -DWITHOUT_SYSTEMD \ - -DVSOMEIP_VERSION=\"3.4.10\" \ + -DVSOMEIP_VERSION=\"3.5.0\" \ -DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\" \ -Wno-unused-parameter \ -Wno-non-virtual-dtor \ @@ -147,7 +147,7 @@ LOCAL_CFLAGS := \ -frtti \ -fexceptions \ -DWITHOUT_SYSTEMD \ - -DVSOMEIP_VERSION=\"3.4.10\" \ + -DVSOMEIP_VERSION=\"3.5.0\" \ -DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\" \ -Wno-unused-parameter \ -Wno-non-virtual-dtor \ @@ -194,8 +194,8 @@ LOCAL_CFLAGS := \ -frtti \ -fexceptions \ -DWITHOUT_SYSTEMD \ - -DVSOMEIP_VERSION=\"3.4.10\" \ - -DVSOMEIP_COMPAT_VERSION=\"3.4.10\" \ + -DVSOMEIP_VERSION=\"3.5.0\" \ + -DVSOMEIP_COMPAT_VERSION=\"3.5.0\" \ -DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\" \ -Wno-unused-parameter \ -Wno-non-virtual-dtor \ diff --git a/CHANGES b/CHANGES index f4e7081aa..fd7bc3c28 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,27 @@ Changes ======= +v3.5.0 +- Load Policies Lazy Load +- Test - Processing SD messages with unknown type option +- ensure endpoints before deletion +- Improve "end of file" error handling +- Enable debouncing of events & selective events +- Revert "Test - Processing SD messages with unknown type" +- Logs added to points of failure on registration process +- One *.json to ignorem all +- Someip-tp remote address rework +- Fix crash in multicast_receive receive_cb +- Generate network_test configs directly to build +- Fix deadlock if binding of TCP client endpoint fails +- Added missing includes of iomanip to support compilation on Mint +- Cache not yet registered events +- Return true to make sure endpoints are deleted +- Byteorder implementation +- Reorder of prepare_stop method +- Allows applications in the same process using different security configurations +- Fix to not ignore stop offers when sd acceptance is not required + v3.4.10 - Fix QNX build - Fix missing Stop Offer diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c4f70650..75136dd75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ set (VSOMEIP_NAME vsomeip3) set (VSOMEIP_COMPAT_NAME vsomeip) set (VSOMEIP_MAJOR_VERSION 3) -set (VSOMEIP_MINOR_VERSION 4) -set (VSOMEIP_PATCH_VERSION 10) +set (VSOMEIP_MINOR_VERSION 5) +set (VSOMEIP_PATCH_VERSION 0) set (VSOMEIP_HOTFIX_VERSION 0) set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION}) diff --git a/libvsomeip.yaml b/libvsomeip.yaml index 0ad6b7426..ba88909ac 100644 --- a/libvsomeip.yaml +++ b/libvsomeip.yaml @@ -1,5 +1,5 @@ - name: libvsomeip - version: 3.4.10 + version: 3.5.0 vendor: Lynx Team license: concluded: CLOSED and MPLv2