Commit 03fad3c2 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Handle notification event type

parent cf3c819d
...@@ -42,6 +42,10 @@ void SubscriptionsCollectionApiImpl::create_subscription( ...@@ -42,6 +42,10 @@ void SubscriptionsCollectionApiImpl::create_subscription(
int http_code = 0; int http_code = 0;
ProblemDetails problem_details = {}; ProblemDetails problem_details = {};
std::string sub_id; std::string sub_id;
nlohmann::json json_sub = {};
to_json(json_sub,subscriptionData);
Logger::nrf_sbi().debug("Subscription data %s", json_sub.dump().c_str());
m_nrf_app->handle_create_subscription(subscriptionData, sub_id, http_code, 1, m_nrf_app->handle_create_subscription(subscriptionData, sub_id, http_code, 1,
problem_details); problem_details);
......
/** /**
* NRF NFManagement Service * NRF NFManagement Service
* NRF NFManagement Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved. * NRF NFManagement Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
* *
* The version of the OpenAPI document: 1.1.0.alpha-1 * The version of the OpenAPI document: 1.1.0.alpha-1
*
* *
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). *
* https://openapi-generator.tech * NOTE: This class is auto generated by OpenAPI Generator
* Do not edit the class manually. * (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/ */
#include "NfTypeCond.h" #include "NfTypeCond.h"
#include <iostream>
namespace oai { namespace oai {
namespace nrf { namespace nrf {
namespace model { namespace model {
NfTypeCond::NfTypeCond() { NfTypeCond::NfTypeCond() {}
} NfTypeCond::~NfTypeCond() {}
NfTypeCond::~NfTypeCond() {
}
void NfTypeCond::validate() { void NfTypeCond::validate() {
// TODO: implement validation // TODO: implement validation
...@@ -36,14 +35,9 @@ void from_json(const nlohmann::json &j, NfTypeCond &o) { ...@@ -36,14 +35,9 @@ void from_json(const nlohmann::json &j, NfTypeCond &o) {
j.at("nfType").get_to(o.m_NfType); j.at("nfType").get_to(o.m_NfType);
} }
std::string NfTypeCond::getNfType() const { std::string NfTypeCond::getNfType() const { return m_NfType; }
return m_NfType; void NfTypeCond::setNfType(std::string const &value) { m_NfType = value; }
}
void NfTypeCond::setNfType(std::string const &value) {
m_NfType = value;
}
}
}
}
} // namespace model
} // namespace nrf
} // namespace oai
...@@ -31,7 +31,7 @@ SubscriptionData::SubscriptionData() { ...@@ -31,7 +31,7 @@ SubscriptionData::SubscriptionData() {
m_ReqNfFqdn = ""; m_ReqNfFqdn = "";
m_ReqNfFqdnIsSet = false; m_ReqNfFqdnIsSet = false;
m_ReqSnssaisIsSet = false; m_ReqSnssaisIsSet = false;
//m_SubscrCond; m_SubscrCond = {};
} }
...@@ -74,7 +74,8 @@ void from_json(const nlohmann::json &j, SubscriptionData &o) { ...@@ -74,7 +74,8 @@ void from_json(const nlohmann::json &j, SubscriptionData &o) {
} }
if(j.find("subscrCond") != j.end()) if(j.find("subscrCond") != j.end())
{ {
j.at("subscrCond").get_to(o.m_SubscrCond); //j.at("subscrCond").get_to(o.m_SubscrCond);
o.m_SubscrCond = j.at("subscrCond");
o.m_SubscrCondIsSet = true; o.m_SubscrCondIsSet = true;
} }
...@@ -134,13 +135,12 @@ void SubscriptionData::unsetReqNfInstanceId() { ...@@ -134,13 +135,12 @@ void SubscriptionData::unsetReqNfInstanceId() {
m_ReqNfInstanceIdIsSet = false; m_ReqNfInstanceIdIsSet = false;
} }
subscription_condition_api_t SubscriptionData::getSubscrCond() const void SubscriptionData::getSubscrCond(nlohmann::json &s) const
{ {
return m_SubscrCond; s = m_SubscrCond;
} }
void SubscriptionData::setSubscrCond(nlohmann::json const& value)
void SubscriptionData::setSubscrCond(subscription_condition_api_t const& value)
{ {
m_SubscrCond = value; m_SubscrCond = value;
m_SubscrCondIsSet = true; m_SubscrCondIsSet = true;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
//#include //#include
//"OneOfNfInstanceIdCondNfTypeCondServiceNameCondAmfCondGuamiListCondNetworkSliceCondNfGroupCond.h" //"OneOfNfInstanceIdCondNfTypeCondServiceNameCondAmfCondGuamiListCondNetworkSliceCondNfGroupCond.h"
#include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -54,18 +55,11 @@ typedef struct subscription_condition_api_s { ...@@ -54,18 +55,11 @@ typedef struct subscription_condition_api_s {
}; };
subscription_condition_api_s() : type(0) { subscription_condition_api_s() : type(0) {
nfInstanceIdCond = {}; // TODO
nfTypeCond = {};
serviceNameCond = {};
amfCond = {};
guamiListCond = {};
networkSliceCond = {};
nfGroupCond = {};
} }
subscription_condition_api_s(subscription_condition_api_s const &s) { subscription_condition_api_s(subscription_condition_api_s const &s) {
nfInstanceIdCond = s.nfInstanceIdCond; nfInstanceIdCond = s.nfInstanceIdCond;
// nfInstanceIdCond.setNfInstanceId(s.nfInstanceIdCond.getNfInstanceId());
nfTypeCond = s.nfTypeCond; nfTypeCond = s.nfTypeCond;
serviceNameCond = s.serviceNameCond; serviceNameCond = s.serviceNameCond;
amfCond = s.amfCond; amfCond = s.amfCond;
...@@ -91,15 +85,7 @@ typedef struct subscription_condition_api_s { ...@@ -91,15 +85,7 @@ typedef struct subscription_condition_api_s {
bool operator==(const uint8_t &t) const { return (t == type); } bool operator==(const uint8_t &t) const { return (t == type); }
subscription_condition_api_s &operator=(subscription_condition_api_s s) { subscription_condition_api_s &operator=(subscription_condition_api_s s) {
nfInstanceIdCond = s.nfInstanceIdCond; // TODO:
// nfInstanceIdCond.setNfInstanceId(s.nfInstanceIdCond.getNfInstanceId());
nfTypeCond = s.nfTypeCond;
serviceNameCond = s.serviceNameCond;
amfCond = s.amfCond;
guamiListCond = s.guamiListCond;
networkSliceCond = s.networkSliceCond;
nfGroupCond = s.nfGroupCond;
return *this;
} }
friend void to_json(nlohmann::json &j, friend void to_json(nlohmann::json &j,
...@@ -140,6 +126,8 @@ typedef struct subscription_condition_api_s { ...@@ -140,6 +126,8 @@ typedef struct subscription_condition_api_s {
o.type = 1; o.type = 1;
} }
if (j.find("NfTypeCond") != j.end()) { if (j.find("NfTypeCond") != j.end()) {
o.nfTypeCond = {};
j.at("NfTypeCond").get_to(o.nfTypeCond); j.at("NfTypeCond").get_to(o.nfTypeCond);
o.type = 2; o.type = 2;
} }
...@@ -202,9 +190,9 @@ class SubscriptionData { ...@@ -202,9 +190,9 @@ class SubscriptionData {
// OneOfNfInstanceIdCondNfTypeCondServiceNameCondAmfCondGuamiListCondNetworkSliceCondNfGroupCond // OneOfNfInstanceIdCondNfTypeCondServiceNameCondAmfCondGuamiListCondNetworkSliceCondNfGroupCond
// getSubscrCond() const; // getSubscrCond() const;
subscription_condition_api_t getSubscrCond() const; void getSubscrCond(nlohmann::json &s) const;
void setSubscrCond(subscription_condition_api_t const &value); void setSubscrCond(nlohmann::json const &value);
bool subscrCondIsSet() const; bool subscrCondIsSet() const;
void unsetSubscrCond(); void unsetSubscrCond();
/// <summary> /// <summary>
...@@ -272,7 +260,7 @@ class SubscriptionData { ...@@ -272,7 +260,7 @@ class SubscriptionData {
bool m_ReqNfInstanceIdIsSet; bool m_ReqNfInstanceIdIsSet;
// OneOfNfInstanceIdCondNfTypeCondServiceNameCondAmfCondGuamiListCondNetworkSliceCondNfGroupCond // OneOfNfInstanceIdCondNfTypeCondServiceNameCondAmfCondGuamiListCondNetworkSliceCondNfGroupCond
// m_SubscrCond; // m_SubscrCond;
subscription_condition_api_t m_SubscrCond; nlohmann::json m_SubscrCond;
bool m_SubscrCondIsSet; bool m_SubscrCondIsSet;
std::string m_SubscriptionId; std::string m_SubscriptionId;
......
...@@ -29,7 +29,7 @@ enum class nf_status_e { REGISTERED = 0, SUSPENDED = 1, UNDISCOVERABLE = 2 }; ...@@ -29,7 +29,7 @@ enum class nf_status_e { REGISTERED = 0, SUSPENDED = 1, UNDISCOVERABLE = 2 };
static const std::vector<std::string> nf_status_e2str = { static const std::vector<std::string> nf_status_e2str = {
"REGISTERED", "SUSPENDED", "UNDISCOVERABLE"}; "REGISTERED", "SUSPENDED", "UNDISCOVERABLE"};
enum subscription_condition_type { enum subscription_condition_type_e {
UNKNOWN_CONDITION = 0, UNKNOWN_CONDITION = 0,
NF_INSTANCE_ID_COND = 1, NF_INSTANCE_ID_COND = 1,
NF_TYPE_COND = 2, NF_TYPE_COND = 2,
...@@ -40,6 +40,12 @@ enum subscription_condition_type { ...@@ -40,6 +40,12 @@ enum subscription_condition_type {
NF_GROUP_COND = 7 NF_GROUP_COND = 7
}; };
static const std::vector<std::string> subscription_condition_type_e2str = {
"UNKNOWN_CONDITION", "NF_INSTANCE_ID_COND",
"NF_TYPE_COND", "SERVICE_NAME_COND",
"AMF_COND", "GUAMI_LIST_COND",
"NETWOTK_SLICE_COND", "NF_GROUP_COND"};
typedef struct amf_cond_s { typedef struct amf_cond_s {
std::string amf_set_id; std::string amf_set_id;
std::string amf_region_id; std::string amf_region_id;
...@@ -82,4 +88,10 @@ typedef struct subscription_condition_s { ...@@ -82,4 +88,10 @@ typedef struct subscription_condition_s {
} subscription_condition_t; } subscription_condition_t;
enum notification_event_type_t {
NOTIFICATION_TYPE_NF_REGISTERED = 0,
NOTIFICATION_TYPE_NF_DEREGISTERED = 1,
NOTIFICATION_TYPE_NF_PROFILE_CHANGED = 2
};
#endif #endif
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#include <nlohmann/json.hpp>
#include <regex> #include <regex>
#include "3gpp_29.510.h" #include "3gpp_29.510.h"
...@@ -170,24 +171,32 @@ bool api_conv::subscription_api_to_nrf_subscription( ...@@ -170,24 +171,32 @@ bool api_conv::subscription_api_to_nrf_subscription(
sub.get()->set_notification_uri(api_sub.getNfStatusNotificationUri()); sub.get()->set_notification_uri(api_sub.getNfStatusNotificationUri());
subscription_condition_t sub_condition = {}; subscription_condition_t sub_condition = {};
/*
if (api_sub.subscrCondIsSet()) { if (api_sub.subscrCondIsSet()) {
subscription_condition_api_t sub_condition_api = api_sub.getSubscrCond(); subscription_condition_api_t sub_condition_api = {};
api_sub.getSubscrCond(sub_condition_api);
switch (sub_condition_api.type) { switch (sub_condition_api.type) {
case NF_INSTANCE_ID_COND: { case NF_INSTANCE_ID_COND: {
Logger::nrf_app().debug(
"Subscription condition type: NF_INSTANCE_ID_COND");
sub_condition.type = NF_INSTANCE_ID_COND; sub_condition.type = NF_INSTANCE_ID_COND;
sub_condition.nf_instance_id = sub_condition.nf_instance_id =
sub_condition_api.nfInstanceIdCond.getNfInstanceId(); sub_condition_api.nfInstanceIdCond.getNfInstanceId();
} break; } break;
case NF_TYPE_COND: { case NF_TYPE_COND: {
Logger::nrf_app().debug("Subscription condition type: NF_TYPE_COND");
sub_condition.type = NF_TYPE_COND; sub_condition.type = NF_TYPE_COND;
sub_condition.nf_type = sub_condition_api.nfTypeCond.getNfType(); sub_condition.nf_type = sub_condition_api.nfTypeCond.getNfType();
} break; } break;
case SERVICE_NAME_COND: { case SERVICE_NAME_COND: {
Logger::nrf_app().debug(
"Subscription condition type: SERVICE_NAME_COND");
sub_condition.type = SERVICE_NAME_COND; sub_condition.type = SERVICE_NAME_COND;
sub_condition.service_name = sub_condition.service_name =
sub_condition_api.serviceNameCond.getServiceName(); sub_condition_api.serviceNameCond.getServiceName();
} break; } break;
case AMF_COND: { case AMF_COND: {
Logger::nrf_app().debug("Subscription condition type: AMF_COND");
sub_condition.type = AMF_COND; sub_condition.type = AMF_COND;
sub_condition.amf_info.amf_set_id = sub_condition.amf_info.amf_set_id =
sub_condition_api.amfCond.getAmfSetId(); sub_condition_api.amfCond.getAmfSetId();
...@@ -195,23 +204,85 @@ bool api_conv::subscription_api_to_nrf_subscription( ...@@ -195,23 +204,85 @@ bool api_conv::subscription_api_to_nrf_subscription(
sub_condition_api.amfCond.getAmfRegionId(); sub_condition_api.amfCond.getAmfRegionId();
} break; } break;
case GUAMI_LIST_COND: { case GUAMI_LIST_COND: {
Logger::nrf_app().debug("Subscription condition type: GUAMI_LIST_COND");
sub_condition.type = GUAMI_LIST_COND; sub_condition.type = GUAMI_LIST_COND;
// TODO: // TODO:
} break; } break;
case NETWOTK_SLICE_COND: { case NETWOTK_SLICE_COND: {
Logger::nrf_app().debug(
"Subscription condition type: NETWOTK_SLICE_COND");
sub_condition.type = NETWOTK_SLICE_COND; sub_condition.type = NETWOTK_SLICE_COND;
// TODO: // TODO:
} break; } break;
case NF_GROUP_COND: { case NF_GROUP_COND: {
Logger::nrf_app().debug("Subscription condition type: NF_GROUP_COND");
sub_condition.type = NF_GROUP_COND; sub_condition.type = NF_GROUP_COND;
// TODO: // TODO:
} break; } break;
default: { default: {
return false; Logger::nrf_app().debug("Subscription condition type: Unknown");
return false;
} }
} }
} }
*/
if (api_sub.subscrCondIsSet()) {
nlohmann::json sub_condition_api = {};
api_sub.getSubscrCond(sub_condition_api);
if (sub_condition_api.find("NfInstanceIdCond") != sub_condition_api.end()) {
sub_condition.type = NF_INSTANCE_ID_COND;
sub_condition.nf_instance_id = sub_condition_api.at("NfInstanceIdCond")
.at("nfInstanceId")
.dump()
.c_str();
Logger::nrf_app().debug(
"Subscription condition type: NfInstanceIdCond, nfInstanceId: %s",
sub_condition.nf_instance_id.c_str());
}
if (sub_condition_api.find("NfTypeCond") != sub_condition_api.end()) {
sub_condition.type = NF_TYPE_COND;
sub_condition.nf_type =
sub_condition_api.at("NfTypeCond").at("nfType").dump().c_str();
Logger::nrf_app().debug(
"Subscription condition type: NfTypeCond, nf_type: %s",
sub_condition.nf_type.c_str());
}
if (sub_condition_api.find("ServiceNameCond") != sub_condition_api.end()) {
sub_condition.type = SERVICE_NAME_COND;
sub_condition.service_name = sub_condition_api.at("ServiceNameCond")
.at("serviceName")
.dump()
.c_str();
Logger::nrf_app().debug(
"Subscription condition type: ServiceNameCond, serviceName: %s",
sub_condition.service_name.c_str());
}
if (sub_condition_api.find("AmfCond") != sub_condition_api.end()) {
sub_condition.type = AMF_COND;
sub_condition.amf_info.amf_set_id =
sub_condition_api.at("AmfCond").at("amfSetId").dump().c_str();
sub_condition.amf_info.amf_region_id =
sub_condition_api.at("AmfCond").at("amfRegionId").dump().c_str();
Logger::nrf_app().debug(
"Subscription condition type: AmfCond, amfSetId: %s, amfRegionId: "
"%s ",
sub_condition.amf_info.amf_set_id.c_str(),
sub_condition.amf_info.amf_region_id.c_str());
}
if (sub_condition_api.find("GuamiListCond") != sub_condition_api.end()) {
sub_condition.type = GUAMI_LIST_COND;
// TODO
}
Logger::nrf_app().debug(
"Subscription condition type: %s",
subscription_condition_type_e2str[sub_condition.type].c_str());
}
// TODO: // TODO:
return true; return true;
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "nrf_app.hpp" #include "nrf_app.hpp"
#include <chrono> #include <chrono>
#include "3gpp_29.500.h" #include "3gpp_29.500.h"
#include "3gpp_29.510.h"
#include "api_conversions.hpp" #include "api_conversions.hpp"
#include "common_defs.h" #include "common_defs.h"
#include "logger.hpp" #include "logger.hpp"
...@@ -280,35 +281,40 @@ void nrf_app::handle_deregister_nf_instance(const std::string &nf_instance_id, ...@@ -280,35 +281,40 @@ void nrf_app::handle_deregister_nf_instance(const std::string &nf_instance_id,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_app::handle_create_subscription( void nrf_app::handle_create_subscription(
const SubscriptionData &subscription_data, std::string &sub_id, int &http_code, const SubscriptionData &subscription_data, std::string &sub_id,
const uint8_t http_version, ProblemDetails &problem_details) { int &http_code, const uint8_t http_version,
ProblemDetails &problem_details) {
std::string evsub_id; std::string evsub_id;
Logger::nrf_app().info("Handle Create a new subscription (HTTP version %d)", Logger::nrf_app().info("Handle Create a new subscription (HTTP version %d)",
http_version); http_version);
std::shared_ptr<nrf_subscription> ss = std::make_shared<nrf_subscription>(m_event_sub); std::shared_ptr<nrf_subscription> ss =
std::make_shared<nrf_subscription>(m_event_sub);
// convert to nrf_subscription // convert to nrf_subscription
if (api_conv::subscription_api_to_nrf_subscription(subscription_data, ss)) { if (api_conv::subscription_api_to_nrf_subscription(subscription_data, ss)) {
if (authorize_subscription(ss)) { if (authorize_subscription(ss)) {
// generate a subscription ID // generate a subscription ID
generate_ev_subscription_id(evsub_id); generate_ev_subscription_id(evsub_id);
ss.get()->set_subscription_id(evsub_id); ss.get()->set_subscription_id(evsub_id);
//subscribe to NF status change
ss.get()->subscribe_nf_status_change(); // subscribe to NF status registered
// add to the DB subscribe_nf_status(evsub_id); // from nrf_app
add_subscription(evsub_id, ss); // subscribe to NF status change
Logger::nrf_app().debug("Added a subscription to the DB"); // ss.get()->subscribe_nf_status_change(); //from subscription
// display the info // add to the DB
ss.get()->display(); add_subscription(evsub_id, ss);
//assign info for API server Logger::nrf_app().debug("Added a subscription to the DB");
http_code = HTTP_STATUS_CODE_201_CREATED; // display the info
sub_id = evsub_id; ss.get()->display();
return; // assign info for API server
http_code = HTTP_STATUS_CODE_201_CREATED;
sub_id = evsub_id;
return;
} else { } else {
Logger::nrf_app().debug("Subscription is not authorized!"); Logger::nrf_app().debug("Subscription is not authorized!");
http_code = HTTP_STATUS_CODE_401_UNAUTHORIZED; http_code = HTTP_STATUS_CODE_401_UNAUTHORIZED;
return; return;
} }
} else { } else {
...@@ -350,8 +356,9 @@ bool nrf_app::add_nf_profile(const std::string &profile_id, ...@@ -350,8 +356,9 @@ bool nrf_app::add_nf_profile(const std::string &profile_id,
.count(); .count();
p.get()->subscribe_task_tick(ms); p.get()->subscribe_task_tick(ms);
//Notify NF status change event // Notify NF status change event
m_event_sub.nf_status_change(p); // m_event_sub.nf_status_change(p); //from subscription
m_event_sub.nf_status_registered(profile_id); // from nrf_app
return true; return true;
} }
...@@ -502,10 +509,13 @@ void nrf_app::handle_heartbeart_timeout(uint64_t ms) { ...@@ -502,10 +509,13 @@ void nrf_app::handle_heartbeart_timeout(uint64_t ms) {
Logger::nrf_app().info("handle_heartbeart_timeout %d", ms); Logger::nrf_app().info("handle_heartbeart_timeout %d", ms);
} }
bool nrf_app::authorize_subscription(const std::shared_ptr<nrf_subscription> &s) const { //------------------------------------------------------------------------------
//TODO: bool nrf_app::authorize_subscription(
return true; const std::shared_ptr<nrf_subscription> &s) const {
// TODO:
return true;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_app::generate_ev_subscription_id(std::string &sub_id) { void nrf_app::generate_ev_subscription_id(std::string &sub_id) {
sub_id = std::to_string(evsub_id_generator.get_uid()); sub_id = std::to_string(evsub_id_generator.get_uid());
...@@ -515,3 +525,79 @@ void nrf_app::generate_ev_subscription_id(std::string &sub_id) { ...@@ -515,3 +525,79 @@ void nrf_app::generate_ev_subscription_id(std::string &sub_id) {
evsub_id_t nrf_app::generate_ev_subscription_id() { evsub_id_t nrf_app::generate_ev_subscription_id() {
return evsub_id_generator.get_uid(); return evsub_id_generator.get_uid();
} }
//------------------------------------------------------------------------------
void nrf_app::subscribe_nf_status(const std::string &sub_id) {
// depending on the type of subscription, subscribe to the corresponding event
// for now subscribe to all events
subscribe_nf_status_registered();
subscribe_nf_status_deregistered();
subscribe_nf_status_profile_changed();
}
/*
//------------------------------------------------------------------------------
void nrf_app::handle_nf_status(const std::string &profile_id) {
Logger::nrf_app().info("Handle NF status, profile id %s",
profile_id.c_str()); std::vector<std::string> notification_uris = {};
get_subscription_list(profile_id, notification_uris);
}
*/
//------------------------------------------------------------------------------
void nrf_app::subscribe_nf_status_registered() {
Logger::nrf_app().debug("Subscribe to NF status registered");
m_event_sub.subscribe_nf_status_registered(
boost::bind(&nrf_app::handle_nf_status_registered, this, _1));
}
//------------------------------------------------------------------------------
void nrf_app::handle_nf_status_registered(const std::string &profile_id) {
Logger::nrf_app().info("Handle NF status registered, profile id %s",
profile_id.c_str());
std::vector<std::string> notification_uris = {};
get_subscription_list(profile_id, NOTIFICATION_TYPE_NF_REGISTERED,
notification_uris);
// TODO:
}
//------------------------------------------------------------------------------
void nrf_app::subscribe_nf_status_deregistered() {
Logger::nrf_app().debug("Subscribe to NF status deregistered");
m_event_sub.subscribe_nf_status_deregistered(
boost::bind(&nrf_app::handle_nf_status_deregistered, this, _1));
}
//------------------------------------------------------------------------------
void nrf_app::handle_nf_status_deregistered(const std::string &profile_id) {
Logger::nrf_app().info("Handle NF status deregistered, profile id %s",
profile_id.c_str());
std::vector<std::string> notification_uris = {};
get_subscription_list(profile_id, NOTIFICATION_TYPE_NF_DEREGISTERED,
notification_uris);
// TODO:
}
//------------------------------------------------------------------------------
void nrf_app::subscribe_nf_status_profile_changed() {
Logger::nrf_app().debug("Subscribe to NF status profile changed");
m_event_sub.subscribe_nf_status_profile_changed(
boost::bind(&nrf_app::handle_nf_status_profile_changed, this, _1));
}
//------------------------------------------------------------------------------
void nrf_app::handle_nf_status_profile_changed(const std::string &profile_id) {
Logger::nrf_app().info("Handle NF status profile changed, profile id %s",
profile_id.c_str());
std::vector<std::string> notification_uris = {};
get_subscription_list(profile_id, NOTIFICATION_TYPE_NF_PROFILE_CHANGED,
notification_uris);
// TODO:
}
void nrf_app::get_subscription_list(const std::string &profile_id,
uint8_t notification_type,
std::vector<std::string> &uris) {
// TODO:
}
...@@ -212,6 +212,17 @@ class nrf_app { ...@@ -212,6 +212,17 @@ class nrf_app {
void generate_ev_subscription_id(std::string &sub_id); void generate_ev_subscription_id(std::string &sub_id);
evsub_id_t generate_ev_subscription_id(); evsub_id_t generate_ev_subscription_id();
void subscribe_nf_status(const std::string &sub_id);
// void handle_nf_status(const std::string &profile_id);
void subscribe_nf_status_registered();
void handle_nf_status_registered(const std::string &profile_id);
void subscribe_nf_status_deregistered();
void handle_nf_status_deregistered(const std::string &profile_id);
void subscribe_nf_status_profile_changed();
void handle_nf_status_profile_changed(const std::string &profile_id);
void get_subscription_list(const std::string &profile_id, uint8_t notification_type, std::vector<std::string> &uris);
private: private:
std::map<std::string, std::shared_ptr<nrf_profile>> instance_id2nrf_profile; std::map<std::string, std::shared_ptr<nrf_profile>> instance_id2nrf_profile;
mutable std::shared_mutex m_instance_id2nrf_profile; mutable std::shared_mutex m_instance_id2nrf_profile;
......
...@@ -67,9 +67,30 @@ bs2::connection nrf_event::subscribe_task_tick_extended( ...@@ -67,9 +67,30 @@ bs2::connection nrf_event::subscribe_task_tick_extended(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bs2::connection nrf_event::subscribe_nf_status_change( bs2::connection nrf_event::subscribe_nf_status_change(
const nf_status_sig_t::slot_type &sig) { const nf_status_change_sig_t::slot_type &sig) {
return nf_status_change.connect(sig); return nf_status_change.connect(sig);
} }
//------------------------------------------------------------------------------
bs2::connection nrf_event::subscribe_nf_status_registered(
const nf_status_sig_t::slot_type &sig) {
return nf_status_registered.connect(sig);
}
//------------------------------------------------------------------------------
bs2::connection nrf_event::subscribe_nf_status_deregistered(
const nf_status_sig_t::slot_type &sig) {
return nf_status_deregistered.connect(sig);
}
//------------------------------------------------------------------------------
bs2::connection nrf_event::subscribe_nf_status_profile_changed(
const nf_status_sig_t::slot_type &sig) {
return nf_status_profile_changed.connect(sig);
}
...@@ -70,11 +70,16 @@ class nrf_event { ...@@ -70,11 +70,16 @@ class nrf_event {
uint64_t period, uint64_t start = 0); uint64_t period, uint64_t start = 0);
bs2::connection subscribe_nf_status_change(const nf_status_sig_t::slot_type &sig); bs2::connection subscribe_nf_status_change(const nf_status_change_sig_t::slot_type &sig);
bs2::connection subscribe_nf_status_registered(const nf_status_sig_t::slot_type &sig);
bs2::connection subscribe_nf_status_deregistered(const nf_status_sig_t::slot_type &sig);
bs2::connection subscribe_nf_status_profile_changed(const nf_status_sig_t::slot_type &sig);
private: private:
task_sig_t task_tick; task_sig_t task_tick;
nf_status_sig_t nf_status_change; nf_status_change_sig_t nf_status_change;
nf_status_sig_t nf_status_registered;
nf_status_sig_t nf_status_deregistered;
nf_status_sig_t nf_status_profile_changed;
}; };
} }
......
...@@ -47,13 +47,13 @@ typedef bs2::signal_type<void(uint64_t), ...@@ -47,13 +47,13 @@ typedef bs2::signal_type<void(uint64_t),
// Signal for NF Status // Signal for NF Status
// Subscription ID, NF Status // Subscription ID, NF Status
//typedef bs2::signal_type<void(std::string), typedef bs2::signal_type<void(const std::string &),
// bs2::keywords::mutex_type<bs2::dummy_mutex>>::type bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
// nf_status_sig_t; nf_status_sig_t;
typedef bs2::signal_type<void(const std::shared_ptr<nrf_profile> &p), typedef bs2::signal_type<void(const std::shared_ptr<nrf_profile> &p),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
nf_status_sig_t; nf_status_change_sig_t;
} // namespace app } // namespace app
} // namespace nrf } // namespace nrf
......
...@@ -4,4 +4,4 @@ curl -X GET "http://192.168.1.23/nnrf-nfm/v1/nf-instances?nf-type="serviceId1"& ...@@ -4,4 +4,4 @@ curl -X GET "http://192.168.1.23/nnrf-nfm/v1/nf-instances?nf-type="serviceId1"&
curl -X PATCH -H "Content-Type: application/json" http://192.168.1.23/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d -d '[{"op":"replace","path":"/nfInstanceName", "value": "NEW NAME"}]' curl -X PATCH -H "Content-Type: application/json" http://192.168.1.23/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d -d '[{"op":"replace","path":"/nfInstanceName", "value": "NEW NAME"}]'
curl -X POST http://192.168.1.23/nnrf-nfm/v1/subscriptions -d '{"nfStatusNotificationUri":"http://192.168.1.23/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d"}' curl -X POST http://192.168.1.23/nnrf-nfm/v1/subscriptions -d '{"nfStatusNotificationUri":"http://192.168.1.23/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d", "subscrCond": {"nfType": "AMF"} }'
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