xorp

CliNode Class Reference

The class for the CLI node. More...

#include <cli_node.hh>

Inheritance diagram for CliNode:
ProtoNode< Vif > ProtoUnit ProtoState ServiceBase BugCatcher

List of all members.

Public Types

typedef XorpCallback6< void,
const string &, const string
&, const string &, uint32_t,
const vector< string >
&, const vector< string >
& >::RefPtr 
SenderProcessCallback
typedef XorpCallback1< void,
CliClient * >::RefPtr 
CliClientDeleteCallback

Public Member Functions

 CliNode (int init_family, xorp_module_id init_module_id, EventLoop &init_eventloop)
 Constructor for a given address family, module ID, and event loop.
virtual ~CliNode ()
 Destructor.
int start ()
 Start the node operation.
int stop ()
 Stop the node operation.
void enable ()
 Enable node operation.
void disable ()
 Disable node operation.
void set_cli_port (unsigned short v)
 Set the CLI access port.
void add_enable_cli_access_from_subnet (const IPvXNet &subnet_addr)
 Add a subnet address to the list of subnet addresses enabled for CLI access.
int delete_enable_cli_access_from_subnet (const IPvXNet &subnet_addr)
 Delete a subnet address from the list of subnet addresses enabled for CLI access.
void add_disable_cli_access_from_subnet (const IPvXNet &subnet_addr)
 Add a subnet address to the list of subnet addresses disabled for CLI access.
int delete_disable_cli_access_from_subnet (const IPvXNet &subnet_addr)
 Delete a subnet address from the list of subnet addresses disabled for CLI access.
CliCommandcli_command_root ()
 Get the CliCommand entry for the CLI root command.
CliClientfind_cli_by_term_name (const string &term_name) const
 Find a CLI client CliClient for a given terminal name.
CliClientfind_cli_by_session_id (uint32_t session_id) const
 Find a CLI client CliClient for a given session ID.
list< CliClient * > & client_list ()
 Get the list of CLI clients (see CliClient).
int add_cli_command (const string &processor_name, const string &command_name, const string &command_help, const bool &is_command_cd, const string &command_cd_prompt, const bool &is_command_processor, string &error_msg)
 Add a CLI command to the CLI manager.
int delete_cli_command (const string &processor_name, const string &command_name, string &error_msg)
 Delete a CLI command from the CLI manager.
void recv_process_command_output (const string *processor_name, const string *cli_term_name, const uint32_t *cli_session_id, const string *command_output)
 Process the response of a command processed by a remote node.
int proto_recv (const string &, const string &, const IPvX &, const IPvX &, uint8_t, int32_t, int32_t, bool, bool, const vector< uint8_t > &, string &)
 UNUSED.
int proto_send (const string &, const string &, const IPvX &, const IPvX &, uint8_t, int32_t, int32_t, bool, bool, const uint8_t *, size_t, string &)
 UNUSED.
int signal_message_recv (const string &, int, uint32_t, const IPvX &, const IPvX &, const uint8_t *, size_t)
 UNUSED.
int signal_message_send (const string &, int, uint32_t, const IPvX &, const IPvX &, const uint8_t *, size_t)
 UNUSED.
void set_send_process_command_callback (const SenderProcessCallback &v)
 Set a callback to send a CLI command to a processing module.
CliClientadd_client (XorpFd input_fd, XorpFd output_fd, bool is_network, const string &startup_cli_prompt, string &error_msg)
 Add a CLI client (CliClient) to the CLI with enabled access from a file descriptor.
int remove_client (CliClient *cli_client, string &error_msg)
 Remove a CLI client (CliClient) from the CLI.
void set_cli_client_delete_callback (const CliClientDeleteCallback &v)
 Set the callback method that is invoked whenever a CliClient is deleted.
bool is_log_trace () const
 Test if trace log is enabled.
void set_log_trace (bool is_enabled)
 Enable/disable trace log.

Static Public Member Functions

static int xlog_output (void *obj, xlog_level_t level, const char *msg)
 Output a log message to a CliClient object.

Private Member Functions

int add_internal_cli_commands (string &error_msg)
 CliNode::add_internal_cli_commands: : The error message (if error).
int cli_show_log (const string &server_name, const string &cli_term_name, uint32_t cli_session_id, const vector< string > &command_global_name, const vector< string > &argv)
int cli_show_log_user (const string &server_name, const string &cli_term_name, uint32_t cli_session_id, const vector< string > &command_global_name, const vector< string > &argv)
int cli_set_log_output_cli (const string &server_name, const string &cli_term_name, uint32_t cli_session_id, const vector< string > &command_global_name, const vector< string > &argv)
int cli_set_log_output_file (const string &server_name, const string &cli_term_name, uint32_t cli_session_id, const vector< string > &command_global_name, const vector< string > &argv)
int cli_set_log_output_remove_cli (const string &server_name, const string &cli_term_name, uint32_t cli_session_id, const vector< string > &command_global_name, const vector< string > &argv)
int cli_set_log_output_remove_file (const string &server_name, const string &cli_term_name, uint32_t cli_session_id, const vector< string > &command_global_name, const vector< string > &argv)
int send_process_command (const string &server_name, const string &cli_term_name, const uint32_t cli_session_id, const vector< string > &command_global_name, const vector< string > &argv)
XorpFd sock_serv_open ()
 CliNode::sock_serv_open:
int sock_serv_close ()
 CliNode::sock_serv_close: @:
CliClientadd_connection (XorpFd input_fd, XorpFd output_fd, bool is_network, const string &startup_cli_prompt, string &error_msg)
int delete_connection (CliClient *cli_client, string &error_msg)
void accept_connection (XorpFd fd, IoEventType type)
bool is_allow_cli_access (const IPvX &ipvx) const

Private Attributes

XorpFd _cli_socket
unsigned short _cli_port
list< CliClient * > _client_list
uint32_t _next_session_id
string _startup_cli_prompt
CliCommand _cli_command_root
SenderProcessCallback _send_process_command_callback
CliClientDeleteCallback _cli_client_delete_callback
list< IPvXNet_enable_cli_access_subnet_list
list< IPvXNet_disable_cli_access_subnet_list
bool _is_log_trace

Friends

class CliClient

Detailed Description

The class for the CLI node.

There should one node per CLI instance. There should be one CLI instance per router.


Constructor & Destructor Documentation

CliNode::CliNode ( int  init_family,
xorp_module_id  module_id,
EventLoop init_eventloop 
)

Constructor for a given address family, module ID, and event loop.

CliNode::CliNode: : The address family (AF_INET or AF_INET6 for IPv4 and IPv6 respectively).

Parameters:
init_familythe address family (AF_INET or AF_INET6 for IPv4 and IPv6 respectively). Note that this argument may disappear in the future, and a single Cli node would provide access for both IPv4 and IPv6.
init_module_idthe module ID (xorp_module_id). Should be equal to XORP_MODULE_CLI.
init_eventloopthe event loop to use.

: The module ID (must be XORP_MODULE_CLI). : The event loop.

CLI node constructor.

CliNode::~CliNode ( ) [virtual]

Destructor.

CliNode::~CliNode: @:

CLI node destructor.


Member Function Documentation

int CliNode::add_cli_command ( const string &  processor_name,
const string &  command_name,
const string &  command_help,
const bool &  is_command_cd,
const string &  command_cd_prompt,
const bool &  is_command_processor,
string &  error_msg 
)

Add a CLI command to the CLI manager.

Parameters:
processor_namethe name of the module that will process that command.
command_namethe name of the command to add.
command_helpthe help for the command to add.
is_command_cdif true, this is a command that allows "change directory" inside the CLI command-tree.
command_cd_promptif is_command_cd is true, the string that will replace the CLI prompt after we "cd" to that level of the CLI command-tree.
is_command_processorif true, this is a processing command that would be performed by .
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
CliClient * CliNode::add_client ( XorpFd  input_fd,
XorpFd  output_fd,
bool  is_network,
const string &  startup_cli_prompt,
string &  error_msg 
)

