Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-NRF
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-NRF
Commits
6b57e049
Unverified
Commit
6b57e049
authored
Jun 25, 2021
by
kharade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fqdn added in NFProfile
parent
2f1e8ef3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
1 deletion
+105
-1
src/common/utils/api_conversions.cpp
src/common/utils/api_conversions.cpp
+5
-1
src/nrf_app/nrf_profile.cpp
src/nrf_app/nrf_profile.cpp
+64
-0
src/nrf_app/nrf_profile.hpp
src/nrf_app/nrf_profile.hpp
+36
-0
No files found.
src/common/utils/api_conversions.cpp
View file @
6b57e049
...
@@ -83,7 +83,10 @@ bool api_conv::profile_api_to_nrf_profile(
...
@@ -83,7 +83,10 @@ bool api_conv::profile_api_to_nrf_profile(
Logger
::
nrf_app
().
debug
(
Logger
::
nrf_app
().
debug
(
"
\t
SNSSAI (SD, SST): %d, %s"
,
sn
.
sST
,
sn
.
sD
.
c_str
());
"
\t
SNSSAI (SD, SST): %d, %s"
,
sn
.
sST
,
sn
.
sD
.
c_str
());
}
}
if
(
api_profile
.
fqdnIsSet
())
{
profile
.
get
()
->
set_fqdn
(
api_profile
.
getFqdn
());
Logger
::
nrf_app
().
debug
(
"
\t
FQDN: %s"
,
api_profile
.
getFqdn
().
c_str
());
}
std
::
vector
<
std
::
string
>
ipv4_addr_str
=
api_profile
.
getIpv4Addresses
();
std
::
vector
<
std
::
string
>
ipv4_addr_str
=
api_profile
.
getIpv4Addresses
();
for
(
auto
address
:
ipv4_addr_str
)
{
for
(
auto
address
:
ipv4_addr_str
)
{
struct
in_addr
addr4
=
{};
struct
in_addr
addr4
=
{};
...
@@ -98,6 +101,7 @@ bool api_conv::profile_api_to_nrf_profile(
...
@@ -98,6 +101,7 @@ bool api_conv::profile_api_to_nrf_profile(
Logger
::
nrf_app
().
debug
(
"
\t
IPv4 Addr: %s"
,
address
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
IPv4 Addr: %s"
,
address
.
c_str
());
profile
.
get
()
->
add_nf_ipv4_addresses
(
addr4
);
profile
.
get
()
->
add_nf_ipv4_addresses
(
addr4
);
}
}
// ToDo: Check if ipv6 addr present
nf_type_t
nf_type
=
string_to_nf_type
(
api_profile
.
getNfType
());
nf_type_t
nf_type
=
string_to_nf_type
(
api_profile
.
getNfType
());
...
...
src/nrf_app/nrf_profile.cpp
View file @
6b57e049
...
@@ -157,6 +157,15 @@ void nrf_profile::add_snssai(const snssai_t& s) {
...
@@ -157,6 +157,15 @@ void nrf_profile::add_snssai(const snssai_t& s) {
snssais
.
push_back
(
s
);
snssais
.
push_back
(
s
);
}
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_fqdn
(
const
std
::
string
&
fqdN
)
{
fqdn
=
fqdN
;
}
//------------------------------------------------------------------------------
std
::
string
nrf_profile
::
get_fqdn
()
const
{
return
fqdn
;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_ipv4_addresses
(
const
std
::
vector
<
struct
in_addr
>&
a
)
{
void
nrf_profile
::
set_nf_ipv4_addresses
(
const
std
::
vector
<
struct
in_addr
>&
a
)
{
ipv4_addresses
=
a
;
ipv4_addresses
=
a
;
...
@@ -167,6 +176,15 @@ void nrf_profile::add_nf_ipv4_addresses(const struct in_addr& a) {
...
@@ -167,6 +176,15 @@ void nrf_profile::add_nf_ipv4_addresses(const struct in_addr& a) {
ipv4_addresses
.
push_back
(
a
);
ipv4_addresses
.
push_back
(
a
);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_ipv6_addresses
(
const
std
::
vector
<
struct
in6_addr
>&
a
)
{
ipv6_addresses
=
a
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
add_nf_ipv6_addresses
(
const
struct
in6_addr
&
a
)
{
ipv6_addresses
.
push_back
(
a
);
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_ipv4_addresses
(
std
::
vector
<
struct
in_addr
>&
a
)
const
{
void
nrf_profile
::
get_nf_ipv4_addresses
(
std
::
vector
<
struct
in_addr
>&
a
)
const
{
a
=
ipv4_addresses
;
a
=
ipv4_addresses
;
}
}
...
@@ -277,12 +295,22 @@ bool nrf_profile::replace_profile_info(
...
@@ -277,12 +295,22 @@ bool nrf_profile::replace_profile_info(
}
}
}
}
if
(
path
.
compare
(
"fqdn"
)
==
0
)
{
fqdn
=
value
;
return
true
;
}
// Replace an array
// Replace an array
if
(
path
.
compare
(
"ipv4Addresses"
)
==
0
)
{
if
(
path
.
compare
(
"ipv4Addresses"
)
==
0
)
{
Logger
::
nrf_app
().
info
(
"Does not support this operation for ipv4Addresses"
);
Logger
::
nrf_app
().
info
(
"Does not support this operation for ipv4Addresses"
);
return
false
;
return
false
;
}
}
if
(
path
.
compare
(
"ipv6Addresses"
)
==
0
)
{
Logger
::
nrf_app
().
info
(
"Does not support this operation for ipv6Addresses"
);
return
false
;
}
if
(
path
.
compare
(
"sNssais"
)
==
0
)
{
if
(
path
.
compare
(
"sNssais"
)
==
0
)
{
Logger
::
nrf_app
().
info
(
"Does not support this operation for sNssais"
);
Logger
::
nrf_app
().
info
(
"Does not support this operation for sNssais"
);
return
false
;
return
false
;
...
@@ -350,6 +378,11 @@ bool nrf_profile::add_profile_info(
...
@@ -350,6 +378,11 @@ bool nrf_profile::add_profile_info(
}
}
}
}
if
(
path
.
compare
(
"fqdn"
)
==
0
)
{
fqdn
=
value
;
return
true
;
}
// add an element to a list
// add an element to a list
if
(
path
.
compare
(
"ipv4Addresses"
)
==
0
)
{
if
(
path
.
compare
(
"ipv4Addresses"
)
==
0
)
{
std
::
string
address
=
value
;
std
::
string
address
=
value
;
...
@@ -367,6 +400,23 @@ bool nrf_profile::add_profile_info(
...
@@ -367,6 +400,23 @@ bool nrf_profile::add_profile_info(
return
true
;
return
true
;
}
}
// add an element to a list
if
(
path
.
compare
(
"ipv6Addresses"
)
==
0
)
{
std
::
string
address
=
value
;
struct
in6_addr
addr6
=
{};
unsigned
char
buf_in_addr
[
sizeof
(
struct
in6_addr
)];
if
(
inet_pton
(
AF_INET
,
util
::
trim
(
address
).
c_str
(),
buf_in_addr
)
==
1
)
{
memcpy
(
&
addr6
,
buf_in_addr
,
sizeof
(
struct
in6_addr
));
}
else
{
Logger
::
nrf_app
().
warn
(
"Address conversion: Bad value %s"
,
util
::
trim
(
address
).
c_str
());
return
false
;
}
Logger
::
nrf_app
().
debug
(
"Added IPv6 Addr: %s"
,
address
.
c_str
());
ipv6_addresses
.
push_back
(
addr6
);
return
true
;
}
// add an element to a list of json object
// add an element to a list of json object
if
(
path
.
compare
(
"sNssais"
)
==
0
)
{
if
(
path
.
compare
(
"sNssais"
)
==
0
)
{
Logger
::
nrf_app
().
info
(
"Does not support this operation for sNssais"
);
Logger
::
nrf_app
().
info
(
"Does not support this operation for sNssais"
);
...
@@ -415,6 +465,11 @@ bool nrf_profile::remove_profile_info(const std::string& path) {
...
@@ -415,6 +465,11 @@ bool nrf_profile::remove_profile_info(const std::string& path) {
return
true
;
return
true
;
}
}
if
(
path
.
compare
(
"fqdn"
)
==
0
)
{
fqdn
=
""
;
return
true
;
}
// path: e.g., /ipv4Addresses/4
// path: e.g., /ipv4Addresses/4
if
(
path
.
find
(
"ipv4Addresses"
)
!=
std
::
string
::
npos
)
{
if
(
path
.
find
(
"ipv4Addresses"
)
!=
std
::
string
::
npos
)
{
std
::
vector
<
std
::
string
>
parts
;
std
::
vector
<
std
::
string
>
parts
;
...
@@ -473,12 +528,21 @@ void nrf_profile::to_json(nlohmann::json& data) const {
...
@@ -473,12 +528,21 @@ void nrf_profile::to_json(nlohmann::json& data) const {
;
;
data
[
"sNssais"
].
push_back
(
tmp
);
data
[
"sNssais"
].
push_back
(
tmp
);
}
}
if
(
!
fqdn
.
empty
())
{
data
[
"fqdn"
]
=
fqdn
;
}
// ipv4_addresses
// ipv4_addresses
data
[
"ipv4Addresses"
]
=
nlohmann
::
json
::
array
();
data
[
"ipv4Addresses"
]
=
nlohmann
::
json
::
array
();
for
(
auto
address
:
ipv4_addresses
)
{
for
(
auto
address
:
ipv4_addresses
)
{
nlohmann
::
json
tmp
=
inet_ntoa
(
address
);
nlohmann
::
json
tmp
=
inet_ntoa
(
address
);
data
[
"ipv4Addresses"
].
push_back
(
tmp
);
data
[
"ipv4Addresses"
].
push_back
(
tmp
);
}
}
// // ipv6_addresses
// data["ipv6Addresses"] = nlohmann::json::array();
// for (auto address : ipv6_addresses) {
// nlohmann::json tmp = inet_ntoa(address);
// data["ipv6Addresses"].push_back(tmp);
// }
data
[
"priority"
]
=
priority
;
data
[
"priority"
]
=
priority
;
data
[
"capacity"
]
=
capacity
;
data
[
"capacity"
]
=
capacity
;
// NF services
// NF services
...
...
src/nrf_app/nrf_profile.hpp
View file @
6b57e049
...
@@ -57,7 +57,9 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
...
@@ -57,7 +57,9 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
nf_type
(
NF_TYPE_UNKNOWN
),
nf_type
(
NF_TYPE_UNKNOWN
),
heartBeat_timer
(
0
),
heartBeat_timer
(
0
),
snssais
(),
snssais
(),
fqdn
(),
ipv4_addresses
(),
ipv4_addresses
(),
ipv6_addresses
(),
priority
(
0
),
priority
(
0
),
capacity
(
0
),
capacity
(
0
),
nf_services
(),
nf_services
(),
...
@@ -73,7 +75,9 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
...
@@ -73,7 +75,9 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
nf_type
(
type
),
nf_type
(
type
),
heartBeat_timer
(
0
),
heartBeat_timer
(
0
),
snssais
(),
snssais
(),
fqdn
(),
ipv4_addresses
(),
ipv4_addresses
(),
ipv6_addresses
(),
priority
(
0
),
priority
(
0
),
capacity
(
0
),
capacity
(
0
),
nf_services
(),
nf_services
(),
...
@@ -90,7 +94,9 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
...
@@ -90,7 +94,9 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
nf_instance_id
(
id
),
nf_instance_id
(
id
),
heartBeat_timer
(
0
),
heartBeat_timer
(
0
),
snssais
(),
snssais
(),
fqdn
(),
ipv4_addresses
(),
ipv4_addresses
(),
ipv6_addresses
(),
priority
(
0
),
priority
(
0
),
capacity
(
0
),
capacity
(
0
),
nf_services
(),
nf_services
(),
...
@@ -272,6 +278,20 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
...
@@ -272,6 +278,20 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
*/
*/
void
get_nf_snssais
(
std
::
vector
<
snssai_t
>&
s
)
const
;
void
get_nf_snssais
(
std
::
vector
<
snssai_t
>&
s
)
const
;
/*
* Get NF fqdn
* @param
* @return [std::string] nf fqdn
*/
std
::
string
get_fqdn
()
const
;
/*
* Set NF fqdn
* @param [const fqdn_t &] fqdn: nf fqdn
* @return void
*/
void
set_fqdn
(
const
std
::
string
&
fqdn
);
/*
/*
* Set NF instance ipv4_addresses
* Set NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: ipv4_addresses
* @param [std::vector<struct in_addr> &] a: ipv4_addresses
...
@@ -286,6 +306,20 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
...
@@ -286,6 +306,20 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
*/
*/
void
add_nf_ipv4_addresses
(
const
struct
in_addr
&
a
);
void
add_nf_ipv4_addresses
(
const
struct
in_addr
&
a
);
/*
* Set NF instance ipv6_addresses
* @param [std::vector<struct in6_addr> &] a: ipv6_addresses
* @return void
*/
void
set_nf_ipv6_addresses
(
const
std
::
vector
<
struct
in6_addr
>&
a
);
/*
* Add an IPv6 address to the list of addresses
* @param [const struct in_addr &] a: ipv6_address
* @return void
*/
void
add_nf_ipv6_addresses
(
const
struct
in6_addr
&
a
);
/*
/*
* Get NF instance ipv4_addresses
* Get NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: store instance's ipv4_addresses
* @param [std::vector<struct in_addr> &] a: store instance's ipv4_addresses
...
@@ -441,7 +475,9 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
...
@@ -441,7 +475,9 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
std
::
string
nf_status
;
std
::
string
nf_status
;
int32_t
heartBeat_timer
;
int32_t
heartBeat_timer
;
std
::
vector
<
snssai_t
>
snssais
;
std
::
vector
<
snssai_t
>
snssais
;
std
::
string
fqdn
;
std
::
vector
<
struct
in_addr
>
ipv4_addresses
;
std
::
vector
<
struct
in_addr
>
ipv4_addresses
;
std
::
vector
<
struct
in6_addr
>
ipv6_addresses
;
uint16_t
priority
;
uint16_t
priority
;
uint16_t
capacity
;
uint16_t
capacity
;
nlohmann
::
json
json_data
;
// store extra json data
nlohmann
::
json
json_data
;
// store extra json data
...
...
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