Kea 1.5.0
d2_config.h
Go to the documentation of this file.
1// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef D2_CONFIG_H
8#define D2_CONFIG_H
9
10#include <asiolink/io_service.h>
11#include <cc/data.h>
12#include <cc/simple_parser.h>
13#include <cc/cfg_to_element.h>
14#include <cc/user_context.h>
16#include <dns/tsig.h>
18#include <process/d_cfg_mgr.h>
19
20#include <boost/foreach.hpp>
21
22#include <stdint.h>
23#include <string>
24
25namespace isc {
26namespace d2 {
27
127
131public:
132 D2CfgError(const char* file, size_t line, const char* what) :
133 isc::Exception(file, line, what) { };
134};
135
137class D2Params {
138public:
154 D2Params(const isc::asiolink::IOAddress& ip_address,
155 const size_t port,
156 const size_t dns_server_timeout,
157 const dhcp_ddns::NameChangeProtocol& ncr_protocol,
158 const dhcp_ddns::NameChangeFormat& ncr_format);
159
162 D2Params();
163
165 virtual ~D2Params();
166
169 return(ip_address_);
170 }
171
173 size_t getPort() const {
174 return(port_);
175 }
176
178 size_t getDnsServerTimeout() const {
179 return(dns_server_timeout_);
180 }
181
184 return(ncr_protocol_);
185 }
186
189 return(ncr_format_);
190 }
191
199 std::string getConfigSummary() const;
200
202 bool operator == (const D2Params& other) const;
203
205 bool operator != (const D2Params& other) const;
206
208 std::string toText() const;
209
210protected:
222 virtual void validateContents();
223
224private:
226 isc::asiolink::IOAddress ip_address_;
227
229 size_t port_;
230
232 size_t dns_server_timeout_;
233
236 dhcp_ddns::NameChangeProtocol ncr_protocol_;
237
240 dhcp_ddns::NameChangeFormat ncr_format_;
241};
242
247std::ostream&
248operator<<(std::ostream& os, const D2Params& config);
249
251typedef boost::shared_ptr<D2Params> D2ParamsPtr;
252
261public:
263
264 static const char* HMAC_MD5_STR;
265 static const char* HMAC_SHA1_STR;
266 static const char* HMAC_SHA256_STR;
267 static const char* HMAC_SHA224_STR;
268 static const char* HMAC_SHA384_STR;
269 static const char* HMAC_SHA512_STR;
270 //}@
271
303 TSIGKeyInfo(const std::string& name, const std::string& algorithm,
304 const std::string& secret, uint32_t digestbits = 0);
305
307 virtual ~TSIGKeyInfo();
308
312 const std::string getName() const {
313 return (name_);
314 }
315
319 const std::string getAlgorithm() const {
320 return (algorithm_);
321 }
322
326 uint32_t getDigestbits() const {
327 return (digestbits_);
328 }
329
333 const std::string getSecret() const {
334 return (secret_);
335 }
336
342 return (tsig_key_);
343 }
344
358 static const dns::Name& stringToAlgorithmName(const std::string&
359 algorithm_id);
360
364 virtual isc::data::ElementPtr toElement() const;
365
366private:
375 void remakeKey();
376
381 std::string name_;
382
384 std::string algorithm_;
385
387 std::string secret_;
388
391 uint32_t digestbits_;
392
394 dns::TSIGKeyPtr tsig_key_;
395};
396
398typedef boost::shared_ptr<TSIGKeyInfo> TSIGKeyInfoPtr;
399
401typedef std::map<std::string, TSIGKeyInfoPtr> TSIGKeyInfoMap;
402
404typedef std::pair<std::string, TSIGKeyInfoPtr> TSIGKeyInfoMapPair;
405
407typedef boost::shared_ptr<TSIGKeyInfoMap> TSIGKeyInfoMapPtr;
408
409
416public:
418 static const uint32_t STANDARD_DNS_PORT = 53;
419
432 DnsServerInfo(const std::string& hostname,
433 isc::asiolink::IOAddress ip_address,
434 uint32_t port = STANDARD_DNS_PORT,
435 bool enabled=true);
436
438 virtual ~DnsServerInfo();
439
443 const std::string getHostname() const {
444 return (hostname_);
445 }
446
450 uint32_t getPort() const {
451 return (port_);
452 }
453
458 return (ip_address_);
459 }
460
465 bool isEnabled() const {
466 return (enabled_);
467 }
468
470 void enable() {
471 enabled_ = true;
472 }
473
475 void disable() {
476 enabled_ = false;
477 }
478
480 std::string toText() const;
481
485 virtual isc::data::ElementPtr toElement() const;
486
487
488private:
491 std::string hostname_;
492
495 isc::asiolink::IOAddress ip_address_;
496
498 uint32_t port_;
499
502 bool enabled_;
503};
504
505std::ostream&
506operator<<(std::ostream& os, const DnsServerInfo& server);
507
509typedef boost::shared_ptr<DnsServerInfo> DnsServerInfoPtr;
510
512typedef std::vector<DnsServerInfoPtr> DnsServerInfoStorage;
513
515typedef boost::shared_ptr<DnsServerInfoStorage> DnsServerInfoStoragePtr;
516
517
526public:
533 DdnsDomain(const std::string& name,
535 const TSIGKeyInfoPtr& tsig_key_info = TSIGKeyInfoPtr());
536
538 virtual ~DdnsDomain();
539
543 const std::string getName() const {
544 return (name_);
545 }
546
551 const std::string getKeyName() const;
552
557 return (servers_);
558 }
559
565 return (tsig_key_info_);
566 }
567
571 virtual isc::data::ElementPtr toElement() const;
572
573private:
575 std::string name_;
576
579
582 TSIGKeyInfoPtr tsig_key_info_;
583};
584
586typedef boost::shared_ptr<DdnsDomain> DdnsDomainPtr;
587
589typedef std::map<std::string, DdnsDomainPtr> DdnsDomainMap;
590
592typedef std::pair<std::string, DdnsDomainPtr> DdnsDomainMapPair;
593
595typedef boost::shared_ptr<DdnsDomainMap> DdnsDomainMapPtr;
596
609public:
611 static const char* wildcard_domain_name_;
612
616 DdnsDomainListMgr(const std::string& name);
617
619 virtual ~DdnsDomainListMgr ();
620
639 virtual bool matchDomain(const std::string& fqdn, DdnsDomainPtr& domain);
640
644 const std::string getName() const {
645 return (name_);
646 }
647
651 uint32_t size() const {
652 return (domains_->size());
653 }
654
660 return (wildcard_domain_);
661 }
662
667 return (domains_);
668 }
669
673 void setDomains(DdnsDomainMapPtr domains);
674
678 virtual isc::data::ElementPtr toElement() const;
679
680private:
682 std::string name_;
683
685 DdnsDomainMapPtr domains_;
686
688 DdnsDomainPtr wildcard_domain_;
689};
690
692typedef boost::shared_ptr<DdnsDomainListMgr> DdnsDomainListMgrPtr;
693
705public:
706
709 };
710
712 virtual ~DScalarContext() {
713 }
714
719 return (process::ConfigPtr(new DScalarContext(*this)));
720 }
721
726 isc_throw(isc::NotImplemented, "DScalarContext::ElementPtr");
727 }
728
729protected:
731 DScalarContext(const DScalarContext& rhs) : ConfigBase(rhs) {
732 }
733
734private:
736 DScalarContext& operator=(const DScalarContext& rhs);
737};
738
740typedef boost::shared_ptr<DScalarContext> DScalarContextPtr;
741
747public:
757
758};
759
765public:
779};
780
786public:
802};
803
810public:
823};
824
830public:
841 const TSIGKeyInfoMapPtr keys);
842};
843
849public:
863 const TSIGKeyInfoMapPtr keys);
864};
865
872public:
885 const std::string& mgr_name,
886 const TSIGKeyInfoMapPtr keys);
887};
888
889
890}; // end of isc::d2 namespace
891}; // end of isc namespace
892
893#endif // D2_CONFIG_H
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown when a function is not implemented.
Exception thrown when the error during configuration handling occurs.
Definition: d2_config.h:130
D2CfgError(const char *file, size_t line, const char *what)
Definition: d2_config.h:132
Acts as a storage vault for D2 global scalar parameters.
Definition: d2_config.h:137
size_t getDnsServerTimeout() const
Return the DNS server timeout value.
Definition: d2_config.h:178
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:168
bool operator!=(const D2Params &other) const
Compares two D2Params's for inequality.
Definition: d2_config.cc:100
const dhcp_ddns::NameChangeFormat & getNcrFormat() const
Return the expected format of inbound requests (NCRs).
Definition: d2_config.h:188
size_t getPort() const
Return the TCP/UPD port D2 listens on.
Definition: d2_config.h:173
bool operator==(const D2Params &other) const
Compares two D2Params's for equality.
Definition: d2_config.cc:91
virtual ~D2Params()
Destructor.
Definition: d2_config.cc:51
const dhcp_ddns::NameChangeProtocol & getNcrProtocol() const
Return the socket protocol in use.
Definition: d2_config.h:183
std::string getConfigSummary() const
Return summary of the configuration used by D2.
Definition: d2_config.cc:83
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
Storage container for scalar configuration parameters.
Definition: d2_config.h:704
DScalarContext()
Constructor.
Definition: d2_config.h:708
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: d2_config.h:725
virtual process::ConfigPtr clone()
Creates a clone of a DStubContext.
Definition: d2_config.h:718
virtual ~DScalarContext()
Destructor.
Definition: d2_config.h:712
DScalarContext(const DScalarContext &rhs)
Copy constructor.
Definition: d2_config.h:731
Parser for DdnsDomainListMgr.
Definition: d2_config.h:871
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:624
Provides storage for and management of a list of DNS domains.
Definition: d2_config.h:608
const std::string getName() const
Fetches the manager's name.
Definition: d2_config.h:644
const DdnsDomainMapPtr & getDomains()
Fetches the domain list.
Definition: d2_config.h:666
const DdnsDomainPtr & getWildcardDomain()
Fetches the wild card domain.
Definition: d2_config.h:659
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
void setDomains(DdnsDomainMapPtr domains)
Sets the manger's domain list to the given list of domains.
Definition: d2_config.cc:302
static const char * wildcard_domain_name_
defines the domain name for denoting the wildcard domain.
Definition: d2_config.h:611
virtual ~DdnsDomainListMgr()
Destructor.
Definition: d2_config.cc:298
uint32_t size() const
Returns the number of domains in the domain list.
Definition: d2_config.h:651
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: d2_config.cc:385
Parser for a list of DdnsDomains.
Definition: d2_config.h:848
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:600
Parser for DdnsDomain.
Definition: d2_config.h:829
DdnsDomainPtr parse(data::ConstElementPtr domain_config, const TSIGKeyInfoMapPtr keys)
Performs the actual parsing of the given "ddns-domain" element.
Definition: d2_config.cc:547
Represents a DNS domain that is may be updated dynamically.
Definition: d2_config.h:525
const std::string getKeyName() const
Convenience method which returns the domain's TSIG key name.
Definition: d2_config.cc:255
const std::string getName() const
Getter which returns the domain's name.
Definition: d2_config.h:543
const TSIGKeyInfoPtr & getTSIGKeyInfo()
Getter which returns the domain's TSIGKey info.
Definition: d2_config.h:564
const DnsServerInfoStoragePtr & getServers()
Getter which returns the domain's list of servers.
Definition: d2_config.h:556
virtual ~DdnsDomain()
Destructor.
Definition: d2_config.cc:251
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: d2_config.cc:264
Parser for a list of DnsServerInfos.
Definition: d2_config.h:809
DnsServerInfoStoragePtr parse(data::ConstElementPtr server_list_config)
Performs the actual parsing of the given list "dns-server" elements.
Definition: d2_config.cc:533
Parser for DnsServerInfo.
Definition: d2_config.h:785
DnsServerInfoPtr parse(data::ConstElementPtr server_config)
Performs the actual parsing of the given "dns-server" element.
Definition: d2_config.cc:479
Represents a specific DNS Server.
Definition: d2_config.h:415
bool isEnabled() const
Convenience method which returns whether or not the server is enabled.
Definition: d2_config.h:465
std::string toText() const
Returns a text representation for the server.
Definition: d2_config.cc:214
const std::string getHostname() const
Getter which returns the server's hostname.
Definition: d2_config.h:443
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: d2_config.cc:221
uint32_t getPort() const
Getter which returns the server's port number.
Definition: d2_config.h:450
void enable()
Sets the server's enabled flag to true.
Definition: d2_config.h:470
static const uint32_t STANDARD_DNS_PORT
defines DNS standard port value
Definition: d2_config.h:418
void disable()
Sets the server's enabled flag to false.
Definition: d2_config.h:475
const isc::asiolink::IOAddress & getIpAddress() const
Getter which returns the server's ip_address.
Definition: d2_config.h:457
virtual ~DnsServerInfo()
Destructor.
Definition: d2_config.cc:210
Parser for a list of TSIGKeyInfos.
Definition: d2_config.h:764
TSIGKeyInfoMapPtr parse(data::ConstElementPtr key_list_config)
Performs the parsing of the given list "tsig-key" elements.
Definition: d2_config.cc:456
Parser for TSIGKeyInfo.
Definition: d2_config.h:746
TSIGKeyInfoPtr parse(data::ConstElementPtr key_config)
Performs the actual parsing of the given "tsig-key" element.
Definition: d2_config.cc:402
Represents a TSIG Key.
Definition: d2_config.h:260
static const char * HMAC_SHA224_STR
Definition: d2_config.h:267
const std::string getAlgorithm() const
Getter which returns the key's algorithm string ID.
Definition: d2_config.h:319
virtual ~TSIGKeyInfo()
Destructor.
Definition: d2_config.cc:142
static const char * HMAC_MD5_STR
Defines string values for the supported TSIG algorithms.
Definition: d2_config.h:264
const std::string getName() const
Getter which returns the key's name.
Definition: d2_config.h:312
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: d2_config.cc:185
static const char * HMAC_SHA1_STR
Definition: d2_config.h:265
static const char * HMAC_SHA256_STR
Definition: d2_config.h:266
uint32_t getDigestbits() const
Getter which returns the key's minimum truncated length.
Definition: d2_config.h:326
static const dns::Name & stringToAlgorithmName(const std::string &algorithm_id)
Converts algorithm id to dns::TSIGKey algorithm dns::Name.
Definition: d2_config.cc:146
static const char * HMAC_SHA512_STR
Definition: d2_config.h:269
const std::string getSecret() const
Getter which returns the key's secret.
Definition: d2_config.h:333
const dns::TSIGKeyPtr & getTSIGKey() const
Getter which returns the TSIG key used to sign and verify messages.
Definition: d2_config.h:341
static const char * HMAC_SHA384_STR
Definition: d2_config.h:268
The Name class encapsulates DNS names.
Definition: name.h:223
Base class for all configurations.
Definition: config_base.h:31
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< DdnsDomainListMgr > DdnsDomainListMgrPtr
Defines a pointer for DdnsDomain instances.
Definition: d2_cfg_mgr.h:120
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
Definition: d2_config.h:586
boost::shared_ptr< DdnsDomainMap > DdnsDomainMapPtr
Defines a pointer to DdnsDomain storage containers.
Definition: d2_config.h:595
std::pair< std::string, TSIGKeyInfoPtr > TSIGKeyInfoMapPair
Defines a iterator pairing of name and TSIGKeyInfo.
Definition: d2_config.h:404
boost::shared_ptr< DnsServerInfo > DnsServerInfoPtr
Defines a pointer for DnsServerInfo instances.
Definition: d2_config.h:509
std::map< std::string, DdnsDomainPtr > DdnsDomainMap
Defines a map of DdnsDomains, keyed by the domain name.
Definition: d2_config.h:589
std::pair< std::string, DdnsDomainPtr > DdnsDomainMapPair
Defines a iterator pairing domain name and DdnsDomain.
Definition: d2_config.h:592
boost::shared_ptr< TSIGKeyInfo > TSIGKeyInfoPtr
Defines a pointer for TSIGKeyInfo instances.
Definition: d2_config.h:398
std::vector< DnsServerInfoPtr > DnsServerInfoStorage
Defines a storage container for DnsServerInfo pointers.
Definition: d2_config.h:512
std::map< std::string, TSIGKeyInfoPtr > TSIGKeyInfoMap
Defines a map of TSIGKeyInfos, keyed by the name.
Definition: d2_config.h:401
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
boost::shared_ptr< DnsServerInfoStorage > DnsServerInfoStoragePtr
Defines a pointer to DnsServerInfo storage containers.
Definition: d2_config.h:515
boost::shared_ptr< D2Params > D2ParamsPtr
Defines a pointer for D2Params instances.
Definition: d2_config.h:251
boost::shared_ptr< DScalarContext > DScalarContextPtr
Defines a pointer for DScalarContext instances.
Definition: d2_config.h:740
boost::shared_ptr< TSIGKeyInfoMap > TSIGKeyInfoMapPtr
Defines a pointer to map of TSIGkeyInfos.
Definition: d2_config.h:407
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
boost::shared_ptr< Element > ElementPtr
Definition: data.h:22
NameChangeFormat
Defines the list of data wire formats supported.
Definition: ncr_msg.h:60
NameChangeProtocol
Defines the list of socket protocols supported.
Definition: ncr_io.h:66
boost::shared_ptr< TSIGKey > TSIGKeyPtr
Definition: tsig.h:437
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the SrvConfig.
Definition: config_base.h:119
Defines the logger used by the top-level component of kea-dhcp-ddns.
Abstract class for configuration Cfg_* classes.
Base class for user context.
Definition: user_context.h:22