Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AMF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
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-AMF
Commits
aeddeef3
Commit
aeddeef3
authored
Sep 06, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement Unsubscribe operation
parent
a4d4a12e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
18 deletions
+90
-18
src/amf-app/amf_app.cpp
src/amf-app/amf_app.cpp
+52
-13
src/amf-app/amf_app.hpp
src/amf-app/amf_app.hpp
+15
-0
src/amf-app/amf_subscription.hpp
src/amf-app/amf_subscription.hpp
+3
-2
src/sbi/amf_server/impl/IndividualSubscriptionDocumentApiImplEventExposure.cpp
...pl/IndividualSubscriptionDocumentApiImplEventExposure.cpp
+19
-2
src/sbi/amf_server/impl/SubscriptionsCollectionDocumentApiImplEventExposure.cpp
...l/SubscriptionsCollectionDocumentApiImplEventExposure.cpp
+1
-1
No files found.
src/amf-app/amf_app.cpp
View file @
aeddeef3
...
...
@@ -407,24 +407,43 @@ evsub_id_t amf_app::handle_event_exposure_subscription(
std
::
shared_ptr
<
amf_subscription
>
ss
=
std
::
shared_ptr
<
amf_subscription
>
(
new
amf_subscription
());
ss
.
get
()
->
sub_id
=
evsub_id
;
// TODO:
// if (msg->event_exposure.is_supi_is_set()) {
// supi64_t supi64 = amf_supi_to_u64(msg->event_exposure.get_supi());
// ss.get()->supi = supi64;
//}
// ss.get()->notif_id = msg->event_exposure.get_notif_id();
// ss.get()->notif_uri = msg->event_exposure.get_notif_uri();
// std::vector<event_subscription_t> event_subscriptions =
// msg->event_exposure.get_event_subs();
if
(
msg
->
event_exposure
.
is_supi_is_set
())
{
supi64_t
supi64
=
amf_supi_to_u64
(
msg
->
event_exposure
.
get_supi
());
ss
.
get
()
->
supi
=
supi64
;
}
ss
.
get
()
->
notify_correlation_id
=
msg
->
event_exposure
.
get_notify_correlation_id
();
ss
.
get
()
->
notify_uri
=
msg
->
event_exposure
.
get_notify_uri
();
ss
.
get
()
->
nf_id
=
msg
->
event_exposure
.
get_nf_id
();
std
::
vector
<
amf_event_t
>
event_subscriptions
=
msg
->
event_exposure
.
get_event_subs
();
// store subscription
//
for (auto i : event_subscriptions) {
// ss.get()->ev_type = i.amf_event
;
// add_event_subscription(evsub_id, i.amf_event
, ss);
//
}
for
(
auto
i
:
event_subscriptions
)
{
ss
.
get
()
->
ev_type
=
i
.
type
;
add_event_subscription
(
evsub_id
,
i
.
type
,
ss
);
}
return
evsub_id
;
}
bool
amf_app
::
handle_event_exposure_delete
(
const
std
::
string
&
subscription_id
)
{
// verify Subscription ID
evsub_id_t
sub_id
=
{};
try
{
sub_id
=
std
::
stoi
(
subscription_id
);
}
catch
(
const
std
::
exception
&
err
)
{
Logger
::
amf_app
().
warn
(
"Received a Unsubscribe Request, couldn't find the corresponding "
"subscription"
);
return
false
;
}
return
remove_event_subscription
(
sub_id
);
}
//------------------------------------------------------------------------------
bool
amf_app
::
handle_nf_status_notification
(
std
::
shared_ptr
<
itti_sbi_notification_data
>&
msg
,
...
...
@@ -522,6 +541,26 @@ void amf_app::add_event_subscription(
amf_event_subscriptions
.
emplace
(
std
::
make_pair
(
sub_id
,
ev
),
ss
);
}
//---------------------------------------------------------------------------------------------
bool
amf_app
::
remove_event_subscription
(
evsub_id_t
sub_id
)
{
Logger
::
amf_app
().
debug
(
"Remove an Event subscription (Sub ID %d)"
,
sub_id
);
std
::
unique_lock
lock
(
m_amf_event_subscriptions
);
for
(
auto
it
=
amf_event_subscriptions
.
cbegin
();
it
!=
amf_event_subscriptions
.
cend
();)
{
if
((
uint8_t
)
std
::
get
<
0
>
(
it
->
first
)
==
(
uint32_t
)
sub_id
)
{
Logger
::
amf_app
().
debug
(
"Found an event subscription (Event ID %d)"
,
(
uint8_t
)
std
::
get
<
0
>
(
it
->
first
));
amf_event_subscriptions
.
erase
(
it
++
);
// it = amf_event_subscriptions.erase(it)
return
true
;
}
else
{
++
it
;
}
}
return
false
;
}
//---------------------------------------------------------------------------------------------
void
amf_app
::
get_ee_subscriptions
(
amf_event_type_t
ev
,
...
...
src/amf-app/amf_app.hpp
View file @
aeddeef3
...
...
@@ -140,6 +140,14 @@ class amf_app {
evsub_id_t
handle_event_exposure_subscription
(
std
::
shared_ptr
<
itti_sbi_event_exposure_request
>
msg
);
/*
* Handle Unsubscribe Request from an NF
* @param [const std::string&] subscription_id: Subscription ID
* @return true if the subscription is unsubscribed successfully, otherwise
* return false
*/
bool
handle_event_exposure_delete
(
const
std
::
string
&
subscription_id
);
/*
* Handle NF status notification (e.g., when an UPF becomes available)
* @param [std::shared_ptr<itti_sbi_notification_data>& ] msg: message
...
...
@@ -170,6 +178,13 @@ class amf_app {
evsub_id_t
sub_id
,
amf_event_type_t
ev
,
std
::
shared_ptr
<
amf_subscription
>
ss
);
/*
* Remove an Event Subscription from the list
* @param [const evsub_id_t&] sub_id: Subscription ID
* @return bool
*/
bool
remove_event_subscription
(
evsub_id_t
sub_id
);
/*
* Get a list of subscription associated with a particular event
* @param [amf_event_t] ev: Event type
...
...
src/amf-app/amf_subscription.hpp
View file @
aeddeef3
...
...
@@ -43,8 +43,9 @@ class amf_subscription {
evsub_id_t
sub_id
;
amf_event_type_t
ev_type
;
supi64_t
supi
;
std
::
string
notif_id
;
std
::
string
notif_uri
;
std
::
string
notify_correlation_id
;
std
::
string
notify_uri
;
std
::
string
nf_id
;
};
}
// namespace amf
src/sbi/amf_server/impl/IndividualSubscriptionDocumentApiImplEventExposure.cpp
View file @
aeddeef3
...
...
@@ -29,9 +29,26 @@ IndividualSubscriptionDocumentApiImplEventExposure::
void
IndividualSubscriptionDocumentApiImplEventExposure
::
delete_subscription
(
const
std
::
string
&
subscriptionId
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"This API has not been implemented yet!
\n
"
);
Logger
::
amf_server
().
info
(
"SubscriptionsCollectionDocumentApiImplEventExposure::delete_"
"subscription"
);
// Create a message and store the necessary information
Logger
::
amf_server
().
debug
(
"Delete a subscription with ID %s"
,
subscriptionId
.
c_str
());
if
(
m_amf_app
->
handle_event_exposure_delete
(
subscriptionId
))
{
response
.
send
(
Pistache
::
Http
::
Code
::
No_Content
);
}
else
{
// Send response
nlohmann
::
json
json_data
=
{};
oai
::
amf
::
model
::
ProblemDetails
problem_details
=
{};
problem_details
.
setCause
(
"SUBSCRIPTION_NOT_FOUND"
);
to_json
(
json_data
,
problem_details
);
response
.
send
(
Pistache
::
Http
::
Code
::
Not_Found
,
json_data
.
dump
().
c_str
());
}
}
void
IndividualSubscriptionDocumentApiImplEventExposure
::
modify_subscription
(
const
std
::
string
&
subscriptionId
,
const
AmfUpdateEventOptionItem
&
amfUpdateEventOptionItem
,
...
...
src/sbi/amf_server/impl/SubscriptionsCollectionDocumentApiImplEventExposure.cpp
View file @
aeddeef3
...
...
@@ -77,7 +77,7 @@ void SubscriptionsCollectionDocumentApiImplEventExposure::create_subscription(
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
"application/json"
));
response
.
send
(
Pistache
::
Http
::
Code
(
201
)
,
json_data
.
dump
().
c_str
());
response
.
send
(
Pistache
::
Http
::
Code
::
Created
,
json_data
.
dump
().
c_str
());
}
}
// namespace api
...
...
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