Move the reconnect timeout and max tries into struct datalink.
This commit is contained in:
parent
5b8b8060c1
commit
abff9bae14
@ -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 <sys/param.h>
|
||||
@ -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;
|
||||
|
@ -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 <sys/param.h>
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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 <sys/param.h>
|
||||
@ -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
|
||||
};
|
||||
|
||||
|
@ -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 *);
|
||||
|
Loading…
Reference in New Issue
Block a user