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

Merge branch 'fix_sd_ffffff' into 'develop'

Accept both hex and decimal value for SD from conf file

See merge request oai/cn5g/oai-cn5g-smf!136
parents 64f2bae8 f1b16745
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <ctype.h> #include <ctype.h>
#include <inttypes.h> #include <inttypes.h>
#include <boost/algorithm/string.hpp>
#include "SmContextCreateData.h" #include "SmContextCreateData.h"
#include "SmContextUpdateData.h" #include "SmContextUpdateData.h"
#include "SmContextReleaseData.h" #include "SmContextReleaseData.h"
...@@ -637,12 +639,20 @@ void xgpp_conv::update_sm_context_response_from_ctx_request( ...@@ -637,12 +639,20 @@ void xgpp_conv::update_sm_context_response_from_ctx_request(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void xgpp_conv::sd_string_to_int(const std::string& sd_str, uint32_t& sd) { void xgpp_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 { try {
sd = std::stoul(sd_str, nullptr, 10); if (sd_str.size() > 2) {
if (boost::iequals(sd_str.substr(0, 2), "0x")) {
base = 16;
}
}
sd = std::stoul(sd_str, nullptr, base);
} catch (const std::exception& e) { } catch (const std::exception& e) {
Logger::smf_app().warn( Logger::smf_app().error(
"Error when converting from string to int for S-NSSAI SD, error: %s", "Error when converting from string to int for S-NSSAI SD, error: %s",
e.what()); e.what());
sd = SD_NO_VALUE;
} }
} }
...@@ -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 %#0x", "SUPI " SUPI_64_FMT ", SNSSAI SST %d, SD %ld (0x%x)",
supi64, snssai.sst, snssai.sd); supi64, snssai.sst, snssai.sd, 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.
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "logger.hpp" #include "logger.hpp"
#include "fqdn.hpp" #include "fqdn.hpp"
#include "smf_app.hpp" #include "smf_app.hpp"
#include "3gpp_conversions.hpp"
using namespace std; using namespace std;
using namespace libconfig; using namespace libconfig;
...@@ -842,18 +843,9 @@ int smf_config::load(const string& config_file) { ...@@ -842,18 +843,9 @@ int smf_config::load(const string& config_file) {
SMF_CONFIG_STRING_SESSION_AMBR_UL, session_ambr_ul); SMF_CONFIG_STRING_SESSION_AMBR_UL, session_ambr_ul);
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 = SD_NO_VALUE;
sub_item.single_nssai.sd = 0xFFFFFF; xgpp_conv::sd_string_to_int(nssai_sd, sub_item.single_nssai.sd);
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;
...@@ -1067,20 +1059,14 @@ void smf_config::display() { ...@@ -1067,20 +1059,14 @@ void smf_config::display() {
Logger::smf_app().info( Logger::smf_app().info(
" Session Management Subscription Data %d:", index); " Session Management Subscription Data %d:", index);
std::string nssai_str = {}; if (sub.single_nssai.sd != SD_NO_VALUE) {
nssai_str = nssai_str.append(" ") Logger::smf_app().info(
.append(SMF_CONFIG_STRING_NSSAI_SST) " SST, SD: %d, %ld (0x%x)", sub.single_nssai.sst,
.append(": ") sub.single_nssai.sd, sub.single_nssai.sd);
.append(std::to_string(sub.single_nssai.sst)); } else {
Logger::smf_app().info(" SST: %d", sub.single_nssai.sst);
if (sub.single_nssai.sd != 0xffffff) {
nssai_str = nssai_str.append(", ")
.append(SMF_CONFIG_STRING_NSSAI_SD)
.append(": ")
.append(std::to_string(sub.single_nssai.sd));
} }
Logger::smf_app().info("%s", nssai_str.c_str());
Logger::smf_app().info( Logger::smf_app().info(
" " SMF_CONFIG_STRING_DNN ": %s", sub.dnn.c_str()); " " SMF_CONFIG_STRING_DNN ": %s", sub.dnn.c_str());
Logger::smf_app().info( Logger::smf_app().info(
......
...@@ -3575,8 +3575,8 @@ void smf_context::insert_dnn_subscription( ...@@ -3575,8 +3575,8 @@ void smf_context::insert_dnn_subscription(
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 %#0x)", key, snssai.sst, "Inserted DNN Subscription, key: %ld (SST %d, SD %ld (0x%x))", key,
snssai.sd); snssai.sst, snssai.sd, snssai.sd);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -3601,8 +3601,8 @@ void smf_context::insert_dnn_subscription( ...@@ -3601,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 %#0x), dnn %s", key, "Inserted DNN Subscription, key: %ld (SST %d, SD %ld (0x%x)), dnn %s",
snssai.sst, snssai.sd, dnn.c_str()); key, snssai.sst, snssai.sd, snssai.sd, dnn.c_str());
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -3633,8 +3633,9 @@ bool smf_context::find_dnn_subscription( ...@@ -3633,8 +3633,9 @@ 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 %#0x), map size %d", "Find a DNN Subscription with key: %ld (SST %d, SD %ld (0x%x)), map size "
(uint8_t) snssai.sst, snssai.sd, dnn_subscriptions.size()); "%d",
(uint8_t) snssai.sst, snssai.sd, 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) {
...@@ -3643,8 +3644,8 @@ bool smf_context::find_dnn_subscription( ...@@ -3643,8 +3644,8 @@ bool smf_context::find_dnn_subscription(
} }
Logger::smf_app().info( Logger::smf_app().info(
"DNN subscription (SST %d, SD %#0x) not found", (uint8_t) snssai.sst, "DNN subscription (SST %d, SD %ld (0x%x)) not found",
snssai.sd); (uint8_t) snssai.sst, snssai.sd, snssai.sd);
return false; return false;
} }
......
...@@ -212,8 +212,9 @@ bool smf_n1::create_n1_pdu_session_establishment_accept( ...@@ -212,8 +212,9 @@ bool smf_n1::create_n1_pdu_session_establishment_accept(
sm_context_res.get_snssai().sd; sm_context_res.get_snssai().sd;
Logger::smf_n1().debug( Logger::smf_n1().debug(
"SNSSAI SST %d, SD %#0x", "SNSSAI SST %d, SD %ld (0x%x)",
sm_msg->pdu_session_establishment_accept.snssai.sst, sm_msg->pdu_session_establishment_accept.snssai.sst,
sm_msg->pdu_session_establishment_accept.snssai.sd,
sm_msg->pdu_session_establishment_accept.snssai.sd); sm_msg->pdu_session_establishment_accept.snssai.sd);
// TODO: AlwaysonPDUSessionIndication // TODO: AlwaysonPDUSessionIndication
......
...@@ -476,8 +476,8 @@ bool pfcp_associations::select_up_node( ...@@ -476,8 +476,8 @@ bool pfcp_associations::select_up_node(
Logger::smf_app().info( Logger::smf_app().info(
"Select the UPF for the corresponding DNN %s, NSSSAI (SST: " "Select the UPF for the corresponding DNN %s, NSSSAI (SST: "
"%d, " "%d, "
"SD: %d) ", "SD: %ld (0x%x)) ",
d.dnn.c_str(), snssai.sst, snssai.sd); d.dnn.c_str(), snssai.sst, snssai.sd, snssai.sd);
return true; return true;
} }
} }
......
...@@ -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 %#0x", s.sst, s.sd); Logger::smf_app().debug("\t\t SST %d, SD %ld (0x%x)", s.sst, s.sd, 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());
...@@ -393,7 +393,8 @@ void smf_profile::display() const { ...@@ -393,7 +393,8 @@ 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 %#0x)", s.snssai.sst, s.snssai.sd); "\t\t\tSNSSAI (SST %d, SD %ld (0x%x))", s.snssai.sst, s.snssai.sd,
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());
} }
...@@ -533,7 +534,8 @@ void upf_profile::display() const { ...@@ -533,7 +534,8 @@ 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 %#0x)", s.snssai.sst, s.snssai.sd); "\t\t\tSNSSAI (SST %d, SD %ld (0x%x))", s.snssai.sst, s.snssai.sd,
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());
} }
......
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