Revert "library/GSM_Types: fix encoding of BcdMccMnc (3 octets)"

This is a partial revert of e9858efb90.

I was confused by weird MCC/MNC values in the Destination RAI generated
by the NACC testcases from the PCU_Tests.ttcn.  As I figured out, these
values are not from the INFO.ind, but some hard-coded literals:

* SRC RAI: MCC=262/MNC=42/LAC=13135/RAC=0 (from ts_PCUIF_INFO_default);
* DST RAI: MCC=023/MNC=43/LAC=00423/RAC=2 (resolved by test itself);

so actually they're not incorrect: they're sent by the testsuite itself
in response to the Neighbor Address Resolution Request, and then
expected to be received in the Destination RAI from the PCU.

Another important point is that TITAN produces different results when:

a) converting BcdMccMnc to bytes using the hex2oct() function,
b) converting BcdMccMnc to bytes using the RAW encoder.

The key difference is that TITAN does swap nibbles in each byte when
using the RAW encoder, but does not when using the hex2oct() function.

Use the proper hexorder (low-to-high) in f_enc_BcdMccMnc().
Add a selftest to make sure we're encoding the input properly.

This change makes the NACC testcases pass again.

Change-Id: I6f497b97c4f1e270803e01530be8355beea740bb
Related: SYS#5602
Fixes: OS#5901
This commit is contained in:
Vadim Yanitskiy 2023-02-10 05:21:29 +07:00 committed by fixeria
parent 8a7437b09b
commit 25cd0dc4c8
1 changed files with 21 additions and 2 deletions

View File

@ -443,8 +443,11 @@ function f_enc_BcdMccMnc(GsmMcc mcc, GsmMnc mnc) return BcdMccMnc {
/* 3GPP TS 24.008, Figure 10.5.13
* | MCC digit 2 | MCC digit 1 | octet 1
* | MNC digit 3 | MCC digit 3 | octet 2
* | MNC digit 2 | MNC digit 1 | octet 3 */
return mcc[1] & mcc[0] & mnc[2] & mcc[2] & mnc[1] & mnc[0];
* | MNC digit 2 | MNC digit 1 | octet 3
*
* NOTE: TITAN takes care of swapping the nibbles in octets,
* so we use the normal (low-to-high) ordering here. */
return mcc[0] & mcc[1] & mcc[2] & mnc[2] & mnc[0] & mnc[1];
}
/* Compute BcdMccMnc from integer values */
@ -460,6 +463,22 @@ function f_enc_BcdMccMnc_int(uint16_t mcc, uint16_t mnc, boolean mnc_3_digits) r
}
}
testcase TC_selftest_enc_BcdMccMnc() runs on Dummy_CT {
if (not match('62F224'O, decmatch BcdMccMnc:'262F42'H)) { setverdict(fail); }
if (not match('21F354'O, decmatch BcdMccMnc:'123F45'H)) { setverdict(fail); }
if (not match('216354'O, decmatch BcdMccMnc:'123645'H)) { setverdict(fail); }
if (not match(f_enc_BcdMccMnc('262'H, '42'H), BcdMccMnc:'262F42'H)) { setverdict(fail); }
if (not match(f_enc_BcdMccMnc('123'H, '45'H), BcdMccMnc:'123F45'H)) { setverdict(fail); }
if (not match(f_enc_BcdMccMnc('123'H, '456'H), BcdMccMnc:'123645'H)) { setverdict(fail); }
if (not match(f_enc_BcdMccMnc_int(262, 42, false), BcdMccMnc:'262F42'H)) { setverdict(fail); }
if (not match(f_enc_BcdMccMnc_int(123, 45, false), BcdMccMnc:'123F45'H)) { setverdict(fail); }
if (not match(f_enc_BcdMccMnc_int(123, 456, true), BcdMccMnc:'123645'H)) { setverdict(fail); }
setverdict(pass);
}
/* 24.008 10.5.1.3 */
type record LocationAreaIdentification {
BcdMccMnc mcc_mnc,