Kea 2.5.9
netconf_config.h
Go to the documentation of this file.
1// Copyright (C) 2018-2022 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 <stdint.h>
18
19#include <string>
20#include <unordered_map>
21
22namespace isc {
23namespace netconf {
24
65
72public:
74 enum Type {
75 UNIX, //< Unix socket.
76 HTTP, //< HTTP socket.
77 STDOUT //< standard output.
78 }; // Type
79
85 CfgControlSocket(Type type, const std::string& name,
86 const isc::http::Url& url);
87
89 virtual ~CfgControlSocket() = default;
90
94 Type getType() const {
95 return (type_);
96 }
97
101 const std::string getName() const {
102 return (name_);
103 }
104
108 const isc::http::Url getUrl() const {
109 return (url_);
110 }
111
119 static Type stringToType(const std::string& type);
120
125 static const std::string typeToString(CfgControlSocket::Type type);
126
130 isc::data::ElementPtr toElement() const override final;
131
132private:
134 Type type_;
135
137 const std::string name_;
138
140 const isc::http::Url url_;
141}; // CfgControlSocket
142
144using CfgControlSocketPtr = std::shared_ptr<CfgControlSocket>;
145
150class CfgServer : public isc::data::UserContext, public isc::data::CfgToElement {
151public:
156 CfgServer(const std::string& model, CfgControlSocketPtr ctrl_sock);
157
159 virtual ~CfgServer() = default;
160
164 const std::string getModel() const {
165 return (model_);
166 }
167
172 return (control_socket_);
173 }
174
178 bool getBootUpdate() const {
179 return (boot_update_);
180 }
181
185 void setBootUpdate(bool boot_update) {
186 boot_update_ = boot_update;
187 }
188
192 bool getSubscribeChanges() const {
193 return (subscribe_changes_);
194 }
195
200 return (subscribe_notifications_);
201 }
202
206 void setSubscribeChanges(bool subscribe_changes) {
207 subscribe_changes_ = subscribe_changes;
208 }
209
213 void setSubscribeNotifications(bool subscribe_notifications) {
214 subscribe_notifications_ = subscribe_notifications;
215 }
216
220 bool getValidateChanges() const {
221 return (validate_changes_);
222 }
223
227 void setValidateChanges(bool validate_changes) {
228 validate_changes_ = validate_changes;
229 }
230
232 std::string toText() const;
233
237 isc::data::ElementPtr toElement() const override final;
238
239private:
241 const std::string model_;
242
247 bool boot_update_;
248
253 bool subscribe_changes_;
254
260 bool subscribe_notifications_;
261
266 bool validate_changes_;
267
269 CfgControlSocketPtr control_socket_;
270}; // CfgServer
271
273using CfgServerPtr = std::shared_ptr<CfgServer>;
274
276using CfgServersMap = std::unordered_map<std::string, CfgServerPtr>;
277
279using CfgServersMapPair = std::pair<std::string, CfgServerPtr>;
280
282using CfgServersMapPtr = std::shared_ptr<CfgServersMap>;
283
288std::ostream& operator<<(std::ostream& os, const CfgServer& server);
289
294class ControlSocketConfigParser : public data::SimpleParser {
295public:
305 CfgControlSocketPtr parse(data::ConstElementPtr ctrl_sock_config);
306}; // ControlSocketConfigParser
307
313public:
322 CfgServerPtr parse(data::ConstElementPtr server_config);
323}; // ServerConfigParser
324
325} // namespace netconf
326} // namespace isc
327
328#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).
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.
Parser for CfgControlSocket.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:29
boost::shared_ptr< Element > ElementPtr
Definition: data.h:28
std::shared_ptr< CfgServersMap > CfgServersMapPtr
Defines a pointer to map of CfgServers.
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::unordered_map< std::string, CfgServerPtr > CfgServersMap
Defines a map of CfgServers, keyed by the name.
std::shared_ptr< CfgControlSocket > CfgControlSocketPtr
Defines a pointer for CfgControlSocket instances.
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.
Base class for user context.
Definition: user_context.h:22