Commit 48dc1b75 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Cleanup CMakeLists/remove unnecessary files

parent eb74e19d
...@@ -11,5 +11,3 @@ set (BUILD_TOP_DIR ${OPENAIRCN_DIR}/build) ...@@ -11,5 +11,3 @@ set (BUILD_TOP_DIR ${OPENAIRCN_DIR}/build)
set (SRC_TOP_DIR $ENV{OPENAIRCN_DIR}/src) set (SRC_TOP_DIR $ENV{OPENAIRCN_DIR}/src)
include(${CMAKE_CURRENT_SOURCE_DIR}/../../src/oai-amf/CMakeLists.txt) include(${CMAKE_CURRENT_SOURCE_DIR}/../../src/oai-amf/CMakeLists.txt)
#ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/common ${CMAKE_CURRENT_BINARY_DIR}/common)
...@@ -142,7 +142,7 @@ function main() ...@@ -142,7 +142,7 @@ function main()
cd ./build cd ./build
$CMAKE $cmake_args .. > /dev/null $CMAKE $cmake_args .. > /dev/null
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
compilations amf amf $OPENAIRCN_DIR/build/amf/build/amf compilations amf amf $OPENAIRCN_DIR/build/amf/build/amf $verbose
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
# For daemon should not be group writable # For daemon should not be group writable
$SUDO chmod 755 $OPENAIRCN_DIR/build/amf/build/amf $SUDO chmod 755 $OPENAIRCN_DIR/build/amf/build/amf
......
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/amf-app)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/itti/msgs)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/unicode)
include_directories(${SRC_TOP_DIR}/contexts)
include_directories(${SRC_TOP_DIR}/nas/ies)
include_directories(${SRC_TOP_DIR}/nas/common)
include_directories(${SRC_TOP_DIR}/nas/msgs)
include_directories(${SRC_TOP_DIR}/nas/utils)
include_directories(${SRC_TOP_DIR}/ngap/libngap)
include_directories(${SRC_TOP_DIR}/ngap/ngap_app)
include_directories(${SRC_TOP_DIR}/ngap/ngapIEs)
include_directories(${SRC_TOP_DIR}/ngap/ngapMsgs)
include_directories(${SRC_TOP_DIR}/sbi/amf_server)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/api)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/impl)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/model)
include_directories(${SRC_TOP_DIR}/sbi/smf_client)
include_directories(${SRC_TOP_DIR}/sbi/smf_client/api)
include_directories(${SRC_TOP_DIR}/sbi/smf_client/inputs)
include_directories(${SRC_TOP_DIR}/sbi/smf_client/model)
include_directories(${SRC_TOP_DIR}/sctp)
include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka)
include_directories(${SRC_TOP_DIR}/secu_algorithms/nas_enc_int)
include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr)
file(GLOB AMF_src_files
${CMAKE_CURRENT_SOURCE_DIR}/amf_app.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_module_from_config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_n1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_n2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_n11.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_statistics.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mysql_db.cpp
${SRC_TOP_DIR}/nas/msgs/*.cpp
${SRC_TOP_DIR}/nas/ies/*.cpp
${SRC_TOP_DIR}/nas/utils/*.c
${SRC_TOP_DIR}/utils/*.cpp
${SRC_TOP_DIR}/utils/*.c
${SRC_TOP_DIR}/utils/bstr/*.c
${SRC_TOP_DIR}/ngap/libngap/*.c
${SRC_TOP_DIR}/ngap/ngap_app/*.cpp
${SRC_TOP_DIR}/ngap/ngapMsgs/*.cpp
${SRC_TOP_DIR}/ngap/ngapIEs/*.cpp
)
add_library (AMF STATIC
${AMF_src_files}
)
include_directories(${SRC_TOP_DIR}/common) include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include) include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
add_library( LOG STATIC include_directories(${SRC_TOP_DIR}/common/unicode)
file(GLOB COMMON_SRC ${SRC_TOP_DIR}/common/conversions.cpp)
add_library(3GPP_COMMON_TYPES STATIC
${SRC_TOP_DIR}/common/logger.cpp ${SRC_TOP_DIR}/common/logger.cpp
${SRC_TOP_DIR}/common/conversions.cpp
) )
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/itti/msgs)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/unicode)
include_directories(${SRC_TOP_DIR}/contexts)
include_directories(${SRC_TOP_DIR}/nas/ies)
include_directories(${SRC_TOP_DIR}/nas/common)
include_directories(${SRC_TOP_DIR}/nas/utils)
include_directories(${SRC_TOP_DIR}/ngap/libngap)
include_directories(${SRC_TOP_DIR}/ngap/ngapIEs)
include_directories(${SRC_TOP_DIR}/sctp)
include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka)
include_directories(${SRC_TOP_DIR}/secu_algorithms/nas_enc_int)
include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr)
add_library (CONTEXTS STATIC
${CMAKE_CURRENT_SOURCE_DIR}/gNB_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nas_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pdu_session_context.cpp
)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/itti/msgs)
file(GLOB ITTI_SRC
${SRC_TOP_DIR}/itti/itti.cpp
${SRC_TOP_DIR}/itti/itti_msg.cpp
)
#include <iostream>
#include <thread>
#include <signal.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include "logger.hpp"
#include "options.hpp"
#include "amf_config.hpp"
#include "ngap_app.hpp"
#include "itti.hpp"
using namespace std;
using namespace config;
using namespace ngap;
amf_config amf_cfg;
ngap_app *ngap_inst = NULL;
itti_mw *itti_inst = nullptr;
//------------------------------------------------------------------------------
void amf_ngap_app_task(void*) {
const task_id_t task_id = TASK_NGAP_APP;
itti_inst->notify_task_ready(task_id);
Logger::itti().debug("task(%d) ready", TASK_NGAP_APP);
}
//------------------------------------------------------------------------------
int main(int argc, char **argv) {
srand (time(NULL));
if (!Options::parse(argc, argv)) {
cout<<"Options::parse() failed"<<endl;
return 1;
}
Logger::init( "amf" , Options::getlogStdout() , Options::getlogRotFilelog());
Logger::amf_app().startup("Options parsed!");
amf_cfg.load(Options::getlibconfigConfig());
amf_cfg.display();
//ngap_inst = new ngap_app("10.103.238.20",38412);
itti_inst = new itti_mw();
//itti_inst->start(amf_cfg.itti.itti_timer_sched_params);
itti_inst->create_task(TASK_NGAP_APP, amf_ngap_app_task,nullptr);
Logger::amf_app().debug("Initiating Done!");
pause();
return 0;
}
################################################################################
# Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The OpenAirInterface Software Alliance licenses this file to You under
# the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
#
# 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.
#-------------------------------------------------------------------------------
# For more information about the OpenAirInterface (OAI) Software Alliance:
# contact@openairinterface.org
################################################################################
cmake_minimum_required (VERSION 3.0.2) cmake_minimum_required (VERSION 3.0.2)
###########################################
# macros to define options as there is numerous options in oai
################################################
macro(add_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
add_definitions("-D${name}=${value}")
endmacro(add_option)
macro(add_boolean_option name val helpstr) macro(add_boolean_option name val helpstr)
if(DEFINED ${name}) if(DEFINED ${name})
set(value ${${name}}) set(value ${${name}})
...@@ -14,6 +48,42 @@ macro(add_boolean_option name val helpstr) ...@@ -14,6 +48,42 @@ macro(add_boolean_option name val helpstr)
endif (${value}) endif (${value})
endmacro(add_boolean_option) endmacro(add_boolean_option)
macro(add_integer_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
add_definitions("-D${name}=${value}")
endmacro(add_integer_option)
macro(add_list1_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_list1_option)
macro(add_list2_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${value}=1")
endif()
endmacro(add_list2_option)
macro(add_list_string_option name val helpstr) macro(add_list_string_option name val helpstr)
if(DEFINED ${name}) if(DEFINED ${name})
set(value ${${name}}) set(value ${${name}})
...@@ -26,15 +96,25 @@ macro(add_list_string_option name val helpstr) ...@@ -26,15 +96,25 @@ macro(add_list_string_option name val helpstr)
add_definitions("-D${name}=\"${value}\"") add_definitions("-D${name}=\"${value}\"")
endif() endif()
endmacro(add_list_string_option) endmacro(add_list_string_option)
################################################################
# Compilation flags
################################################################
# determine, whether we want a static binary
SET(STATIC_LINKING FALSE CACHE BOOL "Build a static binary?") SET(STATIC_LINKING FALSE CACHE BOOL "Build a static binary?")
# do we want static libraries?
# When STATIC_LINKING is TRUE, than cmake looks for libraries ending
# with .a. This is for linux only!
IF(STATIC_LINKING) IF(STATIC_LINKING)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
ENDIF(STATIC_LINKING) ENDIF(STATIC_LINKING)
################################################################
# Build type
################################################################
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 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) RelWithDebInfo MinSizeRel)
Message("Build type is ${CMAKE_BUILD_TYPE}") Message("Build type is ${CMAKE_BUILD_TYPE}")
if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_boolean_option(LOG_OAI True "Thread safe logging API") add_boolean_option(LOG_OAI True "Thread safe logging API")
...@@ -46,9 +126,12 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") ...@@ -46,9 +126,12 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(ASAN asan) SET(ASAN asan)
endif() endif()
if (CMAKE_BUILD_TYPE STREQUAL "") if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "MinSizeRel") set(CMAKE_BUILD_TYPE "MinSizeRel")
endif() endif()
Message("Build type is ${CMAKE_BUILD_TYPE}")
################################################################
# Processor architecture
################################################################
Message("Architecture is ${CMAKE_SYSTEM_PROCESSOR}") Message("Architecture is ${CMAKE_SYSTEM_PROCESSOR}")
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l") if (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
...@@ -56,16 +139,19 @@ if (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l") ...@@ -56,16 +139,19 @@ if (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
else (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l") else (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
set(C_FLAGS_PROCESSOR "-msse4.2") set(C_FLAGS_PROCESSOR "-msse4.2")
endif() endif()
#
set(CMAKE_C_FLAGS 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 ") "${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! # add autoTOOLS definitions that were maybe used!
set(CMAKE_C_FLAGS 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") "${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"
)
# set a flag for changes in the source code
# these changes are related to hardcoded path to include .h files
add_definitions(-DCMAKER) add_definitions(-DCMAKER)
add_definitions(-DBSTRLIB_CAN_USE_STL=1 -DBSTRLIB_CAN_USE_IOSTREAM=1 -DBSTRLIB_THROWS_EXCEPTIONS=1) add_definitions(-DBSTRLIB_CAN_USE_STL=1 -DBSTRLIB_CAN_USE_IOSTREAM=1 -DBSTRLIB_THROWS_EXCEPTIONS=1)
if(STATIC_LINKING) 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") 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) else (STATIC_LINKING)
...@@ -76,189 +162,93 @@ set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -O2 -DINFO_IS_ON=1 ") ...@@ -76,189 +162,93 @@ 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 -DAUTH_ALG_ON=0") set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -Os -s -DTRACE_IS_ON=1 -DDEBUG_IS_ON=1 -DINFO_IS_ON=1 -DAUTH_ALG_ON=0")
if(STATIC_LINKING) 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") 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")
else(STATIC_LINKING) 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") 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")
endif(STATIC_LINKING) 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_RELEASE "${CMAKE_CXX_FLAGS} -std=c++17 -O2 -fno-omit-frame-pointer -s -DINFO_IS_ON=1")
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_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -std=c++17 -g -O2 -DINFO_IS_ON=1")
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_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -std=c++17 -Os -s")
################################################################
# Git Version
################################################################
set(GIT_BRANCH "UNKNOWN")
set(GIT_COMMIT_HASH "UNKNOWN")
set(GIT_COMMIT_DATE "UNKNOWN")
find_package(Git)
if(GIT_FOUND)
message("git found: ${GIT_EXECUTABLE}")
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest commit date of the working branch
execute_process(
COMMAND git log -1 --format=%cd
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
set(CMAKE_MODULE_PATH "${OPENAIRCN_DIR}/build/cmake_modules" "${CMAKE_MODULE_PATH}")
include(FindPkgConfig)
message("${OPENAIRCN_DIR}/build/cmake_modules")
add_definitions("-DPACKAGE_VERSION=\"Branch: ${GIT_BRANCH} Abrev. Hash: ${GIT_COMMIT_HASH} Date: ${GIT_COMMIT_DATE}\"")
add_definitions("-DPACKAGE_BUGREPORT=\"openaircn-user@lists.eurecom.fr\"")
include_directories(${SRC_TOP_DIR}/oai-amf) ###############################################################################
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include) # Include CMake modules to find other library
#include_directories(${SRC_TOP_DIR}/itti) ###############################################################################
### for itti set(CMAKE_MODULE_PATH "${OPENAIRCN_DIR}/build/cmake_modules" "${CMAKE_MODULE_PATH}")
include_directories(${SRC_TOP_DIR}/itti) include(FindPkgConfig)
include_directories(${SRC_TOP_DIR}/itti/msgs)
file(GLOB ITTI_SRC
${SRC_TOP_DIR}/itti/itti.cpp
${SRC_TOP_DIR}/itti/itti_msg.cpp
)
###end for itti
### for amf nas ###############################################################################
include_directories(${SRC_TOP_DIR}/nas) # Include Check library for unit tests
file(GLOB AMF_NAS_SRC ###############################################################################
${SRC_TOP_DIR}/nas/nas_context.cpp
)
###end for
### for libnas
include_directories(${SRC_TOP_DIR}/nas/common)
include_directories(${SRC_TOP_DIR}/nas/common)
include_directories(${SRC_TOP_DIR}/nas/ies)
include_directories(${SRC_TOP_DIR}/nas/msgs)
include_directories(${SRC_TOP_DIR}/nas/utils)
file(GLOB NAS_SRC
${SRC_TOP_DIR}/nas/common/*.cpp
${SRC_TOP_DIR}/nas/ies/*.cpp
${SRC_TOP_DIR}/nas/msgs/*.cpp
${SRC_TOP_DIR}/nas/utils/*.cpp
${SRC_TOP_DIR}/nas/utils/*.c
)
###end for
### for amf_app include(CheckCSourceCompiles)
include_directories(${SRC_TOP_DIR}/amf-app) include(CheckCSourceRuns)
file(GLOB AMF_APP_SRC include(CheckFunctionExists)
${SRC_TOP_DIR}/amf-app/amf_app.cpp include(CheckIncludeFile)
${SRC_TOP_DIR}/amf-app/amf_n2.cpp include(CheckIncludeFiles)
${SRC_TOP_DIR}/amf-app/amf_n1.cpp include(CheckLibraryExists)
${SRC_TOP_DIR}/amf-app/amf_n11.cpp include(CheckSymbolExists)
${SRC_TOP_DIR}/amf-app/amf_statistics.cpp include(CheckTypeSize)
)
### end for amf_app
### for common
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/unicode)
file(GLOB COMMON_SRC ${SRC_TOP_DIR}/common/conversions.cpp)
### end for common
### for utils/bstr ###############################################################################
include_directories(${SRC_TOP_DIR}/utils/bstr) # Debug and build related options
include_directories(${SRC_TOP_DIR}/utils) ###############################################################################
file(GLOB MULTI_PARSER_SRC
${SRC_TOP_DIR}/utils/multipartparser.cpp
${SRC_TOP_DIR}/utils/http_multi_parser.cpp
)
file(GLOB BSTR_SRC
${SRC_TOP_DIR}/utils/bstr/bstrlib.c
${SRC_TOP_DIR}/utils/thread_sched.cpp
)
file(GLOB UTILS_SRC
${SRC_TOP_DIR}/utils/string.cpp
${SRC_TOP_DIR}/utils/if.cpp
${SRC_TOP_DIR}/utils/backtrace.c
${SRC_TOP_DIR}/utils/hex_string_convert.cpp
)
##end for utils/bstr
### for sctp add_boolean_option( DISPLAY_LICENCE_INFO False "If a module has a licence banner to show")
include_directories(${SRC_TOP_DIR}/sctp) add_boolean_option( LOG_OAI False "Thread safe logging utility")
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 generated libngap # System packages that are required
include_directories(${SRC_TOP_DIR}/ngap/libngap) # We use either the cmake buildin, in ubuntu are in: /usr/share/cmake*/Modules/
file(GLOB LIB_NGAP_SRC ${SRC_TOP_DIR}/ngap/libngap/*.c) # or cmake provide a generic interface to pkg-config that widely used
###end ###################################
### for encapsulated ngap message
include_directories(${SRC_TOP_DIR}/ngap/ngapIEs)
include_directories(${SRC_TOP_DIR}/ngap/ngapMsgs)
file(GLOB NGAP_MSGS_IES_SRC
${SRC_TOP_DIR}/ngap/ngapIEs/*.cpp
${SRC_TOP_DIR}/ngap/ngapMsgs/*.cpp
)
### end for
### for authentication
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/algorithm_from_spec)
file(GLOB 5GAKA_SRC ${SRC_TOP_DIR}/secu_algorithms/5gaka/*.cpp)
###end for
### for nas algorithms
include_directories(${SRC_TOP_DIR}/secu_algorithms/nas_enc_int)
file(GLOB NAS_ALG_SRC
${SRC_TOP_DIR}/secu_algorithms/nas_enc_int/*.cpp
${SRC_TOP_DIR}/secu_algorithms/nas_enc_int/*.c
)
###end
### 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
${SRC_TOP_DIR}/amf-app/amf_module_from_config.cpp
)
pkg_search_module(CONFIG REQUIRED libconfig++) pkg_search_module(CONFIG REQUIRED libconfig++)
include_directories(${CONFIG_INCLUDE_DIRS}) include_directories(${CONFIG_INCLUDE_DIRS})
### end for config
### for context
include_directories(${SRC_TOP_DIR}/contexts)
file(GLOB CTXS_SRC ${SRC_TOP_DIR}/contexts/*.cpp)
###end
###for N11(smf client)
include_directories(${SRC_TOP_DIR}/sbi/smf_client)
include_directories(${SRC_TOP_DIR}/sbi/smf_client/api)
include_directories(${SRC_TOP_DIR}/sbi/smf_client/model)
file(GLOB SMF_CLIENT_SRC
${SRC_TOP_DIR}/sbi/smf_client/*.cpp
${SRC_TOP_DIR}/sbi/smf_client/api/*.cpp
${SRC_TOP_DIR}/sbi/smf_client/model/*.cpp
)
###end
###for amf server set(THREADS_PREFER_PTHREAD_FLAG ON)
include_directories(${SRC_TOP_DIR}/sbi/amf_server) #find_package(Threads REQUIRED)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/api)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/impl)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/model)
file(GLOB AMF_SERVER_SRC
${SRC_TOP_DIR}/sbi/amf_server/*.cpp
${SRC_TOP_DIR}/sbi/amf_server/api/*.cpp
${SRC_TOP_DIR}/sbi/amf_server/impl/*.cpp
${SRC_TOP_DIR}/sbi/amf_server/model/*.cpp
)
###end
### for mysqp handlers
file(GLOB MYSQL_HANDLERS_SRC
${SRC_TOP_DIR}/amf-app/mysql_db.cpp
)
###end
### for sha-256 algorithms
### end
### for ue_gnb_simu
file(GLOB UE_GNB_SRC
${SRC_TOP_DIR}/test/ue_gnb.cpp
)
pkg_search_module(CRYPTO libcrypto REQUIRED) pkg_search_module(CRYPTO libcrypto REQUIRED)
...@@ -300,12 +290,68 @@ IF( NOT MySQL_FOUND ) ...@@ -300,12 +290,68 @@ IF( NOT MySQL_FOUND )
MESSAGE( SEND_ERROR "MySQL Client is required" ) MESSAGE( SEND_ERROR "MySQL Client is required" )
ENDIF( NOT MySQL_FOUND ) ENDIF( NOT MySQL_FOUND )
################################################################
# Add sub modules
################################################################
if(STATIC_LINKING)
SET(BUILD_SHARED_LIBS OFF)
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/amf-app ${CMAKE_CURRENT_BINARY_DIR}/amf-app)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/contexts ${CMAKE_CURRENT_BINARY_DIR}/contexts)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/sbi/amf_server ${CMAKE_CURRENT_BINARY_DIR}/sbi/amf_server)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/sbi/smf_client ${CMAKE_CURRENT_BINARY_DIR}/sbi/smf_client)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/sctp ${CMAKE_CURRENT_BINARY_DIR}/sctp)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/utils ${CMAKE_CURRENT_BINARY_DIR}/utils)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/secu_algorithms/5gaka ${CMAKE_CURRENT_BINARY_DIR}/secu_algorithms/5gaka)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/secu_algorithms/nas_enc_int ${CMAKE_CURRENT_BINARY_DIR}/secu_algorithms/nas_enc_int)
include_directories(${SRC_TOP_DIR}/oai-amf)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/amf-app)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/itti/msgs)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/unicode)
include_directories(${SRC_TOP_DIR}/contexts)
include_directories(${SRC_TOP_DIR}/nas/ies)
include_directories(${SRC_TOP_DIR}/nas/common)
include_directories(${SRC_TOP_DIR}/nas/msgs)
include_directories(${SRC_TOP_DIR}/nas/utils)
include_directories(${SRC_TOP_DIR}/ngap/libngap)
include_directories(${SRC_TOP_DIR}/ngap/ngap_app)
include_directories(${SRC_TOP_DIR}/ngap/ngapIEs)
include_directories(${SRC_TOP_DIR}/ngap/ngapMsgs)
include_directories(${SRC_TOP_DIR}/sbi/amf_server)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/api)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/impl)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/model)
include_directories(${SRC_TOP_DIR}/sbi/smf_client)
include_directories(${SRC_TOP_DIR}/sbi/smf_client/api)
include_directories(${SRC_TOP_DIR}/sbi/smf_client/inputs)
include_directories(${SRC_TOP_DIR}/sbi/smf_client/model)
include_directories(${SRC_TOP_DIR}/sctp)
include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka)
include_directories(${SRC_TOP_DIR}/secu_algorithms/nas_enc_int)
include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr)
add_executable(amf add_executable(amf
${SRC_TOP_DIR}/oai-amf/main.cpp ${SRC_TOP_DIR}/oai-amf/main.cpp
${COMMON_SRC} ${BSTR_SRC} ${SCTP_SRC} ${NGAP_SRC} ${ITTI_SRC} ${AMF_APP_SRC} ${UTILS_SRC} ${LIB_NGAP_SRC} ${AMF_NAS_SRC} ${SRC_TOP_DIR}/oai-amf/options.cpp
${NGAP_MSGS_IES_SRC} ${CTXS_SRC} ${5GAKA_SRC} ${NAS_SRC} ${SMF_CLIENT_SRC} ${SRC_TOP_DIR}/itti/itti.cpp
${MYSQL_HANDLERS_SRC} ${NAS_ALG_SRC} ${AMF_SERVER_SRC} ${UE_GNB_SRC} ${MULTI_PARSER_SRC} ${SRC_TOP_DIR}/itti/itti_msg.cpp
) )
# LOG from oai-amf/CMakeLists.txt IF(STATIC_LINKING)
target_link_libraries(amf -Wl,--start-group LOG OPTIONS CONFIGS config++ sctp pthread ${NETTLE_LIBRARIES} ${MySQL_LIBRARY} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} boost_system ssl crypt cpprest gmp pistache curl) SET(CMAKE_EXE_LINKER_FLAGS "-static")
SET_TARGET_PROPERTIES(amf PROPERTIES LINK_SEARCH_END_STATIC 1)
# asan do not support static linking
SET(ASAN)
ENDIF(STATIC_LINKING)
target_link_libraries(amf ${ASAN}
-Wl,--start-group 3GPP_COMMON_TYPES AMF CONTEXTS AMF_SCTP AMF_SECU_5GAKA AMF_SECU_NAS AMF_UTILS AMF_SBI_CLIENT AMF_SBI_SERVER config++ sctp pthread ${NETTLE_LIBRARIES} ${MySQL_LIBRARY} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} boost_system ssl crypt cpprest gmp pistache curl)
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "amf_statistics.hpp" #include "amf_statistics.hpp"
#include "SMFClientApi.hpp" #include "SMFClientApi.hpp"
#include "test.hpp"
#include "smf-client.hpp" #include "smf-client.hpp"
#include <string> #include <string>
......
set(AMF_API_SERVER_DIR "${SRC_TOP_DIR}/sbi/amf_server")
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/amf-app)
include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/itti/msgs)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/unicode)
include_directories(${SRC_TOP_DIR}/contexts)
include_directories(${SRC_TOP_DIR}/nas/common)
include_directories(${SRC_TOP_DIR}/ngap/libngap)
include_directories(${SRC_TOP_DIR}/ngap/ngapIEs)
include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka)
include_directories(${SRC_TOP_DIR}/secu_algorithms/nas_enc_int)
include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr)
include_directories(${SRC_TOP_DIR}/sbi/amf_server)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/api)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/impl)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/model)
file(GLOB AMF_API_SERVER_src_files
${AMF_API_SERVER_DIR}/AMFApiServer.cpp
${AMF_API_SERVER_DIR}/model/*.cpp
${AMF_API_SERVER_DIR}/api/*.cpp
${AMF_API_SERVER_DIR}/impl/*.cpp
)
add_library(AMF_SBI_SERVER STATIC
${AMF_API_SERVER_src_files})
# include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
# Nsmf_PDUSession include_directories(${SRC_TOP_DIR}/common)
# SMF PDU Session Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved. include_directories(${SRC_TOP_DIR}/common/unicode)
# include_directories(${SRC_TOP_DIR}/contexts)
# The version of the OpenAPI document: 1.0.0 include_directories(${SRC_TOP_DIR}/nas/common)
# include_directories(${SRC_TOP_DIR}/utils)
# https://openapi-generator.tech include_directories(${SRC_TOP_DIR}/utils/bstr)
# include_directories(${SRC_TOP_DIR}/sbi/smf_client)
# NOTE: Auto generated by OpenAPI Generator (https://openapi-generator.tech). include_directories(${SRC_TOP_DIR}/sbi/smf_client/api)
include_directories(${SRC_TOP_DIR}/sbi/smf_client/inputs)
cmake_minimum_required (VERSION 2.8) include_directories(${SRC_TOP_DIR}/sbi/smf_client/model)
#PROJECT's NAME add_library (AMF_SBI_CLIENT STATIC
project(CppRestOpenAPIClient) ${CMAKE_CURRENT_SOURCE_DIR}/ApiClient.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ApiConfiguration.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ApiException.cpp
# THE LOCATION OF OUTPUT BINARIES ${CMAKE_CURRENT_SOURCE_DIR}/HttpContent.cpp
set(CMAKE_LIBRARY_DIR ${PROJECT_SOURCE_DIR}/lib) ${CMAKE_CURRENT_SOURCE_DIR}/JsonBody.cpp
set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_DIR}) ${CMAKE_CURRENT_SOURCE_DIR}/ModelBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/MultipartFormData.cpp
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") ${CMAKE_CURRENT_SOURCE_DIR}/Object.cpp
${CMAKE_CURRENT_SOURCE_DIR}/SMFClientApi.cpp
if(NOT CMAKE_BUILD_TYPE) )
set(CMAKE_BUILD_TYPE Release)
endif()
# BUILD TYPE
message("A ${CMAKE_BUILD_TYPE} build configuration is detected")
# Update require components as necessary
#find_package(Boost 1.45.0 REQUIRED COMPONENTS ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
# build and set path to cpp rest sdk
set(CPPREST_ROOT "~/cpprestsdk/Release")
set(CPPREST_INCLUDE_DIR ${CPPREST_ROOT}/include)
set(CPPREST_LIBRARY_DIR ${CPPREST_ROOT}/lib)
include_directories(${PROJECT_SOURCE_DIR} api model ${CPPREST_INCLUDE_DIR})
# If using vcpkg, set include directories. Also comment out CPPREST section above since vcpkg will handle it.
# To install required vcpkg packages execute:
# > vcpkg install cpprestsdk cpprestsdk:x64-windows boost-uuid boost-uuid:x64-windows
# set(VCPKG_ROOT "C:\\vcpkg\\installed\\x64-windows")
# set(VCPKG_INCLUDE_DIR ${VCPKG_ROOT}/include)
# set(VCPKG_LIBRARY_DIR ${VCPKG_ROOT}/lib)
# include_directories(${PROJECT_SOURCE_DIR} api model ${VCPKG_INCLUDE_DIR})
#SUPPORTING FILES
set(SUPPORTING_FILES "ApiClient" "ApiConfiguration" "ApiException" "HttpContent" "IHttpBody" "JsonBody" "ModelBase" "MultipartFormData" "Object")
#SOURCE FILES
file(GLOB SOURCE_FILES "api/*" "model/*")
add_library(${PROJECT_NAME} ${SUPPORTING_FILES} ${SOURCE_FILES})
set(SMF_API_CLIENT_SOURCES
SMFClientApi.cpp
${SOURCE_FILES} ${SUPPORTING_FILES} )
add_executable(smf_client_api
${SMF_API_CLIENT_SOURCES})
target_link_libraries(smf_client_api boost_system pthread ssl cpprest crypto )
#include "SMFClientApi.hpp"
#include "IndividualPDUSessionHSMFApi.h"
#include "IndividualSMContextApi.h"
#include "PDUSessionsCollectionApi.h"
#include "SMContextsCollectionApi.h"
#include "ApiConfiguration.h"
#include "ApiClient.h"
#include "nlohmann/json.hpp"
#include "logger.hpp"
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
#define DEFAULT_JSON_FILE "/home/oai/oai-5g-amf/src/sbi/smf_client/inputs/SmContextCreateData.json"
using namespace utility; // Common utilities like string conversions
using namespace web; // Common features like URIs.
using namespace web::http; // Common HTTP functionality
using namespace web::http::client; // HTTP client features
using namespace concurrency::streams; // Asynchronous streams // JSON library
using namespace oai::smf::api;
using namespace oai::smf::model;
//using json = nlohmann::json;
int smf_client_test()
{
// create ApiConfiguration
std::shared_ptr <ApiConfiguration> apiConfiguration (new ApiConfiguration);
apiConfiguration->setBaseUrl(utility::conversions::to_string_t("http://10.103.238.82:8889/nsmf-pdusession/v2"));
//apiConfiguration->setBaseUrl(utility::conversions::to_string_t("http://192.168.2.189:8889/nsmf-pdusession/v2"));
std::shared_ptr <ApiClient> apiClient(new ApiClient (apiConfiguration));
std::shared_ptr<SmContextMessage> smContextMessage (new SmContextMessage);
//fill the content of smContextMessage
//TODO:
std::shared_ptr<SmContextCreateData> smContextCreateData (new SmContextCreateData);
Logger::amf_app().debug("starting test smf_client");
json::value jv; // JSON read from input file
try {
Logger::amf_app().debug("try to get smcontextcreatedata json(%s)", DEFAULT_JSON_FILE);
string_t importFile = DEFAULT_JSON_FILE; // extract filename
ifstream_t f(importFile); // filestream of working file
stringstream_t s; // string stream for holding JSON read from file
if (f) {
s << f.rdbuf(); // stream results of reading from file stream into string stream
f.close(); // close the filestream
jv = json::value::parse(s); // parse the resultant string stream.
std::cout << "file" << DEFAULT_JSON_FILE<<std::endl;
}else{
Logger::amf_app().error("no json file");
}
}
catch (web::json::json_exception excep) {
//std::cout << "ERROR Parsing JSON: ";
//std::cout << excep.what();
Logger::amf_app().error("error!");
}
//auto supi = jv.at(U("supi"));
//std::cout << supi <<std::endl;
smContextCreateData->fromJson(jv);
smContextMessage->setJsonData(smContextCreateData);
std::shared_ptr<HttpContent> n1sm(new HttpContent);
//n1sm->setName("\\\"n1SmMsg\\\"");
//n1sm->setContentDisposition("attachment");
n1sm->setContentType("application/vnd.3gpp.5gnas");
//uint8_t buf[18] = {0x2e, 0x05, 0x1e, 0xc1, 0xff, 0xff, 0x91, 0xa1, 0x7b, 0x00, 0x07, 0x80, 0x00, 0xa0, 0x00, 0x00, 0x0d, 0x00};
uint8_t buf[8] = {0x2e, 0x05, 0x1e, 0xc1, 0xff, 0xff, 0x91, 0xa1};
char test[8];
for(int i=0; i<8; i++)
test[i] = (char)buf[i];
printf("%s\n", test);
std::string value = test;
n1sm->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value) ) ) );
//n1sm->setData( std::shared_ptr<std::istream>( new std::stringstream( "2e051ec1ffff91a17b00078000a00000d00" ) ) );
//n1sm->setData( std::shared_ptr<std::istream>(test));
smContextMessage->setBinaryDataN1SmMessage(n1sm);
std::shared_ptr<SMContextsCollectionApi> smContextsCollectionApi (new SMContextsCollectionApi (apiClient));
smContextsCollectionApi->postSmContexts (smContextMessage);
return 0;
}
...@@ -23,75 +23,4 @@ using namespace oai::smf::model; ...@@ -23,75 +23,4 @@ using namespace oai::smf::model;
//using json = nlohmann::json; //using json = nlohmann::json;
int smf_client_test() int smf_client_test();
{
// create ApiConfiguration
std::shared_ptr <ApiConfiguration> apiConfiguration (new ApiConfiguration);
apiConfiguration->setBaseUrl(utility::conversions::to_string_t("http://10.103.238.82:8889/nsmf-pdusession/v2"));
//apiConfiguration->setBaseUrl(utility::conversions::to_string_t("http://192.168.2.189:8889/nsmf-pdusession/v2"));
std::shared_ptr <ApiClient> apiClient(new ApiClient (apiConfiguration));
std::shared_ptr<SmContextMessage> smContextMessage (new SmContextMessage);
//fill the content of smContextMessage
//TODO:
std::shared_ptr<SmContextCreateData> smContextCreateData (new SmContextCreateData);
Logger::amf_app().debug("starting test smf_client");
json::value jv; // JSON read from input file
try {
Logger::amf_app().debug("try to get smcontextcreatedata json(%s)", DEFAULT_JSON_FILE);
string_t importFile = DEFAULT_JSON_FILE; // extract filename
ifstream_t f(importFile); // filestream of working file
stringstream_t s; // string stream for holding JSON read from file
if (f) {
s << f.rdbuf(); // stream results of reading from file stream into string stream
f.close(); // close the filestream
jv = json::value::parse(s); // parse the resultant string stream.
std::cout << "file" << DEFAULT_JSON_FILE<<std::endl;
}else{
Logger::amf_app().error("no json file");
}
}
catch (web::json::json_exception excep) {
//std::cout << "ERROR Parsing JSON: ";
//std::cout << excep.what();
Logger::amf_app().error("error!");
}
//auto supi = jv.at(U("supi"));
//std::cout << supi <<std::endl;
smContextCreateData->fromJson(jv);
smContextMessage->setJsonData(smContextCreateData);
std::shared_ptr<HttpContent> n1sm(new HttpContent);
//n1sm->setName("\\\"n1SmMsg\\\"");
//n1sm->setContentDisposition("attachment");
n1sm->setContentType("application/vnd.3gpp.5gnas");
//uint8_t buf[18] = {0x2e, 0x05, 0x1e, 0xc1, 0xff, 0xff, 0x91, 0xa1, 0x7b, 0x00, 0x07, 0x80, 0x00, 0xa0, 0x00, 0x00, 0x0d, 0x00};
uint8_t buf[8] = {0x2e, 0x05, 0x1e, 0xc1, 0xff, 0xff, 0x91, 0xa1};
char test[8];
for(int i=0; i<8; i++)
test[i] = (char)buf[i];
printf("%s\n", test);
string value = test;
n1sm->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value) ) ) );
//n1sm->setData( std::shared_ptr<std::istream>( new std::stringstream( "2e051ec1ffff91a17b00078000a00000d00" ) ) );
//n1sm->setData( std::shared_ptr<std::istream>(test));
smContextMessage->setBinaryDataN1SmMessage(n1sm);
std::shared_ptr<SMContextsCollectionApi> smContextsCollectionApi (new SMContextsCollectionApi (apiClient));
smContextsCollectionApi->postSmContexts (smContextMessage);
return 0;
}
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/unicode)
include_directories(${SRC_TOP_DIR}/nas/common)
include_directories(${SRC_TOP_DIR}/sctp)
include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr)
add_library (AMF_SCTP STATIC
${CMAKE_CURRENT_SOURCE_DIR}/sctp_server.cpp
)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/unicode)
include_directories(${SRC_TOP_DIR}/nas/ies)
include_directories(${SRC_TOP_DIR}/nas/common)
include_directories(${SRC_TOP_DIR}/ngap/libngap)
include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka)
include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr)
add_library (AMF_SECU_5GAKA STATIC
authentication_algorithms_with_5gaka.cpp
rijndael.cpp
sha256.cpp
)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/unicode)
include_directories(${SRC_TOP_DIR}/nas/ies)
include_directories(${SRC_TOP_DIR}/nas/common)
include_directories(${SRC_TOP_DIR}/ngap/libngap)
include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka)
include_directories(${SRC_TOP_DIR}/secu_algorithms/nas_enc_int)
include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr)
add_library (AMF_SECU_NAS STATIC
nas_algorithms.cpp
rijndael.c
snow3g.c
)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/unicode)
include_directories(${SRC_TOP_DIR}/nas/common)
include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr)
add_library (AMF_UTILS STATIC
${CMAKE_CURRENT_SOURCE_DIR}/backtrace.c
${CMAKE_CURRENT_SOURCE_DIR}/conversions.c
${CMAKE_CURRENT_SOURCE_DIR}/hex_string_convert.cpp
${CMAKE_CURRENT_SOURCE_DIR}/http_multi_parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/if.cpp
${CMAKE_CURRENT_SOURCE_DIR}/multipartparser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/string.cpp
${CMAKE_CURRENT_SOURCE_DIR}/thread_sched.cpp
)
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