Kea  1.9.9-git
d2_cfg_mgr.h
Go to the documentation of this file.
1 // Copyright (C) 2014-2021 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_CFG_MGR_H
8 #define D2_CFG_MGR_H
9 
10 #include <asiolink/io_service.h>
11 #include <cc/data.h>
12 #include <exceptions/exceptions.h>
13 #include <d2/d2_config.h>
14 #include <hooks/hooks_config.h>
15 #include <process/d_cfg_mgr.h>
16 
17 #include <stdint.h>
18 #include <string>
19 
20 namespace isc {
21 namespace d2 {
22 
25 typedef boost::shared_ptr<D2CfgContext> D2CfgContextPtr;
26 
35 public:
37  D2CfgContext();
38 
40  virtual ~D2CfgContext();
41 
46  return (process::ConfigPtr(new D2CfgContext(*this)));
47  }
48 
51  return (d2_params_);
52  }
53 
58  return (forward_mgr_);
59  }
60 
63  void setForwardMgr(DdnsDomainListMgrPtr forward_mgr) {
64  forward_mgr_ = forward_mgr;
65  }
66 
71  return (reverse_mgr_);
72  }
73 
76  void setReverseMgr(DdnsDomainListMgrPtr reverse_mgr) {
77  reverse_mgr_ = reverse_mgr;
78  }
79 
84  return (keys_);
85  }
86 
90  void setKeys(const TSIGKeyInfoMapPtr& keys) {
91  keys_ = keys;
92  }
93 
97  return (control_socket_);
98  }
99 
102  void setControlSocketInfo(const isc::data::ConstElementPtr& control_socket) {
103  control_socket_ = control_socket;
104  }
105 
110  return (hooks_config_);
111  }
112 
117  return (hooks_config_);
118  }
119 
123  virtual isc::data::ElementPtr toElement() const;
124 
125 protected:
127  D2CfgContext(const D2CfgContext& rhs);
128 
129 private:
131  D2CfgContext& operator=(const D2CfgContext& rhs);
132 
134  D2ParamsPtr d2_params_;
135 
137  DdnsDomainListMgrPtr forward_mgr_;
138 
140  DdnsDomainListMgrPtr reverse_mgr_;
141 
143  TSIGKeyInfoMapPtr keys_;
144 
146  isc::data::ConstElementPtr control_socket_;
147 
149  isc::hooks::HooksConfig hooks_config_;
150 };
151 
153 typedef boost::shared_ptr<DdnsDomainListMgr> DdnsDomainListMgrPtr;
154 
162 public:
165  static const char* IPV4_REV_ZONE_SUFFIX;
166 
169  static const char* IPV6_REV_ZONE_SUFFIX;
170 
172  D2CfgMgr();
173 
175  virtual ~D2CfgMgr();
176 
180  D2CfgContextPtr getD2CfgContext() {
181  return (boost::dynamic_pointer_cast<D2CfgContext>(getContext()));
182  }
183 
192  bool forwardUpdatesEnabled();
193 
202  bool reverseUpdatesEnabled();
203 
215  bool matchForward(const std::string& fqdn, DdnsDomainPtr& domain);
216 
228  bool matchReverse(const std::string& ip_address, DdnsDomainPtr& domain);
229 
243  static std::string reverseIpAddress(const std::string& address);
244 
262  static std::string reverseV4Address(const isc::asiolink::IOAddress& ioaddr);
263 
282  static std::string reverseV6Address(const isc::asiolink::IOAddress& ioaddr);
283 
286  const D2ParamsPtr& getD2Params();
287 
292 
299  virtual std::string getConfigSummary(const uint32_t selection) override;
300 
301  std::list<std::list<std::string>> jsonPathsToRedact() const final override;
302 
303 protected:
310  virtual isc::data::ConstElementPtr
311  parse(isc::data::ConstElementPtr config, bool check_only) override;
312 
319  virtual void setCfgDefaults(isc::data::ElementPtr mutable_config) override;
320 
330  virtual process::ConfigPtr createNewContext() override;
331 };
332 
334 typedef boost::shared_ptr<D2CfgMgr> D2CfgMgrPtr;
335 
336 } // end of isc::d2 namespace
337 } // end of isc namespace
338 
339 #endif // D2_CFG_MGR_H
virtual process::ConfigPtr createNewContext() override
Creates an new, blank D2CfgContext context.
Definition: d2_cfg_mgr.cc:128
boost::shared_ptr< D2Params > D2ParamsPtr
Defines a pointer for D2Params instances.
Definition: d2_config.h:256
boost::shared_ptr< TSIGKeyInfoMap > TSIGKeyInfoMapPtr
Defines a pointer to map of TSIGkeyInfos.
Definition: d2_config.h:412
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: d2_cfg_mgr.cc:64
boost::shared_ptr< DdnsDomainListMgr > DdnsDomainListMgrPtr
Defines a pointer for DdnsDomain instances.
Definition: d2_cfg_mgr.h:153
static std::string reverseIpAddress(const std::string &address)
Generate a reverse order string for the given IP address.
Definition: d2_cfg_mgr.cc:170
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
Definition: d2_config.h:591
virtual void setCfgDefaults(isc::data::ElementPtr mutable_config) override
Adds default values to the given config.
Definition: d2_cfg_mgr.cc:263
Base class for all configurations.
Definition: config_base.h:33
virtual std::string getConfigSummary(const uint32_t selection) override
Returns configuration summary in the textual format.
Definition: d2_cfg_mgr.cc:258
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
std::list< std::list< std::string > > jsonPathsToRedact() const finaloverride
Return a list of all paths that contain passwords or secrets.
Definition: d2_cfg_mgr.cc:317
Wrapper class that holds hooks libraries configuration.
Definition: hooks_config.h:36
void setReverseMgr(DdnsDomainListMgrPtr reverse_mgr)
Sets the reverse domain list manager.
Definition: d2_cfg_mgr.h:76
const isc::data::ConstElementPtr getControlSocketInfo() const
Returns information about control socket.
Definition: d2_cfg_mgr.h:96
Configuration Manager.
Definition: d_cfg_mgr.h:108
D2CfgMgr()
Constructor.
Definition: d2_cfg_mgr.cc:121
const D2ParamsPtr & getD2Params()
Convenience method fetches the D2Params from context.
Definition: d2_cfg_mgr.cc:248
DdnsDomainListMgrPtr getReverseMgr()
Fetches the reverse DNS domain list manager.
Definition: d2_cfg_mgr.h:70
TSIGKeyInfoMapPtr getKeys()
Fetches the map of TSIG keys.
Definition: d2_cfg_mgr.h:83
virtual ~D2CfgContext()
Destructor.
Definition: d2_cfg_mgr.cc:60
virtual ~D2CfgMgr()
Destructor.
Definition: d2_cfg_mgr.cc:124
const isc::data::ConstElementPtr getControlSocketInfo()
Convenience method fetches information about control socket from context.
Definition: d2_cfg_mgr.cc:253
virtual process::ConfigPtr clone()
Creates a clone of this context object.
Definition: d2_cfg_mgr.h:45
D2CfgContextPtr getD2CfgContext()
Convenience method that returns the D2 configuration context.
Definition: d2_cfg_mgr.h:180
boost::shared_ptr< D2CfgMgr > D2CfgMgrPtr
Defines a shared pointer to D2CfgMgr.
Definition: d2_cfg_mgr.h:334
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
DHCP-DDNS Configuration Context.
Definition: d2_cfg_mgr.h:34
boost::shared_ptr< D2CfgContext > D2CfgContextPtr
Pointer to a configuration context.
Definition: d2_cfg_mgr.h:23
D2ParamsPtr & getD2Params()
Fetches a reference to the D2Params.
Definition: d2_cfg_mgr.h:50
static std::string reverseV6Address(const isc::asiolink::IOAddress &ioaddr)
Generate a reverse order string for the given IP address.
Definition: d2_cfg_mgr.cc:218
const isc::hooks::HooksConfig & getHooksConfig() const
Returns const reference to configured hooks libraries.
Definition: d2_cfg_mgr.h:116
static const char * IPV6_REV_ZONE_SUFFIX
Reverse zone suffix added to IPv6 addresses for reverse lookups.
Definition: d2_cfg_mgr.h:169
Defines the logger used by the top-level component of kea-dhcp-ddns.
bool forwardUpdatesEnabled()
Returns whether or not forward updates are enabled.
Definition: d2_cfg_mgr.cc:133
void setKeys(const TSIGKeyInfoMapPtr &keys)
Sets the map of TSIG keys.
Definition: d2_cfg_mgr.h:90
void setForwardMgr(DdnsDomainListMgrPtr forward_mgr)
Sets the forward domain list manager.
Definition: d2_cfg_mgr.h:63
bool matchReverse(const std::string &ip_address, DdnsDomainPtr &domain)
Matches a given IP address to a reverse domain.
Definition: d2_cfg_mgr.cc:159
bool matchForward(const std::string &fqdn, DdnsDomainPtr &domain)
Matches a given FQDN to a forward domain.
Definition: d2_cfg_mgr.cc:145
virtual isc::data::ConstElementPtr parse(isc::data::ConstElementPtr config, bool check_only) override
Parses configuration of the D2.
Definition: d2_cfg_mgr.cc:268
D2CfgContext()
Constructor.
Definition: d2_cfg_mgr.cc:33
DdnsDomainListMgrPtr getForwardMgr()
Fetches the forward DNS domain list manager.
Definition: d2_cfg_mgr.h:57
isc::hooks::HooksConfig & getHooksConfig()
Returns non-const reference to configured hooks libraries.
Definition: d2_cfg_mgr.h:109
bool reverseUpdatesEnabled()
Returns whether or not reverse updates are enabled.
Definition: d2_cfg_mgr.cc:139
void setControlSocketInfo(const isc::data::ConstElementPtr &control_socket)
Sets information about the control socket.
Definition: d2_cfg_mgr.h:102
A collection of classes for housing and parsing the application configuration necessary for the DHCP-...
DHCP-DDNS Configuration Manager.
Definition: d2_cfg_mgr.h:161
static std::string reverseV4Address(const isc::asiolink::IOAddress &ioaddr)
Generate a reverse order string for the given IP address.
Definition: d2_cfg_mgr.cc:188
static const char * IPV4_REV_ZONE_SUFFIX
Reverse zone suffix added to IPv4 addresses for reverse lookups.
Definition: d2_cfg_mgr.h:165
ConfigPtr & getContext()
Fetches the configuration context.
Definition: d_cfg_mgr.h:151
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
Definition: config_base.h:176