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

IPv4-specific data in an InterfaceEntry. More...

#include <IPv4InterfaceData.h>

Inheritance diagram for inet::IPv4InterfaceData:
inet::InterfaceProtocolData

Classes

struct  HostMulticastData
 
struct  HostMulticastGroupData
 
struct  RouterMulticastData
 
struct  RouterMulticastGroupData
 

Public Types

enum  {
  F_IP_ADDRESS, F_NETMASK, F_METRIC, F_MULTICAST_TTL_THRESHOLD,
  F_MULTICAST_ADDRESSES, F_MULTICAST_LISTENERS
}
 
typedef std::vector< IPv4AddressIPv4AddressVector
 

Public Member Functions

 IPv4InterfaceData ()
 
virtual ~IPv4InterfaceData ()
 
virtual std::string info () const override
 
virtual std::string detailedInfo () const override
 
Getters
IPv4Address getIPAddress () const
 
IPv4Address getNetmask () const
 
IPv4Address getNetworkBroadcastAddress () const
 
int getMetric () const
 
int getMulticastTtlThreshold () const
 
int getNumOfJoinedMulticastGroups () const
 
IPv4Address getJoinedMulticastGroup (int index) const
 
const IPv4MulticastSourceListgetJoinedMulticastSources (int index)
 
int getNumOfReportedMulticastGroups () const
 
IPv4Address getReportedMulticastGroup (int index) const
 
const IPv4MulticastSourceListgetReportedMulticastSources (int index) const
 
bool isMemberOfMulticastGroup (const IPv4Address &multicastAddress) const
 
bool hasMulticastListener (IPv4Address multicastAddress) const
 
bool hasMulticastListener (IPv4Address multicastAddress, IPv4Address sourceAddress) const
 
Setters
virtual void setIPAddress (IPv4Address a)
 
virtual void setNetmask (IPv4Address m)
 
virtual void setMetric (int m)
 
virtual void setMulticastTtlThreshold (int threshold)
 
virtual void joinMulticastGroup (const IPv4Address &multicastAddress)
 
virtual void leaveMulticastGroup (const IPv4Address &multicastAddress)
 
virtual void changeMulticastGroupMembership (IPv4Address multicastAddress, McastSourceFilterMode oldFilterMode, const IPv4AddressVector &oldSourceList, McastSourceFilterMode newFilterMode, const IPv4AddressVector &newSourceList)
 This method is called by sockets to register their multicast group membership changes in the interface. More...
 
virtual void addMulticastListener (const IPv4Address &multicastAddress)
 
virtual void addMulticastListener (IPv4Address multicastAddress, IPv4Address sourceAddress)
 
virtual void removeMulticastListener (const IPv4Address &multicastAddress)
 
virtual void removeMulticastListener (IPv4Address multicastAddress, IPv4Address sourceAddress)
 
virtual void setMulticastListeners (IPv4Address multicastAddress, McastSourceFilterMode filterMode, const IPv4AddressVector &sourceList)
 
- Public Member Functions inherited from inet::InterfaceProtocolData
 InterfaceProtocolData ()
 
InterfaceEntrygetInterfaceEntry () const
 Returns the InterfaceEntry that contains this data object, or nullptr. More...
 

Protected Types

typedef std::vector< HostMulticastGroupData * > HostMulticastGroupVector
 
typedef std::vector< RouterMulticastGroupData * > RouterMulticastGroupVector
 

Protected Member Functions

void changed1 (int fieldId)
 
HostMulticastDatagetHostData ()
 
const HostMulticastDatagetHostData () const
 
HostMulticastGroupDatafindHostGroupData (IPv4Address multicastAddress)
 
bool removeHostGroupData (IPv4Address multicastAddress)
 
RouterMulticastDatagetRouterData ()
 
const RouterMulticastDatagetRouterData () const
 
RouterMulticastGroupDatafindRouterGroupData (IPv4Address multicastAddress) const
 
bool removeRouterGroupData (IPv4Address multicastAddress)
 
- Protected Member Functions inherited from inet::InterfaceProtocolData
virtual void changed (simsignal_t signalID, int fieldId)
 

Protected Attributes

IPv4Address inetAddr
 IPv4 address of interface. More...
 
IPv4Address netmask
 netmask More...
 
int metric
 link "cost"; see e.g. MS KB article Q299540 More...
 
HostMulticastDatahostData
 
RouterMulticastDatarouterData
 
- Protected Attributes inherited from inet::InterfaceProtocolData
InterfaceEntryownerp = nullptr
 

Private Member Functions

 IPv4InterfaceData (const IPv4InterfaceData &obj)
 
IPv4InterfaceDataoperator= (const IPv4InterfaceData &obj)
 

Detailed Description

IPv4-specific data in an InterfaceEntry.

Stores interface IPv4 address, netmask, metric, etc.

See also
InterfaceEntry

Member Typedef Documentation

Member Enumeration Documentation

