FD.io VPP  v16.06
Vector Packet Processing
cli.c File Reference

Unix stdin/socket command line interface. More...

+ Include dependency graph for cli.c:

Go to the source code of this file.

Data Structures

struct  unix_cli_banner_t
 A CLI banner line. More...
 
struct  unix_cli_file_t
 Unix CLI session. More...
 
struct  unix_cli_parse_actions_t
 Mapping of input buffer strings to action values. More...
 
struct  unix_cli_main_t
 CLI global state. More...
 

Macros

#define ESC   "\x1b"
 ANSI escape code. More...
 
#define CSI   ESC "["
 ANSI Control Sequence Introducer. More...
 
#define ANSI_CLEAR   CSI "2J" CSI "1;1H"
 ANSI clear screen. More...
 
#define ANSI_RESET   CSI "0m"
 ANSI reset color settings. More...
 
#define ANSI_BOLD   CSI "1m"
 ANSI Start bold text. More...
 
#define ANSI_DIM   CSI "2m"
 ANSI Stop bold text. More...
 
#define ANSI_DRED   ANSI_DIM CSI "31m"
 ANSI Start dark red text. More...
 
#define ANSI_BRED   ANSI_BOLD CSI "31m"
 ANSI Start bright red text. More...
 
#define ANSI_CLEARLINE   CSI "2K"
 ANSI clear line cursor is on. More...
 
#define ANSI_SCROLLDN   CSI "1T"
 ANSI scroll screen down one line. More...
 
#define ANSI_SAVECURSOR   CSI "s"
 ANSI save cursor position. More...
 
#define ANSI_RESTCURSOR   CSI "u"
 ANSI restore cursor position if previously saved. More...
 
#define UNIX_CLI_MAX_DEPTH_TELNET   24
 Maximum depth into a byte stream from which to compile a Telnet protocol message. More...
 
#define UNIX_CLI_STDIN_FD   0
 Unix standard in. More...
 
#define CTL(c)   (u8[]){ (c) - '@', 0 }
 Given a capital ASCII letter character return a NUL terminated string with the control code for that letter. More...
 

Enumerations

enum  unix_cli_parse_action_t {
  UNIX_CLI_PARSE_ACTION_NOACTION = 0, UNIX_CLI_PARSE_ACTION_CRLF, UNIX_CLI_PARSE_ACTION_TAB, UNIX_CLI_PARSE_ACTION_ERASE,
  UNIX_CLI_PARSE_ACTION_ERASERIGHT, UNIX_CLI_PARSE_ACTION_UP, UNIX_CLI_PARSE_ACTION_DOWN, UNIX_CLI_PARSE_ACTION_LEFT,
  UNIX_CLI_PARSE_ACTION_RIGHT, UNIX_CLI_PARSE_ACTION_HOME, UNIX_CLI_PARSE_ACTION_END, UNIX_CLI_PARSE_ACTION_WORDLEFT,
  UNIX_CLI_PARSE_ACTION_WORDRIGHT, UNIX_CLI_PARSE_ACTION_ERASELINELEFT, UNIX_CLI_PARSE_ACTION_ERASELINERIGHT, UNIX_CLI_PARSE_ACTION_CLEAR,
  UNIX_CLI_PARSE_ACTION_REVSEARCH, UNIX_CLI_PARSE_ACTION_FWDSEARCH, UNIX_CLI_PARSE_ACTION_YANK, UNIX_CLI_PARSE_ACTION_TELNETIAC,
  UNIX_CLI_PARSE_ACTION_PAGER_CRLF, UNIX_CLI_PARSE_ACTION_PAGER_QUIT, UNIX_CLI_PARSE_ACTION_PAGER_NEXT, UNIX_CLI_PARSE_ACTION_PAGER_DN,
  UNIX_CLI_PARSE_ACTION_PAGER_UP, UNIX_CLI_PARSE_ACTION_PAGER_TOP, UNIX_CLI_PARSE_ACTION_PAGER_BOTTOM, UNIX_CLI_PARSE_ACTION_PAGER_PGDN,
  UNIX_CLI_PARSE_ACTION_PAGER_PGUP, UNIX_CLI_PARSE_ACTION_PAGER_SEARCH, UNIX_CLI_PARSE_ACTION_PARTIALMATCH, UNIX_CLI_PARSE_ACTION_NOMATCH
}
 CLI actions. More...
 
enum  unix_cli_process_event_type_t { UNIX_CLI_PROCESS_EVENT_READ_READY, UNIX_CLI_PROCESS_EVENT_QUIT }
 CLI session events. More...
 

Functions

always_inline void unix_cli_pager_reset (unix_cli_file_t *f)
 Resets the pager buffer and other data. More...
 
always_inline void unix_cli_file_free (unix_cli_file_t *f)
 Release storage used by a CLI session. More...
 
static unix_cli_parse_action_t unix_cli_match_action (unix_cli_parse_actions_t *a, u8 *input, u32 ilen, i32 *matched)
 Search for a byte sequence in the action list. More...
 
static void unix_cli_add_pending_output (unix_file_t *uf, unix_cli_file_t *cf, u8 *buffer, uword buffer_bytes)
 
static void unix_cli_del_pending_output (unix_file_t *uf, unix_cli_file_t *cf, uword n_bytes)
 
always_inline word unix_vlib_findchr (u8 chr, u8 *str, word len)
 A bit like strchr with a buffer length limit. More...
 
static void unix_vlib_cli_output_raw (unix_cli_file_t *cf, unix_file_t *uf, u8 *buffer, uword buffer_bytes)
 Send a buffer to the CLI stream if possible, enqueue it otherwise. More...
 
static void unix_vlib_cli_output_cooked (unix_cli_file_t *cf, unix_file_t *uf, u8 *buffer, uword buffer_bytes)
 Process a buffer for CRLF handling before outputting it to the CLI. More...
 
static void unix_cli_cli_prompt (unix_cli_file_t *cf, unix_file_t *uf)
 Output the CLI prompt. More...
 
static void unix_cli_pager_prompt (unix_cli_file_t *cf, unix_file_t *uf)
 Output a pager prompt and show number of buffered lines. More...
 
static void unix_cli_pager_message (unix_cli_file_t *cf, unix_file_t *uf, char *message, char *postfix)
 Output a pager "skipping" message. More...
 
static void unix_cli_pager_prompt_erase (unix_cli_file_t *cf, unix_file_t *uf)
 Erase the printed pager prompt. More...
 
static void unix_cli_ansi_cursor (unix_cli_file_t *cf, unix_file_t *uf, u16 x, u16 y)
 Uses an ANSI escape sequence to move the cursor. More...
 
static void unix_vlib_cli_output (uword cli_file_index, u8 *buffer, uword buffer_bytes)
 VLIB CLI output function. More...
 
static u8 unix_cli_terminal_type (u8 *term, uword len)
 Identify whether a terminal type is ANSI capable. More...
 
static void unix_cli_file_welcome (unix_cli_main_t *cm, unix_cli_file_t *cf)
 Emit initial welcome banner and prompt on a connection. More...
 
static void unix_cli_file_welcome_timer (any arg, f64 delay)
 A failsafe triggered on a timer to ensure we send the prompt to telnet sessions that fail to negotiate the terminal type. More...
 
static i32 unix_cli_process_telnet (unix_main_t *um, unix_cli_file_t *cf, unix_file_t *uf, u8 *input_vector, uword len)
 A mostly no-op Telnet state machine. More...
 
static int unix_cli_line_process_one (unix_cli_main_t *cm, unix_main_t *um, unix_cli_file_t *cf, unix_file_t *uf, u8 input, unix_cli_parse_action_t action)
 Process actionable input. More...
 
static int unix_cli_line_edit (unix_cli_main_t *cm, unix_main_t *um, unix_cli_file_t *cf)
 Process input bytes on a stream to provide line editing and command history in the CLI. More...
 
static void unix_cli_process_input (unix_cli_main_t *cm, uword cli_file_index)
 Process input to a CLI session. More...
 
static void unix_cli_kill (unix_cli_main_t *cm, uword cli_file_index)
 
static uword unix_cli_process (vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
 
static clib_error_tunix_cli_write_ready (unix_file_t *uf)
 
static clib_error_tunix_cli_read_ready (unix_file_t *uf)
 
static u32 unix_cli_file_add (unix_cli_main_t *cm, char *name, int fd)
 Store a new CLI session. More...
 
static clib_error_tunix_cli_listen_read_ready (unix_file_t *uf)
 Telnet listening socket has a new connection. More...
 
static void unix_cli_resize_interrupt (int signum)
 The system terminal has informed us that the window size has changed. More...
 
static clib_error_tunix_cli_config (vlib_main_t *vm, unformat_input_t *input)
 Handle configuration directives in the unix section. More...
 
static clib_error_tunix_cli_exit (vlib_main_t *vm)
 Called when VPP is shutting down, this resets the system terminal state, if previously saved. More...
 
void vlib_unix_cli_set_prompt (char *prompt)
 Set the CLI prompt. More...
 
static clib_error_tunix_cli_quit (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 CLI command to quit the terminal session. More...
 
static clib_error_tunix_cli_exec (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 CLI command to execute a VPP command script. More...
 
static clib_error_tunix_show_errors (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 CLI command to show various unix error statistics. More...
 
static clib_error_tunix_cli_show_history (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 CLI command to show session command history. More...
 
static clib_error_tunix_cli_show_terminal (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 CLI command to show terminal status. More...
 
static clib_error_tunix_cli_set_terminal_pager (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 CLI command to set terminal pager settings. More...
 
static clib_error_tunix_cli_set_terminal_history (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 CLI command to set terminal history settings. More...
 
static clib_error_tunix_cli_set_terminal_ansi (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 CLI command to set terminal ANSI settings. More...
 
static clib_error_tunix_cli_init (vlib_main_t *vm)
 

Variables

static unix_cli_banner_t unix_cli_banner []
 Plain welcome banner. More...
 
static unix_cli_banner_t unix_cli_banner_color []
 ANSI color welcome banner. More...
 
static unix_cli_parse_actions_t unix_cli_parse_strings []
 Patterns to match on a CLI input stream. More...
 
static unix_cli_parse_actions_t unix_cli_parse_pager []
 Patterns to match when a CLI session is in the pager. More...
 
static unix_cli_main_t unix_cli_main
 CLI global state. More...
 
vlib_cli_command_t unix_cli_quit_command
 (constructor) VLIB_CLI_COMMAND (unix_cli_quit_command) More...
 
vlib_cli_command_t cli_exec
 (constructor) VLIB_CLI_COMMAND (cli_exec) More...
 
vlib_cli_command_t cli_unix_show_errors
 (constructor) VLIB_CLI_COMMAND (cli_unix_show_errors) More...
 
vlib_cli_command_t cli_unix_cli_show_history
 (constructor) VLIB_CLI_COMMAND (cli_unix_cli_show_history) More...
 
vlib_cli_command_t cli_unix_cli_show_terminal
 (constructor) VLIB_CLI_COMMAND (cli_unix_cli_show_terminal) More...
 
vlib_cli_command_t cli_unix_cli_set_terminal_pager
 (constructor) VLIB_CLI_COMMAND (cli_unix_cli_set_terminal_pager) More...
 
vlib_cli_command_t cli_unix_cli_set_terminal_history
 (constructor) VLIB_CLI_COMMAND (cli_unix_cli_set_terminal_history) More...
 
vlib_cli_command_t cli_unix_cli_set_terminal_ansi
 (constructor) VLIB_CLI_COMMAND (cli_unix_cli_set_terminal_ansi) More...
 

Detailed Description

Unix stdin/socket command line interface.

Provides a command line interface so humans can interact with VPP. This is predominantly a debugging and testing mechanism.

Definition in file cli.c.

Macro Definition Documentation

#define ANSI_BOLD   CSI "1m"

ANSI Start bold text.

Definition at line 70 of file cli.c.

#define ANSI_BRED   ANSI_BOLD CSI "31m"

ANSI Start bright red text.

Definition at line 76 of file cli.c.

#define ANSI_CLEAR   CSI "2J" CSI "1;1H"

ANSI clear screen.

Definition at line 66 of file cli.c.

#define ANSI_CLEARLINE   CSI "2K"

ANSI clear line cursor is on.

Definition at line 78 of file cli.c.

#define ANSI_DIM   CSI "2m"

ANSI Stop bold text.

Definition at line 72 of file cli.c.

#define ANSI_DRED   ANSI_DIM CSI "31m"

ANSI Start dark red text.

Definition at line 74 of file cli.c.

#define ANSI_RESET   CSI "0m"

ANSI reset color settings.

Definition at line 68 of file cli.c.

#define ANSI_RESTCURSOR   CSI "u"

ANSI restore cursor position if previously saved.

Definition at line 84 of file cli.c.

#define ANSI_SAVECURSOR   CSI "s"

ANSI save cursor position.

Definition at line 82 of file cli.c.

#define ANSI_SCROLLDN   CSI "1T"

ANSI scroll screen down one line.

Definition at line 80 of file cli.c.

#define CSI   ESC "["

ANSI Control Sequence Introducer.

Definition at line 63 of file cli.c.

#define CTL (   c)    (u8[]){ (c) - '@', 0 }

Given a capital ASCII letter character return a NUL terminated string with the control code for that letter.

Parameters
cAn ASCII character.
Returns
A NUL terminated string of type u8[].
Example
CTL('A') returns { 0x01, 0x00 } as a u8[].

Definition at line 268 of file cli.c.

#define ESC   "\x1b"

ANSI escape code.

Definition at line 60 of file cli.c.

#define UNIX_CLI_MAX_DEPTH_TELNET   24

Maximum depth into a byte stream from which to compile a Telnet protocol message.

This is a saftey measure.

Definition at line 88 of file cli.c.

#define UNIX_CLI_STDIN_FD   0

Unix standard in.

Definition at line 91 of file cli.c.

Enumeration Type Documentation

CLI actions.

Enumerator
UNIX_CLI_PARSE_ACTION_NOACTION 

No action.

UNIX_CLI_PARSE_ACTION_CRLF 

Carriage return, newline or enter.

UNIX_CLI_PARSE_ACTION_TAB 

Tab key.

UNIX_CLI_PARSE_ACTION_ERASE 

Erase cursor left.

UNIX_CLI_PARSE_ACTION_ERASERIGHT 

Erase cursor right.

UNIX_CLI_PARSE_ACTION_UP 

Up arrow.

UNIX_CLI_PARSE_ACTION_DOWN 

Down arrow.

UNIX_CLI_PARSE_ACTION_LEFT 
UNIX_CLI_PARSE_ACTION_RIGHT 
UNIX_CLI_PARSE_ACTION_HOME 
UNIX_CLI_PARSE_ACTION_END 
UNIX_CLI_PARSE_ACTION_WORDLEFT 
UNIX_CLI_PARSE_ACTION_WORDRIGHT 
UNIX_CLI_PARSE_ACTION_ERASELINELEFT 
UNIX_CLI_PARSE_ACTION_ERASELINERIGHT 
UNIX_CLI_PARSE_ACTION_CLEAR 
UNIX_CLI_PARSE_ACTION_REVSEARCH 
UNIX_CLI_PARSE_ACTION_FWDSEARCH 
UNIX_CLI_PARSE_ACTION_YANK 
UNIX_CLI_PARSE_ACTION_TELNETIAC 
UNIX_CLI_PARSE_ACTION_PAGER_CRLF 
UNIX_CLI_PARSE_ACTION_PAGER_QUIT 
UNIX_CLI_PARSE_ACTION_PAGER_NEXT 
UNIX_CLI_PARSE_ACTION_PAGER_DN 
UNIX_CLI_PARSE_ACTION_PAGER_UP 
UNIX_CLI_PARSE_ACTION_PAGER_TOP 
UNIX_CLI_PARSE_ACTION_PAGER_BOTTOM 
UNIX_CLI_PARSE_ACTION_PAGER_PGDN 
UNIX_CLI_PARSE_ACTION_PAGER_PGUP 
UNIX_CLI_PARSE_ACTION_PAGER_SEARCH 
UNIX_CLI_PARSE_ACTION_PARTIALMATCH 
UNIX_CLI_PARSE_ACTION_NOMATCH 

Definition at line 212 of file cli.c.

CLI session events.

Enumerator
UNIX_CLI_PROCESS_EVENT_READ_READY 

A file descriptor has data to be read.

UNIX_CLI_PROCESS_EVENT_QUIT 

A CLI session wants to close.

Definition at line 375 of file cli.c.

Function Documentation

static void unix_cli_add_pending_output ( unix_file_t uf,
unix_cli_file_t cf,
u8 buffer,
uword  buffer_bytes 
)
static

Definition at line 461 of file cli.c.

+ Here is the caller graph for this function:

static void unix_cli_ansi_cursor ( unix_cli_file_t cf,
unix_file_t uf,
u16  x,
u16  y 
)
static

Uses an ANSI escape sequence to move the cursor.

Definition at line 664 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void unix_cli_cli_prompt ( unix_cli_file_t cf,
unix_file_t uf 
)
static

Output the CLI prompt.

Definition at line 602 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* unix_cli_config ( vlib_main_t vm,
unformat_input_t input 
)
static

Handle configuration directives in the unix section.

Definition at line 2051 of file cli.c.

+ Here is the call graph for this function:

static void unix_cli_del_pending_output ( unix_file_t uf,
unix_cli_file_t cf,
uword  n_bytes 
)
static

Definition at line 479 of file cli.c.

+ Here is the caller graph for this function:

static clib_error_t* unix_cli_exec ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

CLI command to execute a VPP command script.

Definition at line 2224 of file cli.c.

+ Here is the call graph for this function:

static clib_error_t* unix_cli_exit ( vlib_main_t vm)
static

Called when VPP is shutting down, this resets the system terminal state, if previously saved.

Definition at line 2171 of file cli.c.

static u32 unix_cli_file_add ( unix_cli_main_t cm,
char *  name,
int  fd 
)
static

Store a new CLI session.

Parameters
nameThe name of the session.
fdThe file descriptor for the session I/O.
Returns
The session ID.

Definition at line 1898 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline void unix_cli_file_free ( unix_cli_file_t f)

Release storage used by a CLI session.

Parameters
fThe CLI session whose storage needs to be released.

Definition at line 204 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void unix_cli_file_welcome ( unix_cli_main_t cm,
unix_cli_file_t cf 
)
static

Emit initial welcome banner and prompt on a connection.

Definition at line 778 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void unix_cli_file_welcome_timer ( any  arg,
f64  delay 
)
static

A failsafe triggered on a timer to ensure we send the prompt to telnet sessions that fail to negotiate the terminal type.

Definition at line 821 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* unix_cli_init ( vlib_main_t vm)
static

Definition at line 2551 of file cli.c.

+ Here is the caller graph for this function:

static void unix_cli_kill ( unix_cli_main_t cm,
uword  cli_file_index 
)
static

Definition at line 1765 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int unix_cli_line_edit ( unix_cli_main_t cm,
unix_main_t um,
unix_cli_file_t cf 
)
static

Process input bytes on a stream to provide line editing and command history in the CLI.

Definition at line 1594 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int unix_cli_line_process_one ( unix_cli_main_t cm,
unix_main_t um,
unix_cli_file_t cf,
unix_file_t uf,
u8  input,
unix_cli_parse_action_t  action 
)
static

Process actionable input.

Based on the action process the input; this typically involves searching the command history or editing the current command line.

Definition at line 964 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* unix_cli_listen_read_ready ( unix_file_t uf)
static

Telnet listening socket has a new connection.

Definition at line 1959 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static unix_cli_parse_action_t unix_cli_match_action ( unix_cli_parse_actions_t a,
u8 input,
u32  ilen,
i32 matched 
)
static

Search for a byte sequence in the action list.

Searches the unix_cli_parse_actions_t list in a for a match with the bytes in input of maximum length ilen bytes. When a match is made *matched indicates how many bytes were matched. Returns a value from the enum unix_cli_parse_action_t to indicate whether no match was found, a partial match was found or a complete match was found and what action, if any, should be taken.

Parameters
[in]aActions list to search within.
[in]inputString fragment to search for.
[in]ilenLength of the string in 'input'.
[out]matchedPointer to an integer that will contain the number of bytes matched when a complete match is found.
Returns
Action from unix_cli_parse_action_t that the string fragment matches. UNIX_CLI_PARSE_ACTION_PARTIALMATCH is returned when the whole input string matches the start of at least one action. UNIX_CLI_PARSE_ACTION_NOMATCH is returned when there is no match at all.

Definition at line 425 of file cli.c.

+ Here is the caller graph for this function:

static void unix_cli_pager_message ( unix_cli_file_t cf,
unix_file_t uf,
char *  message,
char *  postfix 
)
static

Output a pager "skipping" message.

Definition at line 627 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void unix_cli_pager_prompt ( unix_cli_file_t cf,
unix_file_t uf 
)
static

Output a pager prompt and show number of buffered lines.

Definition at line 610 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void unix_cli_pager_prompt_erase ( unix_cli_file_t cf,
unix_file_t uf 
)
static

Erase the printed pager prompt.

Definition at line 644 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline void unix_cli_pager_reset ( unix_cli_file_t f)

Resets the pager buffer and other data.

Parameters
fThe CLI session whose pager needs to be reset.

Definition at line 187 of file cli.c.

+ Here is the caller graph for this function:

static uword unix_cli_process ( vlib_main_t vm,
vlib_node_runtime_t rt,
vlib_frame_t f 
)
static

Definition at line 1794 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void unix_cli_process_input ( unix_cli_main_t cm,
uword  cli_file_index 
)
static

Process input to a CLI session.

Definition at line 1667 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static i32 unix_cli_process_telnet ( unix_main_t um,
unix_cli_file_t cf,
unix_file_t uf,
u8 input_vector,
uword  len 
)
static

A mostly no-op Telnet state machine.

Process Telnet command bytes in a way that ensures we're mostly transparent to the Telnet protocol. That is, it's mostly a no-op.

Returns
-1 if we need more bytes, otherwise a positive integer number of bytes to consume from the input_vector, not including the initial IAC byte.

Definition at line 845 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* unix_cli_quit ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

CLI command to quit the terminal session.

Note
If this is a stdin session then this will shutdown VPP also.

Definition at line 2203 of file cli.c.

+ Here is the call graph for this function:

static clib_error_t* unix_cli_read_ready ( unix_file_t uf)
static

Definition at line 1857 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void unix_cli_resize_interrupt ( int  signum)
static

The system terminal has informed us that the window size has changed.

Definition at line 2035 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* unix_cli_set_terminal_ansi ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

CLI command to set terminal ANSI settings.

Definition at line 2524 of file cli.c.

+ Here is the call graph for this function:

static clib_error_t* unix_cli_set_terminal_history ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

CLI command to set terminal history settings.

Definition at line 2475 of file cli.c.

+ Here is the call graph for this function:

static clib_error_t* unix_cli_set_terminal_pager ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

CLI command to set terminal pager settings.

Definition at line 2434 of file cli.c.

+ Here is the call graph for this function:

static clib_error_t* unix_cli_show_history ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

CLI command to show session command history.

Definition at line 2359 of file cli.c.

+ Here is the call graph for this function:

static clib_error_t* unix_cli_show_terminal ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

CLI command to show terminal status.

Definition at line 2391 of file cli.c.

+ Here is the call graph for this function:

static u8 unix_cli_terminal_type ( u8 term,
uword  len 
)
static

Identify whether a terminal type is ANSI capable.

Definition at line 760 of file cli.c.

+ Here is the caller graph for this function:

static clib_error_t* unix_cli_write_ready ( unix_file_t uf)
static

Definition at line 1836 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* unix_show_errors ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

CLI command to show various unix error statistics.

Definition at line 2290 of file cli.c.

+ Here is the call graph for this function:

static void unix_vlib_cli_output ( uword  cli_file_index,
u8 buffer,
uword  buffer_bytes 
)
static

VLIB CLI output function.

Definition at line 677 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void unix_vlib_cli_output_cooked ( unix_cli_file_t cf,
unix_file_t uf,
u8 buffer,
uword  buffer_bytes 
)
static

Process a buffer for CRLF handling before outputting it to the CLI.

Parameters
cfUnix CLI session of the desired stream to write to.
ufThe Unix file structure of the desired stream to write to.
bufferPointer to the buffer that needs to be written.
buffer_bytesThe number of bytes from buffer to write.

Definition at line 565 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void unix_vlib_cli_output_raw ( unix_cli_file_t cf,
unix_file_t uf,
u8 buffer,
uword  buffer_bytes 
)
static

Send a buffer to the CLI stream if possible, enqueue it otherwise.

Attempts to write given buffer to the file descriptor of the given Unix CLI session. If that session already has data in the output buffer or if the write attempt tells us to try again later then the given buffer is appended to the pending output buffer instead.

This is typically called only from unix_vlib_cli_output_cooked since that is where CRLF handling occurs or from places where we explicitly do not want cooked handling.

Parameters
cfUnix CLI session of the desired stream to write to.
ufThe Unix file structure of the desired stream to write to.
bufferPointer to the buffer that needs to be written.
buffer_bytesThe number of bytes from buffer to write.

Definition at line 535 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline word unix_vlib_findchr ( u8  chr,
u8 str,
word  len 
)

A bit like strchr with a buffer length limit.

Search a buffer for the first instance of a character up to the limit of the buffer length. If found then return the position of that character.

The key departure from strchr is that if the character is not found then return the buffer length.

Parameters
chrThe byte value to search for.
strThe buffer in which to search for the value.
lenThe depth into the buffer to search.
Returns
The index of the first occurence of chr. If chr is not found then len instead.

Definition at line 509 of file cli.c.

+ Here is the caller graph for this function:

void vlib_unix_cli_set_prompt ( char *  prompt)

Set the CLI prompt.

Parameters
TheC string to set the prompt to.
Note
This setting is global; it impacts all current and future CLI sessions.

Definition at line 2189 of file cli.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

Initial value:
= {
.path = "exec",
.short_help = "Execute commands from file",
.function = unix_cli_exec,
.is_mp_safe = 1,
}
static clib_error_t * unix_cli_exec(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to execute a VPP command script.
Definition: cli.c:2224

(constructor) VLIB_CLI_COMMAND (cli_exec)

Definition at line 2281 of file cli.c.

vlib_cli_command_t cli_unix_cli_set_terminal_ansi
Initial value:
= {
.path = "set terminal ansi",
.short_help = "set terminal ansi [on|off]",
}
static clib_error_t * unix_cli_set_terminal_ansi(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to set terminal ANSI settings.
Definition: cli.c:2524

(constructor) VLIB_CLI_COMMAND (cli_unix_cli_set_terminal_ansi)

Definition at line 2544 of file cli.c.

vlib_cli_command_t cli_unix_cli_set_terminal_history
Initial value:
= {
.path = "set terminal history",
.short_help = "set terminal history [on|off] [limit <lines>]",
}
static clib_error_t * unix_cli_set_terminal_history(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to set terminal history settings.
Definition: cli.c:2475

(constructor) VLIB_CLI_COMMAND (cli_unix_cli_set_terminal_history)

Definition at line 2516 of file cli.c.

vlib_cli_command_t cli_unix_cli_set_terminal_pager
Initial value:
= {
.path = "set terminal pager",
.short_help = "set terminal pager [on|off] [limit <lines>]",
}
static clib_error_t * unix_cli_set_terminal_pager(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to set terminal pager settings.
Definition: cli.c:2434

(constructor) VLIB_CLI_COMMAND (cli_unix_cli_set_terminal_pager)

Definition at line 2467 of file cli.c.

vlib_cli_command_t cli_unix_cli_show_history
Initial value:
= {
.path = "history",
.short_help = "Show current session command history",
.function = unix_cli_show_history,
}
static clib_error_t * unix_cli_show_history(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to show session command history.
Definition: cli.c:2359

(constructor) VLIB_CLI_COMMAND (cli_unix_cli_show_history)

Definition at line 2383 of file cli.c.

vlib_cli_command_t cli_unix_cli_show_terminal
Initial value:
= {
.path = "show terminal",
.short_help = "Show current session terminal settings",
}
static clib_error_t * unix_cli_show_terminal(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to show terminal status.
Definition: cli.c:2391

(constructor) VLIB_CLI_COMMAND (cli_unix_cli_show_terminal)

Definition at line 2426 of file cli.c.

vlib_cli_command_t cli_unix_show_errors
Initial value:
= {
.path = "show unix-errors",
.short_help = "Show Unix system call error history",
.function = unix_show_errors,
}
static clib_error_t * unix_show_errors(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to show various unix error statistics.
Definition: cli.c:2290

(constructor) VLIB_CLI_COMMAND (cli_unix_show_errors)

Definition at line 2351 of file cli.c.

unix_cli_banner_t unix_cli_banner[]
static
Initial value:
= {
_(" _______ _ _ _____ ___ \n"),
_(" __/ __/ _ \\ (_)__ | | / / _ \\/ _ \\\n"),
_(" _/ _// // / / / _ \\ | |/ / ___/ ___/\n"),
_(" /_/ /____(_)_/\\___/ |___/_/ /_/ \n"),
_("\n")
}

Plain welcome banner.

Definition at line 102 of file cli.c.

unix_cli_banner_t unix_cli_banner_color[]
static
Initial value:
= {
_(ANSI_BRED " _______ _ " ANSI_RESET " _ _____ ___ \n"),
_(ANSI_BRED " __/ __/ _ \\ (_)__ " ANSI_RESET " | | / / _ \\/ _ \\\n"),
_(ANSI_BRED " _/ _// // / / / _ \\" ANSI_RESET " | |/ / ___/ ___/\n"),
_(ANSI_BRED " /_/ /____(_)_/\\___/" ANSI_RESET " |___/_/ /_/ \n"),
_("\n")
}
#define ANSI_RESET
ANSI reset color settings.
Definition: cli.c:68
#define ANSI_BRED
ANSI Start bright red text.
Definition: cli.c:76

ANSI color welcome banner.

Definition at line 110 of file cli.c.

unix_cli_main_t unix_cli_main
static

CLI global state.

Definition at line 399 of file cli.c.

unix_cli_parse_actions_t unix_cli_parse_pager[]
static
Initial value:
= {
}
#define NULL
Definition: clib.h:55
#define CSI
ANSI Control Sequence Introducer.
Definition: cli.c:63
#define ESC
ANSI escape code.
Definition: cli.c:60

Patterns to match when a CLI session is in the pager.

Definition at line 337 of file cli.c.

unix_cli_parse_actions_t unix_cli_parse_strings[]
static
Initial value:
= {
}
Carriage return, newline or enter.
Definition: cli.c:214
#define NULL
Definition: clib.h:55
#define CSI
ANSI Control Sequence Introducer.
Definition: cli.c:63
Erase cursor left.
Definition: cli.c:216
Down arrow.
Definition: cli.c:219
#define CTL(c)
Given a capital ASCII letter character return a NUL terminated string with the control code for that ...
Definition: cli.c:268
#define ESC
ANSI escape code.
Definition: cli.c:60
Up arrow.
Definition: cli.c:218
Erase cursor right.
Definition: cli.c:217

Patterns to match on a CLI input stream.

Definition at line 275 of file cli.c.

vlib_cli_command_t unix_cli_quit_command
Initial value:
= {
.path = "quit",
.short_help = "Exit CLI",
.function = unix_cli_quit,
}
static clib_error_t * unix_cli_quit(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to quit the terminal session.
Definition: cli.c:2203

(constructor) VLIB_CLI_COMMAND (unix_cli_quit_command)

Definition at line 2216 of file cli.c.