Add a CLI client (CliClient) to the CLI with enabled access from a file descriptor.

Parameters:
input_fdthe file descriptor for the CLI client to read data from.
output_fdthe file descriptor for the CLI client to write data to.
is_networkif true, this client is associated with a network connection.
startup_cli_promptthe startup CLI prompt.
error_msgthe error message (if error).
Returns:
a pointer to the CLI client (CliClient) with enabled CLI access on success, otherwise NULL.
void CliNode::add_disable_cli_access_from_subnet ( const IPvXNet subnet_addr)

Add a subnet address to the list of subnet addresses disabled for CLI access.

CliNode::add_disable_cli_access_from_subnet: : The subnet address to add.

This method can be called more than once to add a number of subnet addresses.

Parameters:
subnet_addrthe subnet address to add.

Add a subnet address to the list of subnet addresses disabled for CLI access. This method can be called more than once to add a number of subnet addresses.

void CliNode::add_enable_cli_access_from_subnet ( const IPvXNet subnet_addr)

Add a subnet address to the list of subnet addresses enabled for CLI access.

CliNode::add_enable_cli_access_from_subnet: : The subnet address to add.

This method can be called more than once to add a number of subnet addresses.

Parameters:
subnet_addrthe subnet address to add.

Add a subnet address to the list of subnet addresses enabled for CLI access. This method can be called more than once to add a number of subnet addresses.

int CliNode::add_internal_cli_commands ( string &  error_msg) [private]

CliNode::add_internal_cli_commands: : The error message (if error).

Add the internal default CLI commands from the top. XXX: used by the CLI itself for internal processing of a command. TODO: for consistency, even the internal commands should use XRLs instead.

Return value: XORP_OK on success, otherwise XORP_ERROR.

CliCommand* CliNode::cli_command_root ( ) [inline]

Get the CliCommand entry for the CLI root command.

Returns:
a pointer to the CliCommand entry for the CLI root command.
list<CliClient *>& CliNode::client_list ( ) [inline]

Get the list of CLI clients (see CliClient).

Returns:
a reference to the list of pointers to CLI clients (see CliClient).
int CliNode::delete_cli_command ( const string &  processor_name,
const string &  command_name,
string &  error_msg 
)

Delete a CLI command from the CLI manager.

Parameters:
processor_namethe name of the module that is processing that command.
command_namethe name of the command to delete.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int CliNode::delete_disable_cli_access_from_subnet ( const IPvXNet subnet_addr)

Delete a subnet address from the list of subnet addresses disabled for CLI access.

CliNode::delete_disable_cli_access_from_subnet: : The subnet address to delete.

Parameters:
subnet_addrthe subnet address to delete.
Returns:
XORP_OK on success, otherwise XORP_ERROR (e.g., if the subnet address was not added before).

Delete a subnet address from the list of subnet addresses disabled for CLI access.

Return value: XORP_OK on success, otherwise XORP_ERROR.

int CliNode::delete_enable_cli_access_from_subnet ( const IPvXNet subnet_addr)

Delete a subnet address from the list of subnet addresses enabled for CLI access.

CliNode::delete_enable_cli_access_from_subnet: : The subnet address to delete.

Parameters:
subnet_addrthe subnet address to delete.
Returns:
XORP_OK on success, otherwise XORP_ERROR (e.g., if the subnet address was not added before).

Delete a subnet address from the list of subnet addresses enabled for CLI access.

Return value: XORP_OK on success, otherwise XORP_ERROR.

void CliNode::disable ( )

Disable node operation.

Disable the node operation.

If an unit is disabled, it cannot be start or pending-start. If the unit was runnning, it will be stop first.

Reimplemented from ProtoState.

void CliNode::enable ( )

Enable node operation.

Enable the node operation.

If an unit is not enabled, it cannot be start, or pending-start.

Reimplemented from ProtoState.

CliClient * CliNode::find_cli_by_session_id ( uint32_t  session_id) const

Find a CLI client CliClient for a given session ID.

CliNode::find_cli_by_session_id: : The CLI session ID to search for.

Parameters:
session_idthe CLI session ID to search for.
Returns:
the CLI client CliClient with session ID of session_id on success, otherwise NULL.

Find a CLI client CliClient for a given session ID.

Return value: The CLI client with session ID of on success, otherwise NULL.

CliClient * CliNode::find_cli_by_term_name ( const string &  term_name) const

Find a CLI client CliClient for a given terminal name.

CliNode::find_cli_by_term_name: : The CLI terminal name to search for.

Parameters:
term_namethe CLI terminal name to search for.
Returns:
the CLI client CliClient with name of term_name on success, otherwise NULL.

Find a CLI client CliClient for a given terminal name.

Return value: The CLI client with name of on success, otherwise NULL.

bool CliNode::is_log_trace ( ) const [inline]

Test if trace log is enabled.

This method is used to test whether to output trace log debug messges.

Returns:
true if trace log is enabled, otherwise false.
void CliNode::recv_process_command_output ( const string *  processor_name,
const string *  cli_term_name,
const uint32_t *  cli_session_id,
const string *  command_output 
)

Process the response of a command processed by a remote node.

Parameters:
processor_namethe name of the module that has processed that command.
cli_term_namethe terminal name the command was entered from.
cli_session_idthe CLI session ID the command was entered from.
command_outputthe command output to process.
int CliNode::remove_client ( CliClient cli_client,
string &  error_msg 
)

Remove a CLI client (CliClient) from the CLI.

Note that the CLI client object itself is not deleted.

Parameters:
cli_clientthe CLI client (CliClient) to remove.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
void CliNode::set_cli_client_delete_callback ( const CliClientDeleteCallback &  v) [inline]

Set the callback method that is invoked whenever a CliClient is deleted.

Parameters:
vthe CliClientDeleteCallback callback to set.
void CliNode::set_cli_port ( unsigned short  v) [inline]

Set the CLI access port.

The access port is the TCP port the CLI node listens to for network access (e.g., telnet xorp_host <port_number>).

Parameters:
vthe access port number (in host order).
void CliNode::set_log_trace ( bool  is_enabled) [inline]

Enable/disable trace log.

This method is used to enable/disable trace log debug messages output.

Parameters:
is_enabledif true, trace log is enabled, otherwise is disabled.
void CliNode::set_send_process_command_callback ( const SenderProcessCallback &  v) [inline]

Set a callback to send a CLI command to a processing module.

Parameters:
vthe SenderProcessCallback callback to set.
int CliNode::sock_serv_close ( ) [private]

CliNode::sock_serv_close: @:

Close the socket that is used by the CLI to listen on for connections.

Return value: XORP_OK on success, otherwise XORP_ERROR.

XorpFd CliNode::sock_serv_open ( ) [private]

CliNode::sock_serv_open:

Open a socket for the CLI to listen on for connections.

Return value: The new socket to listen on success, othewise a XockFd that contains an invalid socket.

int CliNode::start ( )

Start the node operation.

Returns:
XORP_OK on success, otherwise XORP_ERROR.

Reimplemented from ProtoState.

int CliNode::stop ( )

Stop the node operation.

CliNode::stop: @:

Returns:
XORP_OK on success, otherwise XORP_ERROR.

Stop the CLI operation.

Return value: XORP_OK on success, otherwise XORP_ERROR.

Reimplemented from ProtoState.

int CliNode::xlog_output ( void *  obj,
xlog_level_t  level,
const char *  msg 
) [static]

Output a log message to a CliClient object.

CliNode::xlog_output: : The CliClient object to apply this function to.

Parameters:
objthe CliClient object to apply this method to.
levelthe XLOG level.
msga C-style string with the message to output.
Returns:
on success, the number of characters printed, otherwise XORP_ERROR.

: A C-style string with the message to output.

Output a log message to a CliClient object.

Return value: On success, the number of characters printed, otherwise XORP_ERROR.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations