E2AP code changes
[o-du/l2.git] / src / ric_stub / ric_stub.c
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 functions contains main() for ric_app */
20
21 #include "ric_stub.h"
22 #include "ric_stub_sctp.h"
23
24 #define RIC_ID 1
25 #define RIC_NAME "ORAN_OAM_RIC"
26 #define DU_IP_V4_ADDR "10.0.2.20"
27 #define RIC_IP_V4_ADDR "10.0.2.30"
28 #define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
29 #define RIC_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
30 #define DU_PORT 38482
31 #define RIC_PORT 38482 
32 #define RRC_VER 0
33 #define EXT_RRC_VER 5
34 #define PLMN_MCC0 3
35 #define PLMN_MCC1 1
36 #define PLMN_MCC2 1
37 #define PLMN_MNC0 4
38 #define PLMN_MNC1 8
39 #define PLMN_MNC2 0
40
41 /*******************************************************************
42  *
43  * @brief Handles SCTP notification 
44  *
45  * @details
46  *
47  *    Function : sctpNtfyInd
48  *
49  *    Functionality:
50  *         Handles SCTP notification
51  *
52  * @params[in] sctp notification
53  * @return void
54  *
55  ******************************************************************/
56 void sctpNtfyInd(CmInetSctpNotification *ntfy)
57 {
58 //TODO
59 }
60
61 void init_log()
62 {
63         openlog("CU_STUB",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
64 }
65 /*******************************************************************
66  *
67  * @brief Main function of CU APP
68  *
69  * @details
70  *
71  *    Function : main
72  *
73  *    Functionality:
74  *         - Reads CU related configurations
75  *         - Initialize SCTP Parameters
76  *         - Start SCTP receiver thread
77  *
78  * @params[in] 
79  * @return ROK     - success
80  *         RFAILED - failure
81  *
82  * ****************************************************************/
83
84 S16 tst()
85 {
86    init_log();   
87  
88    DU_LOG("\nStarting RIC_STUB");
89    /* Read CU configurations */
90    readRicCfg();
91
92    /* Initializing SCTP global parameters */
93    sctpActvInit();
94  
95    /* Start CU-SCTP to listen on incoming connection */
96    sctpCfgReq();
97    sctpStartReq();
98
99    RETVALUE(ROK);
100 }
101 /*******************************************************************
102  *
103  * @brief Read RIC related configuration
104  *
105  * @details
106  *
107  *    Function : readRicCfg
108  *
109  *    Functionality:
110  *            - Read RIC related configuration
111  *
112  * @params[in] 
113  * @return ROK     - success
114  *         RFAILED - failure
115  *
116  * ****************************************************************/
117
118 void readRicCfg()
119 {
120    U32 ipv4_du, ipv4_ric;
121
122    DU_LOG("\nReading RIC configurations");
123
124    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
125    cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
126  
127    cuCfgParams.cuId = RIC_ID;
128    strcpy(cuCfgParams.cuName, RIC_NAME);
129  
130    /* DU IP Address and Port*/
131    cuCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
132    cuCfgParams.sctpParams.duIpAddr.ipV6Pres = false;
133    cuCfgParams.sctpParams.duPort = DU_PORT;
134
135    /* RIC IP Address and Port*/
136    cuCfgParams.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
137    cuCfgParams.sctpParams.ricIpAddr.ipV6Pres = false;
138    cuCfgParams.sctpParams.ricPort = RIC_PORT;
139
140    /*PLMN*/
141    cuCfgParams.plmn.mcc[0] = PLMN_MCC0;
142    cuCfgParams.plmn.mcc[1] = PLMN_MCC1;
143    cuCfgParams.plmn.mcc[2] = PLMN_MCC2;
144    cuCfgParams.plmn.mnc[0] = PLMN_MNC0;
145    cuCfgParams.plmn.mnc[1] = PLMN_MNC1;
146    cuCfgParams.plmn.mnc[2] = PLMN_MNC2;
147
148    /*RRC Version*/
149    cuCfgParams.rrcVersion.rrcVer = RRC_VER;
150    cuCfgParams.rrcVersion.extRrcVer = EXT_RRC_VER;
151   
152 } /* End of readCuCfg */
153 /**********************************************************************
154          End of file
155 **********************************************************************/