#include <dhcpsrv/callout_handle_store.h>
#include <stats/stats_mgr.h>
#include <util/stopwatch.h>
-#include <util/threads/lock_guard.h>
#include <hooks/server_hooks.h>
#include <hooks/hooks_manager.h>
}
isc::asiolink::IOAddress
-AllocEngine::IterativeAllocator::pickAddress(const SubnetPtr& subnet,
- const ClientClasses& client_classes,
- const DuidPtr&,
- const IOAddress&) {
- LockGuard<std::mutex> lock(&mutex_);
-
+AllocEngine::IterativeAllocator::pickAddressInternal(const SubnetPtr& subnet,
+ const ClientClasses& client_classes,
+ const DuidPtr&,
+ const IOAddress&) {
// Is this prefix allocation?
bool prefix = pool_type_ == Lease::TYPE_PD;
uint8_t prefix_len = 0;
}
isc::asiolink::IOAddress
-AllocEngine::HashedAllocator::pickAddress(const SubnetPtr&,
- const ClientClasses&,
- const DuidPtr&,
- const IOAddress&) {
+AllocEngine::HashedAllocator::pickAddressInternal(const SubnetPtr&,
+ const ClientClasses&,
+ const DuidPtr&,
+ const IOAddress&) {
isc_throw(NotImplemented, "Hashed allocator is not implemented");
}
}
isc::asiolink::IOAddress
-AllocEngine::RandomAllocator::pickAddress(const SubnetPtr&,
- const ClientClasses&,
- const DuidPtr&,
- const IOAddress&) {
+AllocEngine::RandomAllocator::pickAddressInternal(const SubnetPtr&,
+ const ClientClasses&,
+ const DuidPtr&,
+ const IOAddress&) {
isc_throw(NotImplemented, "Random allocator is not implemented");
}
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/lease_mgr.h>
#include <hooks/callout_handle.h>
+#include <util/threads/lock_guard.h>
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
pickAddress(const SubnetPtr& subnet,
const ClientClasses& client_classes,
const DuidPtr& duid,
- const isc::asiolink::IOAddress& hint) = 0;
+ const isc::asiolink::IOAddress& hint) {
+ isc::util::thread::LockGuard<std::mutex> lock(&mutex_);
+ return pickAddressInternal(subnet, client_classes, duid, hint);
+ }
/// @brief Default constructor.
///
/// Specifies which type of leases this allocator will assign
/// @param pool_type specifies pool type (addresses, temp. addr or prefixes)
- Allocator(Lease::Type pool_type)
- :pool_type_(pool_type) {
+ Allocator(Lease::Type pool_type) : pool_type_(pool_type) {
}
/// @brief virtual destructor
virtual ~Allocator() {
}
+ private:
+ virtual isc::asiolink::IOAddress
+ pickAddressInternal(const SubnetPtr& subnet,
+ const ClientClasses& client_classes,
+ const DuidPtr& duid,
+ const isc::asiolink::IOAddress& hint) = 0;
+
protected:
/// @brief defines pool type allocation
Lease::Type pool_type_;
+
+ private:
+ std::mutex mutex_;
};
/// defines a pointer to allocator
/// @param type - specifies allocation type
IterativeAllocator(Lease::Type type);
+ private:
/// @brief returns the next address from pools in a subnet
///
/// @param subnet next address will be returned from pool of that subnet
/// @param hint client's hint (ignored)
/// @return the next address
virtual isc::asiolink::IOAddress
- pickAddress(const SubnetPtr& subnet,
- const ClientClasses& client_classes,
- const DuidPtr& duid,
- const isc::asiolink::IOAddress& hint);
+ pickAddressInternal(const SubnetPtr& subnet,
+ const ClientClasses& client_classes,
+ const DuidPtr& duid,
+ const isc::asiolink::IOAddress& hint);
protected:
/// @brief Returns the next prefix
static isc::asiolink::IOAddress
increaseAddress(const isc::asiolink::IOAddress& address,
bool prefix, const uint8_t prefix_len);
-
- private:
- std::mutex mutex_;
};
/// @brief Address/prefix allocator that gets an address based on a hash
/// @param type - specifies allocation type
HashedAllocator(Lease::Type type);
+ private:
/// @brief returns an address based on hash calculated from client's DUID.
///
/// @todo: Implement this method
/// @param hint a hint (last address that was picked)
/// @return selected address
virtual isc::asiolink::IOAddress
- pickAddress(const SubnetPtr& subnet,
- const ClientClasses& client_classes,
- const DuidPtr& duid,
- const isc::asiolink::IOAddress& hint);
+ pickAddressInternal(const SubnetPtr& subnet,
+ const ClientClasses& client_classes,
+ const DuidPtr& duid,
+ const isc::asiolink::IOAddress& hint);
};
/// @brief Random allocator that picks address randomly
/// @param type - specifies allocation type
RandomAllocator(Lease::Type type);
+ private:
/// @brief returns a random address from pool of specified subnet
///
/// @todo: Implement this method
/// @param hint the last address that was picked (ignored)
/// @return a random address from the pool
virtual isc::asiolink::IOAddress
- pickAddress(const SubnetPtr& subnet,
- const ClientClasses& client_classes,
- const DuidPtr& duid,
- const isc::asiolink::IOAddress& hint);
+ pickAddressInternal(const SubnetPtr& subnet,
+ const ClientClasses& client_classes,
+ const DuidPtr& duid,
+ const isc::asiolink::IOAddress& hint);
};
public: