b57e570dc71b4678a6d97a5f6b28a8edafd1aa5e
[o-du/l2.git] / src / cm / cm_inet.h
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18 /********************************************************************20**
19   
20         Name:     common Internet socket library
21     
22         Type:     header file 
23   
24         Desc:     common library for Internet sockets
25  
26         File:     cm_inet.h
27
28 *********************************************************************21*/
29  
30 \f
31 /*
32  *      This software may be combined with the following TRILLIUM
33  *      software:
34  *
35  *      part no.                      description
36  *      --------    ----------------------------------------------
37  *      1000151     TCAP over TCP/IP
38  */
39
40 #ifndef __CMINETH__
41 #define __CMINETH__
42
43 #define CM_INET_IPV4ADDR_SIZE      4
44 #define CM_INET_IPV6ADDR_SIZE      16
45
46 #define CM_INET_IPV4PORT_SIZE      2 
47 #define CM_INET_IPV6PORT_SIZE      2 
48
49 /* reusing the definition */
50 #define CM_INET_IPV4ADDR_TYPE CM_IPV4ADDR_TYPE
51 #define CM_INET_IPV6ADDR_TYPE CM_IPV6ADDR_TYPE
52
53 #ifdef WIN32
54 #define CM_INET_HIGH_VER     2
55 #define CM_INET_LOW_VER      2
56 #endif /* WIN32 */
57
58 /* Invalid socket flag */
59 #ifdef WIN32
60 #define CM_INET_INV_SOCKFD INVALID_SOCKET
61 #else
62 #define CM_INET_INV_SOCKFD -1
63 #endif
64
65 /* cm_inet_h_001.main_30 Poll Specific changes */
66 #define CM_INET_POLL_MAXFDSUPP 1024
67
68 #define CM_INET_IPV4_NUM_ADDR   16
69 #define CM_INET_IPV6_NUM_ADDR   4 
70
71 /*cm_inet_h_001.main_21 Updated for TUCL 2.1 Release (Kernel SCTP Support) */
72 #ifdef CM_LKSCTP
73 #define CM_INET_NUM_NET_ADDR    5 
74
75 #define CM_INET_SCTP_MSG_NOTIFICATION  0x8000
76 #define CM_INET_SCTP_MSG_EOR           0x80
77
78 /* sctp notification type */
79 #define CM_INET_SCTP_ASSOC_CHANGE              1
80 #define CM_INET_SCTP_PEER_ADDR_CHANGE          2
81 #define CM_INET_SCTP_SEND_FAILED               3
82 #define CM_INET_SCTP_REMOTE_ERROR              4
83 #define CM_INET_SCTP_SHUTDOWN_EVENT            5
84 #define CM_INET_SCTP_PARTIAL_DELIVERY_EVENT    6 
85 #define CM_INET_SCTP_ADAPTATION_INDICATION     7 
86
87 /* sctp association change state */
88 #define CM_INET_SCTP_COMM_UP          1
89 #define CM_INET_SCTP_COMM_LOST        2
90 #define CM_INET_SCTP_RESTART          3
91 #define CM_INET_SCTP_SHUTDOWN_COMP    4
92 #define CM_INET_SCTP_CANT_STR_ASSOC   5
93
94 /* sctp peer addr state */
95 #define CM_INET_SCTP_ADDR_AVAILABLE     1
96 #define CM_INET_SCTP_ADDR_UNREACHABLE   2
97 #define CM_INET_SCTP_ADDR_REMOVED       3
98 #define CM_INET_SCTP_ADDR_ADDED         4
99 #define CM_INET_SCTP_ADDR_MADE_PRIM     5
100 #define CM_INET_SCTP_ADDR_CONFIRMED     6
101
102 /* sctp assoc state */
103 #define CM_INET_SCTP_STA_EMPTY              0
104 #define CM_INET_SCTP_STA_CLOSED             1
105 #define CM_INET_SCTP_STA_COOKIE_WAIT        2
106 #define CM_INET_SCTP_STA_COOKIE_ECHOED      3
107 #define CM_INET_SCTP_STA_ESTABLISHED        4
108 #define CM_INET_SCTP_STA_SHUTDOWN_PENDING   5
109 #define CM_INET_SCTP_STA_SHUTDOWN_SENT      6
110 #define CM_INET_SCTP_STA_SHUTDOWN_RECEIVED  7 
111 #define CM_INET_SCTP_STA_SHUTDOWN_ACK_SENT  8
112 #endif
113
114 #ifdef IPV6_SUPPORTED 
115 #define CM_INET_IPV4_DOMAIN     AF_INET
116 #define CM_INET_IPV6_DOMAIN     AF_INET6
117 #endif /* IPV6_SUPPORTED */
118
119 /* domain */
120
121 /* cm_inet_h_001.main_31 : added macro for Debug print buffer size */
122 #ifdef CMINETDBG
123 #define CMINET_PRNT_BUF_SIZE 512
124 #endif
125 /* socket types */
126 #define CM_INET_STREAM  SOCK_STREAM   
127 #define CM_INET_DGRAM   SOCK_DGRAM
128 /*cm_inet_h_001.main_21 Updated for TUCL 2.1 Release (Kernel SCTP Support) */
129 #ifdef CM_LKSCTP
130 #define CM_INET_SEQPACKET   SOCK_SEQPACKET
131 #endif
132
133 /* cm_inet_h_001.main_18:Added CM_INET_AI_PASSIVE for getaddrinfo*/
134 #define CM_INET_AI_PASSIVE   AI_PASSIVE
135
136 #ifdef CM_INET2  
137 #define   CM_INET_RAW   SOCK_RAW
138 #endif  /* CM_INET2 */ 
139
140 /* socket options type */
141 #define CM_INET_OPT_BLOCK         0  /* blocking socket */ 
142 #define CM_INET_OPT_REUSEADDR     1  /* reuse socket address */
143 #define CM_INET_OPT_RX_BUF_SIZE   2  /* socket receive buffer size */
144 #define CM_INET_OPT_TX_BUF_SIZE   3  /* socket transmitt buffer size */
145 #define CM_INET_OPT_ADD_MCAST_MBR 4  /* add IP multicast group membership */
146 #define CM_INET_OPT_DRP_MCAST_MBR 5  /* drop IP multicast group membership */
147 #define CM_INET_OPT_TCP_NODELAY   6  /* disable TCP Nagle algorithm */
148
149 #ifdef SS_LINUX
150 #define CM_INET_OPT_BSD_COMPAT    7  /* BSD compatible option for Linux */
151 #endif /* SS_LINUX */
152
153 #define CM_INET_OPT_MCAST_LOOP    8  /* Multicast loop enable/disable */
154 #define CM_INET_OPT_MCAST_IF      9  /* specify local outgoing interface */
155 #define CM_INET_OPT_MCAST_TTL     14 /* Specify TTL value for multicast
156                                       * applications */
157 #ifdef CM_INET2  
158 #define CM_INET_OPT_HDR_INCLD     10 /* Header Include */
159 #define CM_INET_OPT_DONTFRAGMENT  11 /* Don't Fragment  */
160 #define CM_INET_OPT_TOS           12 /* Type of service  */
161 #define CM_INET_OPT_TTL           13 /* Time to Live   */
162
163 #ifdef IPV6_SUPPORTED
164 #define CM_INET_OPT_ADD_MCAST6_MBR  15 /* Add IPV6 multicast member */
165 #define CM_INET_OPT_DRP_MCAST6_MBR  16 /* Drop IPV6 multicast member */
166 #define CM_INET_OPT_MCAST6_LOOP     17 /* Enable or disable multicast loop 
167                                         * packets */
168 #define CM_INET_OPT_MCAST6_IF       18 /* Specify multicast interface */
169 #define CM_INET_OPT_MCAST6_HOPS     19 /* Specify multicast hop limit */
170
171 #define CM_INET_OPT_ICMP6_FILTER    20 /* Specify icmp V6 filter */
172 #define CM_INET_OPT_IPV6_TTL        21 /* Specify unicast hop limit */
173
174 /* IPv6 socket options */
175 #ifdef IPV6_OPTS_SUPPORTED
176 #define CM_INET_OPT_RECVIPV6_HOPLIM  22 /* Receive hop limit */
177 #define CM_INET_OPT_RECVIPV6_HBHOPTS 25  /* Receive HopByHop options */
178 #define CM_INET_OPT_RECVIPV6_DSTOPTS 26  /* Receive Destination options */
179 #define CM_INET_OPT_RECVIPV6_RTHDR   27  /* Receive Route header options */
180 #define CM_INET_ALL_IPV6_EXTHDRS_LEN 512 /* total length of 3 IPV6 ext hdrs */
181 #define CM_INET_OPT_IP_ROUTER_ALERT6 30
182 #endif /* IPV6_OPTS_SUPPORTED */
183 #define CM_INET_OPT_IPV6_PKTINFO     31
184 #endif /* IPV6_SUPPORTED */
185
186 /* IPv4 socket options */
187 #ifdef IPV4_OPTS_SUPPORTED
188 #define CM_INET_OPT_IP_OPTIONS       28 /* Router Alert in IPv4 */
189 #define CM_INET_OPT_IPV4_PKTINFO     32 /* IPv4 PKTINFO */
190 #define CM_INET_OPT_IP_ROUTER_ALERT  29 /* Router Alert to Intercept Linux */
191 #endif /* IPV4_OPTS_SUPPORTED */
192 #endif  /* CM_INET2 */ 
193
194 #define CM_INET_OPT_BROADCAST        23 /* Broadcasting enable/disable */
195 #define CM_INET_OPT_KEEPALIVE        24 /* KEEPALIVE enable/disable */
196
197 /*cm_inet_h_001.main_21 Updated for TUCL 2.1 Release (Kernel SCTP Support) */
198 #ifdef CM_LKSCTP
199 #define CM_INET_OPT_LINGER                 33 /* socket linger */
200 #define CM_INET_OPT_SCTP_EVENTS            34 /* sctp events */
201 #define CM_INET_OPT_SCTP_PRIM_ADDR         35 /* sctp primary address */
202 #define CM_INET_OPT_SCTP_PEERADDR_PARAMS   36 /* sctp peer address parameters */
203 #define CM_INET_OPT_SCTP_GET_ASSOC_STA     37
204 #define CM_INET_OPT_SCTP_GET_PADDR_INFO    38
205 /*cm_inet_h_001.main_22 Updated for the support of configurable RTO parameters, 
206                         HBeat value Max retransmissions (Init, Path, Association)*/
207 #define CM_INET_OPT_SCTP_ASSOC_PARAMS      39
208 #define CM_INET_OPT_SCTP_RTO_INFO          40
209 #define CM_INET_OPT_SCTP_INIT_MSG          41
210 #endif
211
212
213 /* cm_inet_h_001.main_29: Added new macro to support filter for ICMP messages */
214 #ifdef CM_ICMP_FILTER_SUPPORT
215 #ifdef SS_LINUX
216 #define CM_INET_OPT_ICMP_FILTER    42 
217 #endif
218 #ifdef IPV6_SUPPORTED
219 #define CM_MAX_IPV6_FILTER  8
220 #endif
221 #endif
222
223 /* socket option value */
224 #define CM_INET_OPT_DISABLE  0      /* enable option */
225 #define CM_INET_OPT_ENABLE   1      /* disable option */
226 #ifdef CM_LKSCTP
227 /* cm_inet_h_001.main_23: changed the value from 0xffffffff to ~0 to fix TUCL
228                           warnings */
229 #define CM_INET_OPT_DEFAULT  (~0) /* default option */
230 #endif
231
232 /* level for cmInetSetOpt */
233 #define CM_INET_LEVEL_SOCKET      SOL_SOCKET   /* socket level option */
234 #define CM_INET_LEVEL_IP          IPPROTO_IP   /* IP level option */
235 #define CM_INET_LEVEL_TCP         IPPROTO_TCP  /* TCP level option */
236 #define CM_INET_LEVEL_SCTP        IPPROTO_SCTP /* SCTP level option */
237 /* cm_inet_h_001.main_29: Added new macro to support filter for ICMP messages */
238 #ifdef CM_ICMP_FILTER_SUPPORT
239 #ifdef SS_LINUX
240 #define CM_INET_LEVEL_RAW         SOL_RAW   /* socket level option */
241 #endif
242 #endif
243
244 /* shutdown options */
245 #ifdef WIN32
246 #define CM_INET_SHTDWN_RECV  SD_RECEIVE
247 #define CM_INET_SHTDWN_SEND  SD_SEND
248 #define CM_INET_SHTDWN_BOTH  SD_BOTH 
249 #else
250 #define CM_INET_SHTDWN_RECV  0
251 #define CM_INET_SHTDWN_SEND  1
252 #define CM_INET_SHTDWN_BOTH  2
253 #endif /* WIN32 */
254
255 /* send/recv control flags */
256 #define CM_INET_NO_FLAG   0
257 #define CM_INET_MSG_PEEK  MSG_PEEK
258
259 #if !(defined(WIN32) || defined(SS_LINUX))
260 #define CM_INET_MAX_INFO 512 
261 #endif /* WIN32 || SS_LINUX */
262
263 #define CM_INET_MAX_DBUF  15 /* max. number of dBufs for a message */
264
265 /* cm_inet_h_001.main_24 : Inet message length is extended to 7fffffff when LONG_MSG is defined */
266
267 /* cm_inet_h_001.main_26  rss 1. Provided the user the flexibility to set CM_INET_MAX_MSG_LEN
268  * value during compilation time */
269 #ifndef CM_INET_MAX_MSG_LEN 
270 #define CM_INET_MAX_MSG_LEN  0x7fff  /* max length of a message */
271 #endif
272
273 /* cm_inet_h_001.main_25 : ifndef flag added as this can be defined by the customer now*/
274 #ifndef CM_INET_MAX_UDPRAW_MSGSIZE
275 #define CM_INET_MAX_UDPRAW_MSGSIZE 2048
276 #endif
277
278 #define CM_INET_IPV6_ANCIL_DATA  512
279 #define CM_INET_IPV4_ANCIL_DATA  128
280
281 #define CM_INET_READ_ANY  -1  /* read any pending data */
282
283 /* cm_inet_h_001.main_19  1. Added new defines for the new interface - 
284                              cmInetFlushRecvBuf() to flush the data 
285                              from socket receive buffer. */
286 #ifdef CM_INET_FLUSH_RECV_BUF
287 #define CM_INET_READ_THROW -2  /* read and throw data from receive buffer */
288 #define CM_INET_MAX_BYTES_READ 1024
289 #endif /*CM_INET_FLUSH_RECV_BUF*/
290
291 /* cm_inet_h_001.main_20  Added new defines for returning unreachable failure */
292 #define RNETFAILED 27
293
294 #define CM_INET_INADDR_ANY  INADDR_ANY  /* accepts any address */
295
296 #ifdef CM_INET2  
297
298 /* protocol values */
299 #define   CM_INET_PROTO_IP    IPPROTO_IP   /* IP protocol */
300 #define   CM_INET_PROTO_ICMP  IPPROTO_ICMP /* ICMP protocol */
301 #define   CM_INET_PROTO_TCP   IPPROTO_TCP  /* TCP  protocol */
302 #define   CM_INET_PROTO_UDP   IPPROTO_UDP  /* UDP protocol */
303 #define   CM_INET_PROTO_RAW   IPPROTO_RAW  /* Raw protocol */
304 #define   CM_INET_PROTO_SCTP  132          /* SCTP protocol  */
305 /*cm_inet_h_001.main_21 Updated for TUCL 2.1 Release (Kernel SCTP Support) */
306 #ifdef CM_LKSCTP
307 #define   CM_INET_PROTO_LKSCTP  IPPROTO_SCTP          /* SCTP protocol  */
308 #endif
309 #define   CM_INET_PROTO_RSVP  46           /* RSVP protocol */
310
311 #ifdef IPV6_SUPPORTED
312 #define   CM_INET_LEVEL_IPV6   IPPROTO_IPV6   /* IP V6 protocol */
313 #define   CM_INET_PROTO_IPV6   IPPROTO_IPV6   /* IP V6 protocol */
314 #define   CM_INET_PROTO_ICMPV6 IPPROTO_ICMPV6 /* ICMP V6 protocol */
315 #endif /* IPV6_SUPPORTED */
316
317 #endif  /* CM_INET2 */ 
318
319 /* macros */
320
321 /* macros to manipulate and checking a socket file descriptor set */
322 #define CM_INET_FD_SET(_sockFd, _fdSet)    FD_SET((_sockFd)->fd, _fdSet) 
323 #define CM_INET_FD_CLR(_sockFd, _fdSet)    FD_CLR((_sockFd)->fd, _fdSet)
324 #define CM_INET_FD_ISSET(_sockFd, _fdSet)  FD_ISSET((_sockFd)->fd, _fdSet)
325 #define CM_INET_FD_ZERO(_fdSet)            FD_ZERO(_fdSet)
326
327 /* macros to convert from network to host byteorder and vice versa */
328 #define CM_INET_NTOH_UINT32(_long)  ntohl(_long)
329 #define CM_INET_HTON_UINT32(_long)  htonl(_long)
330 #define CM_INET_NTOH_UINT16(_word)  ntohs(_word)
331 #define CM_INET_HTON_UINT16(_word)  htons(_word)
332
333 /* peeks a uint8_t from the given position */
334 #define CM_INET_PEEK_UINT8(_sockFd, _fromAddr, _info, _pos, _octet, _ret)  \
335    _ret = cmInetPeek(_sockFd, _fromAddr, _info, _pos, sizeof(uint8_t), &_octet)  
336           
337 /* 
338  * peeks a uint16_t from the given position (it is supposed that the uint16_t is 
339  * represented in big endian representation within the data stream) 
340  */
341 #define CM_INET_PEEK_UINT16(_sockFd, _fromAddr, _info, _pos, _word, _ret)  \
342    {  \
343       uint8_t _tempWord[2];  \
344       \
345       _ret = cmInetPeek(_sockFd, _fromAddr, _info, _pos, sizeof(uint16_t), _tempWord);  \
346       if (_ret == ROK)  \
347       {  \
348          _word = ((_tempWord[0] << 8) + (_tempWord[1]));  \
349       }  \
350    }
351
352 /* 
353  * peeks a uint32_t from the given position (it is supposed that the uint32_t is 
354  * represented in big endian representation within the data stream)
355  */
356 #define CM_INET_PEEK_UINT32(_sockFd, _fromAddr, _info, _pos, _long, _ret)  \
357    {  \
358       uint8_t _tempLong[4];  \
359       \
360       _ret = cmInetPeek(_sockFd, _fromAddr, _info, _pos, sizeof(uint32_t), _tempLong);  \
361       if (_ret == ROK)  \
362       {  \
363          _long = ((_tempLong[0] << 24) + (_tempLong[1] << 16)  \
364                 + (_tempLong[2] << 8) + _tempLong[3]);  \
365       }  \
366    }
367
368 /* tests if socket descriptor is invalide */
369 #ifdef WIN32 
370 #define CM_INET_INV_SOCK_FD(_sockFd)  ((_sockFd)->fd == INVALID_SOCKET)
371 #else
372 #define CM_INET_INV_SOCK_FD(_sockFd)  ((_sockFd)->fd < 0)
373 #endif /* WIN32 */
374
375 /* tests if two socket descriptor are equal */
376 #define CM_INET_SOCK_SAME(_s1, _s2, _ret)  \
377    {  \
378       _ret = FALSE;  \
379       if ((_s1->fd == _s2->fd) &&  \
380           (_s1->blocking == _s2->blocking) &&  \
381           (_s1->type == _s2->type))  \
382       {  \
383          _ret = TRUE;  \
384       }  \
385    }
386
387 /* set socket descriptor to an invalid (uninitialized) value */
388 #ifdef WIN32 
389 #define CM_INET_SET_INV_SOCK_FD(_sockFd)  ((_sockFd)->fd = INVALID_SOCKET)
390 #else
391 #define CM_INET_SET_INV_SOCK_FD(_sockFd)  ((_sockFd)->fd = -1)
392 #endif /* WIN32 */
393
394 /* This macro frees ipHdrParm structure memory allocated to hold ipv6
395  * extension headers */
396
397 #ifdef IPV6_OPTS_SUPPORTED
398 #define CM_INET_FREE_IPV6_HDRPARM(_region, _pool, _hdrParmIpv6) \
399 { \
400    uint8_t numOpts; \
401    if( _hdrParmIpv6->ipv6ExtHdr.hbhHdrPrsnt) \
402    { \
403       for(numOpts = _hdrParmIpv6->ipv6ExtHdr.hbhOptsArr.numHBHOpts;  \
404           numOpts > 0; numOpts--) \
405       { \
406          if (_hdrParmIpv6->ipv6ExtHdr.hbhOptsArr.hbhOpts[numOpts - 1].length) \
407             SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,_region, _pool, (Data *)_hdrParmIpv6->ipv6ExtHdr. \
408                  hbhOptsArr.hbhOpts[numOpts - 1].value, (Size)(_hdrParmIpv6-> \
409                  ipv6ExtHdr.hbhOptsArr.hbhOpts[numOpts - 1].length)); \
410             SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,_region, _pool, (Data *)&_hdrParmIpv6->ipv6ExtHdr. \
411                  hbhOptsArr.hbhOpts[numOpts - 1], \
412                  (Size)sizeof(CmInetIpv6HBHHdr)); \
413       } \
414    } \
415    if(_hdrParmIpv6->ipv6ExtHdr.destOptsPrsnt) \
416    { \
417       for(numOpts = _hdrParmIpv6->ipv6ExtHdr.destOptsArr.numDestOpts; \
418           numOpts > 0; numOpts--) \
419       { \
420          SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,_region, _pool, (Data *)_hdrParmIpv6->ipv6ExtHdr. \
421                 destOptsArr.destOpts[numOpts - 1].value, (Size)(_hdrParmIpv6-> \
422                 ipv6ExtHdr.destOptsArr.destOpts[numOpts - 1].length)); \
423          SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,_region, _pool, (Data *)&_hdrParmIpv6->ipv6ExtHdr. \
424                 destOptsArr.destOpts[numOpts - 1], \
425                 (Size)sizeof(CmInetIpv6DestOptsHdr)); \
426       } \
427    } \
428    if( _hdrParmIpv6->ipv6ExtHdr.rtOptsPrsnt) \
429    { \
430       SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,_region, _pool, \
431                (Data *)_hdrParmIpv6->ipv6ExtHdr.rtOptsArr.ipv6Addrs, \
432                (Size)(_hdrParmIpv6->ipv6ExtHdr.rtOptsArr.numAddrs * 16)); \
433    } \
434 }
435 /* Use the function for HBH options for destinations options as both ext
436  * header has similar format */
437   
438 #define cmInet6BuildRecvDstOptsArr(cmsgPtr, cmsg_len, destOptsArr, hdrId, info) \
439         cmInet6BuildRecvHopOptsArr(cmsgPtr, cmsg_len, \
440                               (CmInetIpv6HBHHdrArr *)destOptsArr, hdrId, info)
441
442 #define cmInet6BuildSendDestOpts(destOptsArr, cmsgData, curMsgIdx, hdrId) \
443         cmInet6BuildSendHBHOpts((CmInetIpv6HBHHdrArr *)destOptsArr, \
444                                  cmsgData, curMsgIdx, hdrId)
445    
446 #endif /* IPV6_OPTS_SUPPORTED */
447
448 #ifdef IPV6_SUPPORTED
449 #define CM_INET_COPY_IPV6ADDR(_addrToFill, _fromAddr)   \
450 {                                                       \
451    memcpy(_addrToFill, _fromAddr, sizeof(CmInetIpAddr6)); \
452 }
453
454 #if (defined(SUNOS) || defined(HPOS) || defined(SS_VW))
455
456 #define CM_INET_ICMP6_FILTER_SETPASSALL(_icmp6Filter)    \
457 {                                                        \
458    ICMP6_FILTER_SETPASSALL(&_icmp6Filter);               \
459 }
460
461 #define CM_INET_ICMP6_FILTER_SETBLOCKALL(_icmp6Filter)   \
462 {                                                        \
463    ICMP6_FILTER_SETBLOCKALL(&_icmp6Filter);              \
464 }
465
466 #define CM_INET_ICMP6_FILTER_SETPASS(msgType, _icmp6Filter)  \
467 {                                                            \
468    ICMP6_FILTER_SETPASS(msgType, &_icmp6Filter);             \
469 }
470
471 #define CM_INET_ICMP6_FILTER_SETBLOCK(msgType, _icmp6Filter) \
472 {                                                            \
473    ICMP6_FILTER_SETBLOCK(msgType, &_icmp6Filter);            \
474 }
475
476 #define CM_INET_ICMP6_FILTER_WILLPASS(msgType, _icmp6Filter) \
477 {                                                            \
478    ICMP6_FILTER_WILLPASS(msgType, &_icmp6Filter);            \
479 }
480
481 #define CM_INET_ICMP6_FILTER_WILLBLOCK(msgType, _icmp6Filter) \
482 {                                                             \
483    ICMP6_FILTER_WILLBLOCK(msgType, &_icmp6Filter);            \
484 }
485 #endif /* SUNOS || HPOS */
486 #endif /* IPV6_SUPPORTED */
487
488 #define cmPkCmInetIpAddr(x, mBuf)       oduUnpackUInt32(x, mBuf)  /* pack IP Address */
489 #define cmUnpkCmInetIpAddr(x, mBuf)     oduPackUInt32(x, mBuf)  /* unpacks IP Address */
490
491 #ifdef SS_VW
492 #define CM_COPY_VWIPADDR(vwIpAddr, addr) \
493    { \
494       memcpy(addr, &vwIpAddr, sizeof(S32)); \
495    }
496 #endif
497
498 /* Changes for peeking into the file descriptor set */
499 #ifdef WIN32
500 #define CM_INET_FDSETINFO_RESET(_fdSetInfo) \
501 { \
502    _fdSetInfo->numFds = 0; \
503 }
504 #else
505 #define CM_INET_FDSETINFO_RESET(_fdSetInfo) \
506 { \
507    _fdSetInfo->arIdx = 0; \
508 }
509 #endif /* WIN32 */
510
511 /* convert a hex character in ASCII to int format */
512 #define CM_INET_ATOH(_intVal, _asciiVal)                                   \
513 {                                                                         \
514    if ((_asciiVal >='a') && (_asciiVal <='f'))                            \
515    {                                                                      \
516      _intVal = (16 * _intVal) + (_asciiVal - 'a' +10 );                   \
517    }                                                                      \
518    else if ((_asciiVal >='A') && (_asciiVal <= 'F'))                      \
519    {                                                                      \
520      _intVal = (16 * _intVal) + (_asciiVal - 'A' +10 );                   \
521    }                                                                      \
522    else                                                                   \
523    {                                                                      \
524      _intVal = (16 * _intVal) + (_asciiVal - '0');                        \
525    }                                                                      \
526 }
527
528 /* convert a decimal digit in ASCII to int format */
529 #define CM_INET_ATOI(_intVal, _asciiVal)                                  \
530 {                                                                         \
531    _intVal = (10 * _intVal) + (_asciiVal - '0');                          \
532 }
533
534
535 #define CM_INET_GET_IPV4_ADDR_FRM_STRING(_value, _str)                    \
536 {                                                                         \
537    uint16_t     _hiWord;                                                       \
538    uint16_t     _loWord;                                                       \
539                                                                           \
540    _hiWord = 0;                                                           \
541    _loWord = 0;                                                           \
542    _hiWord = PutHiByte(_hiWord, (_str[0]));                               \
543    _hiWord = PutLoByte(_hiWord, (_str[1]));                               \
544    _loWord = PutHiByte(_loWord, (_str[2]));                               \
545    _loWord = PutLoByte(_loWord, (_str[3]));                               \
546    _value  = PutLoWord(_value, _loWord);                                  \
547    _value  = PutHiWord(_value, _hiWord);                                  \
548 }
549
550 /* cm_inet_h_001.main_27: Added error codes*/
551 #define CMINETLOGERROR(errCls, errCode, errVal, errDesc) \
552    SLogError(ENTNC, INSTNC, 0, __FILE__, __LINE__, \
553                       errCls, errCode, errVal, errDesc )
554
555 #define ECMINET         0
556 #define ECMINET001      (ECMINET + 1)     /*cm_inet.c : 819*/
557 #define ECMINET002      (ECMINET + 2)     /*cm_inet.c : 871*/
558 #define ECMINET003      (ECMINET + 3)     /*cm_inet.c : 993*/
559 #define ECMINET004      (ECMINET + 4)     /*cm_inet.c : 997*/
560 #define ECMINET005      (ECMINET + 5)     /*cm_inet.c : 1081*/
561 #define ECMINET006      (ECMINET + 6)     /*cm_inet.c : 1188*/
562 #define ECMINET007      (ECMINET + 7)     /*cm_inet.c : 1226*/
563 #define ECMINET008      (ECMINET + 8)     /*cm_inet.c : 1335*/
564 #define ECMINET009      (ECMINET + 9)     /*cm_inet.c : 1423*/
565 #define ECMINET010      (ECMINET + 10)    /*cm_inet.c : 1566*/
566 #define ECMINET011      (ECMINET + 11)    /*cm_inet.c : 1659*/
567 #define ECMINET012      (ECMINET + 12)    /*cm_inet.c : 1783*/
568 #define ECMINET013      (ECMINET + 13)    /*cm_inet.c : 1867*/
569 #define ECMINET014      (ECMINET + 14)    /*cm_inet.c : 1987*/
570 #define ECMINET015      (ECMINET + 15)    /*cm_inet.c : 2292*/
571 #define ECMINET016      (ECMINET + 16)    /*cm_inet.c : 2310*/
572 #define ECMINET017      (ECMINET + 17)    /*cm_inet.c : 2571*/
573 #define ECMINET018      (ECMINET + 18)    /*cm_inet.c : 2811*/
574 #define ECMINET019      (ECMINET + 19)    /*cm_inet.c : 2955*/
575 #define ECMINET020      (ECMINET + 20)    /*cm_inet.c : 2960*/
576 #define ECMINET021      (ECMINET + 21)    /*cm_inet.c : 3020*/
577 #define ECMINET022      (ECMINET + 22)    /*cm_inet.c : 3119*/
578 #define ECMINET023      (ECMINET + 23)    /*cm_inet.c : 3412*/
579 #define ECMINET024      (ECMINET + 24)    /*cm_inet.c : 3606*/
580 #define ECMINET025      (ECMINET + 25)    /*cm_inet.c : 3709*/
581 #define ECMINET026      (ECMINET + 26)    /*cm_inet.c : 3723*/
582 #define ECMINET027      (ECMINET + 27)    /*cm_inet.c : 3747*/
583 #define ECMINET028      (ECMINET + 28)    /*cm_inet.c : 4148*/
584 #define ECMINET029      (ECMINET + 29)    /*cm_inet.c : 4216*/
585 #define ECMINET030      (ECMINET + 30)    /*cm_inet.c : 4227*/
586 #define ECMINET031      (ECMINET + 31)    /*cm_inet.c : 4240*/
587 #define ECMINET032      (ECMINET + 32)    /*cm_inet.c : 4343*/
588 #define ECMINET033      (ECMINET + 33)    /*cm_inet.c : 3932*/
589 #define ECMINET034      (ECMINET + 34)    /*cm_inet.c : 4788*/
590 #define ECMINET035      (ECMINET + 35)    /*cm_inet.c : 5071*/
591 #define ECMINET036      (ECMINET + 36)    /*cm_inet.c : 5616*/
592 #define ECMINET037      (ECMINET + 37)    /*cm_inet.c : 5735*/
593 #define ECMINET038      (ECMINET + 38)    /*cm_inet.c : 5806*/
594 #define ECMINET039      (ECMINET + 39)    /*cm_inet.c : 5910*/
595 #define ECMINET040      (ECMINET + 40)    /*cm_inet.c : 6797*/
596 #define ECMINET041      (ECMINET + 41)    /*cm_inet.c : 6842*/
597 #define ECMINET042      (ECMINET + 42)    /*cm_inet.c : 6971*/
598 #define ECMINET043      (ECMINET + 43)    /*cm_inet.c : 7090*/
599 #define ECMINET044      (ECMINET + 44)    /*cm_inet.c : 7166*/
600 #define ECMINET045      (ECMINET + 45)    /*cm_inet.c : 7175*/
601 #define ECMINET046      (ECMINET + 46)    /*cm_inet.c : 7201*/
602 #define ECMINET047      (ECMINET + 47)    /*cm_inet.c : 7218*/
603 #define ECMINET048      (ECMINET + 48)    /*cm_inet.c : 7322*/
604 #define ECMINET049      (ECMINET + 49)    /*cm_inet.c : 7347*/
605 #define ECMINET050      (ECMINET + 50)    /*cm_inet.c : 7371*/
606 #define ECMINET051      (ECMINET + 51)    /*cm_inet.c : 7810*/
607 #define ECMINET052      (ECMINET + 52)    /*cm_inet.c : 8416*/
608 #define ECMINET053      (ECMINET + 53)    /*cm_inet.c : 8422*/
609 #define ECMINET054      (ECMINET + 54)    /*cm_inet.c : 8610*/
610 #define ECMINET055      (ECMINET + 55)    /*cm_inet.c : 8703*/
611 #define ECMINET056      (ECMINET + 56)    /*cm_inet.c : 8768*/
612 #define ECMINET057      (ECMINET + 57)    /*cm_inet.c : 1104*/
613 #define ECMINET058      (ECMINET + 58)    /*cm_inet.c : 1125*/
614 #define ECMINET059      (ECMINET + 59)    /*cm_inet.c : 1209*/
615 #define ECMINET060      (ECMINET + 60)    /*cm_inet.c : 1313*/
616 #define ECMINET061      (ECMINET + 61)    /*cm_inet.c : 1355*/
617 #define ECMINET062      (ECMINET + 62)    /*cm_inet.c : 1444*/
618 #define ECMINET063      (ECMINET + 63)    /*cm_inet.c : 1534*/
619 #define ECMINET064      (ECMINET + 64)    /*cm_inet.c : 1803*/
620 #define ECMINET065      (ECMINET + 65)    /*cm_inet.c : 1967*/
621 #define ECMINET066      (ECMINET + 66)    /*cm_inet.c : 2627*/
622 #define ECMINET067      (ECMINET + 67)    /*cm_inet.c : 2757*/
623 #define ECMINET068      (ECMINET + 68)    /*cm_inet.c : 4845*/
624 #define ECMINET069      (ECMINET + 69)    /*cm_inet.c : 5385*/
625 /* cm_inet_h_001.main_28: Added new error code ECMINET070 */
626 #define ECMINET070      (ECMINET + 70)    /*cm_inet.c : 5385*/
627 /* cm_inet_h_001.main_29: Added new error code ECMINET070 */
628 #define ECMINET071      (ECMINET + 71)    /*cm_inet.c : xxxx*/
629 #define ECMINETXXX       ECMINET          /*cm_inet.c : xxxx*/
630
631
632 #endif /* __CMINETH__ */
633 /**********************************************************************
634          End of file
635 **********************************************************************/