RTI Connext Micro  Version 2.4.1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
netio_udp.h
1 /*
2  * FILE: netio_udp.h - UDP API
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  * 13mar2013,eh Fix MICRO-352 (max message/send/receive sizes)
14  * 25apr2012,tk Written
15  *
16  */
17 /*ci
18  * \file
19  * \defgroup NETIO_UDPInterfaceClass UDP Interface
20  * \ingroup NETIOModule
21  * \brief NETIO UDP Interface
22  *
23  * \details
24  *
25  * The UDP interface is implemented as a NETIO interface and NETIO interface
26  * factory.
27  */
28 /*ci \addtogroup NETIO_UDPInterfaceClass
29  * @{
30  */
31 #ifndef netio_udp_h
32 #define netio_udp_h
33 
34 #ifndef osapi_config_h
35 #include "osapi/osapi_config.h"
36 #endif
37 #ifndef osapi_thread_h
38 #include "osapi/osapi_thread.h"
39 #endif
40 #ifndef rt_rt_h
41 #include "rt/rt_rt.h"
42 #endif
43 #ifndef reda_string_h
44 #include "reda/reda_string.h"
45 #endif
46 #ifndef reda_sequence_h
47 #include "reda/reda_sequence.h"
48 #endif
49 #ifndef netio_dll_h
50 #include "netio/netio_dll.h"
51 #endif
52 #ifndef netio_config_h
53 #include "netio/netio_config.h"
54 #endif
55 #ifndef netio_address_h
56 #include "netio/netio_address.h"
57 #endif
58 #ifndef netio_route_h
59 #include "netio/netio_route.h"
60 #endif
61 
62 #ifdef __cplusplus
63 extern "C"
64 {
65 #endif
66 
67 /*ci
68  * \brief Available UDP properties per interface
69  */
70 struct UDP_InterfaceProperty
71 {
72  /*ci
73  * \brief Inherited properties
74  */
75  struct NETIO_InterfaceProperty _parent;
76 };
77 
78 /*ci
79  * \brief Costant to initialize UDP_InterfaceProperty
80  */
81 #define UDP_InterfaceProperty_INITIALIZER \
82 {\
83  NETIO_InterfaceProperty_INITIALIZER\
84 }
85 
86 #ifndef RTI_CERT
87 struct UDP_NatEntry
88 {
89  struct NETIO_Address local_address;
90  struct NETIO_Address public_address;
91 };
92 
93 #define UDP_NatEntry_INITIALIZER \
94 {\
95  NETIO_Address_INITIALIZER,\
96  NETIO_Address_INITIALIZER,\
97 }
98 
99 REDA_DEFINE_SEQUENCE(UDP_NatEntrySeq,struct UDP_NatEntry)
100 
101 #define UDP_NatEntrySeq_INITIALIZER \
102  REDA_DEFINE_SEQUENCE_INITIALIZER(struct UDP_NatEntry)
103 
104 #endif /* !RTI_CERT */
105 
106 /*ci
107  * \def UDP_INTERFACE_MAX_IFNAME
108  * \brief Maximum length of a UDP network interface
109  */
110 #define UDP_INTERFACE_MAX_IFNAME 64
111 
112 /*ci
113  * \def UDP_INTERFACE_INTERFACE_UP_FLAG
114  * \brief Generic flag to indicate if a network stack is up
115  */
116 #define UDP_INTERFACE_INTERFACE_UP_FLAG 0x1
117 
118 /*ci
119  * \def UDP_INTERFACE_INTERFACE_MULTICAST_FLAG
120  * \brief Generic flag to indicate if a network stack supports multicast
121  */
122 #define UDP_INTERFACE_INTERFACE_MULTICAST_FLAG 0x2
123 
124 /*ci
125  * \brief Generic structure to describe a network interface
126  */
127 struct UDP_InterfaceTableEntry
128 {
129  /*ci
130  * \brief Flags to indicate if the interface is up etc.
131  */
132  RTI_UINT32 flags;
133 
134  /*ci
135  * \brief The address of interface as configured by the OS
136  */
137  RTI_UINT32 address;
138 
139  /*ci
140  * \brief The netmask of interface as configured by the OS
141  */
142  RTI_UINT32 netmask;
143 
144  /*ci
145  * \brief The name of interface as configured by the OS
146  */
147  char ifname[UDP_INTERFACE_MAX_IFNAME];
148 };
149 
150 /*ci
151  * \def UDP_InterfaceTableEntry_INITIALIZER
152  * \brief Constant to initialize \ref UDP_InterfaceTableEntry
153  */
154 #define UDP_InterfaceTableEntry_INITIALIZER \
155 {\
156  0,\
157  0,\
158  0,\
159  {0}\
160 }
161 
162 REDA_DEFINE_SEQUENCE(UDP_InterfaceTableEntrySeq,struct UDP_InterfaceTableEntry)
163 
164 #define UDP_InterfaceTableEntrySeq_INITIALIZER \
165  REDA_DEFINE_SEQUENCE_INITIALIZER(struct UDP_InterfaceTableEntry)
166 
167 /*ci
168  * \brief Add an entry to the list of available interfaces
169  *
170  * \details
171  *
172  * \param[in] seq The sequence to add the entry too
173  * \param[in] address The interface address
174  * \param[in] netmask The interface netmask
175  * \param[in] ifname The interface nmae
176  * \param[in] flags The interface state and features
177  *
178  * \return RTI_TRUE on success, RTI_FALSE on failure
179  */
180 MUST_CHECK_RETURN NETIODllExport RTI_BOOL
181 UDP_InterfaceTable_add_entry(struct UDP_InterfaceTableEntrySeq *seq,
182  RTI_UINT32 address,
183  RTI_UINT32 netmask,
184  const char *ifname,
185  RTI_UINT32 flags);
186 
187 #ifdef __cplusplus
188 } /* extern "C" */
189 #endif
190 
191 #ifdef __cplusplus
192 extern "C"
193 {
194 #endif
195 
196 struct UDP_InterfaceFactoryProperty;
197 NETIODllExport RTI_BOOL
198 UDP_InterfaceFactoryProperty_initialize(
199  struct UDP_InterfaceFactoryProperty* self);
200 
201 NETIODllExport RTI_BOOL
202 UDP_InterfaceFactoryProperty_finalize(
203  struct UDP_InterfaceFactoryProperty *p);
204 
205 #ifdef __cplusplus
206 }
207 #endif
208 
209 /*ci
210  * \brief Properties the UDP interface can be registered with
211  */
212 struct UDP_InterfaceFactoryProperty
213 {
214  /*ci
215  * \brief Inherited property struct
216  */
217  struct NETIO_InterfaceFactoryProperty _parent;
218 
219  /*ci
220  * \brief Sequence of allowed interface names
221  */
222  struct REDA_StringSeq allow_interface;
223 
224  /*ci
225  * \brief Sequence of denied interface names
226  */
227  struct REDA_StringSeq deny_interface;
228 
229  /*ci
230  * \brief The size of the send socket buffer
231  */
232  RTI_INT32 max_send_buffer_size;
233 
234  /*ci
235  * \brief The size of the receive socket buffer
236  */
237  RTI_INT32 max_receive_buffer_size;
238 
239  /*ci
240  * \brief The maximum size of the message which can be received
241  */
242  RTI_INT32 max_message_size;
243 
244  /*ci
245  * \brief The maximum TTL
246  */
247  RTI_INT32 multicast_ttl;
248 
249 #ifndef RTI_CERT
250  struct UDP_NatEntrySeq nat;
251 #endif /* !RTI_CERT */
252 
253  /*ci
254  * \brief The interface table if interfaces are added manually
255  */
256  struct UDP_InterfaceTableEntrySeq if_table;
257 
258  /*ci
259  * \brief The network interface to use to send to multicast
260  */
261  REDA_String_T multicast_interface;
262 
263  /*ci
264  * \brief If this should be considered the default UDP interfaces if
265  * no other UDP interface is found to handle a route
266  */
267  RTI_BOOL is_default_interface;
268 
269  /*ci
270  * \brief Disable reading of available network interfaces using system
271  * information and instead rely on the manually configured
272  * interface table
273  */
274  RTI_BOOL disable_auto_interface_config;
275 
276  /*ci
277  * \brief Thread properties for each receive thread created by this
278  * NETIO interface.
279  */
280  struct OSAPI_ThreadProperty recv_thread;
281 
282 #ifdef RTI_CPP
283  public:
284  UDP_InterfaceFactoryProperty()
285  {
286  UDP_InterfaceFactoryProperty_initialize(this);
287  }
288  ~UDP_InterfaceFactoryProperty() { }
289  private:\
290  UDP_InterfaceFactoryProperty(
291  const struct UDP_InterfaceFactoryProperty& from )
292  {
293  UNUSED_ARG(from);
294  }
295  struct UDP_InterfaceFactoryProperty& operator=(
296  const struct UDP_InterfaceFactoryProperty& from )
297  {
298  UNUSED_ARG(from);
299  return *this;
300  }
301  bool operator==(
302  const struct UDP_InterfaceFactoryProperty& other)
303  {
304  UNUSED_ARG(other);
305  return false;
306  }
307  bool operator!=(
308  const struct UDP_InterfaceFactoryProperty& other)
309  {
310  UNUSED_ARG(other);
311  return false;
312  }
313 #endif
314 };
315 
316 #ifdef __cplusplus
317 extern "C"
318 {
319 #endif
320 
321 /*ci
322  * \def UDP_InterfaceFactoryProperty_INITIALIZER
323  * \brief Constant to initialize UDP_InterfaceFactoryProperty
324  */
325 #if (OSAPI_PLATFORM == OSAPI_PLATFORM_VXWORKS) && \
326  (!VXWORKS_VERSION_6_3_OR_BETTER)
327 
328 #define UDP_InterfaceFactoryProperty_INITIALIZER \
329 {\
330  NETIO_InterfaceFactoryProperty_INITIALIZER,\
331  REDA_StringSeq_INITIALIZER,\
332  REDA_StringSeq_INITIALIZER,\
333  (8*1024),\
334  (8*1024),\
335  (8*1024),\
336  1,\
337  UDP_NatEntrySeq_INITIALIZER,\
338  UDP_InterfaceTableEntrySeq_INITIALIZER,\
339  NULL,\
340  RTI_TRUE,\
341  RTI_FALSE, \
342  OSAPI_THREAD_PROPERTY_DEFAULT \
343 }
344 #else /* !VxWorks <6.3 */
345 
346 #ifndef RTI_CERT
347 #define UDP_InterfaceFactoryProperty_INITIALIZER \
348 {\
349  NETIO_InterfaceFactoryProperty_INITIALIZER,\
350  REDA_StringSeq_INITIALIZER,\
351  REDA_StringSeq_INITIALIZER,\
352  (256*1024),\
353  (256*1024),\
354  (8*1024),\
355  1,\
356  UDP_NatEntrySeq_INITIALIZER,\
357  UDP_InterfaceTableEntrySeq_INITIALIZER,\
358  NULL,\
359  RTI_TRUE,\
360  RTI_FALSE, \
361  OSAPI_THREAD_PROPERTY_DEFAULT \
362 }
363 #else
364 #define UDP_InterfaceFactoryProperty_INITIALIZER \
365 {\
366  NETIO_InterfaceFactoryProperty_INITIALIZER,\
367  REDA_StringSeq_INITIALIZER,\
368  REDA_StringSeq_INITIALIZER,\
369  (8*1024),\
370  (8*1024),\
371  (8*1024),\
372  1,\
373  UDP_InterfaceTableEntrySeq_INITIALIZER,\
374  NULL,\
375  RTI_TRUE,\
376  RTI_FALSE, \
377  OSAPI_THREAD_PROPERTY_DEFAULT \
378 }
379 #endif /* !RTI_CERT */
380 #endif
381 
382 #define UDP_INTERFACE_INTERFACE_ID RT_MKINTERFACEID(\
383  RT_COMPONENT_CLASS_NETIO,RT_COMPONENT_INSTANCE_UDP)
384 
385 extern NETIODllVariable struct UDP_InterfaceFactoryProperty UDP_INTERFACE_FACTORY_PROPERTY_DEFAULT;
386 
387 /*ci
388  * \brief Function to retrieve the concrete implementation of the
389  * NETIO UDP interface.
390  *
391  * \return Pointer to UDP interface implementation
392  */
393 
394 MUST_CHECK_RETURN NETIODllExport struct RT_ComponentFactoryI*
395 UDP_InterfaceFactory_get_interface(void);
396 
397 #ifdef __cplusplus
398 } /* extern "C" */
399 #endif
400 
401 #endif /* netio_udp_h */
402 
403 /*ci @} */
404 

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