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

#include <EthernetMacHeaderChecker.h>

Inheritance diagram for inet::EthernetMacHeaderChecker:
inet::queueing::PacketFilterBase inet::queueing::PacketProcessorBase inet::queueing::IPacketFilter inet::queueing::IPacketProcessor inet::StringFormat::IDirectiveResolver inet::queueing::IPacketFlow inet::queueing::IPacketSink inet::queueing::IPacketSource inet::queueing::IPassivePacketSink inet::queueing::IActivePacketSink inet::queueing::IPassivePacketSource inet::queueing::IActivePacketSource

Public Member Functions

virtual bool matchesPacket (const Packet *packet) const override
 Returns true if the filter matches the given packet. More...
 
- Public Member Functions inherited from inet::queueing::PacketFilterBase
virtual IPassivePacketSinkgetConsumer (cGate *gate) override
 Returns the passive packet sink where packets are pushed or nullptr if the connected module doesn't implement the interface. More...
 
virtual IPassivePacketSourcegetProvider (cGate *gate) override
 Returns the passive packet source from where packets are pulled or nullptr if the connected module doesn't implement the interface. More...
 
virtual bool supportsPacketPushing (cGate *gate) const override
 Returns true if the processor supports pushing packets at the given gate. More...
 
virtual bool supportsPacketPulling (cGate *gate) const override
 Returns true if the processor supports pulling packets at the given gate. More...
 
virtual bool supportsPacketStreaming (cGate *gate) const override
 Returns true if the processor supports streaming packets at the given gate. More...
 
virtual bool canPushSomePacket (cGate *gate) const override
 Returns false if the packet sink is full at the given gate and no more packets can be pushed into it without raising an error. More...
 
virtual bool canPushPacket (Packet *packet, cGate *gate) const override
 Returns true if the given packet can be pushed at the given gate into the packet sink without raising an error. More...
 
virtual void pushPacket (Packet *packet, cGate *gate) override
 Pushes the packet into the packet sink at the given gate. More...
 
virtual void pushPacketStart (Packet *packet, cGate *gate, bps datarate) override
 Starts pushing the packet into the packet sink at the given gate. More...
 
virtual void pushPacketEnd (Packet *packet, cGate *gate) override
 Ends pushing the packet into the packet sink at the given gate. More...
 
virtual void pushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength=b(0)) override
 Progresses pushing the packet into the packet sink at the given gate. More...
 
virtual void handleCanPushPacketChanged (cGate *gate) override
 Notifies about a change in the possibility of pushing some packet into the passive packet sink at the given gate. More...
 
virtual void handlePushPacketProcessed (Packet *packet, cGate *gate, bool successful) override
 Notifies about the completion of the packet processing for a packet that was pushed earlier independently whether the packet is passed or streamed. More...
 
virtual bool canPullSomePacket (cGate *gate) const override
 Returns false if the packet source is empty at the given gate and no more packets can be pulled from it without raising an error. More...
 
virtual PacketcanPullPacket (cGate *gate) const override
 Returns the packet that can be pulled at the given gate. More...
 
virtual PacketpullPacket (cGate *gate) override
 Pulls the packet from the packet source at the given gate. More...
 
virtual PacketpullPacketStart (cGate *gate, bps datarate) override
 Starts pulling the packet from the packet source at the given gate. More...
 
virtual PacketpullPacketEnd (cGate *gate) override
 Ends pulling the packet from the packet source at the given gate. More...
 
virtual PacketpullPacketProgress (cGate *gate, bps datarate, b position, b extraProcessableLength) override
 Progresses pulling the packet from the packet source at the given gate. More...
 
virtual void handlePullPacketProcessed (Packet *packet, cGate *gate, bool successful) override
 Notifies about the completion of the packet processing for a packet that was pulled earlier independently whether the packet is passed or streamed. More...
 
virtual void handleCanPullPacketChanged (cGate *gate) override
 Notifies about a change in the possibility of pulling some packet from the passive packet source at the given gate. More...
 
- Public Member Functions inherited from inet::queueing::PacketProcessorBase
virtual bool supportsPacketSending (cGate *gate) const override
 Returns true if the processor supports sending packets at the given gate. More...
 
virtual bool supportsPacketPassing (cGate *gate) const override
 Returns true if the processor supports passing packets as a whole at the given gate. More...
 
- Public Member Functions inherited from inet::queueing::IPacketProcessor
virtual ~IPacketProcessor ()
 
