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"
31 /*******************************************************************
33 * @brief Get the startup config from Netconf
37 * Function : getStartupConfig
40 * - Get the start up IP and port for DU
42 * @params[in] pointer to StartupConfig
43 * @return O1::SUCCESS - success
44 * O1::FAILURE - failure
45 ******************************************************************/
46 uint8_t getStartupConfig(StartupConfig *cfg)
48 if ( InitConfig::instance().getCurrInterfaceConfig(*cfg) )
50 O1_LOG("\nO1 StartupConfig : "
51 "cfg.DU_IPV4_Addr [%s]",
53 O1_LOG("\nO1 StartupConfig : "
56 O1_LOG("\nO1 StartupConfig : "
57 "cfg.CU_IPV4_Addr [%s]",
59 O1_LOG("\nO1 StartupConfig : "
62 O1_LOG("\nO1 StartupConfig : "
63 "cfg.RIC_IPV4_Addr [%s]",
65 O1_LOG("\nO1 StartupConfig : "
73 /*******************************************************************
75 * @brief Get the startup config from Netconf
79 * Function : getStartupConfig
82 * - Get the start up IP and port for CU and RIC
84 * @params[in] pointer to StartupConfig
85 * @return O1::SUCCESS - success
86 * O1::FAILURE - failure
87 ******************************************************************/
88 uint8_t getStartupConfigForStub(StartupConfig *cfg)
91 UnixSocketClient uxClient(O1::ALARM_SOCK_PATH);
92 O1_LOG("\nO1 CONFIG : getStartupConfig ------ \n");
94 msg.msgType = CONFIGURATION;
95 msg.action = GET_STARTUP_CONFIG;
96 if (uxClient.openSocket() == O1::FAILURE)
100 if (uxClient.sendData(&msg,sizeof(msg)) < 0 )
102 uxClient.closeSocket();
105 if (uxClient.receiveData(cfg, sizeof(StartupConfig)) < 0)
107 uxClient.closeSocket();
110 O1_LOG("\nO1 CONFIG : ip du %s\n",cfg->DU_IPV4_Addr );
111 O1_LOG("\nO1 CONFIG : ip cu %s\n",cfg->CU_IPV4_Addr );
112 O1_LOG("\nO1 CONFIG : ip ric %s\n",cfg->RIC_IPV4_Addr );
113 O1_LOG("\nO1 CONFIG : port cu %hu\n",cfg->CU_Port);
114 O1_LOG("\nO1 CONFIG : port du %hu\n",cfg->DU_Port);
115 O1_LOG("\nO1 CONFIG : port ric %hu\n",cfg->RIC_Port);
117 uxClient.closeSocket();
119 SessionHandler sessHdlr;
120 if ( sessHdlr.init() )
122 if ( InitConfig::instance().getCurrInterfaceConfig(*cfg) )
124 O1_LOG("\nO1 StartupConfig : "
125 "cfg.DU_IPV4_Addr [%s]",
127 O1_LOG("\nO1 StartupConfig : "
130 O1_LOG("\nO1 StartupConfig : "
131 "cfg.CU_IPV4_Addr [%s]",
133 O1_LOG("\nO1 StartupConfig : "
136 O1_LOG("\nO1 StartupConfig : "
137 "cfg.RIC_IPV4_Addr [%s]",
139 O1_LOG("\nO1 StartupConfig : "
149 /**********************************************************************
151 **********************************************************************/