Fix the CCP Type field value for DEFLATE.

(I *really* meant to do this  *before* committing the
deflate changes in the first place - oops).

Pppd is horribly broken in this respect - refer to the
ppp man page for details.  Ppp *WON'T* negotiate deflate
with pppd by default - you must ``enable'' and ``accept''
``pppd-deflate'' in your config.

While I'm in there, update the cftypes in ccp.c so that
we recognise some more protocols (we don't actually do
anything with them - just send a REJ).
This commit is contained in:
brian 1997-12-03 23:28:02 +00:00
parent 4060d58634
commit 0d728a9573
8 changed files with 206 additions and 51 deletions

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ccp.c,v 1.20 1997/11/22 03:37:25 brian Exp $
* $Id: ccp.c,v 1.21 1997/12/03 10:23:44 brian Exp $
*
* TODO:
* o Support other compression protocols
@ -80,21 +80,24 @@ struct fsm CcpFsm = {
static char const *cftypes[] = {
/* Check out the latest ``Compression Control Protocol'' rfc (rfc1962.txt) */
"OUI", /* 0: OUI */
"PRED1", /* 1: Predictor type 1 */
"PRED2", /* 2: Predictor type 2 */
"PUDDLE", /* 3: Puddle Jumber */
"???", "???", "???", "???", "???", "???",
"???", "???", "???", "???", "???", "???",
"HWPPC", /* 16: Hewlett-Packard PPC */
"STAC", /* 17: Stac Electronics LZS */
"MSPPC", /* 18: Microsoft PPC */
"GAND", /* 19: Gandalf FZA */
"V42BIS", /* 20: ARG->DATA.42bis compression */
"BSD", /* 21: BSD LZW Compress */
"???",
"???",
"DEFLATE", /* 24: PPP Deflate */
"OUI", /* 0: OUI */
"PRED1", /* 1: Predictor type 1 */
"PRED2", /* 2: Predictor type 2 */
"PUDDLE", /* 3: Puddle Jumber */
"???", "???", "???", "???", "???", "???",
"???", "???", "???", "???", "???", "???",
"HWPPC", /* 16: Hewlett-Packard PPC */
"STAC", /* 17: Stac Electronics LZS (rfc1974) */
"MSPPC", /* 18: Microsoft PPC */
"GAND", /* 19: Gandalf FZA (rfc1993) */
"V42BIS", /* 20: ARG->DATA.42bis compression */
"BSD", /* 21: BSD LZW Compress */
"???",
"LZS-DCP", /* 23: LZS-DCP Compression Protocol (rfc1967) */
"MAGNALINK/DEFLATE", /* 24: Magnalink Variable Resource (rfc1975) */
/* 24: Deflate (according to pppd-2.3.1) */
"DCE", /* 25: Data Circuit-Terminating Equip (rfc1976) */
"DEFLATE", /* 26: Deflate (rfc1979) */
};
#define NCFTYPES (sizeof(cftypes)/sizeof(char *))
@ -107,9 +110,11 @@ protoname(int proto)
return cftypes[proto];
}
/* We support these algorithms, and Req them in the given order */
static const struct ccp_algorithm *algorithm[] = {
&DeflateAlgorithm,
&Pred1Algorithm,
&DeflateAlgorithm
&PppdDeflateAlgorithm
};
static int in_algorithm = -1;

