INET Framework for OMNeT++/OMNEST
inet::EthernetMacProtocolDissector Class Reference

#include <EthernetMacProtocolDissector.h>

Inheritance diagram for inet::EthernetMacProtocolDissector:
inet::ProtocolDissector

Public Member Functions

virtual void dissect (Packet *packet, const Protocol *protocol, ICallback &callback) const override
 Dissects the packet according to the protocol implemented by this ProtocolDissector. More...
 

Member Function Documentation

◆ dissect()

void inet::EthernetMacProtocolDissector::dissect ( Packet packet,
const Protocol protocol,
ICallback callback 
) const
overridevirtual

Dissects the packet according to the protocol implemented by this ProtocolDissector.

Implements inet::ProtocolDissector.

22 {
23  const auto& macHeader = packet->popAtFront<EthernetMacHeader>();
24  callback.startProtocolDataUnit(&Protocol::ethernetMac);
25  callback.visitChunk(macHeader, &Protocol::ethernetMac);
26  const auto& fcs = packet->popAtBack<EthernetFcs>(ETHER_FCS_BYTES);
27  int typeOrLength = macHeader->getTypeOrLength();
28  if (isEth2Type(typeOrLength)) {
29  auto payloadProtocol = ProtocolGroup::ethertype.findProtocol(typeOrLength);
30  callback.dissectPacket(packet, payloadProtocol);
31  }
32  else {
33  // LLC header
34  auto ethEndOffset = packet->getFrontOffset() + B(typeOrLength);
35  auto trailerOffset = packet->getBackOffset();
36  packet->setBackOffset(ethEndOffset);
37  callback.dissectPacket(packet, &Protocol::ieee8022llc);
38  packet->setBackOffset(trailerOffset);
39  }
40  auto paddingLength = packet->getDataLength();
41  if (paddingLength > b(0)) {
42  const auto& padding = packet->popAtFront(paddingLength);
43  callback.visitChunk(padding, &Protocol::ethernetMac);
44  }
45  callback.visitChunk(fcs, &Protocol::ethernetMac);
46  callback.endProtocolDataUnit(&Protocol::ethernetMac);
47 }

The documentation for this class was generated from the following files:
inet::ETHER_FCS_BYTES
const B ETHER_FCS_BYTES
Definition: Ethernet.h:59
inet::ProtocolGroup::findProtocol
const Protocol * findProtocol(int protocolNumber) const
Definition: ProtocolGroup.cc:25
inet::isEth2Type
bool isEth2Type(int typeOrLength)
Definition: EtherType_m.h:107
inet::Protocol::ieee8022llc
static const Protocol ieee8022llc
Definition: Protocol.h:88
inet::units::units::B
intscale< b, 1, 8 > B
Definition: Units.h:1168
inet::Protocol::ethernetMac
static const Protocol ethernetMac
Definition: Protocol.h:65
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::ProtocolGroup::ethertype
static ProtocolGroup ethertype
Definition: ProtocolGroup.h:40