diff --git a/include/fastdds/dds/core/policy/ParameterTypes.hpp b/include/fastdds/dds/core/policy/ParameterTypes.hpp index e583831acdf..15e412f0ab7 100644 --- a/include/fastdds/dds/core/policy/ParameterTypes.hpp +++ b/include/fastdds/dds/core/policy/ParameterTypes.hpp @@ -168,6 +168,7 @@ enum ParameterId_t : uint16_t /* eProsima Fast DDS extensions */ PID_PRODUCT_VERSION = 0x8000, PID_PERSISTENCE_GUID = 0x8002, + PID_MACHINE_ID = 0x8003, PID_DISABLE_POSITIVE_ACKS = 0x8005, PID_DATASHARING = 0x8006, PID_NETWORK_CONFIGURATION_SET = 0x8007, diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 1d3d9f8232f..5ac4799fa84 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -229,6 +229,7 @@ set(${PROJECT_NAME}_source_files statistics/fastdds/domain/DomainParticipant.cpp statistics/fastdds/publisher/qos/DataWriterQos.cpp statistics/fastdds/subscriber/qos/DataReaderQos.cpp + utils/Host.cpp utils/IPFinder.cpp utils/IPLocator.cpp utils/md5.cpp @@ -507,6 +508,14 @@ target_link_libraries(${PROJECT_NAME} eProsima_atomic ) +if (APPLE) + target_link_libraries(${PROJECT_NAME} + ${PRIVACY} + "-framework CoreFoundation" + "-framework IOKit" + ) +endif() + if(MSVC OR MSVC_IDE) # On installed binaries use manifest to specify dependencies if(INSTALLER_PLATFORM AND OPENSSL_FOUND) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index d0686d47462..7dd1797e07e 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -165,7 +165,7 @@ bool TypeLookupManager::assign_remote_endpoints( temp_writer_proxy_data_->guid().guidPrefix = pdata.m_guid.guidPrefix; temp_writer_proxy_data_->persistence_guid().guidPrefix = pdata.m_guid.guidPrefix; - temp_writer_proxy_data_->set_remote_locators(pdata.metatraffic_locators, network, true); + temp_writer_proxy_data_->set_remote_locators(pdata.metatraffic_locators, network, true, pdata.is_from_this_host()); temp_writer_proxy_data_->topicKind(NO_KEY); temp_writer_proxy_data_->m_qos.m_durability.kind = fastdds::dds::VOLATILE_DURABILITY_QOS; temp_writer_proxy_data_->m_qos.m_reliability.kind = fastdds::dds::RELIABLE_RELIABILITY_QOS; @@ -173,7 +173,7 @@ bool TypeLookupManager::assign_remote_endpoints( temp_reader_proxy_data_->clear(); temp_reader_proxy_data_->m_expectsInlineQos = false; temp_reader_proxy_data_->guid().guidPrefix = pdata.m_guid.guidPrefix; - temp_reader_proxy_data_->set_remote_locators(pdata.metatraffic_locators, network, true); + temp_reader_proxy_data_->set_remote_locators(pdata.metatraffic_locators, network, true, pdata.is_from_this_host()); temp_reader_proxy_data_->topicKind(NO_KEY); temp_reader_proxy_data_->m_qos.m_durability.kind = fastdds::dds::VOLATILE_DURABILITY_QOS; temp_reader_proxy_data_->m_qos.m_reliability.kind = fastdds::dds::RELIABLE_RELIABILITY_QOS; diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp index 9e494efdecf..6a3af025e21 100644 --- a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include "ProxyDataFilters.hpp" #include "ProxyHashTables.hpp" @@ -80,6 +81,7 @@ ParticipantProxyData::ParticipantProxyData( const ParticipantProxyData& pdata) : m_protocolVersion(pdata.m_protocolVersion) , m_guid(pdata.m_guid) + , machine_id(pdata.machine_id) , m_VendorId(pdata.m_VendorId) , product_version(pdata.product_version) , m_domain_id(pdata.m_domain_id) @@ -174,6 +176,13 @@ uint32_t ParticipantProxyData::get_serialized_size( // PID_NETWORK_CONFIGURATION_SET ret_val += 4 + PARAMETER_NETWORKCONFIGSET_LENGTH; + if (machine_id.size() > 0) + { + // PID_MACHINE_ID + ret_val += + fastdds::dds::ParameterSerializer::cdr_serialized_size(machine_id); + } + // PID_METATRAFFIC_MULTICAST_LOCATOR ret_val += static_cast((4 + PARAMETER_LOCATOR_LENGTH) * @@ -322,6 +331,14 @@ bool ParticipantProxyData::writeToCDRMessage( return false; } } + if (machine_id.size() > 0) + { + ParameterString_t p(fastdds::dds::PID_MACHINE_ID, 0, machine_id); + if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(p, msg)) + { + return false; + } + } for (const Locator_t& it : metatraffic_locators.multicast) { ParameterLocator_t p(fastdds::dds::PID_METATRAFFIC_MULTICAST_LOCATOR, PARAMETER_LOCATOR_LENGTH, @@ -589,6 +606,28 @@ bool ParticipantProxyData::readFromCDRMessage( m_networkConfiguration = p.netconfigSet; break; } + case fastdds::dds::PID_MACHINE_ID: + { + // Ignore custom PID when coming from other vendors + if (c_VendorId_eProsima != m_VendorId) + { + EPROSIMA_LOG_INFO( + RTPS_PROXY_DATA, + "Ignoring custom PID" << pid << " from vendor " << source_vendor_id); + return true; + } + + ParameterString_t p(pid, plength); + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) + { + return false; + } + + machine_id = p.getName(); + break; + } case fastdds::dds::PID_METATRAFFIC_MULTICAST_LOCATOR: { ParameterLocator_t p(pid, plength); @@ -608,7 +647,7 @@ bool ParticipantProxyData::readFromCDRMessage( Locator_t temp_locator; if (network.transform_remote_locator( p.locator, temp_locator, m_networkConfiguration, - m_guid.is_from_this_host())) + is_from_this_host())) { ProxyDataFilters::filter_locators( network, @@ -638,7 +677,7 @@ bool ParticipantProxyData::readFromCDRMessage( Locator_t temp_locator; if (network.transform_remote_locator( p.locator, temp_locator, m_networkConfiguration, - m_guid.is_from_this_host())) + is_from_this_host())) { ProxyDataFilters::filter_locators( network, @@ -668,7 +707,7 @@ bool ParticipantProxyData::readFromCDRMessage( Locator_t temp_locator; if (network.transform_remote_locator( p.locator, temp_locator, m_networkConfiguration, - m_guid.is_from_this_host())) + is_from_this_host())) { ProxyDataFilters::filter_locators( network, @@ -698,7 +737,7 @@ bool ParticipantProxyData::readFromCDRMessage( Locator_t temp_locator; if (network.transform_remote_locator( p.locator, temp_locator, m_networkConfiguration, - m_guid.is_from_this_host())) + is_from_this_host())) { ProxyDataFilters::filter_locators( network, @@ -854,10 +893,25 @@ bool ParticipantProxyData::readFromCDRMessage( } } +bool ParticipantProxyData::is_from_this_host() const +{ + bool same_host = false; + if (machine_id.size() > 0) + { + same_host = machine_id == SystemInfo::instance().machine_id(); + } + else + { + same_host = m_guid.is_from_this_host(); + } + return same_host; +} + void ParticipantProxyData::clear() { m_protocolVersion = ProtocolVersion_t(); m_guid = GUID_t(); + machine_id = ""; //set_VendorId_Unknown(m_VendorId); m_VendorId = c_VendorId_Unknown; product_version = {}; @@ -891,6 +945,7 @@ void ParticipantProxyData::copy( { m_protocolVersion = pdata.m_protocolVersion; m_guid = pdata.m_guid; + machine_id = pdata.machine_id; m_VendorId[0] = pdata.m_VendorId[0]; m_VendorId[1] = pdata.m_VendorId[1]; product_version = pdata.product_version; diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp index 09e65d13219..e0d91027f09 100644 --- a/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp +++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp @@ -77,6 +77,8 @@ class ParticipantProxyData ProtocolVersion_t m_protocolVersion; //!GUID GUID_t m_guid; + //!Machine ID + fastcdr::string_255 machine_id; //!Vendor ID fastdds::rtps::VendorId_t m_VendorId; //! Product version @@ -163,6 +165,13 @@ class ParticipantProxyData bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id = c_VendorId_eProsima); + /** + * Check if the host where the current process is running is the same as the one that sent the data. + * It tries to use the machine_id. If it is not available, it will compare GUIDs. + * @return True if the host is the same + */ + bool is_from_this_host() const; + //! Clear the data (restore to default state). void clear(); diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index 0a75a6a84b9..7aba95c8146 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -24,7 +24,9 @@ #include #include +#include #include +#include #include "ProxyDataFilters.hpp" @@ -647,11 +649,9 @@ bool ReaderProxyData::writeToCDRMessage( bool ReaderProxyData::readFromCDRMessage( CDRMessage_t* msg, - NetworkFactory& network, - bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id) { - auto param_process = [this, &network, &should_filter_locators, source_vendor_id]( + auto param_process = [this, source_vendor_id]( CDRMessage_t* msg, const ParameterId_t& pid, uint16_t plength) { VendorId_t vendor_id = source_vendor_id; @@ -889,23 +889,7 @@ bool ReaderProxyData::readFromCDRMessage( return false; } - if (!should_filter_locators) - { - remote_locators_.add_unicast_locator(p.locator); - } - else - { - Locator_t temp_locator; - if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration, - m_guid.is_from_this_host())) - { - ProxyDataFilters::filter_locators( - network, - remote_locators_, - temp_locator, - true); - } - } + remote_locators_.add_unicast_locator(p.locator); break; } case fastdds::dds::PID_MULTICAST_LOCATOR: @@ -917,23 +901,7 @@ bool ReaderProxyData::readFromCDRMessage( return false; } - if (!should_filter_locators) - { - remote_locators_.add_multicast_locator(p.locator); - } - else - { - Locator_t temp_locator; - if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration, - m_guid.is_from_this_host())) - { - ProxyDataFilters::filter_locators( - network, - remote_locators_, - temp_locator, - false); - } - } + remote_locators_.add_unicast_locator(p.locator); break; } case fastdds::dds::PID_EXPECTS_INLINE_QOS: @@ -1149,6 +1117,47 @@ bool ReaderProxyData::readFromCDRMessage( return false; } +void ReaderProxyData::setup_locators( + const ReaderProxyData& rdata, + NetworkFactory& network, + const ParticipantProxyData& participant_data) +{ + if (this == &rdata) + { + return; + } + + bool from_this_host = participant_data.is_from_this_host(); + + if (rdata.has_locators()) + { + // Get the transformed remote locators for the ReaderProxyData received + remote_locators_.unicast.clear(); + remote_locators_.multicast.clear(); + for (const Locator_t& locator : rdata.remote_locators_.unicast) + { + Locator_t temp_locator; + if (network.transform_remote_locator(locator, temp_locator, m_networkConfiguration, from_this_host)) + { + ProxyDataFilters::filter_locators(network, remote_locators_, temp_locator, true); + } + } + for (const Locator_t& locator : rdata.remote_locators_.multicast) + { + Locator_t temp_locator; + if (network.transform_remote_locator(locator, temp_locator, m_networkConfiguration, from_this_host)) + { + ProxyDataFilters::filter_locators(network, remote_locators_, temp_locator, false); + } + } + } + else + { + // Get the remote locators from the participant_data + set_remote_locators(participant_data.default_locators, network, true, from_this_host); + } +} + void ReaderProxyData::clear() { m_expectsInlineQos = false; @@ -1284,12 +1293,13 @@ void ReaderProxyData::set_announced_unicast_locators( void ReaderProxyData::set_remote_unicast_locators( const LocatorList_t& locators, - const NetworkFactory& network) + const NetworkFactory& network, + bool from_this_host) { remote_locators_.unicast.clear(); for (const Locator_t& locator : locators) { - if (network.is_locator_remote_or_allowed(locator, m_guid.is_from_this_host())) + if (network.is_locator_remote_or_allowed(locator, from_this_host)) { remote_locators_.add_unicast_locator(locator); } @@ -1304,12 +1314,13 @@ void ReaderProxyData::add_multicast_locator( void ReaderProxyData::set_multicast_locators( const LocatorList_t& locators, - const NetworkFactory& network) + const NetworkFactory& network, + bool from_this_host) { remote_locators_.multicast.clear(); for (const Locator_t& locator : locators) { - if (network.is_locator_remote_or_allowed(locator, m_guid.is_from_this_host())) + if (network.is_locator_remote_or_allowed(locator, from_this_host)) { remote_locators_.add_multicast_locator(locator); } @@ -1325,14 +1336,15 @@ void ReaderProxyData::set_locators( void ReaderProxyData::set_remote_locators( const RemoteLocatorList& locators, const NetworkFactory& network, - bool use_multicast_locators) + bool use_multicast_locators, + bool from_this_host) { remote_locators_.unicast.clear(); remote_locators_.multicast.clear(); for (const Locator_t& locator : locators.unicast) { - if (network.is_locator_remote_or_allowed(locator, m_guid.is_from_this_host())) + if (network.is_locator_remote_or_allowed(locator, from_this_host)) { remote_locators_.add_unicast_locator(locator); } @@ -1342,7 +1354,7 @@ void ReaderProxyData::set_remote_locators( { for (const Locator_t& locator : locators.multicast) { - if (network.is_locator_remote_or_allowed(locator, m_guid.is_from_this_host())) + if (network.is_locator_remote_or_allowed(locator, from_this_host)) { remote_locators_.add_multicast_locator(locator); } diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.hpp b/src/cpp/rtps/builtin/data/ReaderProxyData.hpp index 9511c31d140..80b44b0c893 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.hpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.hpp @@ -35,6 +35,7 @@ namespace rtps { struct CDRMessage_t; class NetworkFactory; +class ParticipantProxyData; /** * Class ReaderProxyData, used to represent all the information on a Reader (both local and remote) with the purpose of @@ -124,24 +125,46 @@ class ReaderProxyData void set_announced_unicast_locators( const LocatorList_t& locators); + /** + * Set the remote unicast locators from @param locators. + * @param locators List of locators to be used + * @param network NetworkFactory to check if the locators are allowed + * @param from_this_host Whether the server is from this host or not + */ void set_remote_unicast_locators( const LocatorList_t& locators, - const NetworkFactory& network); + const NetworkFactory& network, + bool from_this_host); void add_multicast_locator( const Locator_t& locator); + /** + * Set the remote multicast locators from @param locators. + * @param locators List of locators to be used + * @param network NetworkFactory to check if the locators are allowed + * @param from_this_host Whether the server is from this host or not + */ void set_multicast_locators( const LocatorList_t& locators, - const NetworkFactory& network); + const NetworkFactory& network, + bool from_this_host); void set_locators( const RemoteLocatorList& locators); + /** + * Set the remote multicast and unicast locators from @param locators. + * @param locators List of locators to be used + * @param network NetworkFactory to check if the locators are allowed + * @param use_multicast_locators Whether to set multicast locators or not + * @param from_this_host Whether the server is from this host or not + */ void set_remote_locators( const RemoteLocatorList& locators, const NetworkFactory& network, - bool use_multicast_locators); + bool use_multicast_locators, + bool from_this_host); void key( const InstanceHandle_t& key) @@ -423,17 +446,26 @@ class ReaderProxyData * Read the information from a CDRMessage_t. The position of the message must be in the beginning on the * parameter list. * @param msg Pointer to the message. - * @param network Reference to network factory for locator validation and transformation - * @param should_filter_locators Whether to retrieve the locators before the external locators filtering * @param source_vendor_id VendorId of the source participant from which the message was received * @return true on success */ bool readFromCDRMessage( CDRMessage_t* msg, - NetworkFactory& network, - bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id = c_VendorId_eProsima); + /** + * Transform and set the remote locators from the remote_locators_ of another ReaderProxyData. + * If the received ReaderProxyData has no locators, remote locators will be extracted from the + * ParticipantProxyData. + * @param rdata ReaderProxyData to get the locators from + * @param network NetworkFactory to transform locators + * @param participant_data ParticipantProxyData to get the locators from + */ + void setup_locators( + const ReaderProxyData& rdata, + NetworkFactory& network, + const ParticipantProxyData& participant_data); + //! bool m_expectsInlineQos; //!Reader Qos diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp index 225f5c10bf0..2c2d4517f25 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -22,8 +22,10 @@ #include #include +#include #include #include +#include #include "ProxyDataFilters.hpp" @@ -614,11 +616,9 @@ bool WriterProxyData::writeToCDRMessage( bool WriterProxyData::readFromCDRMessage( CDRMessage_t* msg, - NetworkFactory& network, - bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id) { - auto param_process = [this, &network, &should_filter_locators, source_vendor_id]( + auto param_process = [this, source_vendor_id]( CDRMessage_t* msg, const ParameterId_t& pid, uint16_t plength) { VendorId_t vendor_id = source_vendor_id; @@ -886,23 +886,7 @@ bool WriterProxyData::readFromCDRMessage( return false; } - if (!should_filter_locators) - { - remote_locators_.add_unicast_locator(p.locator); - } - else - { - Locator_t temp_locator; - if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration, - m_guid.is_from_this_host())) - { - ProxyDataFilters::filter_locators( - network, - remote_locators_, - temp_locator, - true); - } - } + remote_locators_.add_unicast_locator(p.locator); break; } case fastdds::dds::PID_MULTICAST_LOCATOR: @@ -913,23 +897,7 @@ bool WriterProxyData::readFromCDRMessage( return false; } - if (!should_filter_locators) - { - remote_locators_.add_multicast_locator(p.locator); - } - else - { - Locator_t temp_locator; - if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration, - m_guid.is_from_this_host())) - { - ProxyDataFilters::filter_locators( - network, - remote_locators_, - temp_locator, - false); - } - } + remote_locators_.add_multicast_locator(p.locator); break; } case fastdds::dds::PID_KEY_HASH: @@ -1117,6 +1085,47 @@ bool WriterProxyData::readFromCDRMessage( return false; } +void WriterProxyData::setup_locators( + const WriterProxyData& wdata, + NetworkFactory& network, + const ParticipantProxyData& participant_data) +{ + if (this == &wdata) + { + return; + } + + bool from_this_host = participant_data.is_from_this_host(); + + if (wdata.has_locators()) + { + // Get the transformed remote locators for the WriterProxyData received + remote_locators_.unicast.clear(); + remote_locators_.multicast.clear(); + for (const Locator_t& locator : wdata.remote_locators_.unicast) + { + Locator_t temp_locator; + if (network.transform_remote_locator(locator, temp_locator, m_networkConfiguration, from_this_host)) + { + ProxyDataFilters::filter_locators(network, remote_locators_, temp_locator, true); + } + } + for (const Locator_t& locator : wdata.remote_locators_.multicast) + { + Locator_t temp_locator; + if (network.transform_remote_locator(locator, temp_locator, m_networkConfiguration, from_this_host)) + { + ProxyDataFilters::filter_locators(network, remote_locators_, temp_locator, false); + } + } + } + else + { + // Get the remote locators from the participant_data + set_remote_locators(participant_data.default_locators, network, true, from_this_host); + } +} + void WriterProxyData::clear() { #if HAVE_SECURITY @@ -1245,12 +1254,13 @@ void WriterProxyData::set_announced_unicast_locators( void WriterProxyData::set_remote_unicast_locators( const LocatorList_t& locators, - const NetworkFactory& network) + const NetworkFactory& network, + bool from_this_host) { remote_locators_.unicast.clear(); for (const Locator_t& locator : locators) { - if (network.is_locator_remote_or_allowed(locator, m_guid.is_from_this_host())) + if (network.is_locator_remote_or_allowed(locator, from_this_host)) { remote_locators_.add_unicast_locator(locator); } @@ -1265,12 +1275,13 @@ void WriterProxyData::add_multicast_locator( void WriterProxyData::set_multicast_locators( const LocatorList_t& locators, - const NetworkFactory& network) + const NetworkFactory& network, + bool from_this_host) { remote_locators_.multicast.clear(); for (const Locator_t& locator : locators) { - if (network.is_locator_remote_or_allowed(locator, m_guid.is_from_this_host())) + if (network.is_locator_remote_or_allowed(locator, from_this_host)) { remote_locators_.add_multicast_locator(locator); } @@ -1286,14 +1297,15 @@ void WriterProxyData::set_locators( void WriterProxyData::set_remote_locators( const RemoteLocatorList& locators, const NetworkFactory& network, - bool use_multicast_locators) + bool use_multicast_locators, + bool from_this_host) { remote_locators_.unicast.clear(); remote_locators_.multicast.clear(); for (const Locator_t& locator : locators.unicast) { - if (network.is_locator_remote_or_allowed(locator, m_guid.is_from_this_host())) + if (network.is_locator_remote_or_allowed(locator, from_this_host)) { remote_locators_.add_unicast_locator(locator); } @@ -1303,7 +1315,7 @@ void WriterProxyData::set_remote_locators( { for (const Locator_t& locator : locators.multicast) { - if (network.is_locator_remote_or_allowed(locator, m_guid.is_from_this_host())) + if (network.is_locator_remote_or_allowed(locator, from_this_host)) { remote_locators_.add_multicast_locator(locator); } diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.hpp b/src/cpp/rtps/builtin/data/WriterProxyData.hpp index 7b0729f159c..8a5c53c3d1c 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.hpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.hpp @@ -37,6 +37,7 @@ namespace rtps { struct CDRMessage_t; class NetworkFactory; +class ParticipantProxyData; /** **@ingroup BUILTIN_MODULE @@ -150,24 +151,46 @@ class WriterProxyData void set_announced_unicast_locators( const LocatorList_t& locators); + /** + * Set the remote unicast locators from @param locators. + * @param locators List of locators to be used + * @param network NetworkFactory to check if the locators are allowed + * @param from_this_host Whether the server is from this host or not + */ void set_remote_unicast_locators( const LocatorList_t& locators, - const NetworkFactory& network); + const NetworkFactory& network, + bool from_this_host); void add_multicast_locator( const Locator_t& locator); + /** + * Set the remote multicast locators from @param locators. + * @param locators List of locators to be used + * @param network NetworkFactory to check if the locators are allowed + * @param from_this_host Whether the server is from this host or not + */ void set_multicast_locators( const LocatorList_t& locators, - const NetworkFactory& network); + const NetworkFactory& network, + bool from_this_host); void set_locators( const RemoteLocatorList& locators); + /** + * Set the remote multicast and unicast locators from @param locators. + * @param locators List of locators to be used + * @param network NetworkFactory to check if the locators are allowed + * @param use_multicast_locators Whether to set multicast locators or not + * @param from_this_host Whether the server is from this host or not + */ void set_remote_locators( const RemoteLocatorList& remote_locators, const NetworkFactory& network, - bool use_multicast_locators); + bool use_multicast_locators, + bool from_this_host); void key( const InstanceHandle_t& key) @@ -448,13 +471,30 @@ class WriterProxyData CDRMessage_t* msg, bool write_encapsulation) const; - //!Read a parameter list from a CDRMessage_t. + /** + * Read the information from a CDRMessage_t. The position of the message must be in the beginning on the + * parameter list. + * @param msg Pointer to the message. + * @param source_vendor_id VendorId of the source participant from which the message was received + * @return true on success + */ bool readFromCDRMessage( CDRMessage_t* msg, - NetworkFactory& network, - bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id = c_VendorId_eProsima); + /** + * Transform and set the remote locators from the remote_locators_ of another WriterProxyData. + * If the received WriterProxyData has no locators, remote locators will be extracted from the + * ParticipantProxyData. + * @param wdata WriterProxyData to get the locators from + * @param network NetworkFactory to transform locators + * @param participant_data ParticipantProxyData to get the locators from + */ + void setup_locators( + const WriterProxyData& wdata, + NetworkFactory& network, + const ParticipantProxyData& participant_data); + private: //!GUID diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index d681a338886..67b7a023c72 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -131,7 +131,8 @@ bool EDP::new_reader_proxy_data( } else { - rpd->set_multicast_locators(ratt.multicastLocatorList, network); + rpd->set_multicast_locators(ratt.multicastLocatorList, network, + participant_data.is_from_this_host()); rpd->set_announced_unicast_locators(ratt.unicastLocatorList); fastdds::rtps::network::external_locators::add_external_locators(*rpd, ratt.external_unicast_locators); @@ -271,7 +272,8 @@ bool EDP::new_writer_proxy_data( } else { - wpd->set_multicast_locators(watt.multicastLocatorList, network); + wpd->set_multicast_locators(watt.multicastLocatorList, network, + participant_data.is_from_this_host()); wpd->set_announced_unicast_locators(watt.unicastLocatorList); fastdds::rtps::network::external_locators::add_external_locators(*wpd, watt.external_unicast_locators); @@ -388,7 +390,9 @@ bool EDP::update_reader( } else { - rdata->set_multicast_locators(rtps_reader->getAttributes().multicastLocatorList, network); + rdata->set_multicast_locators( + rtps_reader->getAttributes().multicastLocatorList, network, + participant_data.is_from_this_host()); rdata->set_announced_unicast_locators(rtps_reader->getAttributes().unicastLocatorList); } rdata->m_qos.setQos(rqos, false); @@ -460,7 +464,9 @@ bool EDP::update_writer( } else { - wdata->set_multicast_locators(writer->getAttributes().multicastLocatorList, network); + wdata->set_multicast_locators( + writer->getAttributes().multicastLocatorList, network, + participant_data.is_from_this_host()); wdata->set_announced_unicast_locators(writer->getAttributes().unicastLocatorList); } wdata->m_qos.setQos(wqos, false); diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp index 861b47a0d76..3cd6fff53e3 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp @@ -752,7 +752,8 @@ void EDPSimple::assignRemoteEndpoints( temp_reader_proxy_data->clear(); temp_reader_proxy_data->m_expectsInlineQos = false; temp_reader_proxy_data->guid().guidPrefix = pdata.m_guid.guidPrefix; - temp_reader_proxy_data->set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators); + temp_reader_proxy_data->set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators, + pdata.is_from_this_host()); temp_reader_proxy_data->m_qos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; temp_reader_proxy_data->m_qos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; @@ -761,7 +762,8 @@ void EDPSimple::assignRemoteEndpoints( temp_writer_proxy_data->clear(); temp_writer_proxy_data->guid().guidPrefix = pdata.m_guid.guidPrefix; temp_writer_proxy_data->persistence_guid(pdata.get_persistence_guid()); - temp_writer_proxy_data->set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators); + temp_writer_proxy_data->set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators, + pdata.is_from_this_host()); temp_writer_proxy_data->m_qos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; temp_writer_proxy_data->m_qos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp index dd81e438fdb..dcd35ce4ce9 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp @@ -75,7 +75,7 @@ void EDPBasePUBListener::add_writer_from_change( auto temp_writer_data = edp->get_temporary_writer_proxies_pool().get(); const auto type_server = change->writerGUID; - if (temp_writer_data->readFromCDRMessage(&tempMsg, network, true, change->vendor_id)) + if (temp_writer_data->readFromCDRMessage(&tempMsg, change->vendor_id)) { if (temp_writer_data->guid().guidPrefix == edp->mp_RTPSParticipant->getGuid().guidPrefix) { @@ -95,12 +95,6 @@ void EDPBasePUBListener::add_writer_from_change( bool updating, const ParticipantProxyData& participant_data) { - if (!temp_writer_data->has_locators()) - { - temp_writer_data->set_remote_locators(participant_data.default_locators, network, - true); - } - if (updating && !data->is_update_allowed(*temp_writer_data)) { EPROSIMA_LOG_WARNING(RTPS_EDP, @@ -108,6 +102,7 @@ void EDPBasePUBListener::add_writer_from_change( data->guid()); } *data = *temp_writer_data; + data->setup_locators(*temp_writer_data, network, participant_data); if (request_ret_status != fastdds::dds::RETCODE_OK) { @@ -225,7 +220,7 @@ void EDPBaseSUBListener::add_reader_from_change( auto temp_reader_data = edp->get_temporary_reader_proxies_pool().get(); const auto type_server = change->writerGUID; - if (temp_reader_data->readFromCDRMessage(&tempMsg, network, true, change->vendor_id)) + if (temp_reader_data->readFromCDRMessage(&tempMsg, change->vendor_id)) { if (temp_reader_data->guid().guidPrefix == edp->mp_RTPSParticipant->getGuid().guidPrefix) { @@ -245,12 +240,6 @@ void EDPBaseSUBListener::add_reader_from_change( bool updating, const ParticipantProxyData& participant_data) { - if (!temp_reader_data->has_locators()) - { - temp_reader_data->set_remote_locators(participant_data.default_locators, network, - true); - } - if (updating && !data->is_update_allowed(*temp_reader_data)) { EPROSIMA_LOG_WARNING(RTPS_EDP, @@ -258,6 +247,7 @@ void EDPBaseSUBListener::add_reader_from_change( data->guid()); } *data = *temp_reader_data; + data->setup_locators(*temp_reader_data, network, participant_data); if (request_ret_status != fastdds::dds::RETCODE_OK) { diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp index 78339149141..0e7cbfe55ca 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp @@ -523,7 +523,8 @@ bool EDPStatic::newRemoteReader( if (!newRPD->has_locators()) { const NetworkFactory& network = mp_RTPSParticipant->network_factory(); - newRPD->set_remote_locators(participant_data.default_locators, network, true); + newRPD->set_remote_locators(participant_data.default_locators, network, true, + participant_data.is_from_this_host()); } return true; @@ -575,7 +576,8 @@ bool EDPStatic::newRemoteWriter( if (!newWPD->has_locators()) { const NetworkFactory& network = mp_RTPSParticipant->network_factory(); - newWPD->set_remote_locators(participant_data.default_locators, network, true); + newWPD->set_remote_locators(participant_data.default_locators, network, true, + participant_data.is_from_this_host()); } newWPD->persistence_guid(persistence_guid); diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 00521dc3175..645fe9faa93 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -61,6 +61,7 @@ #include #endif // if HAVE_SECURITY #include +#include #include #include #include @@ -312,6 +313,7 @@ void PDP::initializeParticipantProxyData( participant_data->product_version.major = FASTDDS_VERSION_MAJOR; participant_data->product_version.minor = FASTDDS_VERSION_MINOR; participant_data->product_version.patch = FASTDDS_VERSION_MICRO; + participant_data->machine_id = SystemInfo::instance().machine_id(); // TODO: participant_data->m_availableBuiltinEndpoints |= mp_builtin->available_builtin_endpoints(); diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp index b5ade4acbf9..f3463fe30e9 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp @@ -479,8 +479,8 @@ void PDPClient::assignRemoteEndpoints( if (!should_protect_discovery()) #endif // HAVE_SECURITY { - match_pdp_writer_nts_(server); - match_pdp_reader_nts_(server); + match_pdp_writer_nts_(server, pdata->is_from_this_host()); + match_pdp_reader_nts_(server, pdata->is_from_this_host()); } } } @@ -524,8 +524,8 @@ void PDPClient::notifyAboveRemoteEndpoints( } // Match incoming server - match_pdp_writer_nts_(server); - match_pdp_reader_nts_(server); + match_pdp_writer_nts_(server, pdata.is_from_this_host()); + match_pdp_reader_nts_(server, pdata.is_from_this_host()); } } #endif // HAVE_SECURITY @@ -641,7 +641,8 @@ void PDPClient::removeRemoteEndpoints( temp_writer_data->guid(wguid); temp_writer_data->persistence_guid(pdata->get_persistence_guid()); temp_writer_data->set_persistence_entity_id(c_EntityId_SPDPWriter); - temp_writer_data->set_remote_locators(pdata->metatraffic_locators, network, true); + temp_writer_data->set_remote_locators(pdata->metatraffic_locators, network, true, + pdata->is_from_this_host()); temp_writer_data->m_qos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; temp_writer_data->m_qos.m_durability.kind = dds::TRANSIENT_DURABILITY_QOS; endpoints->reader.reader_->matched_writer_add_edp(*temp_writer_data); @@ -667,7 +668,8 @@ void PDPClient::removeRemoteEndpoints( temp_reader_data->clear(); temp_reader_data->m_expectsInlineQos = false; temp_reader_data->guid(rguid); - temp_reader_data->set_remote_locators(pdata->metatraffic_locators, network, true); + temp_reader_data->set_remote_locators(pdata->metatraffic_locators, network, true, + pdata->is_from_this_host()); temp_reader_data->m_qos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; temp_reader_data->m_qos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; endpoints->writer.writer_->matched_reader_add_edp(*temp_reader_data); @@ -868,14 +870,16 @@ void PDPClient::update_remote_servers_list() } void PDPClient::match_pdp_writer_nts_( - const eprosima::fastdds::rtps::RemoteServerAttributes& server_att) + const eprosima::fastdds::rtps::RemoteServerAttributes& server_att, + bool from_this_host) { - match_pdp_writer_nts_(server_att, server_att.guidPrefix); + match_pdp_writer_nts_(server_att, server_att.guidPrefix, from_this_host); } void PDPClient::match_pdp_writer_nts_( const eprosima::fastdds::rtps::RemoteServerAttributes& server_att, - const eprosima::fastdds::rtps::GuidPrefix_t& prefix_override) + const eprosima::fastdds::rtps::GuidPrefix_t& prefix_override, + bool from_this_host) { auto endpoints = static_cast(builtin_endpoints_.get()); const NetworkFactory& network = mp_RTPSParticipant->network_factory(); @@ -883,8 +887,8 @@ void PDPClient::match_pdp_writer_nts_( temp_writer_data->clear(); temp_writer_data->guid({ prefix_override, endpoints->writer.writer_->getGuid().entityId }); - temp_writer_data->set_multicast_locators(server_att.metatrafficMulticastLocatorList, network); - temp_writer_data->set_remote_unicast_locators(server_att.metatrafficUnicastLocatorList, network); + temp_writer_data->set_multicast_locators(server_att.metatrafficMulticastLocatorList, network, from_this_host); + temp_writer_data->set_remote_unicast_locators(server_att.metatrafficUnicastLocatorList, network, from_this_host); temp_writer_data->m_qos.m_durability.kind = dds::TRANSIENT_DURABILITY_QOS; temp_writer_data->m_qos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; #if HAVE_SECURITY @@ -902,14 +906,16 @@ void PDPClient::match_pdp_writer_nts_( } void PDPClient::match_pdp_reader_nts_( - const eprosima::fastdds::rtps::RemoteServerAttributes& server_att) + const eprosima::fastdds::rtps::RemoteServerAttributes& server_att, + bool from_this_host) { - match_pdp_reader_nts_(server_att, server_att.guidPrefix); + match_pdp_reader_nts_(server_att, server_att.guidPrefix, from_this_host); } void PDPClient::match_pdp_reader_nts_( const eprosima::fastdds::rtps::RemoteServerAttributes& server_att, - const eprosima::fastdds::rtps::GuidPrefix_t& prefix_override) + const eprosima::fastdds::rtps::GuidPrefix_t& prefix_override, + bool from_this_host) { auto endpoints = static_cast(builtin_endpoints_.get()); const NetworkFactory& network = mp_RTPSParticipant->network_factory(); @@ -917,8 +923,8 @@ void PDPClient::match_pdp_reader_nts_( temp_reader_data->clear(); temp_reader_data->guid({ prefix_override, endpoints->reader.reader_->getGuid().entityId }); - temp_reader_data->set_multicast_locators(server_att.metatrafficMulticastLocatorList, network); - temp_reader_data->set_remote_unicast_locators(server_att.metatrafficUnicastLocatorList, network); + temp_reader_data->set_multicast_locators(server_att.metatrafficMulticastLocatorList, network, from_this_host); + temp_reader_data->set_remote_unicast_locators(server_att.metatrafficUnicastLocatorList, network, from_this_host); temp_reader_data->m_qos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; temp_reader_data->m_qos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; #if HAVE_SECURITY diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPClient.h b/src/cpp/rtps/builtin/discovery/participant/PDPClient.h index 49267c89440..7a81fb93ee8 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPClient.h +++ b/src/cpp/rtps/builtin/discovery/participant/PDPClient.h @@ -167,17 +167,23 @@ class PDPClient : public PDP * Manually match the local PDP reader with the PDP writer of a given server. The function is * not thread safe (nts) in the sense that it does not take the PDP mutex. It does however take * temp_data_lock_ + * @param server_att Remote server attributes + * @param from_this_host Whether the server is from this host or not */ void match_pdp_writer_nts_( - const eprosima::fastdds::rtps::RemoteServerAttributes& server_att); + const eprosima::fastdds::rtps::RemoteServerAttributes& server_att, + bool from_this_host); /** * Manually match the local PDP writer with the PDP reader of a given server. The function is * not thread safe (nts) in the sense that it does not take the PDP mutex. It does however take * temp_data_lock_ + * @param server_att Remote server attributes + * @param from_this_host Whether the server is from this host or not */ void match_pdp_reader_nts_( - const eprosima::fastdds::rtps::RemoteServerAttributes& server_att); + const eprosima::fastdds::rtps::RemoteServerAttributes& server_att, + bool from_this_host); private: @@ -187,19 +193,27 @@ class PDPClient : public PDP * Manually match the local PDP reader with the PDP writer of a given server. The function is * not thread safe (nts) in the sense that it does not take the PDP mutex. It does however take * temp_data_lock_ + * @param server_att Remote server attributes + * @param prefix_override GUID prefix of the server + * @param from_this_host Whether the server is from this host or not */ void match_pdp_writer_nts_( const eprosima::fastdds::rtps::RemoteServerAttributes& server_att, - const eprosima::fastdds::rtps::GuidPrefix_t& prefix_override); + const eprosima::fastdds::rtps::GuidPrefix_t& prefix_override, + bool from_this_host); /** * Manually match the local PDP writer with the PDP reader of a given server. The function is * not thread safe (nts) in the sense that it does not take the PDP mutex. It does however take * temp_data_lock_ + * @param server_att Remote server attributes + * @param prefix_override GUID prefix of the server + * @param from_this_host Whether the server is from this host or not */ void match_pdp_reader_nts_( const eprosima::fastdds::rtps::RemoteServerAttributes& server_att, - const eprosima::fastdds::rtps::GuidPrefix_t& prefix_override); + const eprosima::fastdds::rtps::GuidPrefix_t& prefix_override, + bool from_this_host); #if HAVE_SECURITY /** diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp index a41c612afb3..1cf9622ce34 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp @@ -564,7 +564,8 @@ void PDPServer::match_reliable_pdp_endpoints( temp_writer_data->guid().entityId = endpoints->writer.writer_->getGuid().entityId; temp_writer_data->persistence_guid(pdata.get_persistence_guid()); temp_writer_data->set_persistence_entity_id(c_EntityId_SPDPWriter); - temp_writer_data->set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators); + temp_writer_data->set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators, + pdata.is_from_this_host()); temp_writer_data->m_qos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; temp_writer_data->m_qos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; #if HAVE_SECURITY @@ -597,7 +598,8 @@ void PDPServer::match_reliable_pdp_endpoints( temp_reader_data->m_expectsInlineQos = false; temp_reader_data->guid().guidPrefix = pdata.m_guid.guidPrefix; temp_reader_data->guid().entityId = endpoints->reader.reader_->getGuid().entityId; - temp_reader_data->set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators); + temp_reader_data->set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators, + pdata.is_from_this_host()); temp_reader_data->m_qos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; temp_reader_data->m_qos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; #if HAVE_SECURITY @@ -1984,7 +1986,7 @@ void PDPServer::match_pdp_writer_nts_( temp_writer_data->clear(); temp_writer_data->guid({ pdata.m_guid.guidPrefix, endpoints->writer.writer_->getGuid().entityId }); - temp_writer_data->set_remote_locators(pdata.metatraffic_locators, network, true); + temp_writer_data->set_remote_locators(pdata.metatraffic_locators, network, true, pdata.is_from_this_host()); temp_writer_data->m_qos.m_durability.durabilityKind(durability_); temp_writer_data->m_qos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; #if HAVE_SECURITY @@ -2010,7 +2012,7 @@ void PDPServer::match_pdp_reader_nts_( temp_reader_data->clear(); temp_reader_data->guid({ pdata.m_guid.guidPrefix, endpoints->reader.reader_->getGuid().entityId }); - temp_reader_data->set_remote_locators(pdata.metatraffic_locators, network, true); + temp_reader_data->set_remote_locators(pdata.metatraffic_locators, network, true, pdata.is_from_this_host()); temp_reader_data->m_qos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; temp_reader_data->m_qos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; #if HAVE_SECURITY diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp index dbff218fe3e..20c70bac635 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp @@ -677,7 +677,8 @@ void PDPSimple::match_pdp_remote_endpoints( temp_writer_data->guid().entityId = writer_entity_id; temp_writer_data->persistence_guid(pdata.get_persistence_guid()); temp_writer_data->set_persistence_entity_id(writer_entity_id); - temp_writer_data->set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators); + temp_writer_data->set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators, + pdata.is_from_this_host()); temp_writer_data->m_qos.m_reliability.kind = reliability_kind; temp_writer_data->m_qos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; #if HAVE_SECURITY @@ -706,7 +707,8 @@ void PDPSimple::match_pdp_remote_endpoints( temp_reader_data->m_expectsInlineQos = false; temp_reader_data->guid().guidPrefix = pdata.m_guid.guidPrefix; temp_reader_data->guid().entityId = reader_entity_id; - temp_reader_data->set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators); + temp_reader_data->set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators, + pdata.is_from_this_host()); temp_reader_data->m_qos.m_reliability.kind = reliability_kind; temp_reader_data->m_qos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; #if HAVE_SECURITY diff --git a/src/cpp/rtps/builtin/liveliness/WLP.cpp b/src/cpp/rtps/builtin/liveliness/WLP.cpp index 8ba238f8e17..cd8c6a3d960 100644 --- a/src/cpp/rtps/builtin/liveliness/WLP.cpp +++ b/src/cpp/rtps/builtin/liveliness/WLP.cpp @@ -492,7 +492,8 @@ bool WLP::assignRemoteEndpoints( temp_writer_proxy_data_.guid().guidPrefix = pdata.m_guid.guidPrefix; temp_writer_proxy_data_.persistence_guid(pdata.get_persistence_guid()); - temp_writer_proxy_data_.set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators); + temp_writer_proxy_data_.set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators, + pdata.is_from_this_host()); temp_writer_proxy_data_.topicKind(WITH_KEY); temp_writer_proxy_data_.m_qos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; temp_writer_proxy_data_.m_qos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; @@ -500,7 +501,8 @@ bool WLP::assignRemoteEndpoints( temp_reader_proxy_data_.clear(); temp_reader_proxy_data_.m_expectsInlineQos = false; temp_reader_proxy_data_.guid().guidPrefix = pdata.m_guid.guidPrefix; - temp_reader_proxy_data_.set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators); + temp_reader_proxy_data_.set_remote_locators(pdata.metatraffic_locators, network, use_multicast_locators, + pdata.is_from_this_host()); temp_reader_proxy_data_.topicKind(WITH_KEY); temp_reader_proxy_data_.m_qos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; temp_reader_proxy_data_.m_qos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 8d11ce792c6..f137468d6c4 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -3086,11 +3086,7 @@ bool RTPSParticipantImpl::fill_discovery_data_from_cdr_message( alloc_limits.locators.max_multicast_locators, alloc_limits.data_limits); - ret = writer_data.readFromCDRMessage( - &serialized_msg, - network_factory(), - false, - c_VendorId_eProsima); + ret = writer_data.readFromCDRMessage(&serialized_msg, c_VendorId_eProsima); if (ret) { @@ -3121,11 +3117,7 @@ bool RTPSParticipantImpl::fill_discovery_data_from_cdr_message( alloc_limits.locators.max_unicast_locators, alloc_limits.locators.max_multicast_locators, alloc_limits.data_limits); - ret = reader_data.readFromCDRMessage( - &serialized_msg, - network_factory(), - false, - c_VendorId_eProsima); + ret = reader_data.readFromCDRMessage(&serialized_msg, c_VendorId_eProsima); if (ret) { diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index a302d47fae2..9852e875743 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -1173,7 +1173,6 @@ bool SecurityManager::create_participant_stateless_message_reader() ratt.endpoint.multicastLocatorList = pattr.builtin.metatrafficMulticastLocatorList; } ratt.endpoint.unicastLocatorList = pattr.builtin.metatrafficUnicastLocatorList; - ratt.endpoint.remoteLocatorList = pattr.builtin.initialPeersList; ratt.endpoint.external_unicast_locators = pattr.builtin.metatraffic_external_unicast_locators; ratt.endpoint.ignore_non_matching_locators = pattr.ignore_non_matching_locators; ratt.matched_writers_allocation = pattr.allocation.participants; @@ -1273,7 +1272,6 @@ bool SecurityManager::create_participant_volatile_message_secure_writer() watt.endpoint.unicastLocatorList = pattr.builtin.metatrafficUnicastLocatorList; watt.endpoint.external_unicast_locators = pattr.builtin.metatraffic_external_unicast_locators; watt.endpoint.ignore_non_matching_locators = pattr.ignore_non_matching_locators; - watt.endpoint.remoteLocatorList = pattr.builtin.initialPeersList; watt.endpoint.security_attributes().is_submessage_protected = true; watt.endpoint.security_attributes().plugin_endpoint_attributes = PLUGIN_ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_SUBMESSAGE_ENCRYPTED; @@ -1326,7 +1324,6 @@ bool SecurityManager::create_participant_volatile_message_secure_reader() ratt.endpoint.unicastLocatorList = pattr.builtin.metatrafficUnicastLocatorList; ratt.endpoint.external_unicast_locators = pattr.builtin.metatraffic_external_unicast_locators; ratt.endpoint.ignore_non_matching_locators = pattr.ignore_non_matching_locators; - ratt.endpoint.remoteLocatorList = pattr.builtin.initialPeersList; ratt.endpoint.security_attributes().is_submessage_protected = true; ratt.endpoint.security_attributes().plugin_endpoint_attributes = PLUGIN_ENDPOINT_SECURITY_ATTRIBUTES_FLAG_IS_SUBMESSAGE_ENCRYPTED; @@ -2133,7 +2130,8 @@ void SecurityManager::match_builtin_endpoints( temp_stateless_writer_proxy_data_->guid().guidPrefix = participant_data.m_guid.guidPrefix; temp_stateless_writer_proxy_data_->guid().entityId = participant_stateless_message_writer_entity_id; temp_stateless_writer_proxy_data_->persistence_guid(temp_stateless_writer_proxy_data_->guid()); - temp_stateless_writer_proxy_data_->set_remote_locators(participant_data.metatraffic_locators, network, false); + temp_stateless_writer_proxy_data_->set_remote_locators(participant_data.metatraffic_locators, network, false, + participant_data.is_from_this_host()); temp_stateless_writer_proxy_data_->topicKind(NO_KEY); temp_stateless_writer_proxy_data_->m_qos.m_reliability.kind = eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS; @@ -2150,7 +2148,8 @@ void SecurityManager::match_builtin_endpoints( temp_stateless_reader_proxy_data_->m_expectsInlineQos = false; temp_stateless_reader_proxy_data_->guid().guidPrefix = participant_data.m_guid.guidPrefix; temp_stateless_reader_proxy_data_->guid().entityId = participant_stateless_message_reader_entity_id; - temp_stateless_reader_proxy_data_->set_remote_locators(participant_data.metatraffic_locators, network, false); + temp_stateless_reader_proxy_data_->set_remote_locators(participant_data.metatraffic_locators, network, false, + participant_data.is_from_this_host()); temp_stateless_reader_proxy_data_->topicKind(NO_KEY); temp_stateless_reader_proxy_data_->m_qos.m_reliability.kind = eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS; @@ -2174,7 +2173,8 @@ void SecurityManager::match_builtin_key_exchange_endpoints( temp_volatile_writer_proxy_data_->guid().guidPrefix = participant_data.m_guid.guidPrefix; temp_volatile_writer_proxy_data_->guid().entityId = participant_volatile_message_secure_writer_entity_id; temp_volatile_writer_proxy_data_->persistence_guid(temp_volatile_writer_proxy_data_->guid()); - temp_volatile_writer_proxy_data_->set_remote_locators(participant_data.metatraffic_locators, network, false); + temp_volatile_writer_proxy_data_->set_remote_locators(participant_data.metatraffic_locators, network, false, + participant_data.is_from_this_host()); temp_volatile_writer_proxy_data_->topicKind(NO_KEY); temp_volatile_writer_proxy_data_->m_qos.m_reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; temp_volatile_writer_proxy_data_->m_qos.m_durability.kind = eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS; @@ -2190,7 +2190,8 @@ void SecurityManager::match_builtin_key_exchange_endpoints( temp_volatile_reader_proxy_data_->m_expectsInlineQos = false; temp_volatile_reader_proxy_data_->guid().guidPrefix = participant_data.m_guid.guidPrefix; temp_volatile_reader_proxy_data_->guid().entityId = participant_volatile_message_secure_reader_entity_id; - temp_volatile_reader_proxy_data_->set_remote_locators(participant_data.metatraffic_locators, network, false); + temp_volatile_reader_proxy_data_->set_remote_locators(participant_data.metatraffic_locators, network, false, + participant_data.is_from_this_host()); temp_volatile_reader_proxy_data_->topicKind(NO_KEY); temp_volatile_reader_proxy_data_->m_qos.m_reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; temp_volatile_reader_proxy_data_->m_qos.m_durability.kind = eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS; diff --git a/src/cpp/rtps/transport/TCPTransportInterface.cpp b/src/cpp/rtps/transport/TCPTransportInterface.cpp index 907e9ed15c6..5a8693c2049 100644 --- a/src/cpp/rtps/transport/TCPTransportInterface.cpp +++ b/src/cpp/rtps/transport/TCPTransportInterface.cpp @@ -191,6 +191,7 @@ void TCPTransportInterface::clean() { std::vector> channels; + std::vector delete_channels; { std::unique_lock scopedLock(sockets_map_mutex_); @@ -200,10 +201,22 @@ void TCPTransportInterface::clean() for (auto& channel : channel_resources_) { - channels.push_back(channel.second); + if (std::find(channels.begin(), channels.end(), channel.second) == channels.end()) + { + channels.push_back(channel.second); + } + else + { + delete_channels.push_back(channel.first); + } } } + for (auto& delete_channel : delete_channels) + { + channel_resources_.erase(delete_channel); + } + for (auto& channel : channels) { if (channel->connection_established()) @@ -279,7 +292,7 @@ Locator TCPTransportInterface::local_endpoint_to_locator( return locator; } -void TCPTransportInterface::bind_socket( +ResponseCode TCPTransportInterface::bind_socket( std::shared_ptr& channel) { std::unique_lock scopedLock(sockets_map_mutex_); @@ -288,7 +301,29 @@ void TCPTransportInterface::bind_socket( auto it_remove = std::find(unbound_channel_resources_.begin(), unbound_channel_resources_.end(), channel); assert(it_remove != unbound_channel_resources_.end()); unbound_channel_resources_.erase(it_remove); - channel_resources_[channel->locator()] = channel; + + ResponseCode ret = RETCODE_OK; + const auto insert_ret = channel_resources_.insert( + decltype(channel_resources_)::value_type{channel->locator(), channel}); + if (false == insert_ret.second) + { + // There is an existing channel that can be used. Force the Client to close unnecessary socket + ret = RETCODE_SERVER_ERROR; + } + + std::vector local_interfaces; + // Check if the locator is from an owned interface to link all local interfaces to the channel + is_own_interface(channel->locator(), local_interfaces); + if (!local_interfaces.empty()) + { + Locator local_locator(channel->locator()); + for (auto& interface_it : local_interfaces) + { + IPLocator::setIPv4(local_locator, interface_it.locator); + channel_resources_.insert(decltype(channel_resources_)::value_type{local_locator, channel}); + } + } + return ret; } bool TCPTransportInterface::check_crc( @@ -923,7 +958,7 @@ bool TCPTransportInterface::CreateInitialConnect( std::lock_guard socketsLock(sockets_map_mutex_); // We try to find a SenderResource that has this locator. - // Note: This is done in this level because if we do in NetworkFactory level, we have to mantain what transport + // Note: This is done in this level because if we do it at NetworkFactory level, we have to mantain what transport // already reuses a SenderResource. for (auto& sender_resource : send_resource_list) { @@ -987,6 +1022,19 @@ bool TCPTransportInterface::CreateInitialConnect( send_resource_list.emplace_back( static_cast(new TCPSenderResource(*this, physical_locator))); + std::vector local_interfaces; + // Check if the locator is from an owned interface to link all local interfaces to the channel + is_own_interface(physical_locator, local_interfaces); + if (!local_interfaces.empty()) + { + Locator local_locator(physical_locator); + for (auto& interface_it : local_interfaces) + { + IPLocator::setIPv4(local_locator, interface_it.locator); + channel_resources_[local_locator] = channel; + } + } + return true; } @@ -2079,6 +2127,28 @@ void TCPTransportInterface::send_channel_pending_logical_ports( } } +void TCPTransportInterface::is_own_interface( + const Locator& locator, + std::vector& locNames) const +{ + std::vector local_interfaces; + get_ips(local_interfaces, true, false); + for (const auto& interface_it : local_interfaces) + { + if (IPLocator::compareAddress(locator, interface_it.locator) && is_interface_allowed(interface_it.name)) + { + locNames = local_interfaces; + // Remove interface of original locator from the list + locNames.erase(std::remove_if(locNames.begin(), locNames.end(), + [&interface_it](const fastdds::rtps::IPFinder::info_IP& locInterface) + { + return locInterface.locator == interface_it.locator; + }), locNames.end()); + break; + } + } +} + } // namespace rtps } // namespace fastdds } // namespace eprosima diff --git a/src/cpp/rtps/transport/TCPTransportInterface.h b/src/cpp/rtps/transport/TCPTransportInterface.h index 11a1f9f5af2..147a2fdb640 100644 --- a/src/cpp/rtps/transport/TCPTransportInterface.h +++ b/src/cpp/rtps/transport/TCPTransportInterface.h @@ -239,7 +239,7 @@ class TCPTransportInterface : public TransportInterface virtual ~TCPTransportInterface(); //! Stores the binding between the given locator and the given TCP socket. Server side. - void bind_socket( + ResponseCode bind_socket( std::shared_ptr&); //! Removes the listening socket for the specified port. @@ -525,6 +525,16 @@ class TCPTransportInterface : public TransportInterface */ void send_channel_pending_logical_ports( std::shared_ptr& channel); + + /** + * Method to check if a locator contains an interface that belongs to the same host. + * If it occurs, @c locNames will be updated with the list of interfaces of the host. + * @param [in] locator Locator to check. + * @param [in,out] locNames Vector of interfaces to be updated. + */ + void is_own_interface( + const Locator& locator, + std::vector& locNames) const; }; } // namespace rtps diff --git a/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp b/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp index 8813440fd39..9ad8f232332 100644 --- a/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp +++ b/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp @@ -458,7 +458,7 @@ ResponseCode RTCPMessageManager::processBindConnectionRequest( if (RETCODE_OK == code) { - mTransport->bind_socket(channel); + code = mTransport->bind_socket(channel); } sendData(channel, BIND_CONNECTION_RESPONSE, transaction_id, &payload, code); diff --git a/src/cpp/utils/Host.cpp b/src/cpp/utils/Host.cpp new file mode 100644 index 00000000000..4e7582b1147 --- /dev/null +++ b/src/cpp/utils/Host.cpp @@ -0,0 +1,91 @@ +// Copyright 2020 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. + +/* + * Host.cpp + * + */ + +#include + +#if defined(_WIN32) +#include // Avoid conflicts with WinSock of Windows.h +#include +#include +#elif defined(__APPLE__) +#include +#else +#include +#include +#endif // if defined(_WIN32) + + +namespace eprosima { + +fastcdr::string_255 Host::compute_machine_id() +{ + #ifdef _WIN32 + char machine_id[255]; + DWORD BufferSize = sizeof(machine_id); + LONG res = RegGetValueA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography", "MachineGuid", RRF_RT_REG_SZ, + NULL, machine_id, &BufferSize); + if (res == 0) + { + return machine_id; + } + return ""; + #elif defined(__APPLE__) + io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMainPortDefault, "IOService:/"); + if (!ioRegistryRoot) + { + return ""; + } + CFStringRef uuidCf = (CFStringRef) IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR( + kIOPlatformUUIDKey), kCFAllocatorDefault, 0); + IOObjectRelease(ioRegistryRoot); + if (!uuidCf) + { + return ""; + } + + char buf[255]; + if (!CFStringGetCString(uuidCf, buf, sizeof(buf), kCFStringEncodingUTF8)) + { + return ""; + } + CFRelease(uuidCf); + return buf; + #elif defined(_POSIX_SOURCE) + int fd = open("/etc/machine-id", O_RDONLY); + if (fd == -1) + { + return ""; + } + + char buffer[33] = {0}; + ssize_t bytes_read = read(fd, buffer, 32); + close(fd); + + if (bytes_read < 32) + { + return ""; + } + + return buffer; + #else + return ""; + #endif // if defined(_WIN32) +} + +} // eprosima diff --git a/src/cpp/utils/Host.hpp b/src/cpp/utils/Host.hpp index 5dc838927f7..85f816676ec 100644 --- a/src/cpp/utils/Host.hpp +++ b/src/cpp/utils/Host.hpp @@ -15,17 +15,20 @@ #ifndef UTILS_HOST_HPP_ #define UTILS_HOST_HPP_ +#include + #include #include #include #include + namespace eprosima { /** * This singleton generates a host_id based on system interfaces - * ip addresses or mac addresses + * ip addresses, mac addresses or the machine UUID. */ class Host { @@ -53,6 +56,11 @@ class Host return mac_id_; } + inline fastcdr::string_255 machine_id() const + { + return machine_id_; + } + static Host& instance() { static Host singleton; @@ -131,10 +139,20 @@ class Host mac_id_.value[i + 1] = (id_ & 0xFF); } } + + // Compute the machine id hash + machine_id_ = compute_machine_id(); + if (machine_id_ == "") + { + EPROSIMA_LOG_WARNING(UTILS, "Cannot get machine id. Failing back to IP based ID"); + } } + static fastcdr::string_255 compute_machine_id(); + uint16_t id_; uint48 mac_id_; + fastcdr::string_255 machine_id_; }; } // eprosima diff --git a/src/cpp/utils/SystemInfo.hpp b/src/cpp/utils/SystemInfo.hpp index 2d8a6f26f52..709d24576fe 100644 --- a/src/cpp/utils/SystemInfo.hpp +++ b/src/cpp/utils/SystemInfo.hpp @@ -77,6 +77,16 @@ class SystemInfo return Host::instance().id(); } + /** + * Get the identifier of the current machine. + * + * @return the identifier of the current host. + */ + inline fastcdr::string_255 machine_id() const + { + return Host::instance().machine_id(); + } + /** * Get a reference to the singleton instance. * diff --git a/test/mock/rtps/ParticipantProxyData/rtps/builtin/data/ParticipantProxyData.hpp b/test/mock/rtps/ParticipantProxyData/rtps/builtin/data/ParticipantProxyData.hpp index 30811e1e036..2edfcd41acb 100644 --- a/test/mock/rtps/ParticipantProxyData/rtps/builtin/data/ParticipantProxyData.hpp +++ b/test/mock/rtps/ParticipantProxyData/rtps/builtin/data/ParticipantProxyData.hpp @@ -18,6 +18,7 @@ #ifndef RTPS_BUILTIN_DATA__PARTICIPANTPROXYDATA_HPP #define RTPS_BUILTIN_DATA__PARTICIPANTPROXYDATA_HPP +#include #include #include #include @@ -33,6 +34,13 @@ namespace eprosima { namespace fastdds { namespace rtps { +class ReaderProxyData; +class WriterProxyData; + +// proxy specific declarations +template +class ProxyHashTable; + class ParticipantProxyData { public: @@ -64,11 +72,24 @@ class ParticipantProxyData return true; } + bool is_from_this_host() const + { + return true; + } + GUID_t m_guid; uint32_t m_availableBuiltinEndpoints; RemoteLocatorList metatraffic_locators; RemoteLocatorList default_locators; fastdds::rtps::VendorId_t m_VendorId; + fastdds::dds::DomainId_t m_domain_id; + dds::Duration_t m_leaseDuration; + fastcdr::string_255 m_participantName; + fastdds::rtps::ProductVersion_t product_version; + fastdds::dds::ParameterPropertyList_t m_properties; + fastdds::dds::UserDataQosPolicy m_userData; + ProxyHashTable* m_readers = nullptr; + ProxyHashTable* m_writers = nullptr; #if HAVE_SECURITY IdentityToken identity_token_; PermissionsToken permissions_token_; diff --git a/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp b/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp index a7ce8cd7086..917a4d76fef 100644 --- a/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp +++ b/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp @@ -135,14 +135,13 @@ class ReaderProxyData void set_remote_locators( const RemoteLocatorList& /*locators*/, const NetworkFactory& /*network*/, - bool /*use_multicast*/) + bool /*use_multicast*/, + bool /*from_this_host*/) { } bool readFromCDRMessage( CDRMessage_t* /*msg*/, - NetworkFactory& /*network*/, - bool /*should_filter_locators*/, fastdds::rtps::VendorId_t /*source_vendor_id*/) { return true; @@ -150,7 +149,8 @@ class ReaderProxyData void set_multicast_locators( const LocatorList_t& /*locator*/, - const NetworkFactory& /*network*/) + const NetworkFactory& /*network*/, + bool /*from_this_host*/) { } diff --git a/test/mock/rtps/WriterProxyData/rtps/builtin/data/WriterProxyData.hpp b/test/mock/rtps/WriterProxyData/rtps/builtin/data/WriterProxyData.hpp index 1a67868820b..8b40c9225e3 100644 --- a/test/mock/rtps/WriterProxyData/rtps/builtin/data/WriterProxyData.hpp +++ b/test/mock/rtps/WriterProxyData/rtps/builtin/data/WriterProxyData.hpp @@ -115,7 +115,8 @@ class WriterProxyData void set_remote_locators( const RemoteLocatorList& /*locators*/, const NetworkFactory& /*network*/, - bool /*use_multicast*/) + bool /*use_multicast*/, + bool /*from_this_host*/) { } @@ -133,7 +134,8 @@ class WriterProxyData void set_multicast_locators( const LocatorList_t& /*locators*/, - const NetworkFactory& /*network*/) + const NetworkFactory& /*network*/, + bool /*from_this_host*/) { } diff --git a/test/unittest/dds/publisher/CMakeLists.txt b/test/unittest/dds/publisher/CMakeLists.txt index baae50dacb6..81fe89d5633 100644 --- a/test/unittest/dds/publisher/CMakeLists.txt +++ b/test/unittest/dds/publisher/CMakeLists.txt @@ -183,6 +183,7 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/StatefulWriter.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/StatelessPersistentWriter.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/StatelessWriter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -380,5 +381,10 @@ if(MSVC OR MSVC_IDE) iphlpapi Shlwapi ) endif() +if (APPLE) + target_link_libraries(DataWriterTests ${PRIVACY} + "-framework CoreFoundation" "-framework IOKit" + ) +endif() gtest_discover_tests(DataWriterTests PROPERTIES ENVIRONMENT "CERTS_PATH=${PROJECT_SOURCE_DIR}/test/certs") diff --git a/test/unittest/dds/status/CMakeLists.txt b/test/unittest/dds/status/CMakeLists.txt index 2613d36762a..97eb92ec58d 100644 --- a/test/unittest/dds/status/CMakeLists.txt +++ b/test/unittest/dds/status/CMakeLists.txt @@ -79,6 +79,7 @@ set(LISTENERTESTS_SOURCE ListenerTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LocatorSelectorSender.cpp ${PROJECT_SOURCE_DIR}/src/cpp/statistics/fastdds/domain/DomainParticipant.cpp ${PROJECT_SOURCE_DIR}/src/cpp/statistics/fastdds/publisher/qos/DataWriterQos.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -148,6 +149,7 @@ target_include_directories(ListenerTests PRIVATE ${PROJECT_SOURCE_DIR}/test/mock/rtps/DataSharingPayloadPool ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint ${PROJECT_SOURCE_DIR}/test/mock/rtps/NetworkFactory + ${PROJECT_SOURCE_DIR}/test/mock/rtps/ParticipantProxyData ${PROJECT_SOURCE_DIR}/test/mock/rtps/PDP ${PROJECT_SOURCE_DIR}/test/mock/rtps/PDPSimple ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderHistory @@ -198,5 +200,8 @@ endif() if(MSVC OR MSVC_IDE) target_link_libraries(ListenerTests iphlpapi Shlwapi ws2_32) endif() +if (APPLE) + target_link_libraries(ListenerTests "-framework CoreFoundation" "-framework IOKit") +endif() gtest_discover_tests(ListenerTests) diff --git a/test/unittest/dds/xtypes/type_lookup_service/CMakeLists.txt b/test/unittest/dds/xtypes/type_lookup_service/CMakeLists.txt index f4ce49bbb8f..3b79ed319a7 100644 --- a/test/unittest/dds/xtypes/type_lookup_service/CMakeLists.txt +++ b/test/unittest/dds/xtypes/type_lookup_service/CMakeLists.txt @@ -36,6 +36,7 @@ set(TYPELOOKUPSERVICETESTS_SOURCE TypeLookupServiceTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/CDRMessage.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -61,6 +62,7 @@ target_compile_definitions(TypeLookupServiceTests PRIVATE target_include_directories(TypeLookupServiceTests PUBLIC ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint ${PROJECT_SOURCE_DIR}/test/mock/rtps/NetworkFactory + ${PROJECT_SOURCE_DIR}/test/mock/rtps/ParticipantProxyData ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderHistory ${PROJECT_SOURCE_DIR}/test/mock/rtps/ResourceEvent ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSDomain @@ -70,8 +72,8 @@ target_include_directories(TypeLookupServiceTests PUBLIC ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSWriter ${PROJECT_SOURCE_DIR}/test/mock/rtps/StatefulReader ${PROJECT_SOURCE_DIR}/test/mock/rtps/StatefulWriter - ${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterHistory ${PROJECT_SOURCE_DIR}/test/mock/rtps/TypeLookupManager + ${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterHistory ${PROJECT_SOURCE_DIR}/test/mock/xtypes/TypeObjectRegistry ${PROJECT_SOURCE_DIR}/test/mock/xtypes/TypeObjectUtils ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include @@ -87,5 +89,7 @@ target_link_libraries(TypeLookupServiceTests GTest::gmock ${CMAKE_DL_LIBS} ) - +if (APPLE) + target_link_libraries(TypeLookupServiceTests "-framework CoreFoundation" "-framework IOKit") +endif() gtest_discover_tests(TypeLookupServiceTests) diff --git a/test/unittest/dds/xtypes/type_lookup_service/TypeLookupServiceTests.cpp b/test/unittest/dds/xtypes/type_lookup_service/TypeLookupServiceTests.cpp index 807ee2f72b3..21e663f89c1 100644 --- a/test/unittest/dds/xtypes/type_lookup_service/TypeLookupServiceTests.cpp +++ b/test/unittest/dds/xtypes/type_lookup_service/TypeLookupServiceTests.cpp @@ -388,7 +388,7 @@ TEST_F(TypeLookupServiceTests, ReaderProxyData_PID_TYPE_IDV1) msg.init(typeid_msg_buffer, static_cast(sizeof(typeid_msg_buffer))); msg.length = msg.max_size; - ASSERT_TRUE(reader_proxy_.readFromCDRMessage(&msg, network_factory_, true, c_VendorId_eProsima)); + ASSERT_TRUE(reader_proxy_.readFromCDRMessage(&msg, c_VendorId_eProsima)); Log::Flush(); EXPECT_EQ(log_consumer->wait_for_entries(1, 1), 1); @@ -404,7 +404,7 @@ TEST_F(TypeLookupServiceTests, WriterProxyData_PID_TYPE_IDV1) msg.init(typeid_msg_buffer, static_cast(sizeof(typeid_msg_buffer))); msg.length = msg.max_size; - ASSERT_TRUE(writer_proxy_.readFromCDRMessage(&msg, network_factory_, true, c_VendorId_eProsima)); + ASSERT_TRUE(writer_proxy_.readFromCDRMessage(&msg, c_VendorId_eProsima)); Log::Flush(); EXPECT_EQ(log_consumer->wait_for_entries(1, 1), 1); @@ -419,7 +419,7 @@ TEST_F(TypeLookupServiceTests, ReaderProxyData_PID_TYPE_OBJECTV1) msg.init(typeobject_msg_buffer, static_cast(sizeof(typeobject_msg_buffer))); msg.length = msg.max_size; - ASSERT_TRUE(reader_proxy_.readFromCDRMessage(&msg, network_factory_, true, c_VendorId_eProsima)); + ASSERT_TRUE(reader_proxy_.readFromCDRMessage(&msg, c_VendorId_eProsima)); Log::Flush(); EXPECT_EQ(log_consumer->wait_for_entries(1, 1), 1); @@ -434,7 +434,7 @@ TEST_F(TypeLookupServiceTests, WriterProxyData_PID_TYPE_OBJECTV1) msg.init(typeobject_msg_buffer, static_cast(sizeof(typeobject_msg_buffer))); msg.length = msg.max_size; - ASSERT_TRUE(writer_proxy_.readFromCDRMessage(&msg, network_factory_, true, c_VendorId_eProsima)); + ASSERT_TRUE(writer_proxy_.readFromCDRMessage(&msg, c_VendorId_eProsima)); Log::Flush(); EXPECT_EQ(log_consumer->wait_for_entries(1, 1), 1); diff --git a/test/unittest/rtps/attributes/CMakeLists.txt b/test/unittest/rtps/attributes/CMakeLists.txt index 7036c5c87f9..b3b791b1826 100644 --- a/test/unittest/rtps/attributes/CMakeLists.txt +++ b/test/unittest/rtps/attributes/CMakeLists.txt @@ -58,6 +58,7 @@ set(SERVER_ATTRIBUTES_TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -89,6 +90,10 @@ else() target_link_libraries(${SERVER_ATTRIBUTES_TESTS_EXEC} ${PRIVACY} fastcdr fastdds::log) endif() +if (APPLE) + target_link_libraries(${SERVER_ATTRIBUTES_TESTS_EXEC} ${PRIVACY} "-framework CoreFoundation" "-framework IOKit") +endif() + gtest_discover_tests(${SERVER_ATTRIBUTES_TESTS_EXEC} TEST_PREFIX "ServerAttributesTests." TEST_FILTER ${SERVER_ATTRIBUTES_IGNORED_TESTS} diff --git a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp index 88769af870d..16602d2f3e8 100644 --- a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp +++ b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp @@ -122,7 +122,7 @@ TEST(BuiltinDataSerializationTests, ok_with_defaults) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); // EXPECT_EQ(in, out); } @@ -141,7 +141,7 @@ TEST(BuiltinDataSerializationTests, ok_with_defaults) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); } } @@ -214,7 +214,7 @@ TEST(BuiltinDataSerializationTests, msg_without_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, true); + out.readFromCDRMessage(&msg); ASSERT_EQ(out.m_qos.data_sharing.kind(), dds::OFF); } @@ -231,7 +231,7 @@ TEST(BuiltinDataSerializationTests, msg_without_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, true); + out.readFromCDRMessage(&msg); ASSERT_EQ(out.m_qos.data_sharing.kind(), dds::OFF); } } @@ -254,7 +254,7 @@ TEST(BuiltinDataSerializationTests, msg_with_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, true); + out.readFromCDRMessage(&msg); ASSERT_EQ(out.m_qos.data_sharing.kind(), dds::ON); } @@ -274,7 +274,7 @@ TEST(BuiltinDataSerializationTests, msg_with_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, true); + out.readFromCDRMessage(&msg); ASSERT_EQ(out.m_qos.data_sharing.kind(), dds::ON); } } @@ -343,7 +343,7 @@ TEST(BuiltinDataSerializationTests, interoperability_with_opendds_3_27) msg.length = msg.max_size; WriterProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg))); } // DATA(r) @@ -405,7 +405,7 @@ TEST(BuiltinDataSerializationTests, interoperability_with_opendds_3_27) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg))); } } @@ -520,7 +520,7 @@ TEST(BuiltinDataSerializationTests, ignore_unsupported_type_object) msg.length = msg.max_size; WriterProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg))); } } @@ -621,8 +621,7 @@ TEST(BuiltinDataSerializationTests, other_vendor_parameter_list_with_custom_pids msg.init(buffer, buffer_length); msg.length = msg.max_size; - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, - fastdds::rtps::VendorId_t({2, 0})))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, fastdds::rtps::VendorId_t({2, 0})))); }; auto reader_read = [](octet* buffer, uint32_t buffer_length, ReaderProxyData& out) -> void @@ -631,8 +630,7 @@ TEST(BuiltinDataSerializationTests, other_vendor_parameter_list_with_custom_pids msg.init(buffer, buffer_length); msg.length = msg.max_size; - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, - fastdds::rtps::VendorId_t({2, 0})))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, fastdds::rtps::VendorId_t({2, 0})))); }; auto update_cache_change = @@ -883,8 +881,7 @@ TEST(BuiltinDataSerializationTests, rti_parameter_list_with_custom_pids) msg.init(buffer, buffer_length); msg.length = msg.max_size; - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, - fastdds::rtps::c_VendorId_rti_connext))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, fastdds::rtps::c_VendorId_rti_connext))); }; auto reader_read = [](octet* buffer, uint32_t buffer_length, ReaderProxyData& out) -> void @@ -893,8 +890,7 @@ TEST(BuiltinDataSerializationTests, rti_parameter_list_with_custom_pids) msg.init(buffer, buffer_length); msg.length = msg.max_size; - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, - fastdds::rtps::c_VendorId_rti_connext))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, fastdds::rtps::c_VendorId_rti_connext))); }; auto update_cache_change = @@ -1103,7 +1099,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_without_parameters) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); ASSERT_EQ(in.content_filter().content_filtered_topic_name, out.content_filter().content_filtered_topic_name); ASSERT_EQ(in.content_filter().related_topic_name, out.content_filter().related_topic_name); @@ -1144,7 +1140,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_with_parameters) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); ASSERT_EQ(in.content_filter().content_filtered_topic_name, out.content_filter().content_filtered_topic_name); ASSERT_EQ(in.content_filter().related_topic_name, out.content_filter().related_topic_name); @@ -1236,7 +1232,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_topic_name_deser EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); assert_is_empty_content_filter(out.content_filter()); } @@ -1285,7 +1281,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_topic_name_deser EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); assert_is_empty_content_filter(out.content_filter()); } @@ -1370,7 +1366,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_related_topic_na EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); assert_is_empty_content_filter(out.content_filter()); } @@ -1419,7 +1415,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_related_topic_na EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); assert_is_empty_content_filter(out.content_filter()); } @@ -1453,7 +1449,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_empty_filter_class) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); assert_is_empty_content_filter(out.content_filter()); } @@ -1508,7 +1504,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_filter_class_des EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); assert_is_empty_content_filter(out.content_filter()); } @@ -1557,7 +1553,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_filter_class_des EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); assert_is_empty_content_filter(out.content_filter()); } @@ -1591,7 +1587,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_empty_filter_expressio // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); assert_is_empty_content_filter(out.content_filter()); } @@ -1646,7 +1642,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_filter_expressio EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); assert_is_empty_content_filter(out.content_filter()); } @@ -1833,7 +1829,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_interoperability) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg))); ASSERT_EQ("ContentFilter_0", out.content_filter().content_filtered_topic_name.to_string()); ASSERT_EQ("Square", out.content_filter().related_topic_name.to_string()); @@ -1902,7 +1898,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_max_parameter_check) EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg)); ASSERT_EQ(100, out.content_filter().expression_parameters.size()); @@ -1946,7 +1942,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_max_parameter_check) msg_fault.pos = 0; // Deserialization of messages with more than 100 parameters should fail - ASSERT_FALSE(out.readFromCDRMessage(&msg_fault, network, true)); + ASSERT_FALSE(out.readFromCDRMessage(&msg_fault)); } } @@ -1989,6 +1985,10 @@ TEST(BuiltinDataSerializationTests, interoperability_with_intercomdds) // Participant GUID 0x50, 0x00, 0x10, 0x00, 0x01, 0x05, 0xfa, 0xd5, 0x7a, 0x09, 0x6a, 0x22, 0x84, 0xfb, 0x23, 0xa2, 0x00, 0x00, 0x01, 0xc1, + // Custom (0x8003) + 0x03, 0x80, 0x20, 0x00, + 0x38, 0x63, 0x33, 0x64, 0x36, 0x62, 0x61, 0x39, 0x32, 0x61, 0x35, 0x38, 0x39, 0x31, 0x62, 0x62, + 0x62, 0x64, 0x62, 0x34, 0x35, 0x62, 0x67, 0x66, 0x32, 0x61, 0x35, 0x38, 0x39, 0x63, 0x62, 0x36, // Custom (0x8005) 0x05, 0x80, 0x18, 0x00, 0x12, 0x00, 0x00, 0x00, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x43, 0x4f, 0x4d, 0x20, 0x33, 0x5f, 0x31, @@ -2115,7 +2115,7 @@ TEST(BuiltinDataSerializationTests, interoperability_with_intercomdds) msg.length = msg.max_size; WriterProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, intercom_vendor_id))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, intercom_vendor_id))); } // DATA(r) @@ -2182,7 +2182,7 @@ TEST(BuiltinDataSerializationTests, interoperability_with_intercomdds) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, intercom_vendor_id))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, intercom_vendor_id))); } } @@ -2414,7 +2414,7 @@ TEST(BuiltinDataSerializationTests, deserialization_of_big_parameters) limits.max_user_data = parameter_length; WriterProxyData out(max_unicast_locators, max_multicast_locators, limits); EXPECT_NO_THROW( - if (!out.readFromCDRMessage(&msg, network, true)) + if (!out.readFromCDRMessage(&msg)) { failed_for_data_w.insert(pid); } @@ -2431,7 +2431,7 @@ TEST(BuiltinDataSerializationTests, deserialization_of_big_parameters) limits.max_user_data = parameter_length; ReaderProxyData out(max_unicast_locators, max_multicast_locators, limits); EXPECT_NO_THROW( - if (!out.readFromCDRMessage(&msg, network, true)) + if (!out.readFromCDRMessage(&msg)) { failed_for_data_r.insert(pid); } diff --git a/test/unittest/rtps/builtin/CMakeLists.txt b/test/unittest/rtps/builtin/CMakeLists.txt index 3aa968edf7e..4845c8020b5 100644 --- a/test/unittest/rtps/builtin/CMakeLists.txt +++ b/test/unittest/rtps/builtin/CMakeLists.txt @@ -38,6 +38,7 @@ set(BUILTIN_DATA_SERIALIZATION_TESTS_SOURCE BuiltinDataSerializationTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -89,4 +90,8 @@ else() target_link_libraries(BuiltinDataSerializationTests ${PRIVACY} fastcdr) endif() +if (APPLE) + target_link_libraries(BuiltinDataSerializationTests ${PRIVACY} "-framework CoreFoundation" "-framework IOKit") +endif() + gtest_discover_tests(BuiltinDataSerializationTests) diff --git a/test/unittest/rtps/common/CMakeLists.txt b/test/unittest/rtps/common/CMakeLists.txt index f048ff687ec..b74afc41aa9 100644 --- a/test/unittest/rtps/common/CMakeLists.txt +++ b/test/unittest/rtps/common/CMakeLists.txt @@ -26,6 +26,7 @@ set(GUID_UTILS_TESTS_SOURCE GuidUtilsTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -99,6 +100,9 @@ endif() if(MSVC OR MSVC_IDE) target_link_libraries(GuidUtilsTests ws2_32) endif() +if (APPLE) + target_link_libraries(GuidUtilsTests "-framework CoreFoundation" "-framework IOKit") +endif() gtest_discover_tests(GuidUtilsTests) add_executable(SequenceNumberTests ${SEQUENCENUMBERTESTS_SOURCE}) diff --git a/test/unittest/rtps/discovery/CMakeLists.txt b/test/unittest/rtps/discovery/CMakeLists.txt index 4ff782ff106..883594a1fee 100644 --- a/test/unittest/rtps/discovery/CMakeLists.txt +++ b/test/unittest/rtps/discovery/CMakeLists.txt @@ -31,6 +31,7 @@ set(EDPTESTS_SOURCE EdpTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -50,23 +51,24 @@ target_compile_definitions(EdpTests PRIVATE $<$:__INTERNALDEBUG> # Internal debug activated. ) target_include_directories(EdpTests PRIVATE - ${PROJECT_SOURCE_DIR}/test/mock/rtps/PDP + ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint ${PROJECT_SOURCE_DIR}/test/mock/rtps/external_locators ${PROJECT_SOURCE_DIR}/test/mock/rtps/NetworkFactory - ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl - ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint + ${PROJECT_SOURCE_DIR}/test/mock/rtps/ParticipantProxyData + ${PROJECT_SOURCE_DIR}/test/mock/rtps/PDP + ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderHistory ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderProxyData + ${PROJECT_SOURCE_DIR}/test/mock/rtps/ResourceEvent + ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSDomainImpl + ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSReader - ${PROJECT_SOURCE_DIR}/test/mock/rtps/StatefulReader - ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderHistory - ${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterProxyData ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSWriter + ${PROJECT_SOURCE_DIR}/test/mock/rtps/SecurityManager + ${PROJECT_SOURCE_DIR}/test/mock/rtps/StatefulReader ${PROJECT_SOURCE_DIR}/test/mock/rtps/StatefulWriter - ${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterHistory ${PROJECT_SOURCE_DIR}/test/mock/rtps/TimedEvent - ${PROJECT_SOURCE_DIR}/test/mock/rtps/ResourceEvent - ${PROJECT_SOURCE_DIR}/test/mock/rtps/SecurityManager - ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSDomainImpl + ${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterHistory + ${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterProxyData ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ${Asio_INCLUDE_DIR} @@ -83,6 +85,8 @@ if(QNX) endif() if(MSVC OR MSVC_IDE) target_link_libraries(EdpTests ${PRIVACY} fastcdr iphlpapi Shlwapi ws2_32) +elseif(APPLE) + target_link_libraries(EdpTests ${PRIVACY} fastcdr "-framework CoreFoundation" "-framework IOKit") else() target_link_libraries(EdpTests ${PRIVACY} fastcdr) endif() @@ -139,6 +143,7 @@ set(PDPTESTS_SOURCE PDPTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -191,6 +196,8 @@ if(QNX) endif() if(MSVC OR MSVC_IDE) target_link_libraries(PDPTests ${PRIVACY} fastcdr iphlpapi Shlwapi ws2_32) +elseif(APPLE) + target_link_libraries(PDPTests ${PRIVACY} fastcdr "-framework CoreFoundation" "-framework IOKit") else() target_link_libraries(PDPTests ${PRIVACY} fastcdr) endif() diff --git a/test/unittest/rtps/network/CMakeLists.txt b/test/unittest/rtps/network/CMakeLists.txt index 345b5eec5e9..2556df9cafe 100644 --- a/test/unittest/rtps/network/CMakeLists.txt +++ b/test/unittest/rtps/network/CMakeLists.txt @@ -51,6 +51,7 @@ set(NETWORKFACTORYTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv4Transport.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv6Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -121,6 +122,7 @@ add_executable(ExternalLocatorsTests ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -159,6 +161,10 @@ if(WIN32) target_link_libraries(NetworkFactoryTests IPHLPAPI shlwapi) # Later so mocks have precedence target_link_libraries(ExternalLocatorsTests IPHLPAPI shlwapi) # Later so mocks have precedence endif() +if (APPLE) + target_link_libraries(NetworkFactoryTests "-framework CoreFoundation" "-framework IOKit") + target_link_libraries(ExternalLocatorsTests "-framework CoreFoundation" "-framework IOKit") +endif() gtest_discover_tests(NetworkFactoryTests) gtest_discover_tests(ExternalLocatorsTests) diff --git a/test/unittest/rtps/reader/CMakeLists.txt b/test/unittest/rtps/reader/CMakeLists.txt index c3fdc14045c..440ac8e5dd2 100644 --- a/test/unittest/rtps/reader/CMakeLists.txt +++ b/test/unittest/rtps/reader/CMakeLists.txt @@ -295,6 +295,7 @@ set(STATEFUL_READER_TESTS_SOURCE StatefulReaderTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/utils/TypePropagation.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -428,4 +429,7 @@ if(MSVC OR MSVC_IDE) iphlpapi Shlwapi ) endif() +if (APPLE) + target_link_libraries(StatefulReaderTests ${PRIVACY} "-framework CoreFoundation" "-framework IOKit") +endif() gtest_discover_tests(StatefulReaderTests) diff --git a/test/unittest/security/authentication/CMakeLists.txt b/test/unittest/security/authentication/CMakeLists.txt index b7dfe3fee1d..400814d1135 100644 --- a/test/unittest/security/authentication/CMakeLists.txt +++ b/test/unittest/security/authentication/CMakeLists.txt @@ -55,6 +55,7 @@ add_executable(BuiltinPKIDH ${COMMON_SOURCES_AUTH_PLUGIN_TEST_SOURCE} ${PROJECT_SOURCE_DIR}/src/cpp/security/artifact_providers/FileProvider.cpp ${PROJECT_SOURCE_DIR}/src/cpp/security/artifact_providers/Pkcs11Provider.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp @@ -84,5 +85,8 @@ target_link_libraries(BuiltinPKIDH if(QNX) target_link_libraries(BuiltinPKIDH socket) endif() +if (APPLE) + target_link_libraries(BuiltinPKIDH "-framework CoreFoundation" "-framework IOKit") +endif() gtest_discover_tests(BuiltinPKIDH PROPERTIES ENVIRONMENT "CERTS_PATH=${PROJECT_SOURCE_DIR}/test/certs") diff --git a/test/unittest/statistics/dds/CMakeLists.txt b/test/unittest/statistics/dds/CMakeLists.txt index 488c71edd69..10156e13523 100644 --- a/test/unittest/statistics/dds/CMakeLists.txt +++ b/test/unittest/statistics/dds/CMakeLists.txt @@ -300,6 +300,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/statistics/types/monitorservice_typesTypeObjectSupport.cxx ${PROJECT_SOURCE_DIR}/src/cpp/statistics/types/typesPubSubTypes.cxx ${PROJECT_SOURCE_DIR}/src/cpp/statistics/types/typesTypeObjectSupport.cxx + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -481,6 +482,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/statistics/types/monitorservice_typesTypeObjectSupport.cxx ${PROJECT_SOURCE_DIR}/src/cpp/statistics/types/typesPubSubTypes.cxx ${PROJECT_SOURCE_DIR}/src/cpp/statistics/types/typesTypeObjectSupport.cxx + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -596,6 +598,9 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) iphlpapi Shlwapi ) endif() + if (APPLE) + target_link_libraries(StatisticsDomainParticipantMockTests ${PRIVACY} "-framework CoreFoundation" "-framework IOKit") + endif() gtest_discover_tests(StatisticsDomainParticipantMockTests) @@ -645,6 +650,10 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) iphlpapi Shlwapi ) endif() + if (APPLE) + target_link_libraries(StatisticsDomainParticipantStatusQueryableTests ${PRIVACY} "-framework CoreFoundation" "-framework IOKit") + endif() + gtest_discover_tests(StatisticsDomainParticipantStatusQueryableTests) endif (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) diff --git a/test/unittest/statistics/rtps/CMakeLists.txt b/test/unittest/statistics/rtps/CMakeLists.txt index 59860583126..5d807b3c8a3 100644 --- a/test/unittest/statistics/rtps/CMakeLists.txt +++ b/test/unittest/statistics/rtps/CMakeLists.txt @@ -96,6 +96,7 @@ set(STATISTICS_RTPS_MONITORSERVICETESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/statistics/types/monitorservice_typesTypeObjectSupport.cxx ${PROJECT_SOURCE_DIR}/src/cpp/statistics/types/typesPubSubTypes.cxx ${PROJECT_SOURCE_DIR}/src/cpp/statistics/types/typesTypeObjectSupport.cxx + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -121,6 +122,7 @@ target_include_directories(MonitorServiceTests PRIVATE ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint ${PROJECT_SOURCE_DIR}/test/mock/rtps/external_locators ${PROJECT_SOURCE_DIR}/test/mock/rtps/ExternalLocatorsProcessor + ${PROJECT_SOURCE_DIR}/test/mock/rtps/ParticipantProxyData ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderHistory ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReceiverResource ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSDomainImpl @@ -153,6 +155,10 @@ target_link_libraries(MonitorServiceTests gtest_discover_tests(MonitorServiceTests) +if (APPLE) + target_link_libraries(MonitorServiceTests "-framework CoreFoundation" "-framework IOKit") +endif() + if(QNX) target_link_libraries(RTPSStatisticsTests socket) target_link_libraries(MonitorServiceTests socket) diff --git a/test/unittest/transport/CMakeLists.txt b/test/unittest/transport/CMakeLists.txt index 3b45f19afdd..62047bc4582 100644 --- a/test/unittest/transport/CMakeLists.txt +++ b/test/unittest/transport/CMakeLists.txt @@ -89,6 +89,7 @@ set(UDPV4TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv4Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -121,6 +122,7 @@ set(UDPV6TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv4Transport.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv6Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -163,6 +165,7 @@ set(TCPV4TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv4Transport.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -212,6 +215,7 @@ set(TCPV6TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv6Transport.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -249,6 +253,7 @@ set(SHAREDMEMTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/SharedMemTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -308,6 +313,9 @@ endif() if(MSVC OR MSVC_IDE) target_link_libraries(UDPv4Tests ${PRIVACY} iphlpapi Shlwapi ) endif() +if (APPLE) + target_link_libraries(UDPv4Tests ${PRIVACY} "-framework CoreFoundation" "-framework IOKit") +endif() gtest_discover_tests(UDPv4Tests) ########################## @@ -345,6 +353,9 @@ if(NOT DISABLE_UDPV6_TESTS) if(MSVC OR MSVC_IDE) target_link_libraries(UDPv6Tests ${PRIVACY} iphlpapi Shlwapi ) endif() + if (APPLE) + target_link_libraries(UDPv6Tests ${PRIVACY} "-framework CoreFoundation" "-framework IOKit") + endif() gtest_discover_tests(UDPv6Tests) ########################## @@ -378,6 +389,8 @@ if(NOT DISABLE_UDPV6_TESTS) endif() if(MSVC OR MSVC_IDE) target_link_libraries(TCPv6Tests ${PRIVACY} fastcdr iphlpapi Shlwapi) + elseif(APPLE) + target_link_libraries(TCPv6Tests ${PRIVACY} fastcdr "-framework CoreFoundation" "-framework IOKit") else() target_link_libraries(TCPv6Tests ${PRIVACY} fastcdr) endif() @@ -415,6 +428,8 @@ if(QNX) endif() if(MSVC OR MSVC_IDE) target_link_libraries(TCPv4Tests ${PRIVACY} fastcdr iphlpapi Shlwapi) +elseif(APPLE) + target_link_libraries(TCPv4Tests ${PRIVACY} fastcdr "-framework CoreFoundation" "-framework IOKit") else() target_link_libraries(TCPv4Tests ${PRIVACY} fastcdr) endif() @@ -458,6 +473,8 @@ if(IS_THIRDPARTY_BOOST_OK) endif() if(MSVC OR MSVC_IDE) target_link_libraries(SharedMemTests ${PRIVACY} iphlpapi Shlwapi ) + elseif(APPLE) + target_link_libraries(SharedMemTests ${PRIVACY} "-framework CoreFoundation" "-framework IOKit") else() target_link_libraries(SharedMemTests ${PRIVACY} ) endif() diff --git a/test/unittest/transport/TCPv4Tests.cpp b/test/unittest/transport/TCPv4Tests.cpp index b8649b06836..06ee3e8cb68 100644 --- a/test/unittest/transport/TCPv4Tests.cpp +++ b/test/unittest/transport/TCPv4Tests.cpp @@ -2001,6 +2001,9 @@ TEST_F(TCPv4Tests, autofill_port) // This test verifies server's channel resources mapping keys uniqueness, where keys are clients locators. // Clients typically communicated its PID as its locator port. When having several clients in the same // process this lead to overwriting server's channel resources map elements. +// In order to ensure communication in TCP Discovery Server, a different entry is created in the server's +// channel resources map for each IP interface found, all of them using the same TCP channel. Thus, two +// clients will generate at least two entries in the server's channel resources map. TEST_F(TCPv4Tests, client_announced_local_port_uniqueness) { TCPv4TransportDescriptor recvDescriptor; @@ -2032,7 +2035,12 @@ TEST_F(TCPv4Tests, client_announced_local_port_uniqueness) std::this_thread::sleep_for(std::chrono::milliseconds(100)); - ASSERT_EQ(receiveTransportUnderTest.get_channel_resources().size(), 2u); + std::set> channels_created; + for (const auto& channel_resource : receiveTransportUnderTest.get_channel_resources()) + { + channels_created.insert(channel_resource.second); + } + ASSERT_EQ(channels_created.size(), 2u); } #ifndef _WIN32 diff --git a/test/unittest/utils/CMakeLists.txt b/test/unittest/utils/CMakeLists.txt index 32ea0d63d55..348e0c59b40 100644 --- a/test/unittest/utils/CMakeLists.txt +++ b/test/unittest/utils/CMakeLists.txt @@ -64,8 +64,10 @@ set(SYSTEMINFOTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/Host.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp) set(TREETESTS_SOURCE @@ -168,6 +170,9 @@ target_link_libraries(SystemInfoTests fastdds::log GTest::gtest ) +if(APPLE) + target_link_libraries(SystemInfoTests "-framework CoreFoundation" "-framework IOKit") +endif() gtest_discover_tests(SystemInfoTests) add_executable(SharedMutexTests shared_mutex_tests.cpp) diff --git a/test/unittest/utils/SystemInfoTests.cpp b/test/unittest/utils/SystemInfoTests.cpp index 13216b1ca23..4b85ecbec44 100644 --- a/test/unittest/utils/SystemInfoTests.cpp +++ b/test/unittest/utils/SystemInfoTests.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -160,6 +161,12 @@ TEST_F(SystemInfoTests, GetUsernameTest) EXPECT_FALSE(username.empty()); } +TEST_F(SystemInfoTests, GetMachineId) +{ + eprosima::fastcdr::string_255 machine_id = eprosima::SystemInfo::instance().machine_id(); + EXPECT_GT(machine_id.size(), 0u); +} + /** * This test checks the file_exists static method of the SystemInfo class */ diff --git a/tools/fds/server.cpp b/tools/fds/server.cpp index 09098ddddfa..280747d6083 100644 --- a/tools/fds/server.cpp +++ b/tools/fds/server.cpp @@ -304,6 +304,8 @@ int fastdds_discovery_server( // Retrieve first TCP port option::Option* pO_tcp_port = options[TCP_PORT]; + bool udp_server_initialized = (pOp != nullptr) || (pO_port != nullptr); + /** * A locator has been initialized previously in [0.0.0.0] address using either the DEFAULT_ROS2_SERVER_PORT or the * port number set in the CLI. This locator must be used: @@ -318,6 +320,7 @@ int fastdds_discovery_server( // Add default locator in cases a) and b) participantQos.wire_protocol().builtin.metatrafficUnicastLocatorList.clear(); participantQos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(locator4); + udp_server_initialized = true; } else if (nullptr == pOp && nullptr != pO_port) { @@ -569,6 +572,7 @@ int fastdds_discovery_server( } fastdds::rtps::GuidPrefix_t guid_prefix = participantQos.wire_protocol().prefix; + participantQos.transport().use_builtin_transports = udp_server_initialized || options[XML_FILE] != nullptr; // Create the server int return_value = 0; diff --git a/versions.md b/versions.md index 7e3ce4680fd..7d3fc3da1e4 100644 --- a/versions.md +++ b/versions.md @@ -7,6 +7,7 @@ Forthcoming * `DataReader::get_matched_publication_data()` * `DataReader::get_matched_publications()` * Added ``Extended Incompatible QoS`` feature for monitor service. +* Machine UUID added to the Data(p) to check Participants in same host, instead of using GUIDs. Version v3.1.0 --------------