Commit 677695d0 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix issue for SD with Standardized SST

parent 7a1510be
......@@ -983,9 +983,8 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
supi, itti_msg.pdu_session_id, psc)) {
Logger::amf_n2().warn(
"Cannot get pdu_session_context with SUPI (%s)", supi.c_str());
// TODO: remove hardcoded value
item.s_nssai.sst = "01";
item.s_nssai.sd = "none";
item.s_nssai.sst = "01"; // TODO: remove the default value
item.s_nssai.sd = std::to_string(SD_NO_VALUE);
} else {
item.s_nssai.sst = std::to_string(psc.get()->snssai.sST);
item.s_nssai.sd = psc.get()->snssai.sD;
......@@ -1094,7 +1093,8 @@ void amf_n2::handle_itti_message(
Logger::amf_n2().warn(
"Cannot get pdu_session_context with SUPI (%s)", supi.c_str());
item.s_nssai.sst = "01"; // TODO: get from N1N2msgTranferMsg
item.s_nssai.sd = "none"; // TODO: get from N1N2msgTranferMsg
item.s_nssai.sd =
std::to_string(SD_NO_VALUE); // TODO: get from N1N2msgTranferMsg
} else {
item.s_nssai.sst = std::to_string(psc.get()->snssai.sST);
item.s_nssai.sd = psc.get()->snssai.sD;
......@@ -2325,8 +2325,10 @@ bool amf_n2::get_common_plmn(
Logger::amf_n2().debug(
"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) and
(s1.sd.compare(std::to_string(s2.sd)) == 0)) {
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
Logger::amf_n2().debug(
"Common S-NSSAI (SST %s, SD %s)", s1.sst.c_str(),
s1.sd.c_str());
......@@ -2335,6 +2337,7 @@ bool amf_n2::get_common_plmn(
}
}
}
}
item.b_plmn_list.push_back(plmn_slice_support_item);
result.push_back(item);
......
......@@ -69,6 +69,9 @@ constexpr uint64_t SECONDS_SINCE_FIRST_EPOCH = 2208988800;
#define NAS_MESSAGE_DOWNLINK 1
#define NAS_MESSAGE_UPLINK 0
const uint32_t SD_NO_VALUE = 0xFFFFFF;
const uint8_t SST_MAX_STANDARDIZED_VALUE = 127;
typedef enum {
PlainNasMsg = 0x0,
IntegrityProtected = 0x1,
......
......@@ -27,7 +27,7 @@
*/
#include "S-NSSAI.hpp"
#include "amf.hpp"
#include "String2Value.hpp"
using namespace std;
......@@ -38,7 +38,7 @@ namespace ngap {
S_NSSAI::S_NSSAI() {
sdIsSet = false;
sst = 0;
sd = 0;
sd = SD_NO_VALUE;
}
//------------------------------------------------------------------------------
......@@ -116,13 +116,14 @@ void S_NSSAI::setSd(const uint32_t s) {
sdIsSet = true;
sd = s;
}
//------------------------------------------------------------------------------
bool S_NSSAI::getSd(std::string& s_nssaiSd) const {
if (sdIsSet) {
s_nssaiSd = to_string(sd);
} else
s_nssaiSd = "None";
} else {
s_nssaiSd = to_string(SD_NO_VALUE);
}
return sdIsSet;
}
......@@ -131,19 +132,19 @@ std::string S_NSSAI::getSd() const {
if (sdIsSet) {
return to_string(sd);
} else
return "None";
return to_string(SD_NO_VALUE);
}
//------------------------------------------------------------------------------
bool S_NSSAI::encode2S_NSSAI(Ngap_S_NSSAI_t* s_NSSAI) {
if (!sSTEncode2OctetString(s_NSSAI->sST)) return false;
if (sdIsSet) {
Ngap_SD_t* sd = (Ngap_SD_t*) calloc(1, sizeof(Ngap_SD_t));
if (!sd) return false;
if (!sDEncode2OctetString(sd)) {
free(sd);
if (sdIsSet && (sd != SD_NO_VALUE)) {
Ngap_SD_t* sd_tmp = (Ngap_SD_t*) calloc(1, sizeof(Ngap_SD_t));
if (!sd_tmp) return false;
if (!sDEncode2OctetString(sd_tmp)) {
free(sd_tmp);
return false;
}
s_NSSAI->sD = sd;
s_NSSAI->sD = sd_tmp;
}
return true;
}
......@@ -154,6 +155,8 @@ bool S_NSSAI::decodefromS_NSSAI(Ngap_S_NSSAI_t* s_NSSAI) {
if (s_NSSAI->sD) {
sdIsSet = true;
if (!sDdecodefromOctetString(s_NSSAI->sD)) return false;
} else {
sd = SD_NO_VALUE;
}
return true;
}
......
......@@ -21,6 +21,7 @@
#include "InitialContextSetupRequest.hpp"
#include "logger.hpp"
#include "amf.hpp"
extern "C" {
#include "dynamic_memory_check.h"
......@@ -289,8 +290,8 @@ void InitialContextSetupRequestMsg::setAllowedNssai(
for (int i = 0; i < list.size(); i++) {
S_NSSAI snssai = {};
snssai.setSst(list[i].sst);
if (!list[i].sd.empty() && ((list[i].sd.compare("None") != 0) &&
(list[i].sd.compare("none") != 0)))
if (!list[i].sd.empty() &&
((list[i].sd.compare(std::to_string(SD_NO_VALUE)) != 0)))
snssai.setSd(list[i].sd);
snssaiList.push_back(snssai);
}
......
......@@ -21,6 +21,7 @@
#include "NGSetupResponse.hpp"
#include "logger.hpp"
#include "amf.hpp"
extern "C" {
#include "dynamic_memory_check.h"
......@@ -138,8 +139,8 @@ void NGSetupResponseMsg::setPlmnSupportList(
S_NSSAI snssai = {};
snssai.setSst(list[i].slice_list[j].sst);
if (!list[i].slice_list[j].sd.empty() &&
(list[i].slice_list[j].sd.compare("None") != 0) &&
(list[i].slice_list[j].sd.compare("none") != 0)) {
(list[i].slice_list[j].sd.compare(std::to_string(SD_NO_VALUE)) !=
0)) {
snssai.setSd(list[i].slice_list[j].sd);
}
snssais.push_back(snssai);
......
......@@ -21,6 +21,7 @@
#include "RerouteNASRequest.hpp"
#include "common_defs.h"
#include "amf.hpp"
#include "logger.hpp"
......@@ -110,8 +111,8 @@ void RerouteNASRequest::setAllowedNssai(const std::vector<S_Nssai>& list) {
for (int i = 0; i < list.size(); i++) {
S_NSSAI snssai = {};
snssai.setSst(list[i].sst);
if (!list[i].sd.empty() && ((list[i].sd.compare("None") != 0) &&
(list[i].sd.compare("none") != 0)))
if (!list[i].sd.empty() &&
((list[i].sd.compare(std::to_string(SD_NO_VALUE)) != 0)))
snssai.setSd(list[i].sd);
snssaiList.push_back(snssai);
}
......
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