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 DEFINE_MTYPE_STATIC(MVTYSH
, VTYSH_CMD
, "Vtysh cmd copy")
52 /* VTY shell pager name. */
53 char *vtysh_pager_name
= NULL
;
55 /* VTY shell client structure. */
62 struct vtysh_client
*next
;
65 struct vtysh_client vtysh_client
[] =
67 { .fd
= -1, .name
= "zebra", .flag
= VTYSH_ZEBRA
, .path
= ZEBRA_VTYSH_PATH
, .next
= NULL
},
68 { .fd
= -1, .name
= "ripd", .flag
= VTYSH_RIPD
, .path
= RIP_VTYSH_PATH
, .next
= NULL
},
69 { .fd
= -1, .name
= "ripngd", .flag
= VTYSH_RIPNGD
, .path
= RIPNG_VTYSH_PATH
, .next
= NULL
},
70 { .fd
= -1, .name
= "ospfd", .flag
= VTYSH_OSPFD
, .path
= OSPF_VTYSH_PATH
, .next
= NULL
},
71 { .fd
= -1, .name
= "ospf6d", .flag
= VTYSH_OSPF6D
, .path
= OSPF6_VTYSH_PATH
, .next
= NULL
},
72 { .fd
= -1, .name
= "ldpd", .flag
= VTYSH_LDPD
, .path
= LDP_VTYSH_PATH
, .next
= NULL
},
73 { .fd
= -1, .name
= "bgpd", .flag
= VTYSH_BGPD
, .path
= BGP_VTYSH_PATH
, .next
= NULL
},
74 { .fd
= -1, .name
= "isisd", .flag
= VTYSH_ISISD
, .path
= ISIS_VTYSH_PATH
, .next
= NULL
},
75 { .fd
= -1, .name
= "pimd", .flag
= VTYSH_PIMD
, .path
= PIM_VTYSH_PATH
, .next
= NULL
},
76 { .fd
= -1, .name
= "watchquagga", .flag
= VTYSH_WATCHQUAGGA
, .path
= WATCHQUAGGA_VTYSH_PATH
, .next
= NULL
},
79 enum vtysh_write_integrated vtysh_write_integrated
= WRITE_INTEGRATED_UNSPECIFIED
;
82 vclient_close (struct vtysh_client
*vclient
)
87 "Warning: closing connection to %s because of an I/O error!\n",
94 /* Return true if str begins with prefix, else return false */
96 begins_with(const char *str
, const char *prefix
)
100 size_t lenstr
= strlen(str
);
101 size_t lenprefix
= strlen(prefix
);
102 if (lenprefix
> lenstr
)
104 return strncmp(str
, prefix
, lenprefix
) == 0;
107 /* NB: multiplexed function:
108 * if fp == NULL, this calls vtysh_config_parse_line
109 * if fp != NULL, this prints lines to fp
112 vtysh_client_run (struct vtysh_client
*vclient
, const char *line
, FILE *fp
)
116 char *buf
= stackbuf
;
117 size_t bufsz
= sizeof(stackbuf
);
118 char *bufvalid
, *end
= NULL
;
119 char terminator
[3] = {0, 0, 0};
124 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
131 ssize_t nread
= read (vclient
->fd
, bufvalid
, buf
+ bufsz
- bufvalid
);
133 if (nread
< 0 && (errno
== EINTR
|| errno
== EAGAIN
))
138 fprintf (stderr
, "vtysh: error reading from %s: %s (%d)",
139 vclient
->name
, safe_strerror(errno
), errno
);
145 end
= memmem (buf
, bufvalid
- buf
, terminator
, sizeof(terminator
));
146 if (end
+ sizeof(terminator
) + 1 > bufvalid
)
147 /* found \0\0\0 but return code hasn't been read yet */
150 ret
= end
[sizeof(terminator
)];
152 while (bufvalid
> buf
&& (end
> buf
|| !end
))
154 size_t textlen
= (end
? end
: bufvalid
) - buf
;
155 char *eol
= memchr (buf
, '\n', textlen
);
160 /* no line break, end of input, no text left before end
161 * => don't insert an empty line at the end */
164 /* no line break, end of input, but some text left */
167 /* continue reading */
170 /* eol is at a line end now, either \n => \0 or \0\0\0 */
171 assert(eol
&& eol
<= bufvalid
);
179 vtysh_config_parse_line (buf
);
185 memmove (buf
, eol
, bufvalid
- eol
);
186 bufvalid
-= eol
- buf
;
191 if (bufvalid
== buf
+ bufsz
)
197 new = XMALLOC (MTYPE_TMP
, bufsz
);
198 memcpy (new, stackbuf
, sizeof(stackbuf
));
201 new = XREALLOC (MTYPE_TMP
, buf
, bufsz
);
203 bufvalid
= bufvalid
- buf
+ new;
205 /* if end != NULL, we won't be reading more data... */
206 assert (end
== NULL
);
213 vclient_close (vclient
);
217 XFREE (MTYPE_TMP
, buf
);
222 vtysh_client_run_all (struct vtysh_client
*head_client
, const char *line
,
223 int continue_on_err
, FILE *fp
)
225 struct vtysh_client
*client
;
226 int rc
, rc_all
= CMD_SUCCESS
;
228 for (client
= head_client
; client
; client
= client
->next
)
230 rc
= vtysh_client_run(client
, line
, fp
);
231 if (rc
!= CMD_SUCCESS
)
233 if (!continue_on_err
)
242 vtysh_client_execute (struct vtysh_client
*head_client
, const char *line
,
245 return vtysh_client_run_all (head_client
, line
, 0, fp
);
249 vtysh_client_config (struct vtysh_client
*head_client
, char *line
)
251 vtysh_client_run_all (head_client
, line
, 1, NULL
);
255 vtysh_pager_init (void)
259 pager_defined
= getenv ("VTYSH_PAGER");
262 vtysh_pager_name
= strdup (pager_defined
);
264 vtysh_pager_name
= strdup ("more");
267 /* Command execution over the vty interface. */
269 vtysh_execute_func (const char *line
, int pager
)
274 struct cmd_element
*cmd
;
278 int saved_ret
, saved_node
;
280 /* Split readline string up into the vector. */
281 vline
= cmd_make_strvec (line
);
286 saved_ret
= ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
287 saved_node
= vty
->node
;
289 /* If command doesn't succeeded in current node, try to walk up in node tree.
290 * Changing vty->node is enough to try it just out without actual walkup in
292 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
293 && vty
->node
> CONFIG_NODE
)
295 vty
->node
= node_parent(vty
->node
);
296 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
300 vty
->node
= saved_node
;
302 /* If command succeeded in any other node than current (tried > 0) we have
303 * to move into node in the vtysh where it succeeded. */
304 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
306 if ((saved_node
== BGP_VPNV4_NODE
|| saved_node
== BGP_VPNV6_NODE
307 || saved_node
== BGP_ENCAP_NODE
|| saved_node
== BGP_ENCAPV6_NODE
308 || saved_node
== BGP_IPV4_NODE
309 || saved_node
== BGP_IPV6_NODE
|| saved_node
== BGP_IPV4M_NODE
310 || saved_node
== BGP_IPV6M_NODE
)
313 vtysh_execute("exit-address-family");
315 else if ((saved_node
== BGP_VNC_DEFAULTS_NODE
316 || saved_node
== BGP_VNC_NVE_GROUP_NODE
317 || saved_node
== BGP_VNC_L2_GROUP_NODE
) && (tried
== 1))
319 vtysh_execute("exit-vnc");
321 else if ((saved_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
323 vtysh_execute("exit");
327 vtysh_execute ("end");
328 vtysh_execute ("configure terminal");
331 /* If command didn't succeed in any node, continue with return value from
338 cmd_free_strvec (vline
);
344 if (vty
->type
== VTY_FILE
)
345 fprintf (stdout
,"Warning...\n");
347 case CMD_ERR_AMBIGUOUS
:
348 fprintf (stdout
,"%% Ambiguous command.\n");
350 case CMD_ERR_NO_MATCH
:
351 fprintf (stdout
,"%% Unknown command.\n");
353 case CMD_ERR_INCOMPLETE
:
354 fprintf (stdout
,"%% Command incomplete.\n");
356 case CMD_SUCCESS_DAEMON
:
358 /* FIXME: Don't open pager for exit commands. popen() causes problems
359 * if exited from vtysh at all. This hack shouldn't cause any problem
360 * but is really ugly. */
361 if (pager
&& vtysh_pager_name
&& (strncmp(line
, "exit", 4) != 0))
363 fp
= popen (vtysh_pager_name
, "w");
366 perror ("popen failed for pager");
375 if (! strcmp(cmd
->string
,"configure terminal"))
377 for (i
= 0; i
< array_size(vtysh_client
); i
++)
379 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
380 if (cmd_stat
== CMD_WARNING
)
387 vline
= cmd_make_strvec (line
);
391 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
393 if (pclose (fp
) == -1)
395 perror ("pclose failed for pager");
402 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
403 cmd_free_strvec (vline
);
404 if (ret
!= CMD_SUCCESS_DAEMON
)
410 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
415 cmd_stat
= CMD_SUCCESS
;
416 for (i
= 0; i
< array_size(vtysh_client
); i
++)
418 if (cmd
->daemon
& vtysh_client
[i
].flag
)
420 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
421 if (cmd_stat
!= CMD_SUCCESS
)
425 if (cmd_stat
!= CMD_SUCCESS
)
429 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
432 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
434 if (pclose (fp
) == -1)
436 perror ("pclose failed for pager");
444 vtysh_execute_no_pager (const char *line
)
446 return vtysh_execute_func (line
, 0);
450 vtysh_execute (const char *line
)
452 return vtysh_execute_func (line
, 1);
467 while (end
>= s
&& isspace(*end
))
471 while (*s
&& isspace(*s
))
478 vtysh_mark_file (const char *filename
)
485 struct cmd_element
*cmd
;
486 int saved_ret
, prev_node
;
488 char *vty_buf_copy
= NULL
;
489 char *vty_buf_trimmed
= NULL
;
491 if (strncmp("-", filename
, 1) == 0)
494 confp
= fopen (filename
, "r");
498 fprintf (stderr
, "%% Can't open config file %s due to '%s'.\n",
499 filename
, safe_strerror (errno
));
500 return (CMD_ERR_NO_FILE
);
504 vty
->fd
= 0; /* stdout */
505 vty
->type
= VTY_TERM
;
506 vty
->node
= CONFIG_NODE
;
508 vtysh_execute_no_pager ("enable");
509 vtysh_execute_no_pager ("configure terminal");
510 vty_buf_copy
= XCALLOC (MTYPE_VTYSH_CMD
, VTY_BUFSIZ
);
512 while (fgets (vty
->buf
, VTY_BUFSIZ
, confp
))
516 strcpy(vty_buf_copy
, vty
->buf
);
517 vty_buf_trimmed
= trim(vty_buf_copy
);
519 if (vty_buf_trimmed
[0] == '!' || vty_buf_trimmed
[0] == '#')
521 fprintf(stdout
, "%s", vty
->buf
);
525 /* Split readline string up into the vector. */
526 vline
= cmd_make_strvec (vty
->buf
);
530 fprintf(stdout
, "%s", vty
->buf
);
534 /* Ignore the "end" lines, we will generate these where appropriate */
535 if (strlen(vty_buf_trimmed
) == 3 && strncmp("end", vty_buf_trimmed
, 3) == 0)
540 prev_node
= vty
->node
;
541 saved_ret
= ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
543 /* If command doesn't succeeded in current node, try to walk up in node tree.
544 * Changing vty->node is enough to try it just out without actual walkup in
546 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
547 && vty
->node
> CONFIG_NODE
)
549 vty
->node
= node_parent(vty
->node
);
550 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
554 /* If command succeeded in any other node than current (tried > 0) we have
555 * to move into node in the vtysh where it succeeded. */
556 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
558 if ((prev_node
== BGP_VPNV4_NODE
|| prev_node
== BGP_IPV4_NODE
559 || prev_node
== BGP_IPV6_NODE
|| prev_node
== BGP_IPV4M_NODE
560 || prev_node
== BGP_IPV6M_NODE
|| prev_node
== BGP_VPNV6_NODE
)
563 fprintf(stdout
, "exit-address-family\n");
565 else if ((prev_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
567 fprintf(stdout
, "exit\n");
571 fprintf(stdout
, "end\n");
574 /* If command didn't succeed in any node, continue with return value from
579 vty
->node
= prev_node
;
582 cmd_free_strvec (vline
);
586 if (vty
->type
== VTY_FILE
)
587 fprintf (stderr
,"line %d: Warning...: %s\n", lineno
, vty
->buf
);
590 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
592 case CMD_ERR_AMBIGUOUS
:
593 fprintf (stderr
,"line %d: %% Ambiguous command: %s\n", lineno
, vty
->buf
);
596 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
597 return CMD_ERR_AMBIGUOUS
;
598 case CMD_ERR_NO_MATCH
:
599 fprintf (stderr
,"line %d: %% Unknown command: %s\n", lineno
, vty
->buf
);
602 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
603 return CMD_ERR_NO_MATCH
;
604 case CMD_ERR_INCOMPLETE
:
605 fprintf (stderr
,"line %d: %% Command incomplete: %s\n", lineno
, vty
->buf
);
608 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
609 return CMD_ERR_INCOMPLETE
;
611 fprintf(stdout
, "%s", vty
->buf
);
613 case CMD_SUCCESS_DAEMON
:
616 int cmd_stat
= CMD_SUCCESS
;
618 fprintf(stdout
, "%s", vty
->buf
);
619 for (i
= 0; i
< array_size(vtysh_client
); i
++)
621 if (cmd
->daemon
& vtysh_client
[i
].flag
)
623 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
625 if (cmd_stat
!= CMD_SUCCESS
)
629 if (cmd_stat
!= CMD_SUCCESS
)
633 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
637 /* This is the end */
638 fprintf(stdout
, "end\n");
640 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
648 /* Configration make from file. */
650 vtysh_config_from_file (struct vty
*vty
, FILE *fp
)
653 struct cmd_element
*cmd
;
655 int retcode
= CMD_SUCCESS
;
657 while (fgets (vty
->buf
, VTY_BUFSIZ
, fp
))
661 ret
= command_config_read_one_line (vty
, &cmd
, 1);
666 if (vty
->type
== VTY_FILE
)
667 fprintf (stderr
,"line %d: Warning[%d]...: %s\n", lineno
, vty
->node
, vty
->buf
);
668 retcode
= CMD_WARNING
; /* once we have an error, we remember & return that */
670 case CMD_ERR_AMBIGUOUS
:
671 fprintf (stderr
,"line %d: %% Ambiguous command[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
672 retcode
= CMD_ERR_AMBIGUOUS
; /* once we have an error, we remember & return that */
674 case CMD_ERR_NO_MATCH
:
675 fprintf (stderr
,"line %d: %% Unknown command[%d]: %s", lineno
, vty
->node
, vty
->buf
);
676 retcode
= CMD_ERR_NO_MATCH
; /* once we have an error, we remember & return that */
678 case CMD_ERR_INCOMPLETE
:
679 fprintf (stderr
,"line %d: %% Command incomplete[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
680 retcode
= CMD_ERR_INCOMPLETE
; /* once we have an error, we remember & return that */
682 case CMD_SUCCESS_DAEMON
:
685 int cmd_stat
= CMD_SUCCESS
;
687 for (i
= 0; i
< array_size(vtysh_client
); i
++)
689 if (cmd
->daemon
& vtysh_client
[i
].flag
)
691 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
694 * CMD_WARNING - Can mean that the command was
695 * parsed successfully but it was already entered
696 * in a few spots. As such if we receive a
697 * CMD_WARNING from a daemon we shouldn't stop
698 * talking to the other daemons for the particular
701 if (cmd_stat
!= CMD_SUCCESS
&& cmd_stat
!= CMD_WARNING
)
703 fprintf (stderr
, "line %d: Failure to communicate[%d] to %s, line: %s\n",
704 lineno
, cmd_stat
, vtysh_client
[i
].name
, vty
->buf
);
709 if (cmd_stat
!= CMD_SUCCESS
)
713 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
721 /* We don't care about the point of the cursor when '?' is typed. */
723 vtysh_rl_describe (void)
730 struct cmd_token
*token
;
732 vline
= cmd_make_strvec (rl_line_buffer
);
734 /* In case of '> ?'. */
737 vline
= vector_init (1);
738 vector_set (vline
, NULL
);
741 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
742 vector_set (vline
, NULL
);
744 describe
= cmd_describe_command (vline
, vty
, &ret
);
746 fprintf (stdout
,"\n");
748 /* Ambiguous and no match error. */
751 case CMD_ERR_AMBIGUOUS
:
752 cmd_free_strvec (vline
);
753 fprintf (stdout
,"%% Ambiguous command.\n");
757 case CMD_ERR_NO_MATCH
:
758 cmd_free_strvec (vline
);
759 fprintf (stdout
,"%% There is no matched command.\n");
765 /* Get width of command string. */
767 for (i
= 0; i
< vector_active (describe
); i
++)
768 if ((token
= vector_slot (describe
, i
)) != NULL
)
772 if (token
->cmd
[0] == '\0')
775 len
= strlen (token
->cmd
);
776 if (token
->cmd
[0] == '.')
783 for (i
= 0; i
< vector_active (describe
); i
++)
784 if ((token
= vector_slot (describe
, i
)) != NULL
)
786 if (token
->cmd
[0] == '\0')
790 fprintf (stdout
," %-s\n",
791 token
->cmd
[0] == '.' ? token
->cmd
+ 1 : token
->cmd
);
793 fprintf (stdout
," %-*s %s\n",
795 token
->cmd
[0] == '.' ? token
->cmd
+ 1 : token
->cmd
,
799 cmd_free_strvec (vline
);
800 vector_free (describe
);
807 /* Result of cmd_complete_command() call will be stored here
808 * and used in new_completion() in order to put the space in
809 * correct places only. */
813 command_generator (const char *text
, int state
)
816 static char **matched
= NULL
;
817 static int index
= 0;
824 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
827 vline
= cmd_make_strvec (rl_line_buffer
);
831 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
832 vector_set (vline
, NULL
);
835 XFREE (MTYPE_TMP
, matched
);
836 matched
= cmd_complete_command (vline
, vty
, &complete_status
);
837 cmd_free_strvec (vline
);
840 if (matched
&& matched
[index
])
841 return matched
[index
++];
847 new_completion (char *text
, int start
, int end
)
851 matches
= rl_completion_matches (text
, command_generator
);
856 if (complete_status
!= CMD_COMPLETE_FULL_MATCH
)
857 /* only append a space on full match */
858 rl_completion_append_character
= '\0';
864 /* Vty node structures. */
865 static struct cmd_node bgp_node
=
868 "%s(config-router)# ",
871 static struct cmd_node rip_node
=
874 "%s(config-router)# ",
877 static struct cmd_node isis_node
=
880 "%s(config-router)# ",
883 static struct cmd_node interface_node
=
889 static struct cmd_node ns_node
=
892 "%s(config-logical-router)# ",
895 static struct cmd_node vrf_node
=
901 static struct cmd_node rmap_node
=
904 "%s(config-route-map)# "
907 static struct cmd_node zebra_node
=
910 "%s(config-router)# "
913 static struct cmd_node bgp_vpnv4_node
=
916 "%s(config-router-af)# "
919 static struct cmd_node bgp_vpnv6_node
=
922 "%s(config-router-af)# "
925 static struct cmd_node bgp_encap_node
=
928 "%s(config-router-af)# "
931 static struct cmd_node bgp_encapv6_node
=
934 "%s(config-router-af)# "
937 static struct cmd_node bgp_ipv4_node
=
940 "%s(config-router-af)# "
943 static struct cmd_node bgp_ipv4m_node
=
946 "%s(config-router-af)# "
949 static struct cmd_node bgp_ipv6_node
=
952 "%s(config-router-af)# "
955 static struct cmd_node bgp_ipv6m_node
=
958 "%s(config-router-af)# "
961 static struct cmd_node bgp_vnc_defaults_node
=
963 BGP_VNC_DEFAULTS_NODE
,
964 "%s(config-router-vnc-defaults)# "
967 static struct cmd_node bgp_vnc_nve_group_node
=
969 BGP_VNC_NVE_GROUP_NODE
,
970 "%s(config-router-vnc-nve-group)# "
973 static struct cmd_node bgp_vnc_l2_group_node
=
975 BGP_VNC_L2_GROUP_NODE
,
976 "%s(config-router-vnc-l2-group)# "
979 static struct cmd_node ospf_node
=
982 "%s(config-router)# "
985 static struct cmd_node ripng_node
=
988 "%s(config-router)# "
991 static struct cmd_node ospf6_node
=
997 static struct cmd_node ldp_node
=
1003 static struct cmd_node ldp_ipv4_node
=
1006 "%s(config-ldp-af)# "
1009 static struct cmd_node ldp_ipv6_node
=
1012 "%s(config-ldp-af)# "
1015 static struct cmd_node ldp_ipv4_iface_node
=
1017 LDP_IPV4_IFACE_NODE
,
1018 "%s(config-ldp-af-if)# "
1021 static struct cmd_node ldp_ipv6_iface_node
=
1023 LDP_IPV6_IFACE_NODE
,
1024 "%s(config-ldp-af-if)# "
1027 static struct cmd_node ldp_l2vpn_node
=
1030 "%s(config-l2vpn)# "
1033 static struct cmd_node ldp_pseudowire_node
=
1035 LDP_PSEUDOWIRE_NODE
,
1036 "%s(config-l2vpn-pw)# "
1039 static struct cmd_node keychain_node
=
1042 "%s(config-keychain)# "
1045 static struct cmd_node keychain_key_node
=
1048 "%s(config-keychain-key)# "
1051 struct cmd_node link_params_node
=
1054 "%s(config-link-params)# ",
1057 /* Defined in lib/vty.c */
1058 extern struct cmd_node vty_node
;
1060 /* When '^Z' is received from vty, move down to the enable mode. */
1068 /* Nothing to do. */
1071 vty
->node
= ENABLE_NODE
;
1077 DEFUNSH (VTYSH_REALLYALL
,
1081 "End current mode and change to enable mode\n")
1083 return vtysh_end ();
1086 DEFUNSH (VTYSH_BGPD
,
1089 "router bgp " CMD_AS_RANGE
,
1094 vty
->node
= BGP_NODE
;
1098 ALIAS_SH (VTYSH_BGPD
,
1105 ALIAS_SH (VTYSH_BGPD
,
1107 router_bgp_view_cmd
,
1108 "router bgp " CMD_AS_RANGE
" (view|vrf) WORD",
1112 "BGP view\nBGP VRF\n"
1115 DEFUNSH (VTYSH_BGPD
,
1116 address_family_vpnv4
,
1117 address_family_vpnv4_cmd
,
1118 "address-family vpnv4",
1119 "Enter Address Family command mode\n"
1122 vty
->node
= BGP_VPNV4_NODE
;
1126 DEFUNSH (VTYSH_BGPD
,
1127 address_family_vpnv4_unicast
,
1128 address_family_vpnv4_unicast_cmd
,
1129 "address-family vpnv4 unicast",
1130 "Enter Address Family command mode\n"
1132 "Address Family Modifier\n")
1134 vty
->node
= BGP_VPNV4_NODE
;
1138 DEFUNSH (VTYSH_BGPD
,
1139 address_family_vpnv6
,
1140 address_family_vpnv6_cmd
,
1141 "address-family vpnv6",
1142 "Enter Address Family command mode\n"
1145 vty
->node
= BGP_VPNV6_NODE
;
1149 DEFUNSH (VTYSH_BGPD
,
1150 address_family_vpnv6_unicast
,
1151 address_family_vpnv6_unicast_cmd
,
1152 "address-family vpnv6 unicast",
1153 "Enter Address Family command mode\n"
1155 "Address Family Modifier\n")
1157 vty
->node
= BGP_VPNV6_NODE
;
1161 DEFUNSH (VTYSH_BGPD
,
1162 address_family_encap
,
1163 address_family_encap_cmd
,
1164 "address-family encap",
1165 "Enter Address Family command mode\n"
1168 vty
->node
= BGP_ENCAP_NODE
;
1172 DEFUNSH (VTYSH_BGPD
,
1173 address_family_encapv4
,
1174 address_family_encapv4_cmd
,
1175 "address-family encapv4",
1176 "Enter Address Family command mode\n"
1179 vty
->node
= BGP_ENCAP_NODE
;
1183 DEFUNSH (VTYSH_BGPD
,
1184 address_family_encapv6
,
1185 address_family_encapv6_cmd
,
1186 "address-family encapv6",
1187 "Enter Address Family command mode\n"
1190 vty
->node
= BGP_ENCAPV6_NODE
;
1194 DEFUNSH (VTYSH_BGPD
,
1195 address_family_ipv4_unicast
,
1196 address_family_ipv4_unicast_cmd
,
1197 "address-family ipv4 unicast",
1198 "Enter Address Family command mode\n"
1200 "Address Family Modifier\n")
1202 vty
->node
= BGP_IPV4_NODE
;
1206 DEFUNSH (VTYSH_BGPD
,
1207 address_family_ipv4_multicast
,
1208 address_family_ipv4_multicast_cmd
,
1209 "address-family ipv4 multicast",
1210 "Enter Address Family command mode\n"
1212 "Address Family Modifier\n")
1214 vty
->node
= BGP_IPV4M_NODE
;
1218 DEFUNSH (VTYSH_BGPD
,
1219 address_family_ipv6
,
1220 address_family_ipv6_cmd
,
1221 "address-family ipv6",
1222 "Enter Address Family command mode\n"
1225 vty
->node
= BGP_IPV6_NODE
;
1229 DEFUNSH (VTYSH_BGPD
,
1230 address_family_ipv6_unicast
,
1231 address_family_ipv6_unicast_cmd
,
1232 "address-family ipv6 unicast",
1233 "Enter Address Family command mode\n"
1235 "Address Family Modifier\n")
1237 vty
->node
= BGP_IPV6_NODE
;
1241 DEFUNSH (VTYSH_BGPD
,
1242 address_family_ipv6_multicast
,
1243 address_family_ipv6_multicast_cmd
,
1244 "address-family ipv6 multicast",
1245 "Enter Address Family command mode\n"
1247 "Address Family Modifier\n")
1249 vty
->node
= BGP_IPV6M_NODE
;
1253 #if defined (ENABLE_BGP_VNC)
1254 DEFUNSH (VTYSH_BGPD
,
1258 "VNC/RFP related configuration\n"
1259 "Configure default NVE group\n")
1261 vty
->node
= BGP_VNC_DEFAULTS_NODE
;
1265 DEFUNSH (VTYSH_BGPD
,
1268 "vnc nve-group NAME",
1269 "VNC/RFP related configuration\n"
1270 "Configure a NVE group\n"
1273 vty
->node
= BGP_VNC_NVE_GROUP_NODE
;
1277 DEFUNSH (VTYSH_BGPD
,
1280 "vnc l2-group NAME",
1281 "VNC/RFP related configuration\n"
1282 "Configure a L2 group\n"
1285 vty
->node
= BGP_VNC_L2_GROUP_NODE
;
1290 DEFUNSH (VTYSH_RIPD
,
1294 "Authentication key management\n"
1295 "Key-chain management\n"
1298 vty
->node
= KEYCHAIN_NODE
;
1302 DEFUNSH (VTYSH_RIPD
,
1305 "key <0-2147483647>",
1307 "Key identifier number\n")
1309 vty
->node
= KEYCHAIN_KEY_NODE
;
1313 DEFUNSH (VTYSH_RIPD
,
1320 vty
->node
= RIP_NODE
;
1324 DEFUNSH (VTYSH_RIPNGD
,
1331 vty
->node
= RIPNG_NODE
;
1335 DEFUNSH (VTYSH_OSPFD
,
1339 "Enable a routing process\n"
1340 "Start OSPF configuration\n")
1342 vty
->node
= OSPF_NODE
;
1346 ALIAS_SH (VTYSH_OSPFD
,
1348 router_ospf_instance_cmd
,
1349 "router ospf <1-65535>",
1350 "Enable a routing process\n"
1351 "Start OSPF configuration\n"
1354 DEFUNSH (VTYSH_OSPF6D
,
1361 vty
->node
= OSPF6_NODE
;
1365 #if defined (HAVE_LDPD)
1366 DEFUNSH (VTYSH_LDPD
,
1370 "Global MPLS configuration subcommands\n"
1371 "Label Distribution Protocol\n")
1373 vty
->node
= LDP_NODE
;
1377 DEFUNSH (VTYSH_LDPD
,
1378 ldp_address_family_ipv4
,
1379 ldp_address_family_ipv4_cmd
,
1380 "address-family ipv4",
1381 "Configure Address Family and its parameters\n"
1384 vty
->node
= LDP_IPV4_NODE
;
1388 DEFUNSH (VTYSH_LDPD
,
1389 ldp_address_family_ipv6
,
1390 ldp_address_family_ipv6_cmd
,
1391 "address-family ipv6",
1392 "Configure Address Family and its parameters\n"
1395 vty
->node
= LDP_IPV6_NODE
;
1399 DEFUNSH (VTYSH_LDPD
,
1400 ldp_interface_ifname
,
1401 ldp_interface_ifname_cmd
,
1403 "Enable LDP on an interface and enter interface submode\n"
1404 "Interface's name\n")
1409 vty
->node
= LDP_IPV4_IFACE_NODE
;
1412 vty
->node
= LDP_IPV6_IFACE_NODE
;
1421 DEFUNSH (VTYSH_LDPD
,
1422 ldp_l2vpn_word_type_vpls
,
1423 ldp_l2vpn_word_type_vpls_cmd
,
1424 "l2vpn WORD type vpls",
1425 "Configure l2vpn commands\n"
1428 "Virtual Private LAN Service\n")
1430 vty
->node
= LDP_L2VPN_NODE
;
1434 DEFUNSH (VTYSH_LDPD
,
1435 ldp_member_pseudowire_ifname
,
1436 ldp_member_pseudowire_ifname_cmd
,
1437 "member pseudowire IFNAME",
1438 "L2VPN member configuration\n"
1439 "Pseudowire interface\n"
1440 "Interface's name\n")
1442 vty
->node
= LDP_PSEUDOWIRE_NODE
;
1447 DEFUNSH (VTYSH_ISISD
,
1453 "ISO Routing area tag")
1455 vty
->node
= ISIS_NODE
;
1459 DEFUNSH (VTYSH_RMAP
,
1461 vtysh_route_map_cmd
,
1462 "route-map WORD (deny|permit) <1-65535>",
1463 "Create route-map or enter route-map command mode\n"
1465 "Route map denies set operations\n"
1466 "Route map permits set operations\n"
1467 "Sequence to insert to/delete from existing route-map entry\n")
1469 vty
->node
= RMAP_NODE
;
1477 "Configure a terminal line\n"
1478 "Virtual terminal\n")
1480 vty
->node
= VTY_NODE
;
1484 DEFUNSH (VTYSH_REALLYALL
,
1488 "Turn on privileged mode command\n")
1490 vty
->node
= ENABLE_NODE
;
1494 DEFUNSH (VTYSH_REALLYALL
,
1498 "Turn off privileged mode command\n")
1500 if (vty
->node
== ENABLE_NODE
)
1501 vty
->node
= VIEW_NODE
;
1505 DEFUNSH (VTYSH_REALLYALL
,
1506 vtysh_config_terminal
,
1507 vtysh_config_terminal_cmd
,
1508 "configure terminal",
1509 "Configuration from vty interface\n"
1510 "Configuration terminal\n")
1512 vty
->node
= CONFIG_NODE
;
1517 vtysh_exit (struct vty
*vty
)
1526 vty
->node
= ENABLE_NODE
;
1528 case INTERFACE_NODE
:
1538 case LDP_L2VPN_NODE
:
1544 vtysh_execute("end");
1545 vtysh_execute("configure terminal");
1546 vty
->node
= CONFIG_NODE
;
1548 case BGP_VPNV4_NODE
:
1549 case BGP_VPNV6_NODE
:
1550 case BGP_ENCAP_NODE
:
1551 case BGP_ENCAPV6_NODE
:
1553 case BGP_IPV4M_NODE
:
1555 case BGP_IPV6M_NODE
:
1556 case BGP_VNC_DEFAULTS_NODE
:
1557 case BGP_VNC_NVE_GROUP_NODE
:
1558 case BGP_VNC_L2_GROUP_NODE
:
1559 vty
->node
= BGP_NODE
;
1563 vty
->node
= LDP_NODE
;
1565 case LDP_IPV4_IFACE_NODE
:
1566 vty
->node
= LDP_IPV4_NODE
;
1568 case LDP_IPV6_IFACE_NODE
:
1569 vty
->node
= LDP_IPV6_NODE
;
1571 case LDP_PSEUDOWIRE_NODE
:
1572 vty
->node
= LDP_L2VPN_NODE
;
1574 case KEYCHAIN_KEY_NODE
:
1575 vty
->node
= KEYCHAIN_NODE
;
1577 case LINK_PARAMS_NODE
:
1578 vty
->node
= INTERFACE_NODE
;
1586 DEFUNSH (VTYSH_REALLYALL
,
1590 "Exit current mode and down to previous mode\n")
1592 return vtysh_exit (vty
);
1595 ALIAS (vtysh_exit_all
,
1598 "Exit current mode and down to previous mode\n")
1600 DEFUNSH (VTYSH_BGPD
,
1601 exit_address_family
,
1602 exit_address_family_cmd
,
1603 "exit-address-family",
1604 "Exit from Address Family configuration mode\n")
1606 if (vty
->node
== BGP_IPV4_NODE
1607 || vty
->node
== BGP_IPV4M_NODE
1608 || vty
->node
== BGP_VPNV4_NODE
1609 || vty
->node
== BGP_VPNV6_NODE
1610 || vty
->node
== BGP_ENCAP_NODE
1611 || vty
->node
== BGP_ENCAPV6_NODE
1612 || vty
->node
== BGP_IPV6_NODE
1613 || vty
->node
== BGP_IPV6M_NODE
)
1614 vty
->node
= BGP_NODE
;
1618 DEFUNSH (VTYSH_BGPD
,
1620 exit_vnc_config_cmd
,
1622 "Exit from VNC configuration mode\n")
1624 if (vty
->node
== BGP_VNC_DEFAULTS_NODE
1625 || vty
->node
== BGP_VNC_NVE_GROUP_NODE
1626 || vty
->node
== BGP_VNC_L2_GROUP_NODE
)
1627 vty
->node
= BGP_NODE
;
1631 DEFUNSH (VTYSH_ZEBRA
,
1633 vtysh_exit_zebra_cmd
,
1635 "Exit current mode and down to previous mode\n")
1637 return vtysh_exit (vty
);
1640 ALIAS (vtysh_exit_zebra
,
1641 vtysh_quit_zebra_cmd
,
1643 "Exit current mode and down to previous mode\n")
1645 DEFUNSH (VTYSH_RIPD
,
1647 vtysh_exit_ripd_cmd
,
1649 "Exit current mode and down to previous mode\n")
1651 return vtysh_exit (vty
);
1654 ALIAS (vtysh_exit_ripd
,
1655 vtysh_quit_ripd_cmd
,
1657 "Exit current mode and down to previous mode\n")
1659 DEFUNSH (VTYSH_RIPNGD
,
1661 vtysh_exit_ripngd_cmd
,
1663 "Exit current mode and down to previous mode\n")
1665 return vtysh_exit (vty
);
1668 ALIAS (vtysh_exit_ripngd
,
1669 vtysh_quit_ripngd_cmd
,
1671 "Exit current mode and down to previous mode\n")
1673 DEFUNSH (VTYSH_RMAP
,
1675 vtysh_exit_rmap_cmd
,
1677 "Exit current mode and down to previous mode\n")
1679 return vtysh_exit (vty
);
1682 ALIAS (vtysh_exit_rmap
,
1683 vtysh_quit_rmap_cmd
,
1685 "Exit current mode and down to previous mode\n")
1687 DEFUNSH (VTYSH_BGPD
,
1689 vtysh_exit_bgpd_cmd
,
1691 "Exit current mode and down to previous mode\n")
1693 return vtysh_exit (vty
);
1696 ALIAS (vtysh_exit_bgpd
,
1697 vtysh_quit_bgpd_cmd
,
1699 "Exit current mode and down to previous mode\n")
1701 DEFUNSH (VTYSH_OSPFD
,
1703 vtysh_exit_ospfd_cmd
,
1705 "Exit current mode and down to previous mode\n")
1707 return vtysh_exit (vty
);
1710 ALIAS (vtysh_exit_ospfd
,
1711 vtysh_quit_ospfd_cmd
,
1713 "Exit current mode and down to previous mode\n")
1715 DEFUNSH (VTYSH_OSPF6D
,
1717 vtysh_exit_ospf6d_cmd
,
1719 "Exit current mode and down to previous mode\n")
1721 return vtysh_exit (vty
);
1724 ALIAS (vtysh_exit_ospf6d
,
1725 vtysh_quit_ospf6d_cmd
,
1727 "Exit current mode and down to previous mode\n")
1729 #if defined (HAVE_LDPD)
1730 DEFUNSH (VTYSH_LDPD
,
1732 vtysh_exit_ldpd_cmd
,
1734 "Exit current mode and down to previous mode\n")
1736 return vtysh_exit (vty
);
1739 ALIAS (vtysh_exit_ldpd
,
1740 vtysh_quit_ldpd_cmd
,
1742 "Exit current mode and down to previous mode\n")
1745 DEFUNSH (VTYSH_ISISD
,
1747 vtysh_exit_isisd_cmd
,
1749 "Exit current mode and down to previous mode\n")
1751 return vtysh_exit (vty
);
1754 ALIAS (vtysh_exit_isisd
,
1755 vtysh_quit_isisd_cmd
,
1757 "Exit current mode and down to previous mode\n")
1760 vtysh_exit_line_vty
,
1761 vtysh_exit_line_vty_cmd
,
1763 "Exit current mode and down to previous mode\n")
1765 return vtysh_exit (vty
);
1768 ALIAS (vtysh_exit_line_vty
,
1769 vtysh_quit_line_vty_cmd
,
1771 "Exit current mode and down to previous mode\n")
1773 DEFUNSH (VTYSH_INTERFACE
,
1775 vtysh_interface_cmd
,
1777 "Select an interface to configure\n"
1778 "Interface's name\n")
1780 vty
->node
= INTERFACE_NODE
;
1784 ALIAS_SH (VTYSH_ZEBRA
,
1786 vtysh_interface_vrf_cmd
,
1787 "interface IFNAME " VRF_CMD_STR
,
1788 "Select an interface to configure\n"
1789 "Interface's name\n"
1792 /* TODO Implement "no interface command in isisd. */
1793 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_RIPNGD
|VTYSH_OSPFD
|VTYSH_OSPF6D
|VTYSH_LDPD
,
1794 vtysh_no_interface_cmd
,
1795 "no interface IFNAME",
1797 "Delete a pseudo interface's configuration\n"
1798 "Interface's name\n")
1801 vtysh_no_interface_vrf_cmd
,
1802 "no interface IFNAME " VRF_CMD_STR
,
1804 "Delete a pseudo interface's configuration\n"
1805 "Interface's name\n"
1811 "logical-router <1-65535 ns NAME",
1812 "Enable a logical-router\n"
1813 "Specify the logical-router indentifier\n"
1815 "The file name in " NS_RUN_DIR
", or a full pathname\n")
1817 vty
->node
= NS_NODE
;
1825 "Select a VRF to configure\n"
1828 vty
->node
= VRF_NODE
;
1836 "Delete a pseudo vrf's configuration\n"
1843 "Exit current mode and down to previous mode\n")
1845 return vtysh_exit (vty
);
1848 ALIAS (vtysh_exit_ns
,
1851 "Exit current mode and down to previous mode\n")
1857 "Exit current mode and down to previous mode\n")
1859 return vtysh_exit (vty
);
1862 ALIAS (vtysh_exit_vrf
,
1865 "Exit current mode and down to previous mode\n")
1867 /* TODO Implement interface description commands in ripngd, ospf6d
1869 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
|VTYSH_LDPD
,
1870 vtysh_interface_desc_cmd
,
1871 "description .LINE",
1872 "Interface specific description\n"
1873 "Characters describing this interface\n")
1875 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1876 vtysh_no_interface_desc_cmd
,
1879 "Interface specific description\n")
1881 DEFUNSH (VTYSH_INTERFACE
,
1882 vtysh_exit_interface
,
1883 vtysh_exit_interface_cmd
,
1885 "Exit current mode and down to previous mode\n")
1887 return vtysh_exit (vty
);
1890 ALIAS (vtysh_exit_interface
,
1891 vtysh_quit_interface_cmd
,
1893 "Exit current mode and down to previous mode\n")
1895 DEFUN (vtysh_show_thread
,
1896 vtysh_show_thread_cmd
,
1897 "show thread cpu [FILTER]",
1899 "Thread information\n"
1900 "Thread CPU usage\n"
1901 "Display filter (rwtexb)\n")
1904 int ret
= CMD_SUCCESS
;
1907 sprintf(line
, "show thread cpu %s\n", (argc
== 1) ? argv
[0] : "");
1908 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1909 if ( vtysh_client
[i
].fd
>= 0 )
1911 fprintf (stdout
, "Thread statistics for %s:\n",
1912 vtysh_client
[i
].name
);
1913 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1914 fprintf (stdout
,"\n");
1919 DEFUN (vtysh_show_work_queues
,
1920 vtysh_show_work_queues_cmd
,
1923 "Work Queue information\n")
1926 int ret
= CMD_SUCCESS
;
1927 char line
[] = "show work-queues\n";
1929 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1930 if ( vtysh_client
[i
].fd
>= 0 )
1932 fprintf (stdout
, "Work queue statistics for %s:\n",
1933 vtysh_client
[i
].name
);
1934 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1935 fprintf (stdout
,"\n");
1941 DEFUN (vtysh_show_work_queues_daemon
,
1942 vtysh_show_work_queues_daemon_cmd
,
1943 "show work-queues (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd)",
1945 "Work Queue information\n"
1946 "For the zebra daemon\n"
1947 "For the rip daemon\n"
1948 "For the ripng daemon\n"
1949 "For the ospf daemon\n"
1950 "For the ospfv6 daemon\n"
1951 "For the bgp daemon\n"
1952 "For the isis daemon\n")
1955 int ret
= CMD_SUCCESS
;
1957 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1959 if (begins_with(vtysh_client
[i
].name
, argv
[0]))
1963 ret
= vtysh_client_execute(&vtysh_client
[i
], "show work-queues\n", stdout
);
1968 DEFUNSH (VTYSH_ZEBRA
,
1970 vtysh_link_params_cmd
,
1975 vty
->node
= LINK_PARAMS_NODE
;
1979 DEFUNSH (VTYSH_ZEBRA
,
1981 exit_link_params_cmd
,
1983 "Exit from Link Params configuration node\n")
1985 if (vty
->node
== LINK_PARAMS_NODE
)
1986 vty
->node
= INTERFACE_NODE
;
1991 DEFUN (vtysh_show_memory
,
1992 vtysh_show_memory_cmd
,
1995 "Memory statistics\n")
1998 int ret
= CMD_SUCCESS
;
1999 char line
[] = "show memory\n";
2001 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2002 if ( vtysh_client
[i
].fd
>= 0 )
2004 fprintf (stdout
, "Memory statistics for %s:\n",
2005 vtysh_client
[i
].name
);
2006 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2007 fprintf (stdout
,"\n");
2013 /* Logging commands. */
2014 DEFUN (vtysh_show_logging
,
2015 vtysh_show_logging_cmd
,
2018 "Show current logging configuration\n")
2021 int ret
= CMD_SUCCESS
;
2022 char line
[] = "show logging\n";
2024 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2025 if ( vtysh_client
[i
].fd
>= 0 )
2027 fprintf (stdout
,"Logging configuration for %s:\n",
2028 vtysh_client
[i
].name
);
2029 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2030 fprintf (stdout
,"\n");
2038 vtysh_log_stdout_cmd
,
2041 "Set stdout logging level\n")
2047 vtysh_log_stdout_level
,
2048 vtysh_log_stdout_level_cmd
,
2049 "log stdout "LOG_LEVELS
,
2051 "Set stdout logging level\n"
2058 no_vtysh_log_stdout
,
2059 no_vtysh_log_stdout_cmd
,
2060 "no log stdout [LEVEL]",
2063 "Cancel logging to stdout\n"
2072 "log file FILENAME",
2075 "Logging filename\n")
2081 vtysh_log_file_level
,
2082 vtysh_log_file_level_cmd
,
2083 "log file FILENAME "LOG_LEVELS
,
2086 "Logging filename\n"
2094 no_vtysh_log_file_cmd
,
2095 "no log file [FILENAME]",
2098 "Cancel logging to file\n"
2099 "Logging file name\n")
2104 ALIAS_SH (VTYSH_ALL
,
2106 no_vtysh_log_file_level_cmd
,
2107 "no log file FILENAME LEVEL",
2110 "Cancel logging to file\n"
2111 "Logging file name\n"
2116 vtysh_log_monitor_cmd
,
2119 "Set terminal line (monitor) logging level\n")
2125 vtysh_log_monitor_level
,
2126 vtysh_log_monitor_level_cmd
,
2127 "log monitor "LOG_LEVELS
,
2129 "Set terminal line (monitor) logging level\n"
2136 no_vtysh_log_monitor
,
2137 no_vtysh_log_monitor_cmd
,
2138 "no log monitor [LEVEL]",
2141 "Disable terminal line (monitor) logging\n"
2149 vtysh_log_syslog_cmd
,
2152 "Set syslog logging level\n")
2158 vtysh_log_syslog_level
,
2159 vtysh_log_syslog_level_cmd
,
2160 "log syslog "LOG_LEVELS
,
2162 "Set syslog logging level\n"
2169 no_vtysh_log_syslog
,
2170 no_vtysh_log_syslog_cmd
,
2171 "no log syslog [LEVEL]",
2174 "Cancel logging to syslog\n"
2182 vtysh_log_facility_cmd
,
2183 "log facility "LOG_FACILITIES
,
2185 "Facility parameter for syslog messages\n"
2193 no_vtysh_log_facility
,
2194 no_vtysh_log_facility_cmd
,
2195 "no log facility [FACILITY]",
2198 "Reset syslog facility to default (daemon)\n"
2199 "Syslog facility\n")
2205 DEFUNSH_DEPRECATED (VTYSH_ALL
,
2208 "log trap "LOG_LEVELS
,
2210 "(Deprecated) Set logging level and default for all destinations\n"
2217 DEFUNSH_DEPRECATED (VTYSH_ALL
,
2219 no_vtysh_log_trap_cmd
,
2220 "no log trap [LEVEL]",
2223 "Permit all logging information\n"
2230 vtysh_log_record_priority
,
2231 vtysh_log_record_priority_cmd
,
2232 "log record-priority",
2234 "Log the priority of the message within the message\n")
2240 no_vtysh_log_record_priority
,
2241 no_vtysh_log_record_priority_cmd
,
2242 "no log record-priority",
2245 "Do not log the priority of the message within the message\n")
2251 vtysh_log_timestamp_precision
,
2252 vtysh_log_timestamp_precision_cmd
,
2253 "log timestamp precision <0-6>",
2255 "Timestamp configuration\n"
2256 "Set the timestamp precision\n"
2257 "Number of subsecond digits\n")
2263 no_vtysh_log_timestamp_precision
,
2264 no_vtysh_log_timestamp_precision_cmd
,
2265 "no log timestamp precision",
2268 "Timestamp configuration\n"
2269 "Reset the timestamp precision to the default value of 0\n")
2275 vtysh_service_password_encrypt
,
2276 vtysh_service_password_encrypt_cmd
,
2277 "service password-encryption",
2278 "Set up miscellaneous service\n"
2279 "Enable encrypted passwords\n")
2285 no_vtysh_service_password_encrypt
,
2286 no_vtysh_service_password_encrypt_cmd
,
2287 "no service password-encryption",
2289 "Set up miscellaneous service\n"
2290 "Enable encrypted passwords\n")
2296 vtysh_config_password
,
2298 "password (8|) WORD",
2299 "Assign the terminal connection password\n"
2300 "Specifies a HIDDEN password will follow\n"
2302 "The HIDDEN line password string\n")
2308 vtysh_password_text
,
2309 vtysh_password_text_cmd
,
2311 "Assign the terminal connection password\n"
2312 "The UNENCRYPTED (cleartext) line password\n")
2318 vtysh_config_enable_password
,
2319 vtysh_enable_password_cmd
,
2320 "enable password (8|) WORD",
2321 "Modify enable password parameters\n"
2322 "Assign the privileged level password\n"
2323 "Specifies a HIDDEN password will follow\n"
2325 "The HIDDEN 'enable' password string\n")
2331 vtysh_enable_password_text
,
2332 vtysh_enable_password_text_cmd
,
2333 "enable password LINE",
2334 "Modify enable password parameters\n"
2335 "Assign the privileged level password\n"
2336 "The UNENCRYPTED (cleartext) 'enable' password\n")
2342 no_vtysh_config_enable_password
,
2343 no_vtysh_enable_password_cmd
,
2344 "no enable password",
2346 "Modify enable password parameters\n"
2347 "Assign the privileged level password\n")
2352 DEFUN (vtysh_write_terminal
,
2353 vtysh_write_terminal_cmd
,
2355 "Write running configuration to memory, network, or terminal\n"
2356 "Write to terminal\n")
2359 char line
[] = "write terminal\n";
2362 if (vtysh_pager_name
)
2364 fp
= popen (vtysh_pager_name
, "w");
2374 vty_out (vty
, "Building configuration...%s", VTY_NEWLINE
);
2375 vty_out (vty
, "%sCurrent configuration:%s", VTY_NEWLINE
,
2377 vty_out (vty
, "!%s", VTY_NEWLINE
);
2379 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2380 if ((argc
< 1 ) || (begins_with(vtysh_client
[i
].name
, argv
[0])))
2381 vtysh_client_config (&vtysh_client
[i
], line
);
2383 /* Integrate vtysh specific configuration. */
2384 vtysh_config_write ();
2386 vtysh_config_dump (fp
);
2388 if (vtysh_pager_name
&& fp
)
2391 if (pclose (fp
) == -1)
2399 vty_out (vty
, "end%s", VTY_NEWLINE
);
2404 DEFUN (vtysh_write_terminal_daemon
,
2405 vtysh_write_terminal_daemon_cmd
,
2406 "write terminal (zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd)",
2407 "Write running configuration to memory, network, or terminal\n"
2408 "Write to terminal\n"
2409 "For the zebra daemon\n"
2410 "For the rip daemon\n"
2411 "For the ripng daemon\n"
2412 "For the ospf daemon\n"
2413 "For the ospfv6 daemon\n"
2414 "For the ldp daemon\n"
2415 "For the bgp daemon\n"
2416 "For the isis daemon\n"
2417 "For the pim daemon\n")
2420 int ret
= CMD_SUCCESS
;
2422 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2424 if (begins_with(vtysh_client
[i
].name
, argv
[0]))
2428 if (i
== array_size(vtysh_client
))
2429 return CMD_ERR_NO_MATCH
;
2431 ret
= vtysh_client_execute(&vtysh_client
[i
], "show running-config\n", stdout
);
2436 DEFUN (vtysh_integrated_config
,
2437 vtysh_integrated_config_cmd
,
2438 "service integrated-vtysh-config",
2439 "Set up miscellaneous service\n"
2440 "Write configuration into integrated file\n")
2442 vtysh_write_integrated
= WRITE_INTEGRATED_YES
;
2446 DEFUN (no_vtysh_integrated_config
,
2447 no_vtysh_integrated_config_cmd
,
2448 "no service integrated-vtysh-config",
2450 "Set up miscellaneous service\n"
2451 "Write configuration into integrated file\n")
2453 vtysh_write_integrated
= WRITE_INTEGRATED_NO
;
2458 backup_config_file (const char *fbackup
)
2460 char *integrate_sav
= NULL
;
2462 integrate_sav
= malloc (strlen (fbackup
) +
2463 strlen (CONF_BACKUP_EXT
) + 1);
2464 strcpy (integrate_sav
, fbackup
);
2465 strcat (integrate_sav
, CONF_BACKUP_EXT
);
2467 /* Move current configuration file to backup config file. */
2468 unlink (integrate_sav
);
2469 rename (fbackup
, integrate_sav
);
2470 free (integrate_sav
);
2474 vtysh_write_config_integrated(void)
2477 char line
[] = "write terminal\n";
2480 struct passwd
*pwentry
;
2481 struct group
*grentry
;
2487 fprintf (stdout
,"Building Configuration...\n");
2489 backup_config_file(quagga_config
);
2490 fp
= fopen (quagga_config
, "w");
2493 fprintf (stdout
,"%% Error: failed to open configuration file %s: %s\n",
2494 quagga_config
, safe_strerror(errno
));
2499 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2500 vtysh_client_config (&vtysh_client
[i
], line
);
2502 vtysh_config_write ();
2503 vtysh_config_dump (fp
);
2505 if (fchmod (fd
, CONFIGFILE_MASK
) != 0)
2507 printf ("%% Warning: can't chmod configuration file %s: %s\n",
2508 quagga_config
, safe_strerror(errno
));
2512 pwentry
= getpwnam (FRR_USER
);
2514 uid
= pwentry
->pw_uid
;
2517 printf ("%% Warning: could not look up user \"%s\"\n", FRR_USER
);
2521 grentry
= getgrnam (FRR_GROUP
);
2523 gid
= grentry
->gr_gid
;
2526 printf ("%% Warning: could not look up group \"%s\"\n", FRR_GROUP
);
2530 if (!fstat (fd
, &st
))
2532 if (st
.st_uid
== uid
)
2534 if (st
.st_gid
== gid
)
2536 if ((uid
!= (uid_t
)-1 || gid
!= (gid_t
)-1) && fchown (fd
, uid
, gid
))
2538 printf ("%% Warning: can't chown configuration file %s: %s\n",
2539 quagga_config
, safe_strerror(errno
));
2545 printf ("%% Warning: stat() failed on %s: %s\n",
2546 quagga_config
, safe_strerror(errno
));
2552 printf ("Integrated configuration saved to %s\n", quagga_config
);
2560 static bool want_config_integrated(void)
2564 switch (vtysh_write_integrated
)
2566 case WRITE_INTEGRATED_UNSPECIFIED
:
2567 if (stat(quagga_config
, &s
) && errno
== ENOENT
)
2570 case WRITE_INTEGRATED_NO
:
2572 case WRITE_INTEGRATED_YES
:
2578 DEFUN (vtysh_write_memory
,
2579 vtysh_write_memory_cmd
,
2581 "Write running configuration to memory, network, or terminal\n"
2582 "Write configuration to the file (same as write file)\n")
2584 int ret
= CMD_SUCCESS
;
2585 char line
[] = "write memory\n";
2588 fprintf (stdout
, "Note: this version of vtysh never writes vtysh.conf\n");
2590 /* If integrated Quagga.conf explicitely set. */
2591 if (want_config_integrated())
2594 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2595 if (vtysh_client
[i
].flag
== VTYSH_WATCHQUAGGA
)
2597 if (i
< array_size(vtysh_client
) && vtysh_client
[i
].fd
!= -1)
2598 ret
= vtysh_client_execute (&vtysh_client
[i
], "write integrated", stdout
);
2600 if (ret
!= CMD_SUCCESS
)
2602 printf("\nWarning: attempting direct configuration write without "
2603 "watchquagga.\nFile permissions and ownership may be "
2604 "incorrect, or write may fail.\n\n");
2605 ret
= vtysh_write_config_integrated();
2610 fprintf (stdout
,"Building Configuration...\n");
2612 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2613 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2618 ALIAS (vtysh_write_memory
,
2619 vtysh_copy_runningconfig_startupconfig_cmd
,
2620 "copy running-config startup-config",
2621 "Copy from one file to another\n"
2622 "Copy from current system configuration\n"
2623 "Copy to startup configuration\n")
2625 ALIAS (vtysh_write_memory
,
2626 vtysh_write_file_cmd
,
2628 "Write running configuration to memory, network, or terminal\n"
2629 "Write configuration to the file (same as write memory)\n")
2631 ALIAS (vtysh_write_memory
,
2634 "Write running configuration to memory, network, or terminal\n")
2636 ALIAS (vtysh_write_terminal
,
2637 vtysh_show_running_config_cmd
,
2638 "show running-config",
2640 "Current operating configuration\n")
2642 ALIAS (vtysh_write_terminal
,
2643 vtysh_show_running_config_daemon_cmd
,
2644 "show running-config (zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd)",
2646 "Current operating configuration\n"
2647 "For the zebra daemon\n"
2648 "For the rip daemon\n"
2649 "For the ripng daemon\n"
2650 "For the ospf daemon\n"
2651 "For the ospfv6 daemon\n"
2652 "For the ldp daemon\n"
2653 "For the bgp daemon\n"
2654 "For the isis daemon\n"
2655 "For the pim daemon\n")
2657 DEFUN (vtysh_terminal_length
,
2658 vtysh_terminal_length_cmd
,
2659 "terminal length <0-512>",
2660 "Set terminal line parameters\n"
2661 "Set number of lines on a screen\n"
2662 "Number of lines on screen (0 for no pausing)\n")
2665 char *endptr
= NULL
;
2666 char default_pager
[10];
2668 lines
= strtol (argv
[0], &endptr
, 10);
2669 if (lines
< 0 || lines
> 512 || *endptr
!= '\0')
2671 vty_out (vty
, "length is malformed%s", VTY_NEWLINE
);
2675 if (vtysh_pager_name
)
2677 free (vtysh_pager_name
);
2678 vtysh_pager_name
= NULL
;
2683 snprintf(default_pager
, 10, "more -%i", lines
);
2684 vtysh_pager_name
= strdup (default_pager
);
2690 DEFUN (vtysh_terminal_no_length
,
2691 vtysh_terminal_no_length_cmd
,
2692 "terminal no length",
2693 "Set terminal line parameters\n"
2695 "Set number of lines on a screen\n")
2697 if (vtysh_pager_name
)
2699 free (vtysh_pager_name
);
2700 vtysh_pager_name
= NULL
;
2707 DEFUN (vtysh_show_daemons
,
2708 vtysh_show_daemons_cmd
,
2711 "Show list of running daemons\n")
2715 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2716 if ( vtysh_client
[i
].fd
>= 0 )
2717 vty_out(vty
, " %s", vtysh_client
[i
].name
);
2718 vty_out(vty
, "%s", VTY_NEWLINE
);
2723 /* Execute command in child process. */
2725 execute_command (const char *command
, int argc
, const char *arg1
,
2736 /* Failure of fork(). */
2737 fprintf (stderr
, "Can't fork: %s\n", safe_strerror (errno
));
2742 /* This is child process. */
2746 execlp (command
, command
, (const char *)NULL
);
2749 execlp (command
, command
, arg1
, (const char *)NULL
);
2752 execlp (command
, command
, arg1
, arg2
, (const char *)NULL
);
2756 /* When execlp suceed, this part is not executed. */
2757 fprintf (stderr
, "Can't execute %s: %s\n", command
, safe_strerror (errno
));
2762 /* This is parent. */
2764 wait4 (pid
, &status
, 0, NULL
);
2772 "Send echo messages\n"
2773 "Ping destination address or hostname\n")
2775 execute_command ("ping", 1, argv
[0], NULL
);
2782 "Send echo messages\n"
2784 "Ping destination address or hostname\n")
2786 DEFUN (vtysh_traceroute
,
2787 vtysh_traceroute_cmd
,
2789 "Trace route to destination\n"
2790 "Trace route to destination address or hostname\n")
2792 execute_command ("traceroute", 1, argv
[0], NULL
);
2796 ALIAS (vtysh_traceroute
,
2797 vtysh_traceroute_ip_cmd
,
2798 "traceroute ip WORD",
2799 "Trace route to destination\n"
2801 "Trace route to destination address or hostname\n")
2806 "Send echo messages\n"
2808 "Ping destination address or hostname\n")
2810 execute_command ("ping6", 1, argv
[0], NULL
);
2814 DEFUN (vtysh_traceroute6
,
2815 vtysh_traceroute6_cmd
,
2816 "traceroute ipv6 WORD",
2817 "Trace route to destination\n"
2819 "Trace route to destination address or hostname\n")
2821 execute_command ("traceroute6", 1, argv
[0], NULL
);
2825 #if defined(HAVE_SHELL_ACCESS)
2826 DEFUN (vtysh_telnet
,
2829 "Open a telnet connection\n"
2830 "IP address or hostname of a remote system\n")
2832 execute_command ("telnet", 1, argv
[0], NULL
);
2836 DEFUN (vtysh_telnet_port
,
2837 vtysh_telnet_port_cmd
,
2839 "Open a telnet connection\n"
2840 "IP address or hostname of a remote system\n"
2841 "TCP Port number\n")
2843 execute_command ("telnet", 2, argv
[0], argv
[1]);
2850 "Open an ssh connection\n"
2853 execute_command ("ssh", 1, argv
[0], NULL
);
2857 DEFUN (vtysh_start_shell
,
2858 vtysh_start_shell_cmd
,
2860 "Start UNIX shell\n")
2862 execute_command ("sh", 0, NULL
, NULL
);
2866 DEFUN (vtysh_start_bash
,
2867 vtysh_start_bash_cmd
,
2869 "Start UNIX shell\n"
2872 execute_command ("bash", 0, NULL
, NULL
);
2876 DEFUN (vtysh_start_zsh
,
2877 vtysh_start_zsh_cmd
,
2879 "Start UNIX shell\n"
2882 execute_command ("zsh", 0, NULL
, NULL
);
2888 vtysh_install_default (enum node_type node
)
2890 install_element (node
, &config_list_cmd
);
2893 /* Making connection to protocol daemon. */
2895 vtysh_connect (struct vtysh_client
*vclient
)
2899 struct sockaddr_un addr
;
2902 /* Stat socket to see if we have permission to access it. */
2903 ret
= stat (vclient
->path
, &s_stat
);
2904 if (ret
< 0 && errno
!= ENOENT
)
2906 fprintf (stderr
, "vtysh_connect(%s): stat = %s\n",
2907 vclient
->path
, safe_strerror(errno
));
2913 if (! S_ISSOCK(s_stat
.st_mode
))
2915 fprintf (stderr
, "vtysh_connect(%s): Not a socket\n",
2922 sock
= socket (AF_UNIX
, SOCK_STREAM
, 0);
2926 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", vclient
->path
,
2927 safe_strerror(errno
));
2932 memset (&addr
, 0, sizeof (struct sockaddr_un
));
2933 addr
.sun_family
= AF_UNIX
;
2934 strncpy (addr
.sun_path
, vclient
->path
, strlen (vclient
->path
));
2935 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
2936 len
= addr
.sun_len
= SUN_LEN(&addr
);
2938 len
= sizeof (addr
.sun_family
) + strlen (addr
.sun_path
);
2939 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
2941 ret
= connect (sock
, (struct sockaddr
*) &addr
, len
);
2945 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", vclient
->path
,
2946 safe_strerror(errno
));
2956 /* Return true if str ends with suffix, else return false */
2958 ends_with(const char *str
, const char *suffix
)
2960 if (!str
|| !suffix
)
2962 size_t lenstr
= strlen(str
);
2963 size_t lensuffix
= strlen(suffix
);
2964 if (lensuffix
> lenstr
)
2966 return strncmp(str
+ lenstr
- lensuffix
, suffix
, lensuffix
) == 0;
2970 vtysh_client_sorted_insert (struct vtysh_client
*head_client
,
2971 struct vtysh_client
*client
)
2973 struct vtysh_client
*prev_node
, *current_node
;
2975 prev_node
= head_client
;
2976 current_node
= head_client
->next
;
2977 while (current_node
)
2979 if (strcmp(current_node
->path
, client
->path
) > 0)
2982 prev_node
= current_node
;
2983 current_node
= current_node
->next
;
2985 client
->next
= current_node
;
2986 prev_node
->next
= client
;
2989 #define MAXIMUM_INSTANCES 10
2992 vtysh_update_all_insances(struct vtysh_client
* head_client
)
2994 struct vtysh_client
*client
;
2997 struct dirent
*file
;
3000 if (head_client
->flag
!= VTYSH_OSPFD
) return;
3002 /* ls /var/run/quagga/ and look for all files ending in .vty */
3003 dir
= opendir("/var/run/quagga/");
3006 while ((file
= readdir(dir
)) != NULL
)
3008 if (begins_with(file
->d_name
, "ospfd-") && ends_with(file
->d_name
, ".vty"))
3010 if (n
== MAXIMUM_INSTANCES
)
3013 "Parsing /var/run/quagga/, client limit(%d) reached!\n", n
);
3016 client
= (struct vtysh_client
*) malloc(sizeof(struct vtysh_client
));
3018 client
->name
= "ospfd";
3019 client
->flag
= VTYSH_OSPFD
;
3020 ptr
= (char *) malloc(100);
3021 sprintf(ptr
, "/var/run/quagga/%s", file
->d_name
);
3022 client
->path
= (const char *)ptr
;
3023 client
->next
= NULL
;
3024 vtysh_client_sorted_insert(head_client
, client
);
3033 vtysh_connect_all_instances (struct vtysh_client
*head_client
)
3035 struct vtysh_client
*client
;
3038 vtysh_update_all_insances(head_client
);
3040 client
= head_client
->next
;
3043 if (vtysh_connect(client
) == 0)
3045 client
= client
->next
;
3052 vtysh_connect_all(const char *daemon_name
)
3058 for (i
= 0; i
< array_size(vtysh_client
); i
++)
3060 if (!daemon_name
|| !strcmp(daemon_name
, vtysh_client
[i
].name
))
3063 if (vtysh_connect(&vtysh_client
[i
]) == 0)
3066 rc
+= vtysh_connect_all_instances(&vtysh_client
[i
]);
3070 fprintf(stderr
, "Error: no daemons match name %s!\n", daemon_name
);
3074 /* To disable readline's filename completion. */
3076 vtysh_completion_entry_function (const char *ignore
, int invoking_key
)
3082 vtysh_readline_init (void)
3084 /* readline related settings. */
3085 rl_bind_key ('?', (rl_command_func_t
*) vtysh_rl_describe
);
3086 rl_completion_entry_function
= vtysh_completion_entry_function
;
3087 rl_attempted_completion_function
= (rl_completion_func_t
*)new_completion
;
3093 static struct utsname names
;
3094 static char buf
[100];
3095 const char*hostname
;
3096 extern struct host host
;
3098 hostname
= host
.name
;
3102 if (!names
.nodename
[0])
3104 hostname
= names
.nodename
;
3107 snprintf (buf
, sizeof buf
, cmd_prompt (vty
->node
), hostname
);
3113 vtysh_init_vty (void)
3115 /* Make vty structure. */
3117 vty
->type
= VTY_SHELL
;
3118 vty
->node
= VIEW_NODE
;
3120 /* Initialize commands. */
3123 /* Install nodes. */
3124 install_node (&bgp_node
, NULL
);
3125 install_node (&rip_node
, NULL
);
3126 install_node (&interface_node
, NULL
);
3127 install_node (&link_params_node
, NULL
);
3128 install_node (&ns_node
, NULL
);
3129 install_node (&vrf_node
, NULL
);
3130 install_node (&rmap_node
, NULL
);
3131 install_node (&zebra_node
, NULL
);
3132 install_node (&bgp_vpnv4_node
, NULL
);
3133 install_node (&bgp_vpnv6_node
, NULL
);
3134 install_node (&bgp_encap_node
, NULL
);
3135 install_node (&bgp_encapv6_node
, NULL
);
3136 install_node (&bgp_ipv4_node
, NULL
);
3137 install_node (&bgp_ipv4m_node
, NULL
);
3138 install_node (&bgp_ipv6_node
, NULL
);
3139 install_node (&bgp_ipv6m_node
, NULL
);
3140 install_node (&bgp_vnc_defaults_node
, NULL
);
3141 install_node (&bgp_vnc_nve_group_node
, NULL
);
3142 install_node (&bgp_vnc_l2_group_node
, NULL
);
3143 install_node (&ospf_node
, NULL
);
3144 install_node (&ripng_node
, NULL
);
3145 install_node (&ospf6_node
, NULL
);
3146 install_node (&ldp_node
, NULL
);
3147 install_node (&ldp_ipv4_node
, NULL
);
3148 install_node (&ldp_ipv6_node
, NULL
);
3149 install_node (&ldp_ipv4_iface_node
, NULL
);
3150 install_node (&ldp_ipv6_iface_node
, NULL
);
3151 install_node (&ldp_l2vpn_node
, NULL
);
3152 install_node (&ldp_pseudowire_node
, NULL
);
3153 install_node (&keychain_node
, NULL
);
3154 install_node (&keychain_key_node
, NULL
);
3155 install_node (&isis_node
, NULL
);
3156 install_node (&vty_node
, NULL
);
3158 vtysh_install_default (VIEW_NODE
);
3159 vtysh_install_default (CONFIG_NODE
);
3160 vtysh_install_default (BGP_NODE
);
3161 vtysh_install_default (RIP_NODE
);
3162 vtysh_install_default (INTERFACE_NODE
);
3163 vtysh_install_default (LINK_PARAMS_NODE
);
3164 vtysh_install_default (NS_NODE
);
3165 vtysh_install_default (VRF_NODE
);
3166 vtysh_install_default (RMAP_NODE
);
3167 vtysh_install_default (ZEBRA_NODE
);
3168 vtysh_install_default (BGP_VPNV4_NODE
);
3169 vtysh_install_default (BGP_VPNV6_NODE
);
3170 vtysh_install_default (BGP_ENCAP_NODE
);
3171 vtysh_install_default (BGP_ENCAPV6_NODE
);
3172 vtysh_install_default (BGP_IPV4_NODE
);
3173 vtysh_install_default (BGP_IPV4M_NODE
);
3174 vtysh_install_default (BGP_IPV6_NODE
);
3175 vtysh_install_default (BGP_IPV6M_NODE
);
3177 vtysh_install_default (BGP_VNC_DEFAULTS_NODE
);
3178 vtysh_install_default (BGP_VNC_NVE_GROUP_NODE
);
3179 vtysh_install_default (BGP_VNC_L2_GROUP_NODE
);
3181 vtysh_install_default (OSPF_NODE
);
3182 vtysh_install_default (RIPNG_NODE
);
3183 vtysh_install_default (OSPF6_NODE
);
3184 vtysh_install_default (LDP_NODE
);
3185 vtysh_install_default (LDP_IPV4_NODE
);
3186 vtysh_install_default (LDP_IPV6_NODE
);
3187 vtysh_install_default (LDP_IPV4_IFACE_NODE
);
3188 vtysh_install_default (LDP_IPV6_IFACE_NODE
);
3189 vtysh_install_default (LDP_L2VPN_NODE
);
3190 vtysh_install_default (LDP_PSEUDOWIRE_NODE
);
3191 vtysh_install_default (ISIS_NODE
);
3192 vtysh_install_default (KEYCHAIN_NODE
);
3193 vtysh_install_default (KEYCHAIN_KEY_NODE
);
3194 vtysh_install_default (VTY_NODE
);
3196 install_element (VIEW_NODE
, &vtysh_enable_cmd
);
3197 install_element (ENABLE_NODE
, &vtysh_config_terminal_cmd
);
3198 install_element (ENABLE_NODE
, &vtysh_disable_cmd
);
3200 /* "exit" command. */
3201 install_element (VIEW_NODE
, &vtysh_exit_all_cmd
);
3202 install_element (VIEW_NODE
, &vtysh_quit_all_cmd
);
3203 install_element (CONFIG_NODE
, &vtysh_exit_all_cmd
);
3204 /* install_element (CONFIG_NODE, &vtysh_quit_all_cmd); */
3205 install_element (RIP_NODE
, &vtysh_exit_ripd_cmd
);
3206 install_element (RIP_NODE
, &vtysh_quit_ripd_cmd
);
3207 install_element (RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
3208 install_element (RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
3209 install_element (OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
3210 install_element (OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
3211 install_element (OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
3212 install_element (OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
3213 #if defined (HAVE_LDPD)
3214 install_element (LDP_NODE
, &vtysh_exit_ldpd_cmd
);
3215 install_element (LDP_NODE
, &vtysh_quit_ldpd_cmd
);
3216 install_element (LDP_IPV4_NODE
, &vtysh_exit_ldpd_cmd
);
3217 install_element (LDP_IPV4_NODE
, &vtysh_quit_ldpd_cmd
);
3218 install_element (LDP_IPV6_NODE
, &vtysh_exit_ldpd_cmd
);
3219 install_element (LDP_IPV6_NODE
, &vtysh_quit_ldpd_cmd
);
3220 install_element (LDP_IPV4_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3221 install_element (LDP_IPV4_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3222 install_element (LDP_IPV6_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3223 install_element (LDP_IPV6_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3224 install_element (LDP_L2VPN_NODE
, &vtysh_exit_ldpd_cmd
);
3225 install_element (LDP_L2VPN_NODE
, &vtysh_quit_ldpd_cmd
);
3226 install_element (LDP_PSEUDOWIRE_NODE
, &vtysh_exit_ldpd_cmd
);
3227 install_element (LDP_PSEUDOWIRE_NODE
, &vtysh_quit_ldpd_cmd
);
3229 install_element (BGP_NODE
, &vtysh_exit_bgpd_cmd
);
3230 install_element (BGP_NODE
, &vtysh_quit_bgpd_cmd
);
3231 install_element (BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
3232 install_element (BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
3233 install_element (BGP_VPNV6_NODE
, &vtysh_exit_bgpd_cmd
);
3234 install_element (BGP_VPNV6_NODE
, &vtysh_quit_bgpd_cmd
);
3235 install_element (BGP_ENCAP_NODE
, &vtysh_exit_bgpd_cmd
);
3236 install_element (BGP_ENCAP_NODE
, &vtysh_quit_bgpd_cmd
);
3237 install_element (BGP_ENCAPV6_NODE
, &vtysh_exit_bgpd_cmd
);
3238 install_element (BGP_ENCAPV6_NODE
, &vtysh_quit_bgpd_cmd
);
3239 install_element (BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
3240 install_element (BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
3241 install_element (BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
3242 install_element (BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
3243 install_element (BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
3244 install_element (BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
3245 install_element (BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
3246 install_element (BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
3247 #if defined (ENABLE_BGP_VNC)
3248 install_element (BGP_VNC_DEFAULTS_NODE
, &vtysh_exit_bgpd_cmd
);
3249 install_element (BGP_VNC_DEFAULTS_NODE
, &vtysh_quit_bgpd_cmd
);
3250 install_element (BGP_VNC_NVE_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3251 install_element (BGP_VNC_NVE_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3252 install_element (BGP_VNC_L2_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3253 install_element (BGP_VNC_L2_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3255 install_element (ISIS_NODE
, &vtysh_exit_isisd_cmd
);
3256 install_element (ISIS_NODE
, &vtysh_quit_isisd_cmd
);
3257 install_element (KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
3258 install_element (KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
3259 install_element (KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
3260 install_element (KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
3261 install_element (RMAP_NODE
, &vtysh_exit_rmap_cmd
);
3262 install_element (RMAP_NODE
, &vtysh_quit_rmap_cmd
);
3263 install_element (VTY_NODE
, &vtysh_exit_line_vty_cmd
);
3264 install_element (VTY_NODE
, &vtysh_quit_line_vty_cmd
);
3266 /* "end" command. */
3267 install_element (CONFIG_NODE
, &vtysh_end_all_cmd
);
3268 install_element (ENABLE_NODE
, &vtysh_end_all_cmd
);
3269 install_element (RIP_NODE
, &vtysh_end_all_cmd
);
3270 install_element (RIPNG_NODE
, &vtysh_end_all_cmd
);
3271 install_element (OSPF_NODE
, &vtysh_end_all_cmd
);
3272 install_element (OSPF6_NODE
, &vtysh_end_all_cmd
);
3273 install_element (LDP_NODE
, &vtysh_end_all_cmd
);
3274 install_element (LDP_IPV4_NODE
, &vtysh_end_all_cmd
);
3275 install_element (LDP_IPV6_NODE
, &vtysh_end_all_cmd
);
3276 install_element (LDP_IPV4_IFACE_NODE
, &vtysh_end_all_cmd
);
3277 install_element (LDP_IPV6_IFACE_NODE
, &vtysh_end_all_cmd
);
3278 install_element (LDP_L2VPN_NODE
, &vtysh_end_all_cmd
);
3279 install_element (LDP_PSEUDOWIRE_NODE
, &vtysh_end_all_cmd
);
3280 install_element (BGP_NODE
, &vtysh_end_all_cmd
);
3281 install_element (BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
3282 install_element (BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
3283 install_element (BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
3284 install_element (BGP_VPNV6_NODE
, &vtysh_end_all_cmd
);
3285 install_element (BGP_ENCAP_NODE
, &vtysh_end_all_cmd
);
3286 install_element (BGP_ENCAPV6_NODE
, &vtysh_end_all_cmd
);
3287 install_element (BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
3288 install_element (BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
3289 install_element (BGP_VNC_DEFAULTS_NODE
, &vtysh_end_all_cmd
);
3290 install_element (BGP_VNC_NVE_GROUP_NODE
, &vtysh_end_all_cmd
);
3291 install_element (BGP_VNC_L2_GROUP_NODE
, &vtysh_end_all_cmd
);
3292 install_element (ISIS_NODE
, &vtysh_end_all_cmd
);
3293 install_element (KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
3294 install_element (KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
3295 install_element (RMAP_NODE
, &vtysh_end_all_cmd
);
3296 install_element (VTY_NODE
, &vtysh_end_all_cmd
);
3298 install_element (INTERFACE_NODE
, &vtysh_interface_desc_cmd
);
3299 install_element (INTERFACE_NODE
, &vtysh_no_interface_desc_cmd
);
3300 install_element (INTERFACE_NODE
, &vtysh_end_all_cmd
);
3301 install_element (INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
3302 install_element (LINK_PARAMS_NODE
, &exit_link_params_cmd
);
3303 install_element (LINK_PARAMS_NODE
, &vtysh_end_all_cmd
);
3304 install_element (LINK_PARAMS_NODE
, &vtysh_exit_interface_cmd
);
3305 install_element (INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
3307 install_element (NS_NODE
, &vtysh_end_all_cmd
);
3308 install_element (NS_NODE
, &vtysh_exit_ns_cmd
);
3309 install_element (NS_NODE
, &vtysh_quit_ns_cmd
);
3311 install_element (VRF_NODE
, &vtysh_end_all_cmd
);
3312 install_element (VRF_NODE
, &vtysh_exit_vrf_cmd
);
3313 install_element (VRF_NODE
, &vtysh_quit_vrf_cmd
);
3315 install_element (CONFIG_NODE
, &router_rip_cmd
);
3316 install_element (CONFIG_NODE
, &router_ripng_cmd
);
3317 install_element (CONFIG_NODE
, &router_ospf_cmd
);
3318 install_element (CONFIG_NODE
, &router_ospf_instance_cmd
);
3319 install_element (CONFIG_NODE
, &router_ospf6_cmd
);
3320 #if defined (HAVE_LDPD)
3321 install_element (CONFIG_NODE
, &ldp_mpls_ldp_cmd
);
3322 install_element (LDP_NODE
, &ldp_address_family_ipv4_cmd
);
3323 install_element (LDP_NODE
, &ldp_address_family_ipv6_cmd
);
3324 install_element (LDP_IPV4_NODE
, &ldp_interface_ifname_cmd
);
3325 install_element (LDP_IPV6_NODE
, &ldp_interface_ifname_cmd
);
3326 install_element (CONFIG_NODE
, &ldp_l2vpn_word_type_vpls_cmd
);
3327 install_element (LDP_L2VPN_NODE
, &ldp_member_pseudowire_ifname_cmd
);
3329 install_element (CONFIG_NODE
, &router_isis_cmd
);
3330 install_element (CONFIG_NODE
, &router_bgp_cmd
);
3331 install_element (CONFIG_NODE
, &router_bgp_asn_cmd
);
3332 install_element (CONFIG_NODE
, &router_bgp_view_cmd
);
3333 install_element (BGP_NODE
, &address_family_vpnv4_cmd
);
3334 install_element (BGP_NODE
, &address_family_vpnv4_unicast_cmd
);
3335 install_element (BGP_NODE
, &address_family_vpnv6_cmd
);
3336 install_element (BGP_NODE
, &address_family_vpnv6_unicast_cmd
);
3337 install_element (BGP_NODE
, &address_family_encap_cmd
);
3338 install_element (BGP_NODE
, &address_family_encapv6_cmd
);
3339 #if defined(ENABLE_BGP_VNC)
3340 install_element (BGP_NODE
, &vnc_defaults_cmd
);
3341 install_element (BGP_NODE
, &vnc_nve_group_cmd
);
3343 install_element (BGP_NODE
, &address_family_ipv4_unicast_cmd
);
3344 install_element (BGP_NODE
, &address_family_ipv4_multicast_cmd
);
3346 install_element (BGP_NODE
, &address_family_ipv6_cmd
);
3347 install_element (BGP_NODE
, &address_family_ipv6_unicast_cmd
);
3348 install_element (BGP_NODE
, &address_family_ipv6_multicast_cmd
);
3350 install_element (BGP_VPNV4_NODE
, &exit_address_family_cmd
);
3351 install_element (BGP_VPNV6_NODE
, &exit_address_family_cmd
);
3352 install_element (BGP_ENCAP_NODE
, &exit_address_family_cmd
);
3353 install_element (BGP_ENCAPV6_NODE
, &exit_address_family_cmd
);
3354 install_element (BGP_IPV4_NODE
, &exit_address_family_cmd
);
3355 install_element (BGP_IPV4M_NODE
, &exit_address_family_cmd
);
3356 install_element (BGP_IPV6_NODE
, &exit_address_family_cmd
);
3357 install_element (BGP_IPV6M_NODE
, &exit_address_family_cmd
);
3359 install_element (BGP_VNC_DEFAULTS_NODE
, &exit_vnc_config_cmd
);
3360 install_element (BGP_VNC_NVE_GROUP_NODE
, &exit_vnc_config_cmd
);
3361 install_element (BGP_VNC_L2_GROUP_NODE
, &exit_vnc_config_cmd
);
3363 install_element (CONFIG_NODE
, &key_chain_cmd
);
3364 install_element (CONFIG_NODE
, &vtysh_route_map_cmd
);
3365 install_element (CONFIG_NODE
, &vtysh_line_vty_cmd
);
3366 install_element (KEYCHAIN_NODE
, &key_cmd
);
3367 install_element (KEYCHAIN_NODE
, &key_chain_cmd
);
3368 install_element (KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
3369 install_element (CONFIG_NODE
, &vtysh_interface_cmd
);
3370 install_element (CONFIG_NODE
, &vtysh_no_interface_cmd
);
3371 install_element (CONFIG_NODE
, &vtysh_interface_vrf_cmd
);
3372 install_element (CONFIG_NODE
, &vtysh_no_interface_vrf_cmd
);
3373 install_element (INTERFACE_NODE
, &vtysh_link_params_cmd
);
3374 install_element (ENABLE_NODE
, &vtysh_show_running_config_cmd
);
3375 install_element (ENABLE_NODE
, &vtysh_show_running_config_daemon_cmd
);
3376 install_element (ENABLE_NODE
, &vtysh_copy_runningconfig_startupconfig_cmd
);
3377 install_element (ENABLE_NODE
, &vtysh_write_file_cmd
);
3378 install_element (ENABLE_NODE
, &vtysh_write_cmd
);
3380 install_element (CONFIG_NODE
, &vtysh_vrf_cmd
);
3381 install_element (CONFIG_NODE
, &vtysh_no_vrf_cmd
);
3383 /* "write terminal" command. */
3384 install_element (ENABLE_NODE
, &vtysh_write_terminal_cmd
);
3385 install_element (ENABLE_NODE
, &vtysh_write_terminal_daemon_cmd
);
3387 install_element (CONFIG_NODE
, &vtysh_integrated_config_cmd
);
3388 install_element (CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
3390 /* "write memory" command. */
3391 install_element (ENABLE_NODE
, &vtysh_write_memory_cmd
);
3393 install_element (VIEW_NODE
, &vtysh_terminal_length_cmd
);
3394 install_element (VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
3395 install_element (VIEW_NODE
, &vtysh_show_daemons_cmd
);
3397 install_element (VIEW_NODE
, &vtysh_ping_cmd
);
3398 install_element (VIEW_NODE
, &vtysh_ping_ip_cmd
);
3399 install_element (VIEW_NODE
, &vtysh_traceroute_cmd
);
3400 install_element (VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
3401 install_element (VIEW_NODE
, &vtysh_ping6_cmd
);
3402 install_element (VIEW_NODE
, &vtysh_traceroute6_cmd
);
3403 #if defined(HAVE_SHELL_ACCESS)
3404 install_element (VIEW_NODE
, &vtysh_telnet_cmd
);
3405 install_element (VIEW_NODE
, &vtysh_telnet_port_cmd
);
3406 install_element (VIEW_NODE
, &vtysh_ssh_cmd
);
3408 #if defined(HAVE_SHELL_ACCESS)
3409 install_element (ENABLE_NODE
, &vtysh_start_shell_cmd
);
3410 install_element (ENABLE_NODE
, &vtysh_start_bash_cmd
);
3411 install_element (ENABLE_NODE
, &vtysh_start_zsh_cmd
);
3414 install_element (VIEW_NODE
, &vtysh_show_memory_cmd
);
3416 install_element (VIEW_NODE
, &vtysh_show_work_queues_cmd
);
3417 install_element (VIEW_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3419 install_element (VIEW_NODE
, &vtysh_show_thread_cmd
);
3422 install_element (VIEW_NODE
, &vtysh_show_logging_cmd
);
3423 install_element (CONFIG_NODE
, &vtysh_log_stdout_cmd
);
3424 install_element (CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
3425 install_element (CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
3426 install_element (CONFIG_NODE
, &vtysh_log_file_cmd
);
3427 install_element (CONFIG_NODE
, &vtysh_log_file_level_cmd
);
3428 install_element (CONFIG_NODE
, &no_vtysh_log_file_cmd
);
3429 install_element (CONFIG_NODE
, &no_vtysh_log_file_level_cmd
);
3430 install_element (CONFIG_NODE
, &vtysh_log_monitor_cmd
);
3431 install_element (CONFIG_NODE
, &vtysh_log_monitor_level_cmd
);
3432 install_element (CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
3433 install_element (CONFIG_NODE
, &vtysh_log_syslog_cmd
);
3434 install_element (CONFIG_NODE
, &vtysh_log_syslog_level_cmd
);
3435 install_element (CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
3436 install_element (CONFIG_NODE
, &vtysh_log_trap_cmd
);
3437 install_element (CONFIG_NODE
, &no_vtysh_log_trap_cmd
);
3438 install_element (CONFIG_NODE
, &vtysh_log_facility_cmd
);
3439 install_element (CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
3440 install_element (CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
3441 install_element (CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
3442 install_element (CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
3443 install_element (CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
3445 install_element (CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
3446 install_element (CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
3448 install_element (CONFIG_NODE
, &vtysh_password_cmd
);
3449 install_element (CONFIG_NODE
, &vtysh_password_text_cmd
);
3450 install_element (CONFIG_NODE
, &vtysh_enable_password_cmd
);
3451 install_element (CONFIG_NODE
, &vtysh_enable_password_text_cmd
);
3452 install_element (CONFIG_NODE
, &no_vtysh_enable_password_cmd
);