fixeria submitted this change.

View Change

Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve fixeria: Looks good to me, approved
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(-)

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); }

To view, visit change 31278. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Id501ea146eb596085c204a51387f1b92300d1285
Gerrit-Change-Number: 31278
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged