RTI Connext C API Version 7.6.0
transport_common.h
1/*
2 * (c) Copyright, Real-Time Innovations, 2005-2024.
3 * All rights reserved.
4 *
5 * No duplications, whole or partial, manual or electronic, may be made
6 * without express written permission. Any such copies, or
7 * revisions thereof, must display this notice unaltered.
8 * This code contains trade secrets of Real-Time Innovations, Inc.
9 */
10
11#ifndef transport_common_h
12#define transport_common_h
13
14#include "osapi/osapi_type.h"
15#include "osapi/osapi_rtpsGuid.h"
16#include "reda/reda_buffer.h"
17#include "transport/transport_dll.h"
18
19/* Include the APIs useful for the transport plugin user */
20#include "transport/transport_common_user.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/* ================================================================= */
27/* Fundamental types */
28/* ================================================================= */
29/*i
30 * \file
31 * \ingroup NDDS_TransportCommonComponent
32 * \brief Basic types and macros used by the \ndds Transport Plugin interface.
33 */
34
35/* Data submessage ID */
36#define NDDS_TRANSPORT_UDP_DATA_SUBMESSAGE_ID (0x15)
37
38/* OID for SPDP participant announcement writer */
39#define NDDS_TRANSPORT_RTPS_OBJECT_ID_SPDP_PARTICIPANT_WRITER (0x000100C2)
40
41/* OID for SPDP2 bootstrap participant announcement writer */
42#define NDDS_TRANSPORT_RTPS_OBJECT_ID_SPDP2_PARTICIPANT_BOOTSTRAP_WRITER \
43 (0x00010082)
44
45/* OID for SPDP2 config participant writer */
46#define NDDS_TRANSPORT_RTPS_OBJECT_ID_SPDP2_PARTICIPANT_CONFIG_WRITER \
47 (0x00010182)
48
49#define NDDS_TRANSPORT_RTPS_OBJECT_ID_SPDP2_PARTICIPANT_SECURE_CONFIG_WRITER \
50 (0xFF010182)
51
52/* OID for publications writer */
53#define NDDS_TRANSPORT_RTPS_OBJECT_ID_PUB_WRITER (0x000003C2)
54
55/* OID for subscriptions writer */
56#define NDDS_TRANSPORT_RTPS_OBJECT_ID_SUB_WRITER (0x000004C2)
57
58/* OID for publications reader */
59#define NDDS_TRANSPORT_RTPS_OBJECT_ID_PUB_READER (0x000003C7)
60
61/* OID for subscriptions reader */
62#define NDDS_TRANSPORT_RTPS_OBJECT_ID_SUB_READER (0x000004C7)
63
64/* OID for liveliness writer */
65#define NDDS_TRANSPORT_RTPS_OBJECT_ID_P2P_PARTICIPANT_LIVELINESS_WRITER \
66 (0x000200C2)
67
68/* OID for secure liveliness writer */
69#define NDDS_TRANSPORT_RTPS_OBJECT_ID_SECURE_P2P_PARTICIPANT_LIVELINESS_WRITER \
70 (0xFF0200C2)
71
72/* Auto liveliness kind */
73#define NDDS_TRANSPORT_INTER_PARTICIPANT_MESSAGE_KIND_AUTOMATIC_LIVELINESS_UPDATE \
74 (0x00000001)
75
76/* Manual livelienss kind */
77#define NDDS_TRANSPORT_INTER_PARTICIPANT_MESSAGE_KIND_MANUAL_LIVELINESS_UPDATE \
78 (0x00000002)
79
80/* ================================================================= */
81/* Port Type */
82/* ================================================================= */
83
84/*e
85 * \ingroup NDDS_TransportConfigurationComponent
86 *
87 * \brief Type for storing \ndds RTPS ports.
88 *
89 * Unlike IPv4 Socket API ports, which are 2 bytes long, the \ndds
90 * representation of an RTPS port is 4 bytes.
91 */
92typedef RTI_UINT32 NDDS_Transport_Port_t;
93
94/*e
95 * \ingroup NDDS_TransportConfigurationComponent
96 * \brief Port 0 is considered to be invalid.
97 */
98#define NDDS_TRANSPORT_PORT_INVALID ((NDDS_Transport_Port_t) 0)
99
100/*i
101 * \ingroup NDDS_TransportConfigurationComponent
102 * Represents a port that is shared across multiple users.
103 */
104struct NDDS_Transport_SharedPort_t {
106 int ref_count;
107};
108
109/* ================================================================= */
110/* UUID Type */
111/* ================================================================= */
112
113/*e
114 * \ingroup NDDS_TransportConfigurationComponent
115 * \brief Size of a NDDS_Transport_UUID.
116 */
117#define NDDS_TRANSPORT_UUID_SIZE 12
118
119/*e
120 * \ingroup NDDS_TransportConfigurationComponent
121 * \brief Represent an unlimited length
122 */
123#define NDDS_TRANSPORT_LENGTH_UNLIMITED -1
124
125/*e
126 * \ingroup NDDS_TransportConfigurationComponent
127 * \brief Rank interface as unknown or not yet set
128 */
129#define NDDS_TRANSPORT_INTERFACE_RANK_UNKNOWN 0
130
131/*e
132 * \ingroup NDDS_TransportConfigurationComponent
133 *
134 * \brief Unequivocally identifies a transport plugin instance.
135 */
137 unsigned char value[NDDS_TRANSPORT_UUID_SIZE];
138};
139
140/*e
141 * \ingroup NDDS_TransportConfigurationComponent
142 * \brief Value for UUIDs that have no known value. Used as default.
143 */
144#define NDDS_TRANSPORT_UUID_UNKNOWN \
145 { \
146 { \
147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
148 } \
149 }
150
151/* ================================================================= */
152/* (Network) Interface Type */
153/* ================================================================= */
154/*e
155 * \defgroup NDDS_Transport_Interface_t Interface
156 * \ingroup NDDS_TransportCommonComponent
157 * \brief Abstraction of a Transport Plugin network interface.
158 *
159 * A Transport Plugin may be able to use several logical or physical
160 * network interfaces in a single node (machine). For example, there
161 * may be multiple NICs for IP networks or multiple serial ports for
162 * serial networks.
163 *
164 * An instance of a Transport Plugin is a conduit to one or more network
165 * interfaces associated with the transport.
166 *
167 * Instances of a Transport Plugin must assign a unique unicast
168 * address to each of the network interfaces that it can use to send
169 * and receive messages. The unicast address should be within the
170 * range of addresses that are addressable by the Transport Plugin (as
171 * defined by the plugin itself).
172 *
173 * Then, when \ndds sends a message to an unicast destination address,
174 * the destination address will be made of two parts. The network
175 * address and an interface address. The network address portion will
176 * be used by \ndds to select the Transport Plugin instance that will
177 * send the message. The interface address portion is passed to the
178 * Transport Plugin instance as the destination interface to which the
179 * message should be sent.
180 *
181 * @see NDDS_Transport_Address_t NDDS_Transport_ClassId_t
182 */
183
184/*e
185 \ingroup NDDS_Transport_Interface_t
186 \brief Interface status
187 */
188typedef enum {
189 /*e
190 * \brief The transport interface is OFF.
191 */
193 /*e
194 * \brief The transport interface is ON.
195 */
198
199/*e
200 * \ingroup NDDS_Transport_Interface_t
201 * \brief Storage for the description of a network interface used by a
202 * Transport Plugin.
203 */
204typedef struct {
205 /*e
206 * \brief The transport classid of the interface.
207 */
209
210 /*e
211 * \brief An unicast address that uniquely identifies this
212 * interface in the network specified by the transport class.
213 */
215
216 /*e
217 * \brief The state of the interface
218 */
220
221 /*e
222 * \brief Rank of the interface. Used when allow_interfaces_list Qos is set.
223 * A rank value will be assigned to each of the interfaces that match the
224 * allow_interfaces_list filter allowing an endpoint to prioritize some
225 * interfaces upon others.
226 */
227 RTI_UINT16 rank;
228
230
231#define NDDS_TRANSPORT_INTERFACE_INITIALIZER \
232 { \
233 NDDS_TRANSPORT_CLASSID_INVALID, \
234 NDDS_TRANSPORT_ADDRESS_INVALID_INITIALIZER, \
235 NDDS_TRANSPORT_INTERFACE_OFF, \
236 NDDS_TRANSPORT_INTERFACE_RANK_UNKNOWN \
237 }
238
239/*i
240 * \ingroup NDDS_Transport_Interface_t
241 * \brief Prints the contents of an interface to standard out.
242 *
243 * @param interface_in \st_in Interface to be printed.
244 * @param desc_in \st_in A prefix to be printed before the interface.
245 * @param indent_in \st_in Indentation level for the printout.
246 */
247extern NDDS_Transport_DllExport void NDDS_Transport_Interface_print(
248 const NDDS_Transport_Interface_t *interface_in,
249 const char *desc_in,
250 RTI_INT32 indent_in);
251
252/*i
253 * \ingroup NDDS_Transport_Interface_t
254 * \brief Copy an interface from the source to the destination.
255 *
256 * @param dst_out \st_out From where the Interface is copied.
257 * @param src_in \st_in To where the Interface is copied.
258 */
259extern NDDS_Transport_DllExport void NDDS_Transport_Interface_copy(
261 const NDDS_Transport_Interface_t *src_in);
262
263#define NDDS_TRANSPORT_CONTEXT_INVALID \
264 { \
265 NDDS_TRANSPORT_ADDRESS_INVALID_INITIALIZER, \
266 NDDS_TRANSPORT_ADDRESS_INVALID_INITIALIZER, \
267 NDDS_TRANSPORT_PORT_INVALID, \
268 NDDS_TRANSPORT_PORT_INVALID, \
269 NDDS_TRANSPORT_PORT_INVALID, \
270 NDDS_TRANSPORT_CLASSID_INVALID \
271 }
272
273/*i
274 * \ingroup NDDS_TransportCommonComponent
275 * @brief Holds the transport information to be used by Network Capture.
276 *
277 * This struct is first filled by the transport (then associated to a
278 * RTINetioMessage if it is inbound traffic) and finally given as input to
279 * RTINetioCapManager_enqueueRtpsFrame.
280 */
281struct NDDS_Transport_Context_t {
282 /*i
283 * @brief Source address of the message.
284 */
285 NDDS_Transport_Address_t sourceAddress;
286 /*i
287 * @brief Destination address of the message.
288 */
289 NDDS_Transport_Address_t destinationAddress;
290 /*i
291 * @brief source port of the message.
292 */
293 NDDS_Transport_Port_t sourcePort;
294 /*i
295 * @brief Destination port of the message.
296 * In the case of TCP, if participant is acting as server,
297 * this is the server bind port.
298 */
299 NDDS_Transport_Port_t destinationPort;
300 /*i
301 * @brief RTPS port when TCP and participant acting as server.
302 * Otherwise, destinationRTPSPort is equal to 0 and we are assuming
303 * destinationRTPSPort==destinationPort.
304 */
305 NDDS_Transport_Port_t destinationRTPSPort;
306 /*i
307 * @brief Transport class Id. This information is filled by netio.
308 */
310};
311
312/* ================================================================= */
313/* Transport Priority */
314/* ================================================================= */
315/*i
316 * \defgroup NDDS_TransportPriority Transport Priority
317 * \ingroup NDDS_TransportCommonComponent
318 *
319 * \brief A QoS set in DDS DataWriters, \idref_TransportPriorityQosPolicy
320 * that is passed to the Transport Plugin when creating SendResources.
321 *
322 * Sometimes also referred to as Transport QoS or CoS (class of
323 * service), a transport priority at the Transport Plugin level is
324 * directly set by the value of the \idref_TransportPriorityQosPolicy
325 * set on DataWriters. The \ndds core will pass the value of the
326 * \idref_TransportPriorityQosPolicy to the \c share/create SendResource
327 * functions of the Transport API when a DataWriter is created.
328 *
329 * The \ndds core itself does not do anything with the transport priority
330 * except passing it from the user code that set the value via the DDS
331 * API to the Transport API.
332 *
333 * Only Transport Plugin implementations that have the concept of
334 * sending of messages at different priorities or with different
335 * classes of service (CoSs) will find this support useful. It is up
336 * to each implementation to use the transport priority in what ever
337 * way it can to configure itself. Transport Plugins implementations
338 * that do not have a concept of sending data with different priorities
339 * can ignore it.
340 *
341 * For example, TCP/IP-based plugins may offer the user application the
342 * ability to specify different CoS for DataWriters so that individual
343 * message streams may be treated differently by the physical transport
344 * itself.
345 */
346
347/*i
348 * \ingroup NDDS_TransportPriority
349 * \brief The default value of the transport_priority.
350 */
351#define NDDS_TRANSPORT_PRIORITY_DEFAULT (0)
352
353/* ================================================================= */
354/* Buffer Type */
355/* ================================================================= */
356/*i \ingroup NDDS_TransportCommonComponent
357 * \brief Generic buffer to hold data, described by a pointer to the
358 * data and length of the data.
359 */
360#ifdef DOXYGEN_DOCUMENTATION_ONLY
361typedef struct {
362 /*i @brief Length of the buffer pointed to by pointer. */
363 RTI_INT32 length;
364 /*i @brief Pre-allocated (by the caller) buffer. */
365 char *pointer;
366} NDDS_Transport_Buffer_t;
367#endif
368typedef struct REDABuffer NDDS_Transport_Buffer_t;
369
370/*
371 * Structure subject to hidden padding in 64bit build,
372 * so use field compare instead of memory compare.
373 */
374#define NDDS_Transport_Buffer_t_compare(transportBuffer1, transportBuffer2) \
375 (((transportBuffer1)->length < (transportBuffer2)->length) \
376 ? -1 \
377 : (((transportBuffer1)->length > (transportBuffer2)->length) \
378 ? 1 \
379 : (((transportBuffer1)->pointer \
380 < (transportBuffer2)->pointer) \
381 ? -1 \
382 : (((transportBuffer1)->pointer \
383 > (transportBuffer2)->pointer) \
384 ? 1 \
385 : 0))))
386
393extern NDDS_Transport_DllExport RTIBool NDDS_Transport_get_address(
394 char *addresses_str_out,
395 size_t addresses_str_buffer_size_in,
396 const char *list,
397 RTI_UINT32 index);
398
405extern NDDS_Transport_DllExport RTIBool
406NDDS_Transport_get_number_of_addresses_in_string(
407 RTI_UINT32 *number_out,
408 const char *list);
409
410#ifdef __cplusplus
411} /* extern "C" */
412#endif
413
414#include "transport/transport_common_impl.h"
415
416#endif /* transport_common_h */
RTI_UINT32 NDDS_Transport_Port_t
Type for storing RTI Connext RTPS ports.
Definition: transport_common.h:92
#define NDDS_TRANSPORT_UUID_SIZE
Size of a NDDS_Transport_UUID.
Definition: transport_common.h:117
RTI_INT32 NDDS_Transport_ClassId_t
Type for storing RTI Connext Transport Plugin class IDs.
Definition: transport_common_user.h:121
NDDS_Transport_Interface_Status_t
Interface status.
Definition: transport_common.h:188
@ NDDS_TRANSPORT_INTERFACE_OFF
The transport interface is OFF.
Definition: transport_common.h:192
@ NDDS_TRANSPORT_INTERFACE_ON
The transport interface is ON.
Definition: transport_common.h:196
Addresses are stored individually as network-ordered bytes.
Definition: transport_common_user.h:384
Storage for the description of a network interface used by a Transport Plugin.
Definition: transport_common.h:204
RTI_UINT16 rank
Rank of the interface. Used when allow_interfaces_list Qos is set. A rank value will be assigned to e...
Definition: transport_common.h:227
NDDS_Transport_Address_t address
An unicast address that uniquely identifies this interface in the network specified by the transport ...
Definition: transport_common.h:214
NDDS_Transport_ClassId_t transport_classid
The transport classid of the interface.
Definition: transport_common.h:208
NDDS_Transport_Interface_Status_t status
The state of the interface.
Definition: transport_common.h:219
Unequivocally identifies a transport plugin instance.
Definition: transport_common.h:136