Commit 35253241 authored by Francis Dupont's avatar Francis Dupont
Browse files

[5425a] Reported some changes

parent f85ebcc1
......@@ -1961,7 +1961,7 @@ should include options from the isc option space:
<para>
Client classification can also be used to restrict access to specific
pools within a subnet. This is useful when to segregate clients belonging
to the same subnet into different address ranges.
to the same subnet into different address or prefix ranges.
</para>
<para>
......
// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -83,7 +83,6 @@ protected:
///
/// @param subnet next address will be returned from pool of that subnet
/// @param client_classes list of classes client belongs to
/// @param duid Client's DUID
/// @param hint client's hint
///
......
// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -651,8 +651,14 @@ private:
/// A storage for pool specific option values.
CfgOptionPtr options_;
/// @brief User context (optional, may be null)
///
/// User context is arbitrary user data, to be used by hooks.
isc::data::ConstElementPtr user_context_;
/// @brief Client class (a client has to belong to to use this pd-pool)
///
/// If null, everyone is allowed.
isc::data::ConstElementPtr client_class_;
};
......
// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -340,6 +340,7 @@ Pool6::toElement() const {
isc_throw(ToElementError, "invalid prefix range "
<< prefix.toText() << "-" << last.toText());
}
map->set("prefix-len", Element::create(prefix_len));
// Set delegated-len
uint8_t len = getLength();
......@@ -354,10 +355,14 @@ Pool6::toElement() const {
uint8_t xlen = xopt->getExcludedPrefixLength();
map->set("excluded-prefix-len",
Element::create(static_cast<int>(xlen)));
} else {
map->set("excluded-prefix", Element::create(std::string("::")));
map->set("excluded-prefix-len", Element::create(0));
}
// Let's not insert empty excluded-prefix values. If we ever
// decide to insert it after all, here's the code to do it:
// else {
// map->set("excluded-prefix",
// Element::create(std::string("::")));
// map->set("excluded-prefix-len", Element::create(0));
/// }
break;
}
......
......@@ -100,8 +100,7 @@ public:
/// @brief Checks whether this pool supports client that belongs to
/// specified classes.
///
/// @todo: currently doing the same than network which
/// is known to be improved.
/// @todo: currently doing the same as network which needs improving.
///
/// @param client_classes list of all classes the client belongs to
/// @return true if client can be supported, false otherwise
......@@ -204,6 +203,9 @@ protected:
/// @brief Optional definition of a client class
///
/// If empty, all classes are allowed. If non-empty, only those listed
/// here are allowed.
///
/// @ref Network::white_list_
ClientClasses white_list_;
......
// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -709,94 +709,16 @@ Subnet6::toElement() const {
ElementPtr pool_list = Element::createList();
for (PoolCollection::const_iterator pool = pools.cbegin();
pool != pools.cend(); ++pool) {
// Prepare the map for a pool (@todo move this code to pool.cc)
ElementPtr pool_map = Element::createMap();
// Set user-context
(*pool)->contextToElement(pool_map);
// Set pool
const IOAddress& first = (*pool)->getFirstAddress();
const IOAddress& last = (*pool)->getLastAddress();
std::string range = first.toText() + "-" + last.toText();
// Try to output a prefix (vs a range)
int prefix_len = prefixLengthFromRange(first, last);
if (prefix_len >= 0) {
std::ostringstream oss;
oss << first.toText() << "/" << prefix_len;
range = oss.str();
}
pool_map->set("pool", Element::create(range));
// Set pool options
ConstCfgOptionPtr opts = (*pool)->getCfgOption();
pool_map->set("option-data", opts->toElement());
// Set client-class
const ClientClasses& cclasses = (*pool)->getClientClasses();
if (cclasses.size() > 1) {
isc_throw(ToElementError, "client-class has too many items: "
<< cclasses.size());
} else if (!cclasses.empty()) {
pool_map->set("client-class", Element::create(*cclasses.cbegin()));
}
// Push on the pool list
pool_list->add(pool_map);
pool_list->add((*pool)->toElement());
}
map->set("pools", pool_list);
// Set pd-pools
const PoolCollection& pdpools = getPools(Lease::TYPE_PD);
ElementPtr pdpool_list = Element::createList();
for (PoolCollection::const_iterator pool = pdpools.cbegin();
pool != pdpools.cend(); ++pool) {
// Get it as a Pool6 (@todo move this code to pool.cc)
const Pool6* pdpool = dynamic_cast<Pool6*>(pool->get());
if (!pdpool) {
isc_throw(ToElementError, "invalid pd-pool pointer");
}
// Prepare the map for a pd-pool
ElementPtr pool_map = Element::createMap();
// Set user-context
pdpool->contextToElement(pool_map);
// Set prefix
const IOAddress& prefix = pdpool->getFirstAddress();
pool_map->set("prefix", Element::create(prefix.toText()));
// Set prefix-len (get it from min - max)
const IOAddress& last = pdpool->getLastAddress();
int prefix_len = prefixLengthFromRange(prefix, last);
if (prefix_len < 0) {
// The pool is bad: give up
isc_throw(ToElementError, "invalid prefix range "
<< prefix.toText() << "-" << last.toText());
}
pool_map->set("prefix-len", Element::create(prefix_len));
// Set delegated-len
uint8_t len = pdpool->getLength();
pool_map->set("delegated-len",
Element::create(static_cast<int>(len)));
// Set excluded prefix
const Option6PDExcludePtr& xopt =
pdpool->getPrefixExcludeOption();
if (xopt) {
const IOAddress& xprefix =
xopt->getExcludedPrefix(prefix, len);
pool_map->set("excluded-prefix",
Element::create(xprefix.toText()));
uint8_t xlen = xopt->getExcludedPrefixLength();
pool_map->set("excluded-prefix-len",
Element::create(static_cast<int>(xlen)));
}
// Set pool options
ConstCfgOptionPtr opts = pdpool->getCfgOption();
pool_map->set("option-data", opts->toElement());
// Set client-class
const ClientClasses& cclasses = pdpool->getClientClasses();
if (cclasses.size() > 1) {
isc_throw(ToElementError, "client-class has too many items: "
<< cclasses.size());
} else if (!cclasses.empty()) {
pool_map->set("client-class", Element::create(*cclasses.cbegin()));
}
// Push on the pool list
pdpool_list->add(pool_map);
pdpool_list->add((*pool)->toElement());
}
map->set("pd-pools", pdpool_list);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment