Adding new commiter to ODU-High repo
[o-du/l2.git] / src / cm / cm_tpt.x
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 \f
19 /********************************************************************20**
20   
21      Name:     Common transport file
22   
23      Type:     C include file
24   
25      Desc:     Common file for transport related data structures
26   
27      File:     cm_tpt.x
28   
29 *********************************************************************21*/
30  
31 #ifdef SS_4GMX_LCORE
32 #define __CMTPTX__ 1
33 #endif
34
35 #ifndef __CMTPTX__
36 #define __CMTPTX__
37
38
39 #include "cm_inet.x"
40
41 #ifdef CM_AAL
42 #include "cm_atm.x"
43 #endif
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif /* _cplusplus */
48
49 #ifdef __CMINETX__  /* Put cm_inet dependencies here */
50
51 typedef CmInetIpv4Addr  CmIpv4TptAddr;
52 typedef CmInetIpAddr    CmIpv4NetAddr;
53
54 #ifndef IPV6_SUPPORTED
55 typedef uint8_t  CmInetIpAddr6[16];   /* 16 byte IPV6 address */
56
57 /* IPV6 Address */
58 typedef struct cmInetIpv6Addr
59 {
60    uint16_t             port;
61    CmInetIpAddr6   ipv6NetAddr;
62 } CmInetIpv6Addr;
63 #endif /* IPV6_SUPPORTED */
64
65 /* IPV6 Network address */
66 typedef CmInetIpv6Addr  CmIpv6TptAddr;
67 typedef CmInetIpAddr6   CmIpv6NetAddr;
68
69 #endif /* __CMINETX__ */
70
71 /* Network address */
72 typedef struct cmNetAddr
73 {
74    uint8_t   type;      /* type of network address */
75    union
76    {
77       CmIpv4NetAddr  ipv4NetAddr; /* IP network address */
78       CmIpv6NetAddr  ipv6NetAddr; /* IPv6 network address */
79    }u;
80 } CmNetAddr;
81
82 /* list of addresses */
83 typedef struct _cmNetAddrTbl
84 {
85    uint16_t             count;              /* Number of Table Entries */
86    CmNetAddr       netAddr[CM_MAX_NET_ADDR]; /* IPV4/IPV6 addresses */
87 }CmNetAddrTbl;
88
89 /* Added new structure for Local Interface */
90 #ifdef LOCAL_INTF
91 /* used to pass local interface (on which packet was received) to upper user */
92 typedef struct cmTptLocalInf
93 {
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 */
97 }CmTptLocalInf;
98 #endif /* LOCAL_INTF */
99
100 #ifdef CM_INET2
101 /* Multicast information */
102 typedef struct cmNetMCastInf
103 {
104    CmNetAddr         mCastAddr;   /* Multicast adddress */
105    CmNetAddr         localAddr;   /* Local address */
106 } CmNetMCastInf;
107
108 #ifdef IPV6_SUPPORTED 
109 typedef CmInetMCastInf6 CmNetMCastInf6;
110 #endif /* IPV6_SUPPORTED */
111 #endif /* CM_INET2 */
112
113 /* Transport address */
114 typedef struct cmTptAddr
115 {
116    uint8_t   type;                     /* type of transport address */
117    union
118    {
119       CmIpv4TptAddr  ipv4TptAddr; /* IP transport address */
120       CmIpv6TptAddr  ipv6TptAddr; /* IPv6 transport address */
121 #ifdef CM_AAL
122       AtmVccId       aalTptAddr;  /* AAL transport address */
123 #endif
124    }u;
125 } CmTptAddr;
126  
127 /*cm_tpt_x_001.main_12 Updated for TUCL 2.1 Release (Kernel SCTP Support) */
128 #ifdef CM_LKSCTP
129 /* Array of Transport Addresses */
130 typedef struct cmTptAddrLst 
131 {
132    uint8_t            nmb;                        /* Number of Network Addresses */
133    CmTptAddr     tptAddr[CM_MAX_NET_ADDR];   /* List of Network Addresses */
134 } CmTptAddrLst;
135
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;
145 #endif
146
147 /* Socket Options */
148 typedef struct cmSockOpts
149 {
150    uint32_t  level;                    /* option level */
151    uint32_t  option;                   /* option name */
152    union                          /* option parameters */
153    {
154 #ifdef CM_INET2
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 */
160 #else
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) */
166 #ifdef CM_LKSCTP
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;
178 #endif
179    }optVal;
180 }CmSockOpts;
181
182 /* socket parameters */
183 typedef struct cmSockParam
184 {
185    uint8_t             listenQSize;    /* listen queue size */
186    uint8_t             numOpts;        /* number of socket options */
187    CmSockOpts sockOpts[CM_MAX_SOCK_OPTS]; /* socket options */
188 } CmSockParam;
189
190 #ifdef CM_TLS
191 typedef struct tlsTptParam
192 {
193    S16          ctxId;
194    uint8_t           listenQSize;
195    uint8_t           numOpts;
196    CmSockOpts   sockOpts[CM_MAX_SOCK_OPTS];
197
198 } TlsTptParam;
199 #endif /* CM_TLS */
200
201 /*cm_tpt_x_001.main_12 Updated for TUCL 2.1 Release (Kernel SCTP Support) */
202 #ifdef CM_LKSCTP
203 typedef struct sctpSockParam
204 {
205    uint8_t           numOpts;        /* number of socket options */
206    CmSockOpts   sockOpts[CM_MAX_SOCK_OPTS]; /* socket options */
207 } SctpSockParam;
208 #endif
209
210 /* Transport parameters */
211 typedef struct cmTptParam
212 {
213    uint8_t   type;                      /* type of transport parameters */
214
215    union
216    {
217       CmSockParam  sockParam;      /* socket parameters */
218 #ifdef CM_AAL
219       AalConParam  aalParam;       /* AAL connection parameters */
220 #endif
221 #ifdef CM_TLS
222       TlsTptParam  tlsParam;       /* TLS parameters */
223 #endif
224 /*cm_tpt_x_001.main_12 Updated for TUCL 2.1 Release (Kernel SCTP Support) */
225 #ifdef CM_LKSCTP
226       SctpSockParam  sctpParam;    /* LKSCTP parameters */
227 #endif
228    } u;
229
230 } CmTptParam;
231
232 #ifdef CM_INET2  
233 /* IPv4 header parameters */
234 typedef struct cmIpv4HdrParm 
235 {
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 */
244 } CmIpv4HdrParm;
245
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
251 {
252    uint8_t type;
253    uint8_t length;
254    uint8_t *value;
255 } CmIpv6HBHHdr;
256
257 /* structure to hold TLV of each Destination option */
258 typedef struct cmIpv6DestOptsHdr
259 {
260    uint8_t type;
261    uint8_t length;
262    uint8_t *value;
263 } CmIpv6DestOptsHdr;
264
265 /* structure to hold IPV6 addresses of the Route header */
266 typedef struct cmIpv6RtHdr
267 {
268    uint8_t numAddrs;               
269    uint32_t slMap;
270    CmIpv6NetAddr *ipv6Addrs;   
271 } CmIpv6RtHdr;
272
273 /* array of all HBH options */
274 typedef struct cmIpv6HBHHdrArr
275 {
276    uint8_t numHBHOpts;
277    CmIpv6HBHHdr *hbhOpts; 
278 } CmIpv6HBHHdrArr;
279
280 /* array of all Destination options */
281 typedef struct cmIpv6DestOptsArr
282 {
283    uint8_t numDestOpts;
284    CmIpv6DestOptsHdr *destOpts;
285 } CmIpv6DestOptsArr;
286
287 /* structure having 3 substructures for 3 types of ext headers */
288 typedef struct cmIpv6ExtHdr
289 {
290    Bool hbhHdrPrsnt;
291    CmIpv6HBHHdrArr hbhOptsArr;
292
293    Bool destOptsPrsnt;
294    CmIpv6DestOptsArr destOptsArr;
295
296    Bool rtOptsPrsnt;
297    CmIpv6RtHdr rtOpts;
298 } CmIpv6ExtHdr;
299 #endif /* IPV6_OPTS_SUPPORTED */
300
301 /* IPV6 header parameters */
302 typedef struct cmIpv6HdrParm
303 {
304    TknUInt8    ttl;                   /* Set the hop limit */
305    
306    /* added new field */
307    CmNetAddr srcAddr6; /* src addr to set on send pkt(IPv6) */
308
309    /* added new field */
310 #ifdef IPV6_OPTS_SUPPORTED 
311    CmIpv6ExtHdr ipv6ExtHdr;      
312 #endif /* IPV6_OPTS_SUPPORTED */  
313 } CmIpv6HdrParm;
314 #endif /* IPV6_SUPPORTED */
315
316 /* IP header paramters */
317 typedef struct cmIpHdrParm 
318
319    uint8_t       type;                  /* Type of IP header parameters */
320    union 
321    {
322       CmIpv4HdrParm  hdrParmIpv4;  /* IPv4 header parameters */
323 #ifdef IPV6_SUPPORTED 
324       CmIpv6HdrParm  hdrParmIpv6;  /* IPv6 header parameters */
325 #endif /* IPV6_SUPPORTED */
326    }u;
327    
328 } CmIpHdrParm;
329
330 /* IPv4 header */
331 typedef struct cmIpv4Hdr 
332 {
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 */
343
344 } CmIpv4Hdr;
345
346 #ifdef IPV6_SUPPORTED 
347 /* IPv6 header */
348 typedef struct cmIpv6Hdr
349 {
350    union
351    {
352       struct ip6_hdrctl
353       {
354          uint32_t      ip6_un1_flow;
355          uint16_t      ip6_un1_plen;
356          uint8_t       ip6_un1_nxt;
357          uint8_t       ip6_un1_hlim;
358       } ip6_un1;
359       uint8_t    ip6_un2_vfc;
360    } ip6_ctlun;
361    CmIpv6NetAddr  ip6_src;
362    CmIpv6NetAddr  ip6_dst;
363 } CmIpv6Hdr;
364 #endif /* IPV6_SUPPORTED */
365
366 typedef struct cmIcmpError 
367 {
368    uint8_t    errType;                  /* ICMP Error Type */
369    uint32_t   errCodeMask;              /* ICMP Error Code Mask */
370
371 } CmIcmpError;
372
373 /* ICMP v4 filter parameters */
374 typedef struct cmIcmpv4Filter
375 {
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 */
382
383 }CmIcmpv4Filter;
384
385 #ifdef IPV6_SUPPORTED
386 typedef struct cmIcmpv6Filter
387 {
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 */
393
394 } CmIcmpv6Filter; 
395 #endif /* IPV6_SUPPORTED */
396
397 /* ICMP filter paramters */
398 typedef struct cmIcmpFilter 
399 {
400   uint8_t type;                        /* ICMP version */
401   union 
402   {
403     CmIcmpv4Filter icmpv4Filter;  /* ICMPv4 filter structure */
404 #ifdef IPV6_SUPPORTED
405     CmIcmpv6Filter icmpv6Filter;  /* ICMPv6 filter structure */
406 #endif /* IPV6_SUPPORTED */
407   }u;
408
409 } CmIcmpFilter; 
410
411 /* ICMP header */
412 typedef struct cmIcmpv4Hdr 
413 {
414    uint8_t    icmpType;                /* Type of message */
415    uint8_t    icmpCode;                /* Message code */
416    uint16_t   chkSum;                  /* Ones complement cksum of struct */
417    
418    union 
419    {
420       uint8_t   ihPptr;                /* ICMP parameter problem */
421       uint32_t  rdrctAddr;             /* ICMP redirect address */
422       struct idSeq 
423       {
424          S16   icdId;             /* Identifier */                          
425          S16   icdSeq;            /* Sequence Number */
426       } u1;
427       uint32_t ihVoid;                 
428    } u2;
429    
430    union 
431    {
432       struct idTime
433       {
434          uint32_t  itOtime;            /* Original time stamp */
435          uint32_t  itRtime;            /* Received time stamp */
436          uint32_t  itTtime;            /* Transmit time stamp */
437       } s;
438       CmIpv4Hdr icmpIpHdr;        /* IP header */
439       uint32_t     id_mask;
440    } u3;
441
442 } CmIcmpv4Hdr;
443
444 #ifdef IPV6_SUPPORTED
445 typedef struct cmIcmpv6Hdr
446 {
447    uint8_t    icmp6_type;              /* type field */
448    uint8_t    icmp6_code;              /* code field */
449    uint16_t   icmp6_cksum;             /* checksum field */
450
451    union
452    {
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 */
456    } icmp6_dataun;
457 } CmIcmpv6Hdr;
458 #endif /* IPV6_SUPPORTED */
459
460 #endif  /* CM_INET2 */ 
461
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 */
479
480 S16 cmUnpkCmTptParam     ARGS((CmTptParam *unpkParam, Buffer *mBuf));
481
482 #ifdef CM_INET2  
483 S16 cmPkCmIpHdrParm     ARGS((CmIpHdrParm *pkParam, Buffer *mBuf));
484
485 /* changed to include meminfo required to hold IPv6 
486                          extension headers */
487 #ifdef IPV6_OPTS_SUPPORTED
488 S16 cmUnpkCmIpHdrParm    ARGS((CmIpHdrParm *unpkParam, Buffer *mBuf, 
489                                      Mem *memInfo));
490 #else
491 S16 cmUnpkCmIpHdrParm    ARGS((CmIpHdrParm *unpkParam, Buffer *mBuf));
492 #endif
493
494 /* added new packing/unpacking function */
495 #ifdef LOCAL_INTF
496 S16 cmPkCmTptLocalInf    ARGS((CmTptLocalInf *pkParam, Buffer *mBuf));
497 S16 cmUnpkCmTptLocalInf  ARGS((CmTptLocalInf *unpkParam, Buffer *mBuf));
498 #endif /* LOCAL_INTF */
499
500 S16 cmPkCmIcmpFilter     ARGS((CmIcmpFilter *pkParam, Buffer *mBuf));
501 S16 cmUnpkCmIcmpFilter   ARGS((CmIcmpFilter *unpkParam, Buffer *mBuf));
502
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, 
508                                      Mem *memInfo));
509 S16 cmUnpkCmIpv6ExtHdr   ARGS((CmIpv6ExtHdr *unpkParam, Buffer *mBuf, 
510                                      Mem *memInfo));
511 S16 cmPkCmIpv6DestOptsArr ARGS((CmIpv6DestOptsArr *pkParam, 
512                                       Buffer *mBuf));
513 S16 cmPkCmIpv6DestOptsHdr ARGS((CmIpv6DestOptsHdr *pkParam, 
514                                       Buffer *mBuf));
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, 
522                                      Mem *memInfo));
523 S16 cmUnpkCmIpv6HBHHdrArr ARGS((CmIpv6HBHHdrArr *unpkParam, 
524                                       Buffer *mBuf, Mem *memInfo));
525 #endif /* IPV6_OPTS_SUPPORTED */
526 #endif  /* CM_INET2 */ 
527
528 #ifdef __cplusplus
529 }
530 #endif
531
532 #endif /* __CMTPTX__ */
533 \f
534 /********************************************************************30**
535          End of file
536 *********************************************************************31*/