diff options
author | Chris Luke <chrisy@flirble.org> | 2016-04-25 13:48:54 -0400 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2016-04-27 13:32:48 +0000 |
commit | 0aca5eb1b88524fc8e988deb6488d14c092b0137 (patch) | |
tree | bd38ae395a66b02227a22f044cf0e2ddd857183d /vlib/vlib/unix/unix.h | |
parent | b3656ea0b847ef7bd1a19d2915cdd5938f32b314 (diff) |
Debug/Telnet CLI enhancements
A fairly comprehensive re-work of the built-in debug and telnet CLI
to add various command line editing features and to add command history
to the debug CLI.
This may seem like a large change but a good amount of it is merely
reworking the existing CLI code (which changed its indent level).
The features this patch enables include:
- Enable history in the debug CLI.
- Put both stdin and telnet connections in char-by-char mode.
- Echo from the server, not the client, for more control.
- Add a mostly no-op but fairly complete Telnet protocol processor.
- Perform control code parsing on the input byte stream to match strings
of both control codes and ANSI/VT100 escape sequences.
- Up/down keys scroll through the history (like ^P/^N).
- Do CRLF output cooking (\n -> \r\n) for connections that need it.
- Left/right cursor movements, insert/erase at cursor.
- Home/end cursor jumps.
- Jump left/right word at a time (Ctrl-left/right).
- Negotiate the terminal type from Telnet clients. (well, the code doesn’t
really negotiate, it demands it, but the client is led to believe it
was a negotiation)
- Read terminal type from TERM variable for the local debug CLI.
- Delete from cursor to end of line (^K). Delete char-right (^D/Del).
- Clear screen (^L) and repaint prompt/current command (on non-ANSI
terminals it just newlines and repaints the line).
Change-Id: Id274b56ccfd4cc8c19ddc0f478890f21f284262a
Signed-off-by: Chris Luke <chrisy@flirble.org>
Diffstat (limited to 'vlib/vlib/unix/unix.h')
-rw-r--r-- | vlib/vlib/unix/unix.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/vlib/vlib/unix/unix.h b/vlib/vlib/unix/unix.h index 44a8853e356..269b9df5975 100644 --- a/vlib/vlib/unix/unix.h +++ b/vlib/vlib/unix/unix.h @@ -41,6 +41,7 @@ #define included_unix_unix_h #include <vppinfra/socket.h> +#include <termios.h> struct unix_file; typedef clib_error_t * (unix_file_function_t) (struct unix_file * f); @@ -102,10 +103,15 @@ typedef struct { /* CLI log file. GIGO. */ u8 *log_filename; int log_fd; - /* Don't put telnet connections into character mode */ + /* Don't put CLI connections into character mode */ int cli_line_mode; + + /* Maximum amount of command line history to keep per session */ u32 cli_history_limit; - + + /* Store the original state of stdin when it's a tty */ + struct termios tio_stdin; + int tio_isset; } unix_main_t; /* Global main structure. */ |