Kea 2.6.0
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 Types inherited from isc::dhcp::TrackingLeaseMgr
typedef std::function< void(LeasePtr)> CallbackFn
 Type of a callback function invoked upon a lease insertion, update or deletion.
 
enum  CallbackType { TRACK_ADD_LEASE , TRACK_UPDATE_LEASE , TRACK_DELETE_LEASE }
 An enumeration differentiating between lease write operations. More...
 

Public Member Functions

virtual void commit () override
 Commit Transactions.
 
virtual std::string getDescription () const override
 Returns description of the backend.
 
virtual std::string getName () const override
 Returns backend name.
 
virtual std::string getType () const override
 Return backend type.
 
virtual std::pair< uint32_t, uint32_t > getVersion (const std::string &timer_name=std::string()) const override
 Returns backend version.
 
virtual void rollback () override
 Rollback Transactions.
 
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.
 
int getLFCExitStatus () const
 Returns the status code returned by the last executed LFC process.
 
virtual LeaseStatsQueryPtr startLeaseStatsQuery4 () override
 Creates and runs the IPv4 lease stats query.
 
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery4 () override
 Creates and runs the IPv4 lease stats query for all subnets and pools.
 
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4 (const SubnetID &subnet_id) override
 Creates and runs the IPv4 lease stats query for a single subnet.
 
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4 (const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) override
 Creates and runs the IPv4 lease stats query for a single subnet.
 
virtual LeaseStatsQueryPtr startLeaseStatsQuery6 () override
 Creates and runs the IPv6 lease stats query.
 
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery6 () override
 Creates and runs the IPv6 lease stats query for all subnets and pools.
 
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6 (const SubnetID &subnet_id) override
 Creates and runs the IPv6 lease stats query for a single subnet.
 
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6 (const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) override
 Creates and runs the IPv6 lease stats query for a single subnet.
 
- Public Member Functions inherited from isc::dhcp::TrackingLeaseMgr
bool hasCallbacks () const
 Checks if any callbacks have been registered.
 
bool isLocked (const LeasePtr &lease)
 Checks if the lease is locked.
 
void registerCallback (CallbackType type, std::string owner, Lease::Type lease_type, CallbackFn callback_fn)
 Registers a callback function for all subnets.
 
void registerCallback (CallbackType type, std::string owner, SubnetID subnet_id, Lease::Type lease_type, CallbackFn callback_fn)
 Registers a callback function for a subnet.
 
void unregisterAllCallbacks ()
 Unregisters all callbacks.
 
void unregisterCallbacks (SubnetID subnet_id, Lease::Type lease_type)
 Unregisters all callbacks for a given subnet identifier.
 
- Public Member Functions inherited from isc::dhcp::LeaseMgr
 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 Attributes

static const int MAJOR_VERSION_V4 = 3
 
static const int MAJOR_VERSION_V6 = 5
 
static const int MINOR_VERSION_V4 = 0
 the minor version of the v4 memfile backend
 
static const int MINOR_VERSION_V6 = 0
 the minor version of the v6 memfile backend
 

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).
 
- Protected Member Functions inherited from isc::dhcp::TrackingLeaseMgr
 TrackingLeaseMgr ()
 Constructor.
 
void runCallbacks (CallbackType type, const LeasePtr &lease)
 Runs registered callbacks of the particular type.
 
void runCallbacksForSubnetID (CallbackType type, SubnetID subnet_id, const LeasePtr &lease)
 Runs registered callbacks of the particular type for a subnet id.
 
void trackAddLease (const LeasePtr &lease)
 Invokes the callbacks when a new lease is added.
 
void trackDeleteLease (const LeasePtr &lease)
 Invokes the callbacks when a lease is deleted.
 
void trackUpdateLease (const LeasePtr &lease)
 Invokes the callbacks when a lease is updated.
 
bool tryLock (const LeasePtr &lease)
 Attempts to lock a lease.
 
void unlock (const LeasePtr &lease)
 Attempts to unlock a lease.
 
- Protected Member Functions inherited from isc::dhcp::LeaseMgr
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.
 

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.
 

Miscellaneous public convenience methods.

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

Lease6ExtendedInfoRelayIdTable relay_id6_
 stores IPv6 by-relay-id cross-reference table
 
Lease6ExtendedInfoRemoteIdTable remote_id6_
 stores IPv6 by-remote-id cross-reference table
 
boost::shared_ptr< CSVLeaseFile4lease_file4_
 Holds the pointer to the DHCPv4 lease file IO.
 
boost::shared_ptr< CSVLeaseFile6lease_file6_
 Holds the pointer to the DHCPv6 lease file IO.
 
std::string getDefaultLeaseFilePath (Universe u) const
 Returns default path to the lease file.
 
std::string getLeaseFilePath (Universe u) const
 Returns an absolute path to the lease file.
 
bool persistLeases (Universe u) const
 Specifies whether or not leases are written to disk.
 

Private methods and members used for Lease File Cleanup.

virtual size_t getClassLeaseCount (const ClientClass &client_class, const Lease::Type &ltype=Lease::TYPE_V4) const override
 Returns the class lease count for a given class and lease type.
 
virtual void recountClassLeases4 () override
 Recount the leases per class for V4 leases.
 
virtual void recountClassLeases6 () override
 Recount the leases per class for V6 leases.
 
virtual void clearClassLeaseCounts () override
 Clears the class-lease count map.
 
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) override
 The following queries are used to fulfill Bulk Lease Query queries.
 
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) override
 Returns existing IPv4 leases with a given remote-id.
 
virtual Lease6Collection getLeases6ByRelayId (const DUID &relay_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) override
 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) override
 Returns existing IPv6 leases with a given remote-id.
 
size_t extractExtendedInfo4 (bool update, bool current)
 Extract extended info for v4 leases.
 
virtual size_t upgradeExtendedInfo6 (const LeasePageSize &page_size) override
 Upgrade extended info (v6).
 
virtual void wipeExtendedInfoTables6 () override
 Wipe extended info table (v6).
 
virtual size_t byRelayId6size () const override
 Return the by-relay-id table size.
 
virtual size_t byRemoteId6size () const override
 Return the by-remote-id table size.
 
virtual void writeLeases4 (const std::string &filename) override
 Write V4 leases to a file.
 
virtual void writeLeases6 (const std::string &filename) override
 Write V6 leases to a file.
 
virtual size_t upgradeExtendedInfo4 (const LeasePageSize &page_size) override
 Upgrade extended info (v4).
 
void buildExtendedInfoTables6 ()
 Extended information / Bulk Lease Query shared interface.
 
virtual void deleteExtendedInfo6 (const isc::asiolink::IOAddress &addr) override
 Delete lease6 extended info from tables.
 
virtual void addRelayId6 (const isc::asiolink::IOAddress &lease_addr, const std::vector< uint8_t > &relay_id) override
 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) override
 Add lease6 extended info into by-remote-id table.
 

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

Additional Inherited Members

- Static Public Member Functions inherited from isc::dhcp::LeaseMgr
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 Types inherited from isc::dhcp::TrackingLeaseMgr
typedef boost::multi_index_container< Callback, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::composite_key< Callback, boost::multi_index::member< Callback, CallbackType, &Callback::type >, boost::multi_index::member< Callback, SubnetID, &Callback::subnet_id >, boost::multi_index::member< Callback, Lease::Type, &Callback::lease_type > > >, boost::multi_index::ordered_non_unique< boost::multi_index::composite_key< Callback, boost::multi_index::member< Callback, SubnetID, &Callback::subnet_id >, boost::multi_index::member< Callback, Lease::Type, &Callback::lease_type > > > > > CallbackContainer
 A multi-index container holding registered callbacks.
 
typedef boost::shared_ptr< CallbackContainerCallbackContainerPtr
 Pointer to the callback container.
 
- Static Protected Member Functions inherited from isc::dhcp::TrackingLeaseMgr
static std::string callbackTypeToString (CallbackType type)
 Converts callback type to string for logging purposes.
 
- Protected Attributes inherited from isc::dhcp::TrackingLeaseMgr
CallbackContainerPtr callbacks_
 The multi-index container holding registered callbacks.
 
std::unordered_set< asiolink::IOAddress, asiolink::IOAddress::Hashlocked_leases_
 A set of locked leases.
 

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 80 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 953 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 124 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 975 of file memfile_lease_mgr.cc.

References buildExtendedInfoTables6(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_CONVERTING_LEASE_FILES, isc::dhcp::DHCPSRV_MEMFILE_NO_STORAGE, extractExtendedInfo4(), isc::db::DatabaseConnection::getParameter(), getVersion(), lease_file4_, lease_file6_, LOG_WARN, persistLeases(), isc::dhcp::LeaseMgr::setExtendedInfoTablesEnabled(), 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 1020 of file memfile_lease_mgr.cc.

References lease_file4_, and lease_file6_.

Member Function Documentation

◆ addLease() [1/2]

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

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 1075 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_ADD_ADDR4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ addLease() [2/2]

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

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 1124 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_ADD_ADDR6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ addRelayId6()

void isc::dhcp::Memfile_LeaseMgr::addRelayId6 ( const isc::asiolink::IOAddress lease_addr,
const std::vector< uint8_t > &  relay_id 
)
overrideprotectedvirtual

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.

Implements isc::dhcp::LeaseMgr.

Definition at line 3362 of file memfile_lease_mgr.cc.

References relay_id6_.

◆ addRemoteId6()

void isc::dhcp::Memfile_LeaseMgr::addRemoteId6 ( const isc::asiolink::IOAddress lease_addr,
const std::vector< uint8_t > &  remote_id 
)
overrideprotectedvirtual

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.

Implements isc::dhcp::LeaseMgr.

Definition at line 3370 of file memfile_lease_mgr.cc.

References remote_id6_.

◆ 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 2195 of file memfile_lease_mgr.cc.

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

Referenced by isc::dhcp::LFCSetup::setup().

◆ buildExtendedInfoTables6()

◆ byRelayId6size()

size_t isc::dhcp::Memfile_LeaseMgr::byRelayId6size ( ) const
overridevirtual

Return the by-relay-id table size.

Returns
The size of the by-relay-id table.

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 3100 of file memfile_lease_mgr.cc.

References relay_id6_.

◆ byRemoteId6size()

size_t isc::dhcp::Memfile_LeaseMgr::byRemoteId6size ( ) const
overridevirtual

Return the by-remote-id table size.

Returns
The size of the by-remote-id table.

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 3105 of file memfile_lease_mgr.cc.

References remote_id6_.

◆ 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 2674 of file memfile_lease_mgr.cc.

References getClassLeaseCount(), isc_throw, isc::data::prettyPrint(), and isc::dhcp::Lease::TYPE_V4.

+ Here is the call graph for this function:

◆ 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 2760 of file memfile_lease_mgr.cc.

References getClassLeaseCount(), isc_throw, isc::data::prettyPrint(), isc::dhcp::Lease::TYPE_NA, and isc::dhcp::Lease::TYPE_PD.

+ Here is the call graph for this function:

◆ clearClassLeaseCounts()

void isc::dhcp::Memfile_LeaseMgr::clearClassLeaseCounts ( )
overridevirtual

Clears the class-lease count map.

Must be called from a thread-safe context.

Implements isc::dhcp::LeaseMgr.

Definition at line 2669 of file memfile_lease_mgr.cc.

References isc::dhcp::ClassLeaseCounter::clear().

+ Here is the call graph for this function:

◆ commit()

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

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 2184 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.

◆ deleteExpiredReclaimedLeases4()

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

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 2069 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED4, isc::util::MultiThreadingMgr::instance(), lease_file4_, LOG_DEBUG, and V4.

+ Here is the call graph for this function:

◆ deleteExpiredReclaimedLeases6()

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

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 2087 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::util::MultiThreadingMgr::instance(), lease_file6_, LOG_DEBUG, and V6.

+ Here is the call graph for this function:

◆ deleteExtendedInfo6()

void isc::dhcp::Memfile_LeaseMgr::deleteExtendedInfo6 ( const isc::asiolink::IOAddress addr)
overrideprotectedvirtual

Delete lease6 extended info from tables.

Parameters
addrThe address of the lease.

Implements isc::dhcp::LeaseMgr.

Definition at line 3352 of file memfile_lease_mgr.cc.

References relay_id6_, and remote_id6_.

◆ deleteLease() [1/2]

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

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 1997 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_ADDR, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

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)
overridevirtual

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 2056 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_ADDR, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ extractExtendedInfo4()

size_t isc::dhcp::Memfile_LeaseMgr::extractExtendedInfo4 ( bool  update,
bool  current 
)

Extract extended info for v4 leases.

For v4 relay and remote identifiers are stored inside leases vs. tables for v6.

Parameters
updateUpdate extended info in database.
currentspecify whether to use current (true) or staging (false) config.
Returns
The number of updates in the database or 0.

Definition at line 3231 of file memfile_lease_mgr.cc.

References isc::data::copy(), isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_BEGIN_EXTRACT_EXTENDED_INFO4, isc::dhcp::DHCPSRV_MEMFILE_EXTRACT_EXTENDED_INFO4, isc::dhcp::DHCPSRV_MEMFILE_EXTRACT_EXTENDED_INFO4_ERROR, isc::dhcp::LeaseMgr::extractLease4ExtendedInfo(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::getStagingCfg(), isc::dhcp::CfgMgr::instance(), isc_throw, lease_file4_, LOG_DEBUG, LOG_INFO, persistLeases(), isc::dhcp::CfgConsistency::sanityCheckToText(), isc::dhcp::LeaseMgr::upgradeLease4ExtendedInfo(), and V4.

Referenced by Memfile_LeaseMgr().

+ Here is the call graph for this function:

◆ getClassLeaseCount()

size_t isc::dhcp::Memfile_LeaseMgr::getClassLeaseCount ( const ClientClass client_class,
const Lease::Type ltype = Lease::TYPE_V4 
) const
overridevirtual

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

Implements isc::dhcp::LeaseMgr.

Definition at line 2658 of file memfile_lease_mgr.cc.

References isc::dhcp::ClassLeaseCounter::getClassCount(), and isc::util::MultiThreadingMgr::instance().

Referenced by checkLimits4(), and checkLimits6().

+ Here is the call graph for this function:

◆ getDBVersion()

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

Local version of getDBVersion() class method.

Definition at line 1032 of file memfile_lease_mgr.cc.

References MAJOR_VERSION_V4, MAJOR_VERSION_V6, MINOR_VERSION_V4, MINOR_VERSION_V6, V4, and V6.

◆ 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 2223 of file memfile_lease_mgr.cc.

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

+ Here is the call graph for this function:

◆ getDescription()

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

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 2168 of file memfile_lease_mgr.cc.

◆ getExpiredLeases4()

void isc::dhcp::Memfile_LeaseMgr::getExpiredLeases4 ( Lease4Collection expired_leases,
const size_t  max_leases 
) const
overridevirtual

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 1769 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_EXPIRED4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getExpiredLeases6()

void isc::dhcp::Memfile_LeaseMgr::getExpiredLeases6 ( Lease6Collection expired_leases,
const size_t  max_leases 
) const
overridevirtual

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 1805 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_EXPIRED6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getLease4() [1/5]

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

Returns existing IPv4 lease for specified client-id.

Parameters
client_idclient identifier
Returns
lease collection

Implements isc::dhcp::LeaseMgr.

Definition at line 1242 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_CLIENTID, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, and isc::dhcp::IdentifierType< min_size, max_size >::toText().

+ Here is the call graph for this function:

◆ getLease4() [2/5]

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

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 1275 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID_CLIENTID, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, and isc::dhcp::IdentifierType< min_size, max_size >::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
overridevirtual

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 1211 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::util::MultiThreadingMgr::instance(), LOG_DEBUG, and isc::dhcp::HWAddr::toText().

+ Here is the call graph for this function:

◆ getLease4() [4/5]

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

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 1148 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_ADDR4, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ getLease4() [5/5]

Lease4Collection isc::dhcp::Memfile_LeaseMgr::getLease4 ( const isc::dhcp::HWAddr hwaddr) const
overridevirtual

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 1177 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_HWADDR, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, and isc::dhcp::HWAddr::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
overridevirtual

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 1436 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_ADDR6, isc::util::MultiThreadingMgr::instance(), 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 2232 of file memfile_lease_mgr.cc.

References lease_file4_, lease_file6_, and V4.

◆ getLeases4() [1/4]

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

Returns all IPv4 leases.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 1355 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getLeases4() [2/4]

Lease4Collection isc::dhcp::Memfile_LeaseMgr::getLeases4 ( const asiolink::IOAddress lower_bound_address,
const LeasePageSize page_size 
) const
overridevirtual

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 1390 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_PAGE4, isc::util::MultiThreadingMgr::instance(), 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:

◆ getLeases4() [3/4]

Lease4Collection isc::dhcp::Memfile_LeaseMgr::getLeases4 ( const std::string &  hostname) const
overridevirtual

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 1332 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_HOSTNAME4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getLeases4() [4/4]

Lease4Collection isc::dhcp::Memfile_LeaseMgr::getLeases4 ( SubnetID  subnet_id) const
overridevirtual

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 1303 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getLeases4ByRelayId()

Lease4Collection isc::dhcp::Memfile_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 
)
overridevirtual

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.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 2916 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_RELAYID4, isc::util::MultiThreadingMgr::instance(), 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:

◆ getLeases4ByRemoteId()

Lease4Collection isc::dhcp::Memfile_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 
)
overridevirtual

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

Implements isc::dhcp::LeaseMgr.

Definition at line 3002 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_REMOTEID4, isc::util::MultiThreadingMgr::instance(), 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/8]

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

Returns all IPv6 leases.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 1601 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getLeases6() [2/8]

Lease6Collection isc::dhcp::Memfile_LeaseMgr::getLeases6 ( const asiolink::IOAddress lower_bound_address,
const LeasePageSize page_size 
) const
overridevirtual

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 1665 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_PAGE6, isc::util::MultiThreadingMgr::instance(), 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:

◆ getLeases6() [3/8]

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

◆ getLeases6() [4/8]

Lease6Collection isc::dhcp::Memfile_LeaseMgr::getLeases6 ( const std::string &  hostname) const
overridevirtual

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 1578 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_HOSTNAME6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getLeases6() [5/8]

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

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 1470 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::util::MultiThreadingMgr::instance(), LOG_DEBUG, isc::dhcp::IdentifierType< min_size, max_size >::toText(), and isc::dhcp::Lease::typeToText().

+ Here is the call graph for this function:

◆ getLeases6() [6/8]

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

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 1513 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, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, isc::dhcp::IdentifierType< min_size, max_size >::toText(), and isc::dhcp::Lease::typeToText().

+ Here is the call graph for this function:

◆ getLeases6() [7/8]

Lease6Collection isc::dhcp::Memfile_LeaseMgr::getLeases6 ( SubnetID  subnet_id) const
overridevirtual

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 1549 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getLeases6() [8/8]

Lease6Collection isc::dhcp::Memfile_LeaseMgr::getLeases6 ( SubnetID  subnet_id,
const asiolink::IOAddress lower_bound_address,
const LeasePageSize page_size 
) const
overridevirtual

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

Implements isc::dhcp::LeaseMgr.

Definition at line 1718 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID_PAGE6, isc::util::MultiThreadingMgr::instance(), 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:

◆ getLeases6ByRelayId()

Lease6Collection isc::dhcp::Memfile_LeaseMgr::getLeases6ByRelayId ( const DUID relay_id,
const asiolink::IOAddress lower_bound_address,
const LeasePageSize page_size 
)
overridevirtual

Returns existing IPv6 leases with a given relay-id.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 3110 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_RELAYID6, isc::util::MultiThreadingMgr::instance(), isc_throw, isc::asiolink::IOAddress::isV6(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, isc::asiolink::IOAddress::toText(), and isc::dhcp::IdentifierType< min_size, max_size >::toText().

+ Here is the call graph for this function:

◆ getLeases6ByRemoteId()

Lease6Collection isc::dhcp::Memfile_LeaseMgr::getLeases6ByRemoteId ( const OptionBuffer remote_id,
const asiolink::IOAddress lower_bound_address,
const LeasePageSize page_size 
)
overridevirtual

Returns existing IPv6 leases with a given remote-id.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 3172 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_REMOTEID6, isc::util::MultiThreadingMgr::instance(), 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 2367 of file memfile_lease_mgr.cc.

◆ getName()

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

Returns backend name.

For now, memfile can only store data in memory.

Returns
Name of the backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 914 of file memfile_lease_mgr.h.

◆ getType()

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

Return backend type.

Returns the type of the backend.

Returns
Type of the backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 905 of file memfile_lease_mgr.h.

◆ getVersion()

std::pair< uint32_t, uint32_t > isc::dhcp::Memfile_LeaseMgr::getVersion ( const std::string &  timer_name = std::string()) const
overridevirtual

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.

Implements isc::dhcp::LeaseMgr.

Definition at line 2173 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 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 2861 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 2362 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 2372 of file memfile_lease_mgr.cc.

References isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_LFC_START, lease_file4_, lease_file6_, and LOG_INFO.

◆ 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 2241 of file memfile_lease_mgr.cc.

References lease_file4_, lease_file6_, V4, and V6.

Referenced by Memfile_LeaseMgr(), and extractExtendedInfo4().

◆ recountClassLeases4()

void isc::dhcp::Memfile_LeaseMgr::recountClassLeases4 ( )
overridevirtual

Recount the leases per class for V4 leases.

Clears the current class-lease count map and then iterates over all, retabulating counts based on class lists in each lease user-context.

Must be called from a thread-safe context.

Implements isc::dhcp::LeaseMgr.

Definition at line 2636 of file memfile_lease_mgr.cc.

References isc::dhcp::ClassLeaseCounter::addLease(), isc::dhcp::ClassLeaseCounter::clear(), and isc::dhcp::Lease::STATE_DEFAULT.

+ Here is the call graph for this function:

◆ recountClassLeases6()

void isc::dhcp::Memfile_LeaseMgr::recountClassLeases6 ( )
overridevirtual

Recount the leases per class for V6 leases.

Clears the current class-lease count map and then iterates over all, retabulating counts based on class lists in each lease user-context.

Must be called from a thread-safe context.

Implements isc::dhcp::LeaseMgr.

Definition at line 2647 of file memfile_lease_mgr.cc.

References isc::dhcp::ClassLeaseCounter::addLease(), isc::dhcp::ClassLeaseCounter::clear(), and isc::dhcp::Lease::STATE_DEFAULT.

+ Here is the call graph for this function:

◆ rollback()

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

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 2189 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.

◆ startLeaseStatsQuery4()

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

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 2470 of file memfile_lease_mgr.cc.

References isc::util::MultiThreadingMgr::instance().

+ Here is the call graph for this function:

◆ startLeaseStatsQuery6()

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

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 2524 of file memfile_lease_mgr.cc.

References isc::util::MultiThreadingMgr::instance().

+ Here is the call graph for this function:

◆ startPoolLeaseStatsQuery4()

LeaseStatsQueryPtr isc::dhcp::Memfile_LeaseMgr::startPoolLeaseStatsQuery4 ( )
overridevirtual

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 from isc::dhcp::LeaseMgr.

Definition at line 2483 of file memfile_lease_mgr.cc.

References isc::dhcp::LeaseStatsQuery::ALL_SUBNET_POOLS, and isc::util::MultiThreadingMgr::instance().

+ Here is the call graph for this function:

◆ startPoolLeaseStatsQuery6()

LeaseStatsQueryPtr isc::dhcp::Memfile_LeaseMgr::startPoolLeaseStatsQuery6 ( )
overridevirtual

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 from isc::dhcp::LeaseMgr.

Definition at line 2537 of file memfile_lease_mgr.cc.

References isc::dhcp::LeaseStatsQuery::ALL_SUBNET_POOLS, and isc::util::MultiThreadingMgr::instance().

+ Here is the call graph for this function:

◆ startSubnetLeaseStatsQuery4()

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

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 2496 of file memfile_lease_mgr.cc.

References isc::util::MultiThreadingMgr::instance().

+ Here is the call graph for this function:

◆ startSubnetLeaseStatsQuery6()

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

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 2550 of file memfile_lease_mgr.cc.

References isc::util::MultiThreadingMgr::instance().

+ Here is the call graph for this function:

◆ startSubnetRangeLeaseStatsQuery4()

LeaseStatsQueryPtr isc::dhcp::Memfile_LeaseMgr::startSubnetRangeLeaseStatsQuery4 ( const SubnetID first_subnet_id,
const SubnetID last_subnet_id 
)
overridevirtual

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 2509 of file memfile_lease_mgr.cc.

References isc::util::MultiThreadingMgr::instance().

+ Here is the call graph for this function:

◆ startSubnetRangeLeaseStatsQuery6()

LeaseStatsQueryPtr isc::dhcp::Memfile_LeaseMgr::startSubnetRangeLeaseStatsQuery6 ( const SubnetID first_subnet_id,
const SubnetID last_subnet_id 
)
overridevirtual

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 2563 of file memfile_lease_mgr.cc.

References isc::util::MultiThreadingMgr::instance().

+ Here is the call graph for this function:

◆ updateLease4()

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

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 1865 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_UPDATE_ADDR4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ updateLease6()

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

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 1945 of file memfile_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_UPDATE_ADDR6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ upgradeExtendedInfo4()

size_t isc::dhcp::Memfile_LeaseMgr::upgradeExtendedInfo4 ( const LeasePageSize page_size)
overridevirtual

Upgrade extended info (v4).

Parameters
page_sizeThe page size used for retrieval.
Returns
Always return 0 as this function is a noop for not SQL backends.

Implements isc::dhcp::LeaseMgr.

Definition at line 3295 of file memfile_lease_mgr.cc.

◆ upgradeExtendedInfo6()

size_t isc::dhcp::Memfile_LeaseMgr::upgradeExtendedInfo6 ( const LeasePageSize page_size)
overridevirtual

Upgrade extended info (v6).

Parameters
page_sizeThe page size used for retrieval.
Returns
Always return 0 as this function is a noop for not SQL backends.

Implements isc::dhcp::LeaseMgr.

Definition at line 3347 of file memfile_lease_mgr.cc.

◆ wipeExtendedInfoTables6()

void isc::dhcp::Memfile_LeaseMgr::wipeExtendedInfoTables6 ( )
overridevirtual

Wipe extended info table (v6).

Implements isc::dhcp::LeaseMgr.

Definition at line 3088 of file memfile_lease_mgr.cc.

References isc::util::MultiThreadingMgr::instance(), relay_id6_, and remote_id6_.

+ Here is the call graph for this function:

◆ wipeLeases4()

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

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 2578 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)
overridevirtual

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 2607 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:

◆ writeLeases4()

void isc::dhcp::Memfile_LeaseMgr::writeLeases4 ( const std::string &  filename)
overridevirtual

Write V4 leases to a file.

Parameters
filenameFile name to write leases.

Implements isc::dhcp::LeaseMgr.

Definition at line 3378 of file memfile_lease_mgr.cc.

References isc::util::MultiThreadingMgr::instance().

+ Here is the call graph for this function:

◆ writeLeases6()

void isc::dhcp::Memfile_LeaseMgr::writeLeases6 ( const std::string &  filename)
overridevirtual

Write V6 leases to a file.

Parameters
filenameFile name to write leases.

Implements isc::dhcp::LeaseMgr.

Definition at line 3415 of file memfile_lease_mgr.cc.

References isc::util::MultiThreadingMgr::instance().

+ Here is the call graph for this function:

Member Data Documentation

◆ lease_file4_

boost::shared_ptr<CSVLeaseFile4> isc::dhcp::Memfile_LeaseMgr::lease_file4_
protected

Holds the pointer to the DHCPv4 lease file IO.

Definition at line 1113 of file memfile_lease_mgr.h.

Referenced by Memfile_LeaseMgr(), ~Memfile_LeaseMgr(), deleteExpiredReclaimedLeases4(), extractExtendedInfo4(), getLeaseFilePath(), lfcCallback(), and persistLeases().

◆ lease_file6_

boost::shared_ptr<CSVLeaseFile6> isc::dhcp::Memfile_LeaseMgr::lease_file6_
protected

Holds the pointer to the DHCPv6 lease file IO.

Definition at line 1116 of file memfile_lease_mgr.h.

Referenced by Memfile_LeaseMgr(), ~Memfile_LeaseMgr(), deleteExpiredReclaimedLeases6(), getLeaseFilePath(), lfcCallback(), and persistLeases().

◆ relay_id6_

Lease6ExtendedInfoRelayIdTable isc::dhcp::Memfile_LeaseMgr::relay_id6_
protected

stores IPv6 by-relay-id cross-reference table

Definition at line 1107 of file memfile_lease_mgr.h.

Referenced by addRelayId6(), buildExtendedInfoTables6(), byRelayId6size(), deleteExtendedInfo6(), and wipeExtendedInfoTables6().

◆ remote_id6_

Lease6ExtendedInfoRemoteIdTable isc::dhcp::Memfile_LeaseMgr::remote_id6_
protected

stores IPv6 by-remote-id cross-reference table

Definition at line 1110 of file memfile_lease_mgr.h.

Referenced by addRemoteId6(), buildExtendedInfoTables6(), byRemoteId6size(), deleteExtendedInfo6(), and wipeExtendedInfoTables6().


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