RTI Connext Micro  Version 2.4.1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
rtps_rtps.h
Go to the documentation of this file.
1 /*
2  * FILE: RTPSInterface.h
3  *
4  * Copyright 2008-2014 Real-Time Innovations, Inc.
5  *
6  * No duplications, whole or partial, manual or electronic, may be made
7  * without express written permission. Any such copies, or
8  * revisions thereof, must display this notice unaltered.
9  * This code contains trade secrets of Real-Time Innovations, Inc.
10  *
11  * Modification History
12  * --------------------
13  * 13oct2014,eh MICRO-925: remove unused RTPS_DATAFLAGS_K
14  * 09may2014,eh MICRO-261 (Verocel PR#1421): remove RTPS_SubmessageId_toString
15  * for Cert
16  * 07jan2014,eh MICRO-733: update to Connext Micro vendor ID
17  * 15may2013,eh MICRO-394: constant inline qos lengths, from CR-138
18  * 18may2011,eh Created, based on Waveworks tree.
19  */
20 
21 
22 /*e \file
23  * \brief RTPS interface functions and types
24  *
25  * \details
26  * RTPS protocol defined types, implemented in C.
27  *
28  *
29  */
30 #ifndef rtps_rtps_h
31 #define rtps_rtps_h
32 
33 
34 #ifndef osapi_types_h
35 #include "osapi/osapi_types.h"
36 #endif
37 #ifndef reda_epoch_h
38 #include "reda/reda_epoch.h"
39 #endif
40 #ifndef reda_sequenceNumber_h
41 #include "reda/reda_sequenceNumber.h"
42 #endif
43 #ifndef osapi_time_h
44 #include "osapi/osapi_time.h"
45 #endif
46 #ifndef osapi_system_h
47 #include "osapi/osapi_system.h"
48 #endif
49 #ifndef rtps_dll_h
50 #include "rtps/rtps_dll.h"
51 #endif
52 #ifndef cdr_stream_h
53 #include "cdr/cdr_stream.h"
54 #endif
55 #ifndef netio_common_h
56 #include "netio/netio_common.h"
57 #endif
58 #ifndef netio_common_h
59 #include "netio/netio_common.h"
60 #endif
61 #ifndef netio_address_h
62 #include "netio/netio_address.h"
63 #endif
64 #ifndef netio_route_h
65 #include "netio/netio_route.h"
66 #endif
67 #ifndef netio_interface_h
68 #include "netio/netio_interface.h"
69 #endif
70 
71 #ifdef __cplusplus
72 extern "C"
73 {
74 #endif
75 
76 
77 /*ci \brief RTPS module return code */
78 typedef RTI_UINT32 RTPS_ReturnCode_t;
79 
80 /*i \dref_ReturnCode_t_RETCODE_OK
81  */
82 #define RTPS_RETCODE_OK 0
83 
84 #define RTPS_RETCODE_START 1000
85 
86 /*i \dref_ReturnCode_t_RETCODE_ERROR
87 */
88 #define RTPS_RETCODE_ERROR RTPS_RETCODE_START
89 
90 /*i \dref_ReturnCode_t_RETCODE_UNSUPPORTED
91  */
92 #define RTPS_RETCODE_UNSUPPORTED RTPS_RETCODE_START + 1
93 
94 /*i \dref_ReturnCode_t_RETCODE_BAD_PARAMETER
95  */
96 #define RTPS_RETCODE_BAD_PARAMETER RTPS_RETCODE_START + 2
97 
98 /*i \dref_ReturnCode_t_RETCODE_PRECONDITION_NOT_MET
99  */
100 #define RTPS_RETCODE_PRECONDITION_NOT_MET RTPS_RETCODE_START + 3
101 
102 /*i \dref_ReturnCode_t_RETCODE_OUT_OF_RESOURCES
103  */
104 #define RTPS_RETCODE_OUT_OF_RESOURCES RTPS_RETCODE_START + 4
105 
106 /*i \dref_ReturnCode_t_RETCODE_ALREADY_DELETED
107  */
108 #define RTPS_RETCODE_ALREADY_DELETED RTPS_RETCODE_START + 5
109 
110 
111 /*ci \brief Maximum length of an RTPS serializable path name string */
112 #define RTPS_PATHNAME_LEN_MAX (255)
113 
114 
115 /*ci \ingroup RTPS_PidModule
116  * \brief RTPS parameter ID, used to describe RTPS objects.
117  */
118 typedef RTI_UINT16 RTPS_ParameterId;
119 
120 /*ci \ingroup RTPS_PidModule
121  * \brief Mask for ParameterId bit indicating subspace where
122  * unrecognized PIDs are either ignored or treated as
123  * incompatible QoS.
124 */
125 #define RTPS_PID_INCOMPATIBLE_MASK (0x4000)
126 
127 /*ci \ingroup RTPS_PidModule
128  * \brief Pad for parameter values in case they don't end on a 4-byte boundary
129  */
130 #define RTPS_PID_PAD (0x0000)
131 
132 /*ci \ingroup RTPS_PidModule
133  * \brief Indicate end of parameter sequence.
134  */
135 #define RTPS_PID_SENTINEL (0x0001)
136 
137 /*ci \ingroup RTPS_PidModule
138  * \brief Topic name parameter ID
139  *
140  * \details
141  * Used for field Publication::topic: PathName, Subscription::topic : PathName
142  */
143 #define RTPS_PID_TOPIC_NAME (0x0005)
144 
145 /*ci \ingroup RTPS_PidModule
146  * \brief Type name parameter ID
147  *
148  * \details
149  * Used for field Publication::typeName : TypeName,
150  * Subscription::typeName : TypeName
151  */
152 #define RTPS_PID_TYPE_NAME (0x0007)
153 
154 /*ci \ingroup RTPS_PidModule
155  * \brief Durability Qos parameter ID
156  *
157  * \details Used for field
158  * Publication::durabilityQosPolicy : DurabilityQosPolicy, and
159  * Subscription::durabilityQosPolicy : DurabilityQosPolicy
160  */
161 #define RTPS_PID_DURABILITY (0x001d)
162 
163 
164 /*ci \ingroup RTPS_PidModule
165  * \brief Deadline Qos parameter ID
166  *
167  * \details
168  * Used for field Subscription::deadlineQosPolicy : DeadlineQosPolicy
169  */
170 #define RTPS_PID_DEADLINE (0x0023)
171 
172 /*ci \ingroup RTPS_PidModule
173  * \brief Liveliness Qos parameter ID
174  *
175  * \details
176  * Used for field Publication::livelinessQosPolicy : LivelinessQosPolicy, and
177  * Subscription::livelinessQosPolicy : LivelinessQosPolicy
178  */
179 #define RTPS_PID_LIVELINESS (0x001b)
180 
181 /*ci \ingroup RTPS_PidModule
182  * \brief Reliability Qos parameter ID
183  *
184  * \details
185  * Used for field Publication::reliabilityOffered : RTI_UINT32, and
186  * Subscription::reliabilityRequested : RTI_UINT32
187  */
188 #define RTPS_PID_RELIABILITY (0x001a)
189 
190 /*ci \ingroup RTPS_PidModule
191  * \brief Ownership Qos parameter ID
192  *
193  * \details
194  * Used for field Subscription::ownershipQosPolicy : OwnershipQosPolicy
195  */
196 #define RTPS_PID_OWNERSHIP (0x001f)
197 
198 /*ci \ingroup RTPS_PidModule
199  * \brief Ownership Strength Qos parameter ID
200  *
201  * \details
202  * Used for field Publication::strength : long
203  */
204 #define RTPS_PID_OWNERSHIP_STRENGTH (0x0006)
205 
206 /*ci \ingroup RTPS_PidModule
207  * \brief Protocol Version paramater ID
208  *
209  * \details
210  * Used for field Application::protocolVersion : ProtocolVersion
211  */
212 #define RTPS_PID_PROTOCOL_VERSION (0x0015)
213 
214 /*ci \ingroup RTPS_PidModule
215  * \brief Vendor ID parameterID
216  *
217  * \details
218  * Used for field Application::vendorId : VendorId
219  */
220 #define RTPS_PID_VENDOR_ID (0x0016)
221 
222 
223 /*ci \brief Maximum number of addresses per type, per entity */
224 #define RTPS_PID_USERDATA_IPADDRESS_COUNT_MAX (4)
225 
226 /*ci \ingroup RTPS_PidModule
227  * \brief Unicast locator parameter ID
228  *
229  * \details Array of max size RTPS_PID_USERDATA_UNICAST_IPADDRESS_COUNT_MAX
230  */
231 #define RTPS_PID_UNICAST_LOCATOR6 (0x002f)
232 
233 /*ci \ingroup RTPS_PidModule
234  * \brief Multicast locator parameter ID
235  *
236  * \details Array of max size RTPS_PID_USERDATA_UNICAST_IPADDRESS_COUNT_MAX
237  */
238 #define RTPS_PID_MULTICAST_LOCATOR6 (0x0030)
239 
240 /*ci \ingroup RTPS_PidModule
241  * \brief Default unicast locator parameter ID
242  *
243  * \details Array of max size RTPS_PID_USERDATA_UNICAST_IPADDRESS_COUNT_MAX
244  */
245 #define RTPS_PID_DEFAULT_UNICAST_LOCATOR6 (0x0031)
246 
247 /*ci \ingroup RTPS_PidModule
248  * \brief Discovery (meta-traffic) unicast locator parameter ID
249  *
250  * \details Array of max size RTPS_PID_USERDATA_UNICAST_IPADDRESS_COUNT_MAX
251  */
252 #define RTPS_PID_METATRAFFIC_UNICAST_LOCATOR6 (0x0032)
253 
254 /*ci \ingroup RTPS_PidModule
255  * \brief Discovery (meta-traffic) multicast locator parameter ID
256  *
257  * \details Array of max size RTPS_PID_USERDATA_UNICAST_IPADDRESS_COUNT_MAX
258  */
259 #define RTPS_PID_METATRAFFIC_MULTICAST_LOCATOR6 (0x0033)
260 
261 /*ci \ingroup RTPS_PidModule
262  * \brief Liveliness lease duration parameter ID
263  */
264 #define RTPS_PID_LEASE_DURATION (0x0002)
265 
266 /*ci \ingroup RTPS_PidModule
267  * \brief Property Qos parameter ID
268  *
269  * \details Used for field Participant::propertyList
270  */
271 #define RTPS_PID_PROPERTY_LIST (0x0059)
272 
273 /*ci \ingroup RTPS_PidModule
274  * \brief Participant GUID parameter ID
275  */
276 #define RTPS_PID_PARTICIPANT_GUID (0x0050)
277 
278 /*ci \ingroup RTPS_ParameterSequenceClass
279  * \brief Builtin endpoint mask parameter ID
280  *
281  * \details Indicate builtin endpoint set inline Qos,
282  * PID_BUILTIN_ENDPOINT_SET from the RTPS spec
283  */
284 #define RTPS_PID_BUILTIN_ENDPOINT_MASK (0x0058)
285 
286 /*ci \ingroup RTPS_ParameterSequenceClass
287  * \brief Endpoint GUID parameter ID
288  */
289 #define RTPS_PID_ENDPOINT_GUID (0x005A)
290 
291 /*ci \ingroup RTPS_ParameterSequenceClass
292  * \brief Entity name parameter ID
293  */
294 #define RTPS_PID_ENTITY_NAME (0x0062)
295 
296 /******************************************************************************/
297 /*ci \ingroup RTPS_ParameterSequenceClass
298  * \brief Key Hash parameter ID
299  */
300 #define RTPS_PID_KEY_HASH (0x0070)
301 
302 /*ci \brief Key Hash parameter length */
303 #define RTPS_KEY_HASH_PARAM_LENGTH (16)
304 
305 /*ci \ingroup RTPS_ParameterSequenceClass
306  * \brief Status info parameter ID
307  */
308 #define RTPS_PID_STATUS_INFO (0x0071)
309 
310 /*ci \brief Status info parameter length */
311 #define RTPS_STATUS_INFO_PARAM_LENGTH (4)
312 
313 /*ci \brief Send queue size parameter ID */
314 #define RTPS_PID_SEND_QUEUE_SIZE_DEPRECATED (0x0013)
315 
316 /******************************************************************************/
317 /*ci \ingroup RTPS_Class
318  * \brief Host ID of GUID
319  */
320 typedef RTI_UINT32 RTPS_HostId;
321 
322 /*ci \ingroup RTPS_Class
323  * \brief Unknown Host ID
324  */
325 #define RTPS_HOST_ID_UNKNOWN (0x00000000)
326 
327 /*ci \ingroup RTPS_Class
328  * \brief Application ID of GUID
329  */
330 typedef RTI_UINT32 RTPS_AppId;
331 
332 /*ci \ingroup RTPS_Class
333  * \brief Unknown Application ID
334  */
335 #define RTPS_APP_ID_UNKNOWN (0x00000000)
336 
337 /*ci \ingroup RTPS_Class
338  * \brief Instance ID of GUID
339  */
340 typedef RTI_UINT32 RTPS_InstanceId;
341 
342 /*ci \ingroup RTPS_Class
343  * \brief Unknown Instance ID
344  */
345 #define RTPS_INSTANCE_ID_UNKNOWN (0x00000000)
346 
347 /*ci \ingroup RTPS_Class
348  * \brief Object ID of GUID
349  */
350 typedef RTI_UINT32 RTPS_ObjectId;
351 
352 /*ci \ingroup RTPS_Class
353  * \brief Unknown Object ID
354  */
355 #define RTPS_OBJECT_ID_UNKNOWN (0x00000000)
356 
357 /*ci \ingroup RTPS_Class
358  * \brief Maximum Object ID
359  */
360 #define RTPS_OBJECT_ID_MAX (0xFFFFFFFF)
361 
362 /******************************************************************************/
363 /*ci \ingroup RTPS_Class
364  * \brief Prefix portion of GUID.
365  *
366  * \details Uniquely identifies the DomainParticipant to which
367  * an RTPS's DDS entity belong
368  */
369 struct RTPS_GuidPrefix
370 {
371  /*ci \brief First field of GUID Prefix.
372  * \details Historically set to host IP address
373  */
374  RTPS_HostId hostId;
375 
376  /*ci \brief Second field of GUID Prefix.
377  * \details Historically set to process ID
378  */
379  RTPS_AppId appId;
380 
381  /*ci \brief Third field of GUID prefix.
382  * \details Historically set to instance counter
383  */
384  RTPS_InstanceId instanceId;
385 };
386 
387 /*ci \ingroup RTPS_Class
388  * \brief Unknonwn GUID prefix
389  */
390 #define RTPS_GUID_PREFIX_UNKNOWN { \
391  RTPS_HOST_ID_UNKNOWN, \
392  RTPS_APP_ID_UNKNOWN, \
393  RTPS_INSTANCE_ID_UNKNOWN}
394 
395 /*ci \ingroup RTPS_Class
396  * \brief Length in bytes of GUID prefix
397  */
398 #define RTPS_GUID_PREFIX_SIZE (12)
399 
400 /*ci \ingroup RTPS_Class
401  * \brief GUID
402  */
403 struct RTPS_Guid
404 {
405  /*ci \brief GUID prefix */
406  struct RTPS_GuidPrefix prefix;
407 
408  /*ci \brief Unique entity identifier */
409  RTPS_ObjectId objectId;
410 };
411 
412 /*ci \ingroup RTPS_Class
413  * \brief Unknown GUID
414  */
415 #define RTPS_GUID_UNKNOWN { \
416  RTPS_GUID_PREFIX_UNKNOWN, \
417  RTPS_OBJECT_ID_UNKNOWN}
418 
419 /******************************************************************************/
420 /*ci \brief Participant Object ID */
421 #define RTPS_OBJECT_ID_PARTICIPANT (0x000001C1)
422 
423 /*ci \brief Simple Discovery Protocol Participant Writer Object ID */
424 #define RTPS_OBJECT_ID_WRITER_SDP_PARTICIPANT (0x000100C2)
425 
426 /*ci \brief Simple Discovery Protocol Publication Writer Object ID */
427 #define RTPS_OBJECT_ID_WRITER_SDP_PUBLICATION (0x000003C2)
428 
429 /*ci \brief Simple Discovery Protocol Subscription Writer Object ID */
430 #define RTPS_OBJECT_ID_WRITER_SDP_SUBSCRIPTION (0x000004C2)
431 
432 /*ci \brief Simple Discovery Protocol Participant Reader Object ID */
433 #define RTPS_OBJECT_ID_READER_SDP_PARTICIPANT (0x000100C7)
434 
435 /*ci \brief Simple Discovery Protocol Subscription Reader Object ID */
436 #define RTPS_OBJECT_ID_READER_SDP_PUBLICATION (0x000003C7)
437 
438 /*ci \brief Simple Discovery Protocol Subscription Reader Object ID */
439 #define RTPS_OBJECT_ID_READER_SDP_SUBSCRIPTION (0x000004C7)
440 
441 /******************************************************************************/
442 /*ci \brief Key Hash max length */
443 #define RTPS_KEY_HASH_MAX_LENGTH 16
444 
445 /*ci \brief Hash of instance key */
446 struct RTPS_KeyHash
447 {
448  /*ci \brief Key hash value */
449  RTI_UINT8 value[RTPS_KEY_HASH_MAX_LENGTH];
450 
451  /*ci \brief Key hash length */
452  RTI_UINT32 length;
453 };
454 
455 /*ci \brief Nil Key Hash value */
456 #define RTPS_KEY_HASH_NIL {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
457 
458 /*ci \brief Default Key Hash Initializer */
459 #define RTPS_KEY_HASH_DEFAULT { \
460 RTPS_KEY_HASH_NIL, /* value */\
461 RTPS_KEY_HASH_MAX_LENGTH/* length */\
462 }
463 
464 /******************************************************************************/
465 /*ci \ingroup RTPS_Class
466  * \brief Returns RTI_TRUE if GUIDs are equal
467  *
468  * \param[in] a First GUID
469  * \param[in] b Second GUID
470  *
471  * \return RTI_TRUE if GUIDs are equal, RTI_FALSE otherwise
472  */
473 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
474 RTPS_Guid_equals(struct RTPS_Guid *a, struct RTPS_Guid *b);
475 
476 /*ci \ingroup RTPS_Class
477  * \brief Returns RTI_TRUE if GUID prefixes are equal
478  *
479  * \param[in] a First GUID
480  * \param[in] b Second GUID
481  *
482  * \return RTI_TRUE if prefixes of GUIDs are equal, RTI_FALSE otherwise
483  */
484 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
485 RTPS_Guid_prefix_equals(
486  struct RTPS_Guid *a,
487  struct RTPS_Guid *b);
488 
489 /*ci \ingroup RTPS_Class
490  * \brief Returns RTI_TRUE if GUID suffixes are equal
491  *
492  * \param[in] a First GUID
493  * \param[in] b Second GUID
494  *
495  * \return RTI_TRUE if suffixes of GUIDs are equal, RTI_FALSE otherwise
496  */
497 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
498 RTPS_Guid_suffix_equals(
499  struct RTPS_Guid *a,
500  struct RTPS_Guid *b);
501 
502 /******************************************************************************/
503 /*ci \brief RTPS Protocol Version type */
504 typedef RTI_UINT16 RTPS_ProtocolVersion_T;
505 
506 /*ci \brief Major version of supported RTPS protocol */
507 #define RTPS_PROTOCOL_VERSION_MAJOR (0x02)
508 
509 /*ci \brief Minor version of supported RTPS protocol */
510 #define RTPS_PROTOCOL_VERSION_MINOR (0x01)
511 
512 /*ci \brief RTPS Vendor ID type */
513 typedef RTI_UINT16 RTPS_VendorId;
514 
515 /*ci \brief Major version of vendor ID */
516 #define RTPS_VENDOR_ID_MAJOR (0x01)
517 
518 /*ci \brief Minor version of vendor ID */
519 #define RTPS_VENDOR_ID_MINOR (0x0A)
520 
521 /*ci \brief Connext DDS Vendor ID */
522 #define RTPS_VENDOR_ID_RTI_DDS (0x0101)
523 
524 /*ci \brief Connext Micro Vendor ID */
525 #define RTPS_VENDOR_ID_RTI_MICRO (0x010A)
526 
527 /*ci \brief Get major byte of vendor ID */
528 RTPS_VendorId
529 RTPS_VendorId_getMajor(RTPS_VendorId *me);
530 
531 /*ci \brief Get minor byte of vendor ID */
532 RTPS_VendorId
533 RTPS_VendorId_getMinor(RTPS_VendorId *me);
534 
535 /*****************************************************************************/
536 /*ci \brief RTPS Status Info type */
537 typedef RTI_UINT32 RTPS_StatusInfo;
538 
539 /*ci \brief Default empty status info */
540 #define RTPS_NO_STATUS_INFO (0x00000000)
541 
542 /*ci \brief Dispose status info bit */
543 #define RTPS_DISPOSE_STATUS_INFO (0x00000001)
544 
545 /*ci \brief Unregister status info bit */
546 #define RTPS_UNREGISTER_STATUS_INFO (0X00000002)
547 
548 /*ci \brief RTPS submessage header endian flag */
549 #define RTPS_ENDIAN_FLAG (0x01)
550 
551 /*****************************************************************************/
552 
553 /*ci \ingroup RTPS_Class
554  * \brief Denotes the built-in object types
555  *
556  * \details
557  * RTPSObject is categorized into (normal/reserved) x (user/meta) quadrant.
558  * Within each quadrant, there are several built-in (provided for at the RTPS
559  * protocol level) objects, such as application, publication/subscription,
560  * CST (keyed) writer/reader.
561  */
562 typedef enum
563 {
564  RTPS_OBJECT_NORMAL_USER_UNKNOWN = 0x00,
565  RTPS_OBJECT_NORMAL_USER_APPLICATION = 0x01,
566  /*ci \brief Use this suffix for writers of data with a key. */
567  RTPS_OBJECT_NORMAL_USER_CST_WRITER = 0x02,
568  /*ci \brief Use this suffix for writers of data with no key. */
569  RTPS_OBJECT_NORMAL_USER_PUBLICATION = 0x03,
570  /*ci \brief Use this suffix for readers of data with no key. */
571  RTPS_OBJECT_NORMAL_USER_SUBSCRIPTION = 0x04,
572  /*ci \brief Use this suffix for readers of data with a key. */
573  RTPS_OBJECT_NORMAL_USER_CST_READER = 0x07,
574  RTPS_OBJECT_NORMAL_USER_VIRTUAL_SUBSCRIPTION = 0x3C,
575  RTPS_OBJECT_NORMAL_USER_VIRTUAL_CST_READER = 0x3D,
576  RTPS_OBJECT_RESERVED_USER_UNKNOWN = 0x40,
577  RTPS_OBJECT_RESERVED_USER_APPLICATION = 0x41,
578  RTPS_OBJECT_RESERVED_USER_CST_WRITER = 0x42,
579  RTPS_OBJECT_RESERVED_USER_PUBLICATION = 0x43,
580  RTPS_OBJECT_RESERVED_USER_SUBSCRIPTION = 0x44,
581  RTPS_OBJECT_RESERVED_USER_CST_READER = 0x47,
582  RTPS_OBJECT_NORMAL_META_UNKNOWN = 0x80,
583  RTPS_OBJECT_NORMAL_META_APPLICATION = 0x81,
584  RTPS_OBJECT_NORMAL_META_CST_WRITER = 0x82,
585  RTPS_OBJECT_NORMAL_META_PUBLICATION = 0x83,
586  RTPS_OBJECT_NORMAL_META_SUBSCRIPTION = 0x84,
587  RTPS_OBJECT_NORMAL_META_CST_READER = 0x87,
588  RTPS_OBJECT_RESERVED_META_UNKNOWN = 0xc0,
589  RTPS_OBJECT_RESERVED_META_APPLICATION = 0xc1,
590  RTPS_OBJECT_RESERVED_META_CST_WRITER = 0xc2,
591  RTPS_OBJECT_RESERVED_META_PUBLICATION = 0xc3,
592  RTPS_OBJECT_RESERVED_META_SUBSCRIPTION = 0xc4,
593  RTPS_OBJECT_RESERVED_META_CST_READER = 0xc7
594 } RTPS_ObjectSuffix;
595 
596 
597 /* ===========================================================================*/
598 /* RTPS types */
599 /* ===========================================================================*/
600 /*ci \brief RTPS loactor address max length */
601 #define RTPS_LOCATOR_ADDRESS_LENGTH_MAX 16
602 
603 /*ci \brief RTPS Locator type */
604 struct RTPS_Locator_t
605 {
606  /*ci \brief Locator kind */
607  RTI_INT32 kind;
608 
609  /*ci \brief Locator port */
610  RTI_UINT32 port;
611 
612  /*ci \brief Locator address */
613  RTI_UINT8 address[RTPS_LOCATOR_ADDRESS_LENGTH_MAX];
614 };
615 
616 /*ci \brief Default locator initializer */
617 #define RTPS_LOCATOR_DEFAULT {\
618  -1, /* kind */\
619  0, /* port */\
620  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} /* address */\
621 }
622 
623 /*ci \brief RTPS Locator type */
624 #define RTPS_Locator RTPS_Locator_t
625 
626 /*ci \brief UDPv4 locator type */
627 struct RTPS_LocatorUdpv4_t
628 {
629  /*ci \brief Locator kind */
630  RTI_INT32 kind;
631 
632  /*ci \brief Locator port */
633  RTI_UINT32 port;
634 
635  /*ci \brief Locator address */
636  RTI_UINT32 address;
637 };
638 
639 /*ci \brief Default UDPv4 locator initializer */
640 #define RTPS_LOCATOR_UDPV4_DEFAULT {\
641  -1, /* kind */\
642  0, /* port */\
643  0 /* address */\
644 }
645 
646 /*ci \brief Invalid Locator */
647 extern RTPSDllVariable const struct RTPS_Locator_t RTPS_LOCATOR_INVALID;
648 
649 /*ci \brief Invalid Locator kind */
650 extern RTPSDllVariable const RTI_INT32 RTPS_LOCATOR_KIND_INVALID;
651 
652 /*ci \brief Invalid Locator port */
653 extern RTPSDllVariable const RTI_UINT32 RTPS_LOCATOR_PORT_INVALID;
654 
655 /*ci \brief Invalid Locator address */
656 extern RTPSDllVariable const RTI_UINT8
657  RTPS_LOCATOR_ADDRESS_INVALID[RTPS_LOCATOR_ADDRESS_LENGTH_MAX];
658 
659 /*ci \brief UDPv4 Locator kind */
660 extern RTPSDllVariable const RTI_INT32 RTPS_LOCATOR_KIND_UDPv4;
661 
662 /*ci \brief UDPv6 Locator kind */
663 extern RTPSDllVariable const RTI_INT32 RTPS_LOCATOR_KIND_UDPv6;
664 
665 /*ci \brief Reserved Locator kind */
666 extern RTPSDllVariable const RTI_INT32 RTPS_LOCATOR_KIND_RESERVED;
667 
668 /*ci \brief Shared Memory Locator kind */
669 extern RTPSDllVariable const RTI_INT32 RTPS_LOCATOR_KIND_SHMEM;
670 
671 
672 /* ===========================================================================*/
673 /* RTPS Sequence Number */
674 /* ===========================================================================*/
675 
676 
677 /*ci \ingroup RTPS_SequenceNumberClass
678  * \brief Deserialize sequence number from stream buffer
679  *
680  * \details
681  * Post-condition: sequenceNumber is packed and stream pointer is moved forward.
682  *
683  * \param[inout] srcBuffer Deserialization stream buffer
684  * \param[out] instance Deserialized instance
685  * \param[in] byteSwap RTI_TRUE if byte swapping is necessary,
686  * RTI_FALSE otherwise.
687  *
688  */
689 RTPSDllExport void
690 RTPS_SequenceNumber_deserialize(char **srcBuffer,
691  struct REDA_SequenceNumber *instance,
692  RTI_BOOL byteSwap);
693 
694 
695 /*ci \ingroup RTPS_SequenceNumberClass
696  * \brief Calculate the distance between two sequence numbers.
697  *
698  * \param[in] s1 First sequence number
699  * \param[in] s2 Second sequence number
700  *
701  * \return The distance, possibly saturated to RTPS_BITMAP_DISTANCE_MAX.
702  * -1 on failure.
703  */
704 MUST_CHECK_RETURN RTPSDllExport RTI_INT32
705 RTPS_SequenceNumber_getDistance(
706  const struct REDA_SequenceNumber *s1,
707  const struct REDA_SequenceNumber *s2);
708 
709 /*ci \brief Bitmap array max size
710  * \details Bitmap has maximum 256 bits, using (256/32 =) 8 ints
711  */
712 #define RTPS_BITMAP_32BITS_ARRAY_SIZE_MAX (8)
713 
714 /*ci
715  * \brief Bitmap of sequence numbers received
716  *
717  * \details
718  * Tracks sequence numbers of samples sent or received. Used in send and
719  * window implementations.
720  */
721 struct RTPS_Bitmap
722 {
723  /*ci \brief Starting sequence number of bitmap */
724  struct REDA_SequenceNumber _lead;
725 
726  /*ci \brief Number of valid bits or sequence numbers, starting from lead */
727  RTI_INT32 _bitCount;
728 
729  /*ci \brief The bitmap stored as an array of integers.
730  *
731  * \details
732  * Maximum of 256 (=8*32) bits or sequence numbers.
733  * This must be unsigned in order to apply the >> operator.
734  * There are two approaches to handle bits outside bitCount:
735  * 1) They must always be zeroed.
736  * 2) They can be anything.
737  * The first approach puts the burden on otherwise simple
738  * methods such as truncate to zero out truncated bits, whereas
739  * the second approach puts the burden on methods such as shift
740  * to make sure bits beyond the bitCount are not shifted in.
741  * In our implementation, we have opted for the second approach.
742  */
743  RTI_UINT32 _32bits[RTPS_BITMAP_32BITS_ARRAY_SIZE_MAX];
744 };
745 
746 /*ci \brief Maximum number of bits in bitmap */
747 #define RTPS_BITMAP_SIZE_MAX (256)
748 
749 /*ci \brief Maximum bitmap sequence number distance */
750 #define RTPS_BITMAP_DISTANCE_MAX (0x7FFFFFFF)
751 
752 /*ci
753  * \brief Get the lead sequence number of a bitmap
754  *
755  * \param[in] bitmap Bitmap
756  *
757  * \return Pointer to lead sequence number of bitmap
758  */
759 MUST_CHECK_RETURN struct REDA_SequenceNumber*
760 RTPS_Bitmap_getLead(const struct RTPS_Bitmap *me);
761 
762 /*ci
763  * \brief Get the bitCount of a bitmap
764  *
765  * \param[in] bitmap Bitmap
766  *
767  * \return BitCount of bitmap
768  */
769 MUST_CHECK_RETURN RTI_INT32
770 RTPS_Bitmap_getBitCount(const struct RTPS_Bitmap *me);
771 
772 /*ci \brief Reset bitmap to specified lead and bitCount
773  *
774  * \details Post condition: bitmap has its lead and bit count assigned, and
775  * all bits are reset to zero.
776  *
777  * \param[in] me Bitmap
778  * \param[in] seqNum New lead sequence number
779  * \param[in] bitCount New bit count. Must be <= RTPS_BITMAP_SIZE_MAX.
780  *
781  */
782 RTPSDllExport void
783 RTPS_Bitmap_reset(
784  struct RTPS_Bitmap *me,
785  const struct REDA_SequenceNumber *seqNum,
786  RTI_INT32 bitCount);
787 
788 /*ci \ingroup RTPS_BitmapClass
789  * \brief Set specified bit in bitmap.
790  *
791  * \details
792  * The bit corresponding to the input sequence number is set to either
793  * 0 or 1 as specified in input param.
794  *
795  * \param[in] me Bitmap
796  * \param[out] existed RTI_TRUE if bit is already set, RTI_FALSE otherwise.
797  * \param[in] num The sequence number of interest.
798  * \param[in] bit RTI_TRUE if bit is to be turned on, RTI_FALSE otherwise.
799  *
800  * \return RTI_FALSE on failure, which includes the sequence not in bitmap.
801  * RTI_TRUE on success.
802  */
803 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
804 RTPS_Bitmap_setBit(struct RTPS_Bitmap *me,
805  RTI_BOOL *existed,
806  const struct REDA_SequenceNumber *num,
807  RTI_BOOL bit);
808 
809 /*ci \ingroup RTPS_BitmapClass
810  * \brief Get specified bit in bitmap.
811  *
812  * \details
813  * The bit corresponding to the input sequence number is set to either
814  * 0 or 1 as specified in input param.
815  *
816  * \param[in] me Bitmap
817  * \param[in] bit Pointer to the answer, whose value will be RTI_TRUE
818  if bit is on and RTI_FALSE otherwise.
819  * \param[in] num The sequence number of interest.
820  *
821  * \return RTI_FALSE on failure, which includes the sequence not in bitmap.
822  * RTI_TRUE on success.
823  */
824 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
825 RTPS_Bitmap_getBit(
826  const struct RTPS_Bitmap *me,
827  RTI_BOOL *bit,
828  const struct REDA_SequenceNumber *num);
829 
830 /*ci
831  * \brief
832  * Get the sequence number of the first bit in bitmap that matches the input
833  * value
834  *
835  * \param[in] me Bitmap
836  * \param[out] position Sequence number of first bit matching searchBit. If
837  * no match found, position is one greater than last valid bit of bitmap.
838  * \param[in] searchBit Value of bit for which to search
839  *
840  * \return RTI_TRUE on successfully finding matching bit, RTI_FALSE on failure
841  */
842 SHOULD_CHECK_RETURN RTPSDllExport RTI_BOOL
843 RTPS_Bitmap_getFirstBit(
844  const struct RTPS_Bitmap *me,
845  struct REDA_SequenceNumber *position,
846  RTI_BOOL searchBit);
847 
848 /*ci
849  * \brief
850  * Get the sequence number of the last bit in bitmap that matches the input
851  * value
852  *
853  * \param[in] me Bitmap
854  * \param[out] position Sequence number of last bit matching searchBit. If
855  * no match found, position is zero.
856  * \param[in] searchBit Value of bit for which to search
857  *
858  * \return RTI_TRUE on successfully finding matching bit, RTI_FALSE on failure
859  */
860 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
861 RTPS_Bitmap_getLastBit(
862  const struct RTPS_Bitmap *me,
863  struct REDA_SequenceNumber *position,
864  RTI_BOOL searchBit);
865 
866 /*ci
867  * \brief
868  * Fill a range of bits in bitmap with specified value
869  *
870  * \param[in] me Bitmap
871  * \param[in] firstSeqNum First sequence number in range to fill
872  * \param[in] lastSeqNum Last sequence number in range to fill
873  * \param[in] bit Value to set bits in range
874  *
875  * \return RTI_TRUE on success, RTI_FALSE on failure
876  */
877 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
878 RTPS_Bitmap_fill(
879  struct RTPS_Bitmap *me,
880  const struct REDA_SequenceNumber *firstSeqNum,
881  const struct REDA_SequenceNumber *lastSeqNum,
882  RTI_BOOL bit);
883 
884 
885 /*ci
886  * \brief
887  * Merge another bitmap with self bitmap
888  *
889  * \details
890  * Copies '1' bits from source bitmap whose sequence numbers overlap with self
891  * bitmap. Bitcount and lead SN of self bitmap are preserved.
892  *
893  * \param[in] me Self bitmap
894  * \param[in] source Bitmap to merge with self
895  *
896  * \return RTI_TRUE on success, RTI_FALSE on failure
897  */
898 RTPSDllExport void
899 RTPS_Bitmap_merge(
900  struct RTPS_Bitmap *me,
901  const struct RTPS_Bitmap *source);
902 
903 /*ci
904  * \brief
905  * Shift lead sequence number of bitmap to new value
906  *
907  * \details
908  * Preserves bitcount of bitmap, setting new shifted-in bits to zero.
909  *
910  * \param[in] me Self bitmap
911  * \param[in] sequenceNumber New lead sequence number
912  *
913  * \return RTI_TRUE on success, RTI_FALSE on failure
914  */
915 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
916 RTPS_Bitmap_shift(
917  struct RTPS_Bitmap *me,
918  const struct REDA_SequenceNumber *seqNum);
919 
920 /*ci
921  * \brief
922  * Truncates bitmap to end at specified sequence number
923  *
924  * \details
925  * Updates bitcount of bitmap to reflect number of valid bits up to truncated
926  * sequence number. If truncation sequence number is greater than current last
927  * sequence number of bitmap, no truncation is done and bitcount stays the same.
928  *
929  * \param[in] me Self bitmap
930  * \param[in] sequenceNumber Sequence number after which bitmap is truncated.
931  *
932  * \return RTI_TRUE on success, RTI_FALSE on failure
933  */
934 RTPSDllExport void
935 RTPS_Bitmap_truncate(
936  struct RTPS_Bitmap *me,
937  const struct REDA_SequenceNumber *seqNum);
938 
939 /*ci
940  * \brief
941  * Toggle bits of bitmap
942  *
943  * \details
944  * Change '1' to '0' and vice versa.
945  *
946  * \param[in] me Self bitmap
947  *
948  */
949 RTPSDllExport void
950 RTPS_Bitmap_invert(struct RTPS_Bitmap *me);
951 
952 /*ci
953  * \brief
954  * Deserialize from buffer a bitmap
955  *
956  * \details
957  * Change '1' to '0' and vice versa.
958  *
959  * \param[in] me Self bitmap
960  * \param[in] streamPtr Pointer to serialized buffer
961  * \param[in] max_bits_len Remaining space of submessage to deserialize
962  * the variable length bits of bitmap
963  * \param[in] needByteSwap Flag whether byte swap is necessary for
964  * deserialization
965  *
966  * \return RTI_TRUE on success, RTI_FALSE on failure
967  *
968  */
969 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
970 RTPS_Bitmap_deserialize(
971  struct RTPS_Bitmap *me,
972  const char **streamPtr,
973  RTI_UINT32 max_bits_len,
974  RTI_BOOL needByteSwap);
975 
976 /******************************************************************************/
977 /*ci
978  * \brief
979  * Serialize GUID to stream buffer
980  *
981  * \param[inout] stream Serialization stream
982  * \param[in] guid GUID to serialize
983  * \param[in] param Unused
984  *
985  * \return RTI_TRUE on success, RTI_FALSE on failure
986  */
987 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
988 RTPS_Guid_serialize(
989  struct CDR_Stream_t *stream,
990  const struct RTPS_Guid *guid,
991  void * param);
992 
993 /*ci
994  * \brief
995  * Deserialize GUID from stream buffer
996  *
997  * \param[in] stream Deserialization stream
998  * \param[inout] guid Deserialized GUID
999  * \param[in] param Unused
1000  *
1001  * \return RTI_TRUE on success, RTI_FALSE on failure
1002  */
1003 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
1004 RTPS_Guid_deserialize(
1005  struct CDR_Stream_t *stream,
1006  struct RTPS_Guid *guid,
1007  void * param);
1008 
1009 /*ci
1010  * \brief
1011  * Length in bytes of serialized GUID
1012  *
1013  * \param[in] Current length of serialized buffer
1014  *
1015  * \return Number of bytes of serialized GUID
1016  */
1017 MUST_CHECK_RETURN RTPSDllExport RTI_UINT32
1018 RTPS_Guid_getMaxSizeSerialized(RTI_UINT32 size);
1019 
1020 /* -------------------------------------------------------------------------- */
1021 /*ci
1022  * \brief
1023  * Serialize NTP time to stream buffer
1024  *
1025  * \param[inout] stream Serialization stream
1026  * \param[in] time NTP time to serialize
1027  * \param[in] param Unused
1028  *
1029  * \return RTI_TRUE on success, RTI_FALSE on failure
1030  */
1031 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
1032 RTPS_serializeRtiNtpTime(
1033  struct CDR_Stream_t *stream,
1034  const OSAPI_NtpTime *time,
1035  void * param);
1036 
1037 /*ci
1038  * \brief
1039  * Deserialize NTP time from stream buffer
1040  *
1041  * \param[in] stream Deserialization stream
1042  * \param[inout] time Deserialized NTP time
1043  * \param[in] param Unused
1044  *
1045  * \return RTI_TRUE on success, RTI_FALSE on failure
1046  */
1047 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
1048 RTPS_deserializeRtiNtpTime(
1049  struct CDR_Stream_t *stream,
1050  OSAPI_NtpTime *time,
1051  void * param);
1052 
1053 /*ci
1054  * \brief
1055  * Length in bytes of serialized NTP time
1056  *
1057  * \param[in] Current length of serialized buffer
1058  *
1059  * \return Number of bytes of serialized NTP time
1060  */
1061 MUST_CHECK_RETURN RTPSDllExport RTI_UINT32
1062 RTPS_getRtiNtpTimeMaxSizeSerialized(RTI_UINT32 size);
1063 
1064 /* -------------------------------------------------------------------------- */
1065 /*ci
1066  * \brief
1067  * Serialize unsigned short to stream buffer
1068  *
1069  * \param[inout] stream Serialization stream
1070  * \param[in] in Value to serialize
1071  * \param[in] param Unused
1072  *
1073  * \return RTI_TRUE on success, RTI_FALSE on failure
1074  */
1075 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
1076 RTPS_serialize2Octets(
1077  struct CDR_Stream_t *stream,
1078  const RTI_UINT16 * in,
1079  void * param);
1080 
1081 /*ci
1082  * \brief
1083  * Deserialize unsigned short from stream buffer
1084  *
1085  * \param[in] stream Deserialization stream
1086  * \param[inout] out Deserialized value
1087  * \param[in] param Unused
1088  *
1089  * \return RTI_TRUE on success, RTI_FALSE on failure
1090  */
1091 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
1092 RTPS_deserialize2Octets(
1093  struct CDR_Stream_t *stream,
1094  RTI_UINT16 *out,
1095  void * param);
1096 
1097 /*ci
1098  * \brief
1099  * Length in bytes of serialized unsigned short
1100  *
1101  * \param[in] Current length of serialized buffer
1102  *
1103  * \return Number of bytes of serialized unsigned short
1104  */
1105 MUST_CHECK_RETURN RTPSDllExport RTI_UINT32
1106 RTPS_get2OctetsMaxSizeSerialized(RTI_UINT32 size);
1107 
1108 /* -------------------------------------------------------------------------- */
1109 /*ci
1110  * \brief
1111  * Serialize locator to stream buffer
1112  *
1113  * \param[inout] stream Serialization stream
1114  * \param[in] loc Locator to serialize
1115  * \param[in] param Unused
1116  *
1117  * \return RTI_TRUE on success, RTI_FALSE on failure
1118  */
1119 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
1120 RTPS_serializeIpv6Locator(
1121  struct CDR_Stream_t *stream,
1122  const struct RTPS_Locator_t *loc,
1123  void * param);
1124 
1125 /*ci
1126  * \brief
1127  * Deserialize locator from stream buffer
1128  *
1129  * \param[in] stream Deserialization stream
1130  * \param[inout] loc Deserialized locator
1131  * \param[in] param Unused
1132  *
1133  * \return RTI_TRUE on success, RTI_FALSE on failure
1134  */
1135 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
1136 RTPS_deserializeIpv6Locator(
1137  struct CDR_Stream_t *stream,
1138  struct RTPS_Locator_t *loc,
1139  void * param);
1140 
1141 /*ci
1142  * \brief
1143  * Length in bytes of serialized locator
1144  *
1145  * \param[in] Current length of serialized buffer
1146  *
1147  * \return Number of bytes of serialized locator
1148  */
1149 MUST_CHECK_RETURN RTPSDllExport RTI_UINT32
1150 RTPS_getIpv6LocatorMaxSizeSerialized(RTI_UINT32 size);
1151 
1152 /* -------------------------------------------------------------------------- */
1153 /*ci \brief Deserialize epoch from stream buffer
1154  *
1155  * \param[inout] epoch Deserialized epoch
1156  * \param[in] stream Deserialization stream
1157  * \param[in] needByteSwap Flags whether to byte swap byte order on
1158  * deserialization
1159  *
1160  * \return RTI_TRUE on success, RTI_FALSE on failure
1161  */
1162 MUST_CHECK_RETURN RTPSDllExport RTI_BOOL
1163 RTPS_Epoch_deserialize(REDA_Epoch_T * me,
1164  const char **stream,
1165  RTI_BOOL needByteSwap);
1166 
1167 
1168 /*ci \brief RTPS GUID type */
1169 typedef struct NETIO_Guid RTPS_GUID;
1170 
1171 /*ci \brief RTPS GuidPrefix type */
1172 typedef struct NETIO_GuidPrefix RTPS_GuidPrefix_T;
1173 
1174 /*ci \brief RTPS Entity type */
1175 typedef struct NETIO_GuidEntity RTPS_Entity_T;
1176 
1177 /*ci \brief Default unknown GUID prefix initializer */
1178 #define RTPS_GUIDPREFIX_UNKNOWN {{0,0,0,0,0,0,0,0,0,0,0,0}}
1179 
1180 /*ci \brief Default unknown Entity ID initializer */
1181 #define RTPS_ENTITY_UNKNOWN {{0,0,0,0}}
1182 
1183 /*ci \brief Returns whether entity ID is unknown
1184  *
1185  * \param[in] entity_ Entity ID to check
1186  *
1187  * \return 1 if entity is unknown, 0 otherwise.
1188  */
1189 #define RTPSEntity_is_unknown(entity_) \
1190 ( \
1191  ((entity_)->value[0]== 0) && ((entity_)->value[1] == 0) && \
1192  ((entity_)->value[2] == 0) && ((entity_)->value[3] == 0) \
1193 )
1194 
1195 /* -------------------------------------------------------------------------- */
1196 /*ci \brief RTPS Timestamp type */
1197 struct RTPS_Time
1198 {
1199  /*ci \brief Seconds */
1200  RTI_INT32 seconds;
1201 
1202  /*ci \brief Fractional part */
1203  RTI_UINT32 fractions;
1204 };
1205 
1206 /*ci \brief RTPS Vendor ID type */
1207 struct RTPS_Vendor
1208 {
1209  /*ci \brief Vendor ID value */
1210  RTI_UINT8 vendor_id[2];
1211 };
1212 
1213 /*ci \brief RTPS Protocol Version type */
1214 struct RTPS_ProtocolVersion
1215 {
1216  /*ci \brief Major */
1217  RTI_UINT8 major;
1218 
1219  /*ci \brief Minor */
1220  RTI_UINT8 minor;
1221 };
1222 
1223 /*ci \brief RTPS message header
1224  * \details
1225  * Fields are ordered exactly as defined by RTPS specification
1226  */
1227 struct RTPS_Header
1228 {
1229  /*ci \brief 'R''T''P''S' protocol identifier */
1230  RTI_UINT32 rtps;
1231 
1232  /*ci \brief Protocol version */
1233  struct RTPS_ProtocolVersion protocol_version;
1234 
1235  /*ci \brief Vendor ID */
1236  struct RTPS_Vendor vendor_id;
1237 
1238  /*ci \brief Sender's GUID Prefix*/
1239  RTPS_GuidPrefix_T guid_prefix;
1240 };
1241 
1242 /*ci \brief RTPS message header size */
1243 #define RTPS_HEADER_SIZE() sizeof(struct RTPS_Header)
1244 
1245 /*ci \brief RTPS message header's RTPS identifier, in host order */
1246 #ifdef RTI_ENDIAN_LITTLE
1247 #define VALID_RTPS_HEADER 0x53505452 /* RTPS backwards */
1248 #else
1249 #define VALID_RTPS_HEADER 0x52545053 /* RTPS in big endian */
1250 #endif /* RTI_ENDIAN_LITTLE */
1251 
1252 
1253 
1254 /*ci \brief Assign fields of RTPS message header
1255  *
1256  * \param[inout] hdr_ RTPS message header to set
1257  * \param[in] prefix_ Sender's GUID prefix
1258  */
1259 #define RTPS_HEADER_SET(hdr_,prefix_)\
1260 {\
1261  (hdr_)->rtps = VALID_RTPS_HEADER;\
1262  (hdr_)->protocol_version.major = RTPS_PROTOCOL_VERSION_MAJOR;\
1263  (hdr_)->protocol_version.minor = RTPS_PROTOCOL_VERSION_MINOR;\
1264  (hdr_)->vendor_id.vendor_id[0] = RTPS_VENDOR_ID_MAJOR;\
1265  (hdr_)->vendor_id.vendor_id[1] = RTPS_VENDOR_ID_MINOR;\
1266  (hdr_)->guid_prefix = *(prefix_);\
1267 }
1268 
1269 /******************************************************************************/
1270 
1271 /* RTPS Submessage IDs */
1272 /*ci \brief PAD submessage ID */
1273 #define RTPS_PAD_KIND (0x01)
1274 
1275 /*ci \brief ACKNACK submessage ID */
1276 #define RTPS_ACKNACK_KIND (0x06)
1277 
1278 /*ci \brief HEARTBEAT submessage ID */
1279 #define RTPS_HEARTBEAT_KIND (0x07)
1280 
1281 /*ci \brief GAP submessage ID */
1282 #define RTPS_GAP_KIND (0x08)
1283 
1284 /*ci \brief INFO_TS submessage ID */
1285 #define RTPS_INFO_TS_KIND (0x09)
1286 
1287 /*ci \brief INFO_SRC submessage ID */
1288 #define RTPS_INFO_SRC_KIND (0x0c)
1289 
1290 /*ci \brief INFO_REPLY_IP4 submessage ID */
1291 #define RTPS_INFO_REPLY_IP4_KIND (0x0d)
1292 
1293 /*ci \brief INFO_DST submessage ID */
1294 #define RTPS_INFO_DST_KIND (0x0e)
1295 
1296 /*ci \brief INFO_REPLY submessage ID */
1297 #define RTPS_INFO_REPLY_KIND (0x0f)
1298 
1299 /*ci \brief DATA submessage ID */
1300 #define RTPS_DATA_KIND (0x15)
1301 
1302 
1303 #define RTPS_LARGEST_SUBMSG_KIND RTPS_DATA_KIND
1304 
1305 /*ci \brief Length of RTPS submessage header */
1306 #define RTPS_SUBMESSAGE_HEADER_LENGTH 4
1307 
1308 
1309 
1310 /*ci \brief RTPS submessage header
1311  *
1312  * \details
1313  * Fields ordered exactly as defined by RTPS specification
1314  */
1315 struct RTPS_SubmsgHdr
1316 {
1317  /*ci \brief Submessage kind ID */
1318  RTI_UINT8 kind;
1319 
1320  /*ci \brief Submessage flags */
1321  RTI_UINT8 flags;
1322 
1323  /*ci \brief Submessage length */
1324  RTI_UINT16 length;
1325 };
1326 
1327 /*ci \brief Submessage little endianness flag */
1328 #define RTPS_SUBMSG_FLAG_E 0x1
1329 
1330 /*ci \brief Assign submessage header
1331  *
1332  * \param[inout] subhdr_ Submessage header to set
1333  * \param[in] kind_ Submessage ID
1334  * \param[in] flags_ Submessage flags
1335  * \param[in] length_ Submessage length
1336  */
1337 #ifdef RTI_ENDIAN_LITTLE
1338 #define RTPS_SubmsgHdr_set(subhdr_,kind_,flags_,length_) \
1339 {\
1340  (subhdr_)->kind = kind_;\
1341  (subhdr_)->flags = flags_ | RTPS_SUBMSG_FLAG_E;\
1342  (subhdr_)->length = length_ - 4;\
1343 }
1344 #else
1345 #define RTPS_SubmsgHdr_set(subhdr_,kind_,flags_,length_) \
1346 {\
1347  (subhdr_)->kind = kind_;\
1348  (subhdr_)->flags = flags_ & ~RTPS_SUBMSG_FLAG_E;\
1349  (subhdr_)->length = length_ - 4;\
1350 }
1351 #endif
1352 
1353 /*ci \brief Checks whether submessage is an INFO_* kind */
1354 #define RTPSSubmessage_is_info(kind_) \
1355 ((kind_ == RTPS_INFO_DST_KIND) || \
1356  (kind_ == RTPS_INFO_TS_KIND) || \
1357  (kind_ == RTPS_INFO_SRC_KIND) || \
1358  (kind_ == RTPS_INFO_REPLY_IP4_KIND) || \
1359  (kind_ == RTPS_INFO_REPLY_KIND))
1360 
1361 /*ci \brief Checks whether submessage is kind sent by a writer */
1362 #define RTPSSubmessage_from_writer(kind_) \
1363 ((kind_ == RTPS_GAP_KIND) || \
1364  (kind_ == RTPS_DATA_KIND) || \
1365  (kind_ == RTPS_HEARTBEAT_KIND))
1366 
1367 /******************************************************************************/
1368 /*ci \brief ACKNACK submessage, over-the-wire layout */
1369 struct RTPS_ACKNACK
1370 {
1371  /*ci \brief Submesage header */
1372  struct RTPS_SubmsgHdr hdr;
1373 
1374  /*ci \brief Source reader's entity ID */
1375  RTPS_Entity_T reader;
1376 
1377  /*ci \brief Destination writer's entity ID */
1378  RTPS_Entity_T writer;
1379 
1380  /*ci \brief Bitmap (variable length) */
1381  struct RTPS_Bitmap bitmap;
1382 
1383  /*ci \brief Epoch count */
1384  RTI_UINT32 count;
1385 };
1386 
1387 /*ci \brief Calculate number of 32-bit ints to contain bitCount */
1388 #define RTPS_BITMAP_INT_COUNT(bitCount_) \
1389  ((RTI_UINT32)((bitCount_ + 31)/32))
1390 
1391 /*ci \brief ACKNACK Final flag */
1392 #define RTPS_ACKNACKFLAGS_F 0x2
1393 
1394 /*ci \brief Return 1 if ACKNACK Final flag set, 0 otherwise */
1395 #define RTPS_ACKNACK_FINAL(flags) (flags & RTPS_ACKNACKFLAGS_F)
1396 
1397 /*ci \brief Determine legnth of bitmap given bitCount */
1398 #define RTPS_ACKNACK_SIZE(bitCount_) \
1399 ( \
1400  (sizeof(struct RTPS_ACKNACK) - sizeof(struct RTPS_Bitmap)) + \
1401  (sizeof(struct REDA_SequenceNumber)) + \
1402  4 + (4 * RTPS_BITMAP_INT_COUNT(bitCount_)) \
1403 )
1404 
1405 /*ci \brief Assign fields of ACKNACK
1406  *
1407  * \param[inout] ack_ ACKNACK submessage to set
1408  * \param[in] flags_ ACKNACK flags
1409  * \param[in] length_ Submessage length
1410  * \param[in] reader_ Reader entity ID
1411  * \param[in] writer_ Writer entity ID
1412  * \param[in] bitmap_ Bitmap
1413  * \param[in] count_ Epoch count
1414  */
1415 #define RTPS_ACKNACK_SET(ack_,flags_,length_,reader_,writer_,bitmap_,count_) \
1416 { \
1417  RTI_UINT32 int_count, *epoch_ref; \
1418  epoch_ref = &((ack_)->bitmap._32bits[0]); \
1419  RTPS_SubmsgHdr_set(&(ack_)->hdr,RTPS_ACKNACK_KIND,flags_,length_); \
1420  (ack_)->reader = reader_; \
1421  (ack_)->writer = writer_; \
1422  (ack_)->bitmap._lead = (bitmap_)->_lead; \
1423  (ack_)->bitmap._bitCount = (bitmap_)->_bitCount; \
1424  for (int_count = 0; \
1425  int_count < RTPS_BITMAP_INT_COUNT((bitmap_)->_bitCount); ++int_count) \
1426  { \
1427  (ack_)->bitmap._32bits[int_count] = (bitmap_)->_32bits[int_count]; \
1428  epoch_ref = &((ack_)->bitmap._32bits[int_count+1]); \
1429  } \
1430  *epoch_ref = count_; \
1431 }
1432 
1433 /******************************************************************************/
1434 /*ci \brief RTPS DATA submessage
1435  *
1436  * \details
1437  * Fixed length fields declared in type. Variable length fields (inline QoS,
1438  * DATA payload) accounted for later when setting DATA submessage.
1439  */
1440 struct RTPS_DATA
1441 {
1442  /*ci \brief Submessage header */
1443  struct RTPS_SubmsgHdr hdr;
1444 
1445  /*ci \brief Submessage flags */
1446  RTI_UINT16 flags;
1447 
1448  /*ci \brief Inline Qos offset */
1449  RTI_UINT16 inlineQosOffset;
1450 
1451  /*ci \brief Destination reader entity ID */
1452  RTPS_Entity_T reader;
1453 
1454  /*ci \brief Source writer entity ID */
1455  RTPS_Entity_T writer;
1456 
1457  /*ci \brief Sequence number */
1458  struct REDA_SequenceNumber sn;
1459 };
1460 
1461 /*ci \brief Assign fields of DATA submessage
1462  *
1463  * \param[inout] data_ DATA submessage to set
1464  * \param[in] flags_ Submessage flags
1465  * \param[in] length_ Submessage length
1466  * \param[in] eflags_ DATA flags
1467  * \param[in] qlength_ Inline Qos offset
1468  * \param[in] reader_ Reader entity ID
1469  * \param[in] writer_ Writer entity ID
1470  * \param[in] sn_ Sequence number
1471  */
1472 #define RTPS_DATA_SET(data_,flags_,length_,eflags_,qlength_,reader_,writer_,sn_) \
1473 { \
1474  RTPS_SubmsgHdr_set(&(data_)->hdr,RTPS_DATA_KIND,flags_,length_); \
1475  (data_)->flags = eflags_;\
1476  (data_)->inlineQosOffset = qlength_;\
1477  (data_)->reader = reader_;\
1478  (data_)->writer = writer_;\
1479  (data_)->sn = sn_;\
1480 }
1481 
1482 /*ci \brief Default empty DATA submessage flag */
1483 #define RTPS_FLAGS_NONE 0x0
1484 
1485 /*ci \brief Inline Qos Q-flag for DATA submessage */
1486 #define RTPS_DATAFLAGS_Q 0x2
1487 
1488 /*ci \brief Data D-flag for DATA submessage */
1489 #define RTPS_DATAFLAGS_D 0x4
1490 
1491 /*ci \brief Default Inline Qos offset */
1492 #define RTPS_DATA_INLINEQOS_OFFSET 16
1493 
1494 /*ci \brief Total DATA submessage size including payload */
1495 #define RTPS_DATA_SIZE(payload_size) (sizeof(struct RTPS_DATA)+payload_size)
1496 
1497 /******************************************************************************/
1498 /*ci \brief GAP submessage */
1499 struct RTPS_GAP
1500 {
1501  /*ci \brief Submessage header */
1502  struct RTPS_SubmsgHdr hdr;
1503 
1504  /*ci \brief Destination reader entity ID */
1505  RTPS_Entity_T reader;
1506 
1507  /*ci \brief Source writer entity ID */
1508  RTPS_Entity_T writer;
1509 
1510  /*ci \brief Sequence number of start of GAP */
1511  struct REDA_SequenceNumber sn_start;
1512 
1513  /*ci \brief Bitmap */
1514  struct RTPS_Bitmap bitmap; /* variable length */
1515 };
1516 
1517 /*ci \brief Determine size of GAP bitmap from bitCount */
1518 #define RTPS_GAP_SIZE(bitCount_) \
1519 ( \
1520  (sizeof(struct RTPS_GAP)) - (sizeof(struct RTPS_Bitmap)) + \
1521  (sizeof(struct REDA_SequenceNumber)) + \
1522  4 + (4 * RTPS_BITMAP_INT_COUNT(bitCount_)) \
1523 )
1524 
1525 /*ci \brief Assign fields of GAP
1526  *
1527  * \param[inout] gap_ GAP to set
1528  * \param[in] length_ Submessage length
1529  * \param[in] reader_ Reader entity ID
1530  * \param[in] writer_ Writer entity ID
1531  * \param[in] sn_start_ GAP start sequence number
1532  * \param[in] bitmap_ GAP bitmap
1533  */
1534 #define RTPS_GAP_SET(gap_,length_,reader_,writer_,sn_start_,bitmap_) \
1535 { \
1536  RTI_UINT32 int_count; \
1537  RTPS_SubmsgHdr_set(&(gap_)->hdr,RTPS_GAP_KIND,0,length_); \
1538  (gap_)->reader = reader_; \
1539  (gap_)->writer = writer_; \
1540  (gap_)->sn_start = sn_start_; \
1541  (gap_)->bitmap._lead = (bitmap_)->_lead; \
1542  (gap_)->bitmap._bitCount = (bitmap_)->_bitCount; \
1543  for (int_count = 0; \
1544  int_count < RTPS_BITMAP_INT_COUNT((bitmap_)->_bitCount); ++int_count) \
1545  { \
1546  (gap_)->bitmap._32bits[int_count] = (bitmap_)->_32bits[int_count]; \
1547  } \
1548 }
1549 
1550 /******************************************************************************/
1551 /*ci \brief HEARTBEAT submessage */
1552 struct RTPS_HEARTBEAT
1553 {
1554  /*ci \brief Submessage header */
1555  struct RTPS_SubmsgHdr hdr;
1556 
1557  /*ci \brief Destination reader entity ID */
1558  RTPS_Entity_T reader;
1559 
1560  /*ci \brief Source writer entity ID */
1561  RTPS_Entity_T writer;
1562 
1563  /*ci \brief First sequence number */
1564  struct REDA_SequenceNumber sn_first;
1565 
1566  /*ci \brief Last sequence number */
1567  struct REDA_SequenceNumber sn_last;
1568 
1569  /*ci \brief Epoch count */
1570  RTI_INT32 count;
1571 };
1572 
1573 /*ci \brief Assign fields of HEARTBEAT
1574  *
1575  * \param[inout] hb_ HEARTBEAT to set
1576  * \param[in] flags_ Submessage flags
1577  * \param[in] reader_ Reader entity ID
1578  * \param[in] writer_ Writer entity ID
1579  * \param[in] sn_first_ First sequence number
1580  * \param[in] sn_last Last sequence number
1581  * \param[in] count_ Epoch count
1582  */
1583 #define RTPS_HB_SET(hb_,flags_,reader_,writer_,sn_first_,sn_last_,count_) \
1584 { \
1585  RTPS_SubmsgHdr_set(&(hb_)->hdr,RTPS_HEARTBEAT_KIND,flags_,RTPS_HB_SIZE());\
1586  (hb_)->reader = (reader_);\
1587  (hb_)->writer = (writer_);\
1588  (hb_)->sn_first = (sn_first_);\
1589  (hb_)->sn_last = (sn_last_);\
1590  (hb_)->count = (count_);\
1591 }
1592 
1593 /*ci \brief Final HEARTBEAT submesasge flag */
1594 #define RTPS_HBFLAGS_F 0x02
1595 
1596 /*ci \brief Liveliness HEARTBEAT submessage flag */
1597 #define RTPS_HBFLAGS_L 0x04
1598 
1599 /*ci \brief Size of HEARTBEAT */
1600 #define RTPS_HB_SIZE() (sizeof(struct RTPS_HEARTBEAT))
1601 
1602 /******************************************************************************/
1603 /*ci \brief INFO_DST submessage */
1604 struct RTPS_INFO_DST
1605 {
1606  /*ci \brief Submessage header */
1607  struct RTPS_SubmsgHdr hdr;
1608 
1609  /*ci \brief Destination GUID prefix */
1610  RTPS_GuidPrefix_T guid_prefix;
1611 };
1612 
1613 /*ci \brief Size of INFO_DST */
1614 #define RTPS_INFO_DST_SIZE() (sizeof(struct RTPS_INFO_DST))
1615 
1616 /*ci \brief Assign fields of INFO_DST
1617  *
1618  * \param[inout] info_ INFO_DST to set
1619  * \param[in] dst_ Destination GUID prefix
1620  */
1621 #define RTPS_INFO_DST_SET(info_,dst_) \
1622 { \
1623  RTPS_SubmsgHdr_set(&(info_)->hdr,RTPS_INFO_DST_KIND,0,RTPS_INFO_DST_SIZE());\
1624  (info_)->guid_prefix = *(dst_);\
1625 }
1626 
1627 /******************************************************************************/
1628 /*ci \brief INFO_TS submessage */
1629 struct RTPS_INFO_TS
1630 {
1631  /*ci \brief Submessage header */
1632  struct RTPS_SubmsgHdr hdr;
1633 
1634  /*ci \brief Source timestamp */
1635  struct RTPS_Time timestamp;
1636 };
1637 
1638 /*ci \brief Invalid Timestamp INFO_TS flag */
1639 #define RTPS_INFO_TSFLAGS_I (0x2)
1640 
1641 /*ci \brief Size of INFO_TS */
1642 #define RTPS_INFO_TS_SIZE(i_) \
1643 ((i_) ? sizeof(struct RTPS_SubmsgHdr) : sizeof(struct RTPS_INFO_TS))
1644 
1645 
1646 /*ci \brief Assign fields of INFO_TS
1647  *
1648  * \param[inout] info_ts_ INFO_TS to set
1649  * \param[in] flags_ Submessage flags
1650  * \param[in] sec_ Timestamp seconds part
1651  * \param[in] frac_ Timestamp fractional part
1652  */
1653 #define RTPS_INFO_TS_SET(info_ts_,flags_,sec_,frac_) \
1654 {\
1655  RTPS_SubmsgHdr_set(&(info_ts_)->hdr,RTPS_INFO_TS_KIND,flags_,\
1656  RTPS_INFO_TS_SIZE(flags_));\
1657  if (!((flags_) & RTPS_INFO_TSFLAGS_I))\
1658  {\
1659  (info_ts_)->timestamp.seconds = sec_;\
1660  (info_ts_)->timestamp.fractions = frac_;\
1661  }\
1662 }
1663 
1664 /******************************************************************************/
1665 /*ci \brief RTPS headers and submessages
1666  *
1667  * \details
1668  * Used to typecast serialized/deserialized stream buffer
1669  */
1670 union RTPS_MESSAGES
1671 {
1672  /*ci \brief Submessage header */
1673  struct RTPS_SubmsgHdr submsg;
1674 
1675  /*ci \brief Message header */
1676  struct RTPS_Header header;
1677 
1678  /*ci \brief DATA submessage */
1679  struct RTPS_DATA data;
1680 
1681  /*ci \brief GAP submessage */
1682  struct RTPS_GAP gap;
1683 
1684  /*ci \brief HEARTBEAT submessage */
1685  struct RTPS_HEARTBEAT hb;
1686 
1687  /*ci \brief ACKNACK submessage */
1688  struct RTPS_ACKNACK acknack;
1689 
1690  /*ci \brief INFO_TS submessage */
1691  struct RTPS_INFO_TS info_ts;
1692 
1693  /*ci \brief INFO_DST submessage */
1694  struct RTPS_INFO_DST info_dst;
1695 };
1696 
1697 /**************/
1698 /*ci \brief RTPS interface mode */
1699 typedef enum
1700 {
1701  /*ci \brief Default undefined mode */
1702  RTPS_INTERFACEMODE_UNDEFINED,
1703 
1704  /*ci \brief Writer mode */
1705  RTPS_INTERFACEMODE_WRITER,
1706 
1707  /*ci \brief Reader mode */
1708  RTPS_INTERFACEMODE_READER,
1709 
1710  /*ci \brief External receiver mode */
1711  RTPS_INTERFACEMODE_EXTERNAL_RECEIVER
1712 } RTPS_InterfaceMode_t;
1713 
1714 /*ci \brief RTPS interface property */
1715 struct RTPS_InterfaceProperty
1716 {
1717  /*ci \brief Base NETIO interface property */
1718  struct NETIO_InterfaceProperty _parent;
1719 
1720  /*ci \brief RTPS interface mode */
1721  RTPS_InterfaceMode_t mode;
1722 
1723  /*ci \brief RTPS interface GUID address */
1724  struct NETIO_Address intf_address;
1725 
1726  /*ci \brief Maximum number of peers */
1727  RTI_INT32 max_peer_count;
1728 
1729  /*ci \brief Maximum number of downstream transports */
1730  RTI_SIZE_T max_transport_count;
1731 
1732  /*ci \brief Maximum number of submessage buffers */
1733  RTI_SIZE_T max_message_buffer_count;
1734 
1735  /*ci \brief RTI_TRUE for reliable writer or reader */
1736  RTI_BOOL reliable;
1737 
1738  /*ci \brief RTI_TRUE for anonymous writer or reader */
1739  RTI_BOOL anonymous;
1740 
1741  /*ci \brief HEARTBEAT period for reliable writer */
1742  struct OSAPI_NtpTime hb_period;
1743 
1744  /*ci \brief Piggyback HEARTBEAT rate for reliable writer
1745  *
1746  * \details
1747  * A HEARTBEAT submessage is appended to every Nth new DATA submessage
1748  * sent, where N is sample_per_hb.
1749  */
1750  RTI_SIZE_T samples_per_hb;
1751 
1752  /*ci \brief Maximum window size for writer or reader */
1753  RTI_UINT32 max_window_size;
1754 
1755  /*ci \brief Maximum HEARTBEAT retries for reliable writer
1756  *
1757  * \details
1758  * A peer reader must respond to a reliable writer's HEARTBEATs to be
1759  * considered active. If N periodic HEARTBEATs have been sent without
1760  * reciving an ACKNACK, where N is maxhb_retries, the peer reader is
1761  * then considered inactive and will stay inactive until an ACKNACK is
1762  * received.
1763  */
1764  RTI_INT32 max_hb_retries;
1765 
1766  /*ci \brief Maximum number of samples of upstream interface */
1767  RTI_INT32 max_samples;
1768 };
1769 
1770 /*ci \brief Unlimited max HEARTBEAT retries */
1771 #define RTPS_RETRIES_UNLIMITED (-1)
1772 
1773 /*ci \brief Maximum receive window size */
1774 #define RTPS_RECEIVE_WINDOW_MAX_SIZE (256)
1775 
1776 /*ci \brief Default RTPS interface property initializer */
1777 #define RTPS_InterfaceProperty_INITIALIZER \
1778 {\
1779  NETIO_InterfaceProperty_INITIALIZER,\
1780  RTPS_INTERFACEMODE_UNDEFINED,\
1781  NETIO_Address_INITIALIZER, \
1782  32, /* max_peer_count */ \
1783  4, /* max_transport_count */ \
1784  8, /* max_message_buffer_count */ \
1785  RTI_FALSE, /* reliable */ \
1786  RTI_FALSE, /* anonymous */ \
1787  {3,0}, /* hb_period */ \
1788  8, /* samples_per_hb */ \
1789  256, /* window_size */ \
1790  RTPS_RETRIES_UNLIMITED, /* max_hb_retries */\
1791  256 /* max_samples */ \
1792 }
1793 
1794 /*ci \brief Property for an RTPS route */
1795 struct RTPS_RouteProperty
1796 {
1797  /*ci \brief Base NETIO route property */
1798  struct NETIORouteProperty _parent;
1799 
1800  /*ci \brief Reliable flag of peer reachable over route */
1801  RTI_BOOL reliable;
1802 
1803  /*ci \brief First sequence number of upstream interface creating the
1804  * route
1805  */
1806  struct REDA_SequenceNumber first_sn;
1807 
1808  /*ci \brief Last sequence number of upstream interface creating the
1809  * route
1810  */
1811  struct REDA_SequenceNumber last_sn;
1812 
1813  /*ci \brief Last acknowledged sequence number of upstream interface
1814  * creating the route
1815  */
1816  struct REDA_SequenceNumber last_acked_sn;
1817 };
1818 
1819 /*ci \brief Default RTPS route property initializer */
1820 #define RTPSRouteProperty_INITIALIZER \
1821 {\
1822  NETIORouteProperty_INITIALIZER, \
1823  RTI_FALSE, /* reliable */ \
1824  REDA_SEQUENCE_NUMBER_ZERO,\
1825  REDA_SEQUENCE_NUMBER_ZERO, \
1826  REDA_SEQUENCE_NUMBER_ZERO \
1827 }
1828 
1829 /*ci \brief Get RTPS inteface factory
1830  * \return Pointer to RTPS interface factory
1831  */
1832 MUST_CHECK_RETURN RTPSDllExport struct RT_ComponentFactoryI*
1833 RTPS_InterfaceFactory_get_interface(void);
1834 
1835 /*ci \brief Maximum number of destination addresses per peer */
1836 #define RTPS_MAX_DESTINATION_PER_PEER (4)
1837 
1838 #ifdef __cplusplus
1839 } /* extern "C" */
1840 #endif
1841 
1842 #include "rtps/rtps_rtps_impl.h"
1843 
1844 #endif /* rtps_rtps_h */

RTI Connext Micro Version 2.4.1.0 Copyright © Thu Nov 20 2014 Real-Time Innovations, Inc