diff --git a/ddspipe_participants/include/ddspipe_participants/participant/dds/CommonParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/dds/CommonParticipant.hpp index 669cd04f..53d6112e 100644 --- a/ddspipe_participants/include/ddspipe_participants/participant/dds/CommonParticipant.hpp +++ b/ddspipe_participants/include/ddspipe_participants/participant/dds/CommonParticipant.hpp @@ -94,6 +94,7 @@ class CommonParticipant : public core::IParticipant, public fastdds::dds::Domain * @brief Create a writer object * * Depending on the Topic QoS creates a Basic or Specific Writer. + * If it fails to create the writer it will return a blank one. */ DDSPIPE_PARTICIPANTS_DllAPI std::shared_ptr create_writer( @@ -103,6 +104,7 @@ class CommonParticipant : public core::IParticipant, public fastdds::dds::Domain * @brief Create a reader object * * Depending on the Topic QoS creates a Basic or Specific Reader. + * If it fails to create the reader it will return a blank one. */ DDSPIPE_PARTICIPANTS_DllAPI std::shared_ptr create_reader( @@ -130,6 +132,20 @@ class CommonParticipant : public core::IParticipant, public fastdds::dds::Domain const fastdds::dds::PublicationBuiltinTopicData& info, bool& /*should_be_ignored*/) override; + ////////////////// + // STATIC METHODS + ////////////////// + + /** + * @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: ///////////////////////// @@ -140,7 +156,9 @@ class CommonParticipant : public core::IParticipant, public fastdds::dds::Domain CommonParticipant( const std::shared_ptr& participant_configuration, const std::shared_ptr& payload_pool, - const std::shared_ptr& discovery_database); + const std::shared_ptr& discovery_database, + const core::types::DomainId& domain_id, + const fastdds::dds::DomainParticipantQos& participant_attributes); ///////////////////////// // INTERNAL VIRTUAL METHODS @@ -187,13 +205,20 @@ class CommonParticipant : public core::IParticipant, public fastdds::dds::Domain */ std::set type_names_registered_; - const std::shared_ptr configuration_; + //! Participant configuration + const std::shared_ptr configuration_; //! DDS Router shared Payload Pool const std::shared_ptr payload_pool_; //! DDS Router shared Discovery Database const std::shared_ptr discovery_database_; + + //! Domain Id to create the internal DDS Participant. + core::types::DomainId domain_id_; + + //! Participant QoS + fastdds::dds::DomainParticipantQos participant_qos_; }; } /* namespace dds */ diff --git a/ddspipe_participants/include/ddspipe_participants/participant/dds/DiscoveryServerParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/dds/DiscoveryServerParticipant.hpp new file mode 100644 index 00000000..2f13a17d --- /dev/null +++ b/ddspipe_participants/include/ddspipe_participants/participant/dds/DiscoveryServerParticipant.hpp @@ -0,0 +1,58 @@ +// Copyright 2024 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, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +#include +#include +#include + +namespace eprosima { +namespace ddspipe { +namespace participants { +namespace dds { + +/** + * TODO + */ +class DiscoveryServerParticipant + : public CommonParticipant +{ +public: + + DDSPIPE_PARTICIPANTS_DllAPI + DiscoveryServerParticipant( + const std::shared_ptr& participant_configuration, + const std::shared_ptr& payload_pool, + const std::shared_ptr& discovery_database); + +protected: + + ///// + // DDS specific methods + + /** + * @brief Static method that gives the QoS for a Discovery Server Participant. + * + */ + static fastdds::dds::DomainParticipantQos reckon_participant_qos_( + const DiscoveryServerParticipantConfiguration* participant_configuration); +}; + +} /* namespace dds */ +} /* namespace participants */ +} /* namespace ddspipe */ +} /* namespace eprosima */ diff --git a/ddspipe_participants/include/ddspipe_participants/participant/dds/InitialPeersParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/dds/InitialPeersParticipant.hpp new file mode 100644 index 00000000..10cf622b --- /dev/null +++ b/ddspipe_participants/include/ddspipe_participants/participant/dds/InitialPeersParticipant.hpp @@ -0,0 +1,58 @@ +// Copyright 2024 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, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +#include +#include +#include + +namespace eprosima { +namespace ddspipe { +namespace participants { +namespace dds { + +/** + * TODO + */ +class InitialPeersParticipant + : public CommonParticipant +{ +public: + + DDSPIPE_PARTICIPANTS_DllAPI + InitialPeersParticipant( + const std::shared_ptr& participant_configuration, + const std::shared_ptr& payload_pool, + const std::shared_ptr& discovery_database); + +protected: + + ///// + // DDS specific methods + + /** + * @brief Static method that gives the QoS for a Initial Peers Participant. + * + */ + static fastdds::dds::DomainParticipantQos reckon_participant_qos_( + const InitialPeersParticipantConfiguration* participant_configuration); +}; + +} /* namespace dds */ +} /* namespace participants */ +} /* namespace ddspipe */ +} /* namespace eprosima */ diff --git a/ddspipe_participants/include/ddspipe_participants/participant/dds/SimpleParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/dds/SimpleParticipant.hpp new file mode 100644 index 00000000..a8bb8242 --- /dev/null +++ b/ddspipe_participants/include/ddspipe_participants/participant/dds/SimpleParticipant.hpp @@ -0,0 +1,66 @@ +// Copyright 2024 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, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include + +namespace eprosima { +namespace ddspipe { +namespace participants { +namespace dds { + +/** + * Participant with Simple Discovery Protocol. + * + * Standard RTPS Participant with Simple Discovery and default attributes. + */ +class SimpleParticipant : public CommonParticipant +{ +public: + + /** + * @brief Construct a new Dummy Participant object + * + * It uses the \c BaseParticipant constructor. + * Apart from BaseParticipant, it creates a new RTPSParticipant with default Attributes and domain given + * by configuration. + * + * @throw \c InitializationException in case any internal error has ocurred while creating RTPSParticipant + * @throw \c IConfigurationException in case configuration was incorrectly set + */ + DDSPIPE_PARTICIPANTS_DllAPI + SimpleParticipant( + const std::shared_ptr& participant_configuration, + const std::shared_ptr& payload_pool, + const std::shared_ptr& discovery_database); + +protected: + + ///// + // DDS specific methods + + /** + * @brief Static method that gives the QoS for a Simple Participant. + * + */ + static fastdds::dds::DomainParticipantQos reckon_participant_qos_( + const SimpleParticipantConfiguration* participant_configuration); +}; + +} /* namespace dds */ +} /* namespace participants */ +} /* namespace ddspipe */ +} /* namespace eprosima */ diff --git a/ddspipe_participants/include/ddspipe_participants/participant/dds/XmlParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/dds/XmlParticipant.hpp index 3c687cac..17b8f519 100644 --- a/ddspipe_participants/include/ddspipe_participants/participant/dds/XmlParticipant.hpp +++ b/ddspipe_participants/include/ddspipe_participants/participant/dds/XmlParticipant.hpp @@ -56,20 +56,15 @@ class XmlParticipant protected: - ///////////////////////// - // INTERNAL METHODS - ///////////////////////// + ///// + // DDS specific methods - virtual - fastdds::dds::DomainParticipantQos - reckon_participant_qos_() const override; - - ///////////////////////// - // INTERNAL VARIABLES - ///////////////////////// - - //! Participant configuration - const XmlParticipantConfiguration& xml_specific_configuration_; + /** + * @brief Static method that gives the QoS for a XML Participant. + * + */ + static fastdds::dds::DomainParticipantQos reckon_participant_qos_( + const XmlParticipantConfiguration* participant_configuration); }; } /* namespace dds */ diff --git a/ddspipe_participants/src/cpp/participant/dds/CommonParticipant.cpp b/ddspipe_participants/src/cpp/participant/dds/CommonParticipant.cpp index bb40db1e..c5d360ef 100644 --- a/ddspipe_participants/src/cpp/participant/dds/CommonParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/dds/CommonParticipant.cpp @@ -16,6 +16,11 @@ #include +#include +#include +#include +#include + #include #include @@ -44,16 +49,12 @@ using namespace eprosima::ddspipe::core::types; CommonParticipant::~CommonParticipant() { - // In case init has been done, remove everything - if (dds_participant_) + if (nullptr != dds_participant_) { - dds_participant_->set_listener(nullptr); - - for (auto& topic : dds_topics_) - { - dds_participant_->delete_topic(topic.second); - } + // Delete DDS entities contained within the DomainParticipant + dds_participant_->delete_contained_entities(); + // Delete DomainParticipant eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->delete_participant(dds_participant_); } } @@ -86,7 +87,7 @@ void CommonParticipant::init() eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_qos( original_fact_qos); - if (dds_participant_ == nullptr) + if (!dds_participant_) { throw utils::InitializationException(STR_ENTRY << "Error creating DDS Participant " << id() << "."); } @@ -95,6 +96,123 @@ void CommonParticipant::init() { throw utils::InitializationException(STR_ENTRY << "Error enabling DDS Participant " << id() << "."); } + + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_PARTICIPANT, + "New Participant created with id " << this->id() << + " in domain " << domain_id_ << " with guid " << dds_participant_->guid() << + (this->is_repeater() ? " (repeater)" : " (non repeater)")); +} + +template<> +DDSPIPE_PARTICIPANTS_DllAPI +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); + EPROSIMA_LOG_INFO(DDSPIPE_COMMON_PARTICIPANT, + "Adding " << ip << " to UDP whitelist interfaces."); + } + else + { + // Invalid address, continue with next one + EPROSIMA_LOG_WARNING(DDSPIPE_COMMON_PARTICIPANT, + "Not valid IPv4. Discarding UDP whitelist interface " << ip << "."); + } + } + + return udp_transport; +} + +template<> +DDSPIPE_PARTICIPANTS_DllAPI +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); + EPROSIMA_LOG_INFO(DDSPIPE_COMMON_PARTICIPANT, + "Adding " << ip << " to UDP whitelist interfaces."); + } + else + { + // Invalid address, continue with next one + EPROSIMA_LOG_WARNING(DDSPIPE_COMMON_PARTICIPANT, + "Not valid IPv6. Discarding UDP whitelist interface " << ip << "."); + } + } + + return udp_transport; +} + +template<> +DDSPIPE_PARTICIPANTS_DllAPI +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); + EPROSIMA_LOG_INFO(DDSPIPE_COMMON_PARTICIPANT, + "Adding " << ip << " to TCP whitelist interfaces."); + } + else + { + // Invalid address, continue with next one + EPROSIMA_LOG_WARNING(DDSPIPE_COMMON_PARTICIPANT, + "Not valid IPv4. Discarding TCP whitelist interface " << ip << "."); + } + } + + return tcp_transport; +} + +template<> +DDSPIPE_PARTICIPANTS_DllAPI +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); + EPROSIMA_LOG_INFO(DDSPIPE_COMMON_PARTICIPANT, + "Adding " << ip << " to TCP whitelist interfaces."); + } + else + { + // Invalid address, continue with next one + EPROSIMA_LOG_WARNING(DDSPIPE_COMMON_PARTICIPANT, + "Not valid IPv6. Discarding TCP whitelist interface " << ip << "."); + } + } + + return tcp_transport; } core::types::ParticipantId CommonParticipant::id() const noexcept @@ -136,8 +254,20 @@ std::shared_ptr CommonParticipant::create_writer( return std::make_shared(); } - // Get the DDS Topic associated (create it if it does not exist) - fastdds::dds::Topic* fastdds_topic = topic_related_(dds_topic); + fastdds::dds::Topic* fastdds_topic; + try + { + // Get the DDS Topic associated (create it if it does not exist) + fastdds_topic = topic_related_(dds_topic); + } + catch (const utils::InitializationException& e) + { + EPROSIMA_LOG_WARNING( + DDSPIPE_DDS_PARTICIPANT, + e.what() + << " Execution continue but this topic will not be published in Participant " << id() << "."); + return std::make_shared(); + } if (dds_topic.topic_qos.has_partitions() || dds_topic.topic_qos.has_ownership()) { @@ -185,7 +315,20 @@ std::shared_ptr CommonParticipant::create_reader( } // Get the DDS Topic associated (create it if it does not exist) - fastdds::dds::Topic* fastdds_topic = topic_related_(dds_topic); + fastdds::dds::Topic* fastdds_topic; + try + { + // Get the DDS Topic associated (create it if it does not exist) + fastdds_topic = topic_related_(dds_topic); + } + catch (const utils::InitializationException& e) + { + EPROSIMA_LOG_WARNING( + DDSPIPE_DDS_PARTICIPANT, + e.what() + << ". Execution continue but this topic will not be subscribed in Participant " << id() << "."); + return std::make_shared(); + } if (dds_topic.topic_qos.has_partitions() || dds_topic.topic_qos.has_ownership()) { @@ -355,10 +498,14 @@ void CommonParticipant::on_data_writer_discovery( CommonParticipant::CommonParticipant( const std::shared_ptr& participant_configuration, const std::shared_ptr& payload_pool, - const std::shared_ptr& discovery_database) + const std::shared_ptr& discovery_database, + const core::types::DomainId& domain_id, + const fastdds::dds::DomainParticipantQos& participant_qos) : configuration_(participant_configuration) , payload_pool_(payload_pool) , discovery_database_(discovery_database) + , domain_id_(domain_id) + , participant_qos_(participant_qos) { // Do nothing } @@ -374,11 +521,11 @@ fastdds::dds::DomainParticipantQos CommonParticipant::add_qos_properties_( // Set app properties qos.properties().properties().emplace_back( "fastdds.application.id", - configuration_->app_id, + participant_configuration->app_id, "true"); qos.properties().properties().emplace_back( "fastdds.application.metadata", - configuration_->app_metadata, + participant_configuration->app_metadata, "true"); return qos; @@ -399,10 +546,12 @@ fastdds::dds::DomainParticipant* CommonParticipant::create_dds_participant_() fastdds::dds::StatusMask mask; mask << fastdds::dds::StatusMask::publication_matched(); mask << fastdds::dds::StatusMask::subscription_matched(); + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_PARTICIPANT, + "Creating Participant in domain " << domain_id_); return eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->create_participant( - configuration_->domain, - reckon_participant_qos_(), + domain_id_, + participant_qos_, this, mask); } diff --git a/ddspipe_participants/src/cpp/participant/dds/DiscoveryServerParticipant.cpp b/ddspipe_participants/src/cpp/participant/dds/DiscoveryServerParticipant.cpp new file mode 100644 index 00000000..8963ade5 --- /dev/null +++ b/ddspipe_participants/src/cpp/participant/dds/DiscoveryServerParticipant.cpp @@ -0,0 +1,365 @@ +// Copyright 2024 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, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +namespace eprosima { +namespace ddspipe { +namespace participants { +namespace dds { + +DiscoveryServerParticipant::DiscoveryServerParticipant( + const std::shared_ptr& participant_configuration, + const std::shared_ptr& payload_pool, + const std::shared_ptr& discovery_database) + : CommonParticipant( + participant_configuration, + payload_pool, + discovery_database, + participant_configuration->domain, + reckon_participant_qos_(participant_configuration.get())) +{ +} + +fastdds::dds::DomainParticipantQos +DiscoveryServerParticipant::reckon_participant_qos_( + const DiscoveryServerParticipantConfiguration* participant_configuration) +{ + // Use default as base qos + fastdds::dds::DomainParticipantQos pqos = CommonParticipant::reckon_participant_qos_(participant_configuration); + + // Auxiliary variable to save characters and improve readability + const core::types::GuidPrefix& discovery_server_guid_prefix = participant_configuration->discovery_server_guid_prefix; + const auto& tls_config = participant_configuration->tls_configuration; + + // Needed values to check at the end if descriptor must be set + bool has_listening_tcp_ipv4 = false; + bool has_listening_tcp_ipv6 = false; + bool has_listening_udp_ipv4 = false; + bool has_listening_udp_ipv6 = false; + bool has_connection_descriptor = false; + + pqos.transport().use_builtin_transports = false; + + ///// + // Set listening addresses + for (types::Address address : participant_configuration->listening_addresses) + { + if (!address.is_valid()) + { + // Invalid address, continue with next one + EPROSIMA_LOG_WARNING(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, + "Discard listening address: " << address << + " in Participant " << participant_configuration->id << " initialization."); + continue; + } + + // Create DS SERVER locator + eprosima::fastdds::rtps::Locator listening_locator; + listening_locator.kind = address.get_locator_kind(); + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(listening_locator, address.port()); + + std::shared_ptr descriptor; + + switch (address.get_locator_kind()) + { + case LOCATOR_KIND_UDPv4: + { + has_listening_udp_ipv4 = true; + + auto descriptor_tmp = + create_descriptor(participant_configuration->whitelist); + descriptor = descriptor_tmp; + + eprosima::fastdds::rtps::IPLocator::setIPv4(listening_locator, address.ip()); + + break; + } + + case LOCATOR_KIND_UDPv6: + { + has_listening_udp_ipv6 = true; + + auto descriptor_tmp = + create_descriptor(participant_configuration->whitelist); + descriptor = descriptor_tmp; + + eprosima::fastdds::rtps::IPLocator::setIPv6(listening_locator, address.ip()); + + break; + } + + case LOCATOR_KIND_TCPv4: + { + has_listening_tcp_ipv4 = true; + + std::shared_ptr descriptor_tmp; + + // We check if several descriptors share a WAN address. + // If so, we add a new port to the previously created descriptor. + bool same_wan_addr = false; + + auto it = pqos.transport().user_transports.begin(); + while (it != pqos.transport().user_transports.end()) + { + std::shared_ptr tmp_descriptor = + std::dynamic_pointer_cast(*it); + + if ((tmp_descriptor != nullptr) && (address.ip() == tmp_descriptor->get_WAN_address())) + { + // Save in the new descriptor the previously added descriptor with the same WAN address + descriptor_tmp = tmp_descriptor; + // Set that a descriptor with same WAN address was found + same_wan_addr = true; + // Remove the previously added descriptor as this will be replaced by the same one updated with + // more locators. + pqos.transport().user_transports.erase(it); + break; + } + } + + // Add the new locator to the descriptor if another with the same wan address was found + if (same_wan_addr) + { + descriptor_tmp->add_listener_port(address.port()); + } + else + { + descriptor_tmp = + create_descriptor( + participant_configuration->whitelist); + + descriptor_tmp->add_listener_port(address.port()); + descriptor_tmp->set_WAN_address(address.ip()); + + // Enable TLS + if (tls_config.is_active()) + { + tls_config.enable_tls(descriptor_tmp); + } + } + + descriptor = descriptor_tmp; + + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(listening_locator, address.external_port()); + eprosima::fastdds::rtps::IPLocator::setLogicalPort(listening_locator, address.external_port()); + eprosima::fastdds::rtps::IPLocator::setIPv4(listening_locator, address.ip()); + + break; + } + + case LOCATOR_KIND_TCPv6: + { + has_listening_tcp_ipv6 = true; + + auto descriptor_tmp = + create_descriptor(participant_configuration->whitelist); + descriptor_tmp->add_listener_port(address.port()); + + // Enable TLS + if (tls_config.is_active()) + { + tls_config.enable_tls(descriptor_tmp); + } + + descriptor = descriptor_tmp; + + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(listening_locator, address.external_port()); + eprosima::fastdds::rtps::IPLocator::setLogicalPort(listening_locator, address.external_port()); + eprosima::fastdds::rtps::IPLocator::setIPv6(listening_locator, address.ip()); + + break; + } + + default: + break; + } + + // Add descriptor + pqos.transport().user_transports.push_back(descriptor); + + // Set participant as SERVER + pqos.wire_protocol().builtin.discovery_config.discoveryProtocol = + eprosima::fastdds::rtps::DiscoveryProtocol::SERVER; + + // Set SERVER's listening locator for PDP + pqos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(listening_locator); + pqos.wire_protocol().default_unicast_locator_list.push_back(listening_locator); + + logDebug(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, + "Add listening address " << address << " to Participant " << participant_configuration->id << "."); + } + + ///// + // Set connection addresses + for (types::DiscoveryServerConnectionAddress connection_address : participant_configuration->connection_addresses) + { + if (!connection_address.is_valid()) + { + // Invalid connection address, continue with next one + EPROSIMA_LOG_WARNING(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, + "Discard connection address with remote server in Participant " << + participant_configuration->id << " initialization."); + continue; + } + + for (types::Address address : connection_address.addresses()) + { + if (!address.is_valid()) + { + // Invalid ip address, continue with next one + EPROSIMA_LOG_WARNING(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, + "Discard connection address with remote server due to invalid ip address " << + address.ip() << " in Participant " << participant_configuration->id << + " initialization."); + continue; + } + + // Create DS locator + eprosima::fastdds::rtps::Locator server_locator; + server_locator.kind = address.get_locator_kind(); + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(server_locator, address.port()); + + std::shared_ptr descriptor; + + switch (address.get_locator_kind()) + { + case LOCATOR_KIND_UDPv4: + { + if (!has_listening_udp_ipv4) + { + has_connection_descriptor = true; + auto descriptor_tmp = + create_descriptor( + participant_configuration->whitelist); + descriptor = descriptor_tmp; + } + + eprosima::fastdds::rtps::IPLocator::setIPv4(server_locator, address.ip()); + + break; + } + + case LOCATOR_KIND_UDPv6: + { + if (!has_listening_udp_ipv6) + { + has_connection_descriptor = true; + auto descriptor_tmp = + create_descriptor( + participant_configuration->whitelist); + descriptor = descriptor_tmp; + } + + eprosima::fastdds::rtps::IPLocator::setIPv6(server_locator, address.ip()); + + break; + } + + case LOCATOR_KIND_TCPv4: + { + if (!has_listening_tcp_ipv4) + { + has_connection_descriptor = true; + auto descriptor_tmp = + create_descriptor( + participant_configuration->whitelist); + + // Enable TLS + if (tls_config.is_active()) + { + tls_config.enable_tls(descriptor_tmp, true); + } + + descriptor = descriptor_tmp; + } + + eprosima::fastdds::rtps::IPLocator::setLogicalPort(server_locator, address.port()); + eprosima::fastdds::rtps::IPLocator::setIPv4(server_locator, address.ip()); + + break; + } + + case LOCATOR_KIND_TCPv6: + { + if (!has_listening_tcp_ipv6) + { + has_connection_descriptor = true; + auto descriptor_tmp = + create_descriptor( + participant_configuration->whitelist); + + // Enable TLS + if (tls_config.is_active()) + { + tls_config.enable_tls(descriptor_tmp, true); + } + + descriptor = descriptor_tmp; + } + + eprosima::fastdds::rtps::IPLocator::setLogicalPort(server_locator, address.port()); + eprosima::fastdds::rtps::IPLocator::setIPv6(server_locator, address.ip()); + + break; + } + + default: + break; + } + + if (has_connection_descriptor) + { + // Set participant as DS CLIENT + pqos.wire_protocol().builtin.discovery_config.discoveryProtocol = + eprosima::fastdds::rtps::DiscoveryProtocol::SUPER_CLIENT; + + // Add descriptor + pqos.transport().user_transports.push_back(descriptor); + + logDebug(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, + "Add connection address " << address << " to Participant " << participant_configuration->id << "."); + } + + // Add remote SERVER to CLIENT's list of SERVERs + pqos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(server_locator); + } + } + + ///// + // Set Server Guid + // params.prefix = discovery_server_guid_prefix; TODO Irene: Check if this is needed + + logDebug(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, + "Configured Participant " << participant_configuration->id << " with server guid: " << + discovery_server_guid_prefix); + + return pqos; +} + +} /* namespace dds */ +} /* namespace participants */ +} /* namespace ddspipe */ +} /* namespace eprosima */ diff --git a/ddspipe_participants/src/cpp/participant/dds/InitialPeersParticipant.cpp b/ddspipe_participants/src/cpp/participant/dds/InitialPeersParticipant.cpp new file mode 100644 index 00000000..e936a08a --- /dev/null +++ b/ddspipe_participants/src/cpp/participant/dds/InitialPeersParticipant.cpp @@ -0,0 +1,347 @@ +// Copyright 2024 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, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include + +#include + +#include + +namespace eprosima { +namespace ddspipe { +namespace participants { +namespace dds { + +InitialPeersParticipant::InitialPeersParticipant( + const std::shared_ptr& participant_configuration, + const std::shared_ptr& payload_pool, + const std::shared_ptr& discovery_database) + : CommonParticipant( + participant_configuration, + payload_pool, + discovery_database, + participant_configuration->domain, + reckon_participant_qos_(participant_configuration.get())) +{ +} + +fastdds::dds::DomainParticipantQos +InitialPeersParticipant::reckon_participant_qos_( + const InitialPeersParticipantConfiguration* participant_configuration) +{ + // Use default as base qos + fastdds::dds::DomainParticipantQos pqos = CommonParticipant::reckon_participant_qos_(participant_configuration); + + // Auxiliary variable to save characters and improve readability + const auto& tls_config = participant_configuration->tls_configuration; + + // Needed values to check at the end if descriptor must be set + bool has_listening_tcp_ipv4 = false; + bool has_listening_tcp_ipv6 = false; + bool has_listening_udp_ipv4 = false; + bool has_listening_udp_ipv6 = false; + bool has_connection_descriptor = false; + + pqos.transport().use_builtin_transports = false; + + ///// + // Set listening addresses + for (const types::Address& address : participant_configuration->listening_addresses) + { + if (!address.is_valid()) + { + // Invalid address, continue with next one + EPROSIMA_LOG_WARNING(DDSPIPE_INITIALPEERS_PARTICIPANT, + "Discard listening address: " << address << + " in Participant " << participant_configuration->id << " initialization."); + continue; + } + + eprosima::fastdds::rtps::Locator locator; + locator.kind = address.get_locator_kind(); + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(locator, address.port()); + + + std::shared_ptr descriptor; + + switch (address.get_locator_kind()) + { + case LOCATOR_KIND_UDPv4: + { + has_listening_udp_ipv4 = true; + + auto descriptor_tmp = + create_descriptor(participant_configuration->whitelist); + descriptor = descriptor_tmp; + + eprosima::fastdds::rtps::IPLocator::setIPv4(locator, address.ip()); + + break; + } + + case LOCATOR_KIND_UDPv6: + { + has_listening_udp_ipv6 = true; + + auto descriptor_tmp = + create_descriptor(participant_configuration->whitelist); + descriptor = descriptor_tmp; + + eprosima::fastdds::rtps::IPLocator::setIPv6(locator, address.ip()); + + break; + } + + case LOCATOR_KIND_TCPv4: + { + has_listening_tcp_ipv4 = true; + + std::shared_ptr descriptor_tmp; + + // We check if several descriptors share a WAN address. + // If so, we add a new port to the previously created descriptor. + bool same_wan_addr = false; + + auto it = pqos.transport().user_transports.begin(); + while (it != pqos.transport().user_transports.end()) + { + std::shared_ptr tmp_descriptor = + std::dynamic_pointer_cast(*it); + + if ((tmp_descriptor != nullptr) && (address.ip() == tmp_descriptor->get_WAN_address())) + { + // Save in the new descriptor the previously added descriptor with the same WAN address + descriptor_tmp = tmp_descriptor; + // Set that a descriptor with same WAN address was found + same_wan_addr = true; + // Remove the previously added descriptor as this will be replaced by the same one updated with + // more locators. + pqos.transport().user_transports.erase(it); + break; + } + } + + // Add the new locator to the descriptor if another with the same wan address was found + if (same_wan_addr) + { + descriptor_tmp->add_listener_port(address.port()); + } + else + { + descriptor_tmp = create_descriptor( + participant_configuration->whitelist); + descriptor_tmp->add_listener_port(address.port()); + descriptor_tmp->set_WAN_address(address.ip()); + + // Enable TLS + if (tls_config.is_active()) + { + tls_config.enable_tls(descriptor_tmp); + } + + } + + descriptor = descriptor_tmp; + + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(locator, address.external_port()); + eprosima::fastdds::rtps::IPLocator::setLogicalPort(locator, 0); + eprosima::fastdds::rtps::IPLocator::setIPv4(locator, address.ip()); + + break; + } + + case LOCATOR_KIND_TCPv6: + { + has_listening_tcp_ipv6 = true; + + std::shared_ptr descriptor_tmp = + create_descriptor(participant_configuration->whitelist); + + descriptor_tmp->add_listener_port(address.port()); + + // Enable TLS + if (tls_config.is_active()) + { + tls_config.enable_tls(descriptor_tmp); + } + + descriptor = descriptor_tmp; + + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(locator, address.external_port()); + eprosima::fastdds::rtps::IPLocator::setLogicalPort(locator, 0); + eprosima::fastdds::rtps::IPLocator::setIPv6(locator, address.ip()); + + break; + + } + + default: + break; + } + + // Add descriptor + pqos.transport().user_transports.push_back(descriptor); + + // Add listening address to builtin + pqos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(locator); + pqos.wire_protocol().default_unicast_locator_list.push_back(locator); + + logDebug(DDSPIPE_INITIALPEERS_PARTICIPANT, + "Add listening address " << address << " to Participant " << participant_configuration->id << "."); + } + + ///// + // Set connection addresses + for (const types::Address& connection_address : participant_configuration->connection_addresses) + { + if (!connection_address.is_valid()) + { + // Invalid connection address, continue with next one + EPROSIMA_LOG_WARNING(DDSPIPE_INITIALPEERS_PARTICIPANT, + "Discard connection address: " << connection_address << + " in Participant " << participant_configuration->id << " initialization."); + continue; + } + + // Create Locator for connection initial peers + eprosima::fastdds::rtps::Locator locator; + locator.kind = connection_address.get_locator_kind(); + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(locator, connection_address.port()); + + std::shared_ptr descriptor; + + switch (connection_address.get_locator_kind()) + { + case LOCATOR_KIND_UDPv4: + { + if (!has_listening_udp_ipv4) + { + has_connection_descriptor = true; + auto descriptor_tmp = + create_descriptor( + participant_configuration->whitelist); + descriptor = descriptor_tmp; + + // To avoid creating a multicast transport in UDP when non listening addresses + // Fast requires an empty locator that will be set by default afterwards + eprosima::fastdds::rtps::Locator_t empty_locator; + empty_locator.kind = LOCATOR_KIND_UDPv4; + pqos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(empty_locator); + } + + eprosima::fastdds::rtps::IPLocator::setIPv4(locator, connection_address.ip()); + + break; + } + + case LOCATOR_KIND_UDPv6: + { + if (!has_listening_udp_ipv6) + { + has_connection_descriptor = true; + auto descriptor_tmp = + create_descriptor( + participant_configuration->whitelist); + descriptor = descriptor_tmp; + + // To avoid creating a multicast transport in UDP when non listening addresses + // Fast requires an empty locator that will be set by default afterwards + eprosima::fastdds::rtps::Locator_t empty_locator; + empty_locator.kind = LOCATOR_KIND_UDPv6; + pqos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(empty_locator); + } + + eprosima::fastdds::rtps::IPLocator::setIPv6(locator, connection_address.ip()); + + break; + } + + case LOCATOR_KIND_TCPv4: + { + if (!has_listening_tcp_ipv4) + { + has_connection_descriptor = true; + auto descriptor_tmp = + create_descriptor( + participant_configuration->whitelist); + + // Enable TLS + if (tls_config.is_active()) + { + tls_config.enable_tls(descriptor_tmp, true); + } + + descriptor = descriptor_tmp; + } + + eprosima::fastdds::rtps::IPLocator::setLogicalPort(locator, 0); + eprosima::fastdds::rtps::IPLocator::setIPv4(locator, connection_address.ip()); + + break; + } + + case LOCATOR_KIND_TCPv6: + { + if (!has_listening_tcp_ipv6) + { + has_connection_descriptor = true; + auto descriptor_tmp = + create_descriptor( + participant_configuration->whitelist); + + // Enable TLS + if (tls_config.is_active()) + { + tls_config.enable_tls(descriptor_tmp, true); + } + + descriptor = descriptor_tmp; + } + + eprosima::fastdds::rtps::IPLocator::setLogicalPort(locator, 0); + eprosima::fastdds::rtps::IPLocator::setIPv6(locator, connection_address.ip()); + + break; + } + + default: + break; + } + + if (has_connection_descriptor) + { + // Add descriptor + pqos.transport().user_transports.push_back(descriptor); + + logDebug(DDSPIPE_INITIALPEERS_PARTICIPANT, + "Add connection address " << connection_address << " to Participant " << participant_configuration->id << "."); + } + + // Add it to builtin + pqos.wire_protocol().builtin.initialPeersList.push_back(locator); + } + + logDebug(DDSPIPE_INITIALPEERS_PARTICIPANT, + "Configured Participant " << participant_configuration->id); + + return pqos; +} + +} /* namespace dds */ +} /* namespace participants */ +} /* namespace ddspipe */ +} /* namespace eprosima */ diff --git a/ddspipe_participants/src/cpp/participant/dds/SimpleParticipant.cpp b/ddspipe_participants/src/cpp/participant/dds/SimpleParticipant.cpp new file mode 100644 index 00000000..0fbc4b70 --- /dev/null +++ b/ddspipe_participants/src/cpp/participant/dds/SimpleParticipant.cpp @@ -0,0 +1,118 @@ +// Copyright 2024 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, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include +#include +#include +#include +#include + +#include + +namespace eprosima { +namespace ddspipe { +namespace participants { +namespace dds { + +SimpleParticipant::SimpleParticipant( + const std::shared_ptr& participant_configuration, + const std::shared_ptr& payload_pool, + const std::shared_ptr& discovery_database) + : CommonParticipant( + participant_configuration, + payload_pool, + discovery_database, + participant_configuration->domain, + reckon_participant_qos_(participant_configuration.get())) +{ +} + +fastdds::dds::DomainParticipantQos +SimpleParticipant::reckon_participant_qos_( + const SimpleParticipantConfiguration* participant_configuration) +{ + // Use default as base qos + fastdds::dds::DomainParticipantQos pqos = CommonParticipant::reckon_participant_qos_(participant_configuration); + + // Configure Participant transports + if (participant_configuration->transport == core::types::TransportDescriptors::builtin) + { + if (!participant_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(participant_configuration->whitelist); + pqos.transport().user_transports.push_back(udp_transport); + } + } + else if (participant_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 (participant_configuration->transport == core::types::TransportDescriptors::udp_only) + { + pqos.transport().use_builtin_transports = false; + + std::shared_ptr udp_transport = + create_descriptor(participant_configuration->whitelist); + pqos.transport().user_transports.push_back(udp_transport); + } + + // Participant discovery filter configuration + switch (participant_configuration->ignore_participant_flags) + { + case core::types::IgnoreParticipantFlags::no_filter: + pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = + eprosima::fastdds::rtps::ParticipantFilteringFlags::NO_FILTER; + break; + case core::types::IgnoreParticipantFlags::filter_different_host: + pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_DIFFERENT_HOST; + break; + case core::types::IgnoreParticipantFlags::filter_different_process: + pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_DIFFERENT_PROCESS; + break; + case core::types::IgnoreParticipantFlags::filter_same_process: + pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_SAME_PROCESS; + break; + case core::types::IgnoreParticipantFlags::filter_different_and_same_process: + pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = + static_cast( + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_DIFFERENT_PROCESS | + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_SAME_PROCESS); + break; + default: + break; + } + + return pqos; +} + +} /* namespace dds */ +} /* namespace participants */ +} /* namespace ddspipe */ +} /* namespace eprosima */ diff --git a/ddspipe_participants/src/cpp/participant/dds/XmlParticipant.cpp b/ddspipe_participants/src/cpp/participant/dds/XmlParticipant.cpp index 38353996..935d40a8 100644 --- a/ddspipe_participants/src/cpp/participant/dds/XmlParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/dds/XmlParticipant.cpp @@ -36,17 +36,21 @@ XmlParticipant::XmlParticipant( const std::shared_ptr& participant_configuration, const std::shared_ptr& payload_pool, const std::shared_ptr& discovery_database) - : CommonParticipant(participant_configuration, payload_pool, discovery_database) - , xml_specific_configuration_(*reinterpret_cast(configuration_.get())) + : CommonParticipant( + participant_configuration, + payload_pool, + discovery_database, + core::types::DomainId(), + reckon_participant_qos_(participant_configuration.get())) { fastdds::dds::DomainParticipantExtendedQos extended_qos; - if (xml_specific_configuration_.participant_profile.is_set() && + if (participant_configuration->participant_profile.is_set() && fastdds::dds::RETCODE_OK == fastdds::dds::DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_profile( - xml_specific_configuration_.participant_profile.get_value(), + participant_configuration->participant_profile.get_value(), extended_qos)) { - configuration_->domain = extended_qos.domainId(); + domain_id_ = extended_qos.domainId(); } } @@ -84,22 +88,24 @@ std::shared_ptr XmlParticipant::create_reader( } } -fastdds::dds::DomainParticipantQos XmlParticipant::reckon_participant_qos_() const +fastdds::dds::DomainParticipantQos +XmlParticipant::reckon_participant_qos_( + const XmlParticipantConfiguration* participant_configuration) { - fastdds::dds::DomainParticipantQos qos = CommonParticipant::reckon_participant_qos_(); + fastdds::dds::DomainParticipantQos qos = CommonParticipant::reckon_participant_qos_(participant_configuration); // Use the participant's profile if it has been set - if (xml_specific_configuration_.participant_profile.is_set()) + if (participant_configuration->participant_profile.is_set()) { auto res = fastdds::dds::DomainParticipantFactory::get_instance()->get_participant_qos_from_profile( - xml_specific_configuration_.participant_profile.get_value(), + participant_configuration->participant_profile.get_value(), qos ); if (res != fastdds::dds::RETCODE_OK) { throw utils::ConfigurationException(STR_ENTRY - << "Participant profile <" << xml_specific_configuration_.participant_profile.get_value() + << "Participant profile <" << participant_configuration->participant_profile.get_value() << "> does not exist."); } } diff --git a/ddspipe_participants/test/blackbox/participants_creation/ParticipantsCreationgTest.cpp b/ddspipe_participants/test/blackbox/participants_creation/ParticipantsCreationgTest.cpp index 6cbe0818..7341d4b8 100644 --- a/ddspipe_participants/test/blackbox/participants_creation/ParticipantsCreationgTest.cpp +++ b/ddspipe_participants/test/blackbox/participants_creation/ParticipantsCreationgTest.cpp @@ -27,6 +27,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -61,9 +65,13 @@ TEST(ParticipantsCreationgTest, default_configuration) * CASES: * - Blank * - Echo - * - Simple - * - Discovery Server - * - Initial Peers + * - Simple RTPS + * - Simple DDS + * - Discovery Server RTPS + * - Discovery Server DDS + * - Initial Peers RTPS + * - Initial Peers DDS + * - Xml DDS */ TEST(ParticipantsCreationgTest, creation_trivial) { @@ -86,7 +94,7 @@ TEST(ParticipantsCreationgTest, creation_trivial) participants::EchoParticipant participant(conf, discovery_database); } - // Simple + // Simple RTPS { std::shared_ptr conf( new participants::SimpleParticipantConfiguration()); @@ -96,7 +104,17 @@ TEST(ParticipantsCreationgTest, creation_trivial) participant.init(); } - // Discovery Server + // Simple DDS + { + std::shared_ptr conf( + new participants::SimpleParticipantConfiguration()); + conf->id = part_id; + + participants::dds::SimpleParticipant participant(conf, payload_pool, discovery_database); + participant.init(); + } + + // Discovery Server RTPS { std::shared_ptr conf( new participants::InitialPeersParticipantConfiguration()); @@ -107,7 +125,18 @@ TEST(ParticipantsCreationgTest, creation_trivial) participant.init(); } - // Initial Peers + // Discovery Server DDS + { + std::shared_ptr conf( + new participants::InitialPeersParticipantConfiguration()); + conf->id = part_id; + conf->listening_addresses.insert(participants::testing::random_address()); + + participants::dds::InitialPeersParticipant participant(conf, payload_pool, discovery_database); + participant.init(); + } + + // Initial Peers RTPS { std::shared_ptr conf( new participants::DiscoveryServerParticipantConfiguration()); @@ -118,7 +147,18 @@ TEST(ParticipantsCreationgTest, creation_trivial) participant.init(); } - // Xml Participant + // Initial Peers DDS + { + std::shared_ptr conf( + new participants::DiscoveryServerParticipantConfiguration()); + conf->id = part_id; + conf->listening_addresses.insert(participants::testing::random_address()); + + participants::dds::DiscoveryServerParticipant participant(conf, payload_pool, discovery_database); + participant.init(); + } + + // Xml Participant DDS { std::shared_ptr conf( new participants::XmlParticipantConfiguration()); @@ -158,11 +198,11 @@ TEST(ParticipantsCreationgTest, ddspipe_all_creation_builtin_topic) conf, discovery_database)); } - // Simple + // Simple RTPS { std::shared_ptr conf( new participants::SimpleParticipantConfiguration()); - conf->id = core::types::ParticipantId("Simple"); + conf->id = core::types::ParticipantId("SimpleRTPS"); auto part = std::make_shared( conf, payload_pool, discovery_database); @@ -170,11 +210,23 @@ TEST(ParticipantsCreationgTest, ddspipe_all_creation_builtin_topic) part_db->add_participant(conf->id, part); } - // Discovery Server + // Simple DDS + { + std::shared_ptr conf( + new participants::SimpleParticipantConfiguration()); + conf->id = core::types::ParticipantId("SimpleDDS"); + + auto part = std::make_shared( + conf, payload_pool, discovery_database); + part->init(); + part_db->add_participant(conf->id, part); + } + + // Discovery Server RTPS { std::shared_ptr conf( new participants::DiscoveryServerParticipantConfiguration()); - conf->id = core::types::ParticipantId("DiscoveryServer"); + conf->id = core::types::ParticipantId("DiscoveryServerRTPS"); conf->listening_addresses.insert(participants::testing::random_address(1)); auto part = std::make_shared( @@ -183,12 +235,25 @@ TEST(ParticipantsCreationgTest, ddspipe_all_creation_builtin_topic) part_db->add_participant(conf->id, part); } - // Initial Peers + // Discovery Server DDS + { + std::shared_ptr conf( + new participants::DiscoveryServerParticipantConfiguration()); + conf->id = core::types::ParticipantId("DiscoveryServerDDS"); + conf->listening_addresses.insert(participants::testing::random_address(2)); + + auto part = std::make_shared( + conf, payload_pool, discovery_database); + part->init(); + part_db->add_participant(conf->id, part); + } + + // Initial Peers RTPS { std::shared_ptr conf( new participants::InitialPeersParticipantConfiguration()); - conf->id = core::types::ParticipantId("InitialPeers"); - conf->listening_addresses.insert(participants::testing::random_address(2)); + conf->id = core::types::ParticipantId("InitialPeersRTPS"); + conf->listening_addresses.insert(participants::testing::random_address(3)); auto part = std::make_shared( conf, payload_pool, discovery_database); @@ -196,11 +261,24 @@ TEST(ParticipantsCreationgTest, ddspipe_all_creation_builtin_topic) part_db->add_participant(conf->id, part); } - // Xml + // Initial Peers DDS + { + std::shared_ptr conf( + new participants::InitialPeersParticipantConfiguration()); + conf->id = core::types::ParticipantId("InitialPeersDDS"); + conf->listening_addresses.insert(participants::testing::random_address(4)); + + auto part = std::make_shared( + conf, payload_pool, discovery_database); + part->init(); + part_db->add_participant(conf->id, part); + } + + // Xml DDS { std::shared_ptr conf( new participants::XmlParticipantConfiguration()); - conf->id = core::types::ParticipantId("Xml"); + conf->id = core::types::ParticipantId("XmlDDS"); auto part = std::make_shared( conf, payload_pool, discovery_database);