3 * @brief l7vsadm and l7vsd connection data prototype
5 * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6 * Copyright (C) 2009 NTT COMWARE Corporation.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 **********************************************************************/
25 #ifndef L7VS_COMMAND_H
26 #define L7VS_COMMAND_H
28 #include <boost/serialization/string.hpp>
29 #include <boost/serialization/vector.hpp>
30 #include <boost/serialization/list.hpp>
31 #include <boost/serialization/utility.hpp>
32 #include <boost/asio.hpp>
35 #include "logger_enum.h"
36 #include "parameter_enum.h"
37 #include "replication.h"
38 #include "virtualservice_element.h"
39 #include "snmp_info.h"
44 //! @class l7vsadm_request
45 //! @brief l7vsadm -> l7vsd request data class
49 //! @enum COMMAND_CODE_TAG request command code enum
50 enum COMMAND_CODE_TAG {
52 CMD_LIST, //!< List command(-l,--list)
53 CMD_LIST_VERBOSE, //!< Verbose list command(-V,--verbose)
54 CMD_LIST_KEY, //!< Key list command(-K, --key)
55 CMD_ADD_VS, //!< Add VirtualService command(-A,--add-service)
56 CMD_DEL_VS, //!< Delete VirtualService command(-D, --delete-service)
57 CMD_EDIT_VS, //!< Edit VirtualService command(-E, --edit-service)
58 CMD_FLUSH_VS, //!< Flush VirtualService command(-C, --flush)
59 CMD_ADD_RS, //!< Add RealServer command(-a, --add-server)
60 CMD_DEL_RS, //!< Delete RealServer command(-d, --delete-server)
61 CMD_EDIT_RS, //!< Edit RealServer command(-e.--edit-server)
62 CMD_REPLICATION, //!< Replication command(-R, --replication)
63 CMD_LOG, //!< Logger command(-L, -log)
64 CMD_SNMP, //!< SNMPAgent command(-S, --snmp)
65 CMD_PARAMETER, //!< Parameter command(-P, --parameter)
66 CMD_HELP, //!< Help command(-h, --help)
69 //! @enum REPLICATION_COMMAND_TAG replication request command enum
70 enum REPLICATION_COMMAND_TAG {
72 REP_START, //!< REPLICATION START COMMAND
73 REP_STOP, //!< REPLICATION STOP COMMAND
74 REP_FORCE, //!< REPLICATION FORCE COMMAND
75 REP_DUMP //!< REPLICATION DUMP COMMAND
78 COMMAND_CODE_TAG command; //!< request command
79 virtualservice_element vs_element; //!< use VS mode and RealServer mode
80 REPLICATION_COMMAND_TAG replication_command; //!< use replication command mode
81 LOG_CATEGORY_TAG log_category; //!< use log change mode. target log category
82 LOG_LEVEL_TAG log_level; //!< use log level change mode target category log level
83 PARAMETER_COMPONENT_TAG reload_param; //!< set reload param mode
86 l7vsadm_request() : command(CMD_NONE),
87 replication_command(REP_NONE),
88 log_category(LOG_CAT_NONE),
89 log_level(LOG_LV_NONE),
90 reload_param(PARAM_COMP_NOCAT) {}
92 template <typename Elem, typename Traits>
93 friend std::basic_ostream<Elem, Traits>& operator<<(
94 std::basic_ostream<Elem, Traits>& os,
95 const l7vsadm_request &request) {
97 os << "l7vsadm_request={";
98 os << boost::format("command=%d: "
100 "replication_command=%d: "
107 % request.replication_command
108 % request.log_category
110 % request.reload_param
116 friend class boost::serialization::access; //!< serializable access class is friend.
117 //! serializable function
118 //! @param[in] archiver class from boost serializable
119 //! @param[in] version use boost serializable
120 template <class Archive > void serialize(Archive &ar, const unsigned int version) {
123 ar &replication_command;
132 //! @class l7vsd_response
133 //! @brief l7vsd -> l7vsadm data class
137 enum COMMAND_RESPONSE_CODE { //!< response command code enum
138 RESPONSE_NONE = 0, //!< none
139 RESPONSE_OK, //!< request execute ok
140 RESPONSE_ERROR, //!< request execute error
141 RESPONSE_LIST_ERROR, //!< list request error
142 RESPONSE_LIST_VERBOSE_ERROR,//!< list verbose request error
143 RESPONSE_LIST_KEY_ERROR, //!< list key request error
144 RESPONSE_ADD_VS_ERROR, //!< virtual service add error
145 RESPONSE_DEL_VS_ERROR, //!< virtual service delete error
146 RESPONSE_EDIT_VS_ERROR, //!< virtual service edit error
147 RESPONSE_FLUSH_VS_ERROR, //!< virtual service clear error
148 RESPONSE_ADD_RS_ERROR, //!< realserver add error
149 RESPONSE_DEL_RS_ERROR, //!< realserver delete error
150 RESPONSE_EDIT_RS_ERROR, //!< realserver edit error
151 RESPONSE_REPLICATION_ERROR, //!< replication error
152 RESPONSE_LOG_ERROR, //!< logger error
153 RESPONSE_SNMP_ERROR, //!< snmpagent error
154 RESPONSE_PARAMETER_ERROR //!< parameter error
157 typedef std::pair<LOG_CATEGORY_TAG, LOG_LEVEL_TAG> log_category_level_type;
159 l7vsadm_request::COMMAND_CODE_TAG
160 code; //!< request command.
162 COMMAND_RESPONSE_CODE status; //!< return status.
164 std::string message;//!< error message
166 std::list< virtualservice_element >
167 virtualservice_status_list;//!< virtual service lists
169 replication::REPLICATION_MODE_TAG replication_mode_status;//!< replication status.
171 std::list< log_category_level_type >
172 log_status_list; //!< log categories statuses.
174 //bool snmp_connection_status; //!< snmp connection status
178 unsigned long long total_bps; //!< l7vsd's total bit par sec
179 unsigned long long total_client_recv_byte; //!< l7vsd's total client receive bytes
180 unsigned long long total_client_send_byte; //!< l7vsd's total client send bytes
181 unsigned long long total_realserver_recv_byte; //!< l7vsd's total realserver receive bytes
182 unsigned long long total_realserver_send_byte; //!< l7vsd's total realserver send bytes
183 std::vector<virtualservice_element>
184 virtualservice_vec; //!< virtualservice lists
186 l7vsd_response() : code(l7vsadm_request::CMD_NONE),
187 status(RESPONSE_NONE),
189 replication_mode_status(replication::REPLICATION_OUT),
191 total_client_recv_byte(0ULL),
192 total_client_send_byte(0ULL),
193 total_realserver_recv_byte(0ULL),
194 total_realserver_send_byte(0ULL) {}
196 template <typename Elem, typename Traits>
197 friend std::basic_ostream<Elem, Traits>& operator<<(
198 std::basic_ostream<Elem, Traits>& os,
199 const l7vsd_response &response) {
201 os << "l7vsd_response={";
202 os << boost::format("code=%d: "
210 BOOST_FOREACH(virtualservice_element vs_elem, response.virtualservice_status_list) {
211 os << boost::format("virtualservice_status_list[%d]=") % i;
217 os << boost::format("replication_mode_status=%d: ")
218 % response.replication_mode_status;
221 BOOST_FOREACH(log_category_level_type log_pair, response.log_status_list) {
222 os << boost::format("log_status_list[%d]={log_category=%d, log_level=%d}")
230 os << "snmpinfo=" << response.snmpinfo;
232 os << boost::format("total_bps=%d: "
233 "total_client_recv_byte=%d: "
234 "total_client_send_byte=%d: "
235 "total_realserver_recv_byte=%d: "
236 "total_realserver_send_byte=%d: ")
238 % response.total_client_recv_byte
239 % response.total_client_send_byte
240 % response.total_realserver_recv_byte
241 % response.total_realserver_send_byte;
244 BOOST_FOREACH(virtualservice_element vs_elem, response.virtualservice_vec) {
245 os << boost::format("virtualservice_vec[%d]=") % i;
256 friend class boost::serialization::access; //! friend boost serializable class
258 //! @brief using boost serializable. class serializable function.
259 //! @param[in] archive
260 //! @param[in] version
261 template <class Archive > void serialize(Archive &ar, const unsigned int version) {
265 ar &virtualservice_status_list;
266 ar &replication_mode_status;
270 ar &total_client_recv_byte;
271 ar &total_client_send_byte;
272 ar &total_realserver_recv_byte;
273 ar &total_realserver_send_byte;
274 ar &virtualservice_vec;