Commit 7e3ffb6b authored by Raphael Defosseux's avatar Raphael Defosseux
Browse files

Merge branch 'fqdn_dns' into 'develop'

FQDN DNS

See merge request !69
parents d01bad06 e8cb6e5e
...@@ -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 ;;
......
...@@ -69,6 +69,7 @@ install_fb_folly_from_source(){ ...@@ -69,6 +69,7 @@ install_fb_folly_from_source(){
$SUDO $INSTALLER install $OPTION \ $SUDO $INSTALLER install $OPTION \
g++ \ g++ \
libevent-dev \ libevent-dev \
libboost1.67-dev \
libdouble-conversion-dev \ libdouble-conversion-dev \
libgoogle-glog-dev \ libgoogle-glog-dev \
libgflags-dev \ libgflags-dev \
......
...@@ -293,6 +293,8 @@ install_nghttp2_from_git() { ...@@ -293,6 +293,8 @@ install_nghttp2_from_git() {
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO make install $SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO ldconfig
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd popd
fi fi
echo "nghttp2 installation complete" echo "nghttp2 installation complete"
...@@ -345,6 +347,7 @@ check_install_smf_deps() { ...@@ -345,6 +347,7 @@ check_install_smf_deps() {
doxygen \ doxygen \
flex \ flex \
gdb \ gdb \
wget \
git" git"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\ PACKAGE_LIST="\
...@@ -367,12 +370,21 @@ check_install_smf_deps() { ...@@ -367,12 +370,21 @@ check_install_smf_deps() {
if [[ $OS_DISTRO == "ubuntu" ]]; then if [[ $OS_DISTRO == "ubuntu" ]]; then
case "$(get_distribution_release)" in case "$(get_distribution_release)" in
"ubuntu18.04") "ubuntu18.04")
specific_packages="libconfig++-dev libasio-dev libboost-all-dev" # 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
specific_packages="libconfig++-dev"
;; ;;
*)
specific_packages="libconfig++-dev libasio-dev libboost-all-dev"
;;
esac esac
# removed libspdlog-dev # removed libspdlog-dev
PACKAGE_LIST="\ PACKAGE_LIST="\
$specific_packages \ $specific_packages \
libboost1.67-dev \
guile-2.0-dev \ guile-2.0-dev \
libcurl4-gnutls-dev \ libcurl4-gnutls-dev \
libevent-dev \ libevent-dev \
...@@ -392,6 +404,7 @@ check_install_smf_deps() { ...@@ -392,6 +404,7 @@ check_install_smf_deps() {
libcurl4 \ libcurl4 \
net-tools \ net-tools \
pkg-config \ pkg-config \
wget \
libasan2" libasan2"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\ PACKAGE_LIST="\
......
...@@ -12,26 +12,33 @@ SMF_CONF[@INSTANCE@]=$INSTANCE ...@@ -12,26 +12,33 @@ SMF_CONF[@INSTANCE@]=$INSTANCE
SMF_CONF[@PREFIX@]=$PREFIX SMF_CONF[@PREFIX@]=$PREFIX
SMF_CONF[@PID_DIRECTORY@]='/var/run' SMF_CONF[@PID_DIRECTORY@]='/var/run'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_N4@]='enx0050b6f4b8f0' SMF_CONF[@SMF_INTERFACE_NAME_FOR_N4@]='wlo1'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_SBI@]='enx0050b6f4b8f0' SMF_CONF[@SMF_INTERFACE_NAME_FOR_SBI@]='wlo1'
SMF_CONF[@SMF_INTERFACE_PORT_FOR_SBI@]='80' SMF_CONF[@SMF_INTERFACE_PORT_FOR_SBI@]='80'
SMF_CONF[@SMF_INTERFACE_HTTP2_PORT_FOR_SBI@]='9090' SMF_CONF[@SMF_INTERFACE_HTTP2_PORT_FOR_SBI@]='9090'
SMF_CONF[@SMF_API_VERSION@]='v1' SMF_CONF[@SMF_API_VERSION@]='v1'
SMF_CONF[@REGISTER_NRF@]='no'
SMF_CONF[@DISCOVER_UPF@]='no'
SMF_CONF[@UDM_IPV4_ADDRESS@]='172.16.1.103' SMF_CONF[@UDM_IPV4_ADDRESS@]='172.16.1.103'
SMF_CONF[@UDM_PORT@]='80' SMF_CONF[@UDM_PORT@]='80'
SMF_CONF[@UDM_API_VERSION@]='v2' SMF_CONF[@UDM_API_VERSION@]='v2'
SMF_CONF[@UDM_FQDN@]='localhost'
SMF_CONF[@AMF_IPV4_ADDRESS@]='192.168.122.183' SMF_CONF[@AMF_IPV4_ADDRESS@]='192.168.122.183'
SMF_CONF[@AMF_PORT@]='80' SMF_CONF[@AMF_PORT@]='80'
SMF_CONF[@AMF_API_VERSION@]='v1' SMF_CONF[@AMF_API_VERSION@]='v1'
SMF_CONF[@AMF_FQDN@]='localhost'
SMF_CONF[@UPF_IPV4_ADDRESS@]='192.168.12.245' SMF_CONF[@UPF_IPV4_ADDRESS@]='192.168.12.245'
SMF_CONF[@UPF_FQDN@]='localhost'
SMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.1.23' SMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.1.23'
SMF_CONF[@NRF_PORT@]='8080' SMF_CONF[@NRF_PORT@]='8080'
SMF_CONF[@NRF_API_VERSION@]='v1' SMF_CONF[@NRF_API_VERSION@]='v1'
SMF_CONF[@NRF_FQDN@]='localhost'
SMF_CONF[@DEFAULT_DNS_IPV4_ADDRESS@]='8.8.8.8' SMF_CONF[@DEFAULT_DNS_IPV4_ADDRESS@]='8.8.8.8'
SMF_CONF[@DEFAULT_DNS_SEC_IPV4_ADDRESS@]='4.4.4.4' SMF_CONF[@DEFAULT_DNS_SEC_IPV4_ADDRESS@]='4.4.4.4'
......
...@@ -48,28 +48,35 @@ ENV TZ=Europe/Paris ...@@ -48,28 +48,35 @@ ENV TZ=Europe/Paris
RUN apt-get update && \ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \ psmisc \
net-tools \ net-tools \
tzdata \ tzdata \
bc \ bc \
tshark \ tshark \
libasan4 \ perl \
libgoogle-glog0v5 \ openssl \
libdouble-conversion1 \ libasan4 \
libconfig++9v5 \ libldap-2.4-2 \
libcurl4-gnutls-dev \ libgoogle-glog0v5 \
libdouble-conversion1 \
libconfig++9v5 \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Copying executable and generated libraries # Copying executable and generated libraries
WORKDIR /openair-smf/bin WORKDIR /openair-smf/bin
COPY --from=oai-smf-builder /openair-smf/build/smf/build/smf oai_smf COPY --from=oai-smf-builder /openair-smf/build/smf/build/smf oai_smf
COPY --from=oai-smf-builder /openair-smf/scripts/entrypoint.sh entrypoint.sh COPY --from=oai-smf-builder /openair-smf/scripts/entrypoint.sh .
COPY --from=oai-smf-builder /usr/local/lib/libpistache.so /usr/local/lib/
COPY --from=oai-smf-builder /usr/local/lib/libnghttp2_asio.so.1 /usr/local/lib/ WORKDIR /usr/local/lib/
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 /usr/lib/x86_64-linux-gnu/ COPY --from=oai-smf-builder /usr/local/lib/libpistache.so .
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 /usr/lib/x86_64-linux-gnu/ COPY --from=oai-smf-builder /usr/local/lib/libnghttp2_asio.so.1 .
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/libboost_chrono.so.1.65.1 /usr/lib/x86_64-linux-gnu/ COPY --from=oai-smf-builder /usr/lib/libboost_system.so.1.67.0 .
COPY --from=oai-smf-builder /openair-smf/build/smf/build/nas/libNAS.so /usr/local/lib/ COPY --from=oai-smf-builder /usr/lib/libboost_thread.so.1.67.0 .
COPY --from=oai-smf-builder /usr/lib/libboost_chrono.so.1.67.0 .
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 .
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 .
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 .
COPY --from=oai-smf-builder /openair-smf/build/smf/build/nas/libNAS.so .
RUN ldconfig RUN ldconfig
# Copying template configuration files # Copying template configuration files
...@@ -82,5 +89,4 @@ WORKDIR /openair-smf ...@@ -82,5 +89,4 @@ WORKDIR /openair-smf
EXPOSE 80/tcp 9090/tcp 8805/udp EXPOSE 80/tcp 9090/tcp 8805/udp
ENTRYPOINT ["/bin/bash","/openair-smf/bin/entrypoint.sh"] ENTRYPOINT ["/bin/bash","/openair-smf/bin/entrypoint.sh"]
CMD ["/openair-smf/bin/oai_smf", "-c", "/openair-smf/etc/smf.conf", "-o"] CMD ["/openair-smf/bin/oai_smf", "-c", "/openair-smf/etc/smf.conf", "-o"]
...@@ -34,15 +34,19 @@ ARG NEEDED_GIT_PROXY ...@@ -34,15 +34,19 @@ ARG NEEDED_GIT_PROXY
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && DEBIAN_FRONTEND=noninteractive apt-get install --yes \ RUN apt-get update && \
psmisc \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
git \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \
&& rm -rf /var/lib/apt/lists/* psmisc \
software-properties-common \
gnupg \
git && \
rm -rf /var/lib/apt/lists/*
# Some GIT configuration command quite useful # Some GIT configuration command quite useful
RUN /bin/bash -c "if [[ -v NEEDED_GIT_PROXY ]]; then git config --global http.proxy $NEEDED_GIT_PROXY; fi" RUN /bin/bash -c "if [[ -v NEEDED_GIT_PROXY ]]; then git config --global http.proxy $NEEDED_GIT_PROXY; fi" && \
RUN git config --global https.postBuffer 123289600 git config --global https.postBuffer 123289600 && \
RUN git config --global http.sslverify false git config --global http.sslverify false
# Copying source code # Copying source code
WORKDIR /openair-smf WORKDIR /openair-smf
...@@ -60,29 +64,38 @@ FROM ubuntu:bionic as oai-smf ...@@ -60,29 +64,38 @@ FROM ubuntu:bionic as oai-smf
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris ENV TZ=Europe/Paris
# 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 && \
psmisc \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
net-tools \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \
tzdata \ psmisc \
bc \ net-tools \
tshark \ tzdata \
libasan4 \ bc \
libgoogle-glog0v5 \ tshark \
libdouble-conversion1 \ perl \
libconfig++9v5 \ openssl \
libcurl4-gnutls-dev \ libasan4 \
&& rm -rf /var/lib/apt/lists/* libldap-2.4-2 \
libgoogle-glog0v5 \
libdouble-conversion1 \
libconfig++9v5 \
&& rm -rf /var/lib/apt/lists/*
# Copying executable and generated libraries # Copying executable and generated libraries
WORKDIR /openair-smf/bin WORKDIR /openair-smf/bin
COPY --from=oai-smf-builder /openair-smf/build/smf/build/smf oai_smf COPY --from=oai-smf-builder /openair-smf/build/smf/build/smf oai_smf
COPY --from=oai-smf-builder /openair-smf/scripts/entrypoint.sh entrypoint.sh COPY --from=oai-smf-builder /openair-smf/scripts/entrypoint.sh .
COPY --from=oai-smf-builder /usr/local/lib/libpistache.so /usr/local/lib/
COPY --from=oai-smf-builder /usr/local/lib/libnghttp2_asio.so.1 /usr/local/lib/ WORKDIR /usr/local/lib/
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 /usr/lib/x86_64-linux-gnu/ COPY --from=oai-smf-builder /usr/local/lib/libpistache.so .
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 /usr/lib/x86_64-linux-gnu/ COPY --from=oai-smf-builder /usr/local/lib/libnghttp2_asio.so.1 .
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/libboost_chrono.so.1.65.1 /usr/lib/x86_64-linux-gnu/ COPY --from=oai-smf-builder /usr/lib/libboost_system.so.1.67.0 .
COPY --from=oai-smf-builder /openair-smf/build/smf/build/nas/libNAS.so /usr/local/lib/ COPY --from=oai-smf-builder /usr/lib/libboost_thread.so.1.67.0 .
COPY --from=oai-smf-builder /usr/lib/libboost_chrono.so.1.67.0 .
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 .
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 .
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 .
COPY --from=oai-smf-builder /openair-smf/build/smf/build/nas/libNAS.so .
RUN ldconfig RUN ldconfig
# Copying template configuration files # Copying template configuration files
...@@ -95,5 +108,4 @@ WORKDIR /openair-smf ...@@ -95,5 +108,4 @@ WORKDIR /openair-smf
EXPOSE 80/tcp 9090/tcp 8805/udp EXPOSE 80/tcp 9090/tcp 8805/udp
ENTRYPOINT ["/bin/bash","/openair-smf/bin/entrypoint.sh"] ENTRYPOINT ["/bin/bash","/openair-smf/bin/entrypoint.sh"]
CMD ["/openair-smf/bin/oai_smf", "-c", "/openair-smf/etc/smf.conf", "-o"] CMD ["/openair-smf/bin/oai_smf", "-c", "/openair-smf/etc/smf.conf", "-o"]
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
SMF = SMF =
{ {
FQDN = "oai-smf-svc";
INSTANCE = @INSTANCE@; # 0 is the default INSTANCE = @INSTANCE@; # 0 is the default
PID_DIRECTORY = "@PID_DIRECTORY@"; # /var/run is the default PID_DIRECTORY = "@PID_DIRECTORY@"; # /var/run is the default
...@@ -85,6 +86,7 @@ SMF = ...@@ -85,6 +86,7 @@ SMF =
FORCE_PUSH_PROTOCOL_CONFIGURATION_OPTIONS = "no"; # Non standard feature, normally should be set to "no", FORCE_PUSH_PROTOCOL_CONFIGURATION_OPTIONS = "no"; # Non standard feature, normally should be set to "no",
# but you may need to set to yes for UE that do not explicitly request a PDN address through NAS signalling # but you may need to set to yes for UE that do not explicitly request a PDN address through NAS signalling
USE_LOCAL_SUBSCRIPTION_INFO = "yes"; # Set to yes if SMF uses local subscription information instead of from an UDM USE_LOCAL_SUBSCRIPTION_INFO = "yes"; # Set to yes if SMF uses local subscription information instead of from an UDM
USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if AMF/UDM/NRF/UPF will relying on a DNS to resolve FQDN
} }
AMF : AMF :
...@@ -92,6 +94,7 @@ SMF = ...@@ -92,6 +94,7 @@ SMF =
IPV4_ADDRESS = "@AMF_IPV4_ADDRESS@"; # YOUR AMF CONFIG HERE IPV4_ADDRESS = "@AMF_IPV4_ADDRESS@"; # YOUR AMF CONFIG HERE
PORT = @AMF_PORT@; # YOUR AMF CONFIG HERE (default: 80) PORT = @AMF_PORT@; # YOUR AMF CONFIG HERE (default: 80)
API_VERSION = "@AMF_API_VERSION@"; # YOUR AMF API VERSION FOR SBI CONFIG HERE API_VERSION = "@AMF_API_VERSION@"; # YOUR AMF API VERSION FOR SBI CONFIG HERE
FQDN = "@AMF_FQDN@" # YOUR AMF FQDN CONFIG HERE
}; };
UDM : UDM :
...@@ -99,6 +102,7 @@ SMF = ...@@ -99,6 +102,7 @@ SMF =
IPV4_ADDRESS = "@UDM_IPV4_ADDRESS@"; # YOUR UDM CONFIG HERE IPV4_ADDRESS = "@UDM_IPV4_ADDRESS@"; # YOUR UDM CONFIG HERE
PORT = @UDM_PORT@; # YOUR UDM CONFIG HERE (default: 80) PORT = @UDM_PORT@; # YOUR UDM CONFIG HERE (default: 80)
API_VERSION = "@UDM_API_VERSION@"; # YOUR UDM API VERSION FOR SBI CONFIG HERE API_VERSION = "@UDM_API_VERSION@"; # YOUR UDM API VERSION FOR SBI CONFIG HERE
FQDN = "@UDM_FQDN@" # YOUR UDM FQDN CONFIG HERE
}; };
NRF : NRF :
...@@ -106,10 +110,11 @@ SMF = ...@@ -106,10 +110,11 @@ SMF =
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@" # YOUR NRF FQDN CONFIG HERE
}; };
UPF_LIST = ( UPF_LIST = (
{IPV4_ADDRESS = "@UPF_IPV4_ADDRESS@" ;} # YOUR UPF CONFIG HERE {IPV4_ADDRESS = "@UPF_IPV4_ADDRESS@" ; FQDN = "@UPF_FQDN_0@"} # YOUR UPF CONFIG HERE
); );
LOCAL_CONFIGURATION : LOCAL_CONFIGURATION :
......
...@@ -48,6 +48,7 @@ set(CN_UTILS_SRC STATIC ...@@ -48,6 +48,7 @@ set(CN_UTILS_SRC 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
) )
add_library(CN_UTILS ${CN_UTILS_SRC}) add_library(CN_UTILS ${CN_UTILS_SRC})
\ No newline at end of file
/*
* 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::smf_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 */
...@@ -147,6 +147,9 @@ int main(int argc, char** argv) { ...@@ -147,6 +147,9 @@ int main(int argc, char** argv) {
// smf_api_server_2->start(); // smf_api_server_2->start();
std::thread smf_http2_manager(&smf_http2_server::start, smf_api_server_2); std::thread smf_http2_manager(&smf_http2_server::start, smf_api_server_2);
// Register to NRF and discover appropriate UPFs
smf_app_inst->start_nf_registration_discovery();
smf_http1_manager.join(); smf_http1_manager.join();
smf_http2_manager.join(); smf_http2_manager.join();
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include "smf_n4.hpp" #include "smf_n4.hpp"
#include "smf_paa_dynamic.hpp" #include "smf_paa_dynamic.hpp"
#include "string.hpp" #include "string.hpp"
#include "fqdn.hpp"
extern "C" { extern "C" {
#include "dynamic_memory_check.h" #include "dynamic_memory_check.h"
...@@ -340,17 +341,30 @@ smf_app::smf_app(const std::string& config_file) ...@@ -340,17 +341,30 @@ smf_app::smf_app(const std::string& config_file)
throw; throw;
} }
// TODO: should be done when SMF select UPF for a particular UE (should be Logger::smf_app().startup("Started");
// verified) }
for (std::vector<pfcp::node_id_t>::const_iterator it = smf_cfg.upfs.begin();
it != smf_cfg.upfs.end(); ++it) { //------------------------------------------------------------------------------
start_upf_association(*it); smf_app::~smf_app() {
} Logger::smf_app().debug("Delete SMF_APP instance...");
// TODO: Unregister NRF
if (smf_n4_inst) delete smf_n4_inst;
if (smf_sbi_inst) delete smf_sbi_inst;
}
//------------------------------------------------------------------------------
void smf_app::start_nf_registration_discovery() {
if (smf_cfg.discover_upf) { if (smf_cfg.discover_upf) {
// Trigger NFStatusNotify subscription to be noticed when a new UPF becomes // Trigger NFStatusNotify subscription to be noticed when a new UPF becomes
// available (if this option is enabled) // available (if this option is enabled)
trigger_upf_status_notification_subscribe(); trigger_upf_status_notification_subscribe();
} else {
// TODO: should be done when SMF select UPF for a particular UE (should be
// verified)
for (std::vector<pfcp::node_id_t>::const_iterator it = smf_cfg.upfs.begin();
it != smf_cfg.upfs.end(); ++it) {
start_upf_association(*it);
}
} }
// Register to NRF (if this option is enabled) // Register to NRF (if this option is enabled)
...@@ -359,17 +373,8 @@ smf_app::smf_app(const std::string& config_file) ...@@ -359,17 +373,8 @@ smf_app::smf_app(const std::string& config_file)
usleep(microsecond); usleep(microsecond);
register_to_nrf(); register_to_nrf();
} }
Logger::smf_app().startup("Started");
} }
//------------------------------------------------------------------------------
smf_app::~smf_app() {
Logger::smf_app().debug("Delete SMF_APP instance...");
// TODO: Unregister NRF
if (smf_n4_inst) delete smf_n4_inst;
if (smf_sbi_inst) delete smf_sbi_inst;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void smf_app::start_upf_association(const pfcp::node_id_t& node_id) { void smf_app::start_upf_association(const pfcp::node_id_t& node_id) {
std::time_t time_epoch = std::time(nullptr); std::time_t time_epoch = std::time(nullptr);
...@@ -441,8 +446,17 @@ void smf_app::start_upf_association( ...@@ -441,8 +446,17 @@ void smf_app::start_upf_association(
"Could not send ITTI message %s to task TASK_SMF_N4", "Could not send ITTI message %s to task TASK_SMF_N4",
n4_asc.get()->get_msg_name()); n4_asc.get()->get_msg_name());
} }
} else if (node_id.node_id_type == pfcp::NODE_ID_TYPE_FQDN) {
n4_asc->r_endpoint =
endpoint(node_id.u1.ipv4_address, pfcp::default_port);
int ret = itti_inst->send_msg(n4_asc);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N4",
n4_asc.get()->get_msg_name());
}
} else { } else {
Logger::smf_app().warn("Start_association() node_id IPV6, FQDN!"); Logger::smf_app().warn("Start_association() node_id IPV6!");
} }
} }
} }
...@@ -1296,39 +1310,92 @@ bool smf_app::handle_nf_status_notification( ...@@ -1296,39 +1310,92 @@ bool smf_app::handle_nf_status_notification(
upf_info); upf_info);
// Verify if the UPF is already exist