12#include <boost/make_shared.hpp> 
   53    std::stringstream tmp;
 
 
   82        isc_throw(BadValue, 
"Invalid Pool4 address boundaries: not IPv4");
 
 
  100    if (!prefix.
isV4()) {
 
  101        isc_throw(BadValue, 
"Invalid Pool4 address boundaries: not IPv4");
 
  105    if (prefix_len == 0 || prefix_len > 32) {
 
  110    if (first_address != prefix) {
 
  112                  << 
" is not the first address in prefix: " << first_address
 
  113                  << 
"/" << 
static_cast<uint32_t
>(prefix_len));
 
 
  128    return (boost::make_shared<Pool4>(first, last));
 
 
  133    return (boost::make_shared<Pool4>(prefix, prefix_len));
 
 
  146    map->set(
"option-data", opts->toElement());
 
  155        map->set(
"evaluate-additional-classes",
 
  178            map->set(
"ddns-replace-client-name",
 
 
  235    std::string range = first.
toText() + 
"-" + last.
toText();
 
  239    if (prefix_len >= 0) {
 
  240        std::ostringstream oss;
 
  241        oss << first.
toText() << 
"/" << prefix_len;
 
 
  251    : 
Pool(type, first, last), prefix_len_(128), pd_exclude_option_() {
 
  254    if (!first.
isV6() || !last.
isV6()) {
 
  255        isc_throw(BadValue, 
"Invalid Pool6 address boundaries: not IPv6");
 
  261                  << 
", must be TYPE_IA, TYPE_TA or TYPE_PD");
 
  282                  << 
static_cast<int>(type));
 
 
  292             const uint8_t prefix_len, 
const uint8_t delegated_len )
 
  294      prefix_len_(delegated_len), pd_exclude_option_() {
 
  296    init(type, prefix, prefix_len, delegated_len,
 
 
  301             const uint8_t delegated_len,
 
  303             const uint8_t excluded_prefix_len)
 
  305      prefix_len_(delegated_len), pd_exclude_option_() {
 
  307    init(
Lease::TYPE_PD, prefix, prefix_len, delegated_len, excluded_prefix,
 
  308         excluded_prefix_len);
 
  313    if (!excluded_prefix.
isV6()) {
 
  318    if ((excluded_prefix.
isV6Zero() && (excluded_prefix_len != 0)) ||
 
  319        (!excluded_prefix.
isV6Zero() && (excluded_prefix_len == 0))) {
 
  321                  << excluded_prefix << 
"/" 
  322                  << 
static_cast<unsigned>(excluded_prefix_len));
 
  326    if (!excluded_prefix.
isV6Zero() && (excluded_prefix_len != 0)) {
 
  328        if (excluded_prefix_len > 128) {
 
  330                      << 
static_cast<unsigned>(excluded_prefix_len)
 
  331                      << 
" must not be greater than 128");
 
  336        if (excluded_prefix_len <= prefix_len_) {
 
  338                      << 
static_cast<unsigned>(excluded_prefix_len)
 
  339                      << 
" must be longer than the delegated prefix length " 
  340                      << 
static_cast<unsigned>(prefix_len_));
 
 
  353    return (boost::make_shared<Pool6>(type, first, last));
 
 
  358              uint8_t prefix_len, uint8_t delegated_len) {
 
  359    return (boost::make_shared<Pool6>(type, prefix, prefix_len, delegated_len));
 
 
  364              const uint8_t delegated_len, 
const IOAddress& excluded_prefix,
 
  365              const uint8_t excluded_prefix_len) {
 
  366    return (boost::make_shared<Pool6>(prefix, prefix_len,
 
  367                                      delegated_len, excluded_prefix,
 
  368                                      excluded_prefix_len));
 
 
  374            const uint8_t prefix_len,
 
  375            const uint8_t delegated_len,
 
  377            const uint8_t excluded_prefix_len) {
 
  379    if (!prefix.
isV6()) {
 
  384    if (prefix_len == 0 || prefix_len > 128) {
 
  386                  << 
static_cast<unsigned>(prefix_len));
 
  389    if (prefix_len > delegated_len) {
 
  391                  << 
static_cast<int>(delegated_len)
 
  392                  << 
") must be longer than or equal to prefix length (" 
  393                  << 
static_cast<int>(prefix_len) << 
")");
 
  397        isc_throw(BadValue, 
"For NA or TA pools, delegated prefix length must" 
  402    if (excluded_prefix_len && (excluded_prefix_len <= delegated_len)) {
 
  404                  << 
static_cast<int>(excluded_prefix_len)
 
  405                  << 
") must be longer than the delegated prefix length (" 
  406                  << 
static_cast<int>(delegated_len) << 
")");
 
  409    if (prefix_len != 128) {
 
  411        if (first_address != prefix) {
 
  412            isc_throw(BadValue, 
"Invalid Pool6 address boundaries: " << prefix
 
  413                      << 
" is not the first address in prefix: " << first_address
 
  414                      << 
"/" << 
static_cast<uint32_t
>(prefix_len));
 
  431    if (excluded_prefix_len > 0) {
 
  432        pd_exclude_option_.reset(
new Option6PDExclude(prefix, delegated_len,
 
  434                                                      excluded_prefix_len));
 
  447            std::string range = first.
toText() + 
"-" + last.
toText();
 
  451            if (prefix_len >= 0) {
 
  452                std::ostringstream oss;
 
  453                oss << first.
toText() << 
"/" << prefix_len;
 
  468            if (prefix_len < 0) {
 
  482                const IOAddress& xprefix = xopt->getExcludedPrefix(prefix, len);
 
  485                uint8_t xlen = xopt->getExcludedPrefixLength();
 
  486                map->set(
"excluded-prefix-len",
 
  501                      << 
", unsupported for Pool6");
 
 
  510    std::ostringstream s;
 
  512      << 
"-" << 
last_ << 
", delegated_len=" 
  513      << 
static_cast<unsigned>(prefix_len_);
 
  515    if (pd_exclude_option_) {
 
  516       s << 
", excluded_prefix=" 
  517         << pd_exclude_option_->getExcludedPrefix(
first_, prefix_len_).toText()
 
  519         << 
static_cast<unsigned>(pd_exclude_option_->getExcludedPrefixLength());
 
 
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
The IOAddress class represents an IP addresses (version agnostic)
std::string toText() const
Convert the address to a string.
bool isV6() const
Convenience function to check for an IPv6 address.
bool isV4() const
Convenience function to check for an IPv4 address.
bool isV6Zero() const
Convenience function to check if it is an IPv4 zero address.
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Represents option data configuration for the DHCP server.
Container for storing client class names.
Acts as a storage vault for D2 client configuration.
virtual data::ElementPtr toElement() const
Unparse a Pool4 object.
Pool4(const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
the constructor for Pool4 "min-max" style definition
static Pool4Ptr create(const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
Factory function for creating an instance of the Pool4.
uint8_t getLength() const
returns delegated prefix length
virtual data::ElementPtr toElement() const
Unparse a Pool6 object.
Option6PDExcludePtr getPrefixExcludeOption() const
Returns instance of the pool specific Prefix Exclude option.
static Pool6Ptr create(Lease::Type type, const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
Factory function for creating an instance of the Pool6.
virtual std::string toText() const
returns textual representation of the pool
Pool6(Lease::Type type, const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
the constructor for Pool6 "min-max" style definition
Lease::Type getType() const
returns pool type
virtual data::ElementPtr toElement() const
Unparse a pool object.
util::Optional< uint32_t > ddns_ttl_
Explicit value to use for DNS TTL.
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this pool.
util::Optional< std::string > hostname_char_replacement_
A string to replace invalid characters when scrubbing hostnames.
util::Optional< uint32_t > ddns_ttl_max_
Maximum value to use for DNS TTL.
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
Pool(Lease::Type type, const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
protected constructor
util::Optional< std::string > ddns_qualifying_suffix_
Suffix Kea should use when to qualify partial domain-names.
util::Optional< std::string > hostname_char_set_
Regular expression describing invalid characters for client hostnames.
const isc::asiolink::IOAddress & getFirstAddress() const
Returns the first address in a pool.
util::Optional< D2ClientConfig::ReplaceClientNameMode > ddns_replace_client_name_mode_
How Kea should handle the domain-name supplied by the client.
ClientClasses additional_classes_
Additional classes.
bool hasDdnsParameters() const
Checks if any of the DDNS parameters has a value.
util::Optional< uint32_t > ddns_ttl_min_
Minimum value to use for DNS TTL.
const isc::asiolink::IOAddress & getLastAddress() const
Returns the last address in a pool.
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
util::Optional< bool > ddns_override_client_update_
Should Kea perform updates, even if client requested delegation.
util::Optional< double > ddns_ttl_percent_
Percentage of the lease lifetime to use for DNS TTL.
isc::util::uint128_t capacity_
Stores number of possible leases.
ClientClasses client_classes_
List of client classes allowed to use this pool.
void allowClientClass(const isc::dhcp::ClientClass &class_name)
Adds class clas_name to the allowed client classes list.
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
isc::asiolink::IOAddress last_
The last address in a pool.
isc::asiolink::IOAddress first_
The first address in a pool.
util::Optional< std::string > ddns_conflict_resolution_mode_
DDNS conflict resolution mode.
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this pool.
virtual std::string toText() const
returns textual representation of the pool
bool inRange(const isc::asiolink::IOAddress &addr) const
Checks if a given address is in the range.
void addAdditionalClass(const ClientClass &class_name)
Adds class class_name to the additional classes list.
bool clientSupported(const ClientClasses &client_classes) const
Checks whether this pool supports client that belongs to specified classes.
Lease::Type type_
defines a lease type that will be served from this pool
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
IOAddress firstAddrInPrefix(const IOAddress &prefix, uint8_t len)
This code is based on similar code from the Dibbler project.
uint128_t addrsInRange(const IOAddress &min, const IOAddress &max)
Returns number of available addresses in the specified range (min - max).
uint128_t prefixesInRange(const uint8_t pool_len, const uint8_t delegated_len)
Returns number of available IPv6 prefixes in the specified prefix.
IOAddress lastAddrInPrefix(const IOAddress &prefix, uint8_t len)
returns a last address in a given prefix
int prefixLengthFromRange(const IOAddress &min, const IOAddress &max)
Returns prefix length from the specified range (min - max).
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< Pool4 > Pool4Ptr
a pointer an IPv4 Pool
std::string ClientClass
Defines a single class name.
boost::shared_ptr< Option6PDExclude > Option6PDExcludePtr
Pointer to the Option6PDExclude object.
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
boost::shared_ptr< Pool6 > Pool6Ptr
a pointer an IPv6 Pool
Defines the logger used by the top-level component of kea-lfc.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
a common structure for IPv4 and IPv6 leases
Type
Type of lease or pool.
@ TYPE_TA
the lease contains temporary IPv6 address
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
@ TYPE_NA
the lease contains non-temporary IPv6 address
static std::string typeToText(Type type)
returns text representation of a lease type