Kea 3.3.3
ddns_params.cc
Go to the documentation of this file.
1// Copyright (C) 2014-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#include <config.h>
8
10#include <dhcpsrv/ddns_params.h>
11
12namespace isc {
13namespace dhcp {
14
15bool
17 if (!subnet_) {
18 return (false);
19 }
20
21 if (pool_) {
22 auto optional = pool_->getDdnsSendUpdates();
23 if (!optional.unspecified()) {
24 return (optional.get());
25 }
26 }
27
28 return (d2_client_enabled_ && subnet_->getDdnsSendUpdates().get());
29}
30
31bool
33 if (!subnet_) {
34 return (false);
35 }
36
37 if (pool_) {
38 auto optional = pool_->getDdnsOverrideNoUpdate();
39 if (!optional.unspecified()) {
40 return (optional.get());
41 }
42 }
43
44 return (subnet_->getDdnsOverrideNoUpdate().get());
45}
46
48 if (!subnet_) {
49 return (false);
50 }
51
52 if (pool_) {
53 auto optional = pool_->getDdnsOverrideClientUpdate();
54 if (!optional.unspecified()) {
55 return (optional.get());
56 }
57 }
58
59 return (subnet_->getDdnsOverrideClientUpdate().get());
60}
61
64 if (!subnet_) {
66 }
67
68 if (pool_) {
69 auto optional = pool_->getDdnsReplaceClientNameMode();
70 if (!optional.unspecified()) {
71 return (optional.get());
72 }
73 }
74
75 return (subnet_->getDdnsReplaceClientNameMode().get());
76}
77
78std::string
80 if (!subnet_) {
81 return ("");
82 }
83
84 if (pool_) {
85 auto optional = pool_->getDdnsGeneratedPrefix();
86 if (!optional.unspecified()) {
87 return (optional.get());
88 }
89 }
90
91 return (subnet_->getDdnsGeneratedPrefix().get());
92}
93
94std::string
96 if (!subnet_) {
97 return ("");
98 }
99
100 if (pool_) {
101 auto optional = pool_->getDdnsQualifyingSuffix();
102 if (!optional.unspecified()) {
103 return (optional.get());
104 }
105 }
106
107 return (subnet_->getDdnsQualifyingSuffix().get());
108}
109
110std::string
112 if (!subnet_) {
113 return ("");
114 }
115
116 return (subnet_->getHostnameCharSet().get());
117}
118
119std::string
121 if (!subnet_) {
122 return ("");
123 }
124
125 return (subnet_->getHostnameCharReplacement().get());
126}
127
131 if (subnet_) {
132 std::string char_set = getHostnameCharSet();
133 if (!char_set.empty()) {
134 try {
135 sanitizer.reset(new util::str::StringSanitizer(char_set,
137 } catch (const std::exception& ex) {
138 isc_throw(BadValue, "hostname_char_set_: '" << char_set <<
139 "' is not a valid regular expression");
140 }
141 }
142 }
143
144 return (sanitizer);
145}
146
147bool
149 if (!subnet_) {
150 return (false);
151 }
152
153 if (pool_) {
154 auto optional = pool_->getDdnsUpdateOnRenew();
155 if (!optional.unspecified()) {
156 return (optional.get());
157 }
158 }
159
160 return (subnet_->getDdnsUpdateOnRenew().get());
161}
162
163std::string
165 if (!subnet_) {
166 return ("check-with-dhcid");
167 }
168
169 if (pool_) {
170 auto optional = pool_->getDdnsConflictResolutionMode();
171 if (!optional.unspecified()) {
172 return (optional.get());
173 }
174 }
175
176 return (subnet_->getDdnsConflictResolutionMode().get());
177}
178
179
182 if (!subnet_) {
183 return (util::Optional<double>());
184 }
185
186 if (pool_) {
187 auto optional = pool_->getDdnsTtlPercent();
188 if (!optional.unspecified()) {
189 return (optional.get());
190 }
191 }
192
193 return (subnet_->getDdnsTtlPercent());
194}
195
198 if (!subnet_) {
199 return (util::Optional<uint32_t>());
200 }
201
202 if (pool_) {
203 auto optional = pool_->getDdnsTtl();
204 if (!optional.unspecified()) {
205 return (optional.get());
206 }
207 }
208
209 return (subnet_->getDdnsTtl());
210}
211
214 if (!subnet_) {
215 return (util::Optional<uint32_t>());
216 }
217
218 if (pool_) {
219 auto optional = pool_->getDdnsTtlMin();
220 if (!optional.unspecified()) {
221 return (optional.get());
222 }
223 }
224
225 return (subnet_->getDdnsTtlMin());
226}
227
230 if (!subnet_) {
231 return (util::Optional<uint32_t>());
232 }
233
234 if (pool_) {
235 auto optional = pool_->getDdnsTtlMax();
236 if (!optional.unspecified()) {
237 return (optional.get());
238 }
239 }
240
241 return (subnet_->getDdnsTtlMax());
242}
243
244std::string
246 if (!subnet_) {
247 return ("");
248 }
249
250 if (pool_) {
251 auto optional = pool_->getDdnsReverseZone();
252 if (!optional.unspecified()) {
253 return (optional.get());
254 }
255 }
256
257 return (subnet_->getDdnsReverseZone().get());
258}
259
262 if (!subnet_) {
265 "DdnsParams::setPoolFromAddress called without a subnet");
266 }
267
268 pool_ = subnet_->getPool((address.isV4() ? Lease::TYPE_V4 : Lease::TYPE_NA),
269 address, false);
270 return (pool_);
271}
272
273} // namespace dhcp
274} // namespace isc
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown if a function is called in a prohibited way.
ReplaceClientNameMode
Defines the client name replacement modes.
std::string getHostnameCharReplacement() const
Returns the string to replace invalid characters when scrubbing hostnames.
D2ClientConfig::ReplaceClientNameMode getReplaceClientNameMode() const
Returns how Kea should handle the domain-name supplied by the client.
std::string getReverseZone() const
Returns the reverse zone Kea should use for PTR records.
std::string getGeneratedPrefix() const
Returns the Prefix Kea should use when generating domain-names.
util::Optional< double > getTtlPercent() const
Returns percent of lease lifetime to use for TTL.
isc::util::str::StringSanitizerPtr getHostnameSanitizer() const
Returns a regular expression string sanitizer.
std::string getHostnameCharSet() const
Returns the regular expression describing invalid characters for client hostnames.
util::Optional< uint32_t > getTtl() const
Returns explicit TTL to use.
std::string getConflictResolutionMode() const
Returns the DDNS config resolution mode for kea-dhcp-ddns.
std::string getQualifyingSuffix() const
Returns the suffix Kea should use when to qualify partial domain-names.
bool getUpdateOnRenew() const
Returns whether or not DNS should be updated when leases renew.
bool getOverrideNoUpdate() const
Returns whether or not Kea should perform updates, even if client requested no updates.
util::Optional< uint32_t > getTtlMax() const
Returns the maximum TTL to use.
PoolPtr setPoolFromAddress(const asiolink::IOAddress &address)
Sets the pool based on the current subnet and given address.
util::Optional< uint32_t > getTtlMin() const
Returns the minimum TTL to use.
bool getEnableUpdates() const
Returns whether or not DHCP DDNS updating is enabled.
bool getOverrideClientUpdate() const
Returns whether or not Kea should perform updates, even if client requested delegation.
A template representing an optional value.
Definition optional.h:37
Implements a regular expression based string scrubber.
Definition str.h:222
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Definition pool.h:741
std::unique_ptr< StringSanitizer > StringSanitizerPtr
Type representing the pointer to the StringSanitizer.
Definition str.h:263
Defines the logger used by the top-level component of kea-lfc.
@ TYPE_V4
IPv4 lease.
Definition lease.h:52
@ TYPE_NA
the lease contains non-temporary IPv6 address
Definition lease.h:49