anonymous enum
Enumerator
F_IP_ADDRESS 
F_NETMASK 
F_METRIC 
F_MULTICAST_TTL_THRESHOLD 
F_MULTICAST_ADDRESSES 
F_MULTICAST_LISTENERS 
Definition: IPv4InterfaceData.h:95
Definition: IPv4InterfaceData.h:95
Definition: IPv4InterfaceData.h:95
Definition: IPv4InterfaceData.h:95
Definition: IPv4InterfaceData.h:95
Definition: IPv4InterfaceData.h:95

Constructor & Destructor Documentation

inet::IPv4InterfaceData::IPv4InterfaceData ( const IPv4InterfaceData obj)
private
inet::IPv4InterfaceData::IPv4InterfaceData ( )
157 {
159  metric = 0;
160  hostData = nullptr;
161  routerData = nullptr;
162 }
int metric
link "cost"; see e.g. MS KB article Q299540
Definition: IPv4InterfaceData.h:149
RouterMulticastData * routerData
Definition: IPv4InterfaceData.h:151
HostMulticastData * hostData
Definition: IPv4InterfaceData.h:150
IPv4Address netmask
netmask
Definition: IPv4InterfaceData.h:148
static const IPv4Address ALLONES_ADDRESS
255.255.255.255
Definition: IPv4Address.h:105
inet::IPv4InterfaceData::~IPv4InterfaceData ( )
virtual
165 {
166  delete hostData;
167  delete routerData;
168 }
RouterMulticastData * routerData
Definition: IPv4InterfaceData.h:151
HostMulticastData * hostData
Definition: IPv4InterfaceData.h:150

Member Function Documentation

void inet::IPv4InterfaceData::addMulticastListener ( const IPv4Address multicastAddress)
virtual

Referenced by inet::IGMPv2::processV2Report().

361 {
362  if (!multicastAddress.isMulticast())
363  throw cRuntimeError("IPv4InterfaceData::addMulticastListener(): multicast address expected, received %s.", multicastAddress.str().c_str());
364 
365  RouterMulticastGroupData *groupData = findRouterGroupData(multicastAddress);
366  if (!groupData) {
367  groupData = new RouterMulticastGroupData(multicastAddress);
368  getRouterData()->reportedMulticastGroups.push_back(groupData);
369 
370  IPv4MulticastGroupInfo info(getInterfaceEntry(), multicastAddress);
371  check_and_cast<cModule *>(getInterfaceEntry()->getInterfaceTable())->emit(NF_IPv4_MCAST_REGISTERED, &info);
372  }
373 
374  if (!groupData->sourceList.containsAll()) {
375  groupData->sourceList = IPv4MulticastSourceList::ALL_SOURCES;
377  }
378 }
InterfaceEntry * getInterfaceEntry() const
Returns the InterfaceEntry that contains this data object, or nullptr.
Definition: InterfaceEntry.h:77
RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
Definition: IPv4InterfaceData.h:95
IInterfaceTable * getInterfaceTable() const
Returns the IInterfaceTable this interface is in, or nullptr.
Definition: InterfaceEntry.h:168
static const IPv4MulticastSourceList ALL_SOURCES
Definition: IPv4InterfaceData.h:45
RouterMulticastGroupData * findRouterGroupData(IPv4Address multicastAddress) const
Definition: IPv4InterfaceData.cc:324
simsignal_t NF_IPv4_MCAST_REGISTERED
Definition: NotifierConsts.cc:67
RouterMulticastGroupVector reportedMulticastGroups
multicast groups that have listeners on the link connected to this interface
Definition: IPv4InterfaceData.h:138
virtual std::string info() const override
Definition: IPv4InterfaceData.cc:170
void changed1(int fieldId)
Definition: IPv4InterfaceData.h:154
void inet::IPv4InterfaceData::addMulticastListener ( IPv4Address  multicastAddress,
IPv4Address  sourceAddress 
)
virtual
381 {
382  if (!multicastAddress.isMulticast())
383  throw cRuntimeError("IPv4InterfaceData::addMulticastListener(): multicast address expected, received %s.", multicastAddress.str().c_str());
384 
385  RouterMulticastGroupData *groupData = findRouterGroupData(multicastAddress);
386  if (!groupData) {
387  groupData = new RouterMulticastGroupData(multicastAddress);
388  getRouterData()->reportedMulticastGroups.push_back(groupData);
389 
390  IPv4MulticastGroupInfo info(getInterfaceEntry(), multicastAddress);
391  check_and_cast<cModule *>(getInterfaceEntry()->getInterfaceTable())->emit(NF_IPv4_MCAST_REGISTERED, &info);
392  }
393 
394  if (!groupData->sourceList.contains(sourceAddress)) {
395  groupData->sourceList.add(sourceAddress);
397  }
398 }
InterfaceEntry * getInterfaceEntry() const
Returns the InterfaceEntry that contains this data object, or nullptr.
Definition: InterfaceEntry.h:77
RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
Definition: IPv4InterfaceData.h:95
IInterfaceTable * getInterfaceTable() const
Returns the IInterfaceTable this interface is in, or nullptr.
Definition: InterfaceEntry.h:168
RouterMulticastGroupData * findRouterGroupData(IPv4Address multicastAddress) const
Definition: IPv4InterfaceData.cc:324
simsignal_t NF_IPv4_MCAST_REGISTERED
Definition: NotifierConsts.cc:67
RouterMulticastGroupVector reportedMulticastGroups
multicast groups that have listeners on the link connected to this interface
Definition: IPv4InterfaceData.h:138
virtual std::string info() const override
Definition: IPv4InterfaceData.cc:170
void changed1(int fieldId)
Definition: IPv4InterfaceData.h:154
void inet::IPv4InterfaceData::changed1 ( int  fieldId)
inlineprotected
virtual void changed(simsignal_t signalID, int fieldId)
Definition: InterfaceEntry.cc:51
simsignal_t NF_INTERFACE_IPv4CONFIG_CHANGED
Definition: NotifierConsts.cc:53
void inet::IPv4InterfaceData::changeMulticastGroupMembership ( IPv4Address  multicastAddress,
McastSourceFilterMode  oldFilterMode,
const IPv4AddressVector oldSourceList,
McastSourceFilterMode  newFilterMode,
const IPv4AddressVector newSourceList 
)
virtual

This method is called by sockets to register their multicast group membership changes in the interface.

224 {
225  if (!multicastAddress.isMulticast())
226  throw cRuntimeError("IPv4InterfaceData::changeMulticastGroupMembership(): multicast address expected, received %s.", multicastAddress.str().c_str());
227 
228  HostMulticastGroupData *entry = findHostGroupData(multicastAddress);
229  if (!entry) {
230  ASSERT(oldFilterMode == MCAST_INCLUDE_SOURCES && oldSourceList.empty());
231  HostMulticastData *data = getHostData();
232  data->joinedMulticastGroups.push_back(new HostMulticastGroupData(multicastAddress));
233  entry = data->joinedMulticastGroups.back();
234  }
235 
236  std::map<IPv4Address, int> *counts = oldFilterMode == MCAST_INCLUDE_SOURCES ? &entry->includeCounts : &entry->excludeCounts;
237  for (const auto & elem : oldSourceList) {
238  auto count = counts->find(elem);
239  if (count == counts->end())
240  throw cRuntimeError("Inconsistent reference counts in IPv4InterfaceData.");
241  else if (count->second == 1)
242  counts->erase(count);
243  else
244  count->second--;
245  }
246 
247  counts = newFilterMode == MCAST_INCLUDE_SOURCES ? &entry->includeCounts : &entry->excludeCounts;
248  for (const auto & elem : newSourceList) {
249  auto count = counts->find(elem);
250  if (count == counts->end())
251  (*counts)[elem] = 1;
252  else
253  count->second++;
254  }
255 
256  // update number of EXCLUDE mode sockets
257  if (oldFilterMode == MCAST_INCLUDE_SOURCES && newFilterMode == MCAST_EXCLUDE_SOURCES)
258  entry->numOfExcludeModeSockets++;
259  else if (oldFilterMode == MCAST_EXCLUDE_SOURCES && newFilterMode == MCAST_INCLUDE_SOURCES)
260  entry->numOfExcludeModeSockets--;
261 
262  // compute filterMode and sourceList
263  bool changed = entry->updateSourceList();
264 
265  if (changed) {
267 
268  cModule *m = ownerp ? dynamic_cast<cModule *>(ownerp->getInterfaceTable()) : nullptr;
269  if (m) {
270  IPv4MulticastGroupSourceInfo info(ownerp, multicastAddress, entry->sourceList);
271  m->emit(NF_IPv4_MCAST_CHANGE, &info);
272  }
273 
274  // Legacy notifications
275  if (oldFilterMode != newFilterMode && oldSourceList.empty() && newSourceList.empty()) {
276  cModule *m = ownerp ? dynamic_cast<cModule *>(ownerp->getInterfaceTable()) : nullptr;
277  if (m) {
278  IPv4MulticastGroupInfo info2(ownerp, multicastAddress);
279  m->emit(newFilterMode == MCAST_EXCLUDE_SOURCES ? NF_IPv4_MCAST_JOIN : NF_IPv4_MCAST_LEAVE, &info2);
280  }
281  }
282 
283  // remove group data if it is INCLUDE(empty)
284  if (entry->sourceList.isEmpty()) {
285  removeHostGroupData(multicastAddress);
286  }
287  }
288 }
HostMulticastGroupData * findHostGroupData(IPv4Address multicastAddress)
Definition: IPv4InterfaceData.cc:466
simsignal_t NF_IPv4_MCAST_LEAVE
Definition: NotifierConsts.cc:65
int count(const std::vector< T > &v, const T &a)
Definition: stlutils.h:58
Definition: IPv4InterfaceData.h:95
IInterfaceTable * getInterfaceTable() const
Returns the IInterfaceTable this interface is in, or nullptr.
Definition: InterfaceEntry.h:168
virtual void changed(simsignal_t signalID, int fieldId)
Definition: InterfaceEntry.cc:51
simsignal_t NF_IPv4_MCAST_CHANGE
Definition: NotifierConsts.cc:66
InterfaceEntry * ownerp
Definition: InterfaceEntry.h:65
HostMulticastData * getHostData()
Definition: IPv4InterfaceData.h:155
virtual std::string info() const override
Definition: IPv4InterfaceData.cc:170
bool removeHostGroupData(IPv4Address multicastAddress)
Definition: IPv4InterfaceData.cc:477
Definition: InterfaceEntry.h:44
Definition: InterfaceEntry.h:44
void changed1(int fieldId)
Definition: IPv4InterfaceData.h:154
simsignal_t NF_IPv4_MCAST_JOIN
Definition: NotifierConsts.cc:64
value< double, units::m > m
Definition: Units.h:1047
std::string inet::IPv4InterfaceData::detailedInfo ( ) const
overridevirtual
183 {
184  std::stringstream out;
185  out << "inet addr:" << getIPAddress() << "\tMask: " << getNetmask() << "\n";
186  out << "Metric: " << getMetric() << "\n";
187  if (hostData)
188  out << hostData->detailedInfo();
189  if (routerData)
190  out << routerData->detailedInfo();
191  return out.str();
192 }
IPv4Address getNetmask() const
Definition: IPv4InterfaceData.h:178
RouterMulticastData * routerData
Definition: IPv4InterfaceData.h:151
std::string detailedInfo()
Definition: IPv4InterfaceData.cc:108
int getMetric() const
Definition: IPv4InterfaceData.h:180
IPv4Address getIPAddress() const
Definition: IPv4InterfaceData.h:177
HostMulticastData * hostData
Definition: IPv4InterfaceData.h:150
std::string detailedInfo()
Definition: IPv4InterfaceData.cc:143
IPv4InterfaceData::HostMulticastGroupData * inet::IPv4InterfaceData::findHostGroupData ( IPv4Address  multicastAddress)
protected
467 {
468  ASSERT(multicastAddress.isMulticast());
470  for (auto & entrie : entries)
471  if ((entrie)->multicastGroup == multicastAddress)
472  return entrie;
473 
474  return nullptr;
475 }
HostMulticastGroupVector joinedMulticastGroups
Definition: IPv4InterfaceData.h:118
std::vector< HostMulticastGroupData * > HostMulticastGroupVector
Definition: IPv4InterfaceData.h:114
HostMulticastData * getHostData()
Definition: IPv4InterfaceData.h:155
IPv4InterfaceData::RouterMulticastGroupData * inet::IPv4InterfaceData::findRouterGroupData ( IPv4Address  multicastAddress) const
protected
325 {
326  ASSERT(multicastAddress.isMulticast());
328  for (const auto & entrie : entries)
329  if ((entrie)->multicastGroup == multicastAddress)
330  return entrie;
331 
332  return nullptr;
333 }
RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
std::vector< RouterMulticastGroupData * > RouterMulticastGroupVector
Definition: IPv4InterfaceData.h:134
RouterMulticastGroupVector reportedMulticastGroups
multicast groups that have listeners on the link connected to this interface
Definition: IPv4InterfaceData.h:138
HostMulticastData* inet::IPv4InterfaceData::getHostData ( )
inlineprotected
155 { if (!hostData) hostData = new HostMulticastData(); return hostData; }
HostMulticastData * hostData
Definition: IPv4InterfaceData.h:150
const HostMulticastData* inet::IPv4InterfaceData::getHostData ( ) const
inlineprotected

Referenced by getHostData().

156 { return const_cast<IPv4InterfaceData *>(this)->getHostData(); }
IPv4InterfaceData()
Definition: IPv4InterfaceData.cc:156
HostMulticastData * getHostData()
Definition: IPv4InterfaceData.h:155
IPv4Address inet::IPv4InterfaceData::getIPAddress ( ) const
inline

Referenced by inet::DHCPClient::chooseInterface(), inet::IPv4RoutingTable::configureRouterId(), inet::IPv4NetworkConfigurator::createInterfaceInfo(), inet::bgp::BGPRouting::createSession(), inet::sctp::SCTPNatHook::datagramForwardHook(), inet::IPv4NetworkConfigurator::dumpConfig(), inet::RSVP::evalNextHopInterface(), inet::L3AddressResolver::findHostWithAddress(), inet::InterfaceTable::findInterfaceByAddress(), inet::IPv4RoutingTable::findInterfaceByLocalBroadcastAddress(), inet::bgp::BGPRouting::findMyAS(), inet::IPv4::fragmentAndSend(), inet::PingApp::getAllAddresses(), inet::IPv4RoutingTable::getInterfaceByAddress(), inet::L3AddressResolver::getInterfaceIPv4Address(), inet::PIMSM::IamDR(), inet::IPv4Route::info(), inet::LinkStateRouting::initialize(), inet::GlobalARP::initialize(), inet::TED::initializeTED(), inet::bgp::BGPRouting::isInInterfaceTable(), inet::IPv4RoutingTable::isLocalBroadcastAddress(), inet::InterfaceTable::isNeighborAddress(), inet::PIMDM::multicastPacketArrivedOnNonRpfInterface(), inet::PIMSM::multicastPacketArrivedOnNonRpfInterface(), inet::bgp::BGPRouting::openTCPConnectionToPeer(), inet::ICMP::possiblyLocalBroadcast(), inet::IPv4::preroutingFinish(), inet::IPv4RoutingTable::printRoutingTable(), inet::PIMDM::processAssert(), inet::PIMSM::processAssertG(), inet::PIMSM::processAssertSG(), inet::DHCPServer::processDHCPMessage(), inet::PIMDM::processGraftAckPacket(), inet::PIMDM::processGraftPacket(), inet::sctp::SCTPAssociation::processInitArrived(), inet::PIMDM::processJoin(), inet::PIMSM::processJoinG(), inet::PIMSM::processJoinSG(), inet::PIMDM::processPrune(), inet::PIMSM::processPruneG(), inet::PIMSM::processPrunePendingTimer(), inet::PIMSM::processPruneSG(), inet::IGMPv3::processQuery(), inet::PIMDM::processStateRefreshTimer(), inet::LDP::rebuildFecList(), inet::RoutingTableRecorder::recordInterfaceChange(), inet::DHCPServer::sendACK(), inet::ARP::sendARPRequest(), inet::IPv4::sendDatagramToOutput(), inet::sctp::SCTPAssociation::sendInit(), inet::DHCPServer::sendNAK(), inet::DHCPServer::sendOffer(), inet::ospf::Interface::setIfIndex(), inet::DHCPServer::startApp(), inet::PIMSM::updateDesignatedRouterAddress(), inet::InterfaceTable::updateLinkDisplayString(), inet::IPv4RoutingTable::updateNetmaskRoutes(), and inet::bgp::BGPRouting::updateSendProcess().

