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

Address Manager that holds address and prefix information. More...

#include <AddrMgr.h>

+ Inheritance diagram for TAddrMgr:
+ Collaboration diagram for TAddrMgr:

Public Types

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

Public Member Functions

 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)
virtual bool delPrefix (SPtr< TDUID > clntDuid, unsigned long IAID, SPtr< TIPv6Addr > prefix, bool quiet)
virtual void dump ()
 stores content of the AddrMgr database to a file
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)
virtual bool verifyAddr (SPtr< TIPv6Addr > addr)
virtual bool verifyPrefix (SPtr< TIPv6Addr > addr)
bool xmlLoadBuiltIn (const char *xmlFile)
 loads AddrMgr database from a file

Protected Member Functions

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)
virtual void print (std::ostream &out)=0
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< 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

Friends

std::ostream & operator<< (std::ostream &strum, TAddrMgr &x)

Detailed Description

Address Manager that holds address and prefix information.

This class holds information about assigned leases: addresses and prefixes with additional associated information: list of clients, listf of IAs, list of addresses, peer addresses, associated FQDN names, DNS addresses that performed DNS Update, t1,t2,prefered,valid lifetimes and similar data.

TAddrMgr is used by both server and client.

TAddrMgr has a container for TAddrClient - a list of clients. Each TAddrClient contains list of Identity Associations (IAs), represented by TAddrIA. Each TAddrIA contains list of addresses (TAddrAddr) or prefixes (TAddrPrefix).

Member Typedef Documentation

typedef std::map<int, std::string> TAddrMgr::IndexToNameMapping

holds network interface ifindex to name mapping

typedef std::map<std::string, int> TAddrMgr::NameToIndexMapping

holds network interface name to ifindex mapping

Constructor & Destructor Documentation

TAddrMgr::TAddrMgr ( const std::string &  addrdb,
bool  loadfile = false 
)
TAddrMgr::~TAddrMgr ( )
virtual

Member Function Documentation

void TAddrMgr::addClient ( SPtr< TAddrClient x)
bool TAddrMgr::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 
)
virtual

adds prefix for a client. If client's IA is missing, add it, too.

Parameters
clntDuidclient DUID
clntAddrclient address
ifaceinterface index used for client communication
IAIDIA identifier
T1T1 timer value
T2T2 timer value
prefixprefix to be added
prefpreferred lifetime
validvalid lifetime
lengthprefix length
quietshould it be added quietly? (i.e. no messages printed)
Returns
true if adding was successful

Reimplemented in TClntAddrMgr.

bool TAddrMgr::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 
)
protected
Todo:
: This setState() was used on reconfigure branch, but not on master
int TAddrMgr::countClient ( )
void TAddrMgr::dbLoad ( const char *  xmlFile)

loads XML database from disk

this method loads database from disk. (see dump() method for storing the database on disk). Right now it is used by client only, but it can be adapted easily for server side. After DB is loaded, necessary TAddrClient, TAddrIA and TAddrAddr lists are created.

There used to be 2 versions of this function:

  1. libxml2 based. Libxml2 is an external library that provides xml parsing capabilities. It is reliable, but adds big dependency to dibbler, therefore it is not currently used. It is no longer available (because there was nobody to maintain it).
  2. internal parser. See xmlLuadBuiltIn() method. It is very small, works with files generated by dibbler, but due to its size it is quite dumb and may be confused quite easily. This is the only version that is available.
Parameters
xmlFilefilename of the database
bool TAddrMgr::delClient ( SPtr< TDUID duid)
bool TAddrMgr::delPrefix ( SPtr< TDUID clntDuid,
unsigned long  IAID,
SPtr< TIPv6Addr prefix,
bool  quiet 
)
virtual
Todo:
: Cache for prefixes this->addCachedAddr(clntDuid, clntAddr);

Reimplemented in TSrvAddrMgr.

void TAddrMgr::dump ( )
virtual

stores content of the AddrMgr database to a file

stores content of the AddrMgr database to XML file

Reimplemented in TSrvAddrMgr.

void TAddrMgr::firstClient ( )
SPtr< TAddrClient > TAddrMgr::getClient ( )
SPtr< TAddrClient > TAddrMgr::getClient ( SPtr< TDUID duid)

returns client with a specified DUID

returns client with a specified DUID

Parameters
duidclient DUID
Returns
smart pointer to the client (or 0 if client is not found)
SPtr< TAddrClient > TAddrMgr::getClient ( uint32_t  SPI)

returns client with specified SPI index

returns client with specified SPI (Security Prameters Index). Useful for security purposes only

Parameters
SPIsecurity
Returns
smart pointer to the client (or 0 if client is not found)
SPtr< TAddrClient > TAddrMgr::getClient ( SPtr< TIPv6Addr leasedAddr)

returns client that leased specified address

returns client that leased specified address

