INET Framework for OMNeT++/OMNEST
inet::eigrp::EigrpNetworkTable< IPAddress > Class Template Reference

Table with networks for routing. More...

#include <EigrpNetworkTable.h>

Inheritance diagram for inet::eigrp::EigrpNetworkTable< IPAddress >:

Public Member Functions

 EigrpNetworkTable ()
 
virtual ~EigrpNetworkTable ()
 
EigrpNetwork< IPAddress > * addNetwork (IPAddress &address, IPAddress &mask)
 
EigrpNetwork< IPAddress > * findNetworkById (int netId)
 
std::vector< EigrpNetwork< IPAddress > * > * getAllNetworks ()
 
bool isAddressIncluded (IPAddress &address, IPAddress &mask)
 
bool isInterfaceIncluded (const IPAddress &ifAddress, const IPAddress &ifMask, int *resultNetId)
 Returns true if interface with specified address is contained in EIGRP. More...
 
bool isInterfaceIncluded (const Ipv4Address &ifAddress, const Ipv4Address &ifMask, int *resultNetId)
 
bool isInterfaceIncluded (const Ipv6Address &ifAddress, const Ipv6Address &ifMask, int *resultNetId)
 Determines if specified netaddress/mask is included in eigrp process. More...
 

Static Public Attributes

static const int UNSPEC_NETID = 0
 

Protected Attributes

std::vector< EigrpNetwork< IPAddress > * > networkVec
 
int networkCnt
 

Detailed Description

template<typename IPAddress>
class inet::eigrp::EigrpNetworkTable< IPAddress >

Table with networks for routing.

Constructor & Destructor Documentation

◆ EigrpNetworkTable()

template<typename IPAddress >
inet::eigrp::EigrpNetworkTable< IPAddress >::EigrpNetworkTable ( )
inline
73 : networkCnt(1) {}

◆ ~EigrpNetworkTable()

template<typename IPAddress >
inet::eigrp::EigrpNetworkTable< IPAddress >::~EigrpNetworkTable
virtual
19 {
20  int cnt = networkVec.size();
21 
22  for (int i = 0; i < cnt; i++) {
23  delete networkVec[i];
24  }
25  networkVec.clear();
26 }

Member Function Documentation

◆ addNetwork()

template<typename IPAddress >
EigrpNetwork< IPAddress > * inet::eigrp::EigrpNetworkTable< IPAddress >::addNetwork ( IPAddress &  address,
IPAddress &  mask 
)
30 {
31  typename std::vector<EigrpNetwork<IPAddress> *>::iterator it;
32  for (it = networkVec.begin(); it != networkVec.end(); ++it) { // through all networks search same
33  if ((*it)->getAddress() == address && (*it)->getMask() == mask) { // found same -> do not add new
34  return *it;
35  }
36  }
37 
38  // Not found -> add new
39  EigrpNetwork<IPAddress> *net = new EigrpNetwork<IPAddress>(address, mask, networkCnt++);
40  networkVec.push_back(net);
41  return net;
42 }

◆ findNetworkById()

template<typename IPAddress >
EigrpNetwork< IPAddress > * inet::eigrp::EigrpNetworkTable< IPAddress >::findNetworkById ( int  netId)
46 {
47  typename std::vector<EigrpNetwork<IPAddress> *>::iterator it;
48 
49  for (it = networkVec.begin(); it != networkVec.end(); it++) {
50  if ((*it)->getNetworkId() == netId) {
51  return *it;
52  }
53  }
54 
55  return nullptr;
56 }

◆ getAllNetworks()

template<typename IPAddress >
std::vector<EigrpNetwork<IPAddress> *>* inet::eigrp::EigrpNetworkTable< IPAddress >::getAllNetworks ( )
inline
78 { return &networkVec; }

◆ isAddressIncluded()

template<typename IPAddress >
bool inet::eigrp::EigrpNetworkTable< IPAddress >::isAddressIncluded ( IPAddress &  address,
IPAddress &  mask 
)

◆ isInterfaceIncluded() [1/3]

template<typename IPAddress >
bool inet::eigrp::EigrpNetworkTable< IPAddress >::isInterfaceIncluded ( const IPAddress &  ifAddress,
const IPAddress &  ifMask,
int *  resultNetId 
)

Returns true if interface with specified address is contained in EIGRP.

Parameters
resultNetIdID of network that belongs to the interface. If the interface does not belong to any network, it has undefined value.

◆ isInterfaceIncluded() [2/3]

bool inet::eigrp::EigrpNetworkTable< Ipv4Address >::isInterfaceIncluded ( const Ipv4Address ifAddress,
const Ipv4Address ifMask,
int *  resultNetId 
)
60 {
61  typename std::vector<EigrpNetwork<Ipv4Address> *>::iterator it;
62  int netMaskLen, ifMaskLen;
63 
64  if (ifAddress.isUnspecified())
65  return false;
66 
67  for (it = networkVec.begin(); it != networkVec.end(); it++) {
68  Ipv4Address netPrefix = (*it)->getAddress();
69  Ipv4Address netMask = (*it)->getMask();
70 
71  netMaskLen = (netMask.isUnspecified()) ? getNetmaskLength(netPrefix.getNetworkMask()) : getNetmaskLength(netMask);
72  ifMaskLen = getNetmaskLength(ifMask);
73 
74  // prefix isUnspecified -> network = 0.0.0.0 -> all interfaces, or
75  // mask is unspecified -> classful match or
76  // mask is specified -> classless match
77  if (netPrefix.isUnspecified() ||
78  (netMask.isUnspecified() && netPrefix.isNetwork(ifAddress) && netMaskLen <= ifMaskLen) ||
79  (maskedAddrAreEqual(netPrefix, ifAddress, netMask) && netMaskLen <= ifMaskLen))
80  { // IP address of the interface match the prefix
81  (*resultNetId) = (*it)->getNetworkId();
82  return true;
83  }
84  }
85 
86  return false;
87 }

◆ isInterfaceIncluded() [3/3]

bool inet::eigrp::EigrpNetworkTable< Ipv6Address >::isInterfaceIncluded ( const Ipv6Address ifAddress,
const Ipv6Address ifMask,
int *  resultNetId 
)

Determines if specified netaddress/mask is included in eigrp process.

Parameters
ifAddressaddress of interface
ifMaskmask of interface
resultNetIdID of network
Returns
True (and set resultNetId) if address is included in network, which is enabled in Eigrp process, otherwise false (resultNetId is undefined).

In IPv6 is netmask always specified, because it is strictly classless. Configuration is defined per interfaces, and there is no wildcard. In other words matching is much simpler that in the IPv4.

102 {
103  typename std::vector<EigrpNetwork<Ipv6Address> *>::iterator it;
104  int netMaskLen, ifMaskLen;
105 
106  if (ifAddress.isUnspecified())
107  return false; // interface without address can not be included in Eigrp process
108 
109  for (it = networkVec.begin(); it != networkVec.end(); it++) { // go through all networks and determine if ifAddress is from that network
110  Ipv6Address netPrefix = (*it)->getAddress(); // network address
111  Ipv6Address netMask = (*it)->getMask(); // network mask
112 
113  netMaskLen = getNetmaskLength(netMask);
114  ifMaskLen = getNetmaskLength(ifMask);
115 
116  // prefix isUnspecified -> network = 0.0.0.0 -> all interfaces, or
117  // prefix is specified -> classless match
118  if (netPrefix.isUnspecified() ||
119  (maskedAddrAreEqual(netPrefix, ifAddress, netMask) && netMaskLen <= ifMaskLen)) // TODO - PROB-02 - reused from IPv4 version, is it ok?
120  { // IP address of the interface match the prefix
121  (*resultNetId) = (*it)->getNetworkId();
122  return true;
123  }
124  }
125 
126  return false;
127 }

Member Data Documentation

◆ networkCnt

template<typename IPAddress >
int inet::eigrp::EigrpNetworkTable< IPAddress >::networkCnt
protected

◆ networkVec

template<typename IPAddress >
std::vector<EigrpNetwork<IPAddress> *> inet::eigrp::EigrpNetworkTable< IPAddress >::networkVec
protected

◆ UNSPEC_NETID

template<typename IPAddress >
const int inet::eigrp::EigrpNetworkTable< IPAddress >::UNSPEC_NETID = 0
static

The documentation for this class was generated from the following files:
inet::getNetmaskLength
int getNetmaskLength(const Ipv4Address &netmask)
Uses IPv4Address.getNetmaskLength() method.
Definition: EigrpDualStack.cc:22
inet::eigrp::EigrpNetworkTable::networkCnt
int networkCnt
Definition: EigrpNetworkTable.h:68
inet::maskedAddrAreEqual
bool maskedAddrAreEqual(const Ipv4Address &addr1, const Ipv4Address &addr2, const Ipv4Address &netmask)
Compare two IPv4 addresses masked by netmask.
Definition: EigrpDualStack.cc:43
inet::eigrp::EigrpNetworkTable::networkVec
std::vector< EigrpNetwork< IPAddress > * > networkVec
Definition: EigrpNetworkTable.h:67