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 along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <sys/resource.h>
29 #include <readline/readline.h>
30 #include <readline/history.h>
40 #include "vtysh/vtysh.h"
42 #include "bgpd/bgp_vty.h"
47 DEFINE_MTYPE_STATIC(MVTYSH
, VTYSH_CMD
, "Vtysh cmd copy")
49 /* Destination for vtysh output */
55 /* VTY shell pager name. */
56 char *vtysh_pager_name
= NULL
;
58 /* VTY shell client structure. */
63 char path
[MAXPATHLEN
];
64 struct vtysh_client
*next
;
67 struct vtysh_client vtysh_client
[] = {
68 {.fd
= -1, .name
= "zebra", .flag
= VTYSH_ZEBRA
, .next
= NULL
},
69 {.fd
= -1, .name
= "ripd", .flag
= VTYSH_RIPD
, .next
= NULL
},
70 {.fd
= -1, .name
= "ripngd", .flag
= VTYSH_RIPNGD
, .next
= NULL
},
71 {.fd
= -1, .name
= "ospfd", .flag
= VTYSH_OSPFD
, .next
= NULL
},
72 {.fd
= -1, .name
= "ospf6d", .flag
= VTYSH_OSPF6D
, .next
= NULL
},
73 {.fd
= -1, .name
= "ldpd", .flag
= VTYSH_LDPD
, .next
= NULL
},
74 {.fd
= -1, .name
= "bgpd", .flag
= VTYSH_BGPD
, .next
= NULL
},
75 {.fd
= -1, .name
= "isisd", .flag
= VTYSH_ISISD
, .next
= NULL
},
76 {.fd
= -1, .name
= "pimd", .flag
= VTYSH_PIMD
, .next
= NULL
},
77 {.fd
= -1, .name
= "nhrpd", .flag
= VTYSH_NHRPD
, .next
= NULL
},
78 {.fd
= -1, .name
= "eigrpd", .flag
= VTYSH_EIGRPD
, .next
= NULL
},
79 {.fd
= -1, .name
= "babeld", .flag
= VTYSH_BABELD
, .next
= NULL
},
80 {.fd
= -1, .name
= "sharpd", .flag
= VTYSH_SHARPD
, .next
= NULL
},
81 {.fd
= -1, .name
= "watchfrr", .flag
= VTYSH_WATCHFRR
, .next
= NULL
},
82 {.fd
= -1, .name
= "pbrd", .flag
= VTYSH_PBRD
, .next
= NULL
},
85 enum vtysh_write_integrated vtysh_write_integrated
=
86 WRITE_INTEGRATED_UNSPECIFIED
;
88 static void vclient_close(struct vtysh_client
*vclient
)
90 if (vclient
->fd
>= 0) {
92 "Warning: closing connection to %s because of an I/O error!\n",
99 /* Return true if str begins with prefix, else return false */
100 static int begins_with(const char *str
, const char *prefix
)
104 size_t lenstr
= strlen(str
);
105 size_t lenprefix
= strlen(prefix
);
106 if (lenprefix
> lenstr
)
108 return strncmp(str
, prefix
, lenprefix
) == 0;
111 static int vtysh_client_run(struct vtysh_client
*vclient
, const char *line
,
112 FILE *fp
, void (*callback
)(void *, const char *),
117 char *buf
= stackbuf
;
118 size_t bufsz
= sizeof(stackbuf
);
119 char *bufvalid
, *end
= NULL
;
120 char terminator
[3] = {0, 0, 0};
125 ret
= write(vclient
->fd
, line
, strlen(line
) + 1);
132 read(vclient
->fd
, bufvalid
, buf
+ bufsz
- bufvalid
);
134 if (nread
< 0 && (errno
== EINTR
|| errno
== EAGAIN
))
138 fprintf(stderr
, "vtysh: error reading from %s: %s (%d)",
139 vclient
->name
, safe_strerror(errno
), errno
);
146 * We expect string output from daemons, so instead of looking
147 * for the full 3 null bytes of the terminator, we check for
148 * just one instead and assume it is the first byte of the
149 * terminator. The presence of the full terminator is checked
152 if (bufvalid
- buf
>= 4)
153 end
= memmem(bufvalid
- 4, 4, "\0", 1);
156 * calculate # bytes we have, up to & not including the
157 * terminator if present
159 size_t textlen
= (end
? end
: bufvalid
) - buf
;
162 /* feed line processing callback if present */
163 while (callback
&& bufvalid
> buf
&& (end
> buf
|| !end
)) {
164 textlen
= (end
? end
: bufvalid
) - buf
;
165 char *eol
= memchr(buf
, '\n', textlen
);
171 * no line break, end of input, no text left
172 * before end; nothing to write
176 /* no nl, end of input, but some text left */
178 else if (bufvalid
== buf
+ bufsz
) {
180 * no nl, no end of input, no buffer space;
186 if (buf
== stackbuf
) {
187 new = XMALLOC(MTYPE_TMP
, bufsz
);
188 memcpy(new, stackbuf
, sizeof(stackbuf
));
190 new = XREALLOC(MTYPE_TMP
, buf
, bufsz
);
192 bufvalid
= bufvalid
- buf
+ new;
194 /* if end != NULL, we won't be reading more
204 /* eol is at line end now, either \n => \0 or \0\0\0 */
205 assert(eol
&& eol
<= bufvalid
);
212 callback(cbarg
, buf
);
214 /* shift back data and adjust bufvalid */
215 memmove(buf
, eol
, bufvalid
- eol
);
216 bufvalid
-= eol
- buf
;
221 /* else if no callback, dump raw */
224 fwrite(buf
, 1, textlen
, fp
);
225 memmove(buf
, buf
+ textlen
, bufvalid
- buf
- textlen
);
231 * ----------------------------------------------------
232 * At this point `buf` should be in one of two states:
233 * - Empty (i.e. buf == bufvalid)
234 * - Contains up to 4 bytes of the terminator
235 * ----------------------------------------------------
237 assert(((buf
== bufvalid
)
238 || (bufvalid
- buf
<= 4 && buf
[0] == 0x00)));
241 /* if we have the terminator, break */
242 if (end
&& bufvalid
- buf
== 4) {
243 assert(!memcmp(buf
, terminator
, 3));
252 vclient_close(vclient
);
256 XFREE(MTYPE_TMP
, buf
);
260 static int vtysh_client_run_all(struct vtysh_client
*head_client
,
261 const char *line
, int continue_on_err
, FILE *fp
,
262 void (*callback
)(void *, const char *),
265 struct vtysh_client
*client
;
266 int rc
, rc_all
= CMD_SUCCESS
;
267 int correct_instance
= 0, wrong_instance
= 0;
269 for (client
= head_client
; client
; client
= client
->next
) {
270 rc
= vtysh_client_run(client
, line
, fp
, callback
, cbarg
);
271 if (rc
== CMD_NOT_MY_INSTANCE
) {
277 if (rc
!= CMD_SUCCESS
) {
278 if (!continue_on_err
)
283 if (wrong_instance
&& !correct_instance
&& fp
) {
285 "%% [%s]: command ignored as it targets an instance that is not running\n",
287 rc_all
= CMD_WARNING_CONFIG_FAILED
;
292 static int vtysh_client_execute(struct vtysh_client
*head_client
,
293 const char *line
, FILE *fp
)
295 return vtysh_client_run_all(head_client
, line
, 0, fp
, NULL
, NULL
);
298 static void vtysh_client_config(struct vtysh_client
*head_client
, char *line
)
300 /* watchfrr currently doesn't load any config, and has some hardcoded
301 * settings that show up in "show run". skip it here (for now at
302 * least) so we don't get that mangled up in config-write.
304 if (head_client
->flag
== VTYSH_WATCHFRR
)
307 vtysh_client_run_all(head_client
, line
, 1, NULL
,
308 vtysh_config_parse_line
, NULL
);
311 void vtysh_pager_init(void)
315 pager_defined
= getenv("VTYSH_PAGER");
318 vtysh_pager_name
= strdup(pager_defined
);
320 vtysh_pager_name
= strdup(VTYSH_PAGER
);
323 /* Command execution over the vty interface. */
324 static int vtysh_execute_func(const char *line
, int pager
)
329 const struct cmd_element
*cmd
;
333 int saved_ret
, saved_node
;
335 /* Split readline string up into the vector. */
336 vline
= cmd_make_strvec(line
);
342 if (strncmp("en", vector_slot(vline
, 0), 2) == 0) {
343 fprintf(stdout
, "%% Command not allowed: enable\n");
348 saved_ret
= ret
= cmd_execute_command(vline
, vty
, &cmd
, 1);
349 saved_node
= vty
->node
;
351 /* If command doesn't succeeded in current node, try to walk up in node
353 * Changing vty->node is enough to try it just out without actual walkup
356 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
357 && ret
!= CMD_WARNING
&& ret
!= CMD_WARNING_CONFIG_FAILED
358 && 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
368 * to move into node in the vtysh where it succeeded. */
369 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
370 || ret
== CMD_WARNING
) {
371 if ((saved_node
== BGP_VPNV4_NODE
372 || saved_node
== BGP_VPNV6_NODE
373 || saved_node
== BGP_IPV4_NODE
374 || saved_node
== BGP_IPV6_NODE
375 || saved_node
== BGP_FLOWSPECV4_NODE
376 || saved_node
== BGP_FLOWSPECV6_NODE
377 || saved_node
== BGP_IPV4M_NODE
378 || saved_node
== BGP_IPV4L_NODE
379 || saved_node
== BGP_IPV6L_NODE
380 || saved_node
== BGP_IPV6M_NODE
381 || saved_node
== BGP_EVPN_NODE
382 || saved_node
== LDP_IPV4_NODE
383 || saved_node
== LDP_IPV6_NODE
)
385 vtysh_execute("exit-address-family");
386 } else if ((saved_node
== BGP_EVPN_VNI_NODE
) && (tried
== 1)) {
387 vtysh_execute("exit-vni");
388 } else if (saved_node
== BGP_VRF_POLICY_NODE
&& (tried
== 1)) {
389 vtysh_execute("exit-vrf-policy");
390 } else if ((saved_node
== BGP_VNC_DEFAULTS_NODE
391 || saved_node
== BGP_VNC_NVE_GROUP_NODE
392 || saved_node
== BGP_VNC_L2_GROUP_NODE
)
394 vtysh_execute("exit-vnc");
395 } else if (saved_node
== VRF_NODE
&& (tried
== 1)) {
396 vtysh_execute("exit-vrf");
397 } else if ((saved_node
== KEYCHAIN_KEY_NODE
398 || saved_node
== LDP_PSEUDOWIRE_NODE
399 || saved_node
== LDP_IPV4_IFACE_NODE
400 || saved_node
== LDP_IPV6_IFACE_NODE
)
402 vtysh_execute("exit");
404 vtysh_execute("end");
405 vtysh_execute("configure terminal");
408 /* If command didn't succeed in any node, continue with return value
415 cmd_free_strvec(vline
);
420 case CMD_WARNING_CONFIG_FAILED
:
421 if (vty
->type
== VTY_FILE
)
422 fprintf(stdout
, "Warning...\n");
424 case CMD_ERR_AMBIGUOUS
:
425 fprintf(stdout
, "%% Ambiguous command: %s\n", line
);
427 case CMD_ERR_NO_MATCH
:
428 fprintf(stdout
, "%% Unknown command: %s\n", line
);
430 case CMD_ERR_INCOMPLETE
:
431 fprintf(stdout
, "%% Command incomplete: %s\n", line
);
433 case CMD_SUCCESS_DAEMON
: {
435 * FIXME: Don't open pager for exit commands. popen() causes
436 * problems if exited from vtysh at all. This hack shouldn't
437 * cause any problem but is really ugly.
440 if (pager
&& vtysh_pager_name
&& outputfile
== stdout
441 && (strncmp(line
, "exit", 4) != 0)) {
442 fp
= popen(vtysh_pager_name
, "w");
444 perror("popen failed for pager");
450 if (!strcmp(cmd
->string
, "configure terminal")) {
451 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
452 cmd_stat
= vtysh_client_execute(
453 &vtysh_client
[i
], line
, fp
);
454 if (cmd_stat
== CMD_WARNING
)
460 vline
= cmd_make_strvec(line
);
463 if (pager
&& vtysh_pager_name
&& fp
464 && fp
!= outputfile
&& closepager
) {
465 if (pclose(fp
) == -1) {
466 perror("pclose failed for pager");
473 ret
= cmd_execute_command(vline
, vty
, &cmd
, 1);
474 cmd_free_strvec(vline
);
475 if (ret
!= CMD_SUCCESS_DAEMON
)
477 } else if (cmd
->func
) {
478 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
483 cmd_stat
= CMD_SUCCESS
;
484 struct vtysh_client
*vc
;
485 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
486 if (cmd
->daemon
& vtysh_client
[i
].flag
) {
487 if (vtysh_client
[i
].fd
< 0
488 && (cmd
->daemon
== vtysh_client
[i
].flag
)) {
489 bool any_inst
= false;
490 for (vc
= &vtysh_client
[i
]; vc
;
496 "%s is not running\n",
497 vtysh_client
[i
].name
);
501 cmd_stat
= vtysh_client_execute(
502 &vtysh_client
[i
], line
, fp
);
503 if (cmd_stat
!= CMD_SUCCESS
)
507 if (cmd_stat
!= CMD_SUCCESS
)
511 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
514 if (pager
&& vtysh_pager_name
&& fp
&& closepager
&& fp
!= outputfile
) {
515 if (pclose(fp
) == -1) {
516 perror("pclose failed for pager");
523 int vtysh_execute_no_pager(const char *line
)
525 return vtysh_execute_func(line
, 0);
528 int vtysh_execute(const char *line
)
530 return vtysh_execute_func(line
, 1);
533 static char *trim(char *s
)
544 while (end
>= s
&& isspace((int)*end
))
548 while (*s
&& isspace((int)*s
))
554 int vtysh_mark_file(const char *filename
)
561 const struct cmd_element
*cmd
;
562 int saved_ret
, prev_node
;
564 char *vty_buf_copy
= NULL
;
565 char *vty_buf_trimmed
= NULL
;
567 if (strncmp("-", filename
, 1) == 0)
570 confp
= fopen(filename
, "r");
573 fprintf(stderr
, "%% Can't open config file %s due to '%s'.\n",
574 filename
, safe_strerror(errno
));
575 return (CMD_ERR_NO_FILE
);
579 vty
->wfd
= STDERR_FILENO
;
580 vty
->type
= VTY_TERM
;
581 vty
->node
= CONFIG_NODE
;
583 vtysh_execute_no_pager("enable");
584 vtysh_execute_no_pager("configure terminal");
585 vty_buf_copy
= XCALLOC(MTYPE_VTYSH_CMD
, VTY_BUFSIZ
);
587 while (fgets(vty
->buf
, VTY_BUFSIZ
, confp
)) {
590 strcpy(vty_buf_copy
, vty
->buf
);
591 vty_buf_trimmed
= trim(vty_buf_copy
);
594 case LDP_IPV4_IFACE_NODE
:
595 if (strncmp(vty_buf_copy
, " ", 3)) {
596 fprintf(outputfile
, " end\n");
597 vty
->node
= LDP_IPV4_NODE
;
600 case LDP_IPV6_IFACE_NODE
:
601 if (strncmp(vty_buf_copy
, " ", 3)) {
602 fprintf(outputfile
, " end\n");
603 vty
->node
= LDP_IPV6_NODE
;
606 case LDP_PSEUDOWIRE_NODE
:
607 if (strncmp(vty_buf_copy
, " ", 2)) {
608 fprintf(outputfile
, " end\n");
609 vty
->node
= LDP_L2VPN_NODE
;
616 if (vty_buf_trimmed
[0] == '!' || vty_buf_trimmed
[0] == '#') {
617 fprintf(outputfile
, "%s", vty
->buf
);
621 /* Split readline string up into the vector. */
622 vline
= cmd_make_strvec(vty
->buf
);
625 fprintf(outputfile
, "%s", vty
->buf
);
629 /* Ignore the "end" lines, we will generate these where
631 if (strlen(vty_buf_trimmed
) == 3
632 && strncmp("end", vty_buf_trimmed
, 3) == 0) {
633 cmd_free_strvec(vline
);
637 prev_node
= vty
->node
;
638 saved_ret
= ret
= cmd_execute_command_strict(vline
, vty
, &cmd
);
640 /* If command doesn't succeeded in current node, try to walk up
642 * Changing vty->node is enough to try it just out without
645 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
646 && ret
!= CMD_WARNING
&& ret
!= CMD_WARNING_CONFIG_FAILED
647 && vty
->node
> CONFIG_NODE
) {
648 vty
->node
= node_parent(vty
->node
);
649 ret
= cmd_execute_command_strict(vline
, vty
, &cmd
);
653 /* If command succeeded in any other node than current (tried >
655 * to move into node in the vtysh where it succeeded. */
656 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
657 || ret
== CMD_WARNING
) {
658 if ((prev_node
== BGP_VPNV4_NODE
659 || prev_node
== BGP_VPNV6_NODE
660 || prev_node
== BGP_IPV4_NODE
661 || prev_node
== BGP_IPV6_NODE
662 || prev_node
== BGP_FLOWSPECV4_NODE
663 || prev_node
== BGP_FLOWSPECV6_NODE
664 || prev_node
== BGP_IPV4L_NODE
665 || prev_node
== BGP_IPV6L_NODE
666 || prev_node
== BGP_IPV4M_NODE
667 || prev_node
== BGP_IPV6M_NODE
668 || prev_node
== BGP_EVPN_NODE
)
670 fprintf(outputfile
, "exit-address-family\n");
671 } else if ((prev_node
== BGP_EVPN_VNI_NODE
)
673 fprintf(outputfile
, "exit-vni\n");
674 } else if ((prev_node
== KEYCHAIN_KEY_NODE
)
676 fprintf(outputfile
, "exit\n");
678 fprintf(outputfile
, "end\n");
681 /* If command didn't succeed in any node, continue with return
686 vty
->node
= prev_node
;
689 cmd_free_strvec(vline
);
692 case CMD_WARNING_CONFIG_FAILED
:
693 if (vty
->type
== VTY_FILE
)
694 fprintf(stderr
, "line %d: Warning...: %s\n",
698 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
700 case CMD_ERR_AMBIGUOUS
:
701 fprintf(stderr
, "line %d: %% Ambiguous command: %s\n",
705 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
706 return CMD_ERR_AMBIGUOUS
;
707 case CMD_ERR_NO_MATCH
:
708 fprintf(stderr
, "line %d: %% Unknown command: %s\n",
712 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
713 return CMD_ERR_NO_MATCH
;
714 case CMD_ERR_INCOMPLETE
:
715 fprintf(stderr
, "line %d: %% Command incomplete: %s\n",
719 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
720 return CMD_ERR_INCOMPLETE
;
722 fprintf(stdout
, "%s", vty
->buf
);
724 case CMD_SUCCESS_DAEMON
: {
726 int cmd_stat
= CMD_SUCCESS
;
728 fprintf(outputfile
, "%s", vty
->buf
);
729 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
730 if (cmd
->daemon
& vtysh_client
[i
].flag
) {
731 cmd_stat
= vtysh_client_execute(
732 &vtysh_client
[i
], vty
->buf
,
734 if (cmd_stat
!= CMD_SUCCESS
)
738 if (cmd_stat
!= CMD_SUCCESS
)
742 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
746 /* This is the end */
747 fprintf(outputfile
, "\nend\n");
749 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
757 /* Configration make from file. */
758 int vtysh_config_from_file(struct vty
*vty
, FILE *fp
)
761 const struct cmd_element
*cmd
;
763 int retcode
= CMD_SUCCESS
;
765 while (fgets(vty
->buf
, VTY_BUFSIZ
, fp
)) {
768 ret
= command_config_read_one_line(vty
, &cmd
, 1);
772 case CMD_WARNING_CONFIG_FAILED
:
773 if (vty
->type
== VTY_FILE
)
774 fprintf(stderr
, "line %d: Warning[%d]...: %s\n",
775 lineno
, vty
->node
, vty
->buf
);
776 retcode
= ret
; /* once we have an error, we remember &
779 case CMD_ERR_AMBIGUOUS
:
781 "line %d: %% Ambiguous command[%d]: %s\n",
782 lineno
, vty
->node
, vty
->buf
);
783 retcode
= CMD_ERR_AMBIGUOUS
; /* once we have an error,
787 case CMD_ERR_NO_MATCH
:
788 fprintf(stderr
, "line %d: %% Unknown command[%d]: %s",
789 lineno
, vty
->node
, vty
->buf
);
790 retcode
= CMD_ERR_NO_MATCH
; /* once we have an error, we
791 remember & return that */
793 case CMD_ERR_INCOMPLETE
:
795 "line %d: %% Command incomplete[%d]: %s\n",
796 lineno
, vty
->node
, vty
->buf
);
797 retcode
= CMD_ERR_INCOMPLETE
; /* once we have an error,
801 case CMD_SUCCESS_DAEMON
: {
803 int cmd_stat
= CMD_SUCCESS
;
805 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
806 if (cmd
->daemon
& vtysh_client
[i
].flag
) {
807 cmd_stat
= vtysh_client_execute(
808 &vtysh_client
[i
], vty
->buf
,
811 * CMD_WARNING - Can mean that the
813 * parsed successfully but it was
815 * in a few spots. As such if we
817 * CMD_WARNING from a daemon we
819 * talking to the other daemons for the
823 if (cmd_stat
!= CMD_SUCCESS
824 && cmd_stat
!= CMD_WARNING
) {
826 "line %d: Failure to communicate[%d] to %s, line: %s\n",
828 vtysh_client
[i
].name
,
835 if (cmd_stat
!= CMD_SUCCESS
)
839 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
847 /* We don't care about the point of the cursor when '?' is typed. */
848 static int vtysh_rl_describe(void)
855 struct cmd_token
*token
;
857 vline
= cmd_make_strvec(rl_line_buffer
);
859 /* In case of '> ?'. */
861 vline
= vector_init(1);
862 vector_set(vline
, NULL
);
863 } else if (rl_end
&& isspace((int)rl_line_buffer
[rl_end
- 1]))
864 vector_set(vline
, NULL
);
866 fprintf(stdout
, "\n");
868 describe
= cmd_describe_command(vline
, vty
, &ret
);
870 /* Ambiguous and no match error. */
872 case CMD_ERR_AMBIGUOUS
:
873 cmd_free_strvec(vline
);
874 vector_free(describe
);
875 fprintf(stdout
, "%% Ambiguous command.\n");
879 case CMD_ERR_NO_MATCH
:
880 cmd_free_strvec(vline
);
882 vector_free(describe
);
883 fprintf(stdout
, "%% There is no matched command.\n");
889 /* Get width of command string. */
891 for (i
= 0; i
< vector_active(describe
); i
++)
892 if ((token
= vector_slot(describe
, i
)) != NULL
) {
893 if (token
->text
[0] == '\0')
896 int len
= strlen(token
->text
);
902 for (i
= 0; i
< vector_active(describe
); i
++)
903 if ((token
= vector_slot(describe
, i
)) != NULL
) {
905 fprintf(stdout
, " %-s\n", token
->text
);
907 fprintf(stdout
, " %-*s %s\n", width
,
908 token
->text
, token
->desc
);
910 if (IS_VARYING_TOKEN(token
->type
)) {
911 const char *ref
= vector_slot(
912 vline
, vector_active(vline
) - 1);
914 vector varcomps
= vector_init(VECTOR_MIN_SIZE
);
915 cmd_variable_complete(token
, ref
, varcomps
);
917 if (vector_active(varcomps
) > 0) {
919 rl_get_screen_size(&rows
, &cols
);
921 char *ac
= cmd_variable_comp2str(
923 fprintf(stdout
, "%s\n", ac
);
924 XFREE(MTYPE_TMP
, ac
);
927 vector_free(varcomps
);
931 cmd_free_strvec(vline
);
932 vector_free(describe
);
939 /* Result of cmd_complete_command() call will be stored here
940 * and used in new_completion() in order to put the space in
941 * correct places only. */
944 static char *command_generator(const char *text
, int state
)
947 static char **matched
= NULL
;
948 static int index
= 0;
954 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
957 vline
= cmd_make_strvec(rl_line_buffer
);
961 if (rl_end
&& isspace((int)rl_line_buffer
[rl_end
- 1]))
962 vector_set(vline
, NULL
);
964 matched
= cmd_complete_command(vline
, vty
, &complete_status
);
965 cmd_free_strvec(vline
);
968 if (matched
&& matched
[index
])
969 /* this is free()'d by readline, but we leak 1 count of
970 * MTYPE_COMPLETION */
971 return matched
[index
++];
973 XFREE(MTYPE_TMP
, matched
);
979 static char **new_completion(char *text
, int start
, int end
)
983 matches
= rl_completion_matches(text
, command_generator
);
987 if (complete_status
!= CMD_COMPLETE_FULL_MATCH
)
988 /* only append a space on full match */
989 rl_completion_append_character
= '\0';
995 /* Vty node structures. */
996 static struct cmd_node bgp_node
= {
997 BGP_NODE
, "%s(config-router)# ",
1000 static struct cmd_node rip_node
= {
1001 RIP_NODE
, "%s(config-router)# ",
1004 static struct cmd_node isis_node
= {
1005 ISIS_NODE
, "%s(config-router)# ",
1008 static struct cmd_node interface_node
= {
1009 INTERFACE_NODE
, "%s(config-if)# ",
1012 static struct cmd_node pw_node
= {
1013 PW_NODE
, "%s(config-pw)# ",
1016 static struct cmd_node logicalrouter_node
= {
1017 LOGICALROUTER_NODE
, "%s(config-logical-router)# ",
1020 static struct cmd_node vrf_node
= {
1021 VRF_NODE
, "%s(config-vrf)# ",
1024 static struct cmd_node nh_group_node
= {
1026 "%s(config-nh-group)# ",
1029 static struct cmd_node rmap_node
= {RMAP_NODE
, "%s(config-route-map)# "};
1031 static struct cmd_node pbr_map_node
= {PBRMAP_NODE
, "%s(config-pbr-map)# "};
1033 static struct cmd_node zebra_node
= {ZEBRA_NODE
, "%s(config-router)# "};
1035 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
1036 "%s(config-router-af)# "};
1038 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
1039 "%s(config-router-af)# "};
1041 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
1042 "%s(config-router-af)# "};
1044 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
1045 "%s(config-router-af)# "};
1047 static struct cmd_node bgp_ipv4_node
= {BGP_IPV4_NODE
,
1048 "%s(config-router-af)# "};
1050 static struct cmd_node bgp_ipv4m_node
= {BGP_IPV4M_NODE
,
1051 "%s(config-router-af)# "};
1053 static struct cmd_node bgp_ipv4l_node
= {BGP_IPV4L_NODE
,
1054 "%s(config-router-af)# "};
1056 static struct cmd_node bgp_ipv6_node
= {BGP_IPV6_NODE
,
1057 "%s(config-router-af)# "};
1059 static struct cmd_node bgp_ipv6m_node
= {BGP_IPV6M_NODE
,
1060 "%s(config-router-af)# "};
1062 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
1063 "%s(config-router-af)# "};
1065 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
1066 "%s(config-router-af-vni)# "};
1068 static struct cmd_node bgp_ipv6l_node
= {BGP_IPV6L_NODE
,
1069 "%s(config-router-af)# "};
1071 static struct cmd_node bgp_vnc_defaults_node
= {
1072 BGP_VNC_DEFAULTS_NODE
, "%s(config-router-vnc-defaults)# "};
1074 static struct cmd_node bgp_vnc_nve_group_node
= {
1075 BGP_VNC_NVE_GROUP_NODE
, "%s(config-router-vnc-nve-group)# "};
1077 static struct cmd_node bgp_vrf_policy_node
= {BGP_VRF_POLICY_NODE
,
1078 "%s(config-router-vrf-policy)# "};
1080 static struct cmd_node bgp_vnc_l2_group_node
= {
1081 BGP_VNC_L2_GROUP_NODE
, "%s(config-router-vnc-l2-group)# "};
1083 static struct cmd_node ospf_node
= {OSPF_NODE
, "%s(config-router)# "};
1085 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# "};
1087 static struct cmd_node babel_node
= {BABEL_NODE
, "%s(config-router)# "};
1089 static struct cmd_node ripng_node
= {RIPNG_NODE
, "%s(config-router)# "};
1091 static struct cmd_node ospf6_node
= {OSPF6_NODE
, "%s(config-ospf6)# "};
1093 static struct cmd_node ldp_node
= {LDP_NODE
, "%s(config-ldp)# "};
1095 static struct cmd_node ldp_ipv4_node
= {LDP_IPV4_NODE
, "%s(config-ldp-af)# "};
1097 static struct cmd_node ldp_ipv6_node
= {LDP_IPV6_NODE
, "%s(config-ldp-af)# "};
1099 static struct cmd_node ldp_ipv4_iface_node
= {LDP_IPV4_IFACE_NODE
,
1100 "%s(config-ldp-af-if)# "};
1102 static struct cmd_node ldp_ipv6_iface_node
= {LDP_IPV6_IFACE_NODE
,
1103 "%s(config-ldp-af-if)# "};
1105 static struct cmd_node ldp_l2vpn_node
= {LDP_L2VPN_NODE
, "%s(config-l2vpn)# "};
1107 static struct cmd_node ldp_pseudowire_node
= {LDP_PSEUDOWIRE_NODE
,
1108 "%s(config-l2vpn-pw)# "};
1110 static struct cmd_node keychain_node
= {KEYCHAIN_NODE
, "%s(config-keychain)# "};
1112 static struct cmd_node keychain_key_node
= {KEYCHAIN_KEY_NODE
,
1113 "%s(config-keychain-key)# "};
1115 struct cmd_node link_params_node
= {
1116 LINK_PARAMS_NODE
, "%s(config-link-params)# ",
1119 #if defined(HAVE_RPKI)
1120 static struct cmd_node rpki_node
= {RPKI_NODE
, "%s(config-rpki)# ", 1};
1123 /* Defined in lib/vty.c */
1124 extern struct cmd_node vty_node
;
1126 /* When '^Z' is received from vty, move down to the enable mode. */
1127 static int vtysh_end(void)
1129 switch (vty
->node
) {
1132 /* Nothing to do. */
1135 vty
->node
= ENABLE_NODE
;
1141 DEFUNSH(VTYSH_REALLYALL
, vtysh_end_all
, vtysh_end_all_cmd
, "end",
1142 "End current mode and change to enable mode\n")
1147 DEFUNSH(VTYSH_BGPD
, router_bgp
, router_bgp_cmd
,
1148 "router bgp [(1-4294967295) [<view|vrf> WORD]]",
1149 ROUTER_STR BGP_STR AS_STR
1150 "BGP view\nBGP VRF\n"
1153 vty
->node
= BGP_NODE
;
1157 DEFUNSH(VTYSH_BGPD
, address_family_vpnv4
, address_family_vpnv4_cmd
,
1158 "address-family vpnv4 [unicast]",
1159 "Enter Address Family command mode\n"
1161 "Address Family modifier\n")
1163 vty
->node
= BGP_VPNV4_NODE
;
1167 DEFUNSH(VTYSH_BGPD
, address_family_vpnv6
, address_family_vpnv6_cmd
,
1168 "address-family vpnv6 [unicast]",
1169 "Enter Address Family command mode\n"
1171 "Address Family modifier\n")
1173 vty
->node
= BGP_VPNV6_NODE
;
1177 DEFUNSH(VTYSH_BGPD
, address_family_ipv4
, address_family_ipv4_cmd
,
1178 "address-family ipv4 [unicast]",
1179 "Enter Address Family command mode\n"
1181 "Address Family Modifier\n")
1183 vty
->node
= BGP_IPV4_NODE
;
1187 DEFUNSH(VTYSH_BGPD
, address_family_flowspecv4
, address_family_flowspecv4_cmd
,
1188 "address-family ipv4 flowspec",
1189 "Enter Address Family command mode\n"
1191 "Address Family Modifier\n")
1193 vty
->node
= BGP_FLOWSPECV4_NODE
;
1197 DEFUNSH(VTYSH_BGPD
, address_family_flowspecv6
, address_family_flowspecv6_cmd
,
1198 "address-family ipv6 flowspec",
1199 "Enter Address Family command mode\n"
1201 "Address Family Modifier\n")
1203 vty
->node
= BGP_FLOWSPECV6_NODE
;
1207 DEFUNSH(VTYSH_BGPD
, address_family_ipv4_multicast
,
1208 address_family_ipv4_multicast_cmd
, "address-family ipv4 multicast",
1209 "Enter Address Family command mode\n"
1211 "Address Family modifier\n")
1213 vty
->node
= BGP_IPV4M_NODE
;
1217 DEFUNSH(VTYSH_BGPD
, address_family_ipv4_vpn
, address_family_ipv4_vpn_cmd
,
1218 "address-family ipv4 vpn",
1219 "Enter Address Family command mode\n"
1221 "Address Family modifier\n")
1223 vty
->node
= BGP_VPNV4_NODE
;
1227 DEFUNSH(VTYSH_BGPD
, address_family_ipv4_labeled_unicast
,
1228 address_family_ipv4_labeled_unicast_cmd
,
1229 "address-family ipv4 labeled-unicast",
1230 "Enter Address Family command mode\n"
1232 "Address Family modifier\n")
1234 vty
->node
= BGP_IPV4L_NODE
;
1238 DEFUNSH(VTYSH_BGPD
, address_family_ipv6
, address_family_ipv6_cmd
,
1239 "address-family ipv6 [unicast]",
1240 "Enter Address Family command mode\n"
1242 "Address Family modifier\n")
1244 vty
->node
= BGP_IPV6_NODE
;
1248 DEFUNSH(VTYSH_BGPD
, address_family_ipv6_multicast
,
1249 address_family_ipv6_multicast_cmd
, "address-family ipv6 multicast",
1250 "Enter Address Family command mode\n"
1252 "Address Family modifier\n")
1254 vty
->node
= BGP_IPV6M_NODE
;
1258 DEFUNSH(VTYSH_BGPD
, address_family_ipv6_vpn
, address_family_ipv6_vpn_cmd
,
1259 "address-family ipv6 vpn",
1260 "Enter Address Family command mode\n"
1262 "Address Family modifier\n")
1264 vty
->node
= BGP_VPNV6_NODE
;
1268 DEFUNSH(VTYSH_BGPD
, address_family_ipv6_labeled_unicast
,
1269 address_family_ipv6_labeled_unicast_cmd
,
1270 "address-family ipv6 labeled-unicast",
1271 "Enter Address Family command mode\n"
1273 "Address Family modifier\n")
1275 vty
->node
= BGP_IPV6L_NODE
;
1279 #if defined(HAVE_RPKI)
1284 "Enable rpki and enter rpki configuration mode\n")
1286 vty
->node
= RPKI_NODE
;
1294 "Exit current mode and down to previous mode\n")
1296 vty
->node
= CONFIG_NODE
;
1304 "Exit current mode and down to previous mode\n")
1306 return rpki_exit(self
, vty
, argc
, argv
);
1310 DEFUNSH(VTYSH_BGPD
, address_family_evpn
, address_family_evpn_cmd
,
1311 "address-family <l2vpn evpn>",
1312 "Enter Address Family command mode\n"
1314 "Address Family modifier\n")
1316 vty
->node
= BGP_EVPN_NODE
;
1320 #if defined(HAVE_CUMULUS)
1321 DEFUNSH_HIDDEN(VTYSH_BGPD
, address_family_evpn2
, address_family_evpn2_cmd
,
1322 "address-family evpn",
1323 "Enter Address Family command mode\n"
1324 "EVPN Address family\n")
1326 vty
->node
= BGP_EVPN_NODE
;
1331 DEFUNSH(VTYSH_BGPD
, bgp_evpn_vni
, bgp_evpn_vni_cmd
, "vni (1-16777215)",
1332 "VXLAN Network Identifier\n"
1335 vty
->node
= BGP_EVPN_VNI_NODE
;
1339 #if defined(ENABLE_BGP_VNC)
1340 DEFUNSH(VTYSH_BGPD
, vnc_defaults
, vnc_defaults_cmd
, "vnc defaults",
1341 "VNC/RFP related configuration\n"
1342 "Configure default NVE group\n")
1344 vty
->node
= BGP_VNC_DEFAULTS_NODE
;
1348 DEFUNSH(VTYSH_BGPD
, vnc_nve_group
, vnc_nve_group_cmd
, "vnc nve-group NAME",
1349 "VNC/RFP related configuration\n"
1350 "Configure a NVE group\n"
1353 vty
->node
= BGP_VNC_NVE_GROUP_NODE
;
1357 DEFUNSH(VTYSH_BGPD
, vnc_vrf_policy
, vnc_vrf_policy_cmd
, "vrf-policy NAME",
1358 "Configure a VRF policy group\n"
1361 vty
->node
= BGP_VRF_POLICY_NODE
;
1365 DEFUNSH(VTYSH_BGPD
, vnc_l2_group
, vnc_l2_group_cmd
, "vnc l2-group NAME",
1366 "VNC/RFP related configuration\n"
1367 "Configure a L2 group\n"
1370 vty
->node
= BGP_VNC_L2_GROUP_NODE
;
1375 DEFUNSH(VTYSH_RIPD
, key_chain
, key_chain_cmd
, "key chain WORD",
1376 "Authentication key management\n"
1377 "Key-chain management\n"
1380 vty
->node
= KEYCHAIN_NODE
;
1384 DEFUNSH(VTYSH_RIPD
, key
, key_cmd
, "key (0-2147483647)",
1386 "Key identifier number\n")
1388 vty
->node
= KEYCHAIN_KEY_NODE
;
1392 DEFUNSH(VTYSH_RIPD
, router_rip
, router_rip_cmd
, "router rip",
1395 vty
->node
= RIP_NODE
;
1399 DEFUNSH(VTYSH_RIPNGD
, router_ripng
, router_ripng_cmd
, "router ripng",
1400 ROUTER_STR
"RIPng\n")
1402 vty
->node
= RIPNG_NODE
;
1406 DEFUNSH(VTYSH_OSPFD
, router_ospf
, router_ospf_cmd
,
1407 "router ospf [(1-65535)] [vrf NAME]",
1408 "Enable a routing process\n"
1409 "Start OSPF configuration\n"
1413 vty
->node
= OSPF_NODE
;
1417 DEFUNSH(VTYSH_EIGRPD
, router_eigrp
, router_eigrp_cmd
, "router eigrp (1-65535)",
1418 "Enable a routing process\n"
1419 "Start EIGRP configuration\n"
1420 "AS number to use\n")
1422 vty
->node
= EIGRP_NODE
;
1426 DEFUNSH(VTYSH_BABELD
, router_babel
, router_babel_cmd
, "router babel",
1427 "Enable a routing process\n"
1428 "Make Babel instance command\n")
1430 vty
->node
= BABEL_NODE
;
1434 DEFUNSH(VTYSH_OSPF6D
, router_ospf6
, router_ospf6_cmd
, "router ospf6",
1435 ROUTER_STR OSPF6_STR
)
1437 vty
->node
= OSPF6_NODE
;
1441 #if defined(HAVE_LDPD)
1442 DEFUNSH(VTYSH_LDPD
, ldp_mpls_ldp
, ldp_mpls_ldp_cmd
, "mpls ldp",
1443 "Global MPLS configuration subcommands\n"
1444 "Label Distribution Protocol\n")
1446 vty
->node
= LDP_NODE
;
1450 DEFUNSH(VTYSH_LDPD
, ldp_address_family_ipv4
, ldp_address_family_ipv4_cmd
,
1451 "address-family ipv4",
1452 "Configure Address Family and its parameters\n"
1455 vty
->node
= LDP_IPV4_NODE
;
1459 DEFUNSH(VTYSH_LDPD
, ldp_address_family_ipv6
, ldp_address_family_ipv6_cmd
,
1460 "address-family ipv6",
1461 "Configure Address Family and its parameters\n"
1464 vty
->node
= LDP_IPV6_NODE
;
1468 DEFUNSH(VTYSH_LDPD
, ldp_exit_address_family
, ldp_exit_address_family_cmd
,
1469 "exit-address-family", "Exit from Address Family configuration mode\n")
1471 if (vty
->node
== LDP_IPV4_NODE
|| vty
->node
== LDP_IPV6_NODE
)
1472 vty
->node
= LDP_NODE
;
1476 DEFUNSH(VTYSH_LDPD
, ldp_interface_ifname
, ldp_interface_ifname_cmd
,
1478 "Enable LDP on an interface and enter interface submode\n"
1479 "Interface's name\n")
1481 switch (vty
->node
) {
1483 vty
->node
= LDP_IPV4_IFACE_NODE
;
1486 vty
->node
= LDP_IPV6_IFACE_NODE
;
1495 DEFUNSH(VTYSH_LDPD
, ldp_l2vpn_word_type_vpls
, ldp_l2vpn_word_type_vpls_cmd
,
1496 "l2vpn WORD type vpls",
1497 "Configure l2vpn commands\n"
1500 "Virtual Private LAN Service\n")
1502 vty
->node
= LDP_L2VPN_NODE
;
1506 DEFUNSH(VTYSH_LDPD
, ldp_member_pseudowire_ifname
,
1507 ldp_member_pseudowire_ifname_cmd
, "member pseudowire IFNAME",
1508 "L2VPN member configuration\n"
1509 "Pseudowire interface\n"
1510 "Interface's name\n")
1512 vty
->node
= LDP_PSEUDOWIRE_NODE
;
1517 DEFUNSH(VTYSH_ISISD
, router_isis
, router_isis_cmd
, "router isis WORD",
1520 "ISO Routing area tag\n")
1522 vty
->node
= ISIS_NODE
;
1526 DEFUNSH(VTYSH_RMAP
, vtysh_route_map
, vtysh_route_map_cmd
,
1527 "route-map WORD <deny|permit> (1-65535)",
1528 "Create route-map or enter route-map command mode\n"
1530 "Route map denies set operations\n"
1531 "Route map permits set operations\n"
1532 "Sequence to insert to/delete from existing route-map entry\n")
1534 vty
->node
= RMAP_NODE
;
1538 DEFUNSH(VTYSH_PBRD
, vtysh_pbr_map
, vtysh_pbr_map_cmd
,
1539 "pbr-map NAME seq (1-1000)",
1540 "Create pbr-map or enter pbr-map command mode\n"
1541 "The name of the PBR MAP\n"
1542 "Sequence to insert to/delete from existing pbr-map entry\n"
1543 "Sequence number\n")
1545 vty
->node
= PBRMAP_NODE
;
1549 DEFSH(VTYSH_PBRD
, vtysh_no_pbr_map_cmd
, "no pbr-map WORD [seq (1-65535)]",
1552 "The name of the PBR MAP\n"
1553 "Sequence to delete from existing pbr-map entry\n"
1554 "Sequence number\n")
1556 DEFUNSH(VTYSH_ALL
, vtysh_line_vty
, vtysh_line_vty_cmd
, "line vty",
1557 "Configure a terminal line\n"
1558 "Virtual terminal\n")
1560 vty
->node
= VTY_NODE
;
1564 DEFUNSH(VTYSH_REALLYALL
, vtysh_enable
, vtysh_enable_cmd
, "enable",
1565 "Turn on privileged mode command\n")
1567 vty
->node
= ENABLE_NODE
;
1571 DEFUNSH(VTYSH_REALLYALL
, vtysh_disable
, vtysh_disable_cmd
, "disable",
1572 "Turn off privileged mode command\n")
1574 if (vty
->node
== ENABLE_NODE
)
1575 vty
->node
= VIEW_NODE
;
1579 DEFUNSH(VTYSH_REALLYALL
, vtysh_config_terminal
, vtysh_config_terminal_cmd
,
1580 "configure terminal",
1581 "Configuration from vty interface\n"
1582 "Configuration terminal\n")
1584 vty
->node
= CONFIG_NODE
;
1588 static int vtysh_exit(struct vty
*vty
)
1590 switch (vty
->node
) {
1596 vty
->node
= ENABLE_NODE
;
1598 case INTERFACE_NODE
:
1600 case LOGICALROUTER_NODE
:
1612 case LDP_L2VPN_NODE
:
1618 vtysh_execute("end");
1619 vtysh_execute("configure terminal");
1620 vty
->node
= CONFIG_NODE
;
1622 case BGP_VPNV4_NODE
:
1623 case BGP_VPNV6_NODE
:
1625 case BGP_IPV4M_NODE
:
1626 case BGP_IPV4L_NODE
:
1628 case BGP_IPV6M_NODE
:
1629 case BGP_IPV6L_NODE
:
1630 case BGP_FLOWSPECV4_NODE
:
1631 case BGP_FLOWSPECV6_NODE
:
1632 case BGP_VRF_POLICY_NODE
:
1634 case BGP_VNC_DEFAULTS_NODE
:
1635 case BGP_VNC_NVE_GROUP_NODE
:
1636 case BGP_VNC_L2_GROUP_NODE
:
1637 vty
->node
= BGP_NODE
;
1639 case BGP_EVPN_VNI_NODE
:
1640 vty
->node
= BGP_EVPN_NODE
;
1644 vty
->node
= LDP_NODE
;
1646 case LDP_IPV4_IFACE_NODE
:
1647 vty
->node
= LDP_IPV4_NODE
;
1649 case LDP_IPV6_IFACE_NODE
:
1650 vty
->node
= LDP_IPV6_NODE
;
1652 case LDP_PSEUDOWIRE_NODE
:
1653 vty
->node
= LDP_L2VPN_NODE
;
1655 case KEYCHAIN_KEY_NODE
:
1656 vty
->node
= KEYCHAIN_NODE
;
1658 case LINK_PARAMS_NODE
:
1659 vty
->node
= INTERFACE_NODE
;
1667 DEFUNSH(VTYSH_REALLYALL
, vtysh_exit_all
, vtysh_exit_all_cmd
, "exit",
1668 "Exit current mode and down to previous mode\n")
1670 return vtysh_exit(vty
);
1673 DEFUNSH(VTYSH_ALL
, vtysh_quit_all
, vtysh_quit_all_cmd
, "quit",
1674 "Exit current mode and down to previous mode\n")
1676 return vtysh_exit_all(self
, vty
, argc
, argv
);
1679 DEFUNSH(VTYSH_BGPD
, exit_address_family
, exit_address_family_cmd
,
1680 "exit-address-family", "Exit from Address Family configuration mode\n")
1682 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
1683 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
1684 || vty
->node
== BGP_VPNV6_NODE
|| vty
->node
== BGP_IPV6_NODE
1685 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_IPV6M_NODE
1686 || vty
->node
== BGP_EVPN_NODE
1687 || vty
->node
== BGP_FLOWSPECV4_NODE
1688 || vty
->node
== BGP_FLOWSPECV6_NODE
)
1689 vty
->node
= BGP_NODE
;
1693 DEFUNSH(VTYSH_BGPD
, exit_vni
, exit_vni_cmd
, "exit-vni", "Exit from VNI mode\n")
1695 if (vty
->node
== BGP_EVPN_VNI_NODE
)
1696 vty
->node
= BGP_EVPN_NODE
;
1700 DEFUNSH(VTYSH_BGPD
, exit_vnc_config
, exit_vnc_config_cmd
, "exit-vnc",
1701 "Exit from VNC configuration mode\n")
1703 if (vty
->node
== BGP_VNC_DEFAULTS_NODE
1704 || vty
->node
== BGP_VNC_NVE_GROUP_NODE
1705 || vty
->node
== BGP_VNC_L2_GROUP_NODE
)
1706 vty
->node
= BGP_NODE
;
1710 DEFUNSH(VTYSH_PIMD
|VTYSH_ZEBRA
, exit_vrf_config
, exit_vrf_config_cmd
, "exit-vrf",
1711 "Exit from VRF configuration mode\n")
1713 if (vty
->node
== VRF_NODE
)
1714 vty
->node
= CONFIG_NODE
;
1718 DEFUNSH(VTYSH_BGPD
, exit_vrf_policy
, exit_vrf_policy_cmd
, "exit-vrf-policy",
1719 "Exit from VRF policy configuration mode\n")
1721 if (vty
->node
== BGP_VRF_POLICY_NODE
)
1722 vty
->node
= BGP_NODE
;
1726 DEFUNSH(VTYSH_RIPD
, vtysh_exit_ripd
, vtysh_exit_ripd_cmd
, "exit",
1727 "Exit current mode and down to previous mode\n")
1729 return vtysh_exit(vty
);
1732 DEFUNSH(VTYSH_RIPD
, vtysh_quit_ripd
, vtysh_quit_ripd_cmd
, "quit",
1733 "Exit current mode and down to previous mode\n")
1735 return vtysh_exit_ripd(self
, vty
, argc
, argv
);
1738 DEFUNSH(VTYSH_RIPNGD
, vtysh_exit_ripngd
, vtysh_exit_ripngd_cmd
, "exit",
1739 "Exit current mode and down to previous mode\n")
1741 return vtysh_exit(vty
);
1744 DEFUNSH(VTYSH_RIPNGD
, vtysh_quit_ripngd
, vtysh_quit_ripngd_cmd
, "quit",
1745 "Exit current mode and down to previous mode\n")
1747 return vtysh_exit_ripngd(self
, vty
, argc
, argv
);
1750 DEFUNSH(VTYSH_RMAP
, vtysh_exit_rmap
, vtysh_exit_rmap_cmd
, "exit",
1751 "Exit current mode and down to previous mode\n")
1753 return vtysh_exit(vty
);
1756 DEFUNSH(VTYSH_RMAP
, vtysh_quit_rmap
, vtysh_quit_rmap_cmd
, "quit",
1757 "Exit current mode and down to previous mode\n")
1759 return vtysh_exit_rmap(self
, vty
, argc
, argv
);
1762 DEFUNSH(VTYSH_PBRD
, vtysh_exit_pbr_map
, vtysh_exit_pbr_map_cmd
, "exit",
1763 "Exit current mode and down to previous mode\n")
1765 return vtysh_exit(vty
);
1768 DEFUNSH(VTYSH_PBRD
, vtysh_quit_pbr_map
, vtysh_quit_pbr_map_cmd
, "quit",
1769 "Exit current mode and down to previous mode\n")
1771 return vtysh_exit_rmap(self
, vty
, argc
, argv
);
1774 DEFUNSH(VTYSH_BGPD
, vtysh_exit_bgpd
, vtysh_exit_bgpd_cmd
, "exit",
1775 "Exit current mode and down to previous mode\n")
1777 return vtysh_exit(vty
);
1780 DEFUNSH(VTYSH_BGPD
, vtysh_quit_bgpd
, vtysh_quit_bgpd_cmd
, "quit",
1781 "Exit current mode and down to previous mode\n")
1783 return vtysh_exit_bgpd(self
, vty
, argc
, argv
);
1786 DEFUNSH(VTYSH_OSPFD
, vtysh_exit_ospfd
, vtysh_exit_ospfd_cmd
, "exit",
1787 "Exit current mode and down to previous mode\n")
1789 return vtysh_exit(vty
);
1792 DEFUNSH(VTYSH_OSPFD
, vtysh_quit_ospfd
, vtysh_quit_ospfd_cmd
, "quit",
1793 "Exit current mode and down to previous mode\n")
1795 return vtysh_exit_ospfd(self
, vty
, argc
, argv
);
1798 DEFUNSH(VTYSH_EIGRPD
, vtysh_exit_eigrpd
, vtysh_exit_eigrpd_cmd
, "exit",
1799 "Exit current mode and down to previous mode\n")
1801 return vtysh_exit(vty
);
1804 DEFUNSH(VTYSH_EIGRPD
, vtysh_quit_eigrpd
, vtysh_quit_eigrpd_cmd
, "quit",
1805 "Exit current mode and down to previous mode\n")
1807 return vtysh_exit(vty
);
1810 DEFUNSH(VTYSH_EIGRPD
, vtysh_exit_babeld
, vtysh_exit_babeld_cmd
, "exit",
1811 "Exit current mode and down to previous mode\n")
1813 return vtysh_exit(vty
);
1816 DEFUNSH(VTYSH_BABELD
, vtysh_quit_babeld
, vtysh_quit_babeld_cmd
, "quit",
1817 "Exit current mode and down to previous mode\n")
1819 return vtysh_exit(vty
);
1822 DEFUNSH(VTYSH_OSPF6D
, vtysh_exit_ospf6d
, vtysh_exit_ospf6d_cmd
, "exit",
1823 "Exit current mode and down to previous mode\n")
1825 return vtysh_exit(vty
);
1828 DEFUNSH(VTYSH_OSPF6D
, vtysh_quit_ospf6d
, vtysh_quit_ospf6d_cmd
, "quit",
1829 "Exit current mode and down to previous mode\n")
1831 return vtysh_exit_ospf6d(self
, vty
, argc
, argv
);
1834 #if defined(HAVE_LDPD)
1835 DEFUNSH(VTYSH_LDPD
, vtysh_exit_ldpd
, vtysh_exit_ldpd_cmd
, "exit",
1836 "Exit current mode and down to previous mode\n")
1838 return vtysh_exit(vty
);
1841 ALIAS(vtysh_exit_ldpd
, vtysh_quit_ldpd_cmd
, "quit",
1842 "Exit current mode and down to previous mode\n")
1845 DEFUNSH(VTYSH_ISISD
, vtysh_exit_isisd
, vtysh_exit_isisd_cmd
, "exit",
1846 "Exit current mode and down to previous mode\n")
1848 return vtysh_exit(vty
);
1851 DEFUNSH(VTYSH_ISISD
, vtysh_quit_isisd
, vtysh_quit_isisd_cmd
, "quit",
1852 "Exit current mode and down to previous mode\n")
1854 return vtysh_exit_isisd(self
, vty
, argc
, argv
);
1857 DEFUNSH(VTYSH_ALL
, vtysh_exit_line_vty
, vtysh_exit_line_vty_cmd
, "exit",
1858 "Exit current mode and down to previous mode\n")
1860 return vtysh_exit(vty
);
1863 DEFUNSH(VTYSH_ALL
, vtysh_quit_line_vty
, vtysh_quit_line_vty_cmd
, "quit",
1864 "Exit current mode and down to previous mode\n")
1866 return vtysh_exit_line_vty(self
, vty
, argc
, argv
);
1869 DEFUNSH(VTYSH_INTERFACE
, vtysh_interface
, vtysh_interface_cmd
,
1870 "interface IFNAME [vrf NAME]",
1871 "Select an interface to configure\n"
1872 "Interface's name\n" VRF_CMD_HELP_STR
)
1874 vty
->node
= INTERFACE_NODE
;
1878 DEFUNSH(VTYSH_ZEBRA
, vtysh_pseudowire
, vtysh_pseudowire_cmd
,
1879 "pseudowire IFNAME",
1880 "Static pseudowire configuration\n"
1881 "Pseudowire name\n")
1883 vty
->node
= PW_NODE
;
1887 /* TODO Implement "no interface command in isisd. */
1888 DEFSH(VTYSH_ZEBRA
| VTYSH_RIPD
| VTYSH_RIPNGD
| VTYSH_OSPFD
| VTYSH_OSPF6D
1890 vtysh_no_interface_cmd
, "no interface IFNAME", NO_STR
1891 "Delete a pseudo interface's configuration\n"
1892 "Interface's name\n")
1894 DEFSH(VTYSH_ZEBRA
, vtysh_no_interface_vrf_cmd
, "no interface IFNAME vrf NAME",
1896 "Delete a pseudo interface's configuration\n"
1897 "Interface's name\n" VRF_CMD_HELP_STR
)
1899 DEFUNSH(VTYSH_ZEBRA
, vtysh_logicalrouter
, vtysh_logicalrouter_cmd
,
1900 "logical-router (1-65535) ns NAME",
1901 "Enable a logical-router\n"
1902 "Specify the logical-router indentifier\n"
1904 "The file name in " NS_RUN_DIR
", or a full pathname\n")
1906 vty
->node
= LOGICALROUTER_NODE
;
1910 DEFSH(VTYSH_ZEBRA
, vtysh_no_logicalrouter_cmd
,
1911 "no logical-router (1-65535) ns NAME", NO_STR
1912 "Enable a Logical-Router\n"
1913 "Specify the Logical-Router identifier\n"
1915 "The file name in " NS_RUN_DIR
", or a full pathname\n")
1917 DEFUNSH(VTYSH_PBRD
, vtysh_nexthop_group
, vtysh_nexthop_group_cmd
,
1918 "nexthop-group NAME",
1919 "Nexthop Group configuration\n"
1920 "Name of the Nexthop Group\n")
1922 vty
->node
= NH_GROUP_NODE
;
1926 DEFSH(VTYSH_PBRD
, vtysh_no_nexthop_group_cmd
, "no nexthop-group NAME",
1928 "Nexthop Group Configuration\n"
1929 "Name of the Nexthop Group\n")
1931 DEFUNSH(VTYSH_VRF
, vtysh_vrf
, vtysh_vrf_cmd
, "vrf NAME",
1932 "Select a VRF to configure\n"
1935 vty
->node
= VRF_NODE
;
1939 DEFSH(VTYSH_ZEBRA
, vtysh_no_vrf_cmd
, "no vrf NAME", NO_STR
1940 "Delete a pseudo vrf's configuration\n"
1943 DEFUNSH(VTYSH_NS
, vtysh_exit_logicalrouter
,
1944 vtysh_exit_logicalrouter_cmd
, "exit",
1945 "Exit current mode and down to previous mode\n")
1947 return vtysh_exit(vty
);
1950 DEFUNSH(VTYSH_NS
, vtysh_quit_logicalrouter
,
1951 vtysh_quit_logicalrouter_cmd
, "quit",
1952 "Exit current mode and down to previous mode\n")
1954 return vtysh_exit_logicalrouter(self
, vty
, argc
, argv
);
1957 DEFUNSH(VTYSH_VRF
, vtysh_exit_vrf
, vtysh_exit_vrf_cmd
, "exit",
1958 "Exit current mode and down to previous mode\n")
1960 return vtysh_exit(vty
);
1963 DEFUNSH(VTYSH_VRF
, vtysh_quit_vrf
, vtysh_quit_vrf_cmd
, "quit",
1964 "Exit current mode and down to previous mode\n")
1966 return vtysh_exit_vrf(self
, vty
, argc
, argv
);
1969 DEFUNSH(VTYSH_PBRD
, vtysh_exit_nexthop_group
, vtysh_exit_nexthop_group_cmd
,
1970 "exit", "Exit current mode and down to previous mode\n")
1972 return vtysh_exit(vty
);
1975 DEFUNSH(VTYSH_VRF
, vtysh_quit_nexthop_group
, vtysh_quit_nexthop_group_cmd
,
1976 "quit", "Exit current mode and down to previous mode\n")
1978 return vtysh_exit_nexthop_group(self
, vty
, argc
, argv
);
1981 /* TODO Implement interface description commands in ripngd, ospf6d
1983 DEFSH(VTYSH_ZEBRA
| VTYSH_RIPD
| VTYSH_OSPFD
| VTYSH_EIGRPD
,
1984 vtysh_interface_desc_cmd
, "description LINE...",
1985 "Interface specific description\n"
1986 "Characters describing this interface\n")
1988 DEFSH(VTYSH_ZEBRA
| VTYSH_RIPD
| VTYSH_OSPFD
| VTYSH_EIGRPD
,
1989 vtysh_no_interface_desc_cmd
, "no description",
1990 NO_STR
"Interface specific description\n")
1992 DEFUNSH(VTYSH_INTERFACE
, vtysh_exit_interface
, vtysh_exit_interface_cmd
, "exit",
1993 "Exit current mode and down to previous mode\n")
1995 return vtysh_exit(vty
);
1998 DEFUNSH(VTYSH_INTERFACE
, vtysh_quit_interface
, vtysh_quit_interface_cmd
, "quit",
1999 "Exit current mode and down to previous mode\n")
2001 return vtysh_exit_interface(self
, vty
, argc
, argv
);
2004 DEFUN (vtysh_show_thread
,
2005 vtysh_show_thread_cmd
,
2006 "show thread cpu [FILTER]",
2008 "Thread information\n"
2009 "Thread CPU usage\n"
2010 "Display filter (rwtexb)\n")
2014 int ret
= CMD_SUCCESS
;
2017 const char *filter
=
2018 argv_find(argv
, argc
, "FILTER", &idx
) ? argv
[idx
]->arg
: "";
2020 snprintf(line
, sizeof(line
), "do show thread cpu %s\n", filter
);
2021 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2022 if (vtysh_client
[i
].fd
>= 0) {
2023 fprintf(stdout
, "Thread statistics for %s:\n",
2024 vtysh_client
[i
].name
);
2025 ret
= vtysh_client_execute(&vtysh_client
[i
], line
,
2027 fprintf(stdout
, "\n");
2032 DEFUN (vtysh_show_work_queues
,
2033 vtysh_show_work_queues_cmd
,
2036 "Work Queue information\n")
2039 int ret
= CMD_SUCCESS
;
2040 char line
[] = "do show work-queues\n";
2042 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2043 if (vtysh_client
[i
].fd
>= 0) {
2044 fprintf(stdout
, "Work queue statistics for %s:\n",
2045 vtysh_client
[i
].name
);
2046 ret
= vtysh_client_execute(&vtysh_client
[i
], line
,
2048 fprintf(stdout
, "\n");
2054 DEFUN (vtysh_show_work_queues_daemon
,
2055 vtysh_show_work_queues_daemon_cmd
,
2056 "show work-queues <zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pbrd>",
2058 "Work Queue information\n"
2059 "For the zebra daemon\n"
2060 "For the rip daemon\n"
2061 "For the ripng daemon\n"
2062 "For the ospf daemon\n"
2063 "For the ospfv6 daemon\n"
2064 "For the bgp daemon\n"
2065 "For the isis daemon\n"
2066 "For the pbr daemon\n")
2068 int idx_protocol
= 2;
2070 int ret
= CMD_SUCCESS
;
2072 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
2073 if (strmatch(vtysh_client
[i
].name
, argv
[idx_protocol
]->text
))
2077 ret
= vtysh_client_execute(&vtysh_client
[i
], "show work-queues\n",
2083 DEFUNSH(VTYSH_ZEBRA
, vtysh_link_params
, vtysh_link_params_cmd
, "link-params",
2086 vty
->node
= LINK_PARAMS_NODE
;
2090 DEFUNSH(VTYSH_ZEBRA
, exit_link_params
, exit_link_params_cmd
, "exit-link-params",
2091 "Exit from Link Params configuration node\n")
2093 if (vty
->node
== LINK_PARAMS_NODE
)
2094 vty
->node
= INTERFACE_NODE
;
2098 static int show_per_daemon(const char *line
, const char *headline
)
2101 int ret
= CMD_SUCCESS
;
2103 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2104 if (vtysh_client
[i
].fd
>= 0) {
2105 fprintf(outputfile
, headline
, vtysh_client
[i
].name
);
2106 ret
= vtysh_client_execute(&vtysh_client
[i
], line
,
2108 fprintf(stdout
, "\n");
2114 DEFUNSH_HIDDEN (0x00,
2116 vtysh_debug_all_cmd
,
2120 "Toggle all debugs on or off\n")
2125 DEFUN (vtysh_show_debugging
,
2126 vtysh_show_debugging_cmd
,
2131 return show_per_daemon("do show debugging\n", "");
2134 DEFUN (vtysh_show_debugging_hashtable
,
2135 vtysh_show_debugging_hashtable_cmd
,
2136 "show debugging hashtable [statistics]",
2139 "Statistics about hash tables\n"
2140 "Statistics about hash tables\n")
2142 fprintf(stdout
, "\n");
2144 "Load factor (LF) - average number of elements across all buckets\n");
2146 "Full load factor (FLF) - average number of elements across full buckets\n\n");
2148 "Standard deviation (SD) is calculated for both the LF and FLF\n");
2150 "and indicates the typical deviation of bucket chain length\n");
2151 fprintf(stdout
, "from the value in the corresponding load factor.\n\n");
2153 return show_per_daemon("do show debugging hashtable\n",
2154 "Hashtable statistics for %s:\n");
2158 DEFUN (vtysh_show_memory
,
2159 vtysh_show_memory_cmd
,
2162 "Memory statistics\n")
2164 return show_per_daemon("show memory\n", "Memory statistics for %s:\n");
2167 DEFUN (vtysh_show_modules
,
2168 vtysh_show_modules_cmd
,
2173 return show_per_daemon("show modules\n",
2174 "Module information for %s:\n");
2177 /* Logging commands. */
2178 DEFUN (vtysh_show_logging
,
2179 vtysh_show_logging_cmd
,
2182 "Show current logging configuration\n")
2184 return show_per_daemon("do show logging\n",
2185 "Logging configuration for %s:\n");
2188 DEFUNSH(VTYSH_ALL
, vtysh_log_stdout
, vtysh_log_stdout_cmd
, "log stdout",
2190 "Set stdout logging level\n")
2195 DEFUNSH(VTYSH_ALL
, vtysh_log_stdout_level
, vtysh_log_stdout_level_cmd
,
2196 "log stdout <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2198 "Set stdout logging level\n" LOG_LEVEL_DESC
)
2203 DEFUNSH(VTYSH_ALL
, no_vtysh_log_stdout
, no_vtysh_log_stdout_cmd
,
2204 "no log stdout [LEVEL]", NO_STR
2206 "Cancel logging to stdout\n"
2212 DEFUNSH(VTYSH_ALL
, vtysh_log_file
, vtysh_log_file_cmd
, "log file FILENAME",
2215 "Logging filename\n")
2220 DEFUNSH(VTYSH_ALL
, vtysh_log_file_level
, vtysh_log_file_level_cmd
,
2221 "log file FILENAME <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2224 "Logging filename\n" LOG_LEVEL_DESC
)
2229 DEFUNSH(VTYSH_ALL
, no_vtysh_log_file
, no_vtysh_log_file_cmd
,
2230 "no log file [FILENAME [LEVEL]]", NO_STR
2232 "Cancel logging to file\n"
2233 "Logging file name\n"
2239 DEFUNSH(VTYSH_ALL
, vtysh_log_monitor
, vtysh_log_monitor_cmd
,
2240 "log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
2242 "Set terminal line (monitor) logging level\n" LOG_LEVEL_DESC
)
2247 DEFUNSH(VTYSH_ALL
, no_vtysh_log_monitor
, no_vtysh_log_monitor_cmd
,
2248 "no log monitor [LEVEL]", NO_STR
2250 "Disable terminal line (monitor) logging\n"
2256 DEFUNSH(VTYSH_ALL
, vtysh_log_syslog
, vtysh_log_syslog_cmd
,
2257 "log syslog [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
2259 "Set syslog logging level\n" LOG_LEVEL_DESC
)
2264 DEFUNSH(VTYSH_ALL
, no_vtysh_log_syslog
, no_vtysh_log_syslog_cmd
,
2265 "no log syslog [LEVEL]", NO_STR
2267 "Cancel logging to syslog\n"
2273 DEFUNSH(VTYSH_ALL
, vtysh_log_facility
, vtysh_log_facility_cmd
,
2274 "log facility <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>",
2276 "Facility parameter for syslog messages\n" LOG_FACILITY_DESC
)
2281 DEFUNSH(VTYSH_ALL
, no_vtysh_log_facility
, no_vtysh_log_facility_cmd
,
2282 "no log facility [FACILITY]", NO_STR
2284 "Reset syslog facility to default (daemon)\n"
2285 "Syslog facility\n")
2291 VTYSH_ALL
, vtysh_log_trap
, vtysh_log_trap_cmd
,
2292 "log trap <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2294 "(Deprecated) Set logging level and default for all destinations\n" LOG_LEVEL_DESC
)
2299 DEFUNSH_DEPRECATED(VTYSH_ALL
, no_vtysh_log_trap
, no_vtysh_log_trap_cmd
,
2300 "no log trap [LEVEL]", NO_STR
2302 "Permit all logging information\n"
2308 DEFUNSH(VTYSH_ALL
, vtysh_log_record_priority
, vtysh_log_record_priority_cmd
,
2309 "log record-priority",
2311 "Log the priority of the message within the message\n")
2316 DEFUNSH(VTYSH_ALL
, no_vtysh_log_record_priority
,
2317 no_vtysh_log_record_priority_cmd
, "no log record-priority", NO_STR
2319 "Do not log the priority of the message within the message\n")
2324 DEFUNSH(VTYSH_ALL
, vtysh_log_timestamp_precision
,
2325 vtysh_log_timestamp_precision_cmd
, "log timestamp precision (0-6)",
2327 "Timestamp configuration\n"
2328 "Set the timestamp precision\n"
2329 "Number of subsecond digits\n")
2334 DEFUNSH(VTYSH_ALL
, no_vtysh_log_timestamp_precision
,
2335 no_vtysh_log_timestamp_precision_cmd
, "no log timestamp precision",
2338 "Timestamp configuration\n"
2339 "Reset the timestamp precision to the default value of 0\n")
2344 DEFUNSH(VTYSH_ALL
, vtysh_service_password_encrypt
,
2345 vtysh_service_password_encrypt_cmd
, "service password-encryption",
2346 "Set up miscellaneous service\n"
2347 "Enable encrypted passwords\n")
2352 DEFUNSH(VTYSH_ALL
, no_vtysh_service_password_encrypt
,
2353 no_vtysh_service_password_encrypt_cmd
, "no service password-encryption",
2355 "Set up miscellaneous service\n"
2356 "Enable encrypted passwords\n")
2361 DEFUNSH(VTYSH_ALL
, vtysh_config_password
, vtysh_password_cmd
,
2362 "password [(8-8)] LINE",
2363 "Assign the terminal connection password\n"
2364 "Specifies a HIDDEN password will follow\n"
2365 "The password string\n")
2370 DEFUNSH(VTYSH_ALL
, vtysh_config_enable_password
, vtysh_enable_password_cmd
,
2371 "enable password [(8-8)] LINE",
2372 "Modify enable password parameters\n"
2373 "Assign the privileged level password\n"
2374 "Specifies a HIDDEN password will follow\n"
2375 "The 'enable' password string\n")
2380 DEFUNSH(VTYSH_ALL
, no_vtysh_config_enable_password
,
2381 no_vtysh_enable_password_cmd
, "no enable password", NO_STR
2382 "Modify enable password parameters\n"
2383 "Assign the privileged level password\n")
2388 DEFUN (vtysh_write_terminal
,
2389 vtysh_write_terminal_cmd
,
2390 "write terminal [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2391 "Write running configuration to memory, network, or terminal\n"
2392 "Write to terminal\n"
2393 "For the zebra daemon\n"
2394 "For the rip daemon\n"
2395 "For the ripng daemon\n"
2396 "For the ospf daemon\n"
2397 "For the ospfv6 daemon\n"
2398 "For the ldpd daemon\n"
2399 "For the bgp daemon\n"
2400 "For the isis daemon\n"
2401 "For the pim daemon\n")
2404 char line
[] = "do write terminal\n";
2405 FILE *fp
= outputfile
;
2407 if (fp
== stdout
&& vtysh_pager_name
) {
2408 fp
= popen(vtysh_pager_name
, "w");
2415 fprintf(outputfile
, "Building configuration...\n");
2416 fprintf(outputfile
, "\nCurrent configuration:\n");
2417 fprintf(outputfile
, "!\n");
2419 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2421 || (strmatch(vtysh_client
[i
].name
, argv
[2]->text
)))
2422 vtysh_client_config(&vtysh_client
[i
], line
);
2424 /* Integrate vtysh specific configuration. */
2425 vtysh_config_write();
2427 vtysh_config_dump(fp
);
2429 if (vtysh_pager_name
&& fp
&& fp
!= outputfile
) {
2431 if (pclose(fp
) == -1) {
2438 fprintf(outputfile
, "end\n");
2442 DEFUN (vtysh_show_running_config
,
2443 vtysh_show_running_config_cmd
,
2444 "show running-config [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2446 "Current operating configuration\n"
2447 "For the zebra daemon\n"
2448 "For the rip daemon\n"
2449 "For the ripng daemon\n"
2450 "For the ospf daemon\n"
2451 "For the ospfv6 daemon\n"
2452 "For the ldp daemon\n"
2453 "For the bgp daemon\n"
2454 "For the isis daemon\n"
2455 "For the pim daemon\n")
2457 return vtysh_write_terminal(self
, vty
, argc
, argv
);
2460 DEFUN (vtysh_integrated_config
,
2461 vtysh_integrated_config_cmd
,
2462 "service integrated-vtysh-config",
2463 "Set up miscellaneous service\n"
2464 "Write configuration into integrated file\n")
2466 vtysh_write_integrated
= WRITE_INTEGRATED_YES
;
2470 DEFUN (no_vtysh_integrated_config
,
2471 no_vtysh_integrated_config_cmd
,
2472 "no service integrated-vtysh-config",
2474 "Set up miscellaneous service\n"
2475 "Write configuration into integrated file\n")
2477 vtysh_write_integrated
= WRITE_INTEGRATED_NO
;
2481 static void backup_config_file(const char *fbackup
)
2483 char *integrate_sav
= NULL
;
2485 integrate_sav
= malloc(strlen(fbackup
) + strlen(CONF_BACKUP_EXT
) + 1);
2486 strcpy(integrate_sav
, fbackup
);
2487 strcat(integrate_sav
, CONF_BACKUP_EXT
);
2489 /* Move current configuration file to backup config file. */
2490 unlink(integrate_sav
);
2491 rename(fbackup
, integrate_sav
);
2492 free(integrate_sav
);
2495 int vtysh_write_config_integrated(void)
2498 char line
[] = "do write terminal\n";
2501 struct passwd
*pwentry
;
2502 struct group
*grentry
;
2508 fprintf(stdout
, "Building Configuration...\n");
2510 backup_config_file(frr_config
);
2511 fp
= fopen(frr_config
, "w");
2514 "%% Error: failed to open configuration file %s: %s\n",
2515 frr_config
, safe_strerror(errno
));
2516 return CMD_WARNING_CONFIG_FAILED
;
2520 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2521 vtysh_client_config(&vtysh_client
[i
], line
);
2523 vtysh_config_write();
2524 vtysh_config_dump(fp
);
2526 if (fchmod(fd
, CONFIGFILE_MASK
) != 0) {
2527 printf("%% Warning: can't chmod configuration file %s: %s\n",
2528 frr_config
, safe_strerror(errno
));
2533 pwentry
= getpwnam(FRR_USER
);
2535 uid
= pwentry
->pw_uid
;
2537 printf("%% Warning: could not look up user \"%s\"\n", FRR_USER
);
2542 grentry
= getgrnam(FRR_GROUP
);
2544 gid
= grentry
->gr_gid
;
2546 printf("%% Warning: could not look up group \"%s\"\n",
2552 if (!fstat(fd
, &st
)) {
2553 if (st
.st_uid
== uid
)
2555 if (st
.st_gid
== gid
)
2557 if ((uid
!= (uid_t
)-1 || gid
!= (gid_t
)-1)
2558 && fchown(fd
, uid
, gid
)) {
2559 printf("%% Warning: can't chown configuration file %s: %s\n",
2560 frr_config
, safe_strerror(errno
));
2564 printf("%% Warning: stat() failed on %s: %s\n", frr_config
,
2565 safe_strerror(errno
));
2571 printf("Integrated configuration saved to %s\n", frr_config
);
2579 static bool want_config_integrated(void)
2583 switch (vtysh_write_integrated
) {
2584 case WRITE_INTEGRATED_UNSPECIFIED
:
2585 if (stat(frr_config
, &s
) && errno
== ENOENT
)
2588 case WRITE_INTEGRATED_NO
:
2590 case WRITE_INTEGRATED_YES
:
2596 DEFUN (vtysh_write_memory
,
2597 vtysh_write_memory_cmd
,
2598 "write [<memory|file>]",
2599 "Write running configuration to memory, network, or terminal\n"
2600 "Write configuration to the file (same as write file)\n"
2601 "Write configuration to the file (same as write memory)\n")
2603 int ret
= CMD_SUCCESS
;
2604 char line
[] = "do write memory\n";
2608 "Note: this version of vtysh never writes vtysh.conf\n");
2610 /* If integrated frr.conf explicitely set. */
2611 if (want_config_integrated()) {
2612 ret
= CMD_WARNING_CONFIG_FAILED
;
2613 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2614 if (vtysh_client
[i
].flag
== VTYSH_WATCHFRR
)
2616 if (i
< array_size(vtysh_client
) && vtysh_client
[i
].fd
!= -1)
2617 ret
= vtysh_client_execute(&vtysh_client
[i
],
2618 "do write integrated",
2622 * If watchfrr returns CMD_WARNING_CONFIG_FAILED this means
2623 * that it could not write the config, but additionally
2624 * indicates that we should not try either
2626 if (ret
!= CMD_SUCCESS
&& ret
!= CMD_WARNING_CONFIG_FAILED
) {
2627 printf("\nWarning: attempting direct configuration write without "
2628 "watchfrr.\nFile permissions and ownership may be "
2629 "incorrect, or write may fail.\n\n");
2630 ret
= vtysh_write_config_integrated();
2635 fprintf(outputfile
, "Building Configuration...\n");
2637 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2638 ret
= vtysh_client_execute(&vtysh_client
[i
], line
, outputfile
);
2643 DEFUN (vtysh_copy_running_config
,
2644 vtysh_copy_running_config_cmd
,
2645 "copy running-config startup-config",
2646 "Copy from one file to another\n"
2647 "Copy from current system configuration\n"
2648 "Copy to startup configuration\n")
2650 return vtysh_write_memory(self
, vty
, argc
, argv
);
2653 DEFUN (vtysh_terminal_length
,
2654 vtysh_terminal_length_cmd
,
2655 "terminal length (0-512)",
2656 "Set terminal line parameters\n"
2657 "Set number of lines on a screen\n"
2658 "Number of lines on screen (0 for no pausing)\n")
2662 char *endptr
= NULL
;
2663 char default_pager
[10];
2665 lines
= strtol(argv
[idx_number
]->arg
, &endptr
, 10);
2666 if (lines
< 0 || lines
> 512 || *endptr
!= '\0') {
2667 fprintf(outputfile
, "length is malformed\n");
2671 if (vtysh_pager_name
) {
2672 free(vtysh_pager_name
);
2673 vtysh_pager_name
= NULL
;
2677 snprintf(default_pager
, 10, "more -%i", lines
);
2678 vtysh_pager_name
= strdup(default_pager
);
2684 DEFUN (vtysh_terminal_no_length
,
2685 vtysh_terminal_no_length_cmd
,
2686 "terminal no length",
2687 "Set terminal line parameters\n"
2689 "Set number of lines on a screen\n")
2691 if (vtysh_pager_name
) {
2692 free(vtysh_pager_name
);
2693 vtysh_pager_name
= NULL
;
2700 DEFUN (vtysh_show_daemons
,
2701 vtysh_show_daemons_cmd
,
2704 "Show list of running daemons\n")
2708 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2709 if (vtysh_client
[i
].fd
>= 0)
2710 fprintf(outputfile
, " %s", vtysh_client
[i
].name
);
2711 fprintf(outputfile
, "\n");
2716 /* Execute command in child process. */
2717 static void execute_command(const char *command
, int argc
, const char *arg1
,
2727 /* Failure of fork(). */
2728 fprintf(stderr
, "Can't fork: %s\n", safe_strerror(errno
));
2730 } else if (pid
== 0) {
2731 /* This is child process. */
2734 execlp(command
, command
, (const char *)NULL
);
2737 execlp(command
, command
, arg1
, (const char *)NULL
);
2740 execlp(command
, command
, arg1
, arg2
,
2741 (const char *)NULL
);
2745 /* When execlp suceed, this part is not executed. */
2746 fprintf(stderr
, "Can't execute %s: %s\n", command
,
2747 safe_strerror(errno
));
2750 /* This is parent. */
2752 wait4(pid
, &status
, 0, NULL
);
2760 "Send echo messages\n"
2761 "Ping destination address or hostname\n")
2765 argv_find(argv
, argc
, "WORD", &idx
);
2766 execute_command("ping", 1, argv
[idx
]->arg
, NULL
);
2770 ALIAS(vtysh_ping
, vtysh_ping_ip_cmd
, "ping ip WORD",
2771 "Send echo messages\n"
2773 "Ping destination address or hostname\n")
2775 DEFUN (vtysh_traceroute
,
2776 vtysh_traceroute_cmd
,
2778 "Trace route to destination\n"
2779 "Trace route to destination address or hostname\n")
2783 argv_find(argv
, argc
, "WORD", &idx
);
2784 execute_command("traceroute", 1, argv
[idx
]->arg
, NULL
);
2788 ALIAS(vtysh_traceroute
, vtysh_traceroute_ip_cmd
, "traceroute ip WORD",
2789 "Trace route to destination\n"
2791 "Trace route to destination address or hostname\n")
2793 DEFUN (vtysh_mtrace
,
2795 "mtrace WORD [WORD]",
2796 "Multicast trace route to multicast source\n"
2797 "Multicast trace route to multicast source address\n"
2798 "Multicast trace route for multicast group address\n")
2801 execute_command("mtracebis", 1, argv
[1]->arg
, NULL
);
2803 execute_command("mtracebis", 2, argv
[1]->arg
, argv
[2]->arg
);
2810 "Send echo messages\n"
2812 "Ping destination address or hostname\n")
2814 execute_command("ping6", 1, argv
[2]->arg
, NULL
);
2818 DEFUN (vtysh_traceroute6
,
2819 vtysh_traceroute6_cmd
,
2820 "traceroute ipv6 WORD",
2821 "Trace route to destination\n"
2823 "Trace route to destination address or hostname\n")
2825 execute_command("traceroute6", 1, argv
[2]->arg
, NULL
);
2829 #if defined(HAVE_SHELL_ACCESS)
2830 DEFUN (vtysh_telnet
,
2833 "Open a telnet connection\n"
2834 "IP address or hostname of a remote system\n")
2836 execute_command("telnet", 1, argv
[1]->arg
, NULL
);
2840 DEFUN (vtysh_telnet_port
,
2841 vtysh_telnet_port_cmd
,
2843 "Open a telnet connection\n"
2844 "IP address or hostname of a remote system\n"
2845 "TCP Port number\n")
2847 execute_command("telnet", 2, argv
[1]->arg
, argv
[2]->arg
);
2854 "Open an ssh connection\n"
2857 execute_command("ssh", 1, argv
[1]->arg
, NULL
);
2861 DEFUN (vtysh_start_shell
,
2862 vtysh_start_shell_cmd
,
2864 "Start UNIX shell\n")
2866 execute_command("sh", 0, NULL
, NULL
);
2870 DEFUN (vtysh_start_bash
,
2871 vtysh_start_bash_cmd
,
2873 "Start UNIX shell\n"
2876 execute_command("bash", 0, NULL
, NULL
);
2880 DEFUN (vtysh_start_zsh
,
2881 vtysh_start_zsh_cmd
,
2883 "Start UNIX shell\n"
2886 execute_command("zsh", 0, NULL
, NULL
);
2893 "list [permutations]",
2894 "Print command list\n"
2895 "Print all possible command permutations\n")
2897 return cmd_list_cmds(vty
, argc
== 2);
2900 DEFUN (vtysh_output_file
,
2901 vtysh_output_file_cmd
,
2903 "Direct vtysh output to file\n"
2904 "Direct vtysh output to file\n"
2905 "Path to dump output to\n")
2907 const char *path
= argv
[argc
- 1]->arg
;
2908 outputfile
= fopen(path
, "a");
2910 fprintf(stdout
, "Failed to open file '%s': %s\n", path
,
2911 safe_strerror(errno
));
2912 outputfile
= stdout
;
2917 DEFUN (no_vtysh_output_file
,
2918 no_vtysh_output_file_cmd
,
2919 "no output file [FILE]",
2921 "Direct vtysh output to file\n"
2922 "Direct vtysh output to file\n"
2923 "Path to dump output to\n")
2925 if (outputfile
!= stdout
) {
2927 outputfile
= stdout
;
2935 "Find CLI command containing text\n"
2936 "Text to search for\n")
2938 char *text
= argv_concat(argv
, argc
, 1);
2939 const struct cmd_node
*node
;
2940 const struct cmd_element
*cli
;
2943 for (unsigned int i
= 0; i
< vector_active(cmdvec
); i
++) {
2944 node
= vector_slot(cmdvec
, i
);
2947 clis
= node
->cmd_vector
;
2948 for (unsigned int j
= 0; j
< vector_active(clis
); j
++) {
2949 cli
= vector_slot(clis
, j
);
2950 if (strcasestr(cli
->string
, text
))
2951 fprintf(stdout
, " (%s) %s\n",
2952 node_names
[node
->node
], cli
->string
);
2956 XFREE(MTYPE_TMP
, text
);
2961 static void vtysh_install_default(enum node_type node
)
2963 install_element(node
, &config_list_cmd
);
2964 install_element(node
, &find_cmd
);
2965 install_element(node
, &vtysh_output_file_cmd
);
2966 install_element(node
, &no_vtysh_output_file_cmd
);
2969 /* Making connection to protocol daemon. */
2970 static int vtysh_connect(struct vtysh_client
*vclient
)
2974 struct sockaddr_un addr
;
2978 if (!vclient
->path
[0])
2979 snprintf(vclient
->path
, sizeof(vclient
->path
), "%s/%s.vty",
2980 vtydir
, vclient
->name
);
2981 path
= vclient
->path
;
2983 /* Stat socket to see if we have permission to access it. */
2984 ret
= stat(path
, &s_stat
);
2985 if (ret
< 0 && errno
!= ENOENT
) {
2986 fprintf(stderr
, "vtysh_connect(%s): stat = %s\n", path
,
2987 safe_strerror(errno
));
2992 if (!S_ISSOCK(s_stat
.st_mode
)) {
2993 fprintf(stderr
, "vtysh_connect(%s): Not a socket\n",
2999 sock
= socket(AF_UNIX
, SOCK_STREAM
, 0);
3002 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", path
,
3003 safe_strerror(errno
));
3008 memset(&addr
, 0, sizeof(struct sockaddr_un
));
3009 addr
.sun_family
= AF_UNIX
;
3010 strlcpy(addr
.sun_path
, path
, sizeof(addr
.sun_path
));
3011 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
3012 len
= addr
.sun_len
= SUN_LEN(&addr
);
3014 len
= sizeof(addr
.sun_family
) + strlen(addr
.sun_path
);
3015 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
3017 ret
= connect(sock
, (struct sockaddr
*)&addr
, len
);
3020 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", path
,
3021 safe_strerror(errno
));
3031 /* Return true if str ends with suffix, else return false */
3032 static int ends_with(const char *str
, const char *suffix
)
3034 if (!str
|| !suffix
)
3036 size_t lenstr
= strlen(str
);
3037 size_t lensuffix
= strlen(suffix
);
3038 if (lensuffix
> lenstr
)
3040 return strncmp(str
+ lenstr
- lensuffix
, suffix
, lensuffix
) == 0;
3043 static void vtysh_client_sorted_insert(struct vtysh_client
*head_client
,
3044 struct vtysh_client
*client
)
3046 struct vtysh_client
*prev_node
, *current_node
;
3048 prev_node
= head_client
;
3049 current_node
= head_client
->next
;
3050 while (current_node
) {
3051 if (strcmp(current_node
->path
, client
->path
) > 0)
3054 prev_node
= current_node
;
3055 current_node
= current_node
->next
;
3057 client
->next
= current_node
;
3058 prev_node
->next
= client
;
3061 #define MAXIMUM_INSTANCES 10
3063 static void vtysh_update_all_insances(struct vtysh_client
*head_client
)
3065 struct vtysh_client
*client
;
3067 struct dirent
*file
;
3070 if (head_client
->flag
!= VTYSH_OSPFD
)
3073 /* ls vty_sock_dir and look for all files ending in .vty */
3074 dir
= opendir(vtydir
);
3076 while ((file
= readdir(dir
)) != NULL
) {
3077 if (begins_with(file
->d_name
, "ospfd-")
3078 && ends_with(file
->d_name
, ".vty")) {
3079 if (n
== MAXIMUM_INSTANCES
) {
3081 "Parsing %s, client limit(%d) reached!\n",
3085 client
= (struct vtysh_client
*)malloc(
3086 sizeof(struct vtysh_client
));
3088 client
->name
= "ospfd";
3089 client
->flag
= VTYSH_OSPFD
;
3090 snprintf(client
->path
, sizeof(client
->path
),
3091 "%s/%s", vtydir
, file
->d_name
);
3092 client
->next
= NULL
;
3093 vtysh_client_sorted_insert(head_client
, client
);
3101 static int vtysh_connect_all_instances(struct vtysh_client
*head_client
)
3103 struct vtysh_client
*client
;
3106 vtysh_update_all_insances(head_client
);
3108 client
= head_client
->next
;
3110 if (vtysh_connect(client
) == 0)
3112 client
= client
->next
;
3118 int vtysh_connect_all(const char *daemon_name
)
3124 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
3126 || !strcmp(daemon_name
, vtysh_client
[i
].name
)) {
3128 if (vtysh_connect(&vtysh_client
[i
]) == 0)
3131 rc
+= vtysh_connect_all_instances(&vtysh_client
[i
]);
3135 fprintf(stderr
, "Error: no daemons match name %s!\n",
3140 /* To disable readline's filename completion. */
3141 static char *vtysh_completion_entry_function(const char *ignore
,
3147 void vtysh_readline_init(void)
3149 /* readline related settings. */
3151 rl_bind_key('?', (rl_command_func_t
*)vtysh_rl_describe
);
3152 rl_completion_entry_function
= vtysh_completion_entry_function
;
3153 rl_attempted_completion_function
=
3154 (rl_completion_func_t
*)new_completion
;
3157 char *vtysh_prompt(void)
3159 static char buf
[100];
3161 snprintf(buf
, sizeof buf
, cmd_prompt(vty
->node
), cmd_hostname_get());
3165 static void vtysh_ac_line(void *arg
, const char *line
)
3169 for (i
= 0; i
< vector_active(comps
); i
++)
3170 if (!strcmp(line
, (char *)vector_slot(comps
, i
)))
3172 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, line
));
3175 static void vtysh_autocomplete(vector comps
, struct cmd_token
*token
)
3180 snprintf(accmd
, sizeof(accmd
), "autocomplete %d %s %s", token
->type
,
3181 token
->text
, token
->varname
? token
->varname
: "-");
3183 for (i
= 0; i
< array_size(vtysh_client
); i
++)
3184 vtysh_client_run_all(&vtysh_client
[i
], accmd
, 1, NULL
,
3185 vtysh_ac_line
, comps
);
3188 static const struct cmd_variable_handler vtysh_var_handler
[] = {
3192 .completions
= vtysh_autocomplete
},
3193 {.completions
= NULL
}};
3197 if (outputfile
!= stdout
)
3201 void vtysh_init_vty(void)
3203 /* Make vty structure. */
3205 vty
->type
= VTY_SHELL
;
3206 vty
->node
= VIEW_NODE
;
3208 /* set default output */
3209 outputfile
= stdout
;
3211 /* Initialize commands. */
3213 cmd_variable_handler_register(vtysh_var_handler
);
3215 /* Install nodes. */
3216 install_node(&bgp_node
, NULL
);
3217 install_node(&rip_node
, NULL
);
3218 install_node(&interface_node
, NULL
);
3219 install_node(&pw_node
, NULL
);
3220 install_node(&link_params_node
, NULL
);
3221 install_node(&logicalrouter_node
, NULL
);
3222 install_node(&vrf_node
, NULL
);
3223 install_node(&nh_group_node
, NULL
);
3224 install_node(&rmap_node
, NULL
);
3225 install_node(&pbr_map_node
, NULL
);
3226 install_node(&zebra_node
, NULL
);
3227 install_node(&bgp_vpnv4_node
, NULL
);
3228 install_node(&bgp_vpnv6_node
, NULL
);
3229 install_node(&bgp_flowspecv4_node
, NULL
);
3230 install_node(&bgp_flowspecv6_node
, NULL
);
3231 install_node(&bgp_ipv4_node
, NULL
);
3232 install_node(&bgp_ipv4m_node
, NULL
);
3233 install_node(&bgp_ipv4l_node
, NULL
);
3234 install_node(&bgp_ipv6_node
, NULL
);
3235 install_node(&bgp_ipv6m_node
, NULL
);
3236 install_node(&bgp_ipv6l_node
, NULL
);
3237 install_node(&bgp_vrf_policy_node
, NULL
);
3238 install_node(&bgp_evpn_node
, NULL
);
3239 install_node(&bgp_evpn_vni_node
, NULL
);
3240 install_node(&bgp_vnc_defaults_node
, NULL
);
3241 install_node(&bgp_vnc_nve_group_node
, NULL
);
3242 install_node(&bgp_vnc_l2_group_node
, NULL
);
3243 install_node(&ospf_node
, NULL
);
3244 install_node(&eigrp_node
, NULL
);
3245 install_node(&babel_node
, NULL
);
3246 install_node(&ripng_node
, NULL
);
3247 install_node(&ospf6_node
, NULL
);
3248 install_node(&ldp_node
, NULL
);
3249 install_node(&ldp_ipv4_node
, NULL
);
3250 install_node(&ldp_ipv6_node
, NULL
);
3251 install_node(&ldp_ipv4_iface_node
, NULL
);
3252 install_node(&ldp_ipv6_iface_node
, NULL
);
3253 install_node(&ldp_l2vpn_node
, NULL
);
3254 install_node(&ldp_pseudowire_node
, NULL
);
3255 install_node(&keychain_node
, NULL
);
3256 install_node(&keychain_key_node
, NULL
);
3257 install_node(&isis_node
, NULL
);
3258 install_node(&vty_node
, NULL
);
3259 #if defined(HAVE_RPKI)
3260 install_node(&rpki_node
, NULL
);
3263 struct cmd_node
*node
;
3264 for (unsigned int i
= 0; i
< vector_active(cmdvec
); i
++) {
3265 node
= vector_slot(cmdvec
, i
);
3266 if (!node
|| node
->node
== VIEW_NODE
)
3268 vtysh_install_default(node
->node
);
3271 install_element(VIEW_NODE
, &vtysh_enable_cmd
);
3272 install_element(ENABLE_NODE
, &vtysh_config_terminal_cmd
);
3273 install_element(ENABLE_NODE
, &vtysh_disable_cmd
);
3275 /* "exit" command. */
3276 install_element(VIEW_NODE
, &vtysh_exit_all_cmd
);
3277 install_element(CONFIG_NODE
, &vtysh_exit_all_cmd
);
3278 install_element(VIEW_NODE
, &vtysh_quit_all_cmd
);
3279 install_element(CONFIG_NODE
, &vtysh_quit_all_cmd
);
3280 install_element(RIP_NODE
, &vtysh_exit_ripd_cmd
);
3281 install_element(RIP_NODE
, &vtysh_quit_ripd_cmd
);
3282 install_element(RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
3283 install_element(RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
3284 install_element(OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
3285 install_element(OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
3286 install_element(EIGRP_NODE
, &vtysh_exit_eigrpd_cmd
);
3287 install_element(EIGRP_NODE
, &vtysh_quit_eigrpd_cmd
);
3288 install_element(BABEL_NODE
, &vtysh_exit_babeld_cmd
);
3289 install_element(BABEL_NODE
, &vtysh_quit_babeld_cmd
);
3290 install_element(OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
3291 install_element(OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
3292 #if defined(HAVE_LDPD)
3293 install_element(LDP_NODE
, &vtysh_exit_ldpd_cmd
);
3294 install_element(LDP_NODE
, &vtysh_quit_ldpd_cmd
);
3295 install_element(LDP_IPV4_NODE
, &vtysh_exit_ldpd_cmd
);
3296 install_element(LDP_IPV4_NODE
, &vtysh_quit_ldpd_cmd
);
3297 install_element(LDP_IPV4_NODE
, &ldp_exit_address_family_cmd
);
3298 install_element(LDP_IPV6_NODE
, &vtysh_exit_ldpd_cmd
);
3299 install_element(LDP_IPV6_NODE
, &vtysh_quit_ldpd_cmd
);
3300 install_element(LDP_IPV6_NODE
, &ldp_exit_address_family_cmd
);
3301 install_element(LDP_IPV4_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3302 install_element(LDP_IPV4_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3303 install_element(LDP_IPV6_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3304 install_element(LDP_IPV6_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3305 install_element(LDP_L2VPN_NODE
, &vtysh_exit_ldpd_cmd
);
3306 install_element(LDP_L2VPN_NODE
, &vtysh_quit_ldpd_cmd
);
3307 install_element(LDP_PSEUDOWIRE_NODE
, &vtysh_exit_ldpd_cmd
);
3308 install_element(LDP_PSEUDOWIRE_NODE
, &vtysh_quit_ldpd_cmd
);
3310 install_element(BGP_NODE
, &vtysh_exit_bgpd_cmd
);
3311 install_element(BGP_NODE
, &vtysh_quit_bgpd_cmd
);
3312 install_element(BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
3313 install_element(BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
3314 install_element(BGP_VPNV6_NODE
, &vtysh_exit_bgpd_cmd
);
3315 install_element(BGP_VPNV6_NODE
, &vtysh_quit_bgpd_cmd
);
3316 install_element(BGP_FLOWSPECV4_NODE
, &vtysh_exit_bgpd_cmd
);
3317 install_element(BGP_FLOWSPECV4_NODE
, &vtysh_quit_bgpd_cmd
);
3318 install_element(BGP_FLOWSPECV6_NODE
, &vtysh_exit_bgpd_cmd
);
3319 install_element(BGP_FLOWSPECV6_NODE
, &vtysh_quit_bgpd_cmd
);
3320 install_element(BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
3321 install_element(BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
3322 install_element(BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
3323 install_element(BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
3324 install_element(BGP_IPV4L_NODE
, &vtysh_exit_bgpd_cmd
);
3325 install_element(BGP_IPV4L_NODE
, &vtysh_quit_bgpd_cmd
);
3326 install_element(BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
3327 install_element(BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
3328 install_element(BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
3329 install_element(BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
3330 install_element(BGP_EVPN_NODE
, &vtysh_quit_bgpd_cmd
);
3331 install_element(BGP_EVPN_NODE
, &vtysh_exit_bgpd_cmd
);
3332 install_element(BGP_EVPN_VNI_NODE
, &vtysh_exit_bgpd_cmd
);
3333 install_element(BGP_EVPN_VNI_NODE
, &vtysh_quit_bgpd_cmd
);
3334 install_element(BGP_IPV6L_NODE
, &vtysh_exit_bgpd_cmd
);
3335 install_element(BGP_IPV6L_NODE
, &vtysh_quit_bgpd_cmd
);
3336 #if defined(ENABLE_BGP_VNC)
3337 install_element(BGP_VRF_POLICY_NODE
, &vtysh_exit_bgpd_cmd
);
3338 install_element(BGP_VRF_POLICY_NODE
, &vtysh_quit_bgpd_cmd
);
3339 install_element(BGP_VNC_DEFAULTS_NODE
, &vtysh_exit_bgpd_cmd
);
3340 install_element(BGP_VNC_DEFAULTS_NODE
, &vtysh_quit_bgpd_cmd
);
3341 install_element(BGP_VNC_NVE_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3342 install_element(BGP_VNC_NVE_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3343 install_element(BGP_VNC_L2_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3344 install_element(BGP_VNC_L2_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3346 install_element(ISIS_NODE
, &vtysh_exit_isisd_cmd
);
3347 install_element(ISIS_NODE
, &vtysh_quit_isisd_cmd
);
3348 install_element(KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
3349 install_element(KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
3350 install_element(KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
3351 install_element(KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
3352 install_element(RMAP_NODE
, &vtysh_exit_rmap_cmd
);
3353 install_element(RMAP_NODE
, &vtysh_quit_rmap_cmd
);
3354 install_element(PBRMAP_NODE
, &vtysh_exit_pbr_map_cmd
);
3355 install_element(PBRMAP_NODE
, &vtysh_quit_pbr_map_cmd
);
3356 install_element(VTY_NODE
, &vtysh_exit_line_vty_cmd
);
3357 install_element(VTY_NODE
, &vtysh_quit_line_vty_cmd
);
3359 /* "end" command. */
3360 install_element(CONFIG_NODE
, &vtysh_end_all_cmd
);
3361 install_element(ENABLE_NODE
, &vtysh_end_all_cmd
);
3362 install_element(RIP_NODE
, &vtysh_end_all_cmd
);
3363 install_element(RIPNG_NODE
, &vtysh_end_all_cmd
);
3364 install_element(OSPF_NODE
, &vtysh_end_all_cmd
);
3365 install_element(EIGRP_NODE
, &vtysh_end_all_cmd
);
3366 install_element(BABEL_NODE
, &vtysh_end_all_cmd
);
3367 install_element(OSPF6_NODE
, &vtysh_end_all_cmd
);
3368 install_element(LDP_NODE
, &vtysh_end_all_cmd
);
3369 install_element(LDP_IPV4_NODE
, &vtysh_end_all_cmd
);
3370 install_element(LDP_IPV6_NODE
, &vtysh_end_all_cmd
);
3371 install_element(LDP_IPV4_IFACE_NODE
, &vtysh_end_all_cmd
);
3372 install_element(LDP_IPV6_IFACE_NODE
, &vtysh_end_all_cmd
);
3373 install_element(LDP_L2VPN_NODE
, &vtysh_end_all_cmd
);
3374 install_element(LDP_PSEUDOWIRE_NODE
, &vtysh_end_all_cmd
);
3375 install_element(BGP_NODE
, &vtysh_end_all_cmd
);
3376 install_element(BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
3377 install_element(BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
3378 install_element(BGP_IPV4L_NODE
, &vtysh_end_all_cmd
);
3379 install_element(BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
3380 install_element(BGP_VPNV6_NODE
, &vtysh_end_all_cmd
);
3381 install_element(BGP_FLOWSPECV4_NODE
, &vtysh_end_all_cmd
);
3382 install_element(BGP_FLOWSPECV6_NODE
, &vtysh_end_all_cmd
);
3383 install_element(BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
3384 install_element(BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
3385 install_element(BGP_IPV6L_NODE
, &vtysh_end_all_cmd
);
3386 install_element(BGP_VRF_POLICY_NODE
, &vtysh_end_all_cmd
);
3387 install_element(BGP_EVPN_NODE
, &vtysh_end_all_cmd
);
3388 install_element(BGP_EVPN_VNI_NODE
, &vtysh_end_all_cmd
);
3389 install_element(BGP_VNC_DEFAULTS_NODE
, &vtysh_end_all_cmd
);
3390 install_element(BGP_VNC_NVE_GROUP_NODE
, &vtysh_end_all_cmd
);
3391 install_element(BGP_VNC_L2_GROUP_NODE
, &vtysh_end_all_cmd
);
3392 install_element(ISIS_NODE
, &vtysh_end_all_cmd
);
3393 install_element(KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
3394 install_element(KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
3395 install_element(RMAP_NODE
, &vtysh_end_all_cmd
);
3396 install_element(PBRMAP_NODE
, &vtysh_end_all_cmd
);
3397 install_element(VTY_NODE
, &vtysh_end_all_cmd
);
3399 install_element(INTERFACE_NODE
, &vtysh_interface_desc_cmd
);
3400 install_element(INTERFACE_NODE
, &vtysh_no_interface_desc_cmd
);
3401 install_element(INTERFACE_NODE
, &vtysh_end_all_cmd
);
3402 install_element(INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
3403 install_element(LINK_PARAMS_NODE
, &exit_link_params_cmd
);
3404 install_element(LINK_PARAMS_NODE
, &vtysh_end_all_cmd
);
3405 install_element(LINK_PARAMS_NODE
, &vtysh_exit_interface_cmd
);
3406 install_element(INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
3408 install_element(PW_NODE
, &vtysh_end_all_cmd
);
3409 install_element(PW_NODE
, &vtysh_exit_interface_cmd
);
3410 install_element(PW_NODE
, &vtysh_quit_interface_cmd
);
3412 install_element(LOGICALROUTER_NODE
, &vtysh_end_all_cmd
);
3414 install_element(CONFIG_NODE
, &vtysh_logicalrouter_cmd
);
3415 install_element(CONFIG_NODE
, &vtysh_no_logicalrouter_cmd
);
3416 install_element(LOGICALROUTER_NODE
, &vtysh_exit_logicalrouter_cmd
);
3417 install_element(LOGICALROUTER_NODE
, &vtysh_quit_logicalrouter_cmd
);
3419 install_element(CONFIG_NODE
, &vtysh_nexthop_group_cmd
);
3420 install_element(NH_GROUP_NODE
, &vtysh_end_all_cmd
);
3421 install_element(NH_GROUP_NODE
, &vtysh_exit_nexthop_group_cmd
);
3422 install_element(NH_GROUP_NODE
, &vtysh_quit_nexthop_group_cmd
);
3424 install_element(VRF_NODE
, &vtysh_end_all_cmd
);
3425 install_element(VRF_NODE
, &vtysh_exit_vrf_cmd
);
3426 install_element(VRF_NODE
, &vtysh_quit_vrf_cmd
);
3428 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
3429 install_element(CONFIG_NODE
, &router_babel_cmd
);
3430 install_element(CONFIG_NODE
, &router_rip_cmd
);
3431 install_element(CONFIG_NODE
, &router_ripng_cmd
);
3432 install_element(CONFIG_NODE
, &router_ospf_cmd
);
3433 install_element(CONFIG_NODE
, &router_ospf6_cmd
);
3434 #if defined(HAVE_LDPD)
3435 install_element(CONFIG_NODE
, &ldp_mpls_ldp_cmd
);
3436 install_element(LDP_NODE
, &ldp_address_family_ipv4_cmd
);
3437 install_element(LDP_NODE
, &ldp_address_family_ipv6_cmd
);
3438 install_element(LDP_IPV4_NODE
, &ldp_interface_ifname_cmd
);
3439 install_element(LDP_IPV6_NODE
, &ldp_interface_ifname_cmd
);
3440 install_element(CONFIG_NODE
, &ldp_l2vpn_word_type_vpls_cmd
);
3441 install_element(LDP_L2VPN_NODE
, &ldp_member_pseudowire_ifname_cmd
);
3443 install_element(CONFIG_NODE
, &router_isis_cmd
);
3444 install_element(CONFIG_NODE
, &router_bgp_cmd
);
3445 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
3446 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
3447 #if defined(ENABLE_BGP_VNC)
3448 install_element(BGP_NODE
, &vnc_vrf_policy_cmd
);
3449 install_element(BGP_NODE
, &vnc_defaults_cmd
);
3450 install_element(BGP_NODE
, &vnc_nve_group_cmd
);
3451 install_element(BGP_NODE
, &vnc_l2_group_cmd
);
3453 install_element(BGP_NODE
, &address_family_ipv4_cmd
);
3454 install_element(BGP_NODE
, &address_family_ipv4_multicast_cmd
);
3455 install_element(BGP_NODE
, &address_family_ipv4_vpn_cmd
);
3456 install_element(BGP_NODE
, &address_family_ipv4_labeled_unicast_cmd
);
3457 install_element(BGP_NODE
, &address_family_ipv6_cmd
);
3458 install_element(BGP_NODE
, &address_family_ipv6_multicast_cmd
);
3459 install_element(BGP_NODE
, &address_family_ipv6_vpn_cmd
);
3460 install_element(BGP_NODE
, &address_family_ipv6_labeled_unicast_cmd
);
3461 install_element(BGP_NODE
, &address_family_evpn_cmd
);
3462 install_element(BGP_NODE
, &address_family_flowspecv4_cmd
);
3463 install_element(BGP_NODE
, &address_family_flowspecv6_cmd
);
3464 #if defined(HAVE_CUMULUS)
3465 install_element(BGP_NODE
, &address_family_evpn2_cmd
);
3467 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
3468 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
3469 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
3470 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
3471 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
3472 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
3473 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
3474 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
3475 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
3476 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
3477 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
3479 #if defined(HAVE_RPKI)
3480 install_element(CONFIG_NODE
, &rpki_cmd
);
3481 install_element(RPKI_NODE
, &rpki_exit_cmd
);
3482 install_element(RPKI_NODE
, &rpki_quit_cmd
);
3483 install_element(RPKI_NODE
, &vtysh_end_all_cmd
);
3487 install_element(BGP_EVPN_NODE
, &bgp_evpn_vni_cmd
);
3488 install_element(BGP_EVPN_VNI_NODE
, &exit_vni_cmd
);
3490 install_element(BGP_VRF_POLICY_NODE
, &exit_vrf_policy_cmd
);
3491 install_element(BGP_VNC_DEFAULTS_NODE
, &exit_vnc_config_cmd
);
3492 install_element(BGP_VNC_NVE_GROUP_NODE
, &exit_vnc_config_cmd
);
3493 install_element(BGP_VNC_L2_GROUP_NODE
, &exit_vnc_config_cmd
);
3495 install_element(CONFIG_NODE
, &key_chain_cmd
);
3496 install_element(CONFIG_NODE
, &vtysh_route_map_cmd
);
3497 install_element(CONFIG_NODE
, &vtysh_pbr_map_cmd
);
3498 install_element(CONFIG_NODE
, &vtysh_no_pbr_map_cmd
);
3499 install_element(CONFIG_NODE
, &vtysh_line_vty_cmd
);
3500 install_element(KEYCHAIN_NODE
, &key_cmd
);
3501 install_element(KEYCHAIN_NODE
, &key_chain_cmd
);
3502 install_element(KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
3503 install_element(CONFIG_NODE
, &vtysh_interface_cmd
);
3504 install_element(CONFIG_NODE
, &vtysh_no_interface_cmd
);
3505 install_element(CONFIG_NODE
, &vtysh_no_interface_vrf_cmd
);
3506 install_element(CONFIG_NODE
, &vtysh_pseudowire_cmd
);
3507 install_element(INTERFACE_NODE
, &vtysh_link_params_cmd
);
3508 install_element(ENABLE_NODE
, &vtysh_show_running_config_cmd
);
3509 install_element(ENABLE_NODE
, &vtysh_copy_running_config_cmd
);
3511 install_element(VRF_NODE
, &exit_vrf_config_cmd
);
3513 install_element(CONFIG_NODE
, &vtysh_vrf_cmd
);
3514 install_element(CONFIG_NODE
, &vtysh_no_vrf_cmd
);
3515 install_element(CONFIG_NODE
, &vtysh_no_nexthop_group_cmd
);
3517 /* "write terminal" command. */
3518 install_element(ENABLE_NODE
, &vtysh_write_terminal_cmd
);
3520 install_element(CONFIG_NODE
, &vtysh_integrated_config_cmd
);
3521 install_element(CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
3523 /* "write memory" command. */
3524 install_element(ENABLE_NODE
, &vtysh_write_memory_cmd
);
3526 install_element(VIEW_NODE
, &vtysh_terminal_length_cmd
);
3527 install_element(VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
3528 install_element(VIEW_NODE
, &vtysh_show_daemons_cmd
);
3530 install_element(VIEW_NODE
, &vtysh_ping_cmd
);
3531 install_element(VIEW_NODE
, &vtysh_ping_ip_cmd
);
3532 install_element(VIEW_NODE
, &vtysh_traceroute_cmd
);
3533 install_element(VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
3534 install_element(VIEW_NODE
, &vtysh_mtrace_cmd
);
3535 install_element(VIEW_NODE
, &vtysh_ping6_cmd
);
3536 install_element(VIEW_NODE
, &vtysh_traceroute6_cmd
);
3537 #if defined(HAVE_SHELL_ACCESS)
3538 install_element(VIEW_NODE
, &vtysh_telnet_cmd
);
3539 install_element(VIEW_NODE
, &vtysh_telnet_port_cmd
);
3540 install_element(VIEW_NODE
, &vtysh_ssh_cmd
);
3542 #if defined(HAVE_SHELL_ACCESS)
3543 install_element(ENABLE_NODE
, &vtysh_start_shell_cmd
);
3544 install_element(ENABLE_NODE
, &vtysh_start_bash_cmd
);
3545 install_element(ENABLE_NODE
, &vtysh_start_zsh_cmd
);
3549 install_element(VIEW_NODE
, &vtysh_show_debugging_cmd
);
3550 install_element(VIEW_NODE
, &vtysh_show_debugging_hashtable_cmd
);
3551 install_element(ENABLE_NODE
, &vtysh_debug_all_cmd
);
3552 install_element(CONFIG_NODE
, &vtysh_debug_all_cmd
);
3554 /* misc lib show commands */
3555 install_element(VIEW_NODE
, &vtysh_show_memory_cmd
);
3556 install_element(VIEW_NODE
, &vtysh_show_modules_cmd
);
3557 install_element(VIEW_NODE
, &vtysh_show_work_queues_cmd
);
3558 install_element(VIEW_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3559 install_element(VIEW_NODE
, &vtysh_show_thread_cmd
);
3562 install_element(VIEW_NODE
, &vtysh_show_logging_cmd
);
3563 install_element(CONFIG_NODE
, &vtysh_log_stdout_cmd
);
3564 install_element(CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
3565 install_element(CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
3566 install_element(CONFIG_NODE
, &vtysh_log_file_cmd
);
3567 install_element(CONFIG_NODE
, &vtysh_log_file_level_cmd
);
3568 install_element(CONFIG_NODE
, &no_vtysh_log_file_cmd
);
3569 install_element(CONFIG_NODE
, &vtysh_log_monitor_cmd
);
3570 install_element(CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
3571 install_element(CONFIG_NODE
, &vtysh_log_syslog_cmd
);
3572 install_element(CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
3573 install_element(CONFIG_NODE
, &vtysh_log_trap_cmd
);
3574 install_element(CONFIG_NODE
, &no_vtysh_log_trap_cmd
);
3575 install_element(CONFIG_NODE
, &vtysh_log_facility_cmd
);
3576 install_element(CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
3577 install_element(CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
3578 install_element(CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
3579 install_element(CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
3580 install_element(CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
3582 install_element(CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
3583 install_element(CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
3585 install_element(CONFIG_NODE
, &vtysh_password_cmd
);
3586 install_element(CONFIG_NODE
, &vtysh_enable_password_cmd
);
3587 install_element(CONFIG_NODE
, &no_vtysh_enable_password_cmd
);