libosmovty 1.10.0.57-8972
Osmocom VTY library
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <syslog.h>
#include <errno.h>
#include <unistd.h>
#include <ctype.h>
#include <time.h>
#include <limits.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <osmocom/vty/vector.h>
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/utils.h>
Data Structures | |
struct | vty_parent_node |
Macros | |
#define | _XOPEN_SOURCE |
#define | MAXPATHLEN 4096 |
#define | CONFIGFILE_MASK 022 |
#define | ADD(out, str) |
#define | CMD_ATTR_PUBLIC_MASK (CMD_ATTR_HIDDEN | CMD_ATTR_IMMEDIATE | CMD_ATTR_NODE_EXIT) |
#define | IPV6_ADDR_STR "0123456789abcdefABCDEF:.%" |
#define | IPV6_PREFIX_STR "0123456789abcdefABCDEF:.%/" |
#define | STATE_START 1 |
#define | STATE_COLON 2 |
#define | STATE_DOUBLE 3 |
#define | STATE_ADDR 4 |
#define | STATE_DOT 5 |
#define | STATE_SLASH 6 |
#define | STATE_MASK 7 |
#define | INIT_MATCHVEC_SIZE 10 |
#define | INIT_MATCHVEC_SIZE 10 |
Typedefs | |
typedef int(* | print_func_t) (void *data, const char *fmt,...) |
Enumerations | |
enum | match_type { NO_MATCH = 0 , ANY_MATCH , EXTEND_MATCH , IPV4_PREFIX_MATCH , IPV4_MATCH , IPV6_PREFIX_MATCH , IPV6_MATCH , RANGE_MATCH , VARARG_MATCH , PARTLY_MATCH , EXACT_MATCH } |
enum | { ATTR_TYPE_GLOBAL = (1 << 0) , ATTR_TYPE_LIB = (1 << 1) , ATTR_TYPE_APP = (1 << 2) } |
Functions | |
void | print_version (int print_copyright) |
print the version (and optionally copyright) information More... | |
char * | argv_concat (const char **argv, int argc, int shift) |
static const char * | node_name_from_prompt (const char *prompt, char *name_buf, size_t name_buf_size) |
static void | install_basic_node_commands (int node) |
Install common commands like 'exit' and 'list'. More... | |
static void | install_node_bare (struct cmd_node *node, int(*func)(struct vty *)) |
Install top node of command vector, without adding basic node commands. More... | |
void | install_node (struct cmd_node *node, int(*func)(struct vty *)) |
Install top node of command vector. More... | |
static int | cmp_node (const void *p, const void *q) |
static int | cmp_desc (const void *p, const void *q) |
void | sort_node (void) |
Sort each node's command element according to command string. More... | |
int | cmd_make_strvec2 (const char *string, char **indent, vector *strvec_p) |
Break up string in command tokens. More... | |
vector | cmd_make_strvec (const char *string) |
Breaking up string into each command piece. More... | |
void | cmd_free_strvec (vector v) |
Free allocated string vector. More... | |
static char * | cmd_desc_str (const char **string) |
Fetch next description. More... | |
static vector | cmd_make_descvec (const char *string, const char *descstr) |
New string vector. More... | |
static int | cmd_cmdsize (vector strvec) |
const char * | cmd_prompt (enum node_type node) |
Return prompt character of specified node. More... | |
char * | osmo_asciidoc_escape (const char *inp) |
escape all special asciidoc symbols More... | |
static char * | xml_escape (const char *inp) |
static char | cmd_attr_get_flag (unsigned int attr) |
static int | vty_dump_element (const struct cmd_element *cmd, print_func_t print_func, void *data, const char *newline) |
static bool | vty_command_is_common (const struct cmd_element *cmd) |
Return true if a node is installed by install_basic_node_commands(), so that we can avoid repeating them for each and every node during 'show running-config'. More... | |
static int | vty_dump_nodes (print_func_t print_func, void *data, const char *newline, unsigned char gflag_mask, bool match) |
static int | print_func_vty (void *data, const char *format,...) |
static int | vty_dump_xml_ref_to_vty (struct vty *vty) |
static int | print_func_stream (void *data, const char *format,...) |
int | vty_dump_xml_ref_mode (FILE *stream, enum vty_ref_gen_mode mode) |
Print the XML reference of all VTY nodes to the given stream. More... | |
int | vty_dump_xml_ref (FILE *stream) |
Print the XML reference of all VTY nodes to the given stream. More... | |
static int | check_element_exists (struct cmd_node *cnode, const char *cmdstring) |
void | install_element (int ntype, struct cmd_element *cmd) |
Install a command into a node. More... | |
void | install_lib_element (int ntype, struct cmd_element *cmd) |
Install a library command into a node. More... | |
void | install_element_ve (struct cmd_element *cmd) |
void | install_lib_element_ve (struct cmd_element *cmd) |
static int | config_write_host (struct vty *vty) |
static vector | cmd_node_vector (vector v, enum node_type ntype) |
static enum match_type | cmd_ipv4_match (const char *str) |
static enum match_type | cmd_ipv4_prefix_match (const char *str) |
static int | check_base (const char *str) |
int | vty_cmd_range_match (const char *range, const char *str) |
static char * | cmd_deopt (void *ctx, const char *str) |
static enum match_type | cmd_match (const char *str, const char *command, enum match_type min, bool recur) |
static enum match_type | cmd_filter (char *command, vector v, unsigned int index, enum match_type level) |
static int | is_cmd_ambiguous (char *command, vector v, int index, enum match_type type) |
static const char * | cmd_entry_function (const char *src, const char *dst) |
static const char * | cmd_entry_function_desc (const char *src, const char *dst) |
static int | cmd_unique_string (vector v, const char *str) |
static int | desc_unique_string (vector v, const char *str) |
static int | cmd_try_do_shortcut (enum node_type node, char *first_word) |
static vector | cmd_describe_command_real (vector vline, struct vty *vty, int *status) |
vector | cmd_describe_command (vector vline, struct vty *vty, int *status) |
static int | cmd_lcd (char **matched) |
static char ** | cmd_complete_command_real (vector vline, struct vty *vty, int *status) |
char ** | cmd_complete_command (vector vline, struct vty *vty, int *status) |
static struct vty_parent_node * | vty_parent (struct vty *vty) |
static bool | vty_pop_parent (struct vty *vty) |
static void | vty_clear_parents (struct vty *vty) |
int | vty_go_parent (struct vty *vty) |
static int | cmd_execute_command_real (vector vline, struct vty *vty, struct cmd_element **cmd) |
int | cmd_execute_command (vector, struct vty *, struct cmd_element **, int) |
int | cmd_execute_command_strict (vector, struct vty *, struct cmd_element **) |
static size_t | len (const char *str) |
static int | indent_cmp (const char *a, const char *b) |
Make sure the common length of strings a and b is identical, then compare their lengths. More... | |
int | config_from_file (struct vty *, FILE *) |
DEFUN (config_terminal, config_terminal_cmd, "configure [terminal]", "Configuration from vty interface\n" "Configuration terminal\n") | |
DEFUN (enable, config_enable_cmd, "enable [expert-mode]", "Turn on privileged mode command\n" "Enable the expert mode (show hidden commands)\n") | |
DEFUN (disable, config_disable_cmd, "disable", "Turn off privileged mode command\n") | |
gDEFUN (config_exit, config_exit_cmd, "exit", "Exit current mode and down to previous mode\n") | |
gDEFUN (config_end, config_end_cmd, "end", "End current mode and change to enable mode.") | |
DEFUN (shutdown, shutdown_cmd, "shutdown", "Request a shutdown of the program\n") | |
DEFUN (show_version, show_version_cmd, "show version", SHOW_STR "Displays program version\n") | |
DEFUN (show_online_help, show_online_help_cmd, "show online-help", SHOW_STR "Online help\n") | |
DEFUN (show_pid, show_pid_cmd, "show pid", SHOW_STR "Displays the process ID\n") | |
DEFUN (show_uptime, show_uptime_cmd, "show uptime", SHOW_STR "Displays how long the program has been running\n") | |
gDEFUN (config_help, config_help_cmd, "help", "Description of the interactive help system\n") | |
static void | print_attr_list (struct vty *vty, unsigned int attr_mask) |
gDEFUN (show_vty_attr_all, show_vty_attr_all_cmd, "show vty-attributes", SHOW_STR "List of VTY attributes\n") | |
gDEFUN (show_vty_attr, show_vty_attr_cmd, "show vty-attributes (application|library|global)", SHOW_STR "List of VTY attributes\n" "Application specific attributes only\n" "Library specific attributes only\n" "Global attributes only\n") | |
static unsigned int | node_flag_mask (const struct cmd_node *cnode, bool expert_mode) |
static const char * | cmd_gflag_mask (const struct cmd_element *cmd) |
static const char * | cmd_flag_mask (const struct cmd_element *cmd, unsigned int flag_mask) |
gDEFUN (config_list, config_list_cmd, "list [with-flags]", "Print command list\n" "Also print the VTY attribute flags\n") | |
static int | write_config_file (const char *config_file, char **outpath) |
DEFUN (config_write_file, config_write_file_cmd, "write file [PATH]", "Write running configuration to memory, network, or terminal\n" "Write to configuration file\n" "Set file path to store the config, or replace if already exists\n") | |
ALIAS (config_write_file, config_write_cmd, "write", "Write running configuration to memory, network, or terminal\n") ALIAS(config_write_file | |
write Write running configuration to or terminal n Write configuration to the | file (same as write file)\n") ALIAS(config_write_file |
write Write running configuration to or terminal n Write configuration to the copy running config startup Copy configuration n Copy running config to n Copy running config to startup | config (same as write file)\n") DEFUN(config_write_terminal |
if (vty->type==VTY_SHELL_SERV) | |
vty_out (vty, "!%s", VTY_NEWLINE) | |
for (i=0;i< vector_active(cmdvec);i++) if((node | |
ALIAS (config_write_terminal, show_running_config_cmd, "show running-config", SHOW_STR "running configuration\n") | |
DEFUN (config_hostname, hostname_cmd, "hostname WORD", "Set system's network name\n" "This system's network name\n") | |
DEFUN (config_no_hostname, no_hostname_cmd, "no hostname [HOSTNAME]", NO_STR "Reset system's network name\n" "Host name of this router\n") | |
DEFUN (config_password, password_cmd, "password (8|) WORD", "Assign the terminal connection password\n" "Specifies a HIDDEN password will follow\n" "dummy string \n" "The HIDDEN line password string\n") | |
ALIAS (config_password, password_text_cmd, "password LINE", "Assign the terminal connection password\n" "The UNENCRYPTED (cleartext) line password\n") | |
ALIAS (config_enable_password, enable_password_text_cmd, "enable password LINE", "Modify enable password parameters\n" "Assign the privileged level password\n" "The UNENCRYPTED (cleartext) 'enable' password\n") | |
DEFUN (config_terminal_length, config_terminal_length_cmd, "terminal length <0-512>", "Set terminal line parameters\n" "Set number of lines on a screen\n" "Number of lines on screen (0 for no pausing)\n") | |
DEFUN (config_terminal_no_length, config_terminal_no_length_cmd, "terminal no length", "Set terminal line parameters\n" NO_STR "Set number of lines on a screen\n") | |
DEFUN (service_terminal_length, service_terminal_length_cmd, "service terminal-length <0-512>", "Set up miscellaneous service\n" "System wide terminal length configuration\n" "Number of lines of VTY (0 means no line control)\n") | |
DEFUN (no_service_terminal_length, no_service_terminal_length_cmd, "no service terminal-length [<0-512>]", NO_STR "Set up miscellaneous service\n" "System wide terminal length configuration\n" "Number of lines of VTY (0 means no line control)\n") | |
DEFUN_HIDDEN (do_echo, echo_cmd, "echo .MESSAGE", "Echo a message back to the vty\n" "The message to echo\n") | |
DEFUN (banner_motd_file, banner_motd_file_cmd, "banner motd file [FILE]", "Set banner\n" "Banner for motd\n" "Banner from a file\n" "Filename\n") | |
DEFUN (banner_motd_default, banner_motd_default_cmd, "banner motd default", "Set banner string\n" "Strings for motd\n" "Default string\n") | |
DEFUN (no_banner_motd, no_banner_motd_cmd, "no banner motd", NO_STR "Set banner string\n" "Strings for motd\n") | |
void | host_config_set (const char *) |
const char * | host_config_file (void) |
void | install_default (int node) |
Deprecated, now happens implicitly when calling install_node(). More... | |
void | vty_install_default (int node) |
Deprecated, now happens implicitly when calling install_node(). More... | |
int | osmo_vty_write_config_file (const char *filename) |
Write the current running config to a given file. More... | |
int | osmo_vty_save_config_file (void) |
Save the current state to the config file. More... | |
void | cmd_init (int) |
static | __attribute__ ((constructor)) |
Variables | |
void * | tall_vty_cmd_ctx |
static struct timespec | starttime |
vector | cmdvec |
struct host | host |
struct cmd_node | auth_node |
struct cmd_node | view_node |
struct cmd_node | auth_enable_node |
struct cmd_node | enable_node |
struct cmd_node | config_node |
const char * | default_motd = "" |
static const struct value_string | cmd_attr_desc [] |
static const char *const | cmd_lib_attr_desc [32] |
static const char | cmd_lib_attr_letters [32] |
const struct value_string | vty_ref_gen_mode_names [] |
const struct value_string | vty_ref_gen_mode_desc [] |
config_write_memory_cmd | |
write | memory |
write Write running configuration to | network |
write Write running configuration to or terminal n Write configuration to the | copy_runningconfig_startupconfig_cmd |
write Write running configuration to or terminal n Write configuration to the copy running config startup | config |
write Write running configuration to or terminal n Write configuration to the copy running config startup Copy configuration n Copy running config to n Copy running config to startup | config_write_terminal_cmd |
write Write running configuration to or terminal n Write configuration to the copy running config startup Copy configuration n Copy running config to n Copy running config to startup write | terminal |
write Write running configuration to or terminal n Write configuration to the copy running config startup Copy configuration n Copy running config to n Copy running config to startup write Write running configuration to or terminal n Write to terminal | n |
struct cmd_node * | node |
else | |
return | CMD_SUCCESS |
#define _XOPEN_SOURCE |
#define ADD | ( | out, | |
str | |||
) |
#define INIT_MATCHVEC_SIZE 10 |
#define INIT_MATCHVEC_SIZE 10 |
#define MAXPATHLEN 4096 |