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