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>
41 #include "vtysh/vtysh.h"
43 #include "bgpd/bgp_vty.h"
47 #include "lib/grammar_sandbox.h"
49 DEFINE_MTYPE_STATIC(MVTYSH
, VTYSH_CMD
, "Vtysh cmd copy")
54 /* VTY shell pager name. */
55 char *vtysh_pager_name
= NULL
;
57 /* VTY shell client structure. */
64 struct vtysh_client
*next
;
67 struct vtysh_client vtysh_client
[] =
69 { .fd
= -1, .name
= "zebra", .flag
= VTYSH_ZEBRA
, .path
= ZEBRA_VTYSH_PATH
, .next
= NULL
},
70 { .fd
= -1, .name
= "ripd", .flag
= VTYSH_RIPD
, .path
= RIP_VTYSH_PATH
, .next
= NULL
},
71 { .fd
= -1, .name
= "ripngd", .flag
= VTYSH_RIPNGD
, .path
= RIPNG_VTYSH_PATH
, .next
= NULL
},
72 { .fd
= -1, .name
= "ospfd", .flag
= VTYSH_OSPFD
, .path
= OSPF_VTYSH_PATH
, .next
= NULL
},
73 { .fd
= -1, .name
= "ospf6d", .flag
= VTYSH_OSPF6D
, .path
= OSPF6_VTYSH_PATH
, .next
= NULL
},
74 { .fd
= -1, .name
= "bgpd", .flag
= VTYSH_BGPD
, .path
= BGP_VTYSH_PATH
, .next
= NULL
},
75 { .fd
= -1, .name
= "isisd", .flag
= VTYSH_ISISD
, .path
= ISIS_VTYSH_PATH
, .next
= NULL
},
76 { .fd
= -1, .name
= "pimd", .flag
= VTYSH_PIMD
, .path
= PIM_VTYSH_PATH
, .next
= NULL
},
79 /* Using integrated config from Quagga.conf. Default is no. */
80 int vtysh_writeconfig_integrated
= 1;
82 extern char config_default
[];
85 vclient_close (struct vtysh_client
*vclient
)
90 "Warning: closing connection to %s because of an I/O error!\n",
97 /* Return true if str begins with prefix, else return false */
99 begins_with(const char *str
, const char *prefix
)
103 size_t lenstr
= strlen(str
);
104 size_t lenprefix
= strlen(prefix
);
105 if (lenprefix
> lenstr
)
107 return strncmp(str
, prefix
, lenprefix
) == 0;
110 /* Following filled with debug code to trace a problematic condition
111 * under load - it SHOULD handle it. */
112 #define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): "
114 vtysh_client_config_one (struct vtysh_client
*vclient
, char *line
)
129 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
132 vclient_close (vclient
);
136 /* Allow enough room for buffer to read more than a few pages from socket. */
137 bufsz
= 5 * getpagesize() + 1;
138 buf
= XMALLOC(MTYPE_TMP
, bufsz
);
139 memset(buf
, 0, bufsz
);
144 if (pbuf
>= ((buf
+ bufsz
) -1))
146 fprintf (stderr
, ERR_WHERE_STRING \
147 "warning - pbuf beyond buffer end.\n");
151 readln
= (buf
+ bufsz
) - pbuf
- 1;
152 nbytes
= read (vclient
->fd
, pbuf
, readln
);
160 fprintf(stderr
, ERR_WHERE_STRING
"(%u)", errno
);
163 if (errno
== EAGAIN
|| errno
== EIO
)
166 vclient_close (vclient
);
167 XFREE(MTYPE_TMP
, buf
);
176 if (pbuf
[i
] == '\0' && pbuf
[i
+ 1] == '\0' && pbuf
[i
+ 2] == '\0')
184 /* See if a line exists in buffer, if so parse and consume it, and
185 * reset read position. */
186 if ((eoln
= strrchr(buf
, '\n')) == NULL
)
189 if (eoln
>= ((buf
+ bufsz
) - 1))
191 fprintf (stderr
, ERR_WHERE_STRING \
192 "warning - eoln beyond buffer end.\n");
194 vtysh_config_parse(buf
);
197 left
= (size_t)(buf
+ bufsz
- eoln
);
198 memmove(buf
, eoln
, left
);
200 pbuf
= buf
+ strlen(buf
);
203 /* Parse anything left in the buffer. */
205 vtysh_config_parse (buf
);
207 XFREE(MTYPE_TMP
, buf
);
212 vtysh_client_config (struct vtysh_client
*head_client
, char *line
)
214 struct vtysh_client
*client
;
217 rc
= vtysh_client_config_one(head_client
, line
);
218 if (rc
!= CMD_SUCCESS
)
221 client
= head_client
->next
;
224 rc
= vtysh_client_config_one(client
, line
);
225 if (rc
!= CMD_SUCCESS
)
227 client
= client
->next
;
233 vtysh_client_execute_one (struct vtysh_client
*vclient
, const char *line
, FILE *fp
)
244 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
247 vclient_close (vclient
);
253 nbytes
= read (vclient
->fd
, buf
, sizeof(buf
)-1);
255 if (nbytes
<= 0 && errno
!= EINTR
)
257 vclient_close (vclient
);
263 if ((numnulls
== 3) && (nbytes
== 1))
270 /* check for trailling \0\0\0<ret code>,
271 * even if split across reads
272 * (see lib/vty.c::vtysh_read)
282 while (i
< nbytes
&& numnulls
< 3)
284 if (buf
[i
++] == '\0')
290 /* got 3 or more trailing NULs? */
291 if ((numnulls
>= 3) && (i
< nbytes
))
292 return (buf
[nbytes
-1]);
298 vtysh_client_execute (struct vtysh_client
*head_client
, const char *line
, FILE *fp
)
300 struct vtysh_client
*client
;
303 rc
= vtysh_client_execute_one(head_client
, line
, fp
);
304 if (rc
!= CMD_SUCCESS
)
307 client
= head_client
->next
;
310 rc
= vtysh_client_execute_one(client
, line
, fp
);
311 if (rc
!= CMD_SUCCESS
)
313 client
= client
->next
;
319 vtysh_pager_init (void)
323 pager_defined
= getenv ("VTYSH_PAGER");
326 vtysh_pager_name
= strdup (pager_defined
);
328 vtysh_pager_name
= strdup ("more");
331 /* Command execution over the vty interface. */
333 vtysh_execute_func (const char *line
, int pager
)
338 struct cmd_element
*cmd
;
342 int saved_ret
, saved_node
;
344 /* Split readline string up into the vector. */
345 vline
= cmd_make_strvec (line
);
350 saved_ret
= ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
351 saved_node
= vty
->node
;
353 /* If command doesn't succeeded in current node, try to walk up in node tree.
354 * Changing vty->node is enough to try it just out without actual walkup in
356 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
357 && vty
->node
> CONFIG_NODE
)
359 vty
->node
= node_parent(vty
->node
);
360 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
364 vty
->node
= saved_node
;
366 /* If command succeeded in any other node than current (tried > 0) we have
367 * to move into node in the vtysh where it succeeded. */
368 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
370 if ((saved_node
== BGP_VPNV4_NODE
|| saved_node
== BGP_VPNV6_NODE
371 || saved_node
== BGP_ENCAP_NODE
|| saved_node
== BGP_ENCAPV6_NODE
372 || saved_node
== BGP_IPV4_NODE
373 || saved_node
== BGP_IPV6_NODE
|| saved_node
== BGP_IPV4M_NODE
374 || saved_node
== BGP_IPV6M_NODE
)
377 vtysh_execute("exit-address-family");
379 else if ((saved_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
381 vtysh_execute("exit");
385 vtysh_execute ("end");
386 vtysh_execute ("configure terminal");
389 /* If command didn't succeed in any node, continue with return value from
396 cmd_free_strvec (vline
);
402 if (vty
->type
== VTY_FILE
)
403 fprintf (stdout
,"Warning...\n");
405 case CMD_ERR_AMBIGUOUS
:
406 fprintf (stdout
,"%% Ambiguous command.\n");
408 case CMD_ERR_NO_MATCH
:
409 fprintf (stdout
,"%% Unknown command.\n");
411 case CMD_ERR_INCOMPLETE
:
412 fprintf (stdout
,"%% Command incomplete.\n");
414 case CMD_SUCCESS_DAEMON
:
416 /* FIXME: Don't open pager for exit commands. popen() causes problems
417 * if exited from vtysh at all. This hack shouldn't cause any problem
418 * but is really ugly. */
419 if (pager
&& vtysh_pager_name
&& (strncmp(line
, "exit", 4) != 0))
421 fp
= popen (vtysh_pager_name
, "w");
424 perror ("popen failed for pager");
433 if (! strcmp(cmd
->string
,"configure terminal"))
435 for (i
= 0; i
< array_size(vtysh_client
); i
++)
437 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
438 if (cmd_stat
== CMD_WARNING
)
445 vline
= cmd_make_strvec (line
);
449 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
451 if (pclose (fp
) == -1)
453 perror ("pclose failed for pager");
460 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
461 cmd_free_strvec (vline
);
462 if (ret
!= CMD_SUCCESS_DAEMON
)
468 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
473 cmd_stat
= CMD_SUCCESS
;
474 for (i
= 0; i
< array_size(vtysh_client
); i
++)
476 if (cmd
->daemon
& vtysh_client
[i
].flag
)
478 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
479 if (cmd_stat
!= CMD_SUCCESS
)
483 if (cmd_stat
!= CMD_SUCCESS
)
487 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
490 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
492 if (pclose (fp
) == -1)
494 perror ("pclose failed for pager");
502 vtysh_execute_no_pager (const char *line
)
504 return vtysh_execute_func (line
, 0);
508 vtysh_execute (const char *line
)
510 return vtysh_execute_func (line
, 1);
525 while (end
>= s
&& isspace(*end
))
529 while (*s
&& isspace(*s
))
536 vtysh_mark_file (const char *filename
)
543 struct cmd_element
*cmd
;
544 int saved_ret
, prev_node
;
546 char *vty_buf_copy
= NULL
;
547 char *vty_buf_trimmed
= NULL
;
549 if (strncmp("-", filename
, 1) == 0)
552 confp
= fopen (filename
, "r");
556 fprintf (stderr
, "%% Can't open config file %s due to '%s'.\n",
557 filename
, safe_strerror (errno
));
558 return (CMD_ERR_NO_FILE
);
562 vty
->fd
= 0; /* stdout */
563 vty
->type
= VTY_TERM
;
564 vty
->node
= CONFIG_NODE
;
566 vtysh_execute_no_pager ("enable");
567 vtysh_execute_no_pager ("configure terminal");
568 vty_buf_copy
= XCALLOC (MTYPE_VTYSH_CMD
, VTY_BUFSIZ
);
570 while (fgets (vty
->buf
, VTY_BUFSIZ
, confp
))
574 strcpy(vty_buf_copy
, vty
->buf
);
575 vty_buf_trimmed
= trim(vty_buf_copy
);
577 if (vty_buf_trimmed
[0] == '!' || vty_buf_trimmed
[0] == '#')
579 fprintf(stdout
, "%s", vty
->buf
);
583 /* Split readline string up into the vector. */
584 vline
= cmd_make_strvec (vty
->buf
);
588 fprintf(stdout
, "%s", vty
->buf
);
592 /* Ignore the "end" lines, we will generate these where appropriate */
593 if (strlen(vty_buf_trimmed
) == 3 && strncmp("end", vty_buf_trimmed
, 3) == 0)
598 prev_node
= vty
->node
;
599 saved_ret
= ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
601 /* If command doesn't succeeded in current node, try to walk up in node tree.
602 * Changing vty->node is enough to try it just out without actual walkup in
604 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
605 && vty
->node
> CONFIG_NODE
)
607 vty
->node
= node_parent(vty
->node
);
608 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
612 /* If command succeeded in any other node than current (tried > 0) we have
613 * to move into node in the vtysh where it succeeded. */
614 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
616 if ((prev_node
== BGP_VPNV4_NODE
|| prev_node
== BGP_IPV4_NODE
617 || prev_node
== BGP_IPV6_NODE
|| prev_node
== BGP_IPV4M_NODE
618 || prev_node
== BGP_IPV6M_NODE
|| prev_node
== BGP_VPNV6_NODE
)
621 fprintf(stdout
, "exit-address-family\n");
623 else if ((prev_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
625 fprintf(stdout
, "exit\n");
629 fprintf(stdout
, "end\n");
632 /* If command didn't succeed in any node, continue with return value from
637 vty
->node
= prev_node
;
640 cmd_free_strvec (vline
);
644 if (vty
->type
== VTY_FILE
)
645 fprintf (stderr
,"line %d: Warning...: %s\n", lineno
, vty
->buf
);
648 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
650 case CMD_ERR_AMBIGUOUS
:
651 fprintf (stderr
,"line %d: %% Ambiguous command: %s\n", lineno
, vty
->buf
);
654 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
655 return CMD_ERR_AMBIGUOUS
;
656 case CMD_ERR_NO_MATCH
:
657 fprintf (stderr
,"line %d: %% Unknown command: %s\n", lineno
, vty
->buf
);
660 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
661 return CMD_ERR_NO_MATCH
;
662 case CMD_ERR_INCOMPLETE
:
663 fprintf (stderr
,"line %d: %% Command incomplete: %s\n", lineno
, vty
->buf
);
666 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
667 return CMD_ERR_INCOMPLETE
;
669 fprintf(stdout
, "%s", vty
->buf
);
671 case CMD_SUCCESS_DAEMON
:
674 int cmd_stat
= CMD_SUCCESS
;
676 fprintf(stdout
, "%s", vty
->buf
);
677 for (i
= 0; i
< array_size(vtysh_client
); i
++)
679 if (cmd
->daemon
& vtysh_client
[i
].flag
)
681 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
683 if (cmd_stat
!= CMD_SUCCESS
)
687 if (cmd_stat
!= CMD_SUCCESS
)
691 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
695 /* This is the end */
696 fprintf(stdout
, "end\n");
698 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
706 /* Configration make from file. */
708 vtysh_config_from_file (struct vty
*vty
, FILE *fp
)
711 struct cmd_element
*cmd
;
713 int retcode
= CMD_SUCCESS
;
715 while (fgets (vty
->buf
, VTY_BUFSIZ
, fp
))
719 ret
= command_config_read_one_line (vty
, &cmd
, 1);
724 if (vty
->type
== VTY_FILE
)
725 fprintf (stderr
,"line %d: Warning[%d]...: %s\n", lineno
, vty
->node
, vty
->buf
);
726 retcode
= CMD_WARNING
; /* once we have an error, we remember & return that */
728 case CMD_ERR_AMBIGUOUS
:
729 fprintf (stderr
,"line %d: %% Ambiguous command[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
730 retcode
= CMD_ERR_AMBIGUOUS
; /* once we have an error, we remember & return that */
732 case CMD_ERR_NO_MATCH
:
733 fprintf (stderr
,"line %d: %% Unknown command[%d]: %s", lineno
, vty
->node
, vty
->buf
);
734 retcode
= CMD_ERR_NO_MATCH
; /* once we have an error, we remember & return that */
736 case CMD_ERR_INCOMPLETE
:
737 fprintf (stderr
,"line %d: %% Command incomplete[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
738 retcode
= CMD_ERR_INCOMPLETE
; /* once we have an error, we remember & return that */
740 case CMD_SUCCESS_DAEMON
:
743 int cmd_stat
= CMD_SUCCESS
;
745 for (i
= 0; i
< array_size(vtysh_client
); i
++)
747 if (cmd
->daemon
& vtysh_client
[i
].flag
)
749 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
752 * CMD_WARNING - Can mean that the command was
753 * parsed successfully but it was already entered
754 * in a few spots. As such if we receive a
755 * CMD_WARNING from a daemon we shouldn't stop
756 * talking to the other daemons for the particular
759 if (cmd_stat
!= CMD_SUCCESS
&& cmd_stat
!= CMD_WARNING
)
761 fprintf (stderr
, "line %d: Failure to communicate[%d] to %s, line: %s\n",
762 lineno
, cmd_stat
, vtysh_client
[i
].name
, vty
->buf
);
767 if (cmd_stat
!= CMD_SUCCESS
)
771 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
779 /* We don't care about the point of the cursor when '?' is typed. */
781 vtysh_rl_describe (void)
788 struct cmd_token
*token
;
790 vline
= cmd_make_strvec (rl_line_buffer
);
792 /* In case of '> ?'. */
795 vline
= vector_init (1);
796 vector_set (vline
, NULL
);
799 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
800 vector_set (vline
, NULL
);
802 describe
= cmd_describe_command (vline
, vty
, &ret
);
804 fprintf (stdout
,"\n");
806 /* Ambiguous and no match error. */
809 case CMD_ERR_AMBIGUOUS
:
810 cmd_free_strvec (vline
);
811 fprintf (stdout
,"%% Ambiguous command.\n");
815 case CMD_ERR_NO_MATCH
:
816 cmd_free_strvec (vline
);
817 fprintf (stdout
,"%% There is no matched command.\n");
823 /* Get width of command string. */
825 for (i
= 0; i
< vector_active (describe
); i
++)
826 if ((token
= vector_slot (describe
, i
)) != NULL
)
830 if (token
->cmd
[0] == '\0')
833 len
= strlen (token
->cmd
);
834 if (token
->cmd
[0] == '.')
841 for (i
= 0; i
< vector_active (describe
); i
++)
842 if ((token
= vector_slot (describe
, i
)) != NULL
)
844 if (token
->cmd
[0] == '\0')
848 fprintf (stdout
," %-s\n",
849 token
->cmd
[0] == '.' ? token
->cmd
+ 1 : token
->cmd
);
851 fprintf (stdout
," %-*s %s\n",
853 token
->cmd
[0] == '.' ? token
->cmd
+ 1 : token
->cmd
,
857 cmd_free_strvec (vline
);
858 vector_free (describe
);
865 /* Result of cmd_complete_command() call will be stored here
866 * and used in new_completion() in order to put the space in
867 * correct places only. */
871 command_generator (const char *text
, int state
)
874 static char **matched
= NULL
;
875 static int index
= 0;
882 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
885 vline
= cmd_make_strvec (rl_line_buffer
);
889 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
890 vector_set (vline
, NULL
);
893 XFREE (MTYPE_TMP
, matched
);
894 matched
= cmd_complete_command (vline
, vty
, &complete_status
);
895 cmd_free_strvec (vline
);
898 if (matched
&& matched
[index
])
899 return matched
[index
++];
905 new_completion (char *text
, int start
, int end
)
909 matches
= rl_completion_matches (text
, command_generator
);
914 if (complete_status
!= CMD_COMPLETE_FULL_MATCH
)
915 /* only append a space on full match */
916 rl_completion_append_character
= '\0';
922 /* Vty node structures. */
923 static struct cmd_node bgp_node
=
926 "%s(config-router)# ",
929 static struct cmd_node rip_node
=
932 "%s(config-router)# ",
935 static struct cmd_node isis_node
=
938 "%s(config-router)# ",
941 static struct cmd_node interface_node
=
947 static struct cmd_node ns_node
=
950 "%s(config-logical-router)# ",
953 static struct cmd_node vrf_node
=
959 static struct cmd_node rmap_node
=
962 "%s(config-route-map)# "
965 static struct cmd_node zebra_node
=
968 "%s(config-router)# "
971 static struct cmd_node bgp_vpnv4_node
=
974 "%s(config-router-af)# "
977 static struct cmd_node bgp_vpnv6_node
=
980 "%s(config-router-af)# "
983 static struct cmd_node bgp_encap_node
=
986 "%s(config-router-af)# "
989 static struct cmd_node bgp_encapv6_node
=
992 "%s(config-router-af)# "
995 static struct cmd_node bgp_ipv4_node
=
998 "%s(config-router-af)# "
1001 static struct cmd_node bgp_ipv4m_node
=
1004 "%s(config-router-af)# "
1007 static struct cmd_node bgp_ipv6_node
=
1010 "%s(config-router-af)# "
1013 static struct cmd_node bgp_ipv6m_node
=
1016 "%s(config-router-af)# "
1019 static struct cmd_node ospf_node
=
1022 "%s(config-router)# "
1025 static struct cmd_node ripng_node
=
1028 "%s(config-router)# "
1031 static struct cmd_node ospf6_node
=
1034 "%s(config-ospf6)# "
1037 static struct cmd_node keychain_node
=
1040 "%s(config-keychain)# "
1043 static struct cmd_node keychain_key_node
=
1046 "%s(config-keychain-key)# "
1049 struct cmd_node link_params_node
=
1052 "%s(config-link-params)# ",
1055 /* Defined in lib/vty.c */
1056 extern struct cmd_node vty_node
;
1058 /* When '^Z' is received from vty, move down to the enable mode. */
1066 /* Nothing to do. */
1069 vty
->node
= ENABLE_NODE
;
1079 "End current mode and change to enable mode\n")
1081 return vtysh_end ();
1084 DEFUNSH (VTYSH_BGPD
,
1087 "router bgp " CMD_AS_RANGE
,
1092 vty
->node
= BGP_NODE
;
1096 ALIAS_SH (VTYSH_BGPD
,
1103 ALIAS_SH (VTYSH_BGPD
,
1105 router_bgp_view_cmd
,
1106 "router bgp " CMD_AS_RANGE
" (view|vrf) WORD",
1110 "BGP view\nBGP VRF\n"
1113 DEFUNSH (VTYSH_BGPD
,
1114 address_family_vpnv4
,
1115 address_family_vpnv4_cmd
,
1116 "address-family vpnv4",
1117 "Enter Address Family command mode\n"
1120 vty
->node
= BGP_VPNV4_NODE
;
1124 DEFUNSH (VTYSH_BGPD
,
1125 address_family_vpnv4_unicast
,
1126 address_family_vpnv4_unicast_cmd
,
1127 "address-family vpnv4 unicast",
1128 "Enter Address Family command mode\n"
1130 "Address Family Modifier\n")
1132 vty
->node
= BGP_VPNV4_NODE
;
1136 DEFUNSH (VTYSH_BGPD
,
1137 address_family_vpnv6
,
1138 address_family_vpnv6_cmd
,
1139 "address-family vpnv6",
1140 "Enter Address Family command mode\n"
1143 vty
->node
= BGP_VPNV6_NODE
;
1147 DEFUNSH (VTYSH_BGPD
,
1148 address_family_vpnv6_unicast
,
1149 address_family_vpnv6_unicast_cmd
,
1150 "address-family vpnv6 unicast",
1151 "Enter Address Family command mode\n"
1153 "Address Family Modifier\n")
1155 vty
->node
= BGP_VPNV6_NODE
;
1159 DEFUNSH (VTYSH_BGPD
,
1160 address_family_encap
,
1161 address_family_encap_cmd
,
1162 "address-family encap",
1163 "Enter Address Family command mode\n"
1166 vty
->node
= BGP_ENCAP_NODE
;
1170 DEFUNSH (VTYSH_BGPD
,
1171 address_family_encapv4
,
1172 address_family_encapv4_cmd
,
1173 "address-family encapv4",
1174 "Enter Address Family command mode\n"
1177 vty
->node
= BGP_ENCAP_NODE
;
1181 DEFUNSH (VTYSH_BGPD
,
1182 address_family_encapv6
,
1183 address_family_encapv6_cmd
,
1184 "address-family encapv6",
1185 "Enter Address Family command mode\n"
1188 vty
->node
= BGP_ENCAPV6_NODE
;
1192 DEFUNSH (VTYSH_BGPD
,
1193 address_family_ipv4_unicast
,
1194 address_family_ipv4_unicast_cmd
,
1195 "address-family ipv4 unicast",
1196 "Enter Address Family command mode\n"
1198 "Address Family Modifier\n")
1200 vty
->node
= BGP_IPV4_NODE
;
1204 DEFUNSH (VTYSH_BGPD
,
1205 address_family_ipv4_multicast
,
1206 address_family_ipv4_multicast_cmd
,
1207 "address-family ipv4 multicast",
1208 "Enter Address Family command mode\n"
1210 "Address Family Modifier\n")
1212 vty
->node
= BGP_IPV4M_NODE
;
1216 DEFUNSH (VTYSH_BGPD
,
1217 address_family_ipv6
,
1218 address_family_ipv6_cmd
,
1219 "address-family ipv6",
1220 "Enter Address Family command mode\n"
1223 vty
->node
= BGP_IPV6_NODE
;
1227 DEFUNSH (VTYSH_BGPD
,
1228 address_family_ipv6_unicast
,
1229 address_family_ipv6_unicast_cmd
,
1230 "address-family ipv6 unicast",
1231 "Enter Address Family command mode\n"
1233 "Address Family Modifier\n")
1235 vty
->node
= BGP_IPV6_NODE
;
1239 DEFUNSH (VTYSH_BGPD
,
1240 address_family_ipv6_multicast
,
1241 address_family_ipv6_multicast_cmd
,
1242 "address-family ipv6 multicast",
1243 "Enter Address Family command mode\n"
1245 "Address Family Modifier\n")
1247 vty
->node
= BGP_IPV6M_NODE
;
1251 DEFUNSH (VTYSH_RIPD
,
1255 "Authentication key management\n"
1256 "Key-chain management\n"
1259 vty
->node
= KEYCHAIN_NODE
;
1263 DEFUNSH (VTYSH_RIPD
,
1266 "key <0-2147483647>",
1268 "Key identifier number\n")
1270 vty
->node
= KEYCHAIN_KEY_NODE
;
1274 DEFUNSH (VTYSH_RIPD
,
1281 vty
->node
= RIP_NODE
;
1285 DEFUNSH (VTYSH_RIPNGD
,
1292 vty
->node
= RIPNG_NODE
;
1296 DEFUNSH (VTYSH_OSPFD
,
1300 "Enable a routing process\n"
1301 "Start OSPF configuration\n")
1303 vty
->node
= OSPF_NODE
;
1307 ALIAS_SH (VTYSH_OSPFD
,
1309 router_ospf_instance_cmd
,
1310 "router ospf <1-65535>",
1311 "Enable a routing process\n"
1312 "Start OSPF configuration\n"
1315 DEFUNSH (VTYSH_OSPF6D
,
1322 vty
->node
= OSPF6_NODE
;
1326 DEFUNSH (VTYSH_ISISD
,
1332 "ISO Routing area tag")
1334 vty
->node
= ISIS_NODE
;
1338 DEFUNSH (VTYSH_RMAP
,
1341 "route-map WORD (deny|permit) <1-65535>",
1342 "Create route-map or enter route-map command mode\n"
1344 "Route map denies set operations\n"
1345 "Route map permits set operations\n"
1346 "Sequence to insert to/delete from existing route-map entry\n")
1348 vty
->node
= RMAP_NODE
;
1356 "Configure a terminal line\n"
1357 "Virtual terminal\n")
1359 vty
->node
= VTY_NODE
;
1367 "Turn on privileged mode command\n")
1369 vty
->node
= ENABLE_NODE
;
1377 "Turn off privileged mode command\n")
1379 if (vty
->node
== ENABLE_NODE
)
1380 vty
->node
= VIEW_NODE
;
1385 vtysh_config_terminal
,
1386 vtysh_config_terminal_cmd
,
1387 "configure terminal",
1388 "Configuration from vty interface\n"
1389 "Configuration terminal\n")
1391 vty
->node
= CONFIG_NODE
;
1396 vtysh_exit (struct vty
*vty
)
1405 vty
->node
= ENABLE_NODE
;
1407 case INTERFACE_NODE
:
1421 vtysh_execute("end");
1422 vtysh_execute("configure terminal");
1423 vty
->node
= CONFIG_NODE
;
1425 case BGP_VPNV4_NODE
:
1426 case BGP_VPNV6_NODE
:
1427 case BGP_ENCAP_NODE
:
1428 case BGP_ENCAPV6_NODE
:
1430 case BGP_IPV4M_NODE
:
1432 case BGP_IPV6M_NODE
:
1433 vty
->node
= BGP_NODE
;
1435 case KEYCHAIN_KEY_NODE
:
1436 vty
->node
= KEYCHAIN_NODE
;
1438 case LINK_PARAMS_NODE
:
1439 vty
->node
= INTERFACE_NODE
;
1451 "Exit current mode and down to previous mode\n")
1453 return vtysh_exit (vty
);
1456 ALIAS (vtysh_exit_all
,
1459 "Exit current mode and down to previous mode\n")
1461 DEFUNSH (VTYSH_BGPD
,
1462 exit_address_family
,
1463 exit_address_family_cmd
,
1464 "exit-address-family",
1465 "Exit from Address Family configuration mode\n")
1467 if (vty
->node
== BGP_IPV4_NODE
1468 || vty
->node
== BGP_IPV4M_NODE
1469 || vty
->node
== BGP_VPNV4_NODE
1470 || vty
->node
== BGP_VPNV6_NODE
1471 || vty
->node
== BGP_ENCAP_NODE
1472 || vty
->node
== BGP_ENCAPV6_NODE
1473 || vty
->node
== BGP_IPV6_NODE
1474 || vty
->node
== BGP_IPV6M_NODE
)
1475 vty
->node
= BGP_NODE
;
1479 DEFUNSH (VTYSH_ZEBRA
,
1481 vtysh_exit_zebra_cmd
,
1483 "Exit current mode and down to previous mode\n")
1485 return vtysh_exit (vty
);
1488 ALIAS (vtysh_exit_zebra
,
1489 vtysh_quit_zebra_cmd
,
1491 "Exit current mode and down to previous mode\n")
1493 DEFUNSH (VTYSH_RIPD
,
1495 vtysh_exit_ripd_cmd
,
1497 "Exit current mode and down to previous mode\n")
1499 return vtysh_exit (vty
);
1502 ALIAS (vtysh_exit_ripd
,
1503 vtysh_quit_ripd_cmd
,
1505 "Exit current mode and down to previous mode\n")
1507 DEFUNSH (VTYSH_RIPNGD
,
1509 vtysh_exit_ripngd_cmd
,
1511 "Exit current mode and down to previous mode\n")
1513 return vtysh_exit (vty
);
1516 ALIAS (vtysh_exit_ripngd
,
1517 vtysh_quit_ripngd_cmd
,
1519 "Exit current mode and down to previous mode\n")
1521 DEFUNSH (VTYSH_RMAP
,
1523 vtysh_exit_rmap_cmd
,
1525 "Exit current mode and down to previous mode\n")
1527 return vtysh_exit (vty
);
1530 ALIAS (vtysh_exit_rmap
,
1531 vtysh_quit_rmap_cmd
,
1533 "Exit current mode and down to previous mode\n")
1535 DEFUNSH (VTYSH_BGPD
,
1537 vtysh_exit_bgpd_cmd
,
1539 "Exit current mode and down to previous mode\n")
1541 return vtysh_exit (vty
);
1544 ALIAS (vtysh_exit_bgpd
,
1545 vtysh_quit_bgpd_cmd
,
1547 "Exit current mode and down to previous mode\n")
1549 DEFUNSH (VTYSH_OSPFD
,
1551 vtysh_exit_ospfd_cmd
,
1553 "Exit current mode and down to previous mode\n")
1555 return vtysh_exit (vty
);
1558 ALIAS (vtysh_exit_ospfd
,
1559 vtysh_quit_ospfd_cmd
,
1561 "Exit current mode and down to previous mode\n")
1563 DEFUNSH (VTYSH_OSPF6D
,
1565 vtysh_exit_ospf6d_cmd
,
1567 "Exit current mode and down to previous mode\n")
1569 return vtysh_exit (vty
);
1572 ALIAS (vtysh_exit_ospf6d
,
1573 vtysh_quit_ospf6d_cmd
,
1575 "Exit current mode and down to previous mode\n")
1577 DEFUNSH (VTYSH_ISISD
,
1579 vtysh_exit_isisd_cmd
,
1581 "Exit current mode and down to previous mode\n")
1583 return vtysh_exit (vty
);
1586 ALIAS (vtysh_exit_isisd
,
1587 vtysh_quit_isisd_cmd
,
1589 "Exit current mode and down to previous mode\n")
1592 vtysh_exit_line_vty
,
1593 vtysh_exit_line_vty_cmd
,
1595 "Exit current mode and down to previous mode\n")
1597 return vtysh_exit (vty
);
1600 ALIAS (vtysh_exit_line_vty
,
1601 vtysh_quit_line_vty_cmd
,
1603 "Exit current mode and down to previous mode\n")
1605 DEFUNSH (VTYSH_INTERFACE
,
1607 vtysh_interface_cmd
,
1609 "Select an interface to configure\n"
1610 "Interface's name\n")
1612 vty
->node
= INTERFACE_NODE
;
1616 ALIAS_SH (VTYSH_ZEBRA
,
1618 vtysh_interface_vrf_cmd
,
1619 "interface IFNAME " VRF_CMD_STR
,
1620 "Select an interface to configure\n"
1621 "Interface's name\n"
1624 /* TODO Implement "no interface command in isisd. */
1625 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_RIPNGD
|VTYSH_OSPFD
|VTYSH_OSPF6D
,
1626 vtysh_no_interface_cmd
,
1627 "no interface IFNAME",
1629 "Delete a pseudo interface's configuration\n"
1630 "Interface's name\n")
1633 vtysh_no_interface_vrf_cmd
,
1634 "no interface IFNAME " VRF_CMD_STR
,
1636 "Delete a pseudo interface's configuration\n"
1637 "Interface's name\n"
1643 "logical-router <1-65535 ns NAME",
1644 "Enable a logical-router\n"
1645 "Specify the logical-router indentifier\n"
1647 "The file name in " NS_RUN_DIR
", or a full pathname\n")
1649 vty
->node
= NS_NODE
;
1657 "Select a VRF to configure\n"
1660 vty
->node
= VRF_NODE
;
1668 "Delete a pseudo vrf's configuration\n"
1675 "Exit current mode and down to previous mode\n")
1677 return vtysh_exit (vty
);
1680 ALIAS (vtysh_exit_ns
,
1683 "Exit current mode and down to previous mode\n")
1689 "Exit current mode and down to previous mode\n")
1691 return vtysh_exit (vty
);
1694 ALIAS (vtysh_exit_vrf
,
1697 "Exit current mode and down to previous mode\n")
1699 /* TODO Implement interface description commands in ripngd, ospf6d
1701 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1703 "description .LINE",
1704 "Interface specific description\n"
1705 "Characters describing this interface\n")
1707 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1708 no_interface_desc_cmd
,
1711 "Interface specific description\n")
1713 DEFUNSH (VTYSH_INTERFACE
,
1714 vtysh_exit_interface
,
1715 vtysh_exit_interface_cmd
,
1717 "Exit current mode and down to previous mode\n")
1719 return vtysh_exit (vty
);
1722 ALIAS (vtysh_exit_interface
,
1723 vtysh_quit_interface_cmd
,
1725 "Exit current mode and down to previous mode\n")
1727 DEFUN (vtysh_show_thread
,
1728 vtysh_show_thread_cmd
,
1729 "show thread cpu [FILTER]",
1731 "Thread information\n"
1732 "Thread CPU usage\n"
1733 "Display filter (rwtexb)\n")
1736 int ret
= CMD_SUCCESS
;
1739 sprintf(line
, "show thread cpu %s\n", (argc
== 1) ? argv
[0] : "");
1740 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1741 if ( vtysh_client
[i
].fd
>= 0 )
1743 fprintf (stdout
, "Thread statistics for %s:\n",
1744 vtysh_client
[i
].name
);
1745 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1746 fprintf (stdout
,"\n");
1751 DEFUN (vtysh_show_work_queues
,
1752 vtysh_show_work_queues_cmd
,
1755 "Work Queue information\n")
1758 int ret
= CMD_SUCCESS
;
1759 char line
[] = "show work-queues\n";
1761 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1762 if ( vtysh_client
[i
].fd
>= 0 )
1764 fprintf (stdout
, "Work queue statistics for %s:\n",
1765 vtysh_client
[i
].name
);
1766 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1767 fprintf (stdout
,"\n");
1773 DEFUN (vtysh_show_work_queues_daemon
,
1774 vtysh_show_work_queues_daemon_cmd
,
1775 "show work-queues <zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd>",
1777 "Work Queue information\n"
1778 "For the zebra daemon\n"
1779 "For the rip daemon\n"
1780 "For the ripng daemon\n"
1781 "For the ospf daemon\n"
1782 "For the ospfv6 daemon\n"
1783 "For the bgp daemon\n"
1784 "For the isis daemon\n")
1787 int ret
= CMD_SUCCESS
;
1789 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1791 if (begins_with(vtysh_client
[i
].name
, argv
[0]))
1795 ret
= vtysh_client_execute(&vtysh_client
[i
], "show work-queues\n", stdout
);
1800 DEFUNSH (VTYSH_ZEBRA
,
1802 vtysh_link_params_cmd
,
1807 vty
->node
= LINK_PARAMS_NODE
;
1812 DEFUN (vtysh_show_memory
,
1813 vtysh_show_memory_cmd
,
1816 "Memory statistics\n")
1819 int ret
= CMD_SUCCESS
;
1820 char line
[] = "show memory\n";
1822 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1823 if ( vtysh_client
[i
].fd
>= 0 )
1825 fprintf (stdout
, "Memory statistics for %s:\n",
1826 vtysh_client
[i
].name
);
1827 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1828 fprintf (stdout
,"\n");
1834 /* Logging commands. */
1835 DEFUN (vtysh_show_logging
,
1836 vtysh_show_logging_cmd
,
1839 "Show current logging configuration\n")
1842 int ret
= CMD_SUCCESS
;
1843 char line
[] = "show logging\n";
1845 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1846 if ( vtysh_client
[i
].fd
>= 0 )
1848 fprintf (stdout
,"Logging configuration for %s:\n",
1849 vtysh_client
[i
].name
);
1850 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1851 fprintf (stdout
,"\n");
1859 vtysh_log_stdout_cmd
,
1862 "Set stdout logging level\n")
1868 vtysh_log_stdout_level
,
1869 vtysh_log_stdout_level_cmd
,
1870 "log stdout "LOG_LEVELS
,
1872 "Set stdout logging level\n"
1879 no_vtysh_log_stdout
,
1880 no_vtysh_log_stdout_cmd
,
1881 "no log stdout [LEVEL]",
1884 "Cancel logging to stdout\n"
1893 "log file FILENAME",
1896 "Logging filename\n")
1902 vtysh_log_file_level
,
1903 vtysh_log_file_level_cmd
,
1904 "log file FILENAME "LOG_LEVELS
,
1907 "Logging filename\n"
1915 no_vtysh_log_file_cmd
,
1916 "no log file [FILENAME]",
1919 "Cancel logging to file\n"
1920 "Logging file name\n")
1925 ALIAS_SH (VTYSH_ALL
,
1927 no_vtysh_log_file_level_cmd
,
1928 "no log file FILENAME LEVEL",
1931 "Cancel logging to file\n"
1932 "Logging file name\n"
1937 vtysh_log_monitor_cmd
,
1940 "Set terminal line (monitor) logging level\n")
1946 vtysh_log_monitor_level
,
1947 vtysh_log_monitor_level_cmd
,
1948 "log monitor "LOG_LEVELS
,
1950 "Set terminal line (monitor) logging level\n"
1957 no_vtysh_log_monitor
,
1958 no_vtysh_log_monitor_cmd
,
1959 "no log monitor [LEVEL]",
1962 "Disable terminal line (monitor) logging\n"
1970 vtysh_log_syslog_cmd
,
1973 "Set syslog logging level\n")
1979 vtysh_log_syslog_level
,
1980 vtysh_log_syslog_level_cmd
,
1981 "log syslog "LOG_LEVELS
,
1983 "Set syslog logging level\n"
1990 no_vtysh_log_syslog
,
1991 no_vtysh_log_syslog_cmd
,
1992 "no log syslog [LEVEL]",
1995 "Cancel logging to syslog\n"
2003 vtysh_log_facility_cmd
,
2004 "log facility "LOG_FACILITIES
,
2006 "Facility parameter for syslog messages\n"
2014 no_vtysh_log_facility
,
2015 no_vtysh_log_facility_cmd
,
2016 "no log facility [FACILITY]",
2019 "Reset syslog facility to default (daemon)\n"
2020 "Syslog facility\n")
2026 DEFUNSH_DEPRECATED (VTYSH_ALL
,
2029 "log trap "LOG_LEVELS
,
2031 "(Deprecated) Set logging level and default for all destinations\n"
2038 DEFUNSH_DEPRECATED (VTYSH_ALL
,
2040 no_vtysh_log_trap_cmd
,
2041 "no log trap [LEVEL]",
2044 "Permit all logging information\n"
2051 vtysh_log_record_priority
,
2052 vtysh_log_record_priority_cmd
,
2053 "log record-priority",
2055 "Log the priority of the message within the message\n")
2061 no_vtysh_log_record_priority
,
2062 no_vtysh_log_record_priority_cmd
,
2063 "no log record-priority",
2066 "Do not log the priority of the message within the message\n")
2072 vtysh_log_timestamp_precision
,
2073 vtysh_log_timestamp_precision_cmd
,
2074 "log timestamp precision <0-6>",
2076 "Timestamp configuration\n"
2077 "Set the timestamp precision\n"
2078 "Number of subsecond digits\n")
2084 no_vtysh_log_timestamp_precision
,
2085 no_vtysh_log_timestamp_precision_cmd
,
2086 "no log timestamp precision",
2089 "Timestamp configuration\n"
2090 "Reset the timestamp precision to the default value of 0\n")
2096 vtysh_service_password_encrypt
,
2097 vtysh_service_password_encrypt_cmd
,
2098 "service password-encryption",
2099 "Set up miscellaneous service\n"
2100 "Enable encrypted passwords\n")
2106 no_vtysh_service_password_encrypt
,
2107 no_vtysh_service_password_encrypt_cmd
,
2108 "no service password-encryption",
2110 "Set up miscellaneous service\n"
2111 "Enable encrypted passwords\n")
2117 vtysh_config_password
,
2119 "password (8|) WORD",
2120 "Assign the terminal connection password\n"
2121 "Specifies a HIDDEN password will follow\n"
2123 "The HIDDEN line password string\n")
2129 vtysh_password_text
,
2130 vtysh_password_text_cmd
,
2132 "Assign the terminal connection password\n"
2133 "The UNENCRYPTED (cleartext) line password\n")
2139 vtysh_config_enable_password
,
2140 vtysh_enable_password_cmd
,
2141 "enable password (8|) WORD",
2142 "Modify enable password parameters\n"
2143 "Assign the privileged level password\n"
2144 "Specifies a HIDDEN password will follow\n"
2146 "The HIDDEN 'enable' password string\n")
2152 vtysh_enable_password_text
,
2153 vtysh_enable_password_text_cmd
,
2154 "enable password LINE",
2155 "Modify enable password parameters\n"
2156 "Assign the privileged level password\n"
2157 "The UNENCRYPTED (cleartext) 'enable' password\n")
2163 no_vtysh_config_enable_password
,
2164 no_vtysh_enable_password_cmd
,
2165 "no enable password",
2167 "Modify enable password parameters\n"
2168 "Assign the privileged level password\n")
2173 DEFUN (vtysh_write_terminal
,
2174 vtysh_write_terminal_cmd
,
2176 "Write running configuration to memory, network, or terminal\n"
2177 "Write to terminal\n")
2180 char line
[] = "write terminal\n";
2183 if (vtysh_pager_name
)
2185 fp
= popen (vtysh_pager_name
, "w");
2195 vty_out (vty
, "Building configuration...%s", VTY_NEWLINE
);
2196 vty_out (vty
, "%sCurrent configuration:%s", VTY_NEWLINE
,
2198 vty_out (vty
, "!%s", VTY_NEWLINE
);
2200 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2201 if ((argc
< 1 ) || (begins_with(vtysh_client
[i
].name
, argv
[0])))
2202 vtysh_client_config (&vtysh_client
[i
], line
);
2204 /* Integrate vtysh specific configuration. */
2205 vtysh_config_write ();
2207 vtysh_config_dump (fp
);
2209 if (vtysh_pager_name
&& fp
)
2212 if (pclose (fp
) == -1)
2220 vty_out (vty
, "end%s", VTY_NEWLINE
);
2225 DEFUN (vtysh_write_terminal_daemon
,
2226 vtysh_write_terminal_daemon_cmd
,
2227 "write terminal <zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pimd>",
2228 "Write running configuration to memory, network, or terminal\n"
2229 "Write to terminal\n"
2230 "For the zebra daemon\n"
2231 "For the rip daemon\n"
2232 "For the ripng daemon\n"
2233 "For the ospf daemon\n"
2234 "For the ospfv6 daemon\n"
2235 "For the bgp daemon\n"
2236 "For the isis daemon\n"
2237 "For the pim daemon\n")
2240 int ret
= CMD_SUCCESS
;
2242 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2244 if (begins_with(vtysh_client
[i
].name
, argv
[0]))
2248 ret
= vtysh_client_execute(&vtysh_client
[i
], "show running-config\n", stdout
);
2253 DEFUN (vtysh_integrated_config
,
2254 vtysh_integrated_config_cmd
,
2255 "service integrated-vtysh-config",
2256 "Set up miscellaneous service\n"
2257 "Write configuration into integrated file\n")
2259 vtysh_writeconfig_integrated
= 1;
2263 DEFUN (no_vtysh_integrated_config
,
2264 no_vtysh_integrated_config_cmd
,
2265 "no service integrated-vtysh-config",
2267 "Set up miscellaneous service\n"
2268 "Write configuration into integrated file\n")
2270 vtysh_writeconfig_integrated
= 0;
2275 backup_config_file (const char *fbackup
)
2277 char *integrate_sav
= NULL
;
2279 integrate_sav
= malloc (strlen (fbackup
) +
2280 strlen (CONF_BACKUP_EXT
) + 1);
2281 strcpy (integrate_sav
, fbackup
);
2282 strcat (integrate_sav
, CONF_BACKUP_EXT
);
2284 /* Move current configuration file to backup config file. */
2285 unlink (integrate_sav
);
2286 rename (fbackup
, integrate_sav
);
2287 free (integrate_sav
);
2291 write_config_integrated(void)
2294 char line
[] = "write terminal\n";
2297 fprintf (stdout
,"Building Configuration...\n");
2299 backup_config_file(integrate_default
);
2300 backup_config_file(host
.config
);
2302 fp
= fopen (integrate_default
, "w");
2305 fprintf (stdout
,"%% Can't open configuration file %s due to '%s'\n",
2306 integrate_default
, safe_strerror(errno
));
2310 fp1
= fopen (host
.config
, "w");
2313 fprintf (stdout
,"%% Can't open configuration file %s due to '%s'\n",
2314 host
.config
, safe_strerror(errno
));
2318 vtysh_config_write ();
2319 vtysh_config_dump (fp1
);
2322 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2323 vtysh_client_config (&vtysh_client
[i
], line
);
2325 vtysh_config_write ();
2326 vtysh_config_dump (fp
);
2330 if (chmod (integrate_default
, CONFIGFILE_MASK
) != 0)
2332 fprintf (stdout
,"%% Can't chmod configuration file %s: %s\n",
2333 integrate_default
, safe_strerror(errno
));
2337 if (chmod (host
.config
, CONFIGFILE_MASK
) != 0)
2339 fprintf (stdout
,"%% Can't chmod configuration file %s: %s (%d)\n",
2340 integrate_default
, safe_strerror(errno
), errno
);
2343 fprintf(stdout
,"Integrated configuration saved to %s\n",integrate_default
);
2345 fprintf (stdout
,"[OK]\n");
2350 DEFUN (vtysh_write_memory
,
2351 vtysh_write_memory_cmd
,
2353 "Write running configuration to memory, network, or terminal\n"
2354 "Write configuration to the file (same as write file)\n")
2356 int ret
= CMD_SUCCESS
;
2357 char line
[] = "write memory\n";
2361 /* If integrated Quagga.conf explicitely set. */
2362 if (vtysh_writeconfig_integrated
)
2363 return write_config_integrated();
2365 backup_config_file(integrate_default
);
2367 fprintf (stdout
,"Building Configuration...\n");
2369 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2370 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2373 fp
= fopen(host
.config
, "w");
2376 fprintf (stdout
,"%% Can't open configuration file %s due to '%s'\n",
2377 host
.config
, safe_strerror(errno
));
2381 vtysh_config_write ();
2382 vtysh_config_dump (fp
);
2386 if (chmod (host
.config
, CONFIGFILE_MASK
) != 0)
2388 fprintf (stdout
,"%% Can't chmod configuration file %s: %s\n",
2389 integrate_default
, safe_strerror(errno
));
2393 fprintf (stdout
,"[OK]\n");
2398 ALIAS (vtysh_write_memory
,
2399 vtysh_copy_runningconfig_startupconfig_cmd
,
2400 "copy running-config startup-config",
2401 "Copy from one file to another\n"
2402 "Copy from current system configuration\n"
2403 "Copy to startup configuration\n")
2405 ALIAS (vtysh_write_memory
,
2406 vtysh_write_file_cmd
,
2408 "Write running configuration to memory, network, or terminal\n"
2409 "Write configuration to the file (same as write memory)\n")
2411 ALIAS (vtysh_write_memory
,
2414 "Write running configuration to memory, network, or terminal\n")
2416 ALIAS (vtysh_write_terminal
,
2417 vtysh_show_running_config_cmd
,
2418 "show running-config",
2420 "Current operating configuration\n")
2422 ALIAS (vtysh_write_terminal
,
2423 vtysh_show_running_config_daemon_cmd
,
2424 "show running-config (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pimd)",
2426 "Current operating configuration\n"
2427 "For the zebra daemon\n"
2428 "For the rip daemon\n"
2429 "For the ripng daemon\n"
2430 "For the ospf daemon\n"
2431 "For the ospfv6 daemon\n"
2432 "For the bgp daemon\n"
2433 "For the isis daemon\n"
2434 "For the pim daemon\n")
2436 DEFUN (vtysh_terminal_length
,
2437 vtysh_terminal_length_cmd
,
2438 "terminal length (0-512)",
2439 "Set terminal line parameters\n"
2440 "Set number of lines on a screen\n"
2441 "Number of lines on screen (0 for no pausing)\n")
2444 char *endptr
= NULL
;
2445 char default_pager
[10];
2447 lines
= strtol (argv
[0], &endptr
, 10);
2448 if (lines
< 0 || lines
> 512 || *endptr
!= '\0')
2450 vty_out (vty
, "length is malformed%s", VTY_NEWLINE
);
2454 if (vtysh_pager_name
)
2456 free (vtysh_pager_name
);
2457 vtysh_pager_name
= NULL
;
2462 snprintf(default_pager
, 10, "more -%i", lines
);
2463 vtysh_pager_name
= strdup (default_pager
);
2469 DEFUN (vtysh_terminal_no_length
,
2470 vtysh_terminal_no_length_cmd
,
2471 "terminal no length",
2472 "Set terminal line parameters\n"
2474 "Set number of lines on a screen\n")
2476 if (vtysh_pager_name
)
2478 free (vtysh_pager_name
);
2479 vtysh_pager_name
= NULL
;
2486 DEFUN (vtysh_show_daemons
,
2487 vtysh_show_daemons_cmd
,
2490 "Show list of running daemons\n")
2494 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2495 if ( vtysh_client
[i
].fd
>= 0 )
2496 vty_out(vty
, " %s", vtysh_client
[i
].name
);
2497 vty_out(vty
, "%s", VTY_NEWLINE
);
2502 /* Execute command in child process. */
2504 execute_command (const char *command
, int argc
, const char *arg1
,
2515 /* Failure of fork(). */
2516 fprintf (stderr
, "Can't fork: %s\n", safe_strerror (errno
));
2521 /* This is child process. */
2525 execlp (command
, command
, (const char *)NULL
);
2528 execlp (command
, command
, arg1
, (const char *)NULL
);
2531 execlp (command
, command
, arg1
, arg2
, (const char *)NULL
);
2535 /* When execlp suceed, this part is not executed. */
2536 fprintf (stderr
, "Can't execute %s: %s\n", command
, safe_strerror (errno
));
2541 /* This is parent. */
2543 wait4 (pid
, &status
, 0, NULL
);
2551 "Send echo messages\n"
2552 "Ping destination address or hostname\n")
2554 execute_command ("ping", 1, argv
[0], NULL
);
2561 "Send echo messages\n"
2563 "Ping destination address or hostname\n")
2565 DEFUN (vtysh_traceroute
,
2566 vtysh_traceroute_cmd
,
2568 "Trace route to destination\n"
2569 "Trace route to destination address or hostname\n")
2571 execute_command ("traceroute", 1, argv
[0], NULL
);
2575 ALIAS (vtysh_traceroute
,
2576 vtysh_traceroute_ip_cmd
,
2577 "traceroute ip WORD",
2578 "Trace route to destination\n"
2580 "Trace route to destination address or hostname\n")
2586 "Send echo messages\n"
2588 "Ping destination address or hostname\n")
2590 execute_command ("ping6", 1, argv
[0], NULL
);
2594 DEFUN (vtysh_traceroute6
,
2595 vtysh_traceroute6_cmd
,
2596 "traceroute ipv6 WORD",
2597 "Trace route to destination\n"
2599 "Trace route to destination address or hostname\n")
2601 execute_command ("traceroute6", 1, argv
[0], NULL
);
2606 #if defined(HAVE_SHELL_ACCESS)
2607 DEFUN (vtysh_telnet
,
2610 "Open a telnet connection\n"
2611 "IP address or hostname of a remote system\n")
2613 execute_command ("telnet", 1, argv
[0], NULL
);
2617 DEFUN (vtysh_telnet_port
,
2618 vtysh_telnet_port_cmd
,
2620 "Open a telnet connection\n"
2621 "IP address or hostname of a remote system\n"
2622 "TCP Port number\n")
2624 execute_command ("telnet", 2, argv
[0], argv
[1]);
2631 "Open an ssh connection\n"
2634 execute_command ("ssh", 1, argv
[0], NULL
);
2638 DEFUN (vtysh_start_shell
,
2639 vtysh_start_shell_cmd
,
2641 "Start UNIX shell\n")
2643 execute_command ("sh", 0, NULL
, NULL
);
2647 DEFUN (vtysh_start_bash
,
2648 vtysh_start_bash_cmd
,
2650 "Start UNIX shell\n"
2653 execute_command ("bash", 0, NULL
, NULL
);
2657 DEFUN (vtysh_start_zsh
,
2658 vtysh_start_zsh_cmd
,
2660 "Start UNIX shell\n"
2663 execute_command ("zsh", 0, NULL
, NULL
);
2669 vtysh_install_default (enum node_type node
)
2671 install_element (node
, &config_list_cmd
);
2674 /* Making connection to protocol daemon. */
2676 vtysh_connect (struct vtysh_client
*vclient
)
2680 struct sockaddr_un addr
;
2683 /* Stat socket to see if we have permission to access it. */
2684 ret
= stat (vclient
->path
, &s_stat
);
2685 if (ret
< 0 && errno
!= ENOENT
)
2687 fprintf (stderr
, "vtysh_connect(%s): stat = %s\n",
2688 vclient
->path
, safe_strerror(errno
));
2694 if (! S_ISSOCK(s_stat
.st_mode
))
2696 fprintf (stderr
, "vtysh_connect(%s): Not a socket\n",
2703 sock
= socket (AF_UNIX
, SOCK_STREAM
, 0);
2707 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", vclient
->path
,
2708 safe_strerror(errno
));
2713 memset (&addr
, 0, sizeof (struct sockaddr_un
));
2714 addr
.sun_family
= AF_UNIX
;
2715 strncpy (addr
.sun_path
, vclient
->path
, strlen (vclient
->path
));
2716 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
2717 len
= addr
.sun_len
= SUN_LEN(&addr
);
2719 len
= sizeof (addr
.sun_family
) + strlen (addr
.sun_path
);
2720 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
2722 ret
= connect (sock
, (struct sockaddr
*) &addr
, len
);
2726 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", vclient
->path
,
2727 safe_strerror(errno
));
2737 /* Return true if str ends with suffix, else return false */
2739 ends_with(const char *str
, const char *suffix
)
2741 if (!str
|| !suffix
)
2743 size_t lenstr
= strlen(str
);
2744 size_t lensuffix
= strlen(suffix
);
2745 if (lensuffix
> lenstr
)
2747 return strncmp(str
+ lenstr
- lensuffix
, suffix
, lensuffix
) == 0;
2751 vtysh_client_sorted_insert (struct vtysh_client
*head_client
,
2752 struct vtysh_client
*client
)
2754 struct vtysh_client
*prev_node
, *current_node
;
2756 prev_node
= head_client
;
2757 current_node
= head_client
->next
;
2758 while (current_node
)
2760 if (strcmp(current_node
->path
, client
->path
) > 0)
2763 prev_node
= current_node
;
2764 current_node
= current_node
->next
;
2766 client
->next
= current_node
;
2767 prev_node
->next
= client
;
2770 #define MAXIMUM_INSTANCES 10
2773 vtysh_update_all_insances(struct vtysh_client
* head_client
)
2775 struct vtysh_client
*client
;
2778 struct dirent
*file
;
2781 if (head_client
->flag
!= VTYSH_OSPFD
) return;
2783 /* ls /var/run/quagga/ and look for all files ending in .vty */
2784 dir
= opendir("/var/run/quagga/");
2787 while ((file
= readdir(dir
)) != NULL
)
2789 if (begins_with(file
->d_name
, "ospfd-") && ends_with(file
->d_name
, ".vty"))
2791 if (n
== MAXIMUM_INSTANCES
)
2794 "Parsing /var/run/quagga/, client limit(%d) reached!\n", n
);
2797 client
= (struct vtysh_client
*) malloc(sizeof(struct vtysh_client
));
2799 client
->name
= "ospfd";
2800 client
->flag
= VTYSH_OSPFD
;
2801 ptr
= (char *) malloc(100);
2802 sprintf(ptr
, "/var/run/quagga/%s", file
->d_name
);
2803 client
->path
= (const char *)ptr
;
2804 client
->next
= NULL
;
2805 vtysh_client_sorted_insert(head_client
, client
);
2814 vtysh_connect_all_instances (struct vtysh_client
*head_client
)
2816 struct vtysh_client
*client
;
2819 vtysh_update_all_insances(head_client
);
2821 client
= head_client
->next
;
2824 if (vtysh_connect(client
) == 0)
2826 client
= client
->next
;
2833 vtysh_connect_all(const char *daemon_name
)
2839 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2841 if (!daemon_name
|| !strcmp(daemon_name
, vtysh_client
[i
].name
))
2844 if (vtysh_connect(&vtysh_client
[i
]) == 0)
2847 rc
+= vtysh_connect_all_instances(&vtysh_client
[i
]);
2851 fprintf(stderr
, "Error: no daemons match name %s!\n", daemon_name
);
2855 /* To disable readline's filename completion. */
2857 vtysh_completion_entry_function (const char *ignore
, int invoking_key
)
2863 vtysh_readline_init (void)
2865 /* readline related settings. */
2866 rl_bind_key ('?', (rl_command_func_t
*) vtysh_rl_describe
);
2867 rl_completion_entry_function
= vtysh_completion_entry_function
;
2868 rl_attempted_completion_function
= (rl_completion_func_t
*)new_completion
;
2874 static struct utsname names
;
2875 static char buf
[100];
2876 const char*hostname
;
2877 extern struct host host
;
2879 hostname
= host
.name
;
2883 if (!names
.nodename
[0])
2885 hostname
= names
.nodename
;
2888 snprintf (buf
, sizeof buf
, cmd_prompt (vty
->node
), hostname
);
2894 vtysh_init_vty (void)
2896 /* Make vty structure. */
2898 vty
->type
= VTY_SHELL
;
2899 vty
->node
= VIEW_NODE
;
2901 /* Initialize commands. */
2904 /* Install nodes. */
2905 install_node (&bgp_node
, NULL
);
2906 install_node (&rip_node
, NULL
);
2907 install_node (&interface_node
, NULL
);
2908 install_node (&link_params_node
, NULL
);
2909 install_node (&ns_node
, NULL
);
2910 install_node (&vrf_node
, NULL
);
2911 install_node (&rmap_node
, NULL
);
2912 install_node (&zebra_node
, NULL
);
2913 install_node (&bgp_vpnv4_node
, NULL
);
2914 install_node (&bgp_vpnv6_node
, NULL
);
2915 install_node (&bgp_encap_node
, NULL
);
2916 install_node (&bgp_encapv6_node
, NULL
);
2917 install_node (&bgp_ipv4_node
, NULL
);
2918 install_node (&bgp_ipv4m_node
, NULL
);
2919 /* #ifdef HAVE_IPV6 */
2920 install_node (&bgp_ipv6_node
, NULL
);
2921 install_node (&bgp_ipv6m_node
, NULL
);
2923 install_node (&ospf_node
, NULL
);
2924 /* #ifdef HAVE_IPV6 */
2925 install_node (&ripng_node
, NULL
);
2926 install_node (&ospf6_node
, NULL
);
2928 install_node (&keychain_node
, NULL
);
2929 install_node (&keychain_key_node
, NULL
);
2930 install_node (&isis_node
, NULL
);
2931 install_node (&vty_node
, NULL
);
2933 vtysh_install_default (VIEW_NODE
);
2934 vtysh_install_default (ENABLE_NODE
);
2935 vtysh_install_default (CONFIG_NODE
);
2936 vtysh_install_default (BGP_NODE
);
2937 vtysh_install_default (RIP_NODE
);
2938 vtysh_install_default (INTERFACE_NODE
);
2939 vtysh_install_default (LINK_PARAMS_NODE
);
2940 vtysh_install_default (NS_NODE
);
2941 vtysh_install_default (VRF_NODE
);
2942 vtysh_install_default (RMAP_NODE
);
2943 vtysh_install_default (ZEBRA_NODE
);
2944 vtysh_install_default (BGP_VPNV4_NODE
);
2945 vtysh_install_default (BGP_VPNV6_NODE
);
2946 vtysh_install_default (BGP_ENCAP_NODE
);
2947 vtysh_install_default (BGP_ENCAPV6_NODE
);
2948 vtysh_install_default (BGP_IPV4_NODE
);
2949 vtysh_install_default (BGP_IPV4M_NODE
);
2950 vtysh_install_default (BGP_IPV6_NODE
);
2951 vtysh_install_default (BGP_IPV6M_NODE
);
2952 vtysh_install_default (OSPF_NODE
);
2953 vtysh_install_default (RIPNG_NODE
);
2954 vtysh_install_default (OSPF6_NODE
);
2955 vtysh_install_default (ISIS_NODE
);
2956 vtysh_install_default (KEYCHAIN_NODE
);
2957 vtysh_install_default (KEYCHAIN_KEY_NODE
);
2958 vtysh_install_default (VTY_NODE
);
2960 install_element (VIEW_NODE
, &vtysh_enable_cmd
);
2961 install_element (ENABLE_NODE
, &vtysh_config_terminal_cmd
);
2962 install_element (ENABLE_NODE
, &vtysh_disable_cmd
);
2964 /* "exit" command. */
2965 install_element (VIEW_NODE
, &vtysh_exit_all_cmd
);
2966 install_element (VIEW_NODE
, &vtysh_quit_all_cmd
);
2967 install_element (CONFIG_NODE
, &vtysh_exit_all_cmd
);
2968 /* install_element (CONFIG_NODE, &vtysh_quit_all_cmd); */
2969 install_element (ENABLE_NODE
, &vtysh_exit_all_cmd
);
2970 install_element (ENABLE_NODE
, &vtysh_quit_all_cmd
);
2971 install_element (RIP_NODE
, &vtysh_exit_ripd_cmd
);
2972 install_element (RIP_NODE
, &vtysh_quit_ripd_cmd
);
2973 install_element (RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
2974 install_element (RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
2975 install_element (OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
2976 install_element (OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
2977 install_element (OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
2978 install_element (OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
2979 install_element (BGP_NODE
, &vtysh_exit_bgpd_cmd
);
2980 install_element (BGP_NODE
, &vtysh_quit_bgpd_cmd
);
2981 install_element (BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
2982 install_element (BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
2983 install_element (BGP_VPNV6_NODE
, &vtysh_exit_bgpd_cmd
);
2984 install_element (BGP_VPNV6_NODE
, &vtysh_quit_bgpd_cmd
);
2985 install_element (BGP_ENCAP_NODE
, &vtysh_exit_bgpd_cmd
);
2986 install_element (BGP_ENCAP_NODE
, &vtysh_quit_bgpd_cmd
);
2987 install_element (BGP_ENCAPV6_NODE
, &vtysh_exit_bgpd_cmd
);
2988 install_element (BGP_ENCAPV6_NODE
, &vtysh_quit_bgpd_cmd
);
2989 install_element (BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
2990 install_element (BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
2991 install_element (BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
2992 install_element (BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
2993 install_element (BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
2994 install_element (BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
2995 install_element (BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
2996 install_element (BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
2997 install_element (ISIS_NODE
, &vtysh_exit_isisd_cmd
);
2998 install_element (ISIS_NODE
, &vtysh_quit_isisd_cmd
);
2999 install_element (KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
3000 install_element (KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
3001 install_element (KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
3002 install_element (KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
3003 install_element (RMAP_NODE
, &vtysh_exit_rmap_cmd
);
3004 install_element (RMAP_NODE
, &vtysh_quit_rmap_cmd
);
3005 install_element (VTY_NODE
, &vtysh_exit_line_vty_cmd
);
3006 install_element (VTY_NODE
, &vtysh_quit_line_vty_cmd
);
3008 /* "end" command. */
3009 install_element (CONFIG_NODE
, &vtysh_end_all_cmd
);
3010 install_element (ENABLE_NODE
, &vtysh_end_all_cmd
);
3011 install_element (RIP_NODE
, &vtysh_end_all_cmd
);
3012 install_element (RIPNG_NODE
, &vtysh_end_all_cmd
);
3013 install_element (OSPF_NODE
, &vtysh_end_all_cmd
);
3014 install_element (OSPF6_NODE
, &vtysh_end_all_cmd
);
3015 install_element (BGP_NODE
, &vtysh_end_all_cmd
);
3016 install_element (BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
3017 install_element (BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
3018 install_element (BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
3019 install_element (BGP_VPNV6_NODE
, &vtysh_end_all_cmd
);
3020 install_element (BGP_ENCAP_NODE
, &vtysh_end_all_cmd
);
3021 install_element (BGP_ENCAPV6_NODE
, &vtysh_end_all_cmd
);
3022 install_element (BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
3023 install_element (BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
3024 install_element (ISIS_NODE
, &vtysh_end_all_cmd
);
3025 install_element (KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
3026 install_element (KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
3027 install_element (RMAP_NODE
, &vtysh_end_all_cmd
);
3028 install_element (VTY_NODE
, &vtysh_end_all_cmd
);
3030 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
3031 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
3032 install_element (INTERFACE_NODE
, &vtysh_end_all_cmd
);
3033 install_element (INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
3034 install_element (LINK_PARAMS_NODE
, &vtysh_end_all_cmd
);
3035 install_element (LINK_PARAMS_NODE
, &vtysh_exit_interface_cmd
);
3036 install_element (INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
3038 install_element (NS_NODE
, &vtysh_end_all_cmd
);
3039 install_element (NS_NODE
, &vtysh_exit_ns_cmd
);
3040 install_element (NS_NODE
, &vtysh_quit_ns_cmd
);
3042 install_element (VRF_NODE
, &vtysh_end_all_cmd
);
3043 install_element (VRF_NODE
, &vtysh_exit_vrf_cmd
);
3044 install_element (VRF_NODE
, &vtysh_quit_vrf_cmd
);
3046 install_element (CONFIG_NODE
, &router_rip_cmd
);
3048 install_element (CONFIG_NODE
, &router_ripng_cmd
);
3050 install_element (CONFIG_NODE
, &router_ospf_cmd
);
3051 install_element (CONFIG_NODE
, &router_ospf_instance_cmd
);
3053 install_element (CONFIG_NODE
, &router_ospf6_cmd
);
3055 install_element (CONFIG_NODE
, &router_isis_cmd
);
3056 install_element (CONFIG_NODE
, &router_bgp_cmd
);
3057 install_element (CONFIG_NODE
, &router_bgp_asn_cmd
);
3058 install_element (CONFIG_NODE
, &router_bgp_view_cmd
);
3059 install_element (BGP_NODE
, &address_family_vpnv4_cmd
);
3060 install_element (BGP_NODE
, &address_family_vpnv4_unicast_cmd
);
3061 install_element (BGP_NODE
, &address_family_vpnv6_cmd
);
3062 install_element (BGP_NODE
, &address_family_vpnv6_unicast_cmd
);
3063 install_element (BGP_NODE
, &address_family_encap_cmd
);
3064 install_element (BGP_NODE
, &address_family_encapv6_cmd
);
3065 install_element (BGP_NODE
, &address_family_ipv4_unicast_cmd
);
3066 install_element (BGP_NODE
, &address_family_ipv4_multicast_cmd
);
3068 install_element (BGP_NODE
, &address_family_ipv6_cmd
);
3069 install_element (BGP_NODE
, &address_family_ipv6_unicast_cmd
);
3070 install_element (BGP_NODE
, &address_family_ipv6_multicast_cmd
);
3072 install_element (BGP_VPNV4_NODE
, &exit_address_family_cmd
);
3073 install_element (BGP_VPNV6_NODE
, &exit_address_family_cmd
);
3074 install_element (BGP_ENCAP_NODE
, &exit_address_family_cmd
);
3075 install_element (BGP_ENCAPV6_NODE
, &exit_address_family_cmd
);
3076 install_element (BGP_IPV4_NODE
, &exit_address_family_cmd
);
3077 install_element (BGP_IPV4M_NODE
, &exit_address_family_cmd
);
3078 install_element (BGP_IPV6_NODE
, &exit_address_family_cmd
);
3079 install_element (BGP_IPV6M_NODE
, &exit_address_family_cmd
);
3080 install_element (CONFIG_NODE
, &key_chain_cmd
);
3081 install_element (CONFIG_NODE
, &route_map_cmd
);
3082 install_element (CONFIG_NODE
, &vtysh_line_vty_cmd
);
3083 install_element (KEYCHAIN_NODE
, &key_cmd
);
3084 install_element (KEYCHAIN_NODE
, &key_chain_cmd
);
3085 install_element (KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
3086 install_element (CONFIG_NODE
, &vtysh_interface_cmd
);
3087 install_element (CONFIG_NODE
, &vtysh_no_interface_cmd
);
3088 install_element (CONFIG_NODE
, &vtysh_interface_vrf_cmd
);
3089 install_element (CONFIG_NODE
, &vtysh_no_interface_vrf_cmd
);
3090 install_element (INTERFACE_NODE
, &vtysh_link_params_cmd
);
3091 install_element (ENABLE_NODE
, &vtysh_show_running_config_cmd
);
3092 install_element (ENABLE_NODE
, &vtysh_show_running_config_daemon_cmd
);
3093 install_element (ENABLE_NODE
, &vtysh_copy_runningconfig_startupconfig_cmd
);
3094 install_element (ENABLE_NODE
, &vtysh_write_file_cmd
);
3095 install_element (ENABLE_NODE
, &vtysh_write_cmd
);
3097 install_element (CONFIG_NODE
, &vtysh_vrf_cmd
);
3098 install_element (CONFIG_NODE
, &vtysh_no_vrf_cmd
);
3100 /* "write terminal" command. */
3101 install_element (ENABLE_NODE
, &vtysh_write_terminal_cmd
);
3102 install_element (ENABLE_NODE
, &vtysh_write_terminal_daemon_cmd
);
3104 install_element (CONFIG_NODE
, &vtysh_integrated_config_cmd
);
3105 install_element (CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
3107 /* "write memory" command. */
3108 install_element (ENABLE_NODE
, &vtysh_write_memory_cmd
);
3110 install_element (VIEW_NODE
, &vtysh_terminal_length_cmd
);
3111 install_element (ENABLE_NODE
, &vtysh_terminal_length_cmd
);
3112 install_element (VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
3113 install_element (ENABLE_NODE
, &vtysh_terminal_no_length_cmd
);
3114 install_element (VIEW_NODE
, &vtysh_show_daemons_cmd
);
3115 install_element (ENABLE_NODE
, &vtysh_show_daemons_cmd
);
3117 install_element (VIEW_NODE
, &vtysh_ping_cmd
);
3118 install_element (VIEW_NODE
, &vtysh_ping_ip_cmd
);
3119 install_element (VIEW_NODE
, &vtysh_traceroute_cmd
);
3120 install_element (VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
3122 install_element (VIEW_NODE
, &vtysh_ping6_cmd
);
3123 install_element (VIEW_NODE
, &vtysh_traceroute6_cmd
);
3125 #if defined(HAVE_SHELL_ACCESS)
3126 install_element (VIEW_NODE
, &vtysh_telnet_cmd
);
3127 install_element (VIEW_NODE
, &vtysh_telnet_port_cmd
);
3128 install_element (VIEW_NODE
, &vtysh_ssh_cmd
);
3130 install_element (ENABLE_NODE
, &vtysh_ping_cmd
);
3131 install_element (ENABLE_NODE
, &vtysh_ping_ip_cmd
);
3132 install_element (ENABLE_NODE
, &vtysh_traceroute_cmd
);
3133 install_element (ENABLE_NODE
, &vtysh_traceroute_ip_cmd
);
3135 install_element (ENABLE_NODE
, &vtysh_ping6_cmd
);
3136 install_element (ENABLE_NODE
, &vtysh_traceroute6_cmd
);
3138 #if defined(HAVE_SHELL_ACCESS)
3139 install_element (ENABLE_NODE
, &vtysh_telnet_cmd
);
3140 install_element (ENABLE_NODE
, &vtysh_telnet_port_cmd
);
3141 install_element (ENABLE_NODE
, &vtysh_ssh_cmd
);
3142 install_element (ENABLE_NODE
, &vtysh_start_shell_cmd
);
3143 install_element (ENABLE_NODE
, &vtysh_start_bash_cmd
);
3144 install_element (ENABLE_NODE
, &vtysh_start_zsh_cmd
);
3147 install_element (VIEW_NODE
, &vtysh_show_memory_cmd
);
3148 install_element (ENABLE_NODE
, &vtysh_show_memory_cmd
);
3150 install_element (VIEW_NODE
, &vtysh_show_work_queues_cmd
);
3151 install_element (ENABLE_NODE
, &vtysh_show_work_queues_cmd
);
3152 install_element (ENABLE_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3153 install_element (VIEW_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3155 install_element (VIEW_NODE
, &vtysh_show_thread_cmd
);
3156 install_element (ENABLE_NODE
, &vtysh_show_thread_cmd
);
3159 install_element (ENABLE_NODE
, &vtysh_show_logging_cmd
);
3160 install_element (VIEW_NODE
, &vtysh_show_logging_cmd
);
3161 install_element (CONFIG_NODE
, &vtysh_log_stdout_cmd
);
3162 install_element (CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
3163 install_element (CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
3164 install_element (CONFIG_NODE
, &vtysh_log_file_cmd
);
3165 install_element (CONFIG_NODE
, &vtysh_log_file_level_cmd
);
3166 install_element (CONFIG_NODE
, &no_vtysh_log_file_cmd
);
3167 install_element (CONFIG_NODE
, &no_vtysh_log_file_level_cmd
);
3168 install_element (CONFIG_NODE
, &vtysh_log_monitor_cmd
);
3169 install_element (CONFIG_NODE
, &vtysh_log_monitor_level_cmd
);
3170 install_element (CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
3171 install_element (CONFIG_NODE
, &vtysh_log_syslog_cmd
);
3172 install_element (CONFIG_NODE
, &vtysh_log_syslog_level_cmd
);
3173 install_element (CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
3174 install_element (CONFIG_NODE
, &vtysh_log_trap_cmd
);
3175 install_element (CONFIG_NODE
, &no_vtysh_log_trap_cmd
);
3176 install_element (CONFIG_NODE
, &vtysh_log_facility_cmd
);
3177 install_element (CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
3178 install_element (CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
3179 install_element (CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
3180 install_element (CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
3181 install_element (CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
3183 install_element (CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
3184 install_element (CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
3186 install_element (CONFIG_NODE
, &vtysh_password_cmd
);
3187 install_element (CONFIG_NODE
, &vtysh_password_text_cmd
);
3188 install_element (CONFIG_NODE
, &vtysh_enable_password_cmd
);
3189 install_element (CONFIG_NODE
, &vtysh_enable_password_text_cmd
);
3190 install_element (CONFIG_NODE
, &no_vtysh_enable_password_cmd
);
3192 /* grammar sandbox */
3193 grammar_sandbox_init();