Parameters
leasedAddraddress leased to the client
Returns
smart pointer to the client (or 0 if client is not found)
uint64_t TAddrMgr::getNextReplayDetectionValue ( )
unsigned long TAddrMgr::getPrefTimeout ( )

Reimplemented in TClntAddrMgr.

unsigned long TAddrMgr::getT1Timeout ( )

Reimplemented in TClntAddrMgr.

unsigned long TAddrMgr::getT2Timeout ( )

Reimplemented in TClntAddrMgr.

unsigned long TAddrMgr::getValidTimeout ( )

Reimplemented in TClntAddrMgr.

bool TAddrMgr::isDone ( )

returns if shutdown is complete

returns is AddrMgr completed its operations and is ready to conclude shutdown.

Returns
true - I'm done. false - keep going
SPtr< TAddrAddr > TAddrMgr::parseAddrAddr ( const char *  xmlFile,
char *  buf,
bool  pd 
)

parses single address

parses single address that is defined in <AddrAddr> tag.

Parameters
xmlFilename of the file being currently read
bufnull terminated buffer that contains string to parse
pdspecified if AddrAddr is actually a prefix
Returns
pointer to the newly created TAddrAddr object
SPtr< TAddrClient > TAddrMgr::parseAddrClient ( const char *  xmlFile,
FILE *  f 
)

parses XML section that defines single client

parses XML section that defines single client. That is <AddrClient>...</AddrClient> section.

Parameters
xmlFilename of the file being currently read
ffile handle
Returns
pointer to a newly created TAddrClient object
SPtr< TAddrIA > TAddrMgr::parseAddrIA ( 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

(section between <AddrIA>...</AddrIA>)

Parameters
xmlFilename of the file being currently read
ffile handle
t1parsed T1 timer value
t2parsed T2 timer value
iaidparsed IAID
ifaceparsed interface index (ifindex)
Returns
pointer to newly created TAddrIA object
Todo:
parse DUID
SPtr< TAddrIA > TAddrMgr::parseAddrPD ( 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

(section between <AddrPD>...</AddrPD>)

Parameters
xmlFilename of the file being currently read
ffile handle
t1T1 value
t2T2 value
iaidIAID
ifaceinterface index
Returns
pointer to newly created TAddrIA object
SPtr< TAddrPrefix > TAddrMgr::parseAddrPrefix ( const char *  xmlFile,
char *  buf,
bool  pd 
)
SPtr< TAddrIA > TAddrMgr::parseAddrTA ( const char *  xmlFile,
FILE *  f 
)

parses TA definition just a dummy function for now. Temporary addresses are ignored completely

Parameters
xmlFilename of the file being currently read
ffile handle
Returns
will return parsed temporary IA someday. Returns 0 now
bool TAddrMgr::prefixIsFree ( SPtr< TIPv6Addr x)

checks if a specific prefix is used

Parameters
x
Returns
true if prefix is free, false if it is used
virtual void TAddrMgr::print ( std::ostream &  out)
protectedpure virtual

Implemented in TSrvAddrMgr, and TClntAddrMgr.

bool TAddrMgr::updateInterfacesInfo ( const NameToIndexMapping nameToIndex,
const IndexToNameMapping indexToName 
)

tries to update interface name/index information (if required)

Parameters
nameToIndexnetwork interface name to index mapping
indexToNamenetwork interface index to name mapping
Returns
true if successful
bool TAddrMgr::updateInterfacesInfoIA ( SPtr< TAddrIA ia,
const NameToIndexMapping nameToIndex,
const IndexToNameMapping indexToName 
)
bool TAddrMgr::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 
)
virtual

Reimplemented in TClntAddrMgr.

bool TAddrMgr::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
virtual bool TAddrMgr::verifyAddr ( SPtr< TIPv6Addr addr)
inlinevirtual

Reimplemented in TSrvAddrMgr.

virtual bool TAddrMgr::verifyPrefix ( SPtr< TIPv6Addr addr)
inlinevirtual

Reimplemented in TSrvAddrMgr.

bool TAddrMgr::xmlLoadBuiltIn ( const char *  xmlFile)

loads AddrMgr database from a file

loads AddrMgr database from a file. Opens specified XML file and parsed outer <AddrMgr></AddrMgr> tags.

Parameters
xmlFilefilename that contains database
Returns
database load status: true=success, false if there were problems

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  strum,
TAddrMgr x 
)
friend

Member Data Documentation

TContainer< SPtr<TAddrClient> > TAddrMgr::ClntsLst
protected
bool TAddrMgr::DeleteEmptyClient
protected

should the client without any IA, TA or PDs be deleted? (srv = yes, client = no)

bool TAddrMgr::IsDone
protected
uint64_t TAddrMgr::ReplayDetectionValue_
protected
std::string TAddrMgr::XmlFile
protected

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