|
@@ -76,9 +76,7 @@ Pool4::Pool4( const isc::asiolink::IOAddress& prefix, uint8_t prefix_len)
|
|
|
|
|
|
Pool6::Pool6(Lease::Type type, const isc::asiolink::IOAddress& first,
|
|
Pool6::Pool6(Lease::Type type, const isc::asiolink::IOAddress& first,
|
|
const isc::asiolink::IOAddress& last)
|
|
const isc::asiolink::IOAddress& last)
|
|
- : Pool(type, first, last), prefix_len_(128),
|
|
|
|
- excluded_prefix_(IOAddress::IPV6_ZERO_ADDRESS()),
|
|
|
|
- excluded_prefix_len_(0) {
|
|
|
|
|
|
+ : Pool(type, first, last), prefix_len_(128), pd_exclude_option_() {
|
|
|
|
|
|
// check if specified address boundaries are sane
|
|
// check if specified address boundaries are sane
|
|
if (!first.isV6() || !last.isV6()) {
|
|
if (!first.isV6() || !last.isV6()) {
|
|
@@ -121,9 +119,7 @@ Pool6::Pool6(Lease::Type type, const isc::asiolink::IOAddress& first,
|
|
Pool6::Pool6(Lease::Type type, const isc::asiolink::IOAddress& prefix,
|
|
Pool6::Pool6(Lease::Type type, const isc::asiolink::IOAddress& prefix,
|
|
const uint8_t prefix_len, const uint8_t delegated_len /* = 128 */)
|
|
const uint8_t prefix_len, const uint8_t delegated_len /* = 128 */)
|
|
: Pool(type, prefix, IOAddress::IPV6_ZERO_ADDRESS()),
|
|
: Pool(type, prefix, IOAddress::IPV6_ZERO_ADDRESS()),
|
|
- prefix_len_(delegated_len),
|
|
|
|
- excluded_prefix_(IOAddress::IPV6_ZERO_ADDRESS()),
|
|
|
|
- excluded_prefix_len_(0) {
|
|
|
|
|
|
+ prefix_len_(delegated_len), pd_exclude_option_() {
|
|
|
|
|
|
init(type, prefix, prefix_len, delegated_len,
|
|
init(type, prefix, prefix_len, delegated_len,
|
|
IOAddress::IPV6_ZERO_ADDRESS(), 0);
|
|
IOAddress::IPV6_ZERO_ADDRESS(), 0);
|
|
@@ -134,9 +130,7 @@ Pool6::Pool6(const asiolink::IOAddress& prefix, const uint8_t prefix_len,
|
|
const asiolink::IOAddress& excluded_prefix,
|
|
const asiolink::IOAddress& excluded_prefix,
|
|
const uint8_t excluded_prefix_len)
|
|
const uint8_t excluded_prefix_len)
|
|
: Pool(Lease::TYPE_PD, prefix, IOAddress::IPV6_ZERO_ADDRESS()),
|
|
: Pool(Lease::TYPE_PD, prefix, IOAddress::IPV6_ZERO_ADDRESS()),
|
|
- prefix_len_(delegated_len),
|
|
|
|
- excluded_prefix_(excluded_prefix),
|
|
|
|
- excluded_prefix_len_(excluded_prefix_len) {
|
|
|
|
|
|
+ prefix_len_(delegated_len), pd_exclude_option_() {
|
|
|
|
|
|
init(Lease::TYPE_PD, prefix, prefix_len, delegated_len, excluded_prefix,
|
|
init(Lease::TYPE_PD, prefix, prefix_len, delegated_len, excluded_prefix,
|
|
excluded_prefix_len);
|
|
excluded_prefix_len);
|
|
@@ -144,33 +138,33 @@ Pool6::Pool6(const asiolink::IOAddress& prefix, const uint8_t prefix_len,
|
|
// The excluded prefix can only be specified using this constructor.
|
|
// The excluded prefix can only be specified using this constructor.
|
|
// Therefore, the initialization of the excluded prefix is takes place
|
|
// Therefore, the initialization of the excluded prefix is takes place
|
|
// here, rather than in the init(...) function.
|
|
// here, rather than in the init(...) function.
|
|
- if (!excluded_prefix_.isV6()) {
|
|
|
|
|
|
+ if (!excluded_prefix.isV6()) {
|
|
isc_throw(BadValue, "excluded prefix must be an IPv6 prefix");
|
|
isc_throw(BadValue, "excluded prefix must be an IPv6 prefix");
|
|
}
|
|
}
|
|
|
|
|
|
// An "unspecified" prefix should have both value and length equal to 0.
|
|
// An "unspecified" prefix should have both value and length equal to 0.
|
|
- if ((excluded_prefix_.isV6Zero() && (excluded_prefix_len_ != 0)) ||
|
|
|
|
- (!excluded_prefix_.isV6Zero() && (excluded_prefix_len_ == 0))) {
|
|
|
|
|
|
+ if ((excluded_prefix.isV6Zero() && (excluded_prefix_len != 0)) ||
|
|
|
|
+ (!excluded_prefix.isV6Zero() && (excluded_prefix_len == 0))) {
|
|
isc_throw(BadValue, "invalid excluded prefix "
|
|
isc_throw(BadValue, "invalid excluded prefix "
|
|
- << excluded_prefix_ << "/"
|
|
|
|
- << static_cast<unsigned>(excluded_prefix_len_));
|
|
|
|
|
|
+ << excluded_prefix << "/"
|
|
|
|
+ << static_cast<unsigned>(excluded_prefix_len));
|
|
}
|
|
}
|
|
|
|
|
|
// If excluded prefix has been specified.
|
|
// If excluded prefix has been specified.
|
|
- if (!excluded_prefix_.isV6Zero() && (excluded_prefix_len_ != 0)) {
|
|
|
|
|
|
+ if (!excluded_prefix.isV6Zero() && (excluded_prefix_len != 0)) {
|
|
|
|
|
|
// Excluded prefix length must not be greater than 128.
|
|
// Excluded prefix length must not be greater than 128.
|
|
- if (excluded_prefix_len_ > 128) {
|
|
|
|
|
|
+ if (excluded_prefix_len > 128) {
|
|
isc_throw(BadValue, "excluded prefix length "
|
|
isc_throw(BadValue, "excluded prefix length "
|
|
- << static_cast<unsigned>(excluded_prefix_len_)
|
|
|
|
|
|
+ << static_cast<unsigned>(excluded_prefix_len)
|
|
<< " must not be greater than 128");
|
|
<< " must not be greater than 128");
|
|
}
|
|
}
|
|
|
|
|
|
// Excluded prefix must be a sub-prefix of a delegated prefix. First
|
|
// Excluded prefix must be a sub-prefix of a delegated prefix. First
|
|
// check the prefix length as it is less involved.
|
|
// check the prefix length as it is less involved.
|
|
- if (excluded_prefix_len_ <= prefix_len_) {
|
|
|
|
|
|
+ if (excluded_prefix_len <= prefix_len_) {
|
|
isc_throw(BadValue, "excluded prefix length "
|
|
isc_throw(BadValue, "excluded prefix length "
|
|
- << static_cast<unsigned>(excluded_prefix_len_)
|
|
|
|
|
|
+ << static_cast<unsigned>(excluded_prefix_len)
|
|
<< " must be lower than the delegated prefix length "
|
|
<< " must be lower than the delegated prefix length "
|
|
<< static_cast<unsigned>(prefix_len_));
|
|
<< static_cast<unsigned>(prefix_len_));
|
|
}
|
|
}
|
|
@@ -188,7 +182,7 @@ Pool6::init(const Lease::Type& type,
|
|
const asiolink::IOAddress& prefix,
|
|
const asiolink::IOAddress& prefix,
|
|
const uint8_t prefix_len,
|
|
const uint8_t prefix_len,
|
|
const uint8_t delegated_len,
|
|
const uint8_t delegated_len,
|
|
- const asiolink::IOAddress& /*excluded_prefix*/,
|
|
|
|
|
|
+ const asiolink::IOAddress& excluded_prefix,
|
|
const uint8_t excluded_prefix_len) {
|
|
const uint8_t excluded_prefix_len) {
|
|
// Check if the prefix is sane
|
|
// Check if the prefix is sane
|
|
if (!prefix.isV6()) {
|
|
if (!prefix.isV6()) {
|
|
@@ -231,6 +225,14 @@ Pool6::init(const Lease::Type& type,
|
|
// For addresses, we could use addrsInRange(prefix, last_), but it's
|
|
// For addresses, we could use addrsInRange(prefix, last_), but it's
|
|
// much faster to do calculations on prefix lengths.
|
|
// much faster to do calculations on prefix lengths.
|
|
capacity_ = prefixesInRange(prefix_len, delegated_len);
|
|
capacity_ = prefixesInRange(prefix_len, delegated_len);
|
|
|
|
+
|
|
|
|
+ // If user specified an excluded prefix, create an option that will
|
|
|
|
+ // be sent to clients obtaining prefixes from this pool.
|
|
|
|
+ if (excluded_prefix_len > 0) {
|
|
|
|
+ pd_exclude_option_.reset(new Option6PDExclude(prefix, delegated_len,
|
|
|
|
+ excluded_prefix,
|
|
|
|
+ excluded_prefix_len));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
std::string
|
|
std::string
|
|
@@ -238,12 +240,11 @@ Pool6::toText() const {
|
|
std::ostringstream s;
|
|
std::ostringstream s;
|
|
s << "type=" << Lease::typeToText(type_) << ", " << first_
|
|
s << "type=" << Lease::typeToText(type_) << ", " << first_
|
|
<< "-" << last_ << ", delegated_len="
|
|
<< "-" << last_ << ", delegated_len="
|
|
- << static_cast<int>(prefix_len_);
|
|
|
|
|
|
+ << static_cast<unsigned>(prefix_len_);
|
|
|
|
|
|
- if (excluded_prefix_len_ > 0) {
|
|
|
|
- s << ", excluded_prefix=" << excluded_prefix_
|
|
|
|
- << ", excluded_prefix_len="
|
|
|
|
- << static_cast<unsigned>(excluded_prefix_len_);
|
|
|
|
|
|
+ if (pd_exclude_option_) {
|
|
|
|
+ s << ", excluded_prefix_len="
|
|
|
|
+ << static_cast<unsigned>(pd_exclude_option_->getExcludedPrefixLength());
|
|
}
|
|
}
|
|
return (s.str());
|
|
return (s.str());
|
|
}
|
|
}
|