Commit 7d14dd54 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Update Clang-format

parent b71f828a
#
# 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)
...@@ -24,29 +24,29 @@ ...@@ -24,29 +24,29 @@
#define HEART_BEAT_TIMER 10 #define HEART_BEAT_TIMER 10
#define _unused(x) ((void)(x)) #define _unused(x) ((void) (x))
typedef enum nf_type_s { typedef enum nf_type_s {
NF_TYPE_NRF = 0, NF_TYPE_NRF = 0,
NF_TYPE_AMF = 1, NF_TYPE_AMF = 1,
NF_TYPE_SMF = 2, NF_TYPE_SMF = 2,
NF_TYPE_AUSF = 3, NF_TYPE_AUSF = 3,
NF_TYPE_NEF = 4, NF_TYPE_NEF = 4,
NF_TYPE_PCF = 5, NF_TYPE_PCF = 5,
NF_TYPE_SMSF = 6, NF_TYPE_SMSF = 6,
NF_TYPE_NSSF = 7, NF_TYPE_NSSF = 7,
NF_TYPE_UDR = 8, NF_TYPE_UDR = 8,
NF_TYPE_LMF = 9, NF_TYPE_LMF = 9,
NF_TYPE_GMLC = 10, NF_TYPE_GMLC = 10,
NF_TYPE_5G_EIR = 11, NF_TYPE_5G_EIR = 11,
NF_TYPE_SEPP = 12, NF_TYPE_SEPP = 12,
NF_TYPE_UPF = 13, NF_TYPE_UPF = 13,
NF_TYPE_N3IWF = 14, NF_TYPE_N3IWF = 14,
NF_TYPE_AF = 15, NF_TYPE_AF = 15,
NF_TYPE_UDSF = 16, NF_TYPE_UDSF = 16,
NF_TYPE_BSF = 17, NF_TYPE_BSF = 17,
NF_TYPE_CHF = 18, NF_TYPE_CHF = 18,
NF_TYPE_NWDAF = 19, NF_TYPE_NWDAF = 19,
NF_TYPE_UNKNOWN = 20 NF_TYPE_UNKNOWN = 20
} nf_type_t; } nf_type_t;
...@@ -56,12 +56,12 @@ static const std::vector<std::string> nf_type_e2str = { ...@@ -56,12 +56,12 @@ static const std::vector<std::string> nf_type_e2str = {
"N3IWF", "AF", "UDSF", "BSF", "CHF", "NWDAF", "UNKNOWN"}; "N3IWF", "AF", "UDSF", "BSF", "CHF", "NWDAF", "UNKNOWN"};
typedef enum patch_op_type_s { typedef enum patch_op_type_s {
PATCH_OP_ADD = 0, PATCH_OP_ADD = 0,
PATCH_OP_REMOVE = 1, PATCH_OP_REMOVE = 1,
PATCH_OP_REPLACE = 2, PATCH_OP_REPLACE = 2,
PATCH_OP_MOVE = 3, PATCH_OP_MOVE = 3,
PATCH_OP_COPY = 4, PATCH_OP_COPY = 4,
PATCH_OP_TEST = 5, PATCH_OP_TEST = 5,
PATCH_OP_UNKNOWN = 6 PATCH_OP_UNKNOWN = 6
} patch_op_type_t; } patch_op_type_t;
...@@ -73,14 +73,14 @@ static const std::vector<std::string> patch_op_type_e2str = { ...@@ -73,14 +73,14 @@ static const std::vector<std::string> patch_op_type_e2str = {
typedef uint32_t evsub_id_t; typedef uint32_t evsub_id_t;
#define EVSUB_ID_FMT "0x%" PRIx32 #define EVSUB_ID_FMT "0x%" PRIx32
#define EVSUB_ID_SCAN_FMT SCNx32 #define EVSUB_ID_SCAN_FMT SCNx32
#define INVALID_EVSUB_ID ((evsub_id_t)0x00000000) #define INVALID_EVSUB_ID ((evsub_id_t) 0x00000000)
#define UNASSIGNED_EVSUB_ID ((evsub_id_t)0x00000000) #define UNASSIGNED_EVSUB_ID ((evsub_id_t) 0x00000000)
#define NNRF_NFM_BASE "/nnrf-nfm/" #define NNRF_NFM_BASE "/nnrf-nfm/"
#define NNRF_NFM_NF_INSTANCE "/nf-instances/" #define NNRF_NFM_NF_INSTANCE "/nf-instances/"
#define NF_CURL_TIMEOUT_MS 1000L #define NF_CURL_TIMEOUT_MS 1000L
#define MAX_WAIT_MSECS 20000 //1 second #define MAX_WAIT_MSECS 20000 // 1 second
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -41,19 +41,19 @@ namespace app { ...@@ -41,19 +41,19 @@ namespace app {
class nrf_client { class nrf_client {
private: private:
CURLM *curl_multi; CURLM* curl_multi;
std::vector<CURL *> handles; std::vector<CURL*> handles;
struct curl_slist *headers; struct curl_slist* headers;
nrf_event &m_event_sub; nrf_event& m_event_sub;
bs2::connection bs2::connection
task_connection; // connection for performing curl_multi every 1ms task_connection; // connection for performing curl_multi every 1ms
public: public:
nrf_client(nrf_event &ev); nrf_client(nrf_event& ev);
virtual ~nrf_client(); virtual ~nrf_client();
nrf_client(nrf_client const &) = delete; nrf_client(nrf_client const&) = delete;
void operator=(nrf_client const &) = delete; void operator=(nrf_client const&) = delete;
/* /*
* Send Notification for the associated event to the subscriber * Send Notification for the associated event to the subscriber
...@@ -61,8 +61,8 @@ class nrf_client { ...@@ -61,8 +61,8 @@ class nrf_client {
* @param [const std::string &] uri: URI of the subscribed NF * @param [const std::string &] uri: URI of the subscribed NF
* @return void * @return void
*/ */
void notify_subscribed_event(const std::shared_ptr<nrf_profile> &profile, void notify_subscribed_event(
const std::string &uri); const std::shared_ptr<nrf_profile>& profile, const std::string& uri);
/* /*
* Send Notification for the associated event to the subscriber * Send Notification for the associated event to the subscriber
...@@ -71,8 +71,8 @@ class nrf_client { ...@@ -71,8 +71,8 @@ class nrf_client {
* @return void * @return void
*/ */
void notify_subscribed_event_multi( void notify_subscribed_event_multi(
const std::shared_ptr<nrf_profile> &profile, const uint8_t &event_type, const std::shared_ptr<nrf_profile>& profile, const uint8_t& event_type,
const std::vector<std::string> &uris); const std::vector<std::string>& uris);
/* /*
* Send Notification for the associated event to the subscribers * Send Notification for the associated event to the subscribers
...@@ -81,9 +81,9 @@ class nrf_client { ...@@ -81,9 +81,9 @@ class nrf_client {
* @param [const std::vector<std::string> &] uris: list of subscribed NFs' URI * @param [const std::vector<std::string> &] uris: list of subscribed NFs' URI
* @return void * @return void
*/ */
void notify_subscribed_event(const std::shared_ptr<nrf_profile> &profile, void notify_subscribed_event(
const uint8_t &event_type, const std::shared_ptr<nrf_profile>& profile, const uint8_t& event_type,
const std::vector<std::string> &uris); const std::vector<std::string>& uris);
/* /*
* Create Curl handle for multi curl * Create Curl handle for multi curl
...@@ -92,8 +92,9 @@ class nrf_client { ...@@ -92,8 +92,9 @@ class nrf_client {
* @param [std::string &] response_data: response data * @param [std::string &] response_data: response data
* @return pointer to the created curl * @return pointer to the created curl
*/ */
CURL *curl_create_handle(const std::string &uri, const std::string &data, CURL* curl_create_handle(
std::string &response_data); const std::string& uri, const std::string& data,
std::string& response_data);
/* /*
* Prepare to send a request using curl multi * Prepare to send a request using curl multi
...@@ -102,8 +103,9 @@ class nrf_client { ...@@ -102,8 +103,9 @@ class nrf_client {
* @param [std::string &] response_data: response data * @param [std::string &] response_data: response data
* @return void * @return void
*/ */
void send_curl_multi(const std::string &uri, const std::string &data, void send_curl_multi(
std::string &response_data); const std::string& uri, const std::string& data,
std::string& response_data);
/* /*
* Perform curl multi to actually process the available data * Perform curl multi to actually process the available data
......
...@@ -58,7 +58,7 @@ using namespace oai::nrf::app; ...@@ -58,7 +58,7 @@ using namespace oai::nrf::app;
extern nrf_config nrf_cfg; 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); if_cfg.lookupValue(NRF_CONFIG_STRING_INTERFACE_NAME, cfg.if_name);
util::trim(cfg.if_name); util::trim(cfg.if_name);
if (not boost::iequals(cfg.if_name, "none")) { if (not boost::iequals(cfg.if_name, "none")) {
...@@ -66,20 +66,20 @@ int nrf_config::load_interface(const Setting &if_cfg, interface_cfg_t &cfg) { ...@@ -66,20 +66,20 @@ int nrf_config::load_interface(const Setting &if_cfg, interface_cfg_t &cfg) {
if_cfg.lookupValue(NRF_CONFIG_STRING_IPV4_ADDRESS, address); if_cfg.lookupValue(NRF_CONFIG_STRING_IPV4_ADDRESS, address);
util::trim(address); util::trim(address);
if (boost::iequals(address, "read")) { if (boost::iequals(address, "read")) {
if (get_inet_addr_infos_from_iface(cfg.if_name, cfg.addr4, cfg.network4, if (get_inet_addr_infos_from_iface(
cfg.mtu)) { cfg.if_name, cfg.addr4, cfg.network4, cfg.mtu)) {
Logger::nrf_app().error( Logger::nrf_app().error(
"Could not read %s network interface configuration", cfg.if_name); "Could not read %s network interface configuration", cfg.if_name);
return RETURNerror; return RETURNerror;
} }
} else { } else {
std::vector<std::string> words; std::vector<std::string> words;
boost::split(words, address, boost::is_any_of("/"), boost::split(
boost::token_compress_on); words, address, boost::is_any_of("/"), boost::token_compress_on);
if (words.size() != 2) { if (words.size() != 2) {
Logger::nrf_app().error("Bad value " NRF_CONFIG_STRING_IPV4_ADDRESS Logger::nrf_app().error(
" = %s in config file", "Bad value " NRF_CONFIG_STRING_IPV4_ADDRESS " = %s in config file",
address.c_str()); address.c_str());
return RETURNerror; return RETURNerror;
} }
unsigned char buf_in_addr[sizeof(struct in6_addr)]; unsigned char buf_in_addr[sizeof(struct in6_addr)];
...@@ -93,9 +93,9 @@ int nrf_config::load_interface(const Setting &if_cfg, interface_cfg_t &cfg) { ...@@ -93,9 +93,9 @@ int nrf_config::load_interface(const Setting &if_cfg, interface_cfg_t &cfg) {
util::trim(words.at(0)).c_str()); util::trim(words.at(0)).c_str());
return RETURNerror; return RETURNerror;
} }
cfg.network4.s_addr = cfg.network4.s_addr = htons(
htons(ntohs(cfg.addr4.s_addr) & ntohs(cfg.addr4.s_addr) &
0xFFFFFFFF << (32 - std::stoi(util::trim(words.at(1))))); 0xFFFFFFFF << (32 - std::stoi(util::trim(words.at(1)))));
} }
if_cfg.lookupValue(NRF_CONFIG_STRING_PORT, cfg.port); 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) { ...@@ -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; Config cfg;
unsigned char buf_in6_addr[sizeof(struct in6_addr)]; unsigned char buf_in6_addr[sizeof(struct in6_addr)];
// Read the file. If there is an error, report it and exit. // Read the file. If there is an error, report it and exit.
try { try {
cfg.readFile(config_file.c_str()); cfg.readFile(config_file.c_str());
} catch (const FileIOException &fioex) { } catch (const FileIOException& fioex) {
Logger::nrf_app().error("I/O error while reading file %s - %s", Logger::nrf_app().error(
config_file.c_str(), fioex.what()); "I/O error while reading file %s - %s", config_file.c_str(),
fioex.what());
throw; throw;
} catch (const ParseException &pex) { } catch (const ParseException& pex) {
Logger::nrf_app().error("Parse error at %s:%d - %s", pex.getFile(), Logger::nrf_app().error(
pex.getLine(), pex.getError()); "Parse error at %s:%d - %s", pex.getFile(), pex.getLine(),
pex.getError());
throw; throw;
} }
const Setting &root = cfg.getRoot(); const Setting& root = cfg.getRoot();
try { try {
const Setting &nrf_cfg = root[NRF_CONFIG_STRING_NRF_CONFIG]; const Setting& nrf_cfg = root[NRF_CONFIG_STRING_NRF_CONFIG];
} catch (const SettingNotFoundException &nfex) { } catch (const SettingNotFoundException& nfex) {
Logger::nrf_app().error("%s : %s", nfex.what(), nfex.getPath()); Logger::nrf_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror; return RETURNerror;
} }
const Setting &nrf_cfg = root[NRF_CONFIG_STRING_NRF_CONFIG]; const Setting& nrf_cfg = root[NRF_CONFIG_STRING_NRF_CONFIG];
try { try {
nrf_cfg.lookupValue(NRF_CONFIG_STRING_INSTANCE, instance); nrf_cfg.lookupValue(NRF_CONFIG_STRING_INSTANCE, instance);
} catch (const SettingNotFoundException &nfex) { } catch (const SettingNotFoundException& nfex) {
Logger::nrf_app().info("%s : %s, using defaults", nfex.what(), Logger::nrf_app().info(
nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
} }
try { try {
nrf_cfg.lookupValue(NRF_CONFIG_STRING_PID_DIRECTORY, pid_dir); nrf_cfg.lookupValue(NRF_CONFIG_STRING_PID_DIRECTORY, pid_dir);
} catch (const SettingNotFoundException &nfex) { } catch (const SettingNotFoundException& nfex) {
Logger::nrf_app().info("%s : %s, using defaults", nfex.what(), Logger::nrf_app().info(
nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
} }
try { 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); load_interface(sbi_cfg, sbi);
// HTTP2 port // HTTP2 port
if (!(sbi_cfg.lookupValue(NRF_CONFIG_STRING_SBI_HTTP2_PORT, if (!(sbi_cfg.lookupValue(
sbi_http2_port))) { NRF_CONFIG_STRING_SBI_HTTP2_PORT, sbi_http2_port))) {
Logger::nrf_app().error(NRF_CONFIG_STRING_SBI_HTTP2_PORT "failed"); Logger::nrf_app().error(NRF_CONFIG_STRING_SBI_HTTP2_PORT "failed");
throw(NRF_CONFIG_STRING_SBI_HTTP2_PORT "failed"); throw(NRF_CONFIG_STRING_SBI_HTTP2_PORT "failed");
} }
// SBI API VERSION // SBI API VERSION
if (!(sbi_cfg.lookupValue(NRF_CONFIG_STRING_API_VERSION, if (!(sbi_cfg.lookupValue(
sbi_api_version))) { NRF_CONFIG_STRING_API_VERSION, sbi_api_version))) {
Logger::nrf_app().error(NRF_CONFIG_STRING_API_VERSION "failed"); Logger::nrf_app().error(NRF_CONFIG_STRING_API_VERSION "failed");
throw(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()); Logger::nrf_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror; return RETURNerror;
} }
...@@ -173,8 +175,8 @@ int nrf_config::load(const string &config_file) { ...@@ -173,8 +175,8 @@ int nrf_config::load(const string &config_file) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_config::display() { void nrf_config::display() {
Logger::nrf_app().info("==== EURECOM %s v%s ====", PACKAGE_NAME, Logger::nrf_app().info(
PACKAGE_VERSION); "==== EURECOM %s v%s ====", PACKAGE_NAME, PACKAGE_VERSION);
Logger::nrf_app().info("Configuration NRF:"); Logger::nrf_app().info("Configuration NRF:");
Logger::nrf_app().info("- Instance ..............: %d\n", instance); Logger::nrf_app().info("- Instance ..............: %d\n", instance);
Logger::nrf_app().info("- PID dir ...............: %s\n", pid_dir.c_str()); Logger::nrf_app().info("- PID dir ...............: %s\n", pid_dir.c_str());
...@@ -184,8 +186,8 @@ void nrf_config::display() { ...@@ -184,8 +186,8 @@ void nrf_config::display() {
Logger::nrf_app().info(" IPv4 Addr ...........: %s", inet_ntoa(sbi.addr4)); Logger::nrf_app().info(" IPv4 Addr ...........: %s", inet_ntoa(sbi.addr4));
Logger::nrf_app().info(" Port ................: %d", sbi.port); Logger::nrf_app().info(" Port ................: %d", sbi.port);
Logger::nrf_app().info(" HTTP2 port ..........: %d", sbi_http2_port); Logger::nrf_app().info(" HTTP2 port ..........: %d", sbi_http2_port);
Logger::nrf_app().info(" API version..........: %s", Logger::nrf_app().info(
sbi_api_version.c_str()); " API version..........: %s", sbi_api_version.c_str());
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -63,7 +63,7 @@ typedef struct interface_cfg_s { ...@@ -63,7 +63,7 @@ typedef struct interface_cfg_s {
class nrf_config { class nrf_config {
private: 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: public:
/* Reader/writer lock for this configuration */ /* Reader/writer lock for this configuration */
...@@ -78,14 +78,14 @@ class nrf_config { ...@@ -78,14 +78,14 @@ class nrf_config {
bool local_configuration; bool local_configuration;
nrf_config() : m_rw_lock(), pid_dir(), instance(0), sbi() { nrf_config() : m_rw_lock(), pid_dir(), instance(0), sbi() {
sbi.port = 80; sbi.port = 80;
sbi_http2_port = 8080; sbi_http2_port = 8080;
sbi_api_version = "v1"; sbi_api_version = "v1";
}; };
virtual ~nrf_config(); virtual ~nrf_config();
void lock() { m_rw_lock.lock(); }; void lock() { m_rw_lock.lock(); };
void unlock() { m_rw_lock.unlock(); }; void unlock() { m_rw_lock.unlock(); };
int load(const std::string &config_file); int load(const std::string& config_file);
void display(); void display();
}; };
......
...@@ -35,9 +35,8 @@ ...@@ -35,9 +35,8 @@
using namespace oai::nrf::app; using namespace oai::nrf::app;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bs2::connection nrf_event::subscribe_task_tick(const task_sig_t::slot_type &sig, bs2::connection nrf_event::subscribe_task_tick(
uint64_t period, const task_sig_t::slot_type& sig, uint64_t period, uint64_t start) {
uint64_t start) {
/* Wrap the actual callback in a lambda. The latter checks whether the /* 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 * 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 * 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, ...@@ -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( 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) { uint64_t start) {
/* Wrap the actual callback in a lambda. The latter checks whether the /* 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 * 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 * 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 * to register to be notified every X ms instead of every ms, which provides
* greater freedom to implementations. */ * 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); if (t >= start && (t - start) % period == 0) sig(c, t);
}; };
return task_tick.connect_extended(f); return task_tick.connect_extended(f);
...@@ -66,24 +65,24 @@ bs2::connection nrf_event::subscribe_task_tick_extended( ...@@ -66,24 +65,24 @@ bs2::connection nrf_event::subscribe_task_tick_extended(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bs2::connection nrf_event::subscribe_nf_status_change( 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); return nf_status_change.connect(sig);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bs2::connection nrf_event::subscribe_nf_status_registered( 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); return nf_status_registered.connect(sig);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bs2::connection nrf_event::subscribe_nf_status_deregistered( 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); return nf_status_deregistered.connect(sig);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bs2::connection nrf_event::subscribe_nf_status_profile_changed( 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); return nf_status_profile_changed.connect(sig);
} }
...@@ -47,10 +47,10 @@ class task_manager; ...@@ -47,10 +47,10 @@ class task_manager;
class nrf_event { class nrf_event {
public: public:
nrf_event(){}; nrf_event(){};
nrf_event(nrf_event const &) = delete; nrf_event(nrf_event const&) = delete;
void operator=(nrf_event const &) = delete; void operator=(nrf_event const&) = delete;
static nrf_event &get_instance() { static nrf_event& get_instance() {
static nrf_event instance; static nrf_event instance;
return instance; return instance;
} }
...@@ -67,8 +67,8 @@ class nrf_event { ...@@ -67,8 +67,8 @@ class nrf_event {
* @param [uint64_t] start: * @param [uint64_t] start:
* @return void * @return void
*/ */
bs2::connection subscribe_task_tick(const task_sig_t::slot_type &sig, bs2::connection subscribe_task_tick(
uint64_t period, uint64_t start = 0); const task_sig_t::slot_type& sig, uint64_t period, uint64_t start = 0);
/* /*
* Subscribe to the extended task tick event * Subscribe to the extended task tick event
...@@ -78,7 +78,7 @@ class nrf_event { ...@@ -78,7 +78,7 @@ class nrf_event {
* @return void * @return void
*/ */
bs2::connection subscribe_task_tick_extended( 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); uint64_t start = 0);
/* /*
...@@ -89,16 +89,16 @@ class nrf_event { ...@@ -89,16 +89,16 @@ class nrf_event {
* @return void * @return void
*/ */
bs2::connection subscribe_nf_status_change( 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( 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( 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( bs2::connection subscribe_nf_status_profile_changed(
const nf_status_sig_t::slot_type &sig); const nf_status_sig_t::slot_type& sig);
private: private:
task_sig_t task_tick; task_sig_t task_tick;
......
...@@ -40,23 +40,23 @@ namespace app { ...@@ -40,23 +40,23 @@ namespace app {
class nrf_profile; class nrf_profile;
typedef bs2::signal_type<void(uint64_t), typedef bs2::signal_type<
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type void(uint64_t), bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
task_sig_t; task_sig_t;
// Signal for NF Status // Signal for NF Status
// Subscription ID, NF Status // Subscription ID, NF Status
typedef bs2::signal_type<void(const std::string &), typedef bs2::signal_type<
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type void(const std::string&), bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
nf_status_sig_t; nf_status_sig_t;
typedef bs2::signal_type<void(const std::shared_ptr<nrf_profile> &p), typedef bs2::signal_type<
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type void(const std::shared_ptr<nrf_profile>& p),
nf_deregistered_sig_t; bs2::keywords::mutex_type<bs2::dummy_mutex>>::type nf_deregistered_sig_t;
typedef bs2::signal_type<void(const std::shared_ptr<nrf_profile> &p), typedef bs2::signal_type<
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type void(const std::shared_ptr<nrf_profile>& p),
nf_status_change_sig_t; bs2::keywords::mutex_type<bs2::dummy_mutex>>::type nf_status_change_sig_t;
} // namespace app } // namespace app
} // namespace nrf } // namespace nrf
......
...@@ -36,12 +36,10 @@ ...@@ -36,12 +36,10 @@
using namespace oai::nrf::app; using namespace oai::nrf::app;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool nrf_jwt::generate_signature(const std::string &nf_consumer_id, bool nrf_jwt::generate_signature(
const std::string &scope, const std::string& nf_consumer_id, const std::string& scope,
const std::string &nf_type, const std::string& nf_type, const std::string& target_nf_type,
const std::string &target_nf_type, const std::string& nrf_instance_id, std::string& signature) const {
const std::string &nrf_instance_id,
std::string &signature) const {
std::string key; std::string key;
get_secret_key(scope, nf_type, target_nf_type, key); get_secret_key(scope, nf_type, target_nf_type, key);
// Create JWT object // Create JWT object
...@@ -59,11 +57,10 @@ bool nrf_jwt::generate_signature(const std::string &nf_consumer_id, ...@@ -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, bool nrf_jwt::generate_signature(
const std::string &scope, const std::string& nf_consumer_id, const std::string& scope,
const std::string &target_nf_instance_Id, const std::string& target_nf_instance_Id,
const std::string &nrf_instance_id, const std::string& nrf_instance_id, std::string& signature) const {
std::string &signature) const {
std::string key; std::string key;
get_secret_key(scope, target_nf_instance_Id, key); get_secret_key(scope, target_nf_instance_Id, key);
// Create JWT object // Create JWT object
...@@ -81,18 +78,17 @@ bool nrf_jwt::generate_signature(const std::string &nf_consumer_id, ...@@ -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, bool nrf_jwt::get_secret_key(
const std::string &nf_type, const std::string& scope, const std::string& nf_type,
const std::string &target_nf_type, const std::string& target_nf_type, std::string& key) const {
std::string &key) const {
// TODO: // TODO:
key = "secret"; key = "secret";
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool nrf_jwt::get_secret_key(const std::string &scope, bool nrf_jwt::get_secret_key(
const std::string &target_nf_instance_Id, const std::string& scope, const std::string& target_nf_instance_Id,
std::string &key) const { std::string& key) const {
// TODO: // TODO:
key = "secret"; key = "secret";
} }
......
...@@ -53,11 +53,10 @@ class nrf_jwt { ...@@ -53,11 +53,10 @@ class nrf_jwt {
* @param [std::string &] signature: generated signature * @param [std::string &] signature: generated signature
* @return void * @return void
*/ */
bool generate_signature(const std::string &nf_consumer_id, bool generate_signature(
const std::string &scope, const std::string &nf_type, const std::string& nf_consumer_id, const std::string& scope,
const std::string &target_nf_type, const std::string& nf_type, const std::string& target_nf_type,
const std::string &nrf_instance_id, const std::string& nrf_instance_id, std::string& signature) const;
std::string &signature) const;
/* /*
* Generate signature for the requested consumer * Generate signature for the requested consumer
...@@ -70,11 +69,10 @@ class nrf_jwt { ...@@ -70,11 +69,10 @@ class nrf_jwt {
* @param [std::string &] signature: generated signature * @param [std::string &] signature: generated signature
* @return void * @return void
*/ */
bool generate_signature(const std::string &nf_consumer_id, bool generate_signature(
const std::string &scope, const std::string& nf_consumer_id, const std::string& scope,
const std::string &target_nf_instance_Id, const std::string& target_nf_instance_Id,
const std::string &nrf_instance_id, const std::string& nrf_instance_id, std::string& signature) const;
std::string &signature) const;
/* /*
* Get the secret key * Get the secret key
...@@ -85,9 +83,9 @@ class nrf_jwt { ...@@ -85,9 +83,9 @@ class nrf_jwt {
* @param [std::string &] key: secret key * @param [std::string &] key: secret key
* @return void * @return void
*/ */
bool get_secret_key(const std::string &scope, const std::string &nf_type, bool get_secret_key(
const std::string &target_nf_type, const std::string& scope, const std::string& nf_type,
std::string &key) const; const std::string& target_nf_type, std::string& key) const;
/* /*
* Get the secret key * Get the secret key
...@@ -98,9 +96,9 @@ class nrf_jwt { ...@@ -98,9 +96,9 @@ class nrf_jwt {
* @param [std::string &] key: secret key * @param [std::string &] key: secret key
* @return void * @return void
*/ */
bool get_secret_key(const std::string &scope, bool get_secret_key(
const std::string &target_nf_instance_Id, const std::string& scope, const std::string& target_nf_instance_Id,
std::string &key) const; std::string& key) const;
}; };
} // namespace app } // namespace app
......
This diff is collapsed.
This diff is collapsed.
...@@ -36,29 +36,35 @@ ...@@ -36,29 +36,35 @@
using namespace oai::nrf::app; 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( 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; nf_instances = instances;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_search_result::add_nf_instance( 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); nf_instances.push_back(instance);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_search_result::get_nf_instances( 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; instances = nf_instances;
} }
...@@ -69,12 +75,12 @@ std::vector<std::shared_ptr<nrf_profile>> nrf_search_result::get_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; 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; p = validity_period;
} }
...@@ -84,22 +90,22 @@ uint64_t nrf_search_result::get_validity_period() const { ...@@ -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; 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; 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; 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; l = limit_nf_instances;
} }
...@@ -121,14 +127,14 @@ void nrf_search_result::display() { ...@@ -121,14 +127,14 @@ void nrf_search_result::display() {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_search_result::to_json(nlohmann::json &data, void nrf_search_result::to_json(
const uint32_t &limit_nfs) const { nlohmann::json& data, const uint32_t& limit_nfs) const {
data = {}; data = {};
data["validityPeriod"] = validity_period; data["validityPeriod"] = validity_period;
data["nfInstances"] = nlohmann::json::array(); data["nfInstances"] = nlohmann::json::array();
uint32_t limit = limit_nfs > 0 ? limit_nfs : nf_instances.size(); uint32_t limit = limit_nfs > 0 ? limit_nfs : nf_instances.size();
int i = 0; int i = 0;
for (auto instance : nf_instances) { for (auto instance : nf_instances) {
if (i < limit) { if (i < limit) {
nlohmann::json instance_json = {}; nlohmann::json instance_json = {};
......
...@@ -44,27 +44,27 @@ class nrf_search_result { ...@@ -44,27 +44,27 @@ class nrf_search_result {
nrf_search_result() { nrf_search_result() {
limit_nf_instances = 10; // default value, TODO: to be removed 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() { virtual ~nrf_search_result() {
Logger::nrf_app().debug("Delete NRF Subscription instance..."); 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 * Set the search id
* @param [const std::string &]: id: Search id * @param [const std::string &]: id: Search id
* @return void * @return void
*/ */
void set_search_id(const std::string &id); void set_search_id(const std::string& id);
/* /*
* Get the search id * Get the search id
* @param [std::string &]: id: search id * @param [std::string &]: id: search id
* @return void * @return void
*/ */
void get_search_id(std::string &id) const; void get_search_id(std::string& id) const;
/* /*
* Get the search id * Get the search id
...@@ -80,7 +80,7 @@ class nrf_search_result { ...@@ -80,7 +80,7 @@ class nrf_search_result {
* @return void * @return void
*/ */
void set_nf_instances( 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 * Add an nf instance to the list of nrf profile instances
...@@ -88,7 +88,7 @@ class nrf_search_result { ...@@ -88,7 +88,7 @@ class nrf_search_result {
* instance * instance
* @return void * @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 * Get the nf instances
...@@ -97,7 +97,7 @@ class nrf_search_result { ...@@ -97,7 +97,7 @@ class nrf_search_result {
* @return void * @return void
*/ */
void get_nf_instances( 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 * Get the nf instances
...@@ -112,14 +112,14 @@ class nrf_search_result { ...@@ -112,14 +112,14 @@ class nrf_search_result {
* @param [const uint64_t &] p: validity period * @param [const uint64_t &] p: validity period
* @return * @return
*/ */
void set_validity_period(const uint64_t &v); void set_validity_period(const uint64_t& v);
/* /*
* Get the validity period * Get the validity period
* @param [uint64_t &]p: validity period * @param [uint64_t &]p: validity period
* @return * @return
*/ */
void get_validity_period(uint64_t &p) const; void get_validity_period(uint64_t& p) const;
/* /*
* Get the validity period * Get the validity period
...@@ -133,14 +133,14 @@ class nrf_search_result { ...@@ -133,14 +133,14 @@ class nrf_search_result {
* @param [const uint32_t &] n: the total number of NF Instances found by NRF * @param [const uint32_t &] n: the total number of NF Instances found by NRF
* @return void * @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 * Get the the total number of NF Instances found by NRF
* @param [uint32_t &] n: the total number of NF Instances found by NRF * @param [uint32_t &] n: the total number of NF Instances found by NRF
* @return void * @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 * Set the maximum number of NFProfiles to be returned in the response
...@@ -148,7 +148,7 @@ class nrf_search_result { ...@@ -148,7 +148,7 @@ class nrf_search_result {
* returned in the response * returned in the response
* @return void * @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 * Get the maximum number of NFProfiles to be returned in the response
...@@ -156,7 +156,7 @@ class nrf_search_result { ...@@ -156,7 +156,7 @@ class nrf_search_result {
* the response * the response
* @return void * @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 * Get the maximum number of NFProfiles to be returned in the response
...@@ -179,7 +179,7 @@ class nrf_search_result { ...@@ -179,7 +179,7 @@ class nrf_search_result {
* json data 0, means without any restriction * json data 0, means without any restriction
* @return void * @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: private:
std::vector<std::shared_ptr<nrf_profile>> nf_instances; std::vector<std::shared_ptr<nrf_profile>> nf_instances;
......
...@@ -37,12 +37,12 @@ ...@@ -37,12 +37,12 @@
using namespace oai::nrf::app; 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; 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; sub = subscription_id;
} }
...@@ -53,23 +53,23 @@ std::string nrf_subscription::get_subscription_id() const { ...@@ -53,23 +53,23 @@ std::string nrf_subscription::get_subscription_id() const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_subscription::set_notification_uri( void nrf_subscription::set_notification_uri(
const std::string &notification_uri) { const std::string& notification_uri) {
nf_status_notification_uri = notification_uri; nf_status_notification_uri = notification_uri;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_subscription::get_notification_uri( void nrf_subscription::get_notification_uri(
std::string &notification_uri) const { std::string& notification_uri) const {
notification_uri = nf_status_notification_uri; 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; 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; c = sub_condition;
} }
...@@ -81,17 +81,17 @@ subscription_condition_t nrf_subscription::get_sub_condition() const { ...@@ -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; 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); 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; ev_types = notif_events;
} }
...@@ -101,12 +101,12 @@ std::vector<uint8_t> nrf_subscription::get_notif_events() const { ...@@ -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; 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; t = validity_time;
} }
...@@ -120,18 +120,18 @@ void nrf_subscription::display() { ...@@ -120,18 +120,18 @@ void nrf_subscription::display() {
Logger::nrf_app().debug("Subscription information"); Logger::nrf_app().debug("Subscription information");
Logger::nrf_app().debug("\tSub ID: %s", subscription_id.c_str()); Logger::nrf_app().debug("\tSub ID: %s", subscription_id.c_str());
Logger::nrf_app().debug("\tNotification URI: %s", Logger::nrf_app().debug(
nf_status_notification_uri.c_str()); "\tNotification URI: %s", nf_status_notification_uri.c_str());
Logger::nrf_app().debug("\tSubscription condition: %s", Logger::nrf_app().debug(
sub_condition.to_string().c_str()); "\tSubscription condition: %s", sub_condition.to_string().c_str());
std::string notif_events_str = {}; std::string notif_events_str = {};
for (auto n : notif_events) { for (auto n : notif_events) {
notif_events_str.append(notification_event_type_e2str[n]); notif_events_str.append(notification_event_type_e2str[n]);
notif_events_str.append(", "); notif_events_str.append(", ");
} }
Logger::nrf_app().debug("\tNotification Events: %s", Logger::nrf_app().debug(
notif_events_str.c_str()); "\tNotification Events: %s", notif_events_str.c_str());
Logger::nrf_app().debug( Logger::nrf_app().debug(
"\tValidity time: %s", "\tValidity time: %s",
boost::posix_time::to_iso_string(validity_time).c_str()); boost::posix_time::to_iso_string(validity_time).c_str());
...@@ -142,21 +142,21 @@ void nrf_subscription::subscribe_nf_status_registered() { ...@@ -142,21 +142,21 @@ void nrf_subscription::subscribe_nf_status_registered() {
Logger::nrf_app().debug("Subscribe to NF status change event"); Logger::nrf_app().debug("Subscribe to NF status change event");
ev_connection = ev_connection =
m_event_sub.subscribe_nf_status_change( // TODO: To be updated m_event_sub.subscribe_nf_status_change( // TODO: To be updated
boost::bind(&nrf_subscription::handle_nf_status_registered, this, boost::bind(
_1)); &nrf_subscription::handle_nf_status_registered, this, _1));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void nrf_subscription::handle_nf_status_registered( 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; std::string nf_instance_id;
profile.get()->get_nf_instance_id(nf_instance_id); profile.get()->get_nf_instance_id(nf_instance_id);
Logger::nrf_app().info( Logger::nrf_app().info(
"Handle NF status registered (subscription ID %s), profile ID %s", "Handle NF status registered (subscription ID %s), profile ID %s",
subscription_id.c_str(), nf_instance_id.c_str()); subscription_id.c_str(), nf_instance_id.c_str());
// TODO: // TODO:
nlohmann::json notification_data = {}; nlohmann::json notification_data = {};
notification_data["event"] = "NF_REGISTERED"; notification_data["event"] = "NF_REGISTERED";
notification_data["nfInstanceUri"] = ""; notification_data["nfInstanceUri"] = "";
// get NF profile based on profile_id // get NF profile based on profile_id
// NFStatusNotify // NFStatusNotify
......
...@@ -44,32 +44,32 @@ using namespace std; ...@@ -44,32 +44,32 @@ using namespace std;
class nrf_subscription { class nrf_subscription {
public: 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"); validity_time = boost::posix_time::from_iso_string("20991231T235959Z");
}; };
nrf_subscription(nrf_subscription const &) = delete; nrf_subscription(nrf_subscription const&) = delete;
virtual ~nrf_subscription() { virtual ~nrf_subscription() {
Logger::nrf_app().debug("Delete NRF Subscription instance..."); Logger::nrf_app().debug("Delete NRF Subscription instance...");
if (ev_connection.connected()) ev_connection.disconnect(); if (ev_connection.connected()) ev_connection.disconnect();
} }
void operator=(nrf_subscription const &) = delete; void operator=(nrf_subscription const&) = delete;
/* /*
* Set the subscription id * Set the subscription id
* @param [const std::string &]: sub_id: Subscription id * @param [const std::string &]: sub_id: Subscription id
* @return void * @return void
*/ */
void set_subscription_id(const std::string &sub_id); void set_subscription_id(const std::string& sub_id);
/* /*
* Get the subscription id * Get the subscription id
* @param [std::string &]: sub_id: Subscription id * @param [std::string &]: sub_id: Subscription id
* @return void * @return void
*/ */
void get_subscription_id(std::string &sub_id) const; void get_subscription_id(std::string& sub_id) const;
/* /*
* Get the subscription id * Get the subscription id
...@@ -83,28 +83,28 @@ class nrf_subscription { ...@@ -83,28 +83,28 @@ class nrf_subscription {
* @param [const std::string &]: notification_uri: Notification URI * @param [const std::string &]: notification_uri: Notification URI
* @return void * @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) * Get the notification URI (URI where the notification will be sent to)
* @param [std::string &]: notification_uri: Notification URI * @param [std::string &]: notification_uri: Notification URI
* @return void * @return void
*/ */
void get_notification_uri(std::string &notification_uri) const; void get_notification_uri(std::string& notification_uri) const;
/* /*
* Set the subscription condition * Set the subscription condition
* @param [const subscription_condition_t &]: c: Subscription condition * @param [const subscription_condition_t &]: c: Subscription condition
* @return void * @return void
*/ */
void set_sub_condition(const subscription_condition_t &c); void set_sub_condition(const subscription_condition_t& c);
/* /*
* Get the subscription condition * Get the subscription condition
* @param [const subscription_condition_t &]: c: Subscription condition * @param [const subscription_condition_t &]: c: Subscription condition
* @return void * @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; // subscription_condition_t get_sub_condition() const;
/* /*
...@@ -113,14 +113,14 @@ class nrf_subscription { ...@@ -113,14 +113,14 @@ class nrf_subscription {
* event types * event types
* @return void * @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 * Add a notification type to the list of notification events
* @param [const uint8_t &]: ev_type: A notification type * @param [const uint8_t &]: ev_type: A notification type
* @return void * @return void
*/ */
void add_notif_event(const uint8_t &ev_type); void add_notif_event(const uint8_t& ev_type);
/* /*
* Get the notification events * Get the notification events
...@@ -128,7 +128,7 @@ class nrf_subscription { ...@@ -128,7 +128,7 @@ class nrf_subscription {
* types * types
* @return void * @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 * Get the notification events
...@@ -142,14 +142,14 @@ class nrf_subscription { ...@@ -142,14 +142,14 @@ class nrf_subscription {
* @param [const boost::posix_time::ptime &]t: validity time * @param [const boost::posix_time::ptime &]t: validity time
* @return * @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 * Get the validity time
* @param [boost::posix_time::ptime &]t: validity time * @param [boost::posix_time::ptime &]t: validity time
* @return * @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 * Get the validity time
...@@ -171,7 +171,7 @@ class nrf_subscription { ...@@ -171,7 +171,7 @@ class nrf_subscription {
* registered NF profile * registered NF profile
* @return void * @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 * Display all the members of a subscription
...@@ -185,7 +185,7 @@ class nrf_subscription { ...@@ -185,7 +185,7 @@ class nrf_subscription {
std::string subscription_id; std::string subscription_id;
subscription_condition_t sub_condition; subscription_condition_t sub_condition;
std::vector<uint8_t> notif_events; std::vector<uint8_t> notif_events;
nrf_event &m_event_sub; nrf_event& m_event_sub;
bs2::connection ev_connection; bs2::connection ev_connection;
boost::posix_time::ptime validity_time; boost::posix_time::ptime validity_time;
}; };
......
...@@ -38,15 +38,15 @@ ...@@ -38,15 +38,15 @@
using namespace oai::nrf::app; 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; struct itimerspec its;
sfd = timerfd_create(CLOCK_MONOTONIC, 0); sfd = timerfd_create(CLOCK_MONOTONIC, 0);
/* Start the timer */ /* Start the timer */
its.it_value.tv_sec = 0; its.it_value.tv_sec = 0;
its.it_value.tv_nsec = 1000 * 1000; its.it_value.tv_nsec = 1000 * 1000;
its.it_interval.tv_sec = its.it_value.tv_sec; its.it_interval.tv_sec = its.it_value.tv_sec;
its.it_interval.tv_nsec = its.it_value.tv_nsec; its.it_interval.tv_nsec = its.it_value.tv_nsec;
if (timerfd_settime(sfd, TFD_TIMER_ABSTIME, &its, NULL) == -1) { if (timerfd_settime(sfd, TFD_TIMER_ABSTIME, &its, NULL) == -1) {
...@@ -55,7 +55,9 @@ task_manager::task_manager(nrf_event &ev) : event_sub_(ev) { ...@@ -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() { void task_manager::manage_tasks() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment