diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2020-09-15 19:15:01 +0700 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2020-09-15 19:15:22 +0700 |
commit | 220fa204da5e85af8e8bed13171fb93477fae709 (patch) | |
tree | c919eb57f734a796b4c33549ade6e6802b4c38ae | |
parent | ad70991d514a083e4b52a4b12167ef93260d9cba (diff) |
fixup library/PCUIF_Types: version 10: do not add redundant padding
Unlike osmo-pcu, osmo-bts does check length of the messages received
over the PCU interface, so I7a532d7abff8af354e40c5d706bb882efc6f905f
caused all the related test cases in ttcn3-bts-test to fail.
Reverting it is not a solution, because we cannot maintain different
padding attributes for two different protocol versions. Let's add
a wrapper function that would call enc_PCUIF_Message() and append
padding depending on the configured protocol version. In addition,
let's add a module parameter that would allow us to (optionally)
disable padding for ttcn3-pcu-test.
This change makes all broken PCUIF specific test cases pass.
Change-Id: Ica9e0c49c8b16e7d585a481670762c6433c61118
-rw-r--r-- | library/PCUIF_CodecPort.ttcn | 2 | ||||
-rw-r--r-- | library/PCUIF_Types.ttcn | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/library/PCUIF_CodecPort.ttcn b/library/PCUIF_CodecPort.ttcn index 4b2a8ce..0411c39 100644 --- a/library/PCUIF_CodecPort.ttcn +++ b/library/PCUIF_CodecPort.ttcn @@ -23,7 +23,7 @@ type record PCUIF_send_data { private function PCUIF_to_UD(in PCUIF_send_data pin, out UD_send_data pout) { pout.id := pin.id; - pout.data := enc_PCUIF_Message(pin.data); + pout.data := enc_pad_PCUIF_Message(pin.data); } with { extension "prototype(fast)" }; private function fix_padding(inout PCUIF_data data) { diff --git a/library/PCUIF_Types.ttcn b/library/PCUIF_Types.ttcn index 8ce8885..c8676a5 100644 --- a/library/PCUIF_Types.ttcn +++ b/library/PCUIF_Types.ttcn @@ -18,6 +18,8 @@ import from Native_Functions all; modulepar { /* PCUIF version supported by the IUT */ PCUIF_Version mp_pcuif_version := 9; + /* Whether to pad outgoing messages */ + boolean mp_pcuif_padding := true; }; const charstring PCU_SOCK_DEFAULT := "/tmp/pcu_bts"; @@ -317,6 +319,26 @@ external function enc_PCUIF_Message(in PCUIF_Message pdu) return octetstring external function dec_PCUIF_Message(in octetstring stream) return PCUIF_Message with { extension "prototype(convert) decode(RAW)" }; +function enc_pad_PCUIF_Message(in PCUIF_Message pdu) +return octetstring { + var octetstring stream; + var integer len; + + stream := enc_PCUIF_Message(pdu); + if (not mp_pcuif_padding) { + return stream; + } + + select (mp_pcuif_version) { + case (9) { len := 212; } + /* FIXME: 1006 % 4 > 0 (alignment) */ + case (10) { len := 1006; } + case else { len := 0; } + } + + return f_pad_oct(stream, len, '00'O); +} + /* Generic template for matching messages by type and/or the BTS number */ template PCUIF_Message tr_PCUIF_MSG(template PCUIF_MsgType msg_type := ?, |