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 /* This file contains all SCTP related functionality */
33 #define EGTP_DFLT_PORT 2152
34 #define EGTP_MAX_HDR_LEN 40
35 #define EGTP_MAX_MSG_RECV 10
37 #define EGTP_EXT_HDR_UDP_TYPE 64
38 #define EGTP_EXT_HDR_PDCP_TYPE 192
40 #define EGTP_MASK_BIT1 0x01
41 #define EGTP_MASK_BIT2 0x02
42 #define EGTP_MASK_BIT3 0x04
43 #define EGTP_MASK_BIT4 0x08
44 #define EGTP_MASK_BIT5 0x10
45 #define EGTP_MASK_BIT6 0x20
46 #define EGTP_MASK_BIT7 0x40
47 #define EGTP_MASK_BIT8 0x80
52 typedef struct egtpTptSrvr
55 CmInetFd sockFd; /* Socket file descriptor */
58 typedef struct EgtpTeIdCb
60 U32 teId; /* Local tunnel id */
61 U32 remTeId; /* Remote tunnel id */
64 U8 hdr[EGTP_MAX_HDR_LEN];
66 }preEncodedHdr; /* Pre-encoded header for PDUs on this tunnel */
69 typedef struct egtpDstCb
71 CmInetIpAddr dstIp; /* destination IP */
72 U16 dstPort; /* destination port that sends data */
73 EgtpTptSrvr sendTptSrvr; /* Transport server for sending UDP msg to */
74 U32 numTunn; /* Number of tunnels */
75 CmHashListCp teIdLst; /* Tunnel Id list for this destination */
78 typedef struct egtpGlobalCb
80 EgtpConfig egtpCfg; /* EGTP configuration */
81 EgtpTptSrvr recvTptSrvr; /* Transport server for receiving UDP msg */
82 EgtpDstCb dstCb; /* Destination endpoint */
84 extern EgtpGlobalCb egtpCb; /* EGTP global control block */
86 S16 egtpActvInit(Ent entity, Inst inst, Region region, Reason reason);
87 S16 egtpActvTsk(Pst *pst, Buffer *mBuf);
88 S16 egtpFillRspPst(Pst *pst, Pst *rspPst);
89 S16 egtpCfgReq(Pst *pst, EgtpConfig egtpCfg);
90 S16 egtpSrvOpenReq(Pst *pst);
91 S16 egtpSrvOpenPrc(U8 sockType, EgtpTptSrvr *server);
92 S16 egtpTnlMgmtReq(Pst *pst, EgtpTnlEvt tnlEvt);
93 S16 egtpTnlAdd(EgtpTnlEvt tnlEvt);
94 S16 egtpTnlMod(EgtpTnlEvt tnlEvt);
95 S16 egtpTnlDel(EgtpTnlEvt tnlEvt);
96 S16 egtpHdlDatInd(EgtpMsg msg);
97 S16 egtpEncodeHdr(U8 *preEncodedHdr, EgtpMsgHdr *preDefHdr, U8 *hdrIdx);
98 S16 egtpSendMsg(Buffer *mBuf);
101 S16 egtpHdlRecvData(Buffer *mBuf);
102 S16 egtpDecodeHdr(Buffer *mBuf, EgtpMsg *egtpMsg);