From 21e948bf08fc47309f86f78f9f5225b70fb65f29 Mon Sep 17 00:00:00 2001 From: brian Date: Mon, 29 Dec 1997 22:23:13 +0000 Subject: [PATCH] Show how much time is left before timing out in the `show timeout' output. Remove ipIdleSecs variable - it's not used. --- usr.sbin/ppp/command.c | 10 ++++++++-- usr.sbin/ppp/ip.c | 17 +++++++++++++++-- usr.sbin/ppp/ip.h | 5 +++-- usr.sbin/ppp/vars.c | 5 ++--- usr.sbin/ppp/vars.h | 7 +++---- 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index dc4f9cf73af0..8d159cf66785 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.119 1997/12/27 07:22:12 brian Exp $ + * $Id: command.c,v 1.120 1997/12/27 13:45:45 brian Exp $ * */ #include @@ -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; } diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c index 0c9df16b7220..6f9a30ed4092 100644 --- a/usr.sbin/ppp/ip.c +++ b/usr.sbin/ppp/ip.c @@ -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; } } diff --git a/usr.sbin/ppp/ip.h b/usr.sbin/ppp/ip.h index 056d6555eea5..2f3d992d839b 100644 --- a/usr.sbin/ppp/ip.h +++ b/usr.sbin/ppp/ip.h @@ -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); diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c index 015e7bb0715b..494244e06bda 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.40 1997/12/13 02:37:33 brian Exp $ + * $Id: vars.c,v 1.41 1997/12/21 03:16:17 brian Exp $ * */ #include @@ -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; diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h index b9db9770b3d7..2ffa13147ed9 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.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; \ } \