Commit 805b31e2 authored by kharade's avatar kharade

Basic NF registration completed

parent 0413aac0
......@@ -23,6 +23,7 @@ UDM =
# STRING, {"yes", "no"},
USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if UDM will relying on a DNS to resolve UDR's FQDN
USE_HTTP2 = "@USE_HTTP2@"; # Set to yes to enable HTTP2 for AUSF server
REGISTER_NRF = "@REGISTER_NRF@"; # Set to 'yes' if UDM resgisters to an NRF
}
UDR:{
......@@ -31,5 +32,12 @@ UDM =
API_VERSION = "@UDR_VERSION_NB@"; # YOUR API VERSION FOR UDR CONFIG HERE
FQDN = "@UDR_FQDN@" # YOUR UDR FQDN CONFIG HERE
};
NRF :
{
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 HERE
FQDN = "@NRF_FQDN@"; # YOUR NRF FQDN HERE
};
};
\ No newline at end of file
......@@ -7,9 +7,14 @@ SBI_PORT=${SBI_PORT:-80}
UDR_PORT=${UDR_PORT:-80}
SBI_HTTP2_PORT=${SBI_HTTP2_PORT:-8080}
USE_HTTP2=${USE_HTTP2:-no}
REGISTER_NRF=${REGISTER_NRF:-no}
NRF_PORT=${NRF_PORT:-80}
NRF_API_VERSION=${NRF_API_VERSION:-v1}
NRF_FQDN=${NRF_FQDN:-oai-nrf}
if [[ ${USE_FQDN_DNS} == "yes" ]];then
UDR_IP_ADDRESS=${UDR_IP_ADDRESS:-0.0.0.0}
NRF_IPV4_ADDRESS=${NRF_IPV4_ADDRESS:-0.0.0.0}
fi
......
{
"files.associations": {
"cstdlib": "cpp",
"algorithm": "cpp",
"*.h++": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"chrono": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"functional": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"ratio": "cpp",
"regex": "cpp",
"set": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cfenv": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp"
}
}
\ 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
*/
#ifndef FILE_3GPP_29_510_nssf_SEEN
#define FILE_3GPP_29_510_nssf_SEEN
#include <vector>
#include <nlohmann/json.hpp>
// Section 28.4, TS23.003
typedef struct s_nssai {
uint8_t sST;
std::string sD;
s_nssai(const uint8_t& sst, const std::string sd) : sST(sst), sD(sd) {}
s_nssai() : sST(), sD() {}
s_nssai(const s_nssai& p) : sST(p.sST), sD(p.sD) {}
bool operator==(const struct s_nssai& s) const {
if ((s.sST == this->sST) && (s.sD.compare(this->sD) == 0)) {
return true;
} else {
return false;
}
}
s_nssai& operator=(const s_nssai& s) {
sST = s.sST;
sD = s.sD;
return *this;
}
} snssai_t;
typedef struct dnai_s {
} dnai_t;
typedef struct patch_item_s {
std::string op;
std::string path;
// std::string from;
std::string value;
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data["op"] = op;
json_data["path"] = path;
json_data["value"] = value;
return json_data;
}
} patch_item_t;
#define UDM_CURL_TIMEOUT_MS 100L
#define NNRF_NFM_BASE "/nnrf-nfm/"
#define UDM_NF_REGISTER_URL "/nf-instances/"
#endif
\ No newline at end of file
......@@ -71,6 +71,7 @@ void Logger::_init(
m_udm_ueau = new _Logger("udm_ueau", m_sinks, ss.str().c_str());
m_udm_uecm = new _Logger("udm_uecm", m_sinks, ss.str().c_str());
m_udm_sdm = new _Logger("udm_sdm", m_sinks, ss.str().c_str());
m_udm_nrf = new _Logger("udm_nrf", m_sinks, ss.str().c_str());
m_udm_server = new _Logger("udm_server", m_sinks, ss.str().c_str());
m_udm_app = new _Logger("udm_app", m_sinks, ss.str().c_str());
}
......
......@@ -88,6 +88,7 @@ class Logger {
static _Logger& udm_uecm() { return *singleton().m_udm_uecm; }
static _Logger& udm_ee() { return *singleton().m_udm_ee; }
static _Logger& udm_sdm() { return *singleton().m_udm_sdm; }
static _Logger& udm_nrf() { return *singleton().m_udm_nrf; }
static _Logger& udm_server() { return *singleton().m_udm_server; }
static _Logger& udm_app() { return *singleton().m_udm_app; }
......@@ -113,6 +114,7 @@ class Logger {
_Logger* m_udm_uecm;
_Logger* m_udm_ee;
_Logger* m_udm_sdm;
_Logger* m_udm_nrf;
_Logger* m_udm_server;
_Logger* m_udm_app;
};
......
......@@ -123,4 +123,42 @@ enum http_response_codes_e {
HTTP_RESPONSE_CODE_GATEWAY_TIMEOUT = 504
};
typedef struct supi_range_s {
std::string start;
std::string end;
std::string pattern;
} supi_range_t;
typedef struct supi_range_udm_info_item_s {
supi_range_t supi_range;
} supi_range_udm_info_item_t;
typedef struct identity_range_s {
std::string start;
std::string end;
std::string pattern;
} identity_range_t;
typedef struct identity_range_udm_info_item_s {
identity_range_t identity_range;
} identity_range_udm_info_item_t;
typedef struct internal_grpid_s {
std::string start;
std::string end;
std::string pattern;
} internal_grpid_range_t;
typedef struct internal_grpid_udm_info_item_s {
internal_grpid_range_t int_grpid_range;
} internal_grpid_range_udm_info_item_t;
typedef struct udm_info_s {
std::string groupid;
std::vector<supi_range_udm_info_item_t> supi_ranges;
std::vector<identity_range_udm_info_item_t> gpsi_ranges;
std::vector<identity_range_udm_info_item_t> ext_grp_id_ranges;
std::vector<std::string> routing_indicators;
std::vector<internal_grpid_range_udm_info_item_t> int_grp_id_ranges;
} udm_info_t;
#endif
......@@ -28,6 +28,7 @@ bool fqdn::resolve(
const std::string& host_name, std::string& address, uint32_t& port,
uint8_t& addr_type, const std::string& protocol) {
try {
Logger::udm_app().debug("Resolving DNS:- %s", host_name.c_str());
boost::asio::io_context io_context = {};
boost::asio::ip::tcp::resolver resolver{io_context};
......
......@@ -32,6 +32,8 @@ add_library (UDM STATIC
udm_client.cpp
udm_config.cpp
udm_event.cpp
udm_profile.cpp
udm_nrf.cpp
)
......@@ -40,6 +40,7 @@
#include <boost/uuid/uuid_io.hpp>
#include <chrono>
#include "udm_nrf.hpp"
#include "logger.hpp"
#include "udm_client.hpp"
#include "udm_config.hpp"
......@@ -61,6 +62,7 @@ using namespace oai::udm::config;
extern udm_app* udm_app_inst;
extern udm_config udm_cfg;
udm_nrf* udm_nrf_inst = nullptr;
udm_client* udm_client_inst = nullptr;
//------------------------------------------------------------------------------
......@@ -72,7 +74,18 @@ udm_app::udm_app(const std::string& config_file) : event_sub() {
Logger::udm_app().error("Cannot create UDM APP: %s", e.what());
throw;
}
// TODO: Register to NRF
// Register to NRF
if (udm_cfg.register_nrf) {
try {
udm_nrf_inst = new udm_nrf();
udm_nrf_inst->register_to_nrf();
Logger::udm_app().info("NRF TASK Created ");
} catch (std::exception& e) {
Logger::udm_app().error("Cannot create NRF TASK: %s", e.what());
throw;
}
}
// Subscribe to UE Loss of Connectivity Status signal
loss_of_connectivity_connection = event_sub.subscribe_loss_of_connectivity(
......
......@@ -146,6 +146,14 @@ int udm_config::load(const std::string& config_file) {
use_fqdn_dns = false;
}
support_features.lookupValue(
UDM_CONFIG_STRING_SUPPORTED_FEATURES_REGISTER_NRF, opt);
if (boost::iequals(opt, "yes")) {
register_nrf = true;
} else {
register_nrf = false;
}
support_features.lookupValue(
UDM_CONFIG_STRING_SUPPORT_FEATURES_USE_HTTP2, opt);
if (boost::iequals(opt, "yes")) {
......@@ -221,6 +229,63 @@ int udm_config::load(const std::string& config_file) {
Logger::udm_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror;
}
// NRF
if (register_nrf) {
try {
std::string astring = {};
const Setting& nrf_cfg = udm_cfg[UDM_CONFIG_STRING_NRF];
struct in_addr nrf_ipv4_addr = {};
unsigned int nrf_port = 0;
std::string nrf_api_version = {};
if (!use_fqdn_dns) {
nrf_cfg.lookupValue(UDM_CONFIG_STRING_NRF_IPV4_ADDRESS, astring);
IPV4_STR_ADDR_TO_INADDR(
util::trim(astring).c_str(), nrf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !");
nrf_addr.ipv4_addr = nrf_ipv4_addr;
if (!(nrf_cfg.lookupValue(UDM_CONFIG_STRING_NRF_PORT, nrf_port))) {
Logger::udm_app().error(UDM_CONFIG_STRING_NRF_PORT "failed");
throw(UDM_CONFIG_STRING_NRF_PORT "failed");
}
nrf_addr.port = nrf_port;
if (!(nrf_cfg.lookupValue(
UDM_CONFIG_STRING_API_VERSION, nrf_api_version))) {
Logger::udm_app().error(UDM_CONFIG_STRING_API_VERSION "failed");
throw(UDM_CONFIG_STRING_API_VERSION "failed");
}
nrf_addr.api_version = nrf_api_version;
} else {
nrf_cfg.lookupValue(UDM_CONFIG_STRING_FQDN_DNS, astring);
uint8_t addr_type = {0};
std::string address = {};
fqdn::resolve(astring, address, nrf_port, addr_type);
if (addr_type != 0) { // IPv6
// TODO:
throw("DO NOT SUPPORT IPV6 ADDR FOR NRF!");
} else { // IPv4
IPV4_STR_ADDR_TO_INADDR(
util::trim(address).c_str(), nrf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !");
nrf_addr.ipv4_addr = nrf_ipv4_addr;
// We hardcode nrf port from config for the moment
if (!(nrf_cfg.lookupValue(UDM_CONFIG_STRING_NRF_PORT, nrf_port))) {
Logger::udm_app().error(UDM_CONFIG_STRING_NRF_PORT "failed");
throw(UDM_CONFIG_STRING_NRF_PORT "failed");
}
nrf_addr.port = nrf_port;
nrf_addr.api_version = "v1"; // TODO: to get API version from DNS
nrf_addr.fqdn = astring;
}
}
} catch (const SettingNotFoundException& nfex) {
Logger::udm_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror;
}
}
return RETURNok;
}
......@@ -242,6 +307,8 @@ void udm_config::display() {
Logger::config().info(
" Api Version...........: %s", sbi.api_version.c_str());
Logger::config().info("- Supported Features:");
Logger::config().info(
" REGISTER NRF .. ......: %s", register_nrf ? "Yes" : "No");
Logger::config().info(
" Use FQDN ..............: %s", use_fqdn_dns ? "Yes" : "No");
Logger::config().info(
......@@ -254,6 +321,13 @@ void udm_config::display() {
Logger::config().info(" Port..................: %lu ", udr_addr.port);
Logger::config().info(
" API version...........: %s", udr_addr.api_version.c_str());
Logger::config().info("- NRF:");
Logger::config().info(
" IPv4 Addr ............: %s",
inet_ntoa(*((struct in_addr*) &nrf_addr.ipv4_addr)));
Logger::config().info(" Port .................: %lu ", nrf_addr.port);
Logger::config().info(
" API version ..........: %s", nrf_addr.api_version.c_str());
if (use_fqdn_dns)
Logger::config().info(
" FQDN..................: %s", udr_addr.fqdn.c_str());
......
......@@ -62,8 +62,13 @@
#define UDM_CONFIG_STRING_UDR_IPV4_ADDRESS "IPV4_ADDRESS"
#define UDM_CONFIG_STRING_UDR_PORT "PORT"
#define UDM_CONFIG_STRING_NRF "NRF"
#define UDM_CONFIG_STRING_NRF_IPV4_ADDRESS "IPV4_ADDRESS"
#define UDM_CONFIG_STRING_NRF_PORT "PORT"
#define UDM_CONFIG_STRING_SUPPORT_FEATURES "SUPPORT_FEATURES"
#define UDM_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS "USE_FQDN_DNS"
#define UDM_CONFIG_STRING_SUPPORTED_FEATURES_REGISTER_NRF "REGISTER_NRF"
#define UDM_CONFIG_STRING_SUPPORT_FEATURES_USE_HTTP2 "USE_HTTP2"
#define UDM_CONFIG_STRING_FQDN_DNS "FQDN"
......@@ -103,6 +108,14 @@ class udm_config {
std::string fqdn;
} udr_addr;
struct {
struct in_addr ipv4_addr;
unsigned int port;
std::string api_version;
std::string fqdn;
} nrf_addr;
bool register_nrf;
bool use_fqdn_dns;
bool use_http2;
};
......
/*
* 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 udm_nrf.cpp
\brief
\author Tien-Thinh NGUYEN Rohan Kharade
\company Eurecom
\date 2020
\email:
*/
#include "udm_nrf.hpp"
#include "udm_app.hpp"
#include "udm_profile.hpp"
#include "udm_client.hpp"
#include <boost/uuid/random_generator.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <curl/curl.h>
#include <pistache/http.h>
#include <pistache/mime.h>
#include <nlohmann/json.hpp>
#include <stdexcept>
#include "logger.hpp"
#include "udm.h"
using namespace oai::udm::app;
using namespace oai::udm::config;
// using json = nlohmann::json;
extern udm_config udm_cfg;
extern udm_nrf* udm_nrf_inst;
udm_client* udm_client_instance = nullptr;
//------------------------------------------------------------------------------
udm_nrf::udm_nrf() {}
//---------------------------------------------------------------------------------------------
void udm_nrf::get_udm_api_root(std::string& api_root) {
api_root =
std::string(inet_ntoa(*((struct in_addr*) &udm_cfg.nrf_addr.ipv4_addr))) +
":" + std::to_string(udm_cfg.nrf_addr.port) + NNRF_NFM_BASE +
udm_cfg.nrf_addr.api_version;
}
//---------------------------------------------------------------------------------------------
void udm_nrf::generate_udm_profile(
udm_profile& udm_nf_profile, std::string& udm_instance_id) {
// TODO: remove hardcoded values
udm_nf_profile.set_nf_instance_id(udm_instance_id);
udm_nf_profile.set_nf_instance_name("OAI-UDM");
udm_nf_profile.set_fqdn("oai-udm");
udm_nf_profile.set_nf_type("UDM");
udm_nf_profile.set_nf_status("REGISTERED");
udm_nf_profile.set_nf_heartBeat_timer(50);
udm_nf_profile.set_nf_priority(1);
udm_nf_profile.set_nf_capacity(100);
// udm_nf_profile.set_fqdn(udm_cfg.fqdn);
udm_nf_profile.add_nf_ipv4_addresses(udm_cfg.sbi.addr4); // N4's Addr
// UDM info (Hardcoded for now)
// ToDo: If none of these parameters are provided, the UDM can serve any
// external group and any SUPI or GPSI managed by the PLMN of the UDM
// instance. If "supiRanges", "gpsiRanges" and
// "externalGroupIdentifiersRanges" attributes are absent, and "groupId" is
// present, the SUPIs / GPSIs / ExternalGroups served by this UDM instance is
// determined by the NRF (see 3GPP TS 23.501 [2], clause 6.2.6.2)
udm_info_t udm_info_item;
udm_info_item.groupid = "oai-udm-testgroupid";
udm_info_item.routing_indicators.push_back("0210");
udm_info_item.routing_indicators.push_back("9876");
supi_range_udm_info_item_t supi_ranges;
supi_ranges.supi_range.start = "208950000000031";
supi_ranges.supi_range.pattern = "^imsi-20895[31-131]{10}$";
supi_ranges.supi_range.end = "208950000000131";
udm_info_item.supi_ranges.push_back(supi_ranges);
identity_range_udm_info_item_t gpsi_ranges;
gpsi_ranges.identity_range.start = "752740000";
gpsi_ranges.identity_range.pattern = "^gpsi-75274[0-9]{4}$";
gpsi_ranges.identity_range.end = "752749999";
udm_info_item.gpsi_ranges.push_back(gpsi_ranges);
udm_nf_profile.set_udm_info(udm_info_item);
// ToDo:- Add remaining fields
// identity_range_udm_info_item_t ext_grp_id_ranges;
// internal_grpid_range_udm_info_item_t int_grp_id_ranges;
// UDM info item end
udm_nf_profile.display();
}
//---------------------------------------------------------------------------------------------
void udm_nrf::register_to_nrf() {
// generate UUID
std::string udm_instance_id; // UDM instance id
udm_instance_id = to_string(boost::uuids::random_generator()());
nlohmann::json response_data = {};
// Generate NF Profile
udm_profile udm_nf_profile;
generate_udm_profile(udm_nf_profile, udm_instance_id);
// Send NF registeration request
std::string udm_api_root = {};
std::string response = {};
std::string method = {"PUT"};
get_udm_api_root(udm_api_root);
std::string remoteUri = udm_api_root + UDM_NF_REGISTER_URL + udm_instance_id;
nlohmann::json json_data = {};
udm_nf_profile.to_json(json_data);
Logger::udm_nrf().info("Sending NF registeration request");
udm_client_instance->curl_http_client(
remoteUri, method, response, json_data.dump().c_str());
try {
response_data = nlohmann::json::parse(response);
if (response_data["nfStatus"].dump().c_str() == "REGISTERED") {
// ToDo Trigger NF heartbeats
}
} catch (nlohmann::json::exception& e) {
Logger::udm_nrf().info("NF registeration procedure failed");
}
}
//---------------------------------------------------------------------------------------------
/*
* 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 udm_client.hpp
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2020
\email:
*/
#ifndef FILE_UDM_NRF_SEEN
#define FILE_UDM_NRF_SEEN
#include <map>
#include <thread>
#include <curl/curl.h>
#include "logger.hpp"
#include "udm_config.hpp"
#include "udm_profile.hpp"
namespace oai {
namespace udm {
namespace app {
class udm_nrf {
private:
public:
udm_profile udm_nf_profile; // UDM profile
std::string udm_instance_id; // UDM instance id
// timer_id_t timer_udm_heartbeat;
udm_nrf();
udm_nrf(udm_nrf const&) = delete;
void operator=(udm_nrf const&) = delete;
void generate_uuid();
/*
* Generate a UDM profile for this instance
* @param [void]
* @return void
*/
void generate_udm_profile(
udm_profile& udm_nf_profile, std::string& udm_instance_id);
/*
* Trigger NF instance registration to NRF
* @param [void]
* @return void
*/
void register_to_nrf();
/*
* Get udm API Root
* @param [std::string& ] api_root: udm's API Root
* @return void
*/
void get_udm_api_root(std::string& api_root);
};
} // namespace app
} // namespace udm
} // namespace oai
#endif /* FILE_UDM_NRF_SEEN */
This diff is collapsed.
/*
* 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 udm_profile.hpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2021
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#ifndef FILE_UDM_PROFILE_HPP_SEEN
#define FILE_UDM_PROFILE_HPP_SEEN
#include <arpa/inet.h>
#include <netinet/in.h>
#include <nlohmann/json.hpp>
#include <shared_mutex>
#include <vector>
#include "logger.hpp"
#include "3gpp_29.510.h"
#include "udm.h"
namespace oai {
namespace udm {
namespace app {
class udm_profile : public std::enable_shared_from_this<udm_profile> {
public:
udm_profile()
: nf_type("NF_TYPE_UNKNOWN"),
heartBeat_timer(0),
snssais(),
fqdn(),
ipv4_addresses(),
priority(0),
capacity(0) {
nf_instance_name = {};
nf_status = {};
}
udm_profile(const std::string& id)
: nf_instance_id(id),
heartBeat_timer(0),
snssais(),
fqdn(),
ipv4_addresses(),
priority(0),
capacity(0),
nf_type("NF_TYPE_UNKNOWN") {
nf_instance_name = {};
nf_status = {};
}
udm_profile& operator=(const udm_profile& s) {
nf_instance_id = s.nf_instance_id;
heartBeat_timer = s.heartBeat_timer;
snssais = s.snssais;
fqdn = s.fqdn;
ipv4_addresses = s.ipv4_addresses;
priority = s.priority;
capacity = s.capacity;
nf_type = s.nf_type;
nf_instance_name = s.nf_instance_name;
nf_status = s.nf_status;
udm_info = s.udm_info;
return *this;
}
// udm_profile(udm_profile &b) = delete;
virtual ~udm_profile() {
// Logger::udm_app().debug("Delete udm Profile instance...");
}
/*
* Set NF instance ID
* @param [const std::string &] instance_id: instance id
* @return void
*/
void set_nf_instance_id(const std::string& instance_id);
/*
* Get NF instance ID
* @param [std::string &] instance_id: store instance id
* @return void:
*/
void get_nf_instance_id(std::string& instance_id) const;
/*
* Get NF instance ID
* @param [std::string &] instance_id: store instance id
* @return void:
*/
std::string get_nf_instance_id() const;
/*
* Set NF instance name
* @param [const std::string &] instance_name: instance name
* @return void
*/
void set_nf_instance_name(const std::string& instance_name);
/*
* Get NF instance ID
* @param [std::string &] instance_name: store instance name
* @return void:
*/
void get_nf_instance_name(std::string& instance_name) const;
/*
* Get NF instance name
* @param
* @return [std::string] instance name
*/
std::string get_nf_instance_name() const;
/*
* Set NF instance status
* @param [const std::string &] status: instance status
* @return void
*/
void set_nf_status(const std::string& status);
/*
* Get NF instance status
* @param [std::string &] status: store instance status
* @return void:
*/
void get_nf_status(std::string& status) const;
/*
* Get NF status
* @param
* @return [std::string] instance status
*/
std::string get_nf_status() const;
/*
* Get NF type
* @param
* @return [std::string] nf type
*/
std::string get_nf_type() const;
/*
* Set NF type
* @param [const nf_type_t &] type: nf type
* @return void
*/
void set_nf_type(const std::string& type);
/*
* Set NF instance heartBeat_timer
* @param [const std::string &] timer: heartBeat_timer
* @return void
*/
void set_nf_heartBeat_timer(const int32_t& timer);
/*
* Get NF instance heartBeat_timer
* @param [std::string &] timer: store heartBeat_timer
* @return void:
*/
void get_nf_heartBeat_timer(int32_t& timer) const;
/*
* Get NF heartBeat_timer
* @param void
* @return heartBeat_timer
*/
int32_t get_nf_heartBeat_timer() const;
/*
* Set NF instance priority
* @param [const uint16_t] p: instance priority
* @return void
*/
void set_nf_priority(const uint16_t& p);
/*
* Get NF instance priority
* @param [uint16_t] p: store instance priority
* @return void:
*/
void get_nf_priority(uint16_t& p) const;
/*
* Get NF instance priority
* @param void
* @return [uint16_t] instance priority
*/
uint16_t get_nf_priority() const;
/*
* Set NF instance capacity
* @param [const uint16_t] c: instance capacity
* @return void
*/
void set_nf_capacity(const uint16_t& c);
/*
* Get NF instance priority
* @param [uint16_t ] c: store instance capacity
* @return void:
*/
void get_nf_capacity(uint16_t& c) const;
/*
* Get NF instance priority
* @param void
* @return [uint16_t ] instance capacity
*/
uint16_t get_nf_capacity() const;
/*
* Set NF instance SNSSAIs
* @param [std::vector<snssai_t> &] s: SNSSAIs
* @return void
*/
void set_nf_snssais(const std::vector<snssai_t>& s);
/*
* Add SNSSAI
* @param [snssai_t &] s: SNSSAI
* @return void
*/
void add_snssai(const snssai_t& s);
/*
* Get NF instance SNSSAIs
* @param [std::vector<snssai_t> &] s: store instance's SNSSAIs
* @return void:
*/
void get_nf_snssais(std::vector<snssai_t>& s) const;
/*
* Get NF fqdn
* @param
* @return [std::string] nf fqdn
*/
std::string get_fqdn() const;
/*
* Set NF fqdn
* @param [const fqdn_t &] fqdn: nf fqdn
* @return void
*/
void set_fqdn(const std::string& fqdn);
/*
* Set NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: ipv4_addresses
* @return void
*/
void set_nf_ipv4_addresses(const std::vector<struct in_addr>& a);
/*
* Add an IPv4 address to the list of addresses
* @param [const struct in_addr &] a: ipv4_address
* @return void
*/
void add_nf_ipv4_addresses(const struct in_addr& a);
/*
* Get NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: store instance's ipv4_addresses
* @return void:
*/
void get_nf_ipv4_addresses(std::vector<struct in_addr>& a) const;
/*
* Set udm info
* @param [udm_info_t &] s: udm info
* @return void
*/
void set_udm_info(const udm_info_t& s);
/*
* Get NF instance udm info
* @param [udm_info_t &] s: store instance's udm info
* @return void:
*/
void get_udm_info(udm_info_t& s) const;
/*
* Print related-information for NF profile
* @param void
* @return void:
*/
void display() const;
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
void to_json(nlohmann::json& data) const;
/*
* Covert from a json represetation to udm profile
* @param [nlohmann::json &] data: Json data
* @return void
*/
void from_json(const nlohmann::json& data);
/*
* Handle heartbeart timeout event
* @param [uint64_t] ms: current time
* @return void
*/
void handle_heartbeart_timeout(uint64_t ms);
protected:
// From NFProfile (Section 6.1.6.2.2@3GPP TS 29.510 V16.0.0 (2019-06))
std::string nf_instance_id;
std::string nf_instance_name;
std::string nf_type;
std::string nf_status;
int32_t heartBeat_timer;
std::vector<snssai_t> snssais;
std::string fqdn;
std::vector<struct in_addr> ipv4_addresses;
uint16_t priority;
uint16_t capacity;
udm_info_t udm_info;
};
} // namespace app
} // namespace udm
} // namespace oai
#endif
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