xorp

xrl_cli_node.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2011 XORP, Inc and Others
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, Version 2, June
00007 // 1991 as published by the Free Software Foundation. Redistribution
00008 // and/or modification of this program under the terms of any other
00009 // version of the GNU General Public License is not permitted.
00010 // 
00011 // This program is distributed in the hope that it will be useful, but
00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00014 // see the GNU General Public License, Version 2, a copy of which can be
00015 // found in the XORP LICENSE.gpl file.
00016 // 
00017 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00018 // http://xorp.net
00019 
00020 // $XORP: xorp/cli/xrl_cli_node.hh,v 1.25 2008/10/02 21:56:30 bms Exp $
00021 
00022 #ifndef __CLI_XRL_CLI_NODE_HH__
00023 #define __CLI_XRL_CLI_NODE_HH__
00024 
00025 
00026 
00027 #include "libxorp/xlog.h"
00028 #include "libxipc/xrl_std_router.hh"
00029 #include "xrl/targets/cli_base.hh"
00030 #include "xrl/interfaces/cli_processor_xif.hh"
00031 #include "cli_node.hh"
00032 
00033 //
00034 // TODO: XrlCliProcessorV1p0Client should NOT be a base class. Temp. solution..
00035 //
00036 class XrlCliNode : public XrlStdRouter,
00037            public XrlCliTargetBase {
00038 public:
00039     XrlCliNode(EventLoop&   eventloop,
00040            const string&    class_name,
00041            const string&    finder_hostname,
00042            uint16_t     finder_port,
00043            const string&    finder_target,
00044            CliNode&     cli_node);
00045     virtual ~XrlCliNode() {}
00046 
00047     //
00048     // XrlCliNode front-end interface
00049     //
00050     int enable_cli();
00051     int disable_cli();
00052     int start_cli();
00053     int stop_cli();
00054 
00060     XrlRouter&  xrl_router() { return *this; }
00061 
00067     const XrlRouter& xrl_router() const { return *this; }
00068 
00069 protected:
00070     //
00071     // Methods to be implemented by derived classes supporting this interface.
00072     //
00073 
00077     virtual XrlCmdError common_0_1_get_target_name(
00078     // Output values, 
00079     string& name);
00080 
00084     virtual XrlCmdError common_0_1_get_version(
00085     // Output values, 
00086     string& version);
00087 
00091     virtual XrlCmdError common_0_1_get_status(
00092     // Output values,
00093         uint32_t& status,
00094     string& reason);
00095 
00099     virtual XrlCmdError common_0_1_shutdown();
00100 
00101     virtual XrlCmdError common_0_1_startup() { return XrlCmdError::OKAY(); }
00102 
00108     virtual XrlCmdError cli_manager_0_1_enable_cli(
00109     // Input values,
00110     const bool& enable);
00111 
00112     virtual XrlCmdError cli_manager_0_1_start_cli();
00113 
00114     virtual XrlCmdError cli_manager_0_1_stop_cli();
00115 
00123     virtual XrlCmdError cli_manager_0_1_add_enable_cli_access_from_subnet4(
00124     // Input values, 
00125     const IPv4Net&  subnet_addr);
00126 
00127     virtual XrlCmdError cli_manager_0_1_add_enable_cli_access_from_subnet6(
00128     // Input values, 
00129     const IPv6Net&  subnet_addr);
00130 
00137     virtual XrlCmdError cli_manager_0_1_delete_enable_cli_access_from_subnet4(
00138     // Input values, 
00139     const IPv4Net&  subnet_addr);
00140 
00141     virtual XrlCmdError cli_manager_0_1_delete_enable_cli_access_from_subnet6(
00142     // Input values, 
00143     const IPv6Net&  subnet_addr);
00144 
00152     virtual XrlCmdError cli_manager_0_1_add_disable_cli_access_from_subnet4(
00153     // Input values, 
00154     const IPv4Net&  subnet_addr);
00155 
00156     virtual XrlCmdError cli_manager_0_1_add_disable_cli_access_from_subnet6(
00157     // Input values, 
00158     const IPv6Net&  subnet_addr);
00159 
00166     virtual XrlCmdError cli_manager_0_1_delete_disable_cli_access_from_subnet4(
00167     // Input values, 
00168     const IPv4Net&  subnet_addr);
00169 
00170     virtual XrlCmdError cli_manager_0_1_delete_disable_cli_access_from_subnet6(
00171     // Input values, 
00172     const IPv6Net&  subnet_addr);
00173 
00192     virtual XrlCmdError cli_manager_0_1_add_cli_command(
00193     // Input values, 
00194     const string&   processor_name, 
00195     const string&   command_name, 
00196     const string&   command_help, 
00197     const bool& is_command_cd, 
00198     const string&   command_cd_prompt, 
00199     const bool& is_command_processor);
00200 
00208     virtual XrlCmdError cli_manager_0_1_delete_cli_command(
00209     // Input values, 
00210     const string&   processor_name, 
00211     const string&   command_name);
00212     
00213     //
00214     // The CLI client-side (i.e., the CLI sending XRLs)
00215     //
00216     void send_process_command(const string& target,
00217                   const string& processor_name,
00218                   const string& cli_term_name,
00219                   uint32_t cli_session_id,
00220                   const vector<string>& command_global_name,
00221                   const vector<string>& command_argv);
00222     void recv_process_command_output(const XrlError& xrl_error,
00223                      const string *processor_name,
00224                      const string *cli_term_name,
00225                      const uint32_t *cli_session_id,
00226                      const string *command_output);
00227 private:
00233     virtual void finder_connect_event();
00234 
00240     virtual void finder_disconnect_event();
00241 
00242     CliNode&    cli_node() const { return (_cli_node); }
00243 
00244     EventLoop&      _eventloop;
00245     CliNode&        _cli_node;
00246 
00247     XrlCliProcessorV0p1Client _xrl_cli_processor_client;
00248 
00249     bool        _is_finder_alive;
00250 };
00251 
00252 #endif // __CLI_XRL_CLI_NODE_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations