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
= "eigrpd", .flag
= VTYSH_EIGRPD
, .next
= NULL
},
79 { .fd
= -1, .name
= "watchfrr", .flag
= VTYSH_WATCHFRR
, .next
= NULL
},
82 enum vtysh_write_integrated vtysh_write_integrated
= WRITE_INTEGRATED_UNSPECIFIED
;
85 vclient_close (struct vtysh_client
*vclient
)
90 "Warning: closing connection to %s because of an I/O error!\n",
97 /* Return true if str begins with prefix, else return false */
99 begins_with(const char *str
, const char *prefix
)
103 size_t lenstr
= strlen(str
);
104 size_t lenprefix
= strlen(prefix
);
105 if (lenprefix
> lenstr
)
107 return strncmp(str
, prefix
, lenprefix
) == 0;
110 /* NB: multiplexed function:
111 * if fp == NULL, this calls vtysh_config_parse_line
112 * if fp != NULL, this prints lines to fp
115 vtysh_client_run (struct vtysh_client
*vclient
, const char *line
, FILE *fp
)
119 char *buf
= stackbuf
;
120 size_t bufsz
= sizeof(stackbuf
);
121 char *bufvalid
, *end
= NULL
;
122 char terminator
[3] = {0, 0, 0};
127 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
134 ssize_t nread
= read (vclient
->fd
, bufvalid
, buf
+ bufsz
- bufvalid
);
136 if (nread
< 0 && (errno
== EINTR
|| errno
== EAGAIN
))
141 fprintf (stderr
, "vtysh: error reading from %s: %s (%d)",
142 vclient
->name
, safe_strerror(errno
), errno
);
148 end
= memmem (buf
, bufvalid
- buf
, terminator
, sizeof(terminator
));
149 if (end
+ sizeof(terminator
) + 1 > bufvalid
)
150 /* found \0\0\0 but return code hasn't been read yet */
153 ret
= end
[sizeof(terminator
)];
155 while (bufvalid
> buf
&& (end
> buf
|| !end
))
157 size_t textlen
= (end
? end
: bufvalid
) - buf
;
158 char *eol
= memchr (buf
, '\n', textlen
);
163 /* no line break, end of input, no text left before end
164 * => don't insert an empty line at the end */
167 /* no line break, end of input, but some text left */
170 /* continue reading */
173 /* eol is at a line end now, either \n => \0 or \0\0\0 */
174 assert(eol
&& eol
<= bufvalid
);
182 vtysh_config_parse_line (buf
);
188 memmove (buf
, eol
, bufvalid
- eol
);
189 bufvalid
-= eol
- buf
;
194 if (bufvalid
== buf
+ bufsz
)
200 new = XMALLOC (MTYPE_TMP
, bufsz
);
201 memcpy (new, stackbuf
, sizeof(stackbuf
));
204 new = XREALLOC (MTYPE_TMP
, buf
, bufsz
);
206 bufvalid
= bufvalid
- buf
+ new;
208 /* if end != NULL, we won't be reading more data... */
209 assert (end
== NULL
);
216 vclient_close (vclient
);
220 XFREE (MTYPE_TMP
, buf
);
225 vtysh_client_run_all (struct vtysh_client
*head_client
, const char *line
,
226 int continue_on_err
, FILE *fp
)
228 struct vtysh_client
*client
;
229 int rc
, rc_all
= CMD_SUCCESS
;
231 for (client
= head_client
; client
; client
= client
->next
)
233 rc
= vtysh_client_run(client
, line
, fp
);
234 if (rc
!= CMD_SUCCESS
)
236 if (!continue_on_err
)
245 vtysh_client_execute (struct vtysh_client
*head_client
, const char *line
,
248 return vtysh_client_run_all (head_client
, line
, 0, fp
);
252 vtysh_client_config (struct vtysh_client
*head_client
, char *line
)
254 vtysh_client_run_all (head_client
, line
, 1, NULL
);
258 vtysh_pager_init (void)
262 pager_defined
= getenv ("VTYSH_PAGER");
265 vtysh_pager_name
= strdup (pager_defined
);
267 vtysh_pager_name
= strdup ("more");
270 /* Command execution over the vty interface. */
272 vtysh_execute_func (const char *line
, int pager
)
277 const struct cmd_element
*cmd
;
281 int saved_ret
, saved_node
;
283 /* Split readline string up into the vector. */
284 vline
= cmd_make_strvec (line
);
289 saved_ret
= ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
290 saved_node
= vty
->node
;
292 /* If command doesn't succeeded in current node, try to walk up in node tree.
293 * Changing vty->node is enough to try it just out without actual walkup in
295 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
296 && vty
->node
> CONFIG_NODE
)
298 vty
->node
= node_parent(vty
->node
);
299 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
303 vty
->node
= saved_node
;
305 /* If command succeeded in any other node than current (tried > 0) we have
306 * to move into node in the vtysh where it succeeded. */
307 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
309 if ((saved_node
== BGP_VPNV4_NODE
|| saved_node
== BGP_VPNV6_NODE
310 || saved_node
== BGP_ENCAP_NODE
|| saved_node
== BGP_ENCAPV6_NODE
311 || saved_node
== BGP_IPV4_NODE
312 || saved_node
== BGP_IPV6_NODE
|| saved_node
== BGP_IPV4M_NODE
313 || saved_node
== BGP_IPV6M_NODE
|| saved_node
== BGP_EVPN_NODE
)
316 vtysh_execute("exit-address-family");
318 else if (saved_node
== BGP_VRF_POLICY_NODE
&& (tried
== 1))
320 vtysh_execute("exit-vrf-policy");
322 else if ((saved_node
== BGP_VNC_DEFAULTS_NODE
323 || saved_node
== BGP_VNC_NVE_GROUP_NODE
324 || saved_node
== BGP_VNC_L2_GROUP_NODE
) && (tried
== 1))
326 vtysh_execute("exit-vnc");
328 else if ((saved_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
330 vtysh_execute("exit");
334 vtysh_execute ("end");
335 vtysh_execute ("configure terminal");
338 /* If command didn't succeed in any node, continue with return value from
345 cmd_free_strvec (vline
);
351 if (vty
->type
== VTY_FILE
)
352 fprintf (stdout
,"Warning...\n");
354 case CMD_ERR_AMBIGUOUS
:
355 fprintf (stdout
,"%% Ambiguous command.\n");
357 case CMD_ERR_NO_MATCH
:
358 fprintf (stdout
,"%% Unknown command.\n");
360 case CMD_ERR_INCOMPLETE
:
361 fprintf (stdout
,"%% Command incomplete.\n");
363 case CMD_SUCCESS_DAEMON
:
365 /* FIXME: Don't open pager for exit commands. popen() causes problems
366 * if exited from vtysh at all. This hack shouldn't cause any problem
367 * but is really ugly. */
368 if (pager
&& vtysh_pager_name
&& (strncmp(line
, "exit", 4) != 0))
370 fp
= popen (vtysh_pager_name
, "w");
373 perror ("popen failed for pager");
382 if (! strcmp(cmd
->string
,"configure terminal"))
384 for (i
= 0; i
< array_size(vtysh_client
); i
++)
386 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
387 if (cmd_stat
== CMD_WARNING
)
394 vline
= cmd_make_strvec (line
);
398 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
400 if (pclose (fp
) == -1)
402 perror ("pclose failed for pager");
409 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
410 cmd_free_strvec (vline
);
411 if (ret
!= CMD_SUCCESS_DAEMON
)
417 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
422 cmd_stat
= CMD_SUCCESS
;
423 for (i
= 0; i
< array_size(vtysh_client
); i
++)
425 if (cmd
->daemon
& vtysh_client
[i
].flag
)
427 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
428 if (cmd_stat
!= CMD_SUCCESS
)
432 if (cmd_stat
!= CMD_SUCCESS
)
436 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
439 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
441 if (pclose (fp
) == -1)
443 perror ("pclose failed for pager");
451 vtysh_execute_no_pager (const char *line
)
453 return vtysh_execute_func (line
, 0);
457 vtysh_execute (const char *line
)
459 return vtysh_execute_func (line
, 1);
474 while (end
>= s
&& isspace(*end
))
478 while (*s
&& isspace(*s
))
485 vtysh_mark_file (const char *filename
)
492 const struct cmd_element
*cmd
;
493 int saved_ret
, prev_node
;
495 char *vty_buf_copy
= NULL
;
496 char *vty_buf_trimmed
= NULL
;
498 if (strncmp("-", filename
, 1) == 0)
501 confp
= fopen (filename
, "r");
505 fprintf (stderr
, "%% Can't open config file %s due to '%s'.\n",
506 filename
, safe_strerror (errno
));
507 return (CMD_ERR_NO_FILE
);
511 vty
->fd
= 0; /* stdout */
512 vty
->type
= VTY_TERM
;
513 vty
->node
= CONFIG_NODE
;
515 vtysh_execute_no_pager ("enable");
516 vtysh_execute_no_pager ("configure terminal");
517 vty_buf_copy
= XCALLOC (MTYPE_VTYSH_CMD
, VTY_BUFSIZ
);
519 while (fgets (vty
->buf
, VTY_BUFSIZ
, confp
))
523 strcpy(vty_buf_copy
, vty
->buf
);
524 vty_buf_trimmed
= trim(vty_buf_copy
);
526 if (vty_buf_trimmed
[0] == '!' || vty_buf_trimmed
[0] == '#')
528 fprintf(stdout
, "%s", vty
->buf
);
532 /* Split readline string up into the vector. */
533 vline
= cmd_make_strvec (vty
->buf
);
537 fprintf(stdout
, "%s", vty
->buf
);
541 /* Ignore the "end" lines, we will generate these where appropriate */
542 if (strlen(vty_buf_trimmed
) == 3 && strncmp("end", vty_buf_trimmed
, 3) == 0)
547 prev_node
= vty
->node
;
548 saved_ret
= ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
550 /* If command doesn't succeeded in current node, try to walk up in node tree.
551 * Changing vty->node is enough to try it just out without actual walkup in
553 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
554 && vty
->node
> CONFIG_NODE
)
556 vty
->node
= node_parent(vty
->node
);
557 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
561 /* If command succeeded in any other node than current (tried > 0) we have
562 * to move into node in the vtysh where it succeeded. */
563 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
565 if ((prev_node
== BGP_VPNV4_NODE
|| prev_node
== BGP_IPV4_NODE
566 || prev_node
== BGP_IPV6_NODE
|| prev_node
== BGP_IPV4M_NODE
567 || prev_node
== BGP_IPV6M_NODE
|| prev_node
== BGP_VPNV6_NODE
568 || prev_node
== BGP_EVPN_NODE
)
571 fprintf(stdout
, "exit-address-family\n");
573 else if ((prev_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
575 fprintf(stdout
, "exit\n");
579 fprintf(stdout
, "end\n");
582 /* If command didn't succeed in any node, continue with return value from
587 vty
->node
= prev_node
;
590 cmd_free_strvec (vline
);
594 if (vty
->type
== VTY_FILE
)
595 fprintf (stderr
,"line %d: Warning...: %s\n", lineno
, vty
->buf
);
598 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
600 case CMD_ERR_AMBIGUOUS
:
601 fprintf (stderr
,"line %d: %% Ambiguous command: %s\n", lineno
, vty
->buf
);
604 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
605 return CMD_ERR_AMBIGUOUS
;
606 case CMD_ERR_NO_MATCH
:
607 fprintf (stderr
,"line %d: %% Unknown command: %s\n", lineno
, vty
->buf
);
610 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
611 return CMD_ERR_NO_MATCH
;
612 case CMD_ERR_INCOMPLETE
:
613 fprintf (stderr
,"line %d: %% Command incomplete: %s\n", lineno
, vty
->buf
);
616 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
617 return CMD_ERR_INCOMPLETE
;
619 fprintf(stdout
, "%s", vty
->buf
);
621 case CMD_SUCCESS_DAEMON
:
624 int cmd_stat
= CMD_SUCCESS
;
626 fprintf(stdout
, "%s", vty
->buf
);
627 for (i
= 0; i
< array_size(vtysh_client
); i
++)
629 if (cmd
->daemon
& vtysh_client
[i
].flag
)
631 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
633 if (cmd_stat
!= CMD_SUCCESS
)
637 if (cmd_stat
!= CMD_SUCCESS
)
641 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
645 /* This is the end */
646 fprintf(stdout
, "end\n");
648 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
656 /* Configration make from file. */
658 vtysh_config_from_file (struct vty
*vty
, FILE *fp
)
661 const struct cmd_element
*cmd
;
663 int retcode
= CMD_SUCCESS
;
665 while (fgets (vty
->buf
, VTY_BUFSIZ
, fp
))
669 ret
= command_config_read_one_line (vty
, &cmd
, 1);
674 if (vty
->type
== VTY_FILE
)
675 fprintf (stderr
,"line %d: Warning[%d]...: %s\n", lineno
, vty
->node
, vty
->buf
);
676 retcode
= CMD_WARNING
; /* once we have an error, we remember & return that */
678 case CMD_ERR_AMBIGUOUS
:
679 fprintf (stderr
,"line %d: %% Ambiguous command[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
680 retcode
= CMD_ERR_AMBIGUOUS
; /* once we have an error, we remember & return that */
682 case CMD_ERR_NO_MATCH
:
683 fprintf (stderr
,"line %d: %% Unknown command[%d]: %s", lineno
, vty
->node
, vty
->buf
);
684 retcode
= CMD_ERR_NO_MATCH
; /* once we have an error, we remember & return that */
686 case CMD_ERR_INCOMPLETE
:
687 fprintf (stderr
,"line %d: %% Command incomplete[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
688 retcode
= CMD_ERR_INCOMPLETE
; /* once we have an error, we remember & return that */
690 case CMD_SUCCESS_DAEMON
:
693 int cmd_stat
= CMD_SUCCESS
;
695 for (i
= 0; i
< array_size(vtysh_client
); i
++)
697 if (cmd
->daemon
& vtysh_client
[i
].flag
)
699 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
702 * CMD_WARNING - Can mean that the command was
703 * parsed successfully but it was already entered
704 * in a few spots. As such if we receive a
705 * CMD_WARNING from a daemon we shouldn't stop
706 * talking to the other daemons for the particular
709 if (cmd_stat
!= CMD_SUCCESS
&& cmd_stat
!= CMD_WARNING
)
711 fprintf (stderr
, "line %d: Failure to communicate[%d] to %s, line: %s\n",
712 lineno
, cmd_stat
, vtysh_client
[i
].name
, vty
->buf
);
717 if (cmd_stat
!= CMD_SUCCESS
)
721 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
729 /* We don't care about the point of the cursor when '?' is typed. */
731 vtysh_rl_describe (void)
738 struct cmd_token
*token
;
740 vline
= cmd_make_strvec (rl_line_buffer
);
742 /* In case of '> ?'. */
745 vline
= vector_init (1);
746 vector_set (vline
, NULL
);
749 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
750 vector_set (vline
, NULL
);
752 describe
= cmd_describe_command (vline
, vty
, &ret
);
754 fprintf (stdout
,"\n");
756 /* Ambiguous and no match error. */
759 case CMD_ERR_AMBIGUOUS
:
760 cmd_free_strvec (vline
);
761 fprintf (stdout
,"%% Ambiguous command.\n");
765 case CMD_ERR_NO_MATCH
:
766 cmd_free_strvec (vline
);
767 fprintf (stdout
,"%% There is no matched command.\n");
773 /* Get width of command string. */
775 for (i
= 0; i
< vector_active (describe
); i
++)
776 if ((token
= vector_slot (describe
, i
)) != NULL
)
778 if (token
->text
[0] == '\0')
781 int len
= strlen (token
->text
);
787 for (i
= 0; i
< vector_active (describe
); i
++)
788 if ((token
= vector_slot (describe
, i
)) != NULL
)
791 fprintf (stdout
," %-s\n",
794 fprintf (stdout
," %-*s %s\n",
800 cmd_free_strvec (vline
);
801 vector_free (describe
);
808 /* Result of cmd_complete_command() call will be stored here
809 * and used in new_completion() in order to put the space in
810 * correct places only. */
814 command_generator (const char *text
, int state
)
817 static char **matched
= NULL
;
818 static int index
= 0;
825 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
828 vline
= cmd_make_strvec (rl_line_buffer
);
832 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
833 vector_set (vline
, NULL
);
835 matched
= cmd_complete_command (vline
, vty
, &complete_status
);
836 cmd_free_strvec (vline
);
839 if (matched
&& matched
[index
])
840 return matched
[index
++];
842 XFREE (MTYPE_TMP
, matched
);
849 new_completion (char *text
, int start
, int end
)
853 matches
= rl_completion_matches (text
, command_generator
);
858 if (complete_status
!= CMD_COMPLETE_FULL_MATCH
)
859 /* only append a space on full match */
860 rl_completion_append_character
= '\0';
866 /* Vty node structures. */
867 static struct cmd_node bgp_node
=
870 "%s(config-router)# ",
873 static struct cmd_node rip_node
=
876 "%s(config-router)# ",
879 static struct cmd_node isis_node
=
882 "%s(config-router)# ",
885 static struct cmd_node interface_node
=
891 static struct cmd_node ns_node
=
894 "%s(config-logical-router)# ",
897 static struct cmd_node vrf_node
=
903 static struct cmd_node rmap_node
=
906 "%s(config-route-map)# "
909 static struct cmd_node zebra_node
=
912 "%s(config-router)# "
915 static struct cmd_node bgp_vpnv4_node
=
918 "%s(config-router-af)# "
921 static struct cmd_node bgp_vpnv6_node
=
924 "%s(config-router-af)# "
927 static struct cmd_node bgp_encap_node
=
930 "%s(config-router-af)# "
933 static struct cmd_node bgp_encapv6_node
=
936 "%s(config-router-af)# "
939 static struct cmd_node bgp_ipv4_node
=
942 "%s(config-router-af)# "
945 static struct cmd_node bgp_ipv4m_node
=
948 "%s(config-router-af)# "
951 static struct cmd_node bgp_ipv6_node
=
954 "%s(config-router-af)# "
957 static struct cmd_node bgp_ipv6m_node
=
960 "%s(config-router-af)# "
963 static struct cmd_node bgp_evpn_node
=
966 "%s(config-router-af)# "
969 static struct cmd_node bgp_vnc_defaults_node
=
971 BGP_VNC_DEFAULTS_NODE
,
972 "%s(config-router-vnc-defaults)# "
975 static struct cmd_node bgp_vnc_nve_group_node
=
977 BGP_VNC_NVE_GROUP_NODE
,
978 "%s(config-router-vnc-nve-group)# "
981 static struct cmd_node bgp_vrf_policy_node
= {
983 "%s(config-router-vrf-policy)# "
986 static struct cmd_node bgp_vnc_l2_group_node
=
988 BGP_VNC_L2_GROUP_NODE
,
989 "%s(config-router-vnc-l2-group)# "
992 static struct cmd_node ospf_node
=
995 "%s(config-router)# "
998 static struct cmd_node eigrp_node
=
1001 "%s(config-router)# "
1004 static struct cmd_node ripng_node
=
1007 "%s(config-router)# "
1010 static struct cmd_node ospf6_node
=
1013 "%s(config-ospf6)# "
1016 static struct cmd_node ldp_node
=
1022 static struct cmd_node ldp_ipv4_node
=
1025 "%s(config-ldp-af)# "
1028 static struct cmd_node ldp_ipv6_node
=
1031 "%s(config-ldp-af)# "
1034 static struct cmd_node ldp_ipv4_iface_node
=
1036 LDP_IPV4_IFACE_NODE
,
1037 "%s(config-ldp-af-if)# "
1040 static struct cmd_node ldp_ipv6_iface_node
=
1042 LDP_IPV6_IFACE_NODE
,
1043 "%s(config-ldp-af-if)# "
1046 static struct cmd_node ldp_l2vpn_node
=
1049 "%s(config-l2vpn)# "
1052 static struct cmd_node ldp_pseudowire_node
=
1054 LDP_PSEUDOWIRE_NODE
,
1055 "%s(config-l2vpn-pw)# "
1058 static struct cmd_node keychain_node
=
1061 "%s(config-keychain)# "
1064 static struct cmd_node keychain_key_node
=
1067 "%s(config-keychain-key)# "
1070 struct cmd_node link_params_node
=
1073 "%s(config-link-params)# ",
1076 /* Defined in lib/vty.c */
1077 extern struct cmd_node vty_node
;
1079 /* When '^Z' is received from vty, move down to the enable mode. */
1087 /* Nothing to do. */
1090 vty
->node
= ENABLE_NODE
;
1096 DEFUNSH (VTYSH_REALLYALL
,
1100 "End current mode and change to enable mode\n")
1102 return vtysh_end ();
1105 DEFUNSH (VTYSH_BGPD
,
1108 "router bgp [(1-4294967295) [<view|vrf> WORD]]",
1112 "BGP view\nBGP VRF\n"
1115 vty
->node
= BGP_NODE
;
1119 DEFUNSH (VTYSH_BGPD
,
1120 address_family_vpnv4
,
1121 address_family_vpnv4_cmd
,
1122 "address-family vpnv4 [unicast]",
1123 "Enter Address Family command mode\n"
1125 "Address Family Modifier\n")
1127 vty
->node
= BGP_VPNV4_NODE
;
1131 DEFUNSH (VTYSH_BGPD
,
1132 address_family_vpnv6
,
1133 address_family_vpnv6_cmd
,
1134 "address-family vpnv6 [unicast]",
1135 "Enter Address Family command mode\n"
1137 "Address Family Modifier\n")
1139 vty
->node
= BGP_VPNV6_NODE
;
1143 DEFUNSH (VTYSH_BGPD
,
1144 address_family_encapv4
,
1145 address_family_encapv4_cmd
,
1146 "address-family <encap|encapv4>",
1147 "Enter Address Family command mode\n"
1151 vty
->node
= BGP_ENCAP_NODE
;
1155 DEFUNSH (VTYSH_BGPD
,
1156 address_family_encapv6
,
1157 address_family_encapv6_cmd
,
1158 "address-family encapv6",
1159 "Enter Address Family command mode\n"
1162 vty
->node
= BGP_ENCAPV6_NODE
;
1166 DEFUNSH (VTYSH_BGPD
,
1167 address_family_ipv4_unicast
,
1168 address_family_ipv4_unicast_cmd
,
1169 "address-family ipv4 [<unicast|multicast|vpn|encap>]",
1170 "Enter Address Family command mode\n"
1172 "Address Family Modifier\n"
1173 "Address Family Modifier\n"
1174 "Address Family Modifier\n"
1175 "Address Family Modifier\n")
1179 if (argv_find (argv
, argc
, "multicast", &idx
))
1180 vty
->node
= BGP_IPV4M_NODE
;
1182 else if (argv_find (argv
, argc
, "encap", &idx
))
1183 vty
->node
= BGP_ENCAP_NODE
;
1185 else if (argv_find (argv
, argc
, "vpn", &idx
))
1186 vty
->node
= BGP_VPNV4_NODE
;
1189 vty
->node
= BGP_IPV4_NODE
;
1194 DEFUNSH (VTYSH_BGPD
,
1195 address_family_ipv6
,
1196 address_family_ipv6_cmd
,
1197 "address-family ipv6 [<unicast|multicast|vpn|encap>]",
1198 "Enter Address Family command mode\n"
1200 "Address Family Modifier\n"
1201 "Address Family Modifier\n"
1202 "Address Family Modifier\n"
1203 "Address Family Modifier\n")
1207 if (argv_find (argv
, argc
, "multicast", &idx
))
1208 vty
->node
= BGP_IPV6M_NODE
;
1210 else if (argv_find (argv
, argc
, "encap", &idx
))
1211 vty
->node
= BGP_ENCAPV6_NODE
;
1213 else if (argv_find (argv
, argc
, "vpn", &idx
))
1214 vty
->node
= BGP_VPNV6_NODE
;
1217 vty
->node
= BGP_IPV6_NODE
;
1222 DEFUNSH (VTYSH_BGPD
,
1223 address_family_evpn
,
1224 address_family_evpn_cmd
,
1225 "address-family <l2vpn evpn>",
1226 "Enter Address Family command mode\n"
1227 "EVPN Address family\n"
1228 "Layer2 VPN Address family\n"
1229 "Ethernet Virtual Private Network Subsequent Address Family\n")
1231 #if defined(HAVE_EVPN)
1232 vty
->node
= BGP_EVPN_NODE
;
1233 #endif /* HAVE_EVPN */
1237 #if defined (ENABLE_BGP_VNC)
1238 DEFUNSH (VTYSH_BGPD
,
1242 "VNC/RFP related configuration\n"
1243 "Configure default NVE group\n")
1245 vty
->node
= BGP_VNC_DEFAULTS_NODE
;
1249 DEFUNSH (VTYSH_BGPD
,
1252 "vnc nve-group NAME",
1253 "VNC/RFP related configuration\n"
1254 "Configure a NVE group\n"
1257 vty
->node
= BGP_VNC_NVE_GROUP_NODE
;
1261 DEFUNSH (VTYSH_BGPD
,
1265 "Configure a VRF policy group\n"
1268 vty
->node
= BGP_VRF_POLICY_NODE
;
1272 DEFUNSH (VTYSH_BGPD
,
1275 "vnc l2-group NAME",
1276 "VNC/RFP related configuration\n"
1277 "Configure a L2 group\n"
1280 vty
->node
= BGP_VNC_L2_GROUP_NODE
;
1285 DEFUNSH (VTYSH_RIPD
,
1289 "Authentication key management\n"
1290 "Key-chain management\n"
1293 vty
->node
= KEYCHAIN_NODE
;
1297 DEFUNSH (VTYSH_RIPD
,
1300 "key (0-2147483647)",
1302 "Key identifier number\n")
1304 vty
->node
= KEYCHAIN_KEY_NODE
;
1308 DEFUNSH (VTYSH_RIPD
,
1315 vty
->node
= RIP_NODE
;
1319 DEFUNSH (VTYSH_RIPNGD
,
1326 vty
->node
= RIPNG_NODE
;
1330 DEFUNSH (VTYSH_OSPFD
,
1333 "router ospf [(1-65535)]",
1334 "Enable a routing process\n"
1335 "Start OSPF configuration\n"
1338 vty
->node
= OSPF_NODE
;
1342 DEFUNSH (VTYSH_EIGRPD
,
1345 "router eigrp (1-65535)",
1346 "Enable a routing process\n"
1347 "Start EIGRP configuration\n"
1348 "AS number to use\n")
1350 vty
->node
= EIGRP_NODE
;
1354 DEFUNSH (VTYSH_OSPF6D
,
1361 vty
->node
= OSPF6_NODE
;
1365 #if defined (HAVE_LDPD)
1366 DEFUNSH (VTYSH_LDPD
,
1370 "Global MPLS configuration subcommands\n"
1371 "Label Distribution Protocol\n")
1373 vty
->node
= LDP_NODE
;
1377 DEFUNSH (VTYSH_LDPD
,
1378 ldp_address_family_ipv4
,
1379 ldp_address_family_ipv4_cmd
,
1380 "address-family ipv4",
1381 "Configure Address Family and its parameters\n"
1384 vty
->node
= LDP_IPV4_NODE
;
1388 DEFUNSH (VTYSH_LDPD
,
1389 ldp_address_family_ipv6
,
1390 ldp_address_family_ipv6_cmd
,
1391 "address-family ipv6",
1392 "Configure Address Family and its parameters\n"
1395 vty
->node
= LDP_IPV6_NODE
;
1399 DEFUNSH (VTYSH_LDPD
,
1400 ldp_interface_ifname
,
1401 ldp_interface_ifname_cmd
,
1403 "Enable LDP on an interface and enter interface submode\n"
1404 "Interface's name\n")
1409 vty
->node
= LDP_IPV4_IFACE_NODE
;
1412 vty
->node
= LDP_IPV6_IFACE_NODE
;
1421 DEFUNSH (VTYSH_LDPD
,
1422 ldp_l2vpn_word_type_vpls
,
1423 ldp_l2vpn_word_type_vpls_cmd
,
1424 "l2vpn WORD type vpls",
1425 "Configure l2vpn commands\n"
1428 "Virtual Private LAN Service\n")
1430 vty
->node
= LDP_L2VPN_NODE
;
1434 DEFUNSH (VTYSH_LDPD
,
1435 ldp_member_pseudowire_ifname
,
1436 ldp_member_pseudowire_ifname_cmd
,
1437 "member pseudowire IFNAME",
1438 "L2VPN member configuration\n"
1439 "Pseudowire interface\n"
1440 "Interface's name\n")
1442 vty
->node
= LDP_PSEUDOWIRE_NODE
;
1447 DEFUNSH (VTYSH_ISISD
,
1453 "ISO Routing area tag")
1455 vty
->node
= ISIS_NODE
;
1459 DEFUNSH (VTYSH_RMAP
,
1461 vtysh_route_map_cmd
,
1462 "route-map WORD <deny|permit> (1-65535)",
1463 "Create route-map or enter route-map command mode\n"
1465 "Route map denies set operations\n"
1466 "Route map permits set operations\n"
1467 "Sequence to insert to/delete from existing route-map entry\n")
1469 vty
->node
= RMAP_NODE
;
1477 "Configure a terminal line\n"
1478 "Virtual terminal\n")
1480 vty
->node
= VTY_NODE
;
1484 DEFUNSH (VTYSH_REALLYALL
,
1488 "Turn on privileged mode command\n")
1490 vty
->node
= ENABLE_NODE
;
1494 DEFUNSH (VTYSH_REALLYALL
,
1498 "Turn off privileged mode command\n")
1500 if (vty
->node
== ENABLE_NODE
)
1501 vty
->node
= VIEW_NODE
;
1505 DEFUNSH (VTYSH_REALLYALL
,
1506 vtysh_config_terminal
,
1507 vtysh_config_terminal_cmd
,
1508 "configure terminal",
1509 "Configuration from vty interface\n"
1510 "Configuration terminal\n")
1512 vty
->node
= CONFIG_NODE
;
1517 vtysh_exit (struct vty
*vty
)
1526 vty
->node
= ENABLE_NODE
;
1528 case INTERFACE_NODE
:
1539 case LDP_L2VPN_NODE
:
1545 vtysh_execute("end");
1546 vtysh_execute("configure terminal");
1547 vty
->node
= CONFIG_NODE
;
1549 case BGP_VPNV4_NODE
:
1550 case BGP_VPNV6_NODE
:
1551 case BGP_ENCAP_NODE
:
1552 case BGP_ENCAPV6_NODE
:
1554 case BGP_IPV4M_NODE
:
1556 case BGP_IPV6M_NODE
:
1557 case BGP_VRF_POLICY_NODE
:
1559 case BGP_VNC_DEFAULTS_NODE
:
1560 case BGP_VNC_NVE_GROUP_NODE
:
1561 case BGP_VNC_L2_GROUP_NODE
:
1562 vty
->node
= BGP_NODE
;
1566 vty
->node
= LDP_NODE
;
1568 case LDP_IPV4_IFACE_NODE
:
1569 vty
->node
= LDP_IPV4_NODE
;
1571 case LDP_IPV6_IFACE_NODE
:
1572 vty
->node
= LDP_IPV6_NODE
;
1574 case LDP_PSEUDOWIRE_NODE
:
1575 vty
->node
= LDP_L2VPN_NODE
;
1577 case KEYCHAIN_KEY_NODE
:
1578 vty
->node
= KEYCHAIN_NODE
;
1580 case LINK_PARAMS_NODE
:
1581 vty
->node
= INTERFACE_NODE
;
1589 DEFUNSH (VTYSH_REALLYALL
,
1593 "Exit current mode and down to previous mode\n")
1595 return vtysh_exit (vty
);
1602 "Exit current mode and down to previous mode\n")
1604 return vtysh_exit_all (self
, vty
, argc
, argv
);
1607 DEFUNSH (VTYSH_BGPD
,
1608 exit_address_family
,
1609 exit_address_family_cmd
,
1610 "exit-address-family",
1611 "Exit from Address Family configuration mode\n")
1613 if (vty
->node
== BGP_IPV4_NODE
1614 || vty
->node
== BGP_IPV4M_NODE
1615 || vty
->node
== BGP_VPNV4_NODE
1616 || vty
->node
== BGP_VPNV6_NODE
1617 || vty
->node
== BGP_ENCAP_NODE
1618 || vty
->node
== BGP_ENCAPV6_NODE
1619 || vty
->node
== BGP_IPV6_NODE
1620 || vty
->node
== BGP_IPV6M_NODE
)
1621 vty
->node
= BGP_NODE
;
1625 DEFUNSH (VTYSH_BGPD
,
1627 exit_vnc_config_cmd
,
1629 "Exit from VNC configuration mode\n")
1631 if (vty
->node
== BGP_VNC_DEFAULTS_NODE
1632 || vty
->node
== BGP_VNC_NVE_GROUP_NODE
1633 || vty
->node
== BGP_VNC_L2_GROUP_NODE
)
1634 vty
->node
= BGP_NODE
;
1638 DEFUNSH (VTYSH_BGPD
,
1640 exit_vrf_policy_cmd
,
1642 "Exit from VRF configuration mode\n")
1644 if (vty
->node
== BGP_VRF_POLICY_NODE
)
1645 vty
->node
= BGP_NODE
;
1649 DEFUNSH (VTYSH_RIPD
,
1651 vtysh_exit_ripd_cmd
,
1653 "Exit current mode and down to previous mode\n")
1655 return vtysh_exit (vty
);
1658 DEFUNSH (VTYSH_RIPD
,
1660 vtysh_quit_ripd_cmd
,
1662 "Exit current mode and down to previous mode\n")
1664 return vtysh_exit_ripd (self
, vty
, argc
, argv
);
1667 DEFUNSH (VTYSH_RIPNGD
,
1669 vtysh_exit_ripngd_cmd
,
1671 "Exit current mode and down to previous mode\n")
1673 return vtysh_exit (vty
);
1676 DEFUNSH (VTYSH_RIPNGD
,
1678 vtysh_quit_ripngd_cmd
,
1680 "Exit current mode and down to previous mode\n")
1682 return vtysh_exit_ripngd (self
, vty
, argc
, argv
);
1685 DEFUNSH (VTYSH_RMAP
,
1687 vtysh_exit_rmap_cmd
,
1689 "Exit current mode and down to previous mode\n")
1691 return vtysh_exit (vty
);
1694 DEFUNSH (VTYSH_RMAP
,
1696 vtysh_quit_rmap_cmd
,
1698 "Exit current mode and down to previous mode\n")
1700 return vtysh_exit_rmap (self
, vty
, argc
, argv
);
1703 DEFUNSH (VTYSH_BGPD
,
1705 vtysh_exit_bgpd_cmd
,
1707 "Exit current mode and down to previous mode\n")
1709 return vtysh_exit (vty
);
1712 DEFUNSH (VTYSH_BGPD
,
1714 vtysh_quit_bgpd_cmd
,
1716 "Exit current mode and down to previous mode\n")
1718 return vtysh_exit_bgpd (self
, vty
, argc
, argv
);
1721 DEFUNSH (VTYSH_OSPFD
,
1723 vtysh_exit_ospfd_cmd
,
1725 "Exit current mode and down to previous mode\n")
1727 return vtysh_exit (vty
);
1730 DEFUNSH (VTYSH_OSPFD
,
1732 vtysh_quit_ospfd_cmd
,
1734 "Exit current mode and down to previous mode\n")
1736 return vtysh_exit_ospfd (self
, vty
, argc
, argv
);
1739 DEFUNSH (VTYSH_EIGRPD
,
1741 vtysh_exit_eigrpd_cmd
,
1743 "Exit current mode and down to previous mode\n")
1745 return vtysh_exit (vty
);
1748 DEFUNSH (VTYSH_EIGRPD
,
1750 vtysh_quit_eigrpd_cmd
,
1752 "Exit current mode and down to previous mode\n")
1754 return vtysh_exit (vty
);
1757 DEFUNSH (VTYSH_OSPF6D
,
1759 vtysh_exit_ospf6d_cmd
,
1761 "Exit current mode and down to previous mode\n")
1763 return vtysh_exit (vty
);
1766 DEFUNSH (VTYSH_OSPF6D
,
1768 vtysh_quit_ospf6d_cmd
,
1770 "Exit current mode and down to previous mode\n")
1772 return vtysh_exit_ospf6d (self
, vty
, argc
, argv
);
1775 #if defined (HAVE_LDPD)
1776 DEFUNSH (VTYSH_LDPD
,
1778 vtysh_exit_ldpd_cmd
,
1780 "Exit current mode and down to previous mode\n")
1782 return vtysh_exit (vty
);
1785 ALIAS (vtysh_exit_ldpd
,
1786 vtysh_quit_ldpd_cmd
,
1788 "Exit current mode and down to previous mode\n")
1791 DEFUNSH (VTYSH_ISISD
,
1793 vtysh_exit_isisd_cmd
,
1795 "Exit current mode and down to previous mode\n")
1797 return vtysh_exit (vty
);
1800 DEFUNSH (VTYSH_ISISD
,
1802 vtysh_quit_isisd_cmd
,
1804 "Exit current mode and down to previous mode\n")
1806 return vtysh_exit_isisd (self
, vty
, argc
, argv
);
1810 vtysh_exit_line_vty
,
1811 vtysh_exit_line_vty_cmd
,
1813 "Exit current mode and down to previous mode\n")
1815 return vtysh_exit (vty
);
1819 vtysh_quit_line_vty
,
1820 vtysh_quit_line_vty_cmd
,
1822 "Exit current mode and down to previous mode\n")
1824 return vtysh_exit_line_vty (self
, vty
, argc
, argv
);
1827 DEFUNSH (VTYSH_INTERFACE
,
1829 vtysh_interface_cmd
,
1830 "interface IFNAME [vrf NAME]",
1831 "Select an interface to configure\n"
1832 "Interface's name\n"
1835 vty
->node
= INTERFACE_NODE
;
1839 /* TODO Implement "no interface command in isisd. */
1840 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_RIPNGD
|VTYSH_OSPFD
|VTYSH_OSPF6D
|VTYSH_EIGRPD
|VTYSH_LDPD
,
1841 vtysh_no_interface_cmd
,
1842 "no interface IFNAME",
1844 "Delete a pseudo interface's configuration\n"
1845 "Interface's name\n")
1848 vtysh_no_interface_vrf_cmd
,
1849 "no interface IFNAME vrf NAME",
1851 "Delete a pseudo interface's configuration\n"
1852 "Interface's name\n"
1858 "logical-router (1-65535) ns NAME",
1859 "Enable a logical-router\n"
1860 "Specify the logical-router indentifier\n"
1862 "The file name in " NS_RUN_DIR
", or a full pathname\n")
1864 vty
->node
= NS_NODE
;
1872 "Select a VRF to configure\n"
1875 vty
->node
= VRF_NODE
;
1883 "Delete a pseudo vrf's configuration\n"
1890 "Exit current mode and down to previous mode\n")
1892 return vtysh_exit (vty
);
1899 "Exit current mode and down to previous mode\n")
1901 return vtysh_exit_ns(self
, vty
, argc
, argv
);
1908 "Exit current mode and down to previous mode\n")
1910 return vtysh_exit (vty
);
1917 "Exit current mode and down to previous mode\n")
1919 return vtysh_exit_vrf (self
, vty
, argc
, argv
);
1922 /* TODO Implement interface description commands in ripngd, ospf6d
1924 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
|VTYSH_EIGRPD
|VTYSH_LDPD
,
1925 vtysh_interface_desc_cmd
,
1926 "description LINE...",
1927 "Interface specific description\n"
1928 "Characters describing this interface\n")
1930 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
|VTYSH_EIGRPD
,
1931 vtysh_no_interface_desc_cmd
,
1934 "Interface specific description\n")
1936 DEFUNSH (VTYSH_INTERFACE
,
1937 vtysh_exit_interface
,
1938 vtysh_exit_interface_cmd
,
1940 "Exit current mode and down to previous mode\n")
1942 return vtysh_exit (vty
);
1945 DEFUNSH (VTYSH_INTERFACE
,
1946 vtysh_quit_interface
,
1947 vtysh_quit_interface_cmd
,
1949 "Exit current mode and down to previous mode\n")
1951 return vtysh_exit_interface (self
, vty
, argc
, argv
);
1954 DEFUN (vtysh_show_thread
,
1955 vtysh_show_thread_cmd
,
1956 "show thread cpu [FILTER]",
1958 "Thread information\n"
1959 "Thread CPU usage\n"
1960 "Display filter (rwtexb)\n")
1964 int ret
= CMD_SUCCESS
;
1967 sprintf(line
, "show thread cpu %s\n", (argc
== 4) ? argv
[idx_filter
]->arg
: "");
1968 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1969 if ( vtysh_client
[i
].fd
>= 0 )
1971 fprintf (stdout
, "Thread statistics for %s:\n",
1972 vtysh_client
[i
].name
);
1973 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1974 fprintf (stdout
,"\n");
1979 DEFUN (vtysh_show_work_queues
,
1980 vtysh_show_work_queues_cmd
,
1983 "Work Queue information\n")
1986 int ret
= CMD_SUCCESS
;
1987 char line
[] = "show work-queues\n";
1989 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1990 if ( vtysh_client
[i
].fd
>= 0 )
1992 fprintf (stdout
, "Work queue statistics for %s:\n",
1993 vtysh_client
[i
].name
);
1994 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1995 fprintf (stdout
,"\n");
2001 DEFUN (vtysh_show_work_queues_daemon
,
2002 vtysh_show_work_queues_daemon_cmd
,
2003 "show work-queues <zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd>",
2005 "Work Queue information\n"
2006 "For the zebra daemon\n"
2007 "For the rip daemon\n"
2008 "For the ripng daemon\n"
2009 "For the ospf daemon\n"
2010 "For the ospfv6 daemon\n"
2011 "For the bgp daemon\n"
2012 "For the isis daemon\n")
2014 int idx_protocol
= 2;
2016 int ret
= CMD_SUCCESS
;
2018 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2020 if (strmatch(vtysh_client
[i
].name
, argv
[idx_protocol
]->text
))
2024 ret
= vtysh_client_execute(&vtysh_client
[i
], "show work-queues\n", stdout
);
2029 DEFUNSH (VTYSH_ZEBRA
,
2031 vtysh_link_params_cmd
,
2036 vty
->node
= LINK_PARAMS_NODE
;
2040 DEFUNSH (VTYSH_ZEBRA
,
2042 exit_link_params_cmd
,
2044 "Exit from Link Params configuration node\n")
2046 if (vty
->node
== LINK_PARAMS_NODE
)
2047 vty
->node
= INTERFACE_NODE
;
2052 DEFUN (vtysh_show_memory
,
2053 vtysh_show_memory_cmd
,
2056 "Memory statistics\n")
2059 int ret
= CMD_SUCCESS
;
2060 char line
[] = "show memory\n";
2062 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2063 if ( vtysh_client
[i
].fd
>= 0 )
2065 fprintf (stdout
, "Memory statistics for %s:\n",
2066 vtysh_client
[i
].name
);
2067 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2068 fprintf (stdout
,"\n");
2074 /* Logging commands. */
2075 DEFUN (vtysh_show_logging
,
2076 vtysh_show_logging_cmd
,
2079 "Show current logging configuration\n")
2082 int ret
= CMD_SUCCESS
;
2083 char line
[] = "show logging\n";
2085 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2086 if ( vtysh_client
[i
].fd
>= 0 )
2088 fprintf (stdout
,"Logging configuration for %s:\n",
2089 vtysh_client
[i
].name
);
2090 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2091 fprintf (stdout
,"\n");
2099 vtysh_log_stdout_cmd
,
2102 "Set stdout logging level\n")
2108 vtysh_log_stdout_level
,
2109 vtysh_log_stdout_level_cmd
,
2110 "log stdout <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2112 "Set stdout logging level\n"
2119 no_vtysh_log_stdout
,
2120 no_vtysh_log_stdout_cmd
,
2121 "no log stdout [LEVEL]",
2124 "Cancel logging to stdout\n"
2133 "log file FILENAME",
2136 "Logging filename\n")
2142 vtysh_log_file_level
,
2143 vtysh_log_file_level_cmd
,
2144 "log file FILENAME <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2147 "Logging filename\n"
2155 no_vtysh_log_file_cmd
,
2156 "no log file [FILENAME [LEVEL]]",
2159 "Cancel logging to file\n"
2160 "Logging file name\n"
2168 vtysh_log_monitor_cmd
,
2169 "log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
2171 "Set terminal line (monitor) logging level\n"
2178 no_vtysh_log_monitor
,
2179 no_vtysh_log_monitor_cmd
,
2180 "no log monitor [LEVEL]",
2183 "Disable terminal line (monitor) logging\n"
2191 vtysh_log_syslog_cmd
,
2192 "log syslog <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2194 "Set syslog logging level\n"
2201 no_vtysh_log_syslog
,
2202 no_vtysh_log_syslog_cmd
,
2203 "no log syslog [LEVEL]",
2206 "Cancel logging to syslog\n"
2214 vtysh_log_facility_cmd
,
2215 "log facility <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>",
2217 "Facility parameter for syslog messages\n"
2225 no_vtysh_log_facility
,
2226 no_vtysh_log_facility_cmd
,
2227 "no log facility [FACILITY]",
2230 "Reset syslog facility to default (daemon)\n"
2231 "Syslog facility\n")
2237 DEFUNSH_DEPRECATED (VTYSH_ALL
,
2240 "log trap <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
2242 "(Deprecated) Set logging level and default for all destinations\n"
2249 DEFUNSH_DEPRECATED (VTYSH_ALL
,
2251 no_vtysh_log_trap_cmd
,
2252 "no log trap [LEVEL]",
2255 "Permit all logging information\n"
2262 vtysh_log_record_priority
,
2263 vtysh_log_record_priority_cmd
,
2264 "log record-priority",
2266 "Log the priority of the message within the message\n")
2272 no_vtysh_log_record_priority
,
2273 no_vtysh_log_record_priority_cmd
,
2274 "no log record-priority",
2277 "Do not log the priority of the message within the message\n")
2283 vtysh_log_timestamp_precision
,
2284 vtysh_log_timestamp_precision_cmd
,
2285 "log timestamp precision (0-6)",
2287 "Timestamp configuration\n"
2288 "Set the timestamp precision\n"
2289 "Number of subsecond digits\n")
2295 no_vtysh_log_timestamp_precision
,
2296 no_vtysh_log_timestamp_precision_cmd
,
2297 "no log timestamp precision",
2300 "Timestamp configuration\n"
2301 "Reset the timestamp precision to the default value of 0\n")
2307 vtysh_service_password_encrypt
,
2308 vtysh_service_password_encrypt_cmd
,
2309 "service password-encryption",
2310 "Set up miscellaneous service\n"
2311 "Enable encrypted passwords\n")
2317 no_vtysh_service_password_encrypt
,
2318 no_vtysh_service_password_encrypt_cmd
,
2319 "no service password-encryption",
2321 "Set up miscellaneous service\n"
2322 "Enable encrypted passwords\n")
2328 vtysh_config_password
,
2330 "password (8-8) WORD",
2331 "Assign the terminal connection password\n"
2332 "Specifies a HIDDEN password will follow\n"
2334 "The HIDDEN line password string\n")
2340 vtysh_password_text
,
2341 vtysh_password_text_cmd
,
2343 "Assign the terminal connection password\n"
2344 "The UNENCRYPTED (cleartext) line password\n")
2350 vtysh_config_enable_password
,
2351 vtysh_enable_password_cmd
,
2352 "enable password (8-8) WORD",
2353 "Modify enable password parameters\n"
2354 "Assign the privileged level password\n"
2355 "Specifies a HIDDEN password will follow\n"
2356 "The HIDDEN 'enable' password string\n")
2362 vtysh_enable_password_text
,
2363 vtysh_enable_password_text_cmd
,
2364 "enable password LINE",
2365 "Modify enable password parameters\n"
2366 "Assign the privileged level password\n"
2367 "The UNENCRYPTED (cleartext) 'enable' password\n")
2373 no_vtysh_config_enable_password
,
2374 no_vtysh_enable_password_cmd
,
2375 "no enable password",
2377 "Modify enable password parameters\n"
2378 "Assign the privileged level password\n")
2383 DEFUN (vtysh_write_terminal
,
2384 vtysh_write_terminal_cmd
,
2385 "write terminal [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2386 "Write running configuration to memory, network, or terminal\n"
2387 "Write to terminal\n"
2388 "For the zebra daemon\n"
2389 "For the rip daemon\n"
2390 "For the ripng daemon\n"
2391 "For the ospf daemon\n"
2392 "For the ospfv6 daemon\n"
2393 "For the ldpd daemon\n"
2394 "For the bgp daemon\n"
2395 "For the isis daemon\n"
2396 "For the pim daemon\n")
2399 char line
[] = "write terminal\n";
2402 if (vtysh_pager_name
)
2404 fp
= popen (vtysh_pager_name
, "w");
2414 vty_out (vty
, "Building configuration...%s", VTY_NEWLINE
);
2415 vty_out (vty
, "%sCurrent configuration:%s", VTY_NEWLINE
,
2417 vty_out (vty
, "!%s", VTY_NEWLINE
);
2419 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2420 if ((argc
< 3 ) || (strmatch (vtysh_client
[i
].name
, argv
[2]->text
)))
2421 vtysh_client_config (&vtysh_client
[i
], line
);
2423 /* Integrate vtysh specific configuration. */
2424 vtysh_config_write ();
2426 vtysh_config_dump (fp
);
2428 if (vtysh_pager_name
&& fp
)
2431 if (pclose (fp
) == -1)
2439 vty_out (vty
, "end%s", VTY_NEWLINE
);
2443 DEFUN (vtysh_show_running_config
,
2444 vtysh_show_running_config_cmd
,
2445 "show running-config [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|pimd>]",
2447 "Current operating configuration\n"
2448 "For the zebra daemon\n"
2449 "For the rip daemon\n"
2450 "For the ripng daemon\n"
2451 "For the ospf daemon\n"
2452 "For the ospfv6 daemon\n"
2453 "For the ldp daemon\n"
2454 "For the bgp daemon\n"
2455 "For the isis daemon\n"
2456 "For the pim daemon\n")
2458 return vtysh_write_terminal (self
, vty
, argc
, argv
);
2461 DEFUN (vtysh_integrated_config
,
2462 vtysh_integrated_config_cmd
,
2463 "service integrated-vtysh-config",
2464 "Set up miscellaneous service\n"
2465 "Write configuration into integrated file\n")
2467 vtysh_write_integrated
= WRITE_INTEGRATED_YES
;
2471 DEFUN (no_vtysh_integrated_config
,
2472 no_vtysh_integrated_config_cmd
,
2473 "no service integrated-vtysh-config",
2475 "Set up miscellaneous service\n"
2476 "Write configuration into integrated file\n")
2478 vtysh_write_integrated
= WRITE_INTEGRATED_NO
;
2483 backup_config_file (const char *fbackup
)
2485 char *integrate_sav
= NULL
;
2487 integrate_sav
= malloc (strlen (fbackup
) +
2488 strlen (CONF_BACKUP_EXT
) + 1);
2489 strcpy (integrate_sav
, fbackup
);
2490 strcat (integrate_sav
, CONF_BACKUP_EXT
);
2492 /* Move current configuration file to backup config file. */
2493 unlink (integrate_sav
);
2494 rename (fbackup
, integrate_sav
);
2495 free (integrate_sav
);
2499 vtysh_write_config_integrated(void)
2502 char line
[] = "write terminal\n";
2505 struct passwd
*pwentry
;
2506 struct group
*grentry
;
2512 fprintf (stdout
,"Building Configuration...\n");
2514 backup_config_file(quagga_config
);
2515 fp
= fopen (quagga_config
, "w");
2518 fprintf (stdout
,"%% Error: failed to open configuration file %s: %s\n",
2519 quagga_config
, safe_strerror(errno
));
2524 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2525 vtysh_client_config (&vtysh_client
[i
], line
);
2527 vtysh_config_write ();
2528 vtysh_config_dump (fp
);
2530 if (fchmod (fd
, CONFIGFILE_MASK
) != 0)
2532 printf ("%% Warning: can't chmod configuration file %s: %s\n",
2533 quagga_config
, safe_strerror(errno
));
2537 pwentry
= getpwnam (FRR_USER
);
2539 uid
= pwentry
->pw_uid
;
2542 printf ("%% Warning: could not look up user \"%s\"\n", FRR_USER
);
2546 grentry
= getgrnam (FRR_GROUP
);
2548 gid
= grentry
->gr_gid
;
2551 printf ("%% Warning: could not look up group \"%s\"\n", FRR_GROUP
);
2555 if (!fstat (fd
, &st
))
2557 if (st
.st_uid
== uid
)
2559 if (st
.st_gid
== gid
)
2561 if ((uid
!= (uid_t
)-1 || gid
!= (gid_t
)-1) && fchown (fd
, uid
, gid
))
2563 printf ("%% Warning: can't chown configuration file %s: %s\n",
2564 quagga_config
, safe_strerror(errno
));
2570 printf ("%% Warning: stat() failed on %s: %s\n",
2571 quagga_config
, safe_strerror(errno
));
2577 printf ("Integrated configuration saved to %s\n", quagga_config
);
2585 static bool want_config_integrated(void)
2589 switch (vtysh_write_integrated
)
2591 case WRITE_INTEGRATED_UNSPECIFIED
:
2592 if (stat(quagga_config
, &s
) && errno
== ENOENT
)
2595 case WRITE_INTEGRATED_NO
:
2597 case WRITE_INTEGRATED_YES
:
2603 DEFUN (vtysh_write_memory
,
2604 vtysh_write_memory_cmd
,
2605 "write [<memory|file>]",
2606 "Write running configuration to memory, network, or terminal\n"
2607 "Write configuration to the file (same as write file)\n"
2608 "Write configuration to the file (same as write memory)\n")
2610 int ret
= CMD_SUCCESS
;
2611 char line
[] = "write memory\n";
2614 fprintf (stdout
, "Note: this version of vtysh never writes vtysh.conf\n");
2616 /* If integrated frr.conf explicitely set. */
2617 if (want_config_integrated())
2620 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2621 if (vtysh_client
[i
].flag
== VTYSH_WATCHFRR
)
2623 if (i
< array_size(vtysh_client
) && vtysh_client
[i
].fd
!= -1)
2624 ret
= vtysh_client_execute (&vtysh_client
[i
], "write integrated", stdout
);
2626 if (ret
!= CMD_SUCCESS
)
2628 printf("\nWarning: attempting direct configuration write without "
2629 "watchfrr.\nFile permissions and ownership may be "
2630 "incorrect, or write may fail.\n\n");
2631 ret
= vtysh_write_config_integrated();
2636 fprintf (stdout
,"Building Configuration...\n");
2638 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2639 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2644 DEFUN (vtysh_copy_running_config
,
2645 vtysh_copy_running_config_cmd
,
2646 "copy running-config startup-config",
2647 "Copy from one file to another\n"
2648 "Copy from current system configuration\n"
2649 "Copy to startup configuration\n")
2651 return vtysh_write_memory (self
, vty
, argc
, argv
);
2654 DEFUN (vtysh_terminal_length
,
2655 vtysh_terminal_length_cmd
,
2656 "terminal length (0-512)",
2657 "Set terminal line parameters\n"
2658 "Set number of lines on a screen\n"
2659 "Number of lines on screen (0 for no pausing)\n")
2663 char *endptr
= NULL
;
2664 char default_pager
[10];
2666 lines
= strtol (argv
[idx_number
]->arg
, &endptr
, 10);
2667 if (lines
< 0 || lines
> 512 || *endptr
!= '\0')
2669 vty_out (vty
, "length is malformed%s", VTY_NEWLINE
);
2673 if (vtysh_pager_name
)
2675 free (vtysh_pager_name
);
2676 vtysh_pager_name
= NULL
;
2681 snprintf(default_pager
, 10, "more -%i", lines
);
2682 vtysh_pager_name
= strdup (default_pager
);
2688 DEFUN (vtysh_terminal_no_length
,
2689 vtysh_terminal_no_length_cmd
,
2690 "terminal no length",
2691 "Set terminal line parameters\n"
2693 "Set number of lines on a screen\n")
2695 if (vtysh_pager_name
)
2697 free (vtysh_pager_name
);
2698 vtysh_pager_name
= NULL
;
2705 DEFUN (vtysh_show_daemons
,
2706 vtysh_show_daemons_cmd
,
2709 "Show list of running daemons\n")
2713 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2714 if ( vtysh_client
[i
].fd
>= 0 )
2715 vty_out(vty
, " %s", vtysh_client
[i
].name
);
2716 vty_out(vty
, "%s", VTY_NEWLINE
);
2721 /* Execute command in child process. */
2723 execute_command (const char *command
, int argc
, struct cmd_token
*arg1
,
2734 /* Failure of fork(). */
2735 fprintf (stderr
, "Can't fork: %s\n", safe_strerror (errno
));
2740 /* This is child process. */
2744 execlp (command
, command
, (const char *)NULL
);
2747 execlp (command
, command
, arg1
, (const char *)NULL
);
2750 execlp (command
, command
, arg1
, arg2
, (const char *)NULL
);
2754 /* When execlp suceed, this part is not executed. */
2755 fprintf (stderr
, "Can't execute %s: %s\n", command
, safe_strerror (errno
));
2760 /* This is parent. */
2762 wait4 (pid
, &status
, 0, NULL
);
2770 "Send echo messages\n"
2771 "Ping destination address or hostname\n")
2773 execute_command ("ping", 1, argv
[0], NULL
);
2780 "Send echo messages\n"
2782 "Ping destination address or hostname\n")
2784 DEFUN (vtysh_traceroute
,
2785 vtysh_traceroute_cmd
,
2787 "Trace route to destination\n"
2788 "Trace route to destination address or hostname\n")
2790 execute_command ("traceroute", 1, argv
[0], NULL
);
2794 ALIAS (vtysh_traceroute
,
2795 vtysh_traceroute_ip_cmd
,
2796 "traceroute ip WORD",
2797 "Trace route to destination\n"
2799 "Trace route to destination address or hostname\n")
2804 "Send echo messages\n"
2806 "Ping destination address or hostname\n")
2808 execute_command ("ping6", 1, argv
[0], NULL
);
2812 DEFUN (vtysh_traceroute6
,
2813 vtysh_traceroute6_cmd
,
2814 "traceroute ipv6 WORD",
2815 "Trace route to destination\n"
2817 "Trace route to destination address or hostname\n")
2819 execute_command ("traceroute6", 1, argv
[0], NULL
);
2823 #if defined(HAVE_SHELL_ACCESS)
2824 DEFUN (vtysh_telnet
,
2827 "Open a telnet connection\n"
2828 "IP address or hostname of a remote system\n")
2830 execute_command ("telnet", 1, argv
[0], NULL
);
2834 DEFUN (vtysh_telnet_port
,
2835 vtysh_telnet_port_cmd
,
2837 "Open a telnet connection\n"
2838 "IP address or hostname of a remote system\n"
2839 "TCP Port number\n")
2841 execute_command ("telnet", 2, argv
[0], argv
[1]);
2848 "Open an ssh connection\n"
2851 execute_command ("ssh", 1, argv
[0], NULL
);
2855 DEFUN (vtysh_start_shell
,
2856 vtysh_start_shell_cmd
,
2858 "Start UNIX shell\n")
2860 execute_command ("sh", 0, NULL
, NULL
);
2864 DEFUN (vtysh_start_bash
,
2865 vtysh_start_bash_cmd
,
2867 "Start UNIX shell\n"
2870 execute_command ("bash", 0, NULL
, NULL
);
2874 DEFUN (vtysh_start_zsh
,
2875 vtysh_start_zsh_cmd
,
2877 "Start UNIX shell\n"
2880 execute_command ("zsh", 0, NULL
, NULL
);
2887 "list [permutations]",
2888 "Print command list\n"
2889 "Print all possible command permutations\n")
2891 return cmd_list_cmds (vty
, argc
== 2);
2895 vtysh_install_default (enum node_type node
)
2897 install_element (node
, &config_list_cmd
);
2900 /* Making connection to protocol daemon. */
2902 vtysh_connect (struct vtysh_client
*vclient
)
2906 struct sockaddr_un addr
;
2910 if (!vclient
->path
[0])
2911 snprintf(vclient
->path
, sizeof(vclient
->path
), "%s/%s.vty",
2912 vty_sock_path
, vclient
->name
);
2913 path
= vclient
->path
;
2915 /* Stat socket to see if we have permission to access it. */
2916 ret
= stat (path
, &s_stat
);
2917 if (ret
< 0 && errno
!= ENOENT
)
2919 fprintf (stderr
, "vtysh_connect(%s): stat = %s\n",
2920 path
, safe_strerror(errno
));
2926 if (! S_ISSOCK(s_stat
.st_mode
))
2928 fprintf (stderr
, "vtysh_connect(%s): Not a socket\n",
2935 sock
= socket (AF_UNIX
, SOCK_STREAM
, 0);
2939 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", path
,
2940 safe_strerror(errno
));
2945 memset (&addr
, 0, sizeof (struct sockaddr_un
));
2946 addr
.sun_family
= AF_UNIX
;
2947 strlcpy (addr
.sun_path
, path
, sizeof (addr
.sun_path
));
2948 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
2949 len
= addr
.sun_len
= SUN_LEN(&addr
);
2951 len
= sizeof (addr
.sun_family
) + strlen (addr
.sun_path
);
2952 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
2954 ret
= connect (sock
, (struct sockaddr
*) &addr
, len
);
2958 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", path
,
2959 safe_strerror(errno
));
2969 /* Return true if str ends with suffix, else return false */
2971 ends_with(const char *str
, const char *suffix
)
2973 if (!str
|| !suffix
)
2975 size_t lenstr
= strlen(str
);
2976 size_t lensuffix
= strlen(suffix
);
2977 if (lensuffix
> lenstr
)
2979 return strncmp(str
+ lenstr
- lensuffix
, suffix
, lensuffix
) == 0;
2983 vtysh_client_sorted_insert (struct vtysh_client
*head_client
,
2984 struct vtysh_client
*client
)
2986 struct vtysh_client
*prev_node
, *current_node
;
2988 prev_node
= head_client
;
2989 current_node
= head_client
->next
;
2990 while (current_node
)
2992 if (strcmp(current_node
->path
, client
->path
) > 0)
2995 prev_node
= current_node
;
2996 current_node
= current_node
->next
;
2998 client
->next
= current_node
;
2999 prev_node
->next
= client
;
3002 #define MAXIMUM_INSTANCES 10
3005 vtysh_update_all_insances(struct vtysh_client
* head_client
)
3007 struct vtysh_client
*client
;
3009 struct dirent
*file
;
3012 if (head_client
->flag
!= VTYSH_OSPFD
) return;
3014 /* ls vty_sock_dir and look for all files ending in .vty */
3015 dir
= opendir(vty_sock_path
);
3018 while ((file
= readdir(dir
)) != NULL
)
3020 if (begins_with(file
->d_name
, "ospfd-") && ends_with(file
->d_name
, ".vty"))
3022 if (n
== MAXIMUM_INSTANCES
)
3025 "Parsing %s, client limit(%d) reached!\n",
3029 client
= (struct vtysh_client
*) malloc(sizeof(struct vtysh_client
));
3031 client
->name
= "ospfd";
3032 client
->flag
= VTYSH_OSPFD
;
3033 snprintf(client
->path
, sizeof(client
->path
), "%s/%s",
3034 vty_sock_path
, file
->d_name
);
3035 client
->next
= NULL
;
3036 vtysh_client_sorted_insert(head_client
, client
);
3045 vtysh_connect_all_instances (struct vtysh_client
*head_client
)
3047 struct vtysh_client
*client
;
3050 vtysh_update_all_insances(head_client
);
3052 client
= head_client
->next
;
3055 if (vtysh_connect(client
) == 0)
3057 client
= client
->next
;
3064 vtysh_connect_all(const char *daemon_name
)
3070 for (i
= 0; i
< array_size(vtysh_client
); i
++)
3072 if (!daemon_name
|| !strcmp(daemon_name
, vtysh_client
[i
].name
))
3075 if (vtysh_connect(&vtysh_client
[i
]) == 0)
3078 rc
+= vtysh_connect_all_instances(&vtysh_client
[i
]);
3082 fprintf(stderr
, "Error: no daemons match name %s!\n", daemon_name
);
3086 /* To disable readline's filename completion. */
3088 vtysh_completion_entry_function (const char *ignore
, int invoking_key
)
3094 vtysh_readline_init (void)
3096 /* readline related settings. */
3098 rl_bind_key ('?', (rl_command_func_t
*) vtysh_rl_describe
);
3099 rl_completion_entry_function
= vtysh_completion_entry_function
;
3100 rl_attempted_completion_function
= (rl_completion_func_t
*)new_completion
;
3106 static struct utsname names
;
3107 static char buf
[100];
3108 const char*hostname
;
3109 extern struct host host
;
3111 hostname
= host
.name
;
3115 if (!names
.nodename
[0])
3117 hostname
= names
.nodename
;
3120 snprintf (buf
, sizeof buf
, cmd_prompt (vty
->node
), hostname
);
3126 vtysh_init_vty (void)
3128 /* Make vty structure. */
3130 vty
->type
= VTY_SHELL
;
3131 vty
->node
= VIEW_NODE
;
3133 /* Initialize commands. */
3136 /* Install nodes. */
3137 install_node (&bgp_node
, NULL
);
3138 install_node (&rip_node
, NULL
);
3139 install_node (&interface_node
, NULL
);
3140 install_node (&link_params_node
, NULL
);
3141 install_node (&ns_node
, NULL
);
3142 install_node (&vrf_node
, NULL
);
3143 install_node (&rmap_node
, NULL
);
3144 install_node (&zebra_node
, NULL
);
3145 install_node (&bgp_vpnv4_node
, NULL
);
3146 install_node (&bgp_vpnv6_node
, NULL
);
3147 install_node (&bgp_encap_node
, NULL
);
3148 install_node (&bgp_encapv6_node
, NULL
);
3149 install_node (&bgp_ipv4_node
, NULL
);
3150 install_node (&bgp_ipv4m_node
, NULL
);
3151 install_node (&bgp_ipv6_node
, NULL
);
3152 install_node (&bgp_ipv6m_node
, NULL
);
3153 install_node (&bgp_vrf_policy_node
, NULL
);
3154 install_node (&bgp_evpn_node
, NULL
);
3155 install_node (&bgp_vnc_defaults_node
, NULL
);
3156 install_node (&bgp_vnc_nve_group_node
, NULL
);
3157 install_node (&bgp_vnc_l2_group_node
, NULL
);
3158 install_node (&ospf_node
, NULL
);
3159 install_node (&eigrp_node
, NULL
);
3160 install_node (&ripng_node
, NULL
);
3161 install_node (&ospf6_node
, NULL
);
3162 install_node (&ldp_node
, NULL
);
3163 install_node (&ldp_ipv4_node
, NULL
);
3164 install_node (&ldp_ipv6_node
, NULL
);
3165 install_node (&ldp_ipv4_iface_node
, NULL
);
3166 install_node (&ldp_ipv6_iface_node
, NULL
);
3167 install_node (&ldp_l2vpn_node
, NULL
);
3168 install_node (&ldp_pseudowire_node
, NULL
);
3169 install_node (&keychain_node
, NULL
);
3170 install_node (&keychain_key_node
, NULL
);
3171 install_node (&isis_node
, NULL
);
3172 install_node (&vty_node
, NULL
);
3174 vtysh_install_default (VIEW_NODE
);
3175 vtysh_install_default (CONFIG_NODE
);
3176 vtysh_install_default (BGP_NODE
);
3177 vtysh_install_default (RIP_NODE
);
3178 vtysh_install_default (INTERFACE_NODE
);
3179 vtysh_install_default (LINK_PARAMS_NODE
);
3180 vtysh_install_default (NS_NODE
);
3181 vtysh_install_default (VRF_NODE
);
3182 vtysh_install_default (RMAP_NODE
);
3183 vtysh_install_default (ZEBRA_NODE
);
3184 vtysh_install_default (BGP_VPNV4_NODE
);
3185 vtysh_install_default (BGP_VPNV6_NODE
);
3186 vtysh_install_default (BGP_ENCAP_NODE
);
3187 vtysh_install_default (BGP_ENCAPV6_NODE
);
3188 vtysh_install_default (BGP_IPV4_NODE
);
3189 vtysh_install_default (BGP_IPV4M_NODE
);
3190 vtysh_install_default (BGP_IPV6_NODE
);
3191 vtysh_install_default (BGP_IPV6M_NODE
);
3192 vtysh_install_default (BGP_EVPN_NODE
);
3194 vtysh_install_default (BGP_VRF_POLICY_NODE
);
3195 vtysh_install_default (BGP_VNC_DEFAULTS_NODE
);
3196 vtysh_install_default (BGP_VNC_NVE_GROUP_NODE
);
3197 vtysh_install_default (BGP_VNC_L2_GROUP_NODE
);
3199 vtysh_install_default (OSPF_NODE
);
3200 vtysh_install_default (EIGRP_NODE
);
3201 vtysh_install_default (RIPNG_NODE
);
3202 vtysh_install_default (OSPF6_NODE
);
3203 vtysh_install_default (LDP_NODE
);
3204 vtysh_install_default (LDP_IPV4_NODE
);
3205 vtysh_install_default (LDP_IPV6_NODE
);
3206 vtysh_install_default (LDP_IPV4_IFACE_NODE
);
3207 vtysh_install_default (LDP_IPV6_IFACE_NODE
);
3208 vtysh_install_default (LDP_L2VPN_NODE
);
3209 vtysh_install_default (LDP_PSEUDOWIRE_NODE
);
3210 vtysh_install_default (ISIS_NODE
);
3211 vtysh_install_default (KEYCHAIN_NODE
);
3212 vtysh_install_default (KEYCHAIN_KEY_NODE
);
3213 vtysh_install_default (VTY_NODE
);
3215 install_element (VIEW_NODE
, &vtysh_enable_cmd
);
3216 install_element (ENABLE_NODE
, &vtysh_config_terminal_cmd
);
3217 install_element (ENABLE_NODE
, &vtysh_disable_cmd
);
3219 /* "exit" command. */
3220 install_element (VIEW_NODE
, &vtysh_exit_all_cmd
);
3221 install_element (CONFIG_NODE
, &vtysh_exit_all_cmd
);
3222 install_element (VIEW_NODE
, &vtysh_quit_all_cmd
);
3223 install_element (CONFIG_NODE
, &vtysh_quit_all_cmd
);
3224 install_element (RIP_NODE
, &vtysh_exit_ripd_cmd
);
3225 install_element (RIP_NODE
, &vtysh_quit_ripd_cmd
);
3226 install_element (RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
3227 install_element (RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
3228 install_element (OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
3229 install_element (OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
3230 install_element (EIGRP_NODE
, &vtysh_exit_eigrpd_cmd
);
3231 install_element (EIGRP_NODE
, &vtysh_quit_eigrpd_cmd
);
3232 install_element (OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
3233 install_element (OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
3234 #if defined (HAVE_LDPD)
3235 install_element (LDP_NODE
, &vtysh_exit_ldpd_cmd
);
3236 install_element (LDP_NODE
, &vtysh_quit_ldpd_cmd
);
3237 install_element (LDP_IPV4_NODE
, &vtysh_exit_ldpd_cmd
);
3238 install_element (LDP_IPV4_NODE
, &vtysh_quit_ldpd_cmd
);
3239 install_element (LDP_IPV6_NODE
, &vtysh_exit_ldpd_cmd
);
3240 install_element (LDP_IPV6_NODE
, &vtysh_quit_ldpd_cmd
);
3241 install_element (LDP_IPV4_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3242 install_element (LDP_IPV4_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3243 install_element (LDP_IPV6_IFACE_NODE
, &vtysh_exit_ldpd_cmd
);
3244 install_element (LDP_IPV6_IFACE_NODE
, &vtysh_quit_ldpd_cmd
);
3245 install_element (LDP_L2VPN_NODE
, &vtysh_exit_ldpd_cmd
);
3246 install_element (LDP_L2VPN_NODE
, &vtysh_quit_ldpd_cmd
);
3247 install_element (LDP_PSEUDOWIRE_NODE
, &vtysh_exit_ldpd_cmd
);
3248 install_element (LDP_PSEUDOWIRE_NODE
, &vtysh_quit_ldpd_cmd
);
3250 install_element (BGP_NODE
, &vtysh_exit_bgpd_cmd
);
3251 install_element (BGP_NODE
, &vtysh_quit_bgpd_cmd
);
3252 install_element (BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
3253 install_element (BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
3254 install_element (BGP_VPNV6_NODE
, &vtysh_exit_bgpd_cmd
);
3255 install_element (BGP_VPNV6_NODE
, &vtysh_quit_bgpd_cmd
);
3256 install_element (BGP_ENCAP_NODE
, &vtysh_exit_bgpd_cmd
);
3257 install_element (BGP_ENCAP_NODE
, &vtysh_quit_bgpd_cmd
);
3258 install_element (BGP_ENCAPV6_NODE
, &vtysh_exit_bgpd_cmd
);
3259 install_element (BGP_ENCAPV6_NODE
, &vtysh_quit_bgpd_cmd
);
3260 install_element (BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
3261 install_element (BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
3262 install_element (BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
3263 install_element (BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
3264 install_element (BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
3265 install_element (BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
3266 install_element (BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
3267 install_element (BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
3268 install_element (BGP_EVPN_NODE
, &vtysh_quit_bgpd_cmd
);
3269 #if defined (ENABLE_BGP_VNC)
3270 install_element (BGP_VRF_POLICY_NODE
, &vtysh_exit_bgpd_cmd
);
3271 install_element (BGP_VRF_POLICY_NODE
, &vtysh_quit_bgpd_cmd
);
3272 install_element (BGP_VNC_DEFAULTS_NODE
, &vtysh_exit_bgpd_cmd
);
3273 install_element (BGP_VNC_DEFAULTS_NODE
, &vtysh_quit_bgpd_cmd
);
3274 install_element (BGP_VNC_NVE_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3275 install_element (BGP_VNC_NVE_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3276 install_element (BGP_VNC_L2_GROUP_NODE
, &vtysh_exit_bgpd_cmd
);
3277 install_element (BGP_VNC_L2_GROUP_NODE
, &vtysh_quit_bgpd_cmd
);
3279 install_element (ISIS_NODE
, &vtysh_exit_isisd_cmd
);
3280 install_element (ISIS_NODE
, &vtysh_quit_isisd_cmd
);
3281 install_element (KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
3282 install_element (KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
3283 install_element (KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
3284 install_element (KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
3285 install_element (RMAP_NODE
, &vtysh_exit_rmap_cmd
);
3286 install_element (RMAP_NODE
, &vtysh_quit_rmap_cmd
);
3287 install_element (VTY_NODE
, &vtysh_exit_line_vty_cmd
);
3288 install_element (VTY_NODE
, &vtysh_quit_line_vty_cmd
);
3290 /* "end" command. */
3291 install_element (CONFIG_NODE
, &vtysh_end_all_cmd
);
3292 install_element (ENABLE_NODE
, &vtysh_end_all_cmd
);
3293 install_element (RIP_NODE
, &vtysh_end_all_cmd
);
3294 install_element (RIPNG_NODE
, &vtysh_end_all_cmd
);
3295 install_element (OSPF_NODE
, &vtysh_end_all_cmd
);
3296 install_element (EIGRP_NODE
, &vtysh_end_all_cmd
);
3297 install_element (OSPF6_NODE
, &vtysh_end_all_cmd
);
3298 install_element (LDP_NODE
, &vtysh_end_all_cmd
);
3299 install_element (LDP_IPV4_NODE
, &vtysh_end_all_cmd
);
3300 install_element (LDP_IPV6_NODE
, &vtysh_end_all_cmd
);
3301 install_element (LDP_IPV4_IFACE_NODE
, &vtysh_end_all_cmd
);
3302 install_element (LDP_IPV6_IFACE_NODE
, &vtysh_end_all_cmd
);
3303 install_element (LDP_L2VPN_NODE
, &vtysh_end_all_cmd
);
3304 install_element (LDP_PSEUDOWIRE_NODE
, &vtysh_end_all_cmd
);
3305 install_element (BGP_NODE
, &vtysh_end_all_cmd
);
3306 install_element (BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
3307 install_element (BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
3308 install_element (BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
3309 install_element (BGP_VPNV6_NODE
, &vtysh_end_all_cmd
);
3310 install_element (BGP_ENCAP_NODE
, &vtysh_end_all_cmd
);
3311 install_element (BGP_ENCAPV6_NODE
, &vtysh_end_all_cmd
);
3312 install_element (BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
3313 install_element (BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
3314 install_element (BGP_VRF_POLICY_NODE
, &vtysh_end_all_cmd
);
3315 install_element (BGP_EVPN_NODE
, &vtysh_end_all_cmd
);
3316 install_element (BGP_VNC_DEFAULTS_NODE
, &vtysh_end_all_cmd
);
3317 install_element (BGP_VNC_NVE_GROUP_NODE
, &vtysh_end_all_cmd
);
3318 install_element (BGP_VNC_L2_GROUP_NODE
, &vtysh_end_all_cmd
);
3319 install_element (ISIS_NODE
, &vtysh_end_all_cmd
);
3320 install_element (KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
3321 install_element (KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
3322 install_element (RMAP_NODE
, &vtysh_end_all_cmd
);
3323 install_element (VTY_NODE
, &vtysh_end_all_cmd
);
3325 install_element (INTERFACE_NODE
, &vtysh_interface_desc_cmd
);
3326 install_element (INTERFACE_NODE
, &vtysh_no_interface_desc_cmd
);
3327 install_element (INTERFACE_NODE
, &vtysh_end_all_cmd
);
3328 install_element (INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
3329 install_element (LINK_PARAMS_NODE
, &exit_link_params_cmd
);
3330 install_element (LINK_PARAMS_NODE
, &vtysh_end_all_cmd
);
3331 install_element (LINK_PARAMS_NODE
, &vtysh_exit_interface_cmd
);
3332 install_element (INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
3334 install_element (NS_NODE
, &vtysh_end_all_cmd
);
3336 install_element (CONFIG_NODE
, &vtysh_ns_cmd
);
3337 install_element (NS_NODE
, &vtysh_exit_ns_cmd
);
3338 install_element (NS_NODE
, &vtysh_quit_ns_cmd
);
3340 install_element (VRF_NODE
, &vtysh_end_all_cmd
);
3341 install_element (VRF_NODE
, &vtysh_exit_vrf_cmd
);
3342 install_element (VRF_NODE
, &vtysh_quit_vrf_cmd
);
3344 install_element (CONFIG_NODE
, &router_eigrp_cmd
);
3345 install_element (CONFIG_NODE
, &router_rip_cmd
);
3346 install_element (CONFIG_NODE
, &router_ripng_cmd
);
3347 install_element (CONFIG_NODE
, &router_ospf_cmd
);
3348 install_element (CONFIG_NODE
, &router_ospf6_cmd
);
3349 #if defined (HAVE_LDPD)
3350 install_element (CONFIG_NODE
, &ldp_mpls_ldp_cmd
);
3351 install_element (LDP_NODE
, &ldp_address_family_ipv4_cmd
);
3352 install_element (LDP_NODE
, &ldp_address_family_ipv6_cmd
);
3353 install_element (LDP_IPV4_NODE
, &ldp_interface_ifname_cmd
);
3354 install_element (LDP_IPV6_NODE
, &ldp_interface_ifname_cmd
);
3355 install_element (CONFIG_NODE
, &ldp_l2vpn_word_type_vpls_cmd
);
3356 install_element (LDP_L2VPN_NODE
, &ldp_member_pseudowire_ifname_cmd
);
3358 install_element (CONFIG_NODE
, &router_isis_cmd
);
3359 install_element (CONFIG_NODE
, &router_bgp_cmd
);
3360 install_element (BGP_NODE
, &address_family_vpnv4_cmd
);
3361 install_element (BGP_NODE
, &address_family_vpnv6_cmd
);
3362 install_element (BGP_NODE
, &address_family_encapv4_cmd
);
3363 install_element (BGP_NODE
, &address_family_encapv6_cmd
);
3364 #if defined(ENABLE_BGP_VNC)
3365 install_element (BGP_NODE
, &vnc_vrf_policy_cmd
);
3366 install_element (BGP_NODE
, &vnc_defaults_cmd
);
3367 install_element (BGP_NODE
, &vnc_nve_group_cmd
);
3368 install_element (BGP_NODE
, &vnc_l2_group_cmd
);
3370 install_element (BGP_NODE
, &address_family_ipv4_unicast_cmd
);
3371 install_element (BGP_NODE
, &address_family_ipv6_cmd
);
3372 install_element (BGP_NODE
, &address_family_evpn_cmd
);
3373 install_element (BGP_VPNV4_NODE
, &exit_address_family_cmd
);
3374 install_element (BGP_VPNV6_NODE
, &exit_address_family_cmd
);
3375 install_element (BGP_ENCAP_NODE
, &exit_address_family_cmd
);
3376 install_element (BGP_ENCAPV6_NODE
, &exit_address_family_cmd
);
3377 install_element (BGP_IPV4_NODE
, &exit_address_family_cmd
);
3378 install_element (BGP_IPV4M_NODE
, &exit_address_family_cmd
);
3379 install_element (BGP_IPV6_NODE
, &exit_address_family_cmd
);
3380 install_element (BGP_IPV6M_NODE
, &exit_address_family_cmd
);
3381 install_element (BGP_EVPN_NODE
, &exit_address_family_cmd
);
3383 install_element (BGP_VRF_POLICY_NODE
, &exit_vrf_policy_cmd
);
3384 install_element (BGP_VNC_DEFAULTS_NODE
, &exit_vnc_config_cmd
);
3385 install_element (BGP_VNC_NVE_GROUP_NODE
, &exit_vnc_config_cmd
);
3386 install_element (BGP_VNC_L2_GROUP_NODE
, &exit_vnc_config_cmd
);
3388 install_element (CONFIG_NODE
, &key_chain_cmd
);
3389 install_element (CONFIG_NODE
, &vtysh_route_map_cmd
);
3390 install_element (CONFIG_NODE
, &vtysh_line_vty_cmd
);
3391 install_element (KEYCHAIN_NODE
, &key_cmd
);
3392 install_element (KEYCHAIN_NODE
, &key_chain_cmd
);
3393 install_element (KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
3394 install_element (CONFIG_NODE
, &vtysh_interface_cmd
);
3395 install_element (CONFIG_NODE
, &vtysh_no_interface_cmd
);
3396 install_element (CONFIG_NODE
, &vtysh_no_interface_vrf_cmd
);
3397 install_element (INTERFACE_NODE
, &vtysh_link_params_cmd
);
3398 install_element (ENABLE_NODE
, &vtysh_show_running_config_cmd
);
3399 install_element (ENABLE_NODE
, &vtysh_copy_running_config_cmd
);
3401 install_element (CONFIG_NODE
, &vtysh_vrf_cmd
);
3402 install_element (CONFIG_NODE
, &vtysh_no_vrf_cmd
);
3404 /* "write terminal" command. */
3405 install_element (ENABLE_NODE
, &vtysh_write_terminal_cmd
);
3407 install_element (CONFIG_NODE
, &vtysh_integrated_config_cmd
);
3408 install_element (CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
3410 /* "write memory" command. */
3411 install_element (ENABLE_NODE
, &vtysh_write_memory_cmd
);
3413 install_element (VIEW_NODE
, &vtysh_terminal_length_cmd
);
3414 install_element (VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
3415 install_element (VIEW_NODE
, &vtysh_show_daemons_cmd
);
3417 install_element (VIEW_NODE
, &vtysh_ping_cmd
);
3418 install_element (VIEW_NODE
, &vtysh_ping_ip_cmd
);
3419 install_element (VIEW_NODE
, &vtysh_traceroute_cmd
);
3420 install_element (VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
3421 install_element (VIEW_NODE
, &vtysh_ping6_cmd
);
3422 install_element (VIEW_NODE
, &vtysh_traceroute6_cmd
);
3423 #if defined(HAVE_SHELL_ACCESS)
3424 install_element (VIEW_NODE
, &vtysh_telnet_cmd
);
3425 install_element (VIEW_NODE
, &vtysh_telnet_port_cmd
);
3426 install_element (VIEW_NODE
, &vtysh_ssh_cmd
);
3428 #if defined(HAVE_SHELL_ACCESS)
3429 install_element (ENABLE_NODE
, &vtysh_start_shell_cmd
);
3430 install_element (ENABLE_NODE
, &vtysh_start_bash_cmd
);
3431 install_element (ENABLE_NODE
, &vtysh_start_zsh_cmd
);
3434 install_element (VIEW_NODE
, &vtysh_show_memory_cmd
);
3436 install_element (VIEW_NODE
, &vtysh_show_work_queues_cmd
);
3437 install_element (VIEW_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3439 install_element (VIEW_NODE
, &vtysh_show_thread_cmd
);
3442 install_element (VIEW_NODE
, &vtysh_show_logging_cmd
);
3443 install_element (CONFIG_NODE
, &vtysh_log_stdout_cmd
);
3444 install_element (CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
3445 install_element (CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
3446 install_element (CONFIG_NODE
, &vtysh_log_file_cmd
);
3447 install_element (CONFIG_NODE
, &vtysh_log_file_level_cmd
);
3448 install_element (CONFIG_NODE
, &no_vtysh_log_file_cmd
);
3449 install_element (CONFIG_NODE
, &vtysh_log_monitor_cmd
);
3450 install_element (CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
3451 install_element (CONFIG_NODE
, &vtysh_log_syslog_cmd
);
3452 install_element (CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
3453 install_element (CONFIG_NODE
, &vtysh_log_trap_cmd
);
3454 install_element (CONFIG_NODE
, &no_vtysh_log_trap_cmd
);
3455 install_element (CONFIG_NODE
, &vtysh_log_facility_cmd
);
3456 install_element (CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
3457 install_element (CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
3458 install_element (CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
3459 install_element (CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
3460 install_element (CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
3462 install_element (CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
3463 install_element (CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
3465 install_element (CONFIG_NODE
, &vtysh_password_cmd
);
3466 install_element (CONFIG_NODE
, &vtysh_password_text_cmd
);
3467 install_element (CONFIG_NODE
, &vtysh_enable_password_cmd
);
3468 install_element (CONFIG_NODE
, &vtysh_enable_password_text_cmd
);
3469 install_element (CONFIG_NODE
, &no_vtysh_enable_password_cmd
);