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_RECVR_PORT 2152 /* As per the spec 29.281, the registered port number for GTP-U is 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 uint8_t unpackEgtpSrvOpenReq(EgtpSrvOpenReq func, Pst *pst, Buffer *mBuf);
43 typedef struct egtpTptSrvr
46 CmInetFd sockFd; /* Socket file descriptor */
49 typedef struct EgtpTeIdCb
51 uint32_t teId; /* Local tunnel id */
52 uint32_t remTeId; /* Remote tunnel id */
55 uint8_t 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 uint16_t dstPort; /* destination port that sends data */
64 EgtpTptSrvr sendTptSrvr; /* Transport server for sending UDP msg to */
65 uint32_t 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 */
76 EgtpGlobalCb egtpCb; /* EGTP global control block */
78 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg);
79 uint8_t egtpActvInit(Ent entity, Inst inst, Region region, Reason reason);
80 uint8_t egtpActvTsk(Pst *pst, Buffer *mBuf);
81 uint8_t egtpFillRspPst(Pst *pst, Pst *rspPst);
82 uint8_t egtpCfgReq(Pst *pst, EgtpConfig egtpCfg);
83 uint8_t egtpSrvOpenReq(Pst *pst);
84 uint8_t egtpSrvOpenPrc(uint8_t sockType, EgtpTptSrvr *server);
85 uint8_t egtpTnlMgmtReq(Pst *pst, EgtpTnlEvt tnlEvt);
86 uint8_t egtpTnlAdd(EgtpTnlEvt tnlEvt);
87 uint8_t egtpTnlMod(EgtpTnlEvt tnlEvt);
88 uint8_t egtpTnlDel(EgtpTnlEvt tnlEvt);
89 uint8_t egtpHdlDatInd(EgtpMsg msg);
90 uint8_t egtpEncodeHdr(uint8_t *preEncodedHdr, EgtpMsgHdr *preDefHdr, uint8_t *hdrIdx);
91 uint8_t egtpSendMsg(Buffer *mBuf);
92 uint8_t egtpSlotInd();
93 uint8_t egtpRecvMsg();
94 uint8_t egtpHdlRecvData(Buffer *mBuf);
95 uint8_t egtpDecodeHdr(Buffer *mBuf, EgtpMsg *egtpMsg);