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

#include <BindingCache.h>

Inheritance diagram for inet::BindingCache:

Classes

struct  BindingCacheEntry
 

Public Member Functions

 BindingCache ()
 
virtual ~BindingCache ()
 
void addOrUpdateBC (const IPv6Address &hoa, const IPv6Address &coa, const uint lifetime, const uint seq, bool homeReg)
 Sets Binding Cache Entry (BCE) with provided values. More...
 
uint readBCSequenceNumber (const IPv6Address &HoA) const
 Returns sequence number of BCE for provided HoA. More...
 
bool isInBindingCache (const IPv6Address &HoA, IPv6Address &CoA) const
 Added by CB, 29.08.07 Checks whether there is an entry in the BC for the given HoA and CoA. More...
 
bool isInBindingCache (const IPv6Address &HoA) const
 Added by CB, 4.9.07 Checks whether there is an entry in the BC for the given HoA. More...
 
void deleteEntry (IPv6Address &HoA)
 Added by CB, 4.9.07 Delete the entry from the cache with the provided HoA. More...
 
bool getHomeRegistration (const IPv6Address &HoA) const
 Returns the value of the homeRegistration flag for the given HoA. More...
 
uint getLifetime (const IPv6Address &HoA) const
 Returns the lifetime of the binding for the given HoA. More...
 
virtual int generateHomeToken (const IPv6Address &HoA, int nonce)
 Generates a home token from the provided parameters. More...
 
virtual int generateCareOfToken (const IPv6Address &CoA, int nonce)
 Generates a care-of token from the provided parameters. More...
 
virtual int generateKey (int homeToken, int careOfToken, const IPv6Address &CoA)
 Generates the key Kbm from home and care-of keygen token. More...
 

Protected Member Functions

virtual void initialize () override
 
virtual void handleMessage (cMessage *) override
 Raises an error. More...
 

Private Types

typedef std::map< IPv6Address, BindingCacheEntryBindingCache6
 

Private Attributes

BindingCache6 bindingCache
 

Friends

std::ostream & operator<< (std::ostream &os, const BindingCacheEntry &bce)
 

Member Typedef Documentation

Constructor & Destructor Documentation

inet::BindingCache::BindingCache ( )
39 {
40 }
inet::BindingCache::~BindingCache ( )
virtual
43 {
44 // for (unsigned int i = 0; i < bindingUpdateList.size(); i++)
45 // delete bindingUpdateList[i];
46 }

Member Function Documentation

void inet::BindingCache::addOrUpdateBC ( const IPv6Address hoa,
const IPv6Address coa,
const uint  lifetime,
const uint  seq,
bool  homeReg 
)

Sets Binding Cache Entry (BCE) with provided values.

If BCE does not yet exist, a new one will be created.

Referenced by inet::xMIPv6::processBUMessage().

60 {
61  EV_INFO << "\n++++++++++++++++++++Binding Cache Being Updated in Routing Table6 ++++++++++++++\n";
62  bindingCache[hoa].careOfAddress = coa;
63  bindingCache[hoa].bindingLifetime = lifetime;
64  bindingCache[hoa].sequenceNumber = seq;
65  bindingCache[hoa].isHomeRegisteration = homeReg;
66 }
BindingCache6 bindingCache
Definition: BindingCache.h:78
void inet::BindingCache::deleteEntry ( IPv6Address HoA)

Added by CB, 4.9.07 Delete the entry from the cache with the provided HoA.

Referenced by inet::xMIPv6::handleBCExpiry(), and inet::xMIPv6::processBUMessage().

102 {
103  auto pos = bindingCache.find(HoA);
104 
105  if (pos != bindingCache.end()) // update 11.9.07 - CB
106  bindingCache.erase(pos);
107 }
BindingCache6 bindingCache
Definition: BindingCache.h:78
int inet::BindingCache::generateCareOfToken ( const IPv6Address CoA,
int  nonce 
)
virtual

Generates a care-of token from the provided parameters.

Returns a static value for now.

Referenced by inet::xMIPv6::processCoTIMessage(), and inet::xMIPv6::validateBUMessage().

135 {
136  return CO_TOKEN;
137 }
#define CO_TOKEN
Definition: BindingCache.h:34
int inet::BindingCache::generateHomeToken ( const IPv6Address HoA,
int  nonce 
)
virtual

Generates a home token from the provided parameters.

Returns a static value for now.

Referenced by inet::xMIPv6::processHoTIMessage(), and inet::xMIPv6::validateBUMessage().

130 {
131  return HO_TOKEN;
132 }
#define HO_TOKEN
Definition: BindingCache.h:33
int inet::BindingCache::generateKey ( int  homeToken,
int  careOfToken,
const IPv6Address CoA 
)
virtual

Generates the key Kbm from home and care-of keygen token.

For now, this return the sum of both tokens.

Referenced by inet::xMIPv6::validateBUMessage().

140 {
141  // use a dummy value
142  return homeToken + careOfToken;
143 }
bool inet::BindingCache::getHomeRegistration ( const IPv6Address HoA) const

Returns the value of the homeRegistration flag for the given HoA.

Referenced by inet::xMIPv6::validateBUderegisterMessage(), and inet::xMIPv6::validateBUMessage().

110 {
111  BindingCache6::const_iterator pos = bindingCache.find(HoA);
112 
113  if (pos == bindingCache.end())
114  return false; // HoA not yet registered; should not occur anyway
115  else
116  return pos->second.isHomeRegisteration;
117 }
BindingCache6 bindingCache
Definition: BindingCache.h:78
uint inet::BindingCache::getLifetime ( const IPv6Address HoA) const

Returns the lifetime of the binding for the given HoA.

Referenced by inet::xMIPv6::processBUMessage().

120 {
121  BindingCache6::const_iterator pos = bindingCache.find(HoA);
122 
123  if (pos == bindingCache.end())
124  return 0; // HoA not yet registered; should not occur anyway
125  else
126  return pos->second.bindingLifetime;
127 }
BindingCache6 bindingCache
Definition: BindingCache.h:78
void inet::BindingCache::handleMessage ( cMessage *  msg)
overrideprotectedvirtual

Raises an error.

54 {
55  throw cRuntimeError("This module doesn't process messages");
56 }
void inet::BindingCache::initialize ( )
overrideprotectedvirtual
49 {
50  WATCH_MAP(bindingCache); //added by Zarrar Yousaf
51 }
BindingCache6 bindingCache
Definition: BindingCache.h:78
bool inet::BindingCache::isInBindingCache ( const IPv6Address HoA,
IPv6Address CoA 
) const

Added by CB, 29.08.07 Checks whether there is an entry in the BC for the given HoA and CoA.

Referenced by inet::xMIPv6::processBUMessage(), inet::xMIPv6::processHoAOpt(), and inet::xMIPv6::validateBUderegisterMessage().

87 {
88  BindingCache6::const_iterator pos = bindingCache.find(HoA);
89 
90  if (pos == bindingCache.end())
91  return false; // if HoA is not registered then there's obviously no valid entry in the BC
92 
93  return pos->second.careOfAddress == CoA; // if CoA corresponds to HoA, everything is fine
94 }
BindingCache6 bindingCache
Definition: BindingCache.h:78
bool inet::BindingCache::isInBindingCache ( const IPv6Address HoA) const

Added by CB, 4.9.07 Checks whether there is an entry in the BC for the given HoA.

97 {
98  return bindingCache.find(HoA) != bindingCache.end();
99 }
BindingCache6 bindingCache
Definition: BindingCache.h:78
uint inet::BindingCache::readBCSequenceNumber ( const IPv6Address HoA) const

Returns sequence number of BCE for provided HoA.

Referenced by inet::xMIPv6::validateBUMessage().

69 {
70  //Reads the sequence number of the last received BU Message
71  /*IPv6Address HoA = bu->getHomeAddressMN();
72  uint seqNumber = bindingCache[HoA].sequenceNumber;
73  return seqNumber;*/
74 
75  // update 10.09.07 - CB
76  // the code from above creates a new (empty) entry if
77  // the provided HoA does not yet exist.
78  BindingCache6::const_iterator pos = bindingCache.find(HoA);
79 
80  if (pos == bindingCache.end())
81  return 0; // HoA not yet registered
82  else
83  return pos->second.sequenceNumber;
84 }
BindingCache6 bindingCache
Definition: BindingCache.h:78

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const BindingCacheEntry bce 
)
friend
30 {
31  os << "CoA of MN:" << bce.careOfAddress << " BU Lifetime: " << bce.bindingLifetime
32  << " Home Registeration: " << bce.isHomeRegisteration << " BU_Sequence#: "
33  << bce.sequenceNumber << "\n";
34 
35  return os;
36 }

Member Data Documentation


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