blob: 5df562ca853082686e5a362daf3a4e318f131e46 [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;
ajsb1aa1472005-01-28 21:11:46 +000048 const char *name;
49 int flag;
50 const char *path;
51} vtysh_client[] =
52{
53 { .fd = -1, .name = "zebra", .flag = VTYSH_ZEBRA, .path = ZEBRA_VTYSH_PATH},
54 { .fd = -1, .name = "ripd", .flag = VTYSH_RIPD, .path = RIP_VTYSH_PATH},
55 { .fd = -1, .name = "ripngd", .flag = VTYSH_RIPNGD, .path = RIPNG_VTYSH_PATH},
56 { .fd = -1, .name = "ospfd", .flag = VTYSH_OSPFD, .path = OSPF_VTYSH_PATH},
57 { .fd = -1, .name = "ospf6d", .flag = VTYSH_OSPF6D, .path = OSPF6_VTYSH_PATH},
58 { .fd = -1, .name = "bgpd", .flag = VTYSH_BGPD, .path = BGP_VTYSH_PATH},
59 { .fd = -1, .name = "isisd", .flag = VTYSH_ISISD, .path = ISIS_VTYSH_PATH},
60};
61
62#define VTYSH_INDEX_MAX (sizeof(vtysh_client)/sizeof(vtysh_client[0]))
63
64/* We need direct access to ripd to implement vtysh_exit_ripd_only. */
65static struct vtysh_client *ripd_client = NULL;
66
hassob094d262004-08-25 12:22:00 +000067
hassoe7168df2004-10-03 20:11:32 +000068/* Using integrated config from Quagga.conf. Default is no. */
69int vtysh_writeconfig_integrated = 0;
70
71extern char config_default[];
72
ajs274a4a42004-12-07 15:39:31 +000073static void
paul718e3742002-12-13 20:15:29 +000074vclient_close (struct vtysh_client *vclient)
75{
ajsb1aa1472005-01-28 21:11:46 +000076 if (vclient->fd >= 0)
77 {
78 fprintf(stderr,
79 "Warning: closing connection to %s because of an I/O error!\n",
80 vclient->name);
81 close (vclient->fd);
82 vclient->fd = -1;
83 }
paul718e3742002-12-13 20:15:29 +000084}
85
paul718e3742002-12-13 20:15:29 +000086/* Following filled with debug code to trace a problematic condition
hasso95e735b2004-08-26 13:08:30 +000087 * under load - it SHOULD handle it. */
paul718e3742002-12-13 20:15:29 +000088#define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): "
ajs274a4a42004-12-07 15:39:31 +000089static int
paul718e3742002-12-13 20:15:29 +000090vtysh_client_config (struct vtysh_client *vclient, char *line)
91{
92 int ret;
93 char *buf;
94 size_t bufsz;
95 char *pbuf;
96 size_t left;
97 char *eoln;
98 int nbytes;
99 int i;
100 int readln;
101
102 if (vclient->fd < 0)
103 return CMD_SUCCESS;
104
105 ret = write (vclient->fd, line, strlen (line) + 1);
106 if (ret <= 0)
107 {
108 vclient_close (vclient);
109 return CMD_SUCCESS;
110 }
111
hasso95e735b2004-08-26 13:08:30 +0000112 /* Allow enough room for buffer to read more than a few pages from socket. */
paule3d29b52003-01-23 18:05:42 +0000113 bufsz = 5 * getpagesize() + 1;
paul718e3742002-12-13 20:15:29 +0000114 buf = XMALLOC(MTYPE_TMP, bufsz);
115 memset(buf, 0, bufsz);
116 pbuf = buf;
117
118 while (1)
119 {
120 if (pbuf >= ((buf + bufsz) -1))
121 {
122 fprintf (stderr, ERR_WHERE_STRING \
123 "warning - pbuf beyond buffer end.\n");
124 return CMD_WARNING;
125 }
126
127 readln = (buf + bufsz) - pbuf - 1;
128 nbytes = read (vclient->fd, pbuf, readln);
129
130 if (nbytes <= 0)
131 {
132
133 if (errno == EINTR)
134 continue;
135
136 fprintf(stderr, ERR_WHERE_STRING "(%u)", errno);
137 perror("");
138
139 if (errno == EAGAIN || errno == EIO)
140 continue;
141
142 vclient_close (vclient);
143 XFREE(MTYPE_TMP, buf);
144 return CMD_SUCCESS;
145 }
146
147 pbuf[nbytes] = '\0';
148
149 if (nbytes >= 4)
150 {
151 i = nbytes - 4;
152 if (pbuf[i] == '\0' && pbuf[i + 1] == '\0' && pbuf[i + 2] == '\0')
153 {
154 ret = pbuf[i + 3];
155 break;
156 }
157 }
158 pbuf += nbytes;
159
160 /* See if a line exists in buffer, if so parse and consume it, and
hasso95e735b2004-08-26 13:08:30 +0000161 * reset read position. */
paul718e3742002-12-13 20:15:29 +0000162 if ((eoln = strrchr(buf, '\n')) == NULL)
163 continue;
164
165 if (eoln >= ((buf + bufsz) - 1))
166 {
167 fprintf (stderr, ERR_WHERE_STRING \
168 "warning - eoln beyond buffer end.\n");
169 }
170 vtysh_config_parse(buf);
171
172 eoln++;
173 left = (size_t)(buf + bufsz - eoln);
174 memmove(buf, eoln, left);
175 buf[bufsz-1] = '\0';
176 pbuf = buf + strlen(buf);
177 }
178
hasso95e735b2004-08-26 13:08:30 +0000179 /* Parse anything left in the buffer. */
hassoe7168df2004-10-03 20:11:32 +0000180
paul718e3742002-12-13 20:15:29 +0000181 vtysh_config_parse (buf);
182
183 XFREE(MTYPE_TMP, buf);
184 return ret;
185}
186
ajs274a4a42004-12-07 15:39:31 +0000187static int
hassodda09522004-10-07 21:40:25 +0000188vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp)
paul718e3742002-12-13 20:15:29 +0000189{
190 int ret;
191 char buf[1001];
192 int nbytes;
paul2852de12004-09-17 06:52:16 +0000193 int i;
194 int numnulls = 0;
paul718e3742002-12-13 20:15:29 +0000195
196 if (vclient->fd < 0)
197 return CMD_SUCCESS;
198
199 ret = write (vclient->fd, line, strlen (line) + 1);
200 if (ret <= 0)
201 {
202 vclient_close (vclient);
203 return CMD_SUCCESS;
204 }
205
206 while (1)
207 {
208 nbytes = read (vclient->fd, buf, sizeof(buf)-1);
209
210 if (nbytes <= 0 && errno != EINTR)
211 {
212 vclient_close (vclient);
213 return CMD_SUCCESS;
214 }
215
216 if (nbytes > 0)
217 {
ajs85fb1e62004-11-11 14:03:39 +0000218 if ((numnulls == 3) && (nbytes == 1))
219 return buf[0];
220
paul718e3742002-12-13 20:15:29 +0000221 buf[nbytes] = '\0';
ajs85fb1e62004-11-11 14:03:39 +0000222 fputs (buf, fp);
paul718e3742002-12-13 20:15:29 +0000223 fflush (fp);
paul2852de12004-09-17 06:52:16 +0000224
paul0921d482004-10-11 18:21:55 +0000225 /* check for trailling \0\0\0<ret code>,
226 * even if split across reads
227 * (see lib/vty.c::vtysh_read)
228 */
paul2852de12004-09-17 06:52:16 +0000229 if (nbytes >= 4)
230 {
231 i = nbytes-4;
232 numnulls = 0;
233 }
234 else
235 i = 0;
236
paul0921d482004-10-11 18:21:55 +0000237 while (i < nbytes && numnulls < 3)
paul2852de12004-09-17 06:52:16 +0000238 {
239 if (buf[i++] == '\0')
240 numnulls++;
241 else
ajs85fb1e62004-11-11 14:03:39 +0000242 numnulls = 0;
paul2852de12004-09-17 06:52:16 +0000243 }
paul718e3742002-12-13 20:15:29 +0000244
ajs85fb1e62004-11-11 14:03:39 +0000245 /* got 3 or more trailing NULs? */
246 if ((numnulls >= 3) && (i < nbytes))
paul0921d482004-10-11 18:21:55 +0000247 return (buf[nbytes-1]);
paul718e3742002-12-13 20:15:29 +0000248 }
249 }
paul718e3742002-12-13 20:15:29 +0000250}
251
252void
ajsb1aa1472005-01-28 21:11:46 +0000253vtysh_exit_ripd_only (void)
paul718e3742002-12-13 20:15:29 +0000254{
ajsb1aa1472005-01-28 21:11:46 +0000255 if (ripd_client)
256 vtysh_client_execute (ripd_client, "exit", stdout);
paul718e3742002-12-13 20:15:29 +0000257}
258
259
260void
ajsb1aa1472005-01-28 21:11:46 +0000261vtysh_pager_init (void)
paul718e3742002-12-13 20:15:29 +0000262{
hasso5a9c53d2004-08-27 14:23:28 +0000263 char *pager_defined;
264
265 pager_defined = getenv ("VTYSH_PAGER");
266
267 if (pager_defined)
268 vtysh_pager_name = strdup (pager_defined);
269 else
hasso34553cc2004-08-27 13:56:39 +0000270 vtysh_pager_name = strdup ("more");
paul718e3742002-12-13 20:15:29 +0000271}
272
273/* Command execution over the vty interface. */
ajs274a4a42004-12-07 15:39:31 +0000274static void
hassodda09522004-10-07 21:40:25 +0000275vtysh_execute_func (const char *line, int pager)
paul718e3742002-12-13 20:15:29 +0000276{
277 int ret, cmd_stat;
ajsb1aa1472005-01-28 21:11:46 +0000278 u_int i;
paul718e3742002-12-13 20:15:29 +0000279 vector vline;
280 struct cmd_element *cmd;
281 FILE *fp = NULL;
hasso13bfca72005-01-23 21:42:25 +0000282 int closepager = 0;
283 int tried = 0;
284 int saved_ret, saved_node;
paul718e3742002-12-13 20:15:29 +0000285
hasso95e735b2004-08-26 13:08:30 +0000286 /* Split readline string up into the vector. */
paul718e3742002-12-13 20:15:29 +0000287 vline = cmd_make_strvec (line);
288
289 if (vline == NULL)
290 return;
291
hasso13bfca72005-01-23 21:42:25 +0000292 saved_ret = ret = cmd_execute_command (vline, vty, &cmd, 1);
293 saved_node = vty->node;
294
295 /* If command doesn't succeeded in current node, try to walk up in node tree.
296 * Changing vty->node is enough to try it just out without actual walkup in
297 * the vtysh. */
298 while (ret != CMD_SUCCESS && ret != CMD_SUCCESS_DAEMON && ret != CMD_WARNING
299 && vty->node > CONFIG_NODE)
300 {
301 vty->node = node_parent(vty->node);
302 ret = cmd_execute_command (vline, vty, &cmd, 1);
303 tried++;
304 }
305
306 vty->node = saved_node;
307
308 /* If command succeeded in any other node than current (tried > 0) we have
309 * to move into node in the vtysh where it succeeded. */
310 if (ret == CMD_SUCCESS || ret == CMD_SUCCESS_DAEMON || ret == CMD_WARNING)
311 {
312 if ((saved_node == BGP_VPNV4_NODE || saved_node == BGP_IPV4_NODE
313 || saved_node == BGP_IPV6_NODE || saved_node == BGP_IPV4M_NODE)
314 && (tried == 1))
315 {
316 vtysh_execute("exit-address-family");
317 }
318 else if ((saved_node == KEYCHAIN_KEY_NODE) && (tried == 1))
319 {
320 vtysh_execute("exit");
321 }
322 else if (tried)
323 {
324 vtysh_execute ("end");
325 vtysh_execute ("configure terminal");
326 }
327 }
328 /* If command didn't succeed in any node, continue with return value from
329 * first try. */
330 else if (tried)
331 {
332 ret = saved_ret;
333 }
paul718e3742002-12-13 20:15:29 +0000334
335 cmd_free_strvec (vline);
336
337 switch (ret)
338 {
339 case CMD_WARNING:
340 if (vty->type == VTY_FILE)
paul4fc01e62002-12-13 20:49:00 +0000341 fprintf (stdout,"Warning...\n");
paul718e3742002-12-13 20:15:29 +0000342 break;
343 case CMD_ERR_AMBIGUOUS:
paul4fc01e62002-12-13 20:49:00 +0000344 fprintf (stdout,"%% Ambiguous command.\n");
paul718e3742002-12-13 20:15:29 +0000345 break;
346 case CMD_ERR_NO_MATCH:
paul4fc01e62002-12-13 20:49:00 +0000347 fprintf (stdout,"%% Unknown command.\n");
paul718e3742002-12-13 20:15:29 +0000348 break;
349 case CMD_ERR_INCOMPLETE:
paul4fc01e62002-12-13 20:49:00 +0000350 fprintf (stdout,"%% Command incomplete.\n");
paul718e3742002-12-13 20:15:29 +0000351 break;
352 case CMD_SUCCESS_DAEMON:
353 {
hasso97b7db22004-10-20 19:07:48 +0000354 /* FIXME: Don't open pager for exit commands. popen() causes problems
355 * if exited from vtysh at all. This hack shouldn't cause any problem
356 * but is really ugly. */
357 if (pager && vtysh_pager_name && (strncmp(line, "exit", 4) != 0))
paul718e3742002-12-13 20:15:29 +0000358 {
paul4fc01e62002-12-13 20:49:00 +0000359 fp = popen (vtysh_pager_name, "w");
paul718e3742002-12-13 20:15:29 +0000360 if (fp == NULL)
361 {
paula805cc22003-05-01 14:29:48 +0000362 perror ("popen failed for pager");
363 fp = stdout;
paul718e3742002-12-13 20:15:29 +0000364 }
paula805cc22003-05-01 14:29:48 +0000365 else
366 closepager=1;
paul718e3742002-12-13 20:15:29 +0000367 }
368 else
369 fp = stdout;
370
371 if (! strcmp(cmd->string,"configure terminal"))
372 {
ajsb1aa1472005-01-28 21:11:46 +0000373 for (i = 0; i < VTYSH_INDEX_MAX; i++)
374 {
375 cmd_stat = vtysh_client_execute(&vtysh_client[i], line, fp);
376 if (cmd_stat == CMD_WARNING)
377 break;
378 }
379
paul718e3742002-12-13 20:15:29 +0000380 if (cmd_stat)
381 {
hassob094d262004-08-25 12:22:00 +0000382 line = "end";
383 vline = cmd_make_strvec (line);
paul718e3742002-12-13 20:15:29 +0000384
hassob094d262004-08-25 12:22:00 +0000385 if (vline == NULL)
paul718e3742002-12-13 20:15:29 +0000386 {
paula805cc22003-05-01 14:29:48 +0000387 if (pager && vtysh_pager_name && fp && closepager)
paul718e3742002-12-13 20:15:29 +0000388 {
389 if (pclose (fp) == -1)
390 {
paula805cc22003-05-01 14:29:48 +0000391 perror ("pclose failed for pager");
paul718e3742002-12-13 20:15:29 +0000392 }
393 fp = NULL;
394 }
395 return;
396 }
397
hasso87d683b2005-01-16 23:31:54 +0000398 ret = cmd_execute_command (vline, vty, &cmd, 1);
hassob094d262004-08-25 12:22:00 +0000399 cmd_free_strvec (vline);
400 if (ret != CMD_SUCCESS_DAEMON)
401 break;
paul718e3742002-12-13 20:15:29 +0000402 }
403 else
404 if (cmd->func)
405 {
406 (*cmd->func) (cmd, vty, 0, NULL);
407 break;
hassob094d262004-08-25 12:22:00 +0000408 }
paul718e3742002-12-13 20:15:29 +0000409 }
410
ajsb1aa1472005-01-28 21:11:46 +0000411 cmd_stat = CMD_SUCCESS;
412 for (i = 0; i < VTYSH_INDEX_MAX; i++)
413 {
414 if (cmd->daemon & vtysh_client[i].flag)
415 {
416 cmd_stat = vtysh_client_execute(&vtysh_client[i], line, fp);
417 if (cmd_stat != CMD_SUCCESS)
418 break;
419 }
420 }
421 if (cmd_stat != CMD_SUCCESS)
422 break;
423
paul718e3742002-12-13 20:15:29 +0000424 if (cmd->func)
425 (*cmd->func) (cmd, vty, 0, NULL);
426 }
427 }
paula805cc22003-05-01 14:29:48 +0000428 if (pager && vtysh_pager_name && fp && closepager)
paul718e3742002-12-13 20:15:29 +0000429 {
430 if (pclose (fp) == -1)
431 {
paula805cc22003-05-01 14:29:48 +0000432 perror ("pclose failed for pager");
paul718e3742002-12-13 20:15:29 +0000433 }
434 fp = NULL;
435 }
436}
437
438void
hassodda09522004-10-07 21:40:25 +0000439vtysh_execute_no_pager (const char *line)
paul718e3742002-12-13 20:15:29 +0000440{
441 vtysh_execute_func (line, 0);
442}
443
444void
hassodda09522004-10-07 21:40:25 +0000445vtysh_execute (const char *line)
paul718e3742002-12-13 20:15:29 +0000446{
447 vtysh_execute_func (line, 1);
448}
449
450/* Configration make from file. */
451int
452vtysh_config_from_file (struct vty *vty, FILE *fp)
453{
454 int ret;
455 vector vline;
456 struct cmd_element *cmd;
457
458 while (fgets (vty->buf, VTY_BUFSIZ, fp))
459 {
460 if (vty->buf[0] == '!' || vty->buf[1] == '#')
461 continue;
462
463 vline = cmd_make_strvec (vty->buf);
464
hasso95e735b2004-08-26 13:08:30 +0000465 /* In case of comment line. */
paul718e3742002-12-13 20:15:29 +0000466 if (vline == NULL)
467 continue;
468
hasso95e735b2004-08-26 13:08:30 +0000469 /* Execute configuration command : this is strict match. */
paul718e3742002-12-13 20:15:29 +0000470 ret = cmd_execute_command_strict (vline, vty, &cmd);
471
hasso95e735b2004-08-26 13:08:30 +0000472 /* Try again with setting node to CONFIG_NODE. */
paul718e3742002-12-13 20:15:29 +0000473 if (ret != CMD_SUCCESS
474 && ret != CMD_SUCCESS_DAEMON
475 && ret != CMD_WARNING)
476 {
477 if (vty->node == KEYCHAIN_KEY_NODE)
478 {
479 vty->node = KEYCHAIN_NODE;
480 vtysh_exit_ripd_only ();
481 ret = cmd_execute_command_strict (vline, vty, &cmd);
482
483 if (ret != CMD_SUCCESS
484 && ret != CMD_SUCCESS_DAEMON
485 && ret != CMD_WARNING)
486 {
487 vtysh_exit_ripd_only ();
488 vty->node = CONFIG_NODE;
489 ret = cmd_execute_command_strict (vline, vty, &cmd);
490 }
491 }
492 else
493 {
494 vtysh_execute ("end");
495 vtysh_execute ("configure terminal");
496 vty->node = CONFIG_NODE;
497 ret = cmd_execute_command_strict (vline, vty, &cmd);
498 }
499 }
500
501 cmd_free_strvec (vline);
502
503 switch (ret)
504 {
505 case CMD_WARNING:
506 if (vty->type == VTY_FILE)
paul4fc01e62002-12-13 20:49:00 +0000507 fprintf (stdout,"Warning...\n");
paul718e3742002-12-13 20:15:29 +0000508 break;
509 case CMD_ERR_AMBIGUOUS:
paul4fc01e62002-12-13 20:49:00 +0000510 fprintf (stdout,"%% Ambiguous command.\n");
paul718e3742002-12-13 20:15:29 +0000511 break;
512 case CMD_ERR_NO_MATCH:
paul4fc01e62002-12-13 20:49:00 +0000513 fprintf (stdout,"%% Unknown command: %s", vty->buf);
paul718e3742002-12-13 20:15:29 +0000514 break;
515 case CMD_ERR_INCOMPLETE:
paul4fc01e62002-12-13 20:49:00 +0000516 fprintf (stdout,"%% Command incomplete.\n");
paul718e3742002-12-13 20:15:29 +0000517 break;
518 case CMD_SUCCESS_DAEMON:
519 {
ajsb1aa1472005-01-28 21:11:46 +0000520 u_int i;
521 int cmd_stat = CMD_SUCCESS;
522
523 for (i = 0; i < VTYSH_INDEX_MAX; i++)
524 {
525 if (cmd->daemon && vtysh_client[i].flag)
526 {
527 cmd_stat = vtysh_client_execute (&vtysh_client[i],
528 vty->buf, stdout);
529 if (cmd_stat != CMD_SUCCESS)
530 break;
531 }
532 }
533 if (cmd_stat != CMD_SUCCESS)
534 break;
535
paul718e3742002-12-13 20:15:29 +0000536 if (cmd->func)
537 (*cmd->func) (cmd, vty, 0, NULL);
538 }
539 }
540 }
541 return CMD_SUCCESS;
542}
543
544/* We don't care about the point of the cursor when '?' is typed. */
545int
ajsb1aa1472005-01-28 21:11:46 +0000546vtysh_rl_describe (void)
paul718e3742002-12-13 20:15:29 +0000547{
548 int ret;
hassodda09522004-10-07 21:40:25 +0000549 unsigned int i;
paul718e3742002-12-13 20:15:29 +0000550 vector vline;
551 vector describe;
552 int width;
553 struct desc *desc;
554
555 vline = cmd_make_strvec (rl_line_buffer);
556
557 /* In case of '> ?'. */
558 if (vline == NULL)
559 {
560 vline = vector_init (1);
561 vector_set (vline, '\0');
562 }
563 else
564 if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
565 vector_set (vline, '\0');
566
567 describe = cmd_describe_command (vline, vty, &ret);
568
paul4fc01e62002-12-13 20:49:00 +0000569 fprintf (stdout,"\n");
paul718e3742002-12-13 20:15:29 +0000570
571 /* Ambiguous and no match error. */
572 switch (ret)
573 {
574 case CMD_ERR_AMBIGUOUS:
575 cmd_free_strvec (vline);
paul4fc01e62002-12-13 20:49:00 +0000576 fprintf (stdout,"%% Ambiguous command.\n");
paul718e3742002-12-13 20:15:29 +0000577 rl_on_new_line ();
578 return 0;
579 break;
580 case CMD_ERR_NO_MATCH:
581 cmd_free_strvec (vline);
paul4fc01e62002-12-13 20:49:00 +0000582 fprintf (stdout,"%% There is no matched command.\n");
paul718e3742002-12-13 20:15:29 +0000583 rl_on_new_line ();
584 return 0;
585 break;
586 }
587
588 /* Get width of command string. */
589 width = 0;
paul55468c82005-03-14 20:19:01 +0000590 for (i = 0; i < vector_active (describe); i++)
paul718e3742002-12-13 20:15:29 +0000591 if ((desc = vector_slot (describe, i)) != NULL)
592 {
593 int len;
594
595 if (desc->cmd[0] == '\0')
596 continue;
597
598 len = strlen (desc->cmd);
599 if (desc->cmd[0] == '.')
600 len--;
601
602 if (width < len)
603 width = len;
604 }
605
paul55468c82005-03-14 20:19:01 +0000606 for (i = 0; i < vector_active (describe); i++)
paul718e3742002-12-13 20:15:29 +0000607 if ((desc = vector_slot (describe, i)) != NULL)
608 {
609 if (desc->cmd[0] == '\0')
610 continue;
611
612 if (! desc->str)
paul4fc01e62002-12-13 20:49:00 +0000613 fprintf (stdout," %-s\n",
hassob094d262004-08-25 12:22:00 +0000614 desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd);
paul718e3742002-12-13 20:15:29 +0000615 else
paul4fc01e62002-12-13 20:49:00 +0000616 fprintf (stdout," %-*s %s\n",
hassob094d262004-08-25 12:22:00 +0000617 width,
618 desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd,
619 desc->str);
paul718e3742002-12-13 20:15:29 +0000620 }
621
622 cmd_free_strvec (vline);
623 vector_free (describe);
624
625 rl_on_new_line();
626
627 return 0;
628}
629
hasso95e735b2004-08-26 13:08:30 +0000630/* Result of cmd_complete_command() call will be stored here
631 * and used in new_completion() in order to put the space in
632 * correct places only. */
paul718e3742002-12-13 20:15:29 +0000633int complete_status;
634
ajs274a4a42004-12-07 15:39:31 +0000635static char *
pauldfc0d9b2003-04-18 23:55:29 +0000636command_generator (const char *text, int state)
paul718e3742002-12-13 20:15:29 +0000637{
638 vector vline;
639 static char **matched = NULL;
640 static int index = 0;
641
642 /* First call. */
643 if (! state)
644 {
645 index = 0;
646
647 if (vty->node == AUTH_NODE || vty->node == AUTH_ENABLE_NODE)
648 return NULL;
649
650 vline = cmd_make_strvec (rl_line_buffer);
651 if (vline == NULL)
652 return NULL;
653
654 if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
655 vector_set (vline, '\0');
656
657 matched = cmd_complete_command (vline, vty, &complete_status);
658 }
659
660 if (matched && matched[index])
661 return matched[index++];
662
663 return NULL;
664}
665
ajs274a4a42004-12-07 15:39:31 +0000666static char **
paul718e3742002-12-13 20:15:29 +0000667new_completion (char *text, int start, int end)
668{
669 char **matches;
670
pauldfc0d9b2003-04-18 23:55:29 +0000671 matches = rl_completion_matches (text, command_generator);
paul718e3742002-12-13 20:15:29 +0000672
673 if (matches)
674 {
675 rl_point = rl_end;
676 if (complete_status == CMD_COMPLETE_FULL_MATCH)
677 rl_pending_input = ' ';
678 }
679
680 return matches;
681}
682
ajs274a4a42004-12-07 15:39:31 +0000683#if 0
684/* This function is not actually being used. */
685static char **
paul718e3742002-12-13 20:15:29 +0000686vtysh_completion (char *text, int start, int end)
687{
688 int ret;
689 vector vline;
690 char **matched = NULL;
691
692 if (vty->node == AUTH_NODE || vty->node == AUTH_ENABLE_NODE)
693 return NULL;
694
695 vline = cmd_make_strvec (rl_line_buffer);
696 if (vline == NULL)
697 return NULL;
698
699 /* In case of 'help \t'. */
700 if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
701 vector_set (vline, '\0');
702
703 matched = cmd_complete_command (vline, vty, &ret);
704
705 cmd_free_strvec (vline);
706
707 return (char **) matched;
708}
ajs274a4a42004-12-07 15:39:31 +0000709#endif
paul718e3742002-12-13 20:15:29 +0000710
hasso95e735b2004-08-26 13:08:30 +0000711/* Vty node structures. */
paul718e3742002-12-13 20:15:29 +0000712struct cmd_node bgp_node =
713{
714 BGP_NODE,
715 "%s(config-router)# ",
716};
717
paul718e3742002-12-13 20:15:29 +0000718struct cmd_node rip_node =
719{
720 RIP_NODE,
721 "%s(config-router)# ",
722};
723
hassoc25e4582003-12-23 10:39:08 +0000724struct cmd_node isis_node =
725{
726 ISIS_NODE,
727 "%s(config-router)# ",
hassoc25e4582003-12-23 10:39:08 +0000728};
729
paul718e3742002-12-13 20:15:29 +0000730struct cmd_node interface_node =
731{
732 INTERFACE_NODE,
733 "%s(config-if)# ",
734};
735
hasso95e735b2004-08-26 13:08:30 +0000736struct cmd_node rmap_node =
737{
738 RMAP_NODE,
739 "%s(config-route-map)# "
740};
741
742struct cmd_node zebra_node =
743{
744 ZEBRA_NODE,
745 "%s(config-router)# "
746};
747
748struct cmd_node bgp_vpnv4_node =
749{
750 BGP_VPNV4_NODE,
751 "%s(config-router-af)# "
752};
753
754struct cmd_node bgp_ipv4_node =
755{
756 BGP_IPV4_NODE,
757 "%s(config-router-af)# "
758};
759
760struct cmd_node bgp_ipv4m_node =
761{
762 BGP_IPV4M_NODE,
763 "%s(config-router-af)# "
764};
765
766struct cmd_node bgp_ipv6_node =
767{
768 BGP_IPV6_NODE,
769 "%s(config-router-af)# "
770};
771
772struct cmd_node ospf_node =
773{
774 OSPF_NODE,
775 "%s(config-router)# "
776};
777
778struct cmd_node ripng_node =
779{
780 RIPNG_NODE,
781 "%s(config-router)# "
782};
783
784struct cmd_node ospf6_node =
785{
786 OSPF6_NODE,
787 "%s(config-ospf6)# "
788};
789
790struct cmd_node keychain_node =
791{
792 KEYCHAIN_NODE,
793 "%s(config-keychain)# "
794};
795
796struct cmd_node keychain_key_node =
797{
798 KEYCHAIN_KEY_NODE,
799 "%s(config-keychain-key)# "
800};
801
hassoe7168df2004-10-03 20:11:32 +0000802/* Defined in lib/vty.c */
803extern struct cmd_node vty_node;
804
hasso95e735b2004-08-26 13:08:30 +0000805/* When '^Z' is received from vty, move down to the enable mode. */
806int
ajsb1aa1472005-01-28 21:11:46 +0000807vtysh_end (void)
hasso95e735b2004-08-26 13:08:30 +0000808{
809 switch (vty->node)
810 {
811 case VIEW_NODE:
812 case ENABLE_NODE:
813 /* Nothing to do. */
814 break;
815 default:
816 vty->node = ENABLE_NODE;
817 break;
818 }
819 return CMD_SUCCESS;
820}
821
822DEFUNSH (VTYSH_ALL,
823 vtysh_end_all,
824 vtysh_end_all_cmd,
825 "end",
hassoe7168df2004-10-03 20:11:32 +0000826 "End current mode and change to enable mode\n")
hasso95e735b2004-08-26 13:08:30 +0000827{
hasso42895462004-09-26 16:25:07 +0000828 return vtysh_end ();
hasso95e735b2004-08-26 13:08:30 +0000829}
830
paul718e3742002-12-13 20:15:29 +0000831DEFUNSH (VTYSH_BGPD,
832 router_bgp,
833 router_bgp_cmd,
834 "router bgp <1-65535>",
835 ROUTER_STR
836 BGP_STR
837 AS_STR)
838{
839 vty->node = BGP_NODE;
840 return CMD_SUCCESS;
841}
842
843DEFUNSH (VTYSH_BGPD,
844 address_family_vpnv4,
845 address_family_vpnv4_cmd,
846 "address-family vpnv4",
847 "Enter Address Family command mode\n"
848 "Address family\n")
849{
850 vty->node = BGP_VPNV4_NODE;
851 return CMD_SUCCESS;
852}
853
854DEFUNSH (VTYSH_BGPD,
855 address_family_vpnv4_unicast,
856 address_family_vpnv4_unicast_cmd,
857 "address-family vpnv4 unicast",
858 "Enter Address Family command mode\n"
859 "Address family\n"
860 "Address Family Modifier\n")
861{
862 vty->node = BGP_VPNV4_NODE;
863 return CMD_SUCCESS;
864}
865
866DEFUNSH (VTYSH_BGPD,
867 address_family_ipv4_unicast,
868 address_family_ipv4_unicast_cmd,
869 "address-family ipv4 unicast",
870 "Enter Address Family command mode\n"
871 "Address family\n"
872 "Address Family Modifier\n")
873{
874 vty->node = BGP_IPV4_NODE;
875 return CMD_SUCCESS;
876}
877
878DEFUNSH (VTYSH_BGPD,
879 address_family_ipv4_multicast,
880 address_family_ipv4_multicast_cmd,
881 "address-family ipv4 multicast",
882 "Enter Address Family command mode\n"
883 "Address family\n"
884 "Address Family Modifier\n")
885{
886 vty->node = BGP_IPV4M_NODE;
887 return CMD_SUCCESS;
888}
889
890DEFUNSH (VTYSH_BGPD,
891 address_family_ipv6,
892 address_family_ipv6_cmd,
893 "address-family ipv6",
894 "Enter Address Family command mode\n"
895 "Address family\n")
896{
897 vty->node = BGP_IPV6_NODE;
898 return CMD_SUCCESS;
899}
900
901DEFUNSH (VTYSH_BGPD,
902 address_family_ipv6_unicast,
903 address_family_ipv6_unicast_cmd,
904 "address-family ipv6 unicast",
905 "Enter Address Family command mode\n"
906 "Address family\n"
907 "Address Family Modifier\n")
908{
909 vty->node = BGP_IPV6_NODE;
910 return CMD_SUCCESS;
911}
912
913DEFUNSH (VTYSH_RIPD,
914 key_chain,
915 key_chain_cmd,
916 "key chain WORD",
917 "Authentication key management\n"
918 "Key-chain management\n"
919 "Key-chain name\n")
920{
921 vty->node = KEYCHAIN_NODE;
922 return CMD_SUCCESS;
923}
924
925DEFUNSH (VTYSH_RIPD,
926 key,
927 key_cmd,
928 "key <0-2147483647>",
929 "Configure a key\n"
930 "Key identifier number\n")
931{
932 vty->node = KEYCHAIN_KEY_NODE;
933 return CMD_SUCCESS;
934}
935
936DEFUNSH (VTYSH_RIPD,
937 router_rip,
938 router_rip_cmd,
939 "router rip",
940 ROUTER_STR
941 "RIP")
942{
943 vty->node = RIP_NODE;
944 return CMD_SUCCESS;
945}
946
947DEFUNSH (VTYSH_RIPNGD,
948 router_ripng,
949 router_ripng_cmd,
950 "router ripng",
951 ROUTER_STR
952 "RIPng")
953{
954 vty->node = RIPNG_NODE;
955 return CMD_SUCCESS;
956}
957
958DEFUNSH (VTYSH_OSPFD,
959 router_ospf,
960 router_ospf_cmd,
961 "router ospf",
962 "Enable a routing process\n"
963 "Start OSPF configuration\n")
964{
965 vty->node = OSPF_NODE;
966 return CMD_SUCCESS;
967}
968
969DEFUNSH (VTYSH_OSPF6D,
970 router_ospf6,
971 router_ospf6_cmd,
972 "router ospf6",
973 OSPF6_ROUTER_STR
974 OSPF6_STR)
975{
976 vty->node = OSPF6_NODE;
977 return CMD_SUCCESS;
978}
979
hassoc25e4582003-12-23 10:39:08 +0000980DEFUNSH (VTYSH_ISISD,
hassob094d262004-08-25 12:22:00 +0000981 router_isis,
982 router_isis_cmd,
983 "router isis WORD",
984 ROUTER_STR
985 "ISO IS-IS\n"
986 "ISO Routing area tag")
hassoc25e4582003-12-23 10:39:08 +0000987{
988 vty->node = ISIS_NODE;
989 return CMD_SUCCESS;
990}
991
paul718e3742002-12-13 20:15:29 +0000992DEFUNSH (VTYSH_RMAP,
993 route_map,
994 route_map_cmd,
995 "route-map WORD (deny|permit) <1-65535>",
996 "Create route-map or enter route-map command mode\n"
997 "Route map tag\n"
998 "Route map denies set operations\n"
999 "Route map permits set operations\n"
1000 "Sequence to insert to/delete from existing route-map entry\n")
1001{
1002 vty->node = RMAP_NODE;
1003 return CMD_SUCCESS;
1004}
1005
paul718e3742002-12-13 20:15:29 +00001006DEFUNSH (VTYSH_ALL,
hassoe7168df2004-10-03 20:11:32 +00001007 vtysh_line_vty,
1008 vtysh_line_vty_cmd,
1009 "line vty",
1010 "Configure a terminal line\n"
1011 "Virtual terminal\n")
1012{
1013 vty->node = VTY_NODE;
1014 return CMD_SUCCESS;
1015}
1016
1017DEFUNSH (VTYSH_ALL,
paul718e3742002-12-13 20:15:29 +00001018 vtysh_enable,
1019 vtysh_enable_cmd,
1020 "enable",
1021 "Turn on privileged mode command\n")
1022{
1023 vty->node = ENABLE_NODE;
1024 return CMD_SUCCESS;
1025}
1026
paul718e3742002-12-13 20:15:29 +00001027DEFUNSH (VTYSH_ALL,
1028 vtysh_disable,
1029 vtysh_disable_cmd,
1030 "disable",
1031 "Turn off privileged mode command\n")
1032{
1033 if (vty->node == ENABLE_NODE)
1034 vty->node = VIEW_NODE;
1035 return CMD_SUCCESS;
1036}
1037
paul718e3742002-12-13 20:15:29 +00001038DEFUNSH (VTYSH_ALL,
1039 vtysh_config_terminal,
1040 vtysh_config_terminal_cmd,
1041 "configure terminal",
1042 "Configuration from vty interface\n"
1043 "Configuration terminal\n")
1044{
1045 vty->node = CONFIG_NODE;
1046 return CMD_SUCCESS;
1047}
1048
ajs274a4a42004-12-07 15:39:31 +00001049static int
paul718e3742002-12-13 20:15:29 +00001050vtysh_exit (struct vty *vty)
1051{
1052 switch (vty->node)
1053 {
1054 case VIEW_NODE:
1055 case ENABLE_NODE:
1056 exit (0);
1057 break;
1058 case CONFIG_NODE:
1059 vty->node = ENABLE_NODE;
1060 break;
1061 case INTERFACE_NODE:
1062 case ZEBRA_NODE:
1063 case BGP_NODE:
1064 case RIP_NODE:
1065 case RIPNG_NODE:
1066 case OSPF_NODE:
1067 case OSPF6_NODE:
hassoc25e4582003-12-23 10:39:08 +00001068 case ISIS_NODE:
paul718e3742002-12-13 20:15:29 +00001069 case MASC_NODE:
1070 case RMAP_NODE:
1071 case VTY_NODE:
1072 case KEYCHAIN_NODE:
hasso2a56df92004-05-09 23:16:40 +00001073 vtysh_execute("end");
1074 vtysh_execute("configure terminal");
paul718e3742002-12-13 20:15:29 +00001075 vty->node = CONFIG_NODE;
1076 break;
1077 case BGP_VPNV4_NODE:
1078 case BGP_IPV4_NODE:
1079 case BGP_IPV4M_NODE:
1080 case BGP_IPV6_NODE:
1081 vty->node = BGP_NODE;
1082 break;
1083 case KEYCHAIN_KEY_NODE:
1084 vty->node = KEYCHAIN_NODE;
1085 break;
1086 default:
1087 break;
1088 }
1089 return CMD_SUCCESS;
1090}
1091
1092DEFUNSH (VTYSH_ALL,
1093 vtysh_exit_all,
1094 vtysh_exit_all_cmd,
1095 "exit",
1096 "Exit current mode and down to previous mode\n")
1097{
1098 return vtysh_exit (vty);
1099}
1100
1101ALIAS (vtysh_exit_all,
1102 vtysh_quit_all_cmd,
1103 "quit",
1104 "Exit current mode and down to previous mode\n")
1105
1106DEFUNSH (VTYSH_BGPD,
1107 exit_address_family,
1108 exit_address_family_cmd,
1109 "exit-address-family",
1110 "Exit from Address Family configuration mode\n")
1111{
1112 if (vty->node == BGP_IPV4_NODE
1113 || vty->node == BGP_IPV4M_NODE
1114 || vty->node == BGP_VPNV4_NODE
1115 || vty->node == BGP_IPV6_NODE)
1116 vty->node = BGP_NODE;
1117 return CMD_SUCCESS;
1118}
1119
1120DEFUNSH (VTYSH_ZEBRA,
1121 vtysh_exit_zebra,
1122 vtysh_exit_zebra_cmd,
1123 "exit",
1124 "Exit current mode and down to previous mode\n")
1125{
1126 return vtysh_exit (vty);
1127}
1128
1129ALIAS (vtysh_exit_zebra,
1130 vtysh_quit_zebra_cmd,
1131 "quit",
1132 "Exit current mode and down to previous mode\n")
1133
1134DEFUNSH (VTYSH_RIPD,
1135 vtysh_exit_ripd,
1136 vtysh_exit_ripd_cmd,
1137 "exit",
1138 "Exit current mode and down to previous mode\n")
1139{
1140 return vtysh_exit (vty);
1141}
1142
1143ALIAS (vtysh_exit_ripd,
1144 vtysh_quit_ripd_cmd,
1145 "quit",
1146 "Exit current mode and down to previous mode\n")
1147
paul68980082003-03-25 05:07:42 +00001148DEFUNSH (VTYSH_RIPNGD,
hassob094d262004-08-25 12:22:00 +00001149 vtysh_exit_ripngd,
1150 vtysh_exit_ripngd_cmd,
1151 "exit",
1152 "Exit current mode and down to previous mode\n")
paul68980082003-03-25 05:07:42 +00001153{
1154 return vtysh_exit (vty);
1155}
1156
1157ALIAS (vtysh_exit_ripngd,
1158 vtysh_quit_ripngd_cmd,
1159 "quit",
1160 "Exit current mode and down to previous mode\n")
1161
paul718e3742002-12-13 20:15:29 +00001162DEFUNSH (VTYSH_RMAP,
1163 vtysh_exit_rmap,
1164 vtysh_exit_rmap_cmd,
1165 "exit",
1166 "Exit current mode and down to previous mode\n")
1167{
1168 return vtysh_exit (vty);
1169}
1170
1171ALIAS (vtysh_exit_rmap,
1172 vtysh_quit_rmap_cmd,
1173 "quit",
1174 "Exit current mode and down to previous mode\n")
1175
1176DEFUNSH (VTYSH_BGPD,
1177 vtysh_exit_bgpd,
1178 vtysh_exit_bgpd_cmd,
1179 "exit",
1180 "Exit current mode and down to previous mode\n")
1181{
1182 return vtysh_exit (vty);
1183}
1184
1185ALIAS (vtysh_exit_bgpd,
1186 vtysh_quit_bgpd_cmd,
1187 "quit",
1188 "Exit current mode and down to previous mode\n")
1189
1190DEFUNSH (VTYSH_OSPFD,
1191 vtysh_exit_ospfd,
1192 vtysh_exit_ospfd_cmd,
1193 "exit",
1194 "Exit current mode and down to previous mode\n")
1195{
1196 return vtysh_exit (vty);
1197}
1198
1199ALIAS (vtysh_exit_ospfd,
1200 vtysh_quit_ospfd_cmd,
1201 "quit",
1202 "Exit current mode and down to previous mode\n")
1203
paul68980082003-03-25 05:07:42 +00001204DEFUNSH (VTYSH_OSPF6D,
hassob094d262004-08-25 12:22:00 +00001205 vtysh_exit_ospf6d,
1206 vtysh_exit_ospf6d_cmd,
1207 "exit",
1208 "Exit current mode and down to previous mode\n")
paul68980082003-03-25 05:07:42 +00001209{
1210 return vtysh_exit (vty);
1211}
1212
1213ALIAS (vtysh_exit_ospf6d,
1214 vtysh_quit_ospf6d_cmd,
1215 "quit",
1216 "Exit current mode and down to previous mode\n")
1217
hassoc25e4582003-12-23 10:39:08 +00001218DEFUNSH (VTYSH_ISISD,
hassob094d262004-08-25 12:22:00 +00001219 vtysh_exit_isisd,
1220 vtysh_exit_isisd_cmd,
1221 "exit",
1222 "Exit current mode and down to previous mode\n")
hassoc25e4582003-12-23 10:39:08 +00001223{
1224 return vtysh_exit (vty);
1225}
1226
1227ALIAS (vtysh_exit_isisd,
1228 vtysh_quit_isisd_cmd,
1229 "quit",
1230 "Exit current mode and down to previous mode\n")
1231
hassoe7168df2004-10-03 20:11:32 +00001232DEFUNSH (VTYSH_ALL,
1233 vtysh_exit_line_vty,
1234 vtysh_exit_line_vty_cmd,
1235 "exit",
1236 "Exit current mode and down to previous mode\n")
1237{
1238 return vtysh_exit (vty);
1239}
1240
1241ALIAS (vtysh_exit_line_vty,
1242 vtysh_quit_line_vty_cmd,
1243 "quit",
1244 "Exit current mode and down to previous mode\n")
1245
hasso95e735b2004-08-26 13:08:30 +00001246DEFUNSH (VTYSH_INTERFACE,
paul718e3742002-12-13 20:15:29 +00001247 vtysh_interface,
1248 vtysh_interface_cmd,
1249 "interface IFNAME",
1250 "Select an interface to configure\n"
1251 "Interface's name\n")
1252{
1253 vty->node = INTERFACE_NODE;
1254 return CMD_SUCCESS;
1255}
1256
hasso95e735b2004-08-26 13:08:30 +00001257/* TODO Implement "no interface command in isisd. */
paul32d24632003-05-23 09:25:20 +00001258DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D,
1259 vtysh_no_interface_cmd,
1260 "no interface IFNAME",
1261 NO_STR
1262 "Delete a pseudo interface's configuration\n"
1263 "Interface's name\n")
1264
hasso95e735b2004-08-26 13:08:30 +00001265/* TODO Implement interface description commands in ripngd, ospf6d
1266 * and isisd. */
paul338a9912003-03-01 15:44:10 +00001267DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD,
1268 interface_desc_cmd,
1269 "description .LINE",
1270 "Interface specific description\n"
1271 "Characters describing this interface\n")
paul464dc8d2003-03-28 02:25:45 +00001272
1273DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD,
1274 no_interface_desc_cmd,
1275 "no description",
1276 NO_STR
1277 "Interface specific description\n")
paul338a9912003-03-01 15:44:10 +00001278
hasso95e735b2004-08-26 13:08:30 +00001279DEFUNSH (VTYSH_INTERFACE,
paul718e3742002-12-13 20:15:29 +00001280 vtysh_exit_interface,
1281 vtysh_exit_interface_cmd,
1282 "exit",
1283 "Exit current mode and down to previous mode\n")
1284{
1285 return vtysh_exit (vty);
1286}
1287
1288ALIAS (vtysh_exit_interface,
1289 vtysh_quit_interface_cmd,
1290 "quit",
1291 "Exit current mode and down to previous mode\n")
1292
hasso95e735b2004-08-26 13:08:30 +00001293/* Logging commands. */
1294DEFUNSH (VTYSH_ALL,
1295 vtysh_log_stdout,
1296 vtysh_log_stdout_cmd,
1297 "log stdout",
1298 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001299 "Set stdout logging level\n")
1300{
1301 return CMD_SUCCESS;
1302}
1303
1304DEFUNSH (VTYSH_ALL,
1305 vtysh_log_stdout_level,
1306 vtysh_log_stdout_level_cmd,
1307 "log stdout "LOG_LEVELS,
1308 "Logging control\n"
1309 "Set stdout logging level\n"
1310 LOG_LEVEL_DESC)
hasso95e735b2004-08-26 13:08:30 +00001311{
1312 return CMD_SUCCESS;
1313}
1314
1315DEFUNSH (VTYSH_ALL,
1316 no_vtysh_log_stdout,
1317 no_vtysh_log_stdout_cmd,
ajs274a4a42004-12-07 15:39:31 +00001318 "no log stdout [LEVEL]",
hasso95e735b2004-08-26 13:08:30 +00001319 NO_STR
1320 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001321 "Cancel logging to stdout\n"
1322 "Logging level\n")
hasso95e735b2004-08-26 13:08:30 +00001323{
1324 return CMD_SUCCESS;
1325}
1326
1327DEFUNSH (VTYSH_ALL,
1328 vtysh_log_file,
1329 vtysh_log_file_cmd,
1330 "log file FILENAME",
1331 "Logging control\n"
1332 "Logging to file\n"
1333 "Logging filename\n")
1334{
1335 return CMD_SUCCESS;
1336}
1337
1338DEFUNSH (VTYSH_ALL,
ajs274a4a42004-12-07 15:39:31 +00001339 vtysh_log_file_level,
1340 vtysh_log_file_level_cmd,
1341 "log file FILENAME "LOG_LEVELS,
1342 "Logging control\n"
1343 "Logging to file\n"
1344 "Logging filename\n"
1345 LOG_LEVEL_DESC)
1346{
1347 return CMD_SUCCESS;
1348}
1349
1350DEFUNSH (VTYSH_ALL,
hasso95e735b2004-08-26 13:08:30 +00001351 no_vtysh_log_file,
1352 no_vtysh_log_file_cmd,
1353 "no log file [FILENAME]",
1354 NO_STR
1355 "Logging control\n"
1356 "Cancel logging to file\n"
1357 "Logging file name\n")
1358{
1359 return CMD_SUCCESS;
1360}
1361
ajs274a4a42004-12-07 15:39:31 +00001362ALIAS_SH (VTYSH_ALL,
1363 no_vtysh_log_file,
1364 no_vtysh_log_file_level_cmd,
1365 "no log file FILENAME LEVEL",
1366 NO_STR
1367 "Logging control\n"
1368 "Cancel logging to file\n"
1369 "Logging file name\n"
1370 "Logging level\n")
1371
1372DEFUNSH (VTYSH_ALL,
1373 vtysh_log_monitor,
1374 vtysh_log_monitor_cmd,
1375 "log monitor",
1376 "Logging control\n"
1377 "Set terminal line (monitor) logging level\n")
1378{
1379 return CMD_SUCCESS;
1380}
1381
1382DEFUNSH (VTYSH_ALL,
1383 vtysh_log_monitor_level,
1384 vtysh_log_monitor_level_cmd,
1385 "log monitor "LOG_LEVELS,
1386 "Logging control\n"
1387 "Set terminal line (monitor) logging level\n"
1388 LOG_LEVEL_DESC)
1389{
1390 return CMD_SUCCESS;
1391}
1392
1393DEFUNSH (VTYSH_ALL,
1394 no_vtysh_log_monitor,
1395 no_vtysh_log_monitor_cmd,
1396 "no log monitor [LEVEL]",
1397 NO_STR
1398 "Logging control\n"
1399 "Disable terminal line (monitor) logging\n"
1400 "Logging level\n")
1401{
1402 return CMD_SUCCESS;
1403}
1404
hasso95e735b2004-08-26 13:08:30 +00001405DEFUNSH (VTYSH_ALL,
1406 vtysh_log_syslog,
1407 vtysh_log_syslog_cmd,
1408 "log syslog",
1409 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001410 "Set syslog logging level\n")
1411{
1412 return CMD_SUCCESS;
1413}
1414
1415DEFUNSH (VTYSH_ALL,
1416 vtysh_log_syslog_level,
1417 vtysh_log_syslog_level_cmd,
1418 "log syslog "LOG_LEVELS,
1419 "Logging control\n"
1420 "Set syslog logging level\n"
1421 LOG_LEVEL_DESC)
hasso95e735b2004-08-26 13:08:30 +00001422{
1423 return CMD_SUCCESS;
1424}
1425
1426DEFUNSH (VTYSH_ALL,
1427 no_vtysh_log_syslog,
1428 no_vtysh_log_syslog_cmd,
ajs274a4a42004-12-07 15:39:31 +00001429 "no log syslog [LEVEL]",
hasso95e735b2004-08-26 13:08:30 +00001430 NO_STR
1431 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001432 "Cancel logging to syslog\n"
1433 "Logging level\n")
hasso95e735b2004-08-26 13:08:30 +00001434{
1435 return CMD_SUCCESS;
1436}
1437
1438DEFUNSH (VTYSH_ALL,
ajs274a4a42004-12-07 15:39:31 +00001439 vtysh_log_facility,
1440 vtysh_log_facility_cmd,
1441 "log facility "LOG_FACILITIES,
hasso95e735b2004-08-26 13:08:30 +00001442 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001443 "Facility parameter for syslog messages\n"
1444 LOG_FACILITY_DESC)
1445
hasso95e735b2004-08-26 13:08:30 +00001446{
1447 return CMD_SUCCESS;
1448}
1449
1450DEFUNSH (VTYSH_ALL,
ajs274a4a42004-12-07 15:39:31 +00001451 no_vtysh_log_facility,
1452 no_vtysh_log_facility_cmd,
1453 "no log facility [FACILITY]",
hasso95e735b2004-08-26 13:08:30 +00001454 NO_STR
1455 "Logging control\n"
ajs274a4a42004-12-07 15:39:31 +00001456 "Reset syslog facility to default (daemon)\n"
1457 "Syslog facility\n")
1458
1459{
1460 return CMD_SUCCESS;
1461}
1462
1463DEFUNSH_DEPRECATED (VTYSH_ALL,
1464 vtysh_log_trap,
1465 vtysh_log_trap_cmd,
1466 "log trap "LOG_LEVELS,
1467 "Logging control\n"
1468 "(Deprecated) Set logging level and default for all destinations\n"
1469 LOG_LEVEL_DESC)
1470
1471{
1472 return CMD_SUCCESS;
1473}
1474
1475DEFUNSH_DEPRECATED (VTYSH_ALL,
1476 no_vtysh_log_trap,
1477 no_vtysh_log_trap_cmd,
1478 "no log trap [LEVEL]",
1479 NO_STR
1480 "Logging control\n"
1481 "Permit all logging information\n"
1482 "Logging level\n")
hasso95e735b2004-08-26 13:08:30 +00001483{
1484 return CMD_SUCCESS;
1485}
1486
1487DEFUNSH (VTYSH_ALL,
1488 vtysh_log_record_priority,
1489 vtysh_log_record_priority_cmd,
1490 "log record-priority",
1491 "Logging control\n"
1492 "Log the priority of the message within the message\n")
1493{
1494 return CMD_SUCCESS;
1495}
1496
1497DEFUNSH (VTYSH_ALL,
1498 no_vtysh_log_record_priority,
1499 no_vtysh_log_record_priority_cmd,
1500 "no log record-priority",
1501 NO_STR
1502 "Logging control\n"
1503 "Do not log the priority of the message within the message\n")
1504{
1505 return CMD_SUCCESS;
1506}
1507
hassoe7168df2004-10-03 20:11:32 +00001508DEFUNSH (VTYSH_ALL,
1509 vtysh_service_password_encrypt,
1510 vtysh_service_password_encrypt_cmd,
1511 "service password-encryption",
1512 "Set up miscellaneous service\n"
1513 "Enable encrypted passwords\n")
1514{
1515 return CMD_SUCCESS;
1516}
1517
1518DEFUNSH (VTYSH_ALL,
1519 no_vtysh_service_password_encrypt,
1520 no_vtysh_service_password_encrypt_cmd,
1521 "no service password-encryption",
1522 NO_STR
1523 "Set up miscellaneous service\n"
1524 "Enable encrypted passwords\n")
1525{
1526 return CMD_SUCCESS;
1527}
1528
1529DEFUNSH (VTYSH_ALL,
1530 vtysh_config_password,
1531 vtysh_password_cmd,
1532 "password (8|) WORD",
1533 "Assign the terminal connection password\n"
1534 "Specifies a HIDDEN password will follow\n"
1535 "dummy string \n"
1536 "The HIDDEN line password string\n")
1537{
1538 return CMD_SUCCESS;
1539}
1540
1541DEFUNSH (VTYSH_ALL,
1542 vtysh_password_text,
1543 vtysh_password_text_cmd,
1544 "password LINE",
1545 "Assign the terminal connection password\n"
1546 "The UNENCRYPTED (cleartext) line password\n")
1547{
1548 return CMD_SUCCESS;
1549}
1550
1551DEFUNSH (VTYSH_ALL,
1552 vtysh_config_enable_password,
1553 vtysh_enable_password_cmd,
1554 "enable password (8|) WORD",
1555 "Modify enable password parameters\n"
1556 "Assign the privileged level password\n"
1557 "Specifies a HIDDEN password will follow\n"
1558 "dummy string \n"
1559 "The HIDDEN 'enable' password string\n")
1560{
1561 return CMD_SUCCESS;
1562}
1563
1564DEFUNSH (VTYSH_ALL,
1565 vtysh_enable_password_text,
1566 vtysh_enable_password_text_cmd,
1567 "enable password LINE",
1568 "Modify enable password parameters\n"
1569 "Assign the privileged level password\n"
1570 "The UNENCRYPTED (cleartext) 'enable' password\n")
1571{
1572 return CMD_SUCCESS;
1573}
1574
1575DEFUNSH (VTYSH_ALL,
1576 no_vtysh_config_enable_password,
1577 no_vtysh_enable_password_cmd,
1578 "no enable password",
1579 NO_STR
1580 "Modify enable password parameters\n"
1581 "Assign the privileged level password\n")
1582{
1583 return CMD_SUCCESS;
1584}
1585
paul718e3742002-12-13 20:15:29 +00001586DEFUN (vtysh_write_terminal,
1587 vtysh_write_terminal_cmd,
1588 "write terminal",
1589 "Write running configuration to memory, network, or terminal\n"
1590 "Write to terminal\n")
1591{
ajsb1aa1472005-01-28 21:11:46 +00001592 u_int i;
paul718e3742002-12-13 20:15:29 +00001593 int ret;
1594 char line[] = "write terminal\n";
1595 FILE *fp = NULL;
1596
1597 if (vtysh_pager_name)
1598 {
paul4fc01e62002-12-13 20:49:00 +00001599 fp = popen (vtysh_pager_name, "w");
paul718e3742002-12-13 20:15:29 +00001600 if (fp == NULL)
1601 {
1602 perror ("popen");
1603 exit (1);
1604 }
1605 }
1606 else
1607 fp = stdout;
1608
1609 vty_out (vty, "Building configuration...%s", VTY_NEWLINE);
1610 vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE,
1611 VTY_NEWLINE);
hassoe7168df2004-10-03 20:11:32 +00001612 vty_out (vty, "!%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001613
ajsb1aa1472005-01-28 21:11:46 +00001614 for (i = 0; i < VTYSH_INDEX_MAX; i++)
1615 ret = vtysh_client_config (&vtysh_client[i], line);
paul718e3742002-12-13 20:15:29 +00001616
hassoe7168df2004-10-03 20:11:32 +00001617 /* Integrate vtysh specific configuration. */
1618 vtysh_config_write ();
1619
paul718e3742002-12-13 20:15:29 +00001620 vtysh_config_dump (fp);
1621
1622 if (vtysh_pager_name && fp)
1623 {
1624 fflush (fp);
1625 if (pclose (fp) == -1)
1626 {
1627 perror ("pclose");
1628 exit (1);
1629 }
1630 fp = NULL;
1631 }
1632
1633 return CMD_SUCCESS;
1634}
1635
hassoe7168df2004-10-03 20:11:32 +00001636DEFUN (vtysh_integrated_config,
1637 vtysh_integrated_config_cmd,
1638 "service integrated-vtysh-config",
1639 "Set up miscellaneous service\n"
1640 "Write configuration into integrated file\n")
paul4fc01e62002-12-13 20:49:00 +00001641{
hassoe7168df2004-10-03 20:11:32 +00001642 vtysh_writeconfig_integrated = 1;
1643 return CMD_SUCCESS;
paul4fc01e62002-12-13 20:49:00 +00001644}
1645
hassoe7168df2004-10-03 20:11:32 +00001646DEFUN (no_vtysh_integrated_config,
1647 no_vtysh_integrated_config_cmd,
1648 "no service integrated-vtysh-config",
1649 NO_STR
1650 "Set up miscellaneous service\n"
1651 "Write configuration into integrated file\n")
paul4fc01e62002-12-13 20:49:00 +00001652{
hassoe7168df2004-10-03 20:11:32 +00001653 vtysh_writeconfig_integrated = 0;
1654 return CMD_SUCCESS;
paul4fc01e62002-12-13 20:49:00 +00001655}
1656
ajs274a4a42004-12-07 15:39:31 +00001657static int
1658write_config_integrated(void)
paul718e3742002-12-13 20:15:29 +00001659{
ajsb1aa1472005-01-28 21:11:46 +00001660 u_int i;
paul718e3742002-12-13 20:15:29 +00001661 int ret;
paul718e3742002-12-13 20:15:29 +00001662 char line[] = "write terminal\n";
1663 FILE *fp;
1664 char *integrate_sav = NULL;
1665
hasso95e735b2004-08-26 13:08:30 +00001666 integrate_sav = malloc (strlen (integrate_default) +
1667 strlen (CONF_BACKUP_EXT) + 1);
paul718e3742002-12-13 20:15:29 +00001668 strcpy (integrate_sav, integrate_default);
1669 strcat (integrate_sav, CONF_BACKUP_EXT);
1670
paul4fc01e62002-12-13 20:49:00 +00001671 fprintf (stdout,"Building Configuration...\n");
paul718e3742002-12-13 20:15:29 +00001672
hasso95e735b2004-08-26 13:08:30 +00001673 /* Move current configuration file to backup config file. */
paul718e3742002-12-13 20:15:29 +00001674 unlink (integrate_sav);
1675 rename (integrate_default, integrate_sav);
hasso95e735b2004-08-26 13:08:30 +00001676 free (integrate_sav);
paul4fc01e62002-12-13 20:49:00 +00001677
paul718e3742002-12-13 20:15:29 +00001678 fp = fopen (integrate_default, "w");
1679 if (fp == NULL)
1680 {
hasso95e735b2004-08-26 13:08:30 +00001681 fprintf (stdout,"%% Can't open configuration file %s.\n",
1682 integrate_default);
paul718e3742002-12-13 20:15:29 +00001683 return CMD_SUCCESS;
1684 }
paul718e3742002-12-13 20:15:29 +00001685
ajsb1aa1472005-01-28 21:11:46 +00001686 for (i = 0; i < VTYSH_INDEX_MAX; i++)
1687 ret = vtysh_client_config (&vtysh_client[i], line);
paul718e3742002-12-13 20:15:29 +00001688
1689 vtysh_config_dump (fp);
1690
1691 fclose (fp);
1692
gdtaa593d52003-12-22 20:15:53 +00001693 if (chmod (integrate_default, CONFIGFILE_MASK) != 0)
1694 {
1695 fprintf (stdout,"%% Can't chmod configuration file %s: %s (%d)\n",
ajs6099b3b2004-11-20 02:06:59 +00001696 integrate_default, safe_strerror(errno), errno);
gdtaa593d52003-12-22 20:15:53 +00001697 return CMD_WARNING;
1698 }
1699
paul4fc01e62002-12-13 20:49:00 +00001700 fprintf(stdout,"Integrated configuration saved to %s\n",integrate_default);
1701
1702 fprintf (stdout,"[OK]\n");
1703
paul718e3742002-12-13 20:15:29 +00001704 return CMD_SUCCESS;
1705}
1706
paul4fc01e62002-12-13 20:49:00 +00001707DEFUN (vtysh_write_memory,
1708 vtysh_write_memory_cmd,
1709 "write memory",
1710 "Write running configuration to memory, network, or terminal\n"
1711 "Write configuration to the file (same as write file)\n")
1712{
pauldfc0d9b2003-04-18 23:55:29 +00001713 int ret = CMD_SUCCESS;
paul4fc01e62002-12-13 20:49:00 +00001714 char line[] = "write memory\n";
ajsb1aa1472005-01-28 21:11:46 +00001715 u_int i;
paul4fc01e62002-12-13 20:49:00 +00001716
hassoe7168df2004-10-03 20:11:32 +00001717 /* If integrated Quagga.conf explicitely set. */
1718 if (vtysh_writeconfig_integrated)
1719 return write_config_integrated();
paul4fc01e62002-12-13 20:49:00 +00001720
1721 fprintf (stdout,"Building Configuration...\n");
1722
ajsb1aa1472005-01-28 21:11:46 +00001723 for (i = 0; i < VTYSH_INDEX_MAX; i++)
1724 ret = vtysh_client_execute (&vtysh_client[i], line, stdout);
hassoe7168df2004-10-03 20:11:32 +00001725
paul4fc01e62002-12-13 20:49:00 +00001726 fprintf (stdout,"[OK]\n");
1727
pauldfc0d9b2003-04-18 23:55:29 +00001728 return ret;
paul4fc01e62002-12-13 20:49:00 +00001729}
1730
paul718e3742002-12-13 20:15:29 +00001731ALIAS (vtysh_write_memory,
1732 vtysh_copy_runningconfig_startupconfig_cmd,
1733 "copy running-config startup-config",
1734 "Copy from one file to another\n"
1735 "Copy from current system configuration\n"
1736 "Copy to startup configuration\n")
1737
1738ALIAS (vtysh_write_memory,
1739 vtysh_write_file_cmd,
1740 "write file",
1741 "Write running configuration to memory, network, or terminal\n"
1742 "Write configuration to the file (same as write memory)\n")
1743
hasso4a6e2252003-05-25 11:51:29 +00001744ALIAS (vtysh_write_memory,
1745 vtysh_write_cmd,
1746 "write",
1747 "Write running configuration to memory, network, or terminal\n")
1748
paul718e3742002-12-13 20:15:29 +00001749ALIAS (vtysh_write_terminal,
1750 vtysh_show_running_config_cmd,
1751 "show running-config",
1752 SHOW_STR
1753 "Current operating configuration\n")
hassob094d262004-08-25 12:22:00 +00001754
hasso34553cc2004-08-27 13:56:39 +00001755DEFUN (vtysh_terminal_length,
1756 vtysh_terminal_length_cmd,
1757 "terminal length <0-512>",
1758 "Set terminal line parameters\n"
1759 "Set number of lines on a screen\n"
1760 "Number of lines on screen (0 for no pausing)\n")
1761{
1762 int lines;
1763 char *endptr = NULL;
1764 char default_pager[10];
1765
1766 lines = strtol (argv[0], &endptr, 10);
1767 if (lines < 0 || lines > 512 || *endptr != '\0')
1768 {
1769 vty_out (vty, "length is malformed%s", VTY_NEWLINE);
1770 return CMD_WARNING;
1771 }
1772
1773 if (vtysh_pager_name)
1774 {
1775 free (vtysh_pager_name);
1776 vtysh_pager_name = NULL;
1777 }
1778
1779 if (lines != 0)
1780 {
1781 snprintf(default_pager, 10, "more -%i", lines);
1782 vtysh_pager_name = strdup (default_pager);
1783 }
1784
1785 return CMD_SUCCESS;
1786}
1787
1788DEFUN (vtysh_terminal_no_length,
1789 vtysh_terminal_no_length_cmd,
1790 "terminal no length",
1791 "Set terminal line parameters\n"
1792 NO_STR
1793 "Set number of lines on a screen\n")
1794{
1795 if (vtysh_pager_name)
1796 {
1797 free (vtysh_pager_name);
1798 vtysh_pager_name = NULL;
1799 }
1800
1801 vtysh_pager_init();
1802 return CMD_SUCCESS;
1803}
1804
hassof2799e62004-10-28 17:43:11 +00001805DEFUN (vtysh_show_daemons,
1806 vtysh_show_daemons_cmd,
1807 "show daemons",
hassoe7168df2004-10-03 20:11:32 +00001808 SHOW_STR
1809 "Show list of running daemons\n")
1810{
ajsb1aa1472005-01-28 21:11:46 +00001811 u_int i;
1812
1813 for (i = 0; i < VTYSH_INDEX_MAX; i++)
1814 if ( vtysh_client[i].fd >= 0 )
1815 vty_out(vty, " %s", vtysh_client[i].name);
hassoe7168df2004-10-03 20:11:32 +00001816 vty_out(vty, "%s", VTY_NEWLINE);
1817
1818 return CMD_SUCCESS;
1819}
1820
paul718e3742002-12-13 20:15:29 +00001821/* Execute command in child process. */
ajs274a4a42004-12-07 15:39:31 +00001822static int
hasso5862ff52004-10-11 13:20:40 +00001823execute_command (const char *command, int argc, const char *arg1,
1824 const char *arg2)
paul718e3742002-12-13 20:15:29 +00001825{
1826 int ret;
1827 pid_t pid;
1828 int status;
1829
1830 /* Call fork(). */
1831 pid = fork ();
1832
1833 if (pid < 0)
1834 {
1835 /* Failure of fork(). */
ajs6099b3b2004-11-20 02:06:59 +00001836 fprintf (stderr, "Can't fork: %s\n", safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +00001837 exit (1);
1838 }
1839 else if (pid == 0)
1840 {
1841 /* This is child process. */
1842 switch (argc)
1843 {
1844 case 0:
hassofa2b17e2004-03-04 17:45:00 +00001845 ret = execlp (command, command, (const char *)NULL);
paul718e3742002-12-13 20:15:29 +00001846 break;
1847 case 1:
hassofa2b17e2004-03-04 17:45:00 +00001848 ret = execlp (command, command, arg1, (const char *)NULL);
paul718e3742002-12-13 20:15:29 +00001849 break;
1850 case 2:
hassofa2b17e2004-03-04 17:45:00 +00001851 ret = execlp (command, command, arg1, arg2, (const char *)NULL);
paul718e3742002-12-13 20:15:29 +00001852 break;
1853 }
1854
1855 /* When execlp suceed, this part is not executed. */
ajs6099b3b2004-11-20 02:06:59 +00001856 fprintf (stderr, "Can't execute %s: %s\n", command, safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +00001857 exit (1);
1858 }
1859 else
1860 {
1861 /* This is parent. */
1862 execute_flag = 1;
1863 ret = wait4 (pid, &status, 0, NULL);
1864 execute_flag = 0;
1865 }
1866 return 0;
1867}
1868
1869DEFUN (vtysh_ping,
1870 vtysh_ping_cmd,
1871 "ping WORD",
hasso4eeccf12003-06-25 10:49:55 +00001872 "Send echo messages\n"
paul718e3742002-12-13 20:15:29 +00001873 "Ping destination address or hostname\n")
1874{
1875 execute_command ("ping", 1, argv[0], NULL);
1876 return CMD_SUCCESS;
1877}
1878
hasso4eeccf12003-06-25 10:49:55 +00001879ALIAS (vtysh_ping,
1880 vtysh_ping_ip_cmd,
1881 "ping ip WORD",
1882 "Send echo messages\n"
1883 "IP echo\n"
1884 "Ping destination address or hostname\n")
1885
paul718e3742002-12-13 20:15:29 +00001886DEFUN (vtysh_traceroute,
1887 vtysh_traceroute_cmd,
1888 "traceroute WORD",
1889 "Trace route to destination\n"
1890 "Trace route to destination address or hostname\n")
1891{
1892 execute_command ("traceroute", 1, argv[0], NULL);
1893 return CMD_SUCCESS;
1894}
1895
hasso4eeccf12003-06-25 10:49:55 +00001896ALIAS (vtysh_traceroute,
1897 vtysh_traceroute_ip_cmd,
1898 "traceroute ip WORD",
1899 "Trace route to destination\n"
1900 "IP trace\n"
1901 "Trace route to destination address or hostname\n")
1902
1903#ifdef HAVE_IPV6
1904DEFUN (vtysh_ping6,
1905 vtysh_ping6_cmd,
1906 "ping ipv6 WORD",
1907 "Send echo messages\n"
1908 "IPv6 echo\n"
1909 "Ping destination address or hostname\n")
1910{
1911 execute_command ("ping6", 1, argv[0], NULL);
1912 return CMD_SUCCESS;
1913}
1914
1915DEFUN (vtysh_traceroute6,
1916 vtysh_traceroute6_cmd,
1917 "traceroute ipv6 WORD",
1918 "Trace route to destination\n"
1919 "IPv6 trace\n"
1920 "Trace route to destination address or hostname\n")
1921{
1922 execute_command ("traceroute6", 1, argv[0], NULL);
1923 return CMD_SUCCESS;
1924}
1925#endif
1926
paul718e3742002-12-13 20:15:29 +00001927DEFUN (vtysh_telnet,
1928 vtysh_telnet_cmd,
1929 "telnet WORD",
1930 "Open a telnet connection\n"
1931 "IP address or hostname of a remote system\n")
1932{
1933 execute_command ("telnet", 1, argv[0], NULL);
1934 return CMD_SUCCESS;
1935}
1936
1937DEFUN (vtysh_telnet_port,
1938 vtysh_telnet_port_cmd,
1939 "telnet WORD PORT",
1940 "Open a telnet connection\n"
1941 "IP address or hostname of a remote system\n"
1942 "TCP Port number\n")
1943{
1944 execute_command ("telnet", 2, argv[0], argv[1]);
1945 return CMD_SUCCESS;
1946}
1947
paul5087df52003-01-25 06:56:09 +00001948DEFUN (vtysh_ssh,
1949 vtysh_ssh_cmd,
1950 "ssh WORD",
1951 "Open an ssh connection\n"
1952 "[user@]host\n")
1953{
1954 execute_command ("ssh", 1, argv[0], NULL);
1955 return CMD_SUCCESS;
1956}
1957
paul718e3742002-12-13 20:15:29 +00001958DEFUN (vtysh_start_shell,
1959 vtysh_start_shell_cmd,
1960 "start-shell",
1961 "Start UNIX shell\n")
1962{
1963 execute_command ("sh", 0, NULL, NULL);
1964 return CMD_SUCCESS;
1965}
1966
1967DEFUN (vtysh_start_bash,
1968 vtysh_start_bash_cmd,
1969 "start-shell bash",
1970 "Start UNIX shell\n"
1971 "Start bash\n")
1972{
1973 execute_command ("bash", 0, NULL, NULL);
1974 return CMD_SUCCESS;
1975}
1976
1977DEFUN (vtysh_start_zsh,
1978 vtysh_start_zsh_cmd,
1979 "start-shell zsh",
1980 "Start UNIX shell\n"
1981 "Start Z shell\n")
1982{
1983 execute_command ("zsh", 0, NULL, NULL);
1984 return CMD_SUCCESS;
1985}
hassob094d262004-08-25 12:22:00 +00001986
ajs274a4a42004-12-07 15:39:31 +00001987static void
paul718e3742002-12-13 20:15:29 +00001988vtysh_install_default (enum node_type node)
1989{
1990 install_element (node, &config_list_cmd);
1991}
1992
1993/* Making connection to protocol daemon. */
ajs274a4a42004-12-07 15:39:31 +00001994static int
ajsb1aa1472005-01-28 21:11:46 +00001995vtysh_connect (struct vtysh_client *vclient)
paul718e3742002-12-13 20:15:29 +00001996{
1997 int ret;
1998 int sock, len;
1999 struct sockaddr_un addr;
2000 struct stat s_stat;
paul718e3742002-12-13 20:15:29 +00002001
paul718e3742002-12-13 20:15:29 +00002002 /* Stat socket to see if we have permission to access it. */
ajsb1aa1472005-01-28 21:11:46 +00002003 ret = stat (vclient->path, &s_stat);
paul718e3742002-12-13 20:15:29 +00002004 if (ret < 0 && errno != ENOENT)
2005 {
2006 fprintf (stderr, "vtysh_connect(%s): stat = %s\n",
ajsb1aa1472005-01-28 21:11:46 +00002007 vclient->path, safe_strerror(errno));
paul718e3742002-12-13 20:15:29 +00002008 exit(1);
2009 }
2010
2011 if (ret >= 0)
2012 {
2013 if (! S_ISSOCK(s_stat.st_mode))
2014 {
2015 fprintf (stderr, "vtysh_connect(%s): Not a socket\n",
ajsb1aa1472005-01-28 21:11:46 +00002016 vclient->path);
paul718e3742002-12-13 20:15:29 +00002017 exit (1);
2018 }
2019
paul718e3742002-12-13 20:15:29 +00002020 }
2021
2022 sock = socket (AF_UNIX, SOCK_STREAM, 0);
2023 if (sock < 0)
2024 {
2025#ifdef DEBUG
ajsb1aa1472005-01-28 21:11:46 +00002026 fprintf(stderr, "vtysh_connect(%s): socket = %s\n", vclient->path,
ajs6099b3b2004-11-20 02:06:59 +00002027 safe_strerror(errno));
paul718e3742002-12-13 20:15:29 +00002028#endif /* DEBUG */
2029 return -1;
2030 }
2031
2032 memset (&addr, 0, sizeof (struct sockaddr_un));
2033 addr.sun_family = AF_UNIX;
ajsb1aa1472005-01-28 21:11:46 +00002034 strncpy (addr.sun_path, vclient->path, strlen (vclient->path));
paul718e3742002-12-13 20:15:29 +00002035#ifdef HAVE_SUN_LEN
2036 len = addr.sun_len = SUN_LEN(&addr);
2037#else
2038 len = sizeof (addr.sun_family) + strlen (addr.sun_path);
2039#endif /* HAVE_SUN_LEN */
2040
2041 ret = connect (sock, (struct sockaddr *) &addr, len);
2042 if (ret < 0)
2043 {
2044#ifdef DEBUG
ajsb1aa1472005-01-28 21:11:46 +00002045 fprintf(stderr, "vtysh_connect(%s): connect = %s\n", vclient->path,
ajs6099b3b2004-11-20 02:06:59 +00002046 safe_strerror(errno));
paul718e3742002-12-13 20:15:29 +00002047#endif /* DEBUG */
2048 close (sock);
2049 return -1;
2050 }
2051 vclient->fd = sock;
2052
2053 return 0;
2054}
2055
2056void
ajsb1aa1472005-01-28 21:11:46 +00002057vtysh_connect_all(void)
paul718e3742002-12-13 20:15:29 +00002058{
ajsb1aa1472005-01-28 21:11:46 +00002059 u_int i;
2060
2061 for (i = 0; i < VTYSH_INDEX_MAX; i++)
2062 {
2063 vtysh_connect(&vtysh_client[i]);
2064 /* We need direct access to ripd in vtysh_exit_ripd_only. */
2065 if (vtysh_client[i].flag == VTYSH_RIPD)
2066 ripd_client = &vtysh_client[i];
2067 }
paul718e3742002-12-13 20:15:29 +00002068}
2069
hasso95e735b2004-08-26 13:08:30 +00002070/* To disable readline's filename completion. */
ajs274a4a42004-12-07 15:39:31 +00002071static char *
pauldfc0d9b2003-04-18 23:55:29 +00002072vtysh_completion_entry_function (const char *ignore, int invoking_key)
paul718e3742002-12-13 20:15:29 +00002073{
pauldfc0d9b2003-04-18 23:55:29 +00002074 return NULL;
paul718e3742002-12-13 20:15:29 +00002075}
2076
2077void
ajsb1aa1472005-01-28 21:11:46 +00002078vtysh_readline_init (void)
paul718e3742002-12-13 20:15:29 +00002079{
2080 /* readline related settings. */
2081 rl_bind_key ('?', vtysh_rl_describe);
paul68980082003-03-25 05:07:42 +00002082 rl_completion_entry_function = vtysh_completion_entry_function;
paul718e3742002-12-13 20:15:29 +00002083 rl_attempted_completion_function = (CPPFunction *)new_completion;
2084 /* do not append space after completion. It will be appended
hasso95e735b2004-08-26 13:08:30 +00002085 * in new_completion() function explicitly. */
paul718e3742002-12-13 20:15:29 +00002086 rl_completion_append_character = '\0';
2087}
2088
2089char *
ajsb1aa1472005-01-28 21:11:46 +00002090vtysh_prompt (void)
paul718e3742002-12-13 20:15:29 +00002091{
2092 struct utsname names;
2093 static char buf[100];
2094 const char*hostname;
2095 extern struct host host;
2096
2097 hostname = host.name;
2098
2099 if (!hostname)
2100 {
2101 uname (&names);
2102 hostname = names.nodename;
2103 }
2104
2105 snprintf (buf, sizeof buf, cmd_prompt (vty->node), hostname);
2106
2107 return buf;
2108}
2109
2110void
ajsb1aa1472005-01-28 21:11:46 +00002111vtysh_init_vty (void)
paul718e3742002-12-13 20:15:29 +00002112{
2113 /* Make vty structure. */
2114 vty = vty_new ();
2115 vty->type = VTY_SHELL;
2116 vty->node = VIEW_NODE;
2117
2118 /* Initialize commands. */
2119 cmd_init (0);
2120
2121 /* Install nodes. */
2122 install_node (&bgp_node, NULL);
2123 install_node (&rip_node, NULL);
2124 install_node (&interface_node, NULL);
2125 install_node (&rmap_node, NULL);
2126 install_node (&zebra_node, NULL);
2127 install_node (&bgp_vpnv4_node, NULL);
2128 install_node (&bgp_ipv4_node, NULL);
2129 install_node (&bgp_ipv4m_node, NULL);
2130/* #ifdef HAVE_IPV6 */
2131 install_node (&bgp_ipv6_node, NULL);
2132/* #endif */
2133 install_node (&ospf_node, NULL);
2134/* #ifdef HAVE_IPV6 */
2135 install_node (&ripng_node, NULL);
2136 install_node (&ospf6_node, NULL);
2137/* #endif */
2138 install_node (&keychain_node, NULL);
2139 install_node (&keychain_key_node, NULL);
hassoc25e4582003-12-23 10:39:08 +00002140 install_node (&isis_node, NULL);
hassoe7168df2004-10-03 20:11:32 +00002141 install_node (&vty_node, NULL);
paul718e3742002-12-13 20:15:29 +00002142
2143 vtysh_install_default (VIEW_NODE);
2144 vtysh_install_default (ENABLE_NODE);
2145 vtysh_install_default (CONFIG_NODE);
2146 vtysh_install_default (BGP_NODE);
2147 vtysh_install_default (RIP_NODE);
2148 vtysh_install_default (INTERFACE_NODE);
2149 vtysh_install_default (RMAP_NODE);
2150 vtysh_install_default (ZEBRA_NODE);
2151 vtysh_install_default (BGP_VPNV4_NODE);
2152 vtysh_install_default (BGP_IPV4_NODE);
2153 vtysh_install_default (BGP_IPV4M_NODE);
2154 vtysh_install_default (BGP_IPV6_NODE);
2155 vtysh_install_default (OSPF_NODE);
2156 vtysh_install_default (RIPNG_NODE);
2157 vtysh_install_default (OSPF6_NODE);
hassoc25e4582003-12-23 10:39:08 +00002158 vtysh_install_default (ISIS_NODE);
paul718e3742002-12-13 20:15:29 +00002159 vtysh_install_default (KEYCHAIN_NODE);
2160 vtysh_install_default (KEYCHAIN_KEY_NODE);
hassoe7168df2004-10-03 20:11:32 +00002161 vtysh_install_default (VTY_NODE);
paul718e3742002-12-13 20:15:29 +00002162
2163 install_element (VIEW_NODE, &vtysh_enable_cmd);
2164 install_element (ENABLE_NODE, &vtysh_config_terminal_cmd);
2165 install_element (ENABLE_NODE, &vtysh_disable_cmd);
2166
2167 /* "exit" command. */
2168 install_element (VIEW_NODE, &vtysh_exit_all_cmd);
2169 install_element (VIEW_NODE, &vtysh_quit_all_cmd);
2170 install_element (CONFIG_NODE, &vtysh_exit_all_cmd);
2171 /* install_element (CONFIG_NODE, &vtysh_quit_all_cmd); */
2172 install_element (ENABLE_NODE, &vtysh_exit_all_cmd);
2173 install_element (ENABLE_NODE, &vtysh_quit_all_cmd);
2174 install_element (RIP_NODE, &vtysh_exit_ripd_cmd);
2175 install_element (RIP_NODE, &vtysh_quit_ripd_cmd);
paul68980082003-03-25 05:07:42 +00002176 install_element (RIPNG_NODE, &vtysh_exit_ripngd_cmd);
2177 install_element (RIPNG_NODE, &vtysh_quit_ripngd_cmd);
paul718e3742002-12-13 20:15:29 +00002178 install_element (OSPF_NODE, &vtysh_exit_ospfd_cmd);
2179 install_element (OSPF_NODE, &vtysh_quit_ospfd_cmd);
paul68980082003-03-25 05:07:42 +00002180 install_element (OSPF6_NODE, &vtysh_exit_ospf6d_cmd);
2181 install_element (OSPF6_NODE, &vtysh_quit_ospf6d_cmd);
paul718e3742002-12-13 20:15:29 +00002182 install_element (BGP_NODE, &vtysh_exit_bgpd_cmd);
2183 install_element (BGP_NODE, &vtysh_quit_bgpd_cmd);
2184 install_element (BGP_VPNV4_NODE, &vtysh_exit_bgpd_cmd);
2185 install_element (BGP_VPNV4_NODE, &vtysh_quit_bgpd_cmd);
2186 install_element (BGP_IPV4_NODE, &vtysh_exit_bgpd_cmd);
2187 install_element (BGP_IPV4_NODE, &vtysh_quit_bgpd_cmd);
2188 install_element (BGP_IPV4M_NODE, &vtysh_exit_bgpd_cmd);
2189 install_element (BGP_IPV4M_NODE, &vtysh_quit_bgpd_cmd);
2190 install_element (BGP_IPV6_NODE, &vtysh_exit_bgpd_cmd);
2191 install_element (BGP_IPV6_NODE, &vtysh_quit_bgpd_cmd);
hassoc25e4582003-12-23 10:39:08 +00002192 install_element (ISIS_NODE, &vtysh_exit_isisd_cmd);
2193 install_element (ISIS_NODE, &vtysh_quit_isisd_cmd);
paul718e3742002-12-13 20:15:29 +00002194 install_element (KEYCHAIN_NODE, &vtysh_exit_ripd_cmd);
2195 install_element (KEYCHAIN_NODE, &vtysh_quit_ripd_cmd);
2196 install_element (KEYCHAIN_KEY_NODE, &vtysh_exit_ripd_cmd);
2197 install_element (KEYCHAIN_KEY_NODE, &vtysh_quit_ripd_cmd);
2198 install_element (RMAP_NODE, &vtysh_exit_rmap_cmd);
2199 install_element (RMAP_NODE, &vtysh_quit_rmap_cmd);
hassoe7168df2004-10-03 20:11:32 +00002200 install_element (VTY_NODE, &vtysh_exit_line_vty_cmd);
2201 install_element (VTY_NODE, &vtysh_quit_line_vty_cmd);
paul718e3742002-12-13 20:15:29 +00002202
2203 /* "end" command. */
2204 install_element (CONFIG_NODE, &vtysh_end_all_cmd);
2205 install_element (ENABLE_NODE, &vtysh_end_all_cmd);
2206 install_element (RIP_NODE, &vtysh_end_all_cmd);
2207 install_element (RIPNG_NODE, &vtysh_end_all_cmd);
2208 install_element (OSPF_NODE, &vtysh_end_all_cmd);
2209 install_element (OSPF6_NODE, &vtysh_end_all_cmd);
2210 install_element (BGP_NODE, &vtysh_end_all_cmd);
2211 install_element (BGP_IPV4_NODE, &vtysh_end_all_cmd);
2212 install_element (BGP_IPV4M_NODE, &vtysh_end_all_cmd);
2213 install_element (BGP_VPNV4_NODE, &vtysh_end_all_cmd);
2214 install_element (BGP_IPV6_NODE, &vtysh_end_all_cmd);
hassoc25e4582003-12-23 10:39:08 +00002215 install_element (ISIS_NODE, &vtysh_end_all_cmd);
paul718e3742002-12-13 20:15:29 +00002216 install_element (KEYCHAIN_NODE, &vtysh_end_all_cmd);
2217 install_element (KEYCHAIN_KEY_NODE, &vtysh_end_all_cmd);
2218 install_element (RMAP_NODE, &vtysh_end_all_cmd);
hassoe7168df2004-10-03 20:11:32 +00002219 install_element (VTY_NODE, &vtysh_end_all_cmd);
paul718e3742002-12-13 20:15:29 +00002220
paul338a9912003-03-01 15:44:10 +00002221 install_element (INTERFACE_NODE, &interface_desc_cmd);
paul464dc8d2003-03-28 02:25:45 +00002222 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
paul718e3742002-12-13 20:15:29 +00002223 install_element (INTERFACE_NODE, &vtysh_end_all_cmd);
2224 install_element (INTERFACE_NODE, &vtysh_exit_interface_cmd);
2225 install_element (INTERFACE_NODE, &vtysh_quit_interface_cmd);
2226 install_element (CONFIG_NODE, &router_rip_cmd);
2227#ifdef HAVE_IPV6
2228 install_element (CONFIG_NODE, &router_ripng_cmd);
2229#endif
2230 install_element (CONFIG_NODE, &router_ospf_cmd);
2231#ifdef HAVE_IPV6
2232 install_element (CONFIG_NODE, &router_ospf6_cmd);
2233#endif
hassoc25e4582003-12-23 10:39:08 +00002234 install_element (CONFIG_NODE, &router_isis_cmd);
paul718e3742002-12-13 20:15:29 +00002235 install_element (CONFIG_NODE, &router_bgp_cmd);
2236 install_element (BGP_NODE, &address_family_vpnv4_cmd);
2237 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
2238 install_element (BGP_NODE, &address_family_ipv4_unicast_cmd);
2239 install_element (BGP_NODE, &address_family_ipv4_multicast_cmd);
2240#ifdef HAVE_IPV6
2241 install_element (BGP_NODE, &address_family_ipv6_cmd);
2242 install_element (BGP_NODE, &address_family_ipv6_unicast_cmd);
2243#endif
2244 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
2245 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
2246 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
2247 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
2248 install_element (CONFIG_NODE, &key_chain_cmd);
2249 install_element (CONFIG_NODE, &route_map_cmd);
hassoe7168df2004-10-03 20:11:32 +00002250 install_element (CONFIG_NODE, &vtysh_line_vty_cmd);
paul718e3742002-12-13 20:15:29 +00002251 install_element (KEYCHAIN_NODE, &key_cmd);
2252 install_element (KEYCHAIN_NODE, &key_chain_cmd);
2253 install_element (KEYCHAIN_KEY_NODE, &key_chain_cmd);
2254 install_element (CONFIG_NODE, &vtysh_interface_cmd);
paul32d24632003-05-23 09:25:20 +00002255 install_element (CONFIG_NODE, &vtysh_no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00002256 install_element (ENABLE_NODE, &vtysh_show_running_config_cmd);
2257 install_element (ENABLE_NODE, &vtysh_copy_runningconfig_startupconfig_cmd);
2258 install_element (ENABLE_NODE, &vtysh_write_file_cmd);
hasso4a6e2252003-05-25 11:51:29 +00002259 install_element (ENABLE_NODE, &vtysh_write_cmd);
paul718e3742002-12-13 20:15:29 +00002260
hasso95e735b2004-08-26 13:08:30 +00002261 /* "write terminal" command. */
paul718e3742002-12-13 20:15:29 +00002262 install_element (ENABLE_NODE, &vtysh_write_terminal_cmd);
hassoe7168df2004-10-03 20:11:32 +00002263
2264 install_element (CONFIG_NODE, &vtysh_integrated_config_cmd);
2265 install_element (CONFIG_NODE, &no_vtysh_integrated_config_cmd);
paul718e3742002-12-13 20:15:29 +00002266
hasso95e735b2004-08-26 13:08:30 +00002267 /* "write memory" command. */
paul718e3742002-12-13 20:15:29 +00002268 install_element (ENABLE_NODE, &vtysh_write_memory_cmd);
paul718e3742002-12-13 20:15:29 +00002269
hasso34553cc2004-08-27 13:56:39 +00002270 install_element (VIEW_NODE, &vtysh_terminal_length_cmd);
2271 install_element (ENABLE_NODE, &vtysh_terminal_length_cmd);
2272 install_element (VIEW_NODE, &vtysh_terminal_no_length_cmd);
2273 install_element (ENABLE_NODE, &vtysh_terminal_no_length_cmd);
hassof2799e62004-10-28 17:43:11 +00002274 install_element (VIEW_NODE, &vtysh_show_daemons_cmd);
2275 install_element (ENABLE_NODE, &vtysh_show_daemons_cmd);
hasso34553cc2004-08-27 13:56:39 +00002276
paul718e3742002-12-13 20:15:29 +00002277 install_element (VIEW_NODE, &vtysh_ping_cmd);
hasso4eeccf12003-06-25 10:49:55 +00002278 install_element (VIEW_NODE, &vtysh_ping_ip_cmd);
paul718e3742002-12-13 20:15:29 +00002279 install_element (VIEW_NODE, &vtysh_traceroute_cmd);
hasso4eeccf12003-06-25 10:49:55 +00002280 install_element (VIEW_NODE, &vtysh_traceroute_ip_cmd);
2281#ifdef HAVE_IPV6
2282 install_element (VIEW_NODE, &vtysh_ping6_cmd);
2283 install_element (VIEW_NODE, &vtysh_traceroute6_cmd);
2284#endif
paul718e3742002-12-13 20:15:29 +00002285 install_element (VIEW_NODE, &vtysh_telnet_cmd);
2286 install_element (VIEW_NODE, &vtysh_telnet_port_cmd);
paul5087df52003-01-25 06:56:09 +00002287 install_element (VIEW_NODE, &vtysh_ssh_cmd);
paul718e3742002-12-13 20:15:29 +00002288 install_element (ENABLE_NODE, &vtysh_ping_cmd);
hasso4eeccf12003-06-25 10:49:55 +00002289 install_element (ENABLE_NODE, &vtysh_ping_ip_cmd);
paul718e3742002-12-13 20:15:29 +00002290 install_element (ENABLE_NODE, &vtysh_traceroute_cmd);
hasso4eeccf12003-06-25 10:49:55 +00002291 install_element (ENABLE_NODE, &vtysh_traceroute_ip_cmd);
2292#ifdef HAVE_IPV6
2293 install_element (ENABLE_NODE, &vtysh_ping6_cmd);
2294 install_element (ENABLE_NODE, &vtysh_traceroute6_cmd);
2295#endif
paul718e3742002-12-13 20:15:29 +00002296 install_element (ENABLE_NODE, &vtysh_telnet_cmd);
2297 install_element (ENABLE_NODE, &vtysh_telnet_port_cmd);
hasso67e29ab2004-08-26 22:21:31 +00002298 install_element (ENABLE_NODE, &vtysh_ssh_cmd);
paul718e3742002-12-13 20:15:29 +00002299 install_element (ENABLE_NODE, &vtysh_start_shell_cmd);
2300 install_element (ENABLE_NODE, &vtysh_start_bash_cmd);
2301 install_element (ENABLE_NODE, &vtysh_start_zsh_cmd);
2302
paul718e3742002-12-13 20:15:29 +00002303 install_element (CONFIG_NODE, &vtysh_log_stdout_cmd);
ajs274a4a42004-12-07 15:39:31 +00002304 install_element (CONFIG_NODE, &vtysh_log_stdout_level_cmd);
paul718e3742002-12-13 20:15:29 +00002305 install_element (CONFIG_NODE, &no_vtysh_log_stdout_cmd);
2306 install_element (CONFIG_NODE, &vtysh_log_file_cmd);
ajs274a4a42004-12-07 15:39:31 +00002307 install_element (CONFIG_NODE, &vtysh_log_file_level_cmd);
paul718e3742002-12-13 20:15:29 +00002308 install_element (CONFIG_NODE, &no_vtysh_log_file_cmd);
ajs274a4a42004-12-07 15:39:31 +00002309 install_element (CONFIG_NODE, &no_vtysh_log_file_level_cmd);
2310 install_element (CONFIG_NODE, &vtysh_log_monitor_cmd);
2311 install_element (CONFIG_NODE, &vtysh_log_monitor_level_cmd);
2312 install_element (CONFIG_NODE, &no_vtysh_log_monitor_cmd);
paul718e3742002-12-13 20:15:29 +00002313 install_element (CONFIG_NODE, &vtysh_log_syslog_cmd);
ajs274a4a42004-12-07 15:39:31 +00002314 install_element (CONFIG_NODE, &vtysh_log_syslog_level_cmd);
paul718e3742002-12-13 20:15:29 +00002315 install_element (CONFIG_NODE, &no_vtysh_log_syslog_cmd);
2316 install_element (CONFIG_NODE, &vtysh_log_trap_cmd);
2317 install_element (CONFIG_NODE, &no_vtysh_log_trap_cmd);
ajs274a4a42004-12-07 15:39:31 +00002318 install_element (CONFIG_NODE, &vtysh_log_facility_cmd);
2319 install_element (CONFIG_NODE, &no_vtysh_log_facility_cmd);
paul718e3742002-12-13 20:15:29 +00002320 install_element (CONFIG_NODE, &vtysh_log_record_priority_cmd);
2321 install_element (CONFIG_NODE, &no_vtysh_log_record_priority_cmd);
hassoe7168df2004-10-03 20:11:32 +00002322
2323 install_element (CONFIG_NODE, &vtysh_service_password_encrypt_cmd);
2324 install_element (CONFIG_NODE, &no_vtysh_service_password_encrypt_cmd);
2325
2326 install_element (CONFIG_NODE, &vtysh_password_cmd);
2327 install_element (CONFIG_NODE, &vtysh_password_text_cmd);
2328 install_element (CONFIG_NODE, &vtysh_enable_password_cmd);
2329 install_element (CONFIG_NODE, &vtysh_enable_password_text_cmd);
2330 install_element (CONFIG_NODE, &no_vtysh_enable_password_cmd);
2331
paul718e3742002-12-13 20:15:29 +00002332}