Kea: control_socket.h Source File

| Kea 3.0.2-git

control_socket.h
Go to the documentation of this file.
1// Copyright (C) 2018-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
9
10#ifndef CONTROL_SOCKET_H
11#define CONTROL_SOCKET_H
12
13#include <exceptions/exceptions.h>
14#include <netconf/netconf_config.h>
15
16namespace isc {
17namespace netconf {
18
20 class ControlSocketError : public isc::Exception {
21public:
22 ControlSocketError(const char* file, size_t line, const char* what)
23 : isc::Exception(file, line, what) {
24 }
25}; // ControlSocketError
26
33 class ControlSocketBase {
34public:
39 ControlSocketBase(CfgControlSocketPtr ctrl_sock) : socket_cfg_(ctrl_sock) {
40 if (!ctrl_sock) {
41 isc_throw(ControlSocketError, "ControlSocket constructor called "
42 "with a null configuration");
43 }
44 }
45
47 virtual ~ControlSocketBase() = default;
48
52 CfgControlSocket::Type getType() const {
53 return (socket_cfg_->getType());
54 }
55
59 const std::string getName() const {
60 return (socket_cfg_->getName());
61 }
62
66 const isc::http::Url getUrl() const {
67 return (socket_cfg_->getUrl());
68 }
69
77 virtual data::ConstElementPtr configGet(const std::string& service) = 0;
78
87 virtual data::ConstElementPtr configTest(data::ElementPtr config,
88 const std::string& service) = 0;
89
98 virtual data::ConstElementPtr configSet(data::ElementPtr config,
99 const std::string& service) = 0;
100
102 CfgControlSocketPtr socket_cfg_;
103}; // ControlSocketBase
104
106 using ControlSocketBasePtr = std::shared_ptr<ControlSocketBase>;
107
114template <CfgControlSocket::Type TYPE>
115 ControlSocketBasePtr
116createControlSocket(CfgControlSocketPtr ctrl_sock) {
117 isc_throw(NotImplemented, "not specialized createControlSocket");
118}
119
125 ControlSocketBasePtr
126 controlSocketFactory(CfgControlSocketPtr ctrl_sock);
127
128} // namespace netconf
129} // namespace isc
130
131#endif // CONTROL_SOCKET_H
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition exceptions/exceptions.h:23
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::NotImplemented
A generic exception that is thrown when a function is not implemented.
Definition exceptions/exceptions.h:166
isc::http::Url
Represents an URL.
Definition url.h:20
isc::netconf::CfgControlSocket::Type
Type
Defines the list of possible control socket types.
Definition netconf_config.h:73
isc::netconf::ControlSocketBase::configTest
virtual data::ConstElementPtr configTest(data::ElementPtr config, const std::string &service)=0
Test configuration.
isc::netconf::ControlSocketBase::getType
CfgControlSocket::Type getType() const
Getter which returns the socket type.
Definition control_socket.h:52
isc::netconf::ControlSocketBase::~ControlSocketBase
virtual ~ControlSocketBase()=default
Destructor (does nothing).
isc::netconf::ControlSocketBase::configSet
virtual data::ConstElementPtr configSet(data::ElementPtr config, const std::string &service)=0
Set configuration.
isc::netconf::ControlSocketBase::socket_cfg_
CfgControlSocketPtr socket_cfg_
The control socket configuration.
Definition control_socket.h:102
isc::netconf::ControlSocketBase::ControlSocketBase
ControlSocketBase(CfgControlSocketPtr ctrl_sock)
Constructor.
Definition control_socket.h:39
isc::netconf::ControlSocketBase::getName
const std::string getName() const
Returns the Unix socket name.
Definition control_socket.h:59
isc::netconf::ControlSocketBase::configGet
virtual data::ConstElementPtr configGet(const std::string &service)=0
Get configuration.
isc::netconf::ControlSocketBase::getUrl
const isc::http::Url getUrl() const
Returns the HTTP server URL.
Definition control_socket.h:66
isc::netconf::ControlSocketError
Exception thrown when the error during communication.
Definition control_socket.h:20
isc::netconf::ControlSocketError::ControlSocketError
ControlSocketError(const char *file, size_t line, const char *what)
Definition control_socket.h:22
exceptions.h
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
isc::config
Definition command_interpreter.cc:23
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
isc::netconf
Definition control_socket.cc:20
isc::netconf::ControlSocketBasePtr
std::shared_ptr< ControlSocketBase > ControlSocketBasePtr
Type definition for the pointer to the ControlSocketBase.
Definition control_socket.h:106
isc::netconf::createControlSocket
ControlSocketBasePtr createControlSocket(CfgControlSocketPtr ctrl_sock)
Factory template for control sockets.
Definition control_socket.h:116
isc::netconf::CfgControlSocketPtr
std::shared_ptr< CfgControlSocket > CfgControlSocketPtr
Defines a pointer for CfgControlSocket instances.
Definition netconf_config.h:143
isc::netconf::controlSocketFactory
ControlSocketBasePtr controlSocketFactory(CfgControlSocketPtr ctrl_sock)
Factory function for control sockets.
Definition control_socket.cc:23
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
netconf_config.h
A collection of classes for housing and parsing the application configuration necessary for the Netco...