Change in osmo-ttcn3-hacks[master]: library: fix enc_SystemInformation(): properly pad messages

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
Mon May 4 18:17:20 UTC 2020


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18026 )


Change subject: library: fix enc_SystemInformation(): properly pad messages
......................................................................

library: fix enc_SystemInformation(): properly pad messages

Due to a buggy nature of TITAN's padding attributes, we cannot
apply them to individual fields of the records that are embedded
into other structured types, like records and unions.

Ensure that encoded System Information messages are padded to
either 23 or 19 octets, depending on their type. In order to
achieve this, rename and wrap the external encoding function.

Change-Id: I3368df52985e576ad180c9a74d4925dd9c952b55
Signed-off-by: Vadim Yanitskiy <axilirator at gmail.com>
---
M library/GSM_SystemInformation.ttcn
1 file changed, 25 insertions(+), 1 deletion(-)



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

diff --git a/library/GSM_SystemInformation.ttcn b/library/GSM_SystemInformation.ttcn
index de1fcf7..758ad1c 100644
--- a/library/GSM_SystemInformation.ttcn
+++ b/library/GSM_SystemInformation.ttcn
@@ -228,9 +228,33 @@
 			      other, OTHERWISE;
 			)" };
 
-	external function enc_SystemInformation(in SystemInformation si) return octetstring
+	external function enc_SystemInformationNoPad(in SystemInformation si) return octetstring
 		with { extension "prototype(convert) encode(RAW)" };
 	external function dec_SystemInformation(in octetstring stream) return SystemInformation
 		with { extension "prototype(convert) decode(RAW)" };
 
+	/* Due to a buggy nature of TITAN's padding attributes, we have to apply padding manually. */
+	function enc_SystemInformation(in SystemInformation si) return octetstring
+	{
+		var octetstring si_enc := enc_SystemInformationNoPad(si);
+
+		/* Resulting message length depends on SI Type */
+		select (si.header.message_type) {
+		case (SYSTEM_INFORMATION_TYPE_5,
+		      SYSTEM_INFORMATION_TYPE_5bis,
+		      SYSTEM_INFORMATION_TYPE_5ter) {
+			/* SACCH: no Rest Octets, return 'as-is' */
+			return si_enc;
+			}
+		case (SYSTEM_INFORMATION_TYPE_6) {
+			/* SACCH: pad to 19 octets, leave room for L1/LAPDm headers */
+			return f_pad_oct(si_enc, 19, '2B'O);
+			}
+		case else {
+			/* BCCH: pad to 23 octets */
+			return f_pad_oct(si_enc, 23, '2B'O);
+			}
+		}
+	}
+
 } with { encode "RAW"; variant "FIELDORDER(msb)" }

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18026
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: I3368df52985e576ad180c9a74d4925dd9c952b55
Gerrit-Change-Number: 18026
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/20200504/5d55e663/attachment.htm>


More information about the gerrit-log mailing list