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
7d14dd54
Commit
7d14dd54
authored
Jan 15, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Clang-format
parent
b71f828a
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
887 additions
and
722 deletions
+887
-722
src/.clang-format
src/.clang-format
+117
-0
src/common/nrf.h
src/common/nrf.h
+29
-29
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+171
-169
src/nrf_app/nrf_app.hpp
src/nrf_app/nrf_app.hpp
+77
-75
src/nrf_app/nrf_client.cpp
src/nrf_app/nrf_client.cpp
+58
-54
src/nrf_app/nrf_client.hpp
src/nrf_app/nrf_client.hpp
+20
-18
src/nrf_app/nrf_config.cpp
src/nrf_app/nrf_config.cpp
+40
-38
src/nrf_app/nrf_config.hpp
src/nrf_app/nrf_config.hpp
+4
-4
src/nrf_app/nrf_event.cpp
src/nrf_app/nrf_event.cpp
+8
-9
src/nrf_app/nrf_event.hpp
src/nrf_app/nrf_event.hpp
+10
-10
src/nrf_app/nrf_event_sig.hpp
src/nrf_app/nrf_event_sig.hpp
+10
-10
src/nrf_app/nrf_jwt.cpp
src/nrf_app/nrf_jwt.cpp
+14
-18
src/nrf_app/nrf_jwt.hpp
src/nrf_app/nrf_jwt.hpp
+14
-16
src/nrf_app/nrf_profile.cpp
src/nrf_app/nrf_profile.cpp
+156
-120
src/nrf_app/nrf_profile.hpp
src/nrf_app/nrf_profile.hpp
+77
-78
src/nrf_app/nrf_search_result.cpp
src/nrf_app/nrf_search_result.cpp
+23
-17
src/nrf_app/nrf_search_result.hpp
src/nrf_app/nrf_search_result.hpp
+14
-14
src/nrf_app/nrf_subscription.cpp
src/nrf_app/nrf_subscription.cpp
+22
-22
src/nrf_app/nrf_subscription.hpp
src/nrf_app/nrf_subscription.hpp
+16
-16
src/nrf_app/task_manager.cpp
src/nrf_app/task_manager.cpp
+7
-5
No files found.
src/.clang-format
0 → 100644
View file @
7d14dd54
#
# Copyright (c) 2015, EURECOM (www.eurecom.fr)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and documentation are those
# of the authors and should not be interpreted as representing official policies,
# either expressed or implied, of the FreeBSD Project.
#
# see https://clang.llvm.org/docs/ClangFormatStyleOptions.html for explanation
# of style options
BasedOnStyle: Google
Language: Cpp
IndentWidth: 2
ColumnLimit: 80
IncludeBlocks: Preserve
SortIncludes: false
# alignment
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
DerivePointerAlignment: false
PointerAlignment: Left
# function style
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakAfterReturnType: None
IndentWrappedFunctionNames: false
# template style
AlwaysBreakTemplateDeclarations: Yes
# preprocessor style
IndentPPDirectives: None
# block style
AllowShortBlocksOnASingleLine: false
KeepEmptyLinesAtTheStartOfBlocks: false
# break style
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
BreakStringLiterals: true
CompactNamespaces: false
ContinuationIndentWidth: 4
MaxEmptyLinesToKeep: 1
ReflowComments: true
# spacing style
UseTab: Never
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
# class style
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
# case statements
IndentCaseLabels: true
# cpp
Cpp11BracedListStyle: true
FixNamespaceComments: true
NamespaceIndentation: None
SortUsingDeclarations: true
# todo
# AlwaysBreakBeforeMultilineStrings: bool
# PenaltyBreakAssignment (unsigned)
# PenaltyBreakBeforeFirstCallParameter (unsigned)
# PenaltyBreakComment (unsigned)
# PenaltyBreakFirstLessLess (unsigned)
# PenaltyBreakString (unsigned)
# PenaltyBreakTemplateDeclaration (unsigned)
# PenaltyExcessCharacter (unsigned)
# PenaltyReturnTypeOnItsOwnLine (unsigned)
src/common/nrf.h
View file @
7d14dd54
...
...
@@ -24,7 +24,7 @@
#define HEART_BEAT_TIMER 10
#define _unused(x) ((void)(x))
#define _unused(x) ((void)
(x))
typedef
enum
nf_type_s
{
NF_TYPE_NRF
=
0
,
...
...
@@ -73,14 +73,14 @@ static const std::vector<std::string> patch_op_type_e2str = {
typedef
uint32_t
evsub_id_t
;
#define EVSUB_ID_FMT "0x%" PRIx32
#define EVSUB_ID_SCAN_FMT SCNx32
#define INVALID_EVSUB_ID ((evsub_id_t)0x00000000)
#define UNASSIGNED_EVSUB_ID ((evsub_id_t)0x00000000)
#define INVALID_EVSUB_ID ((evsub_id_t)
0x00000000)
#define UNASSIGNED_EVSUB_ID ((evsub_id_t)
0x00000000)
#define NNRF_NFM_BASE "/nnrf-nfm/"
#define NNRF_NFM_NF_INSTANCE "/nf-instances/"
#define NF_CURL_TIMEOUT_MS 1000L
#define MAX_WAIT_MSECS 20000
//
1 second
#define MAX_WAIT_MSECS 20000
//
1 second
#endif
src/nrf_app/nrf_app.cpp
100755 → 100644
View file @
7d14dd54
...
...
@@ -53,13 +53,13 @@ using namespace oai::nrf::app;
using
namespace
oai
::
nrf
::
model
;
using
namespace
std
::
chrono
;
extern
nrf_app
*
nrf_app_inst
;
extern
nrf_app
*
nrf_app_inst
;
extern
nrf_config
nrf_cfg
;
nrf_client
*
nrf_client_inst
=
nullptr
;
nrf_jwt
*
nrf_jwt_inst
=
nullptr
;
nrf_client
*
nrf_client_inst
=
nullptr
;
nrf_jwt
*
nrf_jwt_inst
=
nullptr
;
//------------------------------------------------------------------------------
nrf_app
::
nrf_app
(
const
std
::
string
&
config_file
,
nrf_event
&
ev
)
nrf_app
::
nrf_app
(
const
std
::
string
&
config_file
,
nrf_event
&
ev
)
:
m_event_sub
(
ev
),
m_instance_id2nrf_profile
(),
m_subscription_id2nrf_subscription
(),
...
...
@@ -69,7 +69,7 @@ nrf_app::nrf_app(const std::string &config_file, nrf_event &ev)
try
{
nrf_client_inst
=
new
nrf_client
(
ev
);
nrf_jwt_inst
=
new
nrf_jwt
();
}
catch
(
std
::
exception
&
e
)
{
}
catch
(
std
::
exception
&
e
)
{
Logger
::
nrf_app
().
error
(
"Cannot create NRF_APP: %s"
,
e
.
what
());
throw
;
}
...
...
@@ -95,10 +95,10 @@ void nrf_app::generate_uuid() {
//------------------------------------------------------------------------------
void
nrf_app
::
handle_register_nf_instance
(
const
std
::
string
&
nf_instance_id
,
const
oai
::
nrf
::
model
::
NFProfile
&
nf_profile
,
int
&
http_code
,
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
)
{
oai
::
nrf
::
model
::
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle Register NF Instance/Update NF Instance (HTTP version %d)"
,
http_version
);
...
...
@@ -106,8 +106,8 @@ void nrf_app::handle_register_nf_instance(
// Check if nfInstanceID is a valid UUID (version 4)
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
());
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
;
...
...
@@ -115,8 +115,8 @@ void nrf_app::handle_register_nf_instance(
nf_type_t
type
=
api_conv
::
string_to_nf_type
(
nf_profile
.
getNfType
());
// Create a new NF profile or Update an existing NF profile
Logger
::
nrf_app
().
debug
(
"NF Profile with ID %s, NF type %s"
,
nf_instance_id
.
c_str
(),
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
=
{};
...
...
@@ -133,7 +133,9 @@ void nrf_app::handle_register_nf_instance(
sn
=
std
::
make_shared
<
upf_profile
>
(
m_event_sub
);
}
break
;
default:
{
sn
=
std
::
make_shared
<
nrf_profile
>
(
m_event_sub
);
}
default:
{
sn
=
std
::
make_shared
<
nrf_profile
>
(
m_event_sub
);
}
}
// convert to nrf_profile
...
...
@@ -176,11 +178,11 @@ 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
,
oai
::
nrf
::
model
::
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle Update NF Instance request (HTTP version %d)"
,
http_version
);
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
);
// Find the profile corresponding to the instance ID
std
::
shared_ptr
<
nrf_profile
>
sn
=
{};
...
...
@@ -194,8 +196,8 @@ void nrf_app::handle_update_nf_instance(
// 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
());
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
]);
...
...
@@ -286,8 +288,8 @@ void nrf_app::handle_update_nf_instance(
}
}
else
{
Logger
::
nrf_app
().
debug
(
"NF Profile with ID %s does not exit"
,
nf_instance_id
.
c_str
());
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
]);
...
...
@@ -296,9 +298,9 @@ void nrf_app::handle_update_nf_instance(
//------------------------------------------------------------------------------
void
nrf_app
::
handle_get_nf_instances
(
const
std
::
string
&
nf_type
,
std
::
vector
<
std
::
string
>
&
uris
,
const
uint32_t
&
limit_item
,
int
&
http_code
,
const
uint8_t
http_version
,
oai
::
nrf
::
model
::
ProblemDetails
&
problem_details
)
{
const
std
::
string
&
nf_type
,
std
::
vector
<
std
::
string
>&
uris
,
const
uint32_t
&
limit_item
,
int
&
http_code
,
const
uint8_t
http_version
,
oai
::
nrf
::
model
::
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle Retrieve a collection of NF Instances (HTTP version %d)"
,
http_version
);
...
...
@@ -329,7 +331,7 @@ void nrf_app::handle_get_nf_instances(
// TODO: use the first IP addr
if
(
profile_addresses
.
size
()
>
0
)
{
instance_uri
=
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
profile_addresses
[
0
])));
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
profile_addresses
[
0
])));
uris
.
push_back
(
instance_uri
);
}
profile
.
get
()
->
display
();
...
...
@@ -337,12 +339,12 @@ void nrf_app::handle_get_nf_instances(
}
//------------------------------------------------------------------------------
void
nrf_app
::
handle_get_nf_instance
(
const
std
::
string
&
nf_instance_id
,
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle Retrieve an NF Instance (HTTP version %d)"
,
http_version
);
void
nrf_app
::
handle_get_nf_instance
(
const
std
::
string
&
nf_instance_id
,
std
::
shared_ptr
<
nrf_profile
>&
profile
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle Retrieve an NF Instance (HTTP version %d)"
,
http_version
);
// TODO: If the NF Service Consumer is not allowed to retrieve the NF profile
// of this specific registered NF instance, the NRF shall return "403
...
...
@@ -350,15 +352,15 @@ void nrf_app::handle_get_nf_instance(const std::string &nf_instance_id,
profile
=
find_nf_profile
(
nf_instance_id
);
if
(
profile
.
get
()
==
nullptr
)
{
Logger
::
nrf_app
().
debug
(
"Profile with profile ID %s not found"
,
nf_instance_id
.
c_str
());
Logger
::
nrf_app
().
debug
(
"Profile with profile ID %s not found"
,
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
]);
return
;
}
else
{
Logger
::
nrf_app
().
debug
(
"Profile with profile ID %s"
,
nf_instance_id
.
c_str
());
Logger
::
nrf_app
().
debug
(
"Profile with profile ID %s"
,
nf_instance_id
.
c_str
());
profile
.
get
()
->
display
();
http_code
=
HTTP_STATUS_CODE_200_OK
;
return
;
...
...
@@ -366,12 +368,11 @@ void nrf_app::handle_get_nf_instance(const std::string &nf_instance_id,
}
//------------------------------------------------------------------------------
void
nrf_app
::
handle_deregister_nf_instance
(
const
std
::
string
&
nf_instance_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle Deregister an NF Instance (HTTP version %d)"
,
http_version
);
void
nrf_app
::
handle_deregister_nf_instance
(
const
std
::
string
&
nf_instance_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle Deregister an NF Instance (HTTP version %d)"
,
http_version
);
std
::
shared_ptr
<
nrf_profile
>
profile
=
{};
profile
=
find_nf_profile
(
nf_instance_id
);
...
...
@@ -382,8 +383,8 @@ void nrf_app::handle_deregister_nf_instance(const std::string &nf_instance_id,
m_event_sub
.
nf_status_deregistered
(
profile
);
// from nrf_app
if
(
remove_nf_profile
(
nf_instance_id
))
{
Logger
::
nrf_app
().
debug
(
"Removed NF profile with profile ID %s"
,
nf_instance_id
.
c_str
());
Logger
::
nrf_app
().
debug
(
"Removed NF profile with profile ID %s"
,
nf_instance_id
.
c_str
());
http_code
=
HTTP_STATUS_CODE_204_NO_CONTENT
;
return
;
}
else
{
...
...
@@ -393,8 +394,8 @@ void nrf_app::handle_deregister_nf_instance(const std::string &nf_instance_id,
return
;
}
}
else
{
Logger
::
nrf_app
().
debug
(
"Profile with profile ID %s not found"
,
nf_instance_id
.
c_str
());
Logger
::
nrf_app
().
debug
(
"Profile with profile ID %s not found"
,
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
]);
...
...
@@ -404,13 +405,13 @@ void nrf_app::handle_deregister_nf_instance(const std::string &nf_instance_id,
//------------------------------------------------------------------------------
void
nrf_app
::
handle_create_subscription
(
const
SubscriptionData
&
subscription_data
,
std
::
string
&
sub_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
const
SubscriptionData
&
subscription_data
,
std
::
string
&
sub_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
std
::
string
evsub_id
;
Logger
::
nrf_app
().
info
(
"Handle Create a new subscription (HTTP version %d)"
,
http_version
);
Logger
::
nrf_app
().
info
(
"Handle Create a new subscription (HTTP version %d)"
,
http_version
);
std
::
shared_ptr
<
nrf_subscription
>
ss
=
std
::
make_shared
<
nrf_subscription
>
(
m_event_sub
);
...
...
@@ -452,10 +453,9 @@ void nrf_app::handle_create_subscription(
}
//------------------------------------------------------------------------------
void
nrf_app
::
handle_remove_subscription
(
const
std
::
string
&
sub_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
void
nrf_app
::
handle_remove_subscription
(
const
std
::
string
&
sub_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle Remove an existing subscription (HTTP version %d)"
,
http_version
);
...
...
@@ -472,9 +472,9 @@ void nrf_app::handle_remove_subscription(const std::string &sub_id,
//------------------------------------------------------------------------------
void
nrf_app
::
handle_update_subscription
(
const
std
::
string
&
sub_id
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
const
std
::
string
&
sub_id
,
const
std
::
vector
<
PatchItem
>&
patchItem
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle an Update of subscription to NF Instance (HTTP version %d)"
,
http_version
);
...
...
@@ -492,8 +492,8 @@ void nrf_app::handle_update_subscription(
// 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
());
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
]);
...
...
@@ -515,14 +515,14 @@ void nrf_app::handle_update_subscription(
boost
::
posix_time
::
ptime
pt
(
boost
::
posix_time
::
from_iso_string
(
p
.
getValue
()));
ss
.
get
()
->
set_validity_time
(
pt
);
Logger
::
nrf_app
().
debug
(
"New validity time: %s"
,
p
.
getValue
().
c_str
());
Logger
::
nrf_app
().
debug
(
"New validity time: %s"
,
p
.
getValue
().
c_str
());
Logger
::
nrf_app
().
debug
(
"Updated a subscription to the DB"
);
// display the info
ss
.
get
()
->
display
();
http_code
=
HTTP_STATUS_CODE_204_NO_CONTENT
;
op_success
=
true
;
}
catch
(
std
::
exception
&
e
)
{
}
catch
(
std
::
exception
&
e
)
{
std
::
cout
<<
" Exception: "
<<
e
.
what
()
<<
std
::
endl
;
}
}
...
...
@@ -540,8 +540,8 @@ void nrf_app::handle_update_subscription(
}
}
}
else
{
Logger
::
nrf_app
().
debug
(
"Subscription with ID %s does not exit"
,
sub_id
.
c_str
());
Logger
::
nrf_app
().
debug
(
"Subscription with ID %s does not exit"
,
sub_id
.
c_str
());
http_code
=
HTTP_STATUS_CODE_404_NOT_FOUND
;
problem_details
.
setCause
(
protocol_application_error_e2str
[
SUBSCRIPTION_NOT_FOUND
]);
...
...
@@ -550,17 +550,17 @@ void nrf_app::handle_update_subscription(
//------------------------------------------------------------------------------
void
nrf_app
::
handle_search_nf_instances
(
const
std
::
string
&
target_nf_type
,
const
std
::
string
&
requester_nf_type
,
const
std
::
string
&
requester_nf_instance_id
,
uint32_t
&
limit_nfs
,
std
::
string
&
search_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
const
std
::
string
&
target_nf_type
,
const
std
::
string
&
requester_nf_type
,
const
std
::
string
&
requester_nf_instance_id
,
uint32_t
&
limit_nfs
,
std
::
string
&
search_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle NFDiscover to discover the set of NF Instances (HTTP version %d)"
,
http_version
);
// Check if requester is allowed to discover the NF services
if
(
!
is_service_discover_allowed
(
requester_nf_instance_id
,
requester_nf_type
))
{
if
(
!
is_service_discover_allowed
(
requester_nf_instance_id
,
requester_nf_type
))
{
http_code
=
HTTP_STATUS_CODE_403_FORBIDDEN
;
Logger
::
nrf_app
().
debug
(
"Requester (instance id %s) is not allowed to discover the NF "
...
...
@@ -609,18 +609,17 @@ void nrf_app::handle_search_nf_instances(
ss
.
get
()
->
set_validity_period
(
100000
);
// 100s
// add to the DB
add_search_result
(
search_id
,
ss
);
Logger
::
nrf_app
().
debug
(
"Added a search result with ID %s to the DB"
,
search_id
.
c_str
());
Logger
::
nrf_app
().
debug
(
"Added a search result with ID %s to the DB"
,
search_id
.
c_str
());
ss
.
get
()
->
display
();
http_code
=
HTTP_STATUS_CODE_200_OK
;
}
//------------------------------------------------------------------------------
void
nrf_app
::
handle_access_token_request
(
const
std
::
string
&
request_body
,
AccessTokenRsp
&
access_token_rsp
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
void
nrf_app
::
handle_access_token_request
(
const
std
::
string
&
request_body
,
AccessTokenRsp
&
access_token_rsp
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
)
{
Logger
::
nrf_app
().
info
(
"Handle a request to request an OAuth2 access token from NRF (HTTP "
"version %d)"
,
...
...
@@ -629,7 +628,8 @@ void nrf_app::handle_access_token_request(const std::string &request_body,
std
::
map
<
std
::
string
,
std
::
string
>
access_token_req
;
// Process request_body
std
::
vector
<
std
::
string
>
key_values
;
boost
::
split
(
key_values
,
request_body
,
boost
::
is_any_of
(
"&"
),
boost
::
split
(
key_values
,
request_body
,
boost
::
is_any_of
(
"&"
),
boost
::
token_compress_on
);
for
(
auto
p
:
key_values
)
{
std
::
vector
<
std
::
string
>
key_value
;
...
...
@@ -641,8 +641,8 @@ void nrf_app::handle_access_token_request(const std::string &request_body,
access_token_req
[
key_value
[
0
]]
=
key_value
[
1
];
}
Logger
::
nrf_app
().
debug
(
"(Key, Value): %s, %s"
,
key_value
[
0
].
c_str
(),
key_value
[
1
].
c_str
());
Logger
::
nrf_app
().
debug
(
"(Key, Value): %s, %s"
,
key_value
[
0
].
c_str
(),
key_value
[
1
].
c_str
());
}
// validate the Access Token Request
...
...
@@ -695,8 +695,8 @@ void nrf_app::handle_access_token_request(const std::string &request_body,
}
//------------------------------------------------------------------------------
bool
nrf_app
::
add_nf_profile
(
const
std
::
string
&
profile_id
,
const
std
::
shared_ptr
<
nrf_profile
>
&
p
)
{
bool
nrf_app
::
add_nf_profile
(
const
std
::
string
&
profile_id
,
const
std
::
shared_ptr
<
nrf_profile
>&
p
)
{
/*
//if profile with this id exist, update
if (instance_id2nrf_profile.count(profile_id) > 0) {
...
...
@@ -720,14 +720,14 @@ bool nrf_app::add_nf_profile(const std::string &profile_id,
}
//------------------------------------------------------------------------------
bool
nrf_app
::
update_nf_profile
(
const
std
::
string
&
profile_id
,
const
std
::
shared_ptr
<
nrf_profile
>
&
p
)
{
bool
nrf_app
::
update_nf_profile
(
const
std
::
string
&
profile_id
,
const
std
::
shared_ptr
<
nrf_profile
>&
p
)
{
std
::
unique_lock
lock
(
m_instance_id2nrf_profile
);
// if profile with this id exist, return false
if
(
instance_id2nrf_profile
.
count
(
profile_id
)
>
0
)
{
// if not, update to the list
Logger
::
nrf_app
().
info
(
"Updated the NF profile (profile ID %s)"
,
profile_id
.
c_str
());
Logger
::
nrf_app
().
info
(
"Updated the NF profile (profile ID %s)"
,
profile_id
.
c_str
());
instance_id2nrf_profile
.
at
(
profile_id
)
=
p
;
return
true
;
}
else
{
...
...
@@ -738,7 +738,7 @@ bool nrf_app::update_nf_profile(const std::string &profile_id,
//------------------------------------------------------------------------------
std
::
shared_ptr
<
nrf_profile
>
nrf_app
::
find_nf_profile
(
const
std
::
string
&
profile_id
)
const
{
const
std
::
string
&
profile_id
)
const
{
// Logger::nrf_app().info("Find a NF profile with ID %s", profile_id.c_str());
std
::
shared_lock
lock
(
m_instance_id2nrf_profile
);
...
...
@@ -751,8 +751,8 @@ std::shared_ptr<nrf_profile> nrf_app::find_nf_profile(
}
//------------------------------------------------------------------------------
bool
nrf_app
::
find_nf_profile
(
const
std
::
string
&
profile_id
,
std
::
shared_ptr
<
nrf_profile
>
&
p
)
const
{
bool
nrf_app
::
find_nf_profile
(
const
std
::
string
&
profile_id
,
std
::
shared_ptr
<
nrf_profile
>&
p
)
const
{
// Logger::nrf_app().info("Find a NF profile with ID %s", profile_id.c_str());
std
::
shared_lock
lock
(
m_instance_id2nrf_profile
);
...
...
@@ -767,8 +767,8 @@ bool nrf_app::find_nf_profile(const std::string &profile_id,
//------------------------------------------------------------------------------
void
nrf_app
::
find_nf_profiles
(
const
nf_type_t
&
nf_type
,
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
&
profiles
)
const
{
const
nf_type_t
&
nf_type
,
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
&
profiles
)
const
{
std
::
shared_lock
lock
(
m_instance_id2nrf_profile
);
for
(
auto
profile
:
instance_id2nrf_profile
)
{
if
(
profile
.
second
.
get
()
->
get_nf_type
()
==
nf_type
)
{
...
...
@@ -778,9 +778,9 @@ void nrf_app::find_nf_profiles(
}
//------------------------------------------------------------------------------
bool
nrf_app
::
is_profile_exist
(
const
std
::
string
&
profile_id
)
const
{
Logger
::
nrf_app
().
info
(
"Check if a profile with this ID %s exist"
,
profile_id
.
c_str
());
bool
nrf_app
::
is_profile_exist
(
const
std
::
string
&
profile_id
)
const
{
Logger
::
nrf_app
().
info
(
"Check if a profile with this ID %s exist"
,
profile_id
.
c_str
());
std
::
shared_lock
lock
(
m_instance_id2nrf_profile
);
if
(
instance_id2nrf_profile
.
count
(
profile_id
)
>
0
)
{
...
...
@@ -792,38 +792,38 @@ bool nrf_app::is_profile_exist(const std::string &profile_id) const {
}
//------------------------------------------------------------------------------
bool
nrf_app
::
remove_nf_profile
(
const
std
::
shared_ptr
<
nrf_profile
>
&
snp
)
{
bool
nrf_app
::
remove_nf_profile
(
const
std
::
shared_ptr
<
nrf_profile
>
&
snp
)
{
std
::
string
key
;
snp
.
get
()
->
get_nf_instance_id
(
key
);
std
::
unique_lock
lock
(
m_instance_id2nrf_profile
);
if
(
instance_id2nrf_profile
.
erase
(
key
))
{
Logger
::
nrf_app
().
info
(
"Removed NF profile (ID %s) from the list"
,
key
.
c_str
());
Logger
::
nrf_app
().
info
(
"Removed NF profile (ID %s) from the list"
,
key
.
c_str
());
return
true
;
}
else
{
Logger
::
nrf_app
().
info
(
"Remove_NF_profile, profile not found (ID %s)"
,
key
.
c_str
());
Logger
::
nrf_app
().
info
(
"Remove_NF_profile, profile not found (ID %s)"
,
key
.
c_str
());
return
false
;
}
}
//------------------------------------------------------------------------------
bool
nrf_app
::
remove_nf_profile
(
const
std
::
string
&
profile_id
)
{
bool
nrf_app
::
remove_nf_profile
(
const
std
::
string
&
profile_id
)
{
std
::
unique_lock
lock
(
m_instance_id2nrf_profile
);
if
(
instance_id2nrf_profile
.
erase
(
profile_id
))
{
Logger
::
nrf_app
().
info
(
"Removed NF profile (ID %s) from the list"
,
profile_id
.
c_str
());
Logger
::
nrf_app
().
info
(
"Removed NF profile (ID %s) from the list"
,
profile_id
.
c_str
());
return
true
;
}
else
{
Logger
::
nrf_app
().
info
(
"Remove_NF_profile, profile not found (ID %s)"
,
profile_id
.
c_str
());
Logger
::
nrf_app
().
info
(
"Remove_NF_profile, profile not found (ID %s)"
,
profile_id
.
c_str
());
return
false
;
}
}
//------------------------------------------------------------------------------
bool
nrf_app
::
add_subscription
(
const
std
::
string
&
sub_id
,
const
std
::
shared_ptr
<
nrf_subscription
>
&
s
)
{
bool
nrf_app
::
add_subscription
(
const
std
::
string
&
sub_id
,
const
std
::
shared_ptr
<
nrf_subscription
>&
s
)
{
std
::
unique_lock
lock
(
m_subscription_id2nrf_subscription
);
/*
//if profile with this id exist, update
...
...
@@ -845,11 +845,11 @@ bool nrf_app::add_subscription(const std::string &sub_id,
}
//------------------------------------------------------------------------------
bool
nrf_app
::
remove_subscription
(
const
std
::
string
&
sub_id
)
{
bool
nrf_app
::
remove_subscription
(
const
std
::
string
&
sub_id
)
{
std
::
unique_lock
lock
(
m_subscription_id2nrf_subscription
);
if
(
subscrition_id2nrf_subscription
.
erase
(
sub_id
))
{
Logger
::
nrf_app
().
info
(
"Removed subscription (ID %s) from the list"
,
sub_id
.
c_str
());
Logger
::
nrf_app
().
info
(
"Removed subscription (ID %s) from the list"
,
sub_id
.
c_str
());
return
true
;
}
else
{
Logger
::
nrf_app
().
info
(
...
...
@@ -860,7 +860,7 @@ bool nrf_app::remove_subscription(const std::string &sub_id) {
//------------------------------------------------------------------------------
std
::
shared_ptr
<
nrf_subscription
>
nrf_app
::
find_subscription
(
const
std
::
string
&
sub_id
)
const
{
const
std
::
string
&
sub_id
)
const
{
// Logger::nrf_app().info("Find a subscription with ID %s", sub_id.c_str());
std
::
shared_lock
lock
(
m_subscription_id2nrf_subscription
);
...
...
@@ -895,13 +895,13 @@ void nrf_app::handle_heartbeart_timeout(uint64_t ms) {
//------------------------------------------------------------------------------
bool
nrf_app
::
authorize_subscription
(
const
std
::
shared_ptr
<
nrf_subscription
>
&
s
)
const
{
const
std
::
shared_ptr
<
nrf_subscription
>
&
s
)
const
{
// TODO:
return
true
;
}
//------------------------------------------------------------------------------
void
nrf_app
::
generate_ev_subscription_id
(
std
::
string
&
sub_id
)
{
void
nrf_app
::
generate_ev_subscription_id
(
std
::
string
&
sub_id
)
{
sub_id
=
std
::
to_string
(
evsub_id_generator
.
get_uid
());
}
...
...
@@ -928,17 +928,17 @@ void nrf_app::subscribe_nf_status_registered() {
}
//------------------------------------------------------------------------------
void
nrf_app
::
handle_nf_status_registered
(
const
std
::
string
&
profile_id
)
{
Logger
::
nrf_app
().
info
(
"Handle NF status registered event, profile id %s"
,
profile_id
.
c_str
());
void
nrf_app
::
handle_nf_status_registered
(
const
std
::
string
&
profile_id
)
{
Logger
::
nrf_app
().
info
(
"Handle NF status registered event, profile id %s"
,
profile_id
.
c_str
());
std
::
shared_ptr
<
nrf_profile
>
profile
=
{};
Logger
::
nrf_app
().
info
(
"
\t
Find a NF profile with ID %s"
,
profile_id
.
c_str
());
find_nf_profile
(
profile_id
,
profile
);
if
(
profile
.
get
()
!=
nullptr
)
{
std
::
vector
<
std
::
string
>
notification_uris
=
{};
get_subscription_list
(
profile_id
,
NOTIFICATION_TYPE_NF_REGISTERED
,
notification_uris
);
get_subscription_list
(
profile_id
,
NOTIFICATION_TYPE_NF_REGISTERED
,
notification_uris
);
// send notifications
if
(
notification_uris
.
size
()
>
0
)
nrf_client_inst
->
notify_subscribed_event
(
...
...
@@ -947,8 +947,8 @@ void nrf_app::handle_nf_status_registered(const std::string &profile_id) {
Logger
::
nrf_app
().
debug
(
"
\t
No subscription found"
);
}
else
{
Logger
::
nrf_app
().
error
(
"
\t
NF profile not found, profile id %s"
,
profile_id
.
c_str
());
Logger
::
nrf_app
().
error
(
"
\t
NF profile not found, profile id %s"
,
profile_id
.
c_str
());
}
}
...
...
@@ -962,13 +962,15 @@ void nrf_app::subscribe_nf_status_deregistered() {
//------------------------------------------------------------------------------
void
nrf_app
::
handle_nf_status_deregistered
(
const
std
::
shared_ptr
<
nrf_profile
>
&
p
)
{
Logger
::
nrf_app
().
info
(
"Handle NF status deregistered event, profile id %s"
,
const
std
::
shared_ptr
<
nrf_profile
>&
p
)
{
Logger
::
nrf_app
().
info
(
"Handle NF status deregistered event, profile id %s"
,
p
.
get
()
->
get_nf_instance_id
().
c_str
());
std
::
vector
<
std
::
string
>
notification_uris
=
{};
get_subscription_list
(
p
.
get
()
->
get_nf_instance_id
(),
NOTIFICATION_TYPE_NF_DEREGISTERED
,
notification_uris
);
get_subscription_list
(
p
.
get
()
->
get_nf_instance_id
(),
NOTIFICATION_TYPE_NF_DEREGISTERED
,
notification_uris
);
// send notifications
if
(
notification_uris
.
size
()
>
0
)
nrf_client_inst
->
notify_subscribed_event
(
...
...
@@ -986,7 +988,7 @@ void nrf_app::subscribe_nf_status_profile_changed() {
}
//------------------------------------------------------------------------------
void
nrf_app
::
handle_nf_status_profile_changed
(
const
std
::
string
&
profile_id
)
{
void
nrf_app
::
handle_nf_status_profile_changed
(
const
std
::
string
&
profile_id
)
{
Logger
::
nrf_app
().
info
(
"Handle NF status profile changed event, profile id %s"
,
profile_id
.
c_str
());
...
...
@@ -995,8 +997,8 @@ void nrf_app::handle_nf_status_profile_changed(const std::string &profile_id) {
find_nf_profile
(
profile_id
,
profile
);
if
(
profile
.
get
()
!=
nullptr
)
{
std
::
vector
<
std
::
string
>
notification_uris
=
{};
get_subscription_list
(
profile_id
,
NOTIFICATION_TYPE_NF_PROFILE_CHANGED
,
notification_uris
);
get_subscription_list
(
profile_id
,
NOTIFICATION_TYPE_NF_PROFILE_CHANGED
,
notification_uris
);
// Notification data includes NF profile (other alternative, includes
// profile_changes)
// send notifications
...
...
@@ -1006,15 +1008,15 @@ void nrf_app::handle_nf_status_profile_changed(const std::string &profile_id) {
else
Logger
::
nrf_app
().
debug
(
"
\t
No subscription found"
);
}
else
{
Logger
::
nrf_app
().
error
(
"NF profile not found, profile id %s"
,
profile_id
.
c_str
());
Logger
::
nrf_app
().
error
(
"NF profile not found, profile id %s"
,
profile_id
.
c_str
());
}
}
//------------------------------------------------------------------------------
void
nrf_app
::
get_subscription_list
(
const
std
::
string
&
profile_id
,
const
uint8_t
&
notification_type
,
std
::
vector
<
std
::
string
>
&
uris
)
const
{
void
nrf_app
::
get_subscription_list
(
const
std
::
string
&
profile_id
,
const
uint8_t
&
notification_type
,
std
::
vector
<
std
::
string
>&
uris
)
const
{
Logger
::
nrf_app
().
debug
(
"
\t
Get the list of subscriptions related to this profile, profile id %s"
,
profile_id
.
c_str
());
...
...
@@ -1028,8 +1030,8 @@ void nrf_app::get_subscription_list(const std::string &profile_id,
}
for
(
auto
s
:
subscrition_id2nrf_subscription
)
{
Logger
::
nrf_app
().
info
(
"
\t
Verifying subscription, subscription id %s"
,
s
.
first
.
c_str
());
Logger
::
nrf_app
().
info
(
"
\t
Verifying subscription, subscription id %s"
,
s
.
first
.
c_str
());
std
::
string
uri
;
s
.
second
.
get
()
->
get_notification_uri
(
uri
);
...
...
@@ -1045,8 +1047,8 @@ void nrf_app::get_subscription_list(const std::string &profile_id,
// check validity time
boost
::
posix_time
::
ptime
t
(
boost
::
posix_time
::
microsec_clock
::
local_time
());
Logger
::
nrf_app
().
debug
(
"
\t
Current time %s"
,
boost
::
posix_time
::
to_iso_string
(
t
).
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Current time %s"
,
boost
::
posix_time
::
to_iso_string
(
t
).
c_str
());
if
(
t
>
s
.
second
.
get
()
->
get_validity_time
())
{
Logger
::
nrf_app
().
debug
(
"
\t
This subscription expires, current time %s, validity time %s"
,
...
...
@@ -1063,8 +1065,8 @@ void nrf_app::get_subscription_list(const std::string &profile_id,
case
NF_INSTANCE_ID_COND
:
{
if
(
profile_id
.
compare
(
condition
.
nf_instance_id
)
==
0
)
{
uris
.
push_back
(
uri
);
Logger
::
nrf_app
().
debug
(
"
\t
Subscription id %s, uri %s"
,
s
.
first
.
c_str
(),
uri
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Subscription id %s, uri %s"
,
s
.
first
.
c_str
(),
uri
.
c_str
());
}
}
break
;
...
...
@@ -1072,8 +1074,8 @@ void nrf_app::get_subscription_list(const std::string &profile_id,
std
::
string
nf_type
=
nf_type_e2str
[
profile
.
get
()
->
get_nf_type
()];
if
(
nf_type
.
compare
(
condition
.
nf_type
)
==
0
)
{
uris
.
push_back
(
uri
);
Logger
::
nrf_app
().
debug
(
"
\t
Subscription id %s, uri %s"
,
s
.
first
.
c_str
(),
uri
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Subscription id %s, uri %s"
,
s
.
first
.
c_str
(),
uri
.
c_str
());
}
}
break
;
...
...
@@ -1082,8 +1084,8 @@ void nrf_app::get_subscription_list(const std::string &profile_id,
profile
.
get
()
->
get_nf_instance_name
(
service_name
);
if
(
service_name
.
compare
(
condition
.
service_name
)
==
0
)
{
uris
.
push_back
(
uri
);
Logger
::
nrf_app
().
debug
(
"
\t
Subscription id %s, uri %s"
,
s
.
first
.
c_str
(),
uri
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Subscription id %s, uri %s"
,
s
.
first
.
c_str
(),
uri
.
c_str
());
}
}
break
;
...
...
@@ -1097,8 +1099,8 @@ void nrf_app::get_subscription_list(const std::string &profile_id,
0
)
and
(
info
.
amf_set_id
.
compare
(
condition
.
amf_info
.
amf_set_id
)
==
0
))
{
uris
.
push_back
(
uri
);
Logger
::
nrf_app
().
debug
(
"
\t
Subscription id %s, uri %s"
,
s
.
first
.
c_str
(),
uri
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Subscription id %s, uri %s"
,
s
.
first
.
c_str
(),
uri
.
c_str
());
}
}
}
break
;
...
...
@@ -1125,35 +1127,35 @@ void nrf_app::get_subscription_list(const std::string &profile_id,
//------------------------------------------------------------------------------
bool
nrf_app
::
is_service_discover_allowed
(
const
std
::
string
&
requester_instance_id
,
const
std
::
string
&
requester_nf_type
)
{
const
std
::
string
&
requester_instance_id
,
const
std
::
string
&
requester_nf_type
)
{
// TODO:
return
true
;
}
//------------------------------------------------------------------------------
void
nrf_app
::
generate_search_id
(
std
::
string
&
search_id
)
{
void
nrf_app
::
generate_search_id
(
std
::
string
&
search_id
)
{
search_id
=
std
::
to_string
(
search_id_generator
.
get_uid
());
}
//------------------------------------------------------------------------------
bool
nrf_app
::
add_search_result
(
const
std
::
string
&
id
,
const
std
::
shared_ptr
<
nrf_search_result
>
&
s
)
{
bool
nrf_app
::
add_search_result
(
const
std
::
string
&
id
,
const
std
::
shared_ptr
<
nrf_search_result
>&
s
)
{
std
::
unique_lock
lock
(
m_search_id2search_result
);
// Create or update if search result exist
search_id2search_result
[
id
]
=
s
;
return
true
;
}
bool
nrf_app
::
find_search_result
(
const
std
::
string
&
search_id
,
std
::
shared_ptr
<
nrf_search_result
>
&
s
)
const
{
bool
nrf_app
::
find_search_result
(
const
std
::
string
&
search_id
,
std
::
shared_ptr
<
nrf_search_result
>&
s
)
const
{
std
::
shared_lock
lock
(
m_search_id2search_result
);
if
(
search_id2search_result
.
count
(
search_id
)
>
0
)
{
s
=
search_id2search_result
.
at
(
search_id
);
return
true
;
}
else
{
Logger
::
nrf_app
().
info
(
"Search result (ID %s) not found"
,
search_id
.
c_str
());
Logger
::
nrf_app
().
info
(
"Search result (ID %s) not found"
,
search_id
.
c_str
());
return
false
;
}
}
src/nrf_app/nrf_app.hpp
View file @
7d14dd54
...
...
@@ -50,9 +50,9 @@ using namespace oai::nrf::model;
class
nrf_config
;
class
nrf_app
{
public:
explicit
nrf_app
(
const
std
::
string
&
config_file
,
nrf_event
&
ev
);
nrf_app
(
nrf_app
const
&
)
=
delete
;
void
operator
=
(
nrf_app
const
&
)
=
delete
;
explicit
nrf_app
(
const
std
::
string
&
config_file
,
nrf_event
&
ev
);
nrf_app
(
nrf_app
const
&
)
=
delete
;
void
operator
=
(
nrf_app
const
&
)
=
delete
;
virtual
~
nrf_app
();
...
...
@@ -72,10 +72,10 @@ class nrf_app {
* @param [ProblemDetails &] problem_details: Store details of the error
* @return void
*/
void
handle_register_nf_instance
(
const
std
::
string
&
nf_instance_id
,
const
NFProfile
&
nf_profile
,
int
&
http_cod
e
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
void
handle_register_nf_instance
(
const
std
::
string
&
nf_instance_id
,
const
NFProfile
&
nf_profil
e
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
/*
* Handle a Get NF Instance Information
...
...
@@ -90,9 +90,9 @@ class nrf_app {
* @return void
*/
void
handle_get_nf_instances
(
const
std
::
string
&
nf_type
,
std
::
vector
<
std
::
string
>
&
uris
,
const
uint32_t
&
limit_item
,
int
&
http_code
,
const
uint8_t
http_version
,
oai
::
nrf
::
model
::
ProblemDetails
&
problem_details
);
const
std
::
string
&
nf_type
,
std
::
vector
<
std
::
string
>&
uris
,
const
uint32_t
&
limit_item
,
int
&
http_code
,
const
uint8_t
http_version
,
oai
::
nrf
::
model
::
ProblemDetails
&
problem_details
);
/*
* Handle a Update NF Instance request
...
...
@@ -104,10 +104,10 @@ class nrf_app {
* @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
,
ProblemDetails
&
problem_details
);
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
);
/*
* Handle a Get NF Instance request
...
...
@@ -118,10 +118,10 @@ class nrf_app {
* @param [ProblemDetails &] problem_details: Store details of the error
* @return void
*/
void
handle_get_nf_instance
(
const
std
::
string
&
nf_instance_id
,
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
void
handle_get_nf_instance
(
const
std
::
string
&
nf_instance_id
,
std
::
shared_ptr
<
nrf_profile
>&
profile
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
/*
* Handle De-register a given NF Instance
...
...
@@ -131,9 +131,9 @@ class nrf_app {
* @param [ProblemDetails &] problem_details: Store details of the error
* @return void
*/
void
handle_deregister_nf_instance
(
const
std
::
string
&
nf_instance_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
void
handle_deregister_nf_instance
(
const
std
::
string
&
nf_instance_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
/*
* Handle a Register NF Instance request
...
...
@@ -144,10 +144,10 @@ class nrf_app {
* @param [ProblemDetails &] problem_details: Store details of the error
* @return void
*/
void
handle_create_subscription
(
const
SubscriptionData
&
subscription_data
,
std
::
string
&
sub_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
void
handle_create_subscription
(
const
SubscriptionData
&
subscription_data
,
std
::
string
&
sub_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
/*
* Handle a NFStatusUnSubscribe request (removes an existing subscription)
...
...
@@ -157,9 +157,9 @@ class nrf_app {
* @param [ProblemDetails &] problem_details: Store details of the error
* @return void
*/
void
handle_remove_subscription
(
const
std
::
string
&
sub_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
void
handle_remove_subscription
(
const
std
::
string
&
sub_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
/*
* Handle a Update of Subscription to NF Instances
...
...
@@ -171,10 +171,10 @@ class nrf_app {
* @param [ProblemDetails &] problem_details: Store details of the error
* @return void
*/
void
handle_update_subscription
(
const
std
::
string
&
sub_id
,
const
std
::
vector
<
PatchItem
>
&
patchItem
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
void
handle_update_subscription
(
const
std
::
string
&
sub_id
,
const
std
::
vector
<
PatchItem
>&
patchItem
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
/*
* Handle NFDiscover to discover the set of NF Instances
...
...
@@ -190,12 +190,11 @@ class nrf_app {
* @param [ProblemDetails &] problem_details: Store details of the error
* @return void
*/
void
handle_search_nf_instances
(
const
std
::
string
&
target_nf_type
,
const
std
::
string
&
requester_nf_type
,
const
std
::
string
&
requester_nf_instance_id
,
uint32_t
&
limit_nfs
,
std
::
string
&
search_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
void
handle_search_nf_instances
(
const
std
::
string
&
target_nf_type
,
const
std
::
string
&
requester_nf_type
,
const
std
::
string
&
requester_nf_instance_id
,
uint32_t
&
limit_nfs
,
std
::
string
&
search_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
/*
* Handle a Register NF Instance request
...
...
@@ -206,10 +205,10 @@ class nrf_app {
* @param [ProblemDetails &] problem_details: Store details of the error
* @return void
*/
void
handle_access_token_request
(
const
std
::
string
&
request_body
,
AccessTokenRsp
&
access_token_rsp
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
void
handle_access_token_request
(
const
std
::
string
&
request_body
,
AccessTokenRsp
&
access_token_rsp
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
/*
* Insert a nrf profile
...
...
@@ -217,8 +216,8 @@ class nrf_app {
* @param [std::shared_ptr<nrf_profile> &] p: profile to be added
* @return true if successful, otherwise, return false
*/
bool
add_nf_profile
(
const
std
::
string
&
profile_id
,
const
std
::
shared_ptr
<
nrf_profile
>
&
p
);
bool
add_nf_profile
(
const
std
::
string
&
profile_id
,
const
std
::
shared_ptr
<
nrf_profile
>&
p
);
/*
* Update a nrf profile
...
...
@@ -226,8 +225,8 @@ class nrf_app {
* @param [std::shared_ptr<nrf_profile> &] p: profile to be added
* @return true if successful, otherwise, return false
*/
bool
update_nf_profile
(
const
std
::
string
&
profile_id
,
const
std
::
shared_ptr
<
nrf_profile
>
&
p
);
bool
update_nf_profile
(
const
std
::
string
&
profile_id
,
const
std
::
shared_ptr
<
nrf_profile
>&
p
);
/*
* Find a nf profile with its ID
...
...
@@ -235,15 +234,15 @@ class nrf_app {
* @return shared pointer to the profile if found
*/
std
::
shared_ptr
<
nrf_profile
>
find_nf_profile
(
const
std
::
string
&
profile_id
)
const
;
const
std
::
string
&
profile_id
)
const
;
/*
* Find a nf profile with its ID
* @param [const std::string &] profile_id: Profile ID
* @return shared pointer to the profile if found
*/
bool
find_nf_profile
(
const
std
::
string
&
profile_id
,
std
::
shared_ptr
<
nrf_profile
>
&
p
)
const
;
bool
find_nf_profile
(
const
std
::
string
&
profile_id
,
std
::
shared_ptr
<
nrf_profile
>&
p
)
const
;
/*
* Find a list of nf profiles with a type
...
...
@@ -253,29 +252,29 @@ class nrf_app {
* @return shared pointer to the profile if found
*/
void
find_nf_profiles
(
const
nf_type_t
&
nf_type
,
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
&
profiles
)
const
;
const
nf_type_t
&
nf_type
,
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
&
profiles
)
const
;
/*
* Check if a profile with an ID exist
* @param [const std::string &] profile_id: Profile ID
* @return true if profile exist, otherwise, return false
*/
bool
is_profile_exist
(
const
std
::
string
&
profile_id
)
const
;
bool
is_profile_exist
(
const
std
::
string
&
profile_id
)
const
;
/*
* Remove a nf profile from the list
* @param [std::shared_ptr<nrf_profile> &] snp: profile to be removed
* @return true if successful, otherwise, return false
*/
bool
remove_nf_profile
(
const
std
::
shared_ptr
<
nrf_profile
>
&
snp
);
bool
remove_nf_profile
(
const
std
::
shared_ptr
<
nrf_profile
>
&
snp
);
/*
* Remove a nf profile from the list
* @param [std::string &] profile_id: ID of the profile to be removed
* @return true if successful, otherwise, return false
*/
bool
remove_nf_profile
(
const
std
::
string
&
profile_id
);
bool
remove_nf_profile
(
const
std
::
string
&
profile_id
);
/*
* Add a subscription
...
...
@@ -284,15 +283,15 @@ class nrf_app {
* subscription to be added
* @return true if successful, otherwise, return false
*/
bool
add_subscription
(
const
std
::
string
&
sub_id
,
const
std
::
shared_ptr
<
nrf_subscription
>
&
s
);
bool
add_subscription
(
const
std
::
string
&
sub_id
,
const
std
::
shared_ptr
<
nrf_subscription
>&
s
);
/*
* Remove a subscription from the list
* @param [std::string &] sub_id: ID of the subscription to be removed
* @return true if successful, otherwise, return false
*/
bool
remove_subscription
(
const
std
::
string
&
sub_id
);
bool
remove_subscription
(
const
std
::
string
&
sub_id
);
/*
* Find a subscription with its ID
...
...
@@ -300,7 +299,7 @@ class nrf_app {
* @return shared pointer to the subscription if found, otherwise nullptr
*/
std
::
shared_ptr
<
nrf_subscription
>
find_subscription
(
const
std
::
string
&
sub_id
)
const
;
const
std
::
string
&
sub_id
)
const
;
/*
* Subscribe to the task tick event
...
...
@@ -322,14 +321,14 @@ class nrf_app {
* subscription
* @return true if this sub is authorized, otherwise, return false
*/
bool
authorize_subscription
(
const
std
::
shared_ptr
<
nrf_subscription
>
&
s
)
const
;
bool
authorize_subscription
(
const
std
::
shared_ptr
<
nrf_subscription
>
&
s
)
const
;
/*
* Generate an unique ID for the new subscription
* @param [const std::string &] sub_id: the generated ID
* @return void
*/
void
generate_ev_subscription_id
(
std
::
string
&
sub_id
);
void
generate_ev_subscription_id
(
std
::
string
&
sub_id
);
/*
* Generate an unique ID for the new subscription
...
...
@@ -357,7 +356,7 @@ class nrf_app {
* @param [const std::string &] profile_id: Profile ID of the registered NF
* @return void
*/
void
handle_nf_status_registered
(
const
std
::
string
&
profile_id
);
void
handle_nf_status_registered
(
const
std
::
string
&
profile_id
);
/*
* Subscribe to the event when a NF de-registers from the NRF
...
...
@@ -368,10 +367,11 @@ class nrf_app {
/*
* Handle NF status deregistered event
* @param [const std::shared_ptr<nrf_profile> &] profile: pointer to the deregistered NF
* @param [const std::shared_ptr<nrf_profile> &] profile: pointer to the
* deregistered NF
* @return void
*/
void
handle_nf_status_deregistered
(
const
std
::
shared_ptr
<
nrf_profile
>
&
p
);
void
handle_nf_status_deregistered
(
const
std
::
shared_ptr
<
nrf_profile
>
&
p
);
/*
* Subscribe to the event when a registered NF changes its profile
...
...
@@ -385,7 +385,7 @@ class nrf_app {
* @param [const std::string &] profile_id: Profile ID of the NF
* @return void
*/
void
handle_nf_status_profile_changed
(
const
std
::
string
&
profile_id
);
void
handle_nf_status_profile_changed
(
const
std
::
string
&
profile_id
);
/*
* Get the list of subscriptions to the profile with notification type
...
...
@@ -395,9 +395,9 @@ class nrf_app {
* subscribed NFs
* @return void
*/
void
get_subscription_list
(
const
std
::
string
&
profile_id
,
const
uint8_t
&
notification_type
,
std
::
vector
<
std
::
string
>
&
uris
)
const
;
void
get_subscription_list
(
const
std
::
string
&
profile_id
,
const
uint8_t
&
notification_type
,
std
::
vector
<
std
::
string
>&
uris
)
const
;
/*
* Verify whether the requester is allowed to discover the NF services
...
...
@@ -405,15 +405,16 @@ class nrf_app {
* @param [const std::string &] requester_nf_type: Requester nf type
* @return void
*/
bool
is_service_discover_allowed
(
const
std
::
string
&
requester_instance_id
,
const
std
::
string
&
requester_nf_type
);
bool
is_service_discover_allowed
(
const
std
::
string
&
requester_instance_id
,
const
std
::
string
&
requester_nf_type
);
/*
* Generate an unique ID for the search result
* @param [const std::string &] search_id: the generated search ID
* @return void
*/
void
generate_search_id
(
std
::
string
&
search_id
);
void
generate_search_id
(
std
::
string
&
search_id
);
/*
* Add a search result to the DB
...
...
@@ -422,8 +423,8 @@ class nrf_app {
* search result
* @return void
*/
bool
add_search_result
(
const
std
::
string
&
id
,
const
std
::
shared_ptr
<
nrf_search_result
>
&
s
);
bool
add_search_result
(
const
std
::
string
&
id
,
const
std
::
shared_ptr
<
nrf_search_result
>&
s
);
/*
* Find a search result with its ID
...
...
@@ -432,8 +433,9 @@ class nrf_app {
* result
* @return true if found, otherwise false
*/
bool
find_search_result
(
const
std
::
string
&
search_id
,
std
::
shared_ptr
<
nrf_search_result
>
&
p
)
const
;
bool
find_search_result
(
const
std
::
string
&
search_id
,
std
::
shared_ptr
<
nrf_search_result
>&
p
)
const
;
private:
std
::
string
nrf_instance_id
;
// NRF instance id
...
...
@@ -443,7 +445,7 @@ class nrf_app {
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
nrf_subscription
>>
subscrition_id2nrf_subscription
;
mutable
std
::
shared_mutex
m_subscription_id2nrf_subscription
;
nrf_event
&
m_event_sub
;
nrf_event
&
m_event_sub
;
util
::
uint_generator
<
uint32_t
>
evsub_id_generator
;
std
::
vector
<
bs2
::
connection
>
connections
;
...
...
src/nrf_app/nrf_client.cpp
View file @
7d14dd54
...
...
@@ -45,20 +45,20 @@ using namespace Pistache::Http::Mime;
using
namespace
oai
::
nrf
::
app
;
using
json
=
nlohmann
::
json
;
extern
nrf_client
*
nrf_client_inst
;
extern
nrf_client
*
nrf_client_inst
;
extern
nrf_config
nrf_cfg
;
//------------------------------------------------------------------------------
// To read content of the response from NF
static
std
::
size_t
callback
(
const
char
*
in
,
std
::
size_t
size
,
std
::
size_t
num
,
std
::
string
*
out
)
{
static
std
::
size_t
callback
(
const
char
*
in
,
std
::
size_t
size
,
std
::
size_t
num
,
std
::
string
*
out
)
{
const
std
::
size_t
totalBytes
(
size
*
num
);
out
->
append
(
in
,
totalBytes
);
return
totalBytes
;
}
//------------------------------------------------------------------------------
nrf_client
::
nrf_client
(
nrf_event
&
ev
)
:
m_event_sub
(
ev
)
{
nrf_client
::
nrf_client
(
nrf_event
&
ev
)
:
m_event_sub
(
ev
)
{
curl_global_init
(
CURL_GLOBAL_DEFAULT
);
curl_multi
=
curl_multi_init
();
handles
=
{};
...
...
@@ -87,11 +87,11 @@ nrf_client::~nrf_client() {
}
//------------------------------------------------------------------------------
CURL
*
nrf_client
::
curl_create_handle
(
const
std
::
string
&
uri
,
const
std
::
string
&
data
,
std
::
string
&
response_data
)
{
CURL
*
nrf_client
::
curl_create_handle
(
const
std
::
string
&
uri
,
const
std
::
string
&
data
,
std
::
string
&
response_data
)
{
// create handle for a curl request
CURL
*
curl
=
curl_easy_init
();
CURL
*
curl
=
curl_easy_init
();
if
(
curl
)
{
curl_easy_setopt
(
curl
,
CURLOPT_HTTPHEADER
,
headers
);
...
...
@@ -111,12 +111,12 @@ CURL *nrf_client::curl_create_handle(const std::string &uri,
}
//------------------------------------------------------------------------------
void
nrf_client
::
send_curl_multi
(
const
std
::
string
&
uri
,
const
std
::
string
&
data
,
std
::
string
&
response_data
)
{
void
nrf_client
::
send_curl_multi
(
const
std
::
string
&
uri
,
const
std
::
string
&
data
,
std
::
string
&
response_data
)
{
// create a new handle and add to the multi handle
// the curl will actually be sent in perform_curl_multi
CURL
*
tmp
=
curl_create_handle
(
uri
,
data
,
response_data
);
CURL
*
tmp
=
curl_create_handle
(
uri
,
data
,
response_data
);
curl_multi_add_handle
(
curl_multi
,
tmp
);
handles
.
push_back
(
tmp
);
}
...
...
@@ -159,8 +159,8 @@ void nrf_client::wait_curl_end() {
//------------------------------------------------------------------------------
void
nrf_client
::
curl_release_handles
()
{
CURLMsg
*
curl_msg
=
nullptr
;
CURL
*
curl
=
nullptr
;
CURLMsg
*
curl_msg
=
nullptr
;
CURL
*
curl
=
nullptr
;
CURLcode
code
=
{};
int
http_code
=
0
;
int
msgs_left
=
0
;
...
...
@@ -183,7 +183,7 @@ void nrf_client::curl_release_handles() {
curl_multi_remove_handle
(
curl_multi
,
curl
);
curl_easy_cleanup
(
curl
);
std
::
vector
<
CURL
*>::
iterator
it
;
std
::
vector
<
CURL
*>::
iterator
it
;
it
=
find
(
handles
.
begin
(),
handles
.
end
(),
curl
);
if
(
it
!=
handles
.
end
())
{
handles
.
erase
(
it
);
...
...
@@ -195,7 +195,7 @@ void nrf_client::curl_release_handles() {
curl_multi_remove_handle
(
curl_multi
,
curl
);
curl_easy_cleanup
(
curl
);
std
::
vector
<
CURL
*>::
iterator
it
;
std
::
vector
<
CURL
*>::
iterator
it
;
it
=
find
(
handles
.
begin
(),
handles
.
end
(),
curl
);
if
(
it
!=
handles
.
end
())
{
handles
.
erase
(
it
);
...
...
@@ -208,8 +208,8 @@ void nrf_client::curl_release_handles() {
//------------------------------------------------------------------------------
void
nrf_client
::
notify_subscribed_event
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
uint8_t
&
event_type
,
const
std
::
vector
<
std
::
string
>
&
uris
)
{
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
uint8_t
&
event_type
,
const
std
::
vector
<
std
::
string
>
&
uris
)
{
Logger
::
nrf_app
().
debug
(
"Send notification for the subscribed event to the subscriptions"
);
...
...
@@ -222,7 +222,7 @@ void nrf_client::notify_subscribed_event(
profile
.
get
()
->
get_nf_ipv4_addresses
(
instance_addrs
);
// TODO: use the first IPv4 addr for now
std
::
string
instance_uri
=
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
(
instance_addrs
[
0
]))));
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
(
instance_addrs
[
0
]))));
Logger
::
nrf_app
().
debug
(
"NF instance URI: %s"
,
instance_uri
.
c_str
());
json_data
[
"nfInstanceUri"
]
=
instance_uri
;
...
...
@@ -243,7 +243,9 @@ void nrf_client::notify_subscribed_event(
std
::
static_pointer_cast
<
upf_profile
>
(
profile
).
get
()
->
to_json
(
json_profile
);
}
break
;
default:
{
profile
.
get
()
->
to_json
(
json_profile
);
}
default:
{
profile
.
get
()
->
to_json
(
json_profile
);
}
}
json_data
[
"nfProfile"
]
=
json_profile
;
}
...
...
@@ -262,18 +264,18 @@ void nrf_client::notify_subscribed_event(
//------------------------------------------------------------------------------
void
nrf_client
::
notify_subscribed_event_multi
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
uint8_t
&
event_type
,
const
std
::
vector
<
std
::
string
>
&
uris
)
{
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
uint8_t
&
event_type
,
const
std
::
vector
<
std
::
string
>
&
uris
)
{
Logger
::
nrf_app
().
debug
(
"Send notification for the subscribed event to the subscriptions"
);
int
still_running
=
0
,
numfds
=
0
,
res
=
0
,
msgs_left
=
0
;
CURLMsg
*
curl_msg
=
nullptr
;
CURL
*
curl
=
nullptr
;
CURLMsg
*
curl_msg
=
nullptr
;
CURL
*
curl
=
nullptr
;
CURLcode
return_code
=
{};
int
http_status_code
=
0
;
int
index
=
0
;
char
*
curl_url
=
nullptr
;
char
*
curl_url
=
nullptr
;
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
// Fill the json part
nlohmann
::
json
json_data
=
{};
...
...
@@ -283,7 +285,7 @@ void nrf_client::notify_subscribed_event_multi(
profile
.
get
()
->
get_nf_ipv4_addresses
(
instance_addrs
);
// TODO: use the first IPv4 addr for now
std
::
string
instance_uri
=
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
(
instance_addrs
[
0
]))));
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
(
instance_addrs
[
0
]))));
Logger
::
nrf_app
().
debug
(
"NF instance URI: %s"
,
instance_uri
.
c_str
());
json_data
[
"nfInstanceUri"
]
=
instance_uri
;
...
...
@@ -304,7 +306,9 @@ void nrf_client::notify_subscribed_event_multi(
std
::
static_pointer_cast
<
upf_profile
>
(
profile
).
get
()
->
to_json
(
json_profile
);
}
break
;
default:
{
profile
.
get
()
->
to_json
(
json_profile
);
}
default:
{
profile
.
get
()
->
to_json
(
json_profile
);
}
}
json_data
[
"nfProfile"
]
=
json_profile
;
}
...
...
@@ -315,8 +319,8 @@ void nrf_client::notify_subscribed_event_multi(
for
(
auto
uri
:
uris
)
{
curl
=
curl_easy_init
();
if
(
curl
)
{
Logger
::
nrf_app
().
debug
(
"Send notification to NF with URI: %s"
,
uri
.
c_str
());
Logger
::
nrf_app
().
debug
(
"Send notification to NF with URI: %s"
,
uri
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_HTTPHEADER
,
headers
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
uri
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_HTTPPOST
,
1
);
...
...
@@ -366,7 +370,7 @@ void nrf_client::notify_subscribed_event_multi(
curl_multi_remove_handle
(
curl_multi
,
curl
);
curl_easy_cleanup
(
curl
);
std
::
vector
<
CURL
*>::
iterator
it
;
std
::
vector
<
CURL
*>::
iterator
it
;
it
=
find
(
handles
.
begin
(),
handles
.
end
(),
curl
);
if
(
it
!=
handles
.
end
())
{
handles
.
erase
(
it
);
...
...
@@ -375,8 +379,8 @@ void nrf_client::notify_subscribed_event_multi(
}
}
else
{
Logger
::
nrf_app
().
debug
(
"Error after curl_multi_info_read(), CURLMsg %s"
,
curl_msg
->
msg
);
Logger
::
nrf_app
().
debug
(
"Error after curl_multi_info_read(), CURLMsg %s"
,
curl_msg
->
msg
);
}
}
...
...
@@ -392,9 +396,9 @@ void nrf_client::notify_subscribed_event_multi(
//------------------------------------------------------------------------------
void
nrf_client
::
notify_subscribed_event
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
std
::
string
&
uri
)
{
Logger
::
nrf_app
().
debug
(
"Send notification to the subscribed NF (URI %s)"
,
uri
.
c_str
());
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
std
::
string
&
uri
)
{
Logger
::
nrf_app
().
debug
(
"Send notification to the subscribed NF (URI %s)"
,
uri
.
c_str
());
// Fill the json part
nlohmann
::
json
json_data
=
{};
...
...
@@ -404,14 +408,14 @@ void nrf_client::notify_subscribed_event(
profile
.
get
()
->
get_nf_ipv4_addresses
(
instance_addrs
);
// TODO: use the first IPv4 addr for now
std
::
string
instance_uri
=
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
(
instance_addrs
[
0
]))));
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
(
instance_addrs
[
0
]))));
Logger
::
nrf_app
().
debug
(
"NF instance URI: %s"
,
instance_uri
.
c_str
());
json_data
[
"nfInstanceUri"
]
=
instance_uri
;
std
::
string
body
=
json_data
.
dump
();
curl_global_init
(
CURL_GLOBAL_ALL
);
CURL
*
curl
=
curl
=
curl_easy_init
();
struct
curl_slist
*
headers
=
nullptr
;
CURL
*
curl
=
curl
=
curl_easy_init
();
struct
curl_slist
*
headers
=
nullptr
;
if
(
curl
)
{
CURLcode
res
=
{};
...
...
@@ -440,7 +444,7 @@ void nrf_client::notify_subscribed_event(
json
response_data
=
{};
try
{
response_data
=
json
::
parse
(
*
httpData
.
get
());
}
catch
(
json
::
exception
&
e
)
{
}
catch
(
json
::
exception
&
e
)
{
Logger
::
nrf_app
().
warn
(
"Could not get the cause from the response"
);
}
...
...
src/nrf_app/nrf_client.hpp
View file @
7d14dd54
...
...
@@ -41,19 +41,19 @@ namespace app {
class
nrf_client
{
private:
CURLM
*
curl_multi
;
std
::
vector
<
CURL
*>
handles
;
struct
curl_slist
*
headers
;
nrf_event
&
m_event_sub
;
CURLM
*
curl_multi
;
std
::
vector
<
CURL
*>
handles
;
struct
curl_slist
*
headers
;
nrf_event
&
m_event_sub
;
bs2
::
connection
task_connection
;
// connection for performing curl_multi every 1ms
public:
nrf_client
(
nrf_event
&
ev
);
nrf_client
(
nrf_event
&
ev
);
virtual
~
nrf_client
();
nrf_client
(
nrf_client
const
&
)
=
delete
;
void
operator
=
(
nrf_client
const
&
)
=
delete
;
nrf_client
(
nrf_client
const
&
)
=
delete
;
void
operator
=
(
nrf_client
const
&
)
=
delete
;
/*
* Send Notification for the associated event to the subscriber
...
...
@@ -61,8 +61,8 @@ class nrf_client {
* @param [const std::string &] uri: URI of the subscribed NF
* @return void
*/
void
notify_subscribed_event
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
std
::
string
&
uri
);
void
notify_subscribed_event
(
const
std
::
shared_ptr
<
nrf_profile
>&
profile
,
const
std
::
string
&
uri
);
/*
* Send Notification for the associated event to the subscriber
...
...
@@ -71,8 +71,8 @@ class nrf_client {
* @return void
*/
void
notify_subscribed_event_multi
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
uint8_t
&
event_type
,
const
std
::
vector
<
std
::
string
>
&
uris
);
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
uint8_t
&
event_type
,
const
std
::
vector
<
std
::
string
>
&
uris
);
/*
* Send Notification for the associated event to the subscribers
...
...
@@ -81,9 +81,9 @@ class nrf_client {
* @param [const std::vector<std::string> &] uris: list of subscribed NFs' URI
* @return void
*/
void
notify_subscribed_event
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
,
const
uint8_t
&
event_type
,
const
std
::
vector
<
std
::
string
>
&
uris
);
void
notify_subscribed_event
(
const
std
::
shared_ptr
<
nrf_profile
>&
profile
,
const
uint8_t
&
event_type
,
const
std
::
vector
<
std
::
string
>&
uris
);
/*
* Create Curl handle for multi curl
...
...
@@ -92,8 +92,9 @@ class nrf_client {
* @param [std::string &] response_data: response data
* @return pointer to the created curl
*/
CURL
*
curl_create_handle
(
const
std
::
string
&
uri
,
const
std
::
string
&
data
,
std
::
string
&
response_data
);
CURL
*
curl_create_handle
(
const
std
::
string
&
uri
,
const
std
::
string
&
data
,
std
::
string
&
response_data
);
/*
* Prepare to send a request using curl multi
...
...
@@ -102,8 +103,9 @@ class nrf_client {
* @param [std::string &] response_data: response data
* @return void
*/
void
send_curl_multi
(
const
std
::
string
&
uri
,
const
std
::
string
&
data
,
std
::
string
&
response_data
);
void
send_curl_multi
(
const
std
::
string
&
uri
,
const
std
::
string
&
data
,
std
::
string
&
response_data
);
/*
* Perform curl multi to actually process the available data
...
...
src/nrf_app/nrf_config.cpp
View file @
7d14dd54
...
...
@@ -58,7 +58,7 @@ using namespace oai::nrf::app;
extern
nrf_config
nrf_cfg
;
//------------------------------------------------------------------------------
int
nrf_config
::
load_interface
(
const
Setting
&
if_cfg
,
interface_cfg_t
&
cfg
)
{
int
nrf_config
::
load_interface
(
const
Setting
&
if_cfg
,
interface_cfg_t
&
cfg
)
{
if_cfg
.
lookupValue
(
NRF_CONFIG_STRING_INTERFACE_NAME
,
cfg
.
if_name
);
util
::
trim
(
cfg
.
if_name
);
if
(
not
boost
::
iequals
(
cfg
.
if_name
,
"none"
))
{
...
...
@@ -66,19 +66,19 @@ int nrf_config::load_interface(const Setting &if_cfg, interface_cfg_t &cfg) {
if_cfg
.
lookupValue
(
NRF_CONFIG_STRING_IPV4_ADDRESS
,
address
);
util
::
trim
(
address
);
if
(
boost
::
iequals
(
address
,
"read"
))
{
if
(
get_inet_addr_infos_from_iface
(
cfg
.
if_name
,
cfg
.
addr4
,
cfg
.
network4
,
cfg
.
mtu
))
{
if
(
get_inet_addr_infos_from_iface
(
cfg
.
if_name
,
cfg
.
addr4
,
cfg
.
network4
,
cfg
.
mtu
))
{
Logger
::
nrf_app
().
error
(
"Could not read %s network interface configuration"
,
cfg
.
if_name
);
return
RETURNerror
;
}
}
else
{
std
::
vector
<
std
::
string
>
words
;
boost
::
split
(
words
,
address
,
boost
::
is_any_of
(
"/"
),
boost
::
token_compress_on
);
boost
::
split
(
words
,
address
,
boost
::
is_any_of
(
"/"
),
boost
::
token_compress_on
);
if
(
words
.
size
()
!=
2
)
{
Logger
::
nrf_app
().
error
(
"Bad value "
NRF_CONFIG_STRING_IPV4_ADDRESS
" = %s in config file"
,
Logger
::
nrf_app
().
error
(
"Bad value "
NRF_CONFIG_STRING_IPV4_ADDRESS
" = %s in config file"
,
address
.
c_str
());
return
RETURNerror
;
}
...
...
@@ -93,8 +93,8 @@ int nrf_config::load_interface(const Setting &if_cfg, interface_cfg_t &cfg) {
util
::
trim
(
words
.
at
(
0
)).
c_str
());
return
RETURNerror
;
}
cfg
.
network4
.
s_addr
=
htons
(
ntohs
(
cfg
.
addr4
.
s_addr
)
&
cfg
.
network4
.
s_addr
=
htons
(
ntohs
(
cfg
.
addr4
.
s_addr
)
&
0xFFFFFFFF
<<
(
32
-
std
::
stoi
(
util
::
trim
(
words
.
at
(
1
)))));
}
if_cfg
.
lookupValue
(
NRF_CONFIG_STRING_PORT
,
cfg
.
port
);
...
...
@@ -103,67 +103,69 @@ int nrf_config::load_interface(const Setting &if_cfg, interface_cfg_t &cfg) {
}
//------------------------------------------------------------------------------
int
nrf_config
::
load
(
const
string
&
config_file
)
{
int
nrf_config
::
load
(
const
string
&
config_file
)
{
Config
cfg
;
unsigned
char
buf_in6_addr
[
sizeof
(
struct
in6_addr
)];
// Read the file. If there is an error, report it and exit.
try
{
cfg
.
readFile
(
config_file
.
c_str
());
}
catch
(
const
FileIOException
&
fioex
)
{
Logger
::
nrf_app
().
error
(
"I/O error while reading file %s - %s"
,
config_file
.
c_str
(),
fioex
.
what
());
}
catch
(
const
FileIOException
&
fioex
)
{
Logger
::
nrf_app
().
error
(
"I/O error while reading file %s - %s"
,
config_file
.
c_str
(),
fioex
.
what
());
throw
;
}
catch
(
const
ParseException
&
pex
)
{
Logger
::
nrf_app
().
error
(
"Parse error at %s:%d - %s"
,
pex
.
getFile
(),
pex
.
getLine
(),
pex
.
getError
());
}
catch
(
const
ParseException
&
pex
)
{
Logger
::
nrf_app
().
error
(
"Parse error at %s:%d - %s"
,
pex
.
getFile
(),
pex
.
getLine
(),
pex
.
getError
());
throw
;
}
const
Setting
&
root
=
cfg
.
getRoot
();
const
Setting
&
root
=
cfg
.
getRoot
();
try
{
const
Setting
&
nrf_cfg
=
root
[
NRF_CONFIG_STRING_NRF_CONFIG
];
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
const
Setting
&
nrf_cfg
=
root
[
NRF_CONFIG_STRING_NRF_CONFIG
];
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
nrf_app
().
error
(
"%s : %s"
,
nfex
.
what
(),
nfex
.
getPath
());
return
RETURNerror
;
}
const
Setting
&
nrf_cfg
=
root
[
NRF_CONFIG_STRING_NRF_CONFIG
];
const
Setting
&
nrf_cfg
=
root
[
NRF_CONFIG_STRING_NRF_CONFIG
];
try
{
nrf_cfg
.
lookupValue
(
NRF_CONFIG_STRING_INSTANCE
,
instance
);
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
nrf_app
().
info
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
nrf_app
().
info
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
}
try
{
nrf_cfg
.
lookupValue
(
NRF_CONFIG_STRING_PID_DIRECTORY
,
pid_dir
);
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
nrf_app
().
info
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
nrf_app
().
info
(
"%s : %s, using defaults"
,
nfex
.
what
(),
nfex
.
getPath
());
}
try
{
const
Setting
&
sbi_cfg
=
nrf_cfg
[
NRF_CONFIG_STRING_INTERFACE_SBI
];
const
Setting
&
sbi_cfg
=
nrf_cfg
[
NRF_CONFIG_STRING_INTERFACE_SBI
];
load_interface
(
sbi_cfg
,
sbi
);
// HTTP2 port
if
(
!
(
sbi_cfg
.
lookupValue
(
NRF_CONFIG_STRING_SBI_HTTP2_PORT
,
sbi_http2_port
)))
{
if
(
!
(
sbi_cfg
.
lookupValue
(
NRF_CONFIG_STRING_SBI_HTTP2_PORT
,
sbi_http2_port
)))
{
Logger
::
nrf_app
().
error
(
NRF_CONFIG_STRING_SBI_HTTP2_PORT
"failed"
);
throw
(
NRF_CONFIG_STRING_SBI_HTTP2_PORT
"failed"
);
}
// SBI API VERSION
if
(
!
(
sbi_cfg
.
lookupValue
(
NRF_CONFIG_STRING_API_VERSION
,
sbi_api_version
)))
{
if
(
!
(
sbi_cfg
.
lookupValue
(
NRF_CONFIG_STRING_API_VERSION
,
sbi_api_version
)))
{
Logger
::
nrf_app
().
error
(
NRF_CONFIG_STRING_API_VERSION
"failed"
);
throw
(
NRF_CONFIG_STRING_API_VERSION
"failed"
);
}
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
nrf_app
().
error
(
"%s : %s"
,
nfex
.
what
(),
nfex
.
getPath
());
return
RETURNerror
;
}
...
...
@@ -173,8 +175,8 @@ int nrf_config::load(const string &config_file) {
//------------------------------------------------------------------------------
void
nrf_config
::
display
()
{
Logger
::
nrf_app
().
info
(
"==== EURECOM %s v%s ===="
,
PACKAGE_NAME
,
PACKAGE_VERSION
);
Logger
::
nrf_app
().
info
(
"==== EURECOM %s v%s ===="
,
PACKAGE_NAME
,
PACKAGE_VERSION
);
Logger
::
nrf_app
().
info
(
"Configuration NRF:"
);
Logger
::
nrf_app
().
info
(
"- Instance ..............: %d
\n
"
,
instance
);
Logger
::
nrf_app
().
info
(
"- PID dir ...............: %s
\n
"
,
pid_dir
.
c_str
());
...
...
@@ -184,8 +186,8 @@ void nrf_config::display() {
Logger
::
nrf_app
().
info
(
" IPv4 Addr ...........: %s"
,
inet_ntoa
(
sbi
.
addr4
));
Logger
::
nrf_app
().
info
(
" Port ................: %d"
,
sbi
.
port
);
Logger
::
nrf_app
().
info
(
" HTTP2 port ..........: %d"
,
sbi_http2_port
);
Logger
::
nrf_app
().
info
(
" API version..........: %s"
,
sbi_api_version
.
c_str
());
Logger
::
nrf_app
().
info
(
" API version..........: %s"
,
sbi_api_version
.
c_str
());
}
//------------------------------------------------------------------------------
...
...
src/nrf_app/nrf_config.hpp
View file @
7d14dd54
...
...
@@ -63,7 +63,7 @@ typedef struct interface_cfg_s {
class
nrf_config
{
private:
int
load_interface
(
const
libconfig
::
Setting
&
if_cfg
,
interface_cfg_t
&
cfg
);
int
load_interface
(
const
libconfig
::
Setting
&
if_cfg
,
interface_cfg_t
&
cfg
);
public:
/* Reader/writer lock for this configuration */
...
...
@@ -85,7 +85,7 @@ class nrf_config {
virtual
~
nrf_config
();
void
lock
()
{
m_rw_lock
.
lock
();
};
void
unlock
()
{
m_rw_lock
.
unlock
();
};
int
load
(
const
std
::
string
&
config_file
);
int
load
(
const
std
::
string
&
config_file
);
void
display
();
};
...
...
src/nrf_app/nrf_event.cpp
View file @
7d14dd54
...
...
@@ -35,9 +35,8 @@
using
namespace
oai
::
nrf
::
app
;
//------------------------------------------------------------------------------
bs2
::
connection
nrf_event
::
subscribe_task_tick
(
const
task_sig_t
::
slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
)
{
bs2
::
connection
nrf_event
::
subscribe_task_tick
(
const
task_sig_t
::
slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
)
{
/* Wrap the actual callback in a lambda. The latter checks whether the
* current time is after start time, and ensures that the callback is only
* called every X ms with X being the period time. This way, it is possible
...
...
@@ -51,14 +50,14 @@ bs2::connection nrf_event::subscribe_task_tick(const task_sig_t::slot_type &sig,
//------------------------------------------------------------------------------
bs2
::
connection
nrf_event
::
subscribe_task_tick_extended
(
const
task_sig_t
::
extended_slot_type
&
sig
,
uint64_t
period
,
const
task_sig_t
::
extended_slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
)
{
/* Wrap the actual callback in a lambda. The latter checks whether the
* current time is after start time, and ensures that the callback is only
* called every X ms with X being the period time. This way, it is possible
* to register to be notified every X ms instead of every ms, which provides
* greater freedom to implementations. */
auto
f
=
[
period
,
start
,
sig
](
const
bs2
::
connection
&
c
,
uint64_t
t
)
{
auto
f
=
[
period
,
start
,
sig
](
const
bs2
::
connection
&
c
,
uint64_t
t
)
{
if
(
t
>=
start
&&
(
t
-
start
)
%
period
==
0
)
sig
(
c
,
t
);
};
return
task_tick
.
connect_extended
(
f
);
...
...
@@ -66,24 +65,24 @@ bs2::connection nrf_event::subscribe_task_tick_extended(
//------------------------------------------------------------------------------
bs2
::
connection
nrf_event
::
subscribe_nf_status_change
(
const
nf_status_change_sig_t
::
slot_type
&
sig
)
{
const
nf_status_change_sig_t
::
slot_type
&
sig
)
{
return
nf_status_change
.
connect
(
sig
);
}
//------------------------------------------------------------------------------
bs2
::
connection
nrf_event
::
subscribe_nf_status_registered
(
const
nf_status_sig_t
::
slot_type
&
sig
)
{
const
nf_status_sig_t
::
slot_type
&
sig
)
{
return
nf_status_registered
.
connect
(
sig
);
}
//------------------------------------------------------------------------------
bs2
::
connection
nrf_event
::
subscribe_nf_status_deregistered
(
const
nf_deregistered_sig_t
::
slot_type
&
sig
)
{
const
nf_deregistered_sig_t
::
slot_type
&
sig
)
{
return
nf_status_deregistered
.
connect
(
sig
);
}
//------------------------------------------------------------------------------
bs2
::
connection
nrf_event
::
subscribe_nf_status_profile_changed
(
const
nf_status_sig_t
::
slot_type
&
sig
)
{
const
nf_status_sig_t
::
slot_type
&
sig
)
{
return
nf_status_profile_changed
.
connect
(
sig
);
}
src/nrf_app/nrf_event.hpp
View file @
7d14dd54
...
...
@@ -47,10 +47,10 @@ class task_manager;
class
nrf_event
{
public:
nrf_event
(){};
nrf_event
(
nrf_event
const
&
)
=
delete
;
void
operator
=
(
nrf_event
const
&
)
=
delete
;
nrf_event
(
nrf_event
const
&
)
=
delete
;
void
operator
=
(
nrf_event
const
&
)
=
delete
;
static
nrf_event
&
get_instance
()
{
static
nrf_event
&
get_instance
()
{
static
nrf_event
instance
;
return
instance
;
}
...
...
@@ -67,8 +67,8 @@ class nrf_event {
* @param [uint64_t] start:
* @return void
*/
bs2
::
connection
subscribe_task_tick
(
const
task_sig_t
::
slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
=
0
);
bs2
::
connection
subscribe_task_tick
(
const
task_sig_t
::
slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
=
0
);
/*
* Subscribe to the extended task tick event
...
...
@@ -78,7 +78,7 @@ class nrf_event {
* @return void
*/
bs2
::
connection
subscribe_task_tick_extended
(
const
task_sig_t
::
extended_slot_type
&
sig
,
uint64_t
period
,
const
task_sig_t
::
extended_slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
=
0
);
/*
...
...
@@ -89,16 +89,16 @@ class nrf_event {
* @return void
*/
bs2
::
connection
subscribe_nf_status_change
(
const
nf_status_change_sig_t
::
slot_type
&
sig
);
const
nf_status_change_sig_t
::
slot_type
&
sig
);
bs2
::
connection
subscribe_nf_status_registered
(
const
nf_status_sig_t
::
slot_type
&
sig
);
const
nf_status_sig_t
::
slot_type
&
sig
);
bs2
::
connection
subscribe_nf_status_deregistered
(
const
nf_deregistered_sig_t
::
slot_type
&
sig
);
const
nf_deregistered_sig_t
::
slot_type
&
sig
);
bs2
::
connection
subscribe_nf_status_profile_changed
(
const
nf_status_sig_t
::
slot_type
&
sig
);
const
nf_status_sig_t
::
slot_type
&
sig
);
private:
task_sig_t
task_tick
;
...
...
src/nrf_app/nrf_event_sig.hpp
View file @
7d14dd54
...
...
@@ -40,23 +40,23 @@ namespace app {
class
nrf_profile
;
typedef
bs2
::
signal_type
<
void
(
uint64_t
),
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
typedef
bs2
::
signal_type
<
void
(
uint64_t
),
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
task_sig_t
;
// Signal for NF Status
// Subscription ID, NF Status
typedef
bs2
::
signal_type
<
void
(
const
std
::
string
&
),
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
typedef
bs2
::
signal_type
<
void
(
const
std
::
string
&
),
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
nf_status_sig_t
;
typedef
bs2
::
signal_type
<
void
(
const
std
::
shared_ptr
<
nrf_profile
>
&
p
),
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
nf_deregistered_sig_t
;
typedef
bs2
::
signal_type
<
void
(
const
std
::
shared_ptr
<
nrf_profile
>&
p
),
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
nf_deregistered_sig_t
;
typedef
bs2
::
signal_type
<
void
(
const
std
::
shared_ptr
<
nrf_profile
>
&
p
),
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
nf_status_change_sig_t
;
typedef
bs2
::
signal_type
<
void
(
const
std
::
shared_ptr
<
nrf_profile
>&
p
),
bs2
::
keywords
::
mutex_type
<
bs2
::
dummy_mutex
>>::
type
nf_status_change_sig_t
;
}
// namespace app
}
// namespace nrf
...
...
src/nrf_app/nrf_jwt.cpp
View file @
7d14dd54
...
...
@@ -36,12 +36,10 @@
using
namespace
oai
::
nrf
::
app
;
//------------------------------------------------------------------------------
bool
nrf_jwt
::
generate_signature
(
const
std
::
string
&
nf_consumer_id
,
const
std
::
string
&
scope
,
const
std
::
string
&
nf_type
,
const
std
::
string
&
target_nf_type
,
const
std
::
string
&
nrf_instance_id
,
std
::
string
&
signature
)
const
{
bool
nrf_jwt
::
generate_signature
(
const
std
::
string
&
nf_consumer_id
,
const
std
::
string
&
scope
,
const
std
::
string
&
nf_type
,
const
std
::
string
&
target_nf_type
,
const
std
::
string
&
nrf_instance_id
,
std
::
string
&
signature
)
const
{
std
::
string
key
;
get_secret_key
(
scope
,
nf_type
,
target_nf_type
,
key
);
// Create JWT object
...
...
@@ -59,11 +57,10 @@ bool nrf_jwt::generate_signature(const std::string &nf_consumer_id,
}
//------------------------------------------------------------------------------
bool
nrf_jwt
::
generate_signature
(
const
std
::
string
&
nf_consumer_id
,
const
std
::
string
&
scope
,
const
std
::
string
&
target_nf_instance_Id
,
const
std
::
string
&
nrf_instance_id
,
std
::
string
&
signature
)
const
{
bool
nrf_jwt
::
generate_signature
(
const
std
::
string
&
nf_consumer_id
,
const
std
::
string
&
scope
,
const
std
::
string
&
target_nf_instance_Id
,
const
std
::
string
&
nrf_instance_id
,
std
::
string
&
signature
)
const
{
std
::
string
key
;
get_secret_key
(
scope
,
target_nf_instance_Id
,
key
);
// Create JWT object
...
...
@@ -81,18 +78,17 @@ bool nrf_jwt::generate_signature(const std::string &nf_consumer_id,
}
//------------------------------------------------------------------------------
bool
nrf_jwt
::
get_secret_key
(
const
std
::
string
&
scope
,
const
std
::
string
&
nf_type
,
const
std
::
string
&
target_nf_type
,
std
::
string
&
key
)
const
{
bool
nrf_jwt
::
get_secret_key
(
const
std
::
string
&
scope
,
const
std
::
string
&
nf_type
,
const
std
::
string
&
target_nf_type
,
std
::
string
&
key
)
const
{
// TODO:
key
=
"secret"
;
}
//------------------------------------------------------------------------------
bool
nrf_jwt
::
get_secret_key
(
const
std
::
string
&
scope
,
const
std
::
string
&
target_nf_instance_Id
,
std
::
string
&
key
)
const
{
bool
nrf_jwt
::
get_secret_key
(
const
std
::
string
&
scope
,
const
std
::
string
&
target_nf_instance_Id
,
std
::
string
&
key
)
const
{
// TODO:
key
=
"secret"
;
}
...
...
src/nrf_app/nrf_jwt.hpp
View file @
7d14dd54
...
...
@@ -53,11 +53,10 @@ class nrf_jwt {
* @param [std::string &] signature: generated signature
* @return void
*/
bool
generate_signature
(
const
std
::
string
&
nf_consumer_id
,
const
std
::
string
&
scope
,
const
std
::
string
&
nf_type
,
const
std
::
string
&
target_nf_type
,
const
std
::
string
&
nrf_instance_id
,
std
::
string
&
signature
)
const
;
bool
generate_signature
(
const
std
::
string
&
nf_consumer_id
,
const
std
::
string
&
scope
,
const
std
::
string
&
nf_type
,
const
std
::
string
&
target_nf_type
,
const
std
::
string
&
nrf_instance_id
,
std
::
string
&
signature
)
const
;
/*
* Generate signature for the requested consumer
...
...
@@ -70,11 +69,10 @@ class nrf_jwt {
* @param [std::string &] signature: generated signature
* @return void
*/
bool
generate_signature
(
const
std
::
string
&
nf_consumer_id
,
const
std
::
string
&
scope
,
const
std
::
string
&
target_nf_instance_Id
,
const
std
::
string
&
nrf_instance_id
,
std
::
string
&
signature
)
const
;
bool
generate_signature
(
const
std
::
string
&
nf_consumer_id
,
const
std
::
string
&
scope
,
const
std
::
string
&
target_nf_instance_Id
,
const
std
::
string
&
nrf_instance_id
,
std
::
string
&
signature
)
const
;
/*
* Get the secret key
...
...
@@ -85,9 +83,9 @@ class nrf_jwt {
* @param [std::string &] key: secret key
* @return void
*/
bool
get_secret_key
(
const
std
::
string
&
scope
,
const
std
::
string
&
nf_type
,
const
std
::
string
&
target_
nf_type
,
std
::
string
&
key
)
const
;
bool
get_secret_key
(
const
std
::
string
&
scope
,
const
std
::
string
&
nf_type
,
const
std
::
string
&
target_nf_type
,
std
::
string
&
key
)
const
;
/*
* Get the secret key
...
...
@@ -98,9 +96,9 @@ class nrf_jwt {
* @param [std::string &] key: secret key
* @return void
*/
bool
get_secret_key
(
const
std
::
string
&
scope
,
const
std
::
string
&
target_nf_instance_Id
,
std
::
string
&
key
)
const
;
bool
get_secret_key
(
const
std
::
string
&
scope
,
const
std
::
string
&
target_nf_instance_Id
,
std
::
string
&
key
)
const
;
};
}
// namespace app
...
...
src/nrf_app/nrf_profile.cpp
View file @
7d14dd54
...
...
@@ -41,25 +41,27 @@ using namespace std;
using
namespace
oai
::
nrf
::
app
;
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_instance_id
(
const
std
::
string
&
instance_id
)
{
void
nrf_profile
::
set_nf_instance_id
(
const
std
::
string
&
instance_id
)
{
nf_instance_id
=
instance_id
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_instance_id
(
std
::
string
&
instance_id
)
const
{
void
nrf_profile
::
get_nf_instance_id
(
std
::
string
&
instance_id
)
const
{
instance_id
=
nf_instance_id
;
}
//------------------------------------------------------------------------------
std
::
string
nrf_profile
::
get_nf_instance_id
()
const
{
return
nf_instance_id
;
}
std
::
string
nrf_profile
::
get_nf_instance_id
()
const
{
return
nf_instance_id
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_instance_name
(
const
std
::
string
&
instance_name
)
{
void
nrf_profile
::
set_nf_instance_name
(
const
std
::
string
&
instance_name
)
{
nf_instance_name
=
instance_name
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_instance_name
(
std
::
string
&
instance_name
)
const
{
void
nrf_profile
::
get_nf_instance_name
(
std
::
string
&
instance_name
)
const
{
instance_name
=
nf_instance_name
;
}
...
...
@@ -69,106 +71,128 @@ std::string nrf_profile::get_nf_instance_name() const {
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_type
(
const
nf_type_t
&
type
)
{
nf_type
=
type
;
}
void
nrf_profile
::
set_nf_type
(
const
nf_type_t
&
type
)
{
nf_type
=
type
;
}
//------------------------------------------------------------------------------
nf_type_t
nrf_profile
::
get_nf_type
()
const
{
return
nf_type
;
}
nf_type_t
nrf_profile
::
get_nf_type
()
const
{
return
nf_type
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_status
(
const
std
::
string
&
status
)
{
void
nrf_profile
::
set_nf_status
(
const
std
::
string
&
status
)
{
Logger
::
nrf_app
().
debug
(
"Set NF status to %s"
,
status
.
c_str
());
std
::
unique_lock
lock
(
heartbeart_mutex
);
nf_status
=
status
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_status
(
std
::
string
&
status
)
const
{
void
nrf_profile
::
get_nf_status
(
std
::
string
&
status
)
const
{
status
=
nf_status
;
}
//------------------------------------------------------------------------------
std
::
string
nrf_profile
::
get_nf_status
()
const
{
return
nf_status
;
}
std
::
string
nrf_profile
::
get_nf_status
()
const
{
return
nf_status
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_heartBeat_timer
(
const
int32_t
&
timer
)
{
void
nrf_profile
::
set_nf_heartBeat_timer
(
const
int32_t
&
timer
)
{
heartBeat_timer
=
timer
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_heartBeat_timer
(
int32_t
&
timer
)
const
{
void
nrf_profile
::
get_nf_heartBeat_timer
(
int32_t
&
timer
)
const
{
timer
=
heartBeat_timer
;
}
//------------------------------------------------------------------------------
int32_t
nrf_profile
::
get_nf_heartBeat_timer
()
const
{
return
heartBeat_timer
;
}
int32_t
nrf_profile
::
get_nf_heartBeat_timer
()
const
{
return
heartBeat_timer
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_priority
(
const
uint16_t
&
p
)
{
priority
=
p
;
}
void
nrf_profile
::
set_nf_priority
(
const
uint16_t
&
p
)
{
priority
=
p
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_priority
(
uint16_t
&
p
)
const
{
p
=
priority
;
}
void
nrf_profile
::
get_nf_priority
(
uint16_t
&
p
)
const
{
p
=
priority
;
}
//------------------------------------------------------------------------------
uint16_t
nrf_profile
::
get_nf_priority
()
const
{
return
priority
;
}
uint16_t
nrf_profile
::
get_nf_priority
()
const
{
return
priority
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_capacity
(
const
uint16_t
&
c
)
{
capacity
=
c
;
}
void
nrf_profile
::
set_nf_capacity
(
const
uint16_t
&
c
)
{
capacity
=
c
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_capacity
(
uint16_t
&
c
)
const
{
c
=
capacity
;
}
void
nrf_profile
::
get_nf_capacity
(
uint16_t
&
c
)
const
{
c
=
capacity
;
}
//------------------------------------------------------------------------------
uint16_t
nrf_profile
::
get_nf_capacity
()
const
{
return
capacity
;
}
uint16_t
nrf_profile
::
get_nf_capacity
()
const
{
return
capacity
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_snssais
(
const
std
::
vector
<
snssai_t
>
&
s
)
{
void
nrf_profile
::
set_nf_snssais
(
const
std
::
vector
<
snssai_t
>
&
s
)
{
snssais
=
s
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_snssais
(
std
::
vector
<
snssai_t
>
&
s
)
const
{
void
nrf_profile
::
get_nf_snssais
(
std
::
vector
<
snssai_t
>
&
s
)
const
{
s
=
snssais
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
add_snssai
(
const
snssai_t
&
s
)
{
snssais
.
push_back
(
s
);
}
void
nrf_profile
::
add_snssai
(
const
snssai_t
&
s
)
{
snssais
.
push_back
(
s
);
}
//------------------------------------------------------------------------------
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
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
add_nf_ipv4_addresses
(
const
struct
in_addr
&
a
)
{
void
nrf_profile
::
add_nf_ipv4_addresses
(
const
struct
in_addr
&
a
)
{
ipv4_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
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_json_data
(
const
nlohmann
::
json
&
data
)
{
void
nrf_profile
::
set_json_data
(
const
nlohmann
::
json
&
data
)
{
json_data
=
data
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_json_data
(
nlohmann
::
json
&
data
)
const
{
void
nrf_profile
::
get_json_data
(
nlohmann
::
json
&
data
)
const
{
data
=
json_data
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_services
(
const
std
::
vector
<
nf_service_t
>
&
n
)
{
void
nrf_profile
::
set_nf_services
(
const
std
::
vector
<
nf_service_t
>
&
n
)
{
nf_services
=
n
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
add_nf_service
(
const
nf_service_t
&
n
)
{
void
nrf_profile
::
add_nf_service
(
const
nf_service_t
&
n
)
{
nf_services
.
push_back
(
n
);
}
//------------------------------------------------------------------------------
void
nrf_profile
::
get_nf_services
(
std
::
vector
<
nf_service_t
>
&
n
)
const
{
void
nrf_profile
::
get_nf_services
(
std
::
vector
<
nf_service_t
>
&
n
)
const
{
n
=
nf_services
;
}
...
...
@@ -177,8 +201,8 @@ void nrf_profile::display() {
Logger
::
nrf_app
().
debug
(
"NF instance info"
);
Logger
::
nrf_app
().
debug
(
"
\t
Instance ID: %s"
,
nf_instance_id
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Instance name: %s"
,
nf_instance_name
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Instance type: %s"
,
nf_type_e2str
[
nf_type
].
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Instance type: %s"
,
nf_type_e2str
[
nf_type
].
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Status: %s"
,
nf_status
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
HeartBeat timer: %d"
,
heartBeat_timer
);
Logger
::
nrf_app
().
debug
(
"
\t
Priority: %d"
,
priority
);
...
...
@@ -204,10 +228,10 @@ void nrf_profile::display() {
}
//------------------------------------------------------------------------------
bool
nrf_profile
::
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
Logger
::
nrf_app
().
debug
(
"Replace member %s with new value %s"
,
path
.
c_str
(),
value
.
c_str
());
bool
nrf_profile
::
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
Logger
::
nrf_app
().
debug
(
"Replace member %s with new value %s"
,
path
.
c_str
(),
value
.
c_str
());
if
(
path
.
compare
(
"nfInstanceName"
)
==
0
)
{
nf_instance_name
=
value
;
return
true
;
...
...
@@ -227,7 +251,7 @@ bool nrf_profile::replace_profile_info(const std::string &path,
try
{
heartBeat_timer
=
std
::
stoi
(
value
);
return
true
;
}
catch
(
const
std
::
exception
&
err
)
{
}
catch
(
const
std
::
exception
&
err
)
{
Logger
::
nrf_app
().
debug
(
"Bad value!"
);
return
false
;
}
...
...
@@ -235,9 +259,9 @@ bool nrf_profile::replace_profile_info(const std::string &path,
if
(
path
.
compare
(
"priority"
)
==
0
)
{
try
{
priority
=
(
uint16_t
)
std
::
stoi
(
value
);
priority
=
(
uint16_t
)
std
::
stoi
(
value
);
return
true
;
}
catch
(
const
std
::
exception
&
err
)
{
}
catch
(
const
std
::
exception
&
err
)
{
Logger
::
nrf_app
().
debug
(
"Bad value!"
);
return
false
;
}
...
...
@@ -245,9 +269,9 @@ bool nrf_profile::replace_profile_info(const std::string &path,
if
(
path
.
compare
(
"capacity"
)
==
0
)
{
try
{
capacity
=
(
uint16_t
)
std
::
stoi
(
value
);
capacity
=
(
uint16_t
)
std
::
stoi
(
value
);
return
true
;
}
catch
(
const
std
::
exception
&
err
)
{
}
catch
(
const
std
::
exception
&
err
)
{
Logger
::
nrf_app
().
debug
(
"Bad value!"
);
return
false
;
}
...
...
@@ -273,8 +297,8 @@ bool nrf_profile::replace_profile_info(const std::string &path,
}
//------------------------------------------------------------------------------
bool
nrf_profile
::
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
nrf_profile
::
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
Logger
::
nrf_app
().
debug
(
"Add an array element (value, array member), or a new member (value, "
"member): %s, %s"
,
...
...
@@ -300,7 +324,7 @@ bool nrf_profile::add_profile_info(const std::string &path,
try
{
heartBeat_timer
=
std
::
stoi
(
value
);
return
true
;
}
catch
(
const
std
::
exception
&
err
)
{
}
catch
(
const
std
::
exception
&
err
)
{
Logger
::
nrf_app
().
debug
(
"Bad value!"
);
return
false
;
}
...
...
@@ -308,9 +332,9 @@ bool nrf_profile::add_profile_info(const std::string &path,
if
(
path
.
compare
(
"priority"
)
==
0
)
{
try
{
priority
=
(
uint16_t
)
std
::
stoi
(
value
);
priority
=
(
uint16_t
)
std
::
stoi
(
value
);
return
true
;
}
catch
(
const
std
::
exception
&
err
)
{
}
catch
(
const
std
::
exception
&
err
)
{
Logger
::
nrf_app
().
debug
(
"Bad value!"
);
return
false
;
}
...
...
@@ -318,9 +342,9 @@ bool nrf_profile::add_profile_info(const std::string &path,
if
(
path
.
compare
(
"capacity"
)
==
0
)
{
try
{
capacity
=
(
uint16_t
)
std
::
stoi
(
value
);
capacity
=
(
uint16_t
)
std
::
stoi
(
value
);
return
true
;
}
catch
(
const
std
::
exception
&
err
)
{
}
catch
(
const
std
::
exception
&
err
)
{
Logger
::
nrf_app
().
debug
(
"Bad value!"
);
return
false
;
}
...
...
@@ -334,8 +358,8 @@ bool nrf_profile::add_profile_info(const std::string &path,
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
(
"Address conversion: Bad value %s"
,
util
::
trim
(
address
).
c_str
());
Logger
::
nrf_app
().
warn
(
"Address conversion: Bad value %s"
,
util
::
trim
(
address
).
c_str
());
return
false
;
}
Logger
::
nrf_app
().
debug
(
"Added IPv4 Addr: %s"
,
address
.
c_str
());
...
...
@@ -358,9 +382,9 @@ bool nrf_profile::add_profile_info(const std::string &path,
}
//------------------------------------------------------------------------------
bool
nrf_profile
::
remove_profile_info
(
const
std
::
string
&
path
)
{
Logger
::
nrf_app
().
debug
(
"Remove an array element or a member: %s"
,
path
.
c_str
());
bool
nrf_profile
::
remove_profile_info
(
const
std
::
string
&
path
)
{
Logger
::
nrf_app
().
debug
(
"Remove an array element or a member: %s"
,
path
.
c_str
());
if
(
path
.
compare
(
"nfInstanceName"
)
==
0
)
{
nf_instance_name
=
""
;
return
true
;
...
...
@@ -403,7 +427,7 @@ bool nrf_profile::remove_profile_info(const std::string &path) {
uint32_t
index
=
0
;
try
{
index
=
std
::
stoi
(
parts
.
at
(
1
));
}
catch
(
const
std
::
exception
&
err
)
{
}
catch
(
const
std
::
exception
&
err
)
{
Logger
::
nrf_app
().
warn
(
"Bad value for path: %s "
,
path
.
c_str
());
return
false
;
}
...
...
@@ -412,8 +436,8 @@ bool nrf_profile::remove_profile_info(const std::string &path) {
Logger
::
nrf_app
().
warn
(
"Bad value for path: %s "
,
path
.
c_str
());
return
false
;
}
else
{
Logger
::
nrf_app
().
debug
(
"Removed IPv4 Addr: %s"
,
inet_ntoa
(
ipv4_addresses
[
index
]));
Logger
::
nrf_app
().
debug
(
"Removed IPv4 Addr: %s"
,
inet_ntoa
(
ipv4_addresses
[
index
]));
ipv4_addresses
.
erase
(
ipv4_addresses
.
begin
()
+
index
);
return
true
;
}
...
...
@@ -429,13 +453,12 @@ bool nrf_profile::remove_profile_info(const std::string &path) {
return
false
;
}
Logger
::
nrf_app
().
debug
(
"Member (%s) not found!"
,
path
.
c_str
());
return
false
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
to_json
(
nlohmann
::
json
&
data
)
const
{
void
nrf_profile
::
to_json
(
nlohmann
::
json
&
data
)
const
{
data
[
"nfInstanceId"
]
=
nf_instance_id
;
data
[
"nfInstanceName"
]
=
nf_instance_name
;
data
[
"nfType"
]
=
nf_type_e2str
[
nf_type
];
...
...
@@ -493,8 +516,8 @@ void nrf_profile::subscribe_heartbeat_timeout_nfregistration(uint64_t ms) {
"registration): interval %d, current time %ld"
,
2
*
HEART_BEAT_TIMER
,
ms
);
first_hb_connection
=
m_event_sub
.
subscribe_task_tick
(
boost
::
bind
(
&
nrf_profile
::
handle_heartbeart_timeout_nfregistration
,
this
,
_1
),
boost
::
bind
(
&
nrf_profile
::
handle_heartbeart_timeout_nfregistration
,
this
,
_1
),
interval
,
ms
+
interval
);
}
...
...
@@ -593,29 +616,34 @@ void nrf_profile::set_status_updated(bool status) {
}
//------------------------------------------------------------------------------
void
amf_profile
::
add_amf_info
(
const
amf_info_t
&
info
)
{
amf_info
=
info
;
}
void
amf_profile
::
add_amf_info
(
const
amf_info_t
&
info
)
{
amf_info
=
info
;
}
//------------------------------------------------------------------------------
void
amf_profile
::
get_amf_info
(
amf_info_t
&
info
)
const
{
info
=
amf_info
;
}
void
amf_profile
::
get_amf_info
(
amf_info_t
&
info
)
const
{
info
=
amf_info
;
}
//------------------------------------------------------------------------------
void
amf_profile
::
display
()
{
nrf_profile
::
display
();
Logger
::
nrf_app
().
debug
(
"
\t
AMF Info"
);
Logger
::
nrf_app
().
debug
(
"
\t\t
AMF Set ID: %s, AMF Region ID: %s"
,
amf_info
.
amf_set_id
.
c_str
(),
Logger
::
nrf_app
().
debug
(
"
\t\t
AMF Set ID: %s, AMF Region ID: %s"
,
amf_info
.
amf_set_id
.
c_str
(),
amf_info
.
amf_region_id
.
c_str
());
for
(
auto
g
:
amf_info
.
guami_list
)
{
Logger
::
nrf_app
().
debug
(
"
\t\t
AMF GUAMI List, AMF_ID: %s"
,
g
.
amf_id
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t\t
AMF GUAMI List, PLMN (MCC: %s, MNC: %s)"
,
g
.
plmn
.
mcc
.
c_str
(),
g
.
plmn
.
mnc
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t\t
AMF GUAMI List, PLMN (MCC: %s, MNC: %s)"
,
g
.
plmn
.
mcc
.
c_str
(),
g
.
plmn
.
mnc
.
c_str
());
}
}
//------------------------------------------------------------------------------
bool
amf_profile
::
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
amf_profile
::
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
result
=
nrf_profile
::
replace_profile_info
(
path
,
value
);
if
(
result
)
return
true
;
// for AMF info
...
...
@@ -640,8 +668,8 @@ bool amf_profile::replace_profile_info(const std::string &path,
}
//------------------------------------------------------------------------------
bool
amf_profile
::
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
amf_profile
::
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
result
=
nrf_profile
::
add_profile_info
(
path
,
value
);
if
(
result
)
return
true
;
...
...
@@ -670,7 +698,7 @@ bool amf_profile::add_profile_info(const std::string &path,
}
//------------------------------------------------------------------------------
bool
amf_profile
::
remove_profile_info
(
const
std
::
string
&
path
)
{
bool
amf_profile
::
remove_profile_info
(
const
std
::
string
&
path
)
{
bool
result
=
nrf_profile
::
remove_profile_info
(
path
);
if
(
result
)
return
true
;
// for AMF info
...
...
@@ -696,7 +724,7 @@ bool amf_profile::remove_profile_info(const std::string &path) {
}
//------------------------------------------------------------------------------
void
amf_profile
::
to_json
(
nlohmann
::
json
&
data
)
const
{
void
amf_profile
::
to_json
(
nlohmann
::
json
&
data
)
const
{
nrf_profile
::
to_json
(
data
);
// AMF Info
data
[
"amfInfo"
][
"amfSetId"
]
=
amf_info
.
amf_set_id
;
...
...
@@ -713,10 +741,14 @@ void amf_profile::to_json(nlohmann::json &data) const {
}
//------------------------------------------------------------------------------
void
smf_profile
::
add_smf_info
(
const
smf_info_t
&
info
)
{
smf_info
=
info
;
}
void
smf_profile
::
add_smf_info
(
const
smf_info_t
&
info
)
{
smf_info
=
info
;
}
//------------------------------------------------------------------------------
void
smf_profile
::
get_smf_info
(
smf_info_t
&
infos
)
const
{
infos
=
smf_info
;
}
void
smf_profile
::
get_smf_info
(
smf_info_t
&
infos
)
const
{
infos
=
smf_info
;
}
//------------------------------------------------------------------------------
void
smf_profile
::
display
()
{
...
...
@@ -727,15 +759,15 @@ void smf_profile::display() {
"
\t\t
SNSSAI SMF Info List, SNSSAI (SD: %s, SST: %d)"
,
s
.
snssai
.
sD
.
c_str
(),
s
.
snssai
.
sST
);
for
(
auto
d
:
s
.
dnn_smf_info_list
)
{
Logger
::
nrf_app
().
debug
(
"
\t\t
SNSSAI SMF Info List, DNN List: %s"
,
d
.
dnn
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t\t
SNSSAI SMF Info List, DNN List: %s"
,
d
.
dnn
.
c_str
());
}
}
}
//------------------------------------------------------------------------------
bool
smf_profile
::
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
smf_profile
::
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
result
=
nrf_profile
::
add_profile_info
(
path
,
value
);
if
(
result
)
return
true
;
...
...
@@ -763,8 +795,8 @@ bool smf_profile::add_profile_info(const std::string &path,
}
//------------------------------------------------------------------------------
bool
smf_profile
::
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
smf_profile
::
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
result
=
nrf_profile
::
replace_profile_info
(
path
,
value
);
if
(
result
)
return
true
;
// for SMF info
...
...
@@ -790,7 +822,7 @@ bool smf_profile::replace_profile_info(const std::string &path,
}
//------------------------------------------------------------------------------
bool
smf_profile
::
remove_profile_info
(
const
std
::
string
&
path
)
{
bool
smf_profile
::
remove_profile_info
(
const
std
::
string
&
path
)
{
bool
result
=
nrf_profile
::
remove_profile_info
(
path
);
if
(
result
)
return
true
;
// for SMF info
...
...
@@ -816,7 +848,7 @@ bool smf_profile::remove_profile_info(const std::string &path) {
}
//------------------------------------------------------------------------------
void
smf_profile
::
to_json
(
nlohmann
::
json
&
data
)
const
{
void
smf_profile
::
to_json
(
nlohmann
::
json
&
data
)
const
{
nrf_profile
::
to_json
(
data
);
// SMF Info
data
[
"smfInfo"
][
"sNssaiSmfInfoList"
]
=
nlohmann
::
json
::
array
();
...
...
@@ -835,10 +867,14 @@ void smf_profile::to_json(nlohmann::json &data) const {
}
//------------------------------------------------------------------------------
void
upf_profile
::
add_upf_info
(
const
upf_info_t
&
info
)
{
upf_info
=
info
;
}
void
upf_profile
::
add_upf_info
(
const
upf_info_t
&
info
)
{
upf_info
=
info
;
}
//------------------------------------------------------------------------------
void
upf_profile
::
get_upf_info
(
upf_info_t
&
infos
)
const
{
infos
=
upf_info
;
}
void
upf_profile
::
get_upf_info
(
upf_info_t
&
infos
)
const
{
infos
=
upf_info
;
}
//------------------------------------------------------------------------------
void
upf_profile
::
display
()
{
...
...
@@ -849,15 +885,15 @@ void upf_profile::display() {
"
\t\t
SNSSAI UPF Info List, SNSSAI (SD: %s, SST: %d)"
,
s
.
snssai
.
sD
.
c_str
(),
s
.
snssai
.
sST
);
for
(
auto
d
:
s
.
dnn_upf_info_list
)
{
Logger
::
nrf_app
().
debug
(
"
\t\t
SNSSAI UPF Info List, DNN List: %s"
,
d
.
dnn
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t\t
SNSSAI UPF Info List, DNN List: %s"
,
d
.
dnn
.
c_str
());
}
}
}
//------------------------------------------------------------------------------
bool
upf_profile
::
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
upf_profile
::
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
result
=
nrf_profile
::
add_profile_info
(
path
,
value
);
if
(
result
)
return
true
;
...
...
@@ -885,8 +921,8 @@ bool upf_profile::add_profile_info(const std::string &path,
}
//------------------------------------------------------------------------------
bool
upf_profile
::
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
upf_profile
::
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
)
{
bool
result
=
nrf_profile
::
replace_profile_info
(
path
,
value
);
if
(
result
)
return
true
;
// for UPF info
...
...
@@ -912,7 +948,7 @@ bool upf_profile::replace_profile_info(const std::string &path,
}
//------------------------------------------------------------------------------
bool
upf_profile
::
remove_profile_info
(
const
std
::
string
&
path
)
{
bool
upf_profile
::
remove_profile_info
(
const
std
::
string
&
path
)
{
bool
result
=
nrf_profile
::
remove_profile_info
(
path
);
if
(
result
)
return
true
;
// for UPF info
...
...
@@ -938,7 +974,7 @@ bool upf_profile::remove_profile_info(const std::string &path) {
}
//------------------------------------------------------------------------------
void
upf_profile
::
to_json
(
nlohmann
::
json
&
data
)
const
{
void
upf_profile
::
to_json
(
nlohmann
::
json
&
data
)
const
{
nrf_profile
::
to_json
(
data
);
// UPF Info
data
[
"upfInfo"
][
"sNssaiSmfInfoList"
]
=
nlohmann
::
json
::
array
();
...
...
src/nrf_app/nrf_profile.hpp
View file @
7d14dd54
...
...
@@ -52,7 +52,7 @@ using namespace std;
class
nrf_profile
:
public
std
::
enable_shared_from_this
<
nrf_profile
>
{
public:
nrf_profile
(
nrf_event
&
ev
)
nrf_profile
(
nrf_event
&
ev
)
:
m_event_sub
(
ev
),
nf_type
(
NF_TYPE_UNKNOWN
),
heartBeat_timer
(
0
),
...
...
@@ -68,7 +68,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
first_update
=
true
;
is_updated
=
false
;
}
nrf_profile
(
nrf_event
&
ev
,
const
nf_type_t
type
)
nrf_profile
(
nrf_event
&
ev
,
const
nf_type_t
type
)
:
m_event_sub
(
ev
),
nf_type
(
type
),
heartBeat_timer
(
0
),
...
...
@@ -85,7 +85,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
is_updated
=
false
;
}
nrf_profile
(
nrf_event
&
ev
,
const
std
::
string
&
id
)
nrf_profile
(
nrf_event
&
ev
,
const
std
::
string
&
id
)
:
m_event_sub
(
ev
),
nf_instance_id
(
id
),
heartBeat_timer
(
0
),
...
...
@@ -103,7 +103,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
is_updated
=
false
;
}
nrf_profile
(
nrf_profile
&
b
)
=
delete
;
nrf_profile
(
nrf_profile
&
b
)
=
delete
;
virtual
~
nrf_profile
()
{
Logger
::
nrf_app
().
debug
(
"Delete NRF Profile instance..."
);
...
...
@@ -116,14 +116,14 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param [const std::string &] instance_id: instance id
* @return void
*/
void
set_nf_instance_id
(
const
std
::
string
&
instance_id
);
void
set_nf_instance_id
(
const
std
::
string
&
instance_id
);
/*
* Get NF instance ID
* @param [std::string &] instance_id: store instance id
* @return void:
*/
void
get_nf_instance_id
(
std
::
string
&
instance_id
)
const
;
void
get_nf_instance_id
(
std
::
string
&
instance_id
)
const
;
/*
* Get NF instance ID
...
...
@@ -137,14 +137,14 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param [const std::string &] instance_name: instance name
* @return void
*/
void
set_nf_instance_name
(
const
std
::
string
&
instance_name
);
void
set_nf_instance_name
(
const
std
::
string
&
instance_name
);
/*
* Get NF instance ID
* @param [std::string &] instance_name: store instance name
* @return void:
*/
void
get_nf_instance_name
(
std
::
string
&
instance_name
)
const
;
void
get_nf_instance_name
(
std
::
string
&
instance_name
)
const
;
/*
* Get NF instance name
...
...
@@ -158,14 +158,14 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param [const std::string &] status: instance status
* @return void
*/
void
set_nf_status
(
const
std
::
string
&
status
);
void
set_nf_status
(
const
std
::
string
&
status
);
/*
* Get NF instance status
* @param [std::string &] status: store instance status
* @return void:
*/
void
get_nf_status
(
std
::
string
&
status
)
const
;
void
get_nf_status
(
std
::
string
&
status
)
const
;
/*
* Get NF status
...
...
@@ -186,21 +186,21 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param [const nf_type_t &] type: nf type
* @return void
*/
void
set_nf_type
(
const
nf_type_t
&
type
);
void
set_nf_type
(
const
nf_type_t
&
type
);
/*
* Set NF instance heartBeat_timer
* @param [const std::string &] timer: heartBeat_timer
* @return void
*/
void
set_nf_heartBeat_timer
(
const
int32_t
&
timer
);
void
set_nf_heartBeat_timer
(
const
int32_t
&
timer
);
/*
* Get NF instance heartBeat_timer
* @param [std::string &] timer: store heartBeat_timer
* @return void:
*/
void
get_nf_heartBeat_timer
(
int32_t
&
timer
)
const
;
void
get_nf_heartBeat_timer
(
int32_t
&
timer
)
const
;
/*
* Get NF heartBeat_timer
...
...
@@ -214,14 +214,14 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param [const uint16_t] p: instance priority
* @return void
*/
void
set_nf_priority
(
const
uint16_t
&
p
);
void
set_nf_priority
(
const
uint16_t
&
p
);
/*
* Get NF instance priority
* @param [uint16_t] p: store instance priority
* @return void:
*/
void
get_nf_priority
(
uint16_t
&
p
)
const
;
void
get_nf_priority
(
uint16_t
&
p
)
const
;
/*
* Get NF instance priority
...
...
@@ -235,14 +235,14 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param [const uint16_t] c: instance capacity
* @return void
*/
void
set_nf_capacity
(
const
uint16_t
&
c
);
void
set_nf_capacity
(
const
uint16_t
&
c
);
/*
* Get NF instance priority
* @param [uint16_t ] c: store instance capacity
* @return void:
*/
void
get_nf_capacity
(
uint16_t
&
c
)
const
;
void
get_nf_capacity
(
uint16_t
&
c
)
const
;
/*
* Get NF instance priority
...
...
@@ -256,77 +256,77 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param [std::vector<snssai_t> &] s: SNSSAIs
* @return void
*/
void
set_nf_snssais
(
const
std
::
vector
<
snssai_t
>
&
s
);
void
set_nf_snssais
(
const
std
::
vector
<
snssai_t
>
&
s
);
/*
* Add SNSSAI
* @param [snssai_t &] s: SNSSAI
* @return void
*/
void
add_snssai
(
const
snssai_t
&
s
);
void
add_snssai
(
const
snssai_t
&
s
);
/*
* Get NF instance SNSSAIs
* @param [std::vector<snssai_t> &] s: store instance's SNSSAIs
* @return void:
*/
void
get_nf_snssais
(
std
::
vector
<
snssai_t
>
&
s
)
const
;
void
get_nf_snssais
(
std
::
vector
<
snssai_t
>
&
s
)
const
;
/*
* Set NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: ipv4_addresses
* @return void
*/
void
set_nf_ipv4_addresses
(
const
std
::
vector
<
struct
in_addr
>
&
a
);
void
set_nf_ipv4_addresses
(
const
std
::
vector
<
struct
in_addr
>
&
a
);
/*
* Add an IPv4 address to the list of addresses
* @param [const struct in_addr &] a: ipv4_address
* @return void
*/
void
add_nf_ipv4_addresses
(
const
struct
in_addr
&
a
);
void
add_nf_ipv4_addresses
(
const
struct
in_addr
&
a
);
/*
* Get NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: store instance's ipv4_addresses
* @return void:
*/
void
get_nf_ipv4_addresses
(
std
::
vector
<
struct
in_addr
>
&
a
)
const
;
void
get_nf_ipv4_addresses
(
std
::
vector
<
struct
in_addr
>
&
a
)
const
;
/*
* Set json data
* @param [const nlohmann::json &] data: Json data to be set
* @return void
*/
void
set_json_data
(
const
nlohmann
::
json
&
data
);
void
set_json_data
(
const
nlohmann
::
json
&
data
);
/*
* Get json data
* @param [nlohmann::json &] data: Store json data
* @return void
*/
void
get_json_data
(
nlohmann
::
json
&
data
)
const
;
void
get_json_data
(
nlohmann
::
json
&
data
)
const
;
/*
* Set NF instance services
* @param [std::vector<nf_service_t> &] n: nf_service
* @return void
*/
void
set_nf_services
(
const
std
::
vector
<
nf_service_t
>
&
n
);
void
set_nf_services
(
const
std
::
vector
<
nf_service_t
>
&
n
);
/*
* Add nf service
* @param [snssai_t &] n: nf service
* @return void
*/
void
add_nf_service
(
const
nf_service_t
&
n
);
void
add_nf_service
(
const
nf_service_t
&
n
);
/*
* Get NF services
* @param [std::vector<snssai_t> &] n: store instance's nf services
* @return void:
*/
void
get_nf_services
(
std
::
vector
<
nf_service_t
>
&
n
)
const
;
void
get_nf_services
(
std
::
vector
<
nf_service_t
>
&
n
)
const
;
/*
* Print related-information for NF profile
...
...
@@ -341,8 +341,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
*/
virtual
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
...
...
@@ -350,8 +350,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
*/
virtual
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
...
...
@@ -359,14 +359,14 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
* @param [const std::string &] value: new value
* @return true if success, otherwise false
*/
virtual
bool
remove_profile_info
(
const
std
::
string
&
path
);
virtual
bool
remove_profile_info
(
const
std
::
string
&
path
);
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
virtual
void
to_json
(
nlohmann
::
json
&
data
)
const
;
virtual
void
to_json
(
nlohmann
::
json
&
data
)
const
;
/*
* Subscribe to the HBT timeout event (after receiving NF Update)
...
...
@@ -425,7 +425,7 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
void
set_status_updated
(
bool
status
);
protected:
nrf_event
&
m_event_sub
;
nrf_event
&
m_event_sub
;
bs2
::
connection
task_connection
;
// connection for the HBT timeout (after NF Update)
bs2
::
connection
first_hb_connection
;
// connection for first HBT timeout
...
...
@@ -516,14 +516,14 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
class
amf_profile
:
public
nrf_profile
{
public:
amf_profile
(
nrf_event
&
ev
)
:
nrf_profile
(
ev
,
NF_TYPE_AMF
)
{
amf_info
=
{};
}
amf_profile
(
nrf_event
&
ev
)
:
nrf_profile
(
ev
,
NF_TYPE_AMF
)
{
amf_info
=
{};
}
amf_profile
(
nrf_event
&
ev
,
const
std
::
string
&
id
)
:
nrf_profile
(
ev
,
id
)
{
amf_profile
(
nrf_event
&
ev
,
const
std
::
string
&
id
)
:
nrf_profile
(
ev
,
id
)
{
nf_type
=
NF_TYPE_AMF
;
amf_info
=
{};
}
amf_profile
(
amf_profile
&
b
)
=
delete
;
amf_profile
(
amf_profile
&
b
)
=
delete
;
~
amf_profile
()
{}
...
...
@@ -532,14 +532,14 @@ class amf_profile : public nrf_profile {
* @param [const amf_info_t &] info: AMF info
* @return void
*/
void
add_amf_info
(
const
amf_info_t
&
info
);
void
add_amf_info
(
const
amf_info_t
&
info
);
/*
* Get list of AMF infos an AMF info
* @param [const amf_info_t &] info: AMF info
* @return void
*/
void
get_amf_info
(
amf_info_t
&
info
)
const
;
void
get_amf_info
(
amf_info_t
&
info
)
const
;
/*
* Print related-information for an AMF profile
...
...
@@ -554,7 +554,7 @@ class amf_profile : public nrf_profile {
* @param [const std::string &] value: new value
* @return void
*/
bool
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
bool
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
/*
* Add a new value for a member of NF profile
...
...
@@ -562,7 +562,7 @@ class amf_profile : public 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
);
bool
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
/*
* Remove value of a member of NF profile
...
...
@@ -570,14 +570,14 @@ class amf_profile : public nrf_profile {
* @param [const std::string &] value: new value
* @return true if success, otherwise false
*/
bool
remove_profile_info
(
const
std
::
string
&
path
);
bool
remove_profile_info
(
const
std
::
string
&
path
);
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
void
to_json
(
nlohmann
::
json
&
data
)
const
;
void
to_json
(
nlohmann
::
json
&
data
)
const
;
private:
amf_info_t
amf_info
;
...
...
@@ -585,28 +585,28 @@ class amf_profile : public nrf_profile {
class
smf_profile
:
public
nrf_profile
{
public:
smf_profile
(
nrf_event
&
ev
)
:
nrf_profile
(
ev
,
NF_TYPE_SMF
)
{
smf_info
=
{};
}
smf_profile
(
nrf_event
&
ev
)
:
nrf_profile
(
ev
,
NF_TYPE_SMF
)
{
smf_info
=
{};
}
smf_profile
(
nrf_event
&
ev
,
const
std
::
string
&
id
)
:
nrf_profile
(
ev
,
id
)
{
smf_profile
(
nrf_event
&
ev
,
const
std
::
string
&
id
)
:
nrf_profile
(
ev
,
id
)
{
nf_type
=
NF_TYPE_SMF
;
smf_info
=
{};
}
smf_profile
(
smf_profile
&
b
)
=
delete
;
smf_profile
(
smf_profile
&
b
)
=
delete
;
/*
* Add a SMF info
* @param [const smf_info_t &] info: SMF info
* @return void
*/
void
add_smf_info
(
const
smf_info_t
&
info
);
void
add_smf_info
(
const
smf_info_t
&
info
);
/*
* Get list of SMF infos a SMF info
* @param [const smf_info_t &] info: SMF info
* @return void
*/
void
get_smf_info
(
smf_info_t
&
infos
)
const
;
void
get_smf_info
(
smf_info_t
&
infos
)
const
;
/*
* Print related-information for a SMF profile
...
...
@@ -621,7 +621,7 @@ class smf_profile : public nrf_profile {
* @param [const std::string &] value: new value
* @return void
*/
bool
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
bool
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
/*
* Add a new value for a member of NF profile
...
...
@@ -629,7 +629,7 @@ class smf_profile : public 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
);
bool
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
/*
* Remove value of a member of NF profile
...
...
@@ -637,44 +637,43 @@ class smf_profile : public nrf_profile {
* @param [const std::string &] value: new value
* @return true if success, otherwise false
*/
bool
remove_profile_info
(
const
std
::
string
&
path
);
bool
remove_profile_info
(
const
std
::
string
&
path
);
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
void
to_json
(
nlohmann
::
json
&
data
)
const
;
void
to_json
(
nlohmann
::
json
&
data
)
const
;
private:
smf_info_t
smf_info
;
};
class
upf_profile
:
public
nrf_profile
{
public:
upf_profile
(
nrf_event
&
ev
)
:
nrf_profile
(
ev
,
NF_TYPE_UPF
)
{
upf_info
=
{};
}
upf_profile
(
nrf_event
&
ev
)
:
nrf_profile
(
ev
,
NF_TYPE_UPF
)
{
upf_info
=
{};
}
upf_profile
(
nrf_event
&
ev
,
const
std
::
string
&
id
)
:
nrf_profile
(
ev
,
id
)
{
upf_profile
(
nrf_event
&
ev
,
const
std
::
string
&
id
)
:
nrf_profile
(
ev
,
id
)
{
nf_type
=
NF_TYPE_UPF
;
upf_info
=
{};
}
upf_profile
(
upf_profile
&
b
)
=
delete
;
upf_profile
(
upf_profile
&
b
)
=
delete
;
/*
* Add a UPF info
* @param [const upf_info_t &] info: UPF info
* @return void
*/
void
add_upf_info
(
const
upf_info_t
&
info
);
void
add_upf_info
(
const
upf_info_t
&
info
);
/*
* Get list of UPF infos a UPF info
* @param [const upf_info_t &] info: UPF info
* @return void
*/
void
get_upf_info
(
upf_info_t
&
infos
)
const
;
void
get_upf_info
(
upf_info_t
&
infos
)
const
;
/*
* Print related-information for a UPF profile
...
...
@@ -689,7 +688,7 @@ class upf_profile : public nrf_profile {
* @param [const std::string &] value: new value
* @return void
*/
bool
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
bool
replace_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
/*
* Add a new value for a member of NF profile
...
...
@@ -697,7 +696,7 @@ class upf_profile : public 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
);
bool
add_profile_info
(
const
std
::
string
&
path
,
const
std
::
string
&
value
);
/*
* Remove value of a member of NF profile
...
...
@@ -705,14 +704,14 @@ class upf_profile : public nrf_profile {
* @param [const std::string &] value: new value
* @return true if success, otherwise false
*/
bool
remove_profile_info
(
const
std
::
string
&
path
);
bool
remove_profile_info
(
const
std
::
string
&
path
);
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
void
to_json
(
nlohmann
::
json
&
data
)
const
;
void
to_json
(
nlohmann
::
json
&
data
)
const
;
private:
upf_info_t
upf_info
;
...
...
src/nrf_app/nrf_search_result.cpp
View file @
7d14dd54
...
...
@@ -36,29 +36,35 @@
using
namespace
oai
::
nrf
::
app
;
//------------------------------------------------------------------------------
void
nrf_search_result
::
set_search_id
(
const
std
::
string
&
id
)
{
search_id
=
id
;
}
void
nrf_search_result
::
set_search_id
(
const
std
::
string
&
id
)
{
search_id
=
id
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
get_search_id
(
std
::
string
&
id
)
const
{
id
=
search_id
;
}
void
nrf_search_result
::
get_search_id
(
std
::
string
&
id
)
const
{
id
=
search_id
;
}
//------------------------------------------------------------------------------
std
::
string
nrf_search_result
::
get_search_id
()
const
{
return
search_id
;
}
std
::
string
nrf_search_result
::
get_search_id
()
const
{
return
search_id
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
set_nf_instances
(
const
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
&
instances
)
{
const
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
&
instances
)
{
nf_instances
=
instances
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
add_nf_instance
(
const
std
::
shared_ptr
<
nrf_profile
>
&
instance
)
{
const
std
::
shared_ptr
<
nrf_profile
>
&
instance
)
{
nf_instances
.
push_back
(
instance
);
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
get_nf_instances
(
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
&
instances
)
const
{
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
&
instances
)
const
{
instances
=
nf_instances
;
}
...
...
@@ -69,12 +75,12 @@ std::vector<std::shared_ptr<nrf_profile>> nrf_search_result::get_nf_instances()
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
set_validity_period
(
const
uint64_t
&
p
)
{
void
nrf_search_result
::
set_validity_period
(
const
uint64_t
&
p
)
{
validity_period
=
p
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
get_validity_period
(
uint64_t
&
p
)
const
{
void
nrf_search_result
::
get_validity_period
(
uint64_t
&
p
)
const
{
p
=
validity_period
;
}
...
...
@@ -84,22 +90,22 @@ uint64_t nrf_search_result::get_validity_period() const {
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
set_num_nf_inst_complete
(
const
uint32_t
&
n
)
{
void
nrf_search_result
::
set_num_nf_inst_complete
(
const
uint32_t
&
n
)
{
num_nf_inst_complete
=
n
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
get_num_nf_inst_complete
(
uint32_t
&
n
)
const
{
void
nrf_search_result
::
get_num_nf_inst_complete
(
uint32_t
&
n
)
const
{
n
=
num_nf_inst_complete
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
set_limit_nf_instances
(
const
uint32_t
&
l
)
{
void
nrf_search_result
::
set_limit_nf_instances
(
const
uint32_t
&
l
)
{
limit_nf_instances
=
l
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
get_limit_nf_instances
(
uint32_t
&
l
)
const
{
void
nrf_search_result
::
get_limit_nf_instances
(
uint32_t
&
l
)
const
{
l
=
limit_nf_instances
;
}
...
...
@@ -121,8 +127,8 @@ void nrf_search_result::display() {
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
to_json
(
nlohmann
::
json
&
data
,
const
uint32_t
&
limit_nfs
)
const
{
void
nrf_search_result
::
to_json
(
nlohmann
::
json
&
data
,
const
uint32_t
&
limit_nfs
)
const
{
data
=
{};
data
[
"validityPeriod"
]
=
validity_period
;
...
...
src/nrf_app/nrf_search_result.hpp
View file @
7d14dd54
...
...
@@ -44,27 +44,27 @@ class nrf_search_result {
nrf_search_result
()
{
limit_nf_instances
=
10
;
// default value, TODO: to be removed
};
nrf_search_result
(
nrf_search_result
const
&
)
=
delete
;
nrf_search_result
(
nrf_search_result
const
&
)
=
delete
;
virtual
~
nrf_search_result
()
{
Logger
::
nrf_app
().
debug
(
"Delete NRF Subscription instance..."
);
}
void
operator
=
(
nrf_search_result
const
&
)
=
delete
;
void
operator
=
(
nrf_search_result
const
&
)
=
delete
;
/*
* Set the search id
* @param [const std::string &]: id: Search id
* @return void
*/
void
set_search_id
(
const
std
::
string
&
id
);
void
set_search_id
(
const
std
::
string
&
id
);
/*
* Get the search id
* @param [std::string &]: id: search id
* @return void
*/
void
get_search_id
(
std
::
string
&
id
)
const
;
void
get_search_id
(
std
::
string
&
id
)
const
;
/*
* Get the search id
...
...
@@ -80,7 +80,7 @@ class nrf_search_result {
* @return void
*/
void
set_nf_instances
(
const
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
&
instances
);
const
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
&
instances
);
/*
* Add an nf instance to the list of nrf profile instances
...
...
@@ -88,7 +88,7 @@ class nrf_search_result {
* instance
* @return void
*/
void
add_nf_instance
(
const
std
::
shared_ptr
<
nrf_profile
>
&
instance
);
void
add_nf_instance
(
const
std
::
shared_ptr
<
nrf_profile
>
&
instance
);
/*
* Get the nf instances
...
...
@@ -97,7 +97,7 @@ class nrf_search_result {
* @return void
*/
void
get_nf_instances
(
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
&
instances
)
const
;
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
&
instances
)
const
;
/*
* Get the nf instances
...
...
@@ -112,14 +112,14 @@ class nrf_search_result {
* @param [const uint64_t &] p: validity period
* @return
*/
void
set_validity_period
(
const
uint64_t
&
v
);
void
set_validity_period
(
const
uint64_t
&
v
);
/*
* Get the validity period
* @param [uint64_t &]p: validity period
* @return
*/
void
get_validity_period
(
uint64_t
&
p
)
const
;
void
get_validity_period
(
uint64_t
&
p
)
const
;
/*
* Get the validity period
...
...
@@ -133,14 +133,14 @@ class nrf_search_result {
* @param [const uint32_t &] n: the total number of NF Instances found by NRF
* @return void
*/
void
set_num_nf_inst_complete
(
const
uint32_t
&
n
);
void
set_num_nf_inst_complete
(
const
uint32_t
&
n
);
/*
* Get the the total number of NF Instances found by NRF
* @param [uint32_t &] n: the total number of NF Instances found by NRF
* @return void
*/
void
get_num_nf_inst_complete
(
uint32_t
&
n
)
const
;
void
get_num_nf_inst_complete
(
uint32_t
&
n
)
const
;
/*
* Set the maximum number of NFProfiles to be returned in the response
...
...
@@ -148,7 +148,7 @@ class nrf_search_result {
* returned in the response
* @return void
*/
void
set_limit_nf_instances
(
const
uint32_t
&
l
);
void
set_limit_nf_instances
(
const
uint32_t
&
l
);
/*
* Get the maximum number of NFProfiles to be returned in the response
...
...
@@ -156,7 +156,7 @@ class nrf_search_result {
* the response
* @return void
*/
void
get_limit_nf_instances
(
uint32_t
&
l
)
const
;
void
get_limit_nf_instances
(
uint32_t
&
l
)
const
;
/*
* Get the maximum number of NFProfiles to be returned in the response
...
...
@@ -179,7 +179,7 @@ class nrf_search_result {
* json data 0, means without any restriction
* @return void
*/
void
to_json
(
nlohmann
::
json
&
data
,
const
uint32_t
&
limit_nfs
)
const
;
void
to_json
(
nlohmann
::
json
&
data
,
const
uint32_t
&
limit_nfs
)
const
;
private:
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
nf_instances
;
...
...
src/nrf_app/nrf_subscription.cpp
View file @
7d14dd54
...
...
@@ -37,12 +37,12 @@
using
namespace
oai
::
nrf
::
app
;
//------------------------------------------------------------------------------
void
nrf_subscription
::
set_subscription_id
(
const
std
::
string
&
sub
)
{
void
nrf_subscription
::
set_subscription_id
(
const
std
::
string
&
sub
)
{
subscription_id
=
sub
;
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
get_subscription_id
(
std
::
string
&
sub
)
const
{
void
nrf_subscription
::
get_subscription_id
(
std
::
string
&
sub
)
const
{
sub
=
subscription_id
;
}
...
...
@@ -53,23 +53,23 @@ std::string nrf_subscription::get_subscription_id() const {
//------------------------------------------------------------------------------
void
nrf_subscription
::
set_notification_uri
(
const
std
::
string
&
notification_uri
)
{
const
std
::
string
&
notification_uri
)
{
nf_status_notification_uri
=
notification_uri
;
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
get_notification_uri
(
std
::
string
&
notification_uri
)
const
{
std
::
string
&
notification_uri
)
const
{
notification_uri
=
nf_status_notification_uri
;
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
set_sub_condition
(
const
subscription_condition_t
&
c
)
{
void
nrf_subscription
::
set_sub_condition
(
const
subscription_condition_t
&
c
)
{
sub_condition
=
c
;
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
get_sub_condition
(
subscription_condition_t
&
c
)
const
{
void
nrf_subscription
::
get_sub_condition
(
subscription_condition_t
&
c
)
const
{
c
=
sub_condition
;
}
...
...
@@ -81,17 +81,17 @@ subscription_condition_t nrf_subscription::get_sub_condition() const {
*/
//------------------------------------------------------------------------------
void
nrf_subscription
::
set_notif_events
(
const
std
::
vector
<
uint8_t
>
&
ev_types
)
{
void
nrf_subscription
::
set_notif_events
(
const
std
::
vector
<
uint8_t
>
&
ev_types
)
{
notif_events
=
ev_types
;
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
add_notif_event
(
const
uint8_t
&
ev_type
)
{
void
nrf_subscription
::
add_notif_event
(
const
uint8_t
&
ev_type
)
{
notif_events
.
push_back
(
ev_type
);
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
get_notif_events
(
std
::
vector
<
uint8_t
>
&
ev_types
)
const
{
void
nrf_subscription
::
get_notif_events
(
std
::
vector
<
uint8_t
>
&
ev_types
)
const
{
ev_types
=
notif_events
;
}
...
...
@@ -101,12 +101,12 @@ std::vector<uint8_t> nrf_subscription::get_notif_events() const {
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
set_validity_time
(
const
boost
::
posix_time
::
ptime
&
t
)
{
void
nrf_subscription
::
set_validity_time
(
const
boost
::
posix_time
::
ptime
&
t
)
{
validity_time
=
t
;
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
get_validity_time
(
boost
::
posix_time
::
ptime
&
t
)
const
{
void
nrf_subscription
::
get_validity_time
(
boost
::
posix_time
::
ptime
&
t
)
const
{
t
=
validity_time
;
}
...
...
@@ -120,18 +120,18 @@ void nrf_subscription::display() {
Logger
::
nrf_app
().
debug
(
"Subscription information"
);
Logger
::
nrf_app
().
debug
(
"
\t
Sub ID: %s"
,
subscription_id
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Notification URI: %s"
,
nf_status_notification_uri
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Subscription condition: %s"
,
sub_condition
.
to_string
().
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Notification URI: %s"
,
nf_status_notification_uri
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Subscription condition: %s"
,
sub_condition
.
to_string
().
c_str
());
std
::
string
notif_events_str
=
{};
for
(
auto
n
:
notif_events
)
{
notif_events_str
.
append
(
notification_event_type_e2str
[
n
]);
notif_events_str
.
append
(
", "
);
}
Logger
::
nrf_app
().
debug
(
"
\t
Notification Events: %s"
,
notif_events_str
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Notification Events: %s"
,
notif_events_str
.
c_str
());
Logger
::
nrf_app
().
debug
(
"
\t
Validity time: %s"
,
boost
::
posix_time
::
to_iso_string
(
validity_time
).
c_str
());
...
...
@@ -142,13 +142,13 @@ void nrf_subscription::subscribe_nf_status_registered() {
Logger
::
nrf_app
().
debug
(
"Subscribe to NF status change event"
);
ev_connection
=
m_event_sub
.
subscribe_nf_status_change
(
// TODO: To be updated
boost
::
bind
(
&
nrf_subscription
::
handle_nf_status_registered
,
this
,
_1
));
boost
::
bind
(
&
nrf_subscription
::
handle_nf_status_registered
,
this
,
_1
));
}
//------------------------------------------------------------------------------
void
nrf_subscription
::
handle_nf_status_registered
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
)
{
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
)
{
std
::
string
nf_instance_id
;
profile
.
get
()
->
get_nf_instance_id
(
nf_instance_id
);
Logger
::
nrf_app
().
info
(
...
...
src/nrf_app/nrf_subscription.hpp
View file @
7d14dd54
...
...
@@ -44,32 +44,32 @@ using namespace std;
class
nrf_subscription
{
public:
nrf_subscription
(
nrf_event
&
ev
)
:
m_event_sub
(
ev
)
{
nrf_subscription
(
nrf_event
&
ev
)
:
m_event_sub
(
ev
)
{
validity_time
=
boost
::
posix_time
::
from_iso_string
(
"20991231T235959Z"
);
};
nrf_subscription
(
nrf_subscription
const
&
)
=
delete
;
nrf_subscription
(
nrf_subscription
const
&
)
=
delete
;
virtual
~
nrf_subscription
()
{
Logger
::
nrf_app
().
debug
(
"Delete NRF Subscription instance..."
);
if
(
ev_connection
.
connected
())
ev_connection
.
disconnect
();
}
void
operator
=
(
nrf_subscription
const
&
)
=
delete
;
void
operator
=
(
nrf_subscription
const
&
)
=
delete
;
/*
* Set the subscription id
* @param [const std::string &]: sub_id: Subscription id
* @return void
*/
void
set_subscription_id
(
const
std
::
string
&
sub_id
);
void
set_subscription_id
(
const
std
::
string
&
sub_id
);
/*
* Get the subscription id
* @param [std::string &]: sub_id: Subscription id
* @return void
*/
void
get_subscription_id
(
std
::
string
&
sub_id
)
const
;
void
get_subscription_id
(
std
::
string
&
sub_id
)
const
;
/*
* Get the subscription id
...
...
@@ -83,28 +83,28 @@ class nrf_subscription {
* @param [const std::string &]: notification_uri: Notification URI
* @return void
*/
void
set_notification_uri
(
const
std
::
string
&
notification_uri
);
void
set_notification_uri
(
const
std
::
string
&
notification_uri
);
/*
* Get the notification URI (URI where the notification will be sent to)
* @param [std::string &]: notification_uri: Notification URI
* @return void
*/
void
get_notification_uri
(
std
::
string
&
notification_uri
)
const
;
void
get_notification_uri
(
std
::
string
&
notification_uri
)
const
;
/*
* Set the subscription condition
* @param [const subscription_condition_t &]: c: Subscription condition
* @return void
*/
void
set_sub_condition
(
const
subscription_condition_t
&
c
);
void
set_sub_condition
(
const
subscription_condition_t
&
c
);
/*
* Get the subscription condition
* @param [const subscription_condition_t &]: c: Subscription condition
* @return void
*/
void
get_sub_condition
(
subscription_condition_t
&
c
)
const
;
void
get_sub_condition
(
subscription_condition_t
&
c
)
const
;
// subscription_condition_t get_sub_condition() const;
/*
...
...
@@ -113,14 +113,14 @@ class nrf_subscription {
* event types
* @return void
*/
void
set_notif_events
(
const
std
::
vector
<
uint8_t
>
&
ev_types
);
void
set_notif_events
(
const
std
::
vector
<
uint8_t
>
&
ev_types
);
/*
* Add a notification type to the list of notification events
* @param [const uint8_t &]: ev_type: A notification type
* @return void
*/
void
add_notif_event
(
const
uint8_t
&
ev_type
);
void
add_notif_event
(
const
uint8_t
&
ev_type
);
/*
* Get the notification events
...
...
@@ -128,7 +128,7 @@ class nrf_subscription {
* types
* @return void
*/
void
get_notif_events
(
std
::
vector
<
uint8_t
>
&
ev_types
)
const
;
void
get_notif_events
(
std
::
vector
<
uint8_t
>
&
ev_types
)
const
;
/*
* Get the notification events
...
...
@@ -142,14 +142,14 @@ class nrf_subscription {
* @param [const boost::posix_time::ptime &]t: validity time
* @return
*/
void
set_validity_time
(
const
boost
::
posix_time
::
ptime
&
t
);
void
set_validity_time
(
const
boost
::
posix_time
::
ptime
&
t
);
/*
* Get the validity time
* @param [boost::posix_time::ptime &]t: validity time
* @return
*/
void
get_validity_time
(
boost
::
posix_time
::
ptime
&
t
)
const
;
void
get_validity_time
(
boost
::
posix_time
::
ptime
&
t
)
const
;
/*
* Get the validity time
...
...
@@ -171,7 +171,7 @@ class nrf_subscription {
* registered NF profile
* @return void
*/
void
handle_nf_status_registered
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
);
void
handle_nf_status_registered
(
const
std
::
shared_ptr
<
nrf_profile
>
&
profile
);
/*
* Display all the members of a subscription
...
...
@@ -185,7 +185,7 @@ class nrf_subscription {
std
::
string
subscription_id
;
subscription_condition_t
sub_condition
;
std
::
vector
<
uint8_t
>
notif_events
;
nrf_event
&
m_event_sub
;
nrf_event
&
m_event_sub
;
bs2
::
connection
ev_connection
;
boost
::
posix_time
::
ptime
validity_time
;
};
...
...
src/nrf_app/task_manager.cpp
View file @
7d14dd54
...
...
@@ -38,7 +38,7 @@
using
namespace
oai
::
nrf
::
app
;
//------------------------------------------------------------------------------
task_manager
::
task_manager
(
nrf_event
&
ev
)
:
event_sub_
(
ev
)
{
task_manager
::
task_manager
(
nrf_event
&
ev
)
:
event_sub_
(
ev
)
{
struct
itimerspec
its
;
sfd
=
timerfd_create
(
CLOCK_MONOTONIC
,
0
);
...
...
@@ -55,7 +55,9 @@ task_manager::task_manager(nrf_event &ev) : event_sub_(ev) {
}
//------------------------------------------------------------------------------
void
task_manager
::
run
()
{
manage_tasks
();
}
void
task_manager
::
run
()
{
manage_tasks
();
}
//------------------------------------------------------------------------------
void
task_manager
::
manage_tasks
()
{
...
...
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