From 0217b05050c5e193cd5dda07488d80c5defc95d4 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Mon, 4 May 2020 23:59:01 +0700 Subject: library: fix enc_SystemInformation(): properly pad messages Due to a buggy nature of TITAN's padding attributes [1], 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. [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=562849 Change-Id: I3368df52985e576ad180c9a74d4925dd9c952b55 Signed-off-by: Vadim Yanitskiy --- library/GSM_SystemInformation.ttcn | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'library') diff --git a/library/GSM_SystemInformation.ttcn b/library/GSM_SystemInformation.ttcn index de1fcf76..758ad1c0 100644 --- a/library/GSM_SystemInformation.ttcn +++ b/library/GSM_SystemInformation.ttcn @@ -228,9 +228,33 @@ module GSM_SystemInformation { 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)" } -- cgit v1.2.3