Kea: d2_config.cc Source File

| Kea 3.0.2-git

d2_config.cc
Go to the documentation of this file.
1// Copyright (C) 2013-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#include <config.h>
8
9#include <asiolink/io_error.h>
10#include <d2srv/d2_log.h>
11#include <d2srv/d2_cfg_mgr.h>
12#include <dhcpsrv/parsers/dhcp_parsers.h>
13#include <exceptions/exceptions.h>
14#include <util/filesystem.h>
15
16#include <boost/scoped_ptr.hpp>
17#include <boost/algorithm/string/predicate.hpp>
18
19#include <sstream>
20#include <string>
21
22using namespace isc::data;
23using namespace isc::process;
24
25namespace isc {
26namespace d2 {
27
28// *********************** D2Params *************************
29
30 D2Params::D2Params(const isc::asiolink::IOAddress& ip_address,
31 const size_t port,
32 const size_t dns_server_timeout,
33 const dhcp_ddns::NameChangeProtocol& ncr_protocol,
34 const dhcp_ddns::NameChangeFormat& ncr_format)
35 : ip_address_(ip_address),
36 port_(port),
37 dns_server_timeout_(dns_server_timeout),
38 ncr_protocol_(ncr_protocol),
39 ncr_format_(ncr_format) {
40 validateContents();
41}
42
43D2Params::D2Params()
44 : ip_address_(isc::asiolink::IOAddress("127.0.0.1")),
45 port_(53001), dns_server_timeout_(500),
46 ncr_protocol_(dhcp_ddns::NCR_UDP),
47 ncr_format_(dhcp_ddns::FMT_JSON) {
48 validateContents();
49}
50
51D2Params::~D2Params(){};
52
53void
54D2Params::validateContents() {
55 if (port_ == 0) {
56 isc_throw(D2CfgError, "D2Params: port cannot be 0");
57 }
58
59 if (dns_server_timeout_ < 1) {
60 isc_throw(D2CfgError,
61 "D2Params: DNS server timeout must be larger than 0");
62 }
63
64 if (ncr_format_ != dhcp_ddns::FMT_JSON) {
65 isc_throw(D2CfgError, "D2Params: NCR Format:"
66 << dhcp_ddns::ncrFormatToString(ncr_format_)
67 << " is not yet supported");
68 }
69
70 if (ncr_protocol_ != dhcp_ddns::NCR_UDP) {
71 isc_throw(D2CfgError, "D2Params: NCR Protocol:"
72 << dhcp_ddns::ncrProtocolToString(ncr_protocol_)
73 << " is not yet supported");
74 }
75}
76
77std::string
78D2Params::getConfigSummary() const {
79 std::ostringstream s;
80 s << "listening on " << getIpAddress() << ", port " << getPort()
81 << ", using " << ncrProtocolToString(ncr_protocol_);
82 return (s.str());
83}
84
85bool
86D2Params::operator == (const D2Params& other) const {
87 return ((ip_address_ == other.ip_address_) &&
88 (port_ == other.port_) &&
89 (dns_server_timeout_ == other.dns_server_timeout_) &&
90 (ncr_protocol_ == other.ncr_protocol_) &&
91 (ncr_format_ == other.ncr_format_));
92}
93
94bool
95D2Params::operator != (const D2Params& other) const {
96 return (!(*this == other));
97}
98
99std::string
100D2Params::toText() const {
101 std::ostringstream stream;
102
103 stream << ", ip-address: " << ip_address_.toText()
104 << ", port: " << port_
105 << ", dns-server-timeout_: " << dns_server_timeout_
106 << ", ncr-protocol: "
107 << dhcp_ddns::ncrProtocolToString(ncr_protocol_)
108 << ", ncr-format: " << ncr_format_
109 << dhcp_ddns::ncrFormatToString(ncr_format_);
110
111 return (stream.str());
112}
113
114std::ostream&
115 operator<<(std::ostream& os, const D2Params& config) {
116 os << config.toText();
117 return (os);
118}
119
120// *********************** TSIGKeyInfo *************************
121// Note these values match corresponding values for Bind9's
122// dnssec-keygen
123const char* TSIGKeyInfo::HMAC_MD5_STR = "HMAC-MD5";
124const char* TSIGKeyInfo::HMAC_SHA1_STR = "HMAC-SHA1";
125const char* TSIGKeyInfo::HMAC_SHA224_STR = "HMAC-SHA224";
126const char* TSIGKeyInfo::HMAC_SHA256_STR = "HMAC-SHA256";
127const char* TSIGKeyInfo::HMAC_SHA384_STR = "HMAC-SHA384";
128const char* TSIGKeyInfo::HMAC_SHA512_STR = "HMAC-SHA512";
129
130TSIGKeyInfo::TSIGKeyInfo(const std::string& name, const std::string& algorithm,
131 const std::string& secret, std::string secret_file,
132 uint32_t digestbits)
133 : name_(name), algorithm_(algorithm), secret_(secret),
134 secret_file_(secret_file), digestbits_(digestbits), tsig_key_() {
135 remakeKey();
136}
137
138TSIGKeyInfo::~TSIGKeyInfo() {
139}
140
141const dns::Name&
142TSIGKeyInfo::stringToAlgorithmName(const std::string& algorithm_id) {
143 if (boost::iequals(algorithm_id, HMAC_MD5_STR)) {
144 return (dns::TSIGKey::HMACMD5_NAME());
145 } else if (boost::iequals(algorithm_id, HMAC_SHA1_STR)) {
146 return (dns::TSIGKey::HMACSHA1_NAME());
147 } else if (boost::iequals(algorithm_id, HMAC_SHA224_STR)) {
148 return (dns::TSIGKey::HMACSHA224_NAME());
149 } else if (boost::iequals(algorithm_id, HMAC_SHA256_STR)) {
150 return (dns::TSIGKey::HMACSHA256_NAME());
151 } else if (boost::iequals(algorithm_id, HMAC_SHA384_STR)) {
152 return (dns::TSIGKey::HMACSHA384_NAME());
153 } else if (boost::iequals(algorithm_id, HMAC_SHA512_STR)) {
154 return (dns::TSIGKey::HMACSHA512_NAME());
155 }
156
157 isc_throw(BadValue, "Unknown TSIG Key algorithm: " << algorithm_id);
158}
159
160void
161TSIGKeyInfo::remakeKey() {
162 try {
163 // Since our secret value is base64 encoded already, we need to
164 // build the input string for the appropriate D2TsigKey constructor.
165 // If secret isn't a valid base64 value, the constructor will throw.
166 std::ostringstream stream;
167 stream << dns::Name(name_).toText() << ":"
168 << secret_ << ":"
169 << stringToAlgorithmName(algorithm_);
170 if (digestbits_ > 0) {
171 stream << ":" << digestbits_;
172 }
173
174 tsig_key_.reset(new D2TsigKey(stream.str()));
175 } catch (const std::exception& ex) {
176 isc_throw(D2CfgError, "Cannot make D2TsigKey: " << ex.what());
177 }
178}
179
180 ElementPtr
181TSIGKeyInfo::toElement() const {
182 ElementPtr result = Element::createMap();
183 // Set user-context
184 contextToElement(result);
185 // Set name
186 result->set("name", Element::create(name_));
187 // Set algorithm
188 result->set("algorithm", Element::create(algorithm_));
189 // Set secret[-file]
190 if (!secret_file_.empty()) {
191 result->set("secret-file", Element::create(secret_file_));
192 } else {
193 result->set("secret", Element::create(secret_));
194 }
195 // Set digest-bits
196 result->set("digest-bits",
197 Element::create(static_cast<int64_t>(digestbits_)));
198
199 return (result);
200}
201
202// *********************** DnsServerInfo *************************
203DnsServerInfo::DnsServerInfo(const std::string& hostname,
204 isc::asiolink::IOAddress ip_address,
205 uint32_t port,
206 bool enabled,
207 const TSIGKeyInfoPtr& tsig_key_info,
208 bool inherited_key)
209 : hostname_(hostname), ip_address_(ip_address), port_(port),
210 enabled_(enabled), tsig_key_info_(tsig_key_info),
211 inherited_key_(inherited_key) {
212}
213
214DnsServerInfo::~DnsServerInfo() {
215}
216
217const std::string
218DnsServerInfo::getKeyName() const {
219 if (tsig_key_info_) {
220 return (tsig_key_info_->getName());
221 }
222
223 return ("");
224}
225
226std::string
227DnsServerInfo::toText() const {
228 std::ostringstream stream;
229 stream << (getIpAddress().toText()) << " port:" << getPort();
230 return (stream.str());
231}
232
233 ElementPtr
234DnsServerInfo::toElement() const {
235 ElementPtr result = Element::createMap();
236 // Set user-context
237 contextToElement(result);
238 // Set hostname
239 result->set("hostname", Element::create(hostname_));
240 // Set ip-address
241 result->set("ip-address", Element::create(ip_address_.toText()));
242 // Set port
243 result->set("port", Element::create(static_cast<int64_t>(port_)));
244 // Set key-name
245 if (tsig_key_info_ && !inherited_key_) {
246 result->set("key-name", Element::create(tsig_key_info_->getName()));
247 }
248
249 return (result);
250}
251
252std::ostream&
253 operator<<(std::ostream& os, const DnsServerInfo& server) {
254 os << server.toText();
255 return (os);
256}
257
258// *********************** DdnsDomain *************************
259
260DdnsDomain::DdnsDomain(const std::string& name,
261 DnsServerInfoStoragePtr servers,
262 const std::string& key_name)
263 : name_(name), servers_(servers), key_name_(key_name) {
264}
265
266DdnsDomain::~DdnsDomain() {
267}
268
269 ElementPtr
270DdnsDomain::toElement() const {
271 ElementPtr result = Element::createMap();
272 // Set user-context
273 contextToElement(result);
274 // Set name
275 result->set("name", Element::create(name_));
276 // Set servers
277 ElementPtr servers = Element::createList();
278 for (auto const& server : *servers_) {
279 ElementPtr dns_server = server->toElement();
280 servers->add(dns_server);
281 }
282 // the dns server list may not be empty
283 if (!servers->empty()) {
284 result->set("dns-servers", servers);
285 }
286 // Set key-name
287 if (!key_name_.empty()) {
288 result->set("key-name", Element::create(key_name_));
289 }
290
291 return (result);
292}
293
294// *********************** DdnsDomainLstMgr *************************
295
296const char* DdnsDomainListMgr::wildcard_domain_name_ = "*";
297
298DdnsDomainListMgr::DdnsDomainListMgr(const std::string& name) : name_(name),
299 domains_(new DdnsDomainMap()) {
300}
301
302
303DdnsDomainListMgr::~DdnsDomainListMgr () {
304}
305
306void
307DdnsDomainListMgr::setDomains(DdnsDomainMapPtr domains) {
308 if (!domains) {
309 isc_throw(D2CfgError,
310 "DdnsDomainListMgr::setDomains: Domain list may not be null");
311 }
312
313 domains_ = domains;
314
315 // Look for the wild card domain. If present, set the member variable
316 // to remember it. This saves us from having to look for it every time
317 // we attempt a match.
318 DdnsDomainMap::iterator gotit = domains_->find(wildcard_domain_name_);
319 if (gotit != domains_->end()) {
320 wildcard_domain_ = gotit->second;
321 }
322}
323
324bool
325DdnsDomainListMgr::matchDomain(const std::string& fqdn, DdnsDomainPtr& domain) {
326 // First check the case of one domain to rule them all.
327 if ((size() == 1) && (wildcard_domain_)) {
328 domain = wildcard_domain_;
329 return (true);
330 }
331
332 // Iterate over the domain map looking for the domain which matches
333 // the longest portion of the given fqdn.
334
335 size_t req_len = fqdn.size();
336 size_t match_len = 0;
337 DdnsDomainPtr best_match;
338 for (auto const& map_pair : *domains_) {
339 std::string domain_name = map_pair.first;
340 size_t dom_len = domain_name.size();
341
342 // If the domain name is longer than the fqdn, then it cant be match.
343 if (req_len < dom_len) {
344 continue;
345 }
346
347 // If the lengths are identical and the names match we're done.
348 if (req_len == dom_len) {
349 if (boost::iequals(fqdn, domain_name)) {
350 // exact match, done
351 domain = map_pair.second;
352 return (true);
353 }
354 } else {
355 // The fqdn is longer than the domain name. Adjust the start
356 // point of comparison by the excess in length. Only do the
357 // comparison if the adjustment lands on a boundary. This
358 // prevents "onetwo.net" from matching "two.net".
359 size_t offset = req_len - dom_len;
360 if ((fqdn[offset - 1] == '.') &&
361 (boost::iequals(fqdn.substr(offset), domain_name))) {
362 // Fqdn contains domain name, keep it if its better than
363 // any we have matched so far.
364 if (dom_len > match_len) {
365 match_len = dom_len;
366 best_match = map_pair.second;
367 }
368 }
369 }
370 }
371
372 if (!best_match) {
373 // There's no match. If they specified a wild card domain use it
374 // otherwise there's no domain for this entry.
375 if (wildcard_domain_) {
376 domain = wildcard_domain_;
377 return (true);
378 }
379
380 LOG_WARN(dhcp_to_d2_logger, DHCP_DDNS_NO_MATCH).arg(fqdn);
381 return (false);
382 }
383
384 domain = best_match;
385 return (true);
386}
387
388 ElementPtr
389DdnsDomainListMgr::toElement() const {
390 ElementPtr result = Element::createList();
391 // Iterate on ddns domains
392 for (auto const& domain : *domains_) {
393 ElementPtr ddns_domain = domain.second->toElement();
394 result->add(ddns_domain);
395 }
396
397 return (result);
398}
399
400// *************************** PARSERS ***********************************
401
402// *********************** TSIGKeyInfoParser *************************
403
404 TSIGKeyInfoPtr
405TSIGKeyInfoParser::parse(ConstElementPtr key_config) {
406 std::string name = getString(key_config, "name");
407 std::string algorithm = getString(key_config, "algorithm");
408 uint32_t digestbits = getInteger(key_config, "digest-bits");
409 std::string secret_file;
410 std::string secret;
411 if (key_config->contains("secret-file")) {
412 secret_file = getString(key_config, "secret-file");
413 try {
414 secret = util::file::getContent(secret_file);
415 if (secret.empty()) {
416 isc_throw(BadValue, "Expected '" << secret_file
417 << "' to not be empty");
418 }
419 } catch (const std::exception& ex) {
420 isc_throw(D2CfgError, "tsig-key : " << ex.what()
421 << " (" << getPosition("secret-file", key_config)
422 << ")");
423 }
424 } else {
425 secret = getString(key_config, "secret");
426 }
427 ConstElementPtr user_context = key_config->get("user-context");
428
429 // Algorithm must be valid.
430 try {
431 TSIGKeyInfo::stringToAlgorithmName(algorithm);
432 } catch (const std::exception& ex) {
433 isc_throw(D2CfgError, "tsig-key : " << ex.what()
434 << " (" << getPosition("algorithm", key_config) << ")");
435 }
436
437 // Non-zero digest-bits must be an integral number of octets, greater
438 // than 80 and at least half of the algorithm key length. It defaults
439 // to zero and JSON parsing ensures it's a multiple of 8.
440 if ((digestbits > 0) &&
441 ((digestbits < 80) ||
442 (boost::iequals(algorithm, TSIGKeyInfo::HMAC_SHA224_STR)
443 && (digestbits < 112)) ||
444 (boost::iequals(algorithm, TSIGKeyInfo::HMAC_SHA256_STR)
445 && (digestbits < 128)) ||
446 (boost::iequals(algorithm, TSIGKeyInfo::HMAC_SHA384_STR)
447 && (digestbits < 192)) ||
448 (boost::iequals(algorithm, TSIGKeyInfo::HMAC_SHA512_STR)
449 && (digestbits < 256)))) {
450 isc_throw(D2CfgError, "tsig-key: digest-bits too small : ("
451 << getPosition("digest-bits", key_config)
452 << ")");
453 }
454
455 // Everything should be valid, so create the key instance.
456 // It is possible for the D2TsigKey constructor to fail such as
457 // with an invalid secret content.
458 TSIGKeyInfoPtr key_info;
459 try {
460 key_info.reset(new TSIGKeyInfo(name, algorithm, secret,
461 secret_file, digestbits));
462 } catch (const std::exception& ex) {
463 isc_throw(D2CfgError, ex.what() << " ("
464 << key_config->getPosition() << ")");
465 }
466
467 // Add user-context
468 if (user_context) {
469 key_info->setContext(user_context);
470 }
471
472 return (key_info);
473}
474
475// *********************** TSIGKeyInfoListParser *************************
476
477 TSIGKeyInfoMapPtr
478TSIGKeyInfoListParser::parse(ConstElementPtr key_list) {
479 TSIGKeyInfoMapPtr keys(new TSIGKeyInfoMap());
480 TSIGKeyInfoParser key_parser;
481 for (auto const& key_config : key_list->listValue()) {
482 TSIGKeyInfoPtr key = key_parser.parse(key_config);
483
484 // Duplicates are not allowed and should be flagged as an error.
485 if (keys->find(key->getName()) != keys->end()) {
486 isc_throw(D2CfgError, "Duplicate TSIG key name specified : "
487 << key->getName()
488 << " (" << getPosition("name", key_config) << ")");
489 }
490
491 (*keys)[key->getName()] = key;
492 }
493
494 return (keys);
495}
496
497// *********************** DnsServerInfoParser *************************
498
499 DnsServerInfoPtr
500DnsServerInfoParser::parse(ConstElementPtr server_config,
501 ConstElementPtr domain_config,
502 const TSIGKeyInfoMapPtr keys) {
503 std::string hostname = getString(server_config, "hostname");
504 std::string ip_address = getString(server_config, "ip-address");
505 uint32_t port = getInteger(server_config, "port");
506 std::string key_name = getString(server_config, "key-name");
507 ConstElementPtr user_context = server_config->get("user-context");
508
509 // Key name is optional. If it is not blank, then find the key in the
510 // list of defined keys.
511 TSIGKeyInfoPtr tsig_key_info;
512 bool inherited_key = true;
513 if (key_name.empty()) {
514 std::string domain_key_name = getString(domain_config, "key-name");
515 if (!domain_key_name.empty()) {
516 key_name = domain_key_name;
517 }
518 } else {
519 inherited_key = false;
520 }
521 if (!key_name.empty()) {
522 if (keys) {
523 TSIGKeyInfoMap::iterator kit = keys->find(key_name);
524 if (kit != keys->end()) {
525 tsig_key_info = kit->second;
526 }
527 }
528
529 if (!tsig_key_info) {
530 if (inherited_key) {
531 isc_throw(D2CfgError, "DdnsDomain : specifies an "
532 << "undefined key: " << key_name << " ("
533 << getPosition("key-name", domain_config) << ")");
534 } else {
535 isc_throw(D2CfgError, "Dns Server : specifies an "
536 << "undefined key: " << key_name << " ("
537 << getPosition("key-name", server_config) << ")");
538 }
539 }
540 }
541
542 // The configuration must specify one or the other.
543 if (hostname.empty() == ip_address.empty()) {
544 isc_throw(D2CfgError, "Dns Server must specify one or the other"
545 " of hostname or IP address"
546 << " (" << server_config->getPosition() << ")");
547 }
548
549 DnsServerInfoPtr server_info;
550 if (!hostname.empty()) {
564 isc_throw(D2CfgError, "Dns Server : hostname is not yet supported"
565 << " (" << getPosition("hostname", server_config) << ")");
566 } else {
567 try {
568 // Create an IOAddress from the IP address string given and then
569 // create the DnsServerInfo.
570 isc::asiolink::IOAddress io_addr(ip_address);
571 server_info.reset(new DnsServerInfo(hostname, io_addr, port,
572 true, tsig_key_info,
573 inherited_key));
574 } catch (const isc::asiolink::IOError& ex) {
575 isc_throw(D2CfgError, "Dns Server : invalid IP address : "
576 << ip_address
577 << " (" << getPosition("ip-address", server_config) << ")");
578 }
579 }
580
581 // Add user-context
582 if (user_context) {
583 server_info->setContext(user_context);
584 }
585
586 return (server_info);
587}
588
589// *********************** DnsServerInfoListParser *************************
590
591 DnsServerInfoStoragePtr
592DnsServerInfoListParser::parse(ConstElementPtr server_list,
593 ConstElementPtr domain_config,
594 const TSIGKeyInfoMapPtr keys) {
595 DnsServerInfoStoragePtr servers(new DnsServerInfoStorage());
596 DnsServerInfoParser parser;
597 for (auto const& server_config : server_list->listValue()) {
598 DnsServerInfoPtr server =
599 parser.parse(server_config, domain_config, keys);
600 servers->push_back(server);
601 }
602
603 return (servers);
604}
605
606// *********************** DdnsDomainParser *************************
607
608 DdnsDomainPtr DdnsDomainParser::parse(ConstElementPtr domain_config,
609 const TSIGKeyInfoMapPtr keys) {
610 std::string name = getString(domain_config, "name");
611 std::string key_name = getString(domain_config, "key-name");
612 ConstElementPtr user_context = domain_config->get("user-context");
613
614 // Parse the list of DNS servers
615 ConstElementPtr servers_config;
616 try {
617 servers_config = domain_config->get("dns-servers");
618 } catch (const std::exception& ex) {
619 isc_throw(D2CfgError, "DdnsDomain : missing dns-server list"
620 << " (" << servers_config->getPosition() << ")");
621 }
622
623 DnsServerInfoListParser server_parser;
624 DnsServerInfoStoragePtr servers =
625 server_parser.parse(servers_config, domain_config, keys);
626 if (servers->size() == 0) {
627 isc_throw(D2CfgError, "DNS server list cannot be empty"
628 << servers_config->getPosition());
629 }
630
631 // Instantiate the new domain and add it to domain storage.
632 DdnsDomainPtr domain(new DdnsDomain(name, servers, key_name));
633
634 // Add user-context
635 if (user_context) {
636 domain->setContext(user_context);
637 }
638
639 return (domain);
640}
641
642// *********************** DdnsDomainListParser *************************
643
644 DdnsDomainMapPtr DdnsDomainListParser::parse(ConstElementPtr domain_list,
645 const TSIGKeyInfoMapPtr keys) {
646 DdnsDomainMapPtr domains(new DdnsDomainMap());
647 DdnsDomainParser parser;
648 for (auto const& domain_config : domain_list->listValue()) {
649 DdnsDomainPtr domain = parser.parse(domain_config, keys);
650
651 // Duplicates are not allowed
652 if (domains->find(domain->getName()) != domains->end()) {
653 isc_throw(D2CfgError, "Duplicate domain specified:"
654 << domain->getName()
655 << " (" << getPosition("name", domain_config) << ")");
656 }
657
658 (*domains)[domain->getName()] = domain;
659 }
660
661 return (domains);
662}
663
664// *********************** DdnsDomainListMgrParser *************************
665
666 DdnsDomainListMgrPtr
667DdnsDomainListMgrParser::parse(ConstElementPtr mgr_config,
668 const std::string& mgr_name,
669 const TSIGKeyInfoMapPtr keys) {
670 DdnsDomainListMgrPtr mgr(new DdnsDomainListMgr(mgr_name));
671
672 // Parse the list of domains
673 ConstElementPtr domains_config = mgr_config->get("ddns-domains");
674 if (domains_config) {
675 DdnsDomainListParser domain_parser;
676 DdnsDomainMapPtr domains = domain_parser.parse(domains_config, keys);
677
678 // Add the new domain to the domain storage.
679 mgr->setDomains(domains);
680 }
681
682 return(mgr);
683}
684
685} // end of isc::dhcp namespace
686} // end of isc namespace
Element::create
static ElementPtr create(const Position &pos=ZERO_POSITION())
Definition data.cc:249
Element::createMap
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:304
Element::createList
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition data.cc:299
isc::BadValue
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Definition exceptions/exceptions.h:132
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:45
isc::asiolink::IOAddress::toText
std::string toText() const
Convert the address to a string.
Definition io_address.cc:61
isc::asiolink::IOError
An exception that is thrown if an error occurs within the IO module.
Definition io_error.h:19
isc::d2::D2CfgError
Exception thrown when the error during configuration handling occurs.
Definition d2_config.h:136
isc::d2::D2Params
Acts as a storage vault for D2 global scalar parameters.
Definition d2_config.h:143
isc::d2::D2Params::D2Params
D2Params()
Default constructor The default constructor creates an instance that has updates disabled.
Definition d2_config.cc:43
isc::d2::D2Params::getIpAddress
const isc::asiolink::IOAddress & getIpAddress() const
Return the IP address D2 listens on.
Definition d2_config.h:174
isc::d2::D2Params::operator!=
bool operator!=(const D2Params &other) const
Compares two D2Params's for inequality.
Definition d2_config.cc:95
isc::d2::D2Params::getPort
size_t getPort() const
Return the TCP/UPD port D2 listens on.
Definition d2_config.h:179
isc::d2::D2Params::operator==
bool operator==(const D2Params &other) const
Compares two D2Params's for equality.
Definition d2_config.cc:86
isc::d2::D2Params::D2Params
D2Params(const isc::asiolink::IOAddress &ip_address, const size_t port, const size_t dns_server_timeout, const dhcp_ddns::NameChangeProtocol &ncr_protocol, const dhcp_ddns::NameChangeFormat &ncr_format)
Constructor.
Definition d2_config.cc:30
isc::d2::D2Params::~D2Params
virtual ~D2Params()
Destructor.
Definition d2_config.cc:51
isc::d2::D2Params::getConfigSummary
std::string getConfigSummary() const
Return summary of the configuration used by D2.
Definition d2_config.cc:78
isc::d2::D2Params::toText
std::string toText() const
Generates a string representation of the class contents.
Definition d2_config.cc:100
isc::d2::D2Params::validateContents
virtual void validateContents()
Validates member values.
Definition d2_config.cc:54
isc::d2::DdnsDomainListMgrParser::parse
DdnsDomainListMgrPtr parse(data::ConstElementPtr mgr_config, const std::string &mgr_name, const TSIGKeyInfoMapPtr keys)
Performs the actual parsing of the given manager element.
Definition d2_config.cc:667
isc::d2::DdnsDomainListMgr
Provides storage for and management of a list of DNS domains.
Definition d2_config.h:646
isc::d2::DdnsDomainListMgr::DdnsDomainListMgr
DdnsDomainListMgr(const std::string &name)
Constructor.
Definition d2_config.cc:298
isc::d2::DdnsDomainListMgr::matchDomain
virtual bool matchDomain(const std::string &fqdn, DdnsDomainPtr &domain)
Matches a given name to a domain based on a longest match scheme.
Definition d2_config.cc:325
isc::d2::DdnsDomainListMgr::setDomains
void setDomains(DdnsDomainMapPtr domains)
Sets the manger's domain list to the given list of domains.
Definition d2_config.cc:307
isc::d2::DdnsDomainListMgr::wildcard_domain_name_
static const char * wildcard_domain_name_
defines the domain name for denoting the wildcard domain.
Definition d2_config.h:649
isc::d2::DdnsDomainListMgr::~DdnsDomainListMgr
virtual ~DdnsDomainListMgr()
Destructor.
Definition d2_config.cc:303
isc::d2::DdnsDomainListMgr::size
uint32_t size() const
Returns the number of domains in the domain list.
Definition d2_config.h:689
isc::d2::DdnsDomainListMgr::toElement
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition d2_config.cc:389
isc::d2::DdnsDomainListParser
Parser for a list of DdnsDomains.
Definition d2_config.h:894
isc::d2::DdnsDomainListParser::parse
DdnsDomainMapPtr parse(data::ConstElementPtr domain_list_config, const TSIGKeyInfoMapPtr keys)
Performs the actual parsing of the given list "ddns-domain" elements.
Definition d2_config.cc:644
isc::d2::DdnsDomainParser
Parser for DdnsDomain.
Definition d2_config.h:875
isc::d2::DdnsDomainParser::parse
DdnsDomainPtr parse(data::ConstElementPtr domain_config, const TSIGKeyInfoMapPtr keys)
Performs the actual parsing of the given "ddns-domain" element.
Definition d2_config.cc:608
isc::d2::DdnsDomain
Represents a DNS domain that is may be updated dynamically.
Definition d2_config.h:570
isc::d2::DdnsDomain::DdnsDomain
DdnsDomain(const std::string &name, DnsServerInfoStoragePtr servers, const std::string &key_name="")
Constructor.
Definition d2_config.cc:260
isc::d2::DdnsDomain::~DdnsDomain
virtual ~DdnsDomain()
Destructor.
Definition d2_config.cc:266
isc::d2::DdnsDomain::toElement
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition d2_config.cc:270
isc::d2::DnsServerInfoListParser
Parser for a list of DnsServerInfos.
Definition d2_config.h:851
isc::d2::DnsServerInfoListParser::parse
DnsServerInfoStoragePtr parse(data::ConstElementPtr server_list_config, data::ConstElementPtr domain_config, const TSIGKeyInfoMapPtr keys)
Performs the actual parsing of the given list "dns-server" elements.
Definition d2_config.cc:592
isc::d2::DnsServerInfoParser
Parser for DnsServerInfo.
Definition d2_config.h:823
isc::d2::DnsServerInfoParser::parse
DnsServerInfoPtr parse(data::ConstElementPtr server_config, data::ConstElementPtr domain_config, const TSIGKeyInfoMapPtr keys)
Performs the actual parsing of the given "dns-server" element.
Definition d2_config.cc:500
isc::d2::DnsServerInfo
Represents a specific DNS Server.
Definition d2_config.h:433
isc::d2::DnsServerInfo::toText
std::string toText() const
Returns a text representation for the server.
Definition d2_config.cc:227
isc::d2::DnsServerInfo::getKeyName
const std::string getKeyName() const
Convenience method which returns the server's TSIG key name.
Definition d2_config.cc:218
isc::d2::DnsServerInfo::DnsServerInfo
DnsServerInfo(const std::string &hostname, isc::asiolink::IOAddress ip_address, uint32_t port=STANDARD_DNS_PORT, bool enabled=true, const TSIGKeyInfoPtr &tsig_key_info=TSIGKeyInfoPtr(), bool inherited_key=true)
Constructor.
Definition d2_config.cc:203
isc::d2::DnsServerInfo::toElement
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition d2_config.cc:234
isc::d2::DnsServerInfo::getPort
uint32_t getPort() const
Getter which returns the server's port number.
Definition d2_config.h:474
isc::d2::DnsServerInfo::getIpAddress
const isc::asiolink::IOAddress & getIpAddress() const
Getter which returns the server's ip_address.
Definition d2_config.h:481
isc::d2::DnsServerInfo::~DnsServerInfo
virtual ~DnsServerInfo()
Destructor.
Definition d2_config.cc:214
isc::d2::TSIGKeyInfoListParser::parse
TSIGKeyInfoMapPtr parse(data::ConstElementPtr key_list_config)
Performs the parsing of the given list "tsig-key" elements.
Definition d2_config.cc:478
isc::d2::TSIGKeyInfoParser
Parser for TSIGKeyInfo.
Definition d2_config.h:784
isc::d2::TSIGKeyInfoParser::parse
TSIGKeyInfoPtr parse(data::ConstElementPtr key_config)
Performs the actual parsing of the given "tsig-key" element.
Definition d2_config.cc:405
isc::d2::TSIGKeyInfo
Represents a TSIG Key.
Definition d2_config.h:266
isc::d2::TSIGKeyInfo::HMAC_SHA224_STR
static const char * HMAC_SHA224_STR
Definition d2_config.h:273
isc::d2::TSIGKeyInfo::TSIGKeyInfo
TSIGKeyInfo(const std::string &name, const std::string &algorithm, const std::string &secret, std::string secret_file="", uint32_t digestbits=0)
Constructor.
Definition d2_config.cc:130
isc::d2::TSIGKeyInfo::~TSIGKeyInfo
virtual ~TSIGKeyInfo()
Destructor.
Definition d2_config.cc:138
isc::d2::TSIGKeyInfo::HMAC_MD5_STR
static const char * HMAC_MD5_STR
Defines string values for the supported TSIG algorithms.
Definition d2_config.h:270
isc::d2::TSIGKeyInfo::toElement
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition d2_config.cc:181
isc::d2::TSIGKeyInfo::HMAC_SHA1_STR
static const char * HMAC_SHA1_STR
Definition d2_config.h:271
isc::d2::TSIGKeyInfo::HMAC_SHA256_STR
static const char * HMAC_SHA256_STR
Definition d2_config.h:272
isc::d2::TSIGKeyInfo::stringToAlgorithmName
static const dns::Name & stringToAlgorithmName(const std::string &algorithm_id)
Converts algorithm id to dns::TSIGKey algorithm dns::Name.
Definition d2_config.cc:142
isc::d2::TSIGKeyInfo::HMAC_SHA512_STR
static const char * HMAC_SHA512_STR
Definition d2_config.h:275
isc::d2::TSIGKeyInfo::HMAC_SHA384_STR
static const char * HMAC_SHA384_STR
Definition d2_config.h:274
isc::data::SimpleParser::getPosition
static const data::Element::Position & getPosition(const std::string &name, const data::ConstElementPtr parent)
Utility method that returns position of an element.
Definition lib/cc/simple_parser.cc:158
isc::data::SimpleParser::getString
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
Definition lib/cc/simple_parser.cc:60
isc::data::SimpleParser::getInteger
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
Definition lib/cc/simple_parser.cc:77
isc::dns::Name
The Name class encapsulates DNS names.
Definition name.h:219
isc::dns::Name::toText
std::string toText(bool omit_final_dot=false) const
Convert the Name to a string.
Definition name.cc:503
isc::dns::TSIGKey::HMACMD5_NAME
static const Name & HMACMD5_NAME()
Well known algorithm names as defined in RFC2845 and RFC4635.
Definition tsigkey.cc:304
isc::dns::TSIGKey::HMACSHA224_NAME
static const Name & HMACSHA224_NAME()
Definition tsigkey.cc:322
isc::dns::TSIGKey::HMACSHA256_NAME
static const Name & HMACSHA256_NAME()
Definition tsigkey.cc:328
isc::dns::TSIGKey::HMACSHA1_NAME
static const Name & HMACSHA1_NAME()
Definition tsigkey.cc:316
isc::dns::TSIGKey::HMACSHA512_NAME
static const Name & HMACSHA512_NAME()
Definition tsigkey.cc:340
isc::dns::TSIGKey::HMACSHA384_NAME
static const Name & HMACSHA384_NAME()
Definition tsigkey.cc:334
d2_cfg_mgr.h
d2_log.h
dhcp_parsers.h
exceptions.h
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
filesystem.h
io_error.h
LOG_WARN
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
Definition macros.h:26
asiolink
A wrapper interface for the ASIO library.
isc::asiolink::operator<<
std::ostream & operator<<(std::ostream &os, const IOAddress &address)
Insert the IOAddress as a string into stream.
Definition io_address.cc:131
isc::config
Definition command_interpreter.cc:23
isc::d2
Definition check_exists_add.cc:19
isc::d2::DdnsDomainListMgrPtr
boost::shared_ptr< DdnsDomainListMgr > DdnsDomainListMgrPtr
Defines a pointer for DdnsDomain instances.
Definition d2_cfg_mgr.h:175
isc::d2::DdnsDomainPtr
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
Definition d2_config.h:624
isc::d2::DdnsDomainMapPtr
boost::shared_ptr< DdnsDomainMap > DdnsDomainMapPtr
Defines a pointer to DdnsDomain storage containers.
Definition d2_config.h:633
isc::d2::DnsServerInfoPtr
boost::shared_ptr< DnsServerInfo > DnsServerInfoPtr
Defines a pointer for DnsServerInfo instances.
Definition d2_config.h:554
isc::d2::DdnsDomainMap
std::map< std::string, DdnsDomainPtr > DdnsDomainMap
Defines a map of DdnsDomains, keyed by the domain name.
Definition d2_config.h:627
isc::d2::dhcp_to_d2_logger
isc::log::Logger dhcp_to_d2_logger("dhcp-to-d2")
Definition d2_log.h:19
isc::d2::TSIGKeyInfoPtr
boost::shared_ptr< TSIGKeyInfo > TSIGKeyInfoPtr
Defines a pointer for TSIGKeyInfo instances.
Definition d2_config.h:416
isc::d2::DnsServerInfoStorage
std::vector< DnsServerInfoPtr > DnsServerInfoStorage
Defines a storage container for DnsServerInfo pointers.
Definition d2_config.h:557
isc::d2::TSIGKeyInfoMap
std::map< std::string, TSIGKeyInfoPtr > TSIGKeyInfoMap
Defines a map of TSIGKeyInfos, keyed by the name.
Definition d2_config.h:419
isc::d2::DnsServerInfoStoragePtr
boost::shared_ptr< DnsServerInfoStorage > DnsServerInfoStoragePtr
Defines a pointer to DnsServerInfo storage containers.
Definition d2_config.h:560
isc::d2::DHCP_DDNS_NO_MATCH
const isc::log::MessageID DHCP_DDNS_NO_MATCH
Definition d2_messages.h:51
isc::d2::TSIGKeyInfoMapPtr
boost::shared_ptr< TSIGKeyInfoMap > TSIGKeyInfoMapPtr
Defines a pointer to map of TSIGkeyInfos.
Definition d2_config.h:425
isc::data
Definition base_stamped_element.cc:12
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
isc::dhcp_ddns
Definition dhcp_ddns_log.cc:14
isc::dhcp_ddns::NameChangeFormat
NameChangeFormat
Defines the list of data wire formats supported.
Definition ncr_msg.h:59
isc::dhcp_ddns::FMT_JSON
@ FMT_JSON
Definition ncr_msg.h:60
isc::dhcp_ddns::NameChangeProtocol
NameChangeProtocol
Defines the list of socket protocols supported.
Definition ncr_io.h:69
isc::dhcp_ddns::NCR_UDP
@ NCR_UDP
Definition ncr_io.h:70
isc::dhcp_ddns::ncrProtocolToString
std::string ncrProtocolToString(NameChangeProtocol protocol)
Function which converts NameChangeProtocol enums to text labels.
Definition ncr_io.cc:36
isc::dhcp_ddns::ncrFormatToString
std::string ncrFormatToString(NameChangeFormat format)
Function which converts NameChangeFormat enums to text labels.
Definition ncr_msg.cc:35
isc::dns::name
Definition name.cc:69
isc::process
Definition cb_ctl_base.h:22
isc::util::file::getContent
string getContent(string const &file_name)
Get the content of a regular file.
Definition filesystem.cc:32
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
isc::data::UserContext::contextToElement
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
Definition user_context.cc:15