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

IPv4 multicast route in IIPv4RoutingTable. More...

#include <IPv4Route.h>

Inheritance diagram for inet::IPv4MulticastRoute:
inet::IMulticastRoute

Public Types

enum  {
  F_ORIGIN, F_ORIGINMASK, F_MULTICASTGROUP, F_IN,
  F_OUT, F_SOURCE, F_METRIC, F_LAST
}
 
- Public Types inherited from inet::IMulticastRoute
enum  SourceType { MANUAL, DVMRP, PIM_DM, PIM_SM }
 Specifies where the route comes from. More...
 
typedef std::vector< OutInterface * > OutInterfaceVector
 

Public Member Functions

 IPv4MulticastRoute ()
 
virtual ~IPv4MulticastRoute ()
 
virtual std::string info () const override
 
virtual std::string detailedInfo () const override
 
virtual void setRoutingTable (IIPv4RoutingTable *rt)
 To be called by the routing table when this route is added or removed from it. More...
 
IIPv4RoutingTablegetRoutingTable () const
 
virtual bool isValid () const
 test validity of route entry, e.g. More...
 
virtual bool matches (const IPv4Address &origin, const IPv4Address &group) const
 
virtual void setOrigin (IPv4Address _origin)
 
virtual void setOriginNetmask (IPv4Address _netmask)
 
virtual void setMulticastGroup (IPv4Address _group)
 
virtual void setInInterface (InInterface *_inInterface) override
 
virtual void clearOutInterfaces () override
 
virtual void addOutInterface (OutInterface *outInterface) override
 
virtual bool removeOutInterface (const InterfaceEntry *ie) override
 
virtual void removeOutInterface (unsigned int i) override
 
virtual void setSourceType (SourceType _source) override
 
virtual void setMetric (int _metric) override
 
IPv4Address getOrigin () const
 Source address prefix to match. More...
 
IPv4Address getOriginNetmask () const
 Represents length of prefix to match. More...
 
IPv4Address getMulticastGroup () const
 Multicast group address. More...
 
InInterfacegetInInterface () const
 In interface. More...
 
unsigned int getNumOutInterfaces () const
 Number of out interfaces. More...
 
OutInterfacegetOutInterface (unsigned int k) const
 The kth out interface. More...
 
SourceType getSourceType () const override
 Source of route. More...
 
int getMetric () const override
 "Cost" to reach the destination More...
 
void setSource (cObject *_source) override
 
cObject * getSource () const override
 Source of route. More...
 
virtual IRoutingTablegetRoutingTableAsGeneric () const override
 The routing table in which this route is inserted, or nullptr. More...
 
virtual void setEnabled (bool enabled) override
 
virtual void setOrigin (const L3Address &origin) override
 
virtual void setPrefixLength (int len) override
 
virtual void setMulticastGroup (const L3Address &group) override
 
virtual bool isEnabled () const override
 Disabled entries are ignored by routing until the became enabled again. More...
 
virtual bool isExpired () const override
 Expired entries are ignored by routing, and may be periodically purged. More...
 
virtual L3Address getOriginAsGeneric () const override
 Source address prefix to match. More...
 
virtual int getPrefixLength () const override
 Prefix length to match. More...
 
virtual L3Address getMulticastGroupAsGeneric () const override
 Multicast group address. More...
 
- Public Member Functions inherited from inet::IMulticastRoute
virtual ~IMulticastRoute ()
 
virtual void setInInterface (InInterface *_inInterface)=0
 
virtual void setSourceType (SourceType type)=0
 

Protected Member Functions

void changed (int fieldCode)
 

Private Member Functions

 IPv4MulticastRoute (const IPv4MulticastRoute &obj)
 
IPv4MulticastRouteoperator= (const IPv4MulticastRoute &obj)
 

Private Attributes

IIPv4RoutingTablert
 the routing table in which this route is inserted, or nullptr More...
 
IPv4Address origin
 Source network. More...
 
IPv4Address originNetmask
 Source network mask. More...
 
IPv4Address group
 Multicast group, if unspecified then matches any. More...
 
InInterfaceinInterface
 In interface (upstream) More...
 
OutInterfaceVector outInterfaces
 Out interfaces (downstream) More...
 
SourceType sourceType
 manual, routing prot, etc. More...
 
cObject * source
 Object identifying the source. More...
 
int metric
 Metric ("cost" to reach the source) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from inet::IMulticastRoute
static const char * sourceTypeName (SourceType sourceType)
 

Detailed Description

IPv4 multicast route in IIPv4RoutingTable.

Multicast routing protocols may extend this class to store protocol specific fields.

Multicast datagrams are forwarded along the edges of a multicast tree. The tree might depend on the multicast group and the source (origin) of the multicast datagram.

The forwarding algorithm chooses the route according the to origin (source address) and multicast group (destination address) of the received datagram. The route might specify a prefix of the origin and a multicast group to be matched.

Then the forwarding algorithm copies the datagrams arrived on the parent (upstream) interface to the child interfaces (downstream). If there are no downstream routers on a child interface (i.e. it is a leaf in the multicast routing tree), then the datagram is forwarded only if there are listeners of the multicast group on that link (TRPB routing).

See also
IIPv4RoutingTable, IPv4RoutingTable

Member Enumeration Documentation

anonymous enum
Enumerator
F_ORIGIN 
F_ORIGINMASK 
F_MULTICASTGROUP 
F_IN 
F_OUT 
F_SOURCE 
F_METRIC 
F_LAST 
Definition: IPv4Route.h:181
Definition: IPv4Route.h:181
Definition: IPv4Route.h:181
Definition: IPv4Route.h:181
Definition: IPv4Route.h:181
Definition: IPv4Route.h:181
Definition: IPv4Route.h:181

Constructor & Destructor Documentation

inet::IPv4MulticastRoute::IPv4MulticastRoute ( const IPv4MulticastRoute obj)
private
inet::IPv4MulticastRoute::IPv4MulticastRoute ( )
inline
192 : rt(nullptr), inInterface(nullptr), sourceType(MANUAL), source(nullptr), metric(0) {}
cObject * source
Object identifying the source.
Definition: IPv4Route.h:176
InInterface * inInterface
In interface (upstream)
Definition: IPv4Route.h:173
SourceType sourceType
manual, routing prot, etc.
Definition: IPv4Route.h:175
IIPv4RoutingTable * rt
the routing table in which this route is inserted, or nullptr
Definition: IPv4Route.h:169
manually added static route
Definition: IRoute.h:154
int metric
Metric ("cost" to reach the source)
Definition: IPv4Route.h:177
inet::IPv4MulticastRoute::~IPv4MulticastRoute ( )
virtual
110 {
111  delete inInterface;
112  for (auto & elem : outInterfaces)
113  delete elem;
114  outInterfaces.clear();
115 }
OutInterfaceVector outInterfaces
Out interfaces (downstream)
Definition: IPv4Route.h:174
InInterface * inInterface
In interface (upstream)
Definition: IPv4Route.h:173

Member Function Documentation

void inet::IPv4MulticastRoute::addOutInterface ( OutInterface outInterface)
overridevirtual

Implements inet::IMulticastRoute.

Referenced by inet::IPv4NetworkConfigurator::configureRoutingTable(), inet::PIMSM::createIPv4Route(), inet::PIMDM::multicastReceiverAdded(), inet::IPv4NetworkConfigurator::readManualMulticastRouteConfiguration(), inet::PIMDM::rpfInterfaceHasChanged(), and inet::PIMDM::unroutableMulticastPacketArrived().

188 {
189  ASSERT(outInterface);
190 
191  auto it = outInterfaces.begin();
192  for ( ; it != outInterfaces.end(); ++it) {
193  if ((*it)->getInterface() == outInterface->getInterface()) {
194  delete *it;
195  *it = outInterface;
196  changed(F_OUT);
197  return;
198  }
199  }
200 
201  outInterfaces.push_back(outInterface);
202  changed(F_OUT);
203 }
Definition: IPv4Route.h:181
void changed(int fieldCode)
Definition: IPv4Route.cc:226
OutInterfaceVector outInterfaces
Out interfaces (downstream)
Definition: IPv4Route.h:174
void inet::IPv4MulticastRoute::changed ( int  fieldCode)
protected
227 {
228  if (rt)
229  rt->multicastRouteChanged(this, fieldCode);
230 }
IIPv4RoutingTable * rt
the routing table in which this route is inserted, or nullptr
Definition: IPv4Route.h:169
virtual void multicastRouteChanged(IPv4MulticastRoute *entry, int fieldCode)=0
To be called from multicast route objects whenever a field changes.
void inet::IPv4MulticastRoute::clearOutInterfaces ( )
overridevirtual

