Kea: memfile_lease_mgr.h Source File

| Kea 3.2.0-git

memfile_lease_mgr.h
Go to the documentation of this file.
1// Copyright (C) 2012-2026 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef MEMFILE_LEASE_MGR_H
8#define MEMFILE_LEASE_MGR_H
9
10#include <asiolink/interval_timer.h>
11#include <asiolink/process_spawn.h>
12#include <database/database_connection.h>
13#include <dhcp/hwaddr.h>
14#include <dhcpsrv/csv_lease_file4.h>
15#include <dhcpsrv/csv_lease_file6.h>
16#include <dhcpsrv/lease_mgr_factory.h>
17#include <dhcpsrv/memfile_lease_limits.h>
18#include <dhcpsrv/memfile_lease_storage.h>
19#include <dhcpsrv/tracking_lease_mgr.h>
20
21#include <boost/scoped_ptr.hpp>
22#include <boost/shared_ptr.hpp>
23
24#include <mutex>
25
26namespace isc {
27namespace dhcp {
28
29class LFCSetup;
30
81 class Memfile_LeaseMgr : public TrackingLeaseMgr {
82public:
83
94 static const int MAJOR_VERSION_V4 = 3;
95
97 static const int MINOR_VERSION_V4 = 0;
99
112 static const int MAJOR_VERSION_V6 = 5;
113
115 static const int MINOR_VERSION_V6 = 0;
117
124 enum Universe {
125 V4,
126 V6
127 };
128
132
133
154 Memfile_LeaseMgr(const db::DatabaseConnection::ParameterMap& parameters);
155
157 virtual ~Memfile_LeaseMgr();
158
160 static std::string getDBVersion();
161
163 static std::string getDBVersionInternal(Universe const& u);
164
170 virtual bool addLease(const Lease4Ptr& lease) override;
171
177 virtual bool addLease(const Lease6Ptr& lease) override;
178
187 virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress& addr) const override;
188
199 virtual Lease4Collection getLease4(const isc::dhcp::HWAddr& hwaddr) const override;
200
214 virtual Lease4Ptr getLease4(const HWAddr& hwaddr,
215 SubnetID subnet_id) const override;
216
222 virtual Lease4Collection getLease4(const ClientId& client_id) const override;
223
236 virtual Lease4Ptr getLease4(const ClientId& clientid,
237 SubnetID subnet_id) const override;
238
244 virtual Lease4Collection getLeases4(SubnetID subnet_id) const override;
245
251 virtual Lease4Collection getLeases4(const std::string& hostname) const override;
252
256 virtual Lease4Collection getLeases4() const override;
257
282 virtual Lease4Collection
283 getLeases4(const asiolink::IOAddress& lower_bound_address,
284 const LeasePageSize& page_size) const override;
285
292 virtual Lease4Collection getLeases4(uint32_t state,
293 SubnetID subnet_id) const override;
294
304 virtual Lease6Ptr getLease6(Lease::Type type,
305 const isc::asiolink::IOAddress& addr) const override;
306
317 virtual Lease6Collection getLease6(const isc::dhcp::HWAddr& hwaddr) const override;
318
327 virtual Lease6Collection getLeases6(Lease::Type type,
328 const DUID& duid,
329 uint32_t iaid) const override;
330
343 virtual Lease6Collection getLeases6(Lease::Type type,
344 const DUID& duid,
345 uint32_t iaid,
346 SubnetID subnet_id) const override;
347
353 virtual Lease6Collection getLeases6(SubnetID subnet_id) const override;
354
360 virtual Lease6Collection getLeases6(const std::string& hostname) const override;
361
365 virtual Lease6Collection getLeases6() const override;
366
370 virtual Lease6Collection getLeases6(const DUID& duid) const override;
371
396 virtual Lease6Collection
397 getLeases6(const asiolink::IOAddress& lower_bound_address,
398 const LeasePageSize& page_size) const override;
399
408 virtual Lease6Collection
409 getLeases6(SubnetID subnet_id,
410 const asiolink::IOAddress& lower_bound_address,
411 const LeasePageSize& page_size) const override;
412
419 virtual Lease6Collection getLeases6(uint32_t state,
420 SubnetID subnet_id) const override;
421
432 virtual void getExpiredLeases4(Lease4Collection& expired_leases,
433 const size_t max_leases) const override;
434
445 virtual void getExpiredLeases6(Lease6Collection& expired_leases,
446 const size_t max_leases) const override;
447
465 virtual void updateLease4(const Lease4Ptr& lease4) override;
466
484 virtual void updateLease6(const Lease6Ptr& lease6) override;
485
500 virtual bool deleteLease(const Lease4Ptr& lease) override;
501
516 virtual bool deleteLease(const Lease6Ptr& lease) override;
517
525 virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs) override;
526
534 virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs) override;
535
544 virtual size_t wipeLeases4(const SubnetID& subnet_id) override;
545
554 virtual size_t wipeLeases6(const SubnetID& subnet_id) override;
555
567 virtual std::string
568 checkLimits4(isc::data::ConstElementPtr const& user_context) const override;
569
581 virtual std::string
582 checkLimits6(isc::data::ConstElementPtr const& user_context) const override;
583
584private:
585
589
595 bool addLeaseInternal(const Lease4Ptr& lease);
596
602 bool addLeaseInternal(const Lease6Ptr& lease);
603
609 Lease4Ptr getLease4Internal(const isc::asiolink::IOAddress& addr) const;
610
615 void getLease4Internal(const isc::dhcp::HWAddr& hwaddr,
616 Lease4Collection& collection) const;
617
625 Lease4Ptr getLease4Internal(const HWAddr& hwaddr,
626 SubnetID subnet_id) const;
627
632 void getLease4Internal(const ClientId& client_id,
633 Lease4Collection& collection) const;
634
642 Lease4Ptr getLease4Internal(const ClientId& clientid,
643 const HWAddr& hwaddr,
644 SubnetID subnet_id) const;
645
652 Lease4Ptr getLease4Internal(const ClientId& clientid,
653 SubnetID subnet_id) const;
654
659 void getLeases4Internal(SubnetID subnet_id,
660 Lease4Collection& collection) const;
661
666 void getLeases4Internal(const std::string& hostname,
667 Lease4Collection& collection) const;
668
672 void getLeases4Internal(Lease4Collection& collection) const;
673
680 void getLeases4Internal(const asiolink::IOAddress& lower_bound_address,
681 const LeasePageSize& page_size,
682 Lease4Collection& collection) const;
683
689 void getLeases4ByStateInternal(uint32_t state,
690 SubnetID subnet_id,
691 Lease4Collection& collection) const;
692
697 void getLeases4ByStateInternal(uint32_t state,
698 Lease4Collection& collection) const;
699
706 Lease6Ptr getLease6Internal(Lease::Type type,
707 const isc::asiolink::IOAddress& addr) const;
708
713 void getLease6Internal(const isc::dhcp::HWAddr& hwaddr,
714 Lease6Collection& collection) const;
715
721 Lease6Ptr getAnyLease6Internal(const isc::asiolink::IOAddress& addr) const;
722
730 void getLeases6Internal(Lease::Type type,
731 const DUID& duid,
732 uint32_t iaid,
733 Lease6Collection& collection) const;
734
743 void getLeases6Internal(Lease::Type type,
744 const DUID& duid,
745 uint32_t iaid,
746 SubnetID subnet_id,
747 Lease6Collection& collection) const;
748
753 void getLeases6Internal(SubnetID subnet_id,
754 Lease6Collection& collection) const;
755
760 void getLeases6Internal(const std::string& hostname,
761 Lease6Collection& collection) const;
762
766 void getLeases6Internal(Lease6Collection& collection) const;
767
772 void getLeases6Internal(const DUID& duid,
773 Lease6Collection& collection) const;
774
781 void getLeases6Internal(const asiolink::IOAddress& lower_bound_address,
782 const LeasePageSize& page_size,
783 Lease6Collection& collection) const;
784
793 virtual Lease6Collection
794 getLeases6Internal(SubnetID subnet_id,
795 const asiolink::IOAddress& lower_bound_address,
796 const LeasePageSize& page_size) const;
797
803 void getLeases6ByStateInternal(uint32_t state,
804 SubnetID subnet_id,
805 Lease6Collection& collection) const;
806
811 void getLeases6ByStateInternal(uint32_t state,
812 Lease6Collection& collection) const;
813
820 void getExpiredLeases4Internal(Lease4Collection& expired_leases,
821 const size_t max_leases) const;
822
829 void getExpiredLeases6Internal(Lease6Collection& expired_leases,
830 const size_t max_leases) const;
831
846 void updateLease4Internal(const Lease4Ptr& lease4);
847
862 void updateLease6Internal(const Lease6Ptr& lease6);
863
878 bool deleteLeaseInternal(const Lease4Ptr& addr);
879
894 bool deleteLeaseInternal(const Lease6Ptr& addr);
895
901 size_t wipeLeases4Internal(const SubnetID& subnet_id);
902
908 size_t wipeLeases6Internal(const SubnetID& subnet_id);
910
937 template<typename IndexType, typename LeaseType, typename StorageType,
938 typename LeaseFileType>
939 uint64_t deleteExpiredReclaimedLeases(const uint32_t secs,
940 const Universe& universe,
941 StorageType& storage,
942 LeaseFileType& lease_file);
943
950 int64_t getSubnetStat(const SubnetID& subnet_id, const std::string& stat_label) const;
951
962 bool getLeaseLimit(data::ConstElementPtr parent, Lease::Type ltype, size_t& limit) const;
963
964public:
965
971 virtual std::string getType() const override {
972 return (std::string("memfile"));
973 }
974
980 virtual std::string getName() const override {
981 return ("memory");
982 }
983
989 virtual std::string getDescription() const override;
990
996 virtual std::pair<uint32_t, uint32_t> getVersion(const std::string& timer_name = std::string()) const override;
997
1002 virtual void commit() override;
1003
1008 virtual void rollback() override;
1009
1013 static bool isLFCProcessRunning(const std::string file_name, Universe u);
1014
1021 virtual data::ElementPtr getStatus() const override;
1022
1024
1026
1027
1032 enum LFCFileType {
1033 FILE_CURRENT,
1034 FILE_INPUT,
1035 FILE_PREVIOUS,
1036 FILE_OUTPUT,
1037 FILE_FINISH,
1038 FILE_PID
1039 };
1040
1059 static std::string appendSuffix(const std::string& file_name,
1060 const LFCFileType& file_type);
1062
1066
1067
1072 static std::string getDefaultLeaseFilePath(Universe u,
1073 const std::string filename = "");
1074
1081 std::string getLeaseFilePath(Universe u) const;
1082
1094 bool persistLeases(Universe u) const;
1095
1097
1098private:
1099
1115 std::string initLeaseFilePath(Universe u);
1116
1173 template<typename LeaseObjectType, typename LeaseFileType,
1174 typename StorageType>
1175 bool loadLeasesFromFiles(Universe u, const std::string& filename,
1176 boost::shared_ptr<LeaseFileType>& lease_file,
1177 StorageType& storage);
1178
1180 Lease4Storage storage4_;
1181
1183 Lease6Storage storage6_;
1184
1185protected:
1186
1188 Lease6ExtendedInfoRelayIdTable relay_id6_;
1189
1191 Lease6ExtendedInfoRemoteIdTable remote_id6_;
1192
1194 boost::shared_ptr<CSVLeaseFile4> lease_file4_;
1195
1197 boost::shared_ptr<CSVLeaseFile6> lease_file6_;
1198
1199public:
1200
1205
1206
1210 bool isLFCRunning() const;
1211
1214 int getLFCExitStatus() const;
1215
1217 int getLFCLastPid() const;
1219
1227 virtual LeaseStatsQueryPtr startLeaseStatsQuery4() override;
1228
1240 virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery4() override;
1241
1250 virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID& subnet_id) override;
1251
1261 virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4(const SubnetID& first_subnet_id,
1262 const SubnetID& last_subnet_id) override;
1263
1271 virtual LeaseStatsQueryPtr startLeaseStatsQuery6() override;
1272
1284 virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery6() override;
1285
1294 virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID& subnet_id) override;
1295
1305 virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6(const SubnetID& first_subnet_id,
1306 const SubnetID& last_subnet_id) override;
1307
1311
1312
1313protected:
1314
1326 virtual void lfcCallback();
1328
1330
1331
1332private:
1333
1350 void lfcSetup(bool conversion_needed = false);
1351
1374 template<typename LeaseFileType>
1375 void lfcExecute(boost::shared_ptr<LeaseFileType>& lease_file);
1376
1378 boost::scoped_ptr<LFCSetup> lfc_setup_;
1379
1384 db::DatabaseConnection conn_;
1385
1387
1389 boost::scoped_ptr<std::mutex> mutex_;
1390
1392 ClassLeaseCounter class_lease_counter_;
1393
1394public:
1402 virtual size_t getClassLeaseCount(const ClientClass& client_class,
1403 const Lease::Type& ltype = Lease::TYPE_V4) const override;
1404
1412 virtual void recountClassLeases4() override;
1413
1421 virtual void recountClassLeases6() override;
1422
1426 virtual void clearClassLeaseCounts() override;
1427
1431
1444 virtual Lease4Collection
1445 getLeases4ByRelayId(const OptionBuffer& relay_id,
1446 const asiolink::IOAddress& lower_bound_address,
1447 const LeasePageSize& page_size,
1448 const time_t& qry_start_time = 0,
1449 const time_t& qry_end_time = 0) override;
1450
1463 virtual Lease4Collection
1464 getLeases4ByRemoteId(const OptionBuffer& remote_id,
1465 const asiolink::IOAddress& lower_bound_address,
1466 const LeasePageSize& page_size,
1467 const time_t& qry_start_time = 0,
1468 const time_t& qry_end_time = 0) override;
1469
1478 virtual Lease6Collection
1479 getLeases6ByRelayId(const DUID& relay_id,
1480 const asiolink::IOAddress& lower_bound_address,
1481 const LeasePageSize& page_size) override;
1482
1491 virtual Lease6Collection
1492 getLeases6ByRemoteId(const OptionBuffer& remote_id,
1493 const asiolink::IOAddress& lower_bound_address,
1494 const LeasePageSize& page_size) override;
1495
1505 size_t extractExtendedInfo4(bool update, bool current);
1506
1511 virtual size_t upgradeExtendedInfo6(const LeasePageSize& page_size) override;
1512
1514 virtual void wipeExtendedInfoTables6() override;
1515
1519 virtual size_t byRelayId6size() const override;
1520
1524 virtual size_t byRemoteId6size() const override;
1525
1526private:
1527
1540 Lease4Collection
1541 getLeases4ByRelayIdInternal(const OptionBuffer& relay_id,
1542 const asiolink::IOAddress& lower_bound_address,
1543 const LeasePageSize& page_size,
1544 const time_t& qry_start_time,
1545 const time_t& qry_end_time);
1546
1559 Lease4Collection
1560 getLeases4ByRemoteIdInternal(const OptionBuffer& remote_id,
1561 const asiolink::IOAddress& lower_bound_address,
1562 const LeasePageSize& page_size,
1563 const time_t& qry_start_time,
1564 const time_t& qry_end_time);
1565
1574 Lease6Collection
1575 getLeases6ByRelayIdInternal(const DUID& relay_id,
1576 const asiolink::IOAddress& lower_bound_address,
1577 const LeasePageSize& page_size);
1578
1587 Lease6Collection
1588 getLeases6ByRemoteIdInternal(const OptionBuffer& remote_id,
1589 const asiolink::IOAddress& lower_bound_address,
1590 const LeasePageSize& page_size);
1591
1592public:
1593
1597 virtual void writeLeases4(const std::string& filename) override;
1598
1602 virtual void writeLeases6(const std::string& filename) override;
1603
1608 virtual size_t upgradeExtendedInfo4(const LeasePageSize& page_size) override;
1609
1613 virtual isc::data::ConstElementPtr lfcStartHandler() override;
1614
1615protected:
1616
1618
1620 void buildExtendedInfoTables6();
1621
1625 virtual void deleteExtendedInfo6(const isc::asiolink::IOAddress& addr) override;
1626
1631 virtual void addRelayId6(const isc::asiolink::IOAddress& lease_addr,
1632 const std::vector<uint8_t>& relay_id) override;
1633
1638 virtual void addRemoteId6(const isc::asiolink::IOAddress& lease_addr,
1639 const std::vector<uint8_t>& remote_id) override;
1640
1641private:
1646 virtual void writeLeases4Internal(const std::string& filename);
1647
1652 virtual void writeLeases6Internal(const std::string& filename);
1653
1658 void handleDbLost();
1659
1660public:
1667 static TrackingLeaseMgrPtr
1668 factory(const isc::db::DatabaseConnection::ParameterMap& parameters);
1669
1672 util::ReconnectCtlPtr reconnectCtl() {
1673 return (conn_.reconnectCtl());
1674 }
1675};
1676
1678 struct MemfileLeaseMgrInit {
1679 // Constructor registers
1680 MemfileLeaseMgrInit() {
1681 LeaseMgrFactory::registerFactory("memfile",
1682 Memfile_LeaseMgr::factory,
1683 true,
1684 Memfile_LeaseMgr::getDBVersion);
1685 }
1686
1687 // Destructor deregisters
1688 ~MemfileLeaseMgrInit() {
1689 LeaseMgrFactory::deregisterFactory("memfile", true);
1690 }
1691};
1692
1693} // namespace dhcp
1694} // namespace isc
1695
1696#endif // MEMFILE_LEASE_MGR_H
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:53
isc::db::DatabaseConnection
Common database connection class.
Definition database_connection.h:125
isc::db::DatabaseConnection::ParameterMap
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
Definition database_connection.h:137
isc::dhcp::ClassLeaseCounter
Container that maintains counts of leases per class and lease type.
Definition memfile_lease_limits.h:30
isc::dhcp::ClientId
Holds Client identifier or client IPv4 address.
Definition duid.h:222
isc::dhcp::DUID
Holds DUID (DHCPv6 Unique Identifier).
Definition duid.h:142
isc::dhcp::LFCSetup
Represents a configuration for Lease File Cleanup.
Definition memfile_lease_mgr.cc:76
isc::dhcp::LeaseMgrFactory::registerFactory
static bool registerFactory(const std::string &db_type, const Factory &factory, bool no_log=false, DBVersion db_version=DBVersion())
Register a lease mgr factory.
Definition lease_mgr_factory.cc:157
isc::dhcp::LeaseMgrFactory::deregisterFactory
static bool deregisterFactory(const std::string &db_type, bool no_log=false)
Deregister a lease mgr factory.
Definition lease_mgr_factory.cc:187
isc::dhcp::LeasePageSize
Wraps value holding size of the page with leases.
Definition lease_mgr.h:46
isc::dhcp::Memfile_LeaseMgr::remote_id6_
Lease6ExtendedInfoRemoteIdTable remote_id6_
stores IPv6 by-remote-id cross-reference table
Definition memfile_lease_mgr.h:1191
isc::dhcp::Memfile_LeaseMgr::rollback
virtual void rollback() override
Rollback Transactions.
Definition memfile_lease_mgr.cc:2458
isc::dhcp::Memfile_LeaseMgr::extractExtendedInfo4
size_t extractExtendedInfo4(bool update, bool current)
Extract extended info for v4 leases.
Definition memfile_lease_mgr.cc:3573
isc::dhcp::Memfile_LeaseMgr::startSubnetRangeLeaseStatsQuery6
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.
Definition memfile_lease_mgr.cc:2910
isc::dhcp::Memfile_LeaseMgr::clearClassLeaseCounts
virtual void clearClassLeaseCounts() override
Clears the class-lease count map.
Definition memfile_lease_mgr.cc:3016
isc::dhcp::Memfile_LeaseMgr::byRelayId6size
virtual size_t byRelayId6size() const override
Return the by-relay-id table size.
Definition memfile_lease_mgr.cc:3442
isc::dhcp::Memfile_LeaseMgr::getStatus
virtual data::ElementPtr getStatus() const override
Return status information.
Definition memfile_lease_mgr.cc:2475
isc::dhcp::Memfile_LeaseMgr::getLeases4ByRelayId
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.
Definition memfile_lease_mgr.cc:3258
isc::dhcp::Memfile_LeaseMgr::Memfile_LeaseMgr
Memfile_LeaseMgr(const db::DatabaseConnection::ParameterMap &parameters)
The sole lease manager constructor.
Definition memfile_lease_mgr.cc:1049
isc::dhcp::Memfile_LeaseMgr::isLFCRunning
bool isLFCRunning() const
Checks if the process performing lease file cleanup is running.
Definition memfile_lease_mgr.cc:2675
isc::dhcp::Memfile_LeaseMgr::writeLeases4
virtual void writeLeases4(const std::string &filename) override
Write V4 leases to a file.
Definition memfile_lease_mgr.cc:3726
isc::dhcp::Memfile_LeaseMgr::updateLease4
virtual void updateLease4(const Lease4Ptr &lease4) override
Updates IPv4 lease.
Definition memfile_lease_mgr.cc:2113
isc::dhcp::Memfile_LeaseMgr::wipeLeases4
virtual size_t wipeLeases4(const SubnetID &subnet_id) override
Removes specified IPv4 leases.
Definition memfile_lease_mgr.cc:2925
isc::dhcp::Memfile_LeaseMgr::deleteExtendedInfo6
virtual void deleteExtendedInfo6(const isc::asiolink::IOAddress &addr) override
Delete lease6 extended info from tables.
Definition memfile_lease_mgr.cc:3700
isc::dhcp::Memfile_LeaseMgr::isLFCProcessRunning
static bool isLFCProcessRunning(const std::string file_name, Universe u)
Check if LFC is running.
Definition memfile_lease_mgr.cc:2464
isc::dhcp::Memfile_LeaseMgr::Universe
Universe
Specifies universe (V4, V6).
Definition memfile_lease_mgr.h:124
isc::dhcp::Memfile_LeaseMgr::V4
@ V4
Definition memfile_lease_mgr.h:125
isc::dhcp::Memfile_LeaseMgr::V6
@ V6
Definition memfile_lease_mgr.h:126
isc::dhcp::Memfile_LeaseMgr::getDefaultLeaseFilePath
static std::string getDefaultLeaseFilePath(Universe u, const std::string filename="")
Returns default path to the lease file.
Definition memfile_lease_mgr.cc:2522
isc::dhcp::Memfile_LeaseMgr::getType
virtual std::string getType() const override
Return backend type.
Definition memfile_lease_mgr.h:971
isc::dhcp::Memfile_LeaseMgr::factory
static TrackingLeaseMgrPtr factory(const isc::db::DatabaseConnection::ParameterMap &parameters)
Factory class method.
Definition memfile_lease_mgr.cc:3838
isc::dhcp::Memfile_LeaseMgr::LFCFileType
LFCFileType
Types of the lease files used by the Lease File Cleanup.
Definition memfile_lease_mgr.h:1032
isc::dhcp::Memfile_LeaseMgr::FILE_CURRENT
@ FILE_CURRENT
Lease File
Definition memfile_lease_mgr.h:1033
isc::dhcp::Memfile_LeaseMgr::FILE_PREVIOUS
@ FILE_PREVIOUS
Previous Lease File.
Definition memfile_lease_mgr.h:1035
isc::dhcp::Memfile_LeaseMgr::FILE_FINISH
@ FILE_FINISH
LFC Finish File.
Definition memfile_lease_mgr.h:1037
isc::dhcp::Memfile_LeaseMgr::FILE_OUTPUT
@ FILE_OUTPUT
LFC Output File.
Definition memfile_lease_mgr.h:1036
isc::dhcp::Memfile_LeaseMgr::FILE_PID
@ FILE_PID
PID File.
Definition memfile_lease_mgr.h:1038
isc::dhcp::Memfile_LeaseMgr::FILE_INPUT
@ FILE_INPUT
Lease File Copy
Definition memfile_lease_mgr.h:1034
isc::dhcp::Memfile_LeaseMgr::deleteLease
virtual bool deleteLease(const Lease4Ptr &lease) override
Deletes an IPv4 lease.
Definition memfile_lease_mgr.cc:2256
isc::dhcp::Memfile_LeaseMgr::commit
virtual void commit() override
Commit Transactions.
Definition memfile_lease_mgr.cc:2453
isc::dhcp::Memfile_LeaseMgr::wipeLeases6
virtual size_t wipeLeases6(const SubnetID &subnet_id) override
Removed specified IPv6 leases.
Definition memfile_lease_mgr.cc:2954
isc::dhcp::Memfile_LeaseMgr::getVersion
virtual std::pair< uint32_t, uint32_t > getVersion(const std::string &timer_name=std::string()) const override
Returns backend version.
Definition memfile_lease_mgr.cc:2442
isc::dhcp::Memfile_LeaseMgr::getLFCExitStatus
int getLFCExitStatus() const
Returns the status code returned by the last executed LFC process.
Definition memfile_lease_mgr.cc:2680
isc::dhcp::Memfile_LeaseMgr::startPoolLeaseStatsQuery6
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery6() override
Creates and runs the IPv6 lease stats query for all subnets and pools.
Definition memfile_lease_mgr.cc:2884
isc::dhcp::Memfile_LeaseMgr::persistLeases
bool persistLeases(Universe u) const
Specifies whether or not leases are written to disk.
Definition memfile_lease_mgr.cc:2547
isc::dhcp::Memfile_LeaseMgr::getName
virtual std::string getName() const override
Returns backend name.
Definition memfile_lease_mgr.h:980
isc::dhcp::Memfile_LeaseMgr::addRemoteId6
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.
Definition memfile_lease_mgr.cc:3718
isc::dhcp::Memfile_LeaseMgr::getDBVersion
static std::string getDBVersion()
Return extended version info.
Definition memfile_lease_mgr.cc:1136
isc::dhcp::Memfile_LeaseMgr::getLeases4
virtual Lease4Collection getLeases4() const override
Returns all IPv4 leases.
Definition memfile_lease_mgr.cc:1477
isc::dhcp::Memfile_LeaseMgr::getClassLeaseCount
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.
Definition memfile_lease_mgr.cc:3005
isc::dhcp::Memfile_LeaseMgr::lfcStartHandler
virtual isc::data::ConstElementPtr lfcStartHandler() override
Handler for kea-lfc-start command.
Definition memfile_lease_mgr.cc:2786
isc::dhcp::Memfile_LeaseMgr::getExpiredLeases6
virtual void getExpiredLeases6(Lease6Collection &expired_leases, const size_t max_leases) const override
Returns a collection of expired DHCPv6 leases.
Definition memfile_lease_mgr.cc:2047
isc::dhcp::Memfile_LeaseMgr::buildExtendedInfoTables6
void buildExtendedInfoTables6()
Extended information / Bulk Lease Query shared interface.
Definition memfile_lease_mgr.cc:3648
isc::dhcp::Memfile_LeaseMgr::addLease
virtual bool addLease(const Lease4Ptr &lease) override
Adds an IPv4 lease.
Definition memfile_lease_mgr.cc:1192
isc::dhcp::Memfile_LeaseMgr::byRemoteId6size
virtual size_t byRemoteId6size() const override
Return the by-remote-id table size.
Definition memfile_lease_mgr.cc:3447
isc::dhcp::Memfile_LeaseMgr::writeLeases6
virtual void writeLeases6(const std::string &filename) override
Write V6 leases to a file.
Definition memfile_lease_mgr.cc:3782
isc::dhcp::Memfile_LeaseMgr::relay_id6_
Lease6ExtendedInfoRelayIdTable relay_id6_
stores IPv6 by-relay-id cross-reference table
Definition memfile_lease_mgr.h:1188
isc::dhcp::Memfile_LeaseMgr::recountClassLeases6
virtual void recountClassLeases6() override
Recount the leases per class for V6 leases.
Definition memfile_lease_mgr.cc:2994
isc::dhcp::Memfile_LeaseMgr::getLeases4ByRemoteId
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.
Definition memfile_lease_mgr.cc:3344
isc::dhcp::Memfile_LeaseMgr::wipeExtendedInfoTables6
virtual void wipeExtendedInfoTables6() override
Wipe extended info table (v6).
Definition memfile_lease_mgr.cc:3430
isc::dhcp::Memfile_LeaseMgr::lease_file4_
boost::shared_ptr< CSVLeaseFile4 > lease_file4_
Holds the pointer to the DHCPv4 lease file IO.
Definition memfile_lease_mgr.h:1194
isc::dhcp::Memfile_LeaseMgr::getLeaseFilePath
std::string getLeaseFilePath(Universe u) const
Returns an absolute path to the lease file.
Definition memfile_lease_mgr.cc:2538
isc::dhcp::Memfile_LeaseMgr::getLeases6ByRemoteId
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.
Definition memfile_lease_mgr.cc:3514
isc::dhcp::Memfile_LeaseMgr::getLeases6
virtual Lease6Collection getLeases6() const override
Returns all IPv6 leases.
Definition memfile_lease_mgr.cc:1797
isc::dhcp::Memfile_LeaseMgr::reconnectCtl
util::ReconnectCtlPtr reconnectCtl()
Returns the connection's ReconnectCtl object.
Definition memfile_lease_mgr.h:1672
isc::dhcp::Memfile_LeaseMgr::lfcCallback
virtual void lfcCallback()
A callback function triggering Lease File Cleanup (LFC).
Definition memfile_lease_mgr.cc:2690
isc::dhcp::Memfile_LeaseMgr::startSubnetLeaseStatsQuery4
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id) override
Creates and runs the IPv4 lease stats query for a single subnet.
Definition memfile_lease_mgr.cc:2843
isc::dhcp::Memfile_LeaseMgr::getLFCLastPid
int getLFCLastPid() const
Returns the last lfc process id.
Definition memfile_lease_mgr.cc:2685
isc::dhcp::Memfile_LeaseMgr::getLeases6ByRelayId
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.
Definition memfile_lease_mgr.cc:3452
isc::dhcp::Memfile_LeaseMgr::startSubnetLeaseStatsQuery6
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id) override
Creates and runs the IPv6 lease stats query for a single subnet.
Definition memfile_lease_mgr.cc:2897
isc::dhcp::Memfile_LeaseMgr::getDescription
virtual std::string getDescription() const override
Returns description of the backend.
Definition memfile_lease_mgr.cc:2437
isc::dhcp::Memfile_LeaseMgr::appendSuffix
static std::string appendSuffix(const std::string &file_name, const LFCFileType &file_type)
Appends appropriate suffix to the file name.
Definition memfile_lease_mgr.cc:2494
isc::dhcp::Memfile_LeaseMgr::addRelayId6
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.
Definition memfile_lease_mgr.cc:3710
isc::dhcp::Memfile_LeaseMgr::upgradeExtendedInfo6
virtual size_t upgradeExtendedInfo6(const LeasePageSize &page_size) override
Upgrade extended info (v6).
Definition memfile_lease_mgr.cc:3695
isc::dhcp::Memfile_LeaseMgr::startLeaseStatsQuery4
virtual LeaseStatsQueryPtr startLeaseStatsQuery4() override
Creates and runs the IPv4 lease stats query.
Definition memfile_lease_mgr.cc:2817
isc::dhcp::Memfile_LeaseMgr::getLease6
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const override
Returns existing IPv6 lease for a given IPv6 address.
Definition memfile_lease_mgr.cc:1632
isc::dhcp::Memfile_LeaseMgr::recountClassLeases4
virtual void recountClassLeases4() override
Recount the leases per class for V4 leases.
Definition memfile_lease_mgr.cc:2983
isc::dhcp::Memfile_LeaseMgr::updateLease6
virtual void updateLease6(const Lease6Ptr &lease6) override
Updates IPv6 lease.
Definition memfile_lease_mgr.cc:2199
isc::dhcp::Memfile_LeaseMgr::startSubnetRangeLeaseStatsQuery4
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.
Definition memfile_lease_mgr.cc:2856
isc::dhcp::Memfile_LeaseMgr::deleteExpiredReclaimedLeases4
virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs) override
Deletes all expired-reclaimed DHCPv4 leases.
Definition memfile_lease_mgr.cc:2333
isc::dhcp::Memfile_LeaseMgr::getDBVersionInternal
static std::string getDBVersionInternal(Universe const &u)
Local version of getDBVersion() class method.
Definition memfile_lease_mgr.cc:1124
isc::dhcp::Memfile_LeaseMgr::startPoolLeaseStatsQuery4
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery4() override
Creates and runs the IPv4 lease stats query for all subnets and pools.
Definition memfile_lease_mgr.cc:2830
isc::dhcp::Memfile_LeaseMgr::checkLimits6
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.
Definition memfile_lease_mgr.cc:3107
isc::dhcp::Memfile_LeaseMgr::startLeaseStatsQuery6
virtual LeaseStatsQueryPtr startLeaseStatsQuery6() override
Creates and runs the IPv6 lease stats query.
Definition memfile_lease_mgr.cc:2871
isc::dhcp::Memfile_LeaseMgr::getLease4
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const override
Returns existing IPv4 lease for specified IPv4 address.
Definition memfile_lease_mgr.cc:1270
isc::dhcp::Memfile_LeaseMgr::~Memfile_LeaseMgr
virtual ~Memfile_LeaseMgr()
Destructor (closes file).
Definition memfile_lease_mgr.cc:1112
isc::dhcp::Memfile_LeaseMgr::checkLimits4
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.
Definition memfile_lease_mgr.cc:3021
isc::dhcp::Memfile_LeaseMgr::lease_file6_
boost::shared_ptr< CSVLeaseFile6 > lease_file6_
Holds the pointer to the DHCPv6 lease file IO.
Definition memfile_lease_mgr.h:1197
isc::dhcp::Memfile_LeaseMgr::upgradeExtendedInfo4
virtual size_t upgradeExtendedInfo4(const LeasePageSize &page_size) override
Upgrade extended info (v4).
Definition memfile_lease_mgr.cc:3643
isc::dhcp::Memfile_LeaseMgr::deleteExpiredReclaimedLeases6
virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs) override
Deletes all expired-reclaimed DHCPv6 leases.
Definition memfile_lease_mgr.cc:2351
isc::dhcp::Memfile_LeaseMgr::getExpiredLeases4
virtual void getExpiredLeases4(Lease4Collection &expired_leases, const size_t max_leases) const override
Returns a collection of expired DHCPv4 leases.
Definition memfile_lease_mgr.cc:2010
isc::dhcp::TrackingLeaseMgr::TrackingLeaseMgr
TrackingLeaseMgr()
Constructor.
Definition tracking_lease_mgr.cc:22
csv_lease_file4.h
csv_lease_file6.h
database_connection.h
isc::dhcp::Memfile_LeaseMgr::MAJOR_VERSION_V4
static const int MAJOR_VERSION_V4
Definition memfile_lease_mgr.h:94
isc::dhcp::Memfile_LeaseMgr::MINOR_VERSION_V4
static const int MINOR_VERSION_V4
the minor version of the v4 memfile backend
Definition memfile_lease_mgr.h:97
isc::dhcp::Memfile_LeaseMgr::MAJOR_VERSION_V6
static const int MAJOR_VERSION_V6
Definition memfile_lease_mgr.h:112
isc::dhcp::Memfile_LeaseMgr::MINOR_VERSION_V6
static const int MINOR_VERSION_V6
the minor version of the v6 memfile backend
Definition memfile_lease_mgr.h:115
hwaddr.h
interval_timer.h
lease_mgr_factory.h
memfile_lease_limits.h
memfile_lease_storage.h
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::ClientClass
std::string ClientClass
Defines a single class name.
Definition classify.h:44
isc::dhcp::Lease6ExtendedInfoRemoteIdTable
boost::multi_index_container< Lease6ExtendedInfoPtr, boost::multi_index::indexed_by< boost::multi_index::hashed_non_unique< boost::multi_index::tag< RemoteIdIndexTag >, boost::multi_index::member< Lease6ExtendedInfo, std::vector< uint8_t >, &Lease6ExtendedInfo::id_ > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< LeaseAddressIndexTag >, boost::multi_index::member< Lease6ExtendedInfo, isc::asiolink::IOAddress, &Lease6ExtendedInfo::lease_addr_ > > > > Lease6ExtendedInfoRemoteIdTable
A multi index container holding lease6 extended info for by remote id.
Definition memfile_lease_storage.h:562
isc::dhcp::Lease6Storage
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_unique< boost::multi_index::tag< SubnetIdIndexTag >, boost::multi_index::composite_key< Lease6, boost::multi_index::member< Lease, isc::dhcp::SubnetID, &Lease::subnet_id_ >, boost::multi_index::member< Lease, isc::asiolink::IOAddress, &Lease::addr_ > > >, 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_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetIdPoolIdIndexTag >, boost::multi_index::composite_key< Lease6, boost::multi_index::member< Lease, SubnetID, &Lease::subnet_id_ >, boost::multi_index::member< Lease, uint32_t, &Lease::pool_id_ > > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< HWAddressIndexTag >, boost::multi_index::const_mem_fun< Lease, const std::vector< uint8_t > &, &Lease::getHWAddrVector > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< StateIndexTag >, boost::multi_index::composite_key< Lease6, boost::multi_index::member< Lease, uint32_t, &Lease::state_ >, boost::multi_index::member< Lease, SubnetID, &Lease::subnet_id_ > > > > > Lease6Storage
A multi index container holding DHCPv6 leases.
Definition memfile_lease_storage.h:216
isc::dhcp::Lease6Ptr
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
Definition lease.h:528
isc::dhcp::Lease6Collection
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
Definition lease.h:693
isc::dhcp::LeaseStatsQueryPtr
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
Definition lease_mgr.h:233
isc::dhcp::Lease4Storage
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_ > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< RemoteIdIndexTag >, boost::multi_index::member< Lease4, std::vector< uint8_t >, &Lease4::remote_id_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< RelayIdIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::member< Lease4, std::vector< uint8_t >, &Lease4::relay_id_ >, boost::multi_index::member< Lease, isc::asiolink::IOAddress, &Lease::addr_ > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetIdPoolIdIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::member< Lease, SubnetID, &Lease::subnet_id_ >, boost::multi_index::member< Lease, uint32_t, &Lease::pool_id_ > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< StateIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::member< Lease, uint32_t, &Lease::state_ >, boost::multi_index::member< Lease, SubnetID, &Lease::subnet_id_ > > > > > Lease4Storage
A multi index container holding DHCPv4 leases.
Definition memfile_lease_storage.h:386
isc::dhcp::SubnetID
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition subnet_id.h:25
isc::dhcp::TrackingLeaseMgrPtr
std::unique_ptr< TrackingLeaseMgr > TrackingLeaseMgrPtr
TrackingLeaseMgr pointer.
Definition tracking_lease_mgr.h:306
isc::dhcp::OptionBuffer
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
Definition option.h:24
isc::dhcp::Lease4Collection
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
Definition lease.h:520
isc::dhcp::Lease4Ptr
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition lease.h:315
isc::dhcp::Lease6ExtendedInfoRelayIdTable
boost::multi_index_container< Lease6ExtendedInfoPtr, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::tag< RelayIdIndexTag >, boost::multi_index::composite_key< Lease6ExtendedInfo, boost::multi_index::member< Lease6ExtendedInfo, std::vector< uint8_t >, &Lease6ExtendedInfo::id_ >, boost::multi_index::member< Lease6ExtendedInfo, isc::asiolink::IOAddress, &Lease6ExtendedInfo::lease_addr_ > > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< LeaseAddressIndexTag >, boost::multi_index::member< Lease6ExtendedInfo, isc::asiolink::IOAddress, &Lease6ExtendedInfo::lease_addr_ > > > > Lease6ExtendedInfoRelayIdTable
A multi index container holding lease6 extended info for by relay id.
Definition memfile_lease_storage.h:527
isc::util::ReconnectCtlPtr
boost::shared_ptr< ReconnectCtl > ReconnectCtlPtr
Pointer to an instance of ReconnectCtl.
Definition reconnect_ctl.h:153
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
process_spawn.h
isc::dhcp::HWAddr
Hardware type that represents information from DHCPv4 packet.
Definition hwaddr.h:20
isc::dhcp::Lease::Type
Type
Type of lease or pool.
Definition lease.h:46
isc::dhcp::Lease::TYPE_V4
@ TYPE_V4
IPv4 lease.
Definition lease.h:50
isc::dhcp::MemfileLeaseMgrInit::~MemfileLeaseMgrInit
~MemfileLeaseMgrInit()
Definition memfile_lease_mgr.h:1688
isc::dhcp::MemfileLeaseMgrInit::MemfileLeaseMgrInit
MemfileLeaseMgrInit()
Definition memfile_lease_mgr.h:1680
tracking_lease_mgr.h