Commit ed7b3bb2 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Add Spgwu profile, nrf

parent a7dc32fa
/*
* 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_NRF_SEEN
#define FILE_3GPP_29_510_NRF_SEEN
#include <vector>
typedef struct s_nssai // section 28.4, TS23.003
{
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;
}
}
} snssai_t;
typedef struct dnai_s {
} dnai_t;
typedef struct dnn_upf_info_item_s {
std::string dnn;
// std::vector<std::string> dnai_list
// std::vector<std::string> pdu_session_types
} dnn_upf_info_item_t;
typedef struct snssai_upf_info_item_s {
snssai_t snssai;
std::vector<dnn_upf_info_item_t> dnn_upf_info_list;
} snssai_upf_info_item_t;
typedef struct upf_info_s {
std::vector<snssai_upf_info_item_t> snssai_upf_info_list;
} upf_info_t;
#define NRF_CURL_TIMEOUT_MS 100L
#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
*/
/*
* itti_msg_nrf.hpp
*
* Created on:
* Author:
*/
#ifndef ITTI_MSG_NRF_HPP_INCLUDED_
#define ITTI_MSG_NRF_HPP_INCLUDED_
#include "itti_msg.hpp"
#include "spgwu_profile.hpp"
//#include "PatchItem.h"
class itti_nrf_msg : public itti_msg {
public:
itti_nrf_msg(const itti_msg_type_t msg_type, const task_id_t orig,
const task_id_t dest)
:
itti_msg(msg_type, orig, dest) {
}
itti_nrf_msg(const itti_nrf_msg &i)
:
itti_msg(i) {
}
itti_nrf_msg(const itti_nrf_msg &i, const task_id_t orig,
const task_id_t dest)
:
itti_nrf_msg(i) {
origin = orig;
destination = dest;
}
};
//-----------------------------------------------------------------------------
class itti_nrf_register_nf_instance_request : public itti_nrf_msg {
public:
itti_nrf_register_nf_instance_request(const task_id_t orig,
const task_id_t dest)
: itti_nrf_msg(NRF_REGISTER_NF_INSTANCE_REQUEST, orig, dest),
http_version(1) {}
const char *get_msg_name() { return "NRF_REGISTER_NF_INSTANCE_REQUEST"; };
spgwu::spgwu_profile profile;
uint8_t http_version;
};
//-----------------------------------------------------------------------------
class itti_nrf_register_nf_instance_response : public itti_nrf_msg {
public:
itti_nrf_register_nf_instance_response(const task_id_t orig,
const task_id_t dest)
: itti_nrf_msg(NRF_REGISTER_NF_INSTANCE_RESPONSE, orig, dest),
http_version(1) {}
const char *get_msg_name() { return "NRF_REGISTER_NF_INSTANCE_RESPONSE"; };
spgwu::spgwu_profile profile;
uint8_t http_version;
uint8_t http_response_code;
};
//-----------------------------------------------------------------------------
class itti_nrf_update_nf_instance_request : public itti_nrf_msg {
public:
itti_nrf_update_nf_instance_request(const task_id_t orig,
const task_id_t dest)
: itti_nrf_msg(NRF_UPDATE_NF_INSTANCE_REQUEST, orig, dest),
http_version(1) {}
const char *get_msg_name() { return "NRF_UPDATE_NF_INSTANCE_REQUEST"; };
//std::vector<oai::smf_server::model::PatchItem> patch_items;
uint8_t http_version;
std::string upf_instance_id;
};
//-----------------------------------------------------------------------------
class itti_nrf_update_nf_instance_response : public itti_nrf_msg {
public:
itti_nrf_update_nf_instance_response(const task_id_t orig,
const task_id_t dest)
: itti_nrf_msg(NRF_UPDATE_NF_INSTANCE_RESPONSE, orig, dest),
http_version(1) {}
const char *get_msg_name() { return "NRF_UPDATE_NF_INSTANCE_RESPONSE"; };
uint8_t http_version;
std::string upf_instance_id;
uint8_t http_response_code;
};
//-----------------------------------------------------------------------------
class itti_nrf_deregister_nf_instance : public itti_nrf_msg {
public:
itti_nrf_deregister_nf_instance(const task_id_t orig,
const task_id_t dest)
: itti_nrf_msg(NRF_DEREGISTER_NF_INSTANCE, orig, dest),
http_version(1) {}
const char *get_msg_name() { return "NRF_DEREGISTER_NF_INSTANCE"; };
uint8_t http_version;
std::string upf_instance_id;
};
#endif /* ITTI_MSG_NRF_HPP_INCLUDED_ */
......@@ -53,6 +53,7 @@ typedef enum {
TASK_SPGWU_SX,
TASK_SPGWU_S1U,
TASK_SGW_UDP,
TASK_SPGWU_NRF,
TASK_MAX,
TASK_NONE,
TASK_ALL = 255
......@@ -137,6 +138,11 @@ typedef enum {
UDP_INIT,
UDP_DATA_REQ,
UDP_DATA_IND,
NRF_REGISTER_NF_INSTANCE_REQUEST,
NRF_REGISTER_NF_INSTANCE_RESPONSE,
NRF_UPDATE_NF_INSTANCE_REQUEST,
NRF_UPDATE_NF_INSTANCE_RESPONSE,
NRF_DEREGISTER_NF_INSTANCE,
TIME_OUT,
HEALTH_PING,
TERMINATE,
......
......@@ -300,5 +300,5 @@ ENDIF(STATIC_LINKING)
# folly glog dl double-conversion for FB folly library
target_link_libraries (spgwu ${ASAN} -Wl,--start-group CN_UTILS SPGWU SPGW_SWITCH UDP GTPV1U PFCP 3GPP_COMMON_TYPES gflags glog dl double-conversion folly -Wl,--end-group
pthread m rt config++ event boost_system)
pthread m rt config++ event boost_system pistache curl)
......@@ -37,6 +37,8 @@ add_library (SPGWU STATIC
spgwu_app.cpp
spgwu_config.cpp
spgwu_sx.cpp
spgwu_profile.cpp
spgwu_nrf.cpp
)
......@@ -33,6 +33,7 @@
#include "spgwu_config.hpp"
#include "spgwu_s1u.hpp"
#include "spgwu_sx.hpp"
#include "spgwu_nrf.hpp"
#include <stdexcept>
......@@ -44,6 +45,7 @@ using namespace std;
spgwu_sx* spgwu_sx_inst = nullptr;
spgwu_s1u* spgwu_s1u_inst = nullptr;
spgwu_nrf* spgwu_nrf_inst = nullptr;
extern itti_mw* itti_inst;
extern pfcp_switch* pfcp_switch_inst;
......@@ -157,6 +159,12 @@ spgwu_app::spgwu_app(const std::string& config_file) {
Logger::spgwu_app().error("Cannot create PFCP_SWITCH: %s", e.what());
throw;
}
try {
spgwu_nrf_inst = new spgwu_nrf();
} catch (std::exception& e) {
Logger::spgwu_app().error("Cannot create SPGWU_NRF: %s", e.what());
throw;
}
Logger::spgwu_app().startup("Started");
}
......
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 spgwu_nrf.hpp
\author Lionel GAUTHIER, Tien-Thinh NGUYEN
\company Eurecom
\date 2021
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/
#ifndef FILE_SPGWU_NRF_HPP_SEEN
#define FILE_SPGWU_NRF_HPP_SEEN
#include <map>
#include <thread>
#include <curl/curl.h>
#include "3gpp_29.510.h"
#include "itti_msg_nrf.hpp"
namespace spgwu {
#define TASK_SPGWU_NRF_TIMEOUT_NRF_HEARTBEAT_REQUEST 1
class spgwu_nrf {
private:
std::thread::id thread_id;
std::thread thread;
public:
spgwu_nrf();
spgwu_nrf(spgwu_nrf const &) = delete;
void operator=(spgwu_nrf const &) = delete;
/*
* Send NF instance registration to NRF
* @param [std::shared_ptr<itti_nrf_register_nf_instance_request>] msg:
* Content of message to be sent
* @return void
*/
void register_nf_instance(
std::shared_ptr<itti_nrf_register_nf_instance_request> msg);
/*
* Send NF instance update to NRF
* @param [std::shared_ptr<itti_nrf_update_nf_instance_request>] msg: Content
* of message to be sent
* @return void
*/
void update_nf_instance(
std::shared_ptr<itti_nrf_update_nf_instance_request> msg);
/*
* Send NF deregister to NRF
* @param [std::shared_ptr<itti_nrf_deregister_nf_instance>] msg: Content
* of message to be sent
* @return void
*/
void deregister_nf_instance(
std::shared_ptr<itti_nrf_deregister_nf_instance> msg);
};
} // namespace smf
#endif /* FILE_SPGWU_NRF_HPP_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 spgwu_profile.hpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2021
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#ifndef FILE_UPF_PROFILE_HPP_SEEN
#define FILE_UPF_PROFILE_HPP_SEEN
#include <arpa/inet.h>
#include <netinet/in.h>
#include <map>
#include <memory>
#include <nlohmann/json.hpp>
#include <shared_mutex>
#include <utility>
#include <vector>
#include "logger.hpp"
#include "3gpp_29.510.h"
namespace spgwu {
//using namespace std;
class spgwu_profile : public std::enable_shared_from_this<spgwu_profile> {
public:
spgwu_profile()
: nf_type("NF_TYPE_UNKNOWN"),
heartBeat_timer(0),
snssais(),
ipv4_addresses(),
priority(0),
capacity(0) {
nf_instance_name = "";
nf_status = "";
}
spgwu_profile(const std::string &id)
: nf_instance_id(id),
heartBeat_timer(0),
snssais(),
ipv4_addresses(),
priority(0),
capacity(0),
nf_type("NF_TYPE_UNKNOWN") {
nf_instance_name = "";
nf_status = "";
}
spgwu_profile &operator=(const spgwu_profile &s) {
nf_instance_id = s.nf_instance_id;
heartBeat_timer = s.heartBeat_timer;
snssais = s.snssais;
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;
upf_info = s.upf_info;
}
// spgwu_profile(spgwu_profile &b) = delete;
virtual ~spgwu_profile() {
Logger::spgwu_app().debug("Delete UPF 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;
/*
* 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 upf info
* @param [upf_info_t &] s: upf info
* @return void
*/
void set_upf_info(const upf_info_t &s);
/*
* Add an snssai_upf_info_item to the upf info
* @param [const snssai_upf_info_item_t &] s: snssai_smf_info_item
* @return void
*/
void add_upf_info_item(const snssai_upf_info_item_t &s);
/*
* Get NF instance smf info
* @param [smf_info_t &] s: store instance's smf info
* @return void:
*/
void get_upf_info(upf_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 SMF 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::vector<struct in_addr> ipv4_addresses;
uint16_t priority;
uint16_t capacity;
upf_info_t upf_info;
};
} // namespace spgwu
#endif
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