From dc8c85f330eddbb2c88becee73443894272a43be Mon Sep 17 00:00:00 2001 From: Matan Perelman Date: Tue, 22 Feb 2022 17:10:39 +0200 Subject: [PATCH] Add additional PLMNs to sib.conf --- srsenb/sib.conf.example | 9 ++++++++ srsenb/src/enb_cfg_parser.cc | 45 +++++++++++++++++++++++++++++++++++- srsenb/src/enb_cfg_parser.h | 11 +++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/srsenb/sib.conf.example b/srsenb/sib.conf.example index c38cdbeb2..bafdcb689 100644 --- a/srsenb/sib.conf.example +++ b/srsenb/sib.conf.example @@ -1,3 +1,12 @@ +##################################################################### +# sib1 configuration options (See TS 36.331) +# +# additional_plmns: A list of additional PLMN identities. +# mcc: MCC +# mnc: MNC +# cell_reserved_for_oper: One of "reserved" or "notReserved", default is "notReserved" +# +##################################################################### sib1 = { intra_freq_reselection = "Allowed"; diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index f1351209a..99c947d01 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -70,6 +70,39 @@ bool sib_is_present(const sched_info_list_l& l, sib_type_e sib_num) return false; } +int field_additional_plmns::parse(libconfig::Setting& root) +{ + if (root.getLength() > ASN1_RRC_MAX_PLMN_MINUS1_R14) { + ERROR("PLMN-IdentityList cannot have more than %d entries", ASN1_RRC_MAX_PLMN_R11); + return SRSRAN_ERROR; + } + // Reserve the first place to the primary PLMN, see "SystemInformationBlockType1 field descriptions" in TS 36.331 + data->plmn_id_list.resize((uint32_t)root.getLength() + 1); + for (uint32_t i = 0; i < data->plmn_id_list.size() - 1; i++) { + std::string mcc_str, mnc_str; + if (!root[i].lookupValue("mcc", mcc_str)) { + ERROR("Missing field mcc in additional_plmn=%d\n", i); + return SRSRAN_ERROR; + } + + if (!root[i].lookupValue("mnc", mnc_str)) { + ERROR("Missing field mnc in additional_plmn=%d\n", i); + return SRSRAN_ERROR; + } + + srsran::plmn_id_t plmn; + if (plmn.from_string(mcc_str + mnc_str) == SRSRAN_ERROR) { + ERROR("Could not convert %s to a plmn_id in additional_plmn=%d", (mcc_str + mnc_str).c_str(), i); + return SRSRAN_ERROR; + } + srsran::to_asn1(&data->plmn_id_list[i + 1].plmn_id, plmn); + if (not parse_enum_by_str(data->plmn_id_list[i + 1].cell_reserved_for_oper, "cell_reserved_for_oper", root[i])) { + data->plmn_id_list[i + 1].cell_reserved_for_oper = plmn_id_info_s::cell_reserved_for_oper_e_::not_reserved; + } + } + return 0; +} + int field_sched_info::parse(libconfig::Setting& root) { data->sched_info_list.resize((uint32_t)root.getLength()); @@ -2161,6 +2194,13 @@ int parse_sib1(std::string filename, sib_type1_s* data) sib1.add_field(make_asn1_enum_number_parser("si_window_length", &data->si_win_len)); sib1.add_field(new parser::field("system_info_value_tag", &data->sys_info_value_tag)); + // additional_plmns subsection uses a custom field class + parser::section additional_plmns("additional_plmns"); + sib1.add_subsection(&additional_plmns); + bool dummy_bool = true; + additional_plmns.set_optional(&dummy_bool); + additional_plmns.add_field(new field_additional_plmns(&data->cell_access_related_info)); + // sched_info subsection uses a custom field class parser::section sched_info("sched_info"); sib1.add_subsection(&sched_info); @@ -2594,7 +2634,10 @@ int parse_sibs(all_args_t* args_, rrc_cfg_t* rrc_cfg_, srsenb::phy_cfg_t* phy_co return SRSRAN_ERROR; } sib_type1_s::cell_access_related_info_s_* cell_access = &sib1->cell_access_related_info; - cell_access->plmn_id_list.resize(1); + // In case additional PLMNs were given, resizing will remove them + if (cell_access->plmn_id_list.size() == 0) { + cell_access->plmn_id_list.resize(1); + } srsran::plmn_id_t plmn; if (plmn.from_string(mcc_str + mnc_str) == SRSRAN_ERROR) { ERROR("Could not convert %s to a plmn_id", (mcc_str + mnc_str).c_str()); diff --git a/srsenb/src/enb_cfg_parser.h b/srsenb/src/enb_cfg_parser.h index 08c3e1b71..dc323e69e 100644 --- a/srsenb/src/enb_cfg_parser.h +++ b/srsenb/src/enb_cfg_parser.h @@ -109,6 +109,17 @@ private: } // namespace rr_sections +class field_additional_plmns final : public parser::field_itf +{ +public: + explicit field_additional_plmns(asn1::rrc::sib_type1_s::cell_access_related_info_s_* data_) { data = data_; } + int parse(Setting& root) override; + const char* get_name() override { return "additional_plmns"; } + +private: + asn1::rrc::sib_type1_s::cell_access_related_info_s_* data; +}; + class field_sched_info final : public parser::field_itf { public: