Change in osmo-bsc[master]: bsc: vty: Verify and warn on invalid arfcn passed

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Tue Nov 20 18:14:44 UTC 2018


Pau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/11791 )

Change subject: bsc: vty: Verify and warn on invalid arfcn passed
......................................................................

bsc: vty: Verify and warn on invalid arfcn passed

Related: OS#3063
Depends: libosmocore Change-Id I780d452dcebce385469e32ef2fd844df6033393a
Change-Id: Ib001501bf37289e824a1f72b62afde23892e88d2
---
M src/osmo-bsc/bsc_vty.c
1 file changed, 31 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Neels Hofmeyr: Looks good to me, but someone else must approve
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index 931db5b..4f18d47 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -3114,6 +3114,7 @@
 	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 @@
 		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 @@
 	"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 @@
 		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 @@
       "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 @@
 	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 @@
 	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;

-- 
To view, visit https://gerrit.osmocom.org/11791
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib001501bf37289e824a1f72b62afde23892e88d2
Gerrit-Change-Number: 11791
Gerrit-PatchSet: 5
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181120/6209c543/attachment.htm>


More information about the gerrit-log mailing list