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
5f499912
Commit
5f499912
authored
Jul 19, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup
parent
c9867719
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
86 deletions
+55
-86
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+5
-5
src/amf-app/amf_n11.cpp
src/amf-app/amf_n11.cpp
+49
-80
src/amf-app/amf_n11.hpp
src/amf-app/amf_n11.hpp
+1
-1
No files found.
src/amf-app/amf_n1.cpp
View file @
5f499912
...
@@ -1368,9 +1368,9 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
...
@@ -1368,9 +1368,9 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
Logger
::
amf_n1
().
debug
(
"_5g_aka_confirmation_from_ausf"
);
Logger
::
amf_n1
().
debug
(
"_5g_aka_confirmation_from_ausf"
);
std
::
string
remoteUri
=
nc
.
get
()
->
Href
;
std
::
string
remoteUri
=
nc
.
get
()
->
Href
;
std
::
string
msgBody
;
std
::
string
msgBody
=
{}
;
std
::
string
Response
;
std
::
string
response
=
{}
;
std
::
string
resStar_string
;
std
::
string
resStar_string
=
{}
;
std
::
map
<
std
::
string
,
std
::
string
>::
iterator
iter
;
std
::
map
<
std
::
string
,
std
::
string
>::
iterator
iter
;
iter
=
rand_record
.
find
(
nc
.
get
()
->
imsi
);
iter
=
rand_record
.
find
(
nc
.
get
()
->
imsi
);
...
@@ -1396,12 +1396,12 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
...
@@ -1396,12 +1396,12 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
msgBody
=
confirmationdata_j
.
dump
();
msgBody
=
confirmationdata_j
.
dump
();
// TODO: Should be updated
// TODO: Should be updated
amf_n11_inst
->
curl_http_client
(
remoteUri
,
"PUT"
,
msgBody
,
R
esponse
);
amf_n11_inst
->
curl_http_client
(
remoteUri
,
"PUT"
,
msgBody
,
r
esponse
);
free_wrapper
((
void
**
)
&
resStar_s
);
free_wrapper
((
void
**
)
&
resStar_s
);
try
{
try
{
ConfirmationDataResponse
confirmationdataresponse
;
ConfirmationDataResponse
confirmationdataresponse
;
nlohmann
::
json
::
parse
(
R
esponse
.
c_str
()).
get_to
(
confirmationdataresponse
);
nlohmann
::
json
::
parse
(
r
esponse
.
c_str
()).
get_to
(
confirmationdataresponse
);
unsigned
char
*
kseaf_hex
=
unsigned
char
*
kseaf_hex
=
format_string_as_hex
(
confirmationdataresponse
.
getKseaf
());
format_string_as_hex
(
confirmationdataresponse
.
getKseaf
());
memcpy
(
nc
.
get
()
->
_5g_av
[
0
].
kseaf
,
kseaf_hex
,
32
);
memcpy
(
nc
.
get
()
->
_5g_av
[
0
].
kseaf
,
kseaf_hex
,
32
);
...
...
src/amf-app/amf_n11.cpp
View file @
5f499912
...
@@ -119,7 +119,7 @@ void amf_n11_task(void*) {
...
@@ -119,7 +119,7 @@ void amf_n11_task(void*) {
}
break
;
}
break
;
case
PDU_SESSION_RESOURCE_SETUP_RESPONSE
:
{
case
PDU_SESSION_RESOURCE_SETUP_RESPONSE
:
{
Logger
::
amf_n11
().
info
(
Logger
::
amf_n11
().
info
(
"Receive PDU Session Resource Setup
R
esponse, handling ..."
);
"Receive PDU Session Resource Setup
r
esponse, handling ..."
);
itti_pdu_session_resource_setup_response
*
m
=
itti_pdu_session_resource_setup_response
*
m
=
dynamic_cast
<
itti_pdu_session_resource_setup_response
*>
(
msg
);
dynamic_cast
<
itti_pdu_session_resource_setup_response
*>
(
msg
);
amf_n11_inst
->
handle_itti_message
(
ref
(
*
m
));
amf_n11_inst
->
handle_itti_message
(
ref
(
*
m
));
...
@@ -153,10 +153,10 @@ void amf_n11::handle_itti_message(
...
@@ -153,10 +153,10 @@ void amf_n11::handle_itti_message(
itti_nsmf_pdusession_update_sm_context
&
itti_msg
)
{
itti_nsmf_pdusession_update_sm_context
&
itti_msg
)
{
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
itti_msg
.
ran_ue_ngap_id
)
+
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
itti_msg
.
ran_ue_ngap_id
)
+
":amfid_"
+
to_string
(
itti_msg
.
amf_ue_ngap_id
);
":amfid_"
+
to_string
(
itti_msg
.
amf_ue_ngap_id
);
std
::
shared_ptr
<
ue_context
>
uc
;
std
::
shared_ptr
<
ue_context
>
uc
=
{};
uc
=
amf_app_inst
->
ran_amf_id_2_ue_context
(
ue_context_key
);
uc
=
amf_app_inst
->
ran_amf_id_2_ue_context
(
ue_context_key
);
std
::
string
supi
;
std
::
string
supi
=
{};
if
(
uc
.
get
()
!=
nullptr
)
{
if
(
uc
.
get
()
!=
nullptr
)
{
supi
=
uc
->
supi
;
supi
=
uc
->
supi
;
}
}
...
@@ -168,13 +168,13 @@ void amf_n11::handle_itti_message(
...
@@ -168,13 +168,13 @@ void amf_n11::handle_itti_message(
std
::
shared_ptr
<
pdu_session_context
>
psc
=
{};
std
::
shared_ptr
<
pdu_session_context
>
psc
=
{};
if
(
!
uc
.
get
()
->
find_pdu_session_context
(
itti_msg
.
pdu_session_id
,
psc
))
{
if
(
!
uc
.
get
()
->
find_pdu_session_context
(
itti_msg
.
pdu_session_id
,
psc
))
{
Logger
::
amf_n11
().
error
(
Logger
::
amf_n11
().
error
(
"Could not find p
s
u_session_context with SUPI %s, Failed"
,
"Could not find p
d
u_session_context with SUPI %s, Failed"
,
supi
.
c_str
());
supi
.
c_str
());
return
;
return
;
}
}
std
::
string
smf_addr
;
std
::
string
smf_addr
=
{}
;
std
::
string
smf_api_version
;
std
::
string
smf_api_version
=
{}
;
if
(
!
psc
.
get
()
->
smf_available
)
{
if
(
!
psc
.
get
()
->
smf_available
)
{
Logger
::
amf_n11
().
error
(
"No SMF is available for this PDU session"
);
Logger
::
amf_n11
().
error
(
"No SMF is available for this PDU session"
);
...
@@ -183,7 +183,8 @@ void amf_n11::handle_itti_message(
...
@@ -183,7 +183,8 @@ void amf_n11::handle_itti_message(
smf_api_version
=
psc
->
smf_api_version
;
smf_api_version
=
psc
->
smf_api_version
;
}
}
std
::
string
smf_ip_addr
,
remote_uri
;
std
::
string
smf_ip_addr
=
{};
std
::
string
remote_uri
=
{};
// remove http port from the URI if existed
// remove http port from the URI if existed
std
::
size_t
found_port
=
smf_addr
.
find
(
":"
);
std
::
size_t
found_port
=
smf_addr
.
find
(
":"
);
...
@@ -217,20 +218,20 @@ void amf_n11::handle_itti_message(
...
@@ -217,20 +218,20 @@ void amf_n11::handle_itti_message(
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
amf_n11
::
handle_itti_message
(
itti_nsmf_pdusession_create_sm_context
&
smf
)
{
void
amf_n11
::
handle_itti_message
(
itti_nsmf_pdusession_create_sm_context
&
smf
)
{
Logger
::
amf_n11
().
debug
(
"Handle SMF_PDU_SESSION_CREATE_SM_CTX"
);
Logger
::
amf_n11
().
debug
(
"Handle ITTI SMF_PDU_SESSION_CREATE_SM_CTX"
);
std
::
shared_ptr
<
nas_context
>
nc
;
std
::
shared_ptr
<
nas_context
>
nc
=
{};
nc
=
amf_n1_inst
->
amf_ue_id_2_nas_context
(
smf
.
amf_ue_ngap_id
);
nc
=
amf_n1_inst
->
amf_ue_id_2_nas_context
(
smf
.
amf_ue_ngap_id
);
std
::
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
std
::
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
string
ue_context_key
=
"app_ue_ranid_"
+
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
nc
.
get
()
->
ran_ue_ngap_id
)
+
":amfid_"
+
to_string
(
nc
.
get
()
->
ran_ue_ngap_id
)
+
":amfid_"
+
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
);
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
);
std
::
shared_ptr
<
ue_context
>
uc
;
std
::
shared_ptr
<
ue_context
>
uc
=
{}
;
Logger
::
amf_n11
().
info
(
Logger
::
amf_n11
().
info
(
"Find ue_context in amf_app using UE Context Key: %s"
,
"Find ue_context in amf_app using UE Context Key: %s"
,
ue_context_key
.
c_str
());
ue_context_key
.
c_str
());
uc
=
amf_app_inst
->
ran_amf_id_2_ue_context
(
ue_context_key
);
uc
=
amf_app_inst
->
ran_amf_id_2_ue_context
(
ue_context_key
);
std
::
shared_ptr
<
pdu_session_context
>
psc
;
std
::
shared_ptr
<
pdu_session_context
>
psc
=
{}
;
if
(
!
uc
.
get
()
->
find_pdu_session_context
(
smf
.
pdu_sess_id
,
psc
))
{
if
(
!
uc
.
get
()
->
find_pdu_session_context
(
smf
.
pdu_sess_id
,
psc
))
{
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
new
pdu_session_context
());
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
new
pdu_session_context
());
uc
.
get
()
->
add_pdu_session_context
(
smf
.
pdu_sess_id
,
psc
);
uc
.
get
()
->
add_pdu_session_context
(
smf
.
pdu_sess_id
,
psc
);
...
@@ -247,7 +248,7 @@ void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
...
@@ -247,7 +248,7 @@ void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
psc
.
get
()
->
plmn
.
mnc
=
smf
.
plmn
.
mnc
;
psc
.
get
()
->
plmn
.
mnc
=
smf
.
plmn
.
mnc
;
// parse binary dnn and store
// parse binary dnn and store
std
::
string
dnn
=
"default"
;
std
::
string
dnn
=
"default"
;
// If DNN doesn't available, use "default"
if
((
smf
.
dnn
!=
nullptr
)
&&
(
blength
(
smf
.
dnn
)
>
0
))
{
if
((
smf
.
dnn
!=
nullptr
)
&&
(
blength
(
smf
.
dnn
)
>
0
))
{
char
*
tmp
=
bstring2charString
(
smf
.
dnn
);
char
*
tmp
=
bstring2charString
(
smf
.
dnn
);
dnn
=
tmp
;
dnn
=
tmp
;
...
@@ -257,8 +258,8 @@ void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
...
@@ -257,8 +258,8 @@ void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
Logger
::
amf_n11
().
debug
(
"Requested DNN: %s"
,
dnn
.
c_str
());
Logger
::
amf_n11
().
debug
(
"Requested DNN: %s"
,
dnn
.
c_str
());
psc
.
get
()
->
dnn
=
dnn
;
psc
.
get
()
->
dnn
=
dnn
;
std
::
string
smf_addr
;
std
::
string
smf_addr
=
{}
;
std
::
string
smf_api_version
;
std
::
string
smf_api_version
=
{}
;
if
(
!
psc
.
get
()
->
smf_available
)
{
if
(
!
psc
.
get
()
->
smf_available
)
{
if
(
amf_cfg
.
enable_smf_selection
)
{
if
(
amf_cfg
.
enable_smf_selection
)
{
// use NRF to find suitable SMF based on snssai, plmn and dnn
// use NRF to find suitable SMF based on snssai, plmn and dnn
...
@@ -292,37 +293,6 @@ void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
...
@@ -292,37 +293,6 @@ void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
psc
.
get
()
->
isn2sm_avaliable
=
false
;
psc
.
get
()
->
isn2sm_avaliable
=
false
;
handle_pdu_session_initial_request
(
handle_pdu_session_initial_request
(
supi
,
psc
,
smf_addr
,
smf_api_version
,
smf
.
sm_msg
,
dnn
);
supi
,
psc
,
smf_addr
,
smf_api_version
,
smf
.
sm_msg
,
dnn
);
/*
if (psc.get()->isn1sm_avaliable && psc.get()->isn2sm_avaliable) {
// TODO: should be removed
itti_n1n2_message_transfer_request* itti_msg =
new itti_n1n2_message_transfer_request(TASK_AMF_N11, TASK_AMF_APP);
itti_msg->supi = supi;
uint8_t accept_len = blength(psc.get()->n1sm);
uint8_t* accept = (uint8_t*) calloc(1, accept_len);
memcpy(accept, (uint8_t*) bdata(psc.get()->n1sm), accept_len);
accept[2] = pti;
itti_msg->n1sm = blk2bstr(accept, accept_len);
free(accept);
itti_msg->is_n1sm_set = true;
itti_msg->n2sm = psc.get()->n2sm;
itti_msg->is_n2sm_set = true;
itti_msg->pdu_session_id = psc.get()->pdu_session_id;
std::shared_ptr<itti_n1n2_message_transfer_request> i =
std::shared_ptr<itti_n1n2_message_transfer_request>(itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::amf_n11().error(
"Could not send ITTI message %s to task TASK_AMF_APP",
i->get_msg_name());
}
} else {
psc.get()->isn2sm_avaliable = false;
handle_pdu_session_initial_request(
supi, psc, smf_addr, smf_api_version, smf.sm_msg, dnn);
}
*/
}
break
;
}
break
;
case
EXISTING_PDU_SESSION
:
{
case
EXISTING_PDU_SESSION
:
{
// TODO:
// TODO:
...
@@ -348,7 +318,8 @@ void amf_n11::send_pdu_session_update_sm_context_request(
...
@@ -348,7 +318,8 @@ void amf_n11::send_pdu_session_update_sm_context_request(
"ID %d)"
,
"ID %d)"
,
supi
.
c_str
(),
psc
.
get
()
->
pdu_session_id
);
supi
.
c_str
(),
psc
.
get
()
->
pdu_session_id
);
std
::
string
smf_ip_addr
,
remote_uri
;
std
::
string
smf_ip_addr
=
{};
std
::
string
remote_uri
=
{};
// remove http port from the URI if existed
// remove http port from the URI if existed
std
::
size_t
found_port
=
smf_addr
.
find
(
":"
);
std
::
size_t
found_port
=
smf_addr
.
find
(
":"
);
if
(
found_port
!=
std
::
string
::
npos
)
if
(
found_port
!=
std
::
string
::
npos
)
...
@@ -368,7 +339,7 @@ void amf_n11::send_pdu_session_update_sm_context_request(
...
@@ -368,7 +339,7 @@ void amf_n11::send_pdu_session_update_sm_context_request(
pdu_session_update_request
[
"n1SmMsg"
][
"contentId"
]
=
"n1SmMsg"
;
pdu_session_update_request
[
"n1SmMsg"
][
"contentId"
]
=
"n1SmMsg"
;
std
::
string
json_part
=
pdu_session_update_request
.
dump
();
std
::
string
json_part
=
pdu_session_update_request
.
dump
();
std
::
string
n1SmMsg
;
std
::
string
n1SmMsg
=
{}
;
octet_stream_2_hex_stream
((
uint8_t
*
)
bdata
(
sm_msg
),
blength
(
sm_msg
),
n1SmMsg
);
octet_stream_2_hex_stream
((
uint8_t
*
)
bdata
(
sm_msg
),
blength
(
sm_msg
),
n1SmMsg
);
curl_http_client
(
curl_http_client
(
remote_uri
,
json_part
,
n1SmMsg
,
""
,
supi
,
psc
.
get
()
->
pdu_session_id
);
remote_uri
,
json_part
,
n1SmMsg
,
""
,
supi
,
psc
.
get
()
->
pdu_session_id
);
...
@@ -414,8 +385,9 @@ void amf_n11::handle_pdu_session_initial_request(
...
@@ -414,8 +385,9 @@ void amf_n11::handle_pdu_session_initial_request(
[
"contentId"
]
=
"n1SmMsg"
;
[
"contentId"
]
=
"n1SmMsg"
;
std
::
string
json_part
=
pdu_session_establishment_request
.
dump
();
std
::
string
json_part
=
pdu_session_establishment_request
.
dump
();
std
::
string
n1SmMsg
;
std
::
string
n1SmMsg
=
{}
;
octet_stream_2_hex_stream
((
uint8_t
*
)
bdata
(
sm_msg
),
blength
(
sm_msg
),
n1SmMsg
);
octet_stream_2_hex_stream
((
uint8_t
*
)
bdata
(
sm_msg
),
blength
(
sm_msg
),
n1SmMsg
);
curl_http_client
(
curl_http_client
(
remote_uri
,
json_part
,
n1SmMsg
,
""
,
supi
,
psc
.
get
()
->
pdu_session_id
);
remote_uri
,
json_part
,
n1SmMsg
,
""
,
supi
,
psc
.
get
()
->
pdu_session_id
);
}
}
...
@@ -433,7 +405,8 @@ void amf_n11::handle_itti_message(
...
@@ -433,7 +405,8 @@ void amf_n11::handle_itti_message(
return
;
return
;
}
}
string
smf_addr
,
smf_api_version
;
string
smf_addr
=
{};
std
::
string
smf_api_version
=
{};
if
(
!
psc
.
get
()
->
smf_available
)
{
if
(
!
psc
.
get
()
->
smf_available
)
{
Logger
::
amf_n11
().
error
(
"No SMF is available for this PDU session"
);
Logger
::
amf_n11
().
error
(
"No SMF is available for this PDU session"
);
...
@@ -503,8 +476,8 @@ void amf_n11::curl_http_client(
...
@@ -503,8 +476,8 @@ void amf_n11::curl_http_client(
uint8_t
number_parts
=
0
;
uint8_t
number_parts
=
0
;
mime_parser
parser
=
{};
mime_parser
parser
=
{};
std
::
string
body
;
std
::
string
body
=
{}
;
std
::
shared_ptr
<
pdu_session_context
>
psc
;
std
::
shared_ptr
<
pdu_session_context
>
psc
=
{}
;
if
(
!
amf_app_inst
->
find_pdu_session_context
(
supi
,
pdu_session_id
,
psc
))
{
if
(
!
amf_app_inst
->
find_pdu_session_context
(
supi
,
pdu_session_id
,
psc
))
{
Logger
::
amf_n11
().
warn
(
Logger
::
amf_n11
().
warn
(
...
@@ -552,12 +525,12 @@ void amf_n11::curl_http_client(
...
@@ -552,12 +525,12 @@ void amf_n11::curl_http_client(
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
SMF_CURL_TIMEOUT_MS
);
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
SMF_CURL_TIMEOUT_MS
);
curl_easy_setopt
(
curl
,
CURLOPT_INTERFACE
,
amf_cfg
.
n11
.
if_name
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_INTERFACE
,
amf_cfg
.
n11
.
if_name
.
c_str
());
// Response information
.
// Response information
long
httpCode
=
{
0
};
long
httpCode
=
{
0
};
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
std
::
unique_ptr
<
std
::
string
>
httpHeaderData
(
new
std
::
string
());
std
::
unique_ptr
<
std
::
string
>
httpHeaderData
(
new
std
::
string
());
// Hook up data handling function
.
// Hook up data handling function
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
&
callback
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
&
callback
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
httpData
.
get
());
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
httpData
.
get
());
curl_easy_setopt
(
curl
,
CURLOPT_HEADERDATA
,
httpHeaderData
.
get
());
curl_easy_setopt
(
curl
,
CURLOPT_HEADERDATA
,
httpHeaderData
.
get
());
...
@@ -570,14 +543,14 @@ void amf_n11::curl_http_client(
...
@@ -570,14 +543,14 @@ void amf_n11::curl_http_client(
// get cause from the response
// get cause from the response
std
::
string
response
=
*
httpData
.
get
();
std
::
string
response
=
*
httpData
.
get
();
std
::
string
json_data_response
=
""
;
std
::
string
json_data_response
=
{}
;
std
::
string
n1sm
=
""
;
std
::
string
n1sm
=
{}
;
std
::
string
n2sm
=
""
;
std
::
string
n2sm
=
{}
;
nlohmann
::
json
response_data
=
{};
nlohmann
::
json
response_data
=
{};
bstring
n1sm_hex
,
n2sm_hex
;
bstring
n1sm_hex
,
n2sm_hex
;
Logger
::
amf_n11
().
debug
(
"Get response with HTTP code (%d)"
,
httpCode
);
Logger
::
amf_n11
().
debug
(
"Get response with HTTP code (%d)"
,
httpCode
);
Logger
::
amf_n11
().
debug
(
"
R
esponse body %s"
,
response
.
c_str
());
Logger
::
amf_n11
().
debug
(
"
r
esponse body %s"
,
response
.
c_str
());
// Notify to the result if necessary
// Notify to the result if necessary
// TODO: Notify with the N3 information
// TODO: Notify with the N3 information
...
@@ -635,8 +608,7 @@ void amf_n11::curl_http_client(
...
@@ -635,8 +608,7 @@ void amf_n11::curl_http_client(
std
::
string
cause
=
response_data
[
"error"
][
"cause"
];
std
::
string
cause
=
response_data
[
"error"
][
"cause"
];
Logger
::
amf_n11
().
debug
(
Logger
::
amf_n11
().
debug
(
"Call Network Function services failure (with cause %s)"
,
"Network Function services failure (with cause %s)"
,
cause
.
c_str
());
cause
.
c_str
());
// if (!cause.compare("DNN_DENIED"))
// if (!cause.compare("DNN_DENIED"))
handle_post_sm_context_response_error
(
handle_post_sm_context_response_error
(
httpCode
,
cause
,
n1sm_hex
,
supi
,
pdu_session_id
);
httpCode
,
cause
,
n1sm_hex
,
supi
,
pdu_session_id
);
...
@@ -746,7 +718,7 @@ bool amf_n11::discover_smf(
...
@@ -746,7 +718,7 @@ bool amf_n11::discover_smf(
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
NRF_CURL_TIMEOUT_MS
);
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
NRF_CURL_TIMEOUT_MS
);
curl_easy_setopt
(
curl
,
CURLOPT_INTERFACE
,
amf_cfg
.
n11
.
if_name
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_INTERFACE
,
amf_cfg
.
n11
.
if_name
.
c_str
());
// Response information
.
// Response information
long
httpCode
=
{
0
};
long
httpCode
=
{
0
};
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
&
callback
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
&
callback
);
...
@@ -867,7 +839,7 @@ bool amf_n11::send_ue_authentication_request(
...
@@ -867,7 +839,7 @@ bool amf_n11::send_ue_authentication_request(
curl
,
CURLOPT_HTTP_VERSION
,
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE
);
curl
,
CURLOPT_HTTP_VERSION
,
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE
);
}
}
// Response information
.
// Response information
long
httpCode
=
{
0
};
long
httpCode
=
{
0
};
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
&
callback
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
&
callback
);
...
@@ -912,8 +884,8 @@ bool amf_n11::send_ue_authentication_request(
...
@@ -912,8 +884,8 @@ bool amf_n11::send_ue_authentication_request(
// From AMF_N1, need to be reworked
// From AMF_N1, need to be reworked
void
amf_n11
::
curl_http_client
(
void
amf_n11
::
curl_http_client
(
std
::
string
remoteUri
,
std
::
string
Method
,
std
::
string
msgBody
,
std
::
string
remoteUri
,
std
::
string
Method
,
std
::
string
msgBody
,
std
::
string
&
R
esponse
)
{
std
::
string
&
r
esponse
)
{
Logger
::
amf_n1
().
info
(
"Send HTTP message with body %s"
,
msgBody
.
c_str
());
Logger
::
amf_n1
1
().
info
(
"Send HTTP message with body %s"
,
msgBody
.
c_str
());
uint32_t
str_len
=
msgBody
.
length
();
uint32_t
str_len
=
msgBody
.
length
();
char
*
body_data
=
(
char
*
)
malloc
(
str_len
+
1
);
char
*
body_data
=
(
char
*
)
malloc
(
str_len
+
1
);
...
@@ -944,8 +916,6 @@ void amf_n11::curl_http_client(
...
@@ -944,8 +916,6 @@ void amf_n11::curl_http_client(
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
CURL_TIMEOUT_MS
);
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
CURL_TIMEOUT_MS
);
curl_easy_setopt
(
curl
,
CURLOPT_TCP_KEEPALIVE
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_TCP_KEEPALIVE
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_INTERFACE
,
amf_cfg
.
n11
.
if_name
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_INTERFACE
,
amf_cfg
.
n11
.
if_name
.
c_str
());
// Logger::amf_n1().info("[CURL] request sent by interface " +
// udm_cfg.nudr.if_name);
// Response information.
// Response information.
long
httpCode
=
{
0
};
long
httpCode
=
{
0
};
...
@@ -967,13 +937,13 @@ void amf_n11::curl_http_client(
...
@@ -967,13 +937,13 @@ void amf_n11::curl_http_client(
// get the response
// get the response
std
::
string
response
=
*
httpData
.
get
();
std
::
string
response
=
*
httpData
.
get
();
std
::
string
json_data_response
=
""
;
std
::
string
json_data_response
=
{}
;
std
::
string
resMsg
=
""
;
std
::
string
resMsg
=
{}
;
bool
is_response_ok
=
true
;
bool
is_response_ok
=
true
;
Logger
::
amf_n1
().
info
(
"Get response with httpcode (%d)"
,
httpCode
);
Logger
::
amf_n1
1
().
info
(
"Get response with httpcode (%d)"
,
httpCode
);
if
(
httpCode
==
0
)
{
if
(
httpCode
==
0
)
{
Logger
::
amf_n1
().
info
(
Logger
::
amf_n1
1
().
info
(
"Cannot get response when calling %s"
,
remoteUri
.
c_str
());
"Cannot get response when calling %s"
,
remoteUri
.
c_str
());
// free curl before returning
// free curl before returning
curl_slist_free_all
(
headers
);
curl_slist_free_all
(
headers
);
...
@@ -986,33 +956,32 @@ void amf_n11::curl_http_client(
...
@@ -986,33 +956,32 @@ void amf_n11::curl_http_client(
if
(
httpCode
!=
200
&&
httpCode
!=
201
&&
httpCode
!=
204
)
{
if
(
httpCode
!=
200
&&
httpCode
!=
201
&&
httpCode
!=
204
)
{
is_response_ok
=
false
;
is_response_ok
=
false
;
if
(
response
.
size
()
<
1
)
{
if
(
response
.
size
()
<
1
)
{
Logger
::
amf_n1
().
info
(
"There's no content in the response"
);
Logger
::
amf_n1
1
().
info
(
"There's no content in the response"
);
// TODO: send context response error
// TODO: send context response error
return
;
return
;
}
}
Logger
::
amf_n1
().
info
(
"Wrong response code"
);
Logger
::
amf_n11
().
debug
(
"Error with response code %d"
,
httpCode
);
return
;
return
;
}
}
else
{
else
{
R
esponse
=
*
httpData
.
get
();
r
esponse
=
*
httpData
.
get
();
}
}
if
(
!
is_response_ok
)
{
if
(
!
is_response_ok
)
{
try
{
try
{
response_data
=
nlohmann
::
json
::
parse
(
json_data_response
);
response_data
=
nlohmann
::
json
::
parse
(
json_data_response
);
}
catch
(
nlohmann
::
json
::
exception
&
e
)
{
}
catch
(
nlohmann
::
json
::
exception
&
e
)
{
Logger
::
amf_n1
().
info
(
"Could not get Json content from the response"
);
Logger
::
amf_n1
1
().
info
(
"Could not get Json content from the response"
);
// Set the default Cause
// Set the default Cause
response_data
[
"error"
][
"cause"
]
=
"504 Gateway Timeout"
;
response_data
[
"error"
][
"cause"
]
=
"504 Gateway Timeout"
;
}
}
Logger
::
amf_n1
().
info
(
Logger
::
amf_n1
1
().
info
(
"Get response with jsonData: %s"
,
json_data_response
.
c_str
());
"Get response with jsonData: %s"
,
json_data_response
.
c_str
());
std
::
string
cause
=
response_data
[
"error"
][
"cause"
];
std
::
string
cause
=
response_data
[
"error"
][
"cause"
];
Logger
::
amf_n1
().
info
(
"Call Network Function services failure"
);
Logger
::
amf_n1
1
().
info
(
"Call Network Function services failure"
);
Logger
::
amf_n11
().
info
(
"Cause value: %s"
,
cause
.
c_str
());
Logger
::
amf_n11
().
info
(
"Cause value: %s"
,
cause
.
c_str
());
}
}
curl_slist_free_all
(
headers
);
curl_slist_free_all
(
headers
);
...
...
src/amf-app/amf_n11.hpp
View file @
5f499912
...
@@ -71,7 +71,7 @@ class amf_n11 {
...
@@ -71,7 +71,7 @@ class amf_n11 {
void
curl_http_client
(
void
curl_http_client
(
std
::
string
remoteUri
,
std
::
string
Method
,
std
::
string
msgBody
,
std
::
string
remoteUri
,
std
::
string
Method
,
std
::
string
msgBody
,
std
::
string
&
R
esponse
);
std
::
string
&
r
esponse
);
bool
discover_smf
(
bool
discover_smf
(
std
::
string
&
smf_addr
,
std
::
string
&
smf_api_version
,
std
::
string
&
smf_addr
,
std
::
string
&
smf_api_version
,
...
...
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