177 { return inetAddr; }
IPv4Address inetAddr
IPv4 address of interface.
Definition: IPv4InterfaceData.h:147
IPv4Address inet::IPv4InterfaceData::getJoinedMulticastGroup ( int  index) const
inline

Referenced by inet::InterfaceTable::collectMulticastGroups(), and inet::IPv4NetworkConfigurator::dumpConfig().

183 { return getHostData()->joinedMulticastGroups[index]->multicastGroup; }
HostMulticastGroupVector joinedMulticastGroups
Definition: IPv4InterfaceData.h:118
HostMulticastData * getHostData()
Definition: IPv4InterfaceData.h:155
const IPv4MulticastSourceList& inet::IPv4InterfaceData::getJoinedMulticastSources ( int  index)
inline
184 { return getHostData()->joinedMulticastGroups[index]->sourceList; }
HostMulticastGroupVector joinedMulticastGroups
Definition: IPv4InterfaceData.h:118
HostMulticastData * getHostData()
Definition: IPv4InterfaceData.h:155
int inet::IPv4InterfaceData::getMetric ( ) const
inline

Referenced by inet::IPv4NetworkConfigurator::dumpConfig(), inet::TED::initializeTED(), and inet::IPv4RoutingTable::updateNetmaskRoutes().

180 { return metric; }
int metric
link "cost"; see e.g. MS KB article Q299540
Definition: IPv4InterfaceData.h:149
int inet::IPv4InterfaceData::getMulticastTtlThreshold ( ) const
inline

Referenced by inet::IPv4::forwardMulticastPacket().

RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
int multicastTtlThreshold
multicast ttl threshold, used by multicast routers to limit multicast scope
Definition: IPv4InterfaceData.h:139
IPv4Address inet::IPv4InterfaceData::getNetworkBroadcastAddress ( ) const
inline

Referenced by inet::IPv4::resolveNextHopMacAddress().

IPv4Address inetAddr
IPv4 address of interface.
Definition: IPv4InterfaceData.h:147
IPv4Address makeBroadcastAddress(IPv4Address netmask) const
Returns the broadcast address for the given netmask.
Definition: IPv4Address.cc:275
IPv4Address netmask
netmask
Definition: IPv4InterfaceData.h:148
int inet::IPv4InterfaceData::getNumOfJoinedMulticastGroups ( ) const
inline

Referenced by inet::InterfaceTable::collectMulticastGroups(), and inet::IPv4NetworkConfigurator::dumpConfig().

