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

Converts between DsdvHello and binary (network byte order) dsdv hello packet. More...

#include <DsdvHelloSerializer.h>

Inheritance diagram for inet::DsdvHelloSerializer:
inet::FieldsChunkSerializer inet::ChunkSerializer

Public Member Functions

 DsdvHelloSerializer ()
 
- 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 DsdvHello and binary (network byte order) dsdv hello packet.

Constructor & Destructor Documentation

◆ DsdvHelloSerializer()

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

Member Function Documentation

◆ deserialize()

const Ptr< Chunk > inet::DsdvHelloSerializer::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 dsdvHello = makeShared<DsdvHello>();
29  dsdvHello->setSrcAddress(stream.readIpv4Address());
30  dsdvHello->setSequencenumber(stream.readUint32Be());
31  dsdvHello->setNextAddress(stream.readIpv4Address());
32  dsdvHello->setHopdistance(stream.readUint32Be());
33  dsdvHello->setChunkLength(B(16));
34  return dsdvHello;
35 }

◆ serialize()

void inet::DsdvHelloSerializer::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& dsdvHello = staticPtrCast<const DsdvHello>(chunk);
20  stream.writeIpv4Address(dsdvHello->getSrcAddress());
21  stream.writeUint32Be(dsdvHello->getSequencenumber());
22  stream.writeIpv4Address(dsdvHello->getNextAddress());
23  stream.writeUint32Be(dsdvHello->getHopdistance());
24 }

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