Skip to content

Commit 4aa8f99

Browse files
committed
Avoid ABI/API break by adding new private interface
Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>
1 parent 3c20725 commit 4aa8f99

20 files changed

Lines changed: 120 additions & 151 deletions

include/fastdds/rtps/transport/ChainingTransport.hpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,6 @@ class ChainingTransport : public TransportInterface
227227
return low_level_transport_->getDefaultMetatrafficMulticastLocators(locators, metatraffic_multicast_port);
228228
}
229229

230-
/**
231-
* Call the low-level transport `getDefaultMulticastLocators()`.
232-
* Add multicast locator with the given port
233-
*/
234-
FASTDDS_EXPORTED_API bool getDefaultMulticastLocators(
235-
fastdds::rtps::LocatorList_t& locators,
236-
uint32_t multicast_port) const override
237-
{
238-
return low_level_transport_->getDefaultMulticastLocators(locators, multicast_port);
239-
}
240-
241230
/*!
242231
* Call the low-level transport `getDefaultMetatrafficUnicastLocators()`.
243232
* Add metatraffic unicast locator with the given port
@@ -295,17 +284,6 @@ class ChainingTransport : public TransportInterface
295284
return low_level_transport_->configureInitialPeerLocator(locator, port_params, domainId, list);
296285
}
297286

298-
/**
299-
* Call the low-level transport `fillMulticastLocator()`.
300-
* Assign default values (address and port) to the given multicast locator if not already defined
301-
*/
302-
FASTDDS_EXPORTED_API bool fillMulticastLocator(
303-
fastdds::rtps::Locator_t& locator,
304-
uint32_t well_known_port) const override
305-
{
306-
return low_level_transport_->fillMulticastLocator(locator, well_known_port);
307-
}
308-
309287
/*!
310288
* Call the low-level transport `fillUnicastLocator()`.
311289
* Assign port to the given unicast locator if not already defined

include/fastdds/rtps/transport/TransportInterface.hpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,6 @@ class FASTDDS_EXPORTED_API TransportInterface
245245
LocatorList& locators,
246246
uint32_t unicast_port) const = 0;
247247

248-
//! Add multicast locator with the given port
249-
virtual bool getDefaultMulticastLocators(
250-
LocatorList& locators,
251-
uint32_t multicast_port) const = 0;
252-
253248
//! Assign port to the given metatraffic multicast locator if not already defined
254249
virtual bool fillMetatrafficMulticastLocator(
255250
Locator& locator,
@@ -276,14 +271,6 @@ class FASTDDS_EXPORTED_API TransportInterface
276271
Locator& locator,
277272
uint32_t well_known_port) const = 0;
278273

279-
/**
280-
* Assign default multicast values to a locator if the transport supports them
281-
* and if they are not already defined.
282-
*/
283-
virtual bool fillMulticastLocator(
284-
Locator& locator,
285-
uint32_t well_known_port) const = 0;
286-
287274
/**
288275
* @return The maximum datagram size for reception supported by the transport
289276
*/

src/cpp/rtps/network/NetworkFactory.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <fastdds/utils/IPLocator.hpp>
2626

2727
#include <rtps/network/NetworkConfiguration.hpp>
28+
#include <rtps/transport/MulticastTransportInterface.h>
2829
#include <rtps/transport/TCPTransportInterface.h>
2930

