Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-NRF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-NRF
Commits
03fad3c2
Commit
03fad3c2
authored
Dec 18, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle notification event type
parent
cf3c819d
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
275 additions
and
83 deletions
+275
-83
src/api-server/impl/SubscriptionsCollectionApiImpl.cpp
src/api-server/impl/SubscriptionsCollectionApiImpl.cpp
+4
-0
src/api-server/model/NfTypeCond.cpp
src/api-server/model/NfTypeCond.cpp
+14
-20
src/api-server/model/SubscriptionData.cpp
src/api-server/model/SubscriptionData.cpp
+6
-6
src/api-server/model/SubscriptionData.h
src/api-server/model/SubscriptionData.h
+8
-20
src/common/3gpp_29.510.h
src/common/3gpp_29.510.h
+13
-1
src/common/utils/api_conversions.cpp
src/common/utils/api_conversions.cpp
+73
-2
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+111
-25
src/nrf_app/nrf_app.hpp
src/nrf_app/nrf_app.hpp
+11
-0
src/nrf_app/nrf_event.cpp
src/nrf_app/nrf_event.cpp
+22
-1
src/nrf_app/nrf_event.hpp
src/nrf_app/nrf_event.hpp
+8
-3
src/nrf_app/nrf_event_sig.hpp
src/nrf_app/nrf_event_sig.hpp
+4
-4
yaml/cmd.txt
yaml/cmd.txt
+1
-1
No files found.
src/api-server/impl/SubscriptionsCollectionApiImpl.cpp
View file @
03fad3c2
...
...
@@ -42,6 +42,10 @@ void SubscriptionsCollectionApiImpl::create_subscription(
int
http_code
=
0
;
ProblemDetails
problem_details
=
{};
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
,
problem_details
);
...
...
src/api-server/model/NfTypeCond.cpp
View file @
03fad3c2
/**
* 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
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "NfTypeCond.h"
#include <iostream>
namespace
oai
{
namespace
nrf
{
namespace
model
{
NfTypeCond
::
NfTypeCond
()
{
NfTypeCond
::
NfTypeCond
()
{
}
}
NfTypeCond
::~
NfTypeCond
()
{
}
NfTypeCond
::~
NfTypeCond
()
{}
void
NfTypeCond
::
validate
()
{
// TODO: implement validation
...
...
@@ -36,14 +35,9 @@ void from_json(const nlohmann::json &j, NfTypeCond &o) {
j
.
at
(
"nfType"
).
get_to
(
o
.
m_NfType
);
}
std
::
string
NfTypeCond
::
getNfType
()
const
{
return
m_NfType
;
}
void
NfTypeCond
::
setNfType
(
std
::
string
const
&
value
)
{
m_NfType
=
value
;
}
}
}
}
std
::
string
NfTypeCond
::
getNfType
()
const
{
return
m_NfType
;
}
void
NfTypeCond
::
setNfType
(
std
::
string
const
&
value
)
{
m_NfType
=
value
;
}
}
// namespace model
}
// namespace nrf
}
// namespace oai
src/api-server/model/SubscriptionData.cpp
View file @
03fad3c2
...
...
@@ -31,7 +31,7 @@ SubscriptionData::SubscriptionData() {
m_ReqNfFqdn
=
""
;
m_ReqNfFqdnIsSet
=
false
;
m_ReqSnssaisIsSet
=
false
;
//m_SubscrCond
;
m_SubscrCond
=
{}
;
}
...
...
@@ -74,7 +74,8 @@ void from_json(const nlohmann::json &j, SubscriptionData &o) {
}
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
;
}
...
...
@@ -134,13 +135,12 @@ void SubscriptionData::unsetReqNfInstanceId() {
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
(
subscription_condition_api_t
const
&
value
)
void
SubscriptionData
::
setSubscrCond
(
nlohmann
::
json
const
&
value
)
{
m_SubscrCond
=
value
;
m_SubscrCondIsSet
=
true
;
...
...
src/api-server/model/SubscriptionData.h
View file @
03fad3c2
...
...
@@ -21,6 +21,7 @@
//#include
//"OneOfNfInstanceIdCondNfTypeCondServiceNameCondAmfCondGuamiListCondNetworkSliceCondNfGroupCond.h"
#include <iostream>
#include <nlohmann/json.hpp>
#include <string>
#include <vector>
...
...
@@ -54,18 +55,11 @@ typedef struct subscription_condition_api_s {
};
subscription_condition_api_s
()
:
type
(
0
)
{
nfInstanceIdCond
=
{};
nfTypeCond
=
{};
serviceNameCond
=
{};
amfCond
=
{};
guamiListCond
=
{};
networkSliceCond
=
{};
nfGroupCond
=
{};
// TODO
}
subscription_condition_api_s
(
subscription_condition_api_s
const
&
s
)
{
nfInstanceIdCond
=
s
.
nfInstanceIdCond
;
// nfInstanceIdCond.setNfInstanceId(s.nfInstanceIdCond.getNfInstanceId());
nfTypeCond
=
s
.
nfTypeCond
;
serviceNameCond
=
s
.
serviceNameCond
;
amfCond
=
s
.
amfCond
;
...
...
@@ -91,15 +85,7 @@ typedef struct subscription_condition_api_s {
bool
operator
==
(
const
uint8_t
&
t
)
const
{
return
(
t
==
type
);
}
subscription_condition_api_s
&
operator
=
(
subscription_condition_api_s
s
)
{
nfInstanceIdCond
=
s
.
nfInstanceIdCond
;
// 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
;
// TODO:
}
friend
void
to_json
(
nlohmann
::
json
&
j
,
...
...
@@ -140,6 +126,8 @@ typedef struct subscription_condition_api_s {
o
.
type
=
1
;
}
if
(
j
.
find
(
"NfTypeCond"
)
!=
j
.
end
())
{
o
.
nfTypeCond
=
{};
j
.
at
(
"NfTypeCond"
).
get_to
(
o
.
nfTypeCond
);
o
.
type
=
2
;
}
...
...
@@ -202,9 +190,9 @@ class SubscriptionData {
// OneOfNfInstanceIdCondNfTypeCondServiceNameCondAmfCondGuamiListCondNetworkSliceCondNfGroupCond
// 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
;
void
unsetSubscrCond
();
/// <summary>
...
...
@@ -272,7 +260,7 @@ class SubscriptionData {
bool
m_ReqNfInstanceIdIsSet
;
// OneOfNfInstanceIdCondNfTypeCondServiceNameCondAmfCondGuamiListCondNetworkSliceCondNfGroupCond
// m_SubscrCond;
subscription_condition_api_t
m_SubscrCond
;
nlohmann
::
json
m_SubscrCond
;
bool
m_SubscrCondIsSet
;
std
::
string
m_SubscriptionId
;
...
...
src/common/3gpp_29.510.h
View file @
03fad3c2
...
...
@@ -29,7 +29,7 @@ enum class nf_status_e { REGISTERED = 0, SUSPENDED = 1, UNDISCOVERABLE = 2 };
static
const
std
::
vector
<
std
::
string
>
nf_status_e2str
=
{
"REGISTERED"
,
"SUSPENDED"
,
"UNDISCOVERABLE"
};
enum
subscription_condition_type
{
enum
subscription_condition_type
_e
{
UNKNOWN_CONDITION
=
0
,
NF_INSTANCE_ID_COND
=
1
,
NF_TYPE_COND
=
2
,
...
...
@@ -40,6 +40,12 @@ enum subscription_condition_type {
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
{
std
::
string
amf_set_id
;
std
::
string
amf_region_id
;
...
...
@@ -82,4 +88,10 @@ typedef struct subscription_condition_s {
}
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
src/common/utils/api_conversions.cpp
View file @
03fad3c2
...
...
@@ -35,6 +35,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <nlohmann/json.hpp>
#include <regex>
#include "3gpp_29.510.h"
...
...
@@ -170,24 +171,32 @@ bool api_conv::subscription_api_to_nrf_subscription(
sub
.
get
()
->
set_notification_uri
(
api_sub
.
getNfStatusNotificationUri
());
subscription_condition_t
sub_condition
=
{};
/*
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) {
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.nf_instance_id =
sub_condition_api.nfInstanceIdCond.getNfInstanceId();
} break;
case NF_TYPE_COND: {
Logger::nrf_app().debug("Subscription condition type: NF_TYPE_COND");
sub_condition.type = NF_TYPE_COND;
sub_condition.nf_type = sub_condition_api.nfTypeCond.getNfType();
} break;
case SERVICE_NAME_COND: {
Logger::nrf_app().debug(
"Subscription condition type: SERVICE_NAME_COND");
sub_condition.type = SERVICE_NAME_COND;
sub_condition.service_name =
sub_condition_api.serviceNameCond.getServiceName();
} break;
case AMF_COND: {
Logger::nrf_app().debug("Subscription condition type: AMF_COND");
sub_condition.type = AMF_COND;
sub_condition.amf_info.amf_set_id =
sub_condition_api.amfCond.getAmfSetId();
...
...
@@ -195,23 +204,85 @@ bool api_conv::subscription_api_to_nrf_subscription(
sub_condition_api.amfCond.getAmfRegionId();
} break;
case GUAMI_LIST_COND: {
Logger::nrf_app().debug("Subscription condition type: GUAMI_LIST_COND");
sub_condition.type = GUAMI_LIST_COND;
// TODO:
} break;
case NETWOTK_SLICE_COND: {
Logger::nrf_app().debug(
"Subscription condition type: NETWOTK_SLICE_COND");
sub_condition.type = NETWOTK_SLICE_COND;
// TODO:
} break;
case NF_GROUP_COND: {
Logger::nrf_app().debug("Subscription condition type: NF_GROUP_COND");
sub_condition.type = NF_GROUP_COND;
// TODO:
} break;
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:
return
true
;
}
...
...
src/nrf_app/nrf_app.cpp
View file @
03fad3c2
...
...
@@ -30,6 +30,7 @@
#include "nrf_app.hpp"
#include <chrono>
#include "3gpp_29.500.h"
#include "3gpp_29.510.h"
#include "api_conversions.hpp"
#include "common_defs.h"
#include "logger.hpp"
...
...
@@ -280,35 +281,40 @@ void nrf_app::handle_deregister_nf_instance(const std::string &nf_instance_id,
//------------------------------------------------------------------------------
void
nrf_app
::
handle_create_subscription
(
const
SubscriptionData
&
subscription_data
,
std
::
string
&
sub_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
const
SubscriptionData
&
subscription_data
,
std
::
string
&
sub_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
std
::
string
evsub_id
;
Logger
::
nrf_app
().
info
(
"Handle Create a new subscription (HTTP version %d)"
,
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
if
(
api_conv
::
subscription_api_to_nrf_subscription
(
subscription_data
,
ss
))
{
if
(
authorize_subscription
(
ss
))
{
// generate a subscription ID
generate_ev_subscription_id
(
evsub_id
);
ss
.
get
()
->
set_subscription_id
(
evsub_id
);
//subscribe to NF status change
ss
.
get
()
->
subscribe_nf_status_change
();
// add to the DB
add_subscription
(
evsub_id
,
ss
);
Logger
::
nrf_app
().
debug
(
"Added a subscription to the DB"
);
// display the info
ss
.
get
()
->
display
();
//assign info for API server
http_code
=
HTTP_STATUS_CODE_201_CREATED
;
sub_id
=
evsub_id
;
return
;
// generate a subscription ID
generate_ev_subscription_id
(
evsub_id
);
ss
.
get
()
->
set_subscription_id
(
evsub_id
);
// subscribe to NF status registered
subscribe_nf_status
(
evsub_id
);
// from nrf_app
// subscribe to NF status change
// ss.get()->subscribe_nf_status_change(); //from subscription
// add to the DB
add_subscription
(
evsub_id
,
ss
);
Logger
::
nrf_app
().
debug
(
"Added a subscription to the DB"
);
// display the info
ss
.
get
()
->
display
();
// assign info for API server
http_code
=
HTTP_STATUS_CODE_201_CREATED
;
sub_id
=
evsub_id
;
return
;
}
else
{
Logger
::
nrf_app
().
debug
(
"Subscription is not authorized!"
);
http_code
=
HTTP_STATUS_CODE_401_UNAUTHORIZED
;
return
;
Logger
::
nrf_app
().
debug
(
"Subscription is not authorized!"
);
http_code
=
HTTP_STATUS_CODE_401_UNAUTHORIZED
;
return
;
}
}
else
{
...
...
@@ -350,8 +356,9 @@ bool nrf_app::add_nf_profile(const std::string &profile_id,
.
count
();
p
.
get
()
->
subscribe_task_tick
(
ms
);
//Notify NF status change event
m_event_sub
.
nf_status_change
(
p
);
// Notify NF status change event
// m_event_sub.nf_status_change(p); //from subscription
m_event_sub
.
nf_status_registered
(
profile_id
);
// from nrf_app
return
true
;
}
...
...
@@ -502,10 +509,13 @@ void nrf_app::handle_heartbeart_timeout(uint64_t ms) {
Logger
::
nrf_app
().
info
(
"handle_heartbeart_timeout %d"
,
ms
);
}
bool
nrf_app
::
authorize_subscription
(
const
std
::
shared_ptr
<
nrf_subscription
>
&
s
)
const
{
//TODO:
return
true
;
//------------------------------------------------------------------------------
bool
nrf_app
::
authorize_subscription
(
const
std
::
shared_ptr
<
nrf_subscription
>
&
s
)
const
{
// TODO:
return
true
;
}
//------------------------------------------------------------------------------
void
nrf_app
::
generate_ev_subscription_id
(
std
::
string
&
sub_id
)
{
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) {
evsub_id_t
nrf_app
::
generate_ev_subscription_id
()
{
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:
}
src/nrf_app/nrf_app.hpp
View file @
03fad3c2
...
...
@@ -212,6 +212,17 @@ class nrf_app {
void
generate_ev_subscription_id
(
std
::
string
&
sub_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:
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
nrf_profile
>>
instance_id2nrf_profile
;
mutable
std
::
shared_mutex
m_instance_id2nrf_profile
;
...
...
src/nrf_app/nrf_event.cpp
View file @
03fad3c2
...
...
@@ -67,9 +67,30 @@ bs2::connection nrf_event::subscribe_task_tick_extended(
//------------------------------------------------------------------------------
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
);
}
//------------------------------------------------------------------------------
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
);
}
src/nrf_app/nrf_event.hpp
View file @
03fad3c2
...
...
@@ -70,11 +70,16 @@ class nrf_event {
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:
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
;
};
}
...
...
src/nrf_app/nrf_event_sig.hpp
View file @
03fad3c2
...
...
@@ -47,13 +47,13 @@ typedef bs2::signal_type<void(uint64_t),
// Signal for NF Status
// Subscription ID, NF Status
//typedef bs2::signal_type<void(std::string
),
//
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
//
nf_status_sig_t;
typedef
bs2
::
signal_type
<
void
(
const
std
::
string
&
),
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
nf_status_sig_t
;
typedef
bs2
::
signal_type
<
void
(
const
std
::
shared_ptr
<
nrf_profile
>
&
p
),
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
nf_status_sig_t
;
nf_status_
change_
sig_t
;
}
// namespace app
}
// namespace nrf
...
...
yaml/cmd.txt
View file @
03fad3c2
...
...
@@ -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 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"}
}'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment