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_TNL_MGMT_ADD 1
25 #define EGTP_TNL_MGMT_MOD 2
26 #define EGTP_TNL_MGMT_DEL 3
28 #define EGTP_MAX_HDR_LEN 40
30 #define EGTP_EXT_HDR_UDP_TYPE 64
31 #define EGTP_EXT_HDR_PDCP_TYPE 192
33 #define EGTP_MASK_BIT1 0x01
34 #define EGTP_MASK_BIT2 0x02
35 #define EGTP_MASK_BIT3 0x04
36 #define EGTP_MASK_BIT4 0x08
37 #define EGTP_MASK_BIT5 0x10
38 #define EGTP_MASK_BIT6 0x20
39 #define EGTP_MASK_BIT7 0x40
40 #define EGTP_MASK_BIT8 0x80
43 #define MIN_TEID 1 /*[Spec 29.281,Sec 5.1]: All Zero TEIDs are never assigned for setting up GTP-U Tunnel*/
44 #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 */
46 #define NUM_TUNNEL_TO_PUMP_DATA 4
47 #define NUM_DL_PACKETS 1
49 extern uint8_t sockType;
50 extern uint8_t protType;
52 typedef enum egtpMsgType
57 EGTPU_MSG_ERROR_IND = 26,
58 EGTPU_MSG_SUPP_EXT_HDR_NTF = 31,
59 EGTPU_MSG_END_MARKER = 254,
65 typedef struct egtpExtHdr
67 TknUInt16 udpPort; /**< UDP Port */
68 TknUInt16 pdcpNmb; /**< PDCP Number */
71 /*Structure for MsgHdr */
72 typedef struct egtpMsgHdr
74 TknUInt8 nPdu; /**< N-PDU Number */
75 TknUInt32 seqNum; /**< Sequence Number */
76 EgtpExtHdr extHdr; /**< Extension headers present flag */
77 uint32_t teId; /**< Tunnel Endpoint Id */
78 uint8_t msgType; /**< eGTP-U Message Type */
81 typedef struct egtpMsg
87 typedef struct egtpTnlEvt
94 typedef struct EgtpTeIdCb
96 uint32_t teId; /* Local tunnel id */
97 uint32_t remTeId; /* Remote tunnel id */
100 uint8_t hdr[EGTP_MAX_HDR_LEN];
102 }preEncodedHdr; /* Pre-encoded header for PDUs on this tunnel */
105 typedef struct egtpDstCb
109 uint32_t numTunn; /* Number of tunnels */
110 CmHashListCp teIdLst; /* Tunnel Id list for this destination */
113 typedef struct egtpDstCfg
119 typedef struct cuEgtpParams
121 uint32_t currTunnelId;
122 uint32_t minTunnelId;
123 uint32_t maxTunnelId;
127 EgtpDstCfg dstCfg[MAX_DU_SUPPORTED];
130 typedef struct egtpGlobalCb
132 CuEgtpParams egtpCfg; /* EGTP configuration */
133 CmInetAddr localAddr;
134 CmInetFd sockFd; /* Socket file descriptor */
136 EgtpDstCb dstCb[MAX_DU_SUPPORTED]; /* Destination endpoint */
137 uint8_t gCntPdu[MAX_TEID+1]; /* Maintaining PDU count for each bearer */
140 extern EgtpGlobalCb egtpCb; /* EGTP global control block */
144 S16 cuEgtpSrvOpenReq();
145 S16 cuEgtpTnlMgmtReq(uint32_t duId,EgtpTnlEvt tnlEvt);
146 S16 cuEgtpTnlAdd(uint32_t duId, EgtpTnlEvt tnlEvt);
147 S16 cuEgtpTnlMod(uint32_t duId,EgtpTnlEvt tnlEvt);
148 S16 cuEgtpTnlDel(uint32_t duId,EgtpTnlEvt tnlEvt);
149 S16 cuEgtpEncodeHdr(uint8_t *preEncodedHdr, EgtpMsgHdr *preDefHdr, uint8_t *hdrIdx);
150 S16 cuEgtpHdlRecvMsg(Buffer *mBuf);
151 uint16_t cuEgtpDatReq(uint32_t duId, uint8_t teId);
152 S16 BuildAppMsg(uint32_t duId, EgtpMsg *egtpMsg);
153 S16 BuildEgtpMsg(uint32_t duId, EgtpMsg *egtpMsg);
154 S16 cuEgtpSendMsg(uint32_t duId, Buffer *mBuf);
155 S16 cuEgtpDecodeHdr(Buffer *mBuf);