|
@@ -53,8 +53,8 @@ AllocEngineHooks Hooks;
|
|
namespace isc {
|
|
namespace isc {
|
|
namespace dhcp {
|
|
namespace dhcp {
|
|
|
|
|
|
-AllocEngine::IterativeAllocator::IterativeAllocator()
|
|
|
|
- :Allocator() {
|
|
|
|
|
|
+AllocEngine::IterativeAllocator::IterativeAllocator(Pool::PoolType lease_type)
|
|
|
|
+ :Allocator(lease_type) {
|
|
}
|
|
}
|
|
|
|
|
|
isc::asiolink::IOAddress
|
|
isc::asiolink::IOAddress
|
|
@@ -94,7 +94,7 @@ AllocEngine::IterativeAllocator::pickAddress(const SubnetPtr& subnet,
|
|
// Let's get the last allocated address. It is usually set correctly,
|
|
// Let's get the last allocated address. It is usually set correctly,
|
|
// but there are times when it won't be (like after removing a pool or
|
|
// but there are times when it won't be (like after removing a pool or
|
|
// perhaps restarting the server).
|
|
// perhaps restarting the server).
|
|
- IOAddress last = subnet->getLastAllocated();
|
|
|
|
|
|
+ IOAddress last = subnet->getLastAllocated(lease_type_);
|
|
|
|
|
|
const PoolCollection& pools = subnet->getPools();
|
|
const PoolCollection& pools = subnet->getPools();
|
|
|
|
|
|
@@ -117,7 +117,7 @@ AllocEngine::IterativeAllocator::pickAddress(const SubnetPtr& subnet,
|
|
if (it == pools.end()) {
|
|
if (it == pools.end()) {
|
|
// ok to access first element directly. We checked that pools is non-empty
|
|
// ok to access first element directly. We checked that pools is non-empty
|
|
IOAddress next = pools[0]->getFirstAddress();
|
|
IOAddress next = pools[0]->getFirstAddress();
|
|
- subnet->setLastAllocated(next);
|
|
|
|
|
|
+ subnet->setLastAllocated(next, lease_type_);
|
|
return (next);
|
|
return (next);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -126,7 +126,7 @@ AllocEngine::IterativeAllocator::pickAddress(const SubnetPtr& subnet,
|
|
IOAddress next = increaseAddress(last); // basically addr++
|
|
IOAddress next = increaseAddress(last); // basically addr++
|
|
if ((*it)->inRange(next)) {
|
|
if ((*it)->inRange(next)) {
|
|
// the next one is in the pool as well, so we haven't hit pool boundary yet
|
|
// the next one is in the pool as well, so we haven't hit pool boundary yet
|
|
- subnet->setLastAllocated(next);
|
|
|
|
|
|
+ subnet->setLastAllocated(next, lease_type_);
|
|
return (next);
|
|
return (next);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -136,18 +136,18 @@ AllocEngine::IterativeAllocator::pickAddress(const SubnetPtr& subnet,
|
|
// Really out of luck today. That was the last pool. Let's rewind
|
|
// Really out of luck today. That was the last pool. Let's rewind
|
|
// to the beginning.
|
|
// to the beginning.
|
|
next = pools[0]->getFirstAddress();
|
|
next = pools[0]->getFirstAddress();
|
|
- subnet->setLastAllocated(next);
|
|
|
|
|
|
+ subnet->setLastAllocated(next, lease_type_);
|
|
return (next);
|
|
return (next);
|
|
}
|
|
}
|
|
|
|
|
|
// there is a next pool, let's try first address from it
|
|
// there is a next pool, let's try first address from it
|
|
next = (*it)->getFirstAddress();
|
|
next = (*it)->getFirstAddress();
|
|
- subnet->setLastAllocated(next);
|
|
|
|
|
|
+ subnet->setLastAllocated(next, lease_type_);
|
|
return (next);
|
|
return (next);
|
|
}
|
|
}
|
|
|
|
|
|
-AllocEngine::HashedAllocator::HashedAllocator()
|
|
|
|
- :Allocator() {
|
|
|
|
|
|
+AllocEngine::HashedAllocator::HashedAllocator(Pool::PoolType lease_type)
|
|
|
|
+ :Allocator(lease_type) {
|
|
isc_throw(NotImplemented, "Hashed allocator is not implemented");
|
|
isc_throw(NotImplemented, "Hashed allocator is not implemented");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -159,8 +159,8 @@ AllocEngine::HashedAllocator::pickAddress(const SubnetPtr&,
|
|
isc_throw(NotImplemented, "Hashed allocator is not implemented");
|
|
isc_throw(NotImplemented, "Hashed allocator is not implemented");
|
|
}
|
|
}
|
|
|
|
|
|
-AllocEngine::RandomAllocator::RandomAllocator()
|
|
|
|
- :Allocator() {
|
|
|
|
|
|
+AllocEngine::RandomAllocator::RandomAllocator(Pool::PoolType lease_type)
|
|
|
|
+ :Allocator(lease_type) {
|
|
isc_throw(NotImplemented, "Random allocator is not implemented");
|
|
isc_throw(NotImplemented, "Random allocator is not implemented");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -177,13 +177,13 @@ AllocEngine::AllocEngine(AllocType engine_type, unsigned int attempts)
|
|
:attempts_(attempts) {
|
|
:attempts_(attempts) {
|
|
switch (engine_type) {
|
|
switch (engine_type) {
|
|
case ALLOC_ITERATIVE:
|
|
case ALLOC_ITERATIVE:
|
|
- allocator_ = boost::shared_ptr<Allocator>(new IterativeAllocator());
|
|
|
|
|
|
+ allocator_.reset(new IterativeAllocator(Pool6::TYPE_IA));
|
|
break;
|
|
break;
|
|
case ALLOC_HASHED:
|
|
case ALLOC_HASHED:
|
|
- allocator_ = boost::shared_ptr<Allocator>(new HashedAllocator());
|
|
|
|
|
|
+ allocator_.reset(new HashedAllocator(Pool6::TYPE_IA));
|
|
break;
|
|
break;
|
|
case ALLOC_RANDOM:
|
|
case ALLOC_RANDOM:
|
|
- allocator_ = boost::shared_ptr<Allocator>(new RandomAllocator());
|
|
|
|
|
|
+ allocator_.reset(new RandomAllocator(Pool6::TYPE_IA));
|
|
break;
|
|
break;
|
|
|
|
|
|
default:
|
|
default:
|