Commit 664dd7d4 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Fix after merged

parents 1a62fb49 8baa1fe0
[submodule "src/common-src"]
path = src/common-src
url = https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-common-src.git
[submodule "build/common-build"]
path = build/common-build
url = https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-common-build.git
[submodule "ci-scripts/common-ci"]
path = ci-scripts/common-ci
url = https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-common-ci.git
{
"files.associations": {
"deque": "cpp",
"string": "cpp",
"vector": "cpp"
}
}
\ No newline at end of file
......@@ -10,4 +10,10 @@ set (OPENAIRCN_DIR $ENV{OPENAIRCN_DIR})
set (BUILD_TOP_DIR ${OPENAIRCN_DIR}/build)
set (SRC_TOP_DIR $ENV{OPENAIRCN_DIR}/src)
################################################
# For common-src usage
################################################
set ( NF_TARGET amf )
set ( MOUNTED_COMMON common-src)
include(${CMAKE_CURRENT_SOURCE_DIR}/../../src/oai-amf/CMakeLists.txt)
common-build @ 64c33452
Subproject commit 64c334526218fdb80020bd08a387d7bd092ddcda
......@@ -62,16 +62,67 @@ install_spdlog_from_git() {
fi
git clone $GIT_URL
cd spdlog && git checkout master
cd spdlog && git checkout v1.11.0
mkdir _build && cd _build
$CMAKE -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DSPDLOG_FMT_EXTERNAL=ON -DSPDLOG_BUILD_SHARED=ON ..
make
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
# enable syslog, Useless (defined in SMF code)
sed -i '/#define SPDLOG_ENABLE_SYSLOG/s/^\/\///g' include/spdlog/tweakme.h
popd
rm -Rf $OPENAIRCN_DIR/build/ext/spdlog/_build
fi
echo "spdlog installation complete"
return 0
}
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_fmt_from_git() {
echo "Starting to install fmt"
if [ $1 -eq 0 ]; then
read -p "Do you want to install fmt? <y/N> " prompt
OPTION=""
else
prompt='y'
OPTION="-y"
fi
if [ $2 -eq 0 ]; then
debug=0
else
debug=1
fi
if [[ $prompt =~ [yY](es)* ]]
then
GIT_URL=https://github.com/fmtlib/fmt/
echo "Install fmt from $GIT_URL"
pushd $OPENAIRCN_DIR/build/ext
echo "Downloading fmt"
if [[ $OPTION =~ -[yY](es)* ]]
then
$SUDO rm -rf fmt
fi
git clone $GIT_URL
cd fmt && git checkout 9.0.0
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
mkdir _build && cd _build
$CMAKE -G "Unix Makefiles" -DFMT_TEST=OFF -DBUILD_SHARED_LIBS=TRUE ..
make
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd
rm -Rf $OPENAIRCN_DIR/build/ext/fmt/_build
fi
echo "fmt installation complete"
return 0
}
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
......@@ -404,6 +455,9 @@ check_install_amf_deps(){
ret=$?;[[ $ret -ne 0 ]] && return $ret
echo "distro libs installation complete"
install_fmt_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
install_spdlog_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
......
This diff is collapsed.
common-ci @ c458e9dd
Subproject commit c458e9dd6a5cbce1306680d4289012b8f493ff85
#/*
# * 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
# */
#---------------------------------------------------------------------
#
FROM ubuntu:focal as amf-clang-format-check
ARG MERGE_REQUEST_CHECK
ARG SOURCE_BRANCH
ARG TARGET_BRANCH
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install --yes \
git \
tree \
clang-format-9
WORKDIR /home
COPY . .
RUN /bin/bash -c "if [[ -v MERGE_REQUEST_CHECK ]]; then ./ci-scripts/checkCodingFormattingRules.sh --src-branch $SOURCE_BRANCH --target-branch $TARGET_BRANCH; else ./ci-scripts/checkCodingFormattingRules.sh; fi"
#/*
# * 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
# */
#---------------------------------------------------------------------
#
FROM ubuntu:focal as amf-cppcheck
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install --yes cppcheck
WORKDIR /home
COPY . .
RUN cppcheck --enable=warning --force \
--xml --xml-version=2 \
--suppressions-list=ci-scripts/cppcheck_suppressions.list src \
2> cppcheck.xml \
1> cppcheck_build.log
......@@ -472,9 +472,18 @@ class HtmlReport():
nghttp2_build_start = False
nghttp2_build_status = False
base_image = False
build_stage_id = 'NotAcorrectBuildStageId'
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
for line in logfile:
# old method
result = re.search('FROM oai-amf-base:latest', line)
if result is not None:
base_image = True
# new method --> buildx may cache this stage
result = re.search('^#([0-9]+).* RUN ./build_amf --install-deps', line)
if result is not None:
build_stage_id = result.group(1)
result = re.search(f'^#{build_stage_id} CACHED', line)
if result is not None:
base_image = True
result = re.search(section_start_pattern, line)
......@@ -709,7 +718,7 @@ class HtmlReport():
for variant in variants:
logFileName = 'amf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName):
section_start_pattern = 'FROM .* as oai-amf$'
section_start_pattern = 'COPY --from=oai-amf-builder */openair-amf/build/amf/build/oai_amf'
section_end_pattern = 'WORKDIR /openair-amf/etc'
section_status = False
status = False
......@@ -757,7 +766,7 @@ class HtmlReport():
if os.path.isfile(cwd + '/archives/' + logFileName):
section_start_pattern = 'WORKDIR /openair-amf/etc'
if variant == 'docker':
section_end_pattern = 'Successfully tagged oai-amf'
section_end_pattern = 'naming to docker.io/library/oai-amf:'
else:
section_end_pattern = 'COMMIT oai-amf:'
section_status = False
......@@ -808,27 +817,26 @@ class HtmlReport():
if os.path.isfile(cwd + '/archives/' + logFileName):
if nfType == 'AMF':
if variant == 'docker':
section_start_pattern = 'Successfully tagged oai-amf'
section_start_pattern = 'naming to docker.io/library/oai-amf:'
section_end_pattern = 'OAI-AMF DOCKER IMAGE BUILD'
else:
section_start_pattern = 'COMMIT oai-amf:'
section_end_pattern = 'OAI-AMF PODMAN RHEL8 IMAGE BUILD'
section_status = False
status = False
imageTag = 'notAcorrectTagForTheMoment'
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
for line in logfile:
result = re.search(section_start_pattern, line)
result = re.search(f'{section_start_pattern}([0-9a-zA-Z\-\_\.]+)', line)
if result is not None:
section_status = True
imageTag = result.group(1)
result = re.search(section_end_pattern, line)
if result is not None:
section_status = True
section_status = False
if section_status:
if nfType == 'AMF':
if self.git_pull_request:
result = re.search('oai-amf *ci-tmp', line)
else:
result = re.search('oai-amf *develop', line)
result = re.search(f'oai-amf *{imageTag}', line)
if result is not None and not status:
result = re.search('ago *([0-9A-Z ]+)', line)
if result is not None:
......
......@@ -129,6 +129,8 @@ COPY --from=oai-amf-builder \
/usr/local/lib64/libpistache.so.0 \
/usr/local/lib/libnghttp2_asio.so \
/usr/local/lib/libnghttp2_asio.so.1 \
/usr/local/lib64/libspdlog.so \
/usr/local/lib64/libfmt.so \
/usr/lib64/
RUN ldconfig && \
......
......@@ -49,17 +49,20 @@ RUN git config --global https.postBuffer 123289600 && \
# Copying source code
WORKDIR /openair-amf/
COPY . /openair-amf
COPY ./build/scripts /openair-amf/build/scripts
COPY ./build/amf/CMakeLists.txt /openair-amf/build/amf/CMakeLists.txt
COPY ./build/cmake_modules /openair-amf/cmake_modules
# Installing all the needed libraries/packages to build and run AMF
WORKDIR /openair-amf/build/scripts
RUN ./build_amf --install-deps --force && \
cp -Rf /openair-amf/build/ext /openair-amf-ext-ref
RUN ./build_amf --install-deps --force
#---------------------------------------------------------------------
# BUILDER IMAGE
#---------------------------------------------------------------------
FROM oai-amf-base as oai-amf-builder
# Copying source code
COPY . /openair-amf
# Building AMF
WORKDIR /openair-amf/build/scripts
RUN ldconfig && \
......@@ -127,6 +130,7 @@ COPY --from=oai-amf-builder \
/usr/local/lib/libnghttp2.so.14 \
/usr/local/lib/libnghttp2_asio.so.1 \
/usr/local/lib/libpistache.so \
/usr/local/lib/libfmt.so \
# Ubuntu 18 --> boost 67 will be copied
/usr/lib/libboost_system.so.1.* \
/usr/lib/libboost_thread.so.1.* \
......
......@@ -27,6 +27,7 @@ AMF =
PID_DIRECTORY = "{{ env["PID_DIRECTORY"] if "PID_DIRECTORY" in env.keys() else '/var/run' }}"; # /var/run is the default
AMF_NAME = "OAI-AMF";
LOG_LEVEL = "{{ env["LOG_LEVEL"] if "LOG_LEVEL" in env.keys() else 'debug' }}";
RELATIVE_CAPACITY = 30;
# Display statistics about whole system (in seconds)
......@@ -148,10 +149,3 @@ AMF =
ORDERED_SUPPORTED_CIPHERING_ALGORITHM_LIST = {{ env["CIPH_ALGO_LIST"] if "CIPH_ALGO_LIST" in env.keys() else [ "NEA0" , "NEA1" , "NEA2" ] | tojson }} ;
};
};
MODULES =
{
NGAP_MESSAGE = (
{MSG_NAME = "NGSetupRequest"; ProcedureCode = 21; TypeOfMessage = "initialMessage"}
);
};
\ No newline at end of file
## system modules, such as NGAP message modules and NAS message modules
MODULES =
{
NGAP_MESSAGE = (
{MSG_NAME = "NGSetupRequest"; ProcedureCode = 21; TypeOfMessage = "initialMessage"}
);
};
......@@ -51,8 +51,9 @@ if MOUNT_CONFIG != "yes":
with open(CONFIG_FILE, "w") as fh:
fh.write(output)
print(f"Configuration file {CONFIG_FILE} is ready")
if len(sys.argv) == 1:
sys.exit(0)
os.execvp(sys.argv[1], sys.argv[1:]) #important for running the network function it works like exec $@
else:
print("Configuration file is mounted to the network function")
\ No newline at end of file
print("Configuration file is mounted to the network function")
if len(sys.argv) == 1:
sys.exit(0)
os.execvp(sys.argv[1], sys.argv[1:]) #important for running the network function it works like exec $@
\ No newline at end of file
......@@ -19,7 +19,6 @@
# contact@openairinterface.org
################################################################################
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)
......@@ -43,11 +42,11 @@ 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}/${MOUNTED_COMMON}/logger)
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_sbi.cpp
......@@ -67,9 +66,9 @@ file(GLOB AMF_src_files
${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
${SRC_TOP_DIR}/ngap/ngapIEs/*.cpp
)
add_library (AMF STATIC
${AMF_src_files}
)
......
......@@ -37,7 +37,7 @@
#include "amf_n2.hpp"
#include "amf_sbi.hpp"
#include "amf_statistics.hpp"
#include "comUt.hpp"
#include "output_wrapper.hpp"
#include "itti.hpp"
#include "ngap_app.hpp"
......@@ -204,7 +204,6 @@ long amf_app::generate_amf_ue_ngap_id() {
//------------------------------------------------------------------------------
bool amf_app::is_ran_amf_id_2_ue_context(const string& ue_context_key) const {
std::shared_lock lock(m_ue_ctx_key);
// return bool{ue_ctx_key.count(ue_context_key) > 0};
if (ue_ctx_key.count(ue_context_key) > 0) {
if (ue_ctx_key.at(ue_context_key) != nullptr) {
return true;
......@@ -338,7 +337,8 @@ void amf_app::handle_itti_message(
uint8_t nas[BUFFER_SIZE_1024];
int encoded_size = dl->Encode(nas, BUFFER_SIZE_1024);
comUt::print_buffer("amf_app", "n1n2 transfer", nas, encoded_size);
output_wrapper::print_buffer(
"amf_app", "N1N2 message transfer", nas, encoded_size);
std::shared_ptr<itti_downlink_nas_transfer> dl_msg =
std::make_shared<itti_downlink_nas_transfer>(TASK_AMF_APP, TASK_AMF_N1);
......@@ -388,11 +388,14 @@ void amf_app::handle_itti_message(
// Update AMF UE NGAP ID
std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id, unc)) {
if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(
itti_msg.ran_ue_ngap_id, itti_msg.gnb_id, unc)) {
Logger::amf_n1().error(
"Could not find UE NGAP Context with ran_ue_ngap_id "
"(" GNB_UE_NGAP_ID_FMT ")",
itti_msg.ran_ue_ngap_id);
"(" GNB_UE_NGAP_ID_FMT
"), gNB ID "
"(" GNB_ID_FMT ")",
itti_msg.ran_ue_ngap_id, itti_msg.gnb_id);
} else {
unc->amf_ue_ngap_id = amf_ue_ngap_id;
amf_n2_inst->set_amf_ue_ngap_id_2_ue_ngap_context(amf_ue_ngap_id, unc);
......@@ -404,17 +407,20 @@ void amf_app::handle_itti_message(
if (itti_msg.rrc_cause != -1)
uc->rrc_estb_cause = (e_Ngap_RRCEstablishmentCause) itti_msg.rrc_cause;
if (itti_msg.ueCtxReq == -1)
uc->isUeContextRequest = false;
uc->is_ue_context_request = false;
else
uc->isUeContextRequest = true;
uc->is_ue_context_request = true;
uc->ran_ue_ngap_id = itti_msg.ran_ue_ngap_id;
uc->amf_ue_ngap_id = amf_ue_ngap_id;
uc->gnb_id = itti_msg.gnb_id;
std::string guti = {};
bool is_guti_valid = false;
if (itti_msg.is_5g_s_tmsi_present) {
guti = itti_msg.tai.mcc + itti_msg.tai.mnc + amf_cfg.guami.regionID +
itti_msg._5g_s_tmsi;
guti = conv::tmsi_to_guti(
itti_msg.tai.mcc, itti_msg.tai.mnc, amf_cfg.guami.regionID,
itti_msg._5g_s_tmsi);
is_guti_valid = true;
Logger::amf_app().debug("Receiving GUTI %s", guti.c_str());
}
......@@ -471,11 +477,10 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) {
registration_context.getRanNodeId();
// RAN UE NGAP ID
uint32_t ran_ue_ngap_id = registration_context.getAnN2ApId();
uint32_t gnb_id = {};
if (ran_node_id.gNbIdIsSet()) {
oai::amf::model::GNbId gnb_id_model = ran_node_id.getGNbId();
uint32_t gnb_id = {};
try {
gnb_id = std::stoul(gnb_id_model.getGNBValue(), nullptr, 10);
} catch (const std::exception& e) {
......@@ -485,7 +490,7 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) {
return;
}
gc->globalRanNodeId = gnb_id;
gc->gnb_id = gnb_id;
// TODO: gc->gnb_name
// TODO: DefaultPagingDRX
// TODO: Supported TA List
......@@ -516,6 +521,7 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) {
uc = std::shared_ptr<ue_context>(new ue_context());
uc->amf_ue_ngap_id = -1;
uc->supi = supi;
uc->gnb_id = gnb_id;
set_supi_2_ue_context(supi, uc);
}
}
......@@ -553,7 +559,8 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) {
Logger::amf_app().debug(
"Create a new UE Context with UE Context Key",
ue_context_key.c_str());
uc = std::make_shared<ue_context>();
uc = std::make_shared<ue_context>();
uc->gnb_id = gnb_id;
}
set_ran_amf_id_2_ue_context(ue_context_key, uc);
}
......@@ -577,17 +584,18 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) {
uc->rrc_estb_cause = (e_Ngap_RRCEstablishmentCause) rrc_cause;
}
// ueContextRequest
uc->isUeContextRequest = registration_context.isUeContextRequest();
uc->is_ue_context_request = registration_context.isUeContextRequest();
// Step 4. Create UE NGAP Context if necessary
// Create/Update UE NGAP Context
std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) {
if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, gnb_id, unc)) {
Logger::amf_app().debug(
"Create a new UE NGAP context with ran_ue_ngap_id " GNB_UE_NGAP_ID_FMT,
ran_ue_ngap_id);
unc = std::shared_ptr<ue_ngap_context>(new ue_ngap_context());
amf_n2_inst->set_ran_ue_ngap_id_2_ue_ngap_context(ran_ue_ngap_id, unc);
amf_n2_inst->set_ran_ue_ngap_id_2_ue_ngap_context(
ran_ue_ngap_id, gnb_id, unc);
}
// Store related information into UE NGAP context
......@@ -822,6 +830,7 @@ uint32_t amf_app::get_number_registered_ues() const {
std::shared_lock lock(m_amf_ue_ngap_id2ue_ctx);
return amf_ue_ngap_id2ue_ctx.size();
}
//---------------------------------------------------------------------------------------------
void amf_app::add_n1n2_message_subscription(
const std::string& ue_ctx_id, const n1n2sub_id_t& sub_id,
......
......@@ -31,7 +31,6 @@
#include "ProblemDetails.h"
#include "UeN1N2InfoSubscriptionCreateData.h"
#include "amf_config.hpp"
#include "amf_module_from_config.hpp"
#include "amf_msg.hpp"
#include "amf_profile.hpp"
#include "amf_subscription.hpp"
......
......@@ -66,6 +66,7 @@ amf_config::amf_config() {
nssf_addr.port = DEFAULT_HTTP1_PORT;
nssf_addr.api_version = DEFAULT_SBI_API_VERSION;
instance = 0;
log_level = spdlog::level::debug;
n2 = {};
sbi = {};
sbi_api_version = DEFAULT_SBI_API_VERSION;
......@@ -159,6 +160,16 @@ int amf_config::load(const std::string& config_file) {
"%s : %s, using defaults", nfex.what(), nfex.getPath());
}
// Log Level
try {
std::string string_level;
amf_cfg.lookupValue(AMF_CONFIG_STRING_LOG_LEVEL, string_level);
log_level = spdlog::level::from_str(string_level);
} catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath());
}
// GUAMI
try {
const Setting& guami_cfg = amf_cfg[AMF_CONFIG_STRING_GUAMI];
......@@ -555,7 +566,12 @@ int amf_config::load(const std::string& config_file) {
util::trim(address).c_str(), udm_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR UDM !");
udm_addr.ipv4_addr = udm_ipv4_addr;
udm_addr.port = udm_port;
// We hardcode nrf port from config for the moment
if (!(udm_cfg.lookupValue(AMF_CONFIG_STRING_PORT, udm_port))) {
Logger::amf_app().error(AMF_CONFIG_STRING_PORT "failed");
throw(AMF_CONFIG_STRING_PORT "failed");
}
udm_addr.port = udm_port;
udm_addr.api_version =
DEFAULT_SBI_API_VERSION; // TODO: get API version
}
......@@ -809,8 +825,8 @@ void amf_config::display() {
smf_pool[i].fqdn :
smf_pool[i].ipv4.c_str();
Logger::config().info(
" SMF_INSTANCE_ID %d (%s:%s, version %s) is selected: %s",
smf_pool[i].id, smf_info.c_str(), smf_pool[i].port.c_str(),
" SMF_INSTANCE_ID %d (%s:%d, version %s) is selected: %s",
smf_pool[i].id, smf_info.c_str(), smf_pool[i].port,
smf_pool[i].version.c_str(), selected.c_str());
}
}
......@@ -843,6 +859,9 @@ void amf_config::display() {
Logger::config().info(
" Use HTTP2..............: %s",
support_features.use_http2 ? "Yes" : "No");
Logger::config().info(
"- Log Level will be .......: %s",
spdlog::level::to_string_view(log_level));
}
//------------------------------------------------------------------------------
......@@ -914,7 +933,7 @@ bool amf_config::resolve_fqdn(
//------------------------------------------------------------------------------
std::string amf_config::get_amf_n1n2_message_subscribe_uri(
const std::string& ue_cxt_id) {
unsigned int sbi_port = 80;
unsigned int sbi_port = DEFAULT_HTTP1_PORT;
if (support_features.use_http2) {
sbi_port = sbi_http2_port;
} else {
......@@ -973,11 +992,9 @@ bool amf_config::get_smf_pdu_session_context_uri(
}
std::string smf_addr = {};
std::string smf_port = {};
std::string smf_ip_addr = {};
smf_addr = psc->smf_info.addr;
smf_port = psc->smf_info.port;
// remove http port from the URI if existed
std::size_t found_port = smf_addr.find(":");
......@@ -990,13 +1007,14 @@ bool amf_config::get_smf_pdu_session_context_uri(
if (found != std::string::npos)
smf_uri = psc->smf_info.context_location;
else
smf_uri = smf_addr + ":" + smf_port + psc->smf_info.context_location;
smf_uri = smf_addr + ":" + std::to_string(psc->smf_info.port) +
psc->smf_info.context_location;
return true;
}
//------------------------------------------------------------------------------
std::string amf_config::get_smf_pdu_session_base_uri(
const std::string& smf_addr, const std::string& smf_port,
const std::string& smf_addr, const uint32_t& smf_port,
const std::string& smf_api_version) {
// Remove http port from the URI if existed
std::string smf_ip_addr = {};
......@@ -1006,14 +1024,15 @@ std::string amf_config::get_smf_pdu_session_base_uri(
else
smf_ip_addr = smf_addr;
return smf_ip_addr + ":" + smf_port + "/nsmf-pdusession/" + smf_api_version +
NSMF_PDU_SESSION_CREATE;
return smf_ip_addr + ":" + std::to_string(smf_port) + "/nsmf-pdusession/" +
smf_api_version + NSMF_PDU_SESSION_CREATE;
}
//------------------------------------------------------------------------------
void amf_config::to_json(nlohmann::json& json_data) const {
json_data["instance"] = instance;
json_data["pid_dir"] = pid_dir;
json_data["log_level"] = log_level;
json_data["amf_name"] = amf_name;
json_data["guami"] = guami.to_json();
json_data["guami_list"] = nlohmann::json::array();
......@@ -1072,6 +1091,9 @@ bool amf_config::from_json(nlohmann::json& json_data) {
if (json_data.find("amf_name") != json_data.end()) {
amf_name = json_data["amf_name"].get<std::string>();
}
if (json_data.find("log_level") != json_data.end()) {
log_level = json_data["log_level"].get<spdlog::level::level_enum>();
}
if (json_data.find("guami") != json_data.end()) {
guami.from_json(json_data["guami"]);
}
......
......@@ -113,6 +113,7 @@
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_USE_HTTP2 "USE_HTTP2"
#define AMF_CONFIG_STRING_FQDN_DNS "FQDN"
#define AMF_CONFIG_STRING_LOG_LEVEL "LOG_LEVEL"
using namespace libconfig;
......@@ -332,7 +333,7 @@ typedef struct {
typedef struct {
int id;
std::string ipv4;
std::string port;
uint32_t port;
uint32_t http2_port;
std::string version;
bool selected;
......@@ -351,10 +352,9 @@ typedef struct {
}
void from_json(nlohmann::json& json_data) {
this->id = json_data["id"].get<int>();
this->ipv4 = json_data["ipv4"].get<std::string>();
this->port = json_data["port"]
.get<std::string>(); // TODO: use int instead of string
this->id = json_data["id"].get<int>();
this->ipv4 = json_data["ipv4"].get<std::string>();
this->port = json_data["port"].get<int>();
this->http2_port = json_data["http2_port"].get<int>();
this->version = json_data["version"].get<std::string>();
this->selected = json_data["selected"].get<bool>();
......@@ -468,13 +468,13 @@ class amf_config {
/*
* Get the URI of SMF Services
* @param [const std::string&] smf_addr: SMF's Addr in String representation
* @param [const std::string&] smf_port: SMF's port in String representation
* @param [const uint32_t&] smf_port: SMF's port in String representation
* @param [const std::string&] smf_api_version: SMF's API version in String
* representation
* @return URI in string format
*/
std::string get_smf_pdu_session_base_uri(
const std::string& smf_addr, const std::string& smf_port,
const std::string& smf_addr, const uint32_t& smf_port,
const std::string& smf_api_version);
/*
......@@ -500,6 +500,7 @@ class amf_config {
unsigned int instance;
std::string pid_dir;
spdlog::level::level_enum log_level;
interface_cfg_t n2;
interface_cfg_t sbi;
itti_cfg_t itti;
......
/*
* 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
*/
#include "amf_module_from_config.hpp"
#include <iostream>
#include <string>
#include "common_defs.h"
#include "logger.hpp"
namespace config {
//------------------------------------------------------------------------------
int amf_modules::load(const std::string& config_file) {
Logger::amf_app().debug(
"\nLoad AMF module configuration file (%s)", config_file.c_str());
Config cfg;
try {
cfg.readFile(config_file.c_str());
} catch (const FileIOException& fioex) {
Logger::amf_app().error(
"I/O error while reading file %s - %s", config_file.c_str(),
fioex.what());
throw;
} catch (const ParseException& pex) {
Logger::amf_app().error(
"Parse error at %s:%d - %s", pex.getFile(), pex.getLine(),
pex.getError());
throw;
}
const Setting& root = cfg.getRoot();
try {
const Setting& modules = root[MODULES_CONFIG_STRING_AMF_MODULES];
} catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror;
}
const Setting& modules = root[MODULES_CONFIG_STRING_AMF_MODULES];
const Setting& msg = modules[MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE];
int count = msg.getLength();
for (int i = 0; i < count; i++) {
const Setting& item = msg[i];
std::string typeOfMessage;
int procedure_code;
item.lookupValue(
MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_NAME, msgName);
item.lookupValue(
MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_PROCEDURECODE,
procedure_code);
item.lookupValue(
MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_TYPEOFMSG,
typeOfMessage);
procedureCode = (Ngap_ProcedureCode_t) procedure_code;
if (!(typeOfMessage.compare("initialMessage"))) {
typeOfMsg = Ngap_NGAP_PDU_PR_initiatingMessage;
} else if (!(typeOfMessage.compare("successfuloutcome"))) {
typeOfMsg = Ngap_NGAP_PDU_PR_successfulOutcome;
} else if (!(typeOfMessage.compare("unsuccessfuloutcome"))) {
typeOfMsg = Ngap_NGAP_PDU_PR_unsuccessfulOutcome;
} else {
Logger::config().error("wrong NGAP message configuration");
}
}
return 1;
}
//------------------------------------------------------------------------------
void amf_modules::display() {
Logger::config().info(
"============ AMF Registered Modules ============");
Logger::config().info("NGAP Message Modules:");
Logger::config().info(
"- %s(Procedure code %d, Type of Msg %d)\n", msgName.c_str(),
procedureCode, typeOfMsg);
}
} // namespace config
/*
* 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
*/
#ifndef _AMF_MODULE_FROM_CONFIG_H_
#define _AMF_MODULE_FROM_CONFIG_H_
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <libconfig.h++>
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProcedureCode.h"
#define MODULES_CONFIG_STRING_AMF_MODULES "MODULES"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE "NGAP_MESSAGE"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_NAME "MSG_NAME"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_PROCEDURECODE \
"ProcedureCode"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_TYPEOFMSG "TypeOfMessage"
using namespace libconfig;
namespace config {
class amf_modules {
public:
/*
* Load AMF modules configuration
* @param [const std::string&] config_file: Configuration file
* @return RETURNclear/RETURNerror/RETURNok
*/
int load(const std::string& config_file);
/*
* Display the AMF modules configuration parameters
* @param void
* @return void
*/
void display();
private:
std::string msgName; // vector to store more msgs
Ngap_NGAP_PDU_PR typeOfMsg;
Ngap_ProcedureCode_t procedureCode;
};
} // namespace config
#endif
This diff is collapsed.
......@@ -221,22 +221,22 @@ class amf_n1 {
bool remove_supi_2_ran_id(const std::string& supi);
/*
* Get UE NAS context associated with an IMSI
* @param [const std::string&] imsi: UE IMSI
* Get UE NAS context associated with an SUPI
* @param [const std::string&] imsi: UE SUPI
* @param [const std::shared_ptr<nas_context>&] nc: pointer to UE NAS context
* @return true if the NAS context exists and is not null, otherwise return
* false
*/
bool imsi_2_nas_context(
bool supi_2_nas_context(
const std::string& imsi, std::shared_ptr<nas_context>&) const;
/*
* Store an UE NAS context associated with an IMSI
* @param [const std::string&] imsi: UE IMSI
* Store an UE NAS context associated with an SUPI
* @param [const std::string&] imsi: UE SUPI
* @param [const std::shared_ptr<nas_context>&] nc: pointer to UE NAS context
* @return void
*/
void set_imsi_2_nas_context(
void set_supi_2_nas_context(
const std::string& imsi, const std::shared_ptr<nas_context>& nc);
/*
......@@ -244,7 +244,7 @@ class amf_n1 {
* @param [const std::string&] imsi: UE IMSI
* @return true if successful, otherwise return false
*/
bool remove_imsi_2_nas_context(const std::string& imsi);
bool remove_supi_2_nas_context(const std::string& imsi);
/*
* Perform Registration procedure
......@@ -366,7 +366,7 @@ class amf_n1 {
/*
* Encode the NAS message with corresponding integrity and ciphered algorithms
* @param [nas_secu_ctx*] nsc: NAS Security context
* @param [nas_secu_ctx&] nsc: NAS Security context
* @param [bool] is_secu_ctx_new: indicate the status of the security context
* (new/old)
* @param [uint8_t] security_header_type: Security Header Type
......@@ -377,13 +377,13 @@ class amf_n1 {
* @return void
*/
void encode_nas_message_protected(
nas_secu_ctx* nsc, bool is_secu_ctx_new, uint8_t security_header_type,
nas_secu_ctx& nsc, bool is_secu_ctx_new, uint8_t security_header_type,
uint8_t direction, uint8_t* input_nas_buf, int input_nas_len,
bstring& encrypted_nas);
/*
* Encrypt with integrity algorithm
* @param [nas_secu_ctx*] nsc: NAS Security context
* @param [nas_secu_ctx&] nsc: NAS Security context
* @param [uint8_t] direction: Direction
* @param [uint8_t*] input_nas_buf: Buffer of the input NAS
* @param [int] input_nas_les: Length of the buffer
......@@ -391,19 +391,19 @@ class amf_n1 {
* @return true if MAC can be calculated successfully, otherwise return false
*/
bool nas_message_integrity_protected(
nas_secu_ctx* nsc, uint8_t direction, uint8_t* input_nas,
nas_secu_ctx& nsc, uint8_t direction, uint8_t* input_nas,
int input_nas_len, uint32_t& mac);
/*
* Cipher NAS message with the corresponding ciphered algorithm
* @param [nas_secu_ctx*] nsc: NAS Security context
* @param [nas_secu_ctx&] nsc: NAS Security context
* @param [uint8_t] direction: Direction
* @param [bstring] input_nas: Input NAS message
* @param [bstring&] output_nas: Output NAS message
* @return true if message is successfully ciphered, otherwise return false
*/
bool nas_message_cipher_protected(
nas_secu_ctx* nsc, uint8_t direction, bstring input_nas,
nas_secu_ctx& nsc, uint8_t direction, bstring input_nas,
bstring& output_nas);
// NOTE: All the MySQL-related functions are currently implemented in
......@@ -994,7 +994,7 @@ class amf_n1 {
amfueid2nas_context; // amf ue ngap id
mutable std::shared_mutex m_amfueid2nas_context;
std::map<std::string, std::shared_ptr<nas_context>> imsi2nas_context;
std::map<std::string, std::shared_ptr<nas_context>> supi2nas_context;
std::map<std::string, long> supi2amfId;
std::map<std::string, uint32_t> supi2ranId;
mutable std::shared_mutex m_nas_context;
......
This diff is collapsed.
......@@ -222,99 +222,116 @@ class amf_n2 : public ngap::ngap_app {
* @return void
*/
bool get_common_NSSAI(
const uint32_t& ran_ue_ngap_id, std::vector<nas::SNSSAI_t>& common_nssai);
const uint32_t& ran_ue_ngap_id, uint32_t gnb_id,
std::vector<nas::SNSSAI_t>& common_nssai);
/*
* Get the UE NGAP context associated with a RAN UE NGAP ID if it exists and
* not null
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @param [const uint32_t&] gnb_id: gNB ID
* @param [std::shared_ptr<ue_ngap_context>&] unc: shared pointer to the
* existing UE NGAP context
* @return true if the context exists and is not null, otherwise return false
*/
bool ran_ue_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id,
uint32_t ran_ue_ngap_id, uint32_t gnb_id,
std::shared_ptr<ue_ngap_context>& unc) const;
/*
* Get the UE NGAP context associated with a RAN UE NGAP ID if it exists and
* not null
* @param [uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @param [const std::string&] ue_context_key: UE context key from AMF UE NGAP
* ID and RAN UE NGAP ID
* @param [const std::shared_ptr<ue_ngap_context>&] unc: shared pointer to the
* existing UE NGAP context
* @return true if the context exists and is not null, otherwise return false
*/
bool ran_ue_id_2_ue_ngap_context(
uint32_t ran_ue_ngap_id, const std::string& ue_context_key,
std::shared_ptr<ue_ngap_context>& unc) const;
/*
* Verify whether a UE NGAP context associated with a RAN UE NGAP ID exists
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @param [uint32_t] ran_ue_ngap_id: RAN UE NGAP ID
* @param [uint32_t] gnb_id: gNB ID
* @return true if the context exists and is not null, otherwise return false
*/
bool is_ran_ue_id_2_ue_ngap_context(const uint32_t& ran_ue_ngap_id) const;
bool is_ran_ue_id_2_ue_ngap_context(
uint32_t ran_ue_ngap_id, uint32_t gnb_id) const;
/*
* Store UE NGAP context associated with a RAN UE NGAP ID
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @param [uint32_t] ran_ue_ngap_id: RAN UE NGAP ID
* @param [uint32_t] gnb_id: gNB ID
* @param [const std::shared_ptr<ue_ngap_context>&] unc: pointer to UE NGAP
* context
* @return void
*/
void set_ran_ue_ngap_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id,
uint32_t ran_ue_ngap_id, uint32_t gnb_id,
const std::shared_ptr<ue_ngap_context>& unc);
/*
* Remove UE NGAP context associated with a RAN UE NGAP ID
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @param [uint32_t] ran_ue_ngap_id: RAN UE NGAP ID
* @param [uint32_t] gnb_id: gNB ID
* @return void
*/
void remove_ran_ue_ngap_id_2_ngap_context(const uint32_t& ran_ue_ngap_id);
void remove_ran_ue_ngap_id_2_ngap_context(
uint32_t ran_ue_ngap_id, uint32_t gnb_id);
/*
* Remove UE Context associated with a RAN UE NGAP ID
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @param [uint32_t] ran_ue_ngap_id: RAN UE NGAP ID
* @param [uint32_t] gnb_id: gNB ID
* @return void
*/
void remove_ue_context_with_ran_ue_ngap_id(const uint32_t& ran_ue_ngap_id);
void remove_ue_context_with_ran_ue_ngap_id(
uint32_t ran_ue_ngap_id, uint32_t gnb_id);
/*
* Verify whether a UE NGAP context associated with a AMF UE NGAP ID exists
* and is not null
* @param [const unsigned long&] amf_ue_ngap_id: AMF UE NGAP ID
* @param [const long&] amf_ue_ngap_id: AMF UE NGAP ID
* @return true if the context exists and is not null, otherwise return false
*/
bool is_amf_ue_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id) const;
bool is_amf_ue_id_2_ue_ngap_context(const long& amf_ue_ngap_id) const;
/*
* Get UE NGAP context associated with a AMF UE NGAP ID if the context exists
* and is not null
* @param [const unsigned long&] amf_ue_ngap_id: AMF UE NGAP ID
* @param [const long&] amf_ue_ngap_id: AMF UE NGAP ID
* @param [std::shared_ptr<ue_ngap_context>&] unc: store the pointer to UE
* NGAP context
* @return true if the context exists and is not null, otherwise return false
*/
bool amf_ue_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id,
std::shared_ptr<ue_ngap_context>& unc) const;
const long& amf_ue_ngap_id, std::shared_ptr<ue_ngap_context>& unc) const;
/*
* Store UE NGAP context associated with a AMF UE NGAP ID
* @param [const unsigned long&] amf_ue_ngap_id: AMF UE NGAP ID
* @param [const long&] amf_ue_ngap_id: AMF UE NGAP ID
* @param [const std::shared_ptr<ue_ngap_context>&] unc: pointer to UE NGAP
* context
* @return void
*/
void set_amf_ue_ngap_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id,
std::shared_ptr<ue_ngap_context> unc);
const long& amf_ue_ngap_id, std::shared_ptr<ue_ngap_context> unc);
/*
* Remove UE NGAP context associated with a AMF UE NGAP ID
* @param [const unsigned long&] amf_ue_ngap_id: AMF UE NGAP ID
* @param [const long&] amf_ue_ngap_id: AMF UE NGAP ID
* @return void
*/
void remove_amf_ue_ngap_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id);
void remove_amf_ue_ngap_id_2_ue_ngap_context(const long& amf_ue_ngap_id);
/*
* Remove UE Context associated with a AMF UE NGAP ID
* @param [const unsigned long&] amf_ue_ngap_id: AMF UE NGAP ID
* @return void
*/
void remove_ue_context_with_amf_ue_ngap_id(
const unsigned long& amf_ue_ngap_id);
void remove_ue_context_with_amf_ue_ngap_id(const long& amf_ue_ngap_id);
/*
* Get list of UE Context associated with a gNB
......@@ -328,7 +345,7 @@ class amf_n2 : public ngap::ngap_app {
std::vector<std::shared_ptr<ue_ngap_context>>& ue_contexts);
private:
std::map<uint32_t, std::shared_ptr<ue_ngap_context>>
std::map<std::pair<uint32_t, uint32_t>, std::shared_ptr<ue_ngap_context>>
ranid2uecontext; // ran ue ngap id
mutable std::shared_mutex m_ranid2uecontext;
......
......@@ -203,7 +203,6 @@ void nf_profile::to_json(nlohmann::json& data) const {
nlohmann::json tmp = {};
tmp["sst"] = s.sST;
tmp["sd"] = s.sD;
;
data["sNssais"].push_back(tmp);
}
// ipv4_addresses
......
......@@ -33,7 +33,7 @@
#include "amf_app.hpp"
#include "amf_config.hpp"
#include "amf_n1.hpp"
#include "comUt.hpp"
#include "output_wrapper.hpp"
#include "conversions.hpp"
#include "fqdn.hpp"
#include "itti.hpp"
......@@ -71,7 +71,7 @@ void octet_stream_2_hex_stream(uint8_t* buf, int len, std::string& out) {
}
tmp[2 * len] = '\0';
out = tmp;
printf("n1sm buffer: %s\n", out.c_str());
Logger::amf_sbi().debug("n1sm buffer: %s", out.c_str());
}
//------------------------------------------------------------------------------
......@@ -285,7 +285,7 @@ void amf_sbi::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
return;
}
std::string supi = "imsi-" + nc->imsi;
string supi = conv::imsi_to_supi(nc->imsi);
string ue_context_key =
conv::get_ue_context_key(nc->ran_ue_ngap_id, nc->amf_ue_ngap_id);
std::shared_ptr<ue_context> uc = {};
......@@ -338,7 +338,7 @@ void amf_sbi::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
std::string smf_addr = {};
std::string smf_api_version = {};
std::string smf_port = "80"; // Set to default port number
uint32_t smf_port = DEFAULT_HTTP1_PORT;
if (!psc->smf_info.info_available) {
if (amf_cfg.support_features.enable_smf_selection) {
// Get NRF URI
......@@ -369,9 +369,9 @@ void amf_sbi::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
psc->smf_info.port = smf_port;
psc->smf_info.api_version = smf_api_version;
} else {
smf_addr = psc->smf_info.addr;
smf_api_version = psc->smf_info.api_version;
std::string smf_port = psc->smf_info.port;
smf_addr = psc->smf_info.addr;
smf_api_version = psc->smf_info.api_version;
smf_port = psc->smf_info.port;
}
switch (smf.req_type & 0x07) {
......@@ -438,7 +438,7 @@ void amf_sbi::send_pdu_session_update_sm_context_request(
void amf_sbi::handle_pdu_session_initial_request(
const std::string& supi, std::shared_ptr<pdu_session_context>& psc,
const std::string& smf_addr, const std::string& smf_api_version,
const std::string& smf_port, bstring sm_msg, const std::string& dnn) {
const uint32_t& smf_port, bstring sm_msg, const std::string& dnn) {
Logger::amf_sbi().debug(
"Handle PDU Session Establishment Request (SUPI %s, PDU Session ID %d)",
supi.c_str(), psc->pdu_session_id);
......@@ -749,8 +749,7 @@ void amf_sbi::handle_itti_message(itti_sbi_nf_instance_discovery& itti_msg) {
//------------------------------------------------------------------------------
bool amf_sbi::smf_selection_from_configuration(
std::string& smf_addr, std::string& smf_port,
std::string& smf_api_version) {
std::string& smf_addr, uint32_t& smf_port, std::string& smf_api_version) {
for (int i = 0; i < amf_cfg.smf_pool.size(); i++) {
if (amf_cfg.smf_pool[i].selected) {
if (!amf_cfg.support_features.use_fqdn_dns) {
......@@ -759,7 +758,7 @@ bool amf_sbi::smf_selection_from_configuration(
smf_port = amf_cfg.smf_pool[i].port;
} else {
smf_addr = amf_cfg.smf_pool[i].ipv4;
smf_port = std::to_string(amf_cfg.smf_pool[i].http2_port);
smf_port = amf_cfg.smf_pool[i].http2_port;
}
smf_api_version = amf_cfg.smf_pool[i].version;
......@@ -767,18 +766,19 @@ bool amf_sbi::smf_selection_from_configuration(
} else {
// resolve IP addr from a FQDN/DNS name
uint8_t addr_type = 0;
uint32_t smf_port_resolved = 0;
uint32_t smf_port_resolved = DEFAULT_HTTP1_PORT;
fqdn::resolve(
amf_cfg.smf_pool[i].fqdn, amf_cfg.smf_pool[i].ipv4,
smf_port_resolved, addr_type);
// TODO for HTTP2
if (amf_cfg.support_features.use_http2) smf_port_resolved = 8080;
if (amf_cfg.support_features.use_http2)
smf_port_resolved = DEFAULT_HTTP2_PORT;
if (addr_type != 0) { // IPv6: TODO
Logger::amf_sbi().warn("Do not support IPv6 Addr for SMF");
return false;
} else { // IPv4
smf_addr = amf_cfg.smf_pool[i].ipv4;
smf_port = std::to_string(smf_port_resolved);
smf_port = smf_port_resolved;
smf_api_version = "v1"; // TODO: get API version
return true;
}
......@@ -793,8 +793,8 @@ bool amf_sbi::smf_selection_from_configuration(
void amf_sbi::handle_post_sm_context_response_error(
const long code, const std::string& cause, bstring n1sm,
const std::string& supi, const uint8_t pdu_session_id) {
comUt::print_buffer(
"amf_sbi", "n1 sm", (uint8_t*) bdata(n1sm), blength(n1sm));
output_wrapper::print_buffer(
"amf_sbi", "N1 SM", (uint8_t*) bdata(n1sm), blength(n1sm));
itti_n1n2_message_transfer_request* itti_msg =
new itti_n1n2_message_transfer_request(TASK_AMF_SBI, TASK_AMF_APP);
itti_msg->n1sm = bstrcpy(n1sm);
......@@ -814,7 +814,7 @@ void amf_sbi::handle_post_sm_context_response_error(
//-----------------------------------------------------------------------------------------------------
bool amf_sbi::discover_smf(
std::string& smf_addr, std::string& smf_port, std::string& smf_api_version,
std::string& smf_addr, uint32_t& smf_port, std::string& smf_api_version,
const snssai_t& snssai, const plmn_t& plmn, const std::string& dnn,
const std::string& nrf_uri) {
Logger::amf_sbi().debug(
......@@ -899,7 +899,7 @@ bool amf_sbi::discover_smf(
if (nf_service.find("ipEndPoints") != nf_service.end()) {
nlohmann::json nf_ip_endpoint = nf_service["ipEndPoints"].at(0);
if (nf_ip_endpoint.find("port") != nf_ip_endpoint.end()) {
smf_port = std::to_string(nf_ip_endpoint["port"].get<int>());
smf_port = nf_ip_endpoint["port"].get<int>();
}
}
......@@ -919,8 +919,8 @@ bool amf_sbi::discover_smf(
}
Logger::amf_sbi().debug(
"NFDiscovery, SMF Addr %s, SMF port %s, SMF Api Version %s",
smf_addr.c_str(), smf_port.c_str(), smf_api_version.c_str());
"NFDiscovery, SMF Info: Addr %s, Port %d, API Version %s",
smf_addr.c_str(), smf_port, smf_api_version.c_str());
}
return result;
......@@ -1079,7 +1079,8 @@ void amf_sbi::curl_http_client(
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.sbi.if_name.c_str());
if (http_version == 2) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
if (Logger::should_log(spdlog::level::debug))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
......@@ -1170,7 +1171,7 @@ void amf_sbi::curl_http_client(
Logger::amf_sbi().debug(
"Get response with json_data: %s", json_data_response.c_str());
conv::msg_str_2_msg_hex(n1sm, n1sm_hex);
comUt::print_buffer(
output_wrapper::print_buffer(
"amf_sbi", "Get response with n1sm:", (uint8_t*) bdata(n1sm_hex),
blength(n1sm_hex));
......@@ -1265,16 +1266,16 @@ void amf_sbi::curl_http_client(
if (n1sm.size() > 0) {
conv::msg_str_2_msg_hex(n1sm, n1sm_hex);
comUt::print_buffer(
"amf_sbi", "Get response n1sm:", (uint8_t*) bdata(n1sm_hex),
output_wrapper::print_buffer(
"amf_sbi", "Get response N1 SM:", (uint8_t*) bdata(n1sm_hex),
blength(n1sm_hex));
itti_msg->n1sm = bstrcpy(n1sm_hex);
itti_msg->is_n1sm_set = true;
}
if (n2sm.size() > 0) {
conv::msg_str_2_msg_hex(n2sm, n2sm_hex);
comUt::print_buffer(
"amf_sbi", "Get response n2sm:", (uint8_t*) bdata(n2sm_hex),
output_wrapper::print_buffer(
"amf_sbi", "Get response N2 SM:", (uint8_t*) bdata(n2sm_hex),
blength(n2sm_hex));
itti_msg->n2sm = bstrcpy(n2sm_hex);
itti_msg->is_n2sm_set = true;
......@@ -1366,7 +1367,8 @@ void amf_sbi::curl_http_client(
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.sbi.if_name.c_str());
if (http_version == 2) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
if (Logger::should_log(spdlog::level::debug))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
......@@ -1509,7 +1511,8 @@ void amf_sbi::curl_http_client(
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.sbi.if_name.c_str());
if (http_version == 2) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
if (Logger::should_log(spdlog::level::debug))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
......
......@@ -117,7 +117,7 @@ class amf_sbi {
* Session Context
* @param [const std::string&] smf_addr: SMF's Address
* @param [const std::string&] smf_api_version: SMF's API version
* @param [const std::string&] smf_port: SMF's HTTP port
* @param [const uint32_t&] smf_port: SMF's HTTP port
* @param [bstring] sm_msg: SM message
* @param [const std::string&] dnn: DNN
* @return void
......@@ -125,7 +125,7 @@ class amf_sbi {
void handle_pdu_session_initial_request(
const std::string& supi, std::shared_ptr<pdu_session_context>& psc,
const std::string& smf_addr, const std::string& smf_api_version,
const std::string& smf_port, bstring sm_msg, const std::string& dnn);
const uint32_t& smf_port, bstring sm_msg, const std::string& dnn);
/*
* Send SM Context response error to AMF
......@@ -163,19 +163,18 @@ class amf_sbi {
/*
* Select SMF from the configuration file
* @param [const std::string&] smf_addr: SMF's Address
* @param [const std::string&] smf_port: SMF's HTTP port
* @param [const std::string&] smf_api_version: SMF's API version
* @param [std::string&] smf_addr: SMF's Address
* @param [uint32_t&] smf_port: SMF's HTTP port
* @param [std::string&] smf_api_version: SMF's API version
* @return true if successful, otherwise return false
*/
bool smf_selection_from_configuration(
std::string& smf_addr, std::string& smf_port,
std::string& smf_api_version);
std::string& smf_addr, uint32_t& smf_port, std::string& smf_api_version);
/*
* Find suitable SMF from NRF (based on snssai, plmn and dnn)
* @param [std::string&] smf_addr: SMF's Address
* @param [std::string&] smf_port: SMF's HTTP port
* @param [uint32_t&] smf_port: SMF's HTTP port
* @param [std::string&] smf_api_version: SMF's API version
* @param [const snssai_t&] snssai: SNSSAI
* @param [const plmn_t&] plmn: PLMN
......@@ -184,9 +183,9 @@ class amf_sbi {
* @return true if successful, otherwise return false
*/
bool discover_smf(
std::string& smf_addr, std::string& smf_port,
std::string& smf_api_version, const snssai_t& snssai, const plmn_t& plmn,
const std::string& dnn, const std::string& nrf_uri = {});
std::string& smf_addr, uint32_t& smf_port, std::string& smf_api_version,
const snssai_t& snssai, const plmn_t& plmn, const std::string& dnn,
const std::string& nrf_uri = {});
/*
* Send UE Authentication Request to AUSF
......
......@@ -55,8 +55,9 @@ void statistics::display() {
int i = 1;
for (auto const& gnb : gnbs) {
Logger::amf_app().info(
"| %d | Connected | 0x%x | %s "
" | %s, %s | ",
"| %d | Connected | 0x%x | %s "
" "
" | %s, %s | ",
i, gnb.second.gnb_id, gnb.second.gnb_name.c_str(),
gnb.second.mcc.c_str(), gnb.second.mnc.c_str());
// Comment out to show the supported TA list
......@@ -149,6 +150,21 @@ void statistics::add_gnb(const uint32_t& gnb_id, const gnb_infos& gnb) {
gNB_connected += 1;
}
//------------------------------------------------------------------------------
void statistics::add_gnb(const std::shared_ptr<gnb_context>& gc) {
gnb_infos gnb = {};
gnb.gnb_id = gc->gnb_id;
gnb.mcc = gc->plmn.mcc;
gnb.mnc = gc->plmn.mnc;
gnb.gnb_name = gc->gnb_name;
for (auto i : gc->s_ta_list) {
gnb.plmn_list.push_back(i);
}
std::unique_lock lock(m_gnbs);
gnbs.insert(std::pair<uint32_t, gnb_infos>(gc->gnb_id, gnb));
gNB_connected += 1;
}
//------------------------------------------------------------------------------
void statistics::update_gnb(const uint32_t& gnb_id, const gnb_infos& gnb) {
std::unique_lock lock(m_gnbs);
......
......@@ -109,6 +109,13 @@ class statistics {
*/
void add_gnb(const uint32_t& gnb_id, const gnb_infos& gnb);
/*
* Add gNB to the list connected gNB to this AMF
* @param [const std::shared_ptr<gnb_context> &] gc: pointer to gNB Context
* @return void
*/
void add_gnb(const std::shared_ptr<gnb_context>& gc);
/*
* Update gNB info
* @param [const uint32_t&] gnb_id: gNB ID
......
common-src @ 12e0a397
Subproject commit 12e0a3977f4ae1672543075e523f0ec9b0a75bf4
......@@ -23,12 +23,12 @@ include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/utils/)
include_directories(${SRC_TOP_DIR}/utils/bstr)
include_directories(${SRC_TOP_DIR}/ngap/libngap)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/common/unicode)
include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger)
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/conversions.cpp
${SRC_TOP_DIR}/common/comUt.cpp
${SRC_TOP_DIR}/common/output_wrapper.cpp
)
......@@ -39,6 +39,7 @@ constexpr auto CURL_MIME_BOUNDARY = "----Boundary";
#define FUTURE_STATUS_TIMEOUT_MS 100
#define GNB_ID_FMT "%" PRIu32
#define GNB_UE_NGAP_ID_FMT "%" PRIu32
#define AMF_UE_NGAP_ID_FMT "%" PRIu64
......@@ -76,4 +77,6 @@ typedef enum {
constexpr uint32_t DEFAULT_HTTP1_PORT = 80;
constexpr uint32_t DEFAULT_HTTP2_PORT = 8080;
constexpr auto DEFAULT_SBI_API_VERSION = "v1";
constexpr auto DEFAULT_SUPI_TYPE =
"imsi"; // Set to "imsi" when supporting both IMSI and NAI as SUPI
#endif
......@@ -32,6 +32,10 @@
#include "amf.hpp"
#include "logger.hpp"
#include "output_wrapper.hpp"
constexpr uint8_t kUint32Length =
8; // 4 bytes -8 characters representation in hex
static const char hex_to_ascii_table[16] = {
'0', '1', '2', '3', '4', '5', '6', '7',
......@@ -110,8 +114,8 @@ std::string conv::mncToString(
//------------------------------------------------------------------------------
std::string conv::tmsi_to_string(const uint32_t tmsi) {
std::string s = {};
std::string tmsi_str = std::to_string(tmsi);
uint8_t length = 4 - tmsi_str.size();
std::string tmsi_str = uint32_to_hex_string(tmsi);
uint8_t length = kUint32Length - tmsi_str.size();
for (uint8_t i = 0; i < length; i++) {
s.append("0");
}
......@@ -163,11 +167,8 @@ void conv::convert_string_2_hex(
}
memset(data, 0, input_str.length() + 1);
memcpy((void*) data, (void*) input_str.c_str(), input_str.length());
for (int i = 0; i < input_str.length(); i++) {
printf("%02x ", data[i]);
}
printf("\n");
output_wrapper::print_buffer(
"amf_app", "Data input", data, input_str.length());
char* datahex = (char*) malloc(input_str.length() * 2 + 1);
if (!datahex) {
......@@ -199,9 +200,8 @@ unsigned char* conv::format_string_as_hex(std::string str) {
memset(data, 0, str_len + 1);
memcpy((void*) data, (void*) str.c_str(), str_len);
// TODO: use logger
std::cout << "Data: " << data << " (" << str_len << " bytes)" << std::endl;
std::cout << "Data (formatted): \n";
Logger::amf_app().debug("Data %s (%d bytes)", (void*) data, str_len);
Logger::amf_app().debug("Data (formatted):");
for (int i = 0; i < str_len; i++) {
char datatmp[3] = {0};
memcpy(datatmp, &data[i], 2);
......@@ -215,14 +215,15 @@ unsigned char* conv::format_string_as_hex(std::string str) {
// Convert two hexadecimal characters into one character
unsigned int nAsciiCharacter;
sscanf(datatmp, "%x", &nAsciiCharacter);
printf("%x ", nAsciiCharacter);
if (Logger::should_log(spdlog::level::debug))
printf("%x ", nAsciiCharacter);
// Concatenate this character onto the output
datavalue[i / 2] = (unsigned char) nAsciiCharacter;
// Skip the next character
i++;
}
printf("\n");
if (Logger::should_log(spdlog::level::debug)) printf("\n");
free_wrapper((void**) &data);
return datavalue;
......@@ -245,7 +246,7 @@ char* conv::bstring2charString(bstring b) {
void conv::msg_str_2_msg_hex(std::string msg, bstring& b) {
std::string msg_hex_str = {};
convert_string_2_hex(msg, msg_hex_str);
printf("tmp string: %s\n", msg_hex_str.c_str());
Logger::amf_app().debug("Msg hex %s", msg_hex_str.c_str());
unsigned int msg_len = msg_hex_str.length();
char* data = (char*) malloc(msg_len + 1);
if (!data) {
......@@ -255,7 +256,7 @@ void conv::msg_str_2_msg_hex(std::string msg, bstring& b) {
memset(data, 0, msg_len + 1);
memcpy((void*) data, (void*) msg_hex_str.c_str(), msg_len);
printf("data: %s\n", data);
uint8_t* msg_hex = (uint8_t*) malloc(msg_len / 2 + 1);
if (!msg_hex) {
free_wrapper((void**) &msg_hex);
......@@ -491,3 +492,37 @@ std::string conv::get_serving_network_name(
snn = "5G:mnc" + mnc + ".mcc" + mcc + ".3gppnetwork.org";
return snn;
}
//------------------------------------------------------------------------------
std::string conv::uint32_to_hex_string(uint32_t value) {
char hex_str[kUint32Length + 1];
sprintf(hex_str, "%X", value);
return std::string(hex_str);
}
//------------------------------------------------------------------------------
std::string conv::tmsi_to_guti(
const std::string& mcc, const std::string& mnc,
const std::string& region_id, const std::string& _5g_s_tmsi) {
return {mcc + mnc + region_id + _5g_s_tmsi};
}
//------------------------------------------------------------------------------
std::string conv::tmsi_to_guti(
const std::string& mcc, const std::string& mnc,
const std::string& region_id, const std::string& amf_set_id,
const std::string& amf_pointer, const std::string& tmsi) {
return {mcc + mnc + region_id + amf_set_id + amf_pointer + tmsi};
}
//------------------------------------------------------------------------------
std::string conv::imsi_to_supi(const std::string& imsi) {
std::string supi_type = DEFAULT_SUPI_TYPE;
if (!supi_type.empty()) return {supi_type + "-" + imsi};
return imsi;
}
//------------------------------------------------------------------------------
std::string conv::get_imsi(
const std::string& mcc, const std::string& mnc, const std::string& msin) {
return {mcc + mnc + msin};
}
......@@ -99,5 +99,16 @@ class conv {
const uint32_t ran_ue_ngap_id, long amf_ue_ngap_id);
static std::string get_serving_network_name(
const std::string& mnc, const std::string& mcc);
static std::string uint32_to_hex_string(uint32_t value);
static std::string tmsi_to_guti(
const std::string& mcc, const std::string& mnc,
const std::string& region_id, const std::string& _5g_s_tmsi);
static std::string tmsi_to_guti(
const std::string& mcc, const std::string& mnc,
const std::string& region_id, const std::string& amf_set_id,
const std::string& amf_pointer, const std::string& tmsi);
static std::string imsi_to_supi(const std::string& imsi);
static std::string get_imsi(
const std::string& mcc, const std::string& mnc, const std::string& msin);
};
#endif /* FILE_CONVERSIONS_HPP_SEEN */
/*
* 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
*/
#include "logger.hpp"
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
#include "spdlog/sinks/syslog_sink.h"
Logger* Logger::m_singleton = NULL;
//------------------------------------------------------------------------------
void Logger::_init(
const char* app, const bool log_stdout, const bool log_rot_file) {
int num_sinks = 0;
spdlog::set_async_mode(2048);
#if TRACE_IS_ON
spdlog::level::level_enum llevel = spdlog::level::trace;
#elif DEBUG_IS_ON
spdlog::level::level_enum llevel = spdlog::level::debug;
#elif INFO_IS_ON
spdlog::level::level_enum llevel = spdlog::level::info;
#else
spdlog::level::level_enum llevel = spdlog::level::warn;
#endif
if (log_stdout) {
std::string filename = fmt::format("./{}.log", app);
m_sinks.push_back(
std::make_shared<spdlog::sinks::ansicolor_stdout_sink_mt>());
m_sinks[num_sinks++].get()->set_level(llevel);
}
if (log_rot_file) {
std::string filename = fmt::format("./{}.log", app);
m_sinks.push_back(std::make_shared<spdlog::sinks::rotating_file_sink_mt>(
filename, 5 * 1024 * 1024, 3));
}
std::stringstream ss;
ss << "[%Y-%m-%dT%H:%M:%S.%f] [" << app << "] [%n] [%l] %v";
m_async_cmd = new _Logger("asnyc_c", m_sinks, ss.str().c_str());
m_amf_app = new _Logger("amf_app", m_sinks, ss.str().c_str());
m_config = new _Logger("config ", m_sinks, ss.str().c_str());
m_system = new _Logger("system ", m_sinks, ss.str().c_str());
m_sctp = new _Logger("sctp ", m_sinks, ss.str().c_str());
m_nas_mm = new _Logger("nas_mm ", m_sinks, ss.str().c_str());
m_ngap = new _Logger("ngap ", m_sinks, ss.str().c_str());
m_itti = new _Logger("itti ", m_sinks, ss.str().c_str());
m_amf_n2 = new _Logger("amf_n2 ", m_sinks, ss.str().c_str());
m_amf_n1 = new _Logger("amf_n1 ", m_sinks, ss.str().c_str());
m_amf_sbi = new _Logger("amf_sbi", m_sinks, ss.str().c_str());
m_amf_server = new _Logger("amf_server", m_sinks, ss.str().c_str());
}
//------------------------------------------------------------------------------
_Logger::_Logger(
const char* category, std::vector<spdlog::sink_ptr>& sinks,
const char* pattern)
: m_log(category, sinks.begin(), sinks.end()) {
m_log.set_pattern(pattern);
#if TRACE_IS_ON
m_log.set_level(spdlog::level::trace);
#elif DEBUG_IS_ON
m_log.set_level(spdlog::level::debug);
#elif INFO_IS_ON
m_log.set_level(spdlog::level::info);
#else
m_log.set_level(spdlog::level::warn);
#endif
}
//------------------------------------------------------------------------------
void _Logger::trace(const char* format, ...) {
#if TRACE_IS_ON
va_list args;
va_start(args, format);
log(_ltTrace, format, args);
va_end(args);
#endif
}
//------------------------------------------------------------------------------
void _Logger::debug(const char* format, ...) {
#if DEBUG_IS_ON
va_list args;
va_start(args, format);
log(_ltDebug, format, args);
va_end(args);
#endif
}
//------------------------------------------------------------------------------
void _Logger::info(const char* format, ...) {
#if INFO_IS_ON
va_list args;
va_start(args, format);
log(_ltInfo, format, args);
va_end(args);
#endif
}
//------------------------------------------------------------------------------
void _Logger::startup(const char* format, ...) {
va_list args;
va_start(args, format);
log(_ltStartup, format, args);
va_end(args);
}
//------------------------------------------------------------------------------
void _Logger::warn(const char* format, ...) {
va_list args;
va_start(args, format);
log(_ltWarn, format, args);
va_end(args);
}
//------------------------------------------------------------------------------
void _Logger::error(const char* format, ...) {
va_list args;
va_start(args, format);
log(_ltError, format, args);
va_end(args);
}
//------------------------------------------------------------------------------
void _Logger::log(_LogType lt, const char* format, va_list& args) {
char buffer[2048];
vsnprintf(buffer, sizeof(buffer), format, args);
switch (lt) {
case _ltTrace:
m_log.trace(buffer);
break;
case _ltDebug:
m_log.debug(buffer);
break;
case _ltInfo:
m_log.info(buffer);
break;
case _ltStartup:
m_log.warn(buffer);
break;
case _ltWarn:
m_log.error(buffer);
break;
case _ltError:
m_log.critical(buffer);
break;
}
}
This diff is collapsed.
......@@ -19,38 +19,28 @@
* contact@openairinterface.org
*/
#include "comUt.hpp"
#include "output_wrapper.hpp"
#include "logger.hpp"
//------------------------------------------------------------------------------
void comUt::print_buffer(
const std::string app, const std::string commit, uint8_t* buf, int len) {
if (!app.compare("amf_app")) Logger::amf_app().debug(commit.c_str());
if (!app.compare("amf_n1")) Logger::amf_n1().debug(commit.c_str());
if (!app.compare("amf_server")) Logger::amf_server().debug(commit.c_str());
if (!app.compare("amf_sbi")) Logger::amf_sbi().debug(commit.c_str());
#if DEBUG_IS_ON
for (int i = 0; i < len; i++) printf("%x ", buf[i]);
printf("\n");
#endif
void output_wrapper::print_buffer(
const std::string app, const std::string sink, uint8_t* buf, int len) {
if (!app.compare("amf_app")) Logger::amf_app().debug(sink.c_str());
if (!app.compare("amf_n1")) Logger::amf_n1().debug(sink.c_str());
if (!app.compare("amf_n2")) Logger::amf_n2().debug(sink.c_str());
if (!app.compare("ngap")) Logger::ngap().debug(sink.c_str());
if (!app.compare("amf_server")) Logger::amf_server().debug(sink.c_str());
if (!app.compare("amf_sbi")) Logger::amf_sbi().debug(sink.c_str());
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < len; i++) printf("%02x ", buf[i]);
printf("\n");
}
}
//------------------------------------------------------------------------------
void comUt::hexStr2Byte(const char* src, unsigned char* dest, int len) {
short i;
unsigned char hBy, lBy;
for (i = 0; i < len; i += 2) {
hBy = toupper(src[i]);
lBy = toupper(src[i + 1]);
if (hBy > 0x39)
hBy -= 0x37;
else
hBy -= 0x30;
if (lBy > 0x39)
lBy -= 0x37;
else
lBy -= 0x30;
dest[i / 2] = (hBy << 4) | lBy;
}
void output_wrapper::print_asn_msg(
const asn_TYPE_descriptor_t* td, const void* struct_ptr) {
if (Logger::should_log(spdlog::level::debug))
asn_fprint(stdout, td, struct_ptr);
}
......@@ -19,18 +19,21 @@
* contact@openairinterface.org
*/
#ifndef _PRINT_BUFFER_H
#define _PRINT_BUFFER_H
#include <string>
#ifndef _OUTPUT_WRAPPER_H
#define _OUTPUT_WRAPPER_H
#include "logger.hpp"
class comUt {
extern "C" {
#include "constr_TYPE.h"
}
class output_wrapper {
public:
static void print_buffer(
const std::string app, const std::string commit, uint8_t* buf, int len);
static void hexStr2Byte(const char* src, unsigned char* dest, int len);
const std::string app, const std::string sink, uint8_t* buf, int len);
static void print_asn_msg(
const asn_TYPE_descriptor_t* td, const void* struct_ptr);
};
#endif
......@@ -19,7 +19,6 @@
# contact@openairinterface.org
################################################################################
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)
......@@ -35,6 +34,7 @@ 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}/${MOUNTED_COMMON}/logger)
add_library (CONTEXTS STATIC
${CMAKE_CURRENT_SOURCE_DIR}/nas_context.cpp
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -34,7 +34,7 @@ pdu_session_context::pdu_session_context() {
smf_info.info_available = false;
smf_info.addr = {};
smf_info.api_version = "v1";
smf_info.port = "80";
smf_info.port = DEFAULT_HTTP1_PORT;
snssai = {};
plmn = {};
is_ho_accepted = false;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -150,7 +150,7 @@ static const std::vector<std::string> nas_ciphering_algorithm_list_e2str = {
/************************** cause value for 5g mobility management(Annex A)
* ********************************/
#define _5GMM_CAUSE_ILLEGAL_UE 3
#define _5GMM_CAUSE_SYNCH_FAILURE 0b00010101
#define _5GMM_CAUSE_SYNCH_FAILURE 0b00010101 // 21
#define _5GMM_CAUSE_IMPLICITLY_DE_REGISTERED 10
#define _5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED 9
#define _5GMM_CAUSE_NGKSI_ALREADY_IN_USE 0b01000111 // 71
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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