|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
57 #include <arpa/telnet.h>
58 #include <sys/ioctl.h>
59 #include <sys/types.h>
62 #include <netinet/tcp.h>
73 #define ANSI_CLEAR CSI "2J" CSI "1;1H"
75 #define ANSI_RESET CSI "0m"
77 #define ANSI_BOLD CSI "1m"
79 #define ANSI_DIM CSI "2m"
81 #define ANSI_DRED ANSI_DIM CSI "31m"
83 #define ANSI_BRED ANSI_BOLD CSI "31m"
85 #define ANSI_CLEARLINE CSI "2K"
87 #define ANSI_SCROLLDN CSI "1T"
89 #define ANSI_SAVECURSOR CSI "s"
91 #define ANSI_RESTCURSOR CSI "u"
95 #define UNIX_CLI_MAX_DEPTH_TELNET 32
98 #define UNIX_CLI_MAX_TERMINAL_WIDTH 512
100 #define UNIX_CLI_MAX_TERMINAL_HEIGHT 512
102 #define UNIX_CLI_DEFAULT_TERMINAL_HEIGHT 24
104 #define UNIX_CLI_DEFAULT_TERMINAL_WIDTH 80
113 #define _(a) { .line = (u8 *)(a), .length = sizeof(a) - 1 }
116 _(
" _______ _ _ _____ ___ \n"),
117 _(
" __/ __/ _ \\ (_)__ | | / / _ \\/ _ \\\n"),
118 _(
" _/ _// // / / / _ \\ | |/ / ___/ ___/\n"),
119 _(
" /_/ /____(_)_/\\___/ |___/_/ /_/ \n"),
342 #define CTL(c) (u8[]){ (c) - '@', 0 }
344 #define _(a,b) { .input = (u8 *)(a), .len = sizeof(a) - 1, .action = (b) }
510 return (&
cm->macro_main);
542 u8 * input,
u32 ilen,
i32 * matched)
552 if (memcmp (input,
a->input,
a->len) == 0)
562 if (memcmp (input,
a->input, ilen) == 0)
632 for (
i = 0;
i <
len;
i++, str++)
673 if (n < 0 && errno != EAGAIN)
689 else if ((
word) n < (
word) buffer_bytes)
713 while (
end < buffer_bytes)
720 buffer_bytes - start) + start;
732 if (
end < buffer_bytes)
742 if (buffer_bytes > 0)
827 prompt =
format (0,
"\r%s-- more -- (%d-%d/%d)%s",
842 char *message,
char *postfix)
846 prompt =
format (0,
"\r%s-- %s --%s%s",
928 if (pi && line[pi->
length - 1] !=
'\n')
967 line_index = len_or_index;
991 if (j < l && p[j] ==
'\n')
999 pi->
line = line_index;
1020 word i, old_line, old_offset;
1036 old_line = pi->
line;
1051 if (pi->
line == old_line &&
1120 if (row < cf->height - 1)
1129 if (line[pi->
length - 1] !=
'\n' && row == cf->
height - 2)
1183 if (strncasecmp(a, (char *)term, (size_t)len) == 0) return 1; \
1188 _(
"xterm-256color");
1190 _(
"screen-256color");
1215 if (strncasecmp(a, (char *)term, (size_t)len) == 0) return 1; \
1272 for (
i = 0;
i <
len;
i++)
1293 uword event_type, *event_data = 0;
1326 clib_warning (
"BUG: unknown event type 0x%wx", event_type);
1409 switch (input_vector[1])
1435 if (input_vector[
i - 1] == IAC && input_vector[
i] == SE)
1438 switch (input_vector[2])
1441 if (input_vector[3] != 0)
1445 u8 *term = input_vector + 4;
1469 clib_net_to_host_u16 (*((
u16 *) (input_vector + 3)));
1476 clib_net_to_host_u16 (*((
u16 *) (input_vector + 5)));
1550 u8 **possible_commands;
1642 while (cf->
cursor > delta
1645 while (cf->
cursor > delta
1654 for (j = delta; j > 0; j--, cf->
cursor--)
1670 for (j = delta; j > 0; j--, cf->
cursor--)
1672 for (j = delta; j > 0; j--, cf->
cursor++)
1906 else if (input ==
'D' -
'@')
1913 cf -
cm->cli_file_pool);
1965 if (
vec_len (possible_commands) == 1)
1967 u8 *completed = possible_commands[0];
1996 else if (
vec_len (possible_commands) >= 2)
1998 u8 **possible_command;
1999 uword max_command_len = 0, min_command_len = ~0;
2004 if (
vec_len (*possible_command) > max_command_len)
2005 max_command_len =
vec_len (*possible_command);
2006 if (
vec_len (*possible_command) < min_command_len)
2007 min_command_len =
vec_len (*possible_command);
2015 if (
i + max_command_len >= cf->
width)
2022 for (j =
vec_len (*possible_command); j < max_command_len + 2;
2027 i += max_command_len + 2;
2047 for (;
i < min_command_len;
i++)
2056 common = (*possible_command)[
i];
2058 else if (common != (*possible_command)[
i])
2126 if (pi && line[pi->
length - 1] !=
'\n')
2152 if (line[pi->
length - 1] !=
'\n')
2203 if (pi && line[pi->
length - 1] !=
'\n')
2228 if (pi && line[pi->
length - 1] !=
'\n')
2251 if (pi && line[pi->
length - 1] !=
'\n')
2279 if (pi && line[pi->
length - 1] !=
'\n')
2362 for (k = 0; k < limit; k++)
2367 goto found_at_offset;
2402 else if (isprint (input))
2429 for (; j > 0; j--, cf->
cursor--)
2550 cm->current_input_file_index = cli_file_index;
2575 lv =
format (lv,
"%U[%d]: %v",
2582 int rv __attribute__ ((unused)) = write (um->
log_fd, lv,
vec_len (lv));
2598 _vec_len (expanded) -= 1;
2694 if (ns->
cf_index == cli_file_index)
2753 _vec_len (
data) = 0;
2762 vec_add1 (
cm->unused_cli_process_node_indices,
rt->node_index);
2787 if (n < 0 && errno != EAGAIN)
2818 int n, n_read, n_try;
2831 if (n < 0 && errno != EAGAIN)
2834 n_read = n < 0 ? 0 : n;
2888 if (
vec_len (
cm->unused_cli_process_node_indices) > 0)
2904 if (this_vlib_main == 0)
2907 cm->unused_cli_process_node_indices[l - 1]);
2917 _vec_len (
cm->unused_cli_process_node_indices) = l - 1;
2924 .process_log2_n_stack_bytes = 18,
2946 template.file_descriptor = fd;
2947 template.private_data = cf -
cm->cli_file_pool;
2948 template.description = file_desc;
2963 return cf -
cm->cli_file_pool;
2987 (void) setsockopt (client.fd, IPPROTO_TCP, TCP_NODELAY,
2988 (
void *) &one,
sizeof (one));
3007 u8 charmode_option[] = {
3008 IAC, WONT, TELOPT_LINEMODE,
3009 IAC, DONT, TELOPT_LINEMODE,
3010 IAC, WILL, TELOPT_SGA,
3011 IAC, DO, TELOPT_SGA,
3012 IAC, WILL, TELOPT_ECHO,
3013 IAC, DONT, TELOPT_ECHO,
3014 IAC, DO, TELOPT_TTYPE,
3015 IAC, SB, TELOPT_TTYPE, 1, IAC, SE,
3016 IAC, DO, TELOPT_NAWS,
3017 IAC, SB, TELOPT_NAWS, 1, IAC, SE,
3047 if (
cm->new_session_process_node_index == ~0)
3050 cm->new_session_process_node_index =
3060 cm->new_session_process_node_index,
3077 cm->stdin_cli_file_index);
3083 if (ioctl (STDIN_FILENO, TIOCGWINSZ, &ws) < 0)
3091 cf->
width = ws.ws_col;
3122 struct sigaction sa;
3133 if ((
flags = fcntl (STDIN_FILENO, F_GETFL, 0)) < 0)
3135 (void) fcntl (STDIN_FILENO, F_SETFL,
flags | O_NONBLOCK);
3139 cm->stdin_cli_file_index = cf_index;
3148 if (sigaction (SIGWINCH, &sa, 0) < 0)
3152 if (ioctl (STDIN_FILENO, TIOCGWINSZ, &ws) == 0)
3154 cf->
width = ws.ws_col;
3182 tcgetattr (STDIN_FILENO, &um->
tio_stdin);
3188 tio.c_lflag &= ~(ECHO | ICANON | IEXTEN);
3190 tio.c_iflag &= ~(IXON | IXOFF);
3192 tio.c_cc[VTIME] = 0;
3193 tio.c_cc[VSTOP] = _POSIX_VDISABLE;
3194 tio.c_cc[VSTART] = _POSIX_VDISABLE;
3195 tcsetattr (STDIN_FILENO, TCSAFLUSH, &tio);
3198 term = (
u8 *) getenv (
"TERM");
3201 int len = strlen ((
char *) term);
3219 if (s->config && s->config[0] != 0)
3225 if (strncmp (s->config,
"/run", 4) == 0)
3229 while (
i &&
tmp[--
i] !=
'/')
3247 template.file_descriptor = s->fd;
3248 template.description =
format (0,
"cli listener %s", s->config);
3254 if (!
cm->cli_prompt)
3255 cm->cli_prompt =
format (0,
"VLIB: ");
3274 if (isatty (STDIN_FILENO) && um->
tio_isset)
3275 tcsetattr (STDIN_FILENO, TCSAFLUSH, &um->
tio_stdin);
3290 char *
fmt = (prompt[strlen (prompt) - 1] ==
' ') ?
"%s" :
"%s ";
3300 if (!
cm->cli_file_pool)
3335 cm->current_input_file_index);
3348 .short_help =
"Exit CLI",
3356 .short_help =
"Exit CLI",
3379 if (!
unformat (input,
"%s", &file_name))
3386 fd = open (file_name, O_RDONLY);
3394 if (fstat (fd, &s) < 0)
3400 if (!(S_ISREG (s.st_mode) || S_ISLNK (s.st_mode)))
3409 if (read (fd, file_data, s.st_size) != s.st_size)
3412 s.st_size, file_name);
3423 if (
vec_len (sub_input.buffer) > 1)
3430 (
cm->cli_file_pool,
cm->current_input_file_index))
3431 mm = &
cm->macro_main;
3436 cm->current_input_file_index);
3441 (
i8 *) sub_input.buffer,
3446 _vec_len (expanded) -= 1;
3489 .short_help =
"exec <filename>",
3502 int i, n_errors_to_show;
3505 n_errors_to_show = 1 << 30;
3509 if (!
unformat (input,
"%d", &n_errors_to_show))
3513 "expecting integer number of errors to show, got `%U'",
3526 while (n_errors_to_show > 0)
3534 n_errors_to_show -= 1;
3541 if (
vec_len (unix_errors) == 0)
3546 for (
i =
vec_len (unix_errors) - 1;
i >= 0;
i--)
3564 .path =
"show unix errors",
3565 .short_help =
"Show Unix system call error history",
3578 char path[PATH_MAX];
3582 "Read",
"Write",
"Error",
"File Name",
"Description");
3588 s =
format (s,
"/proc/self/fd/%d%c",
f->file_descriptor, 0);
3589 rv = readlink((
char *) s,
path, PATH_MAX - 1);
3594 f->file_descriptor,
f->polling_thread_index,
3595 f->read_events,
f->write_events,
f->error_events,
3596 path,
f->description);
3607 .path =
"show unix files",
3608 .short_help =
"Show Unix files in use",
3645 .short_help =
"Show current session command history",
3667 "line-by-line" :
"char-by-char");
3677 " (disabled by history limit)");
3683 || cf->
height ?
"" :
" (disabled by terminal height)",
3686 " (disabled by buffer limit)");
3716 .path =
"show terminal",
3717 .short_help =
"Show current session terminal settings",
3736 #define fl(x, y) ( (x) ? toupper((y)) : tolower((y)) )
3742 "%-5d %-5d %-20v %c%c%c%c%c\n",
3796 .path =
"show cli-sessions",
3797 .short_help =
"Show current CLI sessions",
3824 else if (
unformat (line_input,
"off"))
3828 "Pager limit set to %u lines; note, this is global.\n",
3853 .path =
"set terminal pager",
3854 .short_help =
"set terminal pager [on|off] [limit <lines>]",
3881 else if (
unformat (line_input,
"off"))
3903 for (
i = 0;
i < limit;
i++)
3924 .path =
"set terminal history",
3925 .short_help =
"set terminal history [on|off] [limit <lines>]",
3963 .path =
"set terminal ansi",
3964 .short_help =
"set terminal ansi [on|off]",
3970 #define MAX_CLI_WAIT 86400
3984 if (
unformat (line_input,
"%f", &sec))
3991 if (sec <= 0 || sec >
MAX_CLI_WAIT || floor (sec * 1000) / 1000 != sec)
3993 "<sec> must be a positive value and less than 86400 (one day) with no more than msec precision.");
4004 .short_help =
"wait <sec>",
4031 .short_help =
"echo <rest-of-line>",
4045 if (!
unformat (input,
"%s", ¯o_name))
4069 .short_help =
"define <variable-name> <value>",
4082 if (!
unformat (input,
"%s", ¯o_name))
4095 .short_help =
"undefine <variable-name>",
4107 if (
unformat (input,
"noevaluate %=", &evaluate, 0))
4109 else if (
unformat (input,
"noeval %=", &evaluate, 0))
4118 .path =
"show macro",
4119 .short_help =
"show macro [noevaluate]",
4131 cm->new_session_process_node_index = ~0;
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.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
u8 started
Has the session started?
u32 current_input_file_index
File pool index of current input.
#define ANSI_BOLD
ANSI Start bold text.
@ UNIX_CLI_PARSE_ACTION_NOACTION
No action.
#define CLIB_SOCKET_F_IS_SERVER
static clib_error_t * unix_cli_read_ready(clib_file_t *uf)
Called when a CLI session file descriptor has data to be read.
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.
IP(src='1.1.1.1', dst='1.2.3.4', options=[IPOption('\x07')])/TCP(sport
clib_file_main_t file_main
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
@ UNIX_CLI_PARSE_ACTION_ERASERIGHT
Erase cursor right.
u8 has_epipe
If EPIPE has been detected, prevent further write-related activity on the descriptor.
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
static uword unix_cli_new_session_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
A failsafe manager that ensures CLI sessions issue an initial prompt if TELNET negotiation fails.
#define hash_set(h, key, value)
static clib_error_t * unix_cli_init(vlib_main_t *vm)
u8 * output_vector
Vector of output pending write to file descriptor.
u8 * line
The line to print.
unix_cli_process_event_type_t
CLI session events.
vlib_cli_output_function_t * output_function
@ UNIX_CLI_PARSE_ACTION_REVSEARCH
Search backwards in command history.
#define UNIX_FLAG_NOCOLOR
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
#define clib_memcpy(d, s, n)
static void unix_cli_cli_prompt(unix_cli_file_t *cf, clib_file_t *uf)
Output the CLI prompt.
static unix_cli_parse_actions_t unix_cli_parse_pager[]
Patterns to match when a CLI session is in the pager.
@ UNIX_CLI_PARSE_ACTION_PAGER_QUIT
Exit the pager session.
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
#define ANSI_RESTCURSOR
ANSI restore cursor position if previously saved.
static unix_cli_parse_actions_t unix_cli_parse_strings[]
Patterns to match on a CLI input stream.
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
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 pool_elt_at_index(p, i)
Returns pointer to element at given index.
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...
@ UNIX_CLI_PARSE_ACTION_CRLF
Carriage return, newline or enter.
u8 crlf_mode
Set if the CRLF mode wants CR + LF.
static void unix_cli_pager_message(unix_cli_file_t *cf, clib_file_t *uf, char *message, char *postfix)
Output a pager "skipping" message.
@ UNIX_CLI_PARSE_ACTION_PAGER_CRLF
Enter pressed (CR, CRLF, LF, etc)
f64 deadline
Deadline after which the new session must have a prompt.
u32 clib_file_index
The file index held by unix.c.
u8 ** vlib_cli_get_possible_completions(u8 *str)
@ UNIX_CLI_NEW_SESSION_EVENT_ADD
Add a CLI session to the new session list.
static clib_error_t * unix_config(vlib_main_t *vm, unformat_input_t *input)
#define clib_error_return(e, args...)
u32 len
Length of input without final NUL.
@ UNIX_CLI_PARSE_ACTION_END
End key (jump to end of line)
#define vec_append(v1, v2)
Append v2 after v1.
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.
vlib_node_main_t node_main
#define CTL(c)
Given a capital ASCII letter character return a NUL terminated string with the control code for that ...
u32 height
Terminal height.
@ UNIX_CLI_PARSE_ACTION_PAGER_TOP
Scroll to first line.
static unix_cli_main_t unix_cli_main
CLI global state.
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.
u8 * current_command
The command currently pointed at by the history cursor.
#define pool_put(P, E)
Free an object E in pool P.
static unix_cli_file_t * unix_cli_file_if_interactive(unix_cli_main_t *cm)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
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.
#define vec_delete(V, N, M)
Delete N elements starting at element M.
unix_cli_parse_action_t
CLI actions.
uword cf_index
Session index of the new session.
clib_macro_main_t macro_main
Macro tables for this session.
u32 command_number
Current command line counter.
static uword vlib_current_process(vlib_main_t *vm)
__clib_export int clib_macro_set_value(clib_macro_main_t *mm, char *name, char *value)
@ UNIX_CLI_PARSE_ACTION_UP
Up arrow.
@ UNIX_CLI_PARSE_ACTION_ERASELINELEFT
Erase line to left of cursor.
#define UNIX_CLI_MAX_TERMINAL_WIDTH
Maximum terminal width we will accept.
#define UNIX_CLI_DEFAULT_TERMINAL_WIDTH
Default terminal width.
u32 pager_start
Line number of top of page.
vnet_hw_if_output_node_runtime_t * r
#define ANSI_RESET
ANSI reset color settings.
static vlib_cli_command_t cli_unix_cli_show_terminal
(constructor) VLIB_CLI_COMMAND (cli_unix_cli_show_terminal)
unix_cli_parse_action_t action
Action to take when matched.
u32 new_session_process_node_index
New session process node identifier.
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
u8 * cli_prompt
Prompt string for CLI.
void vlib_start_process(vlib_main_t *vm, uword process_index)
static vlib_cli_command_t cli_unix_cli_set_terminal_ansi
(constructor) VLIB_CLI_COMMAND (cli_unix_cli_set_terminal_ansi)
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.
u8 is_socket
Whether the session is attached to a socket.
@ UNIX_CLI_PARSE_ACTION_CLEAR
Clear the terminal.
@ UNIX_CLI_PARSE_ACTION_PAGER_SEARCH
Search the pager buffer.
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 clib_unix_warning(format, args...)
#define hash_unset(h, key)
unix_cli_new_session_t * new_sessions
List of new sessions.
u8 cursor_direction
The current direction of cursor travel.
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
u32 process_node_index
Process node identifier.
@ UNIX_CLI_PARSE_ACTION_ERASEWORDLEFT
Erase word left.
#define VLIB_CONFIG_FUNCTION(x, n,...)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
#define ANSI_SAVECURSOR
ANSI save cursor position.
void clib_longjmp(clib_longjmp_t *save, uword return_value)
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,...
#define pool_foreach(VAR, POOL)
Iterate through pool.
@ UNIX_CLI_PARSE_ACTION_HOME
Home key (jump to start of line)
clib_socket_t cli_listen_socket
@ UNIX_CLI_PARSE_ACTION_DOWN
Down arrow.
@ UNIX_CLI_PARSE_ACTION_PAGER_PGUP
Scroll to previous page.
u8 ** command_history
Array of vectors of commands in the history.
#define ANSI_BRED
ANSI Start bright red text.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void unix_cli_set_session_noninteractive(unix_cli_file_t *cf)
Set a session to be non-interactive.
unix_cli_file_t * cli_file_pool
Vec pool of CLI sessions.
void vlib_worker_thread_node_runtime_update(void)
#define UNIX_FILE_DATA_AVAILABLE_TO_WRITE
static void unix_cli_pager_reindex(unix_cli_file_t *cf)
Reindex entire pager buffer.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
unix_cli_pager_index_t * pager_index
Index of line fragments in the pager buffer.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
struct clib_bihash_value offset
template key/value backing page structure
u32 vlib_process_create(vlib_main_t *vm, char *name, vlib_node_function_t *f, u32 log2_n_stack_bytes)
Create a vlib process.
u32 history_limit
Maximum number of history entries this session will store.
#define vlib_worker_thread_barrier_sync(X)
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.
f64 end
end of the time range
#define VLIB_MAIN_LOOP_EXIT_CLI
u32 cli_pager_buffer_limit
static vlib_process_t * vlib_get_process_from_node(vlib_main_t *vm, vlib_node_t *node)
static unix_cli_banner_t unix_cli_banner_color[]
ANSI color welcome banner.
@ UNIX_CLI_PROCESS_EVENT_QUIT
A CLI session wants to close.
u8 is_interactive
Whether the session is interactive or not.
#define vec_foreach_index(var, v)
Iterate over vector indices.
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.
static void unix_cli_pager_prompt_erase(unix_cli_file_t *cf, clib_file_t *uf)
Erase the printed pager prompt.
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
int vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
@ UNIX_CLI_PARSE_ACTION_WORDRIGHT
Jump cursor to start of right word.
u8 * input_vector
Vector of input saved by Unix input node to be processed by CLI process.
__clib_export i8 * clib_macro_eval(clib_macro_main_t *mm, i8 *s, i32 complain, u16 level, u16 max_level)
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.
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
@ UNIX_CLI_PARSE_ACTION_TAB
Tab key.
u8 ansi_capable
Can we do ANSI output?
@ UNIX_CLI_PARSE_ACTION_PAGER_BOTTOM
Scroll to last line.
vnet_feature_config_main_t * cm
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
__clib_export int clib_macro_unset(clib_macro_main_t *mm, char *name)
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...
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
clib_error_t * vlib_unix_recursive_mkdir(char *path)
u32 stdin_cli_file_index
The session index of the stdin cli.
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * define_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * echo_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
@ UNIX_CLI_PARSE_ACTION_ERASELINERIGHT
Erase line to right & including cursor.
u32 * unused_cli_process_node_indices
Vec pool of unused session indices.
static void clib_socket_free(clib_socket_t *s)
static vlib_cli_command_t undefine_cmd
(constructor) VLIB_CLI_COMMAND (undefine_cmd)
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.
static void unix_cli_pager_reset(unix_cli_file_t *f)
Resets the pager buffer and other data.
u8 * input
Input string to match.
static vlib_cli_command_t unix_cli_q_command
(constructor) VLIB_CLI_COMMAND (unix_cli_q_command)
struct _vlib_node_registration vlib_node_registration_t
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define vlib_call_config_function(vm, x)
static clib_error_t * unix_cli_listen_read_ready(clib_file_t *uf)
Telnet listening socket has a new connection.
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 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.
@ UNIX_CLI_PARSE_ACTION_PARTIALMATCH
Action parser found a partial match.
#define ANSI_SCROLLDN
ANSI scroll screen down one line.
#define vec_free(V)
Free vector's memory (no header).
@ UNIX_CLI_PARSE_ACTION_RIGHT
Right arrow.
int search_mode
If non-zero then the CLI is searching in the history array.
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.
template key/value backing page structure
@ UNIX_CLI_PROCESS_EVENT_READ_READY
A file descriptor has data to be read.
#define ESC
ANSI escape code.
static clib_error_t * show_macro_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
__clib_export void clib_macro_free(clib_macro_main_t *mm)
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.
#define UNIX_CLI_DEFAULT_TERMINAL_HEIGHT
Default terminal height.
#define UNIX_CLI_MAX_DEPTH_TELNET
Maximum depth into a byte stream from which to compile a Telnet protocol message.
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
description fragment has unexpected format
__clib_export clib_error_t * clib_socket_init(clib_socket_t *s)
static void clib_file_del(clib_file_main_t *um, clib_file_t *f)
u8 no_pager
Disable the pager?
static void unix_vlib_cli_output(uword cli_file_index, u8 *buffer, uword buffer_bytes)
VLIB CLI output function.
static vlib_cli_command_t unix_cli_quit_command
(constructor) VLIB_CLI_COMMAND (unix_cli_quit_command)
#define VLIB_INIT_FUNCTION(x)
i32 excursion
How far from the end of the history array the user has browsed.
static clib_error_t * unix_cli_error_detected(clib_file_t *uf)
Called when a CLI session file descriptor has an error condition.
#define CLIB_SOCKET_F_ALLOW_GROUP_WRITE
@ UNIX_CLI_PARSE_ACTION_PAGER_NEXT
Scroll to next page.
static vlib_process_t * vlib_get_current_process(vlib_main_t *vm)
static vlib_cli_command_t cli_exec
(constructor) VLIB_CLI_COMMAND (cli_exec)
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 vec_foreach(var, vec)
Vector iterator.
static void unix_cli_resize_interrupt(int signum)
The system terminal has informed us that the window size has changed.
@ UNIX_FILE_UPDATE_MODIFY
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
#define clib_error_return_unix(e, args...)
@ UNIX_CLI_PARSE_ACTION_PAGER_PGDN
Scroll to next page.
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
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.
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V,...
static vlib_cli_command_t cli_unix_cli_set_terminal_history
(constructor) VLIB_CLI_COMMAND (cli_unix_cli_set_terminal_history)
u8 ** pager_vector
Pager buffer.
u8 has_history
This session has command history.
Mapping of input buffer strings to action values.
@ UNIX_CLI_PARSE_ACTION_FWDSEARCH
Search forwards in command history.
u32 length
The length of the line without terminating NUL.
static vlib_cli_command_t cli_unix_wait_cmd
(constructor) VLIB_CLI_COMMAND (cli_unix_wait_cmd)
u8 * search_key
The string being searched for in the history.
@ UNIX_CLI_PARSE_ACTION_ERASE
Erase cursor left.
unix_cli_timeout_event_type_t
CLI session telnet negotiation timer events.
static unix_cli_banner_t unix_cli_banner[]
Plain welcome banner.
static vlib_cli_command_t cli_unix_show_errors
(constructor) VLIB_CLI_COMMAND (cli_unix_show_errors)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static u32 vlib_get_n_threads()
static void unix_cli_pager_redraw(unix_cli_file_t *cf, clib_file_t *uf)
Redraw the currently displayed page of text.
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 vlib_main_t * vlib_get_main(void)
static void unix_cli_process_input(unix_cli_main_t *cm, uword cli_file_index)
Process input to a CLI session.
@ UNIX_CLI_PARSE_ACTION_LEFT
Left arrow.
vnet_interface_output_runtime_t * rt
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
unix_error_history_t error_history[128]
@ UNIX_CLI_PARSE_ACTION_YANK
Undo last erase action.
Each new session is stored on a list with a deadline after which a prompt is issued,...
clib_macro_main_t macro_main
system default macro table
static vlib_cli_command_t cli_unix_echo_cmd
(constructor) VLIB_CLI_COMMAND (cli_unix_echo_cmd)
static clib_macro_main_t * get_macro_main(void)
Return the macro main / tables we should use for this session.
static void unix_cli_file_free(unix_cli_file_t *f)
Release storage used by a CLI session.
@ UNIX_CLI_PARSE_ACTION_PAGER_REDRAW
Clear and redraw the page on the terminal.
static u8 unix_cli_terminal_type_noninteractive(u8 *term, uword len)
Identify whether a terminal type is non-interactive.
@ UNIX_CLI_PARSE_ACTION_NOMATCH
Action parser did not find any match.
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.
#define clib_warning(format, args...)
static vlib_cli_command_t show_macro
(constructor) VLIB_CLI_COMMAND (show_macro)
static uword vlib_process_suspend_time_is_zero(f64 dt)
Returns TRUE if a process suspend time is less than 10us.
#define UNIX_FLAG_INTERACTIVE
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.
uword output_function_arg
#define ANSI_CLEARLINE
ANSI clear line cursor is on.
static unix_cli_file_t * unix_cli_file_if_exists(unix_cli_main_t *cm)
u32 vlib_register_node(vlib_main_t *vm, vlib_node_registration_t *r)
format_function_t format_clib_macro_main
#define UNIX_CLI_MAX_TERMINAL_HEIGHT
Maximum terminal height we will accept.
static f64 vlib_time_now(vlib_main_t *vm)
#define CSI
ANSI Control Sequence Introducer.
#define VLIB_MAIN_LOOP_EXIT_FUNCTION(x)
#define UNIX_FLAG_NOBANNER
static clib_error_t * unix_wait_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to wait <sec> seconds.
struct _socket_t clib_socket_t
vlib_parse_match_t vlib_parse_eval(u8 *input)
#define clib_panic(format, args...)
static u32 unix_cli_file_add(unix_cli_main_t *cm, char *name, int fd)
Store a new CLI session.
static vlib_cli_command_t cli_unix_cli_set_terminal_pager
(constructor) VLIB_CLI_COMMAND (cli_unix_cli_set_terminal_pager)
static u8 unix_cli_terminal_type_ansi(u8 *term, uword len)
Identify whether a terminal type is ANSI capable.
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.
u8 line_mode
Line mode or char mode.
vl_api_mac_event_action_t action
static vlib_cli_command_t cli_unix_cli_show_history
(constructor) VLIB_CLI_COMMAND (cli_unix_cli_show_history)
static vlib_cli_command_t cli_unix_cli_show_cli_sessions
(constructor) VLIB_CLI_COMMAND (cli_unix_cli_show_cli_sessions)
static void unix_cli_kill(unix_cli_main_t *cm, uword cli_file_index)
Destroy a CLI session.
static clib_error_t * undefine_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static word unix_vlib_findchr(u8 chr, u8 *str, word len)
A bit like strchr with a buffer length limit.
__clib_export void clib_macro_init(clib_macro_main_t *mm)
@ UNIX_CLI_PARSE_ACTION_WORDLEFT
Jump cursor to start of left word.
@ UNIX_CLI_PARSE_ACTION_PAGER_UP
Scroll to previous line.
@ UNIX_CLI_PARSE_ACTION_TELNETIAC
Telnet control code.
clib_longjmp_t main_loop_exit
void vlib_unix_cli_set_prompt(char *prompt)
Set the CLI prompt.
static vlib_cli_command_t define_cmd
(constructor) VLIB_CLI_COMMAND (define_cmd)
#define vec_del1(v, i)
Delete the element at index I.
static clib_error_t * unix_cli_config(vlib_main_t *vm, unformat_input_t *input)
Handle configuration directives in the unix section.
static uword unix_cli_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Handle system events.
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.
static vlib_cli_command_t cli_unix_show_files
(constructor) VLIB_CLI_COMMAND (cli_unix_show_files)
@ UNIX_CLI_PARSE_ACTION_PAGER_DN
Scroll to next line.
u32 cursor
Position of the insert cursor on the current input line.
__clib_export clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
#define ANSI_CLEAR
ANSI clear screen.
vl_api_wireguard_peer_flags_t flags