Commit 0f208d30 authored by kharade's avatar kharade

ausf profile added

parent e962a573
...@@ -148,4 +148,14 @@ typedef struct guami_s { ...@@ -148,4 +148,14 @@ typedef struct guami_s {
std::string amf_id; std::string amf_id;
} guami_t; } guami_t;
typedef struct routing_indicators_s {
std::vector<std::string> routing_indicators;
} routing_indicators_t;
typedef struct supi_range_s {
std::string start;
std::string end;
std::string pattern;
} supi_range_t;
#endif #endif
...@@ -65,6 +65,20 @@ typedef struct upf_info_s { ...@@ -65,6 +65,20 @@ typedef struct upf_info_s {
std::vector<snssai_upf_info_item_t> snssai_upf_info_list; std::vector<snssai_upf_info_item_t> snssai_upf_info_list;
} upf_info_t; } upf_info_t;
typedef struct supi_range_ausf_info_item_s {
supi_range_t supi_range;
} supi_range_ausf_info_item_t;
typedef struct routing_indicators_ausf_info_item_s {
std::vector<std::string> routing_indicator;
} routing_indicators_ausf_info_item_t;
typedef struct ausf_info_s {
std::string groupid;
std::vector<supi_range_ausf_info_item_t> supi_ranges;
std::vector<routing_indicators_ausf_info_item_t> routing_indicators;
} ausf_info_t;
enum subscr_condition_type_e { // TODO: use enum class enum subscr_condition_type_e { // TODO: use enum class
UNKNOWN_CONDITION = 0, UNKNOWN_CONDITION = 0,
NF_INSTANCE_ID_COND = 1, NF_INSTANCE_ID_COND = 1,
......
...@@ -83,6 +83,16 @@ bool api_conv::profile_api_to_nrf_profile( ...@@ -83,6 +83,16 @@ bool api_conv::profile_api_to_nrf_profile(
Logger::nrf_app().debug( Logger::nrf_app().debug(
"\tSNSSAI (SD, SST): %d, %s", sn.sST, sn.sD.c_str()); "\tSNSSAI (SD, SST): %d, %s", sn.sST, sn.sD.c_str());
} }
// if (api_profile.plmnListIsSet()){
// std::vector<PlmnId> &plmnid = api_profile.getPlmnList();
// for (auto s : plmnid) {
// plmn_t sn = {};
// sn.mcc = s.getMcc();
// sn.mnc = s.getMnc();
// profile.get()->add_plmn_list(sn);
// Logger::nrf_app().debug(
// "\tPLMN_List (MCC, MNS): %s, %s", sn.mcc.c_str(), sn.mnc.c_str());
// }
if (api_profile.fqdnIsSet()) { if (api_profile.fqdnIsSet()) {
profile.get()->set_fqdn(api_profile.getFqdn()); profile.get()->set_fqdn(api_profile.getFqdn());
Logger::nrf_app().debug("\tFQDN: %s", api_profile.getFqdn().c_str()); Logger::nrf_app().debug("\tFQDN: %s", api_profile.getFqdn().c_str());
...@@ -206,6 +216,27 @@ bool api_conv::profile_api_to_nrf_profile( ...@@ -206,6 +216,27 @@ bool api_conv::profile_api_to_nrf_profile(
.get() .get()
->add_upf_info(info); ->add_upf_info(info);
} break;
case NF_TYPE_AUSF: {
Logger::nrf_app().debug("\tAUSF profile, AUSFF Info");
profile.get()->set_nf_type(NF_TYPE_AUSF);
ausf_info_t info = {};
AusfInfo ausf_info_api = api_profile.getAusfInfo();
info.groupid = ausf_info_api.getGroupId();
for (auto s : ausf_info_api.getSupiRanges()) {
supi_range_ausf_info_item_t supiRange = {};
supiRange.supi_range.start = s.getStart();
supiRange.supi_range.end = s.getEnd();
supiRange.supi_range.pattern = s.getPattern();
info.supi_ranges.push_back(supiRange);
}
for (auto s : ausf_info_api.getRoutingIndicators()) {
info.routing_indicator.push_back(s);
}
(std::static_pointer_cast<ausf_profile>(profile))
.get()
->add_ausf_info(info);
} break; } break;
default: { default: {
} }
......
...@@ -136,6 +136,10 @@ void nrf_app::handle_register_nf_instance( ...@@ -136,6 +136,10 @@ void nrf_app::handle_register_nf_instance(
sn = std::make_shared<upf_profile>(m_event_sub); sn = std::make_shared<upf_profile>(m_event_sub);
} break; } break;
case NF_TYPE_AUSF: {
sn = std::make_shared<ausf_profile>(m_event_sub);
} break;
default: { default: {
sn = std::make_shared<nrf_profile>(m_event_sub); sn = std::make_shared<nrf_profile>(m_event_sub);
} }
......
...@@ -243,6 +243,10 @@ void nrf_client::notify_subscribed_event( ...@@ -243,6 +243,10 @@ void nrf_client::notify_subscribed_event(
std::static_pointer_cast<upf_profile>(profile).get()->to_json( std::static_pointer_cast<upf_profile>(profile).get()->to_json(
json_profile); json_profile);
} break; } break;
case NF_TYPE_AUSF: {
std::static_pointer_cast<ausf_profile>(profile).get()->to_json(
json_profile);
} break;
default: { default: {
profile.get()->to_json(json_profile); profile.get()->to_json(json_profile);
} }
......
...@@ -166,6 +166,22 @@ void nrf_profile::set_fqdn(const std::string& fqdN) { ...@@ -166,6 +166,22 @@ void nrf_profile::set_fqdn(const std::string& fqdN) {
std::string nrf_profile::get_fqdn() const { std::string nrf_profile::get_fqdn() const {
return fqdn; return fqdn;
} }
//------------------------------------------------------------------------------
void nrf_profile::set_plmn_list(const std::vector<plmn_t>& s) {
plmn_list = s;
}
//------------------------------------------------------------------------------
void nrf_profile::get_plmn_list(std::vector<plmn_t>& s) const {
s = plmn_list;
}
//------------------------------------------------------------------------------
void nrf_profile::add_plmn_list(const plmn_t& s) {
plmn_list.push_back(s);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_profile::set_nf_ipv4_addresses(const std::vector<struct in_addr>& a) { void nrf_profile::set_nf_ipv4_addresses(const std::vector<struct in_addr>& a) {
ipv4_addresses = a; ipv4_addresses = a;
...@@ -226,6 +242,11 @@ void nrf_profile::display() { ...@@ -226,6 +242,11 @@ void nrf_profile::display() {
Logger::nrf_app().debug("\tPriority: %d", priority); Logger::nrf_app().debug("\tPriority: %d", priority);
Logger::nrf_app().debug("\tCapacity: %d", capacity); Logger::nrf_app().debug("\tCapacity: %d", capacity);
// SNSSAIs // SNSSAIs
if (!plmn_list.empty()){
for (auto s : plmn_list) {
Logger::nrf_app().debug("\tPLMN List(MCC, MNC): %d, %s", s.mcc, s.mnc);
}
}
for (auto s : snssais) { for (auto s : snssais) {
Logger::nrf_app().debug("\tNNSSAI(SST, SD): %d, %s", s.sST, s.sD.c_str()); Logger::nrf_app().debug("\tNNSSAI(SST, SD): %d, %s", s.sST, s.sD.c_str());
} }
...@@ -303,6 +324,11 @@ bool nrf_profile::replace_profile_info( ...@@ -303,6 +324,11 @@ bool nrf_profile::replace_profile_info(
} }
// Replace an array // Replace an array
if (path.compare("plmnList") == 0) {
Logger::nrf_app().info("Does not support this operation for ipv4Addresses");
return false;
}
if (path.compare("ipv4Addresses") == 0) { if (path.compare("ipv4Addresses") == 0) {
Logger::nrf_app().info("Does not support this operation for ipv4Addresses"); Logger::nrf_app().info("Does not support this operation for ipv4Addresses");
return false; return false;
...@@ -430,6 +456,11 @@ bool nrf_profile::add_profile_info( ...@@ -430,6 +456,11 @@ bool nrf_profile::add_profile_info(
return false; return false;
} }
if (path.compare("plmnList") == 0) {
Logger::nrf_app().info("Does not support this operation for plmnList");
return false;
}
return false; return false;
} }
...@@ -510,6 +541,11 @@ bool nrf_profile::remove_profile_info(const std::string& path) { ...@@ -510,6 +541,11 @@ bool nrf_profile::remove_profile_info(const std::string& path) {
return false; return false;
} }
if (path.find("plmnList") != std::string::npos) {
Logger::nrf_app().info("Does not support this operation for plmnList");
return false;
}
Logger::nrf_app().debug("Member (%s) not found!", path.c_str()); Logger::nrf_app().debug("Member (%s) not found!", path.c_str());
return false; return false;
} }
...@@ -522,17 +558,28 @@ void nrf_profile::to_json(nlohmann::json& data) const { ...@@ -522,17 +558,28 @@ void nrf_profile::to_json(nlohmann::json& data) const {
data["nfStatus"] = nf_status; data["nfStatus"] = nf_status;
data["heartBeatTimer"] = heartBeat_timer; data["heartBeatTimer"] = heartBeat_timer;
// SNSSAIs // SNSSAIs
data["sNssais"] = nlohmann::json::array(); if (!snssais.empty()){
for (auto s : snssais) { data["sNssais"] = nlohmann::json::array();
nlohmann::json tmp = {}; for (auto s : snssais) {
tmp["sst"] = s.sST; nlohmann::json tmp = {};
tmp["sd"] = s.sD; tmp["sst"] = s.sST;
; tmp["sd"] = s.sD;
data["sNssais"].push_back(tmp); ;
data["sNssais"].push_back(tmp);
}
} }
if (!fqdn.empty()) { if (!fqdn.empty()) {
data["fqdn"] = fqdn; data["fqdn"] = fqdn;
} }
if (!plmn_list.empty()){
data["plmnList"] = nlohmann::json::array();
for (auto s : plmn_list) {
nlohmann::json tmp = {};
tmp["mcc"] = s.mcc;
tmp["mnc"] = s.mnc;
data["plmnList"].push_back(tmp);
}
}
// ipv4_addresses // ipv4_addresses
data["ipv4Addresses"] = nlohmann::json::array(); data["ipv4Addresses"] = nlohmann::json::array();
for (auto address : ipv4_addresses) { for (auto address : ipv4_addresses) {
...@@ -1057,3 +1104,131 @@ void upf_profile::to_json(nlohmann::json& data) const { ...@@ -1057,3 +1104,131 @@ void upf_profile::to_json(nlohmann::json& data) const {
data["upfInfo"]["sNssaiUpfInfoList"].push_back(tmp); data["upfInfo"]["sNssaiUpfInfoList"].push_back(tmp);
} }
} }
//------------------------------------------------------------------------------
void ausf_profile::add_ausf_info(const ausf_info_t& info) {
ausf_info = info;
}
//------------------------------------------------------------------------------
void ausf_profile::get_ausf_info(ausf_info_t& infos) const {
infos = ausf_info;
}
//------------------------------------------------------------------------------
void ausf_profile::display() {
nrf_profile::display();
Logger::nrf_app().debug("\tAUSF Info");
Logger::nrf_app().debug("\t\tGroupId: %s",ausf_info.groupid);
for (auto supi : ausf_info.supi_ranges) {
Logger::nrf_app().debug("\t\t SupiRanges: Start - %s, End - %s, Pattern - %s",supi.supi_range.start,supi.supi_range.end, supi.supi_range.pattern);
}
for (auto route_ind : ausf_info.routing_indicator) {
Logger::nrf_app().debug("\t\t Routing Indicators: %s",route_ind);
}
}
//------------------------------------------------------------------------------
bool ausf_profile::add_profile_info(
const std::string& path, const std::string& value) {
bool result = nrf_profile::add_profile_info(path, value);
if (result) return true;
// add an element to a list of json object
if (path.compare("ausInfo") == 0) {
Logger::nrf_app().info("Does not support this operation for ausInfo");
return false;
}
if ((path.compare("nfInstanceId") != 0) and
(path.compare("nfInstanceName") != 0) and
(path.compare("nfType") != 0) and (path.compare("nfStatus") != 0) and
(path.compare("heartBeatTimer") != 0) and
(path.compare("fqdn") != 0) and
(path.compare("plmnList") != 0) and
(path.compare("ipv4Addresses") != 0) and
(path.compare("priority") != 0) and (path.compare("capacity") != 0) and
(path.compare("priority") != 0) and (path.compare("nfServices") != 0) and
(path.compare("ausfInfo") != 0)) {
Logger::nrf_app().debug("Add new member: %s", path.c_str());
// add new member
json_data[path] = value;
return true;
}
return false;
}
//------------------------------------------------------------------------------
bool ausf_profile::replace_profile_info(
const std::string& path, const std::string& value) {
bool result = nrf_profile::replace_profile_info(path, value);
if (result) return true;
// for AUSF info
if (path.compare("ausInfo") == 0) {
Logger::nrf_app().debug("Does not support this operation for ausfInfo");
return false;
}
if ((path.compare("nfInstanceId") != 0) and
(path.compare("nfInstanceName") != 0) and
(path.compare("nfType") != 0) and (path.compare("nfStatus") != 0) and
(path.compare("heartBeatTimer") != 0) and
(path.compare("fqdn") != 0) and
(path.compare("plmnList") != 0) and
(path.compare("ipv4Addresses") != 0) and
(path.compare("priority") != 0) and (path.compare("capacity") != 0) and
(path.compare("priority") != 0) and (path.compare("nfServices") != 0) and
(path.compare("ausInfo") != 0)) {
Logger::nrf_app().debug("Member (%s) not found!", path.c_str());
return false;
}
return false;
}
//------------------------------------------------------------------------------
bool ausf_profile::remove_profile_info(const std::string& path) {
bool result = nrf_profile::remove_profile_info(path);
if (result) return true;
// for AUSF info
if (path.compare("ausInfo") == 0) {
Logger::nrf_app().debug("Do not support this operation for ausfInfo");
return false;
}
if ((path.compare("nfInstanceId") != 0) and
(path.compare("nfInstanceName") != 0) and
(path.compare("nfType") != 0) and (path.compare("nfStatus") != 0) and
(path.compare("heartBeatTimer") != 0) and
(path.compare("fqdn") != 0) and
(path.compare("plmnList") != 0) and
(path.compare("ipv4Addresses") != 0) and
(path.compare("priority") != 0) and (path.compare("capacity") != 0) and
(path.compare("priority") != 0) and (path.compare("nfServices") != 0) and
(path.compare("ausfInfo") != 0)) {
Logger::nrf_app().debug("Member (%s) not found!", path.c_str());
return false;
}
return false;
}
//------------------------------------------------------------------------------
void ausf_profile::to_json(nlohmann::json& data) const {
nrf_profile::to_json(data);
// AUSF Info
data["ausfInfo"]["groupId"] = ausf_info.groupid;
data["ausfInfo"]["supiRanges"] = nlohmann::json::array();
data["ausfInfo"]["routingIndicators"] = nlohmann::json::array();
for (auto supi : ausf_info.supi_ranges) {
nlohmann::json tmp = {};
tmp["start"] = supi.supi_range.start;
tmp["end"] = supi.supi_range.end;
tmp["pattern"] = supi.supi_range.pattern;
data["ausfInfo"]["supiRanges"].push_back(tmp);
}
for (auto route_ind : ausf_info.routing_indicator) {
std::string tmp = route_ind;
data["ausfInfo"]["routingIndicators"].push_back(route_ind);
}
}
...@@ -58,6 +58,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -58,6 +58,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
heartBeat_timer(0), heartBeat_timer(0),
snssais(), snssais(),
fqdn(), fqdn(),
plmn_list(),
ipv4_addresses(), ipv4_addresses(),
ipv6_addresses(), ipv6_addresses(),
priority(0), priority(0),
...@@ -76,6 +77,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -76,6 +77,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
heartBeat_timer(0), heartBeat_timer(0),
snssais(), snssais(),
fqdn(), fqdn(),
plmn_list(),
ipv4_addresses(), ipv4_addresses(),
ipv6_addresses(), ipv6_addresses(),
priority(0), priority(0),
...@@ -95,6 +97,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -95,6 +97,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
heartBeat_timer(0), heartBeat_timer(0),
snssais(), snssais(),
fqdn(), fqdn(),
plmn_list(),
ipv4_addresses(), ipv4_addresses(),
ipv6_addresses(), ipv6_addresses(),
priority(0), priority(0),
...@@ -292,6 +295,27 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -292,6 +295,27 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
*/ */
void set_fqdn(const std::string& fqdn); void set_fqdn(const std::string& fqdn);
/*
* Set NF instance plmnList
* @param [std::vector<plmn_t> &] s: plmn (mcc, mnc)
* @return void
*/
void set_plmn_list(const std::vector<plmn_t>& s);
/*
* Add plmnList
* @param [plmn_t &] s: plmn (mcc, mnc)
* @return void
*/
void add_plmn_list(const plmn_t& s);
/*
* Get NF instance plmnList
* @param [std::vector<plmn_t> &] s: store plmnList
* @return void:
*/
void get_plmn_list(std::vector<plmn_t>& s) const;
/* /*
* Set NF instance ipv4_addresses * Set NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: ipv4_addresses * @param [std::vector<struct in_addr> &] a: ipv4_addresses
...@@ -474,6 +498,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -474,6 +498,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
nf_type_t nf_type; nf_type_t nf_type;
std::string nf_status; std::string nf_status;
int32_t heartBeat_timer; int32_t heartBeat_timer;
std::vector<plmn_t> plmn_list;
std::vector<snssai_t> snssais; std::vector<snssai_t> snssais;
std::string fqdn; std::string fqdn;
std::vector<struct in_addr> ipv4_addresses; std::vector<struct in_addr> ipv4_addresses;
...@@ -752,6 +777,74 @@ class upf_profile : public nrf_profile { ...@@ -752,6 +777,74 @@ class upf_profile : public nrf_profile {
private: private:
upf_info_t upf_info; upf_info_t upf_info;
}; };
class ausf_profile : public nrf_profile {
public:
ausf_profile(nrf_event& ev) : nrf_profile(ev, NF_TYPE_AUSF) { ausf_info = {}; }
ausf_profile(nrf_event& ev, const std::string& id) : nrf_profile(ev, id) {
nf_type = NF_TYPE_AUSF;
ausf_info = {};
}
ausf_profile(ausf_profile& b) = delete;
/*
* Add a AUSF info
* @param [const ausf_info_t &] info: AUSF info
* @return void
*/
void add_ausf_info(const ausf_info_t& info);
/*
* Get list of AUSF infos a AUSF info
* @param [const ausf_info_t &] info: AUSF info
* @return void
*/
void get_ausf_info(ausf_info_t& infos) const;
/*
* Print related-information for a AUSF profile
* @param void
* @return void:
*/
void display();
/*
* Update a new value for a member of AUSF profile
* @param [const std::string &] path: member name
* @param [const std::string &] value: new value
* @return void
*/
bool replace_profile_info(const std::string& path, const std::string& value);
/*
* Add a new value for a member of NF profile
* @param [const std::string &] path: member name
* @param [const std::string &] value: new value
* @return true if success, otherwise false
*/
bool add_profile_info(const std::string& path, const std::string& value);
/*
* Remove value of a member of NF profile
* @param [const std::string &] path: member name
* @param [const std::string &] value: new value
* @return true if success, otherwise false
*/
bool remove_profile_info(const std::string& path);
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
void to_json(nlohmann::json& data) const;
private:
ausf_info_t ausf_info;
};
} // namespace app } // namespace app
} // namespace nrf } // namespace nrf
} // namespace oai } // namespace oai
......
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