RLCMAC: Fix encoding/decoding of 'union' types
We must supply hand-written C++ functions for encoding/decoding the union types.
This commit is contained in:
parent
5aa500791e
commit
78a1af6782
|
@ -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
|
||||
|
|
|
@ -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)" }
|
||||
|
|
Loading…
Reference in New Issue