Kea: alloc_engine.h Source File

| Kea 3.2.0-git

alloc_engine.h
Go to the documentation of this file.
1// Copyright (C) 2012-2025 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 ALLOC_ENGINE_H
8#define ALLOC_ENGINE_H
9
10#include <asiolink/io_address.h>
11#include <dhcp/classify.h>
12#include <dhcp/duid.h>
13#include <dhcp/hwaddr.h>
14#include <dhcp/pkt4.h>
15#include <dhcp/pkt6.h>
16#include <dhcp/option6_ia.h>
17#include <dhcp/option6_iaaddr.h>
18#include <dhcp/option6_iaprefix.h>
19#include <dhcpsrv/allocator.h>
20#include <dhcpsrv/d2_client_cfg.h>
21#include <dhcpsrv/host.h>
22#include <dhcpsrv/subnet.h>
23#include <dhcpsrv/lease_mgr.h>
24#include <dhcpsrv/srv_config.h>
25#include <hooks/callout_handle.h>
26#include <util/multi_threading_mgr.h>
27#include <util/readwrite_mutex.h>
28
29#include <boost/shared_ptr.hpp>
30#include <boost/noncopyable.hpp>
31
32#include <functional>
33#include <list>
34#include <map>
35#include <mutex>
36#include <set>
37#include <utility>
38
39namespace isc {
40namespace dhcp {
41
47 class AllocEngine : public boost::noncopyable {
48public:
49
59 AllocEngine(isc::util::uint128_t const& attempts);
60
62 virtual ~AllocEngine() { }
63
64private:
65
67 isc::util::uint128_t attempts_;
68
70 int hook_index_lease4_select_;
71 int hook_index_lease6_select_;
72
73public:
74
83 class Resource {
84 public:
85
94 Resource(const isc::asiolink::IOAddress& address,
95 const uint8_t prefix_len = 128,
96 const uint32_t preferred = 0,
97 const uint32_t valid = 0)
98 : address_(address), prefix_len_(prefix_len),
99 preferred_(preferred), valid_(valid) {
100 }
101
105 isc::asiolink::IOAddress getAddress() const {
106 return (address_);
107 }
108
112 uint8_t getPrefixLength() const {
113 return (prefix_len_);
114 }
115
119 uint32_t getPreferred() const {
120 return (preferred_);
121 }
122
126 uint32_t getValid() const {
127 return (valid_);
128 }
129
135 bool equals(const Resource& other) const {
136 return (address_ == other.address_ &&
137 prefix_len_ == other.prefix_len_);
138 }
139
145 bool operator==(const Resource& other) const {
146 return (equals(other));
147 }
148
149 protected:
150
152 isc::asiolink::IOAddress address_;
153
155 uint8_t prefix_len_;
156
158 uint32_t preferred_;
159
161 uint32_t valid_;
162 };
163
167 struct ResourceCompare {
175 bool operator() (const Resource& lhr, const Resource& rhr) const {
176 if (lhr.getAddress() == rhr.getAddress()) {
177 return (lhr.getPrefixLength() < rhr.getPrefixLength());
178 } else {
179 return (lhr.getAddress() < rhr.getAddress());
180 }
181 }
182 };
183
185 typedef std::vector<Resource> HintContainer;
186
188 typedef std::set<Resource, ResourceCompare> ResourceContainer;
189
191 typedef std::pair<Host::IdentifierType, std::vector<uint8_t> > IdentifierPair;
192
194 typedef std::list<IdentifierPair> IdentifierList;
195
218 struct ClientContext6 : public boost::noncopyable {
219
221
222
226 Pkt6Ptr query_;
227
233 bool fake_allocation_;
234
238 bool early_global_reservations_lookup_;
239
241 ConstSubnet6Ptr subnet_;
242
246 ConstSubnet6Ptr host_subnet_;
247
249 DuidPtr duid_;
250
252 HWAddrPtr hwaddr_;
253
256 IdentifierList host_identifiers_;
257
263 std::map<SubnetID, ConstHostPtr> hosts_;
264
268 bool fwd_dns_update_;
269
273 bool rev_dns_update_;
274
279 std::string hostname_;
280
282 hooks::CalloutHandlePtr callout_handle_;
283
285 ResourceContainer allocated_resources_;
286
288 Lease6Collection new_leases_;
289
291
293 struct IAContext {
294
297 uint32_t iaid_;
298
300 Lease::Type type_;
301
306 HintContainer hints_;
307
315 Lease6Collection old_leases_;
316
323 Lease6Collection changed_leases_;
324
326 Lease6Collection reused_leases_;
327
331 ResourceContainer new_resources_;
332
335 Option6IAPtr ia_rsp_;
336
340 IAContext();
341
348 void addHint(const asiolink::IOAddress& prefix,
349 const uint8_t prefix_len = 128,
350 const uint32_t preferred = 0,
351 const uint32_t valid = 0);
352
358 void addHint(const Option6IAAddrPtr& iaaddr);
359
365 void addHint(const Option6IAPrefixPtr& iaprefix);
366
371 void addNewResource(const asiolink::IOAddress& prefix,
372 const uint8_t prefix_len = 128);
373
378 bool isNewResource(const asiolink::IOAddress& prefix,
379 const uint8_t prefix_len = 128) const;
380 };
381
383 std::vector<IAContext> ias_;
384
392 DdnsParamsPtr getDdnsParams();
393
398 void addAllocatedResource(const asiolink::IOAddress& prefix,
399 const uint8_t prefix_len = 128);
400
405 bool isAllocated(const asiolink::IOAddress& prefix,
406 const uint8_t prefix_len = 128) const;
407
413 void addHostIdentifier(const Host::IdentifierType& id_type,
414 const std::vector<uint8_t>& identifier) {
415 host_identifiers_.push_back(IdentifierPair(id_type, identifier));
416 }
417
423 IAContext& currentIA() {
424 if (ias_.empty()) {
425 createIAContext();
426 }
427 return (ias_.back());
428 }
429
430 std::vector<IAContext>& getIAContexts() {
431 return (ias_);
432 }
433
438 void createIAContext() {
439 ias_.push_back(IAContext());
440 }
441
448 ConstHostPtr currentHost() const;
449
458 ConstHostPtr globalHost() const;
459
465 bool hasGlobalReservation(const IPv6Resrv& resv) const;
466
468 ClientContext6();
469
491 ClientContext6(const ConstSubnet6Ptr& subnet, const DuidPtr& duid,
492 const bool fwd_dns, const bool rev_dns,
493 const std::string& hostname, const bool fake_allocation,
494 const Pkt6Ptr& query,
495 const hooks::CalloutHandlePtr& callout_handle =
496 hooks::CalloutHandlePtr());
497
498 private:
502 DdnsParamsPtr ddns_params_;
503 };
504
586 Lease6Collection
587 allocateLeases6(ClientContext6& ctx);
588
609 Lease6Collection renewLeases6(ClientContext6& ctx);
610
659 void reclaimExpiredLeases6(const size_t max_leases, const uint16_t timeout,
660 const bool remove_lease,
661 const uint16_t max_unwarned_cycles = 0);
662
675 void reclaimExpiredLeases6Internal(const size_t max_leases,
676 const uint16_t timeout,
677 const bool remove_lease,
678 const uint16_t max_unwarned_cycles = 0);
679
685 void deleteExpiredReclaimedLeases6(const uint32_t secs);
686
735 void reclaimExpiredLeases4(const size_t max_leases, const uint16_t timeout,
736 const bool remove_lease,
737 const uint16_t max_unwarned_cycles = 0);
738
751 void reclaimExpiredLeases4Internal(const size_t max_leases,
752 const uint16_t timeout,
753 const bool remove_lease,
754 const uint16_t max_unwarned_cycles = 0);
755
761 void deleteExpiredReclaimedLeases4(const uint32_t secs);
762
776 static void findReservation(ClientContext6& ctx);
777
788 static ConstHostPtr findGlobalReservation(ClientContext6& ctx);
789
795 static IPv6Resrv makeIPv6Resrv(const Lease6& lease) {
796 if (lease.type_ == Lease::TYPE_NA) {
797 return (IPv6Resrv(IPv6Resrv::TYPE_NA, lease.addr_,
798 (lease.prefixlen_ ? lease.prefixlen_ : 128)));
799 }
800
801 return (IPv6Resrv(IPv6Resrv::TYPE_PD, lease.addr_, lease.prefixlen_));
802 }
803
804public:
821 static void getLifetimes6(ClientContext6& ctx, uint32_t& preferred,
822 uint32_t& valid);
823
837 static void getMinLifetimes6(ClientContext6& ctx, uint32_t& preferred,
838 uint32_t& valid);
839private:
840
876 Lease6Ptr createLease6(ClientContext6& ctx,
877 const isc::asiolink::IOAddress& addr,
878 const uint8_t prefix_len,
879 hooks::CalloutHandle::CalloutNextStep& callout_status);
880
895 Lease6Collection allocateUnreservedLeases6(ClientContext6& ctx);
896
937 Lease6Ptr allocateBestMatch(ClientContext6& ctx,
938 Lease6Ptr& hint_lease,
939 bool& search_hint_lease,
940 const isc::asiolink::IOAddress& hint,
941 uint8_t hint_prefix_length,
942 ConstSubnet6Ptr original_subnet,
943 SharedNetwork6Ptr& network,
944 uint64_t& total_attempts,
945 uint64_t& subnets_with_unavail_leases,
946 uint64_t& subnets_with_unavail_pools,
947 hooks::CalloutHandle::CalloutNextStep& callout_status,
948 Allocator::PrefixLenMatchType prefix_length_match);
949
966 void
967 allocateReservedLeases6(ClientContext6& ctx, Lease6Collection& existing_leases);
968
982 void
983 allocateGlobalReservedLeases6(ClientContext6& ctx, Lease6Collection& existing_leases);
984
993 void
994 removeNonmatchingReservedLeases6(ClientContext6& ctx,
995 Lease6Collection& existing_leases);
996
1004 void
1005 removeNonmatchingReservedNoHostLeases6(ClientContext6& ctx,
1006 Lease6Collection& existing_leases);
1007
1021 void
1022 removeNonreservedLeases6(ClientContext6& ctx,
1023 Lease6Collection& existing_leases);
1024
1057 Lease6Ptr
1058 reuseExpiredLease(Lease6Ptr& expired,
1059 ClientContext6& ctx,
1060 uint8_t prefix_len,
1061 hooks::CalloutHandle::CalloutNextStep& callout_status);
1062
1081 Lease6Collection updateLeaseData(ClientContext6& ctx,
1082 const Lease6Collection& leases);
1083
1089 static bool
1090 removeLeases(Lease6Collection& container,
1091 const asiolink::IOAddress& addr);
1092
1105 void extendLease6(ClientContext6& ctx, Lease6Ptr lease);
1106
1114 enum DbReclaimMode {
1115 DB_RECLAIM_REMOVE,
1116 DB_RECLAIM_UPDATE,
1117 DB_RECLAIM_LEAVE_UNCHANGED
1118 };
1119
1131 template<typename LeasePtrType>
1132 void reclaimExpiredLease(const LeasePtrType& lease,
1133 const bool remove_lease,
1134 const hooks::CalloutHandlePtr& callout_handle);
1135
1146 template<typename LeasePtrType>
1147 void reclaimExpiredLease(const LeasePtrType& lease,
1148 const hooks::CalloutHandlePtr& callout_handle);
1149
1160 void reclaimExpiredLease(const Lease6Ptr& lease,
1161 const DbReclaimMode& reclaim_mode,
1162 const hooks::CalloutHandlePtr& callout_handle);
1163
1174 void reclaimExpiredLease(const Lease4Ptr& lease,
1175 const DbReclaimMode& reclaim_mode,
1176 const hooks::CalloutHandlePtr& callout_handle);
1177
1196 template<typename LeasePtrType>
1197 void reclaimLeaseInDatabase(const LeasePtrType& lease,
1198 const bool remove_lease,
1199 const std::function<void (const LeasePtrType&)>&
1200 lease_update_fun) const;
1201
1214 bool reclaimDeclined(const Lease4Ptr& lease);
1215
1228 bool reclaimDeclined(const Lease6Ptr& lease);
1229
1230public:
1231
1249 struct ClientContext4 : public boost::noncopyable {
1253 bool early_global_reservations_lookup_;
1254
1256 ConstSubnet4Ptr subnet_;
1257
1259 ClientIdPtr clientid_;
1260
1262 HWAddrPtr hwaddr_;
1263
1268 asiolink::IOAddress requested_address_;
1269
1271 bool fwd_dns_update_;
1272
1274 bool rev_dns_update_;
1275
1280 std::string hostname_;
1281
1283 hooks::CalloutHandlePtr callout_handle_;
1284
1290 bool fake_allocation_;
1291
1294 uint32_t offer_lft_;
1295
1297 Lease4Ptr old_lease_;
1298
1300 Lease4Ptr new_lease_;
1301
1307 std::map<SubnetID, ConstHostPtr> hosts_;
1308
1314 Lease4Ptr conflicting_lease_;
1315
1320 Pkt4Ptr query_;
1321
1324 IdentifierList host_identifiers_;
1325
1328 bool unknown_requested_addr_;
1329
1337 DdnsParamsPtr getDdnsParams();
1338
1339
1345 void addHostIdentifier(const Host::IdentifierType& id_type,
1346 const std::vector<uint8_t>& identifier) {
1347 host_identifiers_.push_back(IdentifierPair(id_type, identifier));
1348 }
1349
1356 ConstHostPtr currentHost() const;
1357
1366 ConstHostPtr globalHost() const;
1367
1369 ClientContext4();
1370
1387 ClientContext4(const ConstSubnet4Ptr& subnet,
1388 const ClientIdPtr& clientid,
1389 const HWAddrPtr& hwaddr,
1390 const asiolink::IOAddress& requested_addr,
1391 const bool fwd_dns_update, const bool rev_dns_update,
1392 const std::string& hostname, const bool fake_allocation,
1393 const uint32_t offer_lft = 0);
1394 private:
1398 DdnsParamsPtr ddns_params_;
1399 };
1400
1402 typedef boost::shared_ptr<ClientContext4> ClientContext4Ptr;
1403
1509 Lease4Ptr allocateLease4(ClientContext4& ctx);
1510
1523 static void findReservation(ClientContext4& ctx);
1524
1535 static ConstHostPtr findGlobalReservation(ClientContext4& ctx);
1536
1554 static uint32_t getValidLft(const ClientContext4& ctx);
1555
1569 static void getMinValidLft(const ClientContext4& ctx, uint32_t& valid);
1570
1587 static uint32_t getOfferLft(const ClientContext4& ctx,
1588 bool only_on_discover = true);
1593 static void getRemaining(const Lease4Ptr& lease, uint32_t& valid);
1594
1600 static void getRemaining(const Lease6Ptr& lease, uint32_t& preferred,
1601 uint32_t& valid);
1602
1603private:
1604
1635 Lease4Ptr discoverLease4(ClientContext4& ctx);
1636
1674 Lease4Ptr requestLease4(ClientContext4& ctx);
1675
1705 Lease4Ptr createLease4(const ClientContext4& ctx,
1706 const isc::asiolink::IOAddress& addr,
1707 hooks::CalloutHandle::CalloutNextStep& callout_status);
1708
1722 Lease4Ptr renewLease4(const Lease4Ptr& lease, ClientContext4& ctx);
1723
1740 Lease4Ptr
1741 reuseExpiredLease4(Lease4Ptr& expired, ClientContext4& ctx,
1742 hooks::CalloutHandle::CalloutNextStep& callout_status);
1743
1759 Lease4Ptr
1760 allocateOrReuseLease4(const asiolink::IOAddress& address,
1761 ClientContext4& ctx,
1762 hooks::CalloutHandle::CalloutNextStep& callout_status);
1763
1782 Lease4Ptr allocateUnreservedLease4(ClientContext4& ctx);
1783
1806 bool updateLease4Information(const Lease4Ptr& lease,
1807 ClientContext4& ctx) const;
1808
1809protected:
1826 bool updateLease4ExtendedInfo(const Lease4Ptr& lease,
1827 const ClientContext4& ctx) const;
1828
1844 void updateLease6ExtendedInfo(const Lease6Ptr& lease,
1845 const ClientContext6& ctx) const;
1846
1850 void clearReclaimedExtendedInfo(const Lease4Ptr& lease) const;
1851
1855 void clearReclaimedExtendedInfo(const Lease6Ptr& lease) const;
1856
1857private:
1858
1872 void setLeaseReusable(const Lease4Ptr& lease,
1873 const ClientContext4& ctx) const;
1874
1889 void setLeaseReusable(const Lease6Ptr& lease,
1890 uint32_t current_preferred_lft,
1891 const ClientContext6& ctx) const;
1892
1893private:
1894
1897 uint16_t incomplete_v4_reclamations_;
1898
1901 uint16_t incomplete_v6_reclamations_;
1902
1903public:
1904
1910 isc::util::ReadWriteMutex& getReadWriteMutex() {
1911 return (rw_mutex_);
1912 }
1913
1915 isc::util::ReadWriteMutex rw_mutex_;
1916
1925 static std::string labelNetworkOrSubnet(ConstSubnetPtr subnet);
1926};
1927
1929 typedef boost::shared_ptr<AllocEngine> AllocEnginePtr;
1930
1931} // namespace dhcp
1932} // namespace isc
1933
1934#endif // ALLOC_ENGINE_H
allocator.h
callout_handle.h
classify.h
Defines elements for storing the names of client classes.
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:53
isc::dhcp::AllocEngine::Resource
Defines a single hint.
Definition alloc_engine.h:83
isc::dhcp::AllocEngine::Resource::prefix_len_
uint8_t prefix_len_
The prefix length (128 for an address).
Definition alloc_engine.h:155
isc::dhcp::AllocEngine::Resource::valid_
uint32_t valid_
The valid lifetime (0 when not set).
Definition alloc_engine.h:161
isc::dhcp::AllocEngine::Resource::operator==
bool operator==(const Resource &other) const
Equality operator.
Definition alloc_engine.h:145
isc::dhcp::AllocEngine::Resource::Resource
Resource(const isc::asiolink::IOAddress &address, const uint8_t prefix_len=128, const uint32_t preferred=0, const uint32_t valid=0)
Default constructor.
Definition alloc_engine.h:94
isc::dhcp::AllocEngine::Resource::equals
bool equals(const Resource &other) const
Compares two AllocEngine::Resource objects for equality.
Definition alloc_engine.h:135
isc::dhcp::AllocEngine::Resource::getPrefixLength
uint8_t getPrefixLength() const
Returns the prefix length.
Definition alloc_engine.h:112
isc::dhcp::AllocEngine::Resource::preferred_
uint32_t preferred_
The preferred lifetime (0 when not set).
Definition alloc_engine.h:158
isc::dhcp::AllocEngine::Resource::getPreferred
uint32_t getPreferred() const
Returns the optional preferred lifetime.
Definition alloc_engine.h:119
isc::dhcp::AllocEngine::Resource::getAddress
isc::asiolink::IOAddress getAddress() const
Returns the address.
Definition alloc_engine.h:105
isc::dhcp::AllocEngine::Resource::getValid
uint32_t getValid() const
Returns the optional valid lifetime.
Definition alloc_engine.h:126
isc::dhcp::AllocEngine::Resource::address_
isc::asiolink::IOAddress address_
The address or prefix.
Definition alloc_engine.h:152
isc::dhcp::AllocEngine::ResourceContainer
std::set< Resource, ResourceCompare > ResourceContainer
Container holding allocated prefixes or addresses.
Definition alloc_engine.h:188
isc::dhcp::AllocEngine::ClientContext4Ptr
boost::shared_ptr< ClientContext4 > ClientContext4Ptr
Pointer to the ClientContext4.
Definition alloc_engine.h:1402
isc::dhcp::AllocEngine::makeIPv6Resrv
static IPv6Resrv makeIPv6Resrv(const Lease6 &lease)
Creates an IPv6Resrv instance from a Lease6.
Definition alloc_engine.h:795
isc::dhcp::AllocEngine::updateLease6ExtendedInfo
void updateLease6ExtendedInfo(const Lease6Ptr &lease, const ClientContext6 &ctx) const
Stores additional client query parameters on a V6 lease.
Definition alloc_engine.cc:5397
isc::dhcp::AllocEngine::getMinValidLft
static void getMinValidLft(const ClientContext4 &ctx, uint32_t &valid)
Returns the valid lifetime based on the v4 context when the pool occupancy is over the adaptive lease...
Definition alloc_engine.cc:4525
isc::dhcp::AllocEngine::reclaimExpiredLeases6Internal
void reclaimExpiredLeases6Internal(const size_t max_leases, const uint16_t timeout, const bool remove_lease, const uint16_t max_unwarned_cycles=0)
Body of reclaimExpiredLeases6.
Definition alloc_engine.cc:2767
isc::dhcp::AllocEngine::updateLease4ExtendedInfo
bool updateLease4ExtendedInfo(const Lease4Ptr &lease, const ClientContext4 &ctx) const
Stores additional client query parameters on a V4 lease.
Definition alloc_engine.cc:5341
isc::dhcp::AllocEngine::getReadWriteMutex
isc::util::ReadWriteMutex & getReadWriteMutex()
Get the read-write mutex.
Definition alloc_engine.h:1910
isc::dhcp::AllocEngine::findGlobalReservation
static ConstHostPtr findGlobalReservation(ClientContext6 &ctx)
Attempts to find the host reservation for the client.
Definition alloc_engine.cc:446
isc::dhcp::AllocEngine::AllocEngine
AllocEngine(isc::util::uint128_t const &attempts)
Constructor.
Definition alloc_engine.cc:96
isc::dhcp::AllocEngine::IdentifierPair
std::pair< Host::IdentifierType, std::vector< uint8_t > > IdentifierPair
A tuple holding host identifier type and value.
Definition alloc_engine.h:191
isc::dhcp::AllocEngine::~AllocEngine
virtual ~AllocEngine()
Destructor.
Definition alloc_engine.h:62
isc::dhcp::AllocEngine::clearReclaimedExtendedInfo
void clearReclaimedExtendedInfo(const Lease4Ptr &lease) const
Clear extended info from a reclaimed V4 lease.
Definition alloc_engine.cc:3500
isc::dhcp::AllocEngine::rw_mutex_
isc::util::ReadWriteMutex rw_mutex_
The read-write mutex.
Definition alloc_engine.h:1915
isc::dhcp::AllocEngine::getLifetimes6
static void getLifetimes6(ClientContext6 &ctx, uint32_t &preferred, uint32_t &valid)
Determines the preferred and valid v6 lease lifetimes.
Definition alloc_engine.cc:1974
isc::dhcp::AllocEngine::findReservation
static void findReservation(ClientContext6 &ctx)
Definition alloc_engine.cc:342
isc::dhcp::AllocEngine::getOfferLft
static uint32_t getOfferLft(const ClientContext4 &ctx, bool only_on_discover=true)
Returns the offer lifetime based on the v4 context.
Definition alloc_engine.cc:4439
isc::dhcp::AllocEngine::reclaimExpiredLeases4Internal
void reclaimExpiredLeases4Internal(const size_t max_leases, const uint16_t timeout, const bool remove_lease, const uint16_t max_unwarned_cycles=0)
Body of reclaimExpiredLeases4.
Definition alloc_engine.cc:2930
isc::dhcp::AllocEngine::deleteExpiredReclaimedLeases4
void deleteExpiredReclaimedLeases4(const uint32_t secs)
Deletes reclaimed leases expired more than specified amount of time ago.
Definition alloc_engine.cc:3334
isc::dhcp::AllocEngine::getValidLft
static uint32_t getValidLft(const ClientContext4 &ctx)
Returns the valid lifetime based on the v4 context.
Definition alloc_engine.cc:4474
isc::dhcp::AllocEngine::reclaimExpiredLeases6
void reclaimExpiredLeases6(const size_t max_leases, const uint16_t timeout, const bool remove_lease, const uint16_t max_unwarned_cycles=0)
Reclaims expired IPv6 leases.
Definition alloc_engine.cc:2746
isc::dhcp::AllocEngine::IdentifierList
std::list< IdentifierPair > IdentifierList
Map holding values to be used as host identifiers.
Definition alloc_engine.h:194
isc::dhcp::AllocEngine::labelNetworkOrSubnet
static std::string labelNetworkOrSubnet(ConstSubnetPtr subnet)
Generates a label for subnet or shared-network from subnet.
Definition alloc_engine.cc:3550
isc::dhcp::AllocEngine::reclaimExpiredLeases4
void reclaimExpiredLeases4(const size_t max_leases, const uint16_t timeout, const bool remove_lease, const uint16_t max_unwarned_cycles=0)
Reclaims expired IPv4 leases.
Definition alloc_engine.cc:2909
isc::dhcp::AllocEngine::getMinLifetimes6
static void getMinLifetimes6(ClientContext6 &ctx, uint32_t &preferred, uint32_t &valid)
Determines the preferred and valid v6 lease lifetimes when the pool occupancy is over the adaptive le...
Definition alloc_engine.cc:2036
isc::dhcp::AllocEngine::getRemaining
static void getRemaining(const Lease4Ptr &lease, uint32_t &valid)
Set remaining valid life time.
Definition alloc_engine.cc:4737
isc::dhcp::AllocEngine::allocateLease4
Lease4Ptr allocateLease4(ClientContext4 &ctx)
Returns IPv4 lease.
Definition alloc_engine.cc:3926
isc::dhcp::AllocEngine::deleteExpiredReclaimedLeases6
void deleteExpiredReclaimedLeases6(const uint32_t secs)
Deletes reclaimed leases expired more than specified amount of time ago.
Definition alloc_engine.cc:2887
isc::dhcp::AllocEngine::allocateLeases6
Lease6Collection allocateLeases6(ClientContext6 &ctx)
Allocates IPv6 leases for a given IA container.
Definition alloc_engine.cc:463
isc::dhcp::AllocEngine::renewLeases6
Lease6Collection renewLeases6(ClientContext6 &ctx)
Renews existing DHCPv6 leases for a given IA.
Definition alloc_engine.cc:2271
isc::dhcp::AllocEngine::HintContainer
std::vector< Resource > HintContainer
Container for client's hints.
Definition alloc_engine.h:185
isc::dhcp::Allocator::PrefixLenMatchType
PrefixLenMatchType
Type of preferred PD-pool prefix length selection criteria.
Definition allocator.h:61
isc::dhcp::Host::IdentifierType
IdentifierType
Type of the host identifier.
Definition host.h:337
isc::dhcp::IPv6Resrv
IPv6 reservation for a host.
Definition host.h:163
isc::dhcp::IPv6Resrv::TYPE_PD
@ TYPE_PD
Definition host.h:171
isc::dhcp::IPv6Resrv::TYPE_NA
@ TYPE_NA
Definition host.h:170
isc::hooks::CalloutHandle::CalloutNextStep
CalloutNextStep
Specifies allowed next steps.
Definition callout_handle.h:86
isc::util::ReadWriteMutex
Read-Write Mutex.
Definition readwrite_mutex.h:29
d2_client_cfg.h
Defines the D2ClientConfig class.
duid.h
host.h
hwaddr.h
io_address.h
lease_mgr.h
An abstract API for lease database.
multi_threading_mgr.h
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::ConstSubnet6Ptr
boost::shared_ptr< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
Definition subnet.h:620
isc::dhcp::ConstSubnet4Ptr
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
Definition subnet.h:455
isc::dhcp::Pkt4Ptr
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition pkt4.h:556
isc::dhcp::DuidPtr
boost::shared_ptr< DUID > DuidPtr
Definition duid.h:136
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::AllocEnginePtr
boost::shared_ptr< AllocEngine > AllocEnginePtr
A pointer to the AllocEngine object.
Definition alloc_engine.h:1929
isc::dhcp::Option6IAPtr
boost::shared_ptr< Option6IA > Option6IAPtr
A pointer to the Option6IA object.
Definition option6_ia.h:20
isc::dhcp::DdnsParamsPtr
boost::shared_ptr< DdnsParams > DdnsParamsPtr
Defines a pointer for DdnsParams instances.
Definition ddns_params.h:191
isc::dhcp::Option6IAPrefixPtr
boost::shared_ptr< Option6IAPrefix > Option6IAPrefixPtr
Pointer to the Option6IAPrefix object.
Definition option6_iaprefix.h:155
isc::dhcp::HWAddrPtr
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
Definition hwaddr.h:154
isc::dhcp::SharedNetwork6Ptr
boost::shared_ptr< SharedNetwork6 > SharedNetwork6Ptr
Pointer to SharedNetwork6 object.
Definition shared_network.h:267
isc::dhcp::ClientIdPtr
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
Definition duid.h:216
isc::dhcp::Option6IAAddrPtr
boost::shared_ptr< Option6IAAddr > Option6IAAddrPtr
A pointer to the isc::dhcp::Option6IAAddr object.
Definition option6_iaaddr.h:20
isc::dhcp::ConstHostPtr
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition host.h:840
isc::dhcp::ConstSubnetPtr
boost::shared_ptr< const Subnet > ConstSubnetPtr
A generic pointer to either const Subnet4 or const Subnet6 object.
Definition subnet.h:449
isc::dhcp::Pkt6Ptr
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Definition pkt6.h:31
isc::dhcp::Lease4Ptr
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition lease.h:315
isc::hooks::CalloutHandlePtr
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
Definition callout_handle.h:470
isc::util::uint128_t
boost::multiprecision::checked_uint128_t uint128_t
Definition bigints.h:21
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
option6_ia.h
option6_iaaddr.h
option6_iaprefix.h
pkt4.h
pkt6.h
readwrite_mutex.h
Standard implementation of read-write mutexes with writer preference using C++11 mutex and condition ...
srv_config.h
isc::dhcp::AllocEngine::ClientContext4
Context information for the DHCPv4 lease allocation.
Definition alloc_engine.h:1249
isc::dhcp::AllocEngine::ClientContext4::clientid_
ClientIdPtr clientid_
Client identifier from the DHCP message.
Definition alloc_engine.h:1259
isc::dhcp::AllocEngine::ClientContext4::getDdnsParams
DdnsParamsPtr getDdnsParams()
Returns the set of DDNS behavioral parameters based on the selected subnet.
Definition alloc_engine.cc:3908
isc::dhcp::AllocEngine::ClientContext4::early_global_reservations_lookup_
bool early_global_reservations_lookup_
Indicates if early global reservation is enabled.
Definition alloc_engine.h:1253
isc::dhcp::AllocEngine::ClientContext4::currentHost
ConstHostPtr currentHost() const
Returns host for currently selected subnet.
Definition alloc_engine.cc:3884
isc::dhcp::AllocEngine::ClientContext4::ClientContext4
ClientContext4()
Default constructor.
Definition alloc_engine.cc:3847
isc::dhcp::AllocEngine::ClientContext4::query_
Pkt4Ptr query_
A pointer to the client's message.
Definition alloc_engine.h:1320
isc::dhcp::AllocEngine::ClientContext4::new_lease_
Lease4Ptr new_lease_
A pointer to a newly allocated lease.
Definition alloc_engine.h:1300
isc::dhcp::AllocEngine::ClientContext4::hostname_
std::string hostname_
Hostname.
Definition alloc_engine.h:1280
isc::dhcp::AllocEngine::ClientContext4::hosts_
std::map< SubnetID, ConstHostPtr > hosts_
Holds a map of hosts belonging to the client within different subnets.
Definition alloc_engine.h:1307
isc::dhcp::AllocEngine::ClientContext4::subnet_
ConstSubnet4Ptr subnet_
Subnet selected for the client by the server.
Definition alloc_engine.h:1256
isc::dhcp::AllocEngine::ClientContext4::rev_dns_update_
bool rev_dns_update_
Perform reverse DNS update.
Definition alloc_engine.h:1274
isc::dhcp::AllocEngine::ClientContext4::offer_lft_
uint32_t offer_lft_
If not zero, then we will allocate on DISCOVER for this amount of time.
Definition alloc_engine.h:1294
isc::dhcp::AllocEngine::ClientContext4::fake_allocation_
bool fake_allocation_
Indicates if this is a real or fake allocation.
Definition alloc_engine.h:1290
isc::dhcp::AllocEngine::ClientContext4::callout_handle_
hooks::CalloutHandlePtr callout_handle_
Callout handle associated with the client's message.
Definition alloc_engine.h:1283
isc::dhcp::AllocEngine::ClientContext4::unknown_requested_addr_
bool unknown_requested_addr_
True when the address DHCPREQUEST'ed by client is not within a dynamic pool the server knows about.
Definition alloc_engine.h:1328
isc::dhcp::AllocEngine::ClientContext4::old_lease_
Lease4Ptr old_lease_
A pointer to an old lease that the client had before update.
Definition alloc_engine.h:1297
isc::dhcp::AllocEngine::ClientContext4::globalHost
ConstHostPtr globalHost() const
Returns global host reservation if there is one.
Definition alloc_engine.cc:3896
isc::dhcp::AllocEngine::ClientContext4::fwd_dns_update_
bool fwd_dns_update_
Perform forward DNS update.
Definition alloc_engine.h:1271
isc::dhcp::AllocEngine::ClientContext4::requested_address_
asiolink::IOAddress requested_address_
An address that the client desires.
Definition alloc_engine.h:1268
isc::dhcp::AllocEngine::ClientContext4::conflicting_lease_
Lease4Ptr conflicting_lease_
A pointer to the object representing a lease in conflict.
Definition alloc_engine.h:1314
isc::dhcp::AllocEngine::ClientContext4::addHostIdentifier
void addHostIdentifier(const Host::IdentifierType &id_type, const std::vector< uint8_t > &identifier)
Convenience function adding host identifier into host_identifiers_ list.
Definition alloc_engine.h:1345
isc::dhcp::AllocEngine::ClientContext4::host_identifiers_
IdentifierList host_identifiers_
A list holding host identifiers extracted from a message received by the server.
Definition alloc_engine.h:1324
isc::dhcp::AllocEngine::ClientContext4::hwaddr_
HWAddrPtr hwaddr_
HW address from the DHCP message.
Definition alloc_engine.h:1262
isc::dhcp::AllocEngine::ClientContext6::IAContext
Parameters pertaining to individual IAs.
Definition alloc_engine.h:293
isc::dhcp::AllocEngine::ClientContext6::IAContext::IAContext
IAContext()
Default constructor.
Definition alloc_engine.cc:227
isc::dhcp::AllocEngine::ClientContext6::IAContext::old_leases_
Lease6Collection old_leases_
A pointer to any old leases that the client had before update but are no longer valid after the updat...
Definition alloc_engine.h:315
isc::dhcp::AllocEngine::ClientContext6::IAContext::ia_rsp_
Option6IAPtr ia_rsp_
A pointer to the IA_NA/IA_PD option to be sent in response.
Definition alloc_engine.h:335
isc::dhcp::AllocEngine::ClientContext6::IAContext::type_
Lease::Type type_
Lease type (IA or PD).
Definition alloc_engine.h:300
isc::dhcp::AllocEngine::ClientContext6::IAContext::new_resources_
ResourceContainer new_resources_
Holds addresses and prefixes allocated for this IA.
Definition alloc_engine.h:331
isc::dhcp::AllocEngine::ClientContext6::IAContext::isNewResource
bool isNewResource(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128) const
Checks if specified address or prefix was new.
Definition alloc_engine.cc:270
isc::dhcp::AllocEngine::ClientContext6::IAContext::changed_leases_
Lease6Collection changed_leases_
A pointer to any leases that have changed FQDN information.
Definition alloc_engine.h:323
isc::dhcp::AllocEngine::ClientContext6::IAContext::addHint
void addHint(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128, const uint32_t preferred=0, const uint32_t valid=0)
Convenience method adding new hint.
Definition alloc_engine.cc:234
isc::dhcp::AllocEngine::ClientContext6::IAContext::addNewResource
void addNewResource(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128)
Convenience method adding new prefix or address.
Definition alloc_engine.cc:263
isc::dhcp::AllocEngine::ClientContext6::IAContext::reused_leases_
Lease6Collection reused_leases_
Set of leases marked for reuse by lease caching.
Definition alloc_engine.h:326
isc::dhcp::AllocEngine::ClientContext6::IAContext::hints_
HintContainer hints_
Client's hints.
Definition alloc_engine.h:306
isc::dhcp::AllocEngine::ClientContext6::IAContext::iaid_
uint32_t iaid_
The IAID field from IA_NA or IA_PD that is being processed.
Definition alloc_engine.h:297
isc::dhcp::AllocEngine::ClientContext6
Context information for the DHCPv6 leases allocation.
Definition alloc_engine.h:218
isc::dhcp::AllocEngine::ClientContext6::currentIA
IAContext & currentIA()
Returns IA specific context for the currently processed IA.
Definition alloc_engine.h:423
isc::dhcp::AllocEngine::ClientContext6::ias_
std::vector< IAContext > ias_
Container holding IA specific contexts.
Definition alloc_engine.h:383
isc::dhcp::AllocEngine::ClientContext6::addHostIdentifier
void addHostIdentifier(const Host::IdentifierType &id_type, const std::vector< uint8_t > &identifier)
Convenience function adding host identifier into host_identifiers_ list.
Definition alloc_engine.h:413
isc::dhcp::AllocEngine::ClientContext6::fake_allocation_
bool fake_allocation_
Indicates if this is a real or fake allocation.
Definition alloc_engine.h:233
isc::dhcp::AllocEngine::ClientContext6::currentHost
ConstHostPtr currentHost() const
Returns host from the most preferred subnet.
Definition alloc_engine.cc:292
isc::dhcp::AllocEngine::ClientContext6::ClientContext6
ClientContext6()
Default constructor.
Definition alloc_engine.cc:198
isc::dhcp::AllocEngine::ClientContext6::duid_
DuidPtr duid_
Client identifier.
Definition alloc_engine.h:249
isc::dhcp::AllocEngine::ClientContext6::addAllocatedResource
void addAllocatedResource(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128)
Convenience method adding allocated prefix or address.
Definition alloc_engine.cc:278
isc::dhcp::AllocEngine::ClientContext6::new_leases_
Lease6Collection new_leases_
A collection of newly allocated leases.
Definition alloc_engine.h:288
isc::dhcp::AllocEngine::ClientContext6::getIAContexts
std::vector< IAContext > & getIAContexts()
Definition alloc_engine.h:430
isc::dhcp::AllocEngine::ClientContext6::hwaddr_
HWAddrPtr hwaddr_
Hardware/MAC address (if available, may be NULL).
Definition alloc_engine.h:252
isc::dhcp::AllocEngine::ClientContext6::callout_handle_
hooks::CalloutHandlePtr callout_handle_
Callout handle associated with the client's message.
Definition alloc_engine.h:282
isc::dhcp::AllocEngine::ClientContext6::isAllocated
bool isAllocated(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128) const
Checks if specified address or prefix was allocated.
Definition alloc_engine.cc:286
isc::dhcp::AllocEngine::ClientContext6::hasGlobalReservation
bool hasGlobalReservation(const IPv6Resrv &resv) const
Determines if a global reservation exists.
Definition alloc_engine.cc:318
isc::dhcp::AllocEngine::ClientContext6::allocated_resources_
ResourceContainer allocated_resources_
Holds addresses and prefixes allocated for all IAs.
Definition alloc_engine.h:285
isc::dhcp::AllocEngine::ClientContext6::rev_dns_update_
bool rev_dns_update_
A boolean value which indicates that server takes responsibility for the reverse DNS Update for this ...
Definition alloc_engine.h:273
isc::dhcp::AllocEngine::ClientContext6::getDdnsParams
DdnsParamsPtr getDdnsParams()
Returns the set of DDNS behavioral parameters based on the selected subnet.
Definition alloc_engine.cc:324
isc::dhcp::AllocEngine::ClientContext6::globalHost
ConstHostPtr globalHost() const
Returns global host reservation if there is one.
Definition alloc_engine.cc:305
isc::dhcp::AllocEngine::ClientContext6::query_
Pkt6Ptr query_
A pointer to the client's message.
Definition alloc_engine.h:226
isc::dhcp::AllocEngine::ClientContext6::early_global_reservations_lookup_
bool early_global_reservations_lookup_
Indicates if early global reservation is enabled.
Definition alloc_engine.h:238
isc::dhcp::AllocEngine::ClientContext6::hostname_
std::string hostname_
Hostname.
Definition alloc_engine.h:279
isc::dhcp::AllocEngine::ClientContext6::createIAContext
void createIAContext()
Creates new IA context.
Definition alloc_engine.h:438
isc::dhcp::AllocEngine::ClientContext6::host_subnet_
ConstSubnet6Ptr host_subnet_
Subnet from which host reservations should be retrieved.
Definition alloc_engine.h:246
isc::dhcp::AllocEngine::ClientContext6::host_identifiers_
IdentifierList host_identifiers_
A list holding host identifiers extracted from a message received by the server.
Definition alloc_engine.h:256
isc::dhcp::AllocEngine::ClientContext6::subnet_
ConstSubnet6Ptr subnet_
Subnet selected for the client by the server.
Definition alloc_engine.h:241
isc::dhcp::AllocEngine::ClientContext6::hosts_
std::map< SubnetID, ConstHostPtr > hosts_
Holds a map of hosts belonging to the client within different subnets.
Definition alloc_engine.h:263
isc::dhcp::AllocEngine::ClientContext6::fwd_dns_update_
bool fwd_dns_update_
A boolean value which indicates that server takes responsibility for the forward DNS Update for this ...
Definition alloc_engine.h:268
isc::dhcp::AllocEngine::ResourceCompare
Resource compare class.
Definition alloc_engine.h:167
isc::dhcp::AllocEngine::ResourceCompare::operator()
bool operator()(const Resource &lhr, const Resource &rhr) const
Compare operator.
Definition alloc_engine.h:175
isc::dhcp::Lease6
Structure that holds a lease for IPv6 address and/or prefix.
Definition lease.h:536
isc::dhcp::Lease6::type_
Lease::Type type_
Lease type.
Definition lease.h:541
isc::dhcp::Lease6::prefixlen_
uint8_t prefixlen_
IPv6 prefix length.
Definition lease.h:546
isc::dhcp::Lease::Type
Type
Type of lease or pool.
Definition lease.h:46
isc::dhcp::Lease::TYPE_NA
@ TYPE_NA
the lease contains non-temporary IPv6 address
Definition lease.h:47
isc::dhcp::Lease::addr_
isc::asiolink::IOAddress addr_
IPv4 ot IPv6 address.
Definition lease.h:126
subnet.h