E2AP review changes part1
[o-du/l2.git] / src / du_app / du_sctp.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_SCTP_H__
22 #define __DU_SCTP_H__
23
24 #include "du_cfg.h"
25 #include "du_mgr.h"
26 #include "du_log.h"
27 #include "cm_inet.h"
28 #include "cm_tpt.h"
29
30 #include "cm_inet.x"
31 #include "cm_tpt.x"
32
33 #define DU_SCTP_DOWN 0
34 #define DU_SCTP_UP 1
35 #define DU_SCTP_CONNECTING 2
36 #define MAX_RETRY 5
37
38 /* Global variable declaration */
39 U8   socket_type;      /* Socket type */
40 Bool nonblocking;      /* Blocking/Non-blocking socket */
41 Bool connUp;           /* Is connection up */
42 Bool pollingState; 
43 CmInetNetAddrLst localAddrLst;
44 CmInetNetAddrLst remoteAddrLst;
45
46 typedef struct
47 {
48    S16           numFds;            /* Total count number of receivers socket Fd */
49    U16           port;              /* Filled by the InetSctpRecvMsg during polling */              
50    U32           flag;              /* Refers to the notifyHandler Flag during successful InetSctpRecvMsg*/
51    Buffer        *mBuf;             /* Buffer filled during Socket polling*/
52    MsgLen        bufLen;            /* Determines the length of the Buffer filled during socket polling */
53    CmInetNetAddr addr;              /* Determines the destination port filled during socket polling */
54    CmInetFdSet      readFd;         /* Refers to the Read Fd socket */
55    CmInetSctpSndRcvInfo   info;     /* Refers to Send Receivers Info*/
56    CmInetSctpNotification ntfy;     /* Refers to the sctp Notification Message */
57 }sctpSockPollParams;
58
59 typedef struct
60 {
61    U8               itfState;         /* determines the interface State*/
62    U16              destPort;         /* Refers to the destination port of F1/E2 */
63    U16              srcPort;          /* Refers to respective src port of DU */
64    U32              assocId;          
65    Bool             recvMsgSet;
66    F1IpAddr         destIpAddr;       /* Refers to te destination Ip Address */
67    CmInetFd         sockFd;           /* Socket file descriptor */
68    CmInetNetAddrLst destAddrLst;      /* Refers to the destinaiton Addr Lst in CmInetNetAddrLst format */
69    CmInetNetAddr    destIpNetAddr;    /* Refers to the destination Addr in CmInetNet Addr format */
70 }DuSctpDestCb;
71
72 /* Global variable declaration */
73 DuSctpDestCb f1Params;     /* SCTP configurations at DU */ 
74 DuSctpDestCb ricParams;    /* SCTP configurations at DU */ 
75
76
77 S16 sctpActvInit(Ent entity, Inst inst, Region region, Reason reason);
78 S16 sctpActvTsk(Pst *pst, Buffer *mBuf);
79 void sctpAssocReq();
80 void sendToDuApp(Buffer *mBuf, Event event);
81 S16 sctpSend(Buffer *mBuf, U8 itfType);
82 typedef S16 (*SctpNtfy) ARGS((Buffer *mBuf, CmInetSctpNotification *ntfy));
83 S16 duSctpCfgReq(SctpParams sctpCfg);
84 S16 fillAddrLst(CmInetNetAddrLst *addrLstPtr, F1IpAddr *ipAddr);
85 S16 fillDestNetAddr(CmInetNetAddr *destAddrPtr, F1IpAddr *dstIpPtr);
86 S16 establishReq(DuSctpDestCb *paramPtr);
87 S16 duSctpAssocReq(U8 itfType);
88 S16 duFillSctpPst(Pst *pst, Event event);
89 S16 sctpSetSockOpts(CmInetFd *sock_Fd);
90 S16 processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, U32 *timeoutPtr, CmInetMemInfo *memInfo, Bool recvMsgSet);
91 S16 sctpSockPoll();
92
93 #endif
94
95 /**********************************************************************
96          End of file
97 **********************************************************************/