Commit dd53e0c5 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'multiple_upf' into 'develop'

Multiple UPFs

See merge request oai/cn5g/oai-cn5g-smf!42
parents 6eecd52d 7d8b9f2d
......@@ -49,27 +49,21 @@ install_fb_folly_from_source(){
then
if [[ "$OS_BASEDISTRO" == "fedora" ]]; then
$SUDO $INSTALLER install $OPTION \
gcc-c++ \
$CMAKE \
boost-devel \
libevent-devel \
double-conversion-devel \
glog-devel \
gflags-devel \
snappy-devel \
make \
lz4-devel \
zlib-devel \
binutils-devel \
jemalloc-devel \
openssl-devel \
pkg-config
openssl-devel
ret=$?;[[ $ret -ne 0 ]] && return $ret
elif [[ $OS_DISTRO == "ubuntu" ]]; then
$SUDO $INSTALLER install $OPTION \
g++ \
cmake \
libboost-all-dev \
libevent-dev \
libdouble-conversion-dev \
libgoogle-glog-dev \
......@@ -78,12 +72,10 @@ install_fb_folly_from_source(){
liblz4-dev \
liblzma-dev \
libsnappy-dev \
make \
wget \
zlib1g-dev \
binutils-dev \
libjemalloc-dev \
libssl-dev \
pkg-config
libjemalloc-dev
ret=$?;[[ $ret -ne 0 ]] && return $ret
fi
......@@ -101,7 +93,7 @@ install_fb_folly_from_source(){
tar zxf release-1.8.0.tar.gz && \
rm -f release-1.8.0.tar.gz && \
cd googletest-release-1.8.0 && \
$CMAKE . && \
$CMAKE . -DBUILD_GMOCK=OFF && \
make && \
$SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
......@@ -149,4 +141,3 @@ install_fb_folly_from_source(){
echo_success "End of folly installation"
return 0
}
......@@ -67,6 +67,7 @@ install_fmt() {
fi
return 0
}
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
......@@ -140,7 +141,11 @@ install_pistache_from_git() {
cd pistache && git checkout e18ed9baeb2145af6f9ea41246cf48054ffd9907
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
mkdir _build && cd _build
$CMAKE -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
$CMAKE -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release \
-DPISTACHE_BUILD_EXAMPLES=false \
-DPISTACHE_BUILD_TESTS=false \
-DPISTACHE_BUILD_DOCS=false \
..
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
make
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
......@@ -151,9 +156,6 @@ install_pistache_from_git() {
return 0
}
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
......@@ -274,7 +276,7 @@ install_nghttp2_from_git() {
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
autoconf
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
./configure --enable-asio-lib
./configure --enable-asio-lib --enable-lib-only
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
make
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
......@@ -349,7 +351,6 @@ check_install_smf_deps() {
$SUDO $INSTALLER install $OPTION $PACKAGE_LIST
ret=$?;[[ $ret -ne 0 ]] && return $ret
# Libraries
if [[ $OS_DISTRO == "ubuntu" ]]; then
case "$(get_distribution_release)" in
......@@ -378,7 +379,8 @@ check_install_smf_deps() {
nettle-dev \
libcurl4 \
net-tools \
pkg-config"
pkg-config \
libasan2"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\
guile-devel \
......@@ -397,7 +399,8 @@ check_install_smf_deps() {
nettle-devel \
libcurl-devel \
python2 \
pkgconfig"
pkgconfig \
libasan"
else
echo_fatal "$OS_DISTRO is not a supported distribution."
fi
......
......@@ -103,6 +103,17 @@ esac
done
# If the repo workspace is shallow, unshallow it
NB_COMMITS=`git log --oneline | wc -l`
if [ $NB_COMMITS -eq 1 ]
then
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" > /dev/null 2>&1
echo "git remote update"
git remote update > /dev/null 2>&1
echo "git fetch --prune --unshallow"
git fetch --prune --unshallow > /dev/null 2>&1
fi
if [[ $TARGET_COMMIT_ID == "latest" ]]
then
TARGET_COMMIT_ID=`git log -n1 --pretty=format:%H origin/$TARGET_BRANCH`
......
......@@ -54,9 +54,8 @@ SMF =
IPV4_LIST = (
{RANGE = "12.1.1.2 - 12.1.1.128";}, # STRING, IPv4 RANGE IP_start - IP_end, YOUR NETWORK CONFIG HERE.
{RANGE = "12.1.1.129 - 12.1.1.224";}, # STRING, IPv4 RANGE IP_start - IP_end, YOUR NETWORK CONFIG HERE.
{RANGE = "192.169.0.2 - 192.169.255.253";}, # STRING, IPv4 RANGE IP_start - IP_end, YOUR NETWORK CONFIG HERE.
{RANGE = "192.170.0.2 - 192.170.255.253";}, # STRING, IPv4 RANGE IP_start - IP_end, YOUR NETWORK CONFIG HERE.
{RANGE = "192.171.0.2 - 192.171.255.253";} # STRING, IPv4 RANGE IP_start - IP_end, YOUR NETWORK CONFIG HERE.
{RANGE = "10.10.10.2 - 10.10.10.253";} # STRING, IPv4 RANGE IP_start - IP_end, YOUR NETWORK CONFIG HERE.
);
IPV6_LIST = (
{PREFIX = "2001:1:2::/64";}, # STRING, IPv6 prefix, YOUR NETWORK CONFIG HERE.
......@@ -69,9 +68,7 @@ SMF =
# IPV4_POOL, IPV6_POOL are index in IPV4_LIST, IPV6_LIST, PDU_SESSION_TYPE choice in {IPv4, IPv6, IPv4v6}
{DNN_NI = "default"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 0; IPV6_POOL = -1},
{DNN_NI = "carrier.com"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 1; IPV6_POOL = -1},
{DNN_NI = "apn2"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 2; IPV6_POOL = -1},
{DNN_NI = "apn3"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 3; IPV6_POOL = -1},
{DNN_NI = "apn4"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 4; IPV6_POOL = -1}
{DNN_NI = "oai"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 2; IPV6_POOL = -1}
);
# DNS address communicated to UEs
......@@ -117,12 +114,11 @@ SMF =
LOCAL_CONFIGURATION :
{
USE_LOCAL_CONFIGURATION = "yes";
SESSION_MANAGEMENT_SUBSCRIPTION_LIST = (
{ NSSAI_SST = 222, NSSAI_SD = "123", DNN = "default", DEFAULT_SESSION_TYPE = "IPV4", DEFAULT_SSC_MODE = 1,
QOS_PROFILE_5QI = 6, QOS_PROFILE_PRIORITY_LEVEL = 1, QOS_PROFILE_ARP_PRIORITY_LEVEL = 1, QOS_PROFILE_ARP_PREEMPTCAP = "NOT_PREEMPT",
QOS_PROFILE_ARP_PREEMPTVULN = "NOT_PREEMPTABLE", SESSION_AMBR_UL = "20Mbps", SESSION_AMBR_DL = "22Mbps"},
{ NSSAI_SST = 222; NSSAI_SD = "123", DNN = "carrier.com", DEFAULT_SESSION_TYPE = "IPV4", DEFAULT_SSC_MODE = 1,
{ NSSAI_SST = 111; NSSAI_SD = "321", DNN = "oai", DEFAULT_SESSION_TYPE = "IPV4", DEFAULT_SSC_MODE = 1,
QOS_PROFILE_5QI = 7, QOS_PROFILE_PRIORITY_LEVEL = 1, QOS_PROFILE_ARP_PRIORITY_LEVEL = 1, QOS_PROFILE_ARP_PREEMPTCAP = "NOT_PREEMPT",
QOS_PROFILE_ARP_PREEMPTVULN = "NOT_PREEMPTABLE", SESSION_AMBR_UL = "10Mbps", SESSION_AMBR_DL = "11Mbps"}
);
......
......@@ -118,7 +118,7 @@ void SMContextsCollectionApi::post_sm_contexts_handler(
} catch (nlohmann::detail::exception& e) {
Logger::smf_api_server().warn(
"Can not parse the json data (error: %s)!", e.what());
"Cannot parse the json data (error: %s)!", e.what());
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (std::exception& e) {
......
......@@ -80,7 +80,7 @@ void IndividualSMContextApiImpl::release_sm_context(
// Handle the itti_n11_release_sm_context_request message in smf_app
std::shared_ptr<itti_n11_release_sm_context_request> itti_msg =
std::make_shared<itti_n11_release_sm_context_request>(
TASK_SMF_N11, TASK_SMF_APP, promise_id, smContextRef);
TASK_SMF_SBI, TASK_SMF_APP, promise_id, smContextRef);
itti_msg->req = sm_context_req_msg;
itti_msg->http_version = 1;
m_smf_app->handle_pdu_session_release_sm_context_request(itti_msg);
......@@ -133,7 +133,7 @@ void IndividualSMContextApiImpl::update_sm_context(
// Handle the itti_n11_update_sm_context_request message in smf_app
std::shared_ptr<itti_n11_update_sm_context_request> itti_msg =
std::make_shared<itti_n11_update_sm_context_request>(
TASK_SMF_N11, TASK_SMF_APP, promise_id, smContextRef);
TASK_SMF_SBI, TASK_SMF_APP, promise_id, smContextRef);
itti_msg->req = sm_context_req_msg;
itti_msg->http_version = 1;
m_smf_app->handle_pdu_session_update_sm_context_request(itti_msg);
......
......@@ -65,7 +65,7 @@ void NFStatusNotifyApiImpl::receive_nf_status_notification(
// Handle the message in smf_app
std::shared_ptr<itti_sbi_notification_data> itti_msg =
std::make_shared<itti_sbi_notification_data>(TASK_SMF_N11, TASK_SMF_APP);
std::make_shared<itti_sbi_notification_data>(TASK_SMF_SBI, TASK_SMF_APP);
itti_msg->notification_msg = notification_msg;
itti_msg->http_version = 1;
......
......@@ -92,7 +92,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
// Handle the pdu_session_create_sm_context_request message in smf_app
std::shared_ptr<itti_n11_create_sm_context_request> itti_msg =
std::make_shared<itti_n11_create_sm_context_request>(
TASK_SMF_N11, TASK_SMF_APP, promise_id);
TASK_SMF_SBI, TASK_SMF_APP, promise_id);
itti_msg->req = sm_context_req_msg;
itti_msg->http_version = 1;
m_smf_app->handle_pdu_session_create_sm_context_request(itti_msg);
......
......@@ -74,7 +74,7 @@ void SubscriptionsCollectionApiImpl::create_individual_subcription(
// Handle the message in smf_app
std::shared_ptr<itti_sbi_event_exposure_request> itti_msg =
std::make_shared<itti_sbi_event_exposure_request>(
TASK_SMF_N11, TASK_SMF_APP);
TASK_SMF_SBI, TASK_SMF_APP);
itti_msg->event_exposure = event_exposure;
itti_msg->http_version = 1;
......
......@@ -345,7 +345,7 @@ void smf_http2_server::create_sm_contexts_handler(
// Handle the pdu_session_create_sm_context_request message in smf_app
std::shared_ptr<itti_n11_create_sm_context_request> itti_msg =
std::make_shared<itti_n11_create_sm_context_request>(
TASK_SMF_N11, TASK_SMF_APP, promise_id);
TASK_SMF_SBI, TASK_SMF_APP, promise_id);
itti_msg->req = sm_context_req_msg;
itti_msg->http_version = 2;
m_smf_app->handle_pdu_session_create_sm_context_request(itti_msg);
......@@ -410,7 +410,7 @@ void smf_http2_server::update_sm_context_handler(
// Handle the itti_n11_update_sm_context_request message in smf_app
std::shared_ptr<itti_n11_update_sm_context_request> itti_msg =
std::make_shared<itti_n11_update_sm_context_request>(
TASK_SMF_N11, TASK_SMF_APP, promise_id, smf_ref);
TASK_SMF_SBI, TASK_SMF_APP, promise_id, smf_ref);
itti_msg->req = sm_context_req_msg;
itti_msg->http_version = 2;
m_smf_app->handle_pdu_session_update_sm_context_request(itti_msg);
......@@ -495,7 +495,7 @@ void smf_http2_server::release_sm_context_handler(
"request from AMF.");
std::shared_ptr<itti_n11_release_sm_context_request> itti_msg =
std::make_shared<itti_n11_release_sm_context_request>(
TASK_SMF_N11, TASK_SMF_APP, promise_id, smf_ref);
TASK_SMF_SBI, TASK_SMF_APP, promise_id, smf_ref);
itti_msg->req = sm_context_req_msg;
itti_msg->scid = smf_ref;
itti_msg->http_version = 2;
......
......@@ -34,23 +34,6 @@
#include <string>
#include <vector>
//------------------------------------------------------------------------------
// 10.5.1.3 Location Area Identification
//------------------------------------------------------------------------------
#define LOCATION_AREA_IDENTIFICATION_IE_TYPE 3
#define LOCATION_AREA_IDENTIFICATION_IE_MIN_LENGTH 6
#define LOCATION_AREA_IDENTIFICATION_IE_MAX_LENGTH 6
#define INVALID_LAC_0000 \
(uint16_t) 0x0000 /*!< \brief This LAC can be coded using a full \
hexadecimal representation except for the following \
reserved hexadecimal values: 0000, and FFFE. */
#define INVALID_LAC_FFFE \
(uint16_t) 0xFFFE /*!< \brief This LAC can be coded using a full \
hexadecimal representation except for the following \
reserved hexadecimal values: 0000, and FFFE. */
//------------------------------------------------------------------------------
// 10.5.6.3 Protocol configuration options
//------------------------------------------------------------------------------
......
This diff is collapsed.
......@@ -63,8 +63,7 @@ void Logger::_init(
m_smf_n1 = new _Logger("smf_n1 ", m_sinks, ss.str().c_str());
m_smf_n2 = new _Logger("smf_n2 ", m_sinks, ss.str().c_str());
m_smf_n4 = new _Logger("smf_n4 ", m_sinks, ss.str().c_str());
m_smf_n10 = new _Logger("smf_n10", m_sinks, ss.str().c_str());
m_smf_n11 = new _Logger("smf_n11", m_sinks, ss.str().c_str());
m_smf_sbi = new _Logger("smf_sbi", m_sinks, ss.str().c_str());
m_smf_api_server = new _Logger("sbi_srv", m_sinks, ss.str().c_str());
}
......
......@@ -86,8 +86,7 @@ class Logger {
static _Logger& smf_n1() { return *singleton().m_smf_n1; }
static _Logger& smf_n2() { return *singleton().m_smf_n2; }
static _Logger& smf_n4() { return *singleton().m_smf_n4; }
static _Logger& smf_n10() { return *singleton().m_smf_n10; }
static _Logger& smf_n11() { return *singleton().m_smf_n11; }
static _Logger& smf_sbi() { return *singleton().m_smf_sbi; }
static _Logger& smf_api_server() { return *singleton().m_smf_api_server; }
private:
......@@ -116,8 +115,7 @@ class Logger {
_Logger* m_smf_n1;
_Logger* m_smf_n2;
_Logger* m_smf_n4;
_Logger* m_smf_n10;
_Logger* m_smf_n11;
_Logger* m_smf_sbi;
_Logger* m_smf_api_server;
};
......
......@@ -369,6 +369,24 @@ class itti_n4_node_report_response : public itti_n4_msg {
pfcp::pfcp_node_report_response pfcp_ies;
};
//-----------------------------------------------------------------------------
class itti_n4_node_failure : public itti_n4_msg {
public:
itti_n4_node_failure(const task_id_t origin, const task_id_t destination)
: itti_n4_msg(N4_NODE_FAILURE, origin, destination), node_id() {}
itti_n4_node_failure(const itti_n4_node_failure& i) : itti_n4_msg(i) {
node_id = i.node_id;
}
itti_n4_node_failure(
const itti_n4_node_failure& i, const task_id_t orig, const task_id_t dest)
: itti_n4_msg(i, orig, dest) {
node_id = i.node_id;
}
const char* get_msg_name() { return typeid(itti_n4_node_failure).name(); };
pfcp::node_id_t node_id;
};
//-----------------------------------------------------------------------------
class itti_n4_session_set_deletion_request : public itti_n4_msg {
public:
......
......@@ -28,7 +28,7 @@
#ifndef FILE_3GPP_CONVERSIONS_HPP_SEEN
#define FILE_3GPP_CONVERSIONS_HPP_SEEN
#include "3gpp_29.274.h"
#include "3gpp_29.244.h"
#include "3gpp_24.501.h"
#include "endpoint.hpp"
......
......@@ -36,8 +36,7 @@ typedef enum {
TASK_ASYNC_SHELL_CMD,
TASK_SMF_APP,
TASK_SMF_N4,
TASK_SMF_N10,
TASK_SMF_N11,
TASK_SMF_SBI,
TASK_MAX,
TASK_NONE,
TASK_ALL = 255
......@@ -93,6 +92,7 @@ typedef enum {
N4_VERSION_NOT_SUPPORTED_RESPONSE,
N4_NODE_REPORT_REQUEST,
N4_NODE_REPORT_RESPONSE,
N4_NODE_FAILURE,
N4_SESSION_SET_DELETION_REQUEST,
N4_SESSION_SET_DELETION_RESPONSE,
N4_SESSION_ESTABLISHMENT_REQUEST,
......
......@@ -30,9 +30,9 @@
int encode_extended_protocol_configuration_options(
protocol_configuration_options_nas_t extendedprotocolconfigurationoptions,
uint8_t iei, uint8_t* buffer, uint32_t len) {
uint8_t* lenPtr = NULL;
uint32_t encoded = 0;
int encode_result = 0;
uint8_t* lenPtr = NULL;
uint32_t encoded = 0;
// int encode_result = 0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer,
((iei > 0) ?
......@@ -150,7 +150,7 @@ int decode_extended_protocol_configuration_options(
//------------------------------------------------------------------------------
int decode_protocol_configuration_options(
protocol_configuration_options_nas_t* protocolconfigurationoptions,
const uint8_t* const buffer, const const uint32_t len) {
const uint8_t* const buffer, const uint32_t len) {
int decoded = 0;
int decode_result = 0;
......
......@@ -214,8 +214,8 @@ int decode_qos_rules(
qosrulesie->packetfilterlist.create_modifyandadd_modifyandreplace[j]
.packetfilteridentifier = bitstream & 0x0f;
uint8_t* lenghtofpacketfiltercontents =
(uint8_t*) (*(buffer + decoded) - 1);
uint8_t lenghtofpacketfiltercontents =
*(buffer + decoded) - 1;
decoded++;
DECODE_U8(buffer + decoded, bitstream, decoded);
......@@ -306,8 +306,8 @@ int decode_qos_rules(
.packetfilterlist.create_modifyandadd_modifyandreplace[j]
.packetfilteridentifier = bitstream & 0x0f;
uint8_t* lenghtofpacketfiltercontents =
(uint8_t*) (*(buffer + decoded) - 1);
uint8_t lenghtofpacketfiltercontents =
*(buffer + decoded) - 1;
decoded++;
DECODE_U8(buffer + decoded, bitstream, decoded);
......
This diff is collapsed.
......@@ -34,7 +34,6 @@
#include "sm_msg.h"
#include "common_types.h"
// test mac and encrypt/decrypt
#define DIRECTION__ 1 // SECU_DIRECTION_DOWNLINK
#define TEST_MAC_ENCRYPT_DECRYPT__ 0
#define NAS_MESSAGE_SECURITY_HEADER_SIZE 7
......
......@@ -102,7 +102,6 @@ int main(int argc, char** argv) {
// Logger
Logger::init("smf", Options::getlogStdout(), Options::getlogRotFilelog());
Logger::smf_app().startup("Options parsed");
struct sigaction sigIntHandler;
......@@ -115,7 +114,7 @@ int main(int argc, char** argv) {
smf_cfg.load(Options::getlibconfigConfig());
smf_cfg.display();
// Inter task Interface
// Inter-task Interface
itti_inst = new itti_mw();
itti_inst->start(smf_cfg.itti.itti_timer_sched_params);
......
......@@ -873,7 +873,7 @@ void pfcp_l4_stack::send_response(
//------------------------------------------------------------------------------
void pfcp_l4_stack::notify_ul_error(
const pfcp_procedure& p, const ::cause_value_e cause) {
const pfcp_procedure& p, const cause_value_e cause) {
Logger::pfcp().trace(
"notify_ul_error proc %" PRId64 " cause %d", p.trxn_id, cause);
}
......@@ -908,7 +908,8 @@ void pfcp_l4_stack::time_out_event(
} else {
// abort procedure
notify_ul_error(
it_proc->second, ::cause_value_e::REMOTE_PEER_NOT_RESPONDING);
it_proc->second,
cause_value_e::CAUSE_VALUE_PFCP_ENTITY_IN_CONGESTION);
}
}
} else {
......
......@@ -28,7 +28,6 @@
#ifndef FILE_PFCP_HPP_SEEN
#define FILE_PFCP_HPP_SEEN
#include "3gpp_29.274.h"
#include "3gpp_29.244.hpp"
#include "itti.hpp"
#include "udp.hpp"
......@@ -120,7 +119,7 @@ class pfcp_l4_stack : public udp_application {
void stop_msg_retry_timer(pfcp_procedure& p);
void stop_msg_retry_timer(timer_id_t& t);
void stop_proc_cleanup_timer(pfcp_procedure& p);
void notify_ul_error(const pfcp_procedure& p, const ::cause_value_e cause);
void notify_ul_error(const pfcp_procedure& p, const cause_value_e cause);
public:
static const uint8_t version = 2;
......
......@@ -55,8 +55,7 @@ add_library (SMF STATIC
smf_pco.cpp
smf_procedure.cpp
smf_n4.cpp
smf_n10.cpp
smf_n11.cpp
smf_sbi.cpp
smf_event.cpp
smf_profile.cpp
smf_subscription.cpp
......
This diff is collapsed.
......@@ -39,7 +39,6 @@
#include <string>
#include <thread>
#include "3gpp_29.274.h"
#include "3gpp_29.502.h"
#include "itti_msg_n11.hpp"
#include "itti_msg_n4.hpp"
......@@ -89,6 +88,7 @@ class smf_context_ref {
pdu_session_id = 0;
amf_status_uri = "";
amf_addr = "";
upf_node_id = {};
}
supi_t supi;
......@@ -97,6 +97,7 @@ class smf_context_ref {
snssai_t nssai;
std::string amf_status_uri;
std::string amf_addr;
pfcp::node_id_t upf_node_id;
};
class smf_app {
......@@ -320,6 +321,13 @@ class smf_app {
*/
void handle_itti_msg(itti_n4_association_setup_request& sna);
/*
* Handle ITTI message (N4 Node Failure)
* @param [itti_n4_node_failure&] snf
* @return void
*/
void handle_itti_msg(std::shared_ptr<itti_n4_node_failure> snf);
/*
* Handle ITTI message from N11 to update PDU session status
* @param [itti_n11_update_pdu_session_status&] snu
......@@ -654,6 +662,14 @@ class smf_app {
*/
void start_upf_association(const pfcp::node_id_t& node_id);
/*
* To start an association with a UPF (SMF-initiated association)
* @param [const pfcp::node_id_t] node_id: UPF Node ID
* @return void
*/
void start_upf_association(
const pfcp::node_id_t& node_id, const upf_profile& profile);
/*
* To store a promise of a PDU Session Create SM Contex Response to be
* triggered when the result is ready
......
......@@ -687,15 +687,6 @@ int smf_config::load(const string& config_file) {
// Local configuration
num_session_management_subscription = 0;
const Setting& local_cfg = smf_cfg[SMF_CONFIG_STRING_LOCAL_CONFIGURATION];
string local_configuration_str = {};
local_cfg.lookupValue(
SMF_CONFIG_STRING_USE_LOCAL_CONFIGURATION, local_configuration_str);
if (boost::iequals(local_configuration_str, "yes")) {
local_configuration = true;
} else {
local_configuration = false;
}
const Setting& session_management_subscription_list_cfg =
local_cfg[SMF_CONFIG_STRING_SESSION_MANAGEMENT_SUBSCRIPTION_LIST];
......@@ -926,7 +917,7 @@ void smf_config::display() {
Logger::smf_app().info(
" Push PCO (DNS+MTU).........: %s", force_push_pco ? "Yes" : "No");
if (local_configuration) {
if (use_local_subscription_info) {
Logger::smf_app().info(
"- " SMF_CONFIG_STRING_SESSION_MANAGEMENT_SUBSCRIPTION_LIST ":");
for (int i = 0; i < num_session_management_subscription; i++) {
......
......@@ -39,7 +39,6 @@
#include "thread_sched.hpp"
#include "3gpp_29.244.h"
#include "3gpp_29.274.h"
#include "pfcp.hpp"
#include "smf.h"
......@@ -112,7 +111,6 @@
#define SMF_CONFIG_STRING_NRF_PORT "PORT"
#define SMF_CONFIG_STRING_LOCAL_CONFIGURATION "LOCAL_CONFIGURATION"
#define SMF_CONFIG_STRING_USE_LOCAL_CONFIGURATION "USE_LOCAL_CONFIGURATION"
#define SMF_CONFIG_STRING_SESSION_MANAGEMENT_SUBSCRIPTION_LIST \
"SESSION_MANAGEMENT_SUBSCRIPTION_LIST"
#define SMF_CONFIG_STRING_NSSAI_SST "NSSAI_SST"
......@@ -240,8 +238,6 @@ class smf_config {
std::string api_version;
} nrf_addr;
// Local configuration
bool local_configuration;
#define SMF_NUM_SESSION_MANAGEMENT_SUBSCRIPTION_MAX 5
struct {
snssai_t single_nssai;
......@@ -307,7 +303,6 @@ class smf_config {
nrf_addr.port = 80;
nrf_addr.api_version = "v1";
local_configuration = false;
num_session_management_subscription = 0;
for (int i = 0; i < SMF_NUM_SESSION_MANAGEMENT_SUBSCRIPTION_MAX; i++) {
......@@ -315,6 +310,10 @@ class smf_config {
}
sbi_http2_port = 8080;
sbi_api_version = "v1";
use_local_subscription_info = false;
register_nrf = false;
discover_upf = false;
};
~smf_config();
void lock() { m_rw_lock.lock(); };
......
......@@ -42,7 +42,7 @@
#include "smf_config.hpp"
#include "smf_event.hpp"
#include "smf_n1.hpp"
#include "smf_n11.hpp"
#include "smf_sbi.hpp"
#include "smf_n2.hpp"
#include "smf_paa_dynamic.hpp"
#include "smf_pfcp_association.hpp"
......@@ -77,7 +77,7 @@ void smf_qos_flow::mark_as_released() {
std::string smf_qos_flow::toString() const {
std::string s = {};
s.append("QoS Flow:\n");
s.append("\tFQI:\t\t\t\t")
s.append("\tQFI:\t\t\t\t")
.append(std::to_string((uint8_t) qfi.qfi))
.append("\n");
s.append("\tUL FTEID:\t\t").append(ul_fteid.toString()).append("\n");
......@@ -735,9 +735,17 @@ void smf_context::handle_itti_msg(
if (find_pdu_session(pdr_id, qfi, sd, sp)) {
// Step 1. send N4 Data Report Ack to UPF
pfcp::node_id_t up_node_id = {};
if (not pfcp_associations::get_instance().select_up_node(
up_node_id, NODE_SELECTION_CRITERIA_MIN_PFCP_SESSIONS)) {
Logger::smf_app().info("REMOTE_PEER_NOT_RESPONDING");
scid_t scid = get_scid();
// Get UPF node
std::shared_ptr<smf_context_ref> scf = {};
if (smf_app_inst->is_scid_2_smf_context(scid)) {
scf = smf_app_inst->scid_2_smf_context(scid);
up_node_id = scf.get()->upf_node_id;
} else {
Logger::smf_app().warn(
"SM Context associated with this id " SCID_FMT
" does not exit!",
scid);
return;
}
......@@ -828,7 +836,7 @@ void smf_context::handle_itti_msg(
session_report_msg.set_json_data(json_data);
itti_n11_session_report_request* itti_n11 =
new itti_n11_session_report_request(TASK_SMF_APP, TASK_SMF_N11);
new itti_n11_session_report_request(TASK_SMF_APP, TASK_SMF_SBI);
itti_n11->http_version = 1; // use HTTPv1 for the moment
std::shared_ptr<itti_n11_session_report_request> itti_n11_report =
std::shared_ptr<itti_n11_session_report_request>(itti_n11);
......@@ -836,13 +844,13 @@ void smf_context::handle_itti_msg(
// send ITTI message to N11 interface to trigger N1N2MessageTransfer
// towards AMFs
Logger::smf_app().info(
"Sending ITTI message %s to task TASK_SMF_N11",
"Sending ITTI message %s to task TASK_SMF_SBI",
itti_n11_report->get_msg_name());
ret = itti_inst->send_msg(itti_n11_report);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N11",
"Could not send ITTI message %s to task TASK_SMF_SBI",
itti_n11_report->get_msg_name());
}
}
......@@ -1252,7 +1260,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
// receiving the response from UPF
itti_n11_create_sm_context_response* sm_context_resp =
new itti_n11_create_sm_context_response(
TASK_SMF_APP, TASK_SMF_N11, smreq->pid);
TASK_SMF_APP, TASK_SMF_SBI, smreq->pid);
std::shared_ptr<itti_n11_create_sm_context_response> sm_context_resp_pending =
std::shared_ptr<itti_n11_create_sm_context_response>(sm_context_resp);
......@@ -1468,7 +1476,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
"Send ITTI msg to SMF APP to trigger the response of Server");
std::shared_ptr<itti_n11_create_sm_context_response> itti_msg =
std::make_shared<itti_n11_create_sm_context_response>(
TASK_SMF_N11, TASK_SMF_APP, smreq->pid);
TASK_SMF_SBI, TASK_SMF_APP, smreq->pid);
pdu_session_create_sm_context_response sm_context_response = {};
std::string smContextRef = std::to_string(smreq->scid);
......@@ -1587,12 +1595,12 @@ void smf_context::handle_pdu_session_create_sm_context_request(
// send ITTI message to N11 to trigger N1N2MessageTransfer towards AMFs
Logger::smf_app().info(
"Sending ITTI message %s to task TASK_SMF_N11",
"Sending ITTI message %s to task TASK_SMF_SBI",
sm_context_resp_pending->get_msg_name());
int ret = itti_inst->send_msg(sm_context_resp_pending);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N11",
"Could not send ITTI message %s to task TASK_SMF_SBI",
sm_context_resp_pending->get_msg_name());
}
}
......@@ -2289,7 +2297,7 @@ void smf_context::handle_pdu_session_update_sm_context_request(
// when receiving the response from UPF
itti_n11_update_sm_context_response* n11_sm_context_resp =
new itti_n11_update_sm_context_response(
TASK_SMF_N11, TASK_SMF_APP, smreq->pid);
TASK_SMF_SBI, TASK_SMF_APP, smreq->pid);
std::shared_ptr<itti_n11_update_sm_context_response> sm_context_resp_pending =
std::shared_ptr<itti_n11_update_sm_context_response>(n11_sm_context_resp);
......@@ -2615,7 +2623,7 @@ void smf_context::handle_pdu_session_update_sm_context_request(
int ret = itti_inst->send_msg(sm_context_resp_pending);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N11",
"Could not send ITTI message %s to task TASK_SMF_SBI",
sm_context_resp_pending->get_msg_name());
}
}
......@@ -2658,7 +2666,7 @@ void smf_context::handle_pdu_session_release_sm_context_request(
itti_n11_release_sm_context_response* n11_sm_context_resp =
new itti_n11_release_sm_context_response(
TASK_SMF_N11, TASK_SMF_APP, smreq->pid);
TASK_SMF_SBI, TASK_SMF_APP, smreq->pid);
std::shared_ptr<itti_n11_release_sm_context_response>
sm_context_resp_pending =
......@@ -2773,7 +2781,7 @@ void smf_context::handle_pdu_session_modification_network_requested(
fmt::format(
NAMF_COMMUNICATION_N1N2_MESSAGE_TRANSFER_URL, supi_str.c_str());
itti_msg->msg.set_amf_url(url);
Logger::smf_n11().debug(
Logger::smf_app().debug(
"N1N2MessageTransfer will be sent to AMF with URL: %s", url.c_str());
// Fill the json part
......@@ -2803,12 +2811,12 @@ void smf_context::handle_pdu_session_modification_network_requested(
// Step 3. Send ITTI message to N11 interface to trigger N1N2MessageTransfer
// towards AMFs
Logger::smf_app().info(
"Sending ITTI message %s to task TASK_SMF_N11", itti_msg->get_msg_name());
"Sending ITTI message %s to task TASK_SMF_SBI", itti_msg->get_msg_name());
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N11",
"Could not send ITTI message %s to task TASK_SMF_SBI",
itti_msg->get_msg_name());
}
}
......@@ -2962,7 +2970,7 @@ void smf_context::handle_sm_context_status_change(
"Send ITTI msg to SMF N11 to trigger the status notification");
std::shared_ptr<itti_n11_notify_sm_context_status> itti_msg =
std::make_shared<itti_n11_notify_sm_context_status>(
TASK_SMF_APP, TASK_SMF_N11);
TASK_SMF_APP, TASK_SMF_SBI);
itti_msg->scid = scid;
itti_msg->sm_context_status = status;
itti_msg->amf_status_uri = scf.get()->amf_status_uri;
......@@ -2971,7 +2979,7 @@ void smf_context::handle_sm_context_status_change(
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N11",
"Could not send ITTI message %s to task TASK_SMF_SBI",
itti_msg->get_msg_name());
}
}
......@@ -2994,7 +3002,7 @@ void smf_context::handle_ee_pdu_session_release(
"Send ITTI msg to SMF N11 to trigger the event notification");
std::shared_ptr<itti_n11_notify_subscribed_event> itti_msg =
std::make_shared<itti_n11_notify_subscribed_event>(
TASK_SMF_APP, TASK_SMF_N11);
TASK_SMF_APP, TASK_SMF_SBI);
for (auto i : subscriptions) {
event_notification ev_notif = {};
......@@ -3012,7 +3020,7 @@ void smf_context::handle_ee_pdu_session_release(
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N11",
"Could not send ITTI message %s to task TASK_SMF_SBI",
itti_msg->get_msg_name());
}
} else {
......
......@@ -38,7 +38,6 @@
#include "3gpp_24.008.h"
#include "3gpp_29.244.h"
#include "3gpp_29.274.h"
#include "3gpp_29.502.h"
#include "3gpp_29.503.h"
#include "common_root_types.h"
......@@ -563,7 +562,7 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
pending_procedures(),
dnn_subscriptions(),
scid(0),
event_sub(smf_event::get_instance()) {
event_sub() {
supi_prefix = {};
// Subscribe to sm context status change
sm_context_status_connection =
......@@ -1060,7 +1059,7 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
mutable std::recursive_mutex m_context;
// for Event Handling
smf_event& event_sub;
smf_event event_sub;
bs2::connection sm_context_status_connection;
bs2::connection ee_pdu_session_release_connection;
};
......
......@@ -34,7 +34,6 @@
#include "3gpp_24.007.h"
#include "3gpp_24.501.h"
#include "3gpp_29.244.h"
#include "3gpp_29.274.h"
#include "3gpp_29.508.h"
#include "3gpp_29.571.h"
#include "NgRanTargetId.h"
......
/*
* 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 smf_n10.cpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2019
\email: tien-thinh.nguyen@eurecom.fr
*/
#include "smf_n10.hpp"
#include <stdexcept>
#include <curl/curl.h>
#include <nlohmann/json.hpp>
#include "common_defs.h"
#include "itti.hpp"
#include "logger.hpp"
#include "smf.h"
#include "smf_config.hpp"
using namespace smf;
using namespace std;
using json = nlohmann::json;
extern itti_mw* itti_inst;
extern smf_n10* smf_n10_inst;
extern smf_config smf_cfg;
void smf_n10_task(void*);
/*
* To read content of the response from UDM
*/
static std::size_t callback(
const char* in, std::size_t size, std::size_t num, std::string* out) {
const std::size_t totalBytes(size * num);
out->append(in, totalBytes);
return totalBytes;
}
//------------------------------------------------------------------------------
void smf_n10_task(void* args_p) {
const task_id_t task_id = TASK_SMF_N10;
itti_inst->notify_task_ready(task_id);
do {
std::shared_ptr<itti_msg> shared_msg = itti_inst->receive_msg(task_id);
auto* msg = shared_msg.get();
switch (msg->msg_type) {
case N10_SESSION_GET_SESSION_MANAGEMENT_SUBSCRIPTION:
break;
case TERMINATE:
if (itti_msg_terminate* terminate =
dynamic_cast<itti_msg_terminate*>(msg)) {
Logger::smf_n10().info("Received terminate message");
return;
}
break;
default:
Logger::smf_n10().info("no handler for msg type %d", msg->msg_type);
}
} while (true);
}
//------------------------------------------------------------------------------
smf_n10::smf_n10() {
Logger::smf_n10().startup("Starting...");
if (itti_inst->create_task(TASK_SMF_N10, smf_n10_task, nullptr)) {
Logger::smf_n10().error("Cannot create task TASK_SMF_N10");
throw std::runtime_error("Cannot create task TASK_SMF_N10");
}
Logger::smf_n10().startup("Started");
}
//------------------------------------------------------------------------------
bool smf_n10::get_sm_data(
const supi64_t& supi, const std::string& dnn, const snssai_t& snssai,
std::shared_ptr<session_management_subscription> subscription) {
// retrieve a UE's Session Management Subscription Data
nlohmann::json jsonData = {};
curl_global_init(CURL_GLOBAL_DEFAULT);
struct curl_slist* headers = nullptr;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");
CURL* curl = curl_easy_init();
std::string url =
std::string(inet_ntoa(*((struct in_addr*) &smf_cfg.udm_addr.ipv4_addr))) +
":" + std::to_string(smf_cfg.udm_addr.port) + NUDM_SDM_BASE +
smf_cfg.udm_addr.api_version +
fmt::format(NUDM_SDM_GET_SM_DATA_URL, std::to_string(supi));
Logger::smf_n10().debug("UDM's URL: %s ", url.c_str());
if (curl) {
CURLcode res = {};
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, UDM_CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_INTERFACE, smf_cfg.sbi.if_name.c_str());
// Response information.
long httpCode = {0};
std::unique_ptr<std::string> httpData(new std::string());
// Hook up data handling function.
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get());
int numRetries = 0;
while (numRetries < UDM_NUMBER_RETRIES) {
res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
Logger::smf_n10().debug("Response from UDM, HTTP Code: %d ", httpCode);
if (static_cast<http_response_codes_e>(httpCode) ==
http_response_codes_e::HTTP_RESPONSE_CODE_OK) {
Logger::smf_n10().debug(
"Got successful response from UDM, URL: %s ", url.c_str());
try {
jsonData = nlohmann::json::parse(*httpData.get());
break;
} catch (json::exception& e) {
Logger::smf_n10().warn("Could not parse json data from UDM");
}
numRetries++;
} else {
Logger::smf_n10().warn(
"Could not get response from UDM, URL %s, retry ...", url.c_str());
// retry
numRetries++;
}
}
curl_easy_cleanup(curl);
}
// process the response
if (!jsonData.empty()) {
Logger::smf_n10().debug("Response from UDM %s", jsonData.dump().c_str());
// retrieve SessionManagementSubscription and store in the context
for (nlohmann::json::iterator it = jsonData["dnnConfigurations"].begin();
it != jsonData["dnnConfigurations"].end(); ++it) {
Logger::smf_n10().debug("DNN %s", it.key().c_str());
try {
std::shared_ptr<dnn_configuration_t> dnn_configuration =
std::make_shared<dnn_configuration_t>();
pdu_session_type_t pdu_session_type(
pdu_session_type_e::PDU_SESSION_TYPE_E_IPV4);
std::string default_session_type =
it.value()["pduSessionTypes"]["defaultSessionType"];
Logger::smf_n10().debug(
"Default session type %s", default_session_type.c_str());
if (default_session_type.compare("IPV4") == 0) {
pdu_session_type.pdu_session_type =
pdu_session_type_e::PDU_SESSION_TYPE_E_IPV4;
} else if (default_session_type.compare("IPV6") == 0) {
pdu_session_type.pdu_session_type =
pdu_session_type_e::PDU_SESSION_TYPE_E_IPV6;
} else if (default_session_type.compare("IPV4V6") == 0) {
pdu_session_type.pdu_session_type =
pdu_session_type_e::PDU_SESSION_TYPE_E_IPV4V6;
}
dnn_configuration->pdu_session_types.default_session_type =
pdu_session_type;
// Ssc_Mode
ssc_mode_t ssc_mode(ssc_mode_e::SSC_MODE_1);
std::string default_ssc_mode = it.value()["sscModes"]["defaultSscMode"];
Logger::smf_n10().debug(
"Default SSC Mode %s", default_ssc_mode.c_str());
if (default_ssc_mode.compare("SSC_MODE_1") == 0) {
dnn_configuration->ssc_modes.default_ssc_mode =
ssc_mode_t(ssc_mode_e::SSC_MODE_1);
} else if (default_ssc_mode.compare("SSC_MODE_2") == 0) {
dnn_configuration->ssc_modes.default_ssc_mode =
ssc_mode_t(ssc_mode_e::SSC_MODE_2);
} else if (default_ssc_mode.compare("SSC_MODE_3") == 0) {
dnn_configuration->ssc_modes.default_ssc_mode =
ssc_mode_t(ssc_mode_e::SSC_MODE_3);
}
// 5gQosProfile
dnn_configuration->_5g_qos_profile._5qi =
it.value()["5gQosProfile"]["5qi"];
dnn_configuration->_5g_qos_profile.arp.priority_level =
it.value()["5gQosProfile"]["arp"]["priorityLevel"];
dnn_configuration->_5g_qos_profile.arp.preempt_cap =
it.value()["5gQosProfile"]["arp"]["preemptCap"];
dnn_configuration->_5g_qos_profile.arp.preempt_vuln =
it.value()["5gQosProfile"]["arp"]["preemptVuln"];
dnn_configuration->_5g_qos_profile.priority_level =
1; // TODO: hardcoded
// session_ambr
dnn_configuration->session_ambr.uplink =
it.value()["sessionAmbr"]["uplink"];
dnn_configuration->session_ambr.downlink =
it.value()["sessionAmbr"]["downlink"];
Logger::smf_n10().debug(
"Session AMBR Uplink %s, Downlink %s",
dnn_configuration->session_ambr.uplink.c_str(),
dnn_configuration->session_ambr.downlink.c_str());
subscription->insert_dnn_configuration(it.key(), dnn_configuration);
} catch (nlohmann::json::exception& e) {
Logger::smf_n10().warn(
"Exception message %s, exception id %d ", e.what(), e.id);
return false;
}
}
return true;
} else {
return false;
}
}
//------------------------------------------------------------------------------
void smf_n10::subscribe_sm_data() {
// TODO:
}
/*
* 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 smf_n10.hpp
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2019
\email: tien-thinh.nguyen@eurecom.fr
*/
#ifndef FILE_SMF_N10_HPP_SEEN
#define FILE_SMF_N10_HPP_SEEN
#include <map>
#include <thread>
#include "3gpp_29.503.h"
#include "smf.h"
#include "smf_context.hpp"
namespace smf {
class smf_n10 {
private:
std::thread::id thread_id;
std::thread thread;
public:
smf_n10();
smf_n10(smf_n10 const&) = delete;
void operator=(smf_n10 const&) = delete;
/*
* Get SM subscription data from UDM
* @param [const supi64_t &] supi
* @param [const std::string &] dnn
* @param [const snssai_t &] snssai
* @param [std::shared_ptr<session_management_subscription>] subscription
* @return bool: True if successful, otherwise false
*
*/
bool get_sm_data(
const supi64_t& supi, const std::string& dnn, const snssai_t& snssai,
std::shared_ptr<session_management_subscription> subscription);
/*
* Subscribe to be notify from UDM
* @param []
* @return void
*
*/
void subscribe_sm_data();
};
} // namespace smf
#endif /* FILE_SMF_N10_HPP_SEEN */
......@@ -157,7 +157,9 @@ class paa_dynamic {
std::map<std::string, dnn_dynamic_pools> dnns;
paa_dynamic() : ipv4_pools(), ipv6_pools(), dnns(){};
mutable std::shared_mutex m_ipv4_pools;
paa_dynamic() : ipv4_pools(), ipv6_pools(), dnns(), m_ipv4_pools(){};
public:
static paa_dynamic& get_instance() {
......@@ -173,6 +175,7 @@ class paa_dynamic {
const struct in_addr& first, const int range) {
if (pool_id >= 0) {
uint32_t uint32pool_id = uint32_t(pool_id);
std::unique_lock lock(m_ipv4_pools);
if (!ipv4_pools.count(uint32pool_id)) {
ipv4_pool pool(first, range);
ipv4_pools[uint32pool_id] = pool;
......@@ -206,6 +209,7 @@ class paa_dynamic {
if (dnns.count(dnn_label)) {
dnn_dynamic_pools& dnn_pool = dnns[dnn_label];
if (paa.pdu_session_type.pdu_session_type == PDU_SESSION_TYPE_E_IPV4) {
std::unique_lock lock(m_ipv4_pools);
for (std::vector<uint32_t>::const_iterator it4 =
dnn_pool.ipv4_pool_ids.begin();
it4 != dnn_pool.ipv4_pool_ids.end(); ++it4) {
......@@ -264,6 +268,7 @@ class paa_dynamic {
if (dnns.count(dnn_label)) {
dnn_dynamic_pools& dnn_pool = dnns[dnn_label];
if (paa.pdu_session_type.pdu_session_type == PDU_SESSION_TYPE_E_IPV4) {
std::unique_lock lock(m_ipv4_pools);
for (std::vector<uint32_t>::const_iterator it4 =
dnn_pool.ipv4_pool_ids.begin();
it4 != dnn_pool.ipv4_pool_ids.end(); ++it4) {
......@@ -295,6 +300,7 @@ class paa_dynamic {
bool release_paa(
const std::string& dnn_label, const struct in_addr& ipv4_address) {
std::unique_lock lock(m_ipv4_pools);
if (dnns.count(dnn_label)) {
dnn_dynamic_pools& dnn_pool = dnns[dnn_label];
for (std::vector<uint32_t>::const_iterator it4 =
......
This diff is collapsed.
......@@ -35,6 +35,7 @@
#include "3gpp_29.244.h"
#include "itti.hpp"
#include "smf_profile.hpp"
namespace smf {
......@@ -61,12 +62,17 @@ class pfcp_association {
timer_id_t timer_association;
timer_id_t timer_graceful_release;
upf_profile upf_node_profile;
bool upf_profile_is_set;
explicit pfcp_association(const pfcp::node_id_t& node_id)
: node_id(node_id),
recovery_time_stamp(),
function_features(),
m_sessions(),
sessions() {
sessions(),
upf_node_profile(),
upf_profile_is_set(false) {
hash_node_id = std::hash<pfcp::node_id_t>{}(node_id);
timer_heartbeat = ITTI_INVALID_TIMER_ID;
num_retries_timer_heartbeat = 0;
......@@ -82,7 +88,9 @@ class pfcp_association {
recovery_time_stamp(recovery_time_stamp),
function_features(),
m_sessions(),
sessions() {
sessions(),
upf_node_profile(),
upf_profile_is_set(false) {
hash_node_id = std::hash<pfcp::node_id_t>{}(node_id);
timer_heartbeat = ITTI_INVALID_TIMER_ID;
num_retries_timer_heartbeat = 0;
......@@ -94,7 +102,12 @@ class pfcp_association {
pfcp_association(
const pfcp::node_id_t& ni, pfcp::recovery_time_stamp_t& rts,
pfcp::up_function_features_s& uff)
: node_id(ni), recovery_time_stamp(rts), m_sessions(), sessions() {
: node_id(ni),
recovery_time_stamp(rts),
m_sessions(),
sessions(),
upf_node_profile(),
upf_profile_is_set(false) {
hash_node_id = std::hash<pfcp::node_id_t>{}(node_id);
function_features.first = true;
function_features.second = uff;
......@@ -115,7 +128,9 @@ class pfcp_association {
trxn_id_heartbeat(p.trxn_id_heartbeat),
is_restore_sessions_pending(p.is_restore_sessions_pending),
timer_association(0),
timer_graceful_release(0) {}
timer_graceful_release(0),
upf_node_profile(p.upf_node_profile),
upf_profile_is_set(p.upf_profile_is_set) {}
void notify_add_session(const pfcp::fseid_t& cp_fseid);
bool has_session(const pfcp::fseid_t& cp_fseid);
......@@ -126,6 +141,15 @@ class pfcp_association {
function_features.first = true;
function_features.second = ff;
};
void set_upf_node_profile(const upf_profile& profile) {
upf_node_profile = profile;
upf_profile_is_set = true;
};
bool is_upf_profile_set() { return upf_profile_is_set; }
void get_upf_node_profile(upf_profile& profile) const {
profile = upf_node_profile;
};
upf_profile get_upf_node_profile() const { return upf_node_profile; };
};
enum node_selection_criteria_e {
......@@ -189,7 +213,13 @@ class pfcp_associations {
bool select_up_node(
pfcp::node_id_t& node_id, const int node_selection_criteria);
bool select_up_node(
pfcp::node_id_t& node_id, const snssai_t& snssai, const std::string& dnn);
bool add_peer_candidate_node(const pfcp::node_id_t& node_id);
bool add_peer_candidate_node(
const pfcp::node_id_t& node_id, const upf_profile& profile);
bool remove_association(const std::string& node_instance_id);
bool remove_association(const int32_t& hash_node_id);
};
} // namespace smf
......
......@@ -31,7 +31,6 @@
#include <algorithm> // std::search
#include "3gpp_29.244.h"
#include "3gpp_29.274.h"
#include "3gpp_29.500.h"
#include "3gpp_29.502.h"
#include "3gpp_conversions.hpp"
......@@ -45,7 +44,7 @@
#include "smf_config.hpp"
#include "smf_context.hpp"
#include "smf_n1.hpp"
#include "smf_n11.hpp"
#include "smf_sbi.hpp"
#include "smf_n2.hpp"
#include "smf_pfcp_association.hpp"
#include "ProblemDetails.h"
......@@ -104,11 +103,28 @@ int session_create_sm_context_procedure::run(
Logger::smf_app().info("Perform a procedure - Create SM Context Request");
// TODO check if compatible with ongoing procedures if any
pfcp::node_id_t up_node_id = {};
snssai_t snssai = sm_context_req->req.get_snssai();
std::string dnn = sm_context_req->req.get_dnn();
// if (not pfcp_associations::get_instance().select_up_node(
// up_node_id, NODE_SELECTION_CRITERIA_MIN_PFCP_SESSIONS)) {
if (not pfcp_associations::get_instance().select_up_node(
up_node_id, NODE_SELECTION_CRITERIA_MIN_PFCP_SESSIONS)) {
up_node_id, snssai, dnn)) {
sm_context_resp->res.set_cause(
PDU_SESSION_APPLICATION_ERROR_PEER_NOT_RESPONDING);
return RETURNerror;
} else {
// Store UPF node
std::shared_ptr<smf_context_ref> scf = {};
if (smf_app_inst->is_scid_2_smf_context(sm_context_req->scid)) {
scf = smf_app_inst->scid_2_smf_context(sm_context_req->scid);
scf.get()->upf_node_id = up_node_id;
} else {
Logger::smf_app().warn(
"SM Context associated with this id " SCID_FMT " does not exit!",
sm_context_req->scid);
// TODO:
}
}
//-------------------
......@@ -427,7 +443,7 @@ void session_create_sm_context_procedure::handle_itti_msg(
fmt::format(
NAMF_COMMUNICATION_N1N2_MESSAGE_TRANSFER_URL, supi_str.c_str());
n11_triggered_pending->res.set_amf_url(url);
Logger::smf_n11().debug(
Logger::smf_app().debug(
"N1N2MessageTransfer will be sent to AMF with URL: %s", url.c_str());
// Fill the json part
......@@ -479,7 +495,7 @@ void session_create_sm_context_procedure::handle_itti_msg(
int ret = itti_inst->send_msg(n11_triggered_pending);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N11",
"Could not send ITTI message %s to task TASK_SMF_SBI",
n11_triggered_pending->get_msg_name());
}
}
......@@ -498,14 +514,34 @@ int session_update_sm_context_procedure::run(
Logger::smf_app().info("Perform a procedure - Update SM Context Request");
// TODO check if compatible with ongoing procedures if any
pfcp::node_id_t up_node_id = {};
if (not pfcp_associations::get_instance().select_up_node(
up_node_id, NODE_SELECTION_CRITERIA_MIN_PFCP_SESSIONS)) {
sm_context_resp->res.set_cause(
PDU_SESSION_APPLICATION_ERROR_PEER_NOT_RESPONDING);
Logger::smf_app().info("[SMF Procedure] REMOTE_PEER_NOT_RESPONDING");
return RETURNerror;
// Get UPF node
std::shared_ptr<smf_context_ref> scf = {};
scid_t scid = {};
try {
scid = std::stoi(sm_context_req->scid);
} catch (const std::exception& err) {
Logger::smf_app().warn(
"SM Context associated with this id %s does not exit!",
sm_context_req->scid);
}
if (smf_app_inst->is_scid_2_smf_context(scid)) {
scf = smf_app_inst->scid_2_smf_context(scid);
up_node_id = scf.get()->upf_node_id;
} else {
Logger::smf_app().warn(
"SM Context associated with this id " SCID_FMT " does not exit!", scid);
// TODO:
}
/* if (not pfcp_associations::get_instance().select_up_node(
up_node_id, NODE_SELECTION_CRITERIA_MIN_PFCP_SESSIONS)) {
sm_context_resp->res.set_cause(
PDU_SESSION_APPLICATION_ERROR_PEER_NOT_RESPONDING);
Logger::smf_app().info("[SMF Procedure] REMOTE_PEER_NOT_RESPONDING");
return RETURNerror;
}
*/
//-------------------
n11_trigger = sm_context_req;
n11_triggered_pending = sm_context_resp;
......@@ -1269,14 +1305,33 @@ int session_release_sm_context_procedure::run(
Logger::smf_app().info("Release SM Context Request");
// TODO check if compatible with ongoing procedures if any
pfcp::node_id_t up_node_id = {};
if (not pfcp_associations::get_instance().select_up_node(
up_node_id, NODE_SELECTION_CRITERIA_MIN_PFCP_SESSIONS)) {
sm_context_res->res.set_cause(
PDU_SESSION_APPLICATION_ERROR_PEER_NOT_RESPONDING);
Logger::smf_app().info("REMOTE_PEER_NOT_RESPONDING");
return RETURNerror;
// Get UPF node
std::shared_ptr<smf_context_ref> scf = {};
scid_t scid = {};
try {
scid = std::stoi(sm_context_req->scid);
} catch (const std::exception& err) {
Logger::smf_app().warn(
"SM Context associated with this id %s does not exit!",
sm_context_req->scid);
}
if (smf_app_inst->is_scid_2_smf_context(scid)) {
scf = smf_app_inst->scid_2_smf_context(scid);
up_node_id = scf.get()->upf_node_id;
} else {
Logger::smf_app().warn(
"SM Context associated with this id " SCID_FMT " does not exit!", scid);
// TODO:
}
/* if (not pfcp_associations::get_instance().select_up_node(
up_node_id, NODE_SELECTION_CRITERIA_MIN_PFCP_SESSIONS)) {
sm_context_res->res.set_cause(
PDU_SESSION_APPLICATION_ERROR_PEER_NOT_RESPONDING);
Logger::smf_app().info("REMOTE_PEER_NOT_RESPONDING");
return RETURNerror;
}
*/
//-------------------
n11_trigger = sm_context_req;
n11_triggered_pending = sm_context_res;
......
......@@ -417,6 +417,7 @@ class smf_profile : public nf_profile {
class upf_profile : public nf_profile {
public:
upf_profile() : nf_profile() { // custom_info = {};
nf_type = "UPF";
}
upf_profile(const std::string& id) : nf_profile(id) { // custom_info = {};
......
......@@ -19,15 +19,15 @@
* contact@openairinterface.org
*/
/*! \file smf_n11.hpp
/*! \file smf_sbi.hpp
\author Lionel GAUTHIER, Tien-Thinh NGUYEN
\company Eurecom
\date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/
#ifndef FILE_SMF_N11_HPP_SEEN
#define FILE_SMF_N11_HPP_SEEN
#ifndef FILE_SMF_SBI_HPP_SEEN
#define FILE_SMF_SBI_HPP_SEEN
#include <map>
#include <thread>
......@@ -39,17 +39,17 @@
namespace smf {
#define TASK_SMF_N11_TIMEOUT_NRF_HEARTBEAT_REQUEST 1
#define TASK_SMF_SBI_TIMEOUT_NRF_HEARTBEAT_REQUEST 1
class smf_n11 {
class smf_sbi {
private:
std::thread::id thread_id;
std::thread thread;
public:
smf_n11();
smf_n11(smf_n11 const&) = delete;
void operator=(smf_n11 const&) = delete;
smf_sbi();
smf_sbi(smf_sbi const&) = delete;
void operator=(smf_sbi const&) = delete;
/*
* Send N1N2 Message Transfer Request to AMF
......@@ -141,6 +141,27 @@ class smf_n11 {
* @return pointer to the created curl
*/
CURL* curl_create_handle(event_notification& ev_notif, std::string* data);
/*
* Get SM subscription data from UDM
* @param [const supi64_t &] supi
* @param [const std::string &] dnn
* @param [const snssai_t &] snssai
* @param [std::shared_ptr<session_management_subscription>] subscription
* @return bool: True if successful, otherwise false
*
*/
bool get_sm_data(
const supi64_t& supi, const std::string& dnn, const snssai_t& snssai,
std::shared_ptr<session_management_subscription> subscription);
/*
* Subscribe to be notify from UDM
* @param []
* @return void
*
*/
void subscribe_sm_data();
};
} // namespace smf
#endif /* FILE_SMF_N11_HPP_SEEN */
#endif /* FILE_SMF_SBI_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