Commit 02272eef authored by Raphael Defosseux's avatar Raphael Defosseux

Merge branch 'nrf' into 'develop'

NF registration completed

See merge request oai/cn5g/oai-cn5g-ausf!14
parents 7ed8d084 848b0a58
...@@ -18,6 +18,7 @@ AUSF = ...@@ -18,6 +18,7 @@ AUSF =
SUPPORT_FEATURES:{ SUPPORT_FEATURES:{
# STRING, {"yes", "no"}, # STRING, {"yes", "no"},
USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if AUSF will relying on a DNS to resolve UDM's FQDN USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if AUSF will relying on a DNS to resolve UDM's FQDN
REGISTER_NRF = "@REGISTER_NRF@"; # Set to 'yes' if AUSF resgisters to an NRF
} }
# UDM Information # UDM Information
...@@ -28,4 +29,11 @@ AUSF = ...@@ -28,4 +29,11 @@ AUSF =
FQDN = "@UDM_FQDN@" # YOUR UDM FQDN CONFIG HERE FQDN = "@UDM_FQDN@" # YOUR UDM FQDN CONFIG HERE
}; };
NRF :
{
IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@"; # YOUR NRF CONFIG HERE
PORT = @NRF_PORT@; # YOUR NRF CONFIG HERE (default: 80)
API_VERSION = "@NRF_API_VERSION@"; # YOUR NRF API VERSION HERE
FQDN = "@NRF_FQDN@";
};
}; };
...@@ -5,6 +5,11 @@ set -euo pipefail ...@@ -5,6 +5,11 @@ set -euo pipefail
CONFIG_DIR="/openair-ausf/etc" CONFIG_DIR="/openair-ausf/etc"
SBI_PORT=${SBI_PORT:-80} SBI_PORT=${SBI_PORT:-80}
UDM_PORT=${UDM_PORT:-80} UDM_PORT=${UDM_PORT:-80}
REGISTER_NRF=${REGISTER_NRF:-no}
NRF_IPV4_ADDRESS=${NRF_IPV4_ADDRESS:-0.0.0.0}
NRF_PORT=${NRF_PORT:-80}
NRF_API_VERSION=${NRF_API_VERSION:-v1}
NRF_FQDN=${NRF_FQDN:-oai-nrf}
if [[ ${USE_FQDN_DNS} == "yes" ]];then if [[ ${USE_FQDN_DNS} == "yes" ]];then
UDM_IP_ADDRESS=${UDM_IP_ADDRESS:-0.0.0.0} UDM_IP_ADDRESS=${UDM_IP_ADDRESS:-0.0.0.0}
......
...@@ -31,6 +31,6 @@ add_library (AUSF STATIC ...@@ -31,6 +31,6 @@ add_library (AUSF STATIC
ausf_app.cpp ausf_app.cpp
ausf_client.cpp ausf_client.cpp
ausf_config.cpp ausf_config.cpp
ausf_profile.cpp
ausf_nrf.cpp
) )
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
*/ */
#include "ausf_app.hpp" #include "ausf_app.hpp"
#include "ausf_nrf.hpp"
#include <unistd.h> #include <unistd.h>
#include "logger.hpp" #include "logger.hpp"
...@@ -52,6 +53,7 @@ extern ausf_app* ausf_app_inst; ...@@ -52,6 +53,7 @@ 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_app::ausf_app(const std::string& config_file) ausf_app::ausf_app(const std::string& config_file)
...@@ -65,7 +67,17 @@ ausf_app::ausf_app(const std::string& config_file) ...@@ -65,7 +67,17 @@ ausf_app::ausf_app(const std::string& config_file)
Logger::ausf_app().error("Cannot create AUSF APP: %s", e.what()); Logger::ausf_app().error("Cannot create AUSF APP: %s", e.what());
throw; throw;
} }
// TODO: Register to NRF // Register to NRF
if (ausf_cfg.register_nrf) {
try {
ausf_nrf_inst = new ausf_nrf();
ausf_nrf_inst->register_to_nrf();
Logger::ausf_app().info("NRF TASK Created ");
} catch (std::exception& e) {
Logger::ausf_app().error("Cannot create NRF TASK: %s", e.what());
throw;
}
}
Logger::ausf_app().startup("Started"); Logger::ausf_app().startup("Started");
} }
......
...@@ -142,6 +142,14 @@ int ausf_config::load(const std::string& config_file) { ...@@ -142,6 +142,14 @@ int ausf_config::load(const std::string& config_file) {
use_fqdn_dns = false; use_fqdn_dns = false;
} }
support_features.lookupValue(
AUSF_CONFIG_STRING_SUPPORTED_FEATURES_REGISTER_NRF, opt);
if (boost::iequals(opt, "yes")) {
register_nrf = true;
} else {
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(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
...@@ -207,6 +215,58 @@ int ausf_config::load(const std::string& config_file) { ...@@ -207,6 +215,58 @@ int ausf_config::load(const std::string& config_file) {
return RETURNerror; return RETURNerror;
} }
// NRF
if (register_nrf) {
try {
std::string astring = {};
const Setting& nrf_cfg = ausf_cfg[AUSF_CONFIG_STRING_NRF];
struct in_addr nrf_ipv4_addr = {};
unsigned int nrf_port = 0;
std::string nrf_api_version = {};
if (!use_fqdn_dns) {
nrf_cfg.lookupValue(AUSF_CONFIG_STRING_NRF_IPV4_ADDRESS, astring);
IPV4_STR_ADDR_TO_INADDR(
util::trim(astring).c_str(), nrf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !");
nrf_addr.ipv4_addr = nrf_ipv4_addr;
if (!(nrf_cfg.lookupValue(AUSF_CONFIG_STRING_NRF_PORT, nrf_port))) {
Logger::ausf_app().error(AUSF_CONFIG_STRING_NRF_PORT "failed");
throw(AUSF_CONFIG_STRING_NRF_PORT "failed");
}
nrf_addr.port = nrf_port;
if (!(nrf_cfg.lookupValue(
AUSF_CONFIG_STRING_API_VERSION, nrf_api_version))) {
Logger::ausf_app().error(AUSF_CONFIG_STRING_API_VERSION "failed");
throw(AUSF_CONFIG_STRING_API_VERSION "failed");
}
nrf_addr.api_version = nrf_api_version;
} else {
nrf_cfg.lookupValue(AUSF_CONFIG_STRING_FQDN_DNS, astring);
uint8_t addr_type = {0};
std::string address = {};
fqdn::resolve(astring, address, nrf_port, addr_type);
if (addr_type != 0) { // IPv6
// TODO:
throw("DO NOT SUPPORT IPV6 ADDR FOR NRF!");
} else { // IPv4
IPV4_STR_ADDR_TO_INADDR(
util::trim(address).c_str(), nrf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR NRF !");
nrf_addr.ipv4_addr = nrf_ipv4_addr;
nrf_addr.port = nrf_port;
nrf_addr.api_version = "v1"; // TODO: to get API version from DNS
nrf_addr.fqdn = astring;
}
}
} catch (const SettingNotFoundException& nfex) {
Logger::ausf_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror;
}
}
return RETURNok; return RETURNok;
} }
...@@ -232,6 +292,15 @@ void ausf_config::display() { ...@@ -232,6 +292,15 @@ void ausf_config::display() {
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", udm_addr.api_version.c_str()); " API version ..........: %s", udm_addr.api_version.c_str());
Logger::config().info("- NRF:");
Logger::config().info(
" IPv4 Addr ............: %s",
inet_ntoa(*((struct in_addr*) &nrf_addr.ipv4_addr)));
Logger::config().info(" Port .................: %lu ", nrf_addr.port);
Logger::config().info(
" API version ..........: %s", nrf_addr.api_version.c_str());
if (use_fqdn_dns) if (use_fqdn_dns)
Logger::config().info( Logger::config().info(
" FQDN .................: %s", udm_addr.fqdn.c_str()); " FQDN .................: %s", udm_addr.fqdn.c_str());
......
...@@ -60,8 +60,13 @@ ...@@ -60,8 +60,13 @@
#define AUSF_CONFIG_STRING_UDM_IPV4_ADDRESS "IPV4_ADDRESS" #define AUSF_CONFIG_STRING_UDM_IPV4_ADDRESS "IPV4_ADDRESS"
#define AUSF_CONFIG_STRING_UDM_PORT "PORT" #define AUSF_CONFIG_STRING_UDM_PORT "PORT"
#define AUSF_CONFIG_STRING_NRF "NRF"
#define AUSF_CONFIG_STRING_NRF_IPV4_ADDRESS "IPV4_ADDRESS"
#define AUSF_CONFIG_STRING_NRF_PORT "PORT"
#define AUSF_CONFIG_STRING_SUPPORT_FEATURES "SUPPORT_FEATURES" #define AUSF_CONFIG_STRING_SUPPORT_FEATURES "SUPPORT_FEATURES"
#define AUSF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS "USE_FQDN_DNS" #define AUSF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS "USE_FQDN_DNS"
#define AUSF_CONFIG_STRING_SUPPORTED_FEATURES_REGISTER_NRF "REGISTER_NRF"
#define AUSF_CONFIG_STRING_FQDN_DNS "FQDN" #define AUSF_CONFIG_STRING_FQDN_DNS "FQDN"
using namespace libconfig; using namespace libconfig;
...@@ -98,6 +103,15 @@ class ausf_config { ...@@ -98,6 +103,15 @@ class ausf_config {
std::string fqdn; std::string fqdn;
} udm_addr; } udm_addr;
struct {
struct in_addr ipv4_addr;
unsigned int port;
std::string api_version;
std::string fqdn;
} nrf_addr;
bool register_nrf;
;
bool use_fqdn_dns; bool use_fqdn_dns;
}; };
......
/*
* 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_nrf.cpp
\brief
\author Jian Yang, Fengjiao He, Hongxin Wang, Tien-Thinh NGUYEN
\company Eurecom
\date 2020
\email:
*/
#include "ausf_nrf.hpp"
#include "ausf_app.hpp"
#include "ausf_profile.hpp"
#include "ausf_client.hpp"
#include <boost/uuid/random_generator.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <curl/curl.h>
#include <pistache/http.h>
#include <pistache/mime.h>
#include <nlohmann/json.hpp>
#include <stdexcept>
#include "logger.hpp"
#include "ausf.h"
using namespace config;
// using namespace ausf;
using namespace oai::ausf::app;
using json = nlohmann::json;
extern ausf_config ausf_cfg;
extern ausf_nrf* ausf_nrf_inst;
ausf_client* ausf_client_instance = nullptr;
//------------------------------------------------------------------------------
ausf_nrf::ausf_nrf() {}
//---------------------------------------------------------------------------------------------
void ausf_nrf::get_ausf_api_root(std::string& api_root) {
api_root = std::string(
inet_ntoa(*((struct in_addr*) &ausf_cfg.nrf_addr.ipv4_addr))) +
":" + std::to_string(ausf_cfg.nrf_addr.port) + NNRF_NFM_BASE +
ausf_cfg.nrf_addr.api_version;
}
//---------------------------------------------------------------------------------------------
void ausf_nrf::generate_ausf_profile(
ausf_profile& ausf_nf_profile, std::string& ausf_instance_id) {
// TODO: remove hardcoded values
ausf_nf_profile.set_nf_instance_id(ausf_instance_id);
ausf_nf_profile.set_nf_instance_name("OAI-AUSF");
ausf_nf_profile.set_nf_type("AUSF");
ausf_nf_profile.set_nf_status("REGISTERED");
ausf_nf_profile.set_nf_heartBeat_timer(50);
ausf_nf_profile.set_nf_priority(1);
ausf_nf_profile.set_nf_capacity(100);
// ausf_nf_profile.set_fqdn(ausf_cfg.fqdn);
ausf_nf_profile.add_nf_ipv4_addresses(ausf_cfg.sbi.addr4); // N4's Addr
// AUSF info (Hardcoded for now)
ausf_info_t ausf_info_item;
supi_range_ausf_info_item_t supi_ranges;
ausf_info_item.groupid = "oai-ausf-testgroupid";
ausf_info_item.routing_indicators.push_back("0210");
ausf_info_item.routing_indicators.push_back("9876");
supi_ranges.supi_range.start = "109238210938";
supi_ranges.supi_range.pattern = "209238210938";
supi_ranges.supi_range.start = "q0930j0c80283ncjf";
ausf_info_item.supi_ranges.push_back(supi_ranges);
ausf_nf_profile.set_ausf_info(ausf_info_item);
// AUSF info item end
ausf_nf_profile.display();
}
//---------------------------------------------------------------------------------------------
void ausf_nrf::register_to_nrf() {
// generate UUID
std::string ausf_instance_id; // AUSF instance id
ausf_instance_id = to_string(boost::uuids::random_generator()());
nlohmann::json response_data = {};
// Generate NF Profile
ausf_profile ausf_nf_profile;
generate_ausf_profile(ausf_nf_profile, ausf_instance_id);
// Send NF registeration request
std::string ausf_api_root = {};
std::string response = {};
std::string method = {"PUT"};
get_ausf_api_root(ausf_api_root);
std::string remoteUri =
ausf_api_root + AUSF_NF_REGISTER_URL + ausf_instance_id;
nlohmann::json json_data = {};
ausf_nf_profile.to_json(json_data);
Logger::ausf_nrf().info("Sending NF registeration request");
ausf_client_instance->curl_http_client(
remoteUri, method, json_data.dump().c_str(), response);
try {
response_data = nlohmann::json::parse(response);
if (response_data["nfStatus"].dump().c_str() == "REGISTERED") {
// ToDo Trigger NF heartbeats
}
} catch (nlohmann::json::exception& e) {
Logger::ausf_nrf().info("NF registeration procedure failed");
}
}
//---------------------------------------------------------------------------------------------
/*
* 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_client.hpp
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2020
\email:
*/
#ifndef FILE_AUSF_NRF_SEEN
#define FILE_AUSF_NRF_SEEN
#include <map>
#include <thread>
#include <curl/curl.h>
#include "logger.hpp"
#include "ausf_config.hpp"
#include "ausf_profile.hpp"
namespace oai {
namespace ausf {
namespace app {
class ausf_nrf {
private:
public:
ausf_profile ausf_nf_profile; // AUSF profile
std::string ausf_instance_id; // AUSF instance id
// timer_id_t timer_ausf_heartbeat;
ausf_nrf();
ausf_nrf(ausf_nrf const&) = delete;
void operator=(ausf_nrf const&) = delete;
void generate_uuid();
/*
* Generate a AUSF profile for this instance
* @param [void]
* @return void
*/
void generate_ausf_profile(
ausf_profile& ausf_nf_profile, std::string& ausf_instance_id);
/*
* Trigger NF instance registration to NRF
* @param [void]
* @return void
*/
void register_to_nrf();
/*
* Get ausf API Root
* @param [std::string& ] api_root: ausf's API Root
* @return void
*/
void get_ausf_api_root(std::string& api_root);
};
} // namespace app
} // namespace ausf
} // namespace oai
#endif /* FILE_AUSF_NRF_SEEN */
This diff is collapsed.
/*
* 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_profile.hpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2021
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#ifndef FILE_AUSF_PROFILE_HPP_SEEN
#define FILE_AUSF_PROFILE_HPP_SEEN
#include <arpa/inet.h>
#include <netinet/in.h>
#include <nlohmann/json.hpp>
#include <shared_mutex>
#include <vector>
#include "logger.hpp"
#include "3gpp_29.510.h"
#include "ausf.h"
namespace oai {
namespace ausf {
namespace app {
class ausf_profile : public std::enable_shared_from_this<ausf_profile> {
public:
ausf_profile()
: nf_type("NF_TYPE_UNKNOWN"),
heartBeat_timer(0),
snssais(),
fqdn(),
ipv4_addresses(),
priority(0),
capacity(0) {
nf_instance_name = {};
nf_status = {};
}
ausf_profile(const std::string& id)
: nf_instance_id(id),
heartBeat_timer(0),
snssais(),
fqdn(),
ipv4_addresses(),
priority(0),
capacity(0),
nf_type("NF_TYPE_UNKNOWN") {
nf_instance_name = {};
nf_status = {};
}
ausf_profile& operator=(const ausf_profile& s) {
nf_instance_id = s.nf_instance_id;
heartBeat_timer = s.heartBeat_timer;
snssais = s.snssais;
fqdn = s.fqdn;
ipv4_addresses = s.ipv4_addresses;
priority = s.priority;
capacity = s.capacity;
nf_type = s.nf_type;
nf_instance_name = s.nf_instance_name;
nf_status = s.nf_status;
ausf_info = s.ausf_info;
return *this;
}
// ausf_profile(ausf_profile &b) = delete;
virtual ~ausf_profile() {
// Logger::ausf_app().debug("Delete ausf Profile instance...");
}
/*
* Set NF instance ID
* @param [const std::string &] instance_id: instance id
* @return void
*/
void set_nf_instance_id(const std::string& instance_id);
/*
* Get NF instance ID
* @param [std::string &] instance_id: store instance id
* @return void:
*/
void get_nf_instance_id(std::string& instance_id) const;
/*
* Get NF instance ID
* @param [std::string &] instance_id: store instance id
* @return void:
*/
std::string get_nf_instance_id() const;
/*
* Set NF instance name
* @param [const std::string &] instance_name: instance name
* @return void
*/
void set_nf_instance_name(const std::string& instance_name);
/*
* Get NF instance ID
* @param [std::string &] instance_name: store instance name
* @return void:
*/
void get_nf_instance_name(std::string& instance_name) const;
/*
* Get NF instance name
* @param
* @return [std::string] instance name
*/
std::string get_nf_instance_name() const;
/*
* Set NF instance status
* @param [const std::string &] status: instance status
* @return void
*/
void set_nf_status(const std::string& status);
/*
* Get NF instance status
* @param [std::string &] status: store instance status
* @return void:
*/
void get_nf_status(std::string& status) const;
/*
* Get NF status
* @param
* @return [std::string] instance status
*/
std::string get_nf_status() const;
/*
* Get NF type
* @param
* @return [std::string] nf type
*/
std::string get_nf_type() const;
/*
* Set NF type
* @param [const nf_type_t &] type: nf type
* @return void
*/
void set_nf_type(const std::string& type);
/*
* Set NF instance heartBeat_timer
* @param [const std::string &] timer: heartBeat_timer
* @return void
*/
void set_nf_heartBeat_timer(const int32_t& timer);
/*
* Get NF instance heartBeat_timer
* @param [std::string &] timer: store heartBeat_timer
* @return void:
*/
void get_nf_heartBeat_timer(int32_t& timer) const;
/*
* Get NF heartBeat_timer
* @param void
* @return heartBeat_timer
*/
int32_t get_nf_heartBeat_timer() const;
/*
* Set NF instance priority
* @param [const uint16_t] p: instance priority
* @return void
*/
void set_nf_priority(const uint16_t& p);
/*
* Get NF instance priority
* @param [uint16_t] p: store instance priority
* @return void:
*/
void get_nf_priority(uint16_t& p) const;
/*
* Get NF instance priority
* @param void
* @return [uint16_t] instance priority
*/
uint16_t get_nf_priority() const;
/*
* Set NF instance capacity
* @param [const uint16_t] c: instance capacity
* @return void
*/
void set_nf_capacity(const uint16_t& c);
/*
* Get NF instance priority
* @param [uint16_t ] c: store instance capacity
* @return void:
*/
void get_nf_capacity(uint16_t& c) const;
/*
* Get NF instance priority
* @param void
* @return [uint16_t ] instance capacity
*/
uint16_t get_nf_capacity() const;
/*
* Set NF instance SNSSAIs
* @param [std::vector<snssai_t> &] s: SNSSAIs
* @return void
*/
void set_nf_snssais(const std::vector<snssai_t>& s);
/*
* Add SNSSAI
* @param [snssai_t &] s: SNSSAI
* @return void
*/
void add_snssai(const snssai_t& s);
/*
* Get NF instance SNSSAIs
* @param [std::vector<snssai_t> &] s: store instance's SNSSAIs
* @return void:
*/
void get_nf_snssais(std::vector<snssai_t>& s) const;
/*
* Get NF fqdn
* @param
* @return [std::string] nf fqdn
*/
std::string get_fqdn() const;
/*
* Set NF fqdn
* @param [const fqdn_t &] fqdn: nf fqdn
* @return void
*/
void set_fqdn(const std::string& fqdn);
/*
* Set NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: ipv4_addresses
* @return void
*/
void set_nf_ipv4_addresses(const std::vector<struct in_addr>& a);
/*
* Add an IPv4 address to the list of addresses
* @param [const struct in_addr &] a: ipv4_address
* @return void
*/
void add_nf_ipv4_addresses(const struct in_addr& a);
/*
* Get NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: store instance's ipv4_addresses
* @return void:
*/
void get_nf_ipv4_addresses(std::vector<struct in_addr>& a) const;
/*
* Set ausf info
* @param [ausf_info_t &] s: ausf info
* @return void
*/
void set_ausf_info(const ausf_info_t& s);
/*
* Get NF instance ausf info
* @param [ausf_info_t &] s: store instance's ausf info
* @return void:
*/
void get_ausf_info(ausf_info_t& s) const;
/*
* Print related-information for NF profile
* @param void
* @return void:
*/
void display() const;
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
void to_json(nlohmann::json& data) const;
/*
* Covert from a json represetation to ausf profile
* @param [nlohmann::json &] data: Json data
* @return void
*/
void from_json(const nlohmann::json& data);
/*
* Handle heartbeart timeout event
* @param [uint64_t] ms: current time
* @return void
*/
void handle_heartbeart_timeout(uint64_t ms);
protected:
// 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_name;
std::string nf_type;
std::string nf_status;
int32_t heartBeat_timer;
std::vector<snssai_t> snssais;
std::string fqdn;
std::vector<struct in_addr> ipv4_addresses;
uint16_t priority;
uint16_t capacity;
ausf_info_t ausf_info;
};
} // namespace app
} // namespace ausf
} // namespace oai
#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
*/
#ifndef FILE_3GPP_29_510_nssf_SEEN
#define FILE_3GPP_29_510_nssf_SEEN
#include <vector>
#include <nlohmann/json.hpp>
// Section 28.4, TS23.003
typedef struct s_nssai {
uint8_t sST;
std::string sD;
s_nssai(const uint8_t& sst, const std::string sd) : sST(sst), sD(sd) {}
s_nssai() : sST(), sD() {}
s_nssai(const s_nssai& p) : sST(p.sST), sD(p.sD) {}
bool operator==(const struct s_nssai& s) const {
if ((s.sST == this->sST) && (s.sD.compare(this->sD) == 0)) {
return true;
} else {
return false;
}
}
s_nssai& operator=(const s_nssai& s) {
sST = s.sST;
sD = s.sD;
return *this;
}
} snssai_t;
typedef struct dnai_s {
} dnai_t;
typedef struct patch_item_s {
std::string op;
std::string path;
// std::string from;
std::string value;
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data["op"] = op;
json_data["path"] = path;
json_data["value"] = value;
return json_data;
}
} patch_item_t;
#define AUSF_CURL_TIMEOUT_MS 100L
#define NNRF_NFM_BASE "/nnrf-nfm/"
#define AUSF_NF_REGISTER_URL "/nf-instances/"
#endif
\ No newline at end of file
...@@ -108,4 +108,20 @@ enum http_response_codes_e { ...@@ -108,4 +108,20 @@ enum http_response_codes_e {
HTTP_RESPONSE_CODE_GATEWAY_TIMEOUT = 504 HTTP_RESPONSE_CODE_GATEWAY_TIMEOUT = 504
}; };
typedef struct supi_range_s {
std::string start;
std::string end;
std::string pattern;
} supi_range_t;
typedef struct supi_range_ausf_info_item_s {
supi_range_t supi_range;
} supi_range_ausf_info_item_t;
typedef struct ausf_info_s {
std::string groupid;
std::vector<supi_range_ausf_info_item_t> supi_ranges;
std::vector<std::string> routing_indicators;
} ausf_info_t;
#endif #endif
...@@ -69,6 +69,7 @@ void Logger::_init( ...@@ -69,6 +69,7 @@ void Logger::_init(
m_config = new _Logger("configurations", m_sinks, ss.str().c_str()); m_config = new _Logger("configurations", m_sinks, ss.str().c_str());
m_system = new _Logger("system", m_sinks, ss.str().c_str()); m_system = new _Logger("system", m_sinks, ss.str().c_str());
m_ausf_app = new _Logger("ausf_app", m_sinks, ss.str().c_str()); m_ausf_app = new _Logger("ausf_app", m_sinks, ss.str().c_str());
m_ausf_nrf = new _Logger("ausf_nrf", m_sinks, ss.str().c_str());
m_ausf_server = new _Logger("ausf_server", m_sinks, ss.str().c_str()); m_ausf_server = new _Logger("ausf_server", m_sinks, ss.str().c_str());
} }
......
...@@ -86,6 +86,7 @@ class Logger { ...@@ -86,6 +86,7 @@ class Logger {
static _Logger& config() { return *singleton().m_config; } static _Logger& config() { return *singleton().m_config; }
static _Logger& system() { return *singleton().m_system; } static _Logger& system() { return *singleton().m_system; }
static _Logger& ausf_app() { return *singleton().m_ausf_app; } static _Logger& ausf_app() { return *singleton().m_ausf_app; }
static _Logger& ausf_nrf() { return *singleton().m_ausf_nrf; }
static _Logger& ausf_server() { return *singleton().m_ausf_server; } static _Logger& ausf_server() { return *singleton().m_ausf_server; }
private: private:
...@@ -107,6 +108,7 @@ class Logger { ...@@ -107,6 +108,7 @@ class Logger {
_Logger* m_config; _Logger* m_config;
_Logger* m_system; _Logger* m_system;
_Logger* m_ausf_app; _Logger* m_ausf_app;
_Logger* m_ausf_nrf;
_Logger* m_ausf_server; _Logger* m_ausf_server;
}; };
......
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