Kea  1.9.9-git
isc::dhcp::Pool Class Reference

base class for Pool4 and Pool6 More...

#include <pool.h>

+ Inheritance diagram for isc::dhcp::Pool:

Public Member Functions

virtual ~Pool ()
 virtual destructor More...
 
void allowClientClass (const ClientClass &class_name)
 Sets the supported class to class class_name. More...
 
bool clientSupported (const ClientClasses &client_classes) const
 Checks whether this pool supports client that belongs to specified classes. More...
 
uint64_t getCapacity () const
 Returns the number of all leases in this pool. More...
 
CfgOptionPtr getCfgOption ()
 Returns pointer to the option data configuration for this pool. More...
 
ConstCfgOptionPtr getCfgOption () const
 Returns const pointer to the option data configuration for this pool. More...
 
const ClientClassgetClientClass () const
 returns the client class More...
 
const isc::asiolink::IOAddressgetFirstAddress () const
 Returns the first address in a pool. More...
 
uint32_t getId () const
 returns Pool-id More...
 
const isc::asiolink::IOAddressgetLastAddress () const
 Returns the last address in a pool. More...
 
isc::asiolink::IOAddress getLastAllocated () const
 returns the last address that was tried from this pool More...
 
IPRangePermutationPtr getPermutation () const
 Returns pointer to the permutation associated with the pool. More...
 
const ClientClassesgetRequiredClasses () const
 Returns classes which are required to be evaluated. More...
 
Lease::Type getType () const
 Returns pool type (v4, v6 non-temporary, v6 temp, v6 prefix) More...
 
bool inRange (const isc::asiolink::IOAddress &addr) const
 Checks if a given address is in the range. More...
 
bool isLastAllocatedValid () const
 checks if the last address is valid More...
 
void requireClientClass (const ClientClass &class_name)
 Adds class class_name to classes required to be evaluated. More...
 
void resetLastAllocated ()
 resets the last address to invalid More...
 
void setLastAllocated (const isc::asiolink::IOAddress &addr)
 sets the last address that was tried from this pool More...
 
virtual data::ElementPtr toElement () const
 Unparse a pool object. More...
 
virtual std::string toText () const
 returns textual representation of the pool More...
 
- Public Member Functions inherited from isc::data::UserContext
void contextToElement (data::ElementPtr map) const
 Merge unparse a user_context object. More...
 
data::ConstElementPtr getContext () const
 Returns const pointer to the user context. More...
 
void setContext (const data::ConstElementPtr &ctx)
 Sets user context. More...
 
- Public Member Functions inherited from isc::data::CfgToElement
virtual ~CfgToElement ()
 Destructor. More...
 

