Kea 2.7.6
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:
76 static CfgMgr& instance();
77
84
89 void setDataDir(const std::string& datadir, bool unspecified = true);
90
102 void setD2ClientConfig(D2ClientConfigPtr& new_config);
103
107 bool ddnsEnabled();
108
113
118
128
129
137 void clear();
138
143
150 void commit();
151
176
190
202
213 void mergeIntoStagingCfg(const uint32_t seq);
214
225 void mergeIntoCurrentCfg(const uint32_t seq);
226
228
230 void setFamily(uint16_t family) {
231 family_ = family == AF_INET ? AF_INET : AF_INET6;
232 }
233
235 uint16_t getFamily() const {
236 return (family_);
237 }
238
240
241protected:
242
249 CfgMgr();
250
252 virtual ~CfgMgr() = default;
253
254private:
261 void mergeIntoCfg(const SrvConfigPtr& taget_config, const uint32_t seq);
262
265
267 D2ClientMgrPtr d2_client_mgr_;
268
273 SrvConfigPtr configuration_;
274
278 SrvConfigPtr staging_configuration_;
279
282
283
284 typedef std::map<uint32_t, SrvConfigPtr> SrvConfigMap;
285
288 SrvConfigMap external_configs_;
290
292 uint16_t family_;
293};
294
295} // namespace isc::dhcp
296} // namespace isc
297
298#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:34
CfgMgr()
Protected constructor.
Definition cfgmgr.cc:22
virtual ~CfgMgr()=default
virtual destructor
const D2ClientConfigPtr & getD2ClientConfig() const
Fetches the DHCP-DDNS configuration pointer.
Definition cfgmgr.cc:63
D2ClientMgr & getD2ClientMgr()
Fetches the DHCP-DDNS manager.
Definition cfgmgr.cc:68
uint16_t getFamily() const
Returns address family.
Definition cfgmgr.h:235
void setFamily(uint16_t family)
Sets address family (AF_INET or AF_INET6)
Definition cfgmgr.h:230
void clear()
Remove current, staging, and external configurations.
Definition cfgmgr.cc:73
SrvConfigPtr createExternalCfg()
Creates an external configuration and returns pointer to it.
Definition cfgmgr.cc:129
void setD2ClientConfig(D2ClientConfigPtr &new_config)
Updates the DHCP-DDNS client configuration to the given value.
Definition cfgmgr.cc:44
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition cfgmgr.cc:28
void mergeIntoStagingCfg(const uint32_t seq)
Merges external configuration with the given sequence number into the staging configuration.
Definition cfgmgr.cc:142
void mergeIntoCurrentCfg(const uint32_t seq)
Merges external configuration with the given sequence number into the current configuration.
Definition cfgmgr.cc:147
void setDataDir(const std::string &datadir, bool unspecified=true)
Sets new data directory.
Definition cfgmgr.cc:39
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Definition cfgmgr.cc:120
bool ddnsEnabled()
Convenience method for checking if DHCP-DDNS updates are enabled.
Definition cfgmgr.cc:58
void commit()
Commits the staging configuration.
Definition cfgmgr.cc:92
void clearStagingConfiguration()
Remove staging configuration.
Definition cfgmgr.cc:87
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Definition cfgmgr.cc:115
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.