Commit c0621b90 authored by Raphael Defosseux's avatar Raphael Defosseux
Browse files

Merge branch 'fqdn_dns' into 'develop'

Add function to allow a NF receives the existed NFs which matches the...

See merge request !8
parents 52ed32fc 9bb39cf2
Pipeline #26092 passed with stage
in 0 seconds
......@@ -168,6 +168,13 @@ void nrf_app::handle_register_nf_instance(
Logger::nrf_app().debug(
"Added/Updated NF Profile with the NF instance info");
sn.get()->display();
nlohmann::json json_tmp = {};
sn.get()->to_json(json_tmp);
Logger::nrf_app().info(
"Added/Updated NF Instance, NF info: %s", json_tmp.dump().c_str());
} else {
// error
Logger::nrf_app().warn(
......@@ -438,6 +445,36 @@ void nrf_app::handle_create_subscription(
// assign info for API server
http_code = HTTP_STATUS_CODE_201_CREATED;
sub_id = evsub_id;
// Send notification (with the existed NFs which matches the
// conditions)
std::string notification_uri =
subscription_data.getNfStatusNotificationUri();
std::vector<uint8_t> ev_types;
ss.get()->get_notif_events(ev_types);
bool nf_registered_event = false;
for (auto ev : ev_types) {
if (ev == NOTIFICATION_TYPE_NF_REGISTERED) {
nf_registered_event = true;
}
}
if (nf_registered_event) {
std::vector<std::shared_ptr<nrf_profile>> profiles = {};
subscription_condition_t sub_condition = {};
ss.get()->get_sub_condition(sub_condition);
find_nf_profiles(sub_condition, profiles);
std::vector<std::string> notification_uris = {};
notification_uris.push_back(notification_uri);
for (auto p : profiles) {
// send notifications
nrf_client_inst->notify_subscribed_event(
p, NOTIFICATION_TYPE_NF_REGISTERED, notification_uris);
}
}
return;
} else {
Logger::nrf_app().debug("Subscription is not authorized!");
......@@ -781,6 +818,53 @@ void nrf_app::find_nf_profiles(
}
}
//------------------------------------------------------------------------------
void nrf_app::find_nf_profiles(
const subscription_condition_t& sub_condition,
std::vector<std::shared_ptr<nrf_profile>>& profiles) const {
std::shared_lock lock(m_instance_id2nrf_profile);
switch (sub_condition.type) {
case NF_INSTANCE_ID_COND: {
// TODO:
} break;
case NF_TYPE_COND: {
nf_type_t nf_type = api_conv::string_to_nf_type(sub_condition.nf_type);
for (auto profile : instance_id2nrf_profile) {
if (profile.second.get()->get_nf_type() == nf_type) {
profiles.push_back(profile.second);
}
}
} break;
case SERVICE_NAME_COND: {
// TODO:
} break;
case AMF_COND:
// TODO
break;
case GUAMI_LIST_COND: {
// TODO:
} break;
case NETWOTK_SLICE_COND: {
// TODO:
} break;
case NF_GROUP_COND: {
// TODO:
} break;
default: {
// TODO:
}
}
return;
}
//------------------------------------------------------------------------------
bool nrf_app::is_profile_exist(const std::string& profile_id) const {
Logger::nrf_app().info(
......
......@@ -255,6 +255,18 @@ class nrf_app {
const nf_type_t& nf_type,
std::vector<std::shared_ptr<nrf_profile>>& profiles) const;
/*
* Find a list of nf profiles matching the condition
* @param [const subscription_condition_t &] sub_condition: Subscription
* condition
* @param [std::vector<std::shared_ptr<nrf_profile>> &] profiles: Store list
* of corresponding profiles
* @return shared pointer to the profile if found
*/
void find_nf_profiles(
const subscription_condition_t& sub_condition,
std::vector<std::shared_ptr<nrf_profile>>& profiles) const;
/*
* Check if a profile with an ID exist
* @param [const std::string &] profile_id: Profile ID
......
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