Commit 7b7c4a22 authored by Raphael Defosseux's avatar Raphael Defosseux

Merge branch 'nf_heartbeat' into 'develop'

nf_heartbeat procedure added

See merge request oai/cn5g/oai-cn5g-ausf!20
parents 936b74a6 334742dd
#
# 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)
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/**
* Nausf_DataRepository API OpenAPI file
* Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB,
* ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 2.1.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "PatchItem.h"
#include <iostream>
using namespace std;
namespace oai {
namespace ausf_server {
namespace model {
PatchItem::PatchItem() {
m_Path = "";
m_From = "";
m_Value = "";
m_FromIsSet = false;
m_ValueIsSet = false;
}
PatchItem::~PatchItem() {}
void PatchItem::validate() {
// TODO: implement validation
}
void to_json(nlohmann::json &j, const PatchItem &o) {
j = nlohmann::json();
j["op"] = o.m_Op;
j["path"] = o.m_Path;
if (o.fromIsSet())
j["from"] = o.m_From;
if (o.valueIsSet())
j["value"] = o.m_Value;
}
void from_json(const nlohmann::json &j, PatchItem &o) {
j.at("op").get_to(o.m_Op);
j.at("path").get_to(o.m_Path);
if (j.find("from") != j.end()) {
j.at("from").get_to(o.m_From);
o.m_FromIsSet = true;
}
if (j.find("value") != j.end()) {
j.at("value").get_to(o.m_Value);
o.m_ValueIsSet = true;
}
}
std::string PatchItem::getOp() const { return m_Op; }
void PatchItem::setOp(std::string const &value) { m_Op = value; }
std::string PatchItem::getPath() const { return m_Path; }
void PatchItem::setPath(std::string const &value) { m_Path = value; }
std::string PatchItem::getFrom() const { return m_From; }
void PatchItem::setFrom(std::string const &value) {
m_From = value;
m_FromIsSet = true;
}
bool PatchItem::fromIsSet() const { return m_FromIsSet; }
void PatchItem::unsetFrom() { m_FromIsSet = false; }
std::string PatchItem::getValue() const { return m_Value; }
void PatchItem::setValue(std::string const &value) {
m_Value = value;
m_ValueIsSet = true;
}
bool PatchItem::valueIsSet() const { return m_ValueIsSet; }
void PatchItem::unsetValue() { m_ValueIsSet = false; }
} // namespace model
} // namespace ausf_server
} // namespace oai
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/**
* Nausf_DataRepository API OpenAPI file
* Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB,
* ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 2.1.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* PatchItem.h
*
*
*/
#ifndef PatchItem_H_
#define PatchItem_H_
#include <string>
#include "PatchOperation.h"
//#include "AnyType.h"
#include <nlohmann/json.hpp>
namespace oai {
namespace ausf_server {
namespace model {
/// <summary>
///
/// </summary>
class PatchItem {
public:
PatchItem();
virtual ~PatchItem();
void validate();
/////////////////////////////////////////////
/// PatchItem members
/// <summary>
///
/// </summary>
std::string getOp() const;
void setOp(std::string const &value);
/// <summary>
///
/// </summary>
std::string getPath() const;
void setPath(std::string const &value);
/// <summary>
///
/// </summary>
std::string getFrom() const;
void setFrom(std::string const &value);
bool fromIsSet() const;
void unsetFrom();
/// <summary>
///
/// </summary>
std::string getValue() const;
void setValue(std::string const &value);
bool valueIsSet() const;
void unsetValue();
friend void to_json(nlohmann::json &j, const PatchItem &o);
friend void from_json(const nlohmann::json &j, PatchItem &o);
protected:
std::string m_Op;
std::string m_Path;
std::string m_From;
bool m_FromIsSet;
std::string m_Value;
bool m_ValueIsSet;
};
} // namespace model
} // namespace ausf_server
} // namespace oai
#endif /* PatchItem_H_ */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/**
* Nausf_DataRepository API OpenAPI file
* Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB,
* ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 2.1.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "PatchOperation.h"
namespace oai {
namespace ausf_server {
namespace model {
PatchOperation::PatchOperation() {}
PatchOperation::~PatchOperation() {}
void PatchOperation::validate() {
// TODO: implement validation
}
void to_json(nlohmann::json &j, const PatchOperation &o) {
j = nlohmann::json();
}
void from_json(const nlohmann::json &j, PatchOperation &o) {}
} // namespace model
} // namespace ausf_server
} // namespace oai
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/**
* NUDR_DataRepository API OpenAPI file
* Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB,
* ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 2.1.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* PatchOperation.h
*
*
*/
#ifndef PatchOperation_H_
#define PatchOperation_H_
#include <nlohmann/json.hpp>
#define PATCH_OPERATION_ADD "add"
#define PATCH_OPERATION_COPY "copy"
#define PATCH_OPERATION_MOVE "move"
#define PATCH_OPERATION_REMOVE "remove"
#define PATCH_OPERATION_REPLACE "replace"
namespace oai {
namespace ausf_server {
namespace model {
/// <summary>
///
/// </summary>
class PatchOperation {
public:
PatchOperation();
virtual ~PatchOperation();
void validate();
/////////////////////////////////////////////
/// PatchOperation members
friend void to_json(nlohmann::json &j, const PatchOperation &o);
friend void from_json(const nlohmann::json &j, PatchOperation &o);
protected:
};
} // namespace model
} // namespace ausf_server
} // namespace oai
#endif /* PatchOperation_H_ */
...@@ -31,6 +31,8 @@ add_library (AUSF STATIC ...@@ -31,6 +31,8 @@ add_library (AUSF STATIC
ausf_app.cpp ausf_app.cpp
ausf_client.cpp ausf_client.cpp
ausf_config.cpp ausf_config.cpp
task_manager.cpp
ausf_event.cpp
ausf_profile.cpp ausf_profile.cpp
ausf_nrf.cpp ausf_nrf.cpp
) )
...@@ -30,50 +30,49 @@ ...@@ -30,50 +30,49 @@
#include "ausf_app.hpp" #include "ausf_app.hpp"
#include "ausf_nrf.hpp" #include "ausf_nrf.hpp"
#include <unistd.h>
#include "logger.hpp"
#include "ausf_client.hpp"
#include "ProblemDetails.h" #include "ProblemDetails.h"
#include "ausf_client.hpp"
#include "logger.hpp"
#include <unistd.h>
#include "conversions.hpp"
#include "sha256.hpp"
#include "UEAuthenticationCtx.h"
#include "ConfirmationDataResponse.h"
#include "AuthenticationInfo.h" #include "AuthenticationInfo.h"
#include "ConfirmationDataResponse.h"
#include "UEAuthenticationCtx.h"
#include "authentication_algorithms_with_5gaka.hpp" #include "authentication_algorithms_with_5gaka.hpp"
#include <string> #include "conversions.hpp"
#include "iostream" #include "iostream"
#include "sha256.hpp"
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <string>
using namespace std; using namespace std;
using namespace oai::ausf::app; using namespace oai::ausf::app;
extern ausf_app* ausf_app_inst; extern ausf_app *ausf_app_inst;
ausf_client* ausf_client_inst = nullptr; ausf_client *ausf_client_inst = nullptr;
using namespace config; using namespace config;
extern ausf_config ausf_cfg; extern ausf_config ausf_cfg;
ausf_nrf* ausf_nrf_inst = nullptr; ausf_nrf *ausf_nrf_inst = nullptr;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
ausf_app::ausf_app(const std::string& config_file) ausf_app::ausf_app(const std::string &config_file, ausf_event &ev)
: contextId2security_context(), : event_sub(ev), contextId2security_context(), supi2security_context(),
supi2security_context(),
imsi2security_context() { imsi2security_context() {
Logger::ausf_app().startup("Starting..."); Logger::ausf_app().startup("Starting...");
try { try {
ausf_client_inst = new ausf_client(); ausf_client_inst = new ausf_client();
} catch (std::exception& e) { } catch (std::exception &e) {
Logger::ausf_app().error("Cannot create AUSF APP: %s", e.what()); Logger::ausf_app().error("Cannot create AUSF APP: %s", e.what());
throw; throw;
} }
// Register to NRF // Register to NRF
if (ausf_cfg.register_nrf) { if (ausf_cfg.register_nrf) {
try { try {
ausf_nrf_inst = new ausf_nrf(); ausf_nrf_inst = new ausf_nrf(ev);
ausf_nrf_inst->register_to_nrf(); ausf_nrf_inst->register_to_nrf();
Logger::ausf_app().info("NRF TASK Created "); Logger::ausf_app().info("NRF TASK Created ");
} catch (std::exception& e) { } catch (std::exception &e) {
Logger::ausf_app().error("Cannot create NRF TASK: %s", e.what()); Logger::ausf_app().error("Cannot create NRF TASK: %s", e.what());
throw; throw;
} }
...@@ -87,50 +86,50 @@ ausf_app::~ausf_app() { ...@@ -87,50 +86,50 @@ ausf_app::~ausf_app() {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool ausf_app::is_supi_2_security_context(const std::string& supi) const { bool ausf_app::is_supi_2_security_context(const std::string &supi) const {
std::shared_lock lock(m_supi2security_context); std::shared_lock lock(m_supi2security_context);
return bool{supi2security_context.count(supi) > 0}; return bool{supi2security_context.count(supi) > 0};
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::shared_ptr<security_context> ausf_app::supi_2_security_context( std::shared_ptr<security_context>
const std::string& supi) const { ausf_app::supi_2_security_context(const std::string &supi) const {
std::shared_lock lock(m_supi2security_context); std::shared_lock lock(m_supi2security_context);
return supi2security_context.at(supi); return supi2security_context.at(supi);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_app::set_supi_2_security_context( void ausf_app::set_supi_2_security_context(
const std::string& supi, std::shared_ptr<security_context> sc) { const std::string &supi, std::shared_ptr<security_context> sc) {
std::unique_lock lock(m_supi2security_context); std::unique_lock lock(m_supi2security_context);
supi2security_context[supi] = sc; supi2security_context[supi] = sc;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool ausf_app::is_contextId_2_security_context( bool ausf_app::is_contextId_2_security_context(
const std::string& contextId) const { const std::string &contextId) const {
std::shared_lock lock(m_contextId2security_context); std::shared_lock lock(m_contextId2security_context);
return bool{contextId2security_context.count(contextId) > 0}; return bool{contextId2security_context.count(contextId) > 0};
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::shared_ptr<security_context> ausf_app::contextId_2_security_context( std::shared_ptr<security_context>
const std::string& contextId) const { ausf_app::contextId_2_security_context(const std::string &contextId) const {
std::shared_lock lock(m_contextId2security_context); std::shared_lock lock(m_contextId2security_context);
return contextId2security_context.at(contextId); return contextId2security_context.at(contextId);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_app::set_contextId_2_security_context( void ausf_app::set_contextId_2_security_context(
const std::string& contextId, std::shared_ptr<security_context> sc) { const std::string &contextId, std::shared_ptr<security_context> sc) {
std::unique_lock lock(m_contextId2security_context); std::unique_lock lock(m_contextId2security_context);
contextId2security_context[contextId] = sc; contextId2security_context[contextId] = sc;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_app::handle_ue_authentications( void ausf_app::handle_ue_authentications(
const AuthenticationInfo& authenticationInfo, nlohmann::json& json_data, const AuthenticationInfo &authenticationInfo, nlohmann::json &json_data,
std::string& location, Pistache::Http::Code& code, uint8_t http_version) { std::string &location, Pistache::Http::Code &code, uint8_t http_version) {
Logger::ausf_app().info("Handle UE Authentication Request"); Logger::ausf_app().info("Handle UE Authentication Request");
std::string snn = std::string snn =
authenticationInfo.getServingNetworkName(); // serving network name authenticationInfo.getServingNetworkName(); // serving network name
...@@ -147,7 +146,7 @@ void ausf_app::handle_ue_authentications( ...@@ -147,7 +146,7 @@ void ausf_app::handle_ue_authentications(
std::string response = {}; std::string response = {};
udm_uri = "http://" + udm_uri = "http://" +
std::string( std::string(
inet_ntoa(*((struct in_addr*) &ausf_cfg.udm_addr.ipv4_addr))) + inet_ntoa(*((struct in_addr *)&ausf_cfg.udm_addr.ipv4_addr))) +
":" + std::to_string(ausf_cfg.udm_addr.port) + "/nudm-ueau/" + ":" + std::to_string(ausf_cfg.udm_addr.port) + "/nudm-ueau/" +
ausf_cfg.udm_addr.api_version + "/" + supi + ausf_cfg.udm_addr.api_version + "/" + supi +
"/security-information/generate-auth-data"; "/security-information/generate-auth-data";
...@@ -177,8 +176,8 @@ void ausf_app::handle_ue_authentications( ...@@ -177,8 +176,8 @@ void ausf_app::handle_ue_authentications(
} }
// Send request to UDM // Send request to UDM
ausf_client_inst->curl_http_client( ausf_client_inst->curl_http_client(udm_uri, method, AuthInfo.dump(),
udm_uri, method, AuthInfo.dump(), response); response);
Logger::ausf_app().info("Response from UDM: %s", response.c_str()); Logger::ausf_app().info("Response from UDM: %s", response.c_str());
...@@ -209,7 +208,7 @@ void ausf_app::handle_ue_authentications( ...@@ -209,7 +208,7 @@ void ausf_app::handle_ue_authentications(
response_data["authenticationVector"].at("xresStar"); // xres* response_data["authenticationVector"].at("xresStar"); // xres*
Logger::ausf_app().debug("xres*_udm %s", xresStar_udm.c_str()); Logger::ausf_app().debug("xres*_udm %s", xresStar_udm.c_str());
} catch (nlohmann::json::exception& e) { } catch (nlohmann::json::exception &e) {
// TODO: Catch parse_error exception // TODO: Catch parse_error exception
// TODO: Catch out_of_range exception // TODO: Catch out_of_range exception
Logger::ausf_app().info("Could not Parse JSON content from UDM response"); Logger::ausf_app().info("Could not Parse JSON content from UDM response");
...@@ -217,12 +216,12 @@ void ausf_app::handle_ue_authentications( ...@@ -217,12 +216,12 @@ void ausf_app::handle_ue_authentications(
// TODO: error handling // TODO: error handling
problemDetails.setCause("CONTEXT_NOT_FOUND"); problemDetails.setCause("CONTEXT_NOT_FOUND");
problemDetails.setStatus(404); problemDetails.setStatus(404);
problemDetails.setDetail( problemDetails.setDetail("Resource corresponding to User " + supi +
"Resource corresponding to User " + supi + " not found"); " not found");
to_json(problemDetails_json, problemDetails); to_json(problemDetails_json, problemDetails);
Logger::ausf_app().error( Logger::ausf_app().error("Resource corresponding to User %s not found",
"Resource corresponding to User %s not found", supi.c_str()); supi.c_str());
Logger::ausf_app().info("Send 404 Not_Found response"); Logger::ausf_app().info("Send 404 Not_Found response");
code = Pistache::Http::Code::Not_Found; code = Pistache::Http::Code::Not_Found;
json_data = problemDetails_json; json_data = problemDetails_json;
...@@ -256,52 +255,48 @@ void ausf_app::handle_ue_authentications( ...@@ -256,52 +255,48 @@ void ausf_app::handle_ue_authentications(
uint8_t hxresStar[16] = {0}; uint8_t hxresStar[16] = {0};
// Getting params from UDM 5G HE AV // Getting params from UDM 5G HE AV
std::copy( std::copy(std::begin(xresStar), std::end(xresStar),
std::begin(xresStar), std::end(xresStar), std::begin(xresStar_ausf)); std::begin(xresStar_ausf));
std::copy(std::begin(rand), std::end(rand), std::begin(rand_ausf)); std::copy(std::begin(rand), std::end(rand), std::begin(rand_ausf));
std::copy(std::begin(autn), std::end(autn), std::begin(autn_ausf)); std::copy(std::begin(autn), std::end(autn), std::begin(autn_ausf));
std::copy(std::begin(kausf), std::end(kausf), std::begin(kausf_ausf)); std::copy(std::begin(kausf), std::end(kausf), std::begin(kausf_ausf));
// Generate_Hxres* // Generate_Hxres*
Authentication_5gaka::generate_Hxres(rand_ausf, xresStar_ausf, hxresStar); Authentication_5gaka::generate_Hxres(rand_ausf, xresStar_ausf, hxresStar);
Logger::ausf_app().debug( Logger::ausf_app().debug("HXresStar calculated:\n %s",
"HXresStar calculated:\n %s",
(conv::uint8_to_hex_string(hxresStar, 16)).c_str()); (conv::uint8_to_hex_string(hxresStar, 16)).c_str());
uint8_t kseaf[32] = {0}; uint8_t kseaf[32] = {0};
Authentication_5gaka::derive_kseaf(snn, kausf, kseaf); Authentication_5gaka::derive_kseaf(snn, kausf, kseaf);
Logger::ausf_app().debug( Logger::ausf_app().debug("Kseaf calculated:\n %s",
"Kseaf calculated:\n %s", (conv::uint8_to_hex_string(kseaf, 32)).c_str()); (conv::uint8_to_hex_string(kseaf, 32)).c_str());
// Store the security context // Store the security context
std::shared_ptr<security_context> sc = {}; std::shared_ptr<security_context> sc = {};
if (is_supi_2_security_context(supi)) { if (is_supi_2_security_context(supi)) {
Logger::ausf_app().debug( Logger::ausf_app().debug("Update security context with SUPI: ",
"Update security context with SUPI: ", supi.c_str()); supi.c_str());
sc = supi_2_security_context(supi); sc = supi_2_security_context(supi);
} else { } else {
Logger::ausf_app().debug( Logger::ausf_app().debug("Create a new security context with SUPI ",
"Create a new security context with SUPI ", supi.c_str()); supi.c_str());
sc = std::make_shared<security_context>(); sc = std::make_shared<security_context>();
set_supi_2_security_context(supi, sc); set_supi_2_security_context(supi, sc);
} }
// Update information // Update information
sc->supi_ausf = supi; // TODO: setter/getter sc->supi_ausf = supi; // TODO: setter/getter
std::copy( std::copy(std::begin(rand_ausf), std::end(rand_ausf),
std::begin(rand_ausf), std::end(rand_ausf),
std::begin(sc->ausf_av_s.rand)); std::begin(sc->ausf_av_s.rand));
std::copy( std::copy(std::begin(autn_ausf), std::end(autn_ausf),
std::begin(autn_ausf), std::end(autn_ausf),
std::begin(sc->ausf_av_s.autn)); std::begin(sc->ausf_av_s.autn));
std::copy( std::copy(std::begin(hxresStar), std::end(hxresStar),
std::begin(hxresStar), std::end(hxresStar),
std::begin(sc->ausf_av_s.hxresStar)); std::begin(sc->ausf_av_s.hxresStar));
std::copy( std::copy(std::begin(kseaf), std::end(kseaf),
std::begin(kseaf), std::end(kseaf), std::begin(sc->ausf_av_s.kseaf)); std::begin(sc->ausf_av_s.kseaf));
// store xres* in ausf // store xres* in ausf
std::copy( std::copy(std::begin(xresStar), std::end(xresStar),
std::begin(xresStar), std::end(xresStar), std::begin(sc->xres_star)); std::begin(sc->xres_star));
sc->supi_ausf = authenticationInfo.getSupiOrSuci(); // store supi in ausf sc->supi_ausf = authenticationInfo.getSupiOrSuci(); // store supi in ausf
sc->serving_nn = snn; // store snn in ausf sc->serving_nn = snn; // store snn in ausf
...@@ -326,11 +321,12 @@ void ausf_app::handle_ue_authentications( ...@@ -326,11 +321,12 @@ void ausf_app::handle_ue_authentications(
set_contextId_2_security_context(authCtxId_s, sc); set_contextId_2_security_context(authCtxId_s, sc);
std::string ausf_port = std::to_string(ausf_cfg.sbi.port); std::string ausf_port = std::to_string(ausf_cfg.sbi.port);
if (http_version == 2) ausf_port = std::to_string(ausf_cfg.sbi_http2_port); if (http_version == 2)
ausf_port = std::to_string(ausf_cfg.sbi_http2_port);
resourceURI = resourceURI =
"http://" + "http://" +
std::string(inet_ntoa(*((struct in_addr*) &ausf_cfg.sbi.addr4))) + ":" + std::string(inet_ntoa(*((struct in_addr *)&ausf_cfg.sbi.addr4))) + ":" +
ausf_port + "/nausf-auth/v1/ue-authentications/" + authCtxId_s + ausf_port + "/nausf-auth/v1/ue-authentications/" + authCtxId_s +
"/5g-aka-confirmation"; "/5g-aka-confirmation";
ausf_Href.setHref(resourceURI); ausf_Href.setHref(resourceURI);
...@@ -353,8 +349,8 @@ void ausf_app::handle_ue_authentications( ...@@ -353,8 +349,8 @@ void ausf_app::handle_ue_authentications(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_app::handle_ue_authentications_confirmation( void ausf_app::handle_ue_authentications_confirmation(
const std::string& authCtxId, const ConfirmationData& confirmationData, const std::string &authCtxId, const ConfirmationData &confirmationData,
nlohmann::json& json_data, Pistache::Http::Code& code) { nlohmann::json &json_data, Pistache::Http::Code &code) {
// SEAF-> AUSF // SEAF-> AUSF
ProblemDetails problemDetails; ProblemDetails problemDetails;
nlohmann::json problemDetails_json = {}; nlohmann::json problemDetails_json = {};
...@@ -363,13 +359,12 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -363,13 +359,12 @@ void ausf_app::handle_ue_authentications_confirmation(
// Get the security context // Get the security context
std::shared_ptr<security_context> sc = {}; std::shared_ptr<security_context> sc = {};
if (is_contextId_2_security_context(authCtxId)) { if (is_contextId_2_security_context(authCtxId)) {
Logger::ausf_app().debug( Logger::ausf_app().debug("Retrieve security context with authCtxId: ",
"Retrieve security context with authCtxId: ", authCtxId.c_str()); authCtxId.c_str());
sc = contextId_2_security_context(authCtxId); sc = contextId_2_security_context(authCtxId);
} else { // No ue-authentications request before } else { // No ue-authentications request before
Logger::ausf_app().debug( Logger::ausf_app().debug("Security context with authCtxId ",
"Security context with authCtxId ", authCtxId.c_str(), authCtxId.c_str(), "does not exist");
"does not exist");
problemDetails.setCause("SERVING_NETWORK_NOT_AUTHORIZED"); problemDetails.setCause("SERVING_NETWORK_NOT_AUTHORIZED");
problemDetails.setStatus(403); problemDetails.setStatus(403);
...@@ -383,18 +378,18 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -383,18 +378,18 @@ void ausf_app::handle_ue_authentications_confirmation(
return; return;
} }
Logger::ausf_app().info( Logger::ausf_app().info("Received authCtxId %s",
"Received authCtxId %s", authCtxId.c_str()); // authCtxId authCtxId.c_str()); // authCtxId
Logger::ausf_app().info( Logger::ausf_app().info("Received res* %s",
"Received res* %s", confirmationData.getResStar().c_str()); confirmationData.getResStar().c_str());
uint8_t resStar[16] = {0}; uint8_t resStar[16] = {0};
conv::hex_str_to_uint8(confirmationData.getResStar().c_str(), resStar); conv::hex_str_to_uint8(confirmationData.getResStar().c_str(), resStar);
ConfirmationDataResponse confirmResponse; ConfirmationDataResponse confirmResponse;
uint8_t authCtxId_seaf[16]; uint8_t authCtxId_seaf[16];
conv::hex_str_to_uint8( conv::hex_str_to_uint8(authCtxId.c_str(),
authCtxId.c_str(), authCtxId_seaf); // authCtxId in SEAF authCtxId_seaf); // authCtxId in SEAF
Logger::ausf_app().debug( Logger::ausf_app().debug(
"authCtxId in AUSF: %s", "authCtxId in AUSF: %s",
...@@ -415,14 +410,13 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -415,14 +410,13 @@ void ausf_app::handle_ue_authentications_confirmation(
// Get stored xres* and compare with res* // Get stored xres* and compare with res*
uint8_t xresStar[16] = {0}; uint8_t xresStar[16] = {0};
// xres* stored for 5g-aka-confirmation // xres* stored for 5g-aka-confirmation
std::copy( std::copy(std::begin(sc->xres_star), std::end(sc->xres_star),
std::begin(sc->xres_star), std::end(sc->xres_star),
std::begin(xresStar)); std::begin(xresStar));
Logger::ausf_app().debug( Logger::ausf_app().debug("xres* in AUSF: %s",
"xres* in AUSF: %s", (conv::uint8_to_hex_string(xresStar, 16)).c_str()); (conv::uint8_to_hex_string(xresStar, 16)).c_str());
Logger::ausf_app().debug( Logger::ausf_app().debug("xres in AMF: %s",
"xres in AMF: %s", (conv::uint8_to_hex_string(resStar, 16)).c_str()); (conv::uint8_to_hex_string(resStar, 16)).c_str());
bool authResult = Authentication_5gaka::equal_uint8(xresStar, resStar, 16); bool authResult = Authentication_5gaka::equal_uint8(xresStar, resStar, 16);
confirmResponse.setAuthResult(authResult); confirmResponse.setAuthResult(authResult);
...@@ -451,7 +445,7 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -451,7 +445,7 @@ void ausf_app::handle_ue_authentications_confirmation(
udm_uri = udm_uri =
"http://" + "http://" +
std::string( std::string(
inet_ntoa(*((struct in_addr*) &ausf_cfg.udm_addr.ipv4_addr))) + inet_ntoa(*((struct in_addr *)&ausf_cfg.udm_addr.ipv4_addr))) +
":" + std::to_string(ausf_cfg.udm_addr.port) + "/nudm-ueau/" + ":" + std::to_string(ausf_cfg.udm_addr.port) + "/nudm-ueau/" +
ausf_cfg.udm_addr.api_version + "/" + sc->supi_ausf + "/auth-events"; ausf_cfg.udm_addr.api_version + "/" + sc->supi_ausf + "/auth-events";
...@@ -476,10 +470,10 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -476,10 +470,10 @@ void ausf_app::handle_ue_authentications_confirmation(
confirmResultInfo["servingNetworkName"] = sc->serving_nn; confirmResultInfo["servingNetworkName"] = sc->serving_nn;
confirmResultInfo["authRemovalInd"] = false; confirmResultInfo["authRemovalInd"] = false;
Logger::ausf_app().debug( Logger::ausf_app().debug("confirmResultInfo: %s",
"confirmResultInfo: %s", confirmResultInfo.dump().c_str()); confirmResultInfo.dump().c_str());
ausf_client_inst->curl_http_client( ausf_client_inst->curl_http_client(udm_uri, method,
udm_uri, method, confirmResultInfo.dump(), response); confirmResultInfo.dump(), response);
} }
} }
......
...@@ -29,15 +29,16 @@ ...@@ -29,15 +29,16 @@
#ifndef FILE_AUSF_APP_HPP_SEEN #ifndef FILE_AUSF_APP_HPP_SEEN
#define FILE_AUSF_APP_HPP_SEEN #define FILE_AUSF_APP_HPP_SEEN
#include "ausf_event.hpp"
#include <string>
#include "AuthenticationInfo.h" #include "AuthenticationInfo.h"
#include "UEAuthenticationCtx.h"
#include "ConfirmationData.h" #include "ConfirmationData.h"
#include "UEAuthenticationCtx.h"
#include "ausf.h" #include "ausf.h"
#include <pistache/http.h>
#include <map> #include <map>
#include <pistache/http.h>
#include <shared_mutex> #include <shared_mutex>
#include <string>
namespace oai { namespace oai {
namespace ausf { namespace ausf {
...@@ -46,7 +47,7 @@ namespace app { ...@@ -46,7 +47,7 @@ namespace app {
using namespace oai::ausf_server::model; using namespace oai::ausf_server::model;
class security_context { class security_context {
public: public:
security_context() : xres_star() { security_context() : xres_star() {
// supi = {}; // supi = {};
ausf_av_s = {}; ausf_av_s = {};
...@@ -67,35 +68,37 @@ class security_context { ...@@ -67,35 +68,37 @@ class security_context {
// class ausf_config; // class ausf_config;
class ausf_app { class ausf_app {
public: public:
explicit ausf_app(const std::string& config_file); explicit ausf_app(const std::string &config_file, ausf_event &ev);
ausf_app(ausf_app const&) = delete; ausf_app(ausf_app const &) = delete;
void operator=(ausf_app const&) = delete; void operator=(ausf_app const &) = delete;
virtual ~ausf_app(); virtual ~ausf_app();
void handle_ue_authentications( void handle_ue_authentications(const AuthenticationInfo &authenticationInfo,
const AuthenticationInfo& authenticationInfo, nlohmann::json& json_data, nlohmann::json &json_data,
std::string& location, Pistache::Http::Code& code, std::string &location,
Pistache::Http::Code &code,
uint8_t http_version = 1); uint8_t http_version = 1);
void handle_ue_authentications_confirmation( void handle_ue_authentications_confirmation(
const std::string& authCtxId, const ConfirmationData& confirmation_data, const std::string &authCtxId, const ConfirmationData &confirmation_data,
nlohmann::json& json_data, Pistache::Http::Code& code); nlohmann::json &json_data, Pistache::Http::Code &code);
bool is_supi_2_security_context(const std::string& supi) const; bool is_supi_2_security_context(const std::string &supi) const;
std::shared_ptr<security_context> supi_2_security_context( std::shared_ptr<security_context>
const std::string& supi) const; supi_2_security_context(const std::string &supi) const;
void set_supi_2_security_context( void set_supi_2_security_context(const std::string &supi,
const std::string& supi, std::shared_ptr<security_context> sc); std::shared_ptr<security_context> sc);
bool is_contextId_2_security_context(const std::string& contextId) const; bool is_contextId_2_security_context(const std::string &contextId) const;
std::shared_ptr<security_context> contextId_2_security_context( std::shared_ptr<security_context>
const std::string& contextId) const; contextId_2_security_context(const std::string &contextId) const;
void set_contextId_2_security_context( void set_contextId_2_security_context(const std::string &contextId,
const std::string& contextId, std::shared_ptr<security_context> sc); std::shared_ptr<security_context> sc);
private: private:
ausf_event &event_sub;
std::map<supi64_t, std::shared_ptr<security_context>> imsi2security_context; std::map<supi64_t, std::shared_ptr<security_context>> imsi2security_context;
mutable std::shared_mutex m_imsi2security_context; mutable std::shared_mutex m_imsi2security_context;
......
...@@ -30,13 +30,13 @@ ...@@ -30,13 +30,13 @@
#include "ausf_client.hpp" #include "ausf_client.hpp"
#include <curl/curl.h> #include <curl/curl.h>
#include <nlohmann/json.hpp>
#include <pistache/http.h> #include <pistache/http.h>
#include <pistache/mime.h> #include <pistache/mime.h>
#include <nlohmann/json.hpp>
#include <stdexcept> #include <stdexcept>
#include "logger.hpp"
#include "ausf.h" #include "ausf.h"
#include "logger.hpp"
using namespace Pistache::Http; using namespace Pistache::Http;
using namespace Pistache::Http::Mime; using namespace Pistache::Http::Mime;
...@@ -44,13 +44,13 @@ using namespace oai::ausf::app; ...@@ -44,13 +44,13 @@ using namespace oai::ausf::app;
using namespace config; using namespace config;
using json = nlohmann::json; using json = nlohmann::json;
extern ausf_client* ausf_client_inst; extern ausf_client *ausf_client_inst;
extern ausf_config ausf_cfg; extern ausf_config ausf_cfg;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// To read content of the response from NF // To read content of the response from NF
static std::size_t callback( static std::size_t callback(const char *in, std::size_t size, std::size_t num,
const char* in, std::size_t size, std::size_t num, std::string* out) { std::string *out) {
const std::size_t totalBytes(size * num); const std::size_t totalBytes(size * num);
out->append(in, totalBytes); out->append(in, totalBytes);
return totalBytes; return totalBytes;
...@@ -65,25 +65,25 @@ ausf_client::~ausf_client() { ...@@ -65,25 +65,25 @@ ausf_client::~ausf_client() {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_client::curl_http_client( void ausf_client::curl_http_client(std::string remoteUri, std::string method,
std::string remoteUri, std::string method, std::string msgBody, std::string msgBody, std::string &response) {
std::string& response) {
Logger::ausf_app().info("Send HTTP message with body %s", msgBody.c_str()); Logger::ausf_app().info("Send HTTP message with body %s", msgBody.c_str());
uint32_t str_len = msgBody.length(); uint32_t str_len = msgBody.length();
char* body_data = (char*) malloc(str_len + 1); char *body_data = (char *)malloc(str_len + 1);
memset(body_data, 0, str_len + 1); memset(body_data, 0, str_len + 1);
memcpy((void*) body_data, (void*) msgBody.c_str(), str_len); memcpy((void *)body_data, (void *)msgBody.c_str(), str_len);
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
CURL* curl = curl_easy_init(); CURL *curl = curl_easy_init();
uint8_t http_version = 1; uint8_t http_version = 1;
if (ausf_cfg.use_http2) http_version = 2; if (ausf_cfg.use_http2)
http_version = 2;
if (curl) { if (curl) {
CURLcode res = {}; CURLcode res = {};
struct curl_slist* headers = nullptr; struct curl_slist *headers = nullptr;
if ((method.compare("POST") == 0) or (method.compare("PUT") == 0) or if ((method.compare("POST") == 0) or (method.compare("PUT") == 0) or
(method.compare("PATCH") == 0)) { (method.compare("PATCH") == 0)) {
std::string content_type = "Content-Type: application/json"; std::string content_type = "Content-Type: application/json";
...@@ -112,8 +112,8 @@ void ausf_client::curl_http_client( ...@@ -112,8 +112,8 @@ void ausf_client::curl_http_client(
// we use a self-signed test server, skip verification during debugging // we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt( curl_easy_setopt(curl, CURLOPT_HTTP_VERSION,
curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE); CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
} }
// Response information. // Response information.
...@@ -140,8 +140,8 @@ void ausf_client::curl_http_client( ...@@ -140,8 +140,8 @@ void ausf_client::curl_http_client(
Logger::ausf_app().info("Get response with HTTP code (%d)", httpCode); Logger::ausf_app().info("Get response with HTTP code (%d)", httpCode);
if (httpCode == 0) { if (httpCode == 0) {
Logger::ausf_app().info( Logger::ausf_app().info("Cannot get response when calling %s",
"Cannot get response when calling %s", remoteUri.c_str()); remoteUri.c_str());
// free curl before returning // free curl before returning
curl_slist_free_all(headers); curl_slist_free_all(headers);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
...@@ -166,14 +166,14 @@ void ausf_client::curl_http_client( ...@@ -166,14 +166,14 @@ void ausf_client::curl_http_client(
if (!is_response_ok) { if (!is_response_ok) {
try { try {
response_data = nlohmann::json::parse(response); response_data = nlohmann::json::parse(response);
} catch (nlohmann::json::exception& e) { } catch (nlohmann::json::exception &e) {
Logger::ausf_app().info("Could not get JSON content from the response"); Logger::ausf_app().info("Could not get JSON content from the response");
// Set the default Cause // Set the default Cause
response_data["error"]["cause"] = "504 Gateway Timeout"; response_data["error"]["cause"] = "504 Gateway Timeout";
} }
Logger::ausf_app().info( Logger::ausf_app().info("Get response with jsonData: %s",
"Get response with jsonData: %s", response.c_str()); response.c_str());
std::string cause = response_data["error"]["cause"]; std::string cause = response_data["error"]["cause"];
Logger::ausf_app().info("Call Network Function services failure"); Logger::ausf_app().info("Call Network Function services failure");
......
...@@ -34,24 +34,23 @@ ...@@ -34,24 +34,23 @@
#include <curl/curl.h> #include <curl/curl.h>
#include "logger.hpp"
#include "ausf_config.hpp" #include "ausf_config.hpp"
#include "logger.hpp"
namespace oai { namespace oai {
namespace ausf { namespace ausf {
namespace app { namespace app {
class ausf_client { class ausf_client {
private: private:
public: public:
ausf_client(); ausf_client();
virtual ~ausf_client(); virtual ~ausf_client();
ausf_client(ausf_client const&) = delete; ausf_client(ausf_client const &) = delete;
void curl_http_client( void curl_http_client(std::string remoteUri, std::string method,
std::string remoteUri, std::string method, std::string msgBody, std::string msgBody, std::string &response);
std::string& response);
}; };
} // namespace app } // namespace app
} // namespace ausf } // namespace ausf
......
...@@ -28,13 +28,13 @@ ...@@ -28,13 +28,13 @@
#include "ausf_config.hpp" #include "ausf_config.hpp"
#include "string.hpp"
#include <iostream> #include <iostream>
#include <libconfig.h++> #include <libconfig.h++>
#include "string.hpp"
#include "logger.hpp"
#include "if.hpp"
#include "fqdn.hpp" #include "fqdn.hpp"
#include "if.hpp"
#include "logger.hpp"
#include "string.hpp" #include "string.hpp"
...@@ -69,82 +69,80 @@ ausf_config::ausf_config() : sbi(), ausf_name(), pid_dir(), instance() { ...@@ -69,82 +69,80 @@ ausf_config::ausf_config() : sbi(), ausf_name(), pid_dir(), instance() {
ausf_config::~ausf_config() {} ausf_config::~ausf_config() {}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int ausf_config::load(const std::string& config_file) { int ausf_config::load(const std::string &config_file) {
Logger::config().debug( Logger::config().debug("\nLoad AUSF system configuration file(%s)",
"\nLoad AUSF system configuration file(%s)", config_file.c_str()); config_file.c_str());
Config cfg; Config cfg;
unsigned char buf_in6_addr[sizeof(struct in6_addr)]; unsigned char buf_in6_addr[sizeof(struct in6_addr)];
try { try {
cfg.readFile(config_file.c_str()); cfg.readFile(config_file.c_str());
} catch (const FileIOException& fioex) { } catch (const FileIOException &fioex) {
Logger::config().error( Logger::config().error("I/O error while reading file %s - %s",
"I/O error while reading file %s - %s", config_file.c_str(), config_file.c_str(), fioex.what());
fioex.what());
throw; throw;
} catch (const ParseException& pex) { } catch (const ParseException &pex) {
Logger::config().error( Logger::config().error("Parse error at %s:%d - %s", pex.getFile(),
"Parse error at %s:%d - %s", pex.getFile(), pex.getLine(), pex.getLine(), pex.getError());
pex.getError());
throw; throw;
} }
const Setting& root = cfg.getRoot(); const Setting &root = cfg.getRoot();
try { try {
const Setting& ausf_cfg = root[AUSF_CONFIG_STRING_AUSF_CONFIG]; const Setting &ausf_cfg = root[AUSF_CONFIG_STRING_AUSF_CONFIG];
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException &nfex) {
Logger::config().error("%s : %s", nfex.what(), nfex.getPath()); Logger::config().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror; return RETURNerror;
} }
const Setting& ausf_cfg = root[AUSF_CONFIG_STRING_AUSF_CONFIG]; const Setting &ausf_cfg = root[AUSF_CONFIG_STRING_AUSF_CONFIG];
try { try {
ausf_cfg.lookupValue(AUSF_CONFIG_STRING_INSTANCE_ID, instance); ausf_cfg.lookupValue(AUSF_CONFIG_STRING_INSTANCE_ID, instance);
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException &nfex) {
Logger::config().error( Logger::config().error("%s : %s, using defaults", nfex.what(),
"%s : %s, using defaults", nfex.what(), nfex.getPath()); nfex.getPath());
} }
try { try {
ausf_cfg.lookupValue(AUSF_CONFIG_STRING_PID_DIRECTORY, pid_dir); ausf_cfg.lookupValue(AUSF_CONFIG_STRING_PID_DIRECTORY, pid_dir);
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException &nfex) {
Logger::config().error( Logger::config().error("%s : %s, using defaults", nfex.what(),
"%s : %s, using defaults", nfex.what(), nfex.getPath()); nfex.getPath());
} }
try { try {
ausf_cfg.lookupValue(AUSF_CONFIG_STRING_AUSF_NAME, ausf_name); ausf_cfg.lookupValue(AUSF_CONFIG_STRING_AUSF_NAME, ausf_name);
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException &nfex) {
Logger::config().error( Logger::config().error("%s : %s, using defaults", nfex.what(),
"%s : %s, using defaults", nfex.what(), nfex.getPath()); nfex.getPath());
} }
// AUSF SBI interface // AUSF SBI interface
try { try {
const Setting& new_if_cfg = ausf_cfg[AUSF_CONFIG_STRING_INTERFACES]; const Setting &new_if_cfg = ausf_cfg[AUSF_CONFIG_STRING_INTERFACES];
const Setting& sbi_cfg = new_if_cfg[AUSF_CONFIG_STRING_INTERFACE_SBI]; const Setting &sbi_cfg = new_if_cfg[AUSF_CONFIG_STRING_INTERFACE_SBI];
load_interface(sbi_cfg, sbi); load_interface(sbi_cfg, sbi);
// HTTP2 port // HTTP2 port
if (!(sbi_cfg.lookupValue( if (!(sbi_cfg.lookupValue(AUSF_CONFIG_STRING_SBI_HTTP2_PORT,
AUSF_CONFIG_STRING_SBI_HTTP2_PORT, sbi_http2_port))) { sbi_http2_port))) {
Logger::ausf_app().error(AUSF_CONFIG_STRING_SBI_HTTP2_PORT "failed"); Logger::ausf_app().error(AUSF_CONFIG_STRING_SBI_HTTP2_PORT "failed");
throw(AUSF_CONFIG_STRING_SBI_HTTP2_PORT " failed"); throw(AUSF_CONFIG_STRING_SBI_HTTP2_PORT " failed");
} }
// API Version // API Version
if (!(sbi_cfg.lookupValue( if (!(sbi_cfg.lookupValue(AUSF_CONFIG_STRING_API_VERSION,
AUSF_CONFIG_STRING_API_VERSION, sbi_api_version))) { sbi_api_version))) {
Logger::ausf_app().error(AUSF_CONFIG_STRING_API_VERSION " failed"); Logger::ausf_app().error(AUSF_CONFIG_STRING_API_VERSION " failed");
throw(AUSF_CONFIG_STRING_API_VERSION " failed"); throw(AUSF_CONFIG_STRING_API_VERSION " failed");
} }
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException &nfex) {
Logger::config().error( Logger::config().error("%s : %s, using defaults", nfex.what(),
"%s : %s, using defaults", nfex.what(), nfex.getPath()); nfex.getPath());
return RETURNerror; return RETURNerror;
} }
// Support features // Support features
try { try {
const Setting& support_features = const Setting &support_features =
ausf_cfg[AUSF_CONFIG_STRING_SUPPORT_FEATURES]; ausf_cfg[AUSF_CONFIG_STRING_SUPPORT_FEATURES];
std::string opt = {}; std::string opt = {};
...@@ -156,8 +154,8 @@ int ausf_config::load(const std::string& config_file) { ...@@ -156,8 +154,8 @@ int ausf_config::load(const std::string& config_file) {
use_fqdn_dns = false; use_fqdn_dns = false;
} }
support_features.lookupValue( support_features.lookupValue(AUSF_CONFIG_STRING_SUPPORT_FEATURES_USE_HTTP2,
AUSF_CONFIG_STRING_SUPPORT_FEATURES_USE_HTTP2, opt); opt);
if (boost::iequals(opt, "yes")) { if (boost::iequals(opt, "yes")) {
use_http2 = true; use_http2 = true;
} else { } else {
...@@ -172,9 +170,9 @@ int ausf_config::load(const std::string& config_file) { ...@@ -172,9 +170,9 @@ int ausf_config::load(const std::string& config_file) {
register_nrf = false; register_nrf = false;
} }
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException &nfex) {
Logger::ausf_app().error( Logger::ausf_app().error("%s : %s, using defaults", nfex.what(),
"%s : %s, using defaults", nfex.what(), nfex.getPath()); nfex.getPath());
return RETURNerror; return RETURNerror;
} }
...@@ -182,15 +180,14 @@ int ausf_config::load(const std::string& config_file) { ...@@ -182,15 +180,14 @@ int ausf_config::load(const std::string& config_file) {
try { try {
std::string astring = {}; std::string astring = {};
const Setting& udm_cfg = ausf_cfg[AUSF_CONFIG_STRING_UDM]; const Setting &udm_cfg = ausf_cfg[AUSF_CONFIG_STRING_UDM];
struct in_addr udm_ipv4_addr = {}; struct in_addr udm_ipv4_addr = {};
unsigned int udm_port = 0; unsigned int udm_port = 0;
std::string udm_api_version = {}; std::string udm_api_version = {};
if (!use_fqdn_dns) { if (!use_fqdn_dns) {
udm_cfg.lookupValue(AUSF_CONFIG_STRING_UDM_IPV4_ADDRESS, astring); udm_cfg.lookupValue(AUSF_CONFIG_STRING_UDM_IPV4_ADDRESS, astring);
IPV4_STR_ADDR_TO_INADDR( IPV4_STR_ADDR_TO_INADDR(util::trim(astring).c_str(), udm_ipv4_addr,
util::trim(astring).c_str(), udm_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR UDM !"); "BAD IPv4 ADDRESS FORMAT FOR UDM !");
udm_addr.ipv4_addr = udm_ipv4_addr; udm_addr.ipv4_addr = udm_ipv4_addr;
if (!(udm_cfg.lookupValue(AUSF_CONFIG_STRING_UDM_PORT, udm_port))) { if (!(udm_cfg.lookupValue(AUSF_CONFIG_STRING_UDM_PORT, udm_port))) {
...@@ -199,8 +196,8 @@ int ausf_config::load(const std::string& config_file) { ...@@ -199,8 +196,8 @@ int ausf_config::load(const std::string& config_file) {
} }
udm_addr.port = udm_port; udm_addr.port = udm_port;
if (!(udm_cfg.lookupValue( if (!(udm_cfg.lookupValue(AUSF_CONFIG_STRING_API_VERSION,
AUSF_CONFIG_STRING_API_VERSION, udm_api_version))) { udm_api_version))) {
Logger::ausf_app().error(AUSF_CONFIG_STRING_API_VERSION "failed"); Logger::ausf_app().error(AUSF_CONFIG_STRING_API_VERSION "failed");
throw(AUSF_CONFIG_STRING_API_VERSION "failed"); throw(AUSF_CONFIG_STRING_API_VERSION "failed");
} }
...@@ -215,8 +212,7 @@ int ausf_config::load(const std::string& config_file) { ...@@ -215,8 +212,7 @@ int ausf_config::load(const std::string& config_file) {
// TODO: // TODO:
throw("DO NOT SUPPORT IPV6 ADDR FOR UDM!"); throw("DO NOT SUPPORT IPV6 ADDR FOR UDM!");
} else { // IPv4 } else { // IPv4
IPV4_STR_ADDR_TO_INADDR( IPV4_STR_ADDR_TO_INADDR(util::trim(address).c_str(), udm_ipv4_addr,
util::trim(address).c_str(), udm_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !"); "BAD IPv4 ADDRESS FORMAT FOR NRF !");
udm_addr.ipv4_addr = udm_ipv4_addr; udm_addr.ipv4_addr = udm_ipv4_addr;
// udm_addr.port = udm_port; // udm_addr.port = udm_port;
...@@ -227,8 +223,8 @@ int ausf_config::load(const std::string& config_file) { ...@@ -227,8 +223,8 @@ int ausf_config::load(const std::string& config_file) {
} }
udm_addr.port = udm_port; udm_addr.port = udm_port;
std::string udm_api_version = {}; std::string udm_api_version = {};
if (!(udm_cfg.lookupValue( if (!(udm_cfg.lookupValue(AUSF_CONFIG_STRING_API_VERSION,
AUSF_CONFIG_STRING_API_VERSION, udm_api_version))) { udm_api_version))) {
Logger::ausf_app().error(AUSF_CONFIG_STRING_API_VERSION "failed"); Logger::ausf_app().error(AUSF_CONFIG_STRING_API_VERSION "failed");
throw(AUSF_CONFIG_STRING_API_VERSION "failed"); throw(AUSF_CONFIG_STRING_API_VERSION "failed");
} }
...@@ -238,7 +234,7 @@ int ausf_config::load(const std::string& config_file) { ...@@ -238,7 +234,7 @@ int ausf_config::load(const std::string& config_file) {
} }
} }
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException &nfex) {
Logger::ausf_app().error("%s : %s", nfex.what(), nfex.getPath()); Logger::ausf_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror; return RETURNerror;
} }
...@@ -248,15 +244,14 @@ int ausf_config::load(const std::string& config_file) { ...@@ -248,15 +244,14 @@ int ausf_config::load(const std::string& config_file) {
try { try {
std::string astring = {}; std::string astring = {};
const Setting& nrf_cfg = ausf_cfg[AUSF_CONFIG_STRING_NRF]; const Setting &nrf_cfg = ausf_cfg[AUSF_CONFIG_STRING_NRF];
struct in_addr nrf_ipv4_addr = {}; struct in_addr nrf_ipv4_addr = {};
unsigned int nrf_port = 0; unsigned int nrf_port = 0;
std::string nrf_api_version = {}; std::string nrf_api_version = {};
if (!use_fqdn_dns) { if (!use_fqdn_dns) {
nrf_cfg.lookupValue(AUSF_CONFIG_STRING_NRF_IPV4_ADDRESS, astring); nrf_cfg.lookupValue(AUSF_CONFIG_STRING_NRF_IPV4_ADDRESS, astring);
IPV4_STR_ADDR_TO_INADDR( IPV4_STR_ADDR_TO_INADDR(util::trim(astring).c_str(), nrf_ipv4_addr,
util::trim(astring).c_str(), nrf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !"); "BAD IPv4 ADDRESS FORMAT FOR NRF !");
nrf_addr.ipv4_addr = nrf_ipv4_addr; nrf_addr.ipv4_addr = nrf_ipv4_addr;
if (!(nrf_cfg.lookupValue(AUSF_CONFIG_STRING_NRF_PORT, nrf_port))) { if (!(nrf_cfg.lookupValue(AUSF_CONFIG_STRING_NRF_PORT, nrf_port))) {
...@@ -265,8 +260,8 @@ int ausf_config::load(const std::string& config_file) { ...@@ -265,8 +260,8 @@ int ausf_config::load(const std::string& config_file) {
} }
nrf_addr.port = nrf_port; nrf_addr.port = nrf_port;
if (!(nrf_cfg.lookupValue( if (!(nrf_cfg.lookupValue(AUSF_CONFIG_STRING_API_VERSION,
AUSF_CONFIG_STRING_API_VERSION, nrf_api_version))) { nrf_api_version))) {
Logger::ausf_app().error(AUSF_CONFIG_STRING_API_VERSION "failed"); Logger::ausf_app().error(AUSF_CONFIG_STRING_API_VERSION "failed");
throw(AUSF_CONFIG_STRING_API_VERSION "failed"); throw(AUSF_CONFIG_STRING_API_VERSION "failed");
} }
...@@ -281,8 +276,7 @@ int ausf_config::load(const std::string& config_file) { ...@@ -281,8 +276,7 @@ int ausf_config::load(const std::string& config_file) {
// TODO: // TODO:
throw("DO NOT SUPPORT IPV6 ADDR FOR NRF!"); throw("DO NOT SUPPORT IPV6 ADDR FOR NRF!");
} else { // IPv4 } else { // IPv4
IPV4_STR_ADDR_TO_INADDR( IPV4_STR_ADDR_TO_INADDR(util::trim(address).c_str(), nrf_ipv4_addr,
util::trim(address).c_str(), nrf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !"); "BAD IPv4 ADDRESS FORMAT FOR NRF !");
nrf_addr.ipv4_addr = nrf_ipv4_addr; nrf_addr.ipv4_addr = nrf_ipv4_addr;
// nrf_addr.port = nrf_port; // nrf_addr.port = nrf_port;
...@@ -296,7 +290,7 @@ int ausf_config::load(const std::string& config_file) { ...@@ -296,7 +290,7 @@ int ausf_config::load(const std::string& config_file) {
nrf_addr.port = nrf_port; nrf_addr.port = nrf_port;
} }
} }
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException &nfex) {
Logger::ausf_app().error("%s : %s", nfex.what(), nfex.getPath()); Logger::ausf_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror; return RETURNerror;
} }
...@@ -306,8 +300,8 @@ int ausf_config::load(const std::string& config_file) { ...@@ -306,8 +300,8 @@ int ausf_config::load(const std::string& config_file) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_config::display() { void ausf_config::display() {
Logger::config().info( Logger::config().info("==== OAI-CN5G %s v%s ====", PACKAGE_NAME,
"==== OAI-CN5G %s v%s ====", PACKAGE_NAME, PACKAGE_VERSION); PACKAGE_VERSION);
Logger::config().info("================= AUSF ================="); Logger::config().info("================= AUSF =================");
Logger::config().info("Configuration AUSF:"); Logger::config().info("Configuration AUSF:");
Logger::config().info("- Instance ...............: %d", instance); Logger::config().info("- Instance ...............: %d", instance);
...@@ -319,40 +313,38 @@ void ausf_config::display() { ...@@ -319,40 +313,38 @@ void ausf_config::display() {
Logger::config().info(" IPv4 Addr ............: %s", inet_ntoa(sbi.addr4)); Logger::config().info(" IPv4 Addr ............: %s", inet_ntoa(sbi.addr4));
Logger::config().info(" HTTP1 Port ...........: %d", sbi.port); Logger::config().info(" HTTP1 Port ...........: %d", sbi.port);
Logger::config().info(" HTTP2 Port............: %d", sbi_http2_port); Logger::config().info(" HTTP2 Port............: %d", sbi_http2_port);
Logger::config().info( Logger::config().info(" API Version...........: %s",
" API Version...........: %s", sbi_api_version.c_str()); sbi_api_version.c_str());
Logger::config().info("- Supported Features:"); Logger::config().info("- Supported Features:");
Logger::config().info( Logger::config().info(" Register NRF ..........: %s",
" Register NRF ..........: %s", register_nrf ? "Yes" : "No"); register_nrf ? "Yes" : "No");
Logger::config().info( Logger::config().info(" Use FQDN ..............: %s",
" Use FQDN ..............: %s", use_fqdn_dns ? "Yes" : "No"); use_fqdn_dns ? "Yes" : "No");
Logger::config().info( Logger::config().info(" Use HTTP2..............: %s",
" Use HTTP2..............: %s", use_http2 ? "Yes" : "No"); use_http2 ? "Yes" : "No");
Logger::config().info("- UDM:"); Logger::config().info("- UDM:");
Logger::config().info( Logger::config().info(" IPv4 Addr ............: %s",
" IPv4 Addr ............: %s", inet_ntoa(*((struct in_addr *)&udm_addr.ipv4_addr)));
inet_ntoa(*((struct in_addr*) &udm_addr.ipv4_addr)));
Logger::config().info(" Port .................: %lu ", udm_addr.port); Logger::config().info(" Port .................: %lu ", udm_addr.port);
Logger::config().info( Logger::config().info(" API version ..........: %s",
" API version ..........: %s", udm_addr.api_version.c_str()); udm_addr.api_version.c_str());
Logger::config().info("- NRF:"); Logger::config().info("- NRF:");
Logger::config().info( Logger::config().info(" IPv4 Addr ............: %s",
" IPv4 Addr ............: %s", inet_ntoa(*((struct in_addr *)&nrf_addr.ipv4_addr)));
inet_ntoa(*((struct in_addr*) &nrf_addr.ipv4_addr)));
Logger::config().info(" Port .................: %lu ", nrf_addr.port); Logger::config().info(" Port .................: %lu ", nrf_addr.port);
Logger::config().info( Logger::config().info(" API version ..........: %s",
" API version ..........: %s", nrf_addr.api_version.c_str()); nrf_addr.api_version.c_str());
if (use_fqdn_dns) if (use_fqdn_dns)
Logger::config().info( Logger::config().info(" FQDN .................: %s",
" FQDN .................: %s", udm_addr.fqdn.c_str()); nrf_addr.fqdn.c_str());
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int ausf_config::load_interface( int ausf_config::load_interface(const libconfig::Setting &if_cfg,
const libconfig::Setting& if_cfg, interface_cfg_t& cfg) { interface_cfg_t &cfg) {
if_cfg.lookupValue(AUSF_CONFIG_STRING_INTERFACE_NAME, cfg.if_name); if_cfg.lookupValue(AUSF_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")) {
...@@ -360,19 +352,19 @@ int ausf_config::load_interface( ...@@ -360,19 +352,19 @@ int ausf_config::load_interface(
if_cfg.lookupValue(AUSF_CONFIG_STRING_IPV4_ADDRESS, address); if_cfg.lookupValue(AUSF_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( if (get_inet_addr_infos_from_iface(cfg.if_name, cfg.addr4, cfg.network4,
cfg.if_name, cfg.addr4, cfg.network4, cfg.mtu)) { cfg.mtu)) {
Logger::config().error( Logger::config().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( boost::split(words, address, boost::is_any_of("/"),
words, address, boost::is_any_of("/"), boost::token_compress_on); boost::token_compress_on);
if (words.size() != 2) { if (words.size() != 2) {
Logger::config().error( Logger::config().error("Bad value " AUSF_CONFIG_STRING_IPV4_ADDRESS
"Bad value " AUSF_CONFIG_STRING_IPV4_ADDRESS " = %s in config file", " = %s in config file",
address.c_str()); address.c_str());
return RETURNerror; return RETURNerror;
} }
...@@ -387,8 +379,8 @@ int ausf_config::load_interface( ...@@ -387,8 +379,8 @@ int ausf_config::load_interface(
util::trim(words.at(0)).c_str()); util::trim(words.at(0)).c_str());
return RETURNerror; return RETURNerror;
} }
cfg.network4.s_addr = htons( cfg.network4.s_addr =
ntohs(cfg.addr4.s_addr) & htons(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(AUSF_CONFIG_STRING_PORT, cfg.port); if_cfg.lookupValue(AUSF_CONFIG_STRING_PORT, cfg.port);
......
...@@ -33,11 +33,11 @@ ...@@ -33,11 +33,11 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <libconfig.h++> #include <libconfig.h++>
#include <mutex>
#include <netinet/in.h> #include <netinet/in.h>
#include <string>
#include <sys/socket.h> #include <sys/socket.h>
#include <mutex>
#include <vector> #include <vector>
#include <string>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
...@@ -85,11 +85,11 @@ typedef struct interface_cfg_s { ...@@ -85,11 +85,11 @@ typedef struct interface_cfg_s {
} interface_cfg_t; } interface_cfg_t;
class ausf_config { class ausf_config {
public: public:
ausf_config(); ausf_config();
~ausf_config(); ~ausf_config();
int load(const std::string& config_file); int load(const std::string &config_file);
int load_interface(const Setting& if_cfg, interface_cfg_t& cfg); int load_interface(const Setting &if_cfg, interface_cfg_t &cfg);
void display(); void display();
unsigned int instance; unsigned int instance;
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file ausf_event.cpp
\brief
\author Tien-Thinh NGUYEN (EURECOM)
\company
\date 2022
\email: contact@openairinterface.org
*/
#include "ausf_event.hpp"
using namespace oai::ausf::app;
bs2::connection
ausf_event::subscribe_task_nf_heartbeat(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
* to register to be notified every X ms instead of every ms, which provides
* greater freedom to implementations. */
auto f = [period, start, sig](uint64_t t) {
if (t >= start && (t - start) % period == 0)
sig(t);
};
return task_tick.connect(f);
}
//------------------------------------------------------------------------------
bs2::connection ausf_event::subscribe_loss_of_connectivity(
const loss_of_connectivity_sig_t::slot_type &sig) {
return loss_of_connectivity.connect(sig);
}
//------------------------------------------------------------------------------
bs2::connection ausf_event::subscribe_ue_reachability_for_data(
const ue_reachability_for_data_sig_t::slot_type &sig) {
return ue_reachability_for_data.connect(sig);
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file ausf_event.hpp
\brief
\author Tien-Thinh NGUYEN (EURECOM)
\company
\date 2022
\email: contact@openairinterface.org
*/
#ifndef FILE_AUSF_EVENT_HPP_SEEN
#define FILE_AUSF_EVENT_HPP_SEEN
#include <boost/signals2.hpp>
namespace bs2 = boost::signals2;
#include "ausf.h"
#include "ausf_event_sig.hpp"
#include "task_manager.hpp"
namespace oai::ausf::app {
class task_manager;
class ausf_event {
public:
ausf_event(){};
ausf_event(ausf_event const &) = delete;
void operator=(ausf_event const &) = delete;
static ausf_event &get_instance() {
static ausf_event instance;
return instance;
}
// class register/handle event
friend class ausf_app;
friend class ausf_nrf;
friend class task_manager;
//------------------------------------------------------------------------------
/*
* Subscribe to the task tick event
* @param [const task_sig_t::slot_type &] sig
* @param [uint64_t] period: interval between two events
* @param [uint64_t] start:
* @return void
*/
bs2::connection subscribe_task_nf_heartbeat(const task_sig_t::slot_type &sig,
uint64_t period,
uint64_t start = 0);
//------------------------------------------------------------------------------
/*
* Subscribe to UE Loss of Connectivity Status signal
* @param [const loss_of_connectivity_sig_t::slot_type&] sig: slot_type
* parameter
* @return boost::signals2::connection: the connection between the signal and
* the slot
*/
bs2::connection subscribe_loss_of_connectivity(
const loss_of_connectivity_sig_t::slot_type &sig);
/*
* Subscribe to UE Reachability for Data signal
* @param [const ue_reachability_for_data_sig_t::slot_type&] sig: slot_type
* parameter
* @return boost::signals2::connection: the connection between the signal and
* the slot
*/
bs2::connection subscribe_ue_reachability_for_data(
const ue_reachability_for_data_sig_t::slot_type &sig);
private:
task_sig_t task_tick;
loss_of_connectivity_sig_t
loss_of_connectivity; // Signal for Loss of Connectivity Report
ue_reachability_for_data_sig_t
ue_reachability_for_data; // Signal for UE Reachability for Data Report
};
} // namespace oai::ausf::app
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file ausf_event_sig.hpp
\brief
\author Tien-Thinh NGUYEN (EURECOM)
\company
\date 2022
\email: contact@openairinterface.org
*/
#ifndef FILE_AUSF_EVENT_SIG_HPP_SEEN
#define FILE_AUSF_EVENT_SIG_HPP_SEEN
#include <boost/signals2.hpp>
#include <string>
namespace bs2 = boost::signals2;
namespace oai::ausf::app {
typedef bs2::signal_type<void(uint64_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
task_sig_t;
// Signal for Loss of Connectivity
// SUPI, Connectivity status, HTTP version
typedef bs2::signal_type<void(std::string, uint8_t, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
loss_of_connectivity_sig_t;
// Signal for UE Reachability for Data
// SUPI, Reachability status, HTTP version
typedef bs2::signal_type<void(std::string, uint8_t, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
ue_reachability_for_data_sig_t;
// UE_REACHABILITY_FOR_SMS
// LOCATION_REPORTING
// CHANGE_OF_SUPI_PEI_ASSOCIATION
// ROAMING_STATUS
// COMMUNICATION_FAILURE
// AVAILABILITY_AFTER_DNN_FAILURE
// CN_TYPE_CHANGE
} // namespace oai::ausf::app
#endif
...@@ -29,19 +29,19 @@ ...@@ -29,19 +29,19 @@
#include "ausf_nrf.hpp" #include "ausf_nrf.hpp"
#include "ausf_app.hpp" #include "ausf_app.hpp"
#include "ausf_profile.hpp"
#include "ausf_client.hpp" #include "ausf_client.hpp"
#include "ausf_profile.hpp"
#include <boost/uuid/random_generator.hpp> #include <boost/uuid/random_generator.hpp>
#include <boost/uuid/uuid_io.hpp> #include <boost/uuid/uuid_io.hpp>
#include <curl/curl.h> #include <curl/curl.h>
#include <nlohmann/json.hpp>
#include <pistache/http.h> #include <pistache/http.h>
#include <pistache/mime.h> #include <pistache/mime.h>
#include <nlohmann/json.hpp>
#include <stdexcept> #include <stdexcept>
#include "logger.hpp"
#include "ausf.h" #include "ausf.h"
#include "logger.hpp"
using namespace config; using namespace config;
// using namespace ausf; // using namespace ausf;
...@@ -50,22 +50,22 @@ using namespace oai::ausf::app; ...@@ -50,22 +50,22 @@ using namespace oai::ausf::app;
using json = nlohmann::json; using json = nlohmann::json;
extern ausf_config ausf_cfg; extern ausf_config ausf_cfg;
extern ausf_nrf* ausf_nrf_inst; extern ausf_nrf *ausf_nrf_inst;
ausf_client* ausf_client_instance = nullptr; ausf_client *ausf_client_instance = nullptr;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
ausf_nrf::ausf_nrf() {} ausf_nrf::ausf_nrf(ausf_event &ev) : m_event_sub(ev) {}
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void ausf_nrf::get_ausf_api_root(std::string& api_root) { void ausf_nrf::get_ausf_api_root(std::string &api_root) {
api_root = std::string( api_root = std::string(
inet_ntoa(*((struct in_addr*) &ausf_cfg.nrf_addr.ipv4_addr))) + inet_ntoa(*((struct in_addr *)&ausf_cfg.nrf_addr.ipv4_addr))) +
":" + std::to_string(ausf_cfg.nrf_addr.port) + NNRF_NFM_BASE + ":" + std::to_string(ausf_cfg.nrf_addr.port) + NNRF_NFM_BASE +
ausf_cfg.nrf_addr.api_version; ausf_cfg.nrf_addr.api_version;
} }
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void ausf_nrf::generate_ausf_profile( void ausf_nrf::generate_ausf_profile(ausf_profile &ausf_nf_profile,
ausf_profile& ausf_nf_profile, std::string& ausf_instance_id) { std::string &ausf_instance_id) {
// TODO: remove hardcoded values // TODO: remove hardcoded values
ausf_nf_profile.set_nf_instance_id(ausf_instance_id); ausf_nf_profile.set_nf_instance_id(ausf_instance_id);
ausf_nf_profile.set_nf_instance_name("OAI-AUSF"); ausf_nf_profile.set_nf_instance_name("OAI-AUSF");
...@@ -95,7 +95,6 @@ void ausf_nrf::generate_ausf_profile( ...@@ -95,7 +95,6 @@ void ausf_nrf::generate_ausf_profile(
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void ausf_nrf::register_to_nrf() { void ausf_nrf::register_to_nrf() {
// generate UUID // generate UUID
std::string ausf_instance_id; // AUSF instance id
ausf_instance_id = to_string(boost::uuids::random_generator()()); ausf_instance_id = to_string(boost::uuids::random_generator()());
nlohmann::json response_data = {}; nlohmann::json response_data = {};
...@@ -114,16 +113,63 @@ void ausf_nrf::register_to_nrf() { ...@@ -114,16 +113,63 @@ void ausf_nrf::register_to_nrf() {
ausf_nf_profile.to_json(json_data); ausf_nf_profile.to_json(json_data);
Logger::ausf_nrf().info("Sending NF registeration request"); Logger::ausf_nrf().info("Sending NF registeration request");
ausf_client_instance->curl_http_client( ausf_client_instance->curl_http_client(remoteUri, method,
remoteUri, method, json_data.dump().c_str(), response); json_data.dump().c_str(), response);
try { try {
response_data = nlohmann::json::parse(response); response_data = nlohmann::json::parse(response);
if (response_data["nfStatus"].dump().c_str() == "REGISTERED") { response_data = nlohmann::json::parse(response);
// ToDo Trigger NF heartbeats if (response.find("REGISTERED") != 0) {
start_event_nf_heartbeat(remoteUri);
} }
} catch (nlohmann::json::exception& e) { } catch (nlohmann::json::exception &e) {
Logger::ausf_nrf().info("NF registeration procedure failed"); Logger::ausf_nrf().info("NF registeration procedure failed");
} }
} }
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void ausf_nrf::start_event_nf_heartbeat(std::string &remoteURI) {
// get current time
uint64_t ms = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
struct itimerspec its;
its.it_value.tv_sec = HEART_BEAT_TIMER; // seconds
its.it_value.tv_nsec = 0; // 100 * 1000 * 1000; //100ms
const uint64_t interval =
its.it_value.tv_sec * 1000 +
its.it_value.tv_nsec / 1000000; // convert sec, nsec to msec
task_connection = m_event_sub.subscribe_task_nf_heartbeat(
boost::bind(&ausf_nrf::trigger_nf_heartbeat_procedure, this, _1),
interval, ms + interval);
}
//---------------------------------------------------------------------------------------------
void ausf_nrf::trigger_nf_heartbeat_procedure(uint64_t ms) {
_unused(ms);
oai::ausf_server::model::PatchItem patch_item = {};
std::vector<oai::ausf_server::model::PatchItem> patch_items;
//{"op":"replace","path":"/nfStatus", "value": "REGISTERED"}
patch_item.setOp("replace");
patch_item.setPath("/nfStatus");
patch_item.setValue("REGISTERED");
patch_items.push_back(patch_item);
Logger::ausf_nrf().info("Sending NF heartbeat request");
std::string response = {};
std::string method = {"PATCH"};
nlohmann::json json_data = nlohmann::json::array();
for (auto i : patch_items) {
nlohmann::json item = {};
to_json(item, i);
json_data.push_back(item);
}
std::string ausf_api_root = {};
get_ausf_api_root(ausf_api_root);
std::string remoteUri =
ausf_api_root + AUSF_NF_REGISTER_URL + ausf_instance_id;
ausf_client_instance->curl_http_client(remoteUri, method,
json_data.dump().c_str(), response);
if (!response.empty())
task_connection.disconnect();
}
\ No newline at end of file
...@@ -34,34 +34,49 @@ ...@@ -34,34 +34,49 @@
#include <curl/curl.h> #include <curl/curl.h>
#include "logger.hpp" #include "PatchItem.h"
#include "ausf_config.hpp" #include "ausf_config.hpp"
#include "ausf_event.hpp"
#include "ausf_profile.hpp" #include "ausf_profile.hpp"
#include "logger.hpp"
using namespace oai::ausf_server::model;
namespace oai { namespace oai {
namespace ausf { namespace ausf {
namespace app { namespace app {
class ausf_nrf { class ausf_nrf {
private: private:
public: public:
ausf_profile ausf_nf_profile; // AUSF profile ausf_profile ausf_nf_profile; // AUSF profile
std::string ausf_instance_id; // AUSF instance id std::string ausf_instance_id; // AUSF instance id
// timer_id_t timer_ausf_heartbeat; // timer_id_t timer_ausf_heartbeat;
ausf_nrf(); ausf_nrf(ausf_event &ev);
ausf_nrf(ausf_nrf const&) = delete; ausf_nrf(ausf_nrf const &) = delete;
void operator=(ausf_nrf const&) = delete; void operator=(ausf_nrf const &) = delete;
void generate_uuid(); void generate_uuid();
/*
* Start event nf heartbeat procedure
* @param [void]
* @return void
*/
void start_event_nf_heartbeat(std::string &remoteURI);
/*
* Trigger NF heartbeat procedure
* @param [void]
* @return void
*/
void trigger_nf_heartbeat_procedure(uint64_t ms);
/* /*
* Generate a AUSF profile for this instance * Generate a AUSF profile for this instance
* @param [void] * @param [void]
* @return void * @return void
*/ */
void generate_ausf_profile( void generate_ausf_profile(ausf_profile &ausf_nf_profile,
ausf_profile& ausf_nf_profile, std::string& ausf_instance_id); std::string &ausf_instance_id);
/* /*
* Trigger NF instance registration to NRF * Trigger NF instance registration to NRF
...@@ -74,7 +89,11 @@ class ausf_nrf { ...@@ -74,7 +89,11 @@ class ausf_nrf {
* @param [std::string& ] api_root: ausf's API Root * @param [std::string& ] api_root: ausf's API Root
* @return void * @return void
*/ */
void get_ausf_api_root(std::string& api_root); void get_ausf_api_root(std::string &api_root);
private:
ausf_event &m_event_sub;
bs2::connection task_connection;
}; };
} // namespace app } // namespace app
} // namespace ausf } // namespace ausf
......
...@@ -30,35 +30,33 @@ ...@@ -30,35 +30,33 @@
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#include "logger.hpp"
#include "ausf_profile.hpp" #include "ausf_profile.hpp"
#include "logger.hpp"
#include "string.hpp" #include "string.hpp"
// using namespace ausf; // using namespace ausf;
using namespace oai::ausf::app; using namespace oai::ausf::app;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::set_nf_instance_id(const std::string& instance_id) { void ausf_profile::set_nf_instance_id(const std::string &instance_id) {
nf_instance_id = instance_id; nf_instance_id = instance_id;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::get_nf_instance_id(std::string& instance_id) const { void ausf_profile::get_nf_instance_id(std::string &instance_id) const {
instance_id = nf_instance_id; instance_id = nf_instance_id;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::string ausf_profile::get_nf_instance_id() const { std::string ausf_profile::get_nf_instance_id() const { return nf_instance_id; }
return nf_instance_id;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::set_nf_instance_name(const std::string& instance_name) { void ausf_profile::set_nf_instance_name(const std::string &instance_name) {
nf_instance_name = instance_name; nf_instance_name = instance_name;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::get_nf_instance_name(std::string& instance_name) const { void ausf_profile::get_nf_instance_name(std::string &instance_name) const {
instance_name = nf_instance_name; instance_name = nf_instance_name;
} }
...@@ -68,122 +66,92 @@ std::string ausf_profile::get_nf_instance_name() const { ...@@ -68,122 +66,92 @@ std::string ausf_profile::get_nf_instance_name() const {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::set_nf_type(const std::string& type) { void ausf_profile::set_nf_type(const std::string &type) { nf_type = type; }
nf_type = type;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::string ausf_profile::get_nf_type() const { std::string ausf_profile::get_nf_type() const { return nf_type; }
return nf_type;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::set_nf_status(const std::string& status) { void ausf_profile::set_nf_status(const std::string &status) {
nf_status = status; nf_status = status;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::get_nf_status(std::string& status) const { void ausf_profile::get_nf_status(std::string &status) const {
status = nf_status; status = nf_status;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::string ausf_profile::get_nf_status() const { std::string ausf_profile::get_nf_status() const { return nf_status; }
return nf_status;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::set_nf_heartBeat_timer(const int32_t& timer) { void ausf_profile::set_nf_heartBeat_timer(const int32_t &timer) {
heartBeat_timer = timer; heartBeat_timer = timer;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::get_nf_heartBeat_timer(int32_t& timer) const { void ausf_profile::get_nf_heartBeat_timer(int32_t &timer) const {
timer = heartBeat_timer; timer = heartBeat_timer;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int32_t ausf_profile::get_nf_heartBeat_timer() const { int32_t ausf_profile::get_nf_heartBeat_timer() const { return heartBeat_timer; }
return heartBeat_timer;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::set_nf_priority(const uint16_t& p) { void ausf_profile::set_nf_priority(const uint16_t &p) { priority = p; }
priority = p;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::get_nf_priority(uint16_t& p) const { void ausf_profile::get_nf_priority(uint16_t &p) const { p = priority; }
p = priority;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint16_t ausf_profile::get_nf_priority() const { uint16_t ausf_profile::get_nf_priority() const { return priority; }
return priority;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::set_nf_capacity(const uint16_t& c) { void ausf_profile::set_nf_capacity(const uint16_t &c) { capacity = c; }
capacity = c;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::get_nf_capacity(uint16_t& c) const { void ausf_profile::get_nf_capacity(uint16_t &c) const { c = capacity; }
c = capacity;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint16_t ausf_profile::get_nf_capacity() const { uint16_t ausf_profile::get_nf_capacity() const { return capacity; }
return capacity;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::set_nf_snssais(const std::vector<snssai_t>& s) { void ausf_profile::set_nf_snssais(const std::vector<snssai_t> &s) {
snssais = s; snssais = s;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::get_nf_snssais(std::vector<snssai_t>& s) const { void ausf_profile::get_nf_snssais(std::vector<snssai_t> &s) const {
s = snssais; s = snssais;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::add_snssai(const snssai_t& s) { void ausf_profile::add_snssai(const snssai_t &s) { snssais.push_back(s); }
snssais.push_back(s);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::set_fqdn(const std::string& fqdN) { void ausf_profile::set_fqdn(const std::string &fqdN) { fqdn = fqdN; }
fqdn = fqdN;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::string ausf_profile::get_fqdn() const { std::string ausf_profile::get_fqdn() const { return fqdn; }
return fqdn;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::set_nf_ipv4_addresses(const std::vector<struct in_addr>& a) { void ausf_profile::set_nf_ipv4_addresses(const std::vector<struct in_addr> &a) {
ipv4_addresses = a; ipv4_addresses = a;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::add_nf_ipv4_addresses(const struct in_addr& a) { void ausf_profile::add_nf_ipv4_addresses(const struct in_addr &a) {
ipv4_addresses.push_back(a); ipv4_addresses.push_back(a);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::get_nf_ipv4_addresses(std::vector<struct in_addr>& a) const { void ausf_profile::get_nf_ipv4_addresses(std::vector<struct in_addr> &a) const {
a = ipv4_addresses; a = ipv4_addresses;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::set_ausf_info(const ausf_info_t& s) { void ausf_profile::set_ausf_info(const ausf_info_t &s) { ausf_info = s; }
ausf_info = s;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::get_ausf_info(ausf_info_t& s) const { void ausf_profile::get_ausf_info(ausf_info_t &s) const { s = ausf_info; }
s = ausf_info;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::display() const { void ausf_profile::display() const {
...@@ -225,7 +193,7 @@ void ausf_profile::display() const { ...@@ -225,7 +193,7 @@ void ausf_profile::display() const {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::to_json(nlohmann::json& data) const { void ausf_profile::to_json(nlohmann::json &data) const {
data["nfInstanceId"] = nf_instance_id; data["nfInstanceId"] = nf_instance_id;
data["nfInstanceName"] = nf_instance_name; data["nfInstanceName"] = nf_instance_name;
data["nfType"] = nf_type; data["nfType"] = nf_type;
...@@ -270,7 +238,7 @@ void ausf_profile::to_json(nlohmann::json& data) const { ...@@ -270,7 +238,7 @@ void ausf_profile::to_json(nlohmann::json& data) const {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::from_json(const nlohmann::json& data) { void ausf_profile::from_json(const nlohmann::json &data) {
if (data.find("nfInstanceId") != data.end()) { if (data.find("nfInstanceId") != data.end()) {
nf_instance_id = data["nfInstanceId"].get<std::string>(); nf_instance_id = data["nfInstanceId"].get<std::string>();
} }
...@@ -310,8 +278,8 @@ void ausf_profile::from_json(const nlohmann::json& data) { ...@@ -310,8 +278,8 @@ void ausf_profile::from_json(const nlohmann::json& data) {
if (inet_pton(AF_INET, util::trim(address).c_str(), buf_in_addr) == 1) { if (inet_pton(AF_INET, util::trim(address).c_str(), buf_in_addr) == 1) {
memcpy(&addr4, buf_in_addr, sizeof(struct in_addr)); memcpy(&addr4, buf_in_addr, sizeof(struct in_addr));
} else { } else {
Logger::ausf_app().warn( Logger::ausf_app().warn("Address conversion: Bad value %s",
"Address conversion: Bad value %s", util::trim(address).c_str()); util::trim(address).c_str());
} }
add_nf_ipv4_addresses(addr4); add_nf_ipv4_addresses(addr4);
} }
...@@ -354,8 +322,7 @@ void ausf_profile::from_json(const nlohmann::json& data) { ...@@ -354,8 +322,7 @@ void ausf_profile::from_json(const nlohmann::json& data) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_profile::handle_heartbeart_timeout(uint64_t ms) { void ausf_profile::handle_heartbeart_timeout(uint64_t ms) {
Logger::ausf_app().info( Logger::ausf_app().info("Handle heartbeart timeout profile %s, time %d",
"Handle heartbeart timeout profile %s, time %d", nf_instance_id.c_str(), nf_instance_id.c_str(), ms);
ms);
set_nf_status("SUSPENDED"); set_nf_status("SUSPENDED");
} }
...@@ -36,42 +36,31 @@ ...@@ -36,42 +36,31 @@
#include <shared_mutex> #include <shared_mutex>
#include <vector> #include <vector>
#include "logger.hpp"
#include "3gpp_29.510.h" #include "3gpp_29.510.h"
#include "ausf.h" #include "ausf.h"
#include "logger.hpp"
namespace oai { namespace oai {
namespace ausf { namespace ausf {
namespace app { namespace app {
class ausf_profile : public std::enable_shared_from_this<ausf_profile> { class ausf_profile : public std::enable_shared_from_this<ausf_profile> {
public: public:
ausf_profile() ausf_profile()
: nf_type("NF_TYPE_UNKNOWN"), : nf_type("NF_TYPE_UNKNOWN"), heartBeat_timer(0), snssais(), fqdn(),
heartBeat_timer(0), ipv4_addresses(), priority(0), capacity(0) {
snssais(),
fqdn(),
ipv4_addresses(),
priority(0),
capacity(0) {
nf_instance_name = {}; nf_instance_name = {};
nf_status = {}; nf_status = {};
} }
ausf_profile(const std::string& id) ausf_profile(const std::string &id)
: nf_instance_id(id), : nf_instance_id(id), heartBeat_timer(0), snssais(), fqdn(),
heartBeat_timer(0), ipv4_addresses(), priority(0), capacity(0), nf_type("NF_TYPE_UNKNOWN") {
snssais(),
fqdn(),
ipv4_addresses(),
priority(0),
capacity(0),
nf_type("NF_TYPE_UNKNOWN") {
nf_instance_name = {}; nf_instance_name = {};
nf_status = {}; nf_status = {};
} }
ausf_profile& operator=(const ausf_profile& s) { ausf_profile &operator=(const ausf_profile &s) {
nf_instance_id = s.nf_instance_id; nf_instance_id = s.nf_instance_id;
heartBeat_timer = s.heartBeat_timer; heartBeat_timer = s.heartBeat_timer;
snssais = s.snssais; snssais = s.snssais;
...@@ -96,13 +85,13 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> { ...@@ -96,13 +85,13 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> {
* @param [const std::string &] instance_id: instance id * @param [const std::string &] instance_id: instance id
* @return void * @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 * Get NF instance ID
* @param [std::string &] instance_id: store instance id * @param [std::string &] instance_id: store instance id
* @return void: * @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 * Get NF instance ID
...@@ -116,14 +105,14 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> { ...@@ -116,14 +105,14 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> {
* @param [const std::string &] instance_name: instance name * @param [const std::string &] instance_name: instance name
* @return void * @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 * Get NF instance ID
* @param [std::string &] instance_name: store instance name * @param [std::string &] instance_name: store instance name
* @return void: * @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 * Get NF instance name
...@@ -137,14 +126,14 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> { ...@@ -137,14 +126,14 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> {
* @param [const std::string &] status: instance status * @param [const std::string &] status: instance status
* @return void * @return void
*/ */
void set_nf_status(const std::string& status); void set_nf_status(const std::string &status);
/* /*
* Get NF instance status * Get NF instance status
* @param [std::string &] status: store instance status * @param [std::string &] status: store instance status
* @return void: * @return void:
*/ */
void get_nf_status(std::string& status) const; void get_nf_status(std::string &status) const;
/* /*
* Get NF status * Get NF status
...@@ -165,21 +154,21 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> { ...@@ -165,21 +154,21 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> {
* @param [const nf_type_t &] type: nf type * @param [const nf_type_t &] type: nf type
* @return void * @return void
*/ */
void set_nf_type(const std::string& type); void set_nf_type(const std::string &type);
/* /*
* Set NF instance heartBeat_timer * Set NF instance heartBeat_timer
* @param [const std::string &] timer: heartBeat_timer * @param [const std::string &] timer: heartBeat_timer
* @return void * @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 * Get NF instance heartBeat_timer
* @param [std::string &] timer: store heartBeat_timer * @param [std::string &] timer: store heartBeat_timer
* @return void: * @return void:
*/ */
void get_nf_heartBeat_timer(int32_t& timer) const; void get_nf_heartBeat_timer(int32_t &timer) const;
/* /*
* Get NF heartBeat_timer * Get NF heartBeat_timer
...@@ -193,14 +182,14 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> { ...@@ -193,14 +182,14 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> {
* @param [const uint16_t] p: instance priority * @param [const uint16_t] p: instance priority
* @return void * @return void
*/ */
void set_nf_priority(const uint16_t& p); void set_nf_priority(const uint16_t &p);
/* /*
* Get NF instance priority * Get NF instance priority
* @param [uint16_t] p: store instance priority * @param [uint16_t] p: store instance priority
* @return void: * @return void:
*/ */
void get_nf_priority(uint16_t& p) const; void get_nf_priority(uint16_t &p) const;
/* /*
* Get NF instance priority * Get NF instance priority
...@@ -214,14 +203,14 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> { ...@@ -214,14 +203,14 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> {
* @param [const uint16_t] c: instance capacity * @param [const uint16_t] c: instance capacity
* @return void * @return void
*/ */
void set_nf_capacity(const uint16_t& c); void set_nf_capacity(const uint16_t &c);
/* /*
* Get NF instance priority * Get NF instance priority
* @param [uint16_t ] c: store instance capacity * @param [uint16_t ] c: store instance capacity
* @return void: * @return void:
*/ */
void get_nf_capacity(uint16_t& c) const; void get_nf_capacity(uint16_t &c) const;
/* /*
* Get NF instance priority * Get NF instance priority
...@@ -235,21 +224,21 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> { ...@@ -235,21 +224,21 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> {
* @param [std::vector<snssai_t> &] s: SNSSAIs * @param [std::vector<snssai_t> &] s: SNSSAIs
* @return void * @return void
*/ */
void set_nf_snssais(const std::vector<snssai_t>& s); void set_nf_snssais(const std::vector<snssai_t> &s);
/* /*
* Add SNSSAI * Add SNSSAI
* @param [snssai_t &] s: SNSSAI * @param [snssai_t &] s: SNSSAI
* @return void * @return void
*/ */
void add_snssai(const snssai_t& s); void add_snssai(const snssai_t &s);
/* /*
* Get NF instance SNSSAIs * Get NF instance SNSSAIs
* @param [std::vector<snssai_t> &] s: store instance's SNSSAIs * @param [std::vector<snssai_t> &] s: store instance's SNSSAIs
* @return void: * @return void:
*/ */
void get_nf_snssais(std::vector<snssai_t>& s) const; void get_nf_snssais(std::vector<snssai_t> &s) const;
/* /*
* Get NF fqdn * Get NF fqdn
...@@ -263,42 +252,42 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> { ...@@ -263,42 +252,42 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> {
* @param [const fqdn_t &] fqdn: nf fqdn * @param [const fqdn_t &] fqdn: nf fqdn
* @return void * @return void
*/ */
void set_fqdn(const std::string& fqdn); void set_fqdn(const std::string &fqdn);
/* /*
* Set NF instance ipv4_addresses * Set NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: ipv4_addresses * @param [std::vector<struct in_addr> &] a: ipv4_addresses
* @return void * @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 * Add an IPv4 address to the list of addresses
* @param [const struct in_addr &] a: ipv4_address * @param [const struct in_addr &] a: ipv4_address
* @return void * @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 * Get NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: store instance's ipv4_addresses * @param [std::vector<struct in_addr> &] a: store instance's ipv4_addresses
* @return void: * @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 ausf info * Set ausf info
* @param [ausf_info_t &] s: ausf info * @param [ausf_info_t &] s: ausf info
* @return void * @return void
*/ */
void set_ausf_info(const ausf_info_t& s); void set_ausf_info(const ausf_info_t &s);
/* /*
* Get NF instance ausf info * Get NF instance ausf info
* @param [ausf_info_t &] s: store instance's ausf info * @param [ausf_info_t &] s: store instance's ausf info
* @return void: * @return void:
*/ */
void get_ausf_info(ausf_info_t& s) const; void get_ausf_info(ausf_info_t &s) const;
/* /*
* Print related-information for NF profile * Print related-information for NF profile
...@@ -312,14 +301,14 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> { ...@@ -312,14 +301,14 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> {
* @param [nlohmann::json &] data: Json data * @param [nlohmann::json &] data: Json data
* @return void * @return void
*/ */
void to_json(nlohmann::json& data) const; void to_json(nlohmann::json &data) const;
/* /*
* Covert from a json represetation to ausf profile * Covert from a json represetation to ausf profile
* @param [nlohmann::json &] data: Json data * @param [nlohmann::json &] data: Json data
* @return void * @return void
*/ */
void from_json(const nlohmann::json& data); void from_json(const nlohmann::json &data);
/* /*
* Handle heartbeart timeout event * Handle heartbeart timeout event
...@@ -328,7 +317,7 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> { ...@@ -328,7 +317,7 @@ class ausf_profile : public std::enable_shared_from_this<ausf_profile> {
*/ */
void handle_heartbeart_timeout(uint64_t ms); void handle_heartbeart_timeout(uint64_t ms);
protected: protected:
// From NFProfile (Section 6.1.6.2.2@3GPP TS 29.510 V16.0.0 (2019-06)) // From NFProfile (Section 6.1.6.2.2@3GPP TS 29.510 V16.0.0 (2019-06))
std::string nf_instance_id; std::string nf_instance_id;
std::string nf_instance_name; std::string nf_instance_name;
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file task_manager.cpp
\brief
\author
\company Eurecom
\date 2020
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#include "task_manager.hpp"
#include <iostream>
#include <thread>
#include <unistd.h>
#include "logger.hpp"
using namespace oai::ausf::app;
//------------------------------------------------------------------------------
task_manager::task_manager(ausf_event &ev) : event_sub_(ev) {
struct itimerspec its;
sfd = timerfd_create(CLOCK_MONOTONIC, 0);
/* Start the timer */
its.it_value.tv_sec = 0;
its.it_value.tv_nsec = 1000 * 1000;
its.it_interval.tv_sec = its.it_value.tv_sec;
its.it_interval.tv_nsec = its.it_value.tv_nsec;
if (timerfd_settime(sfd, TFD_TIMER_ABSTIME, &its, NULL) == -1) {
Logger::ausf_app().error("Failed to set timer for task manager");
}
}
//------------------------------------------------------------------------------
void task_manager::run() { manage_tasks(); }
//------------------------------------------------------------------------------
void task_manager::manage_tasks() {
// starting from current time
uint64_t t = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
while (1) {
event_sub_.task_tick(t);
t++;
wait_for_cycle();
}
}
//------------------------------------------------------------------------------
void task_manager::wait_for_cycle() {
uint64_t exp;
ssize_t res;
if (sfd > 0) {
res = read(sfd, &exp, sizeof(exp));
if ((res < 0) || (res != sizeof(exp))) {
Logger::ausf_app().error("Failed in task manager timer wait");
}
}
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file task_manager.hpp
\brief
\author
\company Eurecom
\date 2020
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#ifndef TASK_MANAGER_H_
#define TASK_MANAGER_H_
#include "ausf_event.hpp"
#include <linux/types.h>
#include <sys/timerfd.h>
using namespace oai::ausf::app;
namespace oai {
namespace ausf {
namespace app {
class ausf_event;
class task_manager {
public:
task_manager(ausf_event &ev);
/*
* Manage the tasks
* @param [void]
* @return void
*/
void manage_tasks();
/*
* Run the tasks (for the moment, simply call function manage_tasks)
* @param [void]
* @return void
*/
void run();
private:
/*
* Make sure that the task tick run every 1ms
* @param [void]
* @return void
*/
void wait_for_cycle();
ausf_event &event_sub_;
int sfd;
};
} // namespace app
} // namespace ausf
} // namespace oai
#endif
...@@ -24,7 +24,10 @@ ...@@ -24,7 +24,10 @@
#define HEART_BEAT_TIMER 10 #define HEART_BEAT_TIMER 10
#define _unused(x) ((void) (x)) #define _unused(x) ((void)(x))
#define NNRF_NFM_BASE "/nnrf-nfm/"
#define AUSF_NF_REGISTER_URL "/nf-instances/"
typedef enum nf_type_s { typedef enum nf_type_s {
NF_TYPE_NRF = 0, NF_TYPE_NRF = 0,
......
...@@ -24,10 +24,11 @@ ...@@ -24,10 +24,11 @@
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <iostream> #include <iostream>
bool fqdn::resolve( bool fqdn::resolve(const std::string &host_name, std::string &address,
const std::string& host_name, std::string& address, uint32_t& port, uint32_t &port, uint8_t &addr_type,
uint8_t& addr_type, const std::string& protocol) { const std::string &protocol) {
try { try {
Logger::ausf_app().debug("Resolving DNS:- %s", host_name.c_str());
boost::asio::io_context io_context = {}; boost::asio::io_context io_context = {};
boost::asio::ip::tcp::resolver resolver{io_context}; boost::asio::ip::tcp::resolver resolver{io_context};
...@@ -49,9 +50,9 @@ bool fqdn::resolve( ...@@ -49,9 +50,9 @@ bool fqdn::resolve(
addr_type = 1; addr_type = 1;
return true; return true;
} }
} catch (std::exception& e) { } catch (std::exception &e) {
throw std::runtime_error( throw std::runtime_error("Cannot resolve a DNS name " +
"Cannot resolve a DNS name " + std::string(e.what())); std::string(e.what()));
return false; return false;
} }
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
* limitations under the License. * limitations under the License.
*/ */
#include "logger.hpp"
#include "ausf-api-server.h" #include "ausf-api-server.h"
#include "ausf-http2-server.h" #include "ausf-http2-server.h"
#include "ausf_config.hpp"
#include "ausf_app.hpp" #include "ausf_app.hpp"
#include "ausf_config.hpp"
#include "logger.hpp"
#include "options.hpp" #include "options.hpp"
#include "pid_file.hpp" #include "pid_file.hpp"
...@@ -26,12 +26,12 @@ ...@@ -26,12 +26,12 @@
#include "pistache/http.h" #include "pistache/http.h"
#include "pistache/router.h" #include "pistache/router.h"
#include <iostream>
#include <signal.h> #include <signal.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> // srand #include <stdlib.h> // srand
#include <unistd.h> // get_pid(), pause()
#include <iostream>
#include <thread> #include <thread>
#include <unistd.h> // get_pid(), pause()
using namespace oai::ausf::app; using namespace oai::ausf::app;
using namespace util; using namespace util;
...@@ -40,9 +40,9 @@ using namespace std; ...@@ -40,9 +40,9 @@ using namespace std;
using namespace config; using namespace config;
ausf_config ausf_cfg; ausf_config ausf_cfg;
ausf_app* ausf_app_inst = nullptr; ausf_app *ausf_app_inst = nullptr;
AUSFApiServer* api_server = nullptr; AUSFApiServer *api_server = nullptr;
ausf_http2_server* ausf_api_server_2 = nullptr; ausf_http2_server *ausf_api_server_2 = nullptr;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void my_app_signal_handler(int s) { void my_app_signal_handler(int s) {
...@@ -68,7 +68,7 @@ void my_app_signal_handler(int s) { ...@@ -68,7 +68,7 @@ void my_app_signal_handler(int s) {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int main(int argc, char** argv) { int main(int argc, char **argv) {
srand(time(NULL)); srand(time(NULL));
// Command line options // Command line options
...@@ -87,40 +87,47 @@ int main(int argc, char** argv) { ...@@ -87,40 +87,47 @@ int main(int argc, char** argv) {
sigIntHandler.sa_flags = 0; sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL); sigaction(SIGINT, &sigIntHandler, NULL);
// Event subsystem
ausf_event ev;
// Config // Config
ausf_cfg.load(Options::getlibconfigConfig()); ausf_cfg.load(Options::getlibconfigConfig());
ausf_cfg.display(); ausf_cfg.display();
// AUSF application layer // AUSF application layer
ausf_app_inst = new ausf_app(Options::getlibconfigConfig()); ausf_app_inst = new ausf_app(Options::getlibconfigConfig(), ev);
// Task Manager
task_manager tm(ev);
std::thread task_manager_thread(&task_manager::run, &tm);
// PID file // PID file
// Currently hard-coded value. TODO: add as config option. // Currently hard-coded value. TODO: add as config option.
string pid_file_name = get_exe_absolute_path("/var/run", ausf_cfg.instance); string pid_file_name = get_exe_absolute_path("/var/run", ausf_cfg.instance);
if (!is_pid_file_lock_success(pid_file_name.c_str())) { if (!is_pid_file_lock_success(pid_file_name.c_str())) {
Logger::ausf_server().error( Logger::ausf_server().error("Lock PID file %s failed\n",
"Lock PID file %s failed\n", pid_file_name.c_str()); pid_file_name.c_str());
exit(-EDEADLK); exit(-EDEADLK);
} }
// AUSF Pistache API server (HTTP1) // AUSF Pistache API server (HTTP1)
Pistache::Address addr( Pistache::Address addr(
std::string(inet_ntoa(*((struct in_addr*) &ausf_cfg.sbi.addr4))), std::string(inet_ntoa(*((struct in_addr *)&ausf_cfg.sbi.addr4))),
Pistache::Port(ausf_cfg.sbi.port)); Pistache::Port(ausf_cfg.sbi.port));
api_server = new AUSFApiServer(addr, ausf_app_inst); api_server = new AUSFApiServer(addr, ausf_app_inst);
api_server->init(2); api_server->init(2);
std::thread ausf_manager(&AUSFApiServer::start, api_server); std::thread ausf_manager(&AUSFApiServer::start, api_server);
// AUSF NGHTTP API server (HTTP2) // AUSF NGHTTP API server (HTTP2)
ausf_api_server_2 = new ausf_http2_server( ausf_api_server_2 =
conv::toString(ausf_cfg.sbi.addr4), ausf_cfg.sbi_http2_port, new ausf_http2_server(conv::toString(ausf_cfg.sbi.addr4),
ausf_app_inst); ausf_cfg.sbi_http2_port, ausf_app_inst);
std::thread ausf_http2_manager(&ausf_http2_server::start, ausf_api_server_2); std::thread ausf_http2_manager(&ausf_http2_server::start, ausf_api_server_2);
ausf_manager.join(); ausf_manager.join();
ausf_http2_manager.join(); ausf_http2_manager.join();
FILE* fp = NULL; FILE *fp = NULL;
std::string filename = fmt::format("/tmp/ausf_{}.status", getpid()); std::string filename = fmt::format("/tmp/ausf_{}.status", getpid());
fp = fopen(filename.c_str(), "w+"); fp = fopen(filename.c_str(), "w+");
fprintf(fp, "STARTED\n"); fprintf(fp, "STARTED\n");
......
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