Commit 11678473 authored by kharade's avatar kharade

nf profile update for PCF

parent d50abc66
......@@ -140,6 +140,14 @@ typedef struct udr_info_s {
std::vector<std::string> data_set_id;
} udr_info_t;
typedef struct pcf_info_s {
std::string groupid;
std::vector<std::string> dnn_list;
std::vector<supi_range_info_item_t> supi_ranges;
std::vector<identity_range_info_item_t> gpsi_ranges;
// ToDo: rxDiamHost, rxDiamRealm, v2xSupportInd.
} pcf_info_t;
enum subscr_condition_type_e { // TODO: use enum class
UNKNOWN_CONDITION = 0,
NF_INSTANCE_ID_COND = 1,
......
......@@ -392,6 +392,8 @@ bool api_conv::profile_api_to_nrf_profile(
profile.get()->set_nf_type(NF_TYPE_UDR);
udr_info_t info = {};
UdrInfo udr_info_api = api_profile.getUdrInfo();
info.groupid = udr_info_api.getGroupId();
Logger::nrf_app().debug("\t\t GroupId - %s", info.groupid.c_str());
if (udr_info_api.supiRangesIsSet()) {
for (auto s : udr_info_api.getSupiRanges()) {
supi_range_info_item_t supiRange = {};
......@@ -443,6 +445,51 @@ bool api_conv::profile_api_to_nrf_profile(
.get()
->add_udr_info(info);
} break;
case NF_TYPE_PCF: {
Logger::nrf_app().debug("\tPCF profile, PCF Info");
profile.get()->set_nf_type(NF_TYPE_PCF);
pcf_info_t info = {};
PcfInfo pcf_info_api = api_profile.getPcfInfo();
info.groupid = pcf_info_api.getGroupId();
Logger::nrf_app().debug("\t\t GroupId - %s", info.groupid.c_str());
if (pcf_info_api.dnnListIsSet()) {
for (auto s : pcf_info_api.getDnnList()) {
Logger::nrf_app().debug("\t\t DNN - %s", s.c_str());
info.dnn_list.push_back(s);
}
}
if (pcf_info_api.supiRangesIsSet()) {
for (auto s : pcf_info_api.getSupiRanges()) {
supi_range_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);
Logger::nrf_app().debug(
"\t\t SupiRanges: Start - %s, End - %s, Pattern - %s",
supiRange.supi_range.start.c_str(),
supiRange.supi_range.end.c_str(),
supiRange.supi_range.pattern.c_str());
}
}
if (pcf_info_api.gpsiRangesIsSet()) {
for (auto s : pcf_info_api.getGpsiRanges()) {
identity_range_info_item_t gpsiRange = {};
gpsiRange.identity_range.start = s.getStart();
gpsiRange.identity_range.end = s.getEnd();
gpsiRange.identity_range.pattern = s.getPattern();
info.gpsi_ranges.push_back(gpsiRange);
Logger::nrf_app().debug(
"\t\t GpsiRanges: Start - %s, End - %s, Pattern - %s",
gpsiRange.identity_range.start.c_str(),
gpsiRange.identity_range.end.c_str(),
gpsiRange.identity_range.pattern.c_str());
}
}
(std::static_pointer_cast<pcf_profile>(profile))
.get()
->add_pcf_info(info);
} break;
default: {
}
}
......@@ -636,7 +683,7 @@ nf_type_t api_conv::string_to_nf_type(const std::string& str) {
if (str.compare("SMF") == 0) return NF_TYPE_SMF;
if (str.compare("AUSF") == 0) return NF_TYPE_AUSF;
if (str.compare("NEF") == 0) return NF_TYPE_NEF;
if (str.compare("PCP") == 0) return NF_TYPE_PCF;
if (str.compare("PCF") == 0) return NF_TYPE_PCF;
if (str.compare("SMSF") == 0) return NF_TYPE_SMSF;
if (str.compare("NSSF") == 0) return NF_TYPE_NSSF;
if (str.compare("UDR") == 0) return NF_TYPE_UDR;
......
......@@ -148,6 +148,10 @@ void nrf_app::handle_register_nf_instance(
sn = std::make_shared<udr_profile>(m_event_sub);
} break;
case NF_TYPE_PCF: {
sn = std::make_shared<pcf_profile>(m_event_sub);
} break;
default: {
sn = std::make_shared<nrf_profile>(m_event_sub);
}
......
......@@ -44,13 +44,15 @@ bool nrf_jwt::generate_signature(
get_secret_key(scope, nf_type, target_nf_type, key);
// Create JWT object
// TODO
jwt::jwt_object obj{jwt::params::algorithm("HS256"),
jwt::params::payload({{"iss", nrf_instance_id},
{"sub", nf_consumer_id},
{"aud", target_nf_type},
{"scope", scope},
{"exp", "1000"}}), // in second
jwt::params::secret(key)};
jwt::jwt_object obj{
jwt::params::algorithm("HS256"),
jwt::params::payload(
{{"iss", nrf_instance_id},
{"sub", nf_consumer_id},
{"aud", target_nf_type},
{"scope", scope},
{"exp", "1000"}}), // in second
jwt::params::secret(key)};
// Get the encoded string/assertion
signature = obj.signature();
......@@ -66,13 +68,15 @@ bool nrf_jwt::generate_signature(
get_secret_key(scope, target_nf_instance_Id, key);
// Create JWT object
// TODO
jwt::jwt_object obj{jwt::params::algorithm("HS256"),
jwt::params::payload({{"iss", nrf_instance_id},
{"sub", nf_consumer_id},
{"aud", target_nf_instance_Id},
{"scope", scope},
{"exp", "1000"}}), // in second
jwt::params::secret(key)};
jwt::jwt_object obj{
jwt::params::algorithm("HS256"),
jwt::params::payload(
{{"iss", nrf_instance_id},
{"sub", nf_consumer_id},
{"aud", target_nf_instance_Id},
{"scope", scope},
{"exp", "1000"}}), // in second
jwt::params::secret(key)};
// Get the encoded string/assertion
signature = obj.signature();
......@@ -103,8 +107,8 @@ void nrf_jwt::test_jwt() {
auto key = "secret"; // Secret to use for the algorithm
// Create JWT object
jwt::jwt_object obj{algorithm("HS256"), payload({{"some", "payload"}}),
secret(key)};
jwt::jwt_object obj{
algorithm("HS256"), payload({{"some", "payload"}}), secret(key)};
// Get the encoded string/assertion
auto enc_str = obj.signature();
......
......@@ -1599,3 +1599,145 @@ void udr_profile::to_json(nlohmann::json& data) const {
data["udrInfo"]["routingIndicators"].push_back(data_set_id);
}
}
//------------------------------------------------------------------------------
void pcf_profile::add_pcf_info(const pcf_info_t& info) {
pcf_info = info;
}
//------------------------------------------------------------------------------
void pcf_profile::get_pcf_info(pcf_info_t& infos) const {
infos = pcf_info;
}
//------------------------------------------------------------------------------
void pcf_profile::display() {
nrf_profile::display();
Logger::nrf_app().debug("\tUDR Info");
Logger::nrf_app().debug("\t\tGroupId: %s", pcf_info.groupid.c_str());
for (auto dnn : pcf_info.dnn_list) {
Logger::nrf_app().debug("\t\t DNN: %s", dnn.c_str());
}
for (auto supi : pcf_info.supi_ranges) {
Logger::nrf_app().debug(
"\t\t SupiRanges: Start - %s, End - %s, Pattern - %s",
supi.supi_range.start.c_str(), supi.supi_range.end.c_str(),
supi.supi_range.pattern.c_str());
}
for (auto gpsiRange : pcf_info.gpsi_ranges) {
Logger::nrf_app().debug(
"\t\t GpsiRanges: Start - %s, End - %s, Pattern - %s",
gpsiRange.identity_range.start.c_str(),
gpsiRange.identity_range.end.c_str(),
gpsiRange.identity_range.pattern.c_str());
}
}
//------------------------------------------------------------------------------
bool pcf_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("pcfInfo") == 0) {
Logger::nrf_app().info("Does not support this operation for pcfInfo");
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("pcfInfo") != 0)) {
Logger::nrf_app().debug("Add new member: %s", path.c_str());
// add new member
json_data[path] = value;
return true;
}
return false;
}
//------------------------------------------------------------------------------
bool pcf_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 UDMAUSF info
if (path.compare("pcfInfo") == 0) {
Logger::nrf_app().debug("Does not support this operation for pcfInfo");
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("pcfInfo") != 0)) {
Logger::nrf_app().debug("Member (%s) not found!", path.c_str());
return false;
}
return false;
}
//------------------------------------------------------------------------------
bool pcf_profile::remove_profile_info(const std::string& path) {
bool result = nrf_profile::remove_profile_info(path);
if (result) return true;
// for UDM info
if (path.compare("pcfInfo") == 0) {
Logger::nrf_app().debug("Do not support this operation for pcfInfo");
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("pcfInfo") != 0)) {
Logger::nrf_app().debug("Member (%s) not found!", path.c_str());
return false;
}
return false;
}
//------------------------------------------------------------------------------
void pcf_profile::to_json(nlohmann::json& data) const {
nrf_profile::to_json(data);
// UDR Info
data["pcfInfo"]["groupId"] = pcf_info.groupid;
data["pcfInfo"]["dnnList"] = nlohmann::json::array();
data["pcfInfo"]["supiRanges"] = nlohmann::json::array();
data["pcfInfo"]["gpsiRanges"] = nlohmann::json::array();
for (auto supi : pcf_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["pcfInfo"]["supiRanges"].push_back(tmp);
}
for (auto gpsi : pcf_info.gpsi_ranges) {
nlohmann::json tmp = {};
tmp["start"] = gpsi.identity_range.start;
tmp["end"] = gpsi.identity_range.end;
tmp["pattern"] = gpsi.identity_range.pattern;
data["pcfInfo"]["gpsiRanges"].push_back(tmp);
}
for (auto dnn : pcf_info.dnn_list) {
data["pcfInfo"]["dnnList"].push_back(dnn);
}
}
\ No newline at end of file
......@@ -981,6 +981,73 @@ class udr_profile : public nrf_profile {
udr_info_t udr_info;
};
class pcf_profile : public nrf_profile {
public:
pcf_profile(nrf_event& ev) : nrf_profile(ev, NF_TYPE_PCF) { pcf_info = {}; }
pcf_profile(nrf_event& ev, const std::string& id) : nrf_profile(ev, id) {
nf_type = NF_TYPE_PCF;
pcf_info = {};
}
pcf_profile(pcf_profile& b) = delete;
/*
* Add a PCF info
* @param [const pcf_info_t &] info: PCF info
* @return void
*/
void add_pcf_info(const pcf_info_t& info);
/*
* Get list of PCF infos a PCF info
* @param [const pcf_info_t &] info: pcf info
* @return void
*/
void get_pcf_info(pcf_info_t& infos) const;
/*
* Print related-information for a PCF profile
* @param void
* @return void:
*/
void display();
/*
* Update a new value for a member of PCF 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 PCF 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 PCF 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 PCF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
void to_json(nlohmann::json& data) const;
private:
pcf_info_t pcf_info;
};
} // namespace app
} // namespace nrf
} // 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