diff --git a/include/fastdds/dds/core/policy/ParameterTypes.hpp b/include/fastdds/dds/core/policy/ParameterTypes.hpp
index a9614d2c5d5..a14b231b4b0 100644
--- a/include/fastdds/dds/core/policy/ParameterTypes.hpp
+++ b/include/fastdds/dds/core/policy/ParameterTypes.hpp
@@ -159,6 +159,7 @@ enum ParameterId_t : uint16_t
PID_CUSTOM_RELATED_SAMPLE_IDENTITY = 0x800f,
PID_DISABLE_POSITIVE_ACKS = 0x8005,
PID_DATASHARING = 0x8006,
+ PID_NETWORK_CONFIGURATION_SET = 0x8007,
};
/*!
@@ -886,6 +887,41 @@ class ParameterBuiltinEndpointSet_t : public Parameter_t
#define PARAMETER_BUILTINENDPOINTSET_LENGTH 4
+/**
+ * @ingroup PARAMETER_MODULE
+ */
+class ParameterNetworkConfigSet_t : public Parameter_t
+{
+public:
+
+ //!Network Config Set
By default, 0.
+ fastrtps::rtps::NetworkConfigSet_t netconfigSet;
+
+ /**
+ * @brief Constructor without parameters
+ */
+ ParameterNetworkConfigSet_t()
+ : netconfigSet(0)
+ {
+ }
+
+ /**
+ * Constructor using a parameter PID and the parameter length
+ *
+ * @param pid Pid of the parameter
+ * @param in_length Its associated length
+ */
+ ParameterNetworkConfigSet_t(
+ ParameterId_t pid,
+ uint16_t in_length)
+ : Parameter_t(pid, in_length)
+ , netconfigSet(0)
+ {
+ }
+
+};
+
+#define PARAMETER_NETWORKCONFIGSET_LENGTH 4
/**
* @ingroup PARAMETER_MODULE
diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h
index 09be3da4531..b6ce937ccdf 100644
--- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h
+++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h
@@ -26,6 +26,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -381,6 +382,9 @@ class BuiltinAttributes
//! TypeLookup Service settings
TypeLookupSettings typelookup_config;
+ //! Network Configuration
+ NetworkConfigSet_t network_configuration;
+
//! Metatraffic Unicast Locator List
LocatorList_t metatrafficUnicastLocatorList;
@@ -424,6 +428,7 @@ class BuiltinAttributes
(this->use_WriterLivelinessProtocol == b.use_WriterLivelinessProtocol) &&
(typelookup_config.use_client == b.typelookup_config.use_client) &&
(typelookup_config.use_server == b.typelookup_config.use_server) &&
+ (this->network_configuration == b.network_configuration) &&
(this->metatrafficUnicastLocatorList == b.metatrafficUnicastLocatorList) &&
(this->metatrafficMulticastLocatorList == b.metatrafficMulticastLocatorList) &&
(this->metatraffic_external_unicast_locators == b.metatraffic_external_unicast_locators) &&
diff --git a/include/fastdds/rtps/builtin/BuiltinProtocols.h b/include/fastdds/rtps/builtin/BuiltinProtocols.h
index c9d99d0038b..12e1dd1d682 100644
--- a/include/fastdds/rtps/builtin/BuiltinProtocols.h
+++ b/include/fastdds/rtps/builtin/BuiltinProtocols.h
@@ -102,11 +102,10 @@ class BuiltinProtocols
LocatorList_t& loclist);
/**
- * Traverses the list of discover servers translating from remote to local locators
- * if possible
- * @param nf NetworkFactory used to make the translation
+ * Traverses the list of discover servers filtering out unsupported or not allowed remote locators
+ * @param nf NetworkFactory used to make the filtering
*/
- void transform_server_remote_locators(
+ void filter_server_remote_locators(
NetworkFactory& nf);
//!BuiltinAttributes of the builtin protocols.
diff --git a/include/fastdds/rtps/builtin/data/NetworkConfiguration.hpp b/include/fastdds/rtps/builtin/data/NetworkConfiguration.hpp
new file mode 100644
index 00000000000..5a0a1f6593e
--- /dev/null
+++ b/include/fastdds/rtps/builtin/data/NetworkConfiguration.hpp
@@ -0,0 +1,24 @@
+// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// 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.
+
+/**
+ * @file NetworkConfiguration.hpp
+ */
+
+#ifndef FASTDDS_RTPS_BUILTIN_DATA__NETWORKCONFIGURATION_HPP
+#define FASTDDS_RTPS_BUILTIN_DATA__NETWORKCONFIGURATION_HPP
+
+#define DISC_NETWORK_CONFIGURATION_LISTENING_LOCALHOST_ALL (0x0000000F)
+
+#endif // FASTDDS_RTPS_BUILTIN_DATA__NETWORKCONFIGURATION_HPP
diff --git a/include/fastdds/rtps/builtin/data/ParticipantProxyData.h b/include/fastdds/rtps/builtin/data/ParticipantProxyData.h
index 5602944ed2d..b9b533c230d 100644
--- a/include/fastdds/rtps/builtin/data/ParticipantProxyData.h
+++ b/include/fastdds/rtps/builtin/data/ParticipantProxyData.h
@@ -81,6 +81,8 @@ class ParticipantProxyData
bool m_expectsInlineQos;
//!Available builtin endpoints
BuiltinEndpointSet_t m_availableBuiltinEndpoints;
+ //!Network configuration
+ NetworkConfigSet_t m_networkConfiguration;
//!Metatraffic locators
RemoteLocatorList metatraffic_locators;
//!Default locators
diff --git a/include/fastdds/rtps/builtin/data/ReaderProxyData.h b/include/fastdds/rtps/builtin/data/ReaderProxyData.h
index 1c61f5184bb..5a96411168c 100644
--- a/include/fastdds/rtps/builtin/data/ReaderProxyData.h
+++ b/include/fastdds/rtps/builtin/data/ReaderProxyData.h
@@ -91,6 +91,28 @@ class ReaderProxyData
return m_guid;
}
+ RTPS_DllAPI void networkConfiguration(
+ const NetworkConfigSet_t& networkConfiguration)
+ {
+ m_networkConfiguration = networkConfiguration;
+ }
+
+ RTPS_DllAPI void networkConfiguration(
+ NetworkConfigSet_t&& networkConfiguration)
+ {
+ m_networkConfiguration = std::move(networkConfiguration);
+ }
+
+ RTPS_DllAPI const NetworkConfigSet_t& networkConfiguration() const
+ {
+ return m_networkConfiguration;
+ }
+
+ RTPS_DllAPI NetworkConfigSet_t& networkConfiguration()
+ {
+ return m_networkConfiguration;
+ }
+
RTPS_DllAPI bool has_locators() const
{
return !remote_locators_.unicast.empty() || !remote_locators_.multicast.empty();
@@ -459,6 +481,8 @@ class ReaderProxyData
//!GUID
GUID_t m_guid;
+ //!Network configuration
+ NetworkConfigSet_t m_networkConfiguration;
//!Holds locator information
RemoteLocatorList remote_locators_;
//!GUID_t of the Reader converted to InstanceHandle_t
diff --git a/include/fastdds/rtps/builtin/data/WriterProxyData.h b/include/fastdds/rtps/builtin/data/WriterProxyData.h
index 8c41d0256c4..651332283ef 100644
--- a/include/fastdds/rtps/builtin/data/WriterProxyData.h
+++ b/include/fastdds/rtps/builtin/data/WriterProxyData.h
@@ -87,6 +87,28 @@ class WriterProxyData
return m_guid;
}
+ RTPS_DllAPI void networkConfiguration(
+ const NetworkConfigSet_t& networkConfiguration)
+ {
+ m_networkConfiguration = networkConfiguration;
+ }
+
+ RTPS_DllAPI void networkConfiguration(
+ NetworkConfigSet_t&& networkConfiguration)
+ {
+ m_networkConfiguration = std::move(networkConfiguration);
+ }
+
+ RTPS_DllAPI const NetworkConfigSet_t& networkConfiguration() const
+ {
+ return m_networkConfiguration;
+ }
+
+ RTPS_DllAPI NetworkConfigSet_t& networkConfiguration()
+ {
+ return m_networkConfiguration;
+ }
+
RTPS_DllAPI void persistence_guid(
const GUID_t& guid)
{
@@ -440,6 +462,9 @@ class WriterProxyData
//!GUID
GUID_t m_guid;
+ //!Network configuration
+ NetworkConfigSet_t m_networkConfiguration;
+
//!Holds locator information
RemoteLocatorList remote_locators_;
diff --git a/include/fastdds/rtps/common/Types.h b/include/fastdds/rtps/common/Types.h
index c0ba598d14e..93282c8593c 100644
--- a/include/fastdds/rtps/common/Types.h
+++ b/include/fastdds/rtps/common/Types.h
@@ -88,6 +88,7 @@ using octet = unsigned char;
//typedef unsigned short ushort;
using SubmessageFlag = unsigned char;
using BuiltinEndpointSet_t = uint32_t;
+using NetworkConfigSet_t = uint32_t;
using Count_t = uint32_t;
#define BIT0 0x01u
diff --git a/include/fastdds/rtps/transport/ChainingTransport.h b/include/fastdds/rtps/transport/ChainingTransport.h
index 1793182b71b..eb69f65c1be 100644
--- a/include/fastdds/rtps/transport/ChainingTransport.h
+++ b/include/fastdds/rtps/transport/ChainingTransport.h
@@ -161,13 +161,12 @@ class ChainingTransport : public TransportInterface
}
/*!
- * Call the low-level transport `is_locator_allowed()`.
- * Must report whether the given locator is allowed by this transport.
+ * Call the low-level transport `is_localhost_allowed()`.
+ * Must report whether localhost locator is allowed
*/
- RTPS_DllAPI bool is_locator_allowed(
- const fastrtps::rtps::Locator_t& locator) const override
+ RTPS_DllAPI bool is_localhost_allowed() const override
{
- return low_level_transport_->is_locator_allowed(locator);
+ return low_level_transport_->is_localhost_allowed();
}
/*!
@@ -351,6 +350,29 @@ class ChainingTransport : public TransportInterface
low_level_transport_->update_network_interfaces();
}
+ //! Call the low-level transport `transform_remote_locator()`.
+ //! Transforms a remote locator into a locator optimized for local communications,
+ //! if allowed by both local and remote transports.
+ RTPS_DllAPI bool transform_remote_locator(
+ const fastrtps::rtps::Locator_t& remote_locator,
+ fastrtps::rtps::Locator_t& result_locator,
+ bool allowed_remote_localhost,
+ bool allowed_local_localhost) const override
+ {
+ return low_level_transport_->transform_remote_locator(remote_locator, result_locator, allowed_remote_localhost,
+ allowed_local_localhost);
+ }
+
+ /*!
+ * Call the low-level transport `is_locator_allowed()`.
+ * Must report whether the given locator is allowed by this transport.
+ */
+ RTPS_DllAPI bool is_locator_allowed(
+ const fastrtps::rtps::Locator_t& locator) const override
+ {
+ return low_level_transport_->is_locator_allowed(locator);
+ }
+
protected:
std::unique_ptr low_level_transport_;
diff --git a/include/fastdds/rtps/transport/TransportInterface.h b/include/fastdds/rtps/transport/TransportInterface.h
index 12209191011..60dec2d299f 100644
--- a/include/fastdds/rtps/transport/TransportInterface.h
+++ b/include/fastdds/rtps/transport/TransportInterface.h
@@ -22,9 +22,9 @@
#include
#include
#include
+#include
#include
#include
-#include
namespace eprosima {
namespace fastdds {
@@ -246,6 +246,36 @@ class RTPS_DllAPI TransportInterface
return transport_kind_;
}
+ /**
+ * Transforms a remote locator into a locator optimized for local communications.
+ *
+ * If the remote locator corresponds to one of the local interfaces, it is converted
+ * to the corresponding local address if allowed by both local and remote transports.
+ *
+ * @param [in] remote_locator Locator to be converted.
+ * @param [out] result_locator Converted locator.
+ * @param [in] allowed_remote_localhost Whether localhost is allowed (and hence used) in the remote transport.
+ * @param [in] allowed_local_localhost Whether localhost is allowed locally (by this or other transport).
+ *
+ * @return false if the input locator is not supported/allowed by this transport, true otherwise.
+ */
+ virtual bool transform_remote_locator(
+ const Locator& remote_locator,
+ Locator& result_locator,
+ bool allowed_remote_localhost,
+ bool allowed_local_localhost) const
+ {
+ static_cast(allowed_remote_localhost);
+ static_cast(allowed_local_localhost);
+ return transform_remote_locator(remote_locator, result_locator);
+ }
+
+ //! Must report whether localhost locator is allowed
+ virtual bool is_localhost_allowed() const
+ {
+ return true;
+ }
+
protected:
TransportInterface(
diff --git a/include/fastrtps/qos/ParameterTypes.h b/include/fastrtps/qos/ParameterTypes.h
index b0cc322ff70..cdcf8d333c9 100644
--- a/include/fastrtps/qos/ParameterTypes.h
+++ b/include/fastrtps/qos/ParameterTypes.h
@@ -30,7 +30,7 @@
#if HAVE_SECURITY
#include
#include
-#endif
+#endif // if HAVE_SECURITY
#include
#include
@@ -54,16 +54,17 @@ using ParameterCount_t = fastdds::dds::ParameterCount_t;
using ParameterEntityId_t = fastdds::dds::ParameterEntityId_t;
using ParameterTime_t = fastdds::dds::ParameterTime_t;
using ParameterBuiltinEndpointSet_t = fastdds::dds::ParameterBuiltinEndpointSet_t;
+using ParameterNetworkConfigSet_t = fastdds::dds::ParameterNetworkConfigSet_t;
using ParameterPropertyList_t = fastdds::dds::ParameterPropertyList_t;
using ParameterSampleIdentity_t = fastdds::dds::ParameterSampleIdentity_t;
#if HAVE_SECURITY
using ParameterToken_t = fastdds::dds::ParameterToken_t;
using ParameterParticipantSecurityInfo_t = fastdds::dds::ParameterParticipantSecurityInfo_t;
using ParameterEndpointSecurityInfo_t = fastdds::dds::ParameterEndpointSecurityInfo_t;
-#endif
+#endif // if HAVE_SECURITY
} //end of namespace
} //end of namespace eprosima
-#endif
+#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#endif /* PARAMETERTYPES_H_ */
diff --git a/src/cpp/fastdds/core/policy/ParameterSerializer.hpp b/src/cpp/fastdds/core/policy/ParameterSerializer.hpp
index 5bc485917dd..606749c2c16 100644
--- a/src/cpp/fastdds/core/policy/ParameterSerializer.hpp
+++ b/src/cpp/fastdds/core/policy/ParameterSerializer.hpp
@@ -612,6 +612,28 @@ inline bool ParameterSerializer::read_content_fro
return fastrtps::rtps::CDRMessage::readUInt32(cdr_message, ¶meter.endpointSet);
}
+template<>
+inline bool ParameterSerializer::add_content_to_cdr_message(
+ const ParameterNetworkConfigSet_t& parameter,
+ fastrtps::rtps::CDRMessage_t* cdr_message)
+{
+ return fastrtps::rtps::CDRMessage::addUInt32(cdr_message, parameter.netconfigSet);
+}
+
+template<>
+inline bool ParameterSerializer::read_content_from_cdr_message(
+ ParameterNetworkConfigSet_t& parameter,
+ fastrtps::rtps::CDRMessage_t* cdr_message,
+ const uint16_t parameter_length)
+{
+ if (parameter_length != PARAMETER_NETWORKCONFIGSET_LENGTH)
+ {
+ return false;
+ }
+ parameter.length = parameter_length;
+ return fastrtps::rtps::CDRMessage::readUInt32(cdr_message, ¶meter.netconfigSet);
+}
+
template<>
inline uint32_t ParameterSerializer::cdr_serialized_size(
const ParameterPropertyList_t& parameter)
diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp
index 7be131a0222..b703685cda8 100644
--- a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp
+++ b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp
@@ -2240,6 +2240,8 @@ bool DomainParticipantImpl::can_qos_be_updated(
from.wire_protocol().builtin.typelookup_config.use_client) ||
!(to.wire_protocol().builtin.typelookup_config.use_server ==
from.wire_protocol().builtin.typelookup_config.use_server) ||
+ !(to.wire_protocol().builtin.network_configuration ==
+ from.wire_protocol().builtin.network_configuration) ||
!(to.wire_protocol().builtin.metatrafficUnicastLocatorList ==
from.wire_protocol().builtin.metatrafficUnicastLocatorList) ||
!(to.wire_protocol().builtin.metatrafficMulticastLocatorList ==
diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.cpp b/src/cpp/rtps/builtin/BuiltinProtocols.cpp
index 415ac001ae3..cd1406a9184 100644
--- a/src/cpp/rtps/builtin/BuiltinProtocols.cpp
+++ b/src/cpp/rtps/builtin/BuiltinProtocols.cpp
@@ -85,7 +85,7 @@ bool BuiltinProtocols::initBuiltinProtocols(
m_DiscoveryServers = m_att.discovery_config.m_DiscoveryServers;
}
- transform_server_remote_locators(p_part->network_factory());
+ filter_server_remote_locators(p_part->network_factory());
const RTPSParticipantAllocationAttributes& allocation = p_part->getRTPSParticipantAttributes().allocation;
@@ -169,21 +169,26 @@ bool BuiltinProtocols::updateMetatrafficLocators(
return true;
}
-void BuiltinProtocols::transform_server_remote_locators(
+void BuiltinProtocols::filter_server_remote_locators(
NetworkFactory& nf)
{
eprosima::shared_lock disc_lock(getDiscoveryMutex());
for (eprosima::fastdds::rtps::RemoteServerAttributes& rs : m_DiscoveryServers)
{
+ LocatorList_t allowed_locators;
for (Locator_t& loc : rs.metatrafficUnicastLocatorList)
{
- Locator_t localized;
- if (nf.transform_remote_locator(loc, localized))
+ if (nf.is_locator_allowed(loc))
{
- loc = localized;
+ allowed_locators.push_back(loc);
+ }
+ else
+ {
+ EPROSIMA_LOG_WARNING(RTPS_PDP, "Ignoring remote server locator " << loc << " : not allowed.");
}
}
+ rs.metatrafficUnicastLocatorList.swap(allowed_locators);
}
}
diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp
index a5cefd53f63..bb46ad5403b 100644
--- a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp
+++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp
@@ -51,6 +51,7 @@ ParticipantProxyData::ParticipantProxyData(
, m_VendorId(c_VendorId_Unknown)
, m_expectsInlineQos(false)
, m_availableBuiltinEndpoints(0)
+ , m_networkConfiguration(0)
, metatraffic_locators(allocation.locators.max_unicast_locators, allocation.locators.max_multicast_locators)
, default_locators(allocation.locators.max_unicast_locators, allocation.locators.max_multicast_locators)
, m_manualLivelinessCount ()
@@ -75,6 +76,7 @@ ParticipantProxyData::ParticipantProxyData(
, m_VendorId(pdata.m_VendorId)
, m_expectsInlineQos(pdata.m_expectsInlineQos)
, m_availableBuiltinEndpoints(pdata.m_availableBuiltinEndpoints)
+ , m_networkConfiguration(pdata.m_networkConfiguration)
, metatraffic_locators(pdata.metatraffic_locators)
, default_locators(pdata.default_locators)
, m_manualLivelinessCount ()
@@ -153,6 +155,9 @@ uint32_t ParticipantProxyData::get_serialized_size(
// PID_PARTICIPANT_GUID
ret_val += 4 + PARAMETER_GUID_LENGTH;
+ // PID_NETWORK_CONFIGURATION_SET
+ ret_val += 4 + PARAMETER_NETWORKCONFIGSET_LENGTH;
+
// PID_METATRAFFIC_MULTICAST_LOCATOR
ret_val += static_cast((4 + PARAMETER_LOCATOR_LENGTH) * metatraffic_locators.multicast.size());
@@ -257,6 +262,14 @@ bool ParticipantProxyData::writeToCDRMessage(
return false;
}
}
+ {
+ ParameterNetworkConfigSet_t p(fastdds::dds::PID_NETWORK_CONFIGURATION_SET, PARAMETER_NETWORKCONFIGSET_LENGTH);
+ p.netconfigSet = m_networkConfiguration;
+ 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, it);
@@ -446,6 +459,18 @@ bool ParticipantProxyData::readFromCDRMessage(
m_key = p.guid;
break;
}
+ case fastdds::dds::PID_NETWORK_CONFIGURATION_SET:
+ {
+ ParameterNetworkConfigSet_t p(pid, plength);
+ if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p,
+ msg, plength))
+ {
+ return false;
+ }
+
+ m_networkConfiguration = p.netconfigSet;
+ break;
+ }
case fastdds::dds::PID_METATRAFFIC_MULTICAST_LOCATOR:
{
ParameterLocator_t p(pid, plength);
@@ -456,7 +481,7 @@ bool ParticipantProxyData::readFromCDRMessage(
}
Locator_t temp_locator;
- if (network.transform_remote_locator(p.locator, temp_locator))
+ if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration))
{
ProxyDataFilters::filter_locators(
is_shm_transport_available,
@@ -476,7 +501,7 @@ bool ParticipantProxyData::readFromCDRMessage(
}
Locator_t temp_locator;
- if (network.transform_remote_locator(p.locator, temp_locator))
+ if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration))
{
ProxyDataFilters::filter_locators(
is_shm_transport_available,
@@ -496,7 +521,7 @@ bool ParticipantProxyData::readFromCDRMessage(
}
Locator_t temp_locator;
- if (network.transform_remote_locator(p.locator, temp_locator))
+ if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration))
{
ProxyDataFilters::filter_locators(
is_shm_transport_available,
@@ -516,7 +541,7 @@ bool ParticipantProxyData::readFromCDRMessage(
}
Locator_t temp_locator;
- if (network.transform_remote_locator(p.locator, temp_locator))
+ if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration))
{
ProxyDataFilters::filter_locators(
is_shm_transport_available,
@@ -664,6 +689,7 @@ void ParticipantProxyData::clear()
m_VendorId = c_VendorId_Unknown;
m_expectsInlineQos = false;
m_availableBuiltinEndpoints = 0;
+ m_networkConfiguration = 0;
metatraffic_locators.unicast.clear();
metatraffic_locators.multicast.clear();
default_locators.unicast.clear();
@@ -693,6 +719,7 @@ void ParticipantProxyData::copy(
m_VendorId[0] = pdata.m_VendorId[0];
m_VendorId[1] = pdata.m_VendorId[1];
m_availableBuiltinEndpoints = pdata.m_availableBuiltinEndpoints;
+ m_networkConfiguration = pdata.m_networkConfiguration;
metatraffic_locators = pdata.metatraffic_locators;
default_locators = pdata.default_locators;
m_participantName = pdata.m_participantName;
diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp
index a10803d0d91..aa113a18380 100644
--- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp
+++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp
@@ -45,6 +45,7 @@ ReaderProxyData::ReaderProxyData (
, security_attributes_(0UL)
, plugin_security_attributes_(0UL)
#endif // if HAVE_SECURITY
+ , m_networkConfiguration(0)
, remote_locators_(max_unicast_locators, max_multicast_locators)
, m_userDefinedId(0)
, m_isAlive(true)
@@ -89,6 +90,7 @@ ReaderProxyData::ReaderProxyData(
, plugin_security_attributes_(readerInfo.plugin_security_attributes_)
#endif // if HAVE_SECURITY
, m_guid(readerInfo.m_guid)
+ , m_networkConfiguration(readerInfo.m_networkConfiguration)
, remote_locators_(readerInfo.remote_locators_)
, m_key(readerInfo.m_key)
, m_RTPSParticipantKey(readerInfo.m_RTPSParticipantKey)
@@ -130,6 +132,7 @@ ReaderProxyData& ReaderProxyData::operator =(
plugin_security_attributes_ = readerInfo.plugin_security_attributes_;
#endif // if HAVE_SECURITY
m_guid = readerInfo.m_guid;
+ m_networkConfiguration = readerInfo.m_networkConfiguration;
remote_locators_ = readerInfo.remote_locators_;
m_key = readerInfo.m_key;
m_RTPSParticipantKey = readerInfo.m_RTPSParticipantKey;
@@ -181,6 +184,9 @@ uint32_t ReaderProxyData::get_serialized_size(
{
uint32_t ret_val = include_encapsulation ? 4 : 0;
+ // PID_NETWORK_CONFIGURATION_SET
+ ret_val += 4 + PARAMETER_NETWORKCONFIGSET_LENGTH;
+
// PID_UNICAST_LOCATOR
ret_val += static_cast((4 + PARAMETER_LOCATOR_LENGTH) * remote_locators_.unicast.size());
@@ -342,6 +348,15 @@ bool ReaderProxyData::writeToCDRMessage(
}
}
+ {
+ ParameterNetworkConfigSet_t p(fastdds::dds::PID_NETWORK_CONFIGURATION_SET, PARAMETER_NETWORKCONFIGSET_LENGTH);
+ p.netconfigSet = m_networkConfiguration;
+ if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(p, msg))
+ {
+ return false;
+ }
+ }
+
for (const Locator_t& locator : remote_locators_.unicast)
{
ParameterLocator_t p(fastdds::dds::PID_UNICAST_LOCATOR, PARAMETER_LOCATOR_LENGTH, locator);
@@ -821,6 +836,18 @@ bool ReaderProxyData::readFromCDRMessage(
m_key = p.guid;
break;
}
+ case fastdds::dds::PID_NETWORK_CONFIGURATION_SET:
+ {
+ ParameterNetworkConfigSet_t p(pid, plength);
+ if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p,
+ msg, plength))
+ {
+ return false;
+ }
+
+ m_networkConfiguration = p.netconfigSet;
+ break;
+ }
case fastdds::dds::PID_UNICAST_LOCATOR:
{
ParameterLocator_t p(pid, plength);
@@ -831,7 +858,7 @@ bool ReaderProxyData::readFromCDRMessage(
}
Locator_t temp_locator;
- if (network.transform_remote_locator(p.locator, temp_locator))
+ if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration))
{
ProxyDataFilters::filter_locators(
is_shm_transport_available,
@@ -851,7 +878,7 @@ bool ReaderProxyData::readFromCDRMessage(
}
Locator_t temp_locator;
- if (network.transform_remote_locator(p.locator, temp_locator))
+ if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration))
{
ProxyDataFilters::filter_locators(
is_shm_transport_available,
@@ -1042,6 +1069,7 @@ void ReaderProxyData::clear()
plugin_security_attributes_ = 0UL;
#endif // if HAVE_SECURITY
m_guid = c_Guid_Unknown;
+ m_networkConfiguration = 0;
remote_locators_.unicast.clear();
remote_locators_.multicast.clear();
m_key = InstanceHandle_t();
@@ -1105,6 +1133,7 @@ void ReaderProxyData::copy(
ReaderProxyData* rdata)
{
m_guid = rdata->m_guid;
+ m_networkConfiguration = rdata->m_networkConfiguration;
remote_locators_ = rdata->remote_locators_;
m_key = rdata->m_key;
m_RTPSParticipantKey = rdata->m_RTPSParticipantKey;
@@ -1169,13 +1198,12 @@ void ReaderProxyData::set_remote_unicast_locators(
const LocatorList_t& locators,
const NetworkFactory& network)
{
- Locator_t local_locator;
remote_locators_.unicast.clear();
for (const Locator_t& locator : locators)
{
- if (network.transform_remote_locator(locator, local_locator))
+ if (network.is_locator_allowed(locator))
{
- remote_locators_.add_unicast_locator(local_locator);
+ remote_locators_.add_unicast_locator(locator);
}
}
}
@@ -1190,11 +1218,10 @@ void ReaderProxyData::set_multicast_locators(
const LocatorList_t& locators,
const NetworkFactory& network)
{
- Locator_t local_locator;
remote_locators_.multicast.clear();
for (const Locator_t& locator : locators)
{
- if (network.transform_remote_locator(locator, local_locator))
+ if (network.is_locator_allowed(locator))
{
remote_locators_.add_multicast_locator(locator);
}
@@ -1212,15 +1239,14 @@ void ReaderProxyData::set_remote_locators(
const NetworkFactory& network,
bool use_multicast_locators)
{
- Locator_t local_locator;
remote_locators_.unicast.clear();
remote_locators_.multicast.clear();
for (const Locator_t& locator : locators.unicast)
{
- if (network.transform_remote_locator(locator, local_locator))
+ if (network.is_locator_allowed(locator))
{
- remote_locators_.add_unicast_locator(local_locator);
+ remote_locators_.add_unicast_locator(locator);
}
}
@@ -1228,7 +1254,7 @@ void ReaderProxyData::set_remote_locators(
{
for (const Locator_t& locator : locators.multicast)
{
- if (network.transform_remote_locator(locator, local_locator))
+ if (network.is_locator_allowed(locator))
{
remote_locators_.add_multicast_locator(locator);
}
diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp
index 8127d9cf16d..e2a33a111f7 100644
--- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp
+++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp
@@ -39,10 +39,11 @@ WriterProxyData::WriterProxyData(
#if HAVE_SECURITY
: security_attributes_(0)
, plugin_security_attributes_(0)
- , remote_locators_(max_unicast_locators, max_multicast_locators)
+ , m_networkConfiguration(0)
#else
- : remote_locators_(max_unicast_locators, max_multicast_locators)
+ : m_networkConfiguration(0)
#endif // if HAVE_SECURITY
+ , remote_locators_(max_unicast_locators, max_multicast_locators)
, m_userDefinedId(0)
, m_typeMaxSerialized(0)
, m_topicKind(NO_KEY)
@@ -73,6 +74,7 @@ WriterProxyData::WriterProxyData(
#else
: m_guid(writerInfo.m_guid)
#endif // if HAVE_SECURITY
+ , m_networkConfiguration(writerInfo.m_networkConfiguration)
, remote_locators_(writerInfo.remote_locators_)
, m_key(writerInfo.m_key)
, m_RTPSParticipantKey(writerInfo.m_RTPSParticipantKey)
@@ -122,6 +124,7 @@ WriterProxyData& WriterProxyData::operator =(
plugin_security_attributes_ = writerInfo.plugin_security_attributes_;
#endif // if HAVE_SECURITY
m_guid = writerInfo.m_guid;
+ m_networkConfiguration = writerInfo.m_networkConfiguration;
remote_locators_ = writerInfo.remote_locators_;
m_key = writerInfo.m_key;
m_RTPSParticipantKey = writerInfo.m_RTPSParticipantKey;
@@ -172,6 +175,9 @@ uint32_t WriterProxyData::get_serialized_size(
{
uint32_t ret_val = include_encapsulation ? 4 : 0;
+ // PID_NETWORK_CONFIGURATION_SET
+ ret_val += 4 + PARAMETER_NETWORKCONFIGSET_LENGTH;
+
// PID_UNICAST_LOCATOR
ret_val += static_cast((4 + PARAMETER_LOCATOR_LENGTH) * remote_locators_.unicast.size());
@@ -331,6 +337,15 @@ bool WriterProxyData::writeToCDRMessage(
}
}
+ {
+ ParameterNetworkConfigSet_t p(fastdds::dds::PID_NETWORK_CONFIGURATION_SET, PARAMETER_NETWORKCONFIGSET_LENGTH);
+ p.netconfigSet = m_networkConfiguration;
+ if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(p, msg))
+ {
+ return false;
+ }
+ }
+
for (const Locator_t& locator : remote_locators_.unicast)
{
ParameterLocator_t p(fastdds::dds::PID_UNICAST_LOCATOR, PARAMETER_LOCATOR_LENGTH, locator);
@@ -825,6 +840,18 @@ bool WriterProxyData::readFromCDRMessage(
persistence_guid_ = p.guid;
break;
}
+ case fastdds::dds::PID_NETWORK_CONFIGURATION_SET:
+ {
+ ParameterNetworkConfigSet_t p(pid, plength);
+ if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p,
+ msg, plength))
+ {
+ return false;
+ }
+
+ m_networkConfiguration = p.netconfigSet;
+ break;
+ }
case fastdds::dds::PID_UNICAST_LOCATOR:
{
ParameterLocator_t p(pid, plength);
@@ -835,7 +862,7 @@ bool WriterProxyData::readFromCDRMessage(
}
Locator_t temp_locator;
- if (network.transform_remote_locator(p.locator, temp_locator))
+ if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration))
{
ProxyDataFilters::filter_locators(
is_shm_transport_available,
@@ -855,7 +882,7 @@ bool WriterProxyData::readFromCDRMessage(
}
Locator_t temp_locator;
- if (network.transform_remote_locator(p.locator, temp_locator))
+ if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration))
{
ProxyDataFilters::filter_locators(
is_shm_transport_available,
@@ -1019,6 +1046,7 @@ void WriterProxyData::clear()
plugin_security_attributes_ = 0UL;
#endif // if HAVE_SECURITY
m_guid = c_Guid_Unknown;
+ m_networkConfiguration = 0;
remote_locators_.unicast.clear();
remote_locators_.multicast.clear();
m_key = InstanceHandle_t();
@@ -1051,6 +1079,7 @@ void WriterProxyData::copy(
WriterProxyData* wdata)
{
m_guid = wdata->m_guid;
+ m_networkConfiguration = wdata->m_networkConfiguration;
remote_locators_ = wdata->remote_locators_;
m_key = wdata->m_key;
m_RTPSParticipantKey = wdata->m_RTPSParticipantKey;
@@ -1115,6 +1144,7 @@ bool WriterProxyData::is_update_allowed(
void WriterProxyData::update(
WriterProxyData* wdata)
{
+ // m_networkConfiguration = wdata->m_networkConfiguration; // TODO: update?
remote_locators_ = wdata->remote_locators_;
m_qos.setQos(wdata->m_qos, false);
}
@@ -1139,13 +1169,12 @@ void WriterProxyData::set_remote_unicast_locators(
const LocatorList_t& locators,
const NetworkFactory& network)
{
- Locator_t local_locator;
remote_locators_.unicast.clear();
for (const Locator_t& locator : locators)
{
- if (network.transform_remote_locator(locator, local_locator))
+ if (network.is_locator_allowed(locator))
{
- remote_locators_.add_unicast_locator(local_locator);
+ remote_locators_.add_unicast_locator(locator);
}
}
}
@@ -1160,11 +1189,10 @@ void WriterProxyData::set_multicast_locators(
const LocatorList_t& locators,
const NetworkFactory& network)
{
- Locator_t local_locator;
remote_locators_.multicast.clear();
for (const Locator_t& locator : locators)
{
- if (network.transform_remote_locator(locator, local_locator))
+ if (network.is_locator_allowed(locator))
{
remote_locators_.add_multicast_locator(locator);
}
@@ -1182,15 +1210,14 @@ void WriterProxyData::set_remote_locators(
const NetworkFactory& network,
bool use_multicast_locators)
{
- Locator_t local_locator;
remote_locators_.unicast.clear();
remote_locators_.multicast.clear();
for (const Locator_t& locator : locators.unicast)
{
- if (network.transform_remote_locator(locator, local_locator))
+ if (network.is_locator_allowed(locator))
{
- remote_locators_.add_unicast_locator(local_locator);
+ remote_locators_.add_unicast_locator(locator);
}
}
@@ -1198,7 +1225,7 @@ void WriterProxyData::set_remote_locators(
{
for (const Locator_t& locator : locators.multicast)
{
- if (network.transform_remote_locator(locator, local_locator))
+ if (network.is_locator_allowed(locator))
{
remote_locators_.add_multicast_locator(locator);
}
diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp
index d5efa9db354..209151ea882 100644
--- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp
+++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp
@@ -285,6 +285,8 @@ void PDP::initializeParticipantProxyData(
if (announce_locators)
{
+ participant_data->m_networkConfiguration = attributes.builtin.network_configuration;
+
for (const Locator_t& loc : attributes.defaultUnicastLocatorList)
{
participant_data->default_locators.add_unicast_locator(loc);
@@ -839,6 +841,9 @@ ReaderProxyData* PDP::addReaderProxyData(
reader_proxies_pool_.pop_back();
}
+ // Copy network configuration from participant to reader proxy
+ ret_val->networkConfiguration(pit->m_networkConfiguration);
+
// Add to ParticipantProxyData
(*pit->m_readers)[reader_guid.entityId] = ret_val;
@@ -934,6 +939,9 @@ WriterProxyData* PDP::addWriterProxyData(
writer_proxies_pool_.pop_back();
}
+ // Copy network configuration from participant to writer proxy
+ ret_val->networkConfiguration(pit->m_networkConfiguration);
+
// Add to ParticipantProxyData
(*pit->m_writers)[writer_guid.entityId] = ret_val;
diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp
index 8868acb4298..fb2a5bfffba 100644
--- a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp
+++ b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp
@@ -16,40 +16,35 @@
* @file PDPSimple.cpp
*
*/
-
#include
-#include
-#include
-#include
-#include
+
+#include
+
+#include
+#include
#include
-#include
+#include
#include
#include
#include
-
+#include
+#include
+#include
+#include
+#include
+#include
#include
-#include
-
-#include
#include
-
-#include
-#include
-
-#include
-
-#include
+#include
+#include
+#include
#include
+#include
#include
#include
#include
-#include
-
-#include
-
using namespace eprosima::fastrtps;
namespace eprosima {
@@ -350,12 +345,47 @@ bool PDPSimple::createPDPEndpoints()
{
const NetworkFactory& network = mp_RTPSParticipant->network_factory();
LocatorList_t fixed_locators;
- Locator_t local_locator;
for (const Locator_t& loc : mp_builtin->m_initialPeersList)
{
- if (network.transform_remote_locator(loc, local_locator))
+ if (network.is_locator_allowed(loc))
+ {
+ // Add initial peers locator without transformation as we don't know whether the
+ // remote transport will allow localhost
+ fixed_locators.push_back(loc);
+
+ /**
+ * TCP special case:
+ *
+ * In TCP, it is not possible to open a socket with 'any' (0.0.0.0) address as it's done
+ * in UDP, so when the TCP transports receive a locator with 'any', they open an input
+ * channel for the specified port in each of the machine interfaces (with the exception
+ * of localhost). In fact, a participant with a TCP transport will only listen on localhost
+ * if localhost is the address of any of the initial peers.
+ *
+ * However, when the TCP enabled participant does not have a whitelist (or localhost is in
+ * it), it allows for transformation of its locators to localhost for performance optimizations.
+ * In this case, the remote TCP participant it will send data using a socket in localhost,
+ * and for that the participant with the initial peers list needs to be listening there
+ * to receive it.
+ *
+ * That means:
+ * 1. Checking that the initial peer is not already localhost
+ * 2. Checking that the initial peer locator is of TCP kind
+ * 3. Checking that the network configuration allows for localhost locators
+ */
+ Locator_t local_locator;
+ network.transform_remote_locator(loc, local_locator,
+ DISC_NETWORK_CONFIGURATION_LISTENING_LOCALHOST_ALL);
+ if (loc != local_locator
+ && (loc.kind == LOCATOR_KIND_TCPv4 || loc.kind == LOCATOR_KIND_TCPv6)
+ && network.is_locator_allowed(local_locator))
+ {
+ fixed_locators.push_back(local_locator);
+ }
+ }
+ else
{
- fixed_locators.push_back(local_locator);
+ EPROSIMA_LOG_WARNING(RTPS_PDP, "Ignoring initial peers locator " << loc << " : not allowed.");
}
}
endpoints->writer.writer_->set_fixed_locators(fixed_locators);
diff --git a/src/cpp/rtps/network/NetworkFactory.cpp b/src/cpp/rtps/network/NetworkFactory.cpp
index 6a46faa8283..a3b70b1aa8f 100644
--- a/src/cpp/rtps/network/NetworkFactory.cpp
+++ b/src/cpp/rtps/network/NetworkFactory.cpp
@@ -38,6 +38,7 @@ NetworkFactory::NetworkFactory(
const RTPSParticipantAttributes& PParam)
: maxMessageSizeBetweenTransports_(std::numeric_limits::max())
, minSendBufferSize_(std::numeric_limits::max())
+ , network_configuration_(0)
{
const std::string* enforce_metatraffic = nullptr;
enforce_metatraffic = PropertyPolicyHelper::find_property(PParam.properties, "fastdds.shm.enforce_metatraffic");
@@ -126,6 +127,9 @@ bool NetworkFactory::RegisterTransport(
if (transport)
{
+ int32_t kind = transport->kind();
+ bool is_localhost_allowed = transport->is_localhost_allowed();
+
if (transport->init(properties))
{
minSendBufferSize = transport->get_configuration()->min_send_buffer_size();
@@ -144,6 +148,11 @@ bool NetworkFactory::RegisterTransport(
{
minSendBufferSize_ = minSendBufferSize;
}
+
+ if (is_localhost_allowed)
+ {
+ network_configuration_ |= kind;
+ }
}
}
@@ -182,11 +191,27 @@ void NetworkFactory::NormalizeLocators(
bool NetworkFactory::transform_remote_locator(
const Locator_t& remote_locator,
- Locator_t& result_locator) const
+ Locator_t& result_locator,
+ const NetworkConfigSet_t& remote_network_config) const
+{
+ for (auto& transport : mRegisteredTransports)
+ {
+ if (transport->transform_remote_locator(remote_locator, result_locator,
+ remote_network_config & remote_locator.kind, network_configuration_ & remote_locator.kind))
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool NetworkFactory::is_locator_allowed(
+ const Locator_t& locator) const
{
for (auto& transport : mRegisteredTransports)
{
- if (transport->transform_remote_locator(remote_locator, result_locator))
+ if (transport->is_locator_allowed(locator))
{
return true;
}
diff --git a/src/cpp/rtps/network/NetworkFactory.h b/src/cpp/rtps/network/NetworkFactory.h
index ade996764b7..8b4d698a967 100644
--- a/src/cpp/rtps/network/NetworkFactory.h
+++ b/src/cpp/rtps/network/NetworkFactory.h
@@ -99,17 +99,30 @@ class NetworkFactory
* Transform a remote locator into a locator optimized for local communications.
*
* If the remote locator corresponds to one of the local interfaces, it is converted
- * to the corresponding local address.
+ * to the corresponding local address if allowed by both local and remote transports.
*
* @param [in] remote_locator Locator to be converted.
* @param [out] result_locator Converted locator.
+ * @param [in] remote_network_config Remote network configuration.
*
* @return false if the input locator is not supported/allowed by any of the registered transports,
* true otherwise.
*/
bool transform_remote_locator(
const Locator_t& remote_locator,
- Locator_t& result_locator) const;
+ Locator_t& result_locator,
+ const NetworkConfigSet_t& remote_network_config) const;
+
+ /**
+ * Must report whether the given locator is allowed by at least one of the registered transports.
+ *
+ * @param [in] locator Locator to check if allowed.
+ *
+ * @return false if the input locator is not supported/allowed by any of the registered transports,
+ * true otherwise.
+ */
+ bool is_locator_allowed(
+ const Locator_t& locator) const;
/**
* Perform the locator selection algorithm.
@@ -138,6 +151,11 @@ class NetworkFactory
return minSendBufferSize_;
}
+ NetworkConfigSet_t network_configuration() const
+ {
+ return network_configuration_;
+ }
+
/**
* Fill ret_locators with the list of all possible locators in the local machine at the given
* physical_port of the locator_kind.
@@ -231,6 +249,9 @@ class NetworkFactory
// Whether multicast metatraffic on SHM transport should always be used
bool enforce_shm_multicast_metatraffic_ = false;
+ // Mask using transport kinds to indicate whether the transports allows localhost
+ NetworkConfigSet_t network_configuration_;
+
/**
* Calculate well-known ports.
*/
diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp
index 0e801116bc8..c322f027d0e 100644
--- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp
+++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp
@@ -417,6 +417,10 @@ RTPSParticipantImpl::RTPSParticipantImpl(
}
#endif // if HAVE_SECURITY
+ // Copy NetworkFactory network_configuration to participant attributes prior to proxy creation
+ // NOTE: all transports already registered before
+ m_att.builtin.network_configuration = m_network_Factory.network_configuration();
+
mp_builtinProtocols = new BuiltinProtocols();
// Initialize builtin protocols
diff --git a/src/cpp/rtps/transport/TCPAcceptor.cpp b/src/cpp/rtps/transport/TCPAcceptor.cpp
index 1531af4b6e5..d4c2ba32552 100644
--- a/src/cpp/rtps/transport/TCPAcceptor.cpp
+++ b/src/cpp/rtps/transport/TCPAcceptor.cpp
@@ -38,12 +38,12 @@ TCPAcceptor::TCPAcceptor(
asio::io_service& io_service,
const std::string& interface,
const Locator& locator)
- : acceptor_(io_service, asio::ip::tcp::endpoint(asio::ip::address_v4::from_string(interface),
+ : acceptor_(io_service, asio::ip::tcp::endpoint(asio::ip::address::from_string(interface),
IPLocator::getPhysicalPort(locator)))
, locator_(locator)
, io_service_(&io_service)
{
- endpoint_ = asio::ip::tcp::endpoint(asio::ip::address_v4::from_string(interface),
+ endpoint_ = asio::ip::tcp::endpoint(asio::ip::address::from_string(interface),
IPLocator::getPhysicalPort(locator_));
}
diff --git a/src/cpp/rtps/transport/TCPAcceptorBasic.cpp b/src/cpp/rtps/transport/TCPAcceptorBasic.cpp
index dff8b3bbca2..45e03d108af 100644
--- a/src/cpp/rtps/transport/TCPAcceptorBasic.cpp
+++ b/src/cpp/rtps/transport/TCPAcceptorBasic.cpp
@@ -40,7 +40,7 @@ TCPAcceptorBasic::TCPAcceptorBasic(
: TCPAcceptor(io_service, interface, locator)
, socket_(*io_service_)
{
- endpoint_ = asio::ip::tcp::endpoint(asio::ip::address_v4::from_string(interface),
+ endpoint_ = asio::ip::tcp::endpoint(asio::ip::address::from_string(interface),
IPLocator::getPhysicalPort(locator_));
}
diff --git a/src/cpp/rtps/transport/TCPTransportInterface.cpp b/src/cpp/rtps/transport/TCPTransportInterface.cpp
index 334cff4c4dc..6ccf7a95042 100644
--- a/src/cpp/rtps/transport/TCPTransportInterface.cpp
+++ b/src/cpp/rtps/transport/TCPTransportInterface.cpp
@@ -501,40 +501,51 @@ Locator TCPTransportInterface::RemoteToMainLocal(
bool TCPTransportInterface::transform_remote_locator(
const Locator& remote_locator,
- Locator& result_locator) const
+ Locator& result_locator,
+ bool allowed_remote_localhost,
+ bool allowed_local_localhost) const
{
- if (!IsLocatorSupported(remote_locator))
+ if (IsLocatorSupported(remote_locator))
{
- // remote_locator not supported
- return false;
- }
-
- if (!is_local_locator(remote_locator))
- {
- // remote_locator is not local
result_locator = remote_locator;
- return true;
- }
+ if (!is_local_locator(result_locator))
+ {
+ // is_local_locator will return false for multicast addresses as well as remote unicast ones.
+ return true;
+ }
- if (!is_locator_allowed(remote_locator))
- {
- // remote_locator not in the whitelist
- return false;
- }
+ // If we get here, the locator is a local unicast address
+
+ // Attempt conversion to localhost if remote transport listening on it allows it
+ if (allowed_remote_localhost)
+ {
+ Locator loopbackLocator;
+ fill_local_ip(loopbackLocator);
+ if (is_locator_allowed(loopbackLocator))
+ {
+ // Locator localhost is in the whitelist, so use localhost instead of remote_locator
+ fill_local_ip(result_locator);
+ IPLocator::setPhysicalPort(result_locator, IPLocator::getPhysicalPort(remote_locator));
+ IPLocator::setLogicalPort(result_locator, IPLocator::getLogicalPort(remote_locator));
+ return true;
+ }
+ else if (allowed_local_localhost)
+ {
+ // Abort transformation if localhost not allowed by this transport, but it is by other local transport
+ // and the remote one.
+ return false;
+ }
+ }
+
+ if (!is_locator_allowed(result_locator))
+ {
+ // Neither original remote locator nor localhost allowed: abort.
+ return false;
+ }
- fill_local_ip(result_locator);
- if (is_locator_allowed(result_locator))
- {
- // Locator localhost is in the whitelist, so use localhost instead of remote_locator
- IPLocator::setPhysicalPort(result_locator, IPLocator::getPhysicalPort(remote_locator));
- IPLocator::setLogicalPort(result_locator, IPLocator::getLogicalPort(remote_locator));
return true;
}
-
- // remote_locator is allowed and local. Localhost is not allowed
- // Then, we can use remote_locator
- result_locator = remote_locator;
- return true;
+ return false;
}
void TCPTransportInterface::CloseOutputChannel(
@@ -1293,13 +1304,14 @@ void TCPTransportInterface::SocketAccepted(
channel->thread(std::thread(&TCPTransportInterface::perform_listen_operation, this,
channel_weak_ptr, rtcp_manager_weak_ptr));
- EPROSIMA_LOG_INFO(RTCP, " Accepted connection (local: " << IPLocator::to_string(locator)
- << ", remote: " << channel->remote_endpoint().address()
- << ":" << channel->remote_endpoint().port() << ")");
+ EPROSIMA_LOG_INFO(RTCP, "Accepted connection (local: "
+ << IPLocator::to_string(locator) << ", remote: "
+ << channel->remote_endpoint().address() << ":"
+ << channel->remote_endpoint().port() << ")");
}
else
{
- EPROSIMA_LOG_INFO(RTCP, " Accepting connection (" << error.message() << ")");
+ EPROSIMA_LOG_INFO(RTCP, "Accepting connection (" << error.message() << ")");
std::this_thread::sleep_for(std::chrono::milliseconds(200)); // Wait a little to accept again.
}
@@ -1700,6 +1712,13 @@ void TCPTransportInterface::update_network_interfaces()
// TODO(jlbueno)
}
+bool TCPTransportInterface::is_localhost_allowed() const
+{
+ Locator local_locator;
+ fill_local_ip(local_locator);
+ return is_locator_allowed(local_locator);
+}
+
} // namespace rtps
} // namespace fastrtps
} // namespace eprosima
diff --git a/src/cpp/rtps/transport/TCPTransportInterface.h b/src/cpp/rtps/transport/TCPTransportInterface.h
index 21569c7abff..f21f61b2e3f 100644
--- a/src/cpp/rtps/transport/TCPTransportInterface.h
+++ b/src/cpp/rtps/transport/TCPTransportInterface.h
@@ -293,16 +293,20 @@ class TCPTransportInterface : public TransportInterface
* Transforms a remote locator into a locator optimized for local communications.
*
* If the remote locator corresponds to one of the local interfaces, it is converted
- * to the corresponding local address.
+ * to the corresponding local address if allowed by both local and remote transports.
*
* @param [in] remote_locator Locator to be converted.
* @param [out] result_locator Converted locator.
+ * @param [in] allowed_remote_localhost Whether localhost is allowed (and hence used) in the remote transport.
+ * @param [in] allowed_local_localhost Whether localhost is allowed locally (by this or other transport).
*
* @return false if the input locator is not supported/allowed by this transport, true otherwise.
*/
bool transform_remote_locator(
const Locator& remote_locator,
- Locator& result_locator) const override;
+ Locator& result_locator,
+ bool allowed_remote_localhost,
+ bool allowed_local_localhost) const override;
/**
* Blocking Receive from the specified channel.
@@ -428,6 +432,8 @@ class TCPTransportInterface : public TransportInterface
void keep_alive();
void update_network_interfaces() override;
+
+ bool is_localhost_allowed() const override;
};
} // namespace rtps
diff --git a/src/cpp/rtps/transport/TCPv6Transport.cpp b/src/cpp/rtps/transport/TCPv6Transport.cpp
index d4abced247a..842dad6f13f 100644
--- a/src/cpp/rtps/transport/TCPv6Transport.cpp
+++ b/src/cpp/rtps/transport/TCPv6Transport.cpp
@@ -224,22 +224,39 @@ bool TCPv6Transport::is_interface_allowed(
return true;
}
- return find(interface_whitelist_.begin(), interface_whitelist_.end(), ip) != interface_whitelist_.end();
+ for (auto& whitelist : interface_whitelist_)
+ {
+ if (compare_ips(whitelist.to_string(), ip.to_string()))
+ {
+ return true;
+ }
+ }
+
+ return false;
}
LocatorList TCPv6Transport::NormalizeLocator(
const Locator& locator)
{
LocatorList list;
-
if (IPLocator::isAny(locator))
{
std::vector locNames;
get_ipv6s(locNames);
for (const auto& infoIP : locNames)
+ {
+ if (is_interface_allowed(infoIP.name))
+ {
+ Locator newloc(locator);
+ IPLocator::setIPv6(newloc, infoIP.locator);
+ list.push_back(newloc);
+ }
+ }
+
+ if (list.empty())
{
Locator newloc(locator);
- IPLocator::setIPv6(newloc, infoIP.locator);
+ IPLocator::setIPv6(newloc, "::1");
list.push_back(newloc);
}
}
@@ -349,6 +366,22 @@ void TCPv6Transport::endpoint_to_locator(
IPLocator::setIPv6(locator, ipBytes.data());
}
+bool TCPv6Transport::compare_ips(
+ const std::string& ip1,
+ const std::string& ip2) const
+{
+ // string::find returns string::npos if the character is not found
+ // If the second parameter is string::npos value, it indicates to take all characters until the end of the string
+ std::string substr1 = ip1.substr(0, ip1.find('%'));
+ std::string substr2 = ip2.substr(0, ip2.find('%'));
+
+ if (substr1.compare(substr2) == 0)
+ {
+ return true;
+ }
+ return false;
+}
+
} // namespace rtps
} // namespace fastrtps
} // namespace eprosima
diff --git a/src/cpp/rtps/transport/TCPv6Transport.h b/src/cpp/rtps/transport/TCPv6Transport.h
index 8565a3eb3c9..fa68307e0a0 100644
--- a/src/cpp/rtps/transport/TCPv6Transport.h
+++ b/src/cpp/rtps/transport/TCPv6Transport.h
@@ -121,6 +121,11 @@ class TCPv6Transport : public TCPTransportInterface
const asio::ip::tcp::endpoint& endpoint,
Locator& locator) const override;
+ //! Checks if the IP addresses are the same without taking into account the IPv6 scope
+ bool compare_ips(
+ const std::string& ip1,
+ const std::string& ip2) const;
+
public:
RTPS_DllAPI TCPv6Transport(
diff --git a/src/cpp/rtps/transport/UDPTransportInterface.cpp b/src/cpp/rtps/transport/UDPTransportInterface.cpp
index 7b9fe4acd10..19adeb1a91a 100644
--- a/src/cpp/rtps/transport/UDPTransportInterface.cpp
+++ b/src/cpp/rtps/transport/UDPTransportInterface.cpp
@@ -389,31 +389,44 @@ Locator UDPTransportInterface::RemoteToMainLocal(
bool UDPTransportInterface::transform_remote_locator(
const Locator& remote_locator,
- Locator& result_locator) const
+ Locator& result_locator,
+ bool allowed_remote_localhost,
+ bool allowed_local_localhost) const
{
if (IsLocatorSupported(remote_locator))
{
result_locator = remote_locator;
if (!is_local_locator(result_locator))
{
- // is_local_locator will return false for multicast addresses as well as
- // remote unicast ones.
+ // is_local_locator will return false for multicast addresses as well as remote unicast ones.
return true;
}
// If we get here, the locator is a local unicast address
- if (!is_locator_allowed(result_locator))
+
+ // Attempt conversion to localhost if remote transport listening on it allows it
+ if (allowed_remote_localhost)
{
- return false;
+ Locator loopbackLocator;
+ fill_local_ip(loopbackLocator);
+ if (is_locator_allowed(loopbackLocator))
+ {
+ // Locator localhost is in the whitelist, so use localhost instead of remote_locator
+ fill_local_ip(result_locator);
+ return true;
+ }
+ else if (allowed_local_localhost)
+ {
+ // Abort transformation if localhost not allowed by this transport, but it is by other local transport
+ // and the remote one.
+ return false;
+ }
}
- // The locator is in the whitelist (or the whitelist is empty)
- Locator loopbackLocator;
- fill_local_ip(loopbackLocator);
- if (is_locator_allowed(loopbackLocator))
+ if (!is_locator_allowed(result_locator))
{
- // Loopback locator
- fill_local_ip(result_locator);
+ // Neither original remote locator nor localhost allowed: abort.
+ return false;
}
return true;
@@ -719,6 +732,13 @@ void UDPTransportInterface::update_network_interfaces()
rescan_interfaces_.store(true);
}
+bool UDPTransportInterface::is_localhost_allowed() const
+{
+ Locator local_locator;
+ fill_local_ip(local_locator);
+ return is_locator_allowed(local_locator);
+}
+
} // namespace rtps
} // namespace fastrtps
} // namespace eprosima
diff --git a/src/cpp/rtps/transport/UDPTransportInterface.h b/src/cpp/rtps/transport/UDPTransportInterface.h
index 46adcc8b19a..d6f0645d11e 100644
--- a/src/cpp/rtps/transport/UDPTransportInterface.h
+++ b/src/cpp/rtps/transport/UDPTransportInterface.h
@@ -87,16 +87,20 @@ class UDPTransportInterface : public TransportInterface
* Transforms a remote locator into a locator optimized for local communications.
*
* If the remote locator corresponds to one of the local interfaces, it is converted
- * to the corresponding local address.
+ * to the corresponding local address if allowed by both local and remote transports.
*
* @param [in] remote_locator Locator to be converted.
* @param [out] result_locator Converted locator.
+ * @param [in] allowed_remote_localhost Whether localhost is allowed (and hence used) in the remote transport.
+ * @param [in] allowed_local_localhost Whether localhost is allowed locally (by this or other transport).
*
* @return false if the input locator is not supported/allowed by this transport, true otherwise.
*/
bool transform_remote_locator(
const Locator& remote_locator,
- Locator& result_locator) const override;
+ Locator& result_locator,
+ bool allowed_remote_localhost,
+ bool allowed_local_localhost) const override;
/**
* Blocking Send through the specified channel. In both modes, using a localLocator of 0.0.0.0 will
@@ -167,6 +171,8 @@ class UDPTransportInterface : public TransportInterface
void update_network_interfaces() override;
+ bool is_localhost_allowed() const override;
+
protected:
friend class UDPChannelResource;
diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp
index ea627dd1d2b..c138b88f88f 100644
--- a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp
+++ b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp
@@ -176,6 +176,11 @@ bool SharedMemTransport::is_local_locator(
return true;
}
+bool SharedMemTransport::is_localhost_allowed() const
+{
+ return true;
+}
+
void SharedMemTransport::delete_input_channel(
SharedMemChannelResource* channel)
{
@@ -392,7 +397,9 @@ Locator SharedMemTransport::RemoteToMainLocal(
bool SharedMemTransport::transform_remote_locator(
const Locator& remote_locator,
- Locator& result_locator) const
+ Locator& result_locator,
+ bool,
+ bool) const
{
if (IsLocatorSupported(remote_locator))
{
diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h
index 63f79172527..88f146a7d06 100644
--- a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h
+++ b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h
@@ -98,16 +98,20 @@ class SharedMemTransport : public TransportInterface
* Transforms a remote locator into a locator optimized for local communications.
*
* If the remote locator corresponds to one of the local interfaces, it is converted
- * to the corresponding local address.
+ * to the corresponding local address if allowed by both local and remote transports.
*
* @param [in] remote_locator Locator to be converted.
* @param [out] result_locator Converted locator.
+ * @param [in] allowed_remote_localhost Whether localhost is allowed (and hence used) in the remote transport.
+ * @param [in] allowed_local_localhost Whether localhost is allowed locally (by this or other transport).
*
* @return false if the input locator is not supported/allowed by this transport, true otherwise.
*/
bool transform_remote_locator(
const Locator& remote_locator,
- Locator& result_locator) const override;
+ Locator& result_locator,
+ bool allowed_remote_localhost,
+ bool allowed_local_localhost) const override;
LocatorList NormalizeLocator(
const Locator& locator) override;
@@ -115,6 +119,8 @@ class SharedMemTransport : public TransportInterface
bool is_local_locator(
const Locator& locator) const override;
+ bool is_localhost_allowed() const override;
+
TransportDescriptorInterface* get_configuration() override
{
return &configuration_;
diff --git a/test/blackbox/common/BlackboxTestsNetworkConf.cpp b/test/blackbox/common/BlackboxTestsNetworkConf.cpp
index 963f285e96f..8ee72b13c42 100644
--- a/test/blackbox/common/BlackboxTestsNetworkConf.cpp
+++ b/test/blackbox/common/BlackboxTestsNetworkConf.cpp
@@ -46,6 +46,10 @@ class NetworkConfig : public testing::TestWithParam();
}
}
@@ -60,9 +64,10 @@ class NetworkConfig : public testing::TestWithParam& interfaces)
+ std::vector& interfaces,
+ bool return_loopback = false)
{
- IPFinder::getIPs(&interfaces, false);
+ IPFinder::getIPs(&interfaces, return_loopback);
auto new_end = remove_if(interfaces.begin(),
interfaces.end(),
[](IPFinder::info_IP ip)
@@ -77,9 +82,10 @@ static void GetIP4s(
}
static void GetIP6s(
- std::vector& interfaces)
+ std::vector& interfaces,
+ bool return_loopback = false)
{
- IPFinder::getIPs(&interfaces, false);
+ IPFinder::getIPs(&interfaces, return_loopback);
auto new_end = remove_if(interfaces.begin(),
interfaces.end(),
[](IPFinder::info_IP ip)
@@ -290,6 +296,134 @@ TEST_P(NetworkConfig, PubSubInterfaceWhitelistUnicast)
reader.block_for_all();
}
+void asymmetric_whitelist_test(
+ const std::vector& pub_interfaces,
+ const std::vector& sub_interfaces)
+{
+ PubSubReader reader(TEST_TOPIC_NAME);
+ PubSubWriter writer(TEST_TOPIC_NAME);
+
+ std::shared_ptr pub_upv4_descriptor = std::make_shared();
+ // include the interfaces in the transport descriptor
+ for (const auto& interface : pub_interfaces)
+ {
+ pub_upv4_descriptor->interfaceWhiteList.push_back(interface.name);
+ }
+
+ // Set the transport descriptor WITH interfaces in the writer
+ writer.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).history_depth(10).
+ disable_builtin_transport().
+ add_user_transport_to_pparams(pub_upv4_descriptor).init();
+
+ ASSERT_TRUE(writer.isInitialized());
+
+ std::shared_ptr sub_upv4_descriptor = std::make_shared();
+ // include the interfaces in the transport descriptor
+ for (const auto& interface : sub_interfaces)
+ {
+ sub_upv4_descriptor->interfaceWhiteList.push_back(interface.name);
+ }
+
+ // Set the transport descriptor WITH interfaces in the reader
+ reader.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).history_depth(10).
+ disable_builtin_transport().
+ add_user_transport_to_pparams(sub_upv4_descriptor).init();
+
+ ASSERT_TRUE(reader.isInitialized());
+
+ // Because its volatile the durability
+ // Wait for discovery.
+ writer.wait_discovery(std::chrono::seconds(5));
+ reader.wait_discovery(std::chrono::seconds(5));
+
+ // Check that endpoints have discovered each other
+ ASSERT_EQ(reader.get_matched(), 1u);
+ ASSERT_EQ(writer.get_matched(), 1u);
+
+ // Because its volatile the durability
+ // Wait for discovery.
+ writer.wait_discovery();
+ reader.wait_discovery();
+
+ auto data = default_helloworld_data_generator();
+ reader.startReception(data);
+ writer.send(data);
+
+ // Check that the sample data has been sent and received successfully
+ ASSERT_TRUE(data.empty());
+ reader.block_for_all();
+}
+
+// Regression test for redmine issue #18854 to check in UDP (v4) that setting the interface whitelist in one
+// of the endpoints, but not in the other, connection is established anyways.
+// All available interfaces case.
+TEST(NetworkConfig, PubSubAsymmetricInterfaceWhitelistAllInterfaces)
+{
+ std::vector no_interfaces;
+
+ std::vector all_interfaces;
+ GetIP4s(all_interfaces, true);
+
+ {
+ // Whitelist only in publisher
+ asymmetric_whitelist_test(all_interfaces, no_interfaces);
+ }
+
+ {
+ // Whitelist only in subscriber
+ asymmetric_whitelist_test(no_interfaces, all_interfaces);
+ }
+}
+
+// Regression test for redmine issue #18854 to check in UDP (v4) that setting the interface whitelist in one
+// of the endpoints, but not in the other, connection is established anyways.
+// Only loopback interface case.
+TEST(NetworkConfig, PubSubAsymmetricInterfaceWhitelistLocalhostOnly)
+{
+ std::vector no_interfaces;
+
+ std::vector locahost_interface_only;
+ GetIP4s(locahost_interface_only, true);
+ auto new_end = remove_if(locahost_interface_only.begin(),
+ locahost_interface_only.end(),
+ [](IPFinder::info_IP ip)
+ {
+ return ip.type != IPFinder::IP4_LOCAL;
+ });
+ locahost_interface_only.erase(new_end, locahost_interface_only.end());
+
+ {
+ // Whitelist only in publisher
+ asymmetric_whitelist_test(locahost_interface_only, no_interfaces);
+ }
+
+ {
+ // Whitelist only in subscriber
+ asymmetric_whitelist_test(no_interfaces, locahost_interface_only);
+ }
+}
+
+// Regression test for redmine issue #18854 to check in UDP (v4) that setting the interface whitelist in one
+// of the endpoints, but not in the other, connection is established anyways.
+// All available interfaces except loopback case.
+TEST(NetworkConfig, PubSubAsymmetricInterfaceWhitelistAllExceptLocalhost)
+{
+ std::vector no_interfaces;
+
+ std::vector all_interfaces_except_localhost;
+ GetIP4s(all_interfaces_except_localhost, false);
+
+ {
+ // Whitelist only in publisher
+ asymmetric_whitelist_test(all_interfaces_except_localhost, no_interfaces);
+ }
+
+ {
+ // Whitelist only in subscriber
+ asymmetric_whitelist_test(no_interfaces, all_interfaces_except_localhost);
+ }
+}
+
TEST_P(NetworkConfig, SubGetListeningLocators)
{
PubSubReader reader(TEST_TOPIC_NAME);
diff --git a/test/blackbox/common/BlackboxTestsTransportTCP.cpp b/test/blackbox/common/BlackboxTestsTransportTCP.cpp
index 816a6c9d7a1..a7254f60d8d 100644
--- a/test/blackbox/common/BlackboxTestsTransportTCP.cpp
+++ b/test/blackbox/common/BlackboxTestsTransportTCP.cpp
@@ -43,6 +43,10 @@ class TransportTCP : public testing::TestWithParam(GetParam());
if (use_ipv6)
{
+#ifdef __APPLE__
+ // TODO: fix IPv6 issues related with zone ID
+ GTEST_SKIP() << "TCPv6 tests are disabled in Mac";
+#endif // ifdef __APPLE__
test_transport_ = std::make_shared();
}
else
diff --git a/test/blackbox/common/BlackboxTestsTransportUDP.cpp b/test/blackbox/common/BlackboxTestsTransportUDP.cpp
index 1ce54611af4..6140fb90ad5 100644
--- a/test/blackbox/common/BlackboxTestsTransportUDP.cpp
+++ b/test/blackbox/common/BlackboxTestsTransportUDP.cpp
@@ -52,6 +52,10 @@ class TransportUDP : public testing::TestWithParam();
}
}
diff --git a/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h b/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h
index dae14ce0b82..b59015ed613 100644
--- a/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h
+++ b/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h
@@ -48,17 +48,30 @@ class NetworkFactory
bool transform_remote_locator(
const Locator_t& remote_locator,
- Locator_t& result_locator) const
+ Locator_t& result_locator,
+ const NetworkConfigSet_t&) const
{
result_locator = remote_locator;
return true;
}
+ bool is_locator_allowed(
+ const Locator_t&) const
+ {
+ return true;
+ }
+
uint32_t get_min_send_buffer_size()
{
return 65536;
}
+ bool is_local_locator(
+ const Locator_t&) const
+ {
+ return true;
+ }
+
};
} // namespace rtps
diff --git a/test/unittest/rtps/network/mock/MockTransport.h b/test/unittest/rtps/network/mock/MockTransport.h
index 42e5ebf0968..20fbc427151 100644
--- a/test/unittest/rtps/network/mock/MockTransport.h
+++ b/test/unittest/rtps/network/mock/MockTransport.h
@@ -112,6 +112,11 @@ class MockTransport : public TransportInterface
return false;
}
+ bool is_localhost_allowed() const override
+ {
+ return false;
+ }
+
TransportDescriptorInterface* get_configuration() override
{
return nullptr;
@@ -185,6 +190,15 @@ class MockTransport : public TransportInterface
return true;
}
+ bool transform_remote_locator(
+ const fastrtps::rtps::Locator_t&,
+ fastrtps::rtps::Locator_t&,
+ bool,
+ bool) const override
+ {
+ return true;
+ }
+
//Helpers and message record
typedef struct
{
diff --git a/test/unittest/transport/SharedMemTests.cpp b/test/unittest/transport/SharedMemTests.cpp
index 7e2f043048f..3edb3f91394 100644
--- a/test/unittest/transport/SharedMemTests.cpp
+++ b/test/unittest/transport/SharedMemTests.cpp
@@ -785,8 +785,10 @@ TEST_F(SHMTransportTests, transform_remote_locator_returns_input_locator)
// Then
Locator_t otherLocator;
- ASSERT_TRUE(transportUnderTest.transform_remote_locator(remote_locator, otherLocator));
+ ASSERT_TRUE(transportUnderTest.transform_remote_locator(remote_locator, otherLocator, false, false));
ASSERT_EQ(otherLocator, remote_locator);
+ // NOTE: transform_remote_locator only checks for kind compatibility in SharedMemTransport, no transformation is
+ // performed and hence \c allowed_remote_localhost and \c allowed_local_localhost args are irrelevant.
}
TEST_F(SHMTransportTests, all_shared_mem_locators_are_local)
diff --git a/test/unittest/transport/TCPv6Tests.cpp b/test/unittest/transport/TCPv6Tests.cpp
index 57fb33ae97f..f144a16deb1 100644
--- a/test/unittest/transport/TCPv6Tests.cpp
+++ b/test/unittest/transport/TCPv6Tests.cpp
@@ -56,6 +56,14 @@ class TCPv6Tests : public ::testing::Test
{
public:
+ void SetUp() override
+ {
+#ifdef __APPLE__
+ // TODO: fix IPv6 issues related with zone ID
+ GTEST_SKIP() << "TCPv6 tests are disabled in Mac";
+#endif // ifdef __APPLE__
+ }
+
TCPv6Tests()
{
HELPER_SetDescriptorDefaults();
diff --git a/test/unittest/transport/UDPv6Tests.cpp b/test/unittest/transport/UDPv6Tests.cpp
index 6f2b11b040a..e45bda237f7 100644
--- a/test/unittest/transport/UDPv6Tests.cpp
+++ b/test/unittest/transport/UDPv6Tests.cpp
@@ -58,6 +58,14 @@ class UDPv6Tests : public ::testing::Test
{
public:
+ void SetUp() override
+ {
+#ifdef __APPLE__
+ // TODO: fix IPv6 issues related with zone ID
+ GTEST_SKIP() << "UDPv6 tests are disabled in Mac";
+#endif // ifdef __APPLE__
+ }
+
UDPv6Tests()
{
HELPER_SetDescriptorDefaults();