Kea 2.5.7
d2_config.h
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#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>
15#include <d2srv/d2_tsig_key.h>
18#include <process/d_cfg_mgr.h>
19
20#include <stdint.h>
21#include <string>
22
23namespace isc {
24namespace d2 {
25
131
135public:
136 D2CfgError(const char* file, size_t line, const char* what) :
137 isc::Exception(file, line, what) { };
138};
139
141class D2Params {
142public:
158 D2Params(const isc::asiolink::IOAddress& ip_address,
159 const size_t port,
160 const size_t dns_server_timeout,
161 const dhcp_ddns::NameChangeProtocol& ncr_protocol,
162 const dhcp_ddns::NameChangeFormat& ncr_format);
163
166 D2Params();
167
169 virtual ~D2Params();
170
173 return(ip_address_);
174 }
175
177 size_t getPort() const {
178 return(port_);
179 }
180
182 size_t getDnsServerTimeout() const {
183 return(dns_server_timeout_);
184 }
185
188 return(ncr_protocol_);
189 }
190
193 return(ncr_format_);
194 }
195
203 std::string getConfigSummary() const;
204
206 bool operator == (const D2Params& other) const;
207
209 bool operator != (const D2Params& other) const;
210
212 std::string toText() const;
213
214protected:
226 virtual void validateContents();
227
228private:
230 isc::asiolink::IOAddress ip_address_;
231
233 size_t port_;
234
236 size_t dns_server_timeout_;
237
240 dhcp_ddns::NameChangeProtocol ncr_protocol_;
241
244 dhcp_ddns::NameChangeFormat ncr_format_;
245};
246
251std::ostream&
252operator<<(std::ostream& os, const D2Params& config);
253
255typedef boost::shared_ptr<D2Params> D2ParamsPtr;
256
265public:
268 static const char* HMAC_MD5_STR;
269 static const char* HMAC_SHA1_STR;
270 static const char* HMAC_SHA256_STR;
271 static const char* HMAC_SHA224_STR;
272 static const char* HMAC_SHA384_STR;
273 static const char* HMAC_SHA512_STR;
275
307 TSIGKeyInfo(const std::string& name, const std::string& algorithm,
308 const std::string& secret, uint32_t digestbits = 0);
309
311 virtual ~TSIGKeyInfo();
312
316 const std::string getName() const {
317 return (name_);
318 }
319
323 const std::string getAlgorithm() const {
324 return (algorithm_);
325 }
326
330 uint32_t getDigestbits() const {
331 return (digestbits_);
332 }
333
337 const std::string getSecret() const {
338 return (secret_);
339 }
340
345 const D2TsigKeyPtr& getTSIGKey() const {
346 return (tsig_key_);
347 }
348
362 static const dns::Name& stringToAlgorithmName(const std::string&
363 algorithm_id);
364
368 virtual isc::data::ElementPtr toElement() const;
369
370private:
379 void remakeKey();
380
385 std::string name_;
386
388 std::string algorithm_;
389
391 std::string secret_;
392
395 uint32_t digestbits_;
396
398 D2TsigKeyPtr tsig_key_;
399};
400
402typedef boost::shared_ptr<TSIGKeyInfo> TSIGKeyInfoPtr;
403
405typedef std::map<std::string, TSIGKeyInfoPtr> TSIGKeyInfoMap;
406
408typedef std::pair<std::string, TSIGKeyInfoPtr> TSIGKeyInfoMapPair;
409
411typedef boost::shared_ptr<TSIGKeyInfoMap> TSIGKeyInfoMapPtr;
412
413
420public:
422 static const uint32_t STANDARD_DNS_PORT = 53;
423
440 DnsServerInfo(const std::string& hostname,
441 isc::asiolink::IOAddress ip_address,
442 uint32_t port = STANDARD_DNS_PORT,
443 bool enabled = true,
444 const TSIGKeyInfoPtr& tsig_key_info = TSIGKeyInfoPtr(),
445 bool inherited_key = true);
446
448 virtual ~DnsServerInfo();
449
453 const std::string getHostname() const {
454 return (hostname_);
455 }
456
460 uint32_t getPort() const {
461 return (port_);
462 }
463
468 return (ip_address_);
469 }
470
475 bool isEnabled() const {
476 return (enabled_);
477 }
478
480 void enable() {
481 enabled_ = true;
482 }
483
485 void disable() {
486 enabled_ = false;
487 }
488
493 const std::string getKeyName() const;
494
500 return (tsig_key_info_);
501 }
502
504 std::string toText() const;
505
509 virtual isc::data::ElementPtr toElement() const;
510
511private:
514 std::string hostname_;
515
518 isc::asiolink::IOAddress ip_address_;
519
521 uint32_t port_;
522
525 bool enabled_;
526
529 TSIGKeyInfoPtr tsig_key_info_;
530
533 bool inherited_key_;
534};
535
536std::ostream&
537operator<<(std::ostream& os, const DnsServerInfo& server);
538
540typedef boost::shared_ptr<DnsServerInfo> DnsServerInfoPtr;
541
543typedef std::vector<DnsServerInfoPtr> DnsServerInfoStorage;
544
546typedef boost::shared_ptr<DnsServerInfoStorage> DnsServerInfoStoragePtr;
547
548
557public:
563 DdnsDomain(const std::string& name, DnsServerInfoStoragePtr servers,
564 const std::string& key_name = "");
565
567 virtual ~DdnsDomain();
568
572 const std::string getName() const {
573 return (name_);
574 }
575
582 const std::string getKeyName() const {
583 return (key_name_);
584 }
585
590 return (servers_);
591 }
592
596 virtual isc::data::ElementPtr toElement() const;
597
598private:
600 std::string name_;
601
604
606 std::string key_name_;
607};
608
610typedef boost::shared_ptr<DdnsDomain> DdnsDomainPtr;
611
613typedef std::map<std::string, DdnsDomainPtr> DdnsDomainMap;
614
616typedef std::pair<std::string, DdnsDomainPtr> DdnsDomainMapPair;
617
619typedef boost::shared_ptr<DdnsDomainMap> DdnsDomainMapPtr;
620
633public:
635 static const char* wildcard_domain_name_;
636
640 DdnsDomainListMgr(const std::string& name);
641
643 virtual ~DdnsDomainListMgr ();
644
663 virtual bool matchDomain(const std::string& fqdn, DdnsDomainPtr& domain);
664
668 const std::string getName() const {
669 return (name_);
670 }
671
675 uint32_t size() const {
676 return (domains_->size());
677 }
678
684 return (wildcard_domain_);
685 }
686
691 return (domains_);
692 }
693
697 void setDomains(DdnsDomainMapPtr domains);
698
702 virtual isc::data::ElementPtr toElement() const;
703
704private:
706 std::string name_;
707
709 DdnsDomainMapPtr domains_;
710
712 DdnsDomainPtr wildcard_domain_;
713};
714
716typedef boost::shared_ptr<DdnsDomainListMgr> DdnsDomainListMgrPtr;
717
729public:
730
733 };
734
736 virtual ~DScalarContext() {
737 }
738
743 return (process::ConfigPtr(new DScalarContext(*this)));
744 }
745
750 isc_throw(isc::NotImplemented, "DScalarContext::ElementPtr");
751 }
752
753protected:
755 DScalarContext(const DScalarContext& rhs) : ConfigBase(rhs) {
756 }
757
758private:
760 DScalarContext& operator=(const DScalarContext& rhs);
761};
762
764typedef boost::shared_ptr<DScalarContext> DScalarContextPtr;
765
771public:
781
782};
783
789public:
803};
804
810public:
828 data::ConstElementPtr domain_config,
829 const TSIGKeyInfoMapPtr keys);
830};
831
838public:
853 data::ConstElementPtr domain_config,
854 const TSIGKeyInfoMapPtr keys);
855};
856
862public:
873 const TSIGKeyInfoMapPtr keys);
874};
875
881public:
895 const TSIGKeyInfoMapPtr keys);
896};
897
904public:
917 const std::string& mgr_name,
918 const TSIGKeyInfoMapPtr keys);
919};
920
921} // end of isc::d2 namespace
922} // end of isc namespace
923
924#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:134
D2CfgError(const char *file, size_t line, const char *what)
Definition: d2_config.h:136
Acts as a storage vault for D2 global scalar parameters.
Definition: d2_config.h:141
size_t getDnsServerTimeout() const
Return the DNS server timeout value.
Definition: d2_config.h:182
D2Params()
Default constructor The default constructor creates an instance that has updates disabled.
Definition: d2_config.cc:42
const isc::asiolink::IOAddress & getIpAddress() const
Return the IP address D2 listens on.
Definition: d2_config.h:172
bool operator!=(const D2Params &other) const
Compares two D2Params's for inequality.
Definition: d2_config.cc:94
const dhcp_ddns::NameChangeFormat & getNcrFormat() const
Return the expected format of inbound requests (NCRs).
Definition: d2_config.h:192
size_t getPort() const
Return the TCP/UPD port D2 listens on.
Definition: d2_config.h:177
bool operator==(const D2Params &other) const
Compares two D2Params's for equality.
Definition: d2_config.cc:85
virtual ~D2Params()
Destructor.
Definition: d2_config.cc:50
const dhcp_ddns::NameChangeProtocol & getNcrProtocol() const
Return the socket protocol in use.
Definition: d2_config.h:187
std::string getConfigSummary() const
Return summary of the configuration used by D2.
Definition: d2_config.cc:77
std::string toText() const
Generates a string representation of the class contents.
Definition: d2_config.cc:99
virtual void validateContents()
Validates member values.
Definition: d2_config.cc:53
Storage container for scalar configuration parameters.
Definition: d2_config.h:728
DScalarContext()
Constructor.
Definition: d2_config.h:732
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: d2_config.h:749
virtual process::ConfigPtr clone()
Creates a clone of a DStubContext.
Definition: d2_config.h:742
virtual ~DScalarContext()
Destructor.
Definition: d2_config.h:736
DScalarContext(const DScalarContext &rhs)
Copy constructor.
Definition: d2_config.h:755
Parser for DdnsDomainListMgr.
Definition: d2_config.h:903
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:643
Provides storage for and management of a list of DNS domains.
Definition: d2_config.h:632
const std::string getName() const
Fetches the manager's name.
Definition: d2_config.h:668
const DdnsDomainMapPtr & getDomains()
Fetches the domain list.
Definition: d2_config.h:690
const DdnsDomainPtr & getWildcardDomain()
Fetches the wild card domain.
Definition: d2_config.h:683
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:319
void setDomains(DdnsDomainMapPtr domains)
Sets the manger's domain list to the given list of domains.
Definition: d2_config.cc:301
static const char * wildcard_domain_name_
defines the domain name for denoting the wildcard domain.
Definition: d2_config.h:635
virtual ~DdnsDomainListMgr()
Destructor.
Definition: d2_config.cc:297
uint32_t size() const
Returns the number of domains in the domain list.
Definition: d2_config.h:675
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: d2_config.cc:383
Parser for a list of DdnsDomains.
Definition: d2_config.h:880
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:620
Parser for DdnsDomain.
Definition: d2_config.h:861
DdnsDomainPtr parse(data::ConstElementPtr domain_config, const TSIGKeyInfoMapPtr keys)
Performs the actual parsing of the given "ddns-domain" element.
Definition: d2_config.cc:584
Represents a DNS domain that is may be updated dynamically.
Definition: d2_config.h:556
const std::string getKeyName() const
Getter which returns the domain's TSIG key name.
Definition: d2_config.h:582
const std::string getName() const
Getter which returns the domain's name.
Definition: d2_config.h:572
const DnsServerInfoStoragePtr & getServers()
Getter which returns the domain's list of servers.
Definition: d2_config.h:589
virtual ~DdnsDomain()
Destructor.
Definition: d2_config.cc:260
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:837
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:568
Parser for DnsServerInfo.
Definition: d2_config.h:809
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:476
Represents a specific DNS Server.
Definition: d2_config.h:419
bool isEnabled() const
Convenience method which returns whether or not the server is enabled.
Definition: d2_config.h:475
std::string toText() const
Returns a text representation for the server.
Definition: d2_config.cc:221
const std::string getKeyName() const
Convenience method which returns the server's TSIG key name.
Definition: d2_config.cc:212
const TSIGKeyInfoPtr & getTSIGKeyInfo()
Getter which returns the server's TSIGKey info.
Definition: d2_config.h:499
const std::string getHostname() const
Getter which returns the server's hostname.
Definition: d2_config.h:453
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: d2_config.cc:228
uint32_t getPort() const
Getter which returns the server's port number.
Definition: d2_config.h:460
void enable()
Sets the server's enabled flag to true.
Definition: d2_config.h:480
static const uint32_t STANDARD_DNS_PORT
defines DNS standard port value
Definition: d2_config.h:422
void disable()
Sets the server's enabled flag to false.
Definition: d2_config.h:485
const isc::asiolink::IOAddress & getIpAddress() const
Getter which returns the server's ip_address.
Definition: d2_config.h:467
virtual ~DnsServerInfo()
Destructor.
Definition: d2_config.cc:208
Parser for a list of TSIGKeyInfos.
Definition: d2_config.h:788
TSIGKeyInfoMapPtr parse(data::ConstElementPtr key_list_config)
Performs the parsing of the given list "tsig-key" elements.
Definition: d2_config.cc:454
Parser for TSIGKeyInfo.
Definition: d2_config.h:770
TSIGKeyInfoPtr parse(data::ConstElementPtr key_config)
Performs the actual parsing of the given "tsig-key" element.
Definition: d2_config.cc:399
Represents a TSIG Key.
Definition: d2_config.h:264
static const char * HMAC_SHA224_STR
Definition: d2_config.h:271
const std::string getAlgorithm() const
Getter which returns the key's algorithm string ID.
Definition: d2_config.h:323
virtual ~TSIGKeyInfo()
Destructor.
Definition: d2_config.cc:136
const D2TsigKeyPtr & getTSIGKey() const
Getter which returns the TSIG key used to sign and verify messages.
Definition: d2_config.h:345
static const char * HMAC_MD5_STR
Defines string values for the supported TSIG algorithms.
Definition: d2_config.h:268
const std::string getName() const
Getter which returns the key's name.
Definition: d2_config.h:316
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: d2_config.cc:179
static const char * HMAC_SHA1_STR
Definition: d2_config.h:269
static const char * HMAC_SHA256_STR
Definition: d2_config.h:270
uint32_t getDigestbits() const
Getter which returns the key's minimum truncated length.
Definition: d2_config.h:330
static const dns::Name & stringToAlgorithmName(const std::string &algorithm_id)
Converts algorithm id to dns::TSIGKey algorithm dns::Name.
Definition: d2_config.cc:140
static const char * HMAC_SHA512_STR
Definition: d2_config.h:273
const std::string getSecret() const
Getter which returns the key's secret.
Definition: d2_config.h:337
static const char * HMAC_SHA384_STR
Definition: d2_config.h:272
The Name class encapsulates DNS names.
Definition: name.h:223
Base class for all configurations.
Definition: config_base.h:33
#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:153
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
Definition: d2_config.h:610
boost::shared_ptr< DdnsDomainMap > DdnsDomainMapPtr
Defines a pointer to DdnsDomain storage containers.
Definition: d2_config.h:619
std::pair< std::string, TSIGKeyInfoPtr > TSIGKeyInfoMapPair
Defines a iterator pairing of name and TSIGKeyInfo.
Definition: d2_config.h:408
boost::shared_ptr< DnsServerInfo > DnsServerInfoPtr
Defines a pointer for DnsServerInfo instances.
Definition: d2_config.h:540
std::map< std::string, DdnsDomainPtr > DdnsDomainMap
Defines a map of DdnsDomains, keyed by the domain name.
Definition: d2_config.h:613
std::pair< std::string, DdnsDomainPtr > DdnsDomainMapPair
Defines a iterator pairing domain name and DdnsDomain.
Definition: d2_config.h:616
boost::shared_ptr< TSIGKeyInfo > TSIGKeyInfoPtr
Defines a pointer for TSIGKeyInfo instances.
Definition: d2_config.h:402
std::vector< DnsServerInfoPtr > DnsServerInfoStorage
Defines a storage container for DnsServerInfo pointers.
Definition: d2_config.h:543
std::map< std::string, TSIGKeyInfoPtr > TSIGKeyInfoMap
Defines a map of TSIGKeyInfos, keyed by the name.
Definition: d2_config.h:405
boost::shared_ptr< DnsServerInfoStorage > DnsServerInfoStoragePtr
Defines a pointer to DnsServerInfo storage containers.
Definition: d2_config.h:546
boost::shared_ptr< D2Params > D2ParamsPtr
Defines a pointer for D2Params instances.
Definition: d2_config.h:255
boost::shared_ptr< DScalarContext > DScalarContextPtr
Defines a pointer for DScalarContext instances.
Definition: d2_config.h:764
boost::shared_ptr< D2TsigKey > D2TsigKeyPtr
Type of pointer to a D2 TSIG key.
Definition: d2_tsig_key.h:71
boost::shared_ptr< TSIGKeyInfoMap > TSIGKeyInfoMapPtr
Defines a pointer to map of TSIGkeyInfos.
Definition: d2_config.h:411
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:60
NameChangeProtocol
Defines the list of socket protocols supported.
Definition: ncr_io.h:68
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
Definition: config_base.h:176
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.
Base class for user context.
Definition: user_context.h:22