INET Framework for OMNeT++/OMNEST
inet::serializer::DefaultSerializer Class Reference

#include <SerializerBase.h>

Inheritance diagram for inet::serializer::DefaultSerializer:
inet::serializer::SerializerBase

Public Member Functions

virtual void serialize (const cPacket *pkt, Buffer &b, Context &context) override
 Serializes a cPacket for transmission on the wire. More...
 
virtual cPacket * deserialize (const Buffer &b, Context &context) override
 Puts a packet sniffed from the wire into an EtherFrame. More...
 
- Public Member Functions inherited from inet::serializer::SerializerBase
 SerializerBase (const char *name=nullptr)
 
void serializePacket (const cPacket *pkt, Buffer &b, Context &context)
 
cPacket * deserializePacket (const Buffer &b, Context &context)
 

Additional Inherited Members

- Static Public Member Functions inherited from inet::serializer::SerializerBase
static SerializerBaselookupSerializer (const cPacket *pkt, Context &context, ProtocolGroup group, int id)
 
static void lookupAndSerialize (const cPacket *pkt, Buffer &b, Context &context, ProtocolGroup group, int id, unsigned int maxLength=(unsigned int)(-1))
 
static SerializerBaselookupDeserializer (Context &context, ProtocolGroup group, int id)
 
static cPacket * lookupAndDeserialize (const Buffer &b, Context &context, ProtocolGroup group, int id, unsigned int maxLength=(unsigned int)(-1))
 

Member Function Documentation

cPacket * inet::serializer::DefaultSerializer::deserialize ( const Buffer b,
Context context 
)
overridevirtual

Puts a packet sniffed from the wire into an EtherFrame.

Implements inet::serializer::SerializerBase.

118 {
119  unsigned int byteLength = b.getRemainingSize();
120  if (byteLength) {
121  cPacket *pkt = new cPacket();
122  pkt->setByteLength(byteLength);
123  b.accessNBytes(byteLength);
124  context.errorOccured = true;
125  return pkt;
126  }
127  else
128  return nullptr;
129 }
value< double, units::m > b
Definition: Units.h:1054
void inet::serializer::DefaultSerializer::serialize ( const cPacket *  pkt,
Buffer b,
Context context 
)
overridevirtual

Serializes a cPacket for transmission on the wire.

Returns the length of data written into buffer.

Implements inet::serializer::SerializerBase.

112 {
113  b.fillNBytes(pkt->getByteLength(), '?');
114  context.errorOccured = true;
115 }
value< double, units::m > b
Definition: Units.h:1054

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