Kea 3.1.1
cfgmgr.h
Go to the documentation of this file.
1// Copyright (C) 2012-2025 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/filesystem.h>
19#include <util/optional.h>
20
21#include <boost/shared_ptr.hpp>
22#include <boost/noncopyable.hpp>
23
24#include <map>
25#include <string>
26#include <vector>
27#include <list>
28
29namespace isc {
30namespace dhcp {
31
37public:
38 DuplicateListeningIface(const char* file, size_t line, const char* what) :
39 isc::Exception(file, line, what) { }
40};
41
71class CfgMgr : public boost::noncopyable {
72public:
77 static CfgMgr& instance();
78
92 std::string getDataDir(bool reset = false,
93 const std::string explicit_path = "");
94
100 std::string validatePath(const std::string data_path) const;
101
113 void setD2ClientConfig(D2ClientConfigPtr& new_config);
114
118 bool ddnsEnabled();
119
124
129
139
140
148 void clear();
149
154
161 void commit();
162
187
201
213
224 void mergeIntoStagingCfg(const uint32_t seq);
225
236 void mergeIntoCurrentCfg(const uint32_t seq);
237
239
241 void setFamily(uint16_t family) {
242 family_ = family == AF_INET ? AF_INET : AF_INET6;
243 }
244
246 uint16_t getFamily() const {
247 return (family_);
248 }
249
251
252protected:
253
260 CfgMgr();
261
263 virtual ~CfgMgr() = default;
264
265private:
272 void mergeIntoCfg(const SrvConfigPtr& taget_config, const uint32_t seq);
273
276 util::file::PathCheckerPtr data_dir_checker_;
277
279 D2ClientMgrPtr d2_client_mgr_;
280
285 SrvConfigPtr configuration_;
286
290 SrvConfigPtr staging_configuration_;
291
294
295
296 typedef std::map<uint32_t, SrvConfigPtr> SrvConfigMap;
297
300 SrvConfigMap external_configs_;
302
304 uint16_t family_;
305};
306
307} // namespace isc::dhcp
308} // namespace isc
309
310#endif // CFGMGR_H
Defines elements for storing the names of client classes.
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
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:64
D2ClientMgr & getD2ClientMgr()
Fetches the DHCP-DDNS manager.
Definition cfgmgr.cc:69
uint16_t getFamily() const
Returns address family.
Definition cfgmgr.h:246
void setFamily(uint16_t family)
Sets address family (AF_INET or AF_INET6)
Definition cfgmgr.h:241
std::string validatePath(const std::string data_path) const
Validates a file path against the supported directory for DHDP data.
Definition cfgmgr.cc:40
void clear()
Remove current, staging, and external configurations.
Definition cfgmgr.cc:74
SrvConfigPtr createExternalCfg()
Creates an external configuration and returns pointer to it.
Definition cfgmgr.cc:130
void setD2ClientConfig(D2ClientConfigPtr &new_config)
Updates the DHCP-DDNS client configuration to the given value.
Definition cfgmgr.cc:45
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition cfgmgr.cc:29
void mergeIntoStagingCfg(const uint32_t seq)
Merges external configuration with the given sequence number into the staging configuration.
Definition cfgmgr.cc:143
void mergeIntoCurrentCfg(const uint32_t seq)
Merges external configuration with the given sequence number into the current configuration.
Definition cfgmgr.cc:148
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Definition cfgmgr.cc:121
bool ddnsEnabled()
Convenience method for checking if DHCP-DDNS updates are enabled.
Definition cfgmgr.cc:59
std::string getDataDir(bool reset=false, const std::string explicit_path="")
Fetches the supported DHCP data directory.
Definition cfgmgr.cc:35
void commit()
Commits the staging configuration.
Definition cfgmgr.cc:93
void clearStagingConfiguration()
Remove staging configuration.
Definition cfgmgr.cc:88
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Definition cfgmgr.cc:116
D2ClientMgr isolates Kea from the details of being a D2 client.
DuplicateListeningIface(const char *file, size_t line, const char *what)
Definition cfgmgr.h:38
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.
boost::shared_ptr< PathChecker > PathCheckerPtr
Defines a pointer to a PathChecker.
Definition filesystem.h:323
Defines the logger used by the top-level component of kea-lfc.