From 2b7ef9b4a8ef7c14399b07550f34f0c391bc4ae7 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Fri, 8 Nov 2019 16:24:19 +0100 Subject: [PATCH] SRSENB: Fixed rr.conf cell list example parsing errors and segfault --- srsenb/rr.conf.example | 59 +++++++++++++++++++----------------- srsenb/src/enb_cfg_parser.cc | 40 ++++++++++++++++-------- 2 files changed, 59 insertions(+), 40 deletions(-) diff --git a/srsenb/rr.conf.example b/srsenb/rr.conf.example index 9c0d40a85..ae38b37a5 100644 --- a/srsenb/rr.conf.example +++ b/srsenb/rr.conf.example @@ -52,35 +52,38 @@ phy_cnfg = cell_list = ( - // rf_port = 0; - // cell_id = 0x01; - // tac = 0x0001; - // pci = 1; - // root_seq_idx = 204; - // dl_earfcn = 3400; - // ul_earfcn = 474; + { + // rf_port = 0; + // cell_id = 0x01; + // tac = 0x0001; + // pci = 1; + // root_seq_idx = 204; + // dl_earfcn = 3400; + // ul_earfcn = 474; - // CA cells - scell_list = ( - {cell_id = 0x02; cross_carrier_scheduling = false; scheduling_cell_id = 0x02; ul_allowed = true}; - ); + // CA cells + scell_list = ( + {cell_id = 0x02; cross_carrier_scheduling = false; scheduling_cell_id = 0x02; ul_allowed = true} + ) - // Cells available for handover - meas_cell_list = - ( - //{ - // cell_idx = 0x19C02; - // dl_earfcn = 2850; - // pci = 2; - //} - ); + // Cells available for handover + meas_cell_list = + ( + //{ + // cell_idx = 0x19C02; + // dl_earfcn = 2850; + // pci = 2; + //} + ); - // ReportCfg (only A3 supported) - meas_report_desc = { - a3_report_type = "RSRP"; - a3_offset = 6; - a3_hysteresis = 0; - a3_time_to_trigger = 480; - rsrq_config = 4; - }; + // ReportCfg (only A3 supported) + meas_report_desc = { + a3_report_type = "RSRP"; + a3_offset = 6; + a3_hysteresis = 0; + a3_time_to_trigger = 480; + rsrq_config = 4; + }; + }, + // Add here more cells ); diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index 273b2e783..9a99f4fed 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -1214,23 +1214,24 @@ static int parse_cell_list(all_args_t* args, rrc_cfg_t* rrc_cfg, Setting& root) rrc_cfg->cell_list.resize(root.getLength()); for (uint32_t n = 0; n < rrc_cfg->cell_list.size(); ++n) { cell_cfg_t& cell_cfg = rrc_cfg->cell_list[n]; + auto& cellroot = root[n]; - parse_opt_field(cell_cfg.rf_port, root[n], "rf_port"); - parse_default_field(cell_cfg.cell_id, root[n], "cell_id", self_cellid, cell_id_parser); - parse_default_field(cell_cfg.tac, root[n], "tac", args->stack.s1ap.tac); - parse_default_field(cell_cfg.pci, root[n], "pci", args->enb.pci); + parse_opt_field(cell_cfg.rf_port, cellroot, "rf_port"); + parse_default_field(cell_cfg.cell_id, cellroot, "cell_id", self_cellid, cell_id_parser); + parse_default_field(cell_cfg.tac, cellroot, "tac", args->stack.s1ap.tac); + parse_default_field(cell_cfg.pci, cellroot, "pci", args->enb.pci); parse_default_field( - cell_cfg.root_seq_idx, root[n], "root_seq_idx", rrc_cfg->sibs[1].sib2().rr_cfg_common.prach_cfg.root_seq_idx); - parse_default_field(cell_cfg.dl_earfcn, root[n], "dl_earfcn", args->enb.dl_earfcn); - parse_default_field(cell_cfg.ul_earfcn, root[n], "ul_earfcn", args->enb.ul_earfcn); + cell_cfg.root_seq_idx, cellroot, "root_seq_idx", rrc_cfg->sibs[1].sib2().rr_cfg_common.prach_cfg.root_seq_idx); + parse_default_field(cell_cfg.dl_earfcn, cellroot, "dl_earfcn", args->enb.dl_earfcn); + parse_default_field(cell_cfg.ul_earfcn, cellroot, "ul_earfcn", args->enb.ul_earfcn); - HANDLEPARSERCODE(parse_meas_cell_list(&rrc_cfg->meas_cfg, root[n]["meas_cell_list"])); - HANDLEPARSERCODE(parse_meas_report_desc(&rrc_cfg->meas_cfg, root[n]["meas_report_desc"])); + HANDLEPARSERCODE(parse_meas_cell_list(&rrc_cfg->meas_cfg, cellroot["meas_cell_list"])); + HANDLEPARSERCODE(parse_meas_report_desc(&rrc_cfg->meas_cfg, cellroot["meas_report_desc"])); - cell_cfg.scell_list.resize(root["scell_list"].getLength()); + cell_cfg.scell_list.resize(cellroot["scell_list"].getLength()); for (uint32_t i = 0; i < cell_cfg.scell_list.size(); ++i) { auto& scell = cell_cfg.scell_list[i]; - auto& scellroot = root["scell_list"][i]; + auto& scellroot = cellroot["scell_list"][i]; cell_id_parser(scell.cell_id, scellroot["cell_id"]); scell.cross_carrier_sched = (bool)scellroot["cross_carrier_scheduling"]; cell_id_parser(scell.sched_cell_id, scellroot["scheduling_cell_id"]); @@ -1238,12 +1239,27 @@ static int parse_cell_list(all_args_t* args, rrc_cfg_t* rrc_cfg, Setting& root) } } + // Configuration check + for (auto it = rrc_cfg->cell_list.begin(); it != rrc_cfg->cell_list.end(); it++) { + for (auto it2 = it + 1; it2 != rrc_cfg->cell_list.end(); it2++) { + // Check RF port is not repeated + if (it->rf_port == it2->rf_port) { + ERROR("Repeated RF port for multiple cells\n"); + } + + // Check cell ID is not repeated + if (it->cell_id == it2->cell_id) { + ERROR("Repeated Cell identifier\n"); + } + } + } + return SRSLTE_SUCCESS; } int cell_list_section::parse(libconfig::Setting& root) { - HANDLEPARSERCODE(parse_cell_list(args, rrc_cfg, root["cell_list"])); + HANDLEPARSERCODE(parse_cell_list(args, rrc_cfg, root)); return 0; }