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

This class provides network addresses using the module path to interface modules. More...

#include <ModulePathAddress.h>

Public Member Functions

 ModulePathAddress ()
 
 ModulePathAddress (int id)
 
int getId () const
 
bool tryParse (const char *addr)
 
bool isUnspecified () const
 
bool isUnicast () const
 
bool isMulticast () const
 
bool isBroadcast () const
 
bool operator== (const ModulePathAddress &addr1) const
 Returns equals(addr). More...
 
bool operator!= (const ModulePathAddress &addr1) const
 Returns !equals(addr). More...
 
bool operator< (const ModulePathAddress &addr1) const
 Compares two addresses. More...
 
bool operator<= (const ModulePathAddress &addr1) const
 
bool operator> (const ModulePathAddress &addr1) const
 
bool operator>= (const ModulePathAddress &addr1) const
 
std::string str () const
 

Static Public Member Functions

static bool maskedAddrAreEqual (const ModulePathAddress &addr1, const ModulePathAddress &addr2, int prefixLength)
 

Private Attributes

int id
 

Detailed Description

This class provides network addresses using the module path to interface modules.

The module path address supports unspecified, broadcast and multicast addresses too. TODO: add support for partial module paths addresses to allow prefix routing

Constructor & Destructor Documentation

inet::ModulePathAddress::ModulePathAddress ( )
inline
39 : id(0) {}
int id
Definition: ModulePathAddress.h:36
inet::ModulePathAddress::ModulePathAddress ( int  id)
inline
40 : id(id) {}
int id
Definition: ModulePathAddress.h:36

Member Function Documentation

int inet::ModulePathAddress::getId ( ) const
inline

Referenced by inet::GenericARP::mapUnicastAddress().

42 { return id; }
int id
Definition: ModulePathAddress.h:36
bool inet::ModulePathAddress::isBroadcast ( ) const
inline

Referenced by inet::L3Address::isBroadcast().

48 { return id == -1; }
bool inet::ModulePathAddress::isMulticast ( ) const
inline

Referenced by inet::L3Address::isMulticast().

47 { return id < -1; }
bool inet::ModulePathAddress::isUnicast ( ) const
inline

Referenced by inet::L3Address::isUnicast().

46 { return id > 0; }
bool inet::ModulePathAddress::isUnspecified ( ) const
inline

Referenced by inet::L3Address::isUnspecified().

45 { return id == 0; }
static bool inet::ModulePathAddress::maskedAddrAreEqual ( const ModulePathAddress addr1,
const ModulePathAddress addr2,
int  prefixLength 
)
inlinestatic

Referenced by inet::L3Address::matches().

67 { return addr1.id == addr2.id; }
bool inet::ModulePathAddress::operator!= ( const ModulePathAddress addr1) const
inline

Returns !equals(addr).

58 { return id != addr1.id; }
bool inet::ModulePathAddress::operator< ( const ModulePathAddress addr1) const
inline

Compares two addresses.

63 { return id < addr1.id; }
bool inet::ModulePathAddress::operator<= ( const ModulePathAddress addr1) const
inline
64 { return id <= addr1.id; }
bool inet::ModulePathAddress::operator== ( const ModulePathAddress addr1) const
inline

Returns equals(addr).

53 { return id == addr1.id; }
bool inet::ModulePathAddress::operator> ( const ModulePathAddress addr1) const
inline
65 { return id > addr1.id; }
bool inet::ModulePathAddress::operator>= ( const ModulePathAddress addr1) const
inline
66 { return id >= addr1.id; }
std::string inet::ModulePathAddress::str ( ) const

Referenced by inet::L3Address::str().

71 {
72  if (id == 0) {
73  return "<unspec>";
74  }
75  else if (id == -1) {
76  return "<BROADCAST>";
77  }
78  else if (id < -1) {
79  std::ostringstream s;
80  s << "<MULTICAST ID=" << -id << ">";
81  return s.str();
82  }
83  else /* if (id > 0) */ {
84  cModule *module = getSimulation()->getModule(id);
85  if (module) {
86  std::string fullPath = module->getFullPath();
87  return strchr(fullPath.c_str(), '.') + 1;
88  }
89  std::ostringstream s;
90  s << "<module ID=" << id << ">";
91  return s.str();
92  }
93 }
value< double, units::s > s
Definition: Units.h:1049
bool inet::ModulePathAddress::tryParse ( const char *  addr)

Referenced by inet::L3Address::tryParse().

53 {
54  cModule *module = getModuleByRelativePath(getSimulation()->getSystemModule(), addr);
55  if (module) {
56  // accepts network interface modules only:
57  if (isNetworkNode(module))
58  return false;
59  IInterfaceTable *ift = L3AddressResolver().findInterfaceTableOf(findContainingNode(module));
60  if (ift == nullptr)
61  return false;
62  if (ift->getInterfaceByInterfaceModule(module) == nullptr)
63  return false;
64  id = module->getId();
65  return true;
66  }
67  return false;
68 }
bool isNetworkNode(const cModule *mod)
Returns true if the given module is a network node, i.e.
Definition: ModuleAccess.cc:28
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:56

Member Data Documentation

int inet::ModulePathAddress::id
private

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