library/GSM_Types: add {enc,dec}_BcdMccMnc() functions

Change-Id: Id501ea146eb596085c204a51387f1b92300d1285
Related: SYS#5602, OS#5901
diff --git a/library/GSM_Types.ttcn b/library/GSM_Types.ttcn
index d48dc6c..b234bf4 100644
--- a/library/GSM_Types.ttcn
+++ b/library/GSM_Types.ttcn
@@ -435,6 +435,13 @@
 type hexstring GsmBcdString with { variant "HEXORDER(low)" };
 type GsmBcdString BcdMccMnc with { variant "FIELDLENGTH(6)" };
 
+/* hex2oct()/oct2hex() do not respect the HEXORDER/FIELDLENGTH attributes,
+ * so better use the functions, employing TITAN's RAW codec, dclared below. */
+external function enc_BcdMccMnc(in BcdMccMnc str) return octetstring
+	with { extension "prototype(convert) encode(RAW)" };
+external function dec_BcdMccMnc(in octetstring str) return BcdMccMnc
+	with { extension "prototype(convert) decode(RAW)" };
+
 /* Compute BcdMccMnc from a pair of GsmMcc/GsmMnc values */
 function f_build_BcdMccMnc(GsmMcc mcc, GsmMnc mnc) return BcdMccMnc {
 	if (lengthof(mnc) == 2) {
@@ -468,6 +475,10 @@
 	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(enc_BcdMccMnc('262F42'H), '62F224'O)) { setverdict(fail); }
+	if (not match(enc_BcdMccMnc('123F45'H), '21F354'O)) { setverdict(fail); }
+	if (not match(enc_BcdMccMnc('123645'H), '216354'O)) { setverdict(fail); }
+
 	if (not match(f_build_BcdMccMnc('262'H,  '42'H), BcdMccMnc:'262F42'H)) { setverdict(fail); }
 	if (not match(f_build_BcdMccMnc('123'H,  '45'H), BcdMccMnc:'123F45'H)) { setverdict(fail); }
 	if (not match(f_build_BcdMccMnc('123'H, '456'H), BcdMccMnc:'123645'H)) { setverdict(fail); }