Kea 2.7.6
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
133
137public:
138 D2CfgError(const char* file, size_t line, const char* what) :
139 isc::Exception(file, line, what) { }
140};
141
143class D2Params {
144public:
160 D2Params(const isc::asiolink::IOAddress& ip_address,
161 const size_t port,
162 const size_t dns_server_timeout,
163 const dhcp_ddns::NameChangeProtocol& ncr_protocol,
164 const dhcp_ddns::NameChangeFormat& ncr_format);
165
168 D2Params();
169
171 virtual ~D2Params();
172
175 return (ip_address_);
176 }
177
179 size_t getPort() const {
180 return (port_);
181 }
182
184 size_t getDnsServerTimeout() const {
185 return (dns_server_timeout_);
186 }
187
190 return (ncr_protocol_);
191 }
192
195 return (ncr_format_);
196 }
197
205 std::string getConfigSummary() const;
206
208 bool operator == (const D2Params& other) const;
209
211 bool operator != (const D2Params& other) const;
212
214 std::string toText() const;
215
216protected:
228 virtual void validateContents();
229
230private:
232 isc::asiolink::IOAddress ip_address_;
233
235 size_t port_;
236
238 size_t dns_server_timeout_;
239
242 dhcp_ddns::NameChangeProtocol ncr_protocol_;
243
246 dhcp_ddns::NameChangeFormat ncr_format_;
247};
248
253std::ostream&
254operator<<(std::ostream& os, const D2Params& config);
255
257typedef boost::shared_ptr<D2Params> D2ParamsPtr;
258
267public:
270 static const char* HMAC_MD5_STR;
271 static const char* HMAC_SHA1_STR;
272 static const char* HMAC_SHA256_STR;
273 static const char* HMAC_SHA224_STR;
274 static const char* HMAC_SHA384_STR;
275 static const char* HMAC_SHA512_STR;
277
310 TSIGKeyInfo(const std::string& name, const std::string& algorithm,
311 const std::string& secret, std::string secret_file = "",
312 uint32_t digestbits = 0);
313
315 virtual ~TSIGKeyInfo();
316
320 const std::string getName() const {
321 return (name_);
322 }
323
327 const std::string getAlgorithm() const {
328 return (algorithm_);
329 }
330
334 uint32_t getDigestbits() const {
335 return (digestbits_);
336 }
337
341 const std::string getSecret() const {
342 return (secret_);
343 }
344
348 const std::string getSecretFile() const {
349 return (secret_file_);
350 }
351
356 const D2TsigKeyPtr& getTSIGKey() const {
357 return (tsig_key_);
358 }
359
373 static const dns::Name& stringToAlgorithmName(const std::string&
374 algorithm_id);
375
379 virtual isc::data::ElementPtr toElement() const;
380
381private:
390 void remakeKey();
391
396 std::string name_;
397
399 std::string algorithm_;
400
402 std::string secret_;
403
405 std::string secret_file_;
406
409 uint32_t digestbits_;
410
412 D2TsigKeyPtr tsig_key_;
413};
414
416typedef boost::shared_ptr<TSIGKeyInfo> TSIGKeyInfoPtr;
417
419typedef std::map<std::string, TSIGKeyInfoPtr> TSIGKeyInfoMap;
420
422typedef std::pair<std::string, TSIGKeyInfoPtr> TSIGKeyInfoMapPair;
423
425typedef boost::shared_ptr<TSIGKeyInfoMap> TSIGKeyInfoMapPtr;
426
427
434public:
436 static const uint32_t STANDARD_DNS_PORT = 53;
437
454 DnsServerInfo(const std::string& hostname,
455 isc::asiolink::IOAddress ip_address,
456 uint32_t port = STANDARD_DNS_PORT,
457 bool enabled = true,
458 const TSIGKeyInfoPtr& tsig_key_info = TSIGKeyInfoPtr(),
459 bool inherited_key = true);
460
462 virtual ~DnsServerInfo();
463
467 const std::string getHostname() const {
468 return (hostname_);
469 }
470
474 uint32_t getPort() const {
475 return (port_);
476 }
477
482 return (ip_address_);
483 }
484
489 bool isEnabled() const {
490 return (enabled_);
491 }
492
494 void enable() {
495 enabled_ = true;
496 }
497
499 void disable() {
500 enabled_ = false;
501 }
502
507 const std::string getKeyName() const;
508
514 return (tsig_key_info_);
515 }
516
518 std::string toText() const;
519
523 virtual isc::data::ElementPtr toElement() const;
524
525private:
528 std::string hostname_;
529
532 isc::asiolink::IOAddress ip_address_;
533
535 uint32_t port_;
536
539 bool enabled_;
540
543 TSIGKeyInfoPtr tsig_key_info_;
544
547 bool inherited_key_;
548};
549
550std::ostream&
551operator<<(std::ostream& os, const DnsServerInfo& server);
552
554typedef boost::shared_ptr<DnsServerInfo> DnsServerInfoPtr;
555
557typedef std::vector<DnsServerInfoPtr> DnsServerInfoStorage;
558
560typedef boost::shared_ptr<DnsServerInfoStorage> DnsServerInfoStoragePtr;
561
562
571public:
577 DdnsDomain(const std::string& name, DnsServerInfoStoragePtr servers,
578 const std::string& key_name = "");
579
581 virtual ~DdnsDomain();
582
586 const std::string getName() const {
587 return (name_);
588 }
589
596 const std::string getKeyName() const {
597 return (key_name_);
598 }
599
604 return (servers_);
605 }
606
610 virtual isc::data::ElementPtr toElement() const;
611
612private:
614 std::string name_;
615
618
620 std::string key_name_;
621};
622
624typedef boost::shared_ptr<DdnsDomain> DdnsDomainPtr;
625
627typedef std::map<std::string, DdnsDomainPtr> DdnsDomainMap;
628
630typedef std::pair<std::string, DdnsDomainPtr> DdnsDomainMapPair;
631
633typedef boost::shared_ptr<DdnsDomainMap> DdnsDomainMapPtr;
634
647public:
649 static const char* wildcard_domain_name_;
650
654 DdnsDomainListMgr(const std::string& name);
655
657 virtual ~DdnsDomainListMgr ();
658
677 virtual bool matchDomain(const std::string& fqdn, DdnsDomainPtr& domain);
678
682 const std::string getName() const {
683 return (name_);
684 }
685
689 uint32_t size() const {
690 return (domains_->size());
691 }
692
698 return (wildcard_domain_);
699 }
700
705 return (domains_);
706 }
707
711 void setDomains(DdnsDomainMapPtr domains);
712
716 virtual isc::data::ElementPtr toElement() const;
717
718private:
720 std::string name_;
721
723 DdnsDomainMapPtr domains_;
724
726 DdnsDomainPtr wildcard_domain_;
727};
728
730typedef boost::shared_ptr<DdnsDomainListMgr> DdnsDomainListMgrPtr;
731
743public:
744
747 };
748
750 virtual ~DScalarContext() {
751 }
752
757 return (process::ConfigPtr(new DScalarContext(*this)));
758 }
759
764 isc_throw(isc::NotImplemented, "DScalarContext::ElementPtr");
765 }
766
767protected:
769 DScalarContext(const DScalarContext& rhs) : ConfigBase(rhs) {
770 }
771
772private:
774 DScalarContext& operator=(const DScalarContext& rhs);
775};
776
778typedef boost::shared_ptr<DScalarContext> DScalarContextPtr;
779
785public:
795
796};
797
803public:
817};
818
824public:
842 data::ConstElementPtr domain_config,
843 const TSIGKeyInfoMapPtr keys);
844};
845
852public:
867 data::ConstElementPtr domain_config,
868 const TSIGKeyInfoMapPtr keys);
869};
870
876public:
887 const TSIGKeyInfoMapPtr keys);
888};
889
895public:
909 const TSIGKeyInfoMapPtr keys);
910};
911
918public:
931 const std::string& mgr_name,
932 const TSIGKeyInfoMapPtr keys);
933};
934
935} // end of isc::d2 namespace
936} // end of isc namespace
937
938#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:136
D2CfgError(const char *file, size_t line, const char *what)
Definition d2_config.h:138
Acts as a storage vault for D2 global scalar parameters.
Definition d2_config.h:143
size_t getDnsServerTimeout() const
Return the DNS server timeout value.
Definition d2_config.h:184
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
const dhcp_ddns::NameChangeFormat & getNcrFormat() const
Return the expected format of inbound requests (NCRs).
Definition d2_config.h:194
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
const dhcp_ddns::NameChangeProtocol & getNcrProtocol() const
Return the socket protocol in use.
Definition d2_config.h:189
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
Storage container for scalar configuration parameters.
Definition d2_config.h:742
DScalarContext()
Constructor.
Definition d2_config.h:746
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition d2_config.h:763
virtual process::ConfigPtr clone()
Creates a clone of a DStubContext.
Definition d2_config.h:756
virtual ~DScalarContext()
Destructor.
Definition d2_config.h:750
DScalarContext(const DScalarContext &rhs)
Copy constructor.
Definition d2_config.h:769
Parser for DdnsDomainListMgr.
Definition d2_config.h:917
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
const std::string getName() const
Fetches the manager's name.
Definition d2_config.h:682
DdnsDomainListMgr(const std::string &name)
Constructor.
Definition d2_config.cc:298
const DdnsDomainMapPtr & getDomains()
Fetches the domain list.
Definition d2_config.h:704
const DdnsDomainPtr & getWildcardDomain()
Fetches the wild card domain.
Definition d2_config.h:697
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
const std::string getKeyName() const
Getter which returns the domain's TSIG key name.
Definition d2_config.h:596
const std::string getName() const
Getter which returns the domain's name.
Definition d2_config.h:586
const DnsServerInfoStoragePtr & getServers()
Getter which returns the domain's list of servers.
Definition d2_config.h:603
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
bool isEnabled() const
Convenience method which returns whether or not the server is enabled.
Definition d2_config.h:489
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
const TSIGKeyInfoPtr & getTSIGKeyInfo()
Getter which returns the server's TSIGKey info.
Definition d2_config.h:513
const std::string getHostname() const
Getter which returns the server's hostname.
Definition d2_config.h:467
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
void enable()
Sets the server's enabled flag to true.
Definition d2_config.h:494
static const uint32_t STANDARD_DNS_PORT
defines DNS standard port value
Definition d2_config.h:436
void disable()
Sets the server's enabled flag to false.
Definition d2_config.h:499
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
Parser for a list of TSIGKeyInfos.
Definition d2_config.h:802
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
const std::string getAlgorithm() const
Getter which returns the key's algorithm string ID.
Definition d2_config.h:327
virtual ~TSIGKeyInfo()
Destructor.
Definition d2_config.cc:138
const D2TsigKeyPtr & getTSIGKey() const
Getter which returns the TSIG key used to sign and verify messages.
Definition d2_config.h:356
static const char * HMAC_MD5_STR
Defines string values for the supported TSIG algorithms.
Definition d2_config.h:270
const std::string getName() const
Getter which returns the key's name.
Definition d2_config.h:320
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
uint32_t getDigestbits() const
Getter which returns the key's minimum truncated length.
Definition d2_config.h:334
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
const std::string getSecret() const
Getter which returns the key's secret.
Definition d2_config.h:341
const std::string getSecretFile() const
Getter which returns the secret file name.
Definition d2_config.h:348
static const char * HMAC_SHA384_STR
Definition d2_config.h:274
The Name class encapsulates DNS names.
Definition name.h:219
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: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
std::pair< std::string, TSIGKeyInfoPtr > TSIGKeyInfoMapPair
Defines a iterator pairing of name and TSIGKeyInfo.
Definition d2_config.h:422
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
std::pair< std::string, DdnsDomainPtr > DdnsDomainMapPair
Defines a iterator pairing domain name and DdnsDomain.
Definition d2_config.h:630
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
boost::shared_ptr< D2Params > D2ParamsPtr
Defines a pointer for D2Params instances.
Definition d2_config.h:257
boost::shared_ptr< DScalarContext > DScalarContextPtr
Defines a pointer for DScalarContext instances.
Definition d2_config.h:778
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: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
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.
Base class for user context.