pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34821?usp=email )


Change subject: GTPv2: Fix match of 15-digit IMSIs
......................................................................

GTPv2: Fix match of 15-digit IMSIs

15-digit IMSIs are len(imsi)=15, but decoded messages are
octet-aligned, hence the hexstring in messages is len(imsi)=16,
where the last hex char is a padding 'F'H.

* Make sure IMSIs stored in GTPv2_Emulation are padded to 16 digits (8
  octets) to process matches easily.
* Update tr_ template to transparently adapt passed hexstrings to match
  the octet-aligned value received from the wire.

Change-Id: Ie2f316ccb5bc69ec15e861616de4fd5babc4004e
---
M library/GTPv2_Emulation.ttcn
M library/GTPv2_Templates.ttcn
M library/Osmocom_Types.ttcn
3 files changed, 35 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/21/34821/1

diff --git a/library/GTPv2_Emulation.ttcn b/library/GTPv2_Emulation.ttcn
index 571da4e..736dd03 100644
--- a/library/GTPv2_Emulation.ttcn
+++ b/library/GTPv2_Emulation.ttcn
@@ -602,6 +602,10 @@
 };

 function f_gtp2_register_imsi(hexstring imsi) runs on GTP2_ConnHdlr {
+       /* 15-digit IMSIs are len(imsi)=15, but decoded messages are
+        * octet-aligned, hence the hexstring in messages is len(imsi)=16, where
+        * the last hex char is a padding 'F'H */
+       imsi := f_pad_bcd_number(imsi);
        GTP2_PROC.call(GTP2EM_register_imsi:{imsi}) {
                [] GTP2_PROC.getreply(GTP2EM_register_imsi:{imsi});
        }
diff --git a/library/GTPv2_Templates.ttcn b/library/GTPv2_Templates.ttcn
index b306955..e5022d8 100644
--- a/library/GTPv2_Templates.ttcn
+++ b/library/GTPv2_Templates.ttcn
@@ -126,7 +126,7 @@
        lengthIndicator := ?,
        instance := ?,
        spare := '0000'B,
-       iMSI_Value := imsi
+       iMSI_Value := f_pad_bcd_number_tmpl(imsi)
 }

 template (present) MSISDN ts_GTP2C_msisdn(template (present) hexstring msisdn) 
:= {
diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
index ef55583..d034a74 100644
--- a/library/Osmocom_Types.ttcn
+++ b/library/Osmocom_Types.ttcn
@@ -261,6 +261,18 @@
        }
 }

+function f_pad_bcd_number_tmpl(template hexstring inp) return template 
hexstring {
+       if (istemplatekind(inp, "omit")) {
+               return omit;
+       } else if (istemplatekind(inp, "*")) {
+               return *;
+       } else if (istemplatekind(inp, "?")) {
+               return ?;
+       } else {
+               return f_pad_bcd_number(valueof(inp));
+       }
+}
+
 /* like L1SAP_IS_PACKET_RACH */
 function ra_is_ps(OCT1 ra) return boolean {
        if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34821?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ie2f316ccb5bc69ec15e861616de4fd5babc4004e
Gerrit-Change-Number: 34821
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to