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

PIMSplitter register itself for PIM protocol (103) in the network layer, and dispatches the received packets either to PIMDM or PIMSM according to the PIM mode of the incoming interface. More...

#include <PIMSplitter.h>

Inheritance diagram for inet::PIMSplitter:

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void processPIMPacket (PIMPacket *pkt)
 

Private Attributes

IInterfaceTableift = nullptr
 
PIMInterfaceTablepimIft = nullptr
 
cGate * ipIn = nullptr
 
cGate * ipOut = nullptr
 
cGate * pimDMIn = nullptr
 
cGate * pimDMOut = nullptr
 
cGate * pimSMIn = nullptr
 
cGate * pimSMOut = nullptr
 

Detailed Description

PIMSplitter register itself for PIM protocol (103) in the network layer, and dispatches the received packets either to PIMDM or PIMSM according to the PIM mode of the incoming interface.

Packets received from the PIM modules are simply forwarded to the network layer.

Member Function Documentation

void inet::PIMSplitter::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
55 {
56  cGate *arrivalGate = msg->getArrivalGate();
57 
58  if (arrivalGate == ipIn) {
59  PIMPacket *pimPacket = dynamic_cast<PIMPacket *>(msg);
60  if (pimPacket) {
61  processPIMPacket(pimPacket);
62  }
63  else if (dynamic_cast<ICMPMessage *>(msg)) {
64  EV_WARN << "Received ICMP error, ignoring.\n";
65  delete msg;
66  }
67  else
68  throw cRuntimeError("PIMSplitter: received unknown packet '%s (%s)' from the network layer.", msg->getName(), msg->getClassName());
69  }
70  else if (arrivalGate == pimSMIn || arrivalGate == pimDMIn) {
71  if (dynamic_cast<RegisterTransportProtocolCommand *>(msg)) {
72  // Drop protocol registrations, splitter register PIM protocol itself
73  delete msg;
74  }
75  else {
76  // Send other packets to the network layer
77  EV_INFO << "Received packet from PIM module, sending it to the network." << endl;
78  send(msg, ipOut);
79  }
80  }
81  else
82  throw cRuntimeError("PIMSplitter: received packet on the unknown gate: %s.", arrivalGate ? arrivalGate->getBaseName() : "nullptr");
83 }
cGate * ipOut
Definition: PIMSplitter.h:45
virtual void processPIMPacket(PIMPacket *pkt)
Definition: PIMSplitter.cc:85
cGate * ipIn
Definition: PIMSplitter.h:44
cGate * pimSMIn
Definition: PIMSplitter.h:48
cGate * pimDMIn
Definition: PIMSplitter.h:46
void inet::PIMSplitter::initialize ( int  stage)
overrideprotectedvirtual
34 {
35  cSimpleModule::initialize(stage);
36 
37  if (stage == INITSTAGE_LOCAL) {
38  ift = getModuleFromPar<IInterfaceTable>(par("interfaceTableModule"), this);
39  pimIft = getModuleFromPar<PIMInterfaceTable>(par("pimInterfaceTableModule"), this);
40 
41  ipIn = gate("ipIn");
42  ipOut = gate("ipOut");
43  pimDMIn = gate("pimDMIn");
44  pimDMOut = gate("pimDMOut");
45  pimSMIn = gate("pimSMIn");
46  pimSMOut = gate("pimSMOut");
47  }
48  else if (stage == INITSTAGE_TRANSPORT_LAYER) {
49  IPSocket ipSocket(ipOut);
50  ipSocket.registerProtocol(IP_PROT_PIM);
51  }
52 }
Initialization of transport-layer protocols.
Definition: InitStages.h:90
cGate * ipOut
Definition: PIMSplitter.h:45
cGate * ipIn
Definition: PIMSplitter.h:44
PIMInterfaceTable * pimIft
Definition: PIMSplitter.h:42
IInterfaceTable * ift
Definition: PIMSplitter.h:41
Definition: IPProtocolId_m.h:90
cGate * pimSMOut
Definition: PIMSplitter.h:49
cGate * pimSMIn
Definition: PIMSplitter.h:48
Local initializations.
Definition: InitStages.h:35
cGate * pimDMOut
Definition: PIMSplitter.h:47
cGate * pimDMIn
Definition: PIMSplitter.h:46
virtual int inet::PIMSplitter::numInitStages ( ) const
inlineoverrideprotectedvirtual
52 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::PIMSplitter::processPIMPacket ( PIMPacket pkt)
protectedvirtual
86 {
87  IPv4ControlInfo *ctrlInfo = check_and_cast<IPv4ControlInfo *>(pkt->getControlInfo());
88  InterfaceEntry *ie = ift->getInterfaceById(ctrlInfo->getInterfaceId());
89  ASSERT(ie);
90 
91  EV_INFO << "Received packet on interface '" << ie->getName() << "'" << endl;
92 
93  PIMInterface *pimInt = pimIft->getInterfaceById(ie->getInterfaceId());
94  if (!pimInt) {
95  EV_WARN << "PIM is not enabled on interface '" << ie->getName() << "', dropping packet." << endl;
96  delete pkt;
97  return;
98  }
99 
100  switch (pimInt->getMode()) {
102  EV_INFO << "Sending packet to PIMDM.\n";
103  send(pkt, pimDMOut);
104  break;
105 
107  EV_INFO << "Sending packet to PIMSM.\n";
108  send(pkt, pimSMOut);
109  break;
110 
111  default:
112  throw cRuntimeError("PIMSplitter: PIM mode of interface '%s' is invalid.", ie->getName());
113  }
114 }
virtual InterfaceEntry * getInterfaceById(int id) const =0
Returns an interface by its Id.
PIMInterfaceTable * pimIft
Definition: PIMSplitter.h:42
IInterfaceTable * ift
Definition: PIMSplitter.h:41
cGate * pimSMOut
Definition: PIMSplitter.h:49
virtual PIMInterface * getInterfaceById(int interfaceId)
Definition: PIMInterfaceTable.cc:116
Definition: PIMInterfaceTable.h:37
Definition: PIMInterfaceTable.h:36
cGate * pimDMOut
Definition: PIMSplitter.h:47

Member Data Documentation

IInterfaceTable* inet::PIMSplitter::ift = nullptr
private
cGate* inet::PIMSplitter::ipIn = nullptr
private
cGate* inet::PIMSplitter::ipOut = nullptr
private
cGate* inet::PIMSplitter::pimDMIn = nullptr
private
cGate* inet::PIMSplitter::pimDMOut = nullptr
private
PIMInterfaceTable* inet::PIMSplitter::pimIft = nullptr
private
cGate* inet::PIMSplitter::pimSMIn = nullptr
private
cGate* inet::PIMSplitter::pimSMOut = nullptr
private

The documentation for this class was generated from the following files: