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>
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
27namespace isc {
28namespace dhcp {
29
35public:
36 DuplicateListeningIface(const char* file, size_t line, const char* what) :
37 isc::Exception(file, line, what) { };
38};
39
69class CfgMgr : public boost::noncopyable {
70public:
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
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
248protected:
249
256 CfgMgr();
257
259 virtual ~CfgMgr();
260
261private:
262
268 void ensureCurrentAllocated();
269
271 std::string datadir_;
272
274 D2ClientMgr d2_client_mgr_;
275
280 SrvConfigPtr configuration_;
281
284
285
286 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
Defines elements for storing the names of client classes.
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.
Configuration Manager.
Definition: cfgmgr.h:69
CfgMgr()
Protected constructor.
Definition: cfgmgr.cc:169
const D2ClientConfigPtr & getD2ClientConfig() const
Fetches the DHCP-DDNS configuration pointer.
Definition: cfgmgr.cc:60
D2ClientMgr & getD2ClientMgr()
Fetches the DHCP-DDNS manager.
Definition: cfgmgr.cc:65
uint16_t getFamily() const
Returns address family.
Definition: cfgmgr.h:242
void setFamily(uint16_t family)
Sets address family (AF_INET or AF_INET6)
Definition: cfgmgr.h:237
void clear()
Removes current, staging and all previous configurations.
Definition: cfgmgr.cc:78
void setD2ClientConfig(D2ClientConfigPtr &new_config)
Updates the DHCP-DDNS client configuration to the given value.
Definition: cfgmgr.cc:40
void rollback()
Removes staging configuration.
Definition: cfgmgr.cc:113
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition: cfgmgr.cc:25
virtual ~CfgMgr()
virtual destructor
Definition: cfgmgr.cc:176
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Definition: cfgmgr.cc:160
void setDataDir(const std::string &datadir)
Sets new data directory.
Definition: cfgmgr.cc:35
bool ddnsEnabled()
Convenience method for checking if DHCP-DDNS updates are enabled.
Definition: cfgmgr.cc:55
std::string getDataDir() const
returns path do the data directory
Definition: cfgmgr.cc:30
void revert(const size_t index)
Reverts to one of the previous configurations.
Definition: cfgmgr.cc:121
static const size_t CONFIG_LIST_SIZE
A number of configurations held by CfgMgr.
Definition: cfgmgr.h:75
void commit()
Commits the staging configuration.
Definition: cfgmgr.cc:87
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Definition: cfgmgr.cc:154
D2ClientMgr isolates Kea from the details of being a D2 client.
Definition: d2_client_mgr.h:79
Exception thrown when the same interface has been specified twice.
Definition: cfgmgr.h:34
DuplicateListeningIface(const char *file, size_t line, const char *what)
Definition: cfgmgr.h:36
Defines the D2ClientMgr class.
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
Definition: srv_config.h:707
Defines the logger used by the top-level component of kea-dhcp-ddns.