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
a064ebd0
Commit
a064ebd0
authored
May 28, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Process response data
parent
03a2c428
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
9 deletions
+45
-9
src/smf_app/smf_sbi.cpp
src/smf_app/smf_sbi.cpp
+43
-7
src/smf_app/smf_sbi.hpp
src/smf_app/smf_sbi.hpp
+2
-2
No files found.
src/smf_app/smf_sbi.cpp
View file @
a064ebd0
...
...
@@ -1341,10 +1341,10 @@ void smf_sbi::send_n1n2_message_transfer_request_curl_multi(
curl_multi_add_handle
(
curl_multi
,
tmp
);
handles
.
push_back
(
tmp
);
boost
::
shared_ptr
<
boost
::
promise
<
std
::
string
>>
p
=
boost
::
make_shared
<
boost
::
promise
<
std
::
string
>>
();
boost
::
shared_ptr
<
boost
::
promise
<
uint32_t
>>
p
=
boost
::
make_shared
<
boost
::
promise
<
uint32_t
>>
();
boost
::
shared_future
<
std
::
string
>
f
;
boost
::
shared_future
<
uint32_t
>
f
;
f
=
p
->
get_future
();
// Generate ID for this promise (to be used in SMF-APP)
...
...
@@ -1356,25 +1356,61 @@ void smf_sbi::send_n1n2_message_transfer_request_curl_multi(
0
);
// TODO: current time as parameter if curl is performed per event
f
.
wait
();
// wait for it to finish
assert
(
f
.
is_ready
());
assert
(
f
.
has_value
());
assert
(
!
f
.
has_exception
());
// Wait for the response back
std
::
string
response_msg
=
f
.
get
();
uint32_t
response_code
=
f
.
get
();
Logger
::
smf_sbi
().
debug
(
"Got result for promise ID %s"
,
sm_context_res
->
res
.
get_amf_url
().
c_str
());
Logger
::
smf_sbi
().
debug
(
"Response data %s"
,
response_data
.
c_str
());
// get cause from the response
json
response_data_json
=
{};
try
{
response_data_json
=
json
::
parse
(
response_data
);
}
catch
(
json
::
exception
&
e
)
{
Logger
::
smf_sbi
().
warn
(
"Could not get the cause from the response"
);
// Set the default Cause
response_data_json
[
"cause"
]
=
"504 Gateway Timeout"
;
}
Logger
::
smf_sbi
().
debug
(
"Response from AMF, Http Code: %d, cause %s"
,
response_code
,
response_data_json
[
"cause"
].
dump
().
c_str
());
// send response to APP to process
itti_n11_n1n2_message_transfer_response_status
*
itti_msg
=
new
itti_n11_n1n2_message_transfer_response_status
(
TASK_SMF_SBI
,
TASK_SMF_APP
);
itti_msg
->
set_response_code
(
response_code
);
itti_msg
->
set_scid
(
sm_context_res
->
scid
);
itti_msg
->
set_procedure_type
(
session_management_procedures_type_e
::
PDU_SESSION_ESTABLISHMENT_UE_REQUESTED
);
itti_msg
->
set_cause
(
response_data_json
[
"cause"
]);
if
(
sm_context_res
->
res
.
get_cause
()
==
static_cast
<
uint8_t
>
(
cause_value_5gsm_e
::
CAUSE_255_REQUEST_ACCEPTED
))
{
itti_msg
->
set_msg_type
(
PDU_SESSION_ESTABLISHMENT_ACCEPT
);
}
else
{
itti_msg
->
set_msg_type
(
PDU_SESSION_ESTABLISHMENT_REJECT
);
}
std
::
shared_ptr
<
itti_n11_n1n2_message_transfer_response_status
>
i
=
std
::
shared_ptr
<
itti_n11_n1n2_message_transfer_response_status
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
RETURNok
!=
ret
)
{
Logger
::
smf_sbi
().
error
(
"Could not send ITTI message %s to task TASK_SMF_APP"
,
i
->
get_msg_name
());
}
free_wrapper
((
void
**
)
&
data
);
}
//---------------------------------------------------------------------------------------------
void
smf_sbi
::
add_promise
(
std
::
string
id
,
boost
::
shared_ptr
<
boost
::
promise
<
std
::
string
>>&
p
)
{
std
::
string
id
,
boost
::
shared_ptr
<
boost
::
promise
<
uint32_t
>>&
p
)
{
std
::
unique_lock
lock
(
m_curl_handle_promises
);
curl_handle_promises
.
emplace
(
id
,
p
);
}
...
...
@@ -1387,7 +1423,7 @@ void smf_sbi::trigger_process_response(std::string& pid, uint32_t http_code) {
pid
.
c_str
());
std
::
unique_lock
lock
(
m_curl_handle_promises
);
if
(
curl_handle_promises
.
count
(
pid
)
>
0
)
{
curl_handle_promises
[
pid
]
->
set_value
(
std
::
to_string
(
http_code
)
);
curl_handle_promises
[
pid
]
->
set_value
(
http_code
);
// Remove this promise from list
curl_handle_promises
.
erase
(
pid
);
}
...
...
src/smf_app/smf_sbi.hpp
View file @
a064ebd0
...
...
@@ -51,7 +51,7 @@ class smf_sbi {
mutable
std
::
shared_mutex
m_curl_handle_promises
;
std
::
map
<
std
::
string
,
boost
::
shared_ptr
<
boost
::
promise
<
std
::
string
>>>
std
::
map
<
std
::
string
,
boost
::
shared_ptr
<
boost
::
promise
<
uint32_t
>>>
curl_handle_promises
;
std
::
thread
::
id
thread_id
;
...
...
@@ -221,7 +221,7 @@ class smf_sbi {
std
::
shared_ptr
<
itti_n11_create_sm_context_response
>
sm_context_res
);
void
add_promise
(
std
::
string
id
,
boost
::
shared_ptr
<
boost
::
promise
<
std
::
string
>>&
p
);
std
::
string
id
,
boost
::
shared_ptr
<
boost
::
promise
<
uint32_t
>>&
p
);
void
trigger_process_response
(
std
::
string
&
pid
,
uint32_t
http_code
);
};
}
// namespace smf
...
...
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