- Public Member Functions inherited from inet::queueing::IPassivePacketSink
virtual ~IPassivePacketSink ()
 
- Public Member Functions inherited from inet::queueing::IActivePacketSink
virtual ~IActivePacketSink ()
 
- Public Member Functions inherited from inet::queueing::IPassivePacketSource
virtual ~IPassivePacketSource ()
 
- Public Member Functions inherited from inet::queueing::IActivePacketSource
virtual ~IActivePacketSource ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void processPacket (Packet *packet) override
 
virtual void dropPacket (Packet *packet) override
 
- Protected Member Functions inherited from inet::queueing::PacketFilterBase
virtual void handleMessage (cMessage *message) override
 
virtual bool isStreamingPacket () const
 
virtual void startPacketStreaming (Packet *packet)
 
virtual void endPacketStreaming (Packet *packet)
 
virtual void checkPacketStreaming (Packet *packet)
 
virtual void dropPacket (Packet *packet, PacketDropReason reason, int limit=-1) override
 
virtual const char * resolveDirective (char directive) const override
 
- Protected Member Functions inherited from inet::queueing::PacketProcessorBase
virtual int numInitStages () const override
 
virtual void refreshDisplay () const override
 
virtual void handlePacketProcessed (Packet *packet)
 
virtual void checkPacketOperationSupport (cGate *gate) const
 
virtual void checkPacketOperationSupport (cGate *startGate, cGate *endGate) const
 
virtual void animate (Packet *packet, cGate *gate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacket (Packet *packet, cGate *gate, Action action) const
 
virtual void animatePacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId, Action action) const
 
virtual void animatePacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacketEnd (Packet *packet, cGate *gate, long transmissionId, Action action) const
 
virtual void animatePacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId, Action action) const
 
virtual void animatePacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions, Action action) const
 
virtual void pushOrSendPacket (Packet *packet, cGate *gate, IPassivePacketSink *consumer)
 
virtual void pushOrSendPacketStart (Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, int transmissionId)
 
virtual void pushOrSendPacketEnd (Packet *packet, cGate *gate, IPassivePacketSink *consumer, int transmissionId)
 
virtual void pushOrSendPacketProgress (Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, b position, b extraProcessableLength, int transmissionId)
 
virtual void animatePush (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePushPacket (Packet *packet, cGate *gate) const
 
virtual void animatePushPacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId) const
 
virtual void animatePushPacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions) const
 
virtual void animatePushPacketEnd (Packet *packet, cGate *gate, long transmissionId) const
 
virtual void animatePushPacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId) const
 
virtual void animatePushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions) const
 
virtual void animatePull (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePullPacket (Packet *packet, cGate *gate) const
 
virtual void animatePullPacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId) const
 
virtual void animatePullPacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions) const
 
virtual void animatePullPacketEnd (Packet *packet, cGate *gate, long transmissionId) const
 
virtual void animatePullPacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePullPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId) const
 
virtual void animatePullPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions) const
 
virtual void updateDisplayString () const
 

Protected Attributes

bool promiscuous = false
 
ModuleRefByPar< IInterfaceTableinterfaceTable
 
- Protected Attributes inherited from inet::queueing::PacketFilterBase
bool backpressure = false
 
cGate * inputGate = nullptr
 
ModuleRef< IActivePacketSourceproducer
 
ModuleRef< IPassivePacketSourceprovider
 
cGate * outputGate = nullptr
 
ModuleRef< IPassivePacketSinkconsumer
 
ModuleRef< IActivePacketSinkcollector
 
int inProgressStreamId = -1
 
int numDroppedPackets = 0
 
b droppedTotalLength = b(-1)
 
- Protected Attributes inherited from inet::queueing::PacketProcessorBase
const char * displayStringTextFormat = nullptr
 
int numProcessedPackets = -1
 
b processedTotalLength = b(-1)
 

Additional Inherited Members

- Protected Types inherited from inet::queueing::PacketProcessorBase
enum  Action { PUSH, PULL }
 

Member Function Documentation

◆ dropPacket()

void inet::EthernetMacHeaderChecker::dropPacket ( Packet packet)
overrideprotectedvirtual

Reimplemented from inet::queueing::PacketFilterBase.

71 {
72  // TODO or PacketFilterBase::dropPacket(packet, NO_PROTOCOL_FOUND);
74 }

