diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 8ddedf08054d..0c813dcd5d6e 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.131.2.17 1998/02/15 23:59:49 brian Exp $ + * $Id: command.c,v 1.131.2.18 1998/02/16 19:09:44 brian Exp $ * */ #include @@ -513,8 +513,10 @@ ShowPreferredMTU(struct cmdargs const *arg) static int ShowReconnect(struct cmdargs const *arg) { - prompt_Printf(&prompt, " Reconnect Timer: %d, %d tries\n", - VarReconnectTimer, VarReconnectTries); + struct datalink *dl = bundle2datalink(arg->bundle, NULL); + + prompt_Printf(&prompt, "%s: Reconnect Timer: %d, %d tries\n", + dl->name, dl->reconnect_timeout, dl->max_reconnect); return 0; } @@ -854,8 +856,10 @@ static int SetReconnect(struct cmdargs const *arg) { if (arg->argc == 2) { - VarReconnectTimer = atoi(arg->argv[0]); - VarReconnectTries = atoi(arg->argv[1]); + struct datalink *dl = bundle2datalink(arg->bundle, NULL); + + dl->reconnect_timeout = atoi(arg->argv[0]); + dl->max_reconnect = (mode & MODE_DIRECT) ? 0 : atoi(arg->argv[1]); return 0; } return -1; @@ -1274,10 +1278,10 @@ SetNBNS(struct cmdargs const *arg) int SetVariable(struct cmdargs const *arg) { + struct datalink *dl = bundle2datalink(arg->bundle, NULL); u_long map; const char *argp; int param = (int)arg->data; - struct datalink *dl = bundle2datalink(arg->bundle, NULL); if (arg->argc > 0) argp = *arg->argv; diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c index 2e074bb7b9fd..9310944af8ac 100644 --- a/usr.sbin/ppp/datalink.c +++ b/usr.sbin/ppp/datalink.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: datalink.c,v 1.1.2.2 1998/02/16 00:18:52 brian Exp $ + * $Id: datalink.c,v 1.1.2.3 1998/02/16 19:09:48 brian Exp $ */ #include @@ -98,16 +98,23 @@ datalink_HangupDone(struct datalink *dl) dl->state = DATALINK_CLOSED; dl->dial_tries = -1; dl->reconnect_tries = 0; + datalink_StartDialTimer(dl, VarRedialTimeout); bundle_LinkClosed(dl->bundle, dl); } else { LogPrintf(LogPHASE, "%s: Entering OPENING state\n", dl->name); dl->state = DATALINK_OPENING; + if (dl->dial_tries < 0) { + datalink_StartDialTimer(dl, dl->reconnect_timeout); + dl->dial_tries = VarDialTries; + dl->reconnect_tries--; + } else { + dl->dial_tries--; + if (VarNextPhone == NULL) + datalink_StartDialTimer(dl, VarRedialTimeout); + else + datalink_StartDialTimer(dl, VarRedialNextTimeout); + } } - - if (VarNextPhone == NULL) - datalink_StartDialTimer(dl, VarRedialTimeout); - else - datalink_StartDialTimer(dl, VarRedialNextTimeout); } static int @@ -291,6 +298,10 @@ datalink_Create(const char *name, struct bundle *bundle) dl->next = NULL; memset(&dl->dial_timer, '\0', sizeof dl->dial_timer); dl->dial_tries = 0; + dl->max_reconnect = 0; + dl->reconnect_tries = 0; + dl->reconnect_timeout = RECONNECT_TIMEOUT; + dl->name = strdup(name); if ((dl->physical = modem_Create(dl->name)) == NULL) { free(dl->name); @@ -330,7 +341,7 @@ datalink_Up(struct datalink *dl) if (dl->state == DATALINK_CLOSED) { LogPrintf(LogPHASE, "%s: Entering OPENING state\n", dl->name); dl->state = DATALINK_OPENING; - dl->reconnect_tries = (mode & MODE_DIRECT) ? 0 : VarReconnectTries; + dl->reconnect_tries = dl->max_reconnect; dl->dial_tries = VarDialTries; } } diff --git a/usr.sbin/ppp/datalink.h b/usr.sbin/ppp/datalink.h index 2bdaa407e3a1..d5ba109976e2 100644 --- a/usr.sbin/ppp/datalink.h +++ b/usr.sbin/ppp/datalink.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: datalink.h,v 1.1.2.1 1998/02/16 00:00:01 brian Exp $ + * $Id: datalink.h,v 1.1.2.2 1998/02/16 19:09:51 brian Exp $ */ #define DATALINK_CLOSED (0) @@ -47,7 +47,10 @@ struct datalink { struct pppTimer dial_timer; /* For timing between opens & scripts */ int dial_tries; /* try again this number of times */ - unsigned reconnect_tries; /* try again this number of times */ + int max_reconnect; /* initially try again this number of times */ + unsigned reconnect_tries; /* currently try again this number of times */ + int reconnect_timeout; /* Timeout before reconnect on carrier loss */ + char *name; /* Our name */ diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h index cfe1e1e40318..7aaf3915da1c 100644 --- a/usr.sbin/ppp/defs.h +++ b/usr.sbin/ppp/defs.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: defs.h,v 1.29 1997/12/27 13:45:48 brian Exp $ + * $Id: defs.h,v 1.29.2.1 1998/01/29 00:49:16 brian Exp $ * * TODO: */ @@ -39,8 +39,7 @@ #define MODEM_SPEED B38400 /* tty speed */ #define SERVER_PORT 3000 /* Base server port no. */ #define MODEM_CTSRTS 1 /* Default (true): use CTS/RTS signals */ -#define RECONNECT_TIMER 3 /* Default timer for carrier loss */ -#define RECONNECT_TRIES 0 /* Default retries on carrier loss */ +#define RECONNECT_TIMEOUT 3 /* Default timer for carrier loss */ #define REDIAL_PERIOD 30 /* Default Hold time to redial */ #define NEXT_REDIAL_PERIOD 3 /* Default Hold time to next number redial */ #define SCRIPT_LEN 512 /* Size of login scripts */ diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c index 60dcccef4ea0..102b01a806d3 100644 --- a/usr.sbin/ppp/vars.c +++ b/usr.sbin/ppp/vars.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vars.c,v 1.45.2.7 1998/02/13 05:10:26 brian Exp $ + * $Id: vars.c,v 1.45.2.8 1998/02/16 00:01:08 brian Exp $ * */ #include @@ -46,7 +46,7 @@ #include "prompt.h" char VarVersion[] = "PPP Version 2.0-beta"; -char VarLocalVersion[] = "$Date: 1998/02/13 05:10:26 $"; +char VarLocalVersion[] = "$Date: 1998/02/16 00:01:08 $"; int Utmp = 0; int ipKeepAlive = 0; @@ -73,8 +73,7 @@ struct confdesc pppConfs[] = { struct pppvars pppVars = { DEF_MRU, DEF_MTU, 0, MODEM_SPEED, CS8, MODEM_CTSRTS, 180, 30, 3, - RECONNECT_TIMER, RECONNECT_TRIES, REDIAL_PERIOD, - NEXT_REDIAL_PERIOD, 1, 1, MODEM_DEV, "", BASE_MODEM_DEV, + REDIAL_PERIOD, NEXT_REDIAL_PERIOD, 1, 1, MODEM_DEV, "", BASE_MODEM_DEV, 1, LOCAL_NO_AUTH }; diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h index 7ad875d07183..4a74d543c264 100644 --- a/usr.sbin/ppp/vars.h +++ b/usr.sbin/ppp/vars.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vars.h,v 1.42.2.4 1998/02/16 00:01:12 brian Exp $ + * $Id: vars.h,v 1.42.2.5 1998/02/16 19:10:03 brian Exp $ * * TODO: */ @@ -64,8 +64,6 @@ struct pppvars { int idle_timeout; /* Idle timeout value */ int lqr_timeout; /* LQR timeout value */ int retry_timeout; /* Retry timeout value */ - int reconnect_timer; /* Timeout before reconnect on carrier loss */ - int reconnect_tries; /* Attempt reconnect on carrier loss */ int redial_timeout; /* Redial timeout value */ int redial_next_timeout; /* Redial next timeout value */ int dial_tries; /* Dial attempts before giving up, 0 == inf */ @@ -125,8 +123,6 @@ struct pppvars { #define VarNextPhone pppVars.next_phone #define VarAltPhone pppVars.alt_phone #define VarShortHost pppVars.shostname -#define VarReconnectTimer pppVars.reconnect_timer -#define VarReconnectTries pppVars.reconnect_tries #define VarRedialTimeout pppVars.redial_timeout #define VarRedialNextTimeout pppVars.redial_next_timeout #define VarDialTries pppVars.dial_tries @@ -153,47 +149,6 @@ extern char VarLocalVersion[]; extern int Utmp; /* Are we in /etc/utmp ? */ extern int ipKeepAlive; -#if 0 -extern int reconnectState; -extern int reconnectCount; - -#define RECON_TRUE (1) -#define RECON_FALSE (2) -#define RECON_UNKNOWN (3) -#define RECON_ENVOKED (4) -#define reconnect(x) \ - do \ - if (reconnectState == RECON_UNKNOWN) { \ - reconnectState = x; \ - if (x == RECON_FALSE) \ - reconnectCount = 0; \ - } \ - while(0) - - -/* - * This is the logic behind the reconnect variables: - * We have four reconnect "states". We start off not requiring anything - * from the reconnect code (reconnectState == RECON_UNKNOWN). If the - * line is brought down (via LcpClose() or LcpDown()), we have to decide - * whether to set to RECON_TRUE or RECON_FALSE. It's only here that we - * know the correct action. Once we've decided, we don't want that - * decision to be overridden (hence the above reconnect() macro) - If we - * call LcpClose, the ModemTimeout() still gets to "notice" that the line - * is down. When it "notice"s, it should only set RECON_TRUE if a decision - * hasn't already been made. - * - * In main.c, when we notice we have RECON_TRUE, we must only action - * it once. The fourth "state" is where we're bringing the line up, - * but if we call LcpClose for any reason (failed PAP/CHAP etc) we - * don't want to set to RECON_{TRUE,FALSE}. - * - * If we get a connection or give up dialing, we go back to RECON_UNKNOWN. - * If we get give up dialing or reconnecting or if we chose to down the - * connection, we set reconnectCount back to zero. - * - */ -#endif extern int EnableCommand(struct cmdargs const *); extern int DisableCommand(struct cmdargs const *);