1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /********************************************************************20**
21 Name: Common transport file
25 Desc: Common file for transport related data structures
29 *********************************************************************21*/
47 #endif /* _cplusplus */
49 #ifdef __CMINETX__ /* Put cm_inet dependencies here */
51 typedef CmInetIpv4Addr CmIpv4TptAddr;
52 typedef CmInetIpAddr CmIpv4NetAddr;
54 #ifndef IPV6_SUPPORTED
55 typedef uint8_t CmInetIpAddr6[16]; /* 16 byte IPV6 address */
58 typedef struct cmInetIpv6Addr
61 CmInetIpAddr6 ipv6NetAddr;
63 #endif /* IPV6_SUPPORTED */
65 /* IPV6 Network address */
66 typedef CmInetIpv6Addr CmIpv6TptAddr;
67 typedef CmInetIpAddr6 CmIpv6NetAddr;
69 #endif /* __CMINETX__ */
72 typedef struct cmNetAddr
74 uint8_t type; /* type of network address */
77 CmIpv4NetAddr ipv4NetAddr; /* IP network address */
78 CmIpv6NetAddr ipv6NetAddr; /* IPv6 network address */
82 /* list of addresses */
83 typedef struct _cmNetAddrTbl
85 uint16_t count; /* Number of Table Entries */
86 CmNetAddr netAddr[CM_MAX_NET_ADDR]; /* IPV4/IPV6 addresses */
89 /* Added new structure for Local Interface */
91 /* used to pass local interface (on which packet was received) to upper user */
92 typedef struct cmTptLocalInf
94 Bool intfPrsnt; /* valid intf is present or not */
95 uint32_t localIf; /* interface index IPv4(32 bit) or IPv6(32 bit) */
96 CmNetAddr localIfAddr; /* interface address */
98 #endif /* LOCAL_INTF */
101 /* Multicast information */
102 typedef struct cmNetMCastInf
104 CmNetAddr mCastAddr; /* Multicast adddress */
105 CmNetAddr localAddr; /* Local address */
108 #ifdef IPV6_SUPPORTED
109 typedef CmInetMCastInf6 CmNetMCastInf6;
110 #endif /* IPV6_SUPPORTED */
111 #endif /* CM_INET2 */
113 /* Transport address */
114 typedef struct cmTptAddr
116 uint8_t type; /* type of transport address */
119 CmIpv4TptAddr ipv4TptAddr; /* IP transport address */
120 CmIpv6TptAddr ipv6TptAddr; /* IPv6 transport address */
122 AtmVccId aalTptAddr; /* AAL transport address */
127 /*cm_tpt_x_001.main_12 Updated for TUCL 2.1 Release (Kernel SCTP Support) */
129 /* Array of Transport Addresses */
130 typedef struct cmTptAddrLst
132 uint8_t nmb; /* Number of Network Addresses */
133 CmTptAddr tptAddr[CM_MAX_NET_ADDR]; /* List of Network Addresses */
136 typedef CmInetSockLinger CmSockLinger;
137 typedef CmInetSctpSockEvent CmSctpEvent;
138 typedef CmInetSctpPeerAddrParams CmSctpPeerAddrParams;
139 typedef CmInetSctpPrimAddr CmSctpPrimAddr;
140 typedef CmInetSctpPeerAddrInfo CmSctpPeerAddrInfo;
141 typedef CmInetSctpStatus CmSctpStatus;
142 typedef CmInetSctpRtoInfo CmSctpRtoInfo;
143 typedef CmInetSctpInitMsg CmSctpInitMsg;
144 typedef CmInetSctpAssocParams CmSctpAssocParams;
148 typedef struct cmSockOpts
150 uint32_t level; /* option level */
151 uint32_t option; /* option name */
152 union /* option parameters */
155 #ifdef IPV6_SUPPORTED
156 CmNetMCastInf6 mCastInfo6; /* IPV6 multicast information */
157 uint32_t infId; /* IPV6 multicast outgoing interface */
158 #endif /* IPV6_SUPPORTED */
159 CmNetMCastInf mCastInfo; /* multicast information */
161 CmNetAddr mCastAddr; /* multicast information */
162 #endif /* CM_INET2 */
163 CmNetAddr lclAddr; /* local outgoing interface */
164 uint32_t value; /* option value */
165 /*cm_tpt_x_001.main_12 Updated for TUCL 2.1 Release (Kernel SCTP Support) */
167 CmSockLinger sockLinger;
168 CmSctpEvent sctpEvent;
169 CmSctpPeerAddrParams sctpPeerAddrParams;
170 CmSctpPrimAddr sctpPrimAddr;
171 CmSctpPeerAddrInfo sctpPeerAddrInfo;
172 CmSctpStatus sctpStatus;
173 /*cm_tpt_x_001.main_13 Updated for the support of configurable RTO parameters,
174 HBeat value Max retransmissions (Init, Path, Association)*/
175 CmSctpRtoInfo sctpRtoInfo;
176 CmSctpInitMsg sctpInitMsg;
177 CmSctpAssocParams sctpPeerAssocParams;
182 /* socket parameters */
183 typedef struct cmSockParam
185 uint8_t listenQSize; /* listen queue size */
186 uint8_t numOpts; /* number of socket options */
187 CmSockOpts sockOpts[CM_MAX_SOCK_OPTS]; /* socket options */
191 typedef struct tlsTptParam
196 CmSockOpts sockOpts[CM_MAX_SOCK_OPTS];
201 /*cm_tpt_x_001.main_12 Updated for TUCL 2.1 Release (Kernel SCTP Support) */
203 typedef struct sctpSockParam
205 uint8_t numOpts; /* number of socket options */
206 CmSockOpts sockOpts[CM_MAX_SOCK_OPTS]; /* socket options */
210 /* Transport parameters */
211 typedef struct cmTptParam
213 uint8_t type; /* type of transport parameters */
217 CmSockParam sockParam; /* socket parameters */
219 AalConParam aalParam; /* AAL connection parameters */
222 TlsTptParam tlsParam; /* TLS parameters */
224 /*cm_tpt_x_001.main_12 Updated for TUCL 2.1 Release (Kernel SCTP Support) */
226 SctpSockParam sctpParam; /* LKSCTP parameters */
233 /* IPv4 header parameters */
234 typedef struct cmIpv4HdrParm
236 TknUInt8 proto; /* Protocol value */
237 TknUInt8 dfBit; /* Don't fragment flag */
238 TknUInt8 tos; /* Type of Service */
239 TknUInt8 ttl; /* Time to Live */
240 /* added new field */
241 #ifdef IPV4_OPTS_SUPPORTED
242 TknStr64 ipv4HdrOpt; /* IPV4 hdr opt */
243 #endif /* IPV4_OPTS_SUPPORTED */
246 #ifdef IPV6_SUPPORTED
247 /* added new structures for IPv6 ext hdr support */
248 #ifdef IPV6_OPTS_SUPPORTED
249 /* structure to hold TLV of each HBH option */
250 typedef struct cmIpv6HBHHdr
257 /* structure to hold TLV of each Destination option */
258 typedef struct cmIpv6DestOptsHdr
265 /* structure to hold IPV6 addresses of the Route header */
266 typedef struct cmIpv6RtHdr
270 CmIpv6NetAddr *ipv6Addrs;
273 /* array of all HBH options */
274 typedef struct cmIpv6HBHHdrArr
277 CmIpv6HBHHdr *hbhOpts;
280 /* array of all Destination options */
281 typedef struct cmIpv6DestOptsArr
284 CmIpv6DestOptsHdr *destOpts;
287 /* structure having 3 substructures for 3 types of ext headers */
288 typedef struct cmIpv6ExtHdr
291 CmIpv6HBHHdrArr hbhOptsArr;
294 CmIpv6DestOptsArr destOptsArr;
299 #endif /* IPV6_OPTS_SUPPORTED */
301 /* IPV6 header parameters */
302 typedef struct cmIpv6HdrParm
304 TknUInt8 ttl; /* Set the hop limit */
306 /* added new field */
307 CmNetAddr srcAddr6; /* src addr to set on send pkt(IPv6) */
309 /* added new field */
310 #ifdef IPV6_OPTS_SUPPORTED
311 CmIpv6ExtHdr ipv6ExtHdr;
312 #endif /* IPV6_OPTS_SUPPORTED */
314 #endif /* IPV6_SUPPORTED */
316 /* IP header paramters */
317 typedef struct cmIpHdrParm
319 uint8_t type; /* Type of IP header parameters */
322 CmIpv4HdrParm hdrParmIpv4; /* IPv4 header parameters */
323 #ifdef IPV6_SUPPORTED
324 CmIpv6HdrParm hdrParmIpv6; /* IPv6 header parameters */
325 #endif /* IPV6_SUPPORTED */
331 typedef struct cmIpv4Hdr
333 uint8_t hdrVer; /* Header and Version */
334 uint8_t tos; /* Type Of Service */
335 S16 length; /* Total length */
336 uint16_t id; /* Identification */
337 S16 off; /* Flags and Offset */
338 uint8_t ttl; /* Time to Live */
339 uint8_t proto; /* Protocol */
340 uint16_t chkSum; /* Checksum */
341 uint32_t srcAddr; /* Source Address */
342 uint32_t destAddr; /* Destination Address */
346 #ifdef IPV6_SUPPORTED
348 typedef struct cmIpv6Hdr
354 uint32_t ip6_un1_flow;
355 uint16_t ip6_un1_plen;
357 uint8_t ip6_un1_hlim;
361 CmIpv6NetAddr ip6_src;
362 CmIpv6NetAddr ip6_dst;
364 #endif /* IPV6_SUPPORTED */
366 typedef struct cmIcmpError
368 uint8_t errType; /* ICMP Error Type */
369 uint32_t errCodeMask; /* ICMP Error Code Mask */
373 /* ICMP v4 filter parameters */
374 typedef struct cmIcmpv4Filter
376 uint8_t icmpMsgFlag; /* Flag to listen to any ICMP msgs */
377 uint8_t allMsg; /* Flag to listen to ICMP messages */
378 uint8_t protocol; /* ICMP packets with protocol only */
379 uint8_t num; /* Number of valid type - code
380 * combinations in the error array */
381 CmIcmpError icmpError[CM_MAX_ICMP_ERROR]; /* Error type & Code array */
385 #ifdef IPV6_SUPPORTED
386 typedef struct cmIcmpv6Filter
388 uint8_t icmpMsgFlag; /* Flag to listen to any ICMP msgs */
389 uint8_t allMsg; /* Flag to listen to all ICMP messages */
390 uint8_t num; /* Number of valid type - code
391 * combinations in the error array */
392 CmIcmpError icmpError[CM_MAX_ICMP_ERROR]; /* Error type & Code array */
395 #endif /* IPV6_SUPPORTED */
397 /* ICMP filter paramters */
398 typedef struct cmIcmpFilter
400 uint8_t type; /* ICMP version */
403 CmIcmpv4Filter icmpv4Filter; /* ICMPv4 filter structure */
404 #ifdef IPV6_SUPPORTED
405 CmIcmpv6Filter icmpv6Filter; /* ICMPv6 filter structure */
406 #endif /* IPV6_SUPPORTED */
412 typedef struct cmIcmpv4Hdr
414 uint8_t icmpType; /* Type of message */
415 uint8_t icmpCode; /* Message code */
416 uint16_t chkSum; /* Ones complement cksum of struct */
420 uint8_t ihPptr; /* ICMP parameter problem */
421 uint32_t rdrctAddr; /* ICMP redirect address */
424 S16 icdId; /* Identifier */
425 S16 icdSeq; /* Sequence Number */
434 uint32_t itOtime; /* Original time stamp */
435 uint32_t itRtime; /* Received time stamp */
436 uint32_t itTtime; /* Transmit time stamp */
438 CmIpv4Hdr icmpIpHdr; /* IP header */
444 #ifdef IPV6_SUPPORTED
445 typedef struct cmIcmpv6Hdr
447 uint8_t icmp6_type; /* type field */
448 uint8_t icmp6_code; /* code field */
449 uint16_t icmp6_cksum; /* checksum field */
453 uint32_t icmp6_un_data32[1]; /* type-specific field */
454 uint16_t icmp6_un_data16[2]; /* type-specific field */
455 uint8_t icmp6_un_data8[4]; /* type-specific field */
458 #endif /* IPV6_SUPPORTED */
460 #endif /* CM_INET2 */
462 /* packing/unpacking function prototypes */
463 /* Added packing and unpacking function prototypes */
464 S16 cmPkCmIpv4TptAddr ARGS((CmIpv4TptAddr *pkParam, Buffer *mBuf));
465 S16 cmPkCmNetAddrTbl ARGS((CmNetAddrTbl *pkParam, Buffer *mBuf));
466 S16 cmPkCmNetAddr ARGS((CmNetAddr *pkParam, Buffer *mBuf));
467 S16 cmPkCmTptAddr ARGS((CmTptAddr *pkParam, Buffer *mBuf));
468 #ifdef IPV6_SUPPORTED
469 S16 cmPkCmNetMCastInf6 ARGS((CmNetMCastInf6 *pkParam, Buffer *mBuf));
470 #endif /* IPV6_SUPPORTED */
471 S16 cmPkCmTptParam ARGS((CmTptParam *pkParam, Buffer *mBuf));
472 S16 cmUnpkCmNetAddrTbl ARGS((CmNetAddrTbl *unpkParam, Buffer *mBuf));
473 S16 cmUnpkCmIpv4TptAddr ARGS((CmIpv4TptAddr *unpkParam, Buffer *mBuf));
474 S16 cmUnpkCmNetAddr ARGS((CmNetAddr *unpkParam, Buffer *mBuf));
475 S16 cmUnpkCmTptAddr ARGS((CmTptAddr *unpkParam, Buffer *mBuf));
476 #ifdef IPV6_SUPPORTED
477 S16 cmUnpkCmNetMCastInf6 ARGS((CmNetMCastInf6 *unpkParam, Buffer *mBuf));
478 #endif /* IPV6_SUPPORTED */
480 S16 cmUnpkCmTptParam ARGS((CmTptParam *unpkParam, Buffer *mBuf));
483 S16 cmPkCmIpHdrParm ARGS((CmIpHdrParm *pkParam, Buffer *mBuf));
485 /* changed to include meminfo required to hold IPv6
487 #ifdef IPV6_OPTS_SUPPORTED
488 S16 cmUnpkCmIpHdrParm ARGS((CmIpHdrParm *unpkParam, Buffer *mBuf,
491 S16 cmUnpkCmIpHdrParm ARGS((CmIpHdrParm *unpkParam, Buffer *mBuf));
494 /* added new packing/unpacking function */
496 S16 cmPkCmTptLocalInf ARGS((CmTptLocalInf *pkParam, Buffer *mBuf));
497 S16 cmUnpkCmTptLocalInf ARGS((CmTptLocalInf *unpkParam, Buffer *mBuf));
498 #endif /* LOCAL_INTF */
500 S16 cmPkCmIcmpFilter ARGS((CmIcmpFilter *pkParam, Buffer *mBuf));
501 S16 cmUnpkCmIcmpFilter ARGS((CmIcmpFilter *unpkParam, Buffer *mBuf));
503 /* added new packing/unpacking functions */
504 #ifdef IPV6_OPTS_SUPPORTED
505 S16 cmPkCmIpv6ExtHdr ARGS((CmIpv6ExtHdr *pkParam, Buffer *mBuf));
506 S16 cmPkCmIpv6RtHdr ARGS((CmIpv6RtHdr *pkParam, Buffer *mBuf));
507 S16 cmUnpkCmIpv6RtHdr ARGS((CmIpv6RtHdr *unpkParam, Buffer *mBuf,
509 S16 cmUnpkCmIpv6ExtHdr ARGS((CmIpv6ExtHdr *unpkParam, Buffer *mBuf,
511 S16 cmPkCmIpv6DestOptsArr ARGS((CmIpv6DestOptsArr *pkParam,
513 S16 cmPkCmIpv6DestOptsHdr ARGS((CmIpv6DestOptsHdr *pkParam,
515 S16 cmUnpkCmIpv6DestOptsHdr ARGS((CmIpv6DestOptsHdr *unpkParam,
516 Buffer *mBuf, Mem *memInfo));
517 S16 cmUnpkCmIpv6DestOptsArr ARGS((CmIpv6DestOptsArr *unpkParam,
518 Buffer *mBuf, Mem *memInfo));
519 S16 cmPkCmIpv6HBHHdrArr ARGS((CmIpv6HBHHdrArr *pkParam, Buffer *mBuf));
520 S16 cmPkCmIpv6HBHHdr ARGS((CmIpv6HBHHdr *pkParam, Buffer *mBuf));
521 S16 cmUnpkCmIpv6HBHHdr ARGS((CmIpv6HBHHdr *unpkParam, Buffer *mBuf,
523 S16 cmUnpkCmIpv6HBHHdrArr ARGS((CmIpv6HBHHdrArr *unpkParam,
524 Buffer *mBuf, Mem *memInfo));
525 #endif /* IPV6_OPTS_SUPPORTED */
526 #endif /* CM_INET2 */
532 #endif /* __CMTPTX__ */
534 /********************************************************************30**
536 *********************************************************************31*/