Kea 3.2.0-git
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 LEASE_MGR_H
8#define LEASE_MGR_H
9
10#include <asiolink/io_address.h>
11#include <asiolink/io_service.h>
12#include <cc/data.h>
15#include <dhcp/duid.h>
16#include <dhcp/option.h>
17#include <dhcp/hwaddr.h>
19#include <dhcpsrv/lease.h>
20#include <dhcpsrv/subnet.h>
21
22#include <boost/noncopyable.hpp>
23#include <boost/shared_ptr.hpp>
24
25#include <fstream>
26#include <iostream>
27#include <map>
28#include <string>
29#include <utility>
30#include <vector>
31
39namespace isc {
40namespace dhcp {
41
43typedef std::pair<uint32_t, uint32_t> VersionPair;
44
47public:
48
54 explicit LeasePageSize(const size_t page_size);
55
56 const size_t page_size_;
57};
58
67 subnet_id_(0), pool_id_(0), lease_type_(Lease::TYPE_NA),
68 lease_state_(Lease::STATE_DEFAULT), state_count_(0) {
69 }
70
80 LeaseStatsRow(const SubnetID& subnet_id, const uint32_t lease_state,
81 const int64_t state_count, uint32_t pool_id = 0)
82 : subnet_id_(subnet_id), pool_id_(pool_id), lease_type_(Lease::TYPE_NA),
83 lease_state_(lease_state), state_count_(state_count) {
84 }
85
94 LeaseStatsRow(const SubnetID& subnet_id, const Lease::Type& lease_type,
95 const uint32_t lease_state, const int64_t state_count,
96 uint32_t pool_id = 0)
97 : subnet_id_(subnet_id), pool_id_(pool_id), lease_type_(lease_type),
98 lease_state_(lease_state), state_count_(state_count) {
99 }
100
102 bool operator<(const LeaseStatsRow &rhs) const {
103 if (subnet_id_ < rhs.subnet_id_) {
104 return (true);
105 }
106
107 if (subnet_id_ == rhs.subnet_id_ &&
108 pool_id_ < rhs.pool_id_) {
109 return (true);
110 }
111
112 if (subnet_id_ == rhs.subnet_id_ &&
113 pool_id_ == rhs.pool_id_ &&
114 lease_type_ < rhs.lease_type_) {
115 return (true);
116 }
117
118 if (subnet_id_ == rhs.subnet_id_ &&
119 pool_id_ == rhs.pool_id_ &&
120 lease_type_ == rhs.lease_type_ &&
122 return (true);
123 }
124
125 return (false);
126 }
127
130
132 uint32_t pool_id_;
133
136
138 uint32_t lease_state_;
139
142};
143
150public:
158
165 LeaseStatsQuery(const SelectMode& select_mode = ALL_SUBNETS);
166
173 LeaseStatsQuery(const SubnetID& subnet_id);
174
183 LeaseStatsQuery(const SubnetID& first_subnet_id, const SubnetID& last_subnet_id);
184
186 virtual ~LeaseStatsQuery() {}
187
193 virtual void start() {}
194
201 virtual bool getNextRow(LeaseStatsRow& row);
202
205 return (first_subnet_id_);
206 }
207
210 return (last_subnet_id_);
211 }
212
217 return (select_mode_);
218 }
219
220protected:
223
226
227private:
229 SelectMode select_mode_;
230};
231
233typedef boost::shared_ptr<LeaseStatsQuery> LeaseStatsQueryPtr;
234
236typedef boost::shared_ptr<LeaseStatsRow> LeaseStatsRowPtr;
237
256
258typedef boost::shared_ptr<SflqPoolInfo> SflqPoolInfoPtr;
259
261typedef std::vector<SflqPoolInfoPtr> SflqPoolInfoCollection;
262typedef boost::shared_ptr<SflqPoolInfoCollection> SflqPoolInfoCollectionPtr;
263
264
275class LeaseMgr {
276public:
279 LeaseMgr() : extended_info_tables_enabled_(false)
280 {}
281
283 virtual ~LeaseMgr()
284 {}
285
288 static std::string getDBVersion();
289
301 virtual bool addLease(const Lease4Ptr& lease) = 0;
302
314 virtual bool addLease(const Lease6Ptr& lease) = 0;
315
328 virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress& addr) const = 0;
329
340 virtual Lease4Collection getLease4(const isc::dhcp::HWAddr& hwaddr) const = 0;
341
352 virtual Lease4Ptr getLease4(const isc::dhcp::HWAddr& hwaddr,
353 SubnetID subnet_id) const = 0;
354
365 virtual Lease4Collection getLease4(const ClientId& clientid) const = 0;
366
376 virtual Lease4Ptr getLease4(const ClientId& clientid,
377 SubnetID subnet_id) const = 0;
378
384 virtual Lease4Collection getLeases4(SubnetID subnet_id) const = 0;
385
391 virtual Lease4Collection getLeases4(const std::string& hostname) const = 0;
392
396 virtual Lease4Collection getLeases4() const = 0;
397
422 virtual Lease4Collection
423 getLeases4(const asiolink::IOAddress& lower_bound_address,
424 const LeasePageSize& page_size) const = 0;
425
432 virtual Lease4Collection getLeases4(uint32_t state,
433 SubnetID subnet_id) const = 0;
434
446 const isc::asiolink::IOAddress& addr) const = 0;
447
458 virtual Lease6Collection getLease6(const isc::dhcp::HWAddr& hwaddr) const = 0;
459
472 virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
473 uint32_t iaid) const = 0;
474
486 virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
487 uint32_t iaid, SubnetID subnet_id) const = 0;
488
512 Lease6Ptr getLease6(Lease::Type type, const DUID& duid,
513 uint32_t iaid, SubnetID subnet_id) const;
514
520 virtual Lease6Collection getLeases6(SubnetID subnet_id) const = 0;
521
527 virtual Lease6Collection getLeases6(const std::string& hostname) const = 0;
528
532 virtual Lease6Collection getLeases6() const = 0;
533
538 virtual Lease6Collection getLeases6(const DUID& duid) const = 0;
539
564 virtual Lease6Collection
565 getLeases6(const asiolink::IOAddress& lower_bound_address,
566 const LeasePageSize& page_size) const = 0;
567
576 virtual Lease6Collection
578 const asiolink::IOAddress& lower_bound_address,
579 const LeasePageSize& page_size) const = 0;
580
587 virtual Lease6Collection getLeases6(uint32_t state,
588 SubnetID subnet_id) const = 0;
589
600 virtual void getExpiredLeases4(Lease4Collection& expired_leases,
601 const size_t max_leases) const = 0;
602
613 virtual void getExpiredLeases6(Lease6Collection& expired_leases,
614 const size_t max_leases) const = 0;
615
621 virtual void updateLease4(const Lease4Ptr& lease4) = 0;
622
626 virtual void updateLease6(const Lease6Ptr& lease6) = 0;
627
636 virtual bool deleteLease(const Lease4Ptr& lease) = 0;
637
646 virtual bool deleteLease(const Lease6Ptr& lease) = 0;
647
655 virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs) = 0;
656
664 virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs) = 0;
665
684 void recountLeaseStats4();
685
696
709
720
732 virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4(const SubnetID& first_subnet_id,
733 const SubnetID& last_subnet_id);
734
756 void recountLeaseStats6();
757
768
781
792
804 virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6(const SubnetID& first_subnet_id,
805 const SubnetID& last_subnet_id);
806
814 virtual size_t wipeLeases4(const SubnetID& subnet_id) = 0;
815
823 virtual size_t wipeLeases6(const SubnetID& subnet_id) = 0;
824
836 virtual std::string checkLimits4(isc::data::ConstElementPtr const& user_context) const = 0;
837
849 virtual std::string checkLimits6(isc::data::ConstElementPtr const& user_context) const = 0;
850
856 virtual std::string getType() const = 0;
857
864 virtual std::string getName() const = 0;
865
871 virtual std::string getDescription() const = 0;
872
888 virtual VersionPair getVersion(const std::string& timer_name = std::string()) const = 0;
889
894 virtual void commit() = 0;
895
900 virtual void rollback() = 0;
901
902 // -- The following are memfile only, but defined in the base LeaseMgr for convenience. --
903
911 virtual size_t getClassLeaseCount(const ClientClass& client_class,
912 const Lease::Type& ltype = Lease::TYPE_V4) const = 0;
913
915 virtual void recountClassLeases4() = 0;
916
918 virtual void recountClassLeases6() = 0;
919
921 virtual void clearClassLeaseCounts() = 0;
922
926
941 static bool
945
958 static bool
962
968 static void extractLease4ExtendedInfo(const Lease4Ptr& lease,
969 bool ignore_errors = true);
970
983 virtual Lease4Collection
985 const asiolink::IOAddress& lower_bound_address,
986 const LeasePageSize& page_size,
987 const time_t& qry_start_time = 0,
988 const time_t& qry_end_time = 0) = 0;
989
1002 virtual Lease4Collection
1004 const asiolink::IOAddress& lower_bound_address,
1005 const LeasePageSize& page_size,
1006 const time_t& qry_start_time = 0,
1007 const time_t& qry_end_time = 0) = 0;
1008
1017 virtual Lease6Collection
1018 getLeases6ByRelayId(const DUID& relay_id,
1019 const asiolink::IOAddress& lower_bound_address,
1020 const LeasePageSize& page_size) = 0;
1021
1030 virtual Lease6Collection
1032 const asiolink::IOAddress& lower_bound_address,
1033 const LeasePageSize& page_size) = 0;
1034
1038 virtual void writeLeases4(const std::string& filename) = 0;
1039
1043 virtual void writeLeases6(const std::string& filename) = 0;
1044
1057 virtual size_t upgradeExtendedInfo4(const LeasePageSize& page_size) = 0;
1058
1065 return (extended_info_tables_enabled_);
1066 }
1067
1072 void setExtendedInfoTablesEnabled(const bool enabled) {
1073 extended_info_tables_enabled_ = enabled;
1074 }
1075
1088 virtual size_t upgradeExtendedInfo6(const LeasePageSize& page_size) = 0;
1089
1091 virtual void wipeExtendedInfoTables6() = 0;
1092
1098 virtual size_t byRelayId6size() const;
1099
1105 virtual size_t byRemoteId6size() const;
1106
1112 virtual data::ElementPtr getStatus() const;
1113
1120
1133 virtual bool sflqCreateFlqPool4(asiolink::IOAddress start_address,
1134 asiolink::IOAddress end_address,
1135 SubnetID subnet_id, bool recreate = false);
1136
1150 asiolink::IOAddress end_address);
1151
1163 virtual bool sflqCreateFlqPool6(asiolink::IOAddress start_address,
1164 asiolink::IOAddress end_address,
1165 Lease::Type lease_type, uint8_t delegated_len,
1166 SubnetID subnet_id, bool recreate = false);
1167
1180 asiolink::IOAddress end_address);
1181
1186
1193
1204 asiolink::IOAddress end_address);
1205
1220 virtual bool sflqPool4Del(asiolink::IOAddress start_address,
1221 asiolink::IOAddress end_address,
1222 bool force = false);
1223
1228
1235
1246 asiolink::IOAddress end_address);
1247
1262 virtual bool sflqPool6Del(asiolink::IOAddress start_address,
1263 asiolink::IOAddress end_address,
1264 bool force = false);
1265
1273 static bool useSharedFlqStatement(Lease4Ptr lease);
1274
1282 static bool useSharedFlqStatement(Lease6Ptr lease);
1283
1287 static void updateStatsOnAdd(const Lease4Ptr& lease);
1288
1292 static void updateStatsOnAdd(const Lease6Ptr& lease);
1293
1298 static void updateStatsOnUpdate(const Lease4Ptr& existing,
1299 const Lease4Ptr& lease);
1300
1305 static void updateStatsOnUpdate(const Lease6Ptr& existing,
1306 const Lease6Ptr& lease);
1307
1311 static void updateStatsOnDelete(const Lease4Ptr& lease);
1312
1316 static void updateStatsOnDelete(const Lease6Ptr& lease);
1317
1326 static void bumpStat(const std::string& stat, SubnetID& subnet_id,
1327 PoolPtr pool, int value);
1328
1337 static void bumpStatPrefix(const std::string& stat, SubnetID&
1338 subnet_id, PoolPtr pool, int value);
1339protected:
1340
1342
1350
1355 virtual bool addExtendedInfo6(const Lease6Ptr& lease);
1356
1360 virtual void deleteExtendedInfo6(const isc::asiolink::IOAddress& addr) = 0;
1361
1366 virtual void addRelayId6(const isc::asiolink::IOAddress& lease_addr,
1367 const std::vector<uint8_t>& relay_id) = 0;
1368
1373 virtual void addRemoteId6(const isc::asiolink::IOAddress& lease_addr,
1374 const std::vector<uint8_t>& remote_id) = 0;
1375
1376private:
1377
1380 bool extended_info_tables_enabled_;
1381};
1382
1383} // namespace dhcp
1384} // namespace isc
1385
1386#endif // LEASE_MGR_H
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
ExtendedInfoSanity
Values for extended info sanity checks done for leases.
Holds Client identifier or client IPv4 address.
Definition duid.h:222
Holds DUID (DHCPv6 Unique Identifier).
Definition duid.h:142
virtual bool sflqPool4Del(asiolink::IOAddress start_address, asiolink::IOAddress end_address, bool force=false)
Delete the SFLQ V4 pool that matches a start and end address.
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.
Definition lease_mgr.cc:552
virtual void rollback()=0
Rollback Transactions.
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query for all subnets and pools.
Definition lease_mgr.cc:547
virtual Lease4Collection getLease4(const ClientId &clientid) const =0
Returns existing IPv4 lease for specified client-id.
virtual void wipeExtendedInfoTables6()=0
Wipe extended info table (v6).
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.
Definition lease_mgr.cc:297
virtual size_t upgradeExtendedInfo6(const LeasePageSize &page_size)=0
Upgrade extended info (v6).
virtual void getExpiredLeases6(Lease6Collection &expired_leases, const size_t max_leases) const =0
Returns a collection of expired DHCPv6 leases.
virtual data::ElementPtr getStatus() const
Return status information.
virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs)=0
Deletes all expired and reclaimed DHCPv6 leases.
void setExtendedInfoTablesEnabled(const bool enabled)
Modifies the setting whether the lease6 extended info tables are enabled.
Definition lease_mgr.h:1072
virtual bool sflqPool6Del(asiolink::IOAddress start_address, asiolink::IOAddress end_address, bool force=false)
Delete the SFLQ V6 pool that matches a start and end address.
virtual size_t byRelayId6size() const
Return the by-relay-id table size.
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.
Definition lease_mgr.cc:803
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 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 SflqPoolInfoCollectionPtr sflqPool4Get(SubnetID subnet_id)
Fetch all SFLQ V4 pools belonging to a subnet.
virtual SflqPoolInfoCollectionPtr sflqPool4GetAll()
Fetch all SFLQ V4 pools.
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.
static void updateStatsOnAdd(const Lease4Ptr &lease)
Update in-memory stats when adding a v4 lease.
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.
LeaseMgr()
Constructor.
Definition lease_mgr.h:279
virtual ~LeaseMgr()
Destructor.
Definition lease_mgr.h:283
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.
virtual size_t byRemoteId6size() const
Return the by-remote-id table size.
bool getExtendedInfoTablesEnabled() const
Returns the setting indicating if lease6 extended info tables are enabled.
Definition lease_mgr.h:1064
virtual asiolink::IOAddress sflqPickFreeLease4(asiolink::IOAddress start_address, asiolink::IOAddress end_address)
Finds a free V4 address within the given pool range.
virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs)=0
Deletes all expired and reclaimed DHCPv4 leases.
static void updateStatsOnUpdate(const Lease4Ptr &existing, const Lease4Ptr &lease)
Update in-memory stats when updating a v4 lease.
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.
static bool useSharedFlqStatement(Lease4Ptr lease)
Determine if SFLQ alternate SQL statements should be used for a given v4 lease.
virtual void commit()=0
Commit Transactions.
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 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 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.
static void bumpStatPrefix(const std::string &stat, SubnetID &subnet_id, PoolPtr pool, int value)
Helper function that adds a value to a prefix stat's global, subnet, and pool level values.
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.
Definition lease_mgr.cc:286
virtual std::string getName() const =0
Returns backend name.
void recountLeaseStats4()
Recalculates per-subnet and global stats for IPv4 leases.
Definition lease_mgr.cc:78
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...
Definition lease_mgr.cc:563
virtual void updateLease4(const Lease4Ptr &lease4)=0
Updates IPv4 lease.
virtual Lease4Collection getLeases4() const =0
Returns all IPv4 leases.
virtual Lease6Collection getLease6(const isc::dhcp::HWAddr &hwaddr) const =0
Returns existing IPv6 leases for specified hardware address.
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 VersionPair getVersion(const std::string &timer_name=std::string()) const =0
Returns backend version.
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.
Definition lease_mgr.cc:557
virtual void clearClassLeaseCounts()=0
Clears the class-lease count map.
static void updateStatsOnDelete(const Lease4Ptr &lease)
Update in-memory stats when deleting a v4 lease.
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.
Definition lease_mgr.cc:281
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 isc::data::ConstElementPtr lfcStartHandler()
Handler for kea-lfc-start command.
virtual LeaseStatsQueryPtr startLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query for all subnets.
Definition lease_mgr.cc:271
virtual Lease4Collection getLeases4(uint32_t state, SubnetID subnet_id) const =0
Returns all IPv4 leases for the particular state and subnet.
static void extractLease4ExtendedInfo(const Lease4Ptr &lease, bool ignore_errors=true)
Extract relay and remote identifiers from the extended info.
virtual bool sflqCreateFlqPool4(asiolink::IOAddress start_address, asiolink::IOAddress end_address, SubnetID subnet_id, bool recreate=false)
Creates a v4 SFLQ Pool.
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 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 &ltype=Lease::TYPE_V4) const =0
Returns the class lease count for a given class and lease type.
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.
Definition lease_mgr.cc:582
virtual SflqPoolInfoCollectionPtr sflqPool6GetAll()
Fetch all SFLQ V6 pools.
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 LeaseStatsQueryPtr startPoolLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query for all subnets and pools.
Definition lease_mgr.cc:276
static void bumpStat(const std::string &stat, SubnetID &subnet_id, PoolPtr pool, int value)
Helper function that adds a value to an address stat's global, subnet, and pool level values.
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 asiolink::IOAddress sflqPickFreeLease6(asiolink::IOAddress start_address, asiolink::IOAddress end_address)
Finds a free V6 address/prefix within the given pool range.
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 Lease6Collection getLeases6(uint32_t state, SubnetID subnet_id) const =0
Returns all IPv6 leases for the particular state and subnet.
virtual SflqPoolInfoCollectionPtr sflqPool6Get(SubnetID subnet_id)
Fetch all SFLQ V6 pools belonging to a subnet.
virtual bool sflqCreateFlqPool6(asiolink::IOAddress start_address, asiolink::IOAddress end_address, Lease::Type lease_type, uint8_t delegated_len, SubnetID subnet_id, bool recreate=false)
Calls stored procedure to create an SFLQ pool for v6.
virtual LeaseStatsQueryPtr startLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query for all subnets.
Definition lease_mgr.cc:542
virtual void updateLease6(const Lease6Ptr &lease6)=0
Updates IPv6 lease.
Wraps value holding size of the page with leases.
Definition lease_mgr.h:46
const size_t page_size_
Holds page size.
Definition lease_mgr.h:56
LeasePageSize(const size_t page_size)
Constructor.
Definition lease_mgr.cc:47
virtual ~LeaseStatsQuery()
virtual destructor
Definition lease_mgr.h:186
LeaseStatsQuery(const SelectMode &select_mode=ALL_SUBNETS)
Constructor to query statistics for all subnets.
Definition lease_mgr.cc:235
SubnetID getLastSubnetID() const
Returns the value of last subnet ID specified (or zero).
Definition lease_mgr.h:209
SubnetID first_subnet_id_
First (or only) subnet_id in the selection criteria.
Definition lease_mgr.h:222
virtual void start()
Executes the query.
Definition lease_mgr.h:193
SubnetID getFirstSubnetID() const
Returns the value of first subnet ID specified (or zero).
Definition lease_mgr.h:204
SelectMode getSelectMode() const
Returns the selection criteria mode The value returned is based upon the constructor variant used and...
Definition lease_mgr.h:216
SubnetID last_subnet_id_
Last subnet_id in the selection criteria when a range is given.
Definition lease_mgr.h:225
virtual bool getNextRow(LeaseStatsRow &row)
Fetches the next row of data.
Definition lease_mgr.cc:292
SelectMode
Defines the types of selection criteria supported.
Definition lease_mgr.h:152
Lease::Type lease_type_
Definition lease_mgr.h:245
boost::posix_time::ptime modified_ts_
Definition lease_mgr.h:252
boost::posix_time::ptime created_ts_
Definition lease_mgr.h:251
data::ElementPtr toElement() const
asiolink::IOAddress start_address_
Definition lease_mgr.h:246
asiolink::IOAddress end_address_
Definition lease_mgr.h:247
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
std::string ClientClass
Defines a single class name.
Definition classify.h:44
std::pair< uint32_t, uint32_t > VersionPair
Pair containing major and minor versions.
Definition lease_mgr.h:43
boost::shared_ptr< SflqPoolInfoCollection > SflqPoolInfoCollectionPtr
Definition lease_mgr.h:262
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
Definition lease.h:528
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
Definition lease.h:693
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
Definition lease_mgr.h:233
boost::shared_ptr< LeaseStatsRow > LeaseStatsRowPtr
Defines a pointer to a LeaseStatsRow.
Definition lease_mgr.h:236
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Definition pool.h:726
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition subnet_id.h:25
boost::shared_ptr< SflqPoolInfo > SflqPoolInfoPtr
A pointer to a SFLQPoolInfo instance.
Definition lease_mgr.h:258
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
Definition option.h:24
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
Definition lease.h:520
std::vector< SflqPoolInfoPtr > SflqPoolInfoCollection
A collection of SFLQPoolInfo structures.
Definition lease_mgr.h:261
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition lease.h:315
Defines the logger used by the top-level component of kea-lfc.
Hardware type that represents information from DHCPv4 packet.
Definition hwaddr.h:20
Contains a single row of lease statistical data.
Definition lease_mgr.h:64
LeaseStatsRow(const SubnetID &subnet_id, const uint32_t lease_state, const int64_t state_count, uint32_t pool_id=0)
Constructor.
Definition lease_mgr.h:80
uint32_t pool_id_
The pool ID to which this data applies.
Definition lease_mgr.h:132
int64_t state_count_
state_count The count of leases in the lease state
Definition lease_mgr.h:141
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.
Definition lease_mgr.h:94
LeaseStatsRow()
Default constructor.
Definition lease_mgr.h:66
uint32_t lease_state_
The lease_state to which the count applies.
Definition lease_mgr.h:138
SubnetID subnet_id_
The subnet ID to which this data applies.
Definition lease_mgr.h:129
bool operator<(const LeaseStatsRow &rhs) const
Less-than operator.
Definition lease_mgr.h:102
Lease::Type lease_type_
The lease_type to which the count applies.
Definition lease_mgr.h:135
a common structure for IPv4 and IPv6 leases
Definition lease.h:31
Type
Type of lease or pool.
Definition lease.h:46
@ TYPE_V4
IPv4 lease.
Definition lease.h:50