From 87f1b2a939ad0ece4151713485434eace677bf3c Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 3 Mar 2020 21:08:22 +0100 Subject: [PATCH] catch exceptions from eNB config parser since the eNB config gets more complex, especially with CA, we need to catch potential parsing errors from libconfig, print an error with the position of the error and gracefully stop the enb --- srsenb/src/enb_cfg_parser.cc | 45 ++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index b8a24516f..a70dbb05b 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -812,19 +812,54 @@ int parse_cfg_files(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_) // Parse config files srslte_cell_t cell_common_cfg = {}; - if (enb_conf_sections::parse_cell_cfg(args_, &cell_common_cfg) != SRSLTE_SUCCESS) { + try { + if (enb_conf_sections::parse_cell_cfg(args_, &cell_common_cfg) != SRSLTE_SUCCESS) { + fprintf(stderr, "Error parsing Cell configuration\n"); + return SRSLTE_ERROR; + } + } catch (const SettingTypeException& stex) { + fprintf(stderr, "Error parsing Cell configuration: %s\n", stex.getPath()); + return SRSLTE_ERROR; + } catch (const ConfigException& cex) { fprintf(stderr, "Error parsing Cell configuration\n"); return SRSLTE_ERROR; } - if (sib_sections::parse_sibs(args_, rrc_cfg_, phy_cfg_) != SRSLTE_SUCCESS) { - fprintf(stderr, "Error parsing SIB configuration\n"); + + try { + if (sib_sections::parse_sibs(args_, rrc_cfg_, phy_cfg_) != SRSLTE_SUCCESS) { + fprintf(stderr, "Error parsing SIB configuration\n"); + return SRSLTE_ERROR; + } + } catch (const SettingTypeException& stex) { + fprintf(stderr, "Error parsing SIB configuration: %s\n", stex.getPath()); + return SRSLTE_ERROR; + } catch (const ConfigException& cex) { + fprintf(stderr, "Error parsing SIB configurationn\n"); return SRSLTE_ERROR; } - if (rr_sections::parse_rr(args_, rrc_cfg_) != SRSLTE_SUCCESS) { + + try { + if (rr_sections::parse_rr(args_, rrc_cfg_) != SRSLTE_SUCCESS) { + fprintf(stderr, "Error parsing Radio Resources configuration\n"); + return SRSLTE_ERROR; + } + } catch (const SettingTypeException& stex) { + fprintf(stderr, "Error parsing Radio Resources configuration: %s\n", stex.getPath()); + return SRSLTE_ERROR; + } catch (const ConfigException& cex) { fprintf(stderr, "Error parsing Radio Resources configuration\n"); return SRSLTE_ERROR; } - if (drb_sections::parse_drb(args_, rrc_cfg_) != SRSLTE_SUCCESS) { + + try { + if (drb_sections::parse_drb(args_, rrc_cfg_) != SRSLTE_SUCCESS) { + fprintf(stderr, "Error parsing DRB configuration\n"); + return SRSLTE_ERROR; + } + } catch (const SettingTypeException& stex) { + fprintf(stderr, "\"Error parsing DRB configuration: %s\n", stex.getPath()); + return SRSLTE_ERROR; + } catch (const ConfigException& cex) { fprintf(stderr, "Error parsing DRB configuration\n"); return SRSLTE_ERROR; }