1995-01-31 06:29:58 +00:00
|
|
|
/*
|
|
|
|
* PPP Finite State Machine for LCP/IPCP
|
|
|
|
*
|
|
|
|
* Written by Toshiharu OHNO (tony-o@iij.ad.jp)
|
|
|
|
*
|
|
|
|
* Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
* provided that the above copyright notice and this paragraph are
|
|
|
|
* duplicated in all such forms and that any documentation,
|
|
|
|
* advertising materials, and other materials related to such
|
|
|
|
* distribution and use acknowledge that the software was developed
|
|
|
|
* by the Internet Initiative Japan, Inc. The name of the
|
|
|
|
* IIJ may not be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1998-09-04 18:26:00 +00:00
|
|
|
* $Id: fsm.c,v 1.36 1998/08/01 01:02:41 brian Exp $
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1995-01-31 06:29:58 +00:00
|
|
|
* TODO:
|
|
|
|
*/
|
1998-04-16 00:26:21 +00:00
|
|
|
|
1998-04-07 00:54:26 +00:00
|
|
|
#include <sys/types.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <netinet/in.h>
|
1998-04-16 00:26:21 +00:00
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/ip.h>
|
1998-04-28 01:25:46 +00:00
|
|
|
#include <sys/un.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <termios.h>
|
|
|
|
|
1998-09-04 18:26:00 +00:00
|
|
|
#include "ua.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "mbuf.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "defs.h"
|
|
|
|
#include "timer.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "fsm.h"
|
1998-04-16 00:26:21 +00:00
|
|
|
#include "iplist.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "lqr.h"
|
1998-03-13 00:44:26 +00:00
|
|
|
#include "hdlc.h"
|
1998-04-16 00:26:21 +00:00
|
|
|
#include "throughput.h"
|
|
|
|
#include "slcompress.h"
|
|
|
|
#include "ipcp.h"
|
|
|
|
#include "filter.h"
|
|
|
|
#include "descriptor.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "lcp.h"
|
1996-01-11 17:48:59 +00:00
|
|
|
#include "ccp.h"
|
1998-01-30 19:46:07 +00:00
|
|
|
#include "link.h"
|
1998-04-16 00:26:21 +00:00
|
|
|
#include "mp.h"
|
|
|
|
#include "bundle.h"
|
|
|
|
#include "async.h"
|
1998-01-29 00:49:32 +00:00
|
|
|
#include "physical.h"
|
1998-04-16 00:26:21 +00:00
|
|
|
#include "lcpproto.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
|
|
|
|
static void FsmSendConfigReq(struct fsm *);
|
|
|
|
static void FsmSendTerminateReq(struct fsm *);
|
|
|
|
static void FsmInitRestartCounter(struct fsm *);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-03-20 19:47:10 +00:00
|
|
|
typedef void (recvfn)(struct fsm *, struct fsmheader *, struct mbuf *);
|
|
|
|
static recvfn FsmRecvConfigReq, FsmRecvConfigAck, FsmRecvConfigNak,
|
|
|
|
FsmRecvConfigRej, FsmRecvTermReq, FsmRecvTermAck,
|
|
|
|
FsmRecvCodeRej, FsmRecvProtoRej, FsmRecvEchoReq,
|
|
|
|
FsmRecvEchoRep, FsmRecvDiscReq, FsmRecvIdent,
|
|
|
|
FsmRecvTimeRemain, FsmRecvResetReq, FsmRecvResetAck;
|
|
|
|
|
|
|
|
static const struct fsmcodedesc {
|
|
|
|
recvfn *recv;
|
|
|
|
unsigned check_reqid : 1;
|
|
|
|
unsigned inc_reqid : 1;
|
|
|
|
const char *name;
|
|
|
|
} FsmCodes[] = {
|
|
|
|
{ FsmRecvConfigReq, 0, 0, "ConfigReq" },
|
|
|
|
{ FsmRecvConfigAck, 1, 1, "ConfigAck" },
|
|
|
|
{ FsmRecvConfigNak, 1, 1, "ConfigNak" },
|
|
|
|
{ FsmRecvConfigRej, 1, 1, "ConfigRej" },
|
|
|
|
{ FsmRecvTermReq, 0, 0, "TerminateReq" },
|
|
|
|
{ FsmRecvTermAck, 1, 1, "TerminateAck" },
|
|
|
|
{ FsmRecvCodeRej, 0, 0, "CodeRej" },
|
|
|
|
{ FsmRecvProtoRej, 0, 0, "ProtocolRej" },
|
|
|
|
{ FsmRecvEchoReq, 0, 0, "EchoRequest" },
|
|
|
|
{ FsmRecvEchoRep, 0, 0, "EchoReply" },
|
|
|
|
{ FsmRecvDiscReq, 0, 0, "DiscardReq" },
|
|
|
|
{ FsmRecvIdent, 0, 0, "Ident" },
|
|
|
|
{ FsmRecvTimeRemain,0, 0, "TimeRemain" },
|
|
|
|
{ FsmRecvResetReq, 0, 0, "ResetReqt" },
|
|
|
|
{ FsmRecvResetAck, 0, 1, "ResetAck" }
|
1995-01-31 06:29:58 +00:00
|
|
|
};
|
|
|
|
|
1998-03-20 19:47:10 +00:00
|
|
|
static const char *
|
|
|
|
Code2Nam(u_int code)
|
|
|
|
{
|
|
|
|
if (code == 0 || code > sizeof FsmCodes / sizeof FsmCodes[0])
|
|
|
|
return "Unknown";
|
|
|
|
return FsmCodes[code-1].name;
|
|
|
|
}
|
|
|
|
|
1998-03-24 18:47:32 +00:00
|
|
|
const char *
|
|
|
|
State2Nam(u_int state)
|
|
|
|
{
|
|
|
|
static const char *StateNames[] = {
|
|
|
|
"Initial", "Starting", "Closed", "Stopped", "Closing", "Stopping",
|
|
|
|
"Req-Sent", "Ack-Rcvd", "Ack-Sent", "Opened",
|
|
|
|
};
|
|
|
|
|
|
|
|
if (state >= sizeof StateNames / sizeof StateNames[0])
|
|
|
|
return "unknown";
|
|
|
|
return StateNames[state];
|
|
|
|
}
|
|
|
|
|
1997-08-17 20:45:50 +00:00
|
|
|
static void
|
1997-11-22 03:37:54 +00:00
|
|
|
StoppedTimeout(void *v)
|
1997-08-17 20:45:50 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
struct fsm *fp = (struct fsm *)v;
|
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: Stopped timer expired\n", fp->link->name);
|
1998-01-20 22:47:48 +00:00
|
|
|
if (fp->OpenTimer.state == TIMER_RUNNING) {
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogWARN, "%s: %s: aborting open delay due to stopped timer\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, fp->name);
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&fp->OpenTimer);
|
1998-01-29 00:44:16 +00:00
|
|
|
}
|
1998-06-20 00:19:42 +00:00
|
|
|
if (fp->state == ST_STOPPED)
|
|
|
|
fsm2initial(fp);
|
1997-08-17 20:45:50 +00:00
|
|
|
}
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
void
|
1998-04-03 19:21:56 +00:00
|
|
|
fsm_Init(struct fsm *fp, const char *name, u_short proto, int mincode,
|
|
|
|
int maxcode, int maxcfg, int LogLevel, struct bundle *bundle,
|
|
|
|
struct link *l, const struct fsm_parent *parent,
|
|
|
|
struct fsm_callbacks *fn, const char *timer_names[3])
|
1998-01-29 00:44:16 +00:00
|
|
|
{
|
1998-02-21 01:45:26 +00:00
|
|
|
fp->name = name;
|
|
|
|
fp->proto = proto;
|
1998-04-03 19:21:56 +00:00
|
|
|
fp->min_code = mincode;
|
1998-02-21 01:45:26 +00:00
|
|
|
fp->max_code = maxcode;
|
1998-04-03 19:21:56 +00:00
|
|
|
fp->state = fp->min_code > CODE_TERMACK ? ST_OPENED : ST_INITIAL;
|
1995-01-31 06:29:58 +00:00
|
|
|
fp->reqid = 1;
|
|
|
|
fp->restart = 1;
|
1998-02-21 01:45:26 +00:00
|
|
|
fp->maxconfig = maxcfg;
|
|
|
|
memset(&fp->FsmTimer, '\0', sizeof fp->FsmTimer);
|
|
|
|
memset(&fp->OpenTimer, '\0', sizeof fp->OpenTimer);
|
|
|
|
memset(&fp->StoppedTimer, '\0', sizeof fp->StoppedTimer);
|
|
|
|
fp->LogLevel = LogLevel;
|
1998-01-30 19:46:07 +00:00
|
|
|
fp->link = l;
|
1998-02-02 19:32:16 +00:00
|
|
|
fp->bundle = bundle;
|
1998-02-27 01:22:39 +00:00
|
|
|
fp->parent = parent;
|
1998-02-21 01:45:26 +00:00
|
|
|
fp->fn = fn;
|
1998-04-03 19:21:56 +00:00
|
|
|
fp->FsmTimer.name = timer_names[0];
|
|
|
|
fp->OpenTimer.name = timer_names[1];
|
|
|
|
fp->StoppedTimer.name = timer_names[2];
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
NewState(struct fsm * fp, int new)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: State change %s --> %s\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, State2Nam(fp->state), State2Nam(new));
|
1997-08-20 23:47:53 +00:00
|
|
|
if (fp->state == ST_STOPPED && fp->StoppedTimer.state == TIMER_RUNNING)
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&fp->StoppedTimer);
|
1995-01-31 06:29:58 +00:00
|
|
|
fp->state = new;
|
1997-08-17 20:45:50 +00:00
|
|
|
if ((new >= ST_INITIAL && new <= ST_STOPPED) || (new == ST_OPENED)) {
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&fp->FsmTimer);
|
1997-08-20 23:47:53 +00:00
|
|
|
if (new == ST_STOPPED && fp->StoppedTimer.load) {
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&fp->StoppedTimer);
|
1997-08-20 23:47:53 +00:00
|
|
|
fp->StoppedTimer.func = StoppedTimeout;
|
1997-08-25 00:29:32 +00:00
|
|
|
fp->StoppedTimer.arg = (void *) fp;
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Start(&fp->StoppedTimer);
|
1997-08-17 20:45:50 +00:00
|
|
|
}
|
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Output(struct fsm *fp, u_int code, u_int id, u_char *ptr, int count)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
int plen;
|
|
|
|
struct fsmheader lh;
|
|
|
|
struct mbuf *bp;
|
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
if (log_IsKept(fp->LogLevel)) {
|
|
|
|
log_Printf(fp->LogLevel, "%s: Send%s(%d) state = %s\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, Code2Nam(code), id, State2Nam(fp->state));
|
1998-03-20 19:47:10 +00:00
|
|
|
switch (code) {
|
|
|
|
case CODE_CONFIGREQ:
|
|
|
|
case CODE_CONFIGACK:
|
|
|
|
case CODE_CONFIGREJ:
|
|
|
|
case CODE_CONFIGNAK:
|
|
|
|
(*fp->fn->DecodeConfig)(fp, ptr, count, MODE_NOP, NULL);
|
|
|
|
if (count < sizeof(struct fsmconfig))
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, " [EMPTY]\n");
|
1998-03-20 19:47:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-08-25 00:29:32 +00:00
|
|
|
plen = sizeof(struct fsmheader) + count;
|
1995-01-31 06:29:58 +00:00
|
|
|
lh.code = code;
|
|
|
|
lh.id = id;
|
|
|
|
lh.length = htons(plen);
|
1998-05-01 19:26:12 +00:00
|
|
|
bp = mbuf_Alloc(plen, MB_FSM);
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader));
|
1995-01-31 06:29:58 +00:00
|
|
|
if (count)
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(MBUF_CTOP(bp) + sizeof(struct fsmheader), ptr, count);
|
1998-05-01 19:26:12 +00:00
|
|
|
log_DumpBp(LogDEBUG, "fsm_Output", bp);
|
|
|
|
hdlc_Output(fp->link, PRI_LINK, fp->proto, bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1998-01-20 22:47:48 +00:00
|
|
|
static void
|
|
|
|
FsmOpenNow(void *v)
|
|
|
|
{
|
|
|
|
struct fsm *fp = (struct fsm *)v;
|
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&fp->OpenTimer);
|
1998-01-20 22:47:48 +00:00
|
|
|
if (fp->state <= ST_STOPPED) {
|
1998-06-27 23:48:54 +00:00
|
|
|
if (fp->state != ST_STARTING) {
|
|
|
|
/*
|
|
|
|
* In practice, we're only here in ST_STOPPED (when delaying the
|
|
|
|
* first config request) or ST_CLOSED (when openmode == 0).
|
|
|
|
*
|
|
|
|
* The ST_STOPPED bit is breaking the RFC already :-(
|
|
|
|
*
|
|
|
|
* According to the RFC (1661) state transition table, a TLS isn't
|
|
|
|
* required for an Open event when state == Closed, but the RFC
|
|
|
|
* must be wrong as TLS hasn't yet been called (since the last TLF)
|
|
|
|
* ie, Initial gets an `Up' event, Closing gets a RTA etc.
|
|
|
|
*/
|
|
|
|
(*fp->fn->LayerStart)(fp);
|
|
|
|
(*fp->parent->LayerStart)(fp->parent->object, fp);
|
|
|
|
}
|
1998-01-20 22:47:48 +00:00
|
|
|
FsmInitRestartCounter(fp);
|
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Open(struct fsm * fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
switch (fp->state) {
|
1998-02-07 20:50:08 +00:00
|
|
|
case ST_INITIAL:
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_STARTING);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerStart)(fp);
|
|
|
|
(*fp->parent->LayerStart)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case ST_CLOSED:
|
|
|
|
if (fp->open_mode == OPEN_PASSIVE) {
|
1998-06-27 23:48:54 +00:00
|
|
|
NewState(fp, ST_STOPPED); /* XXX: This is a hack ! */
|
1998-01-20 22:47:48 +00:00
|
|
|
} else if (fp->open_mode > 0) {
|
|
|
|
if (fp->open_mode > 1)
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogPHASE, "%s: Entering STOPPED state for %d seconds\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, fp->open_mode);
|
1998-06-27 23:48:54 +00:00
|
|
|
NewState(fp, ST_STOPPED); /* XXX: This is a not-so-bad hack ! */
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&fp->OpenTimer);
|
1998-01-20 22:47:48 +00:00
|
|
|
fp->OpenTimer.load = fp->open_mode * SECTICKS;
|
|
|
|
fp->OpenTimer.func = FsmOpenNow;
|
|
|
|
fp->OpenTimer.arg = (void *)fp;
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Start(&fp->OpenTimer);
|
1998-01-20 22:47:48 +00:00
|
|
|
} else
|
|
|
|
FsmOpenNow(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
1997-08-25 00:29:32 +00:00
|
|
|
case ST_STOPPED: /* XXX: restart option */
|
1995-01-31 06:29:58 +00:00
|
|
|
case ST_REQSENT:
|
|
|
|
case ST_ACKRCVD:
|
|
|
|
case ST_ACKSENT:
|
1997-08-25 00:29:32 +00:00
|
|
|
case ST_OPENED: /* XXX: restart option */
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
1997-08-25 00:29:32 +00:00
|
|
|
case ST_CLOSING: /* XXX: restart option */
|
|
|
|
case ST_STOPPING: /* XXX: restart option */
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_STOPPING);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Up(struct fsm * fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
switch (fp->state) {
|
1998-06-27 23:48:54 +00:00
|
|
|
case ST_INITIAL:
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "FSM: Using \"%s\" as a transport\n",
|
1998-04-28 01:25:46 +00:00
|
|
|
fp->link->name);
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_CLOSED);
|
|
|
|
break;
|
|
|
|
case ST_STARTING:
|
|
|
|
FsmInitRestartCounter(fp);
|
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
break;
|
|
|
|
default:
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: Oops, Up at %s\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, State2Nam(fp->state));
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Down(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
switch (fp->state) {
|
1998-02-07 20:50:08 +00:00
|
|
|
case ST_CLOSED:
|
|
|
|
NewState(fp, ST_INITIAL);
|
|
|
|
break;
|
|
|
|
case ST_CLOSING:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerFinish)(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_INITIAL);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerFinish)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case ST_STOPPED:
|
1998-02-07 20:50:08 +00:00
|
|
|
NewState(fp, ST_STARTING);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerStart)(fp);
|
|
|
|
(*fp->parent->LayerStart)(fp->parent->object, fp);
|
1998-02-07 20:50:08 +00:00
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case ST_STOPPING:
|
|
|
|
case ST_REQSENT:
|
|
|
|
case ST_ACKRCVD:
|
|
|
|
case ST_ACKSENT:
|
|
|
|
NewState(fp, ST_STARTING);
|
|
|
|
break;
|
|
|
|
case ST_OPENED:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerDown)(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_STARTING);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Close(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
switch (fp->state) {
|
1998-02-07 20:50:08 +00:00
|
|
|
case ST_STARTING:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerFinish)(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_INITIAL);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerFinish)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case ST_STOPPED:
|
|
|
|
NewState(fp, ST_CLOSED);
|
|
|
|
break;
|
|
|
|
case ST_STOPPING:
|
|
|
|
NewState(fp, ST_CLOSING);
|
|
|
|
break;
|
|
|
|
case ST_OPENED:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerDown)(fp);
|
1998-02-07 20:50:08 +00:00
|
|
|
FsmInitRestartCounter(fp);
|
|
|
|
FsmSendTerminateReq(fp);
|
|
|
|
NewState(fp, ST_CLOSING);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
1998-02-07 20:50:08 +00:00
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case ST_REQSENT:
|
|
|
|
case ST_ACKRCVD:
|
|
|
|
case ST_ACKSENT:
|
|
|
|
FsmInitRestartCounter(fp);
|
|
|
|
FsmSendTerminateReq(fp);
|
|
|
|
NewState(fp, ST_CLOSING);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send functions
|
|
|
|
*/
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
FsmSendConfigReq(struct fsm * fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
if (--fp->maxconfig > 0) {
|
1998-02-06 02:24:29 +00:00
|
|
|
(*fp->fn->SendConfigReq)(fp);
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Start(&fp->FsmTimer); /* Start restart timer */
|
1995-01-31 06:29:58 +00:00
|
|
|
fp->restart--; /* Decrement restart counter */
|
|
|
|
} else {
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Close(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1998-03-20 19:47:10 +00:00
|
|
|
FsmSendTerminateReq(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Output(fp, CODE_TERMREQ, fp->reqid, NULL, 0);
|
1998-03-20 19:47:10 +00:00
|
|
|
(*fp->fn->SentTerminateReq)(fp);
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Start(&fp->FsmTimer); /* Start restart timer */
|
1995-01-31 06:29:58 +00:00
|
|
|
fp->restart--; /* Decrement restart counter */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Timeout actions
|
|
|
|
*/
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1997-11-22 03:37:54 +00:00
|
|
|
FsmTimeout(void *v)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
struct fsm *fp = (struct fsm *)v;
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
if (fp->restart) {
|
|
|
|
switch (fp->state) {
|
1998-02-07 20:50:08 +00:00
|
|
|
case ST_CLOSING:
|
|
|
|
case ST_STOPPING:
|
1995-01-31 06:29:58 +00:00
|
|
|
FsmSendTerminateReq(fp);
|
|
|
|
break;
|
|
|
|
case ST_REQSENT:
|
|
|
|
case ST_ACKSENT:
|
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
break;
|
|
|
|
case ST_ACKRCVD:
|
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
break;
|
|
|
|
}
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Start(&fp->FsmTimer);
|
1995-01-31 06:29:58 +00:00
|
|
|
} else {
|
|
|
|
switch (fp->state) {
|
|
|
|
case ST_CLOSING:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerFinish)(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_CLOSED);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerFinish)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case ST_STOPPING:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerFinish)(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_STOPPED);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerFinish)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case ST_REQSENT: /* XXX: 3p */
|
|
|
|
case ST_ACKSENT:
|
|
|
|
case ST_ACKRCVD:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerFinish)(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_STOPPED);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerFinish)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
FsmInitRestartCounter(struct fsm * fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&fp->FsmTimer);
|
1995-01-31 06:29:58 +00:00
|
|
|
fp->FsmTimer.func = FsmTimeout;
|
1997-08-25 00:29:32 +00:00
|
|
|
fp->FsmTimer.arg = (void *) fp;
|
1998-02-06 02:24:29 +00:00
|
|
|
(*fp->fn->InitRestartCounter)(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Actions when receive packets
|
|
|
|
*/
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1998-02-02 19:32:16 +00:00
|
|
|
FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
1997-08-25 00:29:32 +00:00
|
|
|
/* RCR */
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-03-13 21:08:05 +00:00
|
|
|
struct fsm_decode dec;
|
1995-02-26 12:18:08 +00:00
|
|
|
int plen, flen;
|
1995-01-31 06:29:58 +00:00
|
|
|
int ackaction = 0;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
plen = mbuf_Length(bp);
|
1997-12-24 09:29:17 +00:00
|
|
|
flen = ntohs(lhp->length) - sizeof *lhp;
|
1995-02-26 12:18:08 +00:00
|
|
|
if (plen < flen) {
|
1998-06-16 19:40:42 +00:00
|
|
|
log_Printf(LogWARN, "%s: FsmRecvConfigReq: plen (%d) < flen (%d)\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, plen, flen);
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-25 00:29:32 +00:00
|
|
|
* Check and process easy case
|
1995-01-31 06:29:58 +00:00
|
|
|
*/
|
|
|
|
switch (fp->state) {
|
|
|
|
case ST_INITIAL:
|
1998-06-30 23:04:17 +00:00
|
|
|
if (fp->proto == PROTO_CCP && fp->link->lcp.fsm.state == ST_OPENED) {
|
|
|
|
/*
|
|
|
|
* ccp_SetOpenMode() leaves us in initial if we're disabling
|
|
|
|
* & denying everything. This is a bit smelly, we know that
|
|
|
|
* ``bp'' really has ``fsmheader'' in front of it, and CCP_PROTO
|
|
|
|
* in front of that. CCP_PROTO isn't compressed either 'cos it
|
|
|
|
* doesn't begin with 0x00....
|
|
|
|
*/
|
|
|
|
bp->offset -= sizeof(struct fsmheader) + 2;
|
|
|
|
bp->cnt += sizeof(struct fsmheader) + 2;
|
|
|
|
lcp_SendProtoRej(&fp->link->lcp, MBUF_CTOP(bp), bp->cnt);
|
|
|
|
mbuf_Free(bp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Drop through */
|
1995-01-31 06:29:58 +00:00
|
|
|
case ST_STARTING:
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: Oops, RCR in %s.\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, State2Nam(fp->state));
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
case ST_CLOSED:
|
1998-03-20 19:47:10 +00:00
|
|
|
(*fp->fn->SendTerminateAck)(fp, lhp->id);
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
case ST_CLOSING:
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: Error: Got ConfigReq while state = %s\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, State2Nam(fp->state));
|
1997-11-11 23:23:11 +00:00
|
|
|
case ST_STOPPING:
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
1998-08-01 01:02:41 +00:00
|
|
|
case ST_OPENED:
|
|
|
|
(*fp->fn->LayerDown)(fp);
|
|
|
|
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1998-03-13 21:08:05 +00:00
|
|
|
dec.ackend = dec.ack;
|
|
|
|
dec.nakend = dec.nak;
|
|
|
|
dec.rejend = dec.rej;
|
|
|
|
(*fp->fn->DecodeConfig)(fp, MBUF_CTOP(bp), flen, MODE_REQ, &dec);
|
1998-03-20 19:47:10 +00:00
|
|
|
if (flen < sizeof(struct fsmconfig))
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, " [EMPTY]\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-03-13 21:08:05 +00:00
|
|
|
if (dec.nakend == dec.nak && dec.rejend == dec.rej)
|
1995-01-31 06:29:58 +00:00
|
|
|
ackaction = 1;
|
|
|
|
|
|
|
|
switch (fp->state) {
|
|
|
|
case ST_STOPPED:
|
|
|
|
FsmInitRestartCounter(fp);
|
1998-08-01 01:02:41 +00:00
|
|
|
/* Fall through */
|
|
|
|
|
|
|
|
case ST_OPENED:
|
1995-01-31 06:29:58 +00:00
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-03-13 21:08:05 +00:00
|
|
|
if (dec.rejend != dec.rej)
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Output(fp, CODE_CONFIGREJ, lhp->id, dec.rej, dec.rejend - dec.rej);
|
1998-03-13 21:08:05 +00:00
|
|
|
if (dec.nakend != dec.nak)
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Output(fp, CODE_CONFIGNAK, lhp->id, dec.nak, dec.nakend - dec.nak);
|
1995-01-31 06:29:58 +00:00
|
|
|
if (ackaction)
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Output(fp, CODE_CONFIGACK, lhp->id, dec.ack, dec.ackend - dec.ack);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
switch (fp->state) {
|
|
|
|
case ST_OPENED:
|
1998-02-07 20:50:08 +00:00
|
|
|
case ST_STOPPED:
|
1995-01-31 06:29:58 +00:00
|
|
|
if (ackaction)
|
|
|
|
NewState(fp, ST_ACKSENT);
|
|
|
|
else
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
break;
|
|
|
|
case ST_REQSENT:
|
|
|
|
if (ackaction)
|
|
|
|
NewState(fp, ST_ACKSENT);
|
|
|
|
break;
|
|
|
|
case ST_ACKRCVD:
|
|
|
|
if (ackaction) {
|
|
|
|
NewState(fp, ST_OPENED);
|
1998-04-30 23:53:56 +00:00
|
|
|
if ((*fp->fn->LayerUp)(fp))
|
|
|
|
(*fp->parent->LayerUp)(fp->parent->object, fp);
|
|
|
|
else {
|
|
|
|
(*fp->fn->LayerDown)(fp);
|
|
|
|
FsmInitRestartCounter(fp);
|
|
|
|
FsmSendTerminateReq(fp);
|
|
|
|
NewState(fp, ST_CLOSING);
|
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ST_ACKSENT:
|
|
|
|
if (!ackaction)
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
break;
|
|
|
|
}
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1998-03-20 19:47:10 +00:00
|
|
|
FsmRecvConfigAck(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
1997-08-25 00:29:32 +00:00
|
|
|
/* RCA */
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
switch (fp->state) {
|
1997-08-25 00:29:32 +00:00
|
|
|
case ST_CLOSED:
|
|
|
|
case ST_STOPPED:
|
1998-03-20 19:47:10 +00:00
|
|
|
(*fp->fn->SendTerminateAck)(fp, lhp->id);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case ST_CLOSING:
|
|
|
|
case ST_STOPPING:
|
|
|
|
break;
|
|
|
|
case ST_REQSENT:
|
|
|
|
FsmInitRestartCounter(fp);
|
|
|
|
NewState(fp, ST_ACKRCVD);
|
|
|
|
break;
|
|
|
|
case ST_ACKRCVD:
|
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
break;
|
|
|
|
case ST_ACKSENT:
|
|
|
|
FsmInitRestartCounter(fp);
|
|
|
|
NewState(fp, ST_OPENED);
|
1998-04-30 23:53:56 +00:00
|
|
|
if ((*fp->fn->LayerUp)(fp))
|
|
|
|
(*fp->parent->LayerUp)(fp->parent->object, fp);
|
|
|
|
else {
|
|
|
|
(*fp->fn->LayerDown)(fp);
|
|
|
|
FsmInitRestartCounter(fp);
|
|
|
|
FsmSendTerminateReq(fp);
|
|
|
|
NewState(fp, ST_CLOSING);
|
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case ST_OPENED:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerDown)(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
}
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1998-02-02 19:32:16 +00:00
|
|
|
FsmRecvConfigNak(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
1997-08-25 00:29:32 +00:00
|
|
|
/* RCN */
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-03-13 21:08:05 +00:00
|
|
|
struct fsm_decode dec;
|
1995-02-26 12:18:08 +00:00
|
|
|
int plen, flen;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
plen = mbuf_Length(bp);
|
1997-12-24 09:29:17 +00:00
|
|
|
flen = ntohs(lhp->length) - sizeof *lhp;
|
1995-02-26 12:18:08 +00:00
|
|
|
if (plen < flen) {
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-25 00:29:32 +00:00
|
|
|
* Check and process easy case
|
1995-01-31 06:29:58 +00:00
|
|
|
*/
|
|
|
|
switch (fp->state) {
|
|
|
|
case ST_INITIAL:
|
|
|
|
case ST_STARTING:
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: Oops, RCN in %s.\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, State2Nam(fp->state));
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
case ST_CLOSED:
|
|
|
|
case ST_STOPPED:
|
1998-03-20 19:47:10 +00:00
|
|
|
(*fp->fn->SendTerminateAck)(fp, lhp->id);
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
case ST_CLOSING:
|
|
|
|
case ST_STOPPING:
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-03-13 21:08:05 +00:00
|
|
|
dec.ackend = dec.ack;
|
|
|
|
dec.nakend = dec.nak;
|
|
|
|
dec.rejend = dec.rej;
|
|
|
|
(*fp->fn->DecodeConfig)(fp, MBUF_CTOP(bp), flen, MODE_NAK, &dec);
|
1998-03-20 19:47:10 +00:00
|
|
|
if (flen < sizeof(struct fsmconfig))
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, " [EMPTY]\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
switch (fp->state) {
|
|
|
|
case ST_REQSENT:
|
|
|
|
case ST_ACKSENT:
|
|
|
|
FsmInitRestartCounter(fp);
|
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
break;
|
|
|
|
case ST_OPENED:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerDown)(fp);
|
1998-02-07 20:50:08 +00:00
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
1998-02-07 20:50:08 +00:00
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case ST_ACKRCVD:
|
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1998-03-20 19:47:10 +00:00
|
|
|
FsmRecvTermReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
1997-08-25 00:29:32 +00:00
|
|
|
/* RTR */
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
switch (fp->state) {
|
1998-02-07 20:50:08 +00:00
|
|
|
case ST_INITIAL:
|
|
|
|
case ST_STARTING:
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: Oops, RTR in %s\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, State2Nam(fp->state));
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case ST_CLOSED:
|
|
|
|
case ST_STOPPED:
|
|
|
|
case ST_CLOSING:
|
|
|
|
case ST_STOPPING:
|
|
|
|
case ST_REQSENT:
|
1998-03-20 19:47:10 +00:00
|
|
|
(*fp->fn->SendTerminateAck)(fp, lhp->id);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case ST_ACKRCVD:
|
|
|
|
case ST_ACKSENT:
|
1998-03-20 19:47:10 +00:00
|
|
|
(*fp->fn->SendTerminateAck)(fp, lhp->id);
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
break;
|
|
|
|
case ST_OPENED:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerDown)(fp);
|
1998-03-20 19:47:10 +00:00
|
|
|
(*fp->fn->SendTerminateAck)(fp, lhp->id);
|
1998-06-20 01:55:28 +00:00
|
|
|
FsmInitRestartCounter(fp);
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Start(&fp->FsmTimer); /* Start restart timer */
|
1997-06-02 00:04:40 +00:00
|
|
|
fp->restart = 0;
|
|
|
|
NewState(fp, ST_STOPPING);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
}
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
FsmRecvTermAck(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
|
|
|
/* RTA */
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
switch (fp->state) {
|
1998-02-07 20:50:08 +00:00
|
|
|
case ST_CLOSING:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerFinish)(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_CLOSED);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerFinish)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case ST_STOPPING:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerFinish)(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_STOPPED);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerFinish)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case ST_ACKRCVD:
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
break;
|
|
|
|
case ST_OPENED:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerDown)(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
}
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1998-02-02 19:32:16 +00:00
|
|
|
FsmRecvConfigRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
1997-08-25 00:29:32 +00:00
|
|
|
/* RCJ */
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-03-13 21:08:05 +00:00
|
|
|
struct fsm_decode dec;
|
1995-02-26 12:18:08 +00:00
|
|
|
int plen, flen;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
plen = mbuf_Length(bp);
|
1997-12-24 09:29:17 +00:00
|
|
|
flen = ntohs(lhp->length) - sizeof *lhp;
|
1995-02-26 12:18:08 +00:00
|
|
|
if (plen < flen) {
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-25 00:29:32 +00:00
|
|
|
* Check and process easy case
|
1995-01-31 06:29:58 +00:00
|
|
|
*/
|
|
|
|
switch (fp->state) {
|
|
|
|
case ST_INITIAL:
|
|
|
|
case ST_STARTING:
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: Oops, RCJ in %s.\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, State2Nam(fp->state));
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
case ST_CLOSED:
|
|
|
|
case ST_STOPPED:
|
1998-03-20 19:47:10 +00:00
|
|
|
(*fp->fn->SendTerminateAck)(fp, lhp->id);
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
case ST_CLOSING:
|
|
|
|
case ST_STOPPING:
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-03-13 21:08:05 +00:00
|
|
|
dec.ackend = dec.ack;
|
|
|
|
dec.nakend = dec.nak;
|
|
|
|
dec.rejend = dec.rej;
|
|
|
|
(*fp->fn->DecodeConfig)(fp, MBUF_CTOP(bp), flen, MODE_REJ, &dec);
|
1998-03-20 19:47:10 +00:00
|
|
|
if (flen < sizeof(struct fsmconfig))
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, " [EMPTY]\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
switch (fp->state) {
|
|
|
|
case ST_REQSENT:
|
|
|
|
case ST_ACKSENT:
|
|
|
|
FsmInitRestartCounter(fp);
|
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
break;
|
|
|
|
case ST_OPENED:
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->fn->LayerDown)(fp);
|
1998-02-07 20:50:08 +00:00
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
1998-02-27 01:22:39 +00:00
|
|
|
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
1998-02-07 20:50:08 +00:00
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case ST_ACKRCVD:
|
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
break;
|
|
|
|
}
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1998-03-20 19:47:10 +00:00
|
|
|
FsmRecvCodeRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1998-01-30 19:46:07 +00:00
|
|
|
FsmRecvProtoRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-01-30 19:46:07 +00:00
|
|
|
struct physical *p = link2physical(fp->link);
|
1995-01-31 06:29:58 +00:00
|
|
|
u_short *sp, proto;
|
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
sp = (u_short *)MBUF_CTOP(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
proto = ntohs(*sp);
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: -- Protocol 0x%04x (%s) was rejected!\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, proto, hdlc_Protocol2Nam(proto));
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
switch (proto) {
|
|
|
|
case PROTO_LQR:
|
1998-01-30 19:46:07 +00:00
|
|
|
if (p)
|
1998-05-01 19:26:12 +00:00
|
|
|
lqr_Stop(p, LQM_LQR);
|
1998-01-30 19:46:07 +00:00
|
|
|
else
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogERROR, "%s: FsmRecvProtoRej: Not a physical link !\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case PROTO_CCP:
|
1998-03-13 00:44:51 +00:00
|
|
|
if (fp->proto == PROTO_LCP) {
|
1998-04-03 19:21:56 +00:00
|
|
|
fp = &fp->link->ccp.fsm;
|
1998-03-13 00:44:51 +00:00
|
|
|
(*fp->fn->LayerFinish)(fp);
|
|
|
|
switch (fp->state) {
|
|
|
|
case ST_CLOSED:
|
|
|
|
case ST_CLOSING:
|
|
|
|
NewState(fp, ST_CLOSED);
|
|
|
|
default:
|
|
|
|
NewState(fp, ST_STOPPED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
(*fp->parent->LayerFinish)(fp->parent->object, fp);
|
1998-01-29 00:44:16 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-04-23 21:50:13 +00:00
|
|
|
case PROTO_MP:
|
|
|
|
if (fp->proto == PROTO_LCP) {
|
|
|
|
struct lcp *lcp = fsm2lcp(fp);
|
|
|
|
|
|
|
|
if (lcp->want_mrru && lcp->his_mrru) {
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogPHASE, "%s: MP protocol reject is fatal !\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name);
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Close(fp);
|
1998-04-23 21:50:13 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1998-03-13 00:44:26 +00:00
|
|
|
FsmRecvEchoReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-03-13 00:44:51 +00:00
|
|
|
struct lcp *lcp = fsm2lcp(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
u_char *cp;
|
1998-04-19 23:09:03 +00:00
|
|
|
u_int32_t magic;
|
1998-01-29 00:44:16 +00:00
|
|
|
|
1998-03-13 00:44:51 +00:00
|
|
|
if (lcp) {
|
|
|
|
cp = MBUF_CTOP(bp);
|
1998-09-04 18:26:00 +00:00
|
|
|
ua_ntohl(cp, &magic);
|
1998-03-13 00:44:51 +00:00
|
|
|
if (magic != lcp->his_magic) {
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: RecvEchoReq: Error: His magic is bad!!\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name);
|
1998-03-13 00:44:51 +00:00
|
|
|
/* XXX: We should send terminate request */
|
|
|
|
}
|
|
|
|
if (fp->state == ST_OPENED) {
|
1998-09-04 18:26:00 +00:00
|
|
|
ua_htonl(&lcp->want_magic, cp); /* local magic */
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Output(fp, CODE_ECHOREP, lhp->id, cp, mbuf_Length(bp));
|
1998-03-13 00:44:51 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1998-03-13 00:44:26 +00:00
|
|
|
FsmRecvEchoRep(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
1998-01-29 00:44:16 +00:00
|
|
|
{
|
1998-03-13 00:44:51 +00:00
|
|
|
struct lcp *lcp = fsm2lcp(fp);
|
1998-04-19 23:09:03 +00:00
|
|
|
u_int32_t magic;
|
1998-01-29 00:44:16 +00:00
|
|
|
|
1998-03-13 00:44:51 +00:00
|
|
|
if (lcp) {
|
1998-09-04 18:26:00 +00:00
|
|
|
ua_ntohl(MBUF_CTOP(bp), &magic);
|
1998-03-13 00:44:51 +00:00
|
|
|
/* Tolerate echo replies with either magic number */
|
|
|
|
if (magic != 0 && magic != lcp->his_magic && magic != lcp->want_magic) {
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogWARN,
|
1998-04-24 19:15:48 +00:00
|
|
|
"%s: RecvEchoRep: Bad magic: expected 0x%08x, got: 0x%08x\n",
|
|
|
|
fp->link->name, lcp->his_magic, magic);
|
1998-03-13 00:44:51 +00:00
|
|
|
/*
|
1998-04-19 23:09:03 +00:00
|
|
|
* XXX: We should send terminate request. But poor implementations may
|
|
|
|
* die as a result.
|
1998-03-13 00:44:51 +00:00
|
|
|
*/
|
|
|
|
}
|
1998-05-01 19:26:12 +00:00
|
|
|
lqr_RecvEcho(fp, bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
FsmRecvDiscReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
FsmRecvIdent(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
FsmRecvTimeRemain(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1998-02-21 01:45:26 +00:00
|
|
|
FsmRecvResetReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-02-21 01:45:26 +00:00
|
|
|
(*fp->fn->RecvResetReq)(fp);
|
Implement Reset{Req,Ack} properly, as per rfc 1962.
(I completely mis-read the rfc last time 'round!)
This means:
o Better CCP/WARN Reset diagnostics.
o After we've sent a REQ and before we've received an ACK, we drop
incoming compressed data and send another REQ.
o Before sending an ACK, re-sequence all pending PRI_NORMAL data in
the modem queue so that pending packets won't get to the peer
*after* the ResetAck.
o Send ACKs with the `identifier' from the REQ frame.
o After we've received a correct ACK, duplicate ACKs are ok (and will
reset our history).
o Incorrect ACKs (not matching the last REQ) are moaned about and dropped.
Also,
o Calculate the correct FCS after compressing a packet. DEFLATE
*may* produce an mbuf with more than a single link in the chain,
but HdlcOutput didn't know how to calculate the FCS :-(
o Make `struct fsm'::reqid a u_char, not an int.
This fix will prevent us from sending id `255' 2,000,000,000 times
before wrapping to `0' for another 2,000,000,000 sends :-/
o Bump the version number a little.
The end result: DEFLATE now works over an unreliable link layer.
I can txfr a 1.5Mb kernel over a (rather bad) null-modem
cable at an average of 21679 bytes per second using rcp.
Repeat after me: Don't test compression using a loopback ppp/tcp setup as
we never lose packets and therefore never have to reset!
1998-01-10 01:55:11 +00:00
|
|
|
/*
|
|
|
|
* All sendable compressed packets are queued in the PRI_NORMAL modem
|
|
|
|
* output queue.... dump 'em to the priority queue so that they arrive
|
|
|
|
* at the peer before our ResetAck.
|
|
|
|
*/
|
1998-01-30 19:46:07 +00:00
|
|
|
link_SequenceQueue(fp->link);
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Output(fp, CODE_RESETACK, lhp->id, NULL, 0);
|
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1998-02-21 01:45:26 +00:00
|
|
|
FsmRecvResetAck(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
1998-01-29 00:44:16 +00:00
|
|
|
{
|
1998-02-21 01:45:26 +00:00
|
|
|
(*fp->fn->RecvResetAck)(fp, lhp->id);
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1998-01-29 00:44:16 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Input(struct fsm *fp, struct mbuf *bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
struct fsmheader *lhp;
|
1997-12-03 10:23:54 +00:00
|
|
|
const struct fsmcodedesc *codep;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
len = mbuf_Length(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
if (len < sizeof(struct fsmheader)) {
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
1997-08-25 00:29:32 +00:00
|
|
|
lhp = (struct fsmheader *) MBUF_CTOP(bp);
|
1998-04-03 19:21:56 +00:00
|
|
|
if (lhp->code < fp->min_code || lhp->code > fp->max_code ||
|
1998-01-31 02:48:30 +00:00
|
|
|
lhp->code > sizeof FsmCodes / sizeof *FsmCodes) {
|
1998-04-03 19:21:56 +00:00
|
|
|
/*
|
|
|
|
* Use a private id. This is really a response-type packet, but we
|
|
|
|
* MUST send a unique id for each REQ....
|
|
|
|
*/
|
|
|
|
static u_char id;
|
1998-06-15 19:06:58 +00:00
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Output(fp, CODE_CODEREJ, id++, MBUF_CTOP(bp), bp->cnt);
|
|
|
|
mbuf_Free(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
bp->offset += sizeof(struct fsmheader);
|
|
|
|
bp->cnt -= sizeof(struct fsmheader);
|
|
|
|
|
|
|
|
codep = FsmCodes + lhp->code - 1;
|
1998-04-16 00:26:21 +00:00
|
|
|
if (lhp->id != fp->reqid && codep->check_reqid &&
|
|
|
|
Enabled(fp->bundle, OPT_IDCHECK)) {
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: Recv%s(%d), dropped (expected %d)\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, codep->name, lhp->id, fp->reqid);
|
1998-03-20 19:47:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: Recv%s(%d) state = %s\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, codep->name, lhp->id, State2Nam(fp->state));
|
1998-03-20 19:47:10 +00:00
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
if (log_IsKept(LogDEBUG))
|
|
|
|
mbuf_Log();
|
1998-03-20 19:47:10 +00:00
|
|
|
|
|
|
|
if (codep->inc_reqid && (lhp->id == fp->reqid ||
|
1998-04-16 00:26:21 +00:00
|
|
|
(!Enabled(fp->bundle, OPT_IDCHECK) && codep->check_reqid)))
|
1998-03-20 19:47:10 +00:00
|
|
|
fp->reqid++; /* That's the end of that ``exchange''.... */
|
|
|
|
|
1998-04-16 00:26:21 +00:00
|
|
|
(*codep->recv)(fp, lhp, bp);
|
1998-03-20 19:47:10 +00:00
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
if (log_IsKept(LogDEBUG))
|
|
|
|
mbuf_Log();
|
1998-01-29 00:44:16 +00:00
|
|
|
}
|
1998-02-21 01:45:26 +00:00
|
|
|
|
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_NullRecvResetReq(struct fsm *fp)
|
1998-02-21 01:45:26 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: Oops - received unexpected reset req\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name);
|
1998-02-21 01:45:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_NullRecvResetAck(struct fsm *fp, u_char id)
|
1998-02-21 01:45:26 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: Oops - received unexpected reset ack\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1998-06-20 00:19:42 +00:00
|
|
|
|
1998-06-25 22:33:31 +00:00
|
|
|
void
|
|
|
|
fsm_Reopen(struct fsm *fp)
|
|
|
|
{
|
|
|
|
if (fp->state == ST_OPENED) {
|
|
|
|
(*fp->fn->LayerDown)(fp);
|
|
|
|
FsmInitRestartCounter(fp);
|
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-06-20 00:19:42 +00:00
|
|
|
void
|
|
|
|
fsm2initial(struct fsm *fp)
|
|
|
|
{
|
|
|
|
if (fp->state == ST_STOPPED)
|
|
|
|
fsm_Close(fp);
|
|
|
|
if (fp->state > ST_INITIAL)
|
|
|
|
fsm_Down(fp);
|
|
|
|
if (fp->state > ST_INITIAL)
|
|
|
|
fsm_Close(fp);
|
|
|
|
}
|