Kea 2.7.6
isc::dhcp::LeaseMgr Class Referenceabstract

Abstract Lease Manager. More...

#include <lease_mgr.h>

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

Public Member Functions

 LeaseMgr ()
 Constructor.
 
virtual ~LeaseMgr ()
 Destructor.
 
virtual bool addLease (const Lease4Ptr &lease)=0
 Adds an IPv4 lease.
 
virtual bool addLease (const Lease6Ptr &lease)=0
 Adds an IPv6 lease.
 
virtual size_t byRelayId6size () const
 Return the by-relay-id table size.
 
virtual size_t byRemoteId6size () const
 Return the by-remote-id table size.
 
virtual std::string checkLimits4 (isc::data::ConstElementPtr const &user_context) const =0
 Checks if the IPv4 lease limits set in the given user context are exceeded.
 
virtual std::string checkLimits6 (isc::data::ConstElementPtr const &user_context) const =0
 Checks if the IPv6 lease limits set in the given user context are exceeded.
 
virtual void clearClassLeaseCounts ()=0
 Clears the class-lease count map.
 
virtual void commit ()=0
 Commit Transactions.
 
virtual uint64_t deleteExpiredReclaimedLeases4 (const uint32_t secs)=0
 Deletes all expired and reclaimed DHCPv4 leases.
 
virtual uint64_t deleteExpiredReclaimedLeases6 (const uint32_t secs)=0
 Deletes all expired and reclaimed DHCPv6 leases.
 
virtual bool deleteLease (const Lease4Ptr &lease)=0
 Deletes an IPv4 lease.
 
virtual bool deleteLease (const Lease6Ptr &lease)=0
 Deletes an IPv6 lease.
 
virtual size_t getClassLeaseCount (const ClientClass &client_class, const Lease::Type &ltype=Lease::TYPE_V4) const =0
 Returns the class lease count for a given class and lease type.
 
virtual std::string getDescription () const =0
 Returns description of the backend.
 
virtual void getExpiredLeases4 (Lease4Collection &expired_leases, const size_t max_leases) const =0
 Returns a collection of expired DHCPv4 leases.
 
virtual void getExpiredLeases6 (Lease6Collection &expired_leases, const size_t max_leases) const =0
 Returns a collection of expired DHCPv6 leases.
 
bool getExtendedInfoTablesEnabled () const
 Returns the setting indicating if lease6 extended info tables are enabled.
 
virtual Lease4Collection getLease4 (const ClientId &clientid) const =0
 Returns existing IPv4 lease for specified client-id.
 
virtual Lease4Ptr getLease4 (const ClientId &clientid, SubnetID subnet_id) const =0
 Returns existing IPv4 lease for specified client-id.
 
virtual Lease4Ptr getLease4 (const isc::asiolink::IOAddress &addr) const =0
 Returns an IPv4 lease for specified IPv4 address.
 
virtual Lease4Collection getLease4 (const isc::dhcp::HWAddr &hwaddr) const =0
 Returns existing IPv4 leases for specified hardware address.
 
virtual Lease4Ptr getLease4 (const isc::dhcp::HWAddr &hwaddr, SubnetID subnet_id) const =0
 Returns existing IPv4 leases for specified hardware address and a subnet.
 
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
 
virtual Lease6Ptr getLease6 (Lease::Type type, const isc::asiolink::IOAddress &addr) const =0
 Returns existing IPv6 lease for a given IPv6 address.
 
virtual Lease4Collection getLeases4 () const =0
 Returns all IPv4 leases.
 
virtual Lease4Collection getLeases4 (const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const =0
 Returns range of IPv4 leases using paging.
 
virtual Lease4Collection getLeases4 (const std::string &hostname) const =0
 Returns all IPv4 leases for the particular hostname.
 
virtual Lease4Collection getLeases4 (SubnetID subnet_id) const =0
 Returns all IPv4 leases for the particular subnet identifier.
 
virtual Lease4Collection getLeases4ByRelayId (const OptionBuffer &relay_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size, const time_t &qry_start_time=0, const time_t &qry_end_time=0)=0
 Returns existing IPv4 leases with a given relay-id.
 
virtual Lease4Collection getLeases4ByRemoteId (const OptionBuffer &remote_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size, const time_t &qry_start_time=0, const time_t &qry_end_time=0)=0
 Returns existing IPv4 leases with a given remote-id.
 
virtual Lease6Collection getLeases6 () const =0
 Returns all IPv6 leases.
 
virtual Lease6Collection getLeases6 (const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const =0
 Returns range of IPv6 leases using paging.
 
virtual Lease6Collection getLeases6 (const DUID &duid) const =0
 Returns collection of leases for matching DUID.
 
virtual Lease6Collection getLeases6 (const std::string &hostname) const =0
 Returns all IPv6 leases for the particular hostname.
 
virtual Lease6Collection getLeases6 (Lease::Type type, const DUID &duid, uint32_t iaid) const =0
 Returns existing IPv6 leases for a given DUID+IA combination.
 
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.
 
virtual Lease6Collection getLeases6 (SubnetID subnet_id) const =0
 Returns all IPv6 leases for the particular subnet identifier.
 
virtual Lease6Collection getLeases6 (SubnetID subnet_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const =0
 Returns a page of IPv6 leases for a subnet identifier.
 
virtual Lease6Collection getLeases6ByRelayId (const DUID &relay_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size)=0
 Returns existing IPv6 leases with a given relay-id.
 
virtual Lease6Collection getLeases6ByRemoteId (const OptionBuffer &remote_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size)=0
 Returns existing IPv6 leases with a given remote-id.
 
virtual std::string getName () const =0
 Returns backend name.
 
virtual std::string getType () const =0
 Return backend type.
 
virtual VersionPair getVersion (const std::string &timer_name=std::string()) const =0
 Returns backend version.
 
virtual bool isJsonSupported () const =0
 Checks if JSON support is enabled in the database.
 
virtual void recountClassLeases4 ()=0
 Recount the leases per class for V4 leases.
 
virtual void recountClassLeases6 ()=0
 Recount the leases per class for V6 leases.
 
void recountLeaseStats4 ()
 Recalculates per-subnet and global stats for IPv4 leases.
 
void recountLeaseStats6 ()
 Recalculates per-subnet and global stats for IPv6 leases.
 
virtual void rollback ()=0
 Rollback Transactions.
 
void setExtendedInfoTablesEnabled (const bool enabled)
 Modifies the setting whether the lease6 extended info tables are enabled.
 
virtual LeaseStatsQueryPtr startLeaseStatsQuery4 ()
 Creates and runs the IPv4 lease stats query for all subnets.
 
virtual LeaseStatsQueryPtr startLeaseStatsQuery6 ()
 Creates and runs the IPv6 lease stats query for all subnets.
 
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery4 ()
 Creates and runs the IPv4 lease stats query for all subnets and pools.
 
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery6 ()
 Creates and runs the IPv6 lease stats query for all subnets and pools.
 
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4 (const SubnetID &subnet_id)
 Creates and runs the IPv4 lease stats query for a single subnet.
 
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6 (const SubnetID &subnet_id)
 Creates and runs the IPv6 lease stats query for a single subnet.
 
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.
 
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.
 
virtual void updateLease4 (const Lease4Ptr &lease4)=0
 Updates IPv4 lease.
 
virtual void updateLease6 (const Lease6Ptr &lease6)=0
 Updates IPv6 lease.
 
virtual size_t upgradeExtendedInfo4 (const LeasePageSize &page_size)=0
 Upgrade extended info (v4).
 
virtual size_t upgradeExtendedInfo6 (const LeasePageSize &page_size)=0
 Upgrade extended info (v6).
 
virtual void wipeExtendedInfoTables6 ()=0
 Wipe extended info table (v6).
 
virtual size_t wipeLeases4 (const SubnetID &subnet_id)=0
 Virtual method which removes specified leases.
 
virtual size_t wipeLeases6 (const SubnetID &subnet_id)=0
 Virtual method which removes specified leases.
 
virtual void writeLeases4 (const std::string &filename)=0
 Write V4 leases to a file.
 
virtual void writeLeases6 (const std::string &filename)=0
 Write V6 leases to a file.
 

Static Public Member Functions

static void extractLease4ExtendedInfo (const Lease4Ptr &lease, bool ignore_errors=true)
 Extract relay and remote identifiers from the extended info.
 
static std::string getDBVersion ()
 Class method to return extended version info This class method must be redeclared and redefined in derived classes.
 
static bool upgradeLease4ExtendedInfo (const Lease4Ptr &lease, CfgConsistency::ExtendedInfoSanity check=CfgConsistency::EXTENDED_INFO_CHECK_FIX)
 The following queries are used to fulfill Bulk Lease Query queries.
 
static bool upgradeLease6ExtendedInfo (const Lease6Ptr &lease, CfgConsistency::ExtendedInfoSanity check=CfgConsistency::EXTENDED_INFO_CHECK_FIX)
 Upgrade a V6 lease user context to the new extended info entry.
 

Protected Member Functions

virtual bool addExtendedInfo6 (const Lease6Ptr &lease)
 Extract extended info from a lease6 and add it into tables.
 
virtual void addRelayId6 (const isc::asiolink::IOAddress &lease_addr, const std::vector< uint8_t > &relay_id)=0
 Add lease6 extended info into by-relay-id table.
 
virtual void addRemoteId6 (const isc::asiolink::IOAddress &lease_addr, const std::vector< uint8_t > &remote_id)=0
 Add lease6 extended info into by-remote-id table.
 
virtual void deleteExtendedInfo6 (const isc::asiolink::IOAddress &addr)=0
 Delete lease6 extended info from tables.
 
void setExtendedInfoTablesEnabled (const db::DatabaseConnection::ParameterMap &parameters)
 Extended information / Bulk Lease Query shared interface.
 

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 248 of file lease_mgr.h.

Constructor & Destructor Documentation

◆ LeaseMgr()

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

Constructor.

Definition at line 252 of file lease_mgr.h.

◆ ~LeaseMgr()

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

Destructor.

Definition at line 256 of file lease_mgr.h.

Member Function Documentation

◆ addExtendedInfo6()

bool isc::dhcp::LeaseMgr::addExtendedInfo6 ( const Lease6Ptr & lease)
protectedvirtual

Extract extended info from a lease6 and add it into tables.

Parameters
leaseIPv6 lease to process.
Returns
true if something was added, false otherwise.

Definition at line 1194 of file lease_mgr.cc.

References addRelayId6(), addRemoteId6(), isc::util::encode::decodeHex(), isc::data::Element::list, and isc::data::Element::map.

Referenced by isc::dhcp::Memfile_LeaseMgr::buildExtendedInfoTables6().

+ Here is the call graph for this function:

◆ addLease() [1/2]

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::Memfile_LeaseMgr.

Referenced by isc::lease_cmds::LeaseCmdsImpl::leaseAddHandler(), and isc::dhcp::Dhcpv4Srv::serverDecline().

◆ addLease() [2/2]

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::Memfile_LeaseMgr.

◆ addRelayId6()

virtual void isc::dhcp::LeaseMgr::addRelayId6 ( const isc::asiolink::IOAddress & lease_addr,
const std::vector< uint8_t > & relay_id )
protectedpure virtual

Add lease6 extended info into by-relay-id table.

Parameters
lease_addrThe address of the lease.
relay_idThe relay id from the relay header options.

Implemented in isc::dhcp::Memfile_LeaseMgr.

Referenced by addExtendedInfo6().

◆ addRemoteId6()

virtual void isc::dhcp::LeaseMgr::addRemoteId6 ( const isc::asiolink::IOAddress & lease_addr,
const std::vector< uint8_t > & remote_id )
protectedpure virtual

Add lease6 extended info into by-remote-id table.

Parameters
lease_addrThe address of the lease.
remote_idThe remote id from the relay header options.

Implemented in isc::dhcp::Memfile_LeaseMgr.

Referenced by addExtendedInfo6().

◆ byRelayId6size()

size_t isc::dhcp::LeaseMgr::byRelayId6size ( ) const
virtual

Return the by-relay-id table size.

Must be derived by backends implementing the table.

Returns
Always 0.

Reimplemented in isc::dhcp::Memfile_LeaseMgr.

Definition at line 1255 of file lease_mgr.cc.

◆ byRemoteId6size()

size_t isc::dhcp::LeaseMgr::byRemoteId6size ( ) const
virtual

Return the by-remote-id table size.

Must be derived by backends implementing the table.

Returns
Always 0.

Reimplemented in isc::dhcp::Memfile_LeaseMgr.

Definition at line 1260 of file lease_mgr.cc.

◆ checkLimits4()

virtual std::string isc::dhcp::LeaseMgr::checkLimits4 ( isc::data::ConstElementPtr const & user_context) const
pure virtual

Checks if the IPv4 lease limits set in the given user context are exceeded.

Abstract method.

Parameters
user_contextall or part of the lease's user context which, for the intents and purposes of lease limiting should have the following format (not all nodes are mandatory and values are given only as examples): { "ISC": { "limits": { "client-classes": [ { "name": "foo", "address-limit": 2 } ], "subnet": { "id": 1, "address-limit": 2 } } } }
Returns
a string describing a limit that is being exceeded, or an empty string if no limits are exceeded

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ checkLimits6()

virtual std::string isc::dhcp::LeaseMgr::checkLimits6 ( isc::data::ConstElementPtr const & user_context) const
pure virtual

Checks if the IPv6 lease limits set in the given user context are exceeded.

Abstract method.

Parameters
user_contextall or part of the lease's user context which, for the intents and purposes of lease limiting should have the following format (not all nodes are mandatory and values are given only as examples): { "ISC": { "limits": { "client-classes": [ { "name": "foo", "address-limit": 2, "prefix-limit": 1 } ], "subnet": { "id": 1, "address-limit": 2, "prefix-limit": 1 } } } }
Returns
a string describing a limit that is being exceeded, or an empty string if no limits are exceeded

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ clearClassLeaseCounts()

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

Clears the class-lease count map.

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ commit()

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.

◆ deleteExpiredReclaimedLeases4()

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::Memfile_LeaseMgr.

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

◆ deleteExpiredReclaimedLeases6()

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::Memfile_LeaseMgr.

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

◆ deleteExtendedInfo6()

virtual void isc::dhcp::LeaseMgr::deleteExtendedInfo6 ( const isc::asiolink::IOAddress & addr)
protectedpure virtual

Delete lease6 extended info from tables.

Parameters
addrThe address of the lease.

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ deleteLease() [1/2]

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::Memfile_LeaseMgr.

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

◆ deleteLease() [2/2]

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::Memfile_LeaseMgr.

◆ extractLease4ExtendedInfo()

void isc::dhcp::LeaseMgr::extractLease4ExtendedInfo ( const Lease4Ptr & lease,
bool ignore_errors = true )
static

Extract relay and remote identifiers from the extended info.

Parameters
leasePointer to the lease to be updated.
ignore_errorsWhen true (the default) ignore errors, when false throw an exception.

Definition at line 1108 of file lease_mgr.cc.

References isc::util::encode::decodeHex(), isc_throw, isc::data::Element::map, and isc::data::Element::string.

Referenced by isc::dhcp::Memfile_LeaseMgr::extractExtendedInfo4(), and isc::lease_cmds::Lease4Parser::parse().

+ Here is the call graph for this function:

◆ getClassLeaseCount()

virtual size_t isc::dhcp::LeaseMgr::getClassLeaseCount ( const ClientClass & client_class,
const Lease::Type & ltype = Lease::TYPE_V4 ) const
pure virtual

Returns the class lease count for a given class and lease type.

Parameters
client_classclient class for which the count is desired
ltypetype of lease for which the count is desired. Defaults to Lease::TYPE_V4.
Returns
number of leases

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ getDBVersion()

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 516 of file lease_mgr.cc.

References isc_throw.

◆ getDescription()

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.

◆ getExpiredLeases4()

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::Memfile_LeaseMgr.

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

◆ getExpiredLeases6()

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::Memfile_LeaseMgr.

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

◆ getExtendedInfoTablesEnabled()

bool isc::dhcp::LeaseMgr::getExtendedInfoTablesEnabled ( ) const
inline

Returns the setting indicating if lease6 extended info tables are enabled.

Returns
true if lease6 extended info tables are enabled or false if they are disabled.

Definition at line 1010 of file lease_mgr.h.

Referenced by isc::dhcp::Memfile_LeaseMgr::buildExtendedInfoTables6().

◆ getLease4() [1/5]

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::Memfile_LeaseMgr.

◆ getLease4() [2/5]

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::Memfile_LeaseMgr.

◆ getLease4() [3/5]

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::Memfile_LeaseMgr.

Referenced by isc::lease_cmds::LeaseCmdsImpl::addOrUpdate4(), isc::dhcp::Dhcpv4Srv::assignLease(), 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(), isc::dhcp::Dhcpv4Srv::processRelease(), and isc::dhcp::Dhcpv4Srv::recoverStashedAgentOption().

◆ getLease4() [4/5]

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::Memfile_LeaseMgr.

◆ getLease4() [5/5]

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::Memfile_LeaseMgr.

◆ getLease6() [1/2]

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 55 of file lease_mgr.cc.

References getLeases6(), isc_throw, and isc::dhcp::IdentifierType< min_size, max_size >::toText().

+ Here is the call graph for this function:

◆ getLease6() [2/2]

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::Memfile_LeaseMgr.

Referenced by isc::lease_cmds::LeaseCmdsImpl::addOrUpdate6(), 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().

◆ getLeases4() [1/4]

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::Memfile_LeaseMgr.

◆ getLeases4() [2/4]

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::Memfile_LeaseMgr.

◆ getLeases4() [3/4]

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::Memfile_LeaseMgr.

◆ getLeases4() [4/4]

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::Memfile_LeaseMgr.

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

◆ getLeases4ByRelayId()

virtual Lease4Collection isc::dhcp::LeaseMgr::getLeases4ByRelayId ( const OptionBuffer & relay_id,
const asiolink::IOAddress & lower_bound_address,
const LeasePageSize & page_size,
const time_t & qry_start_time = 0,
const time_t & qry_end_time = 0 )
pure virtual

Returns existing IPv4 leases with a given relay-id.

Parameters
relay_idRAI Relay-ID sub-option value for relay_id of interest
lower_bound_addressIPv4 address used as lower bound for the returned range.
page_sizemaximum size of the page returned.
qry_start_timewhen not zero, only leases whose CLTT is greater than or equal to this value will be included
qry_end_timewhen not zero, only leases whose CLTT is less than or equal to this value will be included
Returns
collection of IPv4 leases

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ getLeases4ByRemoteId()

virtual Lease4Collection isc::dhcp::LeaseMgr::getLeases4ByRemoteId ( const OptionBuffer & remote_id,
const asiolink::IOAddress & lower_bound_address,
const LeasePageSize & page_size,
const time_t & qry_start_time = 0,
const time_t & qry_end_time = 0 )
pure virtual

Returns existing IPv4 leases with a given remote-id.

Parameters
remote_idRAI Remote-ID sub-option value for remote-id of interest
lower_bound_addressIPv4 address used as lower bound for the returned range.
page_sizemaximum size of the page returned.
qry_start_timewhen not zero, only leases whose CLTT is greater than or equal to this value will be included. Defaults to zero.
qry_end_timewhen not zero, only leases whose CLTT is less than or equal to this value will be included. Defaults to zero.
Returns
collection of IPv4 leases

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ getLeases6() [1/8]

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::Memfile_LeaseMgr.

Referenced by getLease6().

◆ getLeases6() [2/8]

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::Memfile_LeaseMgr.

◆ getLeases6() [3/8]

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::Memfile_LeaseMgr.

◆ getLeases6() [4/8]

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::Memfile_LeaseMgr.

◆ getLeases6() [5/8]

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::Memfile_LeaseMgr.

Referenced by isc::dhcp::AllocEngine::allocateLeases6(), 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().

◆ getLeases6() [6/8]

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::Memfile_LeaseMgr.

◆ getLeases6() [7/8]

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::Memfile_LeaseMgr.

◆ getLeases6() [8/8]

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

Returns a page of IPv6 leases for a subnet identifier.

Parameters
subnet_idsubnet identifier.
lower_bound_addressIPv6 address used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
collection of IPv6 leases

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ getLeases6ByRelayId()

virtual Lease6Collection isc::dhcp::LeaseMgr::getLeases6ByRelayId ( const DUID & relay_id,
const asiolink::IOAddress & lower_bound_address,
const LeasePageSize & page_size )
pure virtual

Returns existing IPv6 leases with a given relay-id.

Parameters
relay_idDUID for relay_id of interest.
lower_bound_addressIPv6 address used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
collection of IPv6 leases

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ getLeases6ByRemoteId()

virtual Lease6Collection isc::dhcp::LeaseMgr::getLeases6ByRemoteId ( const OptionBuffer & remote_id,
const asiolink::IOAddress & lower_bound_address,
const LeasePageSize & page_size )
pure virtual

Returns existing IPv6 leases with a given remote-id.

Parameters
remote_idremote-id option data of interest.
lower_bound_addressIPv6 address used as lower bound for the returned range.
page_sizemaximum size of the page returned.
Returns
collection of IPv6 leases

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ getName()

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.

◆ getType()

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.

◆ getVersion()

virtual VersionPair isc::dhcp::LeaseMgr::getVersion ( const std::string & timer_name = std::string()) const
pure virtual

Returns backend version.

Parameters
timer_nameThe DB reconnect timer name.
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.

◆ isJsonSupported()

virtual bool isc::dhcp::LeaseMgr::isJsonSupported ( ) const
pure virtual

Checks if JSON support is enabled in the database.

Abstract method.

Returns
true if there is JSON support, false otherwise

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ recountClassLeases4()

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

Recount the leases per class for V4 leases.

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ recountClassLeases6()

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

Recount the leases per class for V6 leases.

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ recountLeaseStats4()

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.

NULL means not backend does not support recounting.

Definition at line 72 of file lease_mgr.cc.

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

Referenced by isc::dhcp::CfgSubnets4::updateStatistics().

+ Here is the call graph for this function:

◆ recountLeaseStats6()

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.

NULL means not backend does not support recounting.

Definition at line 282 of file lease_mgr.cc.

References isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseStatsRow::lease_state_, isc::dhcp::LeaseStatsRow::lease_type_, isc::dhcp::LeaseStatsRow::pool_id_, startLeaseStatsQuery6(), startPoolLeaseStatsQuery6(), 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.

Referenced by isc::dhcp::CfgSubnets6::updateStatistics().

+ Here is the call graph for this function:

◆ rollback()

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.

◆ setExtendedInfoTablesEnabled() [1/2]

void isc::dhcp::LeaseMgr::setExtendedInfoTablesEnabled ( const bool enabled)
inline

Modifies the setting whether the lease6 extended info tables are enabled.

Parameters
enablednew setting.

Definition at line 1018 of file lease_mgr.h.

Referenced by isc::dhcp::Memfile_LeaseMgr::Memfile_LeaseMgr(), and setExtendedInfoTablesEnabled().

◆ setExtendedInfoTablesEnabled() [2/2]

void isc::dhcp::LeaseMgr::setExtendedInfoTablesEnabled ( const db::DatabaseConnection::ParameterMap & parameters)
protected

Extended information / Bulk Lease Query shared interface.

Decode parameters to set whether the lease extended info tables are enabled.

Note
: common code in constructors.
Parameters
parametersThe parameter map.

Definition at line 521 of file lease_mgr.cc.

References setExtendedInfoTablesEnabled().

+ Here is the call graph for this function:

◆ startLeaseStatsQuery4()

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.

Definition at line 256 of file lease_mgr.cc.

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

◆ startLeaseStatsQuery6()

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.

Definition at line 495 of file lease_mgr.cc.

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

◆ startPoolLeaseStatsQuery4()

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

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

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 and pools. Each row of the result set is an LeaseStatRow which ordered ascending by subnet ID and pool ID.

Returns
A populated LeaseStatsQuery

Reimplemented in isc::dhcp::Memfile_LeaseMgr.

Definition at line 261 of file lease_mgr.cc.

Referenced by recountLeaseStats4().

◆ startPoolLeaseStatsQuery6()

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

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

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 and pools. Each row of the result set is an LeaseStatRow which ordered ascending by subnet ID and pool ID.

Returns
A populated LeaseStatsQuery

Reimplemented in isc::dhcp::Memfile_LeaseMgr.

Definition at line 500 of file lease_mgr.cc.

Referenced by recountLeaseStats6().

◆ startSubnetLeaseStatsQuery4()

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.

Definition at line 266 of file lease_mgr.cc.

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

◆ startSubnetLeaseStatsQuery6()

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.

Definition at line 505 of file lease_mgr.cc.

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

◆ startSubnetRangeLeaseStatsQuery4()

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.

Definition at line 271 of file lease_mgr.cc.

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

◆ startSubnetRangeLeaseStatsQuery6()

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.

Definition at line 510 of file lease_mgr.cc.

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

◆ updateLease4()

virtual void isc::dhcp::LeaseMgr::updateLease4 ( const Lease4Ptr & lease4)
pure virtual

Updates IPv4 lease.

Parameters
lease4The lease to be updated.

If no such lease is present, an exception will be thrown.

Implemented in isc::dhcp::Memfile_LeaseMgr.

Referenced by isc::lease_cmds::LeaseCmdsImpl::addOrUpdate4(), isc::dhcp::Dhcpv4Srv::declineLease(), isc::dhcp::Dhcpv4Srv::postAllocateNameUpdate(), isc::dhcp::Dhcpv4Srv::processRelease(), and isc::dhcp::Dhcpv4Srv::serverDecline().

◆ updateLease6()

virtual void isc::dhcp::LeaseMgr::updateLease6 ( const Lease6Ptr & lease6)
pure virtual

◆ upgradeExtendedInfo4()

virtual size_t isc::dhcp::LeaseMgr::upgradeExtendedInfo4 ( const LeasePageSize & page_size)
pure virtual

Upgrade extended info (v4).

On SQL backends for all leases with a not null user context.

  • sanitize the user context
  • update relay and remote ids
  • when the lease was modified update it in the database On memfile backend a similar action is done when the database is loaded from the file. This function implements the new BLQ hook command named "extended-info4-upgrade".
Parameters
page_sizeThe page size used for retrieval.
Returns
The number of updates in the database.

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ upgradeExtendedInfo6()

virtual size_t isc::dhcp::LeaseMgr::upgradeExtendedInfo6 ( const LeasePageSize & page_size)
pure virtual

Upgrade extended info (v6).

On SQL backends for all leases with a not null user context.

  • sanitize the user context
  • update relay and remote id tables
  • when the lease was modified update it in the database On memfile backend a similar action is done when the database is loaded from the file. This function implements the new BLQ hook command named "extended-info6-upgrade".
Parameters
page_sizeThe page size used for retrieval.
Returns
The number of updates in the database.

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ upgradeLease4ExtendedInfo()

bool isc::dhcp::LeaseMgr::upgradeLease4ExtendedInfo ( const Lease4Ptr & lease,
CfgConsistency::ExtendedInfoSanity check = CfgConsistency::EXTENDED_INFO_CHECK_FIX )
static

The following queries are used to fulfill Bulk Lease Query queries.

They rely on relay data contained in lease's user-context when the extended-store-info flag is enabled.

Upgrade a V4 lease user context to the new extended info entry.

In details:

  • perform sanity checks according to check level.
  • change the "ISC" / "relay-agent-info" to a map.
  • move the "relay-agent-info" string to the "sub-options" entry of the map.
  • decode remote-id and relay-id from the RAI option content and add the raw value in hexadecimal in "remote-id" and/or "relay-id" entries of the map.
Parameters
leasePointer to the lease to be updated.
checkSanity/consistency check level.
Returns
True if the lease user context was updated, false otherwise.

Definition at line 535 of file lease_mgr.cc.

References isc::data::copy(), isc::data::Element::create(), isc::data::Element::createMap(), isc::util::str::decodeFormattedHexString(), isc::util::encode::decodeHex(), isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::DHCPSRV_LEASE4_EXTENDED_INFO_SANITY_FAIL, isc::dhcp::DHCPSRV_LEASE4_EXTENDED_INFO_UPGRADED, isc::dhcp::dhcpsrv_logger, isc::dhcp::LibDHCP::DHO_DHCP_AGENT_OPTIONS_DEF(), isc::util::encode::encodeHex(), isc::dhcp::CfgConsistency::EXTENDED_INFO_CHECK_FIX, isc::dhcp::CfgConsistency::EXTENDED_INFO_CHECK_NONE, isc::dhcp::CfgConsistency::EXTENDED_INFO_CHECK_PEDANTIC, isc_throw, LOG_DEBUG, LOG_ERROR, isc::data::Element::map, isc::dhcp::RAI_OPTION_RELAY_ID, isc::dhcp::RAI_OPTION_REMOTE_ID, isc::data::Element::string, and isc::dhcp::Option::V4.

Referenced by isc::dhcp::Memfile_LeaseMgr::extractExtendedInfo4(), and isc::lease_cmds::Lease4Parser::parse().

+ Here is the call graph for this function:

◆ upgradeLease6ExtendedInfo()

bool isc::dhcp::LeaseMgr::upgradeLease6ExtendedInfo ( const Lease6Ptr & lease,
CfgConsistency::ExtendedInfoSanity check = CfgConsistency::EXTENDED_INFO_CHECK_FIX )
static

Upgrade a V6 lease user context to the new extended info entry.

In details:

  • perform sanity checks according to check level.
  • change the "ISC" / "relays" list entry to "relay-info".
  • decode remote-id and relay-id from each relay options and add the raw value in hexadecimal in "remote-id" and/or "relay-id" in the relay item of the list.
Parameters
leasePointer to the lease to be updated.
checkSanity/consistency check level.
Returns
True if the lease user context was updated, false otherwise.

Definition at line 756 of file lease_mgr.cc.

References isc::data::copy(), isc::data::Element::create(), D6O_RELAY_ID, D6O_REMOTE_ID, isc::util::str::decodeFormattedHexString(), isc::util::encode::decodeHex(), DHCP6_OPTION_SPACE, isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::DHCPSRV_LEASE6_EXTENDED_INFO_SANITY_FAIL, isc::dhcp::DHCPSRV_LEASE6_EXTENDED_INFO_UPGRADED, isc::dhcp::dhcpsrv_logger, isc::util::encode::encodeHex(), isc::dhcp::CfgConsistency::EXTENDED_INFO_CHECK_FIX, isc::dhcp::CfgConsistency::EXTENDED_INFO_CHECK_NONE, isc::dhcp::CfgConsistency::EXTENDED_INFO_CHECK_PEDANTIC, isc::data::Element::integer, isc_throw, isc::asiolink::IOAddress::isV6(), isc::data::Element::list, LOG_DEBUG, LOG_ERROR, isc::data::Element::map, isc::data::Element::string, and isc::dhcp::LibDHCP::unpackOptions6().

Referenced by isc::dhcp::Memfile_LeaseMgr::buildExtendedInfoTables6(), and isc::lease_cmds::Lease6Parser::parse().

+ Here is the call graph for this function:

◆ wipeExtendedInfoTables6()

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

Wipe extended info table (v6).

Implemented in isc::dhcp::Memfile_LeaseMgr.

◆ wipeLeases4()

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::Memfile_LeaseMgr.

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

◆ wipeLeases6()

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::Memfile_LeaseMgr.

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

◆ writeLeases4()

virtual void isc::dhcp::LeaseMgr::writeLeases4 ( const std::string & filename)
pure virtual

Write V4 leases to a file.

Parameters
filenameFile name to write leases.

Implemented in isc::dhcp::Memfile_LeaseMgr.

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

◆ writeLeases6()

virtual void isc::dhcp::LeaseMgr::writeLeases6 ( const std::string & filename)
pure virtual

Write V6 leases to a file.

Parameters
filenameFile name to write leases.

Implemented in isc::dhcp::Memfile_LeaseMgr.

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


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