Converts between ArpPacket and binary (network byte order) Arp header.
More...
#include <ArpPacketSerializer.h>
Converts between ArpPacket and binary (network byte order) Arp header.
◆ ArpPacketSerializer()
| inet::ArpPacketSerializer::ArpPacketSerializer |
( |
| ) |
|
|
inline |
28 : FieldsChunkSerializer() {}
◆ deserialize()
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.
51 auto arpPacket = makeShared<ArpPacket>();
52 if (stream.readUint16Be() != 1)
53 arpPacket->markIncorrect();
55 arpPacket->markIncorrect();
56 uint8_t macAddressLength = stream.readByte();
57 uint8_t ipAddressLength = stream.readByte();
58 arpPacket->setOpcode(
static_cast<ArpOpcode>(stream.readUint16Be()));
59 arpPacket->setSrcMacAddress(
readMacAddress(stream, macAddressLength));
61 arpPacket->setDestMacAddress(
readMacAddress(stream, macAddressLength));
◆ readIpv4Address()
29 b curpos = stream.getPosition();
30 Ipv4Address address = stream.readIpv4Address();
31 stream.seek(curpos +
B(size));
Referenced by deserialize().
◆ readMacAddress()
21 b curpos = stream.getPosition();
22 MacAddress address = stream.readMacAddress();
23 stream.seek(curpos +
B(size));
Referenced by deserialize().
◆ serialize()
Serializes a chunk into a stream by writing all bytes representing the chunk at the end of the stream.
Implements inet::FieldsChunkSerializer.
37 const auto& arpPacket = staticPtrCast<const ArpPacket>(chunk);
38 stream.writeUint16Be(1);
42 stream.writeUint16Be(arpPacket->getOpcode());
43 stream.writeMacAddress(arpPacket->getSrcMacAddress());
44 stream.writeIpv4Address(arpPacket->getSrcIpAddress());
45 stream.writeMacAddress(arpPacket->getDestMacAddress());
46 stream.writeIpv4Address(arpPacket->getDestIpAddress());
The documentation for this class was generated from the following files: