diff options
Diffstat (limited to 'library')
-rw-r--r-- | library/RLCMAC_EncDec.cc | 43 | ||||
-rw-r--r-- | library/RLCMAC_Types.ttcn | 18 |
2 files changed, 53 insertions, 8 deletions
diff --git a/library/RLCMAC_EncDec.cc b/library/RLCMAC_EncDec.cc index b2f05250..1129ae1c 100644 --- a/library/RLCMAC_EncDec.cc +++ b/library/RLCMAC_EncDec.cc @@ -261,5 +261,48 @@ RlcmacUlDataBlock dec__RlcmacUlDataBlock(const OCTETSTRING& stream) return ret_val; } +OCTETSTRING enc__RlcmacUlBlock(const RlcmacUlBlock& si) +{ + if (si.ischosen(RlcmacUlBlock::ALT_data)) + return enc__RlcmacUlDataBlock(si.data()); + else + return enc__RlcmacUlCtrlBlock(si.ctrl()); +} + +OCTETSTRING enc__RlcmacDlBlock(const RlcmacDlBlock& si) +{ + if (si.ischosen(RlcmacDlBlock::ALT_data)) + return enc__RlcmacDlDataBlock(si.data()); + else + return enc__RlcmacDlCtrlBlock(si.ctrl()); +} + + +RlcmacUlBlock dec__RlcmacUlBlock(const OCTETSTRING& stream) +{ + RlcmacUlBlock ret_val; + unsigned char pt = stream[0].get_octet() >> 6; + + if (pt == MacPayloadType::MAC__PT__RLC__DATA) + ret_val.data() = dec__RlcmacUlDataBlock(stream); + else + ret_val.ctrl() = dec__RlcmacUlCtrlBlock(stream); + + return ret_val; +} + +RlcmacDlBlock dec__RlcmacDlBlock(const OCTETSTRING& stream) +{ + RlcmacDlBlock ret_val; + unsigned char pt = stream[0].get_octet() >> 6; + + if (pt == MacPayloadType::MAC__PT__RLC__DATA) + ret_val.data() = dec__RlcmacDlDataBlock(stream); + else + ret_val.ctrl() = dec__RlcmacDlCtrlBlock(stream); + + return ret_val; +} + } // namespace diff --git a/library/RLCMAC_Types.ttcn b/library/RLCMAC_Types.ttcn index 6231a54b..52aaef8a 100644 --- a/library/RLCMAC_Types.ttcn +++ b/library/RLCMAC_Types.ttcn @@ -204,10 +204,11 @@ module RLCMAC_Types { ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)" }; - external function enc_RlcmacUlBlock(in RlcmacUlBlock si) return octetstring - with { extension "prototype(convert) encode(RAW)" }; - external function dec_RlcmacUlBlock(in octetstring stream) return RlcmacUlBlock - with { extension "prototype(convert) decode(RAW)" }; + /* as the sub-types (RlcmacDl*Block) are not using the RAW coder, we cannot + * use auto-generated functions here, as they would decode those sub-types + * based on the RAW coder, not baed on the manual C++ functions */ + external function enc_RlcmacUlBlock(in RlcmacUlBlock si) return octetstring; + external function dec_RlcmacUlBlock(in octetstring stream) return RlcmacUlBlock; type union RlcmacDlBlock { RlcmacDlDataBlock data, @@ -218,9 +219,10 @@ module RLCMAC_Types { ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)" }; - external function enc_RlcmacDlBlock(in RlcmacDlBlock si) return octetstring - with { extension "prototype(convert) encode(RAW)" }; - external function dec_RlcmacDlBlock(in octetstring stream) return RlcmacDlBlock - with { extension "prototype(convert) decode(RAW)" }; + /* as the sub-types (RlcmacDl*Block) are not using the RAW coder, we cannot + * use auto-generated functions here, as they would decode those sub-types + * based on the RAW coder, not baed on the manual C++ functions */ + external function enc_RlcmacDlBlock(in RlcmacDlBlock si) return octetstring; + external function dec_RlcmacDlBlock(in octetstring stream) return RlcmacDlBlock; } with { encode "RAW"; variant "FIELDORDER(msb)" } |