command.c File Reference
VTY Command
`#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 <sys/time.h>`
`#include <sys/stat.h>`
`#include <osmocom/vty/vector.h>`
`#include <osmocom/vty/vty.h>`
`#include <osmocom/vty/command.h>`
`#include <osmocom/core/talloc.h>`
`#include <osmocom/core/utils.h>`

## Macros

#define | _XOPEN_SOURCE
#define | MAXPATHLEN 4096
#define | CONFIGFILE_MASK 022
#define | ADD(out, str)
#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 }

## 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 int | vty_dump_element (struct cmd_element *cmd, print_func_t print_func, void *data, const char *newline)
static bool | vty_command_is_common (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)
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 (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_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 | 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", "Turn on privileged mode command\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 (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")
| gDEFUN (config_help, config_help_cmd, "help", "Description of the interactive help system\n")
| gDEFUN (config_list, config_list_cmd, "list", "Print command list\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 *)
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)

## Variables

void * | tall_vty_cmd_ctx
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 = ""
| 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

## Macro Definition Documentation

## _XOPEN_SOURCE

#define _XOPEN_SOURCE

## ADD

#define ADD | ( |  | out,
|  |  | str
| ) |  |

Value:
for (j = 0; j < strlen(str); ++j) \
*(out++) = str[j];

## INIT_MATCHVEC_SIZE [1/2]

#define INIT_MATCHVEC_SIZE 10

## INIT_MATCHVEC_SIZE [2/2]

#define INIT_MATCHVEC_SIZE 10

## MAXPATHLEN

#define MAXPATHLEN 4096