const Triplet<uint32_t>& t2,
const Triplet<uint32_t>& valid_lifetime)
:id_(getNextID()), prefix_(prefix), prefix_len_(len), t1_(t1),
- t2_(t2), valid_(valid_lifetime) {
+ t2_(t2), valid_(valid_lifetime),
+ last_allocated_(lastAddrInPrefix(prefix, len)) {
if ( (prefix.getFamily() == AF_INET6 && len > 128) ||
(prefix.getFamily() == AF_INET && len > 32) ) {
isc_throw(BadValue, "Invalid prefix length specified for subnet: " << len);
/// leased addresses lifetime (valid-lifetime).
///
/// @todo: Implement support for options here
+
+
+/// @brief Unique indentifier for a subnet (both v4 and v6)
+typedef uint32_t SubnetID;
+
class Subnet {
public:
/// @brief checks if specified address is in range
return (t2_);
}
+ isc::asiolink::IOAddress getLastAllocated() {
+ return (last_allocated_);
+ }
+
+ void setLastAllocated(const isc::asiolink::IOAddress& addr) {
+ last_allocated_ = addr;
+ }
+
+ SubnetID getID() { return id_; }
+
protected:
/// @brief protected constructor
//
/// @brief returns the next unique Subnet-ID
///
/// @return the next unique Subnet-ID
- static uint32_t getNextID() {
- static uint32_t id = 0;
+ static SubnetID getNextID() {
+ static SubnetID id = 0;
return (id++);
}
///
/// Subnet-id is a unique value that can be used to find or identify
/// a Subnet4 or Subnet6.
- uint32_t id_;
+ SubnetID id_;
/// @brief a prefix of the subnet
isc::asiolink::IOAddress prefix_;
/// @brief a tripet (min/default/max) holding allowed valid lifetime values
Triplet<uint32_t> valid_;
+
+ /// @brief last allocated address
+ ///
+ /// This is the last allocated address that was previously allocated from
+ /// this particular subnet. Some allocation algorithms (e.g. iterative) use
+ /// that value, others do not. It should be noted that although the value
+ /// is usually correct, there are cases when it is invalid, e.g. after
+ /// removing a pool, restarting or changing allocation algorithms. For
+ /// that purpose it should be only considered a help that should not be
+ /// fully trusted.
+ isc::asiolink::IOAddress last_allocated_;
};
/// @brief A configuration holder for IPv4 subnet.
/// @brief returns all pools
///
- /// The reference is only valid as long as the object that
- /// returned it.
+ /// The reference is only valid as long as the object that returned it.
///
/// @return a collection of all pools
const Pool4Collection& getPools() const {