From fcf10bce9790bfbd44657a051921135429fe3d7b Mon Sep 17 00:00:00 2001 From: eduponz Date: Tue, 30 Jul 2024 08:27:16 +0200 Subject: [PATCH 01/20] Refs #19036: NetworkFactory.h -> NetworkFactory.hpp Signed-off-by: eduponz --- src/cpp/rtps/builtin/data/ParticipantProxyData.cpp | 2 +- src/cpp/rtps/builtin/data/ReaderProxyData.cpp | 2 +- src/cpp/rtps/builtin/data/WriterProxyData.cpp | 2 +- .../rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp | 2 +- src/cpp/rtps/network/NetworkFactory.cpp | 2 +- .../rtps/network/{NetworkFactory.h => NetworkFactory.hpp} | 6 +++--- src/cpp/rtps/participant/RTPSParticipantImpl.h | 2 +- src/cpp/rtps/security/SecurityManager.cpp | 2 +- .../rtps/network/{NetworkFactory.h => NetworkFactory.hpp} | 6 +++--- .../rtps/participant/RTPSParticipantImpl.h | 2 +- .../unittest/rtps/builtin/BuiltinDataSerializationTests.cpp | 2 +- test/unittest/rtps/network/NetworkFactoryTests.cpp | 2 +- test/unittest/transport/TCPv6Tests.cpp | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) rename src/cpp/rtps/network/{NetworkFactory.h => NetworkFactory.hpp} (98%) rename test/mock/rtps/NetworkFactory/rtps/network/{NetworkFactory.h => NetworkFactory.hpp} (94%) diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp index b9746004f03..272f721d3fd 100644 --- a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index eedb89d3f88..a12f4ff265d 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include "ProxyDataFilters.hpp" diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp index c892798988f..d0c61f53363 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include "ProxyDataFilters.hpp" diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp index b201eef08a5..29a776fde5b 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/cpp/rtps/network/NetworkFactory.cpp b/src/cpp/rtps/network/NetworkFactory.cpp index 6102d017b4f..f708e1cb0f0 100644 --- a/src/cpp/rtps/network/NetworkFactory.cpp +++ b/src/cpp/rtps/network/NetworkFactory.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include #include #include diff --git a/src/cpp/rtps/network/NetworkFactory.h b/src/cpp/rtps/network/NetworkFactory.hpp similarity index 98% rename from src/cpp/rtps/network/NetworkFactory.h rename to src/cpp/rtps/network/NetworkFactory.hpp index 34e9a592809..4e5da83b5f3 100644 --- a/src/cpp/rtps/network/NetworkFactory.h +++ b/src/cpp/rtps/network/NetworkFactory.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef FASTDDS_RTPS_NETWORK__NETWORKFACTORY_H -#define FASTDDS_RTPS_NETWORK__NETWORKFACTORY_H +#ifndef FASTDDS_RTPS_NETWORK__NETWORKFACTORY_HPP +#define FASTDDS_RTPS_NETWORK__NETWORKFACTORY_HPP #include #include @@ -351,4 +351,4 @@ class NetworkFactory } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_RTPS_NETWORK__NETWORKFACTORY_H +#endif // FASTDDS_RTPS_NETWORK__NETWORKFACTORY_HPP diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.h b/src/cpp/rtps/participant/RTPSParticipantImpl.h index d125141d786..4eba5e83013 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -54,7 +54,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index ca68fce8bfc..a11f5159a1f 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h b/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.hpp similarity index 94% rename from test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h rename to test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.hpp index fae7800f8e1..671292048bd 100644 --- a/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h +++ b/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef FASTDDS_RTPS_NETWORK__NETWORKFACTORY_H -#define FASTDDS_RTPS_NETWORK__NETWORKFACTORY_H +#ifndef FASTDDS_RTPS_NETWORK__NETWORKFACTORY_HPP +#define FASTDDS_RTPS_NETWORK__NETWORKFACTORY_HPP #include #include @@ -117,4 +117,4 @@ class NetworkFactory } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_RTPS_NETWORK__NETWORKFACTORY_H +#endif // FASTDDS_RTPS_NETWORK__NETWORKFACTORY_HPP diff --git a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.h b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.h index 90f5ac80ce0..5bf03ed9132 100644 --- a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.h +++ b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.h @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #if HAVE_SECURITY diff --git a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp index 706c955a72e..83ff0208dda 100644 --- a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp +++ b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace eprosima { namespace fastdds { diff --git a/test/unittest/rtps/network/NetworkFactoryTests.cpp b/test/unittest/rtps/network/NetworkFactoryTests.cpp index b8dd570d480..5b073d52a2f 100644 --- a/test/unittest/rtps/network/NetworkFactoryTests.cpp +++ b/test/unittest/rtps/network/NetworkFactoryTests.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; diff --git a/test/unittest/transport/TCPv6Tests.cpp b/test/unittest/transport/TCPv6Tests.cpp index f87aed21774..11e8faf1696 100644 --- a/test/unittest/transport/TCPv6Tests.cpp +++ b/test/unittest/transport/TCPv6Tests.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include From ea8a5c38b9190d99bae524a6fee6662cee16f761 Mon Sep 17 00:00:00 2001 From: eduponz Date: Tue, 30 Jul 2024 12:07:29 +0200 Subject: [PATCH 02/20] Refs #19036: Add NetworkFactory::is_locator_reachable API Signed-off-by: eduponz --- src/cpp/rtps/network/NetworkFactory.cpp | 6 ++++++ src/cpp/rtps/network/NetworkFactory.hpp | 11 +++++++++++ .../NetworkFactory/rtps/network/NetworkFactory.hpp | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/src/cpp/rtps/network/NetworkFactory.cpp b/src/cpp/rtps/network/NetworkFactory.cpp index f708e1cb0f0..ef3352b500a 100644 --- a/src/cpp/rtps/network/NetworkFactory.cpp +++ b/src/cpp/rtps/network/NetworkFactory.cpp @@ -284,6 +284,12 @@ bool NetworkFactory::is_locator_remote_or_allowed( return (is_locator_supported(locator) && !is_fastdds_local) || is_locator_allowed(locator); } +bool NetworkFactory::is_locator_reachable( + const Locator_t& /*locator*/) +{ + return true; +} + void NetworkFactory::select_locators( LocatorSelector& selector) const { diff --git a/src/cpp/rtps/network/NetworkFactory.hpp b/src/cpp/rtps/network/NetworkFactory.hpp index 4e5da83b5f3..e65de896f08 100644 --- a/src/cpp/rtps/network/NetworkFactory.hpp +++ b/src/cpp/rtps/network/NetworkFactory.hpp @@ -195,6 +195,17 @@ class NetworkFactory const Locator_t& locator, bool is_fastdds_local) const; + /** + * Must report whether the given locator is reachable by at least one of the registered transports. + * + * @param [in] locator Locator to check if remote or allowed. + * + * @return true if the input locator is reachable by at least one of the registered transports, + * false otherwise. + */ + bool is_locator_reachable( + const Locator_t& locator); + /** * Perform the locator selection algorithm. * diff --git a/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.hpp b/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.hpp index 671292048bd..c57c7162c03 100644 --- a/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.hpp +++ b/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.hpp @@ -90,6 +90,12 @@ class NetworkFactory return true; } + bool is_locator_reachable( + const Locator_t&) + { + return true; + } + uint32_t get_min_send_buffer_size() { return 65536; From e4a8983710a2e87b20d07ecfbc0f39f9a0c0132b Mon Sep 17 00:00:00 2001 From: eduponz Date: Tue, 30 Jul 2024 12:34:29 +0200 Subject: [PATCH 03/20] Refs #19036: ProxyDataFilters::filter_locators delegates locator checking to the NetworkFactory Signed-off-by: eduponz --- .../builtin/data/ParticipantProxyData.cpp | 14 ++--- .../builtin/data/ParticipantProxyData.hpp | 6 +- .../rtps/builtin/data/ProxyDataFilters.hpp | 25 +++----- src/cpp/rtps/builtin/data/ReaderProxyData.cpp | 10 ++- src/cpp/rtps/builtin/data/ReaderProxyData.hpp | 3 +- src/cpp/rtps/builtin/data/WriterProxyData.cpp | 10 ++- src/cpp/rtps/builtin/data/WriterProxyData.hpp | 3 +- .../discovery/endpoint/EDPSimpleListeners.cpp | 10 ++- .../discovery/participant/PDPListener.cpp | 2 +- .../participant/PDPServerListener.cpp | 1 - .../rtps/participant/RTPSParticipantImpl.cpp | 3 - .../rtps/builtin/data/ReaderProxyData.hpp | 3 +- .../builtin/BuiltinDataSerializationTests.cpp | 62 +++++++++---------- 13 files changed, 66 insertions(+), 86 deletions(-) diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp index 272f721d3fd..8f77ec5e8be 100644 --- a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp @@ -446,13 +446,12 @@ bool ParticipantProxyData::writeToCDRMessage( bool ParticipantProxyData::readFromCDRMessage( CDRMessage_t* msg, bool use_encapsulation, - const NetworkFactory& network, - bool is_shm_transport_available, + NetworkFactory& network, bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id) { auto param_process = - [this, &network, &is_shm_transport_available, &should_filter_locators, source_vendor_id]( + [this, &network, &should_filter_locators, source_vendor_id]( CDRMessage_t* msg, const ParameterId_t& pid, uint16_t plength) { static_cast(source_vendor_id); @@ -503,7 +502,6 @@ bool ParticipantProxyData::readFromCDRMessage( m_VendorId[0] = p.vendorId[0]; m_VendorId[1] = p.vendorId[1]; - is_shm_transport_available &= (m_VendorId == c_VendorId_eProsima); break; } case fastdds::dds::PID_PRODUCT_VERSION: @@ -613,7 +611,7 @@ bool ParticipantProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, metatraffic_locators, temp_locator, false); @@ -643,7 +641,7 @@ bool ParticipantProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, metatraffic_locators, temp_locator, true); @@ -673,7 +671,7 @@ bool ParticipantProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, default_locators, temp_locator, true); @@ -703,7 +701,7 @@ bool ParticipantProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, default_locators, temp_locator, false); diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp index 540c80010f6..e7c8efb193e 100644 --- a/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp +++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp @@ -28,10 +28,11 @@ #include #include #include +#include #include #include -#include #include +#include namespace eprosima { namespace fastdds { @@ -157,8 +158,7 @@ class ParticipantProxyData bool readFromCDRMessage( CDRMessage_t* msg, bool use_encapsulation, - const NetworkFactory& network, - bool is_shm_transport_available, + NetworkFactory& network, bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id = c_VendorId_eProsima); diff --git a/src/cpp/rtps/builtin/data/ProxyDataFilters.hpp b/src/cpp/rtps/builtin/data/ProxyDataFilters.hpp index 00270d6e200..5a6f802a3ce 100644 --- a/src/cpp/rtps/builtin/data/ProxyDataFilters.hpp +++ b/src/cpp/rtps/builtin/data/ProxyDataFilters.hpp @@ -12,10 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef _FASTDDS_RTPS_BUILTIN_DATA_PROXYDATAFILTERS_H_ -#define _FASTDDS_RTPS_BUILTIN_DATA_PROXYDATAFILTERS_H_ +#ifndef FASTDDS_RTPS_BUILTIN_DATA__PROXYDATAFILTERS_HPP +#define FASTDDS_RTPS_BUILTIN_DATA__PROXYDATAFILTERS_HPP #include + +#include #include namespace eprosima { @@ -30,27 +32,20 @@ class ProxyDataFilters public: /** - * This function filters out SHM locators when they cannot be used for communication on the local host. - * @param [in] is_shm_transport_available Indicates whether the participant has SHM transport enabled. + * @brief This function filters out unreachable locators. + * + * @param [in] network_factory Reference to the @ref NetworkFactory * @param [in,out] target_locators_list List where parsed locators are stored * @param [in] temp_locator New locator to parse * @param [in] is_unicast true if temp_locator is unicast, false if it is multicast */ static void filter_locators( - bool is_shm_transport_available, + NetworkFactory& network_factory, RemoteLocatorList& target_locators_list, const Locator_t& temp_locator, bool is_unicast) { - using SHMLocator = eprosima::fastdds::rtps::SHMLocator; - - bool can_use_locator = LOCATOR_KIND_SHM != temp_locator.kind; - if (!can_use_locator) - { - can_use_locator = is_shm_transport_available && SHMLocator::is_shm_and_from_this_host(temp_locator); - } - - if (can_use_locator) + if (network_factory.is_locator_reachable(temp_locator)) { if (is_unicast) { @@ -69,4 +64,4 @@ class ProxyDataFilters } /* namespace fastdds */ } /* namespace eprosima */ -#endif // _FASTDDS_RTPS_BUILTIN_DATA_PROXYDATAFILTERS_H_ +#endif // FASTDDS_RTPS_BUILTIN_DATA__PROXYDATAFILTERS_HPP diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index a12f4ff265d..e65749d81c9 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -647,12 +647,11 @@ bool ReaderProxyData::writeToCDRMessage( bool ReaderProxyData::readFromCDRMessage( CDRMessage_t* msg, - const NetworkFactory& network, - bool is_shm_transport_available, + NetworkFactory& network, bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id) { - auto param_process = [this, &network, &is_shm_transport_available, &should_filter_locators, source_vendor_id]( + auto param_process = [this, &network, &should_filter_locators, source_vendor_id]( CDRMessage_t* msg, const ParameterId_t& pid, uint16_t plength) { VendorId_t vendor_id = c_VendorId_Unknown; @@ -668,7 +667,6 @@ bool ReaderProxyData::readFromCDRMessage( return false; } - is_shm_transport_available &= (p.vendorId == c_VendorId_eProsima); vendor_id = p.vendorId; break; } @@ -902,7 +900,7 @@ bool ReaderProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, remote_locators_, temp_locator, true); @@ -930,7 +928,7 @@ bool ReaderProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, remote_locators_, temp_locator, false); diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.hpp b/src/cpp/rtps/builtin/data/ReaderProxyData.hpp index 7712ef2ea61..c080e2af88f 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.hpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.hpp @@ -431,8 +431,7 @@ class ReaderProxyData */ bool readFromCDRMessage( CDRMessage_t* msg, - const NetworkFactory& network, - bool is_shm_transport_available, + NetworkFactory& network, bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id = c_VendorId_eProsima); diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp index d0c61f53363..3660cb175d0 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -614,12 +614,11 @@ bool WriterProxyData::writeToCDRMessage( bool WriterProxyData::readFromCDRMessage( CDRMessage_t* msg, - const NetworkFactory& network, - bool is_shm_transport_available, + NetworkFactory& network, bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id) { - auto param_process = [this, &network, &is_shm_transport_available, &should_filter_locators, source_vendor_id]( + auto param_process = [this, &network, &should_filter_locators, source_vendor_id]( CDRMessage_t* msg, const ParameterId_t& pid, uint16_t plength) { VendorId_t vendor_id = c_VendorId_Unknown; @@ -635,7 +634,6 @@ bool WriterProxyData::readFromCDRMessage( return false; } - is_shm_transport_available &= (p.vendorId == c_VendorId_eProsima); vendor_id = p.vendorId; break; } @@ -899,7 +897,7 @@ bool WriterProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, remote_locators_, temp_locator, true); @@ -926,7 +924,7 @@ bool WriterProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, remote_locators_, temp_locator, false); diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.hpp b/src/cpp/rtps/builtin/data/WriterProxyData.hpp index 7eb674628a3..7b0729f159c 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.hpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.hpp @@ -451,8 +451,7 @@ class WriterProxyData //!Read a parameter list from a CDRMessage_t. bool readFromCDRMessage( CDRMessage_t* msg, - const NetworkFactory& network, - bool is_shm_transport_possible, + NetworkFactory& network, bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id = c_VendorId_eProsima); diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp index 29a776fde5b..c133fb3950c 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp @@ -70,13 +70,12 @@ void EDPBasePUBListener::add_writer_from_change( const EndpointAddedCallback& writer_added_callback /* = nullptr*/) { //LOAD INFORMATION IN DESTINATION WRITER PROXY DATA - const NetworkFactory& network = edp->mp_RTPSParticipant->network_factory(); + NetworkFactory& network = edp->mp_RTPSParticipant->network_factory(); CDRMessage_t tempMsg(change->serializedPayload); auto temp_writer_data = edp->get_temporary_writer_proxies_pool().get(); const auto type_server = change->writerGUID; - if (temp_writer_data->readFromCDRMessage(&tempMsg, network, - edp->mp_RTPSParticipant->has_shm_transport(), true, change->vendor_id)) + if (temp_writer_data->readFromCDRMessage(&tempMsg, network, true, change->vendor_id)) { if (temp_writer_data->guid().guidPrefix == edp->mp_RTPSParticipant->getGuid().guidPrefix) { @@ -215,13 +214,12 @@ void EDPBaseSUBListener::add_reader_from_change( const EndpointAddedCallback& reader_added_callback /* = nullptr*/) { //LOAD INFORMATION IN TEMPORAL READER PROXY DATA - const NetworkFactory& network = edp->mp_RTPSParticipant->network_factory(); + NetworkFactory& network = edp->mp_RTPSParticipant->network_factory(); CDRMessage_t tempMsg(change->serializedPayload); auto temp_reader_data = edp->get_temporary_reader_proxies_pool().get(); const auto type_server = change->writerGUID; - if (temp_reader_data->readFromCDRMessage(&tempMsg, network, - edp->mp_RTPSParticipant->has_shm_transport(), true, change->vendor_id)) + if (temp_reader_data->readFromCDRMessage(&tempMsg, network, true, change->vendor_id)) { if (temp_reader_data->guid().guidPrefix == edp->mp_RTPSParticipant->getGuid().guidPrefix) { diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp index f5563ef5af5..5e135c4c390 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp @@ -106,7 +106,7 @@ void PDPListener::on_new_cache_change_added( CDRMessage_t msg(change->serializedPayload); temp_participant_data_.clear(); if (temp_participant_data_.readFromCDRMessage(&msg, true, parent_pdp_->getRTPSParticipant()->network_factory(), - parent_pdp_->getRTPSParticipant()->has_shm_transport(), true, change_in->vendor_id)) + true, change_in->vendor_id)) { // After correctly reading it change->instanceHandle = temp_participant_data_.m_key; diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp index 9f054fbb0c0..d928d9ab4c8 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp @@ -139,7 +139,6 @@ void PDPServerListener::on_new_cache_change_added( &msg, true, pdp_server()->getRTPSParticipant()->network_factory(), - pdp_server()->getRTPSParticipant()->has_shm_transport(), true, change_in->vendor_id)) { diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 5191ff89379..4a2bfdb7256 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -2958,7 +2958,6 @@ bool RTPSParticipantImpl::fill_discovery_data_from_cdr_message( &serialized_msg, true, network_factory(), - has_shm_transport(), false, c_VendorId_eProsima); @@ -2990,7 +2989,6 @@ bool RTPSParticipantImpl::fill_discovery_data_from_cdr_message( ret = writer_data.readFromCDRMessage( &serialized_msg, network_factory(), - has_shm_transport(), false, c_VendorId_eProsima); @@ -3026,7 +3024,6 @@ bool RTPSParticipantImpl::fill_discovery_data_from_cdr_message( ret = reader_data.readFromCDRMessage( &serialized_msg, network_factory(), - has_shm_transport(), false, c_VendorId_eProsima); diff --git a/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp b/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp index f2565882519..554adccbddf 100644 --- a/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp +++ b/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp @@ -141,8 +141,7 @@ class ReaderProxyData bool readFromCDRMessage( CDRMessage_t* /*msg*/, - const NetworkFactory& /*network*/, - bool /*is_shm_transport_possible*/, + NetworkFactory& /*network*/, fastdds::rtps::VendorId_t /*source_vendor_id*/) { return true; diff --git a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp index 83ff0208dda..61d6dbb8e86 100644 --- a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp +++ b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp @@ -118,7 +118,7 @@ TEST(BuiltinDataSerializationTests, ok_with_defaults) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); // EXPECT_EQ(in, out); } @@ -137,7 +137,7 @@ TEST(BuiltinDataSerializationTests, ok_with_defaults) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); } } @@ -150,7 +150,7 @@ TEST(BuiltinDataSerializationTests, msg_with_product_version) msg.init(buffer, buffer_length); msg.length = msg.max_size; - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, c_VendorId_eProsima))); }; @@ -210,7 +210,7 @@ TEST(BuiltinDataSerializationTests, msg_without_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, false, true); + out.readFromCDRMessage(&msg, network, true); ASSERT_EQ(out.m_qos.data_sharing.kind(), dds::OFF); } @@ -227,7 +227,7 @@ TEST(BuiltinDataSerializationTests, msg_without_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, false, true); + out.readFromCDRMessage(&msg, network, true); ASSERT_EQ(out.m_qos.data_sharing.kind(), dds::OFF); } } @@ -250,7 +250,7 @@ TEST(BuiltinDataSerializationTests, msg_with_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, false, true); + out.readFromCDRMessage(&msg, network, true); ASSERT_EQ(out.m_qos.data_sharing.kind(), dds::ON); } @@ -270,7 +270,7 @@ TEST(BuiltinDataSerializationTests, msg_with_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, false, true); + out.readFromCDRMessage(&msg, network, true); ASSERT_EQ(out.m_qos.data_sharing.kind(), dds::ON); } } @@ -339,7 +339,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, false, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true))); } // DATA(r) @@ -401,7 +401,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, false, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true))); } } @@ -516,7 +516,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, false, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true))); } } @@ -594,7 +594,7 @@ TEST(BuiltinDataSerializationTests, property_list_with_binary_properties) msg.length = msg.max_size; ParticipantProxyData out(RTPSParticipantAllocationAttributes{}); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, true))); } // Regression test for redmine tickets 20306 and 20307 @@ -607,7 +607,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, true, network, false, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, fastdds::rtps::VendorId_t({2, 0})))); }; @@ -617,7 +617,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, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, fastdds::rtps::VendorId_t({2, 0})))); }; @@ -627,7 +627,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, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, fastdds::rtps::VendorId_t({2, 0})))); }; @@ -869,7 +869,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, true, network, false, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, fastdds::rtps::c_VendorId_rti_connext))); }; @@ -879,7 +879,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, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, fastdds::rtps::c_VendorId_rti_connext))); }; @@ -889,7 +889,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, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, fastdds::rtps::c_VendorId_rti_connext))); }; @@ -1099,7 +1099,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_without_parameters) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); 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); @@ -1140,7 +1140,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_with_parameters) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); 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); @@ -1232,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, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1281,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, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1366,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, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1415,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, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1449,7 +1449,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_empty_filter_class) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1504,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, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1553,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, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1587,7 +1587,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_empty_filter_expressio // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1642,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, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1829,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, false, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true))); ASSERT_EQ("ContentFilter_0", out.content_filter().content_filtered_topic_name.to_string()); ASSERT_EQ("Square", out.content_filter().related_topic_name.to_string()); @@ -1898,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, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); ASSERT_EQ(100, out.content_filter().expression_parameters.size()); @@ -1942,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, true)); + ASSERT_FALSE(out.readFromCDRMessage(&msg_fault, network, true)); } } From efe02ca54054a18950d2a5f83fa093e8aa24fa63 Mon Sep 17 00:00:00 2001 From: eduponz Date: Tue, 30 Jul 2024 12:59:55 +0200 Subject: [PATCH 04/20] Refs #19036: NetworkFactory::is_locator_reachable iterates over the transports until one reports locator reachability Signed-off-by: eduponz --- include/fastdds/rtps/transport/ChainingTransport.hpp | 10 ++++++++++ .../fastdds/rtps/transport/TransportInterface.hpp | 11 +++++++++++ src/cpp/rtps/network/NetworkFactory.cpp | 12 ++++++++++-- src/cpp/rtps/network/NetworkFactory.hpp | 2 +- src/cpp/rtps/transport/TCPv4Transport.cpp | 6 ++++++ src/cpp/rtps/transport/TCPv4Transport.h | 4 ++++ src/cpp/rtps/transport/TCPv6Transport.cpp | 6 ++++++ src/cpp/rtps/transport/TCPv6Transport.h | 4 ++++ src/cpp/rtps/transport/UDPv4Transport.cpp | 6 ++++++ src/cpp/rtps/transport/UDPv4Transport.h | 4 ++++ src/cpp/rtps/transport/UDPv6Transport.cpp | 6 ++++++ src/cpp/rtps/transport/UDPv6Transport.h | 4 ++++ .../rtps/transport/shared_mem/SharedMemTransport.cpp | 6 ++++++ .../rtps/transport/shared_mem/SharedMemTransport.h | 4 ++++ test/unittest/rtps/network/mock/MockTransport.cpp | 6 ++++++ test/unittest/rtps/network/mock/MockTransport.h | 5 +++++ 16 files changed, 93 insertions(+), 3 deletions(-) diff --git a/include/fastdds/rtps/transport/ChainingTransport.hpp b/include/fastdds/rtps/transport/ChainingTransport.hpp index 1fa44fe28e4..c1c84af9723 100644 --- a/include/fastdds/rtps/transport/ChainingTransport.hpp +++ b/include/fastdds/rtps/transport/ChainingTransport.hpp @@ -389,6 +389,16 @@ class ChainingTransport : public TransportInterface return low_level_transport_->is_locator_allowed(locator); } + /*! + * Call the low-level transport `is_locator_reachable()`. + * Must report whether the given locator is reachable by this transport. + */ + FASTDDS_EXPORTED_API bool is_locator_reachable( + const fastdds::rtps::Locator_t& locator) override + { + return low_level_transport_->is_locator_reachable(locator); + } + protected: std::unique_ptr low_level_transport_; diff --git a/include/fastdds/rtps/transport/TransportInterface.hpp b/include/fastdds/rtps/transport/TransportInterface.hpp index 7f2e6329b8f..aa14e8f13cb 100644 --- a/include/fastdds/rtps/transport/TransportInterface.hpp +++ b/include/fastdds/rtps/transport/TransportInterface.hpp @@ -117,6 +117,17 @@ class FASTDDS_EXPORTED_API TransportInterface virtual bool is_locator_allowed( const Locator&) const = 0; + /** + * Must report whether the given locator is reachable by this transport. + * + * @param [in] locator @ref Locator for which the reachability is checked. + * + * @return true if the input locator is reachable by this transport, false otherwise. + */ + virtual bool is_locator_reachable( + const Locator_t& locator) = 0; + + //! Returns the locator describing the main (most general) channel that can write to the provided remote locator. virtual Locator RemoteToMainLocal( const Locator& remote) const = 0; diff --git a/src/cpp/rtps/network/NetworkFactory.cpp b/src/cpp/rtps/network/NetworkFactory.cpp index ef3352b500a..6e948c85553 100644 --- a/src/cpp/rtps/network/NetworkFactory.cpp +++ b/src/cpp/rtps/network/NetworkFactory.cpp @@ -285,9 +285,17 @@ bool NetworkFactory::is_locator_remote_or_allowed( } bool NetworkFactory::is_locator_reachable( - const Locator_t& /*locator*/) + const Locator_t& locator) { - return true; + for (auto& transport : mRegisteredTransports) + { + if (transport->is_locator_reachable(locator)) + { + return true; + } + } + + return false; } void NetworkFactory::select_locators( diff --git a/src/cpp/rtps/network/NetworkFactory.hpp b/src/cpp/rtps/network/NetworkFactory.hpp index e65de896f08..4e282106988 100644 --- a/src/cpp/rtps/network/NetworkFactory.hpp +++ b/src/cpp/rtps/network/NetworkFactory.hpp @@ -198,7 +198,7 @@ class NetworkFactory /** * Must report whether the given locator is reachable by at least one of the registered transports. * - * @param [in] locator Locator to check if remote or allowed. + * @param [in] locator @ref Locator for which the reachability is checked. * * @return true if the input locator is reachable by at least one of the registered transports, * false otherwise. diff --git a/src/cpp/rtps/transport/TCPv4Transport.cpp b/src/cpp/rtps/transport/TCPv4Transport.cpp index 6552edf7a56..9f6b75b09bd 100644 --- a/src/cpp/rtps/transport/TCPv4Transport.cpp +++ b/src/cpp/rtps/transport/TCPv4Transport.cpp @@ -434,6 +434,12 @@ bool TCPv4Transport::is_locator_allowed( return is_interface_allowed(IPLocator::toIPv4string(locator)); } +bool TCPv4Transport::is_locator_reachable( + const Locator_t& locator) +{ + return IsLocatorSupported(locator); +} + bool TCPv4Transport::compare_locator_ip( const Locator& lh, const Locator& rh) const diff --git a/src/cpp/rtps/transport/TCPv4Transport.h b/src/cpp/rtps/transport/TCPv4Transport.h index 190b4d8302d..a21a4206988 100644 --- a/src/cpp/rtps/transport/TCPv4Transport.h +++ b/src/cpp/rtps/transport/TCPv4Transport.h @@ -96,6 +96,10 @@ class TCPv4Transport : public TCPTransportInterface bool is_locator_allowed( const Locator& locator) const override; + //! Checks for whether locator is reachable. + bool is_locator_reachable( + const Locator_t&) override; + //! Checks if the given ip has been included in the white list to use it. virtual bool is_interface_allowed( const std::string& iface) const override; diff --git a/src/cpp/rtps/transport/TCPv6Transport.cpp b/src/cpp/rtps/transport/TCPv6Transport.cpp index 5c9d727d894..9cb3d58a43d 100644 --- a/src/cpp/rtps/transport/TCPv6Transport.cpp +++ b/src/cpp/rtps/transport/TCPv6Transport.cpp @@ -317,6 +317,12 @@ bool TCPv6Transport::is_locator_allowed( return is_interface_allowed(IPLocator::toIPv6string(locator)); } +bool TCPv6Transport::is_locator_reachable( + const Locator_t& locator) +{ + return IsLocatorSupported(locator); +} + bool TCPv6Transport::is_interface_whitelist_empty() const { return interface_whitelist_.empty(); diff --git a/src/cpp/rtps/transport/TCPv6Transport.h b/src/cpp/rtps/transport/TCPv6Transport.h index dd3d40b7ade..03d90fdd6bb 100644 --- a/src/cpp/rtps/transport/TCPv6Transport.h +++ b/src/cpp/rtps/transport/TCPv6Transport.h @@ -98,6 +98,10 @@ class TCPv6Transport : public TCPTransportInterface bool is_locator_allowed( const Locator& locator) const override; + //! Checks for whether locator is reachable. + bool is_locator_reachable( + const Locator_t&) override; + //! Checks if the interfaces white list is empty. virtual bool is_interface_whitelist_empty() const override; diff --git a/src/cpp/rtps/transport/UDPv4Transport.cpp b/src/cpp/rtps/transport/UDPv4Transport.cpp index dd24c2b97f7..d04ee7e5499 100644 --- a/src/cpp/rtps/transport/UDPv4Transport.cpp +++ b/src/cpp/rtps/transport/UDPv4Transport.cpp @@ -603,6 +603,12 @@ bool UDPv4Transport::is_locator_allowed( return is_interface_allowed(IPLocator::toIPv4string(locator)); } +bool UDPv4Transport::is_locator_reachable( + const Locator_t& locator) +{ + return IsLocatorSupported(locator); +} + LocatorList UDPv4Transport::NormalizeLocator( const Locator& locator) { diff --git a/src/cpp/rtps/transport/UDPv4Transport.h b/src/cpp/rtps/transport/UDPv4Transport.h index 8f1d2c37f33..ceabb4c4a3a 100644 --- a/src/cpp/rtps/transport/UDPv4Transport.h +++ b/src/cpp/rtps/transport/UDPv4Transport.h @@ -147,6 +147,10 @@ class UDPv4Transport : public UDPTransportInterface bool is_locator_allowed( const Locator&) const override; + //! Checks for whether locator is reachable. + bool is_locator_reachable( + const Locator_t&) override; + //! Checks if the given interface is allowed by the white list. bool is_interface_allowed( const asio::ip::address_v4& ip) const; diff --git a/src/cpp/rtps/transport/UDPv6Transport.cpp b/src/cpp/rtps/transport/UDPv6Transport.cpp index af9447cda39..437b3c8825f 100644 --- a/src/cpp/rtps/transport/UDPv6Transport.cpp +++ b/src/cpp/rtps/transport/UDPv6Transport.cpp @@ -608,6 +608,12 @@ bool UDPv6Transport::is_locator_allowed( return is_interface_allowed(IPLocator::toIPv6string(locator)); } +bool UDPv6Transport::is_locator_reachable( + const Locator_t& locator) +{ + return IsLocatorSupported(locator); +} + LocatorList UDPv6Transport::NormalizeLocator( const Locator& locator) { diff --git a/src/cpp/rtps/transport/UDPv6Transport.h b/src/cpp/rtps/transport/UDPv6Transport.h index a96071371e4..0f4d4fb5758 100644 --- a/src/cpp/rtps/transport/UDPv6Transport.h +++ b/src/cpp/rtps/transport/UDPv6Transport.h @@ -134,6 +134,10 @@ class UDPv6Transport : public UDPTransportInterface bool is_locator_allowed( const Locator&) const override; + //! Checks for whether locator is reachable. + bool is_locator_reachable( + const Locator_t&) override; + /** * Method to get a list of interfaces to bind the socket associated to the given locator. * @return Vector of interfaces in string format. diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp index 6d78649f870..d63b034cf64 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp @@ -152,6 +152,12 @@ bool SharedMemTransport::is_locator_allowed( return IsLocatorSupported(locator); } +bool SharedMemTransport::is_locator_reachable( + const Locator_t& locator) +{ + return SHMLocator::is_shm_and_from_this_host(locator); +} + LocatorList SharedMemTransport::NormalizeLocator( const Locator& locator) { diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h index 28d2ea52035..f11cdbcd8c6 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h +++ b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h @@ -225,6 +225,10 @@ class SharedMemTransport : public TransportInterface bool is_locator_allowed( const Locator&) const override; + //! Checks for whether locator is reachable. + bool is_locator_reachable( + const Locator_t&) override; + protected: std::shared_ptr shared_mem_manager_; diff --git a/test/unittest/rtps/network/mock/MockTransport.cpp b/test/unittest/rtps/network/mock/MockTransport.cpp index 4bcb4cc94f1..8867715e617 100644 --- a/test/unittest/rtps/network/mock/MockTransport.cpp +++ b/test/unittest/rtps/network/mock/MockTransport.cpp @@ -73,6 +73,12 @@ bool MockTransport::is_locator_allowed( return true; } +bool MockTransport::is_locator_reachable( + const Locator_t& /*locator*/) +{ + return true; +} + bool MockTransport::OpenOutputChannel( fastdds::rtps::SendResourceList& send_resource_list, const Locator_t& locator) diff --git a/test/unittest/rtps/network/mock/MockTransport.h b/test/unittest/rtps/network/mock/MockTransport.h index 2955afa8a1e..5dc6cf49f16 100644 --- a/test/unittest/rtps/network/mock/MockTransport.h +++ b/test/unittest/rtps/network/mock/MockTransport.h @@ -86,8 +86,13 @@ class MockTransport : public fastdds::rtps::TransportInterface bool IsLocatorSupported( const Locator_t&) const override; + bool is_locator_allowed( const Locator_t& locator) const override; + + bool is_locator_reachable( + const Locator_t&) override; + bool DoInputLocatorsMatch( const Locator_t&, const Locator_t&) const override; From b4833f6fd8ecad9d96be4eb13182baac6597fd05 Mon Sep 17 00:00:00 2001 From: eduponz Date: Tue, 30 Jul 2024 15:04:47 +0200 Subject: [PATCH 05/20] Refs #19036: SharedMemTransport::is_locator_reachable discards non-shm non-local ports, and shm local ports that cannot open to write Signed-off-by: eduponz --- .../shared_mem/SharedMemTransport.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp index d63b034cf64..de555d9d682 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp @@ -155,7 +155,24 @@ bool SharedMemTransport::is_locator_allowed( bool SharedMemTransport::is_locator_reachable( const Locator_t& locator) { - return SHMLocator::is_shm_and_from_this_host(locator); + bool is_reachable = SHMLocator::is_shm_and_from_this_host(locator); + + if (is_reachable) + { + try + { + is_reachable = (nullptr != find_port(locator.port)); + } + catch (const std::exception& e) + { + EPROSIMA_LOG_INFO(RTPS_MSG_OUT, + "Local SHM locator '" << locator << + "' is not reachable; discarding. Reason: " << e.what()); + is_reachable = false; + } + } + + return is_reachable; } LocatorList SharedMemTransport::NormalizeLocator( From 170e8c447588790f349bb790b400358a07299a45 Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:31:35 +0200 Subject: [PATCH 06/20] Refs #19036: Apply suggestions Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --- src/cpp/rtps/builtin/data/ParticipantProxyData.cpp | 2 +- src/cpp/rtps/builtin/data/ParticipantProxyData.hpp | 1 + src/cpp/rtps/builtin/data/ReaderProxyData.cpp | 2 +- src/cpp/rtps/builtin/data/ReaderProxyData.hpp | 1 - src/cpp/rtps/builtin/data/WriterProxyData.cpp | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp index 8f77ec5e8be..9e494efdecf 100644 --- a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp @@ -454,7 +454,7 @@ bool ParticipantProxyData::readFromCDRMessage( [this, &network, &should_filter_locators, source_vendor_id]( CDRMessage_t* msg, const ParameterId_t& pid, uint16_t plength) { - static_cast(source_vendor_id); + m_VendorId = source_vendor_id; switch (pid){ case fastdds::dds::PID_KEY_HASH: { diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp index e7c8efb193e..09e65d13219 100644 --- a/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp +++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp @@ -32,6 +32,7 @@ #include #include #include + #include namespace eprosima { diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index e65749d81c9..0a75a6a84b9 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -654,7 +654,7 @@ bool ReaderProxyData::readFromCDRMessage( auto param_process = [this, &network, &should_filter_locators, source_vendor_id]( CDRMessage_t* msg, const ParameterId_t& pid, uint16_t plength) { - VendorId_t vendor_id = c_VendorId_Unknown; + VendorId_t vendor_id = source_vendor_id; switch (pid) { diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.hpp b/src/cpp/rtps/builtin/data/ReaderProxyData.hpp index c080e2af88f..9511c31d140 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.hpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.hpp @@ -424,7 +424,6 @@ class ReaderProxyData * parameter list. * @param msg Pointer to the message. * @param network Reference to network factory for locator validation and transformation - * @param is_shm_transport_available Indicates whether the Reader is reachable by SHM. * @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 diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp index 3660cb175d0..857668b00a9 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -621,7 +621,7 @@ bool WriterProxyData::readFromCDRMessage( auto param_process = [this, &network, &should_filter_locators, source_vendor_id]( CDRMessage_t* msg, const ParameterId_t& pid, uint16_t plength) { - VendorId_t vendor_id = c_VendorId_Unknown; + VendorId_t vendor_id = source_vendor_id; switch (pid) { From 8077a512eb1a90c56652608e381e11231cdeabef Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 31 Jul 2024 16:49:41 +0200 Subject: [PATCH 07/20] Refs #19036. Increase `MAX_DOMAIN_NAME_LENGTH` and `CURRENT_ABI_VERSION`. Signed-off-by: Miguel Company --- src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp index 8a51d2f46b9..19dd09b32c6 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp @@ -47,7 +47,7 @@ class SharedMemGlobal struct BufferDescriptor; // Long names for SHM files could cause problems on some platforms - static constexpr uint32_t MAX_DOMAIN_NAME_LENGTH = 16; + static constexpr uint32_t MAX_DOMAIN_NAME_LENGTH = 255; SharedMemGlobal( const std::string& domain_name) @@ -93,8 +93,8 @@ class SharedMemGlobal typedef MultiProducerConsumerRingBuffer::Listener Listener; typedef MultiProducerConsumerRingBuffer::Cell PortCell; - static const uint32_t CURRENT_ABI_VERSION = 5; - static_assert(CURRENT_ABI_VERSION == (2 + FASTDDS_VERSION_MAJOR), "ABI is not correct"); + static const uint32_t CURRENT_ABI_VERSION = 6; + static_assert(CURRENT_ABI_VERSION == (3 + FASTDDS_VERSION_MAJOR), "ABI is not correct"); static_assert(LOCATOR_KIND_SHM == (16 + FASTDDS_VERSION_MAJOR), "LOCATOR_KIND_SHM is not correct"); struct PortNode From c80f97edf7e3150832751c1bf9f2f84eb93a4033 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 31 Jul 2024 16:54:19 +0200 Subject: [PATCH 08/20] Refs #19036. Rename to `creator_name`. Signed-off-by: Miguel Company --- .../transport/shared_mem/SharedMemGlobal.hpp | 20 +++++++++---------- .../transport/shared_mem/SharedMemManager.hpp | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp index 19dd09b32c6..66e8351545e 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp @@ -47,18 +47,18 @@ class SharedMemGlobal struct BufferDescriptor; // Long names for SHM files could cause problems on some platforms - static constexpr uint32_t MAX_DOMAIN_NAME_LENGTH = 255; + static constexpr uint32_t MAX_CREATOR_NAME_LENGTH = 255; SharedMemGlobal( const std::string& domain_name) : domain_name_(domain_name) { - if (domain_name.length() > MAX_DOMAIN_NAME_LENGTH) + if (domain_name.length() > MAX_CREATOR_NAME_LENGTH) { throw std::runtime_error( domain_name + " too long for domain name (max " + - std::to_string(MAX_DOMAIN_NAME_LENGTH) + + std::to_string(MAX_CREATOR_NAME_LENGTH) + " characters"); } } @@ -159,7 +159,7 @@ class SharedMemGlobal }; ListenerStatus listeners_status[LISTENERS_STATUS_SIZE]; - char domain_name[MAX_DOMAIN_NAME_LENGTH + 1]; + char creator_name[MAX_CREATOR_NAME_LENGTH + 1]; }; /** @@ -908,7 +908,7 @@ class SharedMemGlobal throw std::runtime_error("port is opened ReadShared"); } - std::string lock_name = std::string(node_->domain_name) + "_port" + std::to_string(node_->port_id) + "_el"; + std::string lock_name = std::string(node_->creator_name) + "_port" + std::to_string(node_->port_id) + "_el"; read_exclusive_lock_ = std::unique_ptr(new RobustExclusiveLock(lock_name)); } @@ -919,7 +919,7 @@ class SharedMemGlobal throw std::runtime_error("port is opened ReadExclusive"); } - std::string lock_name = std::string(node_->domain_name) + "_port" + std::to_string(node_->port_id) + "_sl"; + std::string lock_name = std::string(node_->creator_name) + "_port" + std::to_string(node_->port_id) + "_sl"; read_shared_lock_ = std::unique_ptr(new RobustSharedLock(lock_name)); } @@ -1284,12 +1284,12 @@ class SharedMemGlobal port_node->max_buffer_descriptors = max_buffer_descriptors; std::fill_n(port_node->listeners_status, PortNode::LISTENERS_STATUS_SIZE, PortNode::ListenerStatus()); #ifdef _MSC_VER - strncpy_s(port_node->domain_name, sizeof(port_node->domain_name), - domain_name_.c_str(), sizeof(port_node->domain_name) - 1); + strncpy_s(port_node->creator_name, sizeof(port_node->creator_name), + domain_name_.c_str(), sizeof(port_node->creator_name) - 1); #else - strncpy(port_node->domain_name, domain_name_.c_str(), sizeof(port_node->domain_name) - 1); + strncpy(port_node->creator_name, domain_name_.c_str(), sizeof(port_node->creator_name) - 1); #endif // ifdef _MSC_VER - port_node->domain_name[sizeof(port_node->domain_name) - 1] = 0; + port_node->creator_name[sizeof(port_node->creator_name) - 1] = 0; // Buffer cells allocation auto buffer = segment->get().construct::Cell>( diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp b/src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp index c37c78f31ca..ef88e7d7688 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp @@ -246,12 +246,12 @@ class SharedMemManager : static std::shared_ptr create( const std::string& domain_name) { - if (domain_name.length() > SharedMemGlobal::MAX_DOMAIN_NAME_LENGTH) + if (domain_name.length() > SharedMemGlobal::MAX_CREATOR_NAME_LENGTH) { throw std::runtime_error( domain_name + " too long for domain name (max " + - std::to_string(SharedMemGlobal::MAX_DOMAIN_NAME_LENGTH) + + std::to_string(SharedMemGlobal::MAX_CREATOR_NAME_LENGTH) + " characters"); } From 7459a238feb25aa78225c0de361512da19d078d4 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 31 Jul 2024 17:05:26 +0200 Subject: [PATCH 09/20] Refs #19036. Port receives domain name on construction. Signed-off-by: Miguel Company --- .../rtps/transport/shared_mem/SharedMemGlobal.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp index 66e8351545e..67631e4a78e 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp @@ -413,6 +413,8 @@ class SharedMemGlobal // Keep a reference to the WatchTask so that it is not destroyed until the last Port instance is destroyed std::shared_ptr watch_task_; + std::string domain_name_; + public: /** @@ -447,12 +449,14 @@ class SharedMemGlobal Port( std::shared_ptr&& port_segment, PortNode* node, + std::string domain_name, std::unique_ptr&& read_exclusive_lock = std::unique_ptr()) : port_segment_(std::move(port_segment)) , node_(node) , overflows_count_(0) , read_exclusive_lock_(std::move(read_exclusive_lock)) , watch_task_(WatchTask::get()) + , domain_name_(domain_name) { auto buffer_base = static_cast::Cell*>( port_segment_->get_address_from_offset(node_->buffer)); @@ -908,7 +912,7 @@ class SharedMemGlobal throw std::runtime_error("port is opened ReadShared"); } - std::string lock_name = std::string(node_->creator_name) + "_port" + std::to_string(node_->port_id) + "_el"; + std::string lock_name = domain_name_ + "_port" + std::to_string(node_->port_id) + "_el"; read_exclusive_lock_ = std::unique_ptr(new RobustExclusiveLock(lock_name)); } @@ -919,7 +923,7 @@ class SharedMemGlobal throw std::runtime_error("port is opened ReadExclusive"); } - std::string lock_name = std::string(node_->creator_name) + "_port" + std::to_string(node_->port_id) + "_sl"; + std::string lock_name = domain_name_ + "_port" + std::to_string(node_->port_id) + "_sl"; read_shared_lock_ = std::unique_ptr(new RobustSharedLock(lock_name)); } @@ -1106,7 +1110,7 @@ class SharedMemGlobal if (port_node) { - port = std::make_shared(std::move(port_segment), port_node); + port = std::make_shared(std::move(port_segment), port_node, domain_name_); } else { @@ -1305,7 +1309,7 @@ class SharedMemGlobal port_node->buffer_node = segment->get_offset_from_address(buffer_node); port_node->is_port_ok = true; - port = std::make_shared(std::move(segment), port_node, std::move(lock_read_exclusive)); + port = std::make_shared(std::move(segment), port_node, domain_name_, std::move(lock_read_exclusive)); if (open_mode == Port::OpenMode::ReadShared) { From 7e2b522e5aa15faa3039dfc8de0383afa87be689 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 31 Jul 2024 17:29:41 +0200 Subject: [PATCH 10/20] Refs #19036. Use user name as part of the port ABI check. Signed-off-by: Miguel Company --- .../transport/shared_mem/SharedMemGlobal.hpp | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp index 67631e4a78e..3dac355d8be 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp @@ -16,12 +16,14 @@ #define _FASTDDS_SHAREDMEM_GLOBAL_H_ #include +#include #include #include #include #include #include +#include #include #include @@ -29,6 +31,7 @@ #include #include #include +#include #define THREADID "(ID:" << std::this_thread::get_id() << ") " @@ -53,11 +56,15 @@ class SharedMemGlobal const std::string& domain_name) : domain_name_(domain_name) { - if (domain_name.length() > MAX_CREATOR_NAME_LENGTH) + if (fastdds::dds::RETCODE_OK != SystemInfo::get_username(user_name_)) + { + user_name_ = domain_name_; + } + if (user_name_.length() > MAX_CREATOR_NAME_LENGTH) { throw std::runtime_error( - domain_name + - " too long for domain name (max " + + user_name_ + + " too long for creator name (max " + std::to_string(MAX_CREATOR_NAME_LENGTH) + " characters"); } @@ -1047,6 +1054,8 @@ class SharedMemGlobal std::string domain_name_; + std::string user_name_; + std::shared_ptr open_port_internal( uint32_t port_id, uint32_t max_buffer_descriptors, @@ -1108,6 +1117,14 @@ class SharedMemGlobal port_node = port_segment->get().find( ("port_node_abi" + std::to_string(CURRENT_ABI_VERSION)).c_str()).first; + if (port_node) + { + if (0 != strcmp(port_node->creator_name, user_name_.c_str())) + { + throw std::runtime_error("port_abi not compatible"); + } + } + if (port_node) { port = std::make_shared(std::move(port_segment), port_node, domain_name_); @@ -1289,9 +1306,9 @@ class SharedMemGlobal std::fill_n(port_node->listeners_status, PortNode::LISTENERS_STATUS_SIZE, PortNode::ListenerStatus()); #ifdef _MSC_VER strncpy_s(port_node->creator_name, sizeof(port_node->creator_name), - domain_name_.c_str(), sizeof(port_node->creator_name) - 1); + user_name_.c_str(), sizeof(port_node->creator_name) - 1); #else - strncpy(port_node->creator_name, domain_name_.c_str(), sizeof(port_node->creator_name) - 1); + strncpy(port_node->creator_name, user_name_.c_str(), sizeof(port_node->creator_name) - 1); #endif // ifdef _MSC_VER port_node->creator_name[sizeof(port_node->creator_name) - 1] = 0; From 43b342e997c4398f95c8ee700e71816a50335f2f Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:45:45 +0200 Subject: [PATCH 11/20] Revert "Refs #19036. Use user name as part of the port ABI check." This reverts commit 7e2b522e5aa15faa3039dfc8de0383afa87be689. --- .../transport/shared_mem/SharedMemGlobal.hpp | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp index 3dac355d8be..67631e4a78e 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp @@ -16,14 +16,12 @@ #define _FASTDDS_SHAREDMEM_GLOBAL_H_ #include -#include #include #include #include #include #include -#include #include #include @@ -31,7 +29,6 @@ #include #include #include -#include #define THREADID "(ID:" << std::this_thread::get_id() << ") " @@ -56,15 +53,11 @@ class SharedMemGlobal const std::string& domain_name) : domain_name_(domain_name) { - if (fastdds::dds::RETCODE_OK != SystemInfo::get_username(user_name_)) - { - user_name_ = domain_name_; - } - if (user_name_.length() > MAX_CREATOR_NAME_LENGTH) + if (domain_name.length() > MAX_CREATOR_NAME_LENGTH) { throw std::runtime_error( - user_name_ + - " too long for creator name (max " + + domain_name + + " too long for domain name (max " + std::to_string(MAX_CREATOR_NAME_LENGTH) + " characters"); } @@ -1054,8 +1047,6 @@ class SharedMemGlobal std::string domain_name_; - std::string user_name_; - std::shared_ptr open_port_internal( uint32_t port_id, uint32_t max_buffer_descriptors, @@ -1117,14 +1108,6 @@ class SharedMemGlobal port_node = port_segment->get().find( ("port_node_abi" + std::to_string(CURRENT_ABI_VERSION)).c_str()).first; - if (port_node) - { - if (0 != strcmp(port_node->creator_name, user_name_.c_str())) - { - throw std::runtime_error("port_abi not compatible"); - } - } - if (port_node) { port = std::make_shared(std::move(port_segment), port_node, domain_name_); @@ -1306,9 +1289,9 @@ class SharedMemGlobal std::fill_n(port_node->listeners_status, PortNode::LISTENERS_STATUS_SIZE, PortNode::ListenerStatus()); #ifdef _MSC_VER strncpy_s(port_node->creator_name, sizeof(port_node->creator_name), - user_name_.c_str(), sizeof(port_node->creator_name) - 1); + domain_name_.c_str(), sizeof(port_node->creator_name) - 1); #else - strncpy(port_node->creator_name, user_name_.c_str(), sizeof(port_node->creator_name) - 1); + strncpy(port_node->creator_name, domain_name_.c_str(), sizeof(port_node->creator_name) - 1); #endif // ifdef _MSC_VER port_node->creator_name[sizeof(port_node->creator_name) - 1] = 0; From ae9b825b103d50475216c3d0daee2fc12593dfbb Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:45:51 +0200 Subject: [PATCH 12/20] Revert "Refs #19036. Port receives domain name on construction." This reverts commit 7459a238feb25aa78225c0de361512da19d078d4. --- .../rtps/transport/shared_mem/SharedMemGlobal.hpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp index 67631e4a78e..66e8351545e 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp @@ -413,8 +413,6 @@ class SharedMemGlobal // Keep a reference to the WatchTask so that it is not destroyed until the last Port instance is destroyed std::shared_ptr watch_task_; - std::string domain_name_; - public: /** @@ -449,14 +447,12 @@ class SharedMemGlobal Port( std::shared_ptr&& port_segment, PortNode* node, - std::string domain_name, std::unique_ptr&& read_exclusive_lock = std::unique_ptr()) : port_segment_(std::move(port_segment)) , node_(node) , overflows_count_(0) , read_exclusive_lock_(std::move(read_exclusive_lock)) , watch_task_(WatchTask::get()) - , domain_name_(domain_name) { auto buffer_base = static_cast::Cell*>( port_segment_->get_address_from_offset(node_->buffer)); @@ -912,7 +908,7 @@ class SharedMemGlobal throw std::runtime_error("port is opened ReadShared"); } - std::string lock_name = domain_name_ + "_port" + std::to_string(node_->port_id) + "_el"; + std::string lock_name = std::string(node_->creator_name) + "_port" + std::to_string(node_->port_id) + "_el"; read_exclusive_lock_ = std::unique_ptr(new RobustExclusiveLock(lock_name)); } @@ -923,7 +919,7 @@ class SharedMemGlobal throw std::runtime_error("port is opened ReadExclusive"); } - std::string lock_name = domain_name_ + "_port" + std::to_string(node_->port_id) + "_sl"; + std::string lock_name = std::string(node_->creator_name) + "_port" + std::to_string(node_->port_id) + "_sl"; read_shared_lock_ = std::unique_ptr(new RobustSharedLock(lock_name)); } @@ -1110,7 +1106,7 @@ class SharedMemGlobal if (port_node) { - port = std::make_shared(std::move(port_segment), port_node, domain_name_); + port = std::make_shared(std::move(port_segment), port_node); } else { @@ -1309,7 +1305,7 @@ class SharedMemGlobal port_node->buffer_node = segment->get_offset_from_address(buffer_node); port_node->is_port_ok = true; - port = std::make_shared(std::move(segment), port_node, domain_name_, std::move(lock_read_exclusive)); + port = std::make_shared(std::move(segment), port_node, std::move(lock_read_exclusive)); if (open_mode == Port::OpenMode::ReadShared) { From 3f7839ae2ad2287027e81913c269f230baae99bb Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:45:59 +0200 Subject: [PATCH 13/20] Revert "Refs #19036. Rename to `creator_name`." This reverts commit c80f97edf7e3150832751c1bf9f2f84eb93a4033. --- .../transport/shared_mem/SharedMemGlobal.hpp | 20 +++++++++---------- .../transport/shared_mem/SharedMemManager.hpp | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp index 66e8351545e..19dd09b32c6 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp @@ -47,18 +47,18 @@ class SharedMemGlobal struct BufferDescriptor; // Long names for SHM files could cause problems on some platforms - static constexpr uint32_t MAX_CREATOR_NAME_LENGTH = 255; + static constexpr uint32_t MAX_DOMAIN_NAME_LENGTH = 255; SharedMemGlobal( const std::string& domain_name) : domain_name_(domain_name) { - if (domain_name.length() > MAX_CREATOR_NAME_LENGTH) + if (domain_name.length() > MAX_DOMAIN_NAME_LENGTH) { throw std::runtime_error( domain_name + " too long for domain name (max " + - std::to_string(MAX_CREATOR_NAME_LENGTH) + + std::to_string(MAX_DOMAIN_NAME_LENGTH) + " characters"); } } @@ -159,7 +159,7 @@ class SharedMemGlobal }; ListenerStatus listeners_status[LISTENERS_STATUS_SIZE]; - char creator_name[MAX_CREATOR_NAME_LENGTH + 1]; + char domain_name[MAX_DOMAIN_NAME_LENGTH + 1]; }; /** @@ -908,7 +908,7 @@ class SharedMemGlobal throw std::runtime_error("port is opened ReadShared"); } - std::string lock_name = std::string(node_->creator_name) + "_port" + std::to_string(node_->port_id) + "_el"; + std::string lock_name = std::string(node_->domain_name) + "_port" + std::to_string(node_->port_id) + "_el"; read_exclusive_lock_ = std::unique_ptr(new RobustExclusiveLock(lock_name)); } @@ -919,7 +919,7 @@ class SharedMemGlobal throw std::runtime_error("port is opened ReadExclusive"); } - std::string lock_name = std::string(node_->creator_name) + "_port" + std::to_string(node_->port_id) + "_sl"; + std::string lock_name = std::string(node_->domain_name) + "_port" + std::to_string(node_->port_id) + "_sl"; read_shared_lock_ = std::unique_ptr(new RobustSharedLock(lock_name)); } @@ -1284,12 +1284,12 @@ class SharedMemGlobal port_node->max_buffer_descriptors = max_buffer_descriptors; std::fill_n(port_node->listeners_status, PortNode::LISTENERS_STATUS_SIZE, PortNode::ListenerStatus()); #ifdef _MSC_VER - strncpy_s(port_node->creator_name, sizeof(port_node->creator_name), - domain_name_.c_str(), sizeof(port_node->creator_name) - 1); + strncpy_s(port_node->domain_name, sizeof(port_node->domain_name), + domain_name_.c_str(), sizeof(port_node->domain_name) - 1); #else - strncpy(port_node->creator_name, domain_name_.c_str(), sizeof(port_node->creator_name) - 1); + strncpy(port_node->domain_name, domain_name_.c_str(), sizeof(port_node->domain_name) - 1); #endif // ifdef _MSC_VER - port_node->creator_name[sizeof(port_node->creator_name) - 1] = 0; + port_node->domain_name[sizeof(port_node->domain_name) - 1] = 0; // Buffer cells allocation auto buffer = segment->get().construct::Cell>( diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp b/src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp index ef88e7d7688..c37c78f31ca 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp @@ -246,12 +246,12 @@ class SharedMemManager : static std::shared_ptr create( const std::string& domain_name) { - if (domain_name.length() > SharedMemGlobal::MAX_CREATOR_NAME_LENGTH) + if (domain_name.length() > SharedMemGlobal::MAX_DOMAIN_NAME_LENGTH) { throw std::runtime_error( domain_name + " too long for domain name (max " + - std::to_string(SharedMemGlobal::MAX_CREATOR_NAME_LENGTH) + + std::to_string(SharedMemGlobal::MAX_DOMAIN_NAME_LENGTH) + " characters"); } From 3220dc13807795cc5cc0bb43466bd1bd04cab7ec Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:46:10 +0200 Subject: [PATCH 14/20] Revert "Refs #19036. Increase `MAX_DOMAIN_NAME_LENGTH` and `CURRENT_ABI_VERSION`." This reverts commit 8077a512eb1a90c56652608e381e11231cdeabef. --- src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp index 19dd09b32c6..8a51d2f46b9 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp @@ -47,7 +47,7 @@ class SharedMemGlobal struct BufferDescriptor; // Long names for SHM files could cause problems on some platforms - static constexpr uint32_t MAX_DOMAIN_NAME_LENGTH = 255; + static constexpr uint32_t MAX_DOMAIN_NAME_LENGTH = 16; SharedMemGlobal( const std::string& domain_name) @@ -93,8 +93,8 @@ class SharedMemGlobal typedef MultiProducerConsumerRingBuffer::Listener Listener; typedef MultiProducerConsumerRingBuffer::Cell PortCell; - static const uint32_t CURRENT_ABI_VERSION = 6; - static_assert(CURRENT_ABI_VERSION == (3 + FASTDDS_VERSION_MAJOR), "ABI is not correct"); + static const uint32_t CURRENT_ABI_VERSION = 5; + static_assert(CURRENT_ABI_VERSION == (2 + FASTDDS_VERSION_MAJOR), "ABI is not correct"); static_assert(LOCATOR_KIND_SHM == (16 + FASTDDS_VERSION_MAJOR), "LOCATOR_KIND_SHM is not correct"); struct PortNode From bfb7538fbf5146041b2821575e1fc8ddda177118 Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Thu, 1 Aug 2024 12:14:23 +0200 Subject: [PATCH 15/20] Refs #19036: Change the address sent in case of shm transport from host id to user name Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --- .../rtps/transport/shared_mem/SHMLocator.hpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp b/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp index f13dd0002ec..4744f0fc8e7 100644 --- a/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp +++ b/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp @@ -17,6 +17,7 @@ #include #include +#include namespace eprosima { namespace fastdds { @@ -50,8 +51,17 @@ class SHMLocator locator.get_address()[0] = (type == Type::UNICAST) ? 'U' : 'M'; auto host_id = Host::instance().id(); - locator.get_address()[1] = octet(host_id); - locator.get_address()[2] = octet(host_id >> 8); + std::string user_name; + + if ((fastdds::dds::RETCODE_OK == SystemInfo::get_username(user_name)) && (user_name.length() <= 16)) + { + std::strcpy(reinterpret_cast(locator.address), user_name.c_str()); + } + else + { + locator.get_address()[1] = octet(host_id); + locator.get_address()[2] = octet(host_id >> 8); + } return locator; } @@ -67,8 +77,9 @@ class SHMLocator if (locator.kind == LOCATOR_KIND_SHM) { auto host_id = Host::instance().id(); - - return locator.address[1] == octet(host_id) && locator.address[2] == octet(host_id >> 8); + std::string user_name; + SystemInfo::get_username(user_name); + return ((std::memcmp(locator.address, user_name.c_str(), user_name.length()) == 0) || (locator.address[1] == octet(host_id) && locator.address[2] == octet(host_id >> 8))); } return false; From 15f49ab4aefc57717f92d1d795b282586d6db838 Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Thu, 1 Aug 2024 12:27:24 +0200 Subject: [PATCH 16/20] Refs #19036: Uncrustify Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --- src/cpp/rtps/transport/shared_mem/SHMLocator.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp b/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp index 4744f0fc8e7..39dc7082549 100644 --- a/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp +++ b/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp @@ -79,7 +79,9 @@ class SHMLocator auto host_id = Host::instance().id(); std::string user_name; SystemInfo::get_username(user_name); - return ((std::memcmp(locator.address, user_name.c_str(), user_name.length()) == 0) || (locator.address[1] == octet(host_id) && locator.address[2] == octet(host_id >> 8))); + return ((std::memcmp(locator.address, user_name.c_str(), + user_name.length()) == 0) || + (locator.address[1] == octet(host_id) && locator.address[2] == octet(host_id >> 8))); } return false; From 298b3c7d4c44523813701b80fda4de8b12366ba9 Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Thu, 1 Aug 2024 13:50:17 +0200 Subject: [PATCH 17/20] Refs #19036: Copy the user name in address starting from the second byte because the first is used for unicast info Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --- src/cpp/rtps/transport/shared_mem/SHMLocator.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp b/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp index 39dc7082549..c133a6028f4 100644 --- a/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp +++ b/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp @@ -53,9 +53,9 @@ class SHMLocator auto host_id = Host::instance().id(); std::string user_name; - if ((fastdds::dds::RETCODE_OK == SystemInfo::get_username(user_name)) && (user_name.length() <= 16)) + if ((fastdds::dds::RETCODE_OK == SystemInfo::get_username(user_name)) && (user_name.length() < 16)) { - std::strcpy(reinterpret_cast(locator.address), user_name.c_str()); + std::strcpy(reinterpret_cast(&locator.address[1]), user_name.c_str()); } else { @@ -79,7 +79,7 @@ class SHMLocator auto host_id = Host::instance().id(); std::string user_name; SystemInfo::get_username(user_name); - return ((std::memcmp(locator.address, user_name.c_str(), + return ((std::memcmp(&locator.address[1], user_name.c_str(), user_name.length()) == 0) || (locator.address[1] == octet(host_id) && locator.address[2] == octet(host_id >> 8))); } From ef973183de2a84d8b752c88f68a797b504aa17ab Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:23:06 +0200 Subject: [PATCH 18/20] Refs #19036: Add network_mode: and host ipc: host to make the containers communicate Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --- test/examples/configuration.compose.yml | 4 + test/examples/custom_payload_pool.compose.yml | 4 + .../delivery_mechanisms_isolated.compose.yml | 76 --------- test/examples/flow_control.compose.yml | 4 + test/examples/hello_world.compose.yml | 4 + test/examples/request_reply.compose.yml | 4 + test/examples/rtps.compose.yml | 8 + test/examples/security.compose.yml | 4 + .../examples/static_edp_discovery.compose.yml | 4 + .../test_delivery_mechanisms_isolated.py | 144 ------------------ test/examples/topic_instances.compose.yml | 4 + test/examples/xtypes_complete.compose.yml | 10 ++ test/examples/xtypes_minimal.compose.yml | 10 ++ 13 files changed, 60 insertions(+), 220 deletions(-) delete mode 100644 test/examples/delivery_mechanisms_isolated.compose.yml delete mode 100644 test/examples/test_delivery_mechanisms_isolated.py diff --git a/test/examples/configuration.compose.yml b/test/examples/configuration.compose.yml index f35dd6c3c00..79835caf303 100644 --- a/test/examples/configuration.compose.yml +++ b/test/examples/configuration.compose.yml @@ -26,6 +26,8 @@ services: EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/configuration FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/configuration/configuration_profile.xml SUBSCRIBER_ADDITIONAL_ARGUMENTS: ${SUB_ARGS} + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/configuration@FILE_EXTENSION@ subscriber --samples 10 $${SUBSCRIBER_ADDITIONAL_ARGUMENTS}" publisher-subscriber: @@ -41,4 +43,6 @@ services: FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/configuration/configuration_profile.xml PUBLISHER_ADDITIONAL_ARGUMENTS: ${PUB_ARGS} SUBSCRIBER_ADDITIONAL_ARGUMENTS: ${SUB_ARGS} + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/configuration@FILE_EXTENSION@ subscriber --samples 10 $${SUBSCRIBER_ADDITIONAL_ARGUMENTS} & $${EXAMPLE_DIR}/configuration@FILE_EXTENSION@ publisher --samples 10 --wait 2 $${PUBLISHER_ADDITIONAL_ARGUMENTS}" diff --git a/test/examples/custom_payload_pool.compose.yml b/test/examples/custom_payload_pool.compose.yml index bbccefb3c2e..79b1f520ec2 100644 --- a/test/examples/custom_payload_pool.compose.yml +++ b/test/examples/custom_payload_pool.compose.yml @@ -24,6 +24,8 @@ services: # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/custom_payload_pool + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/custom_payload_pool@FILE_EXTENSION@ subscriber --samples 10" publisher: @@ -36,6 +38,8 @@ services: # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/custom_payload_pool + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/custom_payload_pool@FILE_EXTENSION@ publisher --samples 10" depends_on: - subscriber diff --git a/test/examples/delivery_mechanisms_isolated.compose.yml b/test/examples/delivery_mechanisms_isolated.compose.yml deleted file mode 100644 index 124e3231edf..00000000000 --- a/test/examples/delivery_mechanisms_isolated.compose.yml +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -version: "3" - -services: - subscriber: - image: @DOCKER_IMAGE_NAME@ - volumes: - - @PROJECT_BINARY_DIR@:@PROJECT_BINARY_DIR@ - - @fastcdr_LIB_DIR@:@fastcdr_LIB_DIR@ - @TINYXML2_LIB_DIR_COMPOSE_VOLUME@ - environment: - # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows - LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ - EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/delivery_mechanisms - ISOLATED_SUBSCRIBER_ADDITIONAL_ARGUMENTS: ${ISUB_ARGS} - # avoid network and ipc host to isolate this subscriber for sharing memory with other containers - networks: - delivery_mechanisms_net: - ipv4_address: 113.1.1.2 - command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/delivery_mechanisms@FILE_EXTENSION@ subscriber --samples 10 $${ISOLATED_SUBSCRIBER_ADDITIONAL_ARGUMENTS}" - - publisher-subscriber: - image: @DOCKER_IMAGE_NAME@ - volumes: - - @PROJECT_BINARY_DIR@:@PROJECT_BINARY_DIR@ - - @fastcdr_LIB_DIR@:@fastcdr_LIB_DIR@ - @TINYXML2_LIB_DIR_COMPOSE_VOLUME@ - environment: - # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows - LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ - EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/delivery_mechanisms - PUBLISHER_ADDITIONAL_ARGUMENTS: ${PUB_ARGS} - SUBSCRIBER_ADDITIONAL_ARGUMENTS: ${SUB_ARGS} - # avoid network and ipc host to isolate this subscriber for sharing memory with other containers - networks: - delivery_mechanisms_net: - ipv4_address: 113.1.1.3 - command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/delivery_mechanisms@FILE_EXTENSION@ subscriber --samples 10 $${SUBSCRIBER_ADDITIONAL_ARGUMENTS} & $${EXAMPLE_DIR}/delivery_mechanisms@FILE_EXTENSION@ publisher --samples 10 $${PUBLISHER_ADDITIONAL_ARGUMENTS}" - - pubsub: - image: @DOCKER_IMAGE_NAME@ - volumes: - - @PROJECT_BINARY_DIR@:@PROJECT_BINARY_DIR@ - - @fastcdr_LIB_DIR@:@fastcdr_LIB_DIR@ - @TINYXML2_LIB_DIR_COMPOSE_VOLUME@ - environment: - # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows - LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ - EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/delivery_mechanisms - PUBSUB_ADDITIONAL_ARGUMENTS: ${PUBSUB_ARGS} - # avoid network and ipc host to isolate this subscriber for sharing memory with other containers - networks: - delivery_mechanisms_net: - ipv4_address: 113.1.1.4 - command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/delivery_mechanisms@FILE_EXTENSION@ pubsub --samples 10 $${PUBSUB_ADDITIONAL_ARGUMENTS}" - -networks: - delivery_mechanisms_net: - driver: bridge - ipam: - driver: default - config: - - subnet: 113.1.1.0/24 - gateway: 113.1.1.1 diff --git a/test/examples/flow_control.compose.yml b/test/examples/flow_control.compose.yml index 7a048e51d82..02404d4c4ae 100644 --- a/test/examples/flow_control.compose.yml +++ b/test/examples/flow_control.compose.yml @@ -25,6 +25,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/flow_control@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/flow_control/flow_control_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/flow_control@FILE_EXTENSION@ subscriber --samples 10" publisher: @@ -38,6 +40,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/flow_control FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/flow_control/flow_control_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/flow_control@FILE_EXTENSION@ publisher --samples 10 --period 500 --max-bytes 300000 --scheduler PRIORITY-RESERVATION --bandwidth 99 --priority 1" depends_on: - subscriber diff --git a/test/examples/hello_world.compose.yml b/test/examples/hello_world.compose.yml index affe3533b8a..7da6c0aeba3 100644 --- a/test/examples/hello_world.compose.yml +++ b/test/examples/hello_world.compose.yml @@ -25,6 +25,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/hello_world/hello_world_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ subscriber --waitset --samples 10" subscriber-publisher: @@ -38,6 +40,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/hello_world/hello_world_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ subscriber --samples 10 & $${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ publisher --samples 10" depends_on: - waitset-subscriber diff --git a/test/examples/request_reply.compose.yml b/test/examples/request_reply.compose.yml index d5399d18cc8..6661e12493c 100644 --- a/test/examples/request_reply.compose.yml +++ b/test/examples/request_reply.compose.yml @@ -25,6 +25,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/request_reply@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/request_reply/request_reply_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/request_reply@FILE_EXTENSION@ client 2 5 & timeout --preserve-status 3 $${EXAMPLE_DIR}/request_reply@FILE_EXTENSION@ server" alone-client: @@ -38,4 +40,6 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/request_reply@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/request_reply/request_reply_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/request_reply@FILE_EXTENSION@ client 67 24" diff --git a/test/examples/rtps.compose.yml b/test/examples/rtps.compose.yml index 0584a4ccda7..43620d0b8e2 100644 --- a/test/examples/rtps.compose.yml +++ b/test/examples/rtps.compose.yml @@ -24,6 +24,8 @@ services: # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/rtps@FILE_EXTENSION@ + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/rtps@FILE_EXTENSION@ reader --samples 20" sub-dds: @@ -37,6 +39,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/rtps/hello_world_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ subscriber --samples 20" pub-rtps: @@ -49,6 +53,8 @@ services: # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/rtps + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/rtps@FILE_EXTENSION@ writer --samples 10" depends_on: - sub-rtps @@ -65,6 +71,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/rtps/hello_world_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ publisher --samples 10" depends_on: - sub-rtps diff --git a/test/examples/security.compose.yml b/test/examples/security.compose.yml index 1abf5eddb90..d7a74c14114 100644 --- a/test/examples/security.compose.yml +++ b/test/examples/security.compose.yml @@ -26,6 +26,8 @@ services: EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/security CERTS_PATH: @PROJECT_BINARY_DIR@/examples/cpp/security/certs FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/security/secure_subscriber_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/security@FILE_EXTENSION@ subscriber --samples 10" publisher: @@ -40,5 +42,7 @@ services: EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/security CERTS_PATH: @PROJECT_BINARY_DIR@/examples/cpp/security/certs FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/security/secure_publisher_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/security@FILE_EXTENSION@ publisher --samples 10" diff --git a/test/examples/static_edp_discovery.compose.yml b/test/examples/static_edp_discovery.compose.yml index fd315d553ce..329c9e59bf4 100644 --- a/test/examples/static_edp_discovery.compose.yml +++ b/test/examples/static_edp_discovery.compose.yml @@ -25,6 +25,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/static_edp_discovery@FILE_EXTENSION@ XML_FILE: @PROJECT_BINARY_DIR@/examples/cpp/static_edp_discovery/HelloWorld_static_disc.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/static_edp_discovery@FILE_EXTENSION@ subscriber --samples 10 --xml $${XML_FILE}" subscriber-publisher: @@ -38,6 +40,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/static_edp_discovery XML_FILE: @PROJECT_BINARY_DIR@/examples/cpp/static_edp_discovery/HelloWorld_static_disc.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/static_edp_discovery@FILE_EXTENSION@ subscriber --samples 10 --xml $${XML_FILE} & $${EXAMPLE_DIR}/static_edp_discovery@FILE_EXTENSION@ publisher --samples 10 --xml $${XML_FILE}" depends_on: - subscriber diff --git a/test/examples/test_delivery_mechanisms_isolated.py b/test/examples/test_delivery_mechanisms_isolated.py deleted file mode 100644 index f69995c6d36..00000000000 --- a/test/examples/test_delivery_mechanisms_isolated.py +++ /dev/null @@ -1,144 +0,0 @@ -# Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import subprocess -import pytest - -isolated_delivery_test_cases = [ - # Default builtin transports (UDP forced) - ('', '-s 20', '-s 20', '', 50), - ('', '-s 20', '-s 20', '--ignore-local-endpoints', 50), - # Large-data with only one publisher (testing TCP) - ('--mechanism large-data', '--unknown-argument', '--mechanism large-data', '--unknown-argument', 10), - # TCP takes longer to match, so explicitly expect much more samples in this case. - # TCP is configured through initial peers (a single locator), so we test only one publisher at a time - # Note: pubsub with TCP and ignore-local-endpoints NOT set is not supported, tested in expected output test cases - ('-s 100 --mechanism tcpv4 -a 113.1.1.3', '-s 100 --mechanism tcpv4 -a 113.1.1.3', '-s 100 --mechanism tcpv4 -a 113.1.1.3', '--unknown-command', 200), - # UDP - ('--mechanism udpv4', '-s 20 --mechanism udpv4', '-s 20 --mechanism udpv4', '--mechanism udpv4', 50), - ('--mechanism udpv4', '-s 20 --mechanism udpv4', '-s 20 --mechanism udpv4', '--mechanism udpv4 --ignore-local-endpoints', 50), -] - -@pytest.mark.parametrize("pub_args, sub_args, isub_args, pubsub_args, repetitions", isolated_delivery_test_cases) -def test_delivery_mechanisms_isolated(pub_args, sub_args, isub_args, pubsub_args, repetitions): - """.""" - ret = False - out = '' - - command_prerequisites = 'PUB_ARGS="' + pub_args + '" SUB_ARGS="' + sub_args + '" ISUB_ARGS="' + isub_args + '" PUBSUB_ARGS="' + pubsub_args + '" ' - try: - out = subprocess.check_output(command_prerequisites + '/usr/bin/docker compose -f delivery_mechanisms_isolated.compose.yml up', - stderr=subprocess.STDOUT, - shell=True, - timeout=30 - ).decode().split('\n') - - sent = 0 - received = 0 - for line in out: - if 'SENT' in line: - sent += 1 - - if 'RECEIVED' in line: - received += 1 - - if sent != 0 and received != 0 and repetitions == received: - ret = True - else: - print('ERROR: sent: ' + str(sent) + ', but received: ' + str(received) + - ' (expected: ' + str(repetitions) + ')') - raise subprocess.CalledProcessError(1, '') - - except subprocess.CalledProcessError: - for l in out: - print(l) - except subprocess.TimeoutExpired: - print('TIMEOUT') - print(out) - - assert(ret) - -isolated_timeout_test_cases = [ - # Shared memory and data-sharing isolated subscriber timeout test cases - ('--mechanism shm', '--unknown-command', '--mechanism shm', '--mechanism shm -i'), - ('--mechanism data-sharing', '--unknown-command', '--mechanism data-sharing', '--mechanism data-sharing -i'), - # Incompatible mechanisms timeout test cases - ('--mechanism tcpv4', '--mechanism udpv4', '--mechanism udpv6', '--mechanism tcpv6 -i'), - ('--mechanism shm', '--mechanism data-sharing', '--mechanism large-data', '--mechanism intra-process -i') -] - -@pytest.mark.parametrize("pub_args, sub_args, isub_args, pubsub_args", isolated_timeout_test_cases) -def test_delivery_mechanisms_isolated_timeout(pub_args, sub_args, isub_args, pubsub_args): - """.""" - ret = False - out = '' - - command_prerequisites = 'PUB_ARGS="' + pub_args + '" SUB_ARGS="' + sub_args + '" ISUB_ARGS="' + isub_args + '" PUBSUB_ARGS="' + pubsub_args + '" ' - try: - out = subprocess.check_output(command_prerequisites + '/usr/bin/docker compose -f delivery_mechanisms_isolated.compose.yml up', - stderr=subprocess.STDOUT, - shell=True, - timeout=10 - ) - except subprocess.CalledProcessError as e: - print (e.output) - except subprocess.TimeoutExpired: - ret = True - subprocess.check_output('/usr/bin/docker compose -f delivery_mechanisms_isolated.compose.yml down', - stderr=subprocess.STDOUT, - shell=True, - timeout=15 - ) - - assert(ret) - -# Unsupported delivery mechanisms corner case test -isolated_expected_output_test_cases = [ - ('--unknown-argument', '--unknown-argument', '--mechanism tcp', 'Unsupported', 1) -] - -@pytest.mark.parametrize("pub_args, sub_args, pubsub_args, expected_message, n_messages", isolated_expected_output_test_cases) -def test_delivery_mechanisms_isolated_expected_output(pub_args, sub_args, pubsub_args, expected_message, n_messages): - """.""" - ret = False - out = '' - render_out = '' - - command_prerequisites = 'PUB_ARGS="' + pub_args + '" SUB_ARGS="' + sub_args + '" ISUB_ARGS="' + sub_args + '" PUBSUB_ARGS="' + pubsub_args + '" ' - try: - out = subprocess.check_output(command_prerequisites + '/usr/bin/docker compose -f delivery_mechanisms_isolated.compose.yml up', - stderr=subprocess.STDOUT, - shell=True, - timeout=20 - ) - render_out = out.decode().split('\n') - - count = 0 - for line in render_out: - if expected_message in line: - count += 1 - - if count >= int(n_messages): - ret = True - else: - print ('ERROR: expected at least: ' + n_messages +' "' + expected_message + '" messages, but received ' + str(count)) - raise subprocess.CalledProcessError(1, render_out) - - except subprocess.CalledProcessError as e: - print (render_out) - except subprocess.TimeoutExpired: - print('TIMEOUT') - print(out) - - assert(ret) diff --git a/test/examples/topic_instances.compose.yml b/test/examples/topic_instances.compose.yml index c18b85ea48c..8a4622318d4 100644 --- a/test/examples/topic_instances.compose.yml +++ b/test/examples/topic_instances.compose.yml @@ -25,6 +25,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/topic_instances SUBSCRIBER_ADDITIONAL_ARGUMENTS: ${SUB_ARGS} + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "sleep 5 && $${EXAMPLE_DIR}/topic_instances@FILE_EXTENSION@ subscriber --samples 10 $${SUBSCRIBER_ADDITIONAL_ARGUMENTS}" publisher-subscriber: @@ -39,4 +41,6 @@ services: EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/topic_instances PUBLISHER_ADDITIONAL_ARGUMENTS: ${PUB_ARGS} SUBSCRIBER_ADDITIONAL_ARGUMENTS: ${SUB_ARGS} + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/topic_instances@FILE_EXTENSION@ subscriber --samples 10 $${SUBSCRIBER_ADDITIONAL_ARGUMENTS} & $${EXAMPLE_DIR}/topic_instances@FILE_EXTENSION@ publisher --samples 10 $${PUBLISHER_ADDITIONAL_ARGUMENTS}" diff --git a/test/examples/xtypes_complete.compose.yml b/test/examples/xtypes_complete.compose.yml index 6f8ec00de66..ba4f25fed32 100644 --- a/test/examples/xtypes_complete.compose.yml +++ b/test/examples/xtypes_complete.compose.yml @@ -25,6 +25,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/xtypes@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/xtypes/xtypes_complete_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/xtypes@FILE_EXTENSION@ subscriber --samples 30" xtypes-subscriber-publisher: @@ -38,6 +40,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/xtypes FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/xtypes/xtypes_complete_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/xtypes@FILE_EXTENSION@ subscriber --samples 30 & $${EXAMPLE_DIR}/xtypes@FILE_EXTENSION@ publisher --samples 10" depends_on: - xtypes-subscriber @@ -54,6 +58,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/hello_world/hello_world_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ subscriber --samples 30" helloworld-publisher: @@ -67,6 +73,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/hello_world/hello_world_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ publisher --samples 10" depends_on: - xtypes-subscriber @@ -83,6 +91,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/xtypes@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/xtypes/xtypes_complete_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/xtypes@FILE_EXTENSION@ publisher --samples 10 --xml-type" depends_on: - xtypes-subscriber diff --git a/test/examples/xtypes_minimal.compose.yml b/test/examples/xtypes_minimal.compose.yml index c141f768a0a..41b3a693a3b 100644 --- a/test/examples/xtypes_minimal.compose.yml +++ b/test/examples/xtypes_minimal.compose.yml @@ -25,6 +25,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/xtypes@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/xtypes/xtypes_minimal_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/xtypes@FILE_EXTENSION@ subscriber --samples 30" xtypes-subscriber-publisher: @@ -38,6 +40,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/xtypes FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/xtypes/xtypes_minimal_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/xtypes@FILE_EXTENSION@ subscriber --samples 30 & $${EXAMPLE_DIR}/xtypes@FILE_EXTENSION@ publisher --samples 10" depends_on: - xtypes-subscriber @@ -54,6 +58,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/hello_world/hello_world_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ subscriber --samples 30" helloworld-publisher: @@ -67,6 +73,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/hello_world/hello_world_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ publisher --samples 10" depends_on: - xtypes-subscriber @@ -83,6 +91,8 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/xtypes@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/xtypes/xtypes_minimal_profile.xml + network_mode: host + ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/xtypes@FILE_EXTENSION@ publisher --samples 10 --xml-type" depends_on: - xtypes-subscriber From 7d9d6b3405afb70372fb15fa4d10c48bb5921e91 Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:38:09 +0200 Subject: [PATCH 19/20] Refs #19036: Solve build issue in windows Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --- src/cpp/rtps/transport/shared_mem/SHMLocator.hpp | 2 +- test/examples/xtypes_minimal.compose.yml | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp b/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp index c133a6028f4..3cdd3f4b7d8 100644 --- a/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp +++ b/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp @@ -55,7 +55,7 @@ class SHMLocator if ((fastdds::dds::RETCODE_OK == SystemInfo::get_username(user_name)) && (user_name.length() < 16)) { - std::strcpy(reinterpret_cast(&locator.address[1]), user_name.c_str()); + std::memcpy(&locator.address[1], user_name.c_str(), user_name.length()); } else { diff --git a/test/examples/xtypes_minimal.compose.yml b/test/examples/xtypes_minimal.compose.yml index 41b3a693a3b..a7e29dbbb17 100644 --- a/test/examples/xtypes_minimal.compose.yml +++ b/test/examples/xtypes_minimal.compose.yml @@ -73,8 +73,7 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/hello_world/hello_world_profile.xml - network_mode: host - ipc: host + command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ publisher --samples 10" depends_on: - xtypes-subscriber @@ -91,8 +90,6 @@ services: LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/xtypes@FILE_EXTENSION@ FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/xtypes/xtypes_minimal_profile.xml - network_mode: host - ipc: host command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/xtypes@FILE_EXTENSION@ publisher --samples 10 --xml-type" depends_on: - xtypes-subscriber From bcd5d61b43fb031f194971f75f9cdcb542b5be6f Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Fri, 2 Aug 2024 13:49:20 +0200 Subject: [PATCH 20/20] use shm locator's addres MD5 mangling host id and user name Signed-off-by: Mario Dominguez --- .../rtps/transport/shared_mem/SHMLocator.hpp | 21 +++------------ .../transport/shared_mem/SharedMemGlobal.hpp | 1 + src/cpp/utils/SystemInfo.cpp | 27 +++++++++++++++++++ src/cpp/utils/SystemInfo.hpp | 10 +++++++ test/unittest/dds/collections/CMakeLists.txt | 1 + .../dds/core/condition/CMakeLists.txt | 1 + test/unittest/dds/core/entity/CMakeLists.txt | 1 + test/unittest/dds/publisher/CMakeLists.txt | 1 + test/unittest/dds/subscriber/CMakeLists.txt | 1 + test/unittest/logging/CMakeLists.txt | 1 + .../logging/log_macros/CMakeLists.txt | 1 + test/unittest/rtps/common/CMakeLists.txt | 1 + test/unittest/rtps/flowcontrol/CMakeLists.txt | 1 + test/unittest/rtps/history/CMakeLists.txt | 4 +++ test/unittest/rtps/persistence/CMakeLists.txt | 3 ++- test/unittest/rtps/reader/CMakeLists.txt | 3 +++ .../rtps/resources/timedevent/CMakeLists.txt | 1 + test/unittest/rtps/security/CMakeLists.txt | 1 + test/unittest/rtps/writer/CMakeLists.txt | 2 ++ .../security/accesscontrol/CMakeLists.txt | 1 + .../security/authentication/CMakeLists.txt | 2 +- .../security/cryptography/CMakeLists.txt | 1 + test/unittest/security/logging/CMakeLists.txt | 1 + test/unittest/utils/CMakeLists.txt | 3 +++ 24 files changed, 70 insertions(+), 20 deletions(-) diff --git a/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp b/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp index 3cdd3f4b7d8..f48eb040180 100644 --- a/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp +++ b/src/cpp/rtps/transport/shared_mem/SHMLocator.hpp @@ -50,18 +50,7 @@ class SHMLocator locator.get_address()[0] = (type == Type::UNICAST) ? 'U' : 'M'; - auto host_id = Host::instance().id(); - std::string user_name; - - if ((fastdds::dds::RETCODE_OK == SystemInfo::get_username(user_name)) && (user_name.length() < 16)) - { - std::memcpy(&locator.address[1], user_name.c_str(), user_name.length()); - } - else - { - locator.get_address()[1] = octet(host_id); - locator.get_address()[2] = octet(host_id >> 8); - } + memcpy(&locator.get_address()[1], SystemInfo::get_username_host_id_md5_digest(), 15u); return locator; } @@ -76,12 +65,8 @@ class SHMLocator { if (locator.kind == LOCATOR_KIND_SHM) { - auto host_id = Host::instance().id(); - std::string user_name; - SystemInfo::get_username(user_name); - return ((std::memcmp(&locator.address[1], user_name.c_str(), - user_name.length()) == 0) || - (locator.address[1] == octet(host_id) && locator.address[2] == octet(host_id >> 8))); + return ((std::memcmp(&locator.address[1], SystemInfo::get_username_host_id_md5_digest(), + 15u) == 0)); } return false; diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp index 8a51d2f46b9..98d19d53e34 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemGlobal.hpp @@ -1106,6 +1106,7 @@ class SharedMemGlobal if (port_node) { + std::cout << "open_portinternal " << domain_name_ << " port domain name " << port_node->domain_name << std::endl; port = std::make_shared(std::move(port_segment), port_node); } else diff --git a/src/cpp/utils/SystemInfo.cpp b/src/cpp/utils/SystemInfo.cpp index 3cefd7f3208..ebf25c2b056 100644 --- a/src/cpp/utils/SystemInfo.cpp +++ b/src/cpp/utils/SystemInfo.cpp @@ -152,6 +152,30 @@ fastdds::dds::ReturnCode_t SystemInfo::get_username( #endif // _WIN32 } +const unsigned char* SystemInfo::get_username_host_id_md5_digest() +{ + if (!username_host_id_md5_digest_initialized_) + { + std::lock_guard lock_guard(username_host_id_digest_mtx_); + if (!username_host_id_md5_digest_initialized_) + { + // Initialize user name and host id + auto host_id = Host::instance().id(); + std::string user_name_and_host_id; + + get_username(user_name_and_host_id); + user_name_and_host_id += std::to_string(host_id); + + username_host_id_md5_.init(); + username_host_id_md5_.update(user_name_and_host_id.c_str(), user_name_and_host_id.length()); + username_host_id_md5_.finalize(); + username_host_id_md5_digest_initialized_.store(true); + } + } + + return username_host_id_md5_.digest; +} + bool SystemInfo::file_exists( const std::string& filename) { @@ -332,6 +356,9 @@ std::string SystemInfo::environment_file_; bool SystemInfo::cached_interfaces_; std::vector SystemInfo::interfaces_; std::mutex SystemInfo::interfaces_mtx_; +std::atomic SystemInfo::username_host_id_md5_digest_initialized_{false}; +std::mutex SystemInfo::username_host_id_digest_mtx_; +fastdds::MD5 SystemInfo::username_host_id_md5_; } // eprosima diff --git a/src/cpp/utils/SystemInfo.hpp b/src/cpp/utils/SystemInfo.hpp index 2d8a6f26f52..dc924dcafc0 100644 --- a/src/cpp/utils/SystemInfo.hpp +++ b/src/cpp/utils/SystemInfo.hpp @@ -146,6 +146,13 @@ class SystemInfo static ReturnCode_t get_username( std::string& username); + /** + * Gets the resulting md5 digest of th user name and host id + * + * * \param [out] user_host_digest array of octets to store the digest + */ + static const unsigned char* get_username_host_id_md5_digest(); + /** * Check if the file with name \c filename exists. * \c filename can also include the path to the file. @@ -266,6 +273,9 @@ class SystemInfo static bool cached_interfaces_; static std::vector interfaces_; static std::mutex interfaces_mtx_; + static std::atomic username_host_id_md5_digest_initialized_; + static std::mutex username_host_id_digest_mtx_; + static fastdds::MD5 username_host_id_md5_; }; /** diff --git a/test/unittest/dds/collections/CMakeLists.txt b/test/unittest/dds/collections/CMakeLists.txt index dc02374062f..9b1be315651 100644 --- a/test/unittest/dds/collections/CMakeLists.txt +++ b/test/unittest/dds/collections/CMakeLists.txt @@ -27,6 +27,7 @@ set(LOANABLE_SEQUENCE_TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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 LoanableSequenceTests.cpp) diff --git a/test/unittest/dds/core/condition/CMakeLists.txt b/test/unittest/dds/core/condition/CMakeLists.txt index ee706bc6843..38af3609869 100644 --- a/test/unittest/dds/core/condition/CMakeLists.txt +++ b/test/unittest/dds/core/condition/CMakeLists.txt @@ -13,6 +13,7 @@ # limitations under the License. set(LOG_SOURCES + ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp ) diff --git a/test/unittest/dds/core/entity/CMakeLists.txt b/test/unittest/dds/core/entity/CMakeLists.txt index c1b0ccde1d7..4e38013da8f 100644 --- a/test/unittest/dds/core/entity/CMakeLists.txt +++ b/test/unittest/dds/core/entity/CMakeLists.txt @@ -33,6 +33,7 @@ set(ENTITY_TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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 EntityTests.cpp) diff --git a/test/unittest/dds/publisher/CMakeLists.txt b/test/unittest/dds/publisher/CMakeLists.txt index 4c789efab33..a73806bbc24 100644 --- a/test/unittest/dds/publisher/CMakeLists.txt +++ b/test/unittest/dds/publisher/CMakeLists.txt @@ -187,6 +187,7 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/StringMatching.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/UnitsParser.cpp diff --git a/test/unittest/dds/subscriber/CMakeLists.txt b/test/unittest/dds/subscriber/CMakeLists.txt index 657bb10ea5c..067f77794be 100644 --- a/test/unittest/dds/subscriber/CMakeLists.txt +++ b/test/unittest/dds/subscriber/CMakeLists.txt @@ -39,6 +39,7 @@ set(DATAREADERHISTORYTESTS_SOURCE DataReaderHistoryTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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 ) diff --git a/test/unittest/logging/CMakeLists.txt b/test/unittest/logging/CMakeLists.txt index b1b25cc5a1e..468b24bfbe1 100644 --- a/test/unittest/logging/CMakeLists.txt +++ b/test/unittest/logging/CMakeLists.txt @@ -29,6 +29,7 @@ set(LOG_COMMON_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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 ) diff --git a/test/unittest/logging/log_macros/CMakeLists.txt b/test/unittest/logging/log_macros/CMakeLists.txt index e3db7631f3a..5112d58fb1a 100644 --- a/test/unittest/logging/log_macros/CMakeLists.txt +++ b/test/unittest/logging/log_macros/CMakeLists.txt @@ -27,6 +27,7 @@ set(LOG_COMMON_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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 ) diff --git a/test/unittest/rtps/common/CMakeLists.txt b/test/unittest/rtps/common/CMakeLists.txt index f048ff687ec..9dece0c7097 100644 --- a/test/unittest/rtps/common/CMakeLists.txt +++ b/test/unittest/rtps/common/CMakeLists.txt @@ -56,6 +56,7 @@ set(PORTPARAMETERSTESTS_SOURCE PortParametersTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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(TIMETESTS_SOURCE TimeTests.cpp diff --git a/test/unittest/rtps/flowcontrol/CMakeLists.txt b/test/unittest/rtps/flowcontrol/CMakeLists.txt index 9a4e66b82ef..96c3c001c3b 100644 --- a/test/unittest/rtps/flowcontrol/CMakeLists.txt +++ b/test/unittest/rtps/flowcontrol/CMakeLists.txt @@ -31,6 +31,7 @@ set(FLOWCONTROLLER_COMMON_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LocatorSelectorSender.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 ) diff --git a/test/unittest/rtps/history/CMakeLists.txt b/test/unittest/rtps/history/CMakeLists.txt index c5f8fb1401b..a1bd7a9ab89 100644 --- a/test/unittest/rtps/history/CMakeLists.txt +++ b/test/unittest/rtps/history/CMakeLists.txt @@ -27,6 +27,7 @@ set(READERHISTORYTESTS_SOURCE ReaderHistoryTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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(BASICPOOLSTESTS_SOURCE BasicPoolsTests.cpp @@ -42,6 +43,7 @@ set(BASICPOOLSTESTS_SOURCE BasicPoolsTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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(CACHECHANGEPOOLTESTS_SOURCE CacheChangePoolTests.cpp @@ -57,6 +59,7 @@ set(CACHECHANGEPOOLTESTS_SOURCE CacheChangePoolTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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(TOPICPAYLOADPOOLTESTS_SOURCE @@ -74,6 +77,7 @@ set(TOPICPAYLOADPOOLTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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) if(WIN32) diff --git a/test/unittest/rtps/persistence/CMakeLists.txt b/test/unittest/rtps/persistence/CMakeLists.txt index 879f919d4bf..ee90d1efb70 100644 --- a/test/unittest/rtps/persistence/CMakeLists.txt +++ b/test/unittest/rtps/persistence/CMakeLists.txt @@ -34,7 +34,8 @@ if(SQLITE3_SUPPORT) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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 + ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp ) add_executable(PersistenceTests ${PERSISTENCETESTS_SOURCE}) diff --git a/test/unittest/rtps/reader/CMakeLists.txt b/test/unittest/rtps/reader/CMakeLists.txt index c3fdc14045c..095e2af203c 100644 --- a/test/unittest/rtps/reader/CMakeLists.txt +++ b/test/unittest/rtps/reader/CMakeLists.txt @@ -32,6 +32,7 @@ set(WRITERPROXYTESTS_SOURCE WriterProxyTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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 ) @@ -85,6 +86,7 @@ set(WRITERPROXYSTOPTEST_SOURCE WriterProxyStopTest.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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 ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp ) @@ -136,6 +138,7 @@ set(WRITERPROXYACKNACKTESTS_SOURCE WriterProxyAcknackTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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 ) diff --git a/test/unittest/rtps/resources/timedevent/CMakeLists.txt b/test/unittest/rtps/resources/timedevent/CMakeLists.txt index ad5f0ccf35b..8ec2a1d91f6 100644 --- a/test/unittest/rtps/resources/timedevent/CMakeLists.txt +++ b/test/unittest/rtps/resources/timedevent/CMakeLists.txt @@ -27,6 +27,7 @@ set(TIMEDEVENTTESTS_SOURCE mock/MockEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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 ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp) diff --git a/test/unittest/rtps/security/CMakeLists.txt b/test/unittest/rtps/security/CMakeLists.txt index f9d624847b6..80d876b565c 100644 --- a/test/unittest/rtps/security/CMakeLists.txt +++ b/test/unittest/rtps/security/CMakeLists.txt @@ -48,6 +48,7 @@ set(SOURCES_SECURITY_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/security/cryptography/AESGCMGMAC_Types.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 ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp ${PROJECT_SOURCE_DIR}/test/mock/rtps/SecurityPluginFactory/rtps/security/SecurityPluginFactory.cpp diff --git a/test/unittest/rtps/writer/CMakeLists.txt b/test/unittest/rtps/writer/CMakeLists.txt index 3e83e12a8e1..74930428c1d 100644 --- a/test/unittest/rtps/writer/CMakeLists.txt +++ b/test/unittest/rtps/writer/CMakeLists.txt @@ -29,6 +29,7 @@ set(WRITERPROXYTESTS_SOURCE ReaderProxyTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/ReaderProxy.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) if(WIN32) @@ -86,6 +87,7 @@ set(LIVELINESSMANAGERTESTS_SOURCE LivelinessManagerTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp) add_executable(LivelinessManagerTests ${LIVELINESSMANAGERTESTS_SOURCE}) diff --git a/test/unittest/security/accesscontrol/CMakeLists.txt b/test/unittest/security/accesscontrol/CMakeLists.txt index c984cf476b7..8e05c7947c5 100644 --- a/test/unittest/security/accesscontrol/CMakeLists.txt +++ b/test/unittest/security/accesscontrol/CMakeLists.txt @@ -142,6 +142,7 @@ add_executable( ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp # Log related files + ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp # test files diff --git a/test/unittest/security/authentication/CMakeLists.txt b/test/unittest/security/authentication/CMakeLists.txt index b7dfe3fee1d..fd0b2d11138 100644 --- a/test/unittest/security/authentication/CMakeLists.txt +++ b/test/unittest/security/authentication/CMakeLists.txt @@ -54,9 +54,9 @@ add_executable(BuiltinPKIDH ${COMMON_SOURCES_AUTH_PLUGIN_TEST_SOURCE} ${PROJECT_SOURCE_DIR}/src/cpp/security/authentication/PKIHandshakeHandle.cpp ${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/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 ${CMAKE_CURRENT_SOURCE_DIR}/BuiltinPKIDHTests.cpp) target_compile_definitions(BuiltinPKIDH PRIVATE diff --git a/test/unittest/security/cryptography/CMakeLists.txt b/test/unittest/security/cryptography/CMakeLists.txt index 5a077833d3e..6cf60ccaea2 100644 --- a/test/unittest/security/cryptography/CMakeLists.txt +++ b/test/unittest/security/cryptography/CMakeLists.txt @@ -38,6 +38,7 @@ set(COMMON_SOURCES_CRYPTO_PLUGIN_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/security/cryptography/AESGCMGMAC.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 ) diff --git a/test/unittest/security/logging/CMakeLists.txt b/test/unittest/security/logging/CMakeLists.txt index 6cb05fbca7f..97ec464c57a 100644 --- a/test/unittest/security/logging/CMakeLists.txt +++ b/test/unittest/security/logging/CMakeLists.txt @@ -31,6 +31,7 @@ set(COMMON_SOURCES_LOGGING_PLUGIN_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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 ) diff --git a/test/unittest/utils/CMakeLists.txt b/test/unittest/utils/CMakeLists.txt index d9848256f0c..754161b55e2 100644 --- a/test/unittest/utils/CMakeLists.txt +++ b/test/unittest/utils/CMakeLists.txt @@ -29,6 +29,7 @@ set(STRINGMATCHINGTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/StringMatching.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp) set(BITMAPRANGETESTS_SOURCE @@ -49,6 +50,7 @@ set(LOCATORTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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(FIXEDSIZEQUEUETESTS_SOURCE @@ -66,6 +68,7 @@ set(SYSTEMINFOTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.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