| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
TransportInterface.hpp
1// Copyright 2019 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
19
20#ifndef FASTDDS_RTPS_TRANSPORT__TRANSPORTINTERFACE_HPP
21#define FASTDDS_RTPS_TRANSPORT__TRANSPORTINTERFACE_HPP
22
23#include <memory>
24#include <vector>
25
26#include <fastdds/rtps/attributes/PropertyPolicy.hpp>
27#include <fastdds/rtps/common/Locator.hpp>
28#include <fastdds/rtps/common/LocatorList.hpp>
29#include <fastdds/rtps/common/LocatorSelector.hpp>
30#include <fastdds/rtps/common/LocatorSelectorEntry.hpp>
31#include <fastdds/rtps/common/LocatorWithMask.hpp>
32#include <fastdds/rtps/common/PortParameters.hpp>
33#include <fastdds/rtps/transport/network/AllowedNetworkInterface.hpp>
34#include <fastdds/rtps/transport/network/NetmaskFilterKind.hpp>
35#include <fastdds/rtps/transport/SenderResource.hpp>
36#include <fastdds/rtps/transport/TransportDescriptorInterface.hpp>
37#include <fastdds/rtps/transport/TransportReceiverInterface.hpp>
38
39 namespace eprosima {
40 namespace fastdds {
41 namespace rtps {
42
44 constexpr uint32_t s_maximumMessageSize = 65500;
46 constexpr uint32_t s_maximumInitialPeersRange = 4;
48 static const std::string s_IPv4AddressAny = "0.0.0.0";
50 static const std::string s_IPv6AddressAny = "::";
51
52 using SendResourceList = std::vector<std::unique_ptr<fastdds::rtps::SenderResource>>;
53 using NetmaskFilterInfo = std::pair<NetmaskFilterKind, std::vector<AllowedNetworkInterface>>;
54 using TransportNetmaskFilterInfo = std::pair<int32_t, NetmaskFilterInfo>;
55
63 class FASTDDS_EXPORTED_API TransportInterface
64{
65 public:
66
77 virtual ~TransportInterface() = default;
78
80 TransportInterface(
81 const TransportInterface& t) = delete;
82
84 TransportInterface& operator =(
85 const TransportInterface& t) = delete;
86
88 TransportInterface(
89 TransportInterface&& t) = delete;
90
92 TransportInterface& operator =(
93 TransportInterface&& t) = delete;
94
101 virtual bool init(
102 const fastdds::rtps::PropertyPolicy* properties = nullptr,
103 const uint32_t& max_msg_size_no_frag = 0) = 0;
104
109 virtual bool IsInputChannelOpen(
110 const Locator&) const = 0;
111
113 virtual bool IsLocatorSupported(
114 const Locator&) const = 0;
115
117 virtual bool is_locator_allowed(
118 const Locator&) const = 0;
119
127 virtual bool is_locator_reachable(
128 const Locator_t& locator) = 0;
129
130
132 virtual Locator RemoteToMainLocal(
133 const Locator& remote) const = 0;
134
146 virtual bool transform_remote_locator(
147 const Locator& remote_locator,
148 Locator& result_locator) const
149 {
150 (void)remote_locator;
151 (void)result_locator;
152 return false;
153 }
154
157 virtual bool OpenOutputChannel(
158 SendResourceList& sender_resource_list,
159 const Locator&) = 0;
160
170 virtual bool OpenOutputChannels(
171 SendResourceList& sender_resource_list,
172 const fastdds::rtps::LocatorSelectorEntry& locator_selector_entry);
173
180 virtual void CloseOutputChannels(
181 SendResourceList& sender_resource_list,
182 const fastdds::rtps::LocatorSelectorEntry& locator_selector_entry);
183
187 virtual bool OpenInputChannel(
188 const Locator&,
189 TransportReceiverInterface*,
190 uint32_t) = 0;
191
197 virtual bool CloseInputChannel(
198 const Locator&) = 0;
199
201 virtual bool DoInputLocatorsMatch(
202 const Locator&,
203 const Locator&) const = 0;
204
206 virtual LocatorList NormalizeLocator(
207 const Locator& locator) = 0;
208
219 virtual void select_locators(
220 fastdds::rtps::LocatorSelector& selector) const = 0;
221
223 virtual bool is_local_locator(
224 const Locator& locator) const = 0;
225
227 virtual TransportDescriptorInterface* get_configuration() = 0;
228
230 virtual void AddDefaultOutputLocator(
231 LocatorList& defaultList) = 0;
232
234 virtual bool getDefaultMetatrafficMulticastLocators(
235 LocatorList& locators,
236 uint32_t metatraffic_multicast_port) const = 0;
237
239 virtual bool getDefaultMetatrafficUnicastLocators(
240 LocatorList& locators,
241 uint32_t metatraffic_unicast_port) const = 0;
242
244 virtual bool getDefaultUnicastLocators(
245 LocatorList& locators,
246 uint32_t unicast_port) const = 0;
247
249 virtual bool fillMetatrafficMulticastLocator(
250 Locator& locator,
251 uint32_t metatraffic_multicast_port) const = 0;
252
254 virtual bool fillMetatrafficUnicastLocator(
255 Locator& locator,
256 uint32_t metatraffic_unicast_port) const = 0;
257
259 virtual bool configureInitialPeerLocator(
260 Locator& locator,
261 const fastdds::rtps::PortParameters& port_params,
262 uint32_t domainId,
263 LocatorList& list) const = 0;
264
266 virtual bool fillUnicastLocator(
267 Locator& locator,
268 uint32_t well_known_port) const = 0;
269
273 virtual uint32_t max_recv_buffer_size() const = 0;
274
278 virtual void shutdown()
279 {
280 }
281
285 virtual void update_network_interfaces()
286 {
287 }
288
290 int32_t kind() const
291 {
292 return transport_kind_;
293 }
294
308 virtual bool transform_remote_locator(
309 const Locator& remote_locator,
310 Locator& result_locator,
311 bool allowed_remote_localhost,
312 bool allowed_local_localhost) const
313 {
314 static_cast<void>(allowed_remote_localhost);
315 static_cast<void>(allowed_local_localhost);
316 return transform_remote_locator(remote_locator, result_locator);
317 }
318
320 virtual bool is_localhost_allowed() const
321 {
322 return false;
323 }
324
326 virtual NetmaskFilterInfo netmask_filter_info() const
327 {
328 return {NetmaskFilterKind::AUTO, {}};
329 }
330
331 protected:
332
333 TransportInterface(
334 int32_t transport_kind)
335 : transport_kind_(transport_kind)
336 {
337 }
338
339 int32_t transport_kind_;
340};
341
342} // namespace rtps
343} // namespace fastdds
344} // namespace eprosima
345
346#endif // FASTDDS_RTPS_TRANSPORT__TRANSPORTINTERFACE_HPP
eprosima::fastdds::rtps::Locator_t
Class Locator_t, uniquely identifies a communication channel for a particular transport.
Definition Locator.hpp:71
eprosima::fastdds::rtps::LocatorList
Class LocatorList, a Locator vector that doesn't allow duplicates.
Definition LocatorList.hpp:97
eprosima::fastdds::rtps::LocatorSelector
A class used for the efficient selection of locators when sending data to multiple entities.
Definition LocatorSelector.hpp:55
eprosima::fastdds::rtps::PortParameters
Class PortParameters, to define the port parameters and gains related with the RTPS protocol.
Definition PortParameters.hpp:35
eprosima::fastdds::rtps::PropertyPolicy
Definition PropertyPolicy.hpp:30
eprosima::fastdds::rtps::TransportInterface::shutdown
virtual void shutdown()
Shutdown method to close the connections of the transports.
Definition TransportInterface.hpp:278
eprosima::fastdds::rtps::TransportInterface::is_local_locator
virtual bool is_local_locator(const Locator &locator) const =0
Must report whether the given locator is from the local host.
eprosima::fastdds::rtps::TransportInterface::is_locator_allowed
virtual bool is_locator_allowed(const Locator &) const =0
Must report whether the given locator is allowed by this transport.
eprosima::fastdds::rtps::TransportInterface::CloseOutputChannels
virtual void CloseOutputChannels(SendResourceList &sender_resource_list, const fastdds::rtps::LocatorSelectorEntry &locator_selector_entry)
Close the channel that maps to/from the given locator selector entry.
eprosima::fastdds::rtps::TransportInterface::transport_kind_
int32_t transport_kind_
Definition TransportInterface.hpp:339
eprosima::fastdds::rtps::TransportInterface::init
virtual bool init(const fastdds::rtps::PropertyPolicy *properties=nullptr, const uint32_t &max_msg_size_no_frag=0)=0
Initialize this transport.
eprosima::fastdds::rtps::TransportInterface::RemoteToMainLocal
virtual Locator RemoteToMainLocal(const Locator &remote) const =0
Returns the locator describing the main (most general) channel that can write to the provided remote ...
eprosima::fastdds::rtps::TransportInterface::DoInputLocatorsMatch
virtual bool DoInputLocatorsMatch(const Locator &, const Locator &) const =0
Must report whether two locators map to the same internal channel.
eprosima::fastdds::rtps::TransportInterface::getDefaultMetatrafficUnicastLocators
virtual bool getDefaultMetatrafficUnicastLocators(LocatorList &locators, uint32_t metatraffic_unicast_port) const =0
Add metatraffic unicast locator with the given port.
eprosima::fastdds::rtps::TransportInterface::AddDefaultOutputLocator
virtual void AddDefaultOutputLocator(LocatorList &defaultList)=0
Add default output locator to the locator list.
eprosima::fastdds::rtps::TransportInterface::NormalizeLocator
virtual LocatorList NormalizeLocator(const Locator &locator)=0
Performs locator normalization (assign valid IP if not defined by user).
eprosima::fastdds::rtps::TransportInterface::IsInputChannelOpen
virtual bool IsInputChannelOpen(const Locator &) const =0
Must report whether the input channel associated to this locator is open.
eprosima::fastdds::rtps::TransportInterface::getDefaultUnicastLocators
virtual bool getDefaultUnicastLocators(LocatorList &locators, uint32_t unicast_port) const =0
Add unicast locator with the given port.
eprosima::fastdds::rtps::TransportInterface::is_localhost_allowed
virtual bool is_localhost_allowed() const
Must report whether localhost locator is allowed.
Definition TransportInterface.hpp:320
eprosima::fastdds::rtps::TransportInterface::TransportInterface
TransportInterface(const TransportInterface &t)=delete
Copy constructor.
eprosima::fastdds::rtps::TransportInterface::fillMetatrafficMulticastLocator
virtual bool fillMetatrafficMulticastLocator(Locator &locator, uint32_t metatraffic_multicast_port) const =0
Assign port to the given metatraffic multicast locator if not already defined.
eprosima::fastdds::rtps::TransportInterface::netmask_filter_info
virtual NetmaskFilterInfo netmask_filter_info() const
Returns netmask filter information (transport's netmask filter kind and allowlist).
Definition TransportInterface.hpp:326
eprosima::fastdds::rtps::TransportInterface::CloseInputChannel
virtual bool CloseInputChannel(const Locator &)=0
Must close the channel that maps to/from the given locator.
eprosima::fastdds::rtps::TransportInterface::OpenOutputChannel
virtual bool OpenOutputChannel(SendResourceList &sender_resource_list, const Locator &)=0
Must open the channel that maps to/from the given locator.
eprosima::fastdds::rtps::TransportInterface::getDefaultMetatrafficMulticastLocators
virtual bool getDefaultMetatrafficMulticastLocators(LocatorList &locators, uint32_t metatraffic_multicast_port) const =0
Add metatraffic multicast locator with the given port.
eprosima::fastdds::rtps::TransportInterface::TransportInterface
TransportInterface(TransportInterface &&t)=delete
Move constructor.
eprosima::fastdds::rtps::TransportInterface::OpenOutputChannels
virtual bool OpenOutputChannels(SendResourceList &sender_resource_list, const fastdds::rtps::LocatorSelectorEntry &locator_selector_entry)
Must open the channel that maps to/from the given locator selector entry.
eprosima::fastdds::rtps::TransportInterface::kind
int32_t kind() const
Return the transport kind.
Definition TransportInterface.hpp:290
eprosima::fastdds::rtps::TransportInterface::fillUnicastLocator
virtual bool fillUnicastLocator(Locator &locator, uint32_t well_known_port) const =0
Assign port to the given unicast locator if not already defined.
eprosima::fastdds::rtps::TransportInterface::~TransportInterface
virtual ~TransportInterface()=default
Aside from the API defined here, an user-defined Transport must define a descriptor data type and a c...
eprosima::fastdds::rtps::TransportInterface::transform_remote_locator
virtual bool transform_remote_locator(const Locator &remote_locator, Locator &result_locator) const
Transforms a remote locator into a locator optimized for local communications.
Definition TransportInterface.hpp:146
eprosima::fastdds::rtps::TransportInterface::IsLocatorSupported
virtual bool IsLocatorSupported(const Locator &) const =0
Must report whether the given locator is supported by this transport (typically inspecting its "kind"...
eprosima::fastdds::rtps::TransportInterface::OpenInputChannel
virtual bool OpenInputChannel(const Locator &, TransportReceiverInterface *, uint32_t)=0
Opens an input channel to receive incoming connections.
eprosima::fastdds::rtps::TransportInterface::fillMetatrafficUnicastLocator
virtual bool fillMetatrafficUnicastLocator(Locator &locator, uint32_t metatraffic_unicast_port) const =0
Assign port to the given metatraffic unicast locator if not already defined.
eprosima::fastdds::rtps::TransportInterface::update_network_interfaces
virtual void update_network_interfaces()
Update network interfaces.
Definition TransportInterface.hpp:285
eprosima::fastdds::rtps::TransportInterface::transform_remote_locator
virtual bool transform_remote_locator(const Locator &remote_locator, Locator &result_locator, bool allowed_remote_localhost, bool allowed_local_localhost) const
Transforms a remote locator into a locator optimized for local communications.
Definition TransportInterface.hpp:308
eprosima::fastdds::rtps::TransportInterface::is_locator_reachable
virtual bool is_locator_reachable(const Locator_t &locator)=0
Must report whether the given locator is reachable by this transport.
eprosima::fastdds::rtps::TransportInterface::TransportInterface
TransportInterface(int32_t transport_kind)
Definition TransportInterface.hpp:333
eprosima::fastdds::rtps::TransportInterface::get_configuration
virtual TransportDescriptorInterface * get_configuration()=0
Return the transport configuration (Transport Descriptor).
eprosima::fastdds::rtps::TransportInterface::max_recv_buffer_size
virtual uint32_t max_recv_buffer_size() const =0
eprosima::fastdds::rtps::TransportInterface::configureInitialPeerLocator
virtual bool configureInitialPeerLocator(Locator &locator, const fastdds::rtps::PortParameters &port_params, uint32_t domainId, LocatorList &list) const =0
Configure the initial peer locators list.
eprosima::fastdds::rtps::TransportInterface::select_locators
virtual void select_locators(fastdds::rtps::LocatorSelector &selector) const =0
Performs the locator selection algorithm for this transport.
eprosima::fastdds::rtps::TransportReceiverInterface
Interface against which to implement a data receiver, decoupled from transport internals.
Definition TransportReceiverInterface.hpp:34
eprosima::fastdds::rtps
Contains the RTPS protocol implementation.
eprosima::fastdds::rtps::SendResourceList
std::vector< std::unique_ptr< fastdds::rtps::SenderResource > > SendResourceList
Definition TransportInterface.hpp:52
eprosima::fastdds::rtps::TransportNetmaskFilterInfo
std::pair< int32_t, NetmaskFilterInfo > TransportNetmaskFilterInfo
Definition TransportInterface.hpp:54
eprosima::fastdds::rtps::NetmaskFilterKind::AUTO
@ AUTO
Definition NetmaskFilterKind.hpp:33
eprosima::fastdds::rtps::s_maximumMessageSize
constexpr uint32_t s_maximumMessageSize
Default maximum message size.
Definition TransportInterface.hpp:44
eprosima::fastdds::rtps::s_IPv6AddressAny
static const std::string s_IPv6AddressAny
Default IPv6 address.
Definition TransportInterface.hpp:50
eprosima::fastdds::rtps::s_maximumInitialPeersRange
constexpr uint32_t s_maximumInitialPeersRange
Default maximum initial peers range.
Definition TransportInterface.hpp:46
eprosima::fastdds::rtps::s_IPv4AddressAny
static const std::string s_IPv4AddressAny
Default IPv4 address.
Definition TransportInterface.hpp:48
eprosima::fastdds::rtps::Locator
eprosima::fastdds::rtps::Locator_t Locator
Definition Locator.hpp:523
eprosima::fastdds::rtps::NetmaskFilterInfo
std::pair< NetmaskFilterKind, std::vector< AllowedNetworkInterface > > NetmaskFilterInfo
Definition TransportInterface.hpp:53
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::rtps::LocatorSelectorEntry
An entry for the LocatorSelector.
Definition LocatorSelectorEntry.hpp:39
eprosima::fastdds::rtps::TransportDescriptorInterface
Virtual base class for the data type used to define transport configuration.
Definition TransportDescriptorInterface.hpp:48