diff --git a/ddspipe_core/include/ddspipe_core/types/dds/CustomTransport.hpp b/ddspipe_core/include/ddspipe_core/types/dds/CustomTransport.hpp new file mode 100644 index 00000000..f705f374 --- /dev/null +++ b/ddspipe_core/include/ddspipe_core/types/dds/CustomTransport.hpp @@ -0,0 +1,43 @@ +// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// limitations under the License. + +#pragma once + +namespace eprosima { +namespace ddspipe { +namespace core { +namespace types { + +//! Different options for transport configuration +enum class TransportDescriptors +{ + builtin, + udp_only, + shm_only +}; + +//! Possible values for Ignore Participant Flags +enum class IgnoreParticipantFlags +{ + no_filter, + filter_different_host, + filter_different_process, + filter_same_process, + filter_different_and_same_process +}; + +} /* namespace types */ +} /* namespace core */ +} /* namespace ddspipe */ +} /* namespace eprosima */ diff --git a/ddspipe_participants/include/ddspipe_participants/configuration/SimpleParticipantConfiguration.hpp b/ddspipe_participants/include/ddspipe_participants/configuration/SimpleParticipantConfiguration.hpp index af259e50..37fe7def 100644 --- a/ddspipe_participants/include/ddspipe_participants/configuration/SimpleParticipantConfiguration.hpp +++ b/ddspipe_participants/include/ddspipe_participants/configuration/SimpleParticipantConfiguration.hpp @@ -14,9 +14,11 @@ #pragma once +#include +#include #include #include -#include +#include namespace eprosima { namespace ddspipe { @@ -48,6 +50,12 @@ struct SimpleParticipantConfiguration : public ParticipantConfiguration ///////////////////////// core::types::DomainId domain {0u}; + + std::set whitelist {}; + + core::types::TransportDescriptors transport {core::types::TransportDescriptors::builtin}; + + core::types::IgnoreParticipantFlags ignore_participant_flags {core::types::IgnoreParticipantFlags::no_filter}; }; } /* namespace participants */ diff --git a/ddspipe_participants/include/ddspipe_participants/participant/rtps/CommonParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/rtps/CommonParticipant.hpp index 6fd71382..b3608b58 100644 --- a/ddspipe_participants/include/ddspipe_participants/participant/rtps/CommonParticipant.hpp +++ b/ddspipe_participants/include/ddspipe_participants/participant/rtps/CommonParticipant.hpp @@ -19,16 +19,18 @@ #include #include #include -#include #include +#include + -#include -#include #include #include +#include +#include -#include #include +#include +#include namespace eprosima { namespace ddspipe { @@ -156,6 +158,16 @@ class CommonParticipant const core::types::DdsTopic& topic, const core::types::ParticipantId& discoverer_id); + /** + * @brief Create a transport descriptor with given whitelist. + * + * This templated method is specialized for UPDv4, UDPv6, TCPv4 and TCPv6. + */ + template + DDSPIPE_PARTICIPANTS_DllAPI + static std::shared_ptr create_descriptor( + std::set whitelist = {}); + protected: /** diff --git a/ddspipe_participants/include/ddspipe_participants/participant/rtps/SimpleParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/rtps/SimpleParticipant.hpp index 668848a7..ee18060e 100644 --- a/ddspipe_participants/include/ddspipe_participants/participant/rtps/SimpleParticipant.hpp +++ b/ddspipe_participants/include/ddspipe_participants/participant/rtps/SimpleParticipant.hpp @@ -46,6 +46,14 @@ class SimpleParticipant : public CommonParticipant const std::shared_ptr& participant_configuration, const std::shared_ptr& payload_pool, const std::shared_ptr& discovery_database); + +protected: + + /** + * @brief Static method that gives the attributes for a Simple Participant. + */ + static fastrtps::rtps::RTPSParticipantAttributes reckon_participant_attributes_( + const SimpleParticipantConfiguration* configuration); }; } /* namespace rtps */ diff --git a/ddspipe_participants/src/cpp/configuration/SimpleParticipantConfiguration.cpp b/ddspipe_participants/src/cpp/configuration/SimpleParticipantConfiguration.cpp index 8c5f34e8..b7ac65ae 100644 --- a/ddspipe_participants/src/cpp/configuration/SimpleParticipantConfiguration.cpp +++ b/ddspipe_participants/src/cpp/configuration/SimpleParticipantConfiguration.cpp @@ -15,6 +15,7 @@ #include #include +#include namespace eprosima { namespace ddspipe { @@ -34,6 +35,16 @@ bool SimpleParticipantConfiguration::is_valid( return false; } + // Check whitelist interfaces + for (types::IpType ip : whitelist) + { + if (!types::Address::is_ipv4_correct(ip)) + { + error_msg << "Incorrect IPv4 address " << ip << " in whitelist interfaces. "; + return false; + } + } + return true; } diff --git a/ddspipe_participants/src/cpp/participant/dynamic_types/DynTypesParticipant.cpp b/ddspipe_participants/src/cpp/participant/dynamic_types/DynTypesParticipant.cpp index a1caebd1..20e493a3 100644 --- a/ddspipe_participants/src/cpp/participant/dynamic_types/DynTypesParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/dynamic_types/DynTypesParticipant.cpp @@ -26,7 +26,9 @@ #include #include #include - +#include +#include +#include #include #include @@ -179,6 +181,10 @@ void DynTypesParticipant::internal_notify_type_object_( void DynTypesParticipant::initialize_internal_dds_participant_() { + + std::shared_ptr configuration = + std::dynamic_pointer_cast(this->configuration_); + eprosima::fastdds::dds::DomainParticipantQos pqos; pqos.name(this->id()); @@ -186,6 +192,68 @@ void DynTypesParticipant::initialize_internal_dds_participant_() pqos.wire_protocol().builtin.typelookup_config.use_server = false; pqos.wire_protocol().builtin.typelookup_config.use_client = true; + // Configure Participant transports + if (configuration->transport == core::types::TransportDescriptors::builtin) + { + if (!configuration->whitelist.empty()) + { + pqos.transport().use_builtin_transports = false; + + std::shared_ptr shm_transport = + std::make_shared(); + pqos.transport().user_transports.push_back(shm_transport); + + std::shared_ptr udp_transport = + create_descriptor(configuration->whitelist); + pqos.transport().user_transports.push_back(udp_transport); + } + } + else if (configuration->transport == core::types::TransportDescriptors::shm_only) + { + pqos.transport().use_builtin_transports = false; + + std::shared_ptr shm_transport = + std::make_shared(); + pqos.transport().user_transports.push_back(shm_transport); + } + else if (configuration->transport == core::types::TransportDescriptors::udp_only) + { + pqos.transport().use_builtin_transports = false; + + std::shared_ptr udp_transport = + create_descriptor(configuration->whitelist); + pqos.transport().user_transports.push_back(udp_transport); + } + + // Participant discovery filter configuration + switch (configuration->ignore_participant_flags) + { + case core::types::IgnoreParticipantFlags::no_filter: + pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = + eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::NO_FILTER; + break; + case core::types::IgnoreParticipantFlags::filter_different_host: + pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = + eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_HOST; + break; + case core::types::IgnoreParticipantFlags::filter_different_process: + pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = + eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_PROCESS; + break; + case core::types::IgnoreParticipantFlags::filter_same_process: + pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = + eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_SAME_PROCESS; + break; + case core::types::IgnoreParticipantFlags::filter_different_and_same_process: + pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = + static_cast( + eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_PROCESS | + eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_SAME_PROCESS); + break; + default: + break; + } + // Force DDS entities to be created disabled // NOTE: this is very dangerous because we are modifying a global variable (and a not thread safe one) in a // local function. @@ -200,7 +268,7 @@ void DynTypesParticipant::initialize_internal_dds_participant_() // CREATE THE PARTICIPANT dds_participant_ = eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->create_participant( - std::dynamic_pointer_cast(this->configuration_)->domain, + configuration->domain, pqos); dds_participant_->set_listener(this); diff --git a/ddspipe_participants/src/cpp/participant/rtps/CommonParticipant.cpp b/ddspipe_participants/src/cpp/participant/rtps/CommonParticipant.cpp index b2b297f6..f87c24fe 100644 --- a/ddspipe_participants/src/cpp/participant/rtps/CommonParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/rtps/CommonParticipant.cpp @@ -15,6 +15,10 @@ #include +#include +#include +#include +#include #include #include @@ -276,6 +280,114 @@ core::types::Endpoint CommonParticipant::simulate_endpoint( return endpoint; } +template<> +std::shared_ptr +CommonParticipant::create_descriptor( + std::set whitelist) +{ + std::shared_ptr udp_transport = + std::make_shared(); + + for (const types::IpType& ip : whitelist) + { + if (types::Address::is_ipv4_correct(ip)) + { + udp_transport->interfaceWhiteList.emplace_back(ip); + logInfo(DDSPIPE_COMMON_PARTICIPANT, + "Adding " << ip << " to UDP whitelist interfaces."); + } + else + { + // Invalid address, continue with next one + logWarning(DDSPIPE_COMMON_PARTICIPANT, + "Not valid IPv4. Discarding UDP whitelist interface " << ip << "."); + } + } + + return udp_transport; +} + +template<> +std::shared_ptr +CommonParticipant::create_descriptor( + std::set whitelist) +{ + std::shared_ptr udp_transport = + std::make_shared(); + + for (const types::IpType& ip : whitelist) + { + if (types::Address::is_ipv6_correct(ip)) + { + udp_transport->interfaceWhiteList.emplace_back(ip); + logInfo(DDSPIPE_COMMON_PARTICIPANT, + "Adding " << ip << " to UDP whitelist interfaces."); + } + else + { + // Invalid address, continue with next one + logWarning(DDSPIPE_COMMON_PARTICIPANT, + "Not valid IPv6. Discarding UDP whitelist interface " << ip << "."); + } + } + + return udp_transport; +} + +template<> +std::shared_ptr +CommonParticipant::create_descriptor( + std::set whitelist) +{ + std::shared_ptr tcp_transport = + std::make_shared(); + + for (const types::IpType& ip : whitelist) + { + if (types::Address::is_ipv4_correct(ip)) + { + tcp_transport->interfaceWhiteList.emplace_back(ip); + logInfo(DDSPIPE_COMMON_PARTICIPANT, + "Adding " << ip << " to TCP whitelist interfaces."); + } + else + { + // Invalid address, continue with next one + logWarning(DDSPIPE_COMMON_PARTICIPANT, + "Not valid IPv4. Discarding TCP whitelist interface " << ip << "."); + } + } + + return tcp_transport; +} + +template<> +std::shared_ptr +CommonParticipant::create_descriptor( + std::set whitelist) +{ + std::shared_ptr tcp_transport = + std::make_shared(); + + for (const types::IpType& ip : whitelist) + { + if (types::Address::is_ipv6_correct(ip)) + { + tcp_transport->interfaceWhiteList.emplace_back(ip); + logInfo(DDSPIPE_COMMON_PARTICIPANT, + "Adding " << ip << " to TCP whitelist interfaces."); + } + else + { + // Invalid address, continue with next one + logWarning(DDSPIPE_COMMON_PARTICIPANT, + "Not valid IPv6. Discarding TCP whitelist interface " << ip << "."); + } + } + + return tcp_transport; +} + bool CommonParticipant::is_repeater() const noexcept { return configuration_->is_repeater; diff --git a/ddspipe_participants/src/cpp/participant/rtps/DiscoveryServerParticipant.cpp b/ddspipe_participants/src/cpp/participant/rtps/DiscoveryServerParticipant.cpp index 2892886d..8667bb34 100644 --- a/ddspipe_participants/src/cpp/participant/rtps/DiscoveryServerParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/rtps/DiscoveryServerParticipant.cpp @@ -120,7 +120,8 @@ DiscoveryServerParticipant::reckon_participant_attributes_( } else { - descriptor = std::make_shared(); + descriptor = create_descriptor( + configuration->whitelist); descriptor->add_listener_port(address.port()); descriptor->set_WAN_address(address.ip()); @@ -139,7 +140,7 @@ DiscoveryServerParticipant::reckon_participant_attributes_( has_listening_tcp_ipv6 = true; std::shared_ptr descriptor = - std::make_shared(); + create_descriptor(configuration->whitelist); descriptor->add_listener_port(address.port()); @@ -299,7 +300,7 @@ DiscoveryServerParticipant::reckon_participant_attributes_( if (has_connection_tcp_ipv4 && !has_listening_tcp_ipv4) { std::shared_ptr descriptor = - std::make_shared(); + create_descriptor(configuration->whitelist); // Enable TLS if (tls_config.is_active()) @@ -315,7 +316,7 @@ DiscoveryServerParticipant::reckon_participant_attributes_( if (has_connection_tcp_ipv6 && !has_listening_tcp_ipv6) { std::shared_ptr descriptor = - std::make_shared(); + create_descriptor(configuration->whitelist); // Enable TLS if (tls_config.is_active()) @@ -333,7 +334,7 @@ DiscoveryServerParticipant::reckon_participant_attributes_( if (has_udp_ipv4) { std::shared_ptr descriptor = - std::make_shared(); + create_descriptor(configuration->whitelist); params.userTransports.push_back(descriptor); logDebug(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, @@ -342,7 +343,7 @@ DiscoveryServerParticipant::reckon_participant_attributes_( if (has_udp_ipv6) { std::shared_ptr descriptor_v6 = - std::make_shared(); + create_descriptor(configuration->whitelist); params.userTransports.push_back(descriptor_v6); logDebug(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, diff --git a/ddspipe_participants/src/cpp/participant/rtps/InitialPeersParticipant.cpp b/ddspipe_participants/src/cpp/participant/rtps/InitialPeersParticipant.cpp index 1f99e49e..e5b624aa 100644 --- a/ddspipe_participants/src/cpp/participant/rtps/InitialPeersParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/rtps/InitialPeersParticipant.cpp @@ -115,7 +115,8 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic } else { - descriptor = std::make_shared(); + descriptor = create_descriptor( + configuration->whitelist); descriptor->add_listener_port(address.port()); descriptor->set_WAN_address(address.ip()); @@ -134,7 +135,7 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic has_listening_tcp_ipv6 = true; std::shared_ptr descriptor = - std::make_shared(); + create_descriptor(configuration->whitelist); descriptor->add_listener_port(address.port()); @@ -254,7 +255,7 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic if (has_connection_tcp_ipv4 && !has_listening_tcp_ipv4) { std::shared_ptr descriptor = - std::make_shared(); + create_descriptor(configuration->whitelist); // Enable TLS if (tls_config.is_active()) @@ -271,7 +272,7 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic if (has_connection_tcp_ipv6 && !has_listening_tcp_ipv6) { std::shared_ptr descriptor = - std::make_shared(); + create_descriptor(configuration->whitelist); // Enable TLS if (tls_config.is_active()) @@ -289,7 +290,7 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic if (has_udp_ipv4) { std::shared_ptr descriptor = - std::make_shared(); + create_descriptor(configuration->whitelist); params.userTransports.push_back(descriptor); logDebug(DDSPIPE_INITIALPEERS_PARTICIPANT, @@ -299,7 +300,7 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic if (has_udp_ipv6) { std::shared_ptr descriptor_v6 = - std::make_shared(); + create_descriptor(configuration->whitelist); params.userTransports.push_back(descriptor_v6); logDebug(DDSPIPE_INITIALPEERS_PARTICIPANT, diff --git a/ddspipe_participants/src/cpp/participant/rtps/SimpleParticipant.cpp b/ddspipe_participants/src/cpp/participant/rtps/SimpleParticipant.cpp index e8745d7e..12c42db1 100644 --- a/ddspipe_participants/src/cpp/participant/rtps/SimpleParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/rtps/SimpleParticipant.cpp @@ -16,6 +16,9 @@ #include #include +#include +#include +#include #include @@ -33,10 +36,82 @@ SimpleParticipant::SimpleParticipant( payload_pool, discovery_database, participant_configuration->domain, - CommonParticipant::reckon_participant_attributes_(participant_configuration.get())) + reckon_participant_attributes_(participant_configuration.get())) { } +fastrtps::rtps::RTPSParticipantAttributes +SimpleParticipant::reckon_participant_attributes_( + const SimpleParticipantConfiguration* configuration) +{ + // Use default as base attributes + fastrtps::rtps::RTPSParticipantAttributes params = CommonParticipant::reckon_participant_attributes_(configuration); + + // Configure Participant transports + if (configuration->transport == core::types::TransportDescriptors::builtin) + { + if (!configuration->whitelist.empty()) + { + params.useBuiltinTransports = false; + + std::shared_ptr shm_transport = + std::make_shared(); + params.userTransports.push_back(shm_transport); + + std::shared_ptr udp_transport = + create_descriptor(configuration->whitelist); + params.userTransports.push_back(udp_transport); + } + } + else if (configuration->transport == core::types::TransportDescriptors::shm_only) + { + params.useBuiltinTransports = false; + + std::shared_ptr shm_transport = + std::make_shared(); + params.userTransports.push_back(shm_transport); + } + else if (configuration->transport == core::types::TransportDescriptors::udp_only) + { + params.useBuiltinTransports = false; + + std::shared_ptr udp_transport = + create_descriptor(configuration->whitelist); + params.userTransports.push_back(udp_transport); + } + + // Participant discovery filter configuration + switch (configuration->ignore_participant_flags) + { + case core::types::IgnoreParticipantFlags::no_filter: + params.builtin.discovery_config.ignoreParticipantFlags = + eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::NO_FILTER; + break; + case core::types::IgnoreParticipantFlags::filter_different_host: + params.builtin.discovery_config.ignoreParticipantFlags = + eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_HOST; + break; + case core::types::IgnoreParticipantFlags::filter_different_process: + params.builtin.discovery_config.ignoreParticipantFlags = + eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_PROCESS; + break; + case core::types::IgnoreParticipantFlags::filter_same_process: + params.builtin.discovery_config.ignoreParticipantFlags = + eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_SAME_PROCESS; + break; + case core::types::IgnoreParticipantFlags::filter_different_and_same_process: + params.builtin.discovery_config.ignoreParticipantFlags = + static_cast( + eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_PROCESS | + eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_SAME_PROCESS); + break; + default: + break; + } + + return params; +} + } /* namespace rtps */ } /* namespace participants */ } /* namespace ddspipe */ diff --git a/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp b/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp index e0eb9e80..eef46cab 100644 --- a/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp +++ b/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp @@ -57,6 +57,24 @@ constexpr const char* ECHO_DISCOVERY_TAG("discovery"); //! Echo Discovery recei constexpr const char* ECHO_VERBOSE_TAG("verbose"); //! Echo in verbose mode // RTPS related tags + +// Transport related tags +constexpr const char* WHITELIST_INTERFACES_TAG("whitelist-interfaces"); //! Whitelist interfaces + +// Custom transport descriptors tags +constexpr const char* TRANSPORT_DESCRIPTORS_TRANSPORT_TAG("transport"); //! Custom transport descriptors +constexpr const char* TRANSPORT_DESCRIPTORS_BUILTIN_TAG("builtin"); //! Builtin transport (UDP + SHM) (default) +constexpr const char* TRANSPORT_DESCRIPTORS_UDP_TAG("udp"); //! UDP only +constexpr const char* TRANSPORT_DESCRIPTORS_SHM_TAG("shm"); //! Shared Memory only + +// Participant discovery settings +constexpr const char* IGNORE_PARTICIPANT_FLAGS_TAG("ignore-participant-flags"); //! Ignore Participant Flags +constexpr const char* IGNORE_PARTICIPANT_FLAGS_NO_FILTER_TAG("no_filter"); //! No filter (default) +constexpr const char* IGNORE_PARTICIPANT_FLAGS_DIFFERENT_HOST_TAG("filter_different_host"); //! Discovery traffic from another host is discarded +constexpr const char* IGNORE_PARTICIPANT_FLAGS_DIFFERENT_PROCESS_TAG("filter_different_process"); //! Discovery traffic from another process on same host is discarded +constexpr const char* IGNORE_PARTICIPANT_FLAGS_SAME_PROCESS_TAG("filter_same_process"); //! Discovery traffic from own process is discarded +constexpr const char* IGNORE_PARTICIPANT_FLAGS_DIFFERENT_AND_SAME_PROCESS_TAG("filter_different_and_same_process"); //! Discovery traffic from own host is discarded + // Simple RTPS related tags constexpr const char* DOMAIN_ID_TAG("domain"); //! Domain Id of the participant diff --git a/ddspipe_yaml/src/cpp/YamlReader_participants.cpp b/ddspipe_yaml/src/cpp/YamlReader_participants.cpp index c9188e82..a8aa358c 100644 --- a/ddspipe_yaml/src/cpp/YamlReader_participants.cpp +++ b/ddspipe_yaml/src/cpp/YamlReader_participants.cpp @@ -132,6 +132,33 @@ void YamlReader::fill( { object.domain = get(yml, DOMAIN_ID_TAG, version); } + + // Optional whitelist interfaces + if (YamlReader::is_tag_present(yml, WHITELIST_INTERFACES_TAG)) + { + object.whitelist = YamlReader::get_set(yml, WHITELIST_INTERFACES_TAG, version); + } + + // Optional get Transport descriptors + if (YamlReader::is_tag_present(yml, TRANSPORT_DESCRIPTORS_TRANSPORT_TAG)) + { + object.transport = get(yml, TRANSPORT_DESCRIPTORS_TRANSPORT_TAG, version); + } + else + { + object.transport = core::types::TransportDescriptors::builtin; + } + + // Optional get ignore participant flags + if (YamlReader::is_tag_present(yml, IGNORE_PARTICIPANT_FLAGS_TAG)) + { + object.ignore_participant_flags = get(yml, IGNORE_PARTICIPANT_FLAGS_TAG, + version); + } + else + { + object.ignore_participant_flags = core::types::IgnoreParticipantFlags::no_filter; + } } template <> @@ -157,6 +184,12 @@ void YamlReader::fill( // Parent class fill fill(object, yml, version); + // Optional whitelist interfaces + if (YamlReader::is_tag_present(yml, WHITELIST_INTERFACES_TAG)) + { + object.whitelist = YamlReader::get_set(yml, WHITELIST_INTERFACES_TAG, version); + } + // Optional listening addresses if (YamlReader::is_tag_present(yml, LISTENING_ADDRESSES_TAG)) { @@ -219,6 +252,12 @@ void YamlReader::fill( // Parent class fill fill(object, yml, version); + // Optional whitelist interfaces + if (YamlReader::is_tag_present(yml, WHITELIST_INTERFACES_TAG)) + { + object.whitelist = YamlReader::get_set(yml, WHITELIST_INTERFACES_TAG, version); + } + // Optional listening addresses if (YamlReader::is_tag_present(yml, LISTENING_ADDRESSES_TAG)) { diff --git a/ddspipe_yaml/src/cpp/YamlReader_types.cpp b/ddspipe_yaml/src/cpp/YamlReader_types.cpp index 74283a6b..5cecaede 100644 --- a/ddspipe_yaml/src/cpp/YamlReader_types.cpp +++ b/ddspipe_yaml/src/cpp/YamlReader_types.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -48,6 +49,39 @@ namespace yaml { using namespace eprosima::ddspipe::core::types; using namespace eprosima::ddspipe::participants::types; +template <> +DDSPIPE_YAML_DllAPI +TransportDescriptors YamlReader::get( + const Yaml& yml, + const YamlReaderVersion /* version */) +{ + return get_enumeration( + yml, + { + {TRANSPORT_DESCRIPTORS_BUILTIN_TAG, TransportDescriptors::builtin}, + {TRANSPORT_DESCRIPTORS_UDP_TAG, TransportDescriptors::udp_only}, + {TRANSPORT_DESCRIPTORS_SHM_TAG, TransportDescriptors::shm_only} + }); +} + +template <> +DDSPIPE_YAML_DllAPI +IgnoreParticipantFlags YamlReader::get( + const Yaml& yml, + const YamlReaderVersion /* version */) +{ + return get_enumeration( + yml, + { + {IGNORE_PARTICIPANT_FLAGS_NO_FILTER_TAG, IgnoreParticipantFlags::no_filter}, + {IGNORE_PARTICIPANT_FLAGS_DIFFERENT_HOST_TAG, IgnoreParticipantFlags::filter_different_host}, + {IGNORE_PARTICIPANT_FLAGS_DIFFERENT_PROCESS_TAG, IgnoreParticipantFlags::filter_different_process}, + {IGNORE_PARTICIPANT_FLAGS_SAME_PROCESS_TAG, IgnoreParticipantFlags::filter_same_process}, + {IGNORE_PARTICIPANT_FLAGS_DIFFERENT_AND_SAME_PROCESS_TAG, + IgnoreParticipantFlags::filter_different_and_same_process}, + }); +} + template <> DDSPIPE_YAML_DllAPI YamlReaderVersion YamlReader::get( @@ -73,7 +107,7 @@ TransportProtocol YamlReader::get( yml, { {ADDRESS_TRANSPORT_TCP_TAG, TransportProtocol::tcp}, - {ADDRESS_TRANSPORT_UDP_TAG, TransportProtocol::udp}, + {ADDRESS_TRANSPORT_UDP_TAG, TransportProtocol::udp} }); }