| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
ChainingTransport.hpp
1// Copyright 2021 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__CHAININGTRANSPORT_HPP
21#define FASTDDS_RTPS_TRANSPORT__CHAININGTRANSPORT_HPP
22
23#include <map>
24#include <memory>
25
26#include "TransportInterface.hpp"
27#include "ChainingTransportDescriptor.hpp"
28
29 namespace eprosima {
30 namespace fastdds {
31 namespace rtps {
32
33 class ChainingReceiverResource;
34
41 struct ChainingReceiverResourceDeleter
42{
43 void operator ()(
44 ChainingReceiverResource* p);
45};
46
48 using ChainingReceiverResourceReferenceType =
49 std::unique_ptr<ChainingReceiverResource, ChainingReceiverResourceDeleter>;
50
58 class ChainingTransport : public TransportInterface
59{
60
61 public:
62
64 FASTDDS_EXPORTED_API ChainingTransport(
65 const ChainingTransportDescriptor& t)
66 : TransportInterface(0)
67 , low_level_transport_(t.low_level_descriptor->create_transport())
68 {
69 transport_kind_ = low_level_transport_->kind();
70 }
71
73 FASTDDS_EXPORTED_API virtual ~ChainingTransport() = default;
74
81 FASTDDS_EXPORTED_API bool init(
82 const fastdds::rtps::PropertyPolicy* properties = nullptr,
83 const uint32_t& max_msg_size_no_frag = 0) override
84 {
85 return low_level_transport_->init(properties, max_msg_size_no_frag);
86 }
87
93 FASTDDS_EXPORTED_API bool IsInputChannelOpen(
94 const fastdds::rtps::Locator_t& loc) const override
95 {
96 return low_level_transport_->IsInputChannelOpen(loc);
97 }
98
103 FASTDDS_EXPORTED_API bool IsLocatorSupported(
104 const fastdds::rtps::Locator_t& loc) const override
105 {
106 return low_level_transport_->IsLocatorSupported(loc);
107 }
108
113 FASTDDS_EXPORTED_API fastdds::rtps::Locator_t RemoteToMainLocal(
114 const fastdds::rtps::Locator_t& loc) const override
115 {
116 return low_level_transport_->RemoteToMainLocal(loc);
117 }
118
124 FASTDDS_EXPORTED_API bool OpenInputChannel(
125 const fastdds::rtps::Locator_t& loc,
126 TransportReceiverInterface* receiver_interface,
127 uint32_t max_message_size) override;
128
134 FASTDDS_EXPORTED_API bool OpenOutputChannel(
135 SendResourceList& sender_resource_list,
136 const fastdds::rtps::Locator_t& loc) override;
137
144 FASTDDS_EXPORTED_API bool CloseInputChannel(
145 const fastdds::rtps::Locator_t& loc) override
146 {
147 return low_level_transport_->CloseInputChannel(loc);
148 }
149
154 FASTDDS_EXPORTED_API fastdds::rtps::LocatorList_t NormalizeLocator(
155 const fastdds::rtps::Locator_t& locator) override
156 {
157 return low_level_transport_->NormalizeLocator(locator);
158 }
159
164 FASTDDS_EXPORTED_API bool is_local_locator(
165 const fastdds::rtps::Locator_t& locator) const override
166 {
167 return low_level_transport_->is_local_locator(locator);
168 }
169
174 FASTDDS_EXPORTED_API bool is_localhost_allowed() const override
175 {
176 return low_level_transport_->is_localhost_allowed();
177 }
178
183 FASTDDS_EXPORTED_API NetmaskFilterInfo netmask_filter_info() const override
184 {
185 return low_level_transport_->netmask_filter_info();
186 }
187
192 FASTDDS_EXPORTED_API bool DoInputLocatorsMatch(
193 const fastdds::rtps::Locator_t& locator_1,
194 const fastdds::rtps::Locator_t& locator_2) const override
195 {
196 return low_level_transport_->DoInputLocatorsMatch(locator_1, locator_2);
197 }
198
203 FASTDDS_EXPORTED_API void select_locators(
204 fastdds::rtps::LocatorSelector& selector) const override
205 {
206 return low_level_transport_->select_locators(selector);
207 }
208
213 FASTDDS_EXPORTED_API void AddDefaultOutputLocator(
214 fastdds::rtps::LocatorList_t& defaultList) override
215 {
216 return low_level_transport_->AddDefaultOutputLocator(defaultList);
217 }
218
223 FASTDDS_EXPORTED_API bool getDefaultMetatrafficMulticastLocators(
224 fastdds::rtps::LocatorList_t& locators,
225 uint32_t metatraffic_multicast_port) const override
226 {
227 return low_level_transport_->getDefaultMetatrafficMulticastLocators(locators, metatraffic_multicast_port);
228 }
229
234 FASTDDS_EXPORTED_API bool getDefaultMetatrafficUnicastLocators(
235 fastdds::rtps::LocatorList_t& locators,
236 uint32_t metatraffic_unicast_port) const override
237 {
238 return low_level_transport_->getDefaultMetatrafficUnicastLocators(locators, metatraffic_unicast_port);
239 }
240
245 FASTDDS_EXPORTED_API bool getDefaultUnicastLocators(
246 fastdds::rtps::LocatorList_t& locators,
247 uint32_t unicast_port) const override
248 {
249 return low_level_transport_->getDefaultUnicastLocators(locators, unicast_port);
250 }
251
256 FASTDDS_EXPORTED_API bool fillMetatrafficMulticastLocator(
257 fastdds::rtps::Locator_t& locator,
258 uint32_t metatraffic_multicast_port) const override
259 {
260 return low_level_transport_->fillMetatrafficMulticastLocator(locator, metatraffic_multicast_port);
261 }
262
267 FASTDDS_EXPORTED_API bool fillMetatrafficUnicastLocator(
268 fastdds::rtps::Locator_t& locator,
269 uint32_t metatraffic_unicast_port) const override
270 {
271 return low_level_transport_->fillMetatrafficUnicastLocator(locator, metatraffic_unicast_port);
272 }
273
278 FASTDDS_EXPORTED_API bool configureInitialPeerLocator(
279 fastdds::rtps::Locator_t& locator,
280 const fastdds::rtps::PortParameters& port_params,
281 uint32_t domainId,
282 fastdds::rtps::LocatorList_t& list) const override
283 {
284 return low_level_transport_->configureInitialPeerLocator(locator, port_params, domainId, list);
285 }
286
291 FASTDDS_EXPORTED_API bool fillUnicastLocator(
292 fastdds::rtps::Locator_t& locator,
293 uint32_t well_known_port) const override
294 {
295 return low_level_transport_->fillUnicastLocator(locator, well_known_port);
296 }
297
300 FASTDDS_EXPORTED_API bool transform_remote_locator(
301 const fastdds::rtps::Locator_t& remote_locator,
302 fastdds::rtps::Locator_t& result_locator) const override
303 {
304 return low_level_transport_->transform_remote_locator(remote_locator, result_locator);
305 }
306
311 FASTDDS_EXPORTED_API uint32_t max_recv_buffer_size() const override
312 {
313 return low_level_transport_->max_recv_buffer_size();
314 }
315
334 FASTDDS_EXPORTED_API virtual bool send(
335 fastdds::rtps::SenderResource* low_sender_resource,
336 const std::vector<NetworkBuffer>& buffers,
337 uint32_t total_bytes,
338 fastdds::rtps::LocatorsIterator* destination_locators_begin,
339 fastdds::rtps::LocatorsIterator* destination_locators_end,
340 const std::chrono::steady_clock::time_point& timeout) = 0;
341
357 FASTDDS_EXPORTED_API virtual void receive(
358 TransportReceiverInterface* next_receiver,
359 const fastdds::rtps::octet* receive_buffer,
360 uint32_t receive_buffer_size,
361 const fastdds::rtps::Locator_t& local_locator,
362 const fastdds::rtps::Locator_t& remote_locator) = 0;
363
364 FASTDDS_EXPORTED_API void update_network_interfaces() override
365 {
366 low_level_transport_->update_network_interfaces();
367 }
368
372 FASTDDS_EXPORTED_API bool transform_remote_locator(
373 const fastdds::rtps::Locator_t& remote_locator,
374 fastdds::rtps::Locator_t& result_locator,
375 bool allowed_remote_localhost,
376 bool allowed_local_localhost) const override
377 {
378 return low_level_transport_->transform_remote_locator(remote_locator, result_locator, allowed_remote_localhost,
379 allowed_local_localhost);
380 }
381
386 FASTDDS_EXPORTED_API bool is_locator_allowed(
387 const fastdds::rtps::Locator_t& locator) const override
388 {
389 return low_level_transport_->is_locator_allowed(locator);
390 }
391
396 FASTDDS_EXPORTED_API bool is_locator_reachable(
397 const fastdds::rtps::Locator_t& locator) override
398 {
399 return low_level_transport_->is_locator_reachable(locator);
400 }
401
402 protected:
403
404 std::unique_ptr<TransportInterface> low_level_transport_;
405
406 private:
407
408 std::map<fastdds::rtps::Locator_t, ChainingReceiverResourceReferenceType> receiver_resources_;
409};
410
411} // namespace rtps
412} // namespace fastdds
413} // namespace eprosima
414
415#endif // FASTDDS_RTPS_TRANSPORT__CHAININGTRANSPORT_HPP
eprosima::fastdds::rtps::ChainingTransport::fillUnicastLocator
FASTDDS_EXPORTED_API bool fillUnicastLocator(fastdds::rtps::Locator_t &locator, uint32_t well_known_port) const override
Call the low-level transport fillUnicastLocator().
Definition ChainingTransport.hpp:291
eprosima::fastdds::rtps::ChainingTransport::init
FASTDDS_EXPORTED_API bool init(const fastdds::rtps::PropertyPolicy *properties=nullptr, const uint32_t &max_msg_size_no_frag=0) override
Initialize the low-level transport.
Definition ChainingTransport.hpp:81
eprosima::fastdds::rtps::ChainingTransport::OpenInputChannel
FASTDDS_EXPORTED_API bool OpenInputChannel(const fastdds::rtps::Locator_t &loc, TransportReceiverInterface *receiver_interface, uint32_t max_message_size) override
Call the low-level transport OpenInputChannel().
eprosima::fastdds::rtps::ChainingTransport::max_recv_buffer_size
FASTDDS_EXPORTED_API uint32_t max_recv_buffer_size() const override
Call the low-level transport max_recv_buffer_size().
Definition ChainingTransport.hpp:311
eprosima::fastdds::rtps::ChainingTransport::fillMetatrafficMulticastLocator
FASTDDS_EXPORTED_API bool fillMetatrafficMulticastLocator(fastdds::rtps::Locator_t &locator, uint32_t metatraffic_multicast_port) const override
Call the low-level transport fillMetatrafficMulticastLocator().
Definition ChainingTransport.hpp:256
eprosima::fastdds::rtps::ChainingTransport::receive
virtual FASTDDS_EXPORTED_API void receive(TransportReceiverInterface *next_receiver, const fastdds::rtps::octet *receive_buffer, uint32_t receive_buffer_size, const fastdds::rtps::Locator_t &local_locator, const fastdds::rtps::Locator_t &remote_locator)=0
Blocking Receive from the specified channel.
eprosima::fastdds::rtps::ChainingTransport::fillMetatrafficUnicastLocator
FASTDDS_EXPORTED_API bool fillMetatrafficUnicastLocator(fastdds::rtps::Locator_t &locator, uint32_t metatraffic_unicast_port) const override
Call the low-level transport fillMetatrafficUnicastLocator().
Definition ChainingTransport.hpp:267
eprosima::fastdds::rtps::ChainingTransport::NormalizeLocator
FASTDDS_EXPORTED_API fastdds::rtps::LocatorList_t NormalizeLocator(const fastdds::rtps::Locator_t &locator) override
Call the low-level transport NormalizeLocator().
Definition ChainingTransport.hpp:154
eprosima::fastdds::rtps::ChainingTransport::getDefaultMetatrafficMulticastLocators
FASTDDS_EXPORTED_API bool getDefaultMetatrafficMulticastLocators(fastdds::rtps::LocatorList_t &locators, uint32_t metatraffic_multicast_port) const override
Call the low-level transport getDefaultMetatrafficMulticastLocators().
Definition ChainingTransport.hpp:223
eprosima::fastdds::rtps::ChainingTransport::transform_remote_locator
FASTDDS_EXPORTED_API bool transform_remote_locator(const fastdds::rtps::Locator_t &remote_locator, fastdds::rtps::Locator_t &result_locator, bool allowed_remote_localhost, bool allowed_local_localhost) const override
Call the low-level transport transform_remote_locator().
Definition ChainingTransport.hpp:372
eprosima::fastdds::rtps::ChainingTransport::OpenOutputChannel
FASTDDS_EXPORTED_API bool OpenOutputChannel(SendResourceList &sender_resource_list, const fastdds::rtps::Locator_t &loc) override
Call the low-level transport OpenOutputChannel().
eprosima::fastdds::rtps::ChainingTransport::~ChainingTransport
virtual FASTDDS_EXPORTED_API ~ChainingTransport()=default
Destructor.
eprosima::fastdds::rtps::ChainingTransport::update_network_interfaces
FASTDDS_EXPORTED_API void update_network_interfaces() override
Update network interfaces.
Definition ChainingTransport.hpp:364
eprosima::fastdds::rtps::ChainingTransport::AddDefaultOutputLocator
FASTDDS_EXPORTED_API void AddDefaultOutputLocator(fastdds::rtps::LocatorList_t &defaultList) override
Call the low-level transport AddDefaultOutputLocator().
Definition ChainingTransport.hpp:213
eprosima::fastdds::rtps::ChainingTransport::CloseInputChannel
FASTDDS_EXPORTED_API bool CloseInputChannel(const fastdds::rtps::Locator_t &loc) override
Call the low-level transport CloseInputChannel().
Definition ChainingTransport.hpp:144
eprosima::fastdds::rtps::ChainingTransport::IsLocatorSupported
FASTDDS_EXPORTED_API bool IsLocatorSupported(const fastdds::rtps::Locator_t &loc) const override
Call the low-level transport IsLocatorSupported().
Definition ChainingTransport.hpp:103
eprosima::fastdds::rtps::ChainingTransport::is_locator_allowed
FASTDDS_EXPORTED_API bool is_locator_allowed(const fastdds::rtps::Locator_t &locator) const override
Call the low-level transport is_locator_allowed().
Definition ChainingTransport.hpp:386
eprosima::fastdds::rtps::ChainingTransport::configureInitialPeerLocator
FASTDDS_EXPORTED_API bool configureInitialPeerLocator(fastdds::rtps::Locator_t &locator, const fastdds::rtps::PortParameters &port_params, uint32_t domainId, fastdds::rtps::LocatorList_t &list) const override
Call the low-level transport configureInitialPeerLocator().
Definition ChainingTransport.hpp:278
eprosima::fastdds::rtps::ChainingTransport::is_locator_reachable
FASTDDS_EXPORTED_API bool is_locator_reachable(const fastdds::rtps::Locator_t &locator) override
Call the low-level transport is_locator_reachable().
Definition ChainingTransport.hpp:396
eprosima::fastdds::rtps::ChainingTransport::select_locators
FASTDDS_EXPORTED_API void select_locators(fastdds::rtps::LocatorSelector &selector) const override
Call the low-level transport select_locators().
Definition ChainingTransport.hpp:203
eprosima::fastdds::rtps::ChainingTransport::low_level_transport_
std::unique_ptr< TransportInterface > low_level_transport_
Definition ChainingTransport.hpp:404
eprosima::fastdds::rtps::ChainingTransport::send
virtual FASTDDS_EXPORTED_API bool send(fastdds::rtps::SenderResource *low_sender_resource, const std::vector< NetworkBuffer > &buffers, uint32_t total_bytes, fastdds::rtps::LocatorsIterator *destination_locators_begin, fastdds::rtps::LocatorsIterator *destination_locators_end, const std::chrono::steady_clock::time_point &timeout)=0
Blocking Send through the specified channel.
eprosima::fastdds::rtps::ChainingTransport::DoInputLocatorsMatch
FASTDDS_EXPORTED_API bool DoInputLocatorsMatch(const fastdds::rtps::Locator_t &locator_1, const fastdds::rtps::Locator_t &locator_2) const override
Call the low-level transport DoInputLocatorsMatch().
Definition ChainingTransport.hpp:192
eprosima::fastdds::rtps::ChainingTransport::is_localhost_allowed
FASTDDS_EXPORTED_API bool is_localhost_allowed() const override
Call the low-level transport is_localhost_allowed().
Definition ChainingTransport.hpp:174
eprosima::fastdds::rtps::ChainingTransport::getDefaultMetatrafficUnicastLocators
FASTDDS_EXPORTED_API bool getDefaultMetatrafficUnicastLocators(fastdds::rtps::LocatorList_t &locators, uint32_t metatraffic_unicast_port) const override
Call the low-level transport getDefaultMetatrafficUnicastLocators().
Definition ChainingTransport.hpp:234
eprosima::fastdds::rtps::ChainingTransport::IsInputChannelOpen
FASTDDS_EXPORTED_API bool IsInputChannelOpen(const fastdds::rtps::Locator_t &loc) const override
Call the low-level transport IsInputChannelOpen().
Definition ChainingTransport.hpp:93
eprosima::fastdds::rtps::ChainingTransport::netmask_filter_info
FASTDDS_EXPORTED_API NetmaskFilterInfo netmask_filter_info() const override
Call the low-level transport netmask_filter_info().
Definition ChainingTransport.hpp:183
eprosima::fastdds::rtps::ChainingTransport::is_local_locator
FASTDDS_EXPORTED_API bool is_local_locator(const fastdds::rtps::Locator_t &locator) const override
Call the low-level transport is_local_locator().
Definition ChainingTransport.hpp:164
eprosima::fastdds::rtps::ChainingTransport::ChainingTransport
FASTDDS_EXPORTED_API ChainingTransport(const ChainingTransportDescriptor &t)
Constructor.
Definition ChainingTransport.hpp:64
eprosima::fastdds::rtps::ChainingTransport::getDefaultUnicastLocators
FASTDDS_EXPORTED_API bool getDefaultUnicastLocators(fastdds::rtps::LocatorList_t &locators, uint32_t unicast_port) const override
Call the low-level transport getDefaultUnicastLocators().
Definition ChainingTransport.hpp:245
eprosima::fastdds::rtps::ChainingTransport::RemoteToMainLocal
FASTDDS_EXPORTED_API fastdds::rtps::Locator_t RemoteToMainLocal(const fastdds::rtps::Locator_t &loc) const override
Call the low-level transport RemoteToMainLocal().
Definition ChainingTransport.hpp:113
eprosima::fastdds::rtps::ChainingTransport::transform_remote_locator
FASTDDS_EXPORTED_API bool transform_remote_locator(const fastdds::rtps::Locator_t &remote_locator, fastdds::rtps::Locator_t &result_locator) const override
Call the low-level transport transform_remote_locator().
Definition ChainingTransport.hpp:300
eprosima::fastdds::rtps::Locator_t
Class Locator_t, uniquely identifies a communication channel for a particular transport.
Definition Locator.hpp:71
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::SenderResource
RAII object that encapsulates the Send operation over one chanel in an unknown transport.
Definition SenderResource.hpp:49
eprosima::fastdds::rtps::TransportInterface::transport_kind_
int32_t transport_kind_
Definition TransportInterface.hpp:339
eprosima::fastdds::rtps::TransportInterface::TransportInterface
TransportInterface(const TransportInterface &t)=delete
Copy constructor.
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::LocatorList_t
eprosima::fastdds::rtps::LocatorList LocatorList_t
Definition LocatorList.hpp:478
eprosima::fastdds::rtps::SendResourceList
std::vector< std::unique_ptr< fastdds::rtps::SenderResource > > SendResourceList
Definition TransportInterface.hpp:52
eprosima::fastdds::rtps::octet
unsigned char octet
Definition Types.hpp:83
eprosima::fastdds::rtps::ChainingReceiverResourceReferenceType
std::unique_ptr< ChainingReceiverResource, ChainingReceiverResourceDeleter > ChainingReceiverResourceReferenceType
Type of the unique_ptr of a ChainingReceiverResource .
Definition ChainingTransport.hpp:48
eprosima::fastdds::rtps::NetmaskFilterInfo
std::pair< NetmaskFilterKind, std::vector< AllowedNetworkInterface > > NetmaskFilterInfo
Definition TransportInterface.hpp:53
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::rtps::ChainingReceiverResourceDeleter
Deleter for a ChainingReceiverResource.
Definition ChainingTransport.hpp:42
eprosima::fastdds::rtps::ChainingReceiverResourceDeleter::operator()
void operator()(ChainingReceiverResource *p)
eprosima::fastdds::rtps::ChainingTransportDescriptor
Base class for the descriptors of chaining transports.
Definition ChainingTransportDescriptor.hpp:43
eprosima::fastdds::rtps::LocatorsIterator
Provides a Locator's iterator interface that can be used by different Locator's containers.
Definition LocatorsIterator.hpp:33