From: Paul Mackerras Date: Thu, 12 Aug 1999 04:17:07 +0000 (+0000) Subject: add maxfail option to control the max # of failed attempts X-Git-Tag: ppp-2.4.7~670 X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=ee0fba791a4db3588ec086b43ff982bf14265301 add maxfail option to control the max # of failed attempts --- diff --git a/pppd/main.c b/pppd/main.c index a33a5e2..4acc217 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: main.c,v 1.80 1999/07/21 00:24:31 paulus Exp $"; +static const char rcsid[] = "$Id: main.c,v 1.81 1999/08/12 04:17:07 paulus Exp $"; #endif #include @@ -87,6 +87,7 @@ struct stat devstat; /* result of stat() on devnam */ int prepass = 0; /* doing prepass to find device name */ int devnam_fixed; /* set while in options.ttyxx file */ volatile int status; /* exit status for pppd */ +int unsuccess; /* # unsuccessful connection attempts */ static int fd_ppp = -1; /* fd for talking PPP */ static int fd_loop; /* fd for getting demand-dial packets */ @@ -498,6 +499,7 @@ main(argc, argv) ttyfd = -1; real_ttyfd = -1; status = EXIT_OK; + ++unsuccess; if (demand) { /* @@ -856,7 +858,7 @@ main(argc, argv) pidfilename[0] = 0; } - if (!persist) + if (!persist || (maxfail > 0 && unsuccess >= maxfail)) break; kill_link = 0; diff --git a/pppd/options.c b/pppd/options.c index 5d14416..59c7b5b 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: options.c,v 1.60 1999/07/21 00:24:31 paulus Exp $"; +static const char rcsid[] = "$Id: options.c,v 1.61 1999/08/12 04:17:07 paulus Exp $"; #endif #include @@ -93,6 +93,7 @@ char *record_file = NULL; /* File to record chars sent/received */ int using_pty = 0; bool sync_serial = 0; /* Device is synchronous serial device */ int log_to_fd = 1; /* send log messages to this fd too */ +int maxfail; /* max # of unsuccessful connection attempts */ extern option_t auth_options[]; extern struct stat devstat; @@ -239,6 +240,8 @@ option_t general_options[] = { { "nologfd", o_int, &log_to_fd, "Don't send log messages to any file descriptor", OPT_NOARG | OPT_VAL(-1) }, + { "maxfail", o_int, &maxfail, + "Maximum number of unsuccessful connection attempts to allow" }, #ifdef PPP_FILTER { "pdebug", o_int, &dflag,