Implements inet::IMulticastRoute.

173 {
174  if (!outInterfaces.empty()) {
175  for (auto & elem : outInterfaces)
176  delete elem;
177  outInterfaces.clear();
178  changed(F_OUT);
179  }
180 }
Definition: IPv4Route.h:181
void changed(int fieldCode)
Definition: IPv4Route.cc:226
OutInterfaceVector outInterfaces
Out interfaces (downstream)
Definition: IPv4Route.h:174
std::string inet::IPv4MulticastRoute::detailedInfo ( ) const
overridevirtual
159 {
160  return info();
161 }
virtual std::string info() const override
Definition: IPv4Route.cc:117
int inet::IPv4MulticastRoute::getMetric ( ) const
inlineoverridevirtual
virtual L3Address inet::IPv4MulticastRoute::getMulticastGroupAsGeneric ( ) const
inlineoverridevirtual

Multicast group address.

Implements inet::IMulticastRoute.

258 { return getMulticastGroup(); }
IPv4Address getMulticastGroup() const
Multicast group address.
Definition: IPv4Route.h:228
unsigned int inet::IPv4MulticastRoute::getNumOutInterfaces ( ) const
inline
virtual L3Address inet::IPv4MulticastRoute::getOriginAsGeneric ( ) const
inlineoverridevirtual

Source address prefix to match.

Implements inet::IMulticastRoute.

256 { return getOrigin(); }
IPv4Address getOrigin() const
Source address prefix to match.
Definition: IPv4Route.h:222
IPv4Address inet::IPv4MulticastRoute::getOriginNetmask ( ) const
inline
OutInterface* inet::IPv4MulticastRoute::getOutInterface ( unsigned int  k) const
inline

The kth out interface.

Referenced by inet::IPv4NetworkConfigurator::configureRoutingTable(), inet::IPv4NetworkConfigurator::dumpConfig(), inet::IPv4::forwardMulticastPacket(), inet::IPv4RoutingTable::internalAddMulticastRoute(), and inet::IPv4RoutingTable::printMulticastRoutingTable().

237 { return outInterfaces.at(k); }
OutInterfaceVector outInterfaces
Out interfaces (downstream)
Definition: IPv4Route.h:174
const double k
Definition: QAM16Modulation.cc:24
virtual int inet::IPv4MulticastRoute::getPrefixLength ( ) const
inlineoverridevirtual

Prefix length to match.

Implements inet::IMulticastRoute.

257 { return getOriginNetmask().getNetmaskLength(); } //TODO inconsistent naming
IPv4Address getOriginNetmask() const
Represents length of prefix to match.
Definition: IPv4Route.h:225
int getNetmaskLength() const
Counts 1 bits in a netmask.
Definition: IPv4Address.cc:245
IIPv4RoutingTable* inet::IPv4MulticastRoute::getRoutingTable ( ) const
inline

Referenced by inet::IPv4RoutingTable::deleteInterfaceRoutes(), inet::IPv4RoutingTable::deleteMulticastRoute(), inet::IPv4RoutingTable::purge(), and inet::IPv4RoutingTable::removeMulticastRoute().

199 { return rt; }
IIPv4RoutingTable * rt
the routing table in which this route is inserted, or nullptr
Definition: IPv4Route.h:169
IRoutingTable * inet::IPv4MulticastRoute::getRoutingTableAsGeneric ( ) const
overridevirtual

The routing table in which this route is inserted, or nullptr.

Implements inet::IMulticastRoute.

183 {
184  return getRoutingTable();
185 }
IIPv4RoutingTable * getRoutingTable() const
Definition: IPv4Route.h:199
cObject* inet::IPv4MulticastRoute::getSource ( ) const
inlineoverridevirtual
SourceType inet::IPv4MulticastRoute::getSourceType ( ) const
inlineoverridevirtual

