Converts between ARPPacket and binary (network byte order) ARP header.
More...
#include <ARPSerializer.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 ARPPacket and binary (network byte order) ARP header.
inet::serializer::ARPSerializer::ARPSerializer |
( |
const char * |
name = nullptr | ) |
|
|
inline |
SerializerBase(const char *name=nullptr)
Definition: SerializerBase.h:84
cPacket * inet::serializer::ARPSerializer::deserialize |
( |
const Buffer & |
b, |
|
|
Context & |
context |
|
) |
| |
|
overrideprotectedvirtual |
Puts a packet sniffed from the wire into an ARPPacket.
Implements inet::serializer::SerializerBase.
80 ARPPacket *pkt =
new ARPPacket(
"parsed ARP");
85 pkt->setBitError(
true);
88 pkt->setBitError(
true);
89 uint8_t n =
b.readByte();
90 uint8_t
m =
b.readByte();
91 pkt->setOpcode(
b.readUint16());
97 pkt->setByteLength(
b.getPos());
IPv4Address readIPv4Address(const Buffer &b, unsigned int size)
Definition: ARPSerializer.cc:54
MACAddress readMACAddress(const Buffer &b, unsigned int size)
Definition: ARPSerializer.cc:46
Definition: Ieee802Ctrl_m.h:115
value< double, units::m > b
Definition: Units.h:1054
value< double, units::m > m
Definition: Units.h:1047
ARPPacket* inet::serializer::ARPSerializer::parse |
( |
const unsigned char * |
buf, |
|
|
unsigned int |
bufsize |
|
) |
| |
|
inline |
Puts a packet sniffed from the wire into an ARPPacket.
63 { Buffer
b(const_cast<unsigned char *>(buf), bufsize); Context
c;
return check_and_cast<ARPPacket *>(
deserialize(
b, c)); }
virtual cPacket * deserialize(const Buffer &b, Context &context) override
Puts a packet sniffed from the wire into an ARPPacket.
Definition: ARPSerializer.cc:78
const value< double, compose< units::m, pow< units::s,-1 > > > c(299792458)
value< double, units::m > b
Definition: Units.h:1054
IPv4Address inet::serializer::ARPSerializer::readIPv4Address |
( |
const Buffer & |
b, |
|
|
unsigned int |
size |
|
) |
| |
|
protected |
Referenced by deserialize().
56 unsigned int curpos =
b.getPos();
57 IPv4Address addr =
b.readIPv4Address();
58 b.seek(curpos + size);
value< double, units::m > b
Definition: Units.h:1054
MACAddress inet::serializer::ARPSerializer::readMACAddress |
( |
const Buffer & |
b, |
|
|
unsigned int |
size |
|
) |
| |
|
protected |
Referenced by deserialize().
48 unsigned int curpos =
b.getPos();
49 MACAddress addr =
b.readMACAddress();
50 b.seek(curpos + size);
value< double, units::m > b
Definition: Units.h:1054
void inet::serializer::ARPSerializer::serialize |
( |
const cPacket * |
pkt, |
|
|
Buffer & |
b, |
|
|
Context & |
context |
|
) |
| |
|
overrideprotectedvirtual |
Serializes an ARPPacket for transmission on the wire.
Returns the length of data written into buffer.
Implements inet::serializer::SerializerBase.
64 const ARPPacket *pkt = check_and_cast<
const ARPPacket *>(_pkt);
69 b.writeUint16(pkt->getOpcode());
70 b.writeMACAddress(pkt->getSrcMACAddress());
71 b.writeIPv4Address(pkt->getSrcIPAddress());
72 b.writeMACAddress(pkt->getDestMACAddress());
73 b.writeIPv4Address(pkt->getDestIPAddress());
74 if (pkt->getEncapsulatedPacket())
75 throw cRuntimeError(
"ARPSerializer: encapsulated packet not supported!");
#define ETHER_ADDR_LEN
Definition: ethernethdr.h:26
Definition: Ieee802Ctrl_m.h:115
value< double, units::m > b
Definition: Units.h:1054
int inet::serializer::ARPSerializer::serialize |
( |
const ARPPacket * |
pkt, |
|
|
unsigned char * |
buf, |
|
|
unsigned int |
bufsize |
|
) |
| |
|
inline |
Serializes an ARPPacket for transmission on the wire.
Returns the length of data written into buffer.
57 { Buffer
b(buf, bufsize); Context
c;
serialize(pkt,
b, c);
return b.getPos(); }
const value< double, compose< units::m, pow< units::s,-1 > > > c(299792458)
virtual void serialize(const cPacket *pkt, Buffer &b, Context &context) override
Serializes an ARPPacket for transmission on the wire.
Definition: ARPSerializer.cc:62
value< double, units::m > b
Definition: Units.h:1054
The documentation for this class was generated from the following files: