xorp

CliClient Class Reference

The class for the CLI client. More...

#include <cli_client.hh>

List of all members.

Public Member Functions

 CliClient (CliNode &init_cli_node, XorpFd input_fd, XorpFd output_fd, const string &startup_cli_prompt)
 Constructor for a given CLI node and file descriptor.
virtual ~CliClient ()
 Destructor.
bool done () const
 Test if the processing of any pending commands or pending data has complated.
int start_connection (string &error_msg)
 Start the connection.
int stop_connection (string &error_msg)
 Stop the connection.
int cli_print (const string &msg)
 Print a message to the CLI user.
int cli_flush ()
 Flush the CLI output.
int set_log_output (bool v)
 Add/remove this client for displaying log messages.
bool is_log_output () const
 Test if this client has been added for displaying log messages.
XorpFd input_fd ()
 Get the file descriptor for reading the input from the user.
XorpFd output_fd ()
 Get the file descriptor for writing the output to the user.
bool is_input_tty () const
 Test if this client is associated with a terminal type input device.
bool is_output_tty () const
 Test if this client is associated with a terminal type output device.
bool is_network () const
 Test if this client is associated with a network connection.
void set_network_client (bool v)
 Set the flag that associates the client with a network connection.
bool is_telnet () const
 Test if this client is associated with a telnet connection.
bool is_interactive () const
 Test if this client is running in interactive mode.
const string & cli_session_user_name () const
 Get the user name.
const string & cli_session_term_name () const
 Get the terminal name.
const IPvXcli_session_from_address () const
const TimeValcli_session_start_time () const
 Get the start time for this connection.
const TimeValcli_session_stop_time () const
 Get the stop time for this connection.
bool is_cli_session_active () const
 Test if the CLI session is active (i.e., it has been setup and ready to use).
uint32_t cli_session_session_id () const
 Get the session ID.
void set_cli_session_user_name (const string &v)
 Set the user name.
void set_cli_session_term_name (const string &v)
 Set the terminal name.
void set_cli_session_from_address (const IPvX &v)
 Set the user network address.
void set_cli_session_start_time (const TimeVal &v)
 Set the start time for this connection.
void set_cli_session_stop_time (const TimeVal &v)
 Set the stop time for this connection.
void set_is_cli_session_active (bool v)
 Set if this session is active.
void set_cli_session_session_id (uint32_t v)
 Set the session ID.
void post_process_command ()
 Perform final processing of a command.
void flush_process_command_output ()
 Flush the output of a command while it is still running.
bool is_waiting_for_data () const
 Test if waiting for data from command processor.
void set_is_waiting_for_data (bool v)
 Set a flag whether is waiting for data from command processor.
const string & current_cli_prompt () const
 Get the current CLI prompt.
void set_current_cli_prompt (const string &cli_prompt)
 Set the current CLI prompt.
void terminal_resized ()
 Update the terminal-related information after it has been resized.

Private Types

enum  ClientType { CLIENT_MIN = 0, CLIENT_TERMINAL = 0, CLIENT_FILE = 1, CLIENT_MAX }

Private Member Functions

CliNodecli_node ()
GetLinegl ()
int process_telnet_option (int val, bool &is_telnet_option)
 Process octet that may be part of a telnet option.
bool telnet_iac ()
void set_telnet_iac (bool v)
bool telnet_sb ()
void set_telnet_sb (bool v)
bool telnet_dont ()
void set_telnet_dont (bool v)
bool telnet_do ()
void set_telnet_do (bool v)
bool telnet_wont ()
void set_telnet_wont (bool v)
bool telnet_will ()
void set_telnet_will (bool v)
bool telnet_binary ()
void set_telnet_binary (bool v)
void update_terminal_size ()
size_t window_width ()
void set_window_width (uint16_t v)
size_t window_height ()
void set_window_height (uint16_t v)
Buffercommand_buffer ()
Buffertelnet_sb_buffer ()
CliCommandcli_command_root ()
int buff_curpos ()
void set_buff_curpos (int v)
CliCommandcurrent_cli_command ()
void set_current_cli_command (CliCommand *v)
int process_command (const string &command_line)
void interrupt_command ()
CliPipeadd_pipe (const string &pipe_name)
CliPipeadd_pipe (const string &pipe_name, const list< string > &args_list)
void delete_pipe_all ()
bool is_pipe_mode ()
void set_pipe_mode (bool v)
int block_connection (bool is_blocked)
void client_read (XorpFd fd, IoEventType type)
void process_input_data ()
void schedule_process_input_data ()
int process_char (const string &line, uint8_t val, bool &stop_processing)
int process_char_page_mode (uint8_t val)
int preprocess_char (uint8_t val, bool &stop_processing)
void command_line_help (const string &line, int word_end, bool remove_last_input_char)
 CliClient::command_line_help:
bool is_multi_command_prefix (const string &command_line)
void process_line_through_pipes (string &pipe_line)
bool is_page_mode ()
void set_page_mode (bool v)
bool is_page_buffer_mode ()
void set_page_buffer_mode (bool v)
vector< string > & page_buffer ()
const string & page_buffer_line (size_t line_n) const
void reset_page_buffer ()
size_t page_buffer_lines_n ()
void append_page_buffer_line (const string &buffer_line)
void concat_page_buffer_line (const string &buffer_line, size_t pos)
size_t page_buffer_last_line_n ()
void set_page_buffer_last_line_n (size_t v)
void incr_page_buffer_last_line_n ()
void decr_page_buffer_last_line_n ()
size_t page_buffer_window_lines_n ()
size_t page_buffer_last_window_line_n ()
size_t page_buffer2window_line_n (size_t buffer_line_n)
size_t window_lines_n (size_t buffer_line_n)
size_t calculate_first_page_buffer_line_by_window_size (size_t last_buffer_line_n, size_t max_window_size)
bool is_help_mode ()
void set_help_mode (bool v)
bool is_nomore_mode ()
void set_nomore_mode (bool v)
bool is_hold_mode ()
void set_hold_mode (bool v)
bool is_prompt_flushed () const
void set_prompt_flushed (bool v)

Static Private Member Functions

static CPL_MATCH_FN (command_completion_func)

Private Attributes

CliNode_cli_node
XorpFd _input_fd
XorpFd _output_fd
FILE * _input_fd_file
FILE * _output_fd_file
ClientType _client_type
GetLine_gl
bool _telnet_iac
bool _telnet_sb
bool _telnet_dont
bool _telnet_do
bool _telnet_wont
bool _telnet_will
bool _telnet_binary
uint16_t _window_width
uint16_t _window_height
Buffer _command_buffer
Buffer _telnet_sb_buffer
bool _is_modified_stdio_termios_icanon
bool _is_modified_stdio_termios_echo
bool _is_modified_stdio_termios_isig
int _saved_stdio_termios_vmin
int _saved_stdio_termios_vtime
CliCommand_executed_cli_command
vector< string > _executed_cli_command_name
vector< string > _executed_cli_command_args
CliCommand_current_cli_command
string _current_cli_prompt
int _buff_curpos
string _buffer_line
list< CliPipe * > _pipe_list
bool _is_pipe_mode
bool _is_nomore_mode
bool _is_hold_mode
bool _is_page_mode
bool * _is_page_buffer_mode
vector< string > * _page_buffer
size_t * _page_buffer_last_line_n
bool _is_output_buffer_mode
vector< string > _output_buffer
size_t _output_buffer_last_line_n
bool _is_help_buffer_mode
vector< string > _help_buffer
size_t _help_buffer_last_line_n
bool _is_help_mode
bool _is_prompt_flushed
string _action_name_up_arrow
string _action_name_down_arrow
string _action_name_tab
string _action_name_newline_n
string _action_name_newline_r
string _action_name_spacebar
string _action_name_ctrl_a
string _action_name_ctrl_b
string _action_name_ctrl_c
string _action_name_ctrl_d
string _action_name_ctrl_e
string _action_name_ctrl_f
string _action_name_ctrl_h
string _action_name_ctrl_k
string _action_name_ctrl_l
string _action_name_ctrl_m
string _action_name_ctrl_n
string _action_name_ctrl_p
string _action_name_ctrl_u
string _action_name_ctrl_x
string _cli_session_user_name
string _cli_session_term_name
IPvX _cli_session_from_address
TimeVal _cli_session_start_time
TimeVal _cli_session_stop_time
bool _is_cli_session_active
uint32_t _cli_session_session_id
bool _is_network
bool _is_log_output
bool _is_waiting_for_data
vector< uint8_t > _pending_input_data
XorpTimer _process_pending_input_data_timer

Friends

class CliPipe

Detailed Description

The class for the CLI client.

There is one CLI client per CLI user (e.g., telnet connection).


Constructor & Destructor Documentation

CliClient::CliClient ( CliNode init_cli_node,
XorpFd  input_fd,
XorpFd  output_fd,
const string &  startup_cli_prompt 
)

Constructor for a given CLI node and file descriptor.

Parameters:
init_cli_nodethe CliNode CLI node this client belongs to.
input_fdthe file descriptor for the CLI client to read data from.
output_fdthe file descriptor for the CLI client to write data to.
startup_cli_promptthe startup CLI prompt.

Member Function Documentation

int CliClient::cli_flush ( )

Flush the CLI output.

Returns:
XORP_OK on success, otherwise XORP_ERROR.
int CliClient::cli_print ( const string &  msg)

Print a message to the CLI user.

Parameters:
msgC++ string with the message to display.
Returns:
the number of characters printed (not including the trailing '\0').
uint32_t CliClient::cli_session_session_id ( ) const [inline]

Get the session ID.

Returns:
the session ID for this client.
const TimeVal& CliClient::cli_session_start_time ( ) const [inline]

Get the start time for this connection.

Returns:
a reference to TimeVal with the starting time for this connection.
const TimeVal& CliClient::cli_session_stop_time ( ) const [inline]

Get the stop time for this connection.

Returns:
a reference to TimeVal with the end time for this connection.
const string& CliClient::cli_session_term_name ( ) const [inline]

Get the terminal name.

Returns:
the terminal name.
const string& CliClient::cli_session_user_name ( ) const [inline]

Get the user name.

Returns:
the user name.
void CliClient::command_line_help ( const string &  line,
int  word_end,
bool  remove_last_input_char 
) [private]

CliClient::command_line_help:

The current command line. : The cursor position. : If true, then remove the last input character.

Print the help for the same-line command.

const string& CliClient::current_cli_prompt ( ) const [inline]

Get the current CLI prompt.

Returns:
the current CLI prompt.
bool CliClient::done ( ) const

Test if the processing of any pending commands or pending data has complated.

Returns:
true if processing of any pending commands or pending data has completed, otherwise false.
XorpFd CliClient::input_fd ( ) [inline]

Get the file descriptor for reading the input from the user.

Returns:
the file descriptor for reading the input from the user.
bool CliClient::is_cli_session_active ( ) const [inline]

Test if the CLI session is active (i.e., it has been setup and ready to use).

Returns:
true if the CLI session is active, otherwise false.
bool CliClient::is_input_tty ( ) const

Test if this client is associated with a terminal type input device.

Returns:
true if this client is associated with a terminal type input device, otherwise false.
bool CliClient::is_interactive ( ) const

Test if this client is running in interactive mode.

Returns:
true if this client is running in interactive mode, otherwise false.
bool CliClient::is_log_output ( ) const [inline]

Test if this client has been added for displaying log messages.

Returns:
true if this client has been added for displaying log messages, otherwise false.
bool CliClient::is_network ( ) const

Test if this client is associated with a network connection.

Returns:
true if this client is associated with a network connection, otherwise false.
bool CliClient::is_output_tty ( ) const

Test if this client is associated with a terminal type output device.

Returns:
true if this client is associated with a terminal type output device, otherwise false.
bool CliClient::is_telnet ( ) const

Test if this client is associated with a telnet connection.

Returns:
true if this client is associated with a telnet connection, otherwise false.
bool CliClient::is_waiting_for_data ( ) const [inline]

Test if waiting for data from command processor.

Returns:
true if waiting for data from command processor, otherwise false.
XorpFd CliClient::output_fd ( ) [inline]

Get the file descriptor for writing the output to the user.

Returns:
the file descriptor for writing the output to the user.
int CliClient::process_telnet_option ( int  val,
bool &  is_telnet_option 
) [private]

Process octet that may be part of a telnet option.

Parameters:
valthe value of the next octet.
is_telnet_optionreturn-by-reference result: if true, then val is part of a telnet option and it was processed. If it is false, then value should be processed as input data.
Returns:
XORP_OK on success, otherwise XORP_ERROR.
void CliClient::set_cli_session_from_address ( const IPvX v) [inline]

Set the user network address.

Parameters:
vthe user network address to set.
void CliClient::set_cli_session_session_id ( uint32_t  v) [inline]

Set the session ID.

Parameters:
vthe session ID value to set.
void CliClient::set_cli_session_start_time ( const TimeVal v) [inline]

Set the start time for this connection.

Parameters:
vthe start time for this connection.
void CliClient::set_cli_session_stop_time ( const TimeVal v) [inline]

Set the stop time for this connection.

Parameters:
vthe stop time for this connection.
void CliClient::set_cli_session_term_name ( const string &  v) [inline]

Set the terminal name.

Parameters:
vthe terminal name to set.
void CliClient::set_cli_session_user_name ( const string &  v) [inline]

Set the user name.

Parameters:
vthe user name to set.
void CliClient::set_current_cli_prompt ( const string &  cli_prompt)

Set the current CLI prompt.

Parameters:
cli_promptthe current CLI prompt to set.
void CliClient::set_is_cli_session_active ( bool  v) [inline]

Set if this session is active.

Parameters:
vif true, the session is set as active, otherwise is set as non-active.
void CliClient::set_is_waiting_for_data ( bool  v)

Set a flag whether is waiting for data from command processor.

Parameters:
vif true, the session is set as waiting for data, otherwise is set as non-waiting.
int CliClient::set_log_output ( bool  v)

Add/remove this client for displaying log messages.

Parameters:
vif true, add this client for displaying messages, otherwise remove it.
Returns:
XORP_OK on success, otherwise XORP_ERROR.
void CliClient::set_network_client ( bool  v)

Set the flag that associates the client with a network connection.

Parameters:
vtrue if this client is associated with a network connection.
int CliClient::start_connection ( string &  error_msg)

Start the connection.

Parameters:
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int CliClient::stop_connection ( string &  error_msg)

Stop the connection.

Parameters:
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.

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