mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-04 21:44:38 +08:00
PPP, CCP, deflate, BSD compress, predictor 1 & 2 are now optional at compile time
This commit is contained in:
parent
f753a728dd
commit
b553df860c
@ -66,6 +66,7 @@
|
|||||||
#define CCP_OPT_LENGTH(dp) ((dp)[1])
|
#define CCP_OPT_LENGTH(dp) ((dp)[1])
|
||||||
#define CCP_OPT_MINLEN 2
|
#define CCP_OPT_MINLEN 2
|
||||||
|
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
/*
|
/*
|
||||||
* Definitions for BSD-Compress.
|
* Definitions for BSD-Compress.
|
||||||
*/
|
*/
|
||||||
@ -81,7 +82,9 @@
|
|||||||
|
|
||||||
#define BSD_MIN_BITS 9 /* smallest code size supported */
|
#define BSD_MIN_BITS 9 /* smallest code size supported */
|
||||||
#define BSD_MAX_BITS 15 /* largest code size supported */
|
#define BSD_MAX_BITS 15 /* largest code size supported */
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
/*
|
/*
|
||||||
* Definitions for Deflate.
|
* Definitions for Deflate.
|
||||||
*/
|
*/
|
||||||
@ -97,14 +100,18 @@
|
|||||||
#define DEFLATE_METHOD(x) ((x) & 0x0F)
|
#define DEFLATE_METHOD(x) ((x) & 0x0F)
|
||||||
#define DEFLATE_MAKE_OPT(w) ((((w) - 8) << 4) + DEFLATE_METHOD_VAL)
|
#define DEFLATE_MAKE_OPT(w) ((((w) - 8) << 4) + DEFLATE_METHOD_VAL)
|
||||||
#define DEFLATE_CHK_SEQUENCE 0
|
#define DEFLATE_CHK_SEQUENCE 0
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
|
||||||
|
#if MPPE_SUPPORT
|
||||||
/*
|
/*
|
||||||
* Definitions for MPPE.
|
* Definitions for MPPE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CI_MPPE 18 /* config option for MPPE */
|
#define CI_MPPE 18 /* config option for MPPE */
|
||||||
#define CILEN_MPPE 6 /* length of config option */
|
#define CILEN_MPPE 6 /* length of config option */
|
||||||
|
#endif /* MPPE_SUPPORT */
|
||||||
|
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
/*
|
/*
|
||||||
* Definitions for other, as yet unsupported, compression methods.
|
* Definitions for other, as yet unsupported, compression methods.
|
||||||
*/
|
*/
|
||||||
@ -113,21 +120,38 @@
|
|||||||
#define CILEN_PREDICTOR_1 2 /* length of its config option */
|
#define CILEN_PREDICTOR_1 2 /* length of its config option */
|
||||||
#define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
|
#define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
|
||||||
#define CILEN_PREDICTOR_2 2 /* length of its config option */
|
#define CILEN_PREDICTOR_2 2 /* length of its config option */
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
|
|
||||||
typedef struct ccp_options {
|
typedef struct ccp_options {
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
unsigned int deflate :1; /* do Deflate? */
|
unsigned int deflate :1; /* do Deflate? */
|
||||||
unsigned int deflate_correct :1; /* use correct code for deflate? */
|
unsigned int deflate_correct :1; /* use correct code for deflate? */
|
||||||
unsigned int deflate_draft :1; /* use draft RFC code for deflate? */
|
unsigned int deflate_draft :1; /* use draft RFC code for deflate? */
|
||||||
|
#else /* DEFLATE_SUPPORT */
|
||||||
|
unsigned int :3; /* 3 bit of padding */
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
unsigned int bsd_compress :1; /* do BSD Compress? */
|
unsigned int bsd_compress :1; /* do BSD Compress? */
|
||||||
|
#else /* BSDCOMPRESS_SUPPORT */
|
||||||
|
unsigned int :1; /* 1 bit of padding */
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
unsigned int predictor_1 :1; /* do Predictor-1? */
|
unsigned int predictor_1 :1; /* do Predictor-1? */
|
||||||
unsigned int predictor_2 :1; /* do Predictor-2? */
|
unsigned int predictor_2 :1; /* do Predictor-2? */
|
||||||
|
#else /* PREDICTOR_SUPPORT */
|
||||||
|
unsigned int :2; /* 2 bit of padding */
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
unsigned int :2; /* 2 bit of padding to round out to 8 bits */
|
unsigned int :2; /* 2 bit of padding to round out to 8 bits */
|
||||||
|
|
||||||
#if MPPE_SUPPORT
|
#if MPPE_SUPPORT
|
||||||
u8_t mppe; /* MPPE bitfield */
|
u8_t mppe; /* MPPE bitfield */
|
||||||
#endif /* MPPE_SUPPORT */
|
#endif /* MPPE_SUPPORT */
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
u_short bsd_bits; /* # bits/code for BSD Compress */
|
u_short bsd_bits; /* # bits/code for BSD Compress */
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
u_short deflate_size; /* lg(window size) for Deflate */
|
u_short deflate_size; /* lg(window size) for Deflate */
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
short method; /* code for chosen compression method */
|
short method; /* code for chosen compression method */
|
||||||
} ccp_options;
|
} ccp_options;
|
||||||
|
|
||||||
|
@ -85,6 +85,17 @@
|
|||||||
#define PPP_STATS_SUPPORT 0
|
#define PPP_STATS_SUPPORT 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef DEFLATE_SUPPORT
|
||||||
|
#define DEFLATE_SUPPORT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BSDCOMPRESS_SUPPORT
|
||||||
|
#define BSDCOMPRESS_SUPPORT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PREDICTOR_SUPPORT
|
||||||
|
#define PREDICTOR_SUPPORT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
*** PUBLIC DEFINITIONS ***
|
*** PUBLIC DEFINITIONS ***
|
||||||
|
@ -244,12 +244,20 @@ static const fsm_callbacks ccp_callbacks = {
|
|||||||
* Do we want / did we get any compression?
|
* Do we want / did we get any compression?
|
||||||
*/
|
*/
|
||||||
static int ccp_anycompress(ccp_options *opt) {
|
static int ccp_anycompress(ccp_options *opt) {
|
||||||
return ((opt)->deflate || (opt)->bsd_compress
|
return (0
|
||||||
|| (opt)->predictor_1 || (opt)->predictor_2
|
#if DEFLATE_SUPPORT
|
||||||
|
|| (opt)->deflate
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
|
|| (opt)->bsd_compress
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
|
|| (opt)->predictor_1 || (opt)->predictor_2
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
#if MPPE_SUPPORT
|
#if MPPE_SUPPORT
|
||||||
|| (opt)->mppe
|
|| (opt)->mppe
|
||||||
#endif /* MPPE_SUPPORT */
|
#endif /* MPPE_SUPPORT */
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -373,6 +381,7 @@ static void ccp_init(ppp_pcb *pcb) {
|
|||||||
memset(ao, 0, sizeof(*ao));
|
memset(ao, 0, sizeof(*ao));
|
||||||
memset(ho, 0, sizeof(*ho));
|
memset(ho, 0, sizeof(*ho));
|
||||||
|
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
wo->deflate = 1;
|
wo->deflate = 1;
|
||||||
wo->deflate_size = DEFLATE_MAX_SIZE;
|
wo->deflate_size = DEFLATE_MAX_SIZE;
|
||||||
wo->deflate_correct = 1;
|
wo->deflate_correct = 1;
|
||||||
@ -381,13 +390,18 @@ static void ccp_init(ppp_pcb *pcb) {
|
|||||||
ao->deflate_size = DEFLATE_MAX_SIZE;
|
ao->deflate_size = DEFLATE_MAX_SIZE;
|
||||||
ao->deflate_correct = 1;
|
ao->deflate_correct = 1;
|
||||||
ao->deflate_draft = 1;
|
ao->deflate_draft = 1;
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
wo->bsd_compress = 1;
|
wo->bsd_compress = 1;
|
||||||
wo->bsd_bits = BSD_MAX_BITS;
|
wo->bsd_bits = BSD_MAX_BITS;
|
||||||
ao->bsd_compress = 1;
|
ao->bsd_compress = 1;
|
||||||
ao->bsd_bits = BSD_MAX_BITS;
|
ao->bsd_bits = BSD_MAX_BITS;
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
ao->predictor_1 = 1;
|
ao->predictor_1 = 1;
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -528,7 +542,9 @@ static void ccp_resetci(fsm *f) {
|
|||||||
ccp_options *go = &pcb->ccp_gotoptions;
|
ccp_options *go = &pcb->ccp_gotoptions;
|
||||||
ccp_options *wo = &pcb->ccp_wantoptions;
|
ccp_options *wo = &pcb->ccp_wantoptions;
|
||||||
u_char opt_buf[CCP_MAX_OPTION_LENGTH];
|
u_char opt_buf[CCP_MAX_OPTION_LENGTH];
|
||||||
|
#if DEFLATE_SUPPORT || BSDCOMPRESS_SUPPORT
|
||||||
int res;
|
int res;
|
||||||
|
#endif /* DEFLATE_SUPPORT || BSDCOMPRESS_SUPPORT */
|
||||||
|
|
||||||
*go = *wo;
|
*go = *wo;
|
||||||
pcb->all_rejected = 0;
|
pcb->all_rejected = 0;
|
||||||
@ -599,10 +615,16 @@ static void ccp_resetci(fsm *f) {
|
|||||||
/* sync options */
|
/* sync options */
|
||||||
ao->mppe = go->mppe;
|
ao->mppe = go->mppe;
|
||||||
/* MPPE is not compatible with other compression types */
|
/* MPPE is not compatible with other compression types */
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
ao->bsd_compress = go->bsd_compress = 0;
|
ao->bsd_compress = go->bsd_compress = 0;
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
ao->predictor_1 = go->predictor_1 = 0;
|
ao->predictor_1 = go->predictor_1 = 0;
|
||||||
ao->predictor_2 = go->predictor_2 = 0;
|
ao->predictor_2 = go->predictor_2 = 0;
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
ao->deflate = go->deflate = 0;
|
ao->deflate = go->deflate = 0;
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
}
|
}
|
||||||
#endif /* MPPE_SUPPORT */
|
#endif /* MPPE_SUPPORT */
|
||||||
|
|
||||||
@ -622,6 +644,7 @@ static void ccp_resetci(fsm *f) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* MPPE_SUPPORT */
|
#endif /* MPPE_SUPPORT */
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
if (go->bsd_compress) {
|
if (go->bsd_compress) {
|
||||||
opt_buf[0] = CI_BSD_COMPRESS;
|
opt_buf[0] = CI_BSD_COMPRESS;
|
||||||
opt_buf[1] = CILEN_BSD_COMPRESS;
|
opt_buf[1] = CILEN_BSD_COMPRESS;
|
||||||
@ -641,6 +664,8 @@ static void ccp_resetci(fsm *f) {
|
|||||||
go->bsd_bits--;
|
go->bsd_bits--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
if (go->deflate) {
|
if (go->deflate) {
|
||||||
if (go->deflate_correct) {
|
if (go->deflate_correct) {
|
||||||
opt_buf[0] = CI_DEFLATE;
|
opt_buf[0] = CI_DEFLATE;
|
||||||
@ -685,6 +710,8 @@ static void ccp_resetci(fsm *f) {
|
|||||||
if (!go->deflate_correct && !go->deflate_draft)
|
if (!go->deflate_correct && !go->deflate_draft)
|
||||||
go->deflate = 0;
|
go->deflate = 0;
|
||||||
}
|
}
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
if (go->predictor_1) {
|
if (go->predictor_1) {
|
||||||
opt_buf[0] = CI_PREDICTOR_1;
|
opt_buf[0] = CI_PREDICTOR_1;
|
||||||
opt_buf[1] = CILEN_PREDICTOR_1;
|
opt_buf[1] = CILEN_PREDICTOR_1;
|
||||||
@ -697,6 +724,7 @@ static void ccp_resetci(fsm *f) {
|
|||||||
if (ccp_test(pcb, opt_buf, CILEN_PREDICTOR_2, 0) <= 0)
|
if (ccp_test(pcb, opt_buf, CILEN_PREDICTOR_2, 0) <= 0)
|
||||||
go->predictor_2 = 0;
|
go->predictor_2 = 0;
|
||||||
}
|
}
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -706,11 +734,18 @@ static int ccp_cilen(fsm *f) {
|
|||||||
ppp_pcb *pcb = f->pcb;
|
ppp_pcb *pcb = f->pcb;
|
||||||
ccp_options *go = &pcb->ccp_gotoptions;
|
ccp_options *go = &pcb->ccp_gotoptions;
|
||||||
|
|
||||||
return (go->bsd_compress? CILEN_BSD_COMPRESS: 0)
|
return 0
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
|
+ (go->bsd_compress? CILEN_BSD_COMPRESS: 0)
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
+ (go->deflate && go->deflate_correct? CILEN_DEFLATE: 0)
|
+ (go->deflate && go->deflate_correct? CILEN_DEFLATE: 0)
|
||||||
+ (go->deflate && go->deflate_draft? CILEN_DEFLATE: 0)
|
+ (go->deflate && go->deflate_draft? CILEN_DEFLATE: 0)
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
+ (go->predictor_1? CILEN_PREDICTOR_1: 0)
|
+ (go->predictor_1? CILEN_PREDICTOR_1: 0)
|
||||||
+ (go->predictor_2? CILEN_PREDICTOR_2: 0)
|
+ (go->predictor_2? CILEN_PREDICTOR_2: 0)
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
#if MPPE_SUPPORT
|
#if MPPE_SUPPORT
|
||||||
+ (go->mppe? CILEN_MPPE: 0)
|
+ (go->mppe? CILEN_MPPE: 0)
|
||||||
#endif /* MPPE_SUPPORT */
|
#endif /* MPPE_SUPPORT */
|
||||||
@ -743,6 +778,7 @@ static void ccp_addci(fsm *f, u_char *p, int *lenp) {
|
|||||||
p += CILEN_MPPE;
|
p += CILEN_MPPE;
|
||||||
}
|
}
|
||||||
#endif /* MPPE_SUPPORT */
|
#endif /* MPPE_SUPPORT */
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
if (go->deflate) {
|
if (go->deflate) {
|
||||||
if (go->deflate_correct) {
|
if (go->deflate_correct) {
|
||||||
p[0] = CI_DEFLATE;
|
p[0] = CI_DEFLATE;
|
||||||
@ -759,12 +795,16 @@ static void ccp_addci(fsm *f, u_char *p, int *lenp) {
|
|||||||
p += CILEN_DEFLATE;
|
p += CILEN_DEFLATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
if (go->bsd_compress) {
|
if (go->bsd_compress) {
|
||||||
p[0] = CI_BSD_COMPRESS;
|
p[0] = CI_BSD_COMPRESS;
|
||||||
p[1] = CILEN_BSD_COMPRESS;
|
p[1] = CILEN_BSD_COMPRESS;
|
||||||
p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits);
|
p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits);
|
||||||
p += CILEN_BSD_COMPRESS;
|
p += CILEN_BSD_COMPRESS;
|
||||||
}
|
}
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
/* XXX Should Predictor 2 be preferable to Predictor 1? */
|
/* XXX Should Predictor 2 be preferable to Predictor 1? */
|
||||||
if (go->predictor_1) {
|
if (go->predictor_1) {
|
||||||
p[0] = CI_PREDICTOR_1;
|
p[0] = CI_PREDICTOR_1;
|
||||||
@ -776,6 +816,7 @@ static void ccp_addci(fsm *f, u_char *p, int *lenp) {
|
|||||||
p[1] = CILEN_PREDICTOR_2;
|
p[1] = CILEN_PREDICTOR_2;
|
||||||
p += CILEN_PREDICTOR_2;
|
p += CILEN_PREDICTOR_2;
|
||||||
}
|
}
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
|
|
||||||
go->method = (p > p0)? p0[0]: -1;
|
go->method = (p > p0)? p0[0]: -1;
|
||||||
|
|
||||||
@ -789,7 +830,9 @@ static void ccp_addci(fsm *f, u_char *p, int *lenp) {
|
|||||||
static int ccp_ackci(fsm *f, u_char *p, int len) {
|
static int ccp_ackci(fsm *f, u_char *p, int len) {
|
||||||
ppp_pcb *pcb = f->pcb;
|
ppp_pcb *pcb = f->pcb;
|
||||||
ccp_options *go = &pcb->ccp_gotoptions;
|
ccp_options *go = &pcb->ccp_gotoptions;
|
||||||
|
#if BSDCOMPRESS_SUPPORT || PREDICTOR_SUPPORT
|
||||||
u_char *p0 = p;
|
u_char *p0 = p;
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT || PREDICTOR_SUPPORT */
|
||||||
|
|
||||||
#if MPPE_SUPPORT
|
#if MPPE_SUPPORT
|
||||||
if (go->mppe) {
|
if (go->mppe) {
|
||||||
@ -807,6 +850,7 @@ static int ccp_ackci(fsm *f, u_char *p, int len) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif /* MPPE_SUPPORT */
|
#endif /* MPPE_SUPPORT */
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
if (go->deflate) {
|
if (go->deflate) {
|
||||||
if (len < CILEN_DEFLATE
|
if (len < CILEN_DEFLATE
|
||||||
|| p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
|
|| p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
|
||||||
@ -830,6 +874,8 @@ static int ccp_ackci(fsm *f, u_char *p, int len) {
|
|||||||
len -= CILEN_DEFLATE;
|
len -= CILEN_DEFLATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
if (go->bsd_compress) {
|
if (go->bsd_compress) {
|
||||||
if (len < CILEN_BSD_COMPRESS
|
if (len < CILEN_BSD_COMPRESS
|
||||||
|| p[0] != CI_BSD_COMPRESS || p[1] != CILEN_BSD_COMPRESS
|
|| p[0] != CI_BSD_COMPRESS || p[1] != CILEN_BSD_COMPRESS
|
||||||
@ -841,6 +887,8 @@ static int ccp_ackci(fsm *f, u_char *p, int len) {
|
|||||||
if (p == p0 && len == 0)
|
if (p == p0 && len == 0)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
if (go->predictor_1) {
|
if (go->predictor_1) {
|
||||||
if (len < CILEN_PREDICTOR_1
|
if (len < CILEN_PREDICTOR_1
|
||||||
|| p[0] != CI_PREDICTOR_1 || p[1] != CILEN_PREDICTOR_1)
|
|| p[0] != CI_PREDICTOR_1 || p[1] != CILEN_PREDICTOR_1)
|
||||||
@ -861,6 +909,7 @@ static int ccp_ackci(fsm *f, u_char *p, int len) {
|
|||||||
if (p == p0 && len == 0)
|
if (p == p0 && len == 0)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
|
|
||||||
if (len != 0)
|
if (len != 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -877,6 +926,10 @@ static int ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
|
|||||||
ccp_options no; /* options we've seen already */
|
ccp_options no; /* options we've seen already */
|
||||||
ccp_options try_; /* options to ask for next time */
|
ccp_options try_; /* options to ask for next time */
|
||||||
LWIP_UNUSED_ARG(treat_as_reject);
|
LWIP_UNUSED_ARG(treat_as_reject);
|
||||||
|
#if !MPPE_SUPPORT && !DEFLATE_SUPPORT && !BSDCOMPRESS_SUPPORT
|
||||||
|
LWIP_UNUSED_ARG(p);
|
||||||
|
LWIP_UNUSED_ARG(len);
|
||||||
|
#endif /* !MPPE_SUPPORT && !DEFLATE_SUPPORT && !BSDCOMPRESS_SUPPORT */
|
||||||
|
|
||||||
memset(&no, 0, sizeof(no));
|
memset(&no, 0, sizeof(no));
|
||||||
try_ = *go;
|
try_ = *go;
|
||||||
@ -904,6 +957,7 @@ static int ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* MPPE_SUPPORT */
|
#endif /* MPPE_SUPPORT */
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
if (go->deflate && len >= CILEN_DEFLATE
|
if (go->deflate && len >= CILEN_DEFLATE
|
||||||
&& p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
|
&& p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
|
||||||
&& p[1] == CILEN_DEFLATE) {
|
&& p[1] == CILEN_DEFLATE) {
|
||||||
@ -927,7 +981,8 @@ static int ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
|
|||||||
len -= CILEN_DEFLATE;
|
len -= CILEN_DEFLATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
|
if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
|
||||||
&& p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
|
&& p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
|
||||||
no.bsd_compress = 1;
|
no.bsd_compress = 1;
|
||||||
@ -942,6 +997,7 @@ static int ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
|
|||||||
p += CILEN_BSD_COMPRESS;
|
p += CILEN_BSD_COMPRESS;
|
||||||
len -= CILEN_BSD_COMPRESS;
|
len -= CILEN_BSD_COMPRESS;
|
||||||
}
|
}
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Predictor-1 and 2 have no options, so they can't be Naked.
|
* Predictor-1 and 2 have no options, so they can't be Naked.
|
||||||
@ -980,6 +1036,7 @@ static int ccp_rejci(fsm *f, u_char *p, int len) {
|
|||||||
len -= CILEN_MPPE;
|
len -= CILEN_MPPE;
|
||||||
}
|
}
|
||||||
#endif /* MPPE_SUPPORT */
|
#endif /* MPPE_SUPPORT */
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
if (go->deflate_correct && len >= CILEN_DEFLATE
|
if (go->deflate_correct && len >= CILEN_DEFLATE
|
||||||
&& p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
|
&& p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
|
||||||
if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
|
if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
|
||||||
@ -1000,6 +1057,8 @@ static int ccp_rejci(fsm *f, u_char *p, int len) {
|
|||||||
}
|
}
|
||||||
if (!try_.deflate_correct && !try_.deflate_draft)
|
if (!try_.deflate_correct && !try_.deflate_draft)
|
||||||
try_.deflate = 0;
|
try_.deflate = 0;
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
|
if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
|
||||||
&& p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
|
&& p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
|
||||||
if (p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits))
|
if (p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits))
|
||||||
@ -1008,6 +1067,8 @@ static int ccp_rejci(fsm *f, u_char *p, int len) {
|
|||||||
p += CILEN_BSD_COMPRESS;
|
p += CILEN_BSD_COMPRESS;
|
||||||
len -= CILEN_BSD_COMPRESS;
|
len -= CILEN_BSD_COMPRESS;
|
||||||
}
|
}
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
if (go->predictor_1 && len >= CILEN_PREDICTOR_1
|
if (go->predictor_1 && len >= CILEN_PREDICTOR_1
|
||||||
&& p[0] == CI_PREDICTOR_1 && p[1] == CILEN_PREDICTOR_1) {
|
&& p[0] == CI_PREDICTOR_1 && p[1] == CILEN_PREDICTOR_1) {
|
||||||
try_.predictor_1 = 0;
|
try_.predictor_1 = 0;
|
||||||
@ -1020,6 +1081,7 @@ static int ccp_rejci(fsm *f, u_char *p, int len) {
|
|||||||
p += CILEN_PREDICTOR_2;
|
p += CILEN_PREDICTOR_2;
|
||||||
len -= CILEN_PREDICTOR_2;
|
len -= CILEN_PREDICTOR_2;
|
||||||
}
|
}
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
|
|
||||||
if (len != 0)
|
if (len != 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1039,9 +1101,13 @@ static int ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) {
|
|||||||
ppp_pcb *pcb = f->pcb;
|
ppp_pcb *pcb = f->pcb;
|
||||||
ccp_options *ho = &pcb->ccp_hisoptions;
|
ccp_options *ho = &pcb->ccp_hisoptions;
|
||||||
ccp_options *ao = &pcb->ccp_allowoptions;
|
ccp_options *ao = &pcb->ccp_allowoptions;
|
||||||
int ret, newret, res;
|
int ret, newret;
|
||||||
|
#if DEFLATE_SUPPORT || BSDCOMPRESS_SUPPORT
|
||||||
|
int res;
|
||||||
|
int nb;
|
||||||
|
#endif /* DEFLATE_SUPPORT || BSDCOMPRESS_SUPPORT */
|
||||||
u_char *p0, *retp;
|
u_char *p0, *retp;
|
||||||
int len, clen, type, nb;
|
int len, clen, type;
|
||||||
#if MPPE_SUPPORT
|
#if MPPE_SUPPORT
|
||||||
u8_t rej_for_ci_mppe = 1; /* Are we rejecting based on a bad/missing */
|
u8_t rej_for_ci_mppe = 1; /* Are we rejecting based on a bad/missing */
|
||||||
/* CI_MPPE, or due to other options? */
|
/* CI_MPPE, or due to other options? */
|
||||||
@ -1168,6 +1234,7 @@ static int ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) {
|
|||||||
rej_for_ci_mppe = 0;
|
rej_for_ci_mppe = 0;
|
||||||
break;
|
break;
|
||||||
#endif /* MPPE_SUPPORT */
|
#endif /* MPPE_SUPPORT */
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
case CI_DEFLATE:
|
case CI_DEFLATE:
|
||||||
case CI_DEFLATE_DRAFT:
|
case CI_DEFLATE_DRAFT:
|
||||||
if (!ao->deflate || clen != CILEN_DEFLATE
|
if (!ao->deflate || clen != CILEN_DEFLATE
|
||||||
@ -1213,7 +1280,8 @@ static int ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
case CI_BSD_COMPRESS:
|
case CI_BSD_COMPRESS:
|
||||||
if (!ao->bsd_compress || clen != CILEN_BSD_COMPRESS) {
|
if (!ao->bsd_compress || clen != CILEN_BSD_COMPRESS) {
|
||||||
newret = CONFREJ;
|
newret = CONFREJ;
|
||||||
@ -1255,7 +1323,8 @@ static int ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
case CI_PREDICTOR_1:
|
case CI_PREDICTOR_1:
|
||||||
if (!ao->predictor_1 || clen != CILEN_PREDICTOR_1) {
|
if (!ao->predictor_1 || clen != CILEN_PREDICTOR_1) {
|
||||||
newret = CONFREJ;
|
newret = CONFREJ;
|
||||||
@ -1281,6 +1350,7 @@ static int ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) {
|
|||||||
newret = CONFREJ;
|
newret = CONFREJ;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
newret = CONFREJ;
|
newret = CONFREJ;
|
||||||
@ -1323,6 +1393,9 @@ static int ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) {
|
|||||||
*/
|
*/
|
||||||
static const char *method_name(ccp_options *opt, ccp_options *opt2) {
|
static const char *method_name(ccp_options *opt, ccp_options *opt2) {
|
||||||
static char result[64];
|
static char result[64];
|
||||||
|
#if !DEFLATE_SUPPORT && !BSDCOMPRESS_SUPPORT
|
||||||
|
LWIP_UNUSED_ARG(opt2);
|
||||||
|
#endif /* !DEFLATE_SUPPORT && !BSDCOMPRESS_SUPPORT */
|
||||||
|
|
||||||
if (!ccp_anycompress(opt))
|
if (!ccp_anycompress(opt))
|
||||||
return "(none)";
|
return "(none)";
|
||||||
@ -1351,6 +1424,7 @@ static const char *method_name(ccp_options *opt, ccp_options *opt2) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* MPPE_SUPPORT */
|
#endif /* MPPE_SUPPORT */
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
case CI_DEFLATE:
|
case CI_DEFLATE:
|
||||||
case CI_DEFLATE_DRAFT:
|
case CI_DEFLATE_DRAFT:
|
||||||
if (opt2 != NULL && opt2->deflate_size != opt->deflate_size)
|
if (opt2 != NULL && opt2->deflate_size != opt->deflate_size)
|
||||||
@ -1362,6 +1436,8 @@ static const char *method_name(ccp_options *opt, ccp_options *opt2) {
|
|||||||
(opt->method == CI_DEFLATE_DRAFT? "(old#)": ""),
|
(opt->method == CI_DEFLATE_DRAFT? "(old#)": ""),
|
||||||
opt->deflate_size);
|
opt->deflate_size);
|
||||||
break;
|
break;
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
case CI_BSD_COMPRESS:
|
case CI_BSD_COMPRESS:
|
||||||
if (opt2 != NULL && opt2->bsd_bits != opt->bsd_bits)
|
if (opt2 != NULL && opt2->bsd_bits != opt->bsd_bits)
|
||||||
ppp_slprintf(result, sizeof(result), "BSD-Compress (%d/%d)",
|
ppp_slprintf(result, sizeof(result), "BSD-Compress (%d/%d)",
|
||||||
@ -1370,10 +1446,13 @@ static const char *method_name(ccp_options *opt, ccp_options *opt2) {
|
|||||||
ppp_slprintf(result, sizeof(result), "BSD-Compress (%d)",
|
ppp_slprintf(result, sizeof(result), "BSD-Compress (%d)",
|
||||||
opt->bsd_bits);
|
opt->bsd_bits);
|
||||||
break;
|
break;
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
case CI_PREDICTOR_1:
|
case CI_PREDICTOR_1:
|
||||||
return "Predictor 1";
|
return "Predictor 1";
|
||||||
case CI_PREDICTOR_2:
|
case CI_PREDICTOR_2:
|
||||||
return "Predictor 2";
|
return "Predictor 2";
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
default:
|
default:
|
||||||
ppp_slprintf(result, sizeof(result), "Method %d", opt->method);
|
ppp_slprintf(result, sizeof(result), "Method %d", opt->method);
|
||||||
}
|
}
|
||||||
@ -1507,6 +1586,7 @@ static int ccp_printpkt(u_char *p, int plen, void (*printer) (void *, const char
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* MPPE_SUPPORT */
|
#endif /* MPPE_SUPPORT */
|
||||||
|
#if DEFLATE_SUPPORT
|
||||||
case CI_DEFLATE:
|
case CI_DEFLATE:
|
||||||
case CI_DEFLATE_DRAFT:
|
case CI_DEFLATE_DRAFT:
|
||||||
if (optlen >= CILEN_DEFLATE) {
|
if (optlen >= CILEN_DEFLATE) {
|
||||||
@ -1520,6 +1600,8 @@ static int ccp_printpkt(u_char *p, int plen, void (*printer) (void *, const char
|
|||||||
p += CILEN_DEFLATE;
|
p += CILEN_DEFLATE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif /* DEFLATE_SUPPORT */
|
||||||
|
#if BSDCOMPRESS_SUPPORT
|
||||||
case CI_BSD_COMPRESS:
|
case CI_BSD_COMPRESS:
|
||||||
if (optlen >= CILEN_BSD_COMPRESS) {
|
if (optlen >= CILEN_BSD_COMPRESS) {
|
||||||
printer(arg, "bsd v%d %d", BSD_VERSION(p[2]),
|
printer(arg, "bsd v%d %d", BSD_VERSION(p[2]),
|
||||||
@ -1527,6 +1609,8 @@ static int ccp_printpkt(u_char *p, int plen, void (*printer) (void *, const char
|
|||||||
p += CILEN_BSD_COMPRESS;
|
p += CILEN_BSD_COMPRESS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif /* BSDCOMPRESS_SUPPORT */
|
||||||
|
#if PREDICTOR_SUPPORT
|
||||||
case CI_PREDICTOR_1:
|
case CI_PREDICTOR_1:
|
||||||
if (optlen >= CILEN_PREDICTOR_1) {
|
if (optlen >= CILEN_PREDICTOR_1) {
|
||||||
printer(arg, "predictor 1");
|
printer(arg, "predictor 1");
|
||||||
@ -1539,6 +1623,7 @@ static int ccp_printpkt(u_char *p, int plen, void (*printer) (void *, const char
|
|||||||
p += CILEN_PREDICTOR_2;
|
p += CILEN_PREDICTOR_2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif /* PREDICTOR_SUPPORT */
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user