libosmovty 1.10.0.57-8972
Osmocom VTY library
|
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) (((EN) == EAGAIN) || ((EN) == EWOULDBLOCK) || ((EN) == EINTR)) |
#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. More... | |
int | vty_read_config_file (const char *file_name, void *priv) |
Read the configuration file using the VTY code. More... | |
int | vty_read_config_filep (FILE *confp, void *priv) |
Read up VTY configuration from a file stream. More... | |
void | vty_init_vtysh (void) |
void | vty_reset (void) |
Reset all VTY status. More... | |
struct vty * | vty_new (void) |
Allocate a new vty interface structure. More... | |
struct vty * | vty_create (int vty_sock, void *priv) |
Create new vty structure. More... | |
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 More... | |
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). More... | |
int | vty_read (struct vty *vty) |
Read data via vty socket. More... | |
void | vty_close (struct vty *) |
Close a given vty interface. More... | |
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. More... | |
int | vty_config_unlock (struct vty *) |
Unlock the configuration from a given VTY. More... | |
int | vty_shell (struct vty *) |
Return if this VTY is a shell or not. More... | |
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 More... | |
int | vty_current_node (struct vty *vty) |
return the current node of a given VTY More... | |
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. More... | |
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. More... | |
Variables | |
void * | tall_vty_ctx |
struct cmd_element | cfg_description_cmd |
struct cmd_element | cfg_no_description_cmd |
#define ERRNO_IO_RETRY | ( | EN | ) | (((EN) == EAGAIN) || ((EN) == EWOULDBLOCK) || ((EN) == EINTR)) |
#define VTY_BUFSIZ 512 |
#define VTY_CMD_ATTR_FLAGS_RESERVED { '.', '!', '@', '^' } |
#define VTY_CMD_USR_ATTR_NUM 32 |
#define VTY_MAXHIST 20 |
#define VTY_PRINTF_ATTRIBUTE | ( | a, | |
b | |||
) |
#define VTY_READ_BUFSIZ 512 |
enum event |
enum signal_vty |
enum vty_type |
|
static |
References osmo_counter::description, osmo_counter::name, vty_out_context::prefix, vty_out_context::skip_zero, vty_out_context::vty, VTY_NEWLINE, and vty_out().
Referenced by vty_out_statistics_partial2().
void vty_close | ( | struct vty * | vty | ) |
Close a given vty interface.
References buf, buffer_flush_all(), buffer_free(), fd, hist, obuf, vector_unset(), VTY_CLOSED, vty_config_unlock(), vty_event(), VTY_MAXHIST, and vtyvec.
Referenced by vty_create(), vty_read(), vty_read_config_filep(), vty_reset(), and write_config_file().
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 len(), name, OSMO_SNPRINTF_RET, vty_out_context::prefix, value_string::str, and value_string::value.
int vty_config_lock | ( | struct vty * | vty | ) |
Lock the configuration to a given VTY.
[in] | vty | VTY to which the config shall be locked |
This shall be used to make sure only one VTY at a given time has access to modify the configuration
References config, and vty_config.
Referenced by DEFUN().
int vty_config_unlock | ( | struct vty * | vty | ) |
Unlock the configuration from a given VTY.
[in] | vty | VTY from which the configuration shall be unlocked |
References config, and vty_config.
Referenced by gDEFUN(), vty_close(), and vty_end_config().
struct vty * vty_create | ( | int | vty_sock, |
void * | priv | ||
) |
Create new vty structure.
References host::advanced, AUTH_NODE, cp, ENABLE_NODE, fail, fd, hindex, hist, hp, length, host::lines, lines, node, host::password, password_check, host::password_encrypt, priv, status, type, vector_set_index(), VIEW_NODE, vty, vty_clear_buf(), vty_close(), vty_do_window_size(), vty_dont_linemode(), vty_event(), vty_hello(), vty_new(), VTY_NEWLINE, VTY_NORMAL, vty_out(), vty_prompt(), VTY_READ, VTY_TERM, vty_will_echo(), vty_will_suppress_go_ahead(), VTY_WRITE, and vtyvec.
Referenced by telnet_new_connection().
void * vty_current_index | ( | struct vty * | vty | ) |
return the current index of a given VTY
References index.
void vty_flush | ( | struct vty * | vty | ) |
References buffer_flush_all(), fd, and obuf.
const char * vty_get_bind_addr | ( | void | ) |
References vty_bind_addr, and VTY_BIND_ADDR_DEFAULT.
Referenced by telnet_init_default().
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().
char * vty_get_cwd | ( | void | ) |
References vty_cwd.
int vty_go_parent | ( | struct vty * | vty | ) |
References host::app_info, AUTH_ENABLE_NODE, AUTH_NODE, CONFIG_NODE, ENABLE_NODE, vty_app_info::go_parent_cb, node, VIEW_NODE, vty_clear_parents(), and vty_pop_parent().
Referenced by config_from_file(), gDEFUN(), and vty_down_level().
void vty_hello | ( | struct vty * | vty | ) |
References host::app_info, vty_app_info::copyright, host::motd, host::motdfile, vty_app_info::name, VTY_NEWLINE, and vty_out().
Referenced by vty_create().
void vty_init | ( | struct vty_app_info * | app_info | ) |
Initialize VTY layer.
[in] | app_info | application information |
References host::app_info, ARRAY_SIZE, cmd_init(), CONFIG_NODE, ENABLE_NODE, install_lib_element(), install_lib_element_ve(), install_node(), tall_vty_cmd_ctx, tall_vty_ctx, tall_vty_vec_ctx, vty_app_info::usr_attr_letters, vector_init(), VECTOR_MIN_SIZE, VTY_CMD_ATTR_FLAGS_RESERVED, vty_config_write(), VTY_NODE, vty_node, vty_save_cwd(), and vtyvec.
void vty_init_vtysh | ( | void | ) |
References vector_init(), VECTOR_MIN_SIZE, and vtyvec.
bool vty_is_active | ( | struct vty * | vty | ) |
References entry, llist_for_each_entry, and telnet_connection::vty.
void vty_log | ( | const char * | level, |
const char * | proto, | ||
const char * | fmt, | ||
va_list | |||
) |
struct vty * vty_new | ( | void | ) |
Allocate a new vty interface structure.
References buffer_free(), buffer_new(), INIT_LLIST_HEAD, tall_vty_ctx, and VTY_BUFSIZ.
Referenced by vty_create(), vty_read_config_filep(), and write_config_file().
|
inlinestatic |
References VTY_NEWLINE.
Referenced by vty_out_newline().
int vty_out | ( | struct vty * | , |
const char * | , | ||
... | |||
) |
Referenced by _vty_output(), 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_log_single(), config_write_sched(), config_write_stats(), config_write_stats_reporter(), DEFUN(), DEFUN_ATTR(), DEFUN_DEPRECATED(), 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(), rate_ctr_group_handler(), rate_ctr_handler(), rate_ctr_handler_fmt(), set_srep_parameter_int(), set_srep_parameter_str(), talloc_ctx_walk_cb(), vty_out_fsm2(), vty_out_fsm_inst2(), vty_out_rate_ctr_group2(), vty_out_stat_item_group2(), vty_out_statistics_partial2(), and vty_print_logtarget().
int vty_out_newline | ( | struct vty * | vty | ) |
print a newline on the given VTY
References buffer_put(), obuf, and vty_newline().
Referenced by DEFUN().
void vty_out_statistics_full | ( | struct vty * | vty, |
const char * | prefix | ||
) |
References vty_out_context::prefix, and vty_out_statistics_full2().
void vty_out_statistics_full2 | ( | struct vty * | vty, |
const char * | prefix, | ||
bool | skip_zero | ||
) |
References vty_out_context::prefix, vty_out_context::skip_zero, and vty_out_statistics_partial2().
Referenced by DEFUN(), and vty_out_statistics_full().
void vty_out_statistics_partial | ( | struct vty * | vty, |
const char * | prefix, | ||
int | max_level | ||
) |
References vty_out_context::max_level, vty_out_context::prefix, and vty_out_statistics_partial2().
void vty_out_statistics_partial2 | ( | struct vty * | vty, |
const char * | prefix, | ||
int | max_level, | ||
bool | skip_zero | ||
) |
References handle_counter(), vty_out_context::max_level, osmo_counters_for_each(), osmo_stat_item_for_each_group(), osmo_stat_item_group_handler(), vty_out_context::prefix, rate_ctr_for_each_group(), rate_ctr_group_handler(), vty_out_context::skip_zero, vty, VTY_NEWLINE, and vty_out().
Referenced by DEFUN(), vty_out_statistics_full2(), and vty_out_statistics_partial().
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 h, osmo_clock_gettime(), starttime, timespecsub, and vty_out().
Referenced by DEFUN().
int int vty_out_va | ( | struct vty * | vty, |
const char * | format, | ||
va_list | ap | ||
) |
References buf, buffer_put(), fd, len(), obuf, vty_event(), vty_shell(), and VTY_WRITE.
Referenced by osmo_tdef_vty_out_one_va(), osmo_tdef_vty_write(), print_func_vty(), and vty_out().
int vty_read | ( | struct vty * | vty | ) |
Read data via vty socket.
References AUTH_ENABLE_NODE, AUTH_NODE, buf, buffer_reset(), CONTROL, ERRNO_IO_RETRY, escape, fd, iac, iac_sb_in_progress, length, node, obuf, sb_buf, sb_len, status, vty_backward_char(), vty_backward_kill_word(), vty_backward_word(), vty_beginning_of_line(), vty_buffer_reset(), vty_clear_screen(), vty_close(), vty_complete_command(), vty_delete_backward_char(), vty_delete_char(), vty_describe_command(), vty_end_config(), vty_end_of_line(), VTY_ESCAPE, vty_escape_map(), vty_event(), vty_execute(), vty_forward_char(), vty_forward_kill_word(), vty_forward_word(), vty_kill_line(), vty_kill_line_from_beginning(), VTY_NEWLINE, vty_next_line(), VTY_NORMAL, vty_out(), VTY_PRE_ESCAPE, vty_previous_line(), VTY_READ, VTY_READ_BUFSIZ, vty_self_insert(), vty_stop_input(), vty_telnet_option(), vty_transpose_chars(), and VTY_WRITE.
Referenced by client_data().
int vty_read_config_file | ( | const char * | file_name, |
void * | priv | ||
) |
Read the configuration file using the VTY code.
[in] | file_name | file name of the configuration file |
[in] | priv | private data to be passed to vty_read_file |
References host_config_set(), and vty_read_config_filep().
int vty_read_config_filep | ( | FILE * | confp, |
void * | priv | ||
) |
Read up VTY configuration from a file stream.
[in] | confp | file pointer of the stream for the configuration file |
[in] | priv | private data to be passed to vty_read_file |
References buf, CMD_ERR_AMBIGUOUS, CMD_ERR_INVALID_INDENT, CMD_ERR_NO_MATCH, CMD_SUCCESS, config_from_file(), CONFIG_NODE, fd, node, priv, type, vty, vty_close(), VTY_FILE, and vty_new().
Referenced by vty_read_config_file().
void vty_reset | ( | void | ) |
Reset all VTY status.
References buffer_reset(), obuf, status, vector_active, vector_slot, vty, vty_close(), vtyvec, and Vvty_serv_thread.
int vty_shell | ( | struct vty * | vty | ) |
int vty_shell_serv | ( | struct vty * | vty | ) |
References type, and VTY_SHELL_SERV.
|
extern |
|
extern |
|
extern |
Referenced by buffer_getstr().