View File

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ccp.h,v 1.9 1997/11/22 03:37:25 brian Exp $
* $Id: ccp.h,v 1.10 1997/12/03 10:23:45 brian Exp $
*
* TODO:
*/
@ -32,7 +32,8 @@
#define TY_GAND 19 /* Gandalf FZA */
#define TY_V42BIS 20 /* V.42bis compression */
#define TY_BSD 21 /* BSD LZW Compress */
#define TY_DEFLATE 24 /* Deflate (gzip) */
#define TY_PPPD_DEFLATE 24 /* Deflate (gzip) - (mis) numbered by pppd */
#define TY_DEFLATE 26 /* Deflate (gzip) - rfc 1979 */
struct ccpstate {
u_long his_proto; /* peer's compression protocol */

View File

@ -1,5 +1,5 @@
/*
* $Id$
* $Id: deflate.c,v 1.1 1997/12/03 10:23:45 brian Exp $
*/
#include <sys/param.h>
@ -343,6 +343,8 @@ DeflateDictSetup(u_short proto, struct mbuf *mi)
break; /* Done */
LogPrintf(LogERROR, "DeflateDictSetup: inflate returned %d (%s)\n",
res, InputState.cx.msg ? InputState.cx.msg : "");
LogPrintf(LogERROR, "DeflateDictSetup: avail_in %d, avail_out %d\n",
InputState.cx.avail_in, InputState.cx.avail_out);
CcpSendResetReq(&CcpFsm);
mbfree(mi_head); /* lose our allocated ``head'' buf */
return;
@ -383,39 +385,50 @@ DeflateDispOpts(struct lcp_opt *o)
}
static void
DeflateGetOpts(struct lcp_opt *o)
DeflateGetInputOpts(struct lcp_opt *o)
{
o->id = TY_DEFLATE;
o->len = 4;
o->data[1] = '\0';
}
static void
DeflateGetInputOpts(struct lcp_opt *o)
{
DeflateGetOpts(o);
o->data[0] = ((iWindowSize-8)<<4)+8;
o->data[1] = '\0';
}
static void
DeflateGetOutputOpts(struct lcp_opt *o)
{
DeflateGetOpts(o);
o->id = TY_DEFLATE;
o->len = 4;
o->data[0] = ((oWindowSize-8)<<4)+8;
o->data[1] = '\0';
}
static void
PppdDeflateGetInputOpts(struct lcp_opt *o)
{
o->id = TY_PPPD_DEFLATE;
o->len = 4;
o->data[0] = ((iWindowSize-8)<<4)+8;
o->data[1] = '\0';
}
static void
PppdDeflateGetOutputOpts(struct lcp_opt *o)
{
o->id = TY_PPPD_DEFLATE;
o->len = 4;
o->data[0] = ((oWindowSize-8)<<4)+8;
o->data[1] = '\0';
}
static int
DeflateSetOpts(struct lcp_opt *o, int *sz)
{
if (o->id != TY_DEFLATE || o->len != 4 ||
(o->data[0]&15) != 8 || o->data[1] != '\0') {
DeflateGetOpts(o);
if (o->len != 4 || (o->data[0]&15) != 8 || o->data[1] != '\0') {
return MODE_REJ;
}
*sz = (o->data[0] >> 4) + 8;
if (*sz > 15) {
*sz = 15;
DeflateGetOpts(o);
return MODE_NAK;
}
@ -425,13 +438,41 @@ DeflateSetOpts(struct lcp_opt *o, int *sz)
static int
DeflateSetInputOpts(struct lcp_opt *o)
{
return DeflateSetOpts(o, &iWindowSize);
int res;
res = DeflateSetOpts(o, &iWindowSize);
if (res != MODE_ACK)
DeflateGetInputOpts(o);
return res;
}
static int
DeflateSetOutputOpts(struct lcp_opt *o)
{
return DeflateSetOpts(o, &oWindowSize);
int res;
res = DeflateSetOpts(o, &oWindowSize);
if (res != MODE_ACK)
DeflateGetOutputOpts(o);
return res;
}
static int
PppdDeflateSetInputOpts(struct lcp_opt *o)
{
int res;
res = DeflateSetOpts(o, &iWindowSize);
if (res != MODE_ACK)
PppdDeflateGetInputOpts(o);
return res;
}
static int
PppdDeflateSetOutputOpts(struct lcp_opt *o)
{
int res;
res = DeflateSetOpts(o, &oWindowSize);
if (res != MODE_ACK)
PppdDeflateGetOutputOpts(o);
return res;
}
static int
@ -475,8 +516,31 @@ DeflateTermOutput(void)
deflateEnd(&OutputState.cx);
}
const struct ccp_algorithm PppdDeflateAlgorithm = {
TY_PPPD_DEFLATE, /* pppd (wrongly) expects this ``type'' field */
ConfPppdDeflate,
DeflateDispOpts,
{
PppdDeflateGetInputOpts,
PppdDeflateSetInputOpts,
DeflateInitInput,
DeflateTermInput,
DeflateResetInput,
DeflateInput,
DeflateDictSetup
},
{
PppdDeflateGetOutputOpts,
PppdDeflateSetOutputOpts,
DeflateInitOutput,
DeflateTermOutput,
DeflateResetOutput,
DeflateOutput
},
};
const struct ccp_algorithm DeflateAlgorithm = {
TY_DEFLATE,
TY_DEFLATE, /* rfc 1979 */
ConfDeflate,
DeflateDispOpts,
{

View File

@ -1,5 +1,6 @@
/*
* $Id$
* $Id: deflate.h,v 1.1 1997/12/03 10:23:45 brian Exp $
*/
extern const struct ccp_algorithm PppdDeflateAlgorithm;
extern const struct ccp_algorithm DeflateAlgorithm;

View File

@ -1,4 +1,4 @@
.\" $Id: ppp.8,v 1.80 1997/11/18 14:52:06 brian Exp $
.\" $Id: ppp.8,v 1.81 1997/12/03 10:23:51 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@ -1594,6 +1594,37 @@ This is the same algorithm as used by the
.Xr gzip 1
program.
Note: There is a problem negotiating
.Ar deflate
capabilities with
.Xr pppd 8
- a
.Em PPP
implementation available under many operating systems.
.Nm Pppd
(version 2.3.1) incorrectly attempts to negotiate
.Ar deflate
compression using type
.Em 24
as the CCP configuration type rather than type
.Em 26
as specified in
.Pa rfc1979 .
Type
.Ar 24
is actually specified as
.Dq PPP Magnalink Variable Resource Compression
in
.Pa rfc1975 Ns No !
.Nm Ppp
is capable of negotiating with
.Nm pppd ,
but only if
.Dq pppd-deflate
is
.Ar enable Ns No d
and
.Ar accept Ns No ed .
.It lqr
Default: Disabled and Accepted. This option decides if Link Quality
@ -1628,6 +1659,16 @@ in
.Pa /etc/ppp/ppp.conf .
PAP is accepted by default.
.It pppd-deflate
Default: Disabled and Denied. This is a variance of the
.Ar deflate
option, allowing negotiation with the
.Xr pppd 8
program. Refer to the
.Ar deflate
section above for details. It is disabled by default as it violates
.Pa rfc1975 .
.It pred1
Default: Enabled and Accepted. This option decides if Predictor 1
compression will be used by the Compression Control Protocol (CCP).

View File

@ -1,4 +1,4 @@
.\" $Id: ppp.8,v 1.80 1997/11/18 14:52:06 brian Exp $
.\" $Id: ppp.8,v 1.81 1997/12/03 10:23:51 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@ -1594,6 +1594,37 @@ This is the same algorithm as used by the
.Xr gzip 1
program.
Note: There is a problem negotiating
.Ar deflate
capabilities with
.Xr pppd 8
- a
.Em PPP
implementation available under many operating systems.
.Nm Pppd
(version 2.3.1) incorrectly attempts to negotiate
.Ar deflate
compression using type
.Em 24
as the CCP configuration type rather than type
.Em 26
as specified in
.Pa rfc1979 .
Type
.Ar 24
is actually specified as
.Dq PPP Magnalink Variable Resource Compression
in
.Pa rfc1975 Ns No !
.Nm Ppp
is capable of negotiating with
.Nm pppd ,
but only if
.Dq pppd-deflate
is
.Ar enable Ns No d
and
.Ar accept Ns No ed .
.It lqr
Default: Disabled and Accepted. This option decides if Link Quality
@ -1628,6 +1659,16 @@ in
.Pa /etc/ppp/ppp.conf .
PAP is accepted by default.
.It pppd-deflate
Default: Disabled and Denied. This is a variance of the
.Ar deflate
option, allowing negotiation with the
.Xr pppd 8
program. Refer to the
.Ar deflate
section above for details. It is disabled by default as it violates
.Pa rfc1975 .
.It pred1
Default: Enabled and Accepted. This option decides if Predictor 1
compression will be used by the Compression Control Protocol (CCP).

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: vars.c,v 1.37 1997/11/22 13:47:02 brian Exp $
* $Id: vars.c,v 1.38 1997/12/03 10:23:53 brian Exp $
*
*/
#include <sys/param.h>
@ -39,7 +39,7 @@
#include "auth.h"
char VarVersion[] = "PPP Version 1.5";
char VarLocalVersion[] = "$Date: 1997/11/22 13:47:02 $";
char VarLocalVersion[] = "$Date: 1997/12/03 10:23:53 $";
int Utmp = 0;
int ipInOctets = 0;
int ipOutOctets = 0;
@ -58,6 +58,7 @@ struct confdesc pppConfs[] = {
{"deflate", CONF_ENABLE, CONF_ACCEPT},
{"lqr", CONF_DISABLE, CONF_ACCEPT},
{"pap", CONF_DISABLE, CONF_ACCEPT},
{"pppd-deflate", CONF_DISABLE, CONF_DENY},
{"pred1", CONF_ENABLE, CONF_ACCEPT},
{"protocomp", CONF_ENABLE, CONF_ACCEPT},
{"vjcomp", CONF_ENABLE, CONF_ACCEPT},

View File

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: vars.h,v 1.35 1997/11/22 03:37:54 brian Exp $
* $Id: vars.h,v 1.36 1997/12/03 10:23:54 brian Exp $
*
* TODO:
*/
@ -37,16 +37,17 @@ struct confdesc {
#define ConfDeflate 2
#define ConfLqr 3
#define ConfPap 4
#define ConfPred1 5
#define ConfProtocomp 6
#define ConfVjcomp 7
#define ConfPppdDeflate 5
#define ConfPred1 6
#define ConfProtocomp 7
#define ConfVjcomp 8
#define ConfMSExt 8
#define ConfPasswdAuth 9
#define ConfProxy 10
#define ConfThroughput 11
#define ConfUtmp 12
#define MAXCONFS 13
#define ConfMSExt 9
#define ConfPasswdAuth 10
#define ConfProxy 11
#define ConfThroughput 12
#define ConfUtmp 13
#define MAXCONFS 14
#define Enabled(x) (pppConfs[x].myside & CONF_ENABLE)
#define Acceptable(x) (pppConfs[x].hisside & CONF_ACCEPT)