3031
using namespace std;
@@ -495,7 +496,12 @@ bool NetworkFactory::getDefaultMulticastLocators(
495496
bool result = false;
496497
for (auto& transport : mRegisteredTransports)
497498
{
498-
result |= transport->getDefaultMulticastLocators(locators, port);
499+
const MulticastTransportInterface* multicast_transport =
500+
dynamic_cast<const MulticastTransportInterface*>(transport.get());
501+
if (multicast_transport)
502+
{
503+
result |= multicast_transport->getDefaultMulticastLocators(locators, port);
504+
}
499505
}
500506
return result;
501507
}
@@ -524,7 +530,12 @@ bool NetworkFactory::fill_default_multicast_locator(
524530
{
525531
if (transport->IsLocatorSupported(locator))
526532
{
527-
result |= transport->fillMulticastLocator(locator, port);
533+
const MulticastTransportInterface* multicast_transport =
534+
dynamic_cast<const MulticastTransportInterface*>(transport.get());
535+
if (multicast_transport)
536+
{
537+
result |= multicast_transport->fillMulticastLocator(locator, port);
538+
}
528539
}
529540
}
530541
return result;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2026 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <rtps/transport/MulticastTransportInterface.h>
16+
17+
#include <fastdds/utils/IPLocator.hpp>
18+
19+
namespace eprosima {
20+
namespace fastdds {
21+
namespace rtps {
22+
23+
bool MulticastTransportInterface::fillMulticastLocator(
24+
Locator& locator,
25+
uint32_t well_known_port) const
26+
{
27+
LocatorList defaults;
28+
getDefaultMulticastLocators(defaults, well_known_port);
29+
if (!defaults.empty())
30+
{
31+
const Locator& default_loc = *defaults.begin();
32+
if (locator.port == 0)
33+
{
34+
locator.port = default_loc.port;
35+
}
36+
if (!IsAddressDefined(locator))
37+
{
38+
IPLocator::copy_address(default_loc, locator);
39+
}
40+
}
41+
42+
return true;
43+
}
44+
45+
} // namespace rtps
46+
} // namespace fastdds
47+
} // namespace eprosima
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2026 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef _FASTDDS_MULTICAST_TRANSPORT_INTERFACE_H_
16+
#define _FASTDDS_MULTICAST_TRANSPORT_INTERFACE_H_
17+
18+
#include <cstdint>
19+
20+
#include <fastdds/rtps/common/Locator.hpp>
21+
#include <fastdds/rtps/common/LocatorList.hpp>
22+
23+
namespace eprosima {
24+
namespace fastdds {
25+
namespace rtps {
26+
27+
class MulticastTransportInterface
28+
{
29+
public:
30+
31+
virtual ~MulticastTransportInterface() = default;
32+
33+
virtual bool getDefaultMulticastLocators(
34+
LocatorList& locators,
35+
uint32_t multicast_port) const = 0;
36+
37+
virtual bool fillMulticastLocator(
38+
Locator& locator,
39+
uint32_t well_known_port) const;
40+
};
41+
42+
} // namespace rtps
43+
} // namespace fastdds
44+
} // namespace eprosima
45+
46+
#endif // _FASTDDS_MULTICAST_TRANSPORT_INTERFACE_H_

src/cpp/rtps/transport/TCPTransportInterface.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,14 +1693,6 @@ bool TCPTransportInterface::getDefaultMetatrafficMulticastLocators(
16931693
return false;
16941694
}
16951695

1696-
bool TCPTransportInterface::getDefaultMulticastLocators(
1697-
LocatorList&,
1698-
uint32_t ) const
1699-
{
1700-
// TCP doesn't have multicast support
1701-
return false;
1702-
}
1703-
17041696
bool TCPTransportInterface::getDefaultMetatrafficUnicastLocators(
17051697
LocatorList& locators,
17061698
uint32_t metatraffic_unicast_port) const
@@ -1733,14 +1725,6 @@ bool TCPTransportInterface::fillMetatrafficMulticastLocator(
17331725
return false;
17341726
}
17351727

1736-
bool TCPTransportInterface::fillMulticastLocator(
1737-
Locator&,
1738-
uint32_t) const
1739-
{
1740-
// TCP doesn't have multicast support
1741-
return false;
1742-
}
1743-
17441728
bool TCPTransportInterface::fillMetatrafficUnicastLocator(
17451729
Locator& locator,
17461730
uint32_t metatraffic_unicast_port) const

src/cpp/rtps/transport/TCPTransportInterface.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -468,14 +468,6 @@ class TCPTransportInterface : public TransportInterface
468468
LocatorList& locators,
469469
uint32_t unicast_port) const override;
470470

