28 #include <boost/shared_ptr.hpp> 29 #include <boost/noncopyable.hpp> 103 std::lock_guard<std::mutex> lock(mutex_);
104 return pickAddressInternal(subnet, client_classes, duid, hint);
106 return pickAddressInternal(subnet, client_classes, duid, hint);
123 pickAddressInternal(
const SubnetPtr& subnet,
168 pickAddressInternal(
const SubnetPtr& subnet,
188 const uint8_t prefix_len);
202 bool prefix,
const uint8_t prefix_len);
229 pickAddressInternal(
const SubnetPtr& subnet,
259 pickAddressInternal(
const SubnetPtr& subnet,
285 AllocEngine(AllocType engine_type, uint64_t attempts,
bool ipv6 =
true);
305 std::map<Lease::Type, AllocatorPtr> allocators_;
311 int hook_index_lease4_select_;
312 int hook_index_lease6_select_;
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) {
354 return (prefix_len_);
377 return (address_ == other.
address_ &&
387 return (equals(other));
587 const uint8_t prefix_len = 128,
588 const uint32_t preferred = 0,
589 const uint32_t valid = 0);
610 const uint8_t prefix_len = 128);
617 const uint8_t prefix_len = 128)
const;
637 const uint8_t prefix_len = 128);
644 const uint8_t prefix_len = 128)
const;
652 const std::vector<uint8_t>& identifier) {
653 host_identifiers_.push_back(IdentifierPair(id_type, identifier));
665 return (ias_.back());
699 bool hasGlobalReservation(
const IPv6Resrv& resv)
const;
726 const bool fwd_dns,
const bool rev_dns,
727 const std::string& hostname,
const bool fake_allocation,
893 void reclaimExpiredLeases6(
const size_t max_leases,
const uint16_t timeout,
894 const bool remove_lease,
895 const uint16_t max_unwarned_cycles = 0);
902 void deleteExpiredReclaimedLeases6(
const uint32_t secs);
952 void reclaimExpiredLeases4(
const size_t max_leases,
const uint16_t timeout,
953 const bool remove_lease,
954 const uint16_t max_unwarned_cycles = 0);
961 void deleteExpiredReclaimedLeases4(
const uint32_t secs);
1021 static void getLifetimes6(
ClientContext6& ctx, uint32_t& preferred,
1062 const uint8_t prefix_len,
1245 enum DbReclaimMode {
1248 DB_RECLAIM_LEAVE_UNCHANGED
1262 template<
typename LeasePtrType>
1263 void reclaimExpiredLease(
const LeasePtrType& lease,
1264 const bool remove_lease,
1277 template<
typename LeasePtrType>
1278 void reclaimExpiredLease(
const LeasePtrType& lease,
1291 void reclaimExpiredLease(
const Lease6Ptr& lease,
1292 const DbReclaimMode& reclaim_mode,
1305 void reclaimExpiredLease(
const Lease4Ptr& lease,
1306 const DbReclaimMode& reclaim_mode,
1327 template<
typename LeasePtrType>
1328 void reclaimLeaseInDatabase(
const LeasePtrType& lease,
1329 const bool remove_lease,
1330 const std::function<
void (
const LeasePtrType&)>&
1331 lease_update_fun)
const;
1345 bool reclaimDeclined(
const Lease4Ptr& lease);
1359 bool reclaimDeclined(
const Lease6Ptr& lease);
1473 const std::vector<uint8_t>& identifier) {
1474 host_identifiers_.push_back(IdentifierPair(id_type, identifier));
1515 const bool fwd_dns_update,
const bool rev_dns_update,
1516 const std::string& hostname,
const bool fake_allocation);
1883 bool updateLease4Information(
const Lease4Ptr& lease,
1903 bool updateLease4ExtendedInfo(
const Lease4Ptr& lease,
1923 bool updateLease6ExtendedInfo(
const Lease6Ptr& lease,
1941 void setLeaseReusable(
const Lease4Ptr& lease,
1958 void setLeaseReusable(
const Lease6Ptr& lease,
1959 uint32_t current_preferred_lft,
1966 uint16_t incomplete_v4_reclamations_;
1970 uint16_t incomplete_v6_reclamations_;
1993 #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.
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
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.
Standard implementation of read-write mutexes with writer preference using C++11 mutex and condition ...
HWAddrPtr hwaddr_
Hardware/MAC address (if available, may be NULL)
Lease6Collection changed_leases_
A pointer to any leases that have changed FQDN information.
HintContainer hints_
Client's hints.
AllocFailed(const char *file, size_t line, const char *what)
Constructor.
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
isc::util::ReadWriteMutex rw_mutex_
The read-write mutex.
static IPv6Resrv makeIPv6Resrv(const Lease6 &lease)
Creates an IPv6Resrv instance from a Lease6.
Lease6Collection old_leases_
A pointer to any old leases that the client had before update but are no longer valid after the updat...
An abstract API for lease database.
Defines elements for storing the names of client classes.
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
bool early_global_reservations_lookup_
Indicates if early global reservation is enabled.
bool fwd_dns_update_
A boolean value which indicates that server takes responsibility for the forward DNS Update for this ...
DuidPtr duid_
Client identifier.
isc::asiolink::IOAddress getAddress() const
Returns the address.
uint8_t prefix_len_
The prefix length (128 for an address).
IPv6 reservation for a host.
std::list< IdentifierPair > IdentifierList
Map holding values to be used as host identifiers.
hooks::CalloutHandlePtr callout_handle_
Callout handle associated with the client's message.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
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.
boost::shared_ptr< DdnsParams > DdnsParamsPtr
Defines a pointer for DdnsParams instances.
asiolink::IOAddress requested_address_
An address that the client desires.
AllocType
Specifies allocation type.
boost::shared_ptr< Option6IA > Option6IAPtr
A pointer to the Option6IA object.
bool early_global_reservations_lookup_
Indicates if early global reservation is enabled.
ResourceContainer new_resources_
Holds addresses and prefixes allocated for this IA.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Subnet6Ptr subnet_
Subnet selected for the client by the server.
ResourceContainer allocated_resources_
Holds addresses and prefixes allocated for all IAs.
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.
Lease4Ptr old_lease_
A pointer to an old lease that the client had before update.
std::map< SubnetID, ConstHostPtr > hosts_
Holds a map of hosts belonging to the client within different subnets.
Random allocator that picks address randomly.
std::vector< IAContext > ias_
Container holding IA specific contexts.
Context information for the DHCPv6 leases allocation.
Subnet6Ptr host_subnet_
Subnet from which host reservations should be retrieved.
boost::shared_ptr< ClientContext4 > ClientContext4Ptr
Pointer to the ClientContext4.
Subnet4Ptr subnet_
Subnet selected for the client by the server.
uint32_t getValid() const
Returns the optional valid lifetime.
bool unknown_requested_addr_
True when the address DHCPREQUEST'ed by client is not within a dynamic pool the server knows about...
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.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
CalloutNextStep
Specifies allowed next steps.
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
void addHostIdentifier(const Host::IdentifierType &id_type, const std::vector< uint8_t > &identifier)
Convenience function adding host identifier into host_identifiers_ list.
Structure that holds a lease for IPv6 address and/or prefix.
Address/prefix allocator that iterates over all addresses.
std::vector< Resource > HintContainer
Container for client's hints.
Lease::Type type_
Lease type.
virtual ~Allocator()
Virtual destructor.
uint8_t prefixlen_
IPv6 prefix length.
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
uint32_t valid_
The valid lifetime (0 when not set).
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
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
bool fake_allocation_
Indicates if this is a real or fake allocation.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
Lease6Collection new_leases_
A collection of newly allocated leases.
ClientIdPtr clientid_
Client identifier from the DHCP message.
uint32_t iaid_
The IAID field from IA_NA or IA_PD that is being processed.
Lease::Type type_
Lease type (IA or PD)
boost::shared_ptr< Allocator > AllocatorPtr
defines a pointer to allocator
bool equals(const Resource &other) const
Compares two AllocEngine::Resource objects for equality.
Address/prefix allocator that gets an address based on a hash.
Pkt6Ptr query_
A pointer to the client's message.
Parameters pertaining to individual IAs.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
Lease4Ptr new_lease_
A pointer to a newly allocated lease.
isc::asiolink::IOAddress address_
The address or prefix.
Type
Type of lease or pool.
bool rev_dns_update_
A boolean value which indicates that server takes responsibility for the reverse DNS Update for this ...
bool fwd_dns_update_
Perform forward DNS update.
Base class for all address/prefix allocation algorithms.
uint32_t getPreferred() const
Returns the optional preferred lifetime.
isc::asiolink::IOAddress addr_
IPv4 ot IPv6 address.
void createIAContext()
Creates new IA context.
IAContext & currentIA()
Returns IA specific context for the currently processed IA.
uint8_t getPrefixLength() const
Returns the prefix length.
Lease::Type pool_type_
Defines pool type allocation.
uint32_t preferred_
The preferred lifetime (0 when not set).
std::string hostname_
Hostname.
boost::shared_ptr< Subnet6 > Subnet6Ptr
A pointer to a Subnet6 object.
virtual ~AllocEngine()
Destructor.
IdentifierType
Type of the host identifier.
hooks::CalloutHandlePtr callout_handle_
Callout handle associated with the client's message.
bool operator==(const Resource &other) const
Equality operator.
HWAddrPtr hwaddr_
HW address from the DHCP message.
The IOAddress class represents an IP addresses (version agnostic)
std::string hostname_
Hostname.
Context information for the DHCPv4 lease allocation.
DHCPv4 and DHCPv6 allocation engine.
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
std::set< Resource, ResourceCompare > ResourceContainer
Container holding allocated prefixes or addresses.
Allocator(Lease::Type pool_type)
Default constructor.
std::pair< Host::IdentifierType, std::vector< uint8_t > > IdentifierPair
A tuple holding host identifier type and value.
Container for storing client class names.
boost::shared_ptr< Option6IAAddr > Option6IAAddrPtr
A pointer to the isc::dhcp::Option6IAAddr object.
bool rev_dns_update_
Perform reverse DNS update.
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
IdentifierList host_identifiers_
A list holding host identifiers extracted from a message received by the server.