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
9e8579fc
Commit
9e8579fc
authored
Jun 13, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor update for Mime Parser (free memory/use static function)
parent
9b707ff3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
22 deletions
+27
-22
src/api-server/impl/IndividualSMContextApiImpl.cpp
src/api-server/impl/IndividualSMContextApiImpl.cpp
+3
-4
src/api-server/impl/SMContextsCollectionApiImpl.cpp
src/api-server/impl/SMContextsCollectionApiImpl.cpp
+1
-2
src/api-server/smf-http2-server.cpp
src/api-server/smf-http2-server.cpp
+3
-4
src/common/utils/mime_parser.cpp
src/common/utils/mime_parser.cpp
+11
-0
src/common/utils/mime_parser.hpp
src/common/utils/mime_parser.hpp
+3
-3
src/smf_app/smf_sbi.cpp
src/smf_app/smf_sbi.cpp
+6
-9
No files found.
src/api-server/impl/IndividualSMContextApiImpl.cpp
View file @
9e8579fc
...
...
@@ -143,7 +143,6 @@ void IndividualSMContextApiImpl::update_sm_context(
Logger
::
smf_api_server
().
debug
(
"Got result for promise ID %d"
,
promise_id
);
nlohmann
::
json
json_data
=
{};
mime_parser
parser
=
{};
std
::
string
body
=
{};
std
::
string
json_format
;
...
...
@@ -153,7 +152,7 @@ void IndividualSMContextApiImpl::update_sm_context(
if
(
sm_context_response
.
n1_sm_msg_is_set
()
and
sm_context_response
.
n2_sm_info_is_set
())
{
parser
.
create_multipart_related_content
(
mime_parser
::
create_multipart_related_content
(
body
,
json_data
.
dump
(),
CURL_MIME_BOUNDARY
,
sm_context_response
.
get_n1_sm_message
(),
sm_context_response
.
get_n2_sm_information
(),
json_format
);
...
...
@@ -161,7 +160,7 @@ void IndividualSMContextApiImpl::update_sm_context(
Pistache
::
Http
::
Mime
::
MediaType
(
"multipart/related; boundary="
+
std
::
string
(
CURL_MIME_BOUNDARY
)));
}
else
if
(
sm_context_response
.
n1_sm_msg_is_set
())
{
parser
.
create_multipart_related_content
(
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
);
...
...
@@ -169,7 +168,7 @@ void IndividualSMContextApiImpl::update_sm_context(
Pistache
::
Http
::
Mime
::
MediaType
(
"multipart/related; boundary="
+
std
::
string
(
CURL_MIME_BOUNDARY
)));
}
else
if
(
sm_context_response
.
n2_sm_info_is_set
())
{
parser
.
create_multipart_related_content
(
mime_parser
::
create_multipart_related_content
(
body
,
json_data
.
dump
(),
CURL_MIME_BOUNDARY
,
sm_context_response
.
get_n2_sm_information
(),
multipart_related_content_part_e
::
NGAP
,
json_format
);
...
...
src/api-server/impl/SMContextsCollectionApiImpl.cpp
View file @
9e8579fc
...
...
@@ -103,7 +103,6 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
Logger
::
smf_api_server
().
debug
(
"Got result for promise ID %d"
,
promise_id
);
nlohmann
::
json
json_data
=
{};
mime_parser
parser
=
{};
std
::
string
json_format
=
{};
std
::
string
body
=
{};
...
...
@@ -112,7 +111,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
if
(
sm_context_response
.
n1_sm_msg_is_set
())
{
// add N1 container if
// available
parser
.
create_multipart_related_content
(
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
);
...
...
src/api-server/smf-http2-server.cpp
View file @
9e8579fc
...
...
@@ -420,7 +420,6 @@ void smf_http2_server::update_sm_context_handler(
Logger
::
smf_api_server
().
debug
(
"Got result for promise ID %d"
,
promise_id
);
nlohmann
::
json
json_data
=
{};
mime_parser
parser
=
{};
std
::
string
body
=
{};
header_map
h
=
{};
std
::
string
json_format
=
{};
...
...
@@ -431,7 +430,7 @@ void smf_http2_server::update_sm_context_handler(
if
(
sm_context_response
.
n1_sm_msg_is_set
()
and
sm_context_response
.
n2_sm_info_is_set
())
{
parser
.
create_multipart_related_content
(
mime_parser
::
create_multipart_related_content
(
body
,
json_data
.
dump
(),
CURL_MIME_BOUNDARY
,
sm_context_response
.
get_n1_sm_message
(),
sm_context_response
.
get_n2_sm_information
(),
json_format
);
...
...
@@ -439,7 +438,7 @@ void smf_http2_server::update_sm_context_handler(
"content-type"
,
header_value
{
"multipart/related; boundary="
+
std
::
string
(
CURL_MIME_BOUNDARY
)});
}
else
if
(
sm_context_response
.
n1_sm_msg_is_set
())
{
parser
.
create_multipart_related_content
(
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
);
...
...
@@ -447,7 +446,7 @@ void smf_http2_server::update_sm_context_handler(
"content-type"
,
header_value
{
"multipart/related; boundary="
+
std
::
string
(
CURL_MIME_BOUNDARY
)});
}
else
if
(
sm_context_response
.
n2_sm_info_is_set
())
{
parser
.
create_multipart_related_content
(
mime_parser
::
create_multipart_related_content
(
body
,
json_data
.
dump
(),
CURL_MIME_BOUNDARY
,
sm_context_response
.
get_n2_sm_information
(),
multipart_related_content_part_e
::
NGAP
,
json_format
);
...
...
src/common/utils/mime_parser.cpp
View file @
9e8579fc
...
...
@@ -23,6 +23,10 @@
#include "logger.hpp"
#include "conversions.hpp"
extern
"C"
{
#include "dynamic_memory_check.h"
}
bool
mime_parser
::
parse
(
const
std
::
string
&
str
)
{
std
::
string
CRLF
=
"
\r\n
"
;
Logger
::
smf_app
().
debug
(
"Parsing the message with Simple Parser"
);
...
...
@@ -127,6 +131,10 @@ void mime_parser::create_multipart_related_content(
body
.
append
(
CRLF
);
body
.
append
(
std
::
string
((
char
*
)
n2_msg_hex
,
n2_message
.
length
()
/
2
)
+
CRLF
);
body
.
append
(
"--"
+
boundary
+
"--"
+
CRLF
);
// free memory
free_wrapper
((
void
**
)
&
n1_msg_hex
);
free_wrapper
((
void
**
)
&
n2_msg_hex
);
}
//------------------------------------------------------------------------------
...
...
@@ -158,4 +166,7 @@ void mime_parser::create_multipart_related_content(
body
.
append
(
CRLF
);
body
.
append
(
std
::
string
((
char
*
)
msg_hex
,
message
.
length
()
/
2
)
+
CRLF
);
body
.
append
(
"--"
+
boundary
+
"--"
+
CRLF
);
// free memory
free_wrapper
((
void
**
)
&
msg_hex
);
}
src/common/utils/mime_parser.hpp
View file @
9e8579fc
...
...
@@ -62,7 +62,7 @@ class mime_parser {
* @param [const std::string&] str: input string
* @return String represents string in hex format
*/
unsigned
char
*
format_string_as_hex
(
const
std
::
string
&
str
);
static
unsigned
char
*
format_string_as_hex
(
const
std
::
string
&
str
);
/*
* Create HTTP body content for multipart/related message
...
...
@@ -73,7 +73,7 @@ class mime_parser {
* @param [std::string] n2_message: N2 (NGAP) part
* @return void
*/
void
create_multipart_related_content
(
void
static
create_multipart_related_content
(
std
::
string
&
body
,
const
std
::
string
&
json_part
,
const
std
::
string
boundary
,
const
std
::
string
&
n1_message
,
const
std
::
string
&
n2_message
,
...
...
@@ -88,7 +88,7 @@ class mime_parser {
* @param [uint8_t] content_type: 1 for NAS content, else NGAP content
* @return void
*/
void
create_multipart_related_content
(
void
static
create_multipart_related_content
(
std
::
string
&
body
,
const
std
::
string
&
json_part
,
const
std
::
string
boundary
,
const
std
::
string
&
message
,
const
multipart_related_content_part_e
content_type
,
...
...
src/smf_app/smf_sbi.cpp
View file @
9e8579fc
...
...
@@ -165,7 +165,6 @@ void smf_sbi::send_n1n2_message_transfer_request(
"Send Communication_N1N2MessageTransfer to AMF (HTTP version %d)"
,
sm_context_res
->
http_version
);
mime_parser
parser
=
{};
std
::
string
n1_message
=
sm_context_res
->
res
.
get_n1_sm_message
();
nlohmann
::
json
json_data
=
{};
std
::
string
body
;
...
...
@@ -177,11 +176,11 @@ void smf_sbi::send_n1n2_message_transfer_request(
if
(
n2_sm_found
>
0
)
{
std
::
string
n2_message
=
sm_context_res
->
res
.
get_n2_sm_information
();
// prepare the body content for Curl
parser
.
create_multipart_related_content
(
mime_parser
::
create_multipart_related_content
(
body
,
json_part
,
CURL_MIME_BOUNDARY
,
n1_message
,
n2_message
);
}
else
{
// prepare the body content for Curl
parser
.
create_multipart_related_content
(
mime_parser
::
create_multipart_related_content
(
body
,
json_part
,
CURL_MIME_BOUNDARY
,
n1_message
,
multipart_related_content_part_e
::
NAS
);
}
...
...
@@ -284,7 +283,6 @@ void smf_sbi::send_n1n2_message_transfer_request(
sm_session_modification
)
{
Logger
::
smf_sbi
().
debug
(
"Send Communication_N1N2MessageTransfer to AMF"
);
mime_parser
parser
=
{};
std
::
string
body
;
nlohmann
::
json
json_data
=
{};
std
::
string
json_part
;
...
...
@@ -297,10 +295,10 @@ void smf_sbi::send_n1n2_message_transfer_request(
if
(
n2_sm_found
>
0
)
{
std
::
string
n2_message
=
sm_session_modification
->
msg
.
get_n2_sm_information
();
parser
.
create_multipart_related_content
(
mime_parser
::
create_multipart_related_content
(
body
,
json_part
,
CURL_MIME_BOUNDARY
,
n1_message
,
n2_message
);
}
else
{
parser
.
create_multipart_related_content
(
mime_parser
::
create_multipart_related_content
(
body
,
json_part
,
CURL_MIME_BOUNDARY
,
n1_message
,
multipart_related_content_part_e
::
NAS
);
}
...
...
@@ -374,7 +372,6 @@ void smf_sbi::send_n1n2_message_transfer_request(
"Send Communication_N1N2MessageTransfer to AMF (Network-initiated "
"Service Request)"
);
mime_parser
parser
=
{};
std
::
string
n2_message
=
report_msg
->
res
.
get_n2_sm_information
();
nlohmann
::
json
json_data
=
{};
std
::
string
body
;
...
...
@@ -386,10 +383,10 @@ void smf_sbi::send_n1n2_message_transfer_request(
if
(
n1_sm_found
>
0
)
{
std
::
string
n1_message
=
report_msg
->
res
.
get_n1_sm_message
();
// prepare the body content for Curl
parser
.
create_multipart_related_content
(
mime_parser
::
create_multipart_related_content
(
body
,
json_part
,
CURL_MIME_BOUNDARY
,
n1_message
,
n2_message
);
}
else
{
parser
.
create_multipart_related_content
(
mime_parser
::
create_multipart_related_content
(
body
,
json_part
,
CURL_MIME_BOUNDARY
,
n2_message
,
multipart_related_content_part_e
::
NGAP
);
}
...
...
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