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());
} }
*/
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
This diff is collapsed.
...@@ -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