summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2020-05-04 23:59:01 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2020-05-06 02:25:10 +0700
commit0217b05050c5e193cd5dda07488d80c5defc95d4 (patch)
tree0f242389d619202433c089621db42c363eb26553 /library
parentb7bc2e67465199a4310c6ec75a95e297a76674a2 (diff)
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 <axilirator@gmail.com>
Diffstat (limited to 'library')
-rw-r--r--library/GSM_SystemInformation.ttcn26
1 files changed, 25 insertions, 1 deletions
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 @@ 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)" }