Fix of compilation issue .[Issue-Id: ODUHIGH- 323]
[o-du/l2.git] / src / o1 / o1_client / Config.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2020] [HCL Technologies Ltd.]                               #
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 definitions of startup configuration structure */
20
21 #include "Config.h"
22 #include "ssi.h"
23 #include "GlobalDefs.h"
24 #include "TcpClient.h"
25
26 StartupConfig g_cfg;
27
28 /*******************************************************************
29  *
30  * @brief Get the startup config from Netconf
31  *
32  * @details
33  *
34  *    Function : getStartupConfig
35  *
36  *    Functionality:
37  *      - Get the start up IP and port for DU,CU and RIC
38  *
39  * @params[in] pointer to StartupConfig
40  * @return ROK     - success
41  *         RFAILED - failure
42  ******************************************************************/
43 uint8_t getStartupConfig(StartupConfig *cfg)
44 {
45    O1_LOG("\nCONFIG : getStartupConfig ------ \n");
46    MsgHeader msg;
47    msg.msgType = CONFIGURATION;
48    msg.action = GET_STARTUP_CONFIG;
49    if (openSocket(TCP_SERVER_IP,TCP_PORT) == RFAILED)
50    {
51       return RFAILED;
52    }
53    if (sendData(&msg,sizeof(msg)) < 0 )
54    {
55       closeSocket();
56       return RFAILED;
57    }
58    if (receiveData(cfg, sizeof(StartupConfig)) < 0)
59    {
60       closeSocket();
61       return RFAILED;
62    }
63    O1_LOG("\nCONFIG : ip du %s\n",cfg->DU_IPV4_Addr );
64    O1_LOG("\nCONFIG : ip cu %s\n",cfg->CU_IPV4_Addr );
65    O1_LOG("\nCONFIG : ip ric %s\n",cfg->RIC_IPV4_Addr );
66    O1_LOG("\nCONFIG : port cu %hu\n",cfg->CU_Port);
67    O1_LOG("\nCONFIG : port du %hu\n",cfg->DU_Port);
68    O1_LOG("\nCONFIG : port ric %hu\n",cfg->RIC_Port);
69
70    closeSocket();
71    return ROK;
72 }
73
74
75 /**********************************************************************
76          End of file
77 **********************************************************************/