Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AUSF
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-AUSF
Commits
332b9505
Commit
332b9505
authored
Aug 25, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add FQDN support
parent
6898d6bc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
23 deletions
+76
-23
src/ausf_app/ausf_config.cpp
src/ausf_app/ausf_config.cpp
+69
-23
src/ausf_app/ausf_config.hpp
src/ausf_app/ausf_config.hpp
+7
-0
No files found.
src/ausf_app/ausf_config.cpp
View file @
332b9505
...
...
@@ -34,6 +34,7 @@
#include "logger.hpp"
#include "if.hpp"
#include "fqdn.hpp"
#include "string.hpp"
...
...
@@ -59,6 +60,8 @@ ausf_config::ausf_config() : sbi(), ausf_name(), pid_dir(), instance() {
udm_addr
.
ipv4_addr
.
s_addr
=
INADDR_ANY
;
udm_addr
.
port
=
80
;
udm_addr
.
api_version
=
"v1"
;
udm_addr
.
fqdn
=
{};
use_fqdn_dns
=
false
;
}
//------------------------------------------------------------------------------
...
...
@@ -90,7 +93,7 @@ int ausf_config::load(const std::string& config_file) {
const
Setting
&
ausf_cfg
=
root
[
AUSF_CONFIG_STRING_AUSF_CONFIG
];
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
config
().
error
(
"%s : %s"
,
nfex
.
what
(),
nfex
.
getPath
());
return
-
1
;
return
RETURNerror
;
}
const
Setting
&
ausf_cfg
=
root
[
AUSF_CONFIG_STRING_AUSF_CONFIG
];
try
{
...
...
@@ -112,6 +115,7 @@ int ausf_config::load(const std::string& config_file) {
Logger
::
config
().
error
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
}
// AUSF SBI interface
try
{
const
Setting
&
new_if_cfg
=
ausf_cfg
[
AUSF_CONFIG_STRING_INTERFACES
];
...
...
@@ -121,17 +125,39 @@ int ausf_config::load(const std::string& config_file) {
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
config
().
error
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
return
-
1
;
return
RETURNerror
;
}
// Support features
try
{
std
::
string
astring
;
const
Setting
&
support_features
=
ausf_cfg
[
AUSF_CONFIG_STRING_SUPPORT_FEATURES
];
std
::
string
opt
=
{};
support_features
.
lookupValue
(
AUSF_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
::
ausf_app
().
error
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
return
RETURNerror
;
}
// UDM
try
{
std
::
string
astring
=
{};
const
Setting
&
udm_cfg
=
ausf_cfg
[
AUSF_CONFIG_STRING_UDM
];
struct
in_addr
udm_ipv4_addr
;
struct
in_addr
udm_ipv4_addr
=
{}
;
unsigned
int
udm_port
=
0
;
std
::
string
udm_api_version
;
std
::
string
udm_api_version
=
{};
if
(
!
use_fqdn_dns
)
{
udm_cfg
.
lookupValue
(
AUSF_CONFIG_STRING_UDM_IPV4_ADDRESS
,
astring
);
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
astring
).
c_str
(),
udm_ipv4_addr
,
...
...
@@ -150,10 +176,30 @@ int ausf_config::load(const std::string& config_file) {
}
udm_addr
.
api_version
=
udm_api_version
;
}
else
{
udm_cfg
.
lookupValue
(
AUSF_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!"
);
}
else
{
// IPv4
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
address
).
c_str
(),
udm_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR NRF !"
);
udm_addr
.
ipv4_addr
=
udm_ipv4_addr
;
udm_addr
.
port
=
udm_port
;
udm_addr
.
api_version
=
"v1"
;
// TODO: to get API version from DNS
udm_addr
.
fqdn
=
astring
;
}
}
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
ausf_app
().
error
(
"%s : %s"
,
nfex
.
what
(),
nfex
.
getPath
());
return
RETURNerror
;
}
return
RETURNok
;
}
...
...
src/ausf_app/ausf_config.hpp
View file @
332b9505
...
...
@@ -60,6 +60,10 @@
#define AUSF_CONFIG_STRING_UDM_IPV4_ADDRESS "IPV4_ADDRESS"
#define AUSF_CONFIG_STRING_UDM_PORT "PORT"
#define AUSF_CONFIG_STRING_SUPPORT_FEATURES "SUPPORT_FEATURES"
#define AUSF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS "USE_FQDN_DNS"
#define AUSF_CONFIG_STRING_FQDN_DNS "FQDN"
using
namespace
libconfig
;
namespace
config
{
...
...
@@ -91,7 +95,10 @@ class ausf_config {
struct
in_addr
ipv4_addr
;
unsigned
int
port
;
std
::
string
api_version
;
std
::
string
fqdn
;
}
udm_addr
;
bool
use_fqdn_dns
;
};
}
// namespace config
...
...
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