summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-11-16 12:59:46 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2018-11-20 16:56:28 +0000
commitc8772517d9dc32da7c5e8741155e4ab638c2d01e (patch)
tree8d33db38323a32f51dc1b81a79151ddd2d92d626 /utils
parent738782467f70e13b1c6667aceb6747c2f3755f61 (diff)
gsm: Deprecate buggy gsm_arfcn2band API and introduce gsm_arfcn2band_rc
ARFCNs are values in well defined ranges. Until this patch, ARFCNs not belonging to any band were blindly assigned to DCS1800 by gsm_arfcn2band, causing unnoticed bugs and misconfigurations in osmo-bsc. Previous API gsm_arfcn2band cannot accomodate this kind of check easily, so let's deprecate it to tell people to use a new API gsm_arfcn2band_rc which performs this kind of checks and allows callers to log failures, misconfigurations, etc. At the same time, modify implementation of gsm_arfcn2band to abort if an invalid ARFCN is passed, this way users of this API can notice they are passing wrong data to it that most probably will produce unexpected results. Related: OS#3063 Change-Id: I780d452dcebce385469e32ef2fd844df6033393a
Diffstat (limited to 'utils')
-rw-r--r--utils/osmo-arfcn.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/utils/osmo-arfcn.c b/utils/osmo-arfcn.c
index 61108f8d..aee132c7 100644
--- a/utils/osmo-arfcn.c
+++ b/utils/osmo-arfcn.c
@@ -62,6 +62,7 @@ static int arfcn2freq(int arfcn)
static int freq2arfcn(int freq10, int uplink)
{
uint16_t arfcn;
+ enum gsm_band band;
if (uplink != 0 && uplink != 1) {
fprintf(stderr, "Need to specify uplink or downlink\n");
@@ -75,8 +76,13 @@ static int freq2arfcn(int freq10, int uplink)
return -EINVAL;
}
+ if (gsm_arfcn2band_rc(arfcn, &band) < 0) {
+ fprintf(stderr, "ARFCN contains no valid band\n");
+ return -EINVAL;
+ }
+
printf("%s: ARFCN %4d\n",
- gsm_band_name(gsm_arfcn2band(arfcn)),
+ gsm_band_name(band),
arfcn & ~ARFCN_FLAG_MASK);
return 0;
}