blob: 69e98883d871c01a1af7aadbc8068a1f058d572e [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* Virtual terminal interface shell.
2 * Copyright (C) 2000 Kunihiro Ishiguro
3 *
4 * This file is part of GNU Zebra.
5 *
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
9 * later version.
10 *
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.
15 *
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
19 * 02111-1307, USA.
20 */
21
22#include <zebra.h>
23
24#include <sys/un.h>
25#include <setjmp.h>
26#include <sys/wait.h>
27#include <sys/resource.h>
28#include <sys/stat.h>
29
30#include <readline/readline.h>
31#include <readline/history.h>
32
33#include "command.h"
34#include "memory.h"
35#include "vtysh/vtysh.h"
ajs6099b3b2004-11-20 02:06:59 +000036#include "log.h"
Paul Jakma320da872008-07-02 13:40:33 +000037#include "bgpd/bgp_vty.h"
Feng Lu471ea392015-05-22 11:40:00 +020038#include "vrf.h"
paul718e3742002-12-13 20:15:29 +000039
40/* Struct VTY. */
41struct vty *vty;
42
43/* VTY shell pager name. */
44char *vtysh_pager_name = NULL;
45
46/* VTY shell client structure. */
47struct vtysh_client
48{
49 int fd;
ajsb1aa1472005-01-28 21:11:46 +000050 const char *name;
51 int flag;
52 const char *path;
53} vtysh_client[] =
54{
55 { .fd = -1, .name = "zebra", .flag = VTYSH_ZEBRA, .path = ZEBRA_VTYSH_PATH},
56 { .fd = -1, .name = "ripd", .flag = VTYSH_RIPD, .path = RIP_VTYSH_PATH},
57 { .fd = -1, .name = "ripngd", .flag = VTYSH_RIPNGD, .path = RIPNG_VTYSH_PATH},
58 { .fd = -1, .name = "ospfd", .flag = VTYSH_OSPFD, .path = OSPF_VTYSH_PATH},
59 { .fd = -1, .name = "ospf6d", .flag = VTYSH_OSPF6D, .path = OSPF6_VTYSH_PATH},
60 { .fd = -1, .name = "bgpd", .flag = VTYSH_BGPD, .path = BGP_VTYSH_PATH},
61 { .fd = -1, .name = "isisd", .flag = VTYSH_ISISD, .path = ISIS_VTYSH_PATH},
Leonard Herve596470f2009-08-11 15:45:26 -030062 { .fd = -1, .name = "pimd", .flag = VTYSH_PIMD, .path = PIM_VTYSH_PATH},
ajsb1aa1472005-01-28 21:11:46 +000063};
64
ajsb1aa1472005-01-28 21:11:46 +000065
66/* We need direct access to ripd to implement vtysh_exit_ripd_only. */
67static struct vtysh_client *ripd_client = NULL;
68
hassob094d262004-08-25 12:22:00 +000069
hassoe7168df2004-10-03 20:11:32 +000070/* Using integrated config from Quagga.conf. Default is no. */
71int vtysh_writeconfig_integrated = 0;
72
73extern char config_default[];
74
ajs274a4a42004-12-07 15:39:31 +000075static void
paul718e3742002-12-13 20:15:29 +000076vclient_close (struct vtysh_client *vclient)
77{
ajsb1aa1472005-01-28 21:11:46 +000078 if (vclient->fd >= 0)
79 {
80 fprintf(stderr,
81 "Warning: closing connection to %s because of an I/O error!\n",
82 vclient->name);
83 close (vclient->fd);
84 vclient->fd = -1;
85 }
paul718e3742002-12-13 20:15:29 +000086}
87
Donald Sharp07440402016-02-25 07:39:45 -050088/* Return true if str begins with prefix, else return false */
89static int
90begins_with(const char *str, const char *prefix)
91{
92 if (!str || !prefix)
93 return 0;
94 size_t lenstr = strlen(str);
95 size_t lenprefix = strlen(prefix);
96 if (lenprefix > lenstr)
97 return 0;
98 return strncmp(str, prefix, lenprefix) == 0;
99}
100
paul718e3742002-12-13 20:15:29 +0000101/* Following filled with debug code to trace a problematic condition
hasso95e735b2004-08-26 13:08:30 +0000102 * under load - it SHOULD handle it. */
Gautam Kumarcc216b72015-10-26 13:22:12 -0700103#define ERR_WHERE_STRING "vtysh(): vtysh_client_execute(): "
ajs274a4a42004-12-07 15:39:31 +0000104static int
Gautam Kumarcc216b72015-10-26 13:22:12 -0700105vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp)
paul718e3742002-12-13 20:15:29 +0000106{
107 int ret;
108 char *buf;
109 size_t bufsz;
110 char *pbuf;
111 size_t left;
112 char *eoln;
113 int nbytes;
114 int i;
115 int readln;
Gautam Kumarcc216b72015-10-26 13:22:12 -0700116 int numnulls = 0;
paul718e3742002-12-13 20:15:29 +0000117
118 if (vclient->fd < 0)
119 return CMD_SUCCESS;
120
121 ret = write (vclient->fd, line, strlen (line) + 1);
122 if (ret <= 0)
123 {
124 vclient_close (vclient);
125 return CMD_SUCCESS;
126 }
127
hasso95e735b2004-08-26 13:08:30 +0000128 /* Allow enough room for buffer to read more than a few pages from socket. */
paule3d29b52003-01-23 18:05:42 +0000129 bufsz = 5 * getpagesize() + 1;
paul718e3742002-12-13 20:15:29 +0000130 buf = XMALLOC(MTYPE_TMP, bufsz);
131 memset(buf, 0, bufsz);
132 pbuf = buf;
133
134 while (1)
135 {
136 if (pbuf >= ((buf + bufsz) -1))
137 {
138 fprintf (stderr, ERR_WHERE_STRING \
139 "warning - pbuf beyond buffer end.\n");
140 return CMD_WARNING;
141 }
142
143 readln = (buf + bufsz) - pbuf - 1;
144 nbytes = read (vclient->fd, pbuf, readln);
145
146 if (nbytes <= 0)
147 {
148
149 if (errno == EINTR)
150 continue;
151
152 fprintf(stderr, ERR_WHERE_STRING "(%u)", errno);
153 perror("");
154
155 if (errno == EAGAIN || errno == EIO)
156 continue;
157
158 vclient_close (vclient);
159 XFREE(MTYPE_TMP, buf);
160 return CMD_SUCCESS;
161 }
Gautam Kumarcc216b72015-10-26 13:22:12 -0700162 /* If we have already seen 3 nulls, then current byte is ret code */
163 if ((numnulls == 3) && (nbytes == 1))
164 {
165 ret = pbuf[0];
166 break;
167 }
paul718e3742002-12-13 20:15:29 +0000168
169 pbuf[nbytes] = '\0';
170
Gautam Kumarcc216b72015-10-26 13:22:12 -0700171 /* If the config needs to be written in file or stdout */
172 if (fp)
173 {
174 fputs(pbuf, fp);
175 fflush (fp);
176 }
paul718e3742002-12-13 20:15:29 +0000177
Gautam Kumarcc216b72015-10-26 13:22:12 -0700178 /* At max look last four bytes */
179 if (nbytes >= 4)
180 {
181 i = nbytes - 4;
182 numnulls = 0;
183 }
184 else
185 i = 0;
paul718e3742002-12-13 20:15:29 +0000186
Gautam Kumarcc216b72015-10-26 13:22:12 -0700187 /* Count the numnulls */
188 while (i < nbytes && numnulls <3)
189 {
190 if (pbuf[i++] == '\0')
191 numnulls++;
192 else
193 numnulls = 0;
194 }
195 /* We might have seen 3 consecutive nulls so store the ret code before updating pbuf*/
196 ret = pbuf[nbytes-1];
197 pbuf += nbytes;
paul718e3742002-12-13 20:15:29 +0000198
Gautam Kumarcc216b72015-10-26 13:22:12 -0700199 /* See if a line exists in buffer, if so parse and consume it, and
200 * reset read position. If 3 nulls has been encountered consume the buffer before
201 * next read.
202 */
203 if (((eoln = strrchr(buf, '\n')) == NULL) && (numnulls<3))
204 continue;
205
206 if (eoln >= ((buf + bufsz) - 1))
207 {
208 fprintf (stderr, ERR_WHERE_STRING \
209 "warning - eoln beyond buffer end.\n");
210 }
211
212 /* If the config needs parsing, consume it */
213 if(!fp)
214 vtysh_config_parse(buf);
215
216 eoln++;
217 left = (size_t)(buf + bufsz - eoln);
218 /*
219 * This check is required since when a config line split between two consecutive reads,
220 * then buf will have first half of config line and current read will bring rest of the
221 * line. So in this case eoln will be 1 here, hence calculation of left will be wrong.
222 * In this case we don't need to do memmove, because we have already seen 3 nulls.
223 */
224 if(left < bufsz)
225 memmove(buf, eoln, left);
226
227 buf[bufsz-1] = '\0';
228 pbuf = buf + strlen(buf);
229 /* got 3 or more trailing NULs? */
230 if ((numnulls >=3) && (i < nbytes))
231 {
232 break;
233 }
paul718e3742002-12-13 20:15:29 +0000234 }
235
Gautam Kumarcc216b72015-10-26 13:22:12 -0700236 if(!fp)
237 vtysh_config_parse (buf);
paul718e3742002-12-13 20:15:29 +0000238
239 XFREE(MTYPE_TMP, buf);
240 return ret;
241}
Gautam Kumarcc216b72015-10-26 13:22:12 -0700242
paul718e3742002-12-13 20:15:29 +0000243
paul718e3742002-12-13 20:15:29 +0000244void
ajsb1aa1472005-01-28 21:11:46 +0000245vtysh_pager_init (void)
paul718e3742002-12-13 20:15:29 +0000246{
hasso5a9c53d2004-08-27 14:23:28 +0000247 char *pager_defined;
248
249 pager_defined = getenv ("VTYSH_PAGER");
250
251 if (pager_defined)
252 vtysh_pager_name = strdup (pager_defined);
253 else
hasso34553cc2004-08-27 13:56:39 +0000254 vtysh_pager_name = strdup ("more");
paul718e3742002-12-13 20:15:29 +0000255}
256
257/* Command execution over the vty interface. */
Stephen Hemminger57fb9742008-07-28 12:19:04 -0700258static int
hassodda09522004-10-07 21:40:25 +0000259vtysh_execute_func (const char *line, int pager)
paul718e3742002-12-13 20:15:29 +0000260{
Stephen Hemminger2c4d48b2008-07-28 15:04:56 -0700261 int ret, cmd_stat;
ajsb1aa1472005-01-28 21:11:46 +0000262 u_int i;
paul718e3742002-12-13 20:15:29 +0000263 vector vline;
264 struct cmd_element *cmd;
265 FILE *fp = NULL;
hasso13bfca72005-01-23 21:42:25 +0000266 int closepager = 0;
267 int tried = 0;
268 int saved_ret, saved_node;
paul718e3742002-12-13 20:15:29 +0000269
hasso95e735b2004-08-26 13:08:30 +0000270 /* Split readline string up into the vector. */
paul718e3742002-12-13 20:15:29 +0000271 vline = cmd_make_strvec (line);
272
273 if (vline == NULL)
Stephen Hemminger57fb9742008-07-28 12:19:04 -0700274 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000275
hasso13bfca72005-01-23 21:42:25 +0000276 saved_ret = ret = cmd_execute_command (vline, vty, &cmd, 1);
277 saved_node = vty->node;
278
279 /* If command doesn't succeeded in current node, try to walk up in node tree.
280 * Changing vty->node is enough to try it just out without actual walkup in
281 * the vtysh. */
282 while (ret != CMD_SUCCESS && ret != CMD_SUCCESS_DAEMON && ret != CMD_WARNING
283 && vty->node > CONFIG_NODE)
284 {
285 vty->node = node_parent(vty->node);
286 ret = cmd_execute_command (vline, vty, &cmd, 1);
287 tried++;
288 }
289
290 vty->node = saved_node;
291
292 /* If command succeeded in any other node than current (tried > 0) we have
293 * to move into node in the vtysh where it succeeded. */
294 if (ret == CMD_SUCCESS || ret == CMD_SUCCESS_DAEMON || ret == CMD_WARNING)
295 {
Lou Berger82dd7072016-01-12 13:41:57 -0500296 if ((saved_node == BGP_VPNV4_NODE || saved_node == BGP_VPNV6_NODE
Lou Bergera3fda882016-01-12 13:42:04 -0500297 || saved_node == BGP_ENCAP_NODE || saved_node == BGP_ENCAPV6_NODE
Lou Berger13c378d2016-01-12 13:41:56 -0500298 || saved_node == BGP_IPV4_NODE
paul57b5b7e2005-08-22 22:44:29 +0000299 || saved_node == BGP_IPV6_NODE || saved_node == BGP_IPV4M_NODE
300 || saved_node == BGP_IPV6M_NODE)
hasso13bfca72005-01-23 21:42:25 +0000301 && (tried == 1))
302 {
303 vtysh_execute("exit-address-family");
304 }
305 else if ((saved_node == KEYCHAIN_KEY_NODE) && (tried == 1))
306 {
307 vtysh_execute("exit");
308 }
309 else if (tried)
310 {
311 vtysh_execute ("end");
312 vtysh_execute ("configure terminal");
313 }
314 }
315 /* If command didn't succeed in any node, continue with return value from
316 * first try. */
317 else if (tried)
318 {
319 ret = saved_ret;
320 }
paul718e3742002-12-13 20:15:29 +0000321
322 cmd_free_strvec (vline);
323
Stephen Hemminger2c4d48b2008-07-28 15:04:56 -0700324 cmd_stat = ret;
paul718e3742002-12-13 20:15:29 +0000325 switch (ret)
326 {
327 case CMD_WARNING:
328 if (vty->type == VTY_FILE)
paul4fc01e62002-12-13 20:49:00 +0000329 fprintf (stdout,"Warning...\n");
paul718e3742002-12-13 20:15:29 +0000330 break;
331 case CMD_ERR_AMBIGUOUS:
paul4fc01e62002-12-13 20:49:00 +0000332 fprintf (stdout,"%% Ambiguous command.\n");
paul718e3742002-12-13 20:15:29 +0000333 break;
334 case CMD_ERR_NO_MATCH:
paul4fc01e62002-12-13 20:49:00 +0000335 fprintf (stdout,"%% Unknown command.\n");
paul718e3742002-12-13 20:15:29 +0000336 break;
337 case CMD_ERR_INCOMPLETE:
paul4fc01e62002-12-13 20:49:00 +0000338 fprintf (stdout,"%% Command incomplete.\n");
paul718e3742002-12-13 20:15:29 +0000339 break;
340 case CMD_SUCCESS_DAEMON:
341 {
hasso97b7db22004-10-20 19:07:48 +0000342 /* FIXME: Don't open pager for exit commands. popen() causes problems
343 * if exited from vtysh at all. This hack shouldn't cause any problem
344 * but is really ugly. */
345 if (pager && vtysh_pager_name && (strncmp(line, "exit", 4) != 0))
paul718e3742002-12-13 20:15:29 +0000346 {
paul4fc01e62002-12-13 20:49:00 +0000347 fp = popen (vtysh_pager_name, "w");
paul718e3742002-12-13 20:15:29 +0000348 if (fp == NULL)
349 {
paula805cc22003-05-01 14:29:48 +0000350 perror ("popen failed for pager");
351 fp = stdout;
paul718e3742002-12-13 20:15:29 +0000352 }
paula805cc22003-05-01 14:29:48 +0000353 else
354 closepager=1;
paul718e3742002-12-13 20:15:29 +0000355 }
356 else
357 fp = stdout;
358
359 if (! strcmp(cmd->string,"configure terminal"))
360 {
Balaji.G837d16c2012-09-26 14:09:10 +0530361 for (i = 0; i < array_size(vtysh_client); i++)
ajsb1aa1472005-01-28 21:11:46 +0000362 {
363 cmd_stat = vtysh_client_execute(&vtysh_client[i], line, fp);
364 if (cmd_stat == CMD_WARNING)
365 break;
366 }
367
paul718e3742002-12-13 20:15:29 +0000368 if (cmd_stat)
369 {
hassob094d262004-08-25 12:22:00 +0000370 line = "end";
371 vline = cmd_make_strvec (line);
paul718e3742002-12-13 20:15:29 +0000372
hassob094d262004-08-25 12:22:00 +0000373 if (vline == NULL)
paul718e3742002-12-13 20:15:29 +0000374 {
paula805cc22003-05-01 14:29:48 +0000375 if (pager && vtysh_pager_name && fp && closepager)
paul718e3742002-12-13 20:15:29 +0000376 {
377 if (pclose (fp) == -1)
378 {
paula805cc22003-05-01 14:29:48 +0000379 perror ("pclose failed for pager");
paul718e3742002-12-13 20:15:29 +0000380 }
381 fp = NULL;
382 }
Stephen Hemminger57fb9742008-07-28 12:19:04 -0700383 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000384 }
385
hasso87d683b2005-01-16 23:31:54 +0000386 ret = cmd_execute_command (vline, vty, &cmd, 1);
hassob094d262004-08-25 12:22:00 +0000387 cmd_free_strvec (vline);
388 if (ret != CMD_SUCCESS_DAEMON)
389 break;
paul718e3742002-12-13 20:15:29 +0000390 }
391 else
392 if (cmd->func)
393 {
394 (*cmd->func) (cmd, vty, 0, NULL);
395 break;
hassob094d262004-08-25 12:22:00 +0000396 }
paul718e3742002-12-13 20:15:29 +0000397 }
398
ajsb1aa1472005-01-28 21:11:46 +0000399 cmd_stat = CMD_SUCCESS;
Balaji.G837d16c2012-09-26 14:09:10 +0530400 for (i = 0; i < array_size(vtysh_client); i++)
ajsb1aa1472005-01-28 21:11:46 +0000401 {
402 if (cmd->daemon & vtysh_client[i].flag)
403 {
404 cmd_stat = vtysh_client_execute(&vtysh_client[i], line, fp);
405 if (cmd_stat != CMD_SUCCESS)
406 break;
407 }
408 }
409 if (cmd_stat != CMD_SUCCESS)
410 break;
411
paul718e3742002-12-13 20:15:29 +0000412 if (cmd->func)
413 (*cmd->func) (cmd, vty, 0, NULL);
414 }
415 }
paula805cc22003-05-01 14:29:48 +0000416 if (pager && vtysh_pager_name && fp && closepager)
paul718e3742002-12-13 20:15:29 +0000417 {
418 if (pclose (fp) == -1)
419 {
paula805cc22003-05-01 14:29:48 +0000420 perror ("pclose failed for pager");
paul718e3742002-12-13 20:15:29 +0000421 }
422 fp = NULL;
423 }
Stephen Hemminger57fb9742008-07-28 12:19:04 -0700424 return cmd_stat;
paul718e3742002-12-13 20:15:29 +0000425}
426
Stephen Hemminger57fb9742008-07-28 12:19:04 -0700427int
hassodda09522004-10-07 21:40:25 +0000428vtysh_execute_no_pager (const char *line)
paul718e3742002-12-13 20:15:29 +0000429{
Stephen Hemminger57fb9742008-07-28 12:19:04 -0700430 return vtysh_execute_func (line, 0);
paul718e3742002-12-13 20:15:29 +0000431}
432
Stephen Hemminger57fb9742008-07-28 12:19:04 -0700433int
hassodda09522004-10-07 21:40:25 +0000434vtysh_execute (const char *line)
paul718e3742002-12-13 20:15:29 +0000435{
Stephen Hemminger57fb9742008-07-28 12:19:04 -0700436 return vtysh_execute_func (line, 1);
paul718e3742002-12-13 20:15:29 +0000437}
438
439/* Configration make from file. */
440int
441vtysh_config_from_file (struct vty *vty, FILE *fp)
442{
443 int ret;
paul718e3742002-12-13 20:15:29 +0000444 struct cmd_element *cmd;
445
446 while (fgets (vty->buf, VTY_BUFSIZ, fp))
447 {
Donald Sharpd8aa4be2015-09-28 20:10:40 -0400448 ret = command_config_read_one_line (vty, &cmd, 1);
paul718e3742002-12-13 20:15:29 +0000449
450 switch (ret)
451 {
452 case CMD_WARNING:
453 if (vty->type == VTY_FILE)
paul4fc01e62002-12-13 20:49:00 +0000454 fprintf (stdout,"Warning...\n");
paul718e3742002-12-13 20:15:29 +0000455 break;
456 case CMD_ERR_AMBIGUOUS:
paul4fc01e62002-12-13 20:49:00 +0000457 fprintf (stdout,"%% Ambiguous command.\n");
paul718e3742002-12-13 20:15:29 +0000458 break;
459 case CMD_ERR_NO_MATCH:
paul4fc01e62002-12-13 20:49:00 +0000460 fprintf (stdout,"%% Unknown command: %s", vty->buf);
paul718e3742002-12-13 20:15:29 +0000461 break;
462 case CMD_ERR_INCOMPLETE:
paul4fc01e62002-12-13 20:49:00 +0000463 fprintf (stdout,"%% Command incomplete.\n");
paul718e3742002-12-13 20:15:29 +0000464 break;
465 case CMD_SUCCESS_DAEMON:
466 {
ajsb1aa1472005-01-28 21:11:46 +0000467 u_int i;
468 int cmd_stat = CMD_SUCCESS;
469
Balaji.G837d16c2012-09-26 14:09:10 +0530470 for (i = 0; i < array_size(vtysh_client); i++)
ajsb1aa1472005-01-28 21:11:46 +0000471 {
paul44316fe2006-01-11 01:38:25 +0000472 if (cmd->daemon & vtysh_client[i].flag)
ajsb1aa1472005-01-28 21:11:46 +0000473 {
474 cmd_stat = vtysh_client_execute (&vtysh_client[i],
475 vty->buf, stdout);
476 if (cmd_stat != CMD_SUCCESS)
477 break;
478 }
479 }
480 if (cmd_stat != CMD_SUCCESS)
481 break;
482
paul718e3742002-12-13 20:15:29 +0000483 if (cmd->func)
484 (*cmd->func) (cmd, vty, 0, NULL);
485 }
486 }
487 }
488 return CMD_SUCCESS;
489}
490
491/* We don't care about the point of the cursor when '?' is typed. */
David Lampartera9eb9062015-03-04 07:07:01 +0100492static int
ajsb1aa1472005-01-28 21:11:46 +0000493vtysh_rl_describe (void)
paul718e3742002-12-13 20:15:29 +0000494{
495 int ret;
hassodda09522004-10-07 21:40:25 +0000496 unsigned int i;
paul718e3742002-12-13 20:15:29 +0000497 vector vline;
498 vector describe;
499 int width;
Christian Frankecd40b322013-09-30 12:27:51 +0000500 struct cmd_token *token;
paul718e3742002-12-13 20:15:29 +0000501
502 vline = cmd_make_strvec (rl_line_buffer);
503
504 /* In case of '> ?'. */
505 if (vline == NULL)
506 {
507 vline = vector_init (1);
David Lampartera91a3ba2015-03-03 09:06:51 +0100508 vector_set (vline, NULL);
paul718e3742002-12-13 20:15:29 +0000509 }
510 else
511 if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
David Lampartera91a3ba2015-03-03 09:06:51 +0100512 vector_set (vline, NULL);
paul718e3742002-12-13 20:15:29 +0000513
514 describe = cmd_describe_command (vline, vty, &ret);
515
paul4fc01e62002-12-13 20:49:00 +0000516 fprintf (stdout,"\n");
paul718e3742002-12-13 20:15:29 +0000517
518 /* Ambiguous and no match error. */
519 switch (ret)
520 {
521 case CMD_ERR_AMBIGUOUS:
522 cmd_free_strvec (vline);
paul4fc01e62002-12-13 20:49:00 +0000523 fprintf (stdout,"%% Ambiguous command.\n");
paul718e3742002-12-13 20:15:29 +0000524 rl_on_new_line ();
525 return 0;
526 break;
527 case CMD_ERR_NO_MATCH:
528 cmd_free_strvec (vline);
paul4fc01e62002-12-13 20:49:00 +0000529 fprintf (stdout,"%% There is no matched command.\n");
paul718e3742002-12-13 20:15:29 +0000530 rl_on_new_line ();
531 return 0;
532 break;
533 }
534
535 /* Get width of command string. */
536 width = 0;
paul55468c82005-03-14 20:19:01 +0000537 for (i = 0; i < vector_active (describe); i++)
Christian Frankecd40b322013-09-30 12:27:51 +0000538 if ((token = vector_slot (describe, i)) != NULL)
paul718e3742002-12-13 20:15:29 +0000539 {
540 int len;
541
Christian Frankecd40b322013-09-30 12:27:51 +0000542 if (token->cmd[0] == '\0')
paul718e3742002-12-13 20:15:29 +0000543 continue;
544
Christian Frankecd40b322013-09-30 12:27:51 +0000545 len = strlen (token->cmd);
546 if (token->cmd[0] == '.')
paul718e3742002-12-13 20:15:29 +0000547 len--;
548
549 if (width < len)
550 width = len;
551 }
552
paul55468c82005-03-14 20:19:01 +0000553 for (i = 0; i < vector_active (describe); i++)
Christian Frankecd40b322013-09-30 12:27:51 +0000554 if ((token = vector_slot (describe, i)) != NULL)
paul718e3742002-12-13 20:15:29 +0000555 {
Christian Frankecd40b322013-09-30 12:27:51 +0000556 if (token->cmd[0] == '\0')
paul718e3742002-12-13 20:15:29 +0000557 continue;
558
Christian Frankecd40b322013-09-30 12:27:51 +0000559 if (! token->desc)
paul4fc01e62002-12-13 20:49:00 +0000560 fprintf (stdout," %-s\n",
Christian Frankecd40b322013-09-30 12:27:51 +0000561 token->cmd[0] == '.' ? token->cmd + 1 : token->cmd);
paul718e3742002-12-13 20:15:29 +0000562 else
paul4fc01e62002-12-13 20:49:00 +0000563 fprintf (stdout," %-*s %s\n",
hassob094d262004-08-25 12:22:00 +0000564 width,
Christian Frankecd40b322013-09-30 12:27:51 +0000565 token->cmd[0] == '.' ? token->cmd + 1 : token->cmd,
566 token->desc);
paul718e3742002-12-13 20:15:29 +0000567 }
568
569 cmd_free_strvec (vline);
570 vector_free (describe);
571
572 rl_on_new_line();
573
574 return 0;
575}
576
hasso95e735b2004-08-26 13:08:30 +0000577/* Result of cmd_complete_command() call will be stored here
578 * and used in new_completion() in order to put the space in
579 * correct places only. */
paul718e3742002-12-13 20:15:29 +0000580int complete_status;
581
ajs274a4a42004-12-07 15:39:31 +0000582static char *
pauldfc0d9b2003-04-18 23:55:29 +0000583command_generator (const char *text, int state)
paul718e3742002-12-13 20:15:29 +0000584{
585 vector vline;
586 static char **matched = NULL;
587 static int index = 0;
588
589 /* First call. */
590 if (! state)
591 {
592 index = 0;
593
594 if (vty->node == AUTH_NODE || vty->node == AUTH_ENABLE_NODE)
595 return NULL;
596
597 vline = cmd_make_strvec (rl_line_buffer);
598 if (vline == NULL)
599 return NULL;
600
601 if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
David Lampartera91a3ba2015-03-03 09:06:51 +0100602 vector_set (vline, NULL);
paul718e3742002-12-13 20:15:29 +0000603
604 matched = cmd_complete_command (vline, vty, &complete_status);
605 }
606
607 if (matched && matched[index])
608 return matched[index++];
609
610 return NULL;
611}
612
ajs274a4a42004-12-07 15:39:31 +0000613static char **
paul718e3742002-12-13 20:15:29 +0000614new_completion (char *text, int start, int end)
615{
616 char **matches;
617
pauldfc0d9b2003-04-18 23:55:29 +0000618 matches = rl_completion_matches (text, command_generator);
paul718e3742002-12-13 20:15:29 +0000619
620 if (matches)
621 {
622 rl_point = rl_end;
Christian Franke67e7a212013-03-04 09:23:30 +0000623 if (complete_status != CMD_COMPLETE_FULL_MATCH)
624 /* only append a space on full match */
625 rl_completion_append_character = '\0';
paul718e3742002-12-13 20:15:29 +0000626 }
627
628 return matches;
629}
630
ajs274a4a42004-12-07 15:39:31 +0000631#if 0
632/* This function is not actually being used. */
633static char **
paul718e3742002-12-13 20:15:29 +0000634vtysh_completion (char *text, int start, int end)
635{
636 int ret;
637 vector vline;
638 char **matched = NULL;
639
640 if (vty->node == AUTH_NODE || vty->node == AUTH_ENABLE_NODE)
641 return NULL;
642
643 vline = cmd_make_strvec (rl_line_buffer);
644 if (vline == NULL)
645 return NULL;
646
647 /* In case of 'help \t'. */
648 if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
649 vector_set (vline, '\0');
650
651 matched = cmd_complete_command (vline, vty, &ret);
652
653 cmd_free_strvec (vline);
654
655 return (char **) matched;
656}
ajs274a4a42004-12-07 15:39:31 +0000657#endif
paul718e3742002-12-13 20:15:29 +0000658
hasso95e735b2004-08-26 13:08:30 +0000659/* Vty node structures. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800660static struct cmd_node bgp_node =
paul718e3742002-12-13 20:15:29 +0000661{
662 BGP_NODE,
663 "%s(config-router)# ",
664};
665
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800666static struct cmd_node rip_node =
paul718e3742002-12-13 20:15:29 +0000667{
668 RIP_NODE,
669 "%s(config-router)# ",
670};
671
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800672static struct cmd_node isis_node =
hassoc25e4582003-12-23 10:39:08 +0000673{
674 ISIS_NODE,
675 "%s(config-router)# ",
hassoc25e4582003-12-23 10:39:08 +0000676};
677
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800678static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +0000679{
680 INTERFACE_NODE,
681 "%s(config-if)# ",
682};
683
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800684static struct cmd_node rmap_node =
hasso95e735b2004-08-26 13:08:30 +0000685{
686 RMAP_NODE,
687 "%s(config-route-map)# "
688};
689
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800690static struct cmd_node zebra_node =
hasso95e735b2004-08-26 13:08:30 +0000691{
692 ZEBRA_NODE,
693 "%s(config-router)# "
694};
695
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800696static struct cmd_node bgp_vpnv4_node =
hasso95e735b2004-08-26 13:08:30 +0000697{
698 BGP_VPNV4_NODE,
699 "%s(config-router-af)# "
700};
701
Lou Berger13c378d2016-01-12 13:41:56 -0500702static struct cmd_node bgp_vpnv6_node =
703{
704 BGP_VPNV6_NODE,
705 "%s(config-router-af)# "
706};
707
Lou Bergera3fda882016-01-12 13:42:04 -0500708static struct cmd_node bgp_encap_node =
709{
710 BGP_ENCAP_NODE,
711 "%s(config-router-af)# "
712};
713
714static struct cmd_node bgp_encapv6_node =
715{
716 BGP_ENCAPV6_NODE,
717 "%s(config-router-af)# "
718};
719
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800720static struct cmd_node bgp_ipv4_node =
hasso95e735b2004-08-26 13:08:30 +0000721{
722 BGP_IPV4_NODE,
723 "%s(config-router-af)# "
724};
725
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800726static struct cmd_node bgp_ipv4m_node =
hasso95e735b2004-08-26 13:08:30 +0000727{
728 BGP_IPV4M_NODE,
729 "%s(config-router-af)# "
730};
731
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800732static struct cmd_node bgp_ipv6_node =
hasso95e735b2004-08-26 13:08:30 +0000733{
734 BGP_IPV6_NODE,
735 "%s(config-router-af)# "
736};
737
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800738static struct cmd_node bgp_ipv6m_node =
paul57b5b7e2005-08-22 22:44:29 +0000739{
740 BGP_IPV6M_NODE,
741 "%s(config-router-af)# "
742};
743
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800744static struct cmd_node ospf_node =
hasso95e735b2004-08-26 13:08:30 +0000745{
746 OSPF_NODE,
747 "%s(config-router)# "
748};
749
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800750static struct cmd_node ripng_node =
hasso95e735b2004-08-26 13:08:30 +0000751{
752 RIPNG_NODE,
753 "%s(config-router)# "
754};
755
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800756static struct cmd_node ospf6_node =
hasso95e735b2004-08-26 13:08:30 +0000757{
758 OSPF6_NODE,
759 "%s(config-ospf6)# "
760};
761
David Lamparteree53c8b2015-05-23 05:45:59 +0200762static struct cmd_node babel_node =
763{
764 BABEL_NODE,
765 "%s(config-babel)# "
766};
767
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800768static struct cmd_node keychain_node =
hasso95e735b2004-08-26 13:08:30 +0000769{
770 KEYCHAIN_NODE,
771 "%s(config-keychain)# "
772};
773
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800774static struct cmd_node keychain_key_node =
hasso95e735b2004-08-26 13:08:30 +0000775{
776 KEYCHAIN_KEY_NODE,
777 "%s(config-keychain-key)# "
778};
779
hassoe7168df2004-10-03 20:11:32 +0000780/* Defined in lib/vty.c */
781extern struct cmd_node vty_node;
782
hasso95e735b2004-08-26 13:08:30 +0000783/* When '^Z' is received from vty, move down to the enable mode. */
David Lampartera9eb9062015-03-04 07:07:01 +0100784static int
ajsb1aa1472005-01-28 21:11:46 +0000785vtysh_end (void)
hasso95e735b2004-08-26 13:08:30 +0000786{
787 switch (vty->node)
788 {
789 case VIEW_NODE:
790 case ENABLE_NODE:
791 /* Nothing to do. */
792 break;
793 default:
794 vty->node = ENABLE_NODE;
795 break;
796 }
797 return CMD_SUCCESS;
798}
799
800DEFUNSH (VTYSH_ALL,
801 vtysh_end_all,
802 vtysh_end_all_cmd,
803 "end",
hassoe7168df2004-10-03 20:11:32 +0000804 "End current mode and change to enable mode\n")
hasso95e735b2004-08-26 13:08:30 +0000805{
hasso42895462004-09-26 16:25:07 +0000806 return vtysh_end ();
hasso95e735b2004-08-26 13:08:30 +0000807}
808
paul718e3742002-12-13 20:15:29 +0000809DEFUNSH (VTYSH_BGPD,
810 router_bgp,
811 router_bgp_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000812 "router bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000813 ROUTER_STR
814 BGP_STR
815 AS_STR)
816{
817 vty->node = BGP_NODE;
818 return CMD_SUCCESS;
819}
820
Paul Jakma10895fd2008-07-03 19:34:48 +0000821ALIAS_SH (VTYSH_BGPD,
822 router_bgp,
823 router_bgp_view_cmd,
824 "router bgp " CMD_AS_RANGE " view WORD",
825 ROUTER_STR
826 BGP_STR
827 AS_STR
828 "BGP view\n"
829 "view name\n")
830
paul718e3742002-12-13 20:15:29 +0000831DEFUNSH (VTYSH_BGPD,
832 address_family_vpnv4,
833 address_family_vpnv4_cmd,
834 "address-family vpnv4",
835 "Enter Address Family command mode\n"
836 "Address family\n")
837{
838 vty->node = BGP_VPNV4_NODE;
839 return CMD_SUCCESS;
840}
841
842DEFUNSH (VTYSH_BGPD,
843 address_family_vpnv4_unicast,
844 address_family_vpnv4_unicast_cmd,
845 "address-family vpnv4 unicast",
846 "Enter Address Family command mode\n"
847 "Address family\n"
848 "Address Family Modifier\n")
849{
850 vty->node = BGP_VPNV4_NODE;
851 return CMD_SUCCESS;
852}
853
854DEFUNSH (VTYSH_BGPD,
Lou Berger13c378d2016-01-12 13:41:56 -0500855 address_family_vpnv6,
856 address_family_vpnv6_cmd,
857 "address-family vpnv6",
858 "Enter Address Family command mode\n"
859 "Address family\n")
860{
861 vty->node = BGP_VPNV6_NODE;
862 return CMD_SUCCESS;
863}
864
865DEFUNSH (VTYSH_BGPD,
866 address_family_vpnv6_unicast,
867 address_family_vpnv6_unicast_cmd,
868 "address-family vpnv6 unicast",
869 "Enter Address Family command mode\n"
870 "Address family\n"
871 "Address Family Modifier\n")
872{
873 vty->node = BGP_VPNV6_NODE;
874 return CMD_SUCCESS;
875}
876
877DEFUNSH (VTYSH_BGPD,
Lou Bergera3fda882016-01-12 13:42:04 -0500878 address_family_encap,
879 address_family_encap_cmd,
880 "address-family encap",
881 "Enter Address Family command mode\n"
882 "Address family\n")
883{
884 vty->node = BGP_ENCAP_NODE;
885 return CMD_SUCCESS;
886}
887
888DEFUNSH (VTYSH_BGPD,
889 address_family_encapv4,
890 address_family_encapv4_cmd,
891 "address-family encapv4",
892 "Enter Address Family command mode\n"
893 "Address family\n")
894{
895 vty->node = BGP_ENCAP_NODE;
896 return CMD_SUCCESS;
897}
898
899DEFUNSH (VTYSH_BGPD,
900 address_family_encapv6,
901 address_family_encapv6_cmd,
902 "address-family encapv6",
903 "Enter Address Family command mode\n"
904 "Address family\n")
905{
906 vty->node = BGP_ENCAPV6_NODE;
907 return CMD_SUCCESS;
908}
909
910DEFUNSH (VTYSH_BGPD,
paul718e3742002-12-13 20:15:29 +0000911 address_family_ipv4_unicast,
912 address_family_ipv4_unicast_cmd,
913 "address-family ipv4 unicast",
914 "Enter Address Family command mode\n"
915 "Address family\n"
916 "Address Family Modifier\n")
917{
918 vty->node = BGP_IPV4_NODE;
919 return CMD_SUCCESS;
920}
921
922DEFUNSH (VTYSH_BGPD,
923 address_family_ipv4_multicast,
924 address_family_ipv4_multicast_cmd,
925 "address-family ipv4 multicast",
926 "Enter Address Family command mode\n"
927 "Address family\n"
928 "Address Family Modifier\n")
929{
930 vty->node = BGP_IPV4M_NODE;
931 return CMD_SUCCESS;
932}
933
934DEFUNSH (VTYSH_BGPD,
935 address_family_ipv6,
936 address_family_ipv6_cmd,
937 "address-family ipv6",
938 "Enter Address Family command mode\n"
939 "Address family\n")
940{
941 vty->node = BGP_IPV6_NODE;
942 return CMD_SUCCESS;
943}
944
945DEFUNSH (VTYSH_BGPD,
946 address_family_ipv6_unicast,
947 address_family_ipv6_unicast_cmd,
948 "address-family ipv6 unicast",
949 "Enter Address Family command mode\n"
950 "Address family\n"
951 "Address Family Modifier\n")
952{
953 vty->node = BGP_IPV6_NODE;
954 return CMD_SUCCESS;
955}
956
paul57b5b7e2005-08-22 22:44:29 +0000957DEFUNSH (VTYSH_BGPD,
958 address_family_ipv6_multicast,
959 address_family_ipv6_multicast_cmd,
960 "address-family ipv6 multicast",
961 "Enter Address Family command mode\n"
962 "Address family\n"
963 "Address Family Modifier\n")
964{
965 vty->node = BGP_IPV6M_NODE;
966 return CMD_SUCCESS;
967}
968
paul718e3742002-12-13 20:15:29 +0000969DEFUNSH (VTYSH_RIPD,
970 key_chain,
971 key_chain_cmd,
972 "key chain WORD",
973 "Authentication key management\n"
974 "Key-chain management\n"
975 "Key-chain name\n")
976{
977 vty->node = KEYCHAIN_NODE;
978 return CMD_SUCCESS;
979}
980
981DEFUNSH (VTYSH_RIPD,
982 key,
983 key_cmd,
984 "key <0-2147483647>",
985 "Configure a key\n"
986 "Key identifier number\n")
987{
988 vty->node = KEYCHAIN_KEY_NODE;
989 return CMD_SUCCESS;
990}
991
992DEFUNSH (VTYSH_RIPD,
993 router_rip,
994 router_rip_cmd,
995 "router rip",
996 ROUTER_STR
997 "RIP")
998{
999 vty->node = RIP_NODE;
1000 return CMD_SUCCESS;
1001}
1002
1003DEFUNSH (VTYSH_RIPNGD,
1004 router_ripng,
1005 router_ripng_cmd,
1006 "router ripng",
1007 ROUTER_STR
1008 "RIPng")
1009{
1010 vty->node = RIPNG_NODE;
1011 return CMD_SUCCESS;
1012}
1013
1014DEFUNSH (VTYSH_OSPFD,
1015 router_ospf,
1016 router_ospf_cmd,
1017 "router ospf",
1018 "Enable a routing process\n"
1019 "Start OSPF configuration\n")
1020{
1021 vty->node = OSPF_NODE;
1022 return CMD_SUCCESS;
1023}
1024
1025DEFUNSH (VTYSH_OSPF6D,
1026 router_ospf6,
1027 router_ospf6_cmd,
1028 "router ospf6",
1029 OSPF6_ROUTER_STR
1030 OSPF6_STR)
1031{
1032 vty->node = OSPF6_NODE;
1033 return CMD_SUCCESS;
1034}
1035
hassoc25e4582003-12-23 10:39:08 +00001036DEFUNSH (VTYSH_ISISD,
hassob094d262004-08-25 12:22:00 +00001037 router_isis,
1038 router_isis_cmd,
1039 "router isis WORD",
1040 ROUTER_STR
1041 "ISO IS-IS\n"
1042 "ISO Routing area tag")
hassoc25e4582003-12-23 10:39:08 +00001043{
1044 vty->node = ISIS_NODE;
1045 return CMD_SUCCESS;
1046}
1047
paul718e3742002-12-13 20:15:29 +00001048DEFUNSH (VTYSH_RMAP,
1049 route_map,
1050 route_map_cmd,
1051 "route-map WORD (deny|permit) <1-65535>",
1052 "Create route-map or enter route-map command mode\n"
1053 "Route map tag\n"
1054 "Route map denies set operations\n"
1055 "Route map permits set operations\n"
1056 "Sequence to insert to/delete from existing route-map entry\n")
1057{
1058 vty->node = RMAP_NODE;
1059 return CMD_SUCCESS;
1060}
1061
paul718e3742002-12-13 20:15:29 +00001062DEFUNSH (VTYSH_ALL,
hassoe7168df2004-10-03 20:11:32 +00001063 vtysh_line_vty,
1064 vtysh_line_vty_cmd,
1065 "line vty",
1066 "Configure a terminal line\n"
1067 "Virtual terminal\n")
1068{
1069 vty->node = VTY_NODE;
1070 return CMD_SUCCESS;
1071}
1072
1073DEFUNSH (VTYSH_ALL,
paul718e3742002-12-13 20:15:29 +00001074 vtysh_enable,
1075 vtysh_enable_cmd,
1076 "enable",
1077 "Turn on privileged mode command\n")
1078{
1079 vty->node = ENABLE_NODE;
1080 return CMD_SUCCESS;
1081}
1082
paul718e3742002-12-13 20:15:29 +00001083DEFUNSH (VTYSH_ALL,
1084 vtysh_disable,
1085 vtysh_disable_cmd,
1086 "disable",
1087 "Turn off privileged mode command\n")
1088{
1089 if (vty->node == ENABLE_NODE)
1090 vty->node = VIEW_NODE;
1091 return CMD_SUCCESS;
1092}
1093
paul718e3742002-12-13 20:15:29 +00001094DEFUNSH (VTYSH_ALL,
1095 vtysh_config_terminal,
1096 vtysh_config_terminal_cmd,
1097 "configure terminal",
1098 "Configuration from vty interface\n"
1099 "Configuration terminal\n")
1100{
1101 vty->node = CONFIG_NODE;
1102 return CMD_SUCCESS;
1103}
1104
ajs274a4a42004-12-07 15:39:31 +00001105static int
paul718e3742002-12-13 20:15:29 +00001106vtysh_exit (struct vty *vty)
1107{
1108 switch (vty->node)
1109 {
1110 case VIEW_NODE:
1111 case ENABLE_NODE:
1112 exit (0);
1113 break;
1114 case CONFIG_NODE:
1115 vty->node = ENABLE_NODE;
1116 break;
1117 case INTERFACE_NODE:
1118 case ZEBRA_NODE:
1119 case BGP_NODE:
1120 case RIP_NODE:
1121 case RIPNG_NODE:
1122 case OSPF_NODE:
1123 case OSPF6_NODE:
Juliusz Chroboczekfeb6c532012-02-07 04:58:49 +01001124 case BABEL_NODE:
hassoc25e4582003-12-23 10:39:08 +00001125 case ISIS_NODE:
paul718e3742002-12-13 20:15:29 +00001126 case MASC_NODE:
1127 case RMAP_NODE:
1128 case VTY_NODE:
1129 case KEYCHAIN_NODE:
hasso2a56df92004-05-09 23:16:40 +00001130 vtysh_execute("end");
1131 vtysh_execute("configure terminal");
paul718e3742002-12-13 20:15:29 +00001132 vty->node = CONFIG_NODE;
1133 break;
1134 case BGP_VPNV4_NODE:
Lou Berger13c378d2016-01-12 13:41:56 -05001135 case BGP_VPNV6_NODE:
Lou Bergera3fda882016-01-12 13:42:04 -05001136 case BGP_ENCAP_NODE:
1137 case BGP_ENCAPV6_NODE:
paul718e3742002-12-13 20:15:29 +00001138 case BGP_IPV4_NODE:
1139 case BGP_IPV4M_NODE:
1140 case BGP_IPV6_NODE:
paul57b5b7e2005-08-22 22:44:29 +00001141 case BGP_IPV6M_NODE:
paul718e3742002-12-13 20:15:29 +00001142 vty->node = BGP_NODE;
1143 break;
1144 case KEYCHAIN_KEY_NODE:
1145 vty->node = KEYCHAIN_NODE;
1146 break;
1147 default:
1148 break;
1149 }
1150 return CMD_SUCCESS;
1151}
1152
1153DEFUNSH (VTYSH_ALL,
1154 vtysh_exit_all,
1155 vtysh_exit_all_cmd,
1156 "exit",
1157 "Exit current mode and down to previous mode\n")
1158{
1159 return vtysh_exit (vty);
1160}
1161
1162ALIAS (vtysh_exit_all,
1163 vtysh_quit_all_cmd,
1164 "quit",
1165 "Exit current mode and down to previous mode\n")
1166
1167DEFUNSH (VTYSH_BGPD,
1168 exit_address_family,
1169 exit_address_family_cmd,
1170 "exit-address-family",
1171 "Exit from Address Family configuration mode\n")
1172{
1173 if (vty->node == BGP_IPV4_NODE
1174 || vty->node == BGP_IPV4M_NODE
1175 || vty->node == BGP_VPNV4_NODE
Lou Berger13c378d2016-01-12 13:41:56 -05001176 || vty->node == BGP_VPNV6_NODE
Lou Bergera3fda882016-01-12 13:42:04 -05001177 || vty->node == BGP_ENCAP_NODE
1178 || vty->node == BGP_ENCAPV6_NODE
paul57b5b7e2005-08-22 22:44:29 +00001179 || vty->node == BGP_IPV6_NODE
1180 || vty->node == BGP_IPV6M_NODE)
paul718e3742002-12-13 20:15:29 +00001181 vty->node = BGP_NODE;
1182 return CMD_SUCCESS;
1183}
1184
1185DEFUNSH (VTYSH_ZEBRA,
1186 vtysh_exit_zebra,
1187 vtysh_exit_zebra_cmd,
1188 "exit",
1189 "Exit current mode and down to previous mode\n")
1190{
1191 return vtysh_exit (vty);
1192}
1193
1194ALIAS (vtysh_exit_zebra,
1195 vtysh_quit_zebra_cmd,
1196 "quit",
1197 "Exit current mode and down to previous mode\n")
1198
1199DEFUNSH (VTYSH_RIPD,
1200 vtysh_exit_ripd,
1201 vtysh_exit_ripd_cmd,
1202 "exit",
1203 "Exit current mode and down to previous mode\n")
1204{
1205 return vtysh_exit (vty);
1206}
1207
1208ALIAS (vtysh_exit_ripd,
1209 vtysh_quit_ripd_cmd,
1210 "quit",
1211 "Exit current mode and down to previous mode\n")
1212
paul68980082003-03-25 05:07:42 +00001213DEFUNSH (VTYSH_RIPNGD,
hassob094d262004-08-25 12:22:00 +00001214 vtysh_exit_ripngd,
1215 vtysh_exit_ripngd_cmd,
1216 "exit",
1217 "Exit current mode and down to previous mode\n")
paul68980082003-03-25 05:07:42 +00001218{
1219 return vtysh_exit (vty);
1220}
1221
1222ALIAS (vtysh_exit_ripngd,
1223 vtysh_quit_ripngd_cmd,
1224 "quit",
1225 "Exit current mode and down to previous mode\n")
1226
paul718e3742002-12-13 20:15:29 +00001227DEFUNSH (VTYSH_RMAP,
1228 vtysh_exit_rmap,
1229 vtysh_exit_rmap_cmd,
1230 "exit",
1231 "Exit current mode and down to previous mode\n")
1232{
1233 return vtysh_exit (vty);
1234}
1235
1236ALIAS (vtysh_exit_rmap,
1237 vtysh_quit_rmap_cmd,
1238 "quit",
1239 "Exit current mode and down to previous mode\n")
1240
1241DEFUNSH (VTYSH_BGPD,
1242 vtysh_exit_bgpd,
1243 vtysh_exit_bgpd_cmd,
1244 "exit",
1245 "Exit current mode and down to previous mode\n")
1246{
1247 return vtysh_exit (vty);
1248}
1249
1250ALIAS (vtysh_exit_bgpd,
1251 vtysh_quit_bgpd_cmd,
1252 "quit",
1253 "Exit current mode and down to previous mode\n")
1254
1255DEFUNSH (VTYSH_OSPFD,
1256 vtysh_exit_ospfd,
1257 vtysh_exit_ospfd_cmd,
1258 "exit",
1259 "Exit current mode and down to previous mode\n")
1260{
1261 return vtysh_exit (vty);
1262}
1263
1264ALIAS (vtysh_exit_ospfd,
1265 vtysh_quit_ospfd_cmd,
1266 "quit",
1267 "Exit current mode and down to previous mode\n")
1268
paul68980082003-03-25 05:07:42 +00001269DEFUNSH (VTYSH_OSPF6D,
hassob094d262004-08-25 12:22:00 +00001270 vtysh_exit_ospf6d,
1271 vtysh_exit_ospf6d_cmd,
1272 "exit",
1273 "Exit current mode and down to previous mode\n")
paul68980082003-03-25 05:07:42 +00001274{
1275 return vtysh_exit (vty);
1276}
1277
1278ALIAS (vtysh_exit_ospf6d,
1279 vtysh_quit_ospf6d_cmd,
1280 "quit",
1281 "Exit current mode and down to previous mode\n")
1282
hassoc25e4582003-12-23 10:39:08 +00001283DEFUNSH (VTYSH_ISISD,
hassob094d262004-08-25 12:22:00 +00001284 vtysh_exit_isisd,
1285 vtysh_exit_isisd_cmd,
1286 "exit",
1287 "Exit current mode and down to previous mode\n")
hassoc25e4582003-12-23 10:39:08 +00001288{
1289 return vtysh_exit (vty);
1290}
1291
1292ALIAS (vtysh_exit_isisd,
1293 vtysh_quit_isisd_cmd,
1294 "quit",
1295 "Exit current mode and down to previous mode\n")
1296
hassoe7168df2004-10-03 20:11:32 +00001297DEFUNSH (VTYSH_ALL,
1298 vtysh_exit_line_vty,
1299 vtysh_exit_line_vty_cmd,
1300 "exit",
1301 "Exit current mode and down to previous mode\n")
1302{
1303 return vtysh_exit (vty);
1304}
1305
1306ALIAS (vtysh_exit_line_vty,
1307 vtysh_quit_line_vty_cmd,
1308 "quit",
1309 "Exit current mode and down to previous mode\n")
1310
hasso95e735b2004-08-26 13:08:30 +00001311DEFUNSH (VTYSH_INTERFACE,
paul718e3742002-12-13 20:15:29 +00001312 vtysh_interface,
1313 vtysh_interface_cmd,
1314 "interface IFNAME",
1315 "Select an interface to configure\n"
1316 "Interface's name\n")
1317{
1318 vty->node = INTERFACE_NODE;
1319 return CMD_SUCCESS;
1320}
1321
Feng Lu471ea392015-05-22 11:40:00 +02001322ALIAS_SH (VTYSH_ZEBRA,
1323 vtysh_interface,
1324 vtysh_interface_vrf_cmd,
1325 "interface IFNAME " VRF_CMD_STR,
1326 "Select an interface to configure\n"
1327 "Interface's name\n"
1328 VRF_CMD_HELP_STR)
1329
hasso95e735b2004-08-26 13:08:30 +00001330/* TODO Implement "no interface command in isisd. */
paul32d24632003-05-23 09:25:20 +00001331DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D,
1332 vtysh_no_interface_cmd,
1333 "no interface IFNAME",
1334 NO_STR
1335 "Delete a pseudo interface's configuration\n"
1336 "Interface's name\n")
1337
Feng Lu471ea392015-05-22 11:40:00 +02001338DEFSH (VTYSH_ZEBRA,
1339 vtysh_no_interface_vrf_cmd,
1340 "no interface IFNAME " VRF_CMD_STR,
1341 NO_STR
1342 "Delete a pseudo interface's configuration\n"
1343 "Interface's name\n"
1344 VRF_CMD_HELP_STR)
1345
hasso95e735b2004-08-26 13:08:30 +00001346/* TODO Implement interface description commands in ripngd, ospf6d
1347 * and isisd. */
paul338a9912003-03-01 15:44:10 +00001348DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD,
1349 interface_desc_cmd,
1350 "description .LINE",
1351 "Interface specific description\n"
1352 "Characters describing this interface\n")
paul464dc8d2003-03-28 02:25:45 +00001353
1354DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD,
1355 no_interface_desc_cmd,
1356 "no description",
1357 NO_STR
1358 "Interface specific description\n")
paul338a9912003-03-01 15:44:10 +00001359
hasso95e735b2004-08-26 13:08:30 +00001360DEFUNSH (VTYSH_INTERFACE,
paul718e3742002-12-13 20:15:29 +00001361 vtysh_exit_interface,
1362 vtysh_exit_interface_cmd,
1363 "exit",
1364 "Exit current mode and down to previous mode\n")
1365{
1366 return vtysh_exit (vty);
1367}
1368
1369ALIAS (vtysh_exit_interface,
1370 vtysh_quit_interface_cmd,
1371 "quit",
1372 "Exit current mode and down to previous mode\n")
1373
Donald Sharp567a6382015-08-19 21:22:17 -04001374DEFUN (vtysh_show_thread,
1375 vtysh_show_thread_cmd,
1376 "show thread cpu [FILTER]",
1377 SHOW_STR
1378 "Thread information\n"
1379 "Thread CPU usage\n"
1380 "Display filter (rwtexb)\n")
1381{
1382 unsigned int i;
1383 int ret = CMD_SUCCESS;
1384 char line[100];
1385
1386 sprintf(line, "show thread cpu %s\n", (argc == 1) ? argv[0] : "");
1387 for (i = 0; i < array_size(vtysh_client); i++)
1388 if ( vtysh_client[i].fd >= 0 )
1389 {
1390 fprintf (stdout, "Thread statistics for %s:\n",
1391 vtysh_client[i].name);
1392 ret = vtysh_client_execute (&vtysh_client[i], line, stdout);
1393 fprintf (stdout,"\n");
1394 }
1395 return ret;
1396}
1397
1398DEFUN (vtysh_show_work_queues,
1399 vtysh_show_work_queues_cmd,
1400 "show work-queues",
1401 SHOW_STR
1402 "Work Queue information\n")
1403{
1404 unsigned int i;
1405 int ret = CMD_SUCCESS;
1406 char line[] = "show work-queues\n";
1407
1408 for (i = 0; i < array_size(vtysh_client); i++)
1409 if ( vtysh_client[i].fd >= 0 )
1410 {
1411 fprintf (stdout, "Work queue statistics for %s:\n",
1412 vtysh_client[i].name);
1413 ret = vtysh_client_execute (&vtysh_client[i], line, stdout);
1414 fprintf (stdout,"\n");
1415 }
1416
1417 return ret;
1418}
1419
Donald Sharp07440402016-02-25 07:39:45 -05001420DEFUN (vtysh_show_work_queues_daemon,
1421 vtysh_show_work_queues_daemon_cmd,
1422 "show work-queues (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd)",
1423 SHOW_STR
1424 "Work Queue information\n"
1425 "For the zebra daemon\n"
1426 "For the rip daemon\n"
1427 "For the ripng daemon\n"
1428 "For the ospf daemon\n"
1429 "For the ospfv6 daemon\n"
1430 "For the bgp daemon\n"
1431 "For the isis daemon\n")
1432{
1433 unsigned int i;
1434 int ret = CMD_SUCCESS;
1435
1436 for (i = 0; i < array_size(vtysh_client); i++)
1437 {
1438 if (begins_with(vtysh_client[i].name, argv[0]))
1439 break;
1440 }
1441
1442 ret = vtysh_client_execute(&vtysh_client[i], "show work-queues\n", stdout);
1443
1444 return ret;
1445}
1446
Paul Jakma362b4032006-05-28 07:54:45 +00001447/* Memory */
1448DEFUN (vtysh_show_memory,
1449 vtysh_show_memory_cmd,
1450 "show memory",
1451 SHOW_STR
1452 "Memory statistics\n")
1453{
1454 unsigned int i;
1455 int ret = CMD_SUCCESS;
1456 char line[] = "show memory\n";
1457
Balaji.G837d16c2012-09-26 14:09:10 +05301458 for (i = 0; i < array_size(vtysh_client); i++)
Paul Jakma362b4032006-05-28 07:54:45 +00001459 if ( vtysh_client[i].fd >= 0 )
1460 {
1461 fprintf (stdout, "Memory statistics for %s:\n",
1462 vtysh_client[i].name);
1463 ret = vtysh_client_execute (&vtysh_client[i], line, stdout);
1464 fprintf (stdout,"\n");
1465 }
1466
1467 return ret;
1468}
1469
hasso95e735b2004-08-26 13:08:30 +00001470/* Logging commands. */
Paul Jakmadbf7d132006-05-23 22:10:01 +00001471DEFUN (vtysh_show_logging,
1472 vtysh_show_logging_cmd,
1473 "show logging",
1474 SHOW_STR
1475 "Show current logging configuration\n")
1476{
1477 unsigned int i;
1478 int ret = CMD_SUCCESS;
1479 char line[] = "show logging\n";
1480
Balaji.G837d16c2012-09-26 14:09:10 +05301481 for (i = 0; i < array_size(vtysh_client); i++)
Paul Jakma4150f332006-05-23 22:10:55 +00001482 if ( vtysh_client[i].fd >= 0 )
1483 {
1484 fprintf (stdout,"Logging configuration for %s:\n",
1485 vtysh_client[i].name);
1486 ret = vtysh_client_execute (&vtysh_client[i], line, stdout);
1487 fprintf (stdout,"\n");
1488 }
1489
Paul Jakmadbf7d132006-05-23 22:10:01 +00001490 return ret;
1491}
1492
hasso95e735b2004-08-26 13:08:30 +00001493DEFUNSH (VTYSH_ALL,
1494 vtysh_log_stdout,
1495 vtysh_log_stdout_cmd,
1496 "log stdout",
1497 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001498 "Set stdout logging level\n")
1499{
1500 return CMD_SUCCESS;
1501}
1502
1503DEFUNSH (VTYSH_ALL,
1504 vtysh_log_stdout_level,
1505 vtysh_log_stdout_level_cmd,
1506 "log stdout "LOG_LEVELS,
1507 "Logging control\n"
1508 "Set stdout logging level\n"
1509 LOG_LEVEL_DESC)
hasso95e735b2004-08-26 13:08:30 +00001510{
1511 return CMD_SUCCESS;
1512}
1513
1514DEFUNSH (VTYSH_ALL,
1515 no_vtysh_log_stdout,
1516 no_vtysh_log_stdout_cmd,
ajs274a4a42004-12-07 15:39:31 +00001517 "no log stdout [LEVEL]",
hasso95e735b2004-08-26 13:08:30 +00001518 NO_STR
1519 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001520 "Cancel logging to stdout\n"
1521 "Logging level\n")
hasso95e735b2004-08-26 13:08:30 +00001522{
1523 return CMD_SUCCESS;
1524}
1525
1526DEFUNSH (VTYSH_ALL,
1527 vtysh_log_file,
1528 vtysh_log_file_cmd,
1529 "log file FILENAME",
1530 "Logging control\n"
1531 "Logging to file\n"
1532 "Logging filename\n")
1533{
1534 return CMD_SUCCESS;
1535}
1536
1537DEFUNSH (VTYSH_ALL,
ajs274a4a42004-12-07 15:39:31 +00001538 vtysh_log_file_level,
1539 vtysh_log_file_level_cmd,
1540 "log file FILENAME "LOG_LEVELS,
1541 "Logging control\n"
1542 "Logging to file\n"
1543 "Logging filename\n"
1544 LOG_LEVEL_DESC)
1545{
1546 return CMD_SUCCESS;
1547}
1548
1549DEFUNSH (VTYSH_ALL,
hasso95e735b2004-08-26 13:08:30 +00001550 no_vtysh_log_file,
1551 no_vtysh_log_file_cmd,
1552 "no log file [FILENAME]",
1553 NO_STR
1554 "Logging control\n"
1555 "Cancel logging to file\n"
1556 "Logging file name\n")
1557{
1558 return CMD_SUCCESS;
1559}
1560
ajs274a4a42004-12-07 15:39:31 +00001561ALIAS_SH (VTYSH_ALL,
1562 no_vtysh_log_file,
1563 no_vtysh_log_file_level_cmd,
1564 "no log file FILENAME LEVEL",
1565 NO_STR
1566 "Logging control\n"
1567 "Cancel logging to file\n"
1568 "Logging file name\n"
1569 "Logging level\n")
1570
1571DEFUNSH (VTYSH_ALL,
1572 vtysh_log_monitor,
1573 vtysh_log_monitor_cmd,
1574 "log monitor",
1575 "Logging control\n"
1576 "Set terminal line (monitor) logging level\n")
1577{
1578 return CMD_SUCCESS;
1579}
1580
1581DEFUNSH (VTYSH_ALL,
1582 vtysh_log_monitor_level,
1583 vtysh_log_monitor_level_cmd,
1584 "log monitor "LOG_LEVELS,
1585 "Logging control\n"
1586 "Set terminal line (monitor) logging level\n"
1587 LOG_LEVEL_DESC)
1588{
1589 return CMD_SUCCESS;
1590}
1591
1592DEFUNSH (VTYSH_ALL,
1593 no_vtysh_log_monitor,
1594 no_vtysh_log_monitor_cmd,
1595 "no log monitor [LEVEL]",
1596 NO_STR
1597 "Logging control\n"
1598 "Disable terminal line (monitor) logging\n"
1599 "Logging level\n")
1600{
1601 return CMD_SUCCESS;
1602}
1603
hasso95e735b2004-08-26 13:08:30 +00001604DEFUNSH (VTYSH_ALL,
1605 vtysh_log_syslog,
1606 vtysh_log_syslog_cmd,
1607 "log syslog",
1608 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001609 "Set syslog logging level\n")
1610{
1611 return CMD_SUCCESS;
1612}
1613
1614DEFUNSH (VTYSH_ALL,
1615 vtysh_log_syslog_level,
1616 vtysh_log_syslog_level_cmd,
1617 "log syslog "LOG_LEVELS,
1618 "Logging control\n"
1619 "Set syslog logging level\n"
1620 LOG_LEVEL_DESC)
hasso95e735b2004-08-26 13:08:30 +00001621{
1622 return CMD_SUCCESS;
1623}
1624
1625DEFUNSH (VTYSH_ALL,
1626 no_vtysh_log_syslog,
1627 no_vtysh_log_syslog_cmd,
ajs274a4a42004-12-07 15:39:31 +00001628 "no log syslog [LEVEL]",
hasso95e735b2004-08-26 13:08:30 +00001629 NO_STR
1630 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001631 "Cancel logging to syslog\n"
1632 "Logging level\n")
hasso95e735b2004-08-26 13:08:30 +00001633{
1634 return CMD_SUCCESS;
1635}
1636
1637DEFUNSH (VTYSH_ALL,
ajs274a4a42004-12-07 15:39:31 +00001638 vtysh_log_facility,
1639 vtysh_log_facility_cmd,
1640 "log facility "LOG_FACILITIES,
hasso95e735b2004-08-26 13:08:30 +00001641 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001642 "Facility parameter for syslog messages\n"
1643 LOG_FACILITY_DESC)
1644
hasso95e735b2004-08-26 13:08:30 +00001645{
1646 return CMD_SUCCESS;
1647}
1648
1649DEFUNSH (VTYSH_ALL,
ajs274a4a42004-12-07 15:39:31 +00001650 no_vtysh_log_facility,
1651 no_vtysh_log_facility_cmd,
1652 "no log facility [FACILITY]",
hasso95e735b2004-08-26 13:08:30 +00001653 NO_STR
1654 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001655 "Reset syslog facility to default (daemon)\n"
1656 "Syslog facility\n")
1657
1658{
1659 return CMD_SUCCESS;
1660}
1661
1662DEFUNSH_DEPRECATED (VTYSH_ALL,
1663 vtysh_log_trap,
1664 vtysh_log_trap_cmd,
1665 "log trap "LOG_LEVELS,
1666 "Logging control\n"
1667 "(Deprecated) Set logging level and default for all destinations\n"
1668 LOG_LEVEL_DESC)
1669
1670{
1671 return CMD_SUCCESS;
1672}
1673
1674DEFUNSH_DEPRECATED (VTYSH_ALL,
1675 no_vtysh_log_trap,
1676 no_vtysh_log_trap_cmd,
1677 "no log trap [LEVEL]",
1678 NO_STR
1679 "Logging control\n"
1680 "Permit all logging information\n"
1681 "Logging level\n")
hasso95e735b2004-08-26 13:08:30 +00001682{
1683 return CMD_SUCCESS;
1684}
1685
1686DEFUNSH (VTYSH_ALL,
1687 vtysh_log_record_priority,
1688 vtysh_log_record_priority_cmd,
1689 "log record-priority",
1690 "Logging control\n"
1691 "Log the priority of the message within the message\n")
1692{
1693 return CMD_SUCCESS;
1694}
1695
1696DEFUNSH (VTYSH_ALL,
1697 no_vtysh_log_record_priority,
1698 no_vtysh_log_record_priority_cmd,
1699 "no log record-priority",
1700 NO_STR
1701 "Logging control\n"
1702 "Do not log the priority of the message within the message\n")
1703{
1704 return CMD_SUCCESS;
1705}
1706
hassoe7168df2004-10-03 20:11:32 +00001707DEFUNSH (VTYSH_ALL,
Andrew J. Schorrc749b722007-04-29 03:53:31 +00001708 vtysh_log_timestamp_precision,
1709 vtysh_log_timestamp_precision_cmd,
1710 "log timestamp precision <0-6>",
1711 "Logging control\n"
1712 "Timestamp configuration\n"
1713 "Set the timestamp precision\n"
1714 "Number of subsecond digits\n")
1715{
1716 return CMD_SUCCESS;
1717}
1718
1719DEFUNSH (VTYSH_ALL,
1720 no_vtysh_log_timestamp_precision,
1721 no_vtysh_log_timestamp_precision_cmd,
1722 "no log timestamp precision",
1723 NO_STR
1724 "Logging control\n"
1725 "Timestamp configuration\n"
1726 "Reset the timestamp precision to the default value of 0\n")
1727{
1728 return CMD_SUCCESS;
1729}
1730
1731DEFUNSH (VTYSH_ALL,
hassoe7168df2004-10-03 20:11:32 +00001732 vtysh_service_password_encrypt,
1733 vtysh_service_password_encrypt_cmd,
1734 "service password-encryption",
1735 "Set up miscellaneous service\n"
1736 "Enable encrypted passwords\n")
1737{
1738 return CMD_SUCCESS;
1739}
1740
1741DEFUNSH (VTYSH_ALL,
1742 no_vtysh_service_password_encrypt,
1743 no_vtysh_service_password_encrypt_cmd,
1744 "no service password-encryption",
1745 NO_STR
1746 "Set up miscellaneous service\n"
1747 "Enable encrypted passwords\n")
1748{
1749 return CMD_SUCCESS;
1750}
1751
1752DEFUNSH (VTYSH_ALL,
1753 vtysh_config_password,
1754 vtysh_password_cmd,
1755 "password (8|) WORD",
1756 "Assign the terminal connection password\n"
1757 "Specifies a HIDDEN password will follow\n"
1758 "dummy string \n"
1759 "The HIDDEN line password string\n")
1760{
1761 return CMD_SUCCESS;
1762}
1763
1764DEFUNSH (VTYSH_ALL,
1765 vtysh_password_text,
1766 vtysh_password_text_cmd,
1767 "password LINE",
1768 "Assign the terminal connection password\n"
1769 "The UNENCRYPTED (cleartext) line password\n")
1770{
1771 return CMD_SUCCESS;
1772}
1773
1774DEFUNSH (VTYSH_ALL,
1775 vtysh_config_enable_password,
1776 vtysh_enable_password_cmd,
1777 "enable password (8|) WORD",
1778 "Modify enable password parameters\n"
1779 "Assign the privileged level password\n"
1780 "Specifies a HIDDEN password will follow\n"
1781 "dummy string \n"
1782 "The HIDDEN 'enable' password string\n")
1783{
1784 return CMD_SUCCESS;
1785}
1786
1787DEFUNSH (VTYSH_ALL,
1788 vtysh_enable_password_text,
1789 vtysh_enable_password_text_cmd,
1790 "enable password LINE",
1791 "Modify enable password parameters\n"
1792 "Assign the privileged level password\n"
1793 "The UNENCRYPTED (cleartext) 'enable' password\n")
1794{
1795 return CMD_SUCCESS;
1796}
1797
1798DEFUNSH (VTYSH_ALL,
1799 no_vtysh_config_enable_password,
1800 no_vtysh_enable_password_cmd,
1801 "no enable password",
1802 NO_STR
1803 "Modify enable password parameters\n"
1804 "Assign the privileged level password\n")
1805{
1806 return CMD_SUCCESS;
1807}
1808
paul718e3742002-12-13 20:15:29 +00001809DEFUN (vtysh_write_terminal,
1810 vtysh_write_terminal_cmd,
1811 "write terminal",
1812 "Write running configuration to memory, network, or terminal\n"
1813 "Write to terminal\n")
1814{
ajsb1aa1472005-01-28 21:11:46 +00001815 u_int i;
paul718e3742002-12-13 20:15:29 +00001816 char line[] = "write terminal\n";
1817 FILE *fp = NULL;
1818
1819 if (vtysh_pager_name)
1820 {
paul4fc01e62002-12-13 20:49:00 +00001821 fp = popen (vtysh_pager_name, "w");
paul718e3742002-12-13 20:15:29 +00001822 if (fp == NULL)
1823 {
1824 perror ("popen");
1825 exit (1);
1826 }
1827 }
1828 else
1829 fp = stdout;
1830
1831 vty_out (vty, "Building configuration...%s", VTY_NEWLINE);
1832 vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE,
1833 VTY_NEWLINE);
hassoe7168df2004-10-03 20:11:32 +00001834 vty_out (vty, "!%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001835
Balaji.G837d16c2012-09-26 14:09:10 +05301836 for (i = 0; i < array_size(vtysh_client); i++)
Gautam Kumarcc216b72015-10-26 13:22:12 -07001837 vtysh_client_execute (&vtysh_client[i], line, NULL);
paul718e3742002-12-13 20:15:29 +00001838
hassoe7168df2004-10-03 20:11:32 +00001839 /* Integrate vtysh specific configuration. */
1840 vtysh_config_write ();
1841
paul718e3742002-12-13 20:15:29 +00001842 vtysh_config_dump (fp);
1843
1844 if (vtysh_pager_name && fp)
1845 {
1846 fflush (fp);
1847 if (pclose (fp) == -1)
1848 {
1849 perror ("pclose");
1850 exit (1);
1851 }
1852 fp = NULL;
1853 }
1854
Chris Caputo6e79f8b2009-06-23 05:55:57 +00001855 vty_out (vty, "end%s", VTY_NEWLINE);
1856
paul718e3742002-12-13 20:15:29 +00001857 return CMD_SUCCESS;
1858}
1859
Donald Sharp9fb73e82015-09-22 11:13:12 -04001860DEFUN (vtysh_write_terminal_daemon,
1861 vtysh_write_terminal_daemon_cmd,
1862 "write terminal (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|babeld)",
1863 "Write running configuration to memory, network, or terminal\n"
1864 "Write to terminal\n"
1865 "For the zebra daemon\n"
1866 "For the rip daemon\n"
1867 "For the ripng daemon\n"
1868 "For the ospf daemon\n"
1869 "For the ospfv6 daemon\n"
1870 "For the bgp daemon\n"
1871 "For the isis daemon\n"
1872 "For the babel daemon\n")
1873{
1874 unsigned int i;
1875 int ret = CMD_SUCCESS;
1876
1877 for (i = 0; i < array_size(vtysh_client); i++)
1878 {
1879 if (strcmp(vtysh_client[i].name, argv[0]) == 0)
1880 break;
1881 }
1882
1883 ret = vtysh_client_execute(&vtysh_client[i], "show running-config\n", stdout);
1884
1885 return ret;
1886}
1887
hassoe7168df2004-10-03 20:11:32 +00001888DEFUN (vtysh_integrated_config,
1889 vtysh_integrated_config_cmd,
1890 "service integrated-vtysh-config",
1891 "Set up miscellaneous service\n"
1892 "Write configuration into integrated file\n")
paul4fc01e62002-12-13 20:49:00 +00001893{
hassoe7168df2004-10-03 20:11:32 +00001894 vtysh_writeconfig_integrated = 1;
1895 return CMD_SUCCESS;
paul4fc01e62002-12-13 20:49:00 +00001896}
1897
hassoe7168df2004-10-03 20:11:32 +00001898DEFUN (no_vtysh_integrated_config,
1899 no_vtysh_integrated_config_cmd,
1900 "no service integrated-vtysh-config",
1901 NO_STR
1902 "Set up miscellaneous service\n"
1903 "Write configuration into integrated file\n")
paul4fc01e62002-12-13 20:49:00 +00001904{
hassoe7168df2004-10-03 20:11:32 +00001905 vtysh_writeconfig_integrated = 0;
1906 return CMD_SUCCESS;
paul4fc01e62002-12-13 20:49:00 +00001907}
1908
ajs274a4a42004-12-07 15:39:31 +00001909static int
1910write_config_integrated(void)
paul718e3742002-12-13 20:15:29 +00001911{
ajsb1aa1472005-01-28 21:11:46 +00001912 u_int i;
paul718e3742002-12-13 20:15:29 +00001913 char line[] = "write terminal\n";
1914 FILE *fp;
1915 char *integrate_sav = NULL;
1916
hasso95e735b2004-08-26 13:08:30 +00001917 integrate_sav = malloc (strlen (integrate_default) +
1918 strlen (CONF_BACKUP_EXT) + 1);
paul718e3742002-12-13 20:15:29 +00001919 strcpy (integrate_sav, integrate_default);
1920 strcat (integrate_sav, CONF_BACKUP_EXT);
1921
paul4fc01e62002-12-13 20:49:00 +00001922 fprintf (stdout,"Building Configuration...\n");
paul718e3742002-12-13 20:15:29 +00001923
hasso95e735b2004-08-26 13:08:30 +00001924 /* Move current configuration file to backup config file. */
paul718e3742002-12-13 20:15:29 +00001925 unlink (integrate_sav);
1926 rename (integrate_default, integrate_sav);
hasso95e735b2004-08-26 13:08:30 +00001927 free (integrate_sav);
paul4fc01e62002-12-13 20:49:00 +00001928
paul718e3742002-12-13 20:15:29 +00001929 fp = fopen (integrate_default, "w");
1930 if (fp == NULL)
1931 {
hasso95e735b2004-08-26 13:08:30 +00001932 fprintf (stdout,"%% Can't open configuration file %s.\n",
1933 integrate_default);
paul718e3742002-12-13 20:15:29 +00001934 return CMD_SUCCESS;
1935 }
paul718e3742002-12-13 20:15:29 +00001936
Balaji.G837d16c2012-09-26 14:09:10 +05301937 for (i = 0; i < array_size(vtysh_client); i++)
Gautam Kumarcc216b72015-10-26 13:22:12 -07001938 vtysh_client_execute (&vtysh_client[i], line, NULL);
paul718e3742002-12-13 20:15:29 +00001939
1940 vtysh_config_dump (fp);
1941
1942 fclose (fp);
1943
gdtaa593d52003-12-22 20:15:53 +00001944 if (chmod (integrate_default, CONFIGFILE_MASK) != 0)
1945 {
1946 fprintf (stdout,"%% Can't chmod configuration file %s: %s (%d)\n",
ajs6099b3b2004-11-20 02:06:59 +00001947 integrate_default, safe_strerror(errno), errno);
gdtaa593d52003-12-22 20:15:53 +00001948 return CMD_WARNING;
1949 }
1950
paul4fc01e62002-12-13 20:49:00 +00001951 fprintf(stdout,"Integrated configuration saved to %s\n",integrate_default);
1952
1953 fprintf (stdout,"[OK]\n");
1954
paul718e3742002-12-13 20:15:29 +00001955 return CMD_SUCCESS;
1956}
1957
paul4fc01e62002-12-13 20:49:00 +00001958DEFUN (vtysh_write_memory,
1959 vtysh_write_memory_cmd,
1960 "write memory",
1961 "Write running configuration to memory, network, or terminal\n"
1962 "Write configuration to the file (same as write file)\n")
1963{
pauldfc0d9b2003-04-18 23:55:29 +00001964 int ret = CMD_SUCCESS;
paul4fc01e62002-12-13 20:49:00 +00001965 char line[] = "write memory\n";
ajsb1aa1472005-01-28 21:11:46 +00001966 u_int i;
paul4fc01e62002-12-13 20:49:00 +00001967
hassoe7168df2004-10-03 20:11:32 +00001968 /* If integrated Quagga.conf explicitely set. */
1969 if (vtysh_writeconfig_integrated)
1970 return write_config_integrated();
paul4fc01e62002-12-13 20:49:00 +00001971
1972 fprintf (stdout,"Building Configuration...\n");
1973
Balaji.G837d16c2012-09-26 14:09:10 +05301974 for (i = 0; i < array_size(vtysh_client); i++)
ajsb1aa1472005-01-28 21:11:46 +00001975 ret = vtysh_client_execute (&vtysh_client[i], line, stdout);
hassoe7168df2004-10-03 20:11:32 +00001976
paul4fc01e62002-12-13 20:49:00 +00001977 fprintf (stdout,"[OK]\n");
1978
pauldfc0d9b2003-04-18 23:55:29 +00001979 return ret;
paul4fc01e62002-12-13 20:49:00 +00001980}
1981
paul718e3742002-12-13 20:15:29 +00001982ALIAS (vtysh_write_memory,
1983 vtysh_copy_runningconfig_startupconfig_cmd,
1984 "copy running-config startup-config",
1985 "Copy from one file to another\n"
1986 "Copy from current system configuration\n"
1987 "Copy to startup configuration\n")
1988
1989ALIAS (vtysh_write_memory,
1990 vtysh_write_file_cmd,
1991 "write file",
1992 "Write running configuration to memory, network, or terminal\n"
1993 "Write configuration to the file (same as write memory)\n")
1994
hasso4a6e2252003-05-25 11:51:29 +00001995ALIAS (vtysh_write_memory,
1996 vtysh_write_cmd,
1997 "write",
1998 "Write running configuration to memory, network, or terminal\n")
1999
paul718e3742002-12-13 20:15:29 +00002000ALIAS (vtysh_write_terminal,
2001 vtysh_show_running_config_cmd,
2002 "show running-config",
2003 SHOW_STR
2004 "Current operating configuration\n")
hassob094d262004-08-25 12:22:00 +00002005
Donald Sharp9fb73e82015-09-22 11:13:12 -04002006ALIAS (vtysh_write_terminal_daemon,
2007 vtysh_show_running_config_daemon_cmd,
2008 "show running-config (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|babeld)",
2009 SHOW_STR
2010 "Current operating configuration\n"
2011 "For the zebra daemon\n"
2012 "For the rip daemon\n"
2013 "For the ripng daemon\n"
2014 "For the ospf daemon\n"
2015 "For the ospfv6 daemon\n"
2016 "For the bgp daemon\n"
2017 "For the isis daemon\n"
2018 "For the babel daemon\n")
2019
hasso34553cc2004-08-27 13:56:39 +00002020DEFUN (vtysh_terminal_length,
2021 vtysh_terminal_length_cmd,
2022 "terminal length <0-512>",
2023 "Set terminal line parameters\n"
2024 "Set number of lines on a screen\n"
2025 "Number of lines on screen (0 for no pausing)\n")
2026{
2027 int lines;
2028 char *endptr = NULL;
2029 char default_pager[10];
2030
2031 lines = strtol (argv[0], &endptr, 10);
2032 if (lines < 0 || lines > 512 || *endptr != '\0')
2033 {
2034 vty_out (vty, "length is malformed%s", VTY_NEWLINE);
2035 return CMD_WARNING;
2036 }
2037
2038 if (vtysh_pager_name)
2039 {
2040 free (vtysh_pager_name);
2041 vtysh_pager_name = NULL;
2042 }
2043
2044 if (lines != 0)
2045 {
2046 snprintf(default_pager, 10, "more -%i", lines);
2047 vtysh_pager_name = strdup (default_pager);
2048 }
2049
2050 return CMD_SUCCESS;
2051}
2052
2053DEFUN (vtysh_terminal_no_length,
2054 vtysh_terminal_no_length_cmd,
2055 "terminal no length",
2056 "Set terminal line parameters\n"
2057 NO_STR
2058 "Set number of lines on a screen\n")
2059{
2060 if (vtysh_pager_name)
2061 {
2062 free (vtysh_pager_name);
2063 vtysh_pager_name = NULL;
2064 }
2065
2066 vtysh_pager_init();
2067 return CMD_SUCCESS;
2068}
2069
hassof2799e62004-10-28 17:43:11 +00002070DEFUN (vtysh_show_daemons,
2071 vtysh_show_daemons_cmd,
2072 "show daemons",
hassoe7168df2004-10-03 20:11:32 +00002073 SHOW_STR
2074 "Show list of running daemons\n")
2075{
ajsb1aa1472005-01-28 21:11:46 +00002076 u_int i;
2077
Balaji.G837d16c2012-09-26 14:09:10 +05302078 for (i = 0; i < array_size(vtysh_client); i++)
ajsb1aa1472005-01-28 21:11:46 +00002079 if ( vtysh_client[i].fd >= 0 )
2080 vty_out(vty, " %s", vtysh_client[i].name);
hassoe7168df2004-10-03 20:11:32 +00002081 vty_out(vty, "%s", VTY_NEWLINE);
2082
2083 return CMD_SUCCESS;
2084}
2085
paul718e3742002-12-13 20:15:29 +00002086/* Execute command in child process. */
ajs274a4a42004-12-07 15:39:31 +00002087static int
hasso5862ff52004-10-11 13:20:40 +00002088execute_command (const char *command, int argc, const char *arg1,
2089 const char *arg2)
paul718e3742002-12-13 20:15:29 +00002090{
paul718e3742002-12-13 20:15:29 +00002091 pid_t pid;
2092 int status;
2093
2094 /* Call fork(). */
2095 pid = fork ();
2096
2097 if (pid < 0)
2098 {
2099 /* Failure of fork(). */
ajs6099b3b2004-11-20 02:06:59 +00002100 fprintf (stderr, "Can't fork: %s\n", safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +00002101 exit (1);
2102 }
2103 else if (pid == 0)
2104 {
2105 /* This is child process. */
2106 switch (argc)
2107 {
2108 case 0:
David Lamparter6769f432015-03-04 07:18:24 +01002109 execlp (command, command, (const char *)NULL);
paul718e3742002-12-13 20:15:29 +00002110 break;
2111 case 1:
David Lamparter6769f432015-03-04 07:18:24 +01002112 execlp (command, command, arg1, (const char *)NULL);
paul718e3742002-12-13 20:15:29 +00002113 break;
2114 case 2:
David Lamparter6769f432015-03-04 07:18:24 +01002115 execlp (command, command, arg1, arg2, (const char *)NULL);
paul718e3742002-12-13 20:15:29 +00002116 break;
2117 }
2118
2119 /* When execlp suceed, this part is not executed. */
ajs6099b3b2004-11-20 02:06:59 +00002120 fprintf (stderr, "Can't execute %s: %s\n", command, safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +00002121 exit (1);
2122 }
2123 else
2124 {
2125 /* This is parent. */
2126 execute_flag = 1;
David Lamparter6769f432015-03-04 07:18:24 +01002127 wait4 (pid, &status, 0, NULL);
paul718e3742002-12-13 20:15:29 +00002128 execute_flag = 0;
2129 }
2130 return 0;
2131}
2132
2133DEFUN (vtysh_ping,
2134 vtysh_ping_cmd,
2135 "ping WORD",
hasso4eeccf12003-06-25 10:49:55 +00002136 "Send echo messages\n"
paul718e3742002-12-13 20:15:29 +00002137 "Ping destination address or hostname\n")
2138{
2139 execute_command ("ping", 1, argv[0], NULL);
2140 return CMD_SUCCESS;
2141}
2142
hasso4eeccf12003-06-25 10:49:55 +00002143ALIAS (vtysh_ping,
2144 vtysh_ping_ip_cmd,
2145 "ping ip WORD",
2146 "Send echo messages\n"
2147 "IP echo\n"
2148 "Ping destination address or hostname\n")
2149
paul718e3742002-12-13 20:15:29 +00002150DEFUN (vtysh_traceroute,
2151 vtysh_traceroute_cmd,
2152 "traceroute WORD",
2153 "Trace route to destination\n"
2154 "Trace route to destination address or hostname\n")
2155{
2156 execute_command ("traceroute", 1, argv[0], NULL);
2157 return CMD_SUCCESS;
2158}
2159
hasso4eeccf12003-06-25 10:49:55 +00002160ALIAS (vtysh_traceroute,
2161 vtysh_traceroute_ip_cmd,
2162 "traceroute ip WORD",
2163 "Trace route to destination\n"
2164 "IP trace\n"
2165 "Trace route to destination address or hostname\n")
2166
2167#ifdef HAVE_IPV6
2168DEFUN (vtysh_ping6,
2169 vtysh_ping6_cmd,
2170 "ping ipv6 WORD",
2171 "Send echo messages\n"
2172 "IPv6 echo\n"
2173 "Ping destination address or hostname\n")
2174{
2175 execute_command ("ping6", 1, argv[0], NULL);
2176 return CMD_SUCCESS;
2177}
2178
2179DEFUN (vtysh_traceroute6,
2180 vtysh_traceroute6_cmd,
2181 "traceroute ipv6 WORD",
2182 "Trace route to destination\n"
2183 "IPv6 trace\n"
2184 "Trace route to destination address or hostname\n")
2185{
2186 execute_command ("traceroute6", 1, argv[0], NULL);
2187 return CMD_SUCCESS;
2188}
2189#endif
2190
paul718e3742002-12-13 20:15:29 +00002191DEFUN (vtysh_telnet,
2192 vtysh_telnet_cmd,
2193 "telnet WORD",
2194 "Open a telnet connection\n"
2195 "IP address or hostname of a remote system\n")
2196{
2197 execute_command ("telnet", 1, argv[0], NULL);
2198 return CMD_SUCCESS;
2199}
2200
2201DEFUN (vtysh_telnet_port,
2202 vtysh_telnet_port_cmd,
2203 "telnet WORD PORT",
2204 "Open a telnet connection\n"
2205 "IP address or hostname of a remote system\n"
2206 "TCP Port number\n")
2207{
2208 execute_command ("telnet", 2, argv[0], argv[1]);
2209 return CMD_SUCCESS;
2210}
2211
paul5087df52003-01-25 06:56:09 +00002212DEFUN (vtysh_ssh,
2213 vtysh_ssh_cmd,
2214 "ssh WORD",
2215 "Open an ssh connection\n"
2216 "[user@]host\n")
2217{
2218 execute_command ("ssh", 1, argv[0], NULL);
2219 return CMD_SUCCESS;
2220}
2221
paul718e3742002-12-13 20:15:29 +00002222DEFUN (vtysh_start_shell,
2223 vtysh_start_shell_cmd,
2224 "start-shell",
2225 "Start UNIX shell\n")
2226{
2227 execute_command ("sh", 0, NULL, NULL);
2228 return CMD_SUCCESS;
2229}
2230
2231DEFUN (vtysh_start_bash,
2232 vtysh_start_bash_cmd,
2233 "start-shell bash",
2234 "Start UNIX shell\n"
2235 "Start bash\n")
2236{
2237 execute_command ("bash", 0, NULL, NULL);
2238 return CMD_SUCCESS;
2239}
2240
2241DEFUN (vtysh_start_zsh,
2242 vtysh_start_zsh_cmd,
2243 "start-shell zsh",
2244 "Start UNIX shell\n"
2245 "Start Z shell\n")
2246{
2247 execute_command ("zsh", 0, NULL, NULL);
2248 return CMD_SUCCESS;
2249}
hassob094d262004-08-25 12:22:00 +00002250
ajs274a4a42004-12-07 15:39:31 +00002251static void
paul718e3742002-12-13 20:15:29 +00002252vtysh_install_default (enum node_type node)
2253{
2254 install_element (node, &config_list_cmd);
2255}
2256
2257/* Making connection to protocol daemon. */
ajs274a4a42004-12-07 15:39:31 +00002258static int
ajsb1aa1472005-01-28 21:11:46 +00002259vtysh_connect (struct vtysh_client *vclient)
paul718e3742002-12-13 20:15:29 +00002260{
2261 int ret;
2262 int sock, len;
2263 struct sockaddr_un addr;
2264 struct stat s_stat;
paul718e3742002-12-13 20:15:29 +00002265
paul718e3742002-12-13 20:15:29 +00002266 /* Stat socket to see if we have permission to access it. */
ajsb1aa1472005-01-28 21:11:46 +00002267 ret = stat (vclient->path, &s_stat);
paul718e3742002-12-13 20:15:29 +00002268 if (ret < 0 && errno != ENOENT)
2269 {
2270 fprintf (stderr, "vtysh_connect(%s): stat = %s\n",
ajsb1aa1472005-01-28 21:11:46 +00002271 vclient->path, safe_strerror(errno));
paul718e3742002-12-13 20:15:29 +00002272 exit(1);
2273 }
2274
2275 if (ret >= 0)
2276 {
2277 if (! S_ISSOCK(s_stat.st_mode))
2278 {
2279 fprintf (stderr, "vtysh_connect(%s): Not a socket\n",
ajsb1aa1472005-01-28 21:11:46 +00002280 vclient->path);
paul718e3742002-12-13 20:15:29 +00002281 exit (1);
2282 }
2283
paul718e3742002-12-13 20:15:29 +00002284 }
2285
2286 sock = socket (AF_UNIX, SOCK_STREAM, 0);
2287 if (sock < 0)
2288 {
2289#ifdef DEBUG
ajsb1aa1472005-01-28 21:11:46 +00002290 fprintf(stderr, "vtysh_connect(%s): socket = %s\n", vclient->path,
ajs6099b3b2004-11-20 02:06:59 +00002291 safe_strerror(errno));
paul718e3742002-12-13 20:15:29 +00002292#endif /* DEBUG */
2293 return -1;
2294 }
2295
2296 memset (&addr, 0, sizeof (struct sockaddr_un));
2297 addr.sun_family = AF_UNIX;
ajsb1aa1472005-01-28 21:11:46 +00002298 strncpy (addr.sun_path, vclient->path, strlen (vclient->path));
Paul Jakma6f0e3f62007-05-10 02:38:51 +00002299#ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
paul718e3742002-12-13 20:15:29 +00002300 len = addr.sun_len = SUN_LEN(&addr);
2301#else
2302 len = sizeof (addr.sun_family) + strlen (addr.sun_path);
Paul Jakma6f0e3f62007-05-10 02:38:51 +00002303#endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
paul718e3742002-12-13 20:15:29 +00002304
2305 ret = connect (sock, (struct sockaddr *) &addr, len);
2306 if (ret < 0)
2307 {
2308#ifdef DEBUG
ajsb1aa1472005-01-28 21:11:46 +00002309 fprintf(stderr, "vtysh_connect(%s): connect = %s\n", vclient->path,
ajs6099b3b2004-11-20 02:06:59 +00002310 safe_strerror(errno));
paul718e3742002-12-13 20:15:29 +00002311#endif /* DEBUG */
2312 close (sock);
2313 return -1;
2314 }
2315 vclient->fd = sock;
2316
2317 return 0;
2318}
2319
Andrew J. Schorrf366ad32006-07-27 18:01:41 +00002320int
2321vtysh_connect_all(const char *daemon_name)
paul718e3742002-12-13 20:15:29 +00002322{
ajsb1aa1472005-01-28 21:11:46 +00002323 u_int i;
Andrew J. Schorrf366ad32006-07-27 18:01:41 +00002324 int rc = 0;
2325 int matches = 0;
ajsb1aa1472005-01-28 21:11:46 +00002326
Balaji.G837d16c2012-09-26 14:09:10 +05302327 for (i = 0; i < array_size(vtysh_client); i++)
ajsb1aa1472005-01-28 21:11:46 +00002328 {
Andrew J. Schorrf366ad32006-07-27 18:01:41 +00002329 if (!daemon_name || !strcmp(daemon_name, vtysh_client[i].name))
2330 {
2331 matches++;
2332 if (vtysh_connect(&vtysh_client[i]) == 0)
2333 rc++;
2334 /* We need direct access to ripd in vtysh_exit_ripd_only. */
2335 if (vtysh_client[i].flag == VTYSH_RIPD)
2336 ripd_client = &vtysh_client[i];
2337 }
ajsb1aa1472005-01-28 21:11:46 +00002338 }
Andrew J. Schorrf366ad32006-07-27 18:01:41 +00002339 if (!matches)
2340 fprintf(stderr, "Error: no daemons match name %s!\n", daemon_name);
2341 return rc;
paul718e3742002-12-13 20:15:29 +00002342}
2343
hasso95e735b2004-08-26 13:08:30 +00002344/* To disable readline's filename completion. */
ajs274a4a42004-12-07 15:39:31 +00002345static char *
pauldfc0d9b2003-04-18 23:55:29 +00002346vtysh_completion_entry_function (const char *ignore, int invoking_key)
paul718e3742002-12-13 20:15:29 +00002347{
pauldfc0d9b2003-04-18 23:55:29 +00002348 return NULL;
paul718e3742002-12-13 20:15:29 +00002349}
2350
2351void
ajsb1aa1472005-01-28 21:11:46 +00002352vtysh_readline_init (void)
paul718e3742002-12-13 20:15:29 +00002353{
2354 /* readline related settings. */
Sébastien Luttringer66d2ead2014-05-27 19:55:11 +02002355 rl_bind_key ('?', (rl_command_func_t *) vtysh_rl_describe);
paul68980082003-03-25 05:07:42 +00002356 rl_completion_entry_function = vtysh_completion_entry_function;
Sébastien Luttringer66d2ead2014-05-27 19:55:11 +02002357 rl_attempted_completion_function = (rl_completion_func_t *)new_completion;
paul718e3742002-12-13 20:15:29 +00002358}
2359
2360char *
ajsb1aa1472005-01-28 21:11:46 +00002361vtysh_prompt (void)
paul718e3742002-12-13 20:15:29 +00002362{
Andrew J. Schorrf366ad32006-07-27 18:01:41 +00002363 static struct utsname names;
paul718e3742002-12-13 20:15:29 +00002364 static char buf[100];
2365 const char*hostname;
2366 extern struct host host;
2367
2368 hostname = host.name;
2369
2370 if (!hostname)
2371 {
Andrew J. Schorrf366ad32006-07-27 18:01:41 +00002372 if (!names.nodename[0])
2373 uname (&names);
paul718e3742002-12-13 20:15:29 +00002374 hostname = names.nodename;
2375 }
2376
2377 snprintf (buf, sizeof buf, cmd_prompt (vty->node), hostname);
2378
2379 return buf;
2380}
2381
2382void
ajsb1aa1472005-01-28 21:11:46 +00002383vtysh_init_vty (void)
paul718e3742002-12-13 20:15:29 +00002384{
2385 /* Make vty structure. */
2386 vty = vty_new ();
2387 vty->type = VTY_SHELL;
2388 vty->node = VIEW_NODE;
2389
2390 /* Initialize commands. */
2391 cmd_init (0);
2392
2393 /* Install nodes. */
2394 install_node (&bgp_node, NULL);
2395 install_node (&rip_node, NULL);
2396 install_node (&interface_node, NULL);
2397 install_node (&rmap_node, NULL);
2398 install_node (&zebra_node, NULL);
2399 install_node (&bgp_vpnv4_node, NULL);
Lou Berger13c378d2016-01-12 13:41:56 -05002400 install_node (&bgp_vpnv6_node, NULL);
Lou Bergera3fda882016-01-12 13:42:04 -05002401 install_node (&bgp_encap_node, NULL);
2402 install_node (&bgp_encapv6_node, NULL);
paul718e3742002-12-13 20:15:29 +00002403 install_node (&bgp_ipv4_node, NULL);
2404 install_node (&bgp_ipv4m_node, NULL);
2405/* #ifdef HAVE_IPV6 */
2406 install_node (&bgp_ipv6_node, NULL);
paul57b5b7e2005-08-22 22:44:29 +00002407 install_node (&bgp_ipv6m_node, NULL);
paul718e3742002-12-13 20:15:29 +00002408/* #endif */
2409 install_node (&ospf_node, NULL);
2410/* #ifdef HAVE_IPV6 */
2411 install_node (&ripng_node, NULL);
2412 install_node (&ospf6_node, NULL);
2413/* #endif */
David Lamparteree53c8b2015-05-23 05:45:59 +02002414 install_node (&babel_node, NULL);
paul718e3742002-12-13 20:15:29 +00002415 install_node (&keychain_node, NULL);
2416 install_node (&keychain_key_node, NULL);
hassoc25e4582003-12-23 10:39:08 +00002417 install_node (&isis_node, NULL);
hassoe7168df2004-10-03 20:11:32 +00002418 install_node (&vty_node, NULL);
paul718e3742002-12-13 20:15:29 +00002419
2420 vtysh_install_default (VIEW_NODE);
2421 vtysh_install_default (ENABLE_NODE);
2422 vtysh_install_default (CONFIG_NODE);
2423 vtysh_install_default (BGP_NODE);
2424 vtysh_install_default (RIP_NODE);
2425 vtysh_install_default (INTERFACE_NODE);
2426 vtysh_install_default (RMAP_NODE);
2427 vtysh_install_default (ZEBRA_NODE);
2428 vtysh_install_default (BGP_VPNV4_NODE);
Lou Berger13c378d2016-01-12 13:41:56 -05002429 vtysh_install_default (BGP_VPNV6_NODE);
Lou Bergera3fda882016-01-12 13:42:04 -05002430 vtysh_install_default (BGP_ENCAP_NODE);
2431 vtysh_install_default (BGP_ENCAPV6_NODE);
paul718e3742002-12-13 20:15:29 +00002432 vtysh_install_default (BGP_IPV4_NODE);
2433 vtysh_install_default (BGP_IPV4M_NODE);
2434 vtysh_install_default (BGP_IPV6_NODE);
paul57b5b7e2005-08-22 22:44:29 +00002435 vtysh_install_default (BGP_IPV6M_NODE);
paul718e3742002-12-13 20:15:29 +00002436 vtysh_install_default (OSPF_NODE);
2437 vtysh_install_default (RIPNG_NODE);
2438 vtysh_install_default (OSPF6_NODE);
Juliusz Chroboczekfeb6c532012-02-07 04:58:49 +01002439 vtysh_install_default (BABEL_NODE);
hassoc25e4582003-12-23 10:39:08 +00002440 vtysh_install_default (ISIS_NODE);
paul718e3742002-12-13 20:15:29 +00002441 vtysh_install_default (KEYCHAIN_NODE);
2442 vtysh_install_default (KEYCHAIN_KEY_NODE);
hassoe7168df2004-10-03 20:11:32 +00002443 vtysh_install_default (VTY_NODE);
paul718e3742002-12-13 20:15:29 +00002444
2445 install_element (VIEW_NODE, &vtysh_enable_cmd);
2446 install_element (ENABLE_NODE, &vtysh_config_terminal_cmd);
2447 install_element (ENABLE_NODE, &vtysh_disable_cmd);
2448
2449 /* "exit" command. */
2450 install_element (VIEW_NODE, &vtysh_exit_all_cmd);
2451 install_element (VIEW_NODE, &vtysh_quit_all_cmd);
2452 install_element (CONFIG_NODE, &vtysh_exit_all_cmd);
2453 /* install_element (CONFIG_NODE, &vtysh_quit_all_cmd); */
2454 install_element (ENABLE_NODE, &vtysh_exit_all_cmd);
2455 install_element (ENABLE_NODE, &vtysh_quit_all_cmd);
2456 install_element (RIP_NODE, &vtysh_exit_ripd_cmd);
2457 install_element (RIP_NODE, &vtysh_quit_ripd_cmd);
paul68980082003-03-25 05:07:42 +00002458 install_element (RIPNG_NODE, &vtysh_exit_ripngd_cmd);
2459 install_element (RIPNG_NODE, &vtysh_quit_ripngd_cmd);
paul718e3742002-12-13 20:15:29 +00002460 install_element (OSPF_NODE, &vtysh_exit_ospfd_cmd);
2461 install_element (OSPF_NODE, &vtysh_quit_ospfd_cmd);
paul68980082003-03-25 05:07:42 +00002462 install_element (OSPF6_NODE, &vtysh_exit_ospf6d_cmd);
2463 install_element (OSPF6_NODE, &vtysh_quit_ospf6d_cmd);
paul718e3742002-12-13 20:15:29 +00002464 install_element (BGP_NODE, &vtysh_exit_bgpd_cmd);
2465 install_element (BGP_NODE, &vtysh_quit_bgpd_cmd);
2466 install_element (BGP_VPNV4_NODE, &vtysh_exit_bgpd_cmd);
2467 install_element (BGP_VPNV4_NODE, &vtysh_quit_bgpd_cmd);
Lou Berger13c378d2016-01-12 13:41:56 -05002468 install_element (BGP_VPNV6_NODE, &vtysh_exit_bgpd_cmd);
2469 install_element (BGP_VPNV6_NODE, &vtysh_quit_bgpd_cmd);
Lou Bergera3fda882016-01-12 13:42:04 -05002470 install_element (BGP_ENCAP_NODE, &vtysh_exit_bgpd_cmd);
2471 install_element (BGP_ENCAP_NODE, &vtysh_quit_bgpd_cmd);
2472 install_element (BGP_ENCAPV6_NODE, &vtysh_exit_bgpd_cmd);
2473 install_element (BGP_ENCAPV6_NODE, &vtysh_quit_bgpd_cmd);
paul718e3742002-12-13 20:15:29 +00002474 install_element (BGP_IPV4_NODE, &vtysh_exit_bgpd_cmd);
2475 install_element (BGP_IPV4_NODE, &vtysh_quit_bgpd_cmd);
2476 install_element (BGP_IPV4M_NODE, &vtysh_exit_bgpd_cmd);
2477 install_element (BGP_IPV4M_NODE, &vtysh_quit_bgpd_cmd);
2478 install_element (BGP_IPV6_NODE, &vtysh_exit_bgpd_cmd);
2479 install_element (BGP_IPV6_NODE, &vtysh_quit_bgpd_cmd);
paul57b5b7e2005-08-22 22:44:29 +00002480 install_element (BGP_IPV6M_NODE, &vtysh_exit_bgpd_cmd);
2481 install_element (BGP_IPV6M_NODE, &vtysh_quit_bgpd_cmd);
hassoc25e4582003-12-23 10:39:08 +00002482 install_element (ISIS_NODE, &vtysh_exit_isisd_cmd);
2483 install_element (ISIS_NODE, &vtysh_quit_isisd_cmd);
paul718e3742002-12-13 20:15:29 +00002484 install_element (KEYCHAIN_NODE, &vtysh_exit_ripd_cmd);
2485 install_element (KEYCHAIN_NODE, &vtysh_quit_ripd_cmd);
2486 install_element (KEYCHAIN_KEY_NODE, &vtysh_exit_ripd_cmd);
2487 install_element (KEYCHAIN_KEY_NODE, &vtysh_quit_ripd_cmd);
2488 install_element (RMAP_NODE, &vtysh_exit_rmap_cmd);
2489 install_element (RMAP_NODE, &vtysh_quit_rmap_cmd);
hassoe7168df2004-10-03 20:11:32 +00002490 install_element (VTY_NODE, &vtysh_exit_line_vty_cmd);
2491 install_element (VTY_NODE, &vtysh_quit_line_vty_cmd);
paul718e3742002-12-13 20:15:29 +00002492
2493 /* "end" command. */
2494 install_element (CONFIG_NODE, &vtysh_end_all_cmd);
2495 install_element (ENABLE_NODE, &vtysh_end_all_cmd);
2496 install_element (RIP_NODE, &vtysh_end_all_cmd);
2497 install_element (RIPNG_NODE, &vtysh_end_all_cmd);
2498 install_element (OSPF_NODE, &vtysh_end_all_cmd);
2499 install_element (OSPF6_NODE, &vtysh_end_all_cmd);
Juliusz Chroboczekfeb6c532012-02-07 04:58:49 +01002500 install_element (BABEL_NODE, &vtysh_end_all_cmd);
paul718e3742002-12-13 20:15:29 +00002501 install_element (BGP_NODE, &vtysh_end_all_cmd);
2502 install_element (BGP_IPV4_NODE, &vtysh_end_all_cmd);
2503 install_element (BGP_IPV4M_NODE, &vtysh_end_all_cmd);
2504 install_element (BGP_VPNV4_NODE, &vtysh_end_all_cmd);
Lou Berger13c378d2016-01-12 13:41:56 -05002505 install_element (BGP_VPNV6_NODE, &vtysh_end_all_cmd);
Lou Bergera3fda882016-01-12 13:42:04 -05002506 install_element (BGP_ENCAP_NODE, &vtysh_end_all_cmd);
2507 install_element (BGP_ENCAPV6_NODE, &vtysh_end_all_cmd);
paul718e3742002-12-13 20:15:29 +00002508 install_element (BGP_IPV6_NODE, &vtysh_end_all_cmd);
paul57b5b7e2005-08-22 22:44:29 +00002509 install_element (BGP_IPV6M_NODE, &vtysh_end_all_cmd);
hassoc25e4582003-12-23 10:39:08 +00002510 install_element (ISIS_NODE, &vtysh_end_all_cmd);
paul718e3742002-12-13 20:15:29 +00002511 install_element (KEYCHAIN_NODE, &vtysh_end_all_cmd);
2512 install_element (KEYCHAIN_KEY_NODE, &vtysh_end_all_cmd);
2513 install_element (RMAP_NODE, &vtysh_end_all_cmd);
hassoe7168df2004-10-03 20:11:32 +00002514 install_element (VTY_NODE, &vtysh_end_all_cmd);
paul718e3742002-12-13 20:15:29 +00002515
paul338a9912003-03-01 15:44:10 +00002516 install_element (INTERFACE_NODE, &interface_desc_cmd);
paul464dc8d2003-03-28 02:25:45 +00002517 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
paul718e3742002-12-13 20:15:29 +00002518 install_element (INTERFACE_NODE, &vtysh_end_all_cmd);
2519 install_element (INTERFACE_NODE, &vtysh_exit_interface_cmd);
2520 install_element (INTERFACE_NODE, &vtysh_quit_interface_cmd);
2521 install_element (CONFIG_NODE, &router_rip_cmd);
2522#ifdef HAVE_IPV6
2523 install_element (CONFIG_NODE, &router_ripng_cmd);
2524#endif
2525 install_element (CONFIG_NODE, &router_ospf_cmd);
2526#ifdef HAVE_IPV6
2527 install_element (CONFIG_NODE, &router_ospf6_cmd);
2528#endif
hassoc25e4582003-12-23 10:39:08 +00002529 install_element (CONFIG_NODE, &router_isis_cmd);
paul718e3742002-12-13 20:15:29 +00002530 install_element (CONFIG_NODE, &router_bgp_cmd);
Paul Jakma10895fd2008-07-03 19:34:48 +00002531 install_element (CONFIG_NODE, &router_bgp_view_cmd);
paul718e3742002-12-13 20:15:29 +00002532 install_element (BGP_NODE, &address_family_vpnv4_cmd);
2533 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
Lou Berger13c378d2016-01-12 13:41:56 -05002534 install_element (BGP_NODE, &address_family_vpnv6_cmd);
2535 install_element (BGP_NODE, &address_family_vpnv6_unicast_cmd);
Lou Bergera3fda882016-01-12 13:42:04 -05002536 install_element (BGP_NODE, &address_family_encap_cmd);
2537 install_element (BGP_NODE, &address_family_encapv6_cmd);
paul718e3742002-12-13 20:15:29 +00002538 install_element (BGP_NODE, &address_family_ipv4_unicast_cmd);
2539 install_element (BGP_NODE, &address_family_ipv4_multicast_cmd);
2540#ifdef HAVE_IPV6
2541 install_element (BGP_NODE, &address_family_ipv6_cmd);
2542 install_element (BGP_NODE, &address_family_ipv6_unicast_cmd);
2543#endif
2544 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
Lou Berger13c378d2016-01-12 13:41:56 -05002545 install_element (BGP_VPNV6_NODE, &exit_address_family_cmd);
Lou Bergera3fda882016-01-12 13:42:04 -05002546 install_element (BGP_ENCAP_NODE, &exit_address_family_cmd);
2547 install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd);
paul718e3742002-12-13 20:15:29 +00002548 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
2549 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
2550 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
paul57b5b7e2005-08-22 22:44:29 +00002551 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
paul718e3742002-12-13 20:15:29 +00002552 install_element (CONFIG_NODE, &key_chain_cmd);
2553 install_element (CONFIG_NODE, &route_map_cmd);
hassoe7168df2004-10-03 20:11:32 +00002554 install_element (CONFIG_NODE, &vtysh_line_vty_cmd);
paul718e3742002-12-13 20:15:29 +00002555 install_element (KEYCHAIN_NODE, &key_cmd);
2556 install_element (KEYCHAIN_NODE, &key_chain_cmd);
2557 install_element (KEYCHAIN_KEY_NODE, &key_chain_cmd);
2558 install_element (CONFIG_NODE, &vtysh_interface_cmd);
paul32d24632003-05-23 09:25:20 +00002559 install_element (CONFIG_NODE, &vtysh_no_interface_cmd);
Feng Lu471ea392015-05-22 11:40:00 +02002560 install_element (CONFIG_NODE, &vtysh_interface_vrf_cmd);
2561 install_element (CONFIG_NODE, &vtysh_no_interface_vrf_cmd);
paul718e3742002-12-13 20:15:29 +00002562 install_element (ENABLE_NODE, &vtysh_show_running_config_cmd);
Donald Sharp9fb73e82015-09-22 11:13:12 -04002563 install_element (ENABLE_NODE, &vtysh_show_running_config_daemon_cmd);
paul718e3742002-12-13 20:15:29 +00002564 install_element (ENABLE_NODE, &vtysh_copy_runningconfig_startupconfig_cmd);
2565 install_element (ENABLE_NODE, &vtysh_write_file_cmd);
hasso4a6e2252003-05-25 11:51:29 +00002566 install_element (ENABLE_NODE, &vtysh_write_cmd);
paul718e3742002-12-13 20:15:29 +00002567
hasso95e735b2004-08-26 13:08:30 +00002568 /* "write terminal" command. */
paul718e3742002-12-13 20:15:29 +00002569 install_element (ENABLE_NODE, &vtysh_write_terminal_cmd);
Donald Sharp9fb73e82015-09-22 11:13:12 -04002570 install_element (ENABLE_NODE, &vtysh_write_terminal_daemon_cmd);
Donald Sharp07440402016-02-25 07:39:45 -05002571
hassoe7168df2004-10-03 20:11:32 +00002572 install_element (CONFIG_NODE, &vtysh_integrated_config_cmd);
2573 install_element (CONFIG_NODE, &no_vtysh_integrated_config_cmd);
paul718e3742002-12-13 20:15:29 +00002574
hasso95e735b2004-08-26 13:08:30 +00002575 /* "write memory" command. */
paul718e3742002-12-13 20:15:29 +00002576 install_element (ENABLE_NODE, &vtysh_write_memory_cmd);
paul718e3742002-12-13 20:15:29 +00002577
hasso34553cc2004-08-27 13:56:39 +00002578 install_element (VIEW_NODE, &vtysh_terminal_length_cmd);
2579 install_element (ENABLE_NODE, &vtysh_terminal_length_cmd);
2580 install_element (VIEW_NODE, &vtysh_terminal_no_length_cmd);
2581 install_element (ENABLE_NODE, &vtysh_terminal_no_length_cmd);
hassof2799e62004-10-28 17:43:11 +00002582 install_element (VIEW_NODE, &vtysh_show_daemons_cmd);
2583 install_element (ENABLE_NODE, &vtysh_show_daemons_cmd);
hasso34553cc2004-08-27 13:56:39 +00002584
paul718e3742002-12-13 20:15:29 +00002585 install_element (VIEW_NODE, &vtysh_ping_cmd);
hasso4eeccf12003-06-25 10:49:55 +00002586 install_element (VIEW_NODE, &vtysh_ping_ip_cmd);
paul718e3742002-12-13 20:15:29 +00002587 install_element (VIEW_NODE, &vtysh_traceroute_cmd);
hasso4eeccf12003-06-25 10:49:55 +00002588 install_element (VIEW_NODE, &vtysh_traceroute_ip_cmd);
2589#ifdef HAVE_IPV6
2590 install_element (VIEW_NODE, &vtysh_ping6_cmd);
2591 install_element (VIEW_NODE, &vtysh_traceroute6_cmd);
2592#endif
paul718e3742002-12-13 20:15:29 +00002593 install_element (VIEW_NODE, &vtysh_telnet_cmd);
2594 install_element (VIEW_NODE, &vtysh_telnet_port_cmd);
paul5087df52003-01-25 06:56:09 +00002595 install_element (VIEW_NODE, &vtysh_ssh_cmd);
paul718e3742002-12-13 20:15:29 +00002596 install_element (ENABLE_NODE, &vtysh_ping_cmd);
hasso4eeccf12003-06-25 10:49:55 +00002597 install_element (ENABLE_NODE, &vtysh_ping_ip_cmd);
paul718e3742002-12-13 20:15:29 +00002598 install_element (ENABLE_NODE, &vtysh_traceroute_cmd);
hasso4eeccf12003-06-25 10:49:55 +00002599 install_element (ENABLE_NODE, &vtysh_traceroute_ip_cmd);
2600#ifdef HAVE_IPV6
2601 install_element (ENABLE_NODE, &vtysh_ping6_cmd);
2602 install_element (ENABLE_NODE, &vtysh_traceroute6_cmd);
2603#endif
paul718e3742002-12-13 20:15:29 +00002604 install_element (ENABLE_NODE, &vtysh_telnet_cmd);
2605 install_element (ENABLE_NODE, &vtysh_telnet_port_cmd);
hasso67e29ab2004-08-26 22:21:31 +00002606 install_element (ENABLE_NODE, &vtysh_ssh_cmd);
paul718e3742002-12-13 20:15:29 +00002607 install_element (ENABLE_NODE, &vtysh_start_shell_cmd);
2608 install_element (ENABLE_NODE, &vtysh_start_bash_cmd);
2609 install_element (ENABLE_NODE, &vtysh_start_zsh_cmd);
Paul Jakmadbf7d132006-05-23 22:10:01 +00002610
Paul Jakma362b4032006-05-28 07:54:45 +00002611 install_element (VIEW_NODE, &vtysh_show_memory_cmd);
2612 install_element (ENABLE_NODE, &vtysh_show_memory_cmd);
2613
Donald Sharp567a6382015-08-19 21:22:17 -04002614 install_element (VIEW_NODE, &vtysh_show_work_queues_cmd);
2615 install_element (ENABLE_NODE, &vtysh_show_work_queues_cmd);
Donald Sharp07440402016-02-25 07:39:45 -05002616 install_element (ENABLE_NODE, &vtysh_show_work_queues_daemon_cmd);
2617 install_element (VIEW_NODE, &vtysh_show_work_queues_daemon_cmd);
Donald Sharp567a6382015-08-19 21:22:17 -04002618
2619 install_element (VIEW_NODE, &vtysh_show_thread_cmd);
2620 install_element (ENABLE_NODE, &vtysh_show_thread_cmd);
2621
Paul Jakmadbf7d132006-05-23 22:10:01 +00002622 /* Logging */
2623 install_element (ENABLE_NODE, &vtysh_show_logging_cmd);
2624 install_element (VIEW_NODE, &vtysh_show_logging_cmd);
paul718e3742002-12-13 20:15:29 +00002625 install_element (CONFIG_NODE, &vtysh_log_stdout_cmd);
ajs274a4a42004-12-07 15:39:31 +00002626 install_element (CONFIG_NODE, &vtysh_log_stdout_level_cmd);
paul718e3742002-12-13 20:15:29 +00002627 install_element (CONFIG_NODE, &no_vtysh_log_stdout_cmd);
2628 install_element (CONFIG_NODE, &vtysh_log_file_cmd);
ajs274a4a42004-12-07 15:39:31 +00002629 install_element (CONFIG_NODE, &vtysh_log_file_level_cmd);
paul718e3742002-12-13 20:15:29 +00002630 install_element (CONFIG_NODE, &no_vtysh_log_file_cmd);
ajs274a4a42004-12-07 15:39:31 +00002631 install_element (CONFIG_NODE, &no_vtysh_log_file_level_cmd);
2632 install_element (CONFIG_NODE, &vtysh_log_monitor_cmd);
2633 install_element (CONFIG_NODE, &vtysh_log_monitor_level_cmd);
2634 install_element (CONFIG_NODE, &no_vtysh_log_monitor_cmd);
paul718e3742002-12-13 20:15:29 +00002635 install_element (CONFIG_NODE, &vtysh_log_syslog_cmd);
ajs274a4a42004-12-07 15:39:31 +00002636 install_element (CONFIG_NODE, &vtysh_log_syslog_level_cmd);
paul718e3742002-12-13 20:15:29 +00002637 install_element (CONFIG_NODE, &no_vtysh_log_syslog_cmd);
2638 install_element (CONFIG_NODE, &vtysh_log_trap_cmd);
2639 install_element (CONFIG_NODE, &no_vtysh_log_trap_cmd);
ajs274a4a42004-12-07 15:39:31 +00002640 install_element (CONFIG_NODE, &vtysh_log_facility_cmd);
2641 install_element (CONFIG_NODE, &no_vtysh_log_facility_cmd);
paul718e3742002-12-13 20:15:29 +00002642 install_element (CONFIG_NODE, &vtysh_log_record_priority_cmd);
2643 install_element (CONFIG_NODE, &no_vtysh_log_record_priority_cmd);
Andrew J. Schorrc749b722007-04-29 03:53:31 +00002644 install_element (CONFIG_NODE, &vtysh_log_timestamp_precision_cmd);
2645 install_element (CONFIG_NODE, &no_vtysh_log_timestamp_precision_cmd);
hassoe7168df2004-10-03 20:11:32 +00002646
2647 install_element (CONFIG_NODE, &vtysh_service_password_encrypt_cmd);
2648 install_element (CONFIG_NODE, &no_vtysh_service_password_encrypt_cmd);
2649
2650 install_element (CONFIG_NODE, &vtysh_password_cmd);
2651 install_element (CONFIG_NODE, &vtysh_password_text_cmd);
2652 install_element (CONFIG_NODE, &vtysh_enable_password_cmd);
2653 install_element (CONFIG_NODE, &vtysh_enable_password_text_cmd);
2654 install_element (CONFIG_NODE, &no_vtysh_enable_password_cmd);
2655
paul718e3742002-12-13 20:15:29 +00002656}