Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20492] OpenOutputChannels / CloseOutputChannels that receive a LocatorSelectorEntry #4411

Merged
merged 11 commits into from
Mar 6, 2024
24 changes: 24 additions & 0 deletions include/fastdds/rtps/transport/TransportInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <fastdds/rtps/attributes/PropertyPolicy.h>
#include <fastdds/rtps/common/Locator.h>
#include <fastdds/rtps/common/LocatorSelector.hpp>
#include <fastdds/rtps/common/LocatorSelectorEntry.hpp>
#include <fastdds/rtps/common/PortParameters.h>
#include <fastdds/rtps/transport/SenderResource.h>
#include <fastdds/rtps/transport/TransportDescriptorInterface.h>
Expand Down Expand Up @@ -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.
*/
Expand Down
1 change: 1 addition & 0 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/cpp/rtps/network/NetworkFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TCPTransportInterface*>(transport.get());
if (tcp_transport)
{
tcp_transport->CloseOutputChannel(
tcp_transport->cleanup_sender_resources(
send_resource_list,
remote_participant_locators,
participant_initial_peers);
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/transport/TCPTransportInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/transport/TCPTransportInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
53 changes: 53 additions & 0 deletions src/cpp/rtps/transport/TransportInterface.cpp
Original file line number Diff line number Diff line change
@@ -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 <fastdds/rtps/transport/TransportInterface.h>

#include <fastdds/rtps/common/LocatorSelectorEntry.hpp>

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<void>(sender_resource_list);
static_cast<void>(locator_selector_entry);
}

} // namespace rtps
} // namespace fastrtps
} // namespace eprosima
1 change: 1 addition & 0 deletions test/unittest/dds/publisher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/unittest/rtps/discovery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/unittest/rtps/network/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/unittest/statistics/dds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

1 change: 1 addition & 0 deletions test/unittest/statistics/rtps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/unittest/transport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/unittest/transport/TCPv4Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions test/unittest/transport/TCPv6Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------
Expand Down
Loading