2001-06-13 21:52:19 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
|
|
|
|
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
|
|
|
|
* Internet Initiative Japan, Inc (IIJ)
|
|
|
|
* All rights reserved.
|
1995-01-31 06:29:58 +00:00
|
|
|
*
|
2001-06-13 21:52:19 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
1995-01-31 06:29:58 +00:00
|
|
|
*
|
2001-06-13 21:52:19 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1999-08-28 01:35:59 +00:00
|
|
|
* $FreeBSD$
|
1995-01-31 06:29:58 +00:00
|
|
|
*/
|
1998-04-16 00:26:21 +00:00
|
|
|
|
1999-01-28 01:56:34 +00:00
|
|
|
#include <sys/param.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>
|
2001-08-14 16:05:52 +00:00
|
|
|
#include <sys/socket.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>
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
#include "layer.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"
|
2001-08-14 16:05:52 +00:00
|
|
|
#include "ncpaddr.h"
|
1998-04-16 00:26:21 +00:00
|
|
|
#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"
|
1999-01-28 01:56:34 +00:00
|
|
|
#ifndef NORADIUS
|
|
|
|
#include "radius.h"
|
|
|
|
#endif
|
2001-08-14 16:05:52 +00:00
|
|
|
#include "ipv6cp.h"
|
|
|
|
#include "ncp.h"
|
1998-04-16 00:26:21 +00:00
|
|
|
#include "bundle.h"
|
|
|
|
#include "async.h"
|
1998-01-29 00:49:32 +00:00
|
|
|
#include "physical.h"
|
1999-05-08 11:07:56 +00:00
|
|
|
#include "proto.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
|
|
|
|
static void FsmSendConfigReq(struct fsm *);
|
|
|
|
static void FsmSendTerminateReq(struct fsm *);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
static void FsmInitRestartCounter(struct fsm *, int);
|
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" },
|
2000-07-19 02:10:35 +00:00
|
|
|
{ FsmRecvIdent, 0, 1, "Ident" },
|
1998-03-20 19:47:10 +00:00
|
|
|
{ FsmRecvTimeRemain,0, 0, "TimeRemain" },
|
1999-05-08 11:07:56 +00:00
|
|
|
{ FsmRecvResetReq, 0, 0, "ResetReq" },
|
1998-03-20 19:47:10 +00:00
|
|
|
{ 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)
|
|
|
|
{
|
1999-12-27 11:54:57 +00:00
|
|
|
static const char * const StateNames[] = {
|
1998-03-24 18:47:32 +00:00
|
|
|
"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,
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
int maxcode, int LogLevel, struct bundle *bundle,
|
1998-04-03 19:21:56 +00:00
|
|
|
struct link *l, const struct fsm_parent *parent,
|
1999-12-27 11:54:57 +00:00
|
|
|
struct fsm_callbacks *fn, const char * const 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;
|
1999-05-08 11:07:56 +00:00
|
|
|
fp->more.reqs = fp->more.naks = fp->more.rejs = 3;
|
1998-02-21 01:45:26 +00:00
|
|
|
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
|
1999-05-09 20:02:29 +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",
|
2002-04-16 23:57:09 +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
|
2004-09-05 01:46:52 +00:00
|
|
|
fsm_Output(struct fsm *fp, u_int code, u_int id, u_char *ptr, unsigned count,
|
1999-06-02 15:59:09 +00:00
|
|
|
int mtype)
|
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:
|
2002-04-16 23:57:09 +00:00
|
|
|
(*fp->fn->DecodeConfig)(fp, ptr, ptr + count, MODE_NOP, NULL);
|
|
|
|
if (count < sizeof(struct fsm_opt_hdr))
|
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);
|
1999-12-20 20:29:47 +00:00
|
|
|
bp = m_get(plen, mtype);
|
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);
|
1999-09-04 00:00:21 +00:00
|
|
|
link_PushPacket(fp->link, bp, fp->bundle, LINK_QUEUES(fp->link) - 1,
|
|
|
|
fp->proto);
|
2000-07-19 02:10:35 +00:00
|
|
|
|
|
|
|
if (code == CODE_CONFIGREJ)
|
|
|
|
lcp_SendIdentification(&fp->link->lcp);
|
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);
|
|
|
|
}
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(fp, FSM_REQ_TIMER);
|
1998-01-20 22:47:48 +00:00
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
void
|
1999-05-09 20:02:29 +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
|
1999-05-09 20:02:29 +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:
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(fp, FSM_REQ_TIMER);
|
1995-01-31 06:29:58 +00:00
|
|
|
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:
|
1999-03-01 02:52:39 +00:00
|
|
|
/* This TLF contradicts the RFC (1661), which ``misses it out'' ! */
|
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);
|
2001-01-26 01:43:38 +00:00
|
|
|
if (fp->state == ST_OPENED) {
|
|
|
|
FsmInitRestartCounter(fp, FSM_TRM_TIMER);
|
|
|
|
FsmSendTerminateReq(fp);
|
|
|
|
NewState(fp, ST_CLOSING);
|
|
|
|
(*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:
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(fp, FSM_TRM_TIMER);
|
1995-01-31 06:29:58 +00:00
|
|
|
FsmSendTerminateReq(fp);
|
|
|
|
NewState(fp, ST_CLOSING);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send functions
|
|
|
|
*/
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1999-05-09 20:02:29 +00:00
|
|
|
FsmSendConfigReq(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
if (fp->more.reqs-- > 0 && fp->restart-- > 0) {
|
1998-02-06 02:24:29 +00:00
|
|
|
(*fp->fn->SendConfigReq)(fp);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
timer_Start(&fp->FsmTimer); /* Start restart timer */
|
1995-01-31 06:29:58 +00:00
|
|
|
} else {
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
if (fp->more.reqs < 0)
|
|
|
|
log_Printf(LogPHASE, "%s: Too many %s REQs sent - abandoning "
|
|
|
|
"negotiation\n", fp->link->name, fp->name);
|
2000-07-19 02:10:35 +00:00
|
|
|
lcp_SendIdentification(&fp->link->lcp);
|
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
|
|
|
{
|
1999-06-02 15:59:09 +00:00
|
|
|
fsm_Output(fp, CODE_TERMREQ, fp->reqid, NULL, 0, MB_UNKNOWN);
|
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
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(struct fsm *fp, int what)
|
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;
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
fp->FsmTimer.arg = (void *)fp;
|
|
|
|
(*fp->fn->InitRestartCounter)(fp, what);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-05-09 20:02:29 +00:00
|
|
|
* Actions when receive packets
|
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
|
|
|
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;
|
2002-04-16 23:57:09 +00:00
|
|
|
u_char *cp;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
2002-04-16 23:57:09 +00:00
|
|
|
bp = m_pullup(bp);
|
1999-12-20 20:29:47 +00:00
|
|
|
plen = m_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",
|
2002-04-16 23:57:09 +00:00
|
|
|
fp->link->name, plen, flen);
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-05-01 10:04:49 +00:00
|
|
|
/* Some things must be done before we Decode the packet */
|
|
|
|
switch (fp->state) {
|
|
|
|
case ST_OPENED:
|
|
|
|
(*fp->fn->LayerDown)(fp);
|
|
|
|
}
|
|
|
|
|
2002-04-16 23:57:09 +00:00
|
|
|
dec.ackend = dec.ack;
|
|
|
|
dec.nakend = dec.nak;
|
|
|
|
dec.rejend = dec.rej;
|
|
|
|
cp = MBUF_CTOP(bp);
|
|
|
|
(*fp->fn->DecodeConfig)(fp, cp, cp + flen, MODE_REQ, &dec);
|
2004-09-05 01:46:52 +00:00
|
|
|
if (flen < (int)sizeof(struct fsm_opt_hdr))
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(fp->LogLevel, " [EMPTY]\n");
|
|
|
|
|
|
|
|
if (dec.nakend == dec.nak && dec.rejend == dec.rej)
|
|
|
|
ackaction = 1;
|
|
|
|
|
1999-05-09 20:02:29 +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
|
1999-05-08 11:07:56 +00:00
|
|
|
* & denying everything.
|
1998-06-30 23:04:17 +00:00
|
|
|
*/
|
1999-12-20 20:29:47 +00:00
|
|
|
bp = m_prepend(bp, lhp, sizeof *lhp, 2);
|
1999-05-08 11:07:56 +00:00
|
|
|
bp = proto_Prepend(bp, fp->proto, 0, 0);
|
1999-12-20 20:29:47 +00:00
|
|
|
bp = m_pullup(bp);
|
|
|
|
lcp_SendProtoRej(&fp->link->lcp, MBUF_CTOP(bp), bp->m_len);
|
|
|
|
m_freem(bp);
|
1998-06-30 23:04:17 +00:00
|
|
|
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));
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(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);
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(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:
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
case ST_STOPPED:
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(fp, FSM_REQ_TIMER);
|
2002-05-01 10:04:49 +00:00
|
|
|
/* Drop through */
|
1998-08-01 01:02:41 +00:00
|
|
|
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)
|
1999-06-02 15:59:09 +00:00
|
|
|
fsm_Output(fp, CODE_CONFIGREJ, lhp->id, dec.rej, dec.rejend - dec.rej,
|
|
|
|
MB_UNKNOWN);
|
1998-03-13 21:08:05 +00:00
|
|
|
if (dec.nakend != dec.nak)
|
1999-06-02 15:59:09 +00:00
|
|
|
fsm_Output(fp, CODE_CONFIGNAK, lhp->id, dec.nak, dec.nakend - dec.nak,
|
|
|
|
MB_UNKNOWN);
|
1995-01-31 06:29:58 +00:00
|
|
|
if (ackaction)
|
1999-06-02 15:59:09 +00:00
|
|
|
fsm_Output(fp, CODE_CONFIGACK, lhp->id, dec.ack, dec.ackend - dec.ack,
|
|
|
|
MB_UNKNOWN);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
switch (fp->state) {
|
1998-02-07 20:50:08 +00:00
|
|
|
case ST_STOPPED:
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
/*
|
|
|
|
* According to the RFC (1661) state transition table, a TLS isn't
|
|
|
|
* required for a RCR when state == ST_STOPPED, but the RFC
|
|
|
|
* must be wrong as TLS hasn't yet been called (since the last TLF)
|
|
|
|
*/
|
|
|
|
(*fp->fn->LayerStart)(fp);
|
|
|
|
(*fp->parent->LayerStart)(fp->parent->object, fp);
|
2002-08-25 13:30:43 +00:00
|
|
|
/* FALLTHROUGH */
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
|
|
|
|
case ST_OPENED:
|
1995-01-31 06:29:58 +00:00
|
|
|
if (ackaction)
|
|
|
|
NewState(fp, ST_ACKSENT);
|
|
|
|
else
|
|
|
|
NewState(fp, ST_REQSENT);
|
2001-08-14 16:05:52 +00:00
|
|
|
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
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);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(fp, FSM_TRM_TIMER);
|
1998-04-30 23:53:56 +00:00
|
|
|
FsmSendTerminateReq(fp);
|
|
|
|
NewState(fp, ST_CLOSING);
|
2000-07-19 02:10:35 +00:00
|
|
|
lcp_SendIdentification(&fp->link->lcp);
|
1998-04-30 23:53:56 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ST_ACKSENT:
|
|
|
|
if (!ackaction)
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
break;
|
|
|
|
}
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
|
|
|
|
if (dec.rejend != dec.rej && --fp->more.rejs <= 0) {
|
|
|
|
log_Printf(LogPHASE, "%s: Too many %s REJs sent - abandoning negotiation\n",
|
|
|
|
fp->link->name, fp->name);
|
2000-07-19 02:10:35 +00:00
|
|
|
lcp_SendIdentification(&fp->link->lcp);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
fsm_Close(fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dec.nakend != dec.nak && --fp->more.naks <= 0) {
|
|
|
|
log_Printf(LogPHASE, "%s: Too many %s NAKs sent - abandoning negotiation\n",
|
|
|
|
fp->link->name, fp->name);
|
2000-07-19 02:10:35 +00:00
|
|
|
lcp_SendIdentification(&fp->link->lcp);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +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
|
|
|
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
|
|
|
{
|
2002-04-16 23:57:09 +00:00
|
|
|
struct fsm_decode dec;
|
|
|
|
int plen, flen;
|
|
|
|
u_char *cp;
|
|
|
|
|
|
|
|
plen = m_length(bp);
|
|
|
|
flen = ntohs(lhp->length) - sizeof *lhp;
|
|
|
|
if (plen < flen) {
|
|
|
|
m_freem(bp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bp = m_pullup(bp);
|
|
|
|
dec.ackend = dec.ack;
|
|
|
|
dec.nakend = dec.nak;
|
|
|
|
dec.rejend = dec.rej;
|
|
|
|
cp = MBUF_CTOP(bp);
|
|
|
|
(*fp->fn->DecodeConfig)(fp, cp, cp + flen, MODE_ACK, &dec);
|
2004-09-05 01:46:52 +00:00
|
|
|
if (flen < (int)sizeof(struct fsm_opt_hdr))
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(fp->LogLevel, " [EMPTY]\n");
|
|
|
|
|
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:
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(fp, FSM_REQ_TIMER);
|
1995-01-31 06:29:58 +00:00
|
|
|
NewState(fp, ST_ACKRCVD);
|
|
|
|
break;
|
|
|
|
case ST_ACKRCVD:
|
|
|
|
FsmSendConfigReq(fp);
|
|
|
|
NewState(fp, ST_REQSENT);
|
|
|
|
break;
|
|
|
|
case ST_ACKSENT:
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(fp, FSM_REQ_TIMER);
|
1995-01-31 06:29:58 +00:00
|
|
|
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);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(fp, FSM_TRM_TIMER);
|
1998-04-30 23:53:56 +00:00
|
|
|
FsmSendTerminateReq(fp);
|
|
|
|
NewState(fp, ST_CLOSING);
|
2000-07-19 02:10:35 +00:00
|
|
|
lcp_SendIdentification(&fp->link->lcp);
|
1998-04-30 23:53:56 +00:00
|
|
|
}
|
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;
|
|
|
|
}
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(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;
|
2002-04-16 23:57:09 +00:00
|
|
|
u_char *cp;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1999-12-20 20:29:47 +00:00
|
|
|
plen = m_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) {
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(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));
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(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);
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
case ST_CLOSING:
|
|
|
|
case ST_STOPPING:
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-12-20 20:29:47 +00:00
|
|
|
bp = m_pullup(bp);
|
1998-03-13 21:08:05 +00:00
|
|
|
dec.ackend = dec.ack;
|
|
|
|
dec.nakend = dec.nak;
|
|
|
|
dec.rejend = dec.rej;
|
2002-04-16 23:57:09 +00:00
|
|
|
cp = MBUF_CTOP(bp);
|
|
|
|
(*fp->fn->DecodeConfig)(fp, cp, cp + flen, MODE_NAK, &dec);
|
2004-09-05 01:46:52 +00:00
|
|
|
if (flen < (int)sizeof(struct fsm_opt_hdr))
|
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:
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(fp, FSM_REQ_TIMER);
|
1995-01-31 06:29:58 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(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);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(fp, FSM_TRM_TIMER);
|
|
|
|
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);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
/* A delayed ST_STOPPED is now scheduled */
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
2004-09-05 01:46:52 +00:00
|
|
|
FsmRecvTermAck(struct fsm *fp, struct fsmheader *lhp __unused, struct mbuf *bp)
|
1997-08-25 00:29:32 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(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;
|
2004-09-05 01:46:52 +00:00
|
|
|
size_t plen;
|
|
|
|
int flen;
|
2002-04-16 23:57:09 +00:00
|
|
|
u_char *cp;
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1999-12-20 20:29:47 +00:00
|
|
|
plen = m_length(bp);
|
1997-12-24 09:29:17 +00:00
|
|
|
flen = ntohs(lhp->length) - sizeof *lhp;
|
2004-09-05 01:46:52 +00:00
|
|
|
if ((int)plen < flen) {
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-07-19 02:10:35 +00:00
|
|
|
lcp_SendIdentification(&fp->link->lcp);
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
/*
|
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));
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(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);
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
case ST_CLOSING:
|
|
|
|
case ST_STOPPING:
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-12-20 20:29:47 +00:00
|
|
|
bp = m_pullup(bp);
|
1998-03-13 21:08:05 +00:00
|
|
|
dec.ackend = dec.ack;
|
|
|
|
dec.nakend = dec.nak;
|
|
|
|
dec.rejend = dec.rej;
|
2002-04-16 23:57:09 +00:00
|
|
|
cp = MBUF_CTOP(bp);
|
|
|
|
(*fp->fn->DecodeConfig)(fp, cp, cp + flen, MODE_REJ, &dec);
|
2004-09-05 01:46:52 +00:00
|
|
|
if (flen < (int)sizeof(struct fsm_opt_hdr))
|
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:
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(fp, FSM_REQ_TIMER);
|
1995-01-31 06:29:58 +00:00
|
|
|
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;
|
|
|
|
}
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
2004-09-05 01:46:52 +00:00
|
|
|
FsmRecvCodeRej(struct fsm *fp __unused, struct fsmheader *lhp __unused,
|
|
|
|
struct mbuf *bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
2004-09-05 01:46:52 +00:00
|
|
|
FsmRecvProtoRej(struct fsm *fp, struct fsmheader *lhp __unused, 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);
|
1999-05-09 20:02:29 +00:00
|
|
|
u_short proto;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1999-12-20 20:29:47 +00:00
|
|
|
if (m_length(bp) < 2) {
|
|
|
|
m_freem(bp);
|
1999-05-09 20:02:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
bp = mbuf_Read(bp, &proto, 2);
|
|
|
|
proto = ntohs(proto);
|
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;
|
1999-03-01 02:52:39 +00:00
|
|
|
/* Despite the RFC (1661), don't do an out-of-place TLF */
|
|
|
|
/* (*fp->fn->LayerFinish)(fp); */
|
1998-03-13 00:44:51 +00:00
|
|
|
switch (fp->state) {
|
|
|
|
case ST_CLOSED:
|
|
|
|
case ST_CLOSING:
|
|
|
|
NewState(fp, ST_CLOSED);
|
2002-03-30 12:47:29 +00:00
|
|
|
break;
|
1998-03-13 00:44:51 +00:00
|
|
|
default:
|
|
|
|
NewState(fp, ST_STOPPED);
|
|
|
|
break;
|
|
|
|
}
|
1999-03-01 02:52:39 +00:00
|
|
|
/* See above */
|
|
|
|
/* (*fp->parent->LayerFinish)(fp->parent->object, fp); */
|
1998-01-29 00:44:16 +00:00
|
|
|
}
|
|
|
|
break;
|
1999-08-10 08:42:20 +00:00
|
|
|
case PROTO_IPCP:
|
|
|
|
if (fp->proto == PROTO_LCP) {
|
|
|
|
log_Printf(LogPHASE, "%s: IPCP protocol reject closes IPCP !\n",
|
|
|
|
fp->link->name);
|
|
|
|
fsm_Close(&fp->bundle->ncp.ipcp.fsm);
|
|
|
|
}
|
|
|
|
break;
|
2001-08-14 16:05:52 +00:00
|
|
|
#ifndef NOINET6
|
|
|
|
case PROTO_IPV6CP:
|
2001-08-18 19:07:13 +00:00
|
|
|
if (fp->proto == PROTO_LCP) {
|
2001-08-14 16:05:52 +00:00
|
|
|
log_Printf(LogPHASE, "%s: IPV6CP protocol reject closes IPV6CP !\n",
|
|
|
|
fp->link->name);
|
|
|
|
fsm_Close(&fp->bundle->ncp.ipv6cp.fsm);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
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;
|
|
|
|
}
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(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
|
|
|
|
1999-12-20 20:29:47 +00:00
|
|
|
bp = m_pullup(bp);
|
|
|
|
m_settype(bp, MB_ECHOIN);
|
1999-11-06 22:50:59 +00:00
|
|
|
|
|
|
|
if (lcp && ntohs(lhp->length) - sizeof *lhp >= 4) {
|
1998-03-13 00:44:51 +00:00
|
|
|
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) {
|
1999-10-06 23:22:54 +00:00
|
|
|
log_Printf(fp->LogLevel, "%s: RecvEchoReq: magic 0x%08lx is wrong,"
|
|
|
|
" expecting 0x%08lx\n", fp->link->name, (u_long)magic,
|
|
|
|
(u_long)lcp->his_magic);
|
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 */
|
1999-11-06 22:50:59 +00:00
|
|
|
fsm_Output(fp, CODE_ECHOREP, lhp->id, cp,
|
|
|
|
ntohs(lhp->length) - sizeof *lhp, MB_ECHOOUT);
|
1998-03-13 00:44:51 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
2004-09-05 01:46:52 +00:00
|
|
|
FsmRecvEchoRep(struct fsm *fp, struct fsmheader *lhp __unused, struct mbuf *bp)
|
1998-01-29 00:44:16 +00:00
|
|
|
{
|
1999-05-14 09:36:06 +00:00
|
|
|
if (fsm2lcp(fp))
|
1999-05-09 20:02:29 +00:00
|
|
|
bp = lqr_RecvEcho(fp, bp);
|
1999-05-14 09:36:06 +00:00
|
|
|
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
2004-09-05 01:46:52 +00:00
|
|
|
FsmRecvDiscReq(struct fsm *fp __unused, struct fsmheader *lhp __unused,
|
|
|
|
struct mbuf *bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
1999-05-09 20:02:29 +00:00
|
|
|
FsmRecvIdent(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
2000-07-19 02:10:35 +00:00
|
|
|
u_int32_t magic;
|
|
|
|
u_short len;
|
|
|
|
u_char *cp;
|
|
|
|
|
|
|
|
len = ntohs(lhp->length) - sizeof *lhp;
|
|
|
|
if (len >= 4) {
|
|
|
|
bp = m_pullup(m_append(bp, "", 1));
|
|
|
|
cp = MBUF_CTOP(bp);
|
|
|
|
ua_ntohl(cp, &magic);
|
|
|
|
if (magic != fp->link->lcp.his_magic)
|
|
|
|
log_Printf(fp->LogLevel, "%s: RecvIdent: magic 0x%08lx is wrong,"
|
|
|
|
" expecting 0x%08lx\n", fp->link->name, (u_long)magic,
|
|
|
|
(u_long)fp->link->lcp.his_magic);
|
|
|
|
cp[len] = '\0';
|
|
|
|
lcp_RecvIdentification(&fp->link->lcp, cp + 4);
|
|
|
|
}
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
static void
|
2004-09-05 01:46:52 +00:00
|
|
|
FsmRecvTimeRemain(struct fsm *fp __unused, struct fsmheader *lhp __unused,
|
|
|
|
struct mbuf *bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(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
|
|
|
{
|
2001-06-18 15:00:22 +00:00
|
|
|
if ((*fp->fn->RecvResetReq)(fp)) {
|
|
|
|
/*
|
|
|
|
* All sendable compressed packets are queued in the first (lowest
|
|
|
|
* priority) modem output queue.... dump 'em to the priority queue
|
|
|
|
* so that they arrive at the peer before our ResetAck.
|
|
|
|
*/
|
|
|
|
link_SequenceQueue(fp->link);
|
|
|
|
fsm_Output(fp, CODE_RESETACK, lhp->id, NULL, 0, MB_CCPOUT);
|
|
|
|
}
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(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);
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(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
|
|
|
{
|
2004-09-05 01:46:52 +00:00
|
|
|
size_t len;
|
1999-05-08 11:07:56 +00:00
|
|
|
struct fsmheader lh;
|
1997-12-03 10:23:54 +00:00
|
|
|
const struct fsmcodedesc *codep;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1999-12-20 20:29:47 +00:00
|
|
|
len = m_length(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
if (len < sizeof(struct fsmheader)) {
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-05-08 11:07:56 +00:00
|
|
|
bp = mbuf_Read(bp, &lh, sizeof lh);
|
1999-11-06 22:50:59 +00:00
|
|
|
|
2000-07-19 02:10:35 +00:00
|
|
|
if (ntohs(lh.length) > len) {
|
2004-09-06 00:07:58 +00:00
|
|
|
log_Printf(LogWARN, "%s: Oops: Got %zu bytes but %d byte payload "
|
2000-07-19 02:10:35 +00:00
|
|
|
"- dropped\n", fp->link->name, len, (int)ntohs(lh.length));
|
|
|
|
m_freem(bp);
|
|
|
|
return;
|
2000-05-26 21:11:55 +00:00
|
|
|
}
|
1999-11-06 22:50:59 +00:00
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
if (lh.code < fp->min_code || lh.code > fp->max_code ||
|
|
|
|
lh.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
|
|
|
|
1999-12-20 20:29:47 +00:00
|
|
|
bp = m_prepend(bp, &lh, sizeof lh, 0);
|
|
|
|
bp = m_pullup(bp);
|
|
|
|
fsm_Output(fp, CODE_CODEREJ, id++, MBUF_CTOP(bp), bp->m_len, MB_UNKNOWN);
|
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
codep = FsmCodes + lh.code - 1;
|
|
|
|
if (lh.id != fp->reqid && codep->check_reqid &&
|
1998-04-16 00:26:21 +00:00
|
|
|
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",
|
2002-04-16 23:57:09 +00:00
|
|
|
fp->link->name, codep->name, lh.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",
|
2002-04-16 23:57:09 +00:00
|
|
|
fp->link->name, codep->name, lh.id, State2Nam(fp->state));
|
1998-03-20 19:47:10 +00:00
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
if (codep->inc_reqid && (lh.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''.... */
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
(*codep->recv)(fp, &lh, bp);
|
1998-01-29 00:44:16 +00:00
|
|
|
}
|
1998-02-21 01:45:26 +00:00
|
|
|
|
2001-06-18 15:00:22 +00:00
|
|
|
int
|
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);
|
2001-06-18 15:00:22 +00:00
|
|
|
return 1;
|
1998-02-21 01:45:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-09-05 01:46:52 +00:00
|
|
|
fsm_NullRecvResetAck(struct fsm *fp, u_char id __unused)
|
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);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
FsmInitRestartCounter(fp, FSM_REQ_TIMER);
|
1998-06-25 22:33:31 +00:00
|
|
|
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)
|
|
|
|
{
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
timer_Stop(&fp->FsmTimer);
|
|
|
|
timer_Stop(&fp->OpenTimer);
|
|
|
|
timer_Stop(&fp->StoppedTimer);
|
1998-06-20 00:19:42 +00:00
|
|
|
if (fp->state == ST_STOPPED)
|
|
|
|
fsm_Close(fp);
|
|
|
|
if (fp->state > ST_INITIAL)
|
|
|
|
fsm_Down(fp);
|
|
|
|
if (fp->state > ST_INITIAL)
|
|
|
|
fsm_Close(fp);
|
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
|
|
|
|
struct fsm_opt *
|
|
|
|
fsm_readopt(u_char **cp)
|
|
|
|
{
|
|
|
|
struct fsm_opt *o = (struct fsm_opt *)*cp;
|
|
|
|
|
|
|
|
if (o->hdr.len < sizeof(struct fsm_opt_hdr)) {
|
|
|
|
log_Printf(LogERROR, "Bad option length %d (out of phase?)\n", o->hdr.len);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*cp += o->hdr.len;
|
|
|
|
|
|
|
|
if (o->hdr.len > sizeof(struct fsm_opt)) {
|
2002-06-15 08:03:59 +00:00
|
|
|
log_Printf(LogERROR, "Warning: Truncating option length from %d to %d\n",
|
|
|
|
o->hdr.len, (int)sizeof(struct fsm_opt));
|
2002-04-16 23:57:09 +00:00
|
|
|
o->hdr.len = sizeof(struct fsm_opt);
|
|
|
|
}
|
|
|
|
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
fsm_opt(u_char *opt, int optlen, const struct fsm_opt *o)
|
|
|
|
{
|
2004-09-05 01:46:52 +00:00
|
|
|
unsigned cplen = o->hdr.len;
|
2002-04-16 23:57:09 +00:00
|
|
|
|
2004-09-05 01:46:52 +00:00
|
|
|
if (optlen < (int)sizeof(struct fsm_opt_hdr))
|
2002-04-16 23:57:09 +00:00
|
|
|
optlen = 0;
|
|
|
|
|
2004-09-05 01:46:52 +00:00
|
|
|
if ((int)cplen > optlen) {
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(LogERROR, "Can't REJ length %d - trunating to %d\n",
|
|
|
|
cplen, optlen);
|
|
|
|
cplen = optlen;
|
|
|
|
}
|
|
|
|
memcpy(opt, o, cplen);
|
|
|
|
if (cplen)
|
|
|
|
opt[1] = cplen;
|
|
|
|
|
|
|
|
return cplen;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
fsm_rej(struct fsm_decode *dec, const struct fsm_opt *o)
|
|
|
|
{
|
|
|
|
if (!dec)
|
|
|
|
return;
|
|
|
|
dec->rejend += fsm_opt(dec->rejend, FSM_OPTLEN - (dec->rejend - dec->rej), o);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
fsm_ack(struct fsm_decode *dec, const struct fsm_opt *o)
|
|
|
|
{
|
|
|
|
if (!dec)
|
|
|
|
return;
|
|
|
|
dec->ackend += fsm_opt(dec->ackend, FSM_OPTLEN - (dec->ackend - dec->ack), o);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
fsm_nak(struct fsm_decode *dec, const struct fsm_opt *o)
|
|
|
|
{
|
|
|
|
if (!dec)
|
|
|
|
return;
|
|
|
|
dec->nakend += fsm_opt(dec->nakend, FSM_OPTLEN - (dec->nakend - dec->nak), o);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
fsm_opt_normalise(struct fsm_decode *dec)
|
|
|
|
{
|
|
|
|
if (dec->rejend != dec->rej) {
|
|
|
|
/* rejects are preferred */
|
|
|
|
dec->ackend = dec->ack;
|
|
|
|
dec->nakend = dec->nak;
|
|
|
|
} else if (dec->nakend != dec->nak)
|
|
|
|
/* then NAKs */
|
|
|
|
dec->ackend = dec->ack;
|
|
|
|
}
|