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
d3c88ee7
Commit
d3c88ee7
authored
Dec 22, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add nf profile to notification data
parent
a2b4161c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
10 deletions
+30
-10
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+4
-4
src/nrf_app/nrf_client.cpp
src/nrf_app/nrf_client.cpp
+23
-4
src/nrf_app/nrf_client.hpp
src/nrf_app/nrf_client.hpp
+2
-0
src/nrf_app/nrf_profile.cpp
src/nrf_app/nrf_profile.cpp
+0
-2
src/nrf_app/nrf_profile.hpp
src/nrf_app/nrf_profile.hpp
+1
-0
No files found.
src/nrf_app/nrf_app.cpp
View file @
d3c88ee7
...
@@ -584,7 +584,7 @@ void nrf_app::handle_nf_status_registered(const std::string &profile_id) {
...
@@ -584,7 +584,7 @@ void nrf_app::handle_nf_status_registered(const std::string &profile_id) {
notification_uris
);
notification_uris
);
// send notifications
// send notifications
if
(
notification_uris
.
size
()
>
0
)
if
(
notification_uris
.
size
()
>
0
)
nrf_client_inst
->
notify_subscribed_event
(
profile
,
notification_uris
);
nrf_client_inst
->
notify_subscribed_event
(
profile
,
NOTIFICATION_TYPE_NF_REGISTERED
,
notification_uris
);
else
else
Logger
::
nrf_app
().
debug
(
"
\t
No subscription found"
);
Logger
::
nrf_app
().
debug
(
"
\t
No subscription found"
);
...
@@ -614,7 +614,7 @@ void nrf_app::handle_nf_status_deregistered(const std::string &profile_id) {
...
@@ -614,7 +614,7 @@ void nrf_app::handle_nf_status_deregistered(const std::string &profile_id) {
get_subscription_list
(
profile_id
,
NOTIFICATION_TYPE_NF_DEREGISTERED
,
get_subscription_list
(
profile_id
,
NOTIFICATION_TYPE_NF_DEREGISTERED
,
notification_uris
);
notification_uris
);
// send notifications
// send notifications
nrf_client_inst
->
notify_subscribed_event
(
profile
,
notification_uris
);
nrf_client_inst
->
notify_subscribed_event
(
profile
,
NOTIFICATION_TYPE_NF_DEREGISTERED
,
notification_uris
);
}
else
{
}
else
{
Logger
::
nrf_app
().
error
(
"NF profile not found, profile id %s"
,
Logger
::
nrf_app
().
error
(
"NF profile not found, profile id %s"
,
...
@@ -641,9 +641,9 @@ void nrf_app::handle_nf_status_profile_changed(const std::string &profile_id) {
...
@@ -641,9 +641,9 @@ void nrf_app::handle_nf_status_profile_changed(const std::string &profile_id) {
std
::
vector
<
std
::
string
>
notification_uris
=
{};
std
::
vector
<
std
::
string
>
notification_uris
=
{};
get_subscription_list
(
profile_id
,
NOTIFICATION_TYPE_NF_PROFILE_CHANGED
,
get_subscription_list
(
profile_id
,
NOTIFICATION_TYPE_NF_PROFILE_CHANGED
,
notification_uris
);
notification_uris
);
//Notification data includes NF profile (other alternative, includes profile_changes)
// send notifications
// send notifications
nrf_client_inst
->
notify_subscribed_event
(
profile
,
notification_uris
);
nrf_client_inst
->
notify_subscribed_event
(
profile
,
NOTIFICATION_TYPE_NF_PROFILE_CHANGED
,
notification_uris
);
}
else
{
}
else
{
Logger
::
nrf_app
().
error
(
"NF profile not found, profile id %s"
,
Logger
::
nrf_app
().
error
(
"NF profile not found, profile id %s"
,
profile_id
.
c_str
());
profile_id
.
c_str
());
...
...
src/nrf_app/nrf_client.cpp
View file @
d3c88ee7
...
@@ -84,7 +84,7 @@ CURL *nrf_client::curl_create_handle(const std::string &uri,
...
@@ -84,7 +84,7 @@ CURL *nrf_client::curl_create_handle(const std::string &uri,
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
nrf_client
::
notify_subscribed_event
(
void
nrf_client
::
notify_subscribed_event
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
uint8_t
&
event_type
,
const
std
::
vector
<
std
::
string
>
&
uris
)
{
const
std
::
vector
<
std
::
string
>
&
uris
)
{
Logger
::
nrf_app
().
debug
(
Logger
::
nrf_app
().
debug
(
"Send notification for the subscribed event to the subscriptions"
);
"Send notification for the subscribed event to the subscriptions"
);
...
@@ -111,7 +111,7 @@ void nrf_client::notify_subscribed_event(
...
@@ -111,7 +111,7 @@ void nrf_client::notify_subscribed_event(
// Fill the json part
// Fill the json part
nlohmann
::
json
json_data
=
{};
nlohmann
::
json
json_data
=
{};
json_data
[
"event"
]
=
"NF_REGISTERED"
;
json_data
[
"event"
]
=
notification_event_type_e2str
[
event_type
]
;
std
::
string
instance_uri
=
std
::
string
instance_uri
=
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
nrf_cfg
.
sbi
.
addr4
)))
+
":"
+
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
nrf_cfg
.
sbi
.
addr4
)))
+
":"
+
std
::
to_string
(
nrf_cfg
.
sbi
.
port
)
+
NNRF_NFM_BASE
+
std
::
to_string
(
nrf_cfg
.
sbi
.
port
)
+
NNRF_NFM_BASE
+
...
@@ -119,6 +119,25 @@ void nrf_client::notify_subscribed_event(
...
@@ -119,6 +119,25 @@ void nrf_client::notify_subscribed_event(
profile
.
get
()
->
get_nf_instance_id
();
profile
.
get
()
->
get_nf_instance_id
();
Logger
::
nrf_app
().
debug
(
"NF instance URI: %s"
,
instance_uri
.
c_str
());
Logger
::
nrf_app
().
debug
(
"NF instance URI: %s"
,
instance_uri
.
c_str
());
json_data
[
"nfInstanceUri"
]
=
instance_uri
;
json_data
[
"nfInstanceUri"
]
=
instance_uri
;
// NF profile
if
((
event_type
==
NOTIFICATION_TYPE_NF_REGISTERED
)
or
(
event_type
==
NOTIFICATION_TYPE_NF_PROFILE_CHANGED
))
{
nlohmann
::
json
json_profile
=
{};
switch
(
profile
.
get
()
->
get_nf_type
())
{
case
NF_TYPE_AMF
:
{
std
::
static_pointer_cast
<
amf_profile
>
(
profile
).
get
()
->
to_json
(
json_profile
);
}
break
;
case
NF_TYPE_SMF
:
{
std
::
static_pointer_cast
<
smf_profile
>
(
profile
).
get
()
->
to_json
(
json_profile
);
}
break
;
default:
{
profile
.
get
()
->
to_json
(
json_profile
);
}
}
json_data
[
"nfProfile"
]
=
json_profile
;
}
std
::
string
body
=
json_data
.
dump
();
std
::
string
body
=
json_data
.
dump
();
// create and add an easy handle to a multi curl request
// create and add an easy handle to a multi curl request
...
@@ -203,8 +222,8 @@ void nrf_client::notify_subscribed_event(
...
@@ -203,8 +222,8 @@ void nrf_client::notify_subscribed_event(
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
nrf_client
::
notify_subscribed_event
(
void
nrf_client
::
notify_subscribed_event
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
std
::
string
&
uri
)
{
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
std
::
string
&
uri
)
{
Logger
::
nrf_app
().
debug
(
Logger
::
nrf_app
().
debug
(
"Send notification to the subscribed NF (URI %s)"
,
"Send notification to the subscribed NF (URI %s)"
,
uri
.
c_str
());
uri
.
c_str
());
// Fill the json part
// Fill the json part
nlohmann
::
json
json_data
=
{};
nlohmann
::
json
json_data
=
{};
...
...
src/nrf_app/nrf_client.hpp
View file @
d3c88ee7
...
@@ -58,10 +58,12 @@ class nrf_client {
...
@@ -58,10 +58,12 @@ class nrf_client {
/*
/*
* Send Notification for the associated event to the subscribers
* Send Notification for the associated event to the subscribers
* @param [const std::shared_ptr<nrf_profile> &] profile: NF profile
* @param [const std::shared_ptr<nrf_profile> &] profile: NF profile
* @param [const uint8_t &] event_type: notification type
* @param [const std::vector<std::string> &] uris: list of subscribed NFs' URI
* @param [const std::vector<std::string> &] uris: list of subscribed NFs' URI
* @return void
* @return void
*/
*/
void
notify_subscribed_event
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
void
notify_subscribed_event
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
uint8_t
&
event_type
,
const
std
::
vector
<
std
::
string
>
&
uris
);
const
std
::
vector
<
std
::
string
>
&
uris
);
/*
/*
...
...
src/nrf_app/nrf_profile.cpp
View file @
d3c88ee7
...
@@ -482,7 +482,6 @@ void nrf_profile::handle_heartbeart_timeout(uint64_t ms) {
...
@@ -482,7 +482,6 @@ void nrf_profile::handle_heartbeart_timeout(uint64_t ms) {
set_nf_status
(
"SUSPENDED"
);
set_nf_status
(
"SUSPENDED"
);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
amf_profile
::
add_amf_info
(
const
amf_info_t
&
info
)
{
void
amf_profile
::
add_amf_info
(
const
amf_info_t
&
info
)
{
amf_info
=
info
;
amf_info
=
info
;
...
@@ -601,7 +600,6 @@ bool amf_profile::remove_profile_info(
...
@@ -601,7 +600,6 @@ bool amf_profile::remove_profile_info(
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
amf_profile
::
to_json
(
nlohmann
::
json
&
data
)
const
{
void
amf_profile
::
to_json
(
nlohmann
::
json
&
data
)
const
{
nrf_profile
::
to_json
(
data
);
nrf_profile
::
to_json
(
data
);
Logger
::
nrf_app
().
debug
(
"[AMF] To Json"
);
//AMF Info
//AMF Info
data
[
"amfInfo"
][
"amfSetId"
]
=
amf_info
.
amf_set_id
;
data
[
"amfInfo"
][
"amfSetId"
]
=
amf_info
.
amf_set_id
;
data
[
"amfInfo"
][
"amfRegionId"
]
=
amf_info
.
amf_region_id
;
data
[
"amfInfo"
][
"amfRegionId"
]
=
amf_info
.
amf_region_id
;
...
...
src/nrf_app/nrf_profile.hpp
View file @
d3c88ee7
...
@@ -354,6 +354,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
...
@@ -354,6 +354,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
*/
*/
void
unsubscribe_task_tick
();
void
unsubscribe_task_tick
();
protected:
protected:
nrf_event
&
m_event_sub
;
nrf_event
&
m_event_sub
;
bs2
::
connection
task_connection
;
bs2
::
connection
task_connection
;
...
...
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