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

#include <Ieee80211MacProtocolDissector.h>

Inheritance diagram for inet::Ieee80211MacProtocolDissector:
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...
 

Protected Member Functions

virtual const ProtocolcomputeLlcProtocol (Packet *packet) const
 

Member Function Documentation

◆ computeLlcProtocol()

const Protocol * inet::Ieee80211MacProtocolDissector::computeLlcProtocol ( Packet packet) const
protectedvirtual
24 {
25  if (const auto& llcTag = packet->findTag<ieee80211::LlcProtocolTag>())
26  return llcTag->getProtocol();
27  else if (const auto& channelTag = packet->findTag<physicallayer::Ieee80211ChannelInd>()) {
28  // EtherType protocol discrimination is mandatory for deployments in the 5.9 GHz band
29  if (channelTag->getChannel()->getBand() == &physicallayer::Ieee80211CompliantBands::band5_9GHz)
30  return &Protocol::ieee802epd;
31  }
32  const auto& header = packet->peekAtFront();
33  if (dynamicPtrCast<const Ieee8022LlcHeader>(header) != nullptr)
34  return &Protocol::ieee8022llc;
35  else if (dynamicPtrCast<const Ieee802EpdHeader>(header) != nullptr)
36  return &Protocol::ieee802epd;
37  else
38  return nullptr;
39 }

Referenced by dissect().

◆ dissect()

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

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

Implements inet::ProtocolDissector.

42 {
43  const auto& header = packet->popAtFront<inet::ieee80211::Ieee80211MacHeader>();
44  const auto& trailer = packet->popAtBack<inet::ieee80211::Ieee80211MacTrailer>(B(4));
45  callback.startProtocolDataUnit(&Protocol::ieee80211Mac);
46  callback.visitChunk(header, &Protocol::ieee80211Mac);
47  // TODO fragmentation & aggregation
48  if (auto dataHeader = dynamicPtrCast<const inet::ieee80211::Ieee80211DataHeader>(header)) {
49  if (dataHeader->getMoreFragments() || dataHeader->getFragmentNumber() != 0)
50  callback.dissectPacket(packet, nullptr);
51  else if (dataHeader->getAMsduPresent()) {
52  auto originalTrailerPopOffset = packet->getBackOffset();
53  int paddingLength = 0;
54  while (packet->getDataLength() > B(0)) {
55  packet->setFrontOffset(packet->getFrontOffset() + B(paddingLength == 4 ? 0 : paddingLength));
56  const auto& msduSubframeHeader = packet->popAtFront<ieee80211::Ieee80211MsduSubframeHeader>();
57  auto msduEndOffset = packet->getFrontOffset() + B(msduSubframeHeader->getLength());
58  packet->setBackOffset(msduEndOffset);
59  callback.dissectPacket(packet, computeLlcProtocol(packet));
60  paddingLength = 4 - B(msduSubframeHeader->getChunkLength() + B(msduSubframeHeader->getLength())).get() % 4;
61  packet->setBackOffset(originalTrailerPopOffset);
62  packet->setFrontOffset(msduEndOffset);
63  }
64  }
65  else
66  callback.dissectPacket(packet, computeLlcProtocol(packet));
67  }
68  else if (dynamicPtrCast<const inet::ieee80211::Ieee80211ActionFrame>(header))
69  ASSERT(packet->getDataLength() == b(0));
70  else if (dynamicPtrCast<const inet::ieee80211::Ieee80211MgmtHeader>(header))
71  callback.dissectPacket(packet, &Protocol::ieee80211Mgmt);
72  // TODO else if (dynamicPtrCast<const inet::ieee80211::Ieee80211ControlFrame>(header))
73  else
74  ASSERT(packet->getDataLength() == b(0));
75  callback.visitChunk(trailer, &Protocol::ieee80211Mac);
76  callback.endProtocolDataUnit(&Protocol::ieee80211Mac);
77 }

The documentation for this class was generated from the following files:
inet::Protocol::ieee80211Mgmt
static const Protocol ieee80211Mgmt
Definition: Protocol.h:80
inet::physicallayer::Ieee80211CompliantBands::band5_9GHz
static const Ieee80211ArithmeticalBand band5_9GHz
Definition: Ieee80211Band.h:81
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::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::ieee80211::Ieee80211MacTrailer
Class generated from inet/linklayer/ieee80211/mac/Ieee80211Frame.msg:100 by opp_msgtool.
Definition: Ieee80211Frame_m.h:213
inet::Ieee80211MacProtocolDissector::computeLlcProtocol
virtual const Protocol * computeLlcProtocol(Packet *packet) const
Definition: Ieee80211MacProtocolDissector.cc:23
inet::Protocol::ieee80211Mac
static const Protocol ieee80211Mac
Definition: Protocol.h:79
inet::ieee80211::Ieee80211MacHeader
Class generated from inet/linklayer/ieee80211/mac/Ieee80211Frame.msg:115 by opp_msgtool.
Definition: Ieee80211Frame_m.h:274
inet::Protocol::ieee802epd
static const Protocol ieee802epd
Definition: Protocol.h:90