 |
Kea
1.5.0
|
Go to the documentation of this file.
22 :id_(getNextID()), first_(first), last_(last), type_(type),
23 capacity_(0), cfg_option_(new
CfgOption()), client_class_(
""),
24 last_allocated_(first), last_allocated_valid_(false) {
41 std::stringstream tmp;
75 if (prefix_len == 0 || prefix_len > 32) {
99 map->set(
"option-data", opts->toElement());
103 if (!cclass.empty()) {
104 map->set(
"client-class", Element::create(cclass));
109 if (!classes.
empty()) {
112 it != classes.
cend(); ++it) {
113 class_list->add(Element::create(*it));
115 map->set(
"require-client-classes", class_list);
129 std::string range = first.
toText() +
"-" + last.
toText();
133 if (prefix_len >= 0) {
134 std::ostringstream oss;
135 oss << first.
toText() <<
"/" << prefix_len;
139 map->set(
"pool", Element::create(range));
146 :
Pool(type, first, last), prefix_len_(128), pd_exclude_option_() {
149 if (!first.
isV6() || !last.
isV6()) {
156 <<
", must be TYPE_IA, TYPE_TA or TYPE_PD");
177 <<
static_cast<int>(type));
187 const uint8_t prefix_len,
const uint8_t delegated_len )
189 prefix_len_(delegated_len), pd_exclude_option_() {
191 init(type, prefix, prefix_len, delegated_len,
196 const uint8_t delegated_len,
198 const uint8_t excluded_prefix_len)
200 prefix_len_(delegated_len), pd_exclude_option_() {
202 init(
Lease::TYPE_PD, prefix, prefix_len, delegated_len, excluded_prefix,
203 excluded_prefix_len);
208 if (!excluded_prefix.
isV6()) {
213 if ((excluded_prefix.
isV6Zero() && (excluded_prefix_len != 0)) ||
214 (!excluded_prefix.
isV6Zero() && (excluded_prefix_len == 0))) {
216 << excluded_prefix <<
"/"
217 <<
static_cast<unsigned>(excluded_prefix_len));
221 if (!excluded_prefix.
isV6Zero() && (excluded_prefix_len != 0)) {
224 if (excluded_prefix_len > 128) {
226 <<
static_cast<unsigned>(excluded_prefix_len)
227 <<
" must not be greater than 128");
232 if (excluded_prefix_len <= prefix_len_) {
234 <<
static_cast<unsigned>(excluded_prefix_len)
235 <<
" must be lower than the delegated prefix length "
236 <<
static_cast<unsigned>(prefix_len_));
250 const uint8_t prefix_len,
251 const uint8_t delegated_len,
253 const uint8_t excluded_prefix_len) {
255 if (!prefix.
isV6()) {
260 if (prefix_len == 0 || prefix_len > 128) {
262 <<
static_cast<unsigned>(prefix_len));
265 if (prefix_len > delegated_len) {
267 <<
static_cast<int>(delegated_len)
268 <<
") must be longer than or equal to prefix length ("
269 <<
static_cast<int>(prefix_len) <<
")");
273 (delegated_len != 128)) {
274 isc_throw(BadValue,
"For IA or TA pools, delegated prefix length must"
279 if (excluded_prefix_len && (excluded_prefix_len < delegated_len)) {
280 isc_throw(BadValue,
"Excluded prefix (" <<
static_cast<int>(excluded_prefix_len)
281 <<
") must be longer than the delegated prefix length ("
282 <<
static_cast<int>(delegated_len));
298 if (excluded_prefix_len > 0) {
299 pd_exclude_option_.reset(
new Option6PDExclude(prefix, delegated_len,
301 excluded_prefix_len));
314 std::string range = first.
toText() +
"-" + last.
toText();
318 if (prefix_len >= 0) {
319 std::ostringstream oss;
320 oss << first.
toText() <<
"/" << prefix_len;
324 map->set(
"pool", Element::create(range));
330 map->set(
"prefix", Element::create(prefix.
toText()));
335 if (prefix_len < 0) {
340 map->set(
"prefix-len", Element::create(prefix_len));
344 map->set(
"delegated-len", Element::create(
static_cast<int>(len)));
349 const IOAddress& xprefix = xopt->getExcludedPrefix(prefix, len);
350 map->set(
"excluded-prefix", Element::create(xprefix.
toText()));
352 uint8_t xlen = xopt->getExcludedPrefixLength();
353 map->set(
"excluded-prefix-len",
354 Element::create(
static_cast<int>(xlen)));
368 <<
", unsupported for Pool6");
378 std::ostringstream s;
380 <<
"-" <<
last_ <<
", delegated_len="
381 <<
static_cast<unsigned>(prefix_len_);
383 if (pd_exclude_option_) {
384 s <<
", excluded_prefix_len="
385 <<
static_cast<unsigned>(pd_exclude_option_->getExcludedPrefixLength());
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
const ClientClass & getClientClass() const
returns the client class
The IOAddress class represents an IP addresses (version agnostic)
Lease::Type getType() const
returns pool type
uint64_t addrsInRange(const isc::asiolink::IOAddress &min, const isc::asiolink::IOAddress &max)
Returns number of available addresses in the specified range (min - max).
virtual data::ElementPtr toElement() const
Unparse a Pool6 object.
isc::asiolink::IOAddress last_
The last address in a pool.
const isc::asiolink::IOAddress & getLastAddress() const
Returns the last address in a pool.
Type
Type of lease or pool.
int prefixLengthFromRange(const isc::asiolink::IOAddress &min, const isc::asiolink::IOAddress &max)
Returns prefix length from the specified range (min - max).
bool isV6() const
Convenience function to check for an IPv6 address.
const ClientClasses & getRequiredClasses() const
Returns classes which are required to be evaluated.
Represents option data configuration for the DHCP server.
void allowClientClass(const ClientClass &class_name)
Sets the supported class to class class_name.
Lease::Type type_
defines a lease type that will be served from this pool
Defines the logger used by the top-level component of kea-dhcp-ddns.
uint8_t getLength() const
returns delegated prefix length
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
const_iterator cbegin() const
Iterator to the first element.
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
uint64_t prefixesInRange(const uint8_t pool_len, const uint8_t delegated_len)
Returns number of available IPv6 prefixes in the specified prefix.
ClientClass client_class_
Optional definition of a client class.
bool smallerEqual(const IOAddress &other) const
Checks if one address is smaller or equal than the other.
bool contains(const ClientClass &x) const
returns if class x belongs to the defined classes
@ TYPE_TA
the lease contains temporary IPv6 address
bool empty() const
Check if classes is empty.
std::string toText() const
Convert the address to a string.
bool clientSupported(const ClientClasses &client_classes) const
Checks whether this pool supports client that belongs to specified classes.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
Pool6(Lease::Type type, const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
the constructor for Pool6 "min-max" style definition
const isc::asiolink::IOAddress & getFirstAddress() const
Returns the first address in a pool.
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this pool.
std::list< ClientClass >::const_iterator const_iterator
Type of iterators.
std::string ClientClass
Defines a single class name.
boost::shared_ptr< Option6PDExclude > Option6PDExcludePtr
Pointer to the Option6PDExclude object.
base class for Pool4 and Pool6
Option6PDExcludePtr getPrefixExcludeOption() const
Returns instance of the pool specific Prefix Exclude option.
virtual std::string toText() const
returns textual representation of the pool
isc::asiolink::IOAddress first_
The first address in a pool.
uint64_t capacity_
Stores number of possible leases.
isc::asiolink::IOAddress lastAddrInPrefix(const isc::asiolink::IOAddress &prefix, uint8_t len)
returns a last address in a given prefix
boost::shared_ptr< Element > ElementPtr
bool isV6Zero() const
Convenience function to check if it is an IPv4 zero address.
static std::string typeToText(Type type)
returns text representation of a lease type
bool inRange(const isc::asiolink::IOAddress &addr) const
Checks if a given address is in the range.
a common structure for IPv4 and IPv6 leases
virtual data::ElementPtr toElement() const
Unparse a pool object.
bool isV4() const
Convenience function to check for an IPv4 address.
virtual std::string toText() const
returns textual representation of the pool
@ TYPE_NA
the lease contains non-temporary IPv6 address
Pool4(const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
the constructor for Pool4 "min-max" style definition
const_iterator cend() const
Iterator to the past the end element.
virtual data::ElementPtr toElement() const
Unparse a Pool4 object.
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
Container for storing client class names.