Change in osmo-ttcn3-hacks[master]: library/GSUP_Types.ttcn: fix MSISDN / SMSC coding in SM-RP-OA/DA

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Fri Jan 3 12:27:18 UTC 2020


fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16565 )

Change subject: library/GSUP_Types.ttcn: fix MSISDN / SMSC coding in SM-RP-OA/DA
......................................................................

library/GSUP_Types.ttcn: fix MSISDN / SMSC coding in SM-RP-OA/DA

Unlike IMSI, both MSISDN and SMSC address in SM-RP-OA/DA not only
contain the BCD encoded digits, but also a little header with
NPI (Numbering Plan Identification), ToN (Type of Number), and
Extension fields.

Change-Id: I3f55834489f3e613f541cf1e216027e8d48ccaf0
Related: OS#4324
---
M library/GSUP_Types.ttcn
M library/Osmocom_Types.ttcn
M msc/MSC_Tests.ttcn
3 files changed, 57 insertions(+), 15 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/library/GSUP_Types.ttcn b/library/GSUP_Types.ttcn
index 8977d9f..d4b1db1 100644
--- a/library/GSUP_Types.ttcn
+++ b/library/GSUP_Types.ttcn
@@ -869,6 +869,38 @@
 	OSMO_GSUP_SM_RP_ODA_ID_NULL		('FF'O)
 } with { variant "FIELDLENGTH(8)" };
 
+/* See 3GPP TS 24.011, figures 8.5 and 8.6 */
+type record GSUP_SM_RP_Addr {
+	BIT1		ext, /* Extension? */
+	BIT3		ton, /* Type of Number */
+	BIT4		npi, /* Numbering Plan Identification */
+	hexstring	number length (1..20)
+} with {
+	variant "PADDING(yes)";
+	variant "PADDING_PATTERN('1111'B)"
+};
+
+private function f_pad_SM_RP_Addr(template hexstring number)
+return template hexstring {
+	if (isvalue(number) and not istemplatekind(number, "omit")) {
+		return f_pad_bcd_number(valueof(number));
+	} else {
+		return number;
+	}
+}
+
+template GSUP_SM_RP_Addr t_GSUP_SM_RP_Addr(template hexstring number,
+					   template BIT4 npi := '0001'B,
+					   template BIT3 ton := '001'B,
+					   template BIT1 ext := '1'B) := {
+	ext := ext,
+	ton := ton,
+	npi := npi,
+	/* Work around TITAN's padding problems: encoding works fine,
+	 * but it does not consider 'F'H as padding in decoded data. */
+	number := f_pad_SM_RP_Addr(number)
+}
+
 /**
  * SM-RP-DA represents the SM Destination Address, see 7.6.8.1.
  * It can be either of the following:
@@ -879,9 +911,9 @@
  *  - service centre address
  */
 type union GSUP_SM_RP_DA_ID {
-	hexstring	imsi,
-	hexstring	msisdn,
-	hexstring	smsc_addr
+	hexstring		imsi,
+	GSUP_SM_RP_Addr		msisdn,
+	GSUP_SM_RP_Addr		smsc_addr
 };
 
 type record GSUP_SM_RP_DA {
@@ -904,20 +936,20 @@
 	id_enc := { imsi := imsi }
 }
 
-template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_MSISDN(hexstring msisdn) := {
+template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_MSISDN(GSUP_SM_RP_Addr msisdn) := {
 	id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
 	id_enc := { msisdn := msisdn }
 }
-template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_MSISDN(template hexstring msisdn) := {
+template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_MSISDN(template GSUP_SM_RP_Addr msisdn) := {
 	id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
 	id_enc := { msisdn := msisdn }
 }
 
-template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_SMSC_ADDR(hexstring smsc_addr) := {
+template (value) GSUP_SM_RP_DA ts_GSUP_SM_RP_DA_SMSC_ADDR(GSUP_SM_RP_Addr smsc_addr) := {
 	id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
 	id_enc := { smsc_addr := smsc_addr }
 }
-template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_SMSC_ADDR(template hexstring smsc_addr) := {
+template GSUP_SM_RP_DA tr_GSUP_SM_RP_DA_SMSC_ADDR(template GSUP_SM_RP_Addr smsc_addr) := {
 	id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
 	id_enc := { smsc_addr := smsc_addr }
 }
@@ -953,8 +985,8 @@
  *  - service centre address
  */
 type union GSUP_SM_RP_OA_ID {
-	hexstring	msisdn,
-	hexstring	smsc_addr
+	GSUP_SM_RP_Addr		msisdn,
+	GSUP_SM_RP_Addr		smsc_addr
 };
 
 type record GSUP_SM_RP_OA {
@@ -967,20 +999,20 @@
 	)"
 };
 
-template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_MSISDN(hexstring msisdn) := {
+template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_MSISDN(GSUP_SM_RP_Addr msisdn) := {
 	id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
 	id_enc := { msisdn := msisdn }
 }
-template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_MSISDN(template hexstring msisdn) := {
+template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_MSISDN(template GSUP_SM_RP_Addr msisdn) := {
 	id_type := OSMO_GSUP_SM_RP_ODA_ID_MSISDN,
 	id_enc := { msisdn := msisdn }
 }
 
-template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_SMSC_ADDR(hexstring smsc_addr) := {
+template (value) GSUP_SM_RP_OA ts_GSUP_SM_RP_OA_SMSC_ADDR(GSUP_SM_RP_Addr smsc_addr) := {
 	id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
 	id_enc := { smsc_addr := smsc_addr }
 }
-template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_SMSC_ADDR(template hexstring smsc_addr) := {
+template GSUP_SM_RP_OA tr_GSUP_SM_RP_OA_SMSC_ADDR(template GSUP_SM_RP_Addr smsc_addr) := {
 	id_type := OSMO_GSUP_SM_RP_ODA_ID_SMSC_ADDR,
 	id_enc := { smsc_addr := smsc_addr }
 }
diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
index 046a9ea..2e71123 100644
--- a/library/Osmocom_Types.ttcn
+++ b/library/Osmocom_Types.ttcn
@@ -170,5 +170,13 @@
 	return str;
 }
 
+function f_pad_bcd_number(hexstring number) return hexstring {
+	if (lengthof(number) mod 2 != 0) {
+		return number & 'F'H;
+	} else {
+		return number;
+	}
+}
+
 
 } with { encode "RAW"; variant "FIELDORDER(msb)" }
diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 439d7f1..f430335 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -2268,14 +2268,16 @@
 /* Helper for sending MT SMS over GSUP */
 private function f_gsup_forwardSM_req(SmsParameters spars, OCT1 mms := '00'O)
 runs on BSC_ConnHdlr {
+	var GSUP_SM_RP_Addr msisdn := valueof(t_GSUP_SM_RP_Addr(g_pars.msisdn));
+
 	GSUP.send(ts_GSUP_MT_FORWARD_SM_REQ(
 		imsi := g_pars.imsi,
 		/* NOTE: MSC should assign RP-MR itself */
 		sm_rp_mr := 'FF'O,
 		/* FIXME: extract SM-RP-DA from spars.rp.dest */
 		/* TODO: fix encoding of ts_GSUP_SM_RP_DA_IMSI */
-		sm_rp_da := valueof(ts_GSUP_SM_RP_DA_MSISDN(g_pars.msisdn)),
-		sm_rp_oa := valueof(ts_GSUP_SM_RP_OA_SMSC_ADDR(g_pars.msisdn)),
+		sm_rp_da := valueof(ts_GSUP_SM_RP_DA_MSISDN(msisdn)),
+		sm_rp_oa := valueof(ts_GSUP_SM_RP_OA_SMSC_ADDR(msisdn)),
 		/* Encoded SMS TPDU (taken from Wireshark)
 		 * FIXME: we should encode spars somehow */
 		sm_rp_ui := '00068021436500008111328130858200'O,

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16565
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: I3f55834489f3e613f541cf1e216027e8d48ccaf0
Gerrit-Change-Number: 16565
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200103/036703b2/attachment.htm>


More information about the gerrit-log mailing list