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

Code cleanup

parent 560b64e8
/*
* 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_ */
......@@ -272,8 +272,8 @@ void spgwu_nrf::generate_upf_profile() {
generate_uuid();
// TODO: get hardcoded values from configuration file
upf_profile.set_nf_instance_id(upf_instance_id);
upf_profile.set_nf_instance_name("OAI-SMF");
upf_profile.set_nf_type("SMF");
upf_profile.set_nf_instance_name("OAI-UPF");
upf_profile.set_nf_type("UPF");
upf_profile.set_nf_status("REGISTERED");
upf_profile.set_nf_heartBeat_timer(50);
upf_profile.set_nf_priority(1);
......
......@@ -35,7 +35,6 @@
#include "itti.hpp"
#include <curl/curl.h>
#include "3gpp_29.510.h"
#include "itti_msg_nrf.hpp"
#include "spgwu_profile.hpp"
namespace spgwu {
......
......@@ -250,19 +250,19 @@ void spgwu_profile::to_json(nlohmann::json& data) const {
data["capacity"] = capacity;
// UPF info
data["smfInfo"] = {};
data["smfInfo"]["sNssaiSmfInfoList"] = nlohmann::json::array();
data["upfInfo"] = {};
data["upfInfo"]["sNssaiUpfInfoList"] = nlohmann::json::array();
for (auto s : upf_info.snssai_upf_info_list) {
nlohmann::json tmp = {};
tmp["sNssai"]["sst"] = s.snssai.sST;
tmp["sNssai"]["sd"] = s.snssai.sD;
tmp["dnnSmfInfoList"] = nlohmann::json::array();
tmp["dnnUpfInfoList"] = nlohmann::json::array();
for (auto d : s.dnn_upf_info_list) {
nlohmann::json dnn_json = {};
dnn_json["dnn"] = d.dnn;
tmp["dnnSmfInfoList"].push_back(dnn_json);
tmp["dnnUpfInfoList"].push_back(dnn_json);
}
data["smfInfo"]["sNssaiSmfInfoList"].push_back(tmp);
data["upfInfo"]["sNssaiUpfInfoList"].push_back(tmp);
}
Logger::spgwu_app().debug("UPF profile to json:\n %s", data.dump().c_str());
......@@ -328,14 +328,14 @@ void spgwu_profile::from_json(const nlohmann::json& data) {
}
// UPF info
if (data.find("smfInfo") != data.end()) {
nlohmann::json info = data["smfInfo"];
if (data.find("upfInfo") != data.end()) {
nlohmann::json info = data["upfInfo"];
dnn_upf_info_item_t dnn_item = {};
if (info.find("sNssaiSmfInfoList") != info.end()) {
if (info.find("sNssaiUpfInfoList") != info.end()) {
nlohmann::json snssai_upf_info_list =
data["smfInfo"]["sNssaiSmfInfoList"];
data["upfInfo"]["sNssaiUpfInfoList"];
for (auto it : snssai_upf_info_list) {
snssai_upf_info_item_t upf_info_item = {};
......@@ -345,8 +345,8 @@ void spgwu_profile::from_json(const nlohmann::json& data) {
if (it["sNssai"].find("sd") != it["sNssai"].end())
upf_info_item.snssai.sD = it["sNssai"]["sd"].get<std::string>();
}
if (it.find("dnnSmfInfoList") != it.end()) {
for (auto d : it["dnnSmfInfoList"]) {
if (it.find("dnnUpfInfoList") != it.end()) {
for (auto d : it["dnnUpfInfoList"]) {
if (d.find("dnn") != d.end()) {
dnn_item.dnn = d["dnn"].get<std::string>();
upf_info_item.dnn_upf_info_list.push_back(dnn_item);
......
......@@ -279,14 +279,14 @@ class spgwu_profile : public std::enable_shared_from_this<spgwu_profile> {
/*
* Add an snssai_upf_info_item to the upf info
* @param [const snssai_upf_info_item_t &] s: snssai_smf_info_item
* @param [const snssai_upf_info_item_t &] s: snssai_upf_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
* Get NF instance upf info
* @param [upf_info_t &] s: store instance's upf info
* @return void:
*/
void get_upf_info(upf_info_t& s) const;
......@@ -306,7 +306,7 @@ class spgwu_profile : public std::enable_shared_from_this<spgwu_profile> {
void to_json(nlohmann::json& data) const;
/*
* Covert from a json represetation to SMF profile
* Covert from a json represetation to UPF profile
* @param [nlohmann::json &] data: Json data
* @return void
*/
......
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