00ae12658db815b11c50b873cd7da5ad8b8bbbbe
[o-du/l2.git] / src / ric_stub / ric_stub_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 __RIC_SCTP_H__
22 #define __RIC_SCTP_H__
23
24 #define MAX_RETRY 5
25 #define MAX_IPV6_LEN 16
26 #define MAX_DU_SUPPORTED 2
27 #define MAX_ASSOC_SUPPORTED MAX_DU_SUPPORTED
28
29 /* Global variable declaration */
30 uint8_t   socket_type;      /* Socket type */
31
32 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.30 */
33 typedef enum
34 {
35    RIC_SERVICE,
36    SUPPORT_FUNCTIONS,
37    BOTH_FUNCTIONALITY
38 }AssocUsage;
39
40 typedef struct
41 {
42    uint16_t           numFd;
43    uint16_t           port;   
44    uint32_t           flag;
45    Buffer            *mBuf;
46    MsgLen             bufLen; 
47    CmInetNetAddr      addr;
48    CmInetFdSet        readFd;
49    CmInetSctpSndRcvInfo   info;
50    CmInetSctpNotification ntfy;
51 }sctpSockPollParams;
52
53 typedef struct
54 {
55    uint32_t              duId;
56    uint16_t              destPort;         /* DU PORTS */
57    bool                  bReadFdSet;
58    CmInetFd              sockFd;           /* Socket file descriptor */
59    CmInetAddr            peerAddr;
60    CmInetNetAddrLst      destAddrLst;      /* DU Ip address */
61    CmInetNetAddr         destIpNetAddr;    /* DU Ip address */ 
62    Bool                  connUp;
63 }RicSctpAssocCb;
64
65 typedef struct ipAddr
66 {
67  bool ipV4Pres;
68  uint32_t  ipV4Addr;
69  bool ipV6Pres;
70  uint8_t   ipV6Addr[MAX_IPV6_LEN];
71 }SctpIpAddr;
72
73 typedef struct sctpDestInfo
74 {
75    SctpIpAddr  destIpAddr;
76    uint16_t    destPort;
77 }SctpDestInfo;
78
79 typedef struct ricSctpParams
80 {
81    SctpIpAddr     localIpAddr;
82    uint16_t       e2SctpPort;
83    uint8_t        numDestNode;
84    SctpDestInfo   destCb[MAX_DU_SUPPORTED];
85    AssocUsage     usage;
86 }RicSctpParams;
87
88 typedef struct sctpGlobalCb
89 {
90    RicSctpParams    sctpCfg;
91    CmInetNetAddrLst localAddrLst;
92    CmInetFd         e2LstnSockFd;       /* Listening Socket file descriptor for E2 association */
93    uint8_t          numAssoc;
94    RicSctpAssocCb   assocCb[MAX_ASSOC_SUPPORTED]; 
95 }SctpGlobalCb;
96
97 SctpGlobalCb sctpCb;
98
99 uint8_t sctpActvInit();
100 uint8_t sctpSend(uint32_t duId, Buffer *mBuf);
101 uint8_t sctpCfgReq();
102 uint8_t sctpStartReq();
103 uint8_t sctpSetSockOpts(CmInetFd *sock_Fd);
104 uint8_t sctpAccept(RicSctpAssocCb *assocCb);
105 uint8_t sctpSockPoll();
106 uint8_t processPolling(sctpSockPollParams *pollParams, RicSctpAssocCb *destCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo);
107 uint8_t fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr);
108 uint8_t fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr);
109
110 #endif
111
112 /**********************************************************************
113          End of file
114  **********************************************************************/