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
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
114 CmInetIpAddr dstIp; /* destination IP */
115 uint16_t dstPort; /* Remote port that sends data */
116 EgtpTptSrvr sendTptSrvr; /* Transport server for sending UDP msg to */
117 uint32_t numTunn; /* Number of tunnels */
118 CmHashListCp teIdLst; /* Tunnel Id list for this destination */
121 typedef struct egtpGlobalCb
123 EgtpParams egtpCfg; /* EGTP configuration */
124 EgtpTptSrvr recvTptSrvr; /* Transport server for receiving UDP msg */
125 EgtpDstCb dstCb; /* Destination endpoint */
127 EgtpGlobalCb egtpCb; /* EGTP global control block */
131 S16 cuEgtpSrvOpenReq();
132 S16 cuEgtpTnlMgmtReq(EgtpTnlEvt tnlEvt);
133 S16 cuEgtpTnlAdd(EgtpTnlEvt tnlEvt);
134 S16 cuEgtpTnlMod(EgtpTnlEvt tnlEvt);
135 S16 cuEgtpTnlDel(EgtpTnlEvt tnlEvt);
136 S16 cuEgtpEncodeHdr(uint8_t *preEncodedHdr, EgtpMsgHdr *preDefHdr, uint8_t *hdrIdx);
137 S16 cuEgtpHdlRecvMsg(Buffer *mBuf);
139 S16 BuildAppMsg(EgtpMsg *egtpMsg);
140 S16 BuildEgtpMsg(EgtpMsg *egtpMsg);
141 S16 cuEgtpSendMsg(Buffer *mBuf);
142 S16 cuEgtpDecodeHdr(Buffer *mBuf);