182 { return getHostData()->joinedMulticastGroups.size(); }
HostMulticastGroupVector joinedMulticastGroups
Definition: IPv4InterfaceData.h:118
HostMulticastData * getHostData()
Definition: IPv4InterfaceData.h:155
int inet::IPv4InterfaceData::getNumOfReportedMulticastGroups ( ) const
inline
185 { return getRouterData()->reportedMulticastGroups.size(); }
RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
RouterMulticastGroupVector reportedMulticastGroups
multicast groups that have listeners on the link connected to this interface
Definition: IPv4InterfaceData.h:138
IPv4Address inet::IPv4InterfaceData::getReportedMulticastGroup ( int  index) const
inline
186 { return getRouterData()->reportedMulticastGroups[index]->multicastGroup; }
RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
RouterMulticastGroupVector reportedMulticastGroups
multicast groups that have listeners on the link connected to this interface
Definition: IPv4InterfaceData.h:138
const IPv4MulticastSourceList& inet::IPv4InterfaceData::getReportedMulticastSources ( int  index) const
inline
187 { return getRouterData()->reportedMulticastGroups[index]->sourceList; }
RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
RouterMulticastGroupVector reportedMulticastGroups
multicast groups that have listeners on the link connected to this interface
Definition: IPv4InterfaceData.h:138
RouterMulticastData* inet::IPv4InterfaceData::getRouterData ( )
inlineprotected
159 { if (!routerData) routerData = new RouterMulticastData(); return routerData; }
RouterMulticastData * routerData
Definition: IPv4InterfaceData.h:151
const RouterMulticastData* inet::IPv4InterfaceData::getRouterData ( ) const
inlineprotected

Referenced by getRouterData().

160 { return const_cast<IPv4InterfaceData *>(this)->getRouterData(); }
RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
IPv4InterfaceData()
Definition: IPv4InterfaceData.cc:156
bool inet::IPv4InterfaceData::hasMulticastListener ( IPv4Address  multicastAddress) const

Referenced by inet::IPv4::forwardMulticastPacket(), and inet::PIMDM::unroutableMulticastPacketArrived().

349 {
350  RouterMulticastGroupData *groupData = findRouterGroupData(multicastAddress);
351  return groupData && !groupData->sourceList.isEmpty();
352 }
RouterMulticastGroupData * findRouterGroupData(IPv4Address multicastAddress) const
Definition: IPv4InterfaceData.cc:324
bool inet::IPv4InterfaceData::hasMulticastListener ( IPv4Address  multicastAddress,
IPv4Address  sourceAddress 
) const
355 {
356  RouterMulticastGroupData *groupData = findRouterGroupData(multicastAddress);
357  return groupData && !groupData->sourceList.contains(sourceAddress);
358 }
RouterMulticastGroupData * findRouterGroupData(IPv4Address multicastAddress) const
Definition: IPv4InterfaceData.cc:324
std::string inet::IPv4InterfaceData::info ( ) const
overridevirtual
171 {
172  std::stringstream out;
173  out << "IPv4:{inet_addr:" << getIPAddress() << "/" << getNetmask().getNetmaskLength();
174  if (hostData)
175  out << hostData->info();
176  if (routerData)
177  out << routerData->info();
178  out << "}";
179  return out.str();
180 }
IPv4Address getNetmask() const
Definition: IPv4InterfaceData.h:178
RouterMulticastData * routerData
Definition: IPv4InterfaceData.h:151
std::string info()
Definition: IPv4InterfaceData.cc:94
IPv4Address getIPAddress() const
Definition: IPv4InterfaceData.h:177
HostMulticastData * hostData
Definition: IPv4InterfaceData.h:150
std::string info()
Definition: IPv4InterfaceData.cc:127
int getNetmaskLength() const
Counts 1 bits in a netmask.
Definition: IPv4Address.cc:245
bool inet::IPv4InterfaceData::isMemberOfMulticastGroup ( const IPv4Address multicastAddress) const

Referenced by inet::IPv4RoutingTable::isLocalMulticastAddress(), and inet::IPv4::preroutingFinish().

195 {
197  for (HostMulticastGroupVector::const_iterator it = groups.begin(); it != groups.end(); ++it)
198  if ((*it)->multicastGroup == multicastAddress)
199  return true;
200 
201  return false;
202 }
HostMulticastGroupVector joinedMulticastGroups
Definition: IPv4InterfaceData.h:118
std::vector< HostMulticastGroupData * > HostMulticastGroupVector
Definition: IPv4InterfaceData.h:114
HostMulticastData * getHostData()
Definition: IPv4InterfaceData.h:155
void inet::IPv4InterfaceData::joinMulticastGroup ( const IPv4Address multicastAddress)
virtual

Referenced by inet::UDP::addMulticastAddressToInterface(), inet::IPv4NetworkConfigurator::configureInterface(), inet::IPv4RoutingTable::configureInterfaceForIPv4(), inet::PIMBase::handleNodeStart(), inet::IGMPv3::initialize(), inet::ospf::OSPFConfigReader::joinMulticastGroups(), inet::RoutingTableParser::parseMulticastGroups(), and inet::HostAutoConfigurator::setupNetworkLayer().

