Commit ed5ea7f3 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Match SD when provided

parent 505ffdb9
......@@ -254,14 +254,15 @@ typedef struct slice_s {
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data["sst"] = this->sst;
if (sst > SST_MAX_STANDARDIZED_VALUE) json_data["sd"] = this->sd;
if (this->sd != SD_NO_VALUE) json_data["sd"] = this->sd;
return json_data;
}
void from_json(nlohmann::json& json_data) {
this->sst = json_data["sst"].get<int>();
if (this->sst > SST_MAX_STANDARDIZED_VALUE)
if (json_data.find("sd") != json_data.end()) {
this->sd = json_data["sd"].get<int>();
}
}
} slice_t;
......
......@@ -4140,7 +4140,7 @@ bool amf_n1::check_requested_nssai(const std::shared_ptr<nas_context>& nc) {
for (auto s : p.slice_list) {
std::string sd = std::to_string(s.sd);
if (s.sst == n.sst) {
if ((s.sst <= SST_MAX_STANDARDIZED_VALUE) or (s.sd == n.sd)) {
if (s.sd == n.sd) {
found_nssai = true;
Logger::amf_n1().debug(
"Found S-NSSAI (SST %d, SD %d)", s.sst, n.sd);
......@@ -4188,32 +4188,56 @@ bool amf_n1::check_subscribed_nssai(
"NSSAIs");
std::vector<oai::amf::model::Snssai> common_snssais;
for (auto s : nc->requestedNssai) {
std::string sd = std::to_string(s.sd);
// std::string sd = std::to_string(s.sd);
// Check with default subscribed NSSAIs
for (auto n : nssai.getDefaultSingleNssais()) {
if (s.sst == n.getSst()) {
if ((s.sst <= SST_MAX_STANDARDIZED_VALUE) or
(n.sdIsSet() and (n.getSd().compare(sd) == 0)) or
(!n.sdIsSet() and sd.empty())) {
uint32_t sd = SD_NO_VALUE;
if (!n.getSd().empty()) {
conv::sd_string_to_int(n.getSd(), sd);
}
if (sd == s.sd) {
common_snssais.push_back(n);
Logger::amf_n1().debug(
"Common S-NSSAI (SST %d, SD %s)", s.sst, sd.c_str());
"Common S-NSSAI (SST %d, SD %ld)", s.sst, sd);
break;
}
/*
if ((s.sst <= SST_MAX_STANDARDIZED_VALUE) or
(n.sdIsSet() and (n.getSd().compare(sd) == 0)) or
(!n.sdIsSet() and sd.empty())) {
common_snssais.push_back(n);
Logger::amf_n1().debug(
"Common S-NSSAI (SST %d, SD %s)", s.sst, sd.c_str());
break;
}
*/
}
}
// check with other subscribed NSSAIs
for (auto n : nssai.getSingleNssais()) {
if (s.sst == n.getSst()) {
if ((s.sst <= SST_MAX_STANDARDIZED_VALUE) or
(n.sdIsSet() and (n.getSd().compare(sd) == 0)) or
(!n.sdIsSet() and sd.empty())) {
uint32_t sd = SD_NO_VALUE;
if (!n.getSd().empty()) {
conv::sd_string_to_int(n.getSd(), sd);
}
if (sd == s.sd) {
common_snssais.push_back(n);
Logger::amf_n1().debug(
"Common S-NSSAI (SST %d, SD %s)", s.sst, sd.c_str());
"Common S-NSSAI (SST %d, SD %ld)", s.sst, sd);
break;
}
/*
if ((s.sst <= SST_MAX_STANDARDIZED_VALUE) or
(n.sdIsSet() and (n.getSd().compare(sd) == 0)) or
(!n.sdIsSet() and sd.empty())) {
common_snssais.push_back(n);
Logger::amf_n1().debug(
"Common S-NSSAI (SST %d, SD %s)", s.sst, sd.c_str());
break;
}
*/
}
}
}
......@@ -4226,8 +4250,19 @@ bool amf_n1::check_subscribed_nssai(
for (auto n : nssai.getDefaultSingleNssais()) {
bool found_nssai = false;
for (auto s : p.slice_list) {
std::string sd = std::to_string(s.sd);
// std::string sd = std::to_string(s.sd);
if (s.sst == n.getSst()) {
uint32_t sd = SD_NO_VALUE;
if (!n.getSd().empty()) {
conv::sd_string_to_int(n.getSd(), sd);
}
if (sd == s.sd) {
found_nssai = true;
Logger::amf_n1().debug(
"Found S-NSSAI (SST %d, SD %s)", s.sst, n.getSd().c_str());
break;
}
/*
if ((s.sst <= SST_MAX_STANDARDIZED_VALUE) or
(n.sdIsSet() and (n.getSd().compare(sd) == 0)) or
(!n.sdIsSet() and sd.empty())) {
......@@ -4236,6 +4271,7 @@ bool amf_n1::check_subscribed_nssai(
"Found S-NSSAI (SST %d, SD %s)", s.sst, n.getSd().c_str());
break;
}
*/
}
}
......@@ -4249,16 +4285,28 @@ bool amf_n1::check_subscribed_nssai(
for (auto n : common_snssais) {
bool found_nssai = false;
for (auto s : p.slice_list) {
std::string sd = std::to_string(s.sd);
// std::string sd = std::to_string(s.sd);
if (s.sst == n.getSst()) {
if ((s.sst <= SST_MAX_STANDARDIZED_VALUE) or
(n.sdIsSet() and (n.getSd().compare(sd) == 0)) or
(!n.sdIsSet() and sd.empty())) {
uint32_t sd = SD_NO_VALUE;
if (!n.getSd().empty()) {
conv::sd_string_to_int(n.getSd(), sd);
}
if (sd == s.sd) {
found_nssai = true;
Logger::amf_n1().debug(
"Found S-NSSAI (SST %d, SD %s)", s.sst, n.getSd().c_str());
break;
}
/*
if ((s.sst <= SST_MAX_STANDARDIZED_VALUE) or
(n.sdIsSet() and (n.getSd().compare(sd) == 0)) or
(!n.sdIsSet() and sd.empty())) {
found_nssai = true;
Logger::amf_n1().debug(
"Found S-NSSAI (SST %d, SD %s)", s.sst, n.getSd().c_str());
break;
}
*/
}
}
......
......@@ -893,11 +893,24 @@ bool amf_n11::discover_smf(
for (auto& s : instance_json["sNssais"].items()) {
nlohmann::json Snssai = s.value();
int sst = 0;
std::string sd = {};
uint32_t sd = SD_NO_VALUE; // Default value
if (Snssai.count("sst") > 0) sst = Snssai["sst"].get<int>();
if (Snssai.count("sd") > 0) sd = Snssai["sd"].get<string>();
if (Snssai.count("sd") > 0) {
conv::sd_string_to_int(Snssai["sd"].get<string>(), sd);
}
if (sst == snssai.sST) {
// Match SD (optional) only if it is provided
uint32_t input_sd = SD_NO_VALUE; // Default value
conv::sd_string_to_int(snssai.sD, input_sd);
if (sd == input_sd) {
Logger::amf_n11().debug(
"S-NSSAI [SST- %d, SD -%s] is matched for SMF profile",
snssai.sST, snssai.sD.c_str());
result = true;
break; // NSSAI is included in the list of supported slices
// from SMF
}
/*
// Match SD (optional) only if it is provided
if ((sst <= SST_MAX_STANDARDIZED_VALUE) or sd.empty() or
(snssai.sD.compare(sd) == 0)) {
Logger::amf_n11().debug(
......@@ -907,6 +920,7 @@ bool amf_n11::discover_smf(
break; // NSSAI is included in the list of supported slices
// from SMF
}
*/
}
}
}
......
......@@ -2326,15 +2326,28 @@ bool amf_n2::get_common_plmn(
"S-NSSAI from AMF (SST %d, SD %s)", s2.sst,
std::to_string(s2.sd).c_str());
if (s1.sst.compare(std::to_string(s2.sst)) == 0) {
if ((s2.sst <= SST_MAX_STANDARDIZED_VALUE) or
(s1.sd.compare(std::to_string(s2.sd)) ==
0)) { // don't need to check SD for standard NSSAI
uint32_t s1_sd = SD_NO_VALUE;
if (!s1.sd.empty()) {
conv::sd_string_to_int(s1.sd, s1_sd);
}
if (s1_sd == s2.sd) {
Logger::amf_n2().debug(
"Common S-NSSAI (SST %s, SD %s)", s1.sst.c_str(),
s1.sd.c_str());
plmn_slice_support_item.slice_list.push_back(s1);
found_common_plmn = true;
}
/*
if ((s2.sst <= SST_MAX_STANDARDIZED_VALUE) or
(s1.sd.compare(std::to_string(s2.sd)) ==
0)) { // don't need to check SD for
standard NSSAI Logger::amf_n2().debug( "Common S-NSSAI (SST
%s, SD %s)", s1.sst.c_str(), s1.sd.c_str());
plmn_slice_support_item.slice_list.push_back(s1);
found_common_plmn = true;
}
*/
}
}
}
......
......@@ -26,6 +26,7 @@
*/
#include "conversions.hpp"
#include "amf.hpp"
#include "logger.hpp"
#include <arpa/inet.h>
......@@ -268,7 +269,7 @@ void conv::bstring_2_octet_string(bstring& b_str, OCTET_STRING_t& octet_str) {
//------------------------------------------------------------------------------
void conv::sd_string_to_int(const std::string& sd_str, uint32_t& sd) {
sd = 0xFFFFFF;
sd = SD_NO_VALUE;
if (sd_str.empty()) return;
uint8_t base = 10;
try {
......@@ -282,6 +283,6 @@ void conv::sd_string_to_int(const std::string& sd_str, uint32_t& sd) {
Logger::amf_app().error(
"Error when converting from string to int for S-NSSAI SD, error: %s",
e.what());
sd = 0xFFFFFF;
sd = SD_NO_VALUE;
}
}
......@@ -291,7 +291,7 @@ void InitialContextSetupRequestMsg::setAllowedNssai(
for (int i = 0; i < list.size(); i++) {
S_NSSAI snssai = {};
snssai.setSst(list[i].sst);
uint32_t sd = 0xFFFFFF;
uint32_t sd = SD_NO_VALUE;
if (!list[i].sd.empty()) {
conv::sd_string_to_int(list[i].sd, sd);
}
......
......@@ -140,7 +140,7 @@ void NGSetupResponseMsg::setPlmnSupportList(
S_NSSAI snssai = {};
snssai.setSst(list[i].slice_list[j].sst);
uint32_t sd = 0xFFFFFF;
uint32_t sd = SD_NO_VALUE;
if (!list[i].slice_list[j].sd.empty()) {
conv::sd_string_to_int(list[i].slice_list[j].sd, sd);
}
......
......@@ -113,7 +113,7 @@ void RerouteNASRequest::setAllowedNssai(const std::vector<S_Nssai>& list) {
S_NSSAI snssai = {};
snssai.setSst(list[i].sst);
uint32_t sd = 0xFFFFFF;
uint32_t sd = SD_NO_VALUE;
if (!list[i].sd.empty()) {
conv::sd_string_to_int(list[i].sd, sd);
}
......
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