58 #include <arpa/telnet.h> 59 #include <sys/ioctl.h> 60 #include <sys/types.h> 63 #include <netinet/tcp.h> 72 #define ANSI_CLEAR CSI "2J" CSI "1;1H" 74 #define ANSI_RESET CSI "0m" 76 #define ANSI_BOLD CSI "1m" 78 #define ANSI_DIM CSI "2m" 80 #define ANSI_DRED ANSI_DIM CSI "31m" 82 #define ANSI_BRED ANSI_BOLD CSI "31m" 84 #define ANSI_CLEARLINE CSI "2K" 86 #define ANSI_SCROLLDN CSI "1T" 88 #define ANSI_SAVECURSOR CSI "s" 90 #define ANSI_RESTCURSOR CSI "u" 94 #define UNIX_CLI_MAX_DEPTH_TELNET 24 97 #define UNIX_CLI_MAX_TERMINAL_WIDTH 512 99 #define UNIX_CLI_MAX_TERMINAL_HEIGHT 512 101 #define UNIX_CLI_DEFAULT_TERMINAL_HEIGHT 24 103 #define UNIX_CLI_DEFAULT_TERMINAL_WIDTH 80 112 #define _(a) { .line = (u8 *)(a), .length = sizeof(a) - 1 } 115 _(
" _______ _ _ _____ ___ \n"),
116 _(
" __/ __/ _ \\ (_)__ | | / / _ \\/ _ \\\n"),
117 _(
" _/ _// // / / / _ \\ | |/ / ___/ ___/\n"),
118 _(
" /_/ /____(_)_/\\___/ |___/_/ /_/ \n"),
125 _(
ANSI_BRED " __/ __/ _ \\ (_)__ " ANSI_RESET
" | | / / _ \\/ _ \\\n"),
126 _(
ANSI_BRED " _/ _// // / / / _ \\" ANSI_RESET
" | |/ / ___/ ___/\n"),
127 _(
ANSI_BRED " /_/ /____(_)_/\\___/" ANSI_RESET
" |___/_/ /_/ \n"),
338 #define CTL(c) (u8[]){ (c) - '@', 0 } 340 #define _(a,b) { .input = (u8 *)(a), .len = sizeof(a) - 1, .action = (b) } 501 u8 * input,
u32 ilen,
i32 * matched)
511 if (memcmp (input, a->
input, a->
len) == 0)
521 if (memcmp (input, a->
input, ilen) == 0)
540 u8 * buffer,
uword buffer_bytes)
591 for (i = 0; i <
len; i++, str++)
632 if (n < 0 && errno != EAGAIN)
648 else if ((
word) n < (
word) buffer_bytes)
668 u8 * buffer,
uword buffer_bytes)
670 word end = 0, start = 0;
672 while (end < buffer_bytes)
679 buffer_bytes - start) + start;
691 if (end < buffer_bytes)
701 if (buffer_bytes > 0)
786 prompt =
format (0,
"\r%s-- more -- (%d-%d/%d)%s",
801 char *message,
char *postfix)
805 prompt =
format (0,
"\r%s-- %s --%s%s",
830 for (i = 0; i < cf->
width - 1; i++)
878 for (i = 0; i < cf->
height - 1 &&
887 if (pi && line[pi->
length - 1] !=
'\n')
926 line_index = len_or_index;
950 if (j < l && p[j] ==
'\n')
958 pi->
line = line_index;
979 word i, old_line, old_offset;
1010 if (pi->
line == old_line &&
1079 if (row < cf->height - 1)
1088 if (line[pi->
length - 1] !=
'\n' && row == cf->
height - 2)
1142 if (strncasecmp(a, (char *)term, (size_t)len) == 0) return 1; \ 1147 _(
"xterm-256color");
1149 _(
"screen-256color");
1174 if (strncasecmp(a, (char *)term, (size_t)len) == 0) return 1; \ 1223 len =
ARRAY_LEN (unix_cli_banner_color);
1231 for (i = 0; i <
len; i++)
1234 banner[i].line, banner[i].length);
1284 switch (input_vector[1])
1310 if (input_vector[i - 1] == IAC && input_vector[i] == SE)
1313 switch (input_vector[2])
1316 if (input_vector[3] != 0)
1320 u8 *term = input_vector + 4;
1344 clib_net_to_host_u16 (*((
u16 *) (input_vector + 3)));
1351 clib_net_to_host_u16 (*((
u16 *) (input_vector + 5)));
1372 if (i == UNIX_CLI_MAX_DEPTH_TELNET)
1425 u8 **possible_commands;
1736 else if (input ==
'D' -
'@')
1795 if (
vec_len (possible_commands) == 1)
1797 u8 *completed = possible_commands[0];
1826 else if (
vec_len (possible_commands) >= 2)
1828 u8 **possible_command;
1829 uword max_command_len = 0, min_command_len = ~0;
1834 if (
vec_len (*possible_command) > max_command_len)
1835 max_command_len =
vec_len (*possible_command);
1836 if (
vec_len (*possible_command) < min_command_len)
1837 min_command_len =
vec_len (*possible_command);
1845 if (i + max_command_len >= cf->
width)
1852 for (j =
vec_len (*possible_command); j < max_command_len + 2;
1857 i += max_command_len + 2;
1877 for (; i < min_command_len; i++)
1886 common = (*possible_command)[
i];
1888 else if (common != (*possible_command)[i])
1956 if (pi && line[pi->
length - 1] !=
'\n')
1982 if (line[pi->
length - 1] !=
'\n')
2033 if (pi && line[pi->
length - 1] !=
'\n')
2058 if (pi && line[pi->
length - 1] !=
'\n')
2081 if (pi && line[pi->
length - 1] !=
'\n')
2109 if (pi && line[pi->
length - 1] !=
'\n')
2190 for (offset = 0; offset <=
vec_len (item) - limit; offset++)
2192 for (k = 0; k < limit; k++)
2197 goto found_at_offset;
2232 else if (isprint (input))
2259 for (; j > 0; j--, cf->
cursor--)
2404 lv =
format (lv,
"%U[%d]: %v",
2408 int rv __attribute__ ((unused)) = write (um->
log_fd, lv,
vec_len (lv));
2535 for (i = 0; i <
vec_len (data); i++)
2541 for (i = 0; i <
vec_len (data); i++)
2547 _vec_len (data) = 0;
2581 if (n < 0 && errno != EAGAIN)
2612 int n, n_read, n_try;
2625 if (n < 0 && errno != EAGAIN)
2628 n_read = n < 0 ? 0 : n;
2677 file_desc =
format (0,
"%s", name);
2679 name = (
char *)
format (0,
"unix-cli-%s", name);
2697 if (this_vlib_main == 0)
2715 .process_log2_n_stack_bytes = 16,
2736 template.file_descriptor = fd;
2738 template.description = file_desc;
2775 (void) setsockopt (client.fd, IPPROTO_TCP, TCP_NODELAY,
2776 (
void *) &one,
sizeof (one));
2795 u8 charmode_option[] = {
2796 IAC, WONT, TELOPT_LINEMODE,
2797 IAC, DONT, TELOPT_LINEMODE,
2798 IAC, WILL, TELOPT_SGA,
2799 IAC, DO, TELOPT_SGA,
2800 IAC, WILL, TELOPT_ECHO,
2801 IAC, DONT, TELOPT_ECHO,
2802 IAC, DO, TELOPT_TTYPE,
2803 IAC, SB, TELOPT_TTYPE, 1, IAC, SE,
2804 IAC, DO, TELOPT_NAWS,
2805 IAC, SB, TELOPT_NAWS, 1, IAC, SE,
2858 if (ioctl (STDIN_FILENO, TIOCGWINSZ, &ws) < 0)
2866 cf->
width = ws.ws_col;
2897 struct sigaction sa;
2908 if ((flags = fcntl (STDIN_FILENO, F_GETFL, 0)) < 0)
2910 (void) fcntl (STDIN_FILENO, F_SETFL, flags | O_NONBLOCK);
2923 if (sigaction (SIGWINCH, &sa, 0) < 0)
2927 ioctl (STDIN_FILENO, TIOCGWINSZ, &ws);
2928 cf->
width = ws.ws_col;
2955 tcgetattr (STDIN_FILENO, &um->
tio_stdin);
2961 tio.c_lflag &= ~(ECHO | ICANON | IEXTEN);
2963 tio.c_iflag &= ~(IXON | IXOFF);
2965 tio.c_cc[VTIME] = 0;
2966 tio.c_cc[VSTOP] = _POSIX_VDISABLE;
2967 tio.c_cc[VSTART] = _POSIX_VDISABLE;
2968 tcsetattr (STDIN_FILENO, TCSAFLUSH, &tio);
2971 term = (
u8 *) getenv (
"TERM");
2974 int len = strlen ((
char *) term);
2992 if (s->config && s->config[0] != 0)
2998 if (strncmp (s->config,
"/run", 4) == 0)
3000 u8 *tmp =
format (0,
"%s", s->config);
3002 while (i && tmp[--i] !=
'/')
3020 template.file_descriptor = s->fd;
3021 template.description =
format (0,
"cli listener %s", s->config);
3047 if (isatty (STDIN_FILENO) && um->
tio_isset)
3048 tcsetattr (STDIN_FILENO, TCSAFLUSH, &um->
tio_stdin);
3063 char *fmt = (prompt[strlen (prompt) - 1] ==
' ') ?
"%s" :
"%s ";
3102 .short_help =
"Exit CLI",
3110 .short_help =
"Exit CLI",
3129 if (!
unformat (input,
"%s", &file_name))
3136 fd = open (file_name, O_RDONLY);
3147 if (fstat (fd, &s) < 0)
3153 if (!(S_ISREG (s.st_mode) || S_ISLNK (s.st_mode)))
3199 .short_help =
"exec <filename>",
3212 int i, n_errors_to_show;
3215 n_errors_to_show = 1 << 30;
3219 if (!
unformat (input,
"%d", &n_errors_to_show))
3223 "expecting integer number of errors to show, got `%U'",
3236 while (n_errors_to_show > 0)
3244 n_errors_to_show -= 1;
3251 if (
vec_len (unix_errors) == 0)
3256 for (i =
vec_len (unix_errors) - 1; i >= 0; i--)
3274 .path =
"show unix errors",
3275 .short_help =
"Show Unix system call error history",
3288 char path[PATH_MAX];
3291 vlib_cli_output (vm,
"%3s %6s %12s %12s %12s %-32s %s",
"FD",
"Thread",
3292 "Read",
"Write",
"Error",
"File Name",
"Description");
3298 s = format (s,
"/proc/self/fd/%d%c", f->file_descriptor, 0);
3299 rv = readlink((char *) s, path, PATH_MAX - 1);
3301 path[rv < 0 ? 0 : rv] = 0;
3303 vlib_cli_output (vm,
"%3d %6d %12d %12d %12d %-32s %v",
3304 f->file_descriptor, f->polling_thread_index,
3305 f->read_events, f->write_events, f->error_events,
3306 path, f->description);
3307 vec_reset_length (s);
3317 .path =
"show unix files",
3318 .short_help =
"Show Unix files in use",
3357 .short_help =
"Show current session command history",
3377 "line-by-line" :
"char-by-char");
3387 " (disabled by history limit)");
3393 || cf->
height ?
"" :
" (disabled by terminal height)",
3396 " (disabled by buffer limit)");
3426 .path =
"show terminal",
3427 .short_help =
"Show current session terminal settings",
3444 vlib_cli_output (vm,
"%-5s %-5s %-20s %s",
"PNI",
"FD",
"Name",
"Flags");
3446 #define fl(x, y) ( (x) ? toupper((y)) : tolower((y)) ) 3449 uf = pool_elt_at_index (fm->file_pool, cf->clib_file_index);
3450 n = vlib_get_node (vm, cf->process_node_index);
3451 vlib_cli_output (vm,
3452 "%-5d %-5d %-20v %c%c%c%c%c\n",
3453 cf->process_node_index,
3454 uf->file_descriptor,
3456 fl (cf->is_interactive,
'i'),
3457 fl (cf->is_socket,
's'),
3458 fl (cf->line_mode,
'l'),
3459 fl (cf->has_epipe,
'p'),
3460 fl (cf->ansi_capable,
'a'));
3506 .path =
"show cli-sessions",
3507 .short_help =
"Show current CLI sessions",
3536 else if (
unformat (line_input,
"off"))
3540 "Pager limit set to %u lines; note, this is global.\n",
3565 .path =
"set terminal pager",
3566 .short_help =
"set terminal pager [on|off] [limit <lines>]",
3595 else if (
unformat (line_input,
"off"))
3631 .path =
"set terminal history",
3632 .short_help =
"set terminal history [on|off] [limit <lines>]",
3672 .path =
"set terminal ansi",
3673 .short_help =
"set terminal ansi [on|off]",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u32 history_limit
Maximum number of history entries this session will store.
u32 command_number
Current command line counter.
uword output_function_arg
#define vec_foreach_index(var, v)
Iterate over vector indices.
u8 * format_clib_error(u8 *s, va_list *va)
static void clib_file_del(clib_file_main_t *um, clib_file_t *f)
static void unix_cli_ansi_cursor(unix_cli_file_t *cf, clib_file_t *uf, u16 x, u16 y)
Uses an ANSI escape sequence to move the cursor.
#define UNIX_CLI_MAX_DEPTH_TELNET
Maximum depth into a byte stream from which to compile a Telnet protocol message. ...
static clib_error_t * unix_cli_error_detected(clib_file_t *uf)
Called when a CLI session file descriptor has an error condition.
u8 is_interactive
Whether the session is interactive or not.
u32 pager_start
Line number of top of page.
static void unix_vlib_cli_output_raw(unix_cli_file_t *cf, clib_file_t *uf, u8 *buffer, uword buffer_bytes)
Send a buffer to the CLI stream if possible, enqueue it otherwise.
Action parser found a partial match.
Carriage return, newline or enter.
Search forwards in command history.
static u8 unix_cli_terminal_type_noninteractive(u8 *term, uword len)
Identify whether a terminal type is non-interactive.
unix_cli_process_event_type_t
CLI session events.
u8 * input_vector
Vector of input saved by Unix input node to be processed by CLI process.
static void unix_cli_pager_message(unix_cli_file_t *cf, clib_file_t *uf, char *message, char *postfix)
Output a pager "skipping" message.
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
static void unix_cli_del_pending_output(clib_file_t *uf, unix_cli_file_t *cf, uword n_bytes)
Delete all bytes from the output vector and flag the I/O system that no more bytes are available to b...
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.
static uword vlib_current_process(vlib_main_t *vm)
#define CTL(c)
Given a capital ASCII letter character return a NUL terminated string with the control code for that ...
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.
u8 * line
The line to print.
u8 * cli_prompt
Prompt string for CLI.
#define UNIX_CLI_DEFAULT_TERMINAL_WIDTH
Default terminal width.
static void unix_cli_set_session_noninteractive(unix_cli_file_t *cf)
Set a session to be non-interactive.
u32 cli_pager_buffer_limit
static clib_error_t * unix_show_files(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to show various unix error statistics.
u8 ** command_history
Array of vectors of commands in the history.
static void unix_vlib_cli_output(uword cli_file_index, u8 *buffer, uword buffer_bytes)
VLIB CLI output function.
static f64 vlib_time_now(vlib_main_t *vm)
void vlib_unix_cli_set_prompt(char *prompt)
Set the CLI prompt.
static void unix_cli_pager_redraw(unix_cli_file_t *cf, clib_file_t *uf)
Redraw the currently displayed page of text.
static void unix_cli_file_free(unix_cli_file_t *f)
Release storage used by a CLI session.
static u32 unix_cli_file_add(unix_cli_main_t *cm, char *name, int fd)
Store a new CLI session.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
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.
unix_cli_pager_index_t * pager_index
Index of line fragments in the pager buffer.
u8 * current_command
The command currently pointed at by the history cursor.
clib_error_t * clib_socket_init(clib_socket_t *s)
#define VLIB_MAIN_LOOP_EXIT_CLI
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
#define vlib_call_config_function(vm, x)
void clib_longjmp(clib_longjmp_t *save, uword return_value)
static clib_error_t * unix_cli_listen_read_ready(clib_file_t *uf)
Telnet listening socket has a new connection.
#define UNIX_CLI_MAX_TERMINAL_WIDTH
Maximum terminal width we will accept.
u32 cursor
Position of the insert cursor on the current input line.
clib_socket_t cli_listen_socket
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
vlib_main_t ** vlib_mains
unix_cli_parse_action_t action
Action to take when matched.
static clib_error_t * unix_cli_init(vlib_main_t *vm)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define vlib_worker_thread_barrier_sync(X)
#define clib_memcpy(d, s, n)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
#define CLIB_SOCKET_F_IS_SERVER
u8 has_epipe
If EPIPE has been detected, prevent further write-related activity on the descriptor.
u8 ansi_capable
Can we do ANSI output?
static void unix_cli_pager_reindex(unix_cli_file_t *cf)
Reindex entire pager buffer.
A CLI session wants to close.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
void vlib_worker_thread_node_runtime_update(void)
u8 * output_vector
Vector of output pending write to file descriptor.
#define VLIB_INIT_FUNCTION(x)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
End key (jump to end of line)
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
u8 is_socket
Whether the session is attached to a socket.
Jump cursor to start of right word.
u32 len
Length of input without final NUL.
Mapping of input buffer strings to action values.
vlib_parse_match_t vlib_parse_eval(u8 *input)
#define UNIX_CLI_DEFAULT_TERMINAL_HEIGHT
Default terminal height.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
#define ANSI_SCROLLDN
ANSI scroll screen down one line.
clib_file_main_t file_main
u32 process_node_index
Process node identifier.
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
Erase line to right & including cursor.
#define ANSI_CLEARLINE
ANSI clear line cursor is on.
static void unix_vlib_cli_output_cursor_left(unix_cli_file_t *cf, clib_file_t *uf)
Moves the terminal cursor one character to the left, with special handling when it reaches the left e...
static i32 unix_cli_process_telnet(unix_main_t *um, unix_cli_file_t *cf, clib_file_t *uf, u8 *input_vector, uword len)
A mostly no-op Telnet state machine.
u32 * unused_cli_process_node_indices
Vec pool of unused session indices.
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.
static void unix_cli_pager_prompt(unix_cli_file_t *cf, clib_file_t *uf)
Output a pager prompt and show number of buffered lines.
unix_cli_file_t * cli_file_pool
Vec pool of CLI sessions.
int search_mode
If non-zero then the CLI is searching in the history array.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define ANSI_RESTCURSOR
ANSI restore cursor position if previously saved.
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
static void unix_cli_pager_reset(unix_cli_file_t *f)
Resets the pager buffer and other data.
u8 ** vlib_cli_get_possible_completions(u8 *str)
#define clib_error_return_unix(e, args...)
static u8 unix_cli_terminal_type_ansi(u8 *term, uword len)
Identify whether a terminal type is ANSI capable.
Home key (jump to start of line)
#define pool_put(P, E)
Free an object E in pool P.
static clib_error_t * unix_cli_read_ready(clib_file_t *uf)
Called when a CLI session file descriptor has data to be read.
#define ANSI_BOLD
ANSI Start bold text.
static unix_cli_banner_t unix_cli_banner[]
Plain welcome banner.
void timer_call(timer_func_t *func, any arg, f64 dt)
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.
#define VLIB_CONFIG_FUNCTION(x, n,...)
Search backwards in command history.
u8 * input
Input string to match.
void(* file_update)(clib_file_t *file, clib_file_update_type_t update_type)
u32 node_index
Node index.
static void unix_cli_cli_prompt(unix_cli_file_t *cf, clib_file_t *uf)
Output the CLI prompt.
Erase line to left of cursor.
#define CSI
ANSI Control Sequence Introducer.
u8 ** pager_vector
Pager buffer.
unix_error_history_t error_history[128]
static void unix_vlib_cli_output_cooked(unix_cli_file_t *cf, clib_file_t *uf, u8 *buffer, uword buffer_bytes)
Process a buffer for CRLF handling before outputting it to the CLI.
static unix_cli_banner_t unix_cli_banner_color[]
ANSI color welcome banner.
u32 current_input_file_index
File pool index of current input.
#define vec_free(V)
Free vector's memory (no header).
#define VLIB_MAIN_LOOP_EXIT_FUNCTION(x)
static clib_error_t * unix_cli_write_ready(clib_file_t *uf)
Called when a CLI session file descriptor can be written to without blocking.
#define ANSI_SAVECURSOR
ANSI save cursor position.
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.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
A file descriptor has data to be read.
#define ESC
ANSI escape code.
Jump cursor to start of left word.
u8 no_pager
Disable the pager?
#define VLIB_CLI_COMMAND(x,...)
Enter pressed (CR, CRLF, LF, etc)
static void unix_cli_kill(unix_cli_main_t *cm, uword cli_file_index)
Destroy a CLI session.
#define vec_delete(V, N, M)
Delete N elements starting at element M.
static word unix_vlib_findchr(u8 chr, u8 *str, word len)
A bit like strchr with a buffer length limit.
unix_cli_parse_action_t
CLI actions.
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
u32 vlib_register_node(vlib_main_t *vm, vlib_node_registration_t *r)
#define UNIX_FLAG_INTERACTIVE
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.
static clib_error_t * unix_cli_config(vlib_main_t *vm, unformat_input_t *input)
Handle configuration directives in the unix section.
#define vec_append(v1, v2)
Append v2 after v1.
struct _socket_t clib_socket_t
static int unix_cli_line_process_one(unix_cli_main_t *cm, unix_main_t *um, unix_cli_file_t *cf, clib_file_t *uf, u8 input, unix_cli_parse_action_t action)
Process actionable input.
#define UNIX_FILE_DATA_AVAILABLE_TO_WRITE
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
u8 has_history
This session has command history.
#define ANSI_CLEAR
ANSI clear screen.
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.
static void clib_socket_free(clib_socket_t *s)
Action parser did not find any match.
u8 started
Has the session started?
struct _vlib_node_registration vlib_node_registration_t
clib_error_t * vlib_unix_recursive_mkdir(char *path)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define ANSI_BRED
ANSI Start bright red text.
u8 * search_key
The string being searched for in the history.
#define clib_unix_warning(format, args...)
static uword unix_cli_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Handle system events.
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.
static clib_error_t * unix_config(vlib_main_t *vm, unformat_input_t *input)
struct clib_bihash_value offset
template key/value backing page structure
static vlib_process_t * vlib_get_process_from_node(vlib_main_t *vm, vlib_node_t *node)
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
static void unix_cli_pager_prompt_erase(unix_cli_file_t *cf, clib_file_t *uf)
Erase the printed pager prompt.
static void unix_cli_resize_interrupt(int signum)
The system terminal has informed us that the window size has changed.
Clear and redraw the page on the terminal.
static int unix_cli_line_edit(unix_cli_main_t *cm, unix_main_t *um, clib_file_main_t *fm, unix_cli_file_t *cf)
Process input bytes on a stream to provide line editing and command history in the CLI...
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
#define vec_foreach(var, vec)
Vector iterator.
u8 cursor_direction
The current direction of cursor travel.
u8 crlf_mode
Set if the CRLF mode wants CR + LF.
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.
#define ANSI_RESET
ANSI reset color settings.
clib_longjmp_t main_loop_exit
vlib_cli_output_function_t * output_function
u32 clib_file_index
The file index held by unix.c.
static unix_cli_main_t unix_cli_main
CLI global state.
#define CLIB_SOCKET_F_ALLOW_GROUP_WRITE
i32 excursion
How far from the end of the history array the user has browsed.
void vlib_start_process(vlib_main_t *vm, uword process_index)
u8 line_mode
Line mode or char mode.
u32 length
The length of the line without terminating NUL.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u32 stdin_cli_file_index
The session index of the stdin cli.
static void unix_cli_add_pending_output(clib_file_t *uf, unix_cli_file_t *cf, u8 *buffer, uword buffer_bytes)
Add bytes to the output vector and then flagg the I/O system that bytes are available to be sent...
static clib_error_t * unix_cli_show_cli_sessions(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to display a list of CLI sessions.
static void unix_cli_pager_add_line(unix_cli_file_t *cf, u8 *line, word len_or_index)
Process and add a line to the pager index.
#define clib_panic(format, args...)
#define UNIX_CLI_MAX_TERMINAL_HEIGHT
Maximum terminal height we will accept.
u32 height
Terminal height.
static clib_error_t * unix_cli_exit(vlib_main_t *vm)
Called when VPP is shutting down, this restores the system terminal state if previously saved...
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 negotiat...
static void unix_cli_process_input(unix_cli_main_t *cm, uword cli_file_index)
Process input to a CLI session.
static unix_cli_parse_actions_t unix_cli_parse_strings[]
Patterns to match on a CLI input stream.