pespin submitted this change.

View Change



1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

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

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 change 34821. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ie2f316ccb5bc69ec15e861616de4fd5babc4004e
Gerrit-Change-Number: 34821
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin@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