diff options
author | brian <brian@FreeBSD.org> | 1998-01-20 22:47:48 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1998-01-20 22:47:48 +0000 |
commit | 74431679837aec6ed3ce13103d276d7b8afd25d8 (patch) | |
tree | 288a9a13f0a93d1645e9d0b6dbff2b1e5e1c6242 /usr.sbin/ppp/fsm.c | |
parent | e5842c1bb3cac612cd53a80a3f2b9d17e9cae765 (diff) | |
download | FreeBSD-src-74431679837aec6ed3ce13103d276d7b8afd25d8.zip FreeBSD-src-74431679837aec6ed3ce13103d276d7b8afd25d8.tar.gz |
Allow an optional delay when specifying "set openmode active".
The delay defaults to 1 sec (as it always has) unless we've done
a ~p in interactive mode or we've actually detected a HDLC frame.
This is now cleanly implemented (via async timers) so that it is
possible for LCP to come up despite the delay if an LCP REQ is
received.
This will hopefully solve situations with slow servers or slirp
scenarios (where ECHO is left on the port for a second or so before
the peer enters packet mode).
Also, ~p in interactive mode no longer changes the value of the default
openmode delay and -dedicated mode enters packet mode in the right state
according to the value of openmode.
Diffstat (limited to 'usr.sbin/ppp/fsm.c')
-rw-r--r-- | usr.sbin/ppp/fsm.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index 1dd5bef..a3a50d2 100644 --- a/usr.sbin/ppp/fsm.c +++ b/usr.sbin/ppp/fsm.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.c,v 1.25 1997/12/24 09:28:58 brian Exp $ + * $Id: fsm.c,v 1.26 1998/01/10 01:55:09 brian Exp $ * * TODO: * o Refer loglevel for log output @@ -68,6 +68,11 @@ StoppedTimeout(void *v) struct fsm *fp = (struct fsm *)v; LogPrintf(fp->LogLevel, "Stopped timer expired\n"); + if (fp->OpenTimer.state == TIMER_RUNNING) { + LogPrintf(LogWARN, "%s: aborting open delay due to stopped timer\n", + fp->name); + StopTimer(&fp->OpenTimer); + } if (modem != -1) DownConnection(); else @@ -122,6 +127,19 @@ FsmOutput(struct fsm * fp, u_int code, u_int id, u_char * ptr, int count) HdlcOutput(PRI_LINK, fp->proto, bp); } +static void +FsmOpenNow(void *v) +{ + struct fsm *fp = (struct fsm *)v; + + StopTimer(&fp->OpenTimer); + if (fp->state <= ST_STOPPED) { + FsmInitRestartCounter(fp); + FsmSendConfigReq(fp); + NewState(fp, ST_REQSENT); + } +} + void FsmOpen(struct fsm * fp) { @@ -135,11 +153,18 @@ FsmOpen(struct fsm * fp) case ST_CLOSED: if (fp->open_mode == OPEN_PASSIVE) { NewState(fp, ST_STOPPED); - } else { - FsmInitRestartCounter(fp); - FsmSendConfigReq(fp); - NewState(fp, ST_REQSENT); - } + } else if (fp->open_mode > 0) { + if (fp->open_mode > 1) + LogPrintf(LogPHASE, "Entering STOPPED state for %d seconds\n", + fp->open_mode); + NewState(fp, ST_STOPPED); + fp->OpenTimer.state = TIMER_STOPPED; + fp->OpenTimer.load = fp->open_mode * SECTICKS; + fp->OpenTimer.func = FsmOpenNow; + fp->OpenTimer.arg = (void *)fp; + StartTimer(&fp->OpenTimer); + } else + FsmOpenNow(fp); break; case ST_STOPPED: /* XXX: restart option */ case ST_REQSENT: |