From 23b6a4bcc6632b7c217b854bb879eb9cd3bc2f29 Mon Sep 17 00:00:00 2001 From: Juergen Gehring Date: Tue, 22 May 2018 02:56:46 -0700 Subject: vsomeip 2.10.20 --- CHANGES | 14 ++ CMakeLists.txt | 22 ++- exportmap.gcc | 2 + .../configuration/include/configuration.hpp | 3 +- .../configuration/include/configuration_impl.hpp | 5 +- .../configuration/include/internal.hpp.in | 2 +- .../configuration/src/configuration_impl.cpp | 170 +++++++++++++++------ .../endpoints/src/tcp_client_endpoint_impl.cpp | 5 +- .../routing/src/routing_manager_impl.cpp | 3 + implementation/runtime/src/application_impl.cpp | 3 +- .../src/service_discovery_impl.cpp | 127 ++++++++++++++- implementation/utility/src/utility.cpp | 12 +- .../conf/local_routing_test_starter.sh.bat.in | 14 +- 13 files changed, 314 insertions(+), 68 deletions(-) diff --git a/CHANGES b/CHANGES index 0f7aa15..e88362a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,20 @@ Changes ======= +v2.10.20 +- Add security config (i.e. vsomeip_security.json) to mandatory config files +- Enable local_routing_test_starter.sh to use externally defined configuration + files +- Reject malformed subscriptions with SubscribeEventgroupNACK if multiple + endpoint options are referenced +- Use CMake define or environment variable to find gtest +- Quit vsomeipd when Service Discovery is configured but module cannot be loaded +- Added error message when Configuration module cannot be loaded +- Export payload_impl to enable compilation with newer GCC versions +- Avoid printing the same warning twice. Ensure all error paths are identifiable +- Fixed security checks for policies without configured client ID +- Fixed crash on auto config load in case of EOWNERDEAD caused by previous crashed/exited application + v2.10.19 - Catch exceptions on shutdown (especially from boost::log) - Fixed handling of malformed packets in TCP client endpoint in conjunction diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bb01ce..04ae559 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,11 +8,19 @@ project (vsomeip) set (VSOMEIP_MAJOR_VERSION 2) set (VSOMEIP_MINOR_VERSION 10) -set (VSOMEIP_PATCH_VERSION 19) +set (VSOMEIP_PATCH_VERSION 20) set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION}) set (PACKAGE_VERSION ${VSOMEIP_VERSION}) # Used in documentatin/doxygen.in set (CMAKE_VERBOSE_MAKEFILE off) +if (NOT GTEST_ROOT) + if (DEFINED ENV{GTEST_ROOT}) + set(GTEST_ROOT $ENV{GTEST_ROOT}) + else() + set(GTEST_ROOT "n/a" CACHE STRING "Path to root folder of googletest. Must be set for building the tests.") + endif() +endif() + ################################################################################################### # see http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file ################################################################################################### @@ -407,13 +415,13 @@ endif() # google test # check for set environment variable -if(DEFINED ENV{GTEST_ROOT}) - message("GTEST_ROOT is set. GTEST_ROOT = $ENV{GTEST_ROOT}") -else() - message("GTEST_ROOT is not defined. For building the tests environment variable - GTEST_ROOT have to be defined. Tests can not be built.") +if(${GTEST_ROOT} STREQUAL "n/a") + message(STATUS "GTEST_ROOT is not defined. For building the tests the variable + GTEST_ROOT has to be defined. Tests can not be built.") # early exit return() # test can not be build -> make commands build_tests and check are not available +else() + message(STATUS "GTEST_ROOT is set. gtest root path set to ${GTEST_ROOT}") endif() # build google test as static library (always) -> therefore deactivate BUILD_SHARED_LIBS in case it is active @@ -422,7 +430,7 @@ if ("${BUILD_SHARED_LIBS}" STREQUAL "ON") set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 1) endif() -add_subdirectory($ENV{GTEST_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/gtest EXCLUDE_FROM_ALL) +add_subdirectory(${GTEST_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/gtest EXCLUDE_FROM_ALL) if ("${BUILD_SHARED_LIBS_AUTOMATIC_OFF}" STREQUAL "1") set(BUILD_SHARED_LIBS ON) set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0) diff --git a/exportmap.gcc b/exportmap.gcc index 61da700..215ef98 100644 --- a/exportmap.gcc +++ b/exportmap.gcc @@ -23,6 +23,8 @@ global: *vsomeip::message_base_impl::*; *vsomeip::message_header_impl; *vsomeip::message_header_impl::*; + *vsomeip::payload_impl; + *vsomeip::payload_impl::*; *vsomeip::runtime; vsomeip::runtime::get*; vsomeip::runtime::set_property*; diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp index 1423392..c89ed39 100644 --- a/implementation/configuration/include/configuration.hpp +++ b/implementation/configuration/include/configuration.hpp @@ -136,7 +136,8 @@ public: instance_t _instance) const = 0; virtual bool is_offer_allowed(client_t _client, service_t _service, instance_t _instance) const = 0; - virtual bool check_credentials(client_t _client, uint32_t _uid, uint32_t _gid) const = 0; + virtual bool check_credentials(client_t _client, + uint32_t _uid, uint32_t _gid) = 0; // Plugins virtual std::map> get_plugins( diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp index d3b7572..af04ce1 100644 --- a/implementation/configuration/include/configuration_impl.hpp +++ b/implementation/configuration/include/configuration_impl.hpp @@ -149,7 +149,8 @@ public: instance_t _instance) const; VSOMEIP_EXPORT bool is_offer_allowed(client_t _client, service_t _service, instance_t _instance) const; - VSOMEIP_EXPORT bool check_credentials(client_t _client, uint32_t _uid, uint32_t _gid) const; + VSOMEIP_EXPORT bool check_credentials(client_t _client, + uint32_t _uid, uint32_t _gid); VSOMEIP_EXPORT std::map> get_plugins( const std::string &_name) const; @@ -375,6 +376,8 @@ protected: std::uint32_t umask_; std::map> policies_; + std::vector > any_client_policies_; + std::map > ids_; bool policy_enabled_; bool check_credentials_; diff --git a/implementation/configuration/include/internal.hpp.in b/implementation/configuration/include/internal.hpp.in index e2f3da3..6135205 100644 --- a/implementation/configuration/include/internal.hpp.in +++ b/implementation/configuration/include/internal.hpp.in @@ -20,7 +20,7 @@ #define VSOMEIP_DEFAULT_CONFIGURATION_FILE "/etc/vsomeip.json" #define VSOMEIP_LOCAL_CONFIGURATION_FILE "./vsomeip.json" -#define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_plc.json,vsomeip_log.json" +#define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_plc.json,vsomeip_log.json,vsomeip_security.json" #define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "/etc/vsomeip" #define VSOMEIP_DEBUG_CONFIGURATION_FOLDER "/var/opt/public/sin/vsomeip/" diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index 0b33018..aa18f2f 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -1867,7 +1867,7 @@ void configuration_impl::load_policy(const boost::property_tree::ptree &_tree) { } if (!has_been_inserted) { - policies_[ANY_CLIENT] = policy; + any_client_policies_.push_back(policy); } } @@ -2532,20 +2532,26 @@ bool configuration_impl::is_security_enabled() const { } bool configuration_impl::check_credentials(client_t _client, uint32_t _uid, - uint32_t _gid) const { + uint32_t _gid) { if (!policy_enabled_) { return true; } + // store the client -> (uid, gid) mapping + ids_[_client] = std::make_pair(_uid, _gid); + + std::vector > its_policies; bool has_id(false); auto its_client = policies_.find(_client); - // Search for generic policy if no specific could be found - if (its_client == policies_.end()) - its_client = policies_.find(ANY_CLIENT); + // Use client specific policy if it does exist + if (its_client != policies_.end()) + its_policies.push_back(its_client->second); + else + its_policies = any_client_policies_; - if (its_client != policies_.end()) { - for (auto its_credential : its_client->second->ids_) { + for (const auto &p : its_policies) { + for (auto its_credential : p->ids_) { bool has_uid(false), has_gid(false); for (auto its_range : std::get<0>(its_credential)) { if (std::get<0>(its_range) <= _uid && _uid <= std::get<1>(its_range)) { @@ -2566,8 +2572,7 @@ bool configuration_impl::check_credentials(client_t _client, uint32_t _uid, } } - if ((has_id && its_client->second->allow_who_) - || (!has_id && !its_client->second->allow_who_)) { + if ((has_id && p->allow_who_) || (!has_id && !p->allow_who_)) { return true; } } @@ -2586,29 +2591,66 @@ bool configuration_impl::is_client_allowed(client_t _client, service_t _service, if (!policy_enabled_) { return true; } - auto its_client = policies_.find(_client); - // Search for generic policy if no specific could be found - if (its_client == policies_.end()) - its_client = policies_.find(ANY_CLIENT); + uint32_t its_uid(0xffffffff), its_gid(0xffffffff); + bool must_apply(true); + std::vector > its_policies; + auto its_client = policies_.find(_client); - if (its_client == policies_.end()) { - if (!check_credentials_) { - VSOMEIP_INFO << "vSomeIP Security: Client 0x" << std::hex << _client - << " isn't allowed to communicate with service/instance " - << _service << "/" << _instance - << " but will be allowed due to audit mode is active!"; + // Use client specific policy if it does exist + if (its_client != policies_.end()) + its_policies.push_back(its_client->second); + else { + must_apply = false; + its_policies = any_client_policies_; + + auto found_id = ids_.find(_client); + if (found_id != ids_.end()) { + its_uid = found_id->second.first; + its_gid = found_id->second.second; + } else { + if (!check_credentials_) { + VSOMEIP_INFO << "vSomeIP Security: Cannot determine uid/gid for" + "client 0x" << std::hex << _client + << ". Therefore it isn't allowed to communicate to service/instance " + << _service << "/" << _instance + << " but will be allowed due to audit mode is active!"; + } + return !check_credentials_; } - return !check_credentials_; } - auto its_service = its_client->second->services_.find(std::make_pair(_service, _instance)); - if (its_client->second->allow_what_ - && its_service != its_client->second->services_.end()) { - return true; - } else if (!its_client->second->allow_what_ - && its_service == its_client->second->services_.end()) { - return true; + for (const auto &p : its_policies) { + bool has_uid(false), has_gid(false); + if (must_apply) { + has_uid = has_gid = p->allow_what_; + } else { + for (auto its_credential : p->ids_) { + has_uid = has_gid = false; + for (auto its_range : std::get<0>(its_credential)) { + if (std::get<0>(its_range) <= its_uid && its_uid <= std::get<1>(its_range)) { + has_uid = true; + break; + } + } + for (auto its_range : std::get<1>(its_credential)) { + if (std::get<0>(its_range) <= its_gid && its_gid <= std::get<1>(its_range)) { + has_gid = true; + break; + } + } + + if (has_uid && has_gid) + break; + } + } + + auto its_service = p->services_.find(std::make_pair(_service, _instance)); + if (has_uid && has_gid && p->allow_what_ && its_service != p->services_.end()) { + return true; + } else if (!has_uid && !has_gid && !p->allow_what_ && its_service == p->services_.end()) { + return true; + } } if (!check_credentials_) { @@ -2627,29 +2669,67 @@ bool configuration_impl::is_offer_allowed(client_t _client, service_t _service, return true; } + uint32_t its_uid(0xffffffff), its_gid(0xffffffff); + bool must_apply(true); + std::vector > its_policies; auto its_client = policies_.find(_client); - // Search for generic policy if no specific could be found - if (its_client == policies_.end()) - its_client = policies_.find(ANY_CLIENT); - - if (its_client == policies_.end()) { - if (!check_credentials_) { - VSOMEIP_INFO << "vSomeIP Security: Client 0x" << std::hex << _client - << " isn't allowed to offer service/instance " - << _service << "/" << _instance - << " but will be allowed due to audit mode is active!"; + // Use client specific policy if it does exist + if (its_client != policies_.end()) + its_policies.push_back(its_client->second); + else { + must_apply = false; + its_policies = any_client_policies_; + + auto found_id = ids_.find(_client); + if (found_id != ids_.end()) { + its_uid = found_id->second.first; + its_gid = found_id->second.second; + } else { + if (!check_credentials_) { + VSOMEIP_INFO << "vSomeIP Security: Cannot determine uid/gid for" + "client 0x" << std::hex << _client + << ". Therefore it isn't allowed to offer service/instance " + << _service << "/" << _instance + << " but will be allowed due to audit mode is active!"; + } + return !check_credentials_; } - return !check_credentials_; } - auto its_offer = its_client->second->offers_.find(std::make_pair(_service, _instance)); - if (its_client->second->allow_what_ - && its_offer != its_client->second->offers_.end()) { - return true; - } else if (!its_client->second->allow_what_ - && its_offer == its_client->second->offers_.end()) { - return true; + for (const auto &p : its_policies) { + bool has_uid(false), has_gid(false); + if (must_apply) { + has_uid = has_gid = p->allow_what_; + } else { + for (auto its_credential : p->ids_) { + has_uid = has_gid = false; + for (auto its_range : std::get<0>(its_credential)) { + if (std::get<0>(its_range) <= its_uid && its_uid <= std::get<1>(its_range)) { + has_uid = true; + break; + } + } + for (auto its_range : std::get<1>(its_credential)) { + if (std::get<0>(its_range) <= its_gid && its_gid <= std::get<1>(its_range)) { + has_gid = true; + break; + } + } + + if (has_uid && has_gid) + break; + } + } + + auto its_offer = p->offers_.find(std::make_pair(_service, _instance)); + if (has_uid && has_gid + && p->allow_what_ && its_offer != p->offers_.end()) { + return true; + } else if (!has_uid && !has_gid + && !p->allow_what_ && its_offer == p->offers_.end()) { + return true; + } } if (!check_credentials_) { diff --git a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp index 102d0fe..cb92619 100644 --- a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp @@ -552,6 +552,7 @@ void tcp_client_endpoint_impl::receive_cbk( VSOMEIP_WARNING << "tcp_client_endpoint receive_cbk already" " restarting" << get_remote_information(); } else { + VSOMEIP_WARNING << "tcp_client_endpoint receive_cbk restarting."; state_ = cei_state_e::CONNECTING; shutdown_and_close_socket_unlocked(false); was_not_connected_ = true; @@ -560,10 +561,6 @@ void tcp_client_endpoint_impl::receive_cbk( restart(true); } } else { - VSOMEIP_WARNING << "tcp_client_endpoint receive_cbk: " - << _error.message() << "( " << std::dec << _error.value() - << ") local: " << get_address_port_local() - << " remote: " << get_address_port_remote(); its_lock.unlock(); receive(_recv_buffer, _recv_buffer_size, its_missing_capacity); } diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index 9fd9258..733d75b 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -108,6 +108,9 @@ void routing_manager_impl::init() { VSOMEIP_INFO << "Service Discovery module loaded."; discovery_ = std::dynamic_pointer_cast(its_plugin)->create_service_discovery(this); discovery_->init(); + } else { + VSOMEIP_ERROR << "Service Discovery module could not be loaded!"; + std::exit(EXIT_FAILURE); } } diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp index d079816..5d4a80b 100644 --- a/implementation/runtime/src/application_impl.cpp +++ b/implementation/runtime/src/application_impl.cpp @@ -101,7 +101,8 @@ bool application_impl::init() { configuration_->load(name_); VSOMEIP_INFO << "Default configuration module loaded."; } else { - exit(-1); + std::cerr << "Service Discovery module could not be loaded!" << std::endl; + std::exit(EXIT_FAILURE); } } diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index 084d8bf..1f93559 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -1879,12 +1879,17 @@ void service_discovery_impl::process_eventgroupentry( uint16_t its_reserved = _entry->get_reserved(); uint8_t its_counter = _entry->get_counter(); + bool has_two_options_ = (_entry->get_num_options(1) + _entry->get_num_options(2) >= 2) ? true : false; + if (_entry->get_owning_message()->get_return_code() != return_code) { boost::system::error_code ec; VSOMEIP_ERROR << "Invalid return code in SD header " << _message_id->sender_.to_string(ec) << " session: " << std::hex << std::setw(4) << std::setfill('0') << _message_id->session_; if(its_ttl > 0) { + if (has_two_options_) { + its_message_response->decrease_number_required_acks(); + } insert_subscription_nack(its_message_response, its_service, its_instance, its_eventgroup, its_counter, its_major, its_reserved); } @@ -1898,6 +1903,9 @@ void service_discovery_impl::process_eventgroupentry( << _message_id->sender_.to_string(ec) << " session: " << std::hex << std::setw(4) << std::setfill('0') << _message_id->session_; if(its_ttl > 0) { + if (has_two_options_) { + its_message_response->decrease_number_required_acks(); + } insert_subscription_nack(its_message_response, its_service, its_instance, its_eventgroup, its_counter, its_major, its_reserved); } @@ -1924,6 +1932,9 @@ void service_discovery_impl::process_eventgroupentry( << _message_id->sender_.to_string(ec) << " session: " << std::hex << std::setw(4) << std::setfill('0') << _message_id->session_; if(its_ttl > 0) { + if (has_two_options_) { + its_message_response->decrease_number_required_acks(); + } insert_subscription_nack(its_message_response, its_service, its_instance, its_eventgroup, its_counter, its_major, its_reserved); } @@ -1984,6 +1995,9 @@ void service_discovery_impl::process_eventgroupentry( << std::hex << std::setw(4) << std::setfill('0') << _message_id->session_; if (entry_type_e::SUBSCRIBE_EVENTGROUP == its_type && its_ttl > 0) { + if (has_two_options_) { + its_message_response->decrease_number_required_acks(); + } insert_subscription_nack(its_message_response, its_service, its_instance, its_eventgroup, its_counter, its_major, its_reserved); } @@ -2000,6 +2014,9 @@ void service_discovery_impl::process_eventgroupentry( its_ipv4_option->get_address()); if (!check_layer_four_protocol(its_ipv4_option)) { if( its_ttl > 0) { + if (has_two_options_) { + its_message_response->decrease_number_required_acks(); + } insert_subscription_nack(its_message_response, its_service, its_instance, its_eventgroup, its_counter, its_major, its_reserved); } @@ -2012,9 +2029,31 @@ void service_discovery_impl::process_eventgroupentry( is_first_reliable = (its_ipv4_option->get_layer_four_protocol() == layer_four_protocol_e::TCP); + // reject subscription referencing two conflicting options of same protocol type + // ID: SIP_SD_1144 + if (is_first_reliable == is_second_reliable + && its_second_port != ILLEGAL_PORT) { + if (its_ttl > 0) { + if (has_two_options_) { + its_message_response->decrease_number_required_acks(); + } + insert_subscription_nack(its_message_response, its_service, its_instance, + its_eventgroup, its_counter, its_major, its_reserved); + } + boost::system::error_code ec; + VSOMEIP_ERROR << "Multiple IPv4 endpoint options of same kind referenced! " + << _message_id->sender_.to_string(ec) << " session: " + << std::hex << std::setw(4) << std::setfill('0') << _message_id->session_ + << " is_first_reliable: " << is_first_reliable; + return; + } + if(!check_ipv4_address(its_first_address) || 0 == its_first_port) { if(its_ttl > 0) { + if (has_two_options_) { + its_message_response->decrease_number_required_acks(); + } insert_subscription_nack(its_message_response, its_service, its_instance, its_eventgroup, its_counter, its_major, its_reserved); } @@ -2031,9 +2070,31 @@ void service_discovery_impl::process_eventgroupentry( is_second_reliable = (its_ipv4_option->get_layer_four_protocol() == layer_four_protocol_e::TCP); + // reject subscription referencing two conflicting options of same protocol type + // ID: SIP_SD_1144 + if (is_second_reliable == is_first_reliable + && its_first_port != ILLEGAL_PORT) { + if (its_ttl > 0) { + if (has_two_options_) { + its_message_response->decrease_number_required_acks(); + } + insert_subscription_nack(its_message_response, its_service, its_instance, + its_eventgroup, its_counter, its_major, its_reserved); + } + boost::system::error_code ec; + VSOMEIP_ERROR << "Multiple IPv4 endpoint options of same kind referenced! " + << _message_id->sender_.to_string(ec) << " session: " + << std::hex << std::setw(4) << std::setfill('0') << _message_id->session_ + << " is_second_reliable: " << is_second_reliable; + return; + } + if(!check_ipv4_address(its_second_address) || 0 == its_second_port) { if(its_ttl > 0) { + if (has_two_options_) { + its_message_response->decrease_number_required_acks(); + } insert_subscription_nack(its_message_response, its_service, its_instance, its_eventgroup, its_counter, its_major, its_reserved); } @@ -2065,6 +2126,9 @@ void service_discovery_impl::process_eventgroupentry( its_ipv6_option->get_address()); if (!check_layer_four_protocol(its_ipv6_option)) { if(its_ttl > 0) { + if (has_two_options_) { + its_message_response->decrease_number_required_acks(); + } insert_subscription_nack(its_message_response, its_service, its_instance, its_eventgroup, its_counter, its_major, its_reserved); } @@ -2080,12 +2144,46 @@ void service_discovery_impl::process_eventgroupentry( its_first_port = its_ipv6_option->get_port(); is_first_reliable = (its_ipv6_option->get_layer_four_protocol() == layer_four_protocol_e::TCP); + + if (is_first_reliable == is_second_reliable + && its_second_port != ILLEGAL_PORT) { + if (its_ttl > 0) { + if (has_two_options_) { + its_message_response->decrease_number_required_acks(); + } + insert_subscription_nack(its_message_response, its_service, its_instance, + its_eventgroup, its_counter, its_major, its_reserved); + } + boost::system::error_code ec; + VSOMEIP_ERROR << "Multiple IPv6 endpoint options of same kind referenced! " + << _message_id->sender_.to_string(ec) << " session: " + << std::hex << std::setw(4) << std::setfill('0') << _message_id->session_ + << " is_first_reliable: " << is_first_reliable; + return; + } } else if (its_second_port == ILLEGAL_PORT) { its_second_address = its_ipv6_address; its_second_port = its_ipv6_option->get_port(); is_second_reliable = (its_ipv6_option->get_layer_four_protocol() == layer_four_protocol_e::TCP); + + if (is_second_reliable == is_first_reliable + && its_first_port != ILLEGAL_PORT) { + if (its_ttl > 0) { + if (has_two_options_) { + its_message_response->decrease_number_required_acks(); + } + insert_subscription_nack(its_message_response, its_service, its_instance, + its_eventgroup, its_counter, its_major, its_reserved); + } + boost::system::error_code ec; + VSOMEIP_ERROR << "Multiple IPv6 endpoint options of same kind referenced! " + << _message_id->sender_.to_string(ec) << " session: " + << std::hex << std::setw(4) << std::setfill('0') << _message_id->session_ + << " is_second_reliable: " << is_second_reliable; + return; + } } else { // TODO: error message, too many endpoint options! } @@ -2117,6 +2215,15 @@ void service_discovery_impl::process_eventgroupentry( } else { // TODO: error message, too many endpoint options! } + // ID: SIP_SD_946, ID: SIP_SD_1144 + if (its_first_port != ILLEGAL_PORT + && its_second_port != ILLEGAL_PORT) { + boost::system::error_code ec; + VSOMEIP_ERROR << "Multiple IPv4 multicast options referenced! " + << _message_id->sender_.to_string(ec) << " session: " + << std::hex << std::setw(4) << std::setfill('0') << _message_id->session_; + return; + } } else { boost::system::error_code ec; VSOMEIP_ERROR @@ -2144,6 +2251,15 @@ void service_discovery_impl::process_eventgroupentry( } else { // TODO: error message, too many endpoint options! } + // ID: SIP_SD_946, ID: SIP_SD_1144 + if (its_first_port != ILLEGAL_PORT + && its_second_port != ILLEGAL_PORT) { + boost::system::error_code ec; + VSOMEIP_ERROR << "Multiple IPv6 multicast options referenced! " + << _message_id->sender_.to_string(ec) << " session: " + << std::hex << std::setw(4) << std::setfill('0') << _message_id->session_; + return; + } } else { boost::system::error_code ec; VSOMEIP_ERROR @@ -2204,6 +2320,7 @@ void service_discovery_impl::handle_eventgroup_subscription(service_t _service, if (its_message) { bool has_reliable_events(false); bool has_unreliable_events(false); + bool has_two_options_ = (_first_port != ILLEGAL_PORT && _second_port != ILLEGAL_PORT) ? true : false; auto its_eventgroup = host_->find_eventgroup(_service, _instance, _eventgroup); if (its_eventgroup) { its_eventgroup->get_reliability(has_reliable_events, has_unreliable_events); @@ -2229,6 +2346,9 @@ void service_discovery_impl::handle_eventgroup_subscription(service_t _service, } } if (reliablility_nack && _ttl > 0) { + if (has_two_options_) { + its_message->decrease_number_required_acks(); + } insert_subscription_nack(its_message, _service, _instance, _eventgroup, _counter, _major, _reserved); boost::system::error_code ec; @@ -2275,6 +2395,9 @@ void service_discovery_impl::handle_eventgroup_subscription(service_t _service, } its_info = std::make_shared < eventgroupinfo > (_major, 0); if(_ttl > 0) { + if (has_two_options_) { + its_message->decrease_number_required_acks(); + } insert_subscription_nack(its_message, _service, _instance, _eventgroup, _counter, _major, _reserved); } @@ -2305,7 +2428,7 @@ void service_discovery_impl::handle_eventgroup_subscription(service_t _service, << std::hex << std::setw(4) << std::setfill('0') << _eventgroup << "] " << _message_id->sender_.to_string(ec) << " session: " << std::hex << std::setw(4) << std::setfill('0') << _message_id->session_; - if (ILLEGAL_PORT != _second_port) { + if (has_two_options_) { its_message->decrease_number_required_acks(); } return; @@ -2337,7 +2460,7 @@ void service_discovery_impl::handle_eventgroup_subscription(service_t _service, << std::hex << std::setw(4) << std::setfill('0') << _eventgroup << "] " << _message_id->sender_.to_string(ec) << " session: " << std::hex << std::setw(4) << std::setfill('0') << _message_id->session_; - if (ILLEGAL_PORT != _first_port) { + if (has_two_options_) { its_message->decrease_number_required_acks(); } return; diff --git a/implementation/utility/src/utility.cpp b/implementation/utility/src/utility.cpp index e368fa6..6b633ea 100644 --- a/implementation/utility/src/utility.cpp +++ b/implementation/utility/src/utility.cpp @@ -342,17 +342,21 @@ bool utility::auto_configuration_init(const std::shared_ptr &_con } else { the_configuration_data__ = configuration_data; - if (EOWNERDEAD == pthread_mutex_lock(&the_configuration_data__->mutex_)) { + int its_result = pthread_mutex_lock(&the_configuration_data__->mutex_); + + used_client_ids__ = reinterpret_cast( + reinterpret_cast(&the_configuration_data__->routing_manager_host_) + + sizeof(unsigned short)); + + if (EOWNERDEAD == its_result) { VSOMEIP_WARNING << "utility::auto_configuration_init EOWNERDEAD"; check_client_id_consistency(); if (0 != pthread_mutex_consistent(&the_configuration_data__->mutex_)) { VSOMEIP_ERROR << "pthread_mutex_consistent() failed "; } } + its_configuration_refs__++; - used_client_ids__ = reinterpret_cast( - reinterpret_cast(&the_configuration_data__->routing_manager_host_) - + sizeof(unsigned short)); pthread_mutex_unlock(&the_configuration_data__->mutex_); } diff --git a/test/routing_tests/conf/local_routing_test_starter.sh.bat.in b/test/routing_tests/conf/local_routing_test_starter.sh.bat.in index ca8582f..d7abe64 100755 --- a/test/routing_tests/conf/local_routing_test_starter.sh.bat.in +++ b/test/routing_tests/conf/local_routing_test_starter.sh.bat.in @@ -35,7 +35,12 @@ check_tcp_udp_sockets_are_closed () # Start the service export VSOMEIP_APPLICATION_NAME=local_routing_test_service -export VSOMEIP_CONFIGURATION=local_routing_test_service.json +if [ "$VSOMEIP_CONFIGURATION_SERVICE" != "" ] +then + export VSOMEIP_CONFIGURATION=$VSOMEIP_CONFIGURATION_SERVICE +else + export VSOMEIP_CONFIGURATION=local_routing_test_service.json +fi ./local_routing_test_service & SERIVCE_PID=$! sleep 1; @@ -44,7 +49,12 @@ check_tcp_udp_sockets_are_closed $SERIVCE_PID # Start the client export VSOMEIP_APPLICATION_NAME=local_routing_test_client -export VSOMEIP_CONFIGURATION=local_routing_test_client.json +if [ "$VSOMEIP_CONFIGURATION_CLIENT" != "" ] +then + export VSOMEIP_CONFIGURATION=$VSOMEIP_CONFIGURATION_CLIENT +else + export VSOMEIP_CONFIGURATION=local_routing_test_client.json +fi ./local_routing_test_client & CLIENT_PID=$! -- cgit v1.2.1