Source of route.

MANUAL (read from file), from routing protocol, etc

Implements inet::IMulticastRoute.

Referenced by inet::IPv4NetworkConfigurator::configureRoutingTable().

240 { return sourceType; }
SourceType sourceType
manual, routing prot, etc.
Definition: IPv4Route.h:175
std::string inet::IPv4MulticastRoute::info ( ) const
overridevirtual

Referenced by inet::operator<<().

118 {
119  std::stringstream out;
120 
121  out << "origin:";
122  if (origin.isUnspecified())
123  out << "* ";
124  else
125  out << origin << " ";
126  out << "mask:";
128  out << "* ";
129  else
130  out << originNetmask << " ";
131  out << "group:";
132  if (group.isUnspecified())
133  out << "* ";
134  else
135  out << group << " ";
136  out << "metric:" << metric << " ";
137  out << "in:";
138  if (!inInterface)
139  out << "* ";
140  else
141  out << inInterface->getInterface()->getName() << " ";
142  out << "out:";
143  bool first = true;
144  for (auto & elem : outInterfaces) {
145  if (!first)
146  out << ",";
147  if (elem->isEnabled()) {
148  out << elem->getInterface()->getName();
149  first = false;
150  }
151  }
152 
154 
155  return out.str();
156 }
bool isUnspecified() const
True if all four address bytes are zero.
Definition: IPv4Address.h:176
IPv4Address group
Multicast group, if unspecified then matches any.
Definition: IPv4Route.h:172
static const char * sourceTypeName(SourceType sourceType)
Definition: IRoute.cc:69
InterfaceEntry * getInterface() const
Definition: IRoute.h:169
OutInterfaceVector outInterfaces
Out interfaces (downstream)
Definition: IPv4Route.h:174
InInterface * inInterface
In interface (upstream)
Definition: IPv4Route.h:173
SourceType sourceType
manual, routing prot, etc.
Definition: IPv4Route.h:175
IPv4Address originNetmask
Source network mask.
Definition: IPv4Route.h:171
IPv4Address origin
Source network.
Definition: IPv4Route.h:170
int metric
Metric ("cost" to reach the source)
Definition: IPv4Route.h:177
virtual bool inet::IPv4MulticastRoute::isEnabled ( ) const
inlineoverridevirtual

Disabled entries are ignored by routing until the became enabled again.

Implements inet::IMulticastRoute.

254 { return true; /*TODO: isEnabled();*/ }
virtual bool inet::IPv4MulticastRoute::isExpired ( ) const
inlineoverridevirtual

Expired entries are ignored by routing, and may be periodically purged.

Implements inet::IMulticastRoute.

255 { return !isValid(); } //TODO rename IPv4 method
virtual bool isValid() const
test validity of route entry, e.g.
Definition: IPv4Route.h:202
virtual bool inet::IPv4MulticastRoute::isValid ( ) const
inlinevirtual

test validity of route entry, e.g.

check expiry

Referenced by inet::IPv4RoutingTable::purge().

202 { return true; }
virtual bool inet::IPv4MulticastRoute::matches ( const IPv4Address origin,
const IPv4Address group 
) const
inlinevirtual
205  {
206  return (this->group.isUnspecified() || this->group == group) &&
208  }
bool isUnspecified() const
True if all four address bytes are zero.
Definition: IPv4Address.h:176
static bool maskedAddrAreEqual(const IPv4Address &addr1, const IPv4Address &addr2, const IPv4Address &netmask)
Test if the masked addresses (ie the mask is applied to addr1 and addr2) are equal.
Definition: IPv4Address.cc:260
IPv4Address group
Multicast group, if unspecified then matches any.
Definition: IPv4Route.h:172
IPv4Address originNetmask
Source network mask.
Definition: IPv4Route.h:171
IPv4Address origin
Source network.
Definition: IPv4Route.h:170
IPv4MulticastRoute& inet::IPv4MulticastRoute::operator= ( const IPv4MulticastRoute obj)
private
bool inet::IPv4MulticastRoute::removeOutInterface ( const InterfaceEntry ie)
overridevirtual

