blob: 04d9d7d2cb7192682dbe018358806e6afa4a4eba [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"
paul718e3742002-12-13 20:15:29 +000037
38/* Struct VTY. */
39struct vty *vty;
40
41/* VTY shell pager name. */
42char *vtysh_pager_name = NULL;
43
44/* VTY shell client structure. */
45struct vtysh_client
46{
47 int fd;
48} vtysh_client[VTYSH_INDEX_MAX];
hassob094d262004-08-25 12:22:00 +000049
hassoe7168df2004-10-03 20:11:32 +000050/* Using integrated config from Quagga.conf. Default is no. */
51int vtysh_writeconfig_integrated = 0;
52
53extern char config_default[];
54
ajs274a4a42004-12-07 15:39:31 +000055static void
paul718e3742002-12-13 20:15:29 +000056vclient_close (struct vtysh_client *vclient)
57{
58 if (vclient->fd > 0)
59 close (vclient->fd);
60 vclient->fd = -1;
61}
62
paul718e3742002-12-13 20:15:29 +000063/* Following filled with debug code to trace a problematic condition
hasso95e735b2004-08-26 13:08:30 +000064 * under load - it SHOULD handle it. */
paul718e3742002-12-13 20:15:29 +000065#define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): "
ajs274a4a42004-12-07 15:39:31 +000066static int
paul718e3742002-12-13 20:15:29 +000067vtysh_client_config (struct vtysh_client *vclient, char *line)
68{
69 int ret;
70 char *buf;
71 size_t bufsz;
72 char *pbuf;
73 size_t left;
74 char *eoln;
75 int nbytes;
76 int i;
77 int readln;
78
79 if (vclient->fd < 0)
80 return CMD_SUCCESS;
81
82 ret = write (vclient->fd, line, strlen (line) + 1);
83 if (ret <= 0)
84 {
85 vclient_close (vclient);
86 return CMD_SUCCESS;
87 }
88
hasso95e735b2004-08-26 13:08:30 +000089 /* Allow enough room for buffer to read more than a few pages from socket. */
paule3d29b52003-01-23 18:05:42 +000090 bufsz = 5 * getpagesize() + 1;
paul718e3742002-12-13 20:15:29 +000091 buf = XMALLOC(MTYPE_TMP, bufsz);
92 memset(buf, 0, bufsz);
93 pbuf = buf;
94
95 while (1)
96 {
97 if (pbuf >= ((buf + bufsz) -1))
98 {
99 fprintf (stderr, ERR_WHERE_STRING \
100 "warning - pbuf beyond buffer end.\n");
101 return CMD_WARNING;
102 }
103
104 readln = (buf + bufsz) - pbuf - 1;
105 nbytes = read (vclient->fd, pbuf, readln);
106
107 if (nbytes <= 0)
108 {
109
110 if (errno == EINTR)
111 continue;
112
113 fprintf(stderr, ERR_WHERE_STRING "(%u)", errno);
114 perror("");
115
116 if (errno == EAGAIN || errno == EIO)
117 continue;
118
119 vclient_close (vclient);
120 XFREE(MTYPE_TMP, buf);
121 return CMD_SUCCESS;
122 }
123
124 pbuf[nbytes] = '\0';
125
126 if (nbytes >= 4)
127 {
128 i = nbytes - 4;
129 if (pbuf[i] == '\0' && pbuf[i + 1] == '\0' && pbuf[i + 2] == '\0')
130 {
131 ret = pbuf[i + 3];
132 break;
133 }
134 }
135 pbuf += nbytes;
136
137 /* See if a line exists in buffer, if so parse and consume it, and
hasso95e735b2004-08-26 13:08:30 +0000138 * reset read position. */
paul718e3742002-12-13 20:15:29 +0000139 if ((eoln = strrchr(buf, '\n')) == NULL)
140 continue;
141
142 if (eoln >= ((buf + bufsz) - 1))
143 {
144 fprintf (stderr, ERR_WHERE_STRING \
145 "warning - eoln beyond buffer end.\n");
146 }
147 vtysh_config_parse(buf);
148
149 eoln++;
150 left = (size_t)(buf + bufsz - eoln);
151 memmove(buf, eoln, left);
152 buf[bufsz-1] = '\0';
153 pbuf = buf + strlen(buf);
154 }
155
hasso95e735b2004-08-26 13:08:30 +0000156 /* Parse anything left in the buffer. */
hassoe7168df2004-10-03 20:11:32 +0000157
paul718e3742002-12-13 20:15:29 +0000158 vtysh_config_parse (buf);
159
160 XFREE(MTYPE_TMP, buf);
161 return ret;
162}
163
ajs274a4a42004-12-07 15:39:31 +0000164static int
hassodda09522004-10-07 21:40:25 +0000165vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp)
paul718e3742002-12-13 20:15:29 +0000166{
167 int ret;
168 char buf[1001];
169 int nbytes;
paul2852de12004-09-17 06:52:16 +0000170 int i;
171 int numnulls = 0;
paul718e3742002-12-13 20:15:29 +0000172
173 if (vclient->fd < 0)
174 return CMD_SUCCESS;
175
176 ret = write (vclient->fd, line, strlen (line) + 1);
177 if (ret <= 0)
178 {
179 vclient_close (vclient);
180 return CMD_SUCCESS;
181 }
182
183 while (1)
184 {
185 nbytes = read (vclient->fd, buf, sizeof(buf)-1);
186
187 if (nbytes <= 0 && errno != EINTR)
188 {
189 vclient_close (vclient);
190 return CMD_SUCCESS;
191 }
192
193 if (nbytes > 0)
194 {
ajs85fb1e62004-11-11 14:03:39 +0000195 if ((numnulls == 3) && (nbytes == 1))
196 return buf[0];
197
paul718e3742002-12-13 20:15:29 +0000198 buf[nbytes] = '\0';
ajs85fb1e62004-11-11 14:03:39 +0000199 fputs (buf, fp);
paul718e3742002-12-13 20:15:29 +0000200 fflush (fp);
paul2852de12004-09-17 06:52:16 +0000201
paul0921d482004-10-11 18:21:55 +0000202 /* check for trailling \0\0\0<ret code>,
203 * even if split across reads
204 * (see lib/vty.c::vtysh_read)
205 */
paul2852de12004-09-17 06:52:16 +0000206 if (nbytes >= 4)
207 {
208 i = nbytes-4;
209 numnulls = 0;
210 }
211 else
212 i = 0;
213
paul0921d482004-10-11 18:21:55 +0000214 while (i < nbytes && numnulls < 3)
paul2852de12004-09-17 06:52:16 +0000215 {
216 if (buf[i++] == '\0')
217 numnulls++;
218 else
ajs85fb1e62004-11-11 14:03:39 +0000219 numnulls = 0;
paul2852de12004-09-17 06:52:16 +0000220 }
paul718e3742002-12-13 20:15:29 +0000221
ajs85fb1e62004-11-11 14:03:39 +0000222 /* got 3 or more trailing NULs? */
223 if ((numnulls >= 3) && (i < nbytes))
paul0921d482004-10-11 18:21:55 +0000224 return (buf[nbytes-1]);
paul718e3742002-12-13 20:15:29 +0000225 }
226 }
paul718e3742002-12-13 20:15:29 +0000227}
228
229void
230vtysh_exit_ripd_only ()
231{
232 vtysh_client_execute (&vtysh_client[VTYSH_INDEX_RIP], "exit", stdout);
233}
234
235
236void
237vtysh_pager_init ()
238{
hasso5a9c53d2004-08-27 14:23:28 +0000239 char *pager_defined;
240
241 pager_defined = getenv ("VTYSH_PAGER");
242
243 if (pager_defined)
244 vtysh_pager_name = strdup (pager_defined);
245 else
hasso34553cc2004-08-27 13:56:39 +0000246 vtysh_pager_name = strdup ("more");
paul718e3742002-12-13 20:15:29 +0000247}
248
249/* Command execution over the vty interface. */
ajs274a4a42004-12-07 15:39:31 +0000250static void
hassodda09522004-10-07 21:40:25 +0000251vtysh_execute_func (const char *line, int pager)
paul718e3742002-12-13 20:15:29 +0000252{
253 int ret, cmd_stat;
254 vector vline;
255 struct cmd_element *cmd;
256 FILE *fp = NULL;
paula805cc22003-05-01 14:29:48 +0000257 int closepager=0;
paul718e3742002-12-13 20:15:29 +0000258
hasso95e735b2004-08-26 13:08:30 +0000259 /* Split readline string up into the vector. */
paul718e3742002-12-13 20:15:29 +0000260 vline = cmd_make_strvec (line);
261
262 if (vline == NULL)
263 return;
264
265 ret = cmd_execute_command (vline, vty, &cmd);
266
267 cmd_free_strvec (vline);
268
269 switch (ret)
270 {
271 case CMD_WARNING:
272 if (vty->type == VTY_FILE)
paul4fc01e62002-12-13 20:49:00 +0000273 fprintf (stdout,"Warning...\n");
paul718e3742002-12-13 20:15:29 +0000274 break;
275 case CMD_ERR_AMBIGUOUS:
paul4fc01e62002-12-13 20:49:00 +0000276 fprintf (stdout,"%% Ambiguous command.\n");
paul718e3742002-12-13 20:15:29 +0000277 break;
278 case CMD_ERR_NO_MATCH:
paul4fc01e62002-12-13 20:49:00 +0000279 fprintf (stdout,"%% Unknown command.\n");
paul718e3742002-12-13 20:15:29 +0000280 break;
281 case CMD_ERR_INCOMPLETE:
paul4fc01e62002-12-13 20:49:00 +0000282 fprintf (stdout,"%% Command incomplete.\n");
paul718e3742002-12-13 20:15:29 +0000283 break;
284 case CMD_SUCCESS_DAEMON:
285 {
hasso97b7db22004-10-20 19:07:48 +0000286 /* FIXME: Don't open pager for exit commands. popen() causes problems
287 * if exited from vtysh at all. This hack shouldn't cause any problem
288 * but is really ugly. */
289 if (pager && vtysh_pager_name && (strncmp(line, "exit", 4) != 0))
paul718e3742002-12-13 20:15:29 +0000290 {
paul4fc01e62002-12-13 20:49:00 +0000291 fp = popen (vtysh_pager_name, "w");
paul718e3742002-12-13 20:15:29 +0000292 if (fp == NULL)
293 {
paula805cc22003-05-01 14:29:48 +0000294 perror ("popen failed for pager");
295 fp = stdout;
paul718e3742002-12-13 20:15:29 +0000296 }
paula805cc22003-05-01 14:29:48 +0000297 else
298 closepager=1;
paul718e3742002-12-13 20:15:29 +0000299 }
300 else
301 fp = stdout;
302
303 if (! strcmp(cmd->string,"configure terminal"))
304 {
305 cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_ZEBRA],
306 line, fp);
307 if (cmd_stat != CMD_WARNING)
308 cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_RIP],
309 line, fp);
310 if (cmd_stat != CMD_WARNING)
hasso95e735b2004-08-26 13:08:30 +0000311 cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_RIPNG],
312 line, fp);
paul718e3742002-12-13 20:15:29 +0000313 if (cmd_stat != CMD_WARNING)
314 cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_OSPF],
315 line, fp);
316 if (cmd_stat != CMD_WARNING)
hasso95e735b2004-08-26 13:08:30 +0000317 cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_OSPF6],
318 line, fp);
paul718e3742002-12-13 20:15:29 +0000319 if (cmd_stat != CMD_WARNING)
320 cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_BGP],
321 line, fp);
hassob094d262004-08-25 12:22:00 +0000322 if (cmd_stat != CMD_WARNING)
hasso95e735b2004-08-26 13:08:30 +0000323 cmd_stat = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_ISIS],
324 line, fp);
paul718e3742002-12-13 20:15:29 +0000325 if (cmd_stat)
326 {
hassob094d262004-08-25 12:22:00 +0000327 line = "end";
328 vline = cmd_make_strvec (line);
paul718e3742002-12-13 20:15:29 +0000329
hassob094d262004-08-25 12:22:00 +0000330 if (vline == NULL)
paul718e3742002-12-13 20:15:29 +0000331 {
paula805cc22003-05-01 14:29:48 +0000332 if (pager && vtysh_pager_name && fp && closepager)
paul718e3742002-12-13 20:15:29 +0000333 {
334 if (pclose (fp) == -1)
335 {
paula805cc22003-05-01 14:29:48 +0000336 perror ("pclose failed for pager");
paul718e3742002-12-13 20:15:29 +0000337 }
338 fp = NULL;
339 }
340 return;
341 }
342
hassob094d262004-08-25 12:22:00 +0000343 ret = cmd_execute_command (vline, vty, &cmd);
344 cmd_free_strvec (vline);
345 if (ret != CMD_SUCCESS_DAEMON)
346 break;
paul718e3742002-12-13 20:15:29 +0000347 }
348 else
349 if (cmd->func)
350 {
351 (*cmd->func) (cmd, vty, 0, NULL);
352 break;
hassob094d262004-08-25 12:22:00 +0000353 }
paul718e3742002-12-13 20:15:29 +0000354 }
355
356 if (cmd->daemon & VTYSH_ZEBRA)
357 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_ZEBRA], line, fp)
358 != CMD_SUCCESS)
359 break;
360 if (cmd->daemon & VTYSH_RIPD)
361 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_RIP], line, fp)
362 != CMD_SUCCESS)
363 break;
364 if (cmd->daemon & VTYSH_RIPNGD)
365 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_RIPNG], line, fp)
366 != CMD_SUCCESS)
367 break;
368 if (cmd->daemon & VTYSH_OSPFD)
369 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_OSPF], line, fp)
370 != CMD_SUCCESS)
371 break;
372 if (cmd->daemon & VTYSH_OSPF6D)
373 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_OSPF6], line, fp)
374 != CMD_SUCCESS)
375 break;
376 if (cmd->daemon & VTYSH_BGPD)
377 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_BGP], line, fp)
378 != CMD_SUCCESS)
379 break;
hassob094d262004-08-25 12:22:00 +0000380 if (cmd->daemon & VTYSH_ISISD)
381 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_ISIS], line, fp)
382 != CMD_SUCCESS)
383 break;
paul718e3742002-12-13 20:15:29 +0000384 if (cmd->func)
385 (*cmd->func) (cmd, vty, 0, NULL);
386 }
387 }
paula805cc22003-05-01 14:29:48 +0000388 if (pager && vtysh_pager_name && fp && closepager)
paul718e3742002-12-13 20:15:29 +0000389 {
390 if (pclose (fp) == -1)
391 {
paula805cc22003-05-01 14:29:48 +0000392 perror ("pclose failed for pager");
paul718e3742002-12-13 20:15:29 +0000393 }
394 fp = NULL;
395 }
396}
397
398void
hassodda09522004-10-07 21:40:25 +0000399vtysh_execute_no_pager (const char *line)
paul718e3742002-12-13 20:15:29 +0000400{
401 vtysh_execute_func (line, 0);
402}
403
404void
hassodda09522004-10-07 21:40:25 +0000405vtysh_execute (const char *line)
paul718e3742002-12-13 20:15:29 +0000406{
407 vtysh_execute_func (line, 1);
408}
409
410/* Configration make from file. */
411int
412vtysh_config_from_file (struct vty *vty, FILE *fp)
413{
414 int ret;
415 vector vline;
416 struct cmd_element *cmd;
417
418 while (fgets (vty->buf, VTY_BUFSIZ, fp))
419 {
420 if (vty->buf[0] == '!' || vty->buf[1] == '#')
421 continue;
422
423 vline = cmd_make_strvec (vty->buf);
424
hasso95e735b2004-08-26 13:08:30 +0000425 /* In case of comment line. */
paul718e3742002-12-13 20:15:29 +0000426 if (vline == NULL)
427 continue;
428
hasso95e735b2004-08-26 13:08:30 +0000429 /* Execute configuration command : this is strict match. */
paul718e3742002-12-13 20:15:29 +0000430 ret = cmd_execute_command_strict (vline, vty, &cmd);
431
hasso95e735b2004-08-26 13:08:30 +0000432 /* Try again with setting node to CONFIG_NODE. */
paul718e3742002-12-13 20:15:29 +0000433 if (ret != CMD_SUCCESS
434 && ret != CMD_SUCCESS_DAEMON
435 && ret != CMD_WARNING)
436 {
437 if (vty->node == KEYCHAIN_KEY_NODE)
438 {
439 vty->node = KEYCHAIN_NODE;
440 vtysh_exit_ripd_only ();
441 ret = cmd_execute_command_strict (vline, vty, &cmd);
442
443 if (ret != CMD_SUCCESS
444 && ret != CMD_SUCCESS_DAEMON
445 && ret != CMD_WARNING)
446 {
447 vtysh_exit_ripd_only ();
448 vty->node = CONFIG_NODE;
449 ret = cmd_execute_command_strict (vline, vty, &cmd);
450 }
451 }
452 else
453 {
454 vtysh_execute ("end");
455 vtysh_execute ("configure terminal");
456 vty->node = CONFIG_NODE;
457 ret = cmd_execute_command_strict (vline, vty, &cmd);
458 }
459 }
460
461 cmd_free_strvec (vline);
462
463 switch (ret)
464 {
465 case CMD_WARNING:
466 if (vty->type == VTY_FILE)
paul4fc01e62002-12-13 20:49:00 +0000467 fprintf (stdout,"Warning...\n");
paul718e3742002-12-13 20:15:29 +0000468 break;
469 case CMD_ERR_AMBIGUOUS:
paul4fc01e62002-12-13 20:49:00 +0000470 fprintf (stdout,"%% Ambiguous command.\n");
paul718e3742002-12-13 20:15:29 +0000471 break;
472 case CMD_ERR_NO_MATCH:
paul4fc01e62002-12-13 20:49:00 +0000473 fprintf (stdout,"%% Unknown command: %s", vty->buf);
paul718e3742002-12-13 20:15:29 +0000474 break;
475 case CMD_ERR_INCOMPLETE:
paul4fc01e62002-12-13 20:49:00 +0000476 fprintf (stdout,"%% Command incomplete.\n");
paul718e3742002-12-13 20:15:29 +0000477 break;
478 case CMD_SUCCESS_DAEMON:
479 {
480 if (cmd->daemon & VTYSH_ZEBRA)
481 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_ZEBRA],
482 vty->buf, stdout) != CMD_SUCCESS)
483 break;
484 if (cmd->daemon & VTYSH_RIPD)
485 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_RIP],
486 vty->buf, stdout) != CMD_SUCCESS)
487 break;
488 if (cmd->daemon & VTYSH_RIPNGD)
489 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_RIPNG],
490 vty->buf, stdout) != CMD_SUCCESS)
491 break;
492 if (cmd->daemon & VTYSH_OSPFD)
493 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_OSPF],
494 vty->buf, stdout) != CMD_SUCCESS)
495 break;
496 if (cmd->daemon & VTYSH_OSPF6D)
497 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_OSPF6],
498 vty->buf, stdout) != CMD_SUCCESS)
499 break;
500 if (cmd->daemon & VTYSH_BGPD)
501 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_BGP],
502 vty->buf, stdout) != CMD_SUCCESS)
503 break;
hassob094d262004-08-25 12:22:00 +0000504 if (cmd->daemon & VTYSH_ISISD)
505 if (vtysh_client_execute (&vtysh_client[VTYSH_INDEX_ISIS],
506 vty->buf, stdout) != CMD_SUCCESS)
507 break;
paul718e3742002-12-13 20:15:29 +0000508 if (cmd->func)
509 (*cmd->func) (cmd, vty, 0, NULL);
510 }
511 }
512 }
513 return CMD_SUCCESS;
514}
515
516/* We don't care about the point of the cursor when '?' is typed. */
517int
518vtysh_rl_describe ()
519{
520 int ret;
hassodda09522004-10-07 21:40:25 +0000521 unsigned int i;
paul718e3742002-12-13 20:15:29 +0000522 vector vline;
523 vector describe;
524 int width;
525 struct desc *desc;
526
527 vline = cmd_make_strvec (rl_line_buffer);
528
529 /* In case of '> ?'. */
530 if (vline == NULL)
531 {
532 vline = vector_init (1);
533 vector_set (vline, '\0');
534 }
535 else
536 if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
537 vector_set (vline, '\0');
538
539 describe = cmd_describe_command (vline, vty, &ret);
540
paul4fc01e62002-12-13 20:49:00 +0000541 fprintf (stdout,"\n");
paul718e3742002-12-13 20:15:29 +0000542
543 /* Ambiguous and no match error. */
544 switch (ret)
545 {
546 case CMD_ERR_AMBIGUOUS:
547 cmd_free_strvec (vline);
paul4fc01e62002-12-13 20:49:00 +0000548 fprintf (stdout,"%% Ambiguous command.\n");
paul718e3742002-12-13 20:15:29 +0000549 rl_on_new_line ();
550 return 0;
551 break;
552 case CMD_ERR_NO_MATCH:
553 cmd_free_strvec (vline);
paul4fc01e62002-12-13 20:49:00 +0000554 fprintf (stdout,"%% There is no matched command.\n");
paul718e3742002-12-13 20:15:29 +0000555 rl_on_new_line ();
556 return 0;
557 break;
558 }
559
560 /* Get width of command string. */
561 width = 0;
562 for (i = 0; i < vector_max (describe); i++)
563 if ((desc = vector_slot (describe, i)) != NULL)
564 {
565 int len;
566
567 if (desc->cmd[0] == '\0')
568 continue;
569
570 len = strlen (desc->cmd);
571 if (desc->cmd[0] == '.')
572 len--;
573
574 if (width < len)
575 width = len;
576 }
577
578 for (i = 0; i < vector_max (describe); i++)
579 if ((desc = vector_slot (describe, i)) != NULL)
580 {
581 if (desc->cmd[0] == '\0')
582 continue;
583
584 if (! desc->str)
paul4fc01e62002-12-13 20:49:00 +0000585 fprintf (stdout," %-s\n",
hassob094d262004-08-25 12:22:00 +0000586 desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd);
paul718e3742002-12-13 20:15:29 +0000587 else
paul4fc01e62002-12-13 20:49:00 +0000588 fprintf (stdout," %-*s %s\n",
hassob094d262004-08-25 12:22:00 +0000589 width,
590 desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd,
591 desc->str);
paul718e3742002-12-13 20:15:29 +0000592 }
593
594 cmd_free_strvec (vline);
595 vector_free (describe);
596
597 rl_on_new_line();
598
599 return 0;
600}
601
hasso95e735b2004-08-26 13:08:30 +0000602/* Result of cmd_complete_command() call will be stored here
603 * and used in new_completion() in order to put the space in
604 * correct places only. */
paul718e3742002-12-13 20:15:29 +0000605int complete_status;
606
ajs274a4a42004-12-07 15:39:31 +0000607static char *
pauldfc0d9b2003-04-18 23:55:29 +0000608command_generator (const char *text, int state)
paul718e3742002-12-13 20:15:29 +0000609{
610 vector vline;
611 static char **matched = NULL;
612 static int index = 0;
613
614 /* First call. */
615 if (! state)
616 {
617 index = 0;
618
619 if (vty->node == AUTH_NODE || vty->node == AUTH_ENABLE_NODE)
620 return NULL;
621
622 vline = cmd_make_strvec (rl_line_buffer);
623 if (vline == NULL)
624 return NULL;
625
626 if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
627 vector_set (vline, '\0');
628
629 matched = cmd_complete_command (vline, vty, &complete_status);
630 }
631
632 if (matched && matched[index])
633 return matched[index++];
634
635 return NULL;
636}
637
ajs274a4a42004-12-07 15:39:31 +0000638static char **
paul718e3742002-12-13 20:15:29 +0000639new_completion (char *text, int start, int end)
640{
641 char **matches;
642
pauldfc0d9b2003-04-18 23:55:29 +0000643 matches = rl_completion_matches (text, command_generator);
paul718e3742002-12-13 20:15:29 +0000644
645 if (matches)
646 {
647 rl_point = rl_end;
648 if (complete_status == CMD_COMPLETE_FULL_MATCH)
649 rl_pending_input = ' ';
650 }
651
652 return matches;
653}
654
ajs274a4a42004-12-07 15:39:31 +0000655#if 0
656/* This function is not actually being used. */
657static char **
paul718e3742002-12-13 20:15:29 +0000658vtysh_completion (char *text, int start, int end)
659{
660 int ret;
661 vector vline;
662 char **matched = NULL;
663
664 if (vty->node == AUTH_NODE || vty->node == AUTH_ENABLE_NODE)
665 return NULL;
666
667 vline = cmd_make_strvec (rl_line_buffer);
668 if (vline == NULL)
669 return NULL;
670
671 /* In case of 'help \t'. */
672 if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
673 vector_set (vline, '\0');
674
675 matched = cmd_complete_command (vline, vty, &ret);
676
677 cmd_free_strvec (vline);
678
679 return (char **) matched;
680}
ajs274a4a42004-12-07 15:39:31 +0000681#endif
paul718e3742002-12-13 20:15:29 +0000682
hasso95e735b2004-08-26 13:08:30 +0000683/* Vty node structures. */
paul718e3742002-12-13 20:15:29 +0000684struct cmd_node bgp_node =
685{
686 BGP_NODE,
687 "%s(config-router)# ",
688};
689
paul718e3742002-12-13 20:15:29 +0000690struct cmd_node rip_node =
691{
692 RIP_NODE,
693 "%s(config-router)# ",
694};
695
hassoc25e4582003-12-23 10:39:08 +0000696struct cmd_node isis_node =
697{
698 ISIS_NODE,
699 "%s(config-router)# ",
hassoc25e4582003-12-23 10:39:08 +0000700};
701
paul718e3742002-12-13 20:15:29 +0000702struct cmd_node interface_node =
703{
704 INTERFACE_NODE,
705 "%s(config-if)# ",
706};
707
hasso95e735b2004-08-26 13:08:30 +0000708struct cmd_node rmap_node =
709{
710 RMAP_NODE,
711 "%s(config-route-map)# "
712};
713
714struct cmd_node zebra_node =
715{
716 ZEBRA_NODE,
717 "%s(config-router)# "
718};
719
720struct cmd_node bgp_vpnv4_node =
721{
722 BGP_VPNV4_NODE,
723 "%s(config-router-af)# "
724};
725
726struct cmd_node bgp_ipv4_node =
727{
728 BGP_IPV4_NODE,
729 "%s(config-router-af)# "
730};
731
732struct cmd_node bgp_ipv4m_node =
733{
734 BGP_IPV4M_NODE,
735 "%s(config-router-af)# "
736};
737
738struct cmd_node bgp_ipv6_node =
739{
740 BGP_IPV6_NODE,
741 "%s(config-router-af)# "
742};
743
744struct cmd_node ospf_node =
745{
746 OSPF_NODE,
747 "%s(config-router)# "
748};
749
750struct cmd_node ripng_node =
751{
752 RIPNG_NODE,
753 "%s(config-router)# "
754};
755
756struct cmd_node ospf6_node =
757{
758 OSPF6_NODE,
759 "%s(config-ospf6)# "
760};
761
762struct cmd_node keychain_node =
763{
764 KEYCHAIN_NODE,
765 "%s(config-keychain)# "
766};
767
768struct cmd_node keychain_key_node =
769{
770 KEYCHAIN_KEY_NODE,
771 "%s(config-keychain-key)# "
772};
773
hassoe7168df2004-10-03 20:11:32 +0000774/* Defined in lib/vty.c */
775extern struct cmd_node vty_node;
776
hasso95e735b2004-08-26 13:08:30 +0000777/* When '^Z' is received from vty, move down to the enable mode. */
778int
779vtysh_end ()
780{
781 switch (vty->node)
782 {
783 case VIEW_NODE:
784 case ENABLE_NODE:
785 /* Nothing to do. */
786 break;
787 default:
788 vty->node = ENABLE_NODE;
789 break;
790 }
791 return CMD_SUCCESS;
792}
793
794DEFUNSH (VTYSH_ALL,
795 vtysh_end_all,
796 vtysh_end_all_cmd,
797 "end",
hassoe7168df2004-10-03 20:11:32 +0000798 "End current mode and change to enable mode\n")
hasso95e735b2004-08-26 13:08:30 +0000799{
hasso42895462004-09-26 16:25:07 +0000800 return vtysh_end ();
hasso95e735b2004-08-26 13:08:30 +0000801}
802
paul718e3742002-12-13 20:15:29 +0000803DEFUNSH (VTYSH_BGPD,
804 router_bgp,
805 router_bgp_cmd,
806 "router bgp <1-65535>",
807 ROUTER_STR
808 BGP_STR
809 AS_STR)
810{
811 vty->node = BGP_NODE;
812 return CMD_SUCCESS;
813}
814
815DEFUNSH (VTYSH_BGPD,
816 address_family_vpnv4,
817 address_family_vpnv4_cmd,
818 "address-family vpnv4",
819 "Enter Address Family command mode\n"
820 "Address family\n")
821{
822 vty->node = BGP_VPNV4_NODE;
823 return CMD_SUCCESS;
824}
825
826DEFUNSH (VTYSH_BGPD,
827 address_family_vpnv4_unicast,
828 address_family_vpnv4_unicast_cmd,
829 "address-family vpnv4 unicast",
830 "Enter Address Family command mode\n"
831 "Address family\n"
832 "Address Family Modifier\n")
833{
834 vty->node = BGP_VPNV4_NODE;
835 return CMD_SUCCESS;
836}
837
838DEFUNSH (VTYSH_BGPD,
839 address_family_ipv4_unicast,
840 address_family_ipv4_unicast_cmd,
841 "address-family ipv4 unicast",
842 "Enter Address Family command mode\n"
843 "Address family\n"
844 "Address Family Modifier\n")
845{
846 vty->node = BGP_IPV4_NODE;
847 return CMD_SUCCESS;
848}
849
850DEFUNSH (VTYSH_BGPD,
851 address_family_ipv4_multicast,
852 address_family_ipv4_multicast_cmd,
853 "address-family ipv4 multicast",
854 "Enter Address Family command mode\n"
855 "Address family\n"
856 "Address Family Modifier\n")
857{
858 vty->node = BGP_IPV4M_NODE;
859 return CMD_SUCCESS;
860}
861
862DEFUNSH (VTYSH_BGPD,
863 address_family_ipv6,
864 address_family_ipv6_cmd,
865 "address-family ipv6",
866 "Enter Address Family command mode\n"
867 "Address family\n")
868{
869 vty->node = BGP_IPV6_NODE;
870 return CMD_SUCCESS;
871}
872
873DEFUNSH (VTYSH_BGPD,
874 address_family_ipv6_unicast,
875 address_family_ipv6_unicast_cmd,
876 "address-family ipv6 unicast",
877 "Enter Address Family command mode\n"
878 "Address family\n"
879 "Address Family Modifier\n")
880{
881 vty->node = BGP_IPV6_NODE;
882 return CMD_SUCCESS;
883}
884
885DEFUNSH (VTYSH_RIPD,
886 key_chain,
887 key_chain_cmd,
888 "key chain WORD",
889 "Authentication key management\n"
890 "Key-chain management\n"
891 "Key-chain name\n")
892{
893 vty->node = KEYCHAIN_NODE;
894 return CMD_SUCCESS;
895}
896
897DEFUNSH (VTYSH_RIPD,
898 key,
899 key_cmd,
900 "key <0-2147483647>",
901 "Configure a key\n"
902 "Key identifier number\n")
903{
904 vty->node = KEYCHAIN_KEY_NODE;
905 return CMD_SUCCESS;
906}
907
908DEFUNSH (VTYSH_RIPD,
909 router_rip,
910 router_rip_cmd,
911 "router rip",
912 ROUTER_STR
913 "RIP")
914{
915 vty->node = RIP_NODE;
916 return CMD_SUCCESS;
917}
918
919DEFUNSH (VTYSH_RIPNGD,
920 router_ripng,
921 router_ripng_cmd,
922 "router ripng",
923 ROUTER_STR
924 "RIPng")
925{
926 vty->node = RIPNG_NODE;
927 return CMD_SUCCESS;
928}
929
930DEFUNSH (VTYSH_OSPFD,
931 router_ospf,
932 router_ospf_cmd,
933 "router ospf",
934 "Enable a routing process\n"
935 "Start OSPF configuration\n")
936{
937 vty->node = OSPF_NODE;
938 return CMD_SUCCESS;
939}
940
941DEFUNSH (VTYSH_OSPF6D,
942 router_ospf6,
943 router_ospf6_cmd,
944 "router ospf6",
945 OSPF6_ROUTER_STR
946 OSPF6_STR)
947{
948 vty->node = OSPF6_NODE;
949 return CMD_SUCCESS;
950}
951
hassoc25e4582003-12-23 10:39:08 +0000952DEFUNSH (VTYSH_ISISD,
hassob094d262004-08-25 12:22:00 +0000953 router_isis,
954 router_isis_cmd,
955 "router isis WORD",
956 ROUTER_STR
957 "ISO IS-IS\n"
958 "ISO Routing area tag")
hassoc25e4582003-12-23 10:39:08 +0000959{
960 vty->node = ISIS_NODE;
961 return CMD_SUCCESS;
962}
963
paul718e3742002-12-13 20:15:29 +0000964DEFUNSH (VTYSH_RMAP,
965 route_map,
966 route_map_cmd,
967 "route-map WORD (deny|permit) <1-65535>",
968 "Create route-map or enter route-map command mode\n"
969 "Route map tag\n"
970 "Route map denies set operations\n"
971 "Route map permits set operations\n"
972 "Sequence to insert to/delete from existing route-map entry\n")
973{
974 vty->node = RMAP_NODE;
975 return CMD_SUCCESS;
976}
977
paul718e3742002-12-13 20:15:29 +0000978DEFUNSH (VTYSH_ALL,
hassoe7168df2004-10-03 20:11:32 +0000979 vtysh_line_vty,
980 vtysh_line_vty_cmd,
981 "line vty",
982 "Configure a terminal line\n"
983 "Virtual terminal\n")
984{
985 vty->node = VTY_NODE;
986 return CMD_SUCCESS;
987}
988
989DEFUNSH (VTYSH_ALL,
paul718e3742002-12-13 20:15:29 +0000990 vtysh_enable,
991 vtysh_enable_cmd,
992 "enable",
993 "Turn on privileged mode command\n")
994{
995 vty->node = ENABLE_NODE;
996 return CMD_SUCCESS;
997}
998
paul718e3742002-12-13 20:15:29 +0000999DEFUNSH (VTYSH_ALL,
1000 vtysh_disable,
1001 vtysh_disable_cmd,
1002 "disable",
1003 "Turn off privileged mode command\n")
1004{
1005 if (vty->node == ENABLE_NODE)
1006 vty->node = VIEW_NODE;
1007 return CMD_SUCCESS;
1008}
1009
paul718e3742002-12-13 20:15:29 +00001010DEFUNSH (VTYSH_ALL,
1011 vtysh_config_terminal,
1012 vtysh_config_terminal_cmd,
1013 "configure terminal",
1014 "Configuration from vty interface\n"
1015 "Configuration terminal\n")
1016{
1017 vty->node = CONFIG_NODE;
1018 return CMD_SUCCESS;
1019}
1020
ajs274a4a42004-12-07 15:39:31 +00001021static int
paul718e3742002-12-13 20:15:29 +00001022vtysh_exit (struct vty *vty)
1023{
1024 switch (vty->node)
1025 {
1026 case VIEW_NODE:
1027 case ENABLE_NODE:
1028 exit (0);
1029 break;
1030 case CONFIG_NODE:
1031 vty->node = ENABLE_NODE;
1032 break;
1033 case INTERFACE_NODE:
1034 case ZEBRA_NODE:
1035 case BGP_NODE:
1036 case RIP_NODE:
1037 case RIPNG_NODE:
1038 case OSPF_NODE:
1039 case OSPF6_NODE:
hassoc25e4582003-12-23 10:39:08 +00001040 case ISIS_NODE:
paul718e3742002-12-13 20:15:29 +00001041 case MASC_NODE:
1042 case RMAP_NODE:
1043 case VTY_NODE:
1044 case KEYCHAIN_NODE:
hasso2a56df92004-05-09 23:16:40 +00001045 vtysh_execute("end");
1046 vtysh_execute("configure terminal");
paul718e3742002-12-13 20:15:29 +00001047 vty->node = CONFIG_NODE;
1048 break;
1049 case BGP_VPNV4_NODE:
1050 case BGP_IPV4_NODE:
1051 case BGP_IPV4M_NODE:
1052 case BGP_IPV6_NODE:
1053 vty->node = BGP_NODE;
1054 break;
1055 case KEYCHAIN_KEY_NODE:
1056 vty->node = KEYCHAIN_NODE;
1057 break;
1058 default:
1059 break;
1060 }
1061 return CMD_SUCCESS;
1062}
1063
1064DEFUNSH (VTYSH_ALL,
1065 vtysh_exit_all,
1066 vtysh_exit_all_cmd,
1067 "exit",
1068 "Exit current mode and down to previous mode\n")
1069{
1070 return vtysh_exit (vty);
1071}
1072
1073ALIAS (vtysh_exit_all,
1074 vtysh_quit_all_cmd,
1075 "quit",
1076 "Exit current mode and down to previous mode\n")
1077
1078DEFUNSH (VTYSH_BGPD,
1079 exit_address_family,
1080 exit_address_family_cmd,
1081 "exit-address-family",
1082 "Exit from Address Family configuration mode\n")
1083{
1084 if (vty->node == BGP_IPV4_NODE
1085 || vty->node == BGP_IPV4M_NODE
1086 || vty->node == BGP_VPNV4_NODE
1087 || vty->node == BGP_IPV6_NODE)
1088 vty->node = BGP_NODE;
1089 return CMD_SUCCESS;
1090}
1091
1092DEFUNSH (VTYSH_ZEBRA,
1093 vtysh_exit_zebra,
1094 vtysh_exit_zebra_cmd,
1095 "exit",
1096 "Exit current mode and down to previous mode\n")
1097{
1098 return vtysh_exit (vty);
1099}
1100
1101ALIAS (vtysh_exit_zebra,
1102 vtysh_quit_zebra_cmd,
1103 "quit",
1104 "Exit current mode and down to previous mode\n")
1105
1106DEFUNSH (VTYSH_RIPD,
1107 vtysh_exit_ripd,
1108 vtysh_exit_ripd_cmd,
1109 "exit",
1110 "Exit current mode and down to previous mode\n")
1111{
1112 return vtysh_exit (vty);
1113}
1114
1115ALIAS (vtysh_exit_ripd,
1116 vtysh_quit_ripd_cmd,
1117 "quit",
1118 "Exit current mode and down to previous mode\n")
1119
paul68980082003-03-25 05:07:42 +00001120DEFUNSH (VTYSH_RIPNGD,
hassob094d262004-08-25 12:22:00 +00001121 vtysh_exit_ripngd,
1122 vtysh_exit_ripngd_cmd,
1123 "exit",
1124 "Exit current mode and down to previous mode\n")
paul68980082003-03-25 05:07:42 +00001125{
1126 return vtysh_exit (vty);
1127}
1128
1129ALIAS (vtysh_exit_ripngd,
1130 vtysh_quit_ripngd_cmd,
1131 "quit",
1132 "Exit current mode and down to previous mode\n")
1133
paul718e3742002-12-13 20:15:29 +00001134DEFUNSH (VTYSH_RMAP,
1135 vtysh_exit_rmap,
1136 vtysh_exit_rmap_cmd,
1137 "exit",
1138 "Exit current mode and down to previous mode\n")
1139{
1140 return vtysh_exit (vty);
1141}
1142
1143ALIAS (vtysh_exit_rmap,
1144 vtysh_quit_rmap_cmd,
1145 "quit",
1146 "Exit current mode and down to previous mode\n")
1147
1148DEFUNSH (VTYSH_BGPD,
1149 vtysh_exit_bgpd,
1150 vtysh_exit_bgpd_cmd,
1151 "exit",
1152 "Exit current mode and down to previous mode\n")
1153{
1154 return vtysh_exit (vty);
1155}
1156
1157ALIAS (vtysh_exit_bgpd,
1158 vtysh_quit_bgpd_cmd,
1159 "quit",
1160 "Exit current mode and down to previous mode\n")
1161
1162DEFUNSH (VTYSH_OSPFD,
1163 vtysh_exit_ospfd,
1164 vtysh_exit_ospfd_cmd,
1165 "exit",
1166 "Exit current mode and down to previous mode\n")
1167{
1168 return vtysh_exit (vty);
1169}
1170
1171ALIAS (vtysh_exit_ospfd,
1172 vtysh_quit_ospfd_cmd,
1173 "quit",
1174 "Exit current mode and down to previous mode\n")
1175
paul68980082003-03-25 05:07:42 +00001176DEFUNSH (VTYSH_OSPF6D,
hassob094d262004-08-25 12:22:00 +00001177 vtysh_exit_ospf6d,
1178 vtysh_exit_ospf6d_cmd,
1179 "exit",
1180 "Exit current mode and down to previous mode\n")
paul68980082003-03-25 05:07:42 +00001181{
1182 return vtysh_exit (vty);
1183}
1184
1185ALIAS (vtysh_exit_ospf6d,
1186 vtysh_quit_ospf6d_cmd,
1187 "quit",
1188 "Exit current mode and down to previous mode\n")
1189
hassoc25e4582003-12-23 10:39:08 +00001190DEFUNSH (VTYSH_ISISD,
hassob094d262004-08-25 12:22:00 +00001191 vtysh_exit_isisd,
1192 vtysh_exit_isisd_cmd,
1193 "exit",
1194 "Exit current mode and down to previous mode\n")
hassoc25e4582003-12-23 10:39:08 +00001195{
1196 return vtysh_exit (vty);
1197}
1198
1199ALIAS (vtysh_exit_isisd,
1200 vtysh_quit_isisd_cmd,
1201 "quit",
1202 "Exit current mode and down to previous mode\n")
1203
hassoe7168df2004-10-03 20:11:32 +00001204DEFUNSH (VTYSH_ALL,
1205 vtysh_exit_line_vty,
1206 vtysh_exit_line_vty_cmd,
1207 "exit",
1208 "Exit current mode and down to previous mode\n")
1209{
1210 return vtysh_exit (vty);
1211}
1212
1213ALIAS (vtysh_exit_line_vty,
1214 vtysh_quit_line_vty_cmd,
1215 "quit",
1216 "Exit current mode and down to previous mode\n")
1217
hasso95e735b2004-08-26 13:08:30 +00001218DEFUNSH (VTYSH_INTERFACE,
paul718e3742002-12-13 20:15:29 +00001219 vtysh_interface,
1220 vtysh_interface_cmd,
1221 "interface IFNAME",
1222 "Select an interface to configure\n"
1223 "Interface's name\n")
1224{
1225 vty->node = INTERFACE_NODE;
1226 return CMD_SUCCESS;
1227}
1228
hasso95e735b2004-08-26 13:08:30 +00001229/* TODO Implement "no interface command in isisd. */
paul32d24632003-05-23 09:25:20 +00001230DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D,
1231 vtysh_no_interface_cmd,
1232 "no interface IFNAME",
1233 NO_STR
1234 "Delete a pseudo interface's configuration\n"
1235 "Interface's name\n")
1236
hasso95e735b2004-08-26 13:08:30 +00001237/* TODO Implement interface description commands in ripngd, ospf6d
1238 * and isisd. */
paul338a9912003-03-01 15:44:10 +00001239DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD,
1240 interface_desc_cmd,
1241 "description .LINE",
1242 "Interface specific description\n"
1243 "Characters describing this interface\n")
paul464dc8d2003-03-28 02:25:45 +00001244
1245DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD,
1246 no_interface_desc_cmd,
1247 "no description",
1248 NO_STR
1249 "Interface specific description\n")
paul338a9912003-03-01 15:44:10 +00001250
hasso95e735b2004-08-26 13:08:30 +00001251DEFUNSH (VTYSH_INTERFACE,
paul718e3742002-12-13 20:15:29 +00001252 vtysh_exit_interface,
1253 vtysh_exit_interface_cmd,
1254 "exit",
1255 "Exit current mode and down to previous mode\n")
1256{
1257 return vtysh_exit (vty);
1258}
1259
1260ALIAS (vtysh_exit_interface,
1261 vtysh_quit_interface_cmd,
1262 "quit",
1263 "Exit current mode and down to previous mode\n")
1264
hasso95e735b2004-08-26 13:08:30 +00001265/* Logging commands. */
1266DEFUNSH (VTYSH_ALL,
1267 vtysh_log_stdout,
1268 vtysh_log_stdout_cmd,
1269 "log stdout",
1270 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001271 "Set stdout logging level\n")
1272{
1273 return CMD_SUCCESS;
1274}
1275
1276DEFUNSH (VTYSH_ALL,
1277 vtysh_log_stdout_level,
1278 vtysh_log_stdout_level_cmd,
1279 "log stdout "LOG_LEVELS,
1280 "Logging control\n"
1281 "Set stdout logging level\n"
1282 LOG_LEVEL_DESC)
hasso95e735b2004-08-26 13:08:30 +00001283{
1284 return CMD_SUCCESS;
1285}
1286
1287DEFUNSH (VTYSH_ALL,
1288 no_vtysh_log_stdout,
1289 no_vtysh_log_stdout_cmd,
ajs274a4a42004-12-07 15:39:31 +00001290 "no log stdout [LEVEL]",
hasso95e735b2004-08-26 13:08:30 +00001291 NO_STR
1292 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001293 "Cancel logging to stdout\n"
1294 "Logging level\n")
hasso95e735b2004-08-26 13:08:30 +00001295{
1296 return CMD_SUCCESS;
1297}
1298
1299DEFUNSH (VTYSH_ALL,
1300 vtysh_log_file,
1301 vtysh_log_file_cmd,
1302 "log file FILENAME",
1303 "Logging control\n"
1304 "Logging to file\n"
1305 "Logging filename\n")
1306{
1307 return CMD_SUCCESS;
1308}
1309
1310DEFUNSH (VTYSH_ALL,
ajs274a4a42004-12-07 15:39:31 +00001311 vtysh_log_file_level,
1312 vtysh_log_file_level_cmd,
1313 "log file FILENAME "LOG_LEVELS,
1314 "Logging control\n"
1315 "Logging to file\n"
1316 "Logging filename\n"
1317 LOG_LEVEL_DESC)
1318{
1319 return CMD_SUCCESS;
1320}
1321
1322DEFUNSH (VTYSH_ALL,
hasso95e735b2004-08-26 13:08:30 +00001323 no_vtysh_log_file,
1324 no_vtysh_log_file_cmd,
1325 "no log file [FILENAME]",
1326 NO_STR
1327 "Logging control\n"
1328 "Cancel logging to file\n"
1329 "Logging file name\n")
1330{
1331 return CMD_SUCCESS;
1332}
1333
ajs274a4a42004-12-07 15:39:31 +00001334ALIAS_SH (VTYSH_ALL,
1335 no_vtysh_log_file,
1336 no_vtysh_log_file_level_cmd,
1337 "no log file FILENAME LEVEL",
1338 NO_STR
1339 "Logging control\n"
1340 "Cancel logging to file\n"
1341 "Logging file name\n"
1342 "Logging level\n")
1343
1344DEFUNSH (VTYSH_ALL,
1345 vtysh_log_monitor,
1346 vtysh_log_monitor_cmd,
1347 "log monitor",
1348 "Logging control\n"
1349 "Set terminal line (monitor) logging level\n")
1350{
1351 return CMD_SUCCESS;
1352}
1353
1354DEFUNSH (VTYSH_ALL,
1355 vtysh_log_monitor_level,
1356 vtysh_log_monitor_level_cmd,
1357 "log monitor "LOG_LEVELS,
1358 "Logging control\n"
1359 "Set terminal line (monitor) logging level\n"
1360 LOG_LEVEL_DESC)
1361{
1362 return CMD_SUCCESS;
1363}
1364
1365DEFUNSH (VTYSH_ALL,
1366 no_vtysh_log_monitor,
1367 no_vtysh_log_monitor_cmd,
1368 "no log monitor [LEVEL]",
1369 NO_STR
1370 "Logging control\n"
1371 "Disable terminal line (monitor) logging\n"
1372 "Logging level\n")
1373{
1374 return CMD_SUCCESS;
1375}
1376
hasso95e735b2004-08-26 13:08:30 +00001377DEFUNSH (VTYSH_ALL,
1378 vtysh_log_syslog,
1379 vtysh_log_syslog_cmd,
1380 "log syslog",
1381 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001382 "Set syslog logging level\n")
1383{
1384 return CMD_SUCCESS;
1385}
1386
1387DEFUNSH (VTYSH_ALL,
1388 vtysh_log_syslog_level,
1389 vtysh_log_syslog_level_cmd,
1390 "log syslog "LOG_LEVELS,
1391 "Logging control\n"
1392 "Set syslog logging level\n"
1393 LOG_LEVEL_DESC)
hasso95e735b2004-08-26 13:08:30 +00001394{
1395 return CMD_SUCCESS;
1396}
1397
1398DEFUNSH (VTYSH_ALL,
1399 no_vtysh_log_syslog,
1400 no_vtysh_log_syslog_cmd,
ajs274a4a42004-12-07 15:39:31 +00001401 "no log syslog [LEVEL]",
hasso95e735b2004-08-26 13:08:30 +00001402 NO_STR
1403 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001404 "Cancel logging to syslog\n"
1405 "Logging level\n")
hasso95e735b2004-08-26 13:08:30 +00001406{
1407 return CMD_SUCCESS;
1408}
1409
1410DEFUNSH (VTYSH_ALL,
ajs274a4a42004-12-07 15:39:31 +00001411 vtysh_log_facility,
1412 vtysh_log_facility_cmd,
1413 "log facility "LOG_FACILITIES,
hasso95e735b2004-08-26 13:08:30 +00001414 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001415 "Facility parameter for syslog messages\n"
1416 LOG_FACILITY_DESC)
1417
hasso95e735b2004-08-26 13:08:30 +00001418{
1419 return CMD_SUCCESS;
1420}
1421
1422DEFUNSH (VTYSH_ALL,
ajs274a4a42004-12-07 15:39:31 +00001423 no_vtysh_log_facility,
1424 no_vtysh_log_facility_cmd,
1425 "no log facility [FACILITY]",
hasso95e735b2004-08-26 13:08:30 +00001426 NO_STR
1427 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001428 "Reset syslog facility to default (daemon)\n"
1429 "Syslog facility\n")
1430
1431{
1432 return CMD_SUCCESS;
1433}
1434
1435DEFUNSH_DEPRECATED (VTYSH_ALL,
1436 vtysh_log_trap,
1437 vtysh_log_trap_cmd,
1438 "log trap "LOG_LEVELS,
1439 "Logging control\n"
1440 "(Deprecated) Set logging level and default for all destinations\n"
1441 LOG_LEVEL_DESC)
1442
1443{
1444 return CMD_SUCCESS;
1445}
1446
1447DEFUNSH_DEPRECATED (VTYSH_ALL,
1448 no_vtysh_log_trap,
1449 no_vtysh_log_trap_cmd,
1450 "no log trap [LEVEL]",
1451 NO_STR
1452 "Logging control\n"
1453 "Permit all logging information\n"
1454 "Logging level\n")
hasso95e735b2004-08-26 13:08:30 +00001455{
1456 return CMD_SUCCESS;
1457}
1458
1459DEFUNSH (VTYSH_ALL,
1460 vtysh_log_record_priority,
1461 vtysh_log_record_priority_cmd,
1462 "log record-priority",
1463 "Logging control\n"
1464 "Log the priority of the message within the message\n")
1465{
1466 return CMD_SUCCESS;
1467}
1468
1469DEFUNSH (VTYSH_ALL,
1470 no_vtysh_log_record_priority,
1471 no_vtysh_log_record_priority_cmd,
1472 "no log record-priority",
1473 NO_STR
1474 "Logging control\n"
1475 "Do not log the priority of the message within the message\n")
1476{
1477 return CMD_SUCCESS;
1478}
1479
hassoe7168df2004-10-03 20:11:32 +00001480DEFUNSH (VTYSH_ALL,
1481 vtysh_service_password_encrypt,
1482 vtysh_service_password_encrypt_cmd,
1483 "service password-encryption",
1484 "Set up miscellaneous service\n"
1485 "Enable encrypted passwords\n")
1486{
1487 return CMD_SUCCESS;
1488}
1489
1490DEFUNSH (VTYSH_ALL,
1491 no_vtysh_service_password_encrypt,
1492 no_vtysh_service_password_encrypt_cmd,
1493 "no service password-encryption",
1494 NO_STR
1495 "Set up miscellaneous service\n"
1496 "Enable encrypted passwords\n")
1497{
1498 return CMD_SUCCESS;
1499}
1500
1501DEFUNSH (VTYSH_ALL,
1502 vtysh_config_password,
1503 vtysh_password_cmd,
1504 "password (8|) WORD",
1505 "Assign the terminal connection password\n"
1506 "Specifies a HIDDEN password will follow\n"
1507 "dummy string \n"
1508 "The HIDDEN line password string\n")
1509{
1510 return CMD_SUCCESS;
1511}
1512
1513DEFUNSH (VTYSH_ALL,
1514 vtysh_password_text,
1515 vtysh_password_text_cmd,
1516 "password LINE",
1517 "Assign the terminal connection password\n"
1518 "The UNENCRYPTED (cleartext) line password\n")
1519{
1520 return CMD_SUCCESS;
1521}
1522
1523DEFUNSH (VTYSH_ALL,
1524 vtysh_config_enable_password,
1525 vtysh_enable_password_cmd,
1526 "enable password (8|) WORD",
1527 "Modify enable password parameters\n"
1528 "Assign the privileged level password\n"
1529 "Specifies a HIDDEN password will follow\n"
1530 "dummy string \n"
1531 "The HIDDEN 'enable' password string\n")
1532{
1533 return CMD_SUCCESS;
1534}
1535
1536DEFUNSH (VTYSH_ALL,
1537 vtysh_enable_password_text,
1538 vtysh_enable_password_text_cmd,
1539 "enable password LINE",
1540 "Modify enable password parameters\n"
1541 "Assign the privileged level password\n"
1542 "The UNENCRYPTED (cleartext) 'enable' password\n")
1543{
1544 return CMD_SUCCESS;
1545}
1546
1547DEFUNSH (VTYSH_ALL,
1548 no_vtysh_config_enable_password,
1549 no_vtysh_enable_password_cmd,
1550 "no enable password",
1551 NO_STR
1552 "Modify enable password parameters\n"
1553 "Assign the privileged level password\n")
1554{
1555 return CMD_SUCCESS;
1556}
1557
paul718e3742002-12-13 20:15:29 +00001558DEFUN (vtysh_write_terminal,
1559 vtysh_write_terminal_cmd,
1560 "write terminal",
1561 "Write running configuration to memory, network, or terminal\n"
1562 "Write to terminal\n")
1563{
1564 int ret;
1565 char line[] = "write terminal\n";
1566 FILE *fp = NULL;
1567
1568 if (vtysh_pager_name)
1569 {
paul4fc01e62002-12-13 20:49:00 +00001570 fp = popen (vtysh_pager_name, "w");
paul718e3742002-12-13 20:15:29 +00001571 if (fp == NULL)
1572 {
1573 perror ("popen");
1574 exit (1);
1575 }
1576 }
1577 else
1578 fp = stdout;
1579
1580 vty_out (vty, "Building configuration...%s", VTY_NEWLINE);
1581 vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE,
1582 VTY_NEWLINE);
hassoe7168df2004-10-03 20:11:32 +00001583 vty_out (vty, "!%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001584
1585 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_ZEBRA], line);
1586 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_RIP], line);
1587 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_RIPNG], line);
1588 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_OSPF], line);
1589 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_OSPF6], line);
1590 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_BGP], line);
hassoc25e4582003-12-23 10:39:08 +00001591 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_ISIS], line);
paul718e3742002-12-13 20:15:29 +00001592
hassoe7168df2004-10-03 20:11:32 +00001593 /* Integrate vtysh specific configuration. */
1594 vtysh_config_write ();
1595
paul718e3742002-12-13 20:15:29 +00001596 vtysh_config_dump (fp);
1597
1598 if (vtysh_pager_name && fp)
1599 {
1600 fflush (fp);
1601 if (pclose (fp) == -1)
1602 {
1603 perror ("pclose");
1604 exit (1);
1605 }
1606 fp = NULL;
1607 }
1608
1609 return CMD_SUCCESS;
1610}
1611
hassoe7168df2004-10-03 20:11:32 +00001612DEFUN (vtysh_integrated_config,
1613 vtysh_integrated_config_cmd,
1614 "service integrated-vtysh-config",
1615 "Set up miscellaneous service\n"
1616 "Write configuration into integrated file\n")
paul4fc01e62002-12-13 20:49:00 +00001617{
hassoe7168df2004-10-03 20:11:32 +00001618 vtysh_writeconfig_integrated = 1;
1619 return CMD_SUCCESS;
paul4fc01e62002-12-13 20:49:00 +00001620}
1621
hassoe7168df2004-10-03 20:11:32 +00001622DEFUN (no_vtysh_integrated_config,
1623 no_vtysh_integrated_config_cmd,
1624 "no service integrated-vtysh-config",
1625 NO_STR
1626 "Set up miscellaneous service\n"
1627 "Write configuration into integrated file\n")
paul4fc01e62002-12-13 20:49:00 +00001628{
hassoe7168df2004-10-03 20:11:32 +00001629 vtysh_writeconfig_integrated = 0;
1630 return CMD_SUCCESS;
paul4fc01e62002-12-13 20:49:00 +00001631}
1632
ajs274a4a42004-12-07 15:39:31 +00001633static int
1634write_config_integrated(void)
paul718e3742002-12-13 20:15:29 +00001635{
1636 int ret;
paul718e3742002-12-13 20:15:29 +00001637 char line[] = "write terminal\n";
1638 FILE *fp;
1639 char *integrate_sav = NULL;
1640
hasso95e735b2004-08-26 13:08:30 +00001641 integrate_sav = malloc (strlen (integrate_default) +
1642 strlen (CONF_BACKUP_EXT) + 1);
paul718e3742002-12-13 20:15:29 +00001643 strcpy (integrate_sav, integrate_default);
1644 strcat (integrate_sav, CONF_BACKUP_EXT);
1645
paul4fc01e62002-12-13 20:49:00 +00001646 fprintf (stdout,"Building Configuration...\n");
paul718e3742002-12-13 20:15:29 +00001647
hasso95e735b2004-08-26 13:08:30 +00001648 /* Move current configuration file to backup config file. */
paul718e3742002-12-13 20:15:29 +00001649 unlink (integrate_sav);
1650 rename (integrate_default, integrate_sav);
hasso95e735b2004-08-26 13:08:30 +00001651 free (integrate_sav);
paul4fc01e62002-12-13 20:49:00 +00001652
paul718e3742002-12-13 20:15:29 +00001653 fp = fopen (integrate_default, "w");
1654 if (fp == NULL)
1655 {
hasso95e735b2004-08-26 13:08:30 +00001656 fprintf (stdout,"%% Can't open configuration file %s.\n",
1657 integrate_default);
paul718e3742002-12-13 20:15:29 +00001658 return CMD_SUCCESS;
1659 }
paul718e3742002-12-13 20:15:29 +00001660
paul718e3742002-12-13 20:15:29 +00001661 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_ZEBRA], line);
1662 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_RIP], line);
1663 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_RIPNG], line);
1664 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_OSPF], line);
1665 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_OSPF6], line);
1666 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_BGP], line);
hassoc25e4582003-12-23 10:39:08 +00001667 ret = vtysh_client_config (&vtysh_client[VTYSH_INDEX_ISIS], line);
paul718e3742002-12-13 20:15:29 +00001668
1669 vtysh_config_dump (fp);
1670
1671 fclose (fp);
1672
gdtaa593d52003-12-22 20:15:53 +00001673 if (chmod (integrate_default, CONFIGFILE_MASK) != 0)
1674 {
1675 fprintf (stdout,"%% Can't chmod configuration file %s: %s (%d)\n",
ajs6099b3b2004-11-20 02:06:59 +00001676 integrate_default, safe_strerror(errno), errno);
gdtaa593d52003-12-22 20:15:53 +00001677 return CMD_WARNING;
1678 }
1679
paul4fc01e62002-12-13 20:49:00 +00001680 fprintf(stdout,"Integrated configuration saved to %s\n",integrate_default);
1681
1682 fprintf (stdout,"[OK]\n");
1683
paul718e3742002-12-13 20:15:29 +00001684 return CMD_SUCCESS;
1685}
1686
paul4fc01e62002-12-13 20:49:00 +00001687DEFUN (vtysh_write_memory,
1688 vtysh_write_memory_cmd,
1689 "write memory",
1690 "Write running configuration to memory, network, or terminal\n"
1691 "Write configuration to the file (same as write file)\n")
1692{
pauldfc0d9b2003-04-18 23:55:29 +00001693 int ret = CMD_SUCCESS;
paul4fc01e62002-12-13 20:49:00 +00001694 char line[] = "write memory\n";
1695
hassoe7168df2004-10-03 20:11:32 +00001696 /* If integrated Quagga.conf explicitely set. */
1697 if (vtysh_writeconfig_integrated)
1698 return write_config_integrated();
paul4fc01e62002-12-13 20:49:00 +00001699
1700 fprintf (stdout,"Building Configuration...\n");
1701
1702 ret = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_ZEBRA], line, stdout);
1703 ret = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_RIP], line, stdout);
1704 ret = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_RIPNG], line, stdout);
1705 ret = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_OSPF], line, stdout);
1706 ret = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_OSPF6], line, stdout);
1707 ret = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_BGP], line, stdout);
hassoc25e4582003-12-23 10:39:08 +00001708 ret = vtysh_client_execute (&vtysh_client[VTYSH_INDEX_ISIS], line, stdout);
hassoe7168df2004-10-03 20:11:32 +00001709
paul4fc01e62002-12-13 20:49:00 +00001710 fprintf (stdout,"[OK]\n");
1711
pauldfc0d9b2003-04-18 23:55:29 +00001712 return ret;
paul4fc01e62002-12-13 20:49:00 +00001713}
1714
paul718e3742002-12-13 20:15:29 +00001715ALIAS (vtysh_write_memory,
1716 vtysh_copy_runningconfig_startupconfig_cmd,
1717 "copy running-config startup-config",
1718 "Copy from one file to another\n"
1719 "Copy from current system configuration\n"
1720 "Copy to startup configuration\n")
1721
1722ALIAS (vtysh_write_memory,
1723 vtysh_write_file_cmd,
1724 "write file",
1725 "Write running configuration to memory, network, or terminal\n"
1726 "Write configuration to the file (same as write memory)\n")
1727
hasso4a6e2252003-05-25 11:51:29 +00001728ALIAS (vtysh_write_memory,
1729 vtysh_write_cmd,
1730 "write",
1731 "Write running configuration to memory, network, or terminal\n")
1732
paul718e3742002-12-13 20:15:29 +00001733ALIAS (vtysh_write_terminal,
1734 vtysh_show_running_config_cmd,
1735 "show running-config",
1736 SHOW_STR
1737 "Current operating configuration\n")
hassob094d262004-08-25 12:22:00 +00001738
hasso34553cc2004-08-27 13:56:39 +00001739DEFUN (vtysh_terminal_length,
1740 vtysh_terminal_length_cmd,
1741 "terminal length <0-512>",
1742 "Set terminal line parameters\n"
1743 "Set number of lines on a screen\n"
1744 "Number of lines on screen (0 for no pausing)\n")
1745{
1746 int lines;
1747 char *endptr = NULL;
1748 char default_pager[10];
1749
1750 lines = strtol (argv[0], &endptr, 10);
1751 if (lines < 0 || lines > 512 || *endptr != '\0')
1752 {
1753 vty_out (vty, "length is malformed%s", VTY_NEWLINE);
1754 return CMD_WARNING;
1755 }
1756
1757 if (vtysh_pager_name)
1758 {
1759 free (vtysh_pager_name);
1760 vtysh_pager_name = NULL;
1761 }
1762
1763 if (lines != 0)
1764 {
1765 snprintf(default_pager, 10, "more -%i", lines);
1766 vtysh_pager_name = strdup (default_pager);
1767 }
1768
1769 return CMD_SUCCESS;
1770}
1771
1772DEFUN (vtysh_terminal_no_length,
1773 vtysh_terminal_no_length_cmd,
1774 "terminal no length",
1775 "Set terminal line parameters\n"
1776 NO_STR
1777 "Set number of lines on a screen\n")
1778{
1779 if (vtysh_pager_name)
1780 {
1781 free (vtysh_pager_name);
1782 vtysh_pager_name = NULL;
1783 }
1784
1785 vtysh_pager_init();
1786 return CMD_SUCCESS;
1787}
1788
hassof2799e62004-10-28 17:43:11 +00001789DEFUN (vtysh_show_daemons,
1790 vtysh_show_daemons_cmd,
1791 "show daemons",
hassoe7168df2004-10-03 20:11:32 +00001792 SHOW_STR
1793 "Show list of running daemons\n")
1794{
1795 if ( vtysh_client[VTYSH_INDEX_ZEBRA].fd > 0 )
1796 vty_out(vty, " zebra");
1797 if ( vtysh_client[VTYSH_INDEX_RIP].fd > 0 )
1798 vty_out(vty, " ripd");
1799 if ( vtysh_client[VTYSH_INDEX_RIPNG].fd > 0 )
1800 vty_out(vty, " ripngd");
1801 if ( vtysh_client[VTYSH_INDEX_OSPF].fd > 0 )
1802 vty_out(vty, " ospfd");
1803 if ( vtysh_client[VTYSH_INDEX_OSPF6].fd > 0 )
1804 vty_out(vty, " ospf6d");
1805 if ( vtysh_client[VTYSH_INDEX_BGP].fd > 0 )
1806 vty_out(vty, " bgpd");
1807 if ( vtysh_client[VTYSH_INDEX_ISIS].fd > 0 )
1808 vty_out(vty, " isisd");
1809 vty_out(vty, "%s", VTY_NEWLINE);
1810
1811 return CMD_SUCCESS;
1812}
1813
paul718e3742002-12-13 20:15:29 +00001814/* Execute command in child process. */
ajs274a4a42004-12-07 15:39:31 +00001815static int
hasso5862ff52004-10-11 13:20:40 +00001816execute_command (const char *command, int argc, const char *arg1,
1817 const char *arg2)
paul718e3742002-12-13 20:15:29 +00001818{
1819 int ret;
1820 pid_t pid;
1821 int status;
1822
1823 /* Call fork(). */
1824 pid = fork ();
1825
1826 if (pid < 0)
1827 {
1828 /* Failure of fork(). */
ajs6099b3b2004-11-20 02:06:59 +00001829 fprintf (stderr, "Can't fork: %s\n", safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +00001830 exit (1);
1831 }
1832 else if (pid == 0)
1833 {
1834 /* This is child process. */
1835 switch (argc)
1836 {
1837 case 0:
hassofa2b17e2004-03-04 17:45:00 +00001838 ret = execlp (command, command, (const char *)NULL);
paul718e3742002-12-13 20:15:29 +00001839 break;
1840 case 1:
hassofa2b17e2004-03-04 17:45:00 +00001841 ret = execlp (command, command, arg1, (const char *)NULL);
paul718e3742002-12-13 20:15:29 +00001842 break;
1843 case 2:
hassofa2b17e2004-03-04 17:45:00 +00001844 ret = execlp (command, command, arg1, arg2, (const char *)NULL);
paul718e3742002-12-13 20:15:29 +00001845 break;
1846 }
1847
1848 /* When execlp suceed, this part is not executed. */
ajs6099b3b2004-11-20 02:06:59 +00001849 fprintf (stderr, "Can't execute %s: %s\n", command, safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +00001850 exit (1);
1851 }
1852 else
1853 {
1854 /* This is parent. */
1855 execute_flag = 1;
1856 ret = wait4 (pid, &status, 0, NULL);
1857 execute_flag = 0;
1858 }
1859 return 0;
1860}
1861
1862DEFUN (vtysh_ping,
1863 vtysh_ping_cmd,
1864 "ping WORD",
hasso4eeccf12003-06-25 10:49:55 +00001865 "Send echo messages\n"
paul718e3742002-12-13 20:15:29 +00001866 "Ping destination address or hostname\n")
1867{
1868 execute_command ("ping", 1, argv[0], NULL);
1869 return CMD_SUCCESS;
1870}
1871
hasso4eeccf12003-06-25 10:49:55 +00001872ALIAS (vtysh_ping,
1873 vtysh_ping_ip_cmd,
1874 "ping ip WORD",
1875 "Send echo messages\n"
1876 "IP echo\n"
1877 "Ping destination address or hostname\n")
1878
paul718e3742002-12-13 20:15:29 +00001879DEFUN (vtysh_traceroute,
1880 vtysh_traceroute_cmd,
1881 "traceroute WORD",
1882 "Trace route to destination\n"
1883 "Trace route to destination address or hostname\n")
1884{
1885 execute_command ("traceroute", 1, argv[0], NULL);
1886 return CMD_SUCCESS;
1887}
1888
hasso4eeccf12003-06-25 10:49:55 +00001889ALIAS (vtysh_traceroute,
1890 vtysh_traceroute_ip_cmd,
1891 "traceroute ip WORD",
1892 "Trace route to destination\n"
1893 "IP trace\n"
1894 "Trace route to destination address or hostname\n")
1895
1896#ifdef HAVE_IPV6
1897DEFUN (vtysh_ping6,
1898 vtysh_ping6_cmd,
1899 "ping ipv6 WORD",
1900 "Send echo messages\n"
1901 "IPv6 echo\n"
1902 "Ping destination address or hostname\n")
1903{
1904 execute_command ("ping6", 1, argv[0], NULL);
1905 return CMD_SUCCESS;
1906}
1907
1908DEFUN (vtysh_traceroute6,
1909 vtysh_traceroute6_cmd,
1910 "traceroute ipv6 WORD",
1911 "Trace route to destination\n"
1912 "IPv6 trace\n"
1913 "Trace route to destination address or hostname\n")
1914{
1915 execute_command ("traceroute6", 1, argv[0], NULL);
1916 return CMD_SUCCESS;
1917}
1918#endif
1919
paul718e3742002-12-13 20:15:29 +00001920DEFUN (vtysh_telnet,
1921 vtysh_telnet_cmd,
1922 "telnet WORD",
1923 "Open a telnet connection\n"
1924 "IP address or hostname of a remote system\n")
1925{
1926 execute_command ("telnet", 1, argv[0], NULL);
1927 return CMD_SUCCESS;
1928}
1929
1930DEFUN (vtysh_telnet_port,
1931 vtysh_telnet_port_cmd,
1932 "telnet WORD PORT",
1933 "Open a telnet connection\n"
1934 "IP address or hostname of a remote system\n"
1935 "TCP Port number\n")
1936{
1937 execute_command ("telnet", 2, argv[0], argv[1]);
1938 return CMD_SUCCESS;
1939}
1940
paul5087df52003-01-25 06:56:09 +00001941DEFUN (vtysh_ssh,
1942 vtysh_ssh_cmd,
1943 "ssh WORD",
1944 "Open an ssh connection\n"
1945 "[user@]host\n")
1946{
1947 execute_command ("ssh", 1, argv[0], NULL);
1948 return CMD_SUCCESS;
1949}
1950
paul718e3742002-12-13 20:15:29 +00001951DEFUN (vtysh_start_shell,
1952 vtysh_start_shell_cmd,
1953 "start-shell",
1954 "Start UNIX shell\n")
1955{
1956 execute_command ("sh", 0, NULL, NULL);
1957 return CMD_SUCCESS;
1958}
1959
1960DEFUN (vtysh_start_bash,
1961 vtysh_start_bash_cmd,
1962 "start-shell bash",
1963 "Start UNIX shell\n"
1964 "Start bash\n")
1965{
1966 execute_command ("bash", 0, NULL, NULL);
1967 return CMD_SUCCESS;
1968}
1969
1970DEFUN (vtysh_start_zsh,
1971 vtysh_start_zsh_cmd,
1972 "start-shell zsh",
1973 "Start UNIX shell\n"
1974 "Start Z shell\n")
1975{
1976 execute_command ("zsh", 0, NULL, NULL);
1977 return CMD_SUCCESS;
1978}
hassob094d262004-08-25 12:22:00 +00001979
ajs274a4a42004-12-07 15:39:31 +00001980static void
paul718e3742002-12-13 20:15:29 +00001981vtysh_install_default (enum node_type node)
1982{
1983 install_element (node, &config_list_cmd);
1984}
1985
1986/* Making connection to protocol daemon. */
ajs274a4a42004-12-07 15:39:31 +00001987static int
hassodda09522004-10-07 21:40:25 +00001988vtysh_connect (struct vtysh_client *vclient, const char *path)
paul718e3742002-12-13 20:15:29 +00001989{
1990 int ret;
1991 int sock, len;
1992 struct sockaddr_un addr;
1993 struct stat s_stat;
paul718e3742002-12-13 20:15:29 +00001994
1995 memset (vclient, 0, sizeof (struct vtysh_client));
1996 vclient->fd = -1;
1997
1998 /* Stat socket to see if we have permission to access it. */
paul718e3742002-12-13 20:15:29 +00001999 ret = stat (path, &s_stat);
2000 if (ret < 0 && errno != ENOENT)
2001 {
2002 fprintf (stderr, "vtysh_connect(%s): stat = %s\n",
ajs6099b3b2004-11-20 02:06:59 +00002003 path, safe_strerror(errno));
paul718e3742002-12-13 20:15:29 +00002004 exit(1);
2005 }
2006
2007 if (ret >= 0)
2008 {
2009 if (! S_ISSOCK(s_stat.st_mode))
2010 {
2011 fprintf (stderr, "vtysh_connect(%s): Not a socket\n",
2012 path);
2013 exit (1);
2014 }
2015
paul718e3742002-12-13 20:15:29 +00002016 }
2017
2018 sock = socket (AF_UNIX, SOCK_STREAM, 0);
2019 if (sock < 0)
2020 {
2021#ifdef DEBUG
hasso95e735b2004-08-26 13:08:30 +00002022 fprintf(stderr, "vtysh_connect(%s): socket = %s\n", path,
ajs6099b3b2004-11-20 02:06:59 +00002023 safe_strerror(errno));
paul718e3742002-12-13 20:15:29 +00002024#endif /* DEBUG */
2025 return -1;
2026 }
2027
2028 memset (&addr, 0, sizeof (struct sockaddr_un));
2029 addr.sun_family = AF_UNIX;
2030 strncpy (addr.sun_path, path, strlen (path));
2031#ifdef HAVE_SUN_LEN
2032 len = addr.sun_len = SUN_LEN(&addr);
2033#else
2034 len = sizeof (addr.sun_family) + strlen (addr.sun_path);
2035#endif /* HAVE_SUN_LEN */
2036
2037 ret = connect (sock, (struct sockaddr *) &addr, len);
2038 if (ret < 0)
2039 {
2040#ifdef DEBUG
hasso95e735b2004-08-26 13:08:30 +00002041 fprintf(stderr, "vtysh_connect(%s): connect = %s\n", path,
ajs6099b3b2004-11-20 02:06:59 +00002042 safe_strerror(errno));
paul718e3742002-12-13 20:15:29 +00002043#endif /* DEBUG */
2044 close (sock);
2045 return -1;
2046 }
2047 vclient->fd = sock;
2048
2049 return 0;
2050}
2051
2052void
2053vtysh_connect_all()
2054{
2055 /* Clear each daemons client structure. */
paulfe067782003-04-07 16:10:05 +00002056 vtysh_connect (&vtysh_client[VTYSH_INDEX_ZEBRA], ZEBRA_VTYSH_PATH);
2057 vtysh_connect (&vtysh_client[VTYSH_INDEX_RIP], RIP_VTYSH_PATH);
2058 vtysh_connect (&vtysh_client[VTYSH_INDEX_RIPNG], RIPNG_VTYSH_PATH);
2059 vtysh_connect (&vtysh_client[VTYSH_INDEX_OSPF], OSPF_VTYSH_PATH);
2060 vtysh_connect (&vtysh_client[VTYSH_INDEX_OSPF6], OSPF6_VTYSH_PATH);
2061 vtysh_connect (&vtysh_client[VTYSH_INDEX_BGP], BGP_VTYSH_PATH);
hassoc25e4582003-12-23 10:39:08 +00002062 vtysh_connect (&vtysh_client[VTYSH_INDEX_ISIS], ISIS_VTYSH_PATH);
paul718e3742002-12-13 20:15:29 +00002063}
2064
hasso95e735b2004-08-26 13:08:30 +00002065/* To disable readline's filename completion. */
ajs274a4a42004-12-07 15:39:31 +00002066static char *
pauldfc0d9b2003-04-18 23:55:29 +00002067vtysh_completion_entry_function (const char *ignore, int invoking_key)
paul718e3742002-12-13 20:15:29 +00002068{
pauldfc0d9b2003-04-18 23:55:29 +00002069 return NULL;
paul718e3742002-12-13 20:15:29 +00002070}
2071
2072void
2073vtysh_readline_init ()
2074{
2075 /* readline related settings. */
2076 rl_bind_key ('?', vtysh_rl_describe);
paul68980082003-03-25 05:07:42 +00002077 rl_completion_entry_function = vtysh_completion_entry_function;
paul718e3742002-12-13 20:15:29 +00002078 rl_attempted_completion_function = (CPPFunction *)new_completion;
2079 /* do not append space after completion. It will be appended
hasso95e735b2004-08-26 13:08:30 +00002080 * in new_completion() function explicitly. */
paul718e3742002-12-13 20:15:29 +00002081 rl_completion_append_character = '\0';
2082}
2083
2084char *
2085vtysh_prompt ()
2086{
2087 struct utsname names;
2088 static char buf[100];
2089 const char*hostname;
2090 extern struct host host;
2091
2092 hostname = host.name;
2093
2094 if (!hostname)
2095 {
2096 uname (&names);
2097 hostname = names.nodename;
2098 }
2099
2100 snprintf (buf, sizeof buf, cmd_prompt (vty->node), hostname);
2101
2102 return buf;
2103}
2104
2105void
2106vtysh_init_vty ()
2107{
2108 /* Make vty structure. */
2109 vty = vty_new ();
2110 vty->type = VTY_SHELL;
2111 vty->node = VIEW_NODE;
2112
2113 /* Initialize commands. */
2114 cmd_init (0);
2115
2116 /* Install nodes. */
2117 install_node (&bgp_node, NULL);
2118 install_node (&rip_node, NULL);
2119 install_node (&interface_node, NULL);
2120 install_node (&rmap_node, NULL);
2121 install_node (&zebra_node, NULL);
2122 install_node (&bgp_vpnv4_node, NULL);
2123 install_node (&bgp_ipv4_node, NULL);
2124 install_node (&bgp_ipv4m_node, NULL);
2125/* #ifdef HAVE_IPV6 */
2126 install_node (&bgp_ipv6_node, NULL);
2127/* #endif */
2128 install_node (&ospf_node, NULL);
2129/* #ifdef HAVE_IPV6 */
2130 install_node (&ripng_node, NULL);
2131 install_node (&ospf6_node, NULL);
2132/* #endif */
2133 install_node (&keychain_node, NULL);
2134 install_node (&keychain_key_node, NULL);
hassoc25e4582003-12-23 10:39:08 +00002135 install_node (&isis_node, NULL);
hassoe7168df2004-10-03 20:11:32 +00002136 install_node (&vty_node, NULL);
paul718e3742002-12-13 20:15:29 +00002137
2138 vtysh_install_default (VIEW_NODE);
2139 vtysh_install_default (ENABLE_NODE);
2140 vtysh_install_default (CONFIG_NODE);
2141 vtysh_install_default (BGP_NODE);
2142 vtysh_install_default (RIP_NODE);
2143 vtysh_install_default (INTERFACE_NODE);
2144 vtysh_install_default (RMAP_NODE);
2145 vtysh_install_default (ZEBRA_NODE);
2146 vtysh_install_default (BGP_VPNV4_NODE);
2147 vtysh_install_default (BGP_IPV4_NODE);
2148 vtysh_install_default (BGP_IPV4M_NODE);
2149 vtysh_install_default (BGP_IPV6_NODE);
2150 vtysh_install_default (OSPF_NODE);
2151 vtysh_install_default (RIPNG_NODE);
2152 vtysh_install_default (OSPF6_NODE);
hassoc25e4582003-12-23 10:39:08 +00002153 vtysh_install_default (ISIS_NODE);
paul718e3742002-12-13 20:15:29 +00002154 vtysh_install_default (KEYCHAIN_NODE);
2155 vtysh_install_default (KEYCHAIN_KEY_NODE);
hassoe7168df2004-10-03 20:11:32 +00002156 vtysh_install_default (VTY_NODE);
paul718e3742002-12-13 20:15:29 +00002157
2158 install_element (VIEW_NODE, &vtysh_enable_cmd);
2159 install_element (ENABLE_NODE, &vtysh_config_terminal_cmd);
2160 install_element (ENABLE_NODE, &vtysh_disable_cmd);
2161
2162 /* "exit" command. */
2163 install_element (VIEW_NODE, &vtysh_exit_all_cmd);
2164 install_element (VIEW_NODE, &vtysh_quit_all_cmd);
2165 install_element (CONFIG_NODE, &vtysh_exit_all_cmd);
2166 /* install_element (CONFIG_NODE, &vtysh_quit_all_cmd); */
2167 install_element (ENABLE_NODE, &vtysh_exit_all_cmd);
2168 install_element (ENABLE_NODE, &vtysh_quit_all_cmd);
2169 install_element (RIP_NODE, &vtysh_exit_ripd_cmd);
2170 install_element (RIP_NODE, &vtysh_quit_ripd_cmd);
paul68980082003-03-25 05:07:42 +00002171 install_element (RIPNG_NODE, &vtysh_exit_ripngd_cmd);
2172 install_element (RIPNG_NODE, &vtysh_quit_ripngd_cmd);
paul718e3742002-12-13 20:15:29 +00002173 install_element (OSPF_NODE, &vtysh_exit_ospfd_cmd);
2174 install_element (OSPF_NODE, &vtysh_quit_ospfd_cmd);
paul68980082003-03-25 05:07:42 +00002175 install_element (OSPF6_NODE, &vtysh_exit_ospf6d_cmd);
2176 install_element (OSPF6_NODE, &vtysh_quit_ospf6d_cmd);
paul718e3742002-12-13 20:15:29 +00002177 install_element (BGP_NODE, &vtysh_exit_bgpd_cmd);
2178 install_element (BGP_NODE, &vtysh_quit_bgpd_cmd);
2179 install_element (BGP_VPNV4_NODE, &vtysh_exit_bgpd_cmd);
2180 install_element (BGP_VPNV4_NODE, &vtysh_quit_bgpd_cmd);
2181 install_element (BGP_IPV4_NODE, &vtysh_exit_bgpd_cmd);
2182 install_element (BGP_IPV4_NODE, &vtysh_quit_bgpd_cmd);
2183 install_element (BGP_IPV4M_NODE, &vtysh_exit_bgpd_cmd);
2184 install_element (BGP_IPV4M_NODE, &vtysh_quit_bgpd_cmd);
2185 install_element (BGP_IPV6_NODE, &vtysh_exit_bgpd_cmd);
2186 install_element (BGP_IPV6_NODE, &vtysh_quit_bgpd_cmd);
hassoc25e4582003-12-23 10:39:08 +00002187 install_element (ISIS_NODE, &vtysh_exit_isisd_cmd);
2188 install_element (ISIS_NODE, &vtysh_quit_isisd_cmd);
paul718e3742002-12-13 20:15:29 +00002189 install_element (KEYCHAIN_NODE, &vtysh_exit_ripd_cmd);
2190 install_element (KEYCHAIN_NODE, &vtysh_quit_ripd_cmd);
2191 install_element (KEYCHAIN_KEY_NODE, &vtysh_exit_ripd_cmd);
2192 install_element (KEYCHAIN_KEY_NODE, &vtysh_quit_ripd_cmd);
2193 install_element (RMAP_NODE, &vtysh_exit_rmap_cmd);
2194 install_element (RMAP_NODE, &vtysh_quit_rmap_cmd);
hassoe7168df2004-10-03 20:11:32 +00002195 install_element (VTY_NODE, &vtysh_exit_line_vty_cmd);
2196 install_element (VTY_NODE, &vtysh_quit_line_vty_cmd);
paul718e3742002-12-13 20:15:29 +00002197
2198 /* "end" command. */
2199 install_element (CONFIG_NODE, &vtysh_end_all_cmd);
2200 install_element (ENABLE_NODE, &vtysh_end_all_cmd);
2201 install_element (RIP_NODE, &vtysh_end_all_cmd);
2202 install_element (RIPNG_NODE, &vtysh_end_all_cmd);
2203 install_element (OSPF_NODE, &vtysh_end_all_cmd);
2204 install_element (OSPF6_NODE, &vtysh_end_all_cmd);
2205 install_element (BGP_NODE, &vtysh_end_all_cmd);
2206 install_element (BGP_IPV4_NODE, &vtysh_end_all_cmd);
2207 install_element (BGP_IPV4M_NODE, &vtysh_end_all_cmd);
2208 install_element (BGP_VPNV4_NODE, &vtysh_end_all_cmd);
2209 install_element (BGP_IPV6_NODE, &vtysh_end_all_cmd);
hassoc25e4582003-12-23 10:39:08 +00002210 install_element (ISIS_NODE, &vtysh_end_all_cmd);
paul718e3742002-12-13 20:15:29 +00002211 install_element (KEYCHAIN_NODE, &vtysh_end_all_cmd);
2212 install_element (KEYCHAIN_KEY_NODE, &vtysh_end_all_cmd);
2213 install_element (RMAP_NODE, &vtysh_end_all_cmd);
hassoe7168df2004-10-03 20:11:32 +00002214 install_element (VTY_NODE, &vtysh_end_all_cmd);
paul718e3742002-12-13 20:15:29 +00002215
paul338a9912003-03-01 15:44:10 +00002216 install_element (INTERFACE_NODE, &interface_desc_cmd);
paul464dc8d2003-03-28 02:25:45 +00002217 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
paul718e3742002-12-13 20:15:29 +00002218 install_element (INTERFACE_NODE, &vtysh_end_all_cmd);
2219 install_element (INTERFACE_NODE, &vtysh_exit_interface_cmd);
2220 install_element (INTERFACE_NODE, &vtysh_quit_interface_cmd);
2221 install_element (CONFIG_NODE, &router_rip_cmd);
2222#ifdef HAVE_IPV6
2223 install_element (CONFIG_NODE, &router_ripng_cmd);
2224#endif
2225 install_element (CONFIG_NODE, &router_ospf_cmd);
2226#ifdef HAVE_IPV6
2227 install_element (CONFIG_NODE, &router_ospf6_cmd);
2228#endif
hassoc25e4582003-12-23 10:39:08 +00002229 install_element (CONFIG_NODE, &router_isis_cmd);
paul718e3742002-12-13 20:15:29 +00002230 install_element (CONFIG_NODE, &router_bgp_cmd);
2231 install_element (BGP_NODE, &address_family_vpnv4_cmd);
2232 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
2233 install_element (BGP_NODE, &address_family_ipv4_unicast_cmd);
2234 install_element (BGP_NODE, &address_family_ipv4_multicast_cmd);
2235#ifdef HAVE_IPV6
2236 install_element (BGP_NODE, &address_family_ipv6_cmd);
2237 install_element (BGP_NODE, &address_family_ipv6_unicast_cmd);
2238#endif
2239 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
2240 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
2241 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
2242 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
2243 install_element (CONFIG_NODE, &key_chain_cmd);
2244 install_element (CONFIG_NODE, &route_map_cmd);
hassoe7168df2004-10-03 20:11:32 +00002245 install_element (CONFIG_NODE, &vtysh_line_vty_cmd);
paul718e3742002-12-13 20:15:29 +00002246 install_element (KEYCHAIN_NODE, &key_cmd);
2247 install_element (KEYCHAIN_NODE, &key_chain_cmd);
2248 install_element (KEYCHAIN_KEY_NODE, &key_chain_cmd);
2249 install_element (CONFIG_NODE, &vtysh_interface_cmd);
paul32d24632003-05-23 09:25:20 +00002250 install_element (CONFIG_NODE, &vtysh_no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00002251 install_element (ENABLE_NODE, &vtysh_show_running_config_cmd);
2252 install_element (ENABLE_NODE, &vtysh_copy_runningconfig_startupconfig_cmd);
2253 install_element (ENABLE_NODE, &vtysh_write_file_cmd);
hasso4a6e2252003-05-25 11:51:29 +00002254 install_element (ENABLE_NODE, &vtysh_write_cmd);
paul718e3742002-12-13 20:15:29 +00002255
hasso95e735b2004-08-26 13:08:30 +00002256 /* "write terminal" command. */
paul718e3742002-12-13 20:15:29 +00002257 install_element (ENABLE_NODE, &vtysh_write_terminal_cmd);
hassoe7168df2004-10-03 20:11:32 +00002258
2259 install_element (CONFIG_NODE, &vtysh_integrated_config_cmd);
2260 install_element (CONFIG_NODE, &no_vtysh_integrated_config_cmd);
paul718e3742002-12-13 20:15:29 +00002261
hasso95e735b2004-08-26 13:08:30 +00002262 /* "write memory" command. */
paul718e3742002-12-13 20:15:29 +00002263 install_element (ENABLE_NODE, &vtysh_write_memory_cmd);
paul718e3742002-12-13 20:15:29 +00002264
hasso34553cc2004-08-27 13:56:39 +00002265 install_element (VIEW_NODE, &vtysh_terminal_length_cmd);
2266 install_element (ENABLE_NODE, &vtysh_terminal_length_cmd);
2267 install_element (VIEW_NODE, &vtysh_terminal_no_length_cmd);
2268 install_element (ENABLE_NODE, &vtysh_terminal_no_length_cmd);
hassof2799e62004-10-28 17:43:11 +00002269 install_element (VIEW_NODE, &vtysh_show_daemons_cmd);
2270 install_element (ENABLE_NODE, &vtysh_show_daemons_cmd);
hasso34553cc2004-08-27 13:56:39 +00002271
paul718e3742002-12-13 20:15:29 +00002272 install_element (VIEW_NODE, &vtysh_ping_cmd);
hasso4eeccf12003-06-25 10:49:55 +00002273 install_element (VIEW_NODE, &vtysh_ping_ip_cmd);
paul718e3742002-12-13 20:15:29 +00002274 install_element (VIEW_NODE, &vtysh_traceroute_cmd);
hasso4eeccf12003-06-25 10:49:55 +00002275 install_element (VIEW_NODE, &vtysh_traceroute_ip_cmd);
2276#ifdef HAVE_IPV6
2277 install_element (VIEW_NODE, &vtysh_ping6_cmd);
2278 install_element (VIEW_NODE, &vtysh_traceroute6_cmd);
2279#endif
paul718e3742002-12-13 20:15:29 +00002280 install_element (VIEW_NODE, &vtysh_telnet_cmd);
2281 install_element (VIEW_NODE, &vtysh_telnet_port_cmd);
paul5087df52003-01-25 06:56:09 +00002282 install_element (VIEW_NODE, &vtysh_ssh_cmd);
paul718e3742002-12-13 20:15:29 +00002283 install_element (ENABLE_NODE, &vtysh_ping_cmd);
hasso4eeccf12003-06-25 10:49:55 +00002284 install_element (ENABLE_NODE, &vtysh_ping_ip_cmd);
paul718e3742002-12-13 20:15:29 +00002285 install_element (ENABLE_NODE, &vtysh_traceroute_cmd);
hasso4eeccf12003-06-25 10:49:55 +00002286 install_element (ENABLE_NODE, &vtysh_traceroute_ip_cmd);
2287#ifdef HAVE_IPV6
2288 install_element (ENABLE_NODE, &vtysh_ping6_cmd);
2289 install_element (ENABLE_NODE, &vtysh_traceroute6_cmd);
2290#endif
paul718e3742002-12-13 20:15:29 +00002291 install_element (ENABLE_NODE, &vtysh_telnet_cmd);
2292 install_element (ENABLE_NODE, &vtysh_telnet_port_cmd);
hasso67e29ab2004-08-26 22:21:31 +00002293 install_element (ENABLE_NODE, &vtysh_ssh_cmd);
paul718e3742002-12-13 20:15:29 +00002294 install_element (ENABLE_NODE, &vtysh_start_shell_cmd);
2295 install_element (ENABLE_NODE, &vtysh_start_bash_cmd);
2296 install_element (ENABLE_NODE, &vtysh_start_zsh_cmd);
2297
paul718e3742002-12-13 20:15:29 +00002298 install_element (CONFIG_NODE, &vtysh_log_stdout_cmd);
ajs274a4a42004-12-07 15:39:31 +00002299 install_element (CONFIG_NODE, &vtysh_log_stdout_level_cmd);
paul718e3742002-12-13 20:15:29 +00002300 install_element (CONFIG_NODE, &no_vtysh_log_stdout_cmd);
2301 install_element (CONFIG_NODE, &vtysh_log_file_cmd);
ajs274a4a42004-12-07 15:39:31 +00002302 install_element (CONFIG_NODE, &vtysh_log_file_level_cmd);
paul718e3742002-12-13 20:15:29 +00002303 install_element (CONFIG_NODE, &no_vtysh_log_file_cmd);
ajs274a4a42004-12-07 15:39:31 +00002304 install_element (CONFIG_NODE, &no_vtysh_log_file_level_cmd);
2305 install_element (CONFIG_NODE, &vtysh_log_monitor_cmd);
2306 install_element (CONFIG_NODE, &vtysh_log_monitor_level_cmd);
2307 install_element (CONFIG_NODE, &no_vtysh_log_monitor_cmd);
paul718e3742002-12-13 20:15:29 +00002308 install_element (CONFIG_NODE, &vtysh_log_syslog_cmd);
ajs274a4a42004-12-07 15:39:31 +00002309 install_element (CONFIG_NODE, &vtysh_log_syslog_level_cmd);
paul718e3742002-12-13 20:15:29 +00002310 install_element (CONFIG_NODE, &no_vtysh_log_syslog_cmd);
2311 install_element (CONFIG_NODE, &vtysh_log_trap_cmd);
2312 install_element (CONFIG_NODE, &no_vtysh_log_trap_cmd);
ajs274a4a42004-12-07 15:39:31 +00002313 install_element (CONFIG_NODE, &vtysh_log_facility_cmd);
2314 install_element (CONFIG_NODE, &no_vtysh_log_facility_cmd);
paul718e3742002-12-13 20:15:29 +00002315 install_element (CONFIG_NODE, &vtysh_log_record_priority_cmd);
2316 install_element (CONFIG_NODE, &no_vtysh_log_record_priority_cmd);
hassoe7168df2004-10-03 20:11:32 +00002317
2318 install_element (CONFIG_NODE, &vtysh_service_password_encrypt_cmd);
2319 install_element (CONFIG_NODE, &no_vtysh_service_password_encrypt_cmd);
2320
2321 install_element (CONFIG_NODE, &vtysh_password_cmd);
2322 install_element (CONFIG_NODE, &vtysh_password_text_cmd);
2323 install_element (CONFIG_NODE, &vtysh_enable_password_cmd);
2324 install_element (CONFIG_NODE, &vtysh_enable_password_text_cmd);
2325 install_element (CONFIG_NODE, &no_vtysh_enable_password_cmd);
2326
paul718e3742002-12-13 20:15:29 +00002327}