Coverage Report

Created: 2025-06-13 06:46

/src/Fast-DDS/include/fastdds/rtps/attributes/BuiltinTransports.hpp
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2023 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
/**
16
 * @file BuiltinTransports.hpp
17
 */
18
19
#ifndef FASTDDS_RTPS_ATTRIBUTES__BUILTINTRANSPORTS_HPP
20
#define FASTDDS_RTPS_ATTRIBUTES__BUILTINTRANSPORTS_HPP
21
22
#include <ostream>
23
#include <cstdint>
24
25
#include <fastdds/fastdds_dll.hpp>
26
#include <fastdds/rtps/transport/TransportInterface.hpp>
27
28
namespace eprosima {
29
namespace fastdds {
30
namespace rtps {
31
32
33
/**
34
 * @brief Options for configuring the built-in transports when using LARGE_DATA mode.
35
 */
36
struct FASTDDS_EXPORTED_API BuiltinTransportsOptions
37
{
38
    //! Whether to use non-blocking send operation.
39
    bool non_blocking_send = false;
40
41
    /**
42
     * @brief The maximum message size to be used.
43
     *
44
     * It specifies the maximum message size that will be used by the Network Factory
45
     * to register every transport.
46
     *
47
     */
48
    uint32_t maxMessageSize = fastdds::rtps::s_maximumMessageSize;
49
50
    /**
51
     * @brief The value used to configure the send and receive fuffer sizes of the sockets.
52
     *
53
     * It specifies the value that will be used to configure the send and receive buffer sizes of the sockets
54
     * used by the transports created with the builtin transports.
55
     * Zero value indicates to use default system buffer size.
56
     *
57
     */
58
    uint32_t sockets_buffer_size = 0;
59
60
    /**
61
     * @brief Time to wait for logical port negotiation (ms).
62
     *
63
     * It specifies the value that will be used to configure the honomym attribute of the TCPTransportDescriptor used.
64
     * It only takes effect if the LARGE_DATA mode is used.
65
     * Zero value means no waiting (default).
66
     *
67
     */
68
    uint32_t tcp_negotiation_timeout = 0;
69
};
70
71
/**
72
 * @brief Equal to operator.
73
 *
74
 * @param bto1 Left hand side BuiltinTransportsOptions being compared.
75
 * @param bto2 Right hand side BuiltinTransportsOptions being compared.
76
 * @return true if \c bto1 is equal to  \c bto2.
77
 * @return false otherwise.
78
 */
79
inline bool operator ==(
80
        const BuiltinTransportsOptions& bto1,
81
        const BuiltinTransportsOptions& bto2)
82
0
{
83
0
    if (bto1.non_blocking_send != bto2.non_blocking_send)
84
0
    {
85
0
        return false;
86
0
    }
87
0
    if (bto1.maxMessageSize != bto2.maxMessageSize)
88
0
    {
89
0
        return false;
90
0
    }
91
0
    if (bto1.sockets_buffer_size != bto2.sockets_buffer_size)
92
0
    {
93
0
        return false;
94
0
    }
95
0
    if (bto1.tcp_negotiation_timeout != bto2.tcp_negotiation_timeout)
96
0
    {
97
0
        return false;
98
0
    }
99
0
    return true;
100
0
}
101
102
/**
103
 * Defines the kind of transports automatically instantiated upon the creation of a participant
104
 */
105
enum class BuiltinTransports : uint16_t
106
{
107
    NONE = 0,          //< No transport will be instantiated
108
    DEFAULT = 1,       //< Default value that will instantiate UDPv4 and SHM transports
109
    DEFAULTv6 = 2,     //< Instantiate UDPv6 and SHM transports
110
    SHM = 3,           //< Instantiate SHM transport only
111
    UDPv4 = 4,         //< Instantiate UDPv4 transport only
112
    UDPv6 = 5,         //< Instantiate UDPv6 transport only
113
    LARGE_DATA = 6,    //< Instantiate SHM, UDPv4 and TCPv4 transports, but UDPv4 is only used for bootstrapping discovery
114
    LARGE_DATAv6 = 7,  //< Instantiate SHM, UDPv6 and TCPv6 transports, but UDPv6 is only used for bootstrapping discovery
115
    P2P = 8            //< Instantiate SHM, UDPv4 (unicast) and TCPv4 transports, shall only be used along with ROS2_EASY_MODE=<ip>
116
};
117
118
inline std::ostream& operator <<(
119
        std::ostream& output,
120
        BuiltinTransports transports)
121
0
{
122
0
    switch (transports)
123
0
    {
124
0
        case BuiltinTransports::NONE:
125
0
            output << "NONE";
126
0
            break;
127
0
        case BuiltinTransports::DEFAULT:
128
0
            output << "DEFAULT";
129
0
            break;
130
0
        case BuiltinTransports::DEFAULTv6:
131
0
            output << "DEFAULTv6";
132
0
            break;
133
0
        case BuiltinTransports::SHM:
134
0
            output << "SHM";
135
0
            break;
136
0
        case BuiltinTransports::UDPv4:
137
0
            output << "UDPv4";
138
0
            break;
139
0
        case BuiltinTransports::UDPv6:
140
0
            output << "UDPv6";
141
0
            break;
142
0
        case BuiltinTransports::LARGE_DATA:
143
0
            output << "LARGE_DATA";
144
0
            break;
145
0
        case BuiltinTransports::LARGE_DATAv6:
146
0
            output << "LARGE_DATAv6";
147
0
            break;
148
0
        case BuiltinTransports::P2P:
149
0
            output << "P2P";
150
0
            break;
151
0
        default:
152
0
            output << "UNKNOWN";
153
0
            break;
154
0
    }
155
0
    return output;
156
0
}
157
158
}  // namespace rtps
159
}  // namespace fastdds
160
}  // namespace eprosima
161
162
#endif  // FASTDDS_RTPS_ATTRIBUTES__BUILTINTRANSPORTS_HPP