Implements inet::IMulticastRoute.

Referenced by inet::IPv4RoutingTable::deleteInterfaceRoutes(), inet::PIMSM::Route::removeDownstreamInterface(), and inet::PIMDM::rpfInterfaceHasChanged().

206 {
207  for (auto it = outInterfaces.begin(); it != outInterfaces.end(); ++it) {
208  if ((*it)->getInterface() == ie) {
209  delete *it;
210  outInterfaces.erase(it);
211  changed(F_OUT);
212  return true;
213  }
214  }
215  return false;
216 }
Definition: IPv4Route.h:181
void changed(int fieldCode)
Definition: IPv4Route.cc:226
OutInterfaceVector outInterfaces
Out interfaces (downstream)
Definition: IPv4Route.h:174
void inet::IPv4MulticastRoute::removeOutInterface ( unsigned int  i)
overridevirtual

Implements inet::IMulticastRoute.

219 {
220  OutInterface *outInterface = outInterfaces.at(i);
221  delete outInterface;
222  outInterfaces.erase(outInterfaces.begin() + i);
223  changed(F_OUT);
224 }
Definition: IPv4Route.h:181
void changed(int fieldCode)
Definition: IPv4Route.cc:226
OutInterfaceVector outInterfaces
Out interfaces (downstream)
Definition: IPv4Route.h:174
virtual void inet::IPv4MulticastRoute::setEnabled ( bool  enabled)
inlineoverridevirtual

Implements inet::IMulticastRoute.

249 { /*TODO: setEnabled(enabled);*/ }
void inet::IPv4MulticastRoute::setInInterface ( InInterface _inInterface)
overridevirtual

Referenced by inet::IPv4NetworkConfigurator::configureRoutingTable(), inet::PIMSM::createIPv4Route(), inet::IPv4NetworkConfigurator::readManualMulticastRouteConfiguration(), inet::PIMDM::rpfInterfaceHasChanged(), and inet::PIMDM::unroutableMulticastPacketArrived().

164 {
165  if (inInterface != _inInterface) {
166  delete inInterface;
167  inInterface = _inInterface;
168  changed(F_IN);
169  }
170 }
void changed(int fieldCode)
Definition: IPv4Route.cc:226
InInterface * inInterface
In interface (upstream)
Definition: IPv4Route.h:173
Definition: IPv4Route.h:181
virtual void inet::IPv4MulticastRoute::setMetric ( int  _metric)
inlineoverridevirtual

Implements inet::IMulticastRoute.

Referenced by inet::IPv4NetworkConfigurator::configureRoutingTable(), and inet::IPv4NetworkConfigurator::readManualMulticastRouteConfiguration().

219 { if (metric != _metric) { metric = _metric; changed(F_METRIC); } }
void changed(int fieldCode)
Definition: IPv4Route.cc:226
Definition: IPv4Route.h:181
int metric
Metric ("cost" to reach the source)
Definition: IPv4Route.h:177
virtual void inet::IPv4MulticastRoute::setMulticastGroup ( IPv4Address  _group)
inlinevirtual

Referenced by inet::IPv4NetworkConfigurator::configureRoutingTable(), inet::PIMSM::createIPv4Route(), inet::IPv4NetworkConfigurator::readManualMulticastRouteConfiguration(), and inet::PIMDM::unroutableMulticastPacketArrived().

212 { if (group != _group) { group = _group; changed(F_MULTICASTGROUP); } }
IPv4Address group
Multicast group, if unspecified then matches any.
Definition: IPv4Route.h:172
void changed(int fieldCode)
Definition: IPv4Route.cc:226
virtual void inet::IPv4MulticastRoute::setMulticastGroup ( const L3Address group)
inlineoverridevirtual

Implements inet::IMulticastRoute.

Referenced by setMulticastGroup().

252 { setMulticastGroup(group.toIPv4()); }
IPv4Address group
Multicast group, if unspecified then matches any.
Definition: IPv4Route.h:172
virtual void setMulticastGroup(IPv4Address _group)
Definition: IPv4Route.h:212
virtual void inet::IPv4MulticastRoute::setOrigin ( IPv4Address  _origin)
inlinevirtual

Referenced by inet::IPv4NetworkConfigurator::configureRoutingTable(), inet::PIMSM::createIPv4Route(), inet::IPv4NetworkConfigurator::readManualMulticastRouteConfiguration(), and inet::PIMDM::unroutableMulticastPacketArrived().

210 { if (origin != _origin) { origin = _origin; changed(F_ORIGIN); } }
void changed(int fieldCode)
Definition: IPv4Route.cc:226
Definition: IPv4Route.h:181
IPv4Address origin
Source network.
Definition: IPv4Route.h:170
virtual void inet::IPv4MulticastRoute::setOrigin ( const L3Address origin)
inlineoverridevirtual

Implements inet::IMulticastRoute.

Referenced by setOrigin().

250 { setOrigin(origin.toIPv4()); }
virtual void setOrigin(IPv4Address _origin)
Definition: IPv4Route.h:210
IPv4Address origin
Source network.
Definition: IPv4Route.h:170
virtual void inet::IPv4MulticastRoute::setOriginNetmask ( IPv4Address  _netmask)
inlinevirtual
virtual void inet::IPv4MulticastRoute::setPrefixLength ( int  len)
inlineoverridevirtual

Implements inet::IMulticastRoute.

251 { setOriginNetmask(IPv4Address::makeNetmask(len)); } //TODO inconsistent naming
uint16_t len
Definition: TCP_NSC.cc:85
virtual void setOriginNetmask(IPv4Address _netmask)
Definition: IPv4Route.h:211
static IPv4Address makeNetmask(int length)
Creates and returns a netmask with the given length.
Definition: IPv4Address.h:335
virtual void inet::IPv4MulticastRoute::setRoutingTable ( IIPv4RoutingTable rt)
inlinevirtual

To be called by the routing table when this route is added or removed from it.

Referenced by inet::IPv4RoutingTable::internalAddMulticastRoute(), and inet::IPv4RoutingTable::removeMulticastRoute().

198 { this->rt = rt; }
IIPv4RoutingTable * rt
the routing table in which this route is inserted, or nullptr
Definition: IPv4Route.h:169
void inet::IPv4MulticastRoute::setSource ( cObject *  _source)
inlineoverridevirtual

Implements inet::IMulticastRoute.

Referenced by inet::IPv4NetworkConfigurator::configureRoutingTable(), inet::PIMSM::createIPv4Route(), and inet::PIMDM::unroutableMulticastPacketArrived().

245 { source = _source; }
cObject * source
Object identifying the source.
Definition: IPv4Route.h:176
virtual void inet::IPv4MulticastRoute::setSourceType ( SourceType  _source)
inlineoverridevirtual

Referenced by inet::IPv4NetworkConfigurator::configureRoutingTable(), inet::PIMSM::createIPv4Route(), inet::IPv4NetworkConfigurator::readManualMulticastRouteConfiguration(), and inet::PIMDM::unroutableMulticastPacketArrived().

218 { if (sourceType != _source) { sourceType = _source; changed(F_SOURCE); } }
void changed(int fieldCode)
Definition: IPv4Route.cc:226
Definition: IPv4Route.h:181
SourceType sourceType
manual, routing prot, etc.
Definition: IPv4Route.h:175

Member Data Documentation

IPv4Address inet::IPv4MulticastRoute::group
private

Multicast group, if unspecified then matches any.

InInterface* inet::IPv4MulticastRoute::inInterface
private

In interface (upstream)

int inet::IPv4MulticastRoute::metric
private

Metric ("cost" to reach the source)

IPv4Address inet::IPv4MulticastRoute::origin
private

Source network.

IPv4Address inet::IPv4MulticastRoute::originNetmask
private

Source network mask.

OutInterfaceVector inet::IPv4MulticastRoute::outInterfaces
private

Out interfaces (downstream)

IIPv4RoutingTable* inet::IPv4MulticastRoute::rt
private

the routing table in which this route is inserted, or nullptr

cObject* inet::IPv4MulticastRoute::source
private

Object identifying the source.

SourceType inet::IPv4MulticastRoute::sourceType
private

manual, routing prot, etc.


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