libosmovty  0.9.3
Osmocom VTY library
src/vty/command.c File Reference
#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 <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>

Defines

#define _XOPEN_SOURCE
#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 DECIMAL_STRLEN_MAX   10
#define INIT_MATCHVEC_SIZE   10
#define INIT_MATCHVEC_SIZE   10

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
char * argv_concat (const char **argv, int argc, int shift)
void install_node (struct cmd_node *node, int(*func)(struct vty *))
 Install top node of command vector.
static int cmp_node (const void *p, const void *q)
static int cmp_desc (const void *p, const void *q)
static int is_config_child (struct vty *vty)
void sort_node (void)
 Sort each node's command element according to command string.
vector cmd_make_strvec (const char *)
void cmd_free_strvec (vector v)
 Free allocated string vector.
static char * cmd_desc_str (const char **string)
 Fetch next description. Used in cmd_make_descvec().
static vector cmd_make_descvec (const char *string, const char *descstr)
 New string vector.
static int cmd_cmdsize (vector strvec)
const char * cmd_prompt (enum node_type node)
 Return prompt character of specified node.
static char * xml_escape (const char *inp)
static int vty_dump_element (struct cmd_element *cmd, struct vty *vty)
static int vty_dump_nodes (struct vty *vty)
void install_element (int ntype, struct cmd_element *cmd)
 Install a command into a node.
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 (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)
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 **)
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","Write running configuration to memory, network, or terminal\n""Write to configuration file\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

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

Detailed Description


Define Documentation

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