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
|
|
|
*/
|
2001-06-13 21:52:19 +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-03-16 22:54:35 +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
|
|
|
|
2002-08-27 20:11:58 +00:00
|
|
|
#include <stdarg.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <stdio.h>
|
1998-03-17 22:29:12 +00:00
|
|
|
#include <stdlib.h>
|
1999-08-06 20:04:08 +00:00
|
|
|
#include <string.h> /* memcpy() on some archs */
|
1998-02-10 03:23:50 +00:00
|
|
|
#include <termios.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
#include "layer.h"
|
1998-06-15 19:06:25 +00:00
|
|
|
#include "defs.h"
|
1997-11-22 03:37:54 +00:00
|
|
|
#include "command.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "mbuf.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "timer.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "fsm.h"
|
1999-05-08 11:07:56 +00:00
|
|
|
#include "proto.h"
|
1996-01-11 17:48:59 +00:00
|
|
|
#include "pred.h"
|
1997-12-03 10:23:54 +00:00
|
|
|
#include "deflate.h"
|
1998-03-13 21:07:46 +00:00
|
|
|
#include "throughput.h"
|
|
|
|
#include "iplist.h"
|
1998-03-16 22:54:35 +00:00
|
|
|
#include "slcompress.h"
|
1998-08-26 17:39:37 +00:00
|
|
|
#include "lqr.h"
|
|
|
|
#include "hdlc.h"
|
2000-07-19 02:10:35 +00:00
|
|
|
#include "lcp.h"
|
|
|
|
#include "ccp.h"
|
2001-08-14 16:05:52 +00:00
|
|
|
#include "ncpaddr.h"
|
1998-03-13 21:07:46 +00:00
|
|
|
#include "ipcp.h"
|
1998-03-16 22:52:54 +00:00
|
|
|
#include "filter.h"
|
1998-02-10 03:23:50 +00:00
|
|
|
#include "descriptor.h"
|
|
|
|
#include "prompt.h"
|
1998-02-21 01:45:26 +00:00
|
|
|
#include "link.h"
|
1998-04-03 19:21:56 +00:00
|
|
|
#include "mp.h"
|
1998-04-24 19:15:26 +00:00
|
|
|
#include "async.h"
|
|
|
|
#include "physical.h"
|
1999-01-28 01:56:34 +00:00
|
|
|
#ifndef NORADIUS
|
|
|
|
#include "radius.h"
|
|
|
|
#endif
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
2000-10-30 00:15:04 +00:00
|
|
|
#include "mppe.h"
|
|
|
|
#endif
|
2001-08-14 16:05:52 +00:00
|
|
|
#include "ipv6cp.h"
|
|
|
|
#include "ncp.h"
|
1998-04-03 19:21:56 +00:00
|
|
|
#include "bundle.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
static void CcpSendConfigReq(struct fsm *);
|
1998-03-20 19:47:10 +00:00
|
|
|
static void CcpSentTerminateReq(struct fsm *);
|
|
|
|
static void CcpSendTerminateAck(struct fsm *, u_char);
|
2002-04-16 23:57:09 +00:00
|
|
|
static void CcpDecodeConfig(struct fsm *, u_char *, u_char *, int,
|
1998-03-13 21:08:05 +00:00
|
|
|
struct fsm_decode *);
|
1997-06-09 03:27:43 +00:00
|
|
|
static void CcpLayerStart(struct fsm *);
|
|
|
|
static void CcpLayerFinish(struct fsm *);
|
1998-04-30 23:53:56 +00:00
|
|
|
static int CcpLayerUp(struct fsm *);
|
1997-06-09 03:27:43 +00:00
|
|
|
static void CcpLayerDown(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 CcpInitRestartCounter(struct fsm *, int);
|
2001-06-18 15:00:22 +00:00
|
|
|
static int CcpRecvResetReq(struct fsm *);
|
1998-02-21 01:45:26 +00:00
|
|
|
static void CcpRecvResetAck(struct fsm *, u_char);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-02-06 02:24:29 +00:00
|
|
|
static struct fsm_callbacks ccp_Callbacks = {
|
1995-01-31 06:29:58 +00:00
|
|
|
CcpLayerUp,
|
|
|
|
CcpLayerDown,
|
|
|
|
CcpLayerStart,
|
|
|
|
CcpLayerFinish,
|
|
|
|
CcpInitRestartCounter,
|
|
|
|
CcpSendConfigReq,
|
1998-03-20 19:47:10 +00:00
|
|
|
CcpSentTerminateReq,
|
1995-01-31 06:29:58 +00:00
|
|
|
CcpSendTerminateAck,
|
|
|
|
CcpDecodeConfig,
|
1998-02-21 01:45:26 +00:00
|
|
|
CcpRecvResetReq,
|
|
|
|
CcpRecvResetAck
|
1995-01-31 06:29:58 +00:00
|
|
|
};
|
|
|
|
|
1999-12-27 11:54:57 +00:00
|
|
|
static const char * const ccp_TimerNames[] =
|
1998-04-30 23:53:56 +00:00
|
|
|
{"CCP restart", "CCP openmode", "CCP stopped"};
|
|
|
|
|
1997-12-03 10:23:54 +00:00
|
|
|
static const char *
|
|
|
|
protoname(int proto)
|
|
|
|
{
|
2000-03-14 01:46:54 +00:00
|
|
|
static char const * const cftypes[] = {
|
|
|
|
/* Check out the latest ``Compression Control Protocol'' rfc (1962) */
|
|
|
|
"OUI", /* 0: OUI */
|
|
|
|
"PRED1", /* 1: Predictor type 1 */
|
|
|
|
"PRED2", /* 2: Predictor type 2 */
|
|
|
|
"PUDDLE", /* 3: Puddle Jumber */
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
"HWPPC", /* 16: Hewlett-Packard PPC */
|
|
|
|
"STAC", /* 17: Stac Electronics LZS (rfc1974) */
|
2000-10-30 00:15:04 +00:00
|
|
|
"MPPE", /* 18: Microsoft PPC (rfc2118) and */
|
|
|
|
/* Microsoft PPE (draft-ietf-pppext-mppe) */
|
2000-03-14 01:46:54 +00:00
|
|
|
"GAND", /* 19: Gandalf FZA (rfc1993) */
|
|
|
|
"V42BIS", /* 20: ARG->DATA.42bis compression */
|
|
|
|
"BSD", /* 21: BSD LZW Compress */
|
|
|
|
NULL,
|
|
|
|
"LZS-DCP", /* 23: LZS-DCP Compression Protocol (rfc1967) */
|
|
|
|
"MAGNALINK/DEFLATE",/* 24: Magnalink Variable Resource (rfc1975) */
|
|
|
|
/* 24: Deflate (according to pppd-2.3.*) */
|
|
|
|
"DCE", /* 25: Data Circuit-Terminating Equip (rfc1976) */
|
|
|
|
"DEFLATE", /* 26: Deflate (rfc1979) */
|
|
|
|
};
|
|
|
|
|
2004-09-05 01:46:52 +00:00
|
|
|
if (proto < 0 || (unsigned)proto > sizeof cftypes / sizeof *cftypes ||
|
2001-11-03 19:29:30 +00:00
|
|
|
cftypes[proto] == NULL) {
|
|
|
|
if (proto == -1)
|
|
|
|
return "none";
|
2000-03-14 01:46:54 +00:00
|
|
|
return HexStr(proto, NULL, 0);
|
2001-11-03 19:29:30 +00:00
|
|
|
}
|
2000-03-14 01:46:54 +00:00
|
|
|
|
1997-12-03 10:23:54 +00:00
|
|
|
return cftypes[proto];
|
|
|
|
}
|
|
|
|
|
1997-12-03 23:28:02 +00:00
|
|
|
/* We support these algorithms, and Req them in the given order */
|
1999-12-27 11:54:57 +00:00
|
|
|
static const struct ccp_algorithm * const algorithm[] = {
|
1997-12-03 23:28:02 +00:00
|
|
|
&DeflateAlgorithm,
|
1997-12-03 10:23:54 +00:00
|
|
|
&Pred1Algorithm,
|
1997-12-03 23:28:02 +00:00
|
|
|
&PppdDeflateAlgorithm
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
2000-10-30 00:15:04 +00:00
|
|
|
, &MPPEAlgorithm
|
|
|
|
#endif
|
1997-12-03 10:23:54 +00:00
|
|
|
};
|
|
|
|
|
1997-12-24 09:29:17 +00:00
|
|
|
#define NALGORITHMS (sizeof algorithm/sizeof algorithm[0])
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1997-05-10 01:22:19 +00:00
|
|
|
int
|
1998-02-21 01:45:26 +00:00
|
|
|
ccp_ReportStatus(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
2001-06-18 15:00:22 +00:00
|
|
|
struct ccp_opt **o;
|
1998-05-15 23:58:30 +00:00
|
|
|
struct link *l;
|
|
|
|
struct ccp *ccp;
|
2001-06-18 15:00:22 +00:00
|
|
|
int f;
|
1998-05-15 23:58:30 +00:00
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
l = command_ChooseLink(arg);
|
1998-05-15 23:58:30 +00:00
|
|
|
ccp = &l->ccp;
|
1998-02-21 01:45:26 +00:00
|
|
|
|
1998-04-03 19:26:02 +00:00
|
|
|
prompt_Printf(arg->prompt, "%s: %s [%s]\n", l->name, ccp->fsm.name,
|
1998-03-24 18:47:32 +00:00
|
|
|
State2Nam(ccp->fsm.state));
|
1999-05-08 11:07:56 +00:00
|
|
|
if (ccp->fsm.state == ST_OPENED) {
|
|
|
|
prompt_Printf(arg->prompt, " My protocol = %s, His protocol = %s\n",
|
|
|
|
protoname(ccp->my_proto), protoname(ccp->his_proto));
|
|
|
|
prompt_Printf(arg->prompt, " Output: %ld --> %ld, Input: %ld --> %ld\n",
|
|
|
|
ccp->uncompout, ccp->compout,
|
|
|
|
ccp->compin, ccp->uncompin);
|
|
|
|
}
|
1998-04-03 19:24:07 +00:00
|
|
|
|
2001-06-18 15:00:22 +00:00
|
|
|
if (ccp->in.algorithm != -1)
|
|
|
|
prompt_Printf(arg->prompt, "\n Input Options: %s\n",
|
|
|
|
(*algorithm[ccp->in.algorithm]->Disp)(&ccp->in.opt));
|
|
|
|
|
|
|
|
if (ccp->out.algorithm != -1) {
|
|
|
|
o = &ccp->out.opt;
|
|
|
|
for (f = 0; f < ccp->out.algorithm; f++)
|
|
|
|
if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]))
|
|
|
|
o = &(*o)->next;
|
|
|
|
prompt_Printf(arg->prompt, " Output Options: %s\n",
|
|
|
|
(*algorithm[ccp->out.algorithm]->Disp)(&(*o)->val));
|
|
|
|
}
|
|
|
|
|
1998-04-03 19:26:02 +00:00
|
|
|
prompt_Printf(arg->prompt, "\n Defaults: ");
|
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
|
|
|
prompt_Printf(arg->prompt, "FSM retry = %us, max %u Config"
|
|
|
|
" REQ%s, %u Term REQ%s\n", ccp->cfg.fsm.timeout,
|
|
|
|
ccp->cfg.fsm.maxreq, ccp->cfg.fsm.maxreq == 1 ? "" : "s",
|
|
|
|
ccp->cfg.fsm.maxtrm, ccp->cfg.fsm.maxtrm == 1 ? "" : "s");
|
1998-04-16 00:26:21 +00:00
|
|
|
prompt_Printf(arg->prompt, " deflate windows: ");
|
1998-04-03 19:26:02 +00:00
|
|
|
prompt_Printf(arg->prompt, "incoming = %d, ", ccp->cfg.deflate.in.winsize);
|
|
|
|
prompt_Printf(arg->prompt, "outgoing = %d\n", ccp->cfg.deflate.out.winsize);
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
2001-06-18 15:00:22 +00:00
|
|
|
prompt_Printf(arg->prompt, " MPPE: ");
|
|
|
|
if (ccp->cfg.mppe.keybits)
|
|
|
|
prompt_Printf(arg->prompt, "%d bits, ", ccp->cfg.mppe.keybits);
|
|
|
|
else
|
|
|
|
prompt_Printf(arg->prompt, "any bits, ");
|
|
|
|
switch (ccp->cfg.mppe.state) {
|
|
|
|
case MPPE_STATEFUL:
|
2001-07-06 23:45:32 +00:00
|
|
|
prompt_Printf(arg->prompt, "stateful");
|
2001-06-18 15:00:22 +00:00
|
|
|
break;
|
|
|
|
case MPPE_STATELESS:
|
|
|
|
prompt_Printf(arg->prompt, "stateless");
|
|
|
|
break;
|
|
|
|
case MPPE_ANYSTATE:
|
|
|
|
prompt_Printf(arg->prompt, "any state");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
prompt_Printf(arg->prompt, "%s\n",
|
|
|
|
ccp->cfg.mppe.required ? ", required" : "");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
prompt_Printf(arg->prompt, "\n DEFLATE: %s\n",
|
1998-04-16 00:26:21 +00:00
|
|
|
command_ShowNegval(ccp->cfg.neg[CCP_NEG_DEFLATE]));
|
|
|
|
prompt_Printf(arg->prompt, " PREDICTOR1: %s\n",
|
|
|
|
command_ShowNegval(ccp->cfg.neg[CCP_NEG_PRED1]));
|
|
|
|
prompt_Printf(arg->prompt, " DEFLATE24: %s\n",
|
|
|
|
command_ShowNegval(ccp->cfg.neg[CCP_NEG_DEFLATE24]));
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
2001-06-18 15:00:22 +00:00
|
|
|
prompt_Printf(arg->prompt, " MPPE: %s\n",
|
2000-10-30 00:15:04 +00:00
|
|
|
command_ShowNegval(ccp->cfg.neg[CCP_NEG_MPPE]));
|
|
|
|
#endif
|
1997-05-10 01:22:19 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1998-04-30 23:53:56 +00:00
|
|
|
void
|
|
|
|
ccp_SetupCallbacks(struct ccp *ccp)
|
|
|
|
{
|
|
|
|
ccp->fsm.fn = &ccp_Callbacks;
|
|
|
|
ccp->fsm.FsmTimer.name = ccp_TimerNames[0];
|
|
|
|
ccp->fsm.OpenTimer.name = ccp_TimerNames[1];
|
|
|
|
ccp->fsm.StoppedTimer.name = ccp_TimerNames[2];
|
|
|
|
}
|
|
|
|
|
1998-01-29 00:44:16 +00:00
|
|
|
void
|
1998-02-27 01:22:39 +00:00
|
|
|
ccp_Init(struct ccp *ccp, struct bundle *bundle, struct link *l,
|
|
|
|
const struct fsm_parent *parent)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-01-31 02:48:30 +00:00
|
|
|
/* Initialise ourselves */
|
1998-04-03 19:21:56 +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
|
|
|
fsm_Init(&ccp->fsm, "CCP", PROTO_CCP, 1, CCP_MAXCODE, LogCCP,
|
1998-04-30 23:53:56 +00:00
|
|
|
bundle, l, parent, &ccp_Callbacks, ccp_TimerNames);
|
1998-04-03 19:24:07 +00:00
|
|
|
|
1998-03-17 22:29:12 +00:00
|
|
|
ccp->cfg.deflate.in.winsize = 0;
|
|
|
|
ccp->cfg.deflate.out.winsize = 15;
|
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
|
|
|
ccp->cfg.fsm.timeout = DEF_FSMRETRY;
|
|
|
|
ccp->cfg.fsm.maxreq = DEF_FSMTRIES;
|
|
|
|
ccp->cfg.fsm.maxtrm = DEF_FSMTRIES;
|
1998-04-16 00:26:21 +00:00
|
|
|
ccp->cfg.neg[CCP_NEG_DEFLATE] = NEG_ENABLED|NEG_ACCEPTED;
|
|
|
|
ccp->cfg.neg[CCP_NEG_PRED1] = NEG_ENABLED|NEG_ACCEPTED;
|
|
|
|
ccp->cfg.neg[CCP_NEG_DEFLATE24] = 0;
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
2001-06-18 15:00:22 +00:00
|
|
|
ccp->cfg.mppe.keybits = 0;
|
|
|
|
ccp->cfg.mppe.state = MPPE_ANYSTATE;
|
|
|
|
ccp->cfg.mppe.required = 0;
|
2000-11-19 16:53:50 +00:00
|
|
|
ccp->cfg.neg[CCP_NEG_MPPE] = NEG_ENABLED|NEG_ACCEPTED;
|
2000-10-30 00:15:04 +00:00
|
|
|
#endif
|
1998-04-03 19:24:07 +00:00
|
|
|
|
1998-02-21 01:45:26 +00:00
|
|
|
ccp_Setup(ccp);
|
1997-12-04 18:49:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-02-21 01:45:26 +00:00
|
|
|
ccp_Setup(struct ccp *ccp)
|
1997-12-04 18:49:32 +00:00
|
|
|
{
|
1998-02-21 01:45:26 +00:00
|
|
|
/* Set ourselves up for a startup */
|
|
|
|
ccp->fsm.open_mode = 0;
|
|
|
|
ccp->his_proto = ccp->my_proto = -1;
|
|
|
|
ccp->reset_sent = ccp->last_reset = -1;
|
1998-03-17 22:29:12 +00:00
|
|
|
ccp->in.algorithm = ccp->out.algorithm = -1;
|
|
|
|
ccp->in.state = ccp->out.state = NULL;
|
2002-04-16 23:57:09 +00:00
|
|
|
ccp->in.opt.hdr.id = -1;
|
1998-03-17 22:29:12 +00:00
|
|
|
ccp->out.opt = NULL;
|
1998-02-21 01:45:26 +00:00
|
|
|
ccp->his_reject = ccp->my_reject = 0;
|
|
|
|
ccp->uncompout = ccp->compout = 0;
|
|
|
|
ccp->uncompin = ccp->compin = 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
2001-06-18 15:00:22 +00:00
|
|
|
/*
|
|
|
|
* Is ccp *REQUIRED* ?
|
|
|
|
* We ask each of the configured ccp protocols if they're required and
|
|
|
|
* return TRUE if they are.
|
|
|
|
*
|
|
|
|
* It's not possible for the peer to reject a required ccp protocol
|
|
|
|
* without our state machine bringing the supporting lcp layer down.
|
|
|
|
*
|
|
|
|
* If ccp is required but not open, the NCP layer should not push
|
|
|
|
* any data into the link.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ccp_Required(struct ccp *ccp)
|
|
|
|
{
|
2004-09-05 01:46:52 +00:00
|
|
|
unsigned f;
|
2001-06-18 15:00:22 +00:00
|
|
|
|
|
|
|
for (f = 0; f < NALGORITHMS; f++)
|
|
|
|
if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) &&
|
|
|
|
(*algorithm[f]->Required)(&ccp->fsm))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-07-03 22:20:19 +00:00
|
|
|
/*
|
|
|
|
* Report whether it's possible to increase a packet's size after
|
|
|
|
* compression (and by how much).
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ccp_MTUOverhead(struct ccp *ccp)
|
|
|
|
{
|
2001-07-07 13:12:07 +00:00
|
|
|
if (ccp->fsm.state == ST_OPENED && ccp->out.algorithm >= 0)
|
2001-07-03 22:20:19 +00:00
|
|
|
return algorithm[ccp->out.algorithm]->o.MTUOverhead;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1995-01-31 06:29:58 +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
|
|
|
CcpInitRestartCounter(struct fsm *fp, int what)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-01-31 02:48:30 +00:00
|
|
|
/* Set fsm timer load */
|
1998-04-03 19:24:07 +00:00
|
|
|
struct ccp *ccp = fsm2ccp(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
|
|
|
fp->FsmTimer.load = ccp->cfg.fsm.timeout * SECTICKS;
|
|
|
|
switch (what) {
|
|
|
|
case FSM_REQ_TIMER:
|
|
|
|
fp->restart = ccp->cfg.fsm.maxreq;
|
|
|
|
break;
|
|
|
|
case FSM_TRM_TIMER:
|
|
|
|
fp->restart = ccp->cfg.fsm.maxtrm;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fp->restart = 1;
|
|
|
|
break;
|
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-10-26 01:04:02 +00:00
|
|
|
CcpSendConfigReq(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-01-31 02:48:30 +00:00
|
|
|
/* Send config REQ please */
|
1998-02-08 11:05:01 +00:00
|
|
|
struct ccp *ccp = fsm2ccp(fp);
|
1998-03-17 22:29:12 +00:00
|
|
|
struct ccp_opt **o;
|
1998-03-13 21:08:05 +00:00
|
|
|
u_char *cp, buff[100];
|
2004-09-05 01:46:52 +00:00
|
|
|
unsigned f;
|
|
|
|
int alloc;
|
1998-01-29 00:44:16 +00:00
|
|
|
|
1998-03-13 21:08:05 +00:00
|
|
|
cp = buff;
|
1998-03-17 22:29:12 +00:00
|
|
|
o = &ccp->out.opt;
|
|
|
|
alloc = ccp->his_reject == 0 && ccp->out.opt == NULL;
|
1998-02-06 02:24:29 +00:00
|
|
|
ccp->my_proto = -1;
|
1998-03-17 22:29:12 +00:00
|
|
|
ccp->out.algorithm = -1;
|
1997-12-03 10:23:54 +00:00
|
|
|
for (f = 0; f < NALGORITHMS; f++)
|
1998-04-16 00:26:21 +00:00
|
|
|
if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) &&
|
2001-02-04 22:53:11 +00:00
|
|
|
!REJECTED(ccp, algorithm[f]->id) &&
|
|
|
|
(*algorithm[f]->Usable)(fp)) {
|
1998-04-19 03:41:01 +00:00
|
|
|
|
|
|
|
if (!alloc)
|
|
|
|
for (o = &ccp->out.opt; *o != NULL; o = &(*o)->next)
|
2004-09-05 01:46:52 +00:00
|
|
|
if ((*o)->val.hdr.id == algorithm[f]->id && (*o)->algorithm == (int)f)
|
1998-04-19 03:41:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (alloc || *o == NULL) {
|
2004-10-11 09:45:58 +00:00
|
|
|
if ((*o = (struct ccp_opt *)malloc(sizeof(struct ccp_opt))) == NULL) {
|
|
|
|
log_Printf(LogERROR, "%s: Not enough memory for CCP REQ !\n",
|
|
|
|
fp->link->name);
|
|
|
|
break;
|
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
(*o)->val.hdr.id = algorithm[f]->id;
|
|
|
|
(*o)->val.hdr.len = 2;
|
1998-03-17 22:29:12 +00:00
|
|
|
(*o)->next = NULL;
|
|
|
|
(*o)->algorithm = f;
|
2002-06-12 00:33:17 +00:00
|
|
|
(*algorithm[f]->o.OptInit)(fp->bundle, &(*o)->val, &ccp->cfg);
|
1998-03-17 22:29:12 +00:00
|
|
|
}
|
1998-01-29 00:44:16 +00:00
|
|
|
|
2002-04-16 23:57:09 +00:00
|
|
|
if (cp + (*o)->val.hdr.len > buff + sizeof buff) {
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogERROR, "%s: CCP REQ buffer overrun !\n", fp->link->name);
|
1998-03-13 21:08:05 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
memcpy(cp, &(*o)->val, (*o)->val.hdr.len);
|
|
|
|
cp += (*o)->val.hdr.len;
|
1998-03-17 22:29:12 +00:00
|
|
|
|
2002-04-16 23:57:09 +00:00
|
|
|
ccp->my_proto = (*o)->val.hdr.id;
|
1998-03-17 22:29:12 +00:00
|
|
|
ccp->out.algorithm = f;
|
|
|
|
|
|
|
|
if (alloc)
|
|
|
|
o = &(*o)->next;
|
1997-12-03 10:23:54 +00:00
|
|
|
}
|
1998-03-20 19:47:10 +00:00
|
|
|
|
1999-06-02 15:59:09 +00:00
|
|
|
fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, cp - buff, MB_CCPOUT);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
ccp_SendResetReq(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-01-31 02:48:30 +00:00
|
|
|
/* We can't read our input - ask peer to reset */
|
1998-02-08 11:05:01 +00:00
|
|
|
struct ccp *ccp = fsm2ccp(fp);
|
1998-03-20 19:47:10 +00:00
|
|
|
|
1998-02-06 02:24:29 +00:00
|
|
|
ccp->reset_sent = fp->reqid;
|
|
|
|
ccp->last_reset = -1;
|
1999-06-02 15:59:09 +00:00
|
|
|
fsm_Output(fp, CODE_RESETREQ, fp->reqid, NULL, 0, MB_CCPOUT);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-09-05 01:46:52 +00:00
|
|
|
CcpSentTerminateReq(struct fsm *fp __unused)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-01-31 02:48:30 +00:00
|
|
|
/* Term REQ just sent by FSM */
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-03-20 19:47:10 +00:00
|
|
|
CcpSendTerminateAck(struct fsm *fp, u_char id)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-01-31 02:48:30 +00:00
|
|
|
/* Send Term ACK please */
|
1999-06-02 15:59:09 +00:00
|
|
|
fsm_Output(fp, CODE_TERMACK, id, NULL, 0, MB_CCPOUT);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
2001-06-18 15:00:22 +00:00
|
|
|
static int
|
1997-10-26 01:04:02 +00:00
|
|
|
CcpRecvResetReq(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-01-31 02:48:30 +00:00
|
|
|
/* Got a reset REQ, reset outgoing dictionary */
|
1998-02-08 11:05:01 +00:00
|
|
|
struct ccp *ccp = fsm2ccp(fp);
|
2001-06-18 15:00:22 +00:00
|
|
|
if (ccp->out.state == NULL)
|
|
|
|
return 1;
|
|
|
|
return (*algorithm[ccp->out.algorithm]->o.Reset)(ccp->out.state);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-10-26 01:04:02 +00:00
|
|
|
CcpLayerStart(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-01-31 02:48:30 +00:00
|
|
|
/* We're about to start up ! */
|
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
|
|
|
struct ccp *ccp = fsm2ccp(fp);
|
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogCCP, "%s: LayerStart.\n", fp->link->name);
|
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->more.reqs = fp->more.naks = fp->more.rejs = ccp->cfg.fsm.maxreq * 3;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-06-25 22:33:31 +00:00
|
|
|
CcpLayerDown(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-06-25 22:33:31 +00:00
|
|
|
/* About to come down */
|
1998-02-08 11:05:01 +00:00
|
|
|
struct ccp *ccp = fsm2ccp(fp);
|
1998-04-19 03:41:01 +00:00
|
|
|
struct ccp_opt *next;
|
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogCCP, "%s: LayerDown.\n", fp->link->name);
|
1998-03-17 22:29:12 +00:00
|
|
|
if (ccp->in.state != NULL) {
|
|
|
|
(*algorithm[ccp->in.algorithm]->i.Term)(ccp->in.state);
|
|
|
|
ccp->in.state = NULL;
|
1998-04-19 02:23:21 +00:00
|
|
|
ccp->in.algorithm = -1;
|
1998-01-31 02:48:30 +00:00
|
|
|
}
|
1998-03-17 22:29:12 +00:00
|
|
|
if (ccp->out.state != NULL) {
|
|
|
|
(*algorithm[ccp->out.algorithm]->o.Term)(ccp->out.state);
|
|
|
|
ccp->out.state = NULL;
|
1998-04-19 02:23:21 +00:00
|
|
|
ccp->out.algorithm = -1;
|
1998-01-31 02:48:30 +00:00
|
|
|
}
|
1998-04-19 02:23:21 +00:00
|
|
|
ccp->his_reject = ccp->my_reject = 0;
|
2002-06-15 08:03:30 +00:00
|
|
|
|
1998-04-19 03:41:01 +00:00
|
|
|
while (ccp->out.opt) {
|
|
|
|
next = ccp->out.opt->next;
|
|
|
|
free(ccp->out.opt);
|
|
|
|
ccp->out.opt = next;
|
|
|
|
}
|
1998-06-25 22:33:31 +00:00
|
|
|
ccp_Setup(ccp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-06-25 22:33:31 +00:00
|
|
|
CcpLayerFinish(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-06-25 22:33:31 +00:00
|
|
|
/* We're now down */
|
2000-11-07 04:29:33 +00:00
|
|
|
struct ccp *ccp = fsm2ccp(fp);
|
|
|
|
struct ccp_opt *next;
|
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogCCP, "%s: LayerFinish.\n", fp->link->name);
|
2000-11-07 04:29:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Nuke options that may be left over from sending a REQ but never
|
|
|
|
* coming up.
|
|
|
|
*/
|
|
|
|
while (ccp->out.opt) {
|
|
|
|
next = ccp->out.opt->next;
|
|
|
|
free(ccp->out.opt);
|
|
|
|
ccp->out.opt = next;
|
|
|
|
}
|
2001-06-18 15:00:22 +00:00
|
|
|
|
|
|
|
if (ccp_Required(ccp)) {
|
|
|
|
if (fp->link->lcp.fsm.state == ST_OPENED)
|
|
|
|
log_Printf(LogLCP, "%s: Closing due to CCP completion\n", fp->link->name);
|
|
|
|
fsm_Close(&fp->link->lcp.fsm);
|
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1999-05-09 20:02:29 +00:00
|
|
|
/* Called when CCP has reached the OPEN state */
|
1998-04-30 23:53:56 +00:00
|
|
|
static int
|
1997-10-26 01:04:02 +00:00
|
|
|
CcpLayerUp(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-01-31 02:48:30 +00:00
|
|
|
/* We're now up */
|
1998-02-08 11:05:01 +00:00
|
|
|
struct ccp *ccp = fsm2ccp(fp);
|
2000-11-07 04:29:33 +00:00
|
|
|
struct ccp_opt **o;
|
2004-09-05 01:46:52 +00:00
|
|
|
unsigned f, fail;
|
2001-07-03 22:20:19 +00:00
|
|
|
|
|
|
|
for (f = fail = 0; f < NALGORITHMS; f++)
|
|
|
|
if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) &&
|
|
|
|
(*algorithm[f]->Required)(&ccp->fsm) &&
|
2004-09-05 01:46:52 +00:00
|
|
|
(ccp->in.algorithm != (int)f || ccp->out.algorithm != (int)f)) {
|
2001-07-03 22:20:19 +00:00
|
|
|
/* Blow it all away - we haven't negotiated a required algorithm */
|
|
|
|
log_Printf(LogWARN, "%s: Failed to negotiate (required) %s\n",
|
|
|
|
fp->link->name, protoname(algorithm[f]->id));
|
|
|
|
fail = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fail) {
|
|
|
|
ccp->his_proto = ccp->my_proto = -1;
|
|
|
|
fsm_Close(fp);
|
|
|
|
fsm_Close(&fp->link->lcp.fsm);
|
|
|
|
return 0;
|
|
|
|
}
|
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
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogCCP, "%s: LayerUp.\n", fp->link->name);
|
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
|
|
|
|
1998-03-17 22:29:12 +00:00
|
|
|
if (ccp->in.state == NULL && ccp->in.algorithm >= 0 &&
|
2004-09-05 01:46:52 +00:00
|
|
|
ccp->in.algorithm < (int)NALGORITHMS) {
|
2002-06-12 00:33:17 +00:00
|
|
|
ccp->in.state = (*algorithm[ccp->in.algorithm]->i.Init)
|
|
|
|
(fp->bundle, &ccp->in.opt);
|
1998-03-17 22:29:12 +00:00
|
|
|
if (ccp->in.state == NULL) {
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogERROR, "%s: %s (in) initialisation failure\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, protoname(ccp->his_proto));
|
1998-02-06 02:24:29 +00:00
|
|
|
ccp->his_proto = ccp->my_proto = -1;
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Close(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
|
|
|
return 0;
|
1998-01-29 20:45:16 +00:00
|
|
|
}
|
1998-01-04 20:25:41 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
|
2000-11-07 04:29:33 +00:00
|
|
|
o = &ccp->out.opt;
|
2004-09-05 01:46:52 +00:00
|
|
|
if (ccp->out.algorithm > 0)
|
|
|
|
for (f = 0; f < (unsigned)ccp->out.algorithm; f++)
|
|
|
|
if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]))
|
|
|
|
o = &(*o)->next;
|
2000-11-07 04:29:33 +00:00
|
|
|
|
1998-03-17 22:29:12 +00:00
|
|
|
if (ccp->out.state == NULL && ccp->out.algorithm >= 0 &&
|
2004-09-05 01:46:52 +00:00
|
|
|
ccp->out.algorithm < (int)NALGORITHMS) {
|
2002-06-12 00:33:17 +00:00
|
|
|
ccp->out.state = (*algorithm[ccp->out.algorithm]->o.Init)
|
|
|
|
(fp->bundle, &(*o)->val);
|
1998-03-17 22:29:12 +00:00
|
|
|
if (ccp->out.state == NULL) {
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogERROR, "%s: %s (out) initialisation failure\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, protoname(ccp->my_proto));
|
1998-02-06 02:24:29 +00:00
|
|
|
ccp->his_proto = ccp->my_proto = -1;
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Close(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
|
|
|
return 0;
|
1997-12-03 10:23:54 +00:00
|
|
|
}
|
1998-03-17 22:29:12 +00:00
|
|
|
}
|
1997-12-03 10:23:54 +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
|
|
|
fp->more.reqs = fp->more.naks = fp->more.rejs = ccp->cfg.fsm.maxreq * 3;
|
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogCCP, "%s: Out = %s[%d], In = %s[%d]\n",
|
1998-04-24 19:15:48 +00:00
|
|
|
fp->link->name, protoname(ccp->my_proto), ccp->my_proto,
|
1998-02-06 02:24:29 +00:00
|
|
|
protoname(ccp->his_proto), ccp->his_proto);
|
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
|
|
|
|
1998-04-30 23:53:56 +00:00
|
|
|
return 1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-16 23:57:09 +00:00
|
|
|
CcpDecodeConfig(struct fsm *fp, u_char *cp, u_char *end, int mode_type,
|
1998-03-13 21:08:05 +00:00
|
|
|
struct fsm_decode *dec)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-01-31 02:48:30 +00:00
|
|
|
/* Deal with incoming data */
|
1998-02-08 11:05:01 +00:00
|
|
|
struct ccp *ccp = fsm2ccp(fp);
|
2002-04-16 23:57:09 +00:00
|
|
|
int f;
|
|
|
|
const char *disp;
|
|
|
|
struct fsm_opt *opt;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1999-05-02 14:33:39 +00:00
|
|
|
if (mode_type == MODE_REQ)
|
|
|
|
ccp->in.algorithm = -1; /* In case we've received two REQs in a row */
|
|
|
|
|
2004-09-05 01:46:52 +00:00
|
|
|
while (end >= cp + sizeof(opt->hdr)) {
|
2002-04-16 23:57:09 +00:00
|
|
|
if ((opt = fsm_readopt(&cp)) == NULL)
|
1998-04-24 19:15:48 +00:00
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
|
|
|
for (f = NALGORITHMS-1; f > -1; f--)
|
2002-04-16 23:57:09 +00:00
|
|
|
if (algorithm[f]->id == opt->hdr.id)
|
1997-12-03 10:23:54 +00:00
|
|
|
break;
|
|
|
|
|
2002-04-16 23:57:09 +00:00
|
|
|
disp = f == -1 ? "" : (*algorithm[f]->Disp)(opt);
|
|
|
|
if (disp == NULL)
|
|
|
|
disp = "";
|
1998-03-17 22:29:12 +00:00
|
|
|
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(LogCCP, " %s[%d] %s\n", protoname(opt->hdr.id),
|
|
|
|
opt->hdr.len, disp);
|
1998-03-17 22:29:12 +00:00
|
|
|
|
1997-12-03 10:23:54 +00:00
|
|
|
if (f == -1) {
|
|
|
|
/* Don't understand that :-( */
|
|
|
|
if (mode_type == MODE_REQ) {
|
2002-04-16 23:57:09 +00:00
|
|
|
ccp->my_reject |= (1 << opt->hdr.id);
|
|
|
|
fsm_rej(dec, opt);
|
1997-12-03 10:23:54 +00:00
|
|
|
}
|
|
|
|
} else {
|
1998-03-17 22:29:12 +00:00
|
|
|
struct ccp_opt *o;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-11-08 00:28:11 +00:00
|
|
|
switch (mode_type) {
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REQ:
|
2002-04-16 23:57:09 +00:00
|
|
|
if (IsAccepted(ccp->cfg.neg[algorithm[f]->Neg]) &&
|
2001-02-04 22:53:11 +00:00
|
|
|
(*algorithm[f]->Usable)(fp) &&
|
1998-04-16 00:26:21 +00:00
|
|
|
ccp->in.algorithm == -1) {
|
2002-04-16 23:57:09 +00:00
|
|
|
memcpy(&ccp->in.opt, opt, opt->hdr.len);
|
2002-06-12 00:33:17 +00:00
|
|
|
switch ((*algorithm[f]->i.Set)(fp->bundle, &ccp->in.opt, &ccp->cfg)) {
|
1997-12-03 10:23:54 +00:00
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_rej(dec, &ccp->in.opt);
|
1997-12-03 10:23:54 +00:00
|
|
|
break;
|
|
|
|
case MODE_NAK:
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_nak(dec, &ccp->in.opt);
|
1997-12-03 10:23:54 +00:00
|
|
|
break;
|
|
|
|
case MODE_ACK:
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_ack(dec, &ccp->in.opt);
|
|
|
|
ccp->his_proto = opt->hdr.id;
|
2004-09-05 01:46:52 +00:00
|
|
|
ccp->in.algorithm = (int)f; /* This one'll do :-) */
|
1997-12-03 10:23:54 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
} else {
|
|
|
|
fsm_rej(dec, opt);
|
|
|
|
}
|
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_NAK:
|
1998-03-17 22:29:12 +00:00
|
|
|
for (o = ccp->out.opt; o != NULL; o = o->next)
|
2002-04-16 23:57:09 +00:00
|
|
|
if (o->val.hdr.id == opt->hdr.id)
|
1998-03-17 22:29:12 +00:00
|
|
|
break;
|
|
|
|
if (o == NULL)
|
2000-10-30 00:15:29 +00:00
|
|
|
log_Printf(LogCCP, "%s: Warning: Ignoring peer NAK of unsent"
|
|
|
|
" option\n", fp->link->name);
|
1997-12-03 10:23:54 +00:00
|
|
|
else {
|
2002-04-16 23:57:09 +00:00
|
|
|
memcpy(&o->val, opt, opt->hdr.len);
|
2002-06-12 00:33:17 +00:00
|
|
|
if ((*algorithm[f]->o.Set)(fp->bundle, &o->val, &ccp->cfg) ==
|
|
|
|
MODE_ACK)
|
1998-03-17 22:29:12 +00:00
|
|
|
ccp->my_proto = algorithm[f]->id;
|
|
|
|
else {
|
2002-04-16 23:57:09 +00:00
|
|
|
ccp->his_reject |= (1 << opt->hdr.id);
|
|
|
|
ccp->my_proto = -1;
|
2001-06-18 15:00:22 +00:00
|
|
|
if (algorithm[f]->Required(fp)) {
|
|
|
|
log_Printf(LogWARN, "%s: Cannot understand peers (required)"
|
|
|
|
" %s negotiation\n", fp->link->name,
|
|
|
|
protoname(algorithm[f]->id));
|
|
|
|
fsm_Close(&fp->link->lcp.fsm);
|
|
|
|
}
|
1998-03-17 22:29:12 +00:00
|
|
|
}
|
1997-12-03 10:23:54 +00:00
|
|
|
}
|
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
ccp->his_reject |= (1 << opt->hdr.id);
|
|
|
|
ccp->my_proto = -1;
|
2001-06-18 15:00:22 +00:00
|
|
|
if (algorithm[f]->Required(fp)) {
|
|
|
|
log_Printf(LogWARN, "%s: Peer rejected (required) %s negotiation\n",
|
|
|
|
fp->link->name, protoname(algorithm[f]->id));
|
|
|
|
fsm_Close(&fp->link->lcp.fsm);
|
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1998-04-25 10:49:52 +00:00
|
|
|
if (mode_type != MODE_NOP) {
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_opt_normalise(dec);
|
|
|
|
if (dec->rejend != dec->rej || dec->nakend != dec->nak) {
|
1998-04-16 00:26:21 +00:00
|
|
|
if (ccp->in.state == NULL) {
|
|
|
|
ccp->his_proto = -1;
|
|
|
|
ccp->in.algorithm = -1;
|
|
|
|
}
|
1998-01-29 20:45:16 +00:00
|
|
|
}
|
1997-12-03 10:23:54 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
extern struct mbuf *
|
|
|
|
ccp_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-01-31 02:48:30 +00:00
|
|
|
/* Got PROTO_CCP from link */
|
1999-12-20 20:29:47 +00:00
|
|
|
m_settype(bp, MB_CCPIN);
|
1998-02-07 20:50:08 +00:00
|
|
|
if (bundle_Phase(bundle) == PHASE_NETWORK)
|
1999-05-08 11:07:56 +00:00
|
|
|
fsm_Input(&l->ccp.fsm, bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
else {
|
1998-05-21 01:26:10 +00:00
|
|
|
if (bundle_Phase(bundle) < PHASE_NETWORK)
|
|
|
|
log_Printf(LogCCP, "%s: Error: Unexpected CCP in phase %s (ignored)\n",
|
1999-05-08 11:07:56 +00:00
|
|
|
l->ccp.fsm.link->name, bundle_PhaseName(bundle));
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1999-05-08 11:07:56 +00:00
|
|
|
return NULL;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1998-02-21 01:45:26 +00:00
|
|
|
static void
|
|
|
|
CcpRecvResetAck(struct fsm *fp, u_char id)
|
1997-12-03 10:23:54 +00:00
|
|
|
{
|
1998-01-31 02:48:30 +00:00
|
|
|
/* Got a reset ACK, reset incoming dictionary */
|
1998-02-23 00:38:44 +00:00
|
|
|
struct ccp *ccp = fsm2ccp(fp);
|
|
|
|
|
|
|
|
if (ccp->reset_sent != -1) {
|
|
|
|
if (id != ccp->reset_sent) {
|
1999-03-11 01:49:15 +00:00
|
|
|
log_Printf(LogCCP, "%s: Incorrect ResetAck (id %d, not %d)"
|
1998-04-24 19:15:48 +00:00
|
|
|
" ignored\n", fp->link->name, id, ccp->reset_sent);
|
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
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Whaddaya know - a correct reset ack */
|
1998-02-23 00:38:44 +00:00
|
|
|
} else if (id == ccp->last_reset)
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogCCP, "%s: Duplicate ResetAck (resetting again)\n",
|
1999-03-11 01:49:15 +00:00
|
|
|
fp->link->name);
|
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
|
|
|
else {
|
1999-03-11 01:49:15 +00:00
|
|
|
log_Printf(LogCCP, "%s: Unexpected ResetAck (id %d) ignored\n",
|
|
|
|
fp->link->name, id);
|
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
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-02-23 00:38:44 +00:00
|
|
|
ccp->last_reset = ccp->reset_sent;
|
|
|
|
ccp->reset_sent = -1;
|
1998-03-17 22:29:12 +00:00
|
|
|
if (ccp->in.state != NULL)
|
|
|
|
(*algorithm[ccp->in.algorithm]->i.Reset)(ccp->in.state);
|
1997-12-03 10:23:54 +00:00
|
|
|
}
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
static struct mbuf *
|
2004-09-05 01:46:52 +00:00
|
|
|
ccp_LayerPush(struct bundle *b __unused, struct link *l, struct mbuf *bp,
|
1999-05-08 11:07:56 +00:00
|
|
|
int pri, u_short *proto)
|
1997-12-03 10:23:54 +00:00
|
|
|
{
|
2001-06-18 15:00:22 +00:00
|
|
|
if (PROTO_COMPRESSIBLE(*proto)) {
|
|
|
|
if (l->ccp.fsm.state != ST_OPENED) {
|
|
|
|
if (ccp_Required(&l->ccp)) {
|
|
|
|
/* The NCP layer shouldn't have let this happen ! */
|
|
|
|
log_Printf(LogERROR, "%s: Unexpected attempt to use an unopened and"
|
|
|
|
" required CCP layer\n", l->name);
|
|
|
|
m_freem(bp);
|
|
|
|
bp = NULL;
|
|
|
|
}
|
|
|
|
} else if (l->ccp.out.state != NULL) {
|
|
|
|
bp = (*algorithm[l->ccp.out.algorithm]->o.Write)
|
|
|
|
(l->ccp.out.state, &l->ccp, l, pri, proto, bp);
|
|
|
|
switch (*proto) {
|
|
|
|
case PROTO_ICOMPD:
|
|
|
|
m_settype(bp, MB_ICOMPDOUT);
|
|
|
|
break;
|
|
|
|
case PROTO_COMPD:
|
|
|
|
m_settype(bp, MB_COMPDOUT);
|
|
|
|
break;
|
|
|
|
}
|
1999-06-02 15:59:09 +00:00
|
|
|
}
|
|
|
|
}
|
1999-05-08 11:07:56 +00:00
|
|
|
|
|
|
|
return bp;
|
1997-12-03 10:23:54 +00:00
|
|
|
}
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
static struct mbuf *
|
2004-09-05 01:46:52 +00:00
|
|
|
ccp_LayerPull(struct bundle *b __unused, struct link *l, struct mbuf *bp,
|
|
|
|
u_short *proto)
|
1997-12-03 10:23:54 +00:00
|
|
|
{
|
1998-02-18 19:36:13 +00:00
|
|
|
/*
|
1998-04-24 19:15:26 +00:00
|
|
|
* If proto isn't PROTO_[I]COMPD, we still want to pass it to the
|
1998-02-18 19:36:13 +00:00
|
|
|
* decompression routines so that the dictionary's updated
|
|
|
|
*/
|
1999-05-08 11:07:56 +00:00
|
|
|
if (l->ccp.fsm.state == ST_OPENED) {
|
1998-04-24 19:15:26 +00:00
|
|
|
if (*proto == PROTO_COMPD || *proto == PROTO_ICOMPD) {
|
1998-02-18 19:36:13 +00:00
|
|
|
/* Decompress incoming data */
|
1999-05-08 11:07:56 +00:00
|
|
|
if (l->ccp.reset_sent != -1)
|
1998-02-18 19:36:13 +00:00
|
|
|
/* Send another REQ and put the packet in the bit bucket */
|
1999-06-02 15:59:09 +00:00
|
|
|
fsm_Output(&l->ccp.fsm, CODE_RESETREQ, l->ccp.reset_sent, NULL, 0,
|
|
|
|
MB_CCPOUT);
|
|
|
|
else if (l->ccp.in.state != NULL) {
|
|
|
|
bp = (*algorithm[l->ccp.in.algorithm]->i.Read)
|
|
|
|
(l->ccp.in.state, &l->ccp, proto, bp);
|
|
|
|
switch (*proto) {
|
|
|
|
case PROTO_ICOMPD:
|
1999-12-20 20:29:47 +00:00
|
|
|
m_settype(bp, MB_ICOMPDIN);
|
1999-06-02 15:59:09 +00:00
|
|
|
break;
|
|
|
|
case PROTO_COMPD:
|
1999-12-20 20:29:47 +00:00
|
|
|
m_settype(bp, MB_COMPDIN);
|
1999-06-02 15:59:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return bp;
|
|
|
|
}
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1998-02-18 19:36:13 +00:00
|
|
|
bp = NULL;
|
1999-05-12 09:49:12 +00:00
|
|
|
} else if (PROTO_COMPRESSIBLE(*proto) && l->ccp.in.state != NULL) {
|
1998-02-18 19:36:13 +00:00
|
|
|
/* Add incoming Network Layer traffic to our dictionary */
|
1999-05-08 11:07:56 +00:00
|
|
|
(*algorithm[l->ccp.in.algorithm]->i.DictSetup)
|
|
|
|
(l->ccp.in.state, &l->ccp, *proto, bp);
|
2002-07-02 00:12:24 +00:00
|
|
|
}
|
1998-04-25 10:49:52 +00:00
|
|
|
}
|
1998-02-18 19:36:13 +00:00
|
|
|
|
|
|
|
return bp;
|
1997-12-03 10:23:54 +00:00
|
|
|
}
|
|
|
|
|
1998-04-24 19:15:26 +00:00
|
|
|
u_short
|
|
|
|
ccp_Proto(struct ccp *ccp)
|
1997-12-03 10:23:54 +00:00
|
|
|
{
|
1998-04-24 19:15:26 +00:00
|
|
|
return !link2physical(ccp->fsm.link) || !ccp->fsm.bundle->ncp.mp.active ?
|
|
|
|
PROTO_COMPD : PROTO_ICOMPD;
|
1997-12-03 10:23:54 +00:00
|
|
|
}
|
1998-05-23 13:38:09 +00:00
|
|
|
|
1998-06-30 23:04:17 +00:00
|
|
|
int
|
1998-05-23 13:38:09 +00:00
|
|
|
ccp_SetOpenMode(struct ccp *ccp)
|
|
|
|
{
|
|
|
|
int f;
|
|
|
|
|
|
|
|
for (f = 0; f < CCP_NEG_TOTAL; f++)
|
1998-06-30 23:04:17 +00:00
|
|
|
if (IsEnabled(ccp->cfg.neg[f])) {
|
1998-05-23 13:38:09 +00:00
|
|
|
ccp->fsm.open_mode = 0;
|
1998-06-30 23:04:17 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ccp->fsm.open_mode = OPEN_PASSIVE; /* Go straight to ST_STOPPED ? */
|
|
|
|
|
|
|
|
for (f = 0; f < CCP_NEG_TOTAL; f++)
|
|
|
|
if (IsAccepted(ccp->cfg.neg[f]))
|
|
|
|
return 1;
|
1998-05-23 13:38:09 +00:00
|
|
|
|
1998-06-30 23:04:17 +00:00
|
|
|
return 0; /* No CCP at all */
|
1998-05-23 13:38:09 +00:00
|
|
|
}
|
1999-05-08 11:07:56 +00:00
|
|
|
|
2001-02-04 22:53:11 +00:00
|
|
|
int
|
2004-09-05 01:46:52 +00:00
|
|
|
ccp_DefaultUsable(struct fsm *fp __unused)
|
2001-02-04 22:53:11 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-06-18 15:00:22 +00:00
|
|
|
int
|
2004-09-05 01:46:52 +00:00
|
|
|
ccp_DefaultRequired(struct fsm *fp __unused)
|
2001-06-18 15:00:22 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
struct layer ccplayer = { LAYER_CCP, "ccp", ccp_LayerPush, ccp_LayerPull };
|