aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bsc/osmo_bsc_vty.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-03-05 02:09:40 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2018-03-07 15:34:48 +0000
commitf93970b167aba2805cc67e1326591f31fbe93ada (patch)
treefefb1abf602475204e443563b634596df9ff5444 /src/osmo-bsc/osmo_bsc_vty.c
parent56dec0c75358fe42954f9e7949ebd0c163377b10 (diff)
implement support for 3-digit MNC with leading zeros
Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). The changes to abis_test and gsm0408_test show that this code now handles 3-digit MNC correctly, by not dropping the leading zero as 0xf in the encoded PLMN. Re-implement CTRL commands 'mcc', 'mnc' and 'mcc-mnc-apply' to preserve the presence of the third digit of the MNC. Always reply with all leading zeros. Adjust the expected results in ctrl_test_runner.py, to show that it works. In VTY and CTRL, the parsing of MCC and MNC is inherently made stricter by use of osmo_{mcc,mnc}_from_str() -- they will no longer allow surplus characters and detect errno returned by strtol() (in contrast to atoi()). Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore), I020a4f11791c61742a3d795f782805f7b7e8733e (libosmocore) Change-Id: I8e722103344186fde118b26d8353db95a4581daa
Diffstat (limited to 'src/osmo-bsc/osmo_bsc_vty.c')
-rw-r--r--src/osmo-bsc/osmo_bsc_vty.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/osmo-bsc/osmo_bsc_vty.c b/src/osmo-bsc/osmo_bsc_vty.c
index e173b4a7b..3455d01af 100644
--- a/src/osmo-bsc/osmo_bsc_vty.c
+++ b/src/osmo-bsc/osmo_bsc_vty.c
@@ -27,6 +27,7 @@
#include <osmocom/bsc/bsc_msg_filter.h>
#include <osmocom/core/talloc.h>
+#include <osmocom/gsm/gsm48.h>
#include <osmocom/vty/logging.h>
#include <osmocom/mgcp_client/mgcp_client.h>
@@ -107,12 +108,12 @@ static void write_msc(struct vty *vty, struct bsc_msc_data *msc)
struct bsc_msc_dest *dest;
vty_out(vty, "msc %d%s", msc->nr, VTY_NEWLINE);
- if (msc->core_mnc != -1)
- vty_out(vty, " core-mobile-network-code %d%s",
- msc->core_mnc, VTY_NEWLINE);
- if (msc->core_mcc != -1)
- vty_out(vty, " core-mobile-country-code %d%s",
- msc->core_mcc, VTY_NEWLINE);
+ if (msc->core_plmn.mnc != GSM_MCC_MNC_INVALID)
+ vty_out(vty, " core-mobile-network-code %s%s",
+ osmo_mnc_name(msc->core_plmn.mnc, msc->core_plmn.mnc_3_digits), VTY_NEWLINE);
+ if (msc->core_plmn.mcc != GSM_MCC_MNC_INVALID)
+ vty_out(vty, " core-mobile-country-code %s%s",
+ osmo_mcc_name(msc->core_plmn.mcc), VTY_NEWLINE);
if (msc->core_lac != -1)
vty_out(vty, " core-location-area-code %d%s",
msc->core_lac, VTY_NEWLINE);
@@ -236,7 +237,15 @@ DEFUN(cfg_net_bsc_ncc,
"Use this network code for the core network\n" "MNC value\n")
{
struct bsc_msc_data *data = bsc_msc_data(vty);
- data->core_mnc = atoi(argv[0]);
+ uint16_t mnc;
+ bool mnc_3_digits;
+
+ if (osmo_mnc_from_str(argv[0], &mnc, &mnc_3_digits)) {
+ vty_out(vty, "%% Error decoding MNC: %s%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ data->core_plmn.mnc = mnc;
+ data->core_plmn.mnc_3_digits = mnc_3_digits;
return CMD_SUCCESS;
}
@@ -245,8 +254,13 @@ DEFUN(cfg_net_bsc_mcc,
"core-mobile-country-code <1-999>",
"Use this country code for the core network\n" "MCC value\n")
{
+ uint16_t mcc;
struct bsc_msc_data *data = bsc_msc_data(vty);
- data->core_mcc = atoi(argv[0]);
+ if (osmo_mcc_from_str(argv[0], &mcc)) {
+ vty_out(vty, "%% Error decoding MCC: %s%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ data->core_plmn.mcc = mcc;
return CMD_SUCCESS;
}