Kea: alloc_engine.h Source File

| Kea 3.0.2-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);
823private:
824
860 Lease6Ptr createLease6(ClientContext6& ctx,
861 const isc::asiolink::IOAddress& addr,
862 const uint8_t prefix_len,
863 hooks::CalloutHandle::CalloutNextStep& callout_status);
864
879 Lease6Collection allocateUnreservedLeases6(ClientContext6& ctx);
880
921 Lease6Ptr allocateBestMatch(ClientContext6& ctx,
922 Lease6Ptr& hint_lease,
923 bool& search_hint_lease,
924 const isc::asiolink::IOAddress& hint,
925 uint8_t hint_prefix_length,
926 ConstSubnet6Ptr original_subnet,
927 SharedNetwork6Ptr& network,
928 uint64_t& total_attempts,
929 uint64_t& subnets_with_unavail_leases,
930 uint64_t& subnets_with_unavail_pools,
931 hooks::CalloutHandle::CalloutNextStep& callout_status,
932 Allocator::PrefixLenMatchType prefix_length_match);
933
950 void
951 allocateReservedLeases6(ClientContext6& ctx, Lease6Collection& existing_leases);
952
966 void
967 allocateGlobalReservedLeases6(ClientContext6& ctx, Lease6Collection& existing_leases);
968
977 void
978 removeNonmatchingReservedLeases6(ClientContext6& ctx,
979 Lease6Collection& existing_leases);
980
988 void
989 removeNonmatchingReservedNoHostLeases6(ClientContext6& ctx,
990 Lease6Collection& existing_leases);
991
1005 void
1006 removeNonreservedLeases6(ClientContext6& ctx,
1007 Lease6Collection& existing_leases);
1008
1041 Lease6Ptr
1042 reuseExpiredLease(Lease6Ptr& expired,
1043 ClientContext6& ctx,
1044 uint8_t prefix_len,
1045 hooks::CalloutHandle::CalloutNextStep& callout_status);
1046
1065 Lease6Collection updateLeaseData(ClientContext6& ctx,
1066 const Lease6Collection& leases);
1067
1073 static bool
1074 removeLeases(Lease6Collection& container,
1075 const asiolink::IOAddress& addr);
1076
1089 void extendLease6(ClientContext6& ctx, Lease6Ptr lease);
1090
1098 enum DbReclaimMode {
1099 DB_RECLAIM_REMOVE,
1100 DB_RECLAIM_UPDATE,
1101 DB_RECLAIM_LEAVE_UNCHANGED
1102 };
1103
1115 template<typename LeasePtrType>
1116 void reclaimExpiredLease(const LeasePtrType& lease,
1117 const bool remove_lease,
1118 const hooks::CalloutHandlePtr& callout_handle);
1119
1130 template<typename LeasePtrType>
1131 void reclaimExpiredLease(const LeasePtrType& lease,
1132 const hooks::CalloutHandlePtr& callout_handle);
1133
1144 void reclaimExpiredLease(const Lease6Ptr& lease,
1145 const DbReclaimMode& reclaim_mode,
1146 const hooks::CalloutHandlePtr& callout_handle);
1147
1158 void reclaimExpiredLease(const Lease4Ptr& lease,
1159 const DbReclaimMode& reclaim_mode,
1160 const hooks::CalloutHandlePtr& callout_handle);
1161
1180 template<typename LeasePtrType>
1181 void reclaimLeaseInDatabase(const LeasePtrType& lease,
1182 const bool remove_lease,
1183 const std::function<void (const LeasePtrType&)>&
1184 lease_update_fun) const;
1185
1198 bool reclaimDeclined(const Lease4Ptr& lease);
1199
1212 bool reclaimDeclined(const Lease6Ptr& lease);
1213
1214public:
1215
1233 struct ClientContext4 : public boost::noncopyable {
1237 bool early_global_reservations_lookup_;
1238
1240 ConstSubnet4Ptr subnet_;
1241
1243 ClientIdPtr clientid_;
1244
1246 HWAddrPtr hwaddr_;
1247
1252 asiolink::IOAddress requested_address_;
1253
1255 bool fwd_dns_update_;
1256
1258 bool rev_dns_update_;
1259
1264 std::string hostname_;
1265
1267 hooks::CalloutHandlePtr callout_handle_;
1268
1274 bool fake_allocation_;
1275
1278 uint32_t offer_lft_;
1279
1281 Lease4Ptr old_lease_;
1282
1284 Lease4Ptr new_lease_;
1285
1291 std::map<SubnetID, ConstHostPtr> hosts_;
1292
1298 Lease4Ptr conflicting_lease_;
1299
1304 Pkt4Ptr query_;
1305
1308 IdentifierList host_identifiers_;
1309
1312 bool unknown_requested_addr_;
1313
1321 DdnsParamsPtr getDdnsParams();
1322
1323
1329 void addHostIdentifier(const Host::IdentifierType& id_type,
1330 const std::vector<uint8_t>& identifier) {
1331 host_identifiers_.push_back(IdentifierPair(id_type, identifier));
1332 }
1333
1340 ConstHostPtr currentHost() const;
1341
1350 ConstHostPtr globalHost() const;
1351
1353 ClientContext4();
1354
1371 ClientContext4(const ConstSubnet4Ptr& subnet,
1372 const ClientIdPtr& clientid,
1373 const HWAddrPtr& hwaddr,
1374 const asiolink::IOAddress& requested_addr,
1375 const bool fwd_dns_update, const bool rev_dns_update,
1376 const std::string& hostname, const bool fake_allocation,
1377 const uint32_t offer_lft = 0);
1378 private:
1382 DdnsParamsPtr ddns_params_;
1383 };
1384
1386 typedef boost::shared_ptr<ClientContext4> ClientContext4Ptr;
1387
1493 Lease4Ptr allocateLease4(ClientContext4& ctx);
1494
1507 static void findReservation(ClientContext4& ctx);
1508
1519 static ConstHostPtr findGlobalReservation(ClientContext4& ctx);
1520
1538 static uint32_t getValidLft(const ClientContext4& ctx);
1539
1556 static uint32_t getOfferLft(const ClientContext4& ctx,
1557 bool only_on_discover = true);
1558private:
1559
1590 Lease4Ptr discoverLease4(ClientContext4& ctx);
1591
1629 Lease4Ptr requestLease4(ClientContext4& ctx);
1630
1660 Lease4Ptr createLease4(const ClientContext4& ctx,
1661 const isc::asiolink::IOAddress& addr,
1662 hooks::CalloutHandle::CalloutNextStep& callout_status);
1663
1677 Lease4Ptr renewLease4(const Lease4Ptr& lease, ClientContext4& ctx);
1678
1695 Lease4Ptr
1696 reuseExpiredLease4(Lease4Ptr& expired, ClientContext4& ctx,
1697 hooks::CalloutHandle::CalloutNextStep& callout_status);
1698
1714 Lease4Ptr
1715 allocateOrReuseLease4(const asiolink::IOAddress& address,
1716 ClientContext4& ctx,
1717 hooks::CalloutHandle::CalloutNextStep& callout_status);
1718
1737 Lease4Ptr allocateUnreservedLease4(ClientContext4& ctx);
1738
1761 bool updateLease4Information(const Lease4Ptr& lease,
1762 ClientContext4& ctx) const;
1763
1764protected:
1781 bool updateLease4ExtendedInfo(const Lease4Ptr& lease,
1782 const ClientContext4& ctx) const;
1783
1799 void updateLease6ExtendedInfo(const Lease6Ptr& lease,
1800 const ClientContext6& ctx) const;
1801
1805 void clearReclaimedExtendedInfo(const Lease4Ptr& lease) const;
1806
1810 void clearReclaimedExtendedInfo(const Lease6Ptr& lease) const;
1811
1812private:
1813
1827 void setLeaseReusable(const Lease4Ptr& lease,
1828 const ClientContext4& ctx) const;
1829
1844 void setLeaseReusable(const Lease6Ptr& lease,
1845 uint32_t current_preferred_lft,
1846 const ClientContext6& ctx) const;
1847
1848private:
1849
1852 uint16_t incomplete_v4_reclamations_;
1853
1856 uint16_t incomplete_v6_reclamations_;
1857
1858public:
1859
1865 isc::util::ReadWriteMutex& getReadWriteMutex() {
1866 return (rw_mutex_);
1867 }
1868
1870 isc::util::ReadWriteMutex rw_mutex_;
1871
1880 static std::string labelNetworkOrSubnet(ConstSubnetPtr subnet);
1881};
1882
1884 typedef boost::shared_ptr<AllocEngine> AllocEnginePtr;
1885
1886} // namespace dhcp
1887} // namespace isc
1888
1889#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:45
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:1386
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:5085
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:2570
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:5029
isc::dhcp::AllocEngine::getReadWriteMutex
isc::util::ReadWriteMutex & getReadWriteMutex()
Get the read-write mutex.
Definition alloc_engine.h:1865
isc::dhcp::AllocEngine::findGlobalReservation
static ConstHostPtr findGlobalReservation(ClientContext6 &ctx)
Attempts to find the host reservation for the client.
Definition alloc_engine.cc:445
isc::dhcp::AllocEngine::AllocEngine
AllocEngine(isc::util::uint128_t const &attempts)
Constructor.
Definition alloc_engine.cc:95
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:3296
isc::dhcp::AllocEngine::rw_mutex_
isc::util::ReadWriteMutex rw_mutex_
The read-write mutex.
Definition alloc_engine.h:1870
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:1895
isc::dhcp::AllocEngine::findReservation
static void findReservation(ClientContext6 &ctx)
Definition alloc_engine.cc:341
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:4231
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:2733
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:3129
isc::dhcp::AllocEngine::getValidLft
static uint32_t getValidLft(const ClientContext4 &ctx)
Returns the valid lifetime based on the v4 context.
Definition alloc_engine.cc:4266
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:2549
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:3346
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:2712
isc::dhcp::AllocEngine::allocateLease4
Lease4Ptr allocateLease4(ClientContext4 &ctx)
Returns IPv4 lease.
Definition alloc_engine.cc:3722
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:2690
isc::dhcp::AllocEngine::allocateLeases6
Lease6Collection allocateLeases6(ClientContext6 &ctx)
Allocates IPv6 leases for a given IA container.
Definition alloc_engine.cc:462
isc::dhcp::AllocEngine::renewLeases6
Lease6Collection renewLeases6(ClientContext6 &ctx)
Renews existing DHCPv6 leases for a given IA.
Definition alloc_engine.cc:2102
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:623
isc::dhcp::ConstSubnet4Ptr
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
Definition subnet.h:458
isc::dhcp::Pkt4Ptr
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition pkt4.h:555
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:1884
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:143
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:452
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 agent_parser.cc:148
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:1233
isc::dhcp::AllocEngine::ClientContext4::clientid_
ClientIdPtr clientid_
Client identifier from the DHCP message.
Definition alloc_engine.h:1243
isc::dhcp::AllocEngine::ClientContext4::getDdnsParams
DdnsParamsPtr getDdnsParams()
Returns the set of DDNS behavioral parameters based on the selected subnet.
Definition alloc_engine.cc:3704
isc::dhcp::AllocEngine::ClientContext4::early_global_reservations_lookup_
bool early_global_reservations_lookup_
Indicates if early global reservation is enabled.
Definition alloc_engine.h:1237
isc::dhcp::AllocEngine::ClientContext4::currentHost
ConstHostPtr currentHost() const
Returns host for currently selected subnet.
Definition alloc_engine.cc:3680
isc::dhcp::AllocEngine::ClientContext4::ClientContext4
ClientContext4()
Default constructor.
Definition alloc_engine.cc:3643
isc::dhcp::AllocEngine::ClientContext4::query_
Pkt4Ptr query_
A pointer to the client's message.
Definition alloc_engine.h:1304
isc::dhcp::AllocEngine::ClientContext4::new_lease_
Lease4Ptr new_lease_
A pointer to a newly allocated lease.
Definition alloc_engine.h:1284
isc::dhcp::AllocEngine::ClientContext4::hostname_
std::string hostname_
Hostname.
Definition alloc_engine.h:1264
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:1291
isc::dhcp::AllocEngine::ClientContext4::subnet_
ConstSubnet4Ptr subnet_
Subnet selected for the client by the server.
Definition alloc_engine.h:1240
isc::dhcp::AllocEngine::ClientContext4::rev_dns_update_
bool rev_dns_update_
Perform reverse DNS update.
Definition alloc_engine.h:1258
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:1278
isc::dhcp::AllocEngine::ClientContext4::fake_allocation_
bool fake_allocation_
Indicates if this is a real or fake allocation.
Definition alloc_engine.h:1274
isc::dhcp::AllocEngine::ClientContext4::callout_handle_
hooks::CalloutHandlePtr callout_handle_
Callout handle associated with the client's message.
Definition alloc_engine.h:1267
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:1312
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:1281
isc::dhcp::AllocEngine::ClientContext4::globalHost
ConstHostPtr globalHost() const
Returns global host reservation if there is one.
Definition alloc_engine.cc:3692
isc::dhcp::AllocEngine::ClientContext4::fwd_dns_update_
bool fwd_dns_update_
Perform forward DNS update.
Definition alloc_engine.h:1255
isc::dhcp::AllocEngine::ClientContext4::requested_address_
asiolink::IOAddress requested_address_
An address that the client desires.
Definition alloc_engine.h:1252
isc::dhcp::AllocEngine::ClientContext4::conflicting_lease_
Lease4Ptr conflicting_lease_
A pointer to the object representing a lease in conflict.
Definition alloc_engine.h:1298
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:1329
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:1308
isc::dhcp::AllocEngine::ClientContext4::hwaddr_
HWAddrPtr hwaddr_
HW address from the DHCP message.
Definition alloc_engine.h:1246
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:226
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:269
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:233
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:262
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:291
isc::dhcp::AllocEngine::ClientContext6::ClientContext6
ClientContext6()
Default constructor.
Definition alloc_engine.cc:197
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:277
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:285
isc::dhcp::AllocEngine::ClientContext6::hasGlobalReservation
bool hasGlobalReservation(const IPv6Resrv &resv) const
Determines if a global reservation exists.
Definition alloc_engine.cc:317
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:323
isc::dhcp::AllocEngine::ClientContext6::globalHost
ConstHostPtr globalHost() const
Returns global host reservation if there is one.
Definition alloc_engine.cc:304
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