libosmovty UNKNOWN
Osmocom VTY library
Loading...
Searching...
No Matches
VTY (Virtual TTY) interface

Files

file  vty.h

Data Structures

struct  vty
 Internal representation of a single VTY. More...
struct  vty_app_info
 Information an application registers with the VTY. More...
struct  vty_signal_data

Macros

#define VTY_PRINTF_ATTRIBUTE(a, b)
#define ERRNO_IO_RETRY(EN)
#define VTY_READ_BUFSIZ   512
#define VTY_BUFSIZ   512
#define VTY_MAXHIST   20
#define VTY_CMD_USR_ATTR_NUM   32
#define VTY_CMD_ATTR_FLAGS_RESERVED    { '.', '!', '@', '^' }
#define VTY_NEWLINE   ((vty->type == VTY_TERM) ? "\r\n" : "\n")

Enumerations

enum  event {
  VTY_SERV ,
  VTY_READ ,
  VTY_WRITE ,
  VTY_CLOSED ,
  VTY_TIMEOUT_RESET
}
 VTY events. More...
enum  vty_type {
  VTY_TERM ,
  VTY_FILE ,
  VTY_SHELL ,
  VTY_SHELL_SERV
}
enum  signal_vty { S_VTY_EVENT }
 signal handling More...

Functions

static const char * vty_newline (struct vty *vty)
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.
int vty_read_config_filep (FILE *confp, void *priv)
 Read up VTY configuration from a file stream.
void vty_init_vtysh (void)
void vty_reset (void)
 Reset all VTY status.
struct vtyvty_new (void)
 Allocate a new vty interface structure.
struct vtyvty_create (int vty_sock, void *priv)
 Create new vty structure.
bool vty_is_active (struct vty *vty)
int vty_out (struct vty *, const char *,...) VTY_PRINTF_ATTRIBUTE(2
int int vty_out_va (struct vty *vty, const char *format, va_list ap)
int vty_out_newline (struct vty *)
 print a newline on the given VTY
int vty_out_uptime (struct vty *vty, const struct timespec *starttime)
 calculates the time difference of a give timespec to the current time and prints in a human readable format (days, hours, minutes, seconds).
int vty_read (struct vty *vty)
 Read data via vty socket.
void vty_close (struct vty *)
 Close a given vty interface.
void vty_flush (struct vty *vty)
char * vty_get_cwd (void)
void vty_log (const char *level, const char *proto, const char *fmt, va_list)
int vty_config_lock (struct vty *)
 Lock the configuration to a given VTY.
int vty_config_unlock (struct vty *)
 Unlock the configuration from a given VTY.
int vty_shell (struct vty *)
 Return if this VTY is a shell or not.
int vty_shell_serv (struct vty *)
void vty_hello (struct vty *)
void * vty_current_index (struct 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_go_parent (struct vty *vty)
const char * vty_get_bind_addr (void)
int vty_get_bind_port (int default_port)
 Returns configured port passed to the 'line vty'/'bind' command or default_port.
static int handle_counter (struct osmo_counter *counter, void *vctx_)
void vty_out_statistics_partial2 (struct vty *vty, const char *prefix, int max_level, bool skip_zero)
void vty_out_statistics_partial (struct vty *vty, const char *prefix, int max_level)
void vty_out_statistics_full2 (struct vty *vty, const char *prefix, bool skip_zero)
void vty_out_statistics_full (struct vty *vty, const char *prefix)
char * vty_cmd_string_from_valstr (void *ctx, const struct value_string *vals, const char *prefix, const char *sep, const char *end, int do_lower)
 Generate a VTY command string from value_string.

Variables

void * tall_vty_ctx
struct cmd_element cfg_description_cmd
struct cmd_element cfg_no_description_cmd

Detailed Description

Macro Definition Documentation

◆ ERRNO_IO_RETRY

#define ERRNO_IO_RETRY ( EN)
Value:
(((EN) == EAGAIN) || ((EN) == EWOULDBLOCK) || ((EN) == EINTR))

Referenced by buffer_flush_available(), buffer_write(), and vty_read().

◆ VTY_BUFSIZ

#define VTY_BUFSIZ   512

Referenced by config_from_file(), and vty_new().

◆ VTY_CMD_ATTR_FLAGS_RESERVED

#define VTY_CMD_ATTR_FLAGS_RESERVED    { '.', '!', '@', '^' }

Referenced by vty_init().

◆ VTY_CMD_USR_ATTR_NUM

#define VTY_CMD_USR_ATTR_NUM   32

◆ VTY_MAXHIST

#define VTY_MAXHIST   20

◆ VTY_NEWLINE

#define VTY_NEWLINE   ((vty->type == VTY_TERM) ? "\r\n" : "\n")

Referenced by ALIAS(), ALIAS(), asciidoc_counter_generate(), asciidoc_handle_counter(), asciidoc_osmo_stat_item_group_handler(), asciidoc_osmo_stat_item_handler(), asciidoc_rate_ctr_group_handler(), asciidoc_rate_ctr_handler(), config_write_host(), config_write_log_single(), config_write_sched(), config_write_stats(), config_write_stats_reporter(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN_ATTR(), DEFUN_ATTR(), DEFUN_DEPRECATED(), DEFUN_HIDDEN(), for(), gDEFUN(), gDEFUN(), gDEFUN(), gDEFUN(), handle_counter(), log_deprecated_func(), osmo_log_vty2tgt(), osmo_stat_item_group_handler(), osmo_stat_item_handler(), osmo_tdef_vty_out_all_va(), osmo_tdef_vty_out_one_va(), osmo_tdef_vty_parse_T_arg(), osmo_tdef_vty_set_cmd(), osmo_tdef_vty_write(), print_attr_list(), rate_ctr_group_handler(), rate_ctr_group_handler(), rate_ctr_handler(), rate_ctr_handler_fmt(), set_srep_parameter_int(), set_srep_parameter_str(), talloc_ctx_walk_cb(), vty_auth(), vty_command(), vty_complete_command(), vty_config_write(), vty_create(), vty_describe_command(), vty_describe_fold(), vty_down_level(), vty_dump_xml_ref_to_vty(), vty_end_config(), vty_hello(), vty_newline(), vty_out(), vty_out_fsm2(), vty_out_fsm_inst2(), vty_out_rate_ctr_group2(), vty_out_stat_item_group2(), vty_out_statistics_partial2(), vty_print_logtarget(), vty_read(), vty_stop_input(), and vty_telnet_option().

◆ VTY_PRINTF_ATTRIBUTE

#define VTY_PRINTF_ATTRIBUTE ( a,
b )

Referenced by vty_out().

◆ VTY_READ_BUFSIZ

#define VTY_READ_BUFSIZ   512

Referenced by vty_read().

Enumeration Type Documentation

◆ event

enum event

VTY events.

Enumerator
VTY_SERV 
VTY_READ 
VTY_WRITE 
VTY_CLOSED 
VTY_TIMEOUT_RESET 

◆ signal_vty

enum signal_vty

signal handling

Enumerator
S_VTY_EVENT 

◆ vty_type

enum vty_type
Enumerator
VTY_TERM 
VTY_FILE 
VTY_SHELL 
VTY_SHELL_SERV 

Function Documentation

◆ handle_counter()

◆ vty_close()

◆ vty_cmd_string_from_valstr()

char * vty_cmd_string_from_valstr ( void * ctx,
const struct value_string * vals,
const char * prefix,
const char * sep,
const char * end,
int do_lower )

Generate a VTY command string from value_string.

References vty_out_context::prefix, value_string::str, and value_string::value.

◆ vty_config_lock()

int vty_config_lock ( struct vty * vty)

Lock the configuration to a given VTY.

Parameters
[in]vtyVTY to which the config shall be locked
Returns
1 on success, 0 on error

This shall be used to make sure only one VTY at a given time has access to modify the configuration

References vty::config, and vty_config.

Referenced by DEFUN(), and vty_log().

◆ vty_config_unlock()

int vty_config_unlock ( struct vty * vty)

Unlock the configuration from a given VTY.

Parameters
[in]vtyVTY from which the configuration shall be unlocked
Returns
0 in case of success

References vty::config, and vty_config.

Referenced by gDEFUN(), gDEFUN(), vty_close(), vty_end_config(), and vty_log().

◆ vty_create()

◆ vty_current_index()

void * vty_current_index ( struct vty * vty)

return the current index of a given VTY

References vty::index.

Referenced by vty_log().

◆ vty_current_node()

int vty_current_node ( struct vty * vty)

return the current node of a given VTY

References vty::node.

Referenced by vty_log().

◆ vty_flush()

void vty_flush ( struct vty * vty)

References buffer_flush_all(), vty::fd, and vty::obuf.

Referenced by vty_out().

◆ vty_get_bind_addr()

const char * vty_get_bind_addr ( void )

◆ vty_get_bind_port()

int vty_get_bind_port ( int default_port)

Returns configured port passed to the 'line vty'/'bind' command or default_port.

References vty_bind_port.

Referenced by telnet_init_default(), and vty_log().

◆ vty_get_cwd()

char * vty_get_cwd ( void )

References vty_cwd.

Referenced by vty_out().

◆ vty_go_parent()

◆ vty_hello()

void vty_hello ( struct vty * vty)

◆ vty_init()

◆ vty_init_vtysh()

void vty_init_vtysh ( void )

◆ vty_is_active()

bool vty_is_active ( struct vty * vty)

◆ vty_log()

◆ vty_new()

struct vty * vty_new ( void )

Allocate a new vty interface structure.

References buffer_free(), buffer_new(), tall_vty_ctx, and VTY_BUFSIZ.

Referenced by vty_create(), vty_read_config_filep(), and write_config_file().

◆ vty_newline()

const char * vty_newline ( struct vty * vty)
inlinestatic

References VTY_NEWLINE.

Referenced by vty_out_newline().

◆ vty_out()

◆ vty_out_newline()

int vty_out_newline ( struct vty * vty)

print a newline on the given VTY

References buffer_put(), vty::obuf, and vty_newline().

Referenced by DEFUN(), and vty_out().

◆ vty_out_statistics_full()

void vty_out_statistics_full ( struct vty * vty,
const char * prefix )

◆ vty_out_statistics_full2()

void vty_out_statistics_full2 ( struct vty * vty,
const char * prefix,
bool skip_zero )

◆ vty_out_statistics_partial()

void vty_out_statistics_partial ( struct vty * vty,
const char * prefix,
int max_level )

◆ vty_out_statistics_partial2()

void vty_out_statistics_partial2 ( struct vty * vty,
const char * prefix,
int max_level,
bool skip_zero )

◆ vty_out_uptime()

int vty_out_uptime ( struct vty * vty,
const struct timespec * starttime )

calculates the time difference of a give timespec to the current time and prints in a human readable format (days, hours, minutes, seconds).

References starttime, and vty_out().

Referenced by DEFUN(), and vty_out().

◆ vty_out_va()

int int vty_out_va ( struct vty * vty,
const char * format,
va_list ap )

◆ vty_read()

◆ vty_read_config_file()

int vty_read_config_file ( const char * file_name,
void * priv )

Read the configuration file using the VTY code.

Parameters
[in]file_namefile name of the configuration file
[in]privprivate data to be passed to vty_read_file

References host_config_set(), and vty_read_config_filep().

◆ vty_read_config_filep()

int vty_read_config_filep ( FILE * confp,
void * priv )

Read up VTY configuration from a file stream.

Parameters
[in]confpfile pointer of the stream for the configuration file
[in]privprivate data to be passed to vty_read_file
Returns
Zero on success, non-zero on error

References vty::buf, CMD_ERR_AMBIGUOUS, CMD_ERR_INVALID_INDENT, CMD_ERR_NO_MATCH, CMD_SUCCESS, config_from_file(), CONFIG_NODE, vty::fd, vty::node, vty::priv, vty::type, vty_close(), VTY_FILE, and vty_new().

Referenced by vty_read_config_file().

◆ vty_reset()

void vty_reset ( void )

◆ vty_shell()

int vty_shell ( struct vty * vty)

Return if this VTY is a shell or not.

References vty::type, and VTY_SHELL.

Referenced by vty_log(), and vty_out_va().

◆ vty_shell_serv()

int vty_shell_serv ( struct vty * vty)

References vty::type, and VTY_SHELL_SERV.

Referenced by vty_log().

Variable Documentation

◆ cfg_description_cmd

struct cmd_element cfg_description_cmd
extern

Referenced by gDEFUN(), and vty_log().

◆ cfg_no_description_cmd

struct cmd_element cfg_no_description_cmd
extern

Referenced by gDEFUN(), and vty_log().

◆ tall_vty_ctx

void* tall_vty_ctx
extern