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
32a2dbae
Commit
32a2dbae
authored
Feb 03, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First version with AUSF
parent
25ad7ce7
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
238 additions
and
40 deletions
+238
-40
build/scripts/generate_amf_conf.sh
build/scripts/generate_amf_conf.sh
+6
-2
etc/amf.conf
etc/amf.conf
+20
-3
src/amf-app/amf_config.cpp
src/amf-app/amf_config.cpp
+56
-21
src/amf-app/amf_config.hpp
src/amf-app/amf_config.hpp
+13
-2
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+53
-12
src/amf-app/amf_n11.cpp
src/amf-app/amf_n11.cpp
+83
-0
src/amf-app/amf_n11.hpp
src/amf-app/amf_n11.hpp
+6
-0
src/common/amf.hpp
src/common/amf.hpp
+1
-0
No files found.
build/scripts/generate_amf_conf.sh
View file @
32a2dbae
...
@@ -34,8 +34,8 @@ AMF_CONF[@SD_0@]='123'
...
@@ -34,8 +34,8 @@ AMF_CONF[@SD_0@]='123'
AMF_CONF[@SST_1@]
=
'1'
AMF_CONF[@SST_1@]
=
'1'
AMF_CONF[@SD_1@]
=
'12'
AMF_CONF[@SD_1@]
=
'12'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_NGAP@]
=
'
wlo1
'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_NGAP@]
=
'
enx0050b6f4ba5b
'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_N11@]
=
'
wlo1
'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_N11@]
=
'
enx0050b6f4ba5b
'
AMF_CONF[@SMF_INSTANCE_ID_0@]
=
'1'
AMF_CONF[@SMF_INSTANCE_ID_0@]
=
'1'
AMF_CONF[@SMF_IPV4_ADDR_0@]
=
'192.168.122.1'
AMF_CONF[@SMF_IPV4_ADDR_0@]
=
'192.168.122.1'
...
@@ -48,6 +48,10 @@ AMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.1.23'
...
@@ -48,6 +48,10 @@ AMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.1.23'
AMF_CONF[@NRF_PORT@]
=
'80'
AMF_CONF[@NRF_PORT@]
=
'80'
AMF_CONF[@NRF_API_VERSION@]
=
'v1'
AMF_CONF[@NRF_API_VERSION@]
=
'v1'
AMF_CONF[@AUSF_IPV4_ADDRESS@]
=
'192.168.1.23'
AMF_CONF[@AUSF_PORT@]
=
'80'
AMF_CONF[@AUSF_API_VERSION@]
=
'v1'
AMF_CONF[@MYSQL_SERVER@]
=
'127.0.0.1'
AMF_CONF[@MYSQL_SERVER@]
=
'127.0.0.1'
AMF_CONF[@MYSQL_USER@]
=
'root'
AMF_CONF[@MYSQL_USER@]
=
'root'
AMF_CONF[@MYSQL_PASS@]
=
'linux'
AMF_CONF[@MYSQL_PASS@]
=
'linux'
...
...
etc/amf.conf
View file @
32a2dbae
...
@@ -66,6 +66,14 @@ AMF =
...
@@ -66,6 +66,14 @@ AMF =
PPID
=
60
;
# YOUR NETWORK CONFIG HERE
PPID
=
60
;
# YOUR NETWORK CONFIG HERE
};
};
# AMF binded interface for Nausf interface
NAUSF
:
{
INTERFACE_NAME
=
"ens33"
;
# YOUR NETWORK CONFIG HERE
IPV4_ADDRESS
=
"read"
;
PORT
=
8383
;
# YOUR NETWORK CONFIG HERE
};
# AMF binded interface for N11
# AMF binded interface for N11
N11
:
N11
:
{
{
...
@@ -84,15 +92,24 @@ AMF =
...
@@ -84,15 +92,24 @@ 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
};
};
AUSF
:
{
IPV4_ADDRESS
=
"@AUSF_IPV4_ADDRESS@"
;
# YOUR AUSF CONFIG HERE
PORT
= @
AUSF_PORT
@;
# YOUR AUSF CONFIG HERE (default: 80)
API_VERSION
=
"@AUSF_API_VERSION@"
;
# YOUR AUSF API VERSION FOR SBI CONFIG HERE
};
};
};
SUPPORT_FEATURES
:
SUPPORT_FEATURES
:
{
{
#Register to NRF
#Register to NRF
NF_REGISTRATION
=
"
yes
"
;
# STRING, {"yes", "no"}, set to yes if AMF resgisters to an NRF
NF_REGISTRATION
=
"
no
"
;
# STRING, {"yes", "no"}, set to yes if AMF resgisters to an NRF
SMF_SELECTION
=
"no"
;
# STRING, {"yes", "no"}, set to yes to enable SMF discovery and selection
SMF_SELECTION
=
"no"
;
# STRING, {"yes", "no"}, set to yes to enable SMF discovery and selection
EXTERNAL_AUTH
=
"yes"
;
# STRING, {"yes", "no"}, set to yes if AMF works with an external AUSF/UDM
EXTERNAL_AUSF
=
"yes"
;
# STRING, {"yes", "no"}, set to yes if AMF works with an external AUSF
EXTERNAL_UDM
=
"no"
;
# STRING, {"yes", "no"}, set to yes if AMF works with an external UDM
}
}
AUTHENTICATION
:
AUTHENTICATION
:
...
...
src/amf-app/amf_config.cpp
View file @
32a2dbae
...
@@ -62,7 +62,8 @@ amf_config::amf_config() {
...
@@ -62,7 +62,8 @@ amf_config::amf_config() {
nrf_addr
.
api_version
=
"v1"
;
nrf_addr
.
api_version
=
"v1"
;
enable_nf_registration
=
false
;
enable_nf_registration
=
false
;
enable_smf_selection
=
false
;
enable_smf_selection
=
false
;
enable_external_auth
=
false
;
enable_external_ausf
=
false
;
enable_external_udm
=
false
;
// TODO:
// TODO:
is_Nausf
=
true
;
is_Nausf
=
true
;
}
}
...
@@ -241,6 +242,30 @@ int amf_config::load(const std::string& config_file) {
...
@@ -241,6 +242,30 @@ int amf_config::load(const std::string& config_file) {
}
}
nrf_addr
.
api_version
=
nrf_api_version
;
nrf_addr
.
api_version
=
nrf_api_version
;
// AUSF
const
Setting
&
ausf_cfg
=
new_if_cfg
[
AMF_CONFIG_STRING_AUSF
];
struct
in_addr
ausf_ipv4_addr
;
unsigned
int
ausf_port
=
0
;
std
::
string
ausf_api_version
;
//string address;
ausf_cfg
.
lookupValue
(
AMF_CONFIG_STRING_IPV4_ADDRESS
,
address
);
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
address
).
c_str
(),
ausf_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR AUSF !"
);
ausf_addr
.
ipv4_addr
=
ausf_ipv4_addr
;
if
(
!
(
ausf_cfg
.
lookupValue
(
AMF_CONFIG_STRING_PORT
,
ausf_port
)))
{
Logger
::
amf_app
().
error
(
AMF_CONFIG_STRING_PORT
"failed"
);
throw
(
AMF_CONFIG_STRING_PORT
"failed"
);
}
ausf_addr
.
port
=
ausf_port
;
if
(
!
(
ausf_cfg
.
lookupValue
(
AMF_CONFIG_STRING_API_VERSION
,
ausf_api_version
)))
{
Logger
::
amf_app
().
error
(
AMF_CONFIG_STRING_API_VERSION
"failed"
);
throw
(
AMF_CONFIG_STRING_API_VERSION
"failed"
);
}
ausf_addr
.
api_version
=
ausf_api_version
;
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
amf_app
().
error
(
Logger
::
amf_app
().
error
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
...
@@ -331,11 +356,19 @@ int amf_config::load(const std::string& config_file) {
...
@@ -331,11 +356,19 @@ int amf_config::load(const std::string& config_file) {
}
}
support_features
.
lookupValue
(
support_features
.
lookupValue
(
AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AU
TH
,
opt
);
AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AU
SF
,
opt
);
if
(
boost
::
iequals
(
opt
,
"yes"
))
{
if
(
boost
::
iequals
(
opt
,
"yes"
))
{
enable_external_au
th
=
true
;
enable_external_au
sf
=
true
;
}
else
{
}
else
{
enable_external_auth
=
false
;
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
)
{
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
...
@@ -422,24 +455,24 @@ void amf_config::display() {
...
@@ -422,24 +455,24 @@ void amf_config::display() {
" ip ....................: %s"
,
inet_ntoa
(
n11
.
addr4
));
" ip ....................: %s"
,
inet_ntoa
(
n11
.
addr4
));
Logger
::
config
().
info
(
" port ..................: %d"
,
n11
.
port
);
Logger
::
config
().
info
(
" port ..................: %d"
,
n11
.
port
);
if
(
is_Nausf
)
{
if
(
enable_nf_registration
or
enable_smf_selection
)
{
Logger
::
config
().
info
(
"- Nausf Networking:"
);
Logger
::
config
().
info
(
"- NRF:"
);
Logger
::
config
().
info
(
Logger
::
config
().
info
(
" iface ................: %s"
,
nausf
.
if_name
.
c_str
());
" IP addr ..............: %s"
,
inet_ntoa
(
nrf_addr
.
ipv4_addr
));
Logger
::
config
().
info
(
Logger
::
config
().
info
(
" Port .................: %d"
,
nrf_addr
.
port
);
" ip ...................: %s"
,
inet_ntoa
(
nausf
.
addr4
));
Logger
::
config
().
info
(
Logger
::
config
().
info
(
" port .................: %d"
,
nausf
.
port
);
" Api version ..........: %s"
,
nrf_addr
.
api_version
.
c_str
());
}
else
{
}
Logger
::
config
().
warn
(
"- Not using ausf: Please remove [--no-ausf] using it."
);
if
(
enable_external_ausf
)
{
Logger
::
config
().
info
(
"- AUSF:"
);
Logger
::
config
().
info
(
" IP addr ..............: %s"
,
inet_ntoa
(
ausf_addr
.
ipv4_addr
));
Logger
::
config
().
info
(
" Port .................: %d"
,
ausf_addr
.
port
);
Logger
::
config
().
info
(
" Api version ..........: %s"
,
ausf_addr
.
api_version
.
c_str
());
}
}
Logger
::
config
().
info
(
"- NRF:"
);
Logger
::
config
().
info
(
" IP addr ..............: %s"
,
inet_ntoa
(
nrf_addr
.
ipv4_addr
));
Logger
::
config
().
info
(
" Port .................: %d"
,
nrf_addr
.
port
);
Logger
::
config
().
info
(
" Api version ..........: %s"
,
nrf_addr
.
api_version
.
c_str
());
// Logger::config().info(" HTTP2 port ............: %d", n11_http2_port);
// Logger::config().info(" HTTP2 port ............: %d", n11_http2_port);
...
@@ -462,7 +495,9 @@ void amf_config::display() {
...
@@ -462,7 +495,9 @@ void amf_config::display() {
Logger
::
config
().
info
(
Logger
::
config
().
info
(
" SMF Selection..........: %s"
,
enable_smf_selection
?
"Yes"
:
"No"
);
" SMF Selection..........: %s"
,
enable_smf_selection
?
"Yes"
:
"No"
);
Logger
::
config
().
info
(
Logger
::
config
().
info
(
" External Authentication: %s"
,
enable_external_auth
?
"Yes"
:
"No"
);
" External AUSF..........: %s"
,
enable_external_ausf
?
"Yes"
:
"No"
);
Logger
::
config
().
info
(
" External UDM..........: %s"
,
enable_external_udm
?
"Yes"
:
"No"
);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
...
src/amf-app/amf_config.hpp
View file @
32a2dbae
...
@@ -64,6 +64,8 @@
...
@@ -64,6 +64,8 @@
#define AMF_CONFIG_STRING_NRF_PORT "PORT"
#define AMF_CONFIG_STRING_NRF_PORT "PORT"
#define AMF_CONFIG_STRING_API_VERSION "API_VERSION"
#define AMF_CONFIG_STRING_API_VERSION "API_VERSION"
#define AMF_CONFIG_STRING_AUSF "AUSF"
#define AMF_CONFIG_STRING_SCHED_PARAMS "SCHED_PARAMS"
#define AMF_CONFIG_STRING_SCHED_PARAMS "SCHED_PARAMS"
#define AMF_CONFIG_STRING_THREAD_RD_CPU_ID "CPU_ID"
#define AMF_CONFIG_STRING_THREAD_RD_CPU_ID "CPU_ID"
#define AMF_CONFIG_STRING_THREAD_RD_SCHED_POLICY "SCHED_POLICY"
#define AMF_CONFIG_STRING_THREAD_RD_SCHED_POLICY "SCHED_POLICY"
...
@@ -100,7 +102,8 @@
...
@@ -100,7 +102,8 @@
#define AMF_CONFIG_STRING_SUPPORT_FEATURES "SUPPORT_FEATURES"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES "SUPPORT_FEATURES"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_NF_REGISTRATION "NF_REGISTRATION"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_NF_REGISTRATION "NF_REGISTRATION"
#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_AUTH "EXTERNAL_AUTH"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AUSF "EXTERNAL_AUSF"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_UDM "EXTERNAL_UDM"
using
namespace
libconfig
;
using
namespace
libconfig
;
...
@@ -192,13 +195,21 @@ class amf_config {
...
@@ -192,13 +195,21 @@ class amf_config {
std
::
vector
<
smf_inst_t
>
smf_pool
;
std
::
vector
<
smf_inst_t
>
smf_pool
;
bool
enable_nf_registration
;
bool
enable_nf_registration
;
bool
enable_smf_selection
;
bool
enable_smf_selection
;
bool
enable_external_auth
;
bool
enable_external_ausf
;
bool
enable_external_udm
;
struct
{
struct
{
struct
in_addr
ipv4_addr
;
struct
in_addr
ipv4_addr
;
unsigned
int
port
;
unsigned
int
port
;
std
::
string
api_version
;
std
::
string
api_version
;
}
nrf_addr
;
}
nrf_addr
;
struct
{
struct
in_addr
ipv4_addr
;
unsigned
int
port
;
std
::
string
api_version
;
}
ausf_addr
;
bool
is_Nausf
;
bool
is_Nausf
;
}
;
}
;
...
...
src/amf-app/amf_n1.cpp
View file @
32a2dbae
...
@@ -1315,6 +1315,7 @@ void amf_n1::curl_http_client(
...
@@ -1315,6 +1315,7 @@ void amf_n1::curl_http_client(
bool
amf_n1
::
authentication_vectors_from_ausf
(
bool
amf_n1
::
authentication_vectors_from_ausf
(
std
::
shared_ptr
<
nas_context
>&
nc
)
{
std
::
shared_ptr
<
nas_context
>&
nc
)
{
Logger
::
amf_n1
().
debug
(
"authentication_vectors_from_ausf"
);
Logger
::
amf_n1
().
debug
(
"authentication_vectors_from_ausf"
);
/*
std::string ausf_ip =
std::string ausf_ip =
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.nausf.addr4)));
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.nausf.addr4)));
std::string ausf_port = std::to_string(amf_cfg.nausf.port);
std::string ausf_port = std::to_string(amf_cfg.nausf.port);
...
@@ -1322,21 +1323,21 @@ bool amf_n1::authentication_vectors_from_ausf(
...
@@ -1322,21 +1323,21 @@ bool amf_n1::authentication_vectors_from_ausf(
ausf_ip + ":" + ausf_port + "/nausf-auth/v1/ue-authentications";
ausf_ip + ":" + ausf_port + "/nausf-auth/v1/ue-authentications";
std::string msgBody;
std::string msgBody;
std::string Response;
std::string Response;
*/
nlohmann
::
json
authenticationinfo_j
;
UEAuthenticationCtx
ueauthenticationctx
;
// nlohmann::json authenticationinfo_j;
AuthenticationInfo
authenticationinfo
;
AuthenticationInfo
authenticationinfo
;
authenticationinfo
.
setSupiOrSuci
(
nc
.
get
()
->
imsi
);
authenticationinfo
.
setSupiOrSuci
(
nc
.
get
()
->
imsi
);
authenticationinfo
.
setServingNetworkName
(
nc
.
get
()
->
serving_network
);
authenticationinfo
.
setServingNetworkName
(
nc
.
get
()
->
serving_network
);
to_json
(
authenticationinfo_j
,
authenticationinfo
);
msgBody
=
authenticationinfo_j
.
dump
();
curl_http_client
(
remoteUri
,
"POST"
,
msgBody
,
Response
);
Logger
::
amf_n1
().
info
(
"POST response : %s"
,
Response
.
c_str
());
// to_json(authenticationinfo_j, authenticationinfo);
// msgBody = authenticationinfo_j.dump();
try
{
// TODO: Move to N11 (SBI)
UEAuthenticationCtx
ueauthenticationctx
;
// curl_http_client(remoteUri, "POST", msgBody, Response);
nlohmann
::
json
::
parse
(
Response
.
c_str
()).
get_to
(
ueauthenticationctx
);
if
(
amf_n11_inst
->
send_ue_authentication_request
(
authenticationinfo
,
ueauthenticationctx
,
1
))
{
unsigned
char
*
r5gauthdata_rand
=
unsigned
char
*
r5gauthdata_rand
=
format_string_as_hex
(
ueauthenticationctx
.
getR5gAuthData
().
getRand
());
format_string_as_hex
(
ueauthenticationctx
.
getR5gAuthData
().
getRand
());
memcpy
(
nc
.
get
()
->
_5g_av
[
0
].
rand
,
r5gauthdata_rand
,
16
);
memcpy
(
nc
.
get
()
->
_5g_av
[
0
].
rand
,
r5gauthdata_rand
,
16
);
...
@@ -1363,11 +1364,50 @@ bool amf_n1::authentication_vectors_from_ausf(
...
@@ -1363,11 +1364,50 @@ bool amf_n1::authentication_vectors_from_ausf(
}
else
{
}
else
{
Logger
::
amf_n1
().
error
(
"Not found 5G_AKA"
);
Logger
::
amf_n1
().
error
(
"Not found 5G_AKA"
);
}
}
}
catch
(
nlohmann
::
json
::
exception
&
e
)
{
}
else
{
Logger
::
amf_n1
().
info
(
"Could not get
Json content from AUSF response
"
);
Logger
::
amf_n1
().
info
(
"Could not get
expected response from AUSF
"
);
// TODO: error handling
// TODO: error handling
return
false
;
return
false
;
}
}
// Logger::amf_n1().info("POST response : %s", Response.c_str());
/*
try {
nlohmann::json::parse(Response.c_str()).get_to(ueauthenticationctx);
unsigned char* r5gauthdata_rand =
format_string_as_hex(ueauthenticationctx.getR5gAuthData().getRand());
memcpy(nc.get()->_5g_av[0].rand, r5gauthdata_rand, 16);
print_buffer("amf_n1", "5G AV: rand", nc.get()->_5g_av[0].rand, 16);
free_wrapper((void**) &r5gauthdata_rand);
unsigned char* r5gauthdata_autn =
format_string_as_hex(ueauthenticationctx.getR5gAuthData().getAutn());
memcpy(nc.get()->_5g_av[0].autn, r5gauthdata_autn, 16);
print_buffer("amf_n1", "5G AV: autn", nc.get()->_5g_av[0].autn, 16);
free_wrapper((void**) &r5gauthdata_autn);
unsigned char* r5gauthdata_hxresstar = format_string_as_hex(
ueauthenticationctx.getR5gAuthData().getHxresStar());
memcpy(nc.get()->_5g_av[0].hxresStar, r5gauthdata_hxresstar, 16);
print_buffer("amf_n1", "5G AV: hxres*", nc.get()->_5g_av[0].hxresStar,
16); free_wrapper((void**) &r5gauthdata_hxresstar);
std::map<std::string, LinksValueSchema>::iterator iter;
iter = ueauthenticationctx.getLinks().find("5G_AKA");
if (iter != ueauthenticationctx.getLinks().end()) {
nc.get()->Href = iter->second.getHref();
Logger::amf_n1().info("Links is: ", nc.get()->Href);
} else {
Logger::amf_n1().error("Not found 5G_AKA");
}
} catch (nlohmann::json::exception& e) {
Logger::amf_n1().info("Could not get Json content from AUSF response");
// TODO: error handling
return false;
}
*/
return
true
;
return
true
;
}
}
...
@@ -1388,8 +1428,9 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
...
@@ -1388,8 +1428,9 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
to_json
(
confirmationdata_j
,
confirmationdata
);
to_json
(
confirmationdata_j
,
confirmationdata
);
msgBody
=
confirmationdata_j
.
dump
();
msgBody
=
confirmationdata_j
.
dump
();
curl_http_client
(
remoteUri
,
"PUT"
,
msgBody
,
Response
);
// TODO: Move curl to N11(SBI)
curl_http_client
(
remoteUri
,
"PUT"
,
msgBody
,
Response
);
// free(resStar_string.c_str());
// free(resStar_string.c_str());
try
{
try
{
...
...
src/amf-app/amf_n11.cpp
View file @
32a2dbae
...
@@ -861,3 +861,86 @@ bool amf_n11::discover_smf(
...
@@ -861,3 +861,86 @@ bool amf_n11::discover_smf(
curl_global_cleanup
();
curl_global_cleanup
();
return
result
;
return
result
;
}
}
//-----------------------------------------------------------------------------------------------------
bool
amf_n11
::
send_ue_authentication_request
(
oai
::
amf
::
model
::
AuthenticationInfo
&
auth_info
,
oai
::
amf
::
model
::
UEAuthenticationCtx
&
ue_auth_ctx
,
uint8_t
http_version
)
{
Logger
::
amf_n11
().
debug
(
"Send UE Authentication Request to AUSF (HTTP version %d)"
,
http_version
);
nlohmann
::
json
json_data
=
{};
to_json
(
json_data
,
auth_info
);
std
::
string
url
=
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
amf_cfg
.
ausf_addr
.
ipv4_addr
)))
+
":"
+
std
::
to_string
(
amf_cfg
.
ausf_addr
.
port
)
+
"/nausf-auth/"
+
amf_cfg
.
ausf_addr
.
api_version
+
"ue-authentications"
;
Logger
::
amf_n11
().
debug
(
"Send UE Authentication Request to AUSF, URL %s"
,
url
.
c_str
());
std
::
string
body
=
json_data
.
dump
();
Logger
::
amf_n11
().
debug
(
"Send UE Authentication Request to AUSF, msg body:
\n
%s"
,
body
.
c_str
());
curl_global_init
(
CURL_GLOBAL_ALL
);
CURL
*
curl
=
curl
=
curl_easy_init
();
if
(
curl
)
{
CURLcode
res
=
{};
struct
curl_slist
*
headers
=
nullptr
;
// headers = curl_slist_append(headers, "charsets: utf-8");
headers
=
curl_slist_append
(
headers
,
"content-type: application/json"
);
curl_easy_setopt
(
curl
,
CURLOPT_HTTPHEADER
,
headers
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_HTTPGET
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_CUSTOMREQUEST
,
"POST"
);
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
AUSF_CURL_TIMEOUT_MS
);
if
(
http_version
==
2
)
{
curl_easy_setopt
(
curl
,
CURLOPT_VERBOSE
,
1L
);
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt
(
curl
,
CURLOPT_SSL_VERIFYPEER
,
0L
);
curl_easy_setopt
(
curl
,
CURLOPT_SSL_VERIFYHOST
,
0L
);
curl_easy_setopt
(
curl
,
CURLOPT_HTTP_VERSION
,
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE
);
}
// Response information.
long
httpCode
=
{
0
};
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
&
callback
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
httpData
.
get
());
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDSIZE
,
body
.
length
());
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDS
,
body
.
c_str
());
res
=
curl_easy_perform
(
curl
);
curl_easy_getinfo
(
curl
,
CURLINFO_RESPONSE_CODE
,
&
httpCode
);
Logger
::
amf_n11
().
debug
(
"UE Authentication, response from AUSF, HTTP Code: %d"
,
httpCode
);
if
((
httpCode
==
200
)
or
(
httpCode
==
201
))
{
// TODO: remove hardcoded value
try
{
nlohmann
::
json
::
parse
(
*
httpData
.
get
()).
get_to
(
ue_auth_ctx
);
}
catch
(
nlohmann
::
json
::
exception
&
e
)
{
Logger
::
amf_n11
().
warn
(
"UE Authentication, could not parse json from the AUSF "
"response"
);
// TODO: error handling
return
false
;
}
}
else
{
Logger
::
amf_n11
().
warn
(
"NF Instance Registration, could not get response from NRF"
);
return
false
;
}
curl_slist_free_all
(
headers
);
curl_easy_cleanup
(
curl
);
}
curl_global_cleanup
();
return
true
;
}
src/amf-app/amf_n11.hpp
View file @
32a2dbae
...
@@ -35,6 +35,8 @@
...
@@ -35,6 +35,8 @@
#include "itti_msg_n11.hpp"
#include "itti_msg_n11.hpp"
#include "pdu_session_context.hpp"
#include "pdu_session_context.hpp"
#include "AuthenticationInfo.h"
#include "UEAuthenticationCtx.h"
namespace
amf_application
{
namespace
amf_application
{
...
@@ -81,6 +83,10 @@ class amf_n11 {
...
@@ -81,6 +83,10 @@ class amf_n11 {
bool
discover_smf
(
bool
discover_smf
(
std
::
string
&
smf_addr
,
std
::
string
&
smf_api_version
,
std
::
string
&
smf_addr
,
std
::
string
&
smf_api_version
,
const
snssai_t
snssai
,
const
plmn_t
plmn
,
const
std
::
string
dnn
);
const
snssai_t
snssai
,
const
plmn_t
plmn
,
const
std
::
string
dnn
);
bool
send_ue_authentication_request
(
oai
::
amf
::
model
::
AuthenticationInfo
&
auth_info
,
oai
::
amf
::
model
::
UEAuthenticationCtx
&
ue_auth_ctx
,
uint8_t
http_version
);
};
};
}
// namespace amf_application
}
// namespace amf_application
...
...
src/common/amf.hpp
View file @
32a2dbae
...
@@ -100,6 +100,7 @@ enum class http_response_codes_e {
...
@@ -100,6 +100,7 @@ enum class http_response_codes_e {
#define SMF_NUMBER_RETRIES 3
#define SMF_NUMBER_RETRIES 3
constexpr
auto
CURL_MIME_BOUNDARY
=
"----Boundary"
;
constexpr
auto
CURL_MIME_BOUNDARY
=
"----Boundary"
;
#define NRF_CURL_TIMEOUT_MS 100L
#define NRF_CURL_TIMEOUT_MS 100L
#define AUSF_CURL_TIMEOUT_MS 100L
#define BUFFER_SIZE_1024 1024
#define BUFFER_SIZE_1024 1024
#define BUFFER_SIZE_512 512
#define BUFFER_SIZE_512 512
...
...
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