mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 09:41:03 -04:00
Revive the connect-max-attempts option. When running in persist mode,
this limits the number of retries before aborting. This can save expensive phone bills. :-) See rev 1.6 of main.c for original.
This commit is contained in:
parent
d5ad8952dc
commit
65201e4a29
4 changed files with 31 additions and 5 deletions
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: main.c,v 1.13 1997/08/19 17:52:43 peter Exp $";
|
||||
static char rcsid[] = "$Id: main.c,v 1.14 1997/08/22 12:03:55 peter Exp $";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
@ -175,6 +175,7 @@ main(argc, argv)
|
|||
sigset_t mask;
|
||||
struct protent *protp;
|
||||
struct stat statbuf;
|
||||
int connect_attempts = 0;
|
||||
|
||||
phase = PHASE_INITIALIZE;
|
||||
p = ttyname(0);
|
||||
|
|
@ -472,6 +473,7 @@ main(argc, argv)
|
|||
if (device_script(connector, ttyfd, ttyfd) < 0) {
|
||||
syslog(LOG_ERR, "Connect script failed");
|
||||
setdtr(ttyfd, FALSE);
|
||||
connect_attempts++;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
@ -479,6 +481,8 @@ main(argc, argv)
|
|||
sleep(1); /* give it time to set up its terminal */
|
||||
}
|
||||
|
||||
connect_attempts = 0; /* we made it through ok */
|
||||
|
||||
/* set line speed, flow control, etc.; clear CLOCAL if modem option */
|
||||
set_up_tty(ttyfd, 0);
|
||||
|
||||
|
|
@ -487,7 +491,8 @@ main(argc, argv)
|
|||
while ((i = open(devnam, O_RDWR)) < 0) {
|
||||
if (errno != EINTR)
|
||||
syslog(LOG_ERR, "Failed to reopen %s: %m", devnam);
|
||||
if (!persist || errno != EINTR || hungup || kill_link)
|
||||
if (!persist || errno != EINTR ||
|
||||
hungup || kill_link)
|
||||
goto fail;
|
||||
}
|
||||
close(i);
|
||||
|
|
@ -602,6 +607,11 @@ main(argc, argv)
|
|||
iffilename[0] = 0;
|
||||
}
|
||||
|
||||
/* limit to retries? */
|
||||
if (max_con_attempts)
|
||||
if (connect_attempts >= max_con_attempts)
|
||||
break;
|
||||
|
||||
if (!persist)
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: options.c,v 1.14 1997/08/22 15:50:09 peter Exp $";
|
||||
static char rcsid[] = "$Id: options.c,v 1.15 1997/10/10 06:02:56 peter Exp $";
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
|
@ -90,6 +90,7 @@ int nodetach = 0; /* Don't detach from controlling tty */
|
|||
char *connector = NULL; /* Script to establish physical link */
|
||||
char *disconnector = NULL; /* Script to disestablish physical link */
|
||||
char *welcomer = NULL; /* Script to run after phys link estab. */
|
||||
int max_con_attempts = 0; /* Maximum connect tries in non-demand mode */
|
||||
int maxconnect = 0; /* Maximum connect time */
|
||||
char user[MAXNAMELEN]; /* Username for PAP */
|
||||
char passwd[MAXSECRETLEN]; /* Password for PAP */
|
||||
|
|
@ -165,6 +166,7 @@ static int nopcomp __P((char **));
|
|||
static int setconnector __P((char **));
|
||||
static int setdisconnector __P((char **));
|
||||
static int setwelcomer __P((char **));
|
||||
static int setmaxcon __P((char **));
|
||||
static int setmaxconnect __P((char **));
|
||||
static int setdomain __P((char **));
|
||||
static int setnetmask __P((char **));
|
||||
|
|
@ -303,6 +305,7 @@ static struct cmd {
|
|||
{"connect", 1, setconnector}, /* A program to set up a connection */
|
||||
{"disconnect", 1, setdisconnector}, /* program to disconnect serial dev. */
|
||||
{"welcome", 1, setwelcomer},/* Script to welcome client */
|
||||
{"connect-max-attempts", 1, setmaxcon}, /* maximum # connect attempts */
|
||||
{"maxconnect", 1, setmaxconnect}, /* specify a maximum connect time */
|
||||
{"crtscts", 0, setcrtscts}, /* set h/w flow control */
|
||||
{"nocrtscts", 0, setnocrtscts}, /* clear h/w flow control */
|
||||
|
|
@ -1531,6 +1534,13 @@ setwelcomer(argv)
|
|||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
setmaxcon(argv)
|
||||
char **argv;
|
||||
{
|
||||
return int_option(*argv, &max_con_attempts);
|
||||
}
|
||||
|
||||
/*
|
||||
* setmaxconnect - Set the maximum connect time
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
.\" manual page [] for pppd 2.3
|
||||
.\" $Id: pppd.8,v 1.14 1997/08/19 17:52:46 peter Exp $
|
||||
.\" $Id: pppd.8,v 1.15 1997/10/10 06:30:08 peter Exp $
|
||||
.\" SH section heading
|
||||
.\" SS subsection heading
|
||||
.\" LP paragraph
|
||||
|
|
@ -91,6 +91,11 @@ up the serial line. This script would typically use the chat(8)
|
|||
program to dial the modem and start the remote ppp session. This
|
||||
option is privileged if the \fInoauth\fR option is used.
|
||||
.TP
|
||||
.B connect-max-attempts \fI<n>
|
||||
Attempt dial-out connection to remote system no more than specified number
|
||||
of times (default = 1). If the connection is not made, pppd will exit.
|
||||
Requires that \fBpersist\fR has been specified.
|
||||
.TP
|
||||
.B crtscts
|
||||
Use hardware flow control (i.e. RTS/CTS) to control the flow of data
|
||||
on the serial port. If neither the \fIcrtscts\fR nor the
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: pppd.h,v 1.9 1997/08/19 17:52:46 peter Exp $
|
||||
* $Id: pppd.h,v 1.10 1997/10/10 06:02:57 peter Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
|
@ -86,6 +86,7 @@ extern int nodetach; /* Don't detach from controlling tty */
|
|||
extern char *connector; /* Script to establish physical link */
|
||||
extern char *disconnector; /* Script to disestablish physical link */
|
||||
extern char *welcomer; /* Script to welcome client after connection */
|
||||
extern int max_con_attempts;/* Maximum number of times to try dialing */
|
||||
extern int maxconnect; /* Maximum connect time (seconds) */
|
||||
extern char user[]; /* Our name for authenticating ourselves */
|
||||
extern char passwd[]; /* Password for PAP */
|
||||
|
|
|
|||
Loading…
Reference in a new issue