Kea 2.7.5
pool.h
Go to the documentation of this file.
1// Copyright (C) 2012-2024 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 <cc/data.h>
12#include <cc/user_context.h>
13#include <dhcp/classify.h>
16#include <dhcpsrv/cfg_option.h>
17#include <dhcpsrv/lease.h>
19#include <util/bigints.h>
20
21#include <boost/shared_ptr.hpp>
22
23#include <vector>
24
25namespace isc {
26namespace dhcp {
27
33
34public:
37
44 uint64_t getID() const {
45 return (id_);
46 }
47
54 void setID(const uint64_t id) {
55 id_ = id;
56 }
57
62 return (first_);
63 }
64
68 return (last_);
69 }
70
74 bool inRange(const isc::asiolink::IOAddress& addr) const;
75
79 return (type_);
80 }
81
85 virtual std::string toText() const;
86
92 virtual ~Pool() = default;
93
100 return (capacity_);
101 }
102
105 return (cfg_option_);
106 }
107
111 return (cfg_option_);
112 }
113
119 bool clientSupported(const ClientClasses& client_classes) const;
120
124 void allowClientClass(const isc::dhcp::ClientClass& class_name);
125
128 return (client_classes_);
129 }
130
135
139 void addAdditionalClass(const ClientClass& class_name);
140
143 return (additional_classes_);
144 }
145
150
159
163 void setAllocationState(const AllocationStatePtr& allocation_state) {
164 allocation_state_ = allocation_state;
165 }
166
170 virtual data::ElementPtr toElement() const;
171
172protected:
173
183 Pool(Lease::Type type,
184 const isc::asiolink::IOAddress& first,
185 const isc::asiolink::IOAddress& last);
186
191 uint64_t id_;
192
195
198
201
209
212
220
225
228
231};
232
233class Pool4;
234
236typedef boost::shared_ptr<Pool4> Pool4Ptr;
237
242class Pool4 : public Pool {
243public:
248 Pool4(const isc::asiolink::IOAddress& first,
249 const isc::asiolink::IOAddress& last);
250
255 Pool4(const isc::asiolink::IOAddress& prefix,
256 uint8_t prefix_len);
257
269 static Pool4Ptr create(const isc::asiolink::IOAddress& first,
270 const isc::asiolink::IOAddress& last);
271
283 static Pool4Ptr create(const isc::asiolink::IOAddress& prefix,
284 uint8_t prefix_len);
285
289 virtual data::ElementPtr toElement() const;
290};
291
292class Pool6;
293
295typedef boost::shared_ptr<Pool6> Pool6Ptr;
296
301class Pool6 : public Pool {
302public:
303
311 Pool6(Lease::Type type, const isc::asiolink::IOAddress& first,
312 const isc::asiolink::IOAddress& last);
313
341 Pool6(Lease::Type type, const isc::asiolink::IOAddress& prefix,
342 uint8_t prefix_len, uint8_t delegated_len = 128);
343
356 Pool6(const asiolink::IOAddress& prefix, const uint8_t prefix_len,
357 const uint8_t delegated_len,
358 const asiolink::IOAddress& excluded_prefix,
359 const uint8_t excluded_prefix_len);
360
373 static Pool6Ptr create(Lease::Type type,
374 const isc::asiolink::IOAddress& first,
375 const isc::asiolink::IOAddress& last);
376
390 static Pool6Ptr create(Lease::Type type,
391 const isc::asiolink::IOAddress& prefix,
392 uint8_t prefix_len,
393 uint8_t delegated_len = 128);
394
409 static Pool6Ptr create(const asiolink::IOAddress& prefix,
410 const uint8_t prefix_len,
411 const uint8_t delegated_len,
412 const asiolink::IOAddress& excluded_prefix,
413 const uint8_t excluded_prefix_len);
414
419 return (type_);
420 }
421
427 uint8_t getLength() const {
428 return (prefix_len_);
429 }
430
436 return (pd_exclude_option_);
437 }
438
442 virtual data::ElementPtr toElement() const;
443
447 virtual std::string toText() const;
448
449private:
450
469 void init(const Lease::Type& type,
470 const asiolink::IOAddress& prefix,
471 const uint8_t prefix_len,
472 const uint8_t delegated_len,
473 const asiolink::IOAddress& excluded_prefix,
474 const uint8_t excluded_prefix_len);
475
477 uint8_t prefix_len_;
478
480 Option6PDExcludePtr pd_exclude_option_;
481
482};
483
485typedef boost::shared_ptr<Pool> PoolPtr;
486
488typedef std::vector<PoolPtr> PoolCollection;
489
490} // end of isc::dhcp namespace
491} // end of isc namespace
492
493#endif // POOL_H
Defines elements for storing the names of client classes.
Container for storing client class names.
Definition classify.h:109
Pool information for IPv4 addresses.
Definition pool.h:242
virtual data::ElementPtr toElement() const
Unparse a Pool4 object.
Definition pool.cc:149
Pool4(const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
the constructor for Pool4 "min-max" style definition
Definition pool.cc:59
static Pool4Ptr create(const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
Factory function for creating an instance of the Pool4.
Definition pool.cc:109
Pool information for IPv6 addresses and prefixes.
Definition pool.h:301
uint8_t getLength() const
returns delegated prefix length
Definition pool.h:427
virtual data::ElementPtr toElement() const
Unparse a Pool6 object.
Definition pool.cc:360
Option6PDExcludePtr getPrefixExcludeOption() const
Returns instance of the pool specific Prefix Exclude option.
Definition pool.h:435
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.
Definition pool.cc:273
virtual std::string toText() const
returns textual representation of the pool
Definition pool.cc:430
Pool6(Lease::Type type, const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
the constructor for Pool6 "min-max" style definition
Definition pool.cc:170
Lease::Type getType() const
returns pool type
Definition pool.h:418
base class for Pool4 and Pool6
Definition pool.h:32
data::ConstElementPtr user_context_
Pointer to the user context (may be NULL)
Definition pool.h:227
const ClientClasses & getAdditionalClasses() const
Returns the additional classes list.
Definition pool.h:142
virtual data::ElementPtr toElement() const
Unparse a pool object.
Definition pool.cc:119
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this pool.
Definition pool.h:211
void setID(const uint64_t id)
Sets Pool-id.
Definition pool.h:54
ClientClasses & getMutableAdditionalClasses()
Returns the mutable additional classes list.
Definition pool.h:147
Pool(Lease::Type type, const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
protected constructor
Definition pool.cc:21
isc::util::uint128_t getCapacity() const
Returns the number of all leases in this pool.
Definition pool.h:99
const isc::asiolink::IOAddress & getFirstAddress() const
Returns the first address in a pool.
Definition pool.h:61
ClientClasses additional_classes_
Additional classes.
Definition pool.h:224
uint64_t id_
pool-id
Definition pool.h:191
AllocationStatePtr getAllocationState() const
Returns pool-specific allocation state.
Definition pool.h:156
Lease::Type getType() const
Returns pool type (v4, v6 non-temporary, v6 temp, v6 prefix)
Definition pool.h:78
const isc::asiolink::IOAddress & getLastAddress() const
Returns the last address in a pool.
Definition pool.h:67
ClientClasses & getMutableClientClasses()
Returns the mutable list of allowed client classes.
Definition pool.h:132
void setAllocationState(const AllocationStatePtr &allocation_state)
Sets pool-specific allocation state.
Definition pool.h:163
isc::util::uint128_t capacity_
Stores number of possible leases.
Definition pool.h:208
uint64_t getID() const
Returns Pool-id.
Definition pool.h:44
ClientClasses client_classes_
List of client classes allowed to use this pool.
Definition pool.h:219
const ClientClasses & getClientClasses() const
Returns the list of allowed client classes.
Definition pool.h:127
void allowClientClass(const isc::dhcp::ClientClass &class_name)
Adds class clas_name to the allowed client classes list.
Definition pool.cc:38
isc::asiolink::IOAddress last_
The last address in a pool.
Definition pool.h:197
AllocationStatePtr allocation_state_
Holds pool-specific allocation state.
Definition pool.h:230
isc::asiolink::IOAddress first_
The first address in a pool.
Definition pool.h:194
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this pool.
Definition pool.h:104
virtual std::string toText() const
returns textual representation of the pool
Definition pool.cc:52
bool inRange(const isc::asiolink::IOAddress &addr) const
Checks if a given address is in the range.
Definition pool.cc:28
void addAdditionalClass(const ClientClass &class_name)
Adds class class_name to the additional classes list.
Definition pool.cc:45
bool clientSupported(const ClientClasses &client_classes) const
Checks whether this pool supports client that belongs to specified classes.
Definition pool.cc:33
virtual ~Pool()=default
virtual destructor
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this pool.
Definition pool.h:110
Lease::Type type_
defines a lease type that will be served from this pool
Definition pool.h:200
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
boost::shared_ptr< Pool4 > Pool4Ptr
a pointer an IPv4 Pool
Definition pool.h:236
std::string ClientClass
Defines a single class name.
Definition classify.h:43
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition cfg_option.h:832
boost::shared_ptr< Option6PDExclude > Option6PDExcludePtr
Pointer to the Option6PDExclude object.
boost::shared_ptr< AllocationState > AllocationStatePtr
Type of the pointer to the AllocationState.
std::vector< PoolPtr > PoolCollection
a container for either IPv4 or IPv6 Pools
Definition pool.h:488
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Definition pool.h:485
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
Definition cfg_option.h:835
boost::shared_ptr< Pool6 > Pool6Ptr
a pointer an IPv6 Pool
Definition pool.h:295
boost::multiprecision::checked_uint128_t uint128_t
Definition bigints.h:21
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.
Base class for user context.
Type
Type of lease or pool.
Definition lease.h:46