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
31e0877d
Commit
31e0877d
authored
Apr 30, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for UE Triggered Service Request
parent
50e9f49e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
224 additions
and
14 deletions
+224
-14
src/api-server/api/IndividualSMContextApi.cpp
src/api-server/api/IndividualSMContextApi.cpp
+16
-7
src/smf_app/smf_context.cpp
src/smf_app/smf_context.cpp
+7
-6
src/smf_app/smf_procedure.cpp
src/smf_app/smf_procedure.cpp
+10
-0
src/test/amf_client/amf-client.cpp
src/test/amf_client/amf-client.cpp
+191
-1
No files found.
src/api-server/api/IndividualSMContextApi.cpp
View file @
31e0877d
...
@@ -131,7 +131,7 @@ void IndividualSMContextApi::release_sm_context_handler(
...
@@ -131,7 +131,7 @@ void IndividualSMContextApi::release_sm_context_handler(
//return;
//return;
}
}
free_wrapper
((
void
**
)
&
data
);
free_wrapper
((
void
**
)
&
data
);
uint8_t
size
=
g_parts
.
size
();
uint8_t
size
=
g_parts
.
size
();
Logger
::
smf_api_server
().
debug
(
"Number of g_parts %d"
,
g_parts
.
size
());
Logger
::
smf_api_server
().
debug
(
"Number of g_parts %d"
,
g_parts
.
size
());
...
@@ -204,6 +204,7 @@ void IndividualSMContextApi::update_sm_context_handler(
...
@@ -204,6 +204,7 @@ void IndividualSMContextApi::update_sm_context_handler(
const
Pistache
::
Rest
::
Request
&
request
,
const
Pistache
::
Rest
::
Request
&
request
,
Pistache
::
Http
::
ResponseWriter
response
)
{
Pistache
::
Http
::
ResponseWriter
response
)
{
Logger
::
smf_api_server
().
debug
(
""
);
Logger
::
smf_api_server
().
info
(
Logger
::
smf_api_server
().
info
(
"Received a SM context update request from AMF"
);
"Received a SM context update request from AMF"
);
Logger
::
smf_api_server
().
debug
(
"Request body: %s
\n
"
,
request
.
body
().
c_str
());
Logger
::
smf_api_server
().
debug
(
"Request body: %s
\n
"
,
request
.
body
().
c_str
());
...
@@ -247,16 +248,19 @@ void IndividualSMContextApi::update_sm_context_handler(
...
@@ -247,16 +248,19 @@ void IndividualSMContextApi::update_sm_context_handler(
//return;
//return;
}
}
free_wrapper
((
void
**
)
&
data
);
free_wrapper
((
void
**
)
&
data
);
uint8_t
size
=
g_parts
.
size
();
uint8_t
size
=
g_parts
.
size
();
Logger
::
smf_api_server
().
debug
(
"Number of g_parts %d"
,
g_parts
.
size
());
Logger
::
smf_api_server
().
debug
(
"Number of g_parts %d"
,
g_parts
.
size
());
part
p0
=
g_parts
.
front
();
part
p0
=
{
};
g_parts
.
pop_front
();
Logger
::
smf_api_server
().
debug
(
"Request body, part 1: %s"
,
p0
.
body
.
c_str
());
part
p1
=
{
};
part
p1
=
{
};
if
(
size
>
0
)
{
p0
=
g_parts
.
front
();
g_parts
.
pop_front
();
Logger
::
smf_api_server
().
debug
(
"Request body, part 1: %s"
,
p0
.
body
.
c_str
());
}
if
(
size
>
1
)
{
if
(
size
>
1
)
{
p1
=
g_parts
.
front
();
p1
=
g_parts
.
front
();
g_parts
.
pop_front
();
g_parts
.
pop_front
();
...
@@ -269,7 +273,12 @@ void IndividualSMContextApi::update_sm_context_handler(
...
@@ -269,7 +273,12 @@ void IndividualSMContextApi::update_sm_context_handler(
// Getting the body param
// Getting the body param
SmContextUpdateData
smContextUpdateData
=
{
};
SmContextUpdateData
smContextUpdateData
=
{
};
try
{
try
{
nlohmann
::
json
::
parse
(
p0
.
body
.
c_str
()).
get_to
(
smContextUpdateData
);
if
(
size
>
0
)
{
nlohmann
::
json
::
parse
(
p0
.
body
.
c_str
()).
get_to
(
smContextUpdateData
);
}
else
{
nlohmann
::
json
::
parse
(
request
.
body
().
c_str
()).
get_to
(
smContextUpdateData
);
}
smContextUpdateMessage
.
setJsonData
(
smContextUpdateData
);
smContextUpdateMessage
.
setJsonData
(
smContextUpdateData
);
if
(
size
>
1
)
{
if
(
size
>
1
)
{
...
...
src/smf_app/smf_context.cpp
View file @
31e0877d
...
@@ -1649,16 +1649,17 @@ void smf_context::handle_pdu_session_update_sm_context_request(
...
@@ -1649,16 +1649,17 @@ void smf_context::handle_pdu_session_update_sm_context_request(
//2 - UE Triggered Service Request Procedure (step 2)
//2 - UE Triggered Service Request Procedure (step 2)
Logger
::
smf_app
().
info
(
"PDU_RES_SETUP_RSP"
);
Logger
::
smf_app
().
info
(
"PDU_RES_SETUP_RSP"
);
Logger
::
smf_app
().
info
(
"PDU Session Establishment Request, processing N2 SM Information"
);
procedure_type
=
session_management_procedures_type_e
::
PDU_SESSION_ESTABLISHMENT_UE_REQUESTED
;
if
(
sm_context_req_msg
.
rat_type_is_set
()
if
(
sm_context_req_msg
.
rat_type_is_set
()
and
sm_context_req_msg
.
an_type_is_set
())
{
and
sm_context_req_msg
.
an_type_is_set
())
{
procedure_type
=
procedure_type
=
session_management_procedures_type_e
::
SERVICE_REQUEST_UE_TRIGGERED_STEP2
;
session_management_procedures_type_e
::
SERVICE_REQUEST_UE_TRIGGERED_STEP2
;
Logger
::
smf_app
().
info
(
"UE Triggered Service Request, processing N2 SM Information"
);
}
else
{
procedure_type
=
session_management_procedures_type_e
::
PDU_SESSION_ESTABLISHMENT_UE_REQUESTED
;
Logger
::
smf_app
().
info
(
"PDU Session Establishment Request, processing N2 SM Information"
);
}
}
//Ngap_PDUSessionResourceSetupResponseTransfer
//Ngap_PDUSessionResourceSetupResponseTransfer
...
...
src/smf_app/smf_procedure.cpp
View file @
31e0877d
...
@@ -940,6 +940,15 @@ void session_update_sm_context_procedure::handle_itti_msg(
...
@@ -940,6 +940,15 @@ void session_update_sm_context_procedure::handle_itti_msg(
// Update QoS Flow
// Update QoS Flow
smf_qos_flow
qos_flow2
=
qos_flow
;
smf_qos_flow
qos_flow2
=
qos_flow
;
ppc
->
add_qos_flow
(
qos_flow2
);
ppc
->
add_qos_flow
(
qos_flow2
);
qos_flow_context_updated
qcu
=
{
};
qcu
.
set_cause
(
REQUEST_ACCEPTED
);
qcu
.
set_qfi
(
pfcp
::
qfi_t
(
it
.
first
));
qcu
.
set_ul_fteid
(
qos_flow
.
ul_fteid
);
qcu
.
set_qos_profile
(
qos_flow
.
qos_profile
);
n11_triggered_pending
->
res
.
add_qos_flow_context_updated
(
qcu
);
}
}
}
}
}
}
...
@@ -1082,6 +1091,7 @@ void session_update_sm_context_procedure::handle_itti_msg(
...
@@ -1082,6 +1091,7 @@ void session_update_sm_context_procedure::handle_itti_msg(
int ret = itti_inst->send_msg(itti_msg);
int ret = itti_inst->send_msg(itti_msg);
*/
*/
//Prepare response to send to AMF (N1N2MessageTransfer or PDUSession_UpdateSMContextResponse)
nlohmann
::
json
sm_context_updated_data
=
{
};
nlohmann
::
json
sm_context_updated_data
=
{
};
sm_context_updated_data
[
"n1MessageContainer"
][
"n1MessageClass"
]
=
sm_context_updated_data
[
"n1MessageContainer"
][
"n1MessageClass"
]
=
N1N2_MESSAGE_CLASS
;
N1N2_MESSAGE_CLASS
;
...
...
src/test/amf_client/amf-client.cpp
View file @
31e0877d
...
@@ -660,6 +660,192 @@ void send_pdu_session_release_complete(std::string smf_ip_address) {
...
@@ -660,6 +660,192 @@ void send_pdu_session_release_complete(std::string smf_ip_address) {
free
(
buffer
);
free
(
buffer
);
}
}
//------------------------------------------------------------------------------
void
send_pdu_session_update_sm_context_ue_service_request
(
std
::
string
smf_ip_address
)
{
std
::
cout
<<
"[AMF N11] UE-triggered Service Request (SM Context Update Step 1)"
<<
std
::
endl
;
nlohmann
::
json
service_requests
;
//NO NAS, No NGAP
std
::
string
url
=
std
::
string
(
"http://"
);
url
.
append
(
smf_ip_address
);
url
.
append
(
std
::
string
(
"/nsmf-pdusession/v2/sm-contexts/1/modify"
));
//PDU session ID (as specified in section 4.2.3.2 @ 3GPP TS 23.502, but can't find in Yaml file)
service_requests
[
"upCnxState"
]
=
"ACTIVATING"
;
service_requests
[
"ratType"
]
=
"NR"
;
service_requests
[
"anType"
]
=
"3GPP_ACCESS"
;
std
::
string
body
;
body
=
service_requests
.
dump
();
curl_global_init
(
CURL_GLOBAL_ALL
);
CURL
*
curl
=
curl
=
curl_easy_init
();
if
(
curl
)
{
CURLcode
res
=
{
};
struct
curl_slist
*
headers
=
nullptr
;
//headers = curl_slist_append(headers, "charsets: utf-8");
headers
=
curl_slist_append
(
headers
,
"content-type: application/json"
);
curl_easy_setopt
(
curl
,
CURLOPT_HTTPHEADER
,
headers
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_HTTPGET
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
100L
);
//curl_easy_setopt(curl, CURLOPT_INTERFACE, "eno1:amf"); //hardcoded
// Response information.
long
httpCode
=
{
0
};
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
&
callback
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
httpData
.
get
());
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDSIZE
,
body
.
length
());
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDS
,
body
.
c_str
());
res
=
curl_easy_perform
(
curl
);
curl_easy_getinfo
(
curl
,
CURLINFO_RESPONSE_CODE
,
&
httpCode
);
//get response from SMF
nlohmann
::
json
response_data
;
try
{
response_data
=
nlohmann
::
json
::
parse
(
*
httpData
.
get
());
}
catch
(
nlohmann
::
json
::
exception
&
e
)
{
std
::
cout
<<
"Could not get json data from the response"
<<
std
::
endl
;
}
std
::
cout
<<
"[AMF N11] UE Triggered Service Request (Step 1), response from SMF, Http Code "
<<
httpCode
<<
std
::
endl
;
curl_easy_cleanup
(
curl
);
}
curl_global_cleanup
();
}
//------------------------------------------------------------------------------
void
send_pdu_session_update_sm_context_ue_service_request_step2
(
std
::
string
smf_ip_address
)
{
std
::
cout
<<
"[AMF N11] UE-triggered Service Request (SM Context Update Step 2)"
<<
std
::
endl
;
nlohmann
::
json
service_requests
;
//encode PDU Session Resource Setup Response Transfer IE
/*
00 03 e0 ac 0a 05 01 00 00 00 01 00 3c
*/
size_t
buffer_size
=
128
;
char
*
buffer
=
(
char
*
)
calloc
(
1
,
buffer_size
);
int
size
=
0
;
ENCODE_U8
(
buffer
,
0x00
,
size
);
ENCODE_U8
(
buffer
+
size
,
0x03
,
size
);
ENCODE_U8
(
buffer
+
size
,
0xe0
,
size
);
ENCODE_U8
(
buffer
+
size
,
0xac
,
size
);
//uPTransportLayerInformation IP Addr 172.10.5.1: 172.
ENCODE_U8
(
buffer
+
size
,
0x0a
,
size
);
//10
ENCODE_U8
(
buffer
+
size
,
0x05
,
size
);
//.5
ENCODE_U8
(
buffer
+
size
,
0x01
,
size
);
//.1
ENCODE_U8
(
buffer
+
size
,
0x00
,
size
);
//gTP_TEID 00 00 00 01: 00
ENCODE_U8
(
buffer
+
size
,
0x00
,
size
);
//00
ENCODE_U8
(
buffer
+
size
,
0x00
,
size
);
//00
ENCODE_U8
(
buffer
+
size
,
0x01
,
size
);
//01
ENCODE_U8
(
buffer
+
size
,
0x00
,
size
);
//Associated QoS Flow 00 3c
ENCODE_U8
(
buffer
+
size
,
0x3c
,
size
);
//QFI: 60
std
::
cout
<<
"Buffer: "
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
printf
(
"%02x "
,
buffer
[
i
]);
}
std
::
cout
<<
"Buffer: "
<<
std
::
endl
;
std
::
string
url
=
std
::
string
(
"http://"
);
url
.
append
(
smf_ip_address
);
url
.
append
(
std
::
string
(
"/nsmf-pdusession/v2/sm-contexts/1/modify"
));
//Fill the json part
service_requests
[
"n2SmInfoType"
]
=
"PDU_RES_SETUP_RSP"
;
service_requests
[
"n2SmInfo"
][
"contentId"
]
=
"n2SmMsg"
;
//NGAP
//service_requests["n2InfoContainer"]["n2InformationClass"] = "SM";
//service_requests["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapData"]["contentId"] = "n2SmMsg";
// service_requests["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapIeType"] =
// "PDU_RES_SETUP_RSP"; //NGAP message
service_requests
[
"anType"
]
=
"3GPP_ACCESS"
;
service_requests
[
"ratType"
]
=
"NR"
;
std
::
string
body
;
std
::
string
boundary
=
"----Boundary"
;
std
::
string
json_part
=
service_requests
.
dump
();
std
::
string
n2_msg
(
reinterpret_cast
<
const
char
*>
(
buffer
),
size
);
create_multipart_related_content
(
body
,
json_part
,
boundary
,
n2_msg
,
multipart_related_content_part_e
::
NGAP
);
unsigned
char
*
data
=
(
unsigned
char
*
)
malloc
(
body
.
length
()
+
1
);
memset
(
data
,
0
,
body
.
length
()
+
1
);
memcpy
((
void
*
)
data
,
(
void
*
)
body
.
c_str
(),
body
.
length
());
curl_global_init
(
CURL_GLOBAL_ALL
);
CURL
*
curl
=
curl
=
curl_easy_init
();
if
(
curl
)
{
CURLcode
res
=
{
};
struct
curl_slist
*
headers
=
nullptr
;
//headers = curl_slist_append(headers, "charsets: utf-8");
headers
=
curl_slist_append
(
headers
,
"content-type: multipart/related; boundary=----Boundary"
);
curl_easy_setopt
(
curl
,
CURLOPT_HTTPHEADER
,
headers
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_HTTPGET
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
100L
);
//curl_easy_setopt(curl, CURLOPT_INTERFACE, "eno1:amf"); //hardcoded
// Response information.
long
httpCode
=
{
0
};
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
&
callback
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
httpData
.
get
());
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDSIZE
,
body
.
length
());
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDS
,
data
);
res
=
curl_easy_perform
(
curl
);
curl_easy_getinfo
(
curl
,
CURLINFO_RESPONSE_CODE
,
&
httpCode
);
//get cause from the response
nlohmann
::
json
response_data
;
try
{
response_data
=
nlohmann
::
json
::
parse
(
*
httpData
.
get
());
}
catch
(
nlohmann
::
json
::
exception
&
e
)
{
std
::
cout
<<
"Could not get json data from the response"
<<
std
::
endl
;
//Set the default Cause
response_data
[
"cause"
]
=
"504 Gateway Timeout"
;
}
std
::
cout
<<
"[AMF N11] UE Triggered Service Request (Step 2), response from SMF, Http Code "
<<
httpCode
<<
" cause "
<<
response_data
[
"cause"
].
dump
().
c_str
()
<<
std
::
endl
;
curl_easy_cleanup
(
curl
);
}
curl_global_cleanup
();
free
(
buffer
);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
string
smf_ip_address
;
std
::
string
smf_ip_address
;
...
@@ -694,11 +880,15 @@ int main(int argc, char *argv[]) {
...
@@ -694,11 +880,15 @@ int main(int argc, char *argv[]) {
send_pdu_session_update_sm_context_establishment
(
smf_ip_address
);
send_pdu_session_update_sm_context_establishment
(
smf_ip_address
);
usleep
(
200000
);
usleep
(
200000
);
//PDU Session Release procedure
//PDU Session Release procedure
send_pdu_session_release_request
(
smf_ip_address
);
/*
send_pdu_session_release_request(smf_ip_address);
usleep(200000);
usleep(200000);
send_pdu_session_release_resource_release_ack(smf_ip_address);
send_pdu_session_release_resource_release_ack(smf_ip_address);
usleep(200000);
usleep(200000);
send_pdu_session_release_complete(smf_ip_address);
send_pdu_session_release_complete(smf_ip_address);
*/
send_pdu_session_update_sm_context_ue_service_request
(
smf_ip_address
);
usleep
(
200000
);
send_pdu_session_update_sm_context_ue_service_request_step2
(
smf_ip_address
);
return
0
;
return
0
;
}
}
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