Fast DDS  Version 3.0.1
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
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
32namespace eprosima {
33namespace fastdds {
34namespace rtps {
35
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;
182 std::string cert_chain_file;
184 std::string private_key_file;
186 std::string tmp_dh_file;
188 std::string verify_file;
192 std::vector<std::string> verify_paths;
196 int32_t verify_depth = -1;
202 std::string server_name;
203
206 const TLSVerifyMode verify)
207 {
208 verify_mode |= verify;
209 }
210
213 const TLSVerifyMode verify) const
214 {
215 return (verify_mode & verify) == verify;
216 }
217
220 const TLSOptions option)
221 {
222 options |= option;
223 }
224
227 const TLSOptions option) const
228 {
229 return (options & option) == option;
230 }
231
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;
264
271
280
283
286
289
303
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 namespace.
Virtual base class for the data type used to define configuration of transports using sockets.
Definition SocketTransportDescriptor.hpp:53
TLS Configuration.
Definition TCPTransportDescriptor.hpp:100
TLSOptions
Supported TLS features.
Definition TCPTransportDescriptor.hpp:124
@ NO_TLSV1_1
Definition TCPTransportDescriptor.hpp:131
@ NO_SSLV2
Definition TCPTransportDescriptor.hpp:128
@ NO_SSLV3
Definition TCPTransportDescriptor.hpp:129
@ NO_TLSV1_3
Definition TCPTransportDescriptor.hpp:133
@ DEFAULT_WORKAROUNDS
Definition TCPTransportDescriptor.hpp:126
@ NO_COMPRESSION
Definition TCPTransportDescriptor.hpp:127
@ NO_TLSV1
Definition TCPTransportDescriptor.hpp:130
@ SINGLE_DH_USE
Definition TCPTransportDescriptor.hpp:134
@ NONE
Definition TCPTransportDescriptor.hpp:125
@ NO_TLSV1_2
Definition TCPTransportDescriptor.hpp:132
int32_t verify_depth
Maximum allowed depth for verifying intermediate certificates. Do not override.
Definition TCPTransportDescriptor.hpp:196
void add_verify_mode(const TLSVerifyMode verify)
Add verification modes to the verification mode mask.
Definition TCPTransportDescriptor.hpp:205
TLSHandShakeRole handshake_role
Role that the transport will take on handshaking.
Definition TCPTransportDescriptor.hpp:200
bool get_verify_mode(const TLSVerifyMode verify) const
Get the verification mode mask.
Definition TCPTransportDescriptor.hpp:212
uint32_t options
SSL context options mask.
Definition TCPTransportDescriptor.hpp:180
std::string tmp_dh_file
Path to the Diffie-Hellman parameters file.
Definition TCPTransportDescriptor.hpp:186
std::string password
Password of the private_key_file or rsa_private_key_file.
Definition TCPTransportDescriptor.hpp:178
bool operator==(const TLSConfig &t) const
Comparison operator.
Definition TCPTransportDescriptor.hpp:233
uint8_t verify_mode
Verification mode mask.
Definition TCPTransportDescriptor.hpp:190
std::string server_name
Server name or host name required in case Server Name Indication (SNI) is used.
Definition TCPTransportDescriptor.hpp:202
TLSVerifyMode
Peer node verification options.
Definition TCPTransportDescriptor.hpp:153
@ VERIFY_FAIL_IF_NO_PEER_CERT
Definition TCPTransportDescriptor.hpp:157
@ VERIFY_NONE
Definition TCPTransportDescriptor.hpp:155
@ UNUSED
Definition TCPTransportDescriptor.hpp:154
@ VERIFY_PEER
Definition TCPTransportDescriptor.hpp:156
@ VERIFY_CLIENT_ONCE
Definition TCPTransportDescriptor.hpp:158
std::string verify_file
Path to the CA (Certification-Authority) file.
Definition TCPTransportDescriptor.hpp:188
bool default_verify_path
Look for verification files on the default paths.
Definition TCPTransportDescriptor.hpp:194
TLSHandShakeRole
Role that the transport will take on handshaking.
Definition TCPTransportDescriptor.hpp:171
@ CLIENT
Definition TCPTransportDescriptor.hpp:173
@ SERVER
Definition TCPTransportDescriptor.hpp:174
@ DEFAULT
Definition TCPTransportDescriptor.hpp:172
std::string private_key_file
Path to the private key certificate file.
Definition TCPTransportDescriptor.hpp:184
std::vector< std::string > verify_paths
Paths where the system will look for verification files.
Definition TCPTransportDescriptor.hpp:192
bool get_option(const TLSOptions option) const
Get the SSL Context options mask.
Definition TCPTransportDescriptor.hpp:226
void add_option(const TLSOptions option)
Add TLS features to the SSL Context options mask.
Definition TCPTransportDescriptor.hpp:219
std::string cert_chain_file
Path to the public certificate chain file.
Definition TCPTransportDescriptor.hpp:182
std::string rsa_private_key_file
Path to the private key RSA certificate file.
Definition TCPTransportDescriptor.hpp:198
TCP Transport configuration.
Definition TCPTransportDescriptor.hpp:70
uint16_t max_logical_port
Maximum number of logical ports to try during RTCP negotiation.
Definition TCPTransportDescriptor.hpp:259
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
ThreadSettings accept_thread
Thread settings for the accept connections thread.
Definition TCPTransportDescriptor.hpp:288
virtual ~TCPTransportDescriptor()=default
Destructor.
FASTDDS_EXPORTED_API TCPTransportDescriptor & operator=(const TCPTransportDescriptor &t)
Copy assignment.
bool enable_tcp_nodelay
Enables the TCP_NODELAY socket option.
Definition TCPTransportDescriptor.hpp:273
bool calculate_crc
Enables the calculation and sending of CRC on message headers.
Definition TCPTransportDescriptor.hpp:275
uint16_t logical_port_increment
Increment between logical ports to try during RTCP negotiation.
Definition TCPTransportDescriptor.hpp:263
bool apply_security
Enables the use of TLS (Transport Layer Security)
Definition TCPTransportDescriptor.hpp:279
TLSConfig tls_config
Configuration of the TLS (Transport Layer Security)
Definition TCPTransportDescriptor.hpp:282
bool non_blocking_send
Whether to use non-blocking calls to send().
Definition TCPTransportDescriptor.hpp:302
uint32_t tcp_negotiation_timeout
Time to wait for logical port negotiation (ms).
Definition TCPTransportDescriptor.hpp:270
bool check_crc
Enables checking the CRC of incoming message headers.
Definition TCPTransportDescriptor.hpp:277
std::vector< uint16_t > listening_ports
List of ports to listen as server.
Definition TCPTransportDescriptor.hpp:253
uint16_t logical_port_range
Maximum number of logical ports per request to try during RTCP negotiation.
Definition TCPTransportDescriptor.hpp:261
FASTDDS_EXPORTED_API TCPTransportDescriptor()
Constructor.
FASTDDS_EXPORTED_API TCPTransportDescriptor(const TCPTransportDescriptor &t)
Copy constructor.
FASTDDS_EXPORTED_API bool operator==(const TCPTransportDescriptor &t) const
Comparison operator.
void add_listener_port(uint16_t port)
Add listener port to the listening_ports list.
Definition TCPTransportDescriptor.hpp:305
uint32_t keep_alive_frequency_ms
Frequency of RTCP keep alive requests (ms)
Definition TCPTransportDescriptor.hpp:255
ThreadSettings keep_alive_thread
Thread settings for keep alive thread.
Definition TCPTransportDescriptor.hpp:285
Struct ThreadSettings to specify various thread settings.
Definition ThreadSettings.hpp:37