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"
49 DEFINE_MTYPE_STATIC(MVTYSH
, VTYSH_CMD
, "Vtysh cmd copy")
54 /* VTY shell pager name. */
55 char *vtysh_pager_name
= NULL
;
57 /* VTY shell client structure */
62 char path
[MAXPATHLEN
];
63 struct vtysh_client
*next
;
66 /* Some utility functions for working on vtysh-specific vty tasks */
68 static FILE *vty_open_pager(struct vty
*vty
)
73 if (!vtysh_pager_name
)
76 vty
->of_saved
= vty
->of
;
77 vty
->of
= popen(vtysh_pager_name
, "w");
78 if (vty
->of
== NULL
) {
79 vty
->of
= vty
->of_saved
;
89 static int vty_close_pager(struct vty
*vty
)
95 if (pclose(vty
->of
) == -1) {
100 vty
->of
= vty
->of_saved
;
101 vty
->is_paged
= false;
106 void vtysh_pager_init(void)
110 pager_defined
= getenv("VTYSH_PAGER");
113 vtysh_pager_name
= strdup(pager_defined
);
115 vtysh_pager_name
= strdup(VTYSH_PAGER
);
120 struct vtysh_client vtysh_client
[] = {
121 {.fd
= -1, .name
= "zebra", .flag
= VTYSH_ZEBRA
, .next
= NULL
},
122 {.fd
= -1, .name
= "ripd", .flag
= VTYSH_RIPD
, .next
= NULL
},
123 {.fd
= -1, .name
= "ripngd", .flag
= VTYSH_RIPNGD
, .next
= NULL
},
124 {.fd
= -1, .name
= "ospfd", .flag
= VTYSH_OSPFD
, .next
= NULL
},
125 {.fd
= -1, .name
= "ospf6d", .flag
= VTYSH_OSPF6D
, .next
= NULL
},
126 {.fd
= -1, .name
= "ldpd", .flag
= VTYSH_LDPD
, .next
= NULL
},
127 {.fd
= -1, .name
= "bgpd", .flag
= VTYSH_BGPD
, .next
= NULL
},
128 {.fd
= -1, .name
= "isisd", .flag
= VTYSH_ISISD
, .next
= NULL
},
129 {.fd
= -1, .name
= "pimd", .flag
= VTYSH_PIMD
, .next
= NULL
},
130 {.fd
= -1, .name
= "nhrpd", .flag
= VTYSH_NHRPD
, .next
= NULL
},
131 {.fd
= -1, .name
= "eigrpd", .flag
= VTYSH_EIGRPD
, .next
= NULL
},
132 {.fd
= -1, .name
= "babeld", .flag
= VTYSH_BABELD
, .next
= NULL
},
133 {.fd
= -1, .name
= "sharpd", .flag
= VTYSH_SHARPD
, .next
= NULL
},
134 {.fd
= -1, .name
= "watchfrr", .flag
= VTYSH_WATCHFRR
, .next
= NULL
},
135 {.fd
= -1, .name
= "pbrd", .flag
= VTYSH_PBRD
, .next
= NULL
},
136 {.fd
= -1, .name
= "staticd", .flag
= VTYSH_STATICD
, .next
= NULL
},
139 enum vtysh_write_integrated vtysh_write_integrated
=
140 WRITE_INTEGRATED_UNSPECIFIED
;
142 static int vtysh_reconnect(struct vtysh_client
*vclient
);
144 static void vclient_close(struct vtysh_client
*vclient
)
146 if (vclient
->fd
>= 0) {
148 "Warning: closing connection to %s because of an I/O error!\n",
151 /* indicate as candidate for reconnect */
152 vclient
->fd
= VTYSH_WAS_ACTIVE
;
157 * Send a CLI command to a client and read the response.
159 * Output will be printed to vty->of. If you want to suppress output, set that
163 * the client to send the command to
166 * the command to send
169 * if non-null, this will be called with each line of output received from
170 * the client passed in the second parameter
173 * optional first argument to pass to callback
178 static int vtysh_client_run(struct vtysh_client
*vclient
, const char *line
,
179 void (*callback
)(void *, const char *), void *cbarg
)
183 char *buf
= stackbuf
;
184 size_t bufsz
= sizeof(stackbuf
);
185 char *bufvalid
, *end
= NULL
;
186 char terminator
[3] = {0, 0, 0};
188 /* vclinet was previously active, try to reconnect */
189 if (vclient
->fd
== VTYSH_WAS_ACTIVE
) {
190 ret
= vtysh_reconnect(vclient
);
198 ret
= write(vclient
->fd
, line
, strlen(line
) + 1);
200 /* close connection and try to reconnect */
201 vclient_close(vclient
);
202 ret
= vtysh_reconnect(vclient
);
206 ret
= write(vclient
->fd
, line
, strlen(line
) + 1);
214 read(vclient
->fd
, bufvalid
, buf
+ bufsz
- bufvalid
- 1);
216 if (nread
< 0 && (errno
== EINTR
|| errno
== EAGAIN
))
220 vty_out(vty
, "vtysh: error reading from %s: %s (%d)",
221 vclient
->name
, safe_strerror(errno
), errno
);
227 /* Null terminate so we may pass this to *printf later. */
231 * We expect string output from daemons, so instead of looking
232 * for the full 3 null bytes of the terminator, we check for
233 * just one instead and assume it is the first byte of the
234 * terminator. The presence of the full terminator is checked
237 if (bufvalid
- buf
>= 4)
238 end
= memmem(bufvalid
- 4, 4, "\0", 1);
241 * calculate # bytes we have, up to & not including the
242 * terminator if present
244 size_t textlen
= (end
? end
: bufvalid
) - buf
;
247 /* feed line processing callback if present */
248 while (callback
&& bufvalid
> buf
&& (end
> buf
|| !end
)) {
249 textlen
= (end
? end
: bufvalid
) - buf
;
250 char *eol
= memchr(buf
, '\n', textlen
);
256 * no line break, end of input, no text left
257 * before end; nothing to write
261 /* no nl, end of input, but some text left */
263 else if (bufvalid
== buf
+ bufsz
- 1) {
265 * no nl, no end of input, no buffer space;
271 if (buf
== stackbuf
) {
272 new = XMALLOC(MTYPE_TMP
, bufsz
);
273 memcpy(new, stackbuf
, sizeof(stackbuf
));
275 new = XREALLOC(MTYPE_TMP
, buf
, bufsz
);
277 bufvalid
= bufvalid
- buf
+ new;
279 /* if end != NULL, we won't be reading more
289 /* eol is at line end now, either \n => \0 or \0\0\0 */
290 assert(eol
&& eol
<= bufvalid
);
293 vty_out(vty
, "%s\n", buf
);
295 callback(cbarg
, buf
);
297 /* shift back data and adjust bufvalid */
298 memmove(buf
, eol
, bufvalid
- eol
);
299 bufvalid
-= eol
- buf
;
304 /* else if no callback, dump raw */
307 vty_out(vty
, "%s", buf
);
308 memmove(buf
, buf
+ textlen
, bufvalid
- buf
- textlen
);
314 * ----------------------------------------------------
315 * At this point `buf` should be in one of two states:
316 * - Empty (i.e. buf == bufvalid)
317 * - Contains up to 4 bytes of the terminator
318 * ----------------------------------------------------
320 assert(((buf
== bufvalid
)
321 || (bufvalid
- buf
<= 4 && buf
[0] == 0x00)));
324 /* if we have the terminator, break */
325 if (end
&& bufvalid
- buf
== 4) {
326 assert(!memcmp(buf
, terminator
, 3));
335 vclient_close(vclient
);
339 XFREE(MTYPE_TMP
, buf
);
343 static int vtysh_client_run_all(struct vtysh_client
*head_client
,
344 const char *line
, int continue_on_err
,
345 void (*callback
)(void *, const char *),
348 struct vtysh_client
*client
;
349 int rc
, rc_all
= CMD_SUCCESS
;
350 int correct_instance
= 0, wrong_instance
= 0;
352 for (client
= head_client
; client
; client
= client
->next
) {
353 rc
= vtysh_client_run(client
, line
, callback
, cbarg
);
354 if (rc
== CMD_NOT_MY_INSTANCE
) {
360 if (rc
!= CMD_SUCCESS
) {
361 if (!continue_on_err
)
366 if (wrong_instance
&& !correct_instance
) {
368 "%% [%s]: command ignored as it targets an instance that is not running\n",
370 rc_all
= CMD_WARNING_CONFIG_FAILED
;
376 * Execute command against all daemons.
379 * where to start walking in the daemon list
382 * the specific command to execute
387 static int vtysh_client_execute(struct vtysh_client
*head_client
,
390 return vtysh_client_run_all(head_client
, line
, 0, NULL
, NULL
);
394 * Retrieve all running config from daemons and parse it with the vtysh config
395 * parser. Returned output is not displayed to the user.
398 * where to start walking in the daemon list
401 * the specific command to execute
403 static void vtysh_client_config(struct vtysh_client
*head_client
, char *line
)
405 /* watchfrr currently doesn't load any config, and has some hardcoded
406 * settings that show up in "show run". skip it here (for now at
407 * least) so we don't get that mangled up in config-write.
409 if (head_client
->flag
== VTYSH_WATCHFRR
)
412 /* suppress output to user */
413 vty
->of_saved
= vty
->of
;
415 vtysh_client_run_all(head_client
, line
, 1, vtysh_config_parse_line
,
417 vty
->of
= vty
->of_saved
;
420 /* Command execution over the vty interface. */
421 static int vtysh_execute_func(const char *line
, int pager
)
426 const struct cmd_element
*cmd
;
428 int saved_ret
, saved_node
;
430 /* Split readline string up into the vector. */
431 vline
= cmd_make_strvec(line
);
437 if (strncmp("en", vector_slot(vline
, 0), 2) == 0) {
438 cmd_free_strvec(vline
);
439 vty_out(vty
, "%% Command not allowed: enable\n");
444 saved_ret
= ret
= cmd_execute(vty
, line
, &cmd
, 1);
445 saved_node
= vty
->node
;
448 * If command doesn't succeeded in current node, try to walk up in node
449 * tree. Changing vty->node is enough to try it just out without actual
450 * walkup in the vtysh.
452 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
453 && ret
!= CMD_WARNING
&& ret
!= CMD_WARNING_CONFIG_FAILED
454 && vty
->node
> CONFIG_NODE
) {
455 vty
->node
= node_parent(vty
->node
);
456 ret
= cmd_execute(vty
, line
, &cmd
, 1);
460 vty
->node
= saved_node
;
463 * If command succeeded in any other node than current (tried > 0) we
464 * have to move into node in the vtysh where it succeeded.
466 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
467 || ret
== CMD_WARNING
) {
468 if ((saved_node
== BGP_VPNV4_NODE
469 || saved_node
== BGP_VPNV6_NODE
470 || saved_node
== BGP_IPV4_NODE
471 || saved_node
== BGP_IPV6_NODE
472 || saved_node
== BGP_FLOWSPECV4_NODE
473 || saved_node
== BGP_FLOWSPECV6_NODE
474 || saved_node
== BGP_IPV4M_NODE
475 || saved_node
== BGP_IPV4L_NODE
476 || saved_node
== BGP_IPV6L_NODE
477 || saved_node
== BGP_IPV6M_NODE
478 || saved_node
== BGP_EVPN_NODE
479 || saved_node
== LDP_IPV4_NODE
480 || saved_node
== LDP_IPV6_NODE
)
482 vtysh_execute("exit-address-family");
483 } else if ((saved_node
== BGP_EVPN_VNI_NODE
) && (tried
== 1)) {
484 vtysh_execute("exit-vni");
485 } else if (saved_node
== BGP_VRF_POLICY_NODE
&& (tried
== 1)) {
486 vtysh_execute("exit-vrf-policy");
487 } else if ((saved_node
== BGP_VNC_DEFAULTS_NODE
488 || saved_node
== BGP_VNC_NVE_GROUP_NODE
489 || saved_node
== BGP_VNC_L2_GROUP_NODE
)
491 vtysh_execute("exit-vnc");
492 } else if (saved_node
== VRF_NODE
&& (tried
== 1)) {
493 vtysh_execute("exit-vrf");
494 } else if ((saved_node
== KEYCHAIN_KEY_NODE
495 || saved_node
== LDP_PSEUDOWIRE_NODE
496 || saved_node
== LDP_IPV4_IFACE_NODE
497 || saved_node
== LDP_IPV6_IFACE_NODE
)
499 vtysh_execute("exit");
501 vtysh_execute("end");
502 vtysh_execute("configure terminal");
506 * If command didn't succeed in any node, continue with return value
513 cmd_free_strvec(vline
);
518 case CMD_WARNING_CONFIG_FAILED
:
519 if (vty
->type
== VTY_FILE
)
520 vty_out(vty
, "Warning...\n");
522 case CMD_ERR_AMBIGUOUS
:
523 vty_out(vty
, "%% Ambiguous command: %s\n", line
);
525 case CMD_ERR_NO_MATCH
:
526 vty_out(vty
, "%% Unknown command: %s\n", line
);
528 case CMD_ERR_INCOMPLETE
:
529 vty_out(vty
, "%% Command incomplete: %s\n", line
);
531 case CMD_SUCCESS_DAEMON
: {
533 * FIXME: Don't open pager for exit commands. popen() causes
534 * problems if exited from vtysh at all. This hack shouldn't
535 * cause any problem but is really ugly.
537 if (pager
&& strncmp(line
, "exit", 4))
540 if (!strcmp(cmd
->string
, "configure terminal")) {
541 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
542 cmd_stat
= vtysh_client_execute(
543 &vtysh_client
[i
], line
);
544 if (cmd_stat
== CMD_WARNING
)
550 vline
= cmd_make_strvec(line
);
555 vty_close_pager(vty
);
559 ret
= cmd_execute_command(vline
, vty
, &cmd
, 1);
560 cmd_free_strvec(vline
);
561 if (ret
!= CMD_SUCCESS_DAEMON
)
563 } else if (cmd
->func
) {
564 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
569 cmd_stat
= CMD_SUCCESS
;
570 struct vtysh_client
*vc
;
571 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
572 if (cmd
->daemon
& vtysh_client
[i
].flag
) {
573 if (vtysh_client
[i
].fd
< 0
574 && (cmd
->daemon
== vtysh_client
[i
].flag
)) {
575 for (vc
= &vtysh_client
[i
]; vc
;
580 if (vtysh_client
[i
].fd
< 0
581 && (cmd
->daemon
== vtysh_client
[i
].flag
)) {
582 bool any_inst
= false;
583 for (vc
= &vtysh_client
[i
]; vc
;
589 "%s is not running\n",
590 vtysh_client
[i
].name
);
594 cmd_stat
= vtysh_client_execute(
595 &vtysh_client
[i
], line
);
596 if (cmd_stat
!= CMD_SUCCESS
)
600 if (cmd_stat
!= CMD_SUCCESS
)
604 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
608 vty_close_pager(vty
);
613 int vtysh_execute_no_pager(const char *line
)
615 return vtysh_execute_func(line
, 0);
618 int vtysh_execute(const char *line
)
620 return vtysh_execute_func(line
, 1);
623 static char *trim(char *s
)
634 while (end
>= s
&& isspace((int)*end
))
638 while (*s
&& isspace((int)*s
))
644 int vtysh_mark_file(const char *filename
)
651 const struct cmd_element
*cmd
;
652 int saved_ret
, prev_node
;
654 char *vty_buf_copy
= NULL
;
655 char *vty_buf_trimmed
= NULL
;
657 if (strncmp("-", filename
, 1) == 0)
660 confp
= fopen(filename
, "r");
663 fprintf(stderr
, "%% Can't open config file %s due to '%s'.\n",
664 filename
, safe_strerror(errno
));
665 return (CMD_ERR_NO_FILE
);
669 vty
->wfd
= STDERR_FILENO
;
670 vty
->type
= VTY_TERM
;
671 vty
->node
= CONFIG_NODE
;
673 vtysh_execute_no_pager("enable");
674 vtysh_execute_no_pager("configure terminal");
675 vty_buf_copy
= XCALLOC(MTYPE_VTYSH_CMD
, VTY_BUFSIZ
);
677 while (fgets(vty
->buf
, VTY_BUFSIZ
, confp
)) {
680 strcpy(vty_buf_copy
, vty
->buf
);
681 vty_buf_trimmed
= trim(vty_buf_copy
);
684 case LDP_IPV4_IFACE_NODE
:
685 if (strncmp(vty_buf_copy
, " ", 3)) {
686 vty_out(vty
, " end\n");
687 vty
->node
= LDP_IPV4_NODE
;
690 case LDP_IPV6_IFACE_NODE
:
691 if (strncmp(vty_buf_copy
, " ", 3)) {
692 vty_out(vty
, " end\n");
693 vty
->node
= LDP_IPV6_NODE
;
696 case LDP_PSEUDOWIRE_NODE
:
697 if (strncmp(vty_buf_copy
, " ", 2)) {
698 vty_out(vty
, " end\n");
699 vty
->node
= LDP_L2VPN_NODE
;
706 if (vty_buf_trimmed
[0] == '!' || vty_buf_trimmed
[0] == '#') {
707 vty_out(vty
, "%s", vty
->buf
);
711 /* Split readline string up into the vector. */
712 vline
= cmd_make_strvec(vty
->buf
);
715 vty_out(vty
, "%s", vty
->buf
);
720 * Ignore the "end" lines, we will generate these where
723 if (strlen(vty_buf_trimmed
) == 3
724 && strncmp("end", vty_buf_trimmed
, 3) == 0) {
725 cmd_free_strvec(vline
);
729 prev_node
= vty
->node
;
730 saved_ret
= ret
= cmd_execute_command_strict(vline
, vty
, &cmd
);
733 * If command doesn't succeeded in current node, try to walk up
734 * in node tree. Changing vty->node is enough to try it just
735 * out without actual walkup in the vtysh.
737 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
738 && ret
!= CMD_WARNING
&& ret
!= CMD_WARNING_CONFIG_FAILED
739 && vty
->node
> CONFIG_NODE
) {
740 vty
->node
= node_parent(vty
->node
);
741 ret
= cmd_execute_command_strict(vline
, vty
, &cmd
);
746 * If command succeeded in any other node than current (tried >
747 * 0) we have to move into node in the vtysh where it
750 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
751 || ret
== CMD_WARNING
) {
752 if ((prev_node
== BGP_VPNV4_NODE
753 || prev_node
== BGP_VPNV6_NODE
754 || prev_node
== BGP_IPV4_NODE
755 || prev_node
== BGP_IPV6_NODE
756 || prev_node
== BGP_FLOWSPECV4_NODE
757 || prev_node
== BGP_FLOWSPECV6_NODE
758 || prev_node
== BGP_IPV4L_NODE
759 || prev_node
== BGP_IPV6L_NODE
760 || prev_node
== BGP_IPV4M_NODE
761 || prev_node
== BGP_IPV6M_NODE
762 || prev_node
== BGP_EVPN_NODE
)
764 vty_out(vty
, "exit-address-family\n");
765 } else if ((prev_node
== BGP_EVPN_VNI_NODE
)
767 vty_out(vty
, "exit-vni\n");
768 } else if ((prev_node
== KEYCHAIN_KEY_NODE
)
770 vty_out(vty
, "exit\n");
772 vty_out(vty
, "end\n");
776 * If command didn't succeed in any node, continue with return
777 * value from first try.
781 vty
->node
= prev_node
;
784 cmd_free_strvec(vline
);
787 case CMD_WARNING_CONFIG_FAILED
:
788 if (vty
->type
== VTY_FILE
)
789 fprintf(stderr
, "line %d: Warning...: %s\n",
793 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
795 case CMD_ERR_AMBIGUOUS
:
796 fprintf(stderr
, "line %d: %% Ambiguous command: %s\n",
800 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
801 return CMD_ERR_AMBIGUOUS
;
802 case CMD_ERR_NO_MATCH
:
803 fprintf(stderr
, "line %d: %% Unknown command: %s\n",
807 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
808 return CMD_ERR_NO_MATCH
;
809 case CMD_ERR_INCOMPLETE
:
810 fprintf(stderr
, "line %d: %% Command incomplete: %s\n",
814 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
815 return CMD_ERR_INCOMPLETE
;
817 vty_out(vty
, "%s", vty
->buf
);
819 case CMD_SUCCESS_DAEMON
: {
822 vty_out(vty
, "%s", vty
->buf
);
823 cmd_stat
= vtysh_client_execute(&vtysh_client
[0],
825 if (cmd_stat
!= CMD_SUCCESS
)
829 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
833 /* This is the end */
834 vty_out(vty
, "\nend\n");
836 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
844 /* Configration make from file. */
845 int vtysh_config_from_file(struct vty
*vty
, FILE *fp
)
848 const struct cmd_element
*cmd
;
850 /* once we have an error, we remember & return that */
851 int retcode
= CMD_SUCCESS
;
853 while (fgets(vty
->buf
, VTY_BUFSIZ
, fp
)) {
856 ret
= command_config_read_one_line(vty
, &cmd
, 1);
860 case CMD_WARNING_CONFIG_FAILED
:
861 if (vty
->type
== VTY_FILE
)
862 fprintf(stderr
, "line %d: Warning[%d]...: %s\n",
863 lineno
, vty
->node
, vty
->buf
);
867 case CMD_ERR_AMBIGUOUS
:
869 "line %d: %% Ambiguous command[%d]: %s\n",
870 lineno
, vty
->node
, vty
->buf
);
871 retcode
= CMD_ERR_AMBIGUOUS
;
873 case CMD_ERR_NO_MATCH
:
874 fprintf(stderr
, "line %d: %% Unknown command[%d]: %s",
875 lineno
, vty
->node
, vty
->buf
);
876 retcode
= CMD_ERR_NO_MATCH
;
878 case CMD_ERR_INCOMPLETE
:
880 "line %d: %% Command incomplete[%d]: %s\n",
881 lineno
, vty
->node
, vty
->buf
);
882 retcode
= CMD_ERR_INCOMPLETE
;
884 case CMD_SUCCESS_DAEMON
: {
886 int cmd_stat
= CMD_SUCCESS
;
888 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
889 if (cmd
->daemon
& vtysh_client
[i
].flag
) {
890 cmd_stat
= vtysh_client_execute(
891 &vtysh_client
[i
], vty
->buf
);
893 * CMD_WARNING - Can mean that the
894 * command was parsed successfully but
895 * it was already entered in a few
896 * spots. As such if we receive a
897 * CMD_WARNING from a daemon we
898 * shouldn't stop talking to the other
899 * daemons for the particular command.
901 if (cmd_stat
!= CMD_SUCCESS
902 && cmd_stat
!= CMD_WARNING
) {
904 "line %d: Failure to communicate[%d] to %s, line: %s\n",
906 vtysh_client
[i
].name
,
913 if (cmd_stat
!= CMD_SUCCESS
)
917 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
926 * Function processes cli commands terminated with '?' character when entered
927 * through either 'vtysh' or 'vtysh -c' interfaces.
929 static int vtysh_process_questionmark(const char *input
, int input_len
)
933 vector vline
, describe
;
934 struct cmd_token
*token
;
939 vline
= cmd_make_strvec(input
);
941 /* In case of '> ?'. */
943 vline
= vector_init(1);
944 vector_set(vline
, NULL
);
945 } else if (input_len
&& isspace((int)input
[input_len
- 1]))
946 vector_set(vline
, NULL
);
948 describe
= cmd_describe_command(vline
, vty
, &ret
);
950 /* Ambiguous and no match error. */
952 case CMD_ERR_AMBIGUOUS
:
953 cmd_free_strvec(vline
);
954 vector_free(describe
);
955 vty_out(vty
, "%% Ambiguous command.\n");
959 case CMD_ERR_NO_MATCH
:
960 cmd_free_strvec(vline
);
962 vector_free(describe
);
963 vty_out(vty
, "%% There is no matched command.\n");
969 /* Get width of command string. */
971 for (i
= 0; i
< vector_active(describe
); i
++)
972 if ((token
= vector_slot(describe
, i
)) != NULL
) {
973 if (token
->text
[0] == '\0')
976 int len
= strlen(token
->text
);
982 for (i
= 0; i
< vector_active(describe
); i
++)
983 if ((token
= vector_slot(describe
, i
)) != NULL
) {
985 vty_out(vty
, " %-s\n", token
->text
);
987 vty_out(vty
, " %-*s %s\n", width
, token
->text
,
990 if (IS_VARYING_TOKEN(token
->type
)) {
991 const char *ref
= vector_slot(
992 vline
, vector_active(vline
) - 1);
994 vector varcomps
= vector_init(VECTOR_MIN_SIZE
);
995 cmd_variable_complete(token
, ref
, varcomps
);
997 if (vector_active(varcomps
) > 0) {
999 rl_get_screen_size(&rows
, &cols
);
1001 char *ac
= cmd_variable_comp2str(
1003 vty_out(vty
, "%s\n", ac
);
1004 XFREE(MTYPE_TMP
, ac
);
1007 vector_free(varcomps
);
1011 cmd_free_strvec(vline
);
1012 vector_free(describe
);
1018 * Entry point for user commands terminated with '?' character and typed through
1019 * the usual vtysh's stdin interface. This is the function being registered with
1022 static int vtysh_rl_describe(int a
, int b
)
1028 ret
= vtysh_process_questionmark(rl_line_buffer
, rl_end
);
1035 * Function in charged of processing vtysh instructions terminating with '?'
1036 * character and received through the 'vtysh -c' interface. If user's
1037 * instruction is well-formatted, we will call the same processing routine
1038 * utilized by the traditional vtysh's stdin interface.
1040 int vtysh_execute_command_questionmark(char *input
)
1042 int input_len
, qmark_count
= 0;
1045 if (!(input
&& *input
))
1048 /* Finding out question_mark count and strlen */
1049 for (str
= input
; *str
; ++str
) {
1053 input_len
= str
- input
;
1056 * Verify that user's input terminates in '?' and that patterns such as
1057 * 'cmd ? subcmd ?' are prevented.
1059 if (qmark_count
!= 1 || input
[input_len
- 1] != '?')
1063 * Questionmark-processing function is not expecting to receive '?'
1064 * character in input string.
1066 input
[input_len
- 1] = '\0';
1068 return vtysh_process_questionmark(input
, input_len
- 1);
1071 /* Result of cmd_complete_command() call will be stored here
1072 * and used in new_completion() in order to put the space in
1073 * correct places only. */
1074 int complete_status
;
1076 static char *command_generator(const char *text
, int state
)
1079 static char **matched
= NULL
;
1080 static int index
= 0;
1086 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
1089 vline
= cmd_make_strvec(rl_line_buffer
);
1093 if (rl_end
&& isspace((int)rl_line_buffer
[rl_end
- 1]))
1094 vector_set(vline
, NULL
);
1096 matched
= cmd_complete_command(vline
, vty
, &complete_status
);
1097 cmd_free_strvec(vline
);
1100 if (matched
&& matched
[index
])
1102 * this is free()'d by readline, but we leak 1 count of
1105 return matched
[index
++];
1107 XFREE(MTYPE_TMP
, matched
);
1113 static char **new_completion(char *text
, int start
, int end
)
1117 matches
= rl_completion_matches(text
, command_generator
);
1121 if (complete_status
!= CMD_COMPLETE_FULL_MATCH
)
1122 /* only append a space on full match */
1123 rl_completion_append_character
= '\0';
1129 /* Vty node structures. */
1130 static struct cmd_node bgp_node
= {
1131 BGP_NODE
, "%s(config-router)# ",
1134 static struct cmd_node rip_node
= {
1135 RIP_NODE
, "%s(config-router)# ",
1138 static struct cmd_node isis_node
= {
1139 ISIS_NODE
, "%s(config-router)# ",
1142 static struct cmd_node interface_node
= {
1143 INTERFACE_NODE
, "%s(config-if)# ",
1146 static struct cmd_node pw_node
= {
1147 PW_NODE
, "%s(config-pw)# ",
1150 static struct cmd_node logicalrouter_node
= {
1151 LOGICALROUTER_NODE
, "%s(config-logical-router)# ",
1154 static struct cmd_node vrf_node
= {
1155 VRF_NODE
, "%s(config-vrf)# ",
1158 static struct cmd_node nh_group_node
= {
1160 "%s(config-nh-group)# ",
1163 static struct cmd_node rmap_node
= {RMAP_NODE
, "%s(config-route-map)# "};
1165 static struct cmd_node pbr_map_node
= {PBRMAP_NODE
, "%s(config-pbr-map)# "};
1167 static struct cmd_node zebra_node
= {ZEBRA_NODE
, "%s(config-router)# "};
1169 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
1170 "%s(config-router-af)# "};
1172 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
1173 "%s(config-router-af)# "};
1175 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
1176 "%s(config-router-af)# "};
1178 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
1179 "%s(config-router-af)# "};
1181 static struct cmd_node bgp_ipv4_node
= {BGP_IPV4_NODE
,
1182 "%s(config-router-af)# "};
1184 static struct cmd_node bgp_ipv4m_node
= {BGP_IPV4M_NODE
,
1185 "%s(config-router-af)# "};
1187 static struct cmd_node bgp_ipv4l_node
= {BGP_IPV4L_NODE
,
1188 "%s(config-router-af)# "};
1190 static struct cmd_node bgp_ipv6_node
= {BGP_IPV6_NODE
,
1191 "%s(config-router-af)# "};
1193 static struct cmd_node bgp_ipv6m_node
= {BGP_IPV6M_NODE
,
1194 "%s(config-router-af)# "};
1196 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
1197 "%s(config-router-af)# "};
1199 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
1200 "%s(config-router-af-vni)# "};
1202 static struct cmd_node bgp_ipv6l_node
= {BGP_IPV6L_NODE
,
1203 "%s(config-router-af)# "};
1205 static struct cmd_node bgp_vnc_defaults_node
= {
1206 BGP_VNC_DEFAULTS_NODE
, "%s(config-router-vnc-defaults)# "};
1208 static struct cmd_node bgp_vnc_nve_group_node
= {
1209 BGP_VNC_NVE_GROUP_NODE
, "%s(config-router-vnc-nve-group)# "};
1211 static struct cmd_node bgp_vrf_policy_node
= {BGP_VRF_POLICY_NODE
,
1212 "%s(config-router-vrf-policy)# "};
1214 static struct cmd_node bgp_vnc_l2_group_node
= {
1215 BGP_VNC_L2_GROUP_NODE
, "%s(config-router-vnc-l2-group)# "};
1217 static struct cmd_node ospf_node
= {OSPF_NODE
, "%s(config-router)# "};
1219 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# "};
1221 static struct cmd_node babel_node
= {BABEL_NODE
, "%s(config-router)# "};
1223 static struct cmd_node ripng_node
= {RIPNG_NODE
, "%s(config-router)# "};
1225 static struct cmd_node ospf6_node
= {OSPF6_NODE
, "%s(config-ospf6)# "};
1227 static struct cmd_node ldp_node
= {LDP_NODE
, "%s(config-ldp)# "};
1229 static struct cmd_node ldp_ipv4_node
= {LDP_IPV4_NODE
, "%s(config-ldp-af)# "};
1231 static struct cmd_node ldp_ipv6_node
= {LDP_IPV6_NODE
, "%s(config-ldp-af)# "};
1233 static struct cmd_node ldp_ipv4_iface_node
= {LDP_IPV4_IFACE_NODE
,
1234 "%s(config-ldp-af-if)# "};
1236 static struct cmd_node ldp_ipv6_iface_node
= {LDP_IPV6_IFACE_NODE
,
1237 "%s(config-ldp-af-if)# "};
1239 static struct cmd_node ldp_l2vpn_node
= {LDP_L2VPN_NODE
, "%s(config-l2vpn)# "};
1241 static struct cmd_node ldp_pseudowire_node
= {LDP_PSEUDOWIRE_NODE
,
1242 "%s(config-l2vpn-pw)# "};
1244 static struct cmd_node keychain_node
= {KEYCHAIN_NODE
, "%s(config-keychain)# "};
1246 static struct cmd_node keychain_key_node
= {KEYCHAIN_KEY_NODE
,
1247 "%s(config-keychain-key)# "};
1249 struct cmd_node link_params_node
= {
1250 LINK_PARAMS_NODE
, "%s(config-link-params)# ",
1253 #if defined(HAVE_RPKI)
1254 static struct cmd_node rpki_node
= {RPKI_NODE
, "%s(config-rpki)# ", 1};
1257 /* Defined in lib/vty.c */
1258 extern struct cmd_node vty_node
;
1260 /* When '^Z' is received from vty, move down to the enable mode. */
1261 static int vtysh_end(void)
1263 switch (vty
->node
) {
1266 /* Nothing to do. */
1269 vty
->node
= ENABLE_NODE
;
1275 DEFUNSH(VTYSH_REALLYALL
, vtysh_end_all
, vtysh_end_all_cmd
, "end",
1276 "End current mode and change to enable mode\n")
1281 DEFUNSH(VTYSH_BGPD
, router_bgp
, router_bgp_cmd
,
1282 "router bgp [(1-4294967295) [<view|vrf> WORD]]",
1283 ROUTER_STR BGP_STR AS_STR
1284 "BGP view\nBGP VRF\n"
1287 vty
->node
= BGP_NODE
;
1291 DEFUNSH(VTYSH_BGPD
, address_family_vpnv4
, address_family_vpnv4_cmd
,
1292 "address-family vpnv4 [unicast]",
1293 "Enter Address Family command mode\n"
1295 "Address Family modifier\n")
1297 vty
->node
= BGP_VPNV4_NODE
;
1301 DEFUNSH(VTYSH_BGPD
, address_family_vpnv6
, address_family_vpnv6_cmd
,
1302 "address-family vpnv6 [unicast]",
1303 "Enter Address Family command mode\n"
1305 "Address Family modifier\n")
1307 vty
->node
= BGP_VPNV6_NODE
;
1311 DEFUNSH(VTYSH_BGPD
, address_family_ipv4
, address_family_ipv4_cmd
,
1312 "address-family ipv4 [unicast]",
1313 "Enter Address Family command mode\n"
1315 "Address Family Modifier\n")
1317 vty
->node
= BGP_IPV4_NODE
;
1321 DEFUNSH(VTYSH_BGPD
, address_family_flowspecv4
, address_family_flowspecv4_cmd
,
1322 "address-family ipv4 flowspec",
1323 "Enter Address Family command mode\n"
1325 "Address Family Modifier\n")
1327 vty
->node
= BGP_FLOWSPECV4_NODE
;
1331 DEFUNSH(VTYSH_BGPD
, address_family_flowspecv6
, address_family_flowspecv6_cmd
,
1332 "address-family ipv6 flowspec",
1333 "Enter Address Family command mode\n"
1335 "Address Family Modifier\n")
1337 vty
->node
= BGP_FLOWSPECV6_NODE
;
1341 DEFUNSH(VTYSH_BGPD
, address_family_ipv4_multicast
,
1342 address_family_ipv4_multicast_cmd
, "address-family ipv4 multicast",
1343 "Enter Address Family command mode\n"
1345 "Address Family modifier\n")
1347 vty
->node
= BGP_IPV4M_NODE
;
1351 DEFUNSH(VTYSH_BGPD
, address_family_ipv4_vpn
, address_family_ipv4_vpn_cmd
,
1352 "address-family ipv4 vpn",
1353 "Enter Address Family command mode\n"
1355 "Address Family modifier\n")
1357 vty
->node
= BGP_VPNV4_NODE
;
1361 DEFUNSH(VTYSH_BGPD
, address_family_ipv4_labeled_unicast
,
1362 address_family_ipv4_labeled_unicast_cmd
,
1363 "address-family ipv4 labeled-unicast",
1364 "Enter Address Family command mode\n"
1366 "Address Family modifier\n")
1368 vty
->node
= BGP_IPV4L_NODE
;
1372 DEFUNSH(VTYSH_BGPD
, address_family_ipv6
, address_family_ipv6_cmd
,
1373 "address-family ipv6 [unicast]",
1374 "Enter Address Family command mode\n"
1376 "Address Family modifier\n")
1378 vty
->node
= BGP_IPV6_NODE
;
1382 DEFUNSH(VTYSH_BGPD
, address_family_ipv6_multicast
,
1383 address_family_ipv6_multicast_cmd
, "address-family ipv6 multicast",
1384 "Enter Address Family command mode\n"
1386 "Address Family modifier\n")
1388 vty
->node
= BGP_IPV6M_NODE
;
1392 DEFUNSH(VTYSH_BGPD
, address_family_ipv6_vpn
, address_family_ipv6_vpn_cmd
,
1393 "address-family ipv6 vpn",
1394 "Enter Address Family command mode\n"
1396 "Address Family modifier\n")
1398 vty
->node
= BGP_VPNV6_NODE
;
1402 DEFUNSH(VTYSH_BGPD
, address_family_ipv6_labeled_unicast
,
1403 address_family_ipv6_labeled_unicast_cmd
,
1404 "address-family ipv6 labeled-unicast",
1405 "Enter Address Family command mode\n"
1407 "Address Family modifier\n")
1409 vty
->node
= BGP_IPV6L_NODE
;
1413 #if defined(HAVE_RPKI)
1418 "Enable rpki and enter rpki configuration mode\n")
1420 vty
->node
= RPKI_NODE
;
1428 "Exit current mode and down to previous mode\n")
1430 vty
->node
= CONFIG_NODE
;
1438 "Exit current mode and down to previous mode\n")
1440 return rpki_exit(self
, vty
, argc
, argv
);
1444 DEFUNSH(VTYSH_BGPD
, address_family_evpn
, address_family_evpn_cmd
,
1445 "address-family <l2vpn evpn>",
1446 "Enter Address Family command mode\n"
1448 "Address Family modifier\n")
1450 vty
->node
= BGP_EVPN_NODE
;
1454 #if defined(HAVE_CUMULUS)
1455 DEFUNSH_HIDDEN(VTYSH_BGPD
, address_family_evpn2
, address_family_evpn2_cmd
,
1456 "address-family evpn",
1457 "Enter Address Family command mode\n"
1458 "EVPN Address family\n")
1460 vty
->node
= BGP_EVPN_NODE
;
1465 DEFUNSH(VTYSH_BGPD
, bgp_evpn_vni
, bgp_evpn_vni_cmd
, "vni (1-16777215)",
1466 "VXLAN Network Identifier\n"
1469 vty
->node
= BGP_EVPN_VNI_NODE
;
1473 #if defined(ENABLE_BGP_VNC)
1474 DEFUNSH(VTYSH_BGPD
, vnc_defaults
, vnc_defaults_cmd
, "vnc defaults",
1475 "VNC/RFP related configuration\n"
1476 "Configure default NVE group\n")
1478 vty
->node
= BGP_VNC_DEFAULTS_NODE
;
1482 DEFUNSH(VTYSH_BGPD
, vnc_nve_group
, vnc_nve_group_cmd
, "vnc nve-group NAME",
1483 "VNC/RFP related configuration\n"
1484 "Configure a NVE group\n"
1487 vty
->node
= BGP_VNC_NVE_GROUP_NODE
;
1491 DEFUNSH(VTYSH_BGPD
, vnc_vrf_policy
, vnc_vrf_policy_cmd
, "vrf-policy NAME",
1492 "Configure a VRF policy group\n"
1495 vty
->node
= BGP_VRF_POLICY_NODE
;
1499 DEFUNSH(VTYSH_BGPD
, vnc_l2_group
, vnc_l2_group_cmd
, "vnc l2-group NAME",
1500 "VNC/RFP related configuration\n"
1501 "Configure a L2 group\n"
1504 vty
->node
= BGP_VNC_L2_GROUP_NODE
;
1509 DEFUNSH(VTYSH_RIPD
, key_chain
, key_chain_cmd
, "key chain WORD",
1510 "Authentication key management\n"
1511 "Key-chain management\n"
1514 vty
->node
= KEYCHAIN_NODE
;
1518 DEFUNSH(VTYSH_RIPD
, key
, key_cmd
, "key (0-2147483647)",
1520 "Key identifier number\n")
1522 vty
->node
= KEYCHAIN_KEY_NODE
;
1526 DEFUNSH(VTYSH_RIPD
, router_rip
, router_rip_cmd
, "router rip",
1529 vty
->node
= RIP_NODE
;
1533 DEFUNSH(VTYSH_RIPNGD
, router_ripng
, router_ripng_cmd
, "router ripng",
1534 ROUTER_STR
"RIPng\n")
1536 vty
->node
= RIPNG_NODE
;
1540 DEFUNSH(VTYSH_OSPFD
, router_ospf
, router_ospf_cmd
,
1541 "router ospf [(1-65535)] [vrf NAME]",
1542 "Enable a routing process\n"
1543 "Start OSPF configuration\n"
1547 vty
->node
= OSPF_NODE
;
1551 DEFUNSH(VTYSH_EIGRPD
, router_eigrp
, router_eigrp_cmd
, "router eigrp (1-65535)",
1552 "Enable a routing process\n"
1553 "Start EIGRP configuration\n"
1554 "AS number to use\n")
1556 vty
->node
= EIGRP_NODE
;
1560 DEFUNSH(VTYSH_BABELD
, router_babel
, router_babel_cmd
, "router babel",
1561 "Enable a routing process\n"
1562 "Make Babel instance command\n")
1564 vty
->node
= BABEL_NODE
;
1568 DEFUNSH(VTYSH_OSPF6D
, router_ospf6
, router_ospf6_cmd
, "router ospf6",
1569 ROUTER_STR OSPF6_STR
)
1571 vty
->node
= OSPF6_NODE
;
1575 #if defined(HAVE_LDPD)
1576 DEFUNSH(VTYSH_LDPD
, ldp_mpls_ldp
, ldp_mpls_ldp_cmd
, "mpls ldp",
1577 "Global MPLS configuration subcommands\n"
1578 "Label Distribution Protocol\n")
1580 vty
->node
= LDP_NODE
;
1584 DEFUNSH(VTYSH_LDPD
, ldp_address_family_ipv4
, ldp_address_family_ipv4_cmd
,
1585 "address-family ipv4",
1586 "Configure Address Family and its parameters\n"
1589 vty
->node
= LDP_IPV4_NODE
;
1593 DEFUNSH(VTYSH_LDPD
, ldp_address_family_ipv6
, ldp_address_family_ipv6_cmd
,
1594 "address-family ipv6",
1595 "Configure Address Family and its parameters\n"
1598 vty
->node
= LDP_IPV6_NODE
;
1602 DEFUNSH(VTYSH_LDPD
, ldp_exit_address_family
, ldp_exit_address_family_cmd
,
1603 "exit-address-family", "Exit from Address Family configuration mode\n")
1605 if (vty
->node
== LDP_IPV4_NODE
|| vty
->node
== LDP_IPV6_NODE
)
1606 vty
->node
= LDP_NODE
;
1610 DEFUNSH(VTYSH_LDPD
, ldp_interface_ifname
, ldp_interface_ifname_cmd
,
1612 "Enable LDP on an interface and enter interface submode\n"
1613 "Interface's name\n")
1615 switch (vty
->node
) {
1617 vty
->node
= LDP_IPV4_IFACE_NODE
;
1620 vty
->node
= LDP_IPV6_IFACE_NODE
;
1629 DEFUNSH(VTYSH_LDPD
, ldp_l2vpn_word_type_vpls
, ldp_l2vpn_word_type_vpls_cmd
,
1630 "l2vpn WORD type vpls",
1631 "Configure l2vpn commands\n"
1634 "Virtual Private LAN Service\n")
1636 vty
->node
= LDP_L2VPN_NODE
;
1640 DEFUNSH(VTYSH_LDPD
, ldp_member_pseudowire_ifname
,
1641 ldp_member_pseudowire_ifname_cmd
, "member pseudowire IFNAME",
1642 "L2VPN member configuration\n"
1643 "Pseudowire interface\n"
1644 "Interface's name\n")
1646 vty
->node
= LDP_PSEUDOWIRE_NODE
;
1651 DEFUNSH(VTYSH_ISISD
, router_isis
, router_isis_cmd
, "router isis WORD",
1654 "ISO Routing area tag\n")
1656 vty
->node
= ISIS_NODE
;
1660 DEFUNSH(VTYSH_RMAP
, vtysh_route_map
, vtysh_route_map_cmd
,
1661 "route-map WORD <deny|permit> (1-65535)",
1662 "Create route-map or enter route-map command mode\n"
1664 "Route map denies set operations\n"
1665 "Route map permits set operations\n"
1666 "Sequence to insert to/delete from existing route-map entry\n")
1668 vty
->node
= RMAP_NODE
;
1672 DEFUNSH(VTYSH_PBRD
, vtysh_pbr_map
, vtysh_pbr_map_cmd
,
1673 "pbr-map NAME seq (1-700)",
1674 "Create pbr-map or enter pbr-map command mode\n"
1675 "The name of the PBR MAP\n"
1676 "Sequence to insert to/delete from existing pbr-map entry\n"
1677 "Sequence number\n")
1679 vty
->node
= PBRMAP_NODE
;
1683 DEFSH(VTYSH_PBRD
, vtysh_no_pbr_map_cmd
, "no pbr-map WORD [seq (1-700)]",
1686 "The name of the PBR MAP\n"
1687 "Sequence to delete from existing pbr-map entry\n"
1688 "Sequence number\n")
1690 DEFUNSH(VTYSH_ALL
, vtysh_line_vty
, vtysh_line_vty_cmd
, "line vty",
1691 "Configure a terminal line\n"
1692 "Virtual terminal\n")
1694 vty
->node
= VTY_NODE
;
1698 DEFUNSH(VTYSH_REALLYALL
, vtysh_enable
, vtysh_enable_cmd
, "enable",
1699 "Turn on privileged mode command\n")
1701 vty
->node
= ENABLE_NODE
;
1705 DEFUNSH(VTYSH_REALLYALL
, vtysh_disable
, vtysh_disable_cmd
, "disable",
1706 "Turn off privileged mode command\n")
1708 if (vty
->node
== ENABLE_NODE
)
1709 vty
->node
= VIEW_NODE
;
1713 DEFUNSH(VTYSH_REALLYALL
, vtysh_config_terminal
, vtysh_config_terminal_cmd
,
1714 "configure terminal",
1715 "Configuration from vty interface\n"
1716 "Configuration terminal\n")
1718 vty
->node
= CONFIG_NODE
;
1722 static int vtysh_exit(struct vty
*vty
)
1724 switch (vty
->node
) {
1730 vty
->node
= ENABLE_NODE
;
1732 case INTERFACE_NODE
:
1734 case LOGICALROUTER_NODE
:
1746 case LDP_L2VPN_NODE
:
1752 vtysh_execute("end");
1753 vtysh_execute("configure terminal");
1754 vty
->node
= CONFIG_NODE
;
1756 case BGP_VPNV4_NODE
:
1757 case BGP_VPNV6_NODE
:
1759 case BGP_IPV4M_NODE
:
1760 case BGP_IPV4L_NODE
:
1762 case BGP_IPV6M_NODE
:
1763 case BGP_IPV6L_NODE
:
1764 case BGP_FLOWSPECV4_NODE
:
1765 case BGP_FLOWSPECV6_NODE
:
1766 case BGP_VRF_POLICY_NODE
:
1768 case BGP_VNC_DEFAULTS_NODE
:
1769 case BGP_VNC_NVE_GROUP_NODE
:
1770 case BGP_VNC_L2_GROUP_NODE
:
1771 vty
->node
= BGP_NODE
;
1773 case BGP_EVPN_VNI_NODE
:
1774 vty
->node
= BGP_EVPN_NODE
;
1778 vty
->node
= LDP_NODE
;
1780 case LDP_IPV4_IFACE_NODE
:
1781 vty
->node
= LDP_IPV4_NODE
;
1783 case LDP_IPV6_IFACE_NODE
:
1784 vty
->node
= LDP_IPV6_NODE
;
1786 case LDP_PSEUDOWIRE_NODE
:
1787 vty
->node
= LDP_L2VPN_NODE
;
1789 case KEYCHAIN_KEY_NODE
:
1790 vty
->node
= KEYCHAIN_NODE
;
1792 case LINK_PARAMS_NODE
:
1793 vty
->node
= INTERFACE_NODE
;
1801 DEFUNSH(VTYSH_REALLYALL
, vtysh_exit_all
, vtysh_exit_all_cmd
, "exit",
1802 "Exit current mode and down to previous mode\n")
1804 return vtysh_exit(vty
);
1807 DEFUNSH(VTYSH_ALL
, vtysh_quit_all
, vtysh_quit_all_cmd
, "quit",
1808 "Exit current mode and down to previous mode\n")
1810 return vtysh_exit_all(self
, vty
, argc
, argv
);
1813 DEFUNSH(VTYSH_BGPD
, exit_address_family
, exit_address_family_cmd
,
1814 "exit-address-family", "Exit from Address Family configuration mode\n")
1816 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
1817 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
1818 || vty
->node
== BGP_VPNV6_NODE
|| vty
->node
== BGP_IPV6_NODE
1819 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_IPV6M_NODE
1820 || vty
->node
== BGP_EVPN_NODE
1821 || vty
->node
== BGP_FLOWSPECV4_NODE
1822 || vty
->node
== BGP_FLOWSPECV6_NODE
)
1823 vty
->node
= BGP_NODE
;
1827 DEFUNSH(VTYSH_BGPD
, exit_vni
, exit_vni_cmd
, "exit-vni", "Exit from VNI mode\n")
1829 if (vty
->node
== BGP_EVPN_VNI_NODE
)
1830 vty
->node
= BGP_EVPN_NODE
;
1834 DEFUNSH(VTYSH_BGPD
, exit_vnc_config
, exit_vnc_config_cmd
, "exit-vnc",
1835 "Exit from VNC configuration mode\n")
1837 if (vty
->node
== BGP_VNC_DEFAULTS_NODE
1838 || vty
->node
== BGP_VNC_NVE_GROUP_NODE
1839 || vty
->node
== BGP_VNC_L2_GROUP_NODE
)
1840 vty
->node
= BGP_NODE
;
1844 DEFUNSH(VTYSH_PIMD
|VTYSH_ZEBRA
, exit_vrf_config
, exit_vrf_config_cmd
, "exit-vrf",
1845 "Exit from VRF configuration mode\n")
1847 if (vty
->node
== VRF_NODE
)
1848 vty
->node
= CONFIG_NODE
;
1852 DEFUNSH(VTYSH_BGPD
, exit_vrf_policy
, exit_vrf_policy_cmd
, "exit-vrf-policy",
1853 "Exit from VRF policy configuration mode\n")
1855 if (vty
->node
== BGP_VRF_POLICY_NODE
)
1856 vty
->node
= BGP_NODE
;
1860 DEFUNSH(VTYSH_RIPD
, vtysh_exit_ripd
, vtysh_exit_ripd_cmd
, "exit",
1861 "Exit current mode and down to previous mode\n")
1863 return vtysh_exit(vty
);
1866 DEFUNSH(VTYSH_RIPD
, vtysh_quit_ripd
, vtysh_quit_ripd_cmd
, "quit",
1867 "Exit current mode and down to previous mode\n")
1869 return vtysh_exit_ripd(self
, vty
, argc
, argv
);
1872 DEFUNSH(VTYSH_RIPNGD
, vtysh_exit_ripngd
, vtysh_exit_ripngd_cmd
, "exit",
1873 "Exit current mode and down to previous mode\n")
1875 return vtysh_exit(vty
);
1878 DEFUNSH(VTYSH_RIPNGD
, vtysh_quit_ripngd
, vtysh_quit_ripngd_cmd
, "quit",
1879 "Exit current mode and down to previous mode\n")
1881 return vtysh_exit_ripngd(self
, vty
, argc
, argv
);
1884 DEFUNSH(VTYSH_RMAP
, vtysh_exit_rmap
, vtysh_exit_rmap_cmd
, "exit",
1885 "Exit current mode and down to previous mode\n")
1887 return vtysh_exit(vty
);
1890 DEFUNSH(VTYSH_RMAP
, vtysh_quit_rmap
, vtysh_quit_rmap_cmd
, "quit",
1891 "Exit current mode and down to previous mode\n")
1893 return vtysh_exit_rmap(self
, vty
, argc
, argv
);
1896 DEFUNSH(VTYSH_PBRD
, vtysh_exit_pbr_map
, vtysh_exit_pbr_map_cmd
, "exit",
1897 "Exit current mode and down to previous mode\n")
1899 return vtysh_exit(vty
);
1902 DEFUNSH(VTYSH_PBRD
, vtysh_quit_pbr_map
, vtysh_quit_pbr_map_cmd
, "quit",
1903 "Exit current mode and down to previous mode\n")
1905 return vtysh_exit_rmap(self
, vty
, argc
, argv
);
1908 DEFUNSH(VTYSH_BGPD
, vtysh_exit_bgpd
, vtysh_exit_bgpd_cmd
, "exit",
1909 "Exit current mode and down to previous mode\n")
1911 return vtysh_exit(vty
);
1914 DEFUNSH(VTYSH_BGPD
, vtysh_quit_bgpd
, vtysh_quit_bgpd_cmd
, "quit",
1915 "Exit current mode and down to previous mode\n")
1917 return vtysh_exit_bgpd(self
, vty
, argc
, argv
);
1920 DEFUNSH(VTYSH_OSPFD
, vtysh_exit_ospfd
, vtysh_exit_ospfd_cmd
, "exit",
1921 "Exit current mode and down to previous mode\n")
1923 return vtysh_exit(vty
);
1926 DEFUNSH(VTYSH_OSPFD
, vtysh_quit_ospfd
, vtysh_quit_ospfd_cmd
, "quit",
1927 "Exit current mode and down to previous mode\n")
1929 return vtysh_exit_ospfd(self
, vty
, argc
, argv
);
1932 DEFUNSH(VTYSH_EIGRPD
, vtysh_exit_eigrpd
, vtysh_exit_eigrpd_cmd
, "exit",
1933 "Exit current mode and down to previous mode\n")
1935 return vtysh_exit(vty
);
1938 DEFUNSH(VTYSH_EIGRPD
, vtysh_quit_eigrpd
, vtysh_quit_eigrpd_cmd
, "quit",
1939 "Exit current mode and down to previous mode\n")
1941 return vtysh_exit(vty
);
1944 DEFUNSH(VTYSH_EIGRPD
, vtysh_exit_babeld
, vtysh_exit_babeld_cmd
, "exit",
1945 "Exit current mode and down to previous mode\n")
1947 return vtysh_exit(vty
);
1950 DEFUNSH(VTYSH_BABELD
, vtysh_quit_babeld
, vtysh_quit_babeld_cmd
, "quit",
1951 "Exit current mode and down to previous mode\n")
1953 return vtysh_exit(vty
);
1956 DEFUNSH(VTYSH_OSPF6D
, vtysh_exit_ospf6d
, vtysh_exit_ospf6d_cmd
, "exit",
1957 "Exit current mode and down to previous mode\n")
1959 return vtysh_exit(vty
);
1962 DEFUNSH(VTYSH_OSPF6D
, vtysh_quit_ospf6d
, vtysh_quit_ospf6d_cmd
, "quit",
1963 "Exit current mode and down to previous mode\n")
1965 return vtysh_exit_ospf6d(self
, vty
, argc
, argv
);
1968 #if defined(HAVE_LDPD)
1969 DEFUNSH(VTYSH_LDPD
, vtysh_exit_ldpd
, vtysh_exit_ldpd_cmd
, "exit",
1970 "Exit current mode and down to previous mode\n")
1972 return vtysh_exit(vty
);
1975 ALIAS(vtysh_exit_ldpd
, vtysh_quit_ldpd_cmd
, "quit",
1976 "Exit current mode and down to previous mode\n")
1979 DEFUNSH(VTYSH_ISISD
, vtysh_exit_isisd
, vtysh_exit_isisd_cmd
, "exit",
1980 "Exit current mode and down to previous mode\n")
1982 return vtysh_exit(vty
);
1985 DEFUNSH(VTYSH_ISISD
, vtysh_quit_isisd
, vtysh_quit_isisd_cmd
, "quit",
1986 "Exit current mode and down to previous mode\n")
1988 return vtysh_exit_isisd(self
, vty
, argc
, argv
);
1991 DEFUNSH(VTYSH_ALL
, vtysh_exit_line_vty
, vtysh_exit_line_vty_cmd
, "exit",
1992 "Exit current mode and down to previous mode\n")
1994 return vtysh_exit(vty
);
1997 DEFUNSH(VTYSH_ALL
, vtysh_quit_line_vty
, vtysh_quit_line_vty_cmd
, "quit",
1998 "Exit current mode and down to previous mode\n")
2000 return vtysh_exit_line_vty(self
, vty
, argc
, argv
);
2003 DEFUNSH(VTYSH_INTERFACE
, vtysh_interface
, vtysh_interface_cmd
,
2004 "interface IFNAME [vrf NAME]",
2005 "Select an interface to configure\n"
2006 "Interface's name\n" VRF_CMD_HELP_STR
)
2008 vty
->node
= INTERFACE_NODE
;
2012 DEFUNSH(VTYSH_ZEBRA
, vtysh_pseudowire
, vtysh_pseudowire_cmd
,
2013 "pseudowire IFNAME",
2014 "Static pseudowire configuration\n"
2015 "Pseudowire name\n")
2017 vty
->node
= PW_NODE
;
2021 /* TODO Implement "no interface command in isisd. */
2022 DEFSH(VTYSH_ZEBRA
| VTYSH_RIPD
| VTYSH_RIPNGD
| VTYSH_OSPFD
| VTYSH_OSPF6D
2024 vtysh_no_interface_cmd
, "no interface IFNAME", NO_STR
2025 "Delete a pseudo interface's configuration\n"
2026 "Interface's name\n")
2028 DEFSH(VTYSH_ZEBRA
, vtysh_no_interface_vrf_cmd
, "no interface IFNAME vrf NAME",
2030 "Delete a pseudo interface's configuration\n"
2031 "Interface's name\n" VRF_CMD_HELP_STR
)
2033 DEFUNSH(VTYSH_ZEBRA
, vtysh_logicalrouter
, vtysh_logicalrouter_cmd
,
2034 "logical-router (1-65535) ns NAME",
2035 "Enable a logical-router\n"
2036 "Specify the logical-router indentifier\n"
2038 "The file name in " NS_RUN_DIR
", or a full pathname\n")
2040 vty
->node
= LOGICALROUTER_NODE
;
2044 DEFSH(VTYSH_ZEBRA
, vtysh_no_logicalrouter_cmd
,
2045 "no logical-router (1-65535) ns NAME", NO_STR
2046 "Enable a Logical-Router\n"
2047 "Specify the Logical-Router identifier\n"
2049 "The file name in " NS_RUN_DIR
", or a full pathname\n")
2051 DEFUNSH(VTYSH_PBRD
, vtysh_nexthop_group
, vtysh_nexthop_group_cmd
,
2052 "nexthop-group NAME",
2053 "Nexthop Group configuration\n"
2054 "Name of the Nexthop Group\n")
2056 vty
->node
= NH_GROUP_NODE
;
2060 DEFSH(VTYSH_PBRD
, vtysh_no_nexthop_group_cmd
, "no nexthop-group NAME",
2062 "Nexthop Group Configuration\n"
2063 "Name of the Nexthop Group\n")
2065 DEFUNSH(VTYSH_VRF
, vtysh_vrf
, vtysh_vrf_cmd
, "vrf NAME",
2066 "Select a VRF to configure\n"
2069 vty
->node
= VRF_NODE
;
2073 DEFSH(VTYSH_ZEBRA
, vtysh_no_vrf_cmd
, "no vrf NAME", NO_STR
2074 "Delete a pseudo vrf's configuration\n"
2077 DEFUNSH(VTYSH_NS
, vtysh_exit_logicalrouter
,
2078 vtysh_exit_logicalrouter_cmd
, "exit",
2079 "Exit current mode and down to previous mode\n")
2081 return vtysh_exit(vty
);
2084 DEFUNSH(VTYSH_NS
, vtysh_quit_logicalrouter
,
2085 vtysh_quit_logicalrouter_cmd
, "quit",
2086 "Exit current mode and down to previous mode\n")
2088 return vtysh_exit_logicalrouter(self
, vty
, argc
, argv
);
2091 DEFUNSH(VTYSH_VRF
, vtysh_exit_vrf
, vtysh_exit_vrf_cmd
, "exit",
2092 "Exit current mode and down to previous mode\n")
2094 return vtysh_exit(vty
);
2097 DEFUNSH(VTYSH_VRF
, vtysh_quit_vrf
, vtysh_quit_vrf_cmd
, "quit",
2098 "Exit current mode and down to previous mode\n")
2100 return vtysh_exit_vrf(self
, vty
, argc
, argv
);
2103 DEFUNSH(VTYSH_PBRD
, vtysh_exit_nexthop_group
, vtysh_exit_nexthop_group_cmd
,
2104 "exit", "Exit current mode and down to previous mode\n")
2106 return vtysh_exit(vty
);
2109 DEFUNSH(VTYSH_VRF
, vtysh_quit_nexthop_group
, vtysh_quit_nexthop_group_cmd
,
2110 "quit", "Exit current mode and down to previous mode\n")
2112 return vtysh_exit_nexthop_group(self
, vty
, argc
, argv
);
2116 * TODO Implement interface description commands in ripngd, ospf6d
2119 DEFSH(VTYSH_ZEBRA
| VTYSH_RIPD
| VTYSH_OSPFD
| VTYSH_EIGRPD
,
2120 vtysh_interface_desc_cmd
, "description LINE...",
2121 "Interface specific description\n"
2122 "Characters describing this interface\n")
2124 DEFSH(VTYSH_ZEBRA
| VTYSH_RIPD
| VTYSH_OSPFD
| VTYSH_EIGRPD
,
2125 vtysh_no_interface_desc_cmd
, "no description",
2126 NO_STR
"Interface specific description\n")
2128 DEFUNSH(VTYSH_INTERFACE
, vtysh_exit_interface
, vtysh_exit_interface_cmd
, "exit",
2129 "Exit current mode and down to previous mode\n")
2131 return vtysh_exit(vty
);
2134 DEFUNSH(VTYSH_INTERFACE
, vtysh_quit_interface
, vtysh_quit_interface_cmd
, "quit",
2135 "Exit current mode and down to previous mode\n")
2137 return vtysh_exit_interface(self
, vty
, argc
, argv
);
2140 DEFUN (vtysh_show_poll
,
2141 vtysh_show_poll_cmd
,
2144 "Thread information\n"
2145 "Thread Poll Information\n")
2148 int ret
= CMD_SUCCESS
;
2151 snprintf(line
, sizeof(line
), "do show thread poll\n");
2152 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2153 if (vtysh_client
[i
].fd
>= 0) {
2154 vty_out(vty
, "Thread statistics for %s:\n",
2155 vtysh_client
[i
].name
);
2156 ret
= vtysh_client_execute(&vtysh_client
[i
], line
);
2162 DEFUN (vtysh_show_thread
,
2163 vtysh_show_thread_cmd
,
2164 "show thread cpu [FILTER]",
2166 "Thread information\n"
2167 "Thread CPU usage\n"
2168 "Display filter (rwtexb)\n")
2172 int ret
= CMD_SUCCESS
;
2175 const char *filter
=
2176 argv_find(argv
, argc
, "FILTER", &idx
) ? argv
[idx
]->arg
: "";
2178 snprintf(line
, sizeof(line
), "do show thread cpu %s\n", filter
);
2179 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2180 if (vtysh_client
[i
].fd
>= 0) {
2181 vty_out(vty
, "Thread statistics for %s:\n",
2182 vtysh_client
[i
].name
);
2183 ret
= vtysh_client_execute(&vtysh_client
[i
], line
);
2189 DEFUN (vtysh_show_work_queues
,
2190 vtysh_show_work_queues_cmd
,
2193 "Work Queue information\n")
2196 int ret
= CMD_SUCCESS
;
2197 char line
[] = "do show work-queues\n";
2199 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2200 if (vtysh_client
[i
].fd
>= 0) {
2201 vty_out(vty
, "Work queue statistics for %s:\n",
2202 vtysh_client
[i
].name
);
2203 ret
= vtysh_client_execute(&vtysh_client
[i
], line
);
2210 DEFUN (vtysh_show_work_queues_daemon
,
2211 vtysh_show_work_queues_daemon_cmd
,
2212 "show work-queues <zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pbrd>",
2214 "Work Queue information\n"
2215 "For the zebra daemon\n"
2216 "For the rip daemon\n"
2217 "For the ripng daemon\n"
2218 "For the ospf daemon\n"
2219 "For the ospfv6 daemon\n"
2220 "For the bgp daemon\n"
2221 "For the isis daemon\n"
2222 "For the pbr daemon\n")
2224 int idx_protocol
= 2;
2226 int ret
= CMD_SUCCESS
;
2228 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
2229 if (strmatch(vtysh_client
[i
].name
, argv
[idx_protocol
]->text
))
2233 ret
= vtysh_client_execute(&vtysh_client
[i
], "show work-queues\n");
2238 DEFUNSH(VTYSH_ZEBRA
, vtysh_link_params
, vtysh_link_params_cmd
, "link-params",
2241 vty
->node
= LINK_PARAMS_NODE
;
2245 DEFUNSH(VTYSH_ZEBRA
, exit_link_params
, exit_link_params_cmd
, "exit-link-params",
2246 "Exit from Link Params configuration node\n")
2248 if (vty
->node
== LINK_PARAMS_NODE
)
2249 vty
->node
= INTERFACE_NODE
;
2253 static int show_per_daemon(const char *line
, const char *headline
)
2256 int ret
= CMD_SUCCESS
;
2258 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2259 if (vtysh_client
[i
].fd
>= 0) {
2260 vty_out(vty
, headline
, vtysh_client
[i
].name
);
2261 ret
= vtysh_client_execute(&vtysh_client
[i
], line
);
2268 DEFUNSH_HIDDEN (0x00,
2270 vtysh_debug_all_cmd
,
2274 "Toggle all debugs on or off\n")
2279 DEFUN (vtysh_show_debugging
,
2280 vtysh_show_debugging_cmd
,
2285 return show_per_daemon("do show debugging\n", "");
2288 DEFUN (vtysh_show_debugging_hashtable
,
2289 vtysh_show_debugging_hashtable_cmd
,
2290 "show debugging hashtable [statistics]",
2293 "Statistics about hash tables\n"
2294 "Statistics about hash tables\n")
2298 "Load factor (LF) - average number of elements across all buckets\n");
2300 "Full load factor (FLF) - average number of elements across full buckets\n\n");
2302 "Standard deviation (SD) is calculated for both the LF and FLF\n");
2304 "and indicates the typical deviation of bucket chain length\n");
2305 vty_out(vty
, "from the value in the corresponding load factor.\n\n");
2307 return show_per_daemon("do show debugging hashtable\n",
2308 "Hashtable statistics for %s:\n");
2312 DEFUN (vtysh_show_memory
,
2313 vtysh_show_memory_cmd
,
2316 "Memory statistics\n")
2318 return show_per_daemon("do show memory\n", "Memory statistics for %s:\n");
2321 DEFUN (vtysh_show_modules
,
2322 vtysh_show_modules_cmd
,
2327 return show_per_daemon("do show modules\n",
2328 "Module information for %s:\n");
2331 /* Logging commands. */
2332 DEFUN (vtysh_show_logging
,
2333 vtysh_show_logging_cmd
,
2336 "Show current logging configuration\n")
2338 return show_per_daemon("do show logging\n",
2339 "Logging configuration for %s:\n");
2342 DEFUNSH(VTYSH_ALL
, vtysh_log_stdout
, vtysh_log_stdout_cmd
, "log stdout",
2344 "Set stdout logging level\n")
2349 DEFUNSH(VTYSH_ALL
, vtysh_log_stdout_level
, vtysh_log_stdout_level_cmd
,
2350 "log stdout <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2352 "Set stdout logging level\n" LOG_LEVEL_DESC
)
2357 DEFUNSH(VTYSH_ALL
, no_vtysh_log_stdout
, no_vtysh_log_stdout_cmd
,
2358 "no log stdout [LEVEL]", NO_STR
2360 "Cancel logging to stdout\n"
2366 DEFUNSH(VTYSH_ALL
, vtysh_log_file
, vtysh_log_file_cmd
, "log file FILENAME",
2369 "Logging filename\n")
2374 DEFUNSH(VTYSH_ALL
, vtysh_log_file_level
, vtysh_log_file_level_cmd
,
2375 "log file FILENAME <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2378 "Logging filename\n" LOG_LEVEL_DESC
)
2383 DEFUNSH(VTYSH_ALL
, no_vtysh_log_file
, no_vtysh_log_file_cmd
,
2384 "no log file [FILENAME [LEVEL]]", NO_STR
2386 "Cancel logging to file\n"
2387 "Logging file name\n"
2393 DEFUNSH(VTYSH_ALL
, vtysh_log_monitor
, vtysh_log_monitor_cmd
,
2394 "log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
2396 "Set terminal line (monitor) logging level\n" LOG_LEVEL_DESC
)
2401 DEFUNSH(VTYSH_ALL
, no_vtysh_log_monitor
, no_vtysh_log_monitor_cmd
,
2402 "no log monitor [LEVEL]", NO_STR
2404 "Disable terminal line (monitor) logging\n"
2410 DEFUNSH(VTYSH_ALL
, vtysh_log_syslog
, vtysh_log_syslog_cmd
,
2411 "log syslog [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
2413 "Set syslog logging level\n" LOG_LEVEL_DESC
)
2418 DEFUNSH(VTYSH_ALL
, no_vtysh_log_syslog
, no_vtysh_log_syslog_cmd
,
2419 "no log syslog [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
2422 "Cancel logging to syslog\n"
2428 DEFUNSH(VTYSH_ALL
, vtysh_log_facility
, vtysh_log_facility_cmd
,
2429 "log facility <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>",
2431 "Facility parameter for syslog messages\n" LOG_FACILITY_DESC
)
2436 DEFUNSH(VTYSH_ALL
, no_vtysh_log_facility
, no_vtysh_log_facility_cmd
,
2437 "no log facility [FACILITY]", NO_STR
2439 "Reset syslog facility to default (daemon)\n"
2440 "Syslog facility\n")
2445 DEFUNSH(VTYSH_ALL
, vtysh_log_record_priority
, vtysh_log_record_priority_cmd
,
2446 "log record-priority",
2448 "Log the priority of the message within the message\n")
2453 DEFUNSH(VTYSH_ALL
, no_vtysh_log_record_priority
,
2454 no_vtysh_log_record_priority_cmd
, "no log record-priority", NO_STR
2456 "Do not log the priority of the message within the message\n")
2461 DEFUNSH(VTYSH_ALL
, vtysh_log_timestamp_precision
,
2462 vtysh_log_timestamp_precision_cmd
, "log timestamp precision (0-6)",
2464 "Timestamp configuration\n"
2465 "Set the timestamp precision\n"
2466 "Number of subsecond digits\n")
2471 DEFUNSH(VTYSH_ALL
, no_vtysh_log_timestamp_precision
,
2472 no_vtysh_log_timestamp_precision_cmd
, "no log timestamp precision",
2475 "Timestamp configuration\n"
2476 "Reset the timestamp precision to the default value of 0\n")
2481 DEFUNSH(VTYSH_ALL
, vtysh_service_password_encrypt
,
2482 vtysh_service_password_encrypt_cmd
, "service password-encryption",
2483 "Set up miscellaneous service\n"
2484 "Enable encrypted passwords\n")
2489 DEFUNSH(VTYSH_ALL
, no_vtysh_service_password_encrypt
,
2490 no_vtysh_service_password_encrypt_cmd
, "no service password-encryption",
2492 "Set up miscellaneous service\n"
2493 "Enable encrypted passwords\n")
2498 DEFUNSH(VTYSH_ALL
, vtysh_config_password
, vtysh_password_cmd
,
2499 "password [(8-8)] LINE",
2500 "Modify the terminal connection password\n"
2501 "Specifies a HIDDEN password will follow\n"
2502 "The password string\n")
2507 DEFUNSH(VTYSH_ALL
, no_vtysh_config_password
, no_vtysh_password_cmd
,
2508 "no password", NO_STR
2509 "Modify the terminal connection password\n")
2511 vty_out(vty
, NO_PASSWD_CMD_WARNING
);
2516 DEFUNSH(VTYSH_ALL
, vtysh_config_enable_password
, vtysh_enable_password_cmd
,
2517 "enable password [(8-8)] LINE",
2518 "Modify enable password parameters\n"
2519 "Assign the privileged level password\n"
2520 "Specifies a HIDDEN password will follow\n"
2521 "The 'enable' password string\n")
2526 DEFUNSH(VTYSH_ALL
, no_vtysh_config_enable_password
,
2527 no_vtysh_enable_password_cmd
, "no enable password", NO_STR
2528 "Modify enable password parameters\n"
2529 "Assign the privileged level password\n")
2531 vty_out(vty
, NO_PASSWD_CMD_WARNING
);
2536 DEFUN (vtysh_write_terminal
,
2537 vtysh_write_terminal_cmd
,
2538 "write terminal [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2539 "Write running configuration to memory, network, or terminal\n"
2540 "Write to terminal\n"
2541 "For the zebra daemon\n"
2542 "For the rip daemon\n"
2543 "For the ripng daemon\n"
2544 "For the ospf daemon\n"
2545 "For the ospfv6 daemon\n"
2546 "For the ldpd daemon\n"
2547 "For the bgp daemon\n"
2548 "For the isis daemon\n"
2549 "For the pim daemon\n")
2552 char line
[] = "do write terminal\n";
2554 vty_out(vty
, "Building configuration...\n");
2555 vty_out(vty
, "\nCurrent configuration:\n");
2556 vty_out(vty
, "!\n");
2558 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2560 || (strmatch(vtysh_client
[i
].name
, argv
[2]->text
)))
2561 vtysh_client_config(&vtysh_client
[i
], line
);
2563 /* Integrate vtysh specific configuration. */
2564 vty_open_pager(vty
);
2565 vtysh_config_write();
2566 vtysh_config_dump();
2567 vty_close_pager(vty
);
2568 vty_out(vty
, "end\n");
2573 DEFUN (vtysh_show_running_config
,
2574 vtysh_show_running_config_cmd
,
2575 "show running-config [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2577 "Current operating configuration\n"
2578 "For the zebra daemon\n"
2579 "For the rip daemon\n"
2580 "For the ripng daemon\n"
2581 "For the ospf daemon\n"
2582 "For the ospfv6 daemon\n"
2583 "For the ldp daemon\n"
2584 "For the bgp daemon\n"
2585 "For the isis daemon\n"
2586 "For the pim daemon\n")
2588 return vtysh_write_terminal(self
, vty
, argc
, argv
);
2591 DEFUN (vtysh_integrated_config
,
2592 vtysh_integrated_config_cmd
,
2593 "service integrated-vtysh-config",
2594 "Set up miscellaneous service\n"
2595 "Write configuration into integrated file\n")
2597 vtysh_write_integrated
= WRITE_INTEGRATED_YES
;
2601 DEFUN (no_vtysh_integrated_config
,
2602 no_vtysh_integrated_config_cmd
,
2603 "no service integrated-vtysh-config",
2605 "Set up miscellaneous service\n"
2606 "Write configuration into integrated file\n")
2608 vtysh_write_integrated
= WRITE_INTEGRATED_NO
;
2612 static void backup_config_file(const char *fbackup
)
2614 char *integrate_sav
= NULL
;
2616 integrate_sav
= malloc(strlen(fbackup
) + strlen(CONF_BACKUP_EXT
) + 1);
2617 strcpy(integrate_sav
, fbackup
);
2618 strcat(integrate_sav
, CONF_BACKUP_EXT
);
2620 /* Move current configuration file to backup config file. */
2621 if (unlink(integrate_sav
) != 0) {
2622 vty_out(vty
, "Warning: %s unlink failed\n", integrate_sav
);
2624 if (rename(fbackup
, integrate_sav
) != 0) {
2625 vty_out(vty
, "Error renaming %s to %s\n", fbackup
,
2628 free(integrate_sav
);
2631 int vtysh_write_config_integrated(void)
2634 char line
[] = "do write terminal\n";
2638 struct passwd
*pwentry
;
2641 struct group
*grentry
;
2648 vty_out(vty
, "Building Configuration...\n");
2650 backup_config_file(frr_config
);
2651 fp
= fopen(frr_config
, "w");
2654 "%% Error: failed to open configuration file %s: %s\n",
2655 frr_config
, safe_strerror(errno
));
2656 return CMD_WARNING_CONFIG_FAILED
;
2660 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2661 vtysh_client_config(&vtysh_client
[i
], line
);
2663 vtysh_config_write();
2664 vty
->of_saved
= vty
->of
;
2666 vtysh_config_dump();
2667 vty
->of
= vty
->of_saved
;
2669 if (fchmod(fd
, CONFIGFILE_MASK
) != 0) {
2670 printf("%% Warning: can't chmod configuration file %s: %s\n",
2671 frr_config
, safe_strerror(errno
));
2676 pwentry
= getpwnam(FRR_USER
);
2678 uid
= pwentry
->pw_uid
;
2680 printf("%% Warning: could not look up user \"%s\"\n", FRR_USER
);
2685 grentry
= getgrnam(FRR_GROUP
);
2687 gid
= grentry
->gr_gid
;
2689 printf("%% Warning: could not look up group \"%s\"\n",
2695 if (!fstat(fd
, &st
)) {
2696 if (st
.st_uid
== uid
)
2698 if (st
.st_gid
== gid
)
2700 if ((uid
!= (uid_t
)-1 || gid
!= (gid_t
)-1)
2701 && fchown(fd
, uid
, gid
)) {
2702 printf("%% Warning: can't chown configuration file %s: %s\n",
2703 frr_config
, safe_strerror(errno
));
2707 printf("%% Warning: stat() failed on %s: %s\n", frr_config
,
2708 safe_strerror(errno
));
2714 printf("Integrated configuration saved to %s\n", frr_config
);
2722 static bool want_config_integrated(void)
2726 switch (vtysh_write_integrated
) {
2727 case WRITE_INTEGRATED_UNSPECIFIED
:
2728 if (stat(frr_config
, &s
) && errno
== ENOENT
)
2731 case WRITE_INTEGRATED_NO
:
2733 case WRITE_INTEGRATED_YES
:
2739 DEFUN (vtysh_write_memory
,
2740 vtysh_write_memory_cmd
,
2741 "write [<memory|file>]",
2742 "Write running configuration to memory, network, or terminal\n"
2743 "Write configuration to the file (same as write file)\n"
2744 "Write configuration to the file (same as write memory)\n")
2746 int ret
= CMD_SUCCESS
;
2747 char line
[] = "do write memory\n";
2750 vty_out(vty
, "Note: this version of vtysh never writes vtysh.conf\n");
2752 /* If integrated frr.conf explicitely set. */
2753 if (want_config_integrated()) {
2754 ret
= CMD_WARNING_CONFIG_FAILED
;
2756 /* first attempt to use watchfrr if it's available */
2757 bool used_watchfrr
= false;
2759 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2760 if (vtysh_client
[i
].flag
== VTYSH_WATCHFRR
)
2762 if (i
< array_size(vtysh_client
) && vtysh_client
[i
].fd
!= -1) {
2763 used_watchfrr
= true;
2764 ret
= vtysh_client_execute(&vtysh_client
[i
],
2765 "do write integrated");
2769 * If we didn't use watchfrr, fallback to writing the config
2772 if (!used_watchfrr
) {
2773 printf("\nWarning: attempting direct configuration write without "
2774 "watchfrr.\nFile permissions and ownership may be "
2775 "incorrect, or write may fail.\n\n");
2776 ret
= vtysh_write_config_integrated();
2781 vty_out(vty
, "Building Configuration...\n");
2783 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2784 ret
= vtysh_client_execute(&vtysh_client
[i
], line
);
2789 DEFUN (vtysh_copy_running_config
,
2790 vtysh_copy_running_config_cmd
,
2791 "copy running-config startup-config",
2792 "Copy from one file to another\n"
2793 "Copy from current system configuration\n"
2794 "Copy to startup configuration\n")
2796 return vtysh_write_memory(self
, vty
, argc
, argv
);
2799 DEFUN (vtysh_terminal_length
,
2800 vtysh_terminal_length_cmd
,
2801 "terminal length (0-512)",
2802 "Set terminal line parameters\n"
2803 "Set number of lines on a screen\n"
2804 "Number of lines on screen (0 for no pausing)\n")
2808 char *endptr
= NULL
;
2809 char default_pager
[10];
2811 lines
= strtol(argv
[idx_number
]->arg
, &endptr
, 10);
2812 if (lines
< 0 || lines
> 512 || *endptr
!= '\0') {
2813 vty_out(vty
, "length is malformed\n");
2817 if (vtysh_pager_name
) {
2818 free(vtysh_pager_name
);
2819 vtysh_pager_name
= NULL
;
2823 snprintf(default_pager
, 10, "more -%i", lines
);
2824 vtysh_pager_name
= strdup(default_pager
);
2830 DEFUN (vtysh_terminal_no_length
,
2831 vtysh_terminal_no_length_cmd
,
2832 "terminal no length",
2833 "Set terminal line parameters\n"
2835 "Set number of lines on a screen\n")
2837 if (vtysh_pager_name
) {
2838 free(vtysh_pager_name
);
2839 vtysh_pager_name
= NULL
;
2846 DEFUN (vtysh_show_daemons
,
2847 vtysh_show_daemons_cmd
,
2850 "Show list of running daemons\n")
2854 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2855 if (vtysh_client
[i
].fd
>= 0)
2856 vty_out(vty
, " %s", vtysh_client
[i
].name
);
2862 /* Execute command in child process. */
2863 static void execute_command(const char *command
, int argc
, const char *arg1
,
2873 /* Failure of fork(). */
2874 fprintf(stderr
, "Can't fork: %s\n", safe_strerror(errno
));
2876 } else if (pid
== 0) {
2877 /* This is child process. */
2880 execlp(command
, command
, (const char *)NULL
);
2883 execlp(command
, command
, arg1
, (const char *)NULL
);
2886 execlp(command
, command
, arg1
, arg2
,
2887 (const char *)NULL
);
2891 /* When execlp suceed, this part is not executed. */
2892 fprintf(stderr
, "Can't execute %s: %s\n", command
,
2893 safe_strerror(errno
));
2896 /* This is parent. */
2898 wait4(pid
, &status
, 0, NULL
);
2906 "Send echo messages\n"
2907 "Ping destination address or hostname\n")
2911 argv_find(argv
, argc
, "WORD", &idx
);
2912 execute_command("ping", 1, argv
[idx
]->arg
, NULL
);
2916 ALIAS(vtysh_ping
, vtysh_ping_ip_cmd
, "ping ip WORD",
2917 "Send echo messages\n"
2919 "Ping destination address or hostname\n")
2921 DEFUN (vtysh_traceroute
,
2922 vtysh_traceroute_cmd
,
2924 "Trace route to destination\n"
2925 "Trace route to destination address or hostname\n")
2929 argv_find(argv
, argc
, "WORD", &idx
);
2930 execute_command("traceroute", 1, argv
[idx
]->arg
, NULL
);
2934 ALIAS(vtysh_traceroute
, vtysh_traceroute_ip_cmd
, "traceroute ip WORD",
2935 "Trace route to destination\n"
2937 "Trace route to destination address or hostname\n")
2939 DEFUN (vtysh_mtrace
,
2941 "mtrace WORD [WORD]",
2942 "Multicast trace route to multicast source\n"
2943 "Multicast trace route to multicast source address\n"
2944 "Multicast trace route for multicast group address\n")
2947 execute_command("mtracebis", 1, argv
[1]->arg
, NULL
);
2949 execute_command("mtracebis", 2, argv
[1]->arg
, argv
[2]->arg
);
2956 "Send echo messages\n"
2958 "Ping destination address or hostname\n")
2960 execute_command("ping6", 1, argv
[2]->arg
, NULL
);
2964 DEFUN (vtysh_traceroute6
,
2965 vtysh_traceroute6_cmd
,
2966 "traceroute ipv6 WORD",
2967 "Trace route to destination\n"
2969 "Trace route to destination address or hostname\n")
2971 execute_command("traceroute6", 1, argv
[2]->arg
, NULL
);
2975 #if defined(HAVE_SHELL_ACCESS)
2976 DEFUN (vtysh_telnet
,
2979 "Open a telnet connection\n"
2980 "IP address or hostname of a remote system\n")
2982 execute_command("telnet", 1, argv
[1]->arg
, NULL
);
2986 DEFUN (vtysh_telnet_port
,
2987 vtysh_telnet_port_cmd
,
2989 "Open a telnet connection\n"
2990 "IP address or hostname of a remote system\n"
2991 "TCP Port number\n")
2993 execute_command("telnet", 2, argv
[1]->arg
, argv
[2]->arg
);
3000 "Open an ssh connection\n"
3003 execute_command("ssh", 1, argv
[1]->arg
, NULL
);
3007 DEFUN (vtysh_start_shell
,
3008 vtysh_start_shell_cmd
,
3010 "Start UNIX shell\n")
3012 execute_command("sh", 0, NULL
, NULL
);
3016 DEFUN (vtysh_start_bash
,
3017 vtysh_start_bash_cmd
,
3019 "Start UNIX shell\n"
3022 execute_command("bash", 0, NULL
, NULL
);
3026 DEFUN (vtysh_start_zsh
,
3027 vtysh_start_zsh_cmd
,
3029 "Start UNIX shell\n"
3032 execute_command("zsh", 0, NULL
, NULL
);
3039 "list [permutations]",
3040 "Print command list\n"
3041 "Print all possible command permutations\n")
3043 return cmd_list_cmds(vty
, argc
== 2);
3046 DEFUN (vtysh_output_file
,
3047 vtysh_output_file_cmd
,
3049 "Direct vtysh output to file\n"
3050 "Direct vtysh output to file\n"
3051 "Path to dump output to\n")
3053 const char *path
= argv
[argc
- 1]->arg
;
3054 vty
->of
= fopen(path
, "a");
3056 vty_out(vty
, "Failed to open file '%s': %s\n", path
,
3057 safe_strerror(errno
));
3063 DEFUN (no_vtysh_output_file
,
3064 no_vtysh_output_file_cmd
,
3065 "no output file [FILE]",
3067 "Direct vtysh output to file\n"
3068 "Direct vtysh output to file\n"
3069 "Path to dump output to\n")
3071 if (vty
->of
!= stdout
) {
3081 "Find CLI command containing text\n"
3082 "Text to search for\n")
3084 char *text
= argv_concat(argv
, argc
, 1);
3085 const struct cmd_node
*node
;
3086 const struct cmd_element
*cli
;
3089 for (unsigned int i
= 0; i
< vector_active(cmdvec
); i
++) {
3090 node
= vector_slot(cmdvec
, i
);
3093 clis
= node
->cmd_vector
;
3094 for (unsigned int j
= 0; j
< vector_active(clis
); j
++) {
3095 cli
= vector_slot(clis
, j
);
3096 if (strcasestr(cli
->string
, text
))
3097 vty_out(vty
, " (%s) %s\n",
3098 node_names
[node
->node
], cli
->string
);
3102 XFREE(MTYPE_TMP
, text
);
3107 DEFUN_HIDDEN(show_cli_graph_vtysh
,
3108 show_cli_graph_vtysh_cmd
,
3112 "Dump current command space as DOT graph\n")
3114 struct cmd_node
*cn
= vector_slot(cmdvec
, vty
->node
);
3115 char *dot
= cmd_graph_dump_dot(cn
->cmdgraph
);
3117 vty_out(vty
, "%s\n", dot
);
3118 XFREE(MTYPE_TMP
, dot
);
3122 static void vtysh_install_default(enum node_type node
)
3124 install_element(node
, &config_list_cmd
);
3125 install_element(node
, &find_cmd
);
3126 install_element(node
, &show_cli_graph_vtysh_cmd
);
3127 install_element(node
, &vtysh_output_file_cmd
);
3128 install_element(node
, &no_vtysh_output_file_cmd
);
3131 /* Making connection to protocol daemon. */
3132 static int vtysh_connect(struct vtysh_client
*vclient
)
3136 struct sockaddr_un addr
;
3140 if (!vclient
->path
[0])
3141 snprintf(vclient
->path
, sizeof(vclient
->path
), "%s/%s.vty",
3142 vtydir
, vclient
->name
);
3143 path
= vclient
->path
;
3145 /* Stat socket to see if we have permission to access it. */
3146 ret
= stat(path
, &s_stat
);
3147 if (ret
< 0 && errno
!= ENOENT
) {
3148 fprintf(stderr
, "vtysh_connect(%s): stat = %s\n", path
,
3149 safe_strerror(errno
));
3154 if (!S_ISSOCK(s_stat
.st_mode
)) {
3155 fprintf(stderr
, "vtysh_connect(%s): Not a socket\n",
3161 sock
= socket(AF_UNIX
, SOCK_STREAM
, 0);
3164 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", path
,
3165 safe_strerror(errno
));
3170 memset(&addr
, 0, sizeof(struct sockaddr_un
));
3171 addr
.sun_family
= AF_UNIX
;
3172 strlcpy(addr
.sun_path
, path
, sizeof(addr
.sun_path
));
3173 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
3174 len
= addr
.sun_len
= SUN_LEN(&addr
);
3176 len
= sizeof(addr
.sun_family
) + strlen(addr
.sun_path
);
3177 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
3179 ret
= connect(sock
, (struct sockaddr
*)&addr
, len
);
3182 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", path
,
3183 safe_strerror(errno
));
3193 static int vtysh_reconnect(struct vtysh_client
*vclient
)
3197 fprintf(stderr
, "Warning: connecting to %s...", vclient
->name
);
3198 ret
= vtysh_connect(vclient
);
3200 fprintf(stderr
, "failed!\n");
3203 fprintf(stderr
, "success!\n");
3204 if (vtysh_client_execute(vclient
, "enable") < 0)
3206 return vtysh_execute_no_pager("end");
3209 /* Return true if str ends with suffix, else return false */
3210 static int ends_with(const char *str
, const char *suffix
)
3212 if (!str
|| !suffix
)
3214 size_t lenstr
= strlen(str
);
3215 size_t lensuffix
= strlen(suffix
);
3216 if (lensuffix
> lenstr
)
3218 return strncmp(str
+ lenstr
- lensuffix
, suffix
, lensuffix
) == 0;
3221 static void vtysh_client_sorted_insert(struct vtysh_client
*head_client
,
3222 struct vtysh_client
*client
)
3224 struct vtysh_client
*prev_node
, *current_node
;
3226 prev_node
= head_client
;
3227 current_node
= head_client
->next
;
3228 while (current_node
) {
3229 if (strcmp(current_node
->path
, client
->path
) > 0)
3232 prev_node
= current_node
;
3233 current_node
= current_node
->next
;
3235 client
->next
= current_node
;
3236 prev_node
->next
= client
;
3239 #define MAXIMUM_INSTANCES 10
3241 static void vtysh_update_all_insances(struct vtysh_client
*head_client
)
3243 struct vtysh_client
*client
;
3245 struct dirent
*file
;
3248 if (head_client
->flag
!= VTYSH_OSPFD
)
3251 /* ls vty_sock_dir and look for all files ending in .vty */
3252 dir
= opendir(vtydir
);
3254 while ((file
= readdir(dir
)) != NULL
) {
3255 if (begins_with(file
->d_name
, "ospfd-")
3256 && ends_with(file
->d_name
, ".vty")) {
3257 if (n
== MAXIMUM_INSTANCES
) {
3259 "Parsing %s, client limit(%d) reached!\n",
3263 client
= (struct vtysh_client
*)malloc(
3264 sizeof(struct vtysh_client
));
3266 client
->name
= "ospfd";
3267 client
->flag
= VTYSH_OSPFD
;
3268 snprintf(client
->path
, sizeof(client
->path
),
3269 "%s/%s", vtydir
, file
->d_name
);
3270 client
->next
= NULL
;
3271 vtysh_client_sorted_insert(head_client
, client
);
3279 static int vtysh_connect_all_instances(struct vtysh_client
*head_client
)
3281 struct vtysh_client
*client
;
3284 vtysh_update_all_insances(head_client
);
3286 client
= head_client
->next
;
3288 if (vtysh_connect(client
) == 0)
3290 client
= client
->next
;
3296 int vtysh_connect_all(const char *daemon_name
)
3302 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
3304 || !strcmp(daemon_name
, vtysh_client
[i
].name
)) {
3306 if (vtysh_connect(&vtysh_client
[i
]) == 0)
3309 rc
+= vtysh_connect_all_instances(&vtysh_client
[i
]);
3313 fprintf(stderr
, "Error: no daemons match name %s!\n",
3318 /* To disable readline's filename completion. */
3319 static char *vtysh_completion_entry_function(const char *ignore
,
3325 void vtysh_readline_init(void)
3327 /* readline related settings. */
3329 rl_bind_key('?', (rl_command_func_t
*)vtysh_rl_describe
);
3330 rl_completion_entry_function
= vtysh_completion_entry_function
;
3331 rl_attempted_completion_function
=
3332 (rl_completion_func_t
*)new_completion
;
3335 char *vtysh_prompt(void)
3337 static char buf
[100];
3339 snprintf(buf
, sizeof buf
, cmd_prompt(vty
->node
), cmd_hostname_get());
3343 static void vtysh_ac_line(void *arg
, const char *line
)
3347 for (i
= 0; i
< vector_active(comps
); i
++)
3348 if (!strcmp(line
, (char *)vector_slot(comps
, i
)))
3350 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, line
));
3353 static void vtysh_autocomplete(vector comps
, struct cmd_token
*token
)
3358 snprintf(accmd
, sizeof(accmd
), "autocomplete %d %s %s", token
->type
,
3359 token
->text
, token
->varname
? token
->varname
: "-");
3361 vty
->of_saved
= vty
->of
;
3363 for (i
= 0; i
< array_size(vtysh_client
); i
++)
3364 vtysh_client_run_all(&vtysh_client
[i
], accmd
, 1, vtysh_ac_line
,
3366 vty
->of
= vty
->of_saved
;
3369 static const struct cmd_variable_handler vtysh_var_handler
[] = {
3373 .completions
= vtysh_autocomplete
},
3374 {.completions
= NULL
}};
3378 if (vty
->of
!= stdout
)
3382 void vtysh_init_vty(void)
3384 /* Make vty structure. */
3386 vty
->type
= VTY_SHELL
;
3387 vty
->node
= VIEW_NODE
;
3389 /* set default output */
3392 /* Initialize commands. */
3394 cmd_variable_handler_register(vtysh_var_handler
);
3396 /* Install nodes. */
3397 install_node(&bgp_node
, NULL
);
3398 install_node(&rip_node
, NULL
);
3399 install_node(&interface_node
, NULL
);
3400 install_node(&pw_node
, NULL
);
3401 install_node(&link_params_node
, NULL
);
3402 install_node(&logicalrouter_node
, NULL
);
3403 install_node(&vrf_node
, NULL
);
3404 install_node(&nh_group_node
, NULL
);
3405 install_node(&rmap_node
, NULL
);
3406 install_node(&pbr_map_node
, NULL
);
3407 install_node(&zebra_node
, NULL
);
3408 install_node(&bgp_vpnv4_node
, NULL
);
3409 install_node(&bgp_vpnv6_node
, NULL
);
3410 install_node(&bgp_flowspecv4_node
, NULL
);
3411 install_node(&bgp_flowspecv6_node
, NULL
);
3412 install_node(&bgp_ipv4_node
, NULL
);
3413 install_node(&bgp_ipv4m_node
, NULL
);
3414 install_node(&bgp_ipv4l_node
, NULL
);
3415 install_node(&bgp_ipv6_node
, NULL
);
3416 install_node(&bgp_ipv6m_node
, NULL
);
3417 install_node(&bgp_ipv6l_node
, NULL
);
3418 install_node(&bgp_vrf_policy_node
, NULL
);
3419 install_node(&bgp_evpn_node
, NULL
);
3420 install_node(&bgp_evpn_vni_node
, NULL
);
3421 install_node(&bgp_vnc_defaults_node
, NULL
);
3422 install_node(&bgp_vnc_nve_group_node
, NULL
);
3423 install_node(&bgp_vnc_l2_group_node
, NULL
);
3424 install_node(&ospf_node
, NULL
);
3425 install_node(&eigrp_node
, NULL
);
3426 install_node(&babel_node
, NULL
);
3427 install_node(&ripng_node
, NULL
);
3428 install_node(&ospf6_node
, NULL
);
3429 install_node(&ldp_node
, NULL
);
3430 install_node(&ldp_ipv4_node
, NULL
);
3431 install_node(&ldp_ipv6_node
, NULL
);
3432 install_node(&ldp_ipv4_iface_node
, NULL
);
3433 install_node(&ldp_ipv6_iface_node
, NULL
);
3434 install_node(&ldp_l2vpn_node
, NULL
);
3435 install_node(&ldp_pseudowire_node
, NULL
);
3436 install_node(&keychain_node
, NULL
);
3437 install_node(&keychain_key_node
, NULL
);
3438 install_node(&isis_node
, NULL
);
3439 install_node(&vty_node
, NULL
);
3440 #if defined(HAVE_RPKI)
3441 install_node(&rpki_node
, NULL
);
3444 struct cmd_node
*node
;
3445 for (unsigned int i
= 0; i
< vector_active(cmdvec
); i
++) {
3446 node
= vector_slot(cmdvec
, i
);
3447 if (!node
|| node
->node
== VIEW_NODE
)
3449 vtysh_install_default(node
->node
);
3452 install_element(VIEW_NODE
, &vtysh_enable_cmd
);
3453 install_element(ENABLE_NODE
, &vtysh_config_terminal_cmd
);
3454 install_element(ENABLE_NODE
, &vtysh_disable_cmd
);
3456 /* "exit" command. */
3457 install_element(VIEW_NODE
, &vtysh_exit_all_cmd
);
3458 install_element(CONFIG_NODE
, &vtysh_exit_all_cmd
);
3459 install_element(VIEW_NODE
, &vtysh_quit_all_cmd
);
3460 install_element(CONFIG_NODE
, &vtysh_quit_all_cmd
);
3461 install_element(RIP_NODE
, &vtysh_exit_ripd_cmd
);
3462 install_element(RIP_NODE
, &vtysh_quit_ripd_cmd
);
3463 install_element(RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
3464 install_element(RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
3465 install_element(OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
3466 install_element(OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
3467 install_element(EIGRP_NODE
, &vtysh_exit_eigrpd_cmd
);
3468 install_element(EIGRP_NODE
, &vtysh_quit_eigrpd_cmd
);
3469 install_element(BABEL_NODE
, &vtysh_exit_babeld_cmd
);
3470 install_element(BABEL_NODE
, &vtysh_quit_babeld_cmd
);
3471 install_element(OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
3472 install_element(OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
3473 #if defined(HAVE_LDPD)
3474 install_element(LDP_NODE
, &vtysh_exit_ldpd_cmd
);
3475 install_element(LDP_NODE
, &vtysh_quit_ldpd_cmd
);
3476 install_element(LDP_IPV4_NODE
, &vtysh_exit_ldpd_cmd
);
3477 install_element(LDP_IPV4_NODE
, &vtysh_quit_ldpd_cmd
);
3478 install_element(LDP_IPV4_NODE
, &ldp_exit_address_family_cmd
);
3479 install_element(LDP_IPV6_NODE
, &vtysh_exit_ldpd_cmd
);
3480 install_element(LDP_IPV6_NODE
, &vtysh_quit_ldpd_cmd
);
3481 install_element(LDP_IPV6_NODE
, &ldp_exit_address_family_cmd
);
3482 install_element(LDP_IPV4_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3483 install_element(LDP_IPV4_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3484 install_element(LDP_IPV6_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3485 install_element(LDP_IPV6_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3486 install_element(LDP_L2VPN_NODE
, &vtysh_exit_ldpd_cmd
);
3487 install_element(LDP_L2VPN_NODE
, &vtysh_quit_ldpd_cmd
);
3488 install_element(LDP_PSEUDOWIRE_NODE
, &vtysh_exit_ldpd_cmd
);
3489 install_element(LDP_PSEUDOWIRE_NODE
, &vtysh_quit_ldpd_cmd
);
3491 install_element(BGP_NODE
, &vtysh_exit_bgpd_cmd
);
3492 install_element(BGP_NODE
, &vtysh_quit_bgpd_cmd
);
3493 install_element(BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
3494 install_element(BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
3495 install_element(BGP_VPNV6_NODE
, &vtysh_exit_bgpd_cmd
);
3496 install_element(BGP_VPNV6_NODE
, &vtysh_quit_bgpd_cmd
);
3497 install_element(BGP_FLOWSPECV4_NODE
, &vtysh_exit_bgpd_cmd
);
3498 install_element(BGP_FLOWSPECV4_NODE
, &vtysh_quit_bgpd_cmd
);
3499 install_element(BGP_FLOWSPECV6_NODE
, &vtysh_exit_bgpd_cmd
);
3500 install_element(BGP_FLOWSPECV6_NODE
, &vtysh_quit_bgpd_cmd
);
3501 install_element(BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
3502 install_element(BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
3503 install_element(BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
3504 install_element(BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
3505 install_element(BGP_IPV4L_NODE
, &vtysh_exit_bgpd_cmd
);
3506 install_element(BGP_IPV4L_NODE
, &vtysh_quit_bgpd_cmd
);
3507 install_element(BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
3508 install_element(BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
3509 install_element(BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
3510 install_element(BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
3511 install_element(BGP_EVPN_NODE
, &vtysh_quit_bgpd_cmd
);
3512 install_element(BGP_EVPN_NODE
, &vtysh_exit_bgpd_cmd
);
3513 install_element(BGP_EVPN_VNI_NODE
, &vtysh_exit_bgpd_cmd
);
3514 install_element(BGP_EVPN_VNI_NODE
, &vtysh_quit_bgpd_cmd
);
3515 install_element(BGP_IPV6L_NODE
, &vtysh_exit_bgpd_cmd
);
3516 install_element(BGP_IPV6L_NODE
, &vtysh_quit_bgpd_cmd
);
3517 #if defined(ENABLE_BGP_VNC)
3518 install_element(BGP_VRF_POLICY_NODE
, &vtysh_exit_bgpd_cmd
);
3519 install_element(BGP_VRF_POLICY_NODE
, &vtysh_quit_bgpd_cmd
);
3520 install_element(BGP_VNC_DEFAULTS_NODE
, &vtysh_exit_bgpd_cmd
);
3521 install_element(BGP_VNC_DEFAULTS_NODE
, &vtysh_quit_bgpd_cmd
);
3522 install_element(BGP_VNC_NVE_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3523 install_element(BGP_VNC_NVE_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3524 install_element(BGP_VNC_L2_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3525 install_element(BGP_VNC_L2_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3527 install_element(ISIS_NODE
, &vtysh_exit_isisd_cmd
);
3528 install_element(ISIS_NODE
, &vtysh_quit_isisd_cmd
);
3529 install_element(KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
3530 install_element(KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
3531 install_element(KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
3532 install_element(KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
3533 install_element(RMAP_NODE
, &vtysh_exit_rmap_cmd
);
3534 install_element(RMAP_NODE
, &vtysh_quit_rmap_cmd
);
3535 install_element(PBRMAP_NODE
, &vtysh_exit_pbr_map_cmd
);
3536 install_element(PBRMAP_NODE
, &vtysh_quit_pbr_map_cmd
);
3537 install_element(VTY_NODE
, &vtysh_exit_line_vty_cmd
);
3538 install_element(VTY_NODE
, &vtysh_quit_line_vty_cmd
);
3540 /* "end" command. */
3541 install_element(CONFIG_NODE
, &vtysh_end_all_cmd
);
3542 install_element(ENABLE_NODE
, &vtysh_end_all_cmd
);
3543 install_element(RIP_NODE
, &vtysh_end_all_cmd
);
3544 install_element(RIPNG_NODE
, &vtysh_end_all_cmd
);
3545 install_element(OSPF_NODE
, &vtysh_end_all_cmd
);
3546 install_element(EIGRP_NODE
, &vtysh_end_all_cmd
);
3547 install_element(BABEL_NODE
, &vtysh_end_all_cmd
);
3548 install_element(OSPF6_NODE
, &vtysh_end_all_cmd
);
3549 install_element(LDP_NODE
, &vtysh_end_all_cmd
);
3550 install_element(LDP_IPV4_NODE
, &vtysh_end_all_cmd
);
3551 install_element(LDP_IPV6_NODE
, &vtysh_end_all_cmd
);
3552 install_element(LDP_IPV4_IFACE_NODE
, &vtysh_end_all_cmd
);
3553 install_element(LDP_IPV6_IFACE_NODE
, &vtysh_end_all_cmd
);
3554 install_element(LDP_L2VPN_NODE
, &vtysh_end_all_cmd
);
3555 install_element(LDP_PSEUDOWIRE_NODE
, &vtysh_end_all_cmd
);
3556 install_element(BGP_NODE
, &vtysh_end_all_cmd
);
3557 install_element(BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
3558 install_element(BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
3559 install_element(BGP_IPV4L_NODE
, &vtysh_end_all_cmd
);
3560 install_element(BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
3561 install_element(BGP_VPNV6_NODE
, &vtysh_end_all_cmd
);
3562 install_element(BGP_FLOWSPECV4_NODE
, &vtysh_end_all_cmd
);
3563 install_element(BGP_FLOWSPECV6_NODE
, &vtysh_end_all_cmd
);
3564 install_element(BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
3565 install_element(BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
3566 install_element(BGP_IPV6L_NODE
, &vtysh_end_all_cmd
);
3567 install_element(BGP_VRF_POLICY_NODE
, &vtysh_end_all_cmd
);
3568 install_element(BGP_EVPN_NODE
, &vtysh_end_all_cmd
);
3569 install_element(BGP_EVPN_VNI_NODE
, &vtysh_end_all_cmd
);
3570 install_element(BGP_VNC_DEFAULTS_NODE
, &vtysh_end_all_cmd
);
3571 install_element(BGP_VNC_NVE_GROUP_NODE
, &vtysh_end_all_cmd
);
3572 install_element(BGP_VNC_L2_GROUP_NODE
, &vtysh_end_all_cmd
);
3573 install_element(ISIS_NODE
, &vtysh_end_all_cmd
);
3574 install_element(KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
3575 install_element(KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
3576 install_element(RMAP_NODE
, &vtysh_end_all_cmd
);
3577 install_element(PBRMAP_NODE
, &vtysh_end_all_cmd
);
3578 install_element(VTY_NODE
, &vtysh_end_all_cmd
);
3580 install_element(INTERFACE_NODE
, &vtysh_interface_desc_cmd
);
3581 install_element(INTERFACE_NODE
, &vtysh_no_interface_desc_cmd
);
3582 install_element(INTERFACE_NODE
, &vtysh_end_all_cmd
);
3583 install_element(INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
3584 install_element(LINK_PARAMS_NODE
, &exit_link_params_cmd
);
3585 install_element(LINK_PARAMS_NODE
, &vtysh_end_all_cmd
);
3586 install_element(LINK_PARAMS_NODE
, &vtysh_exit_interface_cmd
);
3587 install_element(INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
3589 install_element(PW_NODE
, &vtysh_end_all_cmd
);
3590 install_element(PW_NODE
, &vtysh_exit_interface_cmd
);
3591 install_element(PW_NODE
, &vtysh_quit_interface_cmd
);
3593 install_element(LOGICALROUTER_NODE
, &vtysh_end_all_cmd
);
3595 install_element(CONFIG_NODE
, &vtysh_logicalrouter_cmd
);
3596 install_element(CONFIG_NODE
, &vtysh_no_logicalrouter_cmd
);
3597 install_element(LOGICALROUTER_NODE
, &vtysh_exit_logicalrouter_cmd
);
3598 install_element(LOGICALROUTER_NODE
, &vtysh_quit_logicalrouter_cmd
);
3600 install_element(CONFIG_NODE
, &vtysh_nexthop_group_cmd
);
3601 install_element(NH_GROUP_NODE
, &vtysh_end_all_cmd
);
3602 install_element(NH_GROUP_NODE
, &vtysh_exit_nexthop_group_cmd
);
3603 install_element(NH_GROUP_NODE
, &vtysh_quit_nexthop_group_cmd
);
3605 install_element(VRF_NODE
, &vtysh_end_all_cmd
);
3606 install_element(VRF_NODE
, &vtysh_exit_vrf_cmd
);
3607 install_element(VRF_NODE
, &vtysh_quit_vrf_cmd
);
3609 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
3610 install_element(CONFIG_NODE
, &router_babel_cmd
);
3611 install_element(CONFIG_NODE
, &router_rip_cmd
);
3612 install_element(CONFIG_NODE
, &router_ripng_cmd
);
3613 install_element(CONFIG_NODE
, &router_ospf_cmd
);
3614 install_element(CONFIG_NODE
, &router_ospf6_cmd
);
3615 #if defined(HAVE_LDPD)
3616 install_element(CONFIG_NODE
, &ldp_mpls_ldp_cmd
);
3617 install_element(LDP_NODE
, &ldp_address_family_ipv4_cmd
);
3618 install_element(LDP_NODE
, &ldp_address_family_ipv6_cmd
);
3619 install_element(LDP_IPV4_NODE
, &ldp_interface_ifname_cmd
);
3620 install_element(LDP_IPV6_NODE
, &ldp_interface_ifname_cmd
);
3621 install_element(CONFIG_NODE
, &ldp_l2vpn_word_type_vpls_cmd
);
3622 install_element(LDP_L2VPN_NODE
, &ldp_member_pseudowire_ifname_cmd
);
3624 install_element(CONFIG_NODE
, &router_isis_cmd
);
3625 install_element(CONFIG_NODE
, &router_bgp_cmd
);
3626 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
3627 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
3628 #if defined(ENABLE_BGP_VNC)
3629 install_element(BGP_NODE
, &vnc_vrf_policy_cmd
);
3630 install_element(BGP_NODE
, &vnc_defaults_cmd
);
3631 install_element(BGP_NODE
, &vnc_nve_group_cmd
);
3632 install_element(BGP_NODE
, &vnc_l2_group_cmd
);
3634 install_element(BGP_NODE
, &address_family_ipv4_cmd
);
3635 install_element(BGP_NODE
, &address_family_ipv4_multicast_cmd
);
3636 install_element(BGP_NODE
, &address_family_ipv4_vpn_cmd
);
3637 install_element(BGP_NODE
, &address_family_ipv4_labeled_unicast_cmd
);
3638 install_element(BGP_NODE
, &address_family_ipv6_cmd
);
3639 install_element(BGP_NODE
, &address_family_ipv6_multicast_cmd
);
3640 install_element(BGP_NODE
, &address_family_ipv6_vpn_cmd
);
3641 install_element(BGP_NODE
, &address_family_ipv6_labeled_unicast_cmd
);
3642 install_element(BGP_NODE
, &address_family_evpn_cmd
);
3643 install_element(BGP_NODE
, &address_family_flowspecv4_cmd
);
3644 install_element(BGP_NODE
, &address_family_flowspecv6_cmd
);
3645 #if defined(HAVE_CUMULUS)
3646 install_element(BGP_NODE
, &address_family_evpn2_cmd
);
3648 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
3649 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
3650 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
3651 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
3652 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
3653 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
3654 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
3655 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
3656 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
3657 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
3658 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
3660 #if defined(HAVE_RPKI)
3661 install_element(CONFIG_NODE
, &rpki_cmd
);
3662 install_element(RPKI_NODE
, &rpki_exit_cmd
);
3663 install_element(RPKI_NODE
, &rpki_quit_cmd
);
3664 install_element(RPKI_NODE
, &vtysh_end_all_cmd
);
3668 install_element(BGP_EVPN_NODE
, &bgp_evpn_vni_cmd
);
3669 install_element(BGP_EVPN_VNI_NODE
, &exit_vni_cmd
);
3671 install_element(BGP_VRF_POLICY_NODE
, &exit_vrf_policy_cmd
);
3672 install_element(BGP_VNC_DEFAULTS_NODE
, &exit_vnc_config_cmd
);
3673 install_element(BGP_VNC_NVE_GROUP_NODE
, &exit_vnc_config_cmd
);
3674 install_element(BGP_VNC_L2_GROUP_NODE
, &exit_vnc_config_cmd
);
3676 install_element(CONFIG_NODE
, &key_chain_cmd
);
3677 install_element(CONFIG_NODE
, &vtysh_route_map_cmd
);
3678 install_element(CONFIG_NODE
, &vtysh_pbr_map_cmd
);
3679 install_element(CONFIG_NODE
, &vtysh_no_pbr_map_cmd
);
3680 install_element(CONFIG_NODE
, &vtysh_line_vty_cmd
);
3681 install_element(KEYCHAIN_NODE
, &key_cmd
);
3682 install_element(KEYCHAIN_NODE
, &key_chain_cmd
);
3683 install_element(KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
3684 install_element(CONFIG_NODE
, &vtysh_interface_cmd
);
3685 install_element(CONFIG_NODE
, &vtysh_no_interface_cmd
);
3686 install_element(CONFIG_NODE
, &vtysh_no_interface_vrf_cmd
);
3687 install_element(CONFIG_NODE
, &vtysh_pseudowire_cmd
);
3688 install_element(INTERFACE_NODE
, &vtysh_link_params_cmd
);
3689 install_element(ENABLE_NODE
, &vtysh_show_running_config_cmd
);
3690 install_element(ENABLE_NODE
, &vtysh_copy_running_config_cmd
);
3692 install_element(VRF_NODE
, &exit_vrf_config_cmd
);
3694 install_element(CONFIG_NODE
, &vtysh_vrf_cmd
);
3695 install_element(CONFIG_NODE
, &vtysh_no_vrf_cmd
);
3696 install_element(CONFIG_NODE
, &vtysh_no_nexthop_group_cmd
);
3698 /* "write terminal" command. */
3699 install_element(ENABLE_NODE
, &vtysh_write_terminal_cmd
);
3701 install_element(CONFIG_NODE
, &vtysh_integrated_config_cmd
);
3702 install_element(CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
3704 /* "write memory" command. */
3705 install_element(ENABLE_NODE
, &vtysh_write_memory_cmd
);
3707 install_element(VIEW_NODE
, &vtysh_terminal_length_cmd
);
3708 install_element(VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
3709 install_element(VIEW_NODE
, &vtysh_show_daemons_cmd
);
3711 install_element(VIEW_NODE
, &vtysh_ping_cmd
);
3712 install_element(VIEW_NODE
, &vtysh_ping_ip_cmd
);
3713 install_element(VIEW_NODE
, &vtysh_traceroute_cmd
);
3714 install_element(VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
3715 install_element(VIEW_NODE
, &vtysh_mtrace_cmd
);
3716 install_element(VIEW_NODE
, &vtysh_ping6_cmd
);
3717 install_element(VIEW_NODE
, &vtysh_traceroute6_cmd
);
3718 #if defined(HAVE_SHELL_ACCESS)
3719 install_element(VIEW_NODE
, &vtysh_telnet_cmd
);
3720 install_element(VIEW_NODE
, &vtysh_telnet_port_cmd
);
3721 install_element(VIEW_NODE
, &vtysh_ssh_cmd
);
3723 #if defined(HAVE_SHELL_ACCESS)
3724 install_element(ENABLE_NODE
, &vtysh_start_shell_cmd
);
3725 install_element(ENABLE_NODE
, &vtysh_start_bash_cmd
);
3726 install_element(ENABLE_NODE
, &vtysh_start_zsh_cmd
);
3730 install_element(VIEW_NODE
, &vtysh_show_debugging_cmd
);
3731 install_element(VIEW_NODE
, &vtysh_show_debugging_hashtable_cmd
);
3732 install_element(ENABLE_NODE
, &vtysh_debug_all_cmd
);
3733 install_element(CONFIG_NODE
, &vtysh_debug_all_cmd
);
3735 /* misc lib show commands */
3736 install_element(VIEW_NODE
, &vtysh_show_memory_cmd
);
3737 install_element(VIEW_NODE
, &vtysh_show_modules_cmd
);
3738 install_element(VIEW_NODE
, &vtysh_show_work_queues_cmd
);
3739 install_element(VIEW_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3740 install_element(VIEW_NODE
, &vtysh_show_thread_cmd
);
3741 install_element(VIEW_NODE
, &vtysh_show_poll_cmd
);
3744 install_element(VIEW_NODE
, &vtysh_show_logging_cmd
);
3745 install_element(CONFIG_NODE
, &vtysh_log_stdout_cmd
);
3746 install_element(CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
3747 install_element(CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
3748 install_element(CONFIG_NODE
, &vtysh_log_file_cmd
);
3749 install_element(CONFIG_NODE
, &vtysh_log_file_level_cmd
);
3750 install_element(CONFIG_NODE
, &no_vtysh_log_file_cmd
);
3751 install_element(CONFIG_NODE
, &vtysh_log_monitor_cmd
);
3752 install_element(CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
3753 install_element(CONFIG_NODE
, &vtysh_log_syslog_cmd
);
3754 install_element(CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
3755 install_element(CONFIG_NODE
, &vtysh_log_facility_cmd
);
3756 install_element(CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
3757 install_element(CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
3758 install_element(CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
3759 install_element(CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
3760 install_element(CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
3762 install_element(CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
3763 install_element(CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
3765 install_element(CONFIG_NODE
, &vtysh_password_cmd
);
3766 install_element(CONFIG_NODE
, &no_vtysh_password_cmd
);
3767 install_element(CONFIG_NODE
, &vtysh_enable_password_cmd
);
3768 install_element(CONFIG_NODE
, &no_vtysh_enable_password_cmd
);