Protected Member Functions

 Pool (Lease::Type type, const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
 protected constructor More...
 

Static Protected Member Functions

static uint32_t getNextID ()
 returns the next unique Pool-ID More...
 

Protected Attributes

uint64_t capacity_
 Stores number of possible leases. More...
 
CfgOptionPtr cfg_option_
 Pointer to the option data configuration for this pool. More...
 
ClientClass client_class_
 Optional definition of a client class. More...
 
isc::asiolink::IOAddress first_
 The first address in a pool. More...
 
uint32_t id_
 pool-id More...
 
isc::asiolink::IOAddress last_
 The last address in a pool. More...
 
isc::asiolink::IOAddress last_allocated_
 Last allocated address See isc::dhcp::Subnet::last_allocated_ia_ Initialized and reset to first. More...
 
bool last_allocated_valid_
 Status of last allocated address. More...
 
IPRangePermutationPtr permutation_
 Pointer to the permutation object. More...
 
ClientClasses required_classes_
 Required classes. More...
 
Lease::Type type_
 defines a lease type that will be served from this pool More...
 
data::ConstElementPtr user_context_
 Pointer to the user context (may be NULL) More...
 
- Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr user_context_
 Pointer to the user context (may be NULL) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from isc::data::UserContext
static data::ElementPtr toElement (data::ConstElementPtr map)
 Copy an Element map. More...
 

Detailed Description

base class for Pool4 and Pool6

Stores information about pool of IPv4 or IPv6 addresses. That is a basic component of a configuration.

Definition at line 30 of file pool.h.

Constructor & Destructor Documentation

virtual isc::dhcp::Pool::~Pool ( )
inlinevirtual

virtual destructor

We need Pool to be a polymorphic class, so we could dynamic cast from PoolPtr to Pool6Ptr if we need to. A class becomes polymorphic, when there is at least one virtual method.

Definition at line 78 of file pool.h.

isc::dhcp::Pool::Pool ( Lease::Type  type,
const isc::asiolink::IOAddress first,
const isc::asiolink::IOAddress last 
)
protected

protected constructor

This constructor is protected to prevent anyone from instantiating Pool class directly. Instances of Pool4 and Pool6 should be created instead.

Parameters
typetype of lease that will be served from this pool
firstfirst address of a range
lastlast address of a range

Definition at line 21 of file pool.cc.

Member Function Documentation

void isc::dhcp::Pool::allowClientClass ( const ClientClass class_name)

Sets the supported class to class class_name.

Parameters
class_nameclient class to be supported by this pool

Definition at line 37 of file pool.cc.

References client_class_.

bool isc::dhcp::Pool::clientSupported ( const ClientClasses client_classes) const

Checks whether this pool supports client that belongs to specified classes.

Todo:
: currently doing the same as network which needs improving.
Parameters
client_classeslist of all classes the client belongs to
Returns
true if client can be supported, false otherwise

Definition at line 33 of file pool.cc.

References client_class_, and isc::dhcp::ClientClasses::contains().

+ Here is the call graph for this function:

uint64_t isc::dhcp::Pool::getCapacity ( ) const
inline

Returns the number of all leases in this pool.

Note that this is the upper bound, assuming that no leases are used and there are no host reservations. This is just a theoretical calculation.

Returns
number of possible leases in this pool

Definition at line 86 of file pool.h.

References capacity_.

CfgOptionPtr isc::dhcp::Pool::getCfgOption ( )
inline

Returns pointer to the option data configuration for this pool.

Definition at line 91 of file pool.h.

References cfg_option_.

Referenced by toElement().

ConstCfgOptionPtr isc::dhcp::Pool::getCfgOption ( ) const
inline

Returns const pointer to the option data configuration for this pool.

Definition at line 97 of file pool.h.

References cfg_option_.

const ClientClass& isc::dhcp::Pool::getClientClass ( ) const
inline

returns the client class

Note
The returned reference is only valid as long as the object returned is valid.
Returns
client class client_class_

Definition at line 121 of file pool.h.

References client_class_.

Referenced by toElement().

const isc::asiolink::IOAddress& isc::dhcp::Pool::getFirstAddress ( ) const
inline

Returns the first address in a pool.

Returns
first address in a pool

Definition at line 47 of file pool.h.

References first_.

Referenced by isc::dhcp::Pool4::toElement(), and isc::dhcp::Pool6::toElement().

uint32_t isc::dhcp::Pool::getId ( ) const
inline

returns Pool-id

Note
: PoolType enum was removed. Please use Lease::Type instead
Returns
pool-id value Pool-id is an unique value that can be used to identify a pool.

Definition at line 40 of file pool.h.

References id_.

const isc::asiolink::IOAddress& isc::dhcp::Pool::getLastAddress ( ) const
inline

Returns the last address in a pool.

Returns
last address in a pool

Definition at line 53 of file pool.h.

References last_.

Referenced by isc::dhcp::Pool4::toElement(), and isc::dhcp::Pool6::toElement().

isc::asiolink::IOAddress isc::dhcp::Pool::getLastAllocated ( ) const
inline

returns the last address that was tried from this pool

Returns
address/prefix that was last tried from this pool

Definition at line 142 of file pool.h.

References last_allocated_.

static uint32_t isc::dhcp::Pool::getNextID ( )
inlinestaticprotected

returns the next unique Pool-ID

Returns
the next unique Pool-ID

Definition at line 195 of file pool.h.

IPRangePermutationPtr isc::dhcp::Pool::getPermutation ( ) const
inline

Returns pointer to the permutation associated with the pool.

Returns
Pointer to the address range permutation.

Definition at line 173 of file pool.h.

References permutation_.

const ClientClasses& isc::dhcp::Pool::getRequiredClasses ( ) const
inline

Returns classes which are required to be evaluated.

Definition at line 135 of file pool.h.

References required_classes_.

Referenced by toElement().

Lease::Type isc::dhcp::Pool::getType ( ) const
inline

Returns pool type (v4, v6 non-temporary, v6 temp, v6 prefix)

Returns
returns pool type

Definition at line 64 of file pool.h.

References type_.

bool isc::dhcp::Pool::inRange ( const isc::asiolink::IOAddress addr) const

Checks if a given address is in the range.

Returns
true, if the address is in pool

Definition at line 29 of file pool.cc.

References first_, and last_.

bool isc::dhcp::Pool::isLastAllocatedValid ( ) const
inline

checks if the last address is valid

Returns
true if the last address is valid

Definition at line 148 of file pool.h.

References last_allocated_valid_.

void isc::dhcp::Pool::requireClientClass ( const ClientClass class_name)
inline

Adds class class_name to classes required to be evaluated.

Parameters
class_nameclient class required to be evaluated

Definition at line 128 of file pool.h.

References isc::dhcp::ClientClasses::contains(), isc::dhcp::ClientClasses::insert(), and required_classes_.

+ Here is the call graph for this function:

void isc::dhcp::Pool::resetLastAllocated ( )
inline

resets the last address to invalid

Definition at line 161 of file pool.h.

References last_allocated_valid_.

void isc::dhcp::Pool::setLastAllocated ( const isc::asiolink::IOAddress addr)
inline

sets the last address that was tried from this pool

Parameters
addraddress/prefix to that was tried last

Definition at line 155 of file pool.h.

References last_allocated_, and last_allocated_valid_.

data::ElementPtr isc::dhcp::Pool::toElement ( ) const
virtual

Unparse a pool object.

Returns
A pointer to unparsed pool configuration.

Implements isc::data::CfgToElement.

Reimplemented in isc::dhcp::Pool6, and isc::dhcp::Pool4.

Definition at line 102 of file pool.cc.

References isc::dhcp::ClientClasses::cbegin(), isc::dhcp::ClientClasses::cend(), isc::data::UserContext::contextToElement(), isc::dhcp::ClientClasses::empty(), getCfgOption(), getClientClass(), and getRequiredClasses().

Referenced by isc::dhcp::Pool4::toElement(), and isc::dhcp::Pool6::toElement().

+ Here is the call graph for this function:

std::string isc::dhcp::Pool::toText ( ) const
virtual

returns textual representation of the pool

Returns
textual representation

Reimplemented in isc::dhcp::Pool6.

Definition at line 42 of file pool.cc.

References first_, last_, type_, and isc::dhcp::Lease::typeToText().

+ Here is the call graph for this function:

Member Data Documentation

uint64_t isc::dhcp::Pool::capacity_
protected

Stores number of possible leases.

This could be calculated on the fly, but the calculations are somewhat involved, so it is more efficient to calculate it once and just store the result. Note that for very large pools, the number is capped at max value of uint64_t.

Definition at line 220 of file pool.h.

Referenced by getCapacity(), isc::dhcp::Pool4::Pool4(), and isc::dhcp::Pool6::Pool6().

CfgOptionPtr isc::dhcp::Pool::cfg_option_
protected

Pointer to the option data configuration for this pool.

Definition at line 223 of file pool.h.

Referenced by getCfgOption().

ClientClass isc::dhcp::Pool::client_class_
protected

Optional definition of a client class.

Network::client_class_

Definition at line 228 of file pool.h.

Referenced by allowClientClass(), clientSupported(), and getClientClass().

isc::asiolink::IOAddress isc::dhcp::Pool::first_
protected

The first address in a pool.

Definition at line 206 of file pool.h.

Referenced by getFirstAddress(), inRange(), toText(), and isc::dhcp::Pool6::toText().

uint32_t isc::dhcp::Pool::id_
protected

pool-id

This ID is used to identify this specific pool.

Definition at line 203 of file pool.h.

Referenced by getId().

isc::asiolink::IOAddress isc::dhcp::Pool::last_
protected

The last address in a pool.

Definition at line 209 of file pool.h.

Referenced by getLastAddress(), inRange(), isc::dhcp::Pool4::Pool4(), toText(), and isc::dhcp::Pool6::toText().

isc::asiolink::IOAddress isc::dhcp::Pool::last_allocated_
protected

Last allocated address See isc::dhcp::Subnet::last_allocated_ia_ Initialized and reset to first.

Definition at line 241 of file pool.h.

Referenced by getLastAllocated(), and setLastAllocated().

bool isc::dhcp::Pool::last_allocated_valid_
protected

Status of last allocated address.

Definition at line 244 of file pool.h.

Referenced by isLastAllocatedValid(), resetLastAllocated(), and setLastAllocated().

IPRangePermutationPtr isc::dhcp::Pool::permutation_
protected

Pointer to the permutation object.

It may be initialized for some pools to provide address or delegated prefix randomization capabilities.

Definition at line 250 of file pool.h.

Referenced by getPermutation().

ClientClasses isc::dhcp::Pool::required_classes_
protected

Required classes.

isc::dhcp::Network::required_classes_

Definition at line 233 of file pool.h.

Referenced by getRequiredClasses(), and requireClientClass().

Lease::Type isc::dhcp::Pool::type_
protected

defines a lease type that will be served from this pool

Definition at line 212 of file pool.h.

Referenced by getType(), isc::dhcp::Pool6::getType(), toText(), and isc::dhcp::Pool6::toText().

data::ConstElementPtr isc::dhcp::Pool::user_context_
protected

Pointer to the user context (may be NULL)

Definition at line 236 of file pool.h.


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