Kea 2.7.1
netconf_config.h
Go to the documentation of this file.
1// Copyright (C) 2018-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 NETCONF_CONFIG_H
8#define NETCONF_CONFIG_H
9
10#include <cc/cfg_to_element.h>
11#include <cc/data.h>
12#include <cc/simple_parser.h>
13#include <cc/user_context.h>
15#include <http/url.h>
16
17#include <cstdint>
18#include <string>
19#include <unordered_map>
20
21namespace isc {
22namespace netconf {
23
64
71public:
73 enum Type {
74 UNIX, //< Unix socket.
75 HTTP, //< HTTP socket.
76 STDOUT //< standard output.
77 }; // Type
78
84 CfgControlSocket(Type type, const std::string& name,
85 const isc::http::Url& url);
86
88 virtual ~CfgControlSocket() = default;
89
93 Type getType() const {
94 return (type_);
95 }
96
100 const std::string getName() const {
101 return (name_);
102 }
103
107 const isc::http::Url getUrl() const {
108 return (url_);
109 }
110
118 static Type stringToType(const std::string& type);
119
124 static const std::string typeToString(CfgControlSocket::Type type);
125
129 isc::data::ElementPtr toElement() const override final;
130
131private:
133 Type type_;
134
136 const std::string name_;
137
139 const isc::http::Url url_;
140}; // CfgControlSocket
141
143using CfgControlSocketPtr = std::shared_ptr<CfgControlSocket>;
144
149class CfgServer : public isc::data::UserContext, public isc::data::CfgToElement {
150public:
155 CfgServer(const std::string& model, CfgControlSocketPtr ctrl_sock);
156
158 virtual ~CfgServer() = default;
159
163 const std::string getModel() const {
164 return (model_);
165 }
166
171 return (control_socket_);
172 }
173
177 bool getBootUpdate() const {
178 return (boot_update_);
179 }
180
184 void setBootUpdate(bool boot_update) {
185 boot_update_ = boot_update;
186 }
187
191 bool getSubscribeChanges() const {
192 return (subscribe_changes_);
193 }
194
199 return (subscribe_notifications_);
200 }
201
205 void setSubscribeChanges(bool subscribe_changes) {
206 subscribe_changes_ = subscribe_changes;
207 }
208
212 void setSubscribeNotifications(bool subscribe_notifications) {
213 subscribe_notifications_ = subscribe_notifications;
214 }
215
219 bool getValidateChanges() const {
220 return (validate_changes_);
221 }
222
226 void setValidateChanges(bool validate_changes) {
227 validate_changes_ = validate_changes;
228 }
229
231 std::string toText() const;
232
236 isc::data::ElementPtr toElement() const override final;
237
238private:
240 const std::string model_;
241
246 bool boot_update_;
247
252 bool subscribe_changes_;
253
259 bool subscribe_notifications_;
260
265 bool validate_changes_;
266
268 CfgControlSocketPtr control_socket_;
269}; // CfgServer
270
272using CfgServerPtr = std::shared_ptr<CfgServer>;
273
275using CfgServersMap = std::unordered_map<std::string, CfgServerPtr>;
276
278using CfgServersMapPair = std::pair<std::string, CfgServerPtr>;
279
281using CfgServersMapPtr = std::shared_ptr<CfgServersMap>;
282
287std::ostream& operator<<(std::ostream& os, const CfgServer& server);
288
293class ControlSocketConfigParser : public data::SimpleParser {
294public:
304 CfgControlSocketPtr parse(data::ConstElementPtr ctrl_sock_config);
305}; // ControlSocketConfigParser
306
312public:
321 CfgServerPtr parse(data::ConstElementPtr server_config);
322}; // ServerConfigParser
323
324} // namespace netconf
325} // namespace isc
326
327#endif // NETCONF_CONFIG_H
Represents an URL.
Definition url.h:20
Represents a Control Socket.
const std::string getName() const
Getter which returns the Unix socket name.
Type getType() const
Getter which returns the socket type.
const isc::http::Url getUrl() const
Getter which returns the HTTP server URL.
isc::data::ElementPtr toElement() const override final
Unparse a configuration object.
Type
Defines the list of possible control socket types.
virtual ~CfgControlSocket()=default
Destructor (doing nothing).
CfgControlSocket(Type type, const std::string &name, const isc::http::Url &url)
Constructor.
static const std::string typeToString(CfgControlSocket::Type type)
Converts CfgControlSocket::Type to string.
static Type stringToType(const std::string &type)
Converts socket type name to CfgControlSocket::Type.
Represents a Managed CfgServer.
virtual ~CfgServer()=default
Destructor (doing nothing).
bool getValidateChanges() const
Getter which returns the validate-changes flag.
void setSubscribeChanges(bool subscribe_changes)
Set the subscribe-changes flag.
bool getBootUpdate() const
Getter which returns the boot-update flag.
void setBootUpdate(bool boot_update)
Set the boot-update flag.
bool getSubscribeNotifications() const
Getter which returns the subscribe-changes flag.
bool getSubscribeChanges() const
Getter which returns the subscribe-changes flag.
void setValidateChanges(bool validate_changes)
Set the validate-changes flag.
void setSubscribeNotifications(bool subscribe_notifications)
Set the subscribe-notifications flag.
const CfgControlSocketPtr & getCfgControlSocket() const
Getter which returns the control socket.
const std::string getModel() const
Getter which returns the model name.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
std::pair< std::string, CfgServerPtr > CfgServersMapPair
Defines a iterator pairing of name and CfgServer.
std::shared_ptr< CfgServer > CfgServerPtr
Defines a pointer for CfgServer instances.
std::shared_ptr< CfgControlSocket > CfgControlSocketPtr
Defines a pointer for CfgControlSocket instances.
std::unordered_map< std::string, CfgServerPtr > CfgServersMap
Defines a map of CfgServers, keyed by the name.
std::shared_ptr< CfgServersMap > CfgServersMapPtr
Defines a pointer to map of CfgServers.
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.
Base class for user context.