Commit fcbb4bde authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

first version for NRF

parent cd82e5e8
......@@ -21,8 +21,8 @@
cmake_minimum_required (VERSION 3.0.2)
project(oai-cn)
# Override options for SMF
set ( PACKAGE_NAME "SMF" )
# Override options for NRF
set ( PACKAGE_NAME "NRF" )
set ( STATIC_LINKING False )
#############################################
# Base directories, compatible with legacy OAI building
......@@ -31,6 +31,4 @@ set (OPENAIRCN_DIR $ENV{OPENAIRCN_DIR})
set (BUILD_TOP_DIR ${OPENAIRCN_DIR}/build)
set (SRC_TOP_DIR $ENV{OPENAIRCN_DIR}/src)
include(${CMAKE_CURRENT_SOURCE_DIR}/../../src/oai_smf/CMakeLists.txt)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/smf_app ${CMAKE_CURRENT_BINARY_DIR}/smf_app)
include(${CMAKE_CURRENT_SOURCE_DIR}/../../src/oai-nrf/CMakeLists.txt)
......@@ -19,7 +19,7 @@
# contact@openairinterface.org
################################################################################
# file build_helper.smf
# file build_helper.nrf
# brief
# author Laurent Thomas, Lionel GAUTHIER
#
......@@ -99,7 +99,7 @@ install_spdlog_from_git() {
git clone $GIT_URL
cd spdlog && git checkout master
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
# enable syslog, Useless (defined in SMF code)
# enable syslog, Useless (defined in NRF code)
sed -i '/#define SPDLOG_ENABLE_SYSLOG/s/^\/\///g' include/spdlog/tweakme.h
popd
fi
......@@ -268,7 +268,7 @@ install_nghttp2_from_git() {
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
check_install_smf_deps() {
check_install_nrf_deps() {
if [ $1 -gt 0 ]; then
OPTION="-y"
......@@ -408,7 +408,7 @@ check_install_smf_deps() {
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
check_install_smf_min_deps() {
check_install_nrf_min_deps() {
if [ $1 -gt 0 ]; then
OPTION="-y"
......
......@@ -19,7 +19,7 @@
# For more information about the OpenAirInterface (OAI) Software Alliance:
# contact@openairinterface.org
################################################################################
# file build_smf
# file build_nrf
# brief
# author Lionel Gauthier
# company Eurecom
......@@ -33,14 +33,14 @@ INSTALL_DIR=/usr/local/bin
# include helper functions
################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
source $THIS_SCRIPT_PATH/build_helper.smf
source $THIS_SCRIPT_PATH/build_helper.nrf
function help()
{
echo_error " "
echo_error "Usage: build_smf [OPTION]..."
echo_error "Build the SMF executable."
echo_error "Usage: build_nrf [OPTION]..."
echo_error "Build the NRF executable."
echo_error " "
echo_error "Options:"
echo_error "Mandatory arguments to long options are mandatory for short options too."
......@@ -48,8 +48,8 @@ function help()
echo_error " -c, --clean Clean the build generated files: config, object, executable files (build from scratch)"
echo_error " -f, --force No interactive script for installation of software packages."
echo_error " -h, --help Print this help."
echo_error " -I, --install-deps Check installed software necessary to build and run SMF (support $SUPPORTED_DISTRO)."
echo_error " -i, --install-min-deps Check installed software necessary to run a statically linked SMF (support $SUPPORTED_DISTRO)."
echo_error " -I, --install-deps Check installed software necessary to build and run NRF (support $SUPPORTED_DISTRO)."
echo_error " -i, --install-min-deps Check installed software necessary to run a statically linked NRF (support $SUPPORTED_DISTRO)."
echo_error " -j, --jobs Multiple jobs for compiling."
echo_error " -v, --verbose Build process verbose."
echo_error " -V, --Verbose CMake only build process verbose, display compilation warnings and errors."
......@@ -99,13 +99,13 @@ function main()
return 0
;;
-I | --install-deps)
echo "Check installed software necessary to build and run SMF (support $SUPPORTED_DISTRO):"
echo "Check installed software necessary to build and run NRF (support $SUPPORTED_DISTRO):"
set_openair_env
var_check_install_deps=1
shift;
;;
-i | --install-min-deps)
echo "Check installed software necessary to run SMF (support $SUPPORTED_DISTRO):"
echo "Check installed software necessary to run NRF (support $SUPPORTED_DISTRO):"
set_openair_env
var_check_install_min_deps=1
shift;
......@@ -149,26 +149,26 @@ function main()
if [ $var_check_install_min_deps -gt 0 ];then
disable_ipv6
check_install_smf_min_deps $force $debug
check_install_nrf_min_deps $force $debug
if [[ $? -ne 0 ]]; then
echo_error "Error: SMF minimal deps installation failed"
echo_error "Error: NRF minimal deps installation failed"
return 1
else
echo_success "SMF minimal deps installation successful"
echo_warning "SMF not compiled, to compile it, re-run build_smf without -i option"
echo_success "NRF minimal deps installation successful"
echo_warning "NRF not compiled, to compile it, re-run build_nrf without -i option"
return 0
fi
fi
if [ $var_check_install_deps -gt 0 ];then
disable_ipv6
check_install_smf_deps $force $debug
check_install_nrf_deps $force $debug
if [[ $? -ne 0 ]]; then
echo_error "Error: SMF deps installation failed"
echo_error "Error: NRF deps installation failed"
return 1
else
echo_success "SMF deps installation successful"
echo_warning "SMF not compiled, to compile it, re-run build_smf without -I option"
echo_success "NRF deps installation successful"
echo_warning "NRF not compiled, to compile it, re-run build_nrf without -I option"
return 0
fi
fi
......@@ -178,19 +178,19 @@ function main()
##############################################################################
# Clean
##############################################################################
cd $OPENAIRCN_DIR/build/smf
cd $OPENAIRCN_DIR/build/nrf
if [ $clean -ne 0 ]; then
if [[ $verbose -eq 1 ]]; then
echo "Cleaning SMF: generated configuration files, obj files, executable"
echo "Cleaning NRF: generated configuration files, obj files, executable"
fi
rm -Rf $OPENAIRCN_DIR/build/smf/build 2>&1
rm -Rf $OPENAIRCN_DIR/build/nrf/build 2>&1
mkdir -m 777 -p -v build
fi
##############################################################################
# Compile SMF
# Compile NRF
##############################################################################
cd $OPENAIRCN_DIR/build/smf
cd $OPENAIRCN_DIR/build/nrf
if [ ! -d ./build ]; then
mkdir -m 777 -p -v build
fi
......@@ -199,12 +199,12 @@ function main()
$CMAKE $cmake_args .. > /dev/null
ret=$?;[[ $ret -ne 0 ]] && return $ret
compilations smf smf $OPENAIRCN_DIR/build/smf/build/smf $verbose
compilations nrf nrf $OPENAIRCN_DIR/build/nrf/build/nrf $verbose
ret=$?;[[ $ret -ne 0 ]] && return $ret
# For daemon should not be group writable
$SUDO chmod 755 $OPENAIRCN_DIR/build/smf/build/smf
$SUDO cp -upv $OPENAIRCN_DIR/build/smf/build/smf $INSTALL_DIR && $SUDO chmod 755 $INSTALL_DIR/smf && echo_success "smf installed"
$SUDO chmod 755 $OPENAIRCN_DIR/build/nrf/build/nrf
$SUDO cp -upv $OPENAIRCN_DIR/build/nrf/build/nrf $INSTALL_DIR && $SUDO chmod 755 $INSTALL_DIR/nrf && echo_success "nrf installed"
return 0
}
......
......@@ -262,60 +262,60 @@ else(STATIC_LINKING)
SET(BUILD_SHARED_LIBS ON)
endif(STATIC_LINKING)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/common ${CMAKE_CURRENT_BINARY_DIR}/common)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/common/utils ${CMAKE_CURRENT_BINARY_DIR}/utils)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/pfcp ${CMAKE_CURRENT_BINARY_DIR}/pfcp)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/udp ${CMAKE_CURRENT_BINARY_DIR}/udp)
#ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/common ${CMAKE_CURRENT_BINARY_DIR}/common)
#ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/common/utils ${CMAKE_CURRENT_BINARY_DIR}/utils)
#ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/pfcp ${CMAKE_CURRENT_BINARY_DIR}/pfcp)
#ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/udp ${CMAKE_CURRENT_BINARY_DIR}/udp)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/api-server ${CMAKE_CURRENT_BINARY_DIR}/api-server)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/nas ${CMAKE_CURRENT_BINARY_DIR}/nas)
#ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/nas ${CMAKE_CURRENT_BINARY_DIR}/nas)
#ENABLE_TESTING()
#ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/test ${CMAKE_CURRENT_BINARY_DIR}/test)
################################################################################
# Specific part for oai_smf folder
# Specific part for oai_nrf folder
add_definitions("-DPACKAGE_NAME=\"SMF\"")
include_directories(${SRC_TOP_DIR}/smf_app)
include_directories(${SRC_TOP_DIR}/oai_smf)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/msg)
include_directories(${SRC_TOP_DIR}/common/nas)
include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/common/utils/bstr)
include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/udp)
#include_directories(${SRC_TOP_DIR}/nrf_app)
#include_directories(${SRC_TOP_DIR}/oai_nrf)
#include_directories(${SRC_TOP_DIR}/itti)
#include_directories(${SRC_TOP_DIR}/common)
#include_directories(${SRC_TOP_DIR}/common/msg)
#include_directories(${SRC_TOP_DIR}/common/nas)
#include_directories(${SRC_TOP_DIR}/common/utils)
#include_directories(${SRC_TOP_DIR}/common/utils/bstr)
#include_directories(${SRC_TOP_DIR}/pfcp)
#include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/api-server)
include_directories(${SRC_TOP_DIR}/api-server/api)
include_directories(${SRC_TOP_DIR}/api-server/impl)
include_directories(${SRC_TOP_DIR}/api-server/model)
include_directories(${SRC_TOP_DIR}/nas)
include_directories(${SRC_TOP_DIR}/nas/ies)
include_directories(${SRC_TOP_DIR}/nas/mm)
include_directories(${SRC_TOP_DIR}/nas/mm/msg)
include_directories(${SRC_TOP_DIR}/nas/sm)
include_directories(${SRC_TOP_DIR}/nas/sm/msg)
include_directories(${SRC_TOP_DIR}/nas/security)
include_directories(${SRC_TOP_DIR}/ngap)
include_directories(${SRC_TOP_DIR}/ngap/asn1c)
include_directories(${SRC_TOP_DIR}/ngap/ies)
add_executable(smf
${SRC_TOP_DIR}/oai_smf/main.cpp
${SRC_TOP_DIR}/oai_smf/options.cpp
${SRC_TOP_DIR}/itti/itti.cpp
${SRC_TOP_DIR}/itti/itti_msg.cpp
#include_directories(${SRC_TOP_DIR}/nas)
#include_directories(${SRC_TOP_DIR}/nas/ies)
#include_directories(${SRC_TOP_DIR}/nas/mm)
#include_directories(${SRC_TOP_DIR}/nas/mm/msg)
#include_directories(${SRC_TOP_DIR}/nas/sm)
#include_directories(${SRC_TOP_DIR}/nas/sm/msg)
#include_directories(${SRC_TOP_DIR}/nas/security)
#include_directories(${SRC_TOP_DIR}/ngap)
#include_directories(${SRC_TOP_DIR}/ngap/asn1c)
#include_directories(${SRC_TOP_DIR}/ngap/ies)
add_executable(nrf
${SRC_TOP_DIR}/oai-nrf/main.cpp
${SRC_TOP_DIR}/oai-nrf/options.cpp
# ${SRC_TOP_DIR}/itti/itti.cpp
# ${SRC_TOP_DIR}/itti/itti_msg.cpp
)
IF(STATIC_LINKING)
SET(CMAKE_EXE_LINKER_FLAGS "-static")
SET_TARGET_PROPERTIES(smf PROPERTIES LINK_SEARCH_END_STATIC 1)
SET_TARGET_PROPERTIES(nrf PROPERTIES LINK_SEARCH_END_STATIC 1)
# asan do not support static linking
SET(ASAN)
ENDIF(STATIC_LINKING)
target_link_libraries (smf ${ASAN}
-Wl,--start-group CN_UTILS SMF UDP PFCP 3GPP_COMMON_TYPES SMF_API -lnettle ${NETTLE_LIBRARIES} ${CRYPTO_LIBRARIES} -lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto NAS gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system pistache curl)
target_link_libraries (nrf ${ASAN}
-Wl,--start-group -lnettle ${NETTLE_LIBRARIES} ${CRYPTO_LIBRARIES} -lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system pistache curl)
\ No newline at end of file
......@@ -15,19 +15,14 @@
*/
#include "async_shell_cmd.hpp"
#include "common_defs.h"
#include "itti.hpp"
#include "logger.hpp"
#include "options.hpp"
#include "pid_file.hpp"
#include "smf_app.hpp"
#include "smf_config.hpp"
#include "smf-api-server.h"
//#include "smf-api-server.h"
#include "pistache/endpoint.h"
#include "pistache/http.h"
#include "pistache/router.h"
#include "smf-http2-server.h"
//#include "smf-http2-server.h"
#include <iostream>
#include <thread>
......@@ -36,17 +31,10 @@
#include <stdlib.h> // srand
#include <unistd.h> // get_pid(), pause()
using namespace smf;
using namespace util;
//using namespace smf;
//using namespace util;
using namespace std;
using namespace oai::smf_server::api;
itti_mw *itti_inst = nullptr;
async_shell_cmd *async_shell_cmd_inst = nullptr;
smf_app *smf_app_inst = nullptr;
smf_config smf_cfg;
SMFApiServer *smf_api_server_1 = nullptr;
smf_http2_server *smf_api_server_2 = nullptr;
//using namespace oai::smf_server::api;
void send_heartbeat_to_tasks(const uint32_t sequence);
......@@ -54,17 +42,19 @@ void send_heartbeat_to_tasks(const uint32_t sequence);
//------------------------------------------------------------------------------
void send_heartbeat_to_tasks(const uint32_t sequence)
{
itti_msg_ping *itti_msg = new itti_msg_ping(TASK_SMF_APP, TASK_ALL, sequence);
/* itti_msg_ping *itti_msg = new itti_msg_ping(TASK_SMF_APP, TASK_ALL, sequence);
std::shared_ptr<itti_msg_ping> i = std::shared_ptr<itti_msg_ping>(itti_msg);
int ret = itti_inst->send_broadcast_msg(i);
if (RETURNok != ret) {
Logger::smf_app().error( "Could not send ITTI message %s to task TASK_ALL", i->get_msg_name());
}
*/
}
//------------------------------------------------------------------------------
void my_app_signal_handler(int s)
{
/*
std::cout << "Caught signal " << s << std::endl;
Logger::system().startup( "exiting" );
itti_inst->send_terminate_msg(TASK_SMF_APP);
......@@ -88,6 +78,7 @@ void my_app_signal_handler(int s)
if (smf_app_inst) delete smf_app_inst; smf_app_inst = nullptr;
std::cout << "SMF APP memory done." << std::endl;
std::cout << "Freeing Allocated memory done" << std::endl;
*/
exit(0);
}
//------------------------------------------------------------------------------
......@@ -103,9 +94,9 @@ int main(int argc, char **argv)
}
// Logger
Logger::init( "smf" , Options::getlogStdout() , Options::getlogRotFilelog());
// Logger::init( "smf" , Options::getlogStdout() , Options::getlogRotFilelog());
Logger::smf_app().startup( "Options parsed" );
// Logger::smf_app().startup( "Options parsed" );
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = my_app_signal_handler;
......@@ -114,27 +105,28 @@ int main(int argc, char **argv)
sigaction(SIGINT, &sigIntHandler, NULL);
// Config
smf_cfg.load(Options::getlibconfigConfig());
smf_cfg.display();
// smf_cfg.load(Options::getlibconfigConfig());
// smf_cfg.display();
// Inter task Interface
itti_inst = new itti_mw();
itti_inst->start(smf_cfg.itti.itti_timer_sched_params);
// itti_inst = new itti_mw();
// itti_inst->start(smf_cfg.itti.itti_timer_sched_params);
// system command
async_shell_cmd_inst = new async_shell_cmd(smf_cfg.itti.async_cmd_sched_params);
// async_shell_cmd_inst = new async_shell_cmd(smf_cfg.itti.async_cmd_sched_params);
// SMF application layer
smf_app_inst = new smf_app(Options::getlibconfigConfig());
// smf_app_inst = new smf_app(Options::getlibconfigConfig());
// PID file
// Currently hard-coded value. TODO: add as config option.
string pid_file_name = get_exe_absolute_path("/var/run", smf_cfg.instance);
/* string pid_file_name = get_exe_absolute_path("/var/run", smf_cfg.instance);
if (! is_pid_file_lock_success(pid_file_name.c_str())) {
Logger::smf_app().error( "Lock PID file %s failed\n", pid_file_name.c_str());
exit (-EDEADLK);
}
*/
/*
//SMF Pistache API server (HTTP1)
Pistache::Address addr(std::string(inet_ntoa (*((struct in_addr *)&smf_cfg.sbi.addr4))) , Pistache::Port(smf_cfg.sbi.port));
smf_api_server_1 = new SMFApiServer(addr, smf_app_inst);
......@@ -155,7 +147,7 @@ int main(int argc, char **argv)
fprintf(fp, "STARTED\n");
fflush(fp);
fclose(fp);
*/
pause();
return 0;
}
......@@ -31,7 +31,7 @@ bool Options::m_log_stdout;
void Options::help()
{
std::cout << std::endl
<< "Usage: smf [OPTIONS]..." << std::endl
<< "Usage: nrf [OPTIONS]..." << std::endl
<< " -h, --help Print help and exit" << std::endl
<< " -c, --libconfigcfg filename Read the application configuration from this file." << std::endl
<< " -o, --stdoutlog Send the application logs to STDOUT fd." << std::endl
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment