Kea: command_interpreter.h Source File

| Kea 3.2.0-git

command_interpreter.h
Go to the documentation of this file.
1// Copyright (C) 2009-2026 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 COMMAND_INTERPRETER_H
8#define COMMAND_INTERPRETER_H
9
10#include <cc/data.h>
11#include <string>
12
19
20namespace isc {
21namespace config {
22
24extern const char *CONTROL_COMMAND;
25
27extern const char *CONTROL_RESULT;
28
30extern const char *CONTROL_TEXT;
31
33extern const char *CONTROL_ARGUMENTS;
34
36extern const char *CONTROL_SERVICE;
37
39extern const char *CONTROL_REMOTE_ADDRESS;
40
42 const int CONTROL_RESULT_SUCCESS = 0;
43
45 const int CONTROL_RESULT_ERROR = 1;
46
48 const int CONTROL_RESULT_COMMAND_UNSUPPORTED = 2;
49
53 const int CONTROL_RESULT_EMPTY = 3;
54
59 const int CONTROL_RESULT_CONFLICT = 4;
60
63 const int CONTROL_RESULT_FATAL_ERROR = 5;
64
67 class CtrlChannelError : public isc::Exception {
68public:
69 CtrlChannelError(const char* file, size_t line, const char* what) :
70 isc::Exception(file, line, what) {}
71};
72
76 isc::data::ConstElementPtr createAnswer();
77
84 isc::data::ConstElementPtr createAnswer(const int status_code,
85 const std::string& status_text);
86
94 isc::data::ConstElementPtr createAnswer(const int status_code,
95 const isc::data::ConstElementPtr& arg);
96
104 isc::data::ConstElementPtr createAnswer(const int status_code,
105 const std::string& status,
106 const isc::data::ConstElementPtr& arg);
107
117 isc::data::ConstElementPtr
118 parseAnswer(int &status_code, const isc::data::ConstElementPtr& msg);
119
129 isc::data::ConstElementPtr
130 parseAnswerText(int &rcode, const isc::data::ConstElementPtr& msg);
131
136std::string answerToText(const isc::data::ConstElementPtr& msg);
137
143 isc::data::ConstElementPtr createCommand(const std::string& command);
144
152 isc::data::ConstElementPtr createCommand(const std::string& command,
153 isc::data::ConstElementPtr arg);
154
162 isc::data::ConstElementPtr createCommand(const std::string& command,
163 const std::string& service);
164
174 isc::data::ConstElementPtr createCommand(const std::string& command,
175 isc::data::ConstElementPtr arg,
176 const std::string& service);
177
188std::string parseCommand(isc::data::ConstElementPtr& arg,
189 isc::data::ConstElementPtr command);
190
191
206std::string parseCommandWithArgs(isc::data::ConstElementPtr& arg,
207 isc::data::ConstElementPtr command);
208
222 isc::data::ConstElementPtr
223 combineCommandsLists(const isc::data::ConstElementPtr& response1,
224 const isc::data::ConstElementPtr& response2);
225
226} // namespace config
227} // namespace isc
228
229#endif // COMMAND_INTERPRETER_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::config::CtrlChannelError::CtrlChannelError
CtrlChannelError(const char *file, size_t line, const char *what)
Definition command_interpreter.h:69
data.h
isc::config
Definition command_interpreter.cc:23
isc::config::answerToText
std::string answerToText(const ConstElementPtr &msg)
Converts answer to printable text.
Definition command_interpreter.cc:129
isc::config::CONTROL_ARGUMENTS
const char * CONTROL_ARGUMENTS
String used for arguments map ("arguments").
Definition command_interpreter.cc:28
isc::config::parseAnswerText
ConstElementPtr parseAnswerText(int &rcode, const ConstElementPtr &msg)
Parses a standard config/command level answer and returns text status.
Definition command_interpreter.cc:69
isc::config::CONTROL_RESULT_EMPTY
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
Definition command_interpreter.h:53
isc::config::CONTROL_TEXT
const char * CONTROL_TEXT
String used for storing textual description ("text").
Definition command_interpreter.cc:27
isc::config::CONTROL_COMMAND
const char * CONTROL_COMMAND
String used for commands ("command").
Definition command_interpreter.cc:25
isc::config::parseAnswer
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
Parses a standard config/command level answer and returns arguments or text status code.
Definition command_interpreter.cc:96
isc::config::createCommand
ConstElementPtr createCommand(const std::string &command)
Creates a standard command message with no argument (of the form { "command": "my_command" }...
Definition command_interpreter.cc:167
isc::config::CONTROL_RESULT_ERROR
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
Definition command_interpreter.h:45
isc::config::combineCommandsLists
ConstElementPtr combineCommandsLists(const ConstElementPtr &response1, const ConstElementPtr &response2)
Combines lists of commands carried in two responses.
Definition command_interpreter.cc:266
isc::config::parseCommand
std::string parseCommand(ConstElementPtr &arg, ConstElementPtr command)
Parses the given command into a string containing the actual command and an ElementPtr containing the...
Definition command_interpreter.cc:200
isc::config::CONTROL_SERVICE
const char * CONTROL_SERVICE
String used for service list ("service").
Definition command_interpreter.cc:29
isc::config::parseCommandWithArgs
std::string parseCommandWithArgs(ConstElementPtr &arg, ConstElementPtr command)
Parses the given command into a string containing the command name and an ElementPtr containing the m...
Definition command_interpreter.cc:238
isc::config::createAnswer
ConstElementPtr createAnswer()
Creates a standard config/command level success answer message (i.e.
Definition command_interpreter.cc:54
isc::config::CONTROL_RESULT_CONFLICT
const int CONTROL_RESULT_CONFLICT
Status code indicating that the command was unsuccessful due to a conflict between the command argume...
Definition command_interpreter.h:59
isc::config::CONTROL_RESULT_COMMAND_UNSUPPORTED
const int CONTROL_RESULT_COMMAND_UNSUPPORTED
Status code indicating that the specified command is not supported.
Definition command_interpreter.h:48
isc::config::CONTROL_REMOTE_ADDRESS
const char * CONTROL_REMOTE_ADDRESS
String used for remote address ("remote-address").
Definition command_interpreter.cc:30
isc::config::CONTROL_RESULT_FATAL_ERROR
const int CONTROL_RESULT_FATAL_ERROR
Status code indicating that the command was unsuccessful and the configuration could not be reverted ...
Definition command_interpreter.h:63
isc::config::CONTROL_RESULT
const char * CONTROL_RESULT
String used for result, i.e. integer status ("result").
Definition command_interpreter.cc:26
isc::config::CONTROL_RESULT_SUCCESS
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
Definition command_interpreter.h:42
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18