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
64e521a2
Commit
64e521a2
authored
Sep 16, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get Static IP addr from UDM
parent
f61ad481
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
4 deletions
+105
-4
src/common/3gpp_29.503.h
src/common/3gpp_29.503.h
+35
-0
src/smf_app/smf_sbi.cpp
src/smf_app/smf_sbi.cpp
+69
-3
src/smf_app/smf_sbi.hpp
src/smf_app/smf_sbi.hpp
+1
-1
No files found.
src/common/3gpp_29.503.h
View file @
64e521a2
...
@@ -50,6 +50,14 @@ typedef struct ssc_mode_s {
...
@@ -50,6 +50,14 @@ typedef struct ssc_mode_s {
ssc_mode
=
ssc_mode_e
::
SSC_MODE_1
;
// default mode
ssc_mode
=
ssc_mode_e
::
SSC_MODE_1
;
// default mode
}
}
}
}
ssc_mode_s
&
operator
=
(
const
ssc_mode_s
&
s
)
{
ssc_mode
=
s
.
ssc_mode
;
return
*
this
;
}
virtual
~
ssc_mode_s
(){};
}
ssc_mode_t
;
}
ssc_mode_t
;
typedef
struct
pdu_session_types_s
{
typedef
struct
pdu_session_types_s
{
...
@@ -144,6 +152,33 @@ typedef struct ip_address_s {
...
@@ -144,6 +152,33 @@ typedef struct ip_address_s {
}
}
};
};
ip_address_s
&
operator
=
(
const
struct
in_addr
&
a
)
{
ip_address_type
=
IP_ADDRESS_TYPE_IPV4_ADDRESS
;
u1
.
ipv4_address
.
s_addr
=
a
.
s_addr
;
return
*
this
;
}
ip_address_s
&
operator
=
(
const
struct
in6_addr
&
a
)
{
ip_address_type
=
IP_ADDRESS_TYPE_IPV6_ADDRESS
;
u1
.
ipv6_address
.
s6_addr32
[
0
]
=
a
.
s6_addr32
[
0
];
u1
.
ipv6_address
.
s6_addr32
[
1
]
=
a
.
s6_addr32
[
1
];
u1
.
ipv6_address
.
s6_addr32
[
2
]
=
a
.
s6_addr32
[
2
];
u1
.
ipv6_address
.
s6_addr32
[
3
]
=
a
.
s6_addr32
[
3
];
return
*
this
;
}
ip_address_s
&
operator
=
(
const
ipv6_prefix_t
&
a
)
{
ip_address_type
=
IP_ADDRESS_TYPE_IPV6_PREFIX
;
u1
.
ipv6_prefix
.
prefix_len
=
a
.
prefix_len
;
u1
.
ipv6_prefix
.
prefix
.
s6_addr32
[
0
]
=
a
.
prefix
.
s6_addr32
[
0
];
u1
.
ipv6_prefix
.
prefix
.
s6_addr32
[
1
]
=
a
.
prefix
.
s6_addr32
[
1
];
u1
.
ipv6_prefix
.
prefix
.
s6_addr32
[
2
]
=
a
.
prefix
.
s6_addr32
[
2
];
u1
.
ipv6_prefix
.
prefix
.
s6_addr32
[
3
]
=
a
.
prefix
.
s6_addr32
[
3
];
return
*
this
;
}
virtual
~
ip_address_s
(){};
std
::
string
to_string
()
const
{
std
::
string
to_string
()
const
{
if
(
IP_ADDRESS_TYPE_IPV4_ADDRESS
==
this
->
ip_address_type
)
{
if
(
IP_ADDRESS_TYPE_IPV4_ADDRESS
==
this
->
ip_address_type
)
{
return
conv
::
toString
(
u1
.
ipv4_address
);
return
conv
::
toString
(
u1
.
ipv4_address
);
...
...
src/smf_app/smf_sbi.cpp
View file @
64e521a2
...
@@ -35,6 +35,9 @@
...
@@ -35,6 +35,9 @@
#include <pistache/http.h>
#include <pistache/http.h>
#include <pistache/mime.h>
#include <pistache/mime.h>
#include <nlohmann/json.hpp>
#include <nlohmann/json.hpp>
#include <boost/algorithm/string/split.hpp>
//#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include "common_defs.h"
#include "common_defs.h"
#include "itti.hpp"
#include "itti.hpp"
...
@@ -833,7 +836,7 @@ void smf_sbi::subscribe_upf_status_notify(
...
@@ -833,7 +836,7 @@ void smf_sbi::subscribe_upf_status_notify(
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
smf_sbi
::
get_sm_data
(
bool
smf_sbi
::
get_sm_data
(
const
supi64_t
&
supi
,
const
std
::
string
&
dnn
,
const
snssai_t
&
snssai
,
const
supi64_t
&
supi
,
const
std
::
string
&
dnn
,
const
snssai_t
&
snssai
,
std
::
shared_ptr
<
session_management_subscription
>
subscription
)
{
std
::
shared_ptr
<
session_management_subscription
>
&
subscription
)
{
nlohmann
::
json
jsonData
=
{};
nlohmann
::
json
jsonData
=
{};
std
::
string
query_str
=
{};
std
::
string
query_str
=
{};
query_str
=
"?single-nssai={
\"
sst
\"
:"
+
std
::
to_string
(
snssai
.
sST
)
+
query_str
=
"?single-nssai={
\"
sst
\"
:"
+
std
::
to_string
(
snssai
.
sST
)
+
...
@@ -950,7 +953,7 @@ bool smf_sbi::get_sm_data(
...
@@ -950,7 +953,7 @@ bool smf_sbi::get_sm_data(
}
}
}
}
// session_ambr
: Optional
// session_ambr
(Optional)
if
(
it
.
value
().
find
(
"sessionAmbr"
)
!=
it
.
value
().
end
())
{
if
(
it
.
value
().
find
(
"sessionAmbr"
)
!=
it
.
value
().
end
())
{
dnn_configuration
->
session_ambr
.
uplink
=
dnn_configuration
->
session_ambr
.
uplink
=
it
.
value
()[
"sessionAmbr"
][
"uplink"
];
it
.
value
()[
"sessionAmbr"
][
"uplink"
];
...
@@ -961,9 +964,69 @@ bool smf_sbi::get_sm_data(
...
@@ -961,9 +964,69 @@ bool smf_sbi::get_sm_data(
dnn_configuration
->
session_ambr
.
uplink
.
c_str
(),
dnn_configuration
->
session_ambr
.
uplink
.
c_str
(),
dnn_configuration
->
session_ambr
.
downlink
.
c_str
());
dnn_configuration
->
session_ambr
.
downlink
.
c_str
());
}
}
// Optional: Static IP Address
// Static IP Addresses (Optional)
if
(
it
.
value
().
find
(
"staticIpAddress"
)
!=
it
.
value
().
end
())
{
if
(
it
.
value
().
find
(
"staticIpAddress"
)
!=
it
.
value
().
end
())
{
for
(
const
auto
&
ip_addr
:
it
.
value
()[
"staticIpAddress"
])
{
for
(
const
auto
&
ip_addr
:
it
.
value
()[
"staticIpAddress"
])
{
if
(
ip_addr
.
find
(
"ipv4Addr"
)
!=
ip_addr
.
end
())
{
struct
in_addr
ue_ipv4_addr
=
{};
std
::
string
ue_ip_str
=
ip_addr
[
"ipv4Addr"
].
get
<
std
::
string
>
();
// ip_addr.at("ipv4Addr").get_to(ue_ip_str);
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
ue_ip_str
).
c_str
(),
ue_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR UE IP ADDR !"
);
ip_address_t
ue_ip
=
{};
ue_ip
=
ue_ipv4_addr
;
dnn_configuration
->
static_ip_addresses
.
push_back
(
ue_ip
);
}
else
if
(
ip_addr
.
find
(
"ipv6Addr"
)
!=
ip_addr
.
end
())
{
unsigned
char
buf_in6_addr
[
sizeof
(
struct
in6_addr
)];
struct
in6_addr
ue_ipv6_addr
;
std
::
string
ue_ip_str
=
ip_addr
[
"ipv6Addr"
].
get
<
std
::
string
>
();
if
(
inet_pton
(
AF_INET6
,
util
::
trim
(
ue_ip_str
).
c_str
(),
buf_in6_addr
)
==
1
)
{
memcpy
(
&
ue_ipv6_addr
,
buf_in6_addr
,
sizeof
(
struct
in6_addr
));
}
else
{
Logger
::
smf_app
().
error
(
"Bad UE IPv6 Addr %s"
,
ue_ip_str
.
c_str
());
throw
(
"Bad UE IPv6 Addr %s"
,
ue_ip_str
.
c_str
());
}
ip_address_t
ue_ip
=
{};
ue_ip
=
ue_ipv6_addr
;
dnn_configuration
->
static_ip_addresses
.
push_back
(
ue_ip
);
}
else
if
(
ip_addr
.
find
(
"ipv6Prefix"
)
!=
ip_addr
.
end
())
{
unsigned
char
buf_in6_addr
[
sizeof
(
struct
in6_addr
)];
struct
in6_addr
ipv6_prefix
;
std
::
string
prefix_str
=
ip_addr
[
"ipv6Prefix"
].
get
<
std
::
string
>
();
std
::
vector
<
std
::
string
>
words
=
{};
boost
::
split
(
words
,
prefix_str
,
boost
::
is_any_of
(
"/"
),
boost
::
token_compress_on
);
if
(
words
.
size
()
!=
2
)
{
Logger
::
smf_app
().
error
(
"Bad value for UE IPv6 Prefix %s"
,
prefix_str
.
c_str
());
return
RETURNerror
;
}
if
(
inet_pton
(
AF_INET6
,
util
::
trim
(
words
.
at
(
0
)).
c_str
(),
buf_in6_addr
)
==
1
)
{
memcpy
(
&
ipv6_prefix
,
buf_in6_addr
,
sizeof
(
struct
in6_addr
));
}
else
{
Logger
::
smf_app
().
error
(
"Bad UE IPv6 Addr %s"
,
words
.
at
(
0
).
c_str
());
throw
(
"Bad UE IPv6 Addr %s"
,
words
.
at
(
0
).
c_str
());
}
ip_address_t
ue_ip
=
{};
ipv6_prefix_t
ue_ipv6_prefix
=
{};
ue_ipv6_prefix
.
prefix_len
=
std
::
stoi
(
util
::
trim
(
words
.
at
(
1
)));
ue_ipv6_prefix
.
prefix
=
ipv6_prefix
;
ue_ip
=
ue_ipv6_prefix
;
dnn_configuration
->
static_ip_addresses
.
push_back
(
ue_ip
);
}
}
}
}
}
...
@@ -973,6 +1036,9 @@ bool smf_sbi::get_sm_data(
...
@@ -973,6 +1036,9 @@ bool smf_sbi::get_sm_data(
Logger
::
smf_sbi
().
warn
(
Logger
::
smf_sbi
().
warn
(
"Exception message %s, exception id %d "
,
e
.
what
(),
e
.
id
);
"Exception message %s, exception id %d "
,
e
.
what
(),
e
.
id
);
return
false
;
return
false
;
}
catch
(
std
::
exception
&
e
)
{
Logger
::
smf_sbi
().
warn
(
"Exception message %s"
,
e
.
what
());
return
false
;
}
}
}
}
return
true
;
return
true
;
...
...
src/smf_app/smf_sbi.hpp
View file @
64e521a2
...
@@ -157,7 +157,7 @@ class smf_sbi {
...
@@ -157,7 +157,7 @@ class smf_sbi {
*/
*/
bool
get_sm_data
(
bool
get_sm_data
(
const
supi64_t
&
supi
,
const
std
::
string
&
dnn
,
const
snssai_t
&
snssai
,
const
supi64_t
&
supi
,
const
std
::
string
&
dnn
,
const
snssai_t
&
snssai
,
std
::
shared_ptr
<
session_management_subscription
>
subscription
);
std
::
shared_ptr
<
session_management_subscription
>
&
subscription
);
/*
/*
* Subscribe to be notify from UDM
* Subscribe to be notify from UDM
...
...
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