RTI Connext Traditional C++ API Version 7.7.0
transport_udp.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_udp_h
12#define transport_udp_h
13
14#include "osapi/osapi_socket.h"
15#include "osapi/osapi_atomic.h"
16#include "clock/clock_interface.h"
17#include "transport/transport_dll.h"
18#include "transport/transport_interface.h"
19#include "transport/transport_udp_wan_library.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25struct NDDS_Transport_UDP; /* forward declare */
26
27struct NDDS_Transport_UDP_SocketFactory;
28
29struct NDDS_Transport_UDP_Interface_t;
30
31/* ================================================================= */
32/* Component: UDP/IP Transport Plugin */
33/* ================================================================= */
34
35/*e \dref_UDPTransportBuiltinGroupDocs
36 */
37
38/*i \file
39 * \ingroup NDDS_Transport_UDP_Plugin
40 * \brief UDP Transport Plugin interfaces and definitions.
41 */
42
43/* ================================================================= */
44/* Transport UDP WAN Listener Class */
45/* ================================================================= */
56typedef void (
57 *NDDS_Transport_UDP_WAN_Listener_Public_Mapping_Resolved_Callback)(
58 void *listener_data,
59 const NDDS_Transport_Address_t *public_uuid_adress,
60 NDDS_Transport_Port_t rtps_port);
61
62struct NDDS_Transport_UDP_WAN_Listener {
63 void *listener_data;
64 NDDS_Transport_UDP_WAN_Listener_Public_Mapping_Resolved_Callback
65 on_public_mapping_resolved;
66};
67
68/* ================================================================= */
69/* UDP Port */
70/* ================================================================= */
71/*e \dref_UDPTransport_Port
72 */
73typedef RTI_UINT16 NDDS_Transport_UDP_Port;
74
75#define NDDS_TRANSPORT_UDP_PORT_INVALID (0)
76#define NDDS_TRANSPORT_UDP_PORT_MAX (RTI_UINT16_MAX)
77
78/* ================================================================= */
79/* UDP WAN CommPorts */
80/* ================================================================= */
81
82/*e \dref_UDPTransport_WAN_CommPortsMappingInfo
83 */
85 /*e \dref_UDPTransport_WAN_CommPortsMappingInfo_rtps_port
86 */
88 /*e \dref_UDPTransport_WAN_CommPortsMappingInfo_host_port
89 */
91 /*e \dref_UDPTransport_WAN_CommPortsMappingInfo_public_port
92 */
94 /*i
95 * CORE-16439: It is possible the before a receive resource has been removed
96 * (e.g, interface goes DOWN) the application tries to recreate it again
97 * (e.g, interfaces goes UP). In this scenario, if the
98 * previous resource is still in the process of being removed the creation
99 * of the new resource will fail because it will try to add the same mapping
100 * again to the comm_ports_list. To avoid this situation, we keep a
101 * reference count of how many receive resources are using this mapping
102 * info.
103 *
104 * See CORE-16439 for additional details.
105 *
106 * This field is marked as internal as it is not intended to be used
107 * by applications.
108 */
109 int ref_count;
110};
111
112/* ================================================================= */
113/* Unicast UDP Properties */
114/* ================================================================= */
115
116struct NDDS_Transport_UDP_Property_t {
117 struct NDDS_Transport_Property_t parent;
118 RTI_INT32 send_socket_buffer_size;
119 RTI_INT32 recv_socket_buffer_size;
120 RTI_INT32 unicast_enabled;
121 RTI_INT32 multicast_enabled;
122 RTI_INT32 multicast_ttl;
123 RTI_INT32 multicast_loopback_disabled;
124 RTI_INT32 ignore_loopback_interface;
125 RTI_INT32 ignore_nonup_interfaces;
126 RTI_INT32 ignore_nonrunning_interfaces;
127 RTI_INT32 no_zero_copy;
128 RTI_INT32 send_blocking;
129 RTI_INT32 enable_v4mapped;
130 RTI_INT32 use_checksum;
131 RTI_UINT32 transport_priority_mask;
132 RTI_INT32 transport_priority_mapping_low;
133 RTI_INT32 transport_priority_mapping_high;
134 RTI_INT32 send_ping;
135 RTI_INT32 force_interface_poll_detection;
136 RTI_UINT32 interface_poll_period;
137 RTI_INT32 reuse_multicast_receive_resource;
138 RTI_INT32 protocol_overhead_max;
139 RTI_INT32 disable_interface_tracking;
140 RTI_UINT32 join_multicast_group_timeout;
141 char *public_address;
142 struct NDDS_Transport_UDP_WAN_CommPortsMappingInfo *comm_ports_list;
143 RTI_INT32 comm_ports_list_length;
144 struct NDDS_Transport_UDP_WAN_Listener *wan_listener;
145 RTI_INT32 port_offset;
146 RTI_UINT32 binding_ping_period;
147 /*
148 * Maximum time that an orphan binding–ping mapping may exist without being
149 * refreshed before it is removed.
150 */
151 RTI_UINT32 binding_ping_mapping_expiration;
152 /*i
153 * \brief If this property is set, we use this function to check for an
154 * enabled WAN transport. If the function is not set, we would try to load a
155 * default shared library with the correct function to enable WAN transport.
156 */
157 NDDS_Transport_UDP_WAN_Library_Is_Plugin_Enabled_Function
158 plugin_enabled_function_ptr;
159 /****************** START TESTING ONLY FIELDS *****************/
160 /*i
161 * \brief If this property is set we will update the send
162 * and receive statistics split into participant and endpoint discovery
163 * by parsing the packets. We will update the discovery/user packets
164 * based on the port number regardless of if this property is set.
165 * The default is false for performance reasons and is set to true only
166 * for testing purposes.
167 */
168 RTIBool gather_detailed_statistics;
169 /*i
170 * \brief If this property is set to TRUE we will check if the guid prefix
171 * in the RTPS header matches guid_prefix_to_drop. If it does we will drop
172 * the sample.
173 */
174 RTIBool drop_samples_by_guid_prefix;
175 /*i
176 * \brief GUID prefix to drop when drop_samples_by_guid_prefix is set to
177 * TRUE.
178 */
179 struct RTIOsapiRtpsGuidPrefix guid_prefix_to_drop;
180 /****************** END TESTING ONLY FIELDS *****************/
181};
182
183/*e \ingroup NDDS_Transport_UDP_Plugin
184 * \brief Default value of NDDS_Transport_Property_t#properties_bitmap.
185 */
186#define NDDS_TRANSPORT_UDP_PROPERTIES_BITMAP_DEFAULT (0)
187
188/*e \ingroup NDDS_Transport_UDP_Plugin
189 * \brief Default value of
190 * NDDS_Transport_Property_t#gather_send_buffer_count_max.
191 *
192 * This is also the maximum value that can be used when instantiating the udp
193 * transport.
194 *
195 * 16 is sufficient for \ndds, but more may improve discovery and reliable
196 * performance.
197 * Porting note: find out what the maximum gather buffer count is on your OS!
198 */
199#define NDDS_TRANSPORT_UDP_GATHER_SEND_BUFFER_COUNT_MAX_DEFAULT (16)
200
201/*e \ingroup NDDS_Transport_UDP_Plugin
202 * \brief Used to specify that os maximum be used to specify socket buffer size.
203 *
204 * This property, if set, uses the maximum allowable size set in your OS for
205 * send and receive socket buffer sizes. If you update the maximum allowable
206 * size in your OS setting, then \ndds will automatically pick up that change.
207 * This property is not supported on all platforms because not all platforms
208 * have maximum values for the size of the send and receive buffers for sockets.
209 * If the platform does not support this property, then the property will be
210 * set to \ref
211 * NDDS_Transport_UDP_Plugin#NDDS_TRANSPORT_UDP_SEND_SOCKET_BUFFER_SIZE_DEFAULT
212 * or \ref
213 * NDDS_Transport_UDP_Plugin#NDDS_TRANSPORT_UDP_RECV_SOCKET_BUFFER_SIZE_DEFAULT,
214 * depending on the property being set.
215 * See the Platform Notes to determine if this property is supported on your
216 * platform.
217 *
218 * This value is -2.
219 */
220#define NDDS_TRANSPORT_UDP_SOCKET_BUFFER_SIZE_OS_MAX \
221 RTI_OSAPI_UDP_SOCKET_BUFFER_SIZE_OS_MAX
222
223/*e \ingroup NDDS_Transport_UDP_Plugin
224 * \brief Used to specify that os default be used to specify socket buffer size.
225 *
226 * This property, if set, uses the default size set in your OS for send and
227 * receive socket buffer sizes. If you update the default size in your OS
228 * settings, then \ndds will automatically pick up that change.
229 *
230 * This value is -1.
231 */
232#define NDDS_TRANSPORT_UDP_SOCKET_BUFFER_SIZE_OS_DEFAULT \
233 RTI_OSAPI_UDP_SOCKET_BUFFER_SIZE_OS_DEFAULT
234
235/*e \ingroup NDDS_Transport_UDP_Plugin
236 * \brief Default value of send_socket_buffer_size.
237 *
238 * The default value is 2097152 bytes (1048576 bytes on AIX platforms).
239 */
240#define NDDS_TRANSPORT_UDP_SEND_SOCKET_BUFFER_SIZE_DEFAULT \
241 RTI_OSAPI_UDP_SEND_SOCKET_BUFFER_SIZE_DEFAULT
242
243/*e \ingroup NDDS_Transport_UDP_Plugin
244 * \brief Default value of recv_socket_buffer_size.
245 *
246 * The default value is 2097152 bytes (1048576 bytes on AIX platforms).
247 */
248#define NDDS_TRANSPORT_UDP_RECV_SOCKET_BUFFER_SIZE_DEFAULT \
249 RTI_OSAPI_UDP_RECV_SOCKET_BUFFER_SIZE_DEFAULT
250
251#define NDDS_TRANSPORT_UDP_DATAGRAM_LENGTH_MAX (65535)
252
253/*e \ingroup NDDS_Transport_UDP_Plugin
254 * \brief Default value of multicast_ttl.
255 */
256#define NDDS_TRANSPORT_UDP_MULTICAST_TTL_DEFAULT (1)
257
258
259#ifdef RTI_MULTICAST
260 #define NDDS_TRANSPORT_UDP_USE_MULTICAST_DEFAULT 1
261#else
262 #define NDDS_TRANSPORT_UDP_USE_MULTICAST_DEFAULT 0
263#endif
264
265
266/*e \dref_UDPTransport_IGNORE_LOOPBACK_DISABLED
267 */
268#define NDDS_TRANSPORT_UDP_IGNORE_LOOPBACK_DISABLED (0)
269
270/*e \dref_UDPTransport_IGNORE_LOOPBACK_ENABLED
271 */
272#define NDDS_TRANSPORT_UDP_IGNORE_LOOPBACK_ENABLED (1)
273
274/*e \dref_UDPTransport_IGNORE_LOOPBACK_AUTO
275 */
276#define NDDS_TRANSPORT_UDP_IGNORE_LOOPBACK_AUTO (-1)
277
278
279/*e \dref_UDPTransport_BLOCKING_NEVER
280 */
281#define NDDS_TRANSPORT_UDP_BLOCKING_NEVER (0)
282
283/*e \dref_UDPTransport_BLOCKING_ALWAYS
284 */
285#define NDDS_TRANSPORT_UDP_BLOCKING_ALWAYS (1)
286#define NDDS_TRANSPORT_UDP_BLOCKING_UNICAST_ONLY (2)
287
288/*e \dref_UDPTransport_BLOCKING_DEFAULT
289 */
290#define NDDS_TRANSPORT_UDP_BLOCKING_DEFAULT NDDS_TRANSPORT_UDP_BLOCKING_ALWAYS
291
292/* ================================================================= */
293/* InterfaceListener Class */
294/* ================================================================= */
295
296/*i
297 * \defgroup NDDS_Transport_UDP_InterfaceListenerClass
298 * NDDS_Transport_UDP_InterfaceListener \ingroup NDDS_Transport_UDP_Plugin
299 * \brief Interface for IPv4 or v6 interface acceptance/rejection
300 *
301 * @mtsafety See NDDS_Transport_UDP_public UML diagram
302 *
303 * @see NDDS_Transport_UDP_newI
304 */
305struct NDDS_Transport_UDP_InterfaceListener; /*forward declare */
306
307/*i \ingroup NDDS_Transport_UDP_InterfaceListenerClass
308 * \brief A user-provided function to be used to filter out particular
309 * network interfaces to be used by the Transport Plugin.
310 *
311 * The user may implement this function and pass it to an
312 * instance of a Transport Plugin to reject or accept network
313 * interfaces that the plugin offers as ones to use to receive
314 * messages.
315 *
316 * When \ndds contacts other applications, it will provide a list of
317 * interfaces that other applications can use to send messages (on a
318 * plugin by plugin basis). The addresses of the interfaces are used
319 * as the destination addresses of messages that are sent. If a plugin
320 * rejects one of the available network interfaces, then that interface
321 * will not be offered as one to which other plugins should send
322 * messages.
323 *
324 * For interfaces that can be used by the plugin, this function also
325 * enables the user to select which interfaces \ndds is allowed to use
326 * in sending multicast messages. The set of interfaces enabled for
327 * multicast sending is a subset of the interfaces that can be used for
328 * receiving. That is, an interface cannot be enabled to send
329 * multicast messages but disabled for receiving unicast messages.
330 *
331 * Only IP network interfaces that are "UP" (enabled by the OS and
332 * ready to use) will be passed to this filter function. The ones that
333 * are "DOWN" will not be used by definition.
334 *
335 * @param plugin \st_in The instance of the plugin for which the filter
336 * is being called.
337 *
338 * @param multicast_enabled_out \st_out The filter should set whether
339 * or not the plugin is allowed to use this interface for
340 * sending/receiving multicast messages.
341 *
342 * @param interface_in \st_in An interface offered by the plugin as a
343 * candidate for receive messages.
344 *
345 * @return 1 to use the interface.
346 * \c multicast_enabled_out will indicate whether it is also OK
347 * to use the interface to send multicast messages.
348 *
349 * @return 0 to reject using the interface.
350 */
351typedef RTI_INT32 (*NDDS_Transport_UDP_Interface_Filter_Fcn)(
352 struct NDDS_Transport_UDP_InterfaceListener *self,
353 struct NDDS_Transport_UDP *plugin,
354 RTI_INT32 *multicast_enabled_out,
355 NDDS_Transport_Interface_t *interface_in,
356 const char *interface_name_in);
357
358/*i \ingroup NDDS_Transport_UDP_InterfaceListenerClass
359 * \brief Pure virtual class for the interface listener.
360 * RTI does NOT supply a default interface listener
361 */
362struct NDDS_Transport_UDP_InterfaceListener {
363 /* \copydoc NDDS_Transport_UDP_Interface_Filter_Fcn */
364 NDDS_Transport_UDP_Interface_Filter_Fcn onInterface;
365};
366
367/* ================================================================= */
368/* Socket Factory Class */
369/* ================================================================= */
370/*i
371 * \defgroup NDDS_Transport_UDP_SocketFactoryClass
372 * NDDS_Transport_UDP_SocketFactory \ingroup NDDS_Transport_UDP_Plugin \brief
373 * Interface for socket creation and destruction.
374 *
375 * @mtsafety See NDDS_Transport_UDP_public UML diagram
376 *
377 * @see NDDS_Transport_UDP_new
378 */
379
380/*i
381 * \ingroup NDDS_Transport_UDP_SocketFactoryClass
382 * \brief Interface representation for socket creation and destruction.
383 */
384struct NDDS_Transport_UDP_SocketFactory;
385
386/*i
387 * \ingroup NDDS_Transport_UDP_SocketFactoryClass
388 * \brief Create a new sending socket for the Itransport.
389 *
390 * @pre a valid UDP transport.
391 *
392 * @post A valid UDP send socket, that may not necessarily be bound.
393 *
394 * @param transport_in \b In. The NDDS_Transport_UDP transport that will use
395 * the new socket. Specific property of the transport, such as the maximum
396 * message size allowed, can be queried from the
397 * NDDS_Transport_Plugin#property
398 *
399 * @param interface_address_in \b In. If set, must be the address of
400 * a valid interface. In addition, the socket created should be enabled
401 * to send via multicast. If is NULL, then the socket created will not
402 * be enabled to send multicast.
403 *
404 * @param interface_index_in \b In. If set, must be the index of
405 * a valid interface. In addition, the socket created should be enabled
406 * to send via multicast. If is NULL, then the socket created will not
407 * be enabled to send multicast. Interface index is used instead of an
408 * interface address in UDPv6.
409 *
410 * @return Newly created socket descriptor.
411 *
412 * @mtsafety <<oneThreadAtATime>>
413 *
414 * @see NDDS_Transport_UDP_SocketFactory_create_send_socket
415 * NDDS_Transport_UDP_SocketFactory_Socket_Destroy_Fcn
416 */
417typedef RTI_INT32 (*NDDS_Transport_UDP_SocketFactory_Send_Socket_Create_Fcn)(
418 struct NDDS_Transport_UDP_SocketFactory *me,
419 NDDS_Transport_Port_t *port_out,
420 const struct NDDS_Transport_UDP *transport_in,
421 const NDDS_Transport_Address_t *interface_address_in,
422 const int *interface_index_in);
423
424/*i
425 * \ingroup NDDS_Transport_UDP_SocketFactoryClass
426 * \brief Create a new receiving socket for the transport, which
427 * may be a multicast transport.
428 *
429 * @pre valid IP unicast transport.
430 *
431 * @post A valid, bound unicast receive socket.
432 *
433 * @param port_inout. \b InOut. NOT optional. If
434 * NDDS_TRANSPORT_PORT_INVALID, a new, previously unassigned port must
435 * be chosen, and the port must be assigned a new value so the caller
436 * knows which port it is listening on. If the port is a valid value,
437 * you must attempt to bind to that port, and not proceed in case of
438 * failure (such as if the port is already bound).
439 *
440 * @param transport_in \b In. The transport that wishes to use the
441 * socket. Properties of the IP unicast transport described in
442 * NDDS_Transport_UDP_Property_t must be met in "at least" manner. That
443 * is, doing more than requested is allowed (but will lead to waste
444 * unless the implementer has other insights which suggests more
445 * optimal use of resources), but creation of a socket that cannot meet
446 * the minimum requirement will put the system into an inconsistent
447 * state. For example, the receiving socket will be either polled or
448 * blocking; if the transport is polled
449 * (NDDS_Transport_Plugin_isPolled) it is an error to create a blocking
450 * socket. On the other hand, creating a socket that can buffer more
451 * data than requires is allowed. Specific property of the transport,
452 * such as the maximum message size to be buffered, can be queried from
453 * the NDDS_Transport_Plugin#property.
454 *
455 * @param transport_priority_in \b In. transport_priority hint. The
456 * RTI supplied socket factory NDDS_Transport_UDP_SocketFactory does not
457 * act on transport_priority. If you want to implement a
458 * transport_priority aware socket factory, either implement your own
459 * from scratch or use
460 * NDDS_Transport_UDP_SocketFactory_createReceiveSocket and specialize.
461 *
462 * @param multicast_address_in \b In. Valid if joining a multicast group.
463 *
464 * @see NDDS_Transport_UDP_SocketFactory_Send_Socket_Create_Fcn
465 * NDDS_Transport_UDP_SocketFactory_create_receive_socket
466 * NDDS_Transport_UDP_SocketFactory_Socket_Destroy_Fcn
467 */
468typedef RTI_INT32 (*NDDS_Transport_UDP_SocketFactory_Receive_Socket_Create_Fcn)(
469 struct NDDS_Transport_UDP_SocketFactory *me,
470 NDDS_Transport_Port_t *port_inout,
471 const struct NDDS_Transport_UDP *transport_in,
472 const NDDS_Transport_Address_t *multicast_address_in);
473
474/*i \ingroup NDDS_Transport_UDP_SocketFactoryClass
475 * \brief Destroy a previously created socket.
476 *
477 * @pre Socket no longer used, and no thread blocked on the socket.
478 * @post All resources associate with the socket released.
479 *
480 * @param s_in \b In. socket descriptor.
481 *
482 * @mtsafety <<oneThreadAtATime>>
483 *
484 * @see NDDS_Transport_UDP_SocketFactory_destroy_socket
485 */
486typedef RTI_INT32 (*NDDS_Transport_UDP_SocketFactory_Socket_Destroy_Fcn)(
487 struct NDDS_Transport_UDP_SocketFactory *me,
488 RTI_INT32 s_in);
489
490/*i \ingroup NDDS_Transport_UDP_SocketFactoryClass
491 * \brief Pure virtual class for the socket factory functionality.
492 * RTI supplies the UDP socket factory.
493 */
494struct NDDS_Transport_UDP_SocketFactory {
495 /*e Children: implement this method. */
496 NDDS_Transport_UDP_SocketFactory_Send_Socket_Create_Fcn create_send_socket;
497
498 /*e Children: implement this method. */
499 NDDS_Transport_UDP_SocketFactory_Receive_Socket_Create_Fcn
500 create_receive_socket;
501
502 /*e Children: implement this method to destroy both the send and
503 receive sockets. */
504 NDDS_Transport_UDP_SocketFactory_Socket_Destroy_Fcn destroy_socket;
505};
506
507/*i \ingroup NDDS_Transport_UDP_SocketFactoryClass
508 * \brief Convenience to check if the pure virtual methods have all been
509 * implemented
510 */
511#define NDDS_Transport_UDP_SocketFactory_is_valid(m) \
512 ((m)->create_send_socket && (m)->create_receive_socket && (m)->destroy_socket)
513
514/* ================================================================= */
515/* IP Socket Factory Class */
516/* ================================================================= */
517
518/*i \ingroup NDDS_Transport_UDP_Plugin
519 * \brief Realization of NDDS_Transport_Get_Class_Name_Fcn_cEA for IPv6
520 * transports.
521 *
522 * Returns the string "udpv4" or "udpv6".
523 *
524 * @see NDDS_Transport_Get_Class_Name_Fcn_cEA for complete
525 * documentation.
526 */
527extern NDDS_Transport_DllExport const char *
528NDDS_Transport_UDP_get_class_name_cEA(NDDS_Transport_Plugin *self);
529
530/*i \ingroup NDDS_Transport_UDP_Plugin
531 * \brief Realization of NDDS_Transport_String_To_Address_Fcn_cEA for IP
532 * transports.
533 *
534 * Converts a host name string to an address.
535 *
536 * @param self NOT USED. May be NULL.
537 *
538 * @param address_out \st_out The corresponding numerical value in IPv6
539 * format.
540 *
541 * @param address_in \st_in The name of the address. It can be a
542 * dot notation name or a host name. If NULL, then the IP address of
543 * the localhost will be returned.
544 *
545 * @see NDDS_Transport_String_To_Address_Fcn_cEA for complete
546 * documentation.
547 */
548extern NDDS_Transport_DllExport RTI_INT32
549NDDS_Transport_UDP_string_to_address_cEA(
550 NDDS_Transport_Plugin *self,
551 NDDS_Transport_Address_t *address_out,
552 const char *address_in);
553
554/* ================================================================= */
555/* UDP/IP Transport Plugin */
556/* ================================================================= */
557
558/*i \ingroup NDDS_Transport_UDP_Plugin
559 * \brief Create an instance of a UDP Transport Plugin.
560 *
561 * An application may create and register multiple instances of this
562 * Transport Plugin with \ndds. Multiple instances of the plugin may be useful
563 * for partitioning the network interfaces across multiple \ndds domains.
564 * However, note that the underlying transport, the operating system's IP layer,
565 * is still a "singleton." For example, if a unicast transport has already
566 * bound to a port, and another unicast transport tries to bind to the same
567 * port, the second attempt will fail.
568 *
569 * The transport plugin honors the interface/multicast "white" and "black"
570 * lists specified in the NDDS_Transport_UDP_Property_t#parent:
571 * - NDDS_Transport_Property_t#allow_interfaces_list,
572 * - NDDS_Transport_Property_t#deny_interfaces_list,
573 * - NDDS_Transport_Property_t#allow_multicast_interfaces_list,
574 * - NDDS_Transport_Property_t#deny_multicast_interfaces_list
575 *
576 * The format of a string in these lists is assumed to be in standard IPv4
577 * dot notation, possibly containing wildcards. For example:
578 * - 10.10.30.232
579 * - 10.10.*.*
580 * - 192.168.1.*
581 * - etc.
582 * Strings not in the correct format will be ignored.
583 *
584 * @param property_in \st_in Desired behavior of this transport. May be
585 * NULL for default property.
586 *
587 * @return A UDP Transport Plugin instance on success; or NULL on failure.
588 */
589extern NDDS_Transport_DllExport NDDS_Transport_Plugin *NDDS_Transport_UDP_new(
590 const struct NDDS_Transport_UDP_Property_t *property_in);
591
592/*i \ingroup NDDS_Transport_UDP_Plugin
593 * \brief Create an instance of a UDP Transport Plugin.
594 *
595 * \copydoc NDDS_Transport_UDP_new
596 *
597 * @param socket_factory_in \st_in The factory that will create all the
598 * sockets to be used in the transport. May be NULL if default factory
599 * is to be used. Only used by RTI internal testing.
600 * End users should set this parameter to NULL.
601 *
602 * @param interface_filter_in \st_in A function that will be used to
603 * filter out network interfaces that this plugin can use. May be NULL if
604 * default interface listener is to be used. The default listener uses
605 * The NDDS_Transport_UDP_Property_t#parent's lists to select the interfaces.
606 * Only used by RTI internal testing. End users should set this
607 * parameter to NULL.
608 *
609 * @exception RTI_LOG_MALLOC_FAILURE_d RTI_LOG_CREATION_FAILURE_s
610 * RTI_LOG_PRECONDITION_FAILURE RTI_LOG_INIT_FAILURE_s
611 */
612extern NDDS_Transport_DllExport NDDS_Transport_Plugin *NDDS_Transport_UDP_newI(
613 const struct NDDS_Transport_UDP_Property_t *property_in,
614 struct NDDS_Transport_UDP_SocketFactory *socket_factory_in,
615 struct NDDS_Transport_UDP_InterfaceListener *interface_listener_in);
616
617/*i \ingroup NDDS_Transport_UDP_Plugin
618 * \brief Realization of NDDS_Transport_Get_Receive_Interfaces_Fcn_cEA
619 * for IP transports.
620 *
621 * Retrieves a list of available network interfaces.
622 *
623 * @see NDDS_Transport_Get_Receive_Interfaces_Fcn_cEA for complete
624 * documentation.
625 */
626extern NDDS_Transport_DllExport RTI_INT32
627NDDS_Transport_UDP_get_receive_interfaces_cEA(
628 NDDS_Transport_Plugin *self,
629 RTI_INT32 *found_more_than_provided_for_out,
630 RTI_INT32 *interface_reported_count_out,
631 NDDS_Transport_Interface_t interface_array_inout[],
632 RTI_INT32 interface_array_size_in);
633
634/*i \ingroup NDDS_Transport_UDP_Plugin
635 * \brief Retrieve ignore_loopback property
636 */
637extern NDDS_Transport_DllExport RTI_INT32
638NDDS_Transport_UDP_get_ignore_loopback_interface_status(
639 const NDDS_Transport_Plugin *self);
640
641/*i \ingroup NDDS_Transport_UDP_Plugin
642 * \brief Checks if the provided address is a loopback address or a known
643 * interface address.
644 *
645 * The provided address is an IPv6 address which is internally mapped into a
646 * IPv4 socket address (network byte order).
647 *
648 * Unions are used to force 4-byte allignment of the IPV4 portion of
649 * the addresses. Otherwise we risk bus faults if we are ever passed
650 * unaligned address arrays.
651 */
652extern NDDS_Transport_DllExport RTIBool NDDS_Transport_UDP_is_local_address(
653 const NDDS_Transport_Plugin *self,
654 const NDDS_Transport_Address_t *address_in);
655
656/*i \ingroup NDDS_Transport_UDP_Plugin
657 * Map transport_priority to an IP_TOS value based on the configured
658 * transport properties.
659 *
660 * @brief transport_priority to IP_TOS mapping
661 */
662extern NDDS_Transport_DllExport RTI_INT32
663NDDS_Transport_UDP_map_transport_priority(
664 struct NDDS_Transport_UDP_Property_t *property,
665 RTI_INT32 transport_priority_in);
666
667/*i \ingroup NDDS_Transport_UDP_Plugin
668 * \brief Size of special "unblock" message
669 *
670 * When an ReceiveResource is unblocked with
671 * NDDS_Transport_unblock_recv_fnc_rrEA, a special unblock
672 * message may be sent. This message is guaranteed to be smaller than the
673 * minimum RTPS message size. Higher layer that processes messages
674 * returned by netio should throw away messages of this size, as it was
675 * intended to unblock a blocked thread only.
676 */
677#define NDDS_TRANSPORT_UDP_UNBLOCK_MESSAGE_SIZE \
678 (4 + 4 + sizeof(NDDS_Transport_Plugin *))
679
680/*i \ingroup NDDS_Transport_UDP_Plugin
681 * \brief DiffServ max value
682 *
683 * Maximum value of the DiffServ field in an IP packet
684 */
685#define NDDS_TRANSPORT_UDP_DIFF_SERV_MAX_VALUE RTI_OSAPI_SOCKET_MAX_DIFF_SERV
686
687struct NDDS_Transport_UDP_Statistics {
688 /***********************
689 * PUBLIC FIELDS
690 ***********************/
691 RTI_ATOMIC(RTI_UINT64) user_bytes_sent;
692 RTI_ATOMIC(RTI_UINT64) user_bytes_received;
693 RTI_ATOMIC(RTI_UINT64) user_packets_sent;
694 RTI_ATOMIC(RTI_UINT64) user_packets_received;
695 /*
696 * discovery_bytes and discovery_packets are calculated using the
697 * port number that is sent to/received from. This assumes the port
698 * is an even number. When using an odd port number (ie, using an odd
699 * domain ID), these statistics will not be calculated correctly.
700 * You should not use these members in tests where the domain ID
701 * and port numbers may change.
702 */
703 RTI_ATOMIC(RTI_UINT64) discovery_bytes_sent;
704 RTI_ATOMIC(RTI_UINT64) discovery_bytes_received;
705 RTI_ATOMIC(RTI_UINT64) discovery_packets_sent;
706 RTI_ATOMIC(RTI_UINT64) discovery_packets_received;
707 /*
708 * participant_discovery_bytes and participant_discovery_packets refer to
709 * DATA(P)s or participant bootstrap messages (i.e. messages sent/received
710 * by the anonymous participant writer/reader).
711 */
712 RTI_ATOMIC(RTI_UINT64) participant_discovery_bytes_sent;
713 RTI_ATOMIC(RTI_UINT64) participant_discovery_bytes_received;
714 RTI_ATOMIC(RTI_UINT64) participant_discovery_packets_sent;
715 RTI_ATOMIC(RTI_UINT64) participant_discovery_packets_received;
716 /*
717 * participant_config_bytes and participant_config_packets refer to
718 * participant configuration announcements sent reliably between
719 * participants.
720 */
721 RTI_ATOMIC(RTI_UINT64) participant_config_bytes_sent;
722 RTI_ATOMIC(RTI_UINT64) participant_config_bytes_received;
723 RTI_ATOMIC(RTI_UINT64) participant_config_packets_sent;
724 RTI_ATOMIC(RTI_UINT64) participant_config_packets_received;
725 RTI_ATOMIC(RTI_UINT64) automatic_liveliness_bytes_sent;
726 RTI_ATOMIC(RTI_UINT64) automatic_liveliness_bytes_received;
727 RTI_ATOMIC(RTI_UINT64) automatic_liveliness_packets_sent;
728 RTI_ATOMIC(RTI_UINT64) automatic_liveliness_packets_received;
729 RTI_ATOMIC(RTI_UINT64) manual_liveliness_bytes_sent;
730 RTI_ATOMIC(RTI_UINT64) manual_liveliness_bytes_received;
731 RTI_ATOMIC(RTI_UINT64) manual_liveliness_packets_sent;
732 RTI_ATOMIC(RTI_UINT64) manual_liveliness_packets_received;
733 RTI_ATOMIC(RTI_UINT64) endpoint_discovery_bytes_sent;
734 RTI_ATOMIC(RTI_UINT64) endpoint_discovery_bytes_received;
735 RTI_ATOMIC(RTI_UINT64) endpoint_discovery_packets_sent;
736 RTI_ATOMIC(RTI_UINT64) endpoint_discovery_packets_received;
737 /*
738 * Overhead statistics are for packets that use a builtin port (so are not
739 * user data), but are also not associated with participant or endpoint
740 * discovery
741 */
742 RTI_ATOMIC(RTI_UINT64) overhead_bytes_sent;
743 RTI_ATOMIC(RTI_UINT64) overhead_bytes_received;
744 RTI_ATOMIC(RTI_UINT64) overhead_packets_sent;
745 RTI_ATOMIC(RTI_UINT64) overhead_packets_received;
746 RTI_ATOMIC(RTI_UINT64) binding_ping_event_count;
747 RTI_ATOMIC(RTI_UINT64) binding_ping_packets_sent;
748 RTI_ATOMIC(RTI_UINT64) binding_ping_bytes_sent;
749 RTI_ATOMIC(RTI_UINT64) binding_ping_packets_received;
750 RTI_ATOMIC(RTI_UINT64) binding_ping_bytes_received;
751
752 /*
753 * Array of counters, one per DiffServ value. These counters will be
754 * incremented based on the received DiffServ values of the UDP packet.
755 *
756 * If received_priority_count[2] == 45 it means that we have received 45
757 * packets with DiffServ value 2.
758 *
759 * This field is populated only when gather_detailed_statistics is set
760 * to 1.
761 */
762 RTI_ATOMIC(RTI_UINT32)
763 received_priority_count[NDDS_TRANSPORT_UDP_DIFF_SERV_MAX_VALUE + 1];
764
765 /***********************
766 * PRIVATE FIELDS
767 ***********************/
768 /*
769 * This field is used differently depending on whether or not we are using
770 * security. If we are not using security, this field will count the
771 * automatic liveliness messages sent and received. If we are using
772 * security, this field will count both automatic and manual liveliness
773 * messages sent and received.
774 */
775 RTI_ATOMIC(RTI_UINT64) _liveliness_bytes_sent;
776 RTI_ATOMIC(RTI_UINT64) _liveliness_bytes_received;
777 RTI_ATOMIC(RTI_UINT64) _liveliness_packets_sent;
778 RTI_ATOMIC(RTI_UINT64) _liveliness_packets_received;
779};
780
781/*i
782 * @brief Initializes NDDS_Transport_UDP_Statistics.
783 */
784NDDS_Transport_DllExport void NDDS_Transport_UDP_Statistics_initialize(
785 struct NDDS_Transport_UDP_Statistics *stats);
786
787/*i
788 * @brief Copies the content of an NDDS_Transport_UDP_Statistics object to
789 * another.
790 */
791NDDS_Transport_DllExport void NDDS_Transport_UDP_copy_statistics(
792 struct NDDS_Transport_UDP_Statistics *dst,
793 const struct NDDS_Transport_UDP_Statistics *src);
794
795/*i
796 * @brief Gets transport UDP statistics from self into statistics_out.
797 */
798NDDS_Transport_DllExport void NDDS_Transport_UDP_get_statistics(
799 NDDS_Transport_Plugin *self,
800 struct NDDS_Transport_UDP_Statistics *statistics_out);
801
802/*i
803 * @brief Gets the minimum and maximum transport priorities of the self's send
804 * resources.
805 */
806NDDS_Transport_DllExport void NDDS_Transport_UDP_get_priority_range(
807 NDDS_Transport_Plugin *self,
808 RTI_INT32 *min_priority,
809 RTI_INT32 *max_priority);
810
811/*i
812 * @brief Prints an address with a leading indent of "indent" spaces and a
813 * description string "%s:".
814 */
815NDDS_Transport_DllExport void NDDS_Transport_UDP_Address_print(
816 const NDDS_Transport_Address_t *me,
817 const char *desc,
818 RTI_INT32 indent);
819
820/*i
821 * @brief Gets bytes sent by an UDP transport in a time interval from before and
822 * after transport statistics.
823 */
824NDDS_Transport_DllExport RTI_UINT64 NDDS_Transport_UDP_get_bytes_sent(
825 const struct NDDS_Transport_UDP_Statistics * const before,
826 const struct NDDS_Transport_UDP_Statistics * const after);
827
828/*i
829 * @brief Gets packets sent by an UDP transport in a time interval from before
830 * and after transport statistics.
831 */
832NDDS_Transport_DllExport RTI_UINT64 NDDS_Transport_UDP_get_packets_sent(
833 const struct NDDS_Transport_UDP_Statistics * const before,
834 const struct NDDS_Transport_UDP_Statistics * const after);
835
836/*i
837 * @brief Gets bytes received by an UDP transport in a time interval from
838 * before and after transport statistics.
839 */
840NDDS_Transport_DllExport RTI_UINT64 NDDS_Transport_UDP_get_bytes_received(
841 const struct NDDS_Transport_UDP_Statistics * const before,
842 const struct NDDS_Transport_UDP_Statistics * const after);
843
844/*i
845 * @brief Gets packets received by an UDP transport in a time interval
846 * from before and after transport statistics.
847 */
848NDDS_Transport_DllExport RTI_UINT64 NDDS_Transport_UDP_get_packets_received(
849 const struct NDDS_Transport_UDP_Statistics * const before,
850 const struct NDDS_Transport_UDP_Statistics * const after);
851
852/* ================================================================= */
853/* UDP WAN UUID */
854/* ================================================================= */
855/* Universal Unique IDentifier for a transport UDP_WAN instance. */
856typedef struct {
857 RTI_UINT8 value[9];
858} NDDS_Transport_UDP_WAN_UUID;
859
860#define NDDS_Transport_UDP_WAN_UUID_Initializer \
861 {{0, 0, 0, 0, 0, 0, 0, 0, 0}}
862
863extern NDDS_Transport_DllVariable const NDDS_Transport_UDP_WAN_UUID
864 NDDS_Transport_UDP_WAN_UUID_ZERO;
865
866extern NDDS_Transport_DllExport RTIBool
867NDDS_Transport_UDP_WAN_UUID_is_zero(NDDS_Transport_UDP_WAN_UUID *uuid);
868
879extern NDDS_Transport_DllExport RTIBool NDDS_Transport_UDP_WAN_UUID_populate(
880 NDDS_Transport_UDP_WAN_UUID *self,
881 const struct RTIOsapiRtpsGuidPrefix *guidPrefix,
882 RTI_UINT32 hostAddress);
883
884/* ================================================================= */
885/* UDPv4 WAN Transport Adress Flag */
886/* ================================================================= */
887
888typedef RTI_UINT8 NDDS_Transport_UDP_WAN_AddressFlag;
889
890
891#define NDDS_TRANSPORT_UDP_WAN_ADDRESS_FLAG_NONE (0)
892
893/*
894 * The U flag indicates if the locator contains a UUID. While this identifier by
895 * itself cannot be directly used to reach the transport instance, the UUID can
896 * be mapped to a public IP address by other Connext DDS applications and
897 * services. Also, a locator can have both, the U flag, and the P flag, enabled
898 * simultaneously. Locators with the U flag set are called UUID locators.
899 */
900#define NDDS_TRANSPORT_UDP_WAN_ADDRESS_FLAG_U (0x01U << 0)
901/*
902 * The P flag indicates that the locator contains a globally public IP address
903 * and public port where a transport instance can be reached. public_ip_address
904 * contains the public IP address and public_port contains the public UDP port.
905 * The port is always used to receive data and if the B flag is set it is also
906 * used to send data. Locators with the P flag set are called PUBLIC locators.
907 */
908#define NDDS_TRANSPORT_UDP_WAN_ADDRESS_FLAG_P (0x01U << 1)
909/*
910 * The B flag indicates if the locator is unidirectional or bidirectional.
911 * Bidirectional locators can send/receive RTPS traffic. Unidirectional locators
912 * can only receive RTPS traffic.
913 */
914#define NDDS_TRANSPORT_UDP_WAN_ADDRESS_FLAG_B (0x01U << 2)
915/*
916 * The R flag indicates if the locator is a relay locator provided by a Relay
917 * Service. Locators with the R flag set are called RELAY locators.
918 */
919#define NDDS_TRANSPORT_UDP_WAN_ADDRESS_FLAG_R (0x01U << 3)
920
921/* ================================================================= */
922/* UDPv4 WAN Transport Address Public Port */
923/* ================================================================= */
924
925typedef struct {
926 RTI_UINT8 network_ordered_value[2];
927} NDDS_Transport_UDP_WAN_NetworkPort;
928
929#define NDDS_TRANSPORT_UDP_WAN_NETWORK_PORT_INVALID {{0}}
930
931/* ================================================================= */
932/* UDPv4 WAN Transport Address Public Address */
933/* ================================================================= */
934
935typedef struct {
936 RTI_UINT8 network_ordered_value[4];
937} NDDS_Transport_UDP_WAN_NetworkIpv4Address;
938
939#define NDDS_TRANSPORT_UDP_WAN_NETWORK_IP_ADDRESS_INVALID {{0}}
940
941/* ================================================================= */
942/* UDPv4 WAN Transport Address */
943/* ================================================================= */
944/*
945 * UDPv4_WAN locators use the following NDDS_Transport_Address_t mapping:
946 *
947 * +-------+-------+-------+-------+
948 * | Flags | |
949 * +-------+ +
950 * | DDS_Octet UUID[9] |
951 * | +-------+-------+
952 * | | public_port |
953 * +-------+-------+-------+-------+
954 * | DDS_Octet public_ip_address[4]|
955 * +-------+-------+-------+-------+
956 */
957
958typedef struct {
959 NDDS_Transport_UDP_WAN_AddressFlag _flags;
960 NDDS_Transport_UDP_WAN_UUID _uuid;
961 NDDS_Transport_UDP_WAN_NetworkPort _publicPort;
962 NDDS_Transport_UDP_WAN_NetworkIpv4Address _publicAddress;
963} NDDS_Transport_UDPv4_WAN_Address;
964
965extern NDDS_Transport_DllExport NDDS_Transport_UDP_Port
966NDDS_Transport_UDPv4_WAN_Address_get_public_port(
967 const NDDS_Transport_UDPv4_WAN_Address *self);
968
969extern NDDS_Transport_DllExport NDDS_Transport_UDP_Port
970NDDS_Transport_UDPv4_WAN_Address_get_public_port_for_rtps_port(
971 const NDDS_Transport_UDPv4_WAN_Address *self,
972 NDDS_Transport_Port_t rtps_port,
973 RTI_INT32 udp_port_offset);
974
975extern NDDS_Transport_DllExport void
976NDDS_Transport_UDPv4_WAN_Address_set_public_port(
977 NDDS_Transport_UDPv4_WAN_Address *self,
978 NDDS_Transport_UDP_Port public_port);
979
980extern NDDS_Transport_DllExport RTI_UINT32
981NDDS_Transport_UDPv4_WAN_Address_get_public_address(
982 const NDDS_Transport_UDPv4_WAN_Address *self);
983
984extern NDDS_Transport_DllExport void
985NDDS_Transport_UDPv4_WAN_Address_set_public_address(
986 NDDS_Transport_UDPv4_WAN_Address *self,
987 RTI_UINT32 public_address);
988
1003extern NDDS_Transport_DllExport void NDDS_Transport_UDP_combine_addresses(
1004 const NDDS_Transport_Plugin *self,
1005 NDDS_Transport_Address_t *address_out,
1006 const NDDS_Transport_Address_t *first_address_in,
1007 const NDDS_Transport_Address_t *second_address_in);
1008
1009/*i
1010 * @brief Gets the public address mapping in the provided address for the provided
1011 * (UUID, RTPS port) tuple.
1012 *
1013 * @param self \b In. Plugin, must be WAN.
1014 * @param address \b Out. Address to populate with the binding ping mapping.
1015 * @param rtpsPort \b In. Binding ping RTPS port.
1016 * @param uuid \b In. Binding ping UUID.
1017 *
1018 * @return RTI_TRUE if success, RTI_FALSE if error or if the binding ping
1019 * mapping does not exist.
1020 */
1021extern NDDS_Transport_DllExport RTIBool
1022NDDS_Transport_UDP_get_binding_ping_mapping(
1023 NDDS_Transport_Plugin *self,
1024 NDDS_Transport_UDPv4_WAN_Address *address,
1025 NDDS_Transport_Port_t rtpsPort,
1026 const NDDS_Transport_UDP_WAN_UUID *uuid);
1027
1028#ifdef __cplusplus
1029} /* extern "C" */
1030#endif
1031
1032#include "transport/transport_udp_impl.h"
1033
1034#endif /* transport_udp_h */
RTI_UINT32 NDDS_Transport_Port_t
Type for storing RTI Connext RTPS ports.
Definition: transport_common.h:92
RTI_UINT16 NDDS_Transport_UDP_Port
UDP port.
Definition: transport_udp.h:73
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
Base configuration structure that must be inherited by derived Transport Plugin classes.
Definition: transport_interface_user.h:38
Type for storing UDP WAN communication ports.
Definition: transport_udp.h:84
NDDS_Transport_UDP_Port public_port
Public port.
Definition: transport_udp.h:93
NDDS_Transport_UDP_Port host_port
Host port.
Definition: transport_udp.h:90
NDDS_Transport_Port_t rtps_port
RTPS port.
Definition: transport_udp.h:87