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
a9e2a792
Commit
a9e2a792
authored
Dec 11, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish NFRegister operation
parent
7d9ce68b
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
8 deletions
+81
-8
src/api-server/impl/NFInstanceIDDocumentApiImpl.cpp
src/api-server/impl/NFInstanceIDDocumentApiImpl.cpp
+19
-2
src/common/3gpp_29.500.h
src/common/3gpp_29.500.h
+33
-0
src/common/utils/api_conversions.cpp
src/common/utils/api_conversions.cpp
+9
-1
src/common/utils/api_conversions.hpp
src/common/utils/api_conversions.hpp
+3
-0
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+11
-2
src/nrf_app/nrf_app.hpp
src/nrf_app/nrf_app.hpp
+6
-3
No files found.
src/api-server/impl/NFInstanceIDDocumentApiImpl.cpp
View file @
a9e2a792
...
...
@@ -14,6 +14,8 @@
#include "logger.hpp"
#include "nrf_app.hpp"
#include "nrf_config.hpp"
#include "ProblemDetails.h"
#include "3gpp_29.500.h"
extern
oai
::
nrf
::
app
::
nrf_config
nrf_cfg
;
...
...
@@ -52,10 +54,25 @@ void NFInstanceIDDocumentApiImpl::register_nf_instance(
NFProfile
nf_profile
=
nFProfile
;
int
http_code
=
0
;
m_nrf_app
->
handle_register_nf_instance
(
nfInstanceID
,
nFProfile
,
http_code
,
1
);
ProblemDetails
problem_details
=
{
};
m_nrf_app
->
handle_register_nf_instance
(
nfInstanceID
,
nFProfile
,
http_code
,
1
,
problem_details
);
nlohmann
::
json
json_data
=
{
};
std
::
string
content_type
=
"application/json"
;
if
((
http_code
!=
HTTP_STATUS_CODE_200_OK
)
and
(
http_code
!=
HTTP_STATUS_CODE_201_CREATED
)
and
(
http_code
!=
HTTP_STATUS_CODE_202_ACCEPTED
))
{
to_json
(
json_data
,
problem_details
);
content_type
=
"application/problem+json"
;
}
else
{
to_json
(
json_data
,
nf_profile
);
}
//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/"
...
...
src/common/3gpp_29.500.h
View file @
a9e2a792
...
...
@@ -53,5 +53,38 @@ enum http_status_code_e {
HTTP_STATUS_CODE_504_GATEWAY_TIMEOUT
=
504
};
enum
protocol_application_error_e
{
INVALID_API
=
0
,
//400 Bad Request
INVALID_MSG_FORMAT
=
1
,
//400 Bad Request
INVALID_QUERY_PARAM
=
2
,
//400 Bad Request
MANDATORY_QUERY_PARAM_INCORRECT
=
3
,
//400 Bad Request
OPTIONAL_QUERY_PARAM_INCORRECT
=
4
,
//400 Bad Request
MANDATORY_QUERY_PARAM_MISSING
=
5
,
//400 Bad Request
MANDATORY_IE_INCORRECT
=
6
,
//400 Bad Request
OPTIONAL_IE_INCORRECT
=
7
,
//400 Bad Request
MANDATORY_IE_MISSING
=
8
,
//400 Bad Request
UNSPECIFIED_MSG_FAILURE
=
9
,
//400 Bad Request
MODIFICATION_NOT_ALLOWED
=
10
,
//403 Forbidden
SUBSCRIPTION_NOT_FOUND
=
11
,
//404 Not Found
RESOURCE_URI_STRUCTURE_NOT_FOUND
=
12
,
//404 Not Found
INCORRECT_LENGTH
=
13
,
//411 Length Required
NF_CONGESTION_RISK
=
14
,
//429 Too Many Requests
INSUFFICIENT_RESOURCES
=
15
,
//500 Internal Server Error
UNSPECIFIED_NF_FAILURE
=
16
,
//500 Internal Server Error
SYSTEM_FAILURE
=
17
,
//500 Internal Server Error
NF_CONGESTION
=
18
,
//503 Service Unavailable
};
static
const
std
::
vector
<
std
::
string
>
protocol_application_error_e2str
{
"INVALID_API"
,
"INVALID_MSG_FORMAT"
,
"INVALID_QUERY_PARAM"
,
"MANDATORY_QUERY_PARAM_INCORRECT"
,
"OPTIONAL_QUERY_PARAM_INCORRECT"
,
"MANDATORY_QUERY_PARAM_MISSING"
,
"MANDATORY_IE_INCORRECT"
,
"OPTIONAL_IE_INCORRECT"
,
"MANDATORY_IE_MISSING"
,
"UNSPECIFIED_MSG_FAILURE"
,
"MODIFICATION_NOT_ALLOWED"
,
"SUBSCRIPTION_NOT_FOUND"
,
"RESOURCE_URI_STRUCTURE_NOT_FOUND"
,
"INCORRECT_LENGTH "
,
"NF_CONGESTION_RISK"
,
"INSUFFICIENT_RESOURCES"
,
"UNSPECIFIED_NF_FAILURE"
,
"SYSTEM_FAILURE"
,
"NF_CONGESTION"
};
#endif
src/common/utils/api_conversions.cpp
View file @
a9e2a792
...
...
@@ -32,6 +32,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <regex>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
...
...
@@ -205,3 +206,10 @@ patch_op_type_t api_conv::string_to_patch_operation(const std::string &str) {
//default
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
);
}
src/common/utils/api_conversions.hpp
View file @
a9e2a792
...
...
@@ -64,6 +64,9 @@ nf_type_t string_to_nf_type(const std::string &str);
*/
patch_op_type_t
string_to_patch_operation
(
const
std
::
string
&
str
);
bool
validate_uuid
(
const
std
::
string
&
str
);
}
// namespace api_conv
}
}
...
...
src/nrf_app/nrf_app.cpp
View file @
a9e2a792
...
...
@@ -50,10 +50,19 @@ nrf_app::nrf_app(const std::string &config_file) {
void
nrf_app
::
handle_register_nf_instance
(
const
std
::
string
&
nf_instance_id
,
const
oai
::
nrf
::
model
::
NFProfile
&
nf_profile
,
int
&
http_code
,
const
uint8_t
http_version
)
{
const
uint8_t
http_version
,
oai
::
nrf
::
model
::
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle NF Instance Registration (HTTP version %d)"
,
http_version
);
if
(
!
api_conv
::
validate_uuid
(
nf_instance_id
))
{
http_code
=
HTTP_STATUS_CODE_400_BAD_REQUEST
;
Logger
::
nrf_app
().
debug
(
"Bad UUID format for NF Instance ID (%s)"
,
nf_instance_id
.
c_str
());
problem_details
.
setCause
(
protocol_application_error_e2str
[
MANDATORY_QUERY_PARAM_INCORRECT
]);
return
;
}
//Check if nfInstanceID is a valid UUID (version 4)
//TODO
...
...
@@ -166,7 +175,7 @@ void nrf_app::handle_get_nf_instances(const std::string &nf_type,
find_nf_profiles
(
type
,
profiles
);
if
(
profiles
.
size
()
==
0
)
{
Logger
::
nrf_app
().
debug
(
"No profile found
with type %s
"
,
nf_type
.
c_str
());
Logger
::
nrf_app
().
debug
(
"No profile found
(NF type: %s)
"
,
nf_type
.
c_str
());
}
for
(
auto
profile
:
profiles
)
{
...
...
src/nrf_app/nrf_app.hpp
View file @
a9e2a792
...
...
@@ -34,6 +34,7 @@
#include "NFProfile.h"
#include "nrf_profile.hpp"
#include "PatchItem.h"
#include "ProblemDetails.h"
namespace
oai
{
namespace
nrf
{
...
...
@@ -56,9 +57,11 @@ class nrf_app {
* @param [const uint8_t] http_version: HTTP version
* @return void
*/
void
handle_register_nf_instance
(
const
std
::
string
&
nf_instance_id
,
const
oai
::
nrf
::
model
::
NFProfile
&
nf_profile
,
int
&
http_code
,
const
uint8_t
http_version
);
void
handle_register_nf_instance
(
const
std
::
string
&
nf_instance_id
,
const
oai
::
nrf
::
model
::
NFProfile
&
nf_profile
,
int
&
http_code
,
const
uint8_t
http_version
,
oai
::
nrf
::
model
::
ProblemDetails
&
problem_details
);
/*
* Handle a Get NF Instance Information
...
...
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