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"
48 DEFINE_MTYPE_STATIC(MVTYSH
, VTYSH_CMD
, "Vtysh cmd copy")
53 /* VTY shell pager name. */
54 char *vtysh_pager_name
= NULL
;
56 /* VTY shell client structure. */
62 char path
[MAXPATHLEN
];
63 struct vtysh_client
*next
;
66 struct vtysh_client vtysh_client
[] =
68 { .fd
= -1, .name
= "zebra", .flag
= VTYSH_ZEBRA
, .next
= NULL
},
69 { .fd
= -1, .name
= "ripd", .flag
= VTYSH_RIPD
, .next
= NULL
},
70 { .fd
= -1, .name
= "ripngd", .flag
= VTYSH_RIPNGD
, .next
= NULL
},
71 { .fd
= -1, .name
= "ospfd", .flag
= VTYSH_OSPFD
, .next
= NULL
},
72 { .fd
= -1, .name
= "ospf6d", .flag
= VTYSH_OSPF6D
, .next
= NULL
},
73 { .fd
= -1, .name
= "ldpd", .flag
= VTYSH_LDPD
, .next
= NULL
},
74 { .fd
= -1, .name
= "bgpd", .flag
= VTYSH_BGPD
, .next
= NULL
},
75 { .fd
= -1, .name
= "isisd", .flag
= VTYSH_ISISD
, .next
= NULL
},
76 { .fd
= -1, .name
= "pimd", .flag
= VTYSH_PIMD
, .next
= NULL
},
77 { .fd
= -1, .name
= "nhrpd", .flag
= VTYSH_NHRPD
, .next
= NULL
},
78 { .fd
= -1, .name
= "watchfrr", .flag
= VTYSH_WATCHFRR
, .next
= NULL
},
81 enum vtysh_write_integrated vtysh_write_integrated
= WRITE_INTEGRATED_UNSPECIFIED
;
84 vclient_close (struct vtysh_client
*vclient
)
89 "Warning: closing connection to %s because of an I/O error!\n",
96 /* Return true if str begins with prefix, else return false */
98 begins_with(const char *str
, const char *prefix
)
102 size_t lenstr
= strlen(str
);
103 size_t lenprefix
= strlen(prefix
);
104 if (lenprefix
> lenstr
)
106 return strncmp(str
, prefix
, lenprefix
) == 0;
109 /* NB: multiplexed function:
110 * if fp == NULL, this calls vtysh_config_parse_line
111 * if fp != NULL, this prints lines to fp
114 vtysh_client_run (struct vtysh_client
*vclient
, const char *line
, FILE *fp
)
118 char *buf
= stackbuf
;
119 size_t bufsz
= sizeof(stackbuf
);
120 char *bufvalid
, *end
= NULL
;
121 char terminator
[3] = {0, 0, 0};
126 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
133 ssize_t nread
= read (vclient
->fd
, bufvalid
, buf
+ bufsz
- bufvalid
);
135 if (nread
< 0 && (errno
== EINTR
|| errno
== EAGAIN
))
140 fprintf (stderr
, "vtysh: error reading from %s: %s (%d)",
141 vclient
->name
, safe_strerror(errno
), errno
);
147 end
= memmem (buf
, bufvalid
- buf
, terminator
, sizeof(terminator
));
148 if (end
+ sizeof(terminator
) + 1 > bufvalid
)
149 /* found \0\0\0 but return code hasn't been read yet */
152 ret
= end
[sizeof(terminator
)];
154 while (bufvalid
> buf
&& (end
> buf
|| !end
))
156 size_t textlen
= (end
? end
: bufvalid
) - buf
;
157 char *eol
= memchr (buf
, '\n', textlen
);
162 /* no line break, end of input, no text left before end
163 * => don't insert an empty line at the end */
166 /* no line break, end of input, but some text left */
169 /* continue reading */
172 /* eol is at a line end now, either \n => \0 or \0\0\0 */
173 assert(eol
&& eol
<= bufvalid
);
181 vtysh_config_parse_line (buf
);
187 memmove (buf
, eol
, bufvalid
- eol
);
188 bufvalid
-= eol
- buf
;
193 if (bufvalid
== buf
+ bufsz
)
199 new = XMALLOC (MTYPE_TMP
, bufsz
);
200 memcpy (new, stackbuf
, sizeof(stackbuf
));
203 new = XREALLOC (MTYPE_TMP
, buf
, bufsz
);
205 bufvalid
= bufvalid
- buf
+ new;
207 /* if end != NULL, we won't be reading more data... */
208 assert (end
== NULL
);
215 vclient_close (vclient
);
219 XFREE (MTYPE_TMP
, buf
);
224 vtysh_client_run_all (struct vtysh_client
*head_client
, const char *line
,
225 int continue_on_err
, FILE *fp
)
227 struct vtysh_client
*client
;
228 int rc
, rc_all
= CMD_SUCCESS
;
230 for (client
= head_client
; client
; client
= client
->next
)
232 rc
= vtysh_client_run(client
, line
, fp
);
233 if (rc
!= CMD_SUCCESS
)
235 if (!continue_on_err
)
244 vtysh_client_execute (struct vtysh_client
*head_client
, const char *line
,
247 return vtysh_client_run_all (head_client
, line
, 0, fp
);
251 vtysh_client_config (struct vtysh_client
*head_client
, char *line
)
253 vtysh_client_run_all (head_client
, line
, 1, NULL
);
257 vtysh_pager_init (void)
261 pager_defined
= getenv ("VTYSH_PAGER");
264 vtysh_pager_name
= strdup (pager_defined
);
266 vtysh_pager_name
= strdup ("more");
269 /* Command execution over the vty interface. */
271 vtysh_execute_func (const char *line
, int pager
)
276 const struct cmd_element
*cmd
;
280 int saved_ret
, saved_node
;
282 /* Split readline string up into the vector. */
283 vline
= cmd_make_strvec (line
);
288 saved_ret
= ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
289 saved_node
= vty
->node
;
291 /* If command doesn't succeeded in current node, try to walk up in node tree.
292 * Changing vty->node is enough to try it just out without actual walkup in
294 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
295 && vty
->node
> CONFIG_NODE
)
297 vty
->node
= node_parent(vty
->node
);
298 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
302 vty
->node
= saved_node
;
304 /* If command succeeded in any other node than current (tried > 0) we have
305 * to move into node in the vtysh where it succeeded. */
306 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
308 if ((saved_node
== BGP_VPNV4_NODE
|| saved_node
== BGP_VPNV6_NODE
309 || saved_node
== BGP_ENCAP_NODE
|| saved_node
== BGP_ENCAPV6_NODE
310 || saved_node
== BGP_IPV4_NODE
311 || saved_node
== BGP_IPV6_NODE
|| saved_node
== BGP_IPV4M_NODE
312 || saved_node
== BGP_IPV6M_NODE
|| saved_node
== BGP_EVPN_NODE
)
315 vtysh_execute("exit-address-family");
317 else if (saved_node
== BGP_VRF_POLICY_NODE
&& (tried
== 1))
319 vtysh_execute("exit-vrf-policy");
321 else if ((saved_node
== BGP_VNC_DEFAULTS_NODE
322 || saved_node
== BGP_VNC_NVE_GROUP_NODE
323 || saved_node
== BGP_VNC_L2_GROUP_NODE
) && (tried
== 1))
325 vtysh_execute("exit-vnc");
327 else if ((saved_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
329 vtysh_execute("exit");
333 vtysh_execute ("end");
334 vtysh_execute ("configure terminal");
337 /* If command didn't succeed in any node, continue with return value from
344 cmd_free_strvec (vline
);
350 if (vty
->type
== VTY_FILE
)
351 fprintf (stdout
,"Warning...\n");
353 case CMD_ERR_AMBIGUOUS
:
354 fprintf (stdout
,"%% Ambiguous command.\n");
356 case CMD_ERR_NO_MATCH
:
357 fprintf (stdout
,"%% Unknown command.\n");
359 case CMD_ERR_INCOMPLETE
:
360 fprintf (stdout
,"%% Command incomplete.\n");
362 case CMD_SUCCESS_DAEMON
:
364 /* FIXME: Don't open pager for exit commands. popen() causes problems
365 * if exited from vtysh at all. This hack shouldn't cause any problem
366 * but is really ugly. */
367 if (pager
&& vtysh_pager_name
&& (strncmp(line
, "exit", 4) != 0))
369 fp
= popen (vtysh_pager_name
, "w");
372 perror ("popen failed for pager");
381 if (! strcmp(cmd
->string
,"configure terminal"))
383 for (i
= 0; i
< array_size(vtysh_client
); i
++)
385 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
386 if (cmd_stat
== CMD_WARNING
)
393 vline
= cmd_make_strvec (line
);
397 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
399 if (pclose (fp
) == -1)
401 perror ("pclose failed for pager");
408 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
409 cmd_free_strvec (vline
);
410 if (ret
!= CMD_SUCCESS_DAEMON
)
416 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
421 cmd_stat
= CMD_SUCCESS
;
422 for (i
= 0; i
< array_size(vtysh_client
); i
++)
424 if (cmd
->daemon
& vtysh_client
[i
].flag
)
426 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
427 if (cmd_stat
!= CMD_SUCCESS
)
431 if (cmd_stat
!= CMD_SUCCESS
)
435 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
438 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
440 if (pclose (fp
) == -1)
442 perror ("pclose failed for pager");
450 vtysh_execute_no_pager (const char *line
)
452 return vtysh_execute_func (line
, 0);
456 vtysh_execute (const char *line
)
458 return vtysh_execute_func (line
, 1);
473 while (end
>= s
&& isspace(*end
))
477 while (*s
&& isspace(*s
))
484 vtysh_mark_file (const char *filename
)
491 const struct cmd_element
*cmd
;
492 int saved_ret
, prev_node
;
494 char *vty_buf_copy
= NULL
;
495 char *vty_buf_trimmed
= NULL
;
497 if (strncmp("-", filename
, 1) == 0)
500 confp
= fopen (filename
, "r");
504 fprintf (stderr
, "%% Can't open config file %s due to '%s'.\n",
505 filename
, safe_strerror (errno
));
506 return (CMD_ERR_NO_FILE
);
510 vty
->fd
= 0; /* stdout */
511 vty
->type
= VTY_TERM
;
512 vty
->node
= CONFIG_NODE
;
514 vtysh_execute_no_pager ("enable");
515 vtysh_execute_no_pager ("configure terminal");
516 vty_buf_copy
= XCALLOC (MTYPE_VTYSH_CMD
, VTY_BUFSIZ
);
518 while (fgets (vty
->buf
, VTY_BUFSIZ
, confp
))
522 strcpy(vty_buf_copy
, vty
->buf
);
523 vty_buf_trimmed
= trim(vty_buf_copy
);
525 if (vty_buf_trimmed
[0] == '!' || vty_buf_trimmed
[0] == '#')
527 fprintf(stdout
, "%s", vty
->buf
);
531 /* Split readline string up into the vector. */
532 vline
= cmd_make_strvec (vty
->buf
);
536 fprintf(stdout
, "%s", vty
->buf
);
540 /* Ignore the "end" lines, we will generate these where appropriate */
541 if (strlen(vty_buf_trimmed
) == 3 && strncmp("end", vty_buf_trimmed
, 3) == 0)
546 prev_node
= vty
->node
;
547 saved_ret
= ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
549 /* If command doesn't succeeded in current node, try to walk up in node tree.
550 * Changing vty->node is enough to try it just out without actual walkup in
552 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
553 && vty
->node
> CONFIG_NODE
)
555 vty
->node
= node_parent(vty
->node
);
556 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
560 /* If command succeeded in any other node than current (tried > 0) we have
561 * to move into node in the vtysh where it succeeded. */
562 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
564 if ((prev_node
== BGP_VPNV4_NODE
|| prev_node
== BGP_IPV4_NODE
565 || prev_node
== BGP_IPV6_NODE
|| prev_node
== BGP_IPV4M_NODE
566 || prev_node
== BGP_IPV6M_NODE
|| prev_node
== BGP_VPNV6_NODE
567 || prev_node
== BGP_EVPN_NODE
)
570 fprintf(stdout
, "exit-address-family\n");
572 else if ((prev_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
574 fprintf(stdout
, "exit\n");
578 fprintf(stdout
, "end\n");
581 /* If command didn't succeed in any node, continue with return value from
586 vty
->node
= prev_node
;
589 cmd_free_strvec (vline
);
593 if (vty
->type
== VTY_FILE
)
594 fprintf (stderr
,"line %d: Warning...: %s\n", lineno
, vty
->buf
);
597 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
599 case CMD_ERR_AMBIGUOUS
:
600 fprintf (stderr
,"line %d: %% Ambiguous command: %s\n", lineno
, vty
->buf
);
603 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
604 return CMD_ERR_AMBIGUOUS
;
605 case CMD_ERR_NO_MATCH
:
606 fprintf (stderr
,"line %d: %% Unknown command: %s\n", lineno
, vty
->buf
);
609 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
610 return CMD_ERR_NO_MATCH
;
611 case CMD_ERR_INCOMPLETE
:
612 fprintf (stderr
,"line %d: %% Command incomplete: %s\n", lineno
, vty
->buf
);
615 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
616 return CMD_ERR_INCOMPLETE
;
618 fprintf(stdout
, "%s", vty
->buf
);
620 case CMD_SUCCESS_DAEMON
:
623 int cmd_stat
= CMD_SUCCESS
;
625 fprintf(stdout
, "%s", vty
->buf
);
626 for (i
= 0; i
< array_size(vtysh_client
); i
++)
628 if (cmd
->daemon
& vtysh_client
[i
].flag
)
630 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
632 if (cmd_stat
!= CMD_SUCCESS
)
636 if (cmd_stat
!= CMD_SUCCESS
)
640 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
644 /* This is the end */
645 fprintf(stdout
, "end\n");
647 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
655 /* Configration make from file. */
657 vtysh_config_from_file (struct vty
*vty
, FILE *fp
)
660 const struct cmd_element
*cmd
;
662 int retcode
= CMD_SUCCESS
;
664 while (fgets (vty
->buf
, VTY_BUFSIZ
, fp
))
668 ret
= command_config_read_one_line (vty
, &cmd
, 1);
673 if (vty
->type
== VTY_FILE
)
674 fprintf (stderr
,"line %d: Warning[%d]...: %s\n", lineno
, vty
->node
, vty
->buf
);
675 retcode
= CMD_WARNING
; /* once we have an error, we remember & return that */
677 case CMD_ERR_AMBIGUOUS
:
678 fprintf (stderr
,"line %d: %% Ambiguous command[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
679 retcode
= CMD_ERR_AMBIGUOUS
; /* once we have an error, we remember & return that */
681 case CMD_ERR_NO_MATCH
:
682 fprintf (stderr
,"line %d: %% Unknown command[%d]: %s", lineno
, vty
->node
, vty
->buf
);
683 retcode
= CMD_ERR_NO_MATCH
; /* once we have an error, we remember & return that */
685 case CMD_ERR_INCOMPLETE
:
686 fprintf (stderr
,"line %d: %% Command incomplete[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
687 retcode
= CMD_ERR_INCOMPLETE
; /* once we have an error, we remember & return that */
689 case CMD_SUCCESS_DAEMON
:
692 int cmd_stat
= CMD_SUCCESS
;
694 for (i
= 0; i
< array_size(vtysh_client
); i
++)
696 if (cmd
->daemon
& vtysh_client
[i
].flag
)
698 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
701 * CMD_WARNING - Can mean that the command was
702 * parsed successfully but it was already entered
703 * in a few spots. As such if we receive a
704 * CMD_WARNING from a daemon we shouldn't stop
705 * talking to the other daemons for the particular
708 if (cmd_stat
!= CMD_SUCCESS
&& cmd_stat
!= CMD_WARNING
)
710 fprintf (stderr
, "line %d: Failure to communicate[%d] to %s, line: %s\n",
711 lineno
, cmd_stat
, vtysh_client
[i
].name
, vty
->buf
);
716 if (cmd_stat
!= CMD_SUCCESS
)
720 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
728 /* We don't care about the point of the cursor when '?' is typed. */
730 vtysh_rl_describe (void)
737 struct cmd_token
*token
;
739 vline
= cmd_make_strvec (rl_line_buffer
);
741 /* In case of '> ?'. */
744 vline
= vector_init (1);
745 vector_set (vline
, NULL
);
748 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
749 vector_set (vline
, NULL
);
751 describe
= cmd_describe_command (vline
, vty
, &ret
);
753 fprintf (stdout
,"\n");
755 /* Ambiguous and no match error. */
758 case CMD_ERR_AMBIGUOUS
:
759 cmd_free_strvec (vline
);
760 fprintf (stdout
,"%% Ambiguous command.\n");
764 case CMD_ERR_NO_MATCH
:
765 cmd_free_strvec (vline
);
766 fprintf (stdout
,"%% There is no matched command.\n");
772 /* Get width of command string. */
774 for (i
= 0; i
< vector_active (describe
); i
++)
775 if ((token
= vector_slot (describe
, i
)) != NULL
)
777 if (token
->text
[0] == '\0')
780 int len
= strlen (token
->text
);
786 for (i
= 0; i
< vector_active (describe
); i
++)
787 if ((token
= vector_slot (describe
, i
)) != NULL
)
790 fprintf (stdout
," %-s\n",
793 fprintf (stdout
," %-*s %s\n",
799 cmd_free_strvec (vline
);
800 vector_free (describe
);
807 /* Result of cmd_complete_command() call will be stored here
808 * and used in new_completion() in order to put the space in
809 * correct places only. */
813 command_generator (const char *text
, int state
)
816 static char **matched
= NULL
;
817 static int index
= 0;
824 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
827 vline
= cmd_make_strvec (rl_line_buffer
);
831 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
832 vector_set (vline
, NULL
);
834 matched
= cmd_complete_command (vline
, vty
, &complete_status
);
835 cmd_free_strvec (vline
);
838 if (matched
&& matched
[index
])
839 return matched
[index
++];
841 XFREE (MTYPE_TMP
, matched
);
848 new_completion (char *text
, int start
, int end
)
852 matches
= rl_completion_matches (text
, command_generator
);
857 if (complete_status
!= CMD_COMPLETE_FULL_MATCH
)
858 /* only append a space on full match */
859 rl_completion_append_character
= '\0';
865 /* Vty node structures. */
866 static struct cmd_node bgp_node
=
869 "%s(config-router)# ",
872 static struct cmd_node rip_node
=
875 "%s(config-router)# ",
878 static struct cmd_node isis_node
=
881 "%s(config-router)# ",
884 static struct cmd_node interface_node
=
890 static struct cmd_node ns_node
=
893 "%s(config-logical-router)# ",
896 static struct cmd_node vrf_node
=
902 static struct cmd_node rmap_node
=
905 "%s(config-route-map)# "
908 static struct cmd_node zebra_node
=
911 "%s(config-router)# "
914 static struct cmd_node bgp_vpnv4_node
=
917 "%s(config-router-af)# "
920 static struct cmd_node bgp_vpnv6_node
=
923 "%s(config-router-af)# "
926 static struct cmd_node bgp_encap_node
=
929 "%s(config-router-af)# "
932 static struct cmd_node bgp_encapv6_node
=
935 "%s(config-router-af)# "
938 static struct cmd_node bgp_ipv4_node
=
941 "%s(config-router-af)# "
944 static struct cmd_node bgp_ipv4m_node
=
947 "%s(config-router-af)# "
950 static struct cmd_node bgp_ipv6_node
=
953 "%s(config-router-af)# "
956 static struct cmd_node bgp_ipv6m_node
=
959 "%s(config-router-af)# "
962 static struct cmd_node bgp_evpn_node
=
965 "%s(config-router-af)# "
968 static struct cmd_node bgp_vnc_defaults_node
=
970 BGP_VNC_DEFAULTS_NODE
,
971 "%s(config-router-vnc-defaults)# "
974 static struct cmd_node bgp_vnc_nve_group_node
=
976 BGP_VNC_NVE_GROUP_NODE
,
977 "%s(config-router-vnc-nve-group)# "
980 static struct cmd_node bgp_vrf_policy_node
= {
982 "%s(config-router-vrf-policy)# "
985 static struct cmd_node bgp_vnc_l2_group_node
=
987 BGP_VNC_L2_GROUP_NODE
,
988 "%s(config-router-vnc-l2-group)# "
991 static struct cmd_node ospf_node
=
994 "%s(config-router)# "
997 static struct cmd_node ripng_node
=
1000 "%s(config-router)# "
1003 static struct cmd_node ospf6_node
=
1006 "%s(config-ospf6)# "
1009 static struct cmd_node ldp_node
=
1015 static struct cmd_node ldp_ipv4_node
=
1018 "%s(config-ldp-af)# "
1021 static struct cmd_node ldp_ipv6_node
=
1024 "%s(config-ldp-af)# "
1027 static struct cmd_node ldp_ipv4_iface_node
=
1029 LDP_IPV4_IFACE_NODE
,
1030 "%s(config-ldp-af-if)# "
1033 static struct cmd_node ldp_ipv6_iface_node
=
1035 LDP_IPV6_IFACE_NODE
,
1036 "%s(config-ldp-af-if)# "
1039 static struct cmd_node ldp_l2vpn_node
=
1042 "%s(config-l2vpn)# "
1045 static struct cmd_node ldp_pseudowire_node
=
1047 LDP_PSEUDOWIRE_NODE
,
1048 "%s(config-l2vpn-pw)# "
1051 static struct cmd_node keychain_node
=
1054 "%s(config-keychain)# "
1057 static struct cmd_node keychain_key_node
=
1060 "%s(config-keychain-key)# "
1063 struct cmd_node link_params_node
=
1066 "%s(config-link-params)# ",
1069 /* Defined in lib/vty.c */
1070 extern struct cmd_node vty_node
;
1072 /* When '^Z' is received from vty, move down to the enable mode. */
1080 /* Nothing to do. */
1083 vty
->node
= ENABLE_NODE
;
1089 DEFUNSH (VTYSH_REALLYALL
,
1093 "End current mode and change to enable mode\n")
1095 return vtysh_end ();
1098 DEFUNSH (VTYSH_BGPD
,
1101 "router bgp [(1-4294967295) [<view|vrf> WORD]]",
1105 "BGP view\nBGP VRF\n"
1108 vty
->node
= BGP_NODE
;
1112 DEFUNSH (VTYSH_BGPD
,
1113 address_family_vpnv4
,
1114 address_family_vpnv4_cmd
,
1115 "address-family vpnv4 [unicast]",
1116 "Enter Address Family command mode\n"
1118 "Address Family Modifier\n")
1120 vty
->node
= BGP_VPNV4_NODE
;
1124 DEFUNSH (VTYSH_BGPD
,
1125 address_family_vpnv6
,
1126 address_family_vpnv6_cmd
,
1127 "address-family vpnv6 [unicast]",
1128 "Enter Address Family command mode\n"
1130 "Address Family Modifier\n")
1132 vty
->node
= BGP_VPNV6_NODE
;
1136 DEFUNSH (VTYSH_BGPD
,
1137 address_family_encapv4
,
1138 address_family_encapv4_cmd
,
1139 "address-family <encap|encapv4>",
1140 "Enter Address Family command mode\n"
1144 vty
->node
= BGP_ENCAP_NODE
;
1148 DEFUNSH (VTYSH_BGPD
,
1149 address_family_encapv6
,
1150 address_family_encapv6_cmd
,
1151 "address-family encapv6",
1152 "Enter Address Family command mode\n"
1155 vty
->node
= BGP_ENCAPV6_NODE
;
1159 DEFUNSH (VTYSH_BGPD
,
1160 address_family_ipv4_unicast
,
1161 address_family_ipv4_unicast_cmd
,
1162 "address-family ipv4 [<unicast|multicast|vpn|encap>]",
1163 "Enter Address Family command mode\n"
1165 "Address Family Modifier\n"
1166 "Address Family Modifier\n"
1167 "Address Family Modifier\n"
1168 "Address Family Modifier\n")
1172 if (argv_find (argv
, argc
, "multicast", &idx
))
1173 vty
->node
= BGP_IPV4M_NODE
;
1175 else if (argv_find (argv
, argc
, "encap", &idx
))
1176 vty
->node
= BGP_ENCAP_NODE
;
1178 else if (argv_find (argv
, argc
, "vpn", &idx
))
1179 vty
->node
= BGP_VPNV4_NODE
;
1182 vty
->node
= BGP_IPV4_NODE
;
1187 DEFUNSH (VTYSH_BGPD
,
1188 address_family_ipv6
,
1189 address_family_ipv6_cmd
,
1190 "address-family ipv6 [<unicast|multicast|vpn|encap>]",
1191 "Enter Address Family command mode\n"
1193 "Address Family Modifier\n"
1194 "Address Family Modifier\n"
1195 "Address Family Modifier\n"
1196 "Address Family Modifier\n")
1200 if (argv_find (argv
, argc
, "multicast", &idx
))
1201 vty
->node
= BGP_IPV6M_NODE
;
1203 else if (argv_find (argv
, argc
, "encap", &idx
))
1204 vty
->node
= BGP_ENCAPV6_NODE
;
1206 else if (argv_find (argv
, argc
, "vpn", &idx
))
1207 vty
->node
= BGP_VPNV6_NODE
;
1210 vty
->node
= BGP_IPV6_NODE
;
1215 DEFUNSH (VTYSH_BGPD
,
1216 address_family_evpn
,
1217 address_family_evpn_cmd
,
1218 "address-family <l2vpn evpn>",
1219 "Enter Address Family command mode\n"
1220 "EVPN Address family\n"
1221 "Layer2 VPN Address family\n"
1222 "Ethernet Virtual Private Network Subsequent Address Family\n")
1224 #if defined(HAVE_EVPN)
1225 vty
->node
= BGP_EVPN_NODE
;
1226 #endif /* HAVE_EVPN */
1230 #if defined (ENABLE_BGP_VNC)
1231 DEFUNSH (VTYSH_BGPD
,
1235 "VNC/RFP related configuration\n"
1236 "Configure default NVE group\n")
1238 vty
->node
= BGP_VNC_DEFAULTS_NODE
;
1242 DEFUNSH (VTYSH_BGPD
,
1245 "vnc nve-group NAME",
1246 "VNC/RFP related configuration\n"
1247 "Configure a NVE group\n"
1250 vty
->node
= BGP_VNC_NVE_GROUP_NODE
;
1254 DEFUNSH (VTYSH_BGPD
,
1258 "Configure a VRF policy group\n"
1261 vty
->node
= BGP_VRF_POLICY_NODE
;
1265 DEFUNSH (VTYSH_BGPD
,
1268 "vnc l2-group NAME",
1269 "VNC/RFP related configuration\n"
1270 "Configure a L2 group\n"
1273 vty
->node
= BGP_VNC_L2_GROUP_NODE
;
1278 DEFUNSH (VTYSH_RIPD
,
1282 "Authentication key management\n"
1283 "Key-chain management\n"
1286 vty
->node
= KEYCHAIN_NODE
;
1290 DEFUNSH (VTYSH_RIPD
,
1293 "key (0-2147483647)",
1295 "Key identifier number\n")
1297 vty
->node
= KEYCHAIN_KEY_NODE
;
1301 DEFUNSH (VTYSH_RIPD
,
1308 vty
->node
= RIP_NODE
;
1312 DEFUNSH (VTYSH_RIPNGD
,
1319 vty
->node
= RIPNG_NODE
;
1323 DEFUNSH (VTYSH_OSPFD
,
1326 "router ospf [(1-65535)]",
1327 "Enable a routing process\n"
1328 "Start OSPF configuration\n"
1331 vty
->node
= OSPF_NODE
;
1335 DEFUNSH (VTYSH_OSPF6D
,
1342 vty
->node
= OSPF6_NODE
;
1346 #if defined (HAVE_LDPD)
1347 DEFUNSH (VTYSH_LDPD
,
1351 "Global MPLS configuration subcommands\n"
1352 "Label Distribution Protocol\n")
1354 vty
->node
= LDP_NODE
;
1358 DEFUNSH (VTYSH_LDPD
,
1359 ldp_address_family_ipv4
,
1360 ldp_address_family_ipv4_cmd
,
1361 "address-family ipv4",
1362 "Configure Address Family and its parameters\n"
1365 vty
->node
= LDP_IPV4_NODE
;
1369 DEFUNSH (VTYSH_LDPD
,
1370 ldp_address_family_ipv6
,
1371 ldp_address_family_ipv6_cmd
,
1372 "address-family ipv6",
1373 "Configure Address Family and its parameters\n"
1376 vty
->node
= LDP_IPV6_NODE
;
1380 DEFUNSH (VTYSH_LDPD
,
1381 ldp_interface_ifname
,
1382 ldp_interface_ifname_cmd
,
1384 "Enable LDP on an interface and enter interface submode\n"
1385 "Interface's name\n")
1390 vty
->node
= LDP_IPV4_IFACE_NODE
;
1393 vty
->node
= LDP_IPV6_IFACE_NODE
;
1402 DEFUNSH (VTYSH_LDPD
,
1403 ldp_l2vpn_word_type_vpls
,
1404 ldp_l2vpn_word_type_vpls_cmd
,
1405 "l2vpn WORD type vpls",
1406 "Configure l2vpn commands\n"
1409 "Virtual Private LAN Service\n")
1411 vty
->node
= LDP_L2VPN_NODE
;
1415 DEFUNSH (VTYSH_LDPD
,
1416 ldp_member_pseudowire_ifname
,
1417 ldp_member_pseudowire_ifname_cmd
,
1418 "member pseudowire IFNAME",
1419 "L2VPN member configuration\n"
1420 "Pseudowire interface\n"
1421 "Interface's name\n")
1423 vty
->node
= LDP_PSEUDOWIRE_NODE
;
1428 DEFUNSH (VTYSH_ISISD
,
1434 "ISO Routing area tag")
1436 vty
->node
= ISIS_NODE
;
1440 DEFUNSH (VTYSH_RMAP
,
1442 vtysh_route_map_cmd
,
1443 "route-map WORD <deny|permit> (1-65535)",
1444 "Create route-map or enter route-map command mode\n"
1446 "Route map denies set operations\n"
1447 "Route map permits set operations\n"
1448 "Sequence to insert to/delete from existing route-map entry\n")
1450 vty
->node
= RMAP_NODE
;
1458 "Configure a terminal line\n"
1459 "Virtual terminal\n")
1461 vty
->node
= VTY_NODE
;
1465 DEFUNSH (VTYSH_REALLYALL
,
1469 "Turn on privileged mode command\n")
1471 vty
->node
= ENABLE_NODE
;
1475 DEFUNSH (VTYSH_REALLYALL
,
1479 "Turn off privileged mode command\n")
1481 if (vty
->node
== ENABLE_NODE
)
1482 vty
->node
= VIEW_NODE
;
1486 DEFUNSH (VTYSH_REALLYALL
,
1487 vtysh_config_terminal
,
1488 vtysh_config_terminal_cmd
,
1489 "configure terminal",
1490 "Configuration from vty interface\n"
1491 "Configuration terminal\n")
1493 vty
->node
= CONFIG_NODE
;
1498 vtysh_exit (struct vty
*vty
)
1507 vty
->node
= ENABLE_NODE
;
1509 case INTERFACE_NODE
:
1519 case LDP_L2VPN_NODE
:
1525 vtysh_execute("end");
1526 vtysh_execute("configure terminal");
1527 vty
->node
= CONFIG_NODE
;
1529 case BGP_VPNV4_NODE
:
1530 case BGP_VPNV6_NODE
:
1531 case BGP_ENCAP_NODE
:
1532 case BGP_ENCAPV6_NODE
:
1534 case BGP_IPV4M_NODE
:
1536 case BGP_IPV6M_NODE
:
1537 case BGP_VRF_POLICY_NODE
:
1539 case BGP_VNC_DEFAULTS_NODE
:
1540 case BGP_VNC_NVE_GROUP_NODE
:
1541 case BGP_VNC_L2_GROUP_NODE
:
1542 vty
->node
= BGP_NODE
;
1546 vty
->node
= LDP_NODE
;
1548 case LDP_IPV4_IFACE_NODE
:
1549 vty
->node
= LDP_IPV4_NODE
;
1551 case LDP_IPV6_IFACE_NODE
:
1552 vty
->node
= LDP_IPV6_NODE
;
1554 case LDP_PSEUDOWIRE_NODE
:
1555 vty
->node
= LDP_L2VPN_NODE
;
1557 case KEYCHAIN_KEY_NODE
:
1558 vty
->node
= KEYCHAIN_NODE
;
1560 case LINK_PARAMS_NODE
:
1561 vty
->node
= INTERFACE_NODE
;
1569 DEFUNSH (VTYSH_REALLYALL
,
1573 "Exit current mode and down to previous mode\n")
1575 return vtysh_exit (vty
);
1582 "Exit current mode and down to previous mode\n")
1584 return vtysh_exit_all (self
, vty
, argc
, argv
);
1587 DEFUNSH (VTYSH_BGPD
,
1588 exit_address_family
,
1589 exit_address_family_cmd
,
1590 "exit-address-family",
1591 "Exit from Address Family configuration mode\n")
1593 if (vty
->node
== BGP_IPV4_NODE
1594 || vty
->node
== BGP_IPV4M_NODE
1595 || vty
->node
== BGP_VPNV4_NODE
1596 || vty
->node
== BGP_VPNV6_NODE
1597 || vty
->node
== BGP_ENCAP_NODE
1598 || vty
->node
== BGP_ENCAPV6_NODE
1599 || vty
->node
== BGP_IPV6_NODE
1600 || vty
->node
== BGP_IPV6M_NODE
)
1601 vty
->node
= BGP_NODE
;
1605 DEFUNSH (VTYSH_BGPD
,
1607 exit_vnc_config_cmd
,
1609 "Exit from VNC configuration mode\n")
1611 if (vty
->node
== BGP_VNC_DEFAULTS_NODE
1612 || vty
->node
== BGP_VNC_NVE_GROUP_NODE
1613 || vty
->node
== BGP_VNC_L2_GROUP_NODE
)
1614 vty
->node
= BGP_NODE
;
1618 DEFUNSH (VTYSH_BGPD
,
1620 exit_vrf_policy_cmd
,
1622 "Exit from VRF configuration mode\n")
1624 if (vty
->node
== BGP_VRF_POLICY_NODE
)
1625 vty
->node
= BGP_NODE
;
1629 DEFUNSH (VTYSH_RIPD
,
1631 vtysh_exit_ripd_cmd
,
1633 "Exit current mode and down to previous mode\n")
1635 return vtysh_exit (vty
);
1638 DEFUNSH (VTYSH_RIPD
,
1640 vtysh_quit_ripd_cmd
,
1642 "Exit current mode and down to previous mode\n")
1644 return vtysh_exit_ripd (self
, vty
, argc
, argv
);
1647 DEFUNSH (VTYSH_RIPNGD
,
1649 vtysh_exit_ripngd_cmd
,
1651 "Exit current mode and down to previous mode\n")
1653 return vtysh_exit (vty
);
1656 DEFUNSH (VTYSH_RIPNGD
,
1658 vtysh_quit_ripngd_cmd
,
1660 "Exit current mode and down to previous mode\n")
1662 return vtysh_exit_ripngd (self
, vty
, argc
, argv
);
1665 DEFUNSH (VTYSH_RMAP
,
1667 vtysh_exit_rmap_cmd
,
1669 "Exit current mode and down to previous mode\n")
1671 return vtysh_exit (vty
);
1674 DEFUNSH (VTYSH_RMAP
,
1676 vtysh_quit_rmap_cmd
,
1678 "Exit current mode and down to previous mode\n")
1680 return vtysh_exit_rmap (self
, vty
, argc
, argv
);
1683 DEFUNSH (VTYSH_BGPD
,
1685 vtysh_exit_bgpd_cmd
,
1687 "Exit current mode and down to previous mode\n")
1689 return vtysh_exit (vty
);
1692 DEFUNSH (VTYSH_BGPD
,
1694 vtysh_quit_bgpd_cmd
,
1696 "Exit current mode and down to previous mode\n")
1698 return vtysh_exit_bgpd (self
, vty
, argc
, argv
);
1701 DEFUNSH (VTYSH_OSPFD
,
1703 vtysh_exit_ospfd_cmd
,
1705 "Exit current mode and down to previous mode\n")
1707 return vtysh_exit (vty
);
1710 DEFUNSH (VTYSH_OSPFD
,
1712 vtysh_quit_ospfd_cmd
,
1714 "Exit current mode and down to previous mode\n")
1716 return vtysh_exit_ospfd (self
, vty
, argc
, argv
);
1719 DEFUNSH (VTYSH_OSPF6D
,
1721 vtysh_exit_ospf6d_cmd
,
1723 "Exit current mode and down to previous mode\n")
1725 return vtysh_exit (vty
);
1728 DEFUNSH (VTYSH_OSPF6D
,
1730 vtysh_quit_ospf6d_cmd
,
1732 "Exit current mode and down to previous mode\n")
1734 return vtysh_exit_ospf6d (self
, vty
, argc
, argv
);
1737 #if defined (HAVE_LDPD)
1738 DEFUNSH (VTYSH_LDPD
,
1740 vtysh_exit_ldpd_cmd
,
1742 "Exit current mode and down to previous mode\n")
1744 return vtysh_exit (vty
);
1747 ALIAS (vtysh_exit_ldpd
,
1748 vtysh_quit_ldpd_cmd
,
1750 "Exit current mode and down to previous mode\n")
1753 DEFUNSH (VTYSH_ISISD
,
1755 vtysh_exit_isisd_cmd
,
1757 "Exit current mode and down to previous mode\n")
1759 return vtysh_exit (vty
);
1762 DEFUNSH (VTYSH_ISISD
,
1764 vtysh_quit_isisd_cmd
,
1766 "Exit current mode and down to previous mode\n")
1768 return vtysh_exit_isisd (self
, vty
, argc
, argv
);
1772 vtysh_exit_line_vty
,
1773 vtysh_exit_line_vty_cmd
,
1775 "Exit current mode and down to previous mode\n")
1777 return vtysh_exit (vty
);
1781 vtysh_quit_line_vty
,
1782 vtysh_quit_line_vty_cmd
,
1784 "Exit current mode and down to previous mode\n")
1786 return vtysh_exit_line_vty (self
, vty
, argc
, argv
);
1789 DEFUNSH (VTYSH_INTERFACE
,
1791 vtysh_interface_cmd
,
1792 "interface IFNAME [vrf NAME]",
1793 "Select an interface to configure\n"
1794 "Interface's name\n"
1797 vty
->node
= INTERFACE_NODE
;
1801 /* TODO Implement "no interface command in isisd. */
1802 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_RIPNGD
|VTYSH_OSPFD
|VTYSH_OSPF6D
|VTYSH_LDPD
,
1803 vtysh_no_interface_cmd
,
1804 "no interface IFNAME",
1806 "Delete a pseudo interface's configuration\n"
1807 "Interface's name\n")
1810 vtysh_no_interface_vrf_cmd
,
1811 "no interface IFNAME vrf NAME",
1813 "Delete a pseudo interface's configuration\n"
1814 "Interface's name\n"
1820 "logical-router (1-65535) ns NAME",
1821 "Enable a logical-router\n"
1822 "Specify the logical-router indentifier\n"
1824 "The file name in " NS_RUN_DIR
", or a full pathname\n")
1826 vty
->node
= NS_NODE
;
1834 "Select a VRF to configure\n"
1837 vty
->node
= VRF_NODE
;
1845 "Delete a pseudo vrf's configuration\n"
1852 "Exit current mode and down to previous mode\n")
1854 return vtysh_exit (vty
);
1861 "Exit current mode and down to previous mode\n")
1863 return vtysh_exit_ns(self
, vty
, argc
, argv
);
1870 "Exit current mode and down to previous mode\n")
1872 return vtysh_exit (vty
);
1879 "Exit current mode and down to previous mode\n")
1881 return vtysh_exit_vrf (self
, vty
, argc
, argv
);
1884 /* TODO Implement interface description commands in ripngd, ospf6d
1886 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
|VTYSH_LDPD
,
1887 vtysh_interface_desc_cmd
,
1888 "description LINE...",
1889 "Interface specific description\n"
1890 "Characters describing this interface\n")
1892 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1893 vtysh_no_interface_desc_cmd
,
1896 "Interface specific description\n")
1898 DEFUNSH (VTYSH_INTERFACE
,
1899 vtysh_exit_interface
,
1900 vtysh_exit_interface_cmd
,
1902 "Exit current mode and down to previous mode\n")
1904 return vtysh_exit (vty
);
1907 DEFUNSH (VTYSH_INTERFACE
,
1908 vtysh_quit_interface
,
1909 vtysh_quit_interface_cmd
,
1911 "Exit current mode and down to previous mode\n")
1913 return vtysh_exit_interface (self
, vty
, argc
, argv
);
1916 DEFUN (vtysh_show_thread
,
1917 vtysh_show_thread_cmd
,
1918 "show thread cpu [FILTER]",
1920 "Thread information\n"
1921 "Thread CPU usage\n"
1922 "Display filter (rwtexb)\n")
1926 int ret
= CMD_SUCCESS
;
1929 sprintf(line
, "show thread cpu %s\n", (argc
== 4) ? argv
[idx_filter
]->arg
: "");
1930 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1931 if ( vtysh_client
[i
].fd
>= 0 )
1933 fprintf (stdout
, "Thread statistics for %s:\n",
1934 vtysh_client
[i
].name
);
1935 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1936 fprintf (stdout
,"\n");
1941 DEFUN (vtysh_show_work_queues
,
1942 vtysh_show_work_queues_cmd
,
1945 "Work Queue information\n")
1948 int ret
= CMD_SUCCESS
;
1949 char line
[] = "show work-queues\n";
1951 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1952 if ( vtysh_client
[i
].fd
>= 0 )
1954 fprintf (stdout
, "Work queue statistics for %s:\n",
1955 vtysh_client
[i
].name
);
1956 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1957 fprintf (stdout
,"\n");
1963 DEFUN (vtysh_show_work_queues_daemon
,
1964 vtysh_show_work_queues_daemon_cmd
,
1965 "show work-queues <zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd>",
1967 "Work Queue information\n"
1968 "For the zebra daemon\n"
1969 "For the rip daemon\n"
1970 "For the ripng daemon\n"
1971 "For the ospf daemon\n"
1972 "For the ospfv6 daemon\n"
1973 "For the bgp daemon\n"
1974 "For the isis daemon\n")
1976 int idx_protocol
= 2;
1978 int ret
= CMD_SUCCESS
;
1980 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1982 if (strmatch(vtysh_client
[i
].name
, argv
[idx_protocol
]->text
))
1986 ret
= vtysh_client_execute(&vtysh_client
[i
], "show work-queues\n", stdout
);
1991 DEFUNSH (VTYSH_ZEBRA
,
1993 vtysh_link_params_cmd
,
1998 vty
->node
= LINK_PARAMS_NODE
;
2002 DEFUNSH (VTYSH_ZEBRA
,
2004 exit_link_params_cmd
,
2006 "Exit from Link Params configuration node\n")
2008 if (vty
->node
== LINK_PARAMS_NODE
)
2009 vty
->node
= INTERFACE_NODE
;
2014 DEFUN (vtysh_show_memory
,
2015 vtysh_show_memory_cmd
,
2018 "Memory statistics\n")
2021 int ret
= CMD_SUCCESS
;
2022 char line
[] = "show memory\n";
2024 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2025 if ( vtysh_client
[i
].fd
>= 0 )
2027 fprintf (stdout
, "Memory statistics for %s:\n",
2028 vtysh_client
[i
].name
);
2029 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2030 fprintf (stdout
,"\n");
2036 /* Logging commands. */
2037 DEFUN (vtysh_show_logging
,
2038 vtysh_show_logging_cmd
,
2041 "Show current logging configuration\n")
2044 int ret
= CMD_SUCCESS
;
2045 char line
[] = "show logging\n";
2047 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2048 if ( vtysh_client
[i
].fd
>= 0 )
2050 fprintf (stdout
,"Logging configuration for %s:\n",
2051 vtysh_client
[i
].name
);
2052 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2053 fprintf (stdout
,"\n");
2061 vtysh_log_stdout_cmd
,
2064 "Set stdout logging level\n")
2070 vtysh_log_stdout_level
,
2071 vtysh_log_stdout_level_cmd
,
2072 "log stdout <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2074 "Set stdout logging level\n"
2081 no_vtysh_log_stdout
,
2082 no_vtysh_log_stdout_cmd
,
2083 "no log stdout [LEVEL]",
2086 "Cancel logging to stdout\n"
2095 "log file FILENAME",
2098 "Logging filename\n")
2104 vtysh_log_file_level
,
2105 vtysh_log_file_level_cmd
,
2106 "log file FILENAME <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2109 "Logging filename\n"
2117 no_vtysh_log_file_cmd
,
2118 "no log file [FILENAME [LEVEL]]",
2121 "Cancel logging to file\n"
2122 "Logging file name\n"
2130 vtysh_log_monitor_cmd
,
2131 "log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
2133 "Set terminal line (monitor) logging level\n"
2140 no_vtysh_log_monitor
,
2141 no_vtysh_log_monitor_cmd
,
2142 "no log monitor [LEVEL]",
2145 "Disable terminal line (monitor) logging\n"
2153 vtysh_log_syslog_cmd
,
2154 "log syslog <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2156 "Set syslog logging level\n"
2163 no_vtysh_log_syslog
,
2164 no_vtysh_log_syslog_cmd
,
2165 "no log syslog [LEVEL]",
2168 "Cancel logging to syslog\n"
2176 vtysh_log_facility_cmd
,
2177 "log facility <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>",
2179 "Facility parameter for syslog messages\n"
2187 no_vtysh_log_facility
,
2188 no_vtysh_log_facility_cmd
,
2189 "no log facility [FACILITY]",
2192 "Reset syslog facility to default (daemon)\n"
2193 "Syslog facility\n")
2199 DEFUNSH_DEPRECATED (VTYSH_ALL
,
2202 "log trap <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2204 "(Deprecated) Set logging level and default for all destinations\n"
2211 DEFUNSH_DEPRECATED (VTYSH_ALL
,
2213 no_vtysh_log_trap_cmd
,
2214 "no log trap [LEVEL]",
2217 "Permit all logging information\n"
2224 vtysh_log_record_priority
,
2225 vtysh_log_record_priority_cmd
,
2226 "log record-priority",
2228 "Log the priority of the message within the message\n")
2234 no_vtysh_log_record_priority
,
2235 no_vtysh_log_record_priority_cmd
,
2236 "no log record-priority",
2239 "Do not log the priority of the message within the message\n")
2245 vtysh_log_timestamp_precision
,
2246 vtysh_log_timestamp_precision_cmd
,
2247 "log timestamp precision (0-6)",
2249 "Timestamp configuration\n"
2250 "Set the timestamp precision\n"
2251 "Number of subsecond digits\n")
2257 no_vtysh_log_timestamp_precision
,
2258 no_vtysh_log_timestamp_precision_cmd
,
2259 "no log timestamp precision",
2262 "Timestamp configuration\n"
2263 "Reset the timestamp precision to the default value of 0\n")
2269 vtysh_service_password_encrypt
,
2270 vtysh_service_password_encrypt_cmd
,
2271 "service password-encryption",
2272 "Set up miscellaneous service\n"
2273 "Enable encrypted passwords\n")
2279 no_vtysh_service_password_encrypt
,
2280 no_vtysh_service_password_encrypt_cmd
,
2281 "no service password-encryption",
2283 "Set up miscellaneous service\n"
2284 "Enable encrypted passwords\n")
2290 vtysh_config_password
,
2292 "password (8-8) WORD",
2293 "Assign the terminal connection password\n"
2294 "Specifies a HIDDEN password will follow\n"
2296 "The HIDDEN line password string\n")
2302 vtysh_password_text
,
2303 vtysh_password_text_cmd
,
2305 "Assign the terminal connection password\n"
2306 "The UNENCRYPTED (cleartext) line password\n")
2312 vtysh_config_enable_password
,
2313 vtysh_enable_password_cmd
,
2314 "enable password (8-8) WORD",
2315 "Modify enable password parameters\n"
2316 "Assign the privileged level password\n"
2317 "Specifies a HIDDEN password will follow\n"
2318 "The HIDDEN 'enable' password string\n")
2324 vtysh_enable_password_text
,
2325 vtysh_enable_password_text_cmd
,
2326 "enable password LINE",
2327 "Modify enable password parameters\n"
2328 "Assign the privileged level password\n"
2329 "The UNENCRYPTED (cleartext) 'enable' password\n")
2335 no_vtysh_config_enable_password
,
2336 no_vtysh_enable_password_cmd
,
2337 "no enable password",
2339 "Modify enable password parameters\n"
2340 "Assign the privileged level password\n")
2345 DEFUN (vtysh_write_terminal
,
2346 vtysh_write_terminal_cmd
,
2347 "write terminal [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2348 "Write running configuration to memory, network, or terminal\n"
2349 "Write to terminal\n"
2350 "For the zebra daemon\n"
2351 "For the rip daemon\n"
2352 "For the ripng daemon\n"
2353 "For the ospf daemon\n"
2354 "For the ospfv6 daemon\n"
2355 "For the ldpd daemon\n"
2356 "For the bgp daemon\n"
2357 "For the isis daemon\n"
2358 "For the pim daemon\n")
2361 char line
[] = "write terminal\n";
2364 if (vtysh_pager_name
)
2366 fp
= popen (vtysh_pager_name
, "w");
2376 vty_out (vty
, "Building configuration...%s", VTY_NEWLINE
);
2377 vty_out (vty
, "%sCurrent configuration:%s", VTY_NEWLINE
,
2379 vty_out (vty
, "!%s", VTY_NEWLINE
);
2381 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2382 if ((argc
< 3 ) || (strmatch (vtysh_client
[i
].name
, argv
[2]->text
)))
2383 vtysh_client_config (&vtysh_client
[i
], line
);
2385 /* Integrate vtysh specific configuration. */
2386 vtysh_config_write ();
2388 vtysh_config_dump (fp
);
2390 if (vtysh_pager_name
&& fp
)
2393 if (pclose (fp
) == -1)
2401 vty_out (vty
, "end%s", VTY_NEWLINE
);
2405 DEFUN (vtysh_show_running_config
,
2406 vtysh_show_running_config_cmd
,
2407 "show running-config [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2409 "Current operating configuration\n"
2410 "For the zebra daemon\n"
2411 "For the rip daemon\n"
2412 "For the ripng daemon\n"
2413 "For the ospf daemon\n"
2414 "For the ospfv6 daemon\n"
2415 "For the ldp daemon\n"
2416 "For the bgp daemon\n"
2417 "For the isis daemon\n"
2418 "For the pim daemon\n")
2420 return vtysh_write_terminal (self
, vty
, argc
, argv
);
2423 DEFUN (vtysh_integrated_config
,
2424 vtysh_integrated_config_cmd
,
2425 "service integrated-vtysh-config",
2426 "Set up miscellaneous service\n"
2427 "Write configuration into integrated file\n")
2429 vtysh_write_integrated
= WRITE_INTEGRATED_YES
;
2433 DEFUN (no_vtysh_integrated_config
,
2434 no_vtysh_integrated_config_cmd
,
2435 "no service integrated-vtysh-config",
2437 "Set up miscellaneous service\n"
2438 "Write configuration into integrated file\n")
2440 vtysh_write_integrated
= WRITE_INTEGRATED_NO
;
2445 backup_config_file (const char *fbackup
)
2447 char *integrate_sav
= NULL
;
2449 integrate_sav
= malloc (strlen (fbackup
) +
2450 strlen (CONF_BACKUP_EXT
) + 1);
2451 strcpy (integrate_sav
, fbackup
);
2452 strcat (integrate_sav
, CONF_BACKUP_EXT
);
2454 /* Move current configuration file to backup config file. */
2455 unlink (integrate_sav
);
2456 rename (fbackup
, integrate_sav
);
2457 free (integrate_sav
);
2461 vtysh_write_config_integrated(void)
2464 char line
[] = "write terminal\n";
2467 struct passwd
*pwentry
;
2468 struct group
*grentry
;
2474 fprintf (stdout
,"Building Configuration...\n");
2476 backup_config_file(quagga_config
);
2477 fp
= fopen (quagga_config
, "w");
2480 fprintf (stdout
,"%% Error: failed to open configuration file %s: %s\n",
2481 quagga_config
, safe_strerror(errno
));
2486 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2487 vtysh_client_config (&vtysh_client
[i
], line
);
2489 vtysh_config_write ();
2490 vtysh_config_dump (fp
);
2492 if (fchmod (fd
, CONFIGFILE_MASK
) != 0)
2494 printf ("%% Warning: can't chmod configuration file %s: %s\n",
2495 quagga_config
, safe_strerror(errno
));
2499 pwentry
= getpwnam (FRR_USER
);
2501 uid
= pwentry
->pw_uid
;
2504 printf ("%% Warning: could not look up user \"%s\"\n", FRR_USER
);
2508 grentry
= getgrnam (FRR_GROUP
);
2510 gid
= grentry
->gr_gid
;
2513 printf ("%% Warning: could not look up group \"%s\"\n", FRR_GROUP
);
2517 if (!fstat (fd
, &st
))
2519 if (st
.st_uid
== uid
)
2521 if (st
.st_gid
== gid
)
2523 if ((uid
!= (uid_t
)-1 || gid
!= (gid_t
)-1) && fchown (fd
, uid
, gid
))
2525 printf ("%% Warning: can't chown configuration file %s: %s\n",
2526 quagga_config
, safe_strerror(errno
));
2532 printf ("%% Warning: stat() failed on %s: %s\n",
2533 quagga_config
, safe_strerror(errno
));
2539 printf ("Integrated configuration saved to %s\n", quagga_config
);
2547 static bool want_config_integrated(void)
2551 switch (vtysh_write_integrated
)
2553 case WRITE_INTEGRATED_UNSPECIFIED
:
2554 if (stat(quagga_config
, &s
) && errno
== ENOENT
)
2557 case WRITE_INTEGRATED_NO
:
2559 case WRITE_INTEGRATED_YES
:
2565 DEFUN (vtysh_write_memory
,
2566 vtysh_write_memory_cmd
,
2567 "write [<memory|file>]",
2568 "Write running configuration to memory, network, or terminal\n"
2569 "Write configuration to the file (same as write file)\n"
2570 "Write configuration to the file (same as write memory)\n")
2572 int ret
= CMD_SUCCESS
;
2573 char line
[] = "write memory\n";
2576 fprintf (stdout
, "Note: this version of vtysh never writes vtysh.conf\n");
2578 /* If integrated frr.conf explicitely set. */
2579 if (want_config_integrated())
2582 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2583 if (vtysh_client
[i
].flag
== VTYSH_WATCHFRR
)
2585 if (i
< array_size(vtysh_client
) && vtysh_client
[i
].fd
!= -1)
2586 ret
= vtysh_client_execute (&vtysh_client
[i
], "write integrated", stdout
);
2588 if (ret
!= CMD_SUCCESS
)
2590 printf("\nWarning: attempting direct configuration write without "
2591 "watchfrr.\nFile permissions and ownership may be "
2592 "incorrect, or write may fail.\n\n");
2593 ret
= vtysh_write_config_integrated();
2598 fprintf (stdout
,"Building Configuration...\n");
2600 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2601 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2606 DEFUN (vtysh_copy_running_config
,
2607 vtysh_copy_running_config_cmd
,
2608 "copy running-config startup-config",
2609 "Copy from one file to another\n"
2610 "Copy from current system configuration\n"
2611 "Copy to startup configuration\n")
2613 return vtysh_write_memory (self
, vty
, argc
, argv
);
2616 DEFUN (vtysh_terminal_length
,
2617 vtysh_terminal_length_cmd
,
2618 "terminal length (0-512)",
2619 "Set terminal line parameters\n"
2620 "Set number of lines on a screen\n"
2621 "Number of lines on screen (0 for no pausing)\n")
2625 char *endptr
= NULL
;
2626 char default_pager
[10];
2628 lines
= strtol (argv
[idx_number
]->arg
, &endptr
, 10);
2629 if (lines
< 0 || lines
> 512 || *endptr
!= '\0')
2631 vty_out (vty
, "length is malformed%s", VTY_NEWLINE
);
2635 if (vtysh_pager_name
)
2637 free (vtysh_pager_name
);
2638 vtysh_pager_name
= NULL
;
2643 snprintf(default_pager
, 10, "more -%i", lines
);
2644 vtysh_pager_name
= strdup (default_pager
);
2650 DEFUN (vtysh_terminal_no_length
,
2651 vtysh_terminal_no_length_cmd
,
2652 "terminal no length",
2653 "Set terminal line parameters\n"
2655 "Set number of lines on a screen\n")
2657 if (vtysh_pager_name
)
2659 free (vtysh_pager_name
);
2660 vtysh_pager_name
= NULL
;
2667 DEFUN (vtysh_show_daemons
,
2668 vtysh_show_daemons_cmd
,
2671 "Show list of running daemons\n")
2675 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2676 if ( vtysh_client
[i
].fd
>= 0 )
2677 vty_out(vty
, " %s", vtysh_client
[i
].name
);
2678 vty_out(vty
, "%s", VTY_NEWLINE
);
2683 /* Execute command in child process. */
2685 execute_command (const char *command
, int argc
, struct cmd_token
*arg1
,
2696 /* Failure of fork(). */
2697 fprintf (stderr
, "Can't fork: %s\n", safe_strerror (errno
));
2702 /* This is child process. */
2706 execlp (command
, command
, (const char *)NULL
);
2709 execlp (command
, command
, arg1
, (const char *)NULL
);
2712 execlp (command
, command
, arg1
, arg2
, (const char *)NULL
);
2716 /* When execlp suceed, this part is not executed. */
2717 fprintf (stderr
, "Can't execute %s: %s\n", command
, safe_strerror (errno
));
2722 /* This is parent. */
2724 wait4 (pid
, &status
, 0, NULL
);
2732 "Send echo messages\n"
2733 "Ping destination address or hostname\n")
2735 execute_command ("ping", 1, argv
[0], NULL
);
2742 "Send echo messages\n"
2744 "Ping destination address or hostname\n")
2746 DEFUN (vtysh_traceroute
,
2747 vtysh_traceroute_cmd
,
2749 "Trace route to destination\n"
2750 "Trace route to destination address or hostname\n")
2752 execute_command ("traceroute", 1, argv
[0], NULL
);
2756 ALIAS (vtysh_traceroute
,
2757 vtysh_traceroute_ip_cmd
,
2758 "traceroute ip WORD",
2759 "Trace route to destination\n"
2761 "Trace route to destination address or hostname\n")
2766 "Send echo messages\n"
2768 "Ping destination address or hostname\n")
2770 execute_command ("ping6", 1, argv
[0], NULL
);
2774 DEFUN (vtysh_traceroute6
,
2775 vtysh_traceroute6_cmd
,
2776 "traceroute ipv6 WORD",
2777 "Trace route to destination\n"
2779 "Trace route to destination address or hostname\n")
2781 execute_command ("traceroute6", 1, argv
[0], NULL
);
2785 #if defined(HAVE_SHELL_ACCESS)
2786 DEFUN (vtysh_telnet
,
2789 "Open a telnet connection\n"
2790 "IP address or hostname of a remote system\n")
2792 execute_command ("telnet", 1, argv
[0], NULL
);
2796 DEFUN (vtysh_telnet_port
,
2797 vtysh_telnet_port_cmd
,
2799 "Open a telnet connection\n"
2800 "IP address or hostname of a remote system\n"
2801 "TCP Port number\n")
2803 execute_command ("telnet", 2, argv
[0], argv
[1]);
2810 "Open an ssh connection\n"
2813 execute_command ("ssh", 1, argv
[0], NULL
);
2817 DEFUN (vtysh_start_shell
,
2818 vtysh_start_shell_cmd
,
2820 "Start UNIX shell\n")
2822 execute_command ("sh", 0, NULL
, NULL
);
2826 DEFUN (vtysh_start_bash
,
2827 vtysh_start_bash_cmd
,
2829 "Start UNIX shell\n"
2832 execute_command ("bash", 0, NULL
, NULL
);
2836 DEFUN (vtysh_start_zsh
,
2837 vtysh_start_zsh_cmd
,
2839 "Start UNIX shell\n"
2842 execute_command ("zsh", 0, NULL
, NULL
);
2849 "list [permutations]",
2850 "Print command list\n"
2851 "Print all possible command permutations\n")
2853 return cmd_list_cmds (vty
, argc
== 2);
2857 vtysh_install_default (enum node_type node
)
2859 install_element (node
, &config_list_cmd
);
2862 /* Making connection to protocol daemon. */
2864 vtysh_connect (struct vtysh_client
*vclient
)
2868 struct sockaddr_un addr
;
2872 if (!vclient
->path
[0])
2873 snprintf(vclient
->path
, sizeof(vclient
->path
), "%s/%s.vty",
2874 vty_sock_path
, vclient
->name
);
2875 path
= vclient
->path
;
2877 /* Stat socket to see if we have permission to access it. */
2878 ret
= stat (path
, &s_stat
);
2879 if (ret
< 0 && errno
!= ENOENT
)
2881 fprintf (stderr
, "vtysh_connect(%s): stat = %s\n",
2882 path
, safe_strerror(errno
));
2888 if (! S_ISSOCK(s_stat
.st_mode
))
2890 fprintf (stderr
, "vtysh_connect(%s): Not a socket\n",
2897 sock
= socket (AF_UNIX
, SOCK_STREAM
, 0);
2901 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", path
,
2902 safe_strerror(errno
));
2907 memset (&addr
, 0, sizeof (struct sockaddr_un
));
2908 addr
.sun_family
= AF_UNIX
;
2909 strlcpy (addr
.sun_path
, path
, sizeof (addr
.sun_path
));
2910 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
2911 len
= addr
.sun_len
= SUN_LEN(&addr
);
2913 len
= sizeof (addr
.sun_family
) + strlen (addr
.sun_path
);
2914 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
2916 ret
= connect (sock
, (struct sockaddr
*) &addr
, len
);
2920 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", path
,
2921 safe_strerror(errno
));
2931 /* Return true if str ends with suffix, else return false */
2933 ends_with(const char *str
, const char *suffix
)
2935 if (!str
|| !suffix
)
2937 size_t lenstr
= strlen(str
);
2938 size_t lensuffix
= strlen(suffix
);
2939 if (lensuffix
> lenstr
)
2941 return strncmp(str
+ lenstr
- lensuffix
, suffix
, lensuffix
) == 0;
2945 vtysh_client_sorted_insert (struct vtysh_client
*head_client
,
2946 struct vtysh_client
*client
)
2948 struct vtysh_client
*prev_node
, *current_node
;
2950 prev_node
= head_client
;
2951 current_node
= head_client
->next
;
2952 while (current_node
)
2954 if (strcmp(current_node
->path
, client
->path
) > 0)
2957 prev_node
= current_node
;
2958 current_node
= current_node
->next
;
2960 client
->next
= current_node
;
2961 prev_node
->next
= client
;
2964 #define MAXIMUM_INSTANCES 10
2967 vtysh_update_all_insances(struct vtysh_client
* head_client
)
2969 struct vtysh_client
*client
;
2971 struct dirent
*file
;
2974 if (head_client
->flag
!= VTYSH_OSPFD
) return;
2976 /* ls vty_sock_dir and look for all files ending in .vty */
2977 dir
= opendir(vty_sock_path
);
2980 while ((file
= readdir(dir
)) != NULL
)
2982 if (begins_with(file
->d_name
, "ospfd-") && ends_with(file
->d_name
, ".vty"))
2984 if (n
== MAXIMUM_INSTANCES
)
2987 "Parsing %s, client limit(%d) reached!\n",
2991 client
= (struct vtysh_client
*) malloc(sizeof(struct vtysh_client
));
2993 client
->name
= "ospfd";
2994 client
->flag
= VTYSH_OSPFD
;
2995 snprintf(client
->path
, sizeof(client
->path
), "%s/%s",
2996 vty_sock_path
, file
->d_name
);
2997 client
->next
= NULL
;
2998 vtysh_client_sorted_insert(head_client
, client
);
3007 vtysh_connect_all_instances (struct vtysh_client
*head_client
)
3009 struct vtysh_client
*client
;
3012 vtysh_update_all_insances(head_client
);
3014 client
= head_client
->next
;
3017 if (vtysh_connect(client
) == 0)
3019 client
= client
->next
;
3026 vtysh_connect_all(const char *daemon_name
)
3032 for (i
= 0; i
< array_size(vtysh_client
); i
++)
3034 if (!daemon_name
|| !strcmp(daemon_name
, vtysh_client
[i
].name
))
3037 if (vtysh_connect(&vtysh_client
[i
]) == 0)
3040 rc
+= vtysh_connect_all_instances(&vtysh_client
[i
]);
3044 fprintf(stderr
, "Error: no daemons match name %s!\n", daemon_name
);
3048 /* To disable readline's filename completion. */
3050 vtysh_completion_entry_function (const char *ignore
, int invoking_key
)
3056 vtysh_readline_init (void)
3058 /* readline related settings. */
3060 rl_bind_key ('?', (rl_command_func_t
*) vtysh_rl_describe
);
3061 rl_completion_entry_function
= vtysh_completion_entry_function
;
3062 rl_attempted_completion_function
= (rl_completion_func_t
*)new_completion
;
3068 static struct utsname names
;
3069 static char buf
[100];
3070 const char*hostname
;
3071 extern struct host host
;
3073 hostname
= host
.name
;
3077 if (!names
.nodename
[0])
3079 hostname
= names
.nodename
;
3082 snprintf (buf
, sizeof buf
, cmd_prompt (vty
->node
), hostname
);
3088 vtysh_init_vty (void)
3090 /* Make vty structure. */
3092 vty
->type
= VTY_SHELL
;
3093 vty
->node
= VIEW_NODE
;
3095 /* Initialize commands. */
3098 /* Install nodes. */
3099 install_node (&bgp_node
, NULL
);
3100 install_node (&rip_node
, NULL
);
3101 install_node (&interface_node
, NULL
);
3102 install_node (&link_params_node
, NULL
);
3103 install_node (&ns_node
, NULL
);
3104 install_node (&vrf_node
, NULL
);
3105 install_node (&rmap_node
, NULL
);
3106 install_node (&zebra_node
, NULL
);
3107 install_node (&bgp_vpnv4_node
, NULL
);
3108 install_node (&bgp_vpnv6_node
, NULL
);
3109 install_node (&bgp_encap_node
, NULL
);
3110 install_node (&bgp_encapv6_node
, NULL
);
3111 install_node (&bgp_ipv4_node
, NULL
);
3112 install_node (&bgp_ipv4m_node
, NULL
);
3113 install_node (&bgp_ipv6_node
, NULL
);
3114 install_node (&bgp_ipv6m_node
, NULL
);
3115 install_node (&bgp_vrf_policy_node
, NULL
);
3116 install_node (&bgp_evpn_node
, NULL
);
3117 install_node (&bgp_vnc_defaults_node
, NULL
);
3118 install_node (&bgp_vnc_nve_group_node
, NULL
);
3119 install_node (&bgp_vnc_l2_group_node
, NULL
);
3120 install_node (&ospf_node
, NULL
);
3121 install_node (&ripng_node
, NULL
);
3122 install_node (&ospf6_node
, NULL
);
3123 install_node (&ldp_node
, NULL
);
3124 install_node (&ldp_ipv4_node
, NULL
);
3125 install_node (&ldp_ipv6_node
, NULL
);
3126 install_node (&ldp_ipv4_iface_node
, NULL
);
3127 install_node (&ldp_ipv6_iface_node
, NULL
);
3128 install_node (&ldp_l2vpn_node
, NULL
);
3129 install_node (&ldp_pseudowire_node
, NULL
);
3130 install_node (&keychain_node
, NULL
);
3131 install_node (&keychain_key_node
, NULL
);
3132 install_node (&isis_node
, NULL
);
3133 install_node (&vty_node
, NULL
);
3135 vtysh_install_default (VIEW_NODE
);
3136 vtysh_install_default (CONFIG_NODE
);
3137 vtysh_install_default (BGP_NODE
);
3138 vtysh_install_default (RIP_NODE
);
3139 vtysh_install_default (INTERFACE_NODE
);
3140 vtysh_install_default (LINK_PARAMS_NODE
);
3141 vtysh_install_default (NS_NODE
);
3142 vtysh_install_default (VRF_NODE
);
3143 vtysh_install_default (RMAP_NODE
);
3144 vtysh_install_default (ZEBRA_NODE
);
3145 vtysh_install_default (BGP_VPNV4_NODE
);
3146 vtysh_install_default (BGP_VPNV6_NODE
);
3147 vtysh_install_default (BGP_ENCAP_NODE
);
3148 vtysh_install_default (BGP_ENCAPV6_NODE
);
3149 vtysh_install_default (BGP_IPV4_NODE
);
3150 vtysh_install_default (BGP_IPV4M_NODE
);
3151 vtysh_install_default (BGP_IPV6_NODE
);
3152 vtysh_install_default (BGP_IPV6M_NODE
);
3153 vtysh_install_default (BGP_EVPN_NODE
);
3155 vtysh_install_default (BGP_VRF_POLICY_NODE
);
3156 vtysh_install_default (BGP_VNC_DEFAULTS_NODE
);
3157 vtysh_install_default (BGP_VNC_NVE_GROUP_NODE
);
3158 vtysh_install_default (BGP_VNC_L2_GROUP_NODE
);
3160 vtysh_install_default (OSPF_NODE
);
3161 vtysh_install_default (RIPNG_NODE
);
3162 vtysh_install_default (OSPF6_NODE
);
3163 vtysh_install_default (LDP_NODE
);
3164 vtysh_install_default (LDP_IPV4_NODE
);
3165 vtysh_install_default (LDP_IPV6_NODE
);
3166 vtysh_install_default (LDP_IPV4_IFACE_NODE
);
3167 vtysh_install_default (LDP_IPV6_IFACE_NODE
);
3168 vtysh_install_default (LDP_L2VPN_NODE
);
3169 vtysh_install_default (LDP_PSEUDOWIRE_NODE
);
3170 vtysh_install_default (ISIS_NODE
);
3171 vtysh_install_default (KEYCHAIN_NODE
);
3172 vtysh_install_default (KEYCHAIN_KEY_NODE
);
3173 vtysh_install_default (VTY_NODE
);
3175 install_element (VIEW_NODE
, &vtysh_enable_cmd
);
3176 install_element (ENABLE_NODE
, &vtysh_config_terminal_cmd
);
3177 install_element (ENABLE_NODE
, &vtysh_disable_cmd
);
3179 /* "exit" command. */
3180 install_element (VIEW_NODE
, &vtysh_exit_all_cmd
);
3181 install_element (CONFIG_NODE
, &vtysh_exit_all_cmd
);
3182 install_element (VIEW_NODE
, &vtysh_quit_all_cmd
);
3183 install_element (CONFIG_NODE
, &vtysh_quit_all_cmd
);
3184 install_element (RIP_NODE
, &vtysh_exit_ripd_cmd
);
3185 install_element (RIP_NODE
, &vtysh_quit_ripd_cmd
);
3186 install_element (RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
3187 install_element (RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
3188 install_element (OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
3189 install_element (OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
3190 install_element (OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
3191 install_element (OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
3192 #if defined (HAVE_LDPD)
3193 install_element (LDP_NODE
, &vtysh_exit_ldpd_cmd
);
3194 install_element (LDP_NODE
, &vtysh_quit_ldpd_cmd
);
3195 install_element (LDP_IPV4_NODE
, &vtysh_exit_ldpd_cmd
);
3196 install_element (LDP_IPV4_NODE
, &vtysh_quit_ldpd_cmd
);
3197 install_element (LDP_IPV6_NODE
, &vtysh_exit_ldpd_cmd
);
3198 install_element (LDP_IPV6_NODE
, &vtysh_quit_ldpd_cmd
);
3199 install_element (LDP_IPV4_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3200 install_element (LDP_IPV4_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3201 install_element (LDP_IPV6_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3202 install_element (LDP_IPV6_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3203 install_element (LDP_L2VPN_NODE
, &vtysh_exit_ldpd_cmd
);
3204 install_element (LDP_L2VPN_NODE
, &vtysh_quit_ldpd_cmd
);
3205 install_element (LDP_PSEUDOWIRE_NODE
, &vtysh_exit_ldpd_cmd
);
3206 install_element (LDP_PSEUDOWIRE_NODE
, &vtysh_quit_ldpd_cmd
);
3208 install_element (BGP_NODE
, &vtysh_exit_bgpd_cmd
);
3209 install_element (BGP_NODE
, &vtysh_quit_bgpd_cmd
);
3210 install_element (BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
3211 install_element (BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
3212 install_element (BGP_VPNV6_NODE
, &vtysh_exit_bgpd_cmd
);
3213 install_element (BGP_VPNV6_NODE
, &vtysh_quit_bgpd_cmd
);
3214 install_element (BGP_ENCAP_NODE
, &vtysh_exit_bgpd_cmd
);
3215 install_element (BGP_ENCAP_NODE
, &vtysh_quit_bgpd_cmd
);
3216 install_element (BGP_ENCAPV6_NODE
, &vtysh_exit_bgpd_cmd
);
3217 install_element (BGP_ENCAPV6_NODE
, &vtysh_quit_bgpd_cmd
);
3218 install_element (BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
3219 install_element (BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
3220 install_element (BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
3221 install_element (BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
3222 install_element (BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
3223 install_element (BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
3224 install_element (BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
3225 install_element (BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
3226 install_element (BGP_EVPN_NODE
, &vtysh_quit_bgpd_cmd
);
3227 #if defined (ENABLE_BGP_VNC)
3228 install_element (BGP_VRF_POLICY_NODE
, &vtysh_exit_bgpd_cmd
);
3229 install_element (BGP_VRF_POLICY_NODE
, &vtysh_quit_bgpd_cmd
);
3230 install_element (BGP_VNC_DEFAULTS_NODE
, &vtysh_exit_bgpd_cmd
);
3231 install_element (BGP_VNC_DEFAULTS_NODE
, &vtysh_quit_bgpd_cmd
);
3232 install_element (BGP_VNC_NVE_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3233 install_element (BGP_VNC_NVE_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3234 install_element (BGP_VNC_L2_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3235 install_element (BGP_VNC_L2_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3237 install_element (ISIS_NODE
, &vtysh_exit_isisd_cmd
);
3238 install_element (ISIS_NODE
, &vtysh_quit_isisd_cmd
);
3239 install_element (KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
3240 install_element (KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
3241 install_element (KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
3242 install_element (KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
3243 install_element (RMAP_NODE
, &vtysh_exit_rmap_cmd
);
3244 install_element (RMAP_NODE
, &vtysh_quit_rmap_cmd
);
3245 install_element (VTY_NODE
, &vtysh_exit_line_vty_cmd
);
3246 install_element (VTY_NODE
, &vtysh_quit_line_vty_cmd
);
3248 /* "end" command. */
3249 install_element (CONFIG_NODE
, &vtysh_end_all_cmd
);
3250 install_element (ENABLE_NODE
, &vtysh_end_all_cmd
);
3251 install_element (RIP_NODE
, &vtysh_end_all_cmd
);
3252 install_element (RIPNG_NODE
, &vtysh_end_all_cmd
);
3253 install_element (OSPF_NODE
, &vtysh_end_all_cmd
);
3254 install_element (OSPF6_NODE
, &vtysh_end_all_cmd
);
3255 install_element (LDP_NODE
, &vtysh_end_all_cmd
);
3256 install_element (LDP_IPV4_NODE
, &vtysh_end_all_cmd
);
3257 install_element (LDP_IPV6_NODE
, &vtysh_end_all_cmd
);
3258 install_element (LDP_IPV4_IFACE_NODE
, &vtysh_end_all_cmd
);
3259 install_element (LDP_IPV6_IFACE_NODE
, &vtysh_end_all_cmd
);
3260 install_element (LDP_L2VPN_NODE
, &vtysh_end_all_cmd
);
3261 install_element (LDP_PSEUDOWIRE_NODE
, &vtysh_end_all_cmd
);
3262 install_element (BGP_NODE
, &vtysh_end_all_cmd
);
3263 install_element (BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
3264 install_element (BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
3265 install_element (BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
3266 install_element (BGP_VPNV6_NODE
, &vtysh_end_all_cmd
);
3267 install_element (BGP_ENCAP_NODE
, &vtysh_end_all_cmd
);
3268 install_element (BGP_ENCAPV6_NODE
, &vtysh_end_all_cmd
);
3269 install_element (BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
3270 install_element (BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
3271 install_element (BGP_VRF_POLICY_NODE
, &vtysh_end_all_cmd
);
3272 install_element (BGP_EVPN_NODE
, &vtysh_end_all_cmd
);
3273 install_element (BGP_VNC_DEFAULTS_NODE
, &vtysh_end_all_cmd
);
3274 install_element (BGP_VNC_NVE_GROUP_NODE
, &vtysh_end_all_cmd
);
3275 install_element (BGP_VNC_L2_GROUP_NODE
, &vtysh_end_all_cmd
);
3276 install_element (ISIS_NODE
, &vtysh_end_all_cmd
);
3277 install_element (KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
3278 install_element (KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
3279 install_element (RMAP_NODE
, &vtysh_end_all_cmd
);
3280 install_element (VTY_NODE
, &vtysh_end_all_cmd
);
3282 install_element (INTERFACE_NODE
, &vtysh_interface_desc_cmd
);
3283 install_element (INTERFACE_NODE
, &vtysh_no_interface_desc_cmd
);
3284 install_element (INTERFACE_NODE
, &vtysh_end_all_cmd
);
3285 install_element (INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
3286 install_element (LINK_PARAMS_NODE
, &exit_link_params_cmd
);
3287 install_element (LINK_PARAMS_NODE
, &vtysh_end_all_cmd
);
3288 install_element (LINK_PARAMS_NODE
, &vtysh_exit_interface_cmd
);
3289 install_element (INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
3291 install_element (NS_NODE
, &vtysh_end_all_cmd
);
3293 install_element (CONFIG_NODE
, &vtysh_ns_cmd
);
3294 install_element (NS_NODE
, &vtysh_exit_ns_cmd
);
3295 install_element (NS_NODE
, &vtysh_quit_ns_cmd
);
3297 install_element (VRF_NODE
, &vtysh_end_all_cmd
);
3298 install_element (VRF_NODE
, &vtysh_exit_vrf_cmd
);
3299 install_element (VRF_NODE
, &vtysh_quit_vrf_cmd
);
3301 install_element (CONFIG_NODE
, &router_rip_cmd
);
3302 install_element (CONFIG_NODE
, &router_ripng_cmd
);
3303 install_element (CONFIG_NODE
, &router_ospf_cmd
);
3304 install_element (CONFIG_NODE
, &router_ospf6_cmd
);
3305 #if defined (HAVE_LDPD)
3306 install_element (CONFIG_NODE
, &ldp_mpls_ldp_cmd
);
3307 install_element (LDP_NODE
, &ldp_address_family_ipv4_cmd
);
3308 install_element (LDP_NODE
, &ldp_address_family_ipv6_cmd
);
3309 install_element (LDP_IPV4_NODE
, &ldp_interface_ifname_cmd
);
3310 install_element (LDP_IPV6_NODE
, &ldp_interface_ifname_cmd
);
3311 install_element (CONFIG_NODE
, &ldp_l2vpn_word_type_vpls_cmd
);
3312 install_element (LDP_L2VPN_NODE
, &ldp_member_pseudowire_ifname_cmd
);
3314 install_element (CONFIG_NODE
, &router_isis_cmd
);
3315 install_element (CONFIG_NODE
, &router_bgp_cmd
);
3316 install_element (BGP_NODE
, &address_family_vpnv4_cmd
);
3317 install_element (BGP_NODE
, &address_family_vpnv6_cmd
);
3318 install_element (BGP_NODE
, &address_family_encapv4_cmd
);
3319 install_element (BGP_NODE
, &address_family_encapv6_cmd
);
3320 #if defined(ENABLE_BGP_VNC)
3321 install_element (BGP_NODE
, &vnc_vrf_policy_cmd
);
3322 install_element (BGP_NODE
, &vnc_defaults_cmd
);
3323 install_element (BGP_NODE
, &vnc_nve_group_cmd
);
3324 install_element (BGP_NODE
, &vnc_l2_group_cmd
);
3326 install_element (BGP_NODE
, &address_family_ipv4_unicast_cmd
);
3327 install_element (BGP_NODE
, &address_family_ipv6_cmd
);
3328 install_element (BGP_NODE
, &address_family_evpn_cmd
);
3329 install_element (BGP_VPNV4_NODE
, &exit_address_family_cmd
);
3330 install_element (BGP_VPNV6_NODE
, &exit_address_family_cmd
);
3331 install_element (BGP_ENCAP_NODE
, &exit_address_family_cmd
);
3332 install_element (BGP_ENCAPV6_NODE
, &exit_address_family_cmd
);
3333 install_element (BGP_IPV4_NODE
, &exit_address_family_cmd
);
3334 install_element (BGP_IPV4M_NODE
, &exit_address_family_cmd
);
3335 install_element (BGP_IPV6_NODE
, &exit_address_family_cmd
);
3336 install_element (BGP_IPV6M_NODE
, &exit_address_family_cmd
);
3337 install_element (BGP_EVPN_NODE
, &exit_address_family_cmd
);
3339 install_element (BGP_VRF_POLICY_NODE
, &exit_vrf_policy_cmd
);
3340 install_element (BGP_VNC_DEFAULTS_NODE
, &exit_vnc_config_cmd
);
3341 install_element (BGP_VNC_NVE_GROUP_NODE
, &exit_vnc_config_cmd
);
3342 install_element (BGP_VNC_L2_GROUP_NODE
, &exit_vnc_config_cmd
);
3344 install_element (CONFIG_NODE
, &key_chain_cmd
);
3345 install_element (CONFIG_NODE
, &vtysh_route_map_cmd
);
3346 install_element (CONFIG_NODE
, &vtysh_line_vty_cmd
);
3347 install_element (KEYCHAIN_NODE
, &key_cmd
);
3348 install_element (KEYCHAIN_NODE
, &key_chain_cmd
);
3349 install_element (KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
3350 install_element (CONFIG_NODE
, &vtysh_interface_cmd
);
3351 install_element (CONFIG_NODE
, &vtysh_no_interface_cmd
);
3352 install_element (CONFIG_NODE
, &vtysh_no_interface_vrf_cmd
);
3353 install_element (INTERFACE_NODE
, &vtysh_link_params_cmd
);
3354 install_element (ENABLE_NODE
, &vtysh_show_running_config_cmd
);
3355 install_element (ENABLE_NODE
, &vtysh_copy_running_config_cmd
);
3357 install_element (CONFIG_NODE
, &vtysh_vrf_cmd
);
3358 install_element (CONFIG_NODE
, &vtysh_no_vrf_cmd
);
3360 /* "write terminal" command. */
3361 install_element (ENABLE_NODE
, &vtysh_write_terminal_cmd
);
3363 install_element (CONFIG_NODE
, &vtysh_integrated_config_cmd
);
3364 install_element (CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
3366 /* "write memory" command. */
3367 install_element (ENABLE_NODE
, &vtysh_write_memory_cmd
);
3369 install_element (VIEW_NODE
, &vtysh_terminal_length_cmd
);
3370 install_element (VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
3371 install_element (VIEW_NODE
, &vtysh_show_daemons_cmd
);
3373 install_element (VIEW_NODE
, &vtysh_ping_cmd
);
3374 install_element (VIEW_NODE
, &vtysh_ping_ip_cmd
);
3375 install_element (VIEW_NODE
, &vtysh_traceroute_cmd
);
3376 install_element (VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
3377 install_element (VIEW_NODE
, &vtysh_ping6_cmd
);
3378 install_element (VIEW_NODE
, &vtysh_traceroute6_cmd
);
3379 #if defined(HAVE_SHELL_ACCESS)
3380 install_element (VIEW_NODE
, &vtysh_telnet_cmd
);
3381 install_element (VIEW_NODE
, &vtysh_telnet_port_cmd
);
3382 install_element (VIEW_NODE
, &vtysh_ssh_cmd
);
3384 #if defined(HAVE_SHELL_ACCESS)
3385 install_element (ENABLE_NODE
, &vtysh_start_shell_cmd
);
3386 install_element (ENABLE_NODE
, &vtysh_start_bash_cmd
);
3387 install_element (ENABLE_NODE
, &vtysh_start_zsh_cmd
);
3390 install_element (VIEW_NODE
, &vtysh_show_memory_cmd
);
3392 install_element (VIEW_NODE
, &vtysh_show_work_queues_cmd
);
3393 install_element (VIEW_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3395 install_element (VIEW_NODE
, &vtysh_show_thread_cmd
);
3398 install_element (VIEW_NODE
, &vtysh_show_logging_cmd
);
3399 install_element (CONFIG_NODE
, &vtysh_log_stdout_cmd
);
3400 install_element (CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
3401 install_element (CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
3402 install_element (CONFIG_NODE
, &vtysh_log_file_cmd
);
3403 install_element (CONFIG_NODE
, &vtysh_log_file_level_cmd
);
3404 install_element (CONFIG_NODE
, &no_vtysh_log_file_cmd
);
3405 install_element (CONFIG_NODE
, &vtysh_log_monitor_cmd
);
3406 install_element (CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
3407 install_element (CONFIG_NODE
, &vtysh_log_syslog_cmd
);
3408 install_element (CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
3409 install_element (CONFIG_NODE
, &vtysh_log_trap_cmd
);
3410 install_element (CONFIG_NODE
, &no_vtysh_log_trap_cmd
);
3411 install_element (CONFIG_NODE
, &vtysh_log_facility_cmd
);
3412 install_element (CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
3413 install_element (CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
3414 install_element (CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
3415 install_element (CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
3416 install_element (CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
3418 install_element (CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
3419 install_element (CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
3421 install_element (CONFIG_NODE
, &vtysh_password_cmd
);
3422 install_element (CONFIG_NODE
, &vtysh_password_text_cmd
);
3423 install_element (CONFIG_NODE
, &vtysh_enable_password_cmd
);
3424 install_element (CONFIG_NODE
, &vtysh_enable_password_text_cmd
);
3425 install_element (CONFIG_NODE
, &no_vtysh_enable_password_cmd
);