Commit 3c115400 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix build issue/code cleanup

parent abeb7a32
...@@ -37,7 +37,7 @@ namespace config { ...@@ -37,7 +37,7 @@ namespace config {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int amf_modules::load(const std::string &config_file) { int amf_modules::load(const std::string &config_file) {
cout << endl; cout << endl;
Logger::amf_app().debug("Load amf module configuration file(%s)", config_file.c_str()); Logger::amf_app().debug("Load AMF module configuration file(%s)", config_file.c_str());
Config cfg; Config cfg;
try { try {
cfg.readFile(config_file.c_str()); cfg.readFile(config_file.c_str());
......
...@@ -1063,7 +1063,7 @@ void amf_n1::authentication_response_handle(uint32_t ran_ue_ngap_id, long amf_ue ...@@ -1063,7 +1063,7 @@ void amf_n1::authentication_response_handle(uint32_t ran_ue_ngap_id, long amf_ue
return; return;
} else { } else {
Logger::amf_n1().debug("Authenticated successfully by network!!!"); Logger::amf_n1().debug("Authenticated successfully by network!!!");
if (!nc.get()->is_current_security_avaliable) { if (!nc.get()->is_current_security_available) {
if (!start_security_mode_control_procedure(nc)) { if (!start_security_mode_control_procedure(nc)) {
Logger::amf_n1().error("Start SMC procedure failure"); Logger::amf_n1().error("Start SMC procedure failure");
} else { } else {
......
...@@ -83,7 +83,7 @@ bool amf_n1::connect_to_mysql() { ...@@ -83,7 +83,7 @@ bool amf_n1::connect_to_mysql() {
const int mysql_reconnect_val = 1; const int mysql_reconnect_val = 1;
db_desc = (database_t*) calloc(1, sizeof(database_t)); db_desc = (database_t*) calloc(1, sizeof(database_t));
if (!db_desc) { if (!db_desc) {
Logger::amf_n1().error("An error occurs when allocate memory for DB_DESC"); Logger::amf_n1().error("An error occurs when allocating memory for DB_DESC");
return false; return false;
} }
pthread_mutex_init(&db_desc->db_cs_mutex, NULL); pthread_mutex_init(&db_desc->db_cs_mutex, NULL);
......
cmake_minimum_required (VERSION 3.0.2)
project(OpenAirInterface)
macro(add_list_string_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
set_property(CACHE ${name} PROPERTY STRINGS ${ARGN})
if(NOT "${value}" STREQUAL "False")
add_definitions("-D${name}=\"${value}\"")
endif()
endmacro(add_list_string_option)
SET(STATIC_LINKING FALSE CACHE BOOL "Build a static binary?")
IF(STATIC_LINKING)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
ENDIF(STATIC_LINKING)
add_list_string_option(CMAKE_BUILD_TYPE "RelWithDebInfo" "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." Debug Release
RelWithDebInfo MinSizeRel)
Message("Build type is ${CMAKE_BUILD_TYPE}")
if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_boolean_option(LOG_OAI True "Thread safe logging API")
add_boolean_option(LOG_OAI_MINIMAL True "Thread safe logging API, log only levels above NOTICE")
SET(ASAN asan)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_boolean_option(LOG_OAI True "Thread safe logging API")
SET(ASAN asan)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "MinSizeRel")
endif()
Message("Build type is ${CMAKE_BUILD_TYPE}")
Message("Architecture is ${CMAKE_SYSTEM_PROCESSOR}")
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
set(C_FLAGS_PROCESSOR "-gdwarf-2 -mfloat-abi=hard -mfpu=neon -lgcc -lrt")
else (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
set(C_FLAGS_PROCESSOR "-msse4.2")
endif()
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} -std=gnu99 -Wall -Wstrict-prototypes -fno-strict-aliasing -rdynamic -funroll-loops -Wno-packed-bitfield-compat -fPIC ")
# add autoTOOLS definitions that were maybe used!
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_STRERROR=1 -DHAVE_SOCKET=1 -DHAVE_MEMSET=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_LIBSCTP")
add_definitions(-DCMAKER)
add_definitions(-DBSTRLIB_CAN_USE_STL=1 -DBSTRLIB_CAN_USE_IOSTREAM=1 -DBSTRLIB_THROWS_EXCEPTIONS=1)
if(STATIC_LINKING)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fno-omit-frame-pointer")
else (STATIC_LINKING)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fsanitize=address -fno-omit-frame-pointer")
endif(STATIC_LINKING)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2 -fno-omit-frame-pointer -s -DINFO_IS_ON=1 ")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -O2 -DINFO_IS_ON=1 ")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -Os -s -DTRACE_IS_ON=1 -DDEBUG_IS_ON=1 -DINFO_IS_ON=1")
if(STATIC_LINKING)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -std=c++17 -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fno-omit-frame-pointer -DBUPT=1 -DEURECOM=0")
else(STATIC_LINKING)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -std=c++17 -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fsanitize=address -fno-omit-frame-pointer -DBUPT=1 -DEURECOM=0")
endif(STATIC_LINKING)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -std=c++17 -O2 -fno-omit-frame-pointer -s -DINFO_IS_ON=1 -DBUPT=1 -DEURECOM=0")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -std=c++17 -g -O2 -DINFO_IS_ON=1 -DBUPT=1 -DEURECOM=0")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -std=c++17 -Os -s -DTRACE_IS_ON=1 -DDEBUG_IS_ON=1 -DINFO_IS_ON=1")
set(CMAKE_MODULE_PATH "${OPENAIRCN_DIR}/build/cmake_modules" "${CMAKE_MODULE_PATH}")
include(FindPkgConfig)
message("${OPENAIRCN_DIR}/build/cmake_modules")
include_directories(${SRC_TOP_DIR}/oai-amf)
include_directories(${SRC_TOP_DIR}/amf-app)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
### for common
include_directories(${SRC_TOP_DIR}/common)
file(GLOB COMMON_SRC ${SRC_TOP_DIR}/common/conversions.cpp)
### end for common
### for utils/bstr
include_directories(${SRC_TOP_DIR}/utils/bstr)
include_directories(${SRC_TOP_DIR}/utils)
file(GLOB BSTR_SRC
${SRC_TOP_DIR}/utils/bstr/bstrlib.c
${SRC_TOP_DIR}/utils/thread_sched.cpp
)
##end for utils/bstr
### for sctp
include_directories(${SRC_TOP_DIR}/sctp)
file(GLOB SCTP_SRC ${SRC_TOP_DIR}/sctp/sctp_server.cpp)
#end for sctp
### for ngap
include_directories(${SRC_TOP_DIR}/ngap/ngap_app)
file(GLOB NGAP_SRC ${SRC_TOP_DIR}/ngap/ngap_app/ngap_app.cpp)
###end for ngap
### for itti
include_directories(${SRC_TOP_DIR}/itti) include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/itti/msgs)
file(GLOB ITTI_SRC file(GLOB ITTI_SRC
${SRC_TOP_DIR}/itti/itti.cpp ${SRC_TOP_DIR}/itti/itti.cpp
${SRC_TOP_DIR}/itti/itti_msg.cpp ${SRC_TOP_DIR}/itti/itti_msg.cpp
) )
###end for itti
### for log
add_library( LOG STATIC
${SRC_TOP_DIR}/common/logger.cpp)
add_library( OPTIONS STATIC
${SRC_TOP_DIR}/oai-amf/options.cpp)
###end for log
### for config
add_library( CONFIGS STATIC
${SRC_TOP_DIR}/amf-app/amf_config.cpp)
pkg_search_module(CONFIG REQUIRED libconfig++)
include_directories(${CONFIG_INCLUDE_DIRS})
### end for config
add_executable(amf
#${SRC_TOP_DIR}/oai-amf/main.cpp
#${SRC_TOP_DIR}/ngap/main.cpp
${SRC_TOP_DIR}/itti/main.cpp
${COMMON_SRC} ${BSTR_SRC} ${SCTP_SRC} ${NGAP_SRC} ${ITTI_SRC}
)
# LOG from oai-amf/CMakeLists.txt
target_link_libraries(amf -Wl,--start-group LOG OPTIONS CONFIGS config++ sctp pthread)
...@@ -94,10 +94,16 @@ message("${OPENAIRCN_DIR}/build/cmake_modules") ...@@ -94,10 +94,16 @@ message("${OPENAIRCN_DIR}/build/cmake_modules")
include_directories(${SRC_TOP_DIR}/oai-amf) include_directories(${SRC_TOP_DIR}/oai-amf)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include) include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
#include_directories(${SRC_TOP_DIR}/itti)
### for itti msg ### for itti
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/itti/msgs) include_directories(${SRC_TOP_DIR}/itti/msgs)
###end for itti msg file(GLOB ITTI_SRC
${SRC_TOP_DIR}/itti/itti.cpp
${SRC_TOP_DIR}/itti/itti_msg.cpp
)
###end for itti
### for amf nas ### for amf nas
include_directories(${SRC_TOP_DIR}/nas) include_directories(${SRC_TOP_DIR}/nas)
...@@ -182,14 +188,6 @@ file(GLOB NGAP_MSGS_IES_SRC ...@@ -182,14 +188,6 @@ file(GLOB NGAP_MSGS_IES_SRC
) )
### end for ### end for
### for itti
include_directories(${SRC_TOP_DIR}/itti)
file(GLOB ITTI_SRC
${SRC_TOP_DIR}/itti/itti.cpp
${SRC_TOP_DIR}/itti/itti_msg.cpp
)
###end for itti
### for authentication ### for authentication
include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka) include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka)
include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka/test) include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka/test)
......
...@@ -33,12 +33,10 @@ extern void ue_gnb_simulator(); ...@@ -33,12 +33,10 @@ extern void ue_gnb_simulator();
using namespace std; using namespace std;
using namespace config; using namespace config;
//using namespace ngap;
using namespace amf_application; using namespace amf_application;
amf_config amf_cfg; amf_config amf_cfg;
amf_modules modules; amf_modules modules;
//ngap_app * ngap_inst = NULL;
itti_mw *itti_inst = nullptr; itti_mw *itti_inst = nullptr;
amf_app *amf_app_inst = nullptr; amf_app *amf_app_inst = nullptr;
statistics stacs; statistics stacs;
......
...@@ -50,11 +50,6 @@ extern "C" { ...@@ -50,11 +50,6 @@ extern "C" {
using namespace std; using namespace std;
namespace sctp { namespace sctp {
/*
uint32_t sctp_application::getPpid(){
return ppid_;
}
*/
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
sctp_server::sctp_server(const char *address, const uint16_t port_num) { sctp_server::sctp_server(const char *address, const uint16_t port_num) {
...@@ -135,7 +130,6 @@ void* sctp_server::sctp_receiver_thread(void *arg) { ...@@ -135,7 +130,6 @@ void* sctp_server::sctp_receiver_thread(void *arg) {
fdmax -= 1; fdmax -= 1;
} }
} }
} }
} }
} }
...@@ -255,28 +249,6 @@ sctp_association_t* sctp_server::add_new_association(int sd, uint32_t ppid, stru ...@@ -255,28 +249,6 @@ sctp_association_t* sctp_server::add_new_association(int sd, uint32_t ppid, stru
app_->handle_sctp_new_association(new_association->assoc_id, new_association->instreams, new_association->outstreams); app_->handle_sctp_new_association(new_association->assoc_id, new_association->instreams, new_association->outstreams);
return new_association; return new_association;
} }
/*
sctp_association_t* sctp_server::sctp_add_new_peer (void){
sctp_association_t *new_sctp_descriptor = (sctp_association_t*)calloc (1, sizeof (sctp_association_t));
if (new_sctp_descriptor == NULL) {
Logger::sctp().error("Failed to allocate memory for new peer (%s:%d)",__FILE__,__LINE__);
return NULL;
}
new_sctp_descriptor->next_assoc = NULL;
new_sctp_descriptor->previous_assoc = NULL;
if (sctp_desc.available_connections_tail == NULL) {
sctp_desc.available_connections_head = new_sctp_descriptor;
sctp_desc.available_connections_tail = sctp_desc.available_connections_head;
} else {
new_sctp_descriptor->previous_assoc = sctp_desc.available_connections_tail;
sctp_desc.available_connections_tail->next_assoc = new_sctp_descriptor;
sctp_desc.available_connections_tail = new_sctp_descriptor;
}
sctp_desc.number_of_connections++;
//sctp_dump_list ();
return new_sctp_descriptor;
}
*/
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
sctp_association_t* sctp_server::sctp_is_assoc_in_list(sctp_assoc_id_t assoc_id) { sctp_association_t* sctp_server::sctp_is_assoc_in_list(sctp_assoc_id_t assoc_id) {
......
...@@ -79,10 +79,6 @@ class sctp_application { ...@@ -79,10 +79,6 @@ class sctp_application {
virtual void handle_receive(bstring payload, sctp_assoc_id_t assoc_id, sctp_stream_id_t stream, sctp_stream_id_t instreams, sctp_stream_id_t outstreams) = 0; virtual void handle_receive(bstring payload, sctp_assoc_id_t assoc_id, sctp_stream_id_t stream, sctp_stream_id_t instreams, sctp_stream_id_t outstreams) = 0;
virtual void handle_sctp_new_association(sctp_assoc_id_t assoc_id, sctp_stream_id_t instreams, sctp_stream_id_t outstreams) = 0; virtual void handle_sctp_new_association(sctp_assoc_id_t assoc_id, sctp_stream_id_t instreams, sctp_stream_id_t outstreams) = 0;
virtual uint32_t getPpid() = 0; virtual uint32_t getPpid() = 0;
//protected:
//uint32_t ppid_;
//uint32_t getPpid();
}; };
class sctp_server { class sctp_server {
...@@ -100,7 +96,6 @@ class sctp_server { ...@@ -100,7 +96,6 @@ class sctp_server {
int sctp_handle_com_down(sctp_assoc_id_t assoc_id); int sctp_handle_com_down(sctp_assoc_id_t assoc_id);
int sctp_handle_reset(const sctp_assoc_id_t assoc_id); int sctp_handle_reset(const sctp_assoc_id_t assoc_id);
sctp_association_t* add_new_association(int sd, uint32_t ppid, struct sctp_assoc_change *sctp_assoc_changed); sctp_association_t* add_new_association(int sd, uint32_t ppid, struct sctp_assoc_change *sctp_assoc_changed);
sctp_association_t* sctp_add_new_peer(void);
int sctp_get_localaddresses(int sock, struct sockaddr **local_addr, int *nb_local_addresses); int sctp_get_localaddresses(int sock, struct sockaddr **local_addr, int *nb_local_addresses);
int sctp_get_peeraddresses(int sock, struct sockaddr **remote_addr, int *nb_remote_addresses); int sctp_get_peeraddresses(int sock, struct sockaddr **remote_addr, int *nb_remote_addresses);
sctp_association_t* sctp_is_assoc_in_list(sctp_assoc_id_t assoc_id); sctp_association_t* sctp_is_assoc_in_list(sctp_assoc_id_t assoc_id);
......
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