Commit 5fc4a166 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

add nrf_profile

parent 1570e879
/*
* 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 3gpp_23.003.h
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_3GPP_23_003_SEEN
#define FILE_3GPP_23_003_SEEN
#include <stdint.h>
typedef struct plmn_s {
uint8_t mcc_digit2 :4;
uint8_t mcc_digit1 :4;
uint8_t mcc_digit3 :4;
uint8_t mnc_digit3 :4;
uint8_t mnc_digit2 :4;
uint8_t mnc_digit1 :4;
} plmn_t;
#define INVALID_TAC_0000 (uint16_t)0x0000
#define INVALID_TAC_FFFE (uint16_t)0xFFFE
#define INVALID_TAC (uint32_t)0x00000000
#define INVALID_TMSI UINT32_MAX /*!< \brief The network shall not allocate a TMSI with all 32 bits equal to 1
(this is because the TMSI must be stored in the SIM, and the SIM uses 4 octets with all bits
equal to 1 to indicate that no valid TMSI is available). */
typedef uint16_t tac_t;
typedef struct tai_s {
plmn_t plmn; /*!< \brief <MCC> + <MNC> */
tac_t tac; /*!< \brief Tracking Area Code */
} tai_t;
typedef struct eci_s {
uint32_t gnb_id :20;
uint32_t cell_id :8;
uint32_t empty :4;
} ci_t;
typedef struct cgi_s {
plmn_t plmn;
ci_t cell_identity; //28 bits
} cgi_t;
typedef struct nr_tai_s /*5G ADD it*/
{
plmn_t plmn;
uint32_t tac :24;
} nr_tai_t;
typedef struct nr_cell_identity_s /*5G ADD it */
{
uint32_t gnb_id;
uint8_t cell_id :4;
} nr_cell_identity_t;
typedef struct nr_cgi_s /*5G ADD it */
{
plmn_t plmn;
nr_cell_identity_t cell_identity;
} nr_cgi_t;
typedef struct fiveG_s_tmsi_s /*5G ADD it */
{
uint16_t amf_set_id :10;
uint8_t amf_pointer :6;
uint32_t fiveG_s_tmsi; //32
} fiveG_s_tmsi_t;
typedef struct fiveG_s_gua_s /*5G ADD it */
{
plmn_t plmn;
uint8_t region_id;
uint16_t amf_set_id :10;
uint8_t amf_pointer :6;
} fiveG_s_gua_t;
typedef struct amf_set_id_s /*5G ADD it*/
{
uint16_t amf_set_id :10;
} amf_set_id_t;
typedef struct allowed_nssai /*5G ADD it*/
{
uint8_t sST;
uint32_t sD :24;
} allowed_nssai;
typedef struct allowed_nssai_s /*5G ADD it*/
{
allowed_nssai *s_nssai;
uint32_t count;
} allowed_nssai_t;
#endif
...@@ -21,7 +21,78 @@ ...@@ -21,7 +21,78 @@
#ifndef FILE_NRF_SEEN #ifndef FILE_NRF_SEEN
#define FILE_NRF_SEEN #define FILE_NRF_SEEN
#include "3gpp_23.003.h"
#define HEART_BEAT_TIMER 10 #define HEART_BEAT_TIMER 10
typedef enum nf_type_s {
NF_TYPE_NRF = 0,
NF_TYPE_AMF = 1,
NF_TYPE_SMF = 2,
NF_TYPE_AUSF = 3,
NF_TYPE_NEF = 4,
NF_TYPE_PCF = 5,
NF_TYPE_SMSF = 6,
NF_TYPE_NSSF = 7,
NF_TYPE_UDR = 8,
NF_TYPE_LMF = 9,
NF_TYPE_GMLC = 10,
NF_TYPE_5G_EIR = 11,
NF_TYPE_SEPP = 12,
NF_TYPE_UPF = 13,
NF_TYPE_N3IWF = 14,
NF_TYPE_AF = 15,
NF_TYPE_UDSF = 16,
NF_TYPE_BSF = 17,
NF_TYPE_CHF = 18,
NF_TYPE_NWDAF = 19,
NF_TYPE_UNKNOWN = 20
} nf_type_t;
typedef struct s_nssai // section 28.4, TS23.003
{
uint8_t sST;
//uint32_t sD:24;
std::string sD;
//s_nssai(const uint8_t& sst, const uint32_t sd) : sST(sst), sD(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 guami_s {
plmn_t plmn;
std::string amf_id;
} guami_t;
typedef struct amf_info_s {
std::string amf_set_id;
std::string amf_region_id;
std::vector<guami_t> guami_list;
} amf_info_t;
#endif #endif
...@@ -43,19 +43,57 @@ nrf_app::nrf_app(const std::string &config_file) { ...@@ -43,19 +43,57 @@ nrf_app::nrf_app(const std::string &config_file) {
Logger::nrf_app().startup("Started"); Logger::nrf_app().startup("Started");
} }
//------------------------------------------------------------------------------
void nrf_app::handle_nf_instance_registration_request( void nrf_app::handle_nf_instance_registration_request(
const std::string &nfInstanceID, const std::string &nf_instance_id, oai::nrf::model::NFProfile &nf_profile,
oai::nrf::model::NFProfile &nf_profile, int &http_code, const uint8_t http_version) {
int &http_code,
const uint8_t http_version) {
Logger::nrf_app().info( Logger::nrf_app().info(
"Handle a NF Instance Registration Request (HTTP version %d)", "Handle a NF Instance Registration Request (HTTP version %d)",
http_version); http_version);
//Check if nfInstanceID is a valid UUID (version 4) //Check if nfInstanceID is a valid UUID (version 4)
//TODO //TODO
//Create NF and store //Create NF and store
std::shared_ptr<amf_profile> sa = { };
if (find_nf_profile(nf_instance_id, sa)) {
//if a profile exist with this ID, return error
} else {
//create
Logger::nrf_app().debug("Create a new NF Profile with ID %s",
nf_instance_id);
sa = std::shared_ptr < amf_profile > (new amf_profile(nf_instance_id));
//sa.get()->
add_nf_profile(nf_instance_id, sa);
}
//location header - URI of created resource: can be used with ID - UUID //location header - URI of created resource: can be used with ID - UUID
} }
//------------------------------------------------------------------------------
bool nrf_app::add_nf_profile(const std::string &profile_id,
const std::shared_ptr<nrf_profile> &p) {
return true;
}
//------------------------------------------------------------------------------
bool nrf_app::find_nf_profile(const std::string &profile_id,
const std::shared_ptr<nrf_profile> &snp) {
//TODO
return true;
}
//------------------------------------------------------------------------------
bool nrf_app::remove_nf_profile(std::shared_ptr<nrf_profile> &snp) {
//TODO
return true;
}
//------------------------------------------------------------------------------
bool nrf_app::remove_nf_profile(std::string &profile_id) {
//TODO
return true;
}
...@@ -45,11 +45,43 @@ class nrf_app { ...@@ -45,11 +45,43 @@ class nrf_app {
void operator=(nrf_app const&) = delete; void operator=(nrf_app const&) = delete;
void handle_nf_instance_registration_request( void handle_nf_instance_registration_request(
const std::string &nfInstanceID, const std::string &nf_instance_id,
oai::nrf::model::NFProfile &nf_profile, oai::nrf::model::NFProfile &nf_profile,
int &http_code, int &http_code,
const uint8_t http_version); const uint8_t http_version);
/*
* Insert a nrf profile
* @param [const std::string &] profile_id: Profile ID
* @param [std::shared_ptr<nrf_profile> &] p: profile to be added
* @return true if successful, otherwise, return false
*/
bool add_nf_profile(const std::string &profile_id, const std::shared_ptr<nrf_profile> &p);
/*
* Find a nf profile with its ID
* @param [const std::string &] profile_id: Profile ID
* @param [std::shared_ptr<nrf_profile> &] snp: Stored nf profile if found
* @return void
*/
bool find_nf_profile(const std::string &profile_id,
const std::shared_ptr<nrf_profile> &snp);
/*
* Remove a nf profile from the list
* @param [std::shared_ptr<nrf_profile> &] snp: profile to be removed
* @return true if successful, otherwise, return false
*/
bool remove_nf_profile(std::shared_ptr<nrf_profile> &snp);
/*
* Remove a nf profile from the list
* @param [std::string &] profile_id: ID of the profile to be removed
* @return true if successful, otherwise, return false
*/
bool remove_nf_profile(std::string &profile_id);
private: private:
std::map<std::string, std::shared_ptr<nrf_profile>> instance_id2nrf_profile; std::map<std::string, std::shared_ptr<nrf_profile>> instance_id2nrf_profile;
mutable std::shared_mutex m_instance_id2nrf_profile; mutable std::shared_mutex m_instance_id2nrf_profile;
......
...@@ -29,10 +29,27 @@ ...@@ -29,10 +29,27 @@
#include "nrf_profile.hpp" #include "nrf_profile.hpp"
using namespace std; using namespace std;
using namespace oai::nrf; using namespace oai::nrf;
//------------------------------------------------------------------------------
void nrf_profile::set_nf_instance_id(const std::string &instance_id) {
nf_instance_id = instance_id;
}
//------------------------------------------------------------------------------
void nrf_profile::get_nf_instance_id(std::string &instance_id) const {
instance_id = nf_instance_id;
}
//------------------------------------------------------------------------------
void nrf_profile::set_nf_instance_name(const std::string &instance_name) {
nf_instance_name = instance_name;
}
//------------------------------------------------------------------------------
void nrf_profile::get_nf_instance_name(std::string &instance_name) const {
instance_name = nf_instance_name;
}
...@@ -30,38 +30,92 @@ ...@@ -30,38 +30,92 @@
#ifndef FILE_NRF_PROFILE_HPP_SEEN #ifndef FILE_NRF_PROFILE_HPP_SEEN
#define FILE_NRF_PROFILE_HPP_SEEN #define FILE_NRF_PROFILE_HPP_SEEN
#include <arpa/inet.h>
#include <netinet/in.h>
#include <map> #include <map>
//#include <mutex>
#include <shared_mutex> #include <shared_mutex>
#include <memory> #include <memory>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "nrf.h"
namespace oai { namespace oai {
namespace nrf{ namespace nrf {
using namespace std;
class nrf_profile : public std::enable_shared_from_this<nrf_profile> { class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
public: public:
nrf_profile() nrf_profile() = delete;
{ nrf_profile(const nf_type_t type)
:
heartBeat_timer(0),
snssais(),
ipv4_addresses(),
priority(0),
capacity(0) {
nf_type = type;
nf_instance_name = "";
nf_status = "";
}
nrf_profile(const std::string &id)
:
nf_instance_id(id),
heartBeat_timer(0),
snssais(),
ipv4_addresses(),
priority(0),
capacity(0) {
nf_instance_name = "";
nf_status = "";
nf_type = NF_TYPE_UNKNOWN;
} }
nrf_profile(nrf_profile &b) = delete; nrf_profile(nrf_profile &b) = delete;
private: /*
//lock * Set NF instance ID
mutable std::shared_mutex m_nrf_profile; * @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: instance id
* @return void:
*/
void get_nf_instance_id(std::string &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: instance name
* @return void:
*/
void get_nf_instance_name(std::string &instance_name) const;
private:
//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;
std::string nf_type; nf_type_t nf_type;
std::string nf_status; 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;
/*
/*
std::vector<PlmnId> m_PlmnList; std::vector<PlmnId> m_PlmnList;
bool m_PlmnListIsSet; bool m_PlmnListIsSet;
std::vector<Snssai> m_SNssais; std::vector<Snssai> m_SNssais;
...@@ -72,18 +126,12 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -72,18 +126,12 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
bool m_NsiListIsSet; bool m_NsiListIsSet;
std::string m_Fqdn; std::string m_Fqdn;
bool m_FqdnIsSet; bool m_FqdnIsSet;
std::vector<std::string> m_Ipv4Addresses;
bool m_Ipv4AddressesIsSet;
std::vector<Ipv6Addr> m_Ipv6Addresses; std::vector<Ipv6Addr> m_Ipv6Addresses;
bool m_Ipv6AddressesIsSet; bool m_Ipv6AddressesIsSet;
int32_t m_Capacity;
bool m_CapacityIsSet;
int32_t m_Load; int32_t m_Load;
bool m_LoadIsSet; bool m_LoadIsSet;
std::string m_Locality; std::string m_Locality;
bool m_LocalityIsSet; bool m_LocalityIsSet;
int32_t m_Priority;
bool m_PriorityIsSet;
UdrInfo m_UdrInfo; UdrInfo m_UdrInfo;
bool m_UdrInfoIsSet; bool m_UdrInfoIsSet;
std::vector<UdrInfo> m_UdrInfoExt; std::vector<UdrInfo> m_UdrInfoExt;
...@@ -130,9 +178,31 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> { ...@@ -130,9 +178,31 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
bool m_NfServicesIsSet; bool m_NfServicesIsSet;
std::vector<DefaultNotificationSubscription> m_DefaultNotificationSubscriptions; std::vector<DefaultNotificationSubscription> m_DefaultNotificationSubscriptions;
bool m_DefaultNotificationSubscriptionsIsSet; bool m_DefaultNotificationSubscriptionsIsSet;
*/ */
};
class amf_profile : public nrf_profile {
public:
amf_profile()
:
nrf_profile(NF_TYPE_AMF) {
amf_info = { };
}
amf_profile(const std::string &id)
:
nrf_profile(id) {
amf_info = { };
}
amf_profile(amf_profile &b) = delete;
private:
std::vector<amf_info_t> amf_info;
}; };
} }
} }
......
{ {
"_comment" : "NRF Profile", "_comment" : "NRF Profile (6.1.6.2.2, 3GPP TS 29.510 V16.0.0 (2019-06)Type: NFProfile)",
"nfInstanceId" : "343a924e-6494-4927-860b-d45692c95c2d", "nfInstanceId" : "343a924e-6494-4927-860b-d45692c95c2d",
"nfType" : "AMF", "nfType" : "AMF",
"nfStatus" : "REGISTERED", "nfStatus" : "REGISTERED",
"nfInstanceName": "OAI-AMF",
"heartBeatTimer": 10, "heartBeatTimer": 10,
"sNssais": [
{ "sst": 100,
"sd": "a0a0a0"
}
],
"ipv4Addresses": [
"10.10.10.1", "10.10.10.2"
] ,
"priority": 1,
"capacity": 100,
"amfInfo": "amfInfo":
{ {
"amfSetId" : "1a1a", "amfSetId" : "1a1a",
......
curl -X PUT -H "Content-Type: application/json" -d @registration.json http://192.168.1.88/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d curl -X PUT -H "Content-Type: application/json" -d @amf_registration.json http://192.168.1.88/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d
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