Kea 2.7.5
cfgmgr.h
Go to the documentation of this file.
1// Copyright (C) 2012-2024 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#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
36public:
37 DuplicateListeningIface(const char* file, size_t line, const char* what) :
38 isc::Exception(file, line, what) { }
39};
40
70class CfgMgr : public boost::noncopyable {
71public:
72
76 static const size_t CONFIG_LIST_SIZE;
77
82 static CfgMgr& instance();
83
90
95 void setDataDir(const std::string& datadir, bool unspecified = true);
96
108 void setD2ClientConfig(D2ClientConfigPtr& new_config);
109
113 bool ddnsEnabled();
114
119
124
139
140
148 void clear();
149
158 void commit();
159
169 void rollback();
170
195 void revert(const size_t index);
196
221
235
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
319
321 D2ClientMgrPtr 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
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:70
util::Optional< std::string > getDataDir() const
returns path do the data directory
Definition cfgmgr.cc:31
CfgMgr()
Protected constructor.
Definition cfgmgr.cc:223
const D2ClientConfigPtr & getD2ClientConfig() const
Fetches the DHCP-DDNS configuration pointer.
Definition cfgmgr.cc:61
D2ClientMgr & getD2ClientMgr()
Fetches the DHCP-DDNS manager.
Definition cfgmgr.cc:66
uint16_t getFamily() const
Returns address family.
Definition cfgmgr.h:280
void setFamily(uint16_t family)
Sets address family (AF_INET or AF_INET6)
Definition cfgmgr.h:275
void clear()
Removes current, staging and all previous configurations.
Definition cfgmgr.cc:79
SrvConfigPtr createExternalCfg()
Creates an external configuration and returns pointer to it.
Definition cfgmgr.cc:177
void setD2ClientConfig(D2ClientConfigPtr &new_config)
Updates the DHCP-DDNS client configuration to the given value.
Definition cfgmgr.cc:41
void rollback()
Removes staging configuration.
Definition cfgmgr.cc:120
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition cfgmgr.cc:25
virtual ~CfgMgr()
virtual destructor
Definition cfgmgr.cc:230
void mergeIntoStagingCfg(const uint32_t seq)
Merges external configuration with the given sequence number into the staging configuration.
Definition cfgmgr.cc:190
void mergeIntoCurrentCfg(const uint32_t seq)
Merges external configuration with the given sequence number into the current configuration.
Definition cfgmgr.cc:195
void setDataDir(const std::string &datadir, bool unspecified=true)
Sets new data directory.
Definition cfgmgr.cc:36
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Definition cfgmgr.cc:167
bool ddnsEnabled()
Convenience method for checking if DHCP-DDNS updates are enabled.
Definition cfgmgr.cc:56
void revert(const size_t index)
Reverts to one of the previous configurations.
Definition cfgmgr.cc:128
static const size_t CONFIG_LIST_SIZE
A number of configurations held by CfgMgr.
Definition cfgmgr.h:76
void commit()
Commits the staging configuration.
Definition cfgmgr.cc:90
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Definition cfgmgr.cc:161
D2ClientMgr isolates Kea from the details of being a D2 client.
Exception thrown when the same interface has been specified twice.
Definition cfgmgr.h:35
DuplicateListeningIface(const char *file, size_t line, const char *what)
Definition cfgmgr.h:37
A template representing an optional value.
Definition optional.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.
boost::shared_ptr< D2ClientMgr > D2ClientMgrPtr
Defines a pointer for D2ClientMgr instances.
Defines the logger used by the top-level component of kea-lfc.