Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AMF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
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-AMF
Commits
129bc937
Commit
129bc937
authored
Jun 05, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support FQDN for NRF
parent
99a5200c
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
209 additions
and
70 deletions
+209
-70
etc/amf.conf
etc/amf.conf
+4
-2
src/amf-app/amf_config.cpp
src/amf-app/amf_config.cpp
+89
-57
src/amf-app/amf_config.hpp
src/amf-app/amf_config.hpp
+3
-0
src/amf-app/amf_n11.cpp
src/amf-app/amf_n11.cpp
+8
-11
src/utils/CMakeLists.txt
src/utils/CMakeLists.txt
+1
-0
src/utils/fqdn.cpp
src/utils/fqdn.cpp
+59
-0
src/utils/fqdn.hpp
src/utils/fqdn.hpp
+45
-0
No files found.
etc/amf.conf
View file @
129bc937
...
@@ -86,6 +86,7 @@ AMF =
...
@@ -86,6 +86,7 @@ AMF =
IPV4_ADDRESS
=
"@NRF_IPV4_ADDRESS@"
;
# YOUR NRF CONFIG HERE
IPV4_ADDRESS
=
"@NRF_IPV4_ADDRESS@"
;
# YOUR NRF CONFIG HERE
PORT
= @
NRF_PORT
@;
# YOUR NRF CONFIG HERE (default: 80)
PORT
= @
NRF_PORT
@;
# YOUR NRF CONFIG HERE (default: 80)
API_VERSION
=
"@NRF_API_VERSION@"
;
# YOUR NRF API VERSION FOR SBI CONFIG HERE
API_VERSION
=
"@NRF_API_VERSION@"
;
# YOUR NRF API VERSION FOR SBI CONFIG HERE
FQDN
=
"@NRF_FQDN@"
};
};
AUSF
:
AUSF
:
...
@@ -104,6 +105,7 @@ AMF =
...
@@ -104,6 +105,7 @@ AMF =
SMF_SELECTION
=
"@SMF_SELECTION@"
;
# Set to yes to enable SMF discovery and selection
SMF_SELECTION
=
"@SMF_SELECTION@"
;
# Set to yes to enable SMF discovery and selection
EXTERNAL_AUSF
=
"no"
;
# Set to yes if AMF works with an external AUSF
EXTERNAL_AUSF
=
"no"
;
# Set to yes if AMF works with an external AUSF
EXTERNAL_UDM
=
"no"
;
# Set to yes if AMF works with an external UDM
EXTERNAL_UDM
=
"no"
;
# Set to yes if AMF works with an external UDM
USE_FQDN_DNS
=
"no"
;
# Set to yes if AMF relies on a DNS to resolve SMF/UDM/NRF/UPF's FQDN
}
}
AUTHENTICATION
:
AUTHENTICATION
:
...
...
src/amf-app/amf_config.cpp
View file @
129bc937
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include "logger.hpp"
#include "logger.hpp"
#include "string.hpp"
#include "string.hpp"
#include "thread_sched.hpp"
#include "thread_sched.hpp"
#include "fqdn.hpp"
extern
"C"
{
extern
"C"
{
#include <arpa/inet.h>
#include <arpa/inet.h>
...
@@ -79,6 +80,7 @@ amf_config::amf_config() {
...
@@ -79,6 +80,7 @@ amf_config::amf_config() {
enable_smf_selection
=
false
;
enable_smf_selection
=
false
;
enable_external_ausf
=
false
;
enable_external_ausf
=
false
;
enable_external_udm
=
false
;
enable_external_udm
=
false
;
use_fqdn_dns
=
false
;
struct
{
struct
{
struct
in_addr
ipv4_addr
;
struct
in_addr
ipv4_addr
;
...
@@ -211,6 +213,56 @@ int amf_config::load(const std::string& config_file) {
...
@@ -211,6 +213,56 @@ int amf_config::load(const std::string& config_file) {
Logger
::
amf_app
().
error
(
Logger
::
amf_app
().
error
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
}
}
try
{
const
Setting
&
support_features
=
amf_cfg
[
AMF_CONFIG_STRING_SUPPORT_FEATURES
];
string
opt
;
support_features
.
lookupValue
(
AMF_CONFIG_STRING_SUPPORT_FEATURES_NF_REGISTRATION
,
opt
);
if
(
boost
::
iequals
(
opt
,
"yes"
))
{
enable_nf_registration
=
true
;
}
else
{
enable_nf_registration
=
false
;
}
support_features
.
lookupValue
(
AMF_CONFIG_STRING_SUPPORT_FEATURES_SMF_SELECTION
,
opt
);
if
(
boost
::
iequals
(
opt
,
"yes"
))
{
enable_smf_selection
=
true
;
}
else
{
enable_smf_selection
=
false
;
}
support_features
.
lookupValue
(
AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AUSF
,
opt
);
if
(
boost
::
iequals
(
opt
,
"yes"
))
{
enable_external_ausf
=
true
;
}
else
{
enable_external_ausf
=
false
;
}
support_features
.
lookupValue
(
AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_UDM
,
opt
);
if
(
boost
::
iequals
(
opt
,
"yes"
))
{
enable_external_udm
=
true
;
}
else
{
enable_external_udm
=
false
;
}
support_features
.
lookupValue
(
AMF_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
::
amf_app
().
error
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
return
-
1
;
}
try
{
try
{
const
Setting
&
new_if_cfg
=
amf_cfg
[
AMF_CONFIG_STRING_INTERFACES
];
const
Setting
&
new_if_cfg
=
amf_cfg
[
AMF_CONFIG_STRING_INTERFACES
];
const
Setting
&
n2_amf_cfg
=
const
Setting
&
n2_amf_cfg
=
...
@@ -253,6 +305,7 @@ int amf_config::load(const std::string& config_file) {
...
@@ -253,6 +305,7 @@ int amf_config::load(const std::string& config_file) {
unsigned
int
nrf_port
=
0
;
unsigned
int
nrf_port
=
0
;
std
::
string
nrf_api_version
;
std
::
string
nrf_api_version
;
string
address
;
string
address
;
if
(
!
use_fqdn_dns
)
{
nrf_cfg
.
lookupValue
(
AMF_CONFIG_STRING_NRF_IPV4_ADDRESS
,
address
);
nrf_cfg
.
lookupValue
(
AMF_CONFIG_STRING_NRF_IPV4_ADDRESS
,
address
);
IPV4_STR_ADDR_TO_INADDR
(
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
address
).
c_str
(),
nrf_ipv4_addr
,
util
::
trim
(
address
).
c_str
(),
nrf_ipv4_addr
,
...
@@ -270,7 +323,27 @@ int amf_config::load(const std::string& config_file) {
...
@@ -270,7 +323,27 @@ int amf_config::load(const std::string& config_file) {
throw
(
AMF_CONFIG_STRING_API_VERSION
"failed"
);
throw
(
AMF_CONFIG_STRING_API_VERSION
"failed"
);
}
}
nrf_addr
.
api_version
=
nrf_api_version
;
nrf_addr
.
api_version
=
nrf_api_version
;
}
else
{
std
::
string
nrf_fqdn
=
{};
nrf_cfg
.
lookupValue
(
AMF_CONFIG_STRING_FQDN_DNS
,
nrf_fqdn
);
uint8_t
addr_type
=
0
;
fqdn
::
resolve
(
nrf_fqdn
,
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
}
// AUSF
// AUSF
const
Setting
&
ausf_cfg
=
new_if_cfg
[
AMF_CONFIG_STRING_AUSF
];
const
Setting
&
ausf_cfg
=
new_if_cfg
[
AMF_CONFIG_STRING_AUSF
];
struct
in_addr
ausf_ipv4_addr
;
struct
in_addr
ausf_ipv4_addr
;
...
@@ -364,47 +437,6 @@ int amf_config::load(const std::string& config_file) {
...
@@ -364,47 +437,6 @@ int amf_config::load(const std::string& config_file) {
return
-
1
;
return
-
1
;
}
}
try
{
const
Setting
&
support_features
=
amf_cfg
[
AMF_CONFIG_STRING_SUPPORT_FEATURES
];
string
opt
;
support_features
.
lookupValue
(
AMF_CONFIG_STRING_SUPPORT_FEATURES_NF_REGISTRATION
,
opt
);
if
(
boost
::
iequals
(
opt
,
"yes"
))
{
enable_nf_registration
=
true
;
}
else
{
enable_nf_registration
=
false
;
}
support_features
.
lookupValue
(
AMF_CONFIG_STRING_SUPPORT_FEATURES_SMF_SELECTION
,
opt
);
if
(
boost
::
iequals
(
opt
,
"yes"
))
{
enable_smf_selection
=
true
;
}
else
{
enable_smf_selection
=
false
;
}
support_features
.
lookupValue
(
AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AUSF
,
opt
);
if
(
boost
::
iequals
(
opt
,
"yes"
))
{
enable_external_ausf
=
true
;
}
else
{
enable_external_ausf
=
false
;
}
support_features
.
lookupValue
(
AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_UDM
,
opt
);
if
(
boost
::
iequals
(
opt
,
"yes"
))
{
enable_external_udm
=
true
;
}
else
{
enable_external_udm
=
false
;
}
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
amf_app
().
error
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
return
-
1
;
}
return
1
;
return
1
;
}
}
...
...
src/amf-app/amf_config.hpp
View file @
129bc937
...
@@ -104,6 +104,8 @@
...
@@ -104,6 +104,8 @@
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_SMF_SELECTION "SMF_SELECTION"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_SMF_SELECTION "SMF_SELECTION"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AUSF "EXTERNAL_AUSF"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AUSF "EXTERNAL_AUSF"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_UDM "EXTERNAL_UDM"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_UDM "EXTERNAL_UDM"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS "USE_FQDN_DNS"
#define AMF_CONFIG_STRING_FQDN_DNS "FQDN"
using
namespace
libconfig
;
using
namespace
libconfig
;
...
@@ -196,6 +198,7 @@ class amf_config {
...
@@ -196,6 +198,7 @@ class amf_config {
bool
enable_smf_selection
;
bool
enable_smf_selection
;
bool
enable_external_ausf
;
bool
enable_external_ausf
;
bool
enable_external_udm
;
bool
enable_external_udm
;
bool
use_fqdn_dns
;
struct
{
struct
{
struct
in_addr
ipv4_addr
;
struct
in_addr
ipv4_addr
;
...
...
src/amf-app/amf_n11.cpp
View file @
129bc937
...
@@ -127,17 +127,13 @@ void amf_n11_task(void*) {
...
@@ -127,17 +127,13 @@ void amf_n11_task(void*) {
dynamic_cast
<
itti_pdu_session_resource_setup_response
*>
(
msg
);
dynamic_cast
<
itti_pdu_session_resource_setup_response
*>
(
msg
);
amf_n11_inst
->
handle_itti_message
(
ref
(
*
m
));
amf_n11_inst
->
handle_itti_message
(
ref
(
*
m
));
}
break
;
}
break
;
/*
case
N11_REGISTER_NF_INSTANCE_REQUEST
:
{
case
N11_REGISTER_NF_INSTANCE_REQUEST
:
{
Logger
::
amf_n11
().
info
(
Logger
::
amf_n11
().
info
(
"Receive PDU Session Resource Setup Response, handling
"Receive Register NF Instance Request, handling ..."
);
...");
itti_n11_register_nf_instance_request* m =
itti_n11_register_nf_instance_request
*
m
=
dynamic_cast
<
itti_n11_register_nf_instance_request
*>
(
msg
);
dynamic_cast
<
itti_n11_register_nf_instance_request
*>
(
msg
);
amf_n11_inst->register_nf_instance(
// TODO: Handle ITTI
std::static_pointer_cast<itti_n11_register_nf_instance_request>(
shared_msg));
}
break
;
}
break
;
*/
default:
{
default:
{
Logger
::
amf_n11
().
info
(
Logger
::
amf_n11
().
info
(
...
@@ -863,6 +859,7 @@ void amf_n11::register_nf_instance(
...
@@ -863,6 +859,7 @@ void amf_n11::register_nf_instance(
curl_easy_setopt
(
curl
,
CURLOPT_HTTPGET
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_HTTPGET
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
NRF_CURL_TIMEOUT_MS
);
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
NRF_CURL_TIMEOUT_MS
);
curl_easy_setopt
(
curl
,
CURLOPT_INTERFACE
,
amf_cfg
.
n11
.
if_name
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_INTERFACE
,
amf_cfg
.
n11
.
if_name
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_CUSTOMREQUEST
,
"PUT"
);
// Response information.
// Response information.
long
httpCode
=
{
0
};
long
httpCode
=
{
0
};
...
...
src/utils/CMakeLists.txt
View file @
129bc937
...
@@ -35,5 +35,6 @@ add_library (AMF_UTILS STATIC
...
@@ -35,5 +35,6 @@ add_library (AMF_UTILS STATIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/string.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/string.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/thread_sched.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/thread_sched.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/mime_parser.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/mime_parser.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/fqdn.cpp
)
)
src/utils/fqdn.cpp
0 → 100644
View file @
129bc937
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* 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
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "fqdn.hpp"
#include "logger.hpp"
#include <boost/asio.hpp>
#include <iostream>
bool
fqdn
::
resolve
(
const
std
::
string
&
host_name
,
std
::
string
&
address
,
uint32_t
&
port
,
uint8_t
&
addr_type
,
const
std
::
string
&
protocol
)
{
try
{
boost
::
asio
::
io_context
io_context
=
{};
boost
::
asio
::
ip
::
tcp
::
resolver
resolver
{
io_context
};
boost
::
asio
::
ip
::
tcp
::
resolver
::
results_type
endpoints
=
resolver
.
resolve
(
host_name
,
protocol
);
addr_type
=
0
;
// IPv4 by default
for
(
auto
it
=
endpoints
.
cbegin
();
it
!=
endpoints
.
cend
();
it
++
)
{
// get the first Endpoint
boost
::
asio
::
ip
::
tcp
::
endpoint
endpoint
=
*
it
;
address
=
endpoint
.
address
().
to_string
();
port
=
endpoint
.
port
();
Logger
::
amf_app
().
debug
(
"Resolve a DNS (name %s, protocol %s): Ip Addr %s, port %u"
,
host_name
.
c_str
(),
protocol
.
c_str
(),
address
.
c_str
(),
port
);
if
(
endpoint
.
address
().
is_v4
())
addr_type
=
0
;
else
addr_type
=
1
;
return
true
;
}
}
catch
(
std
::
exception
&
e
)
{
throw
std
::
runtime_error
(
"Cannot resolve a DNS name "
+
std
::
string
(
e
.
what
()));
return
false
;
}
return
false
;
}
src/utils/fqdn.hpp
0 → 100644
View file @
129bc937
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* 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
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file fqdn.hpp
\brief
\author
\company Eurecom
\email:
*/
#ifndef FILE_FQDN_HPP_SEEN
#define FILE_FQDN_HPP_SEEN
#include <string>
class
fqdn
{
public:
/*
* Resolve a DNS name to get host's IP Addr
* @param [const std::string &] host_name: host's name/url
* @param [const std::string &] protocol: protocol
* @param [uint8_t &] addr_type: addr_type (Ipv4/v6)
* @return void
*/
static
bool
resolve
(
const
std
::
string
&
host_name
,
std
::
string
&
address
,
uint32_t
&
port
,
uint8_t
&
addr_type
,
const
std
::
string
&
protocol
=
"http"
);
};
#endif
/* FILE_FQDN_HPP_SEEN */
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