int fd;
} vtysh_client[VTYSH_INDEX_MAX];
+/* Using integrated config from Quagga.conf. Default is no. */
+int vtysh_writeconfig_integrated = 0;
+
+extern char config_default[];
+
void
vclient_close (struct vtysh_client *vclient)
{
}
/* Parse anything left in the buffer. */
+
vtysh_config_parse (buf);
XFREE(MTYPE_TMP, buf);
"%s(config-keychain-key)# "
};
+/* Defined in lib/vty.c */
+extern struct cmd_node vty_node;
+
/* When '^Z' is received from vty, move down to the enable mode. */
int
vtysh_end ()
vtysh_end_all,
vtysh_end_all_cmd,
"end",
- "End current mode and down to previous mode\n")
+ "End current mode and change to enable mode\n")
{
return vtysh_end ();
}
return CMD_SUCCESS;
}
+DEFUNSH (VTYSH_ALL,
+ vtysh_line_vty,
+ vtysh_line_vty_cmd,
+ "line vty",
+ "Configure a terminal line\n"
+ "Virtual terminal\n")
+{
+ vty->node = VTY_NODE;
+ return CMD_SUCCESS;
+}
+
DEFUNSH (VTYSH_ALL,
vtysh_enable,
vtysh_enable_cmd,
"quit",
"Exit current mode and down to previous mode\n")
+DEFUNSH (VTYSH_ALL,
+ vtysh_exit_line_vty,
+ vtysh_exit_line_vty_cmd,
+ "exit",
+ "Exit current mode and down to previous mode\n")
+{
+ return vtysh_exit (vty);
+}
+
+ALIAS (vtysh_exit_line_vty,
+ vtysh_quit_line_vty_cmd,
+ "quit",
+ "Exit current mode and down to previous mode\n")
+
DEFUNSH (VTYSH_INTERFACE,
vtysh_interface,
vtysh_interface_cmd,
return CMD_SUCCESS;
}
+DEFUNSH (VTYSH_ALL,
+ vtysh_service_password_encrypt,
+ vtysh_service_password_encrypt_cmd,
+ "service password-encryption",
+ "Set up miscellaneous service\n"
+ "Enable encrypted passwords\n")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH (VTYSH_ALL,
+ no_vtysh_service_password_encrypt,
+ no_vtysh_service_password_encrypt_cmd,
+ "no service password-encryption",
+ NO_STR
+ "Set up miscellaneous service\n"
+ "Enable encrypted passwords\n")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH (VTYSH_ALL,
+ vtysh_config_password,
+ vtysh_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")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH (VTYSH_ALL,
+ vtysh_password_text,
+ vtysh_password_text_cmd,
+ "password LINE",
+ "Assign the terminal connection password\n"
+ "The UNENCRYPTED (cleartext) line password\n")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH (VTYSH_ALL,
+ vtysh_config_enable_password,
+ vtysh_enable_password_cmd,
+ "enable password (8|) WORD",
+ "Modify enable password parameters\n"
+ "Assign the privileged level password\n"
+ "Specifies a HIDDEN password will follow\n"
+ "dummy string \n"
+ "The HIDDEN 'enable' password string\n")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH (VTYSH_ALL,
+ vtysh_enable_password_text,
+ vtysh_enable_password_text_cmd,
+ "enable password LINE",
+ "Modify enable password parameters\n"
+ "Assign the privileged level password\n"
+ "The UNENCRYPTED (cleartext) 'enable' password\n")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH (VTYSH_ALL,
+ no_vtysh_config_enable_password,
+ no_vtysh_enable_password_cmd,
+ "no enable password",
+ NO_STR
+ "Modify enable password parameters\n"
+ "Assign the privileged level password\n")
+{
+ return CMD_SUCCESS;
+}
+
DEFUN (vtysh_write_terminal,
vtysh_write_terminal_cmd,
"write terminal",
vty_out (vty, "Building configuration...%s", VTY_NEWLINE);
vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE,
VTY_NEWLINE);
-
- vtysh_config_write (fp);
+ vty_out (vty, "!%s", VTY_NEWLINE);
ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_ZEBRA], line);
ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_RIP], line);
ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_BGP], line);
ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_ISIS], line);
+ /* Integrate vtysh specific configuration. */
+ vtysh_config_write ();
+
vtysh_config_dump (fp);
if (vtysh_pager_name && fp)
return CMD_SUCCESS;
}
-struct vtysh_writeconfig_t {
- int daemon;
- int integrated;
-} vtysh_wc = {-1,0};
-
-DEFUN (vtysh_write_config,
- vtysh_write_config_cmd,
- "write-config (daemon|integrated)",
- "Specify config files to write to\n"
- "Write per daemon file\n"
- "Write integrated file\n")
+DEFUN (vtysh_integrated_config,
+ vtysh_integrated_config_cmd,
+ "service integrated-vtysh-config",
+ "Set up miscellaneous service\n"
+ "Write configuration into integrated file\n")
{
- if (!strncmp(argv[0],"d",1))
- vtysh_wc.daemon = 1;
- else if (!strncmp(argv[0],"i",1))
- vtysh_wc.integrated = 1;
-
- return CMD_SUCCESS;
+ vtysh_writeconfig_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")
+DEFUN (no_vtysh_integrated_config,
+ no_vtysh_integrated_config_cmd,
+ "no service integrated-vtysh-config",
+ NO_STR
+ "Set up miscellaneous service\n"
+ "Write configuration into integrated file\n")
{
- if (!strncmp(argv[0],"d",1))
- vtysh_wc.daemon = 0;
- else if (!strncmp(argv[0],"i",1))
- vtysh_wc.integrated = 0;
-
- return CMD_SUCCESS;
+ vtysh_writeconfig_integrated = 0;
+ return CMD_SUCCESS;
}
int write_config_integrated(void)
return CMD_SUCCESS;
}
- vtysh_config_write (fp);
-
ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_ZEBRA], line);
ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_RIP], line);
ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_RIPNG], line);
{
int ret = CMD_SUCCESS;
char line[] = "write memory\n";
+ char *vtysh_conf;
+ extern struct host host;
+ FILE *fp;
- /* If integrated Zebra.conf explicitely set. */
- if (vtysh_wc.integrated == 1)
- ret = write_config_integrated();
-
- if (!vtysh_wc.daemon)
- return ret;
+ /* If integrated Quagga.conf explicitely set. */
+ if (vtysh_writeconfig_integrated)
+ return write_config_integrated();
fprintf (stdout,"Building Configuration...\n");
ret = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_OSPF6], line, stdout);
ret = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_BGP], line, stdout);
ret = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_ISIS], line, stdout);
-
+
fprintf (stdout,"[OK]\n");
return ret;
return CMD_SUCCESS;
}
+DEFUN (vtysh_show_running_daemons,
+ vtysh_show_running_daemons_cmd,
+ "show running-daemons",
+ SHOW_STR
+ "Show list of running daemons\n")
+{
+ if ( vtysh_client[VTYSH_INDEX_ZEBRA].fd > 0 )
+ vty_out(vty, " zebra");
+ if ( vtysh_client[VTYSH_INDEX_RIP].fd > 0 )
+ vty_out(vty, " ripd");
+ if ( vtysh_client[VTYSH_INDEX_RIPNG].fd > 0 )
+ vty_out(vty, " ripngd");
+ if ( vtysh_client[VTYSH_INDEX_OSPF].fd > 0 )
+ vty_out(vty, " ospfd");
+ if ( vtysh_client[VTYSH_INDEX_OSPF6].fd > 0 )
+ vty_out(vty, " ospf6d");
+ if ( vtysh_client[VTYSH_INDEX_BGP].fd > 0 )
+ vty_out(vty, " bgpd");
+ if ( vtysh_client[VTYSH_INDEX_ISIS].fd > 0 )
+ vty_out(vty, " isisd");
+ vty_out(vty, "%s", VTY_NEWLINE);
+
+ return CMD_SUCCESS;
+}
+
/* Execute command in child process. */
int
execute_command (char *command, int argc, char *arg1, char *arg2)
install_node (&keychain_node, NULL);
install_node (&keychain_key_node, NULL);
install_node (&isis_node, NULL);
+ install_node (&vty_node, NULL);
vtysh_install_default (VIEW_NODE);
vtysh_install_default (ENABLE_NODE);
vtysh_install_default (ISIS_NODE);
vtysh_install_default (KEYCHAIN_NODE);
vtysh_install_default (KEYCHAIN_KEY_NODE);
+ vtysh_install_default (VTY_NODE);
install_element (VIEW_NODE, &vtysh_enable_cmd);
install_element (ENABLE_NODE, &vtysh_config_terminal_cmd);
install_element (KEYCHAIN_KEY_NODE, &vtysh_quit_ripd_cmd);
install_element (RMAP_NODE, &vtysh_exit_rmap_cmd);
install_element (RMAP_NODE, &vtysh_quit_rmap_cmd);
+ install_element (VTY_NODE, &vtysh_exit_line_vty_cmd);
+ install_element (VTY_NODE, &vtysh_quit_line_vty_cmd);
/* "end" command. */
install_element (CONFIG_NODE, &vtysh_end_all_cmd);
install_element (KEYCHAIN_NODE, &vtysh_end_all_cmd);
install_element (KEYCHAIN_KEY_NODE, &vtysh_end_all_cmd);
install_element (RMAP_NODE, &vtysh_end_all_cmd);
+ install_element (VTY_NODE, &vtysh_end_all_cmd);
install_element (INTERFACE_NODE, &interface_desc_cmd);
install_element (INTERFACE_NODE, &no_interface_desc_cmd);
install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
install_element (CONFIG_NODE, &key_chain_cmd);
install_element (CONFIG_NODE, &route_map_cmd);
+ install_element (CONFIG_NODE, &vtysh_line_vty_cmd);
install_element (KEYCHAIN_NODE, &key_cmd);
install_element (KEYCHAIN_NODE, &key_chain_cmd);
install_element (KEYCHAIN_KEY_NODE, &key_chain_cmd);
/* "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);
- install_element (BGP_VPNV4_NODE, &vtysh_write_terminal_cmd);
- install_element (BGP_IPV4_NODE, &vtysh_write_terminal_cmd);
- install_element (BGP_IPV4M_NODE, &vtysh_write_terminal_cmd);
- install_element (BGP_IPV6_NODE, &vtysh_write_terminal_cmd);
- install_element (RIP_NODE, &vtysh_write_terminal_cmd);
- install_element (RIPNG_NODE, &vtysh_write_terminal_cmd);
- install_element (OSPF_NODE, &vtysh_write_terminal_cmd);
- install_element (OSPF6_NODE, &vtysh_write_terminal_cmd);
- install_element (ISIS_NODE, &vtysh_write_terminal_cmd);
- install_element (INTERFACE_NODE, &vtysh_write_terminal_cmd);
- install_element (RMAP_NODE, &vtysh_write_terminal_cmd);
- install_element (KEYCHAIN_NODE, &vtysh_write_terminal_cmd);
- install_element (KEYCHAIN_KEY_NODE, &vtysh_write_terminal_cmd);
+
+ install_element (CONFIG_NODE, &vtysh_integrated_config_cmd);
+ install_element (CONFIG_NODE, &no_vtysh_integrated_config_cmd);
/* "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);
- install_element (BGP_VPNV4_NODE, &vtysh_write_memory_cmd);
- install_element (BGP_IPV4_NODE, &vtysh_write_memory_cmd);
- install_element (BGP_IPV4M_NODE, &vtysh_write_memory_cmd);
- install_element (BGP_IPV6_NODE, &vtysh_write_memory_cmd);
- install_element (RIP_NODE, &vtysh_write_memory_cmd);
- install_element (RIPNG_NODE, &vtysh_write_memory_cmd);
- install_element (OSPF_NODE, &vtysh_write_memory_cmd);
- install_element (OSPF6_NODE, &vtysh_write_memory_cmd);
- install_element (ISIS_NODE, &vtysh_write_memory_cmd);
- install_element (INTERFACE_NODE, &vtysh_write_memory_cmd);
- install_element (RMAP_NODE, &vtysh_write_memory_cmd);
- install_element (KEYCHAIN_NODE, &vtysh_write_memory_cmd);
- install_element (KEYCHAIN_KEY_NODE, &vtysh_write_memory_cmd);
install_element (VIEW_NODE, &vtysh_terminal_length_cmd);
install_element (ENABLE_NODE, &vtysh_terminal_length_cmd);
install_element (VIEW_NODE, &vtysh_terminal_no_length_cmd);
install_element (ENABLE_NODE, &vtysh_terminal_no_length_cmd);
+ install_element (VIEW_NODE, &vtysh_show_running_daemons_cmd);
+ install_element (ENABLE_NODE, &vtysh_show_running_daemons_cmd);
install_element (VIEW_NODE, &vtysh_ping_cmd);
install_element (VIEW_NODE, &vtysh_ping_ip_cmd);
install_element (CONFIG_NODE, &no_vtysh_log_trap_cmd);
install_element (CONFIG_NODE, &vtysh_log_record_priority_cmd);
install_element (CONFIG_NODE, &no_vtysh_log_record_priority_cmd);
- install_element (CONFIG_NODE, &vtysh_write_config_cmd);
- install_element (CONFIG_NODE, &no_vtysh_write_config_cmd);
+
+ install_element (CONFIG_NODE, &vtysh_service_password_encrypt_cmd);
+ install_element (CONFIG_NODE, &no_vtysh_service_password_encrypt_cmd);
+
+ install_element (CONFIG_NODE, &vtysh_password_cmd);
+ install_element (CONFIG_NODE, &vtysh_password_text_cmd);
+ install_element (CONFIG_NODE, &vtysh_enable_password_cmd);
+ install_element (CONFIG_NODE, &vtysh_enable_password_text_cmd);
+ install_element (CONFIG_NODE, &no_vtysh_enable_password_cmd);
+
}
vector configvec;
+extern int vtysh_writeconfig_integrated;
+
struct config
{
/* Configuration node name. */
strlen (" address-family ipv6")) == 0)
config = config_get (BGP_IPV6_NODE, line);
else if (config->index == RMAP_NODE ||
- config->index == INTERFACE_NODE )
+ config->index == INTERFACE_NODE ||
+ config->index == VTY_NODE)
config_add_line_uniq (config->line, line);
else
config_add_line (config->line, line);
config = config_get (IP_NODE, line);
else if (strncmp (line, "key", strlen ("key")) == 0)
config = config_get (KEYCHAIN_NODE, line);
+ else if (strncmp (line, "line", strlen ("line")) == 0)
+ config = config_get (VTY_NODE, line);
+ else if ( (strncmp (line, "ipv6 forwarding",
+ strlen ("ipv6 forwarding")) == 0)
+ || (strncmp (line, "ip forwarding",
+ strlen ("ip forwarding")) == 0) )
+ config = config_get (FORWARDING_NODE, line);
+ else if (strncmp (line, "service", strlen ("service")) == 0)
+ config = config_get (SERVICE_NODE, line);
else
{
if (strncmp (line, "log", strlen ("log")) == 0
|| strncmp (line, "hostname", strlen ("hostname")) == 0
|| strncmp (line, "password", strlen ("password")) == 0
|| strncmp (line, "enable password",
- strlen ("enable password")) == 0)
+ strlen ("enable password")) == 0
+ || strncmp (line, "service", strlen ("service")) == 0
+ )
config_add_line_uniq (config_top, line);
else
config_add_line (config_top, line);
#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)
+ (I) == ACCESS_IPV6_NODE || (I) == PREFIX_IPV6_NODE \
+ || (I) == SERVICE_NODE)
/* Display configuration to file pointer. */
void
}
}
-/* Read up configuration file from file_name. */
-void
-vtysh_read_config (char *config_file,
- char *config_default_dir)
+/* Read up configuration file from config_default_dir. */
+int
+vtysh_read_config (char *config_default_dir)
{
- char *cwd;
FILE *confp = NULL;
- char *fullpath;
- /* If -f flag specified. */
- if (config_file != NULL)
- {
- if (! IS_DIRECTORY_SEP (config_file[0]))
- {
- cwd = getcwd (NULL, MAXPATHLEN);
- fullpath = XMALLOC (MTYPE_TMP,
- strlen (cwd) + strlen (config_file) + 2);
- sprintf (fullpath, "%s/%s", cwd, config_file);
- }
- else
- fullpath = config_file;
-
- confp = fopen (fullpath, "r");
-
- if (confp == NULL)
- {
- fprintf (stderr, "can't open configuration file [%s]\n",
- config_file);
- exit(1);
- }
- }
- else
- {
- /* No configuration specified from command line. Open system
- * default file. */
- confp = fopen (config_default_dir, "r");
- if (confp == NULL)
- {
- fprintf (stderr, "can't open configuration file [%s]\n",
- config_default_dir);
- exit (1);
- }
- else
- fullpath = config_default_dir;
- }
+ confp = fopen (config_default_dir, "r");
+ if (confp == NULL)
+ return (1);
vtysh_read_file (confp);
-
fclose (confp);
+ host_config_set (config_default_dir);
- host_config_set (fullpath);
+ return (0);
}
+/* We don't write vtysh specific into file from vtysh. vtysh.conf should
+ * be edited by hand. So, we handle only "write terminal" case here and
+ * integrate vtysh specific conf with conf from daemons.
+ */
void
-vtysh_config_write (FILE *fp)
+vtysh_config_write ()
{
+ char *line;
extern struct host host;
if (host.name)
- fprintf (fp, "hostname %s\n", host.name);
- fprintf (fp, "!\n");
+ {
+ sprintf (line, "hostname %s", host.name);
+ vtysh_config_parse_line(line);
+ }
+ if (vtysh_writeconfig_integrated)
+ vtysh_config_parse_line ("service integrated-vtysh-config");
}
void