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
3314affb
Commit
3314affb
authored
Aug 22, 2022
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Free bstring after using
parent
4b0b2e1b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
40 deletions
+47
-40
src/amf-app/amf_sbi.cpp
src/amf-app/amf_sbi.cpp
+7
-4
src/common/conversions.cpp
src/common/conversions.cpp
+3
-3
src/sbi/amf_server/amf-http2-server.cpp
src/sbi/amf_server/amf-http2-server.cpp
+13
-12
src/sbi/amf_server/impl/N1N2MessageCollectionDocumentApiImpl.cpp
.../amf_server/impl/N1N2MessageCollectionDocumentApiImpl.cpp
+15
-13
src/sctp/sctp_server.cpp
src/sctp/sctp_server.cpp
+9
-8
No files found.
src/amf-app/amf_sbi.cpp
View file @
3314affb
...
...
@@ -1117,7 +1117,8 @@ void amf_sbi::curl_http_client(
std
::
string
n1sm
=
{};
std
::
string
n2sm
=
{};
nlohmann
::
json
response_data
=
{};
bstring
n1sm_hex
,
n2sm_hex
;
bstring
n1sm_hex
=
nullptr
;
bstring
n2sm_hex
=
nullptr
;
Logger
::
amf_sbi
().
info
(
"Get response with HTTP code (%d)"
,
httpCode
);
Logger
::
amf_sbi
().
info
(
"Response body %s"
,
response
.
c_str
());
...
...
@@ -1257,6 +1258,7 @@ void amf_sbi::curl_http_client(
curl_easy_cleanup
(
curl
);
curl_global_cleanup
();
free_wrapper
((
void
**
)
&
body_data
);
bdestroy_wrapper
(
&
n1sm_hex
);
return
;
}
...
...
@@ -1274,7 +1276,7 @@ void amf_sbi::curl_http_client(
comUt
::
print_buffer
(
"amf_sbi"
,
"Get response n1sm:"
,
(
uint8_t
*
)
bdata
(
n1sm_hex
),
blength
(
n1sm_hex
));
itti_msg
->
n1sm
=
n1sm_hex
;
itti_msg
->
n1sm
=
bstrcpy
(
n1sm_hex
)
;
itti_msg
->
is_n1sm_set
=
true
;
}
if
(
n2sm
.
size
()
>
0
)
{
...
...
@@ -1282,7 +1284,7 @@ void amf_sbi::curl_http_client(
comUt
::
print_buffer
(
"amf_sbi"
,
"Get response n2sm:"
,
(
uint8_t
*
)
bdata
(
n2sm_hex
),
blength
(
n2sm_hex
));
itti_msg
->
n2sm
=
n2sm_hex
;
itti_msg
->
n2sm
=
bstrcpy
(
n2sm_hex
)
;
itti_msg
->
is_n2sm_set
=
true
;
itti_msg
->
n2sm_info_type
=
response_data
[
"n2SmInfoType"
];
// response_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapIeType"];
...
...
@@ -1301,6 +1303,8 @@ void amf_sbi::curl_http_client(
}
}
bdestroy_wrapper
(
&
n1sm_hex
);
bdestroy_wrapper
(
&
n2sm_hex
);
curl_slist_free_all
(
headers
);
curl_easy_cleanup
(
curl
);
}
...
...
@@ -1400,7 +1404,6 @@ void amf_sbi::curl_http_client(
std
::
string
n1sm
=
{};
std
::
string
n2sm
=
{};
nlohmann
::
json
response_data
=
{};
bstring
n1sm_hex
,
n2sm_hex
;
// clear input
n1sm_msg
=
{};
...
...
src/common/conversions.cpp
View file @
3314affb
...
...
@@ -195,11 +195,9 @@ unsigned char* conv::format_string_as_hex(std::string str) {
unsigned
char
*
data
=
(
unsigned
char
*
)
malloc
(
str_len
+
1
);
memset
(
data
,
0
,
str_len
+
1
);
memcpy
((
void
*
)
data
,
(
void
*
)
str
.
c_str
(),
str_len
);
std
::
cout
<<
"Data: "
<<
data
<<
" ("
<<
str_len
<<
" bytes)"
<<
std
::
endl
;
std
::
cout
<<
"Data (formatted):
\n
"
;
for
(
int
i
=
0
;
i
<
str_len
;
i
++
)
{
char
datatmp
[
3
]
=
{
0
};
...
...
@@ -240,7 +238,7 @@ char* conv::bstring2charString(bstring b) {
//------------------------------------------------------------------------------
void
conv
::
msg_str_2_msg_hex
(
std
::
string
msg
,
bstring
&
b
)
{
std
::
string
msg_hex_str
;
std
::
string
msg_hex_str
=
{}
;
convert_string_2_hex
(
msg
,
msg_hex_str
);
printf
(
"tmp string: %s
\n
"
,
msg_hex_str
.
c_str
());
unsigned
int
msg_len
=
msg_hex_str
.
length
();
...
...
@@ -251,6 +249,8 @@ void conv::msg_str_2_msg_hex(std::string msg, bstring& b) {
uint8_t
*
msg_hex
=
(
uint8_t
*
)
malloc
(
msg_len
/
2
+
1
);
conv
::
ascii_to_hex
(
msg_hex
,
(
const
char
*
)
data
);
b
=
blk2bstr
(
msg_hex
,
(
msg_len
/
2
));
free_wrapper
((
void
**
)
&
data
);
free_wrapper
((
void
**
)
&
msg_hex
);
}
//------------------------------------------------------------------------------
...
...
src/sbi/amf_server/amf-http2-server.cpp
View file @
3314affb
...
...
@@ -177,29 +177,29 @@ void amf_http2_server::n1_n2_message_transfer_handler(
return
;
}
bstring
n1sm
;
bstring
n1sm
=
nullptr
;
conv
::
msg_str_2_msg_hex
(
n1sm_str
.
substr
(
0
,
n1sm_str
.
length
()),
n1sm
);
// TODO: verify n1sm_length
bstring
n2sm
;
bstring
n2sm
=
nullptr
;
if
(
!
n2sm_str
.
empty
())
{
conv
::
msg_str_2_msg_hex
(
n2sm_str
,
n2sm
);
psc
->
n2sm
=
n2sm
;
psc
->
n2sm
=
bstrcpy
(
n2sm
)
;
psc
->
is_n2sm_avaliable
=
true
;
}
else
{
psc
->
is_n2sm_avaliable
=
false
;
}
psc
->
n1sm
=
n1sm
;
psc
->
n1sm
=
bstrcpy
(
n1sm
)
;
psc
->
is_n1sm_avaliable
=
true
;
itti_n1n2_message_transfer_request
*
itti_msg
=
new
itti_n1n2_message_transfer_request
(
AMF_SERVER
,
TASK_AMF_APP
);
auto
itti_msg
=
std
::
make_shared
<
itti_n1n2_message_transfer_request
>
(
AMF_SERVER
,
TASK_AMF_APP
);
itti_msg
->
supi
=
ueContextId
;
itti_msg
->
n1sm
=
n1sm
;
itti_msg
->
n1sm
=
bstrcpy
(
n1sm
)
;
itti_msg
->
is_n1sm_set
=
true
;
if
(
!
n2sm_str
.
empty
())
{
itti_msg
->
n2sm
=
n2sm
;
itti_msg
->
n2sm
=
bstrcpy
(
n2sm
)
;
itti_msg
->
is_n2sm_set
=
true
;
}
else
{
itti_msg
->
is_n2sm_set
=
false
;
...
...
@@ -230,14 +230,15 @@ void amf_http2_server::n1_n2_message_transfer_handler(
res
.
end
(
response_json
.
dump
().
c_str
());
// Process N1N2 Message Transfer Request
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
);
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
if
(
0
!=
ret
)
{
Logger
::
amf_server
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
i
tti_msg
->
get_msg_name
());
}
bdestroy_wrapper
(
&
n1sm
);
bdestroy_wrapper
(
&
n2sm
);
}
//------------------------------------------------------------------------------
...
...
src/sbi/amf_server/impl/N1N2MessageCollectionDocumentApiImpl.cpp
View file @
3314affb
...
...
@@ -54,7 +54,7 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
Logger
::
amf_server
().
debug
(
"Receive N1N2MessageTransfer Request, handling..."
);
bstring
n1sm
;
bstring
n1sm
=
nullptr
;
conv
::
msg_str_2_msg_hex
(
n1sm_str
,
n1sm
);
comUt
::
print_buffer
(
"amf_server"
,
"Received N1 SM"
,
(
uint8_t
*
)
bdata
(
n1sm
),
blength
(
n1sm
));
...
...
@@ -62,6 +62,7 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
Pistache
::
Http
::
Code
::
Ok
,
"N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer API has "
"not been implemented yet!"
);
bdestroy_wrapper
(
&
n1sm
);
}
void
N1N2MessageCollectionDocumentApiImpl
::
n1_n2_message_transfer
(
...
...
@@ -88,25 +89,25 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
"Cannot get pdu_session_context with SUPI (%s)"
,
supi
.
c_str
());
}
bstring
n1sm
;
bstring
n1sm
=
nullptr
;
conv
::
msg_str_2_msg_hex
(
n1sm_str
.
substr
(
0
,
n1sm_str
.
length
()),
n1sm
);
// TODO: verify n1sm_length
bstring
n2sm
;
bstring
n2sm
=
nullptr
;
conv
::
msg_str_2_msg_hex
(
n2sm_str
,
n2sm
);
psc
->
n1sm
=
n1sm
;
psc
->
n1sm
=
bstrcpy
(
n1sm
)
;
psc
->
is_n1sm_avaliable
=
true
;
psc
->
n2sm
=
n2sm
;
psc
->
n2sm
=
bstrcpy
(
n2sm
)
;
psc
->
is_n2sm_avaliable
=
true
;
Logger
::
amf_server
().
debug
(
"n2sm size in amf_server(%d)"
,
blength
(
psc
->
n2sm
));
itti_n1n2_message_transfer_request
*
itti_msg
=
new
itti_n1n2_message_transfer_request
(
AMF_SERVER
,
TASK_AMF_APP
);
auto
itti_msg
=
std
::
make_shared
<
itti_n1n2_message_transfer_request
>
(
AMF_SERVER
,
TASK_AMF_APP
);
itti_msg
->
supi
=
ueContextId
;
itti_msg
->
n1sm
=
n1sm
;
itti_msg
->
n1sm
=
bstrcpy
(
n1sm
)
;
itti_msg
->
is_n1sm_set
=
true
;
itti_msg
->
n2sm
=
n2sm
;
itti_msg
->
n2sm
=
bstrcpy
(
n2sm
)
;
itti_msg
->
is_n2sm_set
=
true
;
itti_msg
->
pdu_session_id
=
(
uint8_t
)
n1N2MessageTransferReqData
.
getPduSessionId
();
...
...
@@ -131,14 +132,15 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
response
.
send
(
code
,
response_json
.
dump
().
c_str
());
// Process N1N2 Message Transfer Request
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
);
int
ret
=
itti_inst
->
send_msg
(
itti_msg
);
if
(
0
!=
ret
)
{
Logger
::
amf_server
().
error
(
"Could not send ITTI message %s to task TASK_AMF_N2"
,
i
->
get_msg_name
());
i
tti_msg
->
get_msg_name
());
}
bdestroy_wrapper
(
&
n1sm
);
bdestroy_wrapper
(
&
n2sm
);
}
}
// namespace api
...
...
src/sctp/sctp_server.cpp
View file @
3314affb
...
...
@@ -207,12 +207,13 @@ int sctp_server::sctp_read_from_socket(int sd, uint32_t ppid) {
sinfo
.
sinfo_assoc_id
,
sd
,
n
,
ntohs
(
addr
.
sin6_port
),
sinfo
.
sinfo_stream
,
ntohl
(
sinfo
.
sinfo_ppid
));
bstring
payload
=
blk2bstr
(
buffer
,
n
);
//
h
andle payload
//
H
andle payload
app_
->
handle_receive
(
payload
,
(
sctp_assoc_id_t
)
sinfo
.
sinfo_assoc_id
,
sinfo
.
sinfo_stream
,
association
->
instreams
,
association
->
outstreams
);
bdestroy_wrapper
(
&
payload
);
}
return
0
;
return
RETURNok
;
}
//------------------------------------------------------------------------------
...
...
@@ -223,7 +224,7 @@ int sctp_server::sctp_handle_com_down(sctp_assoc_id_t assoc_id) {
//------------------------------------------------------------------------------
int
sctp_server
::
sctp_handle_reset
(
const
sctp_assoc_id_t
assoc_id
)
{
return
0
;
return
RETURNok
;
}
//------------------------------------------------------------------------------
...
...
@@ -343,7 +344,7 @@ int sctp_server::sctp_get_peeraddresses(
}
else
{
sctp_freepaddrs
((
struct
sockaddr
*
)
temp_addr_p
);
}
return
0
;
return
RETURNok
;
}
//------------------------------------------------------------------------------
...
...
@@ -388,7 +389,7 @@ int sctp_server::sctp_get_localaddresses(
sctp_freeladdrs
((
struct
sockaddr
*
)
temp_addr_p
);
}
}
return
0
;
return
RETURNok
;
}
//------------------------------------------------------------------------------
...
...
@@ -420,14 +421,14 @@ int sctp_server::sctp_send_msg(
"[Socket %d] Send stream %u, ppid %u, len %u failed (%s, %d)"
,
assoc_desc
->
sd
,
stream
,
htonl
(
assoc_desc
->
ppid
),
blength
(
*
payload
),
strerror
(
errno
),
errno
);
*
payload
=
NULL
;
//
*payload = NULL;
return
RETURNerror
;
}
Logger
::
sctp
().
debug
(
"Successfully sent %d bytes on stream %d"
,
blength
(
*
payload
),
stream
);
*
payload
=
NULL
;
//
*payload = NULL;
assoc_desc
->
messages_sent
++
;
return
0
;
return
RETURNok
;
}
}
// namespace sctp
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