1 /* Virtual terminal interface shell.
2 * Copyright (C) 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 #include <sys/resource.h>
30 #include <readline/readline.h>
31 #include <readline/history.h>
41 #include "vtysh/vtysh.h"
43 #include "bgpd/bgp_vty.h"
47 DEFINE_MTYPE_STATIC(MVTYSH
, VTYSH_CMD
, "Vtysh cmd copy")
52 /* VTY shell pager name. */
53 char *vtysh_pager_name
= NULL
;
55 /* VTY shell client structure. */
62 struct vtysh_client
*next
;
65 struct vtysh_client vtysh_client
[] =
67 { .fd
= -1, .name
= "zebra", .flag
= VTYSH_ZEBRA
, .path
= ZEBRA_VTYSH_PATH
, .next
= NULL
},
68 { .fd
= -1, .name
= "ripd", .flag
= VTYSH_RIPD
, .path
= RIP_VTYSH_PATH
, .next
= NULL
},
69 { .fd
= -1, .name
= "ripngd", .flag
= VTYSH_RIPNGD
, .path
= RIPNG_VTYSH_PATH
, .next
= NULL
},
70 { .fd
= -1, .name
= "ospfd", .flag
= VTYSH_OSPFD
, .path
= OSPF_VTYSH_PATH
, .next
= NULL
},
71 { .fd
= -1, .name
= "ospf6d", .flag
= VTYSH_OSPF6D
, .path
= OSPF6_VTYSH_PATH
, .next
= NULL
},
72 { .fd
= -1, .name
= "ldpd", .flag
= VTYSH_LDPD
, .path
= LDP_VTYSH_PATH
, .next
= NULL
},
73 { .fd
= -1, .name
= "bgpd", .flag
= VTYSH_BGPD
, .path
= BGP_VTYSH_PATH
, .next
= NULL
},
74 { .fd
= -1, .name
= "isisd", .flag
= VTYSH_ISISD
, .path
= ISIS_VTYSH_PATH
, .next
= NULL
},
75 { .fd
= -1, .name
= "pimd", .flag
= VTYSH_PIMD
, .path
= PIM_VTYSH_PATH
, .next
= NULL
},
76 { .fd
= -1, .name
= "watchfrr", .flag
= VTYSH_WATCHFRR
, .path
= WATCHFRR_VTYSH_PATH
, .next
= NULL
},
79 enum vtysh_write_integrated vtysh_write_integrated
= WRITE_INTEGRATED_UNSPECIFIED
;
82 vclient_close (struct vtysh_client
*vclient
)
87 "Warning: closing connection to %s because of an I/O error!\n",
94 /* Return true if str begins with prefix, else return false */
96 begins_with(const char *str
, const char *prefix
)
100 size_t lenstr
= strlen(str
);
101 size_t lenprefix
= strlen(prefix
);
102 if (lenprefix
> lenstr
)
104 return strncmp(str
, prefix
, lenprefix
) == 0;
107 /* NB: multiplexed function:
108 * if fp == NULL, this calls vtysh_config_parse_line
109 * if fp != NULL, this prints lines to fp
112 vtysh_client_run (struct vtysh_client
*vclient
, const char *line
, FILE *fp
)
116 char *buf
= stackbuf
;
117 size_t bufsz
= sizeof(stackbuf
);
118 char *bufvalid
, *end
= NULL
;
119 char terminator
[3] = {0, 0, 0};
124 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
131 ssize_t nread
= read (vclient
->fd
, bufvalid
, buf
+ bufsz
- bufvalid
);
133 if (nread
< 0 && (errno
== EINTR
|| errno
== EAGAIN
))
138 fprintf (stderr
, "vtysh: error reading from %s: %s (%d)",
139 vclient
->name
, safe_strerror(errno
), errno
);
145 end
= memmem (buf
, bufvalid
- buf
, terminator
, sizeof(terminator
));
146 if (end
+ sizeof(terminator
) + 1 > bufvalid
)
147 /* found \0\0\0 but return code hasn't been read yet */
150 ret
= end
[sizeof(terminator
)];
152 while (bufvalid
> buf
&& (end
> buf
|| !end
))
154 size_t textlen
= (end
? end
: bufvalid
) - buf
;
155 char *eol
= memchr (buf
, '\n', textlen
);
160 /* no line break, end of input, no text left before end
161 * => don't insert an empty line at the end */
164 /* no line break, end of input, but some text left */
167 /* continue reading */
170 /* eol is at a line end now, either \n => \0 or \0\0\0 */
171 assert(eol
&& eol
<= bufvalid
);
179 vtysh_config_parse_line (buf
);
185 memmove (buf
, eol
, bufvalid
- eol
);
186 bufvalid
-= eol
- buf
;
191 if (bufvalid
== buf
+ bufsz
)
197 new = XMALLOC (MTYPE_TMP
, bufsz
);
198 memcpy (new, stackbuf
, sizeof(stackbuf
));
201 new = XREALLOC (MTYPE_TMP
, buf
, bufsz
);
203 bufvalid
= bufvalid
- buf
+ new;
205 /* if end != NULL, we won't be reading more data... */
206 assert (end
== NULL
);
213 vclient_close (vclient
);
217 XFREE (MTYPE_TMP
, buf
);
222 vtysh_client_run_all (struct vtysh_client
*head_client
, const char *line
,
223 int continue_on_err
, FILE *fp
)
225 struct vtysh_client
*client
;
226 int rc
, rc_all
= CMD_SUCCESS
;
228 for (client
= head_client
; client
; client
= client
->next
)
230 rc
= vtysh_client_run(client
, line
, fp
);
231 if (rc
!= CMD_SUCCESS
)
233 if (!continue_on_err
)
242 vtysh_client_execute (struct vtysh_client
*head_client
, const char *line
,
245 return vtysh_client_run_all (head_client
, line
, 0, fp
);
249 vtysh_client_config (struct vtysh_client
*head_client
, char *line
)
251 vtysh_client_run_all (head_client
, line
, 1, NULL
);
255 vtysh_pager_init (void)
259 pager_defined
= getenv ("VTYSH_PAGER");
262 vtysh_pager_name
= strdup (pager_defined
);
264 vtysh_pager_name
= strdup ("more");
267 /* Command execution over the vty interface. */
269 vtysh_execute_func (const char *line
, int pager
)
274 const struct cmd_element
*cmd
;
278 int saved_ret
, saved_node
;
280 /* Split readline string up into the vector. */
281 vline
= cmd_make_strvec (line
);
286 saved_ret
= ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
287 saved_node
= vty
->node
;
289 /* If command doesn't succeeded in current node, try to walk up in node tree.
290 * Changing vty->node is enough to try it just out without actual walkup in
292 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
293 && vty
->node
> CONFIG_NODE
)
295 vty
->node
= node_parent(vty
->node
);
296 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
300 vty
->node
= saved_node
;
302 /* If command succeeded in any other node than current (tried > 0) we have
303 * to move into node in the vtysh where it succeeded. */
304 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
306 if ((saved_node
== BGP_VPNV4_NODE
|| saved_node
== BGP_VPNV6_NODE
307 || saved_node
== BGP_ENCAP_NODE
|| saved_node
== BGP_ENCAPV6_NODE
308 || saved_node
== BGP_IPV4_NODE
309 || saved_node
== BGP_IPV6_NODE
|| saved_node
== BGP_IPV4M_NODE
310 || saved_node
== BGP_IPV6M_NODE
)
313 vtysh_execute("exit-address-family");
315 else if ((saved_node
== BGP_VNC_DEFAULTS_NODE
316 || saved_node
== BGP_VNC_NVE_GROUP_NODE
317 || saved_node
== BGP_VNC_L2_GROUP_NODE
) && (tried
== 1))
319 vtysh_execute("exit-vnc");
321 else if ((saved_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
323 vtysh_execute("exit");
327 vtysh_execute ("end");
328 vtysh_execute ("configure terminal");
331 /* If command didn't succeed in any node, continue with return value from
338 cmd_free_strvec (vline
);
344 if (vty
->type
== VTY_FILE
)
345 fprintf (stdout
,"Warning...\n");
347 case CMD_ERR_AMBIGUOUS
:
348 fprintf (stdout
,"%% Ambiguous command.\n");
350 case CMD_ERR_NO_MATCH
:
351 fprintf (stdout
,"%% Unknown command.\n");
353 case CMD_ERR_INCOMPLETE
:
354 fprintf (stdout
,"%% Command incomplete.\n");
356 case CMD_SUCCESS_DAEMON
:
358 /* FIXME: Don't open pager for exit commands. popen() causes problems
359 * if exited from vtysh at all. This hack shouldn't cause any problem
360 * but is really ugly. */
361 if (pager
&& vtysh_pager_name
&& (strncmp(line
, "exit", 4) != 0))
363 fp
= popen (vtysh_pager_name
, "w");
366 perror ("popen failed for pager");
375 if (! strcmp(cmd
->string
,"configure terminal"))
377 for (i
= 0; i
< array_size(vtysh_client
); i
++)
379 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
380 if (cmd_stat
== CMD_WARNING
)
387 vline
= cmd_make_strvec (line
);
391 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
393 if (pclose (fp
) == -1)
395 perror ("pclose failed for pager");
402 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
403 cmd_free_strvec (vline
);
404 if (ret
!= CMD_SUCCESS_DAEMON
)
410 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
415 cmd_stat
= CMD_SUCCESS
;
416 for (i
= 0; i
< array_size(vtysh_client
); i
++)
418 if (cmd
->daemon
& vtysh_client
[i
].flag
)
420 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
421 if (cmd_stat
!= CMD_SUCCESS
)
425 if (cmd_stat
!= CMD_SUCCESS
)
429 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
432 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
434 if (pclose (fp
) == -1)
436 perror ("pclose failed for pager");
444 vtysh_execute_no_pager (const char *line
)
446 return vtysh_execute_func (line
, 0);
450 vtysh_execute (const char *line
)
452 return vtysh_execute_func (line
, 1);
467 while (end
>= s
&& isspace(*end
))
471 while (*s
&& isspace(*s
))
478 vtysh_mark_file (const char *filename
)
485 const struct cmd_element
*cmd
;
486 int saved_ret
, prev_node
;
488 char *vty_buf_copy
= NULL
;
489 char *vty_buf_trimmed
= NULL
;
491 if (strncmp("-", filename
, 1) == 0)
494 confp
= fopen (filename
, "r");
498 fprintf (stderr
, "%% Can't open config file %s due to '%s'.\n",
499 filename
, safe_strerror (errno
));
500 return (CMD_ERR_NO_FILE
);
504 vty
->fd
= 0; /* stdout */
505 vty
->type
= VTY_TERM
;
506 vty
->node
= CONFIG_NODE
;
508 vtysh_execute_no_pager ("enable");
509 vtysh_execute_no_pager ("configure terminal");
510 vty_buf_copy
= XCALLOC (MTYPE_VTYSH_CMD
, VTY_BUFSIZ
);
512 while (fgets (vty
->buf
, VTY_BUFSIZ
, confp
))
516 strcpy(vty_buf_copy
, vty
->buf
);
517 vty_buf_trimmed
= trim(vty_buf_copy
);
519 if (vty_buf_trimmed
[0] == '!' || vty_buf_trimmed
[0] == '#')
521 fprintf(stdout
, "%s", vty
->buf
);
525 /* Split readline string up into the vector. */
526 vline
= cmd_make_strvec (vty
->buf
);
530 fprintf(stdout
, "%s", vty
->buf
);
534 /* Ignore the "end" lines, we will generate these where appropriate */
535 if (strlen(vty_buf_trimmed
) == 3 && strncmp("end", vty_buf_trimmed
, 3) == 0)
540 prev_node
= vty
->node
;
541 saved_ret
= ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
543 /* If command doesn't succeeded in current node, try to walk up in node tree.
544 * Changing vty->node is enough to try it just out without actual walkup in
546 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
547 && vty
->node
> CONFIG_NODE
)
549 vty
->node
= node_parent(vty
->node
);
550 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
554 /* If command succeeded in any other node than current (tried > 0) we have
555 * to move into node in the vtysh where it succeeded. */
556 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
558 if ((prev_node
== BGP_VPNV4_NODE
|| prev_node
== BGP_IPV4_NODE
559 || prev_node
== BGP_IPV6_NODE
|| prev_node
== BGP_IPV4M_NODE
560 || prev_node
== BGP_IPV6M_NODE
|| prev_node
== BGP_VPNV6_NODE
)
563 fprintf(stdout
, "exit-address-family\n");
565 else if ((prev_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
567 fprintf(stdout
, "exit\n");
571 fprintf(stdout
, "end\n");
574 /* If command didn't succeed in any node, continue with return value from
579 vty
->node
= prev_node
;
582 cmd_free_strvec (vline
);
586 if (vty
->type
== VTY_FILE
)
587 fprintf (stderr
,"line %d: Warning...: %s\n", lineno
, vty
->buf
);
590 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
592 case CMD_ERR_AMBIGUOUS
:
593 fprintf (stderr
,"line %d: %% Ambiguous command: %s\n", lineno
, vty
->buf
);
596 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
597 return CMD_ERR_AMBIGUOUS
;
598 case CMD_ERR_NO_MATCH
:
599 fprintf (stderr
,"line %d: %% Unknown command: %s\n", lineno
, vty
->buf
);
602 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
603 return CMD_ERR_NO_MATCH
;
604 case CMD_ERR_INCOMPLETE
:
605 fprintf (stderr
,"line %d: %% Command incomplete: %s\n", lineno
, vty
->buf
);
608 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
609 return CMD_ERR_INCOMPLETE
;
611 fprintf(stdout
, "%s", vty
->buf
);
613 case CMD_SUCCESS_DAEMON
:
616 int cmd_stat
= CMD_SUCCESS
;
618 fprintf(stdout
, "%s", vty
->buf
);
619 for (i
= 0; i
< array_size(vtysh_client
); i
++)
621 if (cmd
->daemon
& vtysh_client
[i
].flag
)
623 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
625 if (cmd_stat
!= CMD_SUCCESS
)
629 if (cmd_stat
!= CMD_SUCCESS
)
633 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
637 /* This is the end */
638 fprintf(stdout
, "end\n");
640 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
648 /* Configration make from file. */
650 vtysh_config_from_file (struct vty
*vty
, FILE *fp
)
653 const struct cmd_element
*cmd
;
655 int retcode
= CMD_SUCCESS
;
657 while (fgets (vty
->buf
, VTY_BUFSIZ
, fp
))
661 ret
= command_config_read_one_line (vty
, &cmd
, 1);
666 if (vty
->type
== VTY_FILE
)
667 fprintf (stderr
,"line %d: Warning[%d]...: %s\n", lineno
, vty
->node
, vty
->buf
);
668 retcode
= CMD_WARNING
; /* once we have an error, we remember & return that */
670 case CMD_ERR_AMBIGUOUS
:
671 fprintf (stderr
,"line %d: %% Ambiguous command[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
672 retcode
= CMD_ERR_AMBIGUOUS
; /* once we have an error, we remember & return that */
674 case CMD_ERR_NO_MATCH
:
675 fprintf (stderr
,"line %d: %% Unknown command[%d]: %s", lineno
, vty
->node
, vty
->buf
);
676 retcode
= CMD_ERR_NO_MATCH
; /* once we have an error, we remember & return that */
678 case CMD_ERR_INCOMPLETE
:
679 fprintf (stderr
,"line %d: %% Command incomplete[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
680 retcode
= CMD_ERR_INCOMPLETE
; /* once we have an error, we remember & return that */
682 case CMD_SUCCESS_DAEMON
:
685 int cmd_stat
= CMD_SUCCESS
;
687 for (i
= 0; i
< array_size(vtysh_client
); i
++)
689 if (cmd
->daemon
& vtysh_client
[i
].flag
)
691 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
694 * CMD_WARNING - Can mean that the command was
695 * parsed successfully but it was already entered
696 * in a few spots. As such if we receive a
697 * CMD_WARNING from a daemon we shouldn't stop
698 * talking to the other daemons for the particular
701 if (cmd_stat
!= CMD_SUCCESS
&& cmd_stat
!= CMD_WARNING
)
703 fprintf (stderr
, "line %d: Failure to communicate[%d] to %s, line: %s\n",
704 lineno
, cmd_stat
, vtysh_client
[i
].name
, vty
->buf
);
709 if (cmd_stat
!= CMD_SUCCESS
)
713 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
721 /* We don't care about the point of the cursor when '?' is typed. */
723 vtysh_rl_describe (void)
730 struct cmd_token
*token
;
732 vline
= cmd_make_strvec (rl_line_buffer
);
734 /* In case of '> ?'. */
737 vline
= vector_init (1);
738 vector_set (vline
, NULL
);
741 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
742 vector_set (vline
, NULL
);
744 describe
= cmd_describe_command (vline
, vty
, &ret
);
746 fprintf (stdout
,"\n");
748 /* Ambiguous and no match error. */
751 case CMD_ERR_AMBIGUOUS
:
752 cmd_free_strvec (vline
);
753 fprintf (stdout
,"%% Ambiguous command.\n");
757 case CMD_ERR_NO_MATCH
:
758 cmd_free_strvec (vline
);
759 fprintf (stdout
,"%% There is no matched command.\n");
765 /* Get width of command string. */
767 for (i
= 0; i
< vector_active (describe
); i
++)
768 if ((token
= vector_slot (describe
, i
)) != NULL
)
770 if (token
->text
[0] == '\0')
773 int len
= strlen (token
->text
);
779 for (i
= 0; i
< vector_active (describe
); i
++)
780 if ((token
= vector_slot (describe
, i
)) != NULL
)
783 fprintf (stdout
," %-s\n",
786 fprintf (stdout
," %-*s %s\n",
792 cmd_free_strvec (vline
);
793 vector_free (describe
);
800 /* Result of cmd_complete_command() call will be stored here
801 * and used in new_completion() in order to put the space in
802 * correct places only. */
806 command_generator (const char *text
, int state
)
809 static char **matched
= NULL
;
810 static int index
= 0;
817 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
820 vline
= cmd_make_strvec (rl_line_buffer
);
824 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
825 vector_set (vline
, NULL
);
828 XFREE (MTYPE_TMP
, matched
);
829 matched
= cmd_complete_command (vline
, vty
, &complete_status
);
830 cmd_free_strvec (vline
);
833 if (matched
&& matched
[index
])
834 return matched
[index
++];
840 new_completion (char *text
, int start
, int end
)
844 matches
= rl_completion_matches (text
, command_generator
);
849 if (complete_status
!= CMD_COMPLETE_FULL_MATCH
)
850 /* only append a space on full match */
851 rl_completion_append_character
= '\0';
857 /* Vty node structures. */
858 static struct cmd_node bgp_node
=
861 "%s(config-router)# ",
864 static struct cmd_node rip_node
=
867 "%s(config-router)# ",
870 static struct cmd_node isis_node
=
873 "%s(config-router)# ",
876 static struct cmd_node interface_node
=
882 static struct cmd_node ns_node
=
885 "%s(config-logical-router)# ",
888 static struct cmd_node vrf_node
=
894 static struct cmd_node rmap_node
=
897 "%s(config-route-map)# "
900 static struct cmd_node zebra_node
=
903 "%s(config-router)# "
906 static struct cmd_node bgp_vpnv4_node
=
909 "%s(config-router-af)# "
912 static struct cmd_node bgp_vpnv6_node
=
915 "%s(config-router-af)# "
918 static struct cmd_node bgp_encap_node
=
921 "%s(config-router-af)# "
924 static struct cmd_node bgp_encapv6_node
=
927 "%s(config-router-af)# "
930 static struct cmd_node bgp_ipv4_node
=
933 "%s(config-router-af)# "
936 static struct cmd_node bgp_ipv4m_node
=
939 "%s(config-router-af)# "
942 static struct cmd_node bgp_ipv6_node
=
945 "%s(config-router-af)# "
948 static struct cmd_node bgp_ipv6m_node
=
951 "%s(config-router-af)# "
954 static struct cmd_node bgp_vnc_defaults_node
=
956 BGP_VNC_DEFAULTS_NODE
,
957 "%s(config-router-vnc-defaults)# "
960 static struct cmd_node bgp_vnc_nve_group_node
=
962 BGP_VNC_NVE_GROUP_NODE
,
963 "%s(config-router-vnc-nve-group)# "
966 static struct cmd_node bgp_vnc_l2_group_node
=
968 BGP_VNC_L2_GROUP_NODE
,
969 "%s(config-router-vnc-l2-group)# "
972 static struct cmd_node ospf_node
=
975 "%s(config-router)# "
978 static struct cmd_node ripng_node
=
981 "%s(config-router)# "
984 static struct cmd_node ospf6_node
=
990 static struct cmd_node ldp_node
=
996 static struct cmd_node ldp_ipv4_node
=
999 "%s(config-ldp-af)# "
1002 static struct cmd_node ldp_ipv6_node
=
1005 "%s(config-ldp-af)# "
1008 static struct cmd_node ldp_ipv4_iface_node
=
1010 LDP_IPV4_IFACE_NODE
,
1011 "%s(config-ldp-af-if)# "
1014 static struct cmd_node ldp_ipv6_iface_node
=
1016 LDP_IPV6_IFACE_NODE
,
1017 "%s(config-ldp-af-if)# "
1020 static struct cmd_node ldp_l2vpn_node
=
1023 "%s(config-l2vpn)# "
1026 static struct cmd_node ldp_pseudowire_node
=
1028 LDP_PSEUDOWIRE_NODE
,
1029 "%s(config-l2vpn-pw)# "
1032 static struct cmd_node keychain_node
=
1035 "%s(config-keychain)# "
1038 static struct cmd_node keychain_key_node
=
1041 "%s(config-keychain-key)# "
1044 struct cmd_node link_params_node
=
1047 "%s(config-link-params)# ",
1050 /* Defined in lib/vty.c */
1051 extern struct cmd_node vty_node
;
1053 /* When '^Z' is received from vty, move down to the enable mode. */
1061 /* Nothing to do. */
1064 vty
->node
= ENABLE_NODE
;
1070 DEFUNSH (VTYSH_REALLYALL
,
1074 "End current mode and change to enable mode\n")
1076 return vtysh_end ();
1079 DEFUNSH (VTYSH_BGPD
,
1082 "router bgp [(1-4294967295) [<view|vrf> WORD]]",
1086 "BGP view\nBGP VRF\n"
1089 vty
->node
= BGP_NODE
;
1093 DEFUNSH (VTYSH_BGPD
,
1094 address_family_vpnv4
,
1095 address_family_vpnv4_cmd
,
1096 "address-family vpnv4 [unicast]",
1097 "Enter Address Family command mode\n"
1099 "Address Family Modifier\n")
1101 vty
->node
= BGP_VPNV4_NODE
;
1105 DEFUNSH (VTYSH_BGPD
,
1106 address_family_vpnv6
,
1107 address_family_vpnv6_cmd
,
1108 "address-family vpnv6 [unicast]",
1109 "Enter Address Family command mode\n"
1111 "Address Family Modifier\n")
1113 vty
->node
= BGP_VPNV6_NODE
;
1117 DEFUNSH (VTYSH_BGPD
,
1118 address_family_encapv4
,
1119 address_family_encapv4_cmd
,
1120 "address-family <encap|encapv4>",
1121 "Enter Address Family command mode\n"
1125 vty
->node
= BGP_ENCAP_NODE
;
1129 DEFUNSH (VTYSH_BGPD
,
1130 address_family_encapv6
,
1131 address_family_encapv6_cmd
,
1132 "address-family encapv6",
1133 "Enter Address Family command mode\n"
1136 vty
->node
= BGP_ENCAPV6_NODE
;
1140 DEFUNSH (VTYSH_BGPD
,
1141 address_family_ipv4_unicast
,
1142 address_family_ipv4_unicast_cmd
,
1143 "address-family ipv4 unicast",
1144 "Enter Address Family command mode\n"
1146 "Address Family Modifier\n")
1148 vty
->node
= BGP_IPV4_NODE
;
1152 DEFUNSH (VTYSH_BGPD
,
1153 address_family_ipv4_multicast
,
1154 address_family_ipv4_multicast_cmd
,
1155 "address-family ipv4 multicast",
1156 "Enter Address Family command mode\n"
1158 "Address Family Modifier\n")
1160 vty
->node
= BGP_IPV4M_NODE
;
1164 DEFUNSH (VTYSH_BGPD
,
1165 address_family_ipv6
,
1166 address_family_ipv6_cmd
,
1167 "address-family ipv6 [unicast]",
1168 "Enter Address Family command mode\n"
1170 "Address Family Modifier\n")
1172 vty
->node
= BGP_IPV6_NODE
;
1176 DEFUNSH (VTYSH_BGPD
,
1177 address_family_ipv6_multicast
,
1178 address_family_ipv6_multicast_cmd
,
1179 "address-family ipv6 multicast",
1180 "Enter Address Family command mode\n"
1182 "Address Family Modifier\n")
1184 vty
->node
= BGP_IPV6M_NODE
;
1188 #if defined (ENABLE_BGP_VNC)
1189 DEFUNSH (VTYSH_BGPD
,
1193 "VNC/RFP related configuration\n"
1194 "Configure default NVE group\n")
1196 vty
->node
= BGP_VNC_DEFAULTS_NODE
;
1200 DEFUNSH (VTYSH_BGPD
,
1203 "vnc nve-group NAME",
1204 "VNC/RFP related configuration\n"
1205 "Configure a NVE group\n"
1208 vty
->node
= BGP_VNC_NVE_GROUP_NODE
;
1212 DEFUNSH (VTYSH_BGPD
,
1215 "vnc l2-group NAME",
1216 "VNC/RFP related configuration\n"
1217 "Configure a L2 group\n"
1220 vty
->node
= BGP_VNC_L2_GROUP_NODE
;
1225 DEFUNSH (VTYSH_RIPD
,
1229 "Authentication key management\n"
1230 "Key-chain management\n"
1233 vty
->node
= KEYCHAIN_NODE
;
1237 DEFUNSH (VTYSH_RIPD
,
1240 "key (0-2147483647)",
1242 "Key identifier number\n")
1244 vty
->node
= KEYCHAIN_KEY_NODE
;
1248 DEFUNSH (VTYSH_RIPD
,
1255 vty
->node
= RIP_NODE
;
1259 DEFUNSH (VTYSH_RIPNGD
,
1266 vty
->node
= RIPNG_NODE
;
1270 DEFUNSH (VTYSH_OSPFD
,
1273 "router ospf [(1-65535)]",
1274 "Enable a routing process\n"
1275 "Start OSPF configuration\n"
1278 vty
->node
= OSPF_NODE
;
1282 DEFUNSH (VTYSH_OSPF6D
,
1289 vty
->node
= OSPF6_NODE
;
1293 #if defined (HAVE_LDPD)
1294 DEFUNSH (VTYSH_LDPD
,
1298 "Global MPLS configuration subcommands\n"
1299 "Label Distribution Protocol\n")
1301 vty
->node
= LDP_NODE
;
1305 DEFUNSH (VTYSH_LDPD
,
1306 ldp_address_family_ipv4
,
1307 ldp_address_family_ipv4_cmd
,
1308 "address-family ipv4",
1309 "Configure Address Family and its parameters\n"
1312 vty
->node
= LDP_IPV4_NODE
;
1316 DEFUNSH (VTYSH_LDPD
,
1317 ldp_address_family_ipv6
,
1318 ldp_address_family_ipv6_cmd
,
1319 "address-family ipv6",
1320 "Configure Address Family and its parameters\n"
1323 vty
->node
= LDP_IPV6_NODE
;
1327 DEFUNSH (VTYSH_LDPD
,
1328 ldp_interface_ifname
,
1329 ldp_interface_ifname_cmd
,
1331 "Enable LDP on an interface and enter interface submode\n"
1332 "Interface's name\n")
1337 vty
->node
= LDP_IPV4_IFACE_NODE
;
1340 vty
->node
= LDP_IPV6_IFACE_NODE
;
1349 DEFUNSH (VTYSH_LDPD
,
1350 ldp_l2vpn_word_type_vpls
,
1351 ldp_l2vpn_word_type_vpls_cmd
,
1352 "l2vpn WORD type vpls",
1353 "Configure l2vpn commands\n"
1356 "Virtual Private LAN Service\n")
1358 vty
->node
= LDP_L2VPN_NODE
;
1362 DEFUNSH (VTYSH_LDPD
,
1363 ldp_member_pseudowire_ifname
,
1364 ldp_member_pseudowire_ifname_cmd
,
1365 "member pseudowire IFNAME",
1366 "L2VPN member configuration\n"
1367 "Pseudowire interface\n"
1368 "Interface's name\n")
1370 vty
->node
= LDP_PSEUDOWIRE_NODE
;
1375 DEFUNSH (VTYSH_ISISD
,
1381 "ISO Routing area tag")
1383 vty
->node
= ISIS_NODE
;
1387 DEFUNSH (VTYSH_RMAP
,
1389 vtysh_route_map_cmd
,
1390 "route-map WORD <deny|permit> (1-65535)",
1391 "Create route-map or enter route-map command mode\n"
1393 "Route map denies set operations\n"
1394 "Route map permits set operations\n"
1395 "Sequence to insert to/delete from existing route-map entry\n")
1397 vty
->node
= RMAP_NODE
;
1405 "Configure a terminal line\n"
1406 "Virtual terminal\n")
1408 vty
->node
= VTY_NODE
;
1412 DEFUNSH (VTYSH_REALLYALL
,
1416 "Turn on privileged mode command\n")
1418 vty
->node
= ENABLE_NODE
;
1422 DEFUNSH (VTYSH_REALLYALL
,
1426 "Turn off privileged mode command\n")
1428 if (vty
->node
== ENABLE_NODE
)
1429 vty
->node
= VIEW_NODE
;
1433 DEFUNSH (VTYSH_REALLYALL
,
1434 vtysh_config_terminal
,
1435 vtysh_config_terminal_cmd
,
1436 "configure terminal",
1437 "Configuration from vty interface\n"
1438 "Configuration terminal\n")
1440 vty
->node
= CONFIG_NODE
;
1445 vtysh_exit (struct vty
*vty
)
1454 vty
->node
= ENABLE_NODE
;
1456 case INTERFACE_NODE
:
1466 case LDP_L2VPN_NODE
:
1472 vtysh_execute("end");
1473 vtysh_execute("configure terminal");
1474 vty
->node
= CONFIG_NODE
;
1476 case BGP_VPNV4_NODE
:
1477 case BGP_VPNV6_NODE
:
1478 case BGP_ENCAP_NODE
:
1479 case BGP_ENCAPV6_NODE
:
1481 case BGP_IPV4M_NODE
:
1483 case BGP_IPV6M_NODE
:
1484 case BGP_VNC_DEFAULTS_NODE
:
1485 case BGP_VNC_NVE_GROUP_NODE
:
1486 case BGP_VNC_L2_GROUP_NODE
:
1487 vty
->node
= BGP_NODE
;
1491 vty
->node
= LDP_NODE
;
1493 case LDP_IPV4_IFACE_NODE
:
1494 vty
->node
= LDP_IPV4_NODE
;
1496 case LDP_IPV6_IFACE_NODE
:
1497 vty
->node
= LDP_IPV6_NODE
;
1499 case LDP_PSEUDOWIRE_NODE
:
1500 vty
->node
= LDP_L2VPN_NODE
;
1502 case KEYCHAIN_KEY_NODE
:
1503 vty
->node
= KEYCHAIN_NODE
;
1505 case LINK_PARAMS_NODE
:
1506 vty
->node
= INTERFACE_NODE
;
1514 DEFUNSH (VTYSH_REALLYALL
,
1518 "Exit current mode and down to previous mode\n")
1520 return vtysh_exit (vty
);
1527 "Exit current mode and down to previous mode\n")
1529 return vtysh_exit_all (self
, vty
, argc
, argv
);
1532 DEFUNSH (VTYSH_BGPD
,
1533 exit_address_family
,
1534 exit_address_family_cmd
,
1535 "exit-address-family",
1536 "Exit from Address Family configuration mode\n")
1538 if (vty
->node
== BGP_IPV4_NODE
1539 || vty
->node
== BGP_IPV4M_NODE
1540 || vty
->node
== BGP_VPNV4_NODE
1541 || vty
->node
== BGP_VPNV6_NODE
1542 || vty
->node
== BGP_ENCAP_NODE
1543 || vty
->node
== BGP_ENCAPV6_NODE
1544 || vty
->node
== BGP_IPV6_NODE
1545 || vty
->node
== BGP_IPV6M_NODE
)
1546 vty
->node
= BGP_NODE
;
1550 DEFUNSH (VTYSH_BGPD
,
1552 exit_vnc_config_cmd
,
1554 "Exit from VNC configuration mode\n")
1556 if (vty
->node
== BGP_VNC_DEFAULTS_NODE
1557 || vty
->node
== BGP_VNC_NVE_GROUP_NODE
1558 || vty
->node
== BGP_VNC_L2_GROUP_NODE
)
1559 vty
->node
= BGP_NODE
;
1563 DEFUNSH (VTYSH_RIPD
,
1565 vtysh_exit_ripd_cmd
,
1567 "Exit current mode and down to previous mode\n")
1569 return vtysh_exit (vty
);
1572 DEFUNSH (VTYSH_RIPD
,
1574 vtysh_quit_ripd_cmd
,
1576 "Exit current mode and down to previous mode\n")
1578 return vtysh_exit_ripd (self
, vty
, argc
, argv
);
1581 DEFUNSH (VTYSH_RIPNGD
,
1583 vtysh_exit_ripngd_cmd
,
1585 "Exit current mode and down to previous mode\n")
1587 return vtysh_exit (vty
);
1590 DEFUNSH (VTYSH_RIPNGD
,
1592 vtysh_quit_ripngd_cmd
,
1594 "Exit current mode and down to previous mode\n")
1596 return vtysh_exit_ripngd (self
, vty
, argc
, argv
);
1599 DEFUNSH (VTYSH_RMAP
,
1601 vtysh_exit_rmap_cmd
,
1603 "Exit current mode and down to previous mode\n")
1605 return vtysh_exit (vty
);
1608 DEFUNSH (VTYSH_RMAP
,
1610 vtysh_quit_rmap_cmd
,
1612 "Exit current mode and down to previous mode\n")
1614 return vtysh_exit_rmap (self
, vty
, argc
, argv
);
1617 DEFUNSH (VTYSH_BGPD
,
1619 vtysh_exit_bgpd_cmd
,
1621 "Exit current mode and down to previous mode\n")
1623 return vtysh_exit (vty
);
1626 DEFUNSH (VTYSH_BGPD
,
1628 vtysh_quit_bgpd_cmd
,
1630 "Exit current mode and down to previous mode\n")
1632 return vtysh_exit_bgpd (self
, vty
, argc
, argv
);
1635 DEFUNSH (VTYSH_OSPFD
,
1637 vtysh_exit_ospfd_cmd
,
1639 "Exit current mode and down to previous mode\n")
1641 return vtysh_exit (vty
);
1644 DEFUNSH (VTYSH_OSPFD
,
1646 vtysh_quit_ospfd_cmd
,
1648 "Exit current mode and down to previous mode\n")
1650 return vtysh_exit_ospfd (self
, vty
, argc
, argv
);
1653 DEFUNSH (VTYSH_OSPF6D
,
1655 vtysh_exit_ospf6d_cmd
,
1657 "Exit current mode and down to previous mode\n")
1659 return vtysh_exit (vty
);
1662 DEFUNSH (VTYSH_OSPF6D
,
1664 vtysh_quit_ospf6d_cmd
,
1666 "Exit current mode and down to previous mode\n")
1668 return vtysh_exit_ospf6d (self
, vty
, argc
, argv
);
1671 #if defined (HAVE_LDPD)
1672 DEFUNSH (VTYSH_LDPD
,
1674 vtysh_exit_ldpd_cmd
,
1676 "Exit current mode and down to previous mode\n")
1678 return vtysh_exit (vty
);
1681 ALIAS (vtysh_exit_ldpd
,
1682 vtysh_quit_ldpd_cmd
,
1684 "Exit current mode and down to previous mode\n")
1687 DEFUNSH (VTYSH_ISISD
,
1689 vtysh_exit_isisd_cmd
,
1691 "Exit current mode and down to previous mode\n")
1693 return vtysh_exit (vty
);
1696 DEFUNSH (VTYSH_ISISD
,
1698 vtysh_quit_isisd_cmd
,
1700 "Exit current mode and down to previous mode\n")
1702 return vtysh_exit_isisd (self
, vty
, argc
, argv
);
1706 vtysh_exit_line_vty
,
1707 vtysh_exit_line_vty_cmd
,
1709 "Exit current mode and down to previous mode\n")
1711 return vtysh_exit (vty
);
1715 vtysh_quit_line_vty
,
1716 vtysh_quit_line_vty_cmd
,
1718 "Exit current mode and down to previous mode\n")
1720 return vtysh_exit_line_vty (self
, vty
, argc
, argv
);
1723 DEFUNSH (VTYSH_INTERFACE
,
1725 vtysh_interface_cmd
,
1726 "interface IFNAME [vrf NAME]",
1727 "Select an interface to configure\n"
1728 "Interface's name\n"
1731 vty
->node
= INTERFACE_NODE
;
1735 /* TODO Implement "no interface command in isisd. */
1736 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_RIPNGD
|VTYSH_OSPFD
|VTYSH_OSPF6D
|VTYSH_LDPD
,
1737 vtysh_no_interface_cmd
,
1738 "no interface IFNAME",
1740 "Delete a pseudo interface's configuration\n"
1741 "Interface's name\n")
1744 vtysh_no_interface_vrf_cmd
,
1745 "no interface IFNAME vrf NAME",
1747 "Delete a pseudo interface's configuration\n"
1748 "Interface's name\n"
1754 "logical-router (1-65535) ns NAME",
1755 "Enable a logical-router\n"
1756 "Specify the logical-router indentifier\n"
1758 "The file name in " NS_RUN_DIR
", or a full pathname\n")
1760 vty
->node
= NS_NODE
;
1768 "Select a VRF to configure\n"
1771 vty
->node
= VRF_NODE
;
1779 "Delete a pseudo vrf's configuration\n"
1786 "Exit current mode and down to previous mode\n")
1788 return vtysh_exit (vty
);
1795 "Exit current mode and down to previous mode\n")
1797 return vtysh_exit_ns(self
, vty
, argc
, argv
);
1804 "Exit current mode and down to previous mode\n")
1806 return vtysh_exit (vty
);
1813 "Exit current mode and down to previous mode\n")
1815 return vtysh_exit_vrf (self
, vty
, argc
, argv
);
1818 /* TODO Implement interface description commands in ripngd, ospf6d
1820 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
|VTYSH_LDPD
,
1821 vtysh_interface_desc_cmd
,
1822 "description LINE...",
1823 "Interface specific description\n"
1824 "Characters describing this interface\n")
1826 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1827 vtysh_no_interface_desc_cmd
,
1830 "Interface specific description\n")
1832 DEFUNSH (VTYSH_INTERFACE
,
1833 vtysh_exit_interface
,
1834 vtysh_exit_interface_cmd
,
1836 "Exit current mode and down to previous mode\n")
1838 return vtysh_exit (vty
);
1841 DEFUNSH (VTYSH_INTERFACE
,
1842 vtysh_quit_interface
,
1843 vtysh_quit_interface_cmd
,
1845 "Exit current mode and down to previous mode\n")
1847 return vtysh_exit_interface (self
, vty
, argc
, argv
);
1850 DEFUN (vtysh_show_thread
,
1851 vtysh_show_thread_cmd
,
1852 "show thread cpu [FILTER]",
1854 "Thread information\n"
1855 "Thread CPU usage\n"
1856 "Display filter (rwtexb)\n")
1860 int ret
= CMD_SUCCESS
;
1863 sprintf(line
, "show thread cpu %s\n", (argc
== 4) ? argv
[idx_filter
]->arg
: "");
1864 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1865 if ( vtysh_client
[i
].fd
>= 0 )
1867 fprintf (stdout
, "Thread statistics for %s:\n",
1868 vtysh_client
[i
].name
);
1869 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1870 fprintf (stdout
,"\n");
1875 DEFUN (vtysh_show_work_queues
,
1876 vtysh_show_work_queues_cmd
,
1879 "Work Queue information\n")
1882 int ret
= CMD_SUCCESS
;
1883 char line
[] = "show work-queues\n";
1885 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1886 if ( vtysh_client
[i
].fd
>= 0 )
1888 fprintf (stdout
, "Work queue statistics for %s:\n",
1889 vtysh_client
[i
].name
);
1890 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1891 fprintf (stdout
,"\n");
1897 DEFUN (vtysh_show_work_queues_daemon
,
1898 vtysh_show_work_queues_daemon_cmd
,
1899 "show work-queues <zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd>",
1901 "Work Queue information\n"
1902 "For the zebra daemon\n"
1903 "For the rip daemon\n"
1904 "For the ripng daemon\n"
1905 "For the ospf daemon\n"
1906 "For the ospfv6 daemon\n"
1907 "For the bgp daemon\n"
1908 "For the isis daemon\n")
1910 int idx_protocol
= 2;
1912 int ret
= CMD_SUCCESS
;
1914 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1916 if (strmatch(vtysh_client
[i
].name
, argv
[idx_protocol
]->text
))
1920 ret
= vtysh_client_execute(&vtysh_client
[i
], "show work-queues\n", stdout
);
1925 DEFUNSH (VTYSH_ZEBRA
,
1927 vtysh_link_params_cmd
,
1932 vty
->node
= LINK_PARAMS_NODE
;
1936 DEFUNSH (VTYSH_ZEBRA
,
1938 exit_link_params_cmd
,
1940 "Exit from Link Params configuration node\n")
1942 if (vty
->node
== LINK_PARAMS_NODE
)
1943 vty
->node
= INTERFACE_NODE
;
1948 DEFUN (vtysh_show_memory
,
1949 vtysh_show_memory_cmd
,
1952 "Memory statistics\n")
1955 int ret
= CMD_SUCCESS
;
1956 char line
[] = "show memory\n";
1958 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1959 if ( vtysh_client
[i
].fd
>= 0 )
1961 fprintf (stdout
, "Memory statistics for %s:\n",
1962 vtysh_client
[i
].name
);
1963 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1964 fprintf (stdout
,"\n");
1970 /* Logging commands. */
1971 DEFUN (vtysh_show_logging
,
1972 vtysh_show_logging_cmd
,
1975 "Show current logging configuration\n")
1978 int ret
= CMD_SUCCESS
;
1979 char line
[] = "show logging\n";
1981 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1982 if ( vtysh_client
[i
].fd
>= 0 )
1984 fprintf (stdout
,"Logging configuration for %s:\n",
1985 vtysh_client
[i
].name
);
1986 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1987 fprintf (stdout
,"\n");
1995 vtysh_log_stdout_cmd
,
1998 "Set stdout logging level\n")
2004 vtysh_log_stdout_level
,
2005 vtysh_log_stdout_level_cmd
,
2006 "log stdout <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2008 "Set stdout logging level\n"
2015 no_vtysh_log_stdout
,
2016 no_vtysh_log_stdout_cmd
,
2017 "no log stdout [LEVEL]",
2020 "Cancel logging to stdout\n"
2029 "log file FILENAME",
2032 "Logging filename\n")
2038 vtysh_log_file_level
,
2039 vtysh_log_file_level_cmd
,
2040 "log file FILENAME <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2043 "Logging filename\n"
2051 no_vtysh_log_file_cmd
,
2052 "no log file [FILENAME [LEVEL]]",
2055 "Cancel logging to file\n"
2056 "Logging file name\n"
2064 vtysh_log_monitor_cmd
,
2065 "log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
2067 "Set terminal line (monitor) logging level\n"
2074 no_vtysh_log_monitor
,
2075 no_vtysh_log_monitor_cmd
,
2076 "no log monitor [LEVEL]",
2079 "Disable terminal line (monitor) logging\n"
2087 vtysh_log_syslog_cmd
,
2088 "log syslog <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2090 "Set syslog logging level\n"
2097 no_vtysh_log_syslog
,
2098 no_vtysh_log_syslog_cmd
,
2099 "no log syslog [LEVEL]",
2102 "Cancel logging to syslog\n"
2110 vtysh_log_facility_cmd
,
2111 "log facility <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>",
2113 "Facility parameter for syslog messages\n"
2121 no_vtysh_log_facility
,
2122 no_vtysh_log_facility_cmd
,
2123 "no log facility [FACILITY]",
2126 "Reset syslog facility to default (daemon)\n"
2127 "Syslog facility\n")
2133 DEFUNSH_DEPRECATED (VTYSH_ALL
,
2136 "log trap <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2138 "(Deprecated) Set logging level and default for all destinations\n"
2145 DEFUNSH_DEPRECATED (VTYSH_ALL
,
2147 no_vtysh_log_trap_cmd
,
2148 "no log trap [LEVEL]",
2151 "Permit all logging information\n"
2158 vtysh_log_record_priority
,
2159 vtysh_log_record_priority_cmd
,
2160 "log record-priority",
2162 "Log the priority of the message within the message\n")
2168 no_vtysh_log_record_priority
,
2169 no_vtysh_log_record_priority_cmd
,
2170 "no log record-priority",
2173 "Do not log the priority of the message within the message\n")
2179 vtysh_log_timestamp_precision
,
2180 vtysh_log_timestamp_precision_cmd
,
2181 "log timestamp precision (0-6)",
2183 "Timestamp configuration\n"
2184 "Set the timestamp precision\n"
2185 "Number of subsecond digits\n")
2191 no_vtysh_log_timestamp_precision
,
2192 no_vtysh_log_timestamp_precision_cmd
,
2193 "no log timestamp precision",
2196 "Timestamp configuration\n"
2197 "Reset the timestamp precision to the default value of 0\n")
2203 vtysh_service_password_encrypt
,
2204 vtysh_service_password_encrypt_cmd
,
2205 "service password-encryption",
2206 "Set up miscellaneous service\n"
2207 "Enable encrypted passwords\n")
2213 no_vtysh_service_password_encrypt
,
2214 no_vtysh_service_password_encrypt_cmd
,
2215 "no service password-encryption",
2217 "Set up miscellaneous service\n"
2218 "Enable encrypted passwords\n")
2224 vtysh_config_password
,
2226 "password (8-8) WORD",
2227 "Assign the terminal connection password\n"
2228 "Specifies a HIDDEN password will follow\n"
2230 "The HIDDEN line password string\n")
2236 vtysh_password_text
,
2237 vtysh_password_text_cmd
,
2239 "Assign the terminal connection password\n"
2240 "The UNENCRYPTED (cleartext) line password\n")
2246 vtysh_config_enable_password
,
2247 vtysh_enable_password_cmd
,
2248 "enable password (8-8) WORD",
2249 "Modify enable password parameters\n"
2250 "Assign the privileged level password\n"
2251 "Specifies a HIDDEN password will follow\n"
2252 "The HIDDEN 'enable' password string\n")
2258 vtysh_enable_password_text
,
2259 vtysh_enable_password_text_cmd
,
2260 "enable password LINE",
2261 "Modify enable password parameters\n"
2262 "Assign the privileged level password\n"
2263 "The UNENCRYPTED (cleartext) 'enable' password\n")
2269 no_vtysh_config_enable_password
,
2270 no_vtysh_enable_password_cmd
,
2271 "no enable password",
2273 "Modify enable password parameters\n"
2274 "Assign the privileged level password\n")
2279 DEFUN (vtysh_write_terminal
,
2280 vtysh_write_terminal_cmd
,
2281 "write terminal [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2282 "Write running configuration to memory, network, or terminal\n"
2283 "Write to terminal\n"
2284 "For the zebra daemon\n"
2285 "For the rip daemon\n"
2286 "For the ripng daemon\n"
2287 "For the ospf daemon\n"
2288 "For the ospfv6 daemon\n"
2289 "For the ldpd daemon\n"
2290 "For the bgp daemon\n"
2291 "For the isis daemon\n"
2292 "For the pim daemon\n")
2295 char line
[] = "write terminal\n";
2298 if (vtysh_pager_name
)
2300 fp
= popen (vtysh_pager_name
, "w");
2310 vty_out (vty
, "Building configuration...%s", VTY_NEWLINE
);
2311 vty_out (vty
, "%sCurrent configuration:%s", VTY_NEWLINE
,
2313 vty_out (vty
, "!%s", VTY_NEWLINE
);
2315 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2316 if ((argc
< 3 ) || (strmatch (vtysh_client
[i
].name
, argv
[2]->text
)))
2317 vtysh_client_config (&vtysh_client
[i
], line
);
2319 /* Integrate vtysh specific configuration. */
2320 vtysh_config_write ();
2322 vtysh_config_dump (fp
);
2324 if (vtysh_pager_name
&& fp
)
2327 if (pclose (fp
) == -1)
2335 vty_out (vty
, "end%s", VTY_NEWLINE
);
2339 DEFUN (vtysh_show_running_config
,
2340 vtysh_show_running_config_cmd
,
2341 "show running-config [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2343 "Current operating configuration\n"
2344 "For the zebra daemon\n"
2345 "For the rip daemon\n"
2346 "For the ripng daemon\n"
2347 "For the ospf daemon\n"
2348 "For the ospfv6 daemon\n"
2349 "For the ldp daemon\n"
2350 "For the bgp daemon\n"
2351 "For the isis daemon\n"
2352 "For the pim daemon\n")
2354 return vtysh_write_terminal (self
, vty
, argc
, argv
);
2357 DEFUN (vtysh_integrated_config
,
2358 vtysh_integrated_config_cmd
,
2359 "service integrated-vtysh-config",
2360 "Set up miscellaneous service\n"
2361 "Write configuration into integrated file\n")
2363 vtysh_write_integrated
= WRITE_INTEGRATED_YES
;
2367 DEFUN (no_vtysh_integrated_config
,
2368 no_vtysh_integrated_config_cmd
,
2369 "no service integrated-vtysh-config",
2371 "Set up miscellaneous service\n"
2372 "Write configuration into integrated file\n")
2374 vtysh_write_integrated
= WRITE_INTEGRATED_NO
;
2379 backup_config_file (const char *fbackup
)
2381 char *integrate_sav
= NULL
;
2383 integrate_sav
= malloc (strlen (fbackup
) +
2384 strlen (CONF_BACKUP_EXT
) + 1);
2385 strcpy (integrate_sav
, fbackup
);
2386 strcat (integrate_sav
, CONF_BACKUP_EXT
);
2388 /* Move current configuration file to backup config file. */
2389 unlink (integrate_sav
);
2390 rename (fbackup
, integrate_sav
);
2391 free (integrate_sav
);
2395 vtysh_write_config_integrated(void)
2398 char line
[] = "write terminal\n";
2401 struct passwd
*pwentry
;
2402 struct group
*grentry
;
2408 fprintf (stdout
,"Building Configuration...\n");
2410 backup_config_file(quagga_config
);
2411 fp
= fopen (quagga_config
, "w");
2414 fprintf (stdout
,"%% Error: failed to open configuration file %s: %s\n",
2415 quagga_config
, safe_strerror(errno
));
2420 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2421 vtysh_client_config (&vtysh_client
[i
], line
);
2423 vtysh_config_write ();
2424 vtysh_config_dump (fp
);
2426 if (fchmod (fd
, CONFIGFILE_MASK
) != 0)
2428 printf ("%% Warning: can't chmod configuration file %s: %s\n",
2429 quagga_config
, safe_strerror(errno
));
2433 pwentry
= getpwnam (FRR_USER
);
2435 uid
= pwentry
->pw_uid
;
2438 printf ("%% Warning: could not look up user \"%s\"\n", FRR_USER
);
2442 grentry
= getgrnam (FRR_GROUP
);
2444 gid
= grentry
->gr_gid
;
2447 printf ("%% Warning: could not look up group \"%s\"\n", FRR_GROUP
);
2451 if (!fstat (fd
, &st
))
2453 if (st
.st_uid
== uid
)
2455 if (st
.st_gid
== gid
)
2457 if ((uid
!= (uid_t
)-1 || gid
!= (gid_t
)-1) && fchown (fd
, uid
, gid
))
2459 printf ("%% Warning: can't chown configuration file %s: %s\n",
2460 quagga_config
, safe_strerror(errno
));
2466 printf ("%% Warning: stat() failed on %s: %s\n",
2467 quagga_config
, safe_strerror(errno
));
2473 printf ("Integrated configuration saved to %s\n", quagga_config
);
2481 static bool want_config_integrated(void)
2485 switch (vtysh_write_integrated
)
2487 case WRITE_INTEGRATED_UNSPECIFIED
:
2488 if (stat(quagga_config
, &s
) && errno
== ENOENT
)
2491 case WRITE_INTEGRATED_NO
:
2493 case WRITE_INTEGRATED_YES
:
2499 DEFUN (vtysh_write_memory
,
2500 vtysh_write_memory_cmd
,
2501 "write [<memory|file>]",
2502 "Write running configuration to memory, network, or terminal\n"
2503 "Write configuration to the file (same as write file)\n"
2504 "Write configuration to the file (same as write memory)\n")
2506 int ret
= CMD_SUCCESS
;
2507 char line
[] = "write memory\n";
2510 fprintf (stdout
, "Note: this version of vtysh never writes vtysh.conf\n");
2512 /* If integrated Quagga.conf explicitely set. */
2513 if (want_config_integrated())
2516 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2517 if (vtysh_client
[i
].flag
== VTYSH_WATCHFRR
)
2519 if (i
< array_size(vtysh_client
) && vtysh_client
[i
].fd
!= -1)
2520 ret
= vtysh_client_execute (&vtysh_client
[i
], "write integrated", stdout
);
2522 if (ret
!= CMD_SUCCESS
)
2524 printf("\nWarning: attempting direct configuration write without "
2525 "watchfrr.\nFile permissions and ownership may be "
2526 "incorrect, or write may fail.\n\n");
2527 ret
= vtysh_write_config_integrated();
2532 fprintf (stdout
,"Building Configuration...\n");
2534 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2535 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2540 DEFUN (vtysh_copy_running_config
,
2541 vtysh_copy_running_config_cmd
,
2542 "copy running-config startup-config",
2543 "Copy from one file to another\n"
2544 "Copy from current system configuration\n"
2545 "Copy to startup configuration\n")
2547 return vtysh_write_memory (self
, vty
, argc
, argv
);
2550 DEFUN (vtysh_terminal_length
,
2551 vtysh_terminal_length_cmd
,
2552 "terminal length (0-512)",
2553 "Set terminal line parameters\n"
2554 "Set number of lines on a screen\n"
2555 "Number of lines on screen (0 for no pausing)\n")
2559 char *endptr
= NULL
;
2560 char default_pager
[10];
2562 lines
= strtol (argv
[idx_number
]->arg
, &endptr
, 10);
2563 if (lines
< 0 || lines
> 512 || *endptr
!= '\0')
2565 vty_out (vty
, "length is malformed%s", VTY_NEWLINE
);
2569 if (vtysh_pager_name
)
2571 free (vtysh_pager_name
);
2572 vtysh_pager_name
= NULL
;
2577 snprintf(default_pager
, 10, "more -%i", lines
);
2578 vtysh_pager_name
= strdup (default_pager
);
2584 DEFUN (vtysh_terminal_no_length
,
2585 vtysh_terminal_no_length_cmd
,
2586 "terminal no length",
2587 "Set terminal line parameters\n"
2589 "Set number of lines on a screen\n")
2591 if (vtysh_pager_name
)
2593 free (vtysh_pager_name
);
2594 vtysh_pager_name
= NULL
;
2601 DEFUN (vtysh_show_daemons
,
2602 vtysh_show_daemons_cmd
,
2605 "Show list of running daemons\n")
2609 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2610 if ( vtysh_client
[i
].fd
>= 0 )
2611 vty_out(vty
, " %s", vtysh_client
[i
].name
);
2612 vty_out(vty
, "%s", VTY_NEWLINE
);
2617 /* Execute command in child process. */
2619 execute_command (const char *command
, int argc
, struct cmd_token
*arg1
,
2630 /* Failure of fork(). */
2631 fprintf (stderr
, "Can't fork: %s\n", safe_strerror (errno
));
2636 /* This is child process. */
2640 execlp (command
, command
, (const char *)NULL
);
2643 execlp (command
, command
, arg1
, (const char *)NULL
);
2646 execlp (command
, command
, arg1
, arg2
, (const char *)NULL
);
2650 /* When execlp suceed, this part is not executed. */
2651 fprintf (stderr
, "Can't execute %s: %s\n", command
, safe_strerror (errno
));
2656 /* This is parent. */
2658 wait4 (pid
, &status
, 0, NULL
);
2666 "Send echo messages\n"
2667 "Ping destination address or hostname\n")
2669 execute_command ("ping", 1, argv
[0], NULL
);
2676 "Send echo messages\n"
2678 "Ping destination address or hostname\n")
2680 DEFUN (vtysh_traceroute
,
2681 vtysh_traceroute_cmd
,
2683 "Trace route to destination\n"
2684 "Trace route to destination address or hostname\n")
2686 execute_command ("traceroute", 1, argv
[0], NULL
);
2690 ALIAS (vtysh_traceroute
,
2691 vtysh_traceroute_ip_cmd
,
2692 "traceroute ip WORD",
2693 "Trace route to destination\n"
2695 "Trace route to destination address or hostname\n")
2700 "Send echo messages\n"
2702 "Ping destination address or hostname\n")
2704 execute_command ("ping6", 1, argv
[0], NULL
);
2708 DEFUN (vtysh_traceroute6
,
2709 vtysh_traceroute6_cmd
,
2710 "traceroute ipv6 WORD",
2711 "Trace route to destination\n"
2713 "Trace route to destination address or hostname\n")
2715 execute_command ("traceroute6", 1, argv
[0], NULL
);
2719 #if defined(HAVE_SHELL_ACCESS)
2720 DEFUN (vtysh_telnet
,
2723 "Open a telnet connection\n"
2724 "IP address or hostname of a remote system\n")
2726 execute_command ("telnet", 1, argv
[0], NULL
);
2730 DEFUN (vtysh_telnet_port
,
2731 vtysh_telnet_port_cmd
,
2733 "Open a telnet connection\n"
2734 "IP address or hostname of a remote system\n"
2735 "TCP Port number\n")
2737 execute_command ("telnet", 2, argv
[0], argv
[1]);
2744 "Open an ssh connection\n"
2747 execute_command ("ssh", 1, argv
[0], NULL
);
2751 DEFUN (vtysh_start_shell
,
2752 vtysh_start_shell_cmd
,
2754 "Start UNIX shell\n")
2756 execute_command ("sh", 0, NULL
, NULL
);
2760 DEFUN (vtysh_start_bash
,
2761 vtysh_start_bash_cmd
,
2763 "Start UNIX shell\n"
2766 execute_command ("bash", 0, NULL
, NULL
);
2770 DEFUN (vtysh_start_zsh
,
2771 vtysh_start_zsh_cmd
,
2773 "Start UNIX shell\n"
2776 execute_command ("zsh", 0, NULL
, NULL
);
2783 "list [permutations]",
2784 "Print command list\n"
2785 "Print all possible command permutations\n")
2787 return cmd_list_cmds (vty
, argc
== 2);
2791 vtysh_install_default (enum node_type node
)
2793 install_element (node
, &config_list_cmd
);
2796 /* Making connection to protocol daemon. */
2798 vtysh_connect (struct vtysh_client
*vclient
)
2802 struct sockaddr_un addr
;
2805 /* Stat socket to see if we have permission to access it. */
2806 ret
= stat (vclient
->path
, &s_stat
);
2807 if (ret
< 0 && errno
!= ENOENT
)
2809 fprintf (stderr
, "vtysh_connect(%s): stat = %s\n",
2810 vclient
->path
, safe_strerror(errno
));
2816 if (! S_ISSOCK(s_stat
.st_mode
))
2818 fprintf (stderr
, "vtysh_connect(%s): Not a socket\n",
2825 sock
= socket (AF_UNIX
, SOCK_STREAM
, 0);
2829 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", vclient
->path
,
2830 safe_strerror(errno
));
2835 memset (&addr
, 0, sizeof (struct sockaddr_un
));
2836 addr
.sun_family
= AF_UNIX
;
2837 strncpy (addr
.sun_path
, vclient
->path
, strlen (vclient
->path
));
2838 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
2839 len
= addr
.sun_len
= SUN_LEN(&addr
);
2841 len
= sizeof (addr
.sun_family
) + strlen (addr
.sun_path
);
2842 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
2844 ret
= connect (sock
, (struct sockaddr
*) &addr
, len
);
2848 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", vclient
->path
,
2849 safe_strerror(errno
));
2859 /* Return true if str ends with suffix, else return false */
2861 ends_with(const char *str
, const char *suffix
)
2863 if (!str
|| !suffix
)
2865 size_t lenstr
= strlen(str
);
2866 size_t lensuffix
= strlen(suffix
);
2867 if (lensuffix
> lenstr
)
2869 return strncmp(str
+ lenstr
- lensuffix
, suffix
, lensuffix
) == 0;
2873 vtysh_client_sorted_insert (struct vtysh_client
*head_client
,
2874 struct vtysh_client
*client
)
2876 struct vtysh_client
*prev_node
, *current_node
;
2878 prev_node
= head_client
;
2879 current_node
= head_client
->next
;
2880 while (current_node
)
2882 if (strcmp(current_node
->path
, client
->path
) > 0)
2885 prev_node
= current_node
;
2886 current_node
= current_node
->next
;
2888 client
->next
= current_node
;
2889 prev_node
->next
= client
;
2892 #define MAXIMUM_INSTANCES 10
2895 vtysh_update_all_insances(struct vtysh_client
* head_client
)
2897 struct vtysh_client
*client
;
2900 struct dirent
*file
;
2903 if (head_client
->flag
!= VTYSH_OSPFD
) return;
2905 /* ls DAEMON_VTY_DIR and look for all files ending in .vty */
2906 dir
= opendir(DAEMON_VTY_DIR
"/");
2909 while ((file
= readdir(dir
)) != NULL
)
2911 if (begins_with(file
->d_name
, "ospfd-") && ends_with(file
->d_name
, ".vty"))
2913 if (n
== MAXIMUM_INSTANCES
)
2916 "Parsing %s/, client limit(%d) reached!\n",
2920 client
= (struct vtysh_client
*) malloc(sizeof(struct vtysh_client
));
2922 client
->name
= "ospfd";
2923 client
->flag
= VTYSH_OSPFD
;
2924 ptr
= (char *) malloc(100);
2925 sprintf(ptr
, "%s/%s", DAEMON_VTY_DIR
, file
->d_name
);
2926 client
->path
= (const char *)ptr
;
2927 client
->next
= NULL
;
2928 vtysh_client_sorted_insert(head_client
, client
);
2937 vtysh_connect_all_instances (struct vtysh_client
*head_client
)
2939 struct vtysh_client
*client
;
2942 vtysh_update_all_insances(head_client
);
2944 client
= head_client
->next
;
2947 if (vtysh_connect(client
) == 0)
2949 client
= client
->next
;
2956 vtysh_connect_all(const char *daemon_name
)
2962 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2964 if (!daemon_name
|| !strcmp(daemon_name
, vtysh_client
[i
].name
))
2967 if (vtysh_connect(&vtysh_client
[i
]) == 0)
2970 rc
+= vtysh_connect_all_instances(&vtysh_client
[i
]);
2974 fprintf(stderr
, "Error: no daemons match name %s!\n", daemon_name
);
2978 /* To disable readline's filename completion. */
2980 vtysh_completion_entry_function (const char *ignore
, int invoking_key
)
2986 vtysh_readline_init (void)
2988 /* readline related settings. */
2990 rl_bind_key ('?', (rl_command_func_t
*) vtysh_rl_describe
);
2991 rl_completion_entry_function
= vtysh_completion_entry_function
;
2992 rl_attempted_completion_function
= (rl_completion_func_t
*)new_completion
;
2998 static struct utsname names
;
2999 static char buf
[100];
3000 const char*hostname
;
3001 extern struct host host
;
3003 hostname
= host
.name
;
3007 if (!names
.nodename
[0])
3009 hostname
= names
.nodename
;
3012 snprintf (buf
, sizeof buf
, cmd_prompt (vty
->node
), hostname
);
3018 vtysh_init_vty (void)
3020 /* Make vty structure. */
3022 vty
->type
= VTY_SHELL
;
3023 vty
->node
= VIEW_NODE
;
3025 /* Initialize commands. */
3028 /* Install nodes. */
3029 install_node (&bgp_node
, NULL
);
3030 install_node (&rip_node
, NULL
);
3031 install_node (&interface_node
, NULL
);
3032 install_node (&link_params_node
, NULL
);
3033 install_node (&ns_node
, NULL
);
3034 install_node (&vrf_node
, NULL
);
3035 install_node (&rmap_node
, NULL
);
3036 install_node (&zebra_node
, NULL
);
3037 install_node (&bgp_vpnv4_node
, NULL
);
3038 install_node (&bgp_vpnv6_node
, NULL
);
3039 install_node (&bgp_encap_node
, NULL
);
3040 install_node (&bgp_encapv6_node
, NULL
);
3041 install_node (&bgp_ipv4_node
, NULL
);
3042 install_node (&bgp_ipv4m_node
, NULL
);
3043 install_node (&bgp_ipv6_node
, NULL
);
3044 install_node (&bgp_ipv6m_node
, NULL
);
3045 install_node (&bgp_vnc_defaults_node
, NULL
);
3046 install_node (&bgp_vnc_nve_group_node
, NULL
);
3047 install_node (&bgp_vnc_l2_group_node
, NULL
);
3048 install_node (&ospf_node
, NULL
);
3049 install_node (&ripng_node
, NULL
);
3050 install_node (&ospf6_node
, NULL
);
3051 install_node (&ldp_node
, NULL
);
3052 install_node (&ldp_ipv4_node
, NULL
);
3053 install_node (&ldp_ipv6_node
, NULL
);
3054 install_node (&ldp_ipv4_iface_node
, NULL
);
3055 install_node (&ldp_ipv6_iface_node
, NULL
);
3056 install_node (&ldp_l2vpn_node
, NULL
);
3057 install_node (&ldp_pseudowire_node
, NULL
);
3058 install_node (&keychain_node
, NULL
);
3059 install_node (&keychain_key_node
, NULL
);
3060 install_node (&isis_node
, NULL
);
3061 install_node (&vty_node
, NULL
);
3063 vtysh_install_default (VIEW_NODE
);
3064 vtysh_install_default (CONFIG_NODE
);
3065 vtysh_install_default (BGP_NODE
);
3066 vtysh_install_default (RIP_NODE
);
3067 vtysh_install_default (INTERFACE_NODE
);
3068 vtysh_install_default (LINK_PARAMS_NODE
);
3069 vtysh_install_default (NS_NODE
);
3070 vtysh_install_default (VRF_NODE
);
3071 vtysh_install_default (RMAP_NODE
);
3072 vtysh_install_default (ZEBRA_NODE
);
3073 vtysh_install_default (BGP_VPNV4_NODE
);
3074 vtysh_install_default (BGP_VPNV6_NODE
);
3075 vtysh_install_default (BGP_ENCAP_NODE
);
3076 vtysh_install_default (BGP_ENCAPV6_NODE
);
3077 vtysh_install_default (BGP_IPV4_NODE
);
3078 vtysh_install_default (BGP_IPV4M_NODE
);
3079 vtysh_install_default (BGP_IPV6_NODE
);
3080 vtysh_install_default (BGP_IPV6M_NODE
);
3082 vtysh_install_default (BGP_VNC_DEFAULTS_NODE
);
3083 vtysh_install_default (BGP_VNC_NVE_GROUP_NODE
);
3084 vtysh_install_default (BGP_VNC_L2_GROUP_NODE
);
3086 vtysh_install_default (OSPF_NODE
);
3087 vtysh_install_default (RIPNG_NODE
);
3088 vtysh_install_default (OSPF6_NODE
);
3089 vtysh_install_default (LDP_NODE
);
3090 vtysh_install_default (LDP_IPV4_NODE
);
3091 vtysh_install_default (LDP_IPV6_NODE
);
3092 vtysh_install_default (LDP_IPV4_IFACE_NODE
);
3093 vtysh_install_default (LDP_IPV6_IFACE_NODE
);
3094 vtysh_install_default (LDP_L2VPN_NODE
);
3095 vtysh_install_default (LDP_PSEUDOWIRE_NODE
);
3096 vtysh_install_default (ISIS_NODE
);
3097 vtysh_install_default (KEYCHAIN_NODE
);
3098 vtysh_install_default (KEYCHAIN_KEY_NODE
);
3099 vtysh_install_default (VTY_NODE
);
3101 install_element (VIEW_NODE
, &vtysh_enable_cmd
);
3102 install_element (ENABLE_NODE
, &vtysh_config_terminal_cmd
);
3103 install_element (ENABLE_NODE
, &vtysh_disable_cmd
);
3105 /* "exit" command. */
3106 install_element (VIEW_NODE
, &vtysh_exit_all_cmd
);
3107 install_element (CONFIG_NODE
, &vtysh_exit_all_cmd
);
3108 install_element (VIEW_NODE
, &vtysh_quit_all_cmd
);
3109 install_element (CONFIG_NODE
, &vtysh_quit_all_cmd
);
3110 install_element (RIP_NODE
, &vtysh_exit_ripd_cmd
);
3111 install_element (RIP_NODE
, &vtysh_quit_ripd_cmd
);
3112 install_element (RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
3113 install_element (RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
3114 install_element (OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
3115 install_element (OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
3116 install_element (OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
3117 install_element (OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
3118 #if defined (HAVE_LDPD)
3119 install_element (LDP_NODE
, &vtysh_exit_ldpd_cmd
);
3120 install_element (LDP_NODE
, &vtysh_quit_ldpd_cmd
);
3121 install_element (LDP_IPV4_NODE
, &vtysh_exit_ldpd_cmd
);
3122 install_element (LDP_IPV4_NODE
, &vtysh_quit_ldpd_cmd
);
3123 install_element (LDP_IPV6_NODE
, &vtysh_exit_ldpd_cmd
);
3124 install_element (LDP_IPV6_NODE
, &vtysh_quit_ldpd_cmd
);
3125 install_element (LDP_IPV4_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3126 install_element (LDP_IPV4_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3127 install_element (LDP_IPV6_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3128 install_element (LDP_IPV6_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3129 install_element (LDP_L2VPN_NODE
, &vtysh_exit_ldpd_cmd
);
3130 install_element (LDP_L2VPN_NODE
, &vtysh_quit_ldpd_cmd
);
3131 install_element (LDP_PSEUDOWIRE_NODE
, &vtysh_exit_ldpd_cmd
);
3132 install_element (LDP_PSEUDOWIRE_NODE
, &vtysh_quit_ldpd_cmd
);
3134 install_element (BGP_NODE
, &vtysh_exit_bgpd_cmd
);
3135 install_element (BGP_NODE
, &vtysh_quit_bgpd_cmd
);
3136 install_element (BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
3137 install_element (BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
3138 install_element (BGP_VPNV6_NODE
, &vtysh_exit_bgpd_cmd
);
3139 install_element (BGP_VPNV6_NODE
, &vtysh_quit_bgpd_cmd
);
3140 install_element (BGP_ENCAP_NODE
, &vtysh_exit_bgpd_cmd
);
3141 install_element (BGP_ENCAP_NODE
, &vtysh_quit_bgpd_cmd
);
3142 install_element (BGP_ENCAPV6_NODE
, &vtysh_exit_bgpd_cmd
);
3143 install_element (BGP_ENCAPV6_NODE
, &vtysh_quit_bgpd_cmd
);
3144 install_element (BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
3145 install_element (BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
3146 install_element (BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
3147 install_element (BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
3148 install_element (BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
3149 install_element (BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
3150 install_element (BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
3151 install_element (BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
3152 #if defined (ENABLE_BGP_VNC)
3153 install_element (BGP_VNC_DEFAULTS_NODE
, &vtysh_exit_bgpd_cmd
);
3154 install_element (BGP_VNC_DEFAULTS_NODE
, &vtysh_quit_bgpd_cmd
);
3155 install_element (BGP_VNC_NVE_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3156 install_element (BGP_VNC_NVE_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3157 install_element (BGP_VNC_L2_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3158 install_element (BGP_VNC_L2_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3160 install_element (ISIS_NODE
, &vtysh_exit_isisd_cmd
);
3161 install_element (ISIS_NODE
, &vtysh_quit_isisd_cmd
);
3162 install_element (KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
3163 install_element (KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
3164 install_element (KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
3165 install_element (KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
3166 install_element (RMAP_NODE
, &vtysh_exit_rmap_cmd
);
3167 install_element (RMAP_NODE
, &vtysh_quit_rmap_cmd
);
3168 install_element (VTY_NODE
, &vtysh_exit_line_vty_cmd
);
3169 install_element (VTY_NODE
, &vtysh_quit_line_vty_cmd
);
3171 /* "end" command. */
3172 install_element (CONFIG_NODE
, &vtysh_end_all_cmd
);
3173 install_element (ENABLE_NODE
, &vtysh_end_all_cmd
);
3174 install_element (RIP_NODE
, &vtysh_end_all_cmd
);
3175 install_element (RIPNG_NODE
, &vtysh_end_all_cmd
);
3176 install_element (OSPF_NODE
, &vtysh_end_all_cmd
);
3177 install_element (OSPF6_NODE
, &vtysh_end_all_cmd
);
3178 install_element (LDP_NODE
, &vtysh_end_all_cmd
);
3179 install_element (LDP_IPV4_NODE
, &vtysh_end_all_cmd
);
3180 install_element (LDP_IPV6_NODE
, &vtysh_end_all_cmd
);
3181 install_element (LDP_IPV4_IFACE_NODE
, &vtysh_end_all_cmd
);
3182 install_element (LDP_IPV6_IFACE_NODE
, &vtysh_end_all_cmd
);
3183 install_element (LDP_L2VPN_NODE
, &vtysh_end_all_cmd
);
3184 install_element (LDP_PSEUDOWIRE_NODE
, &vtysh_end_all_cmd
);
3185 install_element (BGP_NODE
, &vtysh_end_all_cmd
);
3186 install_element (BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
3187 install_element (BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
3188 install_element (BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
3189 install_element (BGP_VPNV6_NODE
, &vtysh_end_all_cmd
);
3190 install_element (BGP_ENCAP_NODE
, &vtysh_end_all_cmd
);
3191 install_element (BGP_ENCAPV6_NODE
, &vtysh_end_all_cmd
);
3192 install_element (BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
3193 install_element (BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
3194 install_element (BGP_VNC_DEFAULTS_NODE
, &vtysh_end_all_cmd
);
3195 install_element (BGP_VNC_NVE_GROUP_NODE
, &vtysh_end_all_cmd
);
3196 install_element (BGP_VNC_L2_GROUP_NODE
, &vtysh_end_all_cmd
);
3197 install_element (ISIS_NODE
, &vtysh_end_all_cmd
);
3198 install_element (KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
3199 install_element (KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
3200 install_element (RMAP_NODE
, &vtysh_end_all_cmd
);
3201 install_element (VTY_NODE
, &vtysh_end_all_cmd
);
3203 install_element (INTERFACE_NODE
, &vtysh_interface_desc_cmd
);
3204 install_element (INTERFACE_NODE
, &vtysh_no_interface_desc_cmd
);
3205 install_element (INTERFACE_NODE
, &vtysh_end_all_cmd
);
3206 install_element (INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
3207 install_element (LINK_PARAMS_NODE
, &exit_link_params_cmd
);
3208 install_element (LINK_PARAMS_NODE
, &vtysh_end_all_cmd
);
3209 install_element (LINK_PARAMS_NODE
, &vtysh_exit_interface_cmd
);
3210 install_element (INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
3212 install_element (NS_NODE
, &vtysh_end_all_cmd
);
3214 install_element (CONFIG_NODE
, &vtysh_ns_cmd
);
3215 install_element (NS_NODE
, &vtysh_exit_ns_cmd
);
3216 install_element (NS_NODE
, &vtysh_quit_ns_cmd
);
3218 install_element (VRF_NODE
, &vtysh_end_all_cmd
);
3219 install_element (VRF_NODE
, &vtysh_exit_vrf_cmd
);
3220 install_element (VRF_NODE
, &vtysh_quit_vrf_cmd
);
3222 install_element (CONFIG_NODE
, &router_rip_cmd
);
3223 install_element (CONFIG_NODE
, &router_ripng_cmd
);
3224 install_element (CONFIG_NODE
, &router_ospf_cmd
);
3225 install_element (CONFIG_NODE
, &router_ospf6_cmd
);
3226 #if defined (HAVE_LDPD)
3227 install_element (CONFIG_NODE
, &ldp_mpls_ldp_cmd
);
3228 install_element (LDP_NODE
, &ldp_address_family_ipv4_cmd
);
3229 install_element (LDP_NODE
, &ldp_address_family_ipv6_cmd
);
3230 install_element (LDP_IPV4_NODE
, &ldp_interface_ifname_cmd
);
3231 install_element (LDP_IPV6_NODE
, &ldp_interface_ifname_cmd
);
3232 install_element (CONFIG_NODE
, &ldp_l2vpn_word_type_vpls_cmd
);
3233 install_element (LDP_L2VPN_NODE
, &ldp_member_pseudowire_ifname_cmd
);
3235 install_element (CONFIG_NODE
, &router_isis_cmd
);
3236 install_element (CONFIG_NODE
, &router_bgp_cmd
);
3237 install_element (BGP_NODE
, &address_family_vpnv4_cmd
);
3238 install_element (BGP_NODE
, &address_family_vpnv6_cmd
);
3239 install_element (BGP_NODE
, &address_family_encapv4_cmd
);
3240 install_element (BGP_NODE
, &address_family_encapv6_cmd
);
3241 #if defined(ENABLE_BGP_VNC)
3242 install_element (BGP_NODE
, &vnc_defaults_cmd
);
3243 install_element (BGP_NODE
, &vnc_nve_group_cmd
);
3244 install_element (BGP_NODE
, &vnc_l2_group_cmd
);
3246 install_element (BGP_NODE
, &address_family_ipv4_unicast_cmd
);
3247 install_element (BGP_NODE
, &address_family_ipv4_multicast_cmd
);
3248 install_element (BGP_NODE
, &address_family_ipv6_cmd
);
3249 install_element (BGP_NODE
, &address_family_ipv6_multicast_cmd
);
3250 install_element (BGP_VPNV4_NODE
, &exit_address_family_cmd
);
3251 install_element (BGP_VPNV6_NODE
, &exit_address_family_cmd
);
3252 install_element (BGP_ENCAP_NODE
, &exit_address_family_cmd
);
3253 install_element (BGP_ENCAPV6_NODE
, &exit_address_family_cmd
);
3254 install_element (BGP_IPV4_NODE
, &exit_address_family_cmd
);
3255 install_element (BGP_IPV4M_NODE
, &exit_address_family_cmd
);
3256 install_element (BGP_IPV6_NODE
, &exit_address_family_cmd
);
3257 install_element (BGP_IPV6M_NODE
, &exit_address_family_cmd
);
3259 install_element (BGP_VNC_DEFAULTS_NODE
, &exit_vnc_config_cmd
);
3260 install_element (BGP_VNC_NVE_GROUP_NODE
, &exit_vnc_config_cmd
);
3261 install_element (BGP_VNC_L2_GROUP_NODE
, &exit_vnc_config_cmd
);
3263 install_element (CONFIG_NODE
, &key_chain_cmd
);
3264 install_element (CONFIG_NODE
, &vtysh_route_map_cmd
);
3265 install_element (CONFIG_NODE
, &vtysh_line_vty_cmd
);
3266 install_element (KEYCHAIN_NODE
, &key_cmd
);
3267 install_element (KEYCHAIN_NODE
, &key_chain_cmd
);
3268 install_element (KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
3269 install_element (CONFIG_NODE
, &vtysh_interface_cmd
);
3270 install_element (CONFIG_NODE
, &vtysh_no_interface_cmd
);
3271 install_element (CONFIG_NODE
, &vtysh_no_interface_vrf_cmd
);
3272 install_element (INTERFACE_NODE
, &vtysh_link_params_cmd
);
3273 install_element (ENABLE_NODE
, &vtysh_show_running_config_cmd
);
3274 install_element (ENABLE_NODE
, &vtysh_copy_running_config_cmd
);
3276 install_element (CONFIG_NODE
, &vtysh_vrf_cmd
);
3277 install_element (CONFIG_NODE
, &vtysh_no_vrf_cmd
);
3279 /* "write terminal" command. */
3280 install_element (ENABLE_NODE
, &vtysh_write_terminal_cmd
);
3282 install_element (CONFIG_NODE
, &vtysh_integrated_config_cmd
);
3283 install_element (CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
3285 /* "write memory" command. */
3286 install_element (ENABLE_NODE
, &vtysh_write_memory_cmd
);
3288 install_element (VIEW_NODE
, &vtysh_terminal_length_cmd
);
3289 install_element (VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
3290 install_element (VIEW_NODE
, &vtysh_show_daemons_cmd
);
3292 install_element (VIEW_NODE
, &vtysh_ping_cmd
);
3293 install_element (VIEW_NODE
, &vtysh_ping_ip_cmd
);
3294 install_element (VIEW_NODE
, &vtysh_traceroute_cmd
);
3295 install_element (VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
3296 install_element (VIEW_NODE
, &vtysh_ping6_cmd
);
3297 install_element (VIEW_NODE
, &vtysh_traceroute6_cmd
);
3298 #if defined(HAVE_SHELL_ACCESS)
3299 install_element (VIEW_NODE
, &vtysh_telnet_cmd
);
3300 install_element (VIEW_NODE
, &vtysh_telnet_port_cmd
);
3301 install_element (VIEW_NODE
, &vtysh_ssh_cmd
);
3303 #if defined(HAVE_SHELL_ACCESS)
3304 install_element (ENABLE_NODE
, &vtysh_start_shell_cmd
);
3305 install_element (ENABLE_NODE
, &vtysh_start_bash_cmd
);
3306 install_element (ENABLE_NODE
, &vtysh_start_zsh_cmd
);
3309 install_element (VIEW_NODE
, &vtysh_show_memory_cmd
);
3311 install_element (VIEW_NODE
, &vtysh_show_work_queues_cmd
);
3312 install_element (VIEW_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3314 install_element (VIEW_NODE
, &vtysh_show_thread_cmd
);
3317 install_element (VIEW_NODE
, &vtysh_show_logging_cmd
);
3318 install_element (CONFIG_NODE
, &vtysh_log_stdout_cmd
);
3319 install_element (CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
3320 install_element (CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
3321 install_element (CONFIG_NODE
, &vtysh_log_file_cmd
);
3322 install_element (CONFIG_NODE
, &vtysh_log_file_level_cmd
);
3323 install_element (CONFIG_NODE
, &no_vtysh_log_file_cmd
);
3324 install_element (CONFIG_NODE
, &vtysh_log_monitor_cmd
);
3325 install_element (CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
3326 install_element (CONFIG_NODE
, &vtysh_log_syslog_cmd
);
3327 install_element (CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
3328 install_element (CONFIG_NODE
, &vtysh_log_trap_cmd
);
3329 install_element (CONFIG_NODE
, &no_vtysh_log_trap_cmd
);
3330 install_element (CONFIG_NODE
, &vtysh_log_facility_cmd
);
3331 install_element (CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
3332 install_element (CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
3333 install_element (CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
3334 install_element (CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
3335 install_element (CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
3337 install_element (CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
3338 install_element (CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
3340 install_element (CONFIG_NODE
, &vtysh_password_cmd
);
3341 install_element (CONFIG_NODE
, &vtysh_password_text_cmd
);
3342 install_element (CONFIG_NODE
, &vtysh_enable_password_cmd
);
3343 install_element (CONFIG_NODE
, &vtysh_enable_password_text_cmd
);
3344 install_element (CONFIG_NODE
, &no_vtysh_enable_password_cmd
);