Kea 3.3.3
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/hwaddr.h>
17#include <dhcp/option.h>
19#include <dhcpsrv/lease.h>
20#include <dhcpsrv/subnet.h>
21
22#include <cstdint>
23#include <fstream>
24#include <iostream>
25#include <map>
26#include <string>
27#include <utility>
28#include <vector>
29
30#include <boost/noncopyable.hpp>
31#include <boost/shared_ptr.hpp>
32
40namespace isc {
41namespace dhcp {
42
44typedef std::pair<uint32_t, uint32_t> VersionPair;
45
48public:
49
55 explicit LeasePageSize(const size_t page_size);
56
57 const size_t page_size_;
58};
59
68 subnet_id_(0), pool_id_(0), lease_type_(Lease::TYPE_NA),
69 lease_state_(Lease::STATE_DEFAULT), state_count_(0) {
70 }
71
81 LeaseStatsRow(const SubnetID& subnet_id, const uint32_t lease_state,
82 const int64_t state_count, uint32_t pool_id = 0)
83 : subnet_id_(subnet_id), pool_id_(pool_id), lease_type_(Lease::TYPE_NA),
84 lease_state_(lease_state), state_count_(state_count) {
85 }
86
95 LeaseStatsRow(const SubnetID& subnet_id, const Lease::Type& lease_type,
96 const uint32_t lease_state, const int64_t state_count,
97 uint32_t pool_id = 0)
98 : subnet_id_(subnet_id), pool_id_(pool_id), lease_type_(lease_type),
99 lease_state_(lease_state), state_count_(state_count) {
100 }
101
103 bool operator<(const LeaseStatsRow &rhs) const {
104 if (subnet_id_ < rhs.subnet_id_) {
105 return (true);
106 }
107
108 if (subnet_id_ == rhs.subnet_id_ &&
109 pool_id_ < rhs.pool_id_) {
110 return (true);
111 }
112
113 if (subnet_id_ == rhs.subnet_id_ &&
114 pool_id_ == rhs.pool_id_ &&
115 lease_type_ < rhs.lease_type_) {
116 return (true);
117 }
118
119 if (subnet_id_ == rhs.subnet_id_ &&
120 pool_id_ == rhs.pool_id_ &&
121 lease_type_ == rhs.lease_type_ &&
123 return (true);
124 }
125
126 return (false);
127 }
128
131
133 uint32_t pool_id_;
134
137
139 uint32_t lease_state_;
140
143};
144
151public:
159
166 LeaseStatsQuery(const SelectMode& select_mode = ALL_SUBNETS);
167
174 LeaseStatsQuery(const SubnetID& subnet_id);
175
184 LeaseStatsQuery(const SubnetID& first_subnet_id, const SubnetID& last_subnet_id);
185
187 virtual ~LeaseStatsQuery() {}
188
194 virtual void start() {}
195
202 virtual bool getNextRow(LeaseStatsRow& row);
203
206 return (first_subnet_id_);
207 }
208
211 return (last_subnet_id_);
212 }
213
218 return (select_mode_);
219 }
220
221protected:
224
227
228private:
230 SelectMode select_mode_;
231};
232
234typedef boost::shared_ptr<LeaseStatsQuery> LeaseStatsQueryPtr;
235
237typedef boost::shared_ptr<LeaseStatsRow> LeaseStatsRowPtr;
238
257
259typedef boost::shared_ptr<SflqPoolInfo> SflqPoolInfoPtr;
260
262typedef std::vector<SflqPoolInfoPtr> SflqPoolInfoCollection;
263typedef boost::shared_ptr<SflqPoolInfoCollection> SflqPoolInfoCollectionPtr;
264
265
276class LeaseMgr {
277public:
280 LeaseMgr() : extended_info_tables_enabled_(false)
281 {}
282
284 virtual ~LeaseMgr()
285 {}
286
289 static std::string getDBVersion();
290
302 virtual bool addLease(const Lease4Ptr& lease) = 0;
303
315 virtual bool addLease(const Lease6Ptr& lease) = 0;
316
329 virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress& addr) const = 0;
330
341 virtual Lease4Collection getLease4(const isc::dhcp::HWAddr& hwaddr) const = 0;
342
353 virtual Lease4Ptr getLease4(const isc::dhcp::HWAddr& hwaddr,
354 SubnetID subnet_id) const = 0;
355
366 virtual Lease4Collection getLease4(const ClientId& clientid) const = 0;
367
377 virtual Lease4Ptr getLease4(const ClientId& clientid,
378 SubnetID subnet_id) const = 0;
379
385 virtual Lease4Collection getLeases4(SubnetID subnet_id) const = 0;
386
392 virtual Lease4Collection getLeases4(const std::string& hostname) const = 0;
393
397 virtual Lease4Collection getLeases4() const = 0;
398
423 virtual Lease4Collection
424 getLeases4(const asiolink::IOAddress& lower_bound_address,
425 const LeasePageSize& page_size) const = 0;
426
433 virtual Lease4Collection getLeases4(uint32_t state,
434 SubnetID subnet_id) const = 0;
435
447 const isc::asiolink::IOAddress& addr) const = 0;
448
459 virtual Lease6Collection getLease6(const isc::dhcp::HWAddr& hwaddr) const = 0;
460
473 virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
474 uint32_t iaid) const = 0;
475
487 virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
488 uint32_t iaid, SubnetID subnet_id) const = 0;
489
513 Lease6Ptr getLease6(Lease::Type type, const DUID& duid,
514 uint32_t iaid, SubnetID subnet_id) const;
515
521 virtual Lease6Collection getLeases6(SubnetID subnet_id) const = 0;
522
528 virtual Lease6Collection getLeases6(const std::string& hostname) const = 0;
529
533 virtual Lease6Collection getLeases6() const = 0;
534
539 virtual Lease6Collection getLeases6(const DUID& duid) const = 0;
540
565 virtual Lease6Collection
566 getLeases6(const asiolink::IOAddress& lower_bound_address,
567 const LeasePageSize& page_size) const = 0;
568
577 virtual Lease6Collection
579 const asiolink::IOAddress& lower_bound_address,
580 const LeasePageSize& page_size) const = 0;
581
588 virtual Lease6Collection getLeases6(uint32_t state,
589 SubnetID subnet_id) const = 0;
590
601 virtual void getExpiredLeases4(Lease4Collection& expired_leases,
602 const size_t max_leases) const = 0;
603
614 virtual void getExpiredLeases6(Lease6Collection& expired_leases,
615 const size_t max_leases) const = 0;
616
622 virtual void updateLease4(const Lease4Ptr& lease4) = 0;
623
627 virtual void updateLease6(const Lease6Ptr& lease6) = 0;
628
637 virtual bool deleteLease(const Lease4Ptr& lease) = 0;
638
647 virtual bool deleteLease(const Lease6Ptr& lease) = 0;
648
656 virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs) = 0;
657
665 virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs) = 0;
666
685 void recountLeaseStats4();
686
697
710
721
733 virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4(const SubnetID& first_subnet_id,
734 const SubnetID& last_subnet_id);
735
757 void recountLeaseStats6();
758
769
782
793
805 virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6(const SubnetID& first_subnet_id,
806 const SubnetID& last_subnet_id);
807
815 virtual size_t wipeLeases4(const SubnetID& subnet_id) = 0;
816
824 virtual size_t wipeLeases6(const SubnetID& subnet_id) = 0;
825
837 virtual std::string checkLimits4(isc::data::ConstElementPtr const& user_context) const = 0;
838
850 virtual std::string checkLimits6(isc::data::ConstElementPtr const& user_context) const = 0;
851
857 virtual std::string getType() const = 0;
858
865 virtual std::string getName() const = 0;
866
872 virtual std::string getDescription() const = 0;
873
889 virtual VersionPair getVersion(const std::string& timer_name = std::string()) const = 0;
890
895 virtual void commit() = 0;
896
901 virtual void rollback() = 0;
902
903 // -- The following are memfile only, but defined in the base LeaseMgr for convenience. --
904
912 virtual size_t getClassLeaseCount(const ClientClass& client_class,
913 const Lease::Type& ltype = Lease::TYPE_V4) const = 0;
914
916 virtual void recountClassLeases4() = 0;
917
919 virtual void recountClassLeases6() = 0;
920
922 virtual void clearClassLeaseCounts() = 0;
923
927
942 static bool
946
959 static bool
963
969 static void extractLease4ExtendedInfo(const Lease4Ptr& lease,
970 bool ignore_errors = true);
971
984 virtual Lease4Collection
986 const asiolink::IOAddress& lower_bound_address,
987 const LeasePageSize& page_size,
988 const time_t& qry_start_time = 0,
989 const time_t& qry_end_time = 0) = 0;
990
1003 virtual Lease4Collection
1005 const asiolink::IOAddress& lower_bound_address,
1006 const LeasePageSize& page_size,
1007 const time_t& qry_start_time = 0,
1008 const time_t& qry_end_time = 0) = 0;
1009
1018 virtual Lease6Collection
1019 getLeases6ByRelayId(const DUID& relay_id,
1020 const asiolink::IOAddress& lower_bound_address,
1021 const LeasePageSize& page_size) = 0;
1022
1031 virtual Lease6Collection
1033 const asiolink::IOAddress& lower_bound_address,
1034 const LeasePageSize& page_size) = 0;
1035
1039 virtual void writeLeases4(const std::string& filename) = 0;
1040
1044 virtual void writeLeases6(const std::string& filename) = 0;
1045
1058 virtual size_t upgradeExtendedInfo4(const LeasePageSize& page_size) = 0;
1059
1066 return (extended_info_tables_enabled_);
1067 }
1068
1073 void setExtendedInfoTablesEnabled(const bool enabled) {
1074 extended_info_tables_enabled_ = enabled;
1075 }
1076
1089 virtual size_t upgradeExtendedInfo6(const LeasePageSize& page_size) = 0;
1090
1092 virtual void wipeExtendedInfoTables6() = 0;
1093
1099 virtual size_t byRelayId6size() const;
1100
1106 virtual size_t byRemoteId6size() const;
1107
1113 virtual data::ElementPtr getStatus() const;
1114
1121
1134 virtual bool sflqCreateFlqPool4(asiolink::IOAddress start_address,
1135 asiolink::IOAddress end_address,
1136 SubnetID subnet_id, bool recreate = false);
1137
1151 asiolink::IOAddress end_address);
1152
1164 virtual bool sflqCreateFlqPool6(asiolink::IOAddress start_address,
1165 asiolink::IOAddress end_address,
1166 Lease::Type lease_type, uint8_t delegated_len,
1167 SubnetID subnet_id, bool recreate = false);
1168
1181 asiolink::IOAddress end_address);
1182
1187
1194
1205 asiolink::IOAddress end_address);
1206
1221 virtual bool sflqPool4Del(asiolink::IOAddress start_address,
1222 asiolink::IOAddress end_address,
1223 bool force = false);
1224
1229
1236
1247 asiolink::IOAddress end_address);
1248
1263 virtual bool sflqPool6Del(asiolink::IOAddress start_address,
1264 asiolink::IOAddress end_address,
1265 bool force = false);
1266
1274 static bool useSharedFlqStatement(Lease4Ptr lease);
1275
1283 static bool useSharedFlqStatement(Lease6Ptr lease);
1284
1288 static void updateStatsOnAdd(const Lease4Ptr& lease);
1289
1293 static void updateStatsOnAdd(const Lease6Ptr& lease);
1294
1299 static void updateStatsOnUpdate(const Lease4Ptr& existing,
1300 const Lease4Ptr& lease);
1301
1306 static void updateStatsOnUpdate(const Lease6Ptr& existing,
1307 const Lease6Ptr& lease);
1308
1312 static void updateStatsOnDelete(const Lease4Ptr& lease);
1313
1317 static void updateStatsOnDelete(const Lease6Ptr& lease);
1318
1327 static void bumpStat(const std::string& stat, SubnetID& subnet_id,
1328 PoolPtr pool, int value);
1329
1338 static void bumpStatPrefix(const std::string& stat, SubnetID&
1339 subnet_id, PoolPtr pool, int value);
1340protected:
1341
1343
1351
1356 virtual bool addExtendedInfo6(const Lease6Ptr& lease);
1357
1361 virtual void deleteExtendedInfo6(const isc::asiolink::IOAddress& addr) = 0;
1362
1367 virtual void addRelayId6(const isc::asiolink::IOAddress& lease_addr,
1368 const std::vector<uint8_t>& relay_id) = 0;
1369
1374 virtual void addRemoteId6(const isc::asiolink::IOAddress& lease_addr,
1375 const std::vector<uint8_t>& remote_id) = 0;
1376
1377private:
1378
1381 bool extended_info_tables_enabled_;
1382};
1383
1384} // namespace dhcp
1385} // namespace isc
1386
1387#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:1073
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:280
virtual ~LeaseMgr()
Destructor.
Definition lease_mgr.h:284
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:1065
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:47
const size_t page_size_
Holds page size.
Definition lease_mgr.h:57
LeasePageSize(const size_t page_size)
Constructor.
Definition lease_mgr.cc:47
virtual ~LeaseStatsQuery()
virtual destructor
Definition lease_mgr.h:187
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:210
SubnetID first_subnet_id_
First (or only) subnet_id in the selection criteria.
Definition lease_mgr.h:223
virtual void start()
Executes the query.
Definition lease_mgr.h:194
SubnetID getFirstSubnetID() const
Returns the value of first subnet ID specified (or zero).
Definition lease_mgr.h:205
SelectMode getSelectMode() const
Returns the selection criteria mode The value returned is based upon the constructor variant used and...
Definition lease_mgr.h:217
SubnetID last_subnet_id_
Last subnet_id in the selection criteria when a range is given.
Definition lease_mgr.h:226
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:153
Lease::Type lease_type_
Definition lease_mgr.h:246
boost::posix_time::ptime modified_ts_
Definition lease_mgr.h:253
boost::posix_time::ptime created_ts_
Definition lease_mgr.h:252
data::ElementPtr toElement() const
asiolink::IOAddress start_address_
Definition lease_mgr.h:247
asiolink::IOAddress end_address_
Definition lease_mgr.h:248
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:45
std::pair< uint32_t, uint32_t > VersionPair
Pair containing major and minor versions.
Definition lease_mgr.h:44
boost::shared_ptr< SflqPoolInfoCollection > SflqPoolInfoCollectionPtr
Definition lease_mgr.h:263
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
Definition lease.h:530
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
Definition lease.h:695
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
Definition lease_mgr.h:234
boost::shared_ptr< LeaseStatsRow > LeaseStatsRowPtr
Defines a pointer to a LeaseStatsRow.
Definition lease_mgr.h:237
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:259
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
Definition option.h:25
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
Definition lease.h:522
std::vector< SflqPoolInfoPtr > SflqPoolInfoCollection
A collection of SFLQPoolInfo structures.
Definition lease_mgr.h:262
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition lease.h:317
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:65
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:81
uint32_t pool_id_
The pool ID to which this data applies.
Definition lease_mgr.h:133
int64_t state_count_
state_count The count of leases in the lease state
Definition lease_mgr.h:142
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:95
LeaseStatsRow()
Default constructor.
Definition lease_mgr.h:67
uint32_t lease_state_
The lease_state to which the count applies.
Definition lease_mgr.h:139
SubnetID subnet_id_
The subnet ID to which this data applies.
Definition lease_mgr.h:130
bool operator<(const LeaseStatsRow &rhs) const
Less-than operator.
Definition lease_mgr.h:103
Lease::Type lease_type_
The lease_type to which the count applies.
Definition lease_mgr.h:136
a common structure for IPv4 and IPv6 leases
Definition lease.h:33
Type
Type of lease or pool.
Definition lease.h:48
@ TYPE_V4
IPv4 lease.
Definition lease.h:52