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

Converts between PppHeader and binary (network byte order) Ppp header. More...

#include <PppHeaderSerializer.h>

Inheritance diagram for inet::PppHeaderSerializer:
inet::FieldsChunkSerializer inet::ChunkSerializer

Public Member Functions

 PppHeaderSerializer ()
 
- 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 PppHeader and binary (network byte order) Ppp header.

Constructor & Destructor Documentation

◆ PppHeaderSerializer()

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

Member Function Documentation

◆ deserialize()

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

28 {
29  auto pppHeader = makeShared<PppHeader>();
30  pppHeader->setFlag(stream.readUint8());
31  pppHeader->setAddress(stream.readUint8());
32  pppHeader->setControl(stream.readUint8());
33  pppHeader->setProtocol(stream.readUint16Be());
34  return pppHeader;
35 }

◆ serialize()

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

19 {
20  const auto& pppHeader = staticPtrCast<const PppHeader>(chunk);
21  stream.writeUint8(pppHeader->getFlag());
22  stream.writeUint8(pppHeader->getAddress());
23  stream.writeUint8(pppHeader->getControl());
24  stream.writeUint16Be(pppHeader->getProtocol());
25 }

The documentation for this class was generated from the following files: