Kea: control_socket.cc Source File

| Kea 3.0.0

control_socket.cc
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
9
10#include <config.h>
11
12#include <netconf/control_socket.h>
13#include <netconf/http_control_socket.h>
14#include <netconf/stdout_control_socket.h>
15#include <netconf/unix_control_socket.h>
16
17using namespace std;
18
19namespace isc {
20 namespace netconf {
21
22 ControlSocketBasePtr
23controlSocketFactory(CfgControlSocketPtr ctrl_sock) {
24 if (!ctrl_sock) {
25 isc_throw(BadValue, "null control socket configuration");
26 }
27 CfgControlSocket::Type sock_type = ctrl_sock->getType();
28 switch (sock_type) {
29 case CfgControlSocket::Type::UNIX:
30 return (createControlSocket<CfgControlSocket::Type::UNIX>(ctrl_sock));
31 case CfgControlSocket::Type::HTTP:
32 return (createControlSocket<CfgControlSocket::Type::HTTP>(ctrl_sock));
33 case CfgControlSocket::Type::STDOUT:
34 return (createControlSocket<CfgControlSocket::Type::STDOUT>(ctrl_sock));
35 default:
36 isc_throw(BadValue, "Unknown control socket type: " << sock_type);
37 }
38}
39
40} // namespace netconf
41} // namespace isc
isc::BadValue
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Definition exceptions/exceptions.h:132
isc::netconf::CfgControlSocket::getType
Type getType() const
Getter which returns the socket type.
Definition netconf_config.h:93
isc::netconf::CfgControlSocket::Type
Type
Defines the list of possible control socket types.
Definition netconf_config.h:73
isc::netconf::CfgControlSocket::STDOUT
@ STDOUT
Definition netconf_config.h:76
isc::netconf::CfgControlSocket::HTTP
@ HTTP
Definition netconf_config.h:75
isc::netconf::CfgControlSocket::UNIX
@ UNIX
Definition netconf_config.h:74
control_socket.h
Contains declarations for control socket communication.
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
http_control_socket.h
Contains declarations for HTTP control socket communication.
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
stdout_control_socket.h
Contains declarations for stdout control socket communication.
unix_control_socket.h
Contains declarations for UNIX control socket communication.