Kea  1.5.0
cfgmgr.h
Go to the documentation of this file.
1 // Copyright (C) 2012-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 CFGMGR_H
8 #define CFGMGR_H
9 
10 #include <asiolink/io_address.h>
11 #include <dhcp/option.h>
12 #include <dhcp/option_space.h>
13 #include <dhcp/classify.h>
14 #include <dhcpsrv/d2_client_mgr.h>
15 #include <dhcpsrv/pool.h>
16 #include <dhcpsrv/srv_config.h>
17 #include <util/buffer.h>
18 
19 #include <boost/shared_ptr.hpp>
20 #include <boost/noncopyable.hpp>
21 
22 #include <map>
23 #include <string>
24 #include <vector>
25 #include <list>
26 
27 namespace isc {
28 namespace dhcp {
29 
35 public:
36  DuplicateListeningIface(const char* file, size_t line, const char* what) :
37  isc::Exception(file, line, what) { };
38 };
39 
69 class CfgMgr : public boost::noncopyable {
70 public:
71 
75  static const size_t CONFIG_LIST_SIZE;
76 
81  static CfgMgr& instance();
82 
88  std::string getDataDir() const;
89 
93  void setDataDir(const std::string& datadir);
94 
106  void setD2ClientConfig(D2ClientConfigPtr& new_config);
107 
111  bool ddnsEnabled();
112 
116  const D2ClientConfigPtr& getD2ClientConfig() const;
117 
122 
137 
138 
146  void clear();
147 
156  void commit();
157 
167  void rollback();
168 
193  void revert(const size_t index);
194 
219 
233 
235 
237  void setFamily(uint16_t family) {
238  family_ = family == AF_INET ? AF_INET : AF_INET6;
239  }
240 
242  uint16_t getFamily() const {
243  return (family_);
244  }
245 
247 
248 protected:
249 
256  CfgMgr();
257 
259  virtual ~CfgMgr();
260 
261 private:
262 
268  void ensureCurrentAllocated();
269 
271  std::string datadir_;
272 
274  D2ClientMgr d2_client_mgr_;
275 
280  SrvConfigPtr configuration_;
281 
284 
285  typedef std::list<SrvConfigPtr> SrvConfigList;
287 
289  SrvConfigList configs_;
291 
293  uint16_t family_;
294 };
295 
296 } // namespace isc::dhcp
297 } // namespace isc
298 
299 #endif // CFGMGR_H
option_space.h
isc::dhcp::CfgMgr::instance
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition: cfgmgr.cc:25
isc::dhcp::CfgMgr::CONFIG_LIST_SIZE
static const size_t CONFIG_LIST_SIZE
A number of configurations held by CfgMgr.
Definition: cfgmgr.h:75
srv_config.h
io_address.h
isc::dhcp::DuplicateListeningIface
Exception thrown when the same interface has been specified twice.
Definition: cfgmgr.h:34
classify.h
Defines elements for storing the names of client classes.
isc::dhcp::CfgMgr::setFamily
void setFamily(uint16_t family)
Sets address family (AF_INET or AF_INET6)
Definition: cfgmgr.h:237
d2_client_mgr.h
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition: exceptions/exceptions.h:23
isc::dhcp::CfgMgr::setDataDir
void setDataDir(const std::string &datadir)
Sets new data directory.
Definition: cfgmgr.cc:35
isc::dhcp::CfgMgr::getDataDir
std::string getDataDir() const
returns path do the data directory
Definition: cfgmgr.cc:30
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition: exceptions/exceptions.cc:32
isc::dhcp::CfgMgr::CfgMgr
CfgMgr()
Protected constructor.
Definition: cfgmgr.cc:169
isc::dhcp::CfgMgr::setD2ClientConfig
void setD2ClientConfig(D2ClientConfigPtr &new_config)
Updates the DHCP-DDNS client configuration to the given value.
Definition: cfgmgr.cc:40
pool.h
isc::dhcp::CfgMgr::revert
void revert(const size_t index)
Reverts to one of the previous configurations.
Definition: cfgmgr.cc:121
isc::dhcp::CfgMgr::rollback
void rollback()
Removes staging configuration.
Definition: cfgmgr.cc:113
isc::dhcp::CfgMgr::getFamily
uint16_t getFamily() const
Returns address family.
Definition: cfgmgr.h:242
isc::dhcp::D2ClientConfigPtr
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
Definition: d2_client_cfg.h:323
isc::dhcp::DuplicateListeningIface::DuplicateListeningIface
DuplicateListeningIface(const char *file, size_t line, const char *what)
Definition: cfgmgr.h:36
buffer.h
isc::dhcp::CfgMgr::~CfgMgr
virtual ~CfgMgr()
virtual destructor
Definition: cfgmgr.cc:176
isc::dhcp::CfgMgr::getStagingCfg
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Definition: cfgmgr.cc:160
isc::dhcp::CfgMgr::commit
void commit()
Commits the staging configuration.
Definition: cfgmgr.cc:87
isc::dhcp::CfgMgr::clear
void clear()
Removes current, staging and all previous configurations.
Definition: cfgmgr.cc:78
isc::dhcp::D2ClientMgr
D2ClientMgr isolates Kea from the details of being a D2 client.
Definition: d2_client_mgr.h:79
isc::dhcp::CfgMgr::getCurrentCfg
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Definition: cfgmgr.cc:154
isc::dhcp::CfgMgr::getD2ClientMgr
D2ClientMgr & getD2ClientMgr()
Fetches the DHCP-DDNS manager.
Definition: cfgmgr.cc:65
isc::dhcp::CfgMgr::getD2ClientConfig
const D2ClientConfigPtr & getD2ClientConfig() const
Fetches the DHCP-DDNS configuration pointer.
Definition: cfgmgr.cc:60
option.h
isc::dhcp::SrvConfigPtr
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
Definition: srv_config.h:707
isc::dhcp::CfgMgr::ddnsEnabled
bool ddnsEnabled()
Convenience method for checking if DHCP-DDNS updates are enabled.
Definition: cfgmgr.cc:55
isc::dhcp::CfgMgr
Configuration Manager.
Definition: cfgmgr.h:69