diff --git a/include/fastdds/rtps/transport/TransportInterface.h b/include/fastdds/rtps/transport/TransportInterface.h index 60dec2d299f..517ac9c46fc 100644 --- a/include/fastdds/rtps/transport/TransportInterface.h +++ b/include/fastdds/rtps/transport/TransportInterface.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -135,6 +136,29 @@ class RTPS_DllAPI TransportInterface SendResourceList& sender_resource_list, const Locator&) = 0; + /** + * Must open the channel that maps to/from the given locator selector entry. This method must allocate, + * reserve and mark any resources that are needed for said channel. + * + * @param sender_resource_list Participant's send resource list. + * @param locator_selector_entry Locator selector entry with the remote entity locators. + * + * @return true if the channel was correctly opened or if finding an already opened one. + */ + virtual bool OpenOutputChannels( + SendResourceList& sender_resource_list, + const fastrtps::rtps::LocatorSelectorEntry& locator_selector_entry); + + /** + * Close the channel that maps to/from the given locator selector entry. + * + * @param sender_resource_list Participant's send resource list. + * @param locator_selector_entry Locator selector entry with the remote entity locators. + */ + virtual void CloseOutputChannels( + SendResourceList& sender_resource_list, + const fastrtps::rtps::LocatorSelectorEntry& locator_selector_entry); + /** Opens an input channel to receive incoming connections. * If there is an existing channel it registers the receiver interface. */ diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index c82588394b3..94d6b578bed 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -124,6 +124,7 @@ set(${PROJECT_NAME}_source_files fastdds/builtin/typelookup/TypeLookupManager.cpp fastdds/builtin/typelookup/TypeLookupRequestListener.cpp fastdds/builtin/typelookup/TypeLookupReplyListener.cpp + rtps/transport/TransportInterface.cpp rtps/transport/ChainingTransport.cpp rtps/transport/ChannelResource.cpp rtps/transport/PortBasedTransportDescriptor.cpp diff --git a/src/cpp/rtps/network/NetworkFactory.cpp b/src/cpp/rtps/network/NetworkFactory.cpp index 1773038cfa4..61271de95f1 100644 --- a/src/cpp/rtps/network/NetworkFactory.cpp +++ b/src/cpp/rtps/network/NetworkFactory.cpp @@ -477,12 +477,14 @@ void NetworkFactory::remove_participant_associated_send_resources( const LocatorList_t& remote_participant_locators, const LocatorList_t& participant_initial_peers) const { + // TODO(eduponz): Call the overload of CloseOutputChannel that takes a LocatorSelectorEntry for + // all transports and let them decide what to do. for (auto& transport : mRegisteredTransports) { TCPTransportInterface* tcp_transport = dynamic_cast(transport.get()); if (tcp_transport) { - tcp_transport->CloseOutputChannel( + tcp_transport->cleanup_sender_resources( send_resource_list, remote_participant_locators, participant_initial_peers); diff --git a/src/cpp/rtps/transport/TCPTransportInterface.cpp b/src/cpp/rtps/transport/TCPTransportInterface.cpp index ba7c2c46170..bc82b04f907 100644 --- a/src/cpp/rtps/transport/TCPTransportInterface.cpp +++ b/src/cpp/rtps/transport/TCPTransportInterface.cpp @@ -1888,7 +1888,7 @@ void TCPTransportInterface::fill_local_physical_port( } } -void TCPTransportInterface::CloseOutputChannel( +void TCPTransportInterface::cleanup_sender_resources( SendResourceList& send_resource_list, const LocatorList& remote_participant_locators, const LocatorList& participant_initial_peers) const diff --git a/src/cpp/rtps/transport/TCPTransportInterface.h b/src/cpp/rtps/transport/TCPTransportInterface.h index a796a2b401f..31a5a58cee2 100644 --- a/src/cpp/rtps/transport/TCPTransportInterface.h +++ b/src/cpp/rtps/transport/TCPTransportInterface.h @@ -480,7 +480,7 @@ class TCPTransportInterface : public TransportInterface * @param remote_participant_locators Set of locators associated to the remote participant. * @param participant_initial_peers List of locators associated to the initial peers of the local participant. */ - void CloseOutputChannel( + void cleanup_sender_resources( SendResourceList& send_resource_list, const LocatorList& remote_participant_locators, const LocatorList& participant_initial_peers) const; diff --git a/src/cpp/rtps/transport/TransportInterface.cpp b/src/cpp/rtps/transport/TransportInterface.cpp new file mode 100644 index 00000000000..a108682a999 --- /dev/null +++ b/src/cpp/rtps/transport/TransportInterface.cpp @@ -0,0 +1,53 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { + +using LocatorSelectorEntry = fastrtps::rtps::LocatorSelectorEntry; + +bool TransportInterface::OpenOutputChannels( + SendResourceList& send_resource_list, + const LocatorSelectorEntry& locator_selector_entry) +{ + bool success = false; + for (size_t i = 0; i < locator_selector_entry.state.multicast.size(); ++i) + { + size_t index = locator_selector_entry.state.multicast[i]; + success |= OpenOutputChannel(send_resource_list, locator_selector_entry.multicast[index]); + } + for (size_t i = 0; i < locator_selector_entry.state.unicast.size(); ++i) + { + size_t index = locator_selector_entry.state.unicast[i]; + success |= OpenOutputChannel(send_resource_list, locator_selector_entry.unicast[index]); + } + return success; +} + +void TransportInterface::CloseOutputChannels( + SendResourceList& sender_resource_list, + const fastrtps::rtps::LocatorSelectorEntry& locator_selector_entry) +{ + static_cast(sender_resource_list); + static_cast(locator_selector_entry); +} + +} // namespace rtps +} // namespace fastrtps +} // namespace eprosima diff --git a/test/unittest/dds/publisher/CMakeLists.txt b/test/unittest/dds/publisher/CMakeLists.txt index dfa667f5691..3bd42f2e22d 100644 --- a/test/unittest/dds/publisher/CMakeLists.txt +++ b/test/unittest/dds/publisher/CMakeLists.txt @@ -166,6 +166,7 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/RTPSDomain.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/SharedMemTransportDescriptor.cpp diff --git a/test/unittest/rtps/discovery/CMakeLists.txt b/test/unittest/rtps/discovery/CMakeLists.txt index 52fcaf6541a..0b3c3137d15 100644 --- a/test/unittest/rtps/discovery/CMakeLists.txt +++ b/test/unittest/rtps/discovery/CMakeLists.txt @@ -103,6 +103,7 @@ gtest_discover_tests(EdpTests) #PDP TESTS set(TCPTransportInterface_SOURCE + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageCreator.cpp diff --git a/test/unittest/rtps/network/CMakeLists.txt b/test/unittest/rtps/network/CMakeLists.txt index e09a47ebd80..c2bd3151ea9 100644 --- a/test/unittest/rtps/network/CMakeLists.txt +++ b/test/unittest/rtps/network/CMakeLists.txt @@ -29,6 +29,7 @@ set(NETWORKFACTORYTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp diff --git a/test/unittest/statistics/dds/CMakeLists.txt b/test/unittest/statistics/dds/CMakeLists.txt index 9e6b862fc10..eace6ddeb7e 100644 --- a/test/unittest/statistics/dds/CMakeLists.txt +++ b/test/unittest/statistics/dds/CMakeLists.txt @@ -241,6 +241,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/RTPSDomain.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/SharedMemTransportDescriptor.cpp @@ -433,6 +434,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPAcceptor.cpp @@ -671,4 +673,3 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) gtest_discover_tests(StatisticsDomainParticipantStatusQueryableTests) endif (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) - diff --git a/test/unittest/statistics/rtps/CMakeLists.txt b/test/unittest/statistics/rtps/CMakeLists.txt index 5bbb555cd27..4a997149ec9 100644 --- a/test/unittest/statistics/rtps/CMakeLists.txt +++ b/test/unittest/statistics/rtps/CMakeLists.txt @@ -44,6 +44,7 @@ target_link_libraries(RTPSStatisticsTests fastrtps fastcdr GTest::gtest GTest::g gtest_discover_tests(RTPSStatisticsTests) set(TCPTransportInterface_SOURCE + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageCreator.cpp diff --git a/test/unittest/transport/CMakeLists.txt b/test/unittest/transport/CMakeLists.txt index 05f83080b4b..eff0c9ecdd6 100644 --- a/test/unittest/transport/CMakeLists.txt +++ b/test/unittest/transport/CMakeLists.txt @@ -76,6 +76,7 @@ set(UDPV4TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPChannelResource.cpp @@ -99,6 +100,7 @@ set(UDPV6TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPChannelResource.cpp @@ -129,6 +131,7 @@ set(TCPV4TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp @@ -172,6 +175,7 @@ set(TCPV6TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp @@ -210,6 +214,7 @@ set(SHAREDMEMTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp diff --git a/test/unittest/transport/TCPv4Tests.cpp b/test/unittest/transport/TCPv4Tests.cpp index 83b37f45a57..f0125f170db 100644 --- a/test/unittest/transport/TCPv4Tests.cpp +++ b/test/unittest/transport/TCPv4Tests.cpp @@ -2116,7 +2116,7 @@ TEST_F(TCPv4Tests, remove_from_send_resource_list) IPLocator::setWan(wrong_output_locator, g_test_wan_address); } wrong_remote_participant_physical_locators.push_back(wrong_output_locator); - send_transport_under_test.CloseOutputChannel( + send_transport_under_test.cleanup_sender_resources( send_resource_list, wrong_remote_participant_physical_locators, initial_peer_list); @@ -2125,7 +2125,7 @@ TEST_F(TCPv4Tests, remove_from_send_resource_list) // Using the correct locator should remove the channel resource LocatorList_t remote_participant_physical_locators; remote_participant_physical_locators.push_back(discovery_locator); - send_transport_under_test.CloseOutputChannel( + send_transport_under_test.cleanup_sender_resources( send_resource_list, remote_participant_physical_locators, initial_peer_list); @@ -2140,7 +2140,7 @@ TEST_F(TCPv4Tests, remove_from_send_resource_list) IPLocator::setWan(initial_peer_locator, g_test_wan_address); } remote_participant_physical_locators.push_back(initial_peer_locator); - send_transport_under_test.CloseOutputChannel( + send_transport_under_test.cleanup_sender_resources( send_resource_list, remote_participant_physical_locators, initial_peer_list); diff --git a/test/unittest/transport/TCPv6Tests.cpp b/test/unittest/transport/TCPv6Tests.cpp index 7ac66b84e8c..7486ed20468 100644 --- a/test/unittest/transport/TCPv6Tests.cpp +++ b/test/unittest/transport/TCPv6Tests.cpp @@ -527,7 +527,7 @@ TEST_F(TCPv6Tests, remove_from_send_resource_list) IPLocator::createLocator(LOCATOR_KIND_TCPv6, "::1", g_default_port + 2, wrong_output_locator); IPLocator::setLogicalPort(wrong_output_locator, 7410); wrong_remote_participant_physical_locators.push_back(wrong_output_locator); - send_transport_under_test.CloseOutputChannel( + send_transport_under_test.cleanup_sender_resources( send_resource_list, wrong_remote_participant_physical_locators, initial_peer_list); @@ -536,7 +536,7 @@ TEST_F(TCPv6Tests, remove_from_send_resource_list) // Using the correct locator should remove the channel resource LocatorList_t remote_participant_physical_locators; remote_participant_physical_locators.push_back(output_locator_1); - send_transport_under_test.CloseOutputChannel( + send_transport_under_test.cleanup_sender_resources( send_resource_list, remote_participant_physical_locators, initial_peer_list); @@ -545,7 +545,7 @@ TEST_F(TCPv6Tests, remove_from_send_resource_list) // Using the initial peer locator should not remove the channel resource remote_participant_physical_locators.clear(); remote_participant_physical_locators.push_back(output_locator_2); - send_transport_under_test.CloseOutputChannel( + send_transport_under_test.cleanup_sender_resources( send_resource_list, remote_participant_physical_locators, initial_peer_list); diff --git a/versions.md b/versions.md index 9dafef49ef3..f14306e3473 100644 --- a/versions.md +++ b/versions.md @@ -3,6 +3,7 @@ Forthcoming Migrate communication tests in `dds/communication` folder * Added authentication handshake properties. +* Added methods OpenOutputChannels and CloseOutputChannels to TransportInterface with LocatorSelectorEntry argument. Version 2.13.0 --------------