diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2018-03-05 02:09:40 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2018-03-07 15:34:48 +0000 |
commit | f93970b167aba2805cc67e1326591f31fbe93ada (patch) | |
tree | fefb1abf602475204e443563b634596df9ff5444 /tests | |
parent | 56dec0c75358fe42954f9e7949ebd0c163377b10 (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 'tests')
-rw-r--r-- | tests/abis/abis_test.c | 12 | ||||
-rw-r--r-- | tests/abis/abis_test.ok | 6 | ||||
-rw-r--r-- | tests/bssap/bssap_test.err | 2 | ||||
-rwxr-xr-x | tests/ctrl_test_runner.py | 22 | ||||
-rw-r--r-- | tests/gsm0408/gsm0408_test.c | 9 | ||||
-rw-r--r-- | tests/gsm0408/gsm0408_test.ok | 6 | ||||
-rw-r--r-- | tests/nanobts_omlattr/nanobts_omlattr_test.c | 3 |
7 files changed, 27 insertions, 33 deletions
diff --git a/tests/abis/abis_test.c b/tests/abis/abis_test.c index 6369b0701..bb70a1505 100644 --- a/tests/abis/abis_test.c +++ b/tests/abis/abis_test.c @@ -101,8 +101,7 @@ static const struct test_abis_nm_ipaccess_cgi test_abis_nm_ipaccess_cgi_data[] = .plmn = { .mcc = 1, .mnc = 2, .mnc_3_digits = true }, .lac = 3, .cell_identity = 4, - .expect = "00f120" /* FAIL: should be "002100" */ - "0003" "0004", + .expect = "002100" "0003" "0004", }, { .plmn = { .mcc = 0, .mnc = 0, .mnc_3_digits = false }, @@ -114,8 +113,7 @@ static const struct test_abis_nm_ipaccess_cgi test_abis_nm_ipaccess_cgi_data[] = .plmn = { .mcc = 0, .mnc = 0, .mnc_3_digits = true }, .lac = 0, .cell_identity = 0, - .expect = "00f000" /* FAIL: should be "000000" */ - "0000" "0000", + .expect = "000000" "0000" "0000", }, { .plmn = { .mcc = 999, .mnc = 999, .mnc_3_digits = false }, @@ -133,8 +131,7 @@ static const struct test_abis_nm_ipaccess_cgi test_abis_nm_ipaccess_cgi_data[] = .plmn = { .mcc = 909, .mnc = 90, .mnc_3_digits = true }, .lac = 0xabcd, .cell_identity = 0x2345, - .expect = "09f909" /* FAIL: should be "090990" */ - "abcd" "2345", + .expect = "090990" "abcd" "2345", }, }; @@ -151,8 +148,7 @@ static void test_abis_nm_ipaccess_cgi() char *result; bool ok; - net.country_code = t->plmn.mcc; - net.network_code = t->plmn.mnc; + net.plmn = t->plmn; bts.network = &net; bts.location_area_code = t->lac; bts.cell_identity = t->cell_identity; diff --git a/tests/abis/abis_test.ok b/tests/abis/abis_test.ok index ff7772c07..e7e309c5f 100644 --- a/tests/abis/abis_test.ok +++ b/tests/abis/abis_test.ok @@ -8,9 +8,9 @@ SELECTED: 1 SELECTED: 0 test_sw_selection(): OK test_abis_nm_ipaccess_cgi[0]: result=00f12000030004 pass -test_abis_nm_ipaccess_cgi[1]: result=00f12000030004 pass +test_abis_nm_ipaccess_cgi[1]: result=00210000030004 pass test_abis_nm_ipaccess_cgi[2]: result=00f00000000000 pass -test_abis_nm_ipaccess_cgi[3]: result=00f00000000000 pass +test_abis_nm_ipaccess_cgi[3]: result=00000000000000 pass test_abis_nm_ipaccess_cgi[4]: result=999999ffffffff pass test_abis_nm_ipaccess_cgi[5]: result=09f909abcd2345 pass -test_abis_nm_ipaccess_cgi[6]: result=09f909abcd2345 pass +test_abis_nm_ipaccess_cgi[6]: result=090990abcd2345 pass diff --git a/tests/bssap/bssap_test.err b/tests/bssap/bssap_test.err index 18bfbca7e..8ae3b2286 100644 --- a/tests/bssap/bssap_test.err +++ b/tests/bssap/bssap_test.err @@ -16,7 +16,7 @@ bsc_handle_udt() returned 0 2: DMSC Rx MSC UDT: 00 19 52 08 08 59 51 20 69 00 07 43 94 09 04 01 08 44 60 1a 06 04 15 f5 49 00 65 DMSC Rx MSC UDT BSSMAP PAGING -DMSC Paging IMSI 515029600703449: MCC/MNC in Cell Identifier List (515/94) do not match our network (1/1) +DMSC Paging IMSI 515029600703449: MCC-MNC in Cell Identifier List (515-94) do not match our network (001-01) bsc_handle_udt() returned 0 3: diff --git a/tests/ctrl_test_runner.py b/tests/ctrl_test_runner.py index 41765ffc6..f43c09a79 100755 --- a/tests/ctrl_test_runner.py +++ b/tests/ctrl_test_runner.py @@ -371,32 +371,32 @@ class TestCtrlBSC(TestCtrlBase): r = self.do_get('mcc') self.assertEquals(r['mtype'], 'GET_REPLY') self.assertEquals(r['var'], 'mcc') - self.assertEquals(r['value'], '23') + self.assertEquals(r['value'], '023') r = self.do_set('mcc', '023') r = self.do_get('mcc') self.assertEquals(r['mtype'], 'GET_REPLY') self.assertEquals(r['var'], 'mcc') - self.assertEquals(r['value'], '23') + self.assertEquals(r['value'], '023') def testMnc(self): r = self.do_set('mnc', '9') r = self.do_get('mnc') self.assertEquals(r['mtype'], 'GET_REPLY') self.assertEquals(r['var'], 'mnc') - self.assertEquals(r['value'], '9') + self.assertEquals(r['value'], '09') r = self.do_set('mnc', '09') r = self.do_get('mnc') self.assertEquals(r['mtype'], 'GET_REPLY') self.assertEquals(r['var'], 'mnc') - self.assertEquals(r['value'], '9') + self.assertEquals(r['value'], '09') r = self.do_set('mnc', '009') r = self.do_get('mnc') self.assertEquals(r['mtype'], 'GET_REPLY') self.assertEquals(r['var'], 'mnc') - self.assertEquals(r['value'], '9') # FAIL: expecting '009' + self.assertEquals(r['value'], '009') def testMccMncApply(self): @@ -434,7 +434,7 @@ class TestCtrlBSC(TestCtrlBase): r = self.do_get('mnc') self.assertEquals(r['mtype'], 'GET_REPLY') self.assertEquals(r['var'], 'mnc') - self.assertEquals(r['value'], '4') + self.assertEquals(r['value'], '04') r = self.do_get('mcc') self.assertEquals(r['mtype'], 'GET_REPLY') @@ -450,7 +450,7 @@ class TestCtrlBSC(TestCtrlBase): r = self.do_get('mnc') self.assertEquals(r['mtype'], 'GET_REPLY') self.assertEquals(r['var'], 'mnc') - self.assertEquals(r['value'], '3') + self.assertEquals(r['value'], '03') r = self.do_get('mcc') self.assertEquals(r['mtype'], 'GET_REPLY') @@ -466,12 +466,12 @@ class TestCtrlBSC(TestCtrlBase): r = self.do_get('mnc') self.assertEquals(r['mtype'], 'GET_REPLY') self.assertEquals(r['var'], 'mnc') - self.assertEquals(r['value'], '3') # FAIL: expecting '003' + self.assertEquals(r['value'], '003') r = self.do_get('mcc') self.assertEquals(r['mtype'], 'GET_REPLY') self.assertEquals(r['var'], 'mcc') - self.assertEquals(r['value'], '2') + self.assertEquals(r['value'], '002') # Set same MNC with 3 digits r = self.do_set('mcc-mnc-apply', '2,003') @@ -482,12 +482,12 @@ class TestCtrlBSC(TestCtrlBase): r = self.do_get('mnc') self.assertEquals(r['mtype'], 'GET_REPLY') self.assertEquals(r['var'], 'mnc') - self.assertEquals(r['value'], '3') # FAIL: expecting '003' + self.assertEquals(r['value'], '003') r = self.do_get('mcc') self.assertEquals(r['mtype'], 'GET_REPLY') self.assertEquals(r['var'], 'mcc') - self.assertEquals(r['value'], '2') + self.assertEquals(r['value'], '002') class TestCtrlNAT(TestCtrlBase): diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c index 9f5a5c41f..e8d5501bb 100644 --- a/tests/gsm0408/gsm0408_test.c +++ b/tests/gsm0408/gsm0408_test.c @@ -730,7 +730,7 @@ static const struct test_gsm48_ra_id_by_bts test_gsm48_ra_id_by_bts_data[] = { .lac = 3, .rac = 4, .expect = { - .digits = { 0x00, 0xf1, 0x20 }, /* FAIL: should be { 0x00, 0x21, 0x00 }, */ + .digits = { 0x00, 0x21, 0x00 }, .lac = 0x0300, /* network byte order of 3 */ .rac = 4, }, @@ -748,7 +748,7 @@ static const struct test_gsm48_ra_id_by_bts test_gsm48_ra_id_by_bts_data[] = { .lac = 0, .rac = 0, .expect = { - .digits = { 0x00, 0xf0, 0x00 }, /* FAIL: should be { 0, 0, 0 } */ + .digits = {}, }, }, { @@ -776,7 +776,7 @@ static const struct test_gsm48_ra_id_by_bts test_gsm48_ra_id_by_bts_data[] = { .lac = 0xabcd, .rac = 0xab, .expect = { - .digits = { 0x09, 0xf9, 0x09 }, /* FAIL: should be { 0x09, 0x09, 0x90 }, */ + .digits = { 0x09, 0x09, 0x90 }, .lac = 0xcdab, .rac = 0xab, }, @@ -795,8 +795,7 @@ static void test_gsm48_ra_id_by_bts() struct gsm48_ra_id result = {}; bool ok; - net.country_code = t->plmn.mcc; - net.network_code = t->plmn.mnc; + net.plmn = t->plmn; bts.network = &net; bts.location_area_code = t->lac; bts.gprs.rac = t->rac; diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok index 686018bcd..00f87d556 100644 --- a/tests/gsm0408/gsm0408_test.ok +++ b/tests/gsm0408/gsm0408_test.ok @@ -215,10 +215,10 @@ SI5: 06 1d 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 SI5bis: 06 05 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 SI5ter: 06 06 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 test_gsm48_ra_id_by_bts[0]: digits='00f120' lac=0x0300=htons(3) rac=0x04=4 pass -test_gsm48_ra_id_by_bts[1]: digits='00f120' lac=0x0300=htons(3) rac=0x04=4 pass +test_gsm48_ra_id_by_bts[1]: digits='002100' lac=0x0300=htons(3) rac=0x04=4 pass test_gsm48_ra_id_by_bts[2]: digits='00f000' lac=0x0000=htons(0) rac=0x00=0 pass -test_gsm48_ra_id_by_bts[3]: digits='00f000' lac=0x0000=htons(0) rac=0x00=0 pass +test_gsm48_ra_id_by_bts[3]: digits='000000' lac=0x0000=htons(0) rac=0x00=0 pass test_gsm48_ra_id_by_bts[4]: digits='999999' lac=0xffff=htons(65535) rac=0xff=255 pass test_gsm48_ra_id_by_bts[5]: digits='09f909' lac=0xcdab=htons(43981) rac=0xab=171 pass -test_gsm48_ra_id_by_bts[6]: digits='09f909' lac=0xcdab=htons(43981) rac=0xab=171 pass +test_gsm48_ra_id_by_bts[6]: digits='090990' lac=0xcdab=htons(43981) rac=0xab=171 pass Done. diff --git a/tests/nanobts_omlattr/nanobts_omlattr_test.c b/tests/nanobts_omlattr/nanobts_omlattr_test.c index 0554f4393..6fa221c9d 100644 --- a/tests/nanobts_omlattr/nanobts_omlattr_test.c +++ b/tests/nanobts_omlattr/nanobts_omlattr_test.c @@ -218,8 +218,7 @@ int main(int argc, char **argv) bts->rach_ldavg_slots = -1; bts->c0->arfcn = 866; bts->cell_identity = 1337; - bts->network->country_code = 1; - bts->network->network_code = 1; + bts->network->plmn = (struct osmo_plmn_id){ .mcc=1, .mnc=1 }; bts->location_area_code = 1; bts->gprs.rac = 0; uint8_t attr_bts_expected[] = |