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

PIMInterfaceTable contains an PIMInterface entry for each interface on which PIM is enabled. More...

#include <PIMInterfaceTable.h>

Inheritance diagram for inet::PIMInterfaceTable:

Public Member Functions

virtual ~PIMInterfaceTable ()
 
virtual int getNumInterfaces ()
 
virtual PIMInterfacegetInterface (int k)
 
virtual PIMInterfacegetInterfaceById (int interfaceId)
 

Protected Types

typedef std::vector< PIMInterface * > PIMInterfaceVector
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *) override
 
virtual void receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override
 
virtual void configureInterfaces (cXMLElement *config)
 
virtual PIMInterfacecreateInterface (InterfaceEntry *ie, cXMLElement *config)
 
virtual PIMInterfaceVector::iterator findInterface (InterfaceEntry *ie)
 
virtual void addInterface (InterfaceEntry *ie)
 
virtual void removeInterface (InterfaceEntry *ie)
 

Protected Attributes

PIMInterfaceVector pimInterfaces
 

Detailed Description

PIMInterfaceTable contains an PIMInterface entry for each interface on which PIM is enabled.

When interfaces are added to/deleted from the InterfaceTable, then the corresponding PIMInterface entry is added/deleted automatically.

Member Typedef Documentation

Constructor & Destructor Documentation

inet::PIMInterfaceTable::~PIMInterfaceTable ( )
virtual
49 {
50  for (auto & elem : pimInterfaces)
51  delete elem;
52 }
PIMInterfaceVector pimInterfaces
Definition: PIMInterfaceTable.h:74

Member Function Documentation

void inet::PIMInterfaceTable::addInterface ( InterfaceEntry ie)
protectedvirtual
152 {
153  ASSERT(findInterface(ie) == pimInterfaces.end());
154 
155  cXMLElement *config = par("pimConfig").xmlValue();
156  cXMLElementList interfaceElements = config->getChildrenByTagName("interface");
157  InterfaceMatcher matcher(interfaceElements);
158 
159  int i = matcher.findMatchingSelector(ie);
160  if (i >= 0) {
161  PIMInterface *pimInterface = createInterface(ie, interfaceElements[i]);
162  if (pimInterface)
163  pimInterfaces.push_back(pimInterface);
164  }
165 }
virtual PIMInterface * createInterface(InterfaceEntry *ie, cXMLElement *config)
Definition: PIMInterfaceTable.cc:96
PIMInterfaceVector pimInterfaces
Definition: PIMInterfaceTable.h:74
virtual PIMInterfaceVector::iterator findInterface(InterfaceEntry *ie)
Definition: PIMInterfaceTable.cc:142
void inet::PIMInterfaceTable::configureInterfaces ( cXMLElement *  config)
protectedvirtual
78 {
79  cXMLElementList interfaceElements = config->getChildrenByTagName("interface");
80  InterfaceMatcher matcher(interfaceElements);
81  IInterfaceTable *ift = getModuleFromPar<IInterfaceTable>(par("interfaceTableModule"), this);
82 
83  for (int k = 0; k < ift->getNumInterfaces(); ++k) {
84  InterfaceEntry *ie = ift->getInterface(k);
85  if (ie->isMulticast() && !ie->isLoopback()) {
86  int i = matcher.findMatchingSelector(ie);
87  if (i >= 0) {
88  PIMInterface *pimInterface = createInterface(ie, interfaceElements[i]);
89  if (pimInterface)
90  pimInterfaces.push_back(pimInterface);
91  }
92  }
93  }
94 }
virtual PIMInterface * createInterface(InterfaceEntry *ie, cXMLElement *config)
Definition: PIMInterfaceTable.cc:96
PIMInterfaceVector pimInterfaces
Definition: PIMInterfaceTable.h:74
const double k
Definition: QAM16Modulation.cc:24
PIMInterface * inet::PIMInterfaceTable::createInterface ( InterfaceEntry ie,
cXMLElement *  config 
)
protectedvirtual
97 {
98  const char *modeAttr = config->getAttribute("mode");
99  if (!modeAttr)
100  return nullptr;
101 
103  if (strcmp(modeAttr, "dense") == 0)
105  else if (strcmp(modeAttr, "sparse") == 0)
107  else
108  throw cRuntimeError("PIMInterfaceTable: invalid 'mode' attribute value in the configuration of interface '%s'", ie->getName());
109 
110  const char *stateRefreshAttr = config->getAttribute("state-refresh");
111  bool stateRefreshFlag = stateRefreshAttr && !strcmp(stateRefreshAttr, "true");
112 
113  return new PIMInterface(ie, mode, stateRefreshFlag);
114 }
PIMMode
Definition: PIMInterfaceTable.h:35
Definition: PIMInterfaceTable.h:37
Definition: PIMInterfaceTable.h:36
PIMInterfaceTable::PIMInterfaceVector::iterator inet::PIMInterfaceTable::findInterface ( InterfaceEntry ie)
protectedvirtual
143 {
144  for (auto it = pimInterfaces.begin(); it != pimInterfaces.end(); ++it)
145  if ((*it)->getInterfacePtr() == ie)
146  return it;
147 
148  return pimInterfaces.end();
149 }
PIMInterfaceVector pimInterfaces
Definition: PIMInterfaceTable.h:74
virtual PIMInterface* inet::PIMInterfaceTable::getInterface ( int  k)
inlinevirtual

