Converts between UDPPacket and binary (network byte order) UDP header.
More...
#include <UDPSerializer.h>
|
static SerializerBase & | lookupSerializer (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 SerializerBase & | lookupDeserializer (Context &context, ProtocolGroup group, int id) |
|
static cPacket * | lookupAndDeserialize (const Buffer &b, Context &context, ProtocolGroup group, int id, unsigned int maxLength=(unsigned int)(-1)) |
|
Converts between UDPPacket and binary (network byte order) UDP header.
inet::serializer::UDPSerializer::UDPSerializer |
( |
const char * |
name = nullptr | ) |
|
|
inline |
SerializerBase(const char *name=nullptr)
Definition: SerializerBase.h:84
cPacket * inet::serializer::UDPSerializer::deserialize |
( |
const Buffer & |
b, |
|
|
Context & |
context |
|
) |
| |
|
overrideprotectedvirtual |
Puts a packet sniffed from the wire into an EtherFrame.
Implements inet::serializer::SerializerBase.
80 ASSERT(
b.getPos() == 0);
81 UDPPacket *pkt =
new UDPPacket(
"parsed-udp");
82 pkt->setSourcePort(
b.readUint16());
83 pkt->setDestinationPort(
b.readUint16());
84 unsigned int length =
b.readUint16();
85 pkt->setTotalLengthField(length);
86 uint16_t chksum =
b.readUint16();
89 Buffer subBuffer(
b, payloadLength);
91 b.accessNBytes(payloadLength);
92 pkt->encapsulate(encapPacket);
94 if (chksum != 0 &&
c.l3AddressesPtr &&
c.l3AddressesLength)
97 if (length < UDP_HEADER_BYTES || chksum != 0 || pkt->getByteLength() != length)
98 pkt->setBitError(
true);
static ByteArraySerializer byteArraySerializer
Definition: SerializerBase.h:113
static uint16_t checksum(const void *addr, unsigned int count)
Definition: TCPIPchecksum.h:44
const value< double, compose< units::m, pow< units::s,-1 > > > c(299792458)
Definition: UDPPacket_m.h:48
SerializerRegistrationList serializers("default")
List of packet serializers (SerializerBase)
Definition: SerializerBase.h:146
Definition: IPProtocolId_m.h:83
cPacket * deserializePacket(const Buffer &b, Context &context)
Definition: SerializerBase.cc:42
value< double, units::m > b
Definition: Units.h:1054
void inet::serializer::UDPSerializer::serialize |
( |
const cPacket * |
pkt, |
|
|
Buffer & |
b, |
|
|
Context & |
context |
|
) |
| |
|
overrideprotectedvirtual |
Serializes a cPacket for transmission on the wire.
Returns the length of data written into buffer.
Implements inet::serializer::SerializerBase.
59 ASSERT(
b.getPos() == 0);
60 const UDPPacket *pkt = check_and_cast<
const UDPPacket *>(_pkt);
61 int packetLength = pkt->getByteLength();
62 b.writeUint16(pkt->getSourcePort());
63 b.writeUint16(pkt->getDestinationPort());
64 b.writeUint16(pkt->getTotalLengthField());
65 unsigned int chksumPos =
b.getPos();
67 const cPacket *encapPkt = pkt->getEncapsulatedPacket();
74 unsigned int endPos =
b.getPos();
Definition: SerializerBase.h:36
static uint16_t checksum(const void *addr, unsigned int count)
Definition: TCPIPchecksum.h:44
const value< double, compose< units::m, pow< units::s,-1 > > > c(299792458)
Definition: UDPPacket_m.h:48
static void lookupAndSerialize(const cPacket *pkt, Buffer &b, Context &context, ProtocolGroup group, int id, unsigned int maxLength=(unsigned int)(-1))
Definition: SerializerBase.cc:88
Definition: IPProtocolId_m.h:83
value< double, units::m > b
Definition: Units.h:1054
The documentation for this class was generated from the following files: