From f93970b167aba2805cc67e1326591f31fbe93ada Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 5 Mar 2018 02:09:40 +0100 Subject: 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 --- include/osmocom/bsc/bsc_msc_data.h | 4 ++-- include/osmocom/bsc/gsm_data.h | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'include/osmocom/bsc') diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h index a3e0106f1..a04e632ac 100644 --- a/include/osmocom/bsc/bsc_msc_data.h +++ b/include/osmocom/bsc/bsc_msc_data.h @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -78,8 +79,7 @@ struct bsc_msc_data { struct osmo_timer_list pong_timer; int advanced_ping; struct bsc_msc_connection *msc_con; - int core_mnc; - int core_mcc; + struct osmo_plmn_id core_plmn; int core_lac; int core_ci; int rtp_base; diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 8692469b4..27aa2619e 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -1197,9 +1198,8 @@ struct gsm_network { * these have in common, like country and network code, put in yet * separate structs and placed as members in osmo_bsc and osmo_msc. */ - /* global parameters */ - uint16_t country_code; - uint16_t network_code; + struct osmo_plmn_id plmn; + /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ uint8_t a5_encryption_mask; int neci; @@ -1275,6 +1275,16 @@ struct gsm_network { } mgw; }; +static inline const struct osmo_location_area_id *bts_lai(struct gsm_bts *bts) +{ + static struct osmo_location_area_id lai; + lai = (struct osmo_location_area_id){ + .plmn = bts->network->plmn, + .lac = bts->location_area_code, + }; + return &lai; +} + extern void talloc_ctx_init(void *ctx_root); int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); -- cgit v1.2.3