206 {
209 }
std::vector< IPv4Address > IPv4AddressVector
Definition: IPv4InterfaceData.h:92
const char empty[]
Definition: ConstType.h:37
virtual void changeMulticastGroupMembership(IPv4Address multicastAddress, McastSourceFilterMode oldFilterMode, const IPv4AddressVector &oldSourceList, McastSourceFilterMode newFilterMode, const IPv4AddressVector &newSourceList)
This method is called by sockets to register their multicast group membership changes in the interfac...
Definition: IPv4InterfaceData.cc:221
Definition: InterfaceEntry.h:44
Definition: InterfaceEntry.h:44
void inet::IPv4InterfaceData::leaveMulticastGroup ( const IPv4Address multicastAddress)
virtual
213 {
216 }
std::vector< IPv4Address > IPv4AddressVector
Definition: IPv4InterfaceData.h:92
const char empty[]
Definition: ConstType.h:37
virtual void changeMulticastGroupMembership(IPv4Address multicastAddress, McastSourceFilterMode oldFilterMode, const IPv4AddressVector &oldSourceList, McastSourceFilterMode newFilterMode, const IPv4AddressVector &newSourceList)
This method is called by sockets to register their multicast group membership changes in the interfac...
Definition: IPv4InterfaceData.cc:221
Definition: InterfaceEntry.h:44
Definition: InterfaceEntry.h:44
IPv4InterfaceData& inet::IPv4InterfaceData::operator= ( const IPv4InterfaceData obj)
private
bool inet::IPv4InterfaceData::removeHostGroupData ( IPv4Address  multicastAddress)
protected
478 {
479  ASSERT(multicastAddress.isMulticast());
481  for (auto it = entries.begin(); it != entries.end(); ++it)
482  if ((*it)->multicastGroup == multicastAddress) {
483  delete *it;
484  entries.erase(it);
485  return true;
486  }
487  return false;
488 }
HostMulticastGroupVector joinedMulticastGroups
Definition: IPv4InterfaceData.h:118
std::vector< HostMulticastGroupData * > HostMulticastGroupVector
Definition: IPv4InterfaceData.h:114
HostMulticastData * getHostData()
Definition: IPv4InterfaceData.h:155
void inet::IPv4InterfaceData::removeMulticastListener ( const IPv4Address multicastAddress)
virtual

Referenced by inet::IGMPv2::processLeaveTimer(), inet::IGMPv3::processRouterGroupTimer(), and inet::IGMPv3::processRouterSourceTimer().

401 {
403 
404  int n = multicastGroups.size();
405  int i;
406  for (i = 0; i < n; i++)
407  if (multicastGroups[i]->multicastGroup == multicastAddress)
408  break;
409 
410  if (i != n) {
411  delete multicastGroups[i];
412  multicastGroups.erase(multicastGroups.begin() + i);
414 
415  IPv4MulticastGroupInfo info(getInterfaceEntry(), multicastAddress);
416  check_and_cast<cModule *>(getInterfaceEntry()->getInterfaceTable())->emit(NF_IPv4_MCAST_UNREGISTERED, &info);
417  }
418 }
InterfaceEntry * getInterfaceEntry() const
Returns the InterfaceEntry that contains this data object, or nullptr.
Definition: InterfaceEntry.h:77
RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
Definition: IPv4InterfaceData.h:95
IInterfaceTable * getInterfaceTable() const
Returns the IInterfaceTable this interface is in, or nullptr.
Definition: InterfaceEntry.h:168
simsignal_t NF_IPv4_MCAST_UNREGISTERED
Definition: NotifierConsts.cc:68
std::vector< RouterMulticastGroupData * > RouterMulticastGroupVector
Definition: IPv4InterfaceData.h:134
RouterMulticastGroupVector reportedMulticastGroups
multicast groups that have listeners on the link connected to this interface
Definition: IPv4InterfaceData.h:138
virtual std::string info() const override
Definition: IPv4InterfaceData.cc:170
void changed1(int fieldId)
Definition: IPv4InterfaceData.h:154
void inet::IPv4InterfaceData::removeMulticastListener ( IPv4Address  multicastAddress,
IPv4Address  sourceAddress 
)
virtual
421 {
423 
424  int n = multicastGroups.size();
425  int i;
426  for (i = 0; i < n; i++)
427  if (multicastGroups[i]->multicastGroup == multicastAddress)
428  break;
429 
430  if (i != n) {
431  multicastGroups[i]->sourceList.remove(sourceAddress);
432  if (multicastGroups[i]->sourceList.isEmpty()) {
433  delete multicastGroups[i];
434  multicastGroups.erase(multicastGroups.begin() + i);
435 
436  IPv4MulticastGroupInfo info(getInterfaceEntry(), multicastAddress);
437  check_and_cast<cModule *>(getInterfaceEntry()->getInterfaceTable())->emit(NF_IPv4_MCAST_UNREGISTERED, &info);
438  }
440  }
441 }
InterfaceEntry * getInterfaceEntry() const
Returns the InterfaceEntry that contains this data object, or nullptr.
Definition: InterfaceEntry.h:77
RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
Definition: IPv4InterfaceData.h:95
IInterfaceTable * getInterfaceTable() const
Returns the IInterfaceTable this interface is in, or nullptr.
Definition: InterfaceEntry.h:168
simsignal_t NF_IPv4_MCAST_UNREGISTERED
Definition: NotifierConsts.cc:68
std::vector< RouterMulticastGroupData * > RouterMulticastGroupVector
Definition: IPv4InterfaceData.h:134
RouterMulticastGroupVector reportedMulticastGroups
multicast groups that have listeners on the link connected to this interface
Definition: IPv4InterfaceData.h:138
virtual std::string info() const override
Definition: IPv4InterfaceData.cc:170
void changed1(int fieldId)
Definition: IPv4InterfaceData.h:154
bool inet::IPv4InterfaceData::removeRouterGroupData ( IPv4Address  multicastAddress)
protected
336 {
337  ASSERT(multicastAddress.isMulticast());
339  for (auto it = entries.begin(); it != entries.end(); ++it)
340  if ((*it)->multicastGroup == multicastAddress) {
341  delete *it;
342  entries.erase(it);
343  return true;
344  }
345  return false;
346 }
RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
std::vector< RouterMulticastGroupData * > RouterMulticastGroupVector
Definition: IPv4InterfaceData.h:134
RouterMulticastGroupVector reportedMulticastGroups
multicast groups that have listeners on the link connected to this interface
Definition: IPv4InterfaceData.h:138
virtual void inet::IPv4InterfaceData::setMetric ( int  m)
inlinevirtual

