29#include <boost/shared_ptr.hpp>
30#include <boost/noncopyable.hpp>
70 int hook_index_lease4_select_;
71 int hook_index_lease6_select_;
95 const uint8_t prefix_len = 128,
96 const uint32_t preferred = 0,
97 const uint32_t valid = 0)
346 const uint8_t prefix_len = 128,
347 const uint32_t preferred = 0,
348 const uint32_t valid = 0);
369 const uint8_t prefix_len = 128);
376 const uint8_t prefix_len = 128)
const;
396 const uint8_t prefix_len = 128);
403 const uint8_t prefix_len = 128)
const;
411 const std::vector<uint8_t>& identifier) {
424 return (
ias_.back());
485 const bool fwd_dns,
const bool rev_dns,
486 const std::string& hostname,
const bool fake_allocation,
653 const bool remove_lease,
654 const uint16_t max_unwarned_cycles = 0);
669 const uint16_t timeout,
670 const bool remove_lease,
671 const uint16_t max_unwarned_cycles = 0);
729 const bool remove_lease,
730 const uint16_t max_unwarned_cycles = 0);
745 const uint16_t timeout,
746 const bool remove_lease,
747 const uint16_t max_unwarned_cycles = 0);
814 static void getLifetimes6(ClientContext6& ctx, uint32_t& preferred,
853 Lease6Ptr createLease6(ClientContext6& ctx,
855 const uint8_t prefix_len,
914 Lease6Ptr allocateBestMatch(ClientContext6& ctx,
916 bool& search_hint_lease,
918 uint8_t hint_prefix_length,
921 uint64_t& total_attempts,
922 uint64_t& subnets_with_unavail_leases,
923 uint64_t& subnets_with_unavail_pools,
944 allocateReservedLeases6(ClientContext6& ctx,
Lease6Collection& existing_leases);
960 allocateGlobalReservedLeases6(ClientContext6& ctx,
Lease6Collection& existing_leases);
971 removeNonmatchingReservedLeases6(ClientContext6& ctx,
982 removeNonmatchingReservedNoHostLeases6(ClientContext6& ctx,
999 removeNonreservedLeases6(ClientContext6& ctx,
1036 ClientContext6& ctx,
1082 void extendLease6(ClientContext6& ctx,
Lease6Ptr lease);
1091 enum DbReclaimMode {
1094 DB_RECLAIM_LEAVE_UNCHANGED
1108 template<
typename LeasePtrType>
1109 void reclaimExpiredLease(
const LeasePtrType& lease,
1110 const bool remove_lease,
1123 template<
typename LeasePtrType>
1124 void reclaimExpiredLease(
const LeasePtrType& lease,
1137 void reclaimExpiredLease(
const Lease6Ptr& lease,
1138 const DbReclaimMode& reclaim_mode,
1151 void reclaimExpiredLease(
const Lease4Ptr& lease,
1152 const DbReclaimMode& reclaim_mode,
1173 template<
typename LeasePtrType>
1174 void reclaimLeaseInDatabase(
const LeasePtrType& lease,
1175 const bool remove_lease,
1176 const std::function<
void (
const LeasePtrType&)>&
1177 lease_update_fun)
const;
1191 bool reclaimDeclined(
const Lease4Ptr& lease);
1205 bool reclaimDeclined(
const Lease6Ptr& lease);
1323 const std::vector<uint8_t>& identifier) {
1367 const bool fwd_dns_update,
const bool rev_dns_update,
1368 const std::string& hostname,
const bool fake_allocation,
1369 const uint32_t offer_lft = 0);
1749 bool updateLease4Information(
const Lease4Ptr& lease,
1815 void setLeaseReusable(
const Lease4Ptr& lease,
1832 void setLeaseReusable(
const Lease6Ptr& lease,
1833 uint32_t current_preferred_lft,
1840 uint16_t incomplete_v4_reclamations_;
1844 uint16_t incomplete_v6_reclamations_;
Defines elements for storing the names of client classes.
The IOAddress class represents an IP addresses (version agnostic)
uint8_t prefix_len_
The prefix length (128 for an address).
uint32_t valid_
The valid lifetime (0 when not set).
bool operator==(const Resource &other) const
Equality operator.
Resource(const isc::asiolink::IOAddress &address, const uint8_t prefix_len=128, const uint32_t preferred=0, const uint32_t valid=0)
Default constructor.
bool equals(const Resource &other) const
Compares two AllocEngine::Resource objects for equality.
uint8_t getPrefixLength() const
Returns the prefix length.
uint32_t preferred_
The preferred lifetime (0 when not set).
uint32_t getPreferred() const
Returns the optional preferred lifetime.
isc::asiolink::IOAddress getAddress() const
Returns the address.
uint32_t getValid() const
Returns the optional valid lifetime.
isc::asiolink::IOAddress address_
The address or prefix.
DHCPv4 and DHCPv6 allocation engine.
std::set< Resource, ResourceCompare > ResourceContainer
Container holding allocated prefixes or addresses.
boost::shared_ptr< ClientContext4 > ClientContext4Ptr
Pointer to the ClientContext4.
static IPv6Resrv makeIPv6Resrv(const Lease6 &lease)
Creates an IPv6Resrv instance from a Lease6.
void updateLease6ExtendedInfo(const Lease6Ptr &lease, const ClientContext6 &ctx) const
Stores additional client query parameters on a V6 lease.
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.
bool updateLease4ExtendedInfo(const Lease4Ptr &lease, const ClientContext4 &ctx) const
Stores additional client query parameters on a V4 lease.
static uint32_t getOfferLft(const ClientContext4 &ctx)
Returns the offer lifetime based on the v4 context.
isc::util::ReadWriteMutex & getReadWriteMutex()
Get the read-write mutex.
static std::string labelNetworkOrSubnet(SubnetPtr subnet)
Generates a label for subnet or shared-network from subnet.
static ConstHostPtr findGlobalReservation(ClientContext6 &ctx)
Attempts to find the host reservation for the client.
AllocEngine(isc::util::uint128_t const &attempts)
Constructor.
std::pair< Host::IdentifierType, std::vector< uint8_t > > IdentifierPair
A tuple holding host identifier type and value.
virtual ~AllocEngine()
Destructor.
void clearReclaimedExtendedInfo(const Lease4Ptr &lease) const
Clear extended info from a reclaimed V4 lease.
isc::util::ReadWriteMutex rw_mutex_
The read-write mutex.
static void getLifetimes6(ClientContext6 &ctx, uint32_t &preferred, uint32_t &valid)
Determines the preferred and valid v6 lease lifetimes.
static void findReservation(ClientContext6 &ctx)
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.
void deleteExpiredReclaimedLeases4(const uint32_t secs)
Deletes reclaimed leases expired more than specified amount of time ago.
static uint32_t getValidLft(const ClientContext4 &ctx)
Returns the valid lifetime based on the v4 context.
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.
std::list< IdentifierPair > IdentifierList
Map holding values to be used as host identifiers.
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.
Lease4Ptr allocateLease4(ClientContext4 &ctx)
Returns IPv4 lease.
void deleteExpiredReclaimedLeases6(const uint32_t secs)
Deletes reclaimed leases expired more than specified amount of time ago.
Lease6Collection allocateLeases6(ClientContext6 &ctx)
Allocates IPv6 leases for a given IA container.
Lease6Collection renewLeases6(ClientContext6 &ctx)
Renews existing DHCPv6 leases for a given IA.
std::vector< Resource > HintContainer
Container for client's hints.
PrefixLenMatchType
Type of preferred PD-pool prefix length selection criteria.
IdentifierType
Type of the host identifier.
IPv6 reservation for a host.
CalloutNextStep
Specifies allowed next steps.
Defines the D2ClientConfig class.
An abstract API for lease database.
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
boost::shared_ptr< DUID > DuidPtr
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
boost::shared_ptr< AllocEngine > AllocEnginePtr
A pointer to the AllocEngine object.
boost::shared_ptr< Option6IA > Option6IAPtr
A pointer to the Option6IA object.
boost::shared_ptr< Subnet6 > Subnet6Ptr
A pointer to a Subnet6 object.
boost::shared_ptr< DdnsParams > DdnsParamsPtr
Defines a pointer for DdnsParams instances.
boost::shared_ptr< Option6IAPrefix > Option6IAPrefixPtr
Pointer to the Option6IAPrefix object.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
boost::shared_ptr< SharedNetwork6 > SharedNetwork6Ptr
Pointer to SharedNetwork6 object.
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
boost::shared_ptr< Option6IAAddr > Option6IAAddrPtr
A pointer to the isc::dhcp::Option6IAAddr object.
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
boost::multiprecision::checked_uint128_t uint128_t
Defines the logger used by the top-level component of kea-lfc.
Standard implementation of read-write mutexes with writer preference using C++11 mutex and condition ...
Context information for the DHCPv4 lease allocation.
ClientIdPtr clientid_
Client identifier from the DHCP message.
DdnsParamsPtr getDdnsParams()
Returns the set of DDNS behavioral parameters based on the selected subnet.
bool early_global_reservations_lookup_
Indicates if early global reservation is enabled.
ConstHostPtr currentHost() const
Returns host for currently selected subnet.
ClientContext4()
Default constructor.
Pkt4Ptr query_
A pointer to the client's message.
Subnet4Ptr subnet_
Subnet selected for the client by the server.
Lease4Ptr new_lease_
A pointer to a newly allocated lease.
std::string hostname_
Hostname.
std::map< SubnetID, ConstHostPtr > hosts_
Holds a map of hosts belonging to the client within different subnets.
bool rev_dns_update_
Perform reverse DNS update.
uint32_t offer_lft_
If not zero, then we will allocate on DISCOVER for this amount of time.
bool fake_allocation_
Indicates if this is a real or fake allocation.
hooks::CalloutHandlePtr callout_handle_
Callout handle associated with the client's message.
bool unknown_requested_addr_
True when the address DHCPREQUEST'ed by client is not within a dynamic pool the server knows about.
Lease4Ptr old_lease_
A pointer to an old lease that the client had before update.
ConstHostPtr globalHost() const
Returns global host reservation if there is one.
bool fwd_dns_update_
Perform forward DNS update.
asiolink::IOAddress requested_address_
An address that the client desires.
Lease4Ptr conflicting_lease_
A pointer to the object representing a lease in conflict.
void addHostIdentifier(const Host::IdentifierType &id_type, const std::vector< uint8_t > &identifier)
Convenience function adding host identifier into host_identifiers_ list.
IdentifierList host_identifiers_
A list holding host identifiers extracted from a message received by the server.
HWAddrPtr hwaddr_
HW address from the DHCP message.
Parameters pertaining to individual IAs.
IAContext()
Default constructor.
Lease6Collection old_leases_
A pointer to any old leases that the client had before update but are no longer valid after the updat...
Option6IAPtr ia_rsp_
A pointer to the IA_NA/IA_PD option to be sent in response.
Lease::Type type_
Lease type (IA or PD)
ResourceContainer new_resources_
Holds addresses and prefixes allocated for this IA.
bool isNewResource(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128) const
Checks if specified address or prefix was new.
Lease6Collection changed_leases_
A pointer to any leases that have changed FQDN information.
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.
void addNewResource(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128)
Convenience method adding new prefix or address.
HintContainer hints_
Client's hints.
uint32_t iaid_
The IAID field from IA_NA or IA_PD that is being processed.
Context information for the DHCPv6 leases allocation.
IAContext & currentIA()
Returns IA specific context for the currently processed IA.
std::vector< IAContext > ias_
Container holding IA specific contexts.
void addHostIdentifier(const Host::IdentifierType &id_type, const std::vector< uint8_t > &identifier)
Convenience function adding host identifier into host_identifiers_ list.
bool fake_allocation_
Indicates if this is a real or fake allocation.
ConstHostPtr currentHost() const
Returns host from the most preferred subnet.
ClientContext6()
Default constructor.
DuidPtr duid_
Client identifier.
void addAllocatedResource(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128)
Convenience method adding allocated prefix or address.
Lease6Collection new_leases_
A collection of newly allocated leases.
HWAddrPtr hwaddr_
Hardware/MAC address (if available, may be NULL)
hooks::CalloutHandlePtr callout_handle_
Callout handle associated with the client's message.
bool isAllocated(const asiolink::IOAddress &prefix, const uint8_t prefix_len=128) const
Checks if specified address or prefix was allocated.
Subnet6Ptr subnet_
Subnet selected for the client by the server.
Subnet6Ptr host_subnet_
Subnet from which host reservations should be retrieved.
bool hasGlobalReservation(const IPv6Resrv &resv) const
Determines if a global reservation exists.
ResourceContainer allocated_resources_
Holds addresses and prefixes allocated for all IAs.
bool rev_dns_update_
A boolean value which indicates that server takes responsibility for the reverse DNS Update for this ...
DdnsParamsPtr getDdnsParams()
Returns the set of DDNS behavioral parameters based on the selected subnet.
ConstHostPtr globalHost() const
Returns global host reservation if there is one.
Pkt6Ptr query_
A pointer to the client's message.
bool early_global_reservations_lookup_
Indicates if early global reservation is enabled.
std::string hostname_
Hostname.
void createIAContext()
Creates new IA context.
IdentifierList host_identifiers_
A list holding host identifiers extracted from a message received by the server.
std::map< SubnetID, ConstHostPtr > hosts_
Holds a map of hosts belonging to the client within different subnets.
bool fwd_dns_update_
A boolean value which indicates that server takes responsibility for the forward DNS Update for this ...
bool operator()(const Resource &lhr, const Resource &rhr) const
Compare operator.
Structure that holds a lease for IPv6 address and/or prefix.
Lease::Type type_
Lease type.
uint8_t prefixlen_
IPv6 prefix length.
Type
Type of lease or pool.
@ TYPE_NA
the lease contains non-temporary IPv6 address
isc::asiolink::IOAddress addr_
IPv4 ot IPv6 address.