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"
46 #include "command_graph.h"
48 DEFINE_MTYPE_STATIC(MVTYSH
, VTYSH_CMD
, "Vtysh cmd copy")
50 /* Destination for vtysh output */
56 /* VTY shell pager name. */
57 char *vtysh_pager_name
= NULL
;
59 /* VTY shell client structure. */
64 char path
[MAXPATHLEN
];
65 struct vtysh_client
*next
;
68 struct vtysh_client vtysh_client
[] = {
69 {.fd
= -1, .name
= "zebra", .flag
= VTYSH_ZEBRA
, .next
= NULL
},
70 {.fd
= -1, .name
= "ripd", .flag
= VTYSH_RIPD
, .next
= NULL
},
71 {.fd
= -1, .name
= "ripngd", .flag
= VTYSH_RIPNGD
, .next
= NULL
},
72 {.fd
= -1, .name
= "ospfd", .flag
= VTYSH_OSPFD
, .next
= NULL
},
73 {.fd
= -1, .name
= "ospf6d", .flag
= VTYSH_OSPF6D
, .next
= NULL
},
74 {.fd
= -1, .name
= "ldpd", .flag
= VTYSH_LDPD
, .next
= NULL
},
75 {.fd
= -1, .name
= "bgpd", .flag
= VTYSH_BGPD
, .next
= NULL
},
76 {.fd
= -1, .name
= "isisd", .flag
= VTYSH_ISISD
, .next
= NULL
},
77 {.fd
= -1, .name
= "pimd", .flag
= VTYSH_PIMD
, .next
= NULL
},
78 {.fd
= -1, .name
= "nhrpd", .flag
= VTYSH_NHRPD
, .next
= NULL
},
79 {.fd
= -1, .name
= "eigrpd", .flag
= VTYSH_EIGRPD
, .next
= NULL
},
80 {.fd
= -1, .name
= "babeld", .flag
= VTYSH_BABELD
, .next
= NULL
},
81 {.fd
= -1, .name
= "sharpd", .flag
= VTYSH_SHARPD
, .next
= NULL
},
82 {.fd
= -1, .name
= "watchfrr", .flag
= VTYSH_WATCHFRR
, .next
= NULL
},
83 {.fd
= -1, .name
= "pbrd", .flag
= VTYSH_PBRD
, .next
= NULL
},
86 enum vtysh_write_integrated vtysh_write_integrated
=
87 WRITE_INTEGRATED_UNSPECIFIED
;
89 static void vclient_close(struct vtysh_client
*vclient
)
91 if (vclient
->fd
>= 0) {
93 "Warning: closing connection to %s because of an I/O error!\n",
100 /* Return true if str begins with prefix, else return false */
101 static int begins_with(const char *str
, const char *prefix
)
105 size_t lenstr
= strlen(str
);
106 size_t lenprefix
= strlen(prefix
);
107 if (lenprefix
> lenstr
)
109 return strncmp(str
, prefix
, lenprefix
) == 0;
112 static int vtysh_client_run(struct vtysh_client
*vclient
, const char *line
,
113 FILE *fp
, void (*callback
)(void *, const char *),
118 char *buf
= stackbuf
;
119 size_t bufsz
= sizeof(stackbuf
);
120 char *bufvalid
, *end
= NULL
;
121 char terminator
[3] = {0, 0, 0};
126 ret
= write(vclient
->fd
, line
, strlen(line
) + 1);
133 read(vclient
->fd
, bufvalid
, buf
+ bufsz
- bufvalid
);
135 if (nread
< 0 && (errno
== EINTR
|| errno
== EAGAIN
))
139 fprintf(stderr
, "vtysh: error reading from %s: %s (%d)",
140 vclient
->name
, safe_strerror(errno
), errno
);
147 * We expect string output from daemons, so instead of looking
148 * for the full 3 null bytes of the terminator, we check for
149 * just one instead and assume it is the first byte of the
150 * terminator. The presence of the full terminator is checked
153 if (bufvalid
- buf
>= 4)
154 end
= memmem(bufvalid
- 4, 4, "\0", 1);
157 * calculate # bytes we have, up to & not including the
158 * terminator if present
160 size_t textlen
= (end
? end
: bufvalid
) - buf
;
163 /* feed line processing callback if present */
164 while (callback
&& bufvalid
> buf
&& (end
> buf
|| !end
)) {
165 textlen
= (end
? end
: bufvalid
) - buf
;
166 char *eol
= memchr(buf
, '\n', textlen
);
172 * no line break, end of input, no text left
173 * before end; nothing to write
177 /* no nl, end of input, but some text left */
179 else if (bufvalid
== buf
+ bufsz
) {
181 * no nl, no end of input, no buffer space;
187 if (buf
== stackbuf
) {
188 new = XMALLOC(MTYPE_TMP
, bufsz
);
189 memcpy(new, stackbuf
, sizeof(stackbuf
));
191 new = XREALLOC(MTYPE_TMP
, buf
, bufsz
);
193 bufvalid
= bufvalid
- buf
+ new;
195 /* if end != NULL, we won't be reading more
205 /* eol is at line end now, either \n => \0 or \0\0\0 */
206 assert(eol
&& eol
<= bufvalid
);
213 callback(cbarg
, buf
);
215 /* shift back data and adjust bufvalid */
216 memmove(buf
, eol
, bufvalid
- eol
);
217 bufvalid
-= eol
- buf
;
222 /* else if no callback, dump raw */
225 fwrite(buf
, 1, textlen
, fp
);
226 memmove(buf
, buf
+ textlen
, bufvalid
- buf
- textlen
);
232 * ----------------------------------------------------
233 * At this point `buf` should be in one of two states:
234 * - Empty (i.e. buf == bufvalid)
235 * - Contains up to 4 bytes of the terminator
236 * ----------------------------------------------------
238 assert(((buf
== bufvalid
)
239 || (bufvalid
- buf
<= 4 && buf
[0] == 0x00)));
242 /* if we have the terminator, break */
243 if (end
&& bufvalid
- buf
== 4) {
244 assert(!memcmp(buf
, terminator
, 3));
253 vclient_close(vclient
);
257 XFREE(MTYPE_TMP
, buf
);
261 static int vtysh_client_run_all(struct vtysh_client
*head_client
,
262 const char *line
, int continue_on_err
, FILE *fp
,
263 void (*callback
)(void *, const char *),
266 struct vtysh_client
*client
;
267 int rc
, rc_all
= CMD_SUCCESS
;
268 int correct_instance
= 0, wrong_instance
= 0;
270 for (client
= head_client
; client
; client
= client
->next
) {
271 rc
= vtysh_client_run(client
, line
, fp
, callback
, cbarg
);
272 if (rc
== CMD_NOT_MY_INSTANCE
) {
278 if (rc
!= CMD_SUCCESS
) {
279 if (!continue_on_err
)
284 if (wrong_instance
&& !correct_instance
&& fp
) {
286 "%% [%s]: command ignored as it targets an instance that is not running\n",
288 rc_all
= CMD_WARNING_CONFIG_FAILED
;
293 static int vtysh_client_execute(struct vtysh_client
*head_client
,
294 const char *line
, FILE *fp
)
296 return vtysh_client_run_all(head_client
, line
, 0, fp
, NULL
, NULL
);
299 static void vtysh_client_config(struct vtysh_client
*head_client
, char *line
)
301 /* watchfrr currently doesn't load any config, and has some hardcoded
302 * settings that show up in "show run". skip it here (for now at
303 * least) so we don't get that mangled up in config-write.
305 if (head_client
->flag
== VTYSH_WATCHFRR
)
308 vtysh_client_run_all(head_client
, line
, 1, NULL
,
309 vtysh_config_parse_line
, NULL
);
312 void vtysh_pager_init(void)
316 pager_defined
= getenv("VTYSH_PAGER");
319 vtysh_pager_name
= strdup(pager_defined
);
321 vtysh_pager_name
= strdup(VTYSH_PAGER
);
324 /* Command execution over the vty interface. */
325 static int vtysh_execute_func(const char *line
, int pager
)
330 const struct cmd_element
*cmd
;
334 int saved_ret
, saved_node
;
336 /* Split readline string up into the vector. */
337 vline
= cmd_make_strvec(line
);
343 if (strncmp("en", vector_slot(vline
, 0), 2) == 0) {
344 fprintf(stdout
, "%% Command not allowed: enable\n");
349 saved_ret
= ret
= cmd_execute_command(vline
, vty
, &cmd
, 1);
350 saved_node
= vty
->node
;
352 /* If command doesn't succeeded in current node, try to walk up in node
354 * Changing vty->node is enough to try it just out without actual walkup
357 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
358 && ret
!= CMD_WARNING
&& ret
!= CMD_WARNING_CONFIG_FAILED
359 && vty
->node
> CONFIG_NODE
) {
360 vty
->node
= node_parent(vty
->node
);
361 ret
= cmd_execute_command(vline
, vty
, &cmd
, 1);
365 vty
->node
= saved_node
;
367 /* If command succeeded in any other node than current (tried > 0) we
369 * to move into node in the vtysh where it succeeded. */
370 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
371 || ret
== CMD_WARNING
) {
372 if ((saved_node
== BGP_VPNV4_NODE
373 || saved_node
== BGP_VPNV6_NODE
374 || saved_node
== BGP_IPV4_NODE
375 || saved_node
== BGP_IPV6_NODE
376 || saved_node
== BGP_FLOWSPECV4_NODE
377 || saved_node
== BGP_FLOWSPECV6_NODE
378 || saved_node
== BGP_IPV4M_NODE
379 || saved_node
== BGP_IPV4L_NODE
380 || saved_node
== BGP_IPV6L_NODE
381 || saved_node
== BGP_IPV6M_NODE
382 || saved_node
== BGP_EVPN_NODE
383 || saved_node
== LDP_IPV4_NODE
384 || saved_node
== LDP_IPV6_NODE
)
386 vtysh_execute("exit-address-family");
387 } else if ((saved_node
== BGP_EVPN_VNI_NODE
) && (tried
== 1)) {
388 vtysh_execute("exit-vni");
389 } else if (saved_node
== BGP_VRF_POLICY_NODE
&& (tried
== 1)) {
390 vtysh_execute("exit-vrf-policy");
391 } else if ((saved_node
== BGP_VNC_DEFAULTS_NODE
392 || saved_node
== BGP_VNC_NVE_GROUP_NODE
393 || saved_node
== BGP_VNC_L2_GROUP_NODE
)
395 vtysh_execute("exit-vnc");
396 } else if (saved_node
== VRF_NODE
&& (tried
== 1)) {
397 vtysh_execute("exit-vrf");
398 } else if ((saved_node
== KEYCHAIN_KEY_NODE
399 || saved_node
== LDP_PSEUDOWIRE_NODE
400 || saved_node
== LDP_IPV4_IFACE_NODE
401 || saved_node
== LDP_IPV6_IFACE_NODE
)
403 vtysh_execute("exit");
405 vtysh_execute("end");
406 vtysh_execute("configure terminal");
409 /* If command didn't succeed in any node, continue with return value
416 cmd_free_strvec(vline
);
421 case CMD_WARNING_CONFIG_FAILED
:
422 if (vty
->type
== VTY_FILE
)
423 fprintf(stdout
, "Warning...\n");
425 case CMD_ERR_AMBIGUOUS
:
426 fprintf(stdout
, "%% Ambiguous command: %s\n", line
);
428 case CMD_ERR_NO_MATCH
:
429 fprintf(stdout
, "%% Unknown command: %s\n", line
);
431 case CMD_ERR_INCOMPLETE
:
432 fprintf(stdout
, "%% Command incomplete: %s\n", line
);
434 case CMD_SUCCESS_DAEMON
: {
436 * FIXME: Don't open pager for exit commands. popen() causes
437 * problems if exited from vtysh at all. This hack shouldn't
438 * cause any problem but is really ugly.
441 if (pager
&& vtysh_pager_name
&& outputfile
== stdout
442 && (strncmp(line
, "exit", 4) != 0)) {
443 fp
= popen(vtysh_pager_name
, "w");
445 perror("popen failed for pager");
451 if (!strcmp(cmd
->string
, "configure terminal")) {
452 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
453 cmd_stat
= vtysh_client_execute(
454 &vtysh_client
[i
], line
, fp
);
455 if (cmd_stat
== CMD_WARNING
)
461 vline
= cmd_make_strvec(line
);
464 if (pager
&& vtysh_pager_name
&& fp
465 && fp
!= outputfile
&& closepager
) {
466 if (pclose(fp
) == -1) {
467 perror("pclose failed for pager");
474 ret
= cmd_execute_command(vline
, vty
, &cmd
, 1);
475 cmd_free_strvec(vline
);
476 if (ret
!= CMD_SUCCESS_DAEMON
)
478 } else if (cmd
->func
) {
479 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
484 cmd_stat
= CMD_SUCCESS
;
485 struct vtysh_client
*vc
;
486 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
487 if (cmd
->daemon
& vtysh_client
[i
].flag
) {
488 if (vtysh_client
[i
].fd
< 0
489 && (cmd
->daemon
== vtysh_client
[i
].flag
)) {
490 bool any_inst
= false;
491 for (vc
= &vtysh_client
[i
]; vc
;
497 "%s is not running\n",
498 vtysh_client
[i
].name
);
502 cmd_stat
= vtysh_client_execute(
503 &vtysh_client
[i
], line
, fp
);
504 if (cmd_stat
!= CMD_SUCCESS
)
508 if (cmd_stat
!= CMD_SUCCESS
)
512 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
515 if (pager
&& vtysh_pager_name
&& fp
&& closepager
&& fp
!= outputfile
) {
516 if (pclose(fp
) == -1) {
517 perror("pclose failed for pager");
524 int vtysh_execute_no_pager(const char *line
)
526 return vtysh_execute_func(line
, 0);
529 int vtysh_execute(const char *line
)
531 return vtysh_execute_func(line
, 1);
534 static char *trim(char *s
)
545 while (end
>= s
&& isspace((int)*end
))
549 while (*s
&& isspace((int)*s
))
555 int vtysh_mark_file(const char *filename
)
562 const struct cmd_element
*cmd
;
563 int saved_ret
, prev_node
;
565 char *vty_buf_copy
= NULL
;
566 char *vty_buf_trimmed
= NULL
;
568 if (strncmp("-", filename
, 1) == 0)
571 confp
= fopen(filename
, "r");
574 fprintf(stderr
, "%% Can't open config file %s due to '%s'.\n",
575 filename
, safe_strerror(errno
));
576 return (CMD_ERR_NO_FILE
);
580 vty
->wfd
= STDERR_FILENO
;
581 vty
->type
= VTY_TERM
;
582 vty
->node
= CONFIG_NODE
;
584 vtysh_execute_no_pager("enable");
585 vtysh_execute_no_pager("configure terminal");
586 vty_buf_copy
= XCALLOC(MTYPE_VTYSH_CMD
, VTY_BUFSIZ
);
588 while (fgets(vty
->buf
, VTY_BUFSIZ
, confp
)) {
591 strcpy(vty_buf_copy
, vty
->buf
);
592 vty_buf_trimmed
= trim(vty_buf_copy
);
595 case LDP_IPV4_IFACE_NODE
:
596 if (strncmp(vty_buf_copy
, " ", 3)) {
597 fprintf(outputfile
, " end\n");
598 vty
->node
= LDP_IPV4_NODE
;
601 case LDP_IPV6_IFACE_NODE
:
602 if (strncmp(vty_buf_copy
, " ", 3)) {
603 fprintf(outputfile
, " end\n");
604 vty
->node
= LDP_IPV6_NODE
;
607 case LDP_PSEUDOWIRE_NODE
:
608 if (strncmp(vty_buf_copy
, " ", 2)) {
609 fprintf(outputfile
, " end\n");
610 vty
->node
= LDP_L2VPN_NODE
;
617 if (vty_buf_trimmed
[0] == '!' || vty_buf_trimmed
[0] == '#') {
618 fprintf(outputfile
, "%s", vty
->buf
);
622 /* Split readline string up into the vector. */
623 vline
= cmd_make_strvec(vty
->buf
);
626 fprintf(outputfile
, "%s", vty
->buf
);
630 /* Ignore the "end" lines, we will generate these where
632 if (strlen(vty_buf_trimmed
) == 3
633 && strncmp("end", vty_buf_trimmed
, 3) == 0) {
634 cmd_free_strvec(vline
);
638 prev_node
= vty
->node
;
639 saved_ret
= ret
= cmd_execute_command_strict(vline
, vty
, &cmd
);
641 /* If command doesn't succeeded in current node, try to walk up
643 * Changing vty->node is enough to try it just out without
646 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
647 && ret
!= CMD_WARNING
&& ret
!= CMD_WARNING_CONFIG_FAILED
648 && vty
->node
> CONFIG_NODE
) {
649 vty
->node
= node_parent(vty
->node
);
650 ret
= cmd_execute_command_strict(vline
, vty
, &cmd
);
654 /* If command succeeded in any other node than current (tried >
656 * to move into node in the vtysh where it succeeded. */
657 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
658 || ret
== CMD_WARNING
) {
659 if ((prev_node
== BGP_VPNV4_NODE
660 || prev_node
== BGP_VPNV6_NODE
661 || prev_node
== BGP_IPV4_NODE
662 || prev_node
== BGP_IPV6_NODE
663 || prev_node
== BGP_FLOWSPECV4_NODE
664 || prev_node
== BGP_FLOWSPECV6_NODE
665 || prev_node
== BGP_IPV4L_NODE
666 || prev_node
== BGP_IPV6L_NODE
667 || prev_node
== BGP_IPV4M_NODE
668 || prev_node
== BGP_IPV6M_NODE
669 || prev_node
== BGP_EVPN_NODE
)
671 fprintf(outputfile
, "exit-address-family\n");
672 } else if ((prev_node
== BGP_EVPN_VNI_NODE
)
674 fprintf(outputfile
, "exit-vni\n");
675 } else if ((prev_node
== KEYCHAIN_KEY_NODE
)
677 fprintf(outputfile
, "exit\n");
679 fprintf(outputfile
, "end\n");
682 /* If command didn't succeed in any node, continue with return
687 vty
->node
= prev_node
;
690 cmd_free_strvec(vline
);
693 case CMD_WARNING_CONFIG_FAILED
:
694 if (vty
->type
== VTY_FILE
)
695 fprintf(stderr
, "line %d: Warning...: %s\n",
699 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
701 case CMD_ERR_AMBIGUOUS
:
702 fprintf(stderr
, "line %d: %% Ambiguous command: %s\n",
706 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
707 return CMD_ERR_AMBIGUOUS
;
708 case CMD_ERR_NO_MATCH
:
709 fprintf(stderr
, "line %d: %% Unknown command: %s\n",
713 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
714 return CMD_ERR_NO_MATCH
;
715 case CMD_ERR_INCOMPLETE
:
716 fprintf(stderr
, "line %d: %% Command incomplete: %s\n",
720 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
721 return CMD_ERR_INCOMPLETE
;
723 fprintf(stdout
, "%s", vty
->buf
);
725 case CMD_SUCCESS_DAEMON
: {
727 int cmd_stat
= CMD_SUCCESS
;
729 fprintf(outputfile
, "%s", vty
->buf
);
730 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
731 if (cmd
->daemon
& vtysh_client
[i
].flag
) {
732 cmd_stat
= vtysh_client_execute(
733 &vtysh_client
[i
], vty
->buf
,
735 if (cmd_stat
!= CMD_SUCCESS
)
739 if (cmd_stat
!= CMD_SUCCESS
)
743 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
747 /* This is the end */
748 fprintf(outputfile
, "\nend\n");
750 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
758 /* Configration make from file. */
759 int vtysh_config_from_file(struct vty
*vty
, FILE *fp
)
762 const struct cmd_element
*cmd
;
764 int retcode
= CMD_SUCCESS
;
766 while (fgets(vty
->buf
, VTY_BUFSIZ
, fp
)) {
769 ret
= command_config_read_one_line(vty
, &cmd
, 1);
773 case CMD_WARNING_CONFIG_FAILED
:
774 if (vty
->type
== VTY_FILE
)
775 fprintf(stderr
, "line %d: Warning[%d]...: %s\n",
776 lineno
, vty
->node
, vty
->buf
);
777 retcode
= ret
; /* once we have an error, we remember &
780 case CMD_ERR_AMBIGUOUS
:
782 "line %d: %% Ambiguous command[%d]: %s\n",
783 lineno
, vty
->node
, vty
->buf
);
784 retcode
= CMD_ERR_AMBIGUOUS
; /* once we have an error,
788 case CMD_ERR_NO_MATCH
:
789 fprintf(stderr
, "line %d: %% Unknown command[%d]: %s",
790 lineno
, vty
->node
, vty
->buf
);
791 retcode
= CMD_ERR_NO_MATCH
; /* once we have an error, we
792 remember & return that */
794 case CMD_ERR_INCOMPLETE
:
796 "line %d: %% Command incomplete[%d]: %s\n",
797 lineno
, vty
->node
, vty
->buf
);
798 retcode
= CMD_ERR_INCOMPLETE
; /* once we have an error,
802 case CMD_SUCCESS_DAEMON
: {
804 int cmd_stat
= CMD_SUCCESS
;
806 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
807 if (cmd
->daemon
& vtysh_client
[i
].flag
) {
808 cmd_stat
= vtysh_client_execute(
809 &vtysh_client
[i
], vty
->buf
,
812 * CMD_WARNING - Can mean that the
814 * parsed successfully but it was
816 * in a few spots. As such if we
818 * CMD_WARNING from a daemon we
820 * talking to the other daemons for the
824 if (cmd_stat
!= CMD_SUCCESS
825 && cmd_stat
!= CMD_WARNING
) {
827 "line %d: Failure to communicate[%d] to %s, line: %s\n",
829 vtysh_client
[i
].name
,
836 if (cmd_stat
!= CMD_SUCCESS
)
840 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
848 /* We don't care about the point of the cursor when '?' is typed. */
849 static int vtysh_rl_describe(void)
856 struct cmd_token
*token
;
858 vline
= cmd_make_strvec(rl_line_buffer
);
860 /* In case of '> ?'. */
862 vline
= vector_init(1);
863 vector_set(vline
, NULL
);
864 } else if (rl_end
&& isspace((int)rl_line_buffer
[rl_end
- 1]))
865 vector_set(vline
, NULL
);
867 fprintf(stdout
, "\n");
869 describe
= cmd_describe_command(vline
, vty
, &ret
);
871 /* Ambiguous and no match error. */
873 case CMD_ERR_AMBIGUOUS
:
874 cmd_free_strvec(vline
);
875 vector_free(describe
);
876 fprintf(stdout
, "%% Ambiguous command.\n");
880 case CMD_ERR_NO_MATCH
:
881 cmd_free_strvec(vline
);
883 vector_free(describe
);
884 fprintf(stdout
, "%% There is no matched command.\n");
890 /* Get width of command string. */
892 for (i
= 0; i
< vector_active(describe
); i
++)
893 if ((token
= vector_slot(describe
, i
)) != NULL
) {
894 if (token
->text
[0] == '\0')
897 int len
= strlen(token
->text
);
903 for (i
= 0; i
< vector_active(describe
); i
++)
904 if ((token
= vector_slot(describe
, i
)) != NULL
) {
906 fprintf(stdout
, " %-s\n", token
->text
);
908 fprintf(stdout
, " %-*s %s\n", width
,
909 token
->text
, token
->desc
);
911 if (IS_VARYING_TOKEN(token
->type
)) {
912 const char *ref
= vector_slot(
913 vline
, vector_active(vline
) - 1);
915 vector varcomps
= vector_init(VECTOR_MIN_SIZE
);
916 cmd_variable_complete(token
, ref
, varcomps
);
918 if (vector_active(varcomps
) > 0) {
920 rl_get_screen_size(&rows
, &cols
);
922 char *ac
= cmd_variable_comp2str(
924 fprintf(stdout
, "%s\n", ac
);
925 XFREE(MTYPE_TMP
, ac
);
928 vector_free(varcomps
);
932 cmd_free_strvec(vline
);
933 vector_free(describe
);
940 /* Result of cmd_complete_command() call will be stored here
941 * and used in new_completion() in order to put the space in
942 * correct places only. */
945 static char *command_generator(const char *text
, int state
)
948 static char **matched
= NULL
;
949 static int index
= 0;
955 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
958 vline
= cmd_make_strvec(rl_line_buffer
);
962 if (rl_end
&& isspace((int)rl_line_buffer
[rl_end
- 1]))
963 vector_set(vline
, NULL
);
965 matched
= cmd_complete_command(vline
, vty
, &complete_status
);
966 cmd_free_strvec(vline
);
969 if (matched
&& matched
[index
])
970 /* this is free()'d by readline, but we leak 1 count of
971 * MTYPE_COMPLETION */
972 return matched
[index
++];
974 XFREE(MTYPE_TMP
, matched
);
980 static char **new_completion(char *text
, int start
, int end
)
984 matches
= rl_completion_matches(text
, command_generator
);
988 if (complete_status
!= CMD_COMPLETE_FULL_MATCH
)
989 /* only append a space on full match */
990 rl_completion_append_character
= '\0';
996 /* Vty node structures. */
997 static struct cmd_node bgp_node
= {
998 BGP_NODE
, "%s(config-router)# ",
1001 static struct cmd_node rip_node
= {
1002 RIP_NODE
, "%s(config-router)# ",
1005 static struct cmd_node isis_node
= {
1006 ISIS_NODE
, "%s(config-router)# ",
1009 static struct cmd_node interface_node
= {
1010 INTERFACE_NODE
, "%s(config-if)# ",
1013 static struct cmd_node pw_node
= {
1014 PW_NODE
, "%s(config-pw)# ",
1017 static struct cmd_node logicalrouter_node
= {
1018 LOGICALROUTER_NODE
, "%s(config-logical-router)# ",
1021 static struct cmd_node vrf_node
= {
1022 VRF_NODE
, "%s(config-vrf)# ",
1025 static struct cmd_node nh_group_node
= {
1027 "%s(config-nh-group)# ",
1030 static struct cmd_node rmap_node
= {RMAP_NODE
, "%s(config-route-map)# "};
1032 static struct cmd_node pbr_map_node
= {PBRMAP_NODE
, "%s(config-pbr-map)# "};
1034 static struct cmd_node zebra_node
= {ZEBRA_NODE
, "%s(config-router)# "};
1036 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
1037 "%s(config-router-af)# "};
1039 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
1040 "%s(config-router-af)# "};
1042 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
1043 "%s(config-router-af)# "};
1045 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
1046 "%s(config-router-af)# "};
1048 static struct cmd_node bgp_ipv4_node
= {BGP_IPV4_NODE
,
1049 "%s(config-router-af)# "};
1051 static struct cmd_node bgp_ipv4m_node
= {BGP_IPV4M_NODE
,
1052 "%s(config-router-af)# "};
1054 static struct cmd_node bgp_ipv4l_node
= {BGP_IPV4L_NODE
,
1055 "%s(config-router-af)# "};
1057 static struct cmd_node bgp_ipv6_node
= {BGP_IPV6_NODE
,
1058 "%s(config-router-af)# "};
1060 static struct cmd_node bgp_ipv6m_node
= {BGP_IPV6M_NODE
,
1061 "%s(config-router-af)# "};
1063 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
1064 "%s(config-router-af)# "};
1066 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
1067 "%s(config-router-af-vni)# "};
1069 static struct cmd_node bgp_ipv6l_node
= {BGP_IPV6L_NODE
,
1070 "%s(config-router-af)# "};
1072 static struct cmd_node bgp_vnc_defaults_node
= {
1073 BGP_VNC_DEFAULTS_NODE
, "%s(config-router-vnc-defaults)# "};
1075 static struct cmd_node bgp_vnc_nve_group_node
= {
1076 BGP_VNC_NVE_GROUP_NODE
, "%s(config-router-vnc-nve-group)# "};
1078 static struct cmd_node bgp_vrf_policy_node
= {BGP_VRF_POLICY_NODE
,
1079 "%s(config-router-vrf-policy)# "};
1081 static struct cmd_node bgp_vnc_l2_group_node
= {
1082 BGP_VNC_L2_GROUP_NODE
, "%s(config-router-vnc-l2-group)# "};
1084 static struct cmd_node ospf_node
= {OSPF_NODE
, "%s(config-router)# "};
1086 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# "};
1088 static struct cmd_node babel_node
= {BABEL_NODE
, "%s(config-router)# "};
1090 static struct cmd_node ripng_node
= {RIPNG_NODE
, "%s(config-router)# "};
1092 static struct cmd_node ospf6_node
= {OSPF6_NODE
, "%s(config-ospf6)# "};
1094 static struct cmd_node ldp_node
= {LDP_NODE
, "%s(config-ldp)# "};
1096 static struct cmd_node ldp_ipv4_node
= {LDP_IPV4_NODE
, "%s(config-ldp-af)# "};
1098 static struct cmd_node ldp_ipv6_node
= {LDP_IPV6_NODE
, "%s(config-ldp-af)# "};
1100 static struct cmd_node ldp_ipv4_iface_node
= {LDP_IPV4_IFACE_NODE
,
1101 "%s(config-ldp-af-if)# "};
1103 static struct cmd_node ldp_ipv6_iface_node
= {LDP_IPV6_IFACE_NODE
,
1104 "%s(config-ldp-af-if)# "};
1106 static struct cmd_node ldp_l2vpn_node
= {LDP_L2VPN_NODE
, "%s(config-l2vpn)# "};
1108 static struct cmd_node ldp_pseudowire_node
= {LDP_PSEUDOWIRE_NODE
,
1109 "%s(config-l2vpn-pw)# "};
1111 static struct cmd_node keychain_node
= {KEYCHAIN_NODE
, "%s(config-keychain)# "};
1113 static struct cmd_node keychain_key_node
= {KEYCHAIN_KEY_NODE
,
1114 "%s(config-keychain-key)# "};
1116 struct cmd_node link_params_node
= {
1117 LINK_PARAMS_NODE
, "%s(config-link-params)# ",
1120 #if defined(HAVE_RPKI)
1121 static struct cmd_node rpki_node
= {RPKI_NODE
, "%s(config-rpki)# ", 1};
1124 /* Defined in lib/vty.c */
1125 extern struct cmd_node vty_node
;
1127 /* When '^Z' is received from vty, move down to the enable mode. */
1128 static int vtysh_end(void)
1130 switch (vty
->node
) {
1133 /* Nothing to do. */
1136 vty
->node
= ENABLE_NODE
;
1142 DEFUNSH(VTYSH_REALLYALL
, vtysh_end_all
, vtysh_end_all_cmd
, "end",
1143 "End current mode and change to enable mode\n")
1148 DEFUNSH(VTYSH_BGPD
, router_bgp
, router_bgp_cmd
,
1149 "router bgp [(1-4294967295) [<view|vrf> WORD]]",
1150 ROUTER_STR BGP_STR AS_STR
1151 "BGP view\nBGP VRF\n"
1154 vty
->node
= BGP_NODE
;
1158 DEFUNSH(VTYSH_BGPD
, address_family_vpnv4
, address_family_vpnv4_cmd
,
1159 "address-family vpnv4 [unicast]",
1160 "Enter Address Family command mode\n"
1162 "Address Family modifier\n")
1164 vty
->node
= BGP_VPNV4_NODE
;
1168 DEFUNSH(VTYSH_BGPD
, address_family_vpnv6
, address_family_vpnv6_cmd
,
1169 "address-family vpnv6 [unicast]",
1170 "Enter Address Family command mode\n"
1172 "Address Family modifier\n")
1174 vty
->node
= BGP_VPNV6_NODE
;
1178 DEFUNSH(VTYSH_BGPD
, address_family_ipv4
, address_family_ipv4_cmd
,
1179 "address-family ipv4 [unicast]",
1180 "Enter Address Family command mode\n"
1182 "Address Family Modifier\n")
1184 vty
->node
= BGP_IPV4_NODE
;
1188 DEFUNSH(VTYSH_BGPD
, address_family_flowspecv4
, address_family_flowspecv4_cmd
,
1189 "address-family ipv4 flowspec",
1190 "Enter Address Family command mode\n"
1192 "Address Family Modifier\n")
1194 vty
->node
= BGP_FLOWSPECV4_NODE
;
1198 DEFUNSH(VTYSH_BGPD
, address_family_flowspecv6
, address_family_flowspecv6_cmd
,
1199 "address-family ipv6 flowspec",
1200 "Enter Address Family command mode\n"
1202 "Address Family Modifier\n")
1204 vty
->node
= BGP_FLOWSPECV6_NODE
;
1208 DEFUNSH(VTYSH_BGPD
, address_family_ipv4_multicast
,
1209 address_family_ipv4_multicast_cmd
, "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
, address_family_ipv4_vpn
, address_family_ipv4_vpn_cmd
,
1219 "address-family ipv4 vpn",
1220 "Enter Address Family command mode\n"
1222 "Address Family modifier\n")
1224 vty
->node
= BGP_VPNV4_NODE
;
1228 DEFUNSH(VTYSH_BGPD
, address_family_ipv4_labeled_unicast
,
1229 address_family_ipv4_labeled_unicast_cmd
,
1230 "address-family ipv4 labeled-unicast",
1231 "Enter Address Family command mode\n"
1233 "Address Family modifier\n")
1235 vty
->node
= BGP_IPV4L_NODE
;
1239 DEFUNSH(VTYSH_BGPD
, address_family_ipv6
, address_family_ipv6_cmd
,
1240 "address-family ipv6 [unicast]",
1241 "Enter Address Family command mode\n"
1243 "Address Family modifier\n")
1245 vty
->node
= BGP_IPV6_NODE
;
1249 DEFUNSH(VTYSH_BGPD
, address_family_ipv6_multicast
,
1250 address_family_ipv6_multicast_cmd
, "address-family ipv6 multicast",
1251 "Enter Address Family command mode\n"
1253 "Address Family modifier\n")
1255 vty
->node
= BGP_IPV6M_NODE
;
1259 DEFUNSH(VTYSH_BGPD
, address_family_ipv6_vpn
, address_family_ipv6_vpn_cmd
,
1260 "address-family ipv6 vpn",
1261 "Enter Address Family command mode\n"
1263 "Address Family modifier\n")
1265 vty
->node
= BGP_VPNV6_NODE
;
1269 DEFUNSH(VTYSH_BGPD
, address_family_ipv6_labeled_unicast
,
1270 address_family_ipv6_labeled_unicast_cmd
,
1271 "address-family ipv6 labeled-unicast",
1272 "Enter Address Family command mode\n"
1274 "Address Family modifier\n")
1276 vty
->node
= BGP_IPV6L_NODE
;
1280 #if defined(HAVE_RPKI)
1285 "Enable rpki and enter rpki configuration mode\n")
1287 vty
->node
= RPKI_NODE
;
1295 "Exit current mode and down to previous mode\n")
1297 vty
->node
= CONFIG_NODE
;
1305 "Exit current mode and down to previous mode\n")
1307 return rpki_exit(self
, vty
, argc
, argv
);
1311 DEFUNSH(VTYSH_BGPD
, address_family_evpn
, address_family_evpn_cmd
,
1312 "address-family <l2vpn evpn>",
1313 "Enter Address Family command mode\n"
1315 "Address Family modifier\n")
1317 vty
->node
= BGP_EVPN_NODE
;
1321 #if defined(HAVE_CUMULUS)
1322 DEFUNSH_HIDDEN(VTYSH_BGPD
, address_family_evpn2
, address_family_evpn2_cmd
,
1323 "address-family evpn",
1324 "Enter Address Family command mode\n"
1325 "EVPN Address family\n")
1327 vty
->node
= BGP_EVPN_NODE
;
1332 DEFUNSH(VTYSH_BGPD
, bgp_evpn_vni
, bgp_evpn_vni_cmd
, "vni (1-16777215)",
1333 "VXLAN Network Identifier\n"
1336 vty
->node
= BGP_EVPN_VNI_NODE
;
1340 #if defined(ENABLE_BGP_VNC)
1341 DEFUNSH(VTYSH_BGPD
, vnc_defaults
, vnc_defaults_cmd
, "vnc defaults",
1342 "VNC/RFP related configuration\n"
1343 "Configure default NVE group\n")
1345 vty
->node
= BGP_VNC_DEFAULTS_NODE
;
1349 DEFUNSH(VTYSH_BGPD
, vnc_nve_group
, vnc_nve_group_cmd
, "vnc nve-group NAME",
1350 "VNC/RFP related configuration\n"
1351 "Configure a NVE group\n"
1354 vty
->node
= BGP_VNC_NVE_GROUP_NODE
;
1358 DEFUNSH(VTYSH_BGPD
, vnc_vrf_policy
, vnc_vrf_policy_cmd
, "vrf-policy NAME",
1359 "Configure a VRF policy group\n"
1362 vty
->node
= BGP_VRF_POLICY_NODE
;
1366 DEFUNSH(VTYSH_BGPD
, vnc_l2_group
, vnc_l2_group_cmd
, "vnc l2-group NAME",
1367 "VNC/RFP related configuration\n"
1368 "Configure a L2 group\n"
1371 vty
->node
= BGP_VNC_L2_GROUP_NODE
;
1376 DEFUNSH(VTYSH_RIPD
, key_chain
, key_chain_cmd
, "key chain WORD",
1377 "Authentication key management\n"
1378 "Key-chain management\n"
1381 vty
->node
= KEYCHAIN_NODE
;
1385 DEFUNSH(VTYSH_RIPD
, key
, key_cmd
, "key (0-2147483647)",
1387 "Key identifier number\n")
1389 vty
->node
= KEYCHAIN_KEY_NODE
;
1393 DEFUNSH(VTYSH_RIPD
, router_rip
, router_rip_cmd
, "router rip",
1396 vty
->node
= RIP_NODE
;
1400 DEFUNSH(VTYSH_RIPNGD
, router_ripng
, router_ripng_cmd
, "router ripng",
1401 ROUTER_STR
"RIPng\n")
1403 vty
->node
= RIPNG_NODE
;
1407 DEFUNSH(VTYSH_OSPFD
, router_ospf
, router_ospf_cmd
,
1408 "router ospf [(1-65535)] [vrf NAME]",
1409 "Enable a routing process\n"
1410 "Start OSPF configuration\n"
1414 vty
->node
= OSPF_NODE
;
1418 DEFUNSH(VTYSH_EIGRPD
, router_eigrp
, router_eigrp_cmd
, "router eigrp (1-65535)",
1419 "Enable a routing process\n"
1420 "Start EIGRP configuration\n"
1421 "AS number to use\n")
1423 vty
->node
= EIGRP_NODE
;
1427 DEFUNSH(VTYSH_BABELD
, router_babel
, router_babel_cmd
, "router babel",
1428 "Enable a routing process\n"
1429 "Make Babel instance command\n")
1431 vty
->node
= BABEL_NODE
;
1435 DEFUNSH(VTYSH_OSPF6D
, router_ospf6
, router_ospf6_cmd
, "router ospf6",
1436 ROUTER_STR OSPF6_STR
)
1438 vty
->node
= OSPF6_NODE
;
1442 #if defined(HAVE_LDPD)
1443 DEFUNSH(VTYSH_LDPD
, ldp_mpls_ldp
, ldp_mpls_ldp_cmd
, "mpls ldp",
1444 "Global MPLS configuration subcommands\n"
1445 "Label Distribution Protocol\n")
1447 vty
->node
= LDP_NODE
;
1451 DEFUNSH(VTYSH_LDPD
, ldp_address_family_ipv4
, ldp_address_family_ipv4_cmd
,
1452 "address-family ipv4",
1453 "Configure Address Family and its parameters\n"
1456 vty
->node
= LDP_IPV4_NODE
;
1460 DEFUNSH(VTYSH_LDPD
, ldp_address_family_ipv6
, ldp_address_family_ipv6_cmd
,
1461 "address-family ipv6",
1462 "Configure Address Family and its parameters\n"
1465 vty
->node
= LDP_IPV6_NODE
;
1469 DEFUNSH(VTYSH_LDPD
, ldp_exit_address_family
, ldp_exit_address_family_cmd
,
1470 "exit-address-family", "Exit from Address Family configuration mode\n")
1472 if (vty
->node
== LDP_IPV4_NODE
|| vty
->node
== LDP_IPV6_NODE
)
1473 vty
->node
= LDP_NODE
;
1477 DEFUNSH(VTYSH_LDPD
, ldp_interface_ifname
, ldp_interface_ifname_cmd
,
1479 "Enable LDP on an interface and enter interface submode\n"
1480 "Interface's name\n")
1482 switch (vty
->node
) {
1484 vty
->node
= LDP_IPV4_IFACE_NODE
;
1487 vty
->node
= LDP_IPV6_IFACE_NODE
;
1496 DEFUNSH(VTYSH_LDPD
, ldp_l2vpn_word_type_vpls
, ldp_l2vpn_word_type_vpls_cmd
,
1497 "l2vpn WORD type vpls",
1498 "Configure l2vpn commands\n"
1501 "Virtual Private LAN Service\n")
1503 vty
->node
= LDP_L2VPN_NODE
;
1507 DEFUNSH(VTYSH_LDPD
, ldp_member_pseudowire_ifname
,
1508 ldp_member_pseudowire_ifname_cmd
, "member pseudowire IFNAME",
1509 "L2VPN member configuration\n"
1510 "Pseudowire interface\n"
1511 "Interface's name\n")
1513 vty
->node
= LDP_PSEUDOWIRE_NODE
;
1518 DEFUNSH(VTYSH_ISISD
, router_isis
, router_isis_cmd
, "router isis WORD",
1521 "ISO Routing area tag\n")
1523 vty
->node
= ISIS_NODE
;
1527 DEFUNSH(VTYSH_RMAP
, vtysh_route_map
, vtysh_route_map_cmd
,
1528 "route-map WORD <deny|permit> (1-65535)",
1529 "Create route-map or enter route-map command mode\n"
1531 "Route map denies set operations\n"
1532 "Route map permits set operations\n"
1533 "Sequence to insert to/delete from existing route-map entry\n")
1535 vty
->node
= RMAP_NODE
;
1539 DEFUNSH(VTYSH_PBRD
, vtysh_pbr_map
, vtysh_pbr_map_cmd
,
1540 "pbr-map NAME seq (1-1000)",
1541 "Create pbr-map or enter pbr-map command mode\n"
1542 "The name of the PBR MAP\n"
1543 "Sequence to insert to/delete from existing pbr-map entry\n"
1544 "Sequence number\n")
1546 vty
->node
= PBRMAP_NODE
;
1550 DEFSH(VTYSH_PBRD
, vtysh_no_pbr_map_cmd
, "no pbr-map WORD [seq (1-65535)]",
1553 "The name of the PBR MAP\n"
1554 "Sequence to delete from existing pbr-map entry\n"
1555 "Sequence number\n")
1557 DEFUNSH(VTYSH_ALL
, vtysh_line_vty
, vtysh_line_vty_cmd
, "line vty",
1558 "Configure a terminal line\n"
1559 "Virtual terminal\n")
1561 vty
->node
= VTY_NODE
;
1565 DEFUNSH(VTYSH_REALLYALL
, vtysh_enable
, vtysh_enable_cmd
, "enable",
1566 "Turn on privileged mode command\n")
1568 vty
->node
= ENABLE_NODE
;
1572 DEFUNSH(VTYSH_REALLYALL
, vtysh_disable
, vtysh_disable_cmd
, "disable",
1573 "Turn off privileged mode command\n")
1575 if (vty
->node
== ENABLE_NODE
)
1576 vty
->node
= VIEW_NODE
;
1580 DEFUNSH(VTYSH_REALLYALL
, vtysh_config_terminal
, vtysh_config_terminal_cmd
,
1581 "configure terminal",
1582 "Configuration from vty interface\n"
1583 "Configuration terminal\n")
1585 vty
->node
= CONFIG_NODE
;
1589 static int vtysh_exit(struct vty
*vty
)
1591 switch (vty
->node
) {
1597 vty
->node
= ENABLE_NODE
;
1599 case INTERFACE_NODE
:
1601 case LOGICALROUTER_NODE
:
1613 case LDP_L2VPN_NODE
:
1619 vtysh_execute("end");
1620 vtysh_execute("configure terminal");
1621 vty
->node
= CONFIG_NODE
;
1623 case BGP_VPNV4_NODE
:
1624 case BGP_VPNV6_NODE
:
1626 case BGP_IPV4M_NODE
:
1627 case BGP_IPV4L_NODE
:
1629 case BGP_IPV6M_NODE
:
1630 case BGP_IPV6L_NODE
:
1631 case BGP_FLOWSPECV4_NODE
:
1632 case BGP_FLOWSPECV6_NODE
:
1633 case BGP_VRF_POLICY_NODE
:
1635 case BGP_VNC_DEFAULTS_NODE
:
1636 case BGP_VNC_NVE_GROUP_NODE
:
1637 case BGP_VNC_L2_GROUP_NODE
:
1638 vty
->node
= BGP_NODE
;
1640 case BGP_EVPN_VNI_NODE
:
1641 vty
->node
= BGP_EVPN_NODE
;
1645 vty
->node
= LDP_NODE
;
1647 case LDP_IPV4_IFACE_NODE
:
1648 vty
->node
= LDP_IPV4_NODE
;
1650 case LDP_IPV6_IFACE_NODE
:
1651 vty
->node
= LDP_IPV6_NODE
;
1653 case LDP_PSEUDOWIRE_NODE
:
1654 vty
->node
= LDP_L2VPN_NODE
;
1656 case KEYCHAIN_KEY_NODE
:
1657 vty
->node
= KEYCHAIN_NODE
;
1659 case LINK_PARAMS_NODE
:
1660 vty
->node
= INTERFACE_NODE
;
1668 DEFUNSH(VTYSH_REALLYALL
, vtysh_exit_all
, vtysh_exit_all_cmd
, "exit",
1669 "Exit current mode and down to previous mode\n")
1671 return vtysh_exit(vty
);
1674 DEFUNSH(VTYSH_ALL
, vtysh_quit_all
, vtysh_quit_all_cmd
, "quit",
1675 "Exit current mode and down to previous mode\n")
1677 return vtysh_exit_all(self
, vty
, argc
, argv
);
1680 DEFUNSH(VTYSH_BGPD
, exit_address_family
, exit_address_family_cmd
,
1681 "exit-address-family", "Exit from Address Family configuration mode\n")
1683 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
1684 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
1685 || vty
->node
== BGP_VPNV6_NODE
|| vty
->node
== BGP_IPV6_NODE
1686 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_IPV6M_NODE
1687 || vty
->node
== BGP_EVPN_NODE
1688 || vty
->node
== BGP_FLOWSPECV4_NODE
1689 || vty
->node
== BGP_FLOWSPECV6_NODE
)
1690 vty
->node
= BGP_NODE
;
1694 DEFUNSH(VTYSH_BGPD
, exit_vni
, exit_vni_cmd
, "exit-vni", "Exit from VNI mode\n")
1696 if (vty
->node
== BGP_EVPN_VNI_NODE
)
1697 vty
->node
= BGP_EVPN_NODE
;
1701 DEFUNSH(VTYSH_BGPD
, exit_vnc_config
, exit_vnc_config_cmd
, "exit-vnc",
1702 "Exit from VNC configuration mode\n")
1704 if (vty
->node
== BGP_VNC_DEFAULTS_NODE
1705 || vty
->node
== BGP_VNC_NVE_GROUP_NODE
1706 || vty
->node
== BGP_VNC_L2_GROUP_NODE
)
1707 vty
->node
= BGP_NODE
;
1711 DEFUNSH(VTYSH_PIMD
|VTYSH_ZEBRA
, exit_vrf_config
, exit_vrf_config_cmd
, "exit-vrf",
1712 "Exit from VRF configuration mode\n")
1714 if (vty
->node
== VRF_NODE
)
1715 vty
->node
= CONFIG_NODE
;
1719 DEFUNSH(VTYSH_BGPD
, exit_vrf_policy
, exit_vrf_policy_cmd
, "exit-vrf-policy",
1720 "Exit from VRF policy configuration mode\n")
1722 if (vty
->node
== BGP_VRF_POLICY_NODE
)
1723 vty
->node
= BGP_NODE
;
1727 DEFUNSH(VTYSH_RIPD
, vtysh_exit_ripd
, vtysh_exit_ripd_cmd
, "exit",
1728 "Exit current mode and down to previous mode\n")
1730 return vtysh_exit(vty
);
1733 DEFUNSH(VTYSH_RIPD
, vtysh_quit_ripd
, vtysh_quit_ripd_cmd
, "quit",
1734 "Exit current mode and down to previous mode\n")
1736 return vtysh_exit_ripd(self
, vty
, argc
, argv
);
1739 DEFUNSH(VTYSH_RIPNGD
, vtysh_exit_ripngd
, vtysh_exit_ripngd_cmd
, "exit",
1740 "Exit current mode and down to previous mode\n")
1742 return vtysh_exit(vty
);
1745 DEFUNSH(VTYSH_RIPNGD
, vtysh_quit_ripngd
, vtysh_quit_ripngd_cmd
, "quit",
1746 "Exit current mode and down to previous mode\n")
1748 return vtysh_exit_ripngd(self
, vty
, argc
, argv
);
1751 DEFUNSH(VTYSH_RMAP
, vtysh_exit_rmap
, vtysh_exit_rmap_cmd
, "exit",
1752 "Exit current mode and down to previous mode\n")
1754 return vtysh_exit(vty
);
1757 DEFUNSH(VTYSH_RMAP
, vtysh_quit_rmap
, vtysh_quit_rmap_cmd
, "quit",
1758 "Exit current mode and down to previous mode\n")
1760 return vtysh_exit_rmap(self
, vty
, argc
, argv
);
1763 DEFUNSH(VTYSH_PBRD
, vtysh_exit_pbr_map
, vtysh_exit_pbr_map_cmd
, "exit",
1764 "Exit current mode and down to previous mode\n")
1766 return vtysh_exit(vty
);
1769 DEFUNSH(VTYSH_PBRD
, vtysh_quit_pbr_map
, vtysh_quit_pbr_map_cmd
, "quit",
1770 "Exit current mode and down to previous mode\n")
1772 return vtysh_exit_rmap(self
, vty
, argc
, argv
);
1775 DEFUNSH(VTYSH_BGPD
, vtysh_exit_bgpd
, vtysh_exit_bgpd_cmd
, "exit",
1776 "Exit current mode and down to previous mode\n")
1778 return vtysh_exit(vty
);
1781 DEFUNSH(VTYSH_BGPD
, vtysh_quit_bgpd
, vtysh_quit_bgpd_cmd
, "quit",
1782 "Exit current mode and down to previous mode\n")
1784 return vtysh_exit_bgpd(self
, vty
, argc
, argv
);
1787 DEFUNSH(VTYSH_OSPFD
, vtysh_exit_ospfd
, vtysh_exit_ospfd_cmd
, "exit",
1788 "Exit current mode and down to previous mode\n")
1790 return vtysh_exit(vty
);
1793 DEFUNSH(VTYSH_OSPFD
, vtysh_quit_ospfd
, vtysh_quit_ospfd_cmd
, "quit",
1794 "Exit current mode and down to previous mode\n")
1796 return vtysh_exit_ospfd(self
, vty
, argc
, argv
);
1799 DEFUNSH(VTYSH_EIGRPD
, vtysh_exit_eigrpd
, vtysh_exit_eigrpd_cmd
, "exit",
1800 "Exit current mode and down to previous mode\n")
1802 return vtysh_exit(vty
);
1805 DEFUNSH(VTYSH_EIGRPD
, vtysh_quit_eigrpd
, vtysh_quit_eigrpd_cmd
, "quit",
1806 "Exit current mode and down to previous mode\n")
1808 return vtysh_exit(vty
);
1811 DEFUNSH(VTYSH_EIGRPD
, vtysh_exit_babeld
, vtysh_exit_babeld_cmd
, "exit",
1812 "Exit current mode and down to previous mode\n")
1814 return vtysh_exit(vty
);
1817 DEFUNSH(VTYSH_BABELD
, vtysh_quit_babeld
, vtysh_quit_babeld_cmd
, "quit",
1818 "Exit current mode and down to previous mode\n")
1820 return vtysh_exit(vty
);
1823 DEFUNSH(VTYSH_OSPF6D
, vtysh_exit_ospf6d
, vtysh_exit_ospf6d_cmd
, "exit",
1824 "Exit current mode and down to previous mode\n")
1826 return vtysh_exit(vty
);
1829 DEFUNSH(VTYSH_OSPF6D
, vtysh_quit_ospf6d
, vtysh_quit_ospf6d_cmd
, "quit",
1830 "Exit current mode and down to previous mode\n")
1832 return vtysh_exit_ospf6d(self
, vty
, argc
, argv
);
1835 #if defined(HAVE_LDPD)
1836 DEFUNSH(VTYSH_LDPD
, vtysh_exit_ldpd
, vtysh_exit_ldpd_cmd
, "exit",
1837 "Exit current mode and down to previous mode\n")
1839 return vtysh_exit(vty
);
1842 ALIAS(vtysh_exit_ldpd
, vtysh_quit_ldpd_cmd
, "quit",
1843 "Exit current mode and down to previous mode\n")
1846 DEFUNSH(VTYSH_ISISD
, vtysh_exit_isisd
, vtysh_exit_isisd_cmd
, "exit",
1847 "Exit current mode and down to previous mode\n")
1849 return vtysh_exit(vty
);
1852 DEFUNSH(VTYSH_ISISD
, vtysh_quit_isisd
, vtysh_quit_isisd_cmd
, "quit",
1853 "Exit current mode and down to previous mode\n")
1855 return vtysh_exit_isisd(self
, vty
, argc
, argv
);
1858 DEFUNSH(VTYSH_ALL
, vtysh_exit_line_vty
, vtysh_exit_line_vty_cmd
, "exit",
1859 "Exit current mode and down to previous mode\n")
1861 return vtysh_exit(vty
);
1864 DEFUNSH(VTYSH_ALL
, vtysh_quit_line_vty
, vtysh_quit_line_vty_cmd
, "quit",
1865 "Exit current mode and down to previous mode\n")
1867 return vtysh_exit_line_vty(self
, vty
, argc
, argv
);
1870 DEFUNSH(VTYSH_INTERFACE
, vtysh_interface
, vtysh_interface_cmd
,
1871 "interface IFNAME [vrf NAME]",
1872 "Select an interface to configure\n"
1873 "Interface's name\n" VRF_CMD_HELP_STR
)
1875 vty
->node
= INTERFACE_NODE
;
1879 DEFUNSH(VTYSH_ZEBRA
, vtysh_pseudowire
, vtysh_pseudowire_cmd
,
1880 "pseudowire IFNAME",
1881 "Static pseudowire configuration\n"
1882 "Pseudowire name\n")
1884 vty
->node
= PW_NODE
;
1888 /* TODO Implement "no interface command in isisd. */
1889 DEFSH(VTYSH_ZEBRA
| VTYSH_RIPD
| VTYSH_RIPNGD
| VTYSH_OSPFD
| VTYSH_OSPF6D
1891 vtysh_no_interface_cmd
, "no interface IFNAME", NO_STR
1892 "Delete a pseudo interface's configuration\n"
1893 "Interface's name\n")
1895 DEFSH(VTYSH_ZEBRA
, vtysh_no_interface_vrf_cmd
, "no interface IFNAME vrf NAME",
1897 "Delete a pseudo interface's configuration\n"
1898 "Interface's name\n" VRF_CMD_HELP_STR
)
1900 DEFUNSH(VTYSH_ZEBRA
, vtysh_logicalrouter
, vtysh_logicalrouter_cmd
,
1901 "logical-router (1-65535) ns NAME",
1902 "Enable a logical-router\n"
1903 "Specify the logical-router indentifier\n"
1905 "The file name in " NS_RUN_DIR
", or a full pathname\n")
1907 vty
->node
= LOGICALROUTER_NODE
;
1911 DEFSH(VTYSH_ZEBRA
, vtysh_no_logicalrouter_cmd
,
1912 "no logical-router (1-65535) ns NAME", NO_STR
1913 "Enable a Logical-Router\n"
1914 "Specify the Logical-Router identifier\n"
1916 "The file name in " NS_RUN_DIR
", or a full pathname\n")
1918 DEFUNSH(VTYSH_PBRD
, vtysh_nexthop_group
, vtysh_nexthop_group_cmd
,
1919 "nexthop-group NAME",
1920 "Nexthop Group configuration\n"
1921 "Name of the Nexthop Group\n")
1923 vty
->node
= NH_GROUP_NODE
;
1927 DEFSH(VTYSH_PBRD
, vtysh_no_nexthop_group_cmd
, "no nexthop-group NAME",
1929 "Nexthop Group Configuration\n"
1930 "Name of the Nexthop Group\n")
1932 DEFUNSH(VTYSH_VRF
, vtysh_vrf
, vtysh_vrf_cmd
, "vrf NAME",
1933 "Select a VRF to configure\n"
1936 vty
->node
= VRF_NODE
;
1940 DEFSH(VTYSH_ZEBRA
, vtysh_no_vrf_cmd
, "no vrf NAME", NO_STR
1941 "Delete a pseudo vrf's configuration\n"
1944 DEFUNSH(VTYSH_NS
, vtysh_exit_logicalrouter
,
1945 vtysh_exit_logicalrouter_cmd
, "exit",
1946 "Exit current mode and down to previous mode\n")
1948 return vtysh_exit(vty
);
1951 DEFUNSH(VTYSH_NS
, vtysh_quit_logicalrouter
,
1952 vtysh_quit_logicalrouter_cmd
, "quit",
1953 "Exit current mode and down to previous mode\n")
1955 return vtysh_exit_logicalrouter(self
, vty
, argc
, argv
);
1958 DEFUNSH(VTYSH_VRF
, vtysh_exit_vrf
, vtysh_exit_vrf_cmd
, "exit",
1959 "Exit current mode and down to previous mode\n")
1961 return vtysh_exit(vty
);
1964 DEFUNSH(VTYSH_VRF
, vtysh_quit_vrf
, vtysh_quit_vrf_cmd
, "quit",
1965 "Exit current mode and down to previous mode\n")
1967 return vtysh_exit_vrf(self
, vty
, argc
, argv
);
1970 DEFUNSH(VTYSH_PBRD
, vtysh_exit_nexthop_group
, vtysh_exit_nexthop_group_cmd
,
1971 "exit", "Exit current mode and down to previous mode\n")
1973 return vtysh_exit(vty
);
1976 DEFUNSH(VTYSH_VRF
, vtysh_quit_nexthop_group
, vtysh_quit_nexthop_group_cmd
,
1977 "quit", "Exit current mode and down to previous mode\n")
1979 return vtysh_exit_nexthop_group(self
, vty
, argc
, argv
);
1982 /* TODO Implement interface description commands in ripngd, ospf6d
1984 DEFSH(VTYSH_ZEBRA
| VTYSH_RIPD
| VTYSH_OSPFD
| VTYSH_EIGRPD
,
1985 vtysh_interface_desc_cmd
, "description LINE...",
1986 "Interface specific description\n"
1987 "Characters describing this interface\n")
1989 DEFSH(VTYSH_ZEBRA
| VTYSH_RIPD
| VTYSH_OSPFD
| VTYSH_EIGRPD
,
1990 vtysh_no_interface_desc_cmd
, "no description",
1991 NO_STR
"Interface specific description\n")
1993 DEFUNSH(VTYSH_INTERFACE
, vtysh_exit_interface
, vtysh_exit_interface_cmd
, "exit",
1994 "Exit current mode and down to previous mode\n")
1996 return vtysh_exit(vty
);
1999 DEFUNSH(VTYSH_INTERFACE
, vtysh_quit_interface
, vtysh_quit_interface_cmd
, "quit",
2000 "Exit current mode and down to previous mode\n")
2002 return vtysh_exit_interface(self
, vty
, argc
, argv
);
2005 DEFUN (vtysh_show_thread
,
2006 vtysh_show_thread_cmd
,
2007 "show thread cpu [FILTER]",
2009 "Thread information\n"
2010 "Thread CPU usage\n"
2011 "Display filter (rwtexb)\n")
2015 int ret
= CMD_SUCCESS
;
2018 const char *filter
=
2019 argv_find(argv
, argc
, "FILTER", &idx
) ? argv
[idx
]->arg
: "";
2021 snprintf(line
, sizeof(line
), "do show thread cpu %s\n", filter
);
2022 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2023 if (vtysh_client
[i
].fd
>= 0) {
2024 fprintf(stdout
, "Thread statistics for %s:\n",
2025 vtysh_client
[i
].name
);
2026 ret
= vtysh_client_execute(&vtysh_client
[i
], line
,
2028 fprintf(stdout
, "\n");
2033 DEFUN (vtysh_show_work_queues
,
2034 vtysh_show_work_queues_cmd
,
2037 "Work Queue information\n")
2040 int ret
= CMD_SUCCESS
;
2041 char line
[] = "do show work-queues\n";
2043 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2044 if (vtysh_client
[i
].fd
>= 0) {
2045 fprintf(stdout
, "Work queue statistics for %s:\n",
2046 vtysh_client
[i
].name
);
2047 ret
= vtysh_client_execute(&vtysh_client
[i
], line
,
2049 fprintf(stdout
, "\n");
2055 DEFUN (vtysh_show_work_queues_daemon
,
2056 vtysh_show_work_queues_daemon_cmd
,
2057 "show work-queues <zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pbrd>",
2059 "Work Queue information\n"
2060 "For the zebra daemon\n"
2061 "For the rip daemon\n"
2062 "For the ripng daemon\n"
2063 "For the ospf daemon\n"
2064 "For the ospfv6 daemon\n"
2065 "For the bgp daemon\n"
2066 "For the isis daemon\n"
2067 "For the pbr daemon\n")
2069 int idx_protocol
= 2;
2071 int ret
= CMD_SUCCESS
;
2073 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
2074 if (strmatch(vtysh_client
[i
].name
, argv
[idx_protocol
]->text
))
2078 ret
= vtysh_client_execute(&vtysh_client
[i
], "show work-queues\n",
2084 DEFUNSH(VTYSH_ZEBRA
, vtysh_link_params
, vtysh_link_params_cmd
, "link-params",
2087 vty
->node
= LINK_PARAMS_NODE
;
2091 DEFUNSH(VTYSH_ZEBRA
, exit_link_params
, exit_link_params_cmd
, "exit-link-params",
2092 "Exit from Link Params configuration node\n")
2094 if (vty
->node
== LINK_PARAMS_NODE
)
2095 vty
->node
= INTERFACE_NODE
;
2099 static int show_per_daemon(const char *line
, const char *headline
)
2102 int ret
= CMD_SUCCESS
;
2104 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2105 if (vtysh_client
[i
].fd
>= 0) {
2106 fprintf(outputfile
, headline
, vtysh_client
[i
].name
);
2107 ret
= vtysh_client_execute(&vtysh_client
[i
], line
,
2109 fprintf(stdout
, "\n");
2115 DEFUNSH_HIDDEN (0x00,
2117 vtysh_debug_all_cmd
,
2121 "Toggle all debugs on or off\n")
2126 DEFUN (vtysh_show_debugging
,
2127 vtysh_show_debugging_cmd
,
2132 return show_per_daemon("do show debugging\n", "");
2135 DEFUN (vtysh_show_debugging_hashtable
,
2136 vtysh_show_debugging_hashtable_cmd
,
2137 "show debugging hashtable [statistics]",
2140 "Statistics about hash tables\n"
2141 "Statistics about hash tables\n")
2143 fprintf(stdout
, "\n");
2145 "Load factor (LF) - average number of elements across all buckets\n");
2147 "Full load factor (FLF) - average number of elements across full buckets\n\n");
2149 "Standard deviation (SD) is calculated for both the LF and FLF\n");
2151 "and indicates the typical deviation of bucket chain length\n");
2152 fprintf(stdout
, "from the value in the corresponding load factor.\n\n");
2154 return show_per_daemon("do show debugging hashtable\n",
2155 "Hashtable statistics for %s:\n");
2159 DEFUN (vtysh_show_memory
,
2160 vtysh_show_memory_cmd
,
2163 "Memory statistics\n")
2165 return show_per_daemon("show memory\n", "Memory statistics for %s:\n");
2168 DEFUN (vtysh_show_modules
,
2169 vtysh_show_modules_cmd
,
2174 return show_per_daemon("show modules\n",
2175 "Module information for %s:\n");
2178 /* Logging commands. */
2179 DEFUN (vtysh_show_logging
,
2180 vtysh_show_logging_cmd
,
2183 "Show current logging configuration\n")
2185 return show_per_daemon("do show logging\n",
2186 "Logging configuration for %s:\n");
2189 DEFUNSH(VTYSH_ALL
, vtysh_log_stdout
, vtysh_log_stdout_cmd
, "log stdout",
2191 "Set stdout logging level\n")
2196 DEFUNSH(VTYSH_ALL
, vtysh_log_stdout_level
, vtysh_log_stdout_level_cmd
,
2197 "log stdout <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2199 "Set stdout logging level\n" LOG_LEVEL_DESC
)
2204 DEFUNSH(VTYSH_ALL
, no_vtysh_log_stdout
, no_vtysh_log_stdout_cmd
,
2205 "no log stdout [LEVEL]", NO_STR
2207 "Cancel logging to stdout\n"
2213 DEFUNSH(VTYSH_ALL
, vtysh_log_file
, vtysh_log_file_cmd
, "log file FILENAME",
2216 "Logging filename\n")
2221 DEFUNSH(VTYSH_ALL
, vtysh_log_file_level
, vtysh_log_file_level_cmd
,
2222 "log file FILENAME <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2225 "Logging filename\n" LOG_LEVEL_DESC
)
2230 DEFUNSH(VTYSH_ALL
, no_vtysh_log_file
, no_vtysh_log_file_cmd
,
2231 "no log file [FILENAME [LEVEL]]", NO_STR
2233 "Cancel logging to file\n"
2234 "Logging file name\n"
2240 DEFUNSH(VTYSH_ALL
, vtysh_log_monitor
, vtysh_log_monitor_cmd
,
2241 "log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
2243 "Set terminal line (monitor) logging level\n" LOG_LEVEL_DESC
)
2248 DEFUNSH(VTYSH_ALL
, no_vtysh_log_monitor
, no_vtysh_log_monitor_cmd
,
2249 "no log monitor [LEVEL]", NO_STR
2251 "Disable terminal line (monitor) logging\n"
2257 DEFUNSH(VTYSH_ALL
, vtysh_log_syslog
, vtysh_log_syslog_cmd
,
2258 "log syslog [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
2260 "Set syslog logging level\n" LOG_LEVEL_DESC
)
2265 DEFUNSH(VTYSH_ALL
, no_vtysh_log_syslog
, no_vtysh_log_syslog_cmd
,
2266 "no log syslog [LEVEL]", NO_STR
2268 "Cancel logging to syslog\n"
2274 DEFUNSH(VTYSH_ALL
, vtysh_log_facility
, vtysh_log_facility_cmd
,
2275 "log facility <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>",
2277 "Facility parameter for syslog messages\n" LOG_FACILITY_DESC
)
2282 DEFUNSH(VTYSH_ALL
, no_vtysh_log_facility
, no_vtysh_log_facility_cmd
,
2283 "no log facility [FACILITY]", NO_STR
2285 "Reset syslog facility to default (daemon)\n"
2286 "Syslog facility\n")
2292 VTYSH_ALL
, vtysh_log_trap
, vtysh_log_trap_cmd
,
2293 "log trap <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2295 "(Deprecated) Set logging level and default for all destinations\n" LOG_LEVEL_DESC
)
2300 DEFUNSH_DEPRECATED(VTYSH_ALL
, no_vtysh_log_trap
, no_vtysh_log_trap_cmd
,
2301 "no log trap [LEVEL]", NO_STR
2303 "Permit all logging information\n"
2309 DEFUNSH(VTYSH_ALL
, vtysh_log_record_priority
, vtysh_log_record_priority_cmd
,
2310 "log record-priority",
2312 "Log the priority of the message within the message\n")
2317 DEFUNSH(VTYSH_ALL
, no_vtysh_log_record_priority
,
2318 no_vtysh_log_record_priority_cmd
, "no log record-priority", NO_STR
2320 "Do not log the priority of the message within the message\n")
2325 DEFUNSH(VTYSH_ALL
, vtysh_log_timestamp_precision
,
2326 vtysh_log_timestamp_precision_cmd
, "log timestamp precision (0-6)",
2328 "Timestamp configuration\n"
2329 "Set the timestamp precision\n"
2330 "Number of subsecond digits\n")
2335 DEFUNSH(VTYSH_ALL
, no_vtysh_log_timestamp_precision
,
2336 no_vtysh_log_timestamp_precision_cmd
, "no log timestamp precision",
2339 "Timestamp configuration\n"
2340 "Reset the timestamp precision to the default value of 0\n")
2345 DEFUNSH(VTYSH_ALL
, vtysh_service_password_encrypt
,
2346 vtysh_service_password_encrypt_cmd
, "service password-encryption",
2347 "Set up miscellaneous service\n"
2348 "Enable encrypted passwords\n")
2353 DEFUNSH(VTYSH_ALL
, no_vtysh_service_password_encrypt
,
2354 no_vtysh_service_password_encrypt_cmd
, "no service password-encryption",
2356 "Set up miscellaneous service\n"
2357 "Enable encrypted passwords\n")
2362 DEFUNSH(VTYSH_ALL
, vtysh_config_password
, vtysh_password_cmd
,
2363 "password [(8-8)] LINE",
2364 "Assign the terminal connection password\n"
2365 "Specifies a HIDDEN password will follow\n"
2366 "The password string\n")
2371 DEFUNSH(VTYSH_ALL
, vtysh_config_enable_password
, vtysh_enable_password_cmd
,
2372 "enable password [(8-8)] LINE",
2373 "Modify enable password parameters\n"
2374 "Assign the privileged level password\n"
2375 "Specifies a HIDDEN password will follow\n"
2376 "The 'enable' password string\n")
2381 DEFUNSH(VTYSH_ALL
, no_vtysh_config_enable_password
,
2382 no_vtysh_enable_password_cmd
, "no enable password", NO_STR
2383 "Modify enable password parameters\n"
2384 "Assign the privileged level password\n")
2389 DEFUN (vtysh_write_terminal
,
2390 vtysh_write_terminal_cmd
,
2391 "write terminal [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2392 "Write running configuration to memory, network, or terminal\n"
2393 "Write to terminal\n"
2394 "For the zebra daemon\n"
2395 "For the rip daemon\n"
2396 "For the ripng daemon\n"
2397 "For the ospf daemon\n"
2398 "For the ospfv6 daemon\n"
2399 "For the ldpd daemon\n"
2400 "For the bgp daemon\n"
2401 "For the isis daemon\n"
2402 "For the pim daemon\n")
2405 char line
[] = "do write terminal\n";
2406 FILE *fp
= outputfile
;
2408 if (fp
== stdout
&& vtysh_pager_name
) {
2409 fp
= popen(vtysh_pager_name
, "w");
2416 fprintf(outputfile
, "Building configuration...\n");
2417 fprintf(outputfile
, "\nCurrent configuration:\n");
2418 fprintf(outputfile
, "!\n");
2420 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2422 || (strmatch(vtysh_client
[i
].name
, argv
[2]->text
)))
2423 vtysh_client_config(&vtysh_client
[i
], line
);
2425 /* Integrate vtysh specific configuration. */
2426 vtysh_config_write();
2428 vtysh_config_dump(fp
);
2430 if (vtysh_pager_name
&& fp
&& fp
!= outputfile
) {
2432 if (pclose(fp
) == -1) {
2439 fprintf(outputfile
, "end\n");
2443 DEFUN (vtysh_show_running_config
,
2444 vtysh_show_running_config_cmd
,
2445 "show running-config [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2447 "Current operating configuration\n"
2448 "For the zebra daemon\n"
2449 "For the rip daemon\n"
2450 "For the ripng daemon\n"
2451 "For the ospf daemon\n"
2452 "For the ospfv6 daemon\n"
2453 "For the ldp daemon\n"
2454 "For the bgp daemon\n"
2455 "For the isis daemon\n"
2456 "For the pim daemon\n")
2458 return vtysh_write_terminal(self
, vty
, argc
, argv
);
2461 DEFUN (vtysh_integrated_config
,
2462 vtysh_integrated_config_cmd
,
2463 "service integrated-vtysh-config",
2464 "Set up miscellaneous service\n"
2465 "Write configuration into integrated file\n")
2467 vtysh_write_integrated
= WRITE_INTEGRATED_YES
;
2471 DEFUN (no_vtysh_integrated_config
,
2472 no_vtysh_integrated_config_cmd
,
2473 "no service integrated-vtysh-config",
2475 "Set up miscellaneous service\n"
2476 "Write configuration into integrated file\n")
2478 vtysh_write_integrated
= WRITE_INTEGRATED_NO
;
2482 static void backup_config_file(const char *fbackup
)
2484 char *integrate_sav
= NULL
;
2486 integrate_sav
= malloc(strlen(fbackup
) + strlen(CONF_BACKUP_EXT
) + 1);
2487 strcpy(integrate_sav
, fbackup
);
2488 strcat(integrate_sav
, CONF_BACKUP_EXT
);
2490 /* Move current configuration file to backup config file. */
2491 unlink(integrate_sav
);
2492 rename(fbackup
, integrate_sav
);
2493 free(integrate_sav
);
2496 int vtysh_write_config_integrated(void)
2499 char line
[] = "do write terminal\n";
2502 struct passwd
*pwentry
;
2503 struct group
*grentry
;
2509 fprintf(stdout
, "Building Configuration...\n");
2511 backup_config_file(frr_config
);
2512 fp
= fopen(frr_config
, "w");
2515 "%% Error: failed to open configuration file %s: %s\n",
2516 frr_config
, safe_strerror(errno
));
2517 return CMD_WARNING_CONFIG_FAILED
;
2521 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2522 vtysh_client_config(&vtysh_client
[i
], line
);
2524 vtysh_config_write();
2525 vtysh_config_dump(fp
);
2527 if (fchmod(fd
, CONFIGFILE_MASK
) != 0) {
2528 printf("%% Warning: can't chmod configuration file %s: %s\n",
2529 frr_config
, safe_strerror(errno
));
2534 pwentry
= getpwnam(FRR_USER
);
2536 uid
= pwentry
->pw_uid
;
2538 printf("%% Warning: could not look up user \"%s\"\n", FRR_USER
);
2543 grentry
= getgrnam(FRR_GROUP
);
2545 gid
= grentry
->gr_gid
;
2547 printf("%% Warning: could not look up group \"%s\"\n",
2553 if (!fstat(fd
, &st
)) {
2554 if (st
.st_uid
== uid
)
2556 if (st
.st_gid
== gid
)
2558 if ((uid
!= (uid_t
)-1 || gid
!= (gid_t
)-1)
2559 && fchown(fd
, uid
, gid
)) {
2560 printf("%% Warning: can't chown configuration file %s: %s\n",
2561 frr_config
, safe_strerror(errno
));
2565 printf("%% Warning: stat() failed on %s: %s\n", frr_config
,
2566 safe_strerror(errno
));
2572 printf("Integrated configuration saved to %s\n", frr_config
);
2580 static bool want_config_integrated(void)
2584 switch (vtysh_write_integrated
) {
2585 case WRITE_INTEGRATED_UNSPECIFIED
:
2586 if (stat(frr_config
, &s
) && errno
== ENOENT
)
2589 case WRITE_INTEGRATED_NO
:
2591 case WRITE_INTEGRATED_YES
:
2597 DEFUN (vtysh_write_memory
,
2598 vtysh_write_memory_cmd
,
2599 "write [<memory|file>]",
2600 "Write running configuration to memory, network, or terminal\n"
2601 "Write configuration to the file (same as write file)\n"
2602 "Write configuration to the file (same as write memory)\n")
2604 int ret
= CMD_SUCCESS
;
2605 char line
[] = "do write memory\n";
2609 "Note: this version of vtysh never writes vtysh.conf\n");
2611 /* If integrated frr.conf explicitely set. */
2612 if (want_config_integrated()) {
2613 ret
= CMD_WARNING_CONFIG_FAILED
;
2614 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2615 if (vtysh_client
[i
].flag
== VTYSH_WATCHFRR
)
2617 if (i
< array_size(vtysh_client
) && vtysh_client
[i
].fd
!= -1)
2618 ret
= vtysh_client_execute(&vtysh_client
[i
],
2619 "do write integrated",
2623 * If watchfrr returns CMD_WARNING_CONFIG_FAILED this means
2624 * that it could not write the config, but additionally
2625 * indicates that we should not try either
2627 if (ret
!= CMD_SUCCESS
&& ret
!= CMD_WARNING_CONFIG_FAILED
) {
2628 printf("\nWarning: attempting direct configuration write without "
2629 "watchfrr.\nFile permissions and ownership may be "
2630 "incorrect, or write may fail.\n\n");
2631 ret
= vtysh_write_config_integrated();
2636 fprintf(outputfile
, "Building Configuration...\n");
2638 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2639 ret
= vtysh_client_execute(&vtysh_client
[i
], line
, outputfile
);
2644 DEFUN (vtysh_copy_running_config
,
2645 vtysh_copy_running_config_cmd
,
2646 "copy running-config startup-config",
2647 "Copy from one file to another\n"
2648 "Copy from current system configuration\n"
2649 "Copy to startup configuration\n")
2651 return vtysh_write_memory(self
, vty
, argc
, argv
);
2654 DEFUN (vtysh_terminal_length
,
2655 vtysh_terminal_length_cmd
,
2656 "terminal length (0-512)",
2657 "Set terminal line parameters\n"
2658 "Set number of lines on a screen\n"
2659 "Number of lines on screen (0 for no pausing)\n")
2663 char *endptr
= NULL
;
2664 char default_pager
[10];
2666 lines
= strtol(argv
[idx_number
]->arg
, &endptr
, 10);
2667 if (lines
< 0 || lines
> 512 || *endptr
!= '\0') {
2668 fprintf(outputfile
, "length is malformed\n");
2672 if (vtysh_pager_name
) {
2673 free(vtysh_pager_name
);
2674 vtysh_pager_name
= NULL
;
2678 snprintf(default_pager
, 10, "more -%i", lines
);
2679 vtysh_pager_name
= strdup(default_pager
);
2685 DEFUN (vtysh_terminal_no_length
,
2686 vtysh_terminal_no_length_cmd
,
2687 "terminal no length",
2688 "Set terminal line parameters\n"
2690 "Set number of lines on a screen\n")
2692 if (vtysh_pager_name
) {
2693 free(vtysh_pager_name
);
2694 vtysh_pager_name
= NULL
;
2701 DEFUN (vtysh_show_daemons
,
2702 vtysh_show_daemons_cmd
,
2705 "Show list of running daemons\n")
2709 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2710 if (vtysh_client
[i
].fd
>= 0)
2711 fprintf(outputfile
, " %s", vtysh_client
[i
].name
);
2712 fprintf(outputfile
, "\n");
2717 /* Execute command in child process. */
2718 static void execute_command(const char *command
, int argc
, const char *arg1
,
2728 /* Failure of fork(). */
2729 fprintf(stderr
, "Can't fork: %s\n", safe_strerror(errno
));
2731 } else if (pid
== 0) {
2732 /* This is child process. */
2735 execlp(command
, command
, (const char *)NULL
);
2738 execlp(command
, command
, arg1
, (const char *)NULL
);
2741 execlp(command
, command
, arg1
, arg2
,
2742 (const char *)NULL
);
2746 /* When execlp suceed, this part is not executed. */
2747 fprintf(stderr
, "Can't execute %s: %s\n", command
,
2748 safe_strerror(errno
));
2751 /* This is parent. */
2753 wait4(pid
, &status
, 0, NULL
);
2761 "Send echo messages\n"
2762 "Ping destination address or hostname\n")
2766 argv_find(argv
, argc
, "WORD", &idx
);
2767 execute_command("ping", 1, argv
[idx
]->arg
, NULL
);
2771 ALIAS(vtysh_ping
, vtysh_ping_ip_cmd
, "ping ip WORD",
2772 "Send echo messages\n"
2774 "Ping destination address or hostname\n")
2776 DEFUN (vtysh_traceroute
,
2777 vtysh_traceroute_cmd
,
2779 "Trace route to destination\n"
2780 "Trace route to destination address or hostname\n")
2784 argv_find(argv
, argc
, "WORD", &idx
);
2785 execute_command("traceroute", 1, argv
[idx
]->arg
, NULL
);
2789 ALIAS(vtysh_traceroute
, vtysh_traceroute_ip_cmd
, "traceroute ip WORD",
2790 "Trace route to destination\n"
2792 "Trace route to destination address or hostname\n")
2794 DEFUN (vtysh_mtrace
,
2797 "Multicast trace route to multicast source\n"
2798 "Multicast trace route to multicast source address\n")
2802 argv_find(argv
, argc
, "WORD", &idx
);
2803 execute_command("mtracebis", 1, argv
[idx
]->arg
, NULL
);
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 DEFUN_HIDDEN(show_cli_graph_vtysh
,
2962 show_cli_graph_vtysh_cmd
,
2966 "Dump current command space as DOT graph\n")
2968 struct cmd_node
*cn
= vector_slot(cmdvec
, vty
->node
);
2969 char *dot
= cmd_graph_dump_dot(cn
->cmdgraph
);
2971 vty_out(vty
, "%s\n", dot
);
2972 XFREE(MTYPE_TMP
, dot
);
2976 static void vtysh_install_default(enum node_type node
)
2978 install_element(node
, &config_list_cmd
);
2979 install_element(node
, &find_cmd
);
2980 install_element(node
, &show_cli_graph_vtysh_cmd
);
2981 install_element(node
, &vtysh_output_file_cmd
);
2982 install_element(node
, &no_vtysh_output_file_cmd
);
2985 /* Making connection to protocol daemon. */
2986 static int vtysh_connect(struct vtysh_client
*vclient
)
2990 struct sockaddr_un addr
;
2994 if (!vclient
->path
[0])
2995 snprintf(vclient
->path
, sizeof(vclient
->path
), "%s/%s.vty",
2996 vtydir
, vclient
->name
);
2997 path
= vclient
->path
;
2999 /* Stat socket to see if we have permission to access it. */
3000 ret
= stat(path
, &s_stat
);
3001 if (ret
< 0 && errno
!= ENOENT
) {
3002 fprintf(stderr
, "vtysh_connect(%s): stat = %s\n", path
,
3003 safe_strerror(errno
));
3008 if (!S_ISSOCK(s_stat
.st_mode
)) {
3009 fprintf(stderr
, "vtysh_connect(%s): Not a socket\n",
3015 sock
= socket(AF_UNIX
, SOCK_STREAM
, 0);
3018 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", path
,
3019 safe_strerror(errno
));
3024 memset(&addr
, 0, sizeof(struct sockaddr_un
));
3025 addr
.sun_family
= AF_UNIX
;
3026 strlcpy(addr
.sun_path
, path
, sizeof(addr
.sun_path
));
3027 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
3028 len
= addr
.sun_len
= SUN_LEN(&addr
);
3030 len
= sizeof(addr
.sun_family
) + strlen(addr
.sun_path
);
3031 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
3033 ret
= connect(sock
, (struct sockaddr
*)&addr
, len
);
3036 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", path
,
3037 safe_strerror(errno
));
3047 /* Return true if str ends with suffix, else return false */
3048 static int ends_with(const char *str
, const char *suffix
)
3050 if (!str
|| !suffix
)
3052 size_t lenstr
= strlen(str
);
3053 size_t lensuffix
= strlen(suffix
);
3054 if (lensuffix
> lenstr
)
3056 return strncmp(str
+ lenstr
- lensuffix
, suffix
, lensuffix
) == 0;
3059 static void vtysh_client_sorted_insert(struct vtysh_client
*head_client
,
3060 struct vtysh_client
*client
)
3062 struct vtysh_client
*prev_node
, *current_node
;
3064 prev_node
= head_client
;
3065 current_node
= head_client
->next
;
3066 while (current_node
) {
3067 if (strcmp(current_node
->path
, client
->path
) > 0)
3070 prev_node
= current_node
;
3071 current_node
= current_node
->next
;
3073 client
->next
= current_node
;
3074 prev_node
->next
= client
;
3077 #define MAXIMUM_INSTANCES 10
3079 static void vtysh_update_all_insances(struct vtysh_client
*head_client
)
3081 struct vtysh_client
*client
;
3083 struct dirent
*file
;
3086 if (head_client
->flag
!= VTYSH_OSPFD
)
3089 /* ls vty_sock_dir and look for all files ending in .vty */
3090 dir
= opendir(vtydir
);
3092 while ((file
= readdir(dir
)) != NULL
) {
3093 if (begins_with(file
->d_name
, "ospfd-")
3094 && ends_with(file
->d_name
, ".vty")) {
3095 if (n
== MAXIMUM_INSTANCES
) {
3097 "Parsing %s, client limit(%d) reached!\n",
3101 client
= (struct vtysh_client
*)malloc(
3102 sizeof(struct vtysh_client
));
3104 client
->name
= "ospfd";
3105 client
->flag
= VTYSH_OSPFD
;
3106 snprintf(client
->path
, sizeof(client
->path
),
3107 "%s/%s", vtydir
, file
->d_name
);
3108 client
->next
= NULL
;
3109 vtysh_client_sorted_insert(head_client
, client
);
3117 static int vtysh_connect_all_instances(struct vtysh_client
*head_client
)
3119 struct vtysh_client
*client
;
3122 vtysh_update_all_insances(head_client
);
3124 client
= head_client
->next
;
3126 if (vtysh_connect(client
) == 0)
3128 client
= client
->next
;
3134 int vtysh_connect_all(const char *daemon_name
)
3140 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
3142 || !strcmp(daemon_name
, vtysh_client
[i
].name
)) {
3144 if (vtysh_connect(&vtysh_client
[i
]) == 0)
3147 rc
+= vtysh_connect_all_instances(&vtysh_client
[i
]);
3151 fprintf(stderr
, "Error: no daemons match name %s!\n",
3156 /* To disable readline's filename completion. */
3157 static char *vtysh_completion_entry_function(const char *ignore
,
3163 void vtysh_readline_init(void)
3165 /* readline related settings. */
3167 rl_bind_key('?', (rl_command_func_t
*)vtysh_rl_describe
);
3168 rl_completion_entry_function
= vtysh_completion_entry_function
;
3169 rl_attempted_completion_function
=
3170 (rl_completion_func_t
*)new_completion
;
3173 char *vtysh_prompt(void)
3175 static char buf
[100];
3177 snprintf(buf
, sizeof buf
, cmd_prompt(vty
->node
), cmd_hostname_get());
3181 static void vtysh_ac_line(void *arg
, const char *line
)
3185 for (i
= 0; i
< vector_active(comps
); i
++)
3186 if (!strcmp(line
, (char *)vector_slot(comps
, i
)))
3188 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, line
));
3191 static void vtysh_autocomplete(vector comps
, struct cmd_token
*token
)
3196 snprintf(accmd
, sizeof(accmd
), "autocomplete %d %s %s", token
->type
,
3197 token
->text
, token
->varname
? token
->varname
: "-");
3199 for (i
= 0; i
< array_size(vtysh_client
); i
++)
3200 vtysh_client_run_all(&vtysh_client
[i
], accmd
, 1, NULL
,
3201 vtysh_ac_line
, comps
);
3204 static const struct cmd_variable_handler vtysh_var_handler
[] = {
3208 .completions
= vtysh_autocomplete
},
3209 {.completions
= NULL
}};
3213 if (outputfile
!= stdout
)
3217 void vtysh_init_vty(void)
3219 /* Make vty structure. */
3221 vty
->type
= VTY_SHELL
;
3222 vty
->node
= VIEW_NODE
;
3224 /* set default output */
3225 outputfile
= stdout
;
3227 /* Initialize commands. */
3229 cmd_variable_handler_register(vtysh_var_handler
);
3231 /* Install nodes. */
3232 install_node(&bgp_node
, NULL
);
3233 install_node(&rip_node
, NULL
);
3234 install_node(&interface_node
, NULL
);
3235 install_node(&pw_node
, NULL
);
3236 install_node(&link_params_node
, NULL
);
3237 install_node(&logicalrouter_node
, NULL
);
3238 install_node(&vrf_node
, NULL
);
3239 install_node(&nh_group_node
, NULL
);
3240 install_node(&rmap_node
, NULL
);
3241 install_node(&pbr_map_node
, NULL
);
3242 install_node(&zebra_node
, NULL
);
3243 install_node(&bgp_vpnv4_node
, NULL
);
3244 install_node(&bgp_vpnv6_node
, NULL
);
3245 install_node(&bgp_flowspecv4_node
, NULL
);
3246 install_node(&bgp_flowspecv6_node
, NULL
);
3247 install_node(&bgp_ipv4_node
, NULL
);
3248 install_node(&bgp_ipv4m_node
, NULL
);
3249 install_node(&bgp_ipv4l_node
, NULL
);
3250 install_node(&bgp_ipv6_node
, NULL
);
3251 install_node(&bgp_ipv6m_node
, NULL
);
3252 install_node(&bgp_ipv6l_node
, NULL
);
3253 install_node(&bgp_vrf_policy_node
, NULL
);
3254 install_node(&bgp_evpn_node
, NULL
);
3255 install_node(&bgp_evpn_vni_node
, NULL
);
3256 install_node(&bgp_vnc_defaults_node
, NULL
);
3257 install_node(&bgp_vnc_nve_group_node
, NULL
);
3258 install_node(&bgp_vnc_l2_group_node
, NULL
);
3259 install_node(&ospf_node
, NULL
);
3260 install_node(&eigrp_node
, NULL
);
3261 install_node(&babel_node
, NULL
);
3262 install_node(&ripng_node
, NULL
);
3263 install_node(&ospf6_node
, NULL
);
3264 install_node(&ldp_node
, NULL
);
3265 install_node(&ldp_ipv4_node
, NULL
);
3266 install_node(&ldp_ipv6_node
, NULL
);
3267 install_node(&ldp_ipv4_iface_node
, NULL
);
3268 install_node(&ldp_ipv6_iface_node
, NULL
);
3269 install_node(&ldp_l2vpn_node
, NULL
);
3270 install_node(&ldp_pseudowire_node
, NULL
);
3271 install_node(&keychain_node
, NULL
);
3272 install_node(&keychain_key_node
, NULL
);
3273 install_node(&isis_node
, NULL
);
3274 install_node(&vty_node
, NULL
);
3275 #if defined(HAVE_RPKI)
3276 install_node(&rpki_node
, NULL
);
3279 struct cmd_node
*node
;
3280 for (unsigned int i
= 0; i
< vector_active(cmdvec
); i
++) {
3281 node
= vector_slot(cmdvec
, i
);
3282 if (!node
|| node
->node
== VIEW_NODE
)
3284 vtysh_install_default(node
->node
);
3287 install_element(VIEW_NODE
, &vtysh_enable_cmd
);
3288 install_element(ENABLE_NODE
, &vtysh_config_terminal_cmd
);
3289 install_element(ENABLE_NODE
, &vtysh_disable_cmd
);
3291 /* "exit" command. */
3292 install_element(VIEW_NODE
, &vtysh_exit_all_cmd
);
3293 install_element(CONFIG_NODE
, &vtysh_exit_all_cmd
);
3294 install_element(VIEW_NODE
, &vtysh_quit_all_cmd
);
3295 install_element(CONFIG_NODE
, &vtysh_quit_all_cmd
);
3296 install_element(RIP_NODE
, &vtysh_exit_ripd_cmd
);
3297 install_element(RIP_NODE
, &vtysh_quit_ripd_cmd
);
3298 install_element(RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
3299 install_element(RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
3300 install_element(OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
3301 install_element(OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
3302 install_element(EIGRP_NODE
, &vtysh_exit_eigrpd_cmd
);
3303 install_element(EIGRP_NODE
, &vtysh_quit_eigrpd_cmd
);
3304 install_element(BABEL_NODE
, &vtysh_exit_babeld_cmd
);
3305 install_element(BABEL_NODE
, &vtysh_quit_babeld_cmd
);
3306 install_element(OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
3307 install_element(OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
3308 #if defined(HAVE_LDPD)
3309 install_element(LDP_NODE
, &vtysh_exit_ldpd_cmd
);
3310 install_element(LDP_NODE
, &vtysh_quit_ldpd_cmd
);
3311 install_element(LDP_IPV4_NODE
, &vtysh_exit_ldpd_cmd
);
3312 install_element(LDP_IPV4_NODE
, &vtysh_quit_ldpd_cmd
);
3313 install_element(LDP_IPV4_NODE
, &ldp_exit_address_family_cmd
);
3314 install_element(LDP_IPV6_NODE
, &vtysh_exit_ldpd_cmd
);
3315 install_element(LDP_IPV6_NODE
, &vtysh_quit_ldpd_cmd
);
3316 install_element(LDP_IPV6_NODE
, &ldp_exit_address_family_cmd
);
3317 install_element(LDP_IPV4_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3318 install_element(LDP_IPV4_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3319 install_element(LDP_IPV6_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3320 install_element(LDP_IPV6_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3321 install_element(LDP_L2VPN_NODE
, &vtysh_exit_ldpd_cmd
);
3322 install_element(LDP_L2VPN_NODE
, &vtysh_quit_ldpd_cmd
);
3323 install_element(LDP_PSEUDOWIRE_NODE
, &vtysh_exit_ldpd_cmd
);
3324 install_element(LDP_PSEUDOWIRE_NODE
, &vtysh_quit_ldpd_cmd
);
3326 install_element(BGP_NODE
, &vtysh_exit_bgpd_cmd
);
3327 install_element(BGP_NODE
, &vtysh_quit_bgpd_cmd
);
3328 install_element(BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
3329 install_element(BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
3330 install_element(BGP_VPNV6_NODE
, &vtysh_exit_bgpd_cmd
);
3331 install_element(BGP_VPNV6_NODE
, &vtysh_quit_bgpd_cmd
);
3332 install_element(BGP_FLOWSPECV4_NODE
, &vtysh_exit_bgpd_cmd
);
3333 install_element(BGP_FLOWSPECV4_NODE
, &vtysh_quit_bgpd_cmd
);
3334 install_element(BGP_FLOWSPECV6_NODE
, &vtysh_exit_bgpd_cmd
);
3335 install_element(BGP_FLOWSPECV6_NODE
, &vtysh_quit_bgpd_cmd
);
3336 install_element(BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
3337 install_element(BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
3338 install_element(BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
3339 install_element(BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
3340 install_element(BGP_IPV4L_NODE
, &vtysh_exit_bgpd_cmd
);
3341 install_element(BGP_IPV4L_NODE
, &vtysh_quit_bgpd_cmd
);
3342 install_element(BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
3343 install_element(BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
3344 install_element(BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
3345 install_element(BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
3346 install_element(BGP_EVPN_NODE
, &vtysh_quit_bgpd_cmd
);
3347 install_element(BGP_EVPN_NODE
, &vtysh_exit_bgpd_cmd
);
3348 install_element(BGP_EVPN_VNI_NODE
, &vtysh_exit_bgpd_cmd
);
3349 install_element(BGP_EVPN_VNI_NODE
, &vtysh_quit_bgpd_cmd
);
3350 install_element(BGP_IPV6L_NODE
, &vtysh_exit_bgpd_cmd
);
3351 install_element(BGP_IPV6L_NODE
, &vtysh_quit_bgpd_cmd
);
3352 #if defined(ENABLE_BGP_VNC)
3353 install_element(BGP_VRF_POLICY_NODE
, &vtysh_exit_bgpd_cmd
);
3354 install_element(BGP_VRF_POLICY_NODE
, &vtysh_quit_bgpd_cmd
);
3355 install_element(BGP_VNC_DEFAULTS_NODE
, &vtysh_exit_bgpd_cmd
);
3356 install_element(BGP_VNC_DEFAULTS_NODE
, &vtysh_quit_bgpd_cmd
);
3357 install_element(BGP_VNC_NVE_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3358 install_element(BGP_VNC_NVE_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3359 install_element(BGP_VNC_L2_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3360 install_element(BGP_VNC_L2_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3362 install_element(ISIS_NODE
, &vtysh_exit_isisd_cmd
);
3363 install_element(ISIS_NODE
, &vtysh_quit_isisd_cmd
);
3364 install_element(KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
3365 install_element(KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
3366 install_element(KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
3367 install_element(KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
3368 install_element(RMAP_NODE
, &vtysh_exit_rmap_cmd
);
3369 install_element(RMAP_NODE
, &vtysh_quit_rmap_cmd
);
3370 install_element(PBRMAP_NODE
, &vtysh_exit_pbr_map_cmd
);
3371 install_element(PBRMAP_NODE
, &vtysh_quit_pbr_map_cmd
);
3372 install_element(VTY_NODE
, &vtysh_exit_line_vty_cmd
);
3373 install_element(VTY_NODE
, &vtysh_quit_line_vty_cmd
);
3375 /* "end" command. */
3376 install_element(CONFIG_NODE
, &vtysh_end_all_cmd
);
3377 install_element(ENABLE_NODE
, &vtysh_end_all_cmd
);
3378 install_element(RIP_NODE
, &vtysh_end_all_cmd
);
3379 install_element(RIPNG_NODE
, &vtysh_end_all_cmd
);
3380 install_element(OSPF_NODE
, &vtysh_end_all_cmd
);
3381 install_element(EIGRP_NODE
, &vtysh_end_all_cmd
);
3382 install_element(BABEL_NODE
, &vtysh_end_all_cmd
);
3383 install_element(OSPF6_NODE
, &vtysh_end_all_cmd
);
3384 install_element(LDP_NODE
, &vtysh_end_all_cmd
);
3385 install_element(LDP_IPV4_NODE
, &vtysh_end_all_cmd
);
3386 install_element(LDP_IPV6_NODE
, &vtysh_end_all_cmd
);
3387 install_element(LDP_IPV4_IFACE_NODE
, &vtysh_end_all_cmd
);
3388 install_element(LDP_IPV6_IFACE_NODE
, &vtysh_end_all_cmd
);
3389 install_element(LDP_L2VPN_NODE
, &vtysh_end_all_cmd
);
3390 install_element(LDP_PSEUDOWIRE_NODE
, &vtysh_end_all_cmd
);
3391 install_element(BGP_NODE
, &vtysh_end_all_cmd
);
3392 install_element(BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
3393 install_element(BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
3394 install_element(BGP_IPV4L_NODE
, &vtysh_end_all_cmd
);
3395 install_element(BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
3396 install_element(BGP_VPNV6_NODE
, &vtysh_end_all_cmd
);
3397 install_element(BGP_FLOWSPECV4_NODE
, &vtysh_end_all_cmd
);
3398 install_element(BGP_FLOWSPECV6_NODE
, &vtysh_end_all_cmd
);
3399 install_element(BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
3400 install_element(BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
3401 install_element(BGP_IPV6L_NODE
, &vtysh_end_all_cmd
);
3402 install_element(BGP_VRF_POLICY_NODE
, &vtysh_end_all_cmd
);
3403 install_element(BGP_EVPN_NODE
, &vtysh_end_all_cmd
);
3404 install_element(BGP_EVPN_VNI_NODE
, &vtysh_end_all_cmd
);
3405 install_element(BGP_VNC_DEFAULTS_NODE
, &vtysh_end_all_cmd
);
3406 install_element(BGP_VNC_NVE_GROUP_NODE
, &vtysh_end_all_cmd
);
3407 install_element(BGP_VNC_L2_GROUP_NODE
, &vtysh_end_all_cmd
);
3408 install_element(ISIS_NODE
, &vtysh_end_all_cmd
);
3409 install_element(KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
3410 install_element(KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
3411 install_element(RMAP_NODE
, &vtysh_end_all_cmd
);
3412 install_element(PBRMAP_NODE
, &vtysh_end_all_cmd
);
3413 install_element(VTY_NODE
, &vtysh_end_all_cmd
);
3415 install_element(INTERFACE_NODE
, &vtysh_interface_desc_cmd
);
3416 install_element(INTERFACE_NODE
, &vtysh_no_interface_desc_cmd
);
3417 install_element(INTERFACE_NODE
, &vtysh_end_all_cmd
);
3418 install_element(INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
3419 install_element(LINK_PARAMS_NODE
, &exit_link_params_cmd
);
3420 install_element(LINK_PARAMS_NODE
, &vtysh_end_all_cmd
);
3421 install_element(LINK_PARAMS_NODE
, &vtysh_exit_interface_cmd
);
3422 install_element(INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
3424 install_element(PW_NODE
, &vtysh_end_all_cmd
);
3425 install_element(PW_NODE
, &vtysh_exit_interface_cmd
);
3426 install_element(PW_NODE
, &vtysh_quit_interface_cmd
);
3428 install_element(LOGICALROUTER_NODE
, &vtysh_end_all_cmd
);
3430 install_element(CONFIG_NODE
, &vtysh_logicalrouter_cmd
);
3431 install_element(CONFIG_NODE
, &vtysh_no_logicalrouter_cmd
);
3432 install_element(LOGICALROUTER_NODE
, &vtysh_exit_logicalrouter_cmd
);
3433 install_element(LOGICALROUTER_NODE
, &vtysh_quit_logicalrouter_cmd
);
3435 install_element(CONFIG_NODE
, &vtysh_nexthop_group_cmd
);
3436 install_element(NH_GROUP_NODE
, &vtysh_end_all_cmd
);
3437 install_element(NH_GROUP_NODE
, &vtysh_exit_nexthop_group_cmd
);
3438 install_element(NH_GROUP_NODE
, &vtysh_quit_nexthop_group_cmd
);
3440 install_element(VRF_NODE
, &vtysh_end_all_cmd
);
3441 install_element(VRF_NODE
, &vtysh_exit_vrf_cmd
);
3442 install_element(VRF_NODE
, &vtysh_quit_vrf_cmd
);
3444 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
3445 install_element(CONFIG_NODE
, &router_babel_cmd
);
3446 install_element(CONFIG_NODE
, &router_rip_cmd
);
3447 install_element(CONFIG_NODE
, &router_ripng_cmd
);
3448 install_element(CONFIG_NODE
, &router_ospf_cmd
);
3449 install_element(CONFIG_NODE
, &router_ospf6_cmd
);
3450 #if defined(HAVE_LDPD)
3451 install_element(CONFIG_NODE
, &ldp_mpls_ldp_cmd
);
3452 install_element(LDP_NODE
, &ldp_address_family_ipv4_cmd
);
3453 install_element(LDP_NODE
, &ldp_address_family_ipv6_cmd
);
3454 install_element(LDP_IPV4_NODE
, &ldp_interface_ifname_cmd
);
3455 install_element(LDP_IPV6_NODE
, &ldp_interface_ifname_cmd
);
3456 install_element(CONFIG_NODE
, &ldp_l2vpn_word_type_vpls_cmd
);
3457 install_element(LDP_L2VPN_NODE
, &ldp_member_pseudowire_ifname_cmd
);
3459 install_element(CONFIG_NODE
, &router_isis_cmd
);
3460 install_element(CONFIG_NODE
, &router_bgp_cmd
);
3461 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
3462 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
3463 #if defined(ENABLE_BGP_VNC)
3464 install_element(BGP_NODE
, &vnc_vrf_policy_cmd
);
3465 install_element(BGP_NODE
, &vnc_defaults_cmd
);
3466 install_element(BGP_NODE
, &vnc_nve_group_cmd
);
3467 install_element(BGP_NODE
, &vnc_l2_group_cmd
);
3469 install_element(BGP_NODE
, &address_family_ipv4_cmd
);
3470 install_element(BGP_NODE
, &address_family_ipv4_multicast_cmd
);
3471 install_element(BGP_NODE
, &address_family_ipv4_vpn_cmd
);
3472 install_element(BGP_NODE
, &address_family_ipv4_labeled_unicast_cmd
);
3473 install_element(BGP_NODE
, &address_family_ipv6_cmd
);
3474 install_element(BGP_NODE
, &address_family_ipv6_multicast_cmd
);
3475 install_element(BGP_NODE
, &address_family_ipv6_vpn_cmd
);
3476 install_element(BGP_NODE
, &address_family_ipv6_labeled_unicast_cmd
);
3477 install_element(BGP_NODE
, &address_family_evpn_cmd
);
3478 install_element(BGP_NODE
, &address_family_flowspecv4_cmd
);
3479 install_element(BGP_NODE
, &address_family_flowspecv6_cmd
);
3480 #if defined(HAVE_CUMULUS)
3481 install_element(BGP_NODE
, &address_family_evpn2_cmd
);
3483 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
3484 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
3485 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
3486 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
3487 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
3488 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
3489 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
3490 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
3491 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
3492 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
3493 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
3495 #if defined(HAVE_RPKI)
3496 install_element(CONFIG_NODE
, &rpki_cmd
);
3497 install_element(RPKI_NODE
, &rpki_exit_cmd
);
3498 install_element(RPKI_NODE
, &rpki_quit_cmd
);
3499 install_element(RPKI_NODE
, &vtysh_end_all_cmd
);
3503 install_element(BGP_EVPN_NODE
, &bgp_evpn_vni_cmd
);
3504 install_element(BGP_EVPN_VNI_NODE
, &exit_vni_cmd
);
3506 install_element(BGP_VRF_POLICY_NODE
, &exit_vrf_policy_cmd
);
3507 install_element(BGP_VNC_DEFAULTS_NODE
, &exit_vnc_config_cmd
);
3508 install_element(BGP_VNC_NVE_GROUP_NODE
, &exit_vnc_config_cmd
);
3509 install_element(BGP_VNC_L2_GROUP_NODE
, &exit_vnc_config_cmd
);
3511 install_element(CONFIG_NODE
, &key_chain_cmd
);
3512 install_element(CONFIG_NODE
, &vtysh_route_map_cmd
);
3513 install_element(CONFIG_NODE
, &vtysh_pbr_map_cmd
);
3514 install_element(CONFIG_NODE
, &vtysh_no_pbr_map_cmd
);
3515 install_element(CONFIG_NODE
, &vtysh_line_vty_cmd
);
3516 install_element(KEYCHAIN_NODE
, &key_cmd
);
3517 install_element(KEYCHAIN_NODE
, &key_chain_cmd
);
3518 install_element(KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
3519 install_element(CONFIG_NODE
, &vtysh_interface_cmd
);
3520 install_element(CONFIG_NODE
, &vtysh_no_interface_cmd
);
3521 install_element(CONFIG_NODE
, &vtysh_no_interface_vrf_cmd
);
3522 install_element(CONFIG_NODE
, &vtysh_pseudowire_cmd
);
3523 install_element(INTERFACE_NODE
, &vtysh_link_params_cmd
);
3524 install_element(ENABLE_NODE
, &vtysh_show_running_config_cmd
);
3525 install_element(ENABLE_NODE
, &vtysh_copy_running_config_cmd
);
3527 install_element(VRF_NODE
, &exit_vrf_config_cmd
);
3529 install_element(CONFIG_NODE
, &vtysh_vrf_cmd
);
3530 install_element(CONFIG_NODE
, &vtysh_no_vrf_cmd
);
3531 install_element(CONFIG_NODE
, &vtysh_no_nexthop_group_cmd
);
3533 /* "write terminal" command. */
3534 install_element(ENABLE_NODE
, &vtysh_write_terminal_cmd
);
3536 install_element(CONFIG_NODE
, &vtysh_integrated_config_cmd
);
3537 install_element(CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
3539 /* "write memory" command. */
3540 install_element(ENABLE_NODE
, &vtysh_write_memory_cmd
);
3542 install_element(VIEW_NODE
, &vtysh_terminal_length_cmd
);
3543 install_element(VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
3544 install_element(VIEW_NODE
, &vtysh_show_daemons_cmd
);
3546 install_element(VIEW_NODE
, &vtysh_ping_cmd
);
3547 install_element(VIEW_NODE
, &vtysh_ping_ip_cmd
);
3548 install_element(VIEW_NODE
, &vtysh_traceroute_cmd
);
3549 install_element(VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
3550 install_element(VIEW_NODE
, &vtysh_mtrace_cmd
);
3551 install_element(VIEW_NODE
, &vtysh_ping6_cmd
);
3552 install_element(VIEW_NODE
, &vtysh_traceroute6_cmd
);
3553 #if defined(HAVE_SHELL_ACCESS)
3554 install_element(VIEW_NODE
, &vtysh_telnet_cmd
);
3555 install_element(VIEW_NODE
, &vtysh_telnet_port_cmd
);
3556 install_element(VIEW_NODE
, &vtysh_ssh_cmd
);
3558 #if defined(HAVE_SHELL_ACCESS)
3559 install_element(ENABLE_NODE
, &vtysh_start_shell_cmd
);
3560 install_element(ENABLE_NODE
, &vtysh_start_bash_cmd
);
3561 install_element(ENABLE_NODE
, &vtysh_start_zsh_cmd
);
3565 install_element(VIEW_NODE
, &vtysh_show_debugging_cmd
);
3566 install_element(VIEW_NODE
, &vtysh_show_debugging_hashtable_cmd
);
3567 install_element(ENABLE_NODE
, &vtysh_debug_all_cmd
);
3568 install_element(CONFIG_NODE
, &vtysh_debug_all_cmd
);
3570 /* misc lib show commands */
3571 install_element(VIEW_NODE
, &vtysh_show_memory_cmd
);
3572 install_element(VIEW_NODE
, &vtysh_show_modules_cmd
);
3573 install_element(VIEW_NODE
, &vtysh_show_work_queues_cmd
);
3574 install_element(VIEW_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3575 install_element(VIEW_NODE
, &vtysh_show_thread_cmd
);
3578 install_element(VIEW_NODE
, &vtysh_show_logging_cmd
);
3579 install_element(CONFIG_NODE
, &vtysh_log_stdout_cmd
);
3580 install_element(CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
3581 install_element(CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
3582 install_element(CONFIG_NODE
, &vtysh_log_file_cmd
);
3583 install_element(CONFIG_NODE
, &vtysh_log_file_level_cmd
);
3584 install_element(CONFIG_NODE
, &no_vtysh_log_file_cmd
);
3585 install_element(CONFIG_NODE
, &vtysh_log_monitor_cmd
);
3586 install_element(CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
3587 install_element(CONFIG_NODE
, &vtysh_log_syslog_cmd
);
3588 install_element(CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
3589 install_element(CONFIG_NODE
, &vtysh_log_trap_cmd
);
3590 install_element(CONFIG_NODE
, &no_vtysh_log_trap_cmd
);
3591 install_element(CONFIG_NODE
, &vtysh_log_facility_cmd
);
3592 install_element(CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
3593 install_element(CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
3594 install_element(CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
3595 install_element(CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
3596 install_element(CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
3598 install_element(CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
3599 install_element(CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
3601 install_element(CONFIG_NODE
, &vtysh_password_cmd
);
3602 install_element(CONFIG_NODE
, &vtysh_enable_password_cmd
);
3603 install_element(CONFIG_NODE
, &no_vtysh_enable_password_cmd
);