RTI Connext DDS Micro  Version 2.4.11
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
netio_common.h
Go to the documentation of this file.
1 /*
2  * FILE: netio_common.h - NETIO Common API
3  *
4  * Copyright 2012-2015 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  * 28jun2016,tk MICRO-1548 Removed reliance on system headers for UDP
14  * 16mar2015,tk MICRO-1117 Added RTPS and UDP constants for UDP and RTPS
15  * header and trailer space.
16  * 25apr2012,tk Written
17  */
18 /*ce
19  * \file
20  */
21 /*ci \defgroup NETIOCommon NETIO Common API
22  * \ingroup NETIOModule
23  * \brief NETIO APIs available to all NETIO interface
24  */
25 /*ci \defgroup NETIOUtility NETIO Utility API
26  * \ingroup NETIOCommon
27  * \brief Utility function provided by the NETIO module
28  */
29 /*ci \addtogroup NETIOUtility
30  * @{
31  */
32 #ifndef netio_common_h
33 #define netio_common_h
34 
35 #ifndef osapi_types_h
36 #include "osapi/osapi_types.h"
37 #endif
38 #ifndef reda_buffer_h
39 #include "reda/reda_buffer.h"
40 #endif
41 #ifndef netio_dll_h
42 #include "netio/netio_dll.h"
43 #endif
44 
45 #ifdef __cplusplus
46 extern "C"
47 {
48 #endif
49 
50 /*ci
51  * The number of tables created by NETIO common functionality cannot exceed
52  * this number. This number includes tables needed by the NETIO_BindResolver,
53  * METIO_RouteResolver and NETIO_AddressResolver
54  */
55 #define NETIO_RESOURCE_COMMON_TABLES (3)
56 
57 /*ci
58  * A standard NETIO interface typically only uses 2 tables, one route and
59  * one bind
60  */
61 #define NETIO_RESOURCE_TABLES_PER_INTERFACE (2)
62 
63 /*ci
64  * The number of tables needed by and external transport. Although it
65  * is a NETIO interface, it often has additional functionality such as
66  * NAT and thread tables.
67  */
68 #define NETIO_RESOURCE_EXTERNAL_TABLE (4)
69 
70 /*ci
71  * \def NETIO_ntohs
72  * \brief Convert a short integer (16bit) received from an IP network to a
73  * short in host order
74  */
75 #ifdef RTI_ENDIAN_LITTLE
76 #define NETIO_ntohs(x_) (((((RTI_UINT16)(x_))>>8)&0x00ff) | \
77  ((((RTI_UINT16)(x_))<<8)&0xff00))
78 #else
79 #define NETIO_ntohs(x_) (x_)
80 #endif
81 
82 /*ci
83  * \def NETIO_htons
84  * \brief Convert a short integer (16bit) in host order a to short integer
85  * IP network order
86  */
87 #ifdef RTI_ENDIAN_LITTLE
88 #define NETIO_htons(x_) (RTI_UINT16)((((((RTI_UINT16)(x_))>>8)&0x00ff) | \
89  ((((RTI_UINT16)(x_))<<8)&0xff00)))
90 #else
91 #define NETIO_htons(x_) (RTI_UINT16)(x_)
92 #endif
93 
94 /*ci
95  * \def NETIO_ntohl
96  * \brief Convert a long integer (32bit) received from an IP network to a
97  * long in host order
98  */
99 #ifdef RTI_ENDIAN_LITTLE
100 #define NETIO_ntohl(x_) (RTI_UINT32)((((((RTI_UINT32)(x_))>>24)&0x000000ff) | \
101  ((((RTI_UINT32)(x_))>>8)&0x0000ff00) | \
102  ((((RTI_UINT32)(x_))<<24)&0xff000000) | \
103  ((((RTI_UINT32)(x_))<<8)&0x00ff0000)))
104 #else
105 #define NETIO_ntohl(x_) (RTI_UINT32)(x_)
106 #endif
107 
108 /*ci
109  * \def NETIO_htonl
110  * \brief Convert a long integer (32bit) in host order a to long integer
111  * IP network order
112  */
113 #ifdef RTI_ENDIAN_LITTLE
114 #define NETIO_htonl(x_) (((((RTI_UINT32)(x_))>>24)&0x000000ff) | \
115  ((((RTI_UINT32)(x_))>>8)&0x0000ff00) | \
116  ((((RTI_UINT32)(x_))<<24)&0xff000000) | \
117  ((((RTI_UINT32)(x_))<<8)&0x00ff0000))
118 #else
119 #define NETIO_htonl(x_) (x_)
120 #endif
121 
122 /*ci
123  * \def NETIO_PING_MSG
124  * \brief Internal RTPS ping message which serves prime ARP table when a
125  * destination address is added.
126  */
127 #define NETIO_PING_MSG "RTIPING"
128 
129 /*ci
130  * \def NETIO_PING_MSG_SIZE
131  * \brief The length in bytes, excluding the NUL character, of internal
132  * ping message
133  */
134 #define NETIO_PING_MSG_SIZE (7)
135 
136 #if RTI_ENDIAN_LITTLE
137 #define NETIO_INFO_TS_PING_MSG "RTPS\2\1\1\1\0\0\0\0\0\0\0\0\0\0\0\0\x9\x3\0\0"
138 #else
139 #define NETIO_INFO_TS_PING_MSG "RTPS\2\1\1\1\0\0\0\0\0\0\0\0\0\0\0\0\x9\x2\0\0"
140 #endif
141 #define NETIO_INFO_TS_PING_MSG_SIZE (24)
142 
143 
144 #define NETIO_CONNEXT_PING_MSG_SIZE (16)
145 #define NETIO_CONNEXT_PING_MSG "RTPS\2\1\1\1NDDSPING"
146 
147 /*ci
148  * \def RTPS_PACKET_HEADER_MAX_LENGTH
149  * \brief The maximum amount of header space needed to send an RTPS data-sample
150  * \details
151  *
152  * The RTPS header space includes space of the RTPS header and a single
153  * TS and DATA sub message. NOTE: The space for the DATA payload is _not_
154  * included in this constant.
155  *
156  * - This number is calculated using the following layout
157  *
158  * +-----------------------------+
159  * | HEADER | 16 bytes (always)
160  * +-----------------------------+
161  * | INFO_TS | 12 bytes (no inline Qos)
162  * +-----------------------------+
163  * | DATA SUBMESSAGE | 24 bytes (no inline Qos)
164  * +-----------------------------+
165  *
166  * +-----------------------------+
167  * | HEADER | 16 bytes (always)
168  * +-----------------------------+
169  * | INFO_TS | 12 bytes (no inline Qos)
170  * +-----------------------------+
171  * | DATA SUBMESSAGE | 52 bytes (with status info (8)
172  * | | and keyhash (20))
173  * +-----------------------------+
174  *
175  * The max size is 80
176  *
177  * However, because the max header size is hard-coded, 256 was chosen as a
178  * reasonably big header size for other RTPS or downstream interfaces.
179  */
180 #define RTPS_PACKET_HEADER_MAX_LENGTH (256)
181 
182 /*ci
183  * \def RTPS_PACKET_TRAILER_MAX_LENGTH
184  * \brief The maximum amount of trailer space needed to send an RTPS data-sample
185  *
186  * \details
187  * The RTPS trailer includes space for an optional RTPS piggyback heart-beat
188  *
189  * Although the size of a piggyback HB is only 32 byes, 64 bytes was chosen
190  * in case there are implementations that may need more and this is currently
191  * hard-coded.
192  */
193 #define RTPS_PACKET_TRAILER_MAX_LENGTH (64)
194 
195 /*ci
196  * \def UDP_PACKET_HEADER_MAX_LENGTH
197  * \brief The maximum amount of header space needed to send a UDP data-sample
198  *
199  * \details
200  * The UDP transport is using an existing UDP stack and does not add any
201  * UDP information. However, size is chosen based on a fictional
202  * minimum UDP/IPv4 implementation with UDP(8) + IP (20) = 28 padded up to 32
203  */
204 #define UDP_PACKET_HEADER_MAX_LENGTH (32)
205 
206 /*ci
207  * \def UDP_PACKET_TRAILER_MAX_LENGTH
208  * \brief The maximum amount of trailer space needed to send a UDP data-sample
209  *
210  * \details
211  * The UDP transport is using an existing UDP stack and does not add any
212  * UDP information. A fictional implementation does not add any header or
213  * trailer thus it is set to 0
214  */
215 #define UDP_PACKET_TRAILER_MAX_LENGTH (0)
216 
217 #ifdef __cplusplus
218 } /* extern "C" */
219 #endif
220 
221 #endif /* netio_common_h */
222 
223 /*ci @} */

RTI Connext DDS Micro Version 2.4.11 Copyright © Mon Jul 23 2018 Real-Time Innovations, Inc