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 <pwd.h> |
| 28 | |
| 29 | #include <readline/readline.h> |
| 30 | #include <readline/history.h> |
| 31 | |
gdt | 5e4fa16 | 2004-03-16 14:38:36 +0000 | [diff] [blame] | 32 | #include <lib/version.h> |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 33 | #include "getopt.h" |
| 34 | #include "command.h" |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 35 | #include "memory.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 36 | |
| 37 | #include "vtysh/vtysh.h" |
| 38 | #include "vtysh/vtysh_user.h" |
hasso | b094d26 | 2004-08-25 12:22:00 +0000 | [diff] [blame] | 39 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 40 | /* VTY shell program name. */ |
| 41 | char *progname; |
| 42 | |
hasso | 67e29ab | 2004-08-26 22:21:31 +0000 | [diff] [blame] | 43 | /* Configuration file name and directory. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 44 | char config_default[] = SYSCONFDIR VTYSH_DEFAULT_CONFIG; |
| 45 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 46 | /* Flag for indicate executing child command. */ |
| 47 | int execute_flag = 0; |
| 48 | |
| 49 | /* For sigsetjmp() & siglongjmp(). */ |
| 50 | static sigjmp_buf jmpbuf; |
| 51 | |
| 52 | /* Flag for avoid recursive siglongjmp() call. */ |
| 53 | static int jmpflag = 0; |
| 54 | |
| 55 | /* A static variable for holding the line. */ |
| 56 | static char *line_read; |
| 57 | |
| 58 | /* Master of threads. */ |
| 59 | struct thread_master *master; |
hasso | b094d26 | 2004-08-25 12:22:00 +0000 | [diff] [blame] | 60 | |
Stephen Hemminger | 57fb974 | 2008-07-28 12:19:04 -0700 | [diff] [blame] | 61 | /* Command logging */ |
| 62 | FILE *logfile; |
| 63 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 64 | /* SIGTSTP handler. This function care user's ^Z input. */ |
| 65 | void |
| 66 | sigtstp (int sig) |
| 67 | { |
| 68 | /* Execute "end" command. */ |
| 69 | vtysh_execute ("end"); |
| 70 | |
| 71 | /* Initialize readline. */ |
| 72 | rl_initialize (); |
| 73 | printf ("\n"); |
| 74 | |
| 75 | /* Check jmpflag for duplicate siglongjmp(). */ |
| 76 | if (! jmpflag) |
| 77 | return; |
| 78 | |
| 79 | jmpflag = 0; |
| 80 | |
| 81 | /* Back to main command loop. */ |
| 82 | siglongjmp (jmpbuf, 1); |
| 83 | } |
| 84 | |
| 85 | /* SIGINT handler. This function care user's ^Z input. */ |
| 86 | void |
| 87 | sigint (int sig) |
| 88 | { |
| 89 | /* Check this process is not child process. */ |
| 90 | if (! execute_flag) |
| 91 | { |
| 92 | rl_initialize (); |
| 93 | printf ("\n"); |
| 94 | rl_forced_update_display (); |
| 95 | } |
| 96 | } |
| 97 | |
hasso | e42f5a3 | 2004-08-28 17:04:33 +0000 | [diff] [blame] | 98 | /* Signale wrapper for vtysh. We don't use sigevent because |
| 99 | * vtysh doesn't use threads. TODO */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 100 | RETSIGTYPE * |
hasso | e42f5a3 | 2004-08-28 17:04:33 +0000 | [diff] [blame] | 101 | vtysh_signal_set (int signo, void (*func)(int)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 102 | { |
| 103 | int ret; |
| 104 | struct sigaction sig; |
| 105 | struct sigaction osig; |
| 106 | |
| 107 | sig.sa_handler = func; |
| 108 | sigemptyset (&sig.sa_mask); |
| 109 | sig.sa_flags = 0; |
| 110 | #ifdef SA_RESTART |
| 111 | sig.sa_flags |= SA_RESTART; |
| 112 | #endif /* SA_RESTART */ |
| 113 | |
| 114 | ret = sigaction (signo, &sig, &osig); |
| 115 | |
| 116 | if (ret < 0) |
| 117 | return (SIG_ERR); |
| 118 | else |
| 119 | return (osig.sa_handler); |
| 120 | } |
| 121 | |
| 122 | /* Initialization of signal handles. */ |
| 123 | void |
hasso | e42f5a3 | 2004-08-28 17:04:33 +0000 | [diff] [blame] | 124 | vtysh_signal_init () |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 125 | { |
hasso | e42f5a3 | 2004-08-28 17:04:33 +0000 | [diff] [blame] | 126 | vtysh_signal_set (SIGINT, sigint); |
| 127 | vtysh_signal_set (SIGTSTP, sigtstp); |
| 128 | vtysh_signal_set (SIGPIPE, SIG_IGN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 129 | } |
hasso | b094d26 | 2004-08-25 12:22:00 +0000 | [diff] [blame] | 130 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 131 | /* Help information display. */ |
| 132 | static void |
| 133 | usage (int status) |
| 134 | { |
| 135 | if (status != 0) |
| 136 | fprintf (stderr, "Try `%s --help' for more information.\n", progname); |
| 137 | else |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 138 | printf ("Usage : %s [OPTION...]\n\n" \ |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 139 | "Integrated shell for Quagga routing software suite. \n\n" \ |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 140 | "-b, --boot Execute boot startup configuration\n" \ |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 141 | "-c, --command Execute argument as command\n" \ |
| 142 | "-d, --daemon Connect only to the specified daemon\n" \ |
| 143 | "-E, --echo Echo prompt and command in -c mode\n" \ |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 144 | "-C, --dryrun Check configuration for validity and exit\n" \ |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 145 | "-h, --help Display this help and exit\n\n" \ |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 146 | "Note that multiple commands may be executed from the command\n" \ |
| 147 | "line by passing multiple -c args, or by embedding linefeed\n" \ |
| 148 | "characters in one or more of the commands.\n\n" \ |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 149 | "Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); |
| 150 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 151 | exit (status); |
| 152 | } |
| 153 | |
| 154 | /* VTY shell options, we use GNU getopt library. */ |
| 155 | struct option longopts[] = |
| 156 | { |
hasso | b094d26 | 2004-08-25 12:22:00 +0000 | [diff] [blame] | 157 | { "boot", no_argument, NULL, 'b'}, |
hasso | 4991f6c | 2004-04-06 11:36:17 +0000 | [diff] [blame] | 158 | /* For compatibility with older zebra/quagga versions */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 159 | { "eval", required_argument, NULL, 'e'}, |
hasso | 4991f6c | 2004-04-06 11:36:17 +0000 | [diff] [blame] | 160 | { "command", required_argument, NULL, 'c'}, |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 161 | { "daemon", required_argument, NULL, 'd'}, |
| 162 | { "echo", no_argument, NULL, 'E'}, |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 163 | { "dryrun", no_argument, NULL, 'C'}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 164 | { "help", no_argument, NULL, 'h'}, |
Stephen Hemminger | 914131f | 2008-07-30 14:16:47 -0700 | [diff] [blame] | 165 | { "noerror", no_argument, NULL, 'n'}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 166 | { 0 } |
| 167 | }; |
hasso | b094d26 | 2004-08-25 12:22:00 +0000 | [diff] [blame] | 168 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 169 | /* Read a string, and return a pointer to it. Returns NULL on EOF. */ |
| 170 | char * |
| 171 | vtysh_rl_gets () |
| 172 | { |
hasso | 4991f6c | 2004-04-06 11:36:17 +0000 | [diff] [blame] | 173 | HIST_ENTRY *last; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 174 | /* If the buffer has already been allocated, return the memory |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 175 | * to the free pool. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 176 | if (line_read) |
| 177 | { |
| 178 | free (line_read); |
| 179 | line_read = NULL; |
| 180 | } |
| 181 | |
| 182 | /* Get a line from the user. Change prompt according to node. XXX. */ |
| 183 | line_read = readline (vtysh_prompt ()); |
| 184 | |
hasso | 4991f6c | 2004-04-06 11:36:17 +0000 | [diff] [blame] | 185 | /* If the line has any text in it, save it on the history. But only if |
hasso | 95e735b | 2004-08-26 13:08:30 +0000 | [diff] [blame] | 186 | * last command in history isn't the same one. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 187 | if (line_read && *line_read) |
hasso | 4991f6c | 2004-04-06 11:36:17 +0000 | [diff] [blame] | 188 | { |
| 189 | using_history(); |
| 190 | last = previous_history(); |
| 191 | if (!last || strcmp (last->line, line_read) != 0) |
| 192 | add_history (line_read); |
| 193 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 194 | |
| 195 | return (line_read); |
| 196 | } |
hasso | b094d26 | 2004-08-25 12:22:00 +0000 | [diff] [blame] | 197 | |
Stephen Hemminger | 57fb974 | 2008-07-28 12:19:04 -0700 | [diff] [blame] | 198 | static void log_it(const char *line) |
| 199 | { |
| 200 | time_t t = time(NULL); |
| 201 | struct tm *tmp = localtime(&t); |
| 202 | char *user = getenv("USER") ? : "boot"; |
| 203 | char tod[64]; |
| 204 | |
| 205 | strftime(tod, sizeof tod, "%Y%m%d-%H:%M.%S", tmp); |
| 206 | |
| 207 | fprintf(logfile, "%s:%s %s\n", tod, user, line); |
| 208 | } |
| 209 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 210 | /* VTY shell main routine. */ |
| 211 | int |
| 212 | main (int argc, char **argv, char **env) |
| 213 | { |
| 214 | char *p; |
| 215 | int opt; |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 216 | int dryrun = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 217 | int boot_flag = 0; |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 218 | const char *daemon_name = NULL; |
| 219 | struct cmd_rec { |
| 220 | const char *line; |
| 221 | struct cmd_rec *next; |
| 222 | } *cmd = NULL; |
| 223 | struct cmd_rec *tail = NULL; |
| 224 | int echo_command = 0; |
Stephen Hemminger | 914131f | 2008-07-30 14:16:47 -0700 | [diff] [blame] | 225 | int no_error = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 226 | |
| 227 | /* Preserve name of myself. */ |
| 228 | progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); |
| 229 | |
Stephen Hemminger | 57fb974 | 2008-07-28 12:19:04 -0700 | [diff] [blame] | 230 | /* if logging open now */ |
| 231 | if ((p = getenv("VTYSH_LOG")) != NULL) |
| 232 | logfile = fopen(p, "a"); |
| 233 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 234 | /* Option handling. */ |
| 235 | while (1) |
| 236 | { |
Stephen Hemminger | 914131f | 2008-07-30 14:16:47 -0700 | [diff] [blame] | 237 | opt = getopt_long (argc, argv, "be:c:d:nEhC", longopts, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 238 | |
| 239 | if (opt == EOF) |
| 240 | break; |
| 241 | |
| 242 | switch (opt) |
| 243 | { |
| 244 | case 0: |
| 245 | break; |
| 246 | case 'b': |
| 247 | boot_flag = 1; |
| 248 | break; |
| 249 | case 'e': |
hasso | 4991f6c | 2004-04-06 11:36:17 +0000 | [diff] [blame] | 250 | case 'c': |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 251 | { |
| 252 | struct cmd_rec *cr; |
| 253 | cr = XMALLOC(0, sizeof(*cr)); |
| 254 | cr->line = optarg; |
| 255 | cr->next = NULL; |
| 256 | if (tail) |
| 257 | tail->next = cr; |
| 258 | else |
| 259 | cmd = cr; |
| 260 | tail = cr; |
| 261 | } |
| 262 | break; |
| 263 | case 'd': |
| 264 | daemon_name = optarg; |
| 265 | break; |
Stephen Hemminger | 914131f | 2008-07-30 14:16:47 -0700 | [diff] [blame] | 266 | case 'n': |
| 267 | no_error = 1; |
| 268 | break; |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 269 | case 'E': |
| 270 | echo_command = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 271 | break; |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 272 | case 'C': |
| 273 | dryrun = 1; |
| 274 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 275 | case 'h': |
| 276 | usage (0); |
| 277 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 278 | default: |
| 279 | usage (1); |
| 280 | break; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | /* Initialize user input buffer. */ |
| 285 | line_read = NULL; |
Stephen Hemminger | 0fbd62a | 2008-05-02 09:25:02 -0700 | [diff] [blame] | 286 | setlinebuf(stdout); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 287 | |
| 288 | /* Signal and others. */ |
hasso | e42f5a3 | 2004-08-28 17:04:33 +0000 | [diff] [blame] | 289 | vtysh_signal_init (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 290 | |
| 291 | /* Make vty structure and register commands. */ |
| 292 | vtysh_init_vty (); |
| 293 | vtysh_init_cmd (); |
| 294 | vtysh_user_init (); |
| 295 | vtysh_config_init (); |
| 296 | |
| 297 | vty_init_vtysh (); |
| 298 | |
| 299 | sort_node (); |
| 300 | |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 301 | /* Read vtysh configuration file before connecting to daemons. */ |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 302 | vtysh_read_config (config_default); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 303 | |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 304 | /* Start execution only if not in dry-run mode */ |
| 305 | if(dryrun) |
| 306 | return(0); |
| 307 | |
Stephen Hemminger | 914131f | 2008-07-30 14:16:47 -0700 | [diff] [blame] | 308 | /* Ignore error messages */ |
| 309 | if (no_error) |
| 310 | freopen("/dev/null", "w", stdout); |
| 311 | |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 312 | /* Make sure we pass authentication before proceeding. */ |
| 313 | vtysh_auth (); |
| 314 | |
| 315 | /* Do not connect until we have passed authentication. */ |
| 316 | if (vtysh_connect_all (daemon_name) <= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 317 | { |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 318 | fprintf(stderr, "Exiting: failed to connect to any daemons.\n"); |
| 319 | exit(1); |
| 320 | } |
| 321 | |
| 322 | /* If eval mode. */ |
| 323 | if (cmd) |
| 324 | { |
| 325 | /* Enter into enable node. */ |
| 326 | vtysh_execute ("enable"); |
| 327 | |
| 328 | while (cmd != NULL) |
| 329 | { |
Stephen Hemminger | 57fb974 | 2008-07-28 12:19:04 -0700 | [diff] [blame] | 330 | int ret; |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 331 | char *eol; |
| 332 | |
| 333 | while ((eol = strchr(cmd->line, '\n')) != NULL) |
| 334 | { |
| 335 | *eol = '\0'; |
Stephen Hemminger | 57fb974 | 2008-07-28 12:19:04 -0700 | [diff] [blame] | 336 | |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 337 | if (echo_command) |
Stephen Hemminger | 57fb974 | 2008-07-28 12:19:04 -0700 | [diff] [blame] | 338 | printf("%s%s\n", vtysh_prompt(), cmd->line); |
| 339 | |
| 340 | if (logfile) |
| 341 | log_it(cmd->line); |
| 342 | |
| 343 | ret = vtysh_execute_no_pager(cmd->line); |
Stephen Hemminger | 914131f | 2008-07-30 14:16:47 -0700 | [diff] [blame] | 344 | if (!no_error && |
| 345 | ! (ret == CMD_SUCCESS || |
| 346 | ret == CMD_SUCCESS_DAEMON || |
| 347 | ret == CMD_WARNING)) |
Stephen Hemminger | 57fb974 | 2008-07-28 12:19:04 -0700 | [diff] [blame] | 348 | exit(1); |
| 349 | |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 350 | cmd->line = eol+1; |
| 351 | } |
Stephen Hemminger | 57fb974 | 2008-07-28 12:19:04 -0700 | [diff] [blame] | 352 | |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 353 | if (echo_command) |
| 354 | printf("%s%s\n", vtysh_prompt(), cmd->line); |
Stephen Hemminger | 57fb974 | 2008-07-28 12:19:04 -0700 | [diff] [blame] | 355 | |
| 356 | if (logfile) |
| 357 | log_it(cmd->line); |
| 358 | |
| 359 | ret = vtysh_execute_no_pager(cmd->line); |
Stephen Hemminger | 914131f | 2008-07-30 14:16:47 -0700 | [diff] [blame] | 360 | if (!no_error && |
| 361 | ! (ret == CMD_SUCCESS || |
| 362 | ret == CMD_SUCCESS_DAEMON || |
| 363 | ret == CMD_WARNING)) |
Stephen Hemminger | 57fb974 | 2008-07-28 12:19:04 -0700 | [diff] [blame] | 364 | exit(1); |
Andrew J. Schorr | f366ad3 | 2006-07-27 18:01:41 +0000 | [diff] [blame] | 365 | |
| 366 | { |
| 367 | struct cmd_rec *cr; |
| 368 | cr = cmd; |
| 369 | cmd = cmd->next; |
| 370 | XFREE(0, cr); |
| 371 | } |
| 372 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 373 | exit (0); |
| 374 | } |
| 375 | |
| 376 | /* Boot startup configuration file. */ |
| 377 | if (boot_flag) |
| 378 | { |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 379 | if (vtysh_read_config (integrate_default)) |
| 380 | { |
| 381 | fprintf (stderr, "Can't open configuration file [%s]\n", |
| 382 | integrate_default); |
| 383 | exit (1); |
| 384 | } |
| 385 | else |
| 386 | exit (0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | vtysh_pager_init (); |
| 390 | |
| 391 | vtysh_readline_init (); |
| 392 | |
| 393 | vty_hello (vty); |
| 394 | |
hasso | e7168df | 2004-10-03 20:11:32 +0000 | [diff] [blame] | 395 | /* Enter into enable node. */ |
| 396 | vtysh_execute ("enable"); |
| 397 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 398 | /* Preparation for longjmp() in sigtstp(). */ |
| 399 | sigsetjmp (jmpbuf, 1); |
| 400 | jmpflag = 1; |
| 401 | |
| 402 | /* Main command loop. */ |
| 403 | while (vtysh_rl_gets ()) |
| 404 | vtysh_execute (line_read); |
| 405 | |
| 406 | printf ("\n"); |
| 407 | |
| 408 | /* Rest in peace. */ |
| 409 | exit (0); |
| 410 | } |