Referenced by inet::PIMSM::addNewRouteG(), and inet::PIMSM::addNewRouteSG().

80 { return pimInterfaces[k]; }
PIMInterfaceVector pimInterfaces
Definition: PIMInterfaceTable.h:74
const double k
Definition: QAM16Modulation.cc:24
PIMInterface * inet::PIMInterfaceTable::getInterfaceById ( int  interfaceId)
virtual

Referenced by inet::PIMSM::getIncomingInterface(), inet::PIMSM::IamDR(), inet::PIMSM::receiveSignal(), inet::PIMSM::unroutableMulticastPacketArrived(), and inet::PIMSM::updateDesignatedRouterAddress().

117 {
118  for (int i = 0; i < getNumInterfaces(); i++)
119  if (interfaceId == getInterface(i)->getInterfaceId())
120  return getInterface(i);
121 
122  return nullptr;
123 }
virtual PIMInterface * getInterface(int k)
Definition: PIMInterfaceTable.h:80
int getInterfaceId() const
Definition: PIMInterfaceTable.h:55
virtual int getNumInterfaces()
Definition: PIMInterfaceTable.h:79
virtual int inet::PIMInterfaceTable::getNumInterfaces ( )
inlinevirtual

Referenced by inet::PIMSM::addNewRouteG(), and inet::PIMSM::addNewRouteSG().

79 { return pimInterfaces.size(); }
PIMInterfaceVector pimInterfaces
Definition: PIMInterfaceTable.h:74
void inet::PIMInterfaceTable::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
55 {
56  throw cRuntimeError("This module doesn't process messages");
57 }
void inet::PIMInterfaceTable::initialize ( int  stage)
overrideprotectedvirtual
60 {
61  cSimpleModule::initialize(stage);
62 
63  if (stage == INITSTAGE_LOCAL) {
64  WATCH_VECTOR(pimInterfaces);
65  }
66  else if (stage == INITSTAGE_LINK_LAYER_2) {
67  configureInterfaces(par("pimConfig").xmlValue());
68 
69  cModule *host = findContainingNode(this);
70  if (!host)
71  throw cRuntimeError("PIMInterfaceTable: containing node not found.");
72  host->subscribe(NF_INTERFACE_CREATED, this);
73  host->subscribe(NF_INTERFACE_DELETED, this);
74  }
75 }
virtual void configureInterfaces(cXMLElement *config)
Definition: PIMInterfaceTable.cc:77
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:56
Local initializations.
Definition: InitStages.h:35
simsignal_t NF_INTERFACE_CREATED
Definition: NotifierConsts.cc:48
PIMInterfaceVector pimInterfaces
Definition: PIMInterfaceTable.h:74
simsignal_t NF_INTERFACE_DELETED
Definition: NotifierConsts.cc:49
Additional link-layer initializations that depend on the previous stage.
Definition: InitStages.h:64
virtual int inet::PIMInterfaceTable::numInitStages ( ) const
inlineoverrideprotectedvirtual
84 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::PIMInterfaceTable::receiveSignal ( cComponent *  source,
simsignal_t  signalID,
cObject *  obj,
cObject *  details 
)
overrideprotectedvirtual
126 {
127  Enter_Method_Silent();
128  printNotificationBanner(signalID, obj);
129 
130  if (signalID == NF_INTERFACE_CREATED) {
131  InterfaceEntry *ie = check_and_cast<InterfaceEntry *>(obj);
132  if (ie->isMulticast() && !ie->isLoopback())
133  addInterface(ie);
134  }
135  else if (signalID == NF_INTERFACE_DELETED) {
136  InterfaceEntry *ie = check_and_cast<InterfaceEntry *>(obj);
137  if (ie->isMulticast() && !ie->isLoopback())
138  removeInterface(ie);
139  }
140 }
virtual void removeInterface(InterfaceEntry *ie)
Definition: PIMInterfaceTable.cc:167
virtual void addInterface(InterfaceEntry *ie)
Definition: PIMInterfaceTable.cc:151
simsignal_t NF_INTERFACE_CREATED
Definition: NotifierConsts.cc:48
void printNotificationBanner(simsignal_t signalID, const cObject *obj)
Utility function.
Definition: NotifierConsts.cc:109
simsignal_t NF_INTERFACE_DELETED
Definition: NotifierConsts.cc:49
void inet::PIMInterfaceTable::removeInterface ( InterfaceEntry ie)
protectedvirtual
168 {
169  auto it = findInterface(ie);
170  if (it != pimInterfaces.end())
171  pimInterfaces.erase(it);
172 }
PIMInterfaceVector pimInterfaces
Definition: PIMInterfaceTable.h:74
virtual PIMInterfaceVector::iterator findInterface(InterfaceEntry *ie)
Definition: PIMInterfaceTable.cc:142

Member Data Documentation

PIMInterfaceVector inet::PIMInterfaceTable::pimInterfaces
protected

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