INET Framework for OMNeT++/OMNEST
inet::physicallayer::EthernetPhyHeaderSerializer Class Reference

Converts between EthernetPhyHeader and binary (network byte order) Ethernet PHY header. More...

#include <EthernetPhyHeaderSerializer.h>

Inheritance diagram for inet::physicallayer::EthernetPhyHeaderSerializer:
inet::FieldsChunkSerializer inet::ChunkSerializer

Public Member Functions

 EthernetPhyHeaderSerializer ()
 
- 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...
 

Private Attributes

friend EthernetPhyHeaderBaseSerializer
 

Additional Inherited Members

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

Detailed Description

Converts between EthernetPhyHeader and binary (network byte order) Ethernet PHY header.

Constructor & Destructor Documentation

◆ EthernetPhyHeaderSerializer()

inet::physicallayer::EthernetPhyHeaderSerializer::EthernetPhyHeaderSerializer ( )
inline
42 : FieldsChunkSerializer() {}

Member Function Documentation

◆ deserialize()

const Ptr< Chunk > inet::physicallayer::EthernetPhyHeaderSerializer::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.

47 {
48  auto header = makeShared<EthernetPhyHeader>();
49  bool preambleReadSuccessfully = stream.readByteRepeatedly(0x55, B(PREAMBLE_BYTES).get()); // preamble
50  uint8_t sfd = stream.readByte();
51  if (!preambleReadSuccessfully || sfd != 0xD5) {
52  header->markIncorrect();
53  header->markImproperlyRepresented();
54  }
55  return header;
56 }

Referenced by inet::physicallayer::EthernetPhyHeaderBaseSerializer::deserialize().

◆ serialize()

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

41 {
42  stream.writeByteRepeatedly(0x55, B(PREAMBLE_BYTES).get()); // preamble
43  stream.writeByte(0xD5); // SFD
44 }

Member Data Documentation

◆ EthernetPhyHeaderBaseSerializer

friend inet::physicallayer::EthernetPhyHeaderSerializer::EthernetPhyHeaderBaseSerializer
private

The documentation for this class was generated from the following files:
inet::units::units::B
intscale< b, 1, 8 > B
Definition: Units.h:1168
inet::PREAMBLE_BYTES
const B PREAMBLE_BYTES
Definition: Ethernet.h:41