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 | |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 780 | /* Defined in lib/vty.c */ |
| 781 | extern struct cmd_node vty_node; |
| 782 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 783 | /* When '^Z' is received from vty, move down to the enable mode. */ |
David Lamparter | a9eb906 | 2015-03-04 07:07:01 +0100 | [diff] [blame] | 784 | static int |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 785 | vtysh_end (void) |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 786 | { |
| 787 | switch (vty->node) |
| 788 | { |
| 789 | case VIEW_NODE: |
| 790 | case ENABLE_NODE: |
| 791 | /* Nothing to do. */ |
| 792 | break; |
| 793 | default: |
| 794 | vty->node = ENABLE_NODE; |
| 795 | break; |
| 796 | } |
| 797 | return CMD_SUCCESS; |
| 798 | } |
| 799 | |
| 800 | DEFUNSH (VTYSH_ALL, |
| 801 | vtysh_end_all, |
| 802 | vtysh_end_all_cmd, |
| 803 | "end", |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 804 | "End current mode and change to enable mode\n") |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 805 | { |
hasso | 4289546 | 2004-09-26 16:25:07 +0000 | [diff] [blame] | 806 | return vtysh_end (); |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 807 | } |
| 808 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | DEFUNSH (VTYSH_BGPD, |
| 810 | router_bgp, |
| 811 | router_bgp_cmd, |
Paul Jakma | 320da87 | 2008-07-02 13:40:33 +0000 | [diff] [blame] | 812 | "router bgp " CMD_AS_RANGE, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 813 | ROUTER_STR |
| 814 | BGP_STR |
| 815 | AS_STR) |
| 816 | { |
| 817 | vty->node = BGP_NODE; |
| 818 | return CMD_SUCCESS; |
| 819 | } |
| 820 | |
Paul Jakma | 10895fd | 2008-07-03 19:34:48 +0000 | [diff] [blame] | 821 | ALIAS_SH (VTYSH_BGPD, |
| 822 | router_bgp, |
| 823 | router_bgp_view_cmd, |
| 824 | "router bgp " CMD_AS_RANGE " view WORD", |
| 825 | ROUTER_STR |
| 826 | BGP_STR |
| 827 | AS_STR |
| 828 | "BGP view\n" |
| 829 | "view name\n") |
| 830 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 831 | DEFUNSH (VTYSH_BGPD, |
| 832 | address_family_vpnv4, |
| 833 | address_family_vpnv4_cmd, |
| 834 | "address-family vpnv4", |
| 835 | "Enter Address Family command mode\n" |
| 836 | "Address family\n") |
| 837 | { |
| 838 | vty->node = BGP_VPNV4_NODE; |
| 839 | return CMD_SUCCESS; |
| 840 | } |
| 841 | |
| 842 | DEFUNSH (VTYSH_BGPD, |
| 843 | address_family_vpnv4_unicast, |
| 844 | address_family_vpnv4_unicast_cmd, |
| 845 | "address-family vpnv4 unicast", |
| 846 | "Enter Address Family command mode\n" |
| 847 | "Address family\n" |
| 848 | "Address Family Modifier\n") |
| 849 | { |
| 850 | vty->node = BGP_VPNV4_NODE; |
| 851 | return CMD_SUCCESS; |
| 852 | } |
| 853 | |
| 854 | DEFUNSH (VTYSH_BGPD, |
Lou Berger | 13c378d | 2016-01-12 13:41:56 -0500 | [diff] [blame] | 855 | address_family_vpnv6, |
| 856 | address_family_vpnv6_cmd, |
| 857 | "address-family vpnv6", |
| 858 | "Enter Address Family command mode\n" |
| 859 | "Address family\n") |
| 860 | { |
| 861 | vty->node = BGP_VPNV6_NODE; |
| 862 | return CMD_SUCCESS; |
| 863 | } |
| 864 | |
| 865 | DEFUNSH (VTYSH_BGPD, |
| 866 | address_family_vpnv6_unicast, |
| 867 | address_family_vpnv6_unicast_cmd, |
| 868 | "address-family vpnv6 unicast", |
| 869 | "Enter Address Family command mode\n" |
| 870 | "Address family\n" |
| 871 | "Address Family Modifier\n") |
| 872 | { |
| 873 | vty->node = BGP_VPNV6_NODE; |
| 874 | return CMD_SUCCESS; |
| 875 | } |
| 876 | |
| 877 | DEFUNSH (VTYSH_BGPD, |
Lou Berger | a3fda88 | 2016-01-12 13:42:04 -0500 | [diff] [blame] | 878 | address_family_encap, |
| 879 | address_family_encap_cmd, |
| 880 | "address-family encap", |
| 881 | "Enter Address Family command mode\n" |
| 882 | "Address family\n") |
| 883 | { |
| 884 | vty->node = BGP_ENCAP_NODE; |
| 885 | return CMD_SUCCESS; |
| 886 | } |
| 887 | |
| 888 | DEFUNSH (VTYSH_BGPD, |
| 889 | address_family_encapv4, |
| 890 | address_family_encapv4_cmd, |
| 891 | "address-family encapv4", |
| 892 | "Enter Address Family command mode\n" |
| 893 | "Address family\n") |
| 894 | { |
| 895 | vty->node = BGP_ENCAP_NODE; |
| 896 | return CMD_SUCCESS; |
| 897 | } |
| 898 | |
| 899 | DEFUNSH (VTYSH_BGPD, |
| 900 | address_family_encapv6, |
| 901 | address_family_encapv6_cmd, |
| 902 | "address-family encapv6", |
| 903 | "Enter Address Family command mode\n" |
| 904 | "Address family\n") |
| 905 | { |
| 906 | vty->node = BGP_ENCAPV6_NODE; |
| 907 | return CMD_SUCCESS; |
| 908 | } |
| 909 | |
| 910 | DEFUNSH (VTYSH_BGPD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 911 | address_family_ipv4_unicast, |
| 912 | address_family_ipv4_unicast_cmd, |
| 913 | "address-family ipv4 unicast", |
| 914 | "Enter Address Family command mode\n" |
| 915 | "Address family\n" |
| 916 | "Address Family Modifier\n") |
| 917 | { |
| 918 | vty->node = BGP_IPV4_NODE; |
| 919 | return CMD_SUCCESS; |
| 920 | } |
| 921 | |
| 922 | DEFUNSH (VTYSH_BGPD, |
| 923 | address_family_ipv4_multicast, |
| 924 | address_family_ipv4_multicast_cmd, |
| 925 | "address-family ipv4 multicast", |
| 926 | "Enter Address Family command mode\n" |
| 927 | "Address family\n" |
| 928 | "Address Family Modifier\n") |
| 929 | { |
| 930 | vty->node = BGP_IPV4M_NODE; |
| 931 | return CMD_SUCCESS; |
| 932 | } |
| 933 | |
| 934 | DEFUNSH (VTYSH_BGPD, |
| 935 | address_family_ipv6, |
| 936 | address_family_ipv6_cmd, |
| 937 | "address-family ipv6", |
| 938 | "Enter Address Family command mode\n" |
| 939 | "Address family\n") |
| 940 | { |
| 941 | vty->node = BGP_IPV6_NODE; |
| 942 | return CMD_SUCCESS; |
| 943 | } |
| 944 | |
| 945 | DEFUNSH (VTYSH_BGPD, |
| 946 | address_family_ipv6_unicast, |
| 947 | address_family_ipv6_unicast_cmd, |
| 948 | "address-family ipv6 unicast", |
| 949 | "Enter Address Family command mode\n" |
| 950 | "Address family\n" |
| 951 | "Address Family Modifier\n") |
| 952 | { |
| 953 | vty->node = BGP_IPV6_NODE; |
| 954 | return CMD_SUCCESS; |
| 955 | } |
| 956 | |
paul | 57b5b7e | 2005-08-22 22:44:29 +0000 | [diff] [blame] | 957 | DEFUNSH (VTYSH_BGPD, |
| 958 | address_family_ipv6_multicast, |
| 959 | address_family_ipv6_multicast_cmd, |
| 960 | "address-family ipv6 multicast", |
| 961 | "Enter Address Family command mode\n" |
| 962 | "Address family\n" |
| 963 | "Address Family Modifier\n") |
| 964 | { |
| 965 | vty->node = BGP_IPV6M_NODE; |
| 966 | return CMD_SUCCESS; |
| 967 | } |
| 968 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 969 | DEFUNSH (VTYSH_RIPD, |
| 970 | key_chain, |
| 971 | key_chain_cmd, |
| 972 | "key chain WORD", |
| 973 | "Authentication key management\n" |
| 974 | "Key-chain management\n" |
| 975 | "Key-chain name\n") |
| 976 | { |
| 977 | vty->node = KEYCHAIN_NODE; |
| 978 | return CMD_SUCCESS; |
| 979 | } |
| 980 | |
| 981 | DEFUNSH (VTYSH_RIPD, |
| 982 | key, |
| 983 | key_cmd, |
| 984 | "key <0-2147483647>", |
| 985 | "Configure a key\n" |
| 986 | "Key identifier number\n") |
| 987 | { |
| 988 | vty->node = KEYCHAIN_KEY_NODE; |
| 989 | return CMD_SUCCESS; |
| 990 | } |
| 991 | |
| 992 | DEFUNSH (VTYSH_RIPD, |
| 993 | router_rip, |
| 994 | router_rip_cmd, |
| 995 | "router rip", |
| 996 | ROUTER_STR |
| 997 | "RIP") |
| 998 | { |
| 999 | vty->node = RIP_NODE; |
| 1000 | return CMD_SUCCESS; |
| 1001 | } |
| 1002 | |
| 1003 | DEFUNSH (VTYSH_RIPNGD, |
| 1004 | router_ripng, |
| 1005 | router_ripng_cmd, |
| 1006 | "router ripng", |
| 1007 | ROUTER_STR |
| 1008 | "RIPng") |
| 1009 | { |
| 1010 | vty->node = RIPNG_NODE; |
| 1011 | return CMD_SUCCESS; |
| 1012 | } |
| 1013 | |
| 1014 | DEFUNSH (VTYSH_OSPFD, |
| 1015 | router_ospf, |
| 1016 | router_ospf_cmd, |
| 1017 | "router ospf", |
| 1018 | "Enable a routing process\n" |
| 1019 | "Start OSPF configuration\n") |
| 1020 | { |
| 1021 | vty->node = OSPF_NODE; |
| 1022 | return CMD_SUCCESS; |
| 1023 | } |
| 1024 | |
| 1025 | DEFUNSH (VTYSH_OSPF6D, |
| 1026 | router_ospf6, |
| 1027 | router_ospf6_cmd, |
| 1028 | "router ospf6", |
| 1029 | OSPF6_ROUTER_STR |
| 1030 | OSPF6_STR) |
| 1031 | { |
| 1032 | vty->node = OSPF6_NODE; |
| 1033 | return CMD_SUCCESS; |
| 1034 | } |
| 1035 | |
hasso | c25e458 | 2003-12-23 10:39:08 +0000 | [diff] [blame] | 1036 | DEFUNSH (VTYSH_ISISD, |
hasso | b094d26 | 2004-08-25 12:22:00 +0000 | [diff] [blame] | 1037 | router_isis, |
| 1038 | router_isis_cmd, |
| 1039 | "router isis WORD", |
| 1040 | ROUTER_STR |
| 1041 | "ISO IS-IS\n" |
| 1042 | "ISO Routing area tag") |
hasso | c25e458 | 2003-12-23 10:39:08 +0000 | [diff] [blame] | 1043 | { |
| 1044 | vty->node = ISIS_NODE; |
| 1045 | return CMD_SUCCESS; |
| 1046 | } |
| 1047 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1048 | DEFUNSH (VTYSH_RMAP, |
| 1049 | route_map, |
| 1050 | route_map_cmd, |
| 1051 | "route-map WORD (deny|permit) <1-65535>", |
| 1052 | "Create route-map or enter route-map command mode\n" |
| 1053 | "Route map tag\n" |
| 1054 | "Route map denies set operations\n" |
| 1055 | "Route map permits set operations\n" |
| 1056 | "Sequence to insert to/delete from existing route-map entry\n") |
| 1057 | { |
| 1058 | vty->node = RMAP_NODE; |
| 1059 | return CMD_SUCCESS; |
| 1060 | } |
| 1061 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1062 | DEFUNSH (VTYSH_ALL, |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 1063 | vtysh_line_vty, |
| 1064 | vtysh_line_vty_cmd, |
| 1065 | "line vty", |
| 1066 | "Configure a terminal line\n" |
| 1067 | "Virtual terminal\n") |
| 1068 | { |
| 1069 | vty->node = VTY_NODE; |
| 1070 | return CMD_SUCCESS; |
| 1071 | } |
| 1072 | |
| 1073 | DEFUNSH (VTYSH_ALL, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1074 | vtysh_enable, |
| 1075 | vtysh_enable_cmd, |
| 1076 | "enable", |
| 1077 | "Turn on privileged mode command\n") |
| 1078 | { |
| 1079 | vty->node = ENABLE_NODE; |
| 1080 | return CMD_SUCCESS; |
| 1081 | } |
| 1082 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1083 | DEFUNSH (VTYSH_ALL, |
| 1084 | vtysh_disable, |
| 1085 | vtysh_disable_cmd, |
| 1086 | "disable", |
| 1087 | "Turn off privileged mode command\n") |
| 1088 | { |
| 1089 | if (vty->node == ENABLE_NODE) |
| 1090 | vty->node = VIEW_NODE; |
| 1091 | return CMD_SUCCESS; |
| 1092 | } |
| 1093 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1094 | DEFUNSH (VTYSH_ALL, |
| 1095 | vtysh_config_terminal, |
| 1096 | vtysh_config_terminal_cmd, |
| 1097 | "configure terminal", |
| 1098 | "Configuration from vty interface\n" |
| 1099 | "Configuration terminal\n") |
| 1100 | { |
| 1101 | vty->node = CONFIG_NODE; |
| 1102 | return CMD_SUCCESS; |
| 1103 | } |
| 1104 | |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1105 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1106 | vtysh_exit (struct vty *vty) |
| 1107 | { |
| 1108 | switch (vty->node) |
| 1109 | { |
| 1110 | case VIEW_NODE: |
| 1111 | case ENABLE_NODE: |
| 1112 | exit (0); |
| 1113 | break; |
| 1114 | case CONFIG_NODE: |
| 1115 | vty->node = ENABLE_NODE; |
| 1116 | break; |
| 1117 | case INTERFACE_NODE: |
| 1118 | case ZEBRA_NODE: |
| 1119 | case BGP_NODE: |
| 1120 | case RIP_NODE: |
| 1121 | case RIPNG_NODE: |
| 1122 | case OSPF_NODE: |
| 1123 | case OSPF6_NODE: |
Juliusz Chroboczek | feb6c53 | 2012-02-07 04:58:49 +0100 | [diff] [blame] | 1124 | case BABEL_NODE: |
hasso | c25e458 | 2003-12-23 10:39:08 +0000 | [diff] [blame] | 1125 | case ISIS_NODE: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1126 | case MASC_NODE: |
| 1127 | case RMAP_NODE: |
| 1128 | case VTY_NODE: |
| 1129 | case KEYCHAIN_NODE: |
hasso | 2a56df9 | 2004-05-09 23:16:40 +0000 | [diff] [blame] | 1130 | vtysh_execute("end"); |
| 1131 | vtysh_execute("configure terminal"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1132 | vty->node = CONFIG_NODE; |
| 1133 | break; |
| 1134 | case BGP_VPNV4_NODE: |
Lou Berger | 13c378d | 2016-01-12 13:41:56 -0500 | [diff] [blame] | 1135 | case BGP_VPNV6_NODE: |
Lou Berger | a3fda88 | 2016-01-12 13:42:04 -0500 | [diff] [blame] | 1136 | case BGP_ENCAP_NODE: |
| 1137 | case BGP_ENCAPV6_NODE: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1138 | case BGP_IPV4_NODE: |
| 1139 | case BGP_IPV4M_NODE: |
| 1140 | case BGP_IPV6_NODE: |
paul | 57b5b7e | 2005-08-22 22:44:29 +0000 | [diff] [blame] | 1141 | case BGP_IPV6M_NODE: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1142 | vty->node = BGP_NODE; |
| 1143 | break; |
| 1144 | case KEYCHAIN_KEY_NODE: |
| 1145 | vty->node = KEYCHAIN_NODE; |
| 1146 | break; |
| 1147 | default: |
| 1148 | break; |
| 1149 | } |
| 1150 | return CMD_SUCCESS; |
| 1151 | } |
| 1152 | |
| 1153 | DEFUNSH (VTYSH_ALL, |
| 1154 | vtysh_exit_all, |
| 1155 | vtysh_exit_all_cmd, |
| 1156 | "exit", |
| 1157 | "Exit current mode and down to previous mode\n") |
| 1158 | { |
| 1159 | return vtysh_exit (vty); |
| 1160 | } |
| 1161 | |
| 1162 | ALIAS (vtysh_exit_all, |
| 1163 | vtysh_quit_all_cmd, |
| 1164 | "quit", |
| 1165 | "Exit current mode and down to previous mode\n") |
| 1166 | |
| 1167 | DEFUNSH (VTYSH_BGPD, |
| 1168 | exit_address_family, |
| 1169 | exit_address_family_cmd, |
| 1170 | "exit-address-family", |
| 1171 | "Exit from Address Family configuration mode\n") |
| 1172 | { |
| 1173 | if (vty->node == BGP_IPV4_NODE |
| 1174 | || vty->node == BGP_IPV4M_NODE |
| 1175 | || vty->node == BGP_VPNV4_NODE |
Lou Berger | 13c378d | 2016-01-12 13:41:56 -0500 | [diff] [blame] | 1176 | || vty->node == BGP_VPNV6_NODE |
Lou Berger | a3fda88 | 2016-01-12 13:42:04 -0500 | [diff] [blame] | 1177 | || vty->node == BGP_ENCAP_NODE |
| 1178 | || vty->node == BGP_ENCAPV6_NODE |
paul | 57b5b7e | 2005-08-22 22:44:29 +0000 | [diff] [blame] | 1179 | || vty->node == BGP_IPV6_NODE |
| 1180 | || vty->node == BGP_IPV6M_NODE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1181 | vty->node = BGP_NODE; |
| 1182 | return CMD_SUCCESS; |
| 1183 | } |
| 1184 | |
| 1185 | DEFUNSH (VTYSH_ZEBRA, |
| 1186 | vtysh_exit_zebra, |
| 1187 | vtysh_exit_zebra_cmd, |
| 1188 | "exit", |
| 1189 | "Exit current mode and down to previous mode\n") |
| 1190 | { |
| 1191 | return vtysh_exit (vty); |
| 1192 | } |
| 1193 | |
| 1194 | ALIAS (vtysh_exit_zebra, |
| 1195 | vtysh_quit_zebra_cmd, |
| 1196 | "quit", |
| 1197 | "Exit current mode and down to previous mode\n") |
| 1198 | |
| 1199 | DEFUNSH (VTYSH_RIPD, |
| 1200 | vtysh_exit_ripd, |
| 1201 | vtysh_exit_ripd_cmd, |
| 1202 | "exit", |
| 1203 | "Exit current mode and down to previous mode\n") |
| 1204 | { |
| 1205 | return vtysh_exit (vty); |
| 1206 | } |
| 1207 | |
| 1208 | ALIAS (vtysh_exit_ripd, |
| 1209 | vtysh_quit_ripd_cmd, |
| 1210 | "quit", |
| 1211 | "Exit current mode and down to previous mode\n") |
| 1212 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1213 | DEFUNSH (VTYSH_RIPNGD, |
hasso | b094d26 | 2004-08-25 12:22:00 +0000 | [diff] [blame] | 1214 | vtysh_exit_ripngd, |
| 1215 | vtysh_exit_ripngd_cmd, |
| 1216 | "exit", |
| 1217 | "Exit current mode and down to previous mode\n") |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1218 | { |
| 1219 | return vtysh_exit (vty); |
| 1220 | } |
| 1221 | |
| 1222 | ALIAS (vtysh_exit_ripngd, |
| 1223 | vtysh_quit_ripngd_cmd, |
| 1224 | "quit", |
| 1225 | "Exit current mode and down to previous mode\n") |
| 1226 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1227 | DEFUNSH (VTYSH_RMAP, |
| 1228 | vtysh_exit_rmap, |
| 1229 | vtysh_exit_rmap_cmd, |
| 1230 | "exit", |
| 1231 | "Exit current mode and down to previous mode\n") |
| 1232 | { |
| 1233 | return vtysh_exit (vty); |
| 1234 | } |
| 1235 | |
| 1236 | ALIAS (vtysh_exit_rmap, |
| 1237 | vtysh_quit_rmap_cmd, |
| 1238 | "quit", |
| 1239 | "Exit current mode and down to previous mode\n") |
| 1240 | |
| 1241 | DEFUNSH (VTYSH_BGPD, |
| 1242 | vtysh_exit_bgpd, |
| 1243 | vtysh_exit_bgpd_cmd, |
| 1244 | "exit", |
| 1245 | "Exit current mode and down to previous mode\n") |
| 1246 | { |
| 1247 | return vtysh_exit (vty); |
| 1248 | } |
| 1249 | |
| 1250 | ALIAS (vtysh_exit_bgpd, |
| 1251 | vtysh_quit_bgpd_cmd, |
| 1252 | "quit", |
| 1253 | "Exit current mode and down to previous mode\n") |
| 1254 | |
| 1255 | DEFUNSH (VTYSH_OSPFD, |
| 1256 | vtysh_exit_ospfd, |
| 1257 | vtysh_exit_ospfd_cmd, |
| 1258 | "exit", |
| 1259 | "Exit current mode and down to previous mode\n") |
| 1260 | { |
| 1261 | return vtysh_exit (vty); |
| 1262 | } |
| 1263 | |
| 1264 | ALIAS (vtysh_exit_ospfd, |
| 1265 | vtysh_quit_ospfd_cmd, |
| 1266 | "quit", |
| 1267 | "Exit current mode and down to previous mode\n") |
| 1268 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1269 | DEFUNSH (VTYSH_OSPF6D, |
hasso | b094d26 | 2004-08-25 12:22:00 +0000 | [diff] [blame] | 1270 | vtysh_exit_ospf6d, |
| 1271 | vtysh_exit_ospf6d_cmd, |
| 1272 | "exit", |
| 1273 | "Exit current mode and down to previous mode\n") |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1274 | { |
| 1275 | return vtysh_exit (vty); |
| 1276 | } |
| 1277 | |
| 1278 | ALIAS (vtysh_exit_ospf6d, |
| 1279 | vtysh_quit_ospf6d_cmd, |
| 1280 | "quit", |
| 1281 | "Exit current mode and down to previous mode\n") |
| 1282 | |
hasso | c25e458 | 2003-12-23 10:39:08 +0000 | [diff] [blame] | 1283 | DEFUNSH (VTYSH_ISISD, |
hasso | b094d26 | 2004-08-25 12:22:00 +0000 | [diff] [blame] | 1284 | vtysh_exit_isisd, |
| 1285 | vtysh_exit_isisd_cmd, |
| 1286 | "exit", |
| 1287 | "Exit current mode and down to previous mode\n") |
hasso | c25e458 | 2003-12-23 10:39:08 +0000 | [diff] [blame] | 1288 | { |
| 1289 | return vtysh_exit (vty); |
| 1290 | } |
| 1291 | |
| 1292 | ALIAS (vtysh_exit_isisd, |
| 1293 | vtysh_quit_isisd_cmd, |
| 1294 | "quit", |
| 1295 | "Exit current mode and down to previous mode\n") |
| 1296 | |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 1297 | DEFUNSH (VTYSH_ALL, |
| 1298 | vtysh_exit_line_vty, |
| 1299 | vtysh_exit_line_vty_cmd, |
| 1300 | "exit", |
| 1301 | "Exit current mode and down to previous mode\n") |
| 1302 | { |
| 1303 | return vtysh_exit (vty); |
| 1304 | } |
| 1305 | |
| 1306 | ALIAS (vtysh_exit_line_vty, |
| 1307 | vtysh_quit_line_vty_cmd, |
| 1308 | "quit", |
| 1309 | "Exit current mode and down to previous mode\n") |
| 1310 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1311 | DEFUNSH (VTYSH_INTERFACE, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1312 | vtysh_interface, |
| 1313 | vtysh_interface_cmd, |
| 1314 | "interface IFNAME", |
| 1315 | "Select an interface to configure\n" |
| 1316 | "Interface's name\n") |
| 1317 | { |
| 1318 | vty->node = INTERFACE_NODE; |
| 1319 | return CMD_SUCCESS; |
| 1320 | } |
| 1321 | |
Feng Lu | 471ea39 | 2015-05-22 11:40:00 +0200 | [diff] [blame] | 1322 | ALIAS_SH (VTYSH_ZEBRA, |
| 1323 | vtysh_interface, |
| 1324 | vtysh_interface_vrf_cmd, |
| 1325 | "interface IFNAME " VRF_CMD_STR, |
| 1326 | "Select an interface to configure\n" |
| 1327 | "Interface's name\n" |
| 1328 | VRF_CMD_HELP_STR) |
| 1329 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1330 | /* TODO Implement "no interface command in isisd. */ |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 1331 | DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D, |
| 1332 | vtysh_no_interface_cmd, |
| 1333 | "no interface IFNAME", |
| 1334 | NO_STR |
| 1335 | "Delete a pseudo interface's configuration\n" |
| 1336 | "Interface's name\n") |
| 1337 | |
Feng Lu | 471ea39 | 2015-05-22 11:40:00 +0200 | [diff] [blame] | 1338 | DEFSH (VTYSH_ZEBRA, |
| 1339 | vtysh_no_interface_vrf_cmd, |
| 1340 | "no interface IFNAME " VRF_CMD_STR, |
| 1341 | NO_STR |
| 1342 | "Delete a pseudo interface's configuration\n" |
| 1343 | "Interface's name\n" |
| 1344 | VRF_CMD_HELP_STR) |
| 1345 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1346 | /* TODO Implement interface description commands in ripngd, ospf6d |
| 1347 | * and isisd. */ |
paul | 338a991 | 2003-03-01 15:44:10 +0000 | [diff] [blame] | 1348 | DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD, |
| 1349 | interface_desc_cmd, |
| 1350 | "description .LINE", |
| 1351 | "Interface specific description\n" |
| 1352 | "Characters describing this interface\n") |
paul | 464dc8d | 2003-03-28 02:25:45 +0000 | [diff] [blame] | 1353 | |
| 1354 | DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD, |
| 1355 | no_interface_desc_cmd, |
| 1356 | "no description", |
| 1357 | NO_STR |
| 1358 | "Interface specific description\n") |
paul | 338a991 | 2003-03-01 15:44:10 +0000 | [diff] [blame] | 1359 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1360 | DEFUNSH (VTYSH_INTERFACE, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1361 | vtysh_exit_interface, |
| 1362 | vtysh_exit_interface_cmd, |
| 1363 | "exit", |
| 1364 | "Exit current mode and down to previous mode\n") |
| 1365 | { |
| 1366 | return vtysh_exit (vty); |
| 1367 | } |
| 1368 | |
| 1369 | ALIAS (vtysh_exit_interface, |
| 1370 | vtysh_quit_interface_cmd, |
| 1371 | "quit", |
| 1372 | "Exit current mode and down to previous mode\n") |
| 1373 | |
Donald Sharp | 567a638 | 2015-08-19 21:22:17 -0400 | [diff] [blame] | 1374 | DEFUN (vtysh_show_thread, |
| 1375 | vtysh_show_thread_cmd, |
| 1376 | "show thread cpu [FILTER]", |
| 1377 | SHOW_STR |
| 1378 | "Thread information\n" |
| 1379 | "Thread CPU usage\n" |
| 1380 | "Display filter (rwtexb)\n") |
| 1381 | { |
| 1382 | unsigned int i; |
| 1383 | int ret = CMD_SUCCESS; |
| 1384 | char line[100]; |
| 1385 | |
| 1386 | sprintf(line, "show thread cpu %s\n", (argc == 1) ? argv[0] : ""); |
| 1387 | for (i = 0; i < array_size(vtysh_client); i++) |
| 1388 | if ( vtysh_client[i].fd >= 0 ) |
| 1389 | { |
| 1390 | fprintf (stdout, "Thread statistics for %s:\n", |
| 1391 | vtysh_client[i].name); |
| 1392 | ret = vtysh_client_execute (&vtysh_client[i], line, stdout); |
| 1393 | fprintf (stdout,"\n"); |
| 1394 | } |
| 1395 | return ret; |
| 1396 | } |
| 1397 | |
| 1398 | DEFUN (vtysh_show_work_queues, |
| 1399 | vtysh_show_work_queues_cmd, |
| 1400 | "show work-queues", |
| 1401 | SHOW_STR |
| 1402 | "Work Queue information\n") |
| 1403 | { |
| 1404 | unsigned int i; |
| 1405 | int ret = CMD_SUCCESS; |
| 1406 | char line[] = "show work-queues\n"; |
| 1407 | |
| 1408 | for (i = 0; i < array_size(vtysh_client); i++) |
| 1409 | if ( vtysh_client[i].fd >= 0 ) |
| 1410 | { |
| 1411 | fprintf (stdout, "Work queue statistics for %s:\n", |
| 1412 | vtysh_client[i].name); |
| 1413 | ret = vtysh_client_execute (&vtysh_client[i], line, stdout); |
| 1414 | fprintf (stdout,"\n"); |
| 1415 | } |
| 1416 | |
| 1417 | return ret; |
| 1418 | } |
| 1419 | |
Donald Sharp | 0744040 | 2016-02-25 07:39:45 -0500 | [diff] [blame] | 1420 | DEFUN (vtysh_show_work_queues_daemon, |
| 1421 | vtysh_show_work_queues_daemon_cmd, |
| 1422 | "show work-queues (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd)", |
| 1423 | SHOW_STR |
| 1424 | "Work Queue information\n" |
| 1425 | "For the zebra daemon\n" |
| 1426 | "For the rip daemon\n" |
| 1427 | "For the ripng daemon\n" |
| 1428 | "For the ospf daemon\n" |
| 1429 | "For the ospfv6 daemon\n" |
| 1430 | "For the bgp daemon\n" |
| 1431 | "For the isis daemon\n") |
| 1432 | { |
| 1433 | unsigned int i; |
| 1434 | int ret = CMD_SUCCESS; |
| 1435 | |
| 1436 | for (i = 0; i < array_size(vtysh_client); i++) |
| 1437 | { |
| 1438 | if (begins_with(vtysh_client[i].name, argv[0])) |
| 1439 | break; |
| 1440 | } |
| 1441 | |
| 1442 | ret = vtysh_client_execute(&vtysh_client[i], "show work-queues\n", stdout); |
| 1443 | |
| 1444 | return ret; |
| 1445 | } |
| 1446 | |
Paul Jakma | 362b403 | 2006-05-28 07:54:45 +0000 | [diff] [blame] | 1447 | /* Memory */ |
| 1448 | DEFUN (vtysh_show_memory, |
| 1449 | vtysh_show_memory_cmd, |
| 1450 | "show memory", |
| 1451 | SHOW_STR |
| 1452 | "Memory statistics\n") |
| 1453 | { |
| 1454 | unsigned int i; |
| 1455 | int ret = CMD_SUCCESS; |
| 1456 | char line[] = "show memory\n"; |
| 1457 | |
Balaji.G | 837d16c | 2012-09-26 14:09:10 +0530 | [diff] [blame] | 1458 | for (i = 0; i < array_size(vtysh_client); i++) |
Paul Jakma | 362b403 | 2006-05-28 07:54:45 +0000 | [diff] [blame] | 1459 | if ( vtysh_client[i].fd >= 0 ) |
| 1460 | { |
| 1461 | fprintf (stdout, "Memory statistics for %s:\n", |
| 1462 | vtysh_client[i].name); |
| 1463 | ret = vtysh_client_execute (&vtysh_client[i], line, stdout); |
| 1464 | fprintf (stdout,"\n"); |
| 1465 | } |
| 1466 | |
| 1467 | return ret; |
| 1468 | } |
| 1469 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1470 | /* Logging commands. */ |
Paul Jakma | dbf7d13 | 2006-05-23 22:10:01 +0000 | [diff] [blame] | 1471 | DEFUN (vtysh_show_logging, |
| 1472 | vtysh_show_logging_cmd, |
| 1473 | "show logging", |
| 1474 | SHOW_STR |
| 1475 | "Show current logging configuration\n") |
| 1476 | { |
| 1477 | unsigned int i; |
| 1478 | int ret = CMD_SUCCESS; |
| 1479 | char line[] = "show logging\n"; |
| 1480 | |
Balaji.G | 837d16c | 2012-09-26 14:09:10 +0530 | [diff] [blame] | 1481 | for (i = 0; i < array_size(vtysh_client); i++) |
Paul Jakma | 4150f33 | 2006-05-23 22:10:55 +0000 | [diff] [blame] | 1482 | if ( vtysh_client[i].fd >= 0 ) |
| 1483 | { |
| 1484 | fprintf (stdout,"Logging configuration for %s:\n", |
| 1485 | vtysh_client[i].name); |
| 1486 | ret = vtysh_client_execute (&vtysh_client[i], line, stdout); |
| 1487 | fprintf (stdout,"\n"); |
| 1488 | } |
| 1489 | |
Paul Jakma | dbf7d13 | 2006-05-23 22:10:01 +0000 | [diff] [blame] | 1490 | return ret; |
| 1491 | } |
| 1492 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1493 | DEFUNSH (VTYSH_ALL, |
| 1494 | vtysh_log_stdout, |
| 1495 | vtysh_log_stdout_cmd, |
| 1496 | "log stdout", |
| 1497 | "Logging control\n" |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1498 | "Set stdout logging level\n") |
| 1499 | { |
| 1500 | return CMD_SUCCESS; |
| 1501 | } |
| 1502 | |
| 1503 | DEFUNSH (VTYSH_ALL, |
| 1504 | vtysh_log_stdout_level, |
| 1505 | vtysh_log_stdout_level_cmd, |
| 1506 | "log stdout "LOG_LEVELS, |
| 1507 | "Logging control\n" |
| 1508 | "Set stdout logging level\n" |
| 1509 | LOG_LEVEL_DESC) |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1510 | { |
| 1511 | return CMD_SUCCESS; |
| 1512 | } |
| 1513 | |
| 1514 | DEFUNSH (VTYSH_ALL, |
| 1515 | no_vtysh_log_stdout, |
| 1516 | no_vtysh_log_stdout_cmd, |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1517 | "no log stdout [LEVEL]", |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1518 | NO_STR |
| 1519 | "Logging control\n" |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1520 | "Cancel logging to stdout\n" |
| 1521 | "Logging level\n") |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1522 | { |
| 1523 | return CMD_SUCCESS; |
| 1524 | } |
| 1525 | |
| 1526 | DEFUNSH (VTYSH_ALL, |
| 1527 | vtysh_log_file, |
| 1528 | vtysh_log_file_cmd, |
| 1529 | "log file FILENAME", |
| 1530 | "Logging control\n" |
| 1531 | "Logging to file\n" |
| 1532 | "Logging filename\n") |
| 1533 | { |
| 1534 | return CMD_SUCCESS; |
| 1535 | } |
| 1536 | |
| 1537 | DEFUNSH (VTYSH_ALL, |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1538 | vtysh_log_file_level, |
| 1539 | vtysh_log_file_level_cmd, |
| 1540 | "log file FILENAME "LOG_LEVELS, |
| 1541 | "Logging control\n" |
| 1542 | "Logging to file\n" |
| 1543 | "Logging filename\n" |
| 1544 | LOG_LEVEL_DESC) |
| 1545 | { |
| 1546 | return CMD_SUCCESS; |
| 1547 | } |
| 1548 | |
| 1549 | DEFUNSH (VTYSH_ALL, |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1550 | no_vtysh_log_file, |
| 1551 | no_vtysh_log_file_cmd, |
| 1552 | "no log file [FILENAME]", |
| 1553 | NO_STR |
| 1554 | "Logging control\n" |
| 1555 | "Cancel logging to file\n" |
| 1556 | "Logging file name\n") |
| 1557 | { |
| 1558 | return CMD_SUCCESS; |
| 1559 | } |
| 1560 | |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1561 | ALIAS_SH (VTYSH_ALL, |
| 1562 | no_vtysh_log_file, |
| 1563 | no_vtysh_log_file_level_cmd, |
| 1564 | "no log file FILENAME LEVEL", |
| 1565 | NO_STR |
| 1566 | "Logging control\n" |
| 1567 | "Cancel logging to file\n" |
| 1568 | "Logging file name\n" |
| 1569 | "Logging level\n") |
| 1570 | |
| 1571 | DEFUNSH (VTYSH_ALL, |
| 1572 | vtysh_log_monitor, |
| 1573 | vtysh_log_monitor_cmd, |
| 1574 | "log monitor", |
| 1575 | "Logging control\n" |
| 1576 | "Set terminal line (monitor) logging level\n") |
| 1577 | { |
| 1578 | return CMD_SUCCESS; |
| 1579 | } |
| 1580 | |
| 1581 | DEFUNSH (VTYSH_ALL, |
| 1582 | vtysh_log_monitor_level, |
| 1583 | vtysh_log_monitor_level_cmd, |
| 1584 | "log monitor "LOG_LEVELS, |
| 1585 | "Logging control\n" |
| 1586 | "Set terminal line (monitor) logging level\n" |
| 1587 | LOG_LEVEL_DESC) |
| 1588 | { |
| 1589 | return CMD_SUCCESS; |
| 1590 | } |
| 1591 | |
| 1592 | DEFUNSH (VTYSH_ALL, |
| 1593 | no_vtysh_log_monitor, |
| 1594 | no_vtysh_log_monitor_cmd, |
| 1595 | "no log monitor [LEVEL]", |
| 1596 | NO_STR |
| 1597 | "Logging control\n" |
| 1598 | "Disable terminal line (monitor) logging\n" |
| 1599 | "Logging level\n") |
| 1600 | { |
| 1601 | return CMD_SUCCESS; |
| 1602 | } |
| 1603 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1604 | DEFUNSH (VTYSH_ALL, |
| 1605 | vtysh_log_syslog, |
| 1606 | vtysh_log_syslog_cmd, |
| 1607 | "log syslog", |
| 1608 | "Logging control\n" |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1609 | "Set syslog logging level\n") |
| 1610 | { |
| 1611 | return CMD_SUCCESS; |
| 1612 | } |
| 1613 | |
| 1614 | DEFUNSH (VTYSH_ALL, |
| 1615 | vtysh_log_syslog_level, |
| 1616 | vtysh_log_syslog_level_cmd, |
| 1617 | "log syslog "LOG_LEVELS, |
| 1618 | "Logging control\n" |
| 1619 | "Set syslog logging level\n" |
| 1620 | LOG_LEVEL_DESC) |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1621 | { |
| 1622 | return CMD_SUCCESS; |
| 1623 | } |
| 1624 | |
| 1625 | DEFUNSH (VTYSH_ALL, |
| 1626 | no_vtysh_log_syslog, |
| 1627 | no_vtysh_log_syslog_cmd, |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1628 | "no log syslog [LEVEL]", |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1629 | NO_STR |
| 1630 | "Logging control\n" |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1631 | "Cancel logging to syslog\n" |
| 1632 | "Logging level\n") |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1633 | { |
| 1634 | return CMD_SUCCESS; |
| 1635 | } |
| 1636 | |
| 1637 | DEFUNSH (VTYSH_ALL, |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1638 | vtysh_log_facility, |
| 1639 | vtysh_log_facility_cmd, |
| 1640 | "log facility "LOG_FACILITIES, |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1641 | "Logging control\n" |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1642 | "Facility parameter for syslog messages\n" |
| 1643 | LOG_FACILITY_DESC) |
| 1644 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1645 | { |
| 1646 | return CMD_SUCCESS; |
| 1647 | } |
| 1648 | |
| 1649 | DEFUNSH (VTYSH_ALL, |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1650 | no_vtysh_log_facility, |
| 1651 | no_vtysh_log_facility_cmd, |
| 1652 | "no log facility [FACILITY]", |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1653 | NO_STR |
| 1654 | "Logging control\n" |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1655 | "Reset syslog facility to default (daemon)\n" |
| 1656 | "Syslog facility\n") |
| 1657 | |
| 1658 | { |
| 1659 | return CMD_SUCCESS; |
| 1660 | } |
| 1661 | |
| 1662 | DEFUNSH_DEPRECATED (VTYSH_ALL, |
| 1663 | vtysh_log_trap, |
| 1664 | vtysh_log_trap_cmd, |
| 1665 | "log trap "LOG_LEVELS, |
| 1666 | "Logging control\n" |
| 1667 | "(Deprecated) Set logging level and default for all destinations\n" |
| 1668 | LOG_LEVEL_DESC) |
| 1669 | |
| 1670 | { |
| 1671 | return CMD_SUCCESS; |
| 1672 | } |
| 1673 | |
| 1674 | DEFUNSH_DEPRECATED (VTYSH_ALL, |
| 1675 | no_vtysh_log_trap, |
| 1676 | no_vtysh_log_trap_cmd, |
| 1677 | "no log trap [LEVEL]", |
| 1678 | NO_STR |
| 1679 | "Logging control\n" |
| 1680 | "Permit all logging information\n" |
| 1681 | "Logging level\n") |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1682 | { |
| 1683 | return CMD_SUCCESS; |
| 1684 | } |
| 1685 | |
| 1686 | DEFUNSH (VTYSH_ALL, |
| 1687 | vtysh_log_record_priority, |
| 1688 | vtysh_log_record_priority_cmd, |
| 1689 | "log record-priority", |
| 1690 | "Logging control\n" |
| 1691 | "Log the priority of the message within the message\n") |
| 1692 | { |
| 1693 | return CMD_SUCCESS; |
| 1694 | } |
| 1695 | |
| 1696 | DEFUNSH (VTYSH_ALL, |
| 1697 | no_vtysh_log_record_priority, |
| 1698 | no_vtysh_log_record_priority_cmd, |
| 1699 | "no log record-priority", |
| 1700 | NO_STR |
| 1701 | "Logging control\n" |
| 1702 | "Do not log the priority of the message within the message\n") |
| 1703 | { |
| 1704 | return CMD_SUCCESS; |
| 1705 | } |
| 1706 | |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 1707 | DEFUNSH (VTYSH_ALL, |
Andrew J. Schorr | c749b72 | 2007-04-29 03:53:31 +0000 | [diff] [blame] | 1708 | vtysh_log_timestamp_precision, |
| 1709 | vtysh_log_timestamp_precision_cmd, |
| 1710 | "log timestamp precision <0-6>", |
| 1711 | "Logging control\n" |
| 1712 | "Timestamp configuration\n" |
| 1713 | "Set the timestamp precision\n" |
| 1714 | "Number of subsecond digits\n") |
| 1715 | { |
| 1716 | return CMD_SUCCESS; |
| 1717 | } |
| 1718 | |
| 1719 | DEFUNSH (VTYSH_ALL, |
| 1720 | no_vtysh_log_timestamp_precision, |
| 1721 | no_vtysh_log_timestamp_precision_cmd, |
| 1722 | "no log timestamp precision", |
| 1723 | NO_STR |
| 1724 | "Logging control\n" |
| 1725 | "Timestamp configuration\n" |
| 1726 | "Reset the timestamp precision to the default value of 0\n") |
| 1727 | { |
| 1728 | return CMD_SUCCESS; |
| 1729 | } |
| 1730 | |
| 1731 | DEFUNSH (VTYSH_ALL, |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 1732 | vtysh_service_password_encrypt, |
| 1733 | vtysh_service_password_encrypt_cmd, |
| 1734 | "service password-encryption", |
| 1735 | "Set up miscellaneous service\n" |
| 1736 | "Enable encrypted passwords\n") |
| 1737 | { |
| 1738 | return CMD_SUCCESS; |
| 1739 | } |
| 1740 | |
| 1741 | DEFUNSH (VTYSH_ALL, |
| 1742 | no_vtysh_service_password_encrypt, |
| 1743 | no_vtysh_service_password_encrypt_cmd, |
| 1744 | "no service password-encryption", |
| 1745 | NO_STR |
| 1746 | "Set up miscellaneous service\n" |
| 1747 | "Enable encrypted passwords\n") |
| 1748 | { |
| 1749 | return CMD_SUCCESS; |
| 1750 | } |
| 1751 | |
| 1752 | DEFUNSH (VTYSH_ALL, |
| 1753 | vtysh_config_password, |
| 1754 | vtysh_password_cmd, |
| 1755 | "password (8|) WORD", |
| 1756 | "Assign the terminal connection password\n" |
| 1757 | "Specifies a HIDDEN password will follow\n" |
| 1758 | "dummy string \n" |
| 1759 | "The HIDDEN line password string\n") |
| 1760 | { |
| 1761 | return CMD_SUCCESS; |
| 1762 | } |
| 1763 | |
| 1764 | DEFUNSH (VTYSH_ALL, |
| 1765 | vtysh_password_text, |
| 1766 | vtysh_password_text_cmd, |
| 1767 | "password LINE", |
| 1768 | "Assign the terminal connection password\n" |
| 1769 | "The UNENCRYPTED (cleartext) line password\n") |
| 1770 | { |
| 1771 | return CMD_SUCCESS; |
| 1772 | } |
| 1773 | |
| 1774 | DEFUNSH (VTYSH_ALL, |
| 1775 | vtysh_config_enable_password, |
| 1776 | vtysh_enable_password_cmd, |
| 1777 | "enable password (8|) WORD", |
| 1778 | "Modify enable password parameters\n" |
| 1779 | "Assign the privileged level password\n" |
| 1780 | "Specifies a HIDDEN password will follow\n" |
| 1781 | "dummy string \n" |
| 1782 | "The HIDDEN 'enable' password string\n") |
| 1783 | { |
| 1784 | return CMD_SUCCESS; |
| 1785 | } |
| 1786 | |
| 1787 | DEFUNSH (VTYSH_ALL, |
| 1788 | vtysh_enable_password_text, |
| 1789 | vtysh_enable_password_text_cmd, |
| 1790 | "enable password LINE", |
| 1791 | "Modify enable password parameters\n" |
| 1792 | "Assign the privileged level password\n" |
| 1793 | "The UNENCRYPTED (cleartext) 'enable' password\n") |
| 1794 | { |
| 1795 | return CMD_SUCCESS; |
| 1796 | } |
| 1797 | |
| 1798 | DEFUNSH (VTYSH_ALL, |
| 1799 | no_vtysh_config_enable_password, |
| 1800 | no_vtysh_enable_password_cmd, |
| 1801 | "no enable password", |
| 1802 | NO_STR |
| 1803 | "Modify enable password parameters\n" |
| 1804 | "Assign the privileged level password\n") |
| 1805 | { |
| 1806 | return CMD_SUCCESS; |
| 1807 | } |
| 1808 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1809 | DEFUN (vtysh_write_terminal, |
| 1810 | vtysh_write_terminal_cmd, |
| 1811 | "write terminal", |
| 1812 | "Write running configuration to memory, network, or terminal\n" |
| 1813 | "Write to terminal\n") |
| 1814 | { |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 1815 | u_int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1816 | char line[] = "write terminal\n"; |
| 1817 | FILE *fp = NULL; |
| 1818 | |
| 1819 | if (vtysh_pager_name) |
| 1820 | { |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1821 | fp = popen (vtysh_pager_name, "w"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1822 | if (fp == NULL) |
| 1823 | { |
| 1824 | perror ("popen"); |
| 1825 | exit (1); |
| 1826 | } |
| 1827 | } |
| 1828 | else |
| 1829 | fp = stdout; |
| 1830 | |
| 1831 | vty_out (vty, "Building configuration...%s", VTY_NEWLINE); |
| 1832 | vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE, |
| 1833 | VTY_NEWLINE); |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 1834 | vty_out (vty, "!%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1835 | |
Balaji.G | 837d16c | 2012-09-26 14:09:10 +0530 | [diff] [blame] | 1836 | for (i = 0; i < array_size(vtysh_client); i++) |
Gautam Kumar | cc216b7 | 2015-10-26 13:22:12 -0700 | [diff] [blame] | 1837 | vtysh_client_execute (&vtysh_client[i], line, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1838 | |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 1839 | /* Integrate vtysh specific configuration. */ |
| 1840 | vtysh_config_write (); |
| 1841 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1842 | vtysh_config_dump (fp); |
| 1843 | |
| 1844 | if (vtysh_pager_name && fp) |
| 1845 | { |
| 1846 | fflush (fp); |
| 1847 | if (pclose (fp) == -1) |
| 1848 | { |
| 1849 | perror ("pclose"); |
| 1850 | exit (1); |
| 1851 | } |
| 1852 | fp = NULL; |
| 1853 | } |
| 1854 | |
Chris Caputo | 6e79f8b | 2009-06-23 05:55:57 +0000 | [diff] [blame] | 1855 | vty_out (vty, "end%s", VTY_NEWLINE); |
| 1856 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1857 | return CMD_SUCCESS; |
| 1858 | } |
| 1859 | |
Donald Sharp | 9fb73e8 | 2015-09-22 11:13:12 -0400 | [diff] [blame] | 1860 | DEFUN (vtysh_write_terminal_daemon, |
| 1861 | vtysh_write_terminal_daemon_cmd, |
| 1862 | "write terminal (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|babeld)", |
| 1863 | "Write running configuration to memory, network, or terminal\n" |
| 1864 | "Write to terminal\n" |
| 1865 | "For the zebra daemon\n" |
| 1866 | "For the rip daemon\n" |
| 1867 | "For the ripng daemon\n" |
| 1868 | "For the ospf daemon\n" |
| 1869 | "For the ospfv6 daemon\n" |
| 1870 | "For the bgp daemon\n" |
| 1871 | "For the isis daemon\n" |
| 1872 | "For the babel daemon\n") |
| 1873 | { |
| 1874 | unsigned int i; |
| 1875 | int ret = CMD_SUCCESS; |
| 1876 | |
| 1877 | for (i = 0; i < array_size(vtysh_client); i++) |
| 1878 | { |
| 1879 | if (strcmp(vtysh_client[i].name, argv[0]) == 0) |
| 1880 | break; |
| 1881 | } |
| 1882 | |
| 1883 | ret = vtysh_client_execute(&vtysh_client[i], "show running-config\n", stdout); |
| 1884 | |
| 1885 | return ret; |
| 1886 | } |
| 1887 | |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 1888 | DEFUN (vtysh_integrated_config, |
| 1889 | vtysh_integrated_config_cmd, |
| 1890 | "service integrated-vtysh-config", |
| 1891 | "Set up miscellaneous service\n" |
| 1892 | "Write configuration into integrated file\n") |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1893 | { |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 1894 | vtysh_writeconfig_integrated = 1; |
| 1895 | return CMD_SUCCESS; |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1896 | } |
| 1897 | |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 1898 | DEFUN (no_vtysh_integrated_config, |
| 1899 | no_vtysh_integrated_config_cmd, |
| 1900 | "no service integrated-vtysh-config", |
| 1901 | NO_STR |
| 1902 | "Set up miscellaneous service\n" |
| 1903 | "Write configuration into integrated file\n") |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1904 | { |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 1905 | vtysh_writeconfig_integrated = 0; |
| 1906 | return CMD_SUCCESS; |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1907 | } |
| 1908 | |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 1909 | static int |
| 1910 | write_config_integrated(void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1911 | { |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 1912 | u_int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1913 | char line[] = "write terminal\n"; |
| 1914 | FILE *fp; |
| 1915 | char *integrate_sav = NULL; |
| 1916 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1917 | integrate_sav = malloc (strlen (integrate_default) + |
| 1918 | strlen (CONF_BACKUP_EXT) + 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1919 | strcpy (integrate_sav, integrate_default); |
| 1920 | strcat (integrate_sav, CONF_BACKUP_EXT); |
| 1921 | |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1922 | fprintf (stdout,"Building Configuration...\n"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1923 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1924 | /* Move current configuration file to backup config file. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1925 | unlink (integrate_sav); |
| 1926 | rename (integrate_default, integrate_sav); |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1927 | free (integrate_sav); |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1928 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1929 | fp = fopen (integrate_default, "w"); |
| 1930 | if (fp == NULL) |
| 1931 | { |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 1932 | fprintf (stdout,"%% Can't open configuration file %s.\n", |
| 1933 | integrate_default); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1934 | return CMD_SUCCESS; |
| 1935 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1936 | |
Balaji.G | 837d16c | 2012-09-26 14:09:10 +0530 | [diff] [blame] | 1937 | for (i = 0; i < array_size(vtysh_client); i++) |
Gautam Kumar | cc216b7 | 2015-10-26 13:22:12 -0700 | [diff] [blame] | 1938 | vtysh_client_execute (&vtysh_client[i], line, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1939 | |
| 1940 | vtysh_config_dump (fp); |
| 1941 | |
| 1942 | fclose (fp); |
| 1943 | |
gdt | aa593d5 | 2003-12-22 20:15:53 +0000 | [diff] [blame] | 1944 | if (chmod (integrate_default, CONFIGFILE_MASK) != 0) |
| 1945 | { |
| 1946 | fprintf (stdout,"%% Can't chmod configuration file %s: %s (%d)\n", |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 1947 | integrate_default, safe_strerror(errno), errno); |
gdt | aa593d5 | 2003-12-22 20:15:53 +0000 | [diff] [blame] | 1948 | return CMD_WARNING; |
| 1949 | } |
| 1950 | |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1951 | fprintf(stdout,"Integrated configuration saved to %s\n",integrate_default); |
| 1952 | |
| 1953 | fprintf (stdout,"[OK]\n"); |
| 1954 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1955 | return CMD_SUCCESS; |
| 1956 | } |
| 1957 | |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1958 | DEFUN (vtysh_write_memory, |
| 1959 | vtysh_write_memory_cmd, |
| 1960 | "write memory", |
| 1961 | "Write running configuration to memory, network, or terminal\n" |
| 1962 | "Write configuration to the file (same as write file)\n") |
| 1963 | { |
paul | dfc0d9b | 2003-04-18 23:55:29 +0000 | [diff] [blame] | 1964 | int ret = CMD_SUCCESS; |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1965 | char line[] = "write memory\n"; |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 1966 | u_int i; |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1967 | |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 1968 | /* If integrated Quagga.conf explicitely set. */ |
| 1969 | if (vtysh_writeconfig_integrated) |
| 1970 | return write_config_integrated(); |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1971 | |
| 1972 | fprintf (stdout,"Building Configuration...\n"); |
| 1973 | |
Balaji.G | 837d16c | 2012-09-26 14:09:10 +0530 | [diff] [blame] | 1974 | for (i = 0; i < array_size(vtysh_client); i++) |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 1975 | ret = vtysh_client_execute (&vtysh_client[i], line, stdout); |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 1976 | |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1977 | fprintf (stdout,"[OK]\n"); |
| 1978 | |
paul | dfc0d9b | 2003-04-18 23:55:29 +0000 | [diff] [blame] | 1979 | return ret; |
paul | 4fc01e6 | 2002-12-13 20:49:00 +0000 | [diff] [blame] | 1980 | } |
| 1981 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1982 | ALIAS (vtysh_write_memory, |
| 1983 | vtysh_copy_runningconfig_startupconfig_cmd, |
| 1984 | "copy running-config startup-config", |
| 1985 | "Copy from one file to another\n" |
| 1986 | "Copy from current system configuration\n" |
| 1987 | "Copy to startup configuration\n") |
| 1988 | |
| 1989 | ALIAS (vtysh_write_memory, |
| 1990 | vtysh_write_file_cmd, |
| 1991 | "write file", |
| 1992 | "Write running configuration to memory, network, or terminal\n" |
| 1993 | "Write configuration to the file (same as write memory)\n") |
| 1994 | |
hasso | 4a6e225 | 2003-05-25 11:51:29 +0000 | [diff] [blame] | 1995 | ALIAS (vtysh_write_memory, |
| 1996 | vtysh_write_cmd, |
| 1997 | "write", |
| 1998 | "Write running configuration to memory, network, or terminal\n") |
| 1999 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2000 | ALIAS (vtysh_write_terminal, |
| 2001 | vtysh_show_running_config_cmd, |
| 2002 | "show running-config", |
| 2003 | SHOW_STR |
| 2004 | "Current operating configuration\n") |
hasso | b094d26 | 2004-08-25 12:22:00 +0000 | [diff] [blame] | 2005 | |
Donald Sharp | 9fb73e8 | 2015-09-22 11:13:12 -0400 | [diff] [blame] | 2006 | ALIAS (vtysh_write_terminal_daemon, |
| 2007 | vtysh_show_running_config_daemon_cmd, |
| 2008 | "show running-config (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|babeld)", |
| 2009 | SHOW_STR |
| 2010 | "Current operating configuration\n" |
| 2011 | "For the zebra daemon\n" |
| 2012 | "For the rip daemon\n" |
| 2013 | "For the ripng daemon\n" |
| 2014 | "For the ospf daemon\n" |
| 2015 | "For the ospfv6 daemon\n" |
| 2016 | "For the bgp daemon\n" |
| 2017 | "For the isis daemon\n" |
| 2018 | "For the babel daemon\n") |
| 2019 | |
hasso | 34553cc | 2004-08-27 13:56:39 +0000 | [diff] [blame] | 2020 | DEFUN (vtysh_terminal_length, |
| 2021 | vtysh_terminal_length_cmd, |
| 2022 | "terminal length <0-512>", |
| 2023 | "Set terminal line parameters\n" |
| 2024 | "Set number of lines on a screen\n" |
| 2025 | "Number of lines on screen (0 for no pausing)\n") |
| 2026 | { |
| 2027 | int lines; |
| 2028 | char *endptr = NULL; |
| 2029 | char default_pager[10]; |
| 2030 | |
| 2031 | lines = strtol (argv[0], &endptr, 10); |
| 2032 | if (lines < 0 || lines > 512 || *endptr != '\0') |
| 2033 | { |
| 2034 | vty_out (vty, "length is malformed%s", VTY_NEWLINE); |
| 2035 | return CMD_WARNING; |
| 2036 | } |
| 2037 | |
| 2038 | if (vtysh_pager_name) |
| 2039 | { |
| 2040 | free (vtysh_pager_name); |
| 2041 | vtysh_pager_name = NULL; |
| 2042 | } |
| 2043 | |
| 2044 | if (lines != 0) |
| 2045 | { |
| 2046 | snprintf(default_pager, 10, "more -%i", lines); |
| 2047 | vtysh_pager_name = strdup (default_pager); |
| 2048 | } |
| 2049 | |
| 2050 | return CMD_SUCCESS; |
| 2051 | } |
| 2052 | |
| 2053 | DEFUN (vtysh_terminal_no_length, |
| 2054 | vtysh_terminal_no_length_cmd, |
| 2055 | "terminal no length", |
| 2056 | "Set terminal line parameters\n" |
| 2057 | NO_STR |
| 2058 | "Set number of lines on a screen\n") |
| 2059 | { |
| 2060 | if (vtysh_pager_name) |
| 2061 | { |
| 2062 | free (vtysh_pager_name); |
| 2063 | vtysh_pager_name = NULL; |
| 2064 | } |
| 2065 | |
| 2066 | vtysh_pager_init(); |
| 2067 | return CMD_SUCCESS; |
| 2068 | } |
| 2069 | |
hasso | f2799e6 | 2004-10-28 17:43:11 +0000 | [diff] [blame] | 2070 | DEFUN (vtysh_show_daemons, |
| 2071 | vtysh_show_daemons_cmd, |
| 2072 | "show daemons", |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 2073 | SHOW_STR |
| 2074 | "Show list of running daemons\n") |
| 2075 | { |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2076 | u_int i; |
| 2077 | |
Balaji.G | 837d16c | 2012-09-26 14:09:10 +0530 | [diff] [blame] | 2078 | for (i = 0; i < array_size(vtysh_client); i++) |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2079 | if ( vtysh_client[i].fd >= 0 ) |
| 2080 | vty_out(vty, " %s", vtysh_client[i].name); |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 2081 | vty_out(vty, "%s", VTY_NEWLINE); |
| 2082 | |
| 2083 | return CMD_SUCCESS; |
| 2084 | } |
| 2085 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2086 | /* Execute command in child process. */ |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 2087 | static int |
hasso | 5862ff5 | 2004-10-11 13:20:40 +0000 | [diff] [blame] | 2088 | execute_command (const char *command, int argc, const char *arg1, |
| 2089 | const char *arg2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2090 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2091 | pid_t pid; |
| 2092 | int status; |
| 2093 | |
| 2094 | /* Call fork(). */ |
| 2095 | pid = fork (); |
| 2096 | |
| 2097 | if (pid < 0) |
| 2098 | { |
| 2099 | /* Failure of fork(). */ |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 2100 | fprintf (stderr, "Can't fork: %s\n", safe_strerror (errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2101 | exit (1); |
| 2102 | } |
| 2103 | else if (pid == 0) |
| 2104 | { |
| 2105 | /* This is child process. */ |
| 2106 | switch (argc) |
| 2107 | { |
| 2108 | case 0: |
David Lamparter | 6769f43 | 2015-03-04 07:18:24 +0100 | [diff] [blame] | 2109 | execlp (command, command, (const char *)NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2110 | break; |
| 2111 | case 1: |
David Lamparter | 6769f43 | 2015-03-04 07:18:24 +0100 | [diff] [blame] | 2112 | execlp (command, command, arg1, (const char *)NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2113 | break; |
| 2114 | case 2: |
David Lamparter | 6769f43 | 2015-03-04 07:18:24 +0100 | [diff] [blame] | 2115 | execlp (command, command, arg1, arg2, (const char *)NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2116 | break; |
| 2117 | } |
| 2118 | |
| 2119 | /* When execlp suceed, this part is not executed. */ |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 2120 | fprintf (stderr, "Can't execute %s: %s\n", command, safe_strerror (errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2121 | exit (1); |
| 2122 | } |
| 2123 | else |
| 2124 | { |
| 2125 | /* This is parent. */ |
| 2126 | execute_flag = 1; |
David Lamparter | 6769f43 | 2015-03-04 07:18:24 +0100 | [diff] [blame] | 2127 | wait4 (pid, &status, 0, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2128 | execute_flag = 0; |
| 2129 | } |
| 2130 | return 0; |
| 2131 | } |
| 2132 | |
| 2133 | DEFUN (vtysh_ping, |
| 2134 | vtysh_ping_cmd, |
| 2135 | "ping WORD", |
hasso | 4eeccf1 | 2003-06-25 10:49:55 +0000 | [diff] [blame] | 2136 | "Send echo messages\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2137 | "Ping destination address or hostname\n") |
| 2138 | { |
| 2139 | execute_command ("ping", 1, argv[0], NULL); |
| 2140 | return CMD_SUCCESS; |
| 2141 | } |
| 2142 | |
hasso | 4eeccf1 | 2003-06-25 10:49:55 +0000 | [diff] [blame] | 2143 | ALIAS (vtysh_ping, |
| 2144 | vtysh_ping_ip_cmd, |
| 2145 | "ping ip WORD", |
| 2146 | "Send echo messages\n" |
| 2147 | "IP echo\n" |
| 2148 | "Ping destination address or hostname\n") |
| 2149 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2150 | DEFUN (vtysh_traceroute, |
| 2151 | vtysh_traceroute_cmd, |
| 2152 | "traceroute WORD", |
| 2153 | "Trace route to destination\n" |
| 2154 | "Trace route to destination address or hostname\n") |
| 2155 | { |
| 2156 | execute_command ("traceroute", 1, argv[0], NULL); |
| 2157 | return CMD_SUCCESS; |
| 2158 | } |
| 2159 | |
hasso | 4eeccf1 | 2003-06-25 10:49:55 +0000 | [diff] [blame] | 2160 | ALIAS (vtysh_traceroute, |
| 2161 | vtysh_traceroute_ip_cmd, |
| 2162 | "traceroute ip WORD", |
| 2163 | "Trace route to destination\n" |
| 2164 | "IP trace\n" |
| 2165 | "Trace route to destination address or hostname\n") |
| 2166 | |
| 2167 | #ifdef HAVE_IPV6 |
| 2168 | DEFUN (vtysh_ping6, |
| 2169 | vtysh_ping6_cmd, |
| 2170 | "ping ipv6 WORD", |
| 2171 | "Send echo messages\n" |
| 2172 | "IPv6 echo\n" |
| 2173 | "Ping destination address or hostname\n") |
| 2174 | { |
| 2175 | execute_command ("ping6", 1, argv[0], NULL); |
| 2176 | return CMD_SUCCESS; |
| 2177 | } |
| 2178 | |
| 2179 | DEFUN (vtysh_traceroute6, |
| 2180 | vtysh_traceroute6_cmd, |
| 2181 | "traceroute ipv6 WORD", |
| 2182 | "Trace route to destination\n" |
| 2183 | "IPv6 trace\n" |
| 2184 | "Trace route to destination address or hostname\n") |
| 2185 | { |
| 2186 | execute_command ("traceroute6", 1, argv[0], NULL); |
| 2187 | return CMD_SUCCESS; |
| 2188 | } |
| 2189 | #endif |
| 2190 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2191 | DEFUN (vtysh_telnet, |
| 2192 | vtysh_telnet_cmd, |
| 2193 | "telnet WORD", |
| 2194 | "Open a telnet connection\n" |
| 2195 | "IP address or hostname of a remote system\n") |
| 2196 | { |
| 2197 | execute_command ("telnet", 1, argv[0], NULL); |
| 2198 | return CMD_SUCCESS; |
| 2199 | } |
| 2200 | |
| 2201 | DEFUN (vtysh_telnet_port, |
| 2202 | vtysh_telnet_port_cmd, |
| 2203 | "telnet WORD PORT", |
| 2204 | "Open a telnet connection\n" |
| 2205 | "IP address or hostname of a remote system\n" |
| 2206 | "TCP Port number\n") |
| 2207 | { |
| 2208 | execute_command ("telnet", 2, argv[0], argv[1]); |
| 2209 | return CMD_SUCCESS; |
| 2210 | } |
| 2211 | |
paul | 5087df5 | 2003-01-25 06:56:09 +0000 | [diff] [blame] | 2212 | DEFUN (vtysh_ssh, |
| 2213 | vtysh_ssh_cmd, |
| 2214 | "ssh WORD", |
| 2215 | "Open an ssh connection\n" |
| 2216 | "[user@]host\n") |
| 2217 | { |
| 2218 | execute_command ("ssh", 1, argv[0], NULL); |
| 2219 | return CMD_SUCCESS; |
| 2220 | } |
| 2221 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2222 | DEFUN (vtysh_start_shell, |
| 2223 | vtysh_start_shell_cmd, |
| 2224 | "start-shell", |
| 2225 | "Start UNIX shell\n") |
| 2226 | { |
| 2227 | execute_command ("sh", 0, NULL, NULL); |
| 2228 | return CMD_SUCCESS; |
| 2229 | } |
| 2230 | |
| 2231 | DEFUN (vtysh_start_bash, |
| 2232 | vtysh_start_bash_cmd, |
| 2233 | "start-shell bash", |
| 2234 | "Start UNIX shell\n" |
| 2235 | "Start bash\n") |
| 2236 | { |
| 2237 | execute_command ("bash", 0, NULL, NULL); |
| 2238 | return CMD_SUCCESS; |
| 2239 | } |
| 2240 | |
| 2241 | DEFUN (vtysh_start_zsh, |
| 2242 | vtysh_start_zsh_cmd, |
| 2243 | "start-shell zsh", |
| 2244 | "Start UNIX shell\n" |
| 2245 | "Start Z shell\n") |
| 2246 | { |
| 2247 | execute_command ("zsh", 0, NULL, NULL); |
| 2248 | return CMD_SUCCESS; |
| 2249 | } |
hasso | b094d26 | 2004-08-25 12:22:00 +0000 | [diff] [blame] | 2250 | |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 2251 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2252 | vtysh_install_default (enum node_type node) |
| 2253 | { |
| 2254 | install_element (node, &config_list_cmd); |
| 2255 | } |
| 2256 | |
| 2257 | /* Making connection to protocol daemon. */ |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 2258 | static int |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2259 | vtysh_connect (struct vtysh_client *vclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2260 | { |
| 2261 | int ret; |
| 2262 | int sock, len; |
| 2263 | struct sockaddr_un addr; |
| 2264 | struct stat s_stat; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2265 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2266 | /* Stat socket to see if we have permission to access it. */ |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2267 | ret = stat (vclient->path, &s_stat); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2268 | if (ret < 0 && errno != ENOENT) |
| 2269 | { |
| 2270 | fprintf (stderr, "vtysh_connect(%s): stat = %s\n", |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2271 | vclient->path, safe_strerror(errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2272 | exit(1); |
| 2273 | } |
| 2274 | |
| 2275 | if (ret >= 0) |
| 2276 | { |
| 2277 | if (! S_ISSOCK(s_stat.st_mode)) |
| 2278 | { |
| 2279 | fprintf (stderr, "vtysh_connect(%s): Not a socket\n", |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2280 | vclient->path); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2281 | exit (1); |
| 2282 | } |
| 2283 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2284 | } |
| 2285 | |
| 2286 | sock = socket (AF_UNIX, SOCK_STREAM, 0); |
| 2287 | if (sock < 0) |
| 2288 | { |
| 2289 | #ifdef DEBUG |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2290 | fprintf(stderr, "vtysh_connect(%s): socket = %s\n", vclient->path, |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 2291 | safe_strerror(errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2292 | #endif /* DEBUG */ |
| 2293 | return -1; |
| 2294 | } |
| 2295 | |
| 2296 | memset (&addr, 0, sizeof (struct sockaddr_un)); |
| 2297 | addr.sun_family = AF_UNIX; |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2298 | strncpy (addr.sun_path, vclient->path, strlen (vclient->path)); |
Paul Jakma | 6f0e3f6 | 2007-05-10 02:38:51 +0000 | [diff] [blame] | 2299 | #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2300 | len = addr.sun_len = SUN_LEN(&addr); |
| 2301 | #else |
| 2302 | len = sizeof (addr.sun_family) + strlen (addr.sun_path); |
Paul Jakma | 6f0e3f6 | 2007-05-10 02:38:51 +0000 | [diff] [blame] | 2303 | #endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2304 | |
| 2305 | ret = connect (sock, (struct sockaddr *) &addr, len); |
| 2306 | if (ret < 0) |
| 2307 | { |
| 2308 | #ifdef DEBUG |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2309 | fprintf(stderr, "vtysh_connect(%s): connect = %s\n", vclient->path, |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 2310 | safe_strerror(errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2311 | #endif /* DEBUG */ |
| 2312 | close (sock); |
| 2313 | return -1; |
| 2314 | } |
| 2315 | vclient->fd = sock; |
| 2316 | |
| 2317 | return 0; |
| 2318 | } |
| 2319 | |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 2320 | int |
| 2321 | vtysh_connect_all(const char *daemon_name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2322 | { |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2323 | u_int i; |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 2324 | int rc = 0; |
| 2325 | int matches = 0; |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2326 | |
Balaji.G | 837d16c | 2012-09-26 14:09:10 +0530 | [diff] [blame] | 2327 | for (i = 0; i < array_size(vtysh_client); i++) |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2328 | { |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 2329 | if (!daemon_name || !strcmp(daemon_name, vtysh_client[i].name)) |
| 2330 | { |
| 2331 | matches++; |
| 2332 | if (vtysh_connect(&vtysh_client[i]) == 0) |
| 2333 | rc++; |
| 2334 | /* We need direct access to ripd in vtysh_exit_ripd_only. */ |
| 2335 | if (vtysh_client[i].flag == VTYSH_RIPD) |
| 2336 | ripd_client = &vtysh_client[i]; |
| 2337 | } |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2338 | } |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 2339 | if (!matches) |
| 2340 | fprintf(stderr, "Error: no daemons match name %s!\n", daemon_name); |
| 2341 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2342 | } |
| 2343 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 2344 | /* To disable readline's filename completion. */ |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 2345 | static char * |
paul | dfc0d9b | 2003-04-18 23:55:29 +0000 | [diff] [blame] | 2346 | vtysh_completion_entry_function (const char *ignore, int invoking_key) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2347 | { |
paul | dfc0d9b | 2003-04-18 23:55:29 +0000 | [diff] [blame] | 2348 | return NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2349 | } |
| 2350 | |
| 2351 | void |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2352 | vtysh_readline_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2353 | { |
| 2354 | /* readline related settings. */ |
Sébastien Luttringer | 66d2ead | 2014-05-27 19:55:11 +0200 | [diff] [blame] | 2355 | rl_bind_key ('?', (rl_command_func_t *) vtysh_rl_describe); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2356 | rl_completion_entry_function = vtysh_completion_entry_function; |
Sébastien Luttringer | 66d2ead | 2014-05-27 19:55:11 +0200 | [diff] [blame] | 2357 | rl_attempted_completion_function = (rl_completion_func_t *)new_completion; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2358 | } |
| 2359 | |
| 2360 | char * |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2361 | vtysh_prompt (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2362 | { |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 2363 | static struct utsname names; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2364 | static char buf[100]; |
| 2365 | const char*hostname; |
| 2366 | extern struct host host; |
| 2367 | |
| 2368 | hostname = host.name; |
| 2369 | |
| 2370 | if (!hostname) |
| 2371 | { |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 2372 | if (!names.nodename[0]) |
| 2373 | uname (&names); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2374 | hostname = names.nodename; |
| 2375 | } |
| 2376 | |
| 2377 | snprintf (buf, sizeof buf, cmd_prompt (vty->node), hostname); |
| 2378 | |
| 2379 | return buf; |
| 2380 | } |
| 2381 | |
| 2382 | void |
ajs | b1aa147 | 2005-01-28 21:11:46 +0000 | [diff] [blame] | 2383 | vtysh_init_vty (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2384 | { |
| 2385 | /* Make vty structure. */ |
| 2386 | vty = vty_new (); |
| 2387 | vty->type = VTY_SHELL; |
| 2388 | vty->node = VIEW_NODE; |
| 2389 | |
| 2390 | /* Initialize commands. */ |
| 2391 | cmd_init (0); |
| 2392 | |
| 2393 | /* Install nodes. */ |
| 2394 | install_node (&bgp_node, NULL); |
| 2395 | install_node (&rip_node, NULL); |
| 2396 | install_node (&interface_node, NULL); |
| 2397 | install_node (&rmap_node, NULL); |
| 2398 | install_node (&zebra_node, NULL); |
| 2399 | install_node (&bgp_vpnv4_node, NULL); |
Lou Berger | 13c378d | 2016-01-12 13:41:56 -0500 | [diff] [blame] | 2400 | install_node (&bgp_vpnv6_node, NULL); |
Lou Berger | a3fda88 | 2016-01-12 13:42:04 -0500 | [diff] [blame] | 2401 | install_node (&bgp_encap_node, NULL); |
| 2402 | install_node (&bgp_encapv6_node, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2403 | install_node (&bgp_ipv4_node, NULL); |
| 2404 | install_node (&bgp_ipv4m_node, NULL); |
| 2405 | /* #ifdef HAVE_IPV6 */ |
| 2406 | install_node (&bgp_ipv6_node, NULL); |
paul | 57b5b7e | 2005-08-22 22:44:29 +0000 | [diff] [blame] | 2407 | install_node (&bgp_ipv6m_node, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2408 | /* #endif */ |
| 2409 | install_node (&ospf_node, NULL); |
| 2410 | /* #ifdef HAVE_IPV6 */ |
| 2411 | install_node (&ripng_node, NULL); |
| 2412 | install_node (&ospf6_node, NULL); |
| 2413 | /* #endif */ |
David Lamparter | ee53c8b | 2015-05-23 05:45:59 +0200 | [diff] [blame] | 2414 | install_node (&babel_node, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2415 | install_node (&keychain_node, NULL); |
| 2416 | install_node (&keychain_key_node, NULL); |
hasso | c25e458 | 2003-12-23 10:39:08 +0000 | [diff] [blame] | 2417 | install_node (&isis_node, NULL); |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 2418 | install_node (&vty_node, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2419 | |
| 2420 | vtysh_install_default (VIEW_NODE); |
| 2421 | vtysh_install_default (ENABLE_NODE); |
| 2422 | vtysh_install_default (CONFIG_NODE); |
| 2423 | vtysh_install_default (BGP_NODE); |
| 2424 | vtysh_install_default (RIP_NODE); |
| 2425 | vtysh_install_default (INTERFACE_NODE); |
| 2426 | vtysh_install_default (RMAP_NODE); |
| 2427 | vtysh_install_default (ZEBRA_NODE); |
| 2428 | vtysh_install_default (BGP_VPNV4_NODE); |
Lou Berger | 13c378d | 2016-01-12 13:41:56 -0500 | [diff] [blame] | 2429 | vtysh_install_default (BGP_VPNV6_NODE); |
Lou Berger | a3fda88 | 2016-01-12 13:42:04 -0500 | [diff] [blame] | 2430 | vtysh_install_default (BGP_ENCAP_NODE); |
| 2431 | vtysh_install_default (BGP_ENCAPV6_NODE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2432 | vtysh_install_default (BGP_IPV4_NODE); |
| 2433 | vtysh_install_default (BGP_IPV4M_NODE); |
| 2434 | vtysh_install_default (BGP_IPV6_NODE); |
paul | 57b5b7e | 2005-08-22 22:44:29 +0000 | [diff] [blame] | 2435 | vtysh_install_default (BGP_IPV6M_NODE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2436 | vtysh_install_default (OSPF_NODE); |
| 2437 | vtysh_install_default (RIPNG_NODE); |
| 2438 | vtysh_install_default (OSPF6_NODE); |
Juliusz Chroboczek | feb6c53 | 2012-02-07 04:58:49 +0100 | [diff] [blame] | 2439 | vtysh_install_default (BABEL_NODE); |
hasso | c25e458 | 2003-12-23 10:39:08 +0000 | [diff] [blame] | 2440 | vtysh_install_default (ISIS_NODE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2441 | vtysh_install_default (KEYCHAIN_NODE); |
| 2442 | vtysh_install_default (KEYCHAIN_KEY_NODE); |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 2443 | vtysh_install_default (VTY_NODE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2444 | |
| 2445 | install_element (VIEW_NODE, &vtysh_enable_cmd); |
| 2446 | install_element (ENABLE_NODE, &vtysh_config_terminal_cmd); |
| 2447 | install_element (ENABLE_NODE, &vtysh_disable_cmd); |
| 2448 | |
| 2449 | /* "exit" command. */ |
| 2450 | install_element (VIEW_NODE, &vtysh_exit_all_cmd); |
| 2451 | install_element (VIEW_NODE, &vtysh_quit_all_cmd); |
| 2452 | install_element (CONFIG_NODE, &vtysh_exit_all_cmd); |
| 2453 | /* install_element (CONFIG_NODE, &vtysh_quit_all_cmd); */ |
| 2454 | install_element (ENABLE_NODE, &vtysh_exit_all_cmd); |
| 2455 | install_element (ENABLE_NODE, &vtysh_quit_all_cmd); |
| 2456 | install_element (RIP_NODE, &vtysh_exit_ripd_cmd); |
| 2457 | install_element (RIP_NODE, &vtysh_quit_ripd_cmd); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2458 | install_element (RIPNG_NODE, &vtysh_exit_ripngd_cmd); |
| 2459 | install_element (RIPNG_NODE, &vtysh_quit_ripngd_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2460 | install_element (OSPF_NODE, &vtysh_exit_ospfd_cmd); |
| 2461 | install_element (OSPF_NODE, &vtysh_quit_ospfd_cmd); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2462 | install_element (OSPF6_NODE, &vtysh_exit_ospf6d_cmd); |
| 2463 | install_element (OSPF6_NODE, &vtysh_quit_ospf6d_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2464 | install_element (BGP_NODE, &vtysh_exit_bgpd_cmd); |
| 2465 | install_element (BGP_NODE, &vtysh_quit_bgpd_cmd); |
| 2466 | install_element (BGP_VPNV4_NODE, &vtysh_exit_bgpd_cmd); |
| 2467 | install_element (BGP_VPNV4_NODE, &vtysh_quit_bgpd_cmd); |
Lou Berger | 13c378d | 2016-01-12 13:41:56 -0500 | [diff] [blame] | 2468 | install_element (BGP_VPNV6_NODE, &vtysh_exit_bgpd_cmd); |
| 2469 | install_element (BGP_VPNV6_NODE, &vtysh_quit_bgpd_cmd); |
Lou Berger | a3fda88 | 2016-01-12 13:42:04 -0500 | [diff] [blame] | 2470 | install_element (BGP_ENCAP_NODE, &vtysh_exit_bgpd_cmd); |
| 2471 | install_element (BGP_ENCAP_NODE, &vtysh_quit_bgpd_cmd); |
| 2472 | install_element (BGP_ENCAPV6_NODE, &vtysh_exit_bgpd_cmd); |
| 2473 | install_element (BGP_ENCAPV6_NODE, &vtysh_quit_bgpd_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2474 | install_element (BGP_IPV4_NODE, &vtysh_exit_bgpd_cmd); |
| 2475 | install_element (BGP_IPV4_NODE, &vtysh_quit_bgpd_cmd); |
| 2476 | install_element (BGP_IPV4M_NODE, &vtysh_exit_bgpd_cmd); |
| 2477 | install_element (BGP_IPV4M_NODE, &vtysh_quit_bgpd_cmd); |
| 2478 | install_element (BGP_IPV6_NODE, &vtysh_exit_bgpd_cmd); |
| 2479 | install_element (BGP_IPV6_NODE, &vtysh_quit_bgpd_cmd); |
paul | 57b5b7e | 2005-08-22 22:44:29 +0000 | [diff] [blame] | 2480 | install_element (BGP_IPV6M_NODE, &vtysh_exit_bgpd_cmd); |
| 2481 | install_element (BGP_IPV6M_NODE, &vtysh_quit_bgpd_cmd); |
hasso | c25e458 | 2003-12-23 10:39:08 +0000 | [diff] [blame] | 2482 | install_element (ISIS_NODE, &vtysh_exit_isisd_cmd); |
| 2483 | install_element (ISIS_NODE, &vtysh_quit_isisd_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2484 | install_element (KEYCHAIN_NODE, &vtysh_exit_ripd_cmd); |
| 2485 | install_element (KEYCHAIN_NODE, &vtysh_quit_ripd_cmd); |
| 2486 | install_element (KEYCHAIN_KEY_NODE, &vtysh_exit_ripd_cmd); |
| 2487 | install_element (KEYCHAIN_KEY_NODE, &vtysh_quit_ripd_cmd); |
| 2488 | install_element (RMAP_NODE, &vtysh_exit_rmap_cmd); |
| 2489 | install_element (RMAP_NODE, &vtysh_quit_rmap_cmd); |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 2490 | install_element (VTY_NODE, &vtysh_exit_line_vty_cmd); |
| 2491 | install_element (VTY_NODE, &vtysh_quit_line_vty_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2492 | |
| 2493 | /* "end" command. */ |
| 2494 | install_element (CONFIG_NODE, &vtysh_end_all_cmd); |
| 2495 | install_element (ENABLE_NODE, &vtysh_end_all_cmd); |
| 2496 | install_element (RIP_NODE, &vtysh_end_all_cmd); |
| 2497 | install_element (RIPNG_NODE, &vtysh_end_all_cmd); |
| 2498 | install_element (OSPF_NODE, &vtysh_end_all_cmd); |
| 2499 | install_element (OSPF6_NODE, &vtysh_end_all_cmd); |
Juliusz Chroboczek | feb6c53 | 2012-02-07 04:58:49 +0100 | [diff] [blame] | 2500 | install_element (BABEL_NODE, &vtysh_end_all_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2501 | install_element (BGP_NODE, &vtysh_end_all_cmd); |
| 2502 | install_element (BGP_IPV4_NODE, &vtysh_end_all_cmd); |
| 2503 | install_element (BGP_IPV4M_NODE, &vtysh_end_all_cmd); |
| 2504 | install_element (BGP_VPNV4_NODE, &vtysh_end_all_cmd); |
Lou Berger | 13c378d | 2016-01-12 13:41:56 -0500 | [diff] [blame] | 2505 | install_element (BGP_VPNV6_NODE, &vtysh_end_all_cmd); |
Lou Berger | a3fda88 | 2016-01-12 13:42:04 -0500 | [diff] [blame] | 2506 | install_element (BGP_ENCAP_NODE, &vtysh_end_all_cmd); |
| 2507 | install_element (BGP_ENCAPV6_NODE, &vtysh_end_all_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2508 | install_element (BGP_IPV6_NODE, &vtysh_end_all_cmd); |
paul | 57b5b7e | 2005-08-22 22:44:29 +0000 | [diff] [blame] | 2509 | install_element (BGP_IPV6M_NODE, &vtysh_end_all_cmd); |
hasso | c25e458 | 2003-12-23 10:39:08 +0000 | [diff] [blame] | 2510 | install_element (ISIS_NODE, &vtysh_end_all_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2511 | install_element (KEYCHAIN_NODE, &vtysh_end_all_cmd); |
| 2512 | install_element (KEYCHAIN_KEY_NODE, &vtysh_end_all_cmd); |
| 2513 | install_element (RMAP_NODE, &vtysh_end_all_cmd); |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 2514 | install_element (VTY_NODE, &vtysh_end_all_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2515 | |
paul | 338a991 | 2003-03-01 15:44:10 +0000 | [diff] [blame] | 2516 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
paul | 464dc8d | 2003-03-28 02:25:45 +0000 | [diff] [blame] | 2517 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2518 | install_element (INTERFACE_NODE, &vtysh_end_all_cmd); |
| 2519 | install_element (INTERFACE_NODE, &vtysh_exit_interface_cmd); |
| 2520 | install_element (INTERFACE_NODE, &vtysh_quit_interface_cmd); |
| 2521 | install_element (CONFIG_NODE, &router_rip_cmd); |
| 2522 | #ifdef HAVE_IPV6 |
| 2523 | install_element (CONFIG_NODE, &router_ripng_cmd); |
| 2524 | #endif |
| 2525 | install_element (CONFIG_NODE, &router_ospf_cmd); |
| 2526 | #ifdef HAVE_IPV6 |
| 2527 | install_element (CONFIG_NODE, &router_ospf6_cmd); |
| 2528 | #endif |
hasso | c25e458 | 2003-12-23 10:39:08 +0000 | [diff] [blame] | 2529 | install_element (CONFIG_NODE, &router_isis_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2530 | install_element (CONFIG_NODE, &router_bgp_cmd); |
Paul Jakma | 10895fd | 2008-07-03 19:34:48 +0000 | [diff] [blame] | 2531 | install_element (CONFIG_NODE, &router_bgp_view_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2532 | install_element (BGP_NODE, &address_family_vpnv4_cmd); |
| 2533 | install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd); |
Lou Berger | 13c378d | 2016-01-12 13:41:56 -0500 | [diff] [blame] | 2534 | install_element (BGP_NODE, &address_family_vpnv6_cmd); |
| 2535 | install_element (BGP_NODE, &address_family_vpnv6_unicast_cmd); |
Lou Berger | a3fda88 | 2016-01-12 13:42:04 -0500 | [diff] [blame] | 2536 | install_element (BGP_NODE, &address_family_encap_cmd); |
| 2537 | install_element (BGP_NODE, &address_family_encapv6_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2538 | install_element (BGP_NODE, &address_family_ipv4_unicast_cmd); |
| 2539 | install_element (BGP_NODE, &address_family_ipv4_multicast_cmd); |
| 2540 | #ifdef HAVE_IPV6 |
| 2541 | install_element (BGP_NODE, &address_family_ipv6_cmd); |
| 2542 | install_element (BGP_NODE, &address_family_ipv6_unicast_cmd); |
| 2543 | #endif |
| 2544 | install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); |
Lou Berger | 13c378d | 2016-01-12 13:41:56 -0500 | [diff] [blame] | 2545 | install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); |
Lou Berger | a3fda88 | 2016-01-12 13:42:04 -0500 | [diff] [blame] | 2546 | install_element (BGP_ENCAP_NODE, &exit_address_family_cmd); |
| 2547 | install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2548 | install_element (BGP_IPV4_NODE, &exit_address_family_cmd); |
| 2549 | install_element (BGP_IPV4M_NODE, &exit_address_family_cmd); |
| 2550 | install_element (BGP_IPV6_NODE, &exit_address_family_cmd); |
paul | 57b5b7e | 2005-08-22 22:44:29 +0000 | [diff] [blame] | 2551 | install_element (BGP_IPV6M_NODE, &exit_address_family_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2552 | install_element (CONFIG_NODE, &key_chain_cmd); |
| 2553 | install_element (CONFIG_NODE, &route_map_cmd); |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 2554 | install_element (CONFIG_NODE, &vtysh_line_vty_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2555 | install_element (KEYCHAIN_NODE, &key_cmd); |
| 2556 | install_element (KEYCHAIN_NODE, &key_chain_cmd); |
| 2557 | install_element (KEYCHAIN_KEY_NODE, &key_chain_cmd); |
| 2558 | install_element (CONFIG_NODE, &vtysh_interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 2559 | install_element (CONFIG_NODE, &vtysh_no_interface_cmd); |
Feng Lu | 471ea39 | 2015-05-22 11:40:00 +0200 | [diff] [blame] | 2560 | install_element (CONFIG_NODE, &vtysh_interface_vrf_cmd); |
| 2561 | install_element (CONFIG_NODE, &vtysh_no_interface_vrf_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2562 | install_element (ENABLE_NODE, &vtysh_show_running_config_cmd); |
Donald Sharp | 9fb73e8 | 2015-09-22 11:13:12 -0400 | [diff] [blame] | 2563 | install_element (ENABLE_NODE, &vtysh_show_running_config_daemon_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2564 | install_element (ENABLE_NODE, &vtysh_copy_runningconfig_startupconfig_cmd); |
| 2565 | install_element (ENABLE_NODE, &vtysh_write_file_cmd); |
hasso | 4a6e225 | 2003-05-25 11:51:29 +0000 | [diff] [blame] | 2566 | install_element (ENABLE_NODE, &vtysh_write_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2567 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 2568 | /* "write terminal" command. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2569 | install_element (ENABLE_NODE, &vtysh_write_terminal_cmd); |
Donald Sharp | 9fb73e8 | 2015-09-22 11:13:12 -0400 | [diff] [blame] | 2570 | install_element (ENABLE_NODE, &vtysh_write_terminal_daemon_cmd); |
Donald Sharp | 0744040 | 2016-02-25 07:39:45 -0500 | [diff] [blame] | 2571 | |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 2572 | install_element (CONFIG_NODE, &vtysh_integrated_config_cmd); |
| 2573 | install_element (CONFIG_NODE, &no_vtysh_integrated_config_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2574 | |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 2575 | /* "write memory" command. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2576 | install_element (ENABLE_NODE, &vtysh_write_memory_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2577 | |
hasso | 34553cc | 2004-08-27 13:56:39 +0000 | [diff] [blame] | 2578 | install_element (VIEW_NODE, &vtysh_terminal_length_cmd); |
| 2579 | install_element (ENABLE_NODE, &vtysh_terminal_length_cmd); |
| 2580 | install_element (VIEW_NODE, &vtysh_terminal_no_length_cmd); |
| 2581 | install_element (ENABLE_NODE, &vtysh_terminal_no_length_cmd); |
hasso | f2799e6 | 2004-10-28 17:43:11 +0000 | [diff] [blame] | 2582 | install_element (VIEW_NODE, &vtysh_show_daemons_cmd); |
| 2583 | install_element (ENABLE_NODE, &vtysh_show_daemons_cmd); |
hasso | 34553cc | 2004-08-27 13:56:39 +0000 | [diff] [blame] | 2584 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2585 | install_element (VIEW_NODE, &vtysh_ping_cmd); |
hasso | 4eeccf1 | 2003-06-25 10:49:55 +0000 | [diff] [blame] | 2586 | install_element (VIEW_NODE, &vtysh_ping_ip_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2587 | install_element (VIEW_NODE, &vtysh_traceroute_cmd); |
hasso | 4eeccf1 | 2003-06-25 10:49:55 +0000 | [diff] [blame] | 2588 | install_element (VIEW_NODE, &vtysh_traceroute_ip_cmd); |
| 2589 | #ifdef HAVE_IPV6 |
| 2590 | install_element (VIEW_NODE, &vtysh_ping6_cmd); |
| 2591 | install_element (VIEW_NODE, &vtysh_traceroute6_cmd); |
| 2592 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2593 | install_element (VIEW_NODE, &vtysh_telnet_cmd); |
| 2594 | install_element (VIEW_NODE, &vtysh_telnet_port_cmd); |
paul | 5087df5 | 2003-01-25 06:56:09 +0000 | [diff] [blame] | 2595 | install_element (VIEW_NODE, &vtysh_ssh_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2596 | install_element (ENABLE_NODE, &vtysh_ping_cmd); |
hasso | 4eeccf1 | 2003-06-25 10:49:55 +0000 | [diff] [blame] | 2597 | install_element (ENABLE_NODE, &vtysh_ping_ip_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2598 | install_element (ENABLE_NODE, &vtysh_traceroute_cmd); |
hasso | 4eeccf1 | 2003-06-25 10:49:55 +0000 | [diff] [blame] | 2599 | install_element (ENABLE_NODE, &vtysh_traceroute_ip_cmd); |
| 2600 | #ifdef HAVE_IPV6 |
| 2601 | install_element (ENABLE_NODE, &vtysh_ping6_cmd); |
| 2602 | install_element (ENABLE_NODE, &vtysh_traceroute6_cmd); |
| 2603 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2604 | install_element (ENABLE_NODE, &vtysh_telnet_cmd); |
| 2605 | install_element (ENABLE_NODE, &vtysh_telnet_port_cmd); |
hasso | 67e29ab | 2004-08-26 22:21:31 +0000 | [diff] [blame] | 2606 | install_element (ENABLE_NODE, &vtysh_ssh_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2607 | install_element (ENABLE_NODE, &vtysh_start_shell_cmd); |
| 2608 | install_element (ENABLE_NODE, &vtysh_start_bash_cmd); |
| 2609 | install_element (ENABLE_NODE, &vtysh_start_zsh_cmd); |
Paul Jakma | dbf7d13 | 2006-05-23 22:10:01 +0000 | [diff] [blame] | 2610 | |
Paul Jakma | 362b403 | 2006-05-28 07:54:45 +0000 | [diff] [blame] | 2611 | install_element (VIEW_NODE, &vtysh_show_memory_cmd); |
| 2612 | install_element (ENABLE_NODE, &vtysh_show_memory_cmd); |
| 2613 | |
Donald Sharp | 567a638 | 2015-08-19 21:22:17 -0400 | [diff] [blame] | 2614 | install_element (VIEW_NODE, &vtysh_show_work_queues_cmd); |
| 2615 | install_element (ENABLE_NODE, &vtysh_show_work_queues_cmd); |
Donald Sharp | 0744040 | 2016-02-25 07:39:45 -0500 | [diff] [blame] | 2616 | install_element (ENABLE_NODE, &vtysh_show_work_queues_daemon_cmd); |
| 2617 | install_element (VIEW_NODE, &vtysh_show_work_queues_daemon_cmd); |
Donald Sharp | 567a638 | 2015-08-19 21:22:17 -0400 | [diff] [blame] | 2618 | |
| 2619 | install_element (VIEW_NODE, &vtysh_show_thread_cmd); |
| 2620 | install_element (ENABLE_NODE, &vtysh_show_thread_cmd); |
| 2621 | |
Paul Jakma | dbf7d13 | 2006-05-23 22:10:01 +0000 | [diff] [blame] | 2622 | /* Logging */ |
| 2623 | install_element (ENABLE_NODE, &vtysh_show_logging_cmd); |
| 2624 | install_element (VIEW_NODE, &vtysh_show_logging_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2625 | install_element (CONFIG_NODE, &vtysh_log_stdout_cmd); |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 2626 | install_element (CONFIG_NODE, &vtysh_log_stdout_level_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2627 | install_element (CONFIG_NODE, &no_vtysh_log_stdout_cmd); |
| 2628 | install_element (CONFIG_NODE, &vtysh_log_file_cmd); |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 2629 | install_element (CONFIG_NODE, &vtysh_log_file_level_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2630 | install_element (CONFIG_NODE, &no_vtysh_log_file_cmd); |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 2631 | install_element (CONFIG_NODE, &no_vtysh_log_file_level_cmd); |
| 2632 | install_element (CONFIG_NODE, &vtysh_log_monitor_cmd); |
| 2633 | install_element (CONFIG_NODE, &vtysh_log_monitor_level_cmd); |
| 2634 | install_element (CONFIG_NODE, &no_vtysh_log_monitor_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2635 | install_element (CONFIG_NODE, &vtysh_log_syslog_cmd); |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 2636 | install_element (CONFIG_NODE, &vtysh_log_syslog_level_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2637 | install_element (CONFIG_NODE, &no_vtysh_log_syslog_cmd); |
| 2638 | install_element (CONFIG_NODE, &vtysh_log_trap_cmd); |
| 2639 | install_element (CONFIG_NODE, &no_vtysh_log_trap_cmd); |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 2640 | install_element (CONFIG_NODE, &vtysh_log_facility_cmd); |
| 2641 | install_element (CONFIG_NODE, &no_vtysh_log_facility_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2642 | install_element (CONFIG_NODE, &vtysh_log_record_priority_cmd); |
| 2643 | install_element (CONFIG_NODE, &no_vtysh_log_record_priority_cmd); |
Andrew J. Schorr | c749b72 | 2007-04-29 03:53:31 +0000 | [diff] [blame] | 2644 | install_element (CONFIG_NODE, &vtysh_log_timestamp_precision_cmd); |
| 2645 | install_element (CONFIG_NODE, &no_vtysh_log_timestamp_precision_cmd); |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 2646 | |
| 2647 | install_element (CONFIG_NODE, &vtysh_service_password_encrypt_cmd); |
| 2648 | install_element (CONFIG_NODE, &no_vtysh_service_password_encrypt_cmd); |
| 2649 | |
| 2650 | install_element (CONFIG_NODE, &vtysh_password_cmd); |
| 2651 | install_element (CONFIG_NODE, &vtysh_password_text_cmd); |
| 2652 | install_element (CONFIG_NODE, &vtysh_enable_password_cmd); |
| 2653 | install_element (CONFIG_NODE, &vtysh_enable_password_text_cmd); |
| 2654 | install_element (CONFIG_NODE, &no_vtysh_enable_password_cmd); |
| 2655 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2656 | } |