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

This is a partial revert of e9858efb90a2997e2a54161d7b5213d8bac51b6e.

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
diff --git a/library/GSM_Types.ttcn b/library/GSM_Types.ttcn
index 134edbd..0068cb8 100644
--- a/library/GSM_Types.ttcn
+++ b/library/GSM_Types.ttcn
@@ -443,8 +443,11 @@
 	/* 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 @@
 	}
 }
 
+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,