Commit 3c71b1c2 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Fix SD issue

parent 2e98b774
...@@ -62,15 +62,23 @@ static uint64_t smf_supi_to_u64(supi_t supi) { ...@@ -62,15 +62,23 @@ static uint64_t smf_supi_to_u64(supi_t supi) {
typedef struct s_nssai // section 28.4, TS23.003 typedef struct s_nssai // section 28.4, TS23.003
{ {
uint8_t sST; uint8_t sst;
// uint32_t sD:24; uint32_t sd;
std::string sD; s_nssai(const uint8_t& m_sst, const uint32_t m_sd) : sst(m_sst), sd(m_sd) {}
// s_nssai(const uint8_t& sst, const uint32_t sd) : sST(sst), sD(sd) {} s_nssai(const uint8_t& m_sst, const std::string m_sd) : sst(m_sst) {
s_nssai(const uint8_t& sst, const std::string sd) : sST(sst), sD(sd) {} sd = 0xFFFFFF;
s_nssai() : sST(), sD() {} try {
s_nssai(const s_nssai& p) : sST(p.sST), sD(p.sD) {} sd = std::stoul(m_sd, nullptr, 10);
} catch (const std::exception& e) {
Logger::smf_app().warn(
"Error when converting from string to int for snssai.SD, error: %s",
e.what());
}
}
s_nssai() : sst(), sd() {}
s_nssai(const s_nssai& p) : sst(p.sst), sd(p.sd) {}
bool operator==(const struct s_nssai& s) const { bool operator==(const struct s_nssai& s) const {
if ((s.sST == this->sST) && (s.sD.compare(this->sD) == 0)) { if ((s.sst == this->sst) && (s.sd == this->sd)) {
return true; return true;
} else { } else {
return false; return false;
...@@ -78,15 +86,15 @@ typedef struct s_nssai // section 28.4, TS23.003 ...@@ -78,15 +86,15 @@ typedef struct s_nssai // section 28.4, TS23.003
} }
s_nssai& operator=(const struct s_nssai& s) { s_nssai& operator=(const struct s_nssai& s) {
sST = s.sST; sst = s.sst;
sD = s.sD; sd = s.sd;
return *this; return *this;
} }
std::string toString() const { std::string toString() const {
std::string s = {}; std::string s = {};
s.append("SST=").append(std::to_string(sST)); s.append("SST=").append(std::to_string(sst));
s.append(", SD=").append(sD); s.append(", SD=").append(std::to_string(sd));
return s; return s;
} }
......
...@@ -558,8 +558,8 @@ void xgpp_conv::smf_event_exposure_notification_from_openapi( ...@@ -558,8 +558,8 @@ void xgpp_conv::smf_event_exposure_notification_from_openapi(
void xgpp_conv::sm_context_request_from_nas( void xgpp_conv::sm_context_request_from_nas(
const nas_message_t& nas_msg, const nas_message_t& nas_msg,
smf::pdu_session_create_sm_context_request& pcr) { smf::pdu_session_create_sm_context_request& pcr) {
pdu_session_type_t pdu_session_type = {.pdu_session_type = pdu_session_type_t pdu_session_type = {
PDU_SESSION_TYPE_E_IPV4}; .pdu_session_type = PDU_SESSION_TYPE_E_IPV4};
// Extended Protocol Discriminator // Extended Protocol Discriminator
pcr.set_epd(nas_msg.header.extended_protocol_discriminator); pcr.set_epd(nas_msg.header.extended_protocol_discriminator);
// Message Type // Message Type
...@@ -634,3 +634,15 @@ void xgpp_conv::update_sm_context_response_from_ctx_request( ...@@ -634,3 +634,15 @@ void xgpp_conv::update_sm_context_response_from_ctx_request(
ct_response->res.set_snssai(ct_request->req.get_snssai()); ct_response->res.set_snssai(ct_request->req.get_snssai());
ct_response->res.set_dnn(ct_request->req.get_dnn()); ct_response->res.set_dnn(ct_request->req.get_dnn());
} }
//------------------------------------------------------------------------------
void xgpp_conv::sd_string_to_int(const std::string& sd_str, uint32_t& sd) {
sd = 0xFFFFFF;
try {
sd = std::stoul(sd_str, nullptr, 10);
} catch (const std::exception& e) {
Logger::smf_app().warn(
"Error when converting from string to int for S-NSSAI SD, error: %s",
e.what());
}
}
...@@ -169,6 +169,7 @@ void update_sm_context_response_from_ctx_request( ...@@ -169,6 +169,7 @@ void update_sm_context_response_from_ctx_request(
const std::shared_ptr<itti_n11_update_sm_context_request>& ct_request, const std::shared_ptr<itti_n11_update_sm_context_request>& ct_request,
std::shared_ptr<itti_n11_update_sm_context_response>& ct_response); std::shared_ptr<itti_n11_update_sm_context_response>& ct_response);
void sd_string_to_int(const std::string& sd_str, uint32_t& sd);
} // namespace xgpp_conv } // namespace xgpp_conv
#endif /* FILE_3GPP_CONVERSIONS_HPP_SEEN */ #endif /* FILE_3GPP_CONVERSIONS_HPP_SEEN */
...@@ -785,8 +785,8 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -785,8 +785,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
std::string n1_sm_message, n1_sm_message_hex; std::string n1_sm_message, n1_sm_message_hex;
nas_message_t decoded_nas_msg = {}; nas_message_t decoded_nas_msg = {};
cause_value_5gsm_e cause_n1 = {cause_value_5gsm_e::CAUSE_0_UNKNOWN}; cause_value_5gsm_e cause_n1 = {cause_value_5gsm_e::CAUSE_0_UNKNOWN};
pdu_session_type_t pdu_session_type = {.pdu_session_type = pdu_session_type_t pdu_session_type = {
PDU_SESSION_TYPE_E_IPV4}; .pdu_session_type = PDU_SESSION_TYPE_E_IPV4};
// Step 1. Decode NAS and get the necessary information // Step 1. Decode NAS and get the necessary information
int decoder_rc = smf_n1::get_instance().decode_n1_sm_container( int decoder_rc = smf_n1::get_instance().decode_n1_sm_container(
...@@ -853,8 +853,8 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -853,8 +853,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
snssai_t snssai = smreq->req.get_snssai(); snssai_t snssai = smreq->req.get_snssai();
Logger::smf_app().info( Logger::smf_app().info(
"Handle a PDU Session Create SM Context Request message from AMF, " "Handle a PDU Session Create SM Context Request message from AMF, "
"SUPI " SUPI_64_FMT ", SNSSAI SST %d, SD %s", "SUPI " SUPI_64_FMT ", SNSSAI SST %d, SD %#0x",
supi64, snssai.sST, snssai.sD.c_str()); supi64, snssai.sst, snssai.sd);
// Step 2. Verify Procedure transaction id, pdu session id, message type, // Step 2. Verify Procedure transaction id, pdu session id, message type,
// request type, etc. // request type, etc.
...@@ -1878,8 +1878,8 @@ bool smf_app::get_session_management_subscription_data( ...@@ -1878,8 +1878,8 @@ bool smf_app::get_session_management_subscription_data(
std::make_shared<dnn_configuration_t>(); std::make_shared<dnn_configuration_t>();
for (auto sub : smf_cfg.session_management_subscriptions) { for (auto sub : smf_cfg.session_management_subscriptions) {
if ((0 == dnn.compare(sub.dnn)) and (snssai.sST == sub.single_nssai.sST) and if ((0 == dnn.compare(sub.dnn)) and (snssai.sst == sub.single_nssai.sst) and
(0 == snssai.sD.compare(sub.single_nssai.sD))) { (snssai.sd == sub.single_nssai.sd)) {
// PDU Session Type // PDU Session Type
pdu_session_type_t pdu_session_type( pdu_session_type_t pdu_session_type(
pdu_session_type_e::PDU_SESSION_TYPE_E_IPV4); pdu_session_type_e::PDU_SESSION_TYPE_E_IPV4);
...@@ -2278,14 +2278,14 @@ void smf_app::generate_smf_profile() { ...@@ -2278,14 +2278,14 @@ void smf_app::generate_smf_profile() {
for (auto sms : smf_cfg.session_management_subscriptions) { for (auto sms : smf_cfg.session_management_subscriptions) {
// SNSSAIS // SNSSAIS
snssai_t snssai = {}; snssai_t snssai = {};
snssai.sD = sms.single_nssai.sD; snssai.sd = sms.single_nssai.sd;
snssai.sST = sms.single_nssai.sST; snssai.sst = sms.single_nssai.sst;
// Verify if this SNSSAI exist // Verify if this SNSSAI exist
std::vector<snssai_t> ss = {}; std::vector<snssai_t> ss = {};
nf_instance_profile.get_nf_snssais(ss); nf_instance_profile.get_nf_snssais(ss);
bool found = false; bool found = false;
for (auto it : ss) { for (auto it : ss) {
if ((it.sD == snssai.sD) and (it.sST == snssai.sST)) { if ((it.sd == snssai.sd) and (it.sst == snssai.sst)) {
found = true; found = true;
break; break;
} }
...@@ -2296,8 +2296,8 @@ void smf_app::generate_smf_profile() { ...@@ -2296,8 +2296,8 @@ void smf_app::generate_smf_profile() {
dnn_smf_info_item_t dnn_item = {.dnn = sms.dnn}; dnn_smf_info_item_t dnn_item = {.dnn = sms.dnn};
snssai_smf_info_item_t smf_info_item = {}; snssai_smf_info_item_t smf_info_item = {};
smf_info_item.dnn_smf_info_list.push_back(dnn_item); smf_info_item.dnn_smf_info_list.push_back(dnn_item);
smf_info_item.snssai.sD = sms.single_nssai.sD; smf_info_item.snssai.sd = sms.single_nssai.sd;
smf_info_item.snssai.sST = sms.single_nssai.sST; smf_info_item.snssai.sst = sms.single_nssai.sst;
nf_instance_profile.add_smf_info_item(smf_info_item); nf_instance_profile.add_smf_info_item(smf_info_item);
} }
......
...@@ -843,8 +843,17 @@ int smf_config::load(const string& config_file) { ...@@ -843,8 +843,17 @@ int smf_config::load(const string& config_file) {
session_management_subscription_cfg.lookupValue( session_management_subscription_cfg.lookupValue(
SMF_CONFIG_STRING_SESSION_AMBR_DL, session_ambr_dl); SMF_CONFIG_STRING_SESSION_AMBR_DL, session_ambr_dl);
sub_item.single_nssai.sST = nssai_sst; sub_item.single_nssai.sst = nssai_sst;
sub_item.single_nssai.sD = nssai_sd;
sub_item.single_nssai.sd = 0xFFFFFF;
try {
sub_item.single_nssai.sd = std::stoul(nssai_sd, nullptr, 10);
} catch (const std::exception& e) {
Logger::smf_app().warn(
"Error when converting from string to int for snssai.SD, error: "
"%s",
e.what());
}
sub_item.session_type = default_session_type; sub_item.session_type = default_session_type;
sub_item.dnn = dnn; sub_item.dnn = dnn;
sub_item.ssc_mode = default_ssc_mode; sub_item.ssc_mode = default_ssc_mode;
...@@ -1062,13 +1071,13 @@ void smf_config::display() { ...@@ -1062,13 +1071,13 @@ void smf_config::display() {
nssai_str = nssai_str.append(" ") nssai_str = nssai_str.append(" ")
.append(SMF_CONFIG_STRING_NSSAI_SST) .append(SMF_CONFIG_STRING_NSSAI_SST)
.append(": ") .append(": ")
.append(std::to_string(sub.single_nssai.sST)); .append(std::to_string(sub.single_nssai.sst));
if (!boost::iequals(sub.single_nssai.sD, "0xffffff")) { if (sub.single_nssai.sd != 0xffffff) {
nssai_str = nssai_str.append(", ") nssai_str = nssai_str.append(", ")
.append(SMF_CONFIG_STRING_NSSAI_SD) .append(SMF_CONFIG_STRING_NSSAI_SD)
.append(": ") .append(": ")
.append(sub.single_nssai.sD); .append(std::to_string(sub.single_nssai.sd));
} }
Logger::smf_app().info("%s", nssai_str.c_str()); Logger::smf_app().info("%s", nssai_str.c_str());
......
...@@ -945,9 +945,9 @@ void smf_context::handle_itti_msg( ...@@ -945,9 +945,9 @@ void smf_context::handle_itti_msg(
json_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapData"] json_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapData"]
["contentId"] = N2_SM_CONTENT_ID; // NGAP part ["contentId"] = N2_SM_CONTENT_ID; // NGAP part
json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sst"] = json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sst"] =
session_report_msg.get_snssai().sST; session_report_msg.get_snssai().sst;
json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sd"] = json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sd"] =
session_report_msg.get_snssai().sD; std::to_string(session_report_msg.get_snssai().sd);
session_report_msg.set_json_data(json_data); session_report_msg.set_json_data(json_data);
...@@ -1057,7 +1057,7 @@ void smf_context::get_default_qos( ...@@ -1057,7 +1057,7 @@ void smf_context::get_default_qos(
const snssai_t& snssai, const std::string& dnn, const snssai_t& snssai, const std::string& dnn,
subscribed_default_qos_t& default_qos) { subscribed_default_qos_t& default_qos) {
Logger::smf_app().info( Logger::smf_app().info(
"Get default QoS for a PDU Session, key %d", (uint8_t) snssai.sST); "Get default QoS for a PDU Session, key %d", (uint8_t) snssai.sst);
// get the default QoS profile // get the default QoS profile
std::shared_ptr<session_management_subscription> ss = {}; std::shared_ptr<session_management_subscription> ss = {};
std::shared_ptr<dnn_configuration_t> sdc = {}; std::shared_ptr<dnn_configuration_t> sdc = {};
...@@ -3162,9 +3162,9 @@ void smf_context::handle_pdu_session_modification_network_requested( ...@@ -3162,9 +3162,9 @@ void smf_context::handle_pdu_session_modification_network_requested(
json_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapData"] json_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapData"]
["contentId"] = N2_SM_CONTENT_ID; // NGAP part ["contentId"] = N2_SM_CONTENT_ID; // NGAP part
json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sst"] = json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sst"] =
itti_msg->msg.get_snssai().sST; itti_msg->msg.get_snssai().sst;
json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sd"] = json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sd"] =
itti_msg->msg.get_snssai().sD; std::to_string(itti_msg->msg.get_snssai().sd);
json_data["n2InfoContainer"]["ranInfo"] = "SM"; json_data["n2InfoContainer"]["ranInfo"] = "SM";
json_data["pduSessionId"] = itti_msg->msg.get_pdu_session_id(); json_data["pduSessionId"] = itti_msg->msg.get_pdu_session_id();
...@@ -3561,16 +3561,7 @@ bool smf_context::handle_ho_cancellation( ...@@ -3561,16 +3561,7 @@ bool smf_context::handle_ho_cancellation(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void smf_context::get_snssai_key(const snssai_t& snssai, uint32_t& key) { void smf_context::get_snssai_key(const snssai_t& snssai, uint32_t& key) {
uint32_t sd = SD_NO_VALUE; key = (snssai.sd << 8 | snssai.sst);
try {
sd = std::stoul(snssai.sD, nullptr, 10);
} catch (const std::exception& e) {
Logger::smf_app().warn(
"Error when converting from string to int for snssai.SD, error: %s",
e.what());
}
key = (sd << 8 | snssai.sST);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -3582,11 +3573,10 @@ void smf_context::insert_dnn_subscription( ...@@ -3582,11 +3573,10 @@ void smf_context::insert_dnn_subscription(
get_snssai_key(snssai, key); get_snssai_key(snssai, key);
std::unique_lock<std::recursive_mutex> lock(m_context); std::unique_lock<std::recursive_mutex> lock(m_context);
dnn_subscriptions[key] = ss; dnn_subscriptions[key] = ss;
Logger::smf_app().info( Logger::smf_app().info(
"Inserted DNN Subscription, key: %ld (SST %d, SD %s)", key, snssai.sST, "Inserted DNN Subscription, key: %ld (SST %d, SD %#0x)", key, snssai.sst,
snssai.sD.c_str()); snssai.sd);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -3598,11 +3588,9 @@ void smf_context::insert_dnn_subscription( ...@@ -3598,11 +3588,9 @@ void smf_context::insert_dnn_subscription(
get_snssai_key(snssai, key); get_snssai_key(snssai, key);
std::unique_lock<std::recursive_mutex> lock(m_context); std::unique_lock<std::recursive_mutex> lock(m_context);
if (dnn_subscriptions.count(key) > 0) { if (dnn_subscriptions.count(key) > 0) {
std::shared_ptr<session_management_subscription> old_ss = std::shared_ptr<session_management_subscription> old_ss =
dnn_subscriptions.at(key); dnn_subscriptions.at(key);
std::shared_ptr<dnn_configuration_t> dnn_configuration = {}; std::shared_ptr<dnn_configuration_t> dnn_configuration = {};
ss.get()->find_dnn_configuration(dnn, dnn_configuration); ss.get()->find_dnn_configuration(dnn, dnn_configuration);
if (dnn_configuration != nullptr) { if (dnn_configuration != nullptr) {
...@@ -3613,8 +3601,8 @@ void smf_context::insert_dnn_subscription( ...@@ -3613,8 +3601,8 @@ void smf_context::insert_dnn_subscription(
dnn_subscriptions[key] = ss; dnn_subscriptions[key] = ss;
} }
Logger::smf_app().info( Logger::smf_app().info(
"Inserted DNN Subscription, key: %ld (SST %d, SD %s), dnn %s", key, "Inserted DNN Subscription, key: %ld (SST %d, SD %#0x), dnn %s", key,
snssai.sST, snssai.sD.c_str(), dnn.c_str()); snssai.sst, snssai.sd, dnn.c_str());
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -3645,8 +3633,8 @@ bool smf_context::find_dnn_subscription( ...@@ -3645,8 +3633,8 @@ bool smf_context::find_dnn_subscription(
get_snssai_key(snssai, key); get_snssai_key(snssai, key);
Logger::smf_app().info( Logger::smf_app().info(
"Find a DNN Subscription with key: %ld (SST %d, SD %s), map size %d", "Find a DNN Subscription with key: %ld (SST %d, SD %#0x), map size %d",
(uint8_t) snssai.sST, snssai.sD.c_str(), dnn_subscriptions.size()); (uint8_t) snssai.sst, snssai.sd, dnn_subscriptions.size());
std::unique_lock<std::recursive_mutex> lock(m_context); std::unique_lock<std::recursive_mutex> lock(m_context);
if (dnn_subscriptions.count(key) > 0) { if (dnn_subscriptions.count(key) > 0) {
...@@ -3655,8 +3643,8 @@ bool smf_context::find_dnn_subscription( ...@@ -3655,8 +3643,8 @@ bool smf_context::find_dnn_subscription(
} }
Logger::smf_app().info( Logger::smf_app().info(
"DNN subscription (SST %d, SD %s) not found", (uint8_t) snssai.sST, "DNN subscription (SST %d, SD %#0x) not found", (uint8_t) snssai.sst,
snssai.sD.c_str()); snssai.sd);
return false; return false;
} }
...@@ -4157,8 +4145,8 @@ void smf_context::handle_flexcn_event(scid_t scid, uint8_t http_version) { ...@@ -4157,8 +4145,8 @@ void smf_context::handle_flexcn_event(scid_t scid, uint8_t http_version) {
cj["pdu_session_type"] = cj["pdu_session_type"] =
sp->pdu_session_type.toString(); // PDU Session Type sp->pdu_session_type.toString(); // PDU Session Type
// NSSAI // NSSAI
cj["snssai"]["sst"] = sp->get_snssai().sST; cj["snssai"]["sst"] = sp->get_snssai().sst;
cj["snssai"]["sd"] = sp->get_snssai().sD; cj["snssai"]["sd"] = std::to_string(sp->get_snssai().sd);
cj["dnn"] = sp->get_dnn(); // DNN cj["dnn"] = sp->get_dnn(); // DNN
cj["amf_addr"] = sc->get_amf_addr(); // Serving AMF addr cj["amf_addr"] = sc->get_amf_addr(); // Serving AMF addr
......
...@@ -203,18 +203,9 @@ bool smf_n1::create_n1_pdu_session_establishment_accept( ...@@ -203,18 +203,9 @@ bool smf_n1::create_n1_pdu_session_establishment_accept(
// SNSSAI // SNSSAI
sm_msg->pdu_session_establishment_accept.snssai.len = SST_AND_SD_LENGTH; sm_msg->pdu_session_establishment_accept.snssai.len = SST_AND_SD_LENGTH;
sm_msg->pdu_session_establishment_accept.snssai.sst = sm_msg->pdu_session_establishment_accept.snssai.sst =
sm_context_res.get_snssai().sST; sm_context_res.get_snssai().sst;
sm_msg->pdu_session_establishment_accept.snssai.sd =
try { sm_context_res.get_snssai().sd;
sm_msg->pdu_session_establishment_accept.snssai.sd =
std::stoul(sm_context_res.get_snssai().sD, nullptr, 10);
} catch (const std::exception& e) {
Logger::smf_n1().warn(
"Error when converting from string to int for snssai.SD, error: %s",
e.what());
//"no SD value associated with the SST"
sm_msg->pdu_session_establishment_accept.snssai.sd = 0xFFFFFF;
}
Logger::smf_n1().debug( Logger::smf_n1().debug(
"SNSSAI SST %d, SD %#0x", "SNSSAI SST %d, SD %#0x",
......
...@@ -467,17 +467,17 @@ bool pfcp_associations::select_up_node( ...@@ -467,17 +467,17 @@ bool pfcp_associations::select_up_node(
Logger::smf_app().debug("UPF info: %s", upf_info.to_string().c_str()); Logger::smf_app().debug("UPF info: %s", upf_info.to_string().c_str());
for (auto ui : upf_info.snssai_upf_info_list) { for (auto ui : upf_info.snssai_upf_info_list) {
if (ui.snssai.sST == snssai.sST) { if (ui.snssai.sst == snssai.sst) {
if ((ui.snssai.sST <= SST_MAX_STANDARDIZED_VALUE) or if ((ui.snssai.sst <= SST_MAX_STANDARDIZED_VALUE) or
(snssai.sD.compare(ui.snssai.sD) == 0)) { (snssai.sd == ui.snssai.sd)) {
for (auto d : ui.dnn_upf_info_list) { for (auto d : ui.dnn_upf_info_list) {
if (d.dnn.compare(dnn) == 0) { if (d.dnn.compare(dnn) == 0) {
node_id = it->second->node_id; node_id = it->second->node_id;
Logger::smf_app().info( Logger::smf_app().info(
"Select the UPF for the corresponding DNN %s, NSSSAI (SD: " "Select the UPF for the corresponding DNN %s, NSSSAI (SST: "
"%s, " "%d, "
"SST: %d) ", "SD: %d) ",
d.dnn.c_str(), snssai.sD.c_str(), snssai.sST); d.dnn.c_str(), snssai.sst, snssai.sd);
return true; return true;
} }
} }
......
...@@ -542,9 +542,9 @@ void session_create_sm_context_procedure::handle_itti_msg( ...@@ -542,9 +542,9 @@ void session_create_sm_context_procedure::handle_itti_msg(
json_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapData"] json_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapData"]
["contentId"] = N2_SM_CONTENT_ID; // NGAP part ["contentId"] = N2_SM_CONTENT_ID; // NGAP part
json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sst"] = json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sst"] =
n11_triggered_pending->res.get_snssai().sST; n11_triggered_pending->res.get_snssai().sst;
json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sd"] = json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sd"] =
n11_triggered_pending->res.get_snssai().sD; std::to_string(n11_triggered_pending->res.get_snssai().sd);
json_data["n2InfoContainer"]["ranInfo"] = "SM"; json_data["n2InfoContainer"]["ranInfo"] = "SM";
// N1N2MsgTxfrFailureNotification // N1N2MsgTxfrFailureNotification
......
...@@ -203,7 +203,7 @@ void nf_profile::display() const { ...@@ -203,7 +203,7 @@ void nf_profile::display() const {
Logger::smf_app().debug("\tSNSSAI:"); Logger::smf_app().debug("\tSNSSAI:");
} }
for (auto s : snssais) { for (auto s : snssais) {
Logger::smf_app().debug("\t\t SST %d, SD %s", s.sST, s.sD.c_str()); Logger::smf_app().debug("\t\t SST %d, SD %#0x", s.sst, s.sd);
} }
if (!fqdn.empty()) { if (!fqdn.empty()) {
Logger::smf_app().debug("\tFQDN: %s", fqdn.c_str()); Logger::smf_app().debug("\tFQDN: %s", fqdn.c_str());
...@@ -235,8 +235,8 @@ void nf_profile::to_json(nlohmann::json& data) const { ...@@ -235,8 +235,8 @@ void nf_profile::to_json(nlohmann::json& data) const {
data["sNssais"] = nlohmann::json::array(); data["sNssais"] = nlohmann::json::array();
for (auto s : snssais) { for (auto s : snssais) {
nlohmann::json tmp = {}; nlohmann::json tmp = {};
tmp["sst"] = s.sST; tmp["sst"] = s.sst;
tmp["sd"] = s.sD; tmp["sd"] = std::to_string(s.sd);
data["sNssais"].push_back(tmp); data["sNssais"].push_back(tmp);
} }
if (!fqdn.empty()) { if (!fqdn.empty()) {
...@@ -282,8 +282,17 @@ void nf_profile::from_json(const nlohmann::json& data) { ...@@ -282,8 +282,17 @@ void nf_profile::from_json(const nlohmann::json& data) {
if (data.find("sNssais") != data.end()) { if (data.find("sNssais") != data.end()) {
for (auto it : data["sNssais"]) { for (auto it : data["sNssais"]) {
snssai_t s = {}; snssai_t s = {};
s.sST = it["sst"].get<int>(); s.sst = it["sst"].get<int>();
s.sD = it["sd"].get<std::string>(); s.sd = 0xFFFFFF;
try {
s.sd = std::stoul(it["sd"].get<std::string>(), nullptr, 10);
} catch (const std::exception& e) {
Logger::smf_app().warn(
"Error when converting from string to int for snssai.SD, error: %s",
e.what());
}
// s.sD = it["sd"].get<std::string>();
snssais.push_back(s); snssais.push_back(s);
} }
} }
...@@ -384,7 +393,7 @@ void smf_profile::display() const { ...@@ -384,7 +393,7 @@ void smf_profile::display() const {
for (auto s : smf_info.snssai_smf_info_list) { for (auto s : smf_info.snssai_smf_info_list) {
Logger::smf_app().debug("\t\tParameters supported by the SMF:"); Logger::smf_app().debug("\t\tParameters supported by the SMF:");
Logger::smf_app().debug( Logger::smf_app().debug(
"\t\t\tSNSSAI (SST %d, SD %s)", s.snssai.sST, s.snssai.sD.c_str()); "\t\t\tSNSSAI (SST %d, SD %#0x)", s.snssai.sst, s.snssai.sd);
for (auto d : s.dnn_smf_info_list) { for (auto d : s.dnn_smf_info_list) {
Logger::smf_app().debug("\t\t\tDNN %s", d.dnn.c_str()); Logger::smf_app().debug("\t\t\tDNN %s", d.dnn.c_str());
} }
...@@ -430,8 +439,8 @@ void smf_profile::to_json(nlohmann::json& data) const { ...@@ -430,8 +439,8 @@ void smf_profile::to_json(nlohmann::json& data) const {
data["smfInfo"]["sNssaiSmfInfoList"] = nlohmann::json::array(); data["smfInfo"]["sNssaiSmfInfoList"] = nlohmann::json::array();
for (auto s : smf_info.snssai_smf_info_list) { for (auto s : smf_info.snssai_smf_info_list) {
nlohmann::json tmp = {}; nlohmann::json tmp = {};
tmp["sNssai"]["sst"] = s.snssai.sST; tmp["sNssai"]["sst"] = s.snssai.sst;
tmp["sNssai"]["sd"] = s.snssai.sD; tmp["sNssai"]["sd"] = std::to_string(s.snssai.sd);
tmp["dnnSmfInfoList"] = nlohmann::json::array(); tmp["dnnSmfInfoList"] = nlohmann::json::array();
for (auto d : s.dnn_smf_info_list) { for (auto d : s.dnn_smf_info_list) {
nlohmann::json dnn_json = {}; nlohmann::json dnn_json = {};
...@@ -464,9 +473,19 @@ void smf_profile::from_json(const nlohmann::json& data) { ...@@ -464,9 +473,19 @@ void smf_profile::from_json(const nlohmann::json& data) {
snssai_smf_info_item_t smf_info_item = {}; snssai_smf_info_item_t smf_info_item = {};
if (it.find("sNssai") != it.end()) { if (it.find("sNssai") != it.end()) {
if (it["sNssai"].find("sst") != it["sNssai"].end()) if (it["sNssai"].find("sst") != it["sNssai"].end())
smf_info_item.snssai.sST = it["sNssai"]["sst"].get<int>(); smf_info_item.snssai.sst = it["sNssai"]["sst"].get<int>();
if (it["sNssai"].find("sd") != it["sNssai"].end()) if (it["sNssai"].find("sd") != it["sNssai"].end()) {
smf_info_item.snssai.sD = it["sNssai"]["sd"].get<std::string>(); smf_info_item.snssai.sd = 0xFFFFFF;
try {
smf_info_item.snssai.sd = std::stoul(
it["sNssai"]["sd"].get<std::string>(), nullptr, 10);
} catch (const std::exception& e) {
Logger::smf_app().warn(
"Error when converting from string to int for snssai.SD, "
"error: %s",
e.what());
}
}
} }
if (it.find("dnnSmfInfoList") != it.end()) { if (it.find("dnnSmfInfoList") != it.end()) {
for (auto d : it["dnnSmfInfoList"]) { for (auto d : it["dnnSmfInfoList"]) {
...@@ -514,7 +533,7 @@ void upf_profile::display() const { ...@@ -514,7 +533,7 @@ void upf_profile::display() const {
for (auto s : upf_info.snssai_upf_info_list) { for (auto s : upf_info.snssai_upf_info_list) {
Logger::smf_app().debug("\t\tParameters supported by the UPF:"); Logger::smf_app().debug("\t\tParameters supported by the UPF:");
Logger::smf_app().debug( Logger::smf_app().debug(
"\t\t\tSNSSAI (SST %d, SD %s)", s.snssai.sST, s.snssai.sD.c_str()); "\t\t\tSNSSAI (SST %d, SD %#0x)", s.snssai.sst, s.snssai.sd);
for (auto d : s.dnn_upf_info_list) { for (auto d : s.dnn_upf_info_list) {
Logger::smf_app().debug("\t\t\tDNN %s", d.dnn.c_str()); Logger::smf_app().debug("\t\t\tDNN %s", d.dnn.c_str());
} }
...@@ -550,8 +569,8 @@ void upf_profile::to_json(nlohmann::json& data) const { ...@@ -550,8 +569,8 @@ void upf_profile::to_json(nlohmann::json& data) const {
data["upfInfo"]["sNssaiUpfInfoList"] = nlohmann::json::array(); data["upfInfo"]["sNssaiUpfInfoList"] = nlohmann::json::array();
for (auto s : upf_info.snssai_upf_info_list) { for (auto s : upf_info.snssai_upf_info_list) {
nlohmann::json tmp = {}; nlohmann::json tmp = {};
tmp["sNssai"]["sst"] = s.snssai.sST; tmp["sNssai"]["sst"] = s.snssai.sst;
tmp["sNssai"]["sd"] = s.snssai.sD; tmp["sNssai"]["sd"] = std::to_string(s.snssai.sd);
tmp["dnnSmfInfoList"] = nlohmann::json::array(); tmp["dnnSmfInfoList"] = nlohmann::json::array();
for (auto d : s.dnn_upf_info_list) { for (auto d : s.dnn_upf_info_list) {
nlohmann::json dnn_json = {}; nlohmann::json dnn_json = {};
...@@ -598,9 +617,19 @@ void upf_profile::from_json(const nlohmann::json& data) { ...@@ -598,9 +617,19 @@ void upf_profile::from_json(const nlohmann::json& data) {
snssai_upf_info_item_t upf_info_item = {}; snssai_upf_info_item_t upf_info_item = {};
if (it.find("sNssai") != it.end()) { if (it.find("sNssai") != it.end()) {
if (it["sNssai"].find("sst") != it["sNssai"].end()) if (it["sNssai"].find("sst") != it["sNssai"].end())
upf_info_item.snssai.sST = it["sNssai"]["sst"].get<int>(); upf_info_item.snssai.sst = it["sNssai"]["sst"].get<int>();
if (it["sNssai"].find("sd") != it["sNssai"].end()) if (it["sNssai"].find("sd") != it["sNssai"].end()) {
upf_info_item.snssai.sD = it["sNssai"]["sd"].get<std::string>(); upf_info_item.snssai.sd = 0xFFFFFF;
try {
upf_info_item.snssai.sd = std::stoul(
it["sNssai"]["sd"].get<std::string>(), nullptr, 10);
} catch (const std::exception& e) {
Logger::smf_app().warn(
"Error when converting from string to int for snssai.SD, "
"error: %s",
e.what());
}
}
} }
if (it.find("dnnUpfInfoList") != it.end()) { if (it.find("dnnUpfInfoList") != it.end()) {
for (auto d : it["dnnUpfInfoList"]) { for (auto d : it["dnnUpfInfoList"]) {
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "itti.hpp" #include "itti.hpp"
#include "logger.hpp" #include "logger.hpp"
#include "mime_parser.hpp" #include "mime_parser.hpp"
#include "3gpp_conversions.hpp"
#include "smf.h" #include "smf.h"
#include "smf_app.hpp" #include "smf_app.hpp"
#include "smf_config.hpp" #include "smf_config.hpp"
...@@ -844,8 +845,8 @@ bool smf_sbi::get_sm_data( ...@@ -844,8 +845,8 @@ bool smf_sbi::get_sm_data(
std::string mnc = {}; std::string mnc = {};
conv::plmnToMccMnc(plmn, mcc, mnc); conv::plmnToMccMnc(plmn, mcc, mnc);
query_str = "?single-nssai={\"sst\":" + std::to_string(snssai.sST) + query_str = "?single-nssai={\"sst\":" + std::to_string(snssai.sst) +
",\"sd\":\"" + snssai.sD + "\"}&dnn=" + dnn + ",\"sd\":\"" + std::to_string(snssai.sd) + "\"}&dnn=" + dnn +
"&plmn-id={\"mcc\":\"" + mcc + "\",\"mnc\":\"" + mnc + "\"}"; "&plmn-id={\"mcc\":\"" + mcc + "\",\"mnc\":\"" + mnc + "\"}";
std::string url = std::string url =
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))) +
...@@ -906,13 +907,16 @@ bool smf_sbi::get_sm_data( ...@@ -906,13 +907,16 @@ bool smf_sbi::get_sm_data(
if (jsonData.find("singleNssai") == jsonData.end()) return false; if (jsonData.find("singleNssai") == jsonData.end()) return false;
if (jsonData["singleNssai"].find("sst") != jsonData["singleNssai"].end()) { if (jsonData["singleNssai"].find("sst") != jsonData["singleNssai"].end()) {
uint8_t sst = jsonData["singleNssai"]["sst"].get<uint8_t>(); uint8_t sst = jsonData["singleNssai"]["sst"].get<uint8_t>();
if (sst != snssai.sST) { if (sst != snssai.sst) {
return false; return false;
} }
} }
if (jsonData["singleNssai"].find("sd") != jsonData["singleNssai"].end()) { if (jsonData["singleNssai"].find("sd") != jsonData["singleNssai"].end()) {
std::string sd = jsonData["singleNssai"]["sd"]; std::string sd_str = jsonData["singleNssai"]["sd"];
if (sd.compare(snssai.sD) != 0) { uint32_t sd = 0xFFFFFF;
xgpp_conv::sd_string_to_int(
jsonData["singleNssai"]["sd"].get<std::string>(), sd);
if (sd != snssai.sd) {
return false; return false;
} }
} }
......
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