| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
TCPTransportDescriptor.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__TCPTRANSPORTDESCRIPTOR_HPP
21#define FASTDDS_RTPS_TRANSPORT__TCPTRANSPORTDESCRIPTOR_HPP
22
23#include <cstdint>
24#include <iostream>
25#include <string>
26#include <vector>
27
28#include <fastdds/rtps/attributes/ThreadSettings.hpp>
29#include <fastdds/rtps/transport/SocketTransportDescriptor.hpp>
30#include <fastdds/fastdds_dll.hpp>
31
32 namespace eprosima {
33 namespace fastdds {
34 namespace rtps {
35
69 struct TCPTransportDescriptor : public SocketTransportDescriptor
70{
99 struct TLSConfig
100 {
123 enum TLSOptions : uint32_t
124 {
125 NONE = 0, // 0000 0000 0000
126 DEFAULT_WORKAROUNDS = 1 << 0, // 0000 0000 0001
127 NO_COMPRESSION = 1 << 1, // 0000 0000 0010
128 NO_SSLV2 = 1 << 2, // 0000 0000 0100
129 NO_SSLV3 = 1 << 3, // 0000 0000 1000
130 NO_TLSV1 = 1 << 4, // 0000 0001 0000
131 NO_TLSV1_1 = 1 << 5, // 0000 0010 0000
132 NO_TLSV1_2 = 1 << 6, // 0000 0100 0000
133 NO_TLSV1_3 = 1 << 7, // 0000 1000 0000
134 SINGLE_DH_USE = 1 << 8 // 0001 0000 0000
135 };
136
152 enum TLSVerifyMode : uint8_t
153 {
154 UNUSED = 0, // 0000 0000
155 VERIFY_NONE = 1 << 0, // 0000 0001
156 VERIFY_PEER = 1 << 1, // 0000 0010
157 VERIFY_FAIL_IF_NO_PEER_CERT = 1 << 2, // 0000 0100
158 VERIFY_CLIENT_ONCE = 1 << 3 // 0000 1000
159 };
160
170 enum TLSHandShakeRole : uint8_t
171 {
172 DEFAULT = 0, // 0000 0000
173 CLIENT = 1 << 0, // 0000 0001
174 SERVER = 1 << 1 // 0000 0010
175 };
176
178 std::string password;
180 uint32_t options = TLSOptions::NONE;
182 std::string cert_chain_file;
184 std::string private_key_file;
186 std::string tmp_dh_file;
188 std::string verify_file;
190 uint8_t verify_mode = TLSVerifyMode::UNUSED;
192 std::vector<std::string> verify_paths;
194 bool default_verify_path = false;
196 int32_t verify_depth = -1;
198 std::string rsa_private_key_file;
200 TLSHandShakeRole handshake_role = TLSHandShakeRole::DEFAULT;
202 std::string server_name;
203
205 void add_verify_mode(
206 const TLSVerifyMode verify)
207 {
208 verify_mode |= verify;
209 }
210
212 bool get_verify_mode(
213 const TLSVerifyMode verify) const
214 {
215 return (verify_mode & verify) == verify;
216 }
217
219 void add_option(
220 const TLSOptions option)
221 {
222 options |= option;
223 }
224
226 bool get_option(
227 const TLSOptions option) const
228 {
229 return (options & option) == option;
230 }
231
233 bool operator ==(
234 const TLSConfig& t) const
235 {
236 return (this->password == t.password &&
237 this->options == t.options &&
238 this->cert_chain_file == t.cert_chain_file &&
239 this->private_key_file == t.private_key_file &&
240 this->tmp_dh_file == t.tmp_dh_file &&
241 this->verify_file == t.verify_file &&
242 this->verify_mode == t.verify_mode &&
243 this->verify_paths == t.verify_paths &&
244 this->default_verify_path == t.default_verify_path &&
245 this->verify_depth == t.verify_depth &&
246 this->rsa_private_key_file == t.rsa_private_key_file &&
247 this->handshake_role == t.handshake_role);
248 }
249
250 };
251
253 std::vector<uint16_t> listening_ports;
255 uint32_t keep_alive_frequency_ms;
257 uint32_t keep_alive_timeout_ms;
259 uint16_t max_logical_port;
261 uint16_t logical_port_range;
263 uint16_t logical_port_increment;
264
270 uint32_t tcp_negotiation_timeout;
271
273 bool enable_tcp_nodelay;
275 bool calculate_crc;
277 bool check_crc;
279 bool apply_security;
280
282 TLSConfig tls_config;
283
285 ThreadSettings keep_alive_thread;
286
288 ThreadSettings accept_thread;
289
302 bool non_blocking_send;
303
305 void add_listener_port(
306 uint16_t port)
307 {
308 listening_ports.push_back(port);
309 }
310
312 FASTDDS_EXPORTED_API TCPTransportDescriptor();
313
315 FASTDDS_EXPORTED_API TCPTransportDescriptor(
316 const TCPTransportDescriptor& t);
317
319 FASTDDS_EXPORTED_API TCPTransportDescriptor& operator =(
320 const TCPTransportDescriptor& t);
321
323 virtual ~TCPTransportDescriptor() = default;
324
326 FASTDDS_EXPORTED_API bool operator ==(
327 const TCPTransportDescriptor& t) const;
328};
329
330} // namespace rtps
331} // namespace fastdds
332} // namespace eprosima
333
334#endif // FASTDDS_RTPS_TRANSPORT__TCPTRANSPORTDESCRIPTOR_HPP
eprosima::fastdds::rtps
Contains the RTPS protocol implementation.
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::rtps::SocketTransportDescriptor::SocketTransportDescriptor
FASTDDS_EXPORTED_API SocketTransportDescriptor(uint32_t maximumMessageSize, uint32_t maximumInitialPeersRange)
Constructor.
Definition SocketTransportDescriptor.hpp:55
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig
TLS Configuration.
Definition TCPTransportDescriptor.hpp:100
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::TLSOptions
TLSOptions
Supported TLS features.
Definition TCPTransportDescriptor.hpp:124
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::NO_TLSV1_1
@ NO_TLSV1_1
Definition TCPTransportDescriptor.hpp:131
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::NO_SSLV2
@ NO_SSLV2
Definition TCPTransportDescriptor.hpp:128
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::NO_SSLV3
@ NO_SSLV3
Definition TCPTransportDescriptor.hpp:129
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::NO_TLSV1_3
@ NO_TLSV1_3
Definition TCPTransportDescriptor.hpp:133
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::DEFAULT_WORKAROUNDS
@ DEFAULT_WORKAROUNDS
Definition TCPTransportDescriptor.hpp:126
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::NO_COMPRESSION
@ NO_COMPRESSION
Definition TCPTransportDescriptor.hpp:127
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::NO_TLSV1
@ NO_TLSV1
Definition TCPTransportDescriptor.hpp:130
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::SINGLE_DH_USE
@ SINGLE_DH_USE
Definition TCPTransportDescriptor.hpp:134
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::NONE
@ NONE
Definition TCPTransportDescriptor.hpp:125
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::NO_TLSV1_2
@ NO_TLSV1_2
Definition TCPTransportDescriptor.hpp:132
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::verify_depth
int32_t verify_depth
Maximum allowed depth for verifying intermediate certificates. Do not override.
Definition TCPTransportDescriptor.hpp:196
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::add_verify_mode
void add_verify_mode(const TLSVerifyMode verify)
Add verification modes to the verification mode mask.
Definition TCPTransportDescriptor.hpp:205
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::handshake_role
TLSHandShakeRole handshake_role
Role that the transport will take on handshaking.
Definition TCPTransportDescriptor.hpp:200
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::get_verify_mode
bool get_verify_mode(const TLSVerifyMode verify) const
Get the verification mode mask.
Definition TCPTransportDescriptor.hpp:212
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::options
uint32_t options
SSL context options mask.
Definition TCPTransportDescriptor.hpp:180
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::tmp_dh_file
std::string tmp_dh_file
Path to the Diffie-Hellman parameters file.
Definition TCPTransportDescriptor.hpp:186
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::password
std::string password
Password of the private_key_file or rsa_private_key_file.
Definition TCPTransportDescriptor.hpp:178
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::operator==
bool operator==(const TLSConfig &t) const
Comparison operator.
Definition TCPTransportDescriptor.hpp:233
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::verify_mode
uint8_t verify_mode
Verification mode mask.
Definition TCPTransportDescriptor.hpp:190
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::server_name
std::string server_name
Server name or host name required in case Server Name Indication (SNI) is used.
Definition TCPTransportDescriptor.hpp:202
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::TLSVerifyMode
TLSVerifyMode
Peer node verification options.
Definition TCPTransportDescriptor.hpp:153
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::VERIFY_FAIL_IF_NO_PEER_CERT
@ VERIFY_FAIL_IF_NO_PEER_CERT
Definition TCPTransportDescriptor.hpp:157
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::VERIFY_NONE
@ VERIFY_NONE
Definition TCPTransportDescriptor.hpp:155
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::UNUSED
@ UNUSED
Definition TCPTransportDescriptor.hpp:154
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::VERIFY_PEER
@ VERIFY_PEER
Definition TCPTransportDescriptor.hpp:156
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::VERIFY_CLIENT_ONCE
@ VERIFY_CLIENT_ONCE
Definition TCPTransportDescriptor.hpp:158
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::verify_file
std::string verify_file
Path to the CA (Certification-Authority) file.
Definition TCPTransportDescriptor.hpp:188
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::default_verify_path
bool default_verify_path
Look for verification files on the default paths.
Definition TCPTransportDescriptor.hpp:194
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::TLSHandShakeRole
TLSHandShakeRole
Role that the transport will take on handshaking.
Definition TCPTransportDescriptor.hpp:171
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::CLIENT
@ CLIENT
Definition TCPTransportDescriptor.hpp:173
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::SERVER
@ SERVER
Definition TCPTransportDescriptor.hpp:174
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::DEFAULT
@ DEFAULT
Definition TCPTransportDescriptor.hpp:172
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::private_key_file
std::string private_key_file
Path to the private key certificate file.
Definition TCPTransportDescriptor.hpp:184
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::verify_paths
std::vector< std::string > verify_paths
Paths where the system will look for verification files.
Definition TCPTransportDescriptor.hpp:192
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::get_option
bool get_option(const TLSOptions option) const
Get the SSL Context options mask.
Definition TCPTransportDescriptor.hpp:226
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::add_option
void add_option(const TLSOptions option)
Add TLS features to the SSL Context options mask.
Definition TCPTransportDescriptor.hpp:219
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::cert_chain_file
std::string cert_chain_file
Path to the public certificate chain file.
Definition TCPTransportDescriptor.hpp:182
eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::rsa_private_key_file
std::string rsa_private_key_file
Path to the private key RSA certificate file.
Definition TCPTransportDescriptor.hpp:198
eprosima::fastdds::rtps::TCPTransportDescriptor::max_logical_port
uint16_t max_logical_port
Maximum number of logical ports to try during RTCP negotiation.
Definition TCPTransportDescriptor.hpp:259
eprosima::fastdds::rtps::TCPTransportDescriptor::keep_alive_timeout_ms
uint32_t keep_alive_timeout_ms
Time since sending the last keep alive request to consider a connection as broken (ms).
Definition TCPTransportDescriptor.hpp:257
eprosima::fastdds::rtps::TCPTransportDescriptor::accept_thread
ThreadSettings accept_thread
Thread settings for the accept connections thread.
Definition TCPTransportDescriptor.hpp:288
eprosima::fastdds::rtps::TCPTransportDescriptor::~TCPTransportDescriptor
virtual ~TCPTransportDescriptor()=default
Destructor.
eprosima::fastdds::rtps::TCPTransportDescriptor::operator=
FASTDDS_EXPORTED_API TCPTransportDescriptor & operator=(const TCPTransportDescriptor &t)
Copy assignment.
eprosima::fastdds::rtps::TCPTransportDescriptor::enable_tcp_nodelay
bool enable_tcp_nodelay
Enables the TCP_NODELAY socket option.
Definition TCPTransportDescriptor.hpp:273
eprosima::fastdds::rtps::TCPTransportDescriptor::calculate_crc
bool calculate_crc
Enables the calculation and sending of CRC on message headers.
Definition TCPTransportDescriptor.hpp:275
eprosima::fastdds::rtps::TCPTransportDescriptor::logical_port_increment
uint16_t logical_port_increment
Increment between logical ports to try during RTCP negotiation.
Definition TCPTransportDescriptor.hpp:263
eprosima::fastdds::rtps::TCPTransportDescriptor::apply_security
bool apply_security
Enables the use of TLS (Transport Layer Security).
Definition TCPTransportDescriptor.hpp:279
eprosima::fastdds::rtps::TCPTransportDescriptor::tls_config
TLSConfig tls_config
Configuration of the TLS (Transport Layer Security).
Definition TCPTransportDescriptor.hpp:282
eprosima::fastdds::rtps::TCPTransportDescriptor::non_blocking_send
bool non_blocking_send
Whether to use non-blocking calls to send().
Definition TCPTransportDescriptor.hpp:302
eprosima::fastdds::rtps::TCPTransportDescriptor::tcp_negotiation_timeout
uint32_t tcp_negotiation_timeout
Time to wait for logical port negotiation (ms).
Definition TCPTransportDescriptor.hpp:270
eprosima::fastdds::rtps::TCPTransportDescriptor::check_crc
bool check_crc
Enables checking the CRC of incoming message headers.
Definition TCPTransportDescriptor.hpp:277
eprosima::fastdds::rtps::TCPTransportDescriptor::listening_ports
std::vector< uint16_t > listening_ports
List of ports to listen as server.
Definition TCPTransportDescriptor.hpp:253
eprosima::fastdds::rtps::TCPTransportDescriptor::logical_port_range
uint16_t logical_port_range
Maximum number of logical ports per request to try during RTCP negotiation.
Definition TCPTransportDescriptor.hpp:261
eprosima::fastdds::rtps::TCPTransportDescriptor::TCPTransportDescriptor
FASTDDS_EXPORTED_API TCPTransportDescriptor()
Constructor.
eprosima::fastdds::rtps::TCPTransportDescriptor::TCPTransportDescriptor
FASTDDS_EXPORTED_API TCPTransportDescriptor(const TCPTransportDescriptor &t)
Copy constructor.
eprosima::fastdds::rtps::TCPTransportDescriptor::operator==
FASTDDS_EXPORTED_API bool operator==(const TCPTransportDescriptor &t) const
Comparison operator.
eprosima::fastdds::rtps::TCPTransportDescriptor::add_listener_port
void add_listener_port(uint16_t port)
Add listener port to the listening_ports list.
Definition TCPTransportDescriptor.hpp:305
eprosima::fastdds::rtps::TCPTransportDescriptor::keep_alive_frequency_ms
uint32_t keep_alive_frequency_ms
Frequency of RTCP keep alive requests (ms).
Definition TCPTransportDescriptor.hpp:255
eprosima::fastdds::rtps::TCPTransportDescriptor::keep_alive_thread
ThreadSettings keep_alive_thread
Thread settings for keep alive thread.
Definition TCPTransportDescriptor.hpp:285
eprosima::fastdds::rtps::ThreadSettings
Struct ThreadSettings to specify various thread settings.
Definition ThreadSettings.hpp:37