diff options
author | hasso <hasso> | 2004-08-26 13:08:30 +0000 |
---|---|---|
committer | hasso <hasso> | 2004-08-26 13:08:30 +0000 |
commit | 95e735b54408177a8a6659da342f17d487dfeb2c (patch) | |
tree | 579aa332966e9c6d5b580d46ec40ab8fa3e158f0 /vtysh | |
parent | c89f64948d629a80d2ca87796a922172514e448f (diff) |
Vtysh cleanup part 2. No any functional changes yet except VTYSH_INTERFACE.
Diffstat (limited to 'vtysh')
-rw-r--r-- | vtysh/ChangeLog | 11 | ||||
-rw-r--r-- | vtysh/Makefile.am | 19 | ||||
-rw-r--r-- | vtysh/vtysh.c | 518 | ||||
-rw-r--r-- | vtysh/vtysh.h | 5 | ||||
-rw-r--r-- | vtysh/vtysh_config.c | 35 | ||||
-rw-r--r-- | vtysh/vtysh_main.c | 25 |
6 files changed, 314 insertions, 299 deletions
diff --git a/vtysh/ChangeLog b/vtysh/ChangeLog index db9f8051..e73317d4 100644 --- a/vtysh/ChangeLog +++ b/vtysh/ChangeLog @@ -1,3 +1,14 @@ +2004-08-26 Hasso Tepper <hasso@estpak.ee> + + * *.c: Cosmetical changes - strip long lines, fix multiline comments + style, indentation fixes, remove useless comments. + * vtysh.h: define VTYSH_INTERFACE. + * vtysh.c: Use VTYSH_INTERFACE where possible. Added some related TODO + items. + * vtysh.c: Move things around a little to reduce spaghetti mess. + * Makefile.am: Parse only needed files from zebra daemon while + building vtysh_cmd.c file to supress warnings. + 2004-06-30 Greg Troxel <gdt@poblano.ir.bbn.com> * extract.pl.in: Rename from extract.pl, with @PERL@. diff --git a/vtysh/Makefile.am b/vtysh/Makefile.am index 3467fad9..99513e97 100644 --- a/vtysh/Makefile.am +++ b/vtysh/Makefile.am @@ -21,11 +21,16 @@ EXTRA_DIST = extract.pl rebuild4: ./extract.pl $(top_srcdir)/zebra/*.c $(top_srcdir)/ripd/*.c $(top_srcdir)/ospfd/*.c $(top_srcdir)/bgpd/*.c $(top_srcdir)/isisd/*.c $(top_srcdir)/lib/keychain.c $(top_srcdir)/lib/routemap.c $(top_srcdir)/lib/filter.c $(top_srcdir)/lib/plist.c $(top_srcdir)/lib/distribute.c $(top_srcdir)/lib/if_rmap.c > vtysh_cmd.c -vtysh_cmd.c: $(top_srcdir)/zebra/*.c $(top_srcdir)/ripd/*.c $(top_srcdir)/ripngd/*.c $(top_srcdir)/ospfd/*.c \ - $(top_srcdir)/ospf6d/*.c $(top_srcdir)/bgpd/*.c $(top_srcdir)/isisd/*.c $(top_srcdir)/lib/keychain.c $(top_srcdir)/lib/routemap.c \ - $(top_srcdir)/lib/filter.c $(top_srcdir)/lib/plist.c $(top_srcdir)/lib/distribute.c $(top_srcdir)/lib/if_rmap.c - $(srcdir)/extract.pl $(top_srcdir)/zebra/*.c $(top_srcdir)/ripd/*.c $(top_srcdir)/ripngd/*.c $(top_srcdir)/ospfd/*.c \ - $(top_srcdir)/ospf6d/*.c $(top_srcdir)/isisd/*.c $(top_srcdir)/bgpd/*.c $(top_srcdir)/lib/keychain.c \ - $(top_srcdir)/lib/routemap.c $(top_srcdir)/lib/filter.c $(top_srcdir)/lib/plist.c $(top_srcdir)/lib/distribute.c \ - $(top_srcdir)/lib/if_rmap.c > vtysh_cmd.c +vtysh_cmd.c: $(top_srcdir)/ripd/*.c $(top_srcdir)/ripngd/*.c $(top_srcdir)/ospfd/*.c $(top_srcdir)/ospf6d/*.c \ + $(top_srcdir)/isisd/*.c $(top_srcdir)/bgpd/*.c $(top_srcdir)/lib/keychain.c $(top_srcdir)/lib/routemap.c \ + $(top_srcdir)/lib/filter.c $(top_srcdir)/lib/plist.c $(top_srcdir)/lib/distribute.c $(top_srcdir)/lib/if_rmap.c \ + $(top_srcdir)/zebra/debug.c $(top_srcdir)/zebra/interface.c $(top_srcdir)/zebra/irdp.c \ + $(top_srcdir)/zebra/irdp_interface.c $(top_srcdir)/zebra/rtadv.c $(top_srcdir)/zebra/zebra_vty.c \ + $(top_srcdir)/zebra/zserv.c + $(srcdir)/extract.pl $(top_srcdir)/ripd/*.c $(top_srcdir)/ripngd/*.c $(top_srcdir)/ospfd/*.c $(top_srcdir)/ospf6d/*.c \ + $(top_srcdir)/isisd/*.c $(top_srcdir)/bgpd/*.c $(top_srcdir)/lib/keychain.c $(top_srcdir)/lib/routemap.c \ + $(top_srcdir)/lib/filter.c $(top_srcdir)/lib/plist.c $(top_srcdir)/lib/distribute.c $(top_srcdir)/lib/if_rmap.c \ + $(top_srcdir)/zebra/debug.c $(top_srcdir)/zebra/interface.c $(top_srcdir)/zebra/irdp.c \ + $(top_srcdir)/zebra/irdp_interface.c $(top_srcdir)/zebra/rtadv.c $(top_srcdir)/zebra/zebra_vty.c \ + $(top_srcdir)/zebra/zserv.c > vtysh_cmd.c diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 169466ea..e8310d7c 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -46,139 +46,6 @@ struct vtysh_client int fd; } vtysh_client[VTYSH_INDEX_MAX]; -/* When '^Z' is received from vty, move down to the enable mode. */ -int -vtysh_end () -{ - switch (vty->node) - { - case VIEW_NODE: - case ENABLE_NODE: - /* Nothing to do. */ - break; - default: - vty->node = ENABLE_NODE; - break; - } - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - vtysh_end_all, - vtysh_end_all_cmd, - "end", - "End current mode and down to previous mode\n") -{ - return vtysh_end (vty); -} - -DEFUNSH (VTYSH_ALL, - vtysh_log_stdout, - vtysh_log_stdout_cmd, - "log stdout", - "Logging control\n" - "Logging goes to stdout\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - no_vtysh_log_stdout, - no_vtysh_log_stdout_cmd, - "no log stdout", - NO_STR - "Logging control\n" - "Logging goes to stdout\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - vtysh_log_file, - vtysh_log_file_cmd, - "log file FILENAME", - "Logging control\n" - "Logging to file\n" - "Logging filename\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - no_vtysh_log_file, - no_vtysh_log_file_cmd, - "no log file [FILENAME]", - NO_STR - "Logging control\n" - "Cancel logging to file\n" - "Logging file name\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - vtysh_log_syslog, - vtysh_log_syslog_cmd, - "log syslog", - "Logging control\n" - "Logging goes to syslog\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - no_vtysh_log_syslog, - no_vtysh_log_syslog_cmd, - "no log syslog", - NO_STR - "Logging control\n" - "Cancel logging to syslog\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - vtysh_log_trap, - vtysh_log_trap_cmd, - "log trap (emergencies|alerts|critical|errors|warnings|notifications|informational|debugging)", - "Logging control\n" - "Limit logging to specifed level\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - no_vtysh_log_trap, - no_vtysh_log_trap_cmd, - "no log trap", - NO_STR - "Logging control\n" - "Permit all logging information\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - vtysh_log_record_priority, - vtysh_log_record_priority_cmd, - "log record-priority", - "Logging control\n" - "Log the priority of the message within the message\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - no_vtysh_log_record_priority, - no_vtysh_log_record_priority_cmd, - "no log record-priority", - NO_STR - "Logging control\n" - "Do not log the priority of the message within the message\n") -{ - return CMD_SUCCESS; -} - void vclient_close (struct vtysh_client *vclient) { @@ -187,10 +54,8 @@ vclient_close (struct vtysh_client *vclient) vclient->fd = -1; } - /* Following filled with debug code to trace a problematic condition - under load - it SHOULD handle it. -*/ + * under load - it SHOULD handle it. */ #define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): " int vtysh_client_config (struct vtysh_client *vclient, char *line) @@ -215,8 +80,7 @@ vtysh_client_config (struct vtysh_client *vclient, char *line) return CMD_SUCCESS; } - /* Allow enough room for buffer to read more than a few pages from socket - */ + /* Allow enough room for buffer to read more than a few pages from socket. */ bufsz = 5 * getpagesize() + 1; buf = XMALLOC(MTYPE_TMP, bufsz); memset(buf, 0, bufsz); @@ -265,7 +129,7 @@ vtysh_client_config (struct vtysh_client *vclient, char *line) pbuf += nbytes; /* See if a line exists in buffer, if so parse and consume it, and - reset read position */ + * reset read position. */ if ((eoln = strrchr(buf, '\n')) == NULL) continue; @@ -283,7 +147,7 @@ vtysh_client_config (struct vtysh_client *vclient, char *line) pbuf = buf + strlen(buf); } - /* parse anything left in the buffer */ + /* Parse anything left in the buffer. */ vtysh_config_parse (buf); XFREE(MTYPE_TMP, buf); @@ -363,7 +227,7 @@ vtysh_execute_func (char *line, int pager) FILE *fp = NULL; int closepager=0; - /* Split readline string up into the vector */ + /* Split readline string up into the vector. */ vline = cmd_make_strvec (line); if (vline == NULL) @@ -412,17 +276,20 @@ vtysh_execute_func (char *line, int pager) cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_RIP], line, fp); if (cmd_stat != CMD_WARNING) - cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_RIPNG], line, fp); + cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_RIPNG], + line, fp); if (cmd_stat != CMD_WARNING) cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_OSPF], line, fp); if (cmd_stat != CMD_WARNING) - cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_OSPF6], line, fp); + cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_OSPF6], + line, fp); if (cmd_stat != CMD_WARNING) cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_BGP], line, fp); if (cmd_stat != CMD_WARNING) - cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_ISIS], line, fp); + cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_ISIS], + line, fp); if (cmd_stat) { line = "end"; @@ -523,14 +390,14 @@ vtysh_config_from_file (struct vty *vty, FILE *fp) vline = cmd_make_strvec (vty->buf); - /* In case of comment line */ + /* In case of comment line. */ if (vline == NULL) continue; - /* Execute configuration command : this is strict match */ + /* Execute configuration command : this is strict match. */ ret = cmd_execute_command_strict (vline, vty, &cmd); - /* Try again with setting node to CONFIG_NODE */ + /* Try again with setting node to CONFIG_NODE. */ if (ret != CMD_SUCCESS && ret != CMD_SUCCESS_DAEMON && ret != CMD_WARNING) @@ -700,9 +567,9 @@ vtysh_rl_describe () return 0; } -/* result of cmd_complete_command() call will be stored here - and used in new_completion() in order to put the space in - correct places only */ +/* Result of cmd_complete_command() call will be stored here + * and used in new_completion() in order to put the space in + * correct places only. */ int complete_status; char * @@ -778,26 +645,23 @@ vtysh_completion (char *text, int start, int end) return (char **) matched; } -/* BGP node structure. */ +/* Vty node structures. */ struct cmd_node bgp_node = { BGP_NODE, "%s(config-router)# ", }; -/* BGP node structure. */ struct cmd_node rip_node = { RIP_NODE, "%s(config-router)# ", }; -/* ISIS node structure. */ struct cmd_node isis_node = { ISIS_NODE, "%s(config-router)# ", - 1 }; struct cmd_node interface_node = @@ -806,6 +670,98 @@ struct cmd_node interface_node = "%s(config-if)# ", }; +struct cmd_node rmap_node = +{ + RMAP_NODE, + "%s(config-route-map)# " +}; + +struct cmd_node zebra_node = +{ + ZEBRA_NODE, + "%s(config-router)# " +}; + +struct cmd_node bgp_vpnv4_node = +{ + BGP_VPNV4_NODE, + "%s(config-router-af)# " +}; + +struct cmd_node bgp_ipv4_node = +{ + BGP_IPV4_NODE, + "%s(config-router-af)# " +}; + +struct cmd_node bgp_ipv4m_node = +{ + BGP_IPV4M_NODE, + "%s(config-router-af)# " +}; + +struct cmd_node bgp_ipv6_node = +{ + BGP_IPV6_NODE, + "%s(config-router-af)# " +}; + +struct cmd_node ospf_node = +{ + OSPF_NODE, + "%s(config-router)# " +}; + +struct cmd_node ripng_node = +{ + RIPNG_NODE, + "%s(config-router)# " +}; + +struct cmd_node ospf6_node = +{ + OSPF6_NODE, + "%s(config-ospf6)# " +}; + +struct cmd_node keychain_node = +{ + KEYCHAIN_NODE, + "%s(config-keychain)# " +}; + +struct cmd_node keychain_key_node = +{ + KEYCHAIN_KEY_NODE, + "%s(config-keychain-key)# " +}; + +/* When '^Z' is received from vty, move down to the enable mode. */ +int +vtysh_end () +{ + switch (vty->node) + { + case VIEW_NODE: + case ENABLE_NODE: + /* Nothing to do. */ + break; + default: + vty->node = ENABLE_NODE; + break; + } + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_ALL, + vtysh_end_all, + vtysh_end_all_cmd, + "end", + "End current mode and down to previous mode\n") +{ + return vtysh_end (vty); +} + DEFUNSH (VTYSH_BGPD, router_bgp, router_bgp_cmd, @@ -981,7 +937,6 @@ DEFUNSH (VTYSH_RMAP, return CMD_SUCCESS; } -/* Enable command */ DEFUNSH (VTYSH_ALL, vtysh_enable, vtysh_enable_cmd, @@ -992,7 +947,6 @@ DEFUNSH (VTYSH_ALL, return CMD_SUCCESS; } -/* Disable command */ DEFUNSH (VTYSH_ALL, vtysh_disable, vtysh_disable_cmd, @@ -1004,7 +958,6 @@ DEFUNSH (VTYSH_ALL, return CMD_SUCCESS; } -/* Configration from terminal */ DEFUNSH (VTYSH_ALL, vtysh_config_terminal, vtysh_config_terminal_cmd, @@ -1199,7 +1152,7 @@ ALIAS (vtysh_exit_isisd, "quit", "Exit current mode and down to previous mode\n") -DEFUNSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD, +DEFUNSH (VTYSH_INTERFACE, vtysh_interface, vtysh_interface_cmd, "interface IFNAME", @@ -1210,6 +1163,7 @@ DEFUNSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISIS return CMD_SUCCESS; } +/* TODO Implement "no interface command in isisd. */ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D, vtysh_no_interface_cmd, "no interface IFNAME", @@ -1217,6 +1171,8 @@ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D, "Delete a pseudo interface's configuration\n" "Interface's name\n") +/* TODO Implement interface description commands in ripngd, ospf6d + * and isisd. */ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD, interface_desc_cmd, "description .LINE", @@ -1229,7 +1185,7 @@ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD, NO_STR "Interface specific description\n") -DEFUNSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD, +DEFUNSH (VTYSH_INTERFACE, vtysh_exit_interface, vtysh_exit_interface_cmd, "exit", @@ -1243,6 +1199,115 @@ ALIAS (vtysh_exit_interface, "quit", "Exit current mode and down to previous mode\n") +/* Logging commands. */ +DEFUNSH (VTYSH_ALL, + vtysh_log_stdout, + vtysh_log_stdout_cmd, + "log stdout", + "Logging control\n" + "Logging goes to stdout\n") +{ + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_ALL, + no_vtysh_log_stdout, + no_vtysh_log_stdout_cmd, + "no log stdout", + NO_STR + "Logging control\n" + "Logging goes to stdout\n") +{ + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_ALL, + vtysh_log_file, + vtysh_log_file_cmd, + "log file FILENAME", + "Logging control\n" + "Logging to file\n" + "Logging filename\n") +{ + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_ALL, + no_vtysh_log_file, + no_vtysh_log_file_cmd, + "no log file [FILENAME]", + NO_STR + "Logging control\n" + "Cancel logging to file\n" + "Logging file name\n") +{ + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_ALL, + vtysh_log_syslog, + vtysh_log_syslog_cmd, + "log syslog", + "Logging control\n" + "Logging goes to syslog\n") +{ + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_ALL, + no_vtysh_log_syslog, + no_vtysh_log_syslog_cmd, + "no log syslog", + NO_STR + "Logging control\n" + "Cancel logging to syslog\n") +{ + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_ALL, + vtysh_log_trap, + vtysh_log_trap_cmd, + "log trap (emergencies|alerts|critical|errors|warnings|\ + notifications|informational|debugging)", + "Logging control\n" + "Limit logging to specifed level\n") +{ + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_ALL, + no_vtysh_log_trap, + no_vtysh_log_trap_cmd, + "no log trap", + NO_STR + "Logging control\n" + "Permit all logging information\n") +{ + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_ALL, + vtysh_log_record_priority, + vtysh_log_record_priority_cmd, + "log record-priority", + "Logging control\n" + "Log the priority of the message within the message\n") +{ + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_ALL, + no_vtysh_log_record_priority, + no_vtysh_log_record_priority_cmd, + "no log record-priority", + NO_STR + "Logging control\n" + "Do not log the priority of the message within the message\n") +{ + return CMD_SUCCESS; +} + DEFUN (vtysh_write_terminal, vtysh_write_terminal_cmd, "write terminal", @@ -1305,28 +1370,26 @@ DEFUN (vtysh_write_config, "write-config (daemon|integrated)", "Specify config files to write to\n" "Write per daemon file\n" - "Write integrated file\n" - ) + "Write integrated file\n") { - if (!strncmp(argv[0],"d",1)) { - vtysh_wc.daemon = 1; - } else if (!strncmp(argv[0],"i",1)) { - vtysh_wc.integrated = 1; - } + if (!strncmp(argv[0],"d",1)) + vtysh_wc.daemon = 1; + else if (!strncmp(argv[0],"i",1)) + vtysh_wc.integrated = 1; + return CMD_SUCCESS; } DEFUN (no_vtysh_write_config, no_vtysh_write_config_cmd, "no write-config (daemon|integrated)", - "Negate per daemon and/or integrated config files\n" - ) + "Negate per daemon and/or integrated config files\n") { - if (!strncmp(argv[0],"d",1)) { - vtysh_wc.daemon = 0; - } else if (!strncmp(argv[0],"i",1)) { - vtysh_wc.integrated = 0; - } + if (!strncmp(argv[0],"d",1)) + vtysh_wc.daemon = 0; + else if (!strncmp(argv[0],"i",1)) + vtysh_wc.integrated = 0; + return CMD_SUCCESS; } @@ -1337,23 +1400,23 @@ int write_config_integrated(void) FILE *fp; char *integrate_sav = NULL; - integrate_sav = malloc (strlen (integrate_default) - + strlen (CONF_BACKUP_EXT) + 1); + integrate_sav = malloc (strlen (integrate_default) + + strlen (CONF_BACKUP_EXT) + 1); strcpy (integrate_sav, integrate_default); strcat (integrate_sav, CONF_BACKUP_EXT); - fprintf (stdout,"Building Configuration...\n"); - /* Move current configuration file to backup config file */ + /* Move current configuration file to backup config file. */ unlink (integrate_sav); rename (integrate_default, integrate_sav); - free (integrate_sav); + free (integrate_sav); fp = fopen (integrate_default, "w"); if (fp == NULL) { - fprintf (stdout,"%% Can't open configuration file %s.\n", integrate_default); + fprintf (stdout,"%% Can't open configuration file %s.\n", + integrate_default); return CMD_SUCCESS; } @@ -1394,14 +1457,12 @@ DEFUN (vtysh_write_memory, int ret = CMD_SUCCESS; char line[] = "write memory\n"; - /* if integrated Zebra.conf explicitely set */ - if (vtysh_wc.integrated == 1) { - ret = write_config_integrated(); - } + /* If integrated Zebra.conf explicitely set. */ + if (vtysh_wc.integrated == 1) + ret = write_config_integrated(); - if (!vtysh_wc.daemon) { - return ret; - } + if (!vtysh_wc.daemon) + return ret; fprintf (stdout,"Building Configuration...\n"); @@ -1607,76 +1668,6 @@ DEFUN (vtysh_start_zsh, return CMD_SUCCESS; } -/* Route map node structure. */ -struct cmd_node rmap_node = -{ - RMAP_NODE, - "%s(config-route-map)# " -}; - -/* Zebra node structure. */ -struct cmd_node zebra_node = -{ - ZEBRA_NODE, - "%s(config-router)# " -}; - -struct cmd_node bgp_vpnv4_node = -{ - BGP_VPNV4_NODE, - "%s(config-router-af)# " -}; - -struct cmd_node bgp_ipv4_node = -{ - BGP_IPV4_NODE, - "%s(config-router-af)# " -}; - -struct cmd_node bgp_ipv4m_node = -{ - BGP_IPV4M_NODE, - "%s(config-router-af)# " -}; - -struct cmd_node bgp_ipv6_node = -{ - BGP_IPV6_NODE, - "%s(config-router-af)# " -}; - -struct cmd_node ospf_node = -{ - OSPF_NODE, - "%s(config-router)# " -}; - -/* RIPng node structure. */ -struct cmd_node ripng_node = -{ - RIPNG_NODE, - "%s(config-router)# " -}; - -/* OSPF6 node structure. */ -struct cmd_node ospf6_node = -{ - OSPF6_NODE, - "%s(config-ospf6)# " -}; - -struct cmd_node keychain_node = -{ - KEYCHAIN_NODE, - "%s(config-keychain)# " -}; - -struct cmd_node keychain_key_node = -{ - KEYCHAIN_KEY_NODE, - "%s(config-keychain-key)# " -}; - void vtysh_install_default (enum node_type node) { @@ -1723,7 +1714,8 @@ vtysh_connect (struct vtysh_client *vclient, char *path) if (sock < 0) { #ifdef DEBUG - fprintf(stderr, "vtysh_connect(%s): socket = %s\n", path, strerror(errno)); + fprintf(stderr, "vtysh_connect(%s): socket = %s\n", path, + strerror(errno)); #endif /* DEBUG */ return -1; } @@ -1741,7 +1733,8 @@ vtysh_connect (struct vtysh_client *vclient, char *path) if (ret < 0) { #ifdef DEBUG - fprintf(stderr, "vtysh_connect(%s): connect = %s\n", path, strerror(errno)); + fprintf(stderr, "vtysh_connect(%s): connect = %s\n", path, + strerror(errno)); #endif /* DEBUG */ close (sock); return -1; @@ -1764,8 +1757,7 @@ vtysh_connect_all() vtysh_connect (&vtysh_client[VTYSH_INDEX_ISIS], ISIS_VTYSH_PATH); } - -/* To disable readline's filename completion */ +/* To disable readline's filename completion. */ char * vtysh_completion_entry_function (const char *ignore, int invoking_key) { @@ -1780,7 +1772,7 @@ vtysh_readline_init () rl_completion_entry_function = vtysh_completion_entry_function; rl_attempted_completion_function = (CPPFunction *)new_completion; /* do not append space after completion. It will be appended - in new_completion() function explicitly */ + * in new_completion() function explicitly. */ rl_completion_append_character = '\0'; } @@ -1950,7 +1942,7 @@ vtysh_init_vty () install_element (ENABLE_NODE, &vtysh_write_file_cmd); install_element (ENABLE_NODE, &vtysh_write_cmd); - /* write terminal command */ + /* "write terminal" command. */ install_element (ENABLE_NODE, &vtysh_write_terminal_cmd); install_element (CONFIG_NODE, &vtysh_write_terminal_cmd); install_element (BGP_NODE, &vtysh_write_terminal_cmd); @@ -1968,7 +1960,7 @@ vtysh_init_vty () install_element (KEYCHAIN_NODE, &vtysh_write_terminal_cmd); install_element (KEYCHAIN_KEY_NODE, &vtysh_write_terminal_cmd); - /* write memory command */ + /* "write memory" command. */ install_element (ENABLE_NODE, &vtysh_write_memory_cmd); install_element (CONFIG_NODE, &vtysh_write_memory_cmd); install_element (BGP_NODE, &vtysh_write_memory_cmd); diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h index 5ccf41af..abfb3ec4 100644 --- a/vtysh/vtysh.h +++ b/vtysh/vtysh.h @@ -29,8 +29,9 @@ #define VTYSH_OSPF6D 0x10 #define VTYSH_BGPD 0x20 #define VTYSH_ISISD 0x40 -#define VTYSH_ALL VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD -#define VTYSH_RMAP VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD +#define VTYSH_ALL VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD +#define VTYSH_RMAP VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD +#define VTYSH_INTERFACE VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD #define VTYSH_INDEX_ZEBRA 0 #define VTYSH_INDEX_RIP 1 diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index 9a0bff49..f518653f 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -44,7 +44,7 @@ struct config }; struct list *config_top; - + int line_cmp (char *c1, char *c2) { @@ -164,13 +164,17 @@ vtysh_config_parse_line (char *line) /* Store line to current configuration. */ if (config) { - if (strncmp (line, " address-family vpnv4", strlen (" address-family vpnv4")) == 0) + if (strncmp (line, " address-family vpnv4", + strlen (" address-family vpnv4")) == 0) config = config_get (BGP_VPNV4_NODE, line); - else if (strncmp (line, " address-family ipv4 multicast", strlen (" address-family ipv4 multicast")) == 0) + else if (strncmp (line, " address-family ipv4 multicast", + strlen (" address-family ipv4 multicast")) == 0) config = config_get (BGP_IPV4M_NODE, line); - else if (strncmp (line, " address-family ipv6", strlen (" address-family ipv6")) == 0) + else if (strncmp (line, " address-family ipv6", + strlen (" address-family ipv6")) == 0) config = config_get (BGP_IPV6_NODE, line); - else if (config->index == RMAP_NODE || config->index == INTERFACE_NODE ) + else if (config->index == RMAP_NODE || + config->index == INTERFACE_NODE ) config_add_line_uniq (config->line, line); else config_add_line (config->line, line); @@ -199,15 +203,20 @@ vtysh_config_parse_line (char *line) config = config_get (RMAP_NODE, line); else if (strncmp (line, "access-list", strlen ("access-list")) == 0) config = config_get (ACCESS_NODE, line); - else if (strncmp (line, "ipv6 access-list", strlen ("ipv6 access-list")) == 0) + else if (strncmp (line, "ipv6 access-list", + strlen ("ipv6 access-list")) == 0) config = config_get (ACCESS_IPV6_NODE, line); - else if (strncmp (line, "ip prefix-list", strlen ("ip prefix-list")) == 0) + else if (strncmp (line, "ip prefix-list", + strlen ("ip prefix-list")) == 0) config = config_get (PREFIX_NODE, line); - else if (strncmp (line, "ipv6 prefix-list", strlen ("ipv6 prefix-list")) == 0) + else if (strncmp (line, "ipv6 prefix-list", + strlen ("ipv6 prefix-list")) == 0) config = config_get (PREFIX_IPV6_NODE, line); - else if (strncmp (line, "ip as-path access-list", strlen ("ip as-path access-list")) == 0) + else if (strncmp (line, "ip as-path access-list", + strlen ("ip as-path access-list")) == 0) config = config_get (AS_LIST_NODE, line); - else if (strncmp (line, "ip community-list", strlen ("ip community-list")) == 0) + else if (strncmp (line, "ip community-list", + strlen ("ip community-list")) == 0) config = config_get (COMMUNITY_LIST_NODE, line); else if (strncmp (line, "ip route", strlen ("ip route")) == 0) config = config_get (IP_NODE, line); @@ -253,13 +262,13 @@ vtysh_config_parse (char *line) } /* Macro to check delimiter is needed between each configuration line - or not. */ + * or not. */ #define NO_DELIMITER(I) \ ((I) == ACCESS_NODE || (I) == PREFIX_NODE || (I) == IP_NODE \ || (I) == AS_LIST_NODE || (I) == COMMUNITY_LIST_NODE || \ (I) == ACCESS_IPV6_NODE || (I) == PREFIX_IPV6_NODE) -/* Display configuration to file pointer. */ +/* Display configuration to file pointer. */ void vtysh_config_dump (FILE *fp) { @@ -328,7 +337,7 @@ vtysh_read_file (FILE *confp) vtysh_execute_no_pager ("enable"); vtysh_execute_no_pager ("configure terminal"); - /* Execute configuration file */ + /* Execute configuration file. */ ret = vtysh_config_from_file (vty, confp); vtysh_execute_no_pager ("end"); diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 0d2808e9..69a5358e 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -40,7 +40,7 @@ char *progname; /* Configuration file name. Usually this is configurable, but vtysh - has static configuration file only. */ + * has static configuration file only. */ char *config_file = NULL; /* Configuration file and directory. */ @@ -142,15 +142,13 @@ usage (int status) if (status != 0) fprintf (stderr, "Try `%s --help' for more information.\n", progname); else - { - printf ("Usage : %s [OPTION...]\n\n\ -Integrated shell for Quagga routing software suite. \n\n\ --b, --boot Execute boot startup configuration\n\ --c, --command Execute argument as command\n\ --h, --help Display this help and exit\n\ -\n\ -Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); - } + printf ("Usage : %s [OPTION...]\n\n" \ + "Integrated shell for Quagga routing software suite. \n\n"\ + "-b, --boot Execute boot startup configuration\n" \ + "-c, --command Execute argument as command\n "\ + "-h, --help Display this help and exit\n\n" \ + "Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); + exit (status); } @@ -171,7 +169,7 @@ vtysh_rl_gets () { HIST_ENTRY *last; /* If the buffer has already been allocated, return the memory - to the free pool. */ + * to the free pool. */ if (line_read) { free (line_read); @@ -182,8 +180,7 @@ vtysh_rl_gets () line_read = readline (vtysh_prompt ()); /* If the line has any text in it, save it on the history. But only if - * last command in history isn't the same one. - */ + * last command in history isn't the same one. */ if (line_read && *line_read) { using_history(); @@ -261,7 +258,7 @@ main (int argc, char **argv, char **env) /* Read vtysh configuration file. */ vtysh_read_config (config_file, config_current, config_default); - /* If eval mode */ + /* If eval mode. */ if (eval_flag) { vtysh_execute_no_pager (eval_line); |