1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2020-2021] [HCL Technologies Ltd.] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /* This file contains C interface for ODU and stubs to get startup
23 #include "ConfigInterface.h"
24 #include "GlobalDefs.hpp"
25 #include "UnixSocketClient.hpp"
26 #include "SessionHandler.hpp"
27 #include "InitConfig.hpp"
28 #include "NrCellList.hpp"
32 /*******************************************************************
34 * @brief Get the startup config from Netconf
38 * Function : getStartupConfig
41 * - Get the start up IP and port for DU
43 * @params[in] pointer to StartupConfig
44 * @return O1::SUCCESS - success
45 * O1::FAILURE - failure
46 ******************************************************************/
47 uint8_t getStartupConfig(StartupConfig *cfg)
49 if ( InitConfig::instance().getCurrInterfaceConfig(*cfg) )
51 O1_LOG("\nO1 StartupConfig : "
52 "cfg.DU_IPV4_Addr [%s]",
54 O1_LOG("\nO1 StartupConfig : "
57 O1_LOG("\nO1 StartupConfig : "
58 "cfg.CU_IPV4_Addr [%s]",
60 O1_LOG("\nO1 StartupConfig : "
63 O1_LOG("\nO1 StartupConfig : "
64 "cfg.RIC_IPV4_Addr [%s]",
66 O1_LOG("\nO1 StartupConfig : "
74 /*******************************************************************
76 * @brief Get the startup config from Netconf
80 * Function : getStartupConfig
83 * - Get the start up IP and port for CU and RIC
85 * @params[in] pointer to StartupConfig
86 * @return O1::SUCCESS - success
87 * O1::FAILURE - failure
88 ******************************************************************/
89 uint8_t getStartupConfigForStub(StartupConfig *cfg)
92 UnixSocketClient uxClient(O1::ALARM_SOCK_PATH);
93 O1_LOG("\nO1 CONFIG : getStartupConfig ------ \n");
95 msg.msgType = CONFIGURATION;
96 msg.action = GET_STARTUP_CONFIG;
97 if (uxClient.openSocket() == O1::FAILURE)
101 if (uxClient.sendData(&msg,sizeof(msg)) < 0 )
103 uxClient.closeSocket();
106 if (uxClient.receiveData(cfg, sizeof(StartupConfig)) < 0)
108 uxClient.closeSocket();
111 O1_LOG("\nO1 CONFIG : ip du %s\n",cfg->DU_IPV4_Addr );
112 O1_LOG("\nO1 CONFIG : ip cu %s\n",cfg->CU_IPV4_Addr );
113 O1_LOG("\nO1 CONFIG : ip ric %s\n",cfg->RIC_IPV4_Addr );
114 O1_LOG("\nO1 CONFIG : port cu %hu\n",cfg->CU_Port);
115 O1_LOG("\nO1 CONFIG : port du %hu\n",cfg->DU_Port);
116 O1_LOG("\nO1 CONFIG : port ric %hu\n",cfg->RIC_Port);
118 uxClient.closeSocket();
120 SessionHandler sessHdlr;
121 if ( sessHdlr.init() )
123 if ( InitConfig::instance().getCurrInterfaceConfig(*cfg) )
125 O1_LOG("\nO1 StartupConfig : "
126 "cfg.DU_IPV4_Addr [%s]",
128 O1_LOG("\nO1 StartupConfig : "
131 O1_LOG("\nO1 StartupConfig : "
132 "cfg.CU_IPV4_Addr [%s]",
134 O1_LOG("\nO1 StartupConfig : "
137 O1_LOG("\nO1 StartupConfig : "
138 "cfg.RIC_IPV4_Addr [%s]",
140 O1_LOG("\nO1 StartupConfig : "
149 /*******************************************************************
151 * @brief update cell and operational state
155 * Function : setCellOpState
158 * - send update of cell and operational state to it's handler
161 * @params[in] cellId, opState, cellState
162 * @return cell operational in string form
163 ******************************************************************/
166 bool setCellOpState(uint16_t cellId, OpState opState, CellState cellState)
168 O1_LOG("\nO1 ConfigInterface: Setting cellId = %d, opState=%d, \
169 cellState=%d\n", cellId, opState, cellState);
170 return NrCellList::instance().setCellOpState(cellId, opState, \
174 /**********************************************************************
176 **********************************************************************/