Kea 2.7.6
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 ()=default
 virtual destructor
 
void addAdditionalClass (const ClientClass &class_name)
 Adds class class_name to the additional classes list.
 
void allowClientClass (const isc::dhcp::ClientClass &class_name)
 Adds class clas_name to the allowed client classes list.
 
bool clientSupported (const ClientClasses &client_classes) const
 Checks whether this pool supports client that belongs to specified classes.
 
const ClientClassesgetAdditionalClasses () const
 Returns the additional classes list.
 
AllocationStatePtr getAllocationState () const
 Returns pool-specific allocation state.
 
isc::util::uint128_t getCapacity () const
 Returns the number of all leases in this pool.
 
CfgOptionPtr getCfgOption ()
 Returns pointer to the option data configuration for this pool.
 
ConstCfgOptionPtr getCfgOption () const
 Returns const pointer to the option data configuration for this pool.
 
const ClientClassesgetClientClasses () const
 Returns the list of allowed client classes.
 
const isc::asiolink::IOAddressgetFirstAddress () const
 Returns the first address in a pool.
 
uint64_t getID () const
 Returns Pool-id.
 
const isc::asiolink::IOAddressgetLastAddress () const
 Returns the last address in a pool.
 
ClientClassesgetMutableAdditionalClasses ()
 Returns the mutable additional classes list.
 
ClientClassesgetMutableClientClasses ()
 Returns the mutable list of allowed client classes.
 
Lease::Type getType () const
 Returns pool type (v4, v6 non-temporary, v6 temp, v6 prefix)
 
bool inRange (const isc::asiolink::IOAddress &addr) const
 Checks if a given address is in the range.
 
void setAllocationState (const AllocationStatePtr &allocation_state)
 Sets pool-specific allocation state.
 
void setID (const uint64_t id)
 Sets Pool-id.
 
virtual data::ElementPtr toElement () const
 Unparse a pool object.
 
virtual std::string toText () const
 returns textual representation of the pool
 
- Public Member Functions inherited from isc::data::UserContext
void contextToElement (data::ElementPtr map) const
 Merge unparse a user_context object.
 
data::ConstElementPtr getContext () const
 Returns const pointer to the user context.
 
void setContext (const data::ConstElementPtr &ctx)
 Sets user context.
 
- Public Member Functions inherited from isc::data::CfgToElement
virtual ~CfgToElement ()
 Destructor.
 

Protected Member Functions

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

Protected Attributes

ClientClasses additional_classes_
 Additional classes.
 
AllocationStatePtr allocation_state_
 Holds pool-specific allocation state.
 
isc::util::uint128_t capacity_
 Stores number of possible leases.
 
CfgOptionPtr cfg_option_
 Pointer to the option data configuration for this pool.
 
ClientClasses client_classes_
 List of client classes allowed to use this pool.
 
isc::asiolink::IOAddress first_
 The first address in a pool.
 
uint64_t id_
 pool-id
 
isc::asiolink::IOAddress last_
 The last address in a pool.
 
Lease::Type type_
 defines a lease type that will be served from this pool
 
data::ConstElementPtr user_context_
 Pointer to the user context (may be NULL)
 
- Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr user_context_
 Pointer to the user context (may be NULL)
 

Additional Inherited Members

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

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 32 of file pool.h.

Constructor & Destructor Documentation

◆ ~Pool()

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

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.

◆ Pool()

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

◆ addAdditionalClass()

void isc::dhcp::Pool::addAdditionalClass ( const ClientClass & class_name)

Adds class class_name to the additional classes list.

Parameters
class_nameclient class to add

Definition at line 45 of file pool.cc.

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

Referenced by isc::dhcp::PdPoolParser::parse(), and isc::dhcp::PoolParser::parse().

+ Here is the call graph for this function:

◆ allowClientClass()

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

Adds class clas_name to the allowed client classes list.

Parameters
class_nameclient class to be supported by this network

Definition at line 38 of file pool.cc.

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

Referenced by isc::dhcp::PdPoolParser::parse(), and isc::dhcp::PoolParser::parse().

+ Here is the call graph for this function:

◆ clientSupported()

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

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

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_classes_, isc::dhcp::ClientClasses::empty(), and isc::dhcp::ClientClasses::intersects().

+ Here is the call graph for this function:

◆ getAdditionalClasses()

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

Returns the additional classes list.

Definition at line 142 of file pool.h.

References additional_classes_.

◆ getAllocationState()

AllocationStatePtr isc::dhcp::Pool::getAllocationState ( ) const
inline

Returns pool-specific allocation state.

The actual type of the state depends on the allocator type.

Returns
allocation state.

Definition at line 156 of file pool.h.

References allocation_state_.

◆ getCapacity()

isc::util::uint128_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 99 of file pool.h.

References capacity_.

◆ getCfgOption() [1/2]

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

Returns pointer to the option data configuration for this pool.

Definition at line 104 of file pool.h.

References cfg_option_.

Referenced by toElement().

◆ getCfgOption() [2/2]

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

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

Definition at line 110 of file pool.h.

References cfg_option_.

◆ getClientClasses()

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

Returns the list of allowed client classes.

Definition at line 127 of file pool.h.

References client_classes_.

◆ getFirstAddress()

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 61 of file pool.h.

References first_.

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

◆ getID()

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

Returns Pool-id.

Note
: PoolType enum was removed. Please use Lease::Type instead

Pool-id is an unique value that can be used to identify a pool within a subnet or shared network.

Returns
pool-id value

Definition at line 44 of file pool.h.

References id_.

◆ getLastAddress()

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 67 of file pool.h.

References last_.

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

◆ getMutableAdditionalClasses()

ClientClasses & isc::dhcp::Pool::getMutableAdditionalClasses ( )
inline

Returns the mutable additional classes list.

Definition at line 147 of file pool.h.

References additional_classes_.

◆ getMutableClientClasses()

ClientClasses & isc::dhcp::Pool::getMutableClientClasses ( )
inline

Returns the mutable list of allowed client classes.

Definition at line 132 of file pool.h.

References client_classes_.

◆ getType()

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 78 of file pool.h.

References type_.

◆ inRange()

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 28 of file pool.cc.

References first_, and last_.

◆ setAllocationState()

void isc::dhcp::Pool::setAllocationState ( const AllocationStatePtr & allocation_state)
inline

Sets pool-specific allocation state.

Parameters
allocation_stateallocation state instance.

Definition at line 163 of file pool.h.

References allocation_state_.

◆ setID()

void isc::dhcp::Pool::setID ( const uint64_t id)
inline

Sets Pool-id.

Pool-id is an unique value that can be used to identify a pool within a subnet or shared network.

Parameters
idvalue to be set

Definition at line 54 of file pool.h.

References id_.

◆ toElement()

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::Pool4, and isc::dhcp::Pool6.

Definition at line 119 of file pool.cc.

References additional_classes_, client_classes_, isc::data::UserContext::contextToElement(), isc::data::Element::create(), isc::data::Element::createMap(), isc::dhcp::ClientClasses::empty(), getCfgOption(), id_, and isc::dhcp::ClientClasses::toElement().

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

+ Here is the call graph for this function:

◆ toText()

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 52 of file pool.cc.

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

+ Here is the call graph for this function:

Member Data Documentation

◆ additional_classes_

ClientClasses isc::dhcp::Pool::additional_classes_
protected

◆ allocation_state_

AllocationStatePtr isc::dhcp::Pool::allocation_state_
protected

Holds pool-specific allocation state.

Definition at line 230 of file pool.h.

Referenced by getAllocationState(), and setAllocationState().

◆ capacity_

isc::util::uint128_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 208 of file pool.h.

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

◆ cfg_option_

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

Pointer to the option data configuration for this pool.

Definition at line 211 of file pool.h.

Referenced by getCfgOption(), and getCfgOption().

◆ client_classes_

ClientClasses isc::dhcp::Pool::client_classes_
protected

List of client classes allowed to use this pool.

If not empty, only clients belonging to at least one of the classes in this list will be allowed to use this particular pool. By default the list is empty which means that any client is allowed, regardless of its class membership.

Definition at line 219 of file pool.h.

Referenced by allowClientClass(), clientSupported(), getClientClasses(), getMutableClientClasses(), and toElement().

◆ first_

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

The first address in a pool.

Definition at line 194 of file pool.h.

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

◆ id_

uint64_t isc::dhcp::Pool::id_
protected

pool-id

This id is an unique value that can be used to identify a pool within a subnet or shared network.

Definition at line 191 of file pool.h.

Referenced by getID(), setID(), and toElement().

◆ last_

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

The last address in a pool.

Definition at line 197 of file pool.h.

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

◆ type_

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

defines a lease type that will be served from this pool

Definition at line 200 of file pool.h.

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

◆ user_context_

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

Pointer to the user context (may be NULL)

Definition at line 227 of file pool.h.


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