2f158e25b494e6435bcf9c173e31aee7ec2d5f52
[o-du/l2.git] / src / du_app / du_egtp.h
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18  
19 /* This file contains all SCTP related functionality */
20  
21 #ifndef __DU_EGTP_H__
22 #define __DU_EGTP_H__
23
24 #define EGTP_DFLT_PORT 2152
25 #define EGTP_MAX_HDR_LEN 40
26 #define EGTP_MAX_MSG_RECV 10
27
28 #define EGTP_EXT_HDR_UDP_TYPE 64
29 #define EGTP_EXT_HDR_PDCP_TYPE 192
30
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
39
40 uint8_t unpackEgtpSrvOpenReq(EgtpSrvOpenReq func, Pst *pst, Buffer *mBuf);
41 uint8_t         protType;
42
43 typedef struct egtpTptSrvr
44 {
45    CmInetAddr  addr; 
46    CmInetFd    sockFd;     /* Socket file descriptor */
47 }EgtpTptSrvr;
48
49 typedef struct EgtpTeIdCb
50 {
51    uint32_t teId;              /* Local tunnel id */
52    uint32_t remTeId;           /* Remote tunnel id */
53    struct
54    {
55       uint8_t hdr[EGTP_MAX_HDR_LEN];
56       uint8_t cnt;
57    }preEncodedHdr;        /* Pre-encoded header for PDUs on this tunnel */
58 }EgtpTeIdCb;
59
60 typedef struct egtpDstCb
61 {
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 */
67 }EgtpDstCb;
68
69 typedef struct egtpGlobalCb
70 {
71    EgtpConfig   egtpCfg;         /* EGTP configuration */
72    EgtpTptSrvr  recvTptSrvr;     /* Transport server for receiving UDP msg */
73    EgtpDstCb    dstCb;           /* Destination endpoint */
74 }EgtpGlobalCb;
75
76 EgtpGlobalCb egtpCb;   /* EGTP global control block */
77
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);
96
97 #endif