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
},
138 enum vtysh_write_integrated vtysh_write_integrated
=
139 WRITE_INTEGRATED_UNSPECIFIED
;
141 static int vtysh_reconnect(struct vtysh_client
*vclient
);
143 static void vclient_close(struct vtysh_client
*vclient
)
145 if (vclient
->fd
>= 0) {
147 "Warning: closing connection to %s because of an I/O error!\n",
150 /* indicate as candidate for reconnect */
151 vclient
->fd
= VTYSH_WAS_ACTIVE
;
156 * Send a CLI command to a client and read the response.
158 * Output will be printed to vty->of. If you want to suppress output, set that
162 * the client to send the command to
165 * the command to send
168 * if non-null, this will be called with each line of output received from
169 * the client passed in the second parameter
172 * optional first argument to pass to callback
177 static int vtysh_client_run(struct vtysh_client
*vclient
, const char *line
,
178 void (*callback
)(void *, const char *), void *cbarg
)
182 char *buf
= stackbuf
;
183 size_t bufsz
= sizeof(stackbuf
);
184 char *bufvalid
, *end
= NULL
;
185 char terminator
[3] = {0, 0, 0};
187 /* vclinet was previously active, try to reconnect */
188 if (vclient
->fd
== VTYSH_WAS_ACTIVE
) {
189 ret
= vtysh_reconnect(vclient
);
197 ret
= write(vclient
->fd
, line
, strlen(line
) + 1);
199 /* close connection and try to reconnect */
200 vclient_close(vclient
);
201 ret
= vtysh_reconnect(vclient
);
205 ret
= write(vclient
->fd
, line
, strlen(line
) + 1);
213 read(vclient
->fd
, bufvalid
, buf
+ bufsz
- bufvalid
- 1);
215 if (nread
< 0 && (errno
== EINTR
|| errno
== EAGAIN
))
219 vty_out(vty
, "vtysh: error reading from %s: %s (%d)",
220 vclient
->name
, safe_strerror(errno
), errno
);
226 /* Null terminate so we may pass this to *printf later. */
230 * We expect string output from daemons, so instead of looking
231 * for the full 3 null bytes of the terminator, we check for
232 * just one instead and assume it is the first byte of the
233 * terminator. The presence of the full terminator is checked
236 if (bufvalid
- buf
>= 4)
237 end
= memmem(bufvalid
- 4, 4, "\0", 1);
240 * calculate # bytes we have, up to & not including the
241 * terminator if present
243 size_t textlen
= (end
? end
: bufvalid
) - buf
;
246 /* feed line processing callback if present */
247 while (callback
&& bufvalid
> buf
&& (end
> buf
|| !end
)) {
248 textlen
= (end
? end
: bufvalid
) - buf
;
249 char *eol
= memchr(buf
, '\n', textlen
);
255 * no line break, end of input, no text left
256 * before end; nothing to write
260 /* no nl, end of input, but some text left */
262 else if (bufvalid
== buf
+ bufsz
- 1) {
264 * no nl, no end of input, no buffer space;
270 if (buf
== stackbuf
) {
271 new = XMALLOC(MTYPE_TMP
, bufsz
);
272 memcpy(new, stackbuf
, sizeof(stackbuf
));
274 new = XREALLOC(MTYPE_TMP
, buf
, bufsz
);
276 bufvalid
= bufvalid
- buf
+ new;
278 /* if end != NULL, we won't be reading more
288 /* eol is at line end now, either \n => \0 or \0\0\0 */
289 assert(eol
&& eol
<= bufvalid
);
292 vty_out(vty
, "%s\n", buf
);
294 callback(cbarg
, buf
);
296 /* shift back data and adjust bufvalid */
297 memmove(buf
, eol
, bufvalid
- eol
);
298 bufvalid
-= eol
- buf
;
303 /* else if no callback, dump raw */
306 vty_out(vty
, "%s", buf
);
307 memmove(buf
, buf
+ textlen
, bufvalid
- buf
- textlen
);
313 * ----------------------------------------------------
314 * At this point `buf` should be in one of two states:
315 * - Empty (i.e. buf == bufvalid)
316 * - Contains up to 4 bytes of the terminator
317 * ----------------------------------------------------
319 assert(((buf
== bufvalid
)
320 || (bufvalid
- buf
<= 4 && buf
[0] == 0x00)));
323 /* if we have the terminator, break */
324 if (end
&& bufvalid
- buf
== 4) {
325 assert(!memcmp(buf
, terminator
, 3));
334 vclient_close(vclient
);
338 XFREE(MTYPE_TMP
, buf
);
342 static int vtysh_client_run_all(struct vtysh_client
*head_client
,
343 const char *line
, int continue_on_err
,
344 void (*callback
)(void *, const char *),
347 struct vtysh_client
*client
;
348 int rc
, rc_all
= CMD_SUCCESS
;
349 int correct_instance
= 0, wrong_instance
= 0;
351 for (client
= head_client
; client
; client
= client
->next
) {
352 rc
= vtysh_client_run(client
, line
, callback
, cbarg
);
353 if (rc
== CMD_NOT_MY_INSTANCE
) {
359 if (rc
!= CMD_SUCCESS
) {
360 if (!continue_on_err
)
365 if (wrong_instance
&& !correct_instance
) {
367 "%% [%s]: command ignored as it targets an instance that is not running\n",
369 rc_all
= CMD_WARNING_CONFIG_FAILED
;
375 * Execute command against all daemons.
378 * where to start walking in the daemon list
381 * the specific command to execute
386 static int vtysh_client_execute(struct vtysh_client
*head_client
,
389 return vtysh_client_run_all(head_client
, line
, 0, NULL
, NULL
);
393 * Retrieve all running config from daemons and parse it with the vtysh config
394 * parser. Returned output is not displayed to the user.
397 * where to start walking in the daemon list
400 * the specific command to execute
402 static void vtysh_client_config(struct vtysh_client
*head_client
, char *line
)
404 /* watchfrr currently doesn't load any config, and has some hardcoded
405 * settings that show up in "show run". skip it here (for now at
406 * least) so we don't get that mangled up in config-write.
408 if (head_client
->flag
== VTYSH_WATCHFRR
)
411 /* suppress output to user */
412 vty
->of_saved
= vty
->of
;
414 vtysh_client_run_all(head_client
, line
, 1, vtysh_config_parse_line
,
416 vty
->of
= vty
->of_saved
;
419 /* Command execution over the vty interface. */
420 static int vtysh_execute_func(const char *line
, int pager
)
425 const struct cmd_element
*cmd
;
427 int saved_ret
, saved_node
;
429 /* Split readline string up into the vector. */
430 vline
= cmd_make_strvec(line
);
436 if (strncmp("en", vector_slot(vline
, 0), 2) == 0) {
437 cmd_free_strvec(vline
);
438 vty_out(vty
, "%% Command not allowed: enable\n");
443 saved_ret
= ret
= cmd_execute(vty
, line
, &cmd
, 1);
444 saved_node
= vty
->node
;
447 * If command doesn't succeeded in current node, try to walk up in node
448 * tree. Changing vty->node is enough to try it just out without actual
449 * walkup in the vtysh.
451 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
452 && ret
!= CMD_WARNING
&& ret
!= CMD_WARNING_CONFIG_FAILED
453 && vty
->node
> CONFIG_NODE
) {
454 vty
->node
= node_parent(vty
->node
);
455 ret
= cmd_execute(vty
, line
, &cmd
, 1);
459 vty
->node
= saved_node
;
462 * If command succeeded in any other node than current (tried > 0) we
463 * have to move into node in the vtysh where it succeeded.
465 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
466 || ret
== CMD_WARNING
) {
467 if ((saved_node
== BGP_VPNV4_NODE
468 || saved_node
== BGP_VPNV6_NODE
469 || saved_node
== BGP_IPV4_NODE
470 || saved_node
== BGP_IPV6_NODE
471 || saved_node
== BGP_FLOWSPECV4_NODE
472 || saved_node
== BGP_FLOWSPECV6_NODE
473 || saved_node
== BGP_IPV4M_NODE
474 || saved_node
== BGP_IPV4L_NODE
475 || saved_node
== BGP_IPV6L_NODE
476 || saved_node
== BGP_IPV6M_NODE
477 || saved_node
== BGP_EVPN_NODE
478 || saved_node
== LDP_IPV4_NODE
479 || saved_node
== LDP_IPV6_NODE
)
481 vtysh_execute("exit-address-family");
482 } else if ((saved_node
== BGP_EVPN_VNI_NODE
) && (tried
== 1)) {
483 vtysh_execute("exit-vni");
484 } else if (saved_node
== BGP_VRF_POLICY_NODE
&& (tried
== 1)) {
485 vtysh_execute("exit-vrf-policy");
486 } else if ((saved_node
== BGP_VNC_DEFAULTS_NODE
487 || saved_node
== BGP_VNC_NVE_GROUP_NODE
488 || saved_node
== BGP_VNC_L2_GROUP_NODE
)
490 vtysh_execute("exit-vnc");
491 } else if (saved_node
== VRF_NODE
&& (tried
== 1)) {
492 vtysh_execute("exit-vrf");
493 } else if ((saved_node
== KEYCHAIN_KEY_NODE
494 || saved_node
== LDP_PSEUDOWIRE_NODE
495 || saved_node
== LDP_IPV4_IFACE_NODE
496 || saved_node
== LDP_IPV6_IFACE_NODE
)
498 vtysh_execute("exit");
500 vtysh_execute("end");
501 vtysh_execute("configure terminal");
505 * If command didn't succeed in any node, continue with return value
512 cmd_free_strvec(vline
);
517 case CMD_WARNING_CONFIG_FAILED
:
518 if (vty
->type
== VTY_FILE
)
519 vty_out(vty
, "Warning...\n");
521 case CMD_ERR_AMBIGUOUS
:
522 vty_out(vty
, "%% Ambiguous command: %s\n", line
);
524 case CMD_ERR_NO_MATCH
:
525 vty_out(vty
, "%% Unknown command: %s\n", line
);
527 case CMD_ERR_INCOMPLETE
:
528 vty_out(vty
, "%% Command incomplete: %s\n", line
);
530 case CMD_SUCCESS_DAEMON
: {
532 * FIXME: Don't open pager for exit commands. popen() causes
533 * problems if exited from vtysh at all. This hack shouldn't
534 * cause any problem but is really ugly.
536 if (pager
&& strncmp(line
, "exit", 4))
539 if (!strcmp(cmd
->string
, "configure terminal")) {
540 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
541 cmd_stat
= vtysh_client_execute(
542 &vtysh_client
[i
], line
);
543 if (cmd_stat
== CMD_WARNING
)
549 vline
= cmd_make_strvec(line
);
554 vty_close_pager(vty
);
558 ret
= cmd_execute_command(vline
, vty
, &cmd
, 1);
559 cmd_free_strvec(vline
);
560 if (ret
!= CMD_SUCCESS_DAEMON
)
562 } else if (cmd
->func
) {
563 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
568 cmd_stat
= CMD_SUCCESS
;
569 struct vtysh_client
*vc
;
570 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
571 if (cmd
->daemon
& vtysh_client
[i
].flag
) {
572 if (vtysh_client
[i
].fd
< 0
573 && (cmd
->daemon
== vtysh_client
[i
].flag
)) {
574 for (vc
= &vtysh_client
[i
]; vc
;
579 if (vtysh_client
[i
].fd
< 0
580 && (cmd
->daemon
== vtysh_client
[i
].flag
)) {
581 bool any_inst
= false;
582 for (vc
= &vtysh_client
[i
]; vc
;
588 "%s is not running\n",
589 vtysh_client
[i
].name
);
593 cmd_stat
= vtysh_client_execute(
594 &vtysh_client
[i
], line
);
595 if (cmd_stat
!= CMD_SUCCESS
)
599 if (cmd_stat
!= CMD_SUCCESS
)
603 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
607 vty_close_pager(vty
);
612 int vtysh_execute_no_pager(const char *line
)
614 return vtysh_execute_func(line
, 0);
617 int vtysh_execute(const char *line
)
619 return vtysh_execute_func(line
, 1);
622 static char *trim(char *s
)
633 while (end
>= s
&& isspace((int)*end
))
637 while (*s
&& isspace((int)*s
))
643 int vtysh_mark_file(const char *filename
)
650 const struct cmd_element
*cmd
;
651 int saved_ret
, prev_node
;
653 char *vty_buf_copy
= NULL
;
654 char *vty_buf_trimmed
= NULL
;
656 if (strncmp("-", filename
, 1) == 0)
659 confp
= fopen(filename
, "r");
662 fprintf(stderr
, "%% Can't open config file %s due to '%s'.\n",
663 filename
, safe_strerror(errno
));
664 return (CMD_ERR_NO_FILE
);
668 vty
->wfd
= STDERR_FILENO
;
669 vty
->type
= VTY_TERM
;
670 vty
->node
= CONFIG_NODE
;
672 vtysh_execute_no_pager("enable");
673 vtysh_execute_no_pager("configure terminal");
674 vty_buf_copy
= XCALLOC(MTYPE_VTYSH_CMD
, VTY_BUFSIZ
);
676 while (fgets(vty
->buf
, VTY_BUFSIZ
, confp
)) {
679 strcpy(vty_buf_copy
, vty
->buf
);
680 vty_buf_trimmed
= trim(vty_buf_copy
);
683 case LDP_IPV4_IFACE_NODE
:
684 if (strncmp(vty_buf_copy
, " ", 3)) {
685 vty_out(vty
, " end\n");
686 vty
->node
= LDP_IPV4_NODE
;
689 case LDP_IPV6_IFACE_NODE
:
690 if (strncmp(vty_buf_copy
, " ", 3)) {
691 vty_out(vty
, " end\n");
692 vty
->node
= LDP_IPV6_NODE
;
695 case LDP_PSEUDOWIRE_NODE
:
696 if (strncmp(vty_buf_copy
, " ", 2)) {
697 vty_out(vty
, " end\n");
698 vty
->node
= LDP_L2VPN_NODE
;
705 if (vty_buf_trimmed
[0] == '!' || vty_buf_trimmed
[0] == '#') {
706 vty_out(vty
, "%s", vty
->buf
);
710 /* Split readline string up into the vector. */
711 vline
= cmd_make_strvec(vty
->buf
);
714 vty_out(vty
, "%s", vty
->buf
);
719 * Ignore the "end" lines, we will generate these where
722 if (strlen(vty_buf_trimmed
) == 3
723 && strncmp("end", vty_buf_trimmed
, 3) == 0) {
724 cmd_free_strvec(vline
);
728 prev_node
= vty
->node
;
729 saved_ret
= ret
= cmd_execute_command_strict(vline
, vty
, &cmd
);
732 * If command doesn't succeeded in current node, try to walk up
733 * in node tree. Changing vty->node is enough to try it just
734 * out without actual walkup in the vtysh.
736 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
737 && ret
!= CMD_WARNING
&& ret
!= CMD_WARNING_CONFIG_FAILED
738 && vty
->node
> CONFIG_NODE
) {
739 vty
->node
= node_parent(vty
->node
);
740 ret
= cmd_execute_command_strict(vline
, vty
, &cmd
);
745 * If command succeeded in any other node than current (tried >
746 * 0) we have to move into node in the vtysh where it
749 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
750 || ret
== CMD_WARNING
) {
751 if ((prev_node
== BGP_VPNV4_NODE
752 || prev_node
== BGP_VPNV6_NODE
753 || prev_node
== BGP_IPV4_NODE
754 || prev_node
== BGP_IPV6_NODE
755 || prev_node
== BGP_FLOWSPECV4_NODE
756 || prev_node
== BGP_FLOWSPECV6_NODE
757 || prev_node
== BGP_IPV4L_NODE
758 || prev_node
== BGP_IPV6L_NODE
759 || prev_node
== BGP_IPV4M_NODE
760 || prev_node
== BGP_IPV6M_NODE
761 || prev_node
== BGP_EVPN_NODE
)
763 vty_out(vty
, "exit-address-family\n");
764 } else if ((prev_node
== BGP_EVPN_VNI_NODE
)
766 vty_out(vty
, "exit-vni\n");
767 } else if ((prev_node
== KEYCHAIN_KEY_NODE
)
769 vty_out(vty
, "exit\n");
771 vty_out(vty
, "end\n");
775 * If command didn't succeed in any node, continue with return
776 * value from first try.
780 vty
->node
= prev_node
;
783 cmd_free_strvec(vline
);
786 case CMD_WARNING_CONFIG_FAILED
:
787 if (vty
->type
== VTY_FILE
)
788 fprintf(stderr
, "line %d: Warning...: %s\n",
792 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
794 case CMD_ERR_AMBIGUOUS
:
795 fprintf(stderr
, "line %d: %% Ambiguous command: %s\n",
799 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
800 return CMD_ERR_AMBIGUOUS
;
801 case CMD_ERR_NO_MATCH
:
802 fprintf(stderr
, "line %d: %% Unknown command: %s\n",
806 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
807 return CMD_ERR_NO_MATCH
;
808 case CMD_ERR_INCOMPLETE
:
809 fprintf(stderr
, "line %d: %% Command incomplete: %s\n",
813 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
814 return CMD_ERR_INCOMPLETE
;
816 vty_out(vty
, "%s", vty
->buf
);
818 case CMD_SUCCESS_DAEMON
: {
819 int cmd_stat
= CMD_SUCCESS
;
821 vty_out(vty
, "%s", vty
->buf
);
822 cmd_stat
= vtysh_client_execute(&vtysh_client
[0],
824 if (cmd_stat
!= CMD_SUCCESS
)
828 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
832 /* This is the end */
833 vty_out(vty
, "\nend\n");
835 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
843 /* Configration make from file. */
844 int vtysh_config_from_file(struct vty
*vty
, FILE *fp
)
847 const struct cmd_element
*cmd
;
849 /* once we have an error, we remember & return that */
850 int retcode
= CMD_SUCCESS
;
852 while (fgets(vty
->buf
, VTY_BUFSIZ
, fp
)) {
855 ret
= command_config_read_one_line(vty
, &cmd
, 1);
859 case CMD_WARNING_CONFIG_FAILED
:
860 if (vty
->type
== VTY_FILE
)
861 fprintf(stderr
, "line %d: Warning[%d]...: %s\n",
862 lineno
, vty
->node
, vty
->buf
);
866 case CMD_ERR_AMBIGUOUS
:
868 "line %d: %% Ambiguous command[%d]: %s\n",
869 lineno
, vty
->node
, vty
->buf
);
870 retcode
= CMD_ERR_AMBIGUOUS
;
872 case CMD_ERR_NO_MATCH
:
873 fprintf(stderr
, "line %d: %% Unknown command[%d]: %s",
874 lineno
, vty
->node
, vty
->buf
);
875 retcode
= CMD_ERR_NO_MATCH
;
877 case CMD_ERR_INCOMPLETE
:
879 "line %d: %% Command incomplete[%d]: %s\n",
880 lineno
, vty
->node
, vty
->buf
);
881 retcode
= CMD_ERR_INCOMPLETE
;
883 case CMD_SUCCESS_DAEMON
: {
885 int cmd_stat
= CMD_SUCCESS
;
887 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
888 if (cmd
->daemon
& vtysh_client
[i
].flag
) {
889 cmd_stat
= vtysh_client_execute(
890 &vtysh_client
[i
], vty
->buf
);
892 * CMD_WARNING - Can mean that the
893 * command was parsed successfully but
894 * it was already entered in a few
895 * spots. As such if we receive a
896 * CMD_WARNING from a daemon we
897 * shouldn't stop talking to the other
898 * daemons for the particular command.
900 if (cmd_stat
!= CMD_SUCCESS
901 && cmd_stat
!= CMD_WARNING
) {
903 "line %d: Failure to communicate[%d] to %s, line: %s\n",
905 vtysh_client
[i
].name
,
912 if (cmd_stat
!= CMD_SUCCESS
)
916 (*cmd
->func
)(cmd
, vty
, 0, NULL
);
925 * Function processes cli commands terminated with '?' character when entered
926 * through either 'vtysh' or 'vtysh -c' interfaces.
928 static int vtysh_process_questionmark(const char *input
, int input_len
)
932 vector vline
, describe
;
933 struct cmd_token
*token
;
938 vline
= cmd_make_strvec(input
);
940 /* In case of '> ?'. */
942 vline
= vector_init(1);
943 vector_set(vline
, NULL
);
944 } else if (input_len
&& isspace((int)input
[input_len
- 1]))
945 vector_set(vline
, NULL
);
947 describe
= cmd_describe_command(vline
, vty
, &ret
);
949 /* Ambiguous and no match error. */
951 case CMD_ERR_AMBIGUOUS
:
952 cmd_free_strvec(vline
);
953 vector_free(describe
);
954 vty_out(vty
, "%% Ambiguous command.\n");
958 case CMD_ERR_NO_MATCH
:
959 cmd_free_strvec(vline
);
961 vector_free(describe
);
962 vty_out(vty
, "%% There is no matched command.\n");
968 /* Get width of command string. */
970 for (i
= 0; i
< vector_active(describe
); i
++)
971 if ((token
= vector_slot(describe
, i
)) != NULL
) {
972 if (token
->text
[0] == '\0')
975 int len
= strlen(token
->text
);
981 for (i
= 0; i
< vector_active(describe
); i
++)
982 if ((token
= vector_slot(describe
, i
)) != NULL
) {
984 vty_out(vty
, " %-s\n", token
->text
);
986 vty_out(vty
, " %-*s %s\n", width
, token
->text
,
989 if (IS_VARYING_TOKEN(token
->type
)) {
990 const char *ref
= vector_slot(
991 vline
, vector_active(vline
) - 1);
993 vector varcomps
= vector_init(VECTOR_MIN_SIZE
);
994 cmd_variable_complete(token
, ref
, varcomps
);
996 if (vector_active(varcomps
) > 0) {
998 rl_get_screen_size(&rows
, &cols
);
1000 char *ac
= cmd_variable_comp2str(
1002 vty_out(vty
, "%s\n", ac
);
1003 XFREE(MTYPE_TMP
, ac
);
1006 vector_free(varcomps
);
1010 cmd_free_strvec(vline
);
1011 vector_free(describe
);
1017 * Entry point for user commands terminated with '?' character and typed through
1018 * the usual vtysh's stdin interface. This is the function being registered with
1021 static int vtysh_rl_describe(int a
, int b
)
1027 ret
= vtysh_process_questionmark(rl_line_buffer
, rl_end
);
1034 * Function in charged of processing vtysh instructions terminating with '?'
1035 * character and received through the 'vtysh -c' interface. If user's
1036 * instruction is well-formatted, we will call the same processing routine
1037 * utilized by the traditional vtysh's stdin interface.
1039 int vtysh_execute_command_questionmark(char *input
)
1041 int input_len
, qmark_count
= 0;
1044 if (!(input
&& *input
))
1047 /* Finding out question_mark count and strlen */
1048 for (str
= input
; *str
; ++str
) {
1052 input_len
= str
- input
;
1055 * Verify that user's input terminates in '?' and that patterns such as
1056 * 'cmd ? subcmd ?' are prevented.
1058 if (qmark_count
!= 1 || input
[input_len
- 1] != '?')
1062 * Questionmark-processing function is not expecting to receive '?'
1063 * character in input string.
1065 input
[input_len
- 1] = '\0';
1067 return vtysh_process_questionmark(input
, input_len
- 1);
1070 /* Result of cmd_complete_command() call will be stored here
1071 * and used in new_completion() in order to put the space in
1072 * correct places only. */
1073 int complete_status
;
1075 static char *command_generator(const char *text
, int state
)
1078 static char **matched
= NULL
;
1079 static int index
= 0;
1085 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
1088 vline
= cmd_make_strvec(rl_line_buffer
);
1092 if (rl_end
&& isspace((int)rl_line_buffer
[rl_end
- 1]))
1093 vector_set(vline
, NULL
);
1095 matched
= cmd_complete_command(vline
, vty
, &complete_status
);
1096 cmd_free_strvec(vline
);
1099 if (matched
&& matched
[index
])
1101 * this is free()'d by readline, but we leak 1 count of
1104 return matched
[index
++];
1106 XFREE(MTYPE_TMP
, matched
);
1112 static char **new_completion(char *text
, int start
, int end
)
1116 matches
= rl_completion_matches(text
, command_generator
);
1120 if (complete_status
!= CMD_COMPLETE_FULL_MATCH
)
1121 /* only append a space on full match */
1122 rl_completion_append_character
= '\0';
1128 /* Vty node structures. */
1129 static struct cmd_node bgp_node
= {
1130 BGP_NODE
, "%s(config-router)# ",
1133 static struct cmd_node rip_node
= {
1134 RIP_NODE
, "%s(config-router)# ",
1137 static struct cmd_node isis_node
= {
1138 ISIS_NODE
, "%s(config-router)# ",
1141 static struct cmd_node interface_node
= {
1142 INTERFACE_NODE
, "%s(config-if)# ",
1145 static struct cmd_node pw_node
= {
1146 PW_NODE
, "%s(config-pw)# ",
1149 static struct cmd_node logicalrouter_node
= {
1150 LOGICALROUTER_NODE
, "%s(config-logical-router)# ",
1153 static struct cmd_node vrf_node
= {
1154 VRF_NODE
, "%s(config-vrf)# ",
1157 static struct cmd_node nh_group_node
= {
1159 "%s(config-nh-group)# ",
1162 static struct cmd_node rmap_node
= {RMAP_NODE
, "%s(config-route-map)# "};
1164 static struct cmd_node pbr_map_node
= {PBRMAP_NODE
, "%s(config-pbr-map)# "};
1166 static struct cmd_node zebra_node
= {ZEBRA_NODE
, "%s(config-router)# "};
1168 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
1169 "%s(config-router-af)# "};
1171 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
1172 "%s(config-router-af)# "};
1174 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
1175 "%s(config-router-af)# "};
1177 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
1178 "%s(config-router-af)# "};
1180 static struct cmd_node bgp_ipv4_node
= {BGP_IPV4_NODE
,
1181 "%s(config-router-af)# "};
1183 static struct cmd_node bgp_ipv4m_node
= {BGP_IPV4M_NODE
,
1184 "%s(config-router-af)# "};
1186 static struct cmd_node bgp_ipv4l_node
= {BGP_IPV4L_NODE
,
1187 "%s(config-router-af)# "};
1189 static struct cmd_node bgp_ipv6_node
= {BGP_IPV6_NODE
,
1190 "%s(config-router-af)# "};
1192 static struct cmd_node bgp_ipv6m_node
= {BGP_IPV6M_NODE
,
1193 "%s(config-router-af)# "};
1195 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
1196 "%s(config-router-af)# "};
1198 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
1199 "%s(config-router-af-vni)# "};
1201 static struct cmd_node bgp_ipv6l_node
= {BGP_IPV6L_NODE
,
1202 "%s(config-router-af)# "};
1204 static struct cmd_node bgp_vnc_defaults_node
= {
1205 BGP_VNC_DEFAULTS_NODE
, "%s(config-router-vnc-defaults)# "};
1207 static struct cmd_node bgp_vnc_nve_group_node
= {
1208 BGP_VNC_NVE_GROUP_NODE
, "%s(config-router-vnc-nve-group)# "};
1210 static struct cmd_node bgp_vrf_policy_node
= {BGP_VRF_POLICY_NODE
,
1211 "%s(config-router-vrf-policy)# "};
1213 static struct cmd_node bgp_vnc_l2_group_node
= {
1214 BGP_VNC_L2_GROUP_NODE
, "%s(config-router-vnc-l2-group)# "};
1216 static struct cmd_node ospf_node
= {OSPF_NODE
, "%s(config-router)# "};
1218 static struct cmd_node eigrp_node
= {EIGRP_NODE
, "%s(config-router)# "};
1220 static struct cmd_node babel_node
= {BABEL_NODE
, "%s(config-router)# "};
1222 static struct cmd_node ripng_node
= {RIPNG_NODE
, "%s(config-router)# "};
1224 static struct cmd_node ospf6_node
= {OSPF6_NODE
, "%s(config-ospf6)# "};
1226 static struct cmd_node ldp_node
= {LDP_NODE
, "%s(config-ldp)# "};
1228 static struct cmd_node ldp_ipv4_node
= {LDP_IPV4_NODE
, "%s(config-ldp-af)# "};
1230 static struct cmd_node ldp_ipv6_node
= {LDP_IPV6_NODE
, "%s(config-ldp-af)# "};
1232 static struct cmd_node ldp_ipv4_iface_node
= {LDP_IPV4_IFACE_NODE
,
1233 "%s(config-ldp-af-if)# "};
1235 static struct cmd_node ldp_ipv6_iface_node
= {LDP_IPV6_IFACE_NODE
,
1236 "%s(config-ldp-af-if)# "};
1238 static struct cmd_node ldp_l2vpn_node
= {LDP_L2VPN_NODE
, "%s(config-l2vpn)# "};
1240 static struct cmd_node ldp_pseudowire_node
= {LDP_PSEUDOWIRE_NODE
,
1241 "%s(config-l2vpn-pw)# "};
1243 static struct cmd_node keychain_node
= {KEYCHAIN_NODE
, "%s(config-keychain)# "};
1245 static struct cmd_node keychain_key_node
= {KEYCHAIN_KEY_NODE
,
1246 "%s(config-keychain-key)# "};
1248 struct cmd_node link_params_node
= {
1249 LINK_PARAMS_NODE
, "%s(config-link-params)# ",
1252 #if defined(HAVE_RPKI)
1253 static struct cmd_node rpki_node
= {RPKI_NODE
, "%s(config-rpki)# ", 1};
1256 /* Defined in lib/vty.c */
1257 extern struct cmd_node vty_node
;
1259 /* When '^Z' is received from vty, move down to the enable mode. */
1260 static int vtysh_end(void)
1262 switch (vty
->node
) {
1265 /* Nothing to do. */
1268 vty
->node
= ENABLE_NODE
;
1274 DEFUNSH(VTYSH_REALLYALL
, vtysh_end_all
, vtysh_end_all_cmd
, "end",
1275 "End current mode and change to enable mode\n")
1280 DEFUNSH(VTYSH_BGPD
, router_bgp
, router_bgp_cmd
,
1281 "router bgp [(1-4294967295) [<view|vrf> WORD]]",
1282 ROUTER_STR BGP_STR AS_STR
1283 "BGP view\nBGP VRF\n"
1286 vty
->node
= BGP_NODE
;
1290 DEFUNSH(VTYSH_BGPD
, address_family_vpnv4
, address_family_vpnv4_cmd
,
1291 "address-family vpnv4 [unicast]",
1292 "Enter Address Family command mode\n"
1294 "Address Family modifier\n")
1296 vty
->node
= BGP_VPNV4_NODE
;
1300 DEFUNSH(VTYSH_BGPD
, address_family_vpnv6
, address_family_vpnv6_cmd
,
1301 "address-family vpnv6 [unicast]",
1302 "Enter Address Family command mode\n"
1304 "Address Family modifier\n")
1306 vty
->node
= BGP_VPNV6_NODE
;
1310 DEFUNSH(VTYSH_BGPD
, address_family_ipv4
, address_family_ipv4_cmd
,
1311 "address-family ipv4 [unicast]",
1312 "Enter Address Family command mode\n"
1314 "Address Family Modifier\n")
1316 vty
->node
= BGP_IPV4_NODE
;
1320 DEFUNSH(VTYSH_BGPD
, address_family_flowspecv4
, address_family_flowspecv4_cmd
,
1321 "address-family ipv4 flowspec",
1322 "Enter Address Family command mode\n"
1324 "Address Family Modifier\n")
1326 vty
->node
= BGP_FLOWSPECV4_NODE
;
1330 DEFUNSH(VTYSH_BGPD
, address_family_flowspecv6
, address_family_flowspecv6_cmd
,
1331 "address-family ipv6 flowspec",
1332 "Enter Address Family command mode\n"
1334 "Address Family Modifier\n")
1336 vty
->node
= BGP_FLOWSPECV6_NODE
;
1340 DEFUNSH(VTYSH_BGPD
, address_family_ipv4_multicast
,
1341 address_family_ipv4_multicast_cmd
, "address-family ipv4 multicast",
1342 "Enter Address Family command mode\n"
1344 "Address Family modifier\n")
1346 vty
->node
= BGP_IPV4M_NODE
;
1350 DEFUNSH(VTYSH_BGPD
, address_family_ipv4_vpn
, address_family_ipv4_vpn_cmd
,
1351 "address-family ipv4 vpn",
1352 "Enter Address Family command mode\n"
1354 "Address Family modifier\n")
1356 vty
->node
= BGP_VPNV4_NODE
;
1360 DEFUNSH(VTYSH_BGPD
, address_family_ipv4_labeled_unicast
,
1361 address_family_ipv4_labeled_unicast_cmd
,
1362 "address-family ipv4 labeled-unicast",
1363 "Enter Address Family command mode\n"
1365 "Address Family modifier\n")
1367 vty
->node
= BGP_IPV4L_NODE
;
1371 DEFUNSH(VTYSH_BGPD
, address_family_ipv6
, address_family_ipv6_cmd
,
1372 "address-family ipv6 [unicast]",
1373 "Enter Address Family command mode\n"
1375 "Address Family modifier\n")
1377 vty
->node
= BGP_IPV6_NODE
;
1381 DEFUNSH(VTYSH_BGPD
, address_family_ipv6_multicast
,
1382 address_family_ipv6_multicast_cmd
, "address-family ipv6 multicast",
1383 "Enter Address Family command mode\n"
1385 "Address Family modifier\n")
1387 vty
->node
= BGP_IPV6M_NODE
;
1391 DEFUNSH(VTYSH_BGPD
, address_family_ipv6_vpn
, address_family_ipv6_vpn_cmd
,
1392 "address-family ipv6 vpn",
1393 "Enter Address Family command mode\n"
1395 "Address Family modifier\n")
1397 vty
->node
= BGP_VPNV6_NODE
;
1401 DEFUNSH(VTYSH_BGPD
, address_family_ipv6_labeled_unicast
,
1402 address_family_ipv6_labeled_unicast_cmd
,
1403 "address-family ipv6 labeled-unicast",
1404 "Enter Address Family command mode\n"
1406 "Address Family modifier\n")
1408 vty
->node
= BGP_IPV6L_NODE
;
1412 #if defined(HAVE_RPKI)
1417 "Enable rpki and enter rpki configuration mode\n")
1419 vty
->node
= RPKI_NODE
;
1427 "Exit current mode and down to previous mode\n")
1429 vty
->node
= CONFIG_NODE
;
1437 "Exit current mode and down to previous mode\n")
1439 return rpki_exit(self
, vty
, argc
, argv
);
1443 DEFUNSH(VTYSH_BGPD
, address_family_evpn
, address_family_evpn_cmd
,
1444 "address-family <l2vpn evpn>",
1445 "Enter Address Family command mode\n"
1447 "Address Family modifier\n")
1449 vty
->node
= BGP_EVPN_NODE
;
1453 #if defined(HAVE_CUMULUS)
1454 DEFUNSH_HIDDEN(VTYSH_BGPD
, address_family_evpn2
, address_family_evpn2_cmd
,
1455 "address-family evpn",
1456 "Enter Address Family command mode\n"
1457 "EVPN Address family\n")
1459 vty
->node
= BGP_EVPN_NODE
;
1464 DEFUNSH(VTYSH_BGPD
, bgp_evpn_vni
, bgp_evpn_vni_cmd
, "vni (1-16777215)",
1465 "VXLAN Network Identifier\n"
1468 vty
->node
= BGP_EVPN_VNI_NODE
;
1472 #if defined(ENABLE_BGP_VNC)
1473 DEFUNSH(VTYSH_BGPD
, vnc_defaults
, vnc_defaults_cmd
, "vnc defaults",
1474 "VNC/RFP related configuration\n"
1475 "Configure default NVE group\n")
1477 vty
->node
= BGP_VNC_DEFAULTS_NODE
;
1481 DEFUNSH(VTYSH_BGPD
, vnc_nve_group
, vnc_nve_group_cmd
, "vnc nve-group NAME",
1482 "VNC/RFP related configuration\n"
1483 "Configure a NVE group\n"
1486 vty
->node
= BGP_VNC_NVE_GROUP_NODE
;
1490 DEFUNSH(VTYSH_BGPD
, vnc_vrf_policy
, vnc_vrf_policy_cmd
, "vrf-policy NAME",
1491 "Configure a VRF policy group\n"
1494 vty
->node
= BGP_VRF_POLICY_NODE
;
1498 DEFUNSH(VTYSH_BGPD
, vnc_l2_group
, vnc_l2_group_cmd
, "vnc l2-group NAME",
1499 "VNC/RFP related configuration\n"
1500 "Configure a L2 group\n"
1503 vty
->node
= BGP_VNC_L2_GROUP_NODE
;
1508 DEFUNSH(VTYSH_RIPD
, key_chain
, key_chain_cmd
, "key chain WORD",
1509 "Authentication key management\n"
1510 "Key-chain management\n"
1513 vty
->node
= KEYCHAIN_NODE
;
1517 DEFUNSH(VTYSH_RIPD
, key
, key_cmd
, "key (0-2147483647)",
1519 "Key identifier number\n")
1521 vty
->node
= KEYCHAIN_KEY_NODE
;
1525 DEFUNSH(VTYSH_RIPD
, router_rip
, router_rip_cmd
, "router rip",
1528 vty
->node
= RIP_NODE
;
1532 DEFUNSH(VTYSH_RIPNGD
, router_ripng
, router_ripng_cmd
, "router ripng",
1533 ROUTER_STR
"RIPng\n")
1535 vty
->node
= RIPNG_NODE
;
1539 DEFUNSH(VTYSH_OSPFD
, router_ospf
, router_ospf_cmd
,
1540 "router ospf [(1-65535)] [vrf NAME]",
1541 "Enable a routing process\n"
1542 "Start OSPF configuration\n"
1546 vty
->node
= OSPF_NODE
;
1550 DEFUNSH(VTYSH_EIGRPD
, router_eigrp
, router_eigrp_cmd
, "router eigrp (1-65535)",
1551 "Enable a routing process\n"
1552 "Start EIGRP configuration\n"
1553 "AS number to use\n")
1555 vty
->node
= EIGRP_NODE
;
1559 DEFUNSH(VTYSH_BABELD
, router_babel
, router_babel_cmd
, "router babel",
1560 "Enable a routing process\n"
1561 "Make Babel instance command\n")
1563 vty
->node
= BABEL_NODE
;
1567 DEFUNSH(VTYSH_OSPF6D
, router_ospf6
, router_ospf6_cmd
, "router ospf6",
1568 ROUTER_STR OSPF6_STR
)
1570 vty
->node
= OSPF6_NODE
;
1574 #if defined(HAVE_LDPD)
1575 DEFUNSH(VTYSH_LDPD
, ldp_mpls_ldp
, ldp_mpls_ldp_cmd
, "mpls ldp",
1576 "Global MPLS configuration subcommands\n"
1577 "Label Distribution Protocol\n")
1579 vty
->node
= LDP_NODE
;
1583 DEFUNSH(VTYSH_LDPD
, ldp_address_family_ipv4
, ldp_address_family_ipv4_cmd
,
1584 "address-family ipv4",
1585 "Configure Address Family and its parameters\n"
1588 vty
->node
= LDP_IPV4_NODE
;
1592 DEFUNSH(VTYSH_LDPD
, ldp_address_family_ipv6
, ldp_address_family_ipv6_cmd
,
1593 "address-family ipv6",
1594 "Configure Address Family and its parameters\n"
1597 vty
->node
= LDP_IPV6_NODE
;
1601 DEFUNSH(VTYSH_LDPD
, ldp_exit_address_family
, ldp_exit_address_family_cmd
,
1602 "exit-address-family", "Exit from Address Family configuration mode\n")
1604 if (vty
->node
== LDP_IPV4_NODE
|| vty
->node
== LDP_IPV6_NODE
)
1605 vty
->node
= LDP_NODE
;
1609 DEFUNSH(VTYSH_LDPD
, ldp_interface_ifname
, ldp_interface_ifname_cmd
,
1611 "Enable LDP on an interface and enter interface submode\n"
1612 "Interface's name\n")
1614 switch (vty
->node
) {
1616 vty
->node
= LDP_IPV4_IFACE_NODE
;
1619 vty
->node
= LDP_IPV6_IFACE_NODE
;
1628 DEFUNSH(VTYSH_LDPD
, ldp_l2vpn_word_type_vpls
, ldp_l2vpn_word_type_vpls_cmd
,
1629 "l2vpn WORD type vpls",
1630 "Configure l2vpn commands\n"
1633 "Virtual Private LAN Service\n")
1635 vty
->node
= LDP_L2VPN_NODE
;
1639 DEFUNSH(VTYSH_LDPD
, ldp_member_pseudowire_ifname
,
1640 ldp_member_pseudowire_ifname_cmd
, "member pseudowire IFNAME",
1641 "L2VPN member configuration\n"
1642 "Pseudowire interface\n"
1643 "Interface's name\n")
1645 vty
->node
= LDP_PSEUDOWIRE_NODE
;
1650 DEFUNSH(VTYSH_ISISD
, router_isis
, router_isis_cmd
, "router isis WORD",
1653 "ISO Routing area tag\n")
1655 vty
->node
= ISIS_NODE
;
1659 DEFUNSH(VTYSH_RMAP
, vtysh_route_map
, vtysh_route_map_cmd
,
1660 "route-map WORD <deny|permit> (1-65535)",
1661 "Create route-map or enter route-map command mode\n"
1663 "Route map denies set operations\n"
1664 "Route map permits set operations\n"
1665 "Sequence to insert to/delete from existing route-map entry\n")
1667 vty
->node
= RMAP_NODE
;
1671 DEFUNSH(VTYSH_PBRD
, vtysh_pbr_map
, vtysh_pbr_map_cmd
,
1672 "pbr-map NAME seq (1-700)",
1673 "Create pbr-map or enter pbr-map command mode\n"
1674 "The name of the PBR MAP\n"
1675 "Sequence to insert to/delete from existing pbr-map entry\n"
1676 "Sequence number\n")
1678 vty
->node
= PBRMAP_NODE
;
1682 DEFSH(VTYSH_PBRD
, vtysh_no_pbr_map_cmd
, "no pbr-map WORD [seq (1-700)]",
1685 "The name of the PBR MAP\n"
1686 "Sequence to delete from existing pbr-map entry\n"
1687 "Sequence number\n")
1689 DEFUNSH(VTYSH_ALL
, vtysh_line_vty
, vtysh_line_vty_cmd
, "line vty",
1690 "Configure a terminal line\n"
1691 "Virtual terminal\n")
1693 vty
->node
= VTY_NODE
;
1697 DEFUNSH(VTYSH_REALLYALL
, vtysh_enable
, vtysh_enable_cmd
, "enable",
1698 "Turn on privileged mode command\n")
1700 vty
->node
= ENABLE_NODE
;
1704 DEFUNSH(VTYSH_REALLYALL
, vtysh_disable
, vtysh_disable_cmd
, "disable",
1705 "Turn off privileged mode command\n")
1707 if (vty
->node
== ENABLE_NODE
)
1708 vty
->node
= VIEW_NODE
;
1712 DEFUNSH(VTYSH_REALLYALL
, vtysh_config_terminal
, vtysh_config_terminal_cmd
,
1713 "configure terminal",
1714 "Configuration from vty interface\n"
1715 "Configuration terminal\n")
1717 vty
->node
= CONFIG_NODE
;
1721 static int vtysh_exit(struct vty
*vty
)
1723 switch (vty
->node
) {
1729 vty
->node
= ENABLE_NODE
;
1731 case INTERFACE_NODE
:
1733 case LOGICALROUTER_NODE
:
1745 case LDP_L2VPN_NODE
:
1751 vtysh_execute("end");
1752 vtysh_execute("configure terminal");
1753 vty
->node
= CONFIG_NODE
;
1755 case BGP_VPNV4_NODE
:
1756 case BGP_VPNV6_NODE
:
1758 case BGP_IPV4M_NODE
:
1759 case BGP_IPV4L_NODE
:
1761 case BGP_IPV6M_NODE
:
1762 case BGP_IPV6L_NODE
:
1763 case BGP_FLOWSPECV4_NODE
:
1764 case BGP_FLOWSPECV6_NODE
:
1765 case BGP_VRF_POLICY_NODE
:
1767 case BGP_VNC_DEFAULTS_NODE
:
1768 case BGP_VNC_NVE_GROUP_NODE
:
1769 case BGP_VNC_L2_GROUP_NODE
:
1770 vty
->node
= BGP_NODE
;
1772 case BGP_EVPN_VNI_NODE
:
1773 vty
->node
= BGP_EVPN_NODE
;
1777 vty
->node
= LDP_NODE
;
1779 case LDP_IPV4_IFACE_NODE
:
1780 vty
->node
= LDP_IPV4_NODE
;
1782 case LDP_IPV6_IFACE_NODE
:
1783 vty
->node
= LDP_IPV6_NODE
;
1785 case LDP_PSEUDOWIRE_NODE
:
1786 vty
->node
= LDP_L2VPN_NODE
;
1788 case KEYCHAIN_KEY_NODE
:
1789 vty
->node
= KEYCHAIN_NODE
;
1791 case LINK_PARAMS_NODE
:
1792 vty
->node
= INTERFACE_NODE
;
1800 DEFUNSH(VTYSH_REALLYALL
, vtysh_exit_all
, vtysh_exit_all_cmd
, "exit",
1801 "Exit current mode and down to previous mode\n")
1803 return vtysh_exit(vty
);
1806 DEFUNSH(VTYSH_ALL
, vtysh_quit_all
, vtysh_quit_all_cmd
, "quit",
1807 "Exit current mode and down to previous mode\n")
1809 return vtysh_exit_all(self
, vty
, argc
, argv
);
1812 DEFUNSH(VTYSH_BGPD
, exit_address_family
, exit_address_family_cmd
,
1813 "exit-address-family", "Exit from Address Family configuration mode\n")
1815 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
1816 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
1817 || vty
->node
== BGP_VPNV6_NODE
|| vty
->node
== BGP_IPV6_NODE
1818 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_IPV6M_NODE
1819 || vty
->node
== BGP_EVPN_NODE
1820 || vty
->node
== BGP_FLOWSPECV4_NODE
1821 || vty
->node
== BGP_FLOWSPECV6_NODE
)
1822 vty
->node
= BGP_NODE
;
1826 DEFUNSH(VTYSH_BGPD
, exit_vni
, exit_vni_cmd
, "exit-vni", "Exit from VNI mode\n")
1828 if (vty
->node
== BGP_EVPN_VNI_NODE
)
1829 vty
->node
= BGP_EVPN_NODE
;
1833 DEFUNSH(VTYSH_BGPD
, exit_vnc_config
, exit_vnc_config_cmd
, "exit-vnc",
1834 "Exit from VNC configuration mode\n")
1836 if (vty
->node
== BGP_VNC_DEFAULTS_NODE
1837 || vty
->node
== BGP_VNC_NVE_GROUP_NODE
1838 || vty
->node
== BGP_VNC_L2_GROUP_NODE
)
1839 vty
->node
= BGP_NODE
;
1843 DEFUNSH(VTYSH_PIMD
|VTYSH_ZEBRA
, exit_vrf_config
, exit_vrf_config_cmd
, "exit-vrf",
1844 "Exit from VRF configuration mode\n")
1846 if (vty
->node
== VRF_NODE
)
1847 vty
->node
= CONFIG_NODE
;
1851 DEFUNSH(VTYSH_BGPD
, exit_vrf_policy
, exit_vrf_policy_cmd
, "exit-vrf-policy",
1852 "Exit from VRF policy configuration mode\n")
1854 if (vty
->node
== BGP_VRF_POLICY_NODE
)
1855 vty
->node
= BGP_NODE
;
1859 DEFUNSH(VTYSH_RIPD
, vtysh_exit_ripd
, vtysh_exit_ripd_cmd
, "exit",
1860 "Exit current mode and down to previous mode\n")
1862 return vtysh_exit(vty
);
1865 DEFUNSH(VTYSH_RIPD
, vtysh_quit_ripd
, vtysh_quit_ripd_cmd
, "quit",
1866 "Exit current mode and down to previous mode\n")
1868 return vtysh_exit_ripd(self
, vty
, argc
, argv
);
1871 DEFUNSH(VTYSH_RIPNGD
, vtysh_exit_ripngd
, vtysh_exit_ripngd_cmd
, "exit",
1872 "Exit current mode and down to previous mode\n")
1874 return vtysh_exit(vty
);
1877 DEFUNSH(VTYSH_RIPNGD
, vtysh_quit_ripngd
, vtysh_quit_ripngd_cmd
, "quit",
1878 "Exit current mode and down to previous mode\n")
1880 return vtysh_exit_ripngd(self
, vty
, argc
, argv
);
1883 DEFUNSH(VTYSH_RMAP
, vtysh_exit_rmap
, vtysh_exit_rmap_cmd
, "exit",
1884 "Exit current mode and down to previous mode\n")
1886 return vtysh_exit(vty
);
1889 DEFUNSH(VTYSH_RMAP
, vtysh_quit_rmap
, vtysh_quit_rmap_cmd
, "quit",
1890 "Exit current mode and down to previous mode\n")
1892 return vtysh_exit_rmap(self
, vty
, argc
, argv
);
1895 DEFUNSH(VTYSH_PBRD
, vtysh_exit_pbr_map
, vtysh_exit_pbr_map_cmd
, "exit",
1896 "Exit current mode and down to previous mode\n")
1898 return vtysh_exit(vty
);
1901 DEFUNSH(VTYSH_PBRD
, vtysh_quit_pbr_map
, vtysh_quit_pbr_map_cmd
, "quit",
1902 "Exit current mode and down to previous mode\n")
1904 return vtysh_exit_rmap(self
, vty
, argc
, argv
);
1907 DEFUNSH(VTYSH_BGPD
, vtysh_exit_bgpd
, vtysh_exit_bgpd_cmd
, "exit",
1908 "Exit current mode and down to previous mode\n")
1910 return vtysh_exit(vty
);
1913 DEFUNSH(VTYSH_BGPD
, vtysh_quit_bgpd
, vtysh_quit_bgpd_cmd
, "quit",
1914 "Exit current mode and down to previous mode\n")
1916 return vtysh_exit_bgpd(self
, vty
, argc
, argv
);
1919 DEFUNSH(VTYSH_OSPFD
, vtysh_exit_ospfd
, vtysh_exit_ospfd_cmd
, "exit",
1920 "Exit current mode and down to previous mode\n")
1922 return vtysh_exit(vty
);
1925 DEFUNSH(VTYSH_OSPFD
, vtysh_quit_ospfd
, vtysh_quit_ospfd_cmd
, "quit",
1926 "Exit current mode and down to previous mode\n")
1928 return vtysh_exit_ospfd(self
, vty
, argc
, argv
);
1931 DEFUNSH(VTYSH_EIGRPD
, vtysh_exit_eigrpd
, vtysh_exit_eigrpd_cmd
, "exit",
1932 "Exit current mode and down to previous mode\n")
1934 return vtysh_exit(vty
);
1937 DEFUNSH(VTYSH_EIGRPD
, vtysh_quit_eigrpd
, vtysh_quit_eigrpd_cmd
, "quit",
1938 "Exit current mode and down to previous mode\n")
1940 return vtysh_exit(vty
);
1943 DEFUNSH(VTYSH_EIGRPD
, vtysh_exit_babeld
, vtysh_exit_babeld_cmd
, "exit",
1944 "Exit current mode and down to previous mode\n")
1946 return vtysh_exit(vty
);
1949 DEFUNSH(VTYSH_BABELD
, vtysh_quit_babeld
, vtysh_quit_babeld_cmd
, "quit",
1950 "Exit current mode and down to previous mode\n")
1952 return vtysh_exit(vty
);
1955 DEFUNSH(VTYSH_OSPF6D
, vtysh_exit_ospf6d
, vtysh_exit_ospf6d_cmd
, "exit",
1956 "Exit current mode and down to previous mode\n")
1958 return vtysh_exit(vty
);
1961 DEFUNSH(VTYSH_OSPF6D
, vtysh_quit_ospf6d
, vtysh_quit_ospf6d_cmd
, "quit",
1962 "Exit current mode and down to previous mode\n")
1964 return vtysh_exit_ospf6d(self
, vty
, argc
, argv
);
1967 #if defined(HAVE_LDPD)
1968 DEFUNSH(VTYSH_LDPD
, vtysh_exit_ldpd
, vtysh_exit_ldpd_cmd
, "exit",
1969 "Exit current mode and down to previous mode\n")
1971 return vtysh_exit(vty
);
1974 ALIAS(vtysh_exit_ldpd
, vtysh_quit_ldpd_cmd
, "quit",
1975 "Exit current mode and down to previous mode\n")
1978 DEFUNSH(VTYSH_ISISD
, vtysh_exit_isisd
, vtysh_exit_isisd_cmd
, "exit",
1979 "Exit current mode and down to previous mode\n")
1981 return vtysh_exit(vty
);
1984 DEFUNSH(VTYSH_ISISD
, vtysh_quit_isisd
, vtysh_quit_isisd_cmd
, "quit",
1985 "Exit current mode and down to previous mode\n")
1987 return vtysh_exit_isisd(self
, vty
, argc
, argv
);
1990 DEFUNSH(VTYSH_ALL
, vtysh_exit_line_vty
, vtysh_exit_line_vty_cmd
, "exit",
1991 "Exit current mode and down to previous mode\n")
1993 return vtysh_exit(vty
);
1996 DEFUNSH(VTYSH_ALL
, vtysh_quit_line_vty
, vtysh_quit_line_vty_cmd
, "quit",
1997 "Exit current mode and down to previous mode\n")
1999 return vtysh_exit_line_vty(self
, vty
, argc
, argv
);
2002 DEFUNSH(VTYSH_INTERFACE
, vtysh_interface
, vtysh_interface_cmd
,
2003 "interface IFNAME [vrf NAME]",
2004 "Select an interface to configure\n"
2005 "Interface's name\n" VRF_CMD_HELP_STR
)
2007 vty
->node
= INTERFACE_NODE
;
2011 DEFUNSH(VTYSH_ZEBRA
, vtysh_pseudowire
, vtysh_pseudowire_cmd
,
2012 "pseudowire IFNAME",
2013 "Static pseudowire configuration\n"
2014 "Pseudowire name\n")
2016 vty
->node
= PW_NODE
;
2020 /* TODO Implement "no interface command in isisd. */
2021 DEFSH(VTYSH_ZEBRA
| VTYSH_RIPD
| VTYSH_RIPNGD
| VTYSH_OSPFD
| VTYSH_OSPF6D
2023 vtysh_no_interface_cmd
, "no interface IFNAME", NO_STR
2024 "Delete a pseudo interface's configuration\n"
2025 "Interface's name\n")
2027 DEFSH(VTYSH_ZEBRA
, vtysh_no_interface_vrf_cmd
, "no interface IFNAME vrf NAME",
2029 "Delete a pseudo interface's configuration\n"
2030 "Interface's name\n" VRF_CMD_HELP_STR
)
2032 DEFUNSH(VTYSH_ZEBRA
, vtysh_logicalrouter
, vtysh_logicalrouter_cmd
,
2033 "logical-router (1-65535) ns NAME",
2034 "Enable a logical-router\n"
2035 "Specify the logical-router indentifier\n"
2037 "The file name in " NS_RUN_DIR
", or a full pathname\n")
2039 vty
->node
= LOGICALROUTER_NODE
;
2043 DEFSH(VTYSH_ZEBRA
, vtysh_no_logicalrouter_cmd
,
2044 "no logical-router (1-65535) ns NAME", NO_STR
2045 "Enable a Logical-Router\n"
2046 "Specify the Logical-Router identifier\n"
2048 "The file name in " NS_RUN_DIR
", or a full pathname\n")
2050 DEFUNSH(VTYSH_PBRD
, vtysh_nexthop_group
, vtysh_nexthop_group_cmd
,
2051 "nexthop-group NAME",
2052 "Nexthop Group configuration\n"
2053 "Name of the Nexthop Group\n")
2055 vty
->node
= NH_GROUP_NODE
;
2059 DEFSH(VTYSH_PBRD
, vtysh_no_nexthop_group_cmd
, "no nexthop-group NAME",
2061 "Nexthop Group Configuration\n"
2062 "Name of the Nexthop Group\n")
2064 DEFUNSH(VTYSH_VRF
, vtysh_vrf
, vtysh_vrf_cmd
, "vrf NAME",
2065 "Select a VRF to configure\n"
2068 vty
->node
= VRF_NODE
;
2072 DEFSH(VTYSH_ZEBRA
, vtysh_no_vrf_cmd
, "no vrf NAME", NO_STR
2073 "Delete a pseudo vrf's configuration\n"
2076 DEFUNSH(VTYSH_NS
, vtysh_exit_logicalrouter
,
2077 vtysh_exit_logicalrouter_cmd
, "exit",
2078 "Exit current mode and down to previous mode\n")
2080 return vtysh_exit(vty
);
2083 DEFUNSH(VTYSH_NS
, vtysh_quit_logicalrouter
,
2084 vtysh_quit_logicalrouter_cmd
, "quit",
2085 "Exit current mode and down to previous mode\n")
2087 return vtysh_exit_logicalrouter(self
, vty
, argc
, argv
);
2090 DEFUNSH(VTYSH_VRF
, vtysh_exit_vrf
, vtysh_exit_vrf_cmd
, "exit",
2091 "Exit current mode and down to previous mode\n")
2093 return vtysh_exit(vty
);
2096 DEFUNSH(VTYSH_VRF
, vtysh_quit_vrf
, vtysh_quit_vrf_cmd
, "quit",
2097 "Exit current mode and down to previous mode\n")
2099 return vtysh_exit_vrf(self
, vty
, argc
, argv
);
2102 DEFUNSH(VTYSH_PBRD
, vtysh_exit_nexthop_group
, vtysh_exit_nexthop_group_cmd
,
2103 "exit", "Exit current mode and down to previous mode\n")
2105 return vtysh_exit(vty
);
2108 DEFUNSH(VTYSH_VRF
, vtysh_quit_nexthop_group
, vtysh_quit_nexthop_group_cmd
,
2109 "quit", "Exit current mode and down to previous mode\n")
2111 return vtysh_exit_nexthop_group(self
, vty
, argc
, argv
);
2115 * TODO Implement interface description commands in ripngd, ospf6d
2118 DEFSH(VTYSH_ZEBRA
| VTYSH_RIPD
| VTYSH_OSPFD
| VTYSH_EIGRPD
,
2119 vtysh_interface_desc_cmd
, "description LINE...",
2120 "Interface specific description\n"
2121 "Characters describing this interface\n")
2123 DEFSH(VTYSH_ZEBRA
| VTYSH_RIPD
| VTYSH_OSPFD
| VTYSH_EIGRPD
,
2124 vtysh_no_interface_desc_cmd
, "no description",
2125 NO_STR
"Interface specific description\n")
2127 DEFUNSH(VTYSH_INTERFACE
, vtysh_exit_interface
, vtysh_exit_interface_cmd
, "exit",
2128 "Exit current mode and down to previous mode\n")
2130 return vtysh_exit(vty
);
2133 DEFUNSH(VTYSH_INTERFACE
, vtysh_quit_interface
, vtysh_quit_interface_cmd
, "quit",
2134 "Exit current mode and down to previous mode\n")
2136 return vtysh_exit_interface(self
, vty
, argc
, argv
);
2139 DEFUN (vtysh_show_thread
,
2140 vtysh_show_thread_cmd
,
2141 "show thread cpu [FILTER]",
2143 "Thread information\n"
2144 "Thread CPU usage\n"
2145 "Display filter (rwtexb)\n")
2149 int ret
= CMD_SUCCESS
;
2152 const char *filter
=
2153 argv_find(argv
, argc
, "FILTER", &idx
) ? argv
[idx
]->arg
: "";
2155 snprintf(line
, sizeof(line
), "do show thread cpu %s\n", filter
);
2156 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2157 if (vtysh_client
[i
].fd
>= 0) {
2158 vty_out(vty
, "Thread statistics for %s:\n",
2159 vtysh_client
[i
].name
);
2160 ret
= vtysh_client_execute(&vtysh_client
[i
], line
);
2166 DEFUN (vtysh_show_work_queues
,
2167 vtysh_show_work_queues_cmd
,
2170 "Work Queue information\n")
2173 int ret
= CMD_SUCCESS
;
2174 char line
[] = "do show work-queues\n";
2176 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2177 if (vtysh_client
[i
].fd
>= 0) {
2178 vty_out(vty
, "Work queue statistics for %s:\n",
2179 vtysh_client
[i
].name
);
2180 ret
= vtysh_client_execute(&vtysh_client
[i
], line
);
2187 DEFUN (vtysh_show_work_queues_daemon
,
2188 vtysh_show_work_queues_daemon_cmd
,
2189 "show work-queues <zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pbrd>",
2191 "Work Queue information\n"
2192 "For the zebra daemon\n"
2193 "For the rip daemon\n"
2194 "For the ripng daemon\n"
2195 "For the ospf daemon\n"
2196 "For the ospfv6 daemon\n"
2197 "For the bgp daemon\n"
2198 "For the isis daemon\n"
2199 "For the pbr daemon\n")
2201 int idx_protocol
= 2;
2203 int ret
= CMD_SUCCESS
;
2205 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
2206 if (strmatch(vtysh_client
[i
].name
, argv
[idx_protocol
]->text
))
2210 ret
= vtysh_client_execute(&vtysh_client
[i
], "show work-queues\n");
2215 DEFUNSH(VTYSH_ZEBRA
, vtysh_link_params
, vtysh_link_params_cmd
, "link-params",
2218 vty
->node
= LINK_PARAMS_NODE
;
2222 DEFUNSH(VTYSH_ZEBRA
, exit_link_params
, exit_link_params_cmd
, "exit-link-params",
2223 "Exit from Link Params configuration node\n")
2225 if (vty
->node
== LINK_PARAMS_NODE
)
2226 vty
->node
= INTERFACE_NODE
;
2230 static int show_per_daemon(const char *line
, const char *headline
)
2233 int ret
= CMD_SUCCESS
;
2235 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2236 if (vtysh_client
[i
].fd
>= 0) {
2237 vty_out(vty
, headline
, vtysh_client
[i
].name
);
2238 ret
= vtysh_client_execute(&vtysh_client
[i
], line
);
2245 DEFUNSH_HIDDEN (0x00,
2247 vtysh_debug_all_cmd
,
2251 "Toggle all debugs on or off\n")
2256 DEFUN (vtysh_show_debugging
,
2257 vtysh_show_debugging_cmd
,
2262 return show_per_daemon("do show debugging\n", "");
2265 DEFUN (vtysh_show_debugging_hashtable
,
2266 vtysh_show_debugging_hashtable_cmd
,
2267 "show debugging hashtable [statistics]",
2270 "Statistics about hash tables\n"
2271 "Statistics about hash tables\n")
2275 "Load factor (LF) - average number of elements across all buckets\n");
2277 "Full load factor (FLF) - average number of elements across full buckets\n\n");
2279 "Standard deviation (SD) is calculated for both the LF and FLF\n");
2281 "and indicates the typical deviation of bucket chain length\n");
2282 vty_out(vty
, "from the value in the corresponding load factor.\n\n");
2284 return show_per_daemon("do show debugging hashtable\n",
2285 "Hashtable statistics for %s:\n");
2289 DEFUN (vtysh_show_memory
,
2290 vtysh_show_memory_cmd
,
2293 "Memory statistics\n")
2295 return show_per_daemon("do show memory\n", "Memory statistics for %s:\n");
2298 DEFUN (vtysh_show_modules
,
2299 vtysh_show_modules_cmd
,
2304 return show_per_daemon("do show modules\n",
2305 "Module information for %s:\n");
2308 /* Logging commands. */
2309 DEFUN (vtysh_show_logging
,
2310 vtysh_show_logging_cmd
,
2313 "Show current logging configuration\n")
2315 return show_per_daemon("do show logging\n",
2316 "Logging configuration for %s:\n");
2319 DEFUNSH(VTYSH_ALL
, vtysh_log_stdout
, vtysh_log_stdout_cmd
, "log stdout",
2321 "Set stdout logging level\n")
2326 DEFUNSH(VTYSH_ALL
, vtysh_log_stdout_level
, vtysh_log_stdout_level_cmd
,
2327 "log stdout <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2329 "Set stdout logging level\n" LOG_LEVEL_DESC
)
2334 DEFUNSH(VTYSH_ALL
, no_vtysh_log_stdout
, no_vtysh_log_stdout_cmd
,
2335 "no log stdout [LEVEL]", NO_STR
2337 "Cancel logging to stdout\n"
2343 DEFUNSH(VTYSH_ALL
, vtysh_log_file
, vtysh_log_file_cmd
, "log file FILENAME",
2346 "Logging filename\n")
2351 DEFUNSH(VTYSH_ALL
, vtysh_log_file_level
, vtysh_log_file_level_cmd
,
2352 "log file FILENAME <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2355 "Logging filename\n" LOG_LEVEL_DESC
)
2360 DEFUNSH(VTYSH_ALL
, no_vtysh_log_file
, no_vtysh_log_file_cmd
,
2361 "no log file [FILENAME [LEVEL]]", NO_STR
2363 "Cancel logging to file\n"
2364 "Logging file name\n"
2370 DEFUNSH(VTYSH_ALL
, vtysh_log_monitor
, vtysh_log_monitor_cmd
,
2371 "log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
2373 "Set terminal line (monitor) logging level\n" LOG_LEVEL_DESC
)
2378 DEFUNSH(VTYSH_ALL
, no_vtysh_log_monitor
, no_vtysh_log_monitor_cmd
,
2379 "no log monitor [LEVEL]", NO_STR
2381 "Disable terminal line (monitor) logging\n"
2387 DEFUNSH(VTYSH_ALL
, vtysh_log_syslog
, vtysh_log_syslog_cmd
,
2388 "log syslog [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
2390 "Set syslog logging level\n" LOG_LEVEL_DESC
)
2395 DEFUNSH(VTYSH_ALL
, no_vtysh_log_syslog
, no_vtysh_log_syslog_cmd
,
2396 "no log syslog [LEVEL]", NO_STR
2398 "Cancel logging to syslog\n"
2404 DEFUNSH(VTYSH_ALL
, vtysh_log_facility
, vtysh_log_facility_cmd
,
2405 "log facility <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>",
2407 "Facility parameter for syslog messages\n" LOG_FACILITY_DESC
)
2412 DEFUNSH(VTYSH_ALL
, no_vtysh_log_facility
, no_vtysh_log_facility_cmd
,
2413 "no log facility [FACILITY]", NO_STR
2415 "Reset syslog facility to default (daemon)\n"
2416 "Syslog facility\n")
2422 VTYSH_ALL
, vtysh_log_trap
, vtysh_log_trap_cmd
,
2423 "log trap <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2425 "(Deprecated) Set logging level and default for all destinations\n" LOG_LEVEL_DESC
)
2430 DEFUNSH_DEPRECATED(VTYSH_ALL
, no_vtysh_log_trap
, no_vtysh_log_trap_cmd
,
2431 "no log trap [LEVEL]", NO_STR
2433 "Permit all logging information\n"
2439 DEFUNSH(VTYSH_ALL
, vtysh_log_record_priority
, vtysh_log_record_priority_cmd
,
2440 "log record-priority",
2442 "Log the priority of the message within the message\n")
2447 DEFUNSH(VTYSH_ALL
, no_vtysh_log_record_priority
,
2448 no_vtysh_log_record_priority_cmd
, "no log record-priority", NO_STR
2450 "Do not log the priority of the message within the message\n")
2455 DEFUNSH(VTYSH_ALL
, vtysh_log_timestamp_precision
,
2456 vtysh_log_timestamp_precision_cmd
, "log timestamp precision (0-6)",
2458 "Timestamp configuration\n"
2459 "Set the timestamp precision\n"
2460 "Number of subsecond digits\n")
2465 DEFUNSH(VTYSH_ALL
, no_vtysh_log_timestamp_precision
,
2466 no_vtysh_log_timestamp_precision_cmd
, "no log timestamp precision",
2469 "Timestamp configuration\n"
2470 "Reset the timestamp precision to the default value of 0\n")
2475 DEFUNSH(VTYSH_ALL
, vtysh_service_password_encrypt
,
2476 vtysh_service_password_encrypt_cmd
, "service password-encryption",
2477 "Set up miscellaneous service\n"
2478 "Enable encrypted passwords\n")
2483 DEFUNSH(VTYSH_ALL
, no_vtysh_service_password_encrypt
,
2484 no_vtysh_service_password_encrypt_cmd
, "no service password-encryption",
2486 "Set up miscellaneous service\n"
2487 "Enable encrypted passwords\n")
2492 DEFUNSH(VTYSH_ALL
, vtysh_config_password
, vtysh_password_cmd
,
2493 "password [(8-8)] LINE",
2494 "Modify the terminal connection password\n"
2495 "Specifies a HIDDEN password will follow\n"
2496 "The password string\n")
2501 DEFUNSH(VTYSH_ALL
, no_vtysh_config_password
, no_vtysh_password_cmd
,
2502 "no password", NO_STR
2503 "Modify the terminal connection password\n")
2505 vty_out(vty
, NO_PASSWD_CMD_WARNING
);
2510 DEFUNSH(VTYSH_ALL
, vtysh_config_enable_password
, vtysh_enable_password_cmd
,
2511 "enable password [(8-8)] LINE",
2512 "Modify enable password parameters\n"
2513 "Assign the privileged level password\n"
2514 "Specifies a HIDDEN password will follow\n"
2515 "The 'enable' password string\n")
2520 DEFUNSH(VTYSH_ALL
, no_vtysh_config_enable_password
,
2521 no_vtysh_enable_password_cmd
, "no enable password", NO_STR
2522 "Modify enable password parameters\n"
2523 "Assign the privileged level password\n")
2525 vty_out(vty
, NO_PASSWD_CMD_WARNING
);
2530 DEFUN (vtysh_write_terminal
,
2531 vtysh_write_terminal_cmd
,
2532 "write terminal [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2533 "Write running configuration to memory, network, or terminal\n"
2534 "Write to terminal\n"
2535 "For the zebra daemon\n"
2536 "For the rip daemon\n"
2537 "For the ripng daemon\n"
2538 "For the ospf daemon\n"
2539 "For the ospfv6 daemon\n"
2540 "For the ldpd daemon\n"
2541 "For the bgp daemon\n"
2542 "For the isis daemon\n"
2543 "For the pim daemon\n")
2546 char line
[] = "do write terminal\n";
2548 vty_out(vty
, "Building configuration...\n");
2549 vty_out(vty
, "\nCurrent configuration:\n");
2550 vty_out(vty
, "!\n");
2552 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2554 || (strmatch(vtysh_client
[i
].name
, argv
[2]->text
)))
2555 vtysh_client_config(&vtysh_client
[i
], line
);
2557 /* Integrate vtysh specific configuration. */
2558 vty_open_pager(vty
);
2559 vtysh_config_write();
2560 vtysh_config_dump();
2561 vty_close_pager(vty
);
2562 vty_out(vty
, "end\n");
2567 DEFUN (vtysh_show_running_config
,
2568 vtysh_show_running_config_cmd
,
2569 "show running-config [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2571 "Current operating configuration\n"
2572 "For the zebra daemon\n"
2573 "For the rip daemon\n"
2574 "For the ripng daemon\n"
2575 "For the ospf daemon\n"
2576 "For the ospfv6 daemon\n"
2577 "For the ldp daemon\n"
2578 "For the bgp daemon\n"
2579 "For the isis daemon\n"
2580 "For the pim daemon\n")
2582 return vtysh_write_terminal(self
, vty
, argc
, argv
);
2585 DEFUN (vtysh_integrated_config
,
2586 vtysh_integrated_config_cmd
,
2587 "service integrated-vtysh-config",
2588 "Set up miscellaneous service\n"
2589 "Write configuration into integrated file\n")
2591 vtysh_write_integrated
= WRITE_INTEGRATED_YES
;
2595 DEFUN (no_vtysh_integrated_config
,
2596 no_vtysh_integrated_config_cmd
,
2597 "no service integrated-vtysh-config",
2599 "Set up miscellaneous service\n"
2600 "Write configuration into integrated file\n")
2602 vtysh_write_integrated
= WRITE_INTEGRATED_NO
;
2606 static void backup_config_file(const char *fbackup
)
2608 char *integrate_sav
= NULL
;
2610 integrate_sav
= malloc(strlen(fbackup
) + strlen(CONF_BACKUP_EXT
) + 1);
2611 strcpy(integrate_sav
, fbackup
);
2612 strcat(integrate_sav
, CONF_BACKUP_EXT
);
2614 /* Move current configuration file to backup config file. */
2615 unlink(integrate_sav
);
2616 rename(fbackup
, integrate_sav
);
2617 free(integrate_sav
);
2620 int vtysh_write_config_integrated(void)
2623 char line
[] = "do write terminal\n";
2626 struct passwd
*pwentry
;
2627 struct group
*grentry
;
2633 vty_out(vty
, "Building Configuration...\n");
2635 backup_config_file(frr_config
);
2636 fp
= fopen(frr_config
, "w");
2639 "%% Error: failed to open configuration file %s: %s\n",
2640 frr_config
, safe_strerror(errno
));
2641 return CMD_WARNING_CONFIG_FAILED
;
2645 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2646 vtysh_client_config(&vtysh_client
[i
], line
);
2648 vtysh_config_write();
2649 vtysh_config_dump();
2651 if (fchmod(fd
, CONFIGFILE_MASK
) != 0) {
2652 printf("%% Warning: can't chmod configuration file %s: %s\n",
2653 frr_config
, safe_strerror(errno
));
2658 pwentry
= getpwnam(FRR_USER
);
2660 uid
= pwentry
->pw_uid
;
2662 printf("%% Warning: could not look up user \"%s\"\n", FRR_USER
);
2667 grentry
= getgrnam(FRR_GROUP
);
2669 gid
= grentry
->gr_gid
;
2671 printf("%% Warning: could not look up group \"%s\"\n",
2677 if (!fstat(fd
, &st
)) {
2678 if (st
.st_uid
== uid
)
2680 if (st
.st_gid
== gid
)
2682 if ((uid
!= (uid_t
)-1 || gid
!= (gid_t
)-1)
2683 && fchown(fd
, uid
, gid
)) {
2684 printf("%% Warning: can't chown configuration file %s: %s\n",
2685 frr_config
, safe_strerror(errno
));
2689 printf("%% Warning: stat() failed on %s: %s\n", frr_config
,
2690 safe_strerror(errno
));
2696 printf("Integrated configuration saved to %s\n", frr_config
);
2704 static bool want_config_integrated(void)
2708 switch (vtysh_write_integrated
) {
2709 case WRITE_INTEGRATED_UNSPECIFIED
:
2710 if (stat(frr_config
, &s
) && errno
== ENOENT
)
2713 case WRITE_INTEGRATED_NO
:
2715 case WRITE_INTEGRATED_YES
:
2721 DEFUN (vtysh_write_memory
,
2722 vtysh_write_memory_cmd
,
2723 "write [<memory|file>]",
2724 "Write running configuration to memory, network, or terminal\n"
2725 "Write configuration to the file (same as write file)\n"
2726 "Write configuration to the file (same as write memory)\n")
2728 int ret
= CMD_SUCCESS
;
2729 char line
[] = "do write memory\n";
2732 vty_out(vty
, "Note: this version of vtysh never writes vtysh.conf\n");
2734 /* If integrated frr.conf explicitely set. */
2735 if (want_config_integrated()) {
2736 ret
= CMD_WARNING_CONFIG_FAILED
;
2738 /* first attempt to use watchfrr if it's available */
2739 bool used_watchfrr
= false;
2741 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2742 if (vtysh_client
[i
].flag
== VTYSH_WATCHFRR
)
2744 if (i
< array_size(vtysh_client
) && vtysh_client
[i
].fd
!= -1) {
2745 used_watchfrr
= true;
2746 ret
= vtysh_client_execute(&vtysh_client
[i
],
2747 "do write integrated");
2751 * If we didn't use watchfrr, fallback to writing the config
2754 if (!used_watchfrr
) {
2755 printf("\nWarning: attempting direct configuration write without "
2756 "watchfrr.\nFile permissions and ownership may be "
2757 "incorrect, or write may fail.\n\n");
2758 ret
= vtysh_write_config_integrated();
2763 vty_out(vty
, "Building Configuration...\n");
2765 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2766 ret
= vtysh_client_execute(&vtysh_client
[i
], line
);
2771 DEFUN (vtysh_copy_running_config
,
2772 vtysh_copy_running_config_cmd
,
2773 "copy running-config startup-config",
2774 "Copy from one file to another\n"
2775 "Copy from current system configuration\n"
2776 "Copy to startup configuration\n")
2778 return vtysh_write_memory(self
, vty
, argc
, argv
);
2781 DEFUN (vtysh_terminal_length
,
2782 vtysh_terminal_length_cmd
,
2783 "terminal length (0-512)",
2784 "Set terminal line parameters\n"
2785 "Set number of lines on a screen\n"
2786 "Number of lines on screen (0 for no pausing)\n")
2790 char *endptr
= NULL
;
2791 char default_pager
[10];
2793 lines
= strtol(argv
[idx_number
]->arg
, &endptr
, 10);
2794 if (lines
< 0 || lines
> 512 || *endptr
!= '\0') {
2795 vty_out(vty
, "length is malformed\n");
2799 if (vtysh_pager_name
) {
2800 free(vtysh_pager_name
);
2801 vtysh_pager_name
= NULL
;
2805 snprintf(default_pager
, 10, "more -%i", lines
);
2806 vtysh_pager_name
= strdup(default_pager
);
2812 DEFUN (vtysh_terminal_no_length
,
2813 vtysh_terminal_no_length_cmd
,
2814 "terminal no length",
2815 "Set terminal line parameters\n"
2817 "Set number of lines on a screen\n")
2819 if (vtysh_pager_name
) {
2820 free(vtysh_pager_name
);
2821 vtysh_pager_name
= NULL
;
2828 DEFUN (vtysh_show_daemons
,
2829 vtysh_show_daemons_cmd
,
2832 "Show list of running daemons\n")
2836 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2837 if (vtysh_client
[i
].fd
>= 0)
2838 vty_out(vty
, " %s", vtysh_client
[i
].name
);
2844 /* Execute command in child process. */
2845 static void execute_command(const char *command
, int argc
, const char *arg1
,
2855 /* Failure of fork(). */
2856 fprintf(stderr
, "Can't fork: %s\n", safe_strerror(errno
));
2858 } else if (pid
== 0) {
2859 /* This is child process. */
2862 execlp(command
, command
, (const char *)NULL
);
2865 execlp(command
, command
, arg1
, (const char *)NULL
);
2868 execlp(command
, command
, arg1
, arg2
,
2869 (const char *)NULL
);
2873 /* When execlp suceed, this part is not executed. */
2874 fprintf(stderr
, "Can't execute %s: %s\n", command
,
2875 safe_strerror(errno
));
2878 /* This is parent. */
2880 wait4(pid
, &status
, 0, NULL
);
2888 "Send echo messages\n"
2889 "Ping destination address or hostname\n")
2893 argv_find(argv
, argc
, "WORD", &idx
);
2894 execute_command("ping", 1, argv
[idx
]->arg
, NULL
);
2898 ALIAS(vtysh_ping
, vtysh_ping_ip_cmd
, "ping ip WORD",
2899 "Send echo messages\n"
2901 "Ping destination address or hostname\n")
2903 DEFUN (vtysh_traceroute
,
2904 vtysh_traceroute_cmd
,
2906 "Trace route to destination\n"
2907 "Trace route to destination address or hostname\n")
2911 argv_find(argv
, argc
, "WORD", &idx
);
2912 execute_command("traceroute", 1, argv
[idx
]->arg
, NULL
);
2916 ALIAS(vtysh_traceroute
, vtysh_traceroute_ip_cmd
, "traceroute ip WORD",
2917 "Trace route to destination\n"
2919 "Trace route to destination address or hostname\n")
2921 DEFUN (vtysh_mtrace
,
2923 "mtrace WORD [WORD]",
2924 "Multicast trace route to multicast source\n"
2925 "Multicast trace route to multicast source address\n"
2926 "Multicast trace route for multicast group address\n")
2929 execute_command("mtracebis", 1, argv
[1]->arg
, NULL
);
2931 execute_command("mtracebis", 2, argv
[1]->arg
, argv
[2]->arg
);
2938 "Send echo messages\n"
2940 "Ping destination address or hostname\n")
2942 execute_command("ping6", 1, argv
[2]->arg
, NULL
);
2946 DEFUN (vtysh_traceroute6
,
2947 vtysh_traceroute6_cmd
,
2948 "traceroute ipv6 WORD",
2949 "Trace route to destination\n"
2951 "Trace route to destination address or hostname\n")
2953 execute_command("traceroute6", 1, argv
[2]->arg
, NULL
);
2957 #if defined(HAVE_SHELL_ACCESS)
2958 DEFUN (vtysh_telnet
,
2961 "Open a telnet connection\n"
2962 "IP address or hostname of a remote system\n")
2964 execute_command("telnet", 1, argv
[1]->arg
, NULL
);
2968 DEFUN (vtysh_telnet_port
,
2969 vtysh_telnet_port_cmd
,
2971 "Open a telnet connection\n"
2972 "IP address or hostname of a remote system\n"
2973 "TCP Port number\n")
2975 execute_command("telnet", 2, argv
[1]->arg
, argv
[2]->arg
);
2982 "Open an ssh connection\n"
2985 execute_command("ssh", 1, argv
[1]->arg
, NULL
);
2989 DEFUN (vtysh_start_shell
,
2990 vtysh_start_shell_cmd
,
2992 "Start UNIX shell\n")
2994 execute_command("sh", 0, NULL
, NULL
);
2998 DEFUN (vtysh_start_bash
,
2999 vtysh_start_bash_cmd
,
3001 "Start UNIX shell\n"
3004 execute_command("bash", 0, NULL
, NULL
);
3008 DEFUN (vtysh_start_zsh
,
3009 vtysh_start_zsh_cmd
,
3011 "Start UNIX shell\n"
3014 execute_command("zsh", 0, NULL
, NULL
);
3021 "list [permutations]",
3022 "Print command list\n"
3023 "Print all possible command permutations\n")
3025 return cmd_list_cmds(vty
, argc
== 2);
3028 DEFUN (vtysh_output_file
,
3029 vtysh_output_file_cmd
,
3031 "Direct vtysh output to file\n"
3032 "Direct vtysh output to file\n"
3033 "Path to dump output to\n")
3035 const char *path
= argv
[argc
- 1]->arg
;
3036 vty
->of
= fopen(path
, "a");
3038 vty_out(vty
, "Failed to open file '%s': %s\n", path
,
3039 safe_strerror(errno
));
3045 DEFUN (no_vtysh_output_file
,
3046 no_vtysh_output_file_cmd
,
3047 "no output file [FILE]",
3049 "Direct vtysh output to file\n"
3050 "Direct vtysh output to file\n"
3051 "Path to dump output to\n")
3053 if (vty
->of
!= stdout
) {
3063 "Find CLI command containing text\n"
3064 "Text to search for\n")
3066 char *text
= argv_concat(argv
, argc
, 1);
3067 const struct cmd_node
*node
;
3068 const struct cmd_element
*cli
;
3071 for (unsigned int i
= 0; i
< vector_active(cmdvec
); i
++) {
3072 node
= vector_slot(cmdvec
, i
);
3075 clis
= node
->cmd_vector
;
3076 for (unsigned int j
= 0; j
< vector_active(clis
); j
++) {
3077 cli
= vector_slot(clis
, j
);
3078 if (strcasestr(cli
->string
, text
))
3079 vty_out(vty
, " (%s) %s\n",
3080 node_names
[node
->node
], cli
->string
);
3084 XFREE(MTYPE_TMP
, text
);
3089 DEFUN_HIDDEN(show_cli_graph_vtysh
,
3090 show_cli_graph_vtysh_cmd
,
3094 "Dump current command space as DOT graph\n")
3096 struct cmd_node
*cn
= vector_slot(cmdvec
, vty
->node
);
3097 char *dot
= cmd_graph_dump_dot(cn
->cmdgraph
);
3099 vty_out(vty
, "%s\n", dot
);
3100 XFREE(MTYPE_TMP
, dot
);
3104 static void vtysh_install_default(enum node_type node
)
3106 install_element(node
, &config_list_cmd
);
3107 install_element(node
, &find_cmd
);
3108 install_element(node
, &show_cli_graph_vtysh_cmd
);
3109 install_element(node
, &vtysh_output_file_cmd
);
3110 install_element(node
, &no_vtysh_output_file_cmd
);
3113 /* Making connection to protocol daemon. */
3114 static int vtysh_connect(struct vtysh_client
*vclient
)
3118 struct sockaddr_un addr
;
3122 if (!vclient
->path
[0])
3123 snprintf(vclient
->path
, sizeof(vclient
->path
), "%s/%s.vty",
3124 vtydir
, vclient
->name
);
3125 path
= vclient
->path
;
3127 /* Stat socket to see if we have permission to access it. */
3128 ret
= stat(path
, &s_stat
);
3129 if (ret
< 0 && errno
!= ENOENT
) {
3130 fprintf(stderr
, "vtysh_connect(%s): stat = %s\n", path
,
3131 safe_strerror(errno
));
3136 if (!S_ISSOCK(s_stat
.st_mode
)) {
3137 fprintf(stderr
, "vtysh_connect(%s): Not a socket\n",
3143 sock
= socket(AF_UNIX
, SOCK_STREAM
, 0);
3146 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", path
,
3147 safe_strerror(errno
));
3152 memset(&addr
, 0, sizeof(struct sockaddr_un
));
3153 addr
.sun_family
= AF_UNIX
;
3154 strlcpy(addr
.sun_path
, path
, sizeof(addr
.sun_path
));
3155 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
3156 len
= addr
.sun_len
= SUN_LEN(&addr
);
3158 len
= sizeof(addr
.sun_family
) + strlen(addr
.sun_path
);
3159 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
3161 ret
= connect(sock
, (struct sockaddr
*)&addr
, len
);
3164 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", path
,
3165 safe_strerror(errno
));
3175 static int vtysh_reconnect(struct vtysh_client
*vclient
)
3179 fprintf(stderr
, "Warning: connecting to %s...", vclient
->name
);
3180 ret
= vtysh_connect(vclient
);
3182 fprintf(stderr
, "failed!\n");
3185 fprintf(stderr
, "success!\n");
3186 if (vtysh_client_execute(vclient
, "enable") < 0)
3188 return vtysh_execute_no_pager("end");
3191 /* Return true if str ends with suffix, else return false */
3192 static int ends_with(const char *str
, const char *suffix
)
3194 if (!str
|| !suffix
)
3196 size_t lenstr
= strlen(str
);
3197 size_t lensuffix
= strlen(suffix
);
3198 if (lensuffix
> lenstr
)
3200 return strncmp(str
+ lenstr
- lensuffix
, suffix
, lensuffix
) == 0;
3203 static void vtysh_client_sorted_insert(struct vtysh_client
*head_client
,
3204 struct vtysh_client
*client
)
3206 struct vtysh_client
*prev_node
, *current_node
;
3208 prev_node
= head_client
;
3209 current_node
= head_client
->next
;
3210 while (current_node
) {
3211 if (strcmp(current_node
->path
, client
->path
) > 0)
3214 prev_node
= current_node
;
3215 current_node
= current_node
->next
;
3217 client
->next
= current_node
;
3218 prev_node
->next
= client
;
3221 #define MAXIMUM_INSTANCES 10
3223 static void vtysh_update_all_insances(struct vtysh_client
*head_client
)
3225 struct vtysh_client
*client
;
3227 struct dirent
*file
;
3230 if (head_client
->flag
!= VTYSH_OSPFD
)
3233 /* ls vty_sock_dir and look for all files ending in .vty */
3234 dir
= opendir(vtydir
);
3236 while ((file
= readdir(dir
)) != NULL
) {
3237 if (begins_with(file
->d_name
, "ospfd-")
3238 && ends_with(file
->d_name
, ".vty")) {
3239 if (n
== MAXIMUM_INSTANCES
) {
3241 "Parsing %s, client limit(%d) reached!\n",
3245 client
= (struct vtysh_client
*)malloc(
3246 sizeof(struct vtysh_client
));
3248 client
->name
= "ospfd";
3249 client
->flag
= VTYSH_OSPFD
;
3250 snprintf(client
->path
, sizeof(client
->path
),
3251 "%s/%s", vtydir
, file
->d_name
);
3252 client
->next
= NULL
;
3253 vtysh_client_sorted_insert(head_client
, client
);
3261 static int vtysh_connect_all_instances(struct vtysh_client
*head_client
)
3263 struct vtysh_client
*client
;
3266 vtysh_update_all_insances(head_client
);
3268 client
= head_client
->next
;
3270 if (vtysh_connect(client
) == 0)
3272 client
= client
->next
;
3278 int vtysh_connect_all(const char *daemon_name
)
3284 for (i
= 0; i
< array_size(vtysh_client
); i
++) {
3286 || !strcmp(daemon_name
, vtysh_client
[i
].name
)) {
3288 if (vtysh_connect(&vtysh_client
[i
]) == 0)
3291 rc
+= vtysh_connect_all_instances(&vtysh_client
[i
]);
3295 fprintf(stderr
, "Error: no daemons match name %s!\n",
3300 /* To disable readline's filename completion. */
3301 static char *vtysh_completion_entry_function(const char *ignore
,
3307 void vtysh_readline_init(void)
3309 /* readline related settings. */
3311 rl_bind_key('?', (rl_command_func_t
*)vtysh_rl_describe
);
3312 rl_completion_entry_function
= vtysh_completion_entry_function
;
3313 rl_attempted_completion_function
=
3314 (rl_completion_func_t
*)new_completion
;
3317 char *vtysh_prompt(void)
3319 static char buf
[100];
3321 snprintf(buf
, sizeof buf
, cmd_prompt(vty
->node
), cmd_hostname_get());
3325 static void vtysh_ac_line(void *arg
, const char *line
)
3329 for (i
= 0; i
< vector_active(comps
); i
++)
3330 if (!strcmp(line
, (char *)vector_slot(comps
, i
)))
3332 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, line
));
3335 static void vtysh_autocomplete(vector comps
, struct cmd_token
*token
)
3340 snprintf(accmd
, sizeof(accmd
), "autocomplete %d %s %s", token
->type
,
3341 token
->text
, token
->varname
? token
->varname
: "-");
3343 for (i
= 0; i
< array_size(vtysh_client
); i
++)
3344 vtysh_client_run_all(&vtysh_client
[i
], accmd
, 1, vtysh_ac_line
,
3348 static const struct cmd_variable_handler vtysh_var_handler
[] = {
3352 .completions
= vtysh_autocomplete
},
3353 {.completions
= NULL
}};
3357 if (vty
->of
!= stdout
)
3361 void vtysh_init_vty(void)
3363 /* Make vty structure. */
3365 vty
->type
= VTY_SHELL
;
3366 vty
->node
= VIEW_NODE
;
3368 /* set default output */
3371 /* Initialize commands. */
3373 cmd_variable_handler_register(vtysh_var_handler
);
3375 /* Install nodes. */
3376 install_node(&bgp_node
, NULL
);
3377 install_node(&rip_node
, NULL
);
3378 install_node(&interface_node
, NULL
);
3379 install_node(&pw_node
, NULL
);
3380 install_node(&link_params_node
, NULL
);
3381 install_node(&logicalrouter_node
, NULL
);
3382 install_node(&vrf_node
, NULL
);
3383 install_node(&nh_group_node
, NULL
);
3384 install_node(&rmap_node
, NULL
);
3385 install_node(&pbr_map_node
, NULL
);
3386 install_node(&zebra_node
, NULL
);
3387 install_node(&bgp_vpnv4_node
, NULL
);
3388 install_node(&bgp_vpnv6_node
, NULL
);
3389 install_node(&bgp_flowspecv4_node
, NULL
);
3390 install_node(&bgp_flowspecv6_node
, NULL
);
3391 install_node(&bgp_ipv4_node
, NULL
);
3392 install_node(&bgp_ipv4m_node
, NULL
);
3393 install_node(&bgp_ipv4l_node
, NULL
);
3394 install_node(&bgp_ipv6_node
, NULL
);
3395 install_node(&bgp_ipv6m_node
, NULL
);
3396 install_node(&bgp_ipv6l_node
, NULL
);
3397 install_node(&bgp_vrf_policy_node
, NULL
);
3398 install_node(&bgp_evpn_node
, NULL
);
3399 install_node(&bgp_evpn_vni_node
, NULL
);
3400 install_node(&bgp_vnc_defaults_node
, NULL
);
3401 install_node(&bgp_vnc_nve_group_node
, NULL
);
3402 install_node(&bgp_vnc_l2_group_node
, NULL
);
3403 install_node(&ospf_node
, NULL
);
3404 install_node(&eigrp_node
, NULL
);
3405 install_node(&babel_node
, NULL
);
3406 install_node(&ripng_node
, NULL
);
3407 install_node(&ospf6_node
, NULL
);
3408 install_node(&ldp_node
, NULL
);
3409 install_node(&ldp_ipv4_node
, NULL
);
3410 install_node(&ldp_ipv6_node
, NULL
);
3411 install_node(&ldp_ipv4_iface_node
, NULL
);
3412 install_node(&ldp_ipv6_iface_node
, NULL
);
3413 install_node(&ldp_l2vpn_node
, NULL
);
3414 install_node(&ldp_pseudowire_node
, NULL
);
3415 install_node(&keychain_node
, NULL
);
3416 install_node(&keychain_key_node
, NULL
);
3417 install_node(&isis_node
, NULL
);
3418 install_node(&vty_node
, NULL
);
3419 #if defined(HAVE_RPKI)
3420 install_node(&rpki_node
, NULL
);
3423 struct cmd_node
*node
;
3424 for (unsigned int i
= 0; i
< vector_active(cmdvec
); i
++) {
3425 node
= vector_slot(cmdvec
, i
);
3426 if (!node
|| node
->node
== VIEW_NODE
)
3428 vtysh_install_default(node
->node
);
3431 install_element(VIEW_NODE
, &vtysh_enable_cmd
);
3432 install_element(ENABLE_NODE
, &vtysh_config_terminal_cmd
);
3433 install_element(ENABLE_NODE
, &vtysh_disable_cmd
);
3435 /* "exit" command. */
3436 install_element(VIEW_NODE
, &vtysh_exit_all_cmd
);
3437 install_element(CONFIG_NODE
, &vtysh_exit_all_cmd
);
3438 install_element(VIEW_NODE
, &vtysh_quit_all_cmd
);
3439 install_element(CONFIG_NODE
, &vtysh_quit_all_cmd
);
3440 install_element(RIP_NODE
, &vtysh_exit_ripd_cmd
);
3441 install_element(RIP_NODE
, &vtysh_quit_ripd_cmd
);
3442 install_element(RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
3443 install_element(RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
3444 install_element(OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
3445 install_element(OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
3446 install_element(EIGRP_NODE
, &vtysh_exit_eigrpd_cmd
);
3447 install_element(EIGRP_NODE
, &vtysh_quit_eigrpd_cmd
);
3448 install_element(BABEL_NODE
, &vtysh_exit_babeld_cmd
);
3449 install_element(BABEL_NODE
, &vtysh_quit_babeld_cmd
);
3450 install_element(OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
3451 install_element(OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
3452 #if defined(HAVE_LDPD)
3453 install_element(LDP_NODE
, &vtysh_exit_ldpd_cmd
);
3454 install_element(LDP_NODE
, &vtysh_quit_ldpd_cmd
);
3455 install_element(LDP_IPV4_NODE
, &vtysh_exit_ldpd_cmd
);
3456 install_element(LDP_IPV4_NODE
, &vtysh_quit_ldpd_cmd
);
3457 install_element(LDP_IPV4_NODE
, &ldp_exit_address_family_cmd
);
3458 install_element(LDP_IPV6_NODE
, &vtysh_exit_ldpd_cmd
);
3459 install_element(LDP_IPV6_NODE
, &vtysh_quit_ldpd_cmd
);
3460 install_element(LDP_IPV6_NODE
, &ldp_exit_address_family_cmd
);
3461 install_element(LDP_IPV4_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3462 install_element(LDP_IPV4_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3463 install_element(LDP_IPV6_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3464 install_element(LDP_IPV6_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3465 install_element(LDP_L2VPN_NODE
, &vtysh_exit_ldpd_cmd
);
3466 install_element(LDP_L2VPN_NODE
, &vtysh_quit_ldpd_cmd
);
3467 install_element(LDP_PSEUDOWIRE_NODE
, &vtysh_exit_ldpd_cmd
);
3468 install_element(LDP_PSEUDOWIRE_NODE
, &vtysh_quit_ldpd_cmd
);
3470 install_element(BGP_NODE
, &vtysh_exit_bgpd_cmd
);
3471 install_element(BGP_NODE
, &vtysh_quit_bgpd_cmd
);
3472 install_element(BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
3473 install_element(BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
3474 install_element(BGP_VPNV6_NODE
, &vtysh_exit_bgpd_cmd
);
3475 install_element(BGP_VPNV6_NODE
, &vtysh_quit_bgpd_cmd
);
3476 install_element(BGP_FLOWSPECV4_NODE
, &vtysh_exit_bgpd_cmd
);
3477 install_element(BGP_FLOWSPECV4_NODE
, &vtysh_quit_bgpd_cmd
);
3478 install_element(BGP_FLOWSPECV6_NODE
, &vtysh_exit_bgpd_cmd
);
3479 install_element(BGP_FLOWSPECV6_NODE
, &vtysh_quit_bgpd_cmd
);
3480 install_element(BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
3481 install_element(BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
3482 install_element(BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
3483 install_element(BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
3484 install_element(BGP_IPV4L_NODE
, &vtysh_exit_bgpd_cmd
);
3485 install_element(BGP_IPV4L_NODE
, &vtysh_quit_bgpd_cmd
);
3486 install_element(BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
3487 install_element(BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
3488 install_element(BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
3489 install_element(BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
3490 install_element(BGP_EVPN_NODE
, &vtysh_quit_bgpd_cmd
);
3491 install_element(BGP_EVPN_NODE
, &vtysh_exit_bgpd_cmd
);
3492 install_element(BGP_EVPN_VNI_NODE
, &vtysh_exit_bgpd_cmd
);
3493 install_element(BGP_EVPN_VNI_NODE
, &vtysh_quit_bgpd_cmd
);
3494 install_element(BGP_IPV6L_NODE
, &vtysh_exit_bgpd_cmd
);
3495 install_element(BGP_IPV6L_NODE
, &vtysh_quit_bgpd_cmd
);
3496 #if defined(ENABLE_BGP_VNC)
3497 install_element(BGP_VRF_POLICY_NODE
, &vtysh_exit_bgpd_cmd
);
3498 install_element(BGP_VRF_POLICY_NODE
, &vtysh_quit_bgpd_cmd
);
3499 install_element(BGP_VNC_DEFAULTS_NODE
, &vtysh_exit_bgpd_cmd
);
3500 install_element(BGP_VNC_DEFAULTS_NODE
, &vtysh_quit_bgpd_cmd
);
3501 install_element(BGP_VNC_NVE_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3502 install_element(BGP_VNC_NVE_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3503 install_element(BGP_VNC_L2_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3504 install_element(BGP_VNC_L2_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3506 install_element(ISIS_NODE
, &vtysh_exit_isisd_cmd
);
3507 install_element(ISIS_NODE
, &vtysh_quit_isisd_cmd
);
3508 install_element(KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
3509 install_element(KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
3510 install_element(KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
3511 install_element(KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
3512 install_element(RMAP_NODE
, &vtysh_exit_rmap_cmd
);
3513 install_element(RMAP_NODE
, &vtysh_quit_rmap_cmd
);
3514 install_element(PBRMAP_NODE
, &vtysh_exit_pbr_map_cmd
);
3515 install_element(PBRMAP_NODE
, &vtysh_quit_pbr_map_cmd
);
3516 install_element(VTY_NODE
, &vtysh_exit_line_vty_cmd
);
3517 install_element(VTY_NODE
, &vtysh_quit_line_vty_cmd
);
3519 /* "end" command. */
3520 install_element(CONFIG_NODE
, &vtysh_end_all_cmd
);
3521 install_element(ENABLE_NODE
, &vtysh_end_all_cmd
);
3522 install_element(RIP_NODE
, &vtysh_end_all_cmd
);
3523 install_element(RIPNG_NODE
, &vtysh_end_all_cmd
);
3524 install_element(OSPF_NODE
, &vtysh_end_all_cmd
);
3525 install_element(EIGRP_NODE
, &vtysh_end_all_cmd
);
3526 install_element(BABEL_NODE
, &vtysh_end_all_cmd
);
3527 install_element(OSPF6_NODE
, &vtysh_end_all_cmd
);
3528 install_element(LDP_NODE
, &vtysh_end_all_cmd
);
3529 install_element(LDP_IPV4_NODE
, &vtysh_end_all_cmd
);
3530 install_element(LDP_IPV6_NODE
, &vtysh_end_all_cmd
);
3531 install_element(LDP_IPV4_IFACE_NODE
, &vtysh_end_all_cmd
);
3532 install_element(LDP_IPV6_IFACE_NODE
, &vtysh_end_all_cmd
);
3533 install_element(LDP_L2VPN_NODE
, &vtysh_end_all_cmd
);
3534 install_element(LDP_PSEUDOWIRE_NODE
, &vtysh_end_all_cmd
);
3535 install_element(BGP_NODE
, &vtysh_end_all_cmd
);
3536 install_element(BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
3537 install_element(BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
3538 install_element(BGP_IPV4L_NODE
, &vtysh_end_all_cmd
);
3539 install_element(BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
3540 install_element(BGP_VPNV6_NODE
, &vtysh_end_all_cmd
);
3541 install_element(BGP_FLOWSPECV4_NODE
, &vtysh_end_all_cmd
);
3542 install_element(BGP_FLOWSPECV6_NODE
, &vtysh_end_all_cmd
);
3543 install_element(BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
3544 install_element(BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
3545 install_element(BGP_IPV6L_NODE
, &vtysh_end_all_cmd
);
3546 install_element(BGP_VRF_POLICY_NODE
, &vtysh_end_all_cmd
);
3547 install_element(BGP_EVPN_NODE
, &vtysh_end_all_cmd
);
3548 install_element(BGP_EVPN_VNI_NODE
, &vtysh_end_all_cmd
);
3549 install_element(BGP_VNC_DEFAULTS_NODE
, &vtysh_end_all_cmd
);
3550 install_element(BGP_VNC_NVE_GROUP_NODE
, &vtysh_end_all_cmd
);
3551 install_element(BGP_VNC_L2_GROUP_NODE
, &vtysh_end_all_cmd
);
3552 install_element(ISIS_NODE
, &vtysh_end_all_cmd
);
3553 install_element(KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
3554 install_element(KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
3555 install_element(RMAP_NODE
, &vtysh_end_all_cmd
);
3556 install_element(PBRMAP_NODE
, &vtysh_end_all_cmd
);
3557 install_element(VTY_NODE
, &vtysh_end_all_cmd
);
3559 install_element(INTERFACE_NODE
, &vtysh_interface_desc_cmd
);
3560 install_element(INTERFACE_NODE
, &vtysh_no_interface_desc_cmd
);
3561 install_element(INTERFACE_NODE
, &vtysh_end_all_cmd
);
3562 install_element(INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
3563 install_element(LINK_PARAMS_NODE
, &exit_link_params_cmd
);
3564 install_element(LINK_PARAMS_NODE
, &vtysh_end_all_cmd
);
3565 install_element(LINK_PARAMS_NODE
, &vtysh_exit_interface_cmd
);
3566 install_element(INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
3568 install_element(PW_NODE
, &vtysh_end_all_cmd
);
3569 install_element(PW_NODE
, &vtysh_exit_interface_cmd
);
3570 install_element(PW_NODE
, &vtysh_quit_interface_cmd
);
3572 install_element(LOGICALROUTER_NODE
, &vtysh_end_all_cmd
);
3574 install_element(CONFIG_NODE
, &vtysh_logicalrouter_cmd
);
3575 install_element(CONFIG_NODE
, &vtysh_no_logicalrouter_cmd
);
3576 install_element(LOGICALROUTER_NODE
, &vtysh_exit_logicalrouter_cmd
);
3577 install_element(LOGICALROUTER_NODE
, &vtysh_quit_logicalrouter_cmd
);
3579 install_element(CONFIG_NODE
, &vtysh_nexthop_group_cmd
);
3580 install_element(NH_GROUP_NODE
, &vtysh_end_all_cmd
);
3581 install_element(NH_GROUP_NODE
, &vtysh_exit_nexthop_group_cmd
);
3582 install_element(NH_GROUP_NODE
, &vtysh_quit_nexthop_group_cmd
);
3584 install_element(VRF_NODE
, &vtysh_end_all_cmd
);
3585 install_element(VRF_NODE
, &vtysh_exit_vrf_cmd
);
3586 install_element(VRF_NODE
, &vtysh_quit_vrf_cmd
);
3588 install_element(CONFIG_NODE
, &router_eigrp_cmd
);
3589 install_element(CONFIG_NODE
, &router_babel_cmd
);
3590 install_element(CONFIG_NODE
, &router_rip_cmd
);
3591 install_element(CONFIG_NODE
, &router_ripng_cmd
);
3592 install_element(CONFIG_NODE
, &router_ospf_cmd
);
3593 install_element(CONFIG_NODE
, &router_ospf6_cmd
);
3594 #if defined(HAVE_LDPD)
3595 install_element(CONFIG_NODE
, &ldp_mpls_ldp_cmd
);
3596 install_element(LDP_NODE
, &ldp_address_family_ipv4_cmd
);
3597 install_element(LDP_NODE
, &ldp_address_family_ipv6_cmd
);
3598 install_element(LDP_IPV4_NODE
, &ldp_interface_ifname_cmd
);
3599 install_element(LDP_IPV6_NODE
, &ldp_interface_ifname_cmd
);
3600 install_element(CONFIG_NODE
, &ldp_l2vpn_word_type_vpls_cmd
);
3601 install_element(LDP_L2VPN_NODE
, &ldp_member_pseudowire_ifname_cmd
);
3603 install_element(CONFIG_NODE
, &router_isis_cmd
);
3604 install_element(CONFIG_NODE
, &router_bgp_cmd
);
3605 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
3606 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
3607 #if defined(ENABLE_BGP_VNC)
3608 install_element(BGP_NODE
, &vnc_vrf_policy_cmd
);
3609 install_element(BGP_NODE
, &vnc_defaults_cmd
);
3610 install_element(BGP_NODE
, &vnc_nve_group_cmd
);
3611 install_element(BGP_NODE
, &vnc_l2_group_cmd
);
3613 install_element(BGP_NODE
, &address_family_ipv4_cmd
);
3614 install_element(BGP_NODE
, &address_family_ipv4_multicast_cmd
);
3615 install_element(BGP_NODE
, &address_family_ipv4_vpn_cmd
);
3616 install_element(BGP_NODE
, &address_family_ipv4_labeled_unicast_cmd
);
3617 install_element(BGP_NODE
, &address_family_ipv6_cmd
);
3618 install_element(BGP_NODE
, &address_family_ipv6_multicast_cmd
);
3619 install_element(BGP_NODE
, &address_family_ipv6_vpn_cmd
);
3620 install_element(BGP_NODE
, &address_family_ipv6_labeled_unicast_cmd
);
3621 install_element(BGP_NODE
, &address_family_evpn_cmd
);
3622 install_element(BGP_NODE
, &address_family_flowspecv4_cmd
);
3623 install_element(BGP_NODE
, &address_family_flowspecv6_cmd
);
3624 #if defined(HAVE_CUMULUS)
3625 install_element(BGP_NODE
, &address_family_evpn2_cmd
);
3627 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
3628 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
3629 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
3630 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
3631 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
3632 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
3633 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
3634 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
3635 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
3636 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
3637 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
3639 #if defined(HAVE_RPKI)
3640 install_element(CONFIG_NODE
, &rpki_cmd
);
3641 install_element(RPKI_NODE
, &rpki_exit_cmd
);
3642 install_element(RPKI_NODE
, &rpki_quit_cmd
);
3643 install_element(RPKI_NODE
, &vtysh_end_all_cmd
);
3647 install_element(BGP_EVPN_NODE
, &bgp_evpn_vni_cmd
);
3648 install_element(BGP_EVPN_VNI_NODE
, &exit_vni_cmd
);
3650 install_element(BGP_VRF_POLICY_NODE
, &exit_vrf_policy_cmd
);
3651 install_element(BGP_VNC_DEFAULTS_NODE
, &exit_vnc_config_cmd
);
3652 install_element(BGP_VNC_NVE_GROUP_NODE
, &exit_vnc_config_cmd
);
3653 install_element(BGP_VNC_L2_GROUP_NODE
, &exit_vnc_config_cmd
);
3655 install_element(CONFIG_NODE
, &key_chain_cmd
);
3656 install_element(CONFIG_NODE
, &vtysh_route_map_cmd
);
3657 install_element(CONFIG_NODE
, &vtysh_pbr_map_cmd
);
3658 install_element(CONFIG_NODE
, &vtysh_no_pbr_map_cmd
);
3659 install_element(CONFIG_NODE
, &vtysh_line_vty_cmd
);
3660 install_element(KEYCHAIN_NODE
, &key_cmd
);
3661 install_element(KEYCHAIN_NODE
, &key_chain_cmd
);
3662 install_element(KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
3663 install_element(CONFIG_NODE
, &vtysh_interface_cmd
);
3664 install_element(CONFIG_NODE
, &vtysh_no_interface_cmd
);
3665 install_element(CONFIG_NODE
, &vtysh_no_interface_vrf_cmd
);
3666 install_element(CONFIG_NODE
, &vtysh_pseudowire_cmd
);
3667 install_element(INTERFACE_NODE
, &vtysh_link_params_cmd
);
3668 install_element(ENABLE_NODE
, &vtysh_show_running_config_cmd
);
3669 install_element(ENABLE_NODE
, &vtysh_copy_running_config_cmd
);
3671 install_element(VRF_NODE
, &exit_vrf_config_cmd
);
3673 install_element(CONFIG_NODE
, &vtysh_vrf_cmd
);
3674 install_element(CONFIG_NODE
, &vtysh_no_vrf_cmd
);
3675 install_element(CONFIG_NODE
, &vtysh_no_nexthop_group_cmd
);
3677 /* "write terminal" command. */
3678 install_element(ENABLE_NODE
, &vtysh_write_terminal_cmd
);
3680 install_element(CONFIG_NODE
, &vtysh_integrated_config_cmd
);
3681 install_element(CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
3683 /* "write memory" command. */
3684 install_element(ENABLE_NODE
, &vtysh_write_memory_cmd
);
3686 install_element(VIEW_NODE
, &vtysh_terminal_length_cmd
);
3687 install_element(VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
3688 install_element(VIEW_NODE
, &vtysh_show_daemons_cmd
);
3690 install_element(VIEW_NODE
, &vtysh_ping_cmd
);
3691 install_element(VIEW_NODE
, &vtysh_ping_ip_cmd
);
3692 install_element(VIEW_NODE
, &vtysh_traceroute_cmd
);
3693 install_element(VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
3694 install_element(VIEW_NODE
, &vtysh_mtrace_cmd
);
3695 install_element(VIEW_NODE
, &vtysh_ping6_cmd
);
3696 install_element(VIEW_NODE
, &vtysh_traceroute6_cmd
);
3697 #if defined(HAVE_SHELL_ACCESS)
3698 install_element(VIEW_NODE
, &vtysh_telnet_cmd
);
3699 install_element(VIEW_NODE
, &vtysh_telnet_port_cmd
);
3700 install_element(VIEW_NODE
, &vtysh_ssh_cmd
);
3702 #if defined(HAVE_SHELL_ACCESS)
3703 install_element(ENABLE_NODE
, &vtysh_start_shell_cmd
);
3704 install_element(ENABLE_NODE
, &vtysh_start_bash_cmd
);
3705 install_element(ENABLE_NODE
, &vtysh_start_zsh_cmd
);
3709 install_element(VIEW_NODE
, &vtysh_show_debugging_cmd
);
3710 install_element(VIEW_NODE
, &vtysh_show_debugging_hashtable_cmd
);
3711 install_element(ENABLE_NODE
, &vtysh_debug_all_cmd
);
3712 install_element(CONFIG_NODE
, &vtysh_debug_all_cmd
);
3714 /* misc lib show commands */
3715 install_element(VIEW_NODE
, &vtysh_show_memory_cmd
);
3716 install_element(VIEW_NODE
, &vtysh_show_modules_cmd
);
3717 install_element(VIEW_NODE
, &vtysh_show_work_queues_cmd
);
3718 install_element(VIEW_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3719 install_element(VIEW_NODE
, &vtysh_show_thread_cmd
);
3722 install_element(VIEW_NODE
, &vtysh_show_logging_cmd
);
3723 install_element(CONFIG_NODE
, &vtysh_log_stdout_cmd
);
3724 install_element(CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
3725 install_element(CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
3726 install_element(CONFIG_NODE
, &vtysh_log_file_cmd
);
3727 install_element(CONFIG_NODE
, &vtysh_log_file_level_cmd
);
3728 install_element(CONFIG_NODE
, &no_vtysh_log_file_cmd
);
3729 install_element(CONFIG_NODE
, &vtysh_log_monitor_cmd
);
3730 install_element(CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
3731 install_element(CONFIG_NODE
, &vtysh_log_syslog_cmd
);
3732 install_element(CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
3733 install_element(CONFIG_NODE
, &vtysh_log_trap_cmd
);
3734 install_element(CONFIG_NODE
, &no_vtysh_log_trap_cmd
);
3735 install_element(CONFIG_NODE
, &vtysh_log_facility_cmd
);
3736 install_element(CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
3737 install_element(CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
3738 install_element(CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
3739 install_element(CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
3740 install_element(CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
3742 install_element(CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
3743 install_element(CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
3745 install_element(CONFIG_NODE
, &vtysh_password_cmd
);
3746 install_element(CONFIG_NODE
, &no_vtysh_password_cmd
);
3747 install_element(CONFIG_NODE
, &vtysh_enable_password_cmd
);
3748 install_element(CONFIG_NODE
, &no_vtysh_enable_password_cmd
);