Referenced by inet::IPv4NetworkConfigurator::configureInterface(), inet::IPv4RoutingTable::configureInterfaceForIPv4(), inet::IPv4RoutingTable::configureLoopbackForIPv4(), and inet::RoutingTableParser::parseInterfaces().

197 { metric = m; changed1(F_METRIC); }
int metric
link "cost"; see e.g. MS KB article Q299540
Definition: IPv4InterfaceData.h:149
Definition: IPv4InterfaceData.h:95
void changed1(int fieldId)
Definition: IPv4InterfaceData.h:154
value< double, units::m > m
Definition: Units.h:1047
void inet::IPv4InterfaceData::setMulticastListeners ( IPv4Address  multicastAddress,
McastSourceFilterMode  filterMode,
const IPv4AddressVector sourceList 
)
virtual

Referenced by inet::IGMPv3::processReport().

444 {
445  if (!multicastAddress.isMulticast())
446  throw cRuntimeError("IPv4InterfaceData::setMulticastListeners(): multicast address expected, received %s.", multicastAddress.str().c_str());
447 
448  RouterMulticastGroupData *groupData = findRouterGroupData(multicastAddress);
449  if (!groupData) {
450  groupData = new RouterMulticastGroupData(multicastAddress);
451  getRouterData()->reportedMulticastGroups.push_back(groupData);
452  }
453 
454  if (filterMode != groupData->sourceList.filterMode || sourceList != groupData->sourceList.sources) {
455  if (filterMode != MCAST_INCLUDE_SOURCES || !sourceList.empty()) {
456  groupData->sourceList.filterMode = filterMode;
457  groupData->sourceList.sources = sourceList;
458  }
459  else
460  removeRouterGroupData(multicastAddress);
461 
463  }
464 }
RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
Definition: IPv4InterfaceData.h:95
RouterMulticastGroupData * findRouterGroupData(IPv4Address multicastAddress) const
Definition: IPv4InterfaceData.cc:324
RouterMulticastGroupVector reportedMulticastGroups
multicast groups that have listeners on the link connected to this interface
Definition: IPv4InterfaceData.h:138
bool removeRouterGroupData(IPv4Address multicastAddress)
Definition: IPv4InterfaceData.cc:335
Definition: InterfaceEntry.h:44
void changed1(int fieldId)
Definition: IPv4InterfaceData.h:154
virtual void inet::IPv4InterfaceData::setMulticastTtlThreshold ( int  threshold)
inlinevirtual
RouterMulticastData * getRouterData()
Definition: IPv4InterfaceData.h:159
int multicastTtlThreshold
multicast ttl threshold, used by multicast routers to limit multicast scope
Definition: IPv4InterfaceData.h:139
Definition: IPv4InterfaceData.h:95
void changed1(int fieldId)
Definition: IPv4InterfaceData.h:154
virtual void inet::IPv4InterfaceData::setNetmask ( IPv4Address  m)
inlinevirtual

Member Data Documentation

HostMulticastData* inet::IPv4InterfaceData::hostData
protected
IPv4Address inet::IPv4InterfaceData::inetAddr
protected

IPv4 address of interface.

int inet::IPv4InterfaceData::metric
protected

link "cost"; see e.g. MS KB article Q299540

IPv4Address inet::IPv4InterfaceData::netmask
protected

netmask

RouterMulticastData* inet::IPv4InterfaceData::routerData
protected

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