Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-SMF
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-SMF
Commits
a9b5db1e
Unverified
Commit
a9b5db1e
authored
Sep 06, 2021
by
kharade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nf registration and subscription support over httpv2
parent
03c5e7b5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
18 deletions
+96
-18
src/api-server/smf-http2-server.cpp
src/api-server/smf-http2-server.cpp
+68
-6
src/api-server/smf-http2-server.h
src/api-server/smf-http2-server.h
+5
-0
src/common/smf.h
src/common/smf.h
+1
-0
src/smf_app/smf_app.cpp
src/smf_app/smf_app.cpp
+14
-8
src/smf_app/smf_sbi.cpp
src/smf_app/smf_sbi.cpp
+8
-4
No files found.
src/api-server/smf-http2-server.cpp
View file @
a9b5db1e
...
...
@@ -316,6 +316,31 @@ void smf_http2_server::start() {
});
});
// NFStatusNotify
server
.
handle
(
NNRF_NF_STATUS_NOTIFY_BASE
+
smf_cfg
.
sbi_api_version
+
NNRF_NF_STATUS_SUBSCRIBE_URL
,
[
&
](
const
request
&
request
,
const
response
&
response
)
{
request
.
on_data
([
&
](
const
uint8_t
*
data
,
std
::
size_t
len
)
{
std
::
string
msg
((
char
*
)
data
,
len
);
try
{
if
(
request
.
method
().
compare
(
"POST"
)
==
0
&&
len
>
0
)
{
smf
::
data_notification_msg
notification_msg
=
{};
NotificationData
notificationData
=
{};
nlohmann
::
json
::
parse
(
msg
.
c_str
()).
get_to
(
notificationData
);
this
->
nf_status_notify_handler
(
notificationData
,
response
);
}
}
catch
(
nlohmann
::
detail
::
exception
&
e
)
{
Logger
::
smf_sbi
().
warn
(
"Can not parse the json data (error: %s)!"
,
e
.
what
());
response
.
write_head
(
http_status_code_e
::
HTTP_STATUS_CODE_400_BAD_REQUEST
);
response
.
end
();
return
;
}
});
});
if
(
server
.
listen_and_serve
(
ec
,
m_address
,
std
::
to_string
(
m_port
)))
{
std
::
cerr
<<
"HTTP Server error: "
<<
ec
.
message
()
<<
std
::
endl
;
}
...
...
@@ -453,24 +478,27 @@ void smf_http2_server::update_sm_context_handler(
sm_context_response
.
get_n1_sm_message
(),
sm_context_response
.
get_n2_sm_information
(),
json_format
);
h
.
emplace
(
"content-type"
,
header_value
{
"multipart/related; boundary="
+
std
::
string
(
CURL_MIME_BOUNDARY
)});
"content-type"
,
header_value
{
"multipart/related; boundary="
+
std
::
string
(
CURL_MIME_BOUNDARY
)});
}
else
if
(
sm_context_response
.
n1_sm_msg_is_set
())
{
mime_parser
::
create_multipart_related_content
(
body
,
json_data
.
dump
(),
CURL_MIME_BOUNDARY
,
sm_context_response
.
get_n1_sm_message
(),
multipart_related_content_part_e
::
NAS
,
json_format
);
h
.
emplace
(
"content-type"
,
header_value
{
"multipart/related; boundary="
+
std
::
string
(
CURL_MIME_BOUNDARY
)});
"content-type"
,
header_value
{
"multipart/related; boundary="
+
std
::
string
(
CURL_MIME_BOUNDARY
)});
}
else
if
(
sm_context_response
.
n2_sm_info_is_set
())
{
mime_parser
::
create_multipart_related_content
(
body
,
json_data
.
dump
(),
CURL_MIME_BOUNDARY
,
sm_context_response
.
get_n2_sm_information
(),
multipart_related_content_part_e
::
NGAP
,
json_format
);
h
.
emplace
(
"content-type"
,
header_value
{
"multipart/related; boundary="
+
std
::
string
(
CURL_MIME_BOUNDARY
)});
"content-type"
,
header_value
{
"multipart/related; boundary="
+
std
::
string
(
CURL_MIME_BOUNDARY
)});
}
else
{
h
.
emplace
(
"content-type"
,
header_value
{
json_format
});
body
=
json_data
.
dump
().
c_str
();
...
...
@@ -526,6 +554,40 @@ void smf_http2_server::release_sm_context_handler(
response
.
end
();
}
void
smf_http2_server
::
nf_status_notify_handler
(
const
NotificationData
&
notificationData
,
const
response
&
response
)
{
Logger
::
smf_api_server
().
info
(
"NFStatusNotifyApiImpl, received a NF status notification..."
);
smf
::
data_notification_msg
notification_msg
=
{};
nlohmann
::
json
json_data
=
{};
std
::
string
content_type
=
"application/json"
;
// convert from NotificationData to data_notification_msg
xgpp_conv
::
data_notification_from_openapi
(
notificationData
,
notification_msg
);
// Handle the message in smf_app
std
::
shared_ptr
<
itti_sbi_notification_data
>
itti_msg
=
std
::
make_shared
<
itti_sbi_notification_data
>
(
TASK_SMF_SBI
,
TASK_SMF_APP
);
itti_msg
->
notification_msg
=
notification_msg
;
itti_msg
->
http_version
=
1
;
ProblemDetails
problem_details
=
{};
uint8_t
http_code
=
0
;
header_map
h
;
h
.
emplace
(
"location"
,
header_value
{
m_address
+
"/nsmf-nfstatus-notify/v1/subscriptions"
});
h
.
emplace
(
"content-type"
,
header_value
{
content_type
});
response
.
write_head
(
http_code
,
h
);
response
.
end
(
json_data
.
dump
().
c_str
());
if
(
m_smf_app
->
handle_nf_status_notification
(
itti_msg
,
problem_details
,
http_code
))
response
.
end
();
else
response
.
end
(
json_data
.
dump
().
c_str
());
}
//------------------------------------------------------------------------------
void
smf_http2_server
::
stop
()
{
server
.
stop
();
...
...
src/api-server/smf-http2-server.h
View file @
a9b5db1e
...
...
@@ -35,6 +35,7 @@
#include "SmContextUpdateMessage.h"
#include "SmContextMessage.h"
#include "SmContextReleaseMessage.h"
#include "NFStatusNotifyApiImpl.h"
#include "uint_generator.hpp"
#include "smf.h"
...
...
@@ -59,6 +60,10 @@ class smf_http2_server {
const
std
::
string
&
smf_ref
,
const
SmContextReleaseMessage
&
smContextReleaseMessage
,
const
response
&
response
);
void
nf_status_notify_handler
(
const
NotificationData
&
notificationData
,
const
response
&
response
);
void
stop
();
private:
...
...
src/common/smf.h
View file @
a9b5db1e
...
...
@@ -204,6 +204,7 @@ typedef struct qos_profile_s {
#define NNRF_NFM_BASE "/nnrf-nfm/"
#define NNRF_NF_REGISTER_URL "/nf-instances/"
#define NNRF_NF_STATUS_SUBSCRIBE_URL "/subscriptions"
#define NNRF_NF_STATUS_NOTIFY_BASE "/nsmf-nfstatus-notify/"
// for CURL
#define NF_CURL_TIMEOUT_MS 100L
...
...
src/smf_app/smf_app.cpp
View file @
a9b5db1e
...
...
@@ -701,8 +701,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
std
::
string
n1_sm_message
,
n1_sm_message_hex
;
nas_message_t
decoded_nas_msg
=
{};
cause_value_5gsm_e
cause_n1
=
{
cause_value_5gsm_e
::
CAUSE_0_UNKNOWN
};
pdu_session_type_t
pdu_session_type
=
{
.
pdu_session_type
=
PDU_SESSION_TYPE_E_IPV4
};
pdu_session_type_t
pdu_session_type
=
{
.
pdu_session_type
=
PDU_SESSION_TYPE_E_IPV4
};
// Step 1. Decode NAS and get the necessary information
int
decoder_rc
=
smf_n1
::
get_instance
().
decode_n1_sm_container
(
...
...
@@ -1625,6 +1625,7 @@ void smf_app::timer_nrf_heartbeat_timeout(
patch_item
.
setValue
(
"REGISTERED"
);
itti_msg
->
patch_items
.
push_back
(
patch_item
);
itti_msg
->
smf_instance_id
=
smf_instance_id
;
itti_msg
->
http_version
=
smf_cfg
.
nrf_addr
.
http_version
;
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
if
(
RETURNok
!=
ret
)
{
...
...
@@ -2071,6 +2072,7 @@ void smf_app::trigger_nf_registration_request() {
std
::
make_shared
<
itti_n11_register_nf_instance_request
>
(
TASK_SMF_APP
,
TASK_SMF_SBI
);
itti_msg
->
profile
=
nf_instance_profile
;
itti_msg
->
http_version
=
smf_cfg
.
nrf_addr
.
http_version
;
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
if
(
RETURNok
!=
ret
)
{
Logger
::
smf_app
().
error
(
...
...
@@ -2088,6 +2090,7 @@ void smf_app::trigger_nf_deregistration() {
std
::
make_shared
<
itti_n11_deregister_nf_instance
>
(
TASK_SMF_APP
,
TASK_SMF_SBI
);
itti_msg
->
smf_instance_id
=
smf_instance_id
;
itti_msg
->
http_version
=
smf_cfg
.
nrf_addr
.
http_version
;
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
if
(
RETURNok
!=
ret
)
{
Logger
::
smf_app
().
error
(
...
...
@@ -2107,10 +2110,12 @@ void smf_app::trigger_upf_status_notification_subscribe() {
TASK_SMF_APP
,
TASK_SMF_SBI
);
nlohmann
::
json
json_data
=
{};
unsigned
int
port
=
smf_cfg
.
sbi
.
port
;
if
(
smf_cfg
.
nrf_addr
.
http_version
==
2
)
port
=
smf_cfg
.
sbi_http2_port
;
// TODO: remove hardcoded values
json_data
[
"nfStatusNotificationUri"
]
=
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
smf_cfg
.
sbi
.
addr4
)))
+
":"
+
std
::
to_string
(
smf_cfg
.
sbi
.
port
)
+
"/nsmf-nfstatus-notify/"
+
std
::
to_string
(
port
)
+
"/nsmf-nfstatus-notify/"
+
smf_cfg
.
sbi_api_version
+
"/subscriptions"
;
json_data
[
"subscrCond"
][
"NfTypeCond"
][
"nfType"
]
=
"UPF"
;
...
...
@@ -2126,6 +2131,7 @@ void smf_app::trigger_upf_status_notification_subscribe() {
itti_msg
->
url
=
url
;
itti_msg
->
json_data
=
json_data
;
itti_msg
->
http_version
=
smf_cfg
.
nrf_addr
.
http_version
;
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
if
(
RETURNok
!=
ret
)
{
Logger
::
smf_app
().
error
(
...
...
src/smf_app/smf_sbi.cpp
View file @
a9b5db1e
...
...
@@ -596,7 +596,8 @@ void smf_sbi::register_nf_instance(
add_promise
(
promise_id
,
p
);
// Create a new curl easy handle and add to the multi handle
if
(
!
curl_create_handle
(
url
,
body
,
response_data
,
pid_ptr
,
"PUT"
))
{
if
(
!
curl_create_handle
(
url
,
body
,
response_data
,
pid_ptr
,
"PUT"
,
msg
->
http_version
))
{
Logger
::
smf_sbi
().
warn
(
"Could not create a new handle to send message"
);
remove_promise
(
promise_id
);
return
;
...
...
@@ -680,7 +681,8 @@ void smf_sbi::update_nf_instance(
add_promise
(
promise_id
,
p
);
// Create a new curl easy handle and add to the multi handle
if
(
!
curl_create_handle
(
url
,
body
,
response_data
,
pid_ptr
,
"PATCH"
))
{
if
(
!
curl_create_handle
(
url
,
body
,
response_data
,
pid_ptr
,
"PATCH"
,
msg
->
http_version
))
{
Logger
::
smf_sbi
().
warn
(
"Could not create a new handle to send message"
);
remove_promise
(
promise_id
);
return
;
...
...
@@ -747,7 +749,8 @@ void smf_sbi::deregister_nf_instance(
add_promise
(
promise_id
,
p
);
// Create a new curl easy handle and add to the multi handle
if
(
!
curl_create_handle
(
url
,
response_data
,
pid_ptr
,
"DELETE"
))
{
if
(
!
curl_create_handle
(
url
,
response_data
,
pid_ptr
,
"DELETE"
,
msg
->
http_version
))
{
Logger
::
smf_sbi
().
warn
(
"Could not create a new handle to send message"
);
remove_promise
(
promise_id
);
return
;
...
...
@@ -799,7 +802,8 @@ void smf_sbi::subscribe_upf_status_notify(
add_promise
(
promise_id
,
p
);
// Create a new curl easy handle and add to the multi handle
if
(
!
curl_create_handle
(
msg
->
url
,
body
,
response_data
,
pid_ptr
,
"POST"
))
{
if
(
!
curl_create_handle
(
msg
->
url
,
body
,
response_data
,
pid_ptr
,
"POST"
,
msg
->
http_version
))
{
Logger
::
smf_sbi
().
warn
(
"Could not create a new handle to send message"
);
remove_promise
(
promise_id
);
return
;
...
...
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