INET Framework for OMNeT++/OMNEST
inet::NetworkConfiguratorBase::InterfaceMatcher Class Reference

#include <NetworkConfiguratorBase.h>

Public Member Functions

 InterfaceMatcher (const char *pattern)
 
 ~InterfaceMatcher ()
 
bool matches (InterfaceInfo *interfaceInfo)
 
bool matchesAny ()
 

Protected Attributes

bool matchesany = false
 
std::vector< inet::PatternMatcher * > nameMatchers
 
std::vector< inet::PatternMatcher * > towardsMatchers
 

Constructor & Destructor Documentation

inet::NetworkConfiguratorBase::InterfaceMatcher::InterfaceMatcher ( const char *  pattern)
551 {
552  matchesany = isEmpty(pattern);
553  if (matchesany)
554  return;
555  cStringTokenizer tokenizer(pattern);
556  while (tokenizer.hasMoreTokens()) {
557  const char *token = tokenizer.nextToken();
558  if (*token == '>')
559  towardsMatchers.push_back(new inet::PatternMatcher(token + 1, true, true, true));
560  else
561  nameMatchers.push_back(new inet::PatternMatcher(token, true, true, true));
562  }
563 }
std::vector< inet::PatternMatcher * > nameMatchers
Definition: NetworkConfiguratorBase.h:146
std::vector< inet::PatternMatcher * > towardsMatchers
Definition: NetworkConfiguratorBase.h:147
bool matchesany
Definition: NetworkConfiguratorBase.h:145
Glob-style pattern matching class, adopted to special OMNeT++ requirements.
Definition: PatternMatcher.h:78
bool isEmpty(const char *s)
Definition: L2NetworkConfigurator.cc:35
inet::NetworkConfiguratorBase::InterfaceMatcher::~InterfaceMatcher ( )
566 {
567  for (auto & nameMatcher : nameMatchers)
568  delete nameMatcher;
569  for (auto & towardsMatcher : towardsMatchers)
570  delete towardsMatcher;
571 }
std::vector< inet::PatternMatcher * > nameMatchers
Definition: NetworkConfiguratorBase.h:146
std::vector< inet::PatternMatcher * > towardsMatchers
Definition: NetworkConfiguratorBase.h:147

Member Function Documentation

bool inet::NetworkConfiguratorBase::InterfaceMatcher::matches ( InterfaceInfo interfaceInfo)

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

574 {
575  if (matchesany)
576  return true;
577 
578  const char *interfaceName = interfaceInfo->interfaceEntry->getName();
579  for (auto & nameMatcher : nameMatchers)
580  if (nameMatcher->matches(interfaceName))
581  return true;
582 
583  LinkInfo *linkInfo = interfaceInfo->linkInfo;
584  cModule *ownerModule = interfaceInfo->interfaceEntry->getInterfaceTable()->getHostModule();
585  for (auto & candidateInfo : linkInfo->interfaceInfos) {
586  cModule *candidateModule = candidateInfo->interfaceEntry->getInterfaceTable()->getHostModule();
587  if (candidateModule == ownerModule)
588  continue;
589  std::string candidateFullPath = candidateModule->getFullPath();
590  std::string candidateShortenedFullPath = candidateFullPath.substr(candidateFullPath.find('.') + 1);
591  for (auto & towardsMatcher : towardsMatchers)
592  if (towardsMatcher->matches(candidateShortenedFullPath.c_str()) ||
593  towardsMatcher->matches(candidateFullPath.c_str()))
594  return true;
595 
596  }
597  return false;
598 }
std::vector< inet::PatternMatcher * > nameMatchers
Definition: NetworkConfiguratorBase.h:146
std::vector< inet::PatternMatcher * > towardsMatchers
Definition: NetworkConfiguratorBase.h:147
bool matchesany
Definition: NetworkConfiguratorBase.h:145
bool inet::NetworkConfiguratorBase::InterfaceMatcher::matchesAny ( )
inline
154 { return matchesany; }
bool matchesany
Definition: NetworkConfiguratorBase.h:145

Member Data Documentation

bool inet::NetworkConfiguratorBase::InterfaceMatcher::matchesany = false
protected
std::vector<inet::PatternMatcher *> inet::NetworkConfiguratorBase::InterfaceMatcher::nameMatchers
protected
std::vector<inet::PatternMatcher *> inet::NetworkConfiguratorBase::InterfaceMatcher::towardsMatchers
protected

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