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 @@
#include <stdbool.h>
#include <ctype.h>
#include <inttypes.h>
#include <boost/algorithm/string.hpp>
#include "SmContextCreateData.h"
#include "SmContextUpdateData.h"
#include "SmContextReleaseData.h"
......@@ -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) {
sd = 0xFFFFFF;
sd = SD_NO_VALUE;
if (sd_str.empty()) return;
uint8_t base = 10;
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) {
Logger::smf_app().warn(
Logger::smf_app().error(
"Error when converting from string to int for S-NSSAI SD, error: %s",
e.what());
sd = SD_NO_VALUE;
}
}
......@@ -853,8 +853,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
snssai_t snssai = smreq->req.get_snssai();
Logger::smf_app().info(
"Handle a PDU Session Create SM Context Request message from AMF, "
"SUPI " SUPI_64_FMT ", SNSSAI SST %d, SD %#0x",
supi64, snssai.sst, snssai.sd);
"SUPI " SUPI_64_FMT ", SNSSAI SST %d, SD %ld (0x%x)",
supi64, snssai.sst, snssai.sd, snssai.sd);
// Step 2. Verify Procedure transaction id, pdu session id, message type,
// request type, etc.
......
......@@ -50,6 +50,7 @@
#include "logger.hpp"
#include "fqdn.hpp"
#include "smf_app.hpp"
#include "3gpp_conversions.hpp"
using namespace std;
using namespace libconfig;
......@@ -842,18 +843,9 @@ int smf_config::load(const string& config_file) {
SMF_CONFIG_STRING_SESSION_AMBR_UL, session_ambr_ul);
session_management_subscription_cfg.lookupValue(
SMF_CONFIG_STRING_SESSION_AMBR_DL, session_ambr_dl);
sub_item.single_nssai.sst = nssai_sst;
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.single_nssai.sd = SD_NO_VALUE;
xgpp_conv::sd_string_to_int(nssai_sd, sub_item.single_nssai.sd);
sub_item.session_type = default_session_type;
sub_item.dnn = dnn;
sub_item.ssc_mode = default_ssc_mode;
......@@ -1067,20 +1059,14 @@ void smf_config::display() {
Logger::smf_app().info(
" Session Management Subscription Data %d:", index);
std::string nssai_str = {};
nssai_str = nssai_str.append(" ")
.append(SMF_CONFIG_STRING_NSSAI_SST)
.append(": ")
.append(std::to_string(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));
if (sub.single_nssai.sd != SD_NO_VALUE) {
Logger::smf_app().info(
" SST, SD: %d, %ld (0x%x)", sub.single_nssai.sst,
sub.single_nssai.sd, sub.single_nssai.sd);
} else {
Logger::smf_app().info(" SST: %d", sub.single_nssai.sst);
}
Logger::smf_app().info("%s", nssai_str.c_str());
Logger::smf_app().info(
" " SMF_CONFIG_STRING_DNN ": %s", sub.dnn.c_str());
Logger::smf_app().info(
......
......@@ -3575,8 +3575,8 @@ void smf_context::insert_dnn_subscription(
std::unique_lock<std::recursive_mutex> lock(m_context);
dnn_subscriptions[key] = ss;
Logger::smf_app().info(
"Inserted DNN Subscription, key: %ld (SST %d, SD %#0x)", key, snssai.sst,
snssai.sd);
"Inserted DNN Subscription, key: %ld (SST %d, SD %ld (0x%x))", key,
snssai.sst, snssai.sd, snssai.sd);
}
//------------------------------------------------------------------------------
......@@ -3601,8 +3601,8 @@ void smf_context::insert_dnn_subscription(
dnn_subscriptions[key] = ss;
}
Logger::smf_app().info(
"Inserted DNN Subscription, key: %ld (SST %d, SD %#0x), dnn %s", key,
snssai.sst, snssai.sd, dnn.c_str());
"Inserted DNN Subscription, key: %ld (SST %d, SD %ld (0x%x)), dnn %s",
key, snssai.sst, snssai.sd, snssai.sd, dnn.c_str());
}
//------------------------------------------------------------------------------
......@@ -3633,8 +3633,9 @@ bool smf_context::find_dnn_subscription(
get_snssai_key(snssai, key);
Logger::smf_app().info(
"Find a DNN Subscription with key: %ld (SST %d, SD %#0x), map size %d",
(uint8_t) snssai.sst, snssai.sd, dnn_subscriptions.size());
"Find a DNN Subscription with key: %ld (SST %d, SD %ld (0x%x)), map size "
"%d",
(uint8_t) snssai.sst, snssai.sd, snssai.sd, dnn_subscriptions.size());
std::unique_lock<std::recursive_mutex> lock(m_context);
if (dnn_subscriptions.count(key) > 0) {
......@@ -3643,8 +3644,8 @@ bool smf_context::find_dnn_subscription(
}
Logger::smf_app().info(
"DNN subscription (SST %d, SD %#0x) not found", (uint8_t) snssai.sst,
snssai.sd);
"DNN subscription (SST %d, SD %ld (0x%x)) not found",
(uint8_t) snssai.sst, snssai.sd, snssai.sd);
return false;
}
......
......@@ -212,8 +212,9 @@ bool smf_n1::create_n1_pdu_session_establishment_accept(
sm_context_res.get_snssai().sd;
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.sd,
sm_msg->pdu_session_establishment_accept.snssai.sd);
// TODO: AlwaysonPDUSessionIndication
......
......@@ -476,8 +476,8 @@ bool pfcp_associations::select_up_node(
Logger::smf_app().info(
"Select the UPF for the corresponding DNN %s, NSSSAI (SST: "
"%d, "
"SD: %d) ",
d.dnn.c_str(), snssai.sst, snssai.sd);
"SD: %ld (0x%x)) ",
d.dnn.c_str(), snssai.sst, snssai.sd, snssai.sd);
return true;
}
}
......
......@@ -203,7 +203,7 @@ void nf_profile::display() const {
Logger::smf_app().debug("\tSNSSAI:");
}
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()) {
Logger::smf_app().debug("\tFQDN: %s", fqdn.c_str());
......@@ -393,7 +393,8 @@ void smf_profile::display() const {
for (auto s : smf_info.snssai_smf_info_list) {
Logger::smf_app().debug("\t\tParameters supported by the SMF:");
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) {
Logger::smf_app().debug("\t\t\tDNN %s", d.dnn.c_str());
}
......@@ -533,7 +534,8 @@ void upf_profile::display() const {
for (auto s : upf_info.snssai_upf_info_list) {
Logger::smf_app().debug("\t\tParameters supported by the UPF:");
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) {
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