22 #include <boost/noncopyable.hpp>
23 #include <boost/shared_ptr.hpp>
81 const int64_t state_count, uint32_t pool_id = 0)
95 const uint32_t lease_state,
const int64_t state_count,
217 return (select_mode_);
425 uint32_t iaid)
const = 0;
439 uint32_t iaid,
SubnetID subnet_id)
const = 0;
465 uint32_t iaid,
SubnetID subnet_id)
const;
531 const size_t max_leases)
const = 0;
544 const size_t max_leases)
const = 0;
838 io_service_ = io_service;
843 return (io_service_);
913 bool ignore_errors =
true);
931 const time_t& qry_start_time = 0,
932 const time_t& qry_end_time = 0) = 0;
950 const time_t& qry_start_time = 0,
951 const time_t& qry_end_time = 0) = 0;
1032 return (extended_info_tables_enabled_);
1066 extended_info_tables_enabled_ = enabled;
1093 const std::vector<uint8_t>& relay_id) = 0;
1100 const std::vector<uint8_t>& remote_id) = 0;
1108 bool extended_info_tables_enabled_;
The IOAddress class represents an IP addresses (version agnostic)
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
ExtendedInfoSanity
Values for extended info sanity checks done for leases.
@ EXTENDED_INFO_CHECK_FIX
Holds Client identifier or client IPv4 address.
Holds DUID (DHCPv6 Unique Identifier)
virtual Lease6Collection getLeases6ByLink(const asiolink::IOAddress &link_addr, uint8_t link_len, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size)=0
Returns existing IPv6 leases with on a given link.
virtual Lease6Collection getLeases6(SubnetID subnet_id) const =0
Returns all IPv6 leases for the particular subnet identifier.
virtual Lease4Collection getLeases4(const std::string &hostname) const =0
Returns all IPv4 leases for the particular hostname.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
virtual void rollback()=0
Rollback Transactions.
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query for all subnets and pools.
virtual Lease4Collection getLease4(const ClientId &clientid) const =0
Returns existing IPv4 lease for specified client-id.
virtual Lease6Collection getLeases6() const =0
Returns all IPv6 leases.
virtual Lease6Collection getLeases6(Lease::Type type, const DUID &duid, uint32_t iaid) const =0
Returns existing IPv6 leases for a given DUID+IA combination.
void recountLeaseStats6()
Recalculates per-subnet and global stats for IPv6 leases.
virtual void getExpiredLeases6(Lease6Collection &expired_leases, const size_t max_leases) const =0
Returns a collection of expired DHCPv6 leases.
virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs)=0
Deletes all expired and reclaimed DHCPv6 leases.
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.
virtual size_t wipeLeases6(const SubnetID &subnet_id)=0
Virtual method which removes specified leases.
virtual size_t upgradeExtendedInfo4(const LeasePageSize &page_size)=0
Upgrade extended info (v4).
virtual void recountClassLeases4()=0
Recount the leases per class for V4 leases.
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 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 ~LeaseMgr()
Destructor.
virtual void writeLeases6(const std::string &filename)=0
Write V6 leases to a file.
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const =0
Returns an IPv4 lease for specified IPv4 address.
bool getExtendedInfoTablesEnabled() const
Returns the setting indicating if lease extended info tables are enabled.
virtual size_t upgradeBinaryAddress6(const LeasePageSize &page_size)=0
Upgrade binary address (v6).
virtual Lease6Collection getLeases6ByRemoteId(const OptionBuffer &remote_id, const asiolink::IOAddress &link_addr, uint8_t link_len, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size)=0
Returns existing IPv6 leases with a given remote-id.
virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs)=0
Deletes all expired and reclaimed DHCPv4 leases.
virtual Lease6Collection getLeases6(const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const =0
Returns range of IPv6 leases using paging.
virtual Lease4Ptr getLease4(const isc::dhcp::HWAddr &hwaddr, SubnetID subnet_id) const =0
Returns existing IPv4 leases for specified hardware address and a subnet.
virtual bool addLease(const Lease6Ptr &lease)=0
Adds an IPv6 lease.
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 void commit()=0
Commit Transactions.
virtual VersionPair getVersion() const =0
Returns backend version.
static isc::asiolink::IOServicePtr & getIOService()
Returns pointer to the IO service.
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 Lease6Collection getLeases6(const DUID &duid) const =0
Returns collection of leases for matching DUID.
virtual bool addLease(const Lease4Ptr &lease)=0
Adds an IPv4 lease.
virtual std::string getType() const =0
Return backend type.
virtual Lease4Ptr getLease4(const ClientId &clientid, SubnetID subnet_id) const =0
Returns existing IPv4 lease for specified client-id.
virtual size_t wipeLeases4(const SubnetID &subnet_id)=0
Virtual method which removes specified leases.
virtual void setExtendedInfoTablesEnabled(const bool enabled)
Extended information / Bulk Lease Query shared interface.
virtual bool deleteLease(const Lease4Ptr &lease)=0
Deletes an IPv4 lease.
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 size_t buildExtendedInfoTables6(bool update, bool current)=0
Build extended info v6 tables.
virtual std::string getName() const =0
Returns backend name.
void recountLeaseStats4()
Recalculates per-subnet and global stats for IPv4 leases.
virtual bool isJsonSupported() const =0
Checks if JSON support is enabled in the database.
virtual void getExpiredLeases4(Lease4Collection &expired_leases, const size_t max_leases) const =0
Returns a collection of expired DHCPv4 leases.
static std::string getDBVersion()
Class method to return extended version info This class method must be redeclared and redefined in de...
virtual void updateLease4(const Lease4Ptr &lease4)=0
Updates IPv4 lease.
virtual Lease4Collection getLeases4() const =0
Returns all IPv4 leases.
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 writeLeases4(const std::string &filename)=0
Write V4 leases to a file.
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 clearClassLeaseCounts()=0
Clears the class-lease count map.
virtual bool deleteLease(const Lease6Ptr &lease)=0
Deletes an IPv6 lease.
virtual Lease4Collection getLeases4(const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const =0
Returns range of IPv4 leases using paging.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const =0
Returns existing IPv6 lease for a given IPv6 address.
virtual Lease4Collection getLease4(const isc::dhcp::HWAddr &hwaddr) const =0
Returns existing IPv4 leases for specified hardware address.
virtual std::string getDescription() const =0
Returns description of the backend.
virtual void recountClassLeases6()=0
Recount the leases per class for V6 leases.
virtual LeaseStatsQueryPtr startLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query for all subnets.
static void extractLease4ExtendedInfo(const Lease4Ptr &lease, bool ignore_errors=true)
Extract relay and remote identifiers from the extended info.
virtual void deleteExtendedInfo6(const isc::asiolink::IOAddress &addr)=0
Delete lease6 extended info from tables.
virtual size_t getClassLeaseCount(const ClientClass &client_class, const Lease::Type <ype=Lease::TYPE_V4) const =0
Returns the class lease count for a given class and lease type.
static void setIOService(const isc::asiolink::IOServicePtr &io_service)
Sets IO service to be used by the Lease Manager.
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.
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 Lease6Collection getLeases6ByRelayId(const DUID &relay_id, const asiolink::IOAddress &link_addr, uint8_t link_len, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size)=0
Returns existing IPv6 leases with a given relay-id.
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query for all subnets and pools.
virtual bool addExtendedInfo6(const Lease6Ptr &lease)
Extract extended info from a lease6 and add it into tables.
virtual Lease6Collection getLeases6(const std::string &hostname) const =0
Returns all IPv6 leases for the particular hostname.
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 LeaseStatsQueryPtr startLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query for all subnets.
virtual void updateLease6(const Lease6Ptr &lease6)=0
Updates IPv6 lease.
Wraps value holding size of the page with leases.
const size_t page_size_
Holds page size.
LeasePageSize(const size_t page_size)
Constructor.
Base class for fulfilling a statistical lease data query.
virtual ~LeaseStatsQuery()
virtual destructor
LeaseStatsQuery(const SelectMode &select_mode=ALL_SUBNETS)
Constructor to query statistics for all subnets.
SubnetID getLastSubnetID() const
Returns the value of last subnet ID specified (or zero)
SubnetID first_subnet_id_
First (or only) subnet_id in the selection criteria.
virtual void start()
Executes the query.
SubnetID getFirstSubnetID() const
Returns the value of first subnet ID specified (or zero)
SelectMode getSelectMode() const
Returns the selection criteria mode The value returned is based upon the constructor variant used and...
SubnetID last_subnet_id_
Last subnet_id in the selection criteria when a range is given.
virtual bool getNextRow(LeaseStatsRow &row)
Fetches the next row of data.
SelectMode
Defines the types of selection criteria supported.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
boost::shared_ptr< const Element > ConstElementPtr
std::string ClientClass
Defines a single class name.
std::pair< uint32_t, uint32_t > VersionPair
Pair containing major and minor versions.
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
boost::shared_ptr< LeaseStatsRow > LeaseStatsRowPtr
Defines a pointer to a LeaseStatsRow.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Defines the logger used by the top-level component of kea-lfc.
Hardware type that represents information from DHCPv4 packet.
Contains a single row of lease statistical data.
LeaseStatsRow(const SubnetID &subnet_id, const uint32_t lease_state, const int64_t state_count, uint32_t pool_id=0)
Constructor.
uint32_t pool_id_
The pool ID to which this data applies.
int64_t state_count_
state_count The count of leases in the lease state
LeaseStatsRow(const SubnetID &subnet_id, const Lease::Type &lease_type, const uint32_t lease_state, const int64_t state_count, uint32_t pool_id=0)
Constructor.
LeaseStatsRow()
Default constructor.
uint32_t lease_state_
The lease_state to which the count applies.
SubnetID subnet_id_
The subnet ID to which this data applies.
bool operator<(const LeaseStatsRow &rhs) const
Less-than operator.
Lease::Type lease_type_
The lease_type to which the count applies.
a common structure for IPv4 and IPv6 leases
Type
Type of lease or pool.