diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-11-16 14:12:31 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-11-20 18:14:43 +0000 |
commit | 33ca61346fc5bc5216cfa3838741ef76cb5c93c8 (patch) | |
tree | ae0f2b76ee2cf3db163a42d51872d38b7d7b631a /src | |
parent | 89f3a3347f29997c384c9387f71b3d27a4a32f47 (diff) |
bsc: vty: Verify and warn on invalid arfcn passed
Related: OS#3063
Depends: libosmocore Change-Id I780d452dcebce385469e32ef2fd844df6033393a
Change-Id: Ib001501bf37289e824a1f72b62afde23892e88d2
Diffstat (limited to 'src')
-rw-r--r-- | src/osmo-bsc/bsc_vty.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c index 931db5b34..4f18d4735 100644 --- a/src/osmo-bsc/bsc_vty.c +++ b/src/osmo-bsc/bsc_vty.c @@ -3114,6 +3114,7 @@ DEFUN(cfg_bts_neigh, cfg_bts_neigh_cmd, struct gsm_bts *bts = vty->index; struct bitvec *bv = &bts->si_common.neigh_list; uint16_t arfcn = atoi(argv[1]); + enum gsm_band unused; if (bts->neigh_list_manual_mode == NL_MODE_AUTOMATIC) { vty_out(vty, "%% Cannot configure neighbor list in " @@ -3121,6 +3122,11 @@ DEFUN(cfg_bts_neigh, cfg_bts_neigh_cmd, return CMD_WARNING; } + if (gsm_arfcn2band_rc(arfcn, &unused) < 0) { + vty_out(vty, "%% Invalid arfcn %" PRIu16 " detected%s", arfcn, VTY_NEWLINE); + return CMD_WARNING; + } + if (!strcmp(argv[0], "add")) bitvec_set_bit_pos(bv, arfcn, 1); else @@ -3257,6 +3263,7 @@ DEFUN(cfg_bts_si5_neigh, cfg_bts_si5_neigh_cmd, "Delete from SI5 manual neighbor list\n" "ARFCN of neighbor\n" "ARFCN of neighbor\n") { + enum gsm_band unused; struct gsm_bts *bts = vty->index; struct bitvec *bv = &bts->si_common.si5_neigh_list; uint16_t arfcn = atoi(argv[1]); @@ -3267,6 +3274,11 @@ DEFUN(cfg_bts_si5_neigh, cfg_bts_si5_neigh_cmd, return CMD_WARNING; } + if (gsm_arfcn2band_rc(arfcn, &unused) < 0) { + vty_out(vty, "%% Invalid arfcn %" PRIu16 " detected%s", arfcn, VTY_NEWLINE); + return CMD_WARNING; + } + if (!strcmp(argv[0], "add")) bitvec_set_bit_pos(bv, arfcn, 1); else @@ -3937,8 +3949,14 @@ DEFUN(cfg_trx_arfcn, "Set the ARFCN for this TRX\n" "Absolute Radio Frequency Channel Number\n") { - int arfcn = atoi(argv[0]); + enum gsm_band unused; struct gsm_bts_trx *trx = vty->index; + int arfcn = atoi(argv[0]); + + if (gsm_arfcn2band_rc(arfcn, &unused) < 0) { + vty_out(vty, "%% Invalid arfcn %" PRIu16 " detected%s", arfcn, VTY_NEWLINE); + return CMD_WARNING; + } /* FIXME: check if this ARFCN is supported by this TRX */ @@ -4186,9 +4204,15 @@ DEFUN(cfg_ts_arfcn_add, HOPPING_STR "Configure hopping ARFCN list\n" "Add an entry to the hopping ARFCN list\n" "ARFCN\n") { + enum gsm_band unused; struct gsm_bts_trx_ts *ts = vty->index; int arfcn = atoi(argv[0]); + if (gsm_arfcn2band_rc(arfcn, &unused) < 0) { + vty_out(vty, "%% Invalid arfcn %" PRIu16 " detected%s", arfcn, VTY_NEWLINE); + return CMD_WARNING; + } + bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 1); return CMD_SUCCESS; @@ -4200,9 +4224,15 @@ DEFUN(cfg_ts_arfcn_del, HOPPING_STR "Configure hopping ARFCN list\n" "Delete an entry to the hopping ARFCN list\n" "ARFCN\n") { + enum gsm_band unused; struct gsm_bts_trx_ts *ts = vty->index; int arfcn = atoi(argv[0]); + if (gsm_arfcn2band_rc(arfcn, &unused) < 0) { + vty_out(vty, "%% Invalid arfcn %" PRIu16 " detected%s", arfcn, VTY_NEWLINE); + return CMD_WARNING; + } + bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 0); return CMD_SUCCESS; |