Commit e6a7c6d8 authored by Raphael Defosseux's avatar Raphael Defosseux

Merge branch 'fqdn_dns' into 'develop'

Fqdn dns

See merge request oai/cn5g/oai-cn5g-amf!28
parents 6071beb4 bfef8dcf
...@@ -128,6 +128,7 @@ check_supported_distribution() { ...@@ -128,6 +128,7 @@ check_supported_distribution() {
local distribution=$(get_distribution_release) local distribution=$(get_distribution_release)
case "$distribution" in case "$distribution" in
"ubuntu18.04") return 0 ;; "ubuntu18.04") return 0 ;;
"ubuntu20.04") return 0 ;;
"rhel8") return 0 ;; "rhel8") return 0 ;;
"rhel8.2") return 0 ;; "rhel8.2") return 0 ;;
"rhel8.3") return 0 ;; "rhel8.3") return 0 ;;
......
...@@ -32,6 +32,45 @@ THIS_SCRIPT_PATH=`dirname $SCRIPT` ...@@ -32,6 +32,45 @@ THIS_SCRIPT_PATH=`dirname $SCRIPT`
source $THIS_SCRIPT_PATH/build_helper source $THIS_SCRIPT_PATH/build_helper
source $THIS_SCRIPT_PATH/build_helper.fb_folly source $THIS_SCRIPT_PATH/build_helper.fb_folly
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_boost_1_66() {
if [ $1 -eq 0 ]; then
read -p "Do you want to install Boost version 1.66.0 ? <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
BOOST_URL=https://boostorg.jfrog.io/artifactory/main/release/1.66.0/source/boost_1_66_0.tar.bz2
echo "Install Boost from $BOOST_URL"
pushd $OPENAIRCN_DIR/build/ext
echo "Downloading Boost 1.66.0"
if [[ $OPTION =~ -[yY](es)* ]]
then
$SUDO rm -rf boost
fi
#git clone $GIT_URL
wget $BOOST_URL
tar --bzip2 -xf boost_1_66_0.tar.bz2
cp -fR boost_1_66_0/boost /usr/include
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd
fi
return 0
}
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script) #arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries) #arg2 is debug (0 or 1) (install debug libraries)
...@@ -259,6 +298,8 @@ install_nlohmann_from_git() { ...@@ -259,6 +298,8 @@ install_nlohmann_from_git() {
#arg2 is debug (0 or 1) (install debug libraries) #arg2 is debug (0 or 1) (install debug libraries)
check_install_amf_deps(){ check_install_amf_deps(){
var_ubuntu_18_04=0
if [ $1 -gt 0 ]; then if [ $1 -gt 0 ]; then
OPTION="-y" OPTION="-y"
else else
...@@ -300,6 +341,7 @@ check_install_amf_deps(){ ...@@ -300,6 +341,7 @@ check_install_amf_deps(){
doxygen \ doxygen \
flex \ flex \
gdb \ gdb \
wget \
git" git"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\ PACKAGE_LIST="\
...@@ -319,11 +361,24 @@ check_install_amf_deps(){ ...@@ -319,11 +361,24 @@ check_install_amf_deps(){
echo "Install build tools" echo "Install build tools"
$SUDO $INSTALLER install $OPTION $PACKAGE_LIST $SUDO $INSTALLER install $OPTION $PACKAGE_LIST
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
# Libraries # Libraries
if [[ $OS_DISTRO == "ubuntu" ]]; then if [[ $OS_DISTRO == "ubuntu" ]]; then
case "$(get_distribution_release)" in case "$(get_distribution_release)" in
"ubuntu18.04") "ubuntu18.04")
# Currently Ubuntu18.04 has boost 1.65 as the latest
# We need at least 1.66
# PPA has 1.67
$SUDO add-apt-repository ppa:mhier/libboost-latest --yes
$SUDO $INSTALLER update
#var_ubuntu_18_04=1
if [ $IS_CONTAINER -eq 0 ]; then
specific_packages="libconfig++-dev libasio-dev libboost-all-dev mysql-server"
else
specific_packages="libconfig++-dev"
fi
;;
*)
if [ $IS_CONTAINER -eq 0 ]; then if [ $IS_CONTAINER -eq 0 ]; then
specific_packages="libconfig++-dev libasio-dev libboost-all-dev mysql-server" specific_packages="libconfig++-dev libasio-dev libboost-all-dev mysql-server"
else else
...@@ -334,10 +389,10 @@ check_install_amf_deps(){ ...@@ -334,10 +389,10 @@ check_install_amf_deps(){
# removed libspdlog-dev # removed libspdlog-dev
PACKAGE_LIST="\ PACKAGE_LIST="\
$specific_packages \ $specific_packages \
libboost1.67-dev \
mysql-server \ mysql-server \
mysql-client \ mysql-client \
libmysqlclient-dev \ libmysqlclient-dev \
libcpprest-dev \
guile-2.0-dev \ guile-2.0-dev \
libcurl4-gnutls-dev \ libcurl4-gnutls-dev \
libevent-dev \ libevent-dev \
...@@ -359,6 +414,7 @@ check_install_amf_deps(){ ...@@ -359,6 +414,7 @@ check_install_amf_deps(){
net-tools \ net-tools \
pkg-config \ pkg-config \
ninja-build \ ninja-build \
wget \
libasan2" libasan2"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\ PACKAGE_LIST="\
...@@ -396,8 +452,8 @@ check_install_amf_deps(){ ...@@ -396,8 +452,8 @@ check_install_amf_deps(){
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
# Use fmt lib included in spdlog # Use fmt lib included in spdlog
install_fmt $1 # install_fmt $1
ret=$?;[[ $ret -ne 0 ]] && return $ret # ret=$?;[[ $ret -ne 0 ]] && return $ret
install_spdlog_from_git $1 $2 install_spdlog_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
...@@ -411,6 +467,11 @@ check_install_amf_deps(){ ...@@ -411,6 +467,11 @@ check_install_amf_deps(){
install_nlohmann_from_git $1 $2 install_nlohmann_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
if [ $var_ubuntu_18_04 -ne 0 ]; then
install_boost_1_66 $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
fi
$SUDO ldconfig $SUDO ldconfig
return 0 return 0
......
...@@ -34,23 +34,30 @@ AMF_CONF[@SD_0@]='123' ...@@ -34,23 +34,30 @@ AMF_CONF[@SD_0@]='123'
AMF_CONF[@SST_1@]='1' AMF_CONF[@SST_1@]='1'
AMF_CONF[@SD_1@]='12' AMF_CONF[@SD_1@]='12'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_NGAP@]='enx0050b6f4ba5b' AMF_CONF[@AMF_INTERFACE_NAME_FOR_NGAP@]='wlo1'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_N11@]='enx0050b6f4ba5b' AMF_CONF[@AMF_INTERFACE_NAME_FOR_N11@]='wlo1'
AMF_CONF[@NF_REGISTRATION@]='no'
AMF_CONF[@SMF_SELECTION@]='no'
AMF_CONF[@SMF_INSTANCE_ID_0@]='1' AMF_CONF[@SMF_INSTANCE_ID_0@]='1'
AMF_CONF[@SMF_IPV4_ADDR_0@]='192.168.122.1' AMF_CONF[@SMF_IPV4_ADDR_0@]='192.168.122.1'
AMF_CONF[@SMF_HTTP_VERSION_0@]='v1' AMF_CONF[@SMF_HTTP_VERSION_0@]='v1'
AMF_CONF[@SMF_FQDN_0@]='localhost'
AMF_CONF[@SMF_INSTANCE_ID_1@]='2' AMF_CONF[@SMF_INSTANCE_ID_1@]='2'
AMF_CONF[@SMF_IPV4_ADDR_1@]='192.168.122.2' AMF_CONF[@SMF_IPV4_ADDR_1@]='192.168.122.2'
AMF_CONF[@SMF_HTTP_VERSION_1@]='v1' AMF_CONF[@SMF_HTTP_VERSION_1@]='v1'
AMF_CONF[@SMF_FQDN_1@]='localhost'
AMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.1.23' AMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.1.23'
AMF_CONF[@NRF_PORT@]='80' AMF_CONF[@NRF_PORT@]='80'
AMF_CONF[@NRF_API_VERSION@]='v1' AMF_CONF[@NRF_API_VERSION@]='v1'
AMF_CONF[@NRF_FQDN@]='localhost'
AMF_CONF[@AUSF_IPV4_ADDRESS@]='192.168.1.23' AMF_CONF[@AUSF_IPV4_ADDRESS@]='192.168.1.23'
AMF_CONF[@AUSF_PORT@]='80' AMF_CONF[@AUSF_PORT@]='80'
AMF_CONF[@AUSF_API_VERSION@]='v1' AMF_CONF[@AUSF_API_VERSION@]='v1'
AMF_CONF[@AUSF_FQDN@]='localhost'
AMF_CONF[@MYSQL_SERVER@]='127.0.0.1' AMF_CONF[@MYSQL_SERVER@]='127.0.0.1'
AMF_CONF[@MYSQL_USER@]='root' AMF_CONF[@MYSQL_USER@]='root'
......
...@@ -51,6 +51,7 @@ RUN apt-get update && \ ...@@ -51,6 +51,7 @@ RUN apt-get update && \
tzdata \ tzdata \
psmisc \ psmisc \
net-tools \ net-tools \
libconfig++-dev \
bc \ bc \
tshark \ tshark \
libconfig++9v5 \ libconfig++9v5 \
...@@ -65,8 +66,6 @@ COPY --from=oai-amf-builder /openair-amf/scripts/entrypoint.sh entrypoint.sh ...@@ -65,8 +66,6 @@ COPY --from=oai-amf-builder /openair-amf/scripts/entrypoint.sh entrypoint.sh
WORKDIR /usr/lib/x86_64-linux-gnu WORKDIR /usr/lib/x86_64-linux-gnu
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcpprest.so.2.10 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libssl.so.1.1 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libssl.so.1.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 .
...@@ -87,6 +86,8 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 . ...@@ -87,6 +86,8 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libasan.so.4 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libasan.so.4 .
WORKDIR /usr/local/lib WORKDIR /usr/local/lib
COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 .
COPY --from=oai-amf-builder /usr/local/lib/libpistache.so . COPY --from=oai-amf-builder /usr/local/lib/libpistache.so .
RUN ldconfig RUN ldconfig
......
...@@ -34,11 +34,13 @@ ARG NEEDED_GIT_PROXY ...@@ -34,11 +34,13 @@ ARG NEEDED_GIT_PROXY
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe ENV TZ=Europe
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN apt-get update && \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && DEBIAN_FRONTEND=noninteractive apt-get install --yes \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
psmisc \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \
git \ psmisc \
vim \ software-properties-common \
git \
vim \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Some GIT configuration commands quite useful # Some GIT configuration commands quite useful
...@@ -63,16 +65,18 @@ RUN ./build_amf --clean --Verbose --build-type Release --jobs ...@@ -63,16 +65,18 @@ RUN ./build_amf --clean --Verbose --build-type Release --jobs
FROM ubuntu:bionic as oai-amf FROM ubuntu:bionic as oai-amf
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# We install some debug tools for the moment in addition of mandatory libraries # We install some debug tools for the moment in addition of mandatory libraries
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && DEBIAN_FRONTEND=noninteractive apt-get install --yes \ RUN apt-get update && \
tzdata \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
psmisc \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \
net-tools \ tzdata \
bc \ psmisc \
tshark \ net-tools \
libconfig++9v5 \ libconfig++-dev \
libsctp1 \ bc \
tshark \
libconfig++9v5 \
libsctp1 \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Copying executable and generated libraries # Copying executable and generated libraries
...@@ -83,8 +87,6 @@ COPY --from=oai-amf-builder /openair-amf/scripts/entrypoint.sh entrypoint.sh ...@@ -83,8 +87,6 @@ COPY --from=oai-amf-builder /openair-amf/scripts/entrypoint.sh entrypoint.sh
WORKDIR /usr/lib/x86_64-linux-gnu WORKDIR /usr/lib/x86_64-linux-gnu
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcpprest.so.2.10 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libssl.so.1.1 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libssl.so.1.1 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 .
...@@ -105,6 +107,8 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 . ...@@ -105,6 +107,8 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 .
COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libasan.so.4 . COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libasan.so.4 .
WORKDIR /usr/local/lib WORKDIR /usr/local/lib
COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 .
COPY --from=oai-amf-builder /usr/local/lib/libpistache.so . COPY --from=oai-amf-builder /usr/local/lib/libpistache.so .
RUN ldconfig RUN ldconfig
...@@ -119,5 +123,4 @@ WORKDIR /openair-amf ...@@ -119,5 +123,4 @@ WORKDIR /openair-amf
EXPOSE 80/tcp 9090/tcp 38412/sctp EXPOSE 80/tcp 9090/tcp 38412/sctp
ENTRYPOINT ["/bin/bash","/openair-amf/bin/entrypoint.sh"] ENTRYPOINT ["/bin/bash","/openair-amf/bin/entrypoint.sh"]
CMD ["/openair-amf/bin/oai_amf", "-c", "/openair-amf/etc/amf.conf", "-o"] CMD ["/openair-amf/bin/oai_amf", "-c", "/openair-amf/etc/amf.conf", "-o"]
...@@ -72,27 +72,27 @@ AMF = ...@@ -72,27 +72,27 @@ AMF =
INTERFACE_NAME = "@AMF_INTERFACE_NAME_FOR_N11@"; # YOUR NETWORK CONFIG HERE INTERFACE_NAME = "@AMF_INTERFACE_NAME_FOR_N11@"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read"; IPV4_ADDRESS = "read";
PORT = 80; # YOUR NETWORK CONFIG HERE PORT = 80; # YOUR NETWORK CONFIG HERE
API_VERSION = "v1"; # YOUR AMF API VERSION CONFIG HERE API_VERSION = "v1"; # YOUR AMF API VERSION CONFIG HERE
SMF_INSTANCES_POOL = ( SMF_INSTANCES_POOL = (
{SMF_INSTANCE_ID = @SMF_INSTANCE_ID_0@; IPV4_ADDRESS = "@SMF_IPV4_ADDR_0@"; PORT = "80"; VERSION = "@SMF_HTTP_VERSION_0@"; SELECTED = "true"}, # YOUR SMF CONFIG HERE {SMF_INSTANCE_ID = @SMF_INSTANCE_ID_0@; IPV4_ADDRESS = "@SMF_IPV4_ADDR_0@"; PORT = "80"; VERSION = "@SMF_HTTP_VERSION_0@"; FQDN = "@SMF_FQDN_0@", SELECTED = "true"}, # YOUR SMF CONFIG HERE
{SMF_INSTANCE_ID = @SMF_INSTANCE_ID_1@; IPV4_ADDRESS = "@SMF_IPV4_ADDR_1@"; PORT = "80"; VERSION = "@SMF_HTTP_VERSION_1@"; SELECTED = "false"} # YOUR SMF CONFIG HERE {SMF_INSTANCE_ID = @SMF_INSTANCE_ID_1@; IPV4_ADDRESS = "@SMF_IPV4_ADDR_1@"; PORT = "80"; VERSION = "@SMF_HTTP_VERSION_1@"; FQDN = "@SMF_FQDN_1@", SELECTED = "false"} # YOUR SMF CONFIG HERE
); );
}; };
NRF : NRF :
{ {
IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@"; # YOUR NRF CONFIG HERE IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@"; # YOUR NRF CONFIG HERE
PORT = @NRF_PORT@; # YOUR NRF CONFIG HERE (default: 80) PORT = @NRF_PORT@; # YOUR NRF CONFIG HERE (default: 80)
API_VERSION = "@NRF_API_VERSION@"; # YOUR NRF API VERSION FOR SBI CONFIG HERE API_VERSION = "@NRF_API_VERSION@"; # YOUR NRF API VERSION FOR SBI CONFIG HERE
FQDN = "@NRF_FQDN@"
}; };
AUSF : AUSF :
{ {
IPV4_ADDRESS = "@AUSF_IPV4_ADDRESS@"; # YOUR AUSF CONFIG HERE IPV4_ADDRESS = "@AUSF_IPV4_ADDRESS@"; # YOUR AUSF CONFIG HERE
PORT = @AUSF_PORT@; # YOUR AUSF CONFIG HERE (default: 80) PORT = @AUSF_PORT@; # YOUR AUSF CONFIG HERE (default: 80)
API_VERSION = "@AUSF_API_VERSION@"; # YOUR AUSF API VERSION FOR SBI CONFIG HERE API_VERSION = "@AUSF_API_VERSION@"; # YOUR AUSF API VERSION FOR SBI CONFIG HERE
}; };
}; };
...@@ -101,9 +101,10 @@ AMF = ...@@ -101,9 +101,10 @@ AMF =
{ {
# STRING, {"yes", "no"}, # STRING, {"yes", "no"},
NF_REGISTRATION = "@NF_REGISTRATION@"; # Set to yes if AMF resgisters to an NRF NF_REGISTRATION = "@NF_REGISTRATION@"; # Set to yes if AMF resgisters to an NRF
SMF_SELECTION = "@SMF_SELECTION@"; # Set to yes to enable SMF discovery and selection SMF_SELECTION = "@SMF_SELECTION@"; # Set to yes to enable SMF discovery and selection
EXTERNAL_AUSF = "no"; # Set to yes if AMF works with an external AUSF EXTERNAL_AUSF = "no"; # Set to yes if AMF works with an external AUSF
EXTERNAL_UDM = "no"; # Set to yes if AMF works with an external UDM EXTERNAL_UDM = "no"; # Set to yes if AMF works with an external UDM
USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if AMF relies on a DNS to resolve NRF/SMF/UDM/AUSF's FQDN
} }
AUTHENTICATION: AUTHENTICATION:
......
...@@ -404,13 +404,9 @@ void amf_app::generate_amf_profile() { ...@@ -404,13 +404,9 @@ void amf_app::generate_amf_profile() {
nf_service.nf_service_status = "REGISTERED"; nf_service.nf_service_status = "REGISTERED";
// IP Endpoint // IP Endpoint
ip_endpoint_t endpoint = {}; ip_endpoint_t endpoint = {};
std::vector<struct in_addr> addrs; endpoint.ipv4_address = amf_cfg.n11.addr4;
nf_instance_profile.get_nf_ipv4_addresses(addrs); endpoint.transport = "TCP";
for (auto a : addrs) { endpoint.port = amf_cfg.n11.port;
endpoint.ipv4_addresses.push_back(a);
}
endpoint.transport = "TCP";
endpoint.port = amf_cfg.n11.port;
nf_service.ip_endpoints.push_back(endpoint); nf_service.ip_endpoints.push_back(endpoint);
nf_instance_profile.add_nf_service(nf_service); nf_instance_profile.add_nf_service(nf_service);
...@@ -452,12 +448,17 @@ void amf_app::trigger_nf_registration_request() { ...@@ -452,12 +448,17 @@ void amf_app::trigger_nf_registration_request() {
std::make_shared<itti_n11_register_nf_instance_request>( std::make_shared<itti_n11_register_nf_instance_request>(
TASK_AMF_APP, TASK_AMF_N11); TASK_AMF_APP, TASK_AMF_N11);
itti_msg->profile = nf_instance_profile; itti_msg->profile = nf_instance_profile;
amf_n11_inst->register_nf_instance(itti_msg);
/*
int ret = itti_inst->send_msg(itti_msg); int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) { if (RETURNok != ret) {
Logger::amf_app().error( Logger::amf_app().error(
"Could not send ITTI message %s to task TASK_AMF_N11", "Could not send ITTI message %s to task TASK_AMF_N11",
itti_msg->get_msg_name()); itti_msg->get_msg_name());
} }
*/
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "logger.hpp" #include "logger.hpp"
#include "string.hpp" #include "string.hpp"
#include "thread_sched.hpp" #include "thread_sched.hpp"
#include "fqdn.hpp"
extern "C" { extern "C" {
#include <arpa/inet.h> #include <arpa/inet.h>
...@@ -79,6 +80,7 @@ amf_config::amf_config() { ...@@ -79,6 +80,7 @@ amf_config::amf_config() {
enable_smf_selection = false; enable_smf_selection = false;
enable_external_ausf = false; enable_external_ausf = false;
enable_external_udm = false; enable_external_udm = false;
use_fqdn_dns = false;
struct { struct {
struct in_addr ipv4_addr; struct in_addr ipv4_addr;
...@@ -104,6 +106,8 @@ int amf_config::load(const std::string& config_file) { ...@@ -104,6 +106,8 @@ int amf_config::load(const std::string& config_file) {
"\nLoad AMF system configuration file(%s)", config_file.c_str()); "\nLoad AMF system configuration file(%s)", config_file.c_str());
Config cfg; Config cfg;
unsigned char buf_in6_addr[sizeof(struct in6_addr)]; unsigned char buf_in6_addr[sizeof(struct in6_addr)];
// Config file
try { try {
cfg.readFile(config_file.c_str()); cfg.readFile(config_file.c_str());
} catch (const FileIOException& fioex) { } catch (const FileIOException& fioex) {
...@@ -117,13 +121,18 @@ int amf_config::load(const std::string& config_file) { ...@@ -117,13 +121,18 @@ int amf_config::load(const std::string& config_file) {
pex.getError()); pex.getError());
throw; throw;
} }
const Setting& root = cfg.getRoot(); const Setting& root = cfg.getRoot();
// AMF config
try { try {
const Setting& amf_cfg = root[AMF_CONFIG_STRING_AMF_CONFIG]; const Setting& amf_cfg = root[AMF_CONFIG_STRING_AMF_CONFIG];
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error("%s : %s", nfex.what(), nfex.getPath()); Logger::amf_app().error("%s : %s", nfex.what(), nfex.getPath());
return -1; return -1;
} }
// Instance
const Setting& amf_cfg = root[AMF_CONFIG_STRING_AMF_CONFIG]; const Setting& amf_cfg = root[AMF_CONFIG_STRING_AMF_CONFIG];
try { try {
amf_cfg.lookupValue(AMF_CONFIG_STRING_INSTANCE_ID, instance); amf_cfg.lookupValue(AMF_CONFIG_STRING_INSTANCE_ID, instance);
...@@ -131,6 +140,8 @@ int amf_config::load(const std::string& config_file) { ...@@ -131,6 +140,8 @@ int amf_config::load(const std::string& config_file) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
} }
// Statistic Timer interval
try { try {
amf_cfg.lookupValue( amf_cfg.lookupValue(
AMF_CONFIG_STRING_STATISTICS_TIMER_INTERVAL, statistics_interval); AMF_CONFIG_STRING_STATISTICS_TIMER_INTERVAL, statistics_interval);
...@@ -138,18 +149,24 @@ int amf_config::load(const std::string& config_file) { ...@@ -138,18 +149,24 @@ int amf_config::load(const std::string& config_file) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
} }
// PID Dir
try { try {
amf_cfg.lookupValue(AMF_CONFIG_STRING_PID_DIRECTORY, pid_dir); amf_cfg.lookupValue(AMF_CONFIG_STRING_PID_DIRECTORY, pid_dir);
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
} }
// AMF Name
try { try {
amf_cfg.lookupValue(AMF_CONFIG_STRING_AMF_NAME, AMF_Name); amf_cfg.lookupValue(AMF_CONFIG_STRING_AMF_NAME, AMF_Name);
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
} }
// GUAMI
try { try {
const Setting& guami_cfg = amf_cfg[AMF_CONFIG_STRING_GUAMI]; const Setting& guami_cfg = amf_cfg[AMF_CONFIG_STRING_GUAMI];
guami_cfg.lookupValue(AMF_CONFIG_STRING_MCC, guami.mcc); guami_cfg.lookupValue(AMF_CONFIG_STRING_MCC, guami.mcc);
...@@ -161,6 +178,8 @@ int amf_config::load(const std::string& config_file) { ...@@ -161,6 +178,8 @@ int amf_config::load(const std::string& config_file) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
} }
// GUAMI List
try { try {
const Setting& guami_list_cfg = const Setting& guami_list_cfg =
amf_cfg[AMF_CONFIG_STRING_SERVED_GUAMI_LIST]; amf_cfg[AMF_CONFIG_STRING_SERVED_GUAMI_LIST];
...@@ -179,6 +198,8 @@ int amf_config::load(const std::string& config_file) { ...@@ -179,6 +198,8 @@ int amf_config::load(const std::string& config_file) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
} }
// AMF Capacity
try { try {
amf_cfg.lookupValue( amf_cfg.lookupValue(
AMF_CONFIG_STRING_RELATIVE_AMF_CAPACITY, relativeAMFCapacity); AMF_CONFIG_STRING_RELATIVE_AMF_CAPACITY, relativeAMFCapacity);
...@@ -186,6 +207,8 @@ int amf_config::load(const std::string& config_file) { ...@@ -186,6 +207,8 @@ int amf_config::load(const std::string& config_file) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
} }
// PLMN List
try { try {
const Setting& plmn_list_cfg = amf_cfg[AMF_CONFIG_STRING_PLMN_SUPPORT_LIST]; const Setting& plmn_list_cfg = amf_cfg[AMF_CONFIG_STRING_PLMN_SUPPORT_LIST];
int count = plmn_list_cfg.getLength(); int count = plmn_list_cfg.getLength();
...@@ -211,13 +234,72 @@ int amf_config::load(const std::string& config_file) { ...@@ -211,13 +234,72 @@ int amf_config::load(const std::string& config_file) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
} }
// Supported features
try {
const Setting& support_features =
amf_cfg[AMF_CONFIG_STRING_SUPPORT_FEATURES];
string opt;
support_features.lookupValue(
AMF_CONFIG_STRING_SUPPORT_FEATURES_NF_REGISTRATION, opt);
if (boost::iequals(opt, "yes")) {
enable_nf_registration = true;
} else {
enable_nf_registration = false;
}
support_features.lookupValue(
AMF_CONFIG_STRING_SUPPORT_FEATURES_SMF_SELECTION, opt);
if (boost::iequals(opt, "yes")) {
enable_smf_selection = true;
} else {
enable_smf_selection = false;
}
support_features.lookupValue(
AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AUSF, opt);
if (boost::iequals(opt, "yes")) {
enable_external_ausf = true;
} else {
enable_external_ausf = false;
}
support_features.lookupValue(
AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_UDM, opt);
if (boost::iequals(opt, "yes")) {
enable_external_udm = true;
} else {
enable_external_udm = false;
}
support_features.lookupValue(
AMF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS, opt);
if (boost::iequals(opt, "yes")) {
use_fqdn_dns = true;
} else {
use_fqdn_dns = false;
}
} catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath());
return -1;
}
// Network interfaces
// TODO: should move SMF/NRF/AUSF out of this section
try { try {
const Setting& new_if_cfg = amf_cfg[AMF_CONFIG_STRING_INTERFACES]; const Setting& new_if_cfg = amf_cfg[AMF_CONFIG_STRING_INTERFACES];
// N2
const Setting& n2_amf_cfg = const Setting& n2_amf_cfg =
new_if_cfg[AMF_CONFIG_STRING_INTERFACE_NGAP_AMF]; new_if_cfg[AMF_CONFIG_STRING_INTERFACE_NGAP_AMF];
load_interface(n2_amf_cfg, n2); load_interface(n2_amf_cfg, n2);
// N11
const Setting& n11_cfg = new_if_cfg[AMF_CONFIG_STRING_INTERFACE_N11]; const Setting& n11_cfg = new_if_cfg[AMF_CONFIG_STRING_INTERFACE_N11];
load_interface(n11_cfg, n11); load_interface(n11_cfg, n11);
// SBI API VERSION // SBI API VERSION
if (!(n11_cfg.lookupValue( if (!(n11_cfg.lookupValue(
AMF_CONFIG_STRING_API_VERSION, sbi_api_version))) { AMF_CONFIG_STRING_API_VERSION, sbi_api_version))) {
...@@ -225,22 +307,60 @@ int amf_config::load(const std::string& config_file) { ...@@ -225,22 +307,60 @@ int amf_config::load(const std::string& config_file) {
throw(AMF_CONFIG_STRING_API_VERSION "failed"); throw(AMF_CONFIG_STRING_API_VERSION "failed");
} }
// SMF
const Setting& smf_addr_pool = const Setting& smf_addr_pool =
n11_cfg[AMF_CONFIG_STRING_SMF_INSTANCES_POOL]; n11_cfg[AMF_CONFIG_STRING_SMF_INSTANCES_POOL];
int count = smf_addr_pool.getLength(); int count = smf_addr_pool.getLength();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
const Setting& smf_addr_item = smf_addr_pool[i]; const Setting& smf_addr_item = smf_addr_pool[i];
smf_inst_t smf_inst; smf_inst_t smf_inst = {};
std::string selected; struct in_addr smf_ipv4_addr = {};
unsigned int smf_port = {};
std::string smf_api_version = {};
std::string selected = {};
smf_addr_item.lookupValue(AMF_CONFIG_STRING_SMF_INSTANCE_ID, smf_inst.id); smf_addr_item.lookupValue(AMF_CONFIG_STRING_SMF_INSTANCE_ID, smf_inst.id);
smf_addr_item.lookupValue(AMF_CONFIG_STRING_IPV4_ADDRESS, smf_inst.ipv4); if (!use_fqdn_dns) {
smf_addr_item.lookupValue( smf_addr_item.lookupValue(
AMF_CONFIG_STRING_SMF_INSTANCE_PORT, smf_inst.port); AMF_CONFIG_STRING_IPV4_ADDRESS, smf_inst.ipv4);
smf_addr_item.lookupValue( IPV4_STR_ADDR_TO_INADDR(
AMF_CONFIG_STRING_SMF_INSTANCE_VERSION, smf_inst.version); util::trim(smf_inst.ipv4).c_str(), smf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR SMF !");
if (!(smf_addr_item.lookupValue(
AMF_CONFIG_STRING_SMF_INSTANCE_PORT, smf_inst.port))) {
Logger::amf_app().error(AMF_CONFIG_STRING_SMF_INSTANCE_PORT "failed");
throw(AMF_CONFIG_STRING_SMF_INSTANCE_PORT "failed");
}
smf_addr_item.lookupValue(
AMF_CONFIG_STRING_SMF_INSTANCE_VERSION, smf_inst.version);
if (!(smf_addr_item.lookupValue(
AMF_CONFIG_STRING_SMF_INSTANCE_VERSION, smf_inst.version))) {
Logger::amf_app().error(AMF_CONFIG_STRING_SMF_INSTANCE_VERSION
"failed");
throw(AMF_CONFIG_STRING_SMF_INSTANCE_VERSION "failed");
}
} else {
std::string smf_fqdn = {};
smf_addr_item.lookupValue(AMF_CONFIG_STRING_FQDN_DNS, smf_fqdn);
smf_inst.fqdn = smf_fqdn;
/*
uint8_t addr_type = 0;
fqdn::resolve(smf_fqdn, smf_inst.ipv4, smf_port, addr_type);
if (addr_type != 0) { // IPv6: TODO
throw("DO NOT SUPPORT IPV6 ADDR FOR SMF!");
} else { // IPv4
IPV4_STR_ADDR_TO_INADDR(
util::trim(smf_inst.ipv4).c_str(), smf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR SMF !");
smf_inst.port = std::to_string(smf_port);
smf_inst.version = "v1"; // TODO: get API version
}
*/
}
smf_addr_item.lookupValue( smf_addr_item.lookupValue(
AMF_CONFIG_STRING_SMF_INSTANCE_SELECTED, selected); AMF_CONFIG_STRING_SMF_INSTANCE_SELECTED, selected);
if (!selected.compare("true")) if (boost::iequals(selected, "true"))
smf_inst.selected = true; smf_inst.selected = true;
else else
smf_inst.selected = false; smf_inst.selected = false;
...@@ -248,35 +368,53 @@ int amf_config::load(const std::string& config_file) { ...@@ -248,35 +368,53 @@ int amf_config::load(const std::string& config_file) {
} }
// NRF // NRF
const Setting& nrf_cfg = new_if_cfg[AMF_CONFIG_STRING_NRF]; const Setting& nrf_cfg = new_if_cfg[AMF_CONFIG_STRING_NRF];
struct in_addr nrf_ipv4_addr; struct in_addr nrf_ipv4_addr = {};
unsigned int nrf_port = 0; unsigned int nrf_port = 0;
std::string nrf_api_version; std::string nrf_api_version = {};
string address; string address = {};
nrf_cfg.lookupValue(AMF_CONFIG_STRING_NRF_IPV4_ADDRESS, address);
IPV4_STR_ADDR_TO_INADDR( if (!use_fqdn_dns) {
util::trim(address).c_str(), nrf_ipv4_addr, nrf_cfg.lookupValue(AMF_CONFIG_STRING_NRF_IPV4_ADDRESS, address);
"BAD IPv4 ADDRESS FORMAT FOR NRF !"); IPV4_STR_ADDR_TO_INADDR(
nrf_addr.ipv4_addr = nrf_ipv4_addr; util::trim(address).c_str(), nrf_ipv4_addr,
if (!(nrf_cfg.lookupValue(AMF_CONFIG_STRING_NRF_PORT, nrf_port))) { "BAD IPv4 ADDRESS FORMAT FOR NRF !");
Logger::amf_app().error(AMF_CONFIG_STRING_NRF_PORT "failed"); nrf_addr.ipv4_addr = nrf_ipv4_addr;
throw(AMF_CONFIG_STRING_NRF_PORT "failed"); if (!(nrf_cfg.lookupValue(AMF_CONFIG_STRING_NRF_PORT, nrf_port))) {
} Logger::amf_app().error(AMF_CONFIG_STRING_NRF_PORT "failed");
nrf_addr.port = nrf_port; throw(AMF_CONFIG_STRING_NRF_PORT "failed");
}
if (!(nrf_cfg.lookupValue( nrf_addr.port = nrf_port;
AMF_CONFIG_STRING_API_VERSION, nrf_api_version))) { if (!(nrf_cfg.lookupValue(
Logger::amf_app().error(AMF_CONFIG_STRING_API_VERSION "failed"); AMF_CONFIG_STRING_API_VERSION, nrf_api_version))) {
throw(AMF_CONFIG_STRING_API_VERSION "failed"); Logger::amf_app().error(AMF_CONFIG_STRING_API_VERSION "failed");
throw(AMF_CONFIG_STRING_API_VERSION "failed");
}
nrf_addr.api_version = nrf_api_version;
} else {
std::string nrf_fqdn = {};
nrf_cfg.lookupValue(AMF_CONFIG_STRING_FQDN_DNS, nrf_fqdn);
uint8_t addr_type = {};
fqdn::resolve(nrf_fqdn, address, nrf_port, addr_type);
if (addr_type != 0) { // IPv6: TODO
throw("DO NOT SUPPORT IPV6 ADDR FOR NRF!");
} else { // IPv4
IPV4_STR_ADDR_TO_INADDR(
util::trim(address).c_str(), nrf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !");
nrf_addr.ipv4_addr = nrf_ipv4_addr;
nrf_addr.port = nrf_port;
nrf_addr.api_version = "v1"; // TODO: get API version
}
} }
nrf_addr.api_version = nrf_api_version;
// AUSF // AUSF
const Setting& ausf_cfg = new_if_cfg[AMF_CONFIG_STRING_AUSF]; // TODO: add FQDN option
struct in_addr ausf_ipv4_addr; const Setting& ausf_cfg = new_if_cfg[AMF_CONFIG_STRING_AUSF];
unsigned int ausf_port = 0; struct in_addr ausf_ipv4_addr = {};
std::string ausf_api_version; unsigned int ausf_port = {};
// string address; std::string ausf_api_version = {};
ausf_cfg.lookupValue(AMF_CONFIG_STRING_IPV4_ADDRESS, address); ausf_cfg.lookupValue(AMF_CONFIG_STRING_IPV4_ADDRESS, address);
IPV4_STR_ADDR_TO_INADDR( IPV4_STR_ADDR_TO_INADDR(
util::trim(address).c_str(), ausf_ipv4_addr, util::trim(address).c_str(), ausf_ipv4_addr,
...@@ -300,6 +438,8 @@ int amf_config::load(const std::string& config_file) { ...@@ -300,6 +438,8 @@ int amf_config::load(const std::string& config_file) {
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
return -1; return -1;
} }
// Emergency support
try { try {
const Setting& core_config = amf_cfg[AMF_CONFIG_STRING_CORE_CONFIGURATION]; const Setting& core_config = amf_cfg[AMF_CONFIG_STRING_CORE_CONFIGURATION];
core_config.lookupValue( core_config.lookupValue(
...@@ -309,6 +449,9 @@ int amf_config::load(const std::string& config_file) { ...@@ -309,6 +449,9 @@ int amf_config::load(const std::string& config_file) {
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
return -1; return -1;
} }
// Authentication Info
// TODO: remove operator_key, random
try { try {
const Setting& auth = amf_cfg[AMF_CONFIG_STRING_AUTHENTICATION]; const Setting& auth = amf_cfg[AMF_CONFIG_STRING_AUTHENTICATION];
auth.lookupValue( auth.lookupValue(
...@@ -324,6 +467,8 @@ int amf_config::load(const std::string& config_file) { ...@@ -324,6 +467,8 @@ int amf_config::load(const std::string& config_file) {
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
return -1; return -1;
} }
// Integrity/Ciphering algorithms (NAS)
try { try {
const Setting& nas = amf_cfg[AMF_CONFIG_STRING_NAS]; const Setting& nas = amf_cfg[AMF_CONFIG_STRING_NAS];
const Setting& intAlg = const Setting& intAlg =
...@@ -364,47 +509,6 @@ int amf_config::load(const std::string& config_file) { ...@@ -364,47 +509,6 @@ int amf_config::load(const std::string& config_file) {
return -1; return -1;
} }
try {
const Setting& support_features =
amf_cfg[AMF_CONFIG_STRING_SUPPORT_FEATURES];
string opt;
support_features.lookupValue(
AMF_CONFIG_STRING_SUPPORT_FEATURES_NF_REGISTRATION, opt);
if (boost::iequals(opt, "yes")) {
enable_nf_registration = true;
} else {
enable_nf_registration = false;
}
support_features.lookupValue(
AMF_CONFIG_STRING_SUPPORT_FEATURES_SMF_SELECTION, opt);
if (boost::iequals(opt, "yes")) {
enable_smf_selection = true;
} else {
enable_smf_selection = false;
}
support_features.lookupValue(
AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AUSF, opt);
if (boost::iequals(opt, "yes")) {
enable_external_ausf = true;
} else {
enable_external_ausf = false;
}
support_features.lookupValue(
AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_UDM, opt);
if (boost::iequals(opt, "yes")) {
enable_external_udm = true;
} else {
enable_external_udm = false;
}
} catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath());
return -1;
}
return 1; return 1;
} }
...@@ -453,53 +557,55 @@ void amf_config::display() { ...@@ -453,53 +557,55 @@ void amf_config::display() {
"- MySQL pass ..............: %s", auth_para.mysql_pass.c_str()); "- MySQL pass ..............: %s", auth_para.mysql_pass.c_str());
Logger::config().info( Logger::config().info(
"- MySQL DB ................: %s", auth_para.mysql_db.c_str()); "- MySQL DB ................: %s", auth_para.mysql_db.c_str());
Logger::config().info(
"- operator key ............: %s", auth_para.operator_key.c_str()); /* Logger::config().info(
Logger::config().info( "- operator key ............: %s", auth_para.operator_key.c_str());
"- random ..................: %s", auth_para.random.c_str()); Logger::config().info(
"- random ..................: %s", auth_para.random.c_str());
*/
Logger::config().info("- N2 Networking:"); Logger::config().info("- N2 Networking:");
Logger::config().info(" iface .................: %s", n2.if_name.c_str()); Logger::config().info(" Iface .................: %s", n2.if_name.c_str());
Logger::config().info(" ip ....................: %s", inet_ntoa(n2.addr4)); Logger::config().info(" IP Addr ...............: %s", inet_ntoa(n2.addr4));
Logger::config().info(" port ..................: %d", n2.port); Logger::config().info(" Port ..................: %d", n2.port);
Logger::config().info("- SBI Networking:"); Logger::config().info("- SBI Networking:");
Logger::config().info(" iface .................: %s", n11.if_name.c_str()); Logger::config().info(" Iface .................: %s", n11.if_name.c_str());
Logger::config().info( Logger::config().info(
" ip ....................: %s", inet_ntoa(n11.addr4)); " IP Addr ...............: %s", inet_ntoa(n11.addr4));
Logger::config().info(" port ..................: %d", n11.port); Logger::config().info(" Port ..................: %d", n11.port);
Logger::config().info( Logger::config().info(
" API version............: %s", sbi_api_version.c_str()); " API version............: %s", sbi_api_version.c_str());
if (enable_nf_registration or enable_smf_selection) { if (enable_nf_registration or enable_smf_selection) {
Logger::config().info("- NRF:"); Logger::config().info("- NRF:");
Logger::config().info( Logger::config().info(
" IP addr ...............: %s", inet_ntoa(nrf_addr.ipv4_addr)); " IP Addr ...............: %s", inet_ntoa(nrf_addr.ipv4_addr));
Logger::config().info(" Port ..................: %d", nrf_addr.port); Logger::config().info(" Port ..................: %d", nrf_addr.port);
Logger::config().info( Logger::config().info(
" Api version ...........: %s", nrf_addr.api_version.c_str()); " API version ...........: %s", nrf_addr.api_version.c_str());
} }
if (enable_external_ausf) { if (enable_external_ausf) {
Logger::config().info("- AUSF:"); Logger::config().info("- AUSF:");
Logger::config().info( Logger::config().info(
" IP addr ...............: %s", inet_ntoa(ausf_addr.ipv4_addr)); " IP Addr ...............: %s", inet_ntoa(ausf_addr.ipv4_addr));
Logger::config().info(" Port ..................: %d", ausf_addr.port); Logger::config().info(" Port ..................: %d", ausf_addr.port);
Logger::config().info( Logger::config().info(
" Api version ...........: %s", ausf_addr.api_version.c_str()); " API version ...........: %s", ausf_addr.api_version.c_str());
} }
Logger::config().info("- Remote SMF Pool.........: "); if (!enable_smf_selection) {
for (int i = 0; i < smf_pool.size(); i++) { Logger::config().info("- SMF Pool.........: ");
std::string selected; for (int i = 0; i < smf_pool.size(); i++) {
if (smf_pool[i].selected) std::string selected = smf_pool[i].selected ? "true" : "false";
selected = "true"; std::string smf_info =
else use_fqdn_dns ? smf_pool[i].fqdn : smf_pool[i].ipv4.c_str();
selected = "false"; Logger::config().info(
Logger::config().info( " SMF_INSTANCE_ID %d (%s:%s, version %s) is selected: %s",
" 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_pool[i].id, smf_pool[i].ipv4.c_str(), smf_pool[i].port.c_str(), smf_pool[i].version.c_str(), selected.c_str());
smf_pool[i].version.c_str(), selected.c_str()); }
} }
Logger::config().info("- Supported Features:"); Logger::config().info("- Supported Features:");
...@@ -511,6 +617,8 @@ void amf_config::display() { ...@@ -511,6 +617,8 @@ void amf_config::display() {
" External AUSF .........: %s", enable_external_ausf ? "Yes" : "No"); " External AUSF .........: %s", enable_external_ausf ? "Yes" : "No");
Logger::config().info( Logger::config().info(
" External UDM ..........: %s", enable_external_udm ? "Yes" : "No"); " External UDM ..........: %s", enable_external_udm ? "Yes" : "No");
Logger::config().info(
" Use FQDN ..............: %s", use_fqdn_dns ? "Yes" : "No");
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -104,6 +104,8 @@ ...@@ -104,6 +104,8 @@
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_SMF_SELECTION "SMF_SELECTION" #define AMF_CONFIG_STRING_SUPPORT_FEATURES_SMF_SELECTION "SMF_SELECTION"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AUSF "EXTERNAL_AUSF" #define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AUSF "EXTERNAL_AUSF"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_UDM "EXTERNAL_UDM" #define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_UDM "EXTERNAL_UDM"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS "USE_FQDN_DNS"
#define AMF_CONFIG_STRING_FQDN_DNS "FQDN"
using namespace libconfig; using namespace libconfig;
...@@ -166,6 +168,7 @@ typedef struct { ...@@ -166,6 +168,7 @@ typedef struct {
std::string port; std::string port;
std::string version; std::string version;
bool selected; bool selected;
std::string fqdn;
} smf_inst_t; } smf_inst_t;
class amf_config { class amf_config {
...@@ -196,6 +199,7 @@ class amf_config { ...@@ -196,6 +199,7 @@ class amf_config {
bool enable_smf_selection; bool enable_smf_selection;
bool enable_external_ausf; bool enable_external_ausf;
bool enable_external_udm; bool enable_external_udm;
bool use_fqdn_dns;
struct { struct {
struct in_addr ipv4_addr; struct in_addr ipv4_addr;
......
...@@ -439,7 +439,7 @@ void amf_n1::nas_signalling_establishment_request_handle( ...@@ -439,7 +439,7 @@ void amf_n1::nas_signalling_establishment_request_handle(
case SERVICE_REQUEST: { case SERVICE_REQUEST: {
Logger::amf_n1().debug("Received service request message, handling..."); Logger::amf_n1().debug("Received service request message, handling...");
nc.get()->security_ctx->ul_count.seq_num = ulCount; if (nc.get()) nc.get()->security_ctx->ul_count.seq_num = ulCount;
service_request_handle( service_request_handle(
true, nc, ran_ue_ngap_id, amf_ue_ngap_id, plain_msg); true, nc, ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break; } break;
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "SmContextCreateData.h" #include "SmContextCreateData.h"
#include "mime_parser.hpp" #include "mime_parser.hpp"
#include "ue_context.hpp" #include "ue_context.hpp"
#include "fqdn.hpp"
extern "C" { extern "C" {
#include "dynamic_memory_check.h" #include "dynamic_memory_check.h"
...@@ -127,6 +128,14 @@ void amf_n11_task(void*) { ...@@ -127,6 +128,14 @@ void amf_n11_task(void*) {
dynamic_cast<itti_pdu_session_resource_setup_response*>(msg); dynamic_cast<itti_pdu_session_resource_setup_response*>(msg);
amf_n11_inst->handle_itti_message(ref(*m)); amf_n11_inst->handle_itti_message(ref(*m));
} break; } break;
case N11_REGISTER_NF_INSTANCE_REQUEST: {
Logger::amf_n11().info(
"Receive Register NF Instance Request, handling ...");
itti_n11_register_nf_instance_request* m =
dynamic_cast<itti_n11_register_nf_instance_request*>(msg);
// TODO: Handle ITTI
} break;
default: { default: {
Logger::amf_n11().info( Logger::amf_n11().info(
"Receive unknown message type %d", msg->msg_type); "Receive unknown message type %d", msg->msg_type);
...@@ -464,8 +473,26 @@ bool amf_n11::smf_selection_from_configuration( ...@@ -464,8 +473,26 @@ bool amf_n11::smf_selection_from_configuration(
std::string& smf_addr, std::string& smf_api_version) { std::string& smf_addr, std::string& smf_api_version) {
for (int i = 0; i < amf_cfg.smf_pool.size(); i++) { for (int i = 0; i < amf_cfg.smf_pool.size(); i++) {
if (amf_cfg.smf_pool[i].selected) { if (amf_cfg.smf_pool[i].selected) {
smf_addr = amf_cfg.smf_pool[i].ipv4 + ":" + amf_cfg.smf_pool[i].port; if (!amf_cfg.use_fqdn_dns) {
smf_api_version = amf_cfg.smf_pool[i].version; smf_addr = amf_cfg.smf_pool[i].ipv4 + ":" + amf_cfg.smf_pool[i].port;
smf_api_version = amf_cfg.smf_pool[i].version;
return true;
} else {
// resolve IP addr from a FQDN/DNS name
uint8_t addr_type = 0;
uint32_t smf_port = 0;
fqdn::resolve(
amf_cfg.smf_pool[i].fqdn, amf_cfg.smf_pool[i].ipv4, smf_port,
addr_type);
if (addr_type != 0) { // IPv6: TODO
Logger::amf_n11().warn("Do not support IPv6 Addr for SMF");
return false;
} else { // IPv4
smf_addr = amf_cfg.smf_pool[i].ipv4 + ":" + std::to_string(smf_port);
smf_api_version = "v1"; // TODO: get API version
return true;
}
}
return true; return true;
} }
} }
...@@ -816,6 +843,80 @@ bool amf_n11::discover_smf( ...@@ -816,6 +843,80 @@ bool amf_n11::discover_smf(
return result; return result;
} }
//-----------------------------------------------------------------------------------------------------
void amf_n11::register_nf_instance(
std::shared_ptr<itti_n11_register_nf_instance_request> msg) {
Logger::amf_n11().debug(
"Send NF Instance Registration to NRF (HTTP version %d)",
msg->http_version);
nlohmann::json json_data = {};
msg->profile.to_json(json_data);
std::string url =
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.nrf_addr.ipv4_addr))) +
":" + std::to_string(amf_cfg.nrf_addr.port) + "/nnrf-nfm/" +
amf_cfg.nrf_addr.api_version + "/nf-instances/" +
msg->profile.get_nf_instance_id();
Logger::amf_n11().debug(
"Send NF Instance Registration to NRF, NRF URL %s", url.c_str());
std::string body = json_data.dump();
Logger::amf_n11().debug(
"Send NF Instance Registration to NRF, msg body: \n %s", body.c_str());
curl_global_init(CURL_GLOBAL_ALL);
CURL* curl = curl = curl_easy_init();
if (curl) {
CURLcode res = {};
struct curl_slist* headers = nullptr;
// headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, NRF_CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str());
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
// Response information.
long httpCode = {0};
std::unique_ptr<std::string> httpData(new std::string());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, body.length());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
Logger::amf_n11().debug(
"NFDiscovery, response from NRF, HTTP Code: %d", httpCode);
if (httpCode == 200) {
Logger::amf_n11().debug(
"NFRegistration, got successful response from NRF");
nlohmann::json response_data = {};
try {
response_data = nlohmann::json::parse(*httpData.get());
} catch (nlohmann::json::exception& e) {
Logger::amf_n11().warn(
"NFDiscovery, could not parse json from the NRF "
"response");
}
Logger::amf_n11().debug(
"NFDiscovery, response from NRF, json data: \n %s",
response_data.dump().c_str());
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
}
}
//----------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------
bool amf_n11::send_ue_authentication_request( bool amf_n11::send_ue_authentication_request(
oai::amf::model::AuthenticationInfo& auth_info, oai::amf::model::AuthenticationInfo& auth_info,
......
...@@ -75,7 +75,8 @@ class amf_n11 { ...@@ -75,7 +75,8 @@ class amf_n11 {
bool discover_smf( bool discover_smf(
std::string& smf_addr, std::string& smf_api_version, std::string& smf_addr, std::string& smf_api_version,
const snssai_t snssai, const plmn_t plmn, const std::string dnn); const snssai_t snssai, const plmn_t plmn, const std::string dnn);
void register_nf_instance(
std::shared_ptr<itti_n11_register_nf_instance_request> msg);
bool send_ue_authentication_request( bool send_ue_authentication_request(
oai::amf::model::AuthenticationInfo& auth_info, oai::amf::model::AuthenticationInfo& auth_info,
oai::amf::model::UEAuthenticationCtx& ue_auth_ctx, uint8_t http_version); oai::amf::model::UEAuthenticationCtx& ue_auth_ctx, uint8_t http_version);
......
...@@ -371,11 +371,9 @@ void amf_profile::to_json(nlohmann::json& data) const { ...@@ -371,11 +371,9 @@ void amf_profile::to_json(nlohmann::json& data) const {
for (auto endpoint : service.ip_endpoints) { for (auto endpoint : service.ip_endpoints) {
nlohmann::json ep_tmp = {}; nlohmann::json ep_tmp = {};
ep_tmp["ipv4Address"] = nlohmann::json::array(); ep_tmp["ipv4Address"] = nlohmann::json::array();
for (auto address : endpoint.ipv4_addresses) { ep_tmp["ipv4Address"] = inet_ntoa(endpoint.ipv4_address);
ep_tmp["ipv4Address"].push_back(inet_ntoa(address)); ep_tmp["transport"] = endpoint.transport;
} ep_tmp["port"] = endpoint.port;
ep_tmp["transport"] = endpoint.transport;
ep_tmp["port"] = endpoint.port;
srv_tmp["ipEndPoints"].push_back(ep_tmp); srv_tmp["ipEndPoints"].push_back(ep_tmp);
} }
......
...@@ -276,16 +276,14 @@ typedef struct nf_service_version_s { ...@@ -276,16 +276,14 @@ typedef struct nf_service_version_s {
} nf_service_version_t; } nf_service_version_t;
typedef struct ip_endpoint_s { typedef struct ip_endpoint_s {
std::vector<struct in_addr> ipv4_addresses; struct in_addr ipv4_address;
// std::vector<struct in6_addr> ipv6_addresses; // struct in6_addr ipv6_address;
std::string transport; // TCP std::string transport; // TCP
unsigned int port; unsigned int port;
std::string to_string() const { std::string to_string() const {
std::string s = {}; std::string s = {};
s.append("Ipv4 Addresses: "); s.append("Ipv4 Address: ");
for (auto ipv4 : ipv4_addresses) { s.append(inet_ntoa(ipv4_address));
s.append(inet_ntoa(ipv4));
}
s.append(", TransportProtocol: "); s.append(", TransportProtocol: ");
s.append(transport); s.append(transport);
s.append(", Port: "); s.append(", Port: ");
......
...@@ -35,5 +35,6 @@ add_library (AMF_UTILS STATIC ...@@ -35,5 +35,6 @@ add_library (AMF_UTILS STATIC
${CMAKE_CURRENT_SOURCE_DIR}/string.cpp ${CMAKE_CURRENT_SOURCE_DIR}/string.cpp
${CMAKE_CURRENT_SOURCE_DIR}/thread_sched.cpp ${CMAKE_CURRENT_SOURCE_DIR}/thread_sched.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mime_parser.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mime_parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/fqdn.cpp
) )
/*
* 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 "fqdn.hpp"
#include "logger.hpp"
#include <boost/asio.hpp>
#include <iostream>
bool fqdn::resolve(
const std::string& host_name, std::string& address, uint32_t& port,
uint8_t& addr_type, const std::string& protocol) {
try {
boost::asio::io_context io_context = {};
boost::asio::ip::tcp::resolver resolver{io_context};
boost::asio::ip::tcp::resolver::results_type endpoints =
resolver.resolve(host_name, protocol);
addr_type = 0; // IPv4 by default
for (auto it = endpoints.cbegin(); it != endpoints.cend(); it++) {
// get the first Endpoint
boost::asio::ip::tcp::endpoint endpoint = *it;
address = endpoint.address().to_string();
port = endpoint.port();
Logger::amf_app().debug(
"Resolve a DNS (name %s, protocol %s): Ip Addr %s, port %u",
host_name.c_str(), protocol.c_str(), address.c_str(), port);
if (endpoint.address().is_v4())
addr_type = 0;
else
addr_type = 1;
return true;
}
} catch (std::exception& e) {
throw std::runtime_error(
"Cannot resolve a DNS name " + std::string(e.what()));
return false;
}
return false;
}
/*
* 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
*/
/*! \file fqdn.hpp
\brief
\author
\company Eurecom
\email:
*/
#ifndef FILE_FQDN_HPP_SEEN
#define FILE_FQDN_HPP_SEEN
#include <string>
class fqdn {
public:
/*
* Resolve a DNS name to get host's IP Addr
* @param [const std::string &] host_name: host's name/url
* @param [const std::string &] protocol: protocol
* @param [uint8_t &] addr_type: addr_type (Ipv4/v6)
* @return void
*/
static bool resolve(
const std::string& host_name, std::string& address, uint32_t& port,
uint8_t& addr_type, const std::string& protocol = "http");
};
#endif /* FILE_FQDN_HPP_SEEN */
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