libosmovty 0.9.6-23.20170220git32ee5af8.fc42
Osmocom VTY library
Loading...
Searching...
No Matches
vty.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <termios.h>
#include <sys/utsname.h>
#include <sys/param.h>
#include <arpa/telnet.h>
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/buffer.h>
#include <osmocom/core/talloc.h>

Macros

#define SYSCONFDIR   "/usr/local/etc"
 
#define VTY_BIND_ADDR_DEFAULT   "127.0.0.1"
 
#define CONTROL(X)
 
#define VTY_NORMAL   0
 
#define VTY_PRE_ESCAPE   1
 
#define VTY_ESCAPE   2
 

Functions

void vty_event (enum event event, int sock, struct vty *vty)
 callback from core VTY code about VTY related events
 
static void vty_clear_buf (struct vty *vty)
 
struct vtyvty_new (void)
 Allocate a new vty interface structure.
 
static void vty_auth (struct vty *vty, char *buf)
 
void vty_close (struct vty *vty)
 Close a given vty interface.
 
int vty_shell (struct vty *vty)
 Return if this VTY is a shell or not.
 
int vty_out (struct vty *vty, const char *format,...)
 VTY standard output function.
 
int vty_out_newline (struct vty *vty)
 print a newline on the given VTY
 
void * vty_current_index (struct vty *vty)
 return the current index of a given VTY
 
int vty_current_node (struct vty *vty)
 return the current node of a given VTY
 
int vty_config_lock (struct vty *vty)
 Lock the configuration to a given VTY.
 
int vty_config_unlock (struct vty *vty)
 Unlock the configuration from a given VTY.
 
void vty_hello (struct vty *vty)
 
static void vty_prompt (struct vty *vty)
 
static int vty_command (struct vty *vty, char *buf)
 
static void vty_write (struct vty *vty, const char *buf, size_t nbytes)
 
static void vty_ensure (struct vty *vty, int length)
 
static void vty_self_insert (struct vty *vty, char c)
 
static void vty_self_insert_overwrite (struct vty *vty, char c)
 
static void vty_insert_word_overwrite (struct vty *vty, char *str)
 
static void vty_forward_char (struct vty *vty)
 
static void vty_backward_char (struct vty *vty)
 
static void vty_beginning_of_line (struct vty *vty)
 
static void vty_end_of_line (struct vty *vty)
 
static void vty_hist_add (struct vty *vty)
 
static int vty_telnet_option (struct vty *vty, unsigned char *buf, int nbytes)
 
static int vty_execute (struct vty *vty)
 
static void vty_will_echo (struct vty *vty)
 
static void vty_will_suppress_go_ahead (struct vty *vty)
 
static void vty_dont_linemode (struct vty *vty)
 
static void vty_do_window_size (struct vty *vty)
 
static void vty_kill_line_from_beginning (struct vty *)
 
static void vty_redraw_line (struct vty *)
 
static void vty_history_print (struct vty *vty)
 
static void vty_next_line (struct vty *vty)
 
static void vty_previous_line (struct vty *vty)
 
static void vty_forward_word (struct vty *vty)
 
static void vty_backward_pure_word (struct vty *vty)
 
static void vty_backward_word (struct vty *vty)
 
static void vty_down_level (struct vty *vty)
 
static void vty_end_config (struct vty *vty)
 
static void vty_delete_char (struct vty *vty)
 
static void vty_delete_backward_char (struct vty *vty)
 
static void vty_kill_line (struct vty *vty)
 
static void vty_forward_kill_word (struct vty *vty)
 
static void vty_backward_kill_word (struct vty *vty)
 
static void vty_transpose_chars (struct vty *vty)
 
static void vty_complete_command (struct vty *vty)
 
static void vty_describe_fold (struct vty *vty, int cmd_width, unsigned int desc_width, struct desc *desc)
 
static void vty_describe_command (struct vty *vty)
 
static void vty_stop_input (struct vty *vty)
 
static void vty_escape_map (unsigned char c, struct vty *vty)
 
static void vty_buffer_reset (struct vty *vty)
 
int vty_read (struct vty *vty)
 Read data via vty socket.
 
static int vty_read_file (FILE *confp, void *priv)
 
struct vtyvty_create (int vty_sock, void *priv)
 Create new vty structure.
 
 DEFUN (config_who, config_who_cmd, "who", "Display who is on vty\n")
 
 DEFUN (line_vty, line_vty_cmd, "line vty", "Configure a terminal line\n" "Virtual terminal\n")
 
 DEFUN (vty_login, vty_login_cmd, "login", "Enable password checking\n")
 
 DEFUN (no_vty_login, no_vty_login_cmd, "no login", NO_STR "Enable password checking\n")
 
 DEFUN (vty_bind, vty_bind_cmd, "bind A.B.C.D", "Accept VTY telnet connections on local interface\n" "Local interface IP address (default: " VTY_BIND_ADDR_DEFAULT ")\n")
 
const char * vty_get_bind_addr (void)
 
 DEFUN (service_advanced_vty, service_advanced_vty_cmd, "service advanced-vty", "Set up miscellaneous service\n" "Enable advanced mode vty interface\n")
 
 DEFUN (no_service_advanced_vty, no_service_advanced_vty_cmd, "no service advanced-vty", NO_STR "Set up miscellaneous service\n" "Enable advanced mode vty interface\n")
 
 DEFUN (terminal_monitor, terminal_monitor_cmd, "terminal monitor", "Set terminal line parameters\n" "Copy debug output to the current terminal line\n")
 
 DEFUN (terminal_no_monitor, terminal_no_monitor_cmd, "terminal no monitor", "Set terminal line parameters\n" NO_STR "Copy debug output to the current terminal line\n")
 
 DEFUN (show_history, show_history_cmd, "show history", SHOW_STR "Display the session command history\n")
 
static int vty_config_write (struct vty *vty)
 
void vty_reset (void)
 Reset all VTY status.
 
static void vty_save_cwd (void)
 
char * vty_get_cwd (void)
 
int vty_shell_serv (struct vty *vty)
 
void vty_init_vtysh (void)
 
void vty_init (struct vty_app_info *app_info)
 Initialize VTY layer.
 
int vty_read_config_file (const char *file_name, void *priv)
 Read the configuration file using the VTY code.
 

Variables

struct host host
 
static vector vtyvec
 
vector Vvty_serv_thread
 
char * vty_cwd = NULL
 
static const char * vty_bind_addr = NULL
 
static int vty_config
 
static int password_check
 
void * tall_vty_ctx
 
static const char telnet_backward_char = 0x08
 
static const char telnet_space_char = ' '
 
struct cmd_node vty_node
 
void * tall_bsc_ctx
 

Macro Definition Documentation

◆ CONTROL

#define CONTROL ( X)
Value:
((X) - '@')

Function Documentation

◆ vty_out()

int vty_out ( struct vty * vty,
const char * format,
... )

VTY standard output function.

Parameters
[in]vtyVTY to which we should print
[in]formatvariable-length format string

References vty::buf, vty::fd, vty::obuf, vty_event(), and vty_shell().

Referenced by vty_create(), and vty_read().

Variable Documentation

◆ vty_node

struct cmd_node vty_node
Initial value:
= {
"%s(config-line)# ",
1,
}
@ VTY_NODE
Vty node.
Definition command.h:80