Commit 5f2f4eb8 authored by Fang-WANG's avatar Fang-WANG

subscribe 6 NFs and handle notify OK

parent 0dba68d6
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# CI artifacts
archives
src/oai_rules_result*
test_results_oai_smf.html
build/*
......@@ -412,20 +412,20 @@ check_install_smf_deps() {
#install_fmt $1
#ret=$?;[[ $ret -ne 0 ]] && return $ret
install_spdlog_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
#install_spdlog_from_git $1 $2
#ret=$?;[[ $ret -ne 0 ]] && return $ret
install_fb_folly_from_source $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
# install_fb_folly_from_source $1 $2
#ret=$?;[[ $ret -ne 0 ]] && return $ret
install_pistache_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
# install_pistache_from_git $1 $2
#ret=$?;[[ $ret -ne 0 ]] && return $ret
install_nlohmann_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
#install_nlohmann_from_git $1 $2
#ret=$?;[[ $ret -ne 0 ]] && return $ret
install_nghttp2_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
#install_nghttp2_from_git $1 $2
#ret=$?;[[ $ret -ne 0 ]] && return $ret
return 0
}
......
################################################################################
# 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
################################################################################
SMF =
{
INSTANCE = 10; # 0 is the default
PID_DIRECTORY = "/var/run/Haiwen"; # /var/run is the default
INTERFACES :
{
N4 :
{
# SMF binded interface for N4 communication (UPF)
INTERFACE_NAME = ""; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read";
PORT = 80;
};
SBI :
{
# SMF binded interface for SBI interface (e.g., communication with AMF, UDM)
INTERFACE_NAME = "ens37"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read";
PORT = 9889; # YOUR NETWORK CONFIG HERE (default: 80)
HTTP2_PORT = 9890; # YOUR NETWORK CONFIG HERE
API_VERSION = "v1"; # YOUR SMF API VERSION CONFIG HERE
};
};
# Pool of UE assigned IP addresses
# Do not make IP pools overlap
# first IPv4 address X.Y.Z.1 is reserved for GTP network device on UPF
IP_ADDRESS_POOL :
{
IPV4_LIST = (
{RANGE = "192.169.0.200 - 192.169.0.253";}, # STRING, IPv4 RANGE IP_start - IP_end, YOUR NETWORK CONFIG HERE.
{RANGE = "192.169.0.3 - 192.169.255.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.
{PREFIX = "3001:1:2::/64";} # STRING, IPv6 prefix, YOUR NETWORK CONFIG HERE.
);
};
DNN_LIST = (
# IPV4_POOL, IPV6_POOL are index in IPV4_LIST, IPV6_LIST, PDU_SESSION_TYPE choice in {IPv4, IPv6, IPv4v6}
{DNN_NI = "IMS"; PDU_SESSION_TYPE = "IPv4v6"; IPV4_POOL = 0; IPV6_POOL = 0},
{DNN_NI = "internet"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 1; IPV6_POOL = -1},
{DNN_NI = "ctnet"; PDU_SESSION_TYPE = "IPv4v6"; IPV4_POOL = 1; IPV6_POOL = 1}
);
# DNS address communicated to UEs
DEFAULT_DNS_IPV4_ADDRESS = "114.114.114.114"; # YOUR DNS CONFIG HERE
DEFAULT_DNS_SEC_IPV4_ADDRESS = "114.114.114.114"; # YOUR DNS CONFIG HERE
DEFAULT_DNS_IPV6_ADDRESS = "2001:4860:4860::8888"; # YOUR DNS CONFIG HERE
DEFAULT_DNS_SEC_IPV6_ADDRESS = "2001:4860:4860::8844"; # YOUR DNS CONFIG HERE
SUPPORT_FEATURES:
{
# STRING, {"yes", "no"},
REGISTER_NRF = "no"; # Set to yes if SMF resgisters to an NRF
DISCOVER_UPF = "yes"; # Set to yes to enable UPF discovery and selection
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
}
AMF :
{
IPV4_ADDRESS = "0.0.0.0"; # YOUR AMF CONFIG HERE
PORT = 8282; # YOUR AMF CONFIG HERE (default: 80)
API_VERSION = "v2"; # YOUR AMF API VERSION FOR SBI CONFIG HERE
};
UDM :
{
IPV4_ADDRESS = "0.0.0.0"; # YOUR UDM CONFIG HERE
PORT = 8181; # YOUR UDM CONFIG HERE (default: 80)
API_VERSION = "v2"; # YOUR UDM API VERSION FOR SBI CONFIG HERE
};
NRF :
{
IPV4_ADDRESS = "192.168.83.129"; # YOUR NRF CONFIG HERE
PORT = 80; # YOUR NRF CONFIG HERE (default: 80)
API_VERSION = "v1"; # YOUR NRF API VERSION FOR SBI CONFIG HERE
};
UPF_LIST = (
{IPV4_ADDRESS = "0.0.0.0";} # YOUR UPF CONFIG HERE
);
LOCAL_CONFIGURATION :
{
USE_LOCAL_CONFIGURATION = "yes";
SESSION_MANAGEMENT_SUBSCRIPTION_LIST = (
{ NSSAI_SST = 1, NSSAI_SD = "0", DNN = "IMS", DEFAULT_SESSION_TYPE = "IPV4V6", DEFAULT_SSC_MODE = 1,
QOS_PROFILE_5QI = 5, 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 = 1, NSSAI_SD = "0", DNN = "ctnet", DEFAULT_SESSION_TYPE = "IPV4V6", DEFAULT_SSC_MODE = 1,
QOS_PROFILE_5QI = 9, 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 = "100Mbps", SESSION_AMBR_DL = "110Mbps"},
{ NSSAI_SST = 1; NSSAI_SD = "0", DNN = "internet", DEFAULT_SESSION_TYPE = "IPV4", DEFAULT_SSC_MODE = 1,
QOS_PROFILE_5QI = 9, 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 = "100Mbps", SESSION_AMBR_DL = "110Mbps"}
);
};
};
......@@ -410,14 +410,18 @@ void xgpp_conv::data_notification_from_openapi(
dn_msg.set_nf_instance_uri(nd.getNfInstanceUri());
std::shared_ptr<smf::nf_profile> p = {};
Logger::smf_app().debug(
"data_notification_from_openapi NF %s is %s.", nd.getNfProfile().getNfType().c_str(),nd.getEvent().c_str());
// Only support UPF for now
if (nd.getNfProfile().getNfType() == "UPF")
// if (nd.getNfProfile().getNfType() == "UPF")
p = std::make_shared<smf::upf_profile>();
nlohmann::json pj = {};
to_json(pj, nd.getNfProfile());
p.get()->from_json(pj);
// nlohmann::json pj = {};
// to_json(pj, nd.getNfProfile());
// p.get()->from_json(pj);
p.get()->set_nf_type(nd.getNfProfile().getNfType());
p.get()->set_nf_status(nd.getNfProfile().getNfStatus());
dn_msg.set_profile(p);
}
......
......@@ -338,7 +338,7 @@ smf_app::smf_app(const std::string& config_file)
}
try {
smf_n4_inst = new smf_n4();
// smf_n4_inst = new smf_n4();
smf_sbi_inst = new smf_sbi();
} catch (std::exception& e) {
Logger::smf_app().error("Cannot create SMF_APP: %s", e.what());
......@@ -347,15 +347,20 @@ smf_app::smf_app(const std::string& config_file)
// 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();
/*for (std::vector<pfcp::node_id_t>::const_iterator it = smf_cfg.upfs.begin();
it != smf_cfg.upfs.end(); ++it) {
start_upf_association(*it);
}
}*/
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();
trigger_upf_status_notification_subscribe("AMF");
trigger_upf_status_notification_subscribe("SMF");
trigger_upf_status_notification_subscribe("UPF");
trigger_upf_status_notification_subscribe("AUSF");
trigger_upf_status_notification_subscribe("UDR");
trigger_upf_status_notification_subscribe("UDM");
}
// Register to NRF (if this option is enabled)
......@@ -1281,72 +1286,11 @@ bool smf_app::handle_nf_status_notification(
data_notification_msg notification_msg = msg.get()->notification_msg;
std::string event_type;
notification_msg.get_notification_event_type(event_type);
if (event_type.compare("NF_REGISTERED") == 0) {
std::shared_ptr<nf_profile> profile = {};
notification_msg.get_profile(profile);
if (profile.get() != nullptr) {
std::string nf_type = profile.get()->get_nf_type();
if (nf_type.compare("UPF") == 0) { // UPF
upf_info_t upf_info = {};
std::static_pointer_cast<upf_profile>(profile).get()->get_upf_info(
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);
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 = false;
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 {
return false;
}
}
if (event_type.compare("NF_DEREGISTERED") == 0) {
Logger::smf_app().debug(
"This event (%s) has not been supported yet!", event_type);
// TODO: Remove UPF from the list UPFs if received DE-REGISTERED Event
/* std::string nf_instance_uri = {};
notification_msg.get_nf_instance_uri(nf_instance_uri);
std::vector<std::string> split_result;
boost::split(
split_result, nf_instance_uri, boost::is_any_of("/"));
if (split_result.size() > 0) {
std::string instance_id = split_result[split_result.size() -1];
pfcp_associations::get_instance().remove_association(instance_id);
}
*/
}
std::shared_ptr<nf_profile> profile = {};
notification_msg.get_profile(profile);
Logger::smf_app().debug(
"handle_nf_status_notification NF %s is %s !", profile.get()->get_nf_type().c_str(), event_type.c_str());
return true;
}
......@@ -2050,7 +1994,7 @@ void smf_app::trigger_nf_deregistration() {
}
//------------------------------------------------------------------------------
void smf_app::trigger_upf_status_notification_subscribe() {
void smf_app::trigger_upf_status_notification_subscribe(string a) {
Logger::smf_app().debug(
"Send ITTI msg to N11 task to subscribe to UPF status notification "
"from NRF");
......@@ -2066,11 +2010,11 @@ void smf_app::trigger_upf_status_notification_subscribe() {
std::to_string(smf_cfg.sbi.port) + "/nsmf-nfstatus-notify/" +
smf_cfg.sbi_api_version + "/subscriptions";
json_data["subscrCond"]["NfTypeCond"]["nfType"] = "UPF";
json_data["subscrCond"]["NfTypeCond"]["nfType"] = a;
json_data["reqNotifEvents"] = nlohmann::json::array();
json_data["reqNotifEvents"].push_back("NF_REGISTERED");
json_data["reqNotifEvents"].push_back("NF_DEREGISTERED");
json_data["validityTime"] = "20210531T235959";
json_data["validityTime"] = "20220531T235959";
std::string url =
std::string(inet_ntoa(*((struct in_addr*) &smf_cfg.nrf_addr.ipv4_addr))) +
......
......@@ -858,7 +858,7 @@ class smf_app {
* @param [void]
* @return void
*/
void trigger_upf_status_notification_subscribe();
void trigger_upf_status_notification_subscribe(string a);
};
} // namespace smf
#include "smf_config.hpp"
......
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