Show how much time is left before timing out in the

`show timeout' output.
Remove ipIdleSecs variable - it's not used.
This commit is contained in:
brian 1997-12-29 22:23:13 +00:00
parent b05332bc2c
commit 21e948bf08
5 changed files with 31 additions and 13 deletions

View File

@ -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.119 1997/12/27 07:22:12 brian Exp $
* $Id: command.c,v 1.120 1997/12/27 13:45:45 brian Exp $
*
*/
#include <sys/param.h>
@ -444,10 +444,16 @@ ShowEscape(struct cmdargs const *arg)
static int
ShowTimeout(struct cmdargs const *arg)
{
if (VarTerm)
if (VarTerm) {
int remaining;
fprintf(VarTerm, " Idle Timer: %d secs LQR Timer: %d secs"
" Retry Timer: %d secs\n", VarIdleTimeout, VarLqrTimeout,
VarRetryTimeout);
remaining = RemainingIdleTime();
if (remaining != -1)
fprintf(VarTerm, " %d secs remaining\n", remaining);
}
return 0;
}

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ip.c,v 1.33 1997/12/24 09:29:01 brian Exp $
* $Id: ip.c,v 1.34 1997/12/28 02:46:22 brian Exp $
*
* TODO:
* o Return ICMP message for filterd packet
@ -86,11 +86,15 @@ IdleTimeout(void *v)
void
StartIdleTimer()
{
static time_t IdleStarted;
if (!(mode & (MODE_DEDICATED | MODE_DDIAL))) {
StopTimer(&IdleTimer);
IdleTimer.func = IdleTimeout;
IdleTimer.load = VarIdleTimeout * SECTICKS;
IdleTimer.state = TIMER_STOPPED;
time(&IdleStarted);
IdleTimer.arg = (void *)&IdleStarted;
StartTimer(&IdleTimer);
}
}
@ -108,6 +112,15 @@ StopIdleTimer()
StopTimer(&IdleTimer);
}
int
RemainingIdleTime()
{
if (VarIdleTimeout == 0 || IdleTimer.state != TIMER_RUNNING ||
IdleTimer.arg == NULL)
return -1;
return VarIdleTimeout - (time(NULL) - *(time_t *)IdleTimer.arg);
}
/*
* If any IP layer traffic is detected, refresh IdleTimer.
*/
@ -115,8 +128,8 @@ static void
RestartIdleTimer(void)
{
if (!(mode & (MODE_DEDICATED | MODE_DDIAL)) && ipKeepAlive) {
time((time_t *)IdleTimer.arg);
StartTimer(&IdleTimer);
ipIdleSecs = 0;
}
}

View File

@ -17,14 +17,15 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ip.h,v 1.6 1997/10/26 01:02:53 brian Exp $
* $Id: ip.h,v 1.7 1997/10/26 12:42:11 brian Exp $
*
*/
extern void IpStartOutput(void);
extern int PacketCheck(char *, int, int);
extern int PacketCheck(char *, int, int);
extern void IpEnqueue(int, char *, int);
extern void IpInput(struct mbuf *);
extern void StartIdleTimer(void);
extern void StopIdleTimer(void);
extern void UpdateIdleTimer(void);
extern int RemainingIdleTime(void);

View File

@ -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.40 1997/12/13 02:37:33 brian Exp $
* $Id: vars.c,v 1.41 1997/12/21 03:16:17 brian Exp $
*
*/
#include <sys/param.h>
@ -39,13 +39,12 @@
#include "auth.h"
char VarVersion[] = "PPP Version 1.6";
char VarLocalVersion[] = "$Date: 1997/12/13 02:37:33 $";
char VarLocalVersion[] = "$Date: 1997/12/21 03:16:17 $";
int Utmp = 0;
int ipInOctets = 0;
int ipOutOctets = 0;
int ipKeepAlive = 0;
int ipConnectSecs = 0;
int ipIdleSecs = 0;
int reconnectState = RECON_UNKNOWN;
int reconnectCount = 0;

View File

@ -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.37 1997/12/03 23:28:02 brian Exp $
* $Id: vars.h,v 1.38 1997/12/21 03:16:19 brian Exp $
*
* TODO:
*/
@ -160,7 +160,6 @@ extern int ipInOctets;
extern int ipOutOctets;
extern int ipKeepAlive;
extern int ipConnectSecs;
extern int ipIdleSecs;
extern int reconnectState;
extern int reconnectCount;
@ -170,8 +169,8 @@ extern int reconnectCount;
#define RECON_ENVOKED (4)
#define reconnect(x) \
do \
if (reconnectState == RECON_UNKNOWN) { \
reconnectState = x; \
if (reconnectState == RECON_UNKNOWN) { \
reconnectState = x; \
if (x == RECON_FALSE) \
reconnectCount = 0; \
} \