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"
37 #include "bgpd/bgp_vty.h"
42 /* VTY shell pager name. */
43 char *vtysh_pager_name
= NULL
;
45 /* VTY shell client structure. */
54 { .fd
= -1, .name
= "zebra", .flag
= VTYSH_ZEBRA
, .path
= ZEBRA_VTYSH_PATH
},
55 { .fd
= -1, .name
= "ripd", .flag
= VTYSH_RIPD
, .path
= RIP_VTYSH_PATH
},
56 { .fd
= -1, .name
= "ripngd", .flag
= VTYSH_RIPNGD
, .path
= RIPNG_VTYSH_PATH
},
57 { .fd
= -1, .name
= "ospfd", .flag
= VTYSH_OSPFD
, .path
= OSPF_VTYSH_PATH
},
58 { .fd
= -1, .name
= "ospf6d", .flag
= VTYSH_OSPF6D
, .path
= OSPF6_VTYSH_PATH
},
59 { .fd
= -1, .name
= "bgpd", .flag
= VTYSH_BGPD
, .path
= BGP_VTYSH_PATH
},
60 { .fd
= -1, .name
= "isisd", .flag
= VTYSH_ISISD
, .path
= ISIS_VTYSH_PATH
},
63 #define VTYSH_INDEX_MAX (sizeof(vtysh_client)/sizeof(vtysh_client[0]))
65 /* We need direct access to ripd to implement vtysh_exit_ripd_only. */
66 static struct vtysh_client
*ripd_client
= NULL
;
69 /* Using integrated config from Quagga.conf. Default is no. */
70 int vtysh_writeconfig_integrated
= 0;
72 extern char config_default
[];
75 vclient_close (struct vtysh_client
*vclient
)
80 "Warning: closing connection to %s because of an I/O error!\n",
87 /* Following filled with debug code to trace a problematic condition
88 * under load - it SHOULD handle it. */
89 #define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): "
91 vtysh_client_config (struct vtysh_client
*vclient
, char *line
)
106 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
109 vclient_close (vclient
);
113 /* Allow enough room for buffer to read more than a few pages from socket. */
114 bufsz
= 5 * getpagesize() + 1;
115 buf
= XMALLOC(MTYPE_TMP
, bufsz
);
116 memset(buf
, 0, bufsz
);
121 if (pbuf
>= ((buf
+ bufsz
) -1))
123 fprintf (stderr
, ERR_WHERE_STRING \
124 "warning - pbuf beyond buffer end.\n");
128 readln
= (buf
+ bufsz
) - pbuf
- 1;
129 nbytes
= read (vclient
->fd
, pbuf
, readln
);
137 fprintf(stderr
, ERR_WHERE_STRING
"(%u)", errno
);
140 if (errno
== EAGAIN
|| errno
== EIO
)
143 vclient_close (vclient
);
144 XFREE(MTYPE_TMP
, buf
);
153 if (pbuf
[i
] == '\0' && pbuf
[i
+ 1] == '\0' && pbuf
[i
+ 2] == '\0')
161 /* See if a line exists in buffer, if so parse and consume it, and
162 * reset read position. */
163 if ((eoln
= strrchr(buf
, '\n')) == NULL
)
166 if (eoln
>= ((buf
+ bufsz
) - 1))
168 fprintf (stderr
, ERR_WHERE_STRING \
169 "warning - eoln beyond buffer end.\n");
171 vtysh_config_parse(buf
);
174 left
= (size_t)(buf
+ bufsz
- eoln
);
175 memmove(buf
, eoln
, left
);
177 pbuf
= buf
+ strlen(buf
);
180 /* Parse anything left in the buffer. */
182 vtysh_config_parse (buf
);
184 XFREE(MTYPE_TMP
, buf
);
189 vtysh_client_execute (struct vtysh_client
*vclient
, const char *line
, FILE *fp
)
200 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
203 vclient_close (vclient
);
209 nbytes
= read (vclient
->fd
, buf
, sizeof(buf
)-1);
211 if (nbytes
<= 0 && errno
!= EINTR
)
213 vclient_close (vclient
);
219 if ((numnulls
== 3) && (nbytes
== 1))
226 /* check for trailling \0\0\0<ret code>,
227 * even if split across reads
228 * (see lib/vty.c::vtysh_read)
238 while (i
< nbytes
&& numnulls
< 3)
240 if (buf
[i
++] == '\0')
246 /* got 3 or more trailing NULs? */
247 if ((numnulls
>= 3) && (i
< nbytes
))
248 return (buf
[nbytes
-1]);
254 vtysh_exit_ripd_only (void)
257 vtysh_client_execute (ripd_client
, "exit", stdout
);
262 vtysh_pager_init (void)
266 pager_defined
= getenv ("VTYSH_PAGER");
269 vtysh_pager_name
= strdup (pager_defined
);
271 vtysh_pager_name
= strdup ("more");
274 /* Command execution over the vty interface. */
276 vtysh_execute_func (const char *line
, int pager
)
281 struct cmd_element
*cmd
;
285 int saved_ret
, saved_node
;
287 /* Split readline string up into the vector. */
288 vline
= cmd_make_strvec (line
);
293 saved_ret
= ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
294 saved_node
= vty
->node
;
296 /* If command doesn't succeeded in current node, try to walk up in node tree.
297 * Changing vty->node is enough to try it just out without actual walkup in
299 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
300 && vty
->node
> CONFIG_NODE
)
302 vty
->node
= node_parent(vty
->node
);
303 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
307 vty
->node
= saved_node
;
309 /* If command succeeded in any other node than current (tried > 0) we have
310 * to move into node in the vtysh where it succeeded. */
311 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
313 if ((saved_node
== BGP_VPNV4_NODE
|| saved_node
== BGP_IPV4_NODE
314 || saved_node
== BGP_IPV6_NODE
|| saved_node
== BGP_IPV4M_NODE
315 || saved_node
== BGP_IPV6M_NODE
)
318 vtysh_execute("exit-address-family");
320 else if ((saved_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
322 vtysh_execute("exit");
326 vtysh_execute ("end");
327 vtysh_execute ("configure terminal");
330 /* If command didn't succeed in any node, continue with return value from
337 cmd_free_strvec (vline
);
343 if (vty
->type
== VTY_FILE
)
344 fprintf (stdout
,"Warning...\n");
346 case CMD_ERR_AMBIGUOUS
:
347 fprintf (stdout
,"%% Ambiguous command.\n");
349 case CMD_ERR_NO_MATCH
:
350 fprintf (stdout
,"%% Unknown command.\n");
352 case CMD_ERR_INCOMPLETE
:
353 fprintf (stdout
,"%% Command incomplete.\n");
355 case CMD_SUCCESS_DAEMON
:
357 /* FIXME: Don't open pager for exit commands. popen() causes problems
358 * if exited from vtysh at all. This hack shouldn't cause any problem
359 * but is really ugly. */
360 if (pager
&& vtysh_pager_name
&& (strncmp(line
, "exit", 4) != 0))
362 fp
= popen (vtysh_pager_name
, "w");
365 perror ("popen failed for pager");
374 if (! strcmp(cmd
->string
,"configure terminal"))
376 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
378 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
379 if (cmd_stat
== CMD_WARNING
)
386 vline
= cmd_make_strvec (line
);
390 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
392 if (pclose (fp
) == -1)
394 perror ("pclose failed for pager");
401 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
402 cmd_free_strvec (vline
);
403 if (ret
!= CMD_SUCCESS_DAEMON
)
409 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
414 cmd_stat
= CMD_SUCCESS
;
415 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
417 if (cmd
->daemon
& vtysh_client
[i
].flag
)
419 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
420 if (cmd_stat
!= CMD_SUCCESS
)
424 if (cmd_stat
!= CMD_SUCCESS
)
428 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
431 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
433 if (pclose (fp
) == -1)
435 perror ("pclose failed for pager");
443 vtysh_execute_no_pager (const char *line
)
445 return vtysh_execute_func (line
, 0);
449 vtysh_execute (const char *line
)
451 return vtysh_execute_func (line
, 1);
454 /* Configration make from file. */
456 vtysh_config_from_file (struct vty
*vty
, FILE *fp
)
460 struct cmd_element
*cmd
;
462 while (fgets (vty
->buf
, VTY_BUFSIZ
, fp
))
464 if (vty
->buf
[0] == '!' || vty
->buf
[1] == '#')
467 vline
= cmd_make_strvec (vty
->buf
);
469 /* In case of comment line. */
473 /* Execute configuration command : this is strict match. */
474 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
476 /* Try again with setting node to CONFIG_NODE. */
477 if (ret
!= CMD_SUCCESS
478 && ret
!= CMD_SUCCESS_DAEMON
479 && ret
!= CMD_WARNING
)
481 if (vty
->node
== KEYCHAIN_KEY_NODE
)
483 vty
->node
= KEYCHAIN_NODE
;
484 vtysh_exit_ripd_only ();
485 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
487 if (ret
!= CMD_SUCCESS
488 && ret
!= CMD_SUCCESS_DAEMON
489 && ret
!= CMD_WARNING
)
491 vtysh_exit_ripd_only ();
492 vty
->node
= CONFIG_NODE
;
493 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
498 vtysh_execute ("end");
499 vtysh_execute ("configure terminal");
500 vty
->node
= CONFIG_NODE
;
501 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
505 cmd_free_strvec (vline
);
510 if (vty
->type
== VTY_FILE
)
511 fprintf (stdout
,"Warning...\n");
513 case CMD_ERR_AMBIGUOUS
:
514 fprintf (stdout
,"%% Ambiguous command.\n");
516 case CMD_ERR_NO_MATCH
:
517 fprintf (stdout
,"%% Unknown command: %s", vty
->buf
);
519 case CMD_ERR_INCOMPLETE
:
520 fprintf (stdout
,"%% Command incomplete.\n");
522 case CMD_SUCCESS_DAEMON
:
525 int cmd_stat
= CMD_SUCCESS
;
527 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
529 if (cmd
->daemon
& vtysh_client
[i
].flag
)
531 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
533 if (cmd_stat
!= CMD_SUCCESS
)
537 if (cmd_stat
!= CMD_SUCCESS
)
541 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
548 /* We don't care about the point of the cursor when '?' is typed. */
550 vtysh_rl_describe (void)
559 vline
= cmd_make_strvec (rl_line_buffer
);
561 /* In case of '> ?'. */
564 vline
= vector_init (1);
565 vector_set (vline
, '\0');
568 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
569 vector_set (vline
, '\0');
571 describe
= cmd_describe_command (vline
, vty
, &ret
);
573 fprintf (stdout
,"\n");
575 /* Ambiguous and no match error. */
578 case CMD_ERR_AMBIGUOUS
:
579 cmd_free_strvec (vline
);
580 fprintf (stdout
,"%% Ambiguous command.\n");
584 case CMD_ERR_NO_MATCH
:
585 cmd_free_strvec (vline
);
586 fprintf (stdout
,"%% There is no matched command.\n");
592 /* Get width of command string. */
594 for (i
= 0; i
< vector_active (describe
); i
++)
595 if ((desc
= vector_slot (describe
, i
)) != NULL
)
599 if (desc
->cmd
[0] == '\0')
602 len
= strlen (desc
->cmd
);
603 if (desc
->cmd
[0] == '.')
610 for (i
= 0; i
< vector_active (describe
); i
++)
611 if ((desc
= vector_slot (describe
, i
)) != NULL
)
613 if (desc
->cmd
[0] == '\0')
617 fprintf (stdout
," %-s\n",
618 desc
->cmd
[0] == '.' ? desc
->cmd
+ 1 : desc
->cmd
);
620 fprintf (stdout
," %-*s %s\n",
622 desc
->cmd
[0] == '.' ? desc
->cmd
+ 1 : desc
->cmd
,
626 cmd_free_strvec (vline
);
627 vector_free (describe
);
634 /* Result of cmd_complete_command() call will be stored here
635 * and used in new_completion() in order to put the space in
636 * correct places only. */
640 command_generator (const char *text
, int state
)
643 static char **matched
= NULL
;
644 static int index
= 0;
651 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
654 vline
= cmd_make_strvec (rl_line_buffer
);
658 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
659 vector_set (vline
, '\0');
661 matched
= cmd_complete_command (vline
, vty
, &complete_status
);
664 if (matched
&& matched
[index
])
665 return matched
[index
++];
671 new_completion (char *text
, int start
, int end
)
675 matches
= rl_completion_matches (text
, command_generator
);
680 if (complete_status
== CMD_COMPLETE_FULL_MATCH
)
681 rl_pending_input
= ' ';
688 /* This function is not actually being used. */
690 vtysh_completion (char *text
, int start
, int end
)
694 char **matched
= NULL
;
696 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
699 vline
= cmd_make_strvec (rl_line_buffer
);
703 /* In case of 'help \t'. */
704 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
705 vector_set (vline
, '\0');
707 matched
= cmd_complete_command (vline
, vty
, &ret
);
709 cmd_free_strvec (vline
);
711 return (char **) matched
;
715 /* Vty node structures. */
716 static struct cmd_node bgp_node
=
719 "%s(config-router)# ",
722 static struct cmd_node rip_node
=
725 "%s(config-router)# ",
728 static struct cmd_node isis_node
=
731 "%s(config-router)# ",
734 static struct cmd_node interface_node
=
740 static struct cmd_node rmap_node
=
743 "%s(config-route-map)# "
746 static struct cmd_node zebra_node
=
749 "%s(config-router)# "
752 static struct cmd_node bgp_vpnv4_node
=
755 "%s(config-router-af)# "
758 static struct cmd_node bgp_ipv4_node
=
761 "%s(config-router-af)# "
764 static struct cmd_node bgp_ipv4m_node
=
767 "%s(config-router-af)# "
770 static struct cmd_node bgp_ipv6_node
=
773 "%s(config-router-af)# "
776 static struct cmd_node bgp_ipv6m_node
=
779 "%s(config-router-af)# "
782 static struct cmd_node ospf_node
=
785 "%s(config-router)# "
788 static struct cmd_node ripng_node
=
791 "%s(config-router)# "
794 static struct cmd_node ospf6_node
=
800 static struct cmd_node keychain_node
=
803 "%s(config-keychain)# "
806 static struct cmd_node keychain_key_node
=
809 "%s(config-keychain-key)# "
812 /* Defined in lib/vty.c */
813 extern struct cmd_node vty_node
;
815 /* When '^Z' is received from vty, move down to the enable mode. */
826 vty
->node
= ENABLE_NODE
;
836 "End current mode and change to enable mode\n")
844 "router bgp " CMD_AS_RANGE
,
849 vty
->node
= BGP_NODE
;
853 ALIAS_SH (VTYSH_BGPD
,
856 "router bgp " CMD_AS_RANGE
" view WORD",
864 address_family_vpnv4
,
865 address_family_vpnv4_cmd
,
866 "address-family vpnv4",
867 "Enter Address Family command mode\n"
870 vty
->node
= BGP_VPNV4_NODE
;
875 address_family_vpnv4_unicast
,
876 address_family_vpnv4_unicast_cmd
,
877 "address-family vpnv4 unicast",
878 "Enter Address Family command mode\n"
880 "Address Family Modifier\n")
882 vty
->node
= BGP_VPNV4_NODE
;
887 address_family_ipv4_unicast
,
888 address_family_ipv4_unicast_cmd
,
889 "address-family ipv4 unicast",
890 "Enter Address Family command mode\n"
892 "Address Family Modifier\n")
894 vty
->node
= BGP_IPV4_NODE
;
899 address_family_ipv4_multicast
,
900 address_family_ipv4_multicast_cmd
,
901 "address-family ipv4 multicast",
902 "Enter Address Family command mode\n"
904 "Address Family Modifier\n")
906 vty
->node
= BGP_IPV4M_NODE
;
912 address_family_ipv6_cmd
,
913 "address-family ipv6",
914 "Enter Address Family command mode\n"
917 vty
->node
= BGP_IPV6_NODE
;
922 address_family_ipv6_unicast
,
923 address_family_ipv6_unicast_cmd
,
924 "address-family ipv6 unicast",
925 "Enter Address Family command mode\n"
927 "Address Family Modifier\n")
929 vty
->node
= BGP_IPV6_NODE
;
934 address_family_ipv6_multicast
,
935 address_family_ipv6_multicast_cmd
,
936 "address-family ipv6 multicast",
937 "Enter Address Family command mode\n"
939 "Address Family Modifier\n")
941 vty
->node
= BGP_IPV6M_NODE
;
949 "Authentication key management\n"
950 "Key-chain management\n"
953 vty
->node
= KEYCHAIN_NODE
;
960 "key <0-2147483647>",
962 "Key identifier number\n")
964 vty
->node
= KEYCHAIN_KEY_NODE
;
975 vty
->node
= RIP_NODE
;
979 DEFUNSH (VTYSH_RIPNGD
,
986 vty
->node
= RIPNG_NODE
;
990 DEFUNSH (VTYSH_OSPFD
,
994 "Enable a routing process\n"
995 "Start OSPF configuration\n")
997 vty
->node
= OSPF_NODE
;
1001 DEFUNSH (VTYSH_OSPF6D
,
1008 vty
->node
= OSPF6_NODE
;
1012 DEFUNSH (VTYSH_ISISD
,
1018 "ISO Routing area tag")
1020 vty
->node
= ISIS_NODE
;
1024 DEFUNSH (VTYSH_RMAP
,
1027 "route-map WORD (deny|permit) <1-65535>",
1028 "Create route-map or enter route-map command mode\n"
1030 "Route map denies set operations\n"
1031 "Route map permits set operations\n"
1032 "Sequence to insert to/delete from existing route-map entry\n")
1034 vty
->node
= RMAP_NODE
;
1042 "Configure a terminal line\n"
1043 "Virtual terminal\n")
1045 vty
->node
= VTY_NODE
;
1053 "Turn on privileged mode command\n")
1055 vty
->node
= ENABLE_NODE
;
1063 "Turn off privileged mode command\n")
1065 if (vty
->node
== ENABLE_NODE
)
1066 vty
->node
= VIEW_NODE
;
1071 vtysh_config_terminal
,
1072 vtysh_config_terminal_cmd
,
1073 "configure terminal",
1074 "Configuration from vty interface\n"
1075 "Configuration terminal\n")
1077 vty
->node
= CONFIG_NODE
;
1082 vtysh_exit (struct vty
*vty
)
1091 vty
->node
= ENABLE_NODE
;
1093 case INTERFACE_NODE
:
1105 vtysh_execute("end");
1106 vtysh_execute("configure terminal");
1107 vty
->node
= CONFIG_NODE
;
1109 case BGP_VPNV4_NODE
:
1111 case BGP_IPV4M_NODE
:
1113 case BGP_IPV6M_NODE
:
1114 vty
->node
= BGP_NODE
;
1116 case KEYCHAIN_KEY_NODE
:
1117 vty
->node
= KEYCHAIN_NODE
;
1129 "Exit current mode and down to previous mode\n")
1131 return vtysh_exit (vty
);
1134 ALIAS (vtysh_exit_all
,
1137 "Exit current mode and down to previous mode\n")
1139 DEFUNSH (VTYSH_BGPD
,
1140 exit_address_family
,
1141 exit_address_family_cmd
,
1142 "exit-address-family",
1143 "Exit from Address Family configuration mode\n")
1145 if (vty
->node
== BGP_IPV4_NODE
1146 || vty
->node
== BGP_IPV4M_NODE
1147 || vty
->node
== BGP_VPNV4_NODE
1148 || vty
->node
== BGP_IPV6_NODE
1149 || vty
->node
== BGP_IPV6M_NODE
)
1150 vty
->node
= BGP_NODE
;
1154 DEFUNSH (VTYSH_ZEBRA
,
1156 vtysh_exit_zebra_cmd
,
1158 "Exit current mode and down to previous mode\n")
1160 return vtysh_exit (vty
);
1163 ALIAS (vtysh_exit_zebra
,
1164 vtysh_quit_zebra_cmd
,
1166 "Exit current mode and down to previous mode\n")
1168 DEFUNSH (VTYSH_RIPD
,
1170 vtysh_exit_ripd_cmd
,
1172 "Exit current mode and down to previous mode\n")
1174 return vtysh_exit (vty
);
1177 ALIAS (vtysh_exit_ripd
,
1178 vtysh_quit_ripd_cmd
,
1180 "Exit current mode and down to previous mode\n")
1182 DEFUNSH (VTYSH_RIPNGD
,
1184 vtysh_exit_ripngd_cmd
,
1186 "Exit current mode and down to previous mode\n")
1188 return vtysh_exit (vty
);
1191 ALIAS (vtysh_exit_ripngd
,
1192 vtysh_quit_ripngd_cmd
,
1194 "Exit current mode and down to previous mode\n")
1196 DEFUNSH (VTYSH_RMAP
,
1198 vtysh_exit_rmap_cmd
,
1200 "Exit current mode and down to previous mode\n")
1202 return vtysh_exit (vty
);
1205 ALIAS (vtysh_exit_rmap
,
1206 vtysh_quit_rmap_cmd
,
1208 "Exit current mode and down to previous mode\n")
1210 DEFUNSH (VTYSH_BGPD
,
1212 vtysh_exit_bgpd_cmd
,
1214 "Exit current mode and down to previous mode\n")
1216 return vtysh_exit (vty
);
1219 ALIAS (vtysh_exit_bgpd
,
1220 vtysh_quit_bgpd_cmd
,
1222 "Exit current mode and down to previous mode\n")
1224 DEFUNSH (VTYSH_OSPFD
,
1226 vtysh_exit_ospfd_cmd
,
1228 "Exit current mode and down to previous mode\n")
1230 return vtysh_exit (vty
);
1233 ALIAS (vtysh_exit_ospfd
,
1234 vtysh_quit_ospfd_cmd
,
1236 "Exit current mode and down to previous mode\n")
1238 DEFUNSH (VTYSH_OSPF6D
,
1240 vtysh_exit_ospf6d_cmd
,
1242 "Exit current mode and down to previous mode\n")
1244 return vtysh_exit (vty
);
1247 ALIAS (vtysh_exit_ospf6d
,
1248 vtysh_quit_ospf6d_cmd
,
1250 "Exit current mode and down to previous mode\n")
1252 DEFUNSH (VTYSH_ISISD
,
1254 vtysh_exit_isisd_cmd
,
1256 "Exit current mode and down to previous mode\n")
1258 return vtysh_exit (vty
);
1261 ALIAS (vtysh_exit_isisd
,
1262 vtysh_quit_isisd_cmd
,
1264 "Exit current mode and down to previous mode\n")
1267 vtysh_exit_line_vty
,
1268 vtysh_exit_line_vty_cmd
,
1270 "Exit current mode and down to previous mode\n")
1272 return vtysh_exit (vty
);
1275 ALIAS (vtysh_exit_line_vty
,
1276 vtysh_quit_line_vty_cmd
,
1278 "Exit current mode and down to previous mode\n")
1280 DEFUNSH (VTYSH_INTERFACE
,
1282 vtysh_interface_cmd
,
1284 "Select an interface to configure\n"
1285 "Interface's name\n")
1287 vty
->node
= INTERFACE_NODE
;
1291 /* TODO Implement "no interface command in isisd. */
1292 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_RIPNGD
|VTYSH_OSPFD
|VTYSH_OSPF6D
,
1293 vtysh_no_interface_cmd
,
1294 "no interface IFNAME",
1296 "Delete a pseudo interface's configuration\n"
1297 "Interface's name\n")
1299 /* TODO Implement interface description commands in ripngd, ospf6d
1301 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1303 "description .LINE",
1304 "Interface specific description\n"
1305 "Characters describing this interface\n")
1307 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1308 no_interface_desc_cmd
,
1311 "Interface specific description\n")
1313 DEFUNSH (VTYSH_INTERFACE
,
1314 vtysh_exit_interface
,
1315 vtysh_exit_interface_cmd
,
1317 "Exit current mode and down to previous mode\n")
1319 return vtysh_exit (vty
);
1322 ALIAS (vtysh_exit_interface
,
1323 vtysh_quit_interface_cmd
,
1325 "Exit current mode and down to previous mode\n")
1328 DEFUN (vtysh_show_memory
,
1329 vtysh_show_memory_cmd
,
1332 "Memory statistics\n")
1335 int ret
= CMD_SUCCESS
;
1336 char line
[] = "show memory\n";
1338 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
1339 if ( vtysh_client
[i
].fd
>= 0 )
1341 fprintf (stdout
, "Memory statistics for %s:\n",
1342 vtysh_client
[i
].name
);
1343 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1344 fprintf (stdout
,"\n");
1350 /* Logging commands. */
1351 DEFUN (vtysh_show_logging
,
1352 vtysh_show_logging_cmd
,
1355 "Show current logging configuration\n")
1358 int ret
= CMD_SUCCESS
;
1359 char line
[] = "show logging\n";
1361 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
1362 if ( vtysh_client
[i
].fd
>= 0 )
1364 fprintf (stdout
,"Logging configuration for %s:\n",
1365 vtysh_client
[i
].name
);
1366 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1367 fprintf (stdout
,"\n");
1375 vtysh_log_stdout_cmd
,
1378 "Set stdout logging level\n")
1384 vtysh_log_stdout_level
,
1385 vtysh_log_stdout_level_cmd
,
1386 "log stdout "LOG_LEVELS
,
1388 "Set stdout logging level\n"
1395 no_vtysh_log_stdout
,
1396 no_vtysh_log_stdout_cmd
,
1397 "no log stdout [LEVEL]",
1400 "Cancel logging to stdout\n"
1409 "log file FILENAME",
1412 "Logging filename\n")
1418 vtysh_log_file_level
,
1419 vtysh_log_file_level_cmd
,
1420 "log file FILENAME "LOG_LEVELS
,
1423 "Logging filename\n"
1431 no_vtysh_log_file_cmd
,
1432 "no log file [FILENAME]",
1435 "Cancel logging to file\n"
1436 "Logging file name\n")
1441 ALIAS_SH (VTYSH_ALL
,
1443 no_vtysh_log_file_level_cmd
,
1444 "no log file FILENAME LEVEL",
1447 "Cancel logging to file\n"
1448 "Logging file name\n"
1453 vtysh_log_monitor_cmd
,
1456 "Set terminal line (monitor) logging level\n")
1462 vtysh_log_monitor_level
,
1463 vtysh_log_monitor_level_cmd
,
1464 "log monitor "LOG_LEVELS
,
1466 "Set terminal line (monitor) logging level\n"
1473 no_vtysh_log_monitor
,
1474 no_vtysh_log_monitor_cmd
,
1475 "no log monitor [LEVEL]",
1478 "Disable terminal line (monitor) logging\n"
1486 vtysh_log_syslog_cmd
,
1489 "Set syslog logging level\n")
1495 vtysh_log_syslog_level
,
1496 vtysh_log_syslog_level_cmd
,
1497 "log syslog "LOG_LEVELS
,
1499 "Set syslog logging level\n"
1506 no_vtysh_log_syslog
,
1507 no_vtysh_log_syslog_cmd
,
1508 "no log syslog [LEVEL]",
1511 "Cancel logging to syslog\n"
1519 vtysh_log_facility_cmd
,
1520 "log facility "LOG_FACILITIES
,
1522 "Facility parameter for syslog messages\n"
1530 no_vtysh_log_facility
,
1531 no_vtysh_log_facility_cmd
,
1532 "no log facility [FACILITY]",
1535 "Reset syslog facility to default (daemon)\n"
1536 "Syslog facility\n")
1542 DEFUNSH_DEPRECATED (VTYSH_ALL
,
1545 "log trap "LOG_LEVELS
,
1547 "(Deprecated) Set logging level and default for all destinations\n"
1554 DEFUNSH_DEPRECATED (VTYSH_ALL
,
1556 no_vtysh_log_trap_cmd
,
1557 "no log trap [LEVEL]",
1560 "Permit all logging information\n"
1567 vtysh_log_record_priority
,
1568 vtysh_log_record_priority_cmd
,
1569 "log record-priority",
1571 "Log the priority of the message within the message\n")
1577 no_vtysh_log_record_priority
,
1578 no_vtysh_log_record_priority_cmd
,
1579 "no log record-priority",
1582 "Do not log the priority of the message within the message\n")
1588 vtysh_log_timestamp_precision
,
1589 vtysh_log_timestamp_precision_cmd
,
1590 "log timestamp precision <0-6>",
1592 "Timestamp configuration\n"
1593 "Set the timestamp precision\n"
1594 "Number of subsecond digits\n")
1600 no_vtysh_log_timestamp_precision
,
1601 no_vtysh_log_timestamp_precision_cmd
,
1602 "no log timestamp precision",
1605 "Timestamp configuration\n"
1606 "Reset the timestamp precision to the default value of 0\n")
1612 vtysh_service_password_encrypt
,
1613 vtysh_service_password_encrypt_cmd
,
1614 "service password-encryption",
1615 "Set up miscellaneous service\n"
1616 "Enable encrypted passwords\n")
1622 no_vtysh_service_password_encrypt
,
1623 no_vtysh_service_password_encrypt_cmd
,
1624 "no service password-encryption",
1626 "Set up miscellaneous service\n"
1627 "Enable encrypted passwords\n")
1633 vtysh_config_password
,
1635 "password (8|) WORD",
1636 "Assign the terminal connection password\n"
1637 "Specifies a HIDDEN password will follow\n"
1639 "The HIDDEN line password string\n")
1645 vtysh_password_text
,
1646 vtysh_password_text_cmd
,
1648 "Assign the terminal connection password\n"
1649 "The UNENCRYPTED (cleartext) line password\n")
1655 vtysh_config_enable_password
,
1656 vtysh_enable_password_cmd
,
1657 "enable password (8|) WORD",
1658 "Modify enable password parameters\n"
1659 "Assign the privileged level password\n"
1660 "Specifies a HIDDEN password will follow\n"
1662 "The HIDDEN 'enable' password string\n")
1668 vtysh_enable_password_text
,
1669 vtysh_enable_password_text_cmd
,
1670 "enable password LINE",
1671 "Modify enable password parameters\n"
1672 "Assign the privileged level password\n"
1673 "The UNENCRYPTED (cleartext) 'enable' password\n")
1679 no_vtysh_config_enable_password
,
1680 no_vtysh_enable_password_cmd
,
1681 "no enable password",
1683 "Modify enable password parameters\n"
1684 "Assign the privileged level password\n")
1689 DEFUN (vtysh_write_terminal
,
1690 vtysh_write_terminal_cmd
,
1692 "Write running configuration to memory, network, or terminal\n"
1693 "Write to terminal\n")
1697 char line
[] = "write terminal\n";
1700 if (vtysh_pager_name
)
1702 fp
= popen (vtysh_pager_name
, "w");
1712 vty_out (vty
, "Building configuration...%s", VTY_NEWLINE
);
1713 vty_out (vty
, "%sCurrent configuration:%s", VTY_NEWLINE
,
1715 vty_out (vty
, "!%s", VTY_NEWLINE
);
1717 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
1718 ret
= vtysh_client_config (&vtysh_client
[i
], line
);
1720 /* Integrate vtysh specific configuration. */
1721 vtysh_config_write ();
1723 vtysh_config_dump (fp
);
1725 if (vtysh_pager_name
&& fp
)
1728 if (pclose (fp
) == -1)
1736 vty_out (vty
, "end%s", VTY_NEWLINE
);
1741 DEFUN (vtysh_integrated_config
,
1742 vtysh_integrated_config_cmd
,
1743 "service integrated-vtysh-config",
1744 "Set up miscellaneous service\n"
1745 "Write configuration into integrated file\n")
1747 vtysh_writeconfig_integrated
= 1;
1751 DEFUN (no_vtysh_integrated_config
,
1752 no_vtysh_integrated_config_cmd
,
1753 "no service integrated-vtysh-config",
1755 "Set up miscellaneous service\n"
1756 "Write configuration into integrated file\n")
1758 vtysh_writeconfig_integrated
= 0;
1763 write_config_integrated(void)
1767 char line
[] = "write terminal\n";
1769 char *integrate_sav
= NULL
;
1771 integrate_sav
= malloc (strlen (integrate_default
) +
1772 strlen (CONF_BACKUP_EXT
) + 1);
1773 strcpy (integrate_sav
, integrate_default
);
1774 strcat (integrate_sav
, CONF_BACKUP_EXT
);
1776 fprintf (stdout
,"Building Configuration...\n");
1778 /* Move current configuration file to backup config file. */
1779 unlink (integrate_sav
);
1780 rename (integrate_default
, integrate_sav
);
1781 free (integrate_sav
);
1783 fp
= fopen (integrate_default
, "w");
1786 fprintf (stdout
,"%% Can't open configuration file %s.\n",
1791 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
1792 ret
= vtysh_client_config (&vtysh_client
[i
], line
);
1794 vtysh_config_dump (fp
);
1798 if (chmod (integrate_default
, CONFIGFILE_MASK
) != 0)
1800 fprintf (stdout
,"%% Can't chmod configuration file %s: %s (%d)\n",
1801 integrate_default
, safe_strerror(errno
), errno
);
1805 fprintf(stdout
,"Integrated configuration saved to %s\n",integrate_default
);
1807 fprintf (stdout
,"[OK]\n");
1812 DEFUN (vtysh_write_memory
,
1813 vtysh_write_memory_cmd
,
1815 "Write running configuration to memory, network, or terminal\n"
1816 "Write configuration to the file (same as write file)\n")
1818 int ret
= CMD_SUCCESS
;
1819 char line
[] = "write memory\n";
1822 /* If integrated Quagga.conf explicitely set. */
1823 if (vtysh_writeconfig_integrated
)
1824 return write_config_integrated();
1826 fprintf (stdout
,"Building Configuration...\n");
1828 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
1829 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1831 fprintf (stdout
,"[OK]\n");
1836 ALIAS (vtysh_write_memory
,
1837 vtysh_copy_runningconfig_startupconfig_cmd
,
1838 "copy running-config startup-config",
1839 "Copy from one file to another\n"
1840 "Copy from current system configuration\n"
1841 "Copy to startup configuration\n")
1843 ALIAS (vtysh_write_memory
,
1844 vtysh_write_file_cmd
,
1846 "Write running configuration to memory, network, or terminal\n"
1847 "Write configuration to the file (same as write memory)\n")
1849 ALIAS (vtysh_write_memory
,
1852 "Write running configuration to memory, network, or terminal\n")
1854 ALIAS (vtysh_write_terminal
,
1855 vtysh_show_running_config_cmd
,
1856 "show running-config",
1858 "Current operating configuration\n")
1860 DEFUN (vtysh_terminal_length
,
1861 vtysh_terminal_length_cmd
,
1862 "terminal length <0-512>",
1863 "Set terminal line parameters\n"
1864 "Set number of lines on a screen\n"
1865 "Number of lines on screen (0 for no pausing)\n")
1868 char *endptr
= NULL
;
1869 char default_pager
[10];
1871 lines
= strtol (argv
[0], &endptr
, 10);
1872 if (lines
< 0 || lines
> 512 || *endptr
!= '\0')
1874 vty_out (vty
, "length is malformed%s", VTY_NEWLINE
);
1878 if (vtysh_pager_name
)
1880 free (vtysh_pager_name
);
1881 vtysh_pager_name
= NULL
;
1886 snprintf(default_pager
, 10, "more -%i", lines
);
1887 vtysh_pager_name
= strdup (default_pager
);
1893 DEFUN (vtysh_terminal_no_length
,
1894 vtysh_terminal_no_length_cmd
,
1895 "terminal no length",
1896 "Set terminal line parameters\n"
1898 "Set number of lines on a screen\n")
1900 if (vtysh_pager_name
)
1902 free (vtysh_pager_name
);
1903 vtysh_pager_name
= NULL
;
1910 DEFUN (vtysh_show_daemons
,
1911 vtysh_show_daemons_cmd
,
1914 "Show list of running daemons\n")
1918 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
1919 if ( vtysh_client
[i
].fd
>= 0 )
1920 vty_out(vty
, " %s", vtysh_client
[i
].name
);
1921 vty_out(vty
, "%s", VTY_NEWLINE
);
1926 /* Execute command in child process. */
1928 execute_command (const char *command
, int argc
, const char *arg1
,
1940 /* Failure of fork(). */
1941 fprintf (stderr
, "Can't fork: %s\n", safe_strerror (errno
));
1946 /* This is child process. */
1950 ret
= execlp (command
, command
, (const char *)NULL
);
1953 ret
= execlp (command
, command
, arg1
, (const char *)NULL
);
1956 ret
= execlp (command
, command
, arg1
, arg2
, (const char *)NULL
);
1960 /* When execlp suceed, this part is not executed. */
1961 fprintf (stderr
, "Can't execute %s: %s\n", command
, safe_strerror (errno
));
1966 /* This is parent. */
1968 ret
= wait4 (pid
, &status
, 0, NULL
);
1977 "Send echo messages\n"
1978 "Ping destination address or hostname\n")
1980 execute_command ("ping", 1, argv
[0], NULL
);
1987 "Send echo messages\n"
1989 "Ping destination address or hostname\n")
1991 DEFUN (vtysh_traceroute
,
1992 vtysh_traceroute_cmd
,
1994 "Trace route to destination\n"
1995 "Trace route to destination address or hostname\n")
1997 execute_command ("traceroute", 1, argv
[0], NULL
);
2001 ALIAS (vtysh_traceroute
,
2002 vtysh_traceroute_ip_cmd
,
2003 "traceroute ip WORD",
2004 "Trace route to destination\n"
2006 "Trace route to destination address or hostname\n")
2012 "Send echo messages\n"
2014 "Ping destination address or hostname\n")
2016 execute_command ("ping6", 1, argv
[0], NULL
);
2020 DEFUN (vtysh_traceroute6
,
2021 vtysh_traceroute6_cmd
,
2022 "traceroute ipv6 WORD",
2023 "Trace route to destination\n"
2025 "Trace route to destination address or hostname\n")
2027 execute_command ("traceroute6", 1, argv
[0], NULL
);
2032 DEFUN (vtysh_telnet
,
2035 "Open a telnet connection\n"
2036 "IP address or hostname of a remote system\n")
2038 execute_command ("telnet", 1, argv
[0], NULL
);
2042 DEFUN (vtysh_telnet_port
,
2043 vtysh_telnet_port_cmd
,
2045 "Open a telnet connection\n"
2046 "IP address or hostname of a remote system\n"
2047 "TCP Port number\n")
2049 execute_command ("telnet", 2, argv
[0], argv
[1]);
2056 "Open an ssh connection\n"
2059 execute_command ("ssh", 1, argv
[0], NULL
);
2063 DEFUN (vtysh_start_shell
,
2064 vtysh_start_shell_cmd
,
2066 "Start UNIX shell\n")
2068 execute_command ("sh", 0, NULL
, NULL
);
2072 DEFUN (vtysh_start_bash
,
2073 vtysh_start_bash_cmd
,
2075 "Start UNIX shell\n"
2078 execute_command ("bash", 0, NULL
, NULL
);
2082 DEFUN (vtysh_start_zsh
,
2083 vtysh_start_zsh_cmd
,
2085 "Start UNIX shell\n"
2088 execute_command ("zsh", 0, NULL
, NULL
);
2093 vtysh_install_default (enum node_type node
)
2095 install_element (node
, &config_list_cmd
);
2098 /* Making connection to protocol daemon. */
2100 vtysh_connect (struct vtysh_client
*vclient
)
2104 struct sockaddr_un addr
;
2107 /* Stat socket to see if we have permission to access it. */
2108 ret
= stat (vclient
->path
, &s_stat
);
2109 if (ret
< 0 && errno
!= ENOENT
)
2111 fprintf (stderr
, "vtysh_connect(%s): stat = %s\n",
2112 vclient
->path
, safe_strerror(errno
));
2118 if (! S_ISSOCK(s_stat
.st_mode
))
2120 fprintf (stderr
, "vtysh_connect(%s): Not a socket\n",
2127 sock
= socket (AF_UNIX
, SOCK_STREAM
, 0);
2131 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", vclient
->path
,
2132 safe_strerror(errno
));
2137 memset (&addr
, 0, sizeof (struct sockaddr_un
));
2138 addr
.sun_family
= AF_UNIX
;
2139 strncpy (addr
.sun_path
, vclient
->path
, strlen (vclient
->path
));
2140 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
2141 len
= addr
.sun_len
= SUN_LEN(&addr
);
2143 len
= sizeof (addr
.sun_family
) + strlen (addr
.sun_path
);
2144 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
2146 ret
= connect (sock
, (struct sockaddr
*) &addr
, len
);
2150 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", vclient
->path
,
2151 safe_strerror(errno
));
2162 vtysh_connect_all(const char *daemon_name
)
2168 for (i
= 0; i
< VTYSH_INDEX_MAX
; i
++)
2170 if (!daemon_name
|| !strcmp(daemon_name
, vtysh_client
[i
].name
))
2173 if (vtysh_connect(&vtysh_client
[i
]) == 0)
2175 /* We need direct access to ripd in vtysh_exit_ripd_only. */
2176 if (vtysh_client
[i
].flag
== VTYSH_RIPD
)
2177 ripd_client
= &vtysh_client
[i
];
2181 fprintf(stderr
, "Error: no daemons match name %s!\n", daemon_name
);
2185 /* To disable readline's filename completion. */
2187 vtysh_completion_entry_function (const char *ignore
, int invoking_key
)
2193 vtysh_readline_init (void)
2195 /* readline related settings. */
2196 rl_bind_key ('?', (Function
*) vtysh_rl_describe
);
2197 rl_completion_entry_function
= vtysh_completion_entry_function
;
2198 rl_attempted_completion_function
= (CPPFunction
*)new_completion
;
2199 /* do not append space after completion. It will be appended
2200 * in new_completion() function explicitly. */
2201 rl_completion_append_character
= '\0';
2207 static struct utsname names
;
2208 static char buf
[100];
2209 const char*hostname
;
2210 extern struct host host
;
2212 hostname
= host
.name
;
2216 if (!names
.nodename
[0])
2218 hostname
= names
.nodename
;
2221 snprintf (buf
, sizeof buf
, cmd_prompt (vty
->node
), hostname
);
2227 vtysh_init_vty (void)
2229 /* Make vty structure. */
2231 vty
->type
= VTY_SHELL
;
2232 vty
->node
= VIEW_NODE
;
2234 /* Initialize commands. */
2237 /* Install nodes. */
2238 install_node (&bgp_node
, NULL
);
2239 install_node (&rip_node
, NULL
);
2240 install_node (&interface_node
, NULL
);
2241 install_node (&rmap_node
, NULL
);
2242 install_node (&zebra_node
, NULL
);
2243 install_node (&bgp_vpnv4_node
, NULL
);
2244 install_node (&bgp_ipv4_node
, NULL
);
2245 install_node (&bgp_ipv4m_node
, NULL
);
2246 /* #ifdef HAVE_IPV6 */
2247 install_node (&bgp_ipv6_node
, NULL
);
2248 install_node (&bgp_ipv6m_node
, NULL
);
2250 install_node (&ospf_node
, NULL
);
2251 /* #ifdef HAVE_IPV6 */
2252 install_node (&ripng_node
, NULL
);
2253 install_node (&ospf6_node
, NULL
);
2255 install_node (&keychain_node
, NULL
);
2256 install_node (&keychain_key_node
, NULL
);
2257 install_node (&isis_node
, NULL
);
2258 install_node (&vty_node
, NULL
);
2260 vtysh_install_default (VIEW_NODE
);
2261 vtysh_install_default (ENABLE_NODE
);
2262 vtysh_install_default (CONFIG_NODE
);
2263 vtysh_install_default (BGP_NODE
);
2264 vtysh_install_default (RIP_NODE
);
2265 vtysh_install_default (INTERFACE_NODE
);
2266 vtysh_install_default (RMAP_NODE
);
2267 vtysh_install_default (ZEBRA_NODE
);
2268 vtysh_install_default (BGP_VPNV4_NODE
);
2269 vtysh_install_default (BGP_IPV4_NODE
);
2270 vtysh_install_default (BGP_IPV4M_NODE
);
2271 vtysh_install_default (BGP_IPV6_NODE
);
2272 vtysh_install_default (BGP_IPV6M_NODE
);
2273 vtysh_install_default (OSPF_NODE
);
2274 vtysh_install_default (RIPNG_NODE
);
2275 vtysh_install_default (OSPF6_NODE
);
2276 vtysh_install_default (ISIS_NODE
);
2277 vtysh_install_default (KEYCHAIN_NODE
);
2278 vtysh_install_default (KEYCHAIN_KEY_NODE
);
2279 vtysh_install_default (VTY_NODE
);
2281 install_element (VIEW_NODE
, &vtysh_enable_cmd
);
2282 install_element (ENABLE_NODE
, &vtysh_config_terminal_cmd
);
2283 install_element (ENABLE_NODE
, &vtysh_disable_cmd
);
2285 /* "exit" command. */
2286 install_element (VIEW_NODE
, &vtysh_exit_all_cmd
);
2287 install_element (VIEW_NODE
, &vtysh_quit_all_cmd
);
2288 install_element (CONFIG_NODE
, &vtysh_exit_all_cmd
);
2289 /* install_element (CONFIG_NODE, &vtysh_quit_all_cmd); */
2290 install_element (ENABLE_NODE
, &vtysh_exit_all_cmd
);
2291 install_element (ENABLE_NODE
, &vtysh_quit_all_cmd
);
2292 install_element (RIP_NODE
, &vtysh_exit_ripd_cmd
);
2293 install_element (RIP_NODE
, &vtysh_quit_ripd_cmd
);
2294 install_element (RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
2295 install_element (RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
2296 install_element (OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
2297 install_element (OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
2298 install_element (OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
2299 install_element (OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
2300 install_element (BGP_NODE
, &vtysh_exit_bgpd_cmd
);
2301 install_element (BGP_NODE
, &vtysh_quit_bgpd_cmd
);
2302 install_element (BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
2303 install_element (BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
2304 install_element (BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
2305 install_element (BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
2306 install_element (BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
2307 install_element (BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
2308 install_element (BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
2309 install_element (BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
2310 install_element (BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
2311 install_element (BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
2312 install_element (ISIS_NODE
, &vtysh_exit_isisd_cmd
);
2313 install_element (ISIS_NODE
, &vtysh_quit_isisd_cmd
);
2314 install_element (KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
2315 install_element (KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
2316 install_element (KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
2317 install_element (KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
2318 install_element (RMAP_NODE
, &vtysh_exit_rmap_cmd
);
2319 install_element (RMAP_NODE
, &vtysh_quit_rmap_cmd
);
2320 install_element (VTY_NODE
, &vtysh_exit_line_vty_cmd
);
2321 install_element (VTY_NODE
, &vtysh_quit_line_vty_cmd
);
2323 /* "end" command. */
2324 install_element (CONFIG_NODE
, &vtysh_end_all_cmd
);
2325 install_element (ENABLE_NODE
, &vtysh_end_all_cmd
);
2326 install_element (RIP_NODE
, &vtysh_end_all_cmd
);
2327 install_element (RIPNG_NODE
, &vtysh_end_all_cmd
);
2328 install_element (OSPF_NODE
, &vtysh_end_all_cmd
);
2329 install_element (OSPF6_NODE
, &vtysh_end_all_cmd
);
2330 install_element (BGP_NODE
, &vtysh_end_all_cmd
);
2331 install_element (BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
2332 install_element (BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
2333 install_element (BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
2334 install_element (BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
2335 install_element (BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
2336 install_element (ISIS_NODE
, &vtysh_end_all_cmd
);
2337 install_element (KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
2338 install_element (KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
2339 install_element (RMAP_NODE
, &vtysh_end_all_cmd
);
2340 install_element (VTY_NODE
, &vtysh_end_all_cmd
);
2342 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
2343 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
2344 install_element (INTERFACE_NODE
, &vtysh_end_all_cmd
);
2345 install_element (INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
2346 install_element (INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
2347 install_element (CONFIG_NODE
, &router_rip_cmd
);
2349 install_element (CONFIG_NODE
, &router_ripng_cmd
);
2351 install_element (CONFIG_NODE
, &router_ospf_cmd
);
2353 install_element (CONFIG_NODE
, &router_ospf6_cmd
);
2355 install_element (CONFIG_NODE
, &router_isis_cmd
);
2356 install_element (CONFIG_NODE
, &router_bgp_cmd
);
2357 install_element (CONFIG_NODE
, &router_bgp_view_cmd
);
2358 install_element (BGP_NODE
, &address_family_vpnv4_cmd
);
2359 install_element (BGP_NODE
, &address_family_vpnv4_unicast_cmd
);
2360 install_element (BGP_NODE
, &address_family_ipv4_unicast_cmd
);
2361 install_element (BGP_NODE
, &address_family_ipv4_multicast_cmd
);
2363 install_element (BGP_NODE
, &address_family_ipv6_cmd
);
2364 install_element (BGP_NODE
, &address_family_ipv6_unicast_cmd
);
2366 install_element (BGP_VPNV4_NODE
, &exit_address_family_cmd
);
2367 install_element (BGP_IPV4_NODE
, &exit_address_family_cmd
);
2368 install_element (BGP_IPV4M_NODE
, &exit_address_family_cmd
);
2369 install_element (BGP_IPV6_NODE
, &exit_address_family_cmd
);
2370 install_element (BGP_IPV6M_NODE
, &exit_address_family_cmd
);
2371 install_element (CONFIG_NODE
, &key_chain_cmd
);
2372 install_element (CONFIG_NODE
, &route_map_cmd
);
2373 install_element (CONFIG_NODE
, &vtysh_line_vty_cmd
);
2374 install_element (KEYCHAIN_NODE
, &key_cmd
);
2375 install_element (KEYCHAIN_NODE
, &key_chain_cmd
);
2376 install_element (KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
2377 install_element (CONFIG_NODE
, &vtysh_interface_cmd
);
2378 install_element (CONFIG_NODE
, &vtysh_no_interface_cmd
);
2379 install_element (ENABLE_NODE
, &vtysh_show_running_config_cmd
);
2380 install_element (ENABLE_NODE
, &vtysh_copy_runningconfig_startupconfig_cmd
);
2381 install_element (ENABLE_NODE
, &vtysh_write_file_cmd
);
2382 install_element (ENABLE_NODE
, &vtysh_write_cmd
);
2384 /* "write terminal" command. */
2385 install_element (ENABLE_NODE
, &vtysh_write_terminal_cmd
);
2387 install_element (CONFIG_NODE
, &vtysh_integrated_config_cmd
);
2388 install_element (CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
2390 /* "write memory" command. */
2391 install_element (ENABLE_NODE
, &vtysh_write_memory_cmd
);
2393 install_element (VIEW_NODE
, &vtysh_terminal_length_cmd
);
2394 install_element (ENABLE_NODE
, &vtysh_terminal_length_cmd
);
2395 install_element (VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
2396 install_element (ENABLE_NODE
, &vtysh_terminal_no_length_cmd
);
2397 install_element (VIEW_NODE
, &vtysh_show_daemons_cmd
);
2398 install_element (ENABLE_NODE
, &vtysh_show_daemons_cmd
);
2400 install_element (VIEW_NODE
, &vtysh_ping_cmd
);
2401 install_element (VIEW_NODE
, &vtysh_ping_ip_cmd
);
2402 install_element (VIEW_NODE
, &vtysh_traceroute_cmd
);
2403 install_element (VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
2405 install_element (VIEW_NODE
, &vtysh_ping6_cmd
);
2406 install_element (VIEW_NODE
, &vtysh_traceroute6_cmd
);
2408 install_element (VIEW_NODE
, &vtysh_telnet_cmd
);
2409 install_element (VIEW_NODE
, &vtysh_telnet_port_cmd
);
2410 install_element (VIEW_NODE
, &vtysh_ssh_cmd
);
2411 install_element (ENABLE_NODE
, &vtysh_ping_cmd
);
2412 install_element (ENABLE_NODE
, &vtysh_ping_ip_cmd
);
2413 install_element (ENABLE_NODE
, &vtysh_traceroute_cmd
);
2414 install_element (ENABLE_NODE
, &vtysh_traceroute_ip_cmd
);
2416 install_element (ENABLE_NODE
, &vtysh_ping6_cmd
);
2417 install_element (ENABLE_NODE
, &vtysh_traceroute6_cmd
);
2419 install_element (ENABLE_NODE
, &vtysh_telnet_cmd
);
2420 install_element (ENABLE_NODE
, &vtysh_telnet_port_cmd
);
2421 install_element (ENABLE_NODE
, &vtysh_ssh_cmd
);
2422 install_element (ENABLE_NODE
, &vtysh_start_shell_cmd
);
2423 install_element (ENABLE_NODE
, &vtysh_start_bash_cmd
);
2424 install_element (ENABLE_NODE
, &vtysh_start_zsh_cmd
);
2426 install_element (VIEW_NODE
, &vtysh_show_memory_cmd
);
2427 install_element (ENABLE_NODE
, &vtysh_show_memory_cmd
);
2430 install_element (ENABLE_NODE
, &vtysh_show_logging_cmd
);
2431 install_element (VIEW_NODE
, &vtysh_show_logging_cmd
);
2432 install_element (CONFIG_NODE
, &vtysh_log_stdout_cmd
);
2433 install_element (CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
2434 install_element (CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
2435 install_element (CONFIG_NODE
, &vtysh_log_file_cmd
);
2436 install_element (CONFIG_NODE
, &vtysh_log_file_level_cmd
);
2437 install_element (CONFIG_NODE
, &no_vtysh_log_file_cmd
);
2438 install_element (CONFIG_NODE
, &no_vtysh_log_file_level_cmd
);
2439 install_element (CONFIG_NODE
, &vtysh_log_monitor_cmd
);
2440 install_element (CONFIG_NODE
, &vtysh_log_monitor_level_cmd
);
2441 install_element (CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
2442 install_element (CONFIG_NODE
, &vtysh_log_syslog_cmd
);
2443 install_element (CONFIG_NODE
, &vtysh_log_syslog_level_cmd
);
2444 install_element (CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
2445 install_element (CONFIG_NODE
, &vtysh_log_trap_cmd
);
2446 install_element (CONFIG_NODE
, &no_vtysh_log_trap_cmd
);
2447 install_element (CONFIG_NODE
, &vtysh_log_facility_cmd
);
2448 install_element (CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
2449 install_element (CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
2450 install_element (CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
2451 install_element (CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
2452 install_element (CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
2454 install_element (CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
2455 install_element (CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
2457 install_element (CONFIG_NODE
, &vtysh_password_cmd
);
2458 install_element (CONFIG_NODE
, &vtysh_password_text_cmd
);
2459 install_element (CONFIG_NODE
, &vtysh_enable_password_cmd
);
2460 install_element (CONFIG_NODE
, &vtysh_enable_password_text_cmd
);
2461 install_element (CONFIG_NODE
, &no_vtysh_enable_password_cmd
);