Commit 684da9db authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Accept both hex and decimal value for SD from conf file

parent 64f2bae8
......@@ -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;
}
}
......@@ -50,6 +50,7 @@
#include "logger.hpp"
#include "fqdn.hpp"
#include "smf_app.hpp"
#include "3gpp_conversions.hpp"
using namespace std;
using namespace libconfig;
......@@ -844,16 +845,9 @@ int smf_config::load(const string& config_file) {
SMF_CONFIG_STRING_SESSION_AMBR_DL, session_ambr_dl);
sub_item.single_nssai.sst = nssai_sst;
sub_item.single_nssai.sd = SD_NO_VALUE;
xgpp_conv::sd_string_to_int(nssai_sd, sub_item.single_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.dnn = dnn;
sub_item.ssc_mode = default_ssc_mode;
......
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