O1 IP PORT configuration for CM .[Issue-Id: ODUHIGH-196]
[o-du/l2.git] / src / o1 / InitConfig.hpp
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 InitConfig class header*/
20
21 #ifndef __INIT_CONFIG_HPP__
22 #define __INIT_CONFIG_HPP__
23
24 #include <utility>
25 #include <string>
26 #include <iostream>
27 #include "sysrepo-cpp/Session.hpp"
28 #include <map>
29 #include "Singleton.hpp"
30 #include "Config.h"
31
32 #include "GlobalDefs.hpp"
33 #define IP_ADDRESS "interface-address" 
34 #define PORT "port"
35 #define INTERFACE_MODULE_NAME_ORAN "/o-ran-sc-odu-interface-v1:odu"
36 #define MAX_XPATH 100
37 #define NETCONF_STARTUP_CFG "/etc/netconf_startup.cfg"
38
39 #define DEFAULT_DU_IPV4_ADDR "192.168.130.81"
40 #define DEFAULT_DU_PORT 38472
41
42 #define DEFAULT_CU_IPV4_ADDR "192.168.130.82"
43 #define DEFAULT_CU_PORT 38472
44
45 #define DEFAULT_RIC_IPV4_ADDR "192.168.130.80"
46 #define DEFAULT_RIC_PORT 36422
47
48 enum class Interface 
49 { ODU,
50   OCU,
51   RIC
52 };
53
54
55 class InitConfig : public Singleton<InitConfig>
56 {
57
58    friend Singleton<InitConfig>;
59
60    public:
61       
62      //member variable
63       typedef std::pair<std::string, uint16_t> Address;
64       typedef std::map<Interface, Address> InterfaceMap;
65      
66       InitConfig();
67       ~InitConfig();
68       bool init(sysrepo::S_Session sess);
69       bool getCurrInterfaceConfig(StartupConfig & cfg);
70
71    private:
72
73       InterfaceMap mInterfaceList;
74       char xpath[MAX_XPATH];
75       sysrepo::S_Session mSess;
76       //string mVal;
77       /* function to get the data of Interfaces param*/
78       InterfaceMap getInterfaceConfig(sysrepo::S_Session sess);
79       Address getInterfaceData(sysrepo::S_Session sess, Interface inf);
80       char * getInterfaceXpath( std::string sInf, std::string param);
81       std::string getData(sysrepo::S_Session sess,char* xpath);
82       std::string interfaceToString(Interface inf);
83       bool printInterfaceConfig();
84       bool writeInterfaceConfig();
85
86 };
87
88 #endif
89
90 /**********************************************************************
91          End of file
92 **********************************************************************/