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
284aa70e
Commit
284aa70e
authored
Jun 05, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support FQDN Resolver
parent
036ddedb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
193 additions
and
51 deletions
+193
-51
src/smf_app/smf_app.hpp
src/smf_app/smf_app.hpp
+4
-3
src/smf_app/smf_config.cpp
src/smf_app/smf_config.cpp
+184
-48
src/smf_app/smf_config.hpp
src/smf_app/smf_config.hpp
+5
-0
No files found.
src/smf_app/smf_app.hpp
View file @
284aa70e
...
...
@@ -81,10 +81,10 @@ class smf_context_ref {
void
clear
()
{
supi
=
{};
nssai
=
{};
dnn
=
""
;
dnn
=
{}
;
pdu_session_id
=
0
;
amf_status_uri
=
""
;
amf_addr
=
""
;
amf_status_uri
=
{}
;
amf_addr
=
{}
;
upf_node_id
=
{};
}
...
...
@@ -214,6 +214,7 @@ class smf_app {
void
operator
=
(
smf_app
const
&
)
=
delete
;
void
test_dns
();
/*
* Set the association between Seid and SM Context
* @param [const seid_t &] seid: SessionID
...
...
src/smf_app/smf_config.cpp
View file @
284aa70e
...
...
@@ -49,6 +49,7 @@
#include "epc.h"
#include "if.hpp"
#include "logger.hpp"
#include "fqdn.hpp"
#include "smf_app.hpp"
using
namespace
std
;
...
...
@@ -580,6 +581,14 @@ int smf_config::load(const string& config_file) {
force_push_pco
=
false
;
}
support_features
.
lookupValue
(
SMF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS
,
opt
);
if
(
boost
::
iequals
(
opt
,
"yes"
))
{
use_fqdn_dns
=
true
;
}
else
{
use_fqdn_dns
=
false
;
}
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
smf_app
().
error
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
...
...
@@ -589,48 +598,99 @@ int smf_config::load(const string& config_file) {
// AMF
const
Setting
&
amf_cfg
=
smf_cfg
[
SMF_CONFIG_STRING_AMF
];
struct
in_addr
amf_ipv4_addr
;
unsigned
int
amf_port
=
0
;
std
::
string
amf_api_version
;
amf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_AMF_IPV4_ADDRESS
,
astring
);
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
astring
).
c_str
(),
amf_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR AMF !"
);
amf_addr
.
ipv4_addr
=
amf_ipv4_addr
;
if
(
!
(
amf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_AMF_PORT
,
amf_port
)))
{
Logger
::
smf_app
().
error
(
SMF_CONFIG_STRING_AMF_PORT
"failed"
);
throw
(
SMF_CONFIG_STRING_AMF_PORT
"failed"
);
}
amf_addr
.
port
=
amf_port
;
unsigned
int
amf_port
=
0
;
std
::
string
amf_api_version
=
{};
if
(
!
use_fqdn_dns
)
{
amf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_AMF_IPV4_ADDRESS
,
astring
);
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
astring
).
c_str
(),
amf_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR AMF !"
);
amf_addr
.
ipv4_addr
=
amf_ipv4_addr
;
if
(
!
(
amf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_AMF_PORT
,
amf_port
)))
{
Logger
::
smf_app
().
error
(
SMF_CONFIG_STRING_AMF_PORT
"failed"
);
throw
(
SMF_CONFIG_STRING_AMF_PORT
"failed"
);
}
amf_addr
.
port
=
amf_port
;
if
(
!
(
amf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_API_VERSION
,
amf_api_version
)))
{
Logger
::
smf_app
().
error
(
SMF_CONFIG_STRING_API_VERSION
"failed"
);
throw
(
SMF_CONFIG_STRING_API_VERSION
"failed"
);
if
(
!
(
amf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_API_VERSION
,
amf_api_version
)))
{
Logger
::
smf_app
().
error
(
SMF_CONFIG_STRING_API_VERSION
"failed"
);
throw
(
SMF_CONFIG_STRING_API_VERSION
"failed"
);
}
amf_addr
.
api_version
=
amf_api_version
;
}
else
{
amf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_FQDN_DNS
,
astring
);
// astring = "maserati";
uint8_t
addr_type
=
0
;
std
::
string
address
=
{};
fqdn
::
resolve
(
astring
,
address
,
amf_port
,
addr_type
);
if
(
addr_type
!=
0
)
{
// IPv6
// TODO:
throw
(
"DO NOT SUPPORT IPV6 ADDR FOR AMF"
"failed"
);
}
else
{
// IPv4
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
address
).
c_str
(),
amf_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR AMF !"
);
amf_addr
.
ipv4_addr
=
amf_ipv4_addr
;
amf_addr
.
port
=
amf_port
;
}
// TODO: How to get API version from DNS
}
amf_addr
.
api_version
=
amf_api_version
;
// UDM
const
Setting
&
udm_cfg
=
smf_cfg
[
SMF_CONFIG_STRING_UDM
];
struct
in_addr
udm_ipv4_addr
;
unsigned
int
udm_port
=
0
;
std
::
string
udm_api_version
;
udm_cfg
.
lookupValue
(
SMF_CONFIG_STRING_UDM_IPV4_ADDRESS
,
astring
);
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
astring
).
c_str
(),
udm_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR UDM !"
);
udm_addr
.
ipv4_addr
=
udm_ipv4_addr
;
if
(
!
(
udm_cfg
.
lookupValue
(
SMF_CONFIG_STRING_UDM_PORT
,
udm_port
)))
{
Logger
::
smf_app
().
error
(
SMF_CONFIG_STRING_UDM_PORT
"failed"
);
throw
(
SMF_CONFIG_STRING_UDM_PORT
"failed"
);
}
udm_addr
.
port
=
udm_port
;
if
(
!
(
udm_cfg
.
lookupValue
(
SMF_CONFIG_STRING_API_VERSION
,
udm_api_version
)))
{
Logger
::
smf_app
().
error
(
SMF_CONFIG_STRING_API_VERSION
"failed"
);
throw
(
SMF_CONFIG_STRING_API_VERSION
"failed"
);
if
(
!
use_fqdn_dns
)
{
udm_cfg
.
lookupValue
(
SMF_CONFIG_STRING_UDM_IPV4_ADDRESS
,
astring
);
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
astring
).
c_str
(),
udm_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR UDM !"
);
udm_addr
.
ipv4_addr
=
udm_ipv4_addr
;
if
(
!
(
udm_cfg
.
lookupValue
(
SMF_CONFIG_STRING_UDM_PORT
,
udm_port
)))
{
Logger
::
smf_app
().
error
(
SMF_CONFIG_STRING_UDM_PORT
"failed"
);
throw
(
SMF_CONFIG_STRING_UDM_PORT
"failed"
);
}
udm_addr
.
port
=
udm_port
;
if
(
!
(
udm_cfg
.
lookupValue
(
SMF_CONFIG_STRING_API_VERSION
,
udm_api_version
)))
{
Logger
::
smf_app
().
error
(
SMF_CONFIG_STRING_API_VERSION
"failed"
);
throw
(
SMF_CONFIG_STRING_API_VERSION
"failed"
);
}
udm_addr
.
api_version
=
udm_api_version
;
}
else
{
udm_cfg
.
lookupValue
(
SMF_CONFIG_STRING_FQDN_DNS
,
astring
);
uint8_t
addr_type
=
0
;
std
::
string
address
=
{};
fqdn
::
resolve
(
astring
,
address
,
udm_port
,
addr_type
);
if
(
addr_type
!=
0
)
{
// IPv6
// TODO:
throw
(
"DO NOT SUPPORT IPV6 ADDR FOR UDM"
"failed"
);
}
else
{
// IPv4
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
address
).
c_str
(),
udm_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR UDM !"
);
udm_addr
.
ipv4_addr
=
udm_ipv4_addr
;
udm_addr
.
port
=
udm_port
;
}
// TODO: How to get API version from DNS
}
udm_addr
.
api_version
=
udm_api_version
;
// UPF list
unsigned
char
buf_in_addr
[
sizeof
(
struct
in_addr
)
+
1
];
...
...
@@ -638,8 +698,60 @@ int smf_config::load(const string& config_file) {
count
=
upf_list_cfg
.
getLength
();
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
const
Setting
&
upf_cfg
=
upf_list_cfg
[
i
];
// TODO FQDN
string
address
=
{};
if
(
!
use_fqdn_dns
)
{
if
(
upf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_UPF_IPV4_ADDRESS
,
address
))
{
pfcp
::
node_id_t
n
=
{};
n
.
node_id_type
=
pfcp
::
NODE_ID_TYPE_IPV4_ADDRESS
;
// actually
if
(
inet_pton
(
AF_INET
,
util
::
trim
(
address
).
c_str
(),
buf_in_addr
)
==
1
)
{
memcpy
(
&
n
.
u1
.
ipv4_address
,
buf_in_addr
,
sizeof
(
struct
in_addr
));
}
else
{
Logger
::
smf_app
().
error
(
"CONFIG: BAD IPV4 ADDRESS in "
SMF_CONFIG_STRING_UPF_LIST
" item %d"
,
i
);
throw
(
"CONFIG: BAD ADDRESS in "
SMF_CONFIG_STRING_UPF_LIST
);
}
upfs
.
push_back
(
n
);
}
}
else
{
unsigned
int
upf_port
=
0
;
upf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_FQDN_DNS
,
astring
);
uint8_t
addr_type
=
0
;
std
::
string
address
=
{};
fqdn
::
resolve
(
astring
,
address
,
upf_port
,
addr_type
,
""
);
if
(
addr_type
!=
0
)
{
// IPv6
// TODO:
throw
(
"DO NOT SUPPORT IPV6 ADDR FOR NRF"
"failed"
);
}
else
{
// IPv4
pfcp
::
node_id_t
n
=
{};
n
.
node_id_type
=
pfcp
::
NODE_ID_TYPE_IPV4_ADDRESS
;
// actually
if
(
inet_pton
(
AF_INET
,
util
::
trim
(
address
).
c_str
(),
buf_in_addr
)
==
1
)
{
memcpy
(
&
n
.
u1
.
ipv4_address
,
buf_in_addr
,
sizeof
(
struct
in_addr
));
}
else
{
Logger
::
smf_app
().
error
(
"CONFIG: BAD IPV4 ADDRESS in "
SMF_CONFIG_STRING_UPF_LIST
" item %d"
,
i
);
throw
(
"CONFIG: BAD ADDRESS in "
SMF_CONFIG_STRING_UPF_LIST
);
}
upfs
.
push_back
(
n
);
}
// TODO: How to get API version from DNS
}
if
(
upf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_UPF_IPV4_ADDRESS
,
address
))
{
pfcp
::
node_id_t
n
=
{};
n
.
node_id_type
=
pfcp
::
NODE_ID_TYPE_IPV4_ADDRESS
;
// actually
...
...
@@ -666,23 +778,47 @@ int smf_config::load(const string& config_file) {
struct
in_addr
nrf_ipv4_addr
;
unsigned
int
nrf_port
=
0
;
std
::
string
nrf_api_version
;
nrf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_NRF_IPV4_ADDRESS
,
astring
);
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
astring
).
c_str
(),
nrf_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR NRF !"
);
nrf_addr
.
ipv4_addr
=
nrf_ipv4_addr
;
if
(
!
(
nrf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_NRF_PORT
,
nrf_port
)))
{
Logger
::
smf_app
().
error
(
SMF_CONFIG_STRING_NRF_PORT
"failed"
);
throw
(
SMF_CONFIG_STRING_NRF_PORT
"failed"
);
}
nrf_addr
.
port
=
nrf_port
;
if
(
!
use_fqdn_dns
)
{
nrf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_NRF_IPV4_ADDRESS
,
astring
);
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
astring
).
c_str
(),
nrf_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR NRF !"
);
nrf_addr
.
ipv4_addr
=
nrf_ipv4_addr
;
if
(
!
(
nrf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_NRF_PORT
,
nrf_port
)))
{
Logger
::
smf_app
().
error
(
SMF_CONFIG_STRING_NRF_PORT
"failed"
);
throw
(
SMF_CONFIG_STRING_NRF_PORT
"failed"
);
}
nrf_addr
.
port
=
nrf_port
;
if
(
!
(
nrf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_API_VERSION
,
nrf_api_version
)))
{
Logger
::
smf_app
().
error
(
SMF_CONFIG_STRING_API_VERSION
"failed"
);
throw
(
SMF_CONFIG_STRING_API_VERSION
"failed"
);
if
(
!
(
nrf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_API_VERSION
,
nrf_api_version
)))
{
Logger
::
smf_app
().
error
(
SMF_CONFIG_STRING_API_VERSION
"failed"
);
throw
(
SMF_CONFIG_STRING_API_VERSION
"failed"
);
}
nrf_addr
.
api_version
=
nrf_api_version
;
}
else
{
nrf_cfg
.
lookupValue
(
SMF_CONFIG_STRING_FQDN_DNS
,
astring
);
uint8_t
addr_type
=
0
;
std
::
string
address
=
{};
fqdn
::
resolve
(
astring
,
address
,
nrf_port
,
addr_type
);
if
(
addr_type
!=
0
)
{
// IPv6
// TODO:
throw
(
"DO NOT SUPPORT IPV6 ADDR FOR NRF"
"failed"
);
}
else
{
// IPv4
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
address
).
c_str
(),
nrf_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR NRF !"
);
nrf_addr
.
ipv4_addr
=
nrf_ipv4_addr
;
nrf_addr
.
port
=
nrf_port
;
}
// TODO: How to get API version from DNS
}
nrf_addr
.
api_version
=
nrf_api_version
;
// Local configuration
num_session_management_subscription
=
0
;
...
...
src/smf_app/smf_config.hpp
View file @
284aa70e
...
...
@@ -137,6 +137,9 @@
"USE_LOCAL_SUBSCRIPTION_INFO"
#define SMF_CONFIG_STRING_NAS_FORCE_PUSH_PCO \
"FORCE_PUSH_PROTOCOL_CONFIGURATION_OPTIONS"
#define SMF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS "USE_FQDN_DNS"
#define SMF_CONFIG_STRING_FQDN_DNS "FQDN"
#define SMF_MAX_ALLOCATED_PDN_ADDRESSES 1024
...
...
@@ -217,6 +220,7 @@ class smf_config {
bool
register_nrf
;
bool
discover_upf
;
bool
use_local_subscription_info
;
bool
use_fqdn_dns
;
struct
{
struct
in_addr
ipv4_addr
;
...
...
@@ -314,6 +318,7 @@ class smf_config {
use_local_subscription_info
=
false
;
register_nrf
=
false
;
discover_upf
=
false
;
use_fqdn_dns
=
false
;
};
~
smf_config
();
void
lock
()
{
m_rw_lock
.
lock
();
};
...
...
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