#include <EthernetControlFrameSerializer.h>
◆ EthernetControlFrameSerializer()
| inet::EthernetControlFrameSerializer::EthernetControlFrameSerializer |
( |
| ) |
|
|
inline |
22 : 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.
35 Ptr<EthernetControlFrameBase> controlFrame =
nullptr;
36 uint16_t opCode = stream.readUint16Be();
38 auto pauseFrame = makeShared<EthernetPauseFrame>();
39 pauseFrame->setOpCode(opCode);
40 pauseFrame->setPauseTime(stream.readUint16Be());
41 controlFrame = pauseFrame;
44 controlFrame = makeShared<EthernetControlFrameBase>();
45 controlFrame->setOpCode(opCode);
46 controlFrame->markImproperlyRepresented();
◆ serialize()
| void inet::EthernetControlFrameSerializer::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.
22 const auto& frame = staticPtrCast<const EthernetControlFrameBase>(chunk);
23 stream.writeUint16Be(frame->getOpCode());
25 auto pauseFrame = dynamicPtrCast<const EthernetPauseFrame>(frame);
26 ASSERT(pauseFrame !=
nullptr);
27 stream.writeUint16Be(pauseFrame->getPauseTime());
30 throw cRuntimeError(
"Cannot serialize '%s' (EthernetControlFrame with opCode = %d)", frame->getClassName(), frame->getOpCode());
The documentation for this class was generated from the following files: