Kea  2.1.7-git
isc::dhcp::Memfile_LeaseMgr Class Reference

Concrete implementation of a lease database backend using flat file. More...

#include <memfile_lease_mgr.h>

+ Inheritance diagram for isc::dhcp::Memfile_LeaseMgr:

Public Types

enum  Universe { V4, V6 }
 Specifies universe (V4, V6) More...
 

Public Member Functions

virtual void commit ()
 Commit Transactions. More...
 
virtual std::string getDescription () const
 Returns description of the backend. More...
 
virtual std::string getName () const
 Returns backend name. More...
 
virtual std::string getType () const
 Return backend type. More...
 
virtual std::pair< uint32_t, uint32_t > getVersion () const
 Returns backend version. More...
 
virtual void rollback ()
 Rollback Transactions. More...
 
virtual LeaseStatsQueryPtr startLeaseStatsQuery4 ()
 Creates and runs the IPv4 lease stats query. More...
 
virtual LeaseStatsQueryPtr startLeaseStatsQuery6 ()
 Creates and runs the IPv6 lease stats query. 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...
 
Miscellaneous public convenience methods.

The following methods allow for retrieving useful information about the state of the backend.

std::string getDefaultLeaseFilePath (Universe u) const
 Returns default path to the lease file. More...
 
std::string getLeaseFilePath (Universe u) const
 Returns an absolute path to the lease file. More...
 
bool persistLeases (Universe u) const
 Specifies whether or not leases are written to disk. More...
 
Public methods to retrieve information about the LFC process state.

These methods are meant to be used by unit tests to retrieve the state of the spawned LFC process before validating the result of the lease file cleanup.

bool isLFCRunning () const
 Checks if the process performing lease file cleanup is running. More...
 
int getLFCExitStatus () const
 Returns the status code returned by the last executed LFC process. More...
 
- Public Member Functions inherited from isc::dhcp::LeaseMgr
 LeaseMgr ()
 Constructor. More...
 
virtual ~LeaseMgr ()
 Destructor. 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...
 
void recountLeaseStats4 ()
 Recalculates per-subnet and global stats for IPv4 leases. More...
 
void recountLeaseStats6 ()
 Recalculates per-subnet and global stats for IPv6 leases. More...
 

Static Public Attributes

static const int MAJOR_VERSION_V4 = 2
 
static const int MAJOR_VERSION_V6 = 4
 
static const int MINOR_VERSION_V4 = 1
 the minor version of the v4 memfile backend More...
 
static const int MINOR_VERSION_V6 = 0
 the minor version of the v6 memfile backend More...
 

Protected Member Functions

Protected methods used for Lease File Cleanup.

The following methods are protected so as they can be accessed and tested by unit tests.

virtual void lfcCallback ()
 A callback function triggering Lease File Cleanup (LFC). More...
 

Methods implementing the API of the lease database backend.

The following methods are implementing the API of the LeaseMgr to manage leases.

 Memfile_LeaseMgr (const db::DatabaseConnection::ParameterMap &parameters)
 The sole lease manager constructor. More...
 
virtual ~Memfile_LeaseMgr ()
 Destructor (closes file) More...
 
virtual bool addLease (const Lease4Ptr &lease)
 Adds an IPv4 lease. More...
 
virtual bool addLease (const Lease6Ptr &lease)
 Adds an IPv6 lease. More...
 
virtual Lease4Ptr getLease4 (const isc::asiolink::IOAddress &addr) const
 Returns existing IPv4 lease for specified IPv4 address. More...
 
virtual Lease4Collection getLease4 (const isc::dhcp::HWAddr &hwaddr) const
 Returns existing IPv4 leases for specified hardware address. More...
 
virtual Lease4Ptr getLease4 (const HWAddr &hwaddr, SubnetID subnet_id) const
 Returns existing IPv4 lease for specified hardware address and a subnet. More...
 
virtual Lease4Collection getLease4 (const ClientId &client_id) const
 Returns existing IPv4 lease for specified client-id. More...
 
virtual Lease4Ptr getLease4 (const ClientId &clientid, SubnetID subnet_id) const
 Returns existing IPv4 lease for specified client-id. More...
 
virtual Lease4Collection getLeases4 (SubnetID subnet_id) const
 Returns all IPv4 leases for the particular subnet identifier. More...
 
virtual Lease4Collection getLeases4 (const std::string &hostname) const
 Returns all IPv4 leases for the particular hostname. More...
 
virtual Lease4Collection getLeases4 () const
 Returns all IPv4 leases. More...
 
virtual Lease4Collection getLeases4 (const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const
 Returns range of IPv4 leases using paging. More...
 
virtual Lease6Ptr getLease6 (Lease::Type type, const isc::asiolink::IOAddress &addr) const
 Returns existing IPv6 lease for a given IPv6 address. More...
 
virtual Lease6Collection getLeases6 (Lease::Type type, const DUID &duid, uint32_t iaid) const
 Returns existing IPv6 lease for a given DUID + IA + lease type combination. More...
 
virtual Lease6Collection getLeases6 (Lease::Type type, const DUID &duid, uint32_t iaid, SubnetID subnet_id) const
 Returns existing IPv6 lease for a given DUID + IA + subnet-id + lease type combination. More...
 
virtual Lease6Collection getLeases6 (SubnetID subnet_id) const
 Returns all IPv6 leases for the particular subnet identifier. More...
 
virtual Lease6Collection getLeases6 (const std::string &hostname) const
 Returns all IPv6 leases for the particular hostname. More...
 
virtual Lease6Collection getLeases6 () const
 Returns all IPv6 leases. More...
 
virtual Lease6Collection getLeases6 (const DUID &duid) const
 Returns IPv6 leases for the DUID. More...
 
virtual Lease6Collection getLeases6 (const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const
 Returns range of IPv6 leases using paging. More...
 
virtual void getExpiredLeases4 (Lease4Collection &expired_leases, const size_t max_leases) const
 Returns a collection of expired DHCPv4 leases. More...
 
virtual void getExpiredLeases6 (Lease6Collection &expired_leases, const size_t max_leases) const
 Returns a collection of expired DHCPv6 leases. More...
 
virtual void updateLease4 (const Lease4Ptr &lease4)
 Updates IPv4 lease. More...
 
virtual void updateLease6 (const Lease6Ptr &lease6)
 Updates IPv6 lease. More...
 
virtual bool deleteLease (const Lease4Ptr &lease)
 Deletes an IPv4 lease. More...
 
virtual bool deleteLease (const Lease6Ptr &lease)
 Deletes an IPv6 lease. More...
 
virtual uint64_t deleteExpiredReclaimedLeases4 (const uint32_t secs)
 Deletes all expired-reclaimed DHCPv4 leases. More...
 
virtual uint64_t deleteExpiredReclaimedLeases6 (const uint32_t secs)
 Deletes all expired-reclaimed DHCPv6 leases. More...
 
virtual size_t wipeLeases4 (const SubnetID &subnet_id)
 Removes specified IPv4 leases. More...
 
virtual size_t wipeLeases6 (const SubnetID &subnet_id)
 Removed specified IPv6 leases. More...
 
std::string checkLimits4 (isc::data::ConstElementPtr const &user_context) const override
 Checks if the IPv4 lease limits set in the given user context are exceeded. More...
 
std::string checkLimits6 (isc::data::ConstElementPtr const &user_context) const override
 Checks if the IPv6 lease limits set in the given user context are exceeded. More...
 
bool isJsonSupported () const override
 Checks if JSON support is enabled in the database. More...
 
static std::string getDBVersion (Universe const &u)
 Local version of getDBVersion() class method. More...
 

Public type and method used to determine file names for LFC.

enum  LFCFileType {
  FILE_CURRENT, FILE_INPUT, FILE_PREVIOUS, FILE_OUTPUT,
  FILE_FINISH, FILE_PID
}
 Types of the lease files used by the Lease File Cleanup. More...
 
static std::string appendSuffix (const std::string &file_name, const LFCFileType &file_type)
 Appends appropriate suffix to the file name. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from isc::dhcp::LeaseMgr
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

Concrete implementation of a lease database backend using flat file.

This class implements a lease database backend using CSV files to store DHCPv4 and DHCPv6 leases on disk. The format of the files is determined by the CSVLeaseFile4 and CSVLeaseFile6 classes.

In order to obtain good performance, the backend stores leases incrementally, i.e. updates to leases are appended at the end of the lease file. To record the deletion of a lease, the lease record is appended to the lease file with the valid lifetime set to 0. However, this may result in a significant growth of the lease file size over time, because the lease file will contain many entries for each lease. In order to mitigate this problem, the backend implements the Lease File Cleanup mechanism which is described on the Kea wiki: https://gitlab.isc.org/isc-projects/kea/wikis/designs/Lease-File-Cleanup-design.

The backend installs an asiolink::IntervalTimer to periodically execute the Memfile_LeaseMgr::lfcCallback. This callback function controls the startup of the background process which removes redundant information from the lease file(s).

When the backend is starting up, it reads leases from the lease file (one by one) and adds them to the in-memory container as follows:

  • if the lease record being parsed identifies a lease which is not present in the container, and the lease has valid lifetime greater than 0, the lease is added to the container,
  • if the lease record being parsed identifies a lease which is present in the container, and the valid lifetime of the lease record being parsed is greater than 0, the lease in the container is updated
  • if the lease record being parsed has valid lifetime equal to 0, and the corresponding lease exists in the container, the lease is removed from the container.

After the container holding leases is initialized, each subsequent update, removal or addition of the lease is appended to the lease file synchronously.

Originally, the Memfile backend didn't write leases to disk. This was particularly useful for testing server performance in non-disk bound conditions. In order to preserve this capability, the new parameter "persist=true|false" has been introduced in the database access string. For example, database access string: "type=memfile persist=true" enables writes of leases to a disk.

The lease file locations can be specified with the "name=[path]" parameter in the database access string. The [path] is the absolute path to the file (including file name). If this parameter is not specified, the default location in the installation directory is used: <install-dir>/var/lib/kea/kea-leases4.csv and <install-dir>/var/lib/kea/kea-leases6.csv.

Definition at line 79 of file memfile_lease_mgr.h.

Member Enumeration Documentation

◆ LFCFileType

Types of the lease files used by the Lease File Cleanup.

This enumeration is used by a method which appends the appropriate suffix to the lease file name.

Enumerator
FILE_CURRENT 

Lease File

FILE_INPUT 

Lease File Copy

FILE_PREVIOUS 

Previous Lease File.

FILE_OUTPUT 

LFC Output File.

FILE_FINISH 

LFC Finish File.

FILE_PID 

PID File.

Definition at line 894 of file memfile_lease_mgr.h.

◆ Universe

Specifies universe (V4, V6)

This enumeration is used by various functions in Memfile Lease Manager, to identify the lease type referred to. In particular, it is used by functions operating on the lease files to distinguish between lease files for DHCPv4 and DHCPv6.

Enumerator
V4 
V6 

Definition at line 121 of file memfile_lease_mgr.h.

Constructor & Destructor Documentation

◆ Memfile_LeaseMgr()

isc::dhcp::Memfile_LeaseMgr::Memfile_LeaseMgr ( const db::DatabaseConnection::ParameterMap parameters)

The sole lease manager constructor.

This method:

  • Initializes the new instance based on the parameters given
  • Loads (or creates) the appropriate lease file(s)
  • Initiates the periodic scheduling of the LFC (if enabled)

If any of the files loaded require conversion to the current schema (upgrade or downgrade), lfcSetup() will be invoked with its run_once_now parameter set to true. This causes lfcSetup() to invoke the LFC process immediately regardless of whether LFC is enabled. This ensures that any files which need conversion are converted automatically.

dbconfig is a generic way of passing parameters. Parameters are passed in the "name=value" format, separated by spaces. Values may be enclosed in double quotes, if needed.

Parameters
parametersA data structure relating keywords and values concerned with the database.

Definition at line 635 of file memfile_lease_mgr.cc.

References isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_CONVERTING_LEASE_FILES, isc::dhcp::DHCPSRV_MEMFILE_NO_STORAGE, isc::db::DatabaseConnection::getParameter(), getVersion(), LOG_WARN, persistLeases(), V4, V6, and version().

+ Here is the call graph for this function:

◆ ~Memfile_LeaseMgr()

isc::dhcp::Memfile_LeaseMgr::~Memfile_LeaseMgr ( )
virtual

Destructor (closes file)

Definition at line 675 of file memfile_lease_mgr.cc.

Member Function Documentation

◆ addLease() [1/2]

bool isc::dhcp::Memfile_LeaseMgr::addLease ( const Lease4Ptr lease)
virtual

Adds an IPv4 lease.

Parameters
leaselease to be added
Returns
true if the lease was added, false if not

Implements isc::dhcp::LeaseMgr.

Definition at line 722 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_ADD_ADDR4, LOG_DEBUG, persistLeases(), and V6.

+ Here is the call graph for this function:

◆ addLease() [2/2]

bool isc::dhcp::Memfile_LeaseMgr::addLease ( const Lease6Ptr lease)
virtual

Adds an IPv6 lease.

Parameters
leaselease to be added
Returns
true if the lease was added, false if not

Implements isc::dhcp::LeaseMgr.

Definition at line 758 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_ADD_ADDR6, and LOG_DEBUG.

◆ appendSuffix()

std::string isc::dhcp::Memfile_LeaseMgr::appendSuffix ( const std::string &  file_name,
const LFCFileType file_type 
)
static

Appends appropriate suffix to the file name.

The suffix is selected using the LFC file type specified as a parameter. Each file type uses a unique suffix or no suffix:

  • Current File: no suffix
  • Lease File Copy or Input File: ".1"
  • Previous File: ".2"
  • LFC Output File: ".output"
  • LFC Finish File: ".completed"
  • LFC PID File: ".pid"

See https://gitlab.isc.org/isc-projects/kea/wikis/designs/Lease-File-Cleanup-design for details.

Parameters
file_nameA base file name to which suffix is appended.
file_typeAn LFC file type.
Returns
A lease file name with a suffix appended.

Definition at line 1690 of file memfile_lease_mgr.cc.

References FILE_FINISH, FILE_INPUT, FILE_OUTPUT, FILE_PID, and FILE_PREVIOUS.

Referenced by lfcCallback(), persistLeases(), and isc::dhcp::LFCSetup::setup().

◆ checkLimits4()

std::string isc::dhcp::Memfile_LeaseMgr::checkLimits4 ( isc::data::ConstElementPtr const &  user_context) const
overridevirtual

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

Memfile implementation.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 2063 of file memfile_lease_mgr.cc.

References isc_throw.

◆ checkLimits6()

std::string isc::dhcp::Memfile_LeaseMgr::checkLimits6 ( isc::data::ConstElementPtr const &  user_context) const
overridevirtual

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

Memfile implementation.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 2068 of file memfile_lease_mgr.cc.

References isc_throw.

◆ commit()

void isc::dhcp::Memfile_LeaseMgr::commit ( )
virtual

Commit Transactions.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 1679 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_COMMIT, and LOG_DEBUG.

Referenced by getName().

◆ deleteExpiredReclaimedLeases4()

uint64_t isc::dhcp::Memfile_LeaseMgr::deleteExpiredReclaimedLeases4 ( const uint32_t  secs)
virtual

Deletes all expired-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.

Implements isc::dhcp::LeaseMgr.

Definition at line 1564 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED4, LOG_DEBUG, and V4.

◆ deleteExpiredReclaimedLeases6()

uint64_t isc::dhcp::Memfile_LeaseMgr::deleteExpiredReclaimedLeases6 ( const uint32_t  secs)
virtual

Deletes all expired-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.

Implements isc::dhcp::LeaseMgr.

Definition at line 1582 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED6, isc::dhcp::DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED_START, LOG_DEBUG, persistLeases(), and V6.

+ Here is the call graph for this function:

◆ deleteLease() [1/2]

bool isc::dhcp::Memfile_LeaseMgr::deleteLease ( const Lease4Ptr lease)
virtual

Deletes an IPv4 lease.

Parameters
leaseIPv4 lease being deleted.
Returns
true if deletion was successful, false if no such lease exists.
Note
The current_cltt_ and current_valid_lft_ are used to maximize the chance that only one thread or process performs an update or delete operation on the lease by matching these values with the expiration time data in the database.
For test purposes only, when persistence is disabled, the deletion of the lease is performed only if the value matches the one received on the SELECT query, effectively enforcing no update on the lease between SELECT and DELETE with different expiration time.

Implements isc::dhcp::LeaseMgr.

Definition at line 1509 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_ADDR, LOG_DEBUG, persistLeases(), isc::dhcp::Lease6::preferred_lft_, V6, and isc::dhcp::Lease::valid_lft_.

Referenced by wipeLeases4(), and wipeLeases6().

+ Here is the call graph for this function:

◆ deleteLease() [2/2]

bool isc::dhcp::Memfile_LeaseMgr::deleteLease ( const Lease6Ptr lease)
virtual

Deletes an IPv6 lease.

Parameters
leaseIPv6 lease being deleted.
Returns
true if deletion was successful, false if no such lease exists.
Note
The current_cltt_ and current_valid_lft_ are used to maximize the chance that only one thread or process performs an update or delete operation on the lease by matching these values with the expiration time data in the database.
For test purposes only, when persistence is disabled, the deletion of the lease is performed only if the value matches the one received on the SELECT query, effectively enforcing no update on the lease between SELECT and DELETE with different expiration time.

Implements isc::dhcp::LeaseMgr.

Definition at line 1551 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_ADDR, and LOG_DEBUG.

◆ getDBVersion()

std::string isc::dhcp::Memfile_LeaseMgr::getDBVersion ( Universe const &  u)
static

Local version of getDBVersion() class method.

Definition at line 687 of file memfile_lease_mgr.cc.

References MAJOR_VERSION_V4, MAJOR_VERSION_V6, MINOR_VERSION_V4, MINOR_VERSION_V6, persistLeases(), V4, and V6.

+ Here is the call graph for this function:

◆ getDefaultLeaseFilePath()

std::string isc::dhcp::Memfile_LeaseMgr::getDefaultLeaseFilePath ( Universe  u) const

Returns default path to the lease file.

Parameters
uUniverse (V4 or V6).

Definition at line 1718 of file memfile_lease_mgr.cc.

References isc::dhcp::CfgMgr::getDataDir(), isc::dhcp::CfgMgr::instance(), and V4.

Referenced by persistLeases().

+ Here is the call graph for this function:

◆ getDescription()

std::string isc::dhcp::Memfile_LeaseMgr::getDescription ( ) const
virtual

Returns description of the backend.

This description may be multiline text that describes the backend.

Returns
Description of the backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 1663 of file memfile_lease_mgr.cc.

Referenced by getName().

◆ getExpiredLeases4()

void isc::dhcp::Memfile_LeaseMgr::getExpiredLeases4 ( Lease4Collection expired_leases,
const size_t  max_leases 
) const
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.

Implements isc::dhcp::LeaseMgr.

Definition at line 1336 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_EXPIRED4, and LOG_DEBUG.

◆ getExpiredLeases6()

void isc::dhcp::Memfile_LeaseMgr::getExpiredLeases6 ( Lease6Collection expired_leases,
const size_t  max_leases 
) const
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.

Implements isc::dhcp::LeaseMgr.

Definition at line 1372 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_EXPIRED6, isc_throw, LOG_DEBUG, persistLeases(), and V4.

+ Here is the call graph for this function:

◆ getLease4() [1/5]

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

Returns existing IPv4 lease for specified IPv4 address.

This function returns a copy of the lease. The modification in the return lease does not affect the instance held in the lease storage.

Parameters
addrAn address of the searched lease.
Returns
a pointer to the lease (or NULL if a lease is not found)

Implements isc::dhcp::LeaseMgr.

Definition at line 782 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_ADDR4, isc::dhcp::HWAddr::hwaddr_, LOG_DEBUG, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ getLease4() [2/5]

Lease4Collection isc::dhcp::Memfile_LeaseMgr::getLease4 ( const isc::dhcp::HWAddr hwaddr) const
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

Implements isc::dhcp::LeaseMgr.

Definition at line 811 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_HWADDR, isc::dhcp::HWAddr::hwaddr_, LOG_DEBUG, and isc::dhcp::HWAddr::toText().

+ Here is the call graph for this function:

◆ getLease4() [3/5]

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

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

This function returns a copy of the lease. The modification in the return lease does not affect the instance held in the lease storage.

There can be at most one lease for a given HW address in a single pool, so this method with 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)

Implements isc::dhcp::LeaseMgr.

Definition at line 845 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID_HWADDR, isc::dhcp::ClientId::getClientId(), LOG_DEBUG, and isc::dhcp::HWAddr::toText().

+ Here is the call graph for this function:

◆ getLease4() [4/5]

Lease4Collection isc::dhcp::Memfile_LeaseMgr::getLease4 ( const ClientId client_id) const
virtual

Returns existing IPv4 lease for specified client-id.

Parameters
client_idclient identifier
Returns
lease collection

Implements isc::dhcp::LeaseMgr.

Definition at line 876 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_CLIENTID, isc::dhcp::ClientId::getClientId(), LOG_DEBUG, and isc::dhcp::ClientId::toText().

+ Here is the call graph for this function:

◆ getLease4() [5/5]

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

Returns existing IPv4 lease for specified client-id.

This function returns a copy of the lease. The modification in the return lease does not affect the instance held in the lease storage.

There can be at most one lease for a given HW address in a single pool, so this method with 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)

Implements isc::dhcp::LeaseMgr.

Definition at line 909 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID_CLIENTID, LOG_DEBUG, and isc::dhcp::ClientId::toText().

+ Here is the call graph for this function:

◆ getLease6()

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

Returns existing IPv6 lease for a given IPv6 address.

This function returns a copy of the lease. The modification in the return lease does not affect the instance held in the lease storage.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 1060 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_ADDR6, isc::dhcp::DUID::getDuid(), LOG_DEBUG, isc::asiolink::IOAddress::toText(), and isc::dhcp::Lease::typeToText().

+ Here is the call graph for this function:

◆ getLeaseFilePath()

std::string isc::dhcp::Memfile_LeaseMgr::getLeaseFilePath ( Universe  u) const

Returns an absolute path to the lease file.

Parameters
uUniverse (V4 or V6).
Returns
Absolute path to the lease file or empty string if no lease file is used.

Definition at line 1727 of file memfile_lease_mgr.cc.

References V4.

◆ getLeases4() [1/4]

Lease4Collection isc::dhcp::Memfile_LeaseMgr::getLeases4 ( SubnetID  subnet_id) const
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).

Implements isc::dhcp::LeaseMgr.

Definition at line 937 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID4, and LOG_DEBUG.

◆ getLeases4() [2/4]

Lease4Collection isc::dhcp::Memfile_LeaseMgr::getLeases4 ( const std::string &  hostname) const
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).

Implements isc::dhcp::LeaseMgr.

Definition at line 966 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_HOSTNAME4, and LOG_DEBUG.

◆ getLeases4() [3/4]

Lease4Collection isc::dhcp::Memfile_LeaseMgr::getLeases4 ( ) const
virtual

Returns all IPv4 leases.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 989 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET4, LOG_DEBUG, and isc::dhcp::LeasePageSize::page_size_.

◆ getLeases4() [4/4]

Lease4Collection isc::dhcp::Memfile_LeaseMgr::getLeases4 ( const asiolink::IOAddress lower_bound_address,
const LeasePageSize page_size 
) const
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).

Implements isc::dhcp::LeaseMgr.

Definition at line 1024 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_PAGE4, isc_throw, isc::asiolink::IOAddress::isV4(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ getLeases6() [1/7]

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

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

Parameters
typespecifies lease type: (NA, TA or PD)
duidclient DUID
iaidIA identifier
Returns
collection of IPv6 leases

Implements isc::dhcp::LeaseMgr.

Definition at line 1094 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_IAID_DUID, isc::dhcp::DUID::getDuid(), LOG_DEBUG, isc::dhcp::DUID::toText(), and isc::dhcp::Lease::typeToText().

+ Here is the call graph for this function:

◆ getLeases6() [2/7]

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

Returns existing IPv6 lease for a given DUID + IA + subnet-id + lease type combination.

This function returns a copy of the lease. The modification in the return lease does not affect the instance held in the lease storage.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 1137 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID, LOG_DEBUG, isc::dhcp::DUID::toText(), and isc::dhcp::Lease::typeToText().

+ Here is the call graph for this function:

◆ getLeases6() [3/7]

Lease6Collection isc::dhcp::Memfile_LeaseMgr::getLeases6 ( SubnetID  subnet_id) const
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).

Implements isc::dhcp::LeaseMgr.

Definition at line 1173 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID6, and LOG_DEBUG.

◆ getLeases6() [4/7]

Lease6Collection isc::dhcp::Memfile_LeaseMgr::getLeases6 ( const std::string &  hostname) const
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).

Implements isc::dhcp::LeaseMgr.

Definition at line 1202 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_HOSTNAME6, and LOG_DEBUG.

◆ getLeases6() [5/7]

Lease6Collection isc::dhcp::Memfile_LeaseMgr::getLeases6 ( ) const
virtual

Returns all IPv6 leases.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 1225 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET6, isc::dhcp::DUID::getDuid(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getLeases6() [6/7]

Lease6Collection isc::dhcp::Memfile_LeaseMgr::getLeases6 ( const DUID duid) const
virtual

Returns IPv6 leases for the DUID.

Parameters
duidclient DUID

Implements isc::dhcp::LeaseMgr.

Definition at line 1253 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET6_DUID, LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, and isc::dhcp::DUID::toText().

+ Here is the call graph for this function:

◆ getLeases6() [7/7]

Lease6Collection isc::dhcp::Memfile_LeaseMgr::getLeases6 ( const asiolink::IOAddress lower_bound_address,
const LeasePageSize page_size 
) const
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).

Implements isc::dhcp::LeaseMgr.

Definition at line 1289 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_PAGE6, isc_throw, isc::asiolink::IOAddress::isV6(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ getLFCExitStatus()

int isc::dhcp::Memfile_LeaseMgr::getLFCExitStatus ( ) const

Returns the status code returned by the last executed LFC process.

Definition at line 1856 of file memfile_lease_mgr.cc.

◆ getName()

virtual std::string isc::dhcp::Memfile_LeaseMgr::getName ( ) const
inlinevirtual

Returns backend name.

For now, memfile can only store data in memory.

Returns
Name of the backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 856 of file memfile_lease_mgr.h.

References commit(), getDescription(), getVersion(), and rollback().

+ Here is the call graph for this function:

◆ getType()

virtual std::string isc::dhcp::Memfile_LeaseMgr::getType ( ) const
inlinevirtual

Return backend type.

Returns the type of the backend.

Returns
Type of the backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 847 of file memfile_lease_mgr.h.

◆ getVersion()

std::pair< uint32_t, uint32_t > isc::dhcp::Memfile_LeaseMgr::getVersion ( ) const
virtual

Returns backend version.

Returns
Version number as a pair of unsigned integers. "first" is the major version number, "second" the minor number.

Implements isc::dhcp::LeaseMgr.

Definition at line 1668 of file memfile_lease_mgr.cc.

References isc::db::DatabaseConnection::getParameter(), isc_throw, MAJOR_VERSION_V4, MAJOR_VERSION_V6, MINOR_VERSION_V4, and MINOR_VERSION_V6.

Referenced by getName(), and Memfile_LeaseMgr().

+ Here is the call graph for this function:

◆ isJsonSupported()

bool isc::dhcp::Memfile_LeaseMgr::isJsonSupported ( ) const
overridevirtual

Checks if JSON support is enabled in the database.

Memfile implementation assumes JSON support is always enabled.

Returns
true if there is JSON support, false otherwise

Implements isc::dhcp::LeaseMgr.

Definition at line 2073 of file memfile_lease_mgr.cc.

◆ isLFCRunning()

bool isc::dhcp::Memfile_LeaseMgr::isLFCRunning ( ) const

Checks if the process performing lease file cleanup is running.

Returns
true if the process performing lease file cleanup is running.

Definition at line 1851 of file memfile_lease_mgr.cc.

◆ lfcCallback()

void isc::dhcp::Memfile_LeaseMgr::lfcCallback ( )
protectedvirtual

A callback function triggering Lease File Cleanup (LFC).

This method is executed periodically to start the lease file cleanup. It checks whether the file is a DHCPv4 lease file or DHCPv6 lease file and executes the Memfile_LeaseMgr::lfcExecute private method with the appropriate parameters.

This method is virtual so as it can be overridden and customized in the unit tests. In particular, the unit test which checks that the callback function has been executed would override this function to increase the execution counter each time it is executed.

Definition at line 1861 of file memfile_lease_mgr.cc.

References appendSuffix(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_LFC_LEASE_FILE_RENAME_FAIL, isc::dhcp::DHCPSRV_MEMFILE_LFC_LEASE_FILE_REOPEN_FAIL, isc::dhcp::DHCPSRV_MEMFILE_LFC_START, isc::util::CSVFile::exists(), FILE_FINISH, FILE_INPUT, isc::util::CSVFile::getFilename(), isc::db::DatabaseConnection::getParameter(), isc_throw, LOG_ERROR, LOG_INFO, and isc::Exception::what().

+ Here is the call graph for this function:

◆ persistLeases()

bool isc::dhcp::Memfile_LeaseMgr::persistLeases ( Universe  u) const

Specifies whether or not leases are written to disk.

It is possible that leases for DHCPv4 are written to disk whereas leases for DHCPv6 are not; or vice versa. The argument of the method specifies the type of lease in that respect.

Parameters
uUniverse (V4 or V6).
Returns
true if leases are written to lease file; if false is returned, leases will be held in memory and will be lost upon server shut down.

Definition at line 1736 of file memfile_lease_mgr.cc.

References appendSuffix(), isc::util::PIDFile::check(), FILE_INPUT, FILE_PID, FILE_PREVIOUS, getDefaultLeaseFilePath(), isc::db::DatabaseConnection::getParameter(), isc_throw, V4, and V6.

Referenced by addLease(), deleteExpiredReclaimedLeases6(), deleteLease(), getDBVersion(), getExpiredLeases6(), Memfile_LeaseMgr(), updateLease4(), and updateLease6().

+ Here is the call graph for this function:

◆ rollback()

void isc::dhcp::Memfile_LeaseMgr::rollback ( )
virtual

Rollback Transactions.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 1684 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_ROLLBACK, and LOG_DEBUG.

Referenced by getName().

◆ startLeaseStatsQuery4()

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

Creates and runs the IPv4 lease stats query.

It creates an instance of a MemfileLeaseStatsQuery4 for an all subnets query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.

Returns
The populated query as a pointer to an LeaseStatsQuery

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 1959 of file memfile_lease_mgr.cc.

◆ startLeaseStatsQuery6()

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

Creates and runs the IPv6 lease stats query.

It creates an instance of a MemfileLeaseStatsQuery6 and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.

Returns
The populated query as a pointer to an LeaseStatsQuery.

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 1982 of file memfile_lease_mgr.cc.

◆ startSubnetLeaseStatsQuery4()

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

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

It creates an instance of a MemfileLeaseStatsQuery4 for a single subnet query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.

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

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 1966 of file memfile_lease_mgr.cc.

◆ startSubnetLeaseStatsQuery6()

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

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

It creates an instance of a MemfileLeaseStatsQuery6 for a single subnet query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.

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

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 1989 of file memfile_lease_mgr.cc.

◆ startSubnetRangeLeaseStatsQuery4()

LeaseStatsQueryPtr isc::dhcp::Memfile_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.

It creates an instance of a MemfileLeaseStatsQuery4 for a subnet range query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.

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

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 1973 of file memfile_lease_mgr.cc.

◆ startSubnetRangeLeaseStatsQuery6()

LeaseStatsQueryPtr isc::dhcp::Memfile_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.

It creates an instance of a MemfileLeaseStatsQuery6 for a subnet range query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.

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

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 1996 of file memfile_lease_mgr.cc.

◆ updateLease4()

void isc::dhcp::Memfile_LeaseMgr::updateLease4 ( const Lease4Ptr lease4)
virtual

Updates IPv4 lease.

Warning
This function does not validate the pointer to the lease. It is caller's responsibility to pass the valid pointer.
Parameters
lease4The lease to be updated.
Exceptions
NoSuchLeaseif there is no such lease to be updated.
Note
The current_cltt_ and current_valid_lft_ are used to maximize the chance that only one thread or process performs an update or delete operation on the lease by matching these values with the expiration time data in the database.
For test purposes only, when persistence is disabled, the update of the lease is performed only if the value matches the one received on the SELECT query, effectively enforcing no update on the lease between SELECT and UPDATE with different expiration time.

Implements isc::dhcp::LeaseMgr.

Definition at line 1420 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_UPDATE_ADDR4, isc_throw, LOG_DEBUG, persistLeases(), and V6.

+ Here is the call graph for this function:

◆ updateLease6()

void isc::dhcp::Memfile_LeaseMgr::updateLease6 ( const Lease6Ptr lease6)
virtual

Updates IPv6 lease.

Warning
This function does not validate the pointer to the lease. It is caller's responsibility to pass the valid pointer.
Parameters
lease6The lease to be updated.
Exceptions
NoSuchLeaseif there is no such lease to be updated.
Note
The current_cltt_ and current_valid_lft_ are used to maximize the chance that only one thread or process performs an update or delete operation on the lease by matching these values with the expiration time data in the database.
For test purposes only, when persistence is disabled, the update of the lease is performed only if the value matches the one received on the SELECT query, effectively enforcing no update on the lease between SELECT and UPDATE with different expiration time.

Implements isc::dhcp::LeaseMgr.

Definition at line 1467 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_UPDATE_ADDR6, LOG_DEBUG, persistLeases(), V4, and isc::dhcp::Lease::valid_lft_.

+ Here is the call graph for this function:

◆ wipeLeases4()

size_t isc::dhcp::Memfile_LeaseMgr::wipeLeases4 ( const SubnetID subnet_id)
virtual

Removes specified IPv4 leases.

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

Parameters
subnet_ididentifier of the subnet
Returns
number of leases removed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2005 of file memfile_lease_mgr.cc.

References deleteLease(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_WIPE_LEASES4, isc::dhcp::DHCPSRV_MEMFILE_WIPE_LEASES4_FINISHED, and LOG_INFO.

+ Here is the call graph for this function:

◆ wipeLeases6()

size_t isc::dhcp::Memfile_LeaseMgr::wipeLeases6 ( const SubnetID subnet_id)
virtual

Removed specified IPv6 leases.

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

Parameters
subnet_ididentifier of the subnet
Returns
number of leases removed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2034 of file memfile_lease_mgr.cc.

References deleteLease(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_WIPE_LEASES6, isc::dhcp::DHCPSRV_MEMFILE_WIPE_LEASES6_FINISHED, and LOG_INFO.

+ Here is the call graph for this function:

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