I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/F1AP
I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/RRC
+ifeq ($(O1_ENABLE),YES)
+I_OPTS+=-I$(ROOT_DIR)/src/o1/o1_client
+endif
+
#-------------------------------------------------------------#
#Linker macros
#-------------------------------------------------------------#
I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/F1AP
I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/RRC
I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/E2AP
+
+ifeq ($(O1_ENABLE),YES)
I_OPTS+=-I$(ROOT_DIR)/src/o1/o1_client
+endif
#-------------------------------------------------------------#
#Linker macros
I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/common
I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/E2AP
+ifeq ($(O1_ENABLE),YES)
+I_OPTS+=-I$(ROOT_DIR)/src/o1/o1_client
+endif
#-------------------------------------------------------------#
#Linker macros
#-------------------------------------------------------------#
--- /dev/null
+module o-ran-sc-odu-interface-v1 {
+ yang-version 1;
+ namespace "urn:o-ran:odu:interface:1.0";
+ prefix rxad;
+
+ import ietf-inet-types { prefix inet; }
+
+ organization
+ "O-RAN Software Community";
+ contact
+ "www.o-ran.org";
+ description
+ "This module defines active interface information visible to operators
+
+ Copyright 2020 the O-RAN Alliance.
+
+ Licensed under the Apache License, Version 2.0 (the 'License');
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an 'AS IS' BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.";
+
+ revision 2020-01-29 {
+ description
+ "initial revision";
+ reference
+ "O-RAN-OAM-Interface-Specification (O1)";
+ }
+
+ grouping interface-info {
+ leaf interface-name {
+ type string;
+ description
+ "The unique interface ID";
+ }
+ leaf interface-address {
+ type inet:ip-address;
+ mandatory true;
+ description
+ "The local IP address to listen on for incoming
+ client connections. INADDR_ANY (0.0.0.0) or
+ INADDR6_ANY (0:0:0:0:0:0:0:0 a.k.a. ::) MUST be
+ used when the server is to listen on all IPv4 or
+ IPv6 addresses, respectively.";
+ }
+ leaf port {
+ type inet:port-number;
+ default "0";
+ description
+ "The local port number to listen on for incoming
+ client connections. An invalid default value (0)
+ is used (instead of 'mandatory true') so that an
+ application level data model may 'refine' it with
+ an application specific default port number value.";
+ }
+ description
+ "interface information";
+ }
+
+ container odu {
+ container interfaces {
+ list interface {
+ key "interface-name";
+ uses interface-info;
+ description
+ "The list of active interfaces in RIC";
+ }
+ description
+ "State data container of the interfaces";
+ }
+ description
+ "Root object for RIC interfaces";
+ }
+}
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/mt.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/rl.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/phy_stub.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)'
+ifeq ($(O1_ENABLE),YES)
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1_client.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)'
+endif
link_du: du
$(Q)$(CC1) -g -o $(OBJ_ROOT)/odu/odu -Wl,-R../lib/:. $(OBJ_ROOT)/odu/*.o\
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/mt.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/rl.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/phy_stub.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)'
+ifeq ($(O1_ENABLE),YES)
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1_client.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)'
+endif
$(Q)rm -rf $(OBJ_ROOT)/odu/*
$(Q)rm -rf $(LIB_ROOT)/odu/*
$(Q)rm -rf $(BIN_DIR)/odu/*
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/asn_rrc.mak OBJ_DIR=$(OBJ_ROOT)/cu_stub LIB_DIR=$(LIB_ROOT)/cu_stub LOG_DIR=$(LOG_ROOT)/cu_stub CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/cm.mak OBJ_DIR=$(OBJ_ROOT)/cu_stub LIB_DIR=$(LIB_ROOT)/cu_stub LOG_DIR=$(LOG_ROOT)/cu_stub CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/mt.mak OBJ_DIR=$(OBJ_ROOT)/cu_stub LIB_DIR=$(LIB_ROOT)/cu_stub LOG_DIR=$(LOG_ROOT)/cu_stub CC='$(CC1)'
+ifeq ($(O1_ENABLE),YES)
+ $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1_client.mak OBJ_DIR=$(OBJ_ROOT)/cu_stub LIB_DIR=$(LIB_ROOT)/cu_stub LOG_DIR=$(LOG_ROOT)/cu_stub CC='$(CC1)'
+endif
clean_cu:
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/cu_stub.mak clean OBJ_DIR=$(OBJ_ROOT)/cu_stub LIB_DIR=$(LIB_ROOT)/cu_stub LOG_DIR=$(LOG_ROOT)/cu_stub CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/asn_rrc.mak clean OBJ_DIR=$(OBJ_ROOT)/cu_stub LIB_DIR=$(LIB_ROOT)/cu_stub LOG_DIR=$(LOG_ROOT)/cu_stub CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/cm.mak clean OBJ_DIR=$(OBJ_ROOT)/cu_stub LIB_DIR=$(LIB_ROOT)/cu_stub LOG_DIR=$(LOG_ROOT)/cu_stub CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/mt.mak clean OBJ_DIR=$(OBJ_ROOT)/cu_stub LIB_DIR=$(LIB_ROOT)/cu_stub LOG_DIR=$(LOG_ROOT)/cu_stub CC='$(CC1)'
+ifeq ($(O1_ENABLE),YES)
+ $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1_client.mak clean OBJ_DIR=$(OBJ_ROOT)/cu_stub LIB_DIR=$(LIB_ROOT)/cu_stub LOG_DIR=$(LOG_ROOT)/cu_stub CC='$(CC1)'
+endif
$(Q)rm -rf $(OBJ_ROOT)/cu_stub/*
$(Q)rm -rf $(LIB_ROOT)/cu_stub/*
$(Q)rm -rf $(BIN_DIR)/cu_stub/*
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/asn_e2ap.mak OBJ_DIR=$(OBJ_ROOT)/ric_stub LIB_DIR=$(LIB_ROOT)/ric_stub LOG_DIR=$(LOG_ROOT)/ric_stub CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/cm.mak OBJ_DIR=$(OBJ_ROOT)/ric_stub LIB_DIR=$(LIB_ROOT)/ric_stub LOG_DIR=$(LOG_ROOT)/ric_stub CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/mt.mak OBJ_DIR=$(OBJ_ROOT)/ric_stub LIB_DIR=$(LIB_ROOT)/ric_stub LOG_DIR=$(LOG_ROOT)/ric_stub CC='$(CC1)'
+ifeq ($(O1_ENABLE),YES)
+ $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1_client.mak OBJ_DIR=$(OBJ_ROOT)/ric_stub LIB_DIR=$(LIB_ROOT)/ric_stub LOG_DIR=$(LOG_ROOT)/ric_stub CC='$(CC1)'
+endif
clean_ric:
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/ric_stub.mak clean OBJ_DIR=$(OBJ_ROOT)/ric_stub LIB_DIR=$(LIB_ROOT)/ric_stub LOG_DIR=$(LOG_ROOT)/ric_stub CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/asn_rrc.mak clean OBJ_DIR=$(OBJ_ROOT)/ric_stub LIB_DIR=$(LIB_ROOT)/ric_stub LOG_DIR=$(LOG_ROOT)/ric_stub CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/cm.mak clean OBJ_DIR=$(OBJ_ROOT)/ric_stub LIB_DIR=$(LIB_ROOT)/ric_stub LOG_DIR=$(LOG_ROOT)/ric_stub CC='$(CC1)'
$(Q)$(MAKE) -f $(COM_BUILD_DIR)/mt.mak clean OBJ_DIR=$(OBJ_ROOT)/ric_stub LIB_DIR=$(LIB_ROOT)/ric_stub LOG_DIR=$(LOG_ROOT)/ric_stub CC='$(CC1)'
+ifeq ($(O1_ENABLE),YES)
+ $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1_client.mak clean OBJ_DIR=$(OBJ_ROOT)/ric_stub LIB_DIR=$(LIB_ROOT)/ric_stub LOG_DIR=$(LOG_ROOT)/ric_stub CC='$(CC1)'
+endif
$(Q)rm -rf $(OBJ_ROOT)/ric_stub/*
$(Q)rm -rf $(LIB_ROOT)/ric_stub/*
$(Q)rm -rf $(BIN_DIR)/ric_stub/*
#include "cu_stub_egtp.h"
#include "du_log.h"
+#ifdef O1_ENABLE
+
+#include "Config.h"
+
+#endif
+
#define CU_ID 1
#define CU_NAME "ORAN_OAM_CU"
-#define DU_IP_V4_ADDR "192.168.130.81"
-#define CU_IP_V4_ADDR "192.168.130.82"
+
#define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
#define CU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
+
+#ifndef O1_ENABLE
+
+#define DU_IP_V4_ADDR "192.168.130.81"
+#define CU_IP_V4_ADDR "192.168.130.82"
#define DU_PORT 38472
#define CU_PORT 38472
+
+#endif
+
#define DU_EGTP_PORT 39001
#define CU_EGTP_PORT 39002
#define RRC_VER 0
#define PLMN_MNC1 8
#define PLMN_MNC2 0
+#ifdef O1_ENABLE
+
+extern StartupConfig g_cfg;
+
+#endif
+
+
/*******************************************************************
*
* @brief Handles SCTP notification
DU_LOG("\nReading CU configurations");
+#ifdef O1_ENABLE
+ if( getStartupConfig(&g_cfg) != ROK )
+ {
+ RETVALUE(RFAILED);
+ }
+ DU_LOG("\nReading CU configurations---");
+ DU_LOG("\nReading CU configurations g_cfg.DU_IPV4_Addr=%s", g_cfg.DU_IPV4_Addr);
+ DU_LOG("\nReading CU configurations g_cfg.CU_IPV4_Addr=%s", g_cfg.CU_IPV4_Addr);
+ cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
+ cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
+
+ cuCfgParams.sctpParams.duPort = g_cfg.DU_Port;
+ cuCfgParams.sctpParams.cuPort = g_cfg.CU_Port;
+#else
cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
-
+ cuCfgParams.sctpParams.duPort = DU_PORT;
+ cuCfgParams.sctpParams.cuPort = CU_PORT;
+#endif
+
cuCfgParams.cuId = CU_ID;
strcpy(cuCfgParams.cuName, CU_NAME);
/* DU IP Address and Port*/
cuCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
cuCfgParams.sctpParams.duIpAddr.ipV6Pres = false;
- cuCfgParams.sctpParams.duPort = DU_PORT;
/* CU IP Address and Port*/
cuCfgParams.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
cuCfgParams.sctpParams.cuIpAddr.ipV6Pres = false;
- cuCfgParams.sctpParams.cuPort = CU_PORT;
/*PLMN*/
cuCfgParams.plmn.mcc[0] = PLMN_MCC0;
#include "BWP-DownlinkCommon.h"
#include "BWP-UplinkCommon.h"
+#ifdef O1_ENABLE
+
+#include "Config.h"
+extern StartupConfig g_cfg;
+
+#endif
+
DuCfgParams duCfgParam;
char encBuf[ENC_BUF_MAX_LEN];
* ****************************************************************/
uint8_t fillDuPort(uint16_t *duPort)
{
+
+#ifdef O1_ENABLE
+ duPort[F1_INTERFACE] = g_cfg.DU_Port;
+ duPort[E2_INTERFACE] = g_cfg.RIC_Port;
+#else
duPort[F1_INTERFACE] = DU_PORT; /* DU Port idx 0 38472 */
duPort[E2_INTERFACE] = RIC_PORT; /* RIC Port idx 1 38482 */
-
+#endif
return ROK;
}
MibParams mib;
Sib1Params sib1;
+#ifdef O1_ENABLE
+ if( getStartupConfig(&g_cfg) != ROK )
+ {
+ RETVALUE(RFAILED);
+ }
+ cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
+ cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
+ cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
+
+ duCfgParam.sctpParams.cuPort = g_cfg.CU_Port;
+ duCfgParam.sctpParams.ricPort = g_cfg.RIC_Port;
+#else
cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
+
+ duCfgParam.sctpParams.cuPort = CU_PORT;
+ duCfgParam.sctpParams.ricPort = RIC_PORT;
+#endif
+
fillDuPort(duCfgParam.sctpParams.duPort);
/* F1 DU IP Address and Port*/
/* F1 CU IP Address and Port*/
duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
- duCfgParam.sctpParams.cuPort = CU_PORT;
/* Fill RIC Params */
duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
- duCfgParam.sctpParams.ricPort = RIC_PORT;
+
/* EGTP Parameters */
duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
/* MACROS */
#define DU_INST 0
#define DU_ID 1
+
+#ifndef O1_ENABLE
+
#define DU_IP_V4_ADDR "192.168.130.81"
#define CU_IP_V4_ADDR "192.168.130.82"
#define RIC_IP_V4_ADDR "192.168.130.80"
#define DU_PORT 38472
#define CU_PORT 38472
#define RIC_PORT 36422 /* using X2 port since E2 port not defined */
+
+#endif
+
#define DU_EGTP_PORT 39001
#define CU_EGTP_PORT 39002
#define NR_PCI 1
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+/* This file contains methods of InitConfig and Interfaces to
+ YANG modules */
+
+#include "InitConfig.hpp"
+#include<string>
+#include <string.h>
+using namespace std;
+
+
+/* Default constructor */
+InitConfig::InitConfig()
+{
+}
+
+
+/* Destructor */
+InitConfig::~InitConfig()
+{
+}
+
+/*******************************************************************
+ *
+ * @brief Initialize Configuration
+ *
+ * @details
+ *
+ * Function : init
+ *
+ * Functionality:
+ * - Initialize Configuration
+ *
+ * @params[in] Reference to S_Session
+ * @return bool
+ *
+ ******************************************************************/
+
+bool InitConfig::init(sysrepo::S_Session sess)
+{
+ O1_LOG("\nInitConfig::init started ");
+ mSess = sess;
+ getInterfaceConfig(sess);
+ return true;
+}
+
+/*******************************************************************
+ *
+ * @brief Get running Interface Configuration
+ *
+ * @details
+ *
+ * Function : getCurrInterfaceConfig
+ *
+ * Functionality:
+ * - Get running Interface Configuration
+ *
+ * @params[in] Reference of StartupConfig
+ * @return bool
+ *
+ ******************************************************************/
+
+bool InitConfig::getCurrInterfaceConfig(StartupConfig & cfg)
+{
+ //O1_LOG("\n InitConfig::getCurrInterfaceConfig entry");
+ InitConfig::InterfaceMap::iterator it;
+ for (it=mInterfaceList.begin(); it != mInterfaceList.end(); it++)
+ {
+ //O1_LOG("\n InitConfig::getCurrInterfaceConfig iterator");
+ switch (it->first)
+ {
+ case Interface::ODU :
+ if(it->second.first != "0")
+ strcpy(cfg.DU_IPV4_Addr, it->second.first.c_str());
+ else
+ strcpy(cfg.DU_IPV4_Addr, DEFAULT_DU_IPV4_ADDR);
+ //O1_LOG("\n InitConfig::getCurrInterfaceConfig cfg.DU_IPV4_Addr = \
+ %s", cfg.DU_IPV4_Addr);
+
+ if(it->second.second != 0)
+ cfg.DU_Port = (uint16_t)it->second.second;
+ else
+ cfg.DU_Port = (uint16_t) DEFAULT_DU_PORT;
+ //O1_LOG("\n InitConfig::getCurrInterfaceConfig cfg.DU_Port = %d", \
+ cfg.DU_Port);
+ break;
+
+ case Interface::OCU :
+
+ if(it->second.first != "0")
+ strcpy(cfg.CU_IPV4_Addr, it->second.first.c_str());
+ else
+ strcpy(cfg.CU_IPV4_Addr, DEFAULT_CU_IPV4_ADDR);
+
+ //O1_LOG("\n InitConfig::getCurrInterfaceConfig cfg.CU_IPV4_Addr = \
+ %s", cfg.CU_IPV4_Addr);
+
+ if(it->second.second != 0)
+ cfg.CU_Port = (uint16_t) it->second.second;
+ else
+ cfg.CU_Port = (uint16_t) DEFAULT_CU_PORT;
+
+ //O1_LOG("\n InitConfig::getCurrInterfaceConfig cfg.CU_Port = %d", \
+ cfg.CU_Port);
+ break;
+
+ case Interface::RIC :
+
+ if(it->second.first != "0")
+ strcpy(cfg.RIC_IPV4_Addr, it->second.first.c_str());
+ else
+ strcpy(cfg.RIC_IPV4_Addr, DEFAULT_RIC_IPV4_ADDR);
+
+ //O1_LOG("\n InitConfig::getCurrInterfaceConfig cfg.RIC_IPV4_Addr = \
+ %s", cfg.RIC_IPV4_Addr);
+
+ if(it->second.second != 0)
+ cfg.RIC_Port = (uint16_t) it->second.second;
+ else
+ cfg.RIC_Port = (uint16_t) DEFAULT_RIC_PORT;
+
+ //O1_LOG("\n InitConfig::getCurrInterfaceConfig cfg.RIC_Port = %d", \
+ cfg.RIC_Port);
+ break;
+
+ default :
+ O1_LOG("\nno matching interface");
+ break;
+ }
+ }
+ return true;
+}
+
+/*******************************************************************
+ *
+ * @brief Get Interface Configuration
+ *
+ * @details
+ *
+ * Function : getInterfaceConfig
+ *
+ * Functionality:
+ * - Get running Interface Configuration
+ *
+ * @params[in] Reference of S_Session
+ * @return reference of InterfaceMap
+ *
+ ******************************************************************/
+InitConfig::InterfaceMap InitConfig::getInterfaceConfig(sysrepo::S_Session sess)
+{
+ O1_LOG("\nInitConfig::getInterfaceConfig started");
+ mInterfaceList.insert(std::make_pair(Interface::ODU, \
+ getInterfaceData(sess,Interface::ODU)));
+ mInterfaceList.insert(std::make_pair(Interface::OCU, \
+ getInterfaceData(sess,Interface::OCU)));
+ mInterfaceList.insert(std::make_pair(Interface::RIC, \
+ getInterfaceData(sess,Interface::RIC)));
+ return mInterfaceList;
+}
+
+/*******************************************************************
+ *
+ * @brief Get Interface Data
+ *
+ * @details
+ *
+ * Function : getInterfaceData
+ *
+ * Functionality:
+ * - Get running Interface Data
+ *
+ * @params[in] Reference of S_Session and Interface
+ * @return reference of Address
+ *
+ ******************************************************************/
+InitConfig::Address InitConfig::getInterfaceData(sysrepo::S_Session sess, \
+ Interface inf)
+{
+ O1_LOG("\nInitConfig::getInterfaceData started");
+ string sInf = interfaceToString(inf);
+ return std::make_pair(getData(sess, getInterfaceXpath(sInf, IP_ADDRESS)), \
+ atoi(getData(sess, getInterfaceXpath(sInf, PORT)).c_str()));
+}
+
+/*******************************************************************
+ *
+ * @brief create xpath for interfaces
+ *
+ * @details
+ *
+ * Function : getInterfaceXpath
+ *
+ * Functionality:
+ * - create xpath for interfaces
+ *
+ * @params[in] String of sInf and String of param
+ * @return pointer to xpath
+ *
+ ******************************************************************/
+char * InitConfig::getInterfaceXpath( string sInf, string param)
+{
+ sprintf(xpath, "%s/interfaces/interface[interface-name='%s']/%s", \
+ INTERFACE_MODULE_NAME_ORAN, sInf.c_str(),param.c_str());
+ return xpath;
+}
+
+/*******************************************************************
+ *
+ * @brief Get data of the xpath
+ *
+ * @details
+ *
+ * Function : getData
+ *
+ * Functionality:
+ * - get data of the xpath
+ *
+ * @params[in] reference of S_Session and pointer to xpath
+ * @return value against the xpath
+ *
+ ******************************************************************/
+
+string InitConfig::getData(sysrepo::S_Session sess,char* xpath)
+{
+ //O1_LOG("\nInitConfig::getData of xpath = %s", \
+ xpath); //enable for debugging only
+ try
+ {
+ auto value = sess->get_item(xpath);
+ if (value == nullptr)
+ {
+ //O1_LOG("\nget_item value are null for xpath = %s", \
+ xpath); //enable for debugging only
+ return "0";
+ }
+ string mVal = value->val_to_string();
+ return mVal;
+
+ }
+ catch (...)
+ {
+ //O1_LOG("\nInitConfig::getData exception occured for block xpath= %s", \
+ xpath); //enable for debugging only
+ return "0";
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Convert interface value to string
+ *
+ * @details
+ *
+ * Function : interfaceToString
+ *
+ * Functionality:
+ * - Convert interface value to string
+ *
+ * @params[in] reference to Interface
+ * @return string value of Interface
+ *
+ ******************************************************************/
+string InitConfig::interfaceToString(Interface inf)
+{
+ string interface;
+ switch (inf)
+ {
+ case Interface::ODU :
+ interface = "odu";
+ break;
+ case Interface::OCU :
+ interface = "ocu";
+ break;
+ case Interface::RIC :
+ interface = "ric";
+ break;
+ default :
+ O1_LOG("\n\n no matching interface ");
+ break;
+ }
+ return interface;
+
+}
+
+
+/*******************************************************************
+ *
+ * @brief Print Interface configuration
+ *
+ * @details
+ *
+ * Function : printInterfaceConfig
+ *
+ * Functionality:
+ * - Print Interface configuration
+ *
+ * @params[in] void
+ * @return bool
+ *
+ ******************************************************************/
+bool InitConfig::printInterfaceConfig()
+{
+ InitConfig::InterfaceMap::iterator it;
+ for (it=mInterfaceList.begin(); it != mInterfaceList.end(); it++)
+ {
+ O1_LOG("\ninterface [%s] : \n \t IP = %s \n \t Port = %d", \
+ interfaceToString(it->first).c_str(), it->second.first.c_str(), \
+ it->second.second);
+ }
+ return true;
+}
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+/* This file contains InitConfig class header*/
+
+#ifndef __INIT_CONFIG_HPP__
+#define __INIT_CONFIG_HPP__
+
+#include <utility>
+#include <string>
+#include <iostream>
+#include "sysrepo-cpp/Session.hpp"
+#include <map>
+#include "Singleton.hpp"
+#include "Config.h"
+
+#include "GlobalDefs.hpp"
+#define IP_ADDRESS "interface-address"
+#define PORT "port"
+#define INTERFACE_MODULE_NAME_ORAN "/o-ran-sc-odu-interface-v1:odu"
+#define MAX_XPATH 100
+#define NETCONF_STARTUP_CFG "/etc/netconf_startup.cfg"
+
+#define DEFAULT_DU_IPV4_ADDR "192.168.130.81"
+#define DEFAULT_DU_PORT 38472
+
+#define DEFAULT_CU_IPV4_ADDR "192.168.130.82"
+#define DEFAULT_CU_PORT 38472
+
+#define DEFAULT_RIC_IPV4_ADDR "192.168.130.80"
+#define DEFAULT_RIC_PORT 36422
+
+enum class Interface
+{ ODU,
+ OCU,
+ RIC
+};
+
+
+class InitConfig : public Singleton<InitConfig>
+{
+
+ friend Singleton<InitConfig>;
+
+ public:
+
+ //member variable
+ typedef std::pair<std::string, uint16_t> Address;
+ typedef std::map<Interface, Address> InterfaceMap;
+
+ InitConfig();
+ ~InitConfig();
+ bool init(sysrepo::S_Session sess);
+ bool getCurrInterfaceConfig(StartupConfig & cfg);
+
+ private:
+
+ InterfaceMap mInterfaceList;
+ char xpath[MAX_XPATH];
+ sysrepo::S_Session mSess;
+ //string mVal;
+ /* function to get the data of Interfaces param*/
+ InterfaceMap getInterfaceConfig(sysrepo::S_Session sess);
+ Address getInterfaceData(sysrepo::S_Session sess, Interface inf);
+ char * getInterfaceXpath( std::string sInf, std::string param);
+ std::string getData(sysrepo::S_Session sess,char* xpath);
+ std::string interfaceToString(Interface inf);
+ bool printInterfaceConfig();
+ bool writeInterfaceConfig();
+
+};
+
+#endif
+
+/**********************************************************************
+ End of file
+**********************************************************************/
/* This file contains methods of Session/Connection creation and Subscription to
YANG modules */
+#include <stdio.h>
+#include <stdlib.h>
+#include "sysrepo.h"
#include "SessionHandler.hpp"
+#include "InitConfig.hpp"
+#include <iostream>
-
+using namespace std;
/* Default constructor */
SessionHandler::SessionHandler()
{
{
try
{
+ O1_LOG("\nO1 SessionHandler : Initialization done");
mConn = createConnection();
+ O1_LOG("\nO1 SessionHandler : Initialization done");
mSess = createSession(mConn);
mSub = createSubscribe(mSess);
O1_LOG("\nO1 SessionHandler : Initialization done");
+ //InitConfig initConf;
+ InitConfig::instance().init(mSess);
return true;
}
catch( const std::exception& e )
#include "TcpServer.hpp"
#include "Alarm.hpp"
#include "AlarmManager.hpp"
+#include "Config.h"
#include "GlobalDefs.hpp"
#include <iostream>
#include <cstdio>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
+#include "InitConfig.hpp"
using std::map;
using std::pair;
}
-/**********************************************************************
- Description : Read the data from the connected client application
- Params[In] : fd - File descriptor
- Return : int - No of bytes read
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Read the data from the connected client application
+ *
+ * @details
+ *
+ * Function : readMessage
+ *
+ * Functionality:
+ * - Reads the data from the connected client application
+ *
+ * @params[in] File descriptor
+ * @return No. of bytes read
+ *
+ ******************************************************************/
int TcpServer::readMessage(int fd)
{
- AlarmRecord alrmRec;
- bzero(&alrmRec,sizeof(alrmRec));
- int nbytes = read (fd, &alrmRec, sizeof(alrmRec));
+ AlarmRecord *alrmRec = NULL;
+ char recvBuf[BUFLEN];
+ Alarm alrm;
+ bzero(&recvBuf,sizeof(recvBuf));
+
+ int nbytes = read (fd, &recvBuf, sizeof(recvBuf));
+
if (nbytes > 0)
{
- Alarm alrm;
- uint16_t alrmId;
- O1_LOG("\nO1 TcpServer :\nAction %d\nalarm ID %s\n%d\n%s\n%d\n%s\n%s\nbytes %d",
- alrmRec.msgHeader.action,
- alrmRec.alarmId,
- alrmRec.perceivedSeverity,
- alrmRec.additionalText,
- alrmRec.eventType,
- alrmRec.specificProblem,
- alrmRec.additionalInfo,
+ MsgHeader *msgHdr = (MsgHeader*)recvBuf;
+
+ O1_LOG("\nO1 TcpServer :\nBuf size %ld", sizeof(recvBuf));
+ O1_LOG("\nO1 TcpServer :\nMsgType %d",msgHdr->msgType);
+ O1_LOG("\nO1 TcpServer :\nAction %d",msgHdr->action);
+
+ if ( msgHdr->msgType == ALARM ){
+ uint16_t alrmId;
+ alrmRec = (AlarmRecord*) recvBuf;
+ O1_LOG("\nO1 TcpServer :\nAction %d\nalarm ID %s\n%d\n%s\n%d\n%s\n%s\nbytes %d",
+ alrmRec->msgHeader.action,
+ alrmRec->alarmId,
+ alrmRec->perceivedSeverity,
+ alrmRec->additionalText,
+ alrmRec->eventType,
+ alrmRec->specificProblem,
+ alrmRec->additionalInfo,
nbytes
);
- /*Fill the alarm structure */
- sscanf(alrmRec.alarmId,"%hu",&alrmId);
- alrm.setAlarmId(alrmId);
- alrm.setPerceivedSeverity(alrmRec.perceivedSeverity);
- alrm.setAdditionalText(alrmRec.additionalText);
- alrm.setEventType(alrmRec.eventType);
- alrm.setSpecificProblem(alrmRec.specificProblem);
- alrm.setAdditionalInfo(alrmRec.additionalInfo);
+ /*Fill the alarm structure */
+ sscanf(alrmRec->alarmId,"%hu",&alrmId);
+ alrm.setAlarmId(alrmId);
+ alrm.setPerceivedSeverity(alrmRec->perceivedSeverity);
+ alrm.setAdditionalText(alrmRec->additionalText);
+ alrm.setEventType(alrmRec->eventType);
+ alrm.setSpecificProblem(alrmRec->specificProblem);
+ alrm.setAdditionalInfo(alrmRec->additionalInfo);
+ }
- switch(alrmRec.msgHeader.action)
+ switch(msgHdr->action)
{
- case RAISE:
+ case RAISE_ALARM:
if(AlarmManager::instance().raiseAlarm(alrm))
{
- O1_LOG("\nO1 TcpServer : Alarm raised for alarm Id %s", alrmRec.alarmId);
+ O1_LOG("\nO1 TcpServer : Alarm raised for alarm Id %s", alrmRec->alarmId);
}
else
{
- O1_LOG("\nO1 TcpServer : Error in raising alarm for alrm Id %s", alrmRec.alarmId);
+ O1_LOG("\nO1 TcpServer : Error in raising alarm for alrm Id %s", alrmRec->alarmId);
}
break;
- case CLEAR:
+ case CLEAR_ALARM:
if(AlarmManager::instance().clearAlarm(alrm))
{
- O1_LOG("\nO1 TcpServer : Alarm cleared for alarm Id %s", alrmRec.alarmId);
+ O1_LOG("\nO1 TcpServer : Alarm cleared for alarm Id %s", alrmRec->alarmId);
}
else
{
- O1_LOG("\nO1 TcpServer : Error in clearing alarm for alarm Id %s", alrmRec.alarmId);
+ O1_LOG("\nO1 TcpServer : Error in clearing alarm for alarm Id %s", alrmRec->alarmId);
}
break;
+ case GET_STARTUP_CONFIG:
+ {
+ StartupConfig cfg;
+ InitConfig::instance().getCurrInterfaceConfig(cfg);
+ O1_LOG("\nO1 TcpServer : cfg.DU_IPV4_Addr [%s]", cfg.DU_IPV4_Addr);
+ O1_LOG("\nO1 TcpServer : cfg.DU_Port [%d]", cfg.DU_Port);
+ O1_LOG("\nO1 TcpServer : cfg.CU_IPV4_Addr [%s]", cfg.CU_IPV4_Addr);
+ O1_LOG("\nO1 TcpServer : cfg.CU_Port [%d]", cfg.CU_Port);
+ O1_LOG("\nO1 TcpServer : cfg.RIC_IPV4_Addr [%s]", cfg.RIC_IPV4_Addr);
+ O1_LOG("\nO1 TcpServer : cfg.RIC_Port [%d]", cfg.RIC_Port);
+ if (write (fd, &cfg, sizeof(cfg)) < 0)
+ {
+ O1_LOG("\nO1 TcpServer : Error sending startup configuration \n");
+ }
+ break;
+ }
default:
O1_LOG("\nO1 TcpServer : No action performed");
break;
}
-/**********************************************************************
- Description : Open a TCP socket and bind on the port
- Params[In] : None
- Return : O1::SUCCESS - socket open and bind successful
- O1::FAILURE - socket open and bind failed
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Open a TCP socket and bind on the port
+ *
+ * @details
+ *
+ * Function : makeSocket
+ *
+ * Functionality:
+ * - Opens a TCP socket and bind on the port
+ *
+ * @params[in] void
+ * @return O1:SUCCESS - success
+ * O1:FAILURE - failure
+ ******************************************************************/
int TcpServer::makeSocket()
{
struct sockaddr_in name;
}
-/**********************************************************************
- Description : Start TCP server in thread
- Params[In] : None
- Return : true - task launched in pthread successfully
- false - task failed to launch
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Start TCP server in thread
+ *
+ * @details
+ *
+ * Function : start
+ *
+ * Functionality:
+ * - Start TCP server in thread
+ *
+ * @params[in] void
+ * @return true - success
+ * false - failure
+ ******************************************************************/
bool TcpServer::start()
{
return (pthread_create(&mThreadId, NULL, task, this) == 0);
}
-/**********************************************************************
- Description : A TCP server to handle multiple connection using
- select multiplexing
- Params[In] : None
- Return : true - task launched in pthread successfully
- false - task failed to launch
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief A TCP server to handle multiple connection
+ *
+ * @details
+ *
+ * Function : run
+ *
+ * Functionality:
+ * - A TCP server to handle multiple connection
+ * Uses select multiplexing
+ *
+ * @params[in] void
+ * @return true - success
+ * false - failure
+ ******************************************************************/
bool TcpServer::run()
{
}
-/**********************************************************************
- Description : Static function for launching a TCP server instance
- in a thread
- Params[In] : TcpServer instance
- Return : NULL
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Static function for launching a TCP server instance
+ * in a thread
+ *
+ * @details
+ *
+ * Function : task
+ *
+ * Functionality:
+ * - Static function for launching a TCP server instance
+ * in a thread
+ *
+ * @params[in] TcpServer instance
+ * @return void
+ ******************************************************************/
void* TcpServer::task(void *args)
{
TcpServer *tcpServer = (TcpServer*)args;
}
-/**********************************************************************
- Description : Wait for the thread to complete in the parent process
- Params[In] : None
- Return : true - pthread join success
- false - pthread join failed
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Wait for the thread to complete in the parent process
+ *
+ * @details
+ *
+ * Function : wait
+ *
+ * Functionality:
+ * - Waits for the thread to complete in the parent process
+ *
+ * @params[in] void
+ * @return true : success
+ * false : failure
+ ******************************************************************/
bool TcpServer::wait()
{
return (pthread_join(mThreadId,NULL) == 0);
#include <pthread.h>
using std::string;
+#define BUFLEN 512
class TcpServer
{
#define __ALARM_H__
#include <string.h>
+#include "CommonMessages.h"
#define ALRM_ID_SIZE 10
#define OBJ_INST_SIZE 15
#define TEXT_SIZE 50
TIME_DOMAIN_VIOLATION = 11
}EventType;
-typedef enum
-{
- CLEAR = 0,
- RAISE = 1
-}AlarmAction;
-
-typedef struct
-{
- AlarmAction action;
-}MsgHeader;
typedef struct
{
#include "TcpClient.h"
-/**********************************************************************
- Description : Raise an alarm by sending alarm info to O1 module over
- TCP socket with action set to RAISE
- Params[In] : Alarm information
- Return : ROK - success
- RFAILED - failure
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Raise an alarm
+ *
+ * @details
+ *
+ * Function : raiseAlarm
+ *
+ * Functionality:
+ * - Raise an alarm by sending alarm info to O1 module over
+ * TCP socket with action set to RAISE
+ *
+ * @params[in] alarm information
+ * @return ROK - success
+ * RFAILED - failure
+ ******************************************************************/
uint8_t raiseAlarm(AlarmRecord* alrm)
{
if (openSocket(TCP_SERVER_IP,TCP_PORT) == RFAILED)
{
return RFAILED;
}
- alrm->msgHeader.action = RAISE;
+ alrm->msgHeader.msgType = ALARM;
+ alrm->msgHeader.action = RAISE_ALARM;
if (sendData(alrm,sizeof(AlarmRecord)) < 0 )
{
closeSocket();
return ROK;
}
-/**********************************************************************
- Description : Clears an alarm raised earlier by sending the alrm
- information to O1 module over TCP socket with action
- set to CLEAR
- Params[In] : Alarm information
- Return : ROK - success
- RFAILED - failure
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Clear an alarm
+ *
+ * @details
+ *
+ * Function : clearAlarm
+ *
+ * Functionality:
+ * - Clears an alarm raised earlier by sending the alrm
+ * information to O1 module over TCP socket with action
+ * set to CLEAR
+ *
+ * @params[in] alarm information
+ * @return ROK - success
+ * RFAILED - failure
+ ******************************************************************/
uint8_t clearAlarm(AlarmRecord* alrm)
{
if (openSocket(TCP_SERVER_IP,TCP_PORT) == RFAILED)
{
return RFAILED;
}
- alrm->msgHeader.action = CLEAR;
+ alrm->msgHeader.msgType = ALARM;
+ alrm->msgHeader.action = CLEAR_ALARM;
if (sendData(alrm,sizeof(AlarmRecord)) < 0)
{
closeSocket();
}
-/**********************************************************************
- Description : Fill the cell specific alarm parmeters and generate
- the alarm
- Params[In] : alarm Id, cell Id
- Return : ROK - success
- RFAILED - failure
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Raise a cell specific alarm
+ *
+ * @details
+ *
+ * Function : raiseCellAlrm
+ *
+ * Functionality:
+ * - Fills the cell specific alarm parmeters and generate
+ * the alarm
+ *
+ * @params[in] alarm Id, cell Id
+ * @return ROK - success
+ * RFAILED - failure
+ ******************************************************************/
uint8_t raiseCellAlrm(uint16_t alrmId, uint16_t cellId)
{
char buff[BUFF_SIZE];
return raiseAlarm(&alrm);
}
-/**********************************************************************
- Description : Clear the cell alarm
- Params[In] : alarm Id
- Return : ROK - success
- RFAILED - failure
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Clear the cell alarm
+ *
+ * @details
+ *
+ * Function : clearCellAlrm
+ *
+ * Functionality:
+ * - Clears the cell specific alarm using alarm id
+ *
+ * @params[in] alarm Id
+ * @return ROK - success
+ * RFAILED - failure
+ ******************************************************************/
uint8_t clearCellAlrm(uint16_t alrmId)
{
AlarmRecord alrm;
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+/* This file contains definitions of common message structures */
+
+#ifndef __COMMON_MESSAGES_H__
+#define __COMMON_MESSAGES_H__
+
+
+typedef enum
+{
+ RAISE_ALARM,
+ CLEAR_ALARM,
+ GET_STARTUP_CONFIG
+}MsgAction;
+
+typedef enum
+{
+ ALARM,
+ CONFIGURATION
+}MsgType;
+
+typedef struct
+{
+ MsgType msgType;
+ MsgAction action;
+}MsgHeader;
+
+#endif
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+/* This file contains definitions of startup configuration structure */
+
+#include "Config.h"
+#include "ssi.h"
+#include "GlobalDefs.h"
+#include "TcpClient.h"
+
+StartupConfig g_cfg;
+
+/*******************************************************************
+ *
+ * @brief Get the startup config from Netconf
+ *
+ * @details
+ *
+ * Function : getStartupConfig
+ *
+ * Functionality:
+ * - Get the start up IP and port for DU,CU and RIC
+ *
+ * @params[in] pointer to StartupConfig
+ * @return ROK - success
+ * RFAILED - failure
+ ******************************************************************/
+uint8_t getStartupConfig(StartupConfig *cfg)
+{
+ O1_LOG("\nCONFIG : getStartupConfig ------ \n");
+ MsgHeader msg;
+ msg.msgType = CONFIGURATION;
+ msg.action = GET_STARTUP_CONFIG;
+ if (openSocket(TCP_SERVER_IP,TCP_PORT) == RFAILED)
+ {
+ return RFAILED;
+ }
+ if (sendData(&msg,sizeof(msg)) < 0 )
+ {
+ closeSocket();
+ return RFAILED;
+ }
+ if (receiveData(cfg, sizeof(StartupConfig)) < 0)
+ {
+ closeSocket();
+ return RFAILED;
+ }
+ O1_LOG("\nCONFIG : ip du %s\n",cfg->DU_IPV4_Addr );
+ O1_LOG("\nCONFIG : ip cu %s\n",cfg->CU_IPV4_Addr );
+ O1_LOG("\nCONFIG : ip ric %s\n",cfg->RIC_IPV4_Addr );
+ O1_LOG("\nCONFIG : port cu %hu\n",cfg->CU_Port);
+ O1_LOG("\nCONFIG : port du %hu\n",cfg->DU_Port);
+ O1_LOG("\nCONFIG : port ric %hu\n",cfg->RIC_Port);
+
+ closeSocket();
+ return ROK;
+}
+
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+/* This file contains definitions of startup configuration structure */
+
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#include <stdint.h>
+#include <CommonMessages.h>
+
+#define IPV4_LEN 16
+#define PORT_LEN 10
+
+typedef struct
+{
+ char DU_IPV4_Addr[IPV4_LEN];
+ char CU_IPV4_Addr[IPV4_LEN];
+ char RIC_IPV4_Addr[IPV4_LEN];
+ uint16_t CU_Port;
+ uint16_t DU_Port;
+ uint16_t RIC_Port;
+}StartupConfig;
+
+uint8_t getStartupConfig();
+
+#endif
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+################################################################################
+*******************************************************************************/
+
+/* This file contains definitions of common message structures */
+
+#ifndef __MESSAGE_H__
+#define __MESSAGE_H__
+
+#include <string.h>
+
+typedef enum
+{
+ RAISE_ALARM,
+ CLEAR_ALARM,
+ GET_STARTUP_CONFIG
+}MsgAction;
+
+typedef enum
+{
+ ALARM,
+ CONFIGURATION
+}MsgType;
+
+typedef struct
+{
+ MsgType msgType;
+ MsgAction action;
+}MsgHeader;
+
+#endif
+
+/**********************************************************************
+ End of file
+**********************************************************************/
static const char* s_hostName = NULL;
-/**********************************************************************
- Description : Initilize the sockadd_in structure
- Params[In] : None
- Return : ROK - success
- RFAILED - failure
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Initilize the sockadd_in structure
+ *
+ * @details
+ *
+ * Function : initSockaddr
+ *
+ * Functionality:
+ * - Initilizes the sockadd_in structure
+ *
+ * @params[in] void
+ * @return ROK - success
+ * RFAILED - failure
+ ******************************************************************/
static uint8_t initSockaddr()
{
}
-/**********************************************************************
- Description : Open a TCP socket
- Params[In] : hostName, port
- Return : ROK - success
- RFAILED - failure
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Open a TCP socket
+ *
+ * @details
+ *
+ * Function : openSocket
+ *
+ * Functionality:
+ * - Opens a TCP socket
+ *
+ * @params[in] hostname, port
+ * @return ROK - success
+ * RFAILED - failure
+ ******************************************************************/
uint8_t openSocket(const char* hostName, const uint16_t port)
{
/* Create the socket. */
}
-/**********************************************************************
- Description : Send the message on TCP socket
- Params[In] : message, size of the message
- Return : Number of bytes sent
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Send message over TCP socket
+ *
+ * @details
+ *
+ * Function : sendData
+ *
+ * Functionality:
+ * - Sends message over TCP socket
+ *
+ * @params[in] message, size of the message
+ * @return Number of bytes sent
+ *
+ ******************************************************************/
int sendData(void* data, const int size)
{
int nbytes = write (s_sock, data, size);
return nbytes;
}
-/**********************************************************************
- Description : Close the TCP socket
- Params[In] : None
- Return : ROK - success
- RFAILED - failure
-**********************************************************************/
+/*******************************************************************
+ *
+ * @brief Recieve message over TCP socket
+ *
+ * @details
+ *
+ * Function : receiveData
+ *
+ * Functionality:
+ * - Recieves message over TCP socket
+ *
+ * @params[in] message, size of the message
+ * @return Number of bytes received
+ *
+ ******************************************************************/
+int receiveData(void* data, const int size)
+{
+ int nbytes = read (s_sock, data, size);
+ if (nbytes < 0)
+ {
+ O1_LOG("\nO1 TcpClient : Error reading. %d bytes sent", nbytes);
+ }
+ return nbytes;
+}
+
+/*******************************************************************
+ *
+ * @brief Close the TCP socket
+ *
+ * @details
+ *
+ * Function : closeSocket
+ *
+ * Functionality:
+ * - Closes the TCP socket
+ *
+ * @params[in] message, size of the message
+ * @return ROK - success
+ * RFAILED - failure
+ ******************************************************************/
uint8_t closeSocket()
{
if( close(s_sock) != 0 )
uint8_t openSocket(const char*, const uint16_t);
int sendData(void*, const int);
+int receiveData(void* data, const int size);
uint8_t closeSocket();
#endif
#include "ric_stub_sctp.h"
#include "du_log.h"
+#ifdef O1_ENABLE
+#include "Config.h"
+#endif
+
#define RIC_ID 1
#define RIC_NAME "ORAN_OAM_RIC"
-#define DU_IP_V4_ADDR "192.168.130.81"
-#define RIC_IP_V4_ADDR "192.168.130.80"
+
#define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
#define RIC_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
+
+#ifndef O1_ENABLE
+
+#define DU_IP_V4_ADDR "192.168.130.81"
+#define RIC_IP_V4_ADDR "192.168.130.80"
#define DU_PORT 36422
#define RIC_PORT 36422
+
+#endif
+
#define RRC_VER 0
#define EXT_RRC_VER 5
#define PLMN_MCC0 3
#define PLMN_MNC1 8
#define PLMN_MNC2 0
+#ifdef O1_ENABLE
+
+extern StartupConfig g_cfg;
+
+#endif
+
/*******************************************************************
*
* @brief Handles SCTP notification
DU_LOG("\nReading RIC configurations");
+#ifdef O1_ENABLE
+ if( getStartupConfig(&g_cfg) != ROK )
+ {
+ RETVALUE(RFAILED);
+ }
+ cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
+ cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
+
+ ricCfgParams.sctpParams.duPort = g_cfg.RIC_Port;
+ ricCfgParams.sctpParams.ricPort = g_cfg.RIC_Port;
+#else
cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
-
+
+ ricCfgParams.sctpParams.duPort = DU_PORT;
+ ricCfgParams.sctpParams.ricPort = RIC_PORT;
+#endif
+
ricCfgParams.ricId = RIC_ID;
strcpy(ricCfgParams.ricName, RIC_NAME);
/* DU IP Address and Port*/
ricCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
ricCfgParams.sctpParams.duIpAddr.ipV6Pres = false;
- ricCfgParams.sctpParams.duPort = DU_PORT;
/* RIC IP Address and Port*/
ricCfgParams.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
ricCfgParams.sctpParams.ricIpAddr.ipV6Pres = false;
- ricCfgParams.sctpParams.ricPort = RIC_PORT;
/*PLMN*/
ricCfgParams.plmn.mcc[0] = PLMN_MCC0;