Kea 1.5.0
pool.h
Go to the documentation of this file.
1// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef POOL_H
8#define POOL_H
9
10#include <asiolink/io_address.h>
11#include <dhcp/classify.h>
13#include <boost/shared_ptr.hpp>
14#include <cc/data.h>
15#include <cc/user_context.h>
16#include <dhcpsrv/cfg_option.h>
17#include <dhcpsrv/lease.h>
18#include <boost/shared_ptr.hpp>
19
20#include <vector>
21
22namespace isc {
23namespace dhcp {
24
30
31public:
34
39 uint32_t getId() const {
40 return (id_);
41 }
42
47 return (first_);
48 }
49
53 return (last_);
54 }
55
59 bool inRange(const isc::asiolink::IOAddress& addr) const;
60
64 return (type_);
65 }
66
70 virtual std::string toText() const;
71
77 virtual ~Pool() {
78 }
79
85 uint64_t getCapacity() const {
86 return (capacity_);
87 }
88
91 return (cfg_option_);
92 }
93
97 return (cfg_option_);
98 }
99
107 bool clientSupported(const ClientClasses& client_classes) const;
108
112 void allowClientClass(const ClientClass& class_name);
113
121 return (client_class_);
122 }
123
127 void requireClientClass(const ClientClass& class_name) {
128 if (!required_classes_.contains(class_name)) {
129 required_classes_.insert(class_name);
130 }
131 }
132
135 return (required_classes_);
136 }
137
142 return last_allocated_;
143 }
144
147 bool isLastAllocatedValid() const {
149 }
150
155 last_allocated_ = addr;
157 }
158
161 last_allocated_valid_ = false;
162 }
163
167 virtual data::ElementPtr toElement() const;
168
169protected:
170
180 Pool(Lease::Type type,
181 const isc::asiolink::IOAddress& first,
182 const isc::asiolink::IOAddress& last);
183
187 static uint32_t getNextID() {
188 static uint32_t id = 0;
189 return (id++);
190 }
191
195 uint32_t id_;
196
199
202
205
212 uint64_t capacity_;
213
216
221
226
229
234
237};
238
243class Pool4 : public Pool {
244public:
249 Pool4(const isc::asiolink::IOAddress& first,
250 const isc::asiolink::IOAddress& last);
251
256 Pool4(const isc::asiolink::IOAddress& prefix,
257 uint8_t prefix_len);
258
262 virtual data::ElementPtr toElement() const;
263};
264
266typedef boost::shared_ptr<Pool4> Pool4Ptr;
267
272class Pool6 : public Pool {
273public:
274
282 Pool6(Lease::Type type, const isc::asiolink::IOAddress& first,
283 const isc::asiolink::IOAddress& last);
284
312 Pool6(Lease::Type type, const isc::asiolink::IOAddress& prefix,
313 uint8_t prefix_len, uint8_t delegated_len = 128);
314
327 Pool6(const asiolink::IOAddress& prefix, const uint8_t prefix_len,
328 const uint8_t delegated_len,
329 const asiolink::IOAddress& excluded_prefix,
330 const uint8_t excluded_prefix_len);
331
336 return (type_);
337 }
338
344 uint8_t getLength() const {
345 return (prefix_len_);
346 }
347
353 return (pd_exclude_option_);
354 }
355
359 virtual data::ElementPtr toElement() const;
360
364 virtual std::string toText() const;
365
366private:
367
386 void init(const Lease::Type& type,
387 const asiolink::IOAddress& prefix,
388 const uint8_t prefix_len,
389 const uint8_t delegated_len,
390 const asiolink::IOAddress& excluded_prefix,
391 const uint8_t excluded_prefix_len);
392
394 uint8_t prefix_len_;
395
397 Option6PDExcludePtr pd_exclude_option_;
398
399};
400
402typedef boost::shared_ptr<Pool6> Pool6Ptr;
403
405typedef boost::shared_ptr<Pool> PoolPtr;
406
408typedef std::vector<PoolPtr> PoolCollection;
409
410
411} // end of isc::dhcp namespace
412} // end of isc namespace
413
414
415#endif // POOL_H
Defines elements for storing the names of client classes.
Container for storing client class names.
Definition: classify.h:43
bool contains(const ClientClass &x) const
returns if class x belongs to the defined classes
Definition: classify.h:94
void insert(const ClientClass &class_name)
Insert an element.
Definition: classify.h:62
Pool information for IPv4 addresses.
Definition: pool.h:243
virtual data::ElementPtr toElement() const
Unparse a Pool4 object.
Definition: pool.cc:122
Pool information for IPv6 addresses and prefixes.
Definition: pool.h:272
uint8_t getLength() const
returns delegated prefix length
Definition: pool.h:344
virtual data::ElementPtr toElement() const
Unparse a Pool6 object.
Definition: pool.cc:306
Option6PDExcludePtr getPrefixExcludeOption() const
Returns instance of the pool specific Prefix Exclude option.
Definition: pool.h:352
virtual std::string toText() const
returns textual representation of the pool
Definition: pool.cc:377
Lease::Type getType() const
returns pool type
Definition: pool.h:335
base class for Pool4 and Pool6
Definition: pool.h:29
data::ConstElementPtr user_context_
Pointer to the user context (may be NULL)
Definition: pool.h:228
virtual data::ElementPtr toElement() const
Unparse a pool object.
Definition: pool.cc:90
void setLastAllocated(const isc::asiolink::IOAddress &addr)
sets the last address that was tried from this pool
Definition: pool.h:154
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this pool.
Definition: pool.h:215
const isc::asiolink::IOAddress & getFirstAddress() const
Returns the first address in a pool.
Definition: pool.h:46
uint32_t getId() const
returns Pool-id
Definition: pool.h:39
void allowClientClass(const ClientClass &class_name)
Sets the supported class to class class_name.
Definition: pool.cc:35
Lease::Type getType() const
Returns pool type (v4, v6 non-temporary, v6 temp, v6 prefix)
Definition: pool.h:63
const isc::asiolink::IOAddress & getLastAddress() const
Returns the last address in a pool.
Definition: pool.h:52
isc::asiolink::IOAddress last_allocated_
Last allocated address See isc::dhcp::Subnet::last_allocated_ia_ Initialized and reset to first.
Definition: pool.h:233
bool last_allocated_valid_
Status of last allocated address.
Definition: pool.h:236
const ClientClass & getClientClass() const
returns the client class
Definition: pool.h:120
ClientClasses required_classes_
Required classes.
Definition: pool.h:225
void resetLastAllocated()
resets the last address to invalid
Definition: pool.h:160
const ClientClasses & getRequiredClasses() const
Returns classes which are required to be evaluated.
Definition: pool.h:134
isc::asiolink::IOAddress last_
The last address in a pool.
Definition: pool.h:201
uint64_t capacity_
Stores number of possible leases.
Definition: pool.h:212
static uint32_t getNextID()
returns the next unique Pool-ID
Definition: pool.h:187
isc::asiolink::IOAddress first_
The first address in a pool.
Definition: pool.h:198
virtual ~Pool()
virtual destructor
Definition: pool.h:77
void requireClientClass(const ClientClass &class_name)
Adds class class_name to classes required to be evaluated.
Definition: pool.h:127
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this pool.
Definition: pool.h:90
virtual std::string toText() const
returns textual representation of the pool
Definition: pool.cc:40
bool inRange(const isc::asiolink::IOAddress &addr) const
Checks if a given address is in the range.
Definition: pool.cc:27
uint32_t id_
pool-id
Definition: pool.h:195
ClientClass client_class_
Optional definition of a client class.
Definition: pool.h:220
bool isLastAllocatedValid() const
checks if the last address is valid
Definition: pool.h:147
bool clientSupported(const ClientClasses &client_classes) const
Checks whether this pool supports client that belongs to specified classes.
Definition: pool.cc:31
isc::asiolink::IOAddress getLastAllocated() const
returns the last address that was tried from this pool
Definition: pool.h:141
uint64_t getCapacity() const
Returns the number of all leases in this pool.
Definition: pool.h:85
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this pool.
Definition: pool.h:96
Lease::Type type_
defines a lease type that will be served from this pool
Definition: pool.h:204
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
boost::shared_ptr< Element > ElementPtr
Definition: data.h:22
boost::shared_ptr< Pool4 > Pool4Ptr
a pointer an IPv4 Pool
Definition: pool.h:266
std::string ClientClass
Defines a single class name.
Definition: classify.h:37
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition: cfg_option.h:497
boost::shared_ptr< Option6PDExclude > Option6PDExcludePtr
Pointer to the Option6PDExclude object.
std::vector< PoolPtr > PoolCollection
a container for either IPv4 or IPv6 Pools
Definition: pool.h:408
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Definition: pool.h:405
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
Definition: cfg_option.h:500
boost::shared_ptr< Pool6 > Pool6Ptr
a pointer an IPv6 Pool
Definition: pool.h:402
Defines the logger used by the top-level component of kea-dhcp-ddns.
Base class for user context.
Definition: user_context.h:22
Type
Type of lease or pool.
Definition: lease.h:38