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 */
21 #ifndef __CU_STUB_EGTP_H__
22 #define __CU_STUB_EGTP_H__
31 #define EGTP_DFLT_PORT 2152
32 #define EGTP_TNL_MGMT_ADD 1
33 #define EGTP_TNL_MGMT_MOD 2
34 #define EGTP_TNL_MGMT_DEL 3
36 #define EGTP_MAX_HDR_LEN 40
38 #define EGTP_EXT_HDR_UDP_TYPE 64
39 #define EGTP_EXT_HDR_PDCP_TYPE 192
41 #define EGTP_MASK_BIT1 0x01
42 #define EGTP_MASK_BIT2 0x02
43 #define EGTP_MASK_BIT3 0x04
44 #define EGTP_MASK_BIT4 0x08
45 #define EGTP_MASK_BIT5 0x10
46 #define EGTP_MASK_BIT6 0x20
47 #define EGTP_MASK_BIT7 0x40
48 #define EGTP_MASK_BIT8 0x80
50 #define NUM_TUNNEL_TO_PUMP_DATA 3
51 #define NUM_DL_PACKETS 4
56 typedef enum egtpMsgType
61 EGTPU_MSG_ERROR_IND = 26,
62 EGTPU_MSG_SUPP_EXT_HDR_NTF = 31,
63 EGTPU_MSG_END_MARKER = 254,
69 typedef struct egtpExtHdr
71 TknUInt16 udpPort; /**< UDP Port */
72 TknUInt16 pdcpNmb; /**< PDCP Number */
75 /*Structure for MsgHdr */
76 typedef struct egtpMsgHdr
78 TknUInt8 nPdu; /**< N-PDU Number */
79 TknUInt32 seqNum; /**< Sequence Number */
80 EgtpExtHdr extHdr; /**< Extension headers present flag */
81 uint32_t teId; /**< Tunnel Endpoint Id */
82 uint8_t msgType; /**< eGTP-U Message Type */
85 typedef struct egtpMsg
91 typedef struct egtpTnlEvt
98 typedef struct egtpTptSrvr
101 CmInetFd sockFd; /* Socket file descriptor */
104 typedef struct EgtpTeIdCb
106 uint32_t teId; /* Local tunnel id */
107 uint32_t remTeId; /* Remote tunnel id */
110 uint8_t hdr[EGTP_MAX_HDR_LEN];
112 }preEncodedHdr; /* Pre-encoded header for PDUs on this tunnel */
115 typedef struct egtpDstCb
117 CmInetIpAddr dstIp; /* destination IP */
118 uint16_t dstPort; /* Remote port that sends data */
119 EgtpTptSrvr sendTptSrvr; /* Transport server for sending UDP msg to */
120 uint32_t numTunn; /* Number of tunnels */
121 CmHashListCp teIdLst; /* Tunnel Id list for this destination */
124 typedef struct egtpGlobalCb
126 EgtpParams egtpCfg; /* EGTP configuration */
127 EgtpTptSrvr recvTptSrvr; /* Transport server for receiving UDP msg */
128 EgtpDstCb dstCb; /* Destination endpoint */
129 uint8_t gCntPdu[MAX_TEID+1]; /* Maintaining PDU count for each bearer */
131 EgtpGlobalCb egtpCb; /* EGTP global control block */
135 S16 cuEgtpSrvOpenReq();
136 S16 cuEgtpTnlMgmtReq(EgtpTnlEvt tnlEvt);
137 S16 cuEgtpTnlAdd(EgtpTnlEvt tnlEvt);
138 S16 cuEgtpTnlMod(EgtpTnlEvt tnlEvt);
139 S16 cuEgtpTnlDel(EgtpTnlEvt tnlEvt);
140 S16 cuEgtpEncodeHdr(uint8_t *preEncodedHdr, EgtpMsgHdr *preDefHdr, uint8_t *hdrIdx);
141 S16 cuEgtpHdlRecvMsg(Buffer *mBuf);
142 uint16_t cuEgtpDatReq(uint8_t teId);
143 S16 BuildAppMsg(EgtpMsg *egtpMsg);
144 S16 BuildEgtpMsg(EgtpMsg *egtpMsg);
145 S16 cuEgtpSendMsg(Buffer *mBuf);
146 S16 cuEgtpDecodeHdr(Buffer *mBuf);