#include <Ieee8022LlcHeaderSerializer.h>
◆ Ieee8022LlcHeaderSerializer()
| inet::Ieee8022LlcHeaderSerializer::Ieee8022LlcHeaderSerializer |
( |
| ) |
|
|
inline |
22 : 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.
38 Ptr<Ieee8022LlcHeader> llcHeader =
nullptr;
39 uint8_t ssap = stream.readByte();
40 uint8_t dsap = stream.readByte();
41 uint16_t
ctrl = stream.readByte();
43 ctrl |= ((uint16_t)stream.readByte()) << 8;
44 if (dsap == 0xAA && ssap == 0xAA &&
ctrl == 0x03) {
45 auto snapHeader = makeShared<Ieee8022LlcSnapHeader>();
46 snapHeader->setOui(((uint32_t)stream.readByte() << 16) + stream.readUint16Be());
47 snapHeader->setProtocolId(stream.readUint16Be());
48 llcHeader = snapHeader;
51 llcHeader = makeShared<Ieee8022LlcHeader>();
52 llcHeader->setDsap(dsap);
53 llcHeader->setSsap(ssap);
54 llcHeader->setControl(
ctrl);
◆ serialize()
| void inet::Ieee8022LlcHeaderSerializer::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.
21 const auto& llcHeader =
CHK(dynamicPtrCast<const Ieee8022LlcHeader>(chunk));
22 stream.writeByte(llcHeader->getSsap());
23 stream.writeByte(llcHeader->getDsap());
24 auto control = llcHeader->getControl();
25 stream.writeByte(control);
26 if ((control & 3) != 3)
27 stream.writeByte(control >> 8);
28 if (
auto snapHeader = dynamicPtrCast<const Ieee8022LlcSnapHeader>(chunk)) {
29 stream.writeByte(snapHeader->getOui() >> 16);
30 stream.writeByte(snapHeader->getOui() >> 8);
31 stream.writeByte(snapHeader->getOui());
32 stream.writeUint16Be(snapHeader->getProtocolId());
The documentation for this class was generated from the following files: