7 #ifndef MEMFILE_LEASE_MGR_H
8 #define MEMFILE_LEASE_MGR_H
19 #include <boost/scoped_ptr.hpp>
20 #include <boost/shared_ptr.hpp>
287 uint32_t iaid)
const;
369 const size_t max_leases)
const;
382 const size_t max_leases)
const;
503 bool addLeaseInternal(
const Lease4Ptr& lease);
510 bool addLeaseInternal(
const Lease6Ptr& lease);
540 void getLease4Internal(
const ClientId& client_id,
567 void getLeases4Internal(
SubnetID subnet_id,
574 void getLeases4Internal(
const std::string& hostname,
631 void getLeases6Internal(
SubnetID subnet_id,
638 void getLeases6Internal(
const std::string& hostname,
650 void getLeases6Internal(
const DUID& duid,
670 const size_t max_leases)
const;
679 const size_t max_leases)
const;
695 void updateLease4Internal(
const Lease4Ptr& lease4);
711 void updateLease6Internal(
const Lease6Ptr& lease6);
727 bool deleteLeaseInternal(
const Lease4Ptr& addr);
743 bool deleteLeaseInternal(
const Lease6Ptr& addr);
750 size_t wipeLeases4Internal(
const SubnetID& subnet_id);
757 size_t wipeLeases6Internal(
const SubnetID& subnet_id);
786 template<
typename IndexType,
typename LeaseType,
typename StorageType,
787 typename LeaseFileType>
788 uint64_t deleteExpiredReclaimedLeases(
const uint32_t secs,
790 StorageType& storage,
791 LeaseFileType& lease_file)
const;
801 return (std::string(
"memfile"));
825 return (std::make_pair(MAJOR_VERSION, MINOR_VERSION));
876 static std::string
appendSuffix(
const std::string& file_name,
932 std::string initLeaseFilePath(
Universe u);
989 template<
typename LeaseObjectType,
typename LeaseFileType,
990 typename StorageType>
991 bool loadLeasesFromFiles(
const std::string& filename,
992 boost::shared_ptr<LeaseFileType>& lease_file,
993 StorageType& storage);
1002 boost::shared_ptr<CSVLeaseFile4> lease_file4_;
1005 boost::shared_ptr<CSVLeaseFile6> lease_file6_;
1129 void lfcSetup(
bool conversion_needed =
false);
1153 template<
typename LeaseFileType>
1154 void lfcExecute(boost::shared_ptr<LeaseFileType>& lease_file);
1157 boost::scoped_ptr<LFCSetup> lfc_setup_;
1168 boost::scoped_ptr<std::mutex> mutex_;
1174 #endif // MEMFILE_LEASE_MGR_H
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
virtual void rollback()
Rollback Transactions.
virtual ~Memfile_LeaseMgr()
Destructor (closes file)
virtual std::string getDescription() const
Returns description of the backend.
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
Concrete implementation of a lease database backend using flat file.
An abstract API for lease database.
virtual size_t wipeLeases6(const SubnetID &subnet_id)
Removed specified IPv6 leases.
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
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.
Universe
Specifies universe (V4, V6)
virtual void getExpiredLeases6(Lease6Collection &expired_leases, const size_t max_leases) const
Returns a collection of expired DHCPv6 leases.
virtual void getExpiredLeases4(Lease4Collection &expired_leases, const size_t max_leases) const
Returns a collection of expired DHCPv4 leases.
static const int MAJOR_VERSION
virtual bool deleteLease(const Lease4Ptr &lease)
Deletes an IPv4 lease.
Common database connection class.
std::string getDefaultLeaseFilePath(Universe u) const
Returns default path to the lease file.
Memfile_LeaseMgr(const db::DatabaseConnection::ParameterMap ¶meters)
The sole lease manager constructor.
boost::multi_index_container< Lease4Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< AddressIndexTag >, boost::multi_index::member< Lease, isc::asiolink::IOAddress,&Lease::addr_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< HWAddressSubnetIdIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::const_mem_fun< Lease, const std::vector< uint8_t > &,&Lease::getHWAddrVector >, boost::multi_index::member< Lease, SubnetID,&Lease::subnet_id_ > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ClientIdSubnetIdIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::const_mem_fun< Lease4, const std::vector< uint8_t > &,&Lease4::getClientIdVector >, boost::multi_index::member< Lease, uint32_t,&Lease::subnet_id_ > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ExpirationIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::const_mem_fun< Lease, bool,&Lease::stateExpiredReclaimed >, boost::multi_index::const_mem_fun< Lease, int64_t,&Lease::getExpirationTime > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetIdIndexTag >, boost::multi_index::member< Lease, isc::dhcp::SubnetID,&Lease::subnet_id_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< HostnameIndexTag >, boost::multi_index::member< Lease, std::string,&Lease::hostname_ > > >> Lease4Storage
A multi index container holding DHCPv4 leases.
static std::string getDBVersion()
Local version of getDBVersion() class method.
LFCFileType
Types of the lease files used by the Lease File Cleanup.
Holds DUID (DHCPv6 Unique Identifier)
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
virtual LeaseStatsQueryPtr startLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query.
virtual void lfcCallback()
A callback function triggering Lease File Cleanup (LFC).
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const
Returns existing IPv6 lease for a given IPv6 address.
boost::multi_index_container< Lease6Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< AddressIndexTag >, boost::multi_index::member< Lease, isc::asiolink::IOAddress,&Lease::addr_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< DuidIaidTypeIndexTag >, boost::multi_index::composite_key< Lease6, boost::multi_index::const_mem_fun< Lease6, const std::vector< uint8_t > &,&Lease6::getDuidVector >, boost::multi_index::member< Lease6, uint32_t,&Lease6::iaid_ >, boost::multi_index::member< Lease6, Lease::Type,&Lease6::type_ > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ExpirationIndexTag >, boost::multi_index::composite_key< Lease6, boost::multi_index::const_mem_fun< Lease, bool,&Lease::stateExpiredReclaimed >, boost::multi_index::const_mem_fun< Lease, int64_t,&Lease::getExpirationTime > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetIdIndexTag >, boost::multi_index::member< Lease, isc::dhcp::SubnetID,&Lease::subnet_id_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< DuidIndexTag >, boost::multi_index::const_mem_fun< Lease6, const std::vector< uint8_t > &,&Lease6::getDuidVector > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< HostnameIndexTag >, boost::multi_index::member< Lease, std::string,&Lease::hostname_ > > >> Lease6Storage
A multi index container holding DHCPv6 leases.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs)
Deletes all expired-reclaimed DHCPv4 leases.
virtual void commit()
Commit Transactions.
int getLFCExitStatus() const
Returns the status code returned by the last executed LFC process.
static const int MINOR_VERSION
Defines minor version of the memfile backend.
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
bool isLFCRunning() const
Checks if the process performing lease file cleanup is running.
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 wipeLeases4(const SubnetID &subnet_id)
Removes specified IPv4 leases.
virtual Lease6Collection getLeases6() const
Returns all IPv6 leases.
std::string getLeaseFilePath(Universe u) const
Returns an absolute path to the lease file.
virtual LeaseStatsQueryPtr startLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual Lease4Collection getLeases4() const
Returns all IPv4 leases.
virtual void updateLease4(const Lease4Ptr &lease4)
Updates IPv4 lease.
Type
Type of lease or pool.
Holds Client identifier or client IPv4 address.
virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs)
Deletes all expired-reclaimed DHCPv6 leases.
Hardware type that represents information from DHCPv4 packet.
virtual std::pair< uint32_t, uint32_t > getVersion() const
Returns backend version.
Wraps value holding size of the page with leases.
virtual std::string getType() const
Return backend type.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
The IOAddress class represents an IP addresses (version agnostic)
virtual void updateLease6(const Lease6Ptr &lease6)
Updates IPv6 lease.
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
static std::string appendSuffix(const std::string &file_name, const LFCFileType &file_type)
Appends appropriate suffix to the file name.
bool persistLeases(Universe u) const
Specifies whether or not leases are written to disk.
virtual std::string getName() const
Returns backend name.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
virtual bool addLease(const Lease4Ptr &lease)
Adds an IPv4 lease.
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const
Returns existing IPv4 lease for specified IPv4 address.