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
8b0a2b23
Commit
8b0a2b23
authored
Apr 09, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update SMF API for IndividualSMContextApi/SMContextsCollectionApi
parent
11a86272
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
29 deletions
+51
-29
src/api-server/api/IndividualPDUSessionHSMFApi.cpp
src/api-server/api/IndividualPDUSessionHSMFApi.cpp
+2
-2
src/api-server/api/IndividualSMContextApi.cpp
src/api-server/api/IndividualSMContextApi.cpp
+46
-24
src/api-server/api/SMContextsCollectionApi.cpp
src/api-server/api/SMContextsCollectionApi.cpp
+3
-3
No files found.
src/api-server/api/IndividualPDUSessionHSMFApi.cpp
View file @
8b0a2b23
...
@@ -44,7 +44,7 @@ void IndividualPDUSessionHSMFApi::release_pdu_session_handler(const Pistache::Re
...
@@ -44,7 +44,7 @@ void IndividualPDUSessionHSMFApi::release_pdu_session_handler(const Pistache::Re
// Getting the body param
// Getting the body param
ReleaseData
releaseData
;
ReleaseData
releaseData
=
{}
;
try
{
try
{
nlohmann
::
json
::
parse
(
request
.
body
()).
get_to
(
releaseData
);
nlohmann
::
json
::
parse
(
request
.
body
()).
get_to
(
releaseData
);
...
@@ -66,7 +66,7 @@ void IndividualPDUSessionHSMFApi::update_pdu_session_handler(const Pistache::Res
...
@@ -66,7 +66,7 @@ void IndividualPDUSessionHSMFApi::update_pdu_session_handler(const Pistache::Res
// Getting the body param
// Getting the body param
HsmfUpdateData
hsmfUpdateData
;
HsmfUpdateData
hsmfUpdateData
=
{}
;
try
{
try
{
nlohmann
::
json
::
parse
(
request
.
body
()).
get_to
(
hsmfUpdateData
);
nlohmann
::
json
::
parse
(
request
.
body
()).
get_to
(
hsmfUpdateData
);
...
...
src/api-server/api/IndividualSMContextApi.cpp
View file @
8b0a2b23
...
@@ -79,10 +79,12 @@ void IndividualSMContextApi::release_sm_context_handler(const Pistache::Rest::Re
...
@@ -79,10 +79,12 @@ void IndividualSMContextApi::release_sm_context_handler(const Pistache::Rest::Re
//TODO: to be updated as update_sm_context_handler
//TODO: to be updated as update_sm_context_handler
Logger
::
smf_api_server
().
info
(
"Received a Nsmf_PDUSession_UpdateSMContext: PDU Session Release request from AMF"
);
Logger
::
smf_api_server
().
info
(
"Received a Nsmf_PDUSession_UpdateSMContext: PDU Session Release 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
());
SmContextReleaseMessage
smContextReleaseMessage
;
SmContextReleaseMessage
smContextReleaseMessage
=
{}
;
// Getting the path params
//find boundary
auto
smContextRef
=
request
.
param
(
":smContextRef"
).
as
<
std
::
string
>
();
std
::
size_t
found
=
request
.
body
().
find
(
"Content-Type"
);
std
::
string
boundary_str
=
request
.
body
().
substr
(
2
,
found
-
4
);
Logger
::
smf_api_server
().
debug
(
"Boundary: %s"
,
boundary_str
.
c_str
());
//step 1. use multipartparser to decode the request
//step 1. use multipartparser to decode the request
multipartparser_callbacks_init
(
&
g_callbacks
);
multipartparser_callbacks_init
(
&
g_callbacks
);
...
@@ -95,33 +97,53 @@ void IndividualSMContextApi::release_sm_context_handler(const Pistache::Rest::Re
...
@@ -95,33 +97,53 @@ void IndividualSMContextApi::release_sm_context_handler(const Pistache::Rest::Re
g_callbacks
.
on_part_end
=
&
on_part_end
;
g_callbacks
.
on_part_end
=
&
on_part_end
;
g_callbacks
.
on_body_end
=
&
on_body_end
;
g_callbacks
.
on_body_end
=
&
on_body_end
;
multipartparser
parser
;
multipartparser
parser
=
{}
;
init_globals
();
init_globals
();
multipartparser_init
(
&
parser
,
BOUNDARY
);
multipartparser_init
(
&
parser
,
reinterpret_cast
<
const
char
*>
(
boundary_str
.
c_str
()));
if
((
multipartparser_execute
(
&
parser
,
&
g_callbacks
,
request
.
body
().
c_str
(),
strlen
(
request
.
body
().
c_str
()))
!=
strlen
(
request
.
body
().
c_str
()))
or
(
!
g_body_begin_called
)){
response
.
send
(
Pistache
::
Http
::
Code
::
Bad_Request
,
""
);
return
;
}
//at least 2 parts for Json data and N1/N2
unsigned
int
str_len
=
request
.
body
().
length
();
if
(
g_parts
.
size
()
<
2
){
unsigned
char
*
data
=
(
unsigned
char
*
)
malloc
(
str_len
+
1
);
response
.
send
(
Pistache
::
Http
::
Code
::
Bad_Request
,
""
);
memset
(
data
,
0
,
str_len
+
1
);
return
;
memcpy
((
void
*
)
data
,
(
void
*
)
request
.
body
().
c_str
(),
str_len
);
//if ((multipartparser_execute(&parser, &g_callbacks, request.body().c_str(), strlen(request.body().c_str())) != strlen(request.body().c_str())) or (!g_body_begin_called)){
if
((
multipartparser_execute
(
&
parser
,
&
g_callbacks
,
reinterpret_cast
<
const
char
*>
(
data
),
str_len
)
!=
strlen
(
request
.
body
().
c_str
()))
or
(
!
g_body_begin_called
)){
Logger
::
smf_api_server
().
warn
(
"The received message can not be parsed properly!"
);
//TODO: fix this issue
//response.send(Pistache::Http::Code::Bad_Request, "");
//return;
}
}
free
(
data
);
data
=
nullptr
;
uint8_t
size
=
g_parts
.
size
();
Logger
::
smf_api_server
().
debug
(
"Number of g_parts %d"
,
g_parts
.
size
());
part
p0
=
g_parts
.
front
();
g_parts
.
pop_front
();
part
p0
=
g_parts
.
front
();
g_parts
.
pop_front
();
Logger
::
smf_api_server
().
debug
(
"Request body, part 1:
\n
%s"
,
p0
.
body
.
c_str
());
Logger
::
smf_api_server
().
debug
(
"Request body, part 1: %s"
,
p0
.
body
.
c_str
());
part
p1
=
g_parts
.
front
();
g_parts
.
pop_front
();
part
p1
=
{};
Logger
::
smf_api_server
().
debug
(
"Request body, part 2:
\n
%s"
,
p1
.
body
.
c_str
());
if
(
size
>
1
){
p1
=
g_parts
.
front
();
g_parts
.
pop_front
();
Logger
::
smf_api_server
().
debug
(
"Request body, part 2: %s (%d bytes)"
,
p1
.
body
.
c_str
(),
p1
.
body
.
length
());
//part p2 = g_parts.front(); g_parts.pop_front();
//part p2 = g_parts.front(); g_parts.pop_front();
//Logger::smf_api_server().debug("Request body, part 3: \n %s",p2.body.c_str());
//Logger::smf_api_server().debug("Request body, part 3: \n %s",p2.body.c_str());
}
// Getting the body param
// Getting the body param
SmContextReleaseData
smContextReleaseData
;
SmContextReleaseData
smContextReleaseData
=
{}
;
try
{
try
{
nlohmann
::
json
::
parse
(
p0
.
body
.
c_str
()).
get_to
(
smContextReleaseData
);
nlohmann
::
json
::
parse
(
p0
.
body
.
c_str
()).
get_to
(
smContextReleaseData
);
smContextReleaseMessage
.
setJsonData
(
smContextReleaseData
);
smContextReleaseMessage
.
setJsonData
(
smContextReleaseData
);
smContextReleaseMessage
.
setBinaryDataN2SmInformation
(
p1
.
body
.
c_str
());
if
(
size
>
1
){
if
(
smContextReleaseData
.
n2SmInfoIsSet
()){
//N2 SM (for Session establishment, or for session modification)
Logger
::
smf_api_server
().
debug
(
"N2 SM information is set"
);
smContextReleaseMessage
.
setBinaryDataN2SmInformation
(
p1
.
body
);
}
}
// Getting the path params
auto
smContextRef
=
request
.
param
(
":smContextRef"
).
as
<
std
::
string
>
();
this
->
release_sm_context
(
smContextRef
,
smContextReleaseMessage
,
response
);
this
->
release_sm_context
(
smContextRef
,
smContextReleaseMessage
,
response
);
}
catch
(
nlohmann
::
detail
::
exception
&
e
)
{
}
catch
(
nlohmann
::
detail
::
exception
&
e
)
{
...
@@ -141,7 +163,7 @@ void IndividualSMContextApi::retrieve_sm_context_handler(const Pistache::Rest::R
...
@@ -141,7 +163,7 @@ void IndividualSMContextApi::retrieve_sm_context_handler(const Pistache::Rest::R
// Getting the body param
// Getting the body param
SmContextRetrieveData
smContextRetrieveData
;
SmContextRetrieveData
smContextRetrieveData
=
{}
;
try
{
try
{
nlohmann
::
json
::
parse
(
request
.
body
()).
get_to
(
smContextRetrieveData
);
nlohmann
::
json
::
parse
(
request
.
body
()).
get_to
(
smContextRetrieveData
);
...
@@ -167,7 +189,7 @@ void IndividualSMContextApi::update_sm_context_handler(const Pistache::Rest::Req
...
@@ -167,7 +189,7 @@ void IndividualSMContextApi::update_sm_context_handler(const Pistache::Rest::Req
std
::
string
boundary_str
=
request
.
body
().
substr
(
2
,
found
-
4
);
std
::
string
boundary_str
=
request
.
body
().
substr
(
2
,
found
-
4
);
Logger
::
smf_api_server
().
debug
(
"Boundary: %s"
,
boundary_str
.
c_str
());
Logger
::
smf_api_server
().
debug
(
"Boundary: %s"
,
boundary_str
.
c_str
());
SmContextUpdateMessage
smContextUpdateMessage
;
SmContextUpdateMessage
smContextUpdateMessage
=
{}
;
//step 1. use multipartparser to decode the request
//step 1. use multipartparser to decode the request
multipartparser_callbacks_init
(
&
g_callbacks
);
multipartparser_callbacks_init
(
&
g_callbacks
);
...
@@ -180,7 +202,7 @@ void IndividualSMContextApi::update_sm_context_handler(const Pistache::Rest::Req
...
@@ -180,7 +202,7 @@ void IndividualSMContextApi::update_sm_context_handler(const Pistache::Rest::Req
g_callbacks
.
on_part_end
=
&
on_part_end
;
g_callbacks
.
on_part_end
=
&
on_part_end
;
g_callbacks
.
on_body_end
=
&
on_body_end
;
g_callbacks
.
on_body_end
=
&
on_body_end
;
multipartparser
parser
;
multipartparser
parser
=
{}
;
init_globals
();
init_globals
();
multipartparser_init
(
&
parser
,
reinterpret_cast
<
const
char
*>
(
boundary_str
.
c_str
()));
multipartparser_init
(
&
parser
,
reinterpret_cast
<
const
char
*>
(
boundary_str
.
c_str
()));
...
@@ -214,7 +236,7 @@ void IndividualSMContextApi::update_sm_context_handler(const Pistache::Rest::Req
...
@@ -214,7 +236,7 @@ void IndividualSMContextApi::update_sm_context_handler(const Pistache::Rest::Req
}
}
// Getting the body param
// Getting the body param
SmContextUpdateData
smContextUpdateData
;
SmContextUpdateData
smContextUpdateData
=
{}
;
try
{
try
{
nlohmann
::
json
::
parse
(
p0
.
body
.
c_str
()).
get_to
(
smContextUpdateData
);
nlohmann
::
json
::
parse
(
p0
.
body
.
c_str
()).
get_to
(
smContextUpdateData
);
smContextUpdateMessage
.
setJsonData
(
smContextUpdateData
);
smContextUpdateMessage
.
setJsonData
(
smContextUpdateData
);
...
...
src/api-server/api/SMContextsCollectionApi.cpp
View file @
8b0a2b23
...
@@ -80,8 +80,8 @@ void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Req
...
@@ -80,8 +80,8 @@ void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Req
std
::
string
boundary_str
=
request
.
body
().
substr
(
2
,
found
-
4
);
std
::
string
boundary_str
=
request
.
body
().
substr
(
2
,
found
-
4
);
Logger
::
smf_api_server
().
debug
(
"Boundary: %s"
,
boundary_str
.
c_str
());
Logger
::
smf_api_server
().
debug
(
"Boundary: %s"
,
boundary_str
.
c_str
());
SmContextMessage
smContextMessage
;
SmContextMessage
smContextMessage
=
{}
;
SmContextCreateData
smContextCreateData
;
SmContextCreateData
smContextCreateData
=
{}
;
//step 1. use multipartparser to decode the request
//step 1. use multipartparser to decode the request
multipartparser_callbacks_init
(
&
g_callbacks
);
multipartparser_callbacks_init
(
&
g_callbacks
);
...
@@ -94,7 +94,7 @@ void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Req
...
@@ -94,7 +94,7 @@ void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Req
g_callbacks
.
on_part_end
=
&
on_part_end
;
g_callbacks
.
on_part_end
=
&
on_part_end
;
g_callbacks
.
on_body_end
=
&
on_body_end
;
g_callbacks
.
on_body_end
=
&
on_body_end
;
multipartparser
parser
;
multipartparser
parser
=
{}
;
init_globals
();
init_globals
();
multipartparser_init
(
&
parser
,
reinterpret_cast
<
const
char
*>
(
boundary_str
.
c_str
()));
multipartparser_init
(
&
parser
,
reinterpret_cast
<
const
char
*>
(
boundary_str
.
c_str
()));
if
((
multipartparser_execute
(
&
parser
,
&
g_callbacks
,
request
.
body
().
c_str
(),
strlen
(
request
.
body
().
c_str
()))
!=
strlen
(
request
.
body
().
c_str
()))
or
(
!
g_body_begin_called
)){
if
((
multipartparser_execute
(
&
parser
,
&
g_callbacks
,
request
.
body
().
c_str
(),
strlen
(
request
.
body
().
c_str
()))
!=
strlen
(
request
.
body
().
c_str
()))
or
(
!
g_body_begin_called
)){
...
...
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