Kea  1.9.9-git
isc::dhcp::LeaseMgr Class Referenceabstract

Abstract Lease Manager. More...

#include <lease_mgr.h>

+ Inheritance diagram for isc::dhcp::LeaseMgr:

Public Member Functions

 LeaseMgr ()
 Constructor. More...
 
virtual ~LeaseMgr ()
 Destructor. More...
 
virtual bool addLease (const Lease4Ptr &lease)=0
 Adds an IPv4 lease. More...
 
virtual bool addLease (const Lease6Ptr &lease)=0
 Adds an IPv6 lease. More...
 
virtual void commit ()=0
 Commit Transactions. More...
 
virtual uint64_t deleteExpiredReclaimedLeases4 (const uint32_t secs)=0
 Deletes all expired and reclaimed DHCPv4 leases. More...
 
virtual uint64_t deleteExpiredReclaimedLeases6 (const uint32_t secs)=0
 Deletes all expired and reclaimed DHCPv6 leases. More...
 
virtual bool deleteLease (const Lease4Ptr &lease)=0
 Deletes an IPv4 lease. More...
 
virtual bool deleteLease (const Lease6Ptr &lease)=0
 Deletes an IPv6 lease. More...
 
virtual std::string getDescription () const =0
 Returns description of the backend. More...
 
virtual void getExpiredLeases4 (Lease4Collection &expired_leases, const size_t max_leases) const =0
 Returns a collection of expired DHCPv4 leases. More...
 
virtual void getExpiredLeases6 (Lease6Collection &expired_leases, const size_t max_leases) const =0
 Returns a collection of expired DHCPv6 leases. More...
 
virtual Lease4Ptr getLease4 (const isc::asiolink::IOAddress &addr) const =0
 Returns an IPv4 lease for specified IPv4 address. More...
 
virtual Lease4Collection getLease4 (const isc::dhcp::HWAddr &hwaddr) const =0
 Returns existing IPv4 leases for specified hardware address. More...
 
virtual Lease4Ptr getLease4 (const isc::dhcp::HWAddr &hwaddr, SubnetID subnet_id) const =0
 Returns existing IPv4 leases for specified hardware address and a subnet. More...
 
virtual Lease4Collection getLease4 (const ClientId &clientid) const =0
 Returns existing IPv4 lease for specified client-id. More...
 
virtual Lease4Ptr getLease4 (const ClientId &clientid, SubnetID subnet_id) const =0
 Returns existing IPv4 lease for specified client-id. More...
 
virtual Lease6Ptr getLease6 (Lease::Type type, const isc::asiolink::IOAddress &addr) const =0
 Returns existing IPv6 lease for a given IPv6 address. More...
 
Lease6Ptr getLease6 (Lease::Type type, const DUID &duid, uint32_t iaid, SubnetID subnet_id) const
 returns zero or one IPv6 lease for a given duid+iaid+subnet_id More...
 
virtual Lease4Collection getLeases4 (SubnetID subnet_id) const =0
 Returns all IPv4 leases for the particular subnet identifier. More...
 
virtual Lease4Collection getLeases4 (const std::string &hostname) const =0
 Returns all IPv4 leases for the particular hostname. More...
 
virtual Lease4Collection getLeases4 () const =0
 Returns all IPv4 leases. More...
 
virtual Lease4Collection getLeases4 (const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const =0
 Returns range of IPv4 leases using paging. More...
 
virtual Lease6Collection getLeases6 (Lease::Type type, const DUID &duid, uint32_t iaid) const =0
 Returns existing IPv6 leases for a given DUID+IA combination. More...
 
virtual Lease6Collection getLeases6 (Lease::Type type, const DUID &duid, uint32_t iaid, SubnetID subnet_id) const =0
 Returns existing IPv6 lease for a given DUID+IA combination. More...
 
virtual Lease6Collection getLeases6 (SubnetID subnet_id) const =0
 Returns all IPv6 leases for the particular subnet identifier. More...
 
virtual Lease6Collection getLeases6 (const std::string &hostname) const =0
 Returns all IPv6 leases for the particular hostname. More...
 
virtual Lease6Collection getLeases6 () const =0
 Returns all IPv6 leases. More...
 
virtual Lease6Collection getLeases6 (const DUID &duid) const =0
 Returns collection of leases for matching DUID. More...
 
virtual Lease6Collection getLeases6 (const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const =0
 Returns range of IPv6 leases using paging. More...
 
virtual std::string getName () const =0
 Returns backend name. More...
 
virtual std::string getType () const =0
 Return backend type. More...
 
virtual VersionPair getVersion () const =0
 Returns backend version. More...
 
void recountLeaseStats4 ()
 Recalculates per-subnet and global stats for IPv4 leases. More...
 
void recountLeaseStats6 ()
 Recalculates per-subnet and global stats for IPv6 leases. More...
 
virtual void rollback ()=0
 Rollback Transactions. More...
 
virtual LeaseStatsQueryPtr startLeaseStatsQuery4 ()
 Creates and runs the IPv4 lease stats query for all subnets. More...
 
virtual LeaseStatsQueryPtr startLeaseStatsQuery6 ()
 Creates and runs the IPv6 lease stats query for all subnets. More...
 
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4 (const SubnetID &subnet_id)
 Creates and runs the IPv4 lease stats query for a single subnet. More...
 
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6 (const SubnetID &subnet_id)
 Creates and runs the IPv6 lease stats query for a single subnet. More...
 
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4 (const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
 Creates and runs the IPv4 lease stats query for a single subnet. More...
 
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6 (const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
 Creates and runs the IPv6 lease stats query for a single subnet. More...
 
virtual void updateLease4 (const Lease4Ptr &lease4)=0
 Updates IPv4 lease. More...
 
virtual void updateLease6 (const Lease6Ptr &lease6)=0
 Updates IPv6 lease. More...
 
virtual size_t wipeLeases4 (const SubnetID &subnet_id)=0
 Virtual method which removes specified leases. More...
 
virtual size_t wipeLeases6 (const SubnetID &subnet_id)=0
 Virtual method which removes specified leases. More...
 

Static Public Member Functions

static std::string getDBVersion ()
 Class method to return extended version info This class method must be redeclared and redefined in derived classes. More...
 
static isc::asiolink::IOServicePtrgetIOService ()
 Returns pointer to the IO service. More...
 
static void setIOService (const isc::asiolink::IOServicePtr &io_service)
 Sets IO service to be used by the Lease Manager. More...
 

Detailed Description

Abstract Lease Manager.

This is an abstract API for lease database backends. It provides unified interface to all backends. As this is an abstract class, it should not be used directly, but rather specialized derived class should be used instead.

This class throws no exceptions. However, methods in concrete implementations of this class may throw exceptions: see the documentation of those classes for details.

Definition at line 222 of file lease_mgr.h.

Constructor & Destructor Documentation

isc::dhcp::LeaseMgr::LeaseMgr ( )
inline

Constructor.

Definition at line 226 of file lease_mgr.h.

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

Destructor.

Definition at line 230 of file lease_mgr.h.

Member Function Documentation

virtual bool isc::dhcp::LeaseMgr::addLease ( const Lease4Ptr lease)
pure virtual

Adds an IPv4 lease.

The lease may be modified due to sanity checks setting (see LeaseSanityChecks in CfgConsistency) before being inserted. For performance reasons, the sanity checks do not make a copy, but rather modify lease in place if needed.

Parameters
leaselease to be added
Returns
true if the lease was added, false if not (because a lease with the same address was already there or failed sanity checks)

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

Referenced by isc::dhcp::bench::GenericLeaseMgrBenchmark::benchInsertLeases4(), isc::dhcp::bench::GenericLeaseMgrBenchmark::benchInsertLeases6(), and isc::lease_cmds::LeaseCmdsImpl::leaseAddHandler().

virtual bool isc::dhcp::LeaseMgr::addLease ( const Lease6Ptr lease)
pure virtual

Adds an IPv6 lease.

The lease may be modified due to sanity checks setting (see LeaseSanityChecks in CfgConsistency) before being inserted. For performance reasons, the sanity checks do not make a copy, but rather modify lease in place if needed.

Parameters
leaselease to be added
Returns
true if the lease was added, false if not (because a lease with the same address was already there or failed sanity checks)

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual void isc::dhcp::LeaseMgr::commit ( )
pure virtual

Commit Transactions.

Commits all pending database operations. On databases that don't support transactions, this is a no-op.

Implemented in isc::dhcp::Memfile_LeaseMgr, isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual uint64_t isc::dhcp::LeaseMgr::deleteExpiredReclaimedLeases4 ( const uint32_t  secs)
pure virtual

Deletes all expired and reclaimed DHCPv4 leases.

Parameters
secsNumber of seconds since expiration of leases before they can be removed. Leases which have expired later than this time will not be deleted.
Returns
Number of leases deleted.

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::CqlLeaseMgr, and isc::dhcp::Memfile_LeaseMgr.

Referenced by isc::dhcp::AllocEngine::deleteExpiredReclaimedLeases4().

virtual uint64_t isc::dhcp::LeaseMgr::deleteExpiredReclaimedLeases6 ( const uint32_t  secs)
pure virtual

Deletes all expired and reclaimed DHCPv6 leases.

Parameters
secsNumber of seconds since expiration of leases before they can be removed. Leases which have expired later than this time will not be deleted.
Returns
Number of leases deleted.

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::CqlLeaseMgr, and isc::dhcp::Memfile_LeaseMgr.

Referenced by isc::dhcp::AllocEngine::deleteExpiredReclaimedLeases6().

virtual bool isc::dhcp::LeaseMgr::deleteLease ( const Lease4Ptr lease)
pure virtual

Deletes an IPv4 lease.

Parameters
leaseIPv4 lease to be deleted.
Returns
true if deletion was successful, false if no such lease exists.
Exceptions
isc::dhcp::DbOperationErrorAn operation on the open database has failed.

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::CqlLeaseMgr, and isc::dhcp::Memfile_LeaseMgr.

Referenced by isc::lease_cmds::LeaseCmdsImpl::lease6BulkApplyHandler(), isc::dhcp::Dhcpv4Srv::processRelease(), isc::dhcp::Dhcpv6Srv::releaseIA_NA(), and isc::dhcp::Dhcpv6Srv::releaseIA_PD().

virtual bool isc::dhcp::LeaseMgr::deleteLease ( const Lease6Ptr lease)
pure virtual

Deletes an IPv6 lease.

Parameters
leaseIPv6 lease to be deleted.
Returns
true if deletion was successful, false if no such lease exists.
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::CqlLeaseMgr, and isc::dhcp::Memfile_LeaseMgr.

std::string isc::dhcp::LeaseMgr::getDBVersion ( )
static

Class method to return extended version info This class method must be redeclared and redefined in derived classes.

Definition at line 354 of file lease_mgr.cc.

References isc_throw.

virtual std::string isc::dhcp::LeaseMgr::getDescription ( ) const
pure virtual

Returns description of the backend.

This description may be multiline text that describes the backend.

Returns
Description of the backend.

Implemented in isc::dhcp::Memfile_LeaseMgr, isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual void isc::dhcp::LeaseMgr::getExpiredLeases4 ( Lease4Collection expired_leases,
const size_t  max_leases 
) const
pure virtual

Returns a collection of expired DHCPv4 leases.

This method returns at most max_leases expired leases. The leases returned haven't been reclaimed, i.e. the database query must exclude reclaimed leases from the results returned.

Parameters
[out]expired_leasesA container to which expired leases returned by the database backend are added.
max_leasesA maximum number of leases to be returned. If this value is set to 0, all expired (but not reclaimed) leases are returned.

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::CqlLeaseMgr, and isc::dhcp::Memfile_LeaseMgr.

Referenced by isc::dhcp::bench::GenericLeaseMgrBenchmark::benchGetExpiredLeases4(), and isc::dhcp::AllocEngine::reclaimExpiredLeases4().

virtual void isc::dhcp::LeaseMgr::getExpiredLeases6 ( Lease6Collection expired_leases,
const size_t  max_leases 
) const
pure virtual

Returns a collection of expired DHCPv6 leases.

This method returns at most max_leases expired leases. The leases returned haven't been reclaimed, i.e. the database query must exclude reclaimed leases from the results returned.

Parameters
[out]expired_leasesA container to which expired leases returned by the database backend are added.
max_leasesA maximum number of leases to be returned. If this value is set to 0, all expired (but not reclaimed) leases are returned.

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::CqlLeaseMgr, and isc::dhcp::Memfile_LeaseMgr.

Referenced by isc::dhcp::bench::GenericLeaseMgrBenchmark::benchGetExpiredLeases6(), and isc::dhcp::AllocEngine::reclaimExpiredLeases6().

static isc::asiolink::IOServicePtr& isc::dhcp::LeaseMgr::getIOService ( )
inlinestatic

Returns pointer to the IO service.

Definition at line 758 of file lease_mgr.h.

Referenced by isc::dhcp::PgSqlLeaseMgr::createContext(), isc::dhcp::MySqlLeaseMgr::createContext(), and isc::dhcp::LFCSetup::setup().

virtual Lease4Ptr isc::dhcp::LeaseMgr::getLease4 ( const isc::asiolink::IOAddress addr) const
pure virtual

Returns an IPv4 lease for specified IPv4 address.

This method return a lease that is associated with a given address. For other query types (by hardware addr, by client-id) there can be several leases in different subnets (e.g. for mobile clients that got address in different subnets). However, for a single address there can be only one lease, so this method returns a pointer to a single lease, not a container of leases.

Parameters
addraddress of the searched lease
Returns
smart pointer to the lease (or NULL if a lease is not found)

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

Referenced by isc::lease_cmds::LeaseCmdsImpl::addOrUpdate4(), isc::dhcp::Dhcpv4Srv::assignLease(), isc::dhcp::bench::GenericLeaseMgrBenchmark::benchGetLease4_address(), isc::dhcp::bench::GenericLeaseMgrBenchmark::benchGetLease4_clientid(), isc::dhcp::bench::GenericLeaseMgrBenchmark::benchGetLease4_clientid_subnetid(), isc::dhcp::bench::GenericLeaseMgrBenchmark::benchGetLease4_hwaddr(), isc::dhcp::bench::GenericLeaseMgrBenchmark::benchGetLease4_hwaddr_subnetid(), isc::lease_cmds::LeaseCmdsImpl::lease4DelHandler(), isc::lease_cmds::LeaseCmdsImpl::lease4ResendDdnsHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetByClientIdHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetByHwAddressHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetHandler(), isc::dhcp::Dhcpv4Srv::processDecline(), and isc::dhcp::Dhcpv4Srv::processRelease().

virtual Lease4Collection isc::dhcp::LeaseMgr::getLease4 ( const isc::dhcp::HWAddr hwaddr) const
pure virtual

Returns existing IPv4 leases for specified hardware address.

Although in the usual case there will be only one lease, for mobile clients or clients with multiple static/fixed/reserved leases there can be more than one. Thus return type is a container, not a single pointer.

Parameters
hwaddrhardware address of the client
Returns
lease collection

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual Lease4Ptr isc::dhcp::LeaseMgr::getLease4 ( const isc::dhcp::HWAddr hwaddr,
SubnetID  subnet_id 
) const
pure virtual

Returns existing IPv4 leases for specified hardware address and a subnet.

There can be at most one lease for a given HW address in a single pool, so this method will either return a single lease or NULL.

Parameters
hwaddrhardware address of the client
subnet_ididentifier of the subnet that lease must belong to
Returns
a pointer to the lease (or NULL if a lease is not found)

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual Lease4Collection isc::dhcp::LeaseMgr::getLease4 ( const ClientId clientid) const
pure virtual

Returns existing IPv4 lease for specified client-id.

Although in the usual case there will be only one lease, for mobile clients or clients with multiple static/fixed/reserved leases there can be more than one. Thus return type is a container, not a single pointer.

Parameters
clientidclient identifier
Returns
lease collection

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual Lease4Ptr isc::dhcp::LeaseMgr::getLease4 ( const ClientId clientid,
SubnetID  subnet_id 
) const
pure virtual

Returns existing IPv4 lease for specified client-id.

There can be at most one lease for a given client-id in a single pool, so this method will either return a single lease or NULL.

Parameters
clientidclient identifier
subnet_ididentifier of the subnet that lease must belong to
Returns
a pointer to the lease (or NULL if a lease is not found)

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual Lease6Ptr isc::dhcp::LeaseMgr::getLease6 ( Lease::Type  type,
const isc::asiolink::IOAddress addr 
) const
pure virtual

Returns existing IPv6 lease for a given IPv6 address.

For a given address, we assume that there will be only one lease. The assumption here is that there will not be site or link-local addresses used, so there is no way of having address duplication.

Parameters
typespecifies lease type: (NA, TA or PD)
addraddress of the searched lease
Returns
smart pointer to the lease (or NULL if a lease is not found)

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

Referenced by isc::lease_cmds::LeaseCmdsImpl::addOrUpdate6(), isc::dhcp::bench::GenericLeaseMgrBenchmark::benchGetLease6_type_address(), isc::dhcp::bench::GenericLeaseMgrBenchmark::benchGetLease6_type_duid_iaid_subnetid(), isc::dhcp::Dhcpv6Srv::declineIA(), isc::lease_cmds::LeaseCmdsImpl::getIPv6LeaseForDelete(), isc::lease_cmds::LeaseCmdsImpl::lease6DelHandler(), isc::lease_cmds::LeaseCmdsImpl::lease6ResendDdnsHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetHandler(), isc::dhcp::Dhcpv6Srv::releaseIA_NA(), and isc::dhcp::Dhcpv6Srv::releaseIA_PD().

Lease6Ptr isc::dhcp::LeaseMgr::getLease6 ( Lease::Type  type,
const DUID duid,
uint32_t  iaid,
SubnetID  subnet_id 
) const

returns zero or one IPv6 lease for a given duid+iaid+subnet_id

This function is mostly intended to be used in unit-tests during the transition from single to multi address per IA. It may also be used in other cases where at most one lease is expected in the database.

It is a wrapper around getLeases6(), which returns a collection of leases. That collection can be converted into a single pointer if there are no leases (NULL pointer) or one lease (use that single lease). If there are more leases in the collection, the function will throw MultipleRecords exception.

Note: This method is not virtual on purpose. It is common for all backends.

Parameters
typespecifies lease type: (NA, TA or PD)
duidclient DUID
iaidIA identifier
subnet_idsubnet id of the subnet the lease belongs to
Exceptions
MultipleRecordsif there is more than one lease matching
Returns
Lease pointer (or NULL if none is found)

Definition at line 50 of file lease_mgr.cc.

References getLeases6(), isc_throw, and isc::dhcp::DUID::toText().

+ Here is the call graph for this function:

virtual Lease4Collection isc::dhcp::LeaseMgr::getLeases4 ( SubnetID  subnet_id) const
pure virtual

Returns all IPv4 leases for the particular subnet identifier.

Parameters
subnet_idsubnet identifier.
Returns
Lease collection (may be empty if no IPv4 lease found).

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

Referenced by isc::lease_cmds::LeaseCmdsImpl::leaseGetAllHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetByHostnameHandler(), and isc::lease_cmds::LeaseCmdsImpl::leaseGetPageHandler().

virtual Lease4Collection isc::dhcp::LeaseMgr::getLeases4 ( const std::string &  hostname) const
pure virtual

Returns all IPv4 leases for the particular hostname.

Parameters
hostnamehostname in lower case.
Returns
Lease collection (may be empty if no IPv4 lease found).

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual Lease4Collection isc::dhcp::LeaseMgr::getLeases4 ( ) const
pure virtual

Returns all IPv4 leases.

Returns
Lease collection (may be empty if no IPv4 lease found).

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual Lease4Collection isc::dhcp::LeaseMgr::getLeases4 ( const asiolink::IOAddress lower_bound_address,
const LeasePageSize page_size 
) const
pure virtual

Returns range of IPv4 leases using paging.

This method implements paged browsing of the lease database. The first parameter specifies a page size. The second parameter is optional and specifies the starting address of the range. This address is excluded from the returned range. The IPv4 zero address (default) denotes that the first page should be returned. There is no guarantee about the order of returned leases.

The typical usage of this method is as follows:

  • Get the first page of leases by specifying IPv4 zero address as the beginning of the range.
  • Last address of the returned range should be used as a starting address for the next page in the subsequent call.
  • If the number of leases returned is lower than the page size, it indicates that the last page has been retrieved.
  • If there are no leases returned it indicates that the previous page was the last page.
Parameters
lower_bound_addressIPv4 address used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Lease collection (may be empty if no IPv4 lease found).

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual Lease6Collection isc::dhcp::LeaseMgr::getLeases6 ( Lease::Type  type,
const DUID duid,
uint32_t  iaid 
) const
pure virtual

Returns existing IPv6 leases for a given DUID+IA combination.

Although in the usual case there will be only one lease, for mobile clients or clients with multiple static/fixed/reserved leases there can be more than one. Thus return type is a container, not a single pointer.

Parameters
typespecifies lease type: (NA, TA or PD)
duidclient DUID
iaidIA identifier
Returns
Lease collection (may be empty if no lease is found)

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

Referenced by isc::dhcp::AllocEngine::allocateLeases6(), isc::dhcp::bench::GenericLeaseMgrBenchmark::benchGetLease6_type_duid_iaid(), isc::lease_cmds::LeaseCmdsImpl::leaseGetAllHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetByDuidHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetByHostnameHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetPageHandler(), and isc::dhcp::AllocEngine::renewLeases6().

virtual Lease6Collection isc::dhcp::LeaseMgr::getLeases6 ( Lease::Type  type,
const DUID duid,
uint32_t  iaid,
SubnetID  subnet_id 
) const
pure virtual

Returns existing IPv6 lease for a given DUID+IA combination.

There may be more than one address, temp. address or prefix for specified duid/iaid/subnet-id tuple.

Parameters
typespecifies lease type: (NA, TA or PD)
duidclient DUID
iaidIA identifier
subnet_idsubnet id of the subnet the lease belongs to
Returns
Lease collection (may be empty if no lease is found)

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual Lease6Collection isc::dhcp::LeaseMgr::getLeases6 ( SubnetID  subnet_id) const
pure virtual

Returns all IPv6 leases for the particular subnet identifier.

Parameters
subnet_idsubnet identifier.
Returns
Lease collection (may be empty if no IPv6 lease found).

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual Lease6Collection isc::dhcp::LeaseMgr::getLeases6 ( const std::string &  hostname) const
pure virtual

Returns all IPv6 leases for the particular hostname.

Parameters
hostnamehostname in lower case.
Returns
Lease collection (may be empty if no IPv6 lease found).

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual Lease6Collection isc::dhcp::LeaseMgr::getLeases6 ( ) const
pure virtual

Returns all IPv6 leases.

Returns
Lease collection (may be empty if no IPv6 lease found).

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

Referenced by getLease6().

virtual Lease6Collection isc::dhcp::LeaseMgr::getLeases6 ( const DUID duid) const
pure virtual

Returns collection of leases for matching DUID.

Returns
Lease collection (may be empty if no IPv6 lease found for the DUID).

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::Memfile_LeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual Lease6Collection isc::dhcp::LeaseMgr::getLeases6 ( const asiolink::IOAddress lower_bound_address,
const LeasePageSize page_size 
) const
pure virtual

Returns range of IPv6 leases using paging.

This method implements paged browsing of the lease database. The first parameter specifies a page size. The second parameter is optional and specifies the starting address of the range. This address is excluded from the returned range. The IPv6 zero address (default) denotes that the first page should be returned. There is no guarantee about the order of returned leases.

The typical usage of this method is as follows:

  • Get the first page of leases by specifying IPv6 zero address as the beginning of the range.
  • Last address of the returned range should be used as a starting address for the next page in the subsequent call.
  • If the number of leases returned is lower than the page size, it indicates that the last page has been retrieved.
  • If there are no leases returned it indicates that the previous page was the last page.
Parameters
lower_bound_addressIPv6 address used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
Lease collection (may be empty if no IPv6 lease found).

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::CqlLeaseMgr, and isc::dhcp::Memfile_LeaseMgr.

virtual std::string isc::dhcp::LeaseMgr::getName ( ) const
pure virtual

Returns backend name.

If the backend is a database, this is the name of the database or the file. Otherwise it is just the same as the type.

Returns
Name of the backend.

Implemented in isc::dhcp::Memfile_LeaseMgr, isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual std::string isc::dhcp::LeaseMgr::getType ( ) const
pure virtual

Return backend type.

Returns the type of the backend (e.g. "mysql", "memfile" etc.)

Returns
Type of the backend.

Implemented in isc::dhcp::Memfile_LeaseMgr, isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, and isc::dhcp::CqlLeaseMgr.

virtual VersionPair isc::dhcp::LeaseMgr::getVersion ( ) const
pure virtual

Returns backend version.

Returns
Version number as a pair of unsigned integers. "first" is the major version number, "second" the minor number.
Todo:
: We will need to implement 3 version functions eventually: A. abstract API version B. backend version C. database version (stored in the database scheme)

and then check that: B>=A and B=C (it is ok to have newer backend, as it should be backward compatible) Also if B>C, some database upgrade procedure may be triggered

Implemented in isc::dhcp::Memfile_LeaseMgr, isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, and isc::dhcp::CqlLeaseMgr.

void isc::dhcp::LeaseMgr::recountLeaseStats4 ( )

Recalculates per-subnet and global stats for IPv4 leases.

This method recalculates the following statistics: per-subnet:

  • assigned-addresses
  • declined-addresses global:
  • declined-addresses

It invokes the virtual method, startLeaseStatsQuery4(), which returns an instance of an LeaseStatsQuery. The query query contains a "result set" where each row is an LeaseStatRow that contains a subnet id, a lease type (currently always TYPE_NA), a lease state, and the number of leases of that type, in that state and is ordered by subnet id. The method iterates over the result set rows, setting the appropriate statistic per subnet and adding to the appropriate global statistic.

NULL means not backend does not support recounting.

Definition at line 67 of file lease_mgr.cc.

References isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseStatsRow::lease_state_, startLeaseStatsQuery4(), isc::dhcp::LeaseStatsRow::state_count_, isc::dhcp::Lease::STATE_DECLINED, isc::dhcp::Lease::STATE_DEFAULT, and isc::dhcp::LeaseStatsRow::subnet_id_.

+ Here is the call graph for this function:

void isc::dhcp::LeaseMgr::recountLeaseStats6 ( )

Recalculates per-subnet and global stats for IPv6 leases.

This method recalculates the following statistics: per-subnet:

  • assigned-nas
  • declined-addresses
  • assigned-pds global:
  • assigned-nas
  • declined-addresses
  • assigned-pds

It invokes the virtual method, startLeaseStatsQuery6(), which returns an instance of an LeaseStatsQuery. The query contains a "result set" where each row is an LeaseStatRow that contains a subnet id, a lease type, a lease state, and the number of leases of that type, in that state and is ordered by subnet id. The method iterates over the result set rows, setting the appropriate statistic per subnet and adding to the appropriate global statistic.

NULL means not backend does not support recounting.

Definition at line 215 of file lease_mgr.cc.

References isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseStatsRow::lease_state_, isc::dhcp::LeaseStatsRow::lease_type_, startLeaseStatsQuery6(), isc::dhcp::LeaseStatsRow::state_count_, isc::dhcp::Lease::STATE_DECLINED, isc::dhcp::Lease::STATE_DEFAULT, isc::dhcp::LeaseStatsRow::subnet_id_, isc::dhcp::Lease::TYPE_NA, and isc::dhcp::Lease::TYPE_PD.

+ Here is the call graph for this function:

virtual void isc::dhcp::LeaseMgr::rollback ( )
pure virtual

Rollback Transactions.

Rolls back all pending database operations. On databases that don't support transactions, this is a no-op.

Implemented in isc::dhcp::Memfile_LeaseMgr, isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, and isc::dhcp::CqlLeaseMgr.

static void isc::dhcp::LeaseMgr::setIOService ( const isc::asiolink::IOServicePtr io_service)
inlinestatic

Sets IO service to be used by the Lease Manager.

Parameters
io_serviceIOService object, used for all ASIO operations.

Definition at line 753 of file lease_mgr.h.

Referenced by isc::dhcp::ControlledDhcpv4Srv::ControlledDhcpv4Srv(), isc::dhcp::ControlledDhcpv6Srv::ControlledDhcpv6Srv(), isc::dhcp::ControlledDhcpv4Srv::~ControlledDhcpv4Srv(), and isc::dhcp::ControlledDhcpv6Srv::~ControlledDhcpv6Srv().

LeaseStatsQueryPtr isc::dhcp::LeaseMgr::startLeaseStatsQuery4 ( )
virtual

Creates and runs the IPv4 lease stats query for all subnets.

LeaseMgr derivations implement this method such that it creates and returns an instance of an LeaseStatsQuery whose result set has been populated with up to date IPv4 lease statistical data for all subnets. Each row of the result set is an LeaseStatRow which ordered ascending by subnet ID.

Returns
A populated LeaseStatsQuery

Reimplemented in isc::dhcp::Memfile_LeaseMgr, isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, and isc::dhcp::CqlLeaseMgr.

Definition at line 194 of file lease_mgr.cc.

Referenced by isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet4(), and recountLeaseStats4().

LeaseStatsQueryPtr isc::dhcp::LeaseMgr::startLeaseStatsQuery6 ( )
virtual

Creates and runs the IPv6 lease stats query for all subnets.

LeaseMgr derivations implement this method such that it creates and returns an instance of an LeaseStatsQuery whose result set has been populated with up to date IPv6 lease statistical data for all subnets. Each row of the result set is an LeaseStatRow which ordered ascending by subnet ID.

Returns
A populated LeaseStatsQuery

Reimplemented in isc::dhcp::Memfile_LeaseMgr, isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, and isc::dhcp::CqlLeaseMgr.

Definition at line 338 of file lease_mgr.cc.

Referenced by isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet6(), and recountLeaseStats6().

LeaseStatsQueryPtr isc::dhcp::LeaseMgr::startSubnetLeaseStatsQuery4 ( const SubnetID subnet_id)
virtual

Creates and runs the IPv4 lease stats query for a single subnet.

LeaseMgr derivations implement this method such that it creates and returns an instance of an LeaseStatsQuery whose result set has been populated with up to date IPv4 lease statistical data for a single subnet. Each row of the result set is an LeaseStatRow.

Parameters
subnet_idid of the subnet for which stats are desired
Returns
A populated LeaseStatsQuery

Reimplemented in isc::dhcp::Memfile_LeaseMgr, isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, and isc::dhcp::CqlLeaseMgr.

Definition at line 199 of file lease_mgr.cc.

Referenced by isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet4().

LeaseStatsQueryPtr isc::dhcp::LeaseMgr::startSubnetLeaseStatsQuery6 ( const SubnetID subnet_id)
virtual

Creates and runs the IPv6 lease stats query for a single subnet.

LeaseMgr derivations implement this method such that it creates and returns an instance of an LeaseStatsQuery whose result set has been populated with up to date IPv6 lease statistical data for a single subnet. Each row of the result set is an LeaseStatRow.

Parameters
subnet_idid of the subnet for which stats are desired
Returns
A populated LeaseStatsQuery

Reimplemented in isc::dhcp::Memfile_LeaseMgr, isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, and isc::dhcp::CqlLeaseMgr.

Definition at line 343 of file lease_mgr.cc.

Referenced by isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet6().

LeaseStatsQueryPtr isc::dhcp::LeaseMgr::startSubnetRangeLeaseStatsQuery4 ( const SubnetID first_subnet_id,
const SubnetID last_subnet_id 
)
virtual

Creates and runs the IPv4 lease stats query for a single subnet.

LeaseMgr derivations implement this method such that it creates and returns an instance of an LeaseStatsQuery whose result set has been populated with up to date IPv4 lease statistical data for an inclusive range of subnets. Each row of the result set is an LeaseStatRow which ordered ascending by subnet ID.

Parameters
first_subnet_idfirst subnet in the range of subnets
last_subnet_idlast subnet in the range of subnets
Returns
A populated LeaseStatsQuery

Reimplemented in isc::dhcp::Memfile_LeaseMgr, isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, and isc::dhcp::CqlLeaseMgr.

Definition at line 204 of file lease_mgr.cc.

Referenced by isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet4().

LeaseStatsQueryPtr isc::dhcp::LeaseMgr::startSubnetRangeLeaseStatsQuery6 ( const SubnetID first_subnet_id,
const SubnetID last_subnet_id 
)
virtual

Creates and runs the IPv6 lease stats query for a single subnet.

LeaseMgr derivations implement this method such that it creates and returns an instance of an LeaseStatsQuery whose result set has been populated with up to date IPv6 lease statistical data for an inclusive range of subnets. Each row of the result set is an LeaseStatRow which ordered ascending by subnet ID.

Parameters
first_subnet_idfirst subnet in the range of subnets
last_subnet_idlast subnet in the range of subnets
Returns
A populated LeaseStatsQuery

Reimplemented in isc::dhcp::Memfile_LeaseMgr, isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, and isc::dhcp::CqlLeaseMgr.

Definition at line 348 of file lease_mgr.cc.

Referenced by isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet6().

virtual void isc::dhcp::LeaseMgr::updateLease4 ( const Lease4Ptr lease4)
pure virtual
virtual size_t isc::dhcp::LeaseMgr::wipeLeases4 ( const SubnetID subnet_id)
pure virtual

Virtual method which removes specified leases.

This rather dangerous method is able to remove all leases from specified subnet.

Parameters
subnet_ididentifier of the subnet (or 0 for all subnets)
Returns
number of leases removed.

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::CqlLeaseMgr, and isc::dhcp::Memfile_LeaseMgr.

Referenced by isc::lease_cmds::LeaseCmdsImpl::lease4WipeHandler().

virtual size_t isc::dhcp::LeaseMgr::wipeLeases6 ( const SubnetID subnet_id)
pure virtual

Virtual method which removes specified leases.

This rather dangerous method is able to remove all leases from specified subnet.

Parameters
subnet_ididentifier of the subnet (or 0 for all subnets)
Returns
number of leases removed.

Implemented in isc::dhcp::MySqlLeaseMgr, isc::dhcp::PgSqlLeaseMgr, isc::dhcp::CqlLeaseMgr, and isc::dhcp::Memfile_LeaseMgr.

Referenced by isc::lease_cmds::LeaseCmdsImpl::lease6WipeHandler().


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