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"
49 /* VTY shell pager name. */
50 char *vtysh_pager_name
= NULL
;
52 /* VTY shell client structure. */
59 struct vtysh_client
*next
;
62 struct vtysh_client vtysh_client
[] =
64 { .fd
= -1, .name
= "zebra", .flag
= VTYSH_ZEBRA
, .path
= ZEBRA_VTYSH_PATH
, .next
= NULL
},
65 { .fd
= -1, .name
= "ripd", .flag
= VTYSH_RIPD
, .path
= RIP_VTYSH_PATH
, .next
= NULL
},
66 { .fd
= -1, .name
= "ripngd", .flag
= VTYSH_RIPNGD
, .path
= RIPNG_VTYSH_PATH
, .next
= NULL
},
67 { .fd
= -1, .name
= "ospfd", .flag
= VTYSH_OSPFD
, .path
= OSPF_VTYSH_PATH
, .next
= NULL
},
68 { .fd
= -1, .name
= "ospf6d", .flag
= VTYSH_OSPF6D
, .path
= OSPF6_VTYSH_PATH
, .next
= NULL
},
69 { .fd
= -1, .name
= "bgpd", .flag
= VTYSH_BGPD
, .path
= BGP_VTYSH_PATH
, .next
= NULL
},
70 { .fd
= -1, .name
= "isisd", .flag
= VTYSH_ISISD
, .path
= ISIS_VTYSH_PATH
, .next
= NULL
},
71 { .fd
= -1, .name
= "pimd", .flag
= VTYSH_PIMD
, .path
= PIM_VTYSH_PATH
, .next
= NULL
},
74 /* Using integrated config from Quagga.conf. Default is no. */
75 int vtysh_writeconfig_integrated
= 1;
77 extern char config_default
[];
80 vclient_close (struct vtysh_client
*vclient
)
85 "Warning: closing connection to %s because of an I/O error!\n",
92 /* Return true if str begins with prefix, else return false */
94 begins_with(const char *str
, const char *prefix
)
98 size_t lenstr
= strlen(str
);
99 size_t lenprefix
= strlen(prefix
);
100 if (lenprefix
> lenstr
)
102 return strncmp(str
, prefix
, lenprefix
) == 0;
105 /* Following filled with debug code to trace a problematic condition
106 * under load - it SHOULD handle it. */
107 #define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): "
109 vtysh_client_config_one (struct vtysh_client
*vclient
, char *line
)
124 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
127 vclient_close (vclient
);
131 /* Allow enough room for buffer to read more than a few pages from socket. */
132 bufsz
= 5 * getpagesize() + 1;
133 buf
= XMALLOC(MTYPE_TMP
, bufsz
);
134 memset(buf
, 0, bufsz
);
139 if (pbuf
>= ((buf
+ bufsz
) -1))
141 fprintf (stderr
, ERR_WHERE_STRING \
142 "warning - pbuf beyond buffer end.\n");
146 readln
= (buf
+ bufsz
) - pbuf
- 1;
147 nbytes
= read (vclient
->fd
, pbuf
, readln
);
155 fprintf(stderr
, ERR_WHERE_STRING
"(%u)", errno
);
158 if (errno
== EAGAIN
|| errno
== EIO
)
161 vclient_close (vclient
);
162 XFREE(MTYPE_TMP
, buf
);
171 if (pbuf
[i
] == '\0' && pbuf
[i
+ 1] == '\0' && pbuf
[i
+ 2] == '\0')
179 /* See if a line exists in buffer, if so parse and consume it, and
180 * reset read position. */
181 if ((eoln
= strrchr(buf
, '\n')) == NULL
)
184 if (eoln
>= ((buf
+ bufsz
) - 1))
186 fprintf (stderr
, ERR_WHERE_STRING \
187 "warning - eoln beyond buffer end.\n");
189 vtysh_config_parse(buf
);
192 left
= (size_t)(buf
+ bufsz
- eoln
);
193 memmove(buf
, eoln
, left
);
195 pbuf
= buf
+ strlen(buf
);
198 /* Parse anything left in the buffer. */
200 vtysh_config_parse (buf
);
202 XFREE(MTYPE_TMP
, buf
);
207 vtysh_client_config (struct vtysh_client
*head_client
, char *line
)
209 struct vtysh_client
*client
;
212 rc
= vtysh_client_config_one(head_client
, line
);
213 if (rc
!= CMD_SUCCESS
)
216 client
= head_client
->next
;
219 rc
= vtysh_client_config_one(client
, line
);
220 if (rc
!= CMD_SUCCESS
)
222 client
= client
->next
;
228 vtysh_client_execute_one (struct vtysh_client
*vclient
, const char *line
, FILE *fp
)
239 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
242 vclient_close (vclient
);
248 nbytes
= read (vclient
->fd
, buf
, sizeof(buf
)-1);
250 if (nbytes
<= 0 && errno
!= EINTR
)
252 vclient_close (vclient
);
258 if ((numnulls
== 3) && (nbytes
== 1))
265 /* check for trailling \0\0\0<ret code>,
266 * even if split across reads
267 * (see lib/vty.c::vtysh_read)
277 while (i
< nbytes
&& numnulls
< 3)
279 if (buf
[i
++] == '\0')
285 /* got 3 or more trailing NULs? */
286 if ((numnulls
>= 3) && (i
< nbytes
))
287 return (buf
[nbytes
-1]);
293 vtysh_client_execute (struct vtysh_client
*head_client
, const char *line
, FILE *fp
)
295 struct vtysh_client
*client
;
298 rc
= vtysh_client_execute_one(head_client
, line
, fp
);
299 if (rc
!= CMD_SUCCESS
)
302 client
= head_client
->next
;
305 rc
= vtysh_client_execute_one(client
, line
, fp
);
306 if (rc
!= CMD_SUCCESS
)
308 client
= client
->next
;
314 vtysh_pager_init (void)
318 pager_defined
= getenv ("VTYSH_PAGER");
321 vtysh_pager_name
= strdup (pager_defined
);
323 vtysh_pager_name
= strdup ("more");
326 /* Command execution over the vty interface. */
328 vtysh_execute_func (const char *line
, int pager
)
333 struct cmd_element
*cmd
;
337 int saved_ret
, saved_node
;
339 /* Split readline string up into the vector. */
340 vline
= cmd_make_strvec (line
);
345 saved_ret
= ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
346 saved_node
= vty
->node
;
348 /* If command doesn't succeeded in current node, try to walk up in node tree.
349 * Changing vty->node is enough to try it just out without actual walkup in
351 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
352 && vty
->node
> CONFIG_NODE
)
354 vty
->node
= node_parent(vty
->node
);
355 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
359 vty
->node
= saved_node
;
361 /* If command succeeded in any other node than current (tried > 0) we have
362 * to move into node in the vtysh where it succeeded. */
363 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
365 if ((saved_node
== BGP_VPNV4_NODE
|| saved_node
== BGP_VPNV6_NODE
366 || saved_node
== BGP_ENCAP_NODE
|| saved_node
== BGP_ENCAPV6_NODE
367 || saved_node
== BGP_IPV4_NODE
368 || saved_node
== BGP_IPV6_NODE
|| saved_node
== BGP_IPV4M_NODE
369 || saved_node
== BGP_IPV6M_NODE
)
372 vtysh_execute("exit-address-family");
374 else if ((saved_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
376 vtysh_execute("exit");
380 vtysh_execute ("end");
381 vtysh_execute ("configure terminal");
384 /* If command didn't succeed in any node, continue with return value from
391 cmd_free_strvec (vline
);
397 if (vty
->type
== VTY_FILE
)
398 fprintf (stdout
,"Warning...\n");
400 case CMD_ERR_AMBIGUOUS
:
401 fprintf (stdout
,"%% Ambiguous command.\n");
403 case CMD_ERR_NO_MATCH
:
404 fprintf (stdout
,"%% Unknown command.\n");
406 case CMD_ERR_INCOMPLETE
:
407 fprintf (stdout
,"%% Command incomplete.\n");
409 case CMD_SUCCESS_DAEMON
:
411 /* FIXME: Don't open pager for exit commands. popen() causes problems
412 * if exited from vtysh at all. This hack shouldn't cause any problem
413 * but is really ugly. */
414 if (pager
&& vtysh_pager_name
&& (strncmp(line
, "exit", 4) != 0))
416 fp
= popen (vtysh_pager_name
, "w");
419 perror ("popen failed for pager");
428 if (! strcmp(cmd
->string
,"configure terminal"))
430 for (i
= 0; i
< array_size(vtysh_client
); i
++)
432 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
433 if (cmd_stat
== CMD_WARNING
)
440 vline
= cmd_make_strvec (line
);
444 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
446 if (pclose (fp
) == -1)
448 perror ("pclose failed for pager");
455 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
456 cmd_free_strvec (vline
);
457 if (ret
!= CMD_SUCCESS_DAEMON
)
463 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
468 cmd_stat
= CMD_SUCCESS
;
469 for (i
= 0; i
< array_size(vtysh_client
); i
++)
471 if (cmd
->daemon
& vtysh_client
[i
].flag
)
473 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
474 if (cmd_stat
!= CMD_SUCCESS
)
478 if (cmd_stat
!= CMD_SUCCESS
)
482 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
485 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
487 if (pclose (fp
) == -1)
489 perror ("pclose failed for pager");
497 vtysh_execute_no_pager (const char *line
)
499 return vtysh_execute_func (line
, 0);
503 vtysh_execute (const char *line
)
505 return vtysh_execute_func (line
, 1);
520 while (end
>= s
&& isspace(*end
))
524 while (*s
&& isspace(*s
))
531 vtysh_mark_file (const char *filename
)
538 struct cmd_element
*cmd
;
539 int saved_ret
, prev_node
;
541 char *vty_buf_copy
= NULL
;
542 char *vty_buf_trimmed
= NULL
;
544 if (strncmp("-", filename
, 1) == 0)
547 confp
= fopen (filename
, "r");
551 fprintf (stderr
, "%% Can't open config file %s due to '%s'.\n",
552 filename
, safe_strerror (errno
));
553 return (CMD_ERR_NO_FILE
);
557 vty
->fd
= 0; /* stdout */
558 vty
->type
= VTY_TERM
;
559 vty
->node
= CONFIG_NODE
;
561 vtysh_execute_no_pager ("enable");
562 vtysh_execute_no_pager ("configure terminal");
563 vty_buf_copy
= XCALLOC (MTYPE_VTY
, VTY_BUFSIZ
);
565 while (fgets (vty
->buf
, VTY_BUFSIZ
, confp
))
569 strcpy(vty_buf_copy
, vty
->buf
);
570 vty_buf_trimmed
= trim(vty_buf_copy
);
572 if (vty_buf_trimmed
[0] == '!' || vty_buf_trimmed
[0] == '#')
574 fprintf(stdout
, "%s", vty
->buf
);
578 /* Split readline string up into the vector. */
579 vline
= cmd_make_strvec (vty
->buf
);
583 fprintf(stdout
, "%s", vty
->buf
);
587 /* Ignore the "end" lines, we will generate these where appropriate */
588 if (strlen(vty_buf_trimmed
) == 3 && strncmp("end", vty_buf_trimmed
, 3) == 0)
593 prev_node
= vty
->node
;
594 saved_ret
= ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
596 /* If command doesn't succeeded in current node, try to walk up in node tree.
597 * Changing vty->node is enough to try it just out without actual walkup in
599 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
600 && vty
->node
> CONFIG_NODE
)
602 vty
->node
= node_parent(vty
->node
);
603 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
607 /* If command succeeded in any other node than current (tried > 0) we have
608 * to move into node in the vtysh where it succeeded. */
609 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
611 if ((prev_node
== BGP_VPNV4_NODE
|| prev_node
== BGP_IPV4_NODE
612 || prev_node
== BGP_IPV6_NODE
|| prev_node
== BGP_IPV4M_NODE
613 || prev_node
== BGP_IPV6M_NODE
|| prev_node
== BGP_VPNV6_NODE
)
616 fprintf(stdout
, "exit-address-family\n");
618 else if ((prev_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
620 fprintf(stdout
, "exit\n");
624 fprintf(stdout
, "end\n");
627 /* If command didn't succeed in any node, continue with return value from
632 vty
->node
= prev_node
;
635 cmd_free_strvec (vline
);
639 if (vty
->type
== VTY_FILE
)
640 fprintf (stderr
,"line %d: Warning...: %s\n", lineno
, vty
->buf
);
643 XFREE(MTYPE_VTY
, vty_buf_copy
);
645 case CMD_ERR_AMBIGUOUS
:
646 fprintf (stderr
,"line %d: %% Ambiguous command: %s\n", lineno
, vty
->buf
);
649 XFREE(MTYPE_VTY
, vty_buf_copy
);
650 return CMD_ERR_AMBIGUOUS
;
651 case CMD_ERR_NO_MATCH
:
652 fprintf (stderr
,"line %d: %% Unknown command: %s\n", lineno
, vty
->buf
);
655 XFREE(MTYPE_VTY
, vty_buf_copy
);
656 return CMD_ERR_NO_MATCH
;
657 case CMD_ERR_INCOMPLETE
:
658 fprintf (stderr
,"line %d: %% Command incomplete: %s\n", lineno
, vty
->buf
);
661 XFREE(MTYPE_VTY
, vty_buf_copy
);
662 return CMD_ERR_INCOMPLETE
;
664 fprintf(stdout
, "%s", vty
->buf
);
666 case CMD_SUCCESS_DAEMON
:
669 int cmd_stat
= CMD_SUCCESS
;
671 fprintf(stdout
, "%s", vty
->buf
);
672 for (i
= 0; i
< array_size(vtysh_client
); i
++)
674 if (cmd
->daemon
& vtysh_client
[i
].flag
)
676 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
678 if (cmd_stat
!= CMD_SUCCESS
)
682 if (cmd_stat
!= CMD_SUCCESS
)
686 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
690 /* This is the end */
691 fprintf(stdout
, "end\n");
693 XFREE(MTYPE_VTY
, vty_buf_copy
);
701 /* Configration make from file. */
703 vtysh_config_from_file (struct vty
*vty
, FILE *fp
)
706 struct cmd_element
*cmd
;
708 int retcode
= CMD_SUCCESS
;
710 while (fgets (vty
->buf
, VTY_BUFSIZ
, fp
))
714 ret
= command_config_read_one_line (vty
, &cmd
, 1);
719 if (vty
->type
== VTY_FILE
)
720 fprintf (stderr
,"line %d: Warning[%d]...: %s\n", lineno
, vty
->node
, vty
->buf
);
721 retcode
= CMD_WARNING
; /* once we have an error, we remember & return that */
723 case CMD_ERR_AMBIGUOUS
:
724 fprintf (stderr
,"line %d: %% Ambiguous command[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
725 retcode
= CMD_ERR_AMBIGUOUS
; /* once we have an error, we remember & return that */
727 case CMD_ERR_NO_MATCH
:
728 fprintf (stderr
,"line %d: %% Unknown command[%d]: %s", lineno
, vty
->node
, vty
->buf
);
729 retcode
= CMD_ERR_NO_MATCH
; /* once we have an error, we remember & return that */
731 case CMD_ERR_INCOMPLETE
:
732 fprintf (stderr
,"line %d: %% Command incomplete[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
733 retcode
= CMD_ERR_INCOMPLETE
; /* once we have an error, we remember & return that */
735 case CMD_SUCCESS_DAEMON
:
738 int cmd_stat
= CMD_SUCCESS
;
740 for (i
= 0; i
< array_size(vtysh_client
); i
++)
742 if (cmd
->daemon
& vtysh_client
[i
].flag
)
744 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
747 * CMD_WARNING - Can mean that the command was
748 * parsed successfully but it was already entered
749 * in a few spots. As such if we receive a
750 * CMD_WARNING from a daemon we shouldn't stop
751 * talking to the other daemons for the particular
754 if (cmd_stat
!= CMD_SUCCESS
&& cmd_stat
!= CMD_WARNING
)
756 fprintf (stderr
, "line %d: Failure to communicate[%d] to %s, line: %s\n",
757 lineno
, cmd_stat
, vtysh_client
[i
].name
, vty
->buf
);
762 if (cmd_stat
!= CMD_SUCCESS
)
766 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
774 /* We don't care about the point of the cursor when '?' is typed. */
776 vtysh_rl_describe (void)
783 struct cmd_token
*token
;
785 vline
= cmd_make_strvec (rl_line_buffer
);
787 /* In case of '> ?'. */
790 vline
= vector_init (1);
791 vector_set (vline
, NULL
);
794 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
795 vector_set (vline
, NULL
);
797 describe
= cmd_describe_command (vline
, vty
, &ret
);
799 fprintf (stdout
,"\n");
801 /* Ambiguous and no match error. */
804 case CMD_ERR_AMBIGUOUS
:
805 cmd_free_strvec (vline
);
806 fprintf (stdout
,"%% Ambiguous command.\n");
810 case CMD_ERR_NO_MATCH
:
811 cmd_free_strvec (vline
);
812 fprintf (stdout
,"%% There is no matched command.\n");
818 /* Get width of command string. */
820 for (i
= 0; i
< vector_active (describe
); i
++)
821 if ((token
= vector_slot (describe
, i
)) != NULL
)
825 if (token
->cmd
[0] == '\0')
828 len
= strlen (token
->cmd
);
829 if (token
->cmd
[0] == '.')
836 for (i
= 0; i
< vector_active (describe
); i
++)
837 if ((token
= vector_slot (describe
, i
)) != NULL
)
839 if (token
->cmd
[0] == '\0')
843 fprintf (stdout
," %-s\n",
844 token
->cmd
[0] == '.' ? token
->cmd
+ 1 : token
->cmd
);
846 fprintf (stdout
," %-*s %s\n",
848 token
->cmd
[0] == '.' ? token
->cmd
+ 1 : token
->cmd
,
852 cmd_free_strvec (vline
);
853 vector_free (describe
);
860 /* Result of cmd_complete_command() call will be stored here
861 * and used in new_completion() in order to put the space in
862 * correct places only. */
866 command_generator (const char *text
, int state
)
869 static char **matched
= NULL
;
870 static int index
= 0;
877 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
880 vline
= cmd_make_strvec (rl_line_buffer
);
884 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
885 vector_set (vline
, NULL
);
887 matched
= cmd_complete_command (vline
, vty
, &complete_status
);
890 if (matched
&& matched
[index
])
891 return matched
[index
++];
897 new_completion (char *text
, int start
, int end
)
901 matches
= rl_completion_matches (text
, command_generator
);
906 if (complete_status
!= CMD_COMPLETE_FULL_MATCH
)
907 /* only append a space on full match */
908 rl_completion_append_character
= '\0';
914 /* Vty node structures. */
915 static struct cmd_node bgp_node
=
918 "%s(config-router)# ",
921 static struct cmd_node rip_node
=
924 "%s(config-router)# ",
927 static struct cmd_node isis_node
=
930 "%s(config-router)# ",
933 static struct cmd_node interface_node
=
939 static struct cmd_node vrf_node
=
945 static struct cmd_node rmap_node
=
948 "%s(config-route-map)# "
951 static struct cmd_node zebra_node
=
954 "%s(config-router)# "
957 static struct cmd_node bgp_vpnv4_node
=
960 "%s(config-router-af)# "
963 static struct cmd_node bgp_vpnv6_node
=
966 "%s(config-router-af)# "
969 static struct cmd_node bgp_encap_node
=
972 "%s(config-router-af)# "
975 static struct cmd_node bgp_encapv6_node
=
978 "%s(config-router-af)# "
981 static struct cmd_node bgp_ipv4_node
=
984 "%s(config-router-af)# "
987 static struct cmd_node bgp_ipv4m_node
=
990 "%s(config-router-af)# "
993 static struct cmd_node bgp_ipv6_node
=
996 "%s(config-router-af)# "
999 static struct cmd_node bgp_ipv6m_node
=
1002 "%s(config-router-af)# "
1005 static struct cmd_node ospf_node
=
1008 "%s(config-router)# "
1011 static struct cmd_node ripng_node
=
1014 "%s(config-router)# "
1017 static struct cmd_node ospf6_node
=
1020 "%s(config-ospf6)# "
1023 static struct cmd_node keychain_node
=
1026 "%s(config-keychain)# "
1029 static struct cmd_node keychain_key_node
=
1032 "%s(config-keychain-key)# "
1035 struct cmd_node link_params_node
=
1038 "%s(config-link-params)# ",
1041 /* Defined in lib/vty.c */
1042 extern struct cmd_node vty_node
;
1044 /* When '^Z' is received from vty, move down to the enable mode. */
1052 /* Nothing to do. */
1055 vty
->node
= ENABLE_NODE
;
1065 "End current mode and change to enable mode\n")
1067 return vtysh_end ();
1070 DEFUNSH (VTYSH_BGPD
,
1073 "router bgp " CMD_AS_RANGE
,
1078 vty
->node
= BGP_NODE
;
1082 ALIAS_SH (VTYSH_BGPD
,
1089 ALIAS_SH (VTYSH_BGPD
,
1091 router_bgp_view_cmd
,
1092 "router bgp " CMD_AS_RANGE
" (view|vrf) WORD",
1096 "BGP view\nBGP VRF\n"
1099 DEFUNSH (VTYSH_BGPD
,
1100 address_family_vpnv4
,
1101 address_family_vpnv4_cmd
,
1102 "address-family vpnv4",
1103 "Enter Address Family command mode\n"
1106 vty
->node
= BGP_VPNV4_NODE
;
1110 DEFUNSH (VTYSH_BGPD
,
1111 address_family_vpnv4_unicast
,
1112 address_family_vpnv4_unicast_cmd
,
1113 "address-family vpnv4 unicast",
1114 "Enter Address Family command mode\n"
1116 "Address Family Modifier\n")
1118 vty
->node
= BGP_VPNV4_NODE
;
1122 DEFUNSH (VTYSH_BGPD
,
1123 address_family_vpnv6
,
1124 address_family_vpnv6_cmd
,
1125 "address-family vpnv6",
1126 "Enter Address Family command mode\n"
1129 vty
->node
= BGP_VPNV6_NODE
;
1133 DEFUNSH (VTYSH_BGPD
,
1134 address_family_vpnv6_unicast
,
1135 address_family_vpnv6_unicast_cmd
,
1136 "address-family vpnv6 unicast",
1137 "Enter Address Family command mode\n"
1139 "Address Family Modifier\n")
1141 vty
->node
= BGP_VPNV6_NODE
;
1145 DEFUNSH (VTYSH_BGPD
,
1146 address_family_encap
,
1147 address_family_encap_cmd
,
1148 "address-family encap",
1149 "Enter Address Family command mode\n"
1152 vty
->node
= BGP_ENCAP_NODE
;
1156 DEFUNSH (VTYSH_BGPD
,
1157 address_family_encapv4
,
1158 address_family_encapv4_cmd
,
1159 "address-family encapv4",
1160 "Enter Address Family command mode\n"
1163 vty
->node
= BGP_ENCAP_NODE
;
1167 DEFUNSH (VTYSH_BGPD
,
1168 address_family_encapv6
,
1169 address_family_encapv6_cmd
,
1170 "address-family encapv6",
1171 "Enter Address Family command mode\n"
1174 vty
->node
= BGP_ENCAPV6_NODE
;
1178 DEFUNSH (VTYSH_BGPD
,
1179 address_family_ipv4_unicast
,
1180 address_family_ipv4_unicast_cmd
,
1181 "address-family ipv4 unicast",
1182 "Enter Address Family command mode\n"
1184 "Address Family Modifier\n")
1186 vty
->node
= BGP_IPV4_NODE
;
1190 DEFUNSH (VTYSH_BGPD
,
1191 address_family_ipv4_multicast
,
1192 address_family_ipv4_multicast_cmd
,
1193 "address-family ipv4 multicast",
1194 "Enter Address Family command mode\n"
1196 "Address Family Modifier\n")
1198 vty
->node
= BGP_IPV4M_NODE
;
1202 DEFUNSH (VTYSH_BGPD
,
1203 address_family_ipv6
,
1204 address_family_ipv6_cmd
,
1205 "address-family ipv6",
1206 "Enter Address Family command mode\n"
1209 vty
->node
= BGP_IPV6_NODE
;
1213 DEFUNSH (VTYSH_BGPD
,
1214 address_family_ipv6_unicast
,
1215 address_family_ipv6_unicast_cmd
,
1216 "address-family ipv6 unicast",
1217 "Enter Address Family command mode\n"
1219 "Address Family Modifier\n")
1221 vty
->node
= BGP_IPV6_NODE
;
1225 DEFUNSH (VTYSH_BGPD
,
1226 address_family_ipv6_multicast
,
1227 address_family_ipv6_multicast_cmd
,
1228 "address-family ipv6 multicast",
1229 "Enter Address Family command mode\n"
1231 "Address Family Modifier\n")
1233 vty
->node
= BGP_IPV6M_NODE
;
1237 DEFUNSH (VTYSH_RIPD
,
1241 "Authentication key management\n"
1242 "Key-chain management\n"
1245 vty
->node
= KEYCHAIN_NODE
;
1249 DEFUNSH (VTYSH_RIPD
,
1252 "key <0-2147483647>",
1254 "Key identifier number\n")
1256 vty
->node
= KEYCHAIN_KEY_NODE
;
1260 DEFUNSH (VTYSH_RIPD
,
1267 vty
->node
= RIP_NODE
;
1271 DEFUNSH (VTYSH_RIPNGD
,
1278 vty
->node
= RIPNG_NODE
;
1282 DEFUNSH (VTYSH_OSPFD
,
1286 "Enable a routing process\n"
1287 "Start OSPF configuration\n")
1289 vty
->node
= OSPF_NODE
;
1293 ALIAS_SH (VTYSH_OSPFD
,
1295 router_ospf_instance_cmd
,
1296 "router ospf <1-65535>",
1297 "Enable a routing process\n"
1298 "Start OSPF configuration\n"
1301 DEFUNSH (VTYSH_OSPF6D
,
1308 vty
->node
= OSPF6_NODE
;
1312 DEFUNSH (VTYSH_ISISD
,
1318 "ISO Routing area tag")
1320 vty
->node
= ISIS_NODE
;
1324 DEFUNSH (VTYSH_RMAP
,
1327 "route-map WORD (deny|permit) <1-65535>",
1328 "Create route-map or enter route-map command mode\n"
1330 "Route map denies set operations\n"
1331 "Route map permits set operations\n"
1332 "Sequence to insert to/delete from existing route-map entry\n")
1334 vty
->node
= RMAP_NODE
;
1342 "Configure a terminal line\n"
1343 "Virtual terminal\n")
1345 vty
->node
= VTY_NODE
;
1353 "Turn on privileged mode command\n")
1355 vty
->node
= ENABLE_NODE
;
1363 "Turn off privileged mode command\n")
1365 if (vty
->node
== ENABLE_NODE
)
1366 vty
->node
= VIEW_NODE
;
1371 vtysh_config_terminal
,
1372 vtysh_config_terminal_cmd
,
1373 "configure terminal",
1374 "Configuration from vty interface\n"
1375 "Configuration terminal\n")
1377 vty
->node
= CONFIG_NODE
;
1382 vtysh_exit (struct vty
*vty
)
1391 vty
->node
= ENABLE_NODE
;
1393 case INTERFACE_NODE
:
1406 vtysh_execute("end");
1407 vtysh_execute("configure terminal");
1408 vty
->node
= CONFIG_NODE
;
1410 case BGP_VPNV4_NODE
:
1411 case BGP_VPNV6_NODE
:
1412 case BGP_ENCAP_NODE
:
1413 case BGP_ENCAPV6_NODE
:
1415 case BGP_IPV4M_NODE
:
1417 case BGP_IPV6M_NODE
:
1418 vty
->node
= BGP_NODE
;
1420 case KEYCHAIN_KEY_NODE
:
1421 vty
->node
= KEYCHAIN_NODE
;
1423 case LINK_PARAMS_NODE
:
1424 vty
->node
= INTERFACE_NODE
;
1436 "Exit current mode and down to previous mode\n")
1438 return vtysh_exit (vty
);
1441 ALIAS (vtysh_exit_all
,
1444 "Exit current mode and down to previous mode\n")
1446 DEFUNSH (VTYSH_BGPD
,
1447 exit_address_family
,
1448 exit_address_family_cmd
,
1449 "exit-address-family",
1450 "Exit from Address Family configuration mode\n")
1452 if (vty
->node
== BGP_IPV4_NODE
1453 || vty
->node
== BGP_IPV4M_NODE
1454 || vty
->node
== BGP_VPNV4_NODE
1455 || vty
->node
== BGP_VPNV6_NODE
1456 || vty
->node
== BGP_ENCAP_NODE
1457 || vty
->node
== BGP_ENCAPV6_NODE
1458 || vty
->node
== BGP_IPV6_NODE
1459 || vty
->node
== BGP_IPV6M_NODE
)
1460 vty
->node
= BGP_NODE
;
1464 DEFUNSH (VTYSH_ZEBRA
,
1466 vtysh_exit_zebra_cmd
,
1468 "Exit current mode and down to previous mode\n")
1470 return vtysh_exit (vty
);
1473 ALIAS (vtysh_exit_zebra
,
1474 vtysh_quit_zebra_cmd
,
1476 "Exit current mode and down to previous mode\n")
1478 DEFUNSH (VTYSH_RIPD
,
1480 vtysh_exit_ripd_cmd
,
1482 "Exit current mode and down to previous mode\n")
1484 return vtysh_exit (vty
);
1487 ALIAS (vtysh_exit_ripd
,
1488 vtysh_quit_ripd_cmd
,
1490 "Exit current mode and down to previous mode\n")
1492 DEFUNSH (VTYSH_RIPNGD
,
1494 vtysh_exit_ripngd_cmd
,
1496 "Exit current mode and down to previous mode\n")
1498 return vtysh_exit (vty
);
1501 ALIAS (vtysh_exit_ripngd
,
1502 vtysh_quit_ripngd_cmd
,
1504 "Exit current mode and down to previous mode\n")
1506 DEFUNSH (VTYSH_RMAP
,
1508 vtysh_exit_rmap_cmd
,
1510 "Exit current mode and down to previous mode\n")
1512 return vtysh_exit (vty
);
1515 ALIAS (vtysh_exit_rmap
,
1516 vtysh_quit_rmap_cmd
,
1518 "Exit current mode and down to previous mode\n")
1520 DEFUNSH (VTYSH_BGPD
,
1522 vtysh_exit_bgpd_cmd
,
1524 "Exit current mode and down to previous mode\n")
1526 return vtysh_exit (vty
);
1529 ALIAS (vtysh_exit_bgpd
,
1530 vtysh_quit_bgpd_cmd
,
1532 "Exit current mode and down to previous mode\n")
1534 DEFUNSH (VTYSH_OSPFD
,
1536 vtysh_exit_ospfd_cmd
,
1538 "Exit current mode and down to previous mode\n")
1540 return vtysh_exit (vty
);
1543 ALIAS (vtysh_exit_ospfd
,
1544 vtysh_quit_ospfd_cmd
,
1546 "Exit current mode and down to previous mode\n")
1548 DEFUNSH (VTYSH_OSPF6D
,
1550 vtysh_exit_ospf6d_cmd
,
1552 "Exit current mode and down to previous mode\n")
1554 return vtysh_exit (vty
);
1557 ALIAS (vtysh_exit_ospf6d
,
1558 vtysh_quit_ospf6d_cmd
,
1560 "Exit current mode and down to previous mode\n")
1562 DEFUNSH (VTYSH_ISISD
,
1564 vtysh_exit_isisd_cmd
,
1566 "Exit current mode and down to previous mode\n")
1568 return vtysh_exit (vty
);
1571 ALIAS (vtysh_exit_isisd
,
1572 vtysh_quit_isisd_cmd
,
1574 "Exit current mode and down to previous mode\n")
1577 vtysh_exit_line_vty
,
1578 vtysh_exit_line_vty_cmd
,
1580 "Exit current mode and down to previous mode\n")
1582 return vtysh_exit (vty
);
1585 ALIAS (vtysh_exit_line_vty
,
1586 vtysh_quit_line_vty_cmd
,
1588 "Exit current mode and down to previous mode\n")
1590 DEFUNSH (VTYSH_INTERFACE
,
1592 vtysh_interface_cmd
,
1594 "Select an interface to configure\n"
1595 "Interface's name\n")
1597 vty
->node
= INTERFACE_NODE
;
1601 ALIAS_SH (VTYSH_ZEBRA
,
1603 vtysh_interface_vrf_cmd
,
1604 "interface IFNAME " VRF_CMD_STR
,
1605 "Select an interface to configure\n"
1606 "Interface's name\n"
1609 /* TODO Implement "no interface command in isisd. */
1610 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_RIPNGD
|VTYSH_OSPFD
|VTYSH_OSPF6D
,
1611 vtysh_no_interface_cmd
,
1612 "no interface IFNAME",
1614 "Delete a pseudo interface's configuration\n"
1615 "Interface's name\n")
1618 vtysh_no_interface_vrf_cmd
,
1619 "no interface IFNAME " VRF_CMD_STR
,
1621 "Delete a pseudo interface's configuration\n"
1622 "Interface's name\n"
1629 "Select a VRF to configure\n"
1632 vty
->node
= VRF_NODE
;
1640 "Delete a pseudo vrf's configuration\n"
1647 "Exit current mode and down to previous mode\n")
1649 return vtysh_exit (vty
);
1652 ALIAS (vtysh_exit_vrf
,
1655 "Exit current mode and down to previous mode\n")
1657 /* TODO Implement interface description commands in ripngd, ospf6d
1659 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1661 "description .LINE",
1662 "Interface specific description\n"
1663 "Characters describing this interface\n")
1665 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1666 no_interface_desc_cmd
,
1669 "Interface specific description\n")
1671 DEFUNSH (VTYSH_INTERFACE
,
1672 vtysh_exit_interface
,
1673 vtysh_exit_interface_cmd
,
1675 "Exit current mode and down to previous mode\n")
1677 return vtysh_exit (vty
);
1680 ALIAS (vtysh_exit_interface
,
1681 vtysh_quit_interface_cmd
,
1683 "Exit current mode and down to previous mode\n")
1685 DEFUN (vtysh_show_thread
,
1686 vtysh_show_thread_cmd
,
1687 "show thread cpu [FILTER]",
1689 "Thread information\n"
1690 "Thread CPU usage\n"
1691 "Display filter (rwtexb)\n")
1694 int ret
= CMD_SUCCESS
;
1697 sprintf(line
, "show thread cpu %s\n", (argc
== 1) ? argv
[0] : "");
1698 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1699 if ( vtysh_client
[i
].fd
>= 0 )
1701 fprintf (stdout
, "Thread statistics for %s:\n",
1702 vtysh_client
[i
].name
);
1703 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1704 fprintf (stdout
,"\n");
1709 DEFUN (vtysh_show_work_queues
,
1710 vtysh_show_work_queues_cmd
,
1713 "Work Queue information\n")
1716 int ret
= CMD_SUCCESS
;
1717 char line
[] = "show work-queues\n";
1719 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1720 if ( vtysh_client
[i
].fd
>= 0 )
1722 fprintf (stdout
, "Work queue statistics for %s:\n",
1723 vtysh_client
[i
].name
);
1724 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1725 fprintf (stdout
,"\n");
1731 DEFUN (vtysh_show_work_queues_daemon
,
1732 vtysh_show_work_queues_daemon_cmd
,
1733 "show work-queues (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd)",
1735 "Work Queue information\n"
1736 "For the zebra daemon\n"
1737 "For the rip daemon\n"
1738 "For the ripng daemon\n"
1739 "For the ospf daemon\n"
1740 "For the ospfv6 daemon\n"
1741 "For the bgp daemon\n"
1742 "For the isis daemon\n")
1745 int ret
= CMD_SUCCESS
;
1747 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1749 if (begins_with(vtysh_client
[i
].name
, argv
[0]))
1753 ret
= vtysh_client_execute(&vtysh_client
[i
], "show work-queues\n", stdout
);
1758 DEFUNSH (VTYSH_ZEBRA
,
1760 vtysh_link_params_cmd
,
1765 vty
->node
= LINK_PARAMS_NODE
;
1770 DEFUN (vtysh_show_memory
,
1771 vtysh_show_memory_cmd
,
1774 "Memory statistics\n")
1777 int ret
= CMD_SUCCESS
;
1778 char line
[] = "show memory\n";
1780 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1781 if ( vtysh_client
[i
].fd
>= 0 )
1783 fprintf (stdout
, "Memory statistics for %s:\n",
1784 vtysh_client
[i
].name
);
1785 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1786 fprintf (stdout
,"\n");
1792 /* Logging commands. */
1793 DEFUN (vtysh_show_logging
,
1794 vtysh_show_logging_cmd
,
1797 "Show current logging configuration\n")
1800 int ret
= CMD_SUCCESS
;
1801 char line
[] = "show logging\n";
1803 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1804 if ( vtysh_client
[i
].fd
>= 0 )
1806 fprintf (stdout
,"Logging configuration for %s:\n",
1807 vtysh_client
[i
].name
);
1808 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1809 fprintf (stdout
,"\n");
1817 vtysh_log_stdout_cmd
,
1820 "Set stdout logging level\n")
1826 vtysh_log_stdout_level
,
1827 vtysh_log_stdout_level_cmd
,
1828 "log stdout "LOG_LEVELS
,
1830 "Set stdout logging level\n"
1837 no_vtysh_log_stdout
,
1838 no_vtysh_log_stdout_cmd
,
1839 "no log stdout [LEVEL]",
1842 "Cancel logging to stdout\n"
1851 "log file FILENAME",
1854 "Logging filename\n")
1860 vtysh_log_file_level
,
1861 vtysh_log_file_level_cmd
,
1862 "log file FILENAME "LOG_LEVELS
,
1865 "Logging filename\n"
1873 no_vtysh_log_file_cmd
,
1874 "no log file [FILENAME]",
1877 "Cancel logging to file\n"
1878 "Logging file name\n")
1883 ALIAS_SH (VTYSH_ALL
,
1885 no_vtysh_log_file_level_cmd
,
1886 "no log file FILENAME LEVEL",
1889 "Cancel logging to file\n"
1890 "Logging file name\n"
1895 vtysh_log_monitor_cmd
,
1898 "Set terminal line (monitor) logging level\n")
1904 vtysh_log_monitor_level
,
1905 vtysh_log_monitor_level_cmd
,
1906 "log monitor "LOG_LEVELS
,
1908 "Set terminal line (monitor) logging level\n"
1915 no_vtysh_log_monitor
,
1916 no_vtysh_log_monitor_cmd
,
1917 "no log monitor [LEVEL]",
1920 "Disable terminal line (monitor) logging\n"
1928 vtysh_log_syslog_cmd
,
1931 "Set syslog logging level\n")
1937 vtysh_log_syslog_level
,
1938 vtysh_log_syslog_level_cmd
,
1939 "log syslog "LOG_LEVELS
,
1941 "Set syslog logging level\n"
1948 no_vtysh_log_syslog
,
1949 no_vtysh_log_syslog_cmd
,
1950 "no log syslog [LEVEL]",
1953 "Cancel logging to syslog\n"
1961 vtysh_log_facility_cmd
,
1962 "log facility "LOG_FACILITIES
,
1964 "Facility parameter for syslog messages\n"
1972 no_vtysh_log_facility
,
1973 no_vtysh_log_facility_cmd
,
1974 "no log facility [FACILITY]",
1977 "Reset syslog facility to default (daemon)\n"
1978 "Syslog facility\n")
1984 DEFUNSH_DEPRECATED (VTYSH_ALL
,
1987 "log trap "LOG_LEVELS
,
1989 "(Deprecated) Set logging level and default for all destinations\n"
1996 DEFUNSH_DEPRECATED (VTYSH_ALL
,
1998 no_vtysh_log_trap_cmd
,
1999 "no log trap [LEVEL]",
2002 "Permit all logging information\n"
2009 vtysh_log_record_priority
,
2010 vtysh_log_record_priority_cmd
,
2011 "log record-priority",
2013 "Log the priority of the message within the message\n")
2019 no_vtysh_log_record_priority
,
2020 no_vtysh_log_record_priority_cmd
,
2021 "no log record-priority",
2024 "Do not log the priority of the message within the message\n")
2030 vtysh_log_timestamp_precision
,
2031 vtysh_log_timestamp_precision_cmd
,
2032 "log timestamp precision <0-6>",
2034 "Timestamp configuration\n"
2035 "Set the timestamp precision\n"
2036 "Number of subsecond digits\n")
2042 no_vtysh_log_timestamp_precision
,
2043 no_vtysh_log_timestamp_precision_cmd
,
2044 "no log timestamp precision",
2047 "Timestamp configuration\n"
2048 "Reset the timestamp precision to the default value of 0\n")
2054 vtysh_service_password_encrypt
,
2055 vtysh_service_password_encrypt_cmd
,
2056 "service password-encryption",
2057 "Set up miscellaneous service\n"
2058 "Enable encrypted passwords\n")
2064 no_vtysh_service_password_encrypt
,
2065 no_vtysh_service_password_encrypt_cmd
,
2066 "no service password-encryption",
2068 "Set up miscellaneous service\n"
2069 "Enable encrypted passwords\n")
2075 vtysh_config_password
,
2077 "password (8|) WORD",
2078 "Assign the terminal connection password\n"
2079 "Specifies a HIDDEN password will follow\n"
2081 "The HIDDEN line password string\n")
2087 vtysh_password_text
,
2088 vtysh_password_text_cmd
,
2090 "Assign the terminal connection password\n"
2091 "The UNENCRYPTED (cleartext) line password\n")
2097 vtysh_config_enable_password
,
2098 vtysh_enable_password_cmd
,
2099 "enable password (8|) WORD",
2100 "Modify enable password parameters\n"
2101 "Assign the privileged level password\n"
2102 "Specifies a HIDDEN password will follow\n"
2104 "The HIDDEN 'enable' password string\n")
2110 vtysh_enable_password_text
,
2111 vtysh_enable_password_text_cmd
,
2112 "enable password LINE",
2113 "Modify enable password parameters\n"
2114 "Assign the privileged level password\n"
2115 "The UNENCRYPTED (cleartext) 'enable' password\n")
2121 no_vtysh_config_enable_password
,
2122 no_vtysh_enable_password_cmd
,
2123 "no enable password",
2125 "Modify enable password parameters\n"
2126 "Assign the privileged level password\n")
2131 DEFUN (vtysh_write_terminal
,
2132 vtysh_write_terminal_cmd
,
2134 "Write running configuration to memory, network, or terminal\n"
2135 "Write to terminal\n")
2138 char line
[] = "write terminal\n";
2141 if (vtysh_pager_name
)
2143 fp
= popen (vtysh_pager_name
, "w");
2153 vty_out (vty
, "Building configuration...%s", VTY_NEWLINE
);
2154 vty_out (vty
, "%sCurrent configuration:%s", VTY_NEWLINE
,
2156 vty_out (vty
, "!%s", VTY_NEWLINE
);
2158 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2159 if ((argc
< 1 ) || (begins_with(vtysh_client
[i
].name
, argv
[0])))
2160 vtysh_client_config (&vtysh_client
[i
], line
);
2162 /* Integrate vtysh specific configuration. */
2163 vtysh_config_write ();
2165 vtysh_config_dump (fp
);
2167 if (vtysh_pager_name
&& fp
)
2170 if (pclose (fp
) == -1)
2178 vty_out (vty
, "end%s", VTY_NEWLINE
);
2183 DEFUN (vtysh_write_terminal_daemon
,
2184 vtysh_write_terminal_daemon_cmd
,
2185 "write terminal (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pimd)",
2186 "Write running configuration to memory, network, or terminal\n"
2187 "Write to terminal\n"
2188 "For the zebra daemon\n"
2189 "For the rip daemon\n"
2190 "For the ripng daemon\n"
2191 "For the ospf daemon\n"
2192 "For the ospfv6 daemon\n"
2193 "For the bgp daemon\n"
2194 "For the isis daemon\n"
2195 "For the pim daemon\n")
2198 int ret
= CMD_SUCCESS
;
2200 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2202 if (begins_with(vtysh_client
[i
].name
, argv
[0]))
2206 ret
= vtysh_client_execute(&vtysh_client
[i
], "show running-config\n", stdout
);
2211 DEFUN (vtysh_integrated_config
,
2212 vtysh_integrated_config_cmd
,
2213 "service integrated-vtysh-config",
2214 "Set up miscellaneous service\n"
2215 "Write configuration into integrated file\n")
2217 vtysh_writeconfig_integrated
= 1;
2221 DEFUN (no_vtysh_integrated_config
,
2222 no_vtysh_integrated_config_cmd
,
2223 "no service integrated-vtysh-config",
2225 "Set up miscellaneous service\n"
2226 "Write configuration into integrated file\n")
2228 vtysh_writeconfig_integrated
= 0;
2233 backup_config_file (const char *fbackup
)
2235 char *integrate_sav
= NULL
;
2237 integrate_sav
= malloc (strlen (fbackup
) +
2238 strlen (CONF_BACKUP_EXT
) + 1);
2239 strcpy (integrate_sav
, fbackup
);
2240 strcat (integrate_sav
, CONF_BACKUP_EXT
);
2242 /* Move current configuration file to backup config file. */
2243 unlink (integrate_sav
);
2244 rename (fbackup
, integrate_sav
);
2245 free (integrate_sav
);
2249 write_config_integrated(void)
2252 char line
[] = "write terminal\n";
2255 fprintf (stdout
,"Building Configuration...\n");
2257 backup_config_file(integrate_default
);
2258 backup_config_file(host
.config
);
2260 fp
= fopen (integrate_default
, "w");
2263 fprintf (stdout
,"%% Can't open configuration file %s due to '%s'\n",
2264 integrate_default
, safe_strerror(errno
));
2268 fp1
= fopen (host
.config
, "w");
2271 fprintf (stdout
,"%% Can't open configuration file %s due to '%s'\n",
2272 host
.config
, safe_strerror(errno
));
2276 vtysh_config_write ();
2277 vtysh_config_dump (fp1
);
2280 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2281 vtysh_client_config (&vtysh_client
[i
], line
);
2283 vtysh_config_write ();
2284 vtysh_config_dump (fp
);
2288 if (chmod (integrate_default
, CONFIGFILE_MASK
) != 0)
2290 fprintf (stdout
,"%% Can't chmod configuration file %s: %s\n",
2291 integrate_default
, safe_strerror(errno
));
2295 if (chmod (host
.config
, CONFIGFILE_MASK
) != 0)
2297 fprintf (stdout
,"%% Can't chmod configuration file %s: %s (%d)\n",
2298 integrate_default
, safe_strerror(errno
), errno
);
2301 fprintf(stdout
,"Integrated configuration saved to %s\n",integrate_default
);
2303 fprintf (stdout
,"[OK]\n");
2308 DEFUN (vtysh_write_memory
,
2309 vtysh_write_memory_cmd
,
2311 "Write running configuration to memory, network, or terminal\n"
2312 "Write configuration to the file (same as write file)\n")
2314 int ret
= CMD_SUCCESS
;
2315 char line
[] = "write memory\n";
2319 /* If integrated Quagga.conf explicitely set. */
2320 if (vtysh_writeconfig_integrated
)
2321 return write_config_integrated();
2323 backup_config_file(integrate_default
);
2325 fprintf (stdout
,"Building Configuration...\n");
2327 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2328 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2331 fp
= fopen(host
.config
, "w");
2334 fprintf (stdout
,"%% Can't open configuration file %s due to '%s'\n",
2335 host
.config
, safe_strerror(errno
));
2339 vtysh_config_write ();
2340 vtysh_config_dump (fp
);
2344 if (chmod (host
.config
, CONFIGFILE_MASK
) != 0)
2346 fprintf (stdout
,"%% Can't chmod configuration file %s: %s\n",
2347 integrate_default
, safe_strerror(errno
));
2351 fprintf (stdout
,"[OK]\n");
2356 ALIAS (vtysh_write_memory
,
2357 vtysh_copy_runningconfig_startupconfig_cmd
,
2358 "copy running-config startup-config",
2359 "Copy from one file to another\n"
2360 "Copy from current system configuration\n"
2361 "Copy to startup configuration\n")
2363 ALIAS (vtysh_write_memory
,
2364 vtysh_write_file_cmd
,
2366 "Write running configuration to memory, network, or terminal\n"
2367 "Write configuration to the file (same as write memory)\n")
2369 ALIAS (vtysh_write_memory
,
2372 "Write running configuration to memory, network, or terminal\n")
2374 ALIAS (vtysh_write_terminal
,
2375 vtysh_show_running_config_cmd
,
2376 "show running-config",
2378 "Current operating configuration\n")
2380 ALIAS (vtysh_write_terminal
,
2381 vtysh_show_running_config_daemon_cmd
,
2382 "show running-config (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pimd)",
2384 "Current operating configuration\n"
2385 "For the zebra daemon\n"
2386 "For the rip daemon\n"
2387 "For the ripng daemon\n"
2388 "For the ospf daemon\n"
2389 "For the ospfv6 daemon\n"
2390 "For the bgp daemon\n"
2391 "For the isis daemon\n"
2392 "For the pim daemon\n")
2394 DEFUN (vtysh_terminal_length
,
2395 vtysh_terminal_length_cmd
,
2396 "terminal length <0-512>",
2397 "Set terminal line parameters\n"
2398 "Set number of lines on a screen\n"
2399 "Number of lines on screen (0 for no pausing)\n")
2402 char *endptr
= NULL
;
2403 char default_pager
[10];
2405 lines
= strtol (argv
[0], &endptr
, 10);
2406 if (lines
< 0 || lines
> 512 || *endptr
!= '\0')
2408 vty_out (vty
, "length is malformed%s", VTY_NEWLINE
);
2412 if (vtysh_pager_name
)
2414 free (vtysh_pager_name
);
2415 vtysh_pager_name
= NULL
;
2420 snprintf(default_pager
, 10, "more -%i", lines
);
2421 vtysh_pager_name
= strdup (default_pager
);
2427 DEFUN (vtysh_terminal_no_length
,
2428 vtysh_terminal_no_length_cmd
,
2429 "terminal no length",
2430 "Set terminal line parameters\n"
2432 "Set number of lines on a screen\n")
2434 if (vtysh_pager_name
)
2436 free (vtysh_pager_name
);
2437 vtysh_pager_name
= NULL
;
2444 DEFUN (vtysh_show_daemons
,
2445 vtysh_show_daemons_cmd
,
2448 "Show list of running daemons\n")
2452 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2453 if ( vtysh_client
[i
].fd
>= 0 )
2454 vty_out(vty
, " %s", vtysh_client
[i
].name
);
2455 vty_out(vty
, "%s", VTY_NEWLINE
);
2460 /* Execute command in child process. */
2462 execute_command (const char *command
, int argc
, const char *arg1
,
2473 /* Failure of fork(). */
2474 fprintf (stderr
, "Can't fork: %s\n", safe_strerror (errno
));
2479 /* This is child process. */
2483 execlp (command
, command
, (const char *)NULL
);
2486 execlp (command
, command
, arg1
, (const char *)NULL
);
2489 execlp (command
, command
, arg1
, arg2
, (const char *)NULL
);
2493 /* When execlp suceed, this part is not executed. */
2494 fprintf (stderr
, "Can't execute %s: %s\n", command
, safe_strerror (errno
));
2499 /* This is parent. */
2501 wait4 (pid
, &status
, 0, NULL
);
2509 "Send echo messages\n"
2510 "Ping destination address or hostname\n")
2512 execute_command ("ping", 1, argv
[0], NULL
);
2519 "Send echo messages\n"
2521 "Ping destination address or hostname\n")
2523 DEFUN (vtysh_traceroute
,
2524 vtysh_traceroute_cmd
,
2526 "Trace route to destination\n"
2527 "Trace route to destination address or hostname\n")
2529 execute_command ("traceroute", 1, argv
[0], NULL
);
2533 ALIAS (vtysh_traceroute
,
2534 vtysh_traceroute_ip_cmd
,
2535 "traceroute ip WORD",
2536 "Trace route to destination\n"
2538 "Trace route to destination address or hostname\n")
2544 "Send echo messages\n"
2546 "Ping destination address or hostname\n")
2548 execute_command ("ping6", 1, argv
[0], NULL
);
2552 DEFUN (vtysh_traceroute6
,
2553 vtysh_traceroute6_cmd
,
2554 "traceroute ipv6 WORD",
2555 "Trace route to destination\n"
2557 "Trace route to destination address or hostname\n")
2559 execute_command ("traceroute6", 1, argv
[0], NULL
);
2564 #if defined(HAVE_SHELL_ACCESS)
2565 DEFUN (vtysh_telnet
,
2568 "Open a telnet connection\n"
2569 "IP address or hostname of a remote system\n")
2571 execute_command ("telnet", 1, argv
[0], NULL
);
2575 DEFUN (vtysh_telnet_port
,
2576 vtysh_telnet_port_cmd
,
2578 "Open a telnet connection\n"
2579 "IP address or hostname of a remote system\n"
2580 "TCP Port number\n")
2582 execute_command ("telnet", 2, argv
[0], argv
[1]);
2589 "Open an ssh connection\n"
2592 execute_command ("ssh", 1, argv
[0], NULL
);
2596 DEFUN (vtysh_start_shell
,
2597 vtysh_start_shell_cmd
,
2599 "Start UNIX shell\n")
2601 execute_command ("sh", 0, NULL
, NULL
);
2605 DEFUN (vtysh_start_bash
,
2606 vtysh_start_bash_cmd
,
2608 "Start UNIX shell\n"
2611 execute_command ("bash", 0, NULL
, NULL
);
2615 DEFUN (vtysh_start_zsh
,
2616 vtysh_start_zsh_cmd
,
2618 "Start UNIX shell\n"
2621 execute_command ("zsh", 0, NULL
, NULL
);
2627 vtysh_install_default (enum node_type node
)
2629 install_element (node
, &config_list_cmd
);
2632 /* Making connection to protocol daemon. */
2634 vtysh_connect (struct vtysh_client
*vclient
)
2638 struct sockaddr_un addr
;
2641 /* Stat socket to see if we have permission to access it. */
2642 ret
= stat (vclient
->path
, &s_stat
);
2643 if (ret
< 0 && errno
!= ENOENT
)
2645 fprintf (stderr
, "vtysh_connect(%s): stat = %s\n",
2646 vclient
->path
, safe_strerror(errno
));
2652 if (! S_ISSOCK(s_stat
.st_mode
))
2654 fprintf (stderr
, "vtysh_connect(%s): Not a socket\n",
2661 sock
= socket (AF_UNIX
, SOCK_STREAM
, 0);
2665 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", vclient
->path
,
2666 safe_strerror(errno
));
2671 memset (&addr
, 0, sizeof (struct sockaddr_un
));
2672 addr
.sun_family
= AF_UNIX
;
2673 strncpy (addr
.sun_path
, vclient
->path
, strlen (vclient
->path
));
2674 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
2675 len
= addr
.sun_len
= SUN_LEN(&addr
);
2677 len
= sizeof (addr
.sun_family
) + strlen (addr
.sun_path
);
2678 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
2680 ret
= connect (sock
, (struct sockaddr
*) &addr
, len
);
2684 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", vclient
->path
,
2685 safe_strerror(errno
));
2695 /* Return true if str ends with suffix, else return false */
2697 ends_with(const char *str
, const char *suffix
)
2699 if (!str
|| !suffix
)
2701 size_t lenstr
= strlen(str
);
2702 size_t lensuffix
= strlen(suffix
);
2703 if (lensuffix
> lenstr
)
2705 return strncmp(str
+ lenstr
- lensuffix
, suffix
, lensuffix
) == 0;
2709 vtysh_client_sorted_insert (struct vtysh_client
*head_client
,
2710 struct vtysh_client
*client
)
2712 struct vtysh_client
*prev_node
, *current_node
;
2714 prev_node
= head_client
;
2715 current_node
= head_client
->next
;
2716 while (current_node
)
2718 if (strcmp(current_node
->path
, client
->path
) > 0)
2721 prev_node
= current_node
;
2722 current_node
= current_node
->next
;
2724 client
->next
= current_node
;
2725 prev_node
->next
= client
;
2728 #define MAXIMUM_INSTANCES 10
2731 vtysh_update_all_insances(struct vtysh_client
* head_client
)
2733 struct vtysh_client
*client
;
2736 struct dirent
*file
;
2739 if (head_client
->flag
!= VTYSH_OSPFD
) return;
2741 /* ls /var/run/quagga/ and look for all files ending in .vty */
2742 dir
= opendir("/var/run/quagga/");
2745 while ((file
= readdir(dir
)) != NULL
)
2747 if (begins_with(file
->d_name
, "ospfd-") && ends_with(file
->d_name
, ".vty"))
2749 if (n
== MAXIMUM_INSTANCES
)
2752 "Parsing /var/run/quagga/, client limit(%d) reached!\n", n
);
2755 client
= (struct vtysh_client
*) malloc(sizeof(struct vtysh_client
));
2757 client
->name
= "ospfd";
2758 client
->flag
= VTYSH_OSPFD
;
2759 ptr
= (char *) malloc(100);
2760 sprintf(ptr
, "/var/run/quagga/%s", file
->d_name
);
2761 client
->path
= (const char *)ptr
;
2762 client
->next
= NULL
;
2763 vtysh_client_sorted_insert(head_client
, client
);
2772 vtysh_connect_all_instances (struct vtysh_client
*head_client
)
2774 struct vtysh_client
*client
;
2777 vtysh_update_all_insances(head_client
);
2779 client
= head_client
->next
;
2782 if (vtysh_connect(client
) == 0)
2784 client
= client
->next
;
2791 vtysh_connect_all(const char *daemon_name
)
2797 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2799 if (!daemon_name
|| !strcmp(daemon_name
, vtysh_client
[i
].name
))
2802 if (vtysh_connect(&vtysh_client
[i
]) == 0)
2805 rc
+= vtysh_connect_all_instances(&vtysh_client
[i
]);
2809 fprintf(stderr
, "Error: no daemons match name %s!\n", daemon_name
);
2813 /* To disable readline's filename completion. */
2815 vtysh_completion_entry_function (const char *ignore
, int invoking_key
)
2821 vtysh_readline_init (void)
2823 /* readline related settings. */
2824 rl_bind_key ('?', (rl_command_func_t
*) vtysh_rl_describe
);
2825 rl_completion_entry_function
= vtysh_completion_entry_function
;
2826 rl_attempted_completion_function
= (rl_completion_func_t
*)new_completion
;
2832 static struct utsname names
;
2833 static char buf
[100];
2834 const char*hostname
;
2835 extern struct host host
;
2837 hostname
= host
.name
;
2841 if (!names
.nodename
[0])
2843 hostname
= names
.nodename
;
2846 snprintf (buf
, sizeof buf
, cmd_prompt (vty
->node
), hostname
);
2852 vtysh_init_vty (void)
2854 /* Make vty structure. */
2856 vty
->type
= VTY_SHELL
;
2857 vty
->node
= VIEW_NODE
;
2859 /* Initialize commands. */
2862 /* Install nodes. */
2863 install_node (&bgp_node
, NULL
);
2864 install_node (&rip_node
, NULL
);
2865 install_node (&interface_node
, NULL
);
2866 install_node (&link_params_node
, NULL
);
2867 install_node (&vrf_node
, NULL
);
2868 install_node (&rmap_node
, NULL
);
2869 install_node (&zebra_node
, NULL
);
2870 install_node (&bgp_vpnv4_node
, NULL
);
2871 install_node (&bgp_vpnv6_node
, NULL
);
2872 install_node (&bgp_encap_node
, NULL
);
2873 install_node (&bgp_encapv6_node
, NULL
);
2874 install_node (&bgp_ipv4_node
, NULL
);
2875 install_node (&bgp_ipv4m_node
, NULL
);
2876 /* #ifdef HAVE_IPV6 */
2877 install_node (&bgp_ipv6_node
, NULL
);
2878 install_node (&bgp_ipv6m_node
, NULL
);
2880 install_node (&ospf_node
, NULL
);
2881 /* #ifdef HAVE_IPV6 */
2882 install_node (&ripng_node
, NULL
);
2883 install_node (&ospf6_node
, NULL
);
2885 install_node (&keychain_node
, NULL
);
2886 install_node (&keychain_key_node
, NULL
);
2887 install_node (&isis_node
, NULL
);
2888 install_node (&vty_node
, NULL
);
2890 vtysh_install_default (VIEW_NODE
);
2891 vtysh_install_default (ENABLE_NODE
);
2892 vtysh_install_default (CONFIG_NODE
);
2893 vtysh_install_default (BGP_NODE
);
2894 vtysh_install_default (RIP_NODE
);
2895 vtysh_install_default (INTERFACE_NODE
);
2896 vtysh_install_default (LINK_PARAMS_NODE
);
2897 vtysh_install_default (VRF_NODE
);
2898 vtysh_install_default (RMAP_NODE
);
2899 vtysh_install_default (ZEBRA_NODE
);
2900 vtysh_install_default (BGP_VPNV4_NODE
);
2901 vtysh_install_default (BGP_VPNV6_NODE
);
2902 vtysh_install_default (BGP_ENCAP_NODE
);
2903 vtysh_install_default (BGP_ENCAPV6_NODE
);
2904 vtysh_install_default (BGP_IPV4_NODE
);
2905 vtysh_install_default (BGP_IPV4M_NODE
);
2906 vtysh_install_default (BGP_IPV6_NODE
);
2907 vtysh_install_default (BGP_IPV6M_NODE
);
2908 vtysh_install_default (OSPF_NODE
);
2909 vtysh_install_default (RIPNG_NODE
);
2910 vtysh_install_default (OSPF6_NODE
);
2911 vtysh_install_default (ISIS_NODE
);
2912 vtysh_install_default (KEYCHAIN_NODE
);
2913 vtysh_install_default (KEYCHAIN_KEY_NODE
);
2914 vtysh_install_default (VTY_NODE
);
2916 install_element (VIEW_NODE
, &vtysh_enable_cmd
);
2917 install_element (ENABLE_NODE
, &vtysh_config_terminal_cmd
);
2918 install_element (ENABLE_NODE
, &vtysh_disable_cmd
);
2920 /* "exit" command. */
2921 install_element (VIEW_NODE
, &vtysh_exit_all_cmd
);
2922 install_element (VIEW_NODE
, &vtysh_quit_all_cmd
);
2923 install_element (CONFIG_NODE
, &vtysh_exit_all_cmd
);
2924 /* install_element (CONFIG_NODE, &vtysh_quit_all_cmd); */
2925 install_element (ENABLE_NODE
, &vtysh_exit_all_cmd
);
2926 install_element (ENABLE_NODE
, &vtysh_quit_all_cmd
);
2927 install_element (RIP_NODE
, &vtysh_exit_ripd_cmd
);
2928 install_element (RIP_NODE
, &vtysh_quit_ripd_cmd
);
2929 install_element (RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
2930 install_element (RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
2931 install_element (OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
2932 install_element (OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
2933 install_element (OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
2934 install_element (OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
2935 install_element (BGP_NODE
, &vtysh_exit_bgpd_cmd
);
2936 install_element (BGP_NODE
, &vtysh_quit_bgpd_cmd
);
2937 install_element (BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
2938 install_element (BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
2939 install_element (BGP_VPNV6_NODE
, &vtysh_exit_bgpd_cmd
);
2940 install_element (BGP_VPNV6_NODE
, &vtysh_quit_bgpd_cmd
);
2941 install_element (BGP_ENCAP_NODE
, &vtysh_exit_bgpd_cmd
);
2942 install_element (BGP_ENCAP_NODE
, &vtysh_quit_bgpd_cmd
);
2943 install_element (BGP_ENCAPV6_NODE
, &vtysh_exit_bgpd_cmd
);
2944 install_element (BGP_ENCAPV6_NODE
, &vtysh_quit_bgpd_cmd
);
2945 install_element (BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
2946 install_element (BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
2947 install_element (BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
2948 install_element (BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
2949 install_element (BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
2950 install_element (BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
2951 install_element (BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
2952 install_element (BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
2953 install_element (ISIS_NODE
, &vtysh_exit_isisd_cmd
);
2954 install_element (ISIS_NODE
, &vtysh_quit_isisd_cmd
);
2955 install_element (KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
2956 install_element (KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
2957 install_element (KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
2958 install_element (KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
2959 install_element (RMAP_NODE
, &vtysh_exit_rmap_cmd
);
2960 install_element (RMAP_NODE
, &vtysh_quit_rmap_cmd
);
2961 install_element (VTY_NODE
, &vtysh_exit_line_vty_cmd
);
2962 install_element (VTY_NODE
, &vtysh_quit_line_vty_cmd
);
2964 /* "end" command. */
2965 install_element (CONFIG_NODE
, &vtysh_end_all_cmd
);
2966 install_element (ENABLE_NODE
, &vtysh_end_all_cmd
);
2967 install_element (RIP_NODE
, &vtysh_end_all_cmd
);
2968 install_element (RIPNG_NODE
, &vtysh_end_all_cmd
);
2969 install_element (OSPF_NODE
, &vtysh_end_all_cmd
);
2970 install_element (OSPF6_NODE
, &vtysh_end_all_cmd
);
2971 install_element (BGP_NODE
, &vtysh_end_all_cmd
);
2972 install_element (BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
2973 install_element (BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
2974 install_element (BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
2975 install_element (BGP_VPNV6_NODE
, &vtysh_end_all_cmd
);
2976 install_element (BGP_ENCAP_NODE
, &vtysh_end_all_cmd
);
2977 install_element (BGP_ENCAPV6_NODE
, &vtysh_end_all_cmd
);
2978 install_element (BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
2979 install_element (BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
2980 install_element (ISIS_NODE
, &vtysh_end_all_cmd
);
2981 install_element (KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
2982 install_element (KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
2983 install_element (RMAP_NODE
, &vtysh_end_all_cmd
);
2984 install_element (VTY_NODE
, &vtysh_end_all_cmd
);
2986 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
2987 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
2988 install_element (INTERFACE_NODE
, &vtysh_end_all_cmd
);
2989 install_element (INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
2990 install_element (LINK_PARAMS_NODE
, &vtysh_end_all_cmd
);
2991 install_element (LINK_PARAMS_NODE
, &vtysh_exit_interface_cmd
);
2992 install_element (INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
2994 install_element (VRF_NODE
, &vtysh_end_all_cmd
);
2995 install_element (VRF_NODE
, &vtysh_exit_vrf_cmd
);
2996 install_element (VRF_NODE
, &vtysh_quit_vrf_cmd
);
2998 install_element (CONFIG_NODE
, &router_rip_cmd
);
3000 install_element (CONFIG_NODE
, &router_ripng_cmd
);
3002 install_element (CONFIG_NODE
, &router_ospf_cmd
);
3003 install_element (CONFIG_NODE
, &router_ospf_instance_cmd
);
3005 install_element (CONFIG_NODE
, &router_ospf6_cmd
);
3007 install_element (CONFIG_NODE
, &router_isis_cmd
);
3008 install_element (CONFIG_NODE
, &router_bgp_cmd
);
3009 install_element (CONFIG_NODE
, &router_bgp_asn_cmd
);
3010 install_element (CONFIG_NODE
, &router_bgp_view_cmd
);
3011 install_element (BGP_NODE
, &address_family_vpnv4_cmd
);
3012 install_element (BGP_NODE
, &address_family_vpnv4_unicast_cmd
);
3013 install_element (BGP_NODE
, &address_family_vpnv6_cmd
);
3014 install_element (BGP_NODE
, &address_family_vpnv6_unicast_cmd
);
3015 install_element (BGP_NODE
, &address_family_encap_cmd
);
3016 install_element (BGP_NODE
, &address_family_encapv6_cmd
);
3017 install_element (BGP_NODE
, &address_family_ipv4_unicast_cmd
);
3018 install_element (BGP_NODE
, &address_family_ipv4_multicast_cmd
);
3020 install_element (BGP_NODE
, &address_family_ipv6_cmd
);
3021 install_element (BGP_NODE
, &address_family_ipv6_unicast_cmd
);
3022 install_element (BGP_NODE
, &address_family_ipv6_multicast_cmd
);
3024 install_element (BGP_VPNV4_NODE
, &exit_address_family_cmd
);
3025 install_element (BGP_VPNV6_NODE
, &exit_address_family_cmd
);
3026 install_element (BGP_ENCAP_NODE
, &exit_address_family_cmd
);
3027 install_element (BGP_ENCAPV6_NODE
, &exit_address_family_cmd
);
3028 install_element (BGP_IPV4_NODE
, &exit_address_family_cmd
);
3029 install_element (BGP_IPV4M_NODE
, &exit_address_family_cmd
);
3030 install_element (BGP_IPV6_NODE
, &exit_address_family_cmd
);
3031 install_element (BGP_IPV6M_NODE
, &exit_address_family_cmd
);
3032 install_element (CONFIG_NODE
, &key_chain_cmd
);
3033 install_element (CONFIG_NODE
, &route_map_cmd
);
3034 install_element (CONFIG_NODE
, &vtysh_line_vty_cmd
);
3035 install_element (KEYCHAIN_NODE
, &key_cmd
);
3036 install_element (KEYCHAIN_NODE
, &key_chain_cmd
);
3037 install_element (KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
3038 install_element (CONFIG_NODE
, &vtysh_interface_cmd
);
3039 install_element (CONFIG_NODE
, &vtysh_no_interface_cmd
);
3040 install_element (CONFIG_NODE
, &vtysh_interface_vrf_cmd
);
3041 install_element (CONFIG_NODE
, &vtysh_no_interface_vrf_cmd
);
3042 install_element (INTERFACE_NODE
, &vtysh_link_params_cmd
);
3043 install_element (ENABLE_NODE
, &vtysh_show_running_config_cmd
);
3044 install_element (ENABLE_NODE
, &vtysh_show_running_config_daemon_cmd
);
3045 install_element (ENABLE_NODE
, &vtysh_copy_runningconfig_startupconfig_cmd
);
3046 install_element (ENABLE_NODE
, &vtysh_write_file_cmd
);
3047 install_element (ENABLE_NODE
, &vtysh_write_cmd
);
3049 install_element (CONFIG_NODE
, &vtysh_vrf_cmd
);
3050 install_element (CONFIG_NODE
, &vtysh_no_vrf_cmd
);
3052 /* "write terminal" command. */
3053 install_element (ENABLE_NODE
, &vtysh_write_terminal_cmd
);
3054 install_element (ENABLE_NODE
, &vtysh_write_terminal_daemon_cmd
);
3056 install_element (CONFIG_NODE
, &vtysh_integrated_config_cmd
);
3057 install_element (CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
3059 /* "write memory" command. */
3060 install_element (ENABLE_NODE
, &vtysh_write_memory_cmd
);
3062 install_element (VIEW_NODE
, &vtysh_terminal_length_cmd
);
3063 install_element (ENABLE_NODE
, &vtysh_terminal_length_cmd
);
3064 install_element (VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
3065 install_element (ENABLE_NODE
, &vtysh_terminal_no_length_cmd
);
3066 install_element (VIEW_NODE
, &vtysh_show_daemons_cmd
);
3067 install_element (ENABLE_NODE
, &vtysh_show_daemons_cmd
);
3069 install_element (VIEW_NODE
, &vtysh_ping_cmd
);
3070 install_element (VIEW_NODE
, &vtysh_ping_ip_cmd
);
3071 install_element (VIEW_NODE
, &vtysh_traceroute_cmd
);
3072 install_element (VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
3074 install_element (VIEW_NODE
, &vtysh_ping6_cmd
);
3075 install_element (VIEW_NODE
, &vtysh_traceroute6_cmd
);
3077 #if defined(HAVE_SHELL_ACCESS)
3078 install_element (VIEW_NODE
, &vtysh_telnet_cmd
);
3079 install_element (VIEW_NODE
, &vtysh_telnet_port_cmd
);
3080 install_element (VIEW_NODE
, &vtysh_ssh_cmd
);
3082 install_element (ENABLE_NODE
, &vtysh_ping_cmd
);
3083 install_element (ENABLE_NODE
, &vtysh_ping_ip_cmd
);
3084 install_element (ENABLE_NODE
, &vtysh_traceroute_cmd
);
3085 install_element (ENABLE_NODE
, &vtysh_traceroute_ip_cmd
);
3087 install_element (ENABLE_NODE
, &vtysh_ping6_cmd
);
3088 install_element (ENABLE_NODE
, &vtysh_traceroute6_cmd
);
3090 #if defined(HAVE_SHELL_ACCESS)
3091 install_element (ENABLE_NODE
, &vtysh_telnet_cmd
);
3092 install_element (ENABLE_NODE
, &vtysh_telnet_port_cmd
);
3093 install_element (ENABLE_NODE
, &vtysh_ssh_cmd
);
3094 install_element (ENABLE_NODE
, &vtysh_start_shell_cmd
);
3095 install_element (ENABLE_NODE
, &vtysh_start_bash_cmd
);
3096 install_element (ENABLE_NODE
, &vtysh_start_zsh_cmd
);
3099 install_element (VIEW_NODE
, &vtysh_show_memory_cmd
);
3100 install_element (ENABLE_NODE
, &vtysh_show_memory_cmd
);
3102 install_element (VIEW_NODE
, &vtysh_show_work_queues_cmd
);
3103 install_element (ENABLE_NODE
, &vtysh_show_work_queues_cmd
);
3104 install_element (ENABLE_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3105 install_element (VIEW_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3107 install_element (VIEW_NODE
, &vtysh_show_thread_cmd
);
3108 install_element (ENABLE_NODE
, &vtysh_show_thread_cmd
);
3111 install_element (ENABLE_NODE
, &vtysh_show_logging_cmd
);
3112 install_element (VIEW_NODE
, &vtysh_show_logging_cmd
);
3113 install_element (CONFIG_NODE
, &vtysh_log_stdout_cmd
);
3114 install_element (CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
3115 install_element (CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
3116 install_element (CONFIG_NODE
, &vtysh_log_file_cmd
);
3117 install_element (CONFIG_NODE
, &vtysh_log_file_level_cmd
);
3118 install_element (CONFIG_NODE
, &no_vtysh_log_file_cmd
);
3119 install_element (CONFIG_NODE
, &no_vtysh_log_file_level_cmd
);
3120 install_element (CONFIG_NODE
, &vtysh_log_monitor_cmd
);
3121 install_element (CONFIG_NODE
, &vtysh_log_monitor_level_cmd
);
3122 install_element (CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
3123 install_element (CONFIG_NODE
, &vtysh_log_syslog_cmd
);
3124 install_element (CONFIG_NODE
, &vtysh_log_syslog_level_cmd
);
3125 install_element (CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
3126 install_element (CONFIG_NODE
, &vtysh_log_trap_cmd
);
3127 install_element (CONFIG_NODE
, &no_vtysh_log_trap_cmd
);
3128 install_element (CONFIG_NODE
, &vtysh_log_facility_cmd
);
3129 install_element (CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
3130 install_element (CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
3131 install_element (CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
3132 install_element (CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
3133 install_element (CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
3135 install_element (CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
3136 install_element (CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
3138 install_element (CONFIG_NODE
, &vtysh_password_cmd
);
3139 install_element (CONFIG_NODE
, &vtysh_password_text_cmd
);
3140 install_element (CONFIG_NODE
, &vtysh_enable_password_cmd
);
3141 install_element (CONFIG_NODE
, &vtysh_enable_password_text_cmd
);
3142 install_element (CONFIG_NODE
, &no_vtysh_enable_password_cmd
);