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, const 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 (const 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

◆ BindingCache6

Constructor & Destructor Documentation

◆ BindingCache()

inet::BindingCache::BindingCache ( )
30 {
31 }

◆ ~BindingCache()

inet::BindingCache::~BindingCache ( )
virtual
34 {
35 // for (unsigned int i = 0; i < bindingUpdateList.size(); i++)
36 // delete bindingUpdateList[i];
37 }

Member Function Documentation

◆ addOrUpdateBC()

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.

51 {
52  EV_INFO << "\n++++++++++++++++++++Binding Cache Being Updated in Routing Table6 ++++++++++++++\n";
53  bindingCache[hoa].careOfAddress = coa;
54  bindingCache[hoa].bindingLifetime = lifetime;
55  bindingCache[hoa].sequenceNumber = seq;
56  bindingCache[hoa].isHomeRegisteration = homeReg;
57 }

◆ deleteEntry()

void inet::BindingCache::deleteEntry ( const Ipv6Address HoA)

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

85 {
86  auto pos = bindingCache.find(HoA);
87  if (pos != bindingCache.end())
88  bindingCache.erase(pos);
89 }

◆ generateCareOfToken()

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.

109 {
110  return CO_TOKEN;
111 }

◆ generateHomeToken()

int inet::BindingCache::generateHomeToken ( const Ipv6Address HoA,
int  nonce 
)
virtual

Generates a home token from the provided parameters.

Returns a static value for now.

104 {
105  return HO_TOKEN;
106 }

◆ generateKey()

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.

114 {
115  // use a dummy value
116  return homeToken + careOfToken;
117 }

◆ getHomeRegistration()

bool inet::BindingCache::getHomeRegistration ( const Ipv6Address HoA) const

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

92 {
93  BindingCache6::const_iterator pos = bindingCache.find(HoA);
94  return (pos == bindingCache.end()) ? false : pos->second.isHomeRegisteration;
95 }

◆ getLifetime()

uint inet::BindingCache::getLifetime ( const Ipv6Address HoA) const

Returns the lifetime of the binding for the given HoA.

98 {
99  BindingCache6::const_iterator pos = bindingCache.find(HoA);
100  return (pos == bindingCache.end()) ? 0 : pos->second.bindingLifetime;
101 }

◆ handleMessage()

void inet::BindingCache::handleMessage ( cMessage *  msg)
overrideprotectedvirtual

Raises an error.

45 {
46  throw cRuntimeError("This module doesn't process messages");
47 }

◆ initialize()

void inet::BindingCache::initialize ( )
overrideprotectedvirtual
40 {
41  WATCH_MAP(bindingCache); // added by Zarrar Yousaf
42 }

◆ isInBindingCache() [1/2]

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.

80 {
81  return containsKey(bindingCache, HoA);
82 }

◆ isInBindingCache() [2/2]

bool inet::BindingCache::isInBindingCache ( const Ipv6Address HoA,
const Ipv6Address CoA 
) const

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

74 {
75  BindingCache6::const_iterator pos = bindingCache.find(HoA);
76  return (pos == bindingCache.end()) ? false : pos->second.careOfAddress == CoA;
77 }

◆ readBCSequenceNumber()

uint inet::BindingCache::readBCSequenceNumber ( const Ipv6Address HoA) const

Returns sequence number of BCE for provided HoA.

60 {
61  // Reads the sequence number of the last received BU Message
62  /*Ipv6Address HoA = bu->getHomeAddressMN();
63  uint seqNumber = bindingCache[HoA].sequenceNumber;
64  return seqNumber;*/
65 
66  // update 10.09.07 - CB
67  // the code from above creates a new (empty) entry if
68  // the provided HoA does not yet exist.
69  BindingCache6::const_iterator pos = bindingCache.find(HoA);
70  return (pos == bindingCache.end()) ? 0 : pos->second.sequenceNumber;
71 }

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const BindingCacheEntry bce 
)
friend
21 {
22  os << "CoA of MN:" << bce.careOfAddress << " BU Lifetime: " << bce.bindingLifetime
23  << " Home Registeration: " << bce.isHomeRegisteration << " BU_Sequence#: "
24  << bce.sequenceNumber << "\n";
25 
26  return os;
27 }

Member Data Documentation

◆ bindingCache


The documentation for this class was generated from the following files:
CO_TOKEN
#define CO_TOKEN
Definition: BindingCache.h:21
HO_TOKEN
#define HO_TOKEN
Definition: BindingCache.h:20
inet::BindingCache::bindingCache
BindingCache6 bindingCache
Definition: BindingCache.h:64
inet::containsKey
bool containsKey(const std::map< K, V, _C > &m, const Tk &a)
Definition: stlutils.h:80