INET Framework for OMNeT++/OMNEST
inet::FcsHeaderSerializer Class Reference

Converts between FcsHeader and binary (network byte order) FCS header. More...

#include <FcsHeaderSerializer.h>

Inheritance diagram for inet::FcsHeaderSerializer:
inet::FieldsChunkSerializer inet::ChunkSerializer

Public Member Functions

 FcsHeaderSerializer ()
 
- Public Member Functions inherited from inet::FieldsChunkSerializer
virtual void serialize (MemoryOutputStream &stream, const Ptr< const Chunk > &chunk, b offset, b length) const override
 Serializes a chunk into a stream by writing the bytes representing the chunk at the end of the stream. More...
 
virtual const Ptr< Chunkdeserialize (MemoryInputStream &stream, const std::type_info &typeInfo) const override
 Deserializes a chunk from a stream by reading the bytes at the current position of the stream. More...
 

Protected Member Functions

virtual void serialize (MemoryOutputStream &stream, const Ptr< const Chunk > &chunk) const override
 Serializes a chunk into a stream by writing all bytes representing the chunk at the end of the stream. More...
 
virtual const Ptr< Chunkdeserialize (MemoryInputStream &stream) const override
 Deserializes a chunk from a stream by reading the bytes at the current position of the stream. More...
 

Additional Inherited Members

- Static Public Attributes inherited from inet::ChunkSerializer
static b totalSerializedLength = b(0)
 
static b totalDeserializedLength = b(0)
 

Detailed Description

Converts between FcsHeader and binary (network byte order) FCS header.

Constructor & Destructor Documentation

◆ FcsHeaderSerializer()

inet::FcsHeaderSerializer::FcsHeaderSerializer ( )
inline
25 : FieldsChunkSerializer() {}

Member Function Documentation

◆ deserialize()

const Ptr< Chunk > inet::FcsHeaderSerializer::deserialize ( MemoryInputStream stream) const
overrideprotectedvirtual

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.

27 {
28  auto fcsHeader = makeShared<FcsHeader>();
29  auto fcs = stream.readUint32Be();
30  fcsHeader->setFcs(fcs);
31  fcsHeader->setFcsMode(fcs == 0 ? FCS_DISABLED : FCS_COMPUTED);
32  return fcsHeader;
33 }

◆ serialize()

void inet::FcsHeaderSerializer::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.

18 {
19  const auto& fcsHeader = staticPtrCast<const FcsHeader>(chunk);
20  auto fcsMode = fcsHeader->getFcsMode();
21  if (fcsMode != FCS_DISABLED && fcsMode != FCS_COMPUTED)
22  throw cRuntimeError("Cannot serialize FCS header without turned off or properly computed FCS, try changing the value of fcsMode parameter for FcsHeaderInserter");
23  stream.writeUint32Be(fcsHeader->getFcs());
24 }

The documentation for this class was generated from the following files:
inet::FCS_COMPUTED
@ FCS_COMPUTED
Definition: FcsMode_m.h:59
inet::FCS_DISABLED
@ FCS_DISABLED
Definition: FcsMode_m.h:56