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
ff5a1a97
Commit
ff5a1a97
authored
Dec 12, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add smf
parent
d426b2e3
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
468 additions
and
137 deletions
+468
-137
src/api-server/impl/NFInstanceIDDocumentApiImpl.cpp
src/api-server/impl/NFInstanceIDDocumentApiImpl.cpp
+28
-4
src/common/nrf.h
src/common/nrf.h
+1
-0
src/common/utils/api_conversions.cpp
src/common/utils/api_conversions.cpp
+26
-3
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+48
-71
src/nrf_app/nrf_app.hpp
src/nrf_app/nrf_app.hpp
+10
-6
src/nrf_app/nrf_profile.cpp
src/nrf_app/nrf_profile.cpp
+300
-47
src/nrf_app/nrf_profile.hpp
src/nrf_app/nrf_profile.hpp
+14
-6
yaml/smf_registration.json
yaml/smf_registration.json
+41
-0
No files found.
src/api-server/impl/NFInstanceIDDocumentApiImpl.cpp
View file @
ff5a1a97
...
...
@@ -83,15 +83,39 @@ void NFInstanceIDDocumentApiImpl::update_nf_instance(
const
std
::
string
&
nfInstanceID
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
Logger
::
nrf_sbi
().
info
(
"Got a request to
register
an NF instance, Instance ID: %s"
,
"Got a request to
update
an NF instance, Instance ID: %s"
,
nfInstanceID
.
c_str
());
int
http_code
=
0
;
m_nrf_app
->
handle_update_nf_instance
(
nfInstanceID
,
patchItem
,
http_code
,
1
);
ProblemDetails
problem_details
=
{
};
m_nrf_app
->
handle_update_nf_instance
(
nfInstanceID
,
patchItem
,
http_code
,
1
,
problem_details
);
nlohmann
::
json
json_data
=
{
};
//to_json(json_data, nf_profile);
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
json_data
.
dump
().
c_str
());
std
::
string
content_type
=
"application/json"
;
std
::
shared_ptr
<
nrf_profile
>
profile
=
m_nrf_app
->
find_nf_profile
(
nfInstanceID
);
if
(
http_code
!=
HTTP_STATUS_CODE_200_OK
)
{
to_json
(
json_data
,
problem_details
);
content_type
=
"application/problem+json"
;
}
else
{
//convert the profile to Json
profile
.
get
()
->
to_json
(
json_data
);
}
Logger
::
nrf_sbi
().
debug
(
"Json data: %s"
,
json_data
.
dump
().
c_str
());
//content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
//Location header
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
Location
>
(
m_address
+
base
+
nrf_cfg
.
sbi_api_version
+
"/nf-instances/"
+
nfInstanceID
);
response
.
send
(
Pistache
::
Http
::
Code
(
http_code
),
json_data
.
dump
().
c_str
());
}
}
...
...
src/common/nrf.h
View file @
ff5a1a97
...
...
@@ -126,4 +126,5 @@ typedef struct smf_info_s {
std
::
vector
<
snssai_smf_info_item_t
>
snssai_smf_info_list
;
}
smf_info_t
;
#endif
src/common/utils/api_conversions.cpp
View file @
ff5a1a97
...
...
@@ -131,6 +131,29 @@ bool api_conv::profile_api_to_amf_profile(
}
break
;
case
NF_TYPE_SMF
:
{
Logger
::
nrf_app
().
debug
(
"............SMF profile, SMF Info"
);
profile
.
get
()
->
set_nf_type
(
NF_TYPE_SMF
);
smf_info_t
info
=
{
};
SmfInfo
smf_info_api
=
api_profile
.
getSmfInfo
();
for
(
auto
s
:
smf_info_api
.
getSNssaiSmfInfoList
())
{
snssai_smf_info_item_t
snssai
=
{
};
snssai
.
snssai
.
sD
=
s
.
getSNssai
().
getSd
();
snssai
.
snssai
.
sST
=
s
.
getSNssai
().
getSst
();
Logger
::
nrf_app
().
debug
(
".......................NSSAI SD: %s, SST: %d"
,
snssai
.
snssai
.
sD
.
c_str
(),
snssai
.
snssai
.
sST
);
for
(
auto
d
:
s
.
getDnnSmfInfoList
())
{
dnn_smf_info_item_t
dnn
=
{};
dnn
.
dnn
=
d
.
getDnn
();
snssai
.
dnn_smf_info_list
.
push_back
(
dnn
);
Logger
::
nrf_app
().
debug
(
"......................DNN: %s"
,
dnn
.
dnn
.
c_str
());
}
info
.
snssai_smf_info_list
.
push_back
(
snssai
);
}
(
std
::
static_pointer_cast
<
smf_profile
>
(
profile
)).
get
()
->
add_smf_info
(
info
);
}
break
;
...
...
@@ -207,9 +230,9 @@ patch_op_type_t api_conv::string_to_patch_operation(const std::string &str) {
return
PATCH_OP_UNKNOWN
;
}
bool
api_conv
::
validate_uuid
(
const
std
::
string
&
str
)
{
//should be verified with Capital letter
static
const
std
::
regex
e
(
"[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}"
);
return
regex_match
(
str
,
e
);
static
const
std
::
regex
e
(
"[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}"
);
return
regex_match
(
str
,
e
);
}
src/nrf_app/nrf_app.cpp
View file @
ff5a1a97
...
...
@@ -82,7 +82,7 @@ void nrf_app::handle_register_nf_instance(
break
;
case
NF_TYPE_SMF
:
{
//TODO:
sn
=
std
::
make_shared
<
smf_profile
>
();
}
break
;
...
...
@@ -102,23 +102,8 @@ void nrf_app::handle_register_nf_instance(
//add to the DB
add_nf_profile
(
nf_instance_id
,
sn
);
Logger
::
nrf_app
().
debug
(
"Added/Updated NF Profile to the DB"
);
switch
(
type
)
{
case
NF_TYPE_AMF
:
{
std
::
static_pointer_cast
<
amf_profile
>
(
sn
).
get
()
->
display
();
}
break
;
case
NF_TYPE_SMF
:
{
std
::
static_pointer_cast
<
smf_profile
>
(
sn
).
get
()
->
display
();
}
break
;
default:
{
sn
.
get
()
->
display
();
}
}
//display the info
sn
.
get
()
->
display
();
}
else
{
//error
Logger
::
nrf_app
().
warn
(
...
...
@@ -131,10 +116,10 @@ void nrf_app::handle_register_nf_instance(
}
//------------------------------------------------------------------------------
void
nrf_app
::
handle_update_nf_instance
(
const
std
::
string
&
nf_instance_id
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
int
&
http_code
,
const
uint8_t
http_version
)
{
void
nrf_app
::
handle_update_nf_instance
(
const
std
::
string
&
nf_instance_id
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
int
&
http_code
,
const
uint8_t
http_version
,
oai
::
nrf
::
model
::
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle Update NF Instance request (HTTP version %d)"
,
http_version
);
...
...
@@ -142,81 +127,73 @@ void nrf_app::handle_update_nf_instance(const std::string &nf_instance_id,
//Find the profile corresponding to the instance ID
std
::
shared_ptr
<
nrf_profile
>
sn
=
{
};
sn
=
find_nf_profile
(
nf_instance_id
);
bool
op_success
=
true
;
if
(
sn
.
get
()
!=
nullptr
)
{
for
(
auto
p
:
patchItem
)
{
patch_op_type_t
op
=
api_conv
::
string_to_patch_operation
(
p
.
getOp
());
//Verify Path
if
((
p
.
getPath
().
substr
(
0
,
1
).
compare
(
"/"
)
!=
0
)
or
(
p
.
getPath
().
length
()
<
2
))
{
Logger
::
nrf_app
().
warn
(
"Bad value for operation path: %s "
,
p
.
getPath
().
c_str
());
http_code
=
HTTP_STATUS_CODE_400_BAD_REQUEST
;
problem_details
.
setCause
(
protocol_application_error_e2str
[
MANDATORY_IE_INCORRECT
]);
return
;
}
std
::
string
path
=
p
.
getPath
().
substr
(
1
);
switch
(
op
)
{
case
PATCH_OP_REPLACE
:
{
switch
(
sn
.
get
()
->
get_nf_type
())
{
case
NF_TYPE_AMF
:
{
Logger
::
nrf_app
().
debug
(
"Update a AMF profile"
);
if
(
std
::
static_pointer_cast
<
amf_profile
>
(
sn
)
->
replace_profile_info
(
path
,
p
.
getValue
()))
update_nf_profile
(
nf_instance_id
,
sn
);
}
break
;
case
NF_TYPE_SMF
:
{
}
break
;
default:
{
Logger
::
nrf_app
().
warn
(
"Unknown NF type!"
);
}
if
(
sn
.
get
()
->
replace_profile_info
(
path
,
p
.
getValue
()))
{
update_nf_profile
(
nf_instance_id
,
sn
);
http_code
=
HTTP_STATUS_CODE_200_OK
;
}
else
{
op_success
=
false
;
}
}
case
PATCH_OP_ADD
:
{
switch
(
sn
.
get
()
->
get_nf_type
())
{
case
NF_TYPE_AMF
:
{
Logger
::
nrf_app
().
debug
(
"Update a AMF profile"
);
if
(
std
::
static_pointer_cast
<
amf_profile
>
(
sn
)
->
add_profile_info
(
path
,
p
.
getValue
()))
update_nf_profile
(
nf_instance_id
,
sn
);
}
break
;
case
NF_TYPE_SMF
:
{
}
break
;
default:
{
Logger
::
nrf_app
().
warn
(
"Unknown NF type!"
);
}
break
;
case
PATCH_OP_ADD
:
{
if
(
sn
.
get
()
->
add_profile_info
(
path
,
p
.
getValue
()))
{
update_nf_profile
(
nf_instance_id
,
sn
);
http_code
=
HTTP_STATUS_CODE_200_OK
;
}
else
{
op_success
=
false
;
}
}
case
PATCH_OP_REMOVE
:
{
switch
(
sn
.
get
()
->
get_nf_type
())
{
case
NF_TYPE_AMF
:
{
Logger
::
nrf_app
().
debug
(
"Update a AMF profile"
);
if
(
std
::
static_pointer_cast
<
amf_profile
>
(
sn
)
->
remove_profile_info
(
path
))
update_nf_profile
(
nf_instance_id
,
sn
);
}
break
;
case
NF_TYPE_SMF
:
{
}
break
;
default:
{
Logger
::
nrf_app
().
warn
(
"Unknown NF type!"
);
}
break
;
case
PATCH_OP_REMOVE
:
{
if
(
sn
.
get
()
->
remove_profile_info
(
path
))
{
update_nf_profile
(
nf_instance_id
,
sn
);
http_code
=
HTTP_STATUS_CODE_200_OK
;
}
else
{
op_success
=
false
;
}
}
break
;
default:
{
Logger
::
nrf_app
().
warn
(
"Requested operation is not valid!"
);
}
}
if
(
!
op_success
)
{
http_code
=
HTTP_STATUS_CODE_400_BAD_REQUEST
;
problem_details
.
setCause
(
protocol_application_error_e2str
[
MANDATORY_IE_INCORRECT
]);
}
}
}
else
{
Logger
::
nrf_app
().
debug
(
"NF Profile with ID %s does not exit"
,
nf_instance_id
.
c_str
());
http_code
=
HTTP_STATUS_CODE_404_NOT_FOUND
;
problem_details
.
setCause
(
protocol_application_error_e2str
[
RESOURCE_URI_STRUCTURE_NOT_FOUND
]);
}
}
...
...
@@ -238,7 +215,7 @@ void nrf_app::handle_get_nf_instances(const std::string &nf_type,
}
for
(
auto
profile
:
profiles
)
{
(
std
::
static_pointer_cast
<
amf_profile
>
(
profile
))
.
get
()
->
display
();
profile
.
get
()
->
display
();
}
}
...
...
src/nrf_app/nrf_app.hpp
View file @
ff5a1a97
...
...
@@ -52,16 +52,17 @@ class nrf_app {
/*
* Handle a Register NF Instance request
* @param [const std::string &] nf_instance_id: Instance ID
* @param [
const oai::nrf::model::
NFProfile &] nf_profile: NF profile
* @param [NFProfile &] nf_profile: NF profile
* @param [int &] http_code: HTTP code used to return to the consumer
* @param [const uint8_t] http_version: HTTP version
* @param [ProblemDetails &] problem_details: Store details of the error
* @return void
*/
void
handle_register_nf_instance
(
const
std
::
string
&
nf_instance_id
,
const
oai
::
nrf
::
model
::
NFProfile
&
nf_profile
,
int
&
http_code
,
const
NFProfile
&
nf_profile
,
int
&
http_code
,
const
uint8_t
http_version
,
oai
::
nrf
::
model
::
ProblemDetails
&
problem_details
);
ProblemDetails
&
problem_details
);
/*
* Handle a Get NF Instance Information
...
...
@@ -81,11 +82,14 @@ class nrf_app {
* @param [const std::vector<PatchItem> &] patchItem: List of modifications need to be applied
* @param [int &] http_code: HTTP code used to return to the consumer
* @param [const uint8_t] http_version: HTTP version
* @param [ProblemDetails &] problem_details: Store details of the error
* @return void
*/
void
handle_update_nf_instance
(
const
std
::
string
&
nf_instance_id
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
int
&
http_code
,
const
uint8_t
http_version
);
void
handle_update_nf_instance
(
const
std
::
string
&
nf_instance_id
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
/*
* Insert a nrf profile
* @param [const std::string &] profile_id: Profile ID
...
...
src/nrf_app/nrf_profile.cpp
View file @
ff5a1a97
This diff is collapsed.
Click to expand it.
src/nrf_app/nrf_profile.hpp
View file @
ff5a1a97
...
...
@@ -91,6 +91,9 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
}
nrf_profile
(
nrf_profile
&
b
)
=
delete
;
virtual
~
nrf_profile
()
{
}
/*
* Set NF instance ID
...
...
@@ -285,7 +288,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param void
* @return void:
*/
void
display
();
v
irtual
v
oid
display
();
/*
* Update a new value for a member of NF profile
...
...
@@ -293,7 +296,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param [const std::string &] value: new value
* @return true if success, otherwise false
*/
bool
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
virtual
bool
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
/*
* Add a new value for a member of NF profile
...
...
@@ -301,7 +304,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param [const std::string &] value: new value
* @return true if success, otherwise false
*/
bool
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
virtual
bool
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
/*
* Remove value of a member of NF profile
...
...
@@ -309,8 +312,8 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param [const std::string &] value: new value
* @return true if success, otherwise false
*/
bool
remove_profile_info
(
const
std
::
string
&
path
);
virtual
bool
remove_profile_info
(
const
std
::
string
&
path
);
virtual
void
to_json
(
nlohmann
::
json
&
data
)
const
;
protected:
//From NFProfile (Section 6.1.6.2.2@3GPP TS 29.510 V16.0.0 (2019-06))
std
::
string
nf_instance_id
;
...
...
@@ -408,6 +411,9 @@ class amf_profile : public nrf_profile {
amf_profile
(
amf_profile
&
b
)
=
delete
;
~
amf_profile
()
{
}
/*
* Add an AMF info
* @param [const amf_info_t &] info: AMF info
...
...
@@ -452,6 +458,8 @@ class amf_profile : public nrf_profile {
* @return true if success, otherwise false
*/
bool
remove_profile_info
(
const
std
::
string
&
path
);
void
to_json
(
nlohmann
::
json
&
data
)
const
;
private:
amf_info_t
amf_info
;
};
...
...
@@ -518,7 +526,7 @@ class smf_profile : public nrf_profile {
* @return true if success, otherwise false
*/
bool
remove_profile_info
(
const
std
::
string
&
path
);
void
to_json
(
nlohmann
::
json
&
data
)
const
;
private:
smf_info_t
smf_info
;
};
...
...
yaml/smf_registration.json
0 → 100644
View file @
ff5a1a97
{
"_comment"
:
"NRF Profile (6.1.6.2.2, 3GPP TS 29.510 V16.0.0 (2019-06)Type: NFProfile)"
,
"nfInstanceId"
:
"343a924e-6494-4927-860b-d45692c95c2e"
,
"nfType"
:
"SMF"
,
"nfStatus"
:
"REGISTERED"
,
"nfInstanceName"
:
"OAI-SMF-NEW"
,
"heartBeatTimer"
:
10
,
"sNssais"
:
[
{
"sst"
:
100
,
"sd"
:
"a0a0a0"
}
],
"ipv4Addresses"
:
[
"10.10.10.1"
,
"10.10.10.2"
]
,
"priority"
:
1
,
"capacity"
:
100
,
"smfInfo"
:
{
"sNssaiSmfInfoList"
:
[
{
"sNssai"
:
{
"sst"
:
100
,
"sd"
:
"a0a0a0"
},
"dnnSmfInfoList"
:
[
{
"dnn"
:
"default"
}
]
}
]
}
}
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