Annotation of embedaddon/quagga/vtysh/vtysh.c, revision 1.1.1.2
1.1 misho 1: /* 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"
36: #include "log.h"
37: #include "bgpd/bgp_vty.h"
38:
39: /* Struct VTY. */
40: struct vty *vty;
41:
42: /* VTY shell pager name. */
43: char *vtysh_pager_name = NULL;
44:
45: /* VTY shell client structure. */
46: struct vtysh_client
47: {
48: int fd;
49: const char *name;
50: int flag;
51: const char *path;
52: } vtysh_client[] =
53: {
54: { .fd = -1, .name = "zebra", .flag = VTYSH_ZEBRA, .path = ZEBRA_VTYSH_PATH},
55: { .fd = -1, .name = "ripd", .flag = VTYSH_RIPD, .path = RIP_VTYSH_PATH},
56: { .fd = -1, .name = "ripngd", .flag = VTYSH_RIPNGD, .path = RIPNG_VTYSH_PATH},
57: { .fd = -1, .name = "ospfd", .flag = VTYSH_OSPFD, .path = OSPF_VTYSH_PATH},
58: { .fd = -1, .name = "ospf6d", .flag = VTYSH_OSPF6D, .path = OSPF6_VTYSH_PATH},
59: { .fd = -1, .name = "bgpd", .flag = VTYSH_BGPD, .path = BGP_VTYSH_PATH},
60: { .fd = -1, .name = "isisd", .flag = VTYSH_ISISD, .path = ISIS_VTYSH_PATH},
1.1.1.2 ! misho 61: { .fd = -1, .name = "babeld", .flag = VTYSH_BABELD, .path = BABEL_VTYSH_PATH},
1.1 misho 62: };
63:
64: #define VTYSH_INDEX_MAX (sizeof(vtysh_client)/sizeof(vtysh_client[0]))
65:
66: /* We need direct access to ripd to implement vtysh_exit_ripd_only. */
67: static struct vtysh_client *ripd_client = NULL;
68:
69:
70: /* Using integrated config from Quagga.conf. Default is no. */
71: int vtysh_writeconfig_integrated = 0;
72:
73: extern char config_default[];
74:
75: static void
76: vclient_close (struct vtysh_client *vclient)
77: {
78: if (vclient->fd >= 0)
79: {
80: fprintf(stderr,
81: "Warning: closing connection to %s because of an I/O error!\n",
82: vclient->name);
83: close (vclient->fd);
84: vclient->fd = -1;
85: }
86: }
87:
88: /* Following filled with debug code to trace a problematic condition
89: * under load - it SHOULD handle it. */
90: #define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): "
91: static int
92: vtysh_client_config (struct vtysh_client *vclient, char *line)
93: {
94: int ret;
95: char *buf;
96: size_t bufsz;
97: char *pbuf;
98: size_t left;
99: char *eoln;
100: int nbytes;
101: int i;
102: int readln;
103:
104: if (vclient->fd < 0)
105: return CMD_SUCCESS;
106:
107: ret = write (vclient->fd, line, strlen (line) + 1);
108: if (ret <= 0)
109: {
110: vclient_close (vclient);
111: return CMD_SUCCESS;
112: }
113:
114: /* Allow enough room for buffer to read more than a few pages from socket. */
115: bufsz = 5 * getpagesize() + 1;
116: buf = XMALLOC(MTYPE_TMP, bufsz);
117: memset(buf, 0, bufsz);
118: pbuf = buf;
119:
120: while (1)
121: {
122: if (pbuf >= ((buf + bufsz) -1))
123: {
124: fprintf (stderr, ERR_WHERE_STRING \
125: "warning - pbuf beyond buffer end.\n");
126: return CMD_WARNING;
127: }
128:
129: readln = (buf + bufsz) - pbuf - 1;
130: nbytes = read (vclient->fd, pbuf, readln);
131:
132: if (nbytes <= 0)
133: {
134:
135: if (errno == EINTR)
136: continue;
137:
138: fprintf(stderr, ERR_WHERE_STRING "(%u)", errno);
139: perror("");
140:
141: if (errno == EAGAIN || errno == EIO)
142: continue;
143:
144: vclient_close (vclient);
145: XFREE(MTYPE_TMP, buf);
146: return CMD_SUCCESS;
147: }
148:
149: pbuf[nbytes] = '\0';
150:
151: if (nbytes >= 4)
152: {
153: i = nbytes - 4;
154: if (pbuf[i] == '\0' && pbuf[i + 1] == '\0' && pbuf[i + 2] == '\0')
155: {
156: ret = pbuf[i + 3];
157: break;
158: }
159: }
160: pbuf += nbytes;
161:
162: /* See if a line exists in buffer, if so parse and consume it, and
163: * reset read position. */
164: if ((eoln = strrchr(buf, '\n')) == NULL)
165: continue;
166:
167: if (eoln >= ((buf + bufsz) - 1))
168: {
169: fprintf (stderr, ERR_WHERE_STRING \
170: "warning - eoln beyond buffer end.\n");
171: }
172: vtysh_config_parse(buf);
173:
174: eoln++;
175: left = (size_t)(buf + bufsz - eoln);
176: memmove(buf, eoln, left);
177: buf[bufsz-1] = '\0';
178: pbuf = buf + strlen(buf);
179: }
180:
181: /* Parse anything left in the buffer. */
182:
183: vtysh_config_parse (buf);
184:
185: XFREE(MTYPE_TMP, buf);
186: return ret;
187: }
188:
189: static int
190: vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp)
191: {
192: int ret;
193: char buf[1001];
194: int nbytes;
195: int i;
196: int numnulls = 0;
197:
198: if (vclient->fd < 0)
199: return CMD_SUCCESS;
200:
201: ret = write (vclient->fd, line, strlen (line) + 1);
202: if (ret <= 0)
203: {
204: vclient_close (vclient);
205: return CMD_SUCCESS;
206: }
207:
208: while (1)
209: {
210: nbytes = read (vclient->fd, buf, sizeof(buf)-1);
211:
212: if (nbytes <= 0 && errno != EINTR)
213: {
214: vclient_close (vclient);
215: return CMD_SUCCESS;
216: }
217:
218: if (nbytes > 0)
219: {
220: if ((numnulls == 3) && (nbytes == 1))
221: return buf[0];
222:
223: buf[nbytes] = '\0';
224: fputs (buf, fp);
225: fflush (fp);
226:
227: /* check for trailling \0\0\0<ret code>,
228: * even if split across reads
229: * (see lib/vty.c::vtysh_read)
230: */
231: if (nbytes >= 4)
232: {
233: i = nbytes-4;
234: numnulls = 0;
235: }
236: else
237: i = 0;
238:
239: while (i < nbytes && numnulls < 3)
240: {
241: if (buf[i++] == '\0')
242: numnulls++;
243: else
244: numnulls = 0;
245: }
246:
247: /* got 3 or more trailing NULs? */
248: if ((numnulls >= 3) && (i < nbytes))
249: return (buf[nbytes-1]);
250: }
251: }
252: }
253:
254: void
255: vtysh_exit_ripd_only (void)
256: {
257: if (ripd_client)
258: vtysh_client_execute (ripd_client, "exit", stdout);
259: }
260:
261:
262: void
263: vtysh_pager_init (void)
264: {
265: char *pager_defined;
266:
267: pager_defined = getenv ("VTYSH_PAGER");
268:
269: if (pager_defined)
270: vtysh_pager_name = strdup (pager_defined);
271: else
272: vtysh_pager_name = strdup ("more");
273: }
274:
275: /* Command execution over the vty interface. */
276: static int
277: vtysh_execute_func (const char *line, int pager)
278: {
279: int ret, cmd_stat;
280: u_int i;
281: vector vline;
282: struct cmd_element *cmd;
283: FILE *fp = NULL;
284: int closepager = 0;
285: int tried = 0;
286: int saved_ret, saved_node;
287:
288: /* Split readline string up into the vector. */
289: vline = cmd_make_strvec (line);
290:
291: if (vline == NULL)
292: return CMD_SUCCESS;
293:
294: saved_ret = ret = cmd_execute_command (vline, vty, &cmd, 1);
295: saved_node = vty->node;
296:
297: /* If command doesn't succeeded in current node, try to walk up in node tree.
298: * Changing vty->node is enough to try it just out without actual walkup in
299: * the vtysh. */
300: while (ret != CMD_SUCCESS && ret != CMD_SUCCESS_DAEMON && ret != CMD_WARNING
301: && vty->node > CONFIG_NODE)
302: {
303: vty->node = node_parent(vty->node);
304: ret = cmd_execute_command (vline, vty, &cmd, 1);
305: tried++;
306: }
307:
308: vty->node = saved_node;
309:
310: /* If command succeeded in any other node than current (tried > 0) we have
311: * to move into node in the vtysh where it succeeded. */
312: if (ret == CMD_SUCCESS || ret == CMD_SUCCESS_DAEMON || ret == CMD_WARNING)
313: {
314: if ((saved_node == BGP_VPNV4_NODE || saved_node == BGP_IPV4_NODE
315: || saved_node == BGP_IPV6_NODE || saved_node == BGP_IPV4M_NODE
316: || saved_node == BGP_IPV6M_NODE)
317: && (tried == 1))
318: {
319: vtysh_execute("exit-address-family");
320: }
321: else if ((saved_node == KEYCHAIN_KEY_NODE) && (tried == 1))
322: {
323: vtysh_execute("exit");
324: }
325: else if (tried)
326: {
327: vtysh_execute ("end");
328: vtysh_execute ("configure terminal");
329: }
330: }
331: /* If command didn't succeed in any node, continue with return value from
332: * first try. */
333: else if (tried)
334: {
335: ret = saved_ret;
336: }
337:
338: cmd_free_strvec (vline);
339:
340: cmd_stat = ret;
341: switch (ret)
342: {
343: case CMD_WARNING:
344: if (vty->type == VTY_FILE)
345: fprintf (stdout,"Warning...\n");
346: break;
347: case CMD_ERR_AMBIGUOUS:
348: fprintf (stdout,"%% Ambiguous command.\n");
349: break;
350: case CMD_ERR_NO_MATCH:
351: fprintf (stdout,"%% Unknown command.\n");
352: break;
353: case CMD_ERR_INCOMPLETE:
354: fprintf (stdout,"%% Command incomplete.\n");
355: break;
356: case CMD_SUCCESS_DAEMON:
357: {
358: /* FIXME: Don't open pager for exit commands. popen() causes problems
359: * if exited from vtysh at all. This hack shouldn't cause any problem
360: * but is really ugly. */
361: if (pager && vtysh_pager_name && (strncmp(line, "exit", 4) != 0))
362: {
363: fp = popen (vtysh_pager_name, "w");
364: if (fp == NULL)
365: {
366: perror ("popen failed for pager");
367: fp = stdout;
368: }
369: else
370: closepager=1;
371: }
372: else
373: fp = stdout;
374:
375: if (! strcmp(cmd->string,"configure terminal"))
376: {
377: for (i = 0; i < VTYSH_INDEX_MAX; i++)
378: {
379: cmd_stat = vtysh_client_execute(&vtysh_client[i], line, fp);
380: if (cmd_stat == CMD_WARNING)
381: break;
382: }
383:
384: if (cmd_stat)
385: {
386: line = "end";
387: vline = cmd_make_strvec (line);
388:
389: if (vline == NULL)
390: {
391: if (pager && vtysh_pager_name && fp && closepager)
392: {
393: if (pclose (fp) == -1)
394: {
395: perror ("pclose failed for pager");
396: }
397: fp = NULL;
398: }
399: return CMD_SUCCESS;
400: }
401:
402: ret = cmd_execute_command (vline, vty, &cmd, 1);
403: cmd_free_strvec (vline);
404: if (ret != CMD_SUCCESS_DAEMON)
405: break;
406: }
407: else
408: if (cmd->func)
409: {
410: (*cmd->func) (cmd, vty, 0, NULL);
411: break;
412: }
413: }
414:
415: cmd_stat = CMD_SUCCESS;
416: for (i = 0; i < VTYSH_INDEX_MAX; i++)
417: {
418: if (cmd->daemon & vtysh_client[i].flag)
419: {
420: cmd_stat = vtysh_client_execute(&vtysh_client[i], line, fp);
421: if (cmd_stat != CMD_SUCCESS)
422: break;
423: }
424: }
425: if (cmd_stat != CMD_SUCCESS)
426: break;
427:
428: if (cmd->func)
429: (*cmd->func) (cmd, vty, 0, NULL);
430: }
431: }
432: if (pager && vtysh_pager_name && fp && closepager)
433: {
434: if (pclose (fp) == -1)
435: {
436: perror ("pclose failed for pager");
437: }
438: fp = NULL;
439: }
440: return cmd_stat;
441: }
442:
443: int
444: vtysh_execute_no_pager (const char *line)
445: {
446: return vtysh_execute_func (line, 0);
447: }
448:
449: int
450: vtysh_execute (const char *line)
451: {
452: return vtysh_execute_func (line, 1);
453: }
454:
455: /* Configration make from file. */
456: int
457: vtysh_config_from_file (struct vty *vty, FILE *fp)
458: {
459: int ret;
460: vector vline;
461: struct cmd_element *cmd;
462:
463: while (fgets (vty->buf, VTY_BUFSIZ, fp))
464: {
465: if (vty->buf[0] == '!' || vty->buf[1] == '#')
466: continue;
467:
468: vline = cmd_make_strvec (vty->buf);
469:
470: /* In case of comment line. */
471: if (vline == NULL)
472: continue;
473:
474: /* Execute configuration command : this is strict match. */
475: ret = cmd_execute_command_strict (vline, vty, &cmd);
476:
477: /* Try again with setting node to CONFIG_NODE. */
478: if (ret != CMD_SUCCESS
479: && ret != CMD_SUCCESS_DAEMON
480: && ret != CMD_WARNING)
481: {
482: if (vty->node == KEYCHAIN_KEY_NODE)
483: {
484: vty->node = KEYCHAIN_NODE;
485: vtysh_exit_ripd_only ();
486: ret = cmd_execute_command_strict (vline, vty, &cmd);
487:
488: if (ret != CMD_SUCCESS
489: && ret != CMD_SUCCESS_DAEMON
490: && ret != CMD_WARNING)
491: {
492: vtysh_exit_ripd_only ();
493: vty->node = CONFIG_NODE;
494: ret = cmd_execute_command_strict (vline, vty, &cmd);
495: }
496: }
497: else
498: {
499: vtysh_execute ("end");
500: vtysh_execute ("configure terminal");
501: vty->node = CONFIG_NODE;
502: ret = cmd_execute_command_strict (vline, vty, &cmd);
503: }
504: }
505:
506: cmd_free_strvec (vline);
507:
508: switch (ret)
509: {
510: case CMD_WARNING:
511: if (vty->type == VTY_FILE)
512: fprintf (stdout,"Warning...\n");
513: break;
514: case CMD_ERR_AMBIGUOUS:
515: fprintf (stdout,"%% Ambiguous command.\n");
516: break;
517: case CMD_ERR_NO_MATCH:
518: fprintf (stdout,"%% Unknown command: %s", vty->buf);
519: break;
520: case CMD_ERR_INCOMPLETE:
521: fprintf (stdout,"%% Command incomplete.\n");
522: break;
523: case CMD_SUCCESS_DAEMON:
524: {
525: u_int i;
526: int cmd_stat = CMD_SUCCESS;
527:
528: for (i = 0; i < VTYSH_INDEX_MAX; i++)
529: {
530: if (cmd->daemon & vtysh_client[i].flag)
531: {
532: cmd_stat = vtysh_client_execute (&vtysh_client[i],
533: vty->buf, stdout);
534: if (cmd_stat != CMD_SUCCESS)
535: break;
536: }
537: }
538: if (cmd_stat != CMD_SUCCESS)
539: break;
540:
541: if (cmd->func)
542: (*cmd->func) (cmd, vty, 0, NULL);
543: }
544: }
545: }
546: return CMD_SUCCESS;
547: }
548:
549: /* We don't care about the point of the cursor when '?' is typed. */
550: int
551: vtysh_rl_describe (void)
552: {
553: int ret;
554: unsigned int i;
555: vector vline;
556: vector describe;
557: int width;
558: struct desc *desc;
559:
560: vline = cmd_make_strvec (rl_line_buffer);
561:
562: /* In case of '> ?'. */
563: if (vline == NULL)
564: {
565: vline = vector_init (1);
566: vector_set (vline, '\0');
567: }
568: else
569: if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
570: vector_set (vline, '\0');
571:
572: describe = cmd_describe_command (vline, vty, &ret);
573:
574: fprintf (stdout,"\n");
575:
576: /* Ambiguous and no match error. */
577: switch (ret)
578: {
579: case CMD_ERR_AMBIGUOUS:
580: cmd_free_strvec (vline);
581: fprintf (stdout,"%% Ambiguous command.\n");
582: rl_on_new_line ();
583: return 0;
584: break;
585: case CMD_ERR_NO_MATCH:
586: cmd_free_strvec (vline);
587: fprintf (stdout,"%% There is no matched command.\n");
588: rl_on_new_line ();
589: return 0;
590: break;
591: }
592:
593: /* Get width of command string. */
594: width = 0;
595: for (i = 0; i < vector_active (describe); i++)
596: if ((desc = vector_slot (describe, i)) != NULL)
597: {
598: int len;
599:
600: if (desc->cmd[0] == '\0')
601: continue;
602:
603: len = strlen (desc->cmd);
604: if (desc->cmd[0] == '.')
605: len--;
606:
607: if (width < len)
608: width = len;
609: }
610:
611: for (i = 0; i < vector_active (describe); i++)
612: if ((desc = vector_slot (describe, i)) != NULL)
613: {
614: if (desc->cmd[0] == '\0')
615: continue;
616:
617: if (! desc->str)
618: fprintf (stdout," %-s\n",
619: desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd);
620: else
621: fprintf (stdout," %-*s %s\n",
622: width,
623: desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd,
624: desc->str);
625: }
626:
627: cmd_free_strvec (vline);
628: vector_free (describe);
629:
630: rl_on_new_line();
631:
632: return 0;
633: }
634:
635: /* Result of cmd_complete_command() call will be stored here
636: * and used in new_completion() in order to put the space in
637: * correct places only. */
638: int complete_status;
639:
640: static char *
641: command_generator (const char *text, int state)
642: {
643: vector vline;
644: static char **matched = NULL;
645: static int index = 0;
646:
647: /* First call. */
648: if (! state)
649: {
650: index = 0;
651:
652: if (vty->node == AUTH_NODE || vty->node == AUTH_ENABLE_NODE)
653: return NULL;
654:
655: vline = cmd_make_strvec (rl_line_buffer);
656: if (vline == NULL)
657: return NULL;
658:
659: if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
660: vector_set (vline, '\0');
661:
662: matched = cmd_complete_command (vline, vty, &complete_status);
663: }
664:
665: if (matched && matched[index])
666: return matched[index++];
667:
668: return NULL;
669: }
670:
671: static char **
672: new_completion (char *text, int start, int end)
673: {
674: char **matches;
675:
676: matches = rl_completion_matches (text, command_generator);
677:
678: if (matches)
679: {
680: rl_point = rl_end;
681: if (complete_status == CMD_COMPLETE_FULL_MATCH)
682: rl_pending_input = ' ';
683: }
684:
685: return matches;
686: }
687:
688: #if 0
689: /* This function is not actually being used. */
690: static char **
691: vtysh_completion (char *text, int start, int end)
692: {
693: int ret;
694: vector vline;
695: char **matched = NULL;
696:
697: if (vty->node == AUTH_NODE || vty->node == AUTH_ENABLE_NODE)
698: return NULL;
699:
700: vline = cmd_make_strvec (rl_line_buffer);
701: if (vline == NULL)
702: return NULL;
703:
704: /* In case of 'help \t'. */
705: if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
706: vector_set (vline, '\0');
707:
708: matched = cmd_complete_command (vline, vty, &ret);
709:
710: cmd_free_strvec (vline);
711:
712: return (char **) matched;
713: }
714: #endif
715:
716: /* Vty node structures. */
717: static struct cmd_node bgp_node =
718: {
719: BGP_NODE,
720: "%s(config-router)# ",
721: };
722:
723: static struct cmd_node rip_node =
724: {
725: RIP_NODE,
726: "%s(config-router)# ",
727: };
728:
729: static struct cmd_node isis_node =
730: {
731: ISIS_NODE,
732: "%s(config-router)# ",
733: };
734:
735: static struct cmd_node interface_node =
736: {
737: INTERFACE_NODE,
738: "%s(config-if)# ",
739: };
740:
741: static struct cmd_node rmap_node =
742: {
743: RMAP_NODE,
744: "%s(config-route-map)# "
745: };
746:
747: static struct cmd_node zebra_node =
748: {
749: ZEBRA_NODE,
750: "%s(config-router)# "
751: };
752:
753: static struct cmd_node bgp_vpnv4_node =
754: {
755: BGP_VPNV4_NODE,
756: "%s(config-router-af)# "
757: };
758:
759: static struct cmd_node bgp_ipv4_node =
760: {
761: BGP_IPV4_NODE,
762: "%s(config-router-af)# "
763: };
764:
765: static struct cmd_node bgp_ipv4m_node =
766: {
767: BGP_IPV4M_NODE,
768: "%s(config-router-af)# "
769: };
770:
771: static struct cmd_node bgp_ipv6_node =
772: {
773: BGP_IPV6_NODE,
774: "%s(config-router-af)# "
775: };
776:
777: static struct cmd_node bgp_ipv6m_node =
778: {
779: BGP_IPV6M_NODE,
780: "%s(config-router-af)# "
781: };
782:
783: static struct cmd_node ospf_node =
784: {
785: OSPF_NODE,
786: "%s(config-router)# "
787: };
788:
789: static struct cmd_node ripng_node =
790: {
791: RIPNG_NODE,
792: "%s(config-router)# "
793: };
794:
795: static struct cmd_node ospf6_node =
796: {
797: OSPF6_NODE,
798: "%s(config-ospf6)# "
799: };
800:
1.1.1.2 ! misho 801: static struct cmd_node babel_node =
! 802: {
! 803: BABEL_NODE,
! 804: "%s(config-babel)# "
! 805: };
! 806:
1.1 misho 807: static struct cmd_node keychain_node =
808: {
809: KEYCHAIN_NODE,
810: "%s(config-keychain)# "
811: };
812:
813: static struct cmd_node keychain_key_node =
814: {
815: KEYCHAIN_KEY_NODE,
816: "%s(config-keychain-key)# "
817: };
818:
819: /* Defined in lib/vty.c */
820: extern struct cmd_node vty_node;
821:
822: /* When '^Z' is received from vty, move down to the enable mode. */
823: int
824: vtysh_end (void)
825: {
826: switch (vty->node)
827: {
828: case VIEW_NODE:
829: case ENABLE_NODE:
830: /* Nothing to do. */
831: break;
832: default:
833: vty->node = ENABLE_NODE;
834: break;
835: }
836: return CMD_SUCCESS;
837: }
838:
839: DEFUNSH (VTYSH_ALL,
840: vtysh_end_all,
841: vtysh_end_all_cmd,
842: "end",
843: "End current mode and change to enable mode\n")
844: {
845: return vtysh_end ();
846: }
847:
848: DEFUNSH (VTYSH_BGPD,
849: router_bgp,
850: router_bgp_cmd,
851: "router bgp " CMD_AS_RANGE,
852: ROUTER_STR
853: BGP_STR
854: AS_STR)
855: {
856: vty->node = BGP_NODE;
857: return CMD_SUCCESS;
858: }
859:
860: ALIAS_SH (VTYSH_BGPD,
861: router_bgp,
862: router_bgp_view_cmd,
863: "router bgp " CMD_AS_RANGE " view WORD",
864: ROUTER_STR
865: BGP_STR
866: AS_STR
867: "BGP view\n"
868: "view name\n")
869:
870: DEFUNSH (VTYSH_BGPD,
871: address_family_vpnv4,
872: address_family_vpnv4_cmd,
873: "address-family vpnv4",
874: "Enter Address Family command mode\n"
875: "Address family\n")
876: {
877: vty->node = BGP_VPNV4_NODE;
878: return CMD_SUCCESS;
879: }
880:
881: DEFUNSH (VTYSH_BGPD,
882: address_family_vpnv4_unicast,
883: address_family_vpnv4_unicast_cmd,
884: "address-family vpnv4 unicast",
885: "Enter Address Family command mode\n"
886: "Address family\n"
887: "Address Family Modifier\n")
888: {
889: vty->node = BGP_VPNV4_NODE;
890: return CMD_SUCCESS;
891: }
892:
893: DEFUNSH (VTYSH_BGPD,
894: address_family_ipv4_unicast,
895: address_family_ipv4_unicast_cmd,
896: "address-family ipv4 unicast",
897: "Enter Address Family command mode\n"
898: "Address family\n"
899: "Address Family Modifier\n")
900: {
901: vty->node = BGP_IPV4_NODE;
902: return CMD_SUCCESS;
903: }
904:
905: DEFUNSH (VTYSH_BGPD,
906: address_family_ipv4_multicast,
907: address_family_ipv4_multicast_cmd,
908: "address-family ipv4 multicast",
909: "Enter Address Family command mode\n"
910: "Address family\n"
911: "Address Family Modifier\n")
912: {
913: vty->node = BGP_IPV4M_NODE;
914: return CMD_SUCCESS;
915: }
916:
917: DEFUNSH (VTYSH_BGPD,
918: address_family_ipv6,
919: address_family_ipv6_cmd,
920: "address-family ipv6",
921: "Enter Address Family command mode\n"
922: "Address family\n")
923: {
924: vty->node = BGP_IPV6_NODE;
925: return CMD_SUCCESS;
926: }
927:
928: DEFUNSH (VTYSH_BGPD,
929: address_family_ipv6_unicast,
930: address_family_ipv6_unicast_cmd,
931: "address-family ipv6 unicast",
932: "Enter Address Family command mode\n"
933: "Address family\n"
934: "Address Family Modifier\n")
935: {
936: vty->node = BGP_IPV6_NODE;
937: return CMD_SUCCESS;
938: }
939:
940: DEFUNSH (VTYSH_BGPD,
941: address_family_ipv6_multicast,
942: address_family_ipv6_multicast_cmd,
943: "address-family ipv6 multicast",
944: "Enter Address Family command mode\n"
945: "Address family\n"
946: "Address Family Modifier\n")
947: {
948: vty->node = BGP_IPV6M_NODE;
949: return CMD_SUCCESS;
950: }
951:
952: DEFUNSH (VTYSH_RIPD,
953: key_chain,
954: key_chain_cmd,
955: "key chain WORD",
956: "Authentication key management\n"
957: "Key-chain management\n"
958: "Key-chain name\n")
959: {
960: vty->node = KEYCHAIN_NODE;
961: return CMD_SUCCESS;
962: }
963:
964: DEFUNSH (VTYSH_RIPD,
965: key,
966: key_cmd,
967: "key <0-2147483647>",
968: "Configure a key\n"
969: "Key identifier number\n")
970: {
971: vty->node = KEYCHAIN_KEY_NODE;
972: return CMD_SUCCESS;
973: }
974:
975: DEFUNSH (VTYSH_RIPD,
976: router_rip,
977: router_rip_cmd,
978: "router rip",
979: ROUTER_STR
980: "RIP")
981: {
982: vty->node = RIP_NODE;
983: return CMD_SUCCESS;
984: }
985:
986: DEFUNSH (VTYSH_RIPNGD,
987: router_ripng,
988: router_ripng_cmd,
989: "router ripng",
990: ROUTER_STR
991: "RIPng")
992: {
993: vty->node = RIPNG_NODE;
994: return CMD_SUCCESS;
995: }
996:
997: DEFUNSH (VTYSH_OSPFD,
998: router_ospf,
999: router_ospf_cmd,
1000: "router ospf",
1001: "Enable a routing process\n"
1002: "Start OSPF configuration\n")
1003: {
1004: vty->node = OSPF_NODE;
1005: return CMD_SUCCESS;
1006: }
1007:
1008: DEFUNSH (VTYSH_OSPF6D,
1009: router_ospf6,
1010: router_ospf6_cmd,
1011: "router ospf6",
1012: OSPF6_ROUTER_STR
1013: OSPF6_STR)
1014: {
1015: vty->node = OSPF6_NODE;
1016: return CMD_SUCCESS;
1017: }
1018:
1.1.1.2 ! misho 1019: DEFUNSH (VTYSH_BABELD,
! 1020: router_babel,
! 1021: router_babel_cmd,
! 1022: "router babel",
! 1023: ROUTER_STR
! 1024: "Babel")
! 1025: {
! 1026: vty->node = BABEL_NODE;
! 1027: return CMD_SUCCESS;
! 1028: }
! 1029:
1.1 misho 1030: DEFUNSH (VTYSH_ISISD,
1031: router_isis,
1032: router_isis_cmd,
1033: "router isis WORD",
1034: ROUTER_STR
1035: "ISO IS-IS\n"
1036: "ISO Routing area tag")
1037: {
1038: vty->node = ISIS_NODE;
1039: return CMD_SUCCESS;
1040: }
1041:
1042: DEFUNSH (VTYSH_RMAP,
1043: route_map,
1044: route_map_cmd,
1045: "route-map WORD (deny|permit) <1-65535>",
1046: "Create route-map or enter route-map command mode\n"
1047: "Route map tag\n"
1048: "Route map denies set operations\n"
1049: "Route map permits set operations\n"
1050: "Sequence to insert to/delete from existing route-map entry\n")
1051: {
1052: vty->node = RMAP_NODE;
1053: return CMD_SUCCESS;
1054: }
1055:
1056: DEFUNSH (VTYSH_ALL,
1057: vtysh_line_vty,
1058: vtysh_line_vty_cmd,
1059: "line vty",
1060: "Configure a terminal line\n"
1061: "Virtual terminal\n")
1062: {
1063: vty->node = VTY_NODE;
1064: return CMD_SUCCESS;
1065: }
1066:
1067: DEFUNSH (VTYSH_ALL,
1068: vtysh_enable,
1069: vtysh_enable_cmd,
1070: "enable",
1071: "Turn on privileged mode command\n")
1072: {
1073: vty->node = ENABLE_NODE;
1074: return CMD_SUCCESS;
1075: }
1076:
1077: DEFUNSH (VTYSH_ALL,
1078: vtysh_disable,
1079: vtysh_disable_cmd,
1080: "disable",
1081: "Turn off privileged mode command\n")
1082: {
1083: if (vty->node == ENABLE_NODE)
1084: vty->node = VIEW_NODE;
1085: return CMD_SUCCESS;
1086: }
1087:
1088: DEFUNSH (VTYSH_ALL,
1089: vtysh_config_terminal,
1090: vtysh_config_terminal_cmd,
1091: "configure terminal",
1092: "Configuration from vty interface\n"
1093: "Configuration terminal\n")
1094: {
1095: vty->node = CONFIG_NODE;
1096: return CMD_SUCCESS;
1097: }
1098:
1099: static int
1100: vtysh_exit (struct vty *vty)
1101: {
1102: switch (vty->node)
1103: {
1104: case VIEW_NODE:
1105: case ENABLE_NODE:
1106: exit (0);
1107: break;
1108: case CONFIG_NODE:
1109: vty->node = ENABLE_NODE;
1110: break;
1111: case INTERFACE_NODE:
1112: case ZEBRA_NODE:
1113: case BGP_NODE:
1114: case RIP_NODE:
1115: case RIPNG_NODE:
1116: case OSPF_NODE:
1117: case OSPF6_NODE:
1.1.1.2 ! misho 1118: case BABEL_NODE:
1.1 misho 1119: case ISIS_NODE:
1120: case MASC_NODE:
1121: case RMAP_NODE:
1122: case VTY_NODE:
1123: case KEYCHAIN_NODE:
1124: vtysh_execute("end");
1125: vtysh_execute("configure terminal");
1126: vty->node = CONFIG_NODE;
1127: break;
1128: case BGP_VPNV4_NODE:
1129: case BGP_IPV4_NODE:
1130: case BGP_IPV4M_NODE:
1131: case BGP_IPV6_NODE:
1132: case BGP_IPV6M_NODE:
1133: vty->node = BGP_NODE;
1134: break;
1135: case KEYCHAIN_KEY_NODE:
1136: vty->node = KEYCHAIN_NODE;
1137: break;
1138: default:
1139: break;
1140: }
1141: return CMD_SUCCESS;
1142: }
1143:
1144: DEFUNSH (VTYSH_ALL,
1145: vtysh_exit_all,
1146: vtysh_exit_all_cmd,
1147: "exit",
1148: "Exit current mode and down to previous mode\n")
1149: {
1150: return vtysh_exit (vty);
1151: }
1152:
1153: ALIAS (vtysh_exit_all,
1154: vtysh_quit_all_cmd,
1155: "quit",
1156: "Exit current mode and down to previous mode\n")
1157:
1158: DEFUNSH (VTYSH_BGPD,
1159: exit_address_family,
1160: exit_address_family_cmd,
1161: "exit-address-family",
1162: "Exit from Address Family configuration mode\n")
1163: {
1164: if (vty->node == BGP_IPV4_NODE
1165: || vty->node == BGP_IPV4M_NODE
1166: || vty->node == BGP_VPNV4_NODE
1167: || vty->node == BGP_IPV6_NODE
1168: || vty->node == BGP_IPV6M_NODE)
1169: vty->node = BGP_NODE;
1170: return CMD_SUCCESS;
1171: }
1172:
1173: DEFUNSH (VTYSH_ZEBRA,
1174: vtysh_exit_zebra,
1175: vtysh_exit_zebra_cmd,
1176: "exit",
1177: "Exit current mode and down to previous mode\n")
1178: {
1179: return vtysh_exit (vty);
1180: }
1181:
1182: ALIAS (vtysh_exit_zebra,
1183: vtysh_quit_zebra_cmd,
1184: "quit",
1185: "Exit current mode and down to previous mode\n")
1186:
1187: DEFUNSH (VTYSH_RIPD,
1188: vtysh_exit_ripd,
1189: vtysh_exit_ripd_cmd,
1190: "exit",
1191: "Exit current mode and down to previous mode\n")
1192: {
1193: return vtysh_exit (vty);
1194: }
1195:
1196: ALIAS (vtysh_exit_ripd,
1197: vtysh_quit_ripd_cmd,
1198: "quit",
1199: "Exit current mode and down to previous mode\n")
1200:
1201: DEFUNSH (VTYSH_RIPNGD,
1202: vtysh_exit_ripngd,
1203: vtysh_exit_ripngd_cmd,
1204: "exit",
1205: "Exit current mode and down to previous mode\n")
1206: {
1207: return vtysh_exit (vty);
1208: }
1209:
1210: ALIAS (vtysh_exit_ripngd,
1211: vtysh_quit_ripngd_cmd,
1212: "quit",
1213: "Exit current mode and down to previous mode\n")
1214:
1215: DEFUNSH (VTYSH_RMAP,
1216: vtysh_exit_rmap,
1217: vtysh_exit_rmap_cmd,
1218: "exit",
1219: "Exit current mode and down to previous mode\n")
1220: {
1221: return vtysh_exit (vty);
1222: }
1223:
1224: ALIAS (vtysh_exit_rmap,
1225: vtysh_quit_rmap_cmd,
1226: "quit",
1227: "Exit current mode and down to previous mode\n")
1228:
1229: DEFUNSH (VTYSH_BGPD,
1230: vtysh_exit_bgpd,
1231: vtysh_exit_bgpd_cmd,
1232: "exit",
1233: "Exit current mode and down to previous mode\n")
1234: {
1235: return vtysh_exit (vty);
1236: }
1237:
1238: ALIAS (vtysh_exit_bgpd,
1239: vtysh_quit_bgpd_cmd,
1240: "quit",
1241: "Exit current mode and down to previous mode\n")
1242:
1243: DEFUNSH (VTYSH_OSPFD,
1244: vtysh_exit_ospfd,
1245: vtysh_exit_ospfd_cmd,
1246: "exit",
1247: "Exit current mode and down to previous mode\n")
1248: {
1249: return vtysh_exit (vty);
1250: }
1251:
1252: ALIAS (vtysh_exit_ospfd,
1253: vtysh_quit_ospfd_cmd,
1254: "quit",
1255: "Exit current mode and down to previous mode\n")
1256:
1257: DEFUNSH (VTYSH_OSPF6D,
1258: vtysh_exit_ospf6d,
1259: vtysh_exit_ospf6d_cmd,
1260: "exit",
1261: "Exit current mode and down to previous mode\n")
1262: {
1263: return vtysh_exit (vty);
1264: }
1265:
1266: ALIAS (vtysh_exit_ospf6d,
1267: vtysh_quit_ospf6d_cmd,
1268: "quit",
1269: "Exit current mode and down to previous mode\n")
1270:
1271: DEFUNSH (VTYSH_ISISD,
1272: vtysh_exit_isisd,
1273: vtysh_exit_isisd_cmd,
1274: "exit",
1275: "Exit current mode and down to previous mode\n")
1276: {
1277: return vtysh_exit (vty);
1278: }
1279:
1280: ALIAS (vtysh_exit_isisd,
1281: vtysh_quit_isisd_cmd,
1282: "quit",
1283: "Exit current mode and down to previous mode\n")
1284:
1285: DEFUNSH (VTYSH_ALL,
1286: vtysh_exit_line_vty,
1287: vtysh_exit_line_vty_cmd,
1288: "exit",
1289: "Exit current mode and down to previous mode\n")
1290: {
1291: return vtysh_exit (vty);
1292: }
1293:
1294: ALIAS (vtysh_exit_line_vty,
1295: vtysh_quit_line_vty_cmd,
1296: "quit",
1297: "Exit current mode and down to previous mode\n")
1298:
1299: DEFUNSH (VTYSH_INTERFACE,
1300: vtysh_interface,
1301: vtysh_interface_cmd,
1302: "interface IFNAME",
1303: "Select an interface to configure\n"
1304: "Interface's name\n")
1305: {
1306: vty->node = INTERFACE_NODE;
1307: return CMD_SUCCESS;
1308: }
1309:
1310: /* TODO Implement "no interface command in isisd. */
1311: DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D,
1312: vtysh_no_interface_cmd,
1313: "no interface IFNAME",
1314: NO_STR
1315: "Delete a pseudo interface's configuration\n"
1316: "Interface's name\n")
1317:
1318: /* TODO Implement interface description commands in ripngd, ospf6d
1319: * and isisd. */
1320: DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD,
1321: interface_desc_cmd,
1322: "description .LINE",
1323: "Interface specific description\n"
1324: "Characters describing this interface\n")
1325:
1326: DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD,
1327: no_interface_desc_cmd,
1328: "no description",
1329: NO_STR
1330: "Interface specific description\n")
1331:
1332: DEFUNSH (VTYSH_INTERFACE,
1333: vtysh_exit_interface,
1334: vtysh_exit_interface_cmd,
1335: "exit",
1336: "Exit current mode and down to previous mode\n")
1337: {
1338: return vtysh_exit (vty);
1339: }
1340:
1341: ALIAS (vtysh_exit_interface,
1342: vtysh_quit_interface_cmd,
1343: "quit",
1344: "Exit current mode and down to previous mode\n")
1345:
1346: /* Memory */
1347: DEFUN (vtysh_show_memory,
1348: vtysh_show_memory_cmd,
1349: "show memory",
1350: SHOW_STR
1351: "Memory statistics\n")
1352: {
1353: unsigned int i;
1354: int ret = CMD_SUCCESS;
1355: char line[] = "show memory\n";
1356:
1357: for (i = 0; i < VTYSH_INDEX_MAX; i++)
1358: if ( vtysh_client[i].fd >= 0 )
1359: {
1360: fprintf (stdout, "Memory statistics for %s:\n",
1361: vtysh_client[i].name);
1362: ret = vtysh_client_execute (&vtysh_client[i], line, stdout);
1363: fprintf (stdout,"\n");
1364: }
1365:
1366: return ret;
1367: }
1368:
1369: /* Logging commands. */
1370: DEFUN (vtysh_show_logging,
1371: vtysh_show_logging_cmd,
1372: "show logging",
1373: SHOW_STR
1374: "Show current logging configuration\n")
1375: {
1376: unsigned int i;
1377: int ret = CMD_SUCCESS;
1378: char line[] = "show logging\n";
1379:
1380: for (i = 0; i < VTYSH_INDEX_MAX; i++)
1381: if ( vtysh_client[i].fd >= 0 )
1382: {
1383: fprintf (stdout,"Logging configuration for %s:\n",
1384: vtysh_client[i].name);
1385: ret = vtysh_client_execute (&vtysh_client[i], line, stdout);
1386: fprintf (stdout,"\n");
1387: }
1388:
1389: return ret;
1390: }
1391:
1392: DEFUNSH (VTYSH_ALL,
1393: vtysh_log_stdout,
1394: vtysh_log_stdout_cmd,
1395: "log stdout",
1396: "Logging control\n"
1397: "Set stdout logging level\n")
1398: {
1399: return CMD_SUCCESS;
1400: }
1401:
1402: DEFUNSH (VTYSH_ALL,
1403: vtysh_log_stdout_level,
1404: vtysh_log_stdout_level_cmd,
1405: "log stdout "LOG_LEVELS,
1406: "Logging control\n"
1407: "Set stdout logging level\n"
1408: LOG_LEVEL_DESC)
1409: {
1410: return CMD_SUCCESS;
1411: }
1412:
1413: DEFUNSH (VTYSH_ALL,
1414: no_vtysh_log_stdout,
1415: no_vtysh_log_stdout_cmd,
1416: "no log stdout [LEVEL]",
1417: NO_STR
1418: "Logging control\n"
1419: "Cancel logging to stdout\n"
1420: "Logging level\n")
1421: {
1422: return CMD_SUCCESS;
1423: }
1424:
1425: DEFUNSH (VTYSH_ALL,
1426: vtysh_log_file,
1427: vtysh_log_file_cmd,
1428: "log file FILENAME",
1429: "Logging control\n"
1430: "Logging to file\n"
1431: "Logging filename\n")
1432: {
1433: return CMD_SUCCESS;
1434: }
1435:
1436: DEFUNSH (VTYSH_ALL,
1437: vtysh_log_file_level,
1438: vtysh_log_file_level_cmd,
1439: "log file FILENAME "LOG_LEVELS,
1440: "Logging control\n"
1441: "Logging to file\n"
1442: "Logging filename\n"
1443: LOG_LEVEL_DESC)
1444: {
1445: return CMD_SUCCESS;
1446: }
1447:
1448: DEFUNSH (VTYSH_ALL,
1449: no_vtysh_log_file,
1450: no_vtysh_log_file_cmd,
1451: "no log file [FILENAME]",
1452: NO_STR
1453: "Logging control\n"
1454: "Cancel logging to file\n"
1455: "Logging file name\n")
1456: {
1457: return CMD_SUCCESS;
1458: }
1459:
1460: ALIAS_SH (VTYSH_ALL,
1461: no_vtysh_log_file,
1462: no_vtysh_log_file_level_cmd,
1463: "no log file FILENAME LEVEL",
1464: NO_STR
1465: "Logging control\n"
1466: "Cancel logging to file\n"
1467: "Logging file name\n"
1468: "Logging level\n")
1469:
1470: DEFUNSH (VTYSH_ALL,
1471: vtysh_log_monitor,
1472: vtysh_log_monitor_cmd,
1473: "log monitor",
1474: "Logging control\n"
1475: "Set terminal line (monitor) logging level\n")
1476: {
1477: return CMD_SUCCESS;
1478: }
1479:
1480: DEFUNSH (VTYSH_ALL,
1481: vtysh_log_monitor_level,
1482: vtysh_log_monitor_level_cmd,
1483: "log monitor "LOG_LEVELS,
1484: "Logging control\n"
1485: "Set terminal line (monitor) logging level\n"
1486: LOG_LEVEL_DESC)
1487: {
1488: return CMD_SUCCESS;
1489: }
1490:
1491: DEFUNSH (VTYSH_ALL,
1492: no_vtysh_log_monitor,
1493: no_vtysh_log_monitor_cmd,
1494: "no log monitor [LEVEL]",
1495: NO_STR
1496: "Logging control\n"
1497: "Disable terminal line (monitor) logging\n"
1498: "Logging level\n")
1499: {
1500: return CMD_SUCCESS;
1501: }
1502:
1503: DEFUNSH (VTYSH_ALL,
1504: vtysh_log_syslog,
1505: vtysh_log_syslog_cmd,
1506: "log syslog",
1507: "Logging control\n"
1508: "Set syslog logging level\n")
1509: {
1510: return CMD_SUCCESS;
1511: }
1512:
1513: DEFUNSH (VTYSH_ALL,
1514: vtysh_log_syslog_level,
1515: vtysh_log_syslog_level_cmd,
1516: "log syslog "LOG_LEVELS,
1517: "Logging control\n"
1518: "Set syslog logging level\n"
1519: LOG_LEVEL_DESC)
1520: {
1521: return CMD_SUCCESS;
1522: }
1523:
1524: DEFUNSH (VTYSH_ALL,
1525: no_vtysh_log_syslog,
1526: no_vtysh_log_syslog_cmd,
1527: "no log syslog [LEVEL]",
1528: NO_STR
1529: "Logging control\n"
1530: "Cancel logging to syslog\n"
1531: "Logging level\n")
1532: {
1533: return CMD_SUCCESS;
1534: }
1535:
1536: DEFUNSH (VTYSH_ALL,
1537: vtysh_log_facility,
1538: vtysh_log_facility_cmd,
1539: "log facility "LOG_FACILITIES,
1540: "Logging control\n"
1541: "Facility parameter for syslog messages\n"
1542: LOG_FACILITY_DESC)
1543:
1544: {
1545: return CMD_SUCCESS;
1546: }
1547:
1548: DEFUNSH (VTYSH_ALL,
1549: no_vtysh_log_facility,
1550: no_vtysh_log_facility_cmd,
1551: "no log facility [FACILITY]",
1552: NO_STR
1553: "Logging control\n"
1554: "Reset syslog facility to default (daemon)\n"
1555: "Syslog facility\n")
1556:
1557: {
1558: return CMD_SUCCESS;
1559: }
1560:
1561: DEFUNSH_DEPRECATED (VTYSH_ALL,
1562: vtysh_log_trap,
1563: vtysh_log_trap_cmd,
1564: "log trap "LOG_LEVELS,
1565: "Logging control\n"
1566: "(Deprecated) Set logging level and default for all destinations\n"
1567: LOG_LEVEL_DESC)
1568:
1569: {
1570: return CMD_SUCCESS;
1571: }
1572:
1573: DEFUNSH_DEPRECATED (VTYSH_ALL,
1574: no_vtysh_log_trap,
1575: no_vtysh_log_trap_cmd,
1576: "no log trap [LEVEL]",
1577: NO_STR
1578: "Logging control\n"
1579: "Permit all logging information\n"
1580: "Logging level\n")
1581: {
1582: return CMD_SUCCESS;
1583: }
1584:
1585: DEFUNSH (VTYSH_ALL,
1586: vtysh_log_record_priority,
1587: vtysh_log_record_priority_cmd,
1588: "log record-priority",
1589: "Logging control\n"
1590: "Log the priority of the message within the message\n")
1591: {
1592: return CMD_SUCCESS;
1593: }
1594:
1595: DEFUNSH (VTYSH_ALL,
1596: no_vtysh_log_record_priority,
1597: no_vtysh_log_record_priority_cmd,
1598: "no log record-priority",
1599: NO_STR
1600: "Logging control\n"
1601: "Do not log the priority of the message within the message\n")
1602: {
1603: return CMD_SUCCESS;
1604: }
1605:
1606: DEFUNSH (VTYSH_ALL,
1607: vtysh_log_timestamp_precision,
1608: vtysh_log_timestamp_precision_cmd,
1609: "log timestamp precision <0-6>",
1610: "Logging control\n"
1611: "Timestamp configuration\n"
1612: "Set the timestamp precision\n"
1613: "Number of subsecond digits\n")
1614: {
1615: return CMD_SUCCESS;
1616: }
1617:
1618: DEFUNSH (VTYSH_ALL,
1619: no_vtysh_log_timestamp_precision,
1620: no_vtysh_log_timestamp_precision_cmd,
1621: "no log timestamp precision",
1622: NO_STR
1623: "Logging control\n"
1624: "Timestamp configuration\n"
1625: "Reset the timestamp precision to the default value of 0\n")
1626: {
1627: return CMD_SUCCESS;
1628: }
1629:
1630: DEFUNSH (VTYSH_ALL,
1631: vtysh_service_password_encrypt,
1632: vtysh_service_password_encrypt_cmd,
1633: "service password-encryption",
1634: "Set up miscellaneous service\n"
1635: "Enable encrypted passwords\n")
1636: {
1637: return CMD_SUCCESS;
1638: }
1639:
1640: DEFUNSH (VTYSH_ALL,
1641: no_vtysh_service_password_encrypt,
1642: no_vtysh_service_password_encrypt_cmd,
1643: "no service password-encryption",
1644: NO_STR
1645: "Set up miscellaneous service\n"
1646: "Enable encrypted passwords\n")
1647: {
1648: return CMD_SUCCESS;
1649: }
1650:
1651: DEFUNSH (VTYSH_ALL,
1652: vtysh_config_password,
1653: vtysh_password_cmd,
1654: "password (8|) WORD",
1655: "Assign the terminal connection password\n"
1656: "Specifies a HIDDEN password will follow\n"
1657: "dummy string \n"
1658: "The HIDDEN line password string\n")
1659: {
1660: return CMD_SUCCESS;
1661: }
1662:
1663: DEFUNSH (VTYSH_ALL,
1664: vtysh_password_text,
1665: vtysh_password_text_cmd,
1666: "password LINE",
1667: "Assign the terminal connection password\n"
1668: "The UNENCRYPTED (cleartext) line password\n")
1669: {
1670: return CMD_SUCCESS;
1671: }
1672:
1673: DEFUNSH (VTYSH_ALL,
1674: vtysh_config_enable_password,
1675: vtysh_enable_password_cmd,
1676: "enable password (8|) WORD",
1677: "Modify enable password parameters\n"
1678: "Assign the privileged level password\n"
1679: "Specifies a HIDDEN password will follow\n"
1680: "dummy string \n"
1681: "The HIDDEN 'enable' password string\n")
1682: {
1683: return CMD_SUCCESS;
1684: }
1685:
1686: DEFUNSH (VTYSH_ALL,
1687: vtysh_enable_password_text,
1688: vtysh_enable_password_text_cmd,
1689: "enable password LINE",
1690: "Modify enable password parameters\n"
1691: "Assign the privileged level password\n"
1692: "The UNENCRYPTED (cleartext) 'enable' password\n")
1693: {
1694: return CMD_SUCCESS;
1695: }
1696:
1697: DEFUNSH (VTYSH_ALL,
1698: no_vtysh_config_enable_password,
1699: no_vtysh_enable_password_cmd,
1700: "no enable password",
1701: NO_STR
1702: "Modify enable password parameters\n"
1703: "Assign the privileged level password\n")
1704: {
1705: return CMD_SUCCESS;
1706: }
1707:
1708: DEFUN (vtysh_write_terminal,
1709: vtysh_write_terminal_cmd,
1710: "write terminal",
1711: "Write running configuration to memory, network, or terminal\n"
1712: "Write to terminal\n")
1713: {
1714: u_int i;
1715: int ret;
1716: char line[] = "write terminal\n";
1717: FILE *fp = NULL;
1718:
1719: if (vtysh_pager_name)
1720: {
1721: fp = popen (vtysh_pager_name, "w");
1722: if (fp == NULL)
1723: {
1724: perror ("popen");
1725: exit (1);
1726: }
1727: }
1728: else
1729: fp = stdout;
1730:
1731: vty_out (vty, "Building configuration...%s", VTY_NEWLINE);
1732: vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE,
1733: VTY_NEWLINE);
1734: vty_out (vty, "!%s", VTY_NEWLINE);
1735:
1736: for (i = 0; i < VTYSH_INDEX_MAX; i++)
1737: ret = vtysh_client_config (&vtysh_client[i], line);
1738:
1739: /* Integrate vtysh specific configuration. */
1740: vtysh_config_write ();
1741:
1742: vtysh_config_dump (fp);
1743:
1744: if (vtysh_pager_name && fp)
1745: {
1746: fflush (fp);
1747: if (pclose (fp) == -1)
1748: {
1749: perror ("pclose");
1750: exit (1);
1751: }
1752: fp = NULL;
1753: }
1754:
1755: vty_out (vty, "end%s", VTY_NEWLINE);
1756:
1757: return CMD_SUCCESS;
1758: }
1759:
1760: DEFUN (vtysh_integrated_config,
1761: vtysh_integrated_config_cmd,
1762: "service integrated-vtysh-config",
1763: "Set up miscellaneous service\n"
1764: "Write configuration into integrated file\n")
1765: {
1766: vtysh_writeconfig_integrated = 1;
1767: return CMD_SUCCESS;
1768: }
1769:
1770: DEFUN (no_vtysh_integrated_config,
1771: no_vtysh_integrated_config_cmd,
1772: "no service integrated-vtysh-config",
1773: NO_STR
1774: "Set up miscellaneous service\n"
1775: "Write configuration into integrated file\n")
1776: {
1777: vtysh_writeconfig_integrated = 0;
1778: return CMD_SUCCESS;
1779: }
1780:
1781: static int
1782: write_config_integrated(void)
1783: {
1784: u_int i;
1785: int ret;
1786: char line[] = "write terminal\n";
1787: FILE *fp;
1788: char *integrate_sav = NULL;
1789:
1790: integrate_sav = malloc (strlen (integrate_default) +
1791: strlen (CONF_BACKUP_EXT) + 1);
1792: strcpy (integrate_sav, integrate_default);
1793: strcat (integrate_sav, CONF_BACKUP_EXT);
1794:
1795: fprintf (stdout,"Building Configuration...\n");
1796:
1797: /* Move current configuration file to backup config file. */
1798: unlink (integrate_sav);
1799: rename (integrate_default, integrate_sav);
1800: free (integrate_sav);
1801:
1802: fp = fopen (integrate_default, "w");
1803: if (fp == NULL)
1804: {
1805: fprintf (stdout,"%% Can't open configuration file %s.\n",
1806: integrate_default);
1807: return CMD_SUCCESS;
1808: }
1809:
1810: for (i = 0; i < VTYSH_INDEX_MAX; i++)
1811: ret = vtysh_client_config (&vtysh_client[i], line);
1812:
1813: vtysh_config_dump (fp);
1814:
1815: fclose (fp);
1816:
1817: if (chmod (integrate_default, CONFIGFILE_MASK) != 0)
1818: {
1819: fprintf (stdout,"%% Can't chmod configuration file %s: %s (%d)\n",
1820: integrate_default, safe_strerror(errno), errno);
1821: return CMD_WARNING;
1822: }
1823:
1824: fprintf(stdout,"Integrated configuration saved to %s\n",integrate_default);
1825:
1826: fprintf (stdout,"[OK]\n");
1827:
1828: return CMD_SUCCESS;
1829: }
1830:
1831: DEFUN (vtysh_write_memory,
1832: vtysh_write_memory_cmd,
1833: "write memory",
1834: "Write running configuration to memory, network, or terminal\n"
1835: "Write configuration to the file (same as write file)\n")
1836: {
1837: int ret = CMD_SUCCESS;
1838: char line[] = "write memory\n";
1839: u_int i;
1840:
1841: /* If integrated Quagga.conf explicitely set. */
1842: if (vtysh_writeconfig_integrated)
1843: return write_config_integrated();
1844:
1845: fprintf (stdout,"Building Configuration...\n");
1846:
1847: for (i = 0; i < VTYSH_INDEX_MAX; i++)
1848: ret = vtysh_client_execute (&vtysh_client[i], line, stdout);
1849:
1850: fprintf (stdout,"[OK]\n");
1851:
1852: return ret;
1853: }
1854:
1855: ALIAS (vtysh_write_memory,
1856: vtysh_copy_runningconfig_startupconfig_cmd,
1857: "copy running-config startup-config",
1858: "Copy from one file to another\n"
1859: "Copy from current system configuration\n"
1860: "Copy to startup configuration\n")
1861:
1862: ALIAS (vtysh_write_memory,
1863: vtysh_write_file_cmd,
1864: "write file",
1865: "Write running configuration to memory, network, or terminal\n"
1866: "Write configuration to the file (same as write memory)\n")
1867:
1868: ALIAS (vtysh_write_memory,
1869: vtysh_write_cmd,
1870: "write",
1871: "Write running configuration to memory, network, or terminal\n")
1872:
1873: ALIAS (vtysh_write_terminal,
1874: vtysh_show_running_config_cmd,
1875: "show running-config",
1876: SHOW_STR
1877: "Current operating configuration\n")
1878:
1879: DEFUN (vtysh_terminal_length,
1880: vtysh_terminal_length_cmd,
1881: "terminal length <0-512>",
1882: "Set terminal line parameters\n"
1883: "Set number of lines on a screen\n"
1884: "Number of lines on screen (0 for no pausing)\n")
1885: {
1886: int lines;
1887: char *endptr = NULL;
1888: char default_pager[10];
1889:
1890: lines = strtol (argv[0], &endptr, 10);
1891: if (lines < 0 || lines > 512 || *endptr != '\0')
1892: {
1893: vty_out (vty, "length is malformed%s", VTY_NEWLINE);
1894: return CMD_WARNING;
1895: }
1896:
1897: if (vtysh_pager_name)
1898: {
1899: free (vtysh_pager_name);
1900: vtysh_pager_name = NULL;
1901: }
1902:
1903: if (lines != 0)
1904: {
1905: snprintf(default_pager, 10, "more -%i", lines);
1906: vtysh_pager_name = strdup (default_pager);
1907: }
1908:
1909: return CMD_SUCCESS;
1910: }
1911:
1912: DEFUN (vtysh_terminal_no_length,
1913: vtysh_terminal_no_length_cmd,
1914: "terminal no length",
1915: "Set terminal line parameters\n"
1916: NO_STR
1917: "Set number of lines on a screen\n")
1918: {
1919: if (vtysh_pager_name)
1920: {
1921: free (vtysh_pager_name);
1922: vtysh_pager_name = NULL;
1923: }
1924:
1925: vtysh_pager_init();
1926: return CMD_SUCCESS;
1927: }
1928:
1929: DEFUN (vtysh_show_daemons,
1930: vtysh_show_daemons_cmd,
1931: "show daemons",
1932: SHOW_STR
1933: "Show list of running daemons\n")
1934: {
1935: u_int i;
1936:
1937: for (i = 0; i < VTYSH_INDEX_MAX; i++)
1938: if ( vtysh_client[i].fd >= 0 )
1939: vty_out(vty, " %s", vtysh_client[i].name);
1940: vty_out(vty, "%s", VTY_NEWLINE);
1941:
1942: return CMD_SUCCESS;
1943: }
1944:
1945: /* Execute command in child process. */
1946: static int
1947: execute_command (const char *command, int argc, const char *arg1,
1948: const char *arg2)
1949: {
1950: int ret;
1951: pid_t pid;
1952: int status;
1953:
1954: /* Call fork(). */
1955: pid = fork ();
1956:
1957: if (pid < 0)
1958: {
1959: /* Failure of fork(). */
1960: fprintf (stderr, "Can't fork: %s\n", safe_strerror (errno));
1961: exit (1);
1962: }
1963: else if (pid == 0)
1964: {
1965: /* This is child process. */
1966: switch (argc)
1967: {
1968: case 0:
1969: ret = execlp (command, command, (const char *)NULL);
1970: break;
1971: case 1:
1972: ret = execlp (command, command, arg1, (const char *)NULL);
1973: break;
1974: case 2:
1975: ret = execlp (command, command, arg1, arg2, (const char *)NULL);
1976: break;
1977: }
1978:
1979: /* When execlp suceed, this part is not executed. */
1980: fprintf (stderr, "Can't execute %s: %s\n", command, safe_strerror (errno));
1981: exit (1);
1982: }
1983: else
1984: {
1985: /* This is parent. */
1986: execute_flag = 1;
1987: ret = wait4 (pid, &status, 0, NULL);
1988: execute_flag = 0;
1989: }
1990: return 0;
1991: }
1992:
1993: DEFUN (vtysh_ping,
1994: vtysh_ping_cmd,
1995: "ping WORD",
1996: "Send echo messages\n"
1997: "Ping destination address or hostname\n")
1998: {
1999: execute_command ("ping", 1, argv[0], NULL);
2000: return CMD_SUCCESS;
2001: }
2002:
2003: ALIAS (vtysh_ping,
2004: vtysh_ping_ip_cmd,
2005: "ping ip WORD",
2006: "Send echo messages\n"
2007: "IP echo\n"
2008: "Ping destination address or hostname\n")
2009:
2010: DEFUN (vtysh_traceroute,
2011: vtysh_traceroute_cmd,
2012: "traceroute WORD",
2013: "Trace route to destination\n"
2014: "Trace route to destination address or hostname\n")
2015: {
2016: execute_command ("traceroute", 1, argv[0], NULL);
2017: return CMD_SUCCESS;
2018: }
2019:
2020: ALIAS (vtysh_traceroute,
2021: vtysh_traceroute_ip_cmd,
2022: "traceroute ip WORD",
2023: "Trace route to destination\n"
2024: "IP trace\n"
2025: "Trace route to destination address or hostname\n")
2026:
2027: #ifdef HAVE_IPV6
2028: DEFUN (vtysh_ping6,
2029: vtysh_ping6_cmd,
2030: "ping ipv6 WORD",
2031: "Send echo messages\n"
2032: "IPv6 echo\n"
2033: "Ping destination address or hostname\n")
2034: {
2035: execute_command ("ping6", 1, argv[0], NULL);
2036: return CMD_SUCCESS;
2037: }
2038:
2039: DEFUN (vtysh_traceroute6,
2040: vtysh_traceroute6_cmd,
2041: "traceroute ipv6 WORD",
2042: "Trace route to destination\n"
2043: "IPv6 trace\n"
2044: "Trace route to destination address or hostname\n")
2045: {
2046: execute_command ("traceroute6", 1, argv[0], NULL);
2047: return CMD_SUCCESS;
2048: }
2049: #endif
2050:
2051: DEFUN (vtysh_telnet,
2052: vtysh_telnet_cmd,
2053: "telnet WORD",
2054: "Open a telnet connection\n"
2055: "IP address or hostname of a remote system\n")
2056: {
2057: execute_command ("telnet", 1, argv[0], NULL);
2058: return CMD_SUCCESS;
2059: }
2060:
2061: DEFUN (vtysh_telnet_port,
2062: vtysh_telnet_port_cmd,
2063: "telnet WORD PORT",
2064: "Open a telnet connection\n"
2065: "IP address or hostname of a remote system\n"
2066: "TCP Port number\n")
2067: {
2068: execute_command ("telnet", 2, argv[0], argv[1]);
2069: return CMD_SUCCESS;
2070: }
2071:
2072: DEFUN (vtysh_ssh,
2073: vtysh_ssh_cmd,
2074: "ssh WORD",
2075: "Open an ssh connection\n"
2076: "[user@]host\n")
2077: {
2078: execute_command ("ssh", 1, argv[0], NULL);
2079: return CMD_SUCCESS;
2080: }
2081:
2082: DEFUN (vtysh_start_shell,
2083: vtysh_start_shell_cmd,
2084: "start-shell",
2085: "Start UNIX shell\n")
2086: {
2087: execute_command ("sh", 0, NULL, NULL);
2088: return CMD_SUCCESS;
2089: }
2090:
2091: DEFUN (vtysh_start_bash,
2092: vtysh_start_bash_cmd,
2093: "start-shell bash",
2094: "Start UNIX shell\n"
2095: "Start bash\n")
2096: {
2097: execute_command ("bash", 0, NULL, NULL);
2098: return CMD_SUCCESS;
2099: }
2100:
2101: DEFUN (vtysh_start_zsh,
2102: vtysh_start_zsh_cmd,
2103: "start-shell zsh",
2104: "Start UNIX shell\n"
2105: "Start Z shell\n")
2106: {
2107: execute_command ("zsh", 0, NULL, NULL);
2108: return CMD_SUCCESS;
2109: }
2110:
2111: static void
2112: vtysh_install_default (enum node_type node)
2113: {
2114: install_element (node, &config_list_cmd);
2115: }
2116:
2117: /* Making connection to protocol daemon. */
2118: static int
2119: vtysh_connect (struct vtysh_client *vclient)
2120: {
2121: int ret;
2122: int sock, len;
2123: struct sockaddr_un addr;
2124: struct stat s_stat;
2125:
2126: /* Stat socket to see if we have permission to access it. */
2127: ret = stat (vclient->path, &s_stat);
2128: if (ret < 0 && errno != ENOENT)
2129: {
2130: fprintf (stderr, "vtysh_connect(%s): stat = %s\n",
2131: vclient->path, safe_strerror(errno));
2132: exit(1);
2133: }
2134:
2135: if (ret >= 0)
2136: {
2137: if (! S_ISSOCK(s_stat.st_mode))
2138: {
2139: fprintf (stderr, "vtysh_connect(%s): Not a socket\n",
2140: vclient->path);
2141: exit (1);
2142: }
2143:
2144: }
2145:
2146: sock = socket (AF_UNIX, SOCK_STREAM, 0);
2147: if (sock < 0)
2148: {
2149: #ifdef DEBUG
2150: fprintf(stderr, "vtysh_connect(%s): socket = %s\n", vclient->path,
2151: safe_strerror(errno));
2152: #endif /* DEBUG */
2153: return -1;
2154: }
2155:
2156: memset (&addr, 0, sizeof (struct sockaddr_un));
2157: addr.sun_family = AF_UNIX;
2158: strncpy (addr.sun_path, vclient->path, strlen (vclient->path));
2159: #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
2160: len = addr.sun_len = SUN_LEN(&addr);
2161: #else
2162: len = sizeof (addr.sun_family) + strlen (addr.sun_path);
2163: #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
2164:
2165: ret = connect (sock, (struct sockaddr *) &addr, len);
2166: if (ret < 0)
2167: {
2168: #ifdef DEBUG
2169: fprintf(stderr, "vtysh_connect(%s): connect = %s\n", vclient->path,
2170: safe_strerror(errno));
2171: #endif /* DEBUG */
2172: close (sock);
2173: return -1;
2174: }
2175: vclient->fd = sock;
2176:
2177: return 0;
2178: }
2179:
2180: int
2181: vtysh_connect_all(const char *daemon_name)
2182: {
2183: u_int i;
2184: int rc = 0;
2185: int matches = 0;
2186:
2187: for (i = 0; i < VTYSH_INDEX_MAX; i++)
2188: {
2189: if (!daemon_name || !strcmp(daemon_name, vtysh_client[i].name))
2190: {
2191: matches++;
2192: if (vtysh_connect(&vtysh_client[i]) == 0)
2193: rc++;
2194: /* We need direct access to ripd in vtysh_exit_ripd_only. */
2195: if (vtysh_client[i].flag == VTYSH_RIPD)
2196: ripd_client = &vtysh_client[i];
2197: }
2198: }
2199: if (!matches)
2200: fprintf(stderr, "Error: no daemons match name %s!\n", daemon_name);
2201: return rc;
2202: }
2203:
2204: /* To disable readline's filename completion. */
2205: static char *
2206: vtysh_completion_entry_function (const char *ignore, int invoking_key)
2207: {
2208: return NULL;
2209: }
2210:
2211: void
2212: vtysh_readline_init (void)
2213: {
2214: /* readline related settings. */
2215: rl_bind_key ('?', (Function *) vtysh_rl_describe);
2216: rl_completion_entry_function = vtysh_completion_entry_function;
2217: rl_attempted_completion_function = (CPPFunction *)new_completion;
2218: /* do not append space after completion. It will be appended
2219: * in new_completion() function explicitly. */
2220: rl_completion_append_character = '\0';
2221: }
2222:
2223: char *
2224: vtysh_prompt (void)
2225: {
2226: static struct utsname names;
2227: static char buf[100];
2228: const char*hostname;
2229: extern struct host host;
2230:
2231: hostname = host.name;
2232:
2233: if (!hostname)
2234: {
2235: if (!names.nodename[0])
2236: uname (&names);
2237: hostname = names.nodename;
2238: }
2239:
2240: snprintf (buf, sizeof buf, cmd_prompt (vty->node), hostname);
2241:
2242: return buf;
2243: }
2244:
2245: void
2246: vtysh_init_vty (void)
2247: {
2248: /* Make vty structure. */
2249: vty = vty_new ();
2250: vty->type = VTY_SHELL;
2251: vty->node = VIEW_NODE;
2252:
2253: /* Initialize commands. */
2254: cmd_init (0);
2255:
2256: /* Install nodes. */
2257: install_node (&bgp_node, NULL);
2258: install_node (&rip_node, NULL);
2259: install_node (&interface_node, NULL);
2260: install_node (&rmap_node, NULL);
2261: install_node (&zebra_node, NULL);
2262: install_node (&bgp_vpnv4_node, NULL);
2263: install_node (&bgp_ipv4_node, NULL);
2264: install_node (&bgp_ipv4m_node, NULL);
2265: /* #ifdef HAVE_IPV6 */
2266: install_node (&bgp_ipv6_node, NULL);
2267: install_node (&bgp_ipv6m_node, NULL);
2268: /* #endif */
2269: install_node (&ospf_node, NULL);
2270: /* #ifdef HAVE_IPV6 */
2271: install_node (&ripng_node, NULL);
2272: install_node (&ospf6_node, NULL);
2273: /* #endif */
1.1.1.2 ! misho 2274: install_node (&babel_node, NULL);
1.1 misho 2275: install_node (&keychain_node, NULL);
2276: install_node (&keychain_key_node, NULL);
2277: install_node (&isis_node, NULL);
2278: install_node (&vty_node, NULL);
2279:
2280: vtysh_install_default (VIEW_NODE);
2281: vtysh_install_default (ENABLE_NODE);
2282: vtysh_install_default (CONFIG_NODE);
2283: vtysh_install_default (BGP_NODE);
2284: vtysh_install_default (RIP_NODE);
2285: vtysh_install_default (INTERFACE_NODE);
2286: vtysh_install_default (RMAP_NODE);
2287: vtysh_install_default (ZEBRA_NODE);
2288: vtysh_install_default (BGP_VPNV4_NODE);
2289: vtysh_install_default (BGP_IPV4_NODE);
2290: vtysh_install_default (BGP_IPV4M_NODE);
2291: vtysh_install_default (BGP_IPV6_NODE);
2292: vtysh_install_default (BGP_IPV6M_NODE);
2293: vtysh_install_default (OSPF_NODE);
2294: vtysh_install_default (RIPNG_NODE);
2295: vtysh_install_default (OSPF6_NODE);
1.1.1.2 ! misho 2296: vtysh_install_default (BABEL_NODE);
1.1 misho 2297: vtysh_install_default (ISIS_NODE);
2298: vtysh_install_default (KEYCHAIN_NODE);
2299: vtysh_install_default (KEYCHAIN_KEY_NODE);
2300: vtysh_install_default (VTY_NODE);
2301:
2302: install_element (VIEW_NODE, &vtysh_enable_cmd);
2303: install_element (ENABLE_NODE, &vtysh_config_terminal_cmd);
2304: install_element (ENABLE_NODE, &vtysh_disable_cmd);
2305:
2306: /* "exit" command. */
2307: install_element (VIEW_NODE, &vtysh_exit_all_cmd);
2308: install_element (VIEW_NODE, &vtysh_quit_all_cmd);
2309: install_element (CONFIG_NODE, &vtysh_exit_all_cmd);
2310: /* install_element (CONFIG_NODE, &vtysh_quit_all_cmd); */
2311: install_element (ENABLE_NODE, &vtysh_exit_all_cmd);
2312: install_element (ENABLE_NODE, &vtysh_quit_all_cmd);
2313: install_element (RIP_NODE, &vtysh_exit_ripd_cmd);
2314: install_element (RIP_NODE, &vtysh_quit_ripd_cmd);
2315: install_element (RIPNG_NODE, &vtysh_exit_ripngd_cmd);
2316: install_element (RIPNG_NODE, &vtysh_quit_ripngd_cmd);
2317: install_element (OSPF_NODE, &vtysh_exit_ospfd_cmd);
2318: install_element (OSPF_NODE, &vtysh_quit_ospfd_cmd);
2319: install_element (OSPF6_NODE, &vtysh_exit_ospf6d_cmd);
2320: install_element (OSPF6_NODE, &vtysh_quit_ospf6d_cmd);
2321: install_element (BGP_NODE, &vtysh_exit_bgpd_cmd);
2322: install_element (BGP_NODE, &vtysh_quit_bgpd_cmd);
2323: install_element (BGP_VPNV4_NODE, &vtysh_exit_bgpd_cmd);
2324: install_element (BGP_VPNV4_NODE, &vtysh_quit_bgpd_cmd);
2325: install_element (BGP_IPV4_NODE, &vtysh_exit_bgpd_cmd);
2326: install_element (BGP_IPV4_NODE, &vtysh_quit_bgpd_cmd);
2327: install_element (BGP_IPV4M_NODE, &vtysh_exit_bgpd_cmd);
2328: install_element (BGP_IPV4M_NODE, &vtysh_quit_bgpd_cmd);
2329: install_element (BGP_IPV6_NODE, &vtysh_exit_bgpd_cmd);
2330: install_element (BGP_IPV6_NODE, &vtysh_quit_bgpd_cmd);
2331: install_element (BGP_IPV6M_NODE, &vtysh_exit_bgpd_cmd);
2332: install_element (BGP_IPV6M_NODE, &vtysh_quit_bgpd_cmd);
2333: install_element (ISIS_NODE, &vtysh_exit_isisd_cmd);
2334: install_element (ISIS_NODE, &vtysh_quit_isisd_cmd);
2335: install_element (KEYCHAIN_NODE, &vtysh_exit_ripd_cmd);
2336: install_element (KEYCHAIN_NODE, &vtysh_quit_ripd_cmd);
2337: install_element (KEYCHAIN_KEY_NODE, &vtysh_exit_ripd_cmd);
2338: install_element (KEYCHAIN_KEY_NODE, &vtysh_quit_ripd_cmd);
2339: install_element (RMAP_NODE, &vtysh_exit_rmap_cmd);
2340: install_element (RMAP_NODE, &vtysh_quit_rmap_cmd);
2341: install_element (VTY_NODE, &vtysh_exit_line_vty_cmd);
2342: install_element (VTY_NODE, &vtysh_quit_line_vty_cmd);
2343:
2344: /* "end" command. */
2345: install_element (CONFIG_NODE, &vtysh_end_all_cmd);
2346: install_element (ENABLE_NODE, &vtysh_end_all_cmd);
2347: install_element (RIP_NODE, &vtysh_end_all_cmd);
2348: install_element (RIPNG_NODE, &vtysh_end_all_cmd);
2349: install_element (OSPF_NODE, &vtysh_end_all_cmd);
2350: install_element (OSPF6_NODE, &vtysh_end_all_cmd);
1.1.1.2 ! misho 2351: install_element (BABEL_NODE, &vtysh_end_all_cmd);
1.1 misho 2352: install_element (BGP_NODE, &vtysh_end_all_cmd);
2353: install_element (BGP_IPV4_NODE, &vtysh_end_all_cmd);
2354: install_element (BGP_IPV4M_NODE, &vtysh_end_all_cmd);
2355: install_element (BGP_VPNV4_NODE, &vtysh_end_all_cmd);
2356: install_element (BGP_IPV6_NODE, &vtysh_end_all_cmd);
2357: install_element (BGP_IPV6M_NODE, &vtysh_end_all_cmd);
2358: install_element (ISIS_NODE, &vtysh_end_all_cmd);
2359: install_element (KEYCHAIN_NODE, &vtysh_end_all_cmd);
2360: install_element (KEYCHAIN_KEY_NODE, &vtysh_end_all_cmd);
2361: install_element (RMAP_NODE, &vtysh_end_all_cmd);
2362: install_element (VTY_NODE, &vtysh_end_all_cmd);
2363:
2364: install_element (INTERFACE_NODE, &interface_desc_cmd);
2365: install_element (INTERFACE_NODE, &no_interface_desc_cmd);
2366: install_element (INTERFACE_NODE, &vtysh_end_all_cmd);
2367: install_element (INTERFACE_NODE, &vtysh_exit_interface_cmd);
2368: install_element (INTERFACE_NODE, &vtysh_quit_interface_cmd);
2369: install_element (CONFIG_NODE, &router_rip_cmd);
2370: #ifdef HAVE_IPV6
2371: install_element (CONFIG_NODE, &router_ripng_cmd);
2372: #endif
2373: install_element (CONFIG_NODE, &router_ospf_cmd);
2374: #ifdef HAVE_IPV6
2375: install_element (CONFIG_NODE, &router_ospf6_cmd);
2376: #endif
1.1.1.2 ! misho 2377: install_element (CONFIG_NODE, &router_babel_cmd);
1.1 misho 2378: install_element (CONFIG_NODE, &router_isis_cmd);
2379: install_element (CONFIG_NODE, &router_bgp_cmd);
2380: install_element (CONFIG_NODE, &router_bgp_view_cmd);
2381: install_element (BGP_NODE, &address_family_vpnv4_cmd);
2382: install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
2383: install_element (BGP_NODE, &address_family_ipv4_unicast_cmd);
2384: install_element (BGP_NODE, &address_family_ipv4_multicast_cmd);
2385: #ifdef HAVE_IPV6
2386: install_element (BGP_NODE, &address_family_ipv6_cmd);
2387: install_element (BGP_NODE, &address_family_ipv6_unicast_cmd);
2388: #endif
2389: install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
2390: install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
2391: install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
2392: install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
2393: install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
2394: install_element (CONFIG_NODE, &key_chain_cmd);
2395: install_element (CONFIG_NODE, &route_map_cmd);
2396: install_element (CONFIG_NODE, &vtysh_line_vty_cmd);
2397: install_element (KEYCHAIN_NODE, &key_cmd);
2398: install_element (KEYCHAIN_NODE, &key_chain_cmd);
2399: install_element (KEYCHAIN_KEY_NODE, &key_chain_cmd);
2400: install_element (CONFIG_NODE, &vtysh_interface_cmd);
2401: install_element (CONFIG_NODE, &vtysh_no_interface_cmd);
2402: install_element (ENABLE_NODE, &vtysh_show_running_config_cmd);
2403: install_element (ENABLE_NODE, &vtysh_copy_runningconfig_startupconfig_cmd);
2404: install_element (ENABLE_NODE, &vtysh_write_file_cmd);
2405: install_element (ENABLE_NODE, &vtysh_write_cmd);
2406:
2407: /* "write terminal" command. */
2408: install_element (ENABLE_NODE, &vtysh_write_terminal_cmd);
2409:
2410: install_element (CONFIG_NODE, &vtysh_integrated_config_cmd);
2411: install_element (CONFIG_NODE, &no_vtysh_integrated_config_cmd);
2412:
2413: /* "write memory" command. */
2414: install_element (ENABLE_NODE, &vtysh_write_memory_cmd);
2415:
2416: install_element (VIEW_NODE, &vtysh_terminal_length_cmd);
2417: install_element (ENABLE_NODE, &vtysh_terminal_length_cmd);
2418: install_element (VIEW_NODE, &vtysh_terminal_no_length_cmd);
2419: install_element (ENABLE_NODE, &vtysh_terminal_no_length_cmd);
2420: install_element (VIEW_NODE, &vtysh_show_daemons_cmd);
2421: install_element (ENABLE_NODE, &vtysh_show_daemons_cmd);
2422:
2423: install_element (VIEW_NODE, &vtysh_ping_cmd);
2424: install_element (VIEW_NODE, &vtysh_ping_ip_cmd);
2425: install_element (VIEW_NODE, &vtysh_traceroute_cmd);
2426: install_element (VIEW_NODE, &vtysh_traceroute_ip_cmd);
2427: #ifdef HAVE_IPV6
2428: install_element (VIEW_NODE, &vtysh_ping6_cmd);
2429: install_element (VIEW_NODE, &vtysh_traceroute6_cmd);
2430: #endif
2431: install_element (VIEW_NODE, &vtysh_telnet_cmd);
2432: install_element (VIEW_NODE, &vtysh_telnet_port_cmd);
2433: install_element (VIEW_NODE, &vtysh_ssh_cmd);
2434: install_element (ENABLE_NODE, &vtysh_ping_cmd);
2435: install_element (ENABLE_NODE, &vtysh_ping_ip_cmd);
2436: install_element (ENABLE_NODE, &vtysh_traceroute_cmd);
2437: install_element (ENABLE_NODE, &vtysh_traceroute_ip_cmd);
2438: #ifdef HAVE_IPV6
2439: install_element (ENABLE_NODE, &vtysh_ping6_cmd);
2440: install_element (ENABLE_NODE, &vtysh_traceroute6_cmd);
2441: #endif
2442: install_element (ENABLE_NODE, &vtysh_telnet_cmd);
2443: install_element (ENABLE_NODE, &vtysh_telnet_port_cmd);
2444: install_element (ENABLE_NODE, &vtysh_ssh_cmd);
2445: install_element (ENABLE_NODE, &vtysh_start_shell_cmd);
2446: install_element (ENABLE_NODE, &vtysh_start_bash_cmd);
2447: install_element (ENABLE_NODE, &vtysh_start_zsh_cmd);
2448:
2449: install_element (VIEW_NODE, &vtysh_show_memory_cmd);
2450: install_element (ENABLE_NODE, &vtysh_show_memory_cmd);
2451:
2452: /* Logging */
2453: install_element (ENABLE_NODE, &vtysh_show_logging_cmd);
2454: install_element (VIEW_NODE, &vtysh_show_logging_cmd);
2455: install_element (CONFIG_NODE, &vtysh_log_stdout_cmd);
2456: install_element (CONFIG_NODE, &vtysh_log_stdout_level_cmd);
2457: install_element (CONFIG_NODE, &no_vtysh_log_stdout_cmd);
2458: install_element (CONFIG_NODE, &vtysh_log_file_cmd);
2459: install_element (CONFIG_NODE, &vtysh_log_file_level_cmd);
2460: install_element (CONFIG_NODE, &no_vtysh_log_file_cmd);
2461: install_element (CONFIG_NODE, &no_vtysh_log_file_level_cmd);
2462: install_element (CONFIG_NODE, &vtysh_log_monitor_cmd);
2463: install_element (CONFIG_NODE, &vtysh_log_monitor_level_cmd);
2464: install_element (CONFIG_NODE, &no_vtysh_log_monitor_cmd);
2465: install_element (CONFIG_NODE, &vtysh_log_syslog_cmd);
2466: install_element (CONFIG_NODE, &vtysh_log_syslog_level_cmd);
2467: install_element (CONFIG_NODE, &no_vtysh_log_syslog_cmd);
2468: install_element (CONFIG_NODE, &vtysh_log_trap_cmd);
2469: install_element (CONFIG_NODE, &no_vtysh_log_trap_cmd);
2470: install_element (CONFIG_NODE, &vtysh_log_facility_cmd);
2471: install_element (CONFIG_NODE, &no_vtysh_log_facility_cmd);
2472: install_element (CONFIG_NODE, &vtysh_log_record_priority_cmd);
2473: install_element (CONFIG_NODE, &no_vtysh_log_record_priority_cmd);
2474: install_element (CONFIG_NODE, &vtysh_log_timestamp_precision_cmd);
2475: install_element (CONFIG_NODE, &no_vtysh_log_timestamp_precision_cmd);
2476:
2477: install_element (CONFIG_NODE, &vtysh_service_password_encrypt_cmd);
2478: install_element (CONFIG_NODE, &no_vtysh_service_password_encrypt_cmd);
2479:
2480: install_element (CONFIG_NODE, &vtysh_password_cmd);
2481: install_element (CONFIG_NODE, &vtysh_password_text_cmd);
2482: install_element (CONFIG_NODE, &vtysh_enable_password_cmd);
2483: install_element (CONFIG_NODE, &vtysh_enable_password_text_cmd);
2484: install_element (CONFIG_NODE, &no_vtysh_enable_password_cmd);
2485:
2486: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>