#CMD /opt/o-du-l2/bin/odu/odu
#cleanup netconf folder and install libraries
-RUN cd build/o1 && rm -rf netconf && /bin/bash install_lib.sh -c
-
-RUN cd build/o1 && make o1 MACHINE=BIT64
+RUN cd build/scripts && /bin/bash install_lib.sh -c
# Install the data models based on the ODU yang model
-RUN /usr/local/bin/sysrepoctl -i build/o1/yang/o-ran-sc-odu-alarm-v1.yang
+RUN /usr/local/bin/sysrepoctl -i build/yang/o-ran-sc-odu-alarm-v1.yang
+
+RUN cd build/odu && make clean_odu odu MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/RRC
ifeq ($(O1_ENABLE),YES)
-I_OPTS+=-I$(ROOT_DIR)/src/o1/o1_client
+I_OPTS+=-I$(ROOT_DIR)/src/o1
endif
#-------------------------------------------------------------#
I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/E2AP
ifeq ($(O1_ENABLE),YES)
-I_OPTS+=-I$(ROOT_DIR)/src/o1/o1_client
+I_OPTS+=-I$(ROOT_DIR)/src/o1
endif
#-------------------------------------------------------------#
include ../common/env.mak
COLOR=$(COLOR_RED)
-ROOT_DIR=$(patsubst %/build/o1,%,$(BUILD_DIR))
-
SRC_DIR=$(ROOT_DIR)/src/o1/
CPP_SRCS=$(wildcard $(SRC_DIR)/*.cpp)
CPP_OBJS=$(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(CPP_SRCS))
+PLTFRM_FLAGS=
lib: $(LIB_DIR)/libo1.a
include $(COM_BUILD_DIR)/compile.mak
L_OPTS+= -lsysrepo-cpp -lyang-cpp
L_OPTS+= -lm -lpthread
I_OPTS=-I$(ROOT_DIR)/src/o1/
-I_OPTS+=-I$(ROOT_DIR)/src/o1/o1_client
#-------------------------------------------------------------#
#Linker macros
+++ /dev/null
-################################################################################
-# Copyright (c) [2017-2019] [Radisys] #
-# #
-# 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 is makefile for O1 client
-
-include ../common/rsys_fancy.mak
-include ../common/env.mak
-COLOR=$(COLOR_RED)
-
-SRC_DIR=$(ROOT_DIR)/src/o1/o1_client
-C_SRCS=$(wildcard $(SRC_DIR)/*.c)
-C_OBJS=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(C_SRCS))
-
-lib: $(LIB_DIR)/libo1client.a
-include $(COM_BUILD_DIR)/compile.mak
-
-L_OPTS=-lsysrepo -lyang
-L_OPTS+= -lsysrepo-cpp -lyang-cpp
-L_OPTS+= -lm -lpthread
-I_OPTS+=-I$(ROOT_DIR)/src/o1/o1_client
-I_OPTS+=-I$(ROOT_DIR)/src/cm
-I_OPTS+=-I$(ROOT_DIR)/src/mt
-
-#-------------------------------------------------------------#
-#Linker macros
-#-------------------------------------------------------------#
-$(LIB_DIR)/libo1client.a:$(C_OBJS) $(C_WO_PED_OBJS)
- @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)"
- $(Q)ar -cr $(LIB_DIR)/libo1client.a $(C_OBJS) $(C_WO_PED_OBJS)
-
-#-------------------------------------------------------------#
-#Clean macros
-#-------------------------------------------------------------#
-clean:
- @echo -e "$(COLOR_RED)Cleaning O1 Client$(REVERT_COLOR)"
- $(Q)\rm -f $(LIB_DIR)/libo1client.a $(C_OBJS) $(C_WO_PED_OBJS) $(LOG_FILES) $(BAK_FILES)
-
-#**********************************************************************
-# End of file
-#**********************************************************************
I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/E2AP
ifeq ($(O1_ENABLE),YES)
-I_OPTS+=-I$(ROOT_DIR)/src/o1/o1_client
+I_OPTS+=-I$(ROOT_DIR)/src/o1
endif
#-------------------------------------------------------------#
#Linker macros
--- /dev/null
+<odu xmlns="urn:o-ran:odu:interface:1.0">
+<interfaces>
+<interface>
+<interface-name>odu</interface-name>
+<interface-address>192.168.130.81</interface-address>
+<port>38472</port>
+</interface>
+<interface>
+<interface-name>ocu</interface-name>
+<interface-address>192.168.130.82</interface-address>
+<port>38472</port>
+</interface>
+<interface>
+<interface-name>ric</interface-name>
+<interface-address>192.168.130.80</interface-address>
+<port>36422</port>
+</interface>
+</interfaces>
+</odu>
+++ /dev/null
-################################################################################
-# Copyright (c) [2017-2019] [Radisys] #
-# #
-# 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. #
-################################################################################
-
-# Master makefile for O1 module
-
-# Identify the location our software which is used by rest
-# of the build scripts
-
-include ../common/rsys_fancy.mak
-include ../common/env.mak
-
-ROOT_DIR=$(patsubst %/build/o1,%,$(BUILD_DIR))
-RULE=$(COLOR_RED)
-OPTS=$(COLOR_GREEN)
-NORM=$(REVERT_COLOR)
-
-# For improved speed
-CPUINFO=`cat /proc/cpuinfo | grep processor| wc -l`
-ifeq ($(CPUINFO), 1)
- NUM_PARALLEL=1
-else
- NUM_PARALLEL=$(shell echo $(CPUINFO) - 1 |bc)
-endif
-
-ifeq ($(FAST), 1)
- NUM_PARALLEL=$(shell echo $(CPUINFO) + 2 |bc)
-endif
-
-PARALLEL_COMP=-j $(NUM_PARALLEL)
-
-# Different options to O1 build
-# # Other apsects of tool chain set here
-# # These should be made available appropriately to the builds
-ifeq ($(MACHINE),BIT64)
-CC =gcc -m64
-CCPP =g++ -m64
-else
-CC =gcc -m32
-CCPP =g++ -m32
-endif
-
-CC1= $(CC)
-CCPP1= $(CCPP)
-
-
-# The include options get merged with the options needed by
-# # the called makefiles and hence we export these to make them
-# # available to them.
-BUILD=i686-linux
-
-# The called makefiles depend on these macros and these need to be exported
-export PLTFRM
-export PLTFRM_FLAGS
-export BUILD
-export I_OPTS
-
-# Add to the linker options the platform specific components
-#L_OPTS+=-lnsl -lrt -lm -lpthread -lsctp
-L_OPTS=-lsysrepo -lyang
-L_OPTS+= -lsysrepo-cpp -lyang-cpp
-L_OPTS+= -lm -lpthread
-
-# Export some of the flags expected from the command line.
-# # These macros are made available for the makefiles called from this makefile
-export MACHINE
-
-help:
- @echo -e "******************************************************************"
- @echo -e "BUILD COMMAND DESCRIPTION "
- @echo -e "------------------------------------------------------------------"
- @echo -e "$(RULE)o1 - Builds all components of O1$(NORM)"
- @echo -e "$(RULE)clean_o1 - clean up O1$(NORM)"
- @echo -e "$(RULE)clean_all - cleanup O1 and all directories$(NORM)"
- @echo -e "$(OPTS) options: $(NORM)"
- @echo -e "$(OPTS) MACHINE=BIT64/BIT32 - Default is BIT32$(NORM)"
- @echo -e "******************************************************************"
-
-prepare_dirs:
- $(Q)echo -e "Preparing directories for build..."
- $(Q)mkdir -p $(BUILD_DIR)/obj/o1
- $(Q)mkdir -p $(LIB_ROOT)/o1
- $(Q)mkdir -p $(BIN_DIR)/o1
- $(Q)echo -e "Directories are successfully prepared"
-
-o1_mod:
- $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1.mak OBJ_DIR=$(OBJ_ROOT)/o1 LIB_DIR=$(LIB_ROOT)/o1 LOG_DIR=$(LOG_ROOT)/o1 CC='$(CCPP1)'
-
-link_o1: o1_mod
- $(Q)$(CCPP1) -g -o $(OBJ_ROOT)/o1/o1 -Wl,-R../lib/:. $(OBJ_ROOT)/o1/*.o\
- $(L_OPTS) -L$(LIB_ROOT)/o1
-
-clean_o1:
- $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1.mak clean OBJ_DIR=$(OBJ_ROOT)/o1 LIB_DIR=$(LIB_ROOT)/o1 LOG_DIR=$(LOG_ROOT)/o1 CC='$(CC1)'
- $(Q)rm -rf $(OBJ_ROOT)/o1/*
- $(Q)rm -rf $(LIB_ROOT)/o1/*
- $(Q)rm -rf $(BIN_DIR)/o1/*
- $(Q)echo -e "***** O1 CLEAN COMPLETE *****"
-
-clean_all: clean_o1
- $(Q)rm -rf $(OBJ_ROOT)
- $(Q)rm -rf $(LIB_ROOT)
- $(Q)rm -rf $(LOG_ROOT)
- $(Q)rm -rf $(BIN_DIR)
-
-copy_build: link_o1
- $(Q)cp -f ./obj/o1/o1 ./bin/o1
- $(Q)echo -e "***** O1 BUILD COMPLETE *****"
-
-o1: prepare_dirs copy_build
-
-#**********************************************************************
-# End of file
-#**********************************************************************
-lrte_gro -lrte_pmd_ark -lrte_pmd_i40e -lrte_pmd_sw_event
endif
+ifeq ($(O1_ENABLE),YES)
+ L_OPTS+=-lsysrepo -lyang
+ L_OPTS+=-lsysrepo-cpp -lyang-cpp
+ L_OPTS+=-lstdc++
+endif
+
# Export some of the flags expected from the command line.
# # These macros are made available for the makefiles called from this makefile
export BOARD
$(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)'
+ $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CCPP1)'
endif
link_du: du
$(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)'
+ $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CCPP1)'
endif
$(Q)rm -rf $(OBJ_ROOT)/odu/*
$(Q)rm -rf $(LIB_ROOT)/odu/*
$(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)'
+ $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1.mak OBJ_DIR=$(OBJ_ROOT)/cu_stub LIB_DIR=$(LIB_ROOT)/cu_stub LOG_DIR=$(LOG_ROOT)/cu_stub CC='$(CCPP1)'
endif
clean_cu:
$(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)'
+ $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1.mak clean OBJ_DIR=$(OBJ_ROOT)/cu_stub LIB_DIR=$(LIB_ROOT)/cu_stub LOG_DIR=$(LOG_ROOT)/cu_stub CC='$(CCPP1)'
endif
$(Q)rm -rf $(OBJ_ROOT)/cu_stub/*
$(Q)rm -rf $(LIB_ROOT)/cu_stub/*
$(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)'
+ $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1.mak OBJ_DIR=$(OBJ_ROOT)/ric_stub LIB_DIR=$(LIB_ROOT)/ric_stub LOG_DIR=$(LOG_ROOT)/ric_stub CC='$(CCPP1)'
endif
clean_ric:
$(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)'
+ $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1.mak clean OBJ_DIR=$(OBJ_ROOT)/ric_stub LIB_DIR=$(LIB_ROOT)/ric_stub LOG_DIR=$(LOG_ROOT)/ric_stub CC='$(CCPP1)'
endif
$(Q)rm -rf $(OBJ_ROOT)/ric_stub/*
$(Q)rm -rf $(LIB_ROOT)/ric_stub/*
#variable declaration
CURRENT_PATH=`pwd`
HOME="$CURRENT_PATH/../.."
-MAKE_PATH="$HOME/build/o1"
-NETCONF_PATH="$HOME/build/o1/netconf"
-SYSREPOCTL_PATH="$NETCONF_PATH/sysrepo/build/sysrepoctl"
-YANG_PATH="$HOME/build/o1/yang"
+NETCONF_PATH="$HOME/build/netconf"
+YANG_PATH="$HOME/build/yang"
+CONFIG_PATH="$HOME/build/config"
+STARTUP_CONFIG="startup_config.xml"
INSTALL="netconf"
CLEANUP="no"
echo -e "$1 "
}
-
-
-#functions definitions
-#TBD: install only mandatory packages
-
#install pre-requisite packages
prerequisite_netconf() {
#install netconf libraries
install_netconf_lib() {
- #with sudo we can not create new user so we need to create it manually using
- #root credentials.
-
- #$SUDO adduser --system netconf && \
- # echo "netconf:netconf" | chpasswd
-
- #$SUDO mkdir -p /home/netconf/.ssh && \
- # ssh-keygen -A && \
- # ssh-keygen -t dsa -P '' -f /home/netconf/.ssh/id_dsa && \
- # cat /home/netconf/.ssh/id_dsa.pub > /home/netconf/.ssh/authorized_keys
-
if [[ "$CLEANUP" == "cleanup" ]]; then
rm -rf $NETCONF_PATH
log_warning "DELETED $NETCONF_PATH"
#install yang module
install_yang_module() {
- $SYSREPOCTL_PATH -i "$YANG_PATH/o-ran-sc-du-alarm-v1.yang"
+ sysrepoctl -i "$YANG_PATH/o-ran-sc-odu-alarm-v1.yang"
+ sysrepoctl -i "$YANG_PATH/o-ran-sc-odu-interface-v1.yang"
+ sysrepocfg --import="$CONFIG_PATH/$STARTUP_CONFIG" --datastore startup --module o-ran-sc-odu-interface-v1
}
}
#start execution / function calls
-if [[ "$#" -ge 2 ]] ; then
+if [[ "$#" -ge 3 ]] ; then
log_error " NUMBER OF PARAMETER : $# "
show_help
fi
--- /dev/null
+#!/bin/bash
+
+if [ "$1" == "" ]
+then
+ echo Usage : netopeer.sh [start] [stop]
+fi
+
+if [ "$1" == "start" ]
+then
+ netopeer2-server -d -v2 > /var/log/netopeer2-server.log 2>&1 &
+fi
+
+if [ "$1" == "stop" ]
+then
+ kill -9 `pidof netopeer2-server`
+fi
1. l2/build/ : contains files required to compile the code
a. common : contains individual module's makefile
b. odu : contains main makefile to generate an executable binary
- c. scripts: contains scripts for logging
- d. o1 : contains main makefile to generate an executable binary
+ c. scripts: contains scripts for logging, installing netconf libraries and starting netopeer server
+ d. config : contains the configuration files
+ e. yang : contains the YANG modules
2. l2/docs/ : contains README and other configuration files for building docs
b. On CentOS : sudo yum install -y libpcap-devel
-C. Pre-requisite for running O1 module:
----------------------------------------
-Install netconf server
-----------------------
+C. Pre-requisite for O1 Interface (Required only if run with O1 interface enabled)
+-----------------------------------------------------------------------------------
+1. Setup netconf server
-1. Create new netconf user (login with root user and run following command)
+ Create new netconf user (login with root user and run following commands)
$adduser --system netconf && \
echo "netconf:netconf" | chpasswd
ssh-keygen -A && \
ssh-keygen -t dsa -P '' -f /home/netconf/.ssh/id_dsa && \
cat /home/netconf/.ssh/id_dsa.pub > /home/netconf/.ssh/authorized_keys
-2. Install netconf packages.
- $cd l2/build/o1/
+ Install netconf packages.
+ $cd l2/build/scripts
$chmod +x install_lib.sh
- $ ./install_lib.sh
+ $ ./install_lib.sh -c
-Install the yang module
------------------------
-1. cd l2/build/o1/yang
- sysrepoctl -i o-ran-sc-odu-alarm-v1.yang
- sysrepoctl -i o-ran-sc-odu-interface-v1.yang
+2. Start Netopeer2-server:
+ $cd l2/build/scripts
+ $./netopeer-server.sh start
+
+3. Install the yang modules
+ $cd l2/build/yang
+ $sysrepoctl -i o-ran-sc-odu-alarm-v1.yang
+ $sysrepoctl -i o-ran-sc-odu-interface-v1.yang
+
+4. Configure the startup IP and Port configurations for DU, CU and RIC
+
+ $cd l2/build/config
+
+ Open the startup_config.xml and edit the desired IP and Port for CU, DU and RIC.
+ Then load the configuration in the sysrepo running datastore using the command below
+
+ $sysrepocfg --import=startup_config.xml --datastore running --module o-ran-sc-odu-interface-v1
D. How to Clean and Build:
4. Cleaning ODU, CU Stub and RIC Stub:
make clean_all
-5. Building ODU binary with O1 interface enabled:
+
+E. How to Clean and Build with O1 interface enabled (Requires pre-requisite steps in section C)
+------------------------------------------------------------------------------------------------
+
+1. Building ODU binary:
a. Build folder
cd l2/build/odu
- b. Building ODU with O1 module enabled:
+ b. Building ODU binary
make odu MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
c. Cleaning ODU binary
- make clean_odu MACHINE=BIT64 MODE=FDD
+ make clean_odu MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
- d. Build folder
- cd l2/build/o1
- e. Building O1 binary
- make o1 MACHINE=BIT64
- f. Cleaning O1 binary
- make clean_o1
+2. Building CU Stub binary:
+ a. Build folder
+ cd l2/build/odu
+ b. Building CU Stub binary
+ make cu_stub NODE=TEST_STUB MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
+ c. Cleaning CU Stub binary
+ make clean_cu NODE=TEST_STUB MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
+
+3. Building RIC Stub binary:
+ a. Build folder
+ cd l2/build/odu
+ b. Building RIC Stub binary
+ make ric_stub NODE=TEST_STUB MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
+ c. Cleaning RIC Stub binary
+ make clean_ric NODE=TEST_STUB MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
+
+4. Cleaning ODU, CU Stub and RIC Stub:
+ make clean_all
-E. How to execute:
+F. How to execute:
------------------
1. Assign virtual IP addresses as follows:
a. ifconfig <interface name>:ODU "192.168.130.81"
b. ifconfig <interface name>:CU_STUB "192.168.130.82"
c. ifconfig <interface name>:RIC_STUB "192.168.130.80"
-2. Execute O1 (only if O-DU is built with O1 interface enabled):
- a. O1 execution folder:
- cd l2/build/o1/bin/o1
- b. Run O1 binary:
- ./o1
+PS: If O1 interface is enabled, IP should match those configured in step C.4.
-3. Execute CU Stub:
+2. Execute CU Stub:
a. CU execution folder:
cd l2/bin/cu_stub
b. Run CU Stub binary:
./cu_stub
-4. Execute RIC Stub:
+3. Execute RIC Stub:
a. RIC execution folder:
cd l2/bin/ric_stub
b. Run RIC Stub binary:
./ric_stub
-5. Execute DU:
+4. Execute DU:
a. DU execution folder:
cd l2/bin/odu
b. Run ODU binary:
./odu
PS: CU stub and RIC stub must be run (in no particular sequence) before ODU
- If O1 module is enabled it must be run before ODU
-F. How to test with Intel L1:
+
+G. How to test with Intel L1:
-----------------------------
I. Compilation
./odu
-G. How to execute the Health Check : get alarm-list
+H. How to execute the Health Check : get alarm-list
----------------------------------------------------
Steps:
Here are the steps as executed in the terminal
- netopeer2-cli
+ $netopeer2-cli
> connect --login netconf
Interactive SSH Authentication
Type your password:
ODU - O1 Communication
^^^^^^^^^^^^^^^^^^^^^^
-O-DU High and O1 module communicate on a TCP socket.
+O1 module runs as a thread in O-DU High.
+
+Alarm communication between the threads happen on a Unix socket.
O-DU High sends alarm messages in the following structure using Alarm Interface APIs.
- Ubuntu : sudo apt-get install -y libpcap-dev
- CentOS : sudo yum install -y libpcap-devel
-Following libraries are required to compile and execute O1 module:
+
+
+Cloning code
+--------------
+
+- Create a folder to clone the O-DU High code into. The folder is hereafter referred to as <O-DU High Directory>.
+
+- Clone code into <O-DU High Directory>
+
+ git clone "https://gerrit.o-ran-sc.org/r/o-du/l2"
+
+
+Setting up Netconf server
+-------------------------
-- Netconf:
+ Following steps are required to compile ODU with O1 interface enabled:
+
+- Install Netconf libraries:
+
libssh, libyang, libnetconf2, sysrepo, netopeer2
Script is provided in the following folder to install these libraries
- Ubuntu :
- | cd <O-DU High Directory>/l2/build/o1
- | sudo ./install_lib.sh
+ | cd <O-DU High Directory>/l2/build/scripts
+ | sudo ./install_lib.sh -c
+- Start Netopeer2-server:
+
+ - Ubuntu :
+ | cd <O-DU High Directory>/l2/build/scripts
+ | sudo ./netopeer-server.sh start
-Cloning code
---------------
+- Create a new netconf user
+
+ Switch to root user and run following commands
+
+ - Ubuntu :
+
+ | adduser --system netconf && \\
+ | echo "netconf:netconf" | chpasswd
-- Create a folder to clone the O-DU High code into. The folder is hereafter referred to as <O-DU High Directory>.
+ | mkdir -p /home/netconf/.ssh && \\
+ | ssh-keygen -A && \\
+ | ssh-keygen -t dsa -P '' -f /home/netconf/.ssh/id_dsa && \\
+ | cat /home/netconf/.ssh/id_dsa.pub > /home/netconf/.ssh/authorized_keys
-- Clone code into <O-DU High Directory>
+- Install the YANG modules
- git clone "https://gerrit.o-ran-sc.org/r/o-du/l2"
+ - Ubuntu :
+
+ | cd <O-DU High Directory>/l2/build/yang
+ | sysrepoctl -i ./yang/o-ran-sc-odu-alarm-v1.yang
+ | sysrepoctl -i ./yang/o-ran-sc-odu-interface-v1.yang
+
+- Configure the startup IP and Port configurations for DU, CU and RIC
+
+ - Ubuntu :
+
+ | cd <O-DU High Directory>/l2/build/config
+ |
+ | Open the startup_config.xml and edit the desired IP and Port for CU, DU and RIC.
+ | Then load the configuration in the sysrepo running datastore using the command below
+ |
+ | sysrepocfg --import=startup_config.xml --datastore running --module o-ran-sc-odu-interface-v1
Compilation
------------
make clean_odu MACHINE=BIT64 MODE=FDD
- - Build O-DU High binary
+ - Compile O-DU High binary
make odu MACHINE=BIT64 MODE=FDD
- To build with O1 interface enabled:
-
- make odu MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
- Build CU Stub :
make clean_cu NODE=TEST_STUB MACHINE=BIT64 MODE=FDD
- - Build CU Stub binary
+ - Compile CU Stub binary
make cu_stub NODE=TEST_STUB MACHINE=BIT64 MODE=FDD
make clean_ric NODE=TEST_STUB MACHINE=BIT64 MODE=FDD
- - Build RIC Stub binary
+ - Compile RIC Stub binary
make ric_stub NODE=TEST_STUB MACHINE=BIT64 MODE=FDD
-- Build O-DU High with O1 interface enabled:
- - Navigate to o1 Build folder
+Compilation with O1 interface enabled
+--------------------------------------
+
+- Build O-DU High:
+
+ - Navigate to Build folder
+
+ cd <O-DU High Directory>/l2/build/odu
+
+ - Clean O-DU High binary
+
+ make clean_odu MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
+
+
+ - Compile O-DU High binary
+
+ make odu MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
+
+
+- Build CU Stub :
+
+ - Navigate to Build folder
- cd <O-DU High Directory>/l2/build/o1
+ cd <O-DU High Directory>/l2/build/odu
- - Clean O1 binary
+ - Clean CU Stub binary
- make clean_o1 MACHINE=BIT64
+ make clean_cu NODE=TEST_STUB MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
- - Build O1 binary
+ - Compile CU Stub binary
- make o1 MACHINE=BIT64
+ make cu_stub NODE=TEST_STUB MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
- - Navigate to odu Build folder
+- Build RIC Stub :
+ - Navigate to Build folder
+
cd <O-DU High Directory>/l2/build/odu
- - Clean O-DU High binary
+ - Clean RIC Stub binary
+
+ make clean_ric NODE=TEST_STUB MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
- make clean_odu MACHINE=BIT64 MODE=FDD
-
- - Build O-DU High binary
+ - Compile RIC Stub binary
- make odu MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
+ make ric_stub NODE=TEST_STUB MACHINE=BIT64 MODE=FDD O1_ENABLE=YES
- RIC Stub - <O-DU High Directory>/l2/bin/ric_stub
-- O1 - <O-DU High Directory>/l2/build/o1/bin/o1
^^^^^^^^^^
.. figure:: ODU-O1-Arch.jpg
- :width: 600
+ :width: 554
:alt: Figure 2 O1 Architecture
Figure 2 - O1 Architecture
-As shown in figure 2 the O1 module in O-DU High runs a separate process and communicates with ODU-High process over a TCP interface. O1 module uses API calls for interacting with the Netconf server(Netopeer) and datastore(sysrepo) for providing the Netconf interface.
+As shown in figure 2 the O1 module runs as a thread in O-DU High. Alarm communication happens over a Unix socket between the O1 and O-DU threads. O1 module uses API calls for interacting with the Netconf server(Netopeer) and datastore(sysrepo) for providing the Netconf interface.
O1 architecture has following components:
-- Netconf Manager: Subscribe to Netconf YANG modules and events. Register callback handler methods.
+- Session Handler: Subscribe to Netconf YANG modules and events. Register callback handler methods.
- Alarm Manager: Stores and manages(add/updated/delete) alarms.
-- TCP server: Receives the alarm messages sent from O-DU High over TCP socket.
+- Unix socket server: Receives the alarm messages sent from O-DU High thread over Unix socket.
-- TCP Client Alarm Interface : Integrates with O-DU High module and provides an interface for sending the alarm messages to O1 module over TCP socket.
+- Alarm Interface : Provides an interface to O-DU High threads for sending the alarm messages to O1 module over Unix socket.
- Netopeer server: Serves the northbound SMO/OAM Netconf requests.
O1 Netconf get-alarm list procedure
-----------------------------------
-This section describes the *Health Status Retrieval* scenario of O-DU High health-check. It enables a northbound client(SMO) to retrieve the health of the ODU-High based on the last self-check performed. The alarm-list is provided as the response to the request via O1 Netconf interface.
+This section describes the *Health Status Retrieval* scenario of O-DU High health-check. It enables a northbound client(SMO) to retrieve the health of the O-DU High based on the last self-check performed. The alarm-list is provided as the response to the request via O1 Netconf interface.
.. figure:: ODU-O1-GetAlarmListFlow.jpg
- :width: 720
+ :width: 869
:alt: Figure 6 O1 get alarm-list flow
Figure 6 - O1 get alarm-list flow
As seen in the Figure 6,
-- On the cell state change from de-active to activate, ODU High process raises a cell up alarm message and sends it over the TCP socket using the TCP client Alarm Interface API.
+- On the cell state change from de-active to activate, DU APP module raises a cell up alarm message and sends it over the Unix socket using the Alarm Interface API.
-- On other side a TCP server, running as a thread, in O1 module receives the cell up alarm message and it passes the alarm information to the Alarm Manager.
+- On other side a Unix socket server, running as a thread, in O1 module receives the cell up alarm message and it passes on the alarm information to the Alarm Manager.
- Alarm Manager stores the alarm data in a list.
-- Whenever SMO/OAM requires the current alarm list, it sends a Netconf get request. The request is received by the Netopeer Server and a callback method, registered with the Netconf Manager, is invoked.
+- Whenever SMO/OAM requires the current alarm list, it sends a Netconf get request. The request is received by the Netopeer Server and a callback method, registered with the Session Handler, is invoked.
- The callback function fetches the alarm list from Alarm Manager and sends it back to the client (SMO/OAM) via Netconf interface.
b. ifconfig <interface name>:CU_STUB "192.168.130.82"
c. ifconfig <interface name>:RIC_STUB "192.168.130.80"
-2. Execute O1 (only if O-DU is built with O1 interface enabled):
+PS: If O1 interface is enabled, IPs should match those configured in "startup_config.xml"
+ ( Refer Installation Guide - "Setting up Netconf server" )
- a. Navigate to O1 build folder
-
- - cd <O-DU High Directory>/l2/build/o1
-
- b. Create a new netconf user and install the YANG module
-
- Switch to root user and run following commands
-
- | adduser --system netconf && \\
- | echo "netconf:netconf" | chpasswd
-
- | mkdir -p /home/netconf/.ssh && \\
- | ssh-keygen -A && \\
- | ssh-keygen -t dsa -P '' -f /home/netconf/.ssh/id_dsa && \\
- | cat /home/netconf/.ssh/id_dsa.pub > /home/netconf/.ssh/authorized_keys
-
- sysrepoctl -i ./yang/o-ran-sc-odu-alarm-v1.yang
- sysrepoctl -i ./yang/o-ran-sc-odu-interface-v1.yang
-
- c. Navigate to O1 execution folder
-
- - cd <O-DU High Directory>/l2/build/o1/bin/o1
-
- d. Run O1 binary
-
- - ./o1
-
-3. Execute CU Stub:
+2. Execute CU Stub:
a. Navigate to CU execution folder
- ./cu_stub
-4. Execute RIC Stub:
+3. Execute RIC Stub:
a. Navigate to RIC execution folder
- ./ric_stub
-5. Execute O-DU High:
+4. Execute O-DU High:
a. Navigate to ODU execution folder
- ./odu
-PS: CU stub and RIC stub must be run (in no particular sequence) before ODU. If O-DU High is built with O1 interface enabled, the O1 binary must be run before all other binaries.
+PS: CU stub and RIC stub must be run (in no particular sequence) before ODU.
II. Execution - Using Docker Images
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#include "du_log.h"
#ifdef O1_ENABLE
-
-#include "Config.h"
-
+#include "ConfigInterface.h"
#endif
#define CU_ID 1
DU_LOG("\nDEBUG --> CU_STUB : Reading CU configurations");
#ifdef O1_ENABLE
- if( getStartupConfig(&g_cfg) != ROK )
+ if( getStartupConfigForStub(&g_cfg) != ROK )
{
- RETVALUE(RFAILED);
+ DU_LOG("\nError --> CU_STUB : Could not fetch startup "\
+ "configurations from Netconf interface\n");
+ exit(1);
}
- 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);
#include "du_mgr.h"
#include "du_utils.h"
#include "du_cell_mgr.h"
+
#ifdef O1_ENABLE
-#include "GlobalDefs.h"
#include "AlarmInterface.h"
#endif
#include "BWP-UplinkCommon.h"
#ifdef O1_ENABLE
-
-#include "Config.h"
+#include "ConfigInterface.h"
extern StartupConfig g_cfg;
-
#endif
DuCfgParams duCfgParam;
#include "GTPTunnel.h"
#ifdef O1_ENABLE
-
-#include "Config.h"
+#include "ConfigInterface.h"
extern StartupConfig g_cfg;
-
#endif
DuCfgParams duCfgParam;
#include "du_sctp.h"
#include "du_egtp.h"
+#ifdef O1_ENABLE
+
+#include "O1Interface.h"
+
+#endif
+
uint8_t rlcUlActvTsk (Pst *, Buffer *);
uint8_t rlcUlActvInit (Ent, Inst, Region, Reason);
uint8_t rlcDlActvTsk (Pst *, Buffer *);
{
init_log();
+#ifdef O1_ENABLE
+ if(start_O1_module() != ROK)
+ return RFAILED;
+#endif
+
//Initialize TAPA layers
if(duInit() != ROK)
{
#ifdef O1_ENABLE
-#include "GlobalDefs.h"
#include "AlarmInterface.h"
#endif
#include <string>
#include <string.h>
-#include "Alarm.h"
+#include "AlarmMessages.h"
using std::string;
/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2021] [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. #
################################################################################
*******************************************************************************/
-/* This file contains interfaces to raise and clear alarms */
+/* This file contains C interfaces for ODU to raise and clear alarms */
+#include <stdio.h>
+#include <time.h>
+#include "GlobalDefs.hpp"
#include "AlarmInterface.h"
-#include "TcpClient.h"
-
+#include "UnixSocketClient.hpp"
/*******************************************************************
*
*
* Functionality:
* - Raise an alarm by sending alarm info to O1 module over
- * TCP socket with action set to RAISE
+ * Unix socket with action set to RAISE
*
* @params[in] alarm information
- * @return ROK - success
- * RFAILED - failure
+ * @return O1::SUCCESS - success
+ * O1::FAILURE - failure
******************************************************************/
uint8_t raiseAlarm(AlarmRecord* alrm)
{
- if (openSocket(TCP_SERVER_IP,TCP_PORT) == RFAILED)
+
+ UnixSocketClient uxClient(O1::ALARM_SOCK_PATH);
+ if (uxClient.openSocket() == O1::FAILURE)
{
- return RFAILED;
+ return O1::FAILURE;
}
alrm->msgHeader.msgType = ALARM;
alrm->msgHeader.action = RAISE_ALARM;
- if (sendData(alrm,sizeof(AlarmRecord)) < 0 )
+ if (uxClient.sendData(alrm,sizeof(AlarmRecord)) < 0 )
{
- closeSocket();
- return RFAILED;
+ uxClient.closeSocket();
+ return O1::FAILURE;
}
- closeSocket();
- return ROK;
+ uxClient.closeSocket();
+ return O1::SUCCESS;
}
/*******************************************************************
*
* Functionality:
* - Clears an alarm raised earlier by sending the alrm
- * information to O1 module over TCP socket with action
+ * information to O1 module over Unix socket with action
* set to CLEAR
*
* @params[in] alarm information
- * @return ROK - success
- * RFAILED - failure
+ * @return O1::SUCCESS - success
+ * O1::FAILURE - failure
******************************************************************/
uint8_t clearAlarm(AlarmRecord* alrm)
{
- if (openSocket(TCP_SERVER_IP,TCP_PORT) == RFAILED)
+ UnixSocketClient uxClient(O1::ALARM_SOCK_PATH);
+ if (uxClient.openSocket() == O1::FAILURE)
{
- return RFAILED;
+ return O1::FAILURE;
}
alrm->msgHeader.msgType = ALARM;
alrm->msgHeader.action = CLEAR_ALARM;
- if (sendData(alrm,sizeof(AlarmRecord)) < 0)
+ if (uxClient.sendData(alrm,sizeof(AlarmRecord)) < 0)
{
- closeSocket();
- return RFAILED;
+ uxClient.closeSocket();
+ return O1::FAILURE;
}
- closeSocket();
- return ROK;
+ uxClient.closeSocket();
+ return O1::SUCCESS;
}
* the alarm
*
* @params[in] alarm Id, cell Id
- * @return ROK - success
- * RFAILED - failure
+ * @return O1::SUCCESS - success
+ * O1::FAILURE - failure
******************************************************************/
uint8_t raiseCellAlrm(uint16_t alrmId, uint16_t cellId)
{
* - Clears the cell specific alarm using alarm id
*
* @params[in] alarm Id
- * @return ROK - success
- * RFAILED - failure
+ * @return O1::SUCCESS - success
+ * O1::FAILURE - failure
******************************************************************/
uint8_t clearCellAlrm(uint16_t alrmId)
{
/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2021] [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. #
################################################################################
*******************************************************************************/
-/* This file contains interfaces to raise and clear alarms */
+/* This file contains C interfaces for ODU to raise and clear alarms */
#ifndef __ALARM_INTERFACE_H__
#define __ALARM_INTERFACE_H__
#include <stdint.h>
-#include "Alarm.h"
-#include "ssi.h"
-#include "GlobalDefs.h"
+#include "AlarmMessages.h"
+#define CELL_UP_ALARM_ID 1009
+#define CELL_DOWN_ALARM_ID 1010
#define BUFF_SIZE 20
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
uint8_t raiseAlarm(AlarmRecord* alrm);
uint8_t clearAlarm(AlarmRecord* alrm);
uint8_t raiseCellAlrm(uint16_t alrmId, uint16_t cellId);
uint8_t clearCellAlrm(uint16_t alrmId);
+#ifdef __cplusplus
+}
+#endif
+
#endif
/**********************************************************************
/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2021] [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. #
/* This file contains definitions of Alarm structure */
-#ifndef __ALARM_H__
-#define __ALARM_H__
+#ifndef __ALARM_MESSAGES_H__
+#define __ALARM_MESSAGES_H__
#include <string.h>
#include "CommonMessages.h"
/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2021] [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. #
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2021] [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 C interface for ODU and stubs to get startup
+ configuration
+*/
+
+#include "ConfigInterface.h"
+#include "GlobalDefs.hpp"
+#include "UnixSocketClient.hpp"
+#include "SessionHandler.hpp"
+#include "InitConfig.hpp"
+
+StartupConfig g_cfg;
+
+/*******************************************************************
+ *
+ * @brief Get the startup config from Netconf
+ *
+ * @details
+ *
+ * Function : getStartupConfig
+ *
+ * Functionality:
+ * - Get the start up IP and port for DU
+ *
+ * @params[in] pointer to StartupConfig
+ * @return O1::SUCCESS - success
+ * O1::FAILURE - failure
+ ******************************************************************/
+uint8_t getStartupConfig(StartupConfig *cfg)
+{
+ if ( InitConfig::instance().getCurrInterfaceConfig(*cfg) )
+ {
+ O1_LOG("\nO1 StartupConfig : "
+ "cfg.DU_IPV4_Addr [%s]",
+ cfg->DU_IPV4_Addr);
+ O1_LOG("\nO1 StartupConfig : "
+ "cfg.DU_Port [%d]",
+ cfg->DU_Port);
+ O1_LOG("\nO1 StartupConfig : "
+ "cfg.CU_IPV4_Addr [%s]",
+ cfg->CU_IPV4_Addr);
+ O1_LOG("\nO1 StartupConfig : "
+ "cfg.CU_Port [%d]",
+ cfg->CU_Port);
+ O1_LOG("\nO1 StartupConfig : "
+ "cfg.RIC_IPV4_Addr [%s]",
+ cfg->RIC_IPV4_Addr);
+ O1_LOG("\nO1 StartupConfig : "
+ "cfg.RIC_Port [%d]",
+ cfg->RIC_Port);
+ return O1::SUCCESS;
+ }
+ return O1::FAILURE;
+}
+
+/*******************************************************************
+ *
+ * @brief Get the startup config from Netconf
+ *
+ * @details
+ *
+ * Function : getStartupConfig
+ *
+ * Functionality:
+ * - Get the start up IP and port for CU and RIC
+ *
+ * @params[in] pointer to StartupConfig
+ * @return O1::SUCCESS - success
+ * O1::FAILURE - failure
+ ******************************************************************/
+uint8_t getStartupConfigForStub(StartupConfig *cfg)
+{
+#if 0
+ UnixSocketClient uxClient(O1::ALARM_SOCK_PATH);
+ O1_LOG("\nO1 CONFIG : getStartupConfig ------ \n");
+ MsgHeader msg;
+ msg.msgType = CONFIGURATION;
+ msg.action = GET_STARTUP_CONFIG;
+ if (uxClient.openSocket() == O1::FAILURE)
+ {
+ return O1::FAILURE;
+ }
+ if (uxClient.sendData(&msg,sizeof(msg)) < 0 )
+ {
+ uxClient.closeSocket();
+ return O1::FAILURE;
+ }
+ if (uxClient.receiveData(cfg, sizeof(StartupConfig)) < 0)
+ {
+ uxClient.closeSocket();
+ return O1::FAILURE;
+ }
+ O1_LOG("\nO1 CONFIG : ip du %s\n",cfg->DU_IPV4_Addr );
+ O1_LOG("\nO1 CONFIG : ip cu %s\n",cfg->CU_IPV4_Addr );
+ O1_LOG("\nO1 CONFIG : ip ric %s\n",cfg->RIC_IPV4_Addr );
+ O1_LOG("\nO1 CONFIG : port cu %hu\n",cfg->CU_Port);
+ O1_LOG("\nO1 CONFIG : port du %hu\n",cfg->DU_Port);
+ O1_LOG("\nO1 CONFIG : port ric %hu\n",cfg->RIC_Port);
+
+ uxClient.closeSocket();
+#endif
+ SessionHandler sessHdlr;
+ if ( sessHdlr.init() )
+ {
+ if ( InitConfig::instance().getCurrInterfaceConfig(*cfg) )
+ {
+ O1_LOG("\nO1 StartupConfig : "
+ "cfg.DU_IPV4_Addr [%s]",
+ cfg->DU_IPV4_Addr);
+ O1_LOG("\nO1 StartupConfig : "
+ "cfg.DU_Port [%d]",
+ cfg->DU_Port);
+ O1_LOG("\nO1 StartupConfig : "
+ "cfg.CU_IPV4_Addr [%s]",
+ cfg->CU_IPV4_Addr);
+ O1_LOG("\nO1 StartupConfig : "
+ "cfg.CU_Port [%d]",
+ cfg->CU_Port);
+ O1_LOG("\nO1 StartupConfig : "
+ "cfg.RIC_IPV4_Addr [%s]",
+ cfg->RIC_IPV4_Addr);
+ O1_LOG("\nO1 StartupConfig : "
+ "cfg.RIC_Port [%d]",
+ cfg->RIC_Port);
+ return O1::SUCCESS;
+ }
+ }
+ return O1::FAILURE;
+}
+
+
+/**********************************************************************
+ End of file
+**********************************************************************/
################################################################################
*******************************************************************************/
-/* This file contains definitions of startup configuration structure */
+/* This file contains C interface for ODU and stubs to get startup
+ configuration
+*/
-#ifndef __CONFIG_H__
-#define __CONFIG_H__
+#ifndef __CONFIG_INTERFACE_H__
+#define __CONFIG_INTERFACE_H__
#include <stdint.h>
#include <CommonMessages.h>
#define IPV4_LEN 16
#define PORT_LEN 10
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
typedef struct
{
char DU_IPV4_Addr[IPV4_LEN];
uint16_t RIC_Port;
}StartupConfig;
-uint8_t getStartupConfig();
+
+uint8_t getStartupConfig(StartupConfig *cfg);
+uint8_t getStartupConfigForStub(StartupConfig *cfg);
+
+#ifdef __cplusplus
+}
+#endif
#endif
#include "GlobalDefs.hpp"
-const short O1::TCP_PORT = 8282;
const int O1::SUCCESS = 0;
const int O1::FAILURE = 1;
+const std::string O1::ALARM_SOCK_PATH("/tmp/alarmsock");
+const int O1::CPU_CORE = 22;
+
/**********************************************************************
End of file
#define __GLOBAL_DEFS_HPP__
#include <syslog.h>
+#include <string>
+
+using std::string;
#define O1_LOG(...) ( {\
printf(__VA_ARGS__);\
class O1
{
public:
- static const short TCP_PORT;
static const int SUCCESS;
static const int FAILURE;
+ static const string ALARM_SOCK_PATH;
+ static const int CPU_CORE;
};
#endif
YANG modules */
#include "InitConfig.hpp"
-#include<string>
-#include <string.h>
-using namespace std;
/* Default constructor */
bool InitConfig::init(sysrepo::S_Session sess)
{
- O1_LOG("\nInitConfig::init started ");
mSess = sess;
- getInterfaceConfig(sess);
+ InitConfig::InterfaceMap map;
+ if(!getInterfaceConfig(sess, map))
+ {
+ O1_LOG("\nInitConfig::getInterfaceConfig InitConfig data error ");
+ return false;
+ }
return true;
}
switch (it->first)
{
case Interface::ODU :
- if(it->second.first != "0")
+ if(it->second.first != "")
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);
+ return false;
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);
+ return false;
break;
case Interface::OCU :
- if(it->second.first != "0")
+ if(it->second.first != "")
strcpy(cfg.CU_IPV4_Addr, it->second.first.c_str());
else
- strcpy(cfg.CU_IPV4_Addr, DEFAULT_CU_IPV4_ADDR);
+ return false;
- //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;
+ return false;
- //O1_LOG("\n InitConfig::getCurrInterfaceConfig cfg.CU_Port = %d", \
- cfg.CU_Port);
break;
case Interface::RIC :
- if(it->second.first != "0")
+ if(it->second.first != "")
strcpy(cfg.RIC_IPV4_Addr, it->second.first.c_str());
else
- strcpy(cfg.RIC_IPV4_Addr, DEFAULT_RIC_IPV4_ADDR);
+ return false;
- //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;
+ return false;
- //O1_LOG("\n InitConfig::getCurrInterfaceConfig cfg.RIC_Port = %d", \
- cfg.RIC_Port);
break;
default :
* @return reference of InterfaceMap
*
******************************************************************/
-InitConfig::InterfaceMap InitConfig::getInterfaceConfig(sysrepo::S_Session sess)
+bool InitConfig::getInterfaceConfig(sysrepo::S_Session sess , InitConfig::InterfaceMap &map)
{
- 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;
+ InitConfig::Address oduAddr;
+ InitConfig::Address ocuAddr;
+ InitConfig::Address ricAddr;
+ if(getInterfaceData(sess,Interface::ODU, oduAddr) && \
+ getInterfaceData(sess,Interface::OCU, ocuAddr) && \
+ getInterfaceData(sess,Interface::RIC, ricAddr))
+ {
+ mInterfaceList.insert(std::make_pair(Interface::ODU, oduAddr));
+ mInterfaceList.insert(std::make_pair(Interface::OCU, ocuAddr));
+ mInterfaceList.insert(std::make_pair(Interface::RIC, ricAddr));
+ map = mInterfaceList;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
/*******************************************************************
* @return reference of Address
*
******************************************************************/
-InitConfig::Address InitConfig::getInterfaceData(sysrepo::S_Session sess, \
- Interface inf)
+bool InitConfig::getInterfaceData(sysrepo::S_Session sess, \
+ Interface inf, InitConfig::Address & addr)
{
- O1_LOG("\nInitConfig::getInterfaceData started");
+ //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()));
+ string ip;
+ string port;
+
+ if(getData(sess, getInterfaceXpath(sInf, IP_ADDRESS), ip))
+ {
+ if(getData(sess, getInterfaceXpath(sInf, PORT), port))
+ {
+ addr = std::make_pair(ip, atoi(port.c_str()));
+ return true;
+ }
+ else
+ return false;
+ }
+ else
+ return false;
}
/*******************************************************************
*
******************************************************************/
-string InitConfig::getData(sysrepo::S_Session sess,char* xpath)
+bool InitConfig::getData(sysrepo::S_Session sess,char* xpath, string &val)
{
//O1_LOG("\nInitConfig::getData of xpath = %s", \
xpath); //enable for debugging only
auto value = sess->get_item(xpath);
if (value == nullptr)
{
+ O1_LOG("\nInitConfig::getData no data available at xpath= %s", \
+ xpath);
//O1_LOG("\nget_item value are null for xpath = %s", \
xpath); //enable for debugging only
- return "0";
+ return false;
}
- string mVal = value->val_to_string();
- return mVal;
+ val = value->val_to_string();
+ return true;
}
catch (...)
{
- //O1_LOG("\nInitConfig::getData exception occured for block xpath= %s", \
- xpath); //enable for debugging only
- return "0";
+ O1_LOG("\nInitConfig::getData exception occured for xpath= %s", \
+ xpath);
+ return false;
}
}
#include <utility>
#include <string>
#include <iostream>
-#include "sysrepo-cpp/Session.hpp"
+#include <string.h>
#include <map>
+#include "sysrepo-cpp/Session.hpp"
#include "Singleton.hpp"
-#include "Config.h"
-
+#include "ConfigInterface.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 36421
-
+using namespace std;
enum class Interface
{ ODU,
OCU,
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);
+ bool getInterfaceData(sysrepo::S_Session sess, \
+ Interface inf, InitConfig::Address & addr);
+ bool getInterfaceConfig(sysrepo::S_Session sess , InitConfig::InterfaceMap &map);
char * getInterfaceXpath( std::string sInf, std::string param);
- std::string getData(sysrepo::S_Session sess,char* xpath);
+ bool getData(sysrepo::S_Session sess,char* xpath, string &val);
std::string interfaceToString(Interface inf);
bool printInterfaceConfig();
bool writeInterfaceConfig();
**********************************************************************/
bool NetconfManager::init(void)
{
- if(startNetopeerServer())
+ /* if(startNetopeerServer())
{
O1_LOG("\nO1 NetconfManager : netopeer server started");
}
-
+ */
try
{
mSessHndl = new SessionHandler;
if( !mSessHndl->init())
{
- O1_LOG("\nO1 NetconfManager : SessionHandler init failed ");
+ O1_LOG("\nO1 NetconfManager : SessionHandler init failed \n");
return false;
}
+ return true;
}
catch( const std::exception& e )
{
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2021] [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 the O1App class which is responsible for running/starting
+ all the O1 modules in a thread. It inherits the Thread class and Singleton
+ class.
+*/
+
+#include "O1App.hpp"
+#include "GlobalDefs.hpp"
+#include "SessionHandler.hpp"
+#include "ConfigInterface.h"
+#include <unistd.h>
+
+/*******************************************************************
+ *
+ * @brief Constructor
+ *
+ * @details
+ *
+ * Function : O1App
+ *
+ * Functionality:
+ * - Constructor intialization
+ *
+ * @params[in] None
+ * @return None
+ ******************************************************************/
+
+O1App::O1App() : mUxSocketServer(O1::ALARM_SOCK_PATH)
+{
+
+}
+
+/*******************************************************************
+ *
+ * @brief Destructor
+ *
+ * @details
+ *
+ * Function : ~O1App
+ *
+ * Functionality:
+ * - Destructor
+ *
+ * @params[in] None
+ * @return None
+ ******************************************************************/
+
+O1App::~O1App()
+{
+
+}
+
+/*******************************************************************
+ *
+ * @brief Runs the O1 modules as a thread
+ *
+ * @details
+ *
+ * Function : run
+ *
+ * Functionality:
+ * - Implements the "run" function of Thread class.
+ * Starts all the O1 modules.
+ *
+ *
+ * @params[in] void
+ * @return true : success
+ * false : failure
+ ******************************************************************/
+
+bool O1App::run()
+{
+
+ SessionHandler sessHdlr;
+ /* Start Netconf session and subscribe to yang modules */
+ try
+ {
+ if( !sessHdlr.init() )
+ {
+ O1_LOG("\nO1 O1App : SessionHandler initialization failed ");
+ return false;
+ }
+ }
+ catch( const std::exception& e )
+ {
+ O1_LOG("\nO1 O1App : Exception : %s", e.what());
+ return false;
+ }
+
+ /* Start the Unix Socket Server to listen for alarm messages */
+ if( mUxSocketServer.start() )
+ {
+
+ if(mUxSocketServer.setAffinity(O1::CPU_CORE))
+ {
+ O1_LOG("\nO1 O1App : CPU affinity set " );
+ mUxSocketServer.printAffinity();
+ }
+
+ sleep(2);
+ if( mUxSocketServer.isRunning() )
+ {
+ mStartupStatus = true;
+ O1_LOG("\nO1 O1App : Unix Socket server started\n");
+ }
+ else
+ {
+ O1_LOG("\nO1 O1App : Unix Socket server failed to start\n");
+ return false;
+ }
+ /* Wait for the Unix Socket Server thread to end*/
+ mUxSocketServer.join();
+ }
+ else
+ {
+ O1_LOG("\nO1 O1App : Unix Socket server failed to start\n");
+ return false;
+ }
+ return true;
+}
+
+/*******************************************************************
+ *
+ * @brief Check if the O1 Module is fully up and running
+ *
+ * @details
+ *
+ * Function : getStartupStatus
+ *
+ * Functionality:
+ * - Returns the status of O1App whether it is fully up
+ *
+ *
+ * @params[in] void
+ * @return true : started
+ * false : not started
+ ******************************************************************/
+
+bool O1App::getStartupStatus() const
+{
+ return mStartupStatus;
+}
+
+/*******************************************************************
+ *
+ * @brief Cleanup O1App
+ *
+ * @details
+ *
+ * Function : cleanUp
+ *
+ * Functionality:
+ * - Implements the "cleanUp" function of Thread class to
+ * take care of any clean up required for O1 components
+ * before stopping the thread.
+ *
+ * @params[in] void
+ * @return void
+ ******************************************************************/
+
+void O1App::cleanUp(void)
+{
+ /* Stop the socket server thread */
+ mUxSocketServer.stop();
+}
/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2021] [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. #
################################################################################
*******************************************************************************/
-/* Class for global defines and constants for O1 interface */
+/* This file contains the O1App class which is responsible for running/starting
+ all the O1 modules in a thread. It inherits the Thread class and Singleton
+ class.
+*/
-#ifndef __GLOBAL_DEFS_H__
-#define __GLOBAL_DEFS_H__
+#ifndef __O1_APP_HPP__
+#define __O1_APP_HPP__
-#include <syslog.h>
+#include "Singleton.hpp"
+#include "Thread.hpp"
+#include "UnixSocketServer.hpp"
-#define O1_LOG(...) ({\
- printf(__VA_ARGS__);\
- syslog(LOG_DEBUG,__VA_ARGS__);\
- })
-#define TCP_PORT 8282
-#define TCP_SERVER_IP "127.0.0.1"
-#define CELL_UP_ALARM_ID 1009
-#define CELL_DOWN_ALARM_ID 1010
+class O1App : public Singleton<O1App>, public Thread
+{
+ friend Singleton<O1App>;
+
+ private:
+ bool mStartupStatus;
+ UnixSocketServer mUxSocketServer;
-#endif
+ protected:
+ bool run();
+
+ public:
+ O1App();
+ ~O1App();
+ bool getStartupStatus()const;
+ void cleanUp(void);
+};
-/**********************************************************************
- End of file
-**********************************************************************/
+
+#endif
/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2021] [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. #
################################################################################
*******************************************************************************/
-/* This file contains definitions of startup configuration structure */
+/* This file contains the C interface for ODU to start the O1 module */
-#include "Config.h"
-#include "ssi.h"
-#include "GlobalDefs.h"
-#include "TcpClient.h"
+#include "O1Interface.h"
+#include "O1App.hpp"
+#include "GlobalDefs.hpp"
+#include <signal.h>
+#include <unistd.h>
-StartupConfig g_cfg;
/*******************************************************************
*
- * @brief Get the startup config from Netconf
+ * @brief Wait for the O1 Module to start
*
* @details
*
- * Function : getStartupConfig
+ * Function : check_O1_module_status
*
* Functionality:
- * - Get the start up IP and port for DU,CU and RIC
+ * - Checks if the O1App has started
*
- * @params[in] pointer to StartupConfig
- * @return ROK - success
- * RFAILED - failure
+ *
+ * @params[in] void
+ * @return O1::SUCCESS - success
+ * O1::FAILURE - 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)
+
+int static check_O1_module_status(void){
+ for( int i = 0; i < 5 ; i++)
{
- return RFAILED;
+ if( O1App::instance().getStartupStatus() == true)
+ {
+ return O1::SUCCESS;
+ }
+ else
+ {
+ sleep(1);
+ }
}
- if (sendData(&msg,sizeof(msg)) < 0 )
- {
- closeSocket();
- return RFAILED;
+
+ return O1::FAILURE;
+}
+
+/*******************************************************************
+ *
+ * @brief Starts the O1 Module
+ *
+ * @details
+ *
+ * Function : start_O1_module
+ *
+ * Functionality:
+ * - Starts the O1 module by instantiating the O1App instance
+ * Invoked from the ODU-High main function
+ *
+ *
+ * @params[in] void
+ * @return O1::SUCCESS - success
+ * O1::FAILURE - failure
+ ******************************************************************/
+
+int start_O1_module(void)
+{
+
+ if(O1App::instance().start() == false){
+ O1_LOG("\nO1 O1Interface : Failed to start");
+ return O1::FAILURE;
}
- if (receiveData(cfg, sizeof(StartupConfig)) < 0)
+
+ if(O1App::instance().setAffinity(O1::CPU_CORE))
{
- closeSocket();
- return RFAILED;
+ O1_LOG("\nO1 O1Interface : CPU affinity set " );
+ O1App::instance().printAffinity();
}
- 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;
+ return check_O1_module_status();
}
/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2021] [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. #
################################################################################
*******************************************************************************/
-/* This file contains functions to connect to a TCP server and send massages */
+/* This file contains the C interface for ODU to start the O1 module */
-#ifndef __TCP_CLIENT_H__
-#define __TCP_CLIENT_H__
-#include <stdint.h>
-#include "ssi.h"
+#ifndef __O1_INTERFACE_H__
+#define __O1_INTERFACE_H__
-uint8_t openSocket(const char*, const uint16_t);
-int sendData(void*, const int);
-int receiveData(void* data, const int size);
-uint8_t closeSocket();
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+int start_O1_module(void);
+#ifdef __cplusplus
+}
#endif
-/**********************************************************************
- End of file
-**********************************************************************/
+
+#endif
+++ /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 O1 main.
- Starts the Netopeer and TCP server
-*/
-
-#include "NetconfManager.hpp"
-#include "TcpServer.hpp"
-#include <signal.h>
-
-/**********************************************************************
- Description : Main function. Start of O1 module.
- Params[In] : None
- Return : EXIT_SUCCESS
- : EXIT_FAILURE
-**********************************************************************/
-
-int main(int argc, char **argv)
-{
- TcpServer tcpServer(O1::TCP_PORT);
- /*SIGINT handling*/
- //signal(SIGINT, NetconfManager::sigintHandler);
- /* Start Netconf server and subscribe to yang modules */
- try
- {
- NetconfManager::instancePtr()->init();
- O1_LOG("\nO1 O1_main : NetconfManager init successful");
-
- }
- catch( const std::exception& e )
- {
- O1_LOG("\nO1 O1_main : Exception : %s", e.what());
- return EXIT_FAILURE;
- }
- /* Start the TCP Server to listen for alarm messages */
- if( tcpServer.start() )
- {
- O1_LOG("\nO1 O1_main : TCP server started\n");
- /* Wait for the TcpServer thread to end*/
- tcpServer.wait();
- }
- else
- {
- O1_LOG("\nO1 O1_main : Failed to start TCP server");
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
-}
-
-/**********************************************************************
- End of file
-**********************************************************************/
{
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;
+ if(mConn != NULL)
+ {
+ O1_LOG("\nO1 SessionHandler : Connection created");
+ //removing nacm module temperary for auth issue resolve
+ //mConn.remove_module("ietf-netconf-acm");
+ mSess = createSession(mConn);
+ if(mSess != NULL)
+ {
+ O1_LOG("\nO1 SessionHandler : Session created");
+ mSub = createSubscribe(mSess);
+ if(mSub != NULL)
+ {
+ O1_LOG("\nO1 SessionHandler : Subscription created");
+ if(InitConfig::instance().init(mSess))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ O1_LOG("\nO1 SessionHandler : Subscription failed");
+ return false;
+ }
+ }
+ else
+ {
+ O1_LOG("\nO1 SessionHandler : Session failed");
+ return false;
+ }
+ }
+ else
+ {
+ O1_LOG("\nO1 SessionHandler : connection failed");
+ return false;
+ }
}
catch( const std::exception& e )
{
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2021] [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 class for launching and managing POSIX threads */
+
+#include "Thread.hpp"
+#include "GlobalDefs.hpp"
+#include <stdio.h>
+#include <unistd.h>
+
+/*******************************************************************
+ *
+ * @brief Constructor
+ *
+ * @details
+ *
+ * Function : Thread
+ *
+ * Functionality:
+ * - Constructor intialization
+ *
+ * @params[in] None
+ * @return None
+ ******************************************************************/
+
+Thread::Thread(): mThreadId(0)
+{
+
+}
+
+/*******************************************************************
+ *
+ * @brief Destructor
+ *
+ * @details
+ *
+ * Function : ~Thread
+ *
+ * Functionality:
+ * - Destructor
+ *
+ * @params[in] None
+ * @return None
+ ******************************************************************/
+
+Thread::~Thread()
+{
+
+}
+
+/*******************************************************************
+ *
+ * @brief Static function registered to run as pthread
+
+ *
+ * @details
+ *
+ * Function : task
+ *
+ * Functionality:
+ * - Static function registered to run as pthread. It calls
+ * the run function that is implemented by the derived
+ * class instance.
+ *
+ * @params[in] void pointer to the base class instance that
+ implements this Thread class
+ * @return void
+ ******************************************************************/
+
+void* Thread::task(void* args)
+{
+ Thread* thisPtr = static_cast<Thread*>(args);
+ thisPtr->run();
+}
+
+
+/*******************************************************************
+ *
+ * @brief Creates a thread
+ *
+ * @details
+ *
+ * Function : start
+ *
+ * Functionality:
+ * - Starts a pthread registering the "task" function for
+ * performing the thread task.
+ *
+ * @params[in] void
+ * @return true : success
+ * false : failure
+ ******************************************************************/
+
+bool Thread::start()
+{
+ return (pthread_create(&mThreadId, NULL, task, this) == 0);
+}
+
+
+/*******************************************************************
+ *
+ * @brief Stops the thread
+ *
+ * @details
+ *
+ * Function : stop
+ *
+ * Functionality:
+ * - Stops the thread. Performs an clean ups prior to
+ * stopping the thread
+ *
+ *
+ * @params[in] void
+ * @return true : success
+ * false : failure
+ ******************************************************************/
+bool Thread::stop()
+{
+ cleanUp();
+ return (pthread_cancel(mThreadId) == 0);
+}
+
+/*******************************************************************
+ *
+ * @brief Wait for the thread to complete
+ *
+ * @details
+ *
+ * Function : join
+ *
+ * Functionality:
+ * - Waits for the thread to complete in the calling process/
+ * thread
+ *
+ * @params[in] void
+ * @return true : success
+ * false : failure
+ ******************************************************************/
+bool Thread::join()
+{
+ return (pthread_join(mThreadId,NULL) == 0);
+}
+
+
+/*******************************************************************
+ *
+ * @brief Set the affinity of the thread
+ *
+ * @details
+ *
+ * Function : setAffinity
+ *
+ * Functionality:
+ * - Pins the thread to cpu core(s)
+ *
+ * @params[in] CPU cores
+ * @return true : success
+ * false : failure
+ ******************************************************************/
+bool Thread::setAffinity(int coreNum)
+{
+ int ret;
+ cpu_set_t cpuset;
+ long nCores = sysconf(_SC_NPROCESSORS_ONLN);
+
+ CPU_ZERO(&cpuset);
+ CPU_SET(coreNum%nCores, &cpuset);
+ ret = pthread_setaffinity_np(mThreadId, sizeof(cpu_set_t), &cpuset);
+ if (ret != 0)
+ {
+ return false;
+ }
+ return true;
+}
+
+/*******************************************************************
+ *
+ * @brief Print the affinity of the thread
+ *
+ * @details
+ *
+ * Function : printAffinity
+ *
+ * Functionality:
+ * - Prints the cpu core(s) the thread is pinned to
+ *
+ * @params[in] void
+ * @return true : success
+ * false : failure
+ ******************************************************************/
+bool Thread::printAffinity()
+{
+ int ret;
+ long nCores = sysconf(_SC_NPROCESSORS_ONLN);
+
+ cpu_set_t cpuset;
+ CPU_ZERO(&cpuset);
+
+ ret = pthread_getaffinity_np(mThreadId, sizeof(cpu_set_t), &cpuset);
+ if (ret != 0)
+ return false;
+
+ for (int i = 0; i < nCores; i++)
+ if (CPU_ISSET(i, &cpuset))
+ O1_LOG("CPU %d ", i);
+ return true;
+}
/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2021] [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. #
################################################################################
*******************************************************************************/
-/* This file contains definitions of common message structures */
+/* This file contains class for launching and managing POSIX threads */
-#ifndef __MESSAGE_H__
-#define __MESSAGE_H__
+#ifndef __THREAD_HPP__
+#define __THREAD_HPP__
-#include <string.h>
+#include <pthread.h>
-typedef enum
+class Thread
{
- RAISE_ALARM,
- CLEAR_ALARM,
- GET_STARTUP_CONFIG
-}MsgAction;
+ private:
+ pthread_t mThreadId;
+ static void* task(void*);
-typedef enum
-{
- ALARM,
- CONFIGURATION
-}MsgType;
+ protected:
+ virtual bool run() = 0;
-typedef struct
-{
- MsgType msgType;
- MsgAction action;
-}MsgHeader;
+ public:
+ Thread();
+ virtual ~Thread();
+ bool start();
+ bool stop();
+ virtual void cleanUp()=0;
+ bool setAffinity(int);
+ bool printAffinity();
+ bool join();
+};
-#endif
-/**********************************************************************
- End of file
-**********************************************************************/
+
+#endif
/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2021] [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. #
################################################################################
*******************************************************************************/
-/* This file contains functions to connect to TCP server and send massages */
+/* This file contains functions to connect to unix socket server and send/recv
+ messages
+*/
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
+#include <sys/un.h>
-#include "TcpClient.h"
-#include "GlobalDefs.h"
-#include "ssi.h"
-
-static int s_sock;
-static struct sockaddr_in s_serverName;
-static uint16_t s_port;
-static const char* s_hostName = NULL;
+#include "UnixSocketClient.hpp"
+#include "GlobalDefs.hpp"
/*******************************************************************
*
- * @brief Initilize the sockadd_in structure
+ * @brief Constructor
*
* @details
*
- * Function : initSockaddr
+ * Function : UnixSocketClient
*
* Functionality:
- * - Initilizes the sockadd_in structure
+ * - Constructor intialization
*
- * @params[in] void
- * @return ROK - success
- * RFAILED - failure
+ * @params[in] socket path
+ * @return None
******************************************************************/
-static uint8_t initSockaddr()
+UnixSocketClient::UnixSocketClient(const string& path)
+ : mSockPath(path)
{
- struct hostent *hostInfo;
- struct sockaddr_in *name = &s_serverName;
- bzero(&s_serverName, sizeof(s_serverName));
- name->sin_family = AF_INET;
- name->sin_port = htons (s_port);
- hostInfo = gethostbyname (s_hostName);
- if (hostInfo == NULL)
- {
- O1_LOG("\nO1 TcpClient : Unknown host %s", s_hostName);
- return RFAILED;
- }
- name->sin_addr = *(struct in_addr *) hostInfo->h_addr;
- return ROK;
}
+/*******************************************************************
+ *
+ * @brief Destructor
+ *
+ * @details
+ *
+ * Function : ~UnixSocketClient
+ *
+ * Functionality:
+ * - Destructor
+ *
+ * @params[in] None
+ * @return None
+ ******************************************************************/
+ UnixSocketClient::~UnixSocketClient()
+ {
+
+ }
/*******************************************************************
*
- * @brief Open a TCP socket
+ * @brief Open a Unix socket
*
* @details
*
* Function : openSocket
*
* Functionality:
- * - Opens a TCP socket
+ * - Opens a Unix socket
*
- * @params[in] hostname, port
- * @return ROK - success
- * RFAILED - failure
+ * @params[in] void
+ * @return O1::SUCCESS - success
+ * O1::FAILURE - failure
******************************************************************/
-uint8_t openSocket(const char* hostName, const uint16_t port)
+uint8_t UnixSocketClient::openSocket()
{
/* Create the socket. */
- s_port = port;
- s_hostName = hostName;
- s_sock = socket (PF_INET, SOCK_STREAM, 0);
- if (s_sock < 0)
+ mSock = socket (AF_UNIX, SOCK_STREAM, 0);
+ if (mSock < 0)
{
- O1_LOG("\nO1 TcpClient : Error opening socket");
- return RFAILED;
+ O1_LOG("\nO1 UnixSocketClient : Error opening socket");
+ return O1::FAILURE;
}
- /* Init the sockaddr_in structure */
- if (initSockaddr() == RFAILED)
- {
- return RFAILED;
- }
+ /* Init the sockaddr_un structure */
+ mSockName.sun_family = AF_UNIX;
+ strcpy(mSockName.sun_path, mSockPath.c_str());
+
/* Connect to the server */
- if (0 > connect (s_sock,
- (struct sockaddr_in *)&s_serverName ,
- sizeof (s_serverName)))
+ if (0 > connect (mSock,
+ (struct sockaddr *)&mSockName,
+ sizeof (mSockName)))
{
- O1_LOG("\nO1 TcpClient : Error connecting");
- return RFAILED;
+ O1_LOG("\nO1 UnixSocketClient : Error connecting");
+ return O1::FAILURE;
}
- return ROK;
+ return O1::SUCCESS;
}
-
/*******************************************************************
*
- * @brief Send message over TCP socket
+ * @brief Send message over Unix socket
*
* @details
*
* Function : sendData
*
* Functionality:
- * - Sends message over TCP socket
+ * - Sends message over Unix socket
*
* @params[in] message, size of the message
* @return Number of bytes sent
*
******************************************************************/
-int sendData(void* data, const int size)
+int UnixSocketClient::sendData(void* data, const int size)
{
- int nbytes = write (s_sock, data, size);
+ int nbytes = write (mSock, data, size);
if (nbytes < 0)
{
- O1_LOG("\nO1 TcpClient : Error writing. %d bytes sent", nbytes);
+ O1_LOG("\nO1 UnixSocketClient : Error writing. %d bytes sent", nbytes);
}
return nbytes;
}
/*******************************************************************
*
- * @brief Recieve message over TCP socket
+ * @brief Recieve message over Unix socket
*
* @details
*
* Function : receiveData
*
* Functionality:
- * - Recieves message over TCP socket
+ * - Recieves message over Unix socket
*
* @params[in] message, size of the message
* @return Number of bytes received
*
******************************************************************/
-int receiveData(void* data, const int size)
+int UnixSocketClient::receiveData(void* data, const int size)
{
- int nbytes = read (s_sock, data, size);
+ int nbytes = read (mSock, data, size);
if (nbytes < 0)
{
- O1_LOG("\nO1 TcpClient : Error reading. %d bytes sent", nbytes);
+ O1_LOG("\nO1 UnixSocketClient : Error reading. %d bytes sent", nbytes);
}
return nbytes;
}
/*******************************************************************
*
- * @brief Close the TCP socket
+ * @brief Close the Unix socket
*
* @details
*
* Function : closeSocket
*
* Functionality:
- * - Closes the TCP socket
+ * - Closes the Unix socket
*
- * @params[in] message, size of the message
- * @return ROK - success
- * RFAILED - failure
+ * @params[in] void
+ * @return O1::SUCCESS - success
+ * O1::FAILURE - failure
******************************************************************/
-uint8_t closeSocket()
+uint8_t UnixSocketClient::closeSocket()
{
- if( close(s_sock) != 0 )
- return RFAILED;
- return ROK;
+ if( close(mSock) != 0 )
+ return O1::FAILURE;
+ return O1::SUCCESS;
}
/**********************************************************************
--- /dev/null
+/*******************************************************************************
+################################################################################
+# Copyright (c) [2020-2021] [HCL Technologies Ltd.] #
+# #
+# Licensed under th`e 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 functions to connect to a unix socket server and send/recv
+ messages
+*/
+
+#ifndef __UNIX_SOCKET_CLIENT_HPP__
+#define __UNIX_SOCKET_CLIENT_HPP__
+
+#include <stdint.h>
+#include <string>
+#include <sys/un.h>
+
+using std::string;
+
+class UnixSocketClient
+{
+ private:
+
+ int mSock;
+ string mSockPath;
+ struct sockaddr_un mSockName;
+
+ public:
+ UnixSocketClient(const string& path);
+ ~UnixSocketClient();
+ uint8_t openSocket();
+ int sendData(void*, const int);
+ int receiveData(void* data, const int size);
+ uint8_t closeSocket();
+
+};
+
+#endif
+
+/**********************************************************************
+ End of file
+**********************************************************************/
/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2021] [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. #
################################################################################
*******************************************************************************/
-/* This file contains TcpServer class that listens for Netconf Alarm messages
- on a TCP socket from ODU. It calls the AlarmManager functions for raising
- or clearing the alarms based on the actions received
+/* This file contains UnixSocketServer class that listens for Netconf Alarm
+ messages on a Unix socket from ODU. It calls the AlarmManager functions
+ for raising or clearing the alarms based on the actions received
*/
-#include "TcpServer.hpp"
+#include "UnixSocketServer.hpp"
#include "Alarm.hpp"
#include "AlarmManager.hpp"
-#include "Config.h"
+#include "ConfigInterface.h"
#include "GlobalDefs.hpp"
#include <iostream>
#include <cstdio>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
+#include <sys/un.h>
#include "InitConfig.hpp"
+
using std::map;
using std::pair;
-/* Destructor */
-TcpServer::~TcpServer()
+/*******************************************************************
+ *
+ * @brief Constructor
+ *
+ * @details
+ *
+ * Function : UnixSocketServer
+ *
+ * Functionality:
+ * - Constructor intialization
+ *
+ * @params[in] socket path
+ * @return None
+ ******************************************************************/
+UnixSocketServer::UnixSocketServer(const string& sockPath)
+ : mSockPath(sockPath),
+ mIsRunning(false)
+{
+
+}
+
+/*******************************************************************
+ *
+ * @brief Destructor
+ *
+ * @details
+ *
+ * Function : ~UnixSocketServer
+ *
+ * Functionality:
+ * - Destructor
+ *
+ * @params[in] None
+ * @return None
+ ******************************************************************/
+UnixSocketServer::~UnixSocketServer()
{
}
* @return No. of bytes read
*
******************************************************************/
-int TcpServer::readMessage(int fd)
+int UnixSocketServer::readMessage(int fd)
{
AlarmRecord *alrmRec = NULL;
char recvBuf[BUFLEN];
{
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);
+ O1_LOG("\nO1 UnixSocketServer :\nMsgType %d",msgHdr->msgType);
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
- );
+ O1_LOG("\nO1 UnixSocketServer :\n"
+ "Action %d\n"
+ "Alarm ID %s\n"
+ "Severity %d\n"
+ "Additional Text %s\n"
+ "Specific Problem %s\n"
+ "Additional Info %s\n"
+ "Alarm Raise Time %s\n",
+ alrmRec->msgHeader.action,
+ alrmRec->alarmId,
+ alrmRec->perceivedSeverity,
+ alrmRec->additionalText,
+ alrmRec->specificProblem,
+ alrmRec->additionalInfo,
+ alrmRec->alarmRaiseTime
+ );
/*Fill the alarm structure */
sscanf(alrmRec->alarmId,"%hu",&alrmId);
case RAISE_ALARM:
if(AlarmManager::instance().raiseAlarm(alrm))
{
- O1_LOG("\nO1 TcpServer : Alarm raised for alarm Id %s", alrmRec->alarmId);
+ O1_LOG("\nO1 UnixSocketServer : "
+ "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 UnixSocketServer : "
+ "Error in raising alarm for alrm Id %s",
+ alrmRec->alarmId);
}
break;
case CLEAR_ALARM:
if(AlarmManager::instance().clearAlarm(alrm))
{
- O1_LOG("\nO1 TcpServer : Alarm cleared for alarm Id %s", alrmRec->alarmId);
+ O1_LOG("\nO1 UnixSocketServer : "
+ "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 UnixSocketServer : "
+ "Error in clearing alarm for alarm Id %s",
+ alrmRec->alarmId);
}
break;
+#if 0
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);
+ O1_LOG("\nO1 UnixSocketServer : "
+ "cfg.DU_IPV4_Addr [%s]",
+ cfg.DU_IPV4_Addr);
+ O1_LOG("\nO1 UnixSocketServer : "
+ "cfg.DU_Port [%d]",
+ cfg.DU_Port);
+ O1_LOG("\nO1 UnixSocketServer : "
+ "cfg.CU_IPV4_Addr [%s]",
+ cfg.CU_IPV4_Addr);
+ O1_LOG("\nO1 UnixSocketServer : "
+ "cfg.CU_Port [%d]",
+ cfg.CU_Port);
+ O1_LOG("\nO1 UnixSocketServer : "
+ "cfg.RIC_IPV4_Addr [%s]",
+ cfg.RIC_IPV4_Addr);
+ O1_LOG("\nO1 UnixSocketServer : "
+ "cfg.RIC_Port [%d]",
+ cfg.RIC_Port);
if (write (fd, &cfg, sizeof(cfg)) < 0)
{
- O1_LOG("\nO1 TcpServer : Error sending startup configuration \n");
+ O1_LOG("\nO1 UnixSocketServer : "
+ "Error sending startup configuration \n");
}
break;
}
+#endif
default:
- O1_LOG("\nO1 TcpServer : No action performed");
+ O1_LOG("\nO1 UnixSocketServer : No action performed");
break;
}
/*******************************************************************
*
- * @brief Open a TCP socket and bind on the port
+ * @brief Open a Unix socket and bind on the port
*
* @details
*
* Function : makeSocket
*
* Functionality:
- * - Opens a TCP socket and bind on the port
+ * - Opens a Unix socket and bind on the port
*
* @params[in] void
* @return O1:SUCCESS - success
* O1:FAILURE - failure
******************************************************************/
-int TcpServer::makeSocket()
+
+int UnixSocketServer::makeSocket()
{
- struct sockaddr_in name;
+ struct sockaddr_un name;
/* Create the socket. */
- mSock = socket (PF_INET, SOCK_STREAM, 0);
+ mSock = socket (AF_UNIX, SOCK_STREAM, 0);
if (mSock < 0)
{
- O1_LOG("\nO1 TcpServer : Socket error");
+ O1_LOG("\nO1 UnixSocketServer : Socket error");
return O1::FAILURE;
}
/* Give the socket a name. */
bzero(&name, sizeof(name));
- name.sin_family = AF_INET;
- name.sin_port = htons (mPort);
- name.sin_addr.s_addr = htonl (INADDR_ANY);
+ name.sun_family = AF_UNIX;
+
+ /* Remove the socket file if it already exists */
+ if ( unlink(mSockPath.c_str()) == 0)
+ {
+ O1_LOG("\nO1 UnixSocketServer : "
+ "Removing the existing socket path %s",
+ mSockPath.c_str());
+ }
+ strcpy(name.sun_path, mSockPath.c_str());
if (bind (mSock, (struct sockaddr *) &name, sizeof (name)) < 0)
{
close(mSock);
- O1_LOG("\nO1 TcpServer : Bind error");
+ O1_LOG("\nO1 UnixSocketServer : Bind error");
return O1::FAILURE;
}
return O1::SUCCESS;
/*******************************************************************
*
- * @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);
-}
-
-/*******************************************************************
- *
- * @brief A TCP server to handle multiple connection
+ * @brief A Unix server to handle multiple connection
*
* @details
*
* Function : run
*
* Functionality:
- * - A TCP server to handle multiple connection
+ * - A Unix server to handle multiple connection
* Uses select multiplexing
*
* @params[in] void
* @return true - success
* false - failure
******************************************************************/
-bool TcpServer::run()
+bool UnixSocketServer::run()
{
fd_set active_fd_set, read_fd_set;
int i;
- struct sockaddr_in clientName;
+ struct sockaddr_un clientName;
socklen_t size;
- bool ret = true;;
+ mIsRunning = true;
/* Create the socket and set it up to accept connections. */
if( makeSocket() == O1::SUCCESS )
{
if (listen (mSock, 1) < 0)
{
- O1_LOG("\nO1 TcpServer : Listen error");
+ O1_LOG("\nO1 UnixSocketServer : Listen error");
close(mSock);
- ret = false;
+ mIsRunning = false;
}
else
{
read_fd_set = active_fd_set;
if (select (FD_SETSIZE, &read_fd_set, NULL, NULL, NULL) < 0)
{
- O1_LOG("\nO1 TcpServer : Select error");
+ O1_LOG("\nO1 UnixSocketServer : Select error");
close(mSock);
- ret = false;
+ mIsRunning = false;
break;
}
newFd = accept(mSock,(struct sockaddr *) &clientName,&size);
if (newFd < 0)
{
- O1_LOG("\nO1 TcpServer : Accept error");
+ O1_LOG("\nO1 UnixSocketServer : Accept error");
close(mSock);
- ret = false;
+ mIsRunning = false;
break;
}
- O1_LOG("\nO1 TcpServer : Connected from host %s, port %hd.\n",
- inet_ntoa (clientName.sin_addr),
- ntohs (clientName.sin_port));
+ O1_LOG("\nO1 UnixSocketServer : Connected from client\n");
FD_SET (newFd, &active_fd_set);
}
else
} /* outer if ends */
else
{
- ret = false;
+ mIsRunning = false;
}
- return ret;
+ return mIsRunning;
}
/*******************************************************************
*
- * @brief Static function for launching a TCP server instance
- * in a thread
+ * @brief Clean up open socket
*
* @details
*
- * Function : task
+ * Function : cleanUp
*
* Functionality:
- * - Static function for launching a TCP server instance
- * in a thread
+ * - Performs any clean ups before stopping the thread
*
- * @params[in] TcpServer instance
+ * @params[in] void
* @return void
******************************************************************/
-void* TcpServer::task(void *args)
+void UnixSocketServer::cleanUp(void)
{
- TcpServer *tcpServer = (TcpServer*)args;
- tcpServer->run();
- return NULL;
+ close(mSock);
+ O1_LOG("\nO1 UnixSocketServer : Cleaning up Closing socket \n");
}
-
/*******************************************************************
*
- * @brief Wait for the thread to complete in the parent process
+ * @brief Check if the server is running
*
* @details
*
- * Function : wait
+ * Function : isRunning
*
* Functionality:
- * - Waits for the thread to complete in the parent process
+ * - Returns the running status of the server
*
* @params[in] void
- * @return true : success
- * false : failure
+ * @return true : running
+ * false: not running
******************************************************************/
-bool TcpServer::wait()
+bool UnixSocketServer::isRunning() const
{
- return (pthread_join(mThreadId,NULL) == 0);
+ return mIsRunning;
}
-
-
/**********************************************************************
End of file
**********************************************************************/
/*******************************************************************************
################################################################################
-# Copyright (c) [2020] [HCL Technologies Ltd.] #
+# Copyright (c) [2020-2021] [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. #
################################################################################
*******************************************************************************/
-/* This file contains TcpServer class that listens for Netconf Alarm messages
- on a TCP socket from ODU. It calls the AlarmManager functions for raising
+/* This file contains UnixSocketServer class that listens for Netconf Alarm messages
+ on a Unix socket from ODU. It calls the AlarmManager functions for raising
or clearing the alarms based on the actions received
*/
-#ifndef __TCP_SERVER_HPP__
-#define __TCP_SERVER_HPP__
+#ifndef __UNIX_SOCKET_SERVER_HPP__
+#define __UNIX_SOCKET_SERVER_HPP__
#include <string>
#include <pthread.h>
+#include "Thread.hpp"
using std::string;
#define BUFLEN 512
-class TcpServer
+class UnixSocketServer : public Thread
{
private:
- pthread_t mThreadId;
int mSock;
- const int16_t mPort;
+ string mSockPath;
int readMessage(int);
int makeSocket();
+
+ protected:
bool run();
- static void* task(void*);
+ bool mIsRunning;
public:
- bool start();
- bool wait();
- TcpServer(const uint16_t port) : mPort(port){};
- ~TcpServer();
+ UnixSocketServer(const string& sockPath);
+ ~UnixSocketServer();
+ bool isRunning() const;
+ virtual void cleanUp(void);
};
#include "du_log.h"
#ifdef O1_ENABLE
-#include "Config.h"
+#include "ConfigInterface.h"
#endif
#define RIC_ID 1
#define PLMN_MNC2 0
#ifdef O1_ENABLE
-
extern StartupConfig g_cfg;
-
#endif
/*******************************************************************
DU_LOG("\nINFO --> RIC : Reading RIC configurations");
#ifdef O1_ENABLE
- if( getStartupConfig(&g_cfg) != ROK )
+ if( getStartupConfigForStub(&g_cfg) != ROK )
{
- RETVALUE(RFAILED);
+ DU_LOG("\nError --> RIC : Could not fetch startup "\
+ "configurations from Netconf interface\n");
+ exit(1);
}
+
cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);