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
e61b995d
Commit
e61b995d
authored
Jul 01, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use timeout for future-promise
parent
06578217
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
33 deletions
+51
-33
src/api-server/impl/SMContextsCollectionApiImpl.cpp
src/api-server/impl/SMContextsCollectionApiImpl.cpp
+50
-32
src/oai_smf/CMakeLists.txt
src/oai_smf/CMakeLists.txt
+1
-1
No files found.
src/api-server/impl/SMContextsCollectionApiImpl.cpp
View file @
e61b995d
...
...
@@ -41,6 +41,12 @@
#include "smf_config.hpp"
#include "3gpp_conversions.hpp"
#include "mime_parser.hpp"
#include <boost/thread.hpp>
#include <boost/thread/future.hpp>
#include <boost/chrono.hpp>
#include <boost/chrono/chrono.hpp>
#include <boost/chrono/duration.hpp>
#include <boost/chrono/system_clocks.hpp>
extern
smf
::
smf_config
smf_cfg
;
...
...
@@ -98,39 +104,51 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
itti_msg
->
http_version
=
1
;
m_smf_app
->
handle_pdu_session_create_sm_context_request
(
itti_msg
);
// Wait for the result from APP and send reply to AMF
smf
::
pdu_session_create_sm_context_response
sm_context_response
=
f
.
get
();
Logger
::
smf_api_server
().
debug
(
"Got result for promise ID %d"
,
promise_id
);
nlohmann
::
json
json_data
=
{};
std
::
string
json_format
=
{};
std
::
string
body
=
{};
sm_context_response
.
get_json_data
(
json_data
);
sm_context_response
.
get_json_format
(
json_format
);
if
(
sm_context_response
.
n1_sm_msg_is_set
())
{
// add N1 container if
// available
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
);
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
"multipart/related; boundary="
+
std
::
string
(
CURL_MIME_BOUNDARY
)));
}
else
if
(
!
json_data
.
empty
())
{
// if not, include json data if available
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
Location
>
(
sm_context_response
.
get_smf_context_uri
());
// Location header
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
json_format
));
body
=
json_data
.
dump
().
c_str
();
}
else
{
// otherwise, send reply without content
response
.
send
(
Pistache
::
Http
::
Code
(
sm_context_response
.
get_http_code
()));
return
;
boost
::
future_status
status
;
// wait for timeout or ready
status
=
f
.
wait_for
(
boost
::
chrono
::
milliseconds
(
100
));
if
(
status
==
boost
::
future_status
::
ready
)
{
assert
(
f
.
is_ready
());
assert
(
f
.
has_value
());
assert
(
!
f
.
has_exception
());
// Wait for the result from APP and send reply to AMF
smf
::
pdu_session_create_sm_context_response
sm_context_response
=
f
.
get
();
Logger
::
smf_api_server
().
debug
(
"Got result for promise ID %d"
,
promise_id
);
nlohmann
::
json
json_data
=
{};
std
::
string
json_format
=
{};
std
::
string
body
=
{};
sm_context_response
.
get_json_data
(
json_data
);
sm_context_response
.
get_json_format
(
json_format
);
if
(
sm_context_response
.
n1_sm_msg_is_set
())
{
// add N1 container if
// available
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
);
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
"multipart/related; boundary="
+
std
::
string
(
CURL_MIME_BOUNDARY
)));
}
else
if
(
!
json_data
.
empty
())
{
// if not, include json data if available
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
Location
>
(
sm_context_response
.
get_smf_context_uri
());
// Location header
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
json_format
));
body
=
json_data
.
dump
().
c_str
();
}
else
{
// otherwise, send reply without content
response
.
send
(
Pistache
::
Http
::
Code
(
sm_context_response
.
get_http_code
()));
return
;
}
response
.
send
(
Pistache
::
Http
::
Code
(
sm_context_response
.
get_http_code
()),
body
);
}
else
{
response
.
send
(
Pistache
::
Http
::
Code
::
Request_Timeout
);
}
response
.
send
(
Pistache
::
Http
::
Code
(
sm_context_response
.
get_http_code
()),
body
);
}
}
// namespace api
}
// namespace smf_server
...
...
src/oai_smf/CMakeLists.txt
View file @
e61b995d
...
...
@@ -320,5 +320,5 @@ IF(STATIC_LINKING)
ENDIF
(
STATIC_LINKING
)
target_link_libraries
(
smf
${
ASAN
}
-Wl,--start-group CN_UTILS SMF UDP PFCP 3GPP_COMMON_TYPES SMF_API -lnettle
${
NETTLE_LIBRARIES
}
${
CRYPTO_LIBRARIES
}
-lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto NAS gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system pistache curl
)
-Wl,--start-group CN_UTILS SMF UDP PFCP 3GPP_COMMON_TYPES SMF_API -lnettle
${
NETTLE_LIBRARIES
}
${
CRYPTO_LIBRARIES
}
-lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto NAS gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system
boost_chrono
pistache curl
)
\ No newline at end of file
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