Commit 96f42d67 authored by Raphael Defosseux's avatar Raphael Defosseux

Merge branch 'custom_info_enabled' into 'develop'

custom info field enabled

See merge request oai/cn5g/oai-cn5g-nrf!24
parents d50abc66 55d09578
......@@ -12,62 +12,63 @@
*/
#include "NFProfile.h"
#include <iostream>
namespace oai {
namespace nrf {
namespace model {
NFProfile::NFProfile() {
m_NfInstanceId = "";
m_NfInstanceName = "";
m_NfInstanceNameIsSet = false;
m_HeartBeatTimer = 0;
m_HeartBeatTimerIsSet = false;
m_PlmnListIsSet = false;
m_SNssaisIsSet = false;
m_PerPlmnSnssaiListIsSet = false;
m_NsiListIsSet = false;
m_Fqdn = "";
m_FqdnIsSet = false;
m_InterPlmnFqdn = "";
m_InterPlmnFqdnIsSet = false;
m_Ipv4AddressesIsSet = false;
m_Ipv6AddressesIsSet = false;
m_AllowedPlmnsIsSet = false;
m_AllowedNfTypesIsSet = false;
m_AllowedNfDomainsIsSet = false;
m_AllowedNssaisIsSet = false;
m_Priority = 0;
m_PriorityIsSet = false;
m_Capacity = 0;
m_CapacityIsSet = false;
m_Load = 0;
m_LoadIsSet = false;
m_Locality = "";
m_LocalityIsSet = false;
m_Priority = 0;
m_PriorityIsSet = false;
m_UdrInfoIsSet = false;
m_UdrInfoExtIsSet = false;
m_UdmInfoIsSet = false;
m_UdmInfoExtIsSet = false;
m_AusfInfoIsSet = false;
m_AusfInfoExtIsSet = false;
m_AmfInfoIsSet = false;
m_AmfInfoExtIsSet = false;
m_SmfInfoIsSet = false;
m_SmfInfoExtIsSet = false;
m_UpfInfoIsSet = false;
m_UpfInfoExtIsSet = false;
m_PcfInfoIsSet = false;
m_PcfInfoExtIsSet = false;
m_BsfInfoIsSet = false;
m_BsfInfoExtIsSet = false;
m_ChfInfoIsSet = false;
m_ChfInfoExtIsSet = false;
m_NrfInfoIsSet = false;
m_NwdafInfoIsSet = false;
// m_CustomInfoIsSet = false;
m_NfInstanceId = "";
m_NfInstanceName = "";
m_NfInstanceNameIsSet = false;
m_HeartBeatTimer = 0;
m_HeartBeatTimerIsSet = false;
m_PlmnListIsSet = false;
m_SNssaisIsSet = false;
m_PerPlmnSnssaiListIsSet = false;
m_NsiListIsSet = false;
m_Fqdn = "";
m_FqdnIsSet = false;
m_InterPlmnFqdn = "";
m_InterPlmnFqdnIsSet = false;
m_Ipv4AddressesIsSet = false;
m_Ipv6AddressesIsSet = false;
m_AllowedPlmnsIsSet = false;
m_AllowedNfTypesIsSet = false;
m_AllowedNfDomainsIsSet = false;
m_AllowedNssaisIsSet = false;
m_Priority = 0;
m_PriorityIsSet = false;
m_Capacity = 0;
m_CapacityIsSet = false;
m_Load = 0;
m_LoadIsSet = false;
m_Locality = "";
m_LocalityIsSet = false;
m_Priority = 0;
m_PriorityIsSet = false;
m_UdrInfoIsSet = false;
m_UdrInfoExtIsSet = false;
m_UdmInfoIsSet = false;
m_UdmInfoExtIsSet = false;
m_AusfInfoIsSet = false;
m_AusfInfoExtIsSet = false;
m_AmfInfoIsSet = false;
m_AmfInfoExtIsSet = false;
m_SmfInfoIsSet = false;
m_SmfInfoExtIsSet = false;
m_UpfInfoIsSet = false;
m_UpfInfoExtIsSet = false;
m_PcfInfoIsSet = false;
m_PcfInfoExtIsSet = false;
m_BsfInfoIsSet = false;
m_BsfInfoExtIsSet = false;
m_ChfInfoIsSet = false;
m_ChfInfoExtIsSet = false;
m_NrfInfoIsSet = false;
m_NwdafInfoIsSet = false;
m_CustomInfoIsSet = false;
m_RecoveryTime = "";
m_RecoveryTimeIsSet = false;
m_NfServicePersistence = false;
......@@ -146,8 +147,7 @@ void to_json(nlohmann::json& j, const NFProfile& o) {
j["chfInfoExt"] = o.m_ChfInfoExt;
if (o.nrfInfoIsSet()) j["nrfInfo"] = o.m_NrfInfo;
if (o.nwdafInfoIsSet()) j["nwdafInfo"] = o.m_NwdafInfo;
// if(o.customInfoIsSet())
// j["customInfo"] = o.m_CustomInfo;
if (o.customInfoIsSet()) j["customInfo"] = o.m_CustomInfo;
if (o.recoveryTimeIsSet()) j["recoveryTime"] = o.m_RecoveryTime;
if (o.nfServicePersistenceIsSet())
j["nfServicePersistence"] = o.m_NfServicePersistence;
......@@ -323,11 +323,10 @@ void from_json(const nlohmann::json& j, NFProfile& o) {
j.at("nwdafInfo").get_to(o.m_NwdafInfo);
o.m_NwdafInfoIsSet = true;
}
/*if(j.find("customInfo") != j.end())
{
j.at("customInfo").get_to(o.m_CustomInfo);
o.m_CustomInfoIsSet = true;
} */
if (j.find("customInfo") != j.end()) {
j.at("customInfo").get_to(o.m_CustomInfo);
o.m_CustomInfoIsSet = true;
}
if (j.find("recoveryTime") != j.end()) {
j.at("recoveryTime").get_to(o.m_RecoveryTime);
o.m_RecoveryTimeIsSet = true;
......@@ -867,26 +866,21 @@ bool NFProfile::nwdafInfoIsSet() const {
void NFProfile::unsetNwdafInfo() {
m_NwdafInfoIsSet = false;
}
/*Object NFProfile::getCustomInfo() const
{
return m_CustomInfo;
}
*/
/*
void NFProfile::setCustomInfo(Object const& value)
{
m_CustomInfo = value;
m_CustomInfoIsSet = true;
}*/
/* bool NFProfile::customInfoIsSet() const
{
return m_CustomInfoIsSet;
}*/
/*
void NFProfile::unsetCustomInfo()
{
m_CustomInfoIsSet = false;
}*/
nlohmann::json NFProfile::getCustomInfo() const {
return m_CustomInfo;
}
void NFProfile::setCustomInfo(nlohmann::json const& value) {
m_CustomInfo = value;
m_CustomInfoIsSet = true;
}
bool NFProfile::customInfoIsSet() const {
return m_CustomInfoIsSet;
}
void NFProfile::unsetCustomInfo() {
m_CustomInfoIsSet = false;
}
std::string NFProfile::getRecoveryTime() const {
return m_RecoveryTime;
......
......@@ -345,10 +345,10 @@ class NFProfile {
/// <summary>
///
/// </summary>
// Object getCustomInfo() const;
// void setCustomInfo(Object const& value);
// bool customInfoIsSet() const;
// void unsetCustomInfo();
nlohmann::json getCustomInfo() const;
void setCustomInfo(nlohmann::json const& value);
bool customInfoIsSet() const;
void unsetCustomInfo();
/// <summary>
///
/// </summary>
......@@ -480,8 +480,8 @@ class NFProfile {
bool m_NrfInfoIsSet;
NwdafInfo m_NwdafInfo;
bool m_NwdafInfoIsSet;
// Object m_CustomInfo;
// bool m_CustomInfoIsSet;
nlohmann::json m_CustomInfo;
bool m_CustomInfoIsSet;
std::string m_RecoveryTime;
bool m_RecoveryTimeIsSet;
bool m_NfServicePersistence;
......
......@@ -65,6 +65,9 @@ bool api_conv::profile_api_to_nrf_profile(
"\tInstance name: %s", profile.get()->get_nf_instance_name().c_str());
profile.get()->set_nf_status(api_profile.getNfStatus());
profile.get()->set_custom_info(api_profile.getCustomInfo());
Logger::nrf_app().debug(
"getCustomInfo -> %s", api_profile.getCustomInfo().dump().c_str());
Logger::nrf_app().debug(
"\tStatus: %s", profile.get()->get_nf_status().c_str());
profile.get()->set_nf_heartBeat_timer(api_profile.getHeartBeatTimer());
......
......@@ -230,6 +230,16 @@ void nrf_profile::get_nf_services(std::vector<nf_service_t>& n) const {
n = nf_services;
}
//------------------------------------------------------------------------------
void nrf_profile::set_custom_info(const nlohmann::json& c) {
custom_info = c;
}
//------------------------------------------------------------------------------
void nrf_profile::get_custom_info(nlohmann::json& c) const {
c = custom_info;
}
//------------------------------------------------------------------------------
void nrf_profile::display() {
Logger::nrf_app().debug("NF instance info");
......@@ -242,6 +252,8 @@ void nrf_profile::display() {
Logger::nrf_app().debug("\tPriority: %d", priority);
Logger::nrf_app().debug("\tCapacity: %d", capacity);
// SNSSAIs
if (!custom_info.empty())
Logger::nrf_app().debug("\tCustomInfo: %s", custom_info.dump().c_str());
if (!plmn_list.empty()) {
for (auto s : plmn_list) {
Logger::nrf_app().debug("\tPLMN List(MCC, MNC): %d, %s", s.mcc, s.mnc);
......@@ -593,6 +605,8 @@ void nrf_profile::to_json(nlohmann::json& data) const {
// }
data["priority"] = priority;
data["capacity"] = capacity;
// CustomInfo
if (!custom_info.empty()) data["customInfo"] = custom_info;
// NF services
data["nfServices"] = nlohmann::json::array();
for (auto service : nf_services) {
......
......@@ -68,6 +68,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
nf_instance_name = "";
nf_status = "";
json_data = {};
custom_info = {};
first_update = true;
is_updated = false;
}
......@@ -365,6 +366,20 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
*/
void get_json_data(nlohmann::json& data) const;
/*
* Set custom info
* @param [const nlohmann::json &] c: custom info to be set
* @return void
*/
void set_custom_info(const nlohmann::json& c);
/*
* Get custom info
* @param [nlohmann::json &] c: Store custom info
* @return void
*/
void get_custom_info(nlohmann::json& c) const;
/*
* Set NF instance services
* @param [std::vector<nf_service_t> &] n: nf_service
......@@ -507,6 +522,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
uint16_t capacity;
nlohmann::json json_data; // store extra json data
std::vector<nf_service_t> nf_services;
nlohmann::json custom_info; // store extra json data
/*
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