Kea  2.1.7-git
cfgmgr.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2019 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 #include <util/optional.h>
19 
20 #include <boost/shared_ptr.hpp>
21 #include <boost/noncopyable.hpp>
22 
23 #include <map>
24 #include <string>
25 #include <vector>
26 #include <list>
27 
28 namespace isc {
29 namespace dhcp {
30 
36 public:
37  DuplicateListeningIface(const char* file, size_t line, const char* what) :
38  isc::Exception(file, line, what) { };
39 };
40 
70 class CfgMgr : public boost::noncopyable {
71 public:
72 
76  static const size_t CONFIG_LIST_SIZE;
77 
82  static CfgMgr& instance();
83 
89  util::Optional<std::string> getDataDir() const;
90 
95  void setDataDir(const std::string& datadir, bool unspecified = true);
96 
108  void setD2ClientConfig(D2ClientConfigPtr& new_config);
109 
113  bool ddnsEnabled();
114 
118  const D2ClientConfigPtr& getD2ClientConfig() const;
119 
123  D2ClientMgr& getD2ClientMgr();
124 
139 
140 
148  void clear();
149 
158  void commit();
159 
169  void rollback();
170 
195  void revert(const size_t index);
196 
220  SrvConfigPtr getCurrentCfg();
221 
234  SrvConfigPtr getStagingCfg();
235 
246  SrvConfigPtr createExternalCfg();
247 
258  void mergeIntoStagingCfg(const uint32_t seq);
259 
270  void mergeIntoCurrentCfg(const uint32_t seq);
271 
273 
275  void setFamily(uint16_t family) {
276  family_ = family == AF_INET ? AF_INET : AF_INET6;
277  }
278 
280  uint16_t getFamily() const {
281  return (family_);
282  }
283 
285 
286 protected:
287 
294  CfgMgr();
295 
297  virtual ~CfgMgr();
298 
299 private:
300 
306  void ensureCurrentAllocated();
307 
308 
315  void mergeIntoCfg(const SrvConfigPtr& taget_config, const uint32_t seq);
316 
319 
321  D2ClientMgr d2_client_mgr_;
322 
327  SrvConfigPtr configuration_;
328 
331 
332  typedef std::list<SrvConfigPtr> SrvConfigList;
334 
336  SrvConfigList configs_;
338 
341 
342  typedef std::map<uint32_t, SrvConfigPtr> SrvConfigMap;
344 
347  SrvConfigMap external_configs_;
349 
351  uint16_t family_;
352 };
353 
354 } // namespace isc::dhcp
355 } // namespace isc
356 
357 #endif // CFGMGR_H
static const size_t CONFIG_LIST_SIZE
A number of configurations held by CfgMgr.
Definition: cfgmgr.h:76
Defines elements for storing the names of client classes.
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
Definition: srv_config.h:1165
Exception thrown when the same interface has been specified twice.
Definition: cfgmgr.h:35
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
DuplicateListeningIface(const char *file, size_t line, const char *what)
Definition: cfgmgr.h:37
void setFamily(uint16_t family)
Sets address family (AF_INET or AF_INET6)
Definition: cfgmgr.h:275
uint16_t getFamily() const
Returns address family.
Definition: cfgmgr.h:280
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
D2ClientMgr isolates Kea from the details of being a D2 client.
Definition: d2_client_mgr.h:79
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
Defines the D2ClientMgr class.
Configuration Manager.
Definition: cfgmgr.h:70