1 /* Virtual terminal interface shell.
2 * Copyright (C) 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 #include <sys/resource.h>
30 #include <readline/readline.h>
31 #include <readline/history.h>
41 #include "vtysh/vtysh.h"
43 #include "bgpd/bgp_vty.h"
47 DEFINE_MTYPE_STATIC(MVTYSH
, VTYSH_CMD
, "Vtysh cmd copy")
52 /* VTY shell pager name. */
53 char *vtysh_pager_name
= NULL
;
55 /* VTY shell client structure. */
62 struct vtysh_client
*next
;
65 struct vtysh_client vtysh_client
[] =
67 { .fd
= -1, .name
= "zebra", .flag
= VTYSH_ZEBRA
, .path
= ZEBRA_VTYSH_PATH
, .next
= NULL
},
68 { .fd
= -1, .name
= "ripd", .flag
= VTYSH_RIPD
, .path
= RIP_VTYSH_PATH
, .next
= NULL
},
69 { .fd
= -1, .name
= "ripngd", .flag
= VTYSH_RIPNGD
, .path
= RIPNG_VTYSH_PATH
, .next
= NULL
},
70 { .fd
= -1, .name
= "ospfd", .flag
= VTYSH_OSPFD
, .path
= OSPF_VTYSH_PATH
, .next
= NULL
},
71 { .fd
= -1, .name
= "ospf6d", .flag
= VTYSH_OSPF6D
, .path
= OSPF6_VTYSH_PATH
, .next
= NULL
},
72 { .fd
= -1, .name
= "bgpd", .flag
= VTYSH_BGPD
, .path
= BGP_VTYSH_PATH
, .next
= NULL
},
73 { .fd
= -1, .name
= "isisd", .flag
= VTYSH_ISISD
, .path
= ISIS_VTYSH_PATH
, .next
= NULL
},
74 { .fd
= -1, .name
= "pimd", .flag
= VTYSH_PIMD
, .path
= PIM_VTYSH_PATH
, .next
= NULL
},
77 /* Using integrated config from Quagga.conf. Default is no. */
78 int vtysh_writeconfig_integrated
= 1;
80 extern char config_default
[];
83 vclient_close (struct vtysh_client
*vclient
)
88 "Warning: closing connection to %s because of an I/O error!\n",
95 /* Return true if str begins with prefix, else return false */
97 begins_with(const char *str
, const char *prefix
)
101 size_t lenstr
= strlen(str
);
102 size_t lenprefix
= strlen(prefix
);
103 if (lenprefix
> lenstr
)
105 return strncmp(str
, prefix
, lenprefix
) == 0;
108 /* Following filled with debug code to trace a problematic condition
109 * under load - it SHOULD handle it. */
110 #define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): "
112 vtysh_client_config_one (struct vtysh_client
*vclient
, char *line
)
127 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
130 vclient_close (vclient
);
134 /* Allow enough room for buffer to read more than a few pages from socket. */
135 bufsz
= 5 * getpagesize() + 1;
136 buf
= XMALLOC(MTYPE_TMP
, bufsz
);
137 memset(buf
, 0, bufsz
);
142 if (pbuf
>= ((buf
+ bufsz
) -1))
144 fprintf (stderr
, ERR_WHERE_STRING \
145 "warning - pbuf beyond buffer end.\n");
149 readln
= (buf
+ bufsz
) - pbuf
- 1;
150 nbytes
= read (vclient
->fd
, pbuf
, readln
);
158 fprintf(stderr
, ERR_WHERE_STRING
"(%u)", errno
);
161 if (errno
== EAGAIN
|| errno
== EIO
)
164 vclient_close (vclient
);
165 XFREE(MTYPE_TMP
, buf
);
174 if (pbuf
[i
] == '\0' && pbuf
[i
+ 1] == '\0' && pbuf
[i
+ 2] == '\0')
182 /* See if a line exists in buffer, if so parse and consume it, and
183 * reset read position. */
184 if ((eoln
= strrchr(buf
, '\n')) == NULL
)
187 if (eoln
>= ((buf
+ bufsz
) - 1))
189 fprintf (stderr
, ERR_WHERE_STRING \
190 "warning - eoln beyond buffer end.\n");
192 vtysh_config_parse(buf
);
195 left
= (size_t)(buf
+ bufsz
- eoln
);
196 memmove(buf
, eoln
, left
);
198 pbuf
= buf
+ strlen(buf
);
201 /* Parse anything left in the buffer. */
203 vtysh_config_parse (buf
);
205 XFREE(MTYPE_TMP
, buf
);
210 vtysh_client_config (struct vtysh_client
*head_client
, char *line
)
212 struct vtysh_client
*client
;
215 rc
= vtysh_client_config_one(head_client
, line
);
216 if (rc
!= CMD_SUCCESS
)
219 client
= head_client
->next
;
222 rc
= vtysh_client_config_one(client
, line
);
223 if (rc
!= CMD_SUCCESS
)
225 client
= client
->next
;
231 vtysh_client_execute_one (struct vtysh_client
*vclient
, const char *line
, FILE *fp
)
242 ret
= write (vclient
->fd
, line
, strlen (line
) + 1);
245 vclient_close (vclient
);
251 nbytes
= read (vclient
->fd
, buf
, sizeof(buf
)-1);
253 if (nbytes
<= 0 && errno
!= EINTR
)
255 vclient_close (vclient
);
261 if ((numnulls
== 3) && (nbytes
== 1))
268 /* check for trailling \0\0\0<ret code>,
269 * even if split across reads
270 * (see lib/vty.c::vtysh_read)
280 while (i
< nbytes
&& numnulls
< 3)
282 if (buf
[i
++] == '\0')
288 /* got 3 or more trailing NULs? */
289 if ((numnulls
>= 3) && (i
< nbytes
))
290 return (buf
[nbytes
-1]);
296 vtysh_client_execute (struct vtysh_client
*head_client
, const char *line
, FILE *fp
)
298 struct vtysh_client
*client
;
301 rc
= vtysh_client_execute_one(head_client
, line
, fp
);
302 if (rc
!= CMD_SUCCESS
)
305 client
= head_client
->next
;
308 rc
= vtysh_client_execute_one(client
, line
, fp
);
309 if (rc
!= CMD_SUCCESS
)
311 client
= client
->next
;
317 vtysh_pager_init (void)
321 pager_defined
= getenv ("VTYSH_PAGER");
324 vtysh_pager_name
= strdup (pager_defined
);
326 vtysh_pager_name
= strdup ("more");
329 /* Command execution over the vty interface. */
331 vtysh_execute_func (const char *line
, int pager
)
336 struct cmd_element
*cmd
;
340 int saved_ret
, saved_node
;
342 /* Split readline string up into the vector. */
343 vline
= cmd_make_strvec (line
);
348 saved_ret
= ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
349 saved_node
= vty
->node
;
351 /* If command doesn't succeeded in current node, try to walk up in node tree.
352 * Changing vty->node is enough to try it just out without actual walkup in
354 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
355 && vty
->node
> CONFIG_NODE
)
357 vty
->node
= node_parent(vty
->node
);
358 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
362 vty
->node
= saved_node
;
364 /* If command succeeded in any other node than current (tried > 0) we have
365 * to move into node in the vtysh where it succeeded. */
366 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
368 if ((saved_node
== BGP_VPNV4_NODE
|| saved_node
== BGP_VPNV6_NODE
369 || saved_node
== BGP_ENCAP_NODE
|| saved_node
== BGP_ENCAPV6_NODE
370 || saved_node
== BGP_IPV4_NODE
371 || saved_node
== BGP_IPV6_NODE
|| saved_node
== BGP_IPV4M_NODE
372 || saved_node
== BGP_IPV6M_NODE
)
375 vtysh_execute("exit-address-family");
377 else if ((saved_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
379 vtysh_execute("exit");
383 vtysh_execute ("end");
384 vtysh_execute ("configure terminal");
387 /* If command didn't succeed in any node, continue with return value from
394 cmd_free_strvec (vline
);
400 if (vty
->type
== VTY_FILE
)
401 fprintf (stdout
,"Warning...\n");
403 case CMD_ERR_AMBIGUOUS
:
404 fprintf (stdout
,"%% Ambiguous command.\n");
406 case CMD_ERR_NO_MATCH
:
407 fprintf (stdout
,"%% Unknown command.\n");
409 case CMD_ERR_INCOMPLETE
:
410 fprintf (stdout
,"%% Command incomplete.\n");
412 case CMD_SUCCESS_DAEMON
:
414 /* FIXME: Don't open pager for exit commands. popen() causes problems
415 * if exited from vtysh at all. This hack shouldn't cause any problem
416 * but is really ugly. */
417 if (pager
&& vtysh_pager_name
&& (strncmp(line
, "exit", 4) != 0))
419 fp
= popen (vtysh_pager_name
, "w");
422 perror ("popen failed for pager");
431 if (! strcmp(cmd
->string
,"configure terminal"))
433 for (i
= 0; i
< array_size(vtysh_client
); i
++)
435 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
436 if (cmd_stat
== CMD_WARNING
)
443 vline
= cmd_make_strvec (line
);
447 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
449 if (pclose (fp
) == -1)
451 perror ("pclose failed for pager");
458 ret
= cmd_execute_command (vline
, vty
, &cmd
, 1);
459 cmd_free_strvec (vline
);
460 if (ret
!= CMD_SUCCESS_DAEMON
)
466 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
471 cmd_stat
= CMD_SUCCESS
;
472 for (i
= 0; i
< array_size(vtysh_client
); i
++)
474 if (cmd
->daemon
& vtysh_client
[i
].flag
)
476 cmd_stat
= vtysh_client_execute(&vtysh_client
[i
], line
, fp
);
477 if (cmd_stat
!= CMD_SUCCESS
)
481 if (cmd_stat
!= CMD_SUCCESS
)
485 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
488 if (pager
&& vtysh_pager_name
&& fp
&& closepager
)
490 if (pclose (fp
) == -1)
492 perror ("pclose failed for pager");
500 vtysh_execute_no_pager (const char *line
)
502 return vtysh_execute_func (line
, 0);
506 vtysh_execute (const char *line
)
508 return vtysh_execute_func (line
, 1);
523 while (end
>= s
&& isspace(*end
))
527 while (*s
&& isspace(*s
))
534 vtysh_mark_file (const char *filename
)
541 struct cmd_element
*cmd
;
542 int saved_ret
, prev_node
;
544 char *vty_buf_copy
= NULL
;
545 char *vty_buf_trimmed
= NULL
;
547 if (strncmp("-", filename
, 1) == 0)
550 confp
= fopen (filename
, "r");
554 fprintf (stderr
, "%% Can't open config file %s due to '%s'.\n",
555 filename
, safe_strerror (errno
));
556 return (CMD_ERR_NO_FILE
);
560 vty
->fd
= 0; /* stdout */
561 vty
->type
= VTY_TERM
;
562 vty
->node
= CONFIG_NODE
;
564 vtysh_execute_no_pager ("enable");
565 vtysh_execute_no_pager ("configure terminal");
566 vty_buf_copy
= XCALLOC (MTYPE_VTYSH_CMD
, VTY_BUFSIZ
);
568 while (fgets (vty
->buf
, VTY_BUFSIZ
, confp
))
572 strcpy(vty_buf_copy
, vty
->buf
);
573 vty_buf_trimmed
= trim(vty_buf_copy
);
575 if (vty_buf_trimmed
[0] == '!' || vty_buf_trimmed
[0] == '#')
577 fprintf(stdout
, "%s", vty
->buf
);
581 /* Split readline string up into the vector. */
582 vline
= cmd_make_strvec (vty
->buf
);
586 fprintf(stdout
, "%s", vty
->buf
);
590 /* Ignore the "end" lines, we will generate these where appropriate */
591 if (strlen(vty_buf_trimmed
) == 3 && strncmp("end", vty_buf_trimmed
, 3) == 0)
596 prev_node
= vty
->node
;
597 saved_ret
= ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
599 /* If command doesn't succeeded in current node, try to walk up in node tree.
600 * Changing vty->node is enough to try it just out without actual walkup in
602 while (ret
!= CMD_SUCCESS
&& ret
!= CMD_SUCCESS_DAEMON
&& ret
!= CMD_WARNING
603 && vty
->node
> CONFIG_NODE
)
605 vty
->node
= node_parent(vty
->node
);
606 ret
= cmd_execute_command_strict (vline
, vty
, &cmd
);
610 /* If command succeeded in any other node than current (tried > 0) we have
611 * to move into node in the vtysh where it succeeded. */
612 if (ret
== CMD_SUCCESS
|| ret
== CMD_SUCCESS_DAEMON
|| ret
== CMD_WARNING
)
614 if ((prev_node
== BGP_VPNV4_NODE
|| prev_node
== BGP_IPV4_NODE
615 || prev_node
== BGP_IPV6_NODE
|| prev_node
== BGP_IPV4M_NODE
616 || prev_node
== BGP_IPV6M_NODE
|| prev_node
== BGP_VPNV6_NODE
)
619 fprintf(stdout
, "exit-address-family\n");
621 else if ((prev_node
== KEYCHAIN_KEY_NODE
) && (tried
== 1))
623 fprintf(stdout
, "exit\n");
627 fprintf(stdout
, "end\n");
630 /* If command didn't succeed in any node, continue with return value from
635 vty
->node
= prev_node
;
638 cmd_free_strvec (vline
);
642 if (vty
->type
== VTY_FILE
)
643 fprintf (stderr
,"line %d: Warning...: %s\n", lineno
, vty
->buf
);
646 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
648 case CMD_ERR_AMBIGUOUS
:
649 fprintf (stderr
,"line %d: %% Ambiguous command: %s\n", lineno
, vty
->buf
);
652 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
653 return CMD_ERR_AMBIGUOUS
;
654 case CMD_ERR_NO_MATCH
:
655 fprintf (stderr
,"line %d: %% Unknown command: %s\n", lineno
, vty
->buf
);
658 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
659 return CMD_ERR_NO_MATCH
;
660 case CMD_ERR_INCOMPLETE
:
661 fprintf (stderr
,"line %d: %% Command incomplete: %s\n", lineno
, vty
->buf
);
664 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
665 return CMD_ERR_INCOMPLETE
;
667 fprintf(stdout
, "%s", vty
->buf
);
669 case CMD_SUCCESS_DAEMON
:
672 int cmd_stat
= CMD_SUCCESS
;
674 fprintf(stdout
, "%s", vty
->buf
);
675 for (i
= 0; i
< array_size(vtysh_client
); i
++)
677 if (cmd
->daemon
& vtysh_client
[i
].flag
)
679 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
681 if (cmd_stat
!= CMD_SUCCESS
)
685 if (cmd_stat
!= CMD_SUCCESS
)
689 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
693 /* This is the end */
694 fprintf(stdout
, "end\n");
696 XFREE(MTYPE_VTYSH_CMD
, vty_buf_copy
);
704 /* Configration make from file. */
706 vtysh_config_from_file (struct vty
*vty
, FILE *fp
)
709 struct cmd_element
*cmd
;
711 int retcode
= CMD_SUCCESS
;
713 while (fgets (vty
->buf
, VTY_BUFSIZ
, fp
))
717 ret
= command_config_read_one_line (vty
, &cmd
, 1);
722 if (vty
->type
== VTY_FILE
)
723 fprintf (stderr
,"line %d: Warning[%d]...: %s\n", lineno
, vty
->node
, vty
->buf
);
724 retcode
= CMD_WARNING
; /* once we have an error, we remember & return that */
726 case CMD_ERR_AMBIGUOUS
:
727 fprintf (stderr
,"line %d: %% Ambiguous command[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
728 retcode
= CMD_ERR_AMBIGUOUS
; /* once we have an error, we remember & return that */
730 case CMD_ERR_NO_MATCH
:
731 fprintf (stderr
,"line %d: %% Unknown command[%d]: %s", lineno
, vty
->node
, vty
->buf
);
732 retcode
= CMD_ERR_NO_MATCH
; /* once we have an error, we remember & return that */
734 case CMD_ERR_INCOMPLETE
:
735 fprintf (stderr
,"line %d: %% Command incomplete[%d]: %s\n", lineno
, vty
->node
, vty
->buf
);
736 retcode
= CMD_ERR_INCOMPLETE
; /* once we have an error, we remember & return that */
738 case CMD_SUCCESS_DAEMON
:
741 int cmd_stat
= CMD_SUCCESS
;
743 for (i
= 0; i
< array_size(vtysh_client
); i
++)
745 if (cmd
->daemon
& vtysh_client
[i
].flag
)
747 cmd_stat
= vtysh_client_execute (&vtysh_client
[i
],
750 * CMD_WARNING - Can mean that the command was
751 * parsed successfully but it was already entered
752 * in a few spots. As such if we receive a
753 * CMD_WARNING from a daemon we shouldn't stop
754 * talking to the other daemons for the particular
757 if (cmd_stat
!= CMD_SUCCESS
&& cmd_stat
!= CMD_WARNING
)
759 fprintf (stderr
, "line %d: Failure to communicate[%d] to %s, line: %s\n",
760 lineno
, cmd_stat
, vtysh_client
[i
].name
, vty
->buf
);
765 if (cmd_stat
!= CMD_SUCCESS
)
769 (*cmd
->func
) (cmd
, vty
, 0, NULL
);
777 /* We don't care about the point of the cursor when '?' is typed. */
779 vtysh_rl_describe (void)
786 struct cmd_token
*token
;
788 vline
= cmd_make_strvec (rl_line_buffer
);
790 /* In case of '> ?'. */
793 vline
= vector_init (1);
794 vector_set (vline
, NULL
);
797 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
798 vector_set (vline
, NULL
);
800 describe
= cmd_describe_command (vline
, vty
, &ret
);
802 fprintf (stdout
,"\n");
804 /* Ambiguous and no match error. */
807 case CMD_ERR_AMBIGUOUS
:
808 cmd_free_strvec (vline
);
809 fprintf (stdout
,"%% Ambiguous command.\n");
813 case CMD_ERR_NO_MATCH
:
814 cmd_free_strvec (vline
);
815 fprintf (stdout
,"%% There is no matched command.\n");
821 /* Get width of command string. */
823 for (i
= 0; i
< vector_active (describe
); i
++)
824 if ((token
= vector_slot (describe
, i
)) != NULL
)
828 if (token
->cmd
[0] == '\0')
831 len
= strlen (token
->cmd
);
832 if (token
->cmd
[0] == '.')
839 for (i
= 0; i
< vector_active (describe
); i
++)
840 if ((token
= vector_slot (describe
, i
)) != NULL
)
842 if (token
->cmd
[0] == '\0')
846 fprintf (stdout
," %-s\n",
847 token
->cmd
[0] == '.' ? token
->cmd
+ 1 : token
->cmd
);
849 fprintf (stdout
," %-*s %s\n",
851 token
->cmd
[0] == '.' ? token
->cmd
+ 1 : token
->cmd
,
855 cmd_free_strvec (vline
);
856 vector_free (describe
);
863 /* Result of cmd_complete_command() call will be stored here
864 * and used in new_completion() in order to put the space in
865 * correct places only. */
869 command_generator (const char *text
, int state
)
872 static char **matched
= NULL
;
873 static int index
= 0;
880 if (vty
->node
== AUTH_NODE
|| vty
->node
== AUTH_ENABLE_NODE
)
883 vline
= cmd_make_strvec (rl_line_buffer
);
887 if (rl_end
&& isspace ((int) rl_line_buffer
[rl_end
- 1]))
888 vector_set (vline
, NULL
);
891 XFREE (MTYPE_TMP
, matched
);
892 matched
= cmd_complete_command (vline
, vty
, &complete_status
);
893 cmd_free_strvec (vline
);
896 if (matched
&& matched
[index
])
897 return matched
[index
++];
903 new_completion (char *text
, int start
, int end
)
907 matches
= rl_completion_matches (text
, command_generator
);
912 if (complete_status
!= CMD_COMPLETE_FULL_MATCH
)
913 /* only append a space on full match */
914 rl_completion_append_character
= '\0';
920 /* Vty node structures. */
921 static struct cmd_node bgp_node
=
924 "%s(config-router)# ",
927 static struct cmd_node rip_node
=
930 "%s(config-router)# ",
933 static struct cmd_node isis_node
=
936 "%s(config-router)# ",
939 static struct cmd_node interface_node
=
945 static struct cmd_node ns_node
=
948 "%s(config-logical-router)# ",
951 static struct cmd_node vrf_node
=
957 static struct cmd_node rmap_node
=
960 "%s(config-route-map)# "
963 static struct cmd_node zebra_node
=
966 "%s(config-router)# "
969 static struct cmd_node bgp_vpnv4_node
=
972 "%s(config-router-af)# "
975 static struct cmd_node bgp_vpnv6_node
=
978 "%s(config-router-af)# "
981 static struct cmd_node bgp_encap_node
=
984 "%s(config-router-af)# "
987 static struct cmd_node bgp_encapv6_node
=
990 "%s(config-router-af)# "
993 static struct cmd_node bgp_ipv4_node
=
996 "%s(config-router-af)# "
999 static struct cmd_node bgp_ipv4m_node
=
1002 "%s(config-router-af)# "
1005 static struct cmd_node bgp_ipv6_node
=
1008 "%s(config-router-af)# "
1011 static struct cmd_node bgp_ipv6m_node
=
1014 "%s(config-router-af)# "
1017 static struct cmd_node ospf_node
=
1020 "%s(config-router)# "
1023 static struct cmd_node ripng_node
=
1026 "%s(config-router)# "
1029 static struct cmd_node ospf6_node
=
1032 "%s(config-ospf6)# "
1035 static struct cmd_node keychain_node
=
1038 "%s(config-keychain)# "
1041 static struct cmd_node keychain_key_node
=
1044 "%s(config-keychain-key)# "
1047 struct cmd_node link_params_node
=
1050 "%s(config-link-params)# ",
1053 /* Defined in lib/vty.c */
1054 extern struct cmd_node vty_node
;
1056 /* When '^Z' is received from vty, move down to the enable mode. */
1064 /* Nothing to do. */
1067 vty
->node
= ENABLE_NODE
;
1077 "End current mode and change to enable mode\n")
1079 return vtysh_end ();
1082 DEFUNSH (VTYSH_BGPD
,
1085 "router bgp " CMD_AS_RANGE
,
1090 vty
->node
= BGP_NODE
;
1094 ALIAS_SH (VTYSH_BGPD
,
1101 ALIAS_SH (VTYSH_BGPD
,
1103 router_bgp_view_cmd
,
1104 "router bgp " CMD_AS_RANGE
" (view|vrf) WORD",
1108 "BGP view\nBGP VRF\n"
1111 DEFUNSH (VTYSH_BGPD
,
1112 address_family_vpnv4
,
1113 address_family_vpnv4_cmd
,
1114 "address-family vpnv4",
1115 "Enter Address Family command mode\n"
1118 vty
->node
= BGP_VPNV4_NODE
;
1122 DEFUNSH (VTYSH_BGPD
,
1123 address_family_vpnv4_unicast
,
1124 address_family_vpnv4_unicast_cmd
,
1125 "address-family vpnv4 unicast",
1126 "Enter Address Family command mode\n"
1128 "Address Family Modifier\n")
1130 vty
->node
= BGP_VPNV4_NODE
;
1134 DEFUNSH (VTYSH_BGPD
,
1135 address_family_vpnv6
,
1136 address_family_vpnv6_cmd
,
1137 "address-family vpnv6",
1138 "Enter Address Family command mode\n"
1141 vty
->node
= BGP_VPNV6_NODE
;
1145 DEFUNSH (VTYSH_BGPD
,
1146 address_family_vpnv6_unicast
,
1147 address_family_vpnv6_unicast_cmd
,
1148 "address-family vpnv6 unicast",
1149 "Enter Address Family command mode\n"
1151 "Address Family Modifier\n")
1153 vty
->node
= BGP_VPNV6_NODE
;
1157 DEFUNSH (VTYSH_BGPD
,
1158 address_family_encap
,
1159 address_family_encap_cmd
,
1160 "address-family encap",
1161 "Enter Address Family command mode\n"
1164 vty
->node
= BGP_ENCAP_NODE
;
1168 DEFUNSH (VTYSH_BGPD
,
1169 address_family_encapv4
,
1170 address_family_encapv4_cmd
,
1171 "address-family encapv4",
1172 "Enter Address Family command mode\n"
1175 vty
->node
= BGP_ENCAP_NODE
;
1179 DEFUNSH (VTYSH_BGPD
,
1180 address_family_encapv6
,
1181 address_family_encapv6_cmd
,
1182 "address-family encapv6",
1183 "Enter Address Family command mode\n"
1186 vty
->node
= BGP_ENCAPV6_NODE
;
1190 DEFUNSH (VTYSH_BGPD
,
1191 address_family_ipv4_unicast
,
1192 address_family_ipv4_unicast_cmd
,
1193 "address-family ipv4 unicast",
1194 "Enter Address Family command mode\n"
1196 "Address Family Modifier\n")
1198 vty
->node
= BGP_IPV4_NODE
;
1202 DEFUNSH (VTYSH_BGPD
,
1203 address_family_ipv4_multicast
,
1204 address_family_ipv4_multicast_cmd
,
1205 "address-family ipv4 multicast",
1206 "Enter Address Family command mode\n"
1208 "Address Family Modifier\n")
1210 vty
->node
= BGP_IPV4M_NODE
;
1214 DEFUNSH (VTYSH_BGPD
,
1215 address_family_ipv6
,
1216 address_family_ipv6_cmd
,
1217 "address-family ipv6",
1218 "Enter Address Family command mode\n"
1221 vty
->node
= BGP_IPV6_NODE
;
1225 DEFUNSH (VTYSH_BGPD
,
1226 address_family_ipv6_unicast
,
1227 address_family_ipv6_unicast_cmd
,
1228 "address-family ipv6 unicast",
1229 "Enter Address Family command mode\n"
1231 "Address Family Modifier\n")
1233 vty
->node
= BGP_IPV6_NODE
;
1237 DEFUNSH (VTYSH_BGPD
,
1238 address_family_ipv6_multicast
,
1239 address_family_ipv6_multicast_cmd
,
1240 "address-family ipv6 multicast",
1241 "Enter Address Family command mode\n"
1243 "Address Family Modifier\n")
1245 vty
->node
= BGP_IPV6M_NODE
;
1249 DEFUNSH (VTYSH_RIPD
,
1253 "Authentication key management\n"
1254 "Key-chain management\n"
1257 vty
->node
= KEYCHAIN_NODE
;
1261 DEFUNSH (VTYSH_RIPD
,
1264 "key <0-2147483647>",
1266 "Key identifier number\n")
1268 vty
->node
= KEYCHAIN_KEY_NODE
;
1272 DEFUNSH (VTYSH_RIPD
,
1279 vty
->node
= RIP_NODE
;
1283 DEFUNSH (VTYSH_RIPNGD
,
1290 vty
->node
= RIPNG_NODE
;
1294 DEFUNSH (VTYSH_OSPFD
,
1298 "Enable a routing process\n"
1299 "Start OSPF configuration\n")
1301 vty
->node
= OSPF_NODE
;
1305 ALIAS_SH (VTYSH_OSPFD
,
1307 router_ospf_instance_cmd
,
1308 "router ospf <1-65535>",
1309 "Enable a routing process\n"
1310 "Start OSPF configuration\n"
1313 DEFUNSH (VTYSH_OSPF6D
,
1320 vty
->node
= OSPF6_NODE
;
1324 DEFUNSH (VTYSH_ISISD
,
1330 "ISO Routing area tag")
1332 vty
->node
= ISIS_NODE
;
1336 DEFUNSH (VTYSH_RMAP
,
1339 "route-map WORD (deny|permit) <1-65535>",
1340 "Create route-map or enter route-map command mode\n"
1342 "Route map denies set operations\n"
1343 "Route map permits set operations\n"
1344 "Sequence to insert to/delete from existing route-map entry\n")
1346 vty
->node
= RMAP_NODE
;
1354 "Configure a terminal line\n"
1355 "Virtual terminal\n")
1357 vty
->node
= VTY_NODE
;
1365 "Turn on privileged mode command\n")
1367 vty
->node
= ENABLE_NODE
;
1375 "Turn off privileged mode command\n")
1377 if (vty
->node
== ENABLE_NODE
)
1378 vty
->node
= VIEW_NODE
;
1383 vtysh_config_terminal
,
1384 vtysh_config_terminal_cmd
,
1385 "configure terminal",
1386 "Configuration from vty interface\n"
1387 "Configuration terminal\n")
1389 vty
->node
= CONFIG_NODE
;
1394 vtysh_exit (struct vty
*vty
)
1403 vty
->node
= ENABLE_NODE
;
1405 case INTERFACE_NODE
:
1419 vtysh_execute("end");
1420 vtysh_execute("configure terminal");
1421 vty
->node
= CONFIG_NODE
;
1423 case BGP_VPNV4_NODE
:
1424 case BGP_VPNV6_NODE
:
1425 case BGP_ENCAP_NODE
:
1426 case BGP_ENCAPV6_NODE
:
1428 case BGP_IPV4M_NODE
:
1430 case BGP_IPV6M_NODE
:
1431 vty
->node
= BGP_NODE
;
1433 case KEYCHAIN_KEY_NODE
:
1434 vty
->node
= KEYCHAIN_NODE
;
1436 case LINK_PARAMS_NODE
:
1437 vty
->node
= INTERFACE_NODE
;
1449 "Exit current mode and down to previous mode\n")
1451 return vtysh_exit (vty
);
1454 ALIAS (vtysh_exit_all
,
1457 "Exit current mode and down to previous mode\n")
1459 DEFUNSH (VTYSH_BGPD
,
1460 exit_address_family
,
1461 exit_address_family_cmd
,
1462 "exit-address-family",
1463 "Exit from Address Family configuration mode\n")
1465 if (vty
->node
== BGP_IPV4_NODE
1466 || vty
->node
== BGP_IPV4M_NODE
1467 || vty
->node
== BGP_VPNV4_NODE
1468 || vty
->node
== BGP_VPNV6_NODE
1469 || vty
->node
== BGP_ENCAP_NODE
1470 || vty
->node
== BGP_ENCAPV6_NODE
1471 || vty
->node
== BGP_IPV6_NODE
1472 || vty
->node
== BGP_IPV6M_NODE
)
1473 vty
->node
= BGP_NODE
;
1477 DEFUNSH (VTYSH_ZEBRA
,
1479 vtysh_exit_zebra_cmd
,
1481 "Exit current mode and down to previous mode\n")
1483 return vtysh_exit (vty
);
1486 ALIAS (vtysh_exit_zebra
,
1487 vtysh_quit_zebra_cmd
,
1489 "Exit current mode and down to previous mode\n")
1491 DEFUNSH (VTYSH_RIPD
,
1493 vtysh_exit_ripd_cmd
,
1495 "Exit current mode and down to previous mode\n")
1497 return vtysh_exit (vty
);
1500 ALIAS (vtysh_exit_ripd
,
1501 vtysh_quit_ripd_cmd
,
1503 "Exit current mode and down to previous mode\n")
1505 DEFUNSH (VTYSH_RIPNGD
,
1507 vtysh_exit_ripngd_cmd
,
1509 "Exit current mode and down to previous mode\n")
1511 return vtysh_exit (vty
);
1514 ALIAS (vtysh_exit_ripngd
,
1515 vtysh_quit_ripngd_cmd
,
1517 "Exit current mode and down to previous mode\n")
1519 DEFUNSH (VTYSH_RMAP
,
1521 vtysh_exit_rmap_cmd
,
1523 "Exit current mode and down to previous mode\n")
1525 return vtysh_exit (vty
);
1528 ALIAS (vtysh_exit_rmap
,
1529 vtysh_quit_rmap_cmd
,
1531 "Exit current mode and down to previous mode\n")
1533 DEFUNSH (VTYSH_BGPD
,
1535 vtysh_exit_bgpd_cmd
,
1537 "Exit current mode and down to previous mode\n")
1539 return vtysh_exit (vty
);
1542 ALIAS (vtysh_exit_bgpd
,
1543 vtysh_quit_bgpd_cmd
,
1545 "Exit current mode and down to previous mode\n")
1547 DEFUNSH (VTYSH_OSPFD
,
1549 vtysh_exit_ospfd_cmd
,
1551 "Exit current mode and down to previous mode\n")
1553 return vtysh_exit (vty
);
1556 ALIAS (vtysh_exit_ospfd
,
1557 vtysh_quit_ospfd_cmd
,
1559 "Exit current mode and down to previous mode\n")
1561 DEFUNSH (VTYSH_OSPF6D
,
1563 vtysh_exit_ospf6d_cmd
,
1565 "Exit current mode and down to previous mode\n")
1567 return vtysh_exit (vty
);
1570 ALIAS (vtysh_exit_ospf6d
,
1571 vtysh_quit_ospf6d_cmd
,
1573 "Exit current mode and down to previous mode\n")
1575 DEFUNSH (VTYSH_ISISD
,
1577 vtysh_exit_isisd_cmd
,
1579 "Exit current mode and down to previous mode\n")
1581 return vtysh_exit (vty
);
1584 ALIAS (vtysh_exit_isisd
,
1585 vtysh_quit_isisd_cmd
,
1587 "Exit current mode and down to previous mode\n")
1590 vtysh_exit_line_vty
,
1591 vtysh_exit_line_vty_cmd
,
1593 "Exit current mode and down to previous mode\n")
1595 return vtysh_exit (vty
);
1598 ALIAS (vtysh_exit_line_vty
,
1599 vtysh_quit_line_vty_cmd
,
1601 "Exit current mode and down to previous mode\n")
1603 DEFUNSH (VTYSH_INTERFACE
,
1605 vtysh_interface_cmd
,
1607 "Select an interface to configure\n"
1608 "Interface's name\n")
1610 vty
->node
= INTERFACE_NODE
;
1614 ALIAS_SH (VTYSH_ZEBRA
,
1616 vtysh_interface_vrf_cmd
,
1617 "interface IFNAME " VRF_CMD_STR
,
1618 "Select an interface to configure\n"
1619 "Interface's name\n"
1622 /* TODO Implement "no interface command in isisd. */
1623 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_RIPNGD
|VTYSH_OSPFD
|VTYSH_OSPF6D
,
1624 vtysh_no_interface_cmd
,
1625 "no interface IFNAME",
1627 "Delete a pseudo interface's configuration\n"
1628 "Interface's name\n")
1631 vtysh_no_interface_vrf_cmd
,
1632 "no interface IFNAME " VRF_CMD_STR
,
1634 "Delete a pseudo interface's configuration\n"
1635 "Interface's name\n"
1641 "logical-router <1-65535 ns NAME",
1642 "Enable a logical-router\n"
1643 "Specify the logical-router indentifier\n"
1645 "The file name in " NS_RUN_DIR
", or a full pathname\n")
1647 vty
->node
= NS_NODE
;
1655 "Select a VRF to configure\n"
1658 vty
->node
= VRF_NODE
;
1666 "Delete a pseudo vrf's configuration\n"
1673 "Exit current mode and down to previous mode\n")
1675 return vtysh_exit (vty
);
1678 ALIAS (vtysh_exit_ns
,
1681 "Exit current mode and down to previous mode\n")
1687 "Exit current mode and down to previous mode\n")
1689 return vtysh_exit (vty
);
1692 ALIAS (vtysh_exit_vrf
,
1695 "Exit current mode and down to previous mode\n")
1697 /* TODO Implement interface description commands in ripngd, ospf6d
1699 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1701 "description .LINE",
1702 "Interface specific description\n"
1703 "Characters describing this interface\n")
1705 DEFSH (VTYSH_ZEBRA
|VTYSH_RIPD
|VTYSH_OSPFD
,
1706 no_interface_desc_cmd
,
1709 "Interface specific description\n")
1711 DEFUNSH (VTYSH_INTERFACE
,
1712 vtysh_exit_interface
,
1713 vtysh_exit_interface_cmd
,
1715 "Exit current mode and down to previous mode\n")
1717 return vtysh_exit (vty
);
1720 ALIAS (vtysh_exit_interface
,
1721 vtysh_quit_interface_cmd
,
1723 "Exit current mode and down to previous mode\n")
1725 DEFUN (vtysh_show_thread
,
1726 vtysh_show_thread_cmd
,
1727 "show thread cpu [FILTER]",
1729 "Thread information\n"
1730 "Thread CPU usage\n"
1731 "Display filter (rwtexb)\n")
1734 int ret
= CMD_SUCCESS
;
1737 sprintf(line
, "show thread cpu %s\n", (argc
== 1) ? argv
[0] : "");
1738 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1739 if ( vtysh_client
[i
].fd
>= 0 )
1741 fprintf (stdout
, "Thread statistics for %s:\n",
1742 vtysh_client
[i
].name
);
1743 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1744 fprintf (stdout
,"\n");
1749 DEFUN (vtysh_show_work_queues
,
1750 vtysh_show_work_queues_cmd
,
1753 "Work Queue information\n")
1756 int ret
= CMD_SUCCESS
;
1757 char line
[] = "show work-queues\n";
1759 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1760 if ( vtysh_client
[i
].fd
>= 0 )
1762 fprintf (stdout
, "Work queue statistics for %s:\n",
1763 vtysh_client
[i
].name
);
1764 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1765 fprintf (stdout
,"\n");
1771 DEFUN (vtysh_show_work_queues_daemon
,
1772 vtysh_show_work_queues_daemon_cmd
,
1773 "show work-queues (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd)",
1775 "Work Queue information\n"
1776 "For the zebra daemon\n"
1777 "For the rip daemon\n"
1778 "For the ripng daemon\n"
1779 "For the ospf daemon\n"
1780 "For the ospfv6 daemon\n"
1781 "For the bgp daemon\n"
1782 "For the isis daemon\n")
1785 int ret
= CMD_SUCCESS
;
1787 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1789 if (begins_with(vtysh_client
[i
].name
, argv
[0]))
1793 ret
= vtysh_client_execute(&vtysh_client
[i
], "show work-queues\n", stdout
);
1798 DEFUNSH (VTYSH_ZEBRA
,
1800 vtysh_link_params_cmd
,
1805 vty
->node
= LINK_PARAMS_NODE
;
1810 DEFUN (vtysh_show_memory
,
1811 vtysh_show_memory_cmd
,
1814 "Memory statistics\n")
1817 int ret
= CMD_SUCCESS
;
1818 char line
[] = "show memory\n";
1820 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1821 if ( vtysh_client
[i
].fd
>= 0 )
1823 fprintf (stdout
, "Memory statistics for %s:\n",
1824 vtysh_client
[i
].name
);
1825 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1826 fprintf (stdout
,"\n");
1832 /* Logging commands. */
1833 DEFUN (vtysh_show_logging
,
1834 vtysh_show_logging_cmd
,
1837 "Show current logging configuration\n")
1840 int ret
= CMD_SUCCESS
;
1841 char line
[] = "show logging\n";
1843 for (i
= 0; i
< array_size(vtysh_client
); i
++)
1844 if ( vtysh_client
[i
].fd
>= 0 )
1846 fprintf (stdout
,"Logging configuration for %s:\n",
1847 vtysh_client
[i
].name
);
1848 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
1849 fprintf (stdout
,"\n");
1857 vtysh_log_stdout_cmd
,
1860 "Set stdout logging level\n")
1866 vtysh_log_stdout_level
,
1867 vtysh_log_stdout_level_cmd
,
1868 "log stdout "LOG_LEVELS
,
1870 "Set stdout logging level\n"
1877 no_vtysh_log_stdout
,
1878 no_vtysh_log_stdout_cmd
,
1879 "no log stdout [LEVEL]",
1882 "Cancel logging to stdout\n"
1891 "log file FILENAME",
1894 "Logging filename\n")
1900 vtysh_log_file_level
,
1901 vtysh_log_file_level_cmd
,
1902 "log file FILENAME "LOG_LEVELS
,
1905 "Logging filename\n"
1913 no_vtysh_log_file_cmd
,
1914 "no log file [FILENAME]",
1917 "Cancel logging to file\n"
1918 "Logging file name\n")
1923 ALIAS_SH (VTYSH_ALL
,
1925 no_vtysh_log_file_level_cmd
,
1926 "no log file FILENAME LEVEL",
1929 "Cancel logging to file\n"
1930 "Logging file name\n"
1935 vtysh_log_monitor_cmd
,
1938 "Set terminal line (monitor) logging level\n")
1944 vtysh_log_monitor_level
,
1945 vtysh_log_monitor_level_cmd
,
1946 "log monitor "LOG_LEVELS
,
1948 "Set terminal line (monitor) logging level\n"
1955 no_vtysh_log_monitor
,
1956 no_vtysh_log_monitor_cmd
,
1957 "no log monitor [LEVEL]",
1960 "Disable terminal line (monitor) logging\n"
1968 vtysh_log_syslog_cmd
,
1971 "Set syslog logging level\n")
1977 vtysh_log_syslog_level
,
1978 vtysh_log_syslog_level_cmd
,
1979 "log syslog "LOG_LEVELS
,
1981 "Set syslog logging level\n"
1988 no_vtysh_log_syslog
,
1989 no_vtysh_log_syslog_cmd
,
1990 "no log syslog [LEVEL]",
1993 "Cancel logging to syslog\n"
2001 vtysh_log_facility_cmd
,
2002 "log facility "LOG_FACILITIES
,
2004 "Facility parameter for syslog messages\n"
2012 no_vtysh_log_facility
,
2013 no_vtysh_log_facility_cmd
,
2014 "no log facility [FACILITY]",
2017 "Reset syslog facility to default (daemon)\n"
2018 "Syslog facility\n")
2024 DEFUNSH_DEPRECATED (VTYSH_ALL
,
2027 "log trap "LOG_LEVELS
,
2029 "(Deprecated) Set logging level and default for all destinations\n"
2036 DEFUNSH_DEPRECATED (VTYSH_ALL
,
2038 no_vtysh_log_trap_cmd
,
2039 "no log trap [LEVEL]",
2042 "Permit all logging information\n"
2049 vtysh_log_record_priority
,
2050 vtysh_log_record_priority_cmd
,
2051 "log record-priority",
2053 "Log the priority of the message within the message\n")
2059 no_vtysh_log_record_priority
,
2060 no_vtysh_log_record_priority_cmd
,
2061 "no log record-priority",
2064 "Do not log the priority of the message within the message\n")
2070 vtysh_log_timestamp_precision
,
2071 vtysh_log_timestamp_precision_cmd
,
2072 "log timestamp precision <0-6>",
2074 "Timestamp configuration\n"
2075 "Set the timestamp precision\n"
2076 "Number of subsecond digits\n")
2082 no_vtysh_log_timestamp_precision
,
2083 no_vtysh_log_timestamp_precision_cmd
,
2084 "no log timestamp precision",
2087 "Timestamp configuration\n"
2088 "Reset the timestamp precision to the default value of 0\n")
2094 vtysh_service_password_encrypt
,
2095 vtysh_service_password_encrypt_cmd
,
2096 "service password-encryption",
2097 "Set up miscellaneous service\n"
2098 "Enable encrypted passwords\n")
2104 no_vtysh_service_password_encrypt
,
2105 no_vtysh_service_password_encrypt_cmd
,
2106 "no service password-encryption",
2108 "Set up miscellaneous service\n"
2109 "Enable encrypted passwords\n")
2115 vtysh_config_password
,
2117 "password (8|) WORD",
2118 "Assign the terminal connection password\n"
2119 "Specifies a HIDDEN password will follow\n"
2121 "The HIDDEN line password string\n")
2127 vtysh_password_text
,
2128 vtysh_password_text_cmd
,
2130 "Assign the terminal connection password\n"
2131 "The UNENCRYPTED (cleartext) line password\n")
2137 vtysh_config_enable_password
,
2138 vtysh_enable_password_cmd
,
2139 "enable password (8|) WORD",
2140 "Modify enable password parameters\n"
2141 "Assign the privileged level password\n"
2142 "Specifies a HIDDEN password will follow\n"
2144 "The HIDDEN 'enable' password string\n")
2150 vtysh_enable_password_text
,
2151 vtysh_enable_password_text_cmd
,
2152 "enable password LINE",
2153 "Modify enable password parameters\n"
2154 "Assign the privileged level password\n"
2155 "The UNENCRYPTED (cleartext) 'enable' password\n")
2161 no_vtysh_config_enable_password
,
2162 no_vtysh_enable_password_cmd
,
2163 "no enable password",
2165 "Modify enable password parameters\n"
2166 "Assign the privileged level password\n")
2171 DEFUN (vtysh_write_terminal
,
2172 vtysh_write_terminal_cmd
,
2174 "Write running configuration to memory, network, or terminal\n"
2175 "Write to terminal\n")
2178 char line
[] = "write terminal\n";
2181 if (vtysh_pager_name
)
2183 fp
= popen (vtysh_pager_name
, "w");
2193 vty_out (vty
, "Building configuration...%s", VTY_NEWLINE
);
2194 vty_out (vty
, "%sCurrent configuration:%s", VTY_NEWLINE
,
2196 vty_out (vty
, "!%s", VTY_NEWLINE
);
2198 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2199 if ((argc
< 1 ) || (begins_with(vtysh_client
[i
].name
, argv
[0])))
2200 vtysh_client_config (&vtysh_client
[i
], line
);
2202 /* Integrate vtysh specific configuration. */
2203 vtysh_config_write ();
2205 vtysh_config_dump (fp
);
2207 if (vtysh_pager_name
&& fp
)
2210 if (pclose (fp
) == -1)
2218 vty_out (vty
, "end%s", VTY_NEWLINE
);
2223 DEFUN (vtysh_write_terminal_daemon
,
2224 vtysh_write_terminal_daemon_cmd
,
2225 "write terminal (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pimd)",
2226 "Write running configuration to memory, network, or terminal\n"
2227 "Write to terminal\n"
2228 "For the zebra daemon\n"
2229 "For the rip daemon\n"
2230 "For the ripng daemon\n"
2231 "For the ospf daemon\n"
2232 "For the ospfv6 daemon\n"
2233 "For the bgp daemon\n"
2234 "For the isis daemon\n"
2235 "For the pim daemon\n")
2238 int ret
= CMD_SUCCESS
;
2240 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2242 if (begins_with(vtysh_client
[i
].name
, argv
[0]))
2246 ret
= vtysh_client_execute(&vtysh_client
[i
], "show running-config\n", stdout
);
2251 DEFUN (vtysh_integrated_config
,
2252 vtysh_integrated_config_cmd
,
2253 "service integrated-vtysh-config",
2254 "Set up miscellaneous service\n"
2255 "Write configuration into integrated file\n")
2257 vtysh_writeconfig_integrated
= 1;
2261 DEFUN (no_vtysh_integrated_config
,
2262 no_vtysh_integrated_config_cmd
,
2263 "no service integrated-vtysh-config",
2265 "Set up miscellaneous service\n"
2266 "Write configuration into integrated file\n")
2268 vtysh_writeconfig_integrated
= 0;
2273 backup_config_file (const char *fbackup
)
2275 char *integrate_sav
= NULL
;
2277 integrate_sav
= malloc (strlen (fbackup
) +
2278 strlen (CONF_BACKUP_EXT
) + 1);
2279 strcpy (integrate_sav
, fbackup
);
2280 strcat (integrate_sav
, CONF_BACKUP_EXT
);
2282 /* Move current configuration file to backup config file. */
2283 unlink (integrate_sav
);
2284 rename (fbackup
, integrate_sav
);
2285 free (integrate_sav
);
2289 write_config_integrated(void)
2292 char line
[] = "write terminal\n";
2295 fprintf (stdout
,"Building Configuration...\n");
2297 backup_config_file(integrate_default
);
2298 backup_config_file(host
.config
);
2300 fp
= fopen (integrate_default
, "w");
2303 fprintf (stdout
,"%% Can't open configuration file %s due to '%s'\n",
2304 integrate_default
, safe_strerror(errno
));
2308 fp1
= fopen (host
.config
, "w");
2311 fprintf (stdout
,"%% Can't open configuration file %s due to '%s'\n",
2312 host
.config
, safe_strerror(errno
));
2316 vtysh_config_write ();
2317 vtysh_config_dump (fp1
);
2320 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2321 vtysh_client_config (&vtysh_client
[i
], line
);
2323 vtysh_config_write ();
2324 vtysh_config_dump (fp
);
2328 if (chmod (integrate_default
, CONFIGFILE_MASK
) != 0)
2330 fprintf (stdout
,"%% Can't chmod configuration file %s: %s\n",
2331 integrate_default
, safe_strerror(errno
));
2335 if (chmod (host
.config
, CONFIGFILE_MASK
) != 0)
2337 fprintf (stdout
,"%% Can't chmod configuration file %s: %s (%d)\n",
2338 integrate_default
, safe_strerror(errno
), errno
);
2341 fprintf(stdout
,"Integrated configuration saved to %s\n",integrate_default
);
2343 fprintf (stdout
,"[OK]\n");
2348 DEFUN (vtysh_write_memory
,
2349 vtysh_write_memory_cmd
,
2351 "Write running configuration to memory, network, or terminal\n"
2352 "Write configuration to the file (same as write file)\n")
2354 int ret
= CMD_SUCCESS
;
2355 char line
[] = "write memory\n";
2359 /* If integrated Quagga.conf explicitely set. */
2360 if (vtysh_writeconfig_integrated
)
2361 return write_config_integrated();
2363 backup_config_file(integrate_default
);
2365 fprintf (stdout
,"Building Configuration...\n");
2367 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2368 ret
= vtysh_client_execute (&vtysh_client
[i
], line
, stdout
);
2371 fp
= fopen(host
.config
, "w");
2374 fprintf (stdout
,"%% Can't open configuration file %s due to '%s'\n",
2375 host
.config
, safe_strerror(errno
));
2379 vtysh_config_write ();
2380 vtysh_config_dump (fp
);
2384 if (chmod (host
.config
, CONFIGFILE_MASK
) != 0)
2386 fprintf (stdout
,"%% Can't chmod configuration file %s: %s\n",
2387 integrate_default
, safe_strerror(errno
));
2391 fprintf (stdout
,"[OK]\n");
2396 ALIAS (vtysh_write_memory
,
2397 vtysh_copy_runningconfig_startupconfig_cmd
,
2398 "copy running-config startup-config",
2399 "Copy from one file to another\n"
2400 "Copy from current system configuration\n"
2401 "Copy to startup configuration\n")
2403 ALIAS (vtysh_write_memory
,
2404 vtysh_write_file_cmd
,
2406 "Write running configuration to memory, network, or terminal\n"
2407 "Write configuration to the file (same as write memory)\n")
2409 ALIAS (vtysh_write_memory
,
2412 "Write running configuration to memory, network, or terminal\n")
2414 ALIAS (vtysh_write_terminal
,
2415 vtysh_show_running_config_cmd
,
2416 "show running-config",
2418 "Current operating configuration\n")
2420 ALIAS (vtysh_write_terminal
,
2421 vtysh_show_running_config_daemon_cmd
,
2422 "show running-config (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pimd)",
2424 "Current operating configuration\n"
2425 "For the zebra daemon\n"
2426 "For the rip daemon\n"
2427 "For the ripng daemon\n"
2428 "For the ospf daemon\n"
2429 "For the ospfv6 daemon\n"
2430 "For the bgp daemon\n"
2431 "For the isis daemon\n"
2432 "For the pim daemon\n")
2434 DEFUN (vtysh_terminal_length
,
2435 vtysh_terminal_length_cmd
,
2436 "terminal length <0-512>",
2437 "Set terminal line parameters\n"
2438 "Set number of lines on a screen\n"
2439 "Number of lines on screen (0 for no pausing)\n")
2442 char *endptr
= NULL
;
2443 char default_pager
[10];
2445 lines
= strtol (argv
[0], &endptr
, 10);
2446 if (lines
< 0 || lines
> 512 || *endptr
!= '\0')
2448 vty_out (vty
, "length is malformed%s", VTY_NEWLINE
);
2452 if (vtysh_pager_name
)
2454 free (vtysh_pager_name
);
2455 vtysh_pager_name
= NULL
;
2460 snprintf(default_pager
, 10, "more -%i", lines
);
2461 vtysh_pager_name
= strdup (default_pager
);
2467 DEFUN (vtysh_terminal_no_length
,
2468 vtysh_terminal_no_length_cmd
,
2469 "terminal no length",
2470 "Set terminal line parameters\n"
2472 "Set number of lines on a screen\n")
2474 if (vtysh_pager_name
)
2476 free (vtysh_pager_name
);
2477 vtysh_pager_name
= NULL
;
2484 DEFUN (vtysh_show_daemons
,
2485 vtysh_show_daemons_cmd
,
2488 "Show list of running daemons\n")
2492 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2493 if ( vtysh_client
[i
].fd
>= 0 )
2494 vty_out(vty
, " %s", vtysh_client
[i
].name
);
2495 vty_out(vty
, "%s", VTY_NEWLINE
);
2500 /* Execute command in child process. */
2502 execute_command (const char *command
, int argc
, const char *arg1
,
2513 /* Failure of fork(). */
2514 fprintf (stderr
, "Can't fork: %s\n", safe_strerror (errno
));
2519 /* This is child process. */
2523 execlp (command
, command
, (const char *)NULL
);
2526 execlp (command
, command
, arg1
, (const char *)NULL
);
2529 execlp (command
, command
, arg1
, arg2
, (const char *)NULL
);
2533 /* When execlp suceed, this part is not executed. */
2534 fprintf (stderr
, "Can't execute %s: %s\n", command
, safe_strerror (errno
));
2539 /* This is parent. */
2541 wait4 (pid
, &status
, 0, NULL
);
2549 "Send echo messages\n"
2550 "Ping destination address or hostname\n")
2552 execute_command ("ping", 1, argv
[0], NULL
);
2559 "Send echo messages\n"
2561 "Ping destination address or hostname\n")
2563 DEFUN (vtysh_traceroute
,
2564 vtysh_traceroute_cmd
,
2566 "Trace route to destination\n"
2567 "Trace route to destination address or hostname\n")
2569 execute_command ("traceroute", 1, argv
[0], NULL
);
2573 ALIAS (vtysh_traceroute
,
2574 vtysh_traceroute_ip_cmd
,
2575 "traceroute ip WORD",
2576 "Trace route to destination\n"
2578 "Trace route to destination address or hostname\n")
2584 "Send echo messages\n"
2586 "Ping destination address or hostname\n")
2588 execute_command ("ping6", 1, argv
[0], NULL
);
2592 DEFUN (vtysh_traceroute6
,
2593 vtysh_traceroute6_cmd
,
2594 "traceroute ipv6 WORD",
2595 "Trace route to destination\n"
2597 "Trace route to destination address or hostname\n")
2599 execute_command ("traceroute6", 1, argv
[0], NULL
);
2604 #if defined(HAVE_SHELL_ACCESS)
2605 DEFUN (vtysh_telnet
,
2608 "Open a telnet connection\n"
2609 "IP address or hostname of a remote system\n")
2611 execute_command ("telnet", 1, argv
[0], NULL
);
2615 DEFUN (vtysh_telnet_port
,
2616 vtysh_telnet_port_cmd
,
2618 "Open a telnet connection\n"
2619 "IP address or hostname of a remote system\n"
2620 "TCP Port number\n")
2622 execute_command ("telnet", 2, argv
[0], argv
[1]);
2629 "Open an ssh connection\n"
2632 execute_command ("ssh", 1, argv
[0], NULL
);
2636 DEFUN (vtysh_start_shell
,
2637 vtysh_start_shell_cmd
,
2639 "Start UNIX shell\n")
2641 execute_command ("sh", 0, NULL
, NULL
);
2645 DEFUN (vtysh_start_bash
,
2646 vtysh_start_bash_cmd
,
2648 "Start UNIX shell\n"
2651 execute_command ("bash", 0, NULL
, NULL
);
2655 DEFUN (vtysh_start_zsh
,
2656 vtysh_start_zsh_cmd
,
2658 "Start UNIX shell\n"
2661 execute_command ("zsh", 0, NULL
, NULL
);
2667 vtysh_install_default (enum node_type node
)
2669 install_element (node
, &config_list_cmd
);
2672 /* Making connection to protocol daemon. */
2674 vtysh_connect (struct vtysh_client
*vclient
)
2678 struct sockaddr_un addr
;
2681 /* Stat socket to see if we have permission to access it. */
2682 ret
= stat (vclient
->path
, &s_stat
);
2683 if (ret
< 0 && errno
!= ENOENT
)
2685 fprintf (stderr
, "vtysh_connect(%s): stat = %s\n",
2686 vclient
->path
, safe_strerror(errno
));
2692 if (! S_ISSOCK(s_stat
.st_mode
))
2694 fprintf (stderr
, "vtysh_connect(%s): Not a socket\n",
2701 sock
= socket (AF_UNIX
, SOCK_STREAM
, 0);
2705 fprintf(stderr
, "vtysh_connect(%s): socket = %s\n", vclient
->path
,
2706 safe_strerror(errno
));
2711 memset (&addr
, 0, sizeof (struct sockaddr_un
));
2712 addr
.sun_family
= AF_UNIX
;
2713 strncpy (addr
.sun_path
, vclient
->path
, strlen (vclient
->path
));
2714 #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
2715 len
= addr
.sun_len
= SUN_LEN(&addr
);
2717 len
= sizeof (addr
.sun_family
) + strlen (addr
.sun_path
);
2718 #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
2720 ret
= connect (sock
, (struct sockaddr
*) &addr
, len
);
2724 fprintf(stderr
, "vtysh_connect(%s): connect = %s\n", vclient
->path
,
2725 safe_strerror(errno
));
2735 /* Return true if str ends with suffix, else return false */
2737 ends_with(const char *str
, const char *suffix
)
2739 if (!str
|| !suffix
)
2741 size_t lenstr
= strlen(str
);
2742 size_t lensuffix
= strlen(suffix
);
2743 if (lensuffix
> lenstr
)
2745 return strncmp(str
+ lenstr
- lensuffix
, suffix
, lensuffix
) == 0;
2749 vtysh_client_sorted_insert (struct vtysh_client
*head_client
,
2750 struct vtysh_client
*client
)
2752 struct vtysh_client
*prev_node
, *current_node
;
2754 prev_node
= head_client
;
2755 current_node
= head_client
->next
;
2756 while (current_node
)
2758 if (strcmp(current_node
->path
, client
->path
) > 0)
2761 prev_node
= current_node
;
2762 current_node
= current_node
->next
;
2764 client
->next
= current_node
;
2765 prev_node
->next
= client
;
2768 #define MAXIMUM_INSTANCES 10
2771 vtysh_update_all_insances(struct vtysh_client
* head_client
)
2773 struct vtysh_client
*client
;
2776 struct dirent
*file
;
2779 if (head_client
->flag
!= VTYSH_OSPFD
) return;
2781 /* ls /var/run/quagga/ and look for all files ending in .vty */
2782 dir
= opendir("/var/run/quagga/");
2785 while ((file
= readdir(dir
)) != NULL
)
2787 if (begins_with(file
->d_name
, "ospfd-") && ends_with(file
->d_name
, ".vty"))
2789 if (n
== MAXIMUM_INSTANCES
)
2792 "Parsing /var/run/quagga/, client limit(%d) reached!\n", n
);
2795 client
= (struct vtysh_client
*) malloc(sizeof(struct vtysh_client
));
2797 client
->name
= "ospfd";
2798 client
->flag
= VTYSH_OSPFD
;
2799 ptr
= (char *) malloc(100);
2800 sprintf(ptr
, "/var/run/quagga/%s", file
->d_name
);
2801 client
->path
= (const char *)ptr
;
2802 client
->next
= NULL
;
2803 vtysh_client_sorted_insert(head_client
, client
);
2812 vtysh_connect_all_instances (struct vtysh_client
*head_client
)
2814 struct vtysh_client
*client
;
2817 vtysh_update_all_insances(head_client
);
2819 client
= head_client
->next
;
2822 if (vtysh_connect(client
) == 0)
2824 client
= client
->next
;
2831 vtysh_connect_all(const char *daemon_name
)
2837 for (i
= 0; i
< array_size(vtysh_client
); i
++)
2839 if (!daemon_name
|| !strcmp(daemon_name
, vtysh_client
[i
].name
))
2842 if (vtysh_connect(&vtysh_client
[i
]) == 0)
2845 rc
+= vtysh_connect_all_instances(&vtysh_client
[i
]);
2849 fprintf(stderr
, "Error: no daemons match name %s!\n", daemon_name
);
2853 /* To disable readline's filename completion. */
2855 vtysh_completion_entry_function (const char *ignore
, int invoking_key
)
2861 vtysh_readline_init (void)
2863 /* readline related settings. */
2864 rl_bind_key ('?', (rl_command_func_t
*) vtysh_rl_describe
);
2865 rl_completion_entry_function
= vtysh_completion_entry_function
;
2866 rl_attempted_completion_function
= (rl_completion_func_t
*)new_completion
;
2872 static struct utsname names
;
2873 static char buf
[100];
2874 const char*hostname
;
2875 extern struct host host
;
2877 hostname
= host
.name
;
2881 if (!names
.nodename
[0])
2883 hostname
= names
.nodename
;
2886 snprintf (buf
, sizeof buf
, cmd_prompt (vty
->node
), hostname
);
2892 vtysh_init_vty (void)
2894 /* Make vty structure. */
2896 vty
->type
= VTY_SHELL
;
2897 vty
->node
= VIEW_NODE
;
2899 /* Initialize commands. */
2902 /* Install nodes. */
2903 install_node (&bgp_node
, NULL
);
2904 install_node (&rip_node
, NULL
);
2905 install_node (&interface_node
, NULL
);
2906 install_node (&link_params_node
, NULL
);
2907 install_node (&ns_node
, NULL
);
2908 install_node (&vrf_node
, NULL
);
2909 install_node (&rmap_node
, NULL
);
2910 install_node (&zebra_node
, NULL
);
2911 install_node (&bgp_vpnv4_node
, NULL
);
2912 install_node (&bgp_vpnv6_node
, NULL
);
2913 install_node (&bgp_encap_node
, NULL
);
2914 install_node (&bgp_encapv6_node
, NULL
);
2915 install_node (&bgp_ipv4_node
, NULL
);
2916 install_node (&bgp_ipv4m_node
, NULL
);
2917 /* #ifdef HAVE_IPV6 */
2918 install_node (&bgp_ipv6_node
, NULL
);
2919 install_node (&bgp_ipv6m_node
, NULL
);
2921 install_node (&ospf_node
, NULL
);
2922 /* #ifdef HAVE_IPV6 */
2923 install_node (&ripng_node
, NULL
);
2924 install_node (&ospf6_node
, NULL
);
2926 install_node (&keychain_node
, NULL
);
2927 install_node (&keychain_key_node
, NULL
);
2928 install_node (&isis_node
, NULL
);
2929 install_node (&vty_node
, NULL
);
2931 vtysh_install_default (VIEW_NODE
);
2932 vtysh_install_default (ENABLE_NODE
);
2933 vtysh_install_default (CONFIG_NODE
);
2934 vtysh_install_default (BGP_NODE
);
2935 vtysh_install_default (RIP_NODE
);
2936 vtysh_install_default (INTERFACE_NODE
);
2937 vtysh_install_default (LINK_PARAMS_NODE
);
2938 vtysh_install_default (NS_NODE
);
2939 vtysh_install_default (VRF_NODE
);
2940 vtysh_install_default (RMAP_NODE
);
2941 vtysh_install_default (ZEBRA_NODE
);
2942 vtysh_install_default (BGP_VPNV4_NODE
);
2943 vtysh_install_default (BGP_VPNV6_NODE
);
2944 vtysh_install_default (BGP_ENCAP_NODE
);
2945 vtysh_install_default (BGP_ENCAPV6_NODE
);
2946 vtysh_install_default (BGP_IPV4_NODE
);
2947 vtysh_install_default (BGP_IPV4M_NODE
);
2948 vtysh_install_default (BGP_IPV6_NODE
);
2949 vtysh_install_default (BGP_IPV6M_NODE
);
2950 vtysh_install_default (OSPF_NODE
);
2951 vtysh_install_default (RIPNG_NODE
);
2952 vtysh_install_default (OSPF6_NODE
);
2953 vtysh_install_default (ISIS_NODE
);
2954 vtysh_install_default (KEYCHAIN_NODE
);
2955 vtysh_install_default (KEYCHAIN_KEY_NODE
);
2956 vtysh_install_default (VTY_NODE
);
2958 install_element (VIEW_NODE
, &vtysh_enable_cmd
);
2959 install_element (ENABLE_NODE
, &vtysh_config_terminal_cmd
);
2960 install_element (ENABLE_NODE
, &vtysh_disable_cmd
);
2962 /* "exit" command. */
2963 install_element (VIEW_NODE
, &vtysh_exit_all_cmd
);
2964 install_element (VIEW_NODE
, &vtysh_quit_all_cmd
);
2965 install_element (CONFIG_NODE
, &vtysh_exit_all_cmd
);
2966 /* install_element (CONFIG_NODE, &vtysh_quit_all_cmd); */
2967 install_element (ENABLE_NODE
, &vtysh_exit_all_cmd
);
2968 install_element (ENABLE_NODE
, &vtysh_quit_all_cmd
);
2969 install_element (RIP_NODE
, &vtysh_exit_ripd_cmd
);
2970 install_element (RIP_NODE
, &vtysh_quit_ripd_cmd
);
2971 install_element (RIPNG_NODE
, &vtysh_exit_ripngd_cmd
);
2972 install_element (RIPNG_NODE
, &vtysh_quit_ripngd_cmd
);
2973 install_element (OSPF_NODE
, &vtysh_exit_ospfd_cmd
);
2974 install_element (OSPF_NODE
, &vtysh_quit_ospfd_cmd
);
2975 install_element (OSPF6_NODE
, &vtysh_exit_ospf6d_cmd
);
2976 install_element (OSPF6_NODE
, &vtysh_quit_ospf6d_cmd
);
2977 install_element (BGP_NODE
, &vtysh_exit_bgpd_cmd
);
2978 install_element (BGP_NODE
, &vtysh_quit_bgpd_cmd
);
2979 install_element (BGP_VPNV4_NODE
, &vtysh_exit_bgpd_cmd
);
2980 install_element (BGP_VPNV4_NODE
, &vtysh_quit_bgpd_cmd
);
2981 install_element (BGP_VPNV6_NODE
, &vtysh_exit_bgpd_cmd
);
2982 install_element (BGP_VPNV6_NODE
, &vtysh_quit_bgpd_cmd
);
2983 install_element (BGP_ENCAP_NODE
, &vtysh_exit_bgpd_cmd
);
2984 install_element (BGP_ENCAP_NODE
, &vtysh_quit_bgpd_cmd
);
2985 install_element (BGP_ENCAPV6_NODE
, &vtysh_exit_bgpd_cmd
);
2986 install_element (BGP_ENCAPV6_NODE
, &vtysh_quit_bgpd_cmd
);
2987 install_element (BGP_IPV4_NODE
, &vtysh_exit_bgpd_cmd
);
2988 install_element (BGP_IPV4_NODE
, &vtysh_quit_bgpd_cmd
);
2989 install_element (BGP_IPV4M_NODE
, &vtysh_exit_bgpd_cmd
);
2990 install_element (BGP_IPV4M_NODE
, &vtysh_quit_bgpd_cmd
);
2991 install_element (BGP_IPV6_NODE
, &vtysh_exit_bgpd_cmd
);
2992 install_element (BGP_IPV6_NODE
, &vtysh_quit_bgpd_cmd
);
2993 install_element (BGP_IPV6M_NODE
, &vtysh_exit_bgpd_cmd
);
2994 install_element (BGP_IPV6M_NODE
, &vtysh_quit_bgpd_cmd
);
2995 install_element (ISIS_NODE
, &vtysh_exit_isisd_cmd
);
2996 install_element (ISIS_NODE
, &vtysh_quit_isisd_cmd
);
2997 install_element (KEYCHAIN_NODE
, &vtysh_exit_ripd_cmd
);
2998 install_element (KEYCHAIN_NODE
, &vtysh_quit_ripd_cmd
);
2999 install_element (KEYCHAIN_KEY_NODE
, &vtysh_exit_ripd_cmd
);
3000 install_element (KEYCHAIN_KEY_NODE
, &vtysh_quit_ripd_cmd
);
3001 install_element (RMAP_NODE
, &vtysh_exit_rmap_cmd
);
3002 install_element (RMAP_NODE
, &vtysh_quit_rmap_cmd
);
3003 install_element (VTY_NODE
, &vtysh_exit_line_vty_cmd
);
3004 install_element (VTY_NODE
, &vtysh_quit_line_vty_cmd
);
3006 /* "end" command. */
3007 install_element (CONFIG_NODE
, &vtysh_end_all_cmd
);
3008 install_element (ENABLE_NODE
, &vtysh_end_all_cmd
);
3009 install_element (RIP_NODE
, &vtysh_end_all_cmd
);
3010 install_element (RIPNG_NODE
, &vtysh_end_all_cmd
);
3011 install_element (OSPF_NODE
, &vtysh_end_all_cmd
);
3012 install_element (OSPF6_NODE
, &vtysh_end_all_cmd
);
3013 install_element (BGP_NODE
, &vtysh_end_all_cmd
);
3014 install_element (BGP_IPV4_NODE
, &vtysh_end_all_cmd
);
3015 install_element (BGP_IPV4M_NODE
, &vtysh_end_all_cmd
);
3016 install_element (BGP_VPNV4_NODE
, &vtysh_end_all_cmd
);
3017 install_element (BGP_VPNV6_NODE
, &vtysh_end_all_cmd
);
3018 install_element (BGP_ENCAP_NODE
, &vtysh_end_all_cmd
);
3019 install_element (BGP_ENCAPV6_NODE
, &vtysh_end_all_cmd
);
3020 install_element (BGP_IPV6_NODE
, &vtysh_end_all_cmd
);
3021 install_element (BGP_IPV6M_NODE
, &vtysh_end_all_cmd
);
3022 install_element (ISIS_NODE
, &vtysh_end_all_cmd
);
3023 install_element (KEYCHAIN_NODE
, &vtysh_end_all_cmd
);
3024 install_element (KEYCHAIN_KEY_NODE
, &vtysh_end_all_cmd
);
3025 install_element (RMAP_NODE
, &vtysh_end_all_cmd
);
3026 install_element (VTY_NODE
, &vtysh_end_all_cmd
);
3028 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
3029 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
3030 install_element (INTERFACE_NODE
, &vtysh_end_all_cmd
);
3031 install_element (INTERFACE_NODE
, &vtysh_exit_interface_cmd
);
3032 install_element (LINK_PARAMS_NODE
, &vtysh_end_all_cmd
);
3033 install_element (LINK_PARAMS_NODE
, &vtysh_exit_interface_cmd
);
3034 install_element (INTERFACE_NODE
, &vtysh_quit_interface_cmd
);
3036 install_element (NS_NODE
, &vtysh_end_all_cmd
);
3037 install_element (NS_NODE
, &vtysh_exit_ns_cmd
);
3038 install_element (NS_NODE
, &vtysh_quit_ns_cmd
);
3040 install_element (VRF_NODE
, &vtysh_end_all_cmd
);
3041 install_element (VRF_NODE
, &vtysh_exit_vrf_cmd
);
3042 install_element (VRF_NODE
, &vtysh_quit_vrf_cmd
);
3044 install_element (CONFIG_NODE
, &router_rip_cmd
);
3046 install_element (CONFIG_NODE
, &router_ripng_cmd
);
3048 install_element (CONFIG_NODE
, &router_ospf_cmd
);
3049 install_element (CONFIG_NODE
, &router_ospf_instance_cmd
);
3051 install_element (CONFIG_NODE
, &router_ospf6_cmd
);
3053 install_element (CONFIG_NODE
, &router_isis_cmd
);
3054 install_element (CONFIG_NODE
, &router_bgp_cmd
);
3055 install_element (CONFIG_NODE
, &router_bgp_asn_cmd
);
3056 install_element (CONFIG_NODE
, &router_bgp_view_cmd
);
3057 install_element (BGP_NODE
, &address_family_vpnv4_cmd
);
3058 install_element (BGP_NODE
, &address_family_vpnv4_unicast_cmd
);
3059 install_element (BGP_NODE
, &address_family_vpnv6_cmd
);
3060 install_element (BGP_NODE
, &address_family_vpnv6_unicast_cmd
);
3061 install_element (BGP_NODE
, &address_family_encap_cmd
);
3062 install_element (BGP_NODE
, &address_family_encapv6_cmd
);
3063 install_element (BGP_NODE
, &address_family_ipv4_unicast_cmd
);
3064 install_element (BGP_NODE
, &address_family_ipv4_multicast_cmd
);
3066 install_element (BGP_NODE
, &address_family_ipv6_cmd
);
3067 install_element (BGP_NODE
, &address_family_ipv6_unicast_cmd
);
3068 install_element (BGP_NODE
, &address_family_ipv6_multicast_cmd
);
3070 install_element (BGP_VPNV4_NODE
, &exit_address_family_cmd
);
3071 install_element (BGP_VPNV6_NODE
, &exit_address_family_cmd
);
3072 install_element (BGP_ENCAP_NODE
, &exit_address_family_cmd
);
3073 install_element (BGP_ENCAPV6_NODE
, &exit_address_family_cmd
);
3074 install_element (BGP_IPV4_NODE
, &exit_address_family_cmd
);
3075 install_element (BGP_IPV4M_NODE
, &exit_address_family_cmd
);
3076 install_element (BGP_IPV6_NODE
, &exit_address_family_cmd
);
3077 install_element (BGP_IPV6M_NODE
, &exit_address_family_cmd
);
3078 install_element (CONFIG_NODE
, &key_chain_cmd
);
3079 install_element (CONFIG_NODE
, &route_map_cmd
);
3080 install_element (CONFIG_NODE
, &vtysh_line_vty_cmd
);
3081 install_element (KEYCHAIN_NODE
, &key_cmd
);
3082 install_element (KEYCHAIN_NODE
, &key_chain_cmd
);
3083 install_element (KEYCHAIN_KEY_NODE
, &key_chain_cmd
);
3084 install_element (CONFIG_NODE
, &vtysh_interface_cmd
);
3085 install_element (CONFIG_NODE
, &vtysh_no_interface_cmd
);
3086 install_element (CONFIG_NODE
, &vtysh_interface_vrf_cmd
);
3087 install_element (CONFIG_NODE
, &vtysh_no_interface_vrf_cmd
);
3088 install_element (INTERFACE_NODE
, &vtysh_link_params_cmd
);
3089 install_element (ENABLE_NODE
, &vtysh_show_running_config_cmd
);
3090 install_element (ENABLE_NODE
, &vtysh_show_running_config_daemon_cmd
);
3091 install_element (ENABLE_NODE
, &vtysh_copy_runningconfig_startupconfig_cmd
);
3092 install_element (ENABLE_NODE
, &vtysh_write_file_cmd
);
3093 install_element (ENABLE_NODE
, &vtysh_write_cmd
);
3095 install_element (CONFIG_NODE
, &vtysh_vrf_cmd
);
3096 install_element (CONFIG_NODE
, &vtysh_no_vrf_cmd
);
3098 /* "write terminal" command. */
3099 install_element (ENABLE_NODE
, &vtysh_write_terminal_cmd
);
3100 install_element (ENABLE_NODE
, &vtysh_write_terminal_daemon_cmd
);
3102 install_element (CONFIG_NODE
, &vtysh_integrated_config_cmd
);
3103 install_element (CONFIG_NODE
, &no_vtysh_integrated_config_cmd
);
3105 /* "write memory" command. */
3106 install_element (ENABLE_NODE
, &vtysh_write_memory_cmd
);
3108 install_element (VIEW_NODE
, &vtysh_terminal_length_cmd
);
3109 install_element (ENABLE_NODE
, &vtysh_terminal_length_cmd
);
3110 install_element (VIEW_NODE
, &vtysh_terminal_no_length_cmd
);
3111 install_element (ENABLE_NODE
, &vtysh_terminal_no_length_cmd
);
3112 install_element (VIEW_NODE
, &vtysh_show_daemons_cmd
);
3113 install_element (ENABLE_NODE
, &vtysh_show_daemons_cmd
);
3115 install_element (VIEW_NODE
, &vtysh_ping_cmd
);
3116 install_element (VIEW_NODE
, &vtysh_ping_ip_cmd
);
3117 install_element (VIEW_NODE
, &vtysh_traceroute_cmd
);
3118 install_element (VIEW_NODE
, &vtysh_traceroute_ip_cmd
);
3120 install_element (VIEW_NODE
, &vtysh_ping6_cmd
);
3121 install_element (VIEW_NODE
, &vtysh_traceroute6_cmd
);
3123 #if defined(HAVE_SHELL_ACCESS)
3124 install_element (VIEW_NODE
, &vtysh_telnet_cmd
);
3125 install_element (VIEW_NODE
, &vtysh_telnet_port_cmd
);
3126 install_element (VIEW_NODE
, &vtysh_ssh_cmd
);
3128 install_element (ENABLE_NODE
, &vtysh_ping_cmd
);
3129 install_element (ENABLE_NODE
, &vtysh_ping_ip_cmd
);
3130 install_element (ENABLE_NODE
, &vtysh_traceroute_cmd
);
3131 install_element (ENABLE_NODE
, &vtysh_traceroute_ip_cmd
);
3133 install_element (ENABLE_NODE
, &vtysh_ping6_cmd
);
3134 install_element (ENABLE_NODE
, &vtysh_traceroute6_cmd
);
3136 #if defined(HAVE_SHELL_ACCESS)
3137 install_element (ENABLE_NODE
, &vtysh_telnet_cmd
);
3138 install_element (ENABLE_NODE
, &vtysh_telnet_port_cmd
);
3139 install_element (ENABLE_NODE
, &vtysh_ssh_cmd
);
3140 install_element (ENABLE_NODE
, &vtysh_start_shell_cmd
);
3141 install_element (ENABLE_NODE
, &vtysh_start_bash_cmd
);
3142 install_element (ENABLE_NODE
, &vtysh_start_zsh_cmd
);
3145 install_element (VIEW_NODE
, &vtysh_show_memory_cmd
);
3146 install_element (ENABLE_NODE
, &vtysh_show_memory_cmd
);
3148 install_element (VIEW_NODE
, &vtysh_show_work_queues_cmd
);
3149 install_element (ENABLE_NODE
, &vtysh_show_work_queues_cmd
);
3150 install_element (ENABLE_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3151 install_element (VIEW_NODE
, &vtysh_show_work_queues_daemon_cmd
);
3153 install_element (VIEW_NODE
, &vtysh_show_thread_cmd
);
3154 install_element (ENABLE_NODE
, &vtysh_show_thread_cmd
);
3157 install_element (ENABLE_NODE
, &vtysh_show_logging_cmd
);
3158 install_element (VIEW_NODE
, &vtysh_show_logging_cmd
);
3159 install_element (CONFIG_NODE
, &vtysh_log_stdout_cmd
);
3160 install_element (CONFIG_NODE
, &vtysh_log_stdout_level_cmd
);
3161 install_element (CONFIG_NODE
, &no_vtysh_log_stdout_cmd
);
3162 install_element (CONFIG_NODE
, &vtysh_log_file_cmd
);
3163 install_element (CONFIG_NODE
, &vtysh_log_file_level_cmd
);
3164 install_element (CONFIG_NODE
, &no_vtysh_log_file_cmd
);
3165 install_element (CONFIG_NODE
, &no_vtysh_log_file_level_cmd
);
3166 install_element (CONFIG_NODE
, &vtysh_log_monitor_cmd
);
3167 install_element (CONFIG_NODE
, &vtysh_log_monitor_level_cmd
);
3168 install_element (CONFIG_NODE
, &no_vtysh_log_monitor_cmd
);
3169 install_element (CONFIG_NODE
, &vtysh_log_syslog_cmd
);
3170 install_element (CONFIG_NODE
, &vtysh_log_syslog_level_cmd
);
3171 install_element (CONFIG_NODE
, &no_vtysh_log_syslog_cmd
);
3172 install_element (CONFIG_NODE
, &vtysh_log_trap_cmd
);
3173 install_element (CONFIG_NODE
, &no_vtysh_log_trap_cmd
);
3174 install_element (CONFIG_NODE
, &vtysh_log_facility_cmd
);
3175 install_element (CONFIG_NODE
, &no_vtysh_log_facility_cmd
);
3176 install_element (CONFIG_NODE
, &vtysh_log_record_priority_cmd
);
3177 install_element (CONFIG_NODE
, &no_vtysh_log_record_priority_cmd
);
3178 install_element (CONFIG_NODE
, &vtysh_log_timestamp_precision_cmd
);
3179 install_element (CONFIG_NODE
, &no_vtysh_log_timestamp_precision_cmd
);
3181 install_element (CONFIG_NODE
, &vtysh_service_password_encrypt_cmd
);
3182 install_element (CONFIG_NODE
, &no_vtysh_service_password_encrypt_cmd
);
3184 install_element (CONFIG_NODE
, &vtysh_password_cmd
);
3185 install_element (CONFIG_NODE
, &vtysh_password_text_cmd
);
3186 install_element (CONFIG_NODE
, &vtysh_enable_password_cmd
);
3187 install_element (CONFIG_NODE
, &vtysh_enable_password_text_cmd
);
3188 install_element (CONFIG_NODE
, &no_vtysh_enable_password_cmd
);