summaryrefslogtreecommitdiff
path: root/usr.sbin/ppp/ip.c
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>1997-12-29 22:23:10 +0000
committerbrian <brian@cvs.openbsd.org>1997-12-29 22:23:10 +0000
commit616e3392f75cac20765939a1807a283aaae71608 (patch)
tree9dae5b27789df98d713a1d8253fcfebad7bf3923 /usr.sbin/ppp/ip.c
parentc061429ad5940d86fb941daf4b4a36e42a7d9549 (diff)
Show how much time is left before timing out in the
`show timeout' output. Remove ipIdleSecs variable - it's not used.
Diffstat (limited to 'usr.sbin/ppp/ip.c')
-rw-r--r--usr.sbin/ppp/ip.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c
index b2403fab5ed..fc0dcfcc48c 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.3 1997/12/28 02:46:57 brian Exp $
+ * $Id: ip.c,v 1.4 1997/12/29 22:23:06 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;
}
}