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-Simple
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
CommunityXG
OpenXG-SMF-Simple
Commits
539e6168
Commit
539e6168
authored
Dec 15, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add convert ipv4 to bstring
parent
58be070c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
27 deletions
+53
-27
src/common/utils/CMakeLists.txt
src/common/utils/CMakeLists.txt
+1
-0
src/common/utils/conversions.hpp
src/common/utils/conversions.hpp
+1
-0
src/common/utils/string.cpp
src/common/utils/string.cpp
+37
-26
src/common/utils/string.hpp
src/common/utils/string.hpp
+9
-0
src/smf_app/smf_n1.cpp
src/smf_app/smf_n1.cpp
+5
-1
No files found.
src/common/utils/CMakeLists.txt
View file @
539e6168
...
...
@@ -22,6 +22,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories
(
${
SRC_TOP_DIR
}
/common
)
include_directories
(
${
SRC_TOP_DIR
}
/common/msg
)
include_directories
(
${
SRC_TOP_DIR
}
/common/utils
)
include_directories
(
${
SRC_TOP_DIR
}
/common/utils/bstr
)
include_directories
(
${
SRC_TOP_DIR
}
/itti
)
include_directories
(
${
SRC_TOP_DIR
}
/../build/ext/spdlog/include
)
...
...
src/common/utils/conversions.hpp
View file @
539e6168
...
...
@@ -32,6 +32,7 @@
#include <string>
#include <netinet/in.h>
/* Used to format an uint32_t containing an ipv4 address */
#define IN_ADDR_FMT "%u.%u.%u.%u"
#define PRI_IN_ADDR(aDDRESS) \
...
...
src/common/utils/string.cpp
View file @
539e6168
...
...
@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
file
*
except in compliance with the License.
*
You may obtain a copy of the
License at
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*
file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
...
...
@@ -20,13 +20,13 @@
*/
#include "string.hpp"
#include <stdarg.h>
#include <algorithm>
#include <functional>
#include <cctype>
#include <functional>
#include <locale>
#include <stdarg.h>
template
<
class
T
>
template
<
class
T
>
class
Buffer
{
public:
explicit
Buffer
(
size_t
size
)
{
...
...
@@ -34,12 +34,10 @@ class Buffer {
mbuf
=
new
T
[
msize
];
}
~
Buffer
()
{
if
(
mbuf
)
delete
[]
mbuf
;
}
T
*
get
()
{
return
mbuf
;
if
(
mbuf
)
delete
[]
mbuf
;
}
T
*
get
()
{
return
mbuf
;
}
private:
Buffer
();
size_t
msize
;
...
...
@@ -50,7 +48,7 @@ std::string util::string_format(const char *format, ...) {
va_list
args
;
va_start
(
args
,
format
);
size_t
size
=
vsnprintf
(
NULL
,
0
,
format
,
args
)
+
1
;
// Extra space for '\0'
size_t
size
=
vsnprintf
(
NULL
,
0
,
format
,
args
)
+
1
;
// Extra space for '\0'
va_end
(
args
);
Buffer
<
char
>
buf
(
size
);
...
...
@@ -63,28 +61,41 @@ std::string util::string_format(const char *format, ...) {
}
// Licence : https://creativecommons.org/licenses/by-sa/4.0/legalcode
//https://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring#217605
//
https://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring#217605
// trim from start
std
::
string
&
util
::
ltrim
(
std
::
string
&
s
)
{
s
.
erase
(
s
.
begin
(),
std
::
find_if
(
s
.
begin
(),
s
.
end
(),
std
::
not1
(
std
::
ptr_fun
<
int
,
int
>
(
std
::
isspace
))));
std
::
string
&
util
::
ltrim
(
std
::
string
&
s
)
{
s
.
erase
(
s
.
begin
(),
std
::
find_if
(
s
.
begin
(),
s
.
end
(),
std
::
not1
(
std
::
ptr_fun
<
int
,
int
>
(
std
::
isspace
))));
return
s
;
}
// trim from end
std
::
string
&
util
::
rtrim
(
std
::
string
&
s
)
{
s
.
erase
(
std
::
find_if
(
s
.
rbegin
(),
s
.
rend
(),
std
::
not1
(
std
::
ptr_fun
<
int
,
int
>
(
std
::
isspace
)))
.
base
(),
s
.
end
());
std
::
string
&
util
::
rtrim
(
std
::
string
&
s
)
{
s
.
erase
(
std
::
find_if
(
s
.
rbegin
(),
s
.
rend
(),
std
::
not1
(
std
::
ptr_fun
<
int
,
int
>
(
std
::
isspace
)))
.
base
(),
s
.
end
());
return
s
;
}
// trim from both ends
std
::
string
&
util
::
trim
(
std
::
string
&
s
)
{
return
util
::
ltrim
(
util
::
rtrim
(
s
));
}
std
::
string
&
util
::
trim
(
std
::
string
&
s
)
{
return
util
::
ltrim
(
util
::
rtrim
(
s
));
}
void
util
::
ipv4_to_bstring
(
struct
in_addr
ipv4_address
,
bstring
str
)
{
unsigned
char
bitstream_addr
[
4
];
bitstream_addr
[
0
]
=
(
uint8_t
)((
ipv4_address
.
s_addr
)
&
0x000000ff
);
bitstream_addr
[
1
]
=
(
uint8_t
)(((
ipv4_address
.
s_addr
)
&
0x0000ff00
)
>>
8
);
bitstream_addr
[
2
]
=
(
uint8_t
)(((
ipv4_address
.
s_addr
)
&
0x00ff0000
)
>>
16
);
bitstream_addr
[
3
]
=
(
uint8_t
)(((
ipv4_address
.
s_addr
)
&
0xff000000
)
>>
24
);
str
=
bfromcstralloc
(
4
,
"
\0
"
);
str
->
slen
=
4
;
memcpy
(
str
->
data
,
bitstream_addr
,
sizeof
(
bitstream_addr
));
}
src/common/utils/string.hpp
View file @
539e6168
...
...
@@ -29,6 +29,12 @@
#define FILE_STRING_HPP_FILE_SEEN
#include <string>
#include <arpa/inet.h>
extern
"C"
{
# include "bstrlib.h"
}
namespace
util
{
...
...
@@ -39,5 +45,8 @@ std::string& ltrim(std::string &s);
std
::
string
&
rtrim
(
std
::
string
&
s
);
// trim from both ends
std
::
string
&
trim
(
std
::
string
&
s
);
void
ipv4_to_bstring
(
struct
in_addr
ipv4_address
,
bstring
str
);
}
#endif
src/smf_app/smf_n1.cpp
View file @
539e6168
...
...
@@ -169,7 +169,7 @@ bool smf_n1::create_n1_pdu_session_establishment_accept(
// PDUAddress
paa_t
paa
=
sm_context_res
.
get_paa
();
unsigned
char
bitStream_pdu_address_information
[
4
];
/*
unsigned char bitStream_pdu_address_information[4];
bitStream_pdu_address_information[0] =
(uint8_t)((paa.ipv4_address.s_addr) & 0x000000ff);
bitStream_pdu_address_information[1] =
...
...
@@ -188,6 +188,10 @@ bool smf_n1::create_n1_pdu_session_establishment_accept(
.pdu_address_information->data,
bitStream_pdu_address_information,
sizeof(bitStream_pdu_address_information));
*/
util
::
ipv4_to_bstring
(
paa
.
ipv4_address
,
sm_msg
->
pdu_session_establishment_accept
.
pduaddress
.
pdu_address_information
);
sm_msg
->
pdu_session_establishment_accept
.
pduaddress
.
pdu_session_type_value
=
static_cast
<
uint8_t
>
(
PDU_SESSION_TYPE_E_IPV4
);
...
...
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