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 Dec 13 06:33:54 UTC 2019


fixeria has uploaded this change for review. ( 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
---
M library/GSUP_Types.ttcn
M library/Osmocom_Types.ttcn
M msc/MSC_Tests.ttcn
3 files changed, 60 insertions(+), 18 deletions(-)



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

diff --git a/library/GSUP_Types.ttcn b/library/GSUP_Types.ttcn
index 8977d9f..3fa525f 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 {
+	BIT4		npi, /* Numbering Plan Identification */
+	BIT3		ton, /* Type of Number */
+	BIT1		ext, /* Extension? */
+	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) := {
+	npi := npi,
+	ton := ton,
+	ext := ext,
+	/* 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 480ec96..25d6b64 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -2185,16 +2185,18 @@
 
 
 /* Helper for sending MT SMS over GSUP */
-private function f_gsup_forwardSM_req(SmsParameters spars, OCT1 mms := '00'O)
+private function f_gsup_forwardSM_req(SmsParameters spars,
+	template (value) GSUP_SM_RP_Addr msisdn := t_GSUP_SM_RP_Addr('12345678'H),
+	template (value) GSUP_SM_RP_Addr smsc := t_GSUP_SM_RP_Addr('87654321'H),
+	OCT1 mms := '00'O)
 runs on BSC_ConnHdlr {
 	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(valueof(msisdn))),
+		sm_rp_oa := valueof(ts_GSUP_SM_RP_OA_SMSC_ADDR(valueof(smsc))),
 		/* Encoded SMS TPDU (taken from Wireshark)
 		 * FIXME: we should encode spars somehow */
 		sm_rp_ui := '00068021436500008111328130858200'O,
@@ -2580,7 +2582,7 @@
 	/* Send 4 messages (NOTE: SM-RP-UI remains unchanged) */
 	for (var integer i := 3; i >= 0; i := i-1) {
 		/* Submit a MT SMS on GSUP (MMS is decremented) */
-		f_gsup_forwardSM_req(spars, int2oct(i, 1));
+		f_gsup_forwardSM_req(spars, mms := int2oct(i, 1));
 
 		/* Expect Paging Request and Establish connection */
 		if (i == 3) { /* ... only once! */

-- 
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: 1
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191213/edfc7a50/attachment.htm>


More information about the gerrit-log mailing list