Kea  1.9.9-git
alloc_engine.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2021 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/d2_client_cfg.h>
20 #include <dhcpsrv/host.h>
21 #include <dhcpsrv/subnet.h>
22 #include <dhcpsrv/lease_mgr.h>
23 #include <dhcpsrv/srv_config.h>
24 #include <hooks/callout_handle.h>
26 #include <util/readwrite_mutex.h>
27 
28 #include <boost/shared_ptr.hpp>
29 #include <boost/noncopyable.hpp>
30 
31 #include <functional>
32 #include <list>
33 #include <map>
34 #include <mutex>
35 #include <set>
36 #include <utility>
37 
38 namespace isc {
39 namespace dhcp {
40 
43 class AllocFailed : public isc::Exception {
44 public:
45 
51  AllocFailed(const char* file, size_t line, const char* what)
52  : isc::Exception(file, line, what) {}
53 };
54 
63 class AllocEngine : public boost::noncopyable {
64 protected:
65 
70  class Allocator {
71  public:
72 
98  pickAddress(const SubnetPtr& subnet,
99  const ClientClasses& client_classes,
100  const DuidPtr& duid,
101  const isc::asiolink::IOAddress& hint) {
102  if (isc::util::MultiThreadingMgr::instance().getMode()) {
103  std::lock_guard<std::mutex> lock(mutex_);
104  return pickAddressInternal(subnet, client_classes, duid, hint);
105  } else {
106  return pickAddressInternal(subnet, client_classes, duid, hint);
107  }
108  }
109 
114  Allocator(Lease::Type pool_type) : pool_type_(pool_type) {
115  }
116 
118  virtual ~Allocator() {
119  }
120 
121  private:
123  pickAddressInternal(const SubnetPtr& subnet,
124  const ClientClasses& client_classes,
125  const DuidPtr& duid,
126  const isc::asiolink::IOAddress& hint) = 0;
127 
128  protected:
129 
132 
133  private:
134 
136  std::mutex mutex_;
137  };
138 
140  typedef boost::shared_ptr<Allocator> AllocatorPtr;
141 
148  class IterativeAllocator : public Allocator {
149  public:
150 
156 
157  private:
158 
168  pickAddressInternal(const SubnetPtr& subnet,
169  const ClientClasses& client_classes,
170  const DuidPtr& duid,
171  const isc::asiolink::IOAddress& hint);
172 
173  protected:
174 
188  const uint8_t prefix_len);
189 
202  bool prefix, const uint8_t prefix_len);
203  };
204 
208  class HashedAllocator : public Allocator {
209  public:
210 
215 
216  private:
217 
229  pickAddressInternal(const SubnetPtr& subnet,
230  const ClientClasses& client_classes,
231  const DuidPtr& duid,
232  const isc::asiolink::IOAddress& hint);
233  };
234 
238  class RandomAllocator : public Allocator {
239  public:
240 
245 
246  private:
247 
259  pickAddressInternal(const SubnetPtr& subnet,
260  const ClientClasses& client_classes,
261  const DuidPtr& duid,
262  const isc::asiolink::IOAddress& hint);
263  };
264 
265 public:
266 
268  typedef enum {
269  ALLOC_ITERATIVE, // iterative - one address after another
270  ALLOC_HASHED, // hashed - client's DUID/client-id is hashed
271  ALLOC_RANDOM // random - an address is randomly selected
272  } AllocType;
273 
285  AllocEngine(AllocType engine_type, uint64_t attempts, bool ipv6 = true);
286 
288  virtual ~AllocEngine() { }
289 
297  AllocatorPtr getAllocator(Lease::Type type);
298 
299 private:
300 
305  std::map<Lease::Type, AllocatorPtr> allocators_;
306 
308  uint64_t attempts_;
309 
311  int hook_index_lease4_select_;
312  int hook_index_lease6_select_;
313 
314 public:
315 
324  class Resource {
325  public:
326 
336  const uint8_t prefix_len,
337  const uint32_t preferred = 0,
338  const uint32_t valid = 0)
339  : address_(address), prefix_len_(prefix_len),
340  preferred_(preferred), valid_(valid) {
341  }
342 
347  return (address_);
348  }
349 
353  uint8_t getPrefixLength() const {
354  return (prefix_len_);
355  }
356 
360  uint32_t getPreferred() const {
361  return (preferred_);
362  }
363 
367  uint32_t getValid() const {
368  return (valid_);
369  }
370 
376  bool equals(const Resource& other) const {
377  return (address_ == other.address_ &&
378  prefix_len_ == other.prefix_len_);
379  }
380 
386  bool operator==(const Resource& other) const {
387  return (equals(other));
388  }
389 
390  protected:
391 
394 
396  uint8_t prefix_len_;
397 
399  uint32_t preferred_;
400 
402  uint32_t valid_;
403  };
404 
416  bool operator() (const Resource& lhr, const Resource& rhr) const {
417  if (lhr.getAddress() == rhr.getAddress()) {
418  return (lhr.getPrefixLength() < rhr.getPrefixLength());
419  } else {
420  return (lhr.getAddress() < rhr.getAddress());
421  }
422  }
423  };
424 
426  typedef std::vector<Resource> HintContainer;
427 
429  typedef std::set<Resource, ResourceCompare> ResourceContainer;
430 
432  typedef std::pair<Host::IdentifierType, std::vector<uint8_t> > IdentifierPair;
433 
435  typedef std::list<IdentifierPair> IdentifierList;
436 
459  struct ClientContext6 : public boost::noncopyable {
460 
462 
463 
468 
475 
478 
483 
486 
489 
492  IdentifierList host_identifiers_;
493 
499  std::map<SubnetID, ConstHostPtr> hosts_;
500 
505 
510 
515  std::string hostname_;
516 
519 
521  ResourceContainer allocated_resources_;
522 
525 
527 
529  struct IAContext {
530 
533  uint32_t iaid_;
534 
537 
542  HintContainer hints_;
543 
552 
560 
564  ResourceContainer new_resources_;
565 
569 
573  IAContext();
574 
581  void addHint(const asiolink::IOAddress& prefix,
582  const uint8_t prefix_len = 128,
583  const uint32_t preferred = 0,
584  const uint32_t valid = 0);
585 
591  void addHint(const Option6IAAddrPtr& iaaddr);
592 
598  void addHint(const Option6IAPrefixPtr& iaprefix);
599 
604  void addNewResource(const asiolink::IOAddress& prefix,
605  const uint8_t prefix_len = 128);
606 
611  bool isNewResource(const asiolink::IOAddress& prefix,
612  const uint8_t prefix_len = 128) const;
613  };
614 
616  std::vector<IAContext> ias_;
617 
626 
631  void addAllocatedResource(const asiolink::IOAddress& prefix,
632  const uint8_t prefix_len = 128);
633 
638  bool isAllocated(const asiolink::IOAddress& prefix,
639  const uint8_t prefix_len = 128) const;
640 
647  const std::vector<uint8_t>& identifier) {
648  host_identifiers_.push_back(IdentifierPair(id_type, identifier));
649  }
650 
657  if (ias_.empty()) {
658  createIAContext();
659  }
660  return (ias_.back());
661  }
662 
668  ias_.push_back(IAContext());
669  };
670 
677  ConstHostPtr currentHost() const;
678 
687  ConstHostPtr globalHost() const;
688 
694  bool hasGlobalReservation(const IPv6Resrv& resv) const;
695 
697  ClientContext6();
698 
720  ClientContext6(const Subnet6Ptr& subnet, const DuidPtr& duid,
721  const bool fwd_dns, const bool rev_dns,
722  const std::string& hostname, const bool fake_allocation,
723  const Pkt6Ptr& query,
724  const hooks::CalloutHandlePtr& callout_handle =
726 
727  private:
731  DdnsParamsPtr ddns_params_;
732  };
733 
816  allocateLeases6(ClientContext6& ctx);
817 
838  Lease6Collection renewLeases6(ClientContext6& ctx);
839 
888  void reclaimExpiredLeases6(const size_t max_leases, const uint16_t timeout,
889  const bool remove_lease,
890  const uint16_t max_unwarned_cycles = 0);
891 
897  void deleteExpiredReclaimedLeases6(const uint32_t secs);
898 
947  void reclaimExpiredLeases4(const size_t max_leases, const uint16_t timeout,
948  const bool remove_lease,
949  const uint16_t max_unwarned_cycles = 0);
950 
956  void deleteExpiredReclaimedLeases4(const uint32_t secs);
957 
971  static void findReservation(ClientContext6& ctx);
972 
983  static ConstHostPtr findGlobalReservation(ClientContext6& ctx);
984 
990  static IPv6Resrv makeIPv6Resrv(const Lease6& lease) {
991  if (lease.type_ == Lease::TYPE_NA) {
992  return (IPv6Resrv(IPv6Resrv::TYPE_NA, lease.addr_,
993  (lease.prefixlen_ ? lease.prefixlen_ : 128)));
994  }
995 
996  return (IPv6Resrv(IPv6Resrv::TYPE_PD, lease.addr_, lease.prefixlen_));
997  }
998 
999 private:
1000 
1036  Lease6Ptr createLease6(ClientContext6& ctx,
1037  const isc::asiolink::IOAddress& addr,
1038  const uint8_t prefix_len,
1039  hooks::CalloutHandle::CalloutNextStep& callout_status);
1040 
1055  Lease6Collection allocateUnreservedLeases6(ClientContext6& ctx);
1056 
1073  void
1074  allocateReservedLeases6(ClientContext6& ctx, Lease6Collection& existing_leases);
1075 
1089  void
1090  allocateGlobalReservedLeases6(ClientContext6& ctx, Lease6Collection& existing_leases);
1091 
1100  void
1101  removeNonmatchingReservedLeases6(ClientContext6& ctx,
1102  Lease6Collection& existing_leases);
1103 
1111  void
1112  removeNonmatchingReservedNoHostLeases6(ClientContext6& ctx,
1113  Lease6Collection& existing_leases);
1114 
1128  void
1129  removeNonreservedLeases6(ClientContext6& ctx,
1130  Lease6Collection& existing_leases);
1131 
1164  Lease6Ptr
1165  reuseExpiredLease(Lease6Ptr& expired,
1166  ClientContext6& ctx,
1167  uint8_t prefix_len,
1168  hooks::CalloutHandle::CalloutNextStep& callout_status);
1169 
1188  Lease6Collection updateLeaseData(ClientContext6& ctx,
1189  const Lease6Collection& leases);
1190 
1196  static bool
1197  removeLeases(Lease6Collection& container,
1198  const asiolink::IOAddress& addr);
1199 
1212  void extendLease6(ClientContext6& ctx, Lease6Ptr lease);
1213 
1221  enum DbReclaimMode {
1222  DB_RECLAIM_REMOVE,
1223  DB_RECLAIM_UPDATE,
1224  DB_RECLAIM_LEAVE_UNCHANGED
1225  };
1226 
1238  template<typename LeasePtrType>
1239  void reclaimExpiredLease(const LeasePtrType& lease,
1240  const bool remove_lease,
1241  const hooks::CalloutHandlePtr& callout_handle);
1242 
1253  template<typename LeasePtrType>
1254  void reclaimExpiredLease(const LeasePtrType& lease,
1255  const hooks::CalloutHandlePtr& callout_handle);
1256 
1267  void reclaimExpiredLease(const Lease6Ptr& lease,
1268  const DbReclaimMode& reclaim_mode,
1269  const hooks::CalloutHandlePtr& callout_handle);
1270 
1281  void reclaimExpiredLease(const Lease4Ptr& lease,
1282  const DbReclaimMode& reclaim_mode,
1283  const hooks::CalloutHandlePtr& callout_handle);
1284 
1303  template<typename LeasePtrType>
1304  void reclaimLeaseInDatabase(const LeasePtrType& lease,
1305  const bool remove_lease,
1306  const std::function<void (const LeasePtrType&)>&
1307  lease_update_fun) const;
1308 
1321  bool reclaimDeclined(const Lease4Ptr& lease);
1322 
1335  bool reclaimDeclined(const Lease6Ptr& lease);
1336 
1337 public:
1338 
1356  struct ClientContext4 : public boost::noncopyable {
1359 
1362 
1365 
1371 
1374 
1377 
1382  std::string hostname_;
1383 
1386 
1393 
1396 
1399 
1405  std::map<SubnetID, ConstHostPtr> hosts_;
1406 
1413 
1419 
1422  IdentifierList host_identifiers_;
1423 
1432 
1439  const std::vector<uint8_t>& identifier) {
1440  host_identifiers_.push_back(IdentifierPair(id_type, identifier));
1441  }
1442 
1449  ConstHostPtr currentHost() const;
1450 
1459  ConstHostPtr globalHost() const;
1460 
1462  ClientContext4();
1463 
1478  ClientContext4(const Subnet4Ptr& subnet, const ClientIdPtr& clientid,
1479  const HWAddrPtr& hwaddr,
1480  const asiolink::IOAddress& requested_addr,
1481  const bool fwd_dns_update, const bool rev_dns_update,
1482  const std::string& hostname, const bool fake_allocation);
1483 
1484  private:
1488  DdnsParamsPtr ddns_params_;
1489  };
1490 
1492  typedef boost::shared_ptr<ClientContext4> ClientContext4Ptr;
1493 
1600 
1613  static void findReservation(ClientContext4& ctx);
1614 
1626 
1644  static uint32_t getValidLft(const ClientContext4& ctx);
1645 
1646 private:
1647 
1678  Lease4Ptr discoverLease4(ClientContext4& ctx);
1679 
1717  Lease4Ptr requestLease4(ClientContext4& ctx);
1718 
1748  Lease4Ptr createLease4(const ClientContext4& ctx,
1749  const isc::asiolink::IOAddress& addr,
1750  hooks::CalloutHandle::CalloutNextStep& callout_status);
1751 
1765  Lease4Ptr renewLease4(const Lease4Ptr& lease, ClientContext4& ctx);
1766 
1783  Lease4Ptr
1784  reuseExpiredLease4(Lease4Ptr& expired, ClientContext4& ctx,
1785  hooks::CalloutHandle::CalloutNextStep& callout_status);
1786 
1802  Lease4Ptr
1803  allocateOrReuseLease4(const asiolink::IOAddress& address,
1804  ClientContext4& ctx,
1805  hooks::CalloutHandle::CalloutNextStep& callout_status);
1806 
1825  Lease4Ptr allocateUnreservedLease4(ClientContext4& ctx);
1826 
1849  bool updateLease4Information(const Lease4Ptr& lease,
1850  ClientContext4& ctx) const;
1851 
1852 protected:
1869  bool updateLease4ExtendedInfo(const Lease4Ptr& lease,
1870  const ClientContext4& ctx) const;
1871 
1889  bool updateLease6ExtendedInfo(const Lease6Ptr& lease,
1890  const ClientContext6& ctx) const;
1891 
1892 private:
1893 
1907  void setLeaseReusable(const Lease4Ptr& lease,
1908  const ClientContext4& ctx) const;
1909 
1924  void setLeaseReusable(const Lease6Ptr& lease,
1925  uint32_t current_preferred_lft,
1926  const ClientContext6& ctx) const;
1927 
1928 private:
1929 
1932  uint16_t incomplete_v4_reclamations_;
1933 
1936  uint16_t incomplete_v6_reclamations_;
1937 
1938 public:
1939 
1946  return (rw_mutex_);
1947  }
1948 
1951 };
1952 
1954 typedef boost::shared_ptr<AllocEngine> AllocEnginePtr;
1955 
1956 } // namespace dhcp
1957 } // namespace isc
1958 
1959 #endif // ALLOC_ENGINE_H
Resource(const isc::asiolink::IOAddress &address, const uint8_t prefix_len, const uint32_t preferred=0, const uint32_t valid=0)
Default constructor.
Definition: alloc_engine.h:335
ConstHostPtr globalHost() const
Returns global host reservation if there is one.
Defines the D2ClientConfig class.
std::map< SubnetID, ConstHostPtr > hosts_
Holds a map of hosts belonging to the client within different subnets.
bool fake_allocation_
Indicates if this is a real or fake allocation.
boost::shared_ptr< DUID > DuidPtr
Definition: duid.h:20
bool updateLease4ExtendedInfo(const Lease4Ptr &lease, const ClientContext4 &ctx) const
Stores additional client query parameters on a V4 lease.
virtual isc::asiolink::IOAddress pickAddress(const SubnetPtr &subnet, const ClientClasses &client_classes, const DuidPtr &duid, const isc::asiolink::IOAddress &hint)
Picks one address out of available pools in a given subnet.
Definition: alloc_engine.h:98
Standard implementation of read-write mutexes with writer preference using C++11 mutex and condition ...
uint8_t getPrefixLength() const
Returns the prefix length.
Definition: alloc_engine.h:353
HWAddrPtr hwaddr_
Hardware/MAC address (if available, may be NULL)
Definition: alloc_engine.h:488
Defines a single hint.
Definition: alloc_engine.h:324
Lease6Collection changed_leases_
A pointer to any leases that have changed FQDN information.
Definition: alloc_engine.h:559
AllocFailed(const char *file, size_t line, const char *what)
Constructor.
Definition: alloc_engine.h:51
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
ConstHostPtr currentHost() const
Returns host from the most preferred subnet.
static void findReservation(ClientContext6 &ctx)
Attempts to find appropriate host reservation.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
Definition: hwaddr.h:154
isc::util::ReadWriteMutex rw_mutex_
The read-write mutex.
void addAllocatedResource(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128)
Convenience method adding allocated prefix or address.
static IPv6Resrv makeIPv6Resrv(const Lease6 &lease)
Creates an IPv6Resrv instance from a Lease6.
Definition: alloc_engine.h:990
bool equals(const Resource &other) const
Compares two AllocEngine::Resource objects for equality.
Definition: alloc_engine.h:376
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:551
static isc::asiolink::IOAddress increaseAddress(const isc::asiolink::IOAddress &address, bool prefix, const uint8_t prefix_len)
Returns the next address or prefix.
An abstract API for lease database.
static ConstHostPtr findGlobalReservation(ClientContext6 &ctx)
Attempts to find the host reservation for the client.
Defines elements for storing the names of client classes.
uint32_t getValid() const
Returns the optional valid lifetime.
Definition: alloc_engine.h:367
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
Definition: subnet.h:522
bool fwd_dns_update_
A boolean value which indicates that server takes responsibility for the forward DNS Update for this ...
Definition: alloc_engine.h:504
DuidPtr duid_
Client identifier.
Definition: alloc_engine.h:485
Lease4Ptr allocateLease4(ClientContext4 &ctx)
Returns IPv4 lease.
Read-Write Mutex.
uint8_t prefix_len_
The prefix length (128 for an address).
Definition: alloc_engine.h:396
IPv6 reservation for a host.
Definition: host.h:161
std::list< IdentifierPair > IdentifierList
Map holding values to be used as host identifiers.
Definition: alloc_engine.h:435
AllocEngine(AllocType engine_type, uint64_t attempts, bool ipv6=true)
Constructor.
DdnsParamsPtr getDdnsParams()
Returns the set of DDNS behavioral parameters based on the selected subnet.
hooks::CalloutHandlePtr callout_handle_
Callout handle associated with the client's message.
bool operator()(const Resource &lhr, const Resource &rhr) const
Compare operator.
Definition: alloc_engine.h:416
boost::shared_ptr< AllocEngine > AllocEnginePtr
A pointer to the AllocEngine object.
IdentifierList host_identifiers_
A list holding host identifiers extracted from a message received by the server.
An exception that is thrown when allocation module fails (e.g.
Definition: alloc_engine.h:43
boost::shared_ptr< DdnsParams > DdnsParamsPtr
Defines a pointer for DdnsParams instances.
Definition: srv_config.h:162
asiolink::IOAddress requested_address_
An address that the client desires.
void deleteExpiredReclaimedLeases4(const uint32_t secs)
Deletes reclaimed leases expired more than specified amount of time ago.
IterativeAllocator(Lease::Type type)
Default constructor.
Definition: alloc_engine.cc:93
void addNewResource(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128)
Convenience method adding new prefix or address.
AllocType
Specifies allocation type.
Definition: alloc_engine.h:268
boost::shared_ptr< Option6IA > Option6IAPtr
A pointer to the Option6IA object.
Definition: option6_ia.h:17
bool updateLease6ExtendedInfo(const Lease6Ptr &lease, const ClientContext6 &ctx) const
Stores additional client query parameters on a V6 lease.
ResourceContainer new_resources_
Holds addresses and prefixes allocated for this IA.
Definition: alloc_engine.h:564
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Definition: pkt6.h:28
Subnet6Ptr subnet_
Subnet selected for the client by the server.
Definition: alloc_engine.h:477
ResourceContainer allocated_resources_
Holds addresses and prefixes allocated for all IAs.
Definition: alloc_engine.h:521
Lease4Ptr conflicting_lease_
A pointer to the object representing a lease in conflict.
boost::shared_ptr< Option6IAPrefix > Option6IAPrefixPtr
Pointer to the Option6IAPrefix object.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition: lease.h:283
Lease4Ptr old_lease_
A pointer to an old lease that the client had before update.
ConstHostPtr currentHost() const
Returns host for currently selected subnet.
uint32_t getPreferred() const
Returns the optional preferred lifetime.
Definition: alloc_engine.h:360
std::map< SubnetID, ConstHostPtr > hosts_
Holds a map of hosts belonging to the client within different subnets.
Definition: alloc_engine.h:499
Random allocator that picks address randomly.
Definition: alloc_engine.h:238
std::vector< IAContext > ias_
Container holding IA specific contexts.
Definition: alloc_engine.h:616
Context information for the DHCPv6 leases allocation.
Definition: alloc_engine.h:459
Subnet6Ptr host_subnet_
Subnet from which host reservations should be retrieved.
Definition: alloc_engine.h:482
boost::shared_ptr< ClientContext4 > ClientContext4Ptr
Pointer to the ClientContext4.
Lease6Collection renewLeases6(ClientContext6 &ctx)
Renews existing DHCPv6 leases for a given IA.
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.
Subnet4Ptr subnet_
Subnet selected for the client by the server.
Pkt4Ptr query_
A pointer to the client's message.
Option6IAPtr ia_rsp_
A pointer to the IA_NA/IA_PD option to be sent in response.
Definition: alloc_engine.h:568
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition: pkt4.h:544
CalloutNextStep
Specifies allowed next steps.
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition: host.h:788
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:646
bool hasGlobalReservation(const IPv6Resrv &resv) const
Determines if a global reservation exists.
Structure that holds a lease for IPv6 address and/or prefix.
Definition: lease.h:503
Address/prefix allocator that iterates over all addresses.
Definition: alloc_engine.h:148
std::vector< Resource > HintContainer
Container for client's hints.
Definition: alloc_engine.h:426
Lease::Type type_
Lease type.
Definition: lease.h:508
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.
virtual ~Allocator()
Virtual destructor.
Definition: alloc_engine.h:118
uint8_t prefixlen_
IPv6 prefix length.
Definition: lease.h:513
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
Definition: lease.h:640
uint32_t valid_
The valid lifetime (0 when not set).
Definition: alloc_engine.h:402
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
Definition: duid.h:103
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
isc::util::ReadWriteMutex & getReadWriteMutex()
Get the read-write mutex.
void addHostIdentifier(const Host::IdentifierType &id_type, const std::vector< uint8_t > &identifier)
Convenience function adding host identifier into host_identifiers_ list.
the lease contains non-temporary IPv6 address
Definition: lease.h:51
bool fake_allocation_
Indicates if this is a real or fake allocation.
Definition: alloc_engine.h:474
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Lease6Collection new_leases_
A collection of newly allocated leases.
Definition: alloc_engine.h:524
ClientIdPtr clientid_
Client identifier from the DHCP message.
uint32_t iaid_
The IAID field from IA_NA or IA_PD that is being processed.
Definition: alloc_engine.h:533
Lease::Type type_
Lease type (IA or PD)
Definition: alloc_engine.h:536
boost::shared_ptr< Allocator > AllocatorPtr
defines a pointer to allocator
Definition: alloc_engine.h:140
Address/prefix allocator that gets an address based on a hash.
Definition: alloc_engine.h:208
Pkt6Ptr query_
A pointer to the client's message.
Definition: alloc_engine.h:467
bool isNewResource(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128) const
Checks if specified address or prefix was new.
Lease6Collection allocateLeases6(ClientContext6 &ctx)
Allocates IPv6 leases for a given IA container.
Parameters pertaining to individual IAs.
Definition: alloc_engine.h:529
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
Lease4Ptr new_lease_
A pointer to a newly allocated lease.
HashedAllocator(Lease::Type type)
Default constructor (does nothing)
isc::asiolink::IOAddress address_
The address or prefix.
Definition: alloc_engine.h:393
Type
Type of lease or pool.
Definition: lease.h:50
bool rev_dns_update_
A boolean value which indicates that server takes responsibility for the reverse DNS Update for this ...
Definition: alloc_engine.h:509
bool fwd_dns_update_
Perform forward DNS update.
Base class for all address/prefix allocation algorithms.
Definition: alloc_engine.h:70
static uint32_t getValidLft(const ClientContext4 &ctx)
Returns the valid lifetime based on the v4 context.
void deleteExpiredReclaimedLeases6(const uint32_t secs)
Deletes reclaimed leases expired more than specified amount of time ago.
isc::asiolink::IOAddress addr_
IPv4 ot IPv6 address.
Definition: lease.h:119
void createIAContext()
Creates new IA context.
Definition: alloc_engine.h:667
IAContext & currentIA()
Returns IA specific context for the currently processed IA.
Definition: alloc_engine.h:656
ConstHostPtr globalHost() const
Returns global host reservation if there is one.
Lease::Type pool_type_
Defines pool type allocation.
Definition: alloc_engine.h:131
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.
uint32_t preferred_
The preferred lifetime (0 when not set).
Definition: alloc_engine.h:399
boost::shared_ptr< Subnet6 > Subnet6Ptr
A pointer to a Subnet6 object.
Definition: subnet.h:670
virtual ~AllocEngine()
Destructor.
Definition: alloc_engine.h:288
IdentifierType
Type of the host identifier.
Definition: host.h:307
hooks::CalloutHandlePtr callout_handle_
Callout handle associated with the client's message.
Definition: alloc_engine.h:518
static isc::asiolink::IOAddress increasePrefix(const isc::asiolink::IOAddress &prefix, const uint8_t prefix_len)
Returns the next prefix.
Definition: alloc_engine.cc:98
HWAddrPtr hwaddr_
HW address from the DHCP message.
bool isAllocated(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128) const
Checks if specified address or prefix was allocated.
RandomAllocator(Lease::Type type)
Default constructor (does nothing)
Context information for the DHCPv4 lease allocation.
DHCPv4 and DHCPv6 allocation engine.
Definition: alloc_engine.h:63
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
Definition: lease.h:492
std::set< Resource, ResourceCompare > ResourceContainer
Container holding allocated prefixes or addresses.
Definition: alloc_engine.h:429
Allocator(Lease::Type pool_type)
Default constructor.
Definition: alloc_engine.h:114
std::pair< Host::IdentifierType, std::vector< uint8_t > > IdentifierPair
A tuple holding host identifier type and value.
Definition: alloc_engine.h:432
Container for storing client class names.
Definition: classify.h:43
isc::asiolink::IOAddress getAddress() const
Returns the address.
Definition: alloc_engine.h:346
boost::shared_ptr< Option6IAAddr > Option6IAAddrPtr
A pointer to the isc::dhcp::Option6IAAddr object.
bool rev_dns_update_
Perform reverse DNS update.
bool operator==(const Resource &other) const
Equality operator.
Definition: alloc_engine.h:386
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
Definition: subnet.h:513
DdnsParamsPtr getDdnsParams()
Returns the set of DDNS behavioral parameters based on the selected subnet.
AllocatorPtr getAllocator(Lease::Type type)
Returns allocator for a given pool type.
IdentifierList host_identifiers_
A list holding host identifiers extracted from a message received by the server.
Definition: alloc_engine.h:492
ClientContext6()
Default constructor.