1 /* Virtual terminal interface shell.
2 * Copyright (C) 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 #include <sys/resource.h>
30 #include <readline/readline.h>
31 #include <readline/history.h>
35 #include "vtysh/vtysh.h"
41 /* VTY shell pager name. */
42 char *vtysh_pager_name
= NULL
;
44 /* VTY shell client structure. */
53 { .fd
= -1, .name
= "zebra", .flag
= VTYSH_ZEBRA
, .path
= ZEBRA_VTYSH_PATH
},
54 { .fd
= -1, .name
= "ripd", .flag
= VTYSH_RIPD
, .path
= RIP_VTYSH_PATH
},
55 { .fd
= -1, .name
= "ripngd", .flag
= VTYSH_RIPNGD
, .path
= RIPNG_VTYSH_PATH
},
56 { .fd
= -1, .name
= "ospfd", .flag
= VTYSH_OSPFD
, .path
= OSPF_VTYSH_PATH
},
57 { .fd
= -1, .name
= "ospf6d", .flag
= VTYSH_OSPF6D
, .path
= OSPF6_VTYSH_PATH
},
58 { .fd
= -1, .name
= "bgpd", .flag
= VTYSH_BGPD
, .path
= BGP_VTYSH_PATH
},
59 { .fd
= -1, .name
= "isisd", .flag
= VTYSH_ISISD
, .path
= ISIS_VTYSH_PATH
},
62 #define VTYSH_INDEX_MAX (sizeof(vtysh_client)/sizeof(vtysh_client[0]))
64 /* We need direct access to ripd to implement vtysh_exit_ripd_only. */
65 static struct vtysh_client
*ripd_client
= NULL
;
68 /* Using integrated config from Quagga.conf. Default is no. */
69 int vtysh_writeconfig_integrated
= 0;
71 extern char config_default
[];
74 vclient_close (struct vtysh_client
*vclient
)
79 "Warning: closing connection to %s because of an I/O error!\n",
86 /* Following filled with debug code to trace a problematic condition
87 * under load - it SHOULD handle it. */
88 #define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): "
90 vtysh_client_config (struct vtysh_client
*vclient
, char *line
)
105 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
108 vclient_close (vclient
);
112 /* Allow enough room for buffer to read more than a few pages from socket. */
113 bufsz
= 5 * getpagesize() + 1;
114 buf
= XMALLOC(MTYPE_TMP
, bufsz
);
115 memset(buf
, 0, bufsz
);
120 if (pbuf
>= ((buf
+ bufsz
) -1))
122 fprintf (stderr
, ERR_WHERE_STRING \
123 "warning - pbuf beyond buffer end.\n");
127 readln
= (buf
+ bufsz
) - pbuf
- 1;
128 nbytes
= read (vclient
->fd
, pbuf
, readln
);
136 fprintf(stderr
, ERR_WHERE_STRING
"(%u)", errno
);
139 if (errno
== EAGAIN
|| errno
== EIO
)
142 vclient_close (vclient
);
143 XFREE(MTYPE_TMP
, buf
);
152 if (pbuf
[i
] == '\0' && pbuf
[i
+ 1] == '\0' && pbuf
[i
+ 2] == '\0')
160 /* See if a line exists in buffer, if so parse and consume it, and
161 * reset read position. */
162 if ((eoln
= strrchr(buf
, '\n')) == NULL
)
165 if (eoln
>= ((buf
+ bufsz
) - 1))
167 fprintf (stderr
, ERR_WHERE_STRING \
168 "warning - eoln beyond buffer end.\n");
170 vtysh_config_parse(buf
);
173 left
= (size_t)(buf
+ bufsz
- eoln
);
174 memmove(buf
, eoln
, left
);
176 pbuf
= buf
+ strlen(buf
);
179 /* Parse anything left in the buffer. */
181 vtysh_config_parse (buf
);
183 XFREE(MTYPE_TMP
, buf
);
188 vtysh_client_execute (struct vtysh_client
*vclient
, const char *line
, FILE *fp
)
199 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
202 vclient_close (vclient
);
208 nbytes
= read (vclient
->fd
, buf
, sizeof(buf
)-1);
210 if (nbytes
<= 0 && errno
!= EINTR
)
212 vclient_close (vclient
);
218 if ((numnulls
== 3) && (nbytes
== 1))
225 /* check for trailling \0\0\0<ret code>,
226 * even if split across reads
227 * (see lib/vty.c::vtysh_read)
237 while (i
< nbytes
&& numnulls
< 3)
239 if (buf
[i
++] == '\0')
245 /* got 3 or more trailing NULs? */
246 if ((numnulls
>= 3) && (i
< nbytes
))
247 return (buf
[nbytes
-1]);
253 vtysh_exit_ripd_only (void)
256 vtysh_client_execute (ripd_client
, "exit", stdout
);
261 vtysh_pager_init (void)
265 pager_defined
= getenv ("VTYSH_PAGER");
268 vtysh_pager_name
= strdup (pager_defined
);
270 vtysh_pager_name
= strdup ("more");
273 /* Command execution over the vty interface. */
275 vtysh_execute_func (const char *line
, int pager
)
280 struct cmd_element
*cmd
;
284 int saved_ret
, saved_node
;
286 /* Split readline string up into the vector. */
287 vline
= cmd_make_strvec (line
);
292 saved_ret
= ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
293 saved_node
= vty
->node
;
295 /* If command doesn't succeeded in current node, try to walk up in node tree.
296 * Changing vty->node is enough to try it just out without actual walkup in
298 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
299 && vty
->node
> CONFIG_NODE
)
301 vty
->node
= node_parent(vty
->node
);
302 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
306 vty
->node
= saved_node
;
308 /* If command succeeded in any other node than current (tried > 0) we have
309 * to move into node in the vtysh where it succeeded. */
310 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
312 if ((saved_node
== BGP_VPNV4_NODE
|| saved_node
== BGP_IPV4_NODE
313 || saved_node
== BGP_IPV6_NODE
|| saved_node
== BGP_IPV4M_NODE
314 || saved_node
== BGP_IPV6M_NODE
)
317 vtysh_execute("exit-address-family");
319 else if ((saved_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
321 vtysh_execute("exit");
325 vtysh_execute ("end");
326 vtysh_execute ("configure terminal");
329 /* If command didn't succeed in any node, continue with return value from
336 cmd_free_strvec (vline
);
341 if (vty
->type
== VTY_FILE
)
342 fprintf (stdout
,"Warning...\n");
344 case CMD_ERR_AMBIGUOUS
:
345 fprintf (stdout
,"%% Ambiguous command.\n");
347 case CMD_ERR_NO_MATCH
:
348 fprintf (stdout
,"%% Unknown command.\n");
350 case CMD_ERR_INCOMPLETE
:
351 fprintf (stdout
,"%% Command incomplete.\n");
353 case CMD_SUCCESS_DAEMON
:
355 /* FIXME: Don't open pager for exit commands. popen() causes problems
356 * if exited from vtysh at all. This hack shouldn't cause any problem
357 * but is really ugly. */
358 if (pager
&& vtysh_pager_name
&& (strncmp(line
, "exit", 4) != 0))
360 fp
= popen (vtysh_pager_name
, "w");
363 perror ("popen failed for pager");
372 if (! strcmp(cmd
->string
,"configure terminal"))
374 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
376 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
377 if (cmd_stat
== CMD_WARNING
)
384 vline
= cmd_make_strvec (line
);
388 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
390 if (pclose (fp
) == -1)
392 perror ("pclose failed for pager");
399 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
400 cmd_free_strvec (vline
);
401 if (ret
!= CMD_SUCCESS_DAEMON
)
407 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
412 cmd_stat
= CMD_SUCCESS
;
413 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
415 if (cmd
->daemon
& vtysh_client
[i
].flag
)
417 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
418 if (cmd_stat
!= CMD_SUCCESS
)
422 if (cmd_stat
!= CMD_SUCCESS
)
426 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
429 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
431 if (pclose (fp
) == -1)
433 perror ("pclose failed for pager");
440 vtysh_execute_no_pager (const char *line
)
442 vtysh_execute_func (line
, 0);
446 vtysh_execute (const char *line
)
448 vtysh_execute_func (line
, 1);
451 /* Configration make from file. */
453 vtysh_config_from_file (struct vty
*vty
, FILE *fp
)
457 struct cmd_element
*cmd
;
459 while (fgets (vty
->buf
, VTY_BUFSIZ
, fp
))
461 if (vty
->buf
[0] == '!' || vty
->buf
[1] == '#')
464 vline
= cmd_make_strvec (vty
->buf
);
466 /* In case of comment line. */
470 /* Execute configuration command : this is strict match. */
471 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
473 /* Try again with setting node to CONFIG_NODE. */
474 if (ret
!= CMD_SUCCESS
475 && ret
!= CMD_SUCCESS_DAEMON
476 && ret
!= CMD_WARNING
)
478 if (vty
->node
== KEYCHAIN_KEY_NODE
)
480 vty
->node
= KEYCHAIN_NODE
;
481 vtysh_exit_ripd_only ();
482 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
484 if (ret
!= CMD_SUCCESS
485 && ret
!= CMD_SUCCESS_DAEMON
486 && ret
!= CMD_WARNING
)
488 vtysh_exit_ripd_only ();
489 vty
->node
= CONFIG_NODE
;
490 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
495 vtysh_execute ("end");
496 vtysh_execute ("configure terminal");
497 vty
->node
= CONFIG_NODE
;
498 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
502 cmd_free_strvec (vline
);
507 if (vty
->type
== VTY_FILE
)
508 fprintf (stdout
,"Warning...\n");
510 case CMD_ERR_AMBIGUOUS
:
511 fprintf (stdout
,"%% Ambiguous command.\n");
513 case CMD_ERR_NO_MATCH
:
514 fprintf (stdout
,"%% Unknown command: %s", vty
->buf
);
516 case CMD_ERR_INCOMPLETE
:
517 fprintf (stdout
,"%% Command incomplete.\n");
519 case CMD_SUCCESS_DAEMON
:
522 int cmd_stat
= CMD_SUCCESS
;
524 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
526 if (cmd
->daemon
& vtysh_client
[i
].flag
)
528 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
530 if (cmd_stat
!= CMD_SUCCESS
)
534 if (cmd_stat
!= CMD_SUCCESS
)
538 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
545 /* We don't care about the point of the cursor when '?' is typed. */
547 vtysh_rl_describe (void)
556 vline
= cmd_make_strvec (rl_line_buffer
);
558 /* In case of '> ?'. */
561 vline
= vector_init (1);
562 vector_set (vline
, '\0');
565 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
566 vector_set (vline
, '\0');
568 describe
= cmd_describe_command (vline
, vty
, &ret
);
570 fprintf (stdout
,"\n");
572 /* Ambiguous and no match error. */
575 case CMD_ERR_AMBIGUOUS
:
576 cmd_free_strvec (vline
);
577 fprintf (stdout
,"%% Ambiguous command.\n");
581 case CMD_ERR_NO_MATCH
:
582 cmd_free_strvec (vline
);
583 fprintf (stdout
,"%% There is no matched command.\n");
589 /* Get width of command string. */
591 for (i
= 0; i
< vector_active (describe
); i
++)
592 if ((desc
= vector_slot (describe
, i
)) != NULL
)
596 if (desc
->cmd
[0] == '\0')
599 len
= strlen (desc
->cmd
);
600 if (desc
->cmd
[0] == '.')
607 for (i
= 0; i
< vector_active (describe
); i
++)
608 if ((desc
= vector_slot (describe
, i
)) != NULL
)
610 if (desc
->cmd
[0] == '\0')
614 fprintf (stdout
," %-s\n",
615 desc
->cmd
[0] == '.' ? desc
->cmd
+ 1 : desc
->cmd
);
617 fprintf (stdout
," %-*s %s\n",
619 desc
->cmd
[0] == '.' ? desc
->cmd
+ 1 : desc
->cmd
,
623 cmd_free_strvec (vline
);
624 vector_free (describe
);
631 /* Result of cmd_complete_command() call will be stored here
632 * and used in new_completion() in order to put the space in
633 * correct places only. */
637 command_generator (const char *text
, int state
)
640 static char **matched
= NULL
;
641 static int index
= 0;
648 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
651 vline
= cmd_make_strvec (rl_line_buffer
);
655 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
656 vector_set (vline
, '\0');
658 matched
= cmd_complete_command (vline
, vty
, &complete_status
);
661 if (matched
&& matched
[index
])
662 return matched
[index
++];
668 new_completion (char *text
, int start
, int end
)
672 matches
= rl_completion_matches (text
, command_generator
);
677 if (complete_status
== CMD_COMPLETE_FULL_MATCH
)
678 rl_pending_input
= ' ';
685 /* This function is not actually being used. */
687 vtysh_completion (char *text
, int start
, int end
)
691 char **matched
= NULL
;
693 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
696 vline
= cmd_make_strvec (rl_line_buffer
);
700 /* In case of 'help \t'. */
701 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
702 vector_set (vline
, '\0');
704 matched
= cmd_complete_command (vline
, vty
, &ret
);
706 cmd_free_strvec (vline
);
708 return (char **) matched
;
712 /* Vty node structures. */
713 struct cmd_node bgp_node
=
716 "%s(config-router)# ",
719 struct cmd_node rip_node
=
722 "%s(config-router)# ",
725 struct cmd_node isis_node
=
728 "%s(config-router)# ",
731 struct cmd_node interface_node
=
737 struct cmd_node rmap_node
=
740 "%s(config-route-map)# "
743 struct cmd_node zebra_node
=
746 "%s(config-router)# "
749 struct cmd_node bgp_vpnv4_node
=
752 "%s(config-router-af)# "
755 struct cmd_node bgp_ipv4_node
=
758 "%s(config-router-af)# "
761 struct cmd_node bgp_ipv4m_node
=
764 "%s(config-router-af)# "
767 struct cmd_node bgp_ipv6_node
=
770 "%s(config-router-af)# "
773 struct cmd_node bgp_ipv6m_node
=
776 "%s(config-router-af)# "
779 struct cmd_node ospf_node
=
782 "%s(config-router)# "
785 struct cmd_node ripng_node
=
788 "%s(config-router)# "
791 struct cmd_node ospf6_node
=
797 struct cmd_node keychain_node
=
800 "%s(config-keychain)# "
803 struct cmd_node keychain_key_node
=
806 "%s(config-keychain-key)# "
809 /* Defined in lib/vty.c */
810 extern struct cmd_node vty_node
;
812 /* When '^Z' is received from vty, move down to the enable mode. */
823 vty
->node
= ENABLE_NODE
;
833 "End current mode and change to enable mode\n")
841 "router bgp CMD_AS_RANGE",
846 vty
->node
= BGP_NODE
;
851 address_family_vpnv4
,
852 address_family_vpnv4_cmd
,
853 "address-family vpnv4",
854 "Enter Address Family command mode\n"
857 vty
->node
= BGP_VPNV4_NODE
;
862 address_family_vpnv4_unicast
,
863 address_family_vpnv4_unicast_cmd
,
864 "address-family vpnv4 unicast",
865 "Enter Address Family command mode\n"
867 "Address Family Modifier\n")
869 vty
->node
= BGP_VPNV4_NODE
;
874 address_family_ipv4_unicast
,
875 address_family_ipv4_unicast_cmd
,
876 "address-family ipv4 unicast",
877 "Enter Address Family command mode\n"
879 "Address Family Modifier\n")
881 vty
->node
= BGP_IPV4_NODE
;
886 address_family_ipv4_multicast
,
887 address_family_ipv4_multicast_cmd
,
888 "address-family ipv4 multicast",
889 "Enter Address Family command mode\n"
891 "Address Family Modifier\n")
893 vty
->node
= BGP_IPV4M_NODE
;
899 address_family_ipv6_cmd
,
900 "address-family ipv6",
901 "Enter Address Family command mode\n"
904 vty
->node
= BGP_IPV6_NODE
;
909 address_family_ipv6_unicast
,
910 address_family_ipv6_unicast_cmd
,
911 "address-family ipv6 unicast",
912 "Enter Address Family command mode\n"
914 "Address Family Modifier\n")
916 vty
->node
= BGP_IPV6_NODE
;
921 address_family_ipv6_multicast
,
922 address_family_ipv6_multicast_cmd
,
923 "address-family ipv6 multicast",
924 "Enter Address Family command mode\n"
926 "Address Family Modifier\n")
928 vty
->node
= BGP_IPV6M_NODE
;
936 "Authentication key management\n"
937 "Key-chain management\n"
940 vty
->node
= KEYCHAIN_NODE
;
947 "key <0-2147483647>",
949 "Key identifier number\n")
951 vty
->node
= KEYCHAIN_KEY_NODE
;
962 vty
->node
= RIP_NODE
;
966 DEFUNSH (VTYSH_RIPNGD
,
973 vty
->node
= RIPNG_NODE
;
977 DEFUNSH (VTYSH_OSPFD
,
981 "Enable a routing process\n"
982 "Start OSPF configuration\n")
984 vty
->node
= OSPF_NODE
;
988 DEFUNSH (VTYSH_OSPF6D
,
995 vty
->node
= OSPF6_NODE
;
999 DEFUNSH (VTYSH_ISISD
,
1005 "ISO Routing area tag")
1007 vty
->node
= ISIS_NODE
;
1011 DEFUNSH (VTYSH_RMAP
,
1014 "route-map WORD (deny|permit) <1-65535>",
1015 "Create route-map or enter route-map command mode\n"
1017 "Route map denies set operations\n"
1018 "Route map permits set operations\n"
1019 "Sequence to insert to/delete from existing route-map entry\n")
1021 vty
->node
= RMAP_NODE
;
1029 "Configure a terminal line\n"
1030 "Virtual terminal\n")
1032 vty
->node
= VTY_NODE
;
1040 "Turn on privileged mode command\n")
1042 vty
->node
= ENABLE_NODE
;
1050 "Turn off privileged mode command\n")
1052 if (vty
->node
== ENABLE_NODE
)
1053 vty
->node
= VIEW_NODE
;
1058 vtysh_config_terminal
,
1059 vtysh_config_terminal_cmd
,
1060 "configure terminal",
1061 "Configuration from vty interface\n"
1062 "Configuration terminal\n")
1064 vty
->node
= CONFIG_NODE
;
1069 vtysh_exit (struct vty
*vty
)
1078 vty
->node
= ENABLE_NODE
;
1080 case INTERFACE_NODE
:
1092 vtysh_execute("end");
1093 vtysh_execute("configure terminal");
1094 vty
->node
= CONFIG_NODE
;
1096 case BGP_VPNV4_NODE
:
1098 case BGP_IPV4M_NODE
:
1100 case BGP_IPV6M_NODE
:
1101 vty
->node
= BGP_NODE
;
1103 case KEYCHAIN_KEY_NODE
:
1104 vty
->node
= KEYCHAIN_NODE
;
1116 "Exit current mode and down to previous mode\n")
1118 return vtysh_exit (vty
);
1121 ALIAS (vtysh_exit_all
,
1124 "Exit current mode and down to previous mode\n")
1126 DEFUNSH (VTYSH_BGPD
,
1127 exit_address_family
,
1128 exit_address_family_cmd
,
1129 "exit-address-family",
1130 "Exit from Address Family configuration mode\n")
1132 if (vty
->node
== BGP_IPV4_NODE
1133 || vty
->node
== BGP_IPV4M_NODE
1134 || vty
->node
== BGP_VPNV4_NODE
1135 || vty
->node
== BGP_IPV6_NODE
1136 || vty
->node
== BGP_IPV6M_NODE
)
1137 vty
->node
= BGP_NODE
;
1141 DEFUNSH (VTYSH_ZEBRA
,
1143 vtysh_exit_zebra_cmd
,
1145 "Exit current mode and down to previous mode\n")
1147 return vtysh_exit (vty
);
1150 ALIAS (vtysh_exit_zebra
,
1151 vtysh_quit_zebra_cmd
,
1153 "Exit current mode and down to previous mode\n")
1155 DEFUNSH (VTYSH_RIPD
,
1157 vtysh_exit_ripd_cmd
,
1159 "Exit current mode and down to previous mode\n")
1161 return vtysh_exit (vty
);
1164 ALIAS (vtysh_exit_ripd
,
1165 vtysh_quit_ripd_cmd
,
1167 "Exit current mode and down to previous mode\n")
1169 DEFUNSH (VTYSH_RIPNGD
,
1171 vtysh_exit_ripngd_cmd
,
1173 "Exit current mode and down to previous mode\n")
1175 return vtysh_exit (vty
);
1178 ALIAS (vtysh_exit_ripngd
,
1179 vtysh_quit_ripngd_cmd
,
1181 "Exit current mode and down to previous mode\n")
1183 DEFUNSH (VTYSH_RMAP
,
1185 vtysh_exit_rmap_cmd
,
1187 "Exit current mode and down to previous mode\n")
1189 return vtysh_exit (vty
);
1192 ALIAS (vtysh_exit_rmap
,
1193 vtysh_quit_rmap_cmd
,
1195 "Exit current mode and down to previous mode\n")
1197 DEFUNSH (VTYSH_BGPD
,
1199 vtysh_exit_bgpd_cmd
,
1201 "Exit current mode and down to previous mode\n")
1203 return vtysh_exit (vty
);
1206 ALIAS (vtysh_exit_bgpd
,
1207 vtysh_quit_bgpd_cmd
,
1209 "Exit current mode and down to previous mode\n")
1211 DEFUNSH (VTYSH_OSPFD
,
1213 vtysh_exit_ospfd_cmd
,
1215 "Exit current mode and down to previous mode\n")
1217 return vtysh_exit (vty
);
1220 ALIAS (vtysh_exit_ospfd
,
1221 vtysh_quit_ospfd_cmd
,
1223 "Exit current mode and down to previous mode\n")
1225 DEFUNSH (VTYSH_OSPF6D
,
1227 vtysh_exit_ospf6d_cmd
,
1229 "Exit current mode and down to previous mode\n")
1231 return vtysh_exit (vty
);
1234 ALIAS (vtysh_exit_ospf6d
,
1235 vtysh_quit_ospf6d_cmd
,
1237 "Exit current mode and down to previous mode\n")
1239 DEFUNSH (VTYSH_ISISD
,
1241 vtysh_exit_isisd_cmd
,
1243 "Exit current mode and down to previous mode\n")
1245 return vtysh_exit (vty
);
1248 ALIAS (vtysh_exit_isisd
,
1249 vtysh_quit_isisd_cmd
,
1251 "Exit current mode and down to previous mode\n")
1254 vtysh_exit_line_vty
,
1255 vtysh_exit_line_vty_cmd
,
1257 "Exit current mode and down to previous mode\n")
1259 return vtysh_exit (vty
);
1262 ALIAS (vtysh_exit_line_vty
,
1263 vtysh_quit_line_vty_cmd
,
1265 "Exit current mode and down to previous mode\n")
1267 DEFUNSH (VTYSH_INTERFACE
,
1269 vtysh_interface_cmd
,
1271 "Select an interface to configure\n"
1272 "Interface's name\n")
1274 vty
->node
= INTERFACE_NODE
;
1278 /* TODO Implement "no interface command in isisd. */
1279 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_RIPNGD
|VTYSH_OSPFD
|VTYSH_OSPF6D
,
1280 vtysh_no_interface_cmd
,
1281 "no interface IFNAME",
1283 "Delete a pseudo interface's configuration\n"
1284 "Interface's name\n")
1286 /* TODO Implement interface description commands in ripngd, ospf6d
1288 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1290 "description .LINE",
1291 "Interface specific description\n"
1292 "Characters describing this interface\n")
1294 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1295 no_interface_desc_cmd
,
1298 "Interface specific description\n")
1300 DEFUNSH (VTYSH_INTERFACE
,
1301 vtysh_exit_interface
,
1302 vtysh_exit_interface_cmd
,
1304 "Exit current mode and down to previous mode\n")
1306 return vtysh_exit (vty
);
1309 ALIAS (vtysh_exit_interface
,
1310 vtysh_quit_interface_cmd
,
1312 "Exit current mode and down to previous mode\n")
1315 DEFUN (vtysh_show_memory
,
1316 vtysh_show_memory_cmd
,
1319 "Memory statistics\n")
1322 int ret
= CMD_SUCCESS
;
1323 char line
[] = "show memory\n";
1325 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
1326 if ( vtysh_client
[i
].fd
>= 0 )
1328 fprintf (stdout
, "Memory statistics for %s:\n",
1329 vtysh_client
[i
].name
);
1330 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1331 fprintf (stdout
,"\n");
1337 /* Logging commands. */
1338 DEFUN (vtysh_show_logging
,
1339 vtysh_show_logging_cmd
,
1342 "Show current logging configuration\n")
1345 int ret
= CMD_SUCCESS
;
1346 char line
[] = "show logging\n";
1348 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
1349 if ( vtysh_client
[i
].fd
>= 0 )
1351 fprintf (stdout
,"Logging configuration for %s:\n",
1352 vtysh_client
[i
].name
);
1353 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1354 fprintf (stdout
,"\n");
1362 vtysh_log_stdout_cmd
,
1365 "Set stdout logging level\n")
1371 vtysh_log_stdout_level
,
1372 vtysh_log_stdout_level_cmd
,
1373 "log stdout "LOG_LEVELS
,
1375 "Set stdout logging level\n"
1382 no_vtysh_log_stdout
,
1383 no_vtysh_log_stdout_cmd
,
1384 "no log stdout [LEVEL]",
1387 "Cancel logging to stdout\n"
1396 "log file FILENAME",
1399 "Logging filename\n")
1405 vtysh_log_file_level
,
1406 vtysh_log_file_level_cmd
,
1407 "log file FILENAME "LOG_LEVELS
,
1410 "Logging filename\n"
1418 no_vtysh_log_file_cmd
,
1419 "no log file [FILENAME]",
1422 "Cancel logging to file\n"
1423 "Logging file name\n")
1428 ALIAS_SH (VTYSH_ALL
,
1430 no_vtysh_log_file_level_cmd
,
1431 "no log file FILENAME LEVEL",
1434 "Cancel logging to file\n"
1435 "Logging file name\n"
1440 vtysh_log_monitor_cmd
,
1443 "Set terminal line (monitor) logging level\n")
1449 vtysh_log_monitor_level
,
1450 vtysh_log_monitor_level_cmd
,
1451 "log monitor "LOG_LEVELS
,
1453 "Set terminal line (monitor) logging level\n"
1460 no_vtysh_log_monitor
,
1461 no_vtysh_log_monitor_cmd
,
1462 "no log monitor [LEVEL]",
1465 "Disable terminal line (monitor) logging\n"
1473 vtysh_log_syslog_cmd
,
1476 "Set syslog logging level\n")
1482 vtysh_log_syslog_level
,
1483 vtysh_log_syslog_level_cmd
,
1484 "log syslog "LOG_LEVELS
,
1486 "Set syslog logging level\n"
1493 no_vtysh_log_syslog
,
1494 no_vtysh_log_syslog_cmd
,
1495 "no log syslog [LEVEL]",
1498 "Cancel logging to syslog\n"
1506 vtysh_log_facility_cmd
,
1507 "log facility "LOG_FACILITIES
,
1509 "Facility parameter for syslog messages\n"
1517 no_vtysh_log_facility
,
1518 no_vtysh_log_facility_cmd
,
1519 "no log facility [FACILITY]",
1522 "Reset syslog facility to default (daemon)\n"
1523 "Syslog facility\n")
1529 DEFUNSH_DEPRECATED (VTYSH_ALL
,
1532 "log trap "LOG_LEVELS
,
1534 "(Deprecated) Set logging level and default for all destinations\n"
1541 DEFUNSH_DEPRECATED (VTYSH_ALL
,
1543 no_vtysh_log_trap_cmd
,
1544 "no log trap [LEVEL]",
1547 "Permit all logging information\n"
1554 vtysh_log_record_priority
,
1555 vtysh_log_record_priority_cmd
,
1556 "log record-priority",
1558 "Log the priority of the message within the message\n")
1564 no_vtysh_log_record_priority
,
1565 no_vtysh_log_record_priority_cmd
,
1566 "no log record-priority",
1569 "Do not log the priority of the message within the message\n")
1575 vtysh_log_timestamp_precision
,
1576 vtysh_log_timestamp_precision_cmd
,
1577 "log timestamp precision <0-6>",
1579 "Timestamp configuration\n"
1580 "Set the timestamp precision\n"
1581 "Number of subsecond digits\n")
1587 no_vtysh_log_timestamp_precision
,
1588 no_vtysh_log_timestamp_precision_cmd
,
1589 "no log timestamp precision",
1592 "Timestamp configuration\n"
1593 "Reset the timestamp precision to the default value of 0\n")
1599 vtysh_service_password_encrypt
,
1600 vtysh_service_password_encrypt_cmd
,
1601 "service password-encryption",
1602 "Set up miscellaneous service\n"
1603 "Enable encrypted passwords\n")
1609 no_vtysh_service_password_encrypt
,
1610 no_vtysh_service_password_encrypt_cmd
,
1611 "no service password-encryption",
1613 "Set up miscellaneous service\n"
1614 "Enable encrypted passwords\n")
1620 vtysh_config_password
,
1622 "password (8|) WORD",
1623 "Assign the terminal connection password\n"
1624 "Specifies a HIDDEN password will follow\n"
1626 "The HIDDEN line password string\n")
1632 vtysh_password_text
,
1633 vtysh_password_text_cmd
,
1635 "Assign the terminal connection password\n"
1636 "The UNENCRYPTED (cleartext) line password\n")
1642 vtysh_config_enable_password
,
1643 vtysh_enable_password_cmd
,
1644 "enable password (8|) WORD",
1645 "Modify enable password parameters\n"
1646 "Assign the privileged level password\n"
1647 "Specifies a HIDDEN password will follow\n"
1649 "The HIDDEN 'enable' password string\n")
1655 vtysh_enable_password_text
,
1656 vtysh_enable_password_text_cmd
,
1657 "enable password LINE",
1658 "Modify enable password parameters\n"
1659 "Assign the privileged level password\n"
1660 "The UNENCRYPTED (cleartext) 'enable' password\n")
1666 no_vtysh_config_enable_password
,
1667 no_vtysh_enable_password_cmd
,
1668 "no enable password",
1670 "Modify enable password parameters\n"
1671 "Assign the privileged level password\n")
1676 DEFUN (vtysh_write_terminal
,
1677 vtysh_write_terminal_cmd
,
1679 "Write running configuration to memory, network, or terminal\n"
1680 "Write to terminal\n")
1684 char line
[] = "write terminal\n";
1687 if (vtysh_pager_name
)
1689 fp
= popen (vtysh_pager_name
, "w");
1699 vty_out (vty
, "Building configuration...%s", VTY_NEWLINE
);
1700 vty_out (vty
, "%sCurrent configuration:%s", VTY_NEWLINE
,
1702 vty_out (vty
, "!%s", VTY_NEWLINE
);
1704 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
1705 ret
= vtysh_client_config (&vtysh_client
[i
], line
);
1707 /* Integrate vtysh specific configuration. */
1708 vtysh_config_write ();
1710 vtysh_config_dump (fp
);
1712 vty_out (vty
, "end%s", VTY_NEWLINE
);
1714 if (vtysh_pager_name
&& fp
)
1717 if (pclose (fp
) == -1)
1728 DEFUN (vtysh_integrated_config
,
1729 vtysh_integrated_config_cmd
,
1730 "service integrated-vtysh-config",
1731 "Set up miscellaneous service\n"
1732 "Write configuration into integrated file\n")
1734 vtysh_writeconfig_integrated
= 1;
1738 DEFUN (no_vtysh_integrated_config
,
1739 no_vtysh_integrated_config_cmd
,
1740 "no service integrated-vtysh-config",
1742 "Set up miscellaneous service\n"
1743 "Write configuration into integrated file\n")
1745 vtysh_writeconfig_integrated
= 0;
1750 write_config_integrated(void)
1754 char line
[] = "write terminal\n";
1756 char *integrate_sav
= NULL
;
1758 integrate_sav
= malloc (strlen (integrate_default
) +
1759 strlen (CONF_BACKUP_EXT
) + 1);
1760 strcpy (integrate_sav
, integrate_default
);
1761 strcat (integrate_sav
, CONF_BACKUP_EXT
);
1763 fprintf (stdout
,"Building Configuration...\n");
1765 /* Move current configuration file to backup config file. */
1766 unlink (integrate_sav
);
1767 rename (integrate_default
, integrate_sav
);
1768 free (integrate_sav
);
1770 fp
= fopen (integrate_default
, "w");
1773 fprintf (stdout
,"%% Can't open configuration file %s.\n",
1778 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
1779 ret
= vtysh_client_config (&vtysh_client
[i
], line
);
1781 vtysh_config_dump (fp
);
1785 if (chmod (integrate_default
, CONFIGFILE_MASK
) != 0)
1787 fprintf (stdout
,"%% Can't chmod configuration file %s: %s (%d)\n",
1788 integrate_default
, safe_strerror(errno
), errno
);
1792 fprintf(stdout
,"Integrated configuration saved to %s\n",integrate_default
);
1794 fprintf (stdout
,"[OK]\n");
1799 DEFUN (vtysh_write_memory
,
1800 vtysh_write_memory_cmd
,
1802 "Write running configuration to memory, network, or terminal\n"
1803 "Write configuration to the file (same as write file)\n")
1805 int ret
= CMD_SUCCESS
;
1806 char line
[] = "write memory\n";
1809 /* If integrated Quagga.conf explicitely set. */
1810 if (vtysh_writeconfig_integrated
)
1811 return write_config_integrated();
1813 fprintf (stdout
,"Building Configuration...\n");
1815 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
1816 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1818 fprintf (stdout
,"[OK]\n");
1823 ALIAS (vtysh_write_memory
,
1824 vtysh_copy_runningconfig_startupconfig_cmd
,
1825 "copy running-config startup-config",
1826 "Copy from one file to another\n"
1827 "Copy from current system configuration\n"
1828 "Copy to startup configuration\n")
1830 ALIAS (vtysh_write_memory
,
1831 vtysh_write_file_cmd
,
1833 "Write running configuration to memory, network, or terminal\n"
1834 "Write configuration to the file (same as write memory)\n")
1836 ALIAS (vtysh_write_memory
,
1839 "Write running configuration to memory, network, or terminal\n")
1841 ALIAS (vtysh_write_terminal
,
1842 vtysh_show_running_config_cmd
,
1843 "show running-config",
1845 "Current operating configuration\n")
1847 DEFUN (vtysh_terminal_length
,
1848 vtysh_terminal_length_cmd
,
1849 "terminal length <0-512>",
1850 "Set terminal line parameters\n"
1851 "Set number of lines on a screen\n"
1852 "Number of lines on screen (0 for no pausing)\n")
1855 char *endptr
= NULL
;
1856 char default_pager
[10];
1858 lines
= strtol (argv
[0], &endptr
, 10);
1859 if (lines
< 0 || lines
> 512 || *endptr
!= '\0')
1861 vty_out (vty
, "length is malformed%s", VTY_NEWLINE
);
1865 if (vtysh_pager_name
)
1867 free (vtysh_pager_name
);
1868 vtysh_pager_name
= NULL
;
1873 snprintf(default_pager
, 10, "more -%i", lines
);
1874 vtysh_pager_name
= strdup (default_pager
);
1880 DEFUN (vtysh_terminal_no_length
,
1881 vtysh_terminal_no_length_cmd
,
1882 "terminal no length",
1883 "Set terminal line parameters\n"
1885 "Set number of lines on a screen\n")
1887 if (vtysh_pager_name
)
1889 free (vtysh_pager_name
);
1890 vtysh_pager_name
= NULL
;
1897 DEFUN (vtysh_show_daemons
,
1898 vtysh_show_daemons_cmd
,
1901 "Show list of running daemons\n")
1905 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
1906 if ( vtysh_client
[i
].fd
>= 0 )
1907 vty_out(vty
, " %s", vtysh_client
[i
].name
);
1908 vty_out(vty
, "%s", VTY_NEWLINE
);
1913 /* Execute command in child process. */
1915 execute_command (const char *command
, int argc
, const char *arg1
,
1927 /* Failure of fork(). */
1928 fprintf (stderr
, "Can't fork: %s\n", safe_strerror (errno
));
1933 /* This is child process. */
1937 ret
= execlp (command
, command
, (const char *)NULL
);
1940 ret
= execlp (command
, command
, arg1
, (const char *)NULL
);
1943 ret
= execlp (command
, command
, arg1
, arg2
, (const char *)NULL
);
1947 /* When execlp suceed, this part is not executed. */
1948 fprintf (stderr
, "Can't execute %s: %s\n", command
, safe_strerror (errno
));
1953 /* This is parent. */
1955 ret
= wait4 (pid
, &status
, 0, NULL
);
1964 "Send echo messages\n"
1965 "Ping destination address or hostname\n")
1967 execute_command ("ping", 1, argv
[0], NULL
);
1974 "Send echo messages\n"
1976 "Ping destination address or hostname\n")
1978 DEFUN (vtysh_traceroute
,
1979 vtysh_traceroute_cmd
,
1981 "Trace route to destination\n"
1982 "Trace route to destination address or hostname\n")
1984 execute_command ("traceroute", 1, argv
[0], NULL
);
1988 ALIAS (vtysh_traceroute
,
1989 vtysh_traceroute_ip_cmd
,
1990 "traceroute ip WORD",
1991 "Trace route to destination\n"
1993 "Trace route to destination address or hostname\n")
1999 "Send echo messages\n"
2001 "Ping destination address or hostname\n")
2003 execute_command ("ping6", 1, argv
[0], NULL
);
2007 DEFUN (vtysh_traceroute6
,
2008 vtysh_traceroute6_cmd
,
2009 "traceroute ipv6 WORD",
2010 "Trace route to destination\n"
2012 "Trace route to destination address or hostname\n")
2014 execute_command ("traceroute6", 1, argv
[0], NULL
);
2019 DEFUN (vtysh_telnet
,
2022 "Open a telnet connection\n"
2023 "IP address or hostname of a remote system\n")
2025 execute_command ("telnet", 1, argv
[0], NULL
);
2029 DEFUN (vtysh_telnet_port
,
2030 vtysh_telnet_port_cmd
,
2032 "Open a telnet connection\n"
2033 "IP address or hostname of a remote system\n"
2034 "TCP Port number\n")
2036 execute_command ("telnet", 2, argv
[0], argv
[1]);
2043 "Open an ssh connection\n"
2046 execute_command ("ssh", 1, argv
[0], NULL
);
2050 DEFUN (vtysh_start_shell
,
2051 vtysh_start_shell_cmd
,
2053 "Start UNIX shell\n")
2055 execute_command ("sh", 0, NULL
, NULL
);
2059 DEFUN (vtysh_start_bash
,
2060 vtysh_start_bash_cmd
,
2062 "Start UNIX shell\n"
2065 execute_command ("bash", 0, NULL
, NULL
);
2069 DEFUN (vtysh_start_zsh
,
2070 vtysh_start_zsh_cmd
,
2072 "Start UNIX shell\n"
2075 execute_command ("zsh", 0, NULL
, NULL
);
2080 vtysh_install_default (enum node_type node
)
2082 install_element (node
, &config_list_cmd
);
2085 /* Making connection to protocol daemon. */
2087 vtysh_connect (struct vtysh_client
*vclient
)
2091 struct sockaddr_un addr
;
2094 /* Stat socket to see if we have permission to access it. */
2095 ret
= stat (vclient
->path
, &s_stat
);
2096 if (ret
< 0 && errno
!= ENOENT
)
2098 fprintf (stderr
, "vtysh_connect(%s): stat = %s\n",
2099 vclient
->path
, safe_strerror(errno
));
2105 if (! S_ISSOCK(s_stat
.st_mode
))
2107 fprintf (stderr
, "vtysh_connect(%s): Not a socket\n",
2114 sock
= socket (AF_UNIX
, SOCK_STREAM
, 0);
2118 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", vclient
->path
,
2119 safe_strerror(errno
));
2124 memset (&addr
, 0, sizeof (struct sockaddr_un
));
2125 addr
.sun_family
= AF_UNIX
;
2126 strncpy (addr
.sun_path
, vclient
->path
, strlen (vclient
->path
));
2127 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
2128 len
= addr
.sun_len
= SUN_LEN(&addr
);
2130 len
= sizeof (addr
.sun_family
) + strlen (addr
.sun_path
);
2131 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
2133 ret
= connect (sock
, (struct sockaddr
*) &addr
, len
);
2137 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", vclient
->path
,
2138 safe_strerror(errno
));
2149 vtysh_connect_all(const char *daemon_name
)
2155 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
2157 if (!daemon_name
|| !strcmp(daemon_name
, vtysh_client
[i
].name
))
2160 if (vtysh_connect(&vtysh_client
[i
]) == 0)
2162 /* We need direct access to ripd in vtysh_exit_ripd_only. */
2163 if (vtysh_client
[i
].flag
== VTYSH_RIPD
)
2164 ripd_client
= &vtysh_client
[i
];
2168 fprintf(stderr
, "Error: no daemons match name %s!\n", daemon_name
);
2172 /* To disable readline's filename completion. */
2174 vtysh_completion_entry_function (const char *ignore
, int invoking_key
)
2180 vtysh_readline_init (void)
2182 /* readline related settings. */
2183 rl_bind_key ('?', (Function
*) vtysh_rl_describe
);
2184 rl_completion_entry_function
= vtysh_completion_entry_function
;
2185 rl_attempted_completion_function
= (CPPFunction
*)new_completion
;
2186 /* do not append space after completion. It will be appended
2187 * in new_completion() function explicitly. */
2188 rl_completion_append_character
= '\0';
2194 static struct utsname names
;
2195 static char buf
[100];
2196 const char*hostname
;
2197 extern struct host host
;
2199 hostname
= host
.name
;
2203 if (!names
.nodename
[0])
2205 hostname
= names
.nodename
;
2208 snprintf (buf
, sizeof buf
, cmd_prompt (vty
->node
), hostname
);
2214 vtysh_init_vty (void)
2216 /* Make vty structure. */
2218 vty
->type
= VTY_SHELL
;
2219 vty
->node
= VIEW_NODE
;
2221 /* Initialize commands. */
2224 /* Install nodes. */
2225 install_node (&bgp_node
, NULL
);
2226 install_node (&rip_node
, NULL
);
2227 install_node (&interface_node
, NULL
);
2228 install_node (&rmap_node
, NULL
);
2229 install_node (&zebra_node
, NULL
);
2230 install_node (&bgp_vpnv4_node
, NULL
);
2231 install_node (&bgp_ipv4_node
, NULL
);
2232 install_node (&bgp_ipv4m_node
, NULL
);
2233 /* #ifdef HAVE_IPV6 */
2234 install_node (&bgp_ipv6_node
, NULL
);
2235 install_node (&bgp_ipv6m_node
, NULL
);
2237 install_node (&ospf_node
, NULL
);
2238 /* #ifdef HAVE_IPV6 */
2239 install_node (&ripng_node
, NULL
);
2240 install_node (&ospf6_node
, NULL
);
2242 install_node (&keychain_node
, NULL
);
2243 install_node (&keychain_key_node
, NULL
);
2244 install_node (&isis_node
, NULL
);
2245 install_node (&vty_node
, NULL
);
2247 vtysh_install_default (VIEW_NODE
);
2248 vtysh_install_default (ENABLE_NODE
);
2249 vtysh_install_default (CONFIG_NODE
);
2250 vtysh_install_default (BGP_NODE
);
2251 vtysh_install_default (RIP_NODE
);
2252 vtysh_install_default (INTERFACE_NODE
);
2253 vtysh_install_default (RMAP_NODE
);
2254 vtysh_install_default (ZEBRA_NODE
);
2255 vtysh_install_default (BGP_VPNV4_NODE
);
2256 vtysh_install_default (BGP_IPV4_NODE
);
2257 vtysh_install_default (BGP_IPV4M_NODE
);
2258 vtysh_install_default (BGP_IPV6_NODE
);
2259 vtysh_install_default (BGP_IPV6M_NODE
);
2260 vtysh_install_default (OSPF_NODE
);
2261 vtysh_install_default (RIPNG_NODE
);
2262 vtysh_install_default (OSPF6_NODE
);
2263 vtysh_install_default (ISIS_NODE
);
2264 vtysh_install_default (KEYCHAIN_NODE
);
2265 vtysh_install_default (KEYCHAIN_KEY_NODE
);
2266 vtysh_install_default (VTY_NODE
);
2268 install_element (VIEW_NODE
, &vtysh_enable_cmd
);
2269 install_element (ENABLE_NODE
, &vtysh_config_terminal_cmd
);
2270 install_element (ENABLE_NODE
, &vtysh_disable_cmd
);
2272 /* "exit" command. */
2273 install_element (VIEW_NODE
, &vtysh_exit_all_cmd
);
2274 install_element (VIEW_NODE
, &vtysh_quit_all_cmd
);
2275 install_element (CONFIG_NODE
, &vtysh_exit_all_cmd
);
2276 /* install_element (CONFIG_NODE, &vtysh_quit_all_cmd); */
2277 install_element (ENABLE_NODE
, &vtysh_exit_all_cmd
);
2278 install_element (ENABLE_NODE
, &vtysh_quit_all_cmd
);
2279 install_element (RIP_NODE
, &vtysh_exit_ripd_cmd
);
2280 install_element (RIP_NODE
, &vtysh_quit_ripd_cmd
);
2281 install_element (RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
2282 install_element (RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
2283 install_element (OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
2284 install_element (OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
2285 install_element (OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
2286 install_element (OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
2287 install_element (BGP_NODE
, &vtysh_exit_bgpd_cmd
);
2288 install_element (BGP_NODE
, &vtysh_quit_bgpd_cmd
);
2289 install_element (BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
2290 install_element (BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
2291 install_element (BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
2292 install_element (BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
2293 install_element (BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
2294 install_element (BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
2295 install_element (BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
2296 install_element (BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
2297 install_element (BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
2298 install_element (BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
2299 install_element (ISIS_NODE
, &vtysh_exit_isisd_cmd
);
2300 install_element (ISIS_NODE
, &vtysh_quit_isisd_cmd
);
2301 install_element (KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
2302 install_element (KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
2303 install_element (KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
2304 install_element (KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
2305 install_element (RMAP_NODE
, &vtysh_exit_rmap_cmd
);
2306 install_element (RMAP_NODE
, &vtysh_quit_rmap_cmd
);
2307 install_element (VTY_NODE
, &vtysh_exit_line_vty_cmd
);
2308 install_element (VTY_NODE
, &vtysh_quit_line_vty_cmd
);
2310 /* "end" command. */
2311 install_element (CONFIG_NODE
, &vtysh_end_all_cmd
);
2312 install_element (ENABLE_NODE
, &vtysh_end_all_cmd
);
2313 install_element (RIP_NODE
, &vtysh_end_all_cmd
);
2314 install_element (RIPNG_NODE
, &vtysh_end_all_cmd
);
2315 install_element (OSPF_NODE
, &vtysh_end_all_cmd
);
2316 install_element (OSPF6_NODE
, &vtysh_end_all_cmd
);
2317 install_element (BGP_NODE
, &vtysh_end_all_cmd
);
2318 install_element (BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
2319 install_element (BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
2320 install_element (BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
2321 install_element (BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
2322 install_element (BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
2323 install_element (ISIS_NODE
, &vtysh_end_all_cmd
);
2324 install_element (KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
2325 install_element (KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
2326 install_element (RMAP_NODE
, &vtysh_end_all_cmd
);
2327 install_element (VTY_NODE
, &vtysh_end_all_cmd
);
2329 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
2330 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
2331 install_element (INTERFACE_NODE
, &vtysh_end_all_cmd
);
2332 install_element (INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
2333 install_element (INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
2334 install_element (CONFIG_NODE
, &router_rip_cmd
);
2336 install_element (CONFIG_NODE
, &router_ripng_cmd
);
2338 install_element (CONFIG_NODE
, &router_ospf_cmd
);
2340 install_element (CONFIG_NODE
, &router_ospf6_cmd
);
2342 install_element (CONFIG_NODE
, &router_isis_cmd
);
2343 install_element (CONFIG_NODE
, &router_bgp_cmd
);
2344 install_element (BGP_NODE
, &address_family_vpnv4_cmd
);
2345 install_element (BGP_NODE
, &address_family_vpnv4_unicast_cmd
);
2346 install_element (BGP_NODE
, &address_family_ipv4_unicast_cmd
);
2347 install_element (BGP_NODE
, &address_family_ipv4_multicast_cmd
);
2349 install_element (BGP_NODE
, &address_family_ipv6_cmd
);
2350 install_element (BGP_NODE
, &address_family_ipv6_unicast_cmd
);
2352 install_element (BGP_VPNV4_NODE
, &exit_address_family_cmd
);
2353 install_element (BGP_IPV4_NODE
, &exit_address_family_cmd
);
2354 install_element (BGP_IPV4M_NODE
, &exit_address_family_cmd
);
2355 install_element (BGP_IPV6_NODE
, &exit_address_family_cmd
);
2356 install_element (BGP_IPV6M_NODE
, &exit_address_family_cmd
);
2357 install_element (CONFIG_NODE
, &key_chain_cmd
);
2358 install_element (CONFIG_NODE
, &route_map_cmd
);
2359 install_element (CONFIG_NODE
, &vtysh_line_vty_cmd
);
2360 install_element (KEYCHAIN_NODE
, &key_cmd
);
2361 install_element (KEYCHAIN_NODE
, &key_chain_cmd
);
2362 install_element (KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
2363 install_element (CONFIG_NODE
, &vtysh_interface_cmd
);
2364 install_element (CONFIG_NODE
, &vtysh_no_interface_cmd
);
2365 install_element (ENABLE_NODE
, &vtysh_show_running_config_cmd
);
2366 install_element (ENABLE_NODE
, &vtysh_copy_runningconfig_startupconfig_cmd
);
2367 install_element (ENABLE_NODE
, &vtysh_write_file_cmd
);
2368 install_element (ENABLE_NODE
, &vtysh_write_cmd
);
2370 /* "write terminal" command. */
2371 install_element (ENABLE_NODE
, &vtysh_write_terminal_cmd
);
2373 install_element (CONFIG_NODE
, &vtysh_integrated_config_cmd
);
2374 install_element (CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
2376 /* "write memory" command. */
2377 install_element (ENABLE_NODE
, &vtysh_write_memory_cmd
);
2379 install_element (VIEW_NODE
, &vtysh_terminal_length_cmd
);
2380 install_element (ENABLE_NODE
, &vtysh_terminal_length_cmd
);
2381 install_element (VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
2382 install_element (ENABLE_NODE
, &vtysh_terminal_no_length_cmd
);
2383 install_element (VIEW_NODE
, &vtysh_show_daemons_cmd
);
2384 install_element (ENABLE_NODE
, &vtysh_show_daemons_cmd
);
2386 install_element (VIEW_NODE
, &vtysh_ping_cmd
);
2387 install_element (VIEW_NODE
, &vtysh_ping_ip_cmd
);
2388 install_element (VIEW_NODE
, &vtysh_traceroute_cmd
);
2389 install_element (VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
2391 install_element (VIEW_NODE
, &vtysh_ping6_cmd
);
2392 install_element (VIEW_NODE
, &vtysh_traceroute6_cmd
);
2394 install_element (VIEW_NODE
, &vtysh_telnet_cmd
);
2395 install_element (VIEW_NODE
, &vtysh_telnet_port_cmd
);
2396 install_element (VIEW_NODE
, &vtysh_ssh_cmd
);
2397 install_element (ENABLE_NODE
, &vtysh_ping_cmd
);
2398 install_element (ENABLE_NODE
, &vtysh_ping_ip_cmd
);
2399 install_element (ENABLE_NODE
, &vtysh_traceroute_cmd
);
2400 install_element (ENABLE_NODE
, &vtysh_traceroute_ip_cmd
);
2402 install_element (ENABLE_NODE
, &vtysh_ping6_cmd
);
2403 install_element (ENABLE_NODE
, &vtysh_traceroute6_cmd
);
2405 install_element (ENABLE_NODE
, &vtysh_telnet_cmd
);
2406 install_element (ENABLE_NODE
, &vtysh_telnet_port_cmd
);
2407 install_element (ENABLE_NODE
, &vtysh_ssh_cmd
);
2408 install_element (ENABLE_NODE
, &vtysh_start_shell_cmd
);
2409 install_element (ENABLE_NODE
, &vtysh_start_bash_cmd
);
2410 install_element (ENABLE_NODE
, &vtysh_start_zsh_cmd
);
2412 install_element (VIEW_NODE
, &vtysh_show_memory_cmd
);
2413 install_element (ENABLE_NODE
, &vtysh_show_memory_cmd
);
2416 install_element (ENABLE_NODE
, &vtysh_show_logging_cmd
);
2417 install_element (VIEW_NODE
, &vtysh_show_logging_cmd
);
2418 install_element (CONFIG_NODE
, &vtysh_log_stdout_cmd
);
2419 install_element (CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
2420 install_element (CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
2421 install_element (CONFIG_NODE
, &vtysh_log_file_cmd
);
2422 install_element (CONFIG_NODE
, &vtysh_log_file_level_cmd
);
2423 install_element (CONFIG_NODE
, &no_vtysh_log_file_cmd
);
2424 install_element (CONFIG_NODE
, &no_vtysh_log_file_level_cmd
);
2425 install_element (CONFIG_NODE
, &vtysh_log_monitor_cmd
);
2426 install_element (CONFIG_NODE
, &vtysh_log_monitor_level_cmd
);
2427 install_element (CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
2428 install_element (CONFIG_NODE
, &vtysh_log_syslog_cmd
);
2429 install_element (CONFIG_NODE
, &vtysh_log_syslog_level_cmd
);
2430 install_element (CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
2431 install_element (CONFIG_NODE
, &vtysh_log_trap_cmd
);
2432 install_element (CONFIG_NODE
, &no_vtysh_log_trap_cmd
);
2433 install_element (CONFIG_NODE
, &vtysh_log_facility_cmd
);
2434 install_element (CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
2435 install_element (CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
2436 install_element (CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
2437 install_element (CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
2438 install_element (CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
2440 install_element (CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
2441 install_element (CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
2443 install_element (CONFIG_NODE
, &vtysh_password_cmd
);
2444 install_element (CONFIG_NODE
, &vtysh_password_text_cmd
);
2445 install_element (CONFIG_NODE
, &vtysh_enable_password_cmd
);
2446 install_element (CONFIG_NODE
, &vtysh_enable_password_text_cmd
);
2447 install_element (CONFIG_NODE
, &no_vtysh_enable_password_cmd
);