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

Merge branch 'fix_mcc_mnc_00_udr' into 'develop'

Fix mcc mnc 00 udr

See merge request oai/cn5g/oai-cn5g-smf!162
parents 0396b32b 3febe21b
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#ifdef __cplusplus #ifdef __cplusplus
#include <nlohmann/json.hpp>
extern "C" { extern "C" {
#endif #endif
...@@ -338,10 +339,16 @@ typedef struct pdu_session_type_s { ...@@ -338,10 +339,16 @@ typedef struct pdu_session_type_s {
return (p == pdu_session_type); return (p == pdu_session_type);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
const std::string& toString() const { const std::string& to_string() const {
return pdu_session_type_e2str.at(pdu_session_type); return pdu_session_type_e2str.at(pdu_session_type);
} }
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data = to_string();
return json_data;
}
} pdu_session_type_t; } pdu_session_type_t;
//------------------------------------- //-------------------------------------
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "smf.h" #include "smf.h"
#include "3gpp_29.571.h" #include "3gpp_29.571.h"
#include <nlohmann/json.hpp>
enum ssc_mode_e { enum ssc_mode_e {
SSC_MODE_1 = 1, SSC_MODE_1 = 1,
...@@ -31,7 +32,7 @@ enum ssc_mode_e { ...@@ -31,7 +32,7 @@ enum ssc_mode_e {
SSC_MODE_3 = 3, SSC_MODE_3 = 3,
}; };
static const std::vector<std::string> ssc_mode_e2str = { static const std::vector<std::string> ssc_mode_e2str = {
"Error", "SSC_MODE_1", "SSC_MODE_2", "SSC_MODE_3"}; "SSC_MODE_ERROR", "SSC_MODE_1", "SSC_MODE_2", "SSC_MODE_3"};
typedef struct ssc_mode_s { typedef struct ssc_mode_s {
uint8_t ssc_mode; uint8_t ssc_mode;
...@@ -58,16 +59,48 @@ typedef struct ssc_mode_s { ...@@ -58,16 +59,48 @@ typedef struct ssc_mode_s {
virtual ~ssc_mode_s(){}; virtual ~ssc_mode_s(){};
const std::string& to_string() const { return ssc_mode_e2str.at(ssc_mode); }
nlohmann::json to_json() const {
nlohmann::json json_data = to_string();
return json_data;
}
} ssc_mode_t; } ssc_mode_t;
typedef struct pdu_session_types_s { typedef struct pdu_session_types_s {
pdu_session_type_t default_session_type; pdu_session_type_t default_session_type;
std::vector<pdu_session_type_t> allowed_session_types; std::vector<pdu_session_type_t> allowed_session_types;
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data["pdu_session_types"] = default_session_type.to_string();
if (allowed_session_types.size() > 0) {
json_data["allowed_session_types"] = nlohmann::json::array();
}
for (const auto& a : allowed_session_types) {
nlohmann::json json_item = a.to_string();
json_data["allowed_session_types"].push_back(json_item);
}
return json_data;
}
} pdu_session_types_t; } pdu_session_types_t;
typedef struct ssc_modes_s { typedef struct ssc_modes_s {
ssc_mode_t default_ssc_mode; ssc_mode_t default_ssc_mode;
std::vector<ssc_mode_t> allowed_ssc_modes; std::vector<ssc_mode_t> allowed_ssc_modes;
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data["default_ssc_mode"] = default_ssc_mode.to_string();
if (allowed_ssc_modes.size() > 0) {
json_data["allowed_ssc_modes"] = nlohmann::json::array();
}
for (const auto& a : allowed_ssc_modes) {
nlohmann::json json_item = a.to_string();
json_data["allowed_ssc_modes"].push_back(json_item);
}
return json_data;
}
} ssc_modes_t; } ssc_modes_t;
enum ip_address_type_value_e { enum ip_address_type_value_e {
...@@ -76,6 +109,10 @@ enum ip_address_type_value_e { ...@@ -76,6 +109,10 @@ enum ip_address_type_value_e {
IP_ADDRESS_TYPE_IPV6_PREFIX = 2 IP_ADDRESS_TYPE_IPV6_PREFIX = 2
}; };
static const std::vector<std::string> ip_address_type_value_e2str = {
"IP_ADDRESS_TYPE_IPV4_ADDRESS", "IP_ADDRESS_TYPE_IPV6_ADDRESS",
"IP_ADDRESS_TYPE_IPV6_PREFIX"};
typedef struct ipv6_prefix_s { typedef struct ipv6_prefix_s {
struct in6_addr prefix; struct in6_addr prefix;
uint8_t prefix_len; uint8_t prefix_len;
...@@ -189,6 +226,15 @@ typedef struct ip_address_s { ...@@ -189,6 +226,15 @@ typedef struct ip_address_s {
} }
return std::string("Unknown IP Address Type"); return std::string("Unknown IP Address Type");
} }
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data["ip_address_type"] =
ip_address_type_value_e2str.at(ip_address_type);
json_data["addr"] = to_string();
return json_data;
}
} ip_address_t; } ip_address_t;
typedef struct dnn_configuration_s { typedef struct dnn_configuration_s {
...@@ -197,6 +243,24 @@ typedef struct dnn_configuration_s { ...@@ -197,6 +243,24 @@ typedef struct dnn_configuration_s {
session_ambr_t session_ambr; session_ambr_t session_ambr;
subscribed_default_qos_t _5g_qos_profile; subscribed_default_qos_t _5g_qos_profile;
std::vector<ip_address_t> static_ip_addresses; std::vector<ip_address_t> static_ip_addresses;
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data["pdu_session_types"] = pdu_session_types.to_json();
json_data["ssc_modes"] = ssc_modes.to_json();
json_data["session_ambr"] = session_ambr.to_json();
json_data["_5g_qos_profile"] = _5g_qos_profile.to_json();
if (static_ip_addresses.size() > 0) {
json_data["static_ip_addresses"] = nlohmann::json::array();
}
for (const auto& a : static_ip_addresses) {
nlohmann::json json_item = a.to_string();
json_data["static_ip_addresses"].push_back(json_item);
}
return json_data;
}
} dnn_configuration_t; } dnn_configuration_t;
#endif #endif
...@@ -25,6 +25,13 @@ ...@@ -25,6 +25,13 @@
typedef struct session_ambr_s { typedef struct session_ambr_s {
std::string uplink; std::string uplink;
std::string downlink; std::string downlink;
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data["uplink"] = uplink;
json_data["downlink"] = downlink;
return json_data;
}
} session_ambr_t; } session_ambr_t;
enum preemtion_capability_e { NOT_PREEMPT = 1, MAY_PREEMPT = 2 }; enum preemtion_capability_e { NOT_PREEMPT = 1, MAY_PREEMPT = 2 };
...@@ -37,6 +44,14 @@ typedef struct arp_5gc_s { ...@@ -37,6 +44,14 @@ typedef struct arp_5gc_s {
uint8_t priority_level; // (integer 1-15) uint8_t priority_level; // (integer 1-15)
std::string preempt_cap; std::string preempt_cap;
std::string preempt_vuln; // NOT_PREEMPTABLE, PREEMPTABLE std::string preempt_vuln; // NOT_PREEMPTABLE, PREEMPTABLE
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data["priority_level"] = priority_level;
json_data["preempt_cap"] = preempt_cap;
json_data["preempt_vuln"] = preempt_vuln;
return json_data;
}
} arp_5gc_t; } arp_5gc_t;
// see section 5.4.4.1@TS 29.571 // see section 5.4.4.1@TS 29.571
...@@ -44,6 +59,14 @@ typedef struct subscribed_default_qos_s { ...@@ -44,6 +59,14 @@ typedef struct subscribed_default_qos_s {
uint8_t _5qi; uint8_t _5qi;
arp_5gc_t arp; arp_5gc_t arp;
uint8_t priority_level; // 1-127 uint8_t priority_level; // 1-127
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data["_5qi"] = _5qi;
json_data["arp"] = arp.to_json();
json_data["priority_level"] = priority_level;
return json_data;
}
} subscribed_default_qos_t; } subscribed_default_qos_t;
enum reflective_qos_attribute_e { RQOS = 1, NO_RQOS = 2 }; enum reflective_qos_attribute_e { RQOS = 1, NO_RQOS = 2 };
...@@ -54,6 +77,12 @@ static const std::vector<std::string> reflective_qos_attribute_e2str = { ...@@ -54,6 +77,12 @@ static const std::vector<std::string> reflective_qos_attribute_e2str = {
typedef struct gNB_id_s { typedef struct gNB_id_s {
uint8_t bit_length; uint8_t bit_length;
std::string gNB_value; std::string gNB_value;
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data["bit_length"] = bit_length;
json_data["gNB_value"] = gNB_value;
return json_data;
}
} gNB_id_t; // 22bits to 32bits } gNB_id_t; // 22bits to 32bits
typedef struct global_ran_node_id_s { typedef struct global_ran_node_id_s {
...@@ -61,6 +90,7 @@ typedef struct global_ran_node_id_s { ...@@ -61,6 +90,7 @@ typedef struct global_ran_node_id_s {
// n3IwfId: // n3IwfId:
gNB_id_t gNbId; gNB_id_t gNbId;
// ngeNbId: // ngeNbId:
} global_ran_node_id_t; } global_ran_node_id_t;
#endif #endif
...@@ -46,6 +46,7 @@ typedef struct { ...@@ -46,6 +46,7 @@ typedef struct {
char data[SUPI_DIGITS_MAX + 1]; char data[SUPI_DIGITS_MAX + 1];
} supi_t; } supi_t;
// TODO: Move to conversions
static void smf_string_to_supi(supi_t* const supi, char const* const supi_str) { static void smf_string_to_supi(supi_t* const supi, char const* const supi_str) {
// strncpy(supi->data, supi_str, SUPI_DIGITS_MAX + 1); // strncpy(supi->data, supi_str, SUPI_DIGITS_MAX + 1);
memcpy((void*) supi->data, (void*) supi_str, SUPI_DIGITS_MAX + 1); memcpy((void*) supi->data, (void*) supi_str, SUPI_DIGITS_MAX + 1);
...@@ -77,6 +78,13 @@ static uint64_t smf_supi_to_u64(supi_t supi) { ...@@ -77,6 +78,13 @@ static uint64_t smf_supi_to_u64(supi_t supi) {
return uint_supi; return uint_supi;
} }
static std::string smf_supi64_to_string(const supi64_t& supi) {
std::string supi_str = std::to_string(supi);
uint8_t padded_len = SUPI_DIGITS_MAX - supi_str.length();
for (int i = 0; i < padded_len; i++) supi_str = "0" + supi_str;
return supi_str;
}
typedef struct s_nssai // section 28.4, TS23.003 typedef struct s_nssai // section 28.4, TS23.003
{ {
const uint8_t HASH_SEED = 17; const uint8_t HASH_SEED = 17;
......
...@@ -164,17 +164,31 @@ bool conv::plmnFromString( ...@@ -164,17 +164,31 @@ bool conv::plmnFromString(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void conv::plmnToMccMnc( void conv::plmnToMccMnc(
const plmn_t& plmn, std::string& mcc, std::string& mnc) { const plmn_t& plmn, std::string& mcc, std::string& mnc) {
uint16_t mcc_dec = 0; int m_mcc = plmn.mcc_digit1 * 100 + plmn.mcc_digit2 * 10 + plmn.mcc_digit3;
uint16_t mnc_dec = 0; mcc = std::to_string(m_mcc);
uint16_t mnc_len = 0; if ((plmn.mcc_digit2 == 0) and (plmn.mcc_digit1 == 0)) {
mcc = "00" + mcc;
} else if (plmn.mcc_digit1 == 0) {
mcc = "0" + mcc;
}
mcc_dec = plmn.mcc_digit1 * 100 + plmn.mcc_digit2 * 10 + plmn.mcc_digit3; int m_mnc = 0;
mnc_len = (plmn.mnc_digit3 == 0x0 ? 2 : 3); if (plmn.mnc_digit3 == 0xf) {
mnc_dec = plmn.mnc_digit1 * 10 + plmn.mnc_digit2; m_mnc = plmn.mnc_digit1 * 10 + plmn.mnc_digit2;
mnc_dec = (mnc_len == 2 ? mnc_dec : mnc_dec * 10 + plmn.mnc_digit3); if (plmn.mnc_digit1 == 0) {
mnc = "0" + std::to_string(m_mnc);
return;
}
} else {
m_mnc = plmn.mnc_digit3 * 100 + plmn.mnc_digit1 * 10 + plmn.mnc_digit2;
mnc = std::to_string(m_mnc);
if ((plmn.mnc_digit2 == 0) and (plmn.mnc_digit1 == 0)) {
mnc = "00" + mnc;
} else if (plmn.mnc_digit1 == 0) {
mnc = "0" + mnc;
}
}
mcc = std::to_string(mcc_dec);
mnc = std::to_string(mnc_dec);
return; return;
} }
......
...@@ -1085,7 +1085,7 @@ void smf_config::display() { ...@@ -1085,7 +1085,7 @@ void smf_config::display() {
it++) { it++) {
Logger::smf_app().info( Logger::smf_app().info(
" DNN..........: %s (%s)", it->second.dnn.c_str(), " DNN..........: %s (%s)", it->second.dnn.c_str(),
it->second.pdu_session_type.toString().c_str()); it->second.pdu_session_type.to_string().c_str());
if ((it->second.pdu_session_type.pdu_session_type == if ((it->second.pdu_session_type.pdu_session_type ==
pdu_session_type_e::PDU_SESSION_TYPE_E_IPV4) or pdu_session_type_e::PDU_SESSION_TYPE_E_IPV4) or
......
...@@ -379,7 +379,7 @@ std::string smf_pdu_session::toString() const { ...@@ -379,7 +379,7 @@ std::string smf_pdu_session::toString() const {
s.append("\tDNN:\t\t\t").append(dnn).append("\n"); s.append("\tDNN:\t\t\t").append(dnn).append("\n");
s.append("\tS-NSSAI:\t\t\t").append(snssai.toString()).append("\n"); s.append("\tS-NSSAI:\t\t\t").append(snssai.toString()).append("\n");
s.append("\tPDN type:\t\t") s.append("\tPDN type:\t\t")
.append(pdu_session_type.toString()) .append(pdu_session_type.to_string())
.append("\n"); .append("\n");
} }
if (ipv4) if (ipv4)
...@@ -4427,7 +4427,7 @@ void smf_context::handle_flexcn_event( ...@@ -4427,7 +4427,7 @@ void smf_context::handle_flexcn_event(
} }
} }
cj["pdu_session_type"] = cj["pdu_session_type"] =
sp->pdu_session_type.toString(); // PDU Session Type sp->pdu_session_type.to_string(); // PDU Session Type
// NSSAI // NSSAI
cj["snssai"]["sst"] = sp->get_snssai().sst; cj["snssai"]["sst"] = sp->get_snssai().sst;
cj["snssai"]["sd"] = std::to_string(sp->get_snssai().sd); cj["snssai"]["sd"] = std::to_string(sp->get_snssai().sd);
...@@ -4554,7 +4554,7 @@ void smf_context::handle_pdusesest( ...@@ -4554,7 +4554,7 @@ void smf_context::handle_pdusesest(
} }
} }
ev_notif.set_pdu_session_type( ev_notif.set_pdu_session_type(
sp->pdu_session_type.toString()); // PDU Session Type sp->pdu_session_type.to_string()); // PDU Session Type
ev_notif.set_sst(sp->get_snssai().sst); ev_notif.set_sst(sp->get_snssai().sst);
ev_notif.set_sd(std::to_string(sp->get_snssai().sd)); ev_notif.set_sd(std::to_string(sp->get_snssai().sd));
ev_notif.set_dnn(sp->get_dnn()); ev_notif.set_dnn(sp->get_dnn());
......
...@@ -166,7 +166,7 @@ bool smf_n1::create_n1_pdu_session_establishment_accept( ...@@ -166,7 +166,7 @@ bool smf_n1::create_n1_pdu_session_establishment_accept(
// PDUAddress // PDUAddress
paa_t paa = sm_context_res.get_paa(); paa_t paa = sm_context_res.get_paa();
Logger::smf_n1().debug( Logger::smf_n1().debug(
"PDU Session Type %s", paa.pdu_session_type.toString().c_str()); "PDU Session Type %s", paa.pdu_session_type.to_string().c_str());
sm_msg->pdu_session_establishment_accept.pduaddress.pdu_session_type_value = sm_msg->pdu_session_establishment_accept.pduaddress.pdu_session_type_value =
static_cast<uint8_t>(paa.pdu_session_type.pdu_session_type); static_cast<uint8_t>(paa.pdu_session_type.pdu_session_type);
if (paa.pdu_session_type.pdu_session_type == PDU_SESSION_TYPE_E_IPV4) { if (paa.pdu_session_type.pdu_session_type == PDU_SESSION_TYPE_E_IPV4) {
......
...@@ -94,7 +94,7 @@ struct policy_association { ...@@ -94,7 +94,7 @@ struct policy_association {
context.setSupi("imsi-" + supi); context.setSupi("imsi-" + supi);
oai::smf_server::model::PduSessionType pdu_session_type_model; oai::smf_server::model::PduSessionType pdu_session_type_model;
// hacky // hacky
from_json(pdu_session_type.toString(), pdu_session_type_model); from_json(pdu_session_type.to_string(), pdu_session_type_model);
context.setPduSessionType(pdu_session_type_model); context.setPduSessionType(pdu_session_type_model);
context.setDnn(dnn); context.setDnn(dnn);
context.setSliceInfo(snssai_model); context.setSliceInfo(snssai_model);
......
...@@ -859,7 +859,8 @@ bool smf_sbi::get_sm_data( ...@@ -859,7 +859,8 @@ bool smf_sbi::get_sm_data(
std::string(inet_ntoa(*((struct in_addr*) &smf_cfg.udm_addr.ipv4_addr))) + std::string(inet_ntoa(*((struct in_addr*) &smf_cfg.udm_addr.ipv4_addr))) +
":" + std::to_string(smf_cfg.udm_addr.port) + NUDM_SDM_BASE + ":" + std::to_string(smf_cfg.udm_addr.port) + NUDM_SDM_BASE +
smf_cfg.udm_addr.api_version + smf_cfg.udm_addr.api_version +
fmt::format(NUDM_SDM_GET_SM_DATA_URL, std::to_string(supi)) + query_str; fmt::format(NUDM_SDM_GET_SM_DATA_URL, smf_supi64_to_string(supi)) +
query_str;
Logger::smf_sbi().debug("UDM's URL: %s ", url.c_str()); Logger::smf_sbi().debug("UDM's URL: %s ", url.c_str());
...@@ -935,136 +936,141 @@ bool smf_sbi::get_sm_data( ...@@ -935,136 +936,141 @@ bool smf_sbi::get_sm_data(
// Verify DNN configurations // Verify DNN configurations
if (jsonData.find("dnnConfigurations") == jsonData.end()) return false; if (jsonData.find("dnnConfigurations") == jsonData.end()) return false;
Logger::smf_sbi().debug(
"DNN Configurations %s", jsonData["dnnConfigurations"].dump().c_str());
// Retrieve SessionManagementSubscription and store in the context // Retrieve SessionManagementSubscription and store in the context
for (nlohmann::json::iterator it = jsonData["dnnConfigurations"].begin(); for (nlohmann::json::iterator it = jsonData["dnnConfigurations"].begin();
it != jsonData["dnnConfigurations"].end(); ++it) { it != jsonData["dnnConfigurations"].end(); ++it) {
Logger::smf_sbi().debug("DNN %s", it.key().c_str()); Logger::smf_sbi().debug("DNN %s", it.key().c_str());
if (it.key().compare(dnn) != 0) break; if (it.key().compare(dnn) == 0) {
// Get DNN configuration
try { try {
std::shared_ptr<dnn_configuration_t> dnn_configuration = std::shared_ptr<dnn_configuration_t> dnn_configuration =
std::make_shared<dnn_configuration_t>(); std::make_shared<dnn_configuration_t>();
// PDU Session Type (Mandatory) // PDU Session Type (Mandatory)
std::string default_session_type = std::string default_session_type =
it.value()["pduSessionTypes"]["defaultSessionType"]; it.value()["pduSessionTypes"]["defaultSessionType"];
Logger::smf_sbi().debug(
"Default session type %s", default_session_type.c_str());
pdu_session_type_t pdu_session_type(default_session_type);
dnn_configuration->pdu_session_types.default_session_type =
pdu_session_type;
// SSC_Mode (Mandatory)
std::string default_ssc_mode = it.value()["sscModes"]["defaultSscMode"];
Logger::smf_sbi().debug(
"Default SSC Mode %s", default_ssc_mode.c_str());
ssc_mode_t ssc_mode(default_ssc_mode);
dnn_configuration->ssc_modes.default_ssc_mode = ssc_mode;
// 5gQosProfile (Optional)
if (it.value().find("5gQosProfile") != it.value().end()) {
dnn_configuration->_5g_qos_profile._5qi =
it.value()["5gQosProfile"]["5qi"];
dnn_configuration->_5g_qos_profile.arp.priority_level =
it.value()["5gQosProfile"]["arp"]["priorityLevel"];
dnn_configuration->_5g_qos_profile.arp.preempt_cap =
it.value()["5gQosProfile"]["arp"]["preemptCap"];
dnn_configuration->_5g_qos_profile.arp.preempt_vuln =
it.value()["5gQosProfile"]["arp"]["preemptVuln"];
// Optinal
if (it.value()["5gQosProfile"].find("") !=
it.value()["5gQosProfile"].end()) {
dnn_configuration->_5g_qos_profile.priority_level =
it.value()["5gQosProfile"]["5QiPriorityLevel"];
}
}
// session_ambr (Optional)
if (it.value().find("sessionAmbr") != it.value().end()) {
dnn_configuration->session_ambr.uplink =
it.value()["sessionAmbr"]["uplink"];
dnn_configuration->session_ambr.downlink =
it.value()["sessionAmbr"]["downlink"];
Logger::smf_sbi().debug( Logger::smf_sbi().debug(
"Session AMBR Uplink %s, Downlink %s", "Default session type %s", default_session_type.c_str());
dnn_configuration->session_ambr.uplink.c_str(), pdu_session_type_t pdu_session_type(default_session_type);
dnn_configuration->session_ambr.downlink.c_str()); dnn_configuration->pdu_session_types.default_session_type =
} pdu_session_type;
// Static IP Addresses (Optional) // SSC_Mode (Mandatory)
if (it.value().find("staticIpAddress") != it.value().end()) { std::string default_ssc_mode =
for (const auto& ip_addr : it.value()["staticIpAddress"]) { it.value()["sscModes"]["defaultSscMode"];
if (ip_addr.find("ipv4Addr") != ip_addr.end()) { Logger::smf_sbi().debug(
struct in_addr ue_ipv4_addr = {}; "Default SSC Mode %s", default_ssc_mode.c_str());
std::string ue_ip_str = ip_addr["ipv4Addr"].get<std::string>(); ssc_mode_t ssc_mode(default_ssc_mode);
// ip_addr.at("ipv4Addr").get_to(ue_ip_str); dnn_configuration->ssc_modes.default_ssc_mode = ssc_mode;
IPV4_STR_ADDR_TO_INADDR(
util::trim(ue_ip_str).c_str(), ue_ipv4_addr, // 5gQosProfile (Optional)
"BAD IPv4 ADDRESS FORMAT FOR UE IP ADDR !"); if (it.value().find("5gQosProfile") != it.value().end()) {
ip_address_t ue_ip = {}; dnn_configuration->_5g_qos_profile._5qi =
ue_ip = ue_ipv4_addr; it.value()["5gQosProfile"]["5qi"];
dnn_configuration->static_ip_addresses.push_back(ue_ip); dnn_configuration->_5g_qos_profile.arp.priority_level =
} else if (ip_addr.find("ipv6Addr") != ip_addr.end()) { it.value()["5gQosProfile"]["arp"]["priorityLevel"];
unsigned char buf_in6_addr[sizeof(struct in6_addr)]; dnn_configuration->_5g_qos_profile.arp.preempt_cap =
struct in6_addr ue_ipv6_addr; it.value()["5gQosProfile"]["arp"]["preemptCap"];
std::string ue_ip_str = ip_addr["ipv6Addr"].get<std::string>(); dnn_configuration->_5g_qos_profile.arp.preempt_vuln =
it.value()["5gQosProfile"]["arp"]["preemptVuln"];
if (inet_pton( // Optinal
AF_INET6, util::trim(ue_ip_str).c_str(), buf_in6_addr) == if (it.value()["5gQosProfile"].find("") !=
1) { it.value()["5gQosProfile"].end()) {
memcpy(&ue_ipv6_addr, buf_in6_addr, sizeof(struct in6_addr)); dnn_configuration->_5g_qos_profile.priority_level =
} else { it.value()["5gQosProfile"]["5QiPriorityLevel"];
Logger::smf_app().error( }
"Bad UE IPv6 Addr %s", ue_ip_str.c_str()); }
throw("Bad UE IPv6 Addr %s", ue_ip_str.c_str());
}
ip_address_t ue_ip = {}; // session_ambr (Optional)
ue_ip = ue_ipv6_addr; if (it.value().find("sessionAmbr") != it.value().end()) {
dnn_configuration->static_ip_addresses.push_back(ue_ip); dnn_configuration->session_ambr.uplink =
} else if (ip_addr.find("ipv6Prefix") != ip_addr.end()) { it.value()["sessionAmbr"]["uplink"];
unsigned char buf_in6_addr[sizeof(struct in6_addr)]; dnn_configuration->session_ambr.downlink =
struct in6_addr ipv6_prefix; it.value()["sessionAmbr"]["downlink"];
std::string prefix_str = ip_addr["ipv6Prefix"].get<std::string>(); Logger::smf_sbi().debug(
std::vector<std::string> words = {}; "Session AMBR Uplink %s, Downlink %s",
boost::split( dnn_configuration->session_ambr.uplink.c_str(),
words, prefix_str, boost::is_any_of("/"), dnn_configuration->session_ambr.downlink.c_str());
boost::token_compress_on); }
if (words.size() != 2) {
Logger::smf_app().error(
"Bad value for UE IPv6 Prefix %s", prefix_str.c_str());
return RETURNerror;
}
if (inet_pton( // Static IP Addresses (Optional)
AF_INET6, util::trim(words.at(0)).c_str(), if (it.value().find("staticIpAddress") != it.value().end()) {
buf_in6_addr) == 1) { for (const auto& ip_addr : it.value()["staticIpAddress"]) {
memcpy(&ipv6_prefix, buf_in6_addr, sizeof(struct in6_addr)); if (ip_addr.find("ipv4Addr") != ip_addr.end()) {
} else { struct in_addr ue_ipv4_addr = {};
Logger::smf_app().error( std::string ue_ip_str = ip_addr["ipv4Addr"].get<std::string>();
"Bad UE IPv6 Addr %s", words.at(0).c_str()); // ip_addr.at("ipv4Addr").get_to(ue_ip_str);
throw("Bad UE IPv6 Addr %s", words.at(0).c_str()); IPV4_STR_ADDR_TO_INADDR(
util::trim(ue_ip_str).c_str(), ue_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR UE IP ADDR !");
ip_address_t ue_ip = {};
ue_ip = ue_ipv4_addr;
dnn_configuration->static_ip_addresses.push_back(ue_ip);
} else if (ip_addr.find("ipv6Addr") != ip_addr.end()) {
unsigned char buf_in6_addr[sizeof(struct in6_addr)];
struct in6_addr ue_ipv6_addr;
std::string ue_ip_str = ip_addr["ipv6Addr"].get<std::string>();
if (inet_pton(
AF_INET6, util::trim(ue_ip_str).c_str(),
buf_in6_addr) == 1) {
memcpy(&ue_ipv6_addr, buf_in6_addr, sizeof(struct in6_addr));
} else {
Logger::smf_app().error(
"Bad UE IPv6 Addr %s", ue_ip_str.c_str());
ue_ipv6_addr = in6addr_any;
}
ip_address_t ue_ip = {};
ue_ip = ue_ipv6_addr;
dnn_configuration->static_ip_addresses.push_back(ue_ip);
} else if (ip_addr.find("ipv6Prefix") != ip_addr.end()) {
unsigned char buf_in6_addr[sizeof(struct in6_addr)];
struct in6_addr ipv6_prefix;
std::string prefix_str =
ip_addr["ipv6Prefix"].get<std::string>();
std::vector<std::string> words = {};
boost::split(
words, prefix_str, boost::is_any_of("/"),
boost::token_compress_on);
if (words.size() != 2) {
Logger::smf_app().error(
"Bad value for UE IPv6 Prefix %s", prefix_str.c_str());
return RETURNerror;
}
if (inet_pton(
AF_INET6, util::trim(words.at(0)).c_str(),
buf_in6_addr) == 1) {
memcpy(&ipv6_prefix, buf_in6_addr, sizeof(struct in6_addr));
} else {
Logger::smf_app().error(
"Bad UE IPv6 Addr %s", words.at(0).c_str());
ipv6_prefix = in6addr_any;
}
ip_address_t ue_ip = {};
ipv6_prefix_t ue_ipv6_prefix = {};
ue_ipv6_prefix.prefix_len = std::stoi(util::trim(words.at(1)));
ue_ipv6_prefix.prefix = ipv6_prefix;
ue_ip = ue_ipv6_prefix;
dnn_configuration->static_ip_addresses.push_back(ue_ip);
} }
ip_address_t ue_ip = {};
ipv6_prefix_t ue_ipv6_prefix = {};
ue_ipv6_prefix.prefix_len = std::stoi(util::trim(words.at(1)));
ue_ipv6_prefix.prefix = ipv6_prefix;
ue_ip = ue_ipv6_prefix;
dnn_configuration->static_ip_addresses.push_back(ue_ip);
} }
} }
}
subscription->insert_dnn_configuration(it.key(), dnn_configuration); subscription->insert_dnn_configuration(it.key(), dnn_configuration);
return true; return true;
} catch (nlohmann::json::exception& e) { } catch (nlohmann::json::exception& e) {
Logger::smf_sbi().warn( Logger::smf_sbi().warn(
"Exception message %s, exception id %d ", e.what(), e.id); "Exception message %s, exception id %d ", e.what(), e.id);
return false; return false;
} catch (std::exception& e) { } catch (std::exception& e) {
Logger::smf_sbi().warn("Exception message %s", e.what()); Logger::smf_sbi().warn("Exception message %s", e.what());
return false; return false;
}
} }
} }
return true; return true;
......
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