Kea: cfgmgr.h Source File

| Kea 3.0.2-git

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>
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/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
36 class DuplicateListeningIface : public Exception {
37public:
38 DuplicateListeningIface(const char* file, size_t line, const char* what) :
39 isc::Exception(file, line, what) { }
40};
41
71 class 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
123 const D2ClientConfigPtr& getD2ClientConfig() const;
124
128 D2ClientMgr& getD2ClientMgr();
129
139
140
148 void clear();
149
153 void clearStagingConfiguration();
154
161 void commit();
162
186 SrvConfigPtr getCurrentCfg();
187
200 SrvConfigPtr getStagingCfg();
201
212 SrvConfigPtr createExternalCfg();
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
buffer.h
classify.h
Defines elements for storing the names of client classes.
isc::Exception::Exception
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
Definition exceptions/exceptions.cc:17
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::CfgMgr
CfgMgr()
Protected constructor.
Definition cfgmgr.cc:22
isc::dhcp::CfgMgr::~CfgMgr
virtual ~CfgMgr()=default
virtual destructor
isc::dhcp::CfgMgr::getD2ClientConfig
const D2ClientConfigPtr & getD2ClientConfig() const
Fetches the DHCP-DDNS configuration pointer.
Definition cfgmgr.cc:64
isc::dhcp::CfgMgr::getD2ClientMgr
D2ClientMgr & getD2ClientMgr()
Fetches the DHCP-DDNS manager.
Definition cfgmgr.cc:69
isc::dhcp::CfgMgr::getFamily
uint16_t getFamily() const
Returns address family.
Definition cfgmgr.h:246
isc::dhcp::CfgMgr::setFamily
void setFamily(uint16_t family)
Sets address family (AF_INET or AF_INET6).
Definition cfgmgr.h:241
isc::dhcp::CfgMgr::validatePath
std::string validatePath(const std::string data_path) const
Validates a file path against the supported directory for DHDP data.
Definition cfgmgr.cc:40
isc::dhcp::CfgMgr::clear
void clear()
Remove current, staging, and external configurations.
Definition cfgmgr.cc:74
isc::dhcp::CfgMgr::createExternalCfg
SrvConfigPtr createExternalCfg()
Creates an external configuration and returns pointer to it.
Definition cfgmgr.cc:130
isc::dhcp::CfgMgr::setD2ClientConfig
void setD2ClientConfig(D2ClientConfigPtr &new_config)
Updates the DHCP-DDNS client configuration to the given value.
Definition cfgmgr.cc:45
isc::dhcp::CfgMgr::instance
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition cfgmgr.cc:29
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:143
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:148
isc::dhcp::CfgMgr::getStagingCfg
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Definition cfgmgr.cc:121
isc::dhcp::CfgMgr::ddnsEnabled
bool ddnsEnabled()
Convenience method for checking if DHCP-DDNS updates are enabled.
Definition cfgmgr.cc:59
isc::dhcp::CfgMgr::getDataDir
std::string getDataDir(bool reset=false, const std::string explicit_path="")
Fetches the supported DHCP data directory.
Definition cfgmgr.cc:35
isc::dhcp::CfgMgr::commit
void commit()
Commits the staging configuration.
Definition cfgmgr.cc:93
isc::dhcp::CfgMgr::clearStagingConfiguration
void clearStagingConfiguration()
Remove staging configuration.
Definition cfgmgr.cc:88
isc::dhcp::CfgMgr::getCurrentCfg
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Definition cfgmgr.cc:116
isc::dhcp::D2ClientMgr
D2ClientMgr isolates Kea from the details of being a D2 client.
Definition d2_client_mgr.h:89
isc::dhcp::DuplicateListeningIface::DuplicateListeningIface
DuplicateListeningIface(const char *file, size_t line, const char *what)
Definition cfgmgr.h:38
d2_client_mgr.h
Defines the D2ClientMgr class.
filesystem.h
io_address.h
isc::dhcp
Definition dhcp4/client_handler.cc:20
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:1136
isc::dhcp::D2ClientMgrPtr
boost::shared_ptr< D2ClientMgr > D2ClientMgrPtr
Defines a pointer for D2ClientMgr instances.
Definition d2_client_mgr.h:555
isc::util::file
Definition filesystem.cc:28
isc::util::file::PathCheckerPtr
boost::shared_ptr< PathChecker > PathCheckerPtr
Defines a pointer to a PathChecker.
Definition filesystem.h:298
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
option.h
option_space.h
optional.h
pool.h
srv_config.h