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() {
local distribution=$(get_distribution_release)
case "$distribution" in
"ubuntu18.04") return 0 ;;
"ubuntu20.04") return 0 ;;
"rhel8") return 0 ;;
"rhel8.2") return 0 ;;
"rhel8.3") return 0 ;;
......
......@@ -69,6 +69,7 @@ install_fb_folly_from_source(){
$SUDO $INSTALLER install $OPTION \
g++ \
libevent-dev \
libboost1.67-dev \
libdouble-conversion-dev \
libgoogle-glog-dev \
libgflags-dev \
......
......@@ -293,6 +293,8 @@ install_nghttp2_from_git() {
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO ldconfig
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd
fi
echo "nghttp2 installation complete"
......@@ -345,6 +347,7 @@ check_install_smf_deps() {
doxygen \
flex \
gdb \
wget \
git"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\
......@@ -367,12 +370,21 @@ check_install_smf_deps() {
if [[ $OS_DISTRO == "ubuntu" ]]; then
case "$(get_distribution_release)" in
"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
# removed libspdlog-dev
PACKAGE_LIST="\
$specific_packages \
libboost1.67-dev \
guile-2.0-dev \
libcurl4-gnutls-dev \
libevent-dev \
......@@ -392,6 +404,7 @@ check_install_smf_deps() {
libcurl4 \
net-tools \
pkg-config \
wget \
libasan2"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\
......
......@@ -12,26 +12,33 @@ SMF_CONF[@INSTANCE@]=$INSTANCE
SMF_CONF[@PREFIX@]=$PREFIX
SMF_CONF[@PID_DIRECTORY@]='/var/run'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_N4@]='enx0050b6f4b8f0'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_SBI@]='enx0050b6f4b8f0'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_N4@]='wlo1'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_SBI@]='wlo1'
SMF_CONF[@SMF_INTERFACE_PORT_FOR_SBI@]='80'
SMF_CONF[@SMF_INTERFACE_HTTP2_PORT_FOR_SBI@]='9090'
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_PORT@]='80'
SMF_CONF[@UDM_API_VERSION@]='v2'
SMF_CONF[@UDM_FQDN@]='localhost'
SMF_CONF[@AMF_IPV4_ADDRESS@]='192.168.122.183'
SMF_CONF[@AMF_PORT@]='80'
SMF_CONF[@AMF_API_VERSION@]='v1'
SMF_CONF[@AMF_FQDN@]='localhost'
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_PORT@]='8080'
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_SEC_IPV4_ADDRESS@]='4.4.4.4'
......
......@@ -48,28 +48,35 @@ ENV TZ=Europe/Paris
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \
net-tools \
tzdata \
bc \
tshark \
libasan4 \
libgoogle-glog0v5 \
libdouble-conversion1 \
libconfig++9v5 \
libcurl4-gnutls-dev \
psmisc \
net-tools \
tzdata \
bc \
tshark \
perl \
openssl \
libasan4 \
libldap-2.4-2 \
libgoogle-glog0v5 \
libdouble-conversion1 \
libconfig++9v5 \
&& rm -rf /var/lib/apt/lists/*
# Copying executable and generated libraries
WORKDIR /openair-smf/bin
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 /usr/local/lib/libpistache.so /usr/local/lib/
COPY --from=oai-smf-builder /usr/local/lib/libnghttp2_asio.so.1 /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/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 /usr/lib/x86_64-linux-gnu/
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 /openair-smf/build/smf/build/nas/libNAS.so /usr/local/lib/
COPY --from=oai-smf-builder /openair-smf/scripts/entrypoint.sh .
WORKDIR /usr/local/lib/
COPY --from=oai-smf-builder /usr/local/lib/libpistache.so .
COPY --from=oai-smf-builder /usr/local/lib/libnghttp2_asio.so.1 .
COPY --from=oai-smf-builder /usr/lib/libboost_system.so.1.67.0 .
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
# Copying template configuration files
......@@ -82,5 +89,4 @@ WORKDIR /openair-smf
EXPOSE 80/tcp 9090/tcp 8805/udp
ENTRYPOINT ["/bin/bash","/openair-smf/bin/entrypoint.sh"]
CMD ["/openair-smf/bin/oai_smf", "-c", "/openair-smf/etc/smf.conf", "-o"]
......@@ -34,15 +34,19 @@ ARG NEEDED_GIT_PROXY
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \
git \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \
software-properties-common \
gnupg \
git && \
rm -rf /var/lib/apt/lists/*
# 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 git config --global https.postBuffer 123289600
RUN git config --global http.sslverify false
RUN /bin/bash -c "if [[ -v NEEDED_GIT_PROXY ]]; then git config --global http.proxy $NEEDED_GIT_PROXY; fi" && \
git config --global https.postBuffer 123289600 && \
git config --global http.sslverify false
# Copying source code
WORKDIR /openair-smf
......@@ -60,29 +64,38 @@ FROM ubuntu:bionic as oai-smf
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris
# 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 \
psmisc \
net-tools \
tzdata \
bc \
tshark \
libasan4 \
libgoogle-glog0v5 \
libdouble-conversion1 \
libconfig++9v5 \
libcurl4-gnutls-dev \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \
net-tools \
tzdata \
bc \
tshark \
perl \
openssl \
libasan4 \
libldap-2.4-2 \
libgoogle-glog0v5 \
libdouble-conversion1 \
libconfig++9v5 \
&& rm -rf /var/lib/apt/lists/*
# Copying executable and generated libraries
WORKDIR /openair-smf/bin
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 /usr/local/lib/libpistache.so /usr/local/lib/
COPY --from=oai-smf-builder /usr/local/lib/libnghttp2_asio.so.1 /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/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 /usr/lib/x86_64-linux-gnu/
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 /openair-smf/build/smf/build/nas/libNAS.so /usr/local/lib/
COPY --from=oai-smf-builder /openair-smf/scripts/entrypoint.sh .
WORKDIR /usr/local/lib/
COPY --from=oai-smf-builder /usr/local/lib/libpistache.so .
COPY --from=oai-smf-builder /usr/local/lib/libnghttp2_asio.so.1 .
COPY --from=oai-smf-builder /usr/lib/libboost_system.so.1.67.0 .
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
# Copying template configuration files
......@@ -95,5 +108,4 @@ WORKDIR /openair-smf
EXPOSE 80/tcp 9090/tcp 8805/udp
ENTRYPOINT ["/bin/bash","/openair-smf/bin/entrypoint.sh"]
CMD ["/openair-smf/bin/oai_smf", "-c", "/openair-smf/etc/smf.conf", "-o"]
......@@ -21,6 +21,7 @@
SMF =
{
FQDN = "oai-smf-svc";
INSTANCE = @INSTANCE@; # 0 is the default
PID_DIRECTORY = "@PID_DIRECTORY@"; # /var/run is the default
......@@ -85,6 +86,7 @@ SMF =
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
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 :
......@@ -92,6 +94,7 @@ SMF =
IPV4_ADDRESS = "@AMF_IPV4_ADDRESS@"; # YOUR AMF CONFIG HERE
PORT = @AMF_PORT@; # YOUR AMF CONFIG HERE (default: 80)
API_VERSION = "@AMF_API_VERSION@"; # YOUR AMF API VERSION FOR SBI CONFIG HERE
FQDN = "@AMF_FQDN@" # YOUR AMF FQDN CONFIG HERE
};
UDM :
......@@ -99,6 +102,7 @@ SMF =
IPV4_ADDRESS = "@UDM_IPV4_ADDRESS@"; # YOUR UDM CONFIG HERE
PORT = @UDM_PORT@; # YOUR UDM CONFIG HERE (default: 80)
API_VERSION = "@UDM_API_VERSION@"; # YOUR UDM API VERSION FOR SBI CONFIG HERE
FQDN = "@UDM_FQDN@" # YOUR UDM FQDN CONFIG HERE
};
NRF :
......@@ -106,10 +110,11 @@ SMF =
IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@"; # YOUR NRF CONFIG HERE
PORT = @NRF_PORT@; # YOUR NRF CONFIG HERE (default: 80)
API_VERSION = "@NRF_API_VERSION@"; # YOUR NRF API VERSION FOR SBI CONFIG HERE
FQDN = "@NRF_FQDN@" # YOUR NRF FQDN CONFIG HERE
};
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 :
......
......@@ -48,6 +48,7 @@ set(CN_UTILS_SRC STATIC
${CMAKE_CURRENT_SOURCE_DIR}/string.cpp
${CMAKE_CURRENT_SOURCE_DIR}/thread_sched.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mime_parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/fqdn.cpp
)
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) {
// smf_api_server_2->start();
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_http2_manager.join();
......
......@@ -61,6 +61,7 @@
#include "smf_n4.hpp"
#include "smf_paa_dynamic.hpp"
#include "string.hpp"
#include "fqdn.hpp"
extern "C" {
#include "dynamic_memory_check.h"
......@@ -340,17 +341,30 @@ smf_app::smf_app(const std::string& config_file)
throw;
}
// 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);
}
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_nf_registration_discovery() {
if (smf_cfg.discover_upf) {
// Trigger NFStatusNotify subscription to be noticed when a new UPF becomes
// available (if this option is enabled)
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)
......@@ -359,17 +373,8 @@ smf_app::smf_app(const std::string& config_file)
usleep(microsecond);
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) {
std::time_t time_epoch = std::time(nullptr);
......@@ -441,8 +446,17 @@ void smf_app::start_upf_association(
"Could not send ITTI message %s to task TASK_SMF_N4",
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 {
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(
upf_info);
// Verify if the UPF is already exist
// if not, add to the DB and send Association request
// UPF N4 ipv4 address
std::vector<struct in_addr> ipv4_addrs = {};
profile.get()->get_nf_ipv4_addresses(ipv4_addrs);
// UPF N4 ipv4 address/FQDN
std::string upf_fqdn = profile.get()->get_fqdn();
if (ipv4_addrs.size() < 1) {
Logger::smf_app().debug("No IP Addr found");
return false;
}
if (upf_fqdn.empty()) { // Use IPv4 Addr
std::vector<struct in_addr> ipv4_addrs = {};
profile.get()->get_nf_ipv4_addresses(ipv4_addrs);
bool found = false;
for (auto node : smf_cfg.upfs) {
if (node.u1.ipv4_address.s_addr == ipv4_addrs[0].s_addr) {
found = false;
break;
if (ipv4_addrs.size() < 1) {
Logger::smf_app().debug("No IP Addr found");
return false;
}
bool found = false;
for (auto node : smf_cfg.upfs) {
if (node.u1.ipv4_address.s_addr == ipv4_addrs[0].s_addr) {
found = true;
break;
}
}
if (!found) {
// Add a new UPF node
Logger::smf_app().debug(
"Add a new UPF node, Ipv4 Addr %s", inet_ntoa(ipv4_addrs[0]));
pfcp::node_id_t n = {};
n.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS;
n.u1.ipv4_address.s_addr = ipv4_addrs[0].s_addr;
// memcpy(&n.u1.ipv4_address, &ipv4_addrs[0], sizeof(struct
// in_addr));
smf_cfg.upfs.push_back(n);
upf_profile* upf_node_profile =
dynamic_cast<upf_profile*>(profile.get());
start_upf_association(n, std::ref(*upf_node_profile));
// start_upf_association(n,
// std::static_pointer_cast<upf_profile>(profile));
} else {
Logger::smf_app().debug(
"UPF node already exist (%s)", inet_ntoa(ipv4_addrs[0]));
}
} else { // use FQDN
uint8_t addr_type = {0};
std::string address = {};
uint32_t upf_port = {0};
struct in_addr upf_ipv4_addr = {};
fqdn::resolve(upf_fqdn, address, upf_port, addr_type);
if (addr_type != 0) { // IPv6
// TODO:
Logger::smf_app().debug("Do not support IPv6 addr for UPF");
return false;
} else { // IPv4
if (inet_aton(util::trim(address).c_str(), &upf_ipv4_addr) == 0) {
Logger::smf_app().debug("Bad IPv4 Addr format for UPF");
return false;
}
}
bool found = false;
for (auto node : smf_cfg.upfs) {
if ((node.u1.ipv4_address.s_addr == upf_ipv4_addr.s_addr) or
(upf_fqdn.compare(node.fqdn) == 0)) {
found = true;
break;
}
}
if (!found) {
// Add a new UPF node
Logger::smf_app().debug(
"Add a new UPF node, FQDN %s", upf_fqdn.c_str());
pfcp::node_id_t n = {};
n.node_id_type = pfcp::NODE_ID_TYPE_FQDN;
n.fqdn = upf_fqdn;
n.u1.ipv4_address.s_addr =
upf_ipv4_addr
.s_addr; // Normally we should not do that, but ok since we
// keep both fqdn and IPv4 at the same time
smf_cfg.upfs.push_back(n);
upf_profile* upf_node_profile =
dynamic_cast<upf_profile*>(profile.get());
start_upf_association(n, std::ref(*upf_node_profile));
} else {
Logger::smf_app().debug(
"UPF node already exist (%s)", address.c_str());
}
}
if (!found) {
// Add a new UPF node
Logger::smf_app().debug(
"Add a new UPF node, Ipv4 Addr %s", inet_ntoa(ipv4_addrs[0]));
pfcp::node_id_t n = {};
n.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS;
n.u1.ipv4_address.s_addr = ipv4_addrs[0].s_addr;
// memcpy(&n.u1.ipv4_address, &ipv4_addrs[0], sizeof(struct in_addr));
smf_cfg.upfs.push_back(n);
upf_profile* upf_node_profile =
dynamic_cast<upf_profile*>(profile.get());
start_upf_association(n, std::ref(*upf_node_profile));
// start_upf_association(n,
// std::static_pointer_cast<upf_profile>(profile));
} else {
Logger::smf_app().debug(
"UPF node already exist (%s)", inet_ntoa(ipv4_addrs[0]));
}
}
} else {
......
<
......@@ -81,10 +81,10 @@ class smf_context_ref {
void clear() {
supi = {};
nssai = {};
dnn = "";