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__
24 #define EGTP_RECVR_PORT 2152 /* As per the spec 29.281, the registered port number for GTP-U is 2152 */
25 #define EGTP_TNL_MGMT_ADD 1
26 #define EGTP_TNL_MGMT_MOD 2
27 #define EGTP_TNL_MGMT_DEL 3
29 #define EGTP_MAX_HDR_LEN 40
31 #define EGTP_EXT_HDR_UDP_TYPE 64
32 #define EGTP_EXT_HDR_PDCP_TYPE 192
34 #define EGTP_MASK_BIT1 0x01
35 #define EGTP_MASK_BIT2 0x02
36 #define EGTP_MASK_BIT3 0x04
37 #define EGTP_MASK_BIT4 0x08
38 #define EGTP_MASK_BIT5 0x10
39 #define EGTP_MASK_BIT6 0x20
40 #define EGTP_MASK_BIT7 0x40
41 #define EGTP_MASK_BIT8 0x80
44 #define MIN_TEID 1 /*[Spec 29.281,Sec 5.1]: All Zero TEIDs are never assigned for setting up GTP-U Tunnel*/
45 #define MAX_TEID MAX_NUM_DRB * MAX_NUM_UE /*[Spec 29.281]: Max limit is not mentioned but as per GTP-U Header Format, TEID occupies 4 octets */
47 #define NUM_TUNNEL_TO_PUMP_DATA 4
48 #define NUM_DL_PACKETS 1
53 typedef enum egtpMsgType
58 EGTPU_MSG_ERROR_IND = 26,
59 EGTPU_MSG_SUPP_EXT_HDR_NTF = 31,
60 EGTPU_MSG_END_MARKER = 254,
66 typedef struct egtpExtHdr
68 TknUInt16 udpPort; /**< UDP Port */
69 TknUInt16 pdcpNmb; /**< PDCP Number */
72 /*Structure for MsgHdr */
73 typedef struct egtpMsgHdr
75 TknUInt8 nPdu; /**< N-PDU Number */
76 TknUInt32 seqNum; /**< Sequence Number */
77 EgtpExtHdr extHdr; /**< Extension headers present flag */
78 uint32_t teId; /**< Tunnel Endpoint Id */
79 uint8_t msgType; /**< eGTP-U Message Type */
82 typedef struct egtpMsg
88 typedef struct egtpTnlEvt
95 typedef struct egtpTptSrvr
98 CmInetFd sockFd; /* Socket file descriptor */
101 typedef struct EgtpTeIdCb
103 uint32_t teId; /* Local tunnel id */
104 uint32_t remTeId; /* Remote tunnel id */
107 uint8_t hdr[EGTP_MAX_HDR_LEN];
109 }preEncodedHdr; /* Pre-encoded header for PDUs on this tunnel */
112 typedef struct egtpDstCb
115 CmInetIpAddr dstIp; /* destination IP */
116 uint16_t dstPort; /* Remote port that sends data */
117 EgtpTptSrvr sendTptSrvr; /* Transport server for sending UDP msg to */
118 uint32_t numTunn; /* Number of tunnels */
119 CmHashListCp teIdLst; /* Tunnel Id list for this destination */
122 typedef struct egtpAssoc
130 typedef struct cuEgtpParams
132 uint32_t currTunnelId;
133 uint32_t minTunnelId;
134 uint32_t maxTunnelId;
136 EgtpAssoc egtpAssoc[MAX_DU_SUPPORTED];
139 typedef struct egtpGlobalCb
141 CuEgtpParams egtpCfg; /* EGTP configuration */
142 EgtpTptSrvr recvTptSrvr; /* Transport server for receiving UDP msg */
144 EgtpDstCb dstCb[MAX_DU_SUPPORTED]; /* Destination endpoint */
145 uint8_t gCntPdu[MAX_TEID+1]; /* Maintaining PDU count for each bearer */
147 EgtpGlobalCb egtpCb; /* EGTP global control block */
151 S16 cuEgtpSrvOpenReq();
152 S16 cuEgtpTnlMgmtReq(uint32_t duId,EgtpTnlEvt tnlEvt);
153 S16 cuEgtpTnlAdd(uint32_t duId, EgtpTnlEvt tnlEvt);
154 S16 cuEgtpTnlMod(uint32_t duId,EgtpTnlEvt tnlEvt);
155 S16 cuEgtpTnlDel(uint32_t duId,EgtpTnlEvt tnlEvt);
156 S16 cuEgtpEncodeHdr(uint8_t *preEncodedHdr, EgtpMsgHdr *preDefHdr, uint8_t *hdrIdx);
157 S16 cuEgtpHdlRecvMsg(Buffer *mBuf);
158 uint16_t cuEgtpDatReq(uint32_t duId, uint8_t teId);
159 S16 BuildAppMsg(uint32_t duId, EgtpMsg *egtpMsg);
160 S16 BuildEgtpMsg(uint32_t duId, EgtpMsg *egtpMsg);
161 S16 cuEgtpSendMsg(uint32_t duId, Buffer *mBuf);
162 S16 cuEgtpDecodeHdr(Buffer *mBuf);