◆ initialize()

void inet::EthernetMacHeaderChecker::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::queueing::PacketFilterBase.

25 {
27  if (stage == INITSTAGE_LOCAL) {
28  promiscuous = par("promiscuous");
29  interfaceTable.reference(this, "interfaceTableModule", true);
30  }
31  else if (stage == INITSTAGE_LINK_LAYER)
33 }

◆ matchesPacket()

bool inet::EthernetMacHeaderChecker::matchesPacket ( const Packet packet) const
overridevirtual

Returns true if the filter matches the given packet.

Implements inet::queueing::IPacketFilter.

55 {
56  const auto& header = packet->peekAtFront<EthernetMacHeader>();
57  auto interfaceInd = packet->getTag<InterfaceInd>();
58  auto networkInterface = interfaceTable->getInterfaceById(interfaceInd->getInterfaceId());
59  if (!promiscuous && !networkInterface->matchesMacAddress(header->getDest()))
60  return false;
61  else {
62  auto typeOrLength = header->getTypeOrLength();
63  if (isIeee8023Length(typeOrLength))
64  return true;
65  else
66  return ProtocolGroup::ethertype.findProtocol(typeOrLength) != nullptr;
67  }
68 }

◆ processPacket()

void inet::EthernetMacHeaderChecker::processPacket ( Packet packet)
overrideprotectedvirtual

Reimplemented from inet::queueing::PacketFilterBase.

36 {
37  const auto& header = packet->popAtFront<EthernetMacHeader>();
38  auto macAddressInd = packet->addTagIfAbsent<MacAddressInd>();
39  macAddressInd->setSrcAddress(header->getSrc());
40  macAddressInd->setDestAddress(header->getDest());
41  auto packetProtocolTag = packet->addTagIfAbsent<PacketProtocolTag>();
42  auto typeOrLength = header->getTypeOrLength();
43  const Protocol *protocol;
44  if (isIeee8023Length(typeOrLength))
46  else
48  packetProtocolTag->setFrontOffset(b(0));
49  packetProtocolTag->setBackOffset(b(0));
50  packetProtocolTag->setProtocol(protocol);
51  packet->addTagIfAbsent<DispatchProtocolReq>()->setProtocol(protocol);
52 }

Member Data Documentation

◆ interfaceTable

ModuleRefByPar<IInterfaceTable> inet::EthernetMacHeaderChecker::interfaceTable
protected

Referenced by initialize(), and matchesPacket().

◆ promiscuous

bool inet::EthernetMacHeaderChecker::promiscuous = false
protected

Referenced by initialize(), and matchesPacket().


The documentation for this class was generated from the following files:
inet::queueing::PacketFilterBase::dropPacket
virtual void dropPacket(Packet *packet)
Definition: PacketFilterBase.cc:259
protocol
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
inet::queueing::PacketFilterBase::inputGate
cGate * inputGate
Definition: PacketFilterBase.h:23
inet::ProtocolGroup::findProtocol
const Protocol * findProtocol(int protocolNumber) const
Definition: ProtocolGroup.cc:25
DispatchProtocolReq
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
inet::Protocol::ieee8022llc
static const Protocol ieee8022llc
Definition: Protocol.h:88
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::EthernetMacHeaderChecker::interfaceTable
ModuleRefByPar< IInterfaceTable > interfaceTable
Definition: EthernetMacHeaderChecker.h:23
inet::Protocol::ethernetMac
static const Protocol ethernetMac
Definition: Protocol.h:65
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::isIeee8023Length
bool isIeee8023Length(int typeOrLength)
Definition: EtherType_m.h:108
inet::queueing::PacketFilterBase::initialize
virtual void initialize(int stage) override
Definition: PacketFilterBase.cc:16
inet::ProtocolGroup::getProtocol
const Protocol * getProtocol(int protocolNumber) const
Definition: ProtocolGroup.cc:31
inet::registerProtocol
void registerProtocol(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a protocol primitive (PDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:83
inet::EthernetMacHeaderChecker::promiscuous
bool promiscuous
Definition: EthernetMacHeaderChecker.h:22
inet::NOT_ADDRESSED_TO_US
@ NOT_ADDRESSED_TO_US
Definition: Simsignals_m.h:76
inet::INITSTAGE_LINK_LAYER
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.
inet::ProtocolGroup::ethertype
static ProtocolGroup ethertype
Definition: ProtocolGroup.h:40