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