Kea 2.7.5
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>
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
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) {
41}
42
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) {
49}
50
52
53void
55 if (port_ == 0) {
56 isc_throw(D2CfgError, "D2Params: port cannot be 0");
57 }
58
59 if (dns_server_timeout_ < 1) {
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
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
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&
115operator<<(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
140
141const dns::Name&
142TSIGKeyInfo::stringToAlgorithmName(const std::string& algorithm_id) {
143 if (boost::iequals(algorithm_id, HMAC_MD5_STR)) {
145 } else if (boost::iequals(algorithm_id, HMAC_SHA1_STR)) {
147 } else if (boost::iequals(algorithm_id, HMAC_SHA224_STR)) {
149 } else if (boost::iequals(algorithm_id, HMAC_SHA256_STR)) {
151 } else if (boost::iequals(algorithm_id, HMAC_SHA384_STR)) {
153 } else if (boost::iequals(algorithm_id, HMAC_SHA512_STR)) {
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
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
216
217const std::string
219 if (tsig_key_info_) {
220 return (tsig_key_info_->getName());
221 }
222
223 return ("");
224}
225
226std::string
228 std::ostringstream stream;
229 stream << (getIpAddress().toText()) << " port:" << getPort();
230 return (stream.str());
231}
232
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&
253operator<<(std::ostream& os, const DnsServerInfo& server) {
254 os << server.toText();
255 return (os);
256}
257
258// *********************** DdnsDomain *************************
259
260DdnsDomain::DdnsDomain(const std::string& name,
262 const std::string& key_name)
263 : name_(name), servers_(servers), key_name_(key_name) {
264}
265
268
272 // Set user-context
273 contextToElement(result);
274 // Set name
275 result->set("name", Element::create(name_));
276 // Set servers
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
297
298DdnsDomainListMgr::DdnsDomainListMgr(const std::string& name) : name_(name),
299 domains_(new DdnsDomainMap()) {
300}
301
302
305
306void
308 if (!domains) {
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
381 return (false);
382 }
383
384 domain = best_match;
385 return (true);
386}
387
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
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 {
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
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
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
593 ConstElementPtr domain_config,
594 const TSIGKeyInfoMapPtr keys) {
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
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;
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
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
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
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Exception thrown when the error during configuration handling occurs.
Definition d2_config.h:136
Acts as a storage vault for D2 global scalar parameters.
Definition d2_config.h:143
D2Params()
Default constructor The default constructor creates an instance that has updates disabled.
Definition d2_config.cc:43
const isc::asiolink::IOAddress & getIpAddress() const
Return the IP address D2 listens on.
Definition d2_config.h:174
bool operator!=(const D2Params &other) const
Compares two D2Params's for inequality.
Definition d2_config.cc:95
size_t getPort() const
Return the TCP/UPD port D2 listens on.
Definition d2_config.h:179
bool operator==(const D2Params &other) const
Compares two D2Params's for equality.
Definition d2_config.cc:86
virtual ~D2Params()
Destructor.
Definition d2_config.cc:51
std::string getConfigSummary() const
Return summary of the configuration used by D2.
Definition d2_config.cc:78
std::string toText() const
Generates a string representation of the class contents.
Definition d2_config.cc:100
virtual void validateContents()
Validates member values.
Definition d2_config.cc:54
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
Provides storage for and management of a list of DNS domains.
Definition d2_config.h:646
DdnsDomainListMgr(const std::string &name)
Constructor.
Definition d2_config.cc:298
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
void setDomains(DdnsDomainMapPtr domains)
Sets the manger's domain list to the given list of domains.
Definition d2_config.cc:307
static const char * wildcard_domain_name_
defines the domain name for denoting the wildcard domain.
Definition d2_config.h:649
virtual ~DdnsDomainListMgr()
Destructor.
Definition d2_config.cc:303
uint32_t size() const
Returns the number of domains in the domain list.
Definition d2_config.h:689
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition d2_config.cc:389
Parser for a list of DdnsDomains.
Definition d2_config.h:894
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
Parser for DdnsDomain.
Definition d2_config.h:875
DdnsDomainPtr parse(data::ConstElementPtr domain_config, const TSIGKeyInfoMapPtr keys)
Performs the actual parsing of the given "ddns-domain" element.
Definition d2_config.cc:608
Represents a DNS domain that is may be updated dynamically.
Definition d2_config.h:570
DdnsDomain(const std::string &name, DnsServerInfoStoragePtr servers, const std::string &key_name="")
Constructor.
Definition d2_config.cc:260
virtual ~DdnsDomain()
Destructor.
Definition d2_config.cc:266
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition d2_config.cc:270
Parser for a list of DnsServerInfos.
Definition d2_config.h:851
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
Parser for DnsServerInfo.
Definition d2_config.h:823
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
Represents a specific DNS Server.
Definition d2_config.h:433
std::string toText() const
Returns a text representation for the server.
Definition d2_config.cc:227
const std::string getKeyName() const
Convenience method which returns the server's TSIG key name.
Definition d2_config.cc:218
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
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition d2_config.cc:234
uint32_t getPort() const
Getter which returns the server's port number.
Definition d2_config.h:474
const isc::asiolink::IOAddress & getIpAddress() const
Getter which returns the server's ip_address.
Definition d2_config.h:481
virtual ~DnsServerInfo()
Destructor.
Definition d2_config.cc:214
TSIGKeyInfoMapPtr parse(data::ConstElementPtr key_list_config)
Performs the parsing of the given list "tsig-key" elements.
Definition d2_config.cc:478
Parser for TSIGKeyInfo.
Definition d2_config.h:784
TSIGKeyInfoPtr parse(data::ConstElementPtr key_config)
Performs the actual parsing of the given "tsig-key" element.
Definition d2_config.cc:405
Represents a TSIG Key.
Definition d2_config.h:266
static const char * HMAC_SHA224_STR
Definition d2_config.h:273
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
virtual ~TSIGKeyInfo()
Destructor.
Definition d2_config.cc:138
static const char * HMAC_MD5_STR
Defines string values for the supported TSIG algorithms.
Definition d2_config.h:270
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition d2_config.cc:181
static const char * HMAC_SHA1_STR
Definition d2_config.h:271
static const char * HMAC_SHA256_STR
Definition d2_config.h:272
static const dns::Name & stringToAlgorithmName(const std::string &algorithm_id)
Converts algorithm id to dns::TSIGKey algorithm dns::Name.
Definition d2_config.cc:142
static const char * HMAC_SHA512_STR
Definition d2_config.h:275
static const char * HMAC_SHA384_STR
Definition d2_config.h:274
static ElementPtr create(const Position &pos=ZERO_POSITION())
Definition data.cc:249
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:304
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition data.cc:299
static const data::Element::Position & getPosition(const std::string &name, const data::ConstElementPtr parent)
Utility method that returns position of an element.
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
The Name class encapsulates DNS names.
Definition name.h:219
std::string toText(bool omit_final_dot=false) const
Convert the Name to a string.
Definition name.cc:503
static const Name & HMACMD5_NAME()
Well known algorithm names as defined in RFC2845 and RFC4635.
Definition tsigkey.cc:304
static const Name & HMACSHA224_NAME()
Definition tsigkey.cc:322
static const Name & HMACSHA256_NAME()
Definition tsigkey.cc:328
static const Name & HMACSHA1_NAME()
Definition tsigkey.cc:316
static const Name & HMACSHA512_NAME()
Definition tsigkey.cc:340
static const Name & HMACSHA384_NAME()
Definition tsigkey.cc:334
const Name & name_
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
Definition macros.h:26
boost::shared_ptr< DdnsDomainListMgr > DdnsDomainListMgrPtr
Defines a pointer for DdnsDomain instances.
Definition d2_cfg_mgr.h:175
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
Definition d2_config.h:624
boost::shared_ptr< DdnsDomainMap > DdnsDomainMapPtr
Defines a pointer to DdnsDomain storage containers.
Definition d2_config.h:633
boost::shared_ptr< DnsServerInfo > DnsServerInfoPtr
Defines a pointer for DnsServerInfo instances.
Definition d2_config.h:554
std::map< std::string, DdnsDomainPtr > DdnsDomainMap
Defines a map of DdnsDomains, keyed by the domain name.
Definition d2_config.h:627
isc::log::Logger dhcp_to_d2_logger("dhcp-to-d2")
Definition d2_log.h:19
boost::shared_ptr< TSIGKeyInfo > TSIGKeyInfoPtr
Defines a pointer for TSIGKeyInfo instances.
Definition d2_config.h:416
std::vector< DnsServerInfoPtr > DnsServerInfoStorage
Defines a storage container for DnsServerInfo pointers.
Definition d2_config.h:557
std::map< std::string, TSIGKeyInfoPtr > TSIGKeyInfoMap
Defines a map of TSIGKeyInfos, keyed by the name.
Definition d2_config.h:419
boost::shared_ptr< DnsServerInfoStorage > DnsServerInfoStoragePtr
Defines a pointer to DnsServerInfo storage containers.
Definition d2_config.h:560
const isc::log::MessageID DHCP_DDNS_NO_MATCH
Definition d2_messages.h:51
boost::shared_ptr< TSIGKeyInfoMap > TSIGKeyInfoMapPtr
Defines a pointer to map of TSIGkeyInfos.
Definition d2_config.h:425
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
NameChangeFormat
Defines the list of data wire formats supported.
Definition ncr_msg.h:59
NameChangeProtocol
Defines the list of socket protocols supported.
Definition ncr_io.h:69
std::string ncrProtocolToString(NameChangeProtocol protocol)
Function which converts NameChangeProtocol enums to text labels.
Definition ncr_io.cc:36
std::string ncrFormatToString(NameChangeFormat format)
Function which converts NameChangeFormat enums to text labels.
Definition ncr_msg.cc:35
string getContent(string const &file_name)
Get the content of a regular file.
Definition filesystem.cc:29
Defines the logger used by the top-level component of kea-lfc.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.