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