0f36cb52d59e901d88b93dca637b3e019354e74d
[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 #include "common_def.h"
21 #include "ric_stub.h"
22 #include "ric_stub_sctp.h"
23 #include "du_log.h"
24
25 #ifdef O1_ENABLE
26 #include "CmInterface.h"
27 #endif
28
29 #define RIC_ID 1
30 #define RIC_NAME "ORAN_OAM_RIC"
31
32 #define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
33 #define RIC_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
34
35 #ifndef O1_ENABLE
36
37 #define DU_IP_V4_ADDR "192.168.130.81"
38 #define RIC_IP_V4_ADDR "192.168.130.80"
39 #define DU_PORT 36421
40 #define RIC_PORT 36421
41
42 #endif
43
44 #define RRC_VER 0
45 #define EXT_RRC_VER 5
46 #define PLMN_MCC0 3
47 #define PLMN_MCC1 1
48 #define PLMN_MCC2 1
49 #define PLMN_MNC0 4
50 #define PLMN_MNC1 8
51 #define PLMN_MNC2 0
52
53 #ifdef O1_ENABLE
54 extern StartupConfig g_cfg;
55 #endif
56
57 /*******************************************************************
58  *
59  * @brief Handles SCTP notification 
60  *
61  * @details
62  *
63  *    Function : sctpNtfyInd
64  *
65  *    Functionality:
66  *         Handles SCTP notification
67  *
68  * @params[in] sctp notification
69  * @return void
70  *
71  ******************************************************************/
72 void sctpNtfyInd(CmInetSctpNotification *ntfy)
73 {
74 //TODO
75 }
76
77 void init_log()
78 {
79         openlog("RIC_STUB",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
80 }
81 /*******************************************************************
82  *
83  * @brief Main function of E2 APP
84  *
85  * @details
86  *
87  *    Function : main
88  *
89  *    Functionality:
90  *         - Reads RIC related configurations
91  *         - Initialize SCTP Parameters
92  *         - Start SCTP receiver thread
93  *
94  * @params[in] 
95  * @return ROK     - success
96  *         RFAILED - failure
97  *
98  * ****************************************************************/
99
100 uint8_t tst()
101 {
102    init_log();   
103  
104    DU_LOG("\nINFO  --> RIC : Starting RIC_STUB");
105    /* Read RIC configurations */
106    readRicCfg();
107
108    /* Start RIC-SCTP to listen on incoming connection */
109    sctpCfgReq();
110    sctpStartReq();
111
112    return ROK;
113 }
114 /*******************************************************************
115  *
116  * @brief Read RIC related configuration
117  *
118  * @details
119  *
120  *    Function : readRicCfg
121  *
122  *    Functionality:
123  *            - Read RIC related configuration
124  *
125  * @params[in] 
126  * @return ROK     - success
127  *         RFAILED - failure
128  *
129  * ****************************************************************/
130
131 void readRicCfg()
132 {
133    uint32_t ipv4_du, ipv4_ric;
134
135    DU_LOG("\nINFO  --> RIC : Reading RIC configurations");
136
137 #ifdef O1_ENABLE
138    if( getStartupConfigForStub(&g_cfg) != ROK )
139    {
140       DU_LOG("\nError  -->  RIC : Could not fetch startup "\
141              "configurations from Netconf interface\n");
142       exit(1);
143    }
144
145    cmInetAddr((S8*)g_cfg.DU_IPV4_Addr,  &ipv4_du);
146    cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
147
148    ricCfgParams.sctpParams.duPort = g_cfg.RIC_Port;
149    ricCfgParams.sctpParams.ricPort = g_cfg.RIC_Port;
150 #else
151    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
152    cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
153
154    ricCfgParams.sctpParams.duPort = DU_PORT;
155    ricCfgParams.sctpParams.ricPort = RIC_PORT;
156 #endif
157     
158    ricCfgParams.ricId = RIC_ID;
159    strcpy(ricCfgParams.ricName, RIC_NAME);
160  
161    /* DU IP Address and Port*/
162    ricCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
163    ricCfgParams.sctpParams.duIpAddr.ipV6Pres = false;
164
165    /* RIC IP Address and Port*/
166    ricCfgParams.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
167    ricCfgParams.sctpParams.ricIpAddr.ipV6Pres = false;
168
169    /*PLMN*/
170    ricCfgParams.plmn.mcc[0] = PLMN_MCC0;
171    ricCfgParams.plmn.mcc[1] = PLMN_MCC1;
172    ricCfgParams.plmn.mcc[2] = PLMN_MCC2;
173    ricCfgParams.plmn.mnc[0] = PLMN_MNC0;
174    ricCfgParams.plmn.mnc[1] = PLMN_MNC1;
175    ricCfgParams.plmn.mnc[2] = PLMN_MNC2;
176   
177 } /* End of readCuCfg */
178 /**********************************************************************
179          End of file
180 **********************************************************************/