471-
/**
472-
* This method should never be called because TCP interfaces do not support
473-
* multicast locators. It always returns false
474-
*/
475-
bool getDefaultMulticastLocators(
476-
LocatorList& locators,
477-
uint32_t multicast_port) const override;
478-
479471
/**
480472
* This method should never be called because TCP interfaces do not support
481473
* multicast locators. It always returns false
@@ -498,14 +490,6 @@ class TCPTransportInterface : public TransportInterface
498490
Locator& locator,
499491
uint32_t well_known_port) const override;
500492

501-
/**
502-
* This method should never be called because TCP interfaces do not support
503-
* multicast locators. It always returns false
504-
*/
505-
bool fillMulticastLocator(
506-
Locator& locator,
507-
uint32_t well_known_port) const override;
508-
509493
uint32_t max_recv_buffer_size() const override
510494
{
511495
return configuration()->maxMessageSize;

src/cpp/rtps/transport/UDPTransportInterface.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -796,27 +796,6 @@ bool UDPTransportInterface::fillUnicastLocator(
796796
return true;
797797
}
798798

799-
bool UDPTransportInterface::fillMulticastLocator(
800-
Locator& locator,
801-
uint32_t well_known_port) const
802-
{
803-
LocatorList defaults;
804-
getDefaultMulticastLocators(defaults, well_known_port);
805-
if (!defaults.empty())
806-
{
807-
const Locator& default_loc = *defaults.begin();
808-
if (locator.port == 0)
809-
{
810-
locator.port = default_loc.port;
811-
}
812-
if (!IsAddressDefined(locator))
813-
{
814-
IPLocator::copy_address(default_loc, locator);
815-
}
816-
}
817-
return true;
818-
}
819-
820799
void UDPTransportInterface::get_unknown_network_interfaces(
821800
const SendResourceList& sender_resource_list,
822801
std::vector<IPFinder::info_IP>& locNames,

src/cpp/rtps/transport/UDPTransportInterface.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@
2929
#include <fastdds/rtps/transport/UDPTransportDescriptor.hpp>
3030
#include <fastdds/utils/IPFinder.hpp>
3131

32+
#include <rtps/transport/MulticastTransportInterface.h>
3233
#include <rtps/transport/UDPChannelResource.h>
3334
#include <statistics/rtps/messages/OutputTrafficManager.hpp>
3435

3536
namespace eprosima {
3637
namespace fastdds {
3738
namespace rtps {
3839

39-
class UDPTransportInterface : public TransportInterface
40+
class UDPTransportInterface
41+
: public TransportInterface
42+
, public MulticastTransportInterface
4043
{
4144
friend class UDPSenderResource;
4245
friend struct TSN_UDPSender;
@@ -180,18 +183,6 @@ class UDPTransportInterface : public TransportInterface
180183
uint32_t domainId,
181184
LocatorList& list) const override;
182185

183-
/**
184-
* Assign default multicast values to a locator if they are not already defined.
185-
* This means setting both the address and the port to the default multicast
186-
* values for each version of UDP
187-
*
188-
* @param locator Locator to be filled with default multicast values if not already defined.
189-
* @param well_known_port Port to be used if the locator port is not already defined.
190-
*/
191-
bool fillMulticastLocator(
192-
Locator& locator,
193-
uint32_t well_known_port) const override;
194-
195186
bool fillUnicastLocator(
196187
Locator& locator,
197188
uint32_t well_known_port) const override;

src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,6 @@ bool SharedMemTransport::getDefaultMetatrafficUnicastLocators(
9696
return true;
9797
}
9898

99-
bool SharedMemTransport::getDefaultMulticastLocators(
100-
LocatorList& locators,
101-
uint32_t multicast_port) const
102-
{
103-
static_cast<void>(locators);
104-
static_cast<void>(multicast_port);
105-
return false;
106-
}
107-
10899
bool SharedMemTransport::getDefaultUnicastLocators(
109100
LocatorList& locators,
110101
uint32_t unicast_port) const
@@ -763,15 +754,6 @@ bool SharedMemTransport::fillUnicastLocator(
763754
return true;
764755
}
765756

766-
bool SharedMemTransport::fillMulticastLocator(
767-
Locator& locator,
768-
uint32_t well_known_port) const
769-
{
770-
static_cast<void>(locator);
771-
static_cast<void>(well_known_port);
772-
return false;
773-
}
774-
775757
} // namsepace rtps
776758
} // namespace fastdds
777759
} // namespace eprosima

0 commit comments

Comments
 (0)