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
f92c1a86
Commit
f92c1a86
authored
Mar 08, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support PDU Session IPv4v6(IPv6 address allocation)
parent
a44e42db
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
22 deletions
+70
-22
src/common/utils/string.cpp
src/common/utils/string.cpp
+23
-2
src/common/utils/string.hpp
src/common/utils/string.hpp
+3
-0
src/smf_app/smf_app.cpp
src/smf_app/smf_app.cpp
+8
-8
src/smf_app/smf_context.cpp
src/smf_app/smf_context.cpp
+6
-4
src/smf_app/smf_n1.cpp
src/smf_app/smf_n1.cpp
+28
-7
src/smf_app/smf_paa_dynamic.hpp
src/smf_app/smf_paa_dynamic.hpp
+1
-0
src/smf_app/smf_procedure.cpp
src/smf_app/smf_procedure.cpp
+1
-1
No files found.
src/common/utils/string.cpp
View file @
f92c1a86
...
...
@@ -94,13 +94,34 @@ void util::ipv4_to_bstring(struct in_addr ipv4_address, bstring str) {
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 = bfromcstralloc(4, "\0");
str
->
slen
=
4
;
memcpy
(
str
->
data
,
bitstream_addr
,
sizeof
(
bitstream_addr
));
}
void
util
::
ipv6_to_bstring
(
struct
in6_addr
ipv6_address
,
bstring
str
)
{
unsigned
char
bitstream_addr
[
8
];
for
(
int
i
=
0
;
i
<=
7
;
i
++
)
bitstream_addr
[
i
]
=
(
uint8_t
)(
ipv6_address
.
s6_addr16
[
i
]);
str
->
slen
=
8
;
memcpy
(
str
->
data
,
bitstream_addr
,
sizeof
(
bitstream_addr
));
}
void
util
::
ipv4v6_to_bstring
(
struct
in_addr
ipv4_address
,
struct
in6_addr
ipv6_address
,
bstring
str
)
{
unsigned
char
bitstream_addr
[
12
];
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
);
for
(
int
i
=
0
;
i
<=
7
;
i
++
)
bitstream_addr
[
i
+
4
]
=
(
uint8_t
)(
ipv6_address
.
s6_addr16
[
i
]);
str
->
slen
=
12
;
memcpy
(
str
->
data
,
bitstream_addr
,
sizeof
(
bitstream_addr
));
}
void
util
::
string_to_bstring
(
const
std
::
string
&
str
,
bstring
bstr
)
{
// bstr = bfromcstralloc(str.length(), "\0");
// bstr = bfromcstralloc(str.length(), "\0");
bstr
->
slen
=
str
.
length
();
memcpy
((
void
*
)
bstr
->
data
,
(
void
*
)
str
.
c_str
(),
str
.
length
());
}
src/common/utils/string.hpp
View file @
f92c1a86
...
...
@@ -46,6 +46,9 @@ std::string& rtrim(std::string& s);
std
::
string
&
trim
(
std
::
string
&
s
);
void
ipv4_to_bstring
(
struct
in_addr
ipv4_address
,
bstring
str
);
void
ipv6_to_bstring
(
struct
in6_addr
ipv6_address
,
bstring
str
);
void
ipv4v6_to_bstring
(
struct
in_addr
ipv4_address
,
struct
in6_addr
ipv6_address
,
bstring
str
);
void
string_to_bstring
(
const
std
::
string
&
str
,
bstring
bstr
);
}
// namespace util
...
...
src/smf_app/smf_app.cpp
View file @
f92c1a86
...
...
@@ -30,6 +30,7 @@
#include "smf_app.hpp"
#include <boost/uuid/random_generator.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <cstdlib>
#include <iostream>
...
...
@@ -1642,21 +1643,20 @@ bool smf_app::get_session_management_subscription_data(
Logger
::
smf_app
().
debug
(
"Default session type %s"
,
smf_cfg
.
session_management_subscription
[
i
].
session_type
.
c_str
());
if
(
smf_cfg
.
session_management_subscription
[
i
].
session_type
.
compare
(
"IPV4"
)
==
0
)
{
std
::
string
session_type
=
smf_cfg
.
session_management_subscription
[
i
].
session_type
;
if
(
boost
::
iequals
(
session_type
,
"IPv4"
))
{
pdu_session_type
.
pdu_session_type
=
pdu_session_type_e
::
PDU_SESSION_TYPE_E_IPV4
;
}
else
if
(
smf_cfg
.
session_management_subscription
[
i
].
session_type
.
compare
(
"IPV6"
)
==
0
)
{
}
else
if
(
boost
::
iequals
(
session_type
,
"IPv6"
))
{
pdu_session_type
.
pdu_session_type
=
pdu_session_type_e
::
PDU_SESSION_TYPE_E_IPV6
;
}
else
if
(
smf_cfg
.
session_management_subscription
[
i
].
session_type
.
compare
(
"IPV4V6"
)
==
0
)
{
}
else
if
(
boost
::
iequals
(
session_type
,
"IPv4v6"
))
{
pdu_session_type
.
pdu_session_type
=
pdu_session_type_e
::
PDU_SESSION_TYPE_E_IPV4V6
;
}
dnn_configuration
->
pdu_session_types
.
default_session_type
=
pdu_session_type
;
...
...
src/smf_app/smf_context.cpp
View file @
f92c1a86
...
...
@@ -1580,7 +1580,7 @@ void smf_context::handle_pdu_session_create_sm_context_request(
if
(
sm_context_resp
->
res
.
get_cause
()
!=
static_cast
<
uint8_t
>
(
cause_value_5gsm_e
::
CAUSE_255_REQUEST_ACCEPTED
))
{
// clear pco, ambr
// TODO:
// free paa
paa_t
free_paa
=
{};
free_paa
=
sm_context_resp
->
res
.
get_paa
();
...
...
@@ -1588,10 +1588,12 @@ void smf_context::handle_pdu_session_create_sm_context_request(
switch
(
sp
->
pdu_session_type
.
pdu_session_type
)
{
case
PDU_SESSION_TYPE_E_IPV4
:
case
PDU_SESSION_TYPE_E_IPV4V6
:
paa_dynamic
::
get_instance
().
release_paa
(
sd
->
dnn_in_use
,
free_paa
.
ipv4_address
);
break
;
//
paa_dynamic::get_instance().release_paa(
//
sd->dnn_in_use, free_paa.ipv4_address);
//
break;
case
PDU_SESSION_TYPE_E_IPV6
:
paa_dynamic
::
get_instance
().
release_paa
(
sd
->
dnn_in_use
,
free_paa
);
break
;
case
PDU_SESSION_TYPE_E_UNSTRUCTURED
:
case
PDU_SESSION_TYPE_E_ETHERNET
:
case
PDU_SESSION_TYPE_E_RESERVED
:
...
...
src/smf_app/smf_n1.cpp
View file @
f92c1a86
...
...
@@ -160,15 +160,36 @@ bool smf_n1::create_n1_pdu_session_establishment_accept(
// PDUAddress
paa_t
paa
=
sm_context_res
.
get_paa
();
sm_msg
->
pdu_session_establishment_accept
.
pduaddress
.
pdu_address_information
=
bfromcstralloc
(
4
,
"
\0
"
);
util
::
ipv4_to_bstring
(
paa
.
ipv4_address
,
sm_msg
->
pdu_session_establishment_accept
.
pduaddress
.
pdu_address_information
);
Logger
::
smf_n1
().
debug
(
"PDU Session Type %s"
,
paa
.
pdu_session_type
.
toString
().
c_str
());
sm_msg
->
pdu_session_establishment_accept
.
pduaddress
.
pdu_session_type_value
=
static_cast
<
uint8_t
>
(
paa
.
pdu_session_type
.
pdu_session_type
);
Logger
::
smf_n1
().
debug
(
"UE Address %s"
,
conv
::
toString
(
paa
.
ipv4_address
).
c_str
());
if
(
paa
.
pdu_session_type
.
pdu_session_type
==
PDU_SESSION_TYPE_E_IPV4
)
{
sm_msg
->
pdu_session_establishment_accept
.
pduaddress
.
pdu_address_information
=
bfromcstralloc
(
4
,
"
\0
"
);
util
::
ipv4_to_bstring
(
paa
.
ipv4_address
,
sm_msg
->
pdu_session_establishment_accept
.
pduaddress
.
pdu_address_information
);
Logger
::
smf_n1
().
debug
(
"UE IPv4 Address %s"
,
conv
::
toString
(
paa
.
ipv4_address
).
c_str
());
}
else
if
(
paa
.
pdu_session_type
.
pdu_session_type
==
PDU_SESSION_TYPE_E_IPV4V6
)
{
sm_msg
->
pdu_session_establishment_accept
.
pduaddress
.
pdu_address_information
=
bfromcstralloc
(
12
,
"
\0
"
);
util
::
ipv4v6_to_bstring
(
paa
.
ipv4_address
,
paa
.
ipv6_address
,
sm_msg
->
pdu_session_establishment_accept
.
pduaddress
.
pdu_address_information
);
Logger
::
smf_n1
().
debug
(
"UE IPv4 Address %s"
,
conv
::
toString
(
paa
.
ipv4_address
).
c_str
());
char
str_addr6
[
INET6_ADDRSTRLEN
];
if
(
inet_ntop
(
AF_INET6
,
&
paa
.
ipv6_address
,
str_addr6
,
sizeof
(
str_addr6
)))
{
Logger
::
smf_n1
().
debug
(
"UE IPv6 Address: %s"
,
str_addr6
);
}
}
else
if
(
paa
.
pdu_session_type
.
pdu_session_type
==
PDU_SESSION_TYPE_E_IPV6
)
{
// TODO:
Logger
::
smf_n1
().
debug
(
"IPv6 is not fully supported yet!"
);
}
// TODO: GPRSTimer
// sm_msg->pdu_session_establishment_accept.gprstimer.unit =
...
...
src/smf_app/smf_paa_dynamic.hpp
View file @
f92c1a86
...
...
@@ -290,6 +290,7 @@ class paa_dynamic {
return
false
;
}
else
if
(
paa
.
pdu_session_type
.
pdu_session_type
==
PDU_SESSION_TYPE_E_IPV6
)
{
Logger
::
smf_app
().
debug
(
"IPv6 is not fully supported yet!"
);
return
true
;
}
}
...
...
src/smf_app/smf_procedure.cpp
View file @
f92c1a86
...
...
@@ -408,7 +408,7 @@ void session_create_sm_context_procedure::handle_itti_msg(
// TODO: Support IPv4 only for now
if
(
n11_triggered_pending
->
res
.
get_pdu_session_type
()
==
PDU_SESSION_TYPE_E_IPV
4V
6
)
{
PDU_SESSION_TYPE_E_IPV6
)
{
n11_triggered_pending
->
res
.
set_pdu_session_type
(
PDU_SESSION_TYPE_E_IPV4
);
cause_n1
=
cause_value_5gsm_e
::
CAUSE_50_PDU_SESSION_TYPE_IPV4_ONLY_ALLOWED
;
...
...
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