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

Support NF Services

parent 10c9bccf
......@@ -438,9 +438,7 @@ void NFProfile::unsetPlmnList() {
m_PlmnListIsSet = false;
}
std::vector<Snssai> NFProfile::getSNssais() const {
std::vector<Snssai> s = m_SNssais;
return m_SNssais;
//return s;
}
void NFProfile::setSNssais(std::vector<Snssai> const &value) {
m_SNssais = value;
......@@ -941,9 +939,11 @@ bool NFProfile::nfServicePersistenceIsSet() const {
void NFProfile::unsetNfServicePersistence() {
m_NfServicePersistenceIsSet = false;
}
std::vector<NFService>& NFProfile::getNfServices() {
std::vector<NFService> NFProfile::getNfServices() const {
return m_NfServices;
}
void NFProfile::setNfServices(std::vector<NFService> const &value) {
m_NfServices = value;
m_NfServicesIsSet = true;
......
......@@ -365,7 +365,7 @@ class NFProfile {
/// <summary>
///
/// </summary>
std::vector<NFService>& getNfServices();
std::vector<NFService> getNfServices() const;
void setNfServices(std::vector<NFService> const &value);
bool nfServicesIsSet() const;
void unsetNfServices();
......
......@@ -175,28 +175,28 @@ std::string NFService::getServiceInstanceId() const {
void NFService::setServiceInstanceId(std::string const &value) {
m_ServiceInstanceId = value;
}
ServiceName NFService::getServiceName() const {
std::string NFService::getServiceName() const {
return m_ServiceName;
}
void NFService::setServiceName(ServiceName const &value) {
void NFService::setServiceName(std::string const &value) {
m_ServiceName = value;
}
std::vector<NFServiceVersion>& NFService::getVersions() {
std::vector<NFServiceVersion> NFService::getVersions() {
return m_Versions;
}
void NFService::setVersions(std::vector<NFServiceVersion> const &value) {
m_Versions = value;
}
UriScheme NFService::getScheme() const {
std::string NFService::getScheme() const {
return m_Scheme;
}
void NFService::setScheme(UriScheme const &value) {
void NFService::setScheme(std::string const &value) {
m_Scheme = value;
}
NFServiceStatus NFService::getNfServiceStatus() const {
std::string NFService::getNfServiceStatus() const {
return m_NfServiceStatus;
}
void NFService::setNfServiceStatus(NFServiceStatus const &value) {
void NFService::setNfServiceStatus(std::string const &value) {
m_NfServiceStatus = value;
}
std::string NFService::getFqdn() const {
......
......@@ -56,23 +56,23 @@ class NFService {
/// <summary>
///
/// </summary>
ServiceName getServiceName() const;
void setServiceName(ServiceName const &value);
std::string getServiceName() const;
void setServiceName(std::string const &value);
/// <summary>
///
/// </summary>
std::vector<NFServiceVersion>& getVersions();
std::vector<NFServiceVersion> getVersions();
void setVersions(std::vector<NFServiceVersion> const &value);
/// <summary>
///
/// </summary>
UriScheme getScheme() const;
void setScheme(UriScheme const &value);
std::string getScheme() const;
void setScheme(std::string const &value);
/// <summary>
///
/// </summary>
NFServiceStatus getNfServiceStatus() const;
void setNfServiceStatus(NFServiceStatus const &value);
std::string getNfServiceStatus() const;
void setNfServiceStatus(std::string const &value);
/// <summary>
///
/// </summary>
......@@ -186,13 +186,13 @@ class NFService {
protected:
std::string m_ServiceInstanceId;
ServiceName m_ServiceName;
std::string m_ServiceName;
std::vector<NFServiceVersion> m_Versions;
UriScheme m_Scheme;
std::string m_Scheme;
NFServiceStatus m_NfServiceStatus;
std::string m_NfServiceStatus;
std::string m_Fqdn;
bool m_FqdnIsSet;
......
......@@ -22,15 +22,14 @@
#ifndef FILE_3GPP_29_510_NRF_SEEN
#define FILE_3GPP_29_510_NRF_SEEN
#include "3gpp_23.003.h"
#include <vector>
#include "3gpp_23.003.h"
enum class nf_status_e { REGISTERED = 0, SUSPENDED = 1, UNDISCOVERABLE = 2 };
static const std::vector<std::string> nf_status_e2str = {
"REGISTERED", "SUSPENDED", "UNDISCOVERABLE"};
typedef struct amf_info_s {
std::string amf_set_id;
std::string amf_region_id;
......@@ -51,8 +50,6 @@ typedef struct smf_info_s {
std::vector<snssai_smf_info_item_t> snssai_smf_info_list;
} smf_info_t;
enum subscr_condition_type_e { // TODO: use enum class
UNKNOWN_CONDITION = 0,
NF_INSTANCE_ID_COND = 1,
......@@ -239,4 +236,49 @@ enum notification_event_type_t {
static const std::vector<std::string> notification_event_type_e2str = {
"UNKNOWN EVENT", "NF_REGISTERED", "NF_DEREGISTERED", "NF_PROFILE_CHANGED"};
typedef struct nf_service_version_s {
std::string api_version_in_uri; // apiVersionInUri
std::string api_full_version; // apiFullVersion
nf_service_version_s &operator=(const nf_service_version_s &s) {
api_version_in_uri = s.api_version_in_uri;
api_full_version = s.api_full_version;
}
std::string to_string() const {
std::string s = {};
s.append(", Version (");
s.append("apiVersionInUri: ");
s.append(api_version_in_uri);
s.append(", apiFullVersion: ");
s.append(api_full_version);
s.append(" )");
return s;
}
} nf_service_version_t;
typedef struct nf_service_s {
std::string service_instance_id;
std::string service_name;
std::vector<nf_service_version_t> versions;
std::string scheme;
std::string nf_service_status;
std::string to_string() const {
std::string s = {};
s.append("Service Instance ID: ");
s.append(service_instance_id);
s.append(", Service name: ");
s.append(service_name);
for (auto v : versions) {
s.append(v.to_string());
}
s.append(", Scheme: ");
s.append(scheme);
s.append(", Service status: ");
s.append(nf_service_status);
return s;
}
} nf_service_t;
#endif
......@@ -70,11 +70,9 @@ bool api_conv::profile_api_to_nrf_profile(
Logger::nrf_app().debug("\tHeartBeart timer: %d",
profile.get()->get_nf_heartBeat_timer());
profile.get()->set_nf_priority(api_profile.getPriority());
Logger::nrf_app().debug("\tPriority: %d",
profile.get()->get_nf_priority());
Logger::nrf_app().debug("\tPriority: %d", profile.get()->get_nf_priority());
profile.get()->set_nf_capacity(api_profile.getCapacity());
Logger::nrf_app().debug("\tCapacity: %d",
profile.get()->get_nf_capacity());
Logger::nrf_app().debug("\tCapacity: %d", profile.get()->get_nf_capacity());
// SNSSAIs
std::vector<Snssai> snssai = api_profile.getSNssais();
for (auto s : snssai) {
......@@ -124,8 +122,7 @@ bool api_conv::profile_api_to_nrf_profile(
info.guami_list.push_back(guami);
Logger::nrf_app().debug("\t\tAMF GUAMI, AMF_ID: %s",
guami.amf_id.c_str());
Logger::nrf_app().debug(
"\t\tAMF GUAMI, PLMN (MCC: %s, MNC: %s)",
Logger::nrf_app().debug("\t\tAMF GUAMI, PLMN (MCC: %s, MNC: %s)",
guami.plmn.mcc.c_str(), guami.plmn.mnc.c_str());
}
(std::static_pointer_cast<amf_profile>(profile))
......@@ -148,8 +145,7 @@ bool api_conv::profile_api_to_nrf_profile(
dnn_smf_info_item_t dnn = {};
dnn.dnn = d.getDnn();
snssai.dnn_smf_info_list.push_back(dnn);
Logger::nrf_app().debug("\t\tDNN: %s",
dnn.dnn.c_str());
Logger::nrf_app().debug("\t\tDNN: %s", dnn.dnn.c_str());
}
info.snssai_smf_info_list.push_back(snssai);
}
......@@ -162,6 +158,24 @@ bool api_conv::profile_api_to_nrf_profile(
default: {}
}
// nf_services
if (api_profile.nfServicesIsSet()) {
std::vector<NFService> nf_services = api_profile.getNfServices();
for (auto service : nf_services) {
nf_service_t ns = {};
ns.service_instance_id = service.getServiceInstanceId();
ns.service_name = service.getServiceName();
ns.scheme = service.getScheme();
for (auto v : service.getVersions()) {
nf_service_version_t version = {};
version.api_full_version = v.getApiFullVersion();
version.api_version_in_uri = v.getApiVersionInUri();
ns.versions.push_back(version);
}
ns.nf_service_status = service.getNfServiceStatus();
profile.get()->add_nf_service(ns);
}
}
return true;
}
......@@ -286,7 +300,6 @@ bool api_conv::subscription_api_to_nrf_subscription(
if (sub_condition.type != UNKNOWN_CONDITION) {
sub.get()->set_sub_condition(sub_condition);
}
}
// NotificationEventType
......@@ -308,7 +321,7 @@ bool api_conv::subscription_api_to_nrf_subscription(
if (api_sub.validityTimeIsSet()) {
std::string str = api_sub.getValidityTime();
boost::posix_time::ptime p (boost::posix_time::from_iso_string(str));
boost::posix_time::ptime p(boost::posix_time::from_iso_string(str));
sub.get()->set_validity_time(p);
Logger::nrf_app().debug("Validity Time: %s", str.c_str());
}
......
......@@ -157,6 +157,21 @@ void nrf_profile::get_json_data(nlohmann::json &data) const {
data = json_data;
}
//------------------------------------------------------------------------------
void nrf_profile::set_nf_services(const std::vector<nf_service_t> &n) {
nf_services = n;
}
//------------------------------------------------------------------------------
void nrf_profile::add_nf_service(const nf_service_t &n) {
nf_services.push_back(n);
}
//------------------------------------------------------------------------------
void nrf_profile::get_nf_services(std::vector<nf_service_t> &n) const {
n = nf_services;
}
//------------------------------------------------------------------------------
void nrf_profile::display() {
Logger::nrf_app().debug("NF instance info");
......@@ -181,6 +196,11 @@ void nrf_profile::display() {
if (!json_data.empty()) {
Logger::nrf_app().debug("\tJson Data: %s", json_data.dump().c_str());
}
// NF services
for (auto service : nf_services) {
Logger::nrf_app().debug("\tNF Service: %s", service.to_string().c_str());
}
}
//------------------------------------------------------------------------------
......@@ -244,6 +264,11 @@ bool nrf_profile::replace_profile_info(const std::string &path,
return false;
}
if (path.compare("nfServices") == 0) {
Logger::nrf_app().info("Does not support this operation for nfServices");
return false;
}
return false;
}
......@@ -320,7 +345,12 @@ bool nrf_profile::add_profile_info(const std::string &path,
// add an element to a list of json object
if (path.compare("sNssais") == 0) {
Logger::nrf_app().info("Does not support this operation for snssais");
Logger::nrf_app().info("Does not support this operation for sNssais");
return false;
}
if (path.compare("nfServices") == 0) {
Logger::nrf_app().info("Does not support this operation for nfServices");
return false;
}
......@@ -390,10 +420,16 @@ bool nrf_profile::remove_profile_info(const std::string &path) {
}
if (path.find("sNssais") != std::string::npos) {
Logger::nrf_app().info("Does not support this operation for snssais");
Logger::nrf_app().info("Does not support this operation for sNssais");
return false;
}
if (path.find("nfServices") != std::string::npos) {
Logger::nrf_app().info("Does not support this operation for nfServices");
return false;
}
Logger::nrf_app().debug("Member (%s) not found!", path.c_str());
return false;
}
......@@ -422,6 +458,23 @@ void nrf_profile::to_json(nlohmann::json &data) const {
}
data["priority"] = priority;
data["capacity"] = capacity;
// NF services
data["nfServices"] = nlohmann::json::array();
for (auto service : nf_services) {
nlohmann::json srv_tmp = {};
srv_tmp["serviceInstanceId"] = service.service_instance_id;
srv_tmp["serviceName"] = service.service_name;
srv_tmp["versions"] = nlohmann::json::array();
for (auto v : service.versions) {
nlohmann::json v_tmp = {};
v_tmp["apiVersionInUri"] = v.api_version_in_uri;
v_tmp["apiFullVersion"] = v.api_full_version;
srv_tmp["versions"].push_back(v_tmp);
}
srv_tmp["scheme"] = service.scheme;
srv_tmp["nfServiceStatus"] = service.nf_service_status;
data["nfServices"].push_back(srv_tmp);
}
data["json_data"] = json_data;
}
......@@ -605,7 +658,8 @@ bool amf_profile::add_profile_info(const std::string &path,
(path.compare("sNssais") != 0) and
(path.compare("ipv4Addresses") != 0) and
(path.compare("priority") != 0) and (path.compare("capacity") != 0) and
(path.compare("priority") != 0) and (path.compare("amfInfo") != 0)) {
(path.compare("priority") != 0) and (path.compare("nfServices") != 0) and
(path.compare("amfInfo") != 0)) {
Logger::nrf_app().debug("Add new member: %s", path.c_str());
// add new member
json_data[path] = value;
......@@ -632,7 +686,8 @@ bool amf_profile::remove_profile_info(const std::string &path) {
(path.compare("sNssais") != 0) and
(path.compare("ipv4Addresses") != 0) and
(path.compare("priority") != 0) and (path.compare("capacity") != 0) and
(path.compare("priority") != 0) and (path.compare("amfInfo") != 0)) {
(path.compare("priority") != 0) and (path.compare("nfServices") != 0) and
(path.compare("amfInfo") != 0)) {
Logger::nrf_app().debug("Member (%s) not found!", path.c_str());
return false;
}
......@@ -697,7 +752,8 @@ bool smf_profile::add_profile_info(const std::string &path,
(path.compare("sNssais") != 0) and
(path.compare("ipv4Addresses") != 0) and
(path.compare("priority") != 0) and (path.compare("capacity") != 0) and
(path.compare("priority") != 0) and (path.compare("smfInfo") != 0)) {
(path.compare("priority") != 0) and (path.compare("nfServices") != 0) and
(path.compare("smfInfo") != 0)) {
Logger::nrf_app().debug("Add new member: %s", path.c_str());
// add new member
json_data[path] = value;
......@@ -724,7 +780,8 @@ bool smf_profile::replace_profile_info(const std::string &path,
(path.compare("sNssais") != 0) and
(path.compare("ipv4Addresses") != 0) and
(path.compare("priority") != 0) and (path.compare("capacity") != 0) and
(path.compare("priority") != 0) and (path.compare("amfInfo") != 0)) {
(path.compare("priority") != 0) and (path.compare("nfServices") != 0) and
(path.compare("amfInfo") != 0)) {
Logger::nrf_app().debug("Member (%s) not found!", path.c_str());
return false;
}
......@@ -749,7 +806,8 @@ bool smf_profile::remove_profile_info(const std::string &path) {
(path.compare("sNssais") != 0) and
(path.compare("ipv4Addresses") != 0) and
(path.compare("priority") != 0) and (path.compare("capacity") != 0) and
(path.compare("priority") != 0) and (path.compare("smfInfo") != 0)) {
(path.compare("priority") != 0) and (path.compare("nfServices") != 0) and
(path.compare("smfInfo") != 0)) {
Logger::nrf_app().debug("Member (%s) not found!", path.c_str());
return false;
}
......
......@@ -60,6 +60,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
ipv4_addresses(),
priority(0),
capacity(0),
nf_services(),
heartbeart_mutex() {
nf_instance_name = "";
nf_status = "";
......@@ -75,6 +76,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
ipv4_addresses(),
priority(0),
capacity(0),
nf_services(),
heartbeart_mutex() {
nf_instance_name = "";
nf_status = "";
......@@ -91,6 +93,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
ipv4_addresses(),
priority(0),
capacity(0),
nf_services(),
nf_type(NF_TYPE_UNKNOWN),
heartbeart_mutex() {
nf_instance_name = "";
......@@ -304,6 +307,27 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
*/
void get_json_data(nlohmann::json &data) const;
/*
* Set NF instance services
* @param [std::vector<nf_service_t> &] n: nf_service
* @return void
*/
void set_nf_services(const std::vector<nf_service_t> &n);
/*
* Add nf service
* @param [snssai_t &] n: nf service
* @return void
*/
void add_nf_service(const nf_service_t &n);
/*
* Get NF services
* @param [std::vector<snssai_t> &] n: store instance's nf services
* @return void:
*/
void get_nf_services(std::vector<nf_service_t> &n) const;
/*
* Print related-information for NF profile
* @param void
......@@ -421,6 +445,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
uint16_t priority;
uint16_t capacity;
nlohmann::json json_data; // store extra json data
std::vector<nf_service_t> nf_services;
/*
std::vector<PlmnId> m_PlmnList;
......
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