Converts between TransportPseudoHeader and binary (network byte order) transport pseudo header.
More...
#include <TransportPseudoHeaderSerializer.h>
Converts between TransportPseudoHeader and binary (network byte order) transport pseudo header.
◆ TransportPseudoHeaderSerializer()
| inet::TransportPseudoHeaderSerializer::TransportPseudoHeaderSerializer |
( |
| ) |
|
|
inline |
25 : FieldsChunkSerializer() {}
◆ deserialize()
Deserializes a chunk from a stream by reading the bytes at the current position of the stream.
The current stream position is updated according to the length of the returned chunk.
Implements inet::FieldsChunkSerializer.
47 throw cRuntimeError(
"TransportPseudoHeader is not a valid deserializable data");
◆ serialize()
| void inet::TransportPseudoHeaderSerializer::serialize |
( |
MemoryOutputStream & |
stream, |
|
|
const Ptr< const Chunk > & |
chunk |
|
) |
| const |
|
overrideprotectedvirtual |
Serializes a chunk into a stream by writing all bytes representing the chunk at the end of the stream.
Implements inet::FieldsChunkSerializer.
21 const auto& transportPseudoHeader = staticPtrCast<const TransportPseudoHeader>(chunk);
22 auto nwProtId = transportPseudoHeader->getNetworkProtocolId();
24 ASSERT(transportPseudoHeader->getChunkLength() ==
B(12));
25 stream.writeIpv4Address(transportPseudoHeader->getSrcAddress().toIpv4());
26 stream.writeIpv4Address(transportPseudoHeader->getDestAddress().toIpv4());
28 stream.writeByte(transportPseudoHeader->getProtocolId());
29 stream.writeUint16Be(
B(transportPseudoHeader->getPacketLength()).get());
32 ASSERT(transportPseudoHeader->getChunkLength() ==
B(40));
33 stream.writeIpv6Address(transportPseudoHeader->getSrcAddress().toIpv6());
34 stream.writeIpv6Address(transportPseudoHeader->getDestAddress().toIpv6());
35 stream.writeUint32Be(
B(transportPseudoHeader->getPacketLength()).get());
39 stream.writeByte(transportPseudoHeader->getProtocolId());
42 throw cRuntimeError(
"Unknown network protocol: %d", nwProtId);
The documentation for this class was generated from the following files: