fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/31278 )
Change subject: library/GSM_Types: add {enc,dec}_BcdMccMnc() functions ......................................................................
library/GSM_Types: add {enc,dec}_BcdMccMnc() functions
Change-Id: Id501ea146eb596085c204a51387f1b92300d1285 Related: SYS#5602, OS#5901 --- M library/GSM_Types.ttcn 1 file changed, 11 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/78/31278/1
diff --git a/library/GSM_Types.ttcn b/library/GSM_Types.ttcn index d48dc6c..f47d719 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 the functions (emplying the 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); }