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