Kea 3.3.3
pool.h
Go to the documentation of this file.
1// Copyright (C) 2012-2025 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>
18#include <dhcpsrv/lease.h>
20#include <util/bigints.h>
21#include <util/optional.h>
22
23#include <boost/shared_ptr.hpp>
24
25#include <vector>
26
27namespace isc {
28namespace dhcp {
29
35
36public:
39
46 uint64_t getID() const {
47 return (id_);
48 }
49
56 void setID(const uint64_t id) {
57 id_ = id;
58 }
59
64 return (first_);
65 }
66
70 return (last_);
71 }
72
76 bool inRange(const isc::asiolink::IOAddress& addr) const;
77
81 return (type_);
82 }
83
87 virtual std::string toText() const;
88
94 virtual ~Pool() = default;
95
102 return (capacity_);
103 }
104
107 return (cfg_option_);
108 }
109
113 return (cfg_option_);
114 }
115
121 bool clientSupported(const ClientClasses& client_classes) const;
122
126 void allowClientClass(const isc::dhcp::ClientClass& class_name);
127
130 return (client_classes_);
131 }
132
137
141 void addAdditionalClass(const ClientClass& class_name);
142
145 return (additional_classes_);
146 }
147
152
161
165 void setAllocationState(const AllocationStatePtr& allocation_state) {
166 allocation_state_ = allocation_state;
167 }
168
172 virtual data::ElementPtr toElement() const;
173
174
178 return (ddns_send_updates_);
179 }
180
184 void setDdnsSendUpdates(const util::Optional<bool>& ddns_send_updates) {
185 ddns_send_updates_ = ddns_send_updates;
186 }
187
193
197 void setDdnsOverrideNoUpdate(const util::Optional<bool>& ddns_override_no_update) {
198 ddns_override_no_update_ = ddns_override_no_update;
199 }
200
206
211 ddns_override_client_update) {
212 ddns_override_client_update_ = ddns_override_client_update;
213 }
214
220
224 void
226 ddns_replace_client_name_mode) {
227 ddns_replace_client_name_mode_ = ddns_replace_client_name_mode;
228 }
229
233 return (ddns_generated_prefix_);
234 }
235
239 void setDdnsGeneratedPrefix(const util::Optional<std::string>& ddns_generated_prefix) {
240 ddns_generated_prefix_ = ddns_generated_prefix;
241 }
242
248
252 void setDdnsQualifyingSuffix(const util::Optional<std::string>& ddns_qualifying_suffix) {
253 ddns_qualifying_suffix_ = ddns_qualifying_suffix;
254 }
255
259 return (ddns_reverse_zone_);
260 }
261
265 void setDdnsReverseZone(const util::Optional<std::string>& ddns_reverse_zone) {
266 ddns_reverse_zone_ = ddns_reverse_zone;
267 }
268
272 return (ddns_update_on_renew_);
273 }
274
278 void setDdnsUpdateOnRenew(const util::Optional<bool>& ddns_update_on_renew) {
279 ddns_update_on_renew_ = ddns_update_on_renew;
280 }
281
287
291 void setDdnsConflictResolutionMode(const util::Optional<std::string>& ddns_conflict_resolution_mode) {
292 ddns_conflict_resolution_mode_ = ddns_conflict_resolution_mode;
293 }
294
295
299 return (ddns_ttl_percent_);
300 }
301
305 void setDdnsTtlPercent(const util::Optional<double>& ddns_ttl_percent) {
306 ddns_ttl_percent_ = ddns_ttl_percent;
307 }
308
311 getDdnsTtl() const {
312 return (ddns_ttl_);
313 }
314
318 void setDdnsTtl(const util::Optional<uint32_t>& ddns_ttl) {
319 ddns_ttl_ = ddns_ttl;
320 }
321
325 return (ddns_ttl_min_);
326 }
327
331 void setDdnsTtlMin(const util::Optional<uint32_t>& ddns_ttl_min) {
332 ddns_ttl_min_ = ddns_ttl_min;
333 }
334
338 return (ddns_ttl_max_);
339 }
340
344 void setDdnsTtlMax(const util::Optional<uint32_t>& ddns_ttl_max) {
345 ddns_ttl_max_ = ddns_ttl_max;
346 }
347
351 return (hostname_char_set_);
352 }
353
357 void setHostnameCharSet(const util::Optional<std::string>& hostname_char_set) {
358 hostname_char_set_ = hostname_char_set;
359 }
360
366
371 hostname_char_replacement) {
372 hostname_char_replacement_ = hostname_char_replacement;
373 }
374
378 bool hasDdnsParameters() const;
379
380protected:
381
391 Pool(Lease::Type type,
392 const isc::asiolink::IOAddress& first,
393 const isc::asiolink::IOAddress& last);
394
399 uint64_t id_;
400
403
406
409
417
420
428
433
436
439
443
447
450
453
456
459
462
465
468
471
474
477
480
484
488};
489
490class Pool4;
491
493typedef boost::shared_ptr<Pool4> Pool4Ptr;
494
499class Pool4 : public Pool {
500public:
505 Pool4(const isc::asiolink::IOAddress& first,
506 const isc::asiolink::IOAddress& last);
507
512 Pool4(const isc::asiolink::IOAddress& prefix,
513 uint8_t prefix_len);
514
526 static Pool4Ptr create(const isc::asiolink::IOAddress& first,
527 const isc::asiolink::IOAddress& last);
528
540 static Pool4Ptr create(const isc::asiolink::IOAddress& prefix,
541 uint8_t prefix_len);
542
546 virtual data::ElementPtr toElement() const;
547};
548
549class Pool6;
550
552typedef boost::shared_ptr<Pool6> Pool6Ptr;
553
558class Pool6 : public Pool {
559public:
560
568 Pool6(Lease::Type type, const isc::asiolink::IOAddress& first,
569 const isc::asiolink::IOAddress& last);
570
598 Pool6(Lease::Type type, const isc::asiolink::IOAddress& prefix,
599 uint8_t prefix_len, uint8_t delegated_len = 128);
600
613 Pool6(const asiolink::IOAddress& prefix, const uint8_t prefix_len,
614 const uint8_t delegated_len,
615 const asiolink::IOAddress& excluded_prefix,
616 const uint8_t excluded_prefix_len);
617
630 static Pool6Ptr create(Lease::Type type,
631 const isc::asiolink::IOAddress& first,
632 const isc::asiolink::IOAddress& last);
633
647 static Pool6Ptr create(Lease::Type type,
648 const isc::asiolink::IOAddress& prefix,
649 uint8_t prefix_len,
650 uint8_t delegated_len = 128);
651
666 static Pool6Ptr create(const asiolink::IOAddress& prefix,
667 const uint8_t prefix_len,
668 const uint8_t delegated_len,
669 const asiolink::IOAddress& excluded_prefix,
670 const uint8_t excluded_prefix_len);
671
676 return (type_);
677 }
678
684 uint8_t getLength() const {
685 return (prefix_len_);
686 }
687
693 return (pd_exclude_option_);
694 }
695
699 virtual data::ElementPtr toElement() const;
700
704 virtual std::string toText() const;
705
706private:
707
726 void init(const Lease::Type& type,
727 const asiolink::IOAddress& prefix,
728 const uint8_t prefix_len,
729 const uint8_t delegated_len,
730 const asiolink::IOAddress& excluded_prefix,
731 const uint8_t excluded_prefix_len);
732
734 uint8_t prefix_len_;
735
737 Option6PDExcludePtr pd_exclude_option_;
738
739};
740
742typedef boost::shared_ptr<Pool> PoolPtr;
743
745typedef std::vector<PoolPtr> PoolCollection;
746
747} // end of isc::dhcp namespace
748} // end of isc namespace
749
750#endif // POOL_H
Defines elements for storing the names of client classes.
Container for storing client class names.
Definition classify.h:111
Pool information for IPv4 addresses.
Definition pool.h:499
virtual data::ElementPtr toElement() const
Unparse a Pool4 object.
Definition pool.cc:232
Pool4(const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
the constructor for Pool4 "min-max" style definition
Definition pool.cc:77
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:127
Pool information for IPv6 addresses and prefixes.
Definition pool.h:558
uint8_t getLength() const
returns delegated prefix length
Definition pool.h:684
virtual data::ElementPtr toElement() const
Unparse a Pool6 object.
Definition pool.cc:442
Option6PDExcludePtr getPrefixExcludeOption() const
Returns instance of the pool specific Prefix Exclude option.
Definition pool.h:692
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:355
virtual std::string toText() const
returns textual representation of the pool
Definition pool.cc:512
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:253
Lease::Type getType() const
returns pool type
Definition pool.h:675
data::ConstElementPtr user_context_
Pointer to the user context (may be NULL).
Definition pool.h:435
util::Optional< std::string > getHostnameCharSet() const
Return the char set regexp used to sanitize client hostnames.
Definition pool.h:350
const ClientClasses & getAdditionalClasses() const
Returns the additional classes list.
Definition pool.h:144
virtual data::ElementPtr toElement() const
Unparse a pool object.
Definition pool.cc:137
util::Optional< uint32_t > ddns_ttl_
Explicit value to use for DNS TTL.
Definition pool.h:473
util::Optional< std::string > getDdnsQualifyingSuffix() const
Returns ddns-qualifying-suffix.
Definition pool.h:245
util::Optional< std::string > getDdnsReverseZone() const
Returns ddns-reverse-zone.
Definition pool.h:258
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this pool.
Definition pool.h:419
util::Optional< double > getDdnsTtlPercent() const
Returns ddns-ttl-percent.
Definition pool.h:298
util::Optional< std::string > hostname_char_replacement_
A string to replace invalid characters when scrubbing hostnames.
Definition pool.h:487
void setDdnsTtlPercent(const util::Optional< double > &ddns_ttl_percent)
Sets new ddns-ttl-percent.
Definition pool.h:305
util::Optional< uint32_t > ddns_ttl_max_
Maximum value to use for DNS TTL.
Definition pool.h:479
void setID(const uint64_t id)
Sets Pool-id.
Definition pool.h:56
ClientClasses & getMutableAdditionalClasses()
Returns the mutable additional classes list.
Definition pool.h:149
void setDdnsOverrideNoUpdate(const util::Optional< bool > &ddns_override_no_update)
Sets new ddns-override-no-update.
Definition pool.h:197
void setDdnsTtlMin(const util::Optional< uint32_t > &ddns_ttl_min)
Sets new ddns-ttl-min.
Definition pool.h:331
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
Definition pool.h:464
Pool(Lease::Type type, const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
protected constructor
Definition pool.cc:21
util::Optional< bool > getDdnsUpdateOnRenew() const
Returns ddns-update-on-renew.
Definition pool.h:271
util::Optional< std::string > ddns_qualifying_suffix_
Suffix Kea should use when to qualify partial domain-names.
Definition pool.h:458
isc::util::uint128_t getCapacity() const
Returns the number of all leases in this pool.
Definition pool.h:101
util::Optional< D2ClientConfig::ReplaceClientNameMode > getDdnsReplaceClientNameMode() const
Returns ddns-replace-client-name-mode.
Definition pool.h:217
void setDdnsTtlMax(const util::Optional< uint32_t > &ddns_ttl_max)
Sets new ddns-ttl-max.
Definition pool.h:344
void setHostnameCharSet(const util::Optional< std::string > &hostname_char_set)
Sets new hostname-char-set.
Definition pool.h:357
util::Optional< std::string > hostname_char_set_
Regular expression describing invalid characters for client hostnames.
Definition pool.h:483
const isc::asiolink::IOAddress & getFirstAddress() const
Returns the first address in a pool.
Definition pool.h:63
util::Optional< bool > getDdnsSendUpdates() const
Returns ddns-send-updates.
Definition pool.h:177
util::Optional< D2ClientConfig::ReplaceClientNameMode > ddns_replace_client_name_mode_
How Kea should handle the domain-name supplied by the client.
Definition pool.h:452
ClientClasses additional_classes_
Additional classes.
Definition pool.h:432
void setDdnsConflictResolutionMode(const util::Optional< std::string > &ddns_conflict_resolution_mode)
Sets new ddns-conflict-resolution-mode.
Definition pool.h:291
bool hasDdnsParameters() const
Checks if any of the DDNS parameters has a value.
Definition pool.cc:60
util::Optional< uint32_t > ddns_ttl_min_
Minimum value to use for DNS TTL.
Definition pool.h:476
uint64_t id_
pool-id
Definition pool.h:399
AllocationStatePtr getAllocationState() const
Returns pool-specific allocation state.
Definition pool.h:158
Lease::Type getType() const
Returns pool type (v4, v6 non-temporary, v6 temp, v6 prefix).
Definition pool.h:80
const isc::asiolink::IOAddress & getLastAddress() const
Returns the last address in a pool.
Definition pool.h:69
void setDdnsTtl(const util::Optional< uint32_t > &ddns_ttl)
Sets new ddns-ttl.
Definition pool.h:318
util::Optional< uint32_t > getDdnsTtlMax() const
Returns ddns-ttl-max.
Definition pool.h:337
ClientClasses & getMutableClientClasses()
Returns the mutable list of allowed client classes.
Definition pool.h:134
void setAllocationState(const AllocationStatePtr &allocation_state)
Sets pool-specific allocation state.
Definition pool.h:165
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
Definition pool.h:455
util::Optional< bool > ddns_override_client_update_
Should Kea perform updates, even if client requested delegation.
Definition pool.h:449
util::Optional< double > ddns_ttl_percent_
Percentage of the lease lifetime to use for DNS TTL.
Definition pool.h:470
void setDdnsSendUpdates(const util::Optional< bool > &ddns_send_updates)
Sets new ddns-send-updates.
Definition pool.h:184
isc::util::uint128_t capacity_
Stores number of possible leases.
Definition pool.h:416
uint64_t getID() const
Returns Pool-id.
Definition pool.h:46
ClientClasses client_classes_
List of client classes allowed to use this pool.
Definition pool.h:427
util::Optional< std::string > getDdnsGeneratedPrefix() const
Returns ddns-generated-prefix.
Definition pool.h:232
const ClientClasses & getClientClasses() const
Returns the list of allowed client classes.
Definition pool.h:129
void allowClientClass(const isc::dhcp::ClientClass &class_name)
Adds class clas_name to the allowed client classes list.
Definition pool.cc:38
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
Definition pool.h:446
isc::asiolink::IOAddress last_
The last address in a pool.
Definition pool.h:405
util::Optional< std::string > ddns_reverse_zone_
Reverse zone Kea should use for PTR records.
Definition pool.h:461
AllocationStatePtr allocation_state_
Holds pool-specific allocation state.
Definition pool.h:438
isc::asiolink::IOAddress first_
The first address in a pool.
Definition pool.h:402
util::Optional< uint32_t > getDdnsTtlMin() const
Returns ddns-ttl-min.
Definition pool.h:324
util::Optional< bool > getDdnsOverrideNoUpdate() const
Returns ddns-override-no-update.
Definition pool.h:190
void setDdnsReplaceClientNameMode(const util::Optional< D2ClientConfig::ReplaceClientNameMode > &ddns_replace_client_name_mode)
Sets new ddns-replace-client-name-mode.
Definition pool.h:225
util::Optional< bool > getDdnsOverrideClientUpdate() const
Returns ddns-override-client-update.
Definition pool.h:203
util::Optional< std::string > ddns_conflict_resolution_mode_
DDNS conflict resolution mode.
Definition pool.h:467
void setDdnsQualifyingSuffix(const util::Optional< std::string > &ddns_qualifying_suffix)
Sets new ddns-qualifying-suffix.
Definition pool.h:252
void setDdnsUpdateOnRenew(const util::Optional< bool > &ddns_update_on_renew)
Sets new ddns-update-on-renew.
Definition pool.h:278
void setHostnameCharReplacement(const util::Optional< std::string > &hostname_char_replacement)
Sets new hostname-char-replacement.
Definition pool.h:370
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
Definition pool.h:442
void setDdnsGeneratedPrefix(const util::Optional< std::string > &ddns_generated_prefix)
Sets new ddns-generated-prefix.
Definition pool.h:239
util::Optional< uint32_t > getDdnsTtl() const
Returns ddns-ttl.
Definition pool.h:311
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this pool.
Definition pool.h:106
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 setDdnsReverseZone(const util::Optional< std::string > &ddns_reverse_zone)
Sets new ddns-reverse-zone.
Definition pool.h:265
void addAdditionalClass(const ClientClass &class_name)
Adds class class_name to the additional classes list.
Definition pool.cc:45
void setDdnsOverrideClientUpdate(const util::Optional< bool > &ddns_override_client_update)
Sets new ddns-override-client-update.
Definition pool.h:210
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
util::Optional< std::string > getHostnameCharReplacement() const
Return the invalid char replacement used to sanitize client hostnames.
Definition pool.h:363
util::Optional< std::string > getDdnsConflictResolutionMode() const
Returns ddns-conflict-resolution-mode.
Definition pool.h:284
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this pool.
Definition pool.h:112
Lease::Type type_
defines a lease type that will be served from this pool
Definition pool.h:408
A template representing an optional value.
Definition optional.h:37
Defines the D2ClientConfig class.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
boost::shared_ptr< Pool4 > Pool4Ptr
a pointer an IPv4 Pool
Definition pool.h:493
std::string ClientClass
Defines a single class name.
Definition classify.h:45
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition cfg_option.h:983
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:745
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Definition pool.h:742
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
Definition cfg_option.h:986
boost::shared_ptr< Pool6 > Pool6Ptr
a pointer an IPv6 Pool
Definition pool.h:552
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:48