diff --git a/srsenb/hdr/enb.h b/srsenb/hdr/enb.h index cf59bf6ad..740101f19 100644 --- a/srsenb/hdr/enb.h +++ b/srsenb/hdr/enb.h @@ -59,7 +59,7 @@ namespace srsenb { *******************************************************************************/ struct enb_args_t { - std::string enb_id; + uint32_t enb_id; uint32_t dl_earfcn; // By default the EARFCN from rr.conf's cell list are used but this value can be used for single // cell eNB uint32_t n_prb; diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index 0ac499ccf..97c993bd6 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -896,24 +896,10 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_ // set config for RRC's base cell rrc_cfg_->cell = cell_cfg_; - // Set S1AP related params from cell list (Convert hex strings) - { - std::stringstream sstr; - sstr << std::hex << args_->enb.enb_id; - sstr >> args_->stack.s1ap.enb_id; - } - { - std::stringstream sstr; - sstr << std::hex << rrc_cfg_->cell_list.at(0).cell_id; - uint16_t tmp; // Need intermediate uint16_t as uint8_t is treated as char - sstr >> tmp; - args_->stack.s1ap.cell_id = tmp; - } - { - std::stringstream sstr; - sstr << std::hex << rrc_cfg_->cell_list.at(0).tac; - sstr >> args_->stack.s1ap.tac; - } + // Set S1AP related params from cell list + args_->stack.s1ap.enb_id = args_->enb.enb_id; + args_->stack.s1ap.cell_id = rrc_cfg_->cell_list.at(0).cell_id; + args_->stack.s1ap.tac = rrc_cfg_->cell_list.at(0).tac; // Create dedicated cell configuration from RRC configuration for (auto& cfg : rrc_cfg_->cell_list) { diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index 43ad4a9fa..82623ab9b 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -52,6 +52,7 @@ void parse_args(all_args_t* args, int argc, char* argv[]) { string mcc; string mnc; + string enb_id; // Command line only options bpo::options_description general("General options"); @@ -65,7 +66,7 @@ void parse_args(all_args_t* args, int argc, char* argv[]) bpo::options_description common("Configuration options"); common.add_options() - ("enb.enb_id", bpo::value(&args->enb.enb_id)->default_value("0x0"), "eNodeB ID") + ("enb.enb_id", bpo::value(&enb_id)->default_value("0x0"), "eNodeB ID") ("enb.name", bpo::value(&args->stack.s1ap.enb_name)->default_value("srsenb01"), "eNodeB Name") ("enb.mcc", bpo::value(&mcc)->default_value("001"), "Mobile Country Code") ("enb.mnc", bpo::value(&mnc)->default_value("01"), "Mobile Network Code") @@ -273,6 +274,19 @@ void parse_args(all_args_t* args, int argc, char* argv[]) } } + // Covert eNB Id + std::size_t pos = {}; + try { + args->enb.enb_id = std::stoi(enb_id, &pos, 0); + } catch (...) { + cout << "Error parsing enb.enb_id: " << enb_id << "." << endl; + exit(1); + } + if (pos != enb_id.size()) { + cout << "Error parsing enb.enb_id: " << enb_id << "." << endl; + exit(1); + } + // Apply all_level to any unset layers if (vm.count("log.all_level")) { if (!vm.count("log.rf_level")) {