Kea 2.6.0
isc::dhcp::PgSqlLeaseMgr Class Reference

PostgreSQL Lease Manager. More...

#include <pgsql_lease_mgr.h>

+ Inheritance diagram for isc::dhcp::PgSqlLeaseMgr:

Public Types

enum  StatementIndex {
  DELETE_LEASE4 , DELETE_LEASE4_STATE_EXPIRED , DELETE_LEASE6 , DELETE_LEASE6_STATE_EXPIRED ,
  GET_LEASE4 , GET_LEASE4_ADDR , GET_LEASE4_CLIENTID , GET_LEASE4_CLIENTID_SUBID ,
  GET_LEASE4_HWADDR , GET_LEASE4_HWADDR_SUBID , GET_LEASE4_PAGE , GET_LEASE4_UCTX_PAGE ,
  GET_LEASE4_SUBID , GET_LEASE4_HOSTNAME , GET_LEASE4_EXPIRE , GET_LEASE4_RELAYID ,
  GET_LEASE4_RELAYID_QST , GET_LEASE4_RELAYID_QSET , GET_LEASE4_RELAYID_QET , GET_LEASE4_REMOTEID ,
  GET_LEASE4_REMOTEID_QST , GET_LEASE4_REMOTEID_QSET , GET_LEASE4_REMOTEID_QET , GET_LEASE6 ,
  GET_LEASE6_ADDR , GET_LEASE6_DUID_IAID , GET_LEASE6_DUID_IAID_SUBID , GET_LEASE6_PAGE ,
  GET_LEASE6_UCTX_PAGE , GET_LEASE6_SUBID , GET_LEASE6_SUBID_PAGE , GET_LEASE6_DUID ,
  GET_LEASE6_HOSTNAME , GET_LEASE6_EXPIRE , INSERT_LEASE4 , INSERT_LEASE6 ,
  UPDATE_LEASE4 , UPDATE_LEASE6 , ALL_LEASE4_STATS , SUBNET_LEASE4_STATS ,
  SUBNET_RANGE_LEASE4_STATS , ALL_POOL_LEASE4_STATS , ALL_LEASE6_STATS , SUBNET_LEASE6_STATS ,
  SUBNET_RANGE_LEASE6_STATS , ALL_POOL_LEASE6_STATS , CHECK_LEASE4_LIMITS , CHECK_LEASE6_LIMITS ,
  IS_JSON_SUPPORTED , GET_LEASE4_COUNT_BY_CLASS , GET_LEASE6_COUNT_BY_CLASS , WIPE_RELAY_ID6 ,
  WIPE_REMOTE_ID6 , DELETE_RELAY_ID6 , DELETE_REMOTE_ID6 , ADD_RELAY_ID6 ,
  ADD_REMOTE_ID6 , GET_RELAY_ID6 , GET_REMOTE_ID6 , COUNT_RELAY_ID6 ,
  COUNT_REMOTE_ID6 , NUM_STATEMENTS
}
 Statement Tags. 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

 PgSqlLeaseMgr (const db::DatabaseConnection::ParameterMap &parameters)
 Constructor.
 
virtual ~PgSqlLeaseMgr ()
 Destructor (closes database)
 
virtual bool addLease (const Lease4Ptr &lease) override
 Adds an IPv4 lease.
 
virtual bool addLease (const Lease6Ptr &lease) override
 Adds an IPv6 lease.
 
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 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 void clearClassLeaseCounts () override
 Clears the class-lease count map.
 
virtual void commit () override
 Commit Transactions.
 
PgSqlLeaseContextPtr createContext () const
 Create a new context.
 
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 bool deleteLease (const Lease4Ptr &lease) override
 Deletes an IPv4 lease.
 
virtual bool deleteLease (const Lease6Ptr &lease) override
 Deletes an IPv6 lease.
 
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 std::string getDescription () const override
 Returns description of the backend.
 
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 Lease4Collection getLease4 (const ClientId &clientid) const override
 Returns existing IPv4 leases for specified client-id.
 
virtual Lease4Ptr getLease4 (const ClientId &clientid, SubnetID subnet_id) const override
 Returns existing IPv4 lease for specified client-id.
 
virtual Lease4Ptr getLease4 (const isc::asiolink::IOAddress &addr) const override
 Returns an 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 isc::dhcp::HWAddr &hwaddr, SubnetID subnet_id) const override
 Returns existing IPv4 leases for specified hardware address and a subnet.
 
virtual Lease6Ptr getLease6 (Lease::Type type, const isc::asiolink::IOAddress &addr) const override
 Returns existing IPv6 lease for a given IPv6 address.
 
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 Lease4Collection getLeases4 (const std::string &hostname) const override
 Returns all IPv4 leases for the particular hostname.
 
virtual Lease4Collection getLeases4 (SubnetID subnet_id) const override
 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) 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 getLeases6 () const override
 Returns all IPv6 leases.
 
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 (const DUID &duid) const override
 Returns all IPv6 leases for the DUID.
 
virtual Lease6Collection getLeases6 (const std::string &hostname) const override
 Returns all IPv6 leases for the particular hostname.
 
virtual Lease6Collection getLeases6 (Lease::Type type, const DUID &duid, uint32_t iaid) const override
 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 override
 Returns existing IPv6 lease for a given DUID+IA combination.
 
virtual Lease6Collection getLeases6 (SubnetID subnet_id) const override
 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 override
 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) 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.
 
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 bool isJsonSupported () const override
 Checks if JSON support is enabled in the database.
 
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 rollback () override
 Rollback Transactions.
 
virtual LeaseStatsQueryPtr startLeaseStatsQuery4 () override
 Creates and runs the IPv4 lease stats query.
 
virtual LeaseStatsQueryPtr startLeaseStatsQuery6 () override
 Creates and runs the IPv6 lease stats query.
 
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery4 () override
 Creates and runs the IPv4 lease stats query for all subnets and pools.
 
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery6 () override
 Creates and runs the IPv6 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 startSubnetLeaseStatsQuery6 (const SubnetID &subnet_id) override
 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) override
 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) override
 Creates and runs the IPv6 lease stats query for a single subnet.
 
virtual void updateLease4 (const Lease4Ptr &lease4) override
 Updates IPv4 lease.
 
virtual void updateLease6 (const Lease6Ptr &lease6) override
 Updates IPv6 lease.
 
virtual size_t upgradeExtendedInfo4 (const LeasePageSize &page_size) override
 Upgrade extended info (v4).
 
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 wipeLeases4 (const SubnetID &subnet_id) override
 Removes specified IPv4 leases.
 
virtual size_t wipeLeases6 (const SubnetID &subnet_id) override
 Removed specified IPv6 leases.
 
virtual void writeLeases4 (const std::string &) override
 Write V4 leases to a file.
 
virtual void writeLeases6 (const std::string &) override
 Write V6 leases to a file.
 
- 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 Member Functions

static bool dbReconnect (util::ReconnectCtlPtr db_reconnect_ctl)
 Attempts to reconnect the server to the lease DB backend manager.
 
static std::string getDBVersion ()
 Local version of getDBVersion() class method.
 
- 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 Member Functions

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.
 
virtual void deleteExtendedInfo6 (const isc::asiolink::IOAddress &addr) override
 Extended information / Bulk Lease Query shared interface.
 
- 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.
 

Additional Inherited Members

- 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

PostgreSQL Lease Manager.

This class provides the isc::dhcp::LeaseMgr interface to the PostgreSQL database. Use of this backend presupposes that a PostgreSQL database is available and that the Kea schema has been created within it.

Definition at line 92 of file pgsql_lease_mgr.h.

Member Enumeration Documentation

◆ StatementIndex

Statement Tags.

The contents of the enum are indexes into the list of compiled SQL statements

Enumerator
DELETE_LEASE4 
DELETE_LEASE4_STATE_EXPIRED 
DELETE_LEASE6 
DELETE_LEASE6_STATE_EXPIRED 
GET_LEASE4 
GET_LEASE4_ADDR 
GET_LEASE4_CLIENTID 
GET_LEASE4_CLIENTID_SUBID 
GET_LEASE4_HWADDR 
GET_LEASE4_HWADDR_SUBID 
GET_LEASE4_PAGE 
GET_LEASE4_UCTX_PAGE 
GET_LEASE4_SUBID 
GET_LEASE4_HOSTNAME 
GET_LEASE4_EXPIRE 
GET_LEASE4_RELAYID 
GET_LEASE4_RELAYID_QST 
GET_LEASE4_RELAYID_QSET 
GET_LEASE4_RELAYID_QET 
GET_LEASE4_REMOTEID 
GET_LEASE4_REMOTEID_QST 
GET_LEASE4_REMOTEID_QSET 
GET_LEASE4_REMOTEID_QET 
GET_LEASE6 
GET_LEASE6_ADDR 
GET_LEASE6_DUID_IAID 
GET_LEASE6_DUID_IAID_SUBID 
GET_LEASE6_PAGE 
GET_LEASE6_UCTX_PAGE 
GET_LEASE6_SUBID 
GET_LEASE6_SUBID_PAGE 
GET_LEASE6_DUID 
GET_LEASE6_HOSTNAME 
GET_LEASE6_EXPIRE 
INSERT_LEASE4 
INSERT_LEASE6 
UPDATE_LEASE4 
UPDATE_LEASE6 
ALL_LEASE4_STATS 
SUBNET_LEASE4_STATS 
SUBNET_RANGE_LEASE4_STATS 
ALL_POOL_LEASE4_STATS 
ALL_LEASE6_STATS 
SUBNET_LEASE6_STATS 
SUBNET_RANGE_LEASE6_STATS 
ALL_POOL_LEASE6_STATS 
CHECK_LEASE4_LIMITS 
CHECK_LEASE6_LIMITS 
IS_JSON_SUPPORTED 
GET_LEASE4_COUNT_BY_CLASS 
GET_LEASE6_COUNT_BY_CLASS 
WIPE_RELAY_ID6 
WIPE_REMOTE_ID6 
DELETE_RELAY_ID6 
DELETE_REMOTE_ID6 
ADD_RELAY_ID6 
ADD_REMOTE_ID6 
GET_RELAY_ID6 
GET_REMOTE_ID6 
COUNT_RELAY_ID6 
COUNT_REMOTE_ID6 
NUM_STATEMENTS 

Definition at line 709 of file pgsql_lease_mgr.h.

Constructor & Destructor Documentation

◆ PgSqlLeaseMgr()

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

Constructor.

Uses the following keywords in the parameters passed to it to connect to the database:

  • name - Name of the database to which to connect (mandatory)
  • host - Host to which to connect (optional, defaults to "localhost")
  • user - Username under which to connect (optional)
  • password - Password for "user" on the database (optional)

Check the schema version and create an initial context.

Parameters
parametersA data structure relating keywords and values concerned with the database.
Exceptions
isc::dhcp::NoDatabaseNameMandatory database name not given
isc::db::DbOpenErrorError opening the database or the schema version is incorrect.
isc::db::DbOperationErrorAn operation on the open database has failed.

Definition at line 1614 of file pgsql_lease_mgr.cc.

References createContext(), dbReconnect(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_NO_TLS_SUPPORT, isc::dhcp::DHCPSRV_PGSQL_TLS_SUPPORT, isc::db::PgSqlConnection::ensureSchemaVersion(), isc_throw, LOG_ERROR, LOG_INFO, isc::db::DatabaseConnection::redactedAccessString(), isc::dhcp::LeaseMgr::setExtendedInfoTablesEnabled(), and isc::db::PgSqlConnection::warned_about_tls.

+ Here is the call graph for this function:

◆ ~PgSqlLeaseMgr()

isc::dhcp::PgSqlLeaseMgr::~PgSqlLeaseMgr ( )
virtual

Destructor (closes database)

Definition at line 1655 of file pgsql_lease_mgr.cc.

Member Function Documentation

◆ addLease() [1/2]

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

Adds an IPv4 lease.

Parameters
leaselease to be added
Returns
true if the lease was added, false if not (because a lease with the same address was already there).
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 1794 of file pgsql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_ADD_ADDR4, isc::dhcp::TrackingLeaseMgr::hasCallbacks(), INSERT_LEASE4, LOG_DEBUG, and isc::dhcp::TrackingLeaseMgr::trackAddLease().

+ Here is the call graph for this function:

◆ addLease() [2/2]

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

Adds an IPv6 lease.

Parameters
leaselease to be added
Returns
true if the lease was added, false if not (because a lease with the same address was already there).
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 1819 of file pgsql_lease_mgr.cc.

References isc::dhcp::Lease6::ACTION_IGNORE, isc::dhcp::LeaseMgr::addExtendedInfo6(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_ADD_ADDR6, isc::dhcp::LeaseMgr::getExtendedInfoTablesEnabled(), isc::dhcp::TrackingLeaseMgr::hasCallbacks(), INSERT_LEASE6, LOG_DEBUG, and isc::dhcp::TrackingLeaseMgr::trackAddLease().

+ Here is the call graph for this function:

◆ addRelayId6()

void isc::dhcp::PgSqlLeaseMgr::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 3109 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), ADD_RELAY_ID6, isc::db::PsqlBindArray::formats_, isc_throw, isc::db::PsqlBindArray::lengths_, isc::asiolink::IOAddress::toText(), and isc::db::PsqlBindArray::values_.

+ Here is the call graph for this function:

◆ addRemoteId6()

void isc::dhcp::PgSqlLeaseMgr::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 3145 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), ADD_REMOTE_ID6, isc::db::PsqlBindArray::formats_, isc_throw, isc::db::PsqlBindArray::lengths_, isc::asiolink::IOAddress::toText(), and isc::db::PsqlBindArray::values_.

+ Here is the call graph for this function:

◆ byRelayId6size()

size_t isc::dhcp::PgSqlLeaseMgr::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 3655 of file pgsql_lease_mgr.cc.

References COUNT_RELAY_ID6, and isc::db::PgSqlExchange::getColumnValue().

+ Here is the call graph for this function:

◆ byRemoteId6size()

size_t isc::dhcp::PgSqlLeaseMgr::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 3671 of file pgsql_lease_mgr.cc.

References COUNT_REMOTE_ID6, and isc::db::PgSqlExchange::getColumnValue().

+ Here is the call graph for this function:

◆ checkLimits4()

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

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

PostgreSQL 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 2797 of file pgsql_lease_mgr.cc.

References CHECK_LEASE4_LIMITS.

◆ checkLimits6()

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

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

MySQL 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 2802 of file pgsql_lease_mgr.cc.

References CHECK_LEASE6_LIMITS.

◆ clearClassLeaseCounts()

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

Clears the class-lease count map.

Implements isc::dhcp::LeaseMgr.

Definition at line 2870 of file pgsql_lease_mgr.cc.

References isc_throw.

◆ commit()

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

Commit Transactions.

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

PostgreSQL supports transactions but this manager does not use them.

Implements isc::dhcp::LeaseMgr.

Definition at line 3037 of file pgsql_lease_mgr.cc.

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

◆ createContext()

PgSqlLeaseContextPtr isc::dhcp::PgSqlLeaseMgr::createContext ( ) const

Create a new context.

The database is opened with all the SQL commands pre-compiled.

Returns
A new (never null) context.
Exceptions
isc::dhcp::NoDatabaseNameMandatory database name not given.
isc::db::DbOperationErrorAn operation on the open database has failed.

Definition at line 1728 of file pgsql_lease_mgr.cc.

References dbReconnect(), isc::db::DatabaseConnection::getIOService(), isc_throw, and NUM_STATEMENTS.

Referenced by PgSqlLeaseMgr().

+ Here is the call graph for this function:

◆ dbReconnect()

bool isc::dhcp::PgSqlLeaseMgr::dbReconnect ( util::ReconnectCtlPtr  db_reconnect_ctl)
static

Attempts to reconnect the server to the lease DB backend manager.

This is a self-rescheduling function that attempts to reconnect to the server's lease DB backends after connectivity to one or more have been lost. Upon entry it will attempt to reconnect via LeaseMgrFactory::create. If this is successful, DHCP servicing is re-enabled and server returns to normal operation.

If reconnection fails and the maximum number of retries has not been exhausted, it will schedule a call to itself to occur at the configured retry interval. DHCP service remains disabled.

If the maximum number of retries has been exhausted an error is logged and the server shuts down.

This function is passed to the connection recovery mechanism. It will be invoked when a connection loss is detected.

Parameters
db_reconnect_ctlpointer to the ReconnectCtl containing the configured reconnect parameters.
Returns
true if connection has been recovered, false otherwise.

Definition at line 1659 of file pgsql_lease_mgr.cc.

References dbReconnect(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_LEASE_DB_RECONNECT_ATTEMPT_FAILED, isc::dhcp::DHCPSRV_PGSQL_LEASE_DB_RECONNECT_ATTEMPT_SCHEDULE, isc::dhcp::DHCPSRV_PGSQL_LEASE_DB_RECONNECT_FAILED, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::dhcp::TimerMgr::instance(), isc::db::DatabaseConnection::invokeDbFailedCallback(), isc::db::DatabaseConnection::invokeDbLostCallback(), isc::db::DatabaseConnection::invokeDbRecoveredCallback(), LOG_ERROR, LOG_INFO, isc::asiolink::IntervalTimer::ONE_SHOT, and isc::dhcp::LeaseMgrFactory::recreate().

Referenced by PgSqlLeaseMgr(), createContext(), dbReconnect(), and getVersion().

+ Here is the call graph for this function:

◆ deleteExpiredReclaimedLeases4()

uint64_t isc::dhcp::PgSqlLeaseMgr::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 2731 of file pgsql_lease_mgr.cc.

References DELETE_LEASE4_STATE_EXPIRED, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED4, and LOG_DEBUG.

◆ deleteExpiredReclaimedLeases6()

uint64_t isc::dhcp::PgSqlLeaseMgr::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 2738 of file pgsql_lease_mgr.cc.

References DELETE_LEASE6_STATE_EXPIRED, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED6, and LOG_DEBUG.

◆ deleteExtendedInfo6()

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

Extended information / Bulk Lease Query shared interface.

Delete lease6 extended info from tables.

Parameters
addrThe address of the lease.

Implements isc::dhcp::LeaseMgr.

Definition at line 3047 of file pgsql_lease_mgr.cc.

Referenced by updateLease6().

◆ deleteLease() [1/2]

bool isc::dhcp::PgSqlLeaseMgr::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.
The DELETE query uses WHERE expire = ? to delete the lease 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 2630 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::db::PgSqlExchange::convertToDatabaseTime(), DELETE_LEASE4, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_DELETE_ADDR, isc::dhcp::TrackingLeaseMgr::hasCallbacks(), isc::dhcp::Lease::INFINITY_LFT, isc_throw, LOG_DEBUG, isc::asiolink::IOAddress::toText(), isc::asiolink::IOAddress::toUint32(), and isc::dhcp::TrackingLeaseMgr::trackDeleteLease().

+ Here is the call graph for this function:

◆ deleteLease() [2/2]

bool isc::dhcp::PgSqlLeaseMgr::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.
The DELETE query uses WHERE expire = ? to delete the lease 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 2677 of file pgsql_lease_mgr.cc.

References isc::dhcp::Lease6::ACTION_IGNORE, isc::db::PsqlBindArray::add(), isc::db::PgSqlExchange::convertToDatabaseTime(), DELETE_LEASE6, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_DELETE_ADDR, isc::dhcp::TrackingLeaseMgr::hasCallbacks(), isc::dhcp::Lease::INFINITY_LFT, isc_throw, LOG_DEBUG, isc::asiolink::IOAddress::toText(), and isc::dhcp::TrackingLeaseMgr::trackDeleteLease().

+ Here is the call graph for this function:

◆ getClassLeaseCount()

size_t isc::dhcp::PgSqlLeaseMgr::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 2824 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::db::PsqlBindArray::formats_, GET_LEASE4_COUNT_BY_CLASS, GET_LEASE6_COUNT_BY_CLASS, isc::db::PgSqlExchange::getColumnValue(), isc::db::PsqlBindArray::lengths_, isc::dhcp::Lease::TYPE_V4, and isc::db::PsqlBindArray::values_.

+ Here is the call graph for this function:

◆ getDBVersion()

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

◆ getDescription()

std::string isc::dhcp::PgSqlLeaseMgr::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 3022 of file pgsql_lease_mgr.cc.

◆ getExpiredLeases4()

void isc::dhcp::PgSqlLeaseMgr::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 2431 of file pgsql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_EXPIRED4, GET_LEASE4_EXPIRE, and LOG_DEBUG.

◆ getExpiredLeases6()

void isc::dhcp::PgSqlLeaseMgr::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 2439 of file pgsql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_EXPIRED6, GET_LEASE6_EXPIRE, and LOG_DEBUG.

◆ getLease4() [1/5]

Lease4Collection isc::dhcp::PgSqlLeaseMgr::getLease4 ( const ClientId clientid) const
overridevirtual

Returns existing IPv4 leases for specified client-id.

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

Parameters
clientidclient identifier
Returns
lease collection
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2006 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_CLIENTID, GET_LEASE4_CLIENTID, isc::dhcp::ClientId::getClientId(), 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::PgSqlLeaseMgr::getLease4 ( const ClientId clientid,
SubnetID  subnet_id 
) const
overridevirtual

Returns existing IPv4 lease for specified client-id.

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)
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2029 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_SUBID_CLIENTID, GET_LEASE4_CLIENTID_SUBID, isc::dhcp::ClientId::getClientId(), 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::PgSqlLeaseMgr::getLease4 ( const isc::asiolink::IOAddress addr) const
overridevirtual

Returns an IPv4 lease for specified IPv4 address.

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

Parameters
addraddress of the searched lease
Returns
smart pointer to the lease (or NULL if a lease is not found)
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 1923 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_ADDR4, GET_LEASE4_ADDR, LOG_DEBUG, isc::asiolink::IOAddress::toText(), and isc::asiolink::IOAddress::toUint32().

+ Here is the call graph for this function:

◆ getLease4() [4/5]

Lease4Collection isc::dhcp::PgSqlLeaseMgr::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
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 1947 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_HWADDR, GET_LEASE4_HWADDR, isc::dhcp::HWAddr::hwaddr_, LOG_DEBUG, and isc::dhcp::HWAddr::toText().

+ Here is the call graph for this function:

◆ getLease4() [5/5]

Lease4Ptr isc::dhcp::PgSqlLeaseMgr::getLease4 ( const isc::dhcp::HWAddr hwaddr,
SubnetID  subnet_id 
) const
overridevirtual

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

There can be at most one lease for a given HW address in a single pool, so this method 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)
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 1974 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_SUBID_HWADDR, GET_LEASE4_HWADDR_SUBID, isc::dhcp::HWAddr::hwaddr_, LOG_DEBUG, and isc::dhcp::HWAddr::toText().

+ Here is the call graph for this function:

◆ getLease6()

Lease6Ptr isc::dhcp::PgSqlLeaseMgr::getLease6 ( Lease::Type  type,
const isc::asiolink::IOAddress addr 
) const
overridevirtual

Returns existing IPv6 lease for a given IPv6 address.

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

Parameters
typespecifies lease type: (NA, TA or PD)
addraddress of the searched lease
Returns
smart pointer to the lease (or NULL if a lease is not found)
Exceptions
isc::BadValuerecord retrieved from database had an invalid lease type field.
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2159 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_ADDR6, GET_LEASE6_ADDR, LOG_DEBUG, and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ getLeases4() [1/4]

Lease4Collection isc::dhcp::PgSqlLeaseMgr::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 2104 of file pgsql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET4, GET_LEASE4, and LOG_DEBUG.

◆ getLeases4() [2/4]

Lease4Collection isc::dhcp::PgSqlLeaseMgr::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 2122 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_PAGE4, GET_LEASE4_PAGE, isc_throw, isc::asiolink::IOAddress::isV4(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, isc::asiolink::IOAddress::toText(), and isc::asiolink::IOAddress::toUint32().

+ Here is the call graph for this function:

◆ getLeases4() [3/4]

Lease4Collection isc::dhcp::PgSqlLeaseMgr::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 2081 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_HOSTNAME4, GET_LEASE4_HOSTNAME, and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getLeases4() [4/4]

Lease4Collection isc::dhcp::PgSqlLeaseMgr::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 2057 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_SUBID4, GET_LEASE4_SUBID, and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getLeases4ByRelayId()

Lease4Collection isc::dhcp::PgSqlLeaseMgr::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 3201 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_RELAYID4, GET_LEASE4_RELAYID, GET_LEASE4_RELAYID_QET, GET_LEASE4_RELAYID_QSET, GET_LEASE4_RELAYID_QST, isc_throw, isc::asiolink::IOAddress::isV4(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, isc::asiolink::IOAddress::toText(), and isc::asiolink::IOAddress::toUint32().

+ Here is the call graph for this function:

◆ getLeases4ByRemoteId()

Lease4Collection isc::dhcp::PgSqlLeaseMgr::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 3290 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_REMOTEID4, GET_LEASE4_REMOTEID, GET_LEASE4_REMOTEID_QET, GET_LEASE4_REMOTEID_QSET, GET_LEASE4_REMOTEID_QST, isc_throw, isc::asiolink::IOAddress::isV4(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, isc::asiolink::IOAddress::toText(), and isc::asiolink::IOAddress::toUint32().

+ Here is the call graph for this function:

◆ getLeases6() [1/8]

Lease6Collection isc::dhcp::PgSqlLeaseMgr::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 2375 of file pgsql_lease_mgr.cc.

References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET6, GET_LEASE6, and LOG_DEBUG.

◆ getLeases6() [2/8]

Lease6Collection isc::dhcp::PgSqlLeaseMgr::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 2393 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_PAGE6, GET_LEASE6_PAGE, 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::PgSqlLeaseMgr::getLeases6 ( const DUID duid) const
overridevirtual

Returns all IPv6 leases for the DUID.

Todo:
: implement an optimised of the query using index.
Returns
Lease collection (may be empty if no IPv6 lease found) for the DUID.

Implements isc::dhcp::LeaseMgr.

Definition at line 2330 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_DUID, GET_LEASE6_DUID, isc::dhcp::DUID::getDuid(), LOG_DEBUG, and isc::dhcp::IdentifierType< min_size, max_size >::toText().

+ Here is the call graph for this function:

◆ getLeases6() [4/8]

Lease6Collection isc::dhcp::PgSqlLeaseMgr::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 2352 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_HOSTNAME6, GET_LEASE6_HOSTNAME, and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getLeases6() [5/8]

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

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

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

Parameters
typespecifies lease type: (NA, TA or PD)
duidclient DUID
iaidIA identifier
Returns
smart pointer to the lease (or NULL if a lease is not found)
Exceptions
isc::BadValuerecord retrieved from database had an invalid lease type field.
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2189 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::PgSqlLease6Exchange::Uiaid::dbInputString(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_IAID_DUID, GET_LEASE6_DUID_IAID, isc::dhcp::DUID::getDuid(), LOG_DEBUG, and isc::dhcp::IdentifierType< min_size, max_size >::toText().

+ Here is the call graph for this function:

◆ getLeases6() [6/8]

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

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

Parameters
typespecifies lease type: (NA, TA or PD)
duidclient DUID
iaidIA identifier
subnet_idsubnet id of the subnet the lease belongs to
Returns
lease collection (may be empty if no lease is found)
Exceptions
isc::BadValuerecord retrieved from database had an invalid lease type field.
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2223 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::PgSqlLease6Exchange::Uiaid::dbInputString(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_IAID_SUBID_DUID, GET_LEASE6_DUID_IAID_SUBID, isc::dhcp::DUID::getDuid(), LOG_DEBUG, and isc::dhcp::IdentifierType< min_size, max_size >::toText().

+ Here is the call graph for this function:

◆ getLeases6() [7/8]

Lease6Collection isc::dhcp::PgSqlLeaseMgr::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 2262 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_SUBID6, GET_LEASE6_SUBID, and LOG_DEBUG.

+ Here is the call graph for this function:

◆ getLeases6() [8/8]

Lease6Collection isc::dhcp::PgSqlLeaseMgr::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 2286 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_SUBID_PAGE6, GET_LEASE6_SUBID_PAGE, 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::PgSqlLeaseMgr::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 3464 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_RELAYID6, GET_RELAY_ID6, isc::dhcp::DUID::getDuid(), 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::PgSqlLeaseMgr::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 3510 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_REMOTEID6, GET_REMOTE_ID6, 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:

◆ getName()

std::string isc::dhcp::PgSqlLeaseMgr::getName ( ) const
overridevirtual

Returns backend name.

Each backend have specific name.

Returns
Name of the backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 3007 of file pgsql_lease_mgr.cc.

◆ getType()

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

Return backend type.

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

Returns
Type of the backend.

Implements isc::dhcp::LeaseMgr.

Definition at line 661 of file pgsql_lease_mgr.h.

◆ getVersion()

std::pair< uint32_t, uint32_t > isc::dhcp::PgSqlLeaseMgr::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.
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Implements isc::dhcp::LeaseMgr.

Definition at line 3027 of file pgsql_lease_mgr.cc.

References dbReconnect(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_GET_VERSION, isc::db::DatabaseConnection::getIOService(), isc::db::PgSqlConnection::getVersion(), and LOG_DEBUG.

+ Here is the call graph for this function:

◆ isJsonSupported()

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

Checks if JSON support is enabled in the database.

PostgreSQL implementation.

Returns
true if there is JSON support, false otherwise

Implements isc::dhcp::LeaseMgr.

Definition at line 2807 of file pgsql_lease_mgr.cc.

References isc::db::PgSqlExchange::getColumnValue(), and IS_JSON_SUPPORTED.

+ Here is the call graph for this function:

◆ recountClassLeases4()

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

Recount the leases per class for V4 leases.

Implements isc::dhcp::LeaseMgr.

Definition at line 2860 of file pgsql_lease_mgr.cc.

References isc_throw.

◆ recountClassLeases6()

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

Recount the leases per class for V6 leases.

Implements isc::dhcp::LeaseMgr.

Definition at line 2865 of file pgsql_lease_mgr.cc.

References isc_throw.

◆ rollback()

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

Rollback Transactions.

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

PostgreSQL supports transactions but this manager does not use them.

Implements isc::dhcp::LeaseMgr.

Definition at line 3042 of file pgsql_lease_mgr.cc.

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

◆ startLeaseStatsQuery4()

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

Creates and runs the IPv4 lease stats query.

It creates an instance of a PgSqlLeaseStatsQuery4 and then invokes its start method, which fetches its statistical data result set by executing the ALL_LEASE_STATS4 query. The query object is then returned.

Returns
The populated query as a pointer to an LeaseStatsQuery

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 2885 of file pgsql_lease_mgr.cc.

References ALL_LEASE4_STATS.

◆ startLeaseStatsQuery6()

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

Creates and runs the IPv6 lease stats query.

It creates an instance of a PgSqlLeaseStatsQuery and then invokes its start method, which fetches its statistical data result set by executing the ALL_LEASE_STATS6 query. The query object is then returned.

Returns
The populated query as a pointer to an LeaseStatsQuery

Reimplemented from isc::dhcp::LeaseMgr.

Definition at line 2941 of file pgsql_lease_mgr.cc.

References ALL_LEASE6_STATS.

◆ startPoolLeaseStatsQuery4()

LeaseStatsQueryPtr isc::dhcp::PgSqlLeaseMgr::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 2898 of file pgsql_lease_mgr.cc.

References ALL_POOL_LEASE4_STATS.

◆ startPoolLeaseStatsQuery6()

LeaseStatsQueryPtr isc::dhcp::PgSqlLeaseMgr::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 2954 of file pgsql_lease_mgr.cc.

References ALL_POOL_LEASE6_STATS.

◆ startSubnetLeaseStatsQuery4()

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

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

It creates an instance of a PgSqlLeaseStatsQuery4 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 2911 of file pgsql_lease_mgr.cc.

References SUBNET_LEASE4_STATS.

◆ startSubnetLeaseStatsQuery6()

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

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

It creates an instance of a PgSqlLeaseStatsQuery6 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 2967 of file pgsql_lease_mgr.cc.

References SUBNET_LEASE6_STATS.

◆ startSubnetRangeLeaseStatsQuery4()

LeaseStatsQueryPtr isc::dhcp::PgSqlLeaseMgr::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 PgSqlLeaseStatsQuery4 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 2925 of file pgsql_lease_mgr.cc.

References SUBNET_RANGE_LEASE4_STATS.

◆ startSubnetRangeLeaseStatsQuery6()

LeaseStatsQueryPtr isc::dhcp::PgSqlLeaseMgr::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 PgSqlLeaseStatsQuery6 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 2981 of file pgsql_lease_mgr.cc.

References SUBNET_RANGE_LEASE6_STATS.

◆ updateLease4()

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

Updates IPv4 lease.

Updates the record of the lease in the database (as identified by the address) with the data in the passed lease object.

Parameters
lease4The lease to be updated.
Exceptions
isc::dhcp::NoSuchLeaseAttempt to update a lease that did not exist.
isc::db::DbOperationErrorAn operation on the open database has failed.
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.
The UPDATE query uses WHERE expire = ? to update the lease 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 2510 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::db::PgSqlExchange::convertToDatabaseTime(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_UPDATE_ADDR4, isc::dhcp::TrackingLeaseMgr::hasCallbacks(), isc::dhcp::Lease::INFINITY_LFT, LOG_DEBUG, isc::dhcp::TrackingLeaseMgr::trackUpdateLease(), and UPDATE_LEASE4.

Referenced by upgradeExtendedInfo4().

+ Here is the call graph for this function:

◆ updateLease6()

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

Updates IPv6 lease.

Updates the record of the lease in the database (as identified by the address) with the data in the passed lease object.

Parameters
lease6The lease to be updated.
Exceptions
isc::dhcp::NoSuchLeaseAttempt to update a lease that did not exist.
isc::db::DbOperationErrorAn operation on the open database has failed.
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.
The UPDATE query uses WHERE expire = ? to update the lease 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 2551 of file pgsql_lease_mgr.cc.

References isc::dhcp::Lease6::ACTION_DELETE, isc::dhcp::Lease6::ACTION_IGNORE, isc::dhcp::Lease6::ACTION_UPDATE, isc::db::PsqlBindArray::add(), isc::dhcp::LeaseMgr::addExtendedInfo6(), isc::db::PgSqlExchange::convertToDatabaseTime(), deleteExtendedInfo6(), isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_UPDATE_ADDR6, isc::dhcp::LeaseMgr::getExtendedInfoTablesEnabled(), isc::dhcp::TrackingLeaseMgr::hasCallbacks(), isc::dhcp::Lease::INFINITY_LFT, LOG_DEBUG, isc::db::PsqlBindArray::toText(), isc::dhcp::TrackingLeaseMgr::trackUpdateLease(), and UPDATE_LEASE6.

Referenced by upgradeExtendedInfo6().

+ Here is the call graph for this function:

◆ upgradeExtendedInfo4()

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

Upgrade extended info (v4).

For all leases with a not null user context.

  • sanitize the user context
  • update relay and remote ids
  • when the lease was modified update it in the database This function implements the new BLQ hook command named "extended-info4-upgrade".
Parameters
page_sizeThe page size used for retrieval.
Returns
The number of updates in the database.

Implements isc::dhcp::LeaseMgr.

Definition at line 3379 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4, isc::dhcp::DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4_ERROR, isc::dhcp::DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO4_PAGE, isc::dhcp::LeaseMgr::extractLease4ExtendedInfo(), GET_LEASE4_UCTX_PAGE, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS(), LOG_DEBUG, LOG_INFO, isc::dhcp::LeasePageSize::page_size_, isc::asiolink::IOAddress::toText(), isc::asiolink::IOAddress::toUint32(), updateLease4(), and isc::dhcp::LeaseMgr::upgradeLease4ExtendedInfo().

+ Here is the call graph for this function:

◆ upgradeExtendedInfo6()

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

Upgrade extended info (v6).

All leases with a not null user context.

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

Implements isc::dhcp::LeaseMgr.

Definition at line 3555 of file pgsql_lease_mgr.cc.

References isc::db::PsqlBindArray::add(), isc::dhcp::LeaseMgr::addExtendedInfo6(), isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6, isc::dhcp::DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6_ERROR, isc::dhcp::DHCPSRV_PGSQL_UPGRADE_EXTENDED_INFO6_PAGE, GET_LEASE6_UCTX_PAGE, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::LeaseMgr::getExtendedInfoTablesEnabled(), isc::dhcp::CfgMgr::instance(), isc::asiolink::IOAddress::IPV6_ZERO_ADDRESS(), LOG_DEBUG, LOG_INFO, isc::dhcp::LeasePageSize::page_size_, isc::asiolink::IOAddress::toText(), updateLease6(), isc::dhcp::LeaseMgr::upgradeLease6ExtendedInfo(), and wipeExtendedInfoTables6().

+ Here is the call graph for this function:

◆ wipeExtendedInfoTables6()

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

Wipe extended info table (v6).

Implements isc::dhcp::LeaseMgr.

Definition at line 3636 of file pgsql_lease_mgr.cc.

References WIPE_RELAY_ID6, and WIPE_REMOTE_ID6.

Referenced by upgradeExtendedInfo6().

◆ wipeLeases4()

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

Removes specified IPv4 leases.

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

Todo:
: Not implemented yet.
Parameters
subnet_ididentifier of the subnet
Returns
number of leases removed.

Implements isc::dhcp::LeaseMgr.

Definition at line 2997 of file pgsql_lease_mgr.cc.

References isc_throw.

◆ wipeLeases6()

size_t isc::dhcp::PgSqlLeaseMgr::wipeLeases6 ( const SubnetID subnet_id)
overridevirtual

Removed specified IPv6 leases.

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

Todo:
: Not implemented yet.
Parameters
subnet_ididentifier of the subnet
Returns
number of leases removed.

Implements isc::dhcp::LeaseMgr.

Definition at line 3002 of file pgsql_lease_mgr.cc.

References isc_throw.

◆ writeLeases4()

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

Write V4 leases to a file.

Implements isc::dhcp::LeaseMgr.

Definition at line 2875 of file pgsql_lease_mgr.cc.

References isc_throw.

◆ writeLeases6()

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

Write V6 leases to a file.

Implements isc::dhcp::LeaseMgr.

Definition at line 2880 of file pgsql_lease_mgr.cc.

References isc_throw.


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