Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TSrvAddrMgr Class Reference

#include <SrvAddrMgr.h>

+ Inheritance diagram for TSrvAddrMgr:
+ Collaboration diagram for TSrvAddrMgr:

Classes

struct  TExpiredInfo
class  TSrvCacheEntry

Public Member Functions

 ~TSrvAddrMgr ()
void addCachedEntry (SPtr< TDUID > clntDuid, SPtr< TIPv6Addr > cachedEntry, TIAType type)
bool addClntAddr (SPtr< TDUID > clntDuid, SPtr< TIPv6Addr > clntAddr, int iface, unsigned long IAID, unsigned long T1, unsigned long T2, SPtr< TIPv6Addr > addr, unsigned long pref, unsigned long valid, bool quiet)
 adds an address to the client.
bool addrIsFree (SPtr< TIPv6Addr > addr)
bool addTAAddr (SPtr< TDUID > clntDuid, SPtr< TIPv6Addr > clntAddr, int iface, unsigned long iaid, SPtr< TIPv6Addr > addr, unsigned long pref, unsigned long valid)
 adds TA address to AddrMgr
bool delCachedEntry (SPtr< TIPv6Addr > cachedEntry, TIAType type)
bool delCachedEntry (SPtr< TDUID > clntDuid, TIAType type)
bool delClntAddr (SPtr< TDUID > duid, unsigned long IAID, SPtr< TIPv6Addr > addr, bool quiet)
virtual bool delPrefix (SPtr< TDUID > clntDuid, unsigned long IAID, SPtr< TIPv6Addr > prefix, bool quiet)
bool delTAAddr (SPtr< TDUID > duid, unsigned long iaid, SPtr< TIPv6Addr > addr, bool quiet)
void doDuties (std::vector< TExpiredInfo > &addrLst, std::vector< TExpiredInfo > &tempAddrLst, std::vector< TExpiredInfo > &prefixLst)
 remove outdated addresses
void dump ()
 stores content of the AddrMgr database to a file
void getAddrsCount (SPtr< TContainer< SPtr< TSrvCfgAddrClass > >> classes, long *clntCnt, long *addrCnt, SPtr< TDUID > duid, int iface)
SPtr< TIPv6AddrgetCachedEntry (SPtr< TDUID > clntDuid, TIAType type)
SPtr< TIPv6AddrgetFirstAddr (SPtr< TDUID > clntDuid)
unsigned long getLeaseCount (SPtr< TDUID > duid)
 returns how many leases does this client have?
void setCacheSize (int bytes)
bool taAddrIsFree (SPtr< TIPv6Addr > addr)
virtual bool verifyAddr (SPtr< TIPv6Addr > addr)
 Checks if address is still supported in current configuration (used in loadDB)
virtual bool verifyPrefix (SPtr< TIPv6Addr > addr)
 Checks if prefix is still supported in current configuration (used in loadDB)
- Public Member Functions inherited from TAddrMgr
 TAddrMgr (const std::string &addrdb, bool loadfile=false)
virtual ~TAddrMgr ()
void addClient (SPtr< TAddrClient > x)
virtual bool addPrefix (SPtr< TDUID > clntDuid, SPtr< TIPv6Addr > clntAddr, const std::string &ifname, int ifindex, unsigned long IAID, unsigned long T1, unsigned long T2, SPtr< TIPv6Addr > prefix, unsigned long pref, unsigned long valid, int length, bool quiet)
int countClient ()
void dbLoad (const char *xmlFile)
 loads XML database from disk
bool delClient (SPtr< TDUID > duid)
void firstClient ()
SPtr< TAddrClientgetClient ()
SPtr< TAddrClientgetClient (SPtr< TDUID > duid)
 returns client with a specified DUID
SPtr< TAddrClientgetClient (uint32_t SPI)
 returns client with specified SPI index
SPtr< TAddrClientgetClient (SPtr< TIPv6Addr > leasedAddr)
 returns client that leased specified address
uint64_t getNextReplayDetectionValue ()
unsigned long getPrefTimeout ()
unsigned long getT1Timeout ()
unsigned long getT2Timeout ()
unsigned long getValidTimeout ()
bool isDone ()
 returns if shutdown is complete
SPtr< TAddrAddrparseAddrAddr (const char *xmlFile, char *buf, bool pd)
 parses single address
SPtr< TAddrClientparseAddrClient (const char *xmlFile, FILE *f)
 parses XML section that defines single client
SPtr< TAddrIAparseAddrIA (const char *xmlFile, FILE *f, int t1, int t2, int iaid, const std::string &ifname, int ifindex, SPtr< TIPv6Addr > unicast=SPtr< TIPv6Addr >())
 parses part XML section that represents single IA
SPtr< TAddrIAparseAddrPD (const char *xmlFile, FILE *f, int t1, int t2, int iaid, const std::string &ifname, int ifindex, SPtr< TIPv6Addr > unicast=SPtr< TIPv6Addr >())
 parses part XML section that represents single PD
SPtr< TAddrPrefixparseAddrPrefix (const char *xmlFile, char *buf, bool pd)
SPtr< TAddrIAparseAddrTA (const char *xmlFile, FILE *f)
bool prefixIsFree (SPtr< TIPv6Addr > prefix)
bool updateInterfacesInfo (const NameToIndexMapping &nameToIndex, const IndexToNameMapping &indexToName)
 tries to update interface name/index information (if required)
bool updateInterfacesInfoIA (SPtr< TAddrIA > ia, const NameToIndexMapping &nameToIndex, const IndexToNameMapping &indexToName)
virtual bool updatePrefix (SPtr< TDUID > duid, SPtr< TIPv6Addr > addr, const std::string &ifname, int ifindex, unsigned long IAID, unsigned long T1, unsigned long T2, SPtr< TIPv6Addr > prefix, unsigned long pref, unsigned long valid, int length, bool quiet)
bool xmlLoadBuiltIn (const char *xmlFile)
 loads AddrMgr database from a file

Static Public Member Functions

static TSrvAddrMgrinstance ()
static void instanceCreate (const std::string &xmlFile, bool loadDB)

Protected Member Functions

 TSrvAddrMgr (const std::string &xmlfile, bool loadDB)
void cacheDump ()
void cacheRead ()
void checkCacheSize ()
void print (std::ostream &out)
- Protected Member Functions inherited from TAddrMgr
bool addPrefix (SPtr< TAddrClient > client, SPtr< TDUID > duid, SPtr< TIPv6Addr > clntAddr, const std::string &ifname, int ifindex, unsigned long IAID, unsigned long T1, unsigned long T2, SPtr< TIPv6Addr > prefix, unsigned long pref, unsigned long valid, int length, bool quiet)
bool updatePrefix (SPtr< TAddrClient > client, SPtr< TDUID > duid, SPtr< TIPv6Addr > clntAddr, int iface, unsigned long IAID, unsigned long T1, unsigned long T2, SPtr< TIPv6Addr > prefix, unsigned long pref, unsigned long valid, int length, bool quiet)

Protected Attributes

TContainer< SPtr
< TSrvCacheEntry > > 
Cache
size_t CacheMaxSize
- Protected Attributes inherited from TAddrMgr
TContainer< SPtr< TAddrClient > > ClntsLst
bool DeleteEmptyClient
 should the client without any IA, TA or PDs be deleted? (srv = yes, client = no)
bool IsDone
uint64_t ReplayDetectionValue_
std::string XmlFile

Static Protected Attributes

static TSrvAddrMgrInstance = 0

Additional Inherited Members

- Public Types inherited from TAddrMgr
typedef std::map< int,
std::string > 
IndexToNameMapping
 holds network interface ifindex to name mapping
typedef std::map< std::string,
int > 
NameToIndexMapping
 holds network interface name to ifindex mapping

Constructor & Destructor Documentation

TSrvAddrMgr::~TSrvAddrMgr ( )
TSrvAddrMgr::TSrvAddrMgr ( const std::string &  xmlfile,
bool  loadDB 
)
protected

Member Function Documentation

void TSrvAddrMgr::addCachedEntry ( SPtr< TDUID clntDuid,
SPtr< TIPv6Addr cachedAddr,
TIAType  type 
)

this function adds an address or prefix to a cache. If there is entry for this client, updates it

Parameters
clntDuid
cachedAddr
typetype of entry looked for (TYPE_IA for address or TYPE_PD for prefix)
bool TSrvAddrMgr::addClntAddr ( SPtr< TDUID clntDuid,
SPtr< TIPv6Addr clntAddr,
int  iface,
unsigned long  IAID,
unsigned long  T1,
unsigned long  T2,
SPtr< TIPv6Addr addr,
unsigned long  pref,
unsigned long  valid,
bool  quiet 
)

adds an address to the client.

Adds a single address to the client. If the client is not present in address manager, adds it, too. Also, if client's IA is missing, adds it as well.

Parameters
clntDuidclient DUID
clntAddrclient's address (link-local, used if unicast is to be used)
ifaceinterface, on which client is reachable
IAIDID of an IA
T1- T1 timer
T2- T2 timer
addr- address to be added
prefpreferred lifetime
validvalid lifetime
quietquiet mode (e.g. used during SOLICIT handling, don't print anything about adding client/IA/address, as it will be deleted immediately anyway)
Returns
true, if addition was successful
bool TSrvAddrMgr::addrIsFree ( SPtr< TIPv6Addr addr)
bool TSrvAddrMgr::addTAAddr ( SPtr< TDUID clntDuid,
SPtr< TIPv6Addr clntAddr,
int  iface,
unsigned long  iaid,
SPtr< TIPv6Addr addr,
unsigned long  pref,
unsigned long  valid 
)

adds TA address to AddrMgr

adds temporary address. Add missing client or TA, if necessary.

Parameters
clntDuid
clntAddr
iface
iaid
addr
pref
valid
Returns
void TSrvAddrMgr::cacheDump ( )
protected

dumps address cache into a file specified by SRVCACHE_FILE

void TSrvAddrMgr::cacheRead ( )
protected

dumps address cache into a file specified by SRVCACHE_FILE

void TSrvAddrMgr::checkCacheSize ( )
protected

this function checks if the cache size was not exceeded. If that is so, oldest entries are removed

bool TSrvAddrMgr::delCachedEntry ( SPtr< TIPv6Addr addr,
TIAType  type 
)

this function deletes cached address or prefix entry

Parameters
addr
typetype of entry looked for (TYPE_IA for address or TYPE_PD for prefix)
Returns
bool TSrvAddrMgr::delCachedEntry ( SPtr< TDUID clntDuid,
TIAType  type 
)

this function deletes cache entry

Parameters
clntDuid
typetype of entry looked for (TYPE_IA for address or TYPE_PD for prefix)
Returns
bool TSrvAddrMgr::delClntAddr ( SPtr< TDUID clntDuid,
unsigned long  IAID,
SPtr< TIPv6Addr clntAddr,
bool  quiet 
)

Frees address (also deletes IA and/or client, if this was last address)

Parameters
clntDuidDUID of the client
IAIDIA identifier
clntAddraddress to be removed from DB
quietprint out anything?
Returns
true if removal was successful
bool TSrvAddrMgr::delPrefix ( SPtr< TDUID clntDuid,
unsigned long  IAID,
SPtr< TIPv6Addr prefix,
bool  quiet 
)
virtual

Reimplemented from TAddrMgr.

bool TSrvAddrMgr::delTAAddr ( SPtr< TDUID clntDuid,
unsigned long  iaid,
SPtr< TIPv6Addr clntAddr,
bool  quiet 
)

Frees address (also deletes IA and/or client, if this was last address)

Parameters
clntDuidDUID of the client
iaidIAID of IA that contains address to be deleted
clntAddraddress to be deleted
quietshould method log deleted address?
Returns
true if removal was successful
void TSrvAddrMgr::doDuties ( std::vector< TExpiredInfo > &  addrLst,
std::vector< TExpiredInfo > &  tempAddrLst,
std::vector< TExpiredInfo > &  prefixLst 
)

remove outdated addresses

Parameters
addrLst
tempAddrLst
prefixLst
void TSrvAddrMgr::dump ( )
virtual

stores content of the AddrMgr database to a file

stores content of the AddrMgr database to XML file

Reimplemented from TAddrMgr.

void TSrvAddrMgr::getAddrsCount ( SPtr< TContainer< SPtr< TSrvCfgAddrClass > >>  classes,
long *  clntCnt,
long *  addrCnt,
SPtr< TDUID duid,
int  iface 
)
SPtr< TIPv6Addr > TSrvAddrMgr::getCachedEntry ( SPtr< TDUID clntDuid,
TIAType  type 
)

returns address or prefix cached for this client.

Parameters
clntDuid
typetype of entry looked for (TYPE_IA for address or TYPE_PD for prefix)
Returns
cached address or prefix. 0 if cached address is not found.
SPtr< TIPv6Addr > TSrvAddrMgr::getFirstAddr ( SPtr< TDUID clntDuid)
unsigned long TSrvAddrMgr::getLeaseCount ( SPtr< TDUID duid)

returns how many leases does this client have?

Parameters
duidclient's DUID
Returns
number of leases (addresses and/or prefixes)
TSrvAddrMgr & TSrvAddrMgr::instance ( )
static
void TSrvAddrMgr::instanceCreate ( const std::string &  xmlFile,
bool  loadDB 
)
static
void TSrvAddrMgr::print ( std::ostream &  out)
protectedvirtual

Implements TAddrMgr.

void TSrvAddrMgr::setCacheSize ( int  bytes)
bool TSrvAddrMgr::taAddrIsFree ( SPtr< TIPv6Addr addr)

Verifies if addr is unused

Parameters
addr
Returns
bool TSrvAddrMgr::verifyAddr ( SPtr< TIPv6Addr addr)
virtual

Checks if address is still supported in current configuration (used in loadDB)

Parameters
addrchecked address
Returns
true, if supported

Reimplemented from TAddrMgr.

bool TSrvAddrMgr::verifyPrefix ( SPtr< TIPv6Addr prefix)
virtual

Checks if prefix is still supported in current configuration (used in loadDB)

Parameters
prefixchecked prefix
Returns
true, if prefix is supported

Reimplemented from TAddrMgr.

Member Data Documentation

TContainer< SPtr<TSrvCacheEntry> > TSrvAddrMgr::Cache
protected
size_t TSrvAddrMgr::CacheMaxSize
protected
TSrvAddrMgr * TSrvAddrMgr::Instance = 0
staticprotected

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