diff options
author | brian <brian@FreeBSD.org> | 1997-08-17 20:45:50 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-08-17 20:45:50 +0000 |
commit | 48abae6115c5ac6fba0407b546d3c6e31e7f4192 (patch) | |
tree | bfaa38bde7ce619383c5ebf2b70cf87cca128280 /usr.sbin/ppp/fsm.c | |
parent | 6f340c20e5d94d59afcee4b5d8fbc86d25acd2dd (diff) | |
download | FreeBSD-src-48abae6115c5ac6fba0407b546d3c6e31e7f4192.zip FreeBSD-src-48abae6115c5ac6fba0407b546d3c6e31e7f4192.tar.gz |
Allow the use of a "stopped" timeout via the
"set stopped" directive. If the timeout occurs
it will cause a "Down" event, hanging up the line
if it's still up. This *isn't* part of the FSM
diagram, but I consider it ok as a "higher level
implementation specific timeout" as specified in
the rfc ;-}
Discussed briefly with: joerg
Diffstat (limited to 'usr.sbin/ppp/fsm.c')
-rw-r--r-- | usr.sbin/ppp/fsm.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index ec1b2b7..a881c46 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.12 1997/06/02 00:04:40 brian Exp $ + * $Id: fsm.c,v 1.13 1997/06/09 03:27:21 brian Exp $ * * TODO: * o Refer loglevel for log output @@ -29,6 +29,9 @@ #include "lcpproto.h" #include "lcp.h" #include "ccp.h" +#include "modem.h" +#include "loadalias.h" +#include "vars.h" void FsmSendConfigReq(struct fsm *fp); void FsmSendTerminateReq(struct fsm *fp); @@ -40,6 +43,29 @@ char const *StateNames[] = { "Req-Sent", "Ack-Rcvd", "Ack-Sent", "Opened", }; +/* + * This timer times the ST_STOPPED state out after the given value + * (specified via "set stopped ..."). Although this isn't + * specified in the rfc, the rfc *does* say that "the application + * may use higher level timers to avoid deadlock". + * The StoppedTimer takes effect when the other side ABENDs rather + * than going into ST_ACKSENT (and sending the ACK), causing ppp to + * time out and drop into ST_STOPPED. At this point, nothing will + * change this state :-( + */ +struct pppTimer StoppedTimer; + +static void +StoppedTimeout(fp) +struct fsm *fp; +{ + LogPrintf(LogLCP, "Stopped timer expired\n"); + if (modem != -1) + DownConnection(); + else + FsmDown(fp); +} + void FsmInit(fp) struct fsm *fp; @@ -58,9 +84,19 @@ int new; { LogPrintf(LogLCP, "State change %s --> %s\n", StateNames[fp->state], StateNames[new]); + if (fp->state == ST_STOPPED && StoppedTimer.state == TIMER_RUNNING) + StopTimer(&StoppedTimer); fp->state = new; - if ((new >= ST_INITIAL && new <= ST_STOPPED) || (new == ST_OPENED)) + if ((new >= ST_INITIAL && new <= ST_STOPPED) || (new == ST_OPENED)) { StopTimer(&fp->FsmTimer); + if (new == ST_STOPPED && VarStoppedTimeout) { + StoppedTimer.state = TIMER_STOPPED; + StoppedTimer.func = StoppedTimeout; + StoppedTimer.arg = (void *)fp; + StoppedTimer.load = VarStoppedTimeout * SECTICKS; + StartTimer(&StoppedTimer); + } + } } void |