Kea 3.0.0
unix_command_config.h
Go to the documentation of this file.
1// Copyright (C) 2024-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 UNIX_COMMAND_CONFIG_H
8#define UNIX_COMMAND_CONFIG_H
9
10#include <asiolink/asiolink.h>
14#include <cc/cfg_to_element.h>
15#include <cc/user_context.h>
16#include <util/filesystem.h>
17
18namespace isc {
19namespace config {
20
24public:
26 static const mode_t DEFAULT_SOCKET_PATH_PERMS;
27
29 static mode_t socket_path_perms_;
30
35
37 ~UnixCommandConfig() = default;
38
51 static std::string getSocketPath(bool reset = false,
52 const std::string explicit_path = "");
53
60 static std::string validatePath(const std::string socket_path);
61
65 static mode_t getSocketPathPerms();
66
71 static void setSocketPathPerms(mode_t perms = DEFAULT_SOCKET_PATH_PERMS);
72
76 std::string getSocketType() const {
77 return (socket_type_);
78 }
79
83 void setSocketType(const std::string& socket_type) {
84 socket_type_ = socket_type;
85 }
86
90 std::string getSocketName() const {
91 return (socket_name_);
92 }
93
97 void setSocketName(const std::string& socket_name) {
98 socket_name_ = socket_name;
99 }
100
102 std::string getLockName() {
103 return (std::string(socket_name_ + ".lock"));
104 }
105
109 virtual isc::data::ElementPtr toElement() const;
110
111private:
112
114 std::string socket_type_;
115
119 std::string socket_name_;
120};
121
123typedef boost::shared_ptr<UnixCommandConfig> UnixCommandConfigPtr;
124
130
133
135 boost::shared_ptr<isc::asiolink::UnixDomainSocketAcceptor> acceptor_;
136
138 boost::shared_ptr<isc::asiolink::UnixDomainSocket> socket_;
139
142
145 }
146
148 ~UnixSocketInfo() = default;
149};
150
152typedef boost::shared_ptr<UnixSocketInfo> UnixSocketInfoPtr;
153
154} // end of isc::config namespace
155} // end of isc namespace
156#endif
static std::string getSocketPath(bool reset=false, const std::string explicit_path="")
Fetches the supported control socket path.
static mode_t getSocketPathPerms()
Fetches the required socket path permissions mask.
UnixCommandConfig(isc::data::ConstElementPtr config)
Constructor.
std::string getSocketName() const
Returns socket name.
static const mode_t DEFAULT_SOCKET_PATH_PERMS
Defines the default permissions for unix socket parent directory.
static void setSocketPathPerms(mode_t perms=DEFAULT_SOCKET_PATH_PERMS)
Sets the required socket path permissions mask.
std::string getSocketType() const
Returns socket type.
std::string getLockName()
Returns the lock file name.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
static std::string validatePath(const std::string socket_path)
Validates a path against the supported path for unix control sockets.
void setSocketType(const std::string &socket_type)
Sets socket type.
void setSocketName(const std::string &socket_name)
Sets socket name.
~UnixCommandConfig()=default
Virtual destructor.
static mode_t socket_path_perms_
Stores the default permissions for unix socket parent directory.
boost::shared_ptr< UnixSocketInfo > UnixSocketInfoPtr
Pointer to a UnixSocketInfo object.
boost::shared_ptr< UnixCommandConfig > UnixCommandConfigPtr
Pointer to a UnixCommandConfig object.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
Defines the logger used by the top-level component of kea-lfc.
boost::shared_ptr< isc::asiolink::UnixDomainSocketAcceptor > acceptor_
Pointer to the acceptor service.
UnixCommandConfigPtr config_
Pointer to the socket config.
boost::shared_ptr< isc::asiolink::UnixDomainSocket > socket_
Pointer to the socket into which the new connection is accepted.
~UnixSocketInfo()=default
Destructor.
int lock_fd_
File description to lock name file.
bool usable_
Flag which indicates if socket can be reused.
Abstract class for configuration Cfg_* classes.
Base class for user context.