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

RTI Connext DDS Micro Version 2.4.7 Copyright © Fri Feb 26 2016 Real-Time Innovations, Inc