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
f3e73efb
Commit
f3e73efb
authored
Oct 16, 2019
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix isssue for encode/decode N1 SM container (Hex)
parent
12fa7ade
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
221 additions
and
92 deletions
+221
-92
src/api-server/impl/SMContextsCollectionApiImpl.cpp
src/api-server/impl/SMContextsCollectionApiImpl.cpp
+30
-10
src/nas/nas_message.c
src/nas/nas_message.c
+1
-0
src/oai_smf/CMakeLists.txt
src/oai_smf/CMakeLists.txt
+1
-1
src/smf_app/smf_app.cpp
src/smf_app/smf_app.cpp
+171
-75
src/smf_app/smf_app.hpp
src/smf_app/smf_app.hpp
+9
-1
src/smf_app/smf_n11.cpp
src/smf_app/smf_n11.cpp
+9
-5
No files found.
src/api-server/impl/SMContextsCollectionApiImpl.cpp
View file @
f3e73efb
...
...
@@ -14,6 +14,7 @@
#include "logger.hpp"
#include "smf_msg.hpp"
#include "itti_msg_n11.hpp"
#include "3gpp_29.502.h"
extern
"C"
{
#include "nas_message.h"
...
...
@@ -44,19 +45,39 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
SmContextCreateData
smContextCreateData
=
smContextMessage
.
getJsonData
();
std
::
string
n1_sm_msg
=
smContextMessage
.
getBinaryDataN1SmMessage
();
//FOR DEBUG ONLY!!, GENERATE A PDU SESSION ESTABLISHMENT MESSAGE HERE!!
//FOR DEBUG ONLY!!, GENERATE A PDU SESSION ESTABLISHMENT MESSAGE HERE!!
//sm_encode_establishment_request();
//m_smf_app->create_n1_sm_container(PDU_SESSION_ESTABLISHMENT_REQUEST, n1_sm_msg);
m_smf_app
->
create_n1_sm_container
(
PDU_SESSION_ESTABLISHMENT_REQUEST
,
n1_sm_msg
);
std
::
string
n1_sm_msg_hex
;
m_smf_app
->
convert_string_2_hex
(
n1_sm_msg
,
n1_sm_msg_hex
);
Logger
::
smf_api_server
().
debug
(
"smContextMessage, n1 sm msg %s"
,
n1_sm_msg
.
c_str
());
//Step1. Decode N1 SM container into decoded nas msg
int
decoder_rc
=
m_smf_app
->
decode_nas_message_n1_sm_container
(
decoded_nas_msg
,
n1_sm_msg
);
if
(
decoder_rc
!=
RETURNok
){
//error, should send reply to AMF with error code!!
int
decoder_rc
=
m_smf_app
->
decode_nas_message_n1_sm_container
(
decoded_nas_msg
,
n1_sm_msg_hex
);
if
(
decoder_rc
!=
RETURNok
)
{
//error, should send reply to AMF with error code!!
Logger
::
smf_api_server
().
warn
(
"N1 SM container cannot be decoded correctly!
\n
"
);
SmContextCreateError
smContextCreateError
;
ProblemDetails
problem_details
;
RefToBinaryData
binary_data
;
std
::
string
n1_container
;
problem_details
.
setCause
(
pdu_session_application_error_e2str
[
PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR
]);
smContextCreateError
.
setError
(
problem_details
);
//PDU Session Establishment Reject
//24.501: response with a 5GSM STATUS message including cause "#95 Semantically incorrect message"
m_smf_app
->
create_n1_sm_container
(
PDU_SESSION_ESTABLISHMENT_REJECT
,
n1_container
,
95
);
//TODO: should define 5GSM cause in 24.501
binary_data
.
setContentId
(
n1_container
);
smContextCreateError
.
setN1SmMsg
(
binary_data
);
//Send response to AMF
nlohmann
::
json
jsonData
;
to_json
(
jsonData
,
smContextCreateError
);
std
::
string
resBody
=
jsonData
.
dump
();
//httpResponse.headers().add<Pistache::Http::Header::Location>(url);
response
.
send
(
Pistache
::
Http
::
Code
::
Forbidden
,
resBody
);
return
;
}
Logger
::
smf_api_server
().
debug
(
"nas header decode extended_protocol_discriminator %d, security_header_type:%d,sequence_number:%d,message_authentication_code:%d
\n
"
,
...
...
@@ -108,7 +129,6 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
//Message type (Mandatory) (PDU SESSION ESTABLISHMENT REQUEST message identity)
sm_context_req_msg
.
set_message_type
(
decoded_nas_msg
.
plain
.
sm
.
header
.
message_type
);
sm_context_req_msg
.
set_message_type
(
PDU_SESSION_ESTABLISHMENT_REQUEST
);
//Temporary - should be removed (get from NAS)
//Integrity protection maximum data rate (Mandatory)
...
...
src/nas/nas_message.c
View file @
f3e73efb
...
...
@@ -295,6 +295,7 @@ int nas_message_decode (
}
//return bytes;
//OAILOG_FUNC_RETURN (LOG_NAS, bytes);
return
RETURNok
;
}
...
...
src/oai_smf/CMakeLists.txt
View file @
f3e73efb
...
...
@@ -362,7 +362,7 @@ add_executable(smf
${
SRC_TOP_DIR
}
/oai_smf/options.cpp
${
SRC_TOP_DIR
}
/itti/itti.cpp
${
SRC_TOP_DIR
}
/itti/itti_msg.cpp
#
${SRC_TOP_DIR}/oai_smf/nas_sm_encode_to_json.c
${
SRC_TOP_DIR
}
/oai_smf/nas_sm_encode_to_json.c
)
IF
(
STATIC_LINKING
)
...
...
src/smf_app/smf_app.cpp
View file @
f3e73efb
This diff is collapsed.
Click to expand it.
src/smf_app/smf_app.hpp
View file @
f3e73efb
...
...
@@ -208,7 +208,15 @@ public:
* @param [std::string&] n1_sm_msg N1 SM Container from AMF
* @return status of the decode process
*/
uint8_t
decode_nas_message_n1_sm_container
(
nas_message_t
&
nas_msg
,
std
::
string
&
n1_sm_msg
);
int
decode_nas_message_n1_sm_container
(
nas_message_t
&
nas_msg
,
std
::
string
&
n1_sm_msg
);
/*
* Convert a string to hex representing this string
* @param [std::string&] input_str Input string
* @param [std::string&] output_str String represents string in hex format
* @return void
*/
void
convert_string_2_hex
(
std
::
string
&
input_str
,
std
::
string
&
output_str
);
};
}
...
...
src/smf_app/smf_n11.cpp
View file @
f3e73efb
...
...
@@ -134,19 +134,23 @@ void smf_n11::send_msg_to_amf(std::shared_ptr<itti_n11_create_sm_context_respons
CURL
*
curl
=
curl_easy_init
();
//hardcoded for the moment, should get from NRF/configuration file
std
::
string
url
=
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
smf_cfg
.
amf_addr
.
ipv4_addr
)))
+
":"
+
std
::
to_string
(
smf_cfg
.
amf_addr
.
port
)
+
"/namf-comm/v1/ue-contexts/"
+
std
::
to_string
(
supi64
)
+
"/n1-n2-messages"
;
Logger
::
smf_n11
().
debug
(
"[
get_sm_data] UDM
's URL: %s "
,
url
.
c_str
());
Logger
::
smf_n11
().
debug
(
"[
Send Communication_N1N2MessageTransfer to AMF] AMF
's URL: %s "
,
url
.
c_str
());
//N1 SM container
if
(
sm_context_res
->
res
.
get_cause
()
!=
REQUEST_ACCEPTED
)
{
//PDU Session Establishment Reject
Logger
::
smf_n11
().
debug
(
"[Send Communication_N1N2MessageTransfer to AMF] PDU Session Establishment Reject
\n
"
);
smf_app_inst
->
create_n1_sm_container
(
sm_context_res
,
PDU_SESSION_ESTABLISHMENT_REJECT
,
n1_message
);
//need cause?
}
else
{
//PDU Session Establishment Accept
smf_app_inst
->
create_n1_sm_container
(
sm_context_res
,
PDU_SESSION_ESTABLISHMENT_REJECT
,
n1_message
);
//need cause?
//
smf_app_inst->create_n1_sm_container(sm_context_res, PDU_SESSION_ESTABLISHMENT_ACCPET, n1_message); //need cause?
Logger
::
smf_n11
().
debug
(
"[Send Communication_N1N2MessageTransfer to AMF] PDU Session Establishment Accept
\n
"
);
smf_app_inst
->
create_n1_sm_container
(
sm_context_res
,
PDU_SESSION_ESTABLISHMENT_ACCPET
,
n1_message
);
//need cause?
}
std
::
string
n1_msg_hex
;
smf_app_inst
->
convert_string_2_hex
(
n1_message
,
n1_msg_hex
);
jsonData
[
"n1MessageContainer"
][
"n1MessageClass"
]
=
"SM"
;
jsonData
[
"n1MessageContainer"
][
"n1MessageContent"
][
"contentId"
]
=
n1_m
essage
.
c_str
()
;
Logger
::
smf_n11
().
debug
(
"n1MessageContent: %s
\n
"
,
n1_m
essage
.
c_str
());
jsonData
[
"n1MessageContainer"
][
"n1MessageContent"
][
"contentId"
]
=
n1_m
sg_hex
;
Logger
::
smf_n11
().
debug
(
"n1MessageContent: %s
\n
"
,
n1_m
sg_hex
.
c_str
());
//TODO: fill the content of N1N2MessageTransferReqData
//jsonData["n2InfoContainer"]["n2InformationClass"] = "SM";
...
...
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