Kea: cfgmgr.h Source File

| Kea 2.2.0

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
28namespace isc {
29namespace dhcp {
30
35 class DuplicateListeningIface : public Exception {
36public:
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 {
71public:
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
286protected:
287
294 CfgMgr();
295
297 virtual ~CfgMgr();
298
299private:
300
306 void ensureCurrentAllocated();
307
308
315 void mergeIntoCfg(const SrvConfigPtr& taget_config, const uint32_t seq);
316
318 util::Optional<std::string> datadir_;
319
321 D2ClientMgr d2_client_mgr_;
322
327 SrvConfigPtr configuration_;
328
331
332
333 typedef std::list<SrvConfigPtr> SrvConfigList;
334
336 SrvConfigList configs_;
338
341
342
343 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
buffer.h
classify.h
Defines elements for storing the names of client classes.
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition: exceptions/exceptions.h:23
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
Configuration Manager.
Definition: cfgmgr.h:70
isc::dhcp::CfgMgr::getDataDir
util::Optional< std::string > getDataDir() const
returns path do the data directory
Definition: cfgmgr.cc:31
isc::dhcp::CfgMgr::CfgMgr
CfgMgr()
Protected constructor.
Definition: cfgmgr.cc:222
isc::dhcp::CfgMgr::getD2ClientConfig
const D2ClientConfigPtr & getD2ClientConfig() const
Fetches the DHCP-DDNS configuration pointer.
Definition: cfgmgr.cc:61
isc::dhcp::CfgMgr::getD2ClientMgr
D2ClientMgr & getD2ClientMgr()
Fetches the DHCP-DDNS manager.
Definition: cfgmgr.cc:66
isc::dhcp::CfgMgr::getFamily
uint16_t getFamily() const
Returns address family.
Definition: cfgmgr.h:280
isc::dhcp::CfgMgr::setFamily
void setFamily(uint16_t family)
Sets address family (AF_INET or AF_INET6)
Definition: cfgmgr.h:275
isc::dhcp::CfgMgr::clear
void clear()
Removes current, staging and all previous configurations.
Definition: cfgmgr.cc:79
isc::dhcp::CfgMgr::createExternalCfg
SrvConfigPtr createExternalCfg()
Creates an external configuration and returns pointer to it.
Definition: cfgmgr.cc:177
isc::dhcp::CfgMgr::setD2ClientConfig
void setD2ClientConfig(D2ClientConfigPtr &new_config)
Updates the DHCP-DDNS client configuration to the given value.
Definition: cfgmgr.cc:41
isc::dhcp::CfgMgr::rollback
void rollback()
Removes staging configuration.
Definition: cfgmgr.cc:120
isc::dhcp::CfgMgr::instance
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition: cfgmgr.cc:25
isc::dhcp::CfgMgr::~CfgMgr
virtual ~CfgMgr()
virtual destructor
Definition: cfgmgr.cc:229
isc::dhcp::CfgMgr::mergeIntoStagingCfg
void mergeIntoStagingCfg(const uint32_t seq)
Merges external configuration with the given sequence number into the staging configuration.
Definition: cfgmgr.cc:190
isc::dhcp::CfgMgr::mergeIntoCurrentCfg
void mergeIntoCurrentCfg(const uint32_t seq)
Merges external configuration with the given sequence number into the current configuration.
Definition: cfgmgr.cc:195
isc::dhcp::CfgMgr::setDataDir
void setDataDir(const std::string &datadir, bool unspecified=true)
Sets new data directory.
Definition: cfgmgr.cc:36
isc::dhcp::CfgMgr::getStagingCfg
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Definition: cfgmgr.cc:167
isc::dhcp::CfgMgr::ddnsEnabled
bool ddnsEnabled()
Convenience method for checking if DHCP-DDNS updates are enabled.
Definition: cfgmgr.cc:56
isc::dhcp::CfgMgr::revert
void revert(const size_t index)
Reverts to one of the previous configurations.
Definition: cfgmgr.cc:128
isc::dhcp::CfgMgr::CONFIG_LIST_SIZE
static const size_t CONFIG_LIST_SIZE
A number of configurations held by CfgMgr.
Definition: cfgmgr.h:76
isc::dhcp::CfgMgr::commit
void commit()
Commits the staging configuration.
Definition: cfgmgr.cc:90
isc::dhcp::CfgMgr::getCurrentCfg
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Definition: cfgmgr.cc:161
isc::dhcp::D2ClientMgr
D2ClientMgr isolates Kea from the details of being a D2 client.
Definition: d2_client_mgr.h:80
isc::dhcp::DuplicateListeningIface
Exception thrown when the same interface has been specified twice.
Definition: cfgmgr.h:35
isc::dhcp::DuplicateListeningIface::DuplicateListeningIface
DuplicateListeningIface(const char *file, size_t line, const char *what)
Definition: cfgmgr.h:37
isc::util::Optional< std::string >
d2_client_mgr.h
Defines the D2ClientMgr class.
io_address.h
isc::dhcp::D2ClientConfigPtr
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
Definition: d2_client_cfg.h:236
isc::dhcp::SrvConfigPtr
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
Definition: srv_config.h:1165
isc
Defines the logger used by the top-level component of kea-lfc.
Definition: agent_parser.cc:143
option.h
option_space.h
optional.h
pool.h
srv_config.h