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
eaf979e3
Commit
eaf979e3
authored
Dec 10, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new way to implement NRF profile
parent
c385dc48
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
210 additions
and
25 deletions
+210
-25
src/common/utils/api_conversions.cpp
src/common/utils/api_conversions.cpp
+62
-1
src/common/utils/api_conversions.hpp
src/common/utils/api_conversions.hpp
+4
-1
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+66
-1
src/nrf_app/nrf_profile.cpp
src/nrf_app/nrf_profile.cpp
+69
-18
src/nrf_app/nrf_profile.hpp
src/nrf_app/nrf_profile.hpp
+9
-4
No files found.
src/common/utils/api_conversions.cpp
View file @
eaf979e3
...
...
@@ -37,6 +37,7 @@
#include <boost/algorithm/string/split.hpp>
#include "api_conversions.hpp"
#include "string.hpp"
#include "nrf.h"
//#include "api_conversions.hpp"
#include "logger.hpp"
...
...
@@ -45,7 +46,7 @@ using namespace oai::nrf::model;
using
namespace
oai
::
nrf
::
app
;
using
namespace
oai
::
nrf
;
//------------------------------------------------------------------------------
/*
bool api_conv::profile_api_to_amf_profile(const NFProfile &api_profile,
std::shared_ptr<amf_profile> &profile) {
...
...
@@ -77,6 +78,58 @@ bool api_conv::profile_api_to_amf_profile(const NFProfile &api_profile,
Logger::nrf_app().debug("AMF profile, snssai %d, %s", sn.sST,
sn.sD.c_str());
}
std::vector < std::string > ipv4_addr_str = api_profile.getIpv4Addresses();
for (auto address : ipv4_addr_str) {
struct in_addr addr4 = { };
unsigned char buf_in_addr[sizeof(struct in_addr)];
if (inet_pton(AF_INET, util::trim(address).c_str(), buf_in_addr) == 1) {
memcpy(&addr4, buf_in_addr, sizeof(struct in_addr));
} else {
Logger::nrf_app().warn("NF IPv4 Addr conversion: Bad value %s",
util::trim(address).c_str());
}
Logger::nrf_app().debug("AMF profile, IPv4 Addr %s", address.c_str());
profile.get()->add_nf_ipv4_addresses(addr4);
}
return true;
}
*/
bool
api_conv
::
profile_api_to_amf_profile
(
const
NFProfile
&
api_profile
,
std
::
shared_ptr
<
nrf_profile
>
&
profile
)
{
Logger
::
nrf_app
().
debug
(
"Convert a NF profile generated from OpenAPI to an AMF profile (profile name %s)"
,
api_profile
.
getNfInstanceName
().
c_str
());
profile
.
get
()
->
set_nf_instance_name
(
api_profile
.
getNfInstanceName
());
Logger
::
nrf_app
().
debug
(
"AMF profile, instance name %s"
,
profile
.
get
()
->
get_nf_instance_name
().
c_str
());
profile
.
get
()
->
set_nf_status
(
api_profile
.
getNfStatus
());
Logger
::
nrf_app
().
debug
(
"AMF profile, status %s"
,
profile
.
get
()
->
get_nf_status
().
c_str
());
profile
.
get
()
->
set_nf_heartBeat_timer
(
api_profile
.
getHeartBeatTimer
());
Logger
::
nrf_app
().
debug
(
"AMF profile, status %d"
,
profile
.
get
()
->
get_nf_hertBeat_timer
());
profile
.
get
()
->
set_nf_priority
(
api_profile
.
getPriority
());
Logger
::
nrf_app
().
debug
(
"AMF profile, priority %d"
,
profile
.
get
()
->
get_nf_priority
());
profile
.
get
()
->
set_nf_capacity
(
api_profile
.
getCapacity
());
Logger
::
nrf_app
().
debug
(
"AMF profile, capacity %d"
,
profile
.
get
()
->
get_nf_capacity
());
//SNSSAIs
std
::
vector
<
Snssai
>
snssai
=
api_profile
.
getSNssais
();
for
(
auto
s
:
snssai
)
{
snssai_t
sn
=
{
};
sn
.
sD
=
s
.
getSd
();
sn
.
sST
=
s
.
getSst
();
profile
.
get
()
->
add_snssai
(
sn
);
Logger
::
nrf_app
().
debug
(
"AMF profile, snssai %d, %s"
,
sn
.
sST
,
sn
.
sD
.
c_str
());
}
/*std::vector<snssai_t> sn = { };
profile.get()->get_nf_snssais(sn);
for (auto s : sn) {
...
...
@@ -100,5 +153,13 @@ bool api_conv::profile_api_to_amf_profile(const NFProfile &api_profile,
profile
.
get
()
->
add_nf_ipv4_addresses
(
addr4
);
}
if
(
api_profile
.
getNfType
().
compare
(
"AMF"
)
==
0
)
{
Logger
::
nrf_app
().
debug
(
"AMF profile, AMF INFO"
);
amf_info_t
info
=
{};
info
.
amf_region_id
=
"AMF_REGION_ID"
;
info
.
amf_set_id
=
"AMF_SET_ID"
;
(
std
::
static_pointer_cast
<
amf_profile
>
(
profile
)).
get
()
->
add_amf_info
(
info
);
}
return
true
;
}
src/common/utils/api_conversions.hpp
View file @
eaf979e3
...
...
@@ -42,7 +42,10 @@ namespace nrf {
namespace
api_conv
{
bool
profile_api_to_amf_profile
(
const
NFProfile
&
api_profile
,
std
::
shared_ptr
<
amf_profile
>
&
profile
);
std
::
shared_ptr
<
nrf_profile
>
&
profile
);
//bool profile_api_to_amf_profile(const NFProfile &api_profile,
// std::shared_ptr<amf_profile> &profile);
}
// namespace api_conv
}
...
...
src/nrf_app/nrf_app.cpp
View file @
eaf979e3
...
...
@@ -95,7 +95,7 @@ void nrf_app::handle_register_nf_instance(const std::string &nf_instance_id,
add_nf_profile(nf_instance_id, sa);
}
*/
/*
//create/Update NF profile
Logger::nrf_app().debug("NF Profile with (ID %s, NF type %s)",
nf_instance_id.c_str(), nf_profile.getNfType().c_str());
...
...
@@ -114,6 +114,71 @@ void nrf_app::handle_register_nf_instance(const std::string &nf_instance_id,
http_code = 200;
}
}
*/
//create/Update NF profile
Logger
::
nrf_app
().
debug
(
"NF Profile with (ID %s, NF type %s)"
,
nf_instance_id
.
c_str
(),
nf_profile
.
getNfType
().
c_str
());
std
::
shared_ptr
<
nrf_profile
>
sn
=
std
::
make_shared
<
amf_profile
>
();;
//sn = find_nf_profile(nf_instance_id);
if
(
nf_profile
.
getNfType
().
compare
(
"AMF"
)
==
0
)
{
//std::shared_ptr<amf_profile> sa = { };
//sa = std::shared_ptr < amf_profile > (new amf_profile(nf_instance_id));
if
(
!
api_conv
::
profile_api_to_amf_profile
(
nf_profile
,
sn
))
{
//error, TODO
Logger
::
nrf_app
().
warn
(
"Cannot convert a NF profile generated from OpenAPI to an AMF profile (profile ID %s)"
,
nf_instance_id
.
c_str
());
http_code
=
412
;
//Precondition Failed
}
else
{
add_nf_profile
(
nf_instance_id
,
sn
);
http_code
=
200
;
}
}
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
profiles
=
{
};
find_nf_profiles
(
"AMF"
,
profiles
);
for
(
auto
profile
:
profiles
)
{
(
std
::
static_pointer_cast
<
amf_profile
>
(
profile
)).
get
()
->
display
();
/*
Logger::nrf_app().debug("AMF profile, instance name %s",
profile.get()->get_nf_instance_name().c_str());
Logger::nrf_app().debug("AMF profile, status %s",
profile.get()->get_nf_status().c_str());
Logger::nrf_app().debug("AMF profile, status %d",
profile.get()->get_nf_hertBeat_timer());
Logger::nrf_app().debug("AMF profile, priority %d",
profile.get()->get_nf_priority());
Logger::nrf_app().debug("AMF profile, capacity %d",
profile.get()->get_nf_capacity());
//SNSSAIs
std::vector<snssai_t> sn = { };
profile.get()->get_nf_snssais(sn);
for (auto s : sn) {
Logger::nrf_app().debug("AMF profile, snssai %d, %s", s.sST,
s.sD.c_str());
}
//IPv4 Addresses
std::vector<struct in_addr> addr4 = { };
profile.get()->get_nf_ipv4_addresses(addr4);
for (auto address : addr4) {
Logger::nrf_app().debug("AMF profile, IPv4 Addr %s",
inet_ntoa(address));
}
std::vector<amf_info_t> infos = {};
(std::static_pointer_cast<amf_profile>(profile)).get()->get_amf_infos(infos);
for (auto i: infos) {
Logger::nrf_app().debug("AMF Info, Set ID %s, region ID %s",
i.amf_set_id.c_str(), i.amf_region_id.c_str());
}
*/
}
//location header - URI of created resource: can be used with ID - UUID
...
...
src/nrf_app/nrf_profile.cpp
View file @
eaf979e3
...
...
@@ -28,28 +28,29 @@
*/
#include "nrf_profile.hpp"
#include "logger.hpp"
using
namespace
std
;
using
namespace
oai
::
nrf
::
app
;
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_instance_id
(
const
std
::
string
&
instance_id
)
{
nf_instance_id
=
instance_id
;
nf_instance_id
=
instance_id
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_instance_id
(
std
::
string
&
instance_id
)
const
{
instance_id
=
nf_instance_id
;
instance_id
=
nf_instance_id
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_instance_name
(
const
std
::
string
&
instance_name
)
{
nf_instance_name
=
instance_name
;
nf_instance_name
=
instance_name
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_instance_name
(
std
::
string
&
instance_name
)
const
{
instance_name
=
nf_instance_name
;
instance_name
=
nf_instance_name
;
}
std
::
string
nrf_profile
::
get_nf_instance_name
()
const
{
...
...
@@ -61,12 +62,12 @@ nf_type_t nrf_profile::get_nf_type() const {
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_status
(
const
std
::
string
&
status
)
{
nf_status
=
status
;
nf_status
=
status
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_status
(
std
::
string
&
status
)
const
{
status
=
nf_status
;
status
=
nf_status
;
}
std
::
string
nrf_profile
::
get_nf_status
()
const
{
...
...
@@ -75,12 +76,12 @@ std::string nrf_profile::get_nf_status() const {
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_heartBeat_timer
(
const
int32_t
&
timer
)
{
heartBeat_timer
=
timer
;
heartBeat_timer
=
timer
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_hertBeat_timer
(
int32_t
&
timer
)
const
{
timer
=
heartBeat_timer
;
timer
=
heartBeat_timer
;
}
int32_t
nrf_profile
::
get_nf_hertBeat_timer
()
const
{
...
...
@@ -89,40 +90,39 @@ int32_t nrf_profile::get_nf_hertBeat_timer() const {
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_priority
(
const
uint16_t
&
p
)
{
priority
=
p
;
priority
=
p
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_priority
(
uint16_t
&
p
)
const
{
p
=
priority
;
p
=
priority
;
}
uint16_t
nrf_profile
::
get_nf_priority
()
const
{
return
priority
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_capacity
(
const
uint16_t
&
c
)
{
capacity
=
c
;
capacity
=
c
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_capacity
(
uint16_t
&
c
)
const
{
c
=
capacity
;
c
=
capacity
;
}
uint16_t
nrf_profile
::
get_nf_capacity
()
const
{
return
capacity
;
return
capacity
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_snssais
(
const
std
::
vector
<
snssai_t
>
&
s
)
{
snssais
=
s
;
snssais
=
s
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_snssais
(
std
::
vector
<
snssai_t
>
&
s
)
const
{
s
=
snssais
;
s
=
snssais
;
}
//------------------------------------------------------------------------------
...
...
@@ -131,7 +131,7 @@ void nrf_profile::add_snssai(const snssai_t &s) {
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_ipv4_addresses
(
const
std
::
vector
<
struct
in_addr
>
&
a
)
{
ipv4_addresses
=
a
;
ipv4_addresses
=
a
;
}
void
nrf_profile
::
add_nf_ipv4_addresses
(
const
struct
in_addr
&
a
)
{
...
...
@@ -139,6 +139,57 @@ void nrf_profile::add_nf_ipv4_addresses(const struct in_addr &a) {
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_ipv4_addresses
(
std
::
vector
<
struct
in_addr
>
&
a
)
const
{
a
=
ipv4_addresses
;
a
=
ipv4_addresses
;
}
void
nrf_profile
::
display
()
{
std
::
string
nf_instance_id
;
std
::
string
nf_instance_name
;
nf_type_t
nf_type
;
std
::
string
nf_status
;
int32_t
heartBeat_timer
;
std
::
vector
<
snssai_t
>
snssais
;
std
::
vector
<
struct
in_addr
>
ipv4_addresses
;
uint16_t
priority
;
uint16_t
capacity
;
Logger
::
nrf_app
().
debug
(
"NF profile, instance ID %s"
,
nf_instance_id
.
c_str
());
Logger
::
nrf_app
().
debug
(
"NF profile, instance name %s"
,
nf_instance_name
.
c_str
());
Logger
::
nrf_app
().
debug
(
"AMF profile, status %s"
,
nf_status
.
c_str
());
Logger
::
nrf_app
().
debug
(
"AMF profile, status %d"
,
heartBeat_timer
);
Logger
::
nrf_app
().
debug
(
"AMF profile, priority %d"
,
priority
);
Logger
::
nrf_app
().
debug
(
"AMF profile, capacity %d"
,
capacity
);
//SNSSAIs
for
(
auto
s
:
snssais
)
{
Logger
::
nrf_app
().
debug
(
"AMF profile, snssai %d, %s"
,
s
.
sST
,
s
.
sD
.
c_str
());
}
//IPv4 Addresses
for
(
auto
address
:
ipv4_addresses
)
{
Logger
::
nrf_app
().
debug
(
"AMF profile, IPv4 Addr %s"
,
inet_ntoa
(
address
));
}
}
void
amf_profile
::
add_amf_info
(
const
amf_info_t
&
info
)
{
amf_infos
.
push_back
(
info
);
}
void
amf_profile
::
get_amf_infos
(
std
::
vector
<
amf_info_t
>
&
infos
)
const
{
infos
=
amf_infos
;
}
void
amf_profile
::
display
()
{
nrf_profile
::
display
();
for
(
auto
i
:
amf_infos
)
{
Logger
::
nrf_app
().
debug
(
"AMF Info, Set ID %s, region ID %s"
,
i
.
amf_set_id
.
c_str
(),
i
.
amf_region_id
.
c_str
());
}
}
src/nrf_app/nrf_profile.hpp
View file @
eaf979e3
...
...
@@ -37,6 +37,7 @@
#include <memory>
#include <utility>
#include <vector>
#include "nrf.h"
#include "nrf.h"
...
...
@@ -194,7 +195,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @return void:
*/
void
get_nf_ipv4_addresses
(
std
::
vector
<
struct
in_addr
>
&
a
)
const
;
void
display
();
protected:
//From NFProfile (Section 6.1.6.2.2@3GPP TS 29.510 V16.0.0 (2019-06))
std
::
string
nf_instance_id
;
...
...
@@ -280,20 +281,24 @@ class amf_profile : public nrf_profile {
amf_profile
()
:
nrf_profile
(
NF_TYPE_AMF
)
{
amf_info
=
{
};
amf_infos
=
{
};
}
amf_profile
(
const
std
::
string
&
id
)
:
nrf_profile
(
id
)
{
nf_type
=
NF_TYPE_AMF
;
amf_info
=
{
};
amf_infos
=
{
};
}
amf_profile
(
amf_profile
&
b
)
=
delete
;
void
add_amf_info
(
const
amf_info_t
&
info
);
void
get_amf_infos
(
std
::
vector
<
amf_info_t
>
&
infos
)
const
;
void
display
();
private:
std
::
vector
<
amf_info_t
>
amf_info
;
std
::
vector
<
amf_info_t
>
amf_info
s
;
};
}
...
...
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