1 --- a/include/linux/ppp-comp.h
2 +++ b/include/linux/ppp-comp.h
7 - * ==FILEVERSION 20020319==
8 + * ==FILEVERSION 20020715==
10 * NOTE TO MAINTAINERS:
11 * If you modify this file at all, please set the above date.
12 @@ -86,7 +86,7 @@ struct compressor {
14 /* Compress a packet */
15 int (*compress) (void *state, unsigned char *rptr,
16 - unsigned char *obuf, int isize, int osize);
17 + unsigned char *obuf, int isize, int osize);
19 /* Return compression statistics */
20 void (*comp_stat) (void *state, struct compstat *stats);
21 @@ -107,7 +107,7 @@ struct compressor {
23 /* Decompress a packet. */
24 int (*decompress) (void *state, unsigned char *ibuf, int isize,
25 - unsigned char *obuf, int osize);
26 + unsigned char *obuf, int osize);
28 /* Update state for an incompressible packet received */
29 void (*incomp) (void *state, unsigned char *ibuf, int icnt);
30 @@ -288,6 +288,33 @@ struct compressor {
31 opts |= MPPE_OPT_UNKNOWN; \
32 } while (/* CONSTCOND */ 0)
34 +/* MPPE/MPPC definitions by J.D.*/
35 +#define MPPE_STATELESS MPPE_H_BIT /* configuration bit H */
36 +#define MPPE_40BIT MPPE_L_BIT /* configuration bit L */
37 +#define MPPE_56BIT MPPE_M_BIT /* configuration bit M */
38 +#define MPPE_128BIT MPPE_S_BIT /* configuration bit S */
39 +#define MPPE_MPPC MPPE_C_BIT /* configuration bit C */
42 + * Definitions for Stac LZS.
45 +#define CI_LZS 17 /* config option for Stac LZS */
46 +#define CILEN_LZS 5 /* length of config option */
48 +#define LZS_OVHD 4 /* max. LZS overhead */
49 +#define LZS_HIST_LEN 2048 /* LZS history size */
50 +#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */
52 +#define LZS_MODE_NONE 0
53 +#define LZS_MODE_LCB 1
54 +#define LZS_MODE_CRC 2
55 +#define LZS_MODE_SEQ 3
56 +#define LZS_MODE_EXT 4
58 +#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */
59 +#define LZS_EXT_BIT_COMP 0x20 /* bit C */
62 * Definitions for other, as yet unsupported, compression methods.
64 --- a/include/net/ppp-comp.h
65 +++ b/include/net/ppp-comp.h
66 @@ -255,6 +255,33 @@ struct compressor {
67 opts |= MPPE_OPT_UNKNOWN; \
68 } while (/* CONSTCOND */ 0)
70 +/* MPPE/MPPC definitions by J.D.*/
71 +#define MPPE_STATELESS MPPE_H_BIT /* configuration bit H */
72 +#define MPPE_40BIT MPPE_L_BIT /* configuration bit L */
73 +#define MPPE_56BIT MPPE_M_BIT /* configuration bit M */
74 +#define MPPE_128BIT MPPE_S_BIT /* configuration bit S */
75 +#define MPPE_MPPC MPPE_C_BIT /* configuration bit C */
78 + * Definitions for Stac LZS.
81 +#define CI_LZS 17 /* config option for Stac LZS */
82 +#define CILEN_LZS 5 /* length of config option */
84 +#define LZS_OVHD 4 /* max. LZS overhead */
85 +#define LZS_HIST_LEN 2048 /* LZS history size */
86 +#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */
88 +#define LZS_MODE_NONE 0
89 +#define LZS_MODE_LCB 1
90 +#define LZS_MODE_CRC 2
91 +#define LZS_MODE_SEQ 3
92 +#define LZS_MODE_EXT 4
94 +#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */
95 +#define LZS_EXT_BIT_COMP 0x20 /* bit C */
98 * Definitions for other, as yet unsupported, compression methods.
102 @@ -62,12 +62,10 @@ static int setdeflate __P((char **));
103 static char bsd_value[8];
104 static char deflate_value[8];
107 - * Option variables.
110 -bool refuse_mppe_stateful = 1; /* Allow stateful mode? */
112 +static int setmppe(char **);
113 +static int setnomppe(void);
116 static option_t ccp_option_list[] = {
117 { "noccp", o_bool, &ccp_protent.enabled_flag,
118 @@ -108,54 +106,36 @@ static option_t ccp_option_list[] = {
119 "don't allow Predictor-1", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
120 &ccp_allowoptions[0].predictor_1 },
122 + { "lzs", o_bool, &ccp_wantoptions[0].lzs,
123 + "request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_PRIO },
124 + { "+lzs", o_bool, &ccp_wantoptions[0].lzs,
125 + "request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_ALIAS | OPT_PRIO },
126 + { "nolzs", o_bool, &ccp_wantoptions[0].lzs,
127 + "don't allow Stac LZS", OPT_PRIOSUB | OPT_A2CLR,
128 + &ccp_allowoptions[0].lzs },
129 + { "-lzs", o_bool, &ccp_wantoptions[0].lzs,
130 + "don't allow Stac LZS", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
131 + &ccp_allowoptions[0].lzs },
134 - /* MPPE options are symmetrical ... we only set wantoptions here */
135 - { "require-mppe", o_bool, &ccp_wantoptions[0].mppe,
136 - "require MPPE encryption",
137 - OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 },
138 - { "+mppe", o_bool, &ccp_wantoptions[0].mppe,
139 - "require MPPE encryption",
140 - OPT_ALIAS | OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 },
141 - { "nomppe", o_bool, &ccp_wantoptions[0].mppe,
142 - "don't allow MPPE encryption", OPT_PRIO },
143 - { "-mppe", o_bool, &ccp_wantoptions[0].mppe,
144 - "don't allow MPPE encryption", OPT_ALIAS | OPT_PRIO },
146 - /* We use ccp_allowoptions[0].mppe as a junk var ... it is reset later */
147 - { "require-mppe-40", o_bool, &ccp_allowoptions[0].mppe,
148 - "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40,
149 - &ccp_wantoptions[0].mppe },
150 - { "+mppe-40", o_bool, &ccp_allowoptions[0].mppe,
151 - "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40,
152 - &ccp_wantoptions[0].mppe },
153 - { "nomppe-40", o_bool, &ccp_allowoptions[0].mppe,
154 - "don't allow MPPE 40-bit encryption",
155 - OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40, &ccp_wantoptions[0].mppe },
156 - { "-mppe-40", o_bool, &ccp_allowoptions[0].mppe,
157 - "don't allow MPPE 40-bit encryption",
158 - OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40,
159 - &ccp_wantoptions[0].mppe },
161 - { "require-mppe-128", o_bool, &ccp_allowoptions[0].mppe,
162 - "require MPPE 128-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_128,
163 - &ccp_wantoptions[0].mppe },
164 - { "+mppe-128", o_bool, &ccp_allowoptions[0].mppe,
165 - "require MPPE 128-bit encryption",
166 - OPT_ALIAS | OPT_PRIO | OPT_A2OR | MPPE_OPT_128,
167 - &ccp_wantoptions[0].mppe },
168 - { "nomppe-128", o_bool, &ccp_allowoptions[0].mppe,
169 - "don't allow MPPE 128-bit encryption",
170 - OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128, &ccp_wantoptions[0].mppe },
171 - { "-mppe-128", o_bool, &ccp_allowoptions[0].mppe,
172 - "don't allow MPPE 128-bit encryption",
173 - OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128,
174 - &ccp_wantoptions[0].mppe },
176 - /* strange one; we always request stateless, but will we allow stateful? */
177 - { "mppe-stateful", o_bool, &refuse_mppe_stateful,
178 - "allow MPPE stateful mode", OPT_PRIO },
179 - { "nomppe-stateful", o_bool, &refuse_mppe_stateful,
180 - "disallow MPPE stateful mode", OPT_PRIO | 1 },
181 + { "mppc", o_bool, &ccp_wantoptions[0].mppc,
182 + "request MPPC compression", 1, &ccp_allowoptions[0].mppc },
183 + { "+mppc", o_bool, &ccp_wantoptions[0].mppc,
184 + "request MPPC compression", 1, &ccp_allowoptions[0].mppc, OPT_ALIAS },
185 + { "nomppc", o_bool, &ccp_wantoptions[0].mppc,
186 + "don't allow MPPC compression", OPT_PRIOSUB | OPT_A2CLR,
187 + &ccp_allowoptions[0].mppc },
188 + { "-mppc", o_bool, &ccp_wantoptions[0].mppc,
189 + "don't allow MPPC compression", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
190 + &ccp_allowoptions[0].mppc },
191 + { "mppe", o_special, (void *)setmppe,
192 + "request MPPE encryption" },
193 + { "+mppe", o_special, (void *)setmppe,
194 + "request MPPE encryption" },
195 + { "nomppe", o_special_noarg, (void *)setnomppe,
196 + "don't allow MPPE encryption" },
197 + { "-mppe", o_special_noarg, (void *)setnomppe,
198 + "don't allow MPPE encryption" },
202 @@ -241,7 +221,7 @@ static fsm_callbacks ccp_callbacks = {
204 #define ANY_COMPRESS(opt) ((opt).deflate || (opt).bsd_compress \
205 || (opt).predictor_1 || (opt).predictor_2 \
207 + || (opt).lzs || (opt).mppc || (opt).mppe)
210 * Local state (mainly for handling reset-reqs and reset-acks).
211 @@ -344,6 +324,100 @@ setdeflate(argv)
217 + * Functions called from config options
221 + required - require MPPE; disconnect if peer doesn't support it
222 + stateless - use stateless mode
223 + no40 - disable 40 bit keys
224 + no56 - disable 56 bit keys
225 + no128 - disable 128 bit keys
227 +int setmppe(char **argv)
230 + char *str, cmdbuf[16];
232 + ccp_allowoptions[0].mppe = 1;
233 + ccp_allowoptions[0].mppe_40 = 1;
234 + ccp_allowoptions[0].mppe_56 = 1;
235 + ccp_allowoptions[0].mppe_128 = 1;
236 + ccp_allowoptions[0].mppe_stateless = 0;
237 + ccp_wantoptions[0].mppe = 0;
243 + memset(cmdbuf, '\0', 16);
244 + while ((i < 16) && (*str != ',') && (*str != '\0'))
245 + cmdbuf[i++] = *str++;
247 + if (!strncasecmp(cmdbuf, "no40", strlen("no40"))) {
248 + ccp_allowoptions[0].mppe_40 = 0;
250 + } else if (!strncasecmp(cmdbuf, "no56", strlen("no56"))) {
251 + ccp_allowoptions[0].mppe_56 = 0;
253 + } else if (!strncasecmp(cmdbuf, "no128", strlen("no128"))) {
254 + ccp_allowoptions[0].mppe_128 = 0;
256 + } else if (!strncasecmp(cmdbuf, "stateless", strlen("stateless"))) {
257 + ccp_allowoptions[0].mppe_stateless = 1;
259 + } else if (!strncasecmp(cmdbuf, "required", strlen("required"))) {
260 + ccp_wantoptions[0].mppe = 1;
263 + option_error("invalid parameter '%s' for mppe option", cmdbuf);
272 + if (*str == '\0') {
273 + if (!(ccp_allowoptions[0].mppe_40 || ccp_allowoptions[0].mppe_56 ||
274 + ccp_allowoptions[0].mppe_128)) {
275 + if (ccp_wantoptions[0].mppe == 1) {
276 + option_error("You require MPPE but you have switched off "
277 + "all encryption key lengths.");
280 + ccp_wantoptions[0].mppe = ccp_allowoptions[0].mppe = 0;
281 + ccp_wantoptions[0].mppe_stateless =
282 + ccp_allowoptions[0].mppe_stateless = 0;
284 + ccp_allowoptions[0].mppe = 1;
285 + ccp_wantoptions[0].mppe_stateless =
286 + ccp_allowoptions[0].mppe_stateless;
287 + if (ccp_wantoptions[0].mppe == 1) {
288 + ccp_wantoptions[0].mppe_40 = ccp_allowoptions[0].mppe_40;
289 + ccp_wantoptions[0].mppe_56 = ccp_allowoptions[0].mppe_56;
290 + ccp_wantoptions[0].mppe_128 = ccp_allowoptions[0].mppe_128;
300 + ccp_wantoptions[0].mppe = ccp_allowoptions[0].mppe = 0;
301 + ccp_wantoptions[0].mppe_40 = ccp_allowoptions[0].mppe_40 = 0;
302 + ccp_wantoptions[0].mppe_56 = ccp_allowoptions[0].mppe_56 = 0;
303 + ccp_wantoptions[0].mppe_128 = ccp_allowoptions[0].mppe_128 = 0;
304 + ccp_wantoptions[0].mppe_stateless = ccp_allowoptions[0].mppe_stateless = 0;
310 * ccp_init - initialize CCP.
312 @@ -378,6 +452,30 @@ ccp_init(unit)
313 ccp_allowoptions[0].bsd_bits = BSD_MAX_BITS;
315 ccp_allowoptions[0].predictor_1 = 1;
317 + ccp_wantoptions[0].lzs = 0; /* Stac LZS - will be enabled in the future */
318 + ccp_wantoptions[0].lzs_mode = LZS_MODE_SEQ;
319 + ccp_wantoptions[0].lzs_hists = 1;
320 + ccp_allowoptions[0].lzs = 0; /* Stac LZS - will be enabled in the future */
321 + ccp_allowoptions[0].lzs_mode = LZS_MODE_SEQ;
322 + ccp_allowoptions[0].lzs_hists = 1;
325 + /* by default allow and request MPPC... */
326 + ccp_wantoptions[0].mppc = ccp_allowoptions[0].mppc = 1;
328 + /* ... and allow but don't request MPPE */
329 + ccp_allowoptions[0].mppe = 1;
330 + ccp_allowoptions[0].mppe_40 = 1;
331 + ccp_allowoptions[0].mppe_56 = 1;
332 + ccp_allowoptions[0].mppe_128 = 1;
333 + ccp_allowoptions[0].mppe_stateless = 1;
334 + ccp_wantoptions[0].mppe = 0;
335 + ccp_wantoptions[0].mppe_40 = 0;
336 + ccp_wantoptions[0].mppe_56 = 0;
337 + ccp_wantoptions[0].mppe_128 = 0;
338 + ccp_wantoptions[0].mppe_stateless = 0;
343 @@ -455,11 +553,11 @@ ccp_input(unit, p, len)
344 if (oldstate == OPENED && p[0] == TERMREQ && f->state != OPENED) {
345 notice("Compression disabled by peer.");
347 - if (ccp_gotoptions[unit].mppe) {
348 + if (ccp_wantoptions[unit].mppe) {
349 error("MPPE disabled, closing LCP");
350 lcp_close(unit, "MPPE disabled by peer");
357 @@ -487,6 +585,15 @@ ccp_extcode(f, code, id, p, len)
359 /* send a reset-ack, which the transmitter will see and
360 reset its compression state. */
362 + /* In case of MPPE/MPPC or LZS we shouldn't send CCP_RESETACK,
363 + but we do it in order to reset compressor; CCP_RESETACK is
364 + then silently discarded. See functions ppp_send_frame and
365 + ppp_ccp_peek in ppp_generic.c (Linux only !!!). All the
366 + confusion is caused by the fact that CCP code is splited
367 + into two parts - one part is handled by pppd, the other one
368 + is handled by kernel. */
370 fsm_sdata(f, CCP_RESETACK, id, NULL, 0);
373 @@ -515,12 +622,11 @@ ccp_protrej(unit)
374 fsm_lowerdown(&ccp_fsm[unit]);
377 - if (ccp_gotoptions[unit].mppe) {
378 + if (ccp_wantoptions[unit].mppe) {
379 error("MPPE required but peer negotiation failed");
380 lcp_close(unit, "MPPE required but peer negotiation failed");
388 @@ -537,7 +643,7 @@ ccp_resetci(f)
389 all_rejected[f->unit] = 0;
393 + if (go->mppe || go->mppc) {
394 ccp_options *ao = &ccp_allowoptions[f->unit];
395 int auth_mschap_bits = auth_done[f->unit];
397 @@ -551,80 +657,109 @@ ccp_resetci(f)
398 * NB: If MPPE is required, all other compression opts are invalid.
399 * So, we return right away if we can't do it.
401 + if (ccp_wantoptions[f->unit].mppe) {
402 + /* Leave only the mschap auth bits set */
403 + auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER |
404 + CHAP_MS2_WITHPEER | CHAP_MS2_PEER);
405 + /* Count the mschap auths */
406 + auth_mschap_bits >>= CHAP_MS_SHIFT;
409 + numbits += auth_mschap_bits & 1;
410 + auth_mschap_bits >>= 1;
411 + } while (auth_mschap_bits);
413 + error("MPPE required, but auth done in both directions.");
414 + lcp_close(f->unit, "MPPE required but not available");
418 + error("MPPE required, but MS-CHAP[v2] auth not performed.");
419 + lcp_close(f->unit, "MPPE required but not available");
423 - /* Leave only the mschap auth bits set */
424 - auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER |
425 - CHAP_MS2_WITHPEER | CHAP_MS2_PEER);
426 - /* Count the mschap auths */
427 - auth_mschap_bits >>= CHAP_MS_SHIFT;
430 - numbits += auth_mschap_bits & 1;
431 - auth_mschap_bits >>= 1;
432 - } while (auth_mschap_bits);
434 - error("MPPE required, but auth done in both directions.");
435 - lcp_close(f->unit, "MPPE required but not available");
439 - error("MPPE required, but MS-CHAP[v2] auth not performed.");
440 - lcp_close(f->unit, "MPPE required but not available");
444 - /* A plugin (eg radius) may not have obtained key material. */
445 - if (!mppe_keys_set) {
446 - error("MPPE required, but keys are not available. "
447 - "Possible plugin problem?");
448 - lcp_close(f->unit, "MPPE required but not available");
452 - /* LM auth not supported for MPPE */
453 - if (auth_done[f->unit] & (CHAP_MS_WITHPEER | CHAP_MS_PEER)) {
454 - /* This might be noise */
455 - if (go->mppe & MPPE_OPT_40) {
456 - notice("Disabling 40-bit MPPE; MS-CHAP LM not supported");
457 - go->mppe &= ~MPPE_OPT_40;
458 - ccp_wantoptions[f->unit].mppe &= ~MPPE_OPT_40;
459 + /* A plugin (eg radius) may not have obtained key material. */
460 + if (!mppe_keys_set) {
461 + error("MPPE required, but keys are not available. "
462 + "Possible plugin problem?");
463 + lcp_close(f->unit, "MPPE required but not available");
468 - /* Last check: can we actually negotiate something? */
469 - if (!(go->mppe & (MPPE_OPT_40 | MPPE_OPT_128))) {
470 - /* Could be misconfig, could be 40-bit disabled above. */
471 - error("MPPE required, but both 40-bit and 128-bit disabled.");
472 - lcp_close(f->unit, "MPPE required but not available");
475 + * Check whether the kernel knows about the various
476 + * compression methods we might request. Key material
477 + * unimportant here.
480 + opt_buf[0] = CI_MPPE;
481 + opt_buf[1] = CILEN_MPPE;
485 + opt_buf[5] = MPPE_MPPC;
486 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE, 0) <= 0)
490 + opt_buf[0] = CI_MPPE;
491 + opt_buf[1] = CILEN_MPPE;
492 + opt_buf[2] = MPPE_STATELESS;
495 + opt_buf[5] = MPPE_40BIT;
496 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
500 + opt_buf[0] = CI_MPPE;
501 + opt_buf[1] = CILEN_MPPE;
502 + opt_buf[2] = MPPE_STATELESS;
505 + opt_buf[5] = MPPE_56BIT;
506 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
509 + if (go->mppe_128) {
510 + opt_buf[0] = CI_MPPE;
511 + opt_buf[1] = CILEN_MPPE;
512 + opt_buf[2] = MPPE_STATELESS;
515 + opt_buf[5] = MPPE_128BIT;
516 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
519 + if (!go->mppe_40 && !go->mppe_56 && !go->mppe_128) {
520 + if (ccp_wantoptions[f->unit].mppe) {
521 + error("MPPE required, but kernel has no support.");
522 + lcp_close(f->unit, "MPPE required but not available");
524 + go->mppe = go->mppe_stateless = 0;
526 + /* MPPE is not compatible with other compression types */
527 + if (ccp_wantoptions[f->unit].mppe) {
528 + ao->bsd_compress = go->bsd_compress = 0;
529 + ao->predictor_1 = go->predictor_1 = 0;
530 + ao->predictor_2 = go->predictor_2 = 0;
531 + ao->deflate = go->deflate = 0;
532 + ao->lzs = go->lzs = 0;
537 - ao->mppe = go->mppe;
538 - /* MPPE is not compatible with other compression types */
539 - ao->bsd_compress = go->bsd_compress = 0;
540 - ao->predictor_1 = go->predictor_1 = 0;
541 - ao->predictor_2 = go->predictor_2 = 0;
542 - ao->deflate = go->deflate = 0;
547 - * Check whether the kernel knows about the various
548 - * compression methods we might request.
552 - opt_buf[0] = CI_MPPE;
553 - opt_buf[1] = CILEN_MPPE;
554 - MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
555 - /* Key material unimportant here. */
556 - if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0) {
557 - error("MPPE required, but kernel has no support.");
558 - lcp_close(f->unit, "MPPE required but not available");
561 + opt_buf[0] = CI_LZS;
562 + opt_buf[1] = CILEN_LZS;
563 + opt_buf[2] = go->lzs_hists >> 8;
564 + opt_buf[3] = go->lzs_hists & 0xff;
565 + opt_buf[4] = LZS_MODE_SEQ;
566 + if (ccp_test(f->unit, opt_buf, CILEN_LZS, 0) <= 0)
570 if (go->bsd_compress) {
571 opt_buf[0] = CI_BSD_COMPRESS;
572 opt_buf[1] = CILEN_BSD_COMPRESS;
573 @@ -679,7 +814,8 @@ ccp_cilen(f)
574 + (go->deflate? CILEN_DEFLATE: 0)
575 + (go->predictor_1? CILEN_PREDICTOR_1: 0)
576 + (go->predictor_2? CILEN_PREDICTOR_2: 0)
577 - + (go->mppe? CILEN_MPPE: 0);
578 + + (go->lzs? CILEN_LZS: 0)
579 + + ((go->mppe || go->mppc)? CILEN_MPPE: 0);
583 @@ -693,6 +829,8 @@ ccp_addci(f, p, lenp)
586 ccp_options *go = &ccp_gotoptions[f->unit];
587 + ccp_options *ao = &ccp_allowoptions[f->unit];
588 + ccp_options *wo = &ccp_wantoptions[f->unit];
592 @@ -701,22 +839,43 @@ ccp_addci(f, p, lenp)
593 * in case it gets Acked.
597 + if (go->mppe || go->mppc || (!wo->mppe && ao->mppe)) {
598 u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
600 - p[0] = opt_buf[0] = CI_MPPE;
601 - p[1] = opt_buf[1] = CILEN_MPPE;
602 - MPPE_OPTS_TO_CI(go->mppe, &p[2]);
603 - MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
606 + p[2] = (go->mppe_stateless ? MPPE_STATELESS : 0);
609 + p[5] = (go->mppe_40 ? MPPE_40BIT : 0) | (go->mppe_56 ? MPPE_56BIT : 0) |
610 + (go->mppe_128 ? MPPE_128BIT : 0) | (go->mppc ? MPPE_MPPC : 0);
612 + BCOPY(p, opt_buf, CILEN_MPPE);
613 BCOPY(mppe_recv_key, &opt_buf[CILEN_MPPE], MPPE_MAX_KEY_LEN);
614 res = ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0);
620 /* This shouldn't happen, we've already tested it! */
621 - lcp_close(f->unit, "MPPE required but not available in kernel");
622 + go->mppe = go->mppe_40 = go->mppe_56 = go->mppe_128 =
623 + go->mppe_stateless = go->mppc = 0;
624 + if (ccp_wantoptions[f->unit].mppe)
625 + lcp_close(f->unit, "MPPE required but not available in kernel");
632 + p[2] = go->lzs_hists >> 8;
633 + p[3] = go->lzs_hists & 0xff;
634 + p[4] = LZS_MODE_SEQ;
635 + res = ccp_test(f->unit, p, CILEN_LZS, 0);
643 p[0] = go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT;
644 p[1] = CILEN_DEFLATE;
645 @@ -802,7 +961,7 @@ ccp_addci(f, p, lenp)
648 * ccp_ackci - process a received configure-ack, and return
649 - * 1 iff the packet was OK.
650 + * 1 if the packet was OK.
654 @@ -811,24 +970,44 @@ ccp_ackci(f, p, len)
657 ccp_options *go = &ccp_gotoptions[f->unit];
658 + ccp_options *ao = &ccp_allowoptions[f->unit];
659 + ccp_options *wo = &ccp_wantoptions[f->unit];
664 - u_char opt_buf[CILEN_MPPE];
666 - opt_buf[0] = CI_MPPE;
667 - opt_buf[1] = CILEN_MPPE;
668 - MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
669 - if (len < CILEN_MPPE || memcmp(opt_buf, p, CILEN_MPPE))
670 + if (go->mppe || go->mppc || (!wo->mppe && ao->mppe)) {
671 + if (len < CILEN_MPPE
672 + || p[1] != CILEN_MPPE || p[0] != CI_MPPE
673 + || p[2] != (go->mppe_stateless ? MPPE_STATELESS : 0)
676 + || (p[5] != ((go->mppe_40 ? MPPE_40BIT : 0) |
677 + (go->mppc ? MPPE_MPPC : 0))
678 + && p[5] != ((go->mppe_56 ? MPPE_56BIT : 0) |
679 + (go->mppc ? MPPE_MPPC : 0))
680 + && p[5] != ((go->mppe_128 ? MPPE_128BIT : 0) |
681 + (go->mppc ? MPPE_MPPC : 0))))
683 + if (go->mppe_40 || go->mppe_56 || go->mppe_128)
687 + /* Cope with first/fast ack */
688 + if (p == p0 && len == 0)
693 + if (len < CILEN_LZS || p[0] != CI_LZS || p[1] != CILEN_LZS
694 + || p[2] != go->lzs_hists>>8 || p[3] != (go->lzs_hists&0xff)
695 + || p[4] != LZS_MODE_SEQ)
699 /* XXX Cope with first/fast ack */
701 + if (p == p0 && len == 0)
706 if (len < CILEN_DEFLATE
707 || p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
708 @@ -891,7 +1070,7 @@ ccp_ackci(f, p, len)
711 * ccp_nakci - process received configure-nak.
712 - * Returns 1 iff the nak was OK.
713 + * Returns 1 if the nak was OK.
716 ccp_nakci(f, p, len, treat_as_reject)
717 @@ -901,6 +1080,8 @@ ccp_nakci(f, p, len, treat_as_reject)
720 ccp_options *go = &ccp_gotoptions[f->unit];
721 + ccp_options *ao = &ccp_allowoptions[f->unit];
722 + ccp_options *wo = &ccp_wantoptions[f->unit];
723 ccp_options no; /* options we've seen already */
724 ccp_options try; /* options to ask for next time */
726 @@ -908,28 +1089,100 @@ ccp_nakci(f, p, len, treat_as_reject)
730 - if (go->mppe && len >= CILEN_MPPE
731 - && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
734 - * Peer wants us to use a different strength or other setting.
735 - * Fail if we aren't willing to use his suggestion.
737 - MPPE_CI_TO_OPTS(&p[2], try.mppe);
738 - if ((try.mppe & MPPE_OPT_STATEFUL) && refuse_mppe_stateful) {
739 - error("Refusing MPPE stateful mode offered by peer");
741 - } else if (((go->mppe | MPPE_OPT_STATEFUL) & try.mppe) != try.mppe) {
742 - /* Peer must have set options we didn't request (suggest) */
745 + if ((go->mppe || go->mppc || (!wo->mppe && ao->mppe)) &&
746 + len >= CILEN_MPPE && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
749 - error("MPPE required but peer negotiation failed");
750 - lcp_close(f->unit, "MPPE required but peer negotiation failed");
753 + if (!(p[5] & MPPE_MPPC))
765 + if (go->mppe_stateless)
766 + no.mppe_stateless = 1;
769 + if ((p[5] & MPPE_40BIT))
772 + try.mppe_40 = (p[5] == 0) ? 1 : 0;
775 + if ((p[5] & MPPE_56BIT))
778 + try.mppe_56 = (p[5] == 0) ? 1 : 0;
780 + if (ao->mppe_128) {
781 + if ((p[5] & MPPE_128BIT))
784 + try.mppe_128 = (p[5] == 0) ? 1 : 0;
787 + if (ao->mppe_stateless) {
788 + if ((p[2] & MPPE_STATELESS) || wo->mppe_stateless)
789 + try.mppe_stateless = 1;
791 + try.mppe_stateless = 0;
794 + if (!try.mppe_56 && !try.mppe_40 && !try.mppe_128) {
795 + try.mppe = try.mppe_stateless = 0;
797 + /* we require encryption, but peer doesn't support it
798 + so we close connection */
799 + wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
800 + wo->mppe_56 = wo->mppe_128 = 0;
801 + lcp_close(f->unit, "MPPE required but cannot negotiate MPPE "
805 + if (wo->mppe && (wo->mppe_40 != try.mppe_40) &&
806 + (wo->mppe_56 != try.mppe_56) && (wo->mppe_128 != try.mppe_128)) {
807 + /* cannot negotiate key length */
808 + wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
809 + wo->mppe_56 = wo->mppe_128 = 0;
810 + lcp_close(f->unit, "Cannot negotiate MPPE key length");
812 + if (try.mppe_40 && try.mppe_56 && try.mppe_128)
813 + try.mppe_40 = try.mppe_56 = 0;
815 + if (try.mppe_56 && try.mppe_128)
818 + if (try.mppe_40 && try.mppe_128)
821 + if (try.mppe_40 && try.mppe_56)
829 + if (go->lzs && len >= CILEN_LZS && p[0] == CI_LZS && p[1] == CILEN_LZS) {
831 + if (((p[2]<<8)|p[3]) > 1 || (p[4] != LZS_MODE_SEQ &&
832 + p[4] != LZS_MODE_EXT))
835 + try.lzs_mode = p[4];
836 + try.lzs_hists = (p[2] << 8) | p[3];
842 if (go->deflate && len >= CILEN_DEFLATE
843 && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
844 && p[1] == CILEN_DEFLATE) {
845 @@ -1002,14 +1255,50 @@ ccp_rejci(f, p, len)
849 - if (go->mppe && len >= CILEN_MPPE
850 + if ((go->mppe || go->mppc) && len >= CILEN_MPPE
851 && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
852 - error("MPPE required but peer refused");
853 - lcp_close(f->unit, "MPPE required but peer refused");
854 + ccp_options *wo = &ccp_wantoptions[f->unit];
855 + if (p[2] != (go->mppe_stateless ? MPPE_STATELESS : 0) ||
858 + p[5] != ((go->mppe_40 ? MPPE_40BIT : 0) |
859 + (go->mppe_56 ? MPPE_56BIT : 0) |
860 + (go->mppe_128 ? MPPE_128BIT : 0) |
861 + (go->mppc ? MPPE_MPPC : 0)))
873 + if (go->mppe_stateless)
874 + try.mppe_stateless = 0;
875 + if (!try.mppe_56 && !try.mppe_40 && !try.mppe_128)
876 + try.mppe = try.mppe_stateless = 0;
877 + if (wo->mppe) { /* we want MPPE but cannot negotiate key length */
878 + wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
879 + wo->mppe_56 = wo->mppe_128 = 0;
880 + lcp_close(f->unit, "MPPE required but cannot negotiate MPPE "
889 + if (go->lzs && len >= CILEN_LZS && p[0] == CI_LZS && p[1] == CILEN_LZS) {
890 + if (p[2] != go->lzs_hists>>8 || p[3] != (go->lzs_hists&0xff)
891 + || p[4] != go->lzs_mode)
897 if (go->deflate_correct && len >= CILEN_DEFLATE
898 && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
899 if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
900 @@ -1073,14 +1362,15 @@ ccp_reqci(f, p, lenp, dont_nak)
903 int ret, newret, res;
905 + u_char *p0, *retp, p2, p5;
906 int len, clen, type, nb;
907 ccp_options *ho = &ccp_hisoptions[f->unit];
908 ccp_options *ao = &ccp_allowoptions[f->unit];
909 + ccp_options *wo = &ccp_wantoptions[f->unit];
911 - bool rej_for_ci_mppe = 1; /* Are we rejecting based on a bad/missing */
912 - /* CI_MPPE, or due to other options? */
914 + u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
920 @@ -1103,106 +1393,302 @@ ccp_reqci(f, p, lenp, dont_nak)
924 - if (!ao->mppe || clen != CILEN_MPPE) {
925 + if ((!ao->mppc && !ao->mppe) || clen != CILEN_MPPE) {
929 - MPPE_CI_TO_OPTS(&p[2], ho->mppe);
931 - /* Nak if anything unsupported or unknown are set. */
932 - if (ho->mppe & MPPE_OPT_UNSUPPORTED) {
935 + /* not sure what they want, tell 'em what we got */
936 + if (((p[2] & ~MPPE_STATELESS) != 0 || p[3] != 0 || p[4] != 0 ||
937 + (p[5] & ~(MPPE_40BIT | MPPE_56BIT | MPPE_128BIT |
938 + MPPE_MPPC)) != 0 || p[5] == 0) ||
939 + (p[2] == 0 && p[3] == 0 && p[4] == 0 && p[5] == 0)) {
941 - ho->mppe &= ~MPPE_OPT_UNSUPPORTED;
943 - if (ho->mppe & MPPE_OPT_UNKNOWN) {
945 - ho->mppe &= ~MPPE_OPT_UNKNOWN;
948 - /* Check state opt */
949 - if (ho->mppe & MPPE_OPT_STATEFUL) {
951 - * We can Nak and request stateless, but it's a
952 - * lot easier to just assume the peer will request
953 - * it if he can do it; stateful mode is bad over
954 - * the Internet -- which is where we expect MPPE.
956 - if (refuse_mppe_stateful) {
957 - error("Refusing MPPE stateful mode offered by peer");
960 + p[2] = (wo->mppe_stateless ? MPPE_STATELESS : 0);
963 + p[5] = (wo->mppe_40 ? MPPE_40BIT : 0) |
964 + (wo->mppe_56 ? MPPE_56BIT : 0) |
965 + (wo->mppe_128 ? MPPE_128BIT : 0) |
966 + (wo->mppc ? MPPE_MPPC : 0);
970 + if ((p[5] & MPPE_MPPC)) {
973 + BCOPY(p, opt_buf, CILEN_MPPE);
974 + opt_buf[2] = opt_buf[3] = opt_buf[4] = 0;
975 + opt_buf[5] = MPPE_MPPC;
976 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE, 1) <= 0) {
978 + p[5] &= ~MPPE_MPPC;
983 + if (wo->mppe || ao->mppe) {
984 + p[5] &= ~MPPE_MPPC;
990 - /* Find out which of {S,L} are set. */
991 - if ((ho->mppe & MPPE_OPT_128)
992 - && (ho->mppe & MPPE_OPT_40)) {
993 - /* Both are set, negotiate the strongest. */
995 - if (ao->mppe & MPPE_OPT_128)
996 - ho->mppe &= ~MPPE_OPT_40;
997 - else if (ao->mppe & MPPE_OPT_40)
998 - ho->mppe &= ~MPPE_OPT_128;
1003 - } else if (ho->mppe & MPPE_OPT_128) {
1004 - if (!(ao->mppe & MPPE_OPT_128)) {
1008 - } else if (ho->mppe & MPPE_OPT_40) {
1009 - if (!(ao->mppe & MPPE_OPT_40)) {
1016 + if ((p[2] & MPPE_STATELESS)) {
1017 + if (ao->mppe_stateless) {
1018 + if (wo->mppe_stateless)
1019 + ho->mppe_stateless = 1;
1023 + p[2] &= ~MPPE_STATELESS;
1028 + p[2] &= ~MPPE_STATELESS;
1031 + if (wo->mppe_stateless && !dont_nak) {
1032 + wo->mppe_stateless = 0;
1034 + p[2] |= MPPE_STATELESS;
1038 + if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_56BIT|MPPE_128BIT)) {
1040 + if (ao->mppe_128) {
1042 + p[5] &= ~(MPPE_40BIT|MPPE_56BIT);
1043 + BCOPY(p, opt_buf, CILEN_MPPE);
1044 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1045 + MPPE_MAX_KEY_LEN);
1046 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1047 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1049 + p[5] |= (MPPE_40BIT|MPPE_56BIT);
1050 + p[5] &= ~MPPE_128BIT;
1051 + goto check_mppe_56_40;
1055 + p[5] &= ~MPPE_128BIT;
1056 + goto check_mppe_56_40;
1058 + if ((p[5] & ~MPPE_MPPC) == (MPPE_56BIT|MPPE_128BIT)) {
1060 + if (ao->mppe_128) {
1062 + p[5] &= ~MPPE_56BIT;
1063 + BCOPY(p, opt_buf, CILEN_MPPE);
1064 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1065 + MPPE_MAX_KEY_LEN);
1066 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1067 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1069 + p[5] |= MPPE_56BIT;
1070 + p[5] &= ~MPPE_128BIT;
1071 + goto check_mppe_56;
1075 + p[5] &= ~MPPE_128BIT;
1076 + goto check_mppe_56;
1078 + if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_128BIT)) {
1080 + if (ao->mppe_128) {
1082 + p[5] &= ~MPPE_40BIT;
1083 + BCOPY(p, opt_buf, CILEN_MPPE);
1084 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1085 + MPPE_MAX_KEY_LEN);
1086 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1087 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1089 + p[5] |= MPPE_40BIT;
1090 + p[5] &= ~MPPE_128BIT;
1091 + goto check_mppe_40;
1095 + p[5] &= ~MPPE_128BIT;
1096 + goto check_mppe_40;
1098 + if ((p[5] & ~MPPE_MPPC) == MPPE_128BIT) {
1099 + if (ao->mppe_128) {
1101 + BCOPY(p, opt_buf, CILEN_MPPE);
1102 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1103 + MPPE_MAX_KEY_LEN);
1104 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1105 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1107 + p[5] &= ~MPPE_128BIT;
1112 + p[5] &= ~MPPE_128BIT;
1117 + if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_56BIT)) {
1119 + if (ao->mppe_56) {
1121 + p[5] &= ~MPPE_40BIT;
1122 + BCOPY(p, opt_buf, CILEN_MPPE);
1123 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1124 + MPPE_MAX_KEY_LEN);
1125 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1126 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1128 + p[5] |= MPPE_40BIT;
1129 + p[5] &= ~MPPE_56BIT;
1131 + goto check_mppe_40;
1135 + p[5] &= ~MPPE_56BIT;
1136 + goto check_mppe_40;
1139 + if ((p[5] & ~MPPE_MPPC) == MPPE_56BIT) {
1140 + if (ao->mppe_56) {
1142 + BCOPY(p, opt_buf, CILEN_MPPE);
1143 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1144 + MPPE_MAX_KEY_LEN);
1145 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1146 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1148 + p[5] &= ~MPPE_56BIT;
1153 + p[5] &= ~MPPE_56BIT;
1158 + if ((p[5] & ~MPPE_MPPC) == MPPE_40BIT) {
1159 + if (ao->mppe_40) {
1161 + BCOPY(p, opt_buf, CILEN_MPPE);
1162 + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1163 + MPPE_MAX_KEY_LEN);
1164 + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
1165 + MPPE_MAX_KEY_LEN, 1) <= 0) {
1167 + p[5] &= ~MPPE_40BIT;
1172 + p[5] &= ~MPPE_40BIT;
1176 + if (!ho->mppe_40 && !ho->mppe_56 && !ho->mppe_128) {
1177 + if (wo->mppe_40 || wo->mppe_56 || wo->mppe_128) {
1179 + p[2] |= (wo->mppe_stateless ? MPPE_STATELESS : 0);
1180 + p[5] |= (wo->mppe_40 ? MPPE_40BIT : 0) |
1181 + (wo->mppe_56 ? MPPE_56BIT : 0) |
1182 + (wo->mppe_128 ? MPPE_128BIT : 0) |
1183 + (wo->mppc ? MPPE_MPPC : 0);
1185 + ho->mppe = ho->mppe_stateless = 0;
1188 - /* Neither are set. */
1189 - /* We cannot accept this. */
1191 - /* Give the peer our idea of what can be used,
1192 - so it can choose and confirm */
1193 - ho->mppe = ao->mppe;
1196 - /* rebuild the opts */
1197 - MPPE_OPTS_TO_CI(ho->mppe, &p[2]);
1198 - if (newret == CONFACK) {
1199 - u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
1202 - BCOPY(p, opt_buf, CILEN_MPPE);
1203 - BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1204 - MPPE_MAX_KEY_LEN);
1205 - if (ccp_test(f->unit, opt_buf,
1206 - CILEN_MPPE + MPPE_MAX_KEY_LEN, 1) <= 0) {
1207 - /* This shouldn't happen, we've already tested it! */
1208 - error("MPPE required, but kernel has no support.");
1209 - lcp_close(f->unit, "MPPE required but not available");
1214 - * We need to decrease the interface MTU by MPPE_PAD
1215 - * because MPPE frames **grow**. The kernel [must]
1216 - * allocate MPPE_PAD extra bytes in xmit buffers.
1218 - mtu = netif_get_mtu(f->unit);
1220 - netif_set_mtu(f->unit, mtu - MPPE_PAD);
1226 - * We have accepted MPPE or are willing to negotiate
1227 - * MPPE parameters. A CONFREJ is due to subsequent
1228 - * (non-MPPE) processing.
1230 - rej_for_ci_mppe = 0;
1233 + /* MPPE is not compatible with other compression types */
1235 + ao->bsd_compress = 0;
1236 + ao->predictor_1 = 0;
1237 + ao->predictor_2 = 0;
1242 + if ((!ho->mppc || !ao->mppc) && !ho->mppe) {
1250 + * I have commented the code below because according to RFC1547
1251 + * MTU is only information for higher level protocols about
1252 + * "the maximum allowable length for a packet (q.v.) transmitted
1253 + * over a point-to-point link without incurring network layer
1254 + * fragmentation." Of course a PPP implementation should be able
1255 + * to handle overhead added by MPPE - in our case apropriate code
1256 + * is located in drivers/net/ppp_generic.c in the kernel sources.
1258 + * According to RFC1661:
1259 + * - when negotiated MRU is less than 1500 octets, a PPP
1260 + * implementation must still be able to receive at least 1500
1262 + * - when PFC is negotiated, a PPP implementation is still
1263 + * required to receive frames with uncompressed protocol field.
1265 + * So why not to handle MPPE overhead without changing MTU value?
1266 + * I am sure that RFC3078, unfortunately silently, assumes that.
1270 + * We need to decrease the interface MTU by MPPE_PAD
1271 + * because MPPE frames **grow**. The kernel [must]
1272 + * allocate MPPE_PAD extra bytes in xmit buffers.
1275 + mtu = netif_get_mtu(f->unit);
1277 + netif_set_mtu(f->unit, mtu - MPPE_PAD);
1280 + if (ccp_wantoptions[f->unit].mppe) {
1281 + error("Cannot adjust MTU needed by MPPE.");
1282 + lcp_close(f->unit, "Cannot adjust MTU needed by MPPE.");
1290 + if (!ao->lzs || clen != CILEN_LZS) {
1296 + ho->lzs_hists = (p[2] << 8) | p[3];
1297 + ho->lzs_mode = p[4];
1298 + if ((ho->lzs_hists != ao->lzs_hists) ||
1299 + (ho->lzs_mode != ao->lzs_mode)) {
1302 + p[2] = ao->lzs_hists >> 8;
1303 + p[3] = ao->lzs_hists & 0xff;
1304 + p[4] = ao->lzs_mode;
1309 + if (p == p0 && ccp_test(f->unit, p, CILEN_LZS, 1) <= 0) {
1314 case CI_DEFLATE_DRAFT:
1315 if (!ao->deflate || clen != CILEN_DEFLATE
1316 @@ -1344,12 +1830,6 @@ ccp_reqci(f, p, lenp, dont_nak)
1321 - if (ret == CONFREJ && ao->mppe && rej_for_ci_mppe) {
1322 - error("MPPE required but peer negotiation failed");
1323 - lcp_close(f->unit, "MPPE required but peer negotiation failed");
1329 @@ -1371,24 +1851,35 @@ method_name(opt, opt2)
1331 char *q = result + sizeof(result); /* 1 past result */
1333 - slprintf(p, q - p, "MPPE ");
1335 - if (opt->mppe & MPPE_OPT_128) {
1336 - slprintf(p, q - p, "128-bit ");
1339 - if (opt->mppe & MPPE_OPT_40) {
1340 - slprintf(p, q - p, "40-bit ");
1343 - if (opt->mppe & MPPE_OPT_STATEFUL)
1344 - slprintf(p, q - p, "stateful");
1346 - slprintf(p, q - p, "stateless");
1350 + slprintf(p, q - p, "MPPC/MPPE ");
1353 + slprintf(p, q - p, "MPPE ");
1356 + if (opt->mppe_128) {
1357 + slprintf(p, q - p, "128-bit ");
1359 + } else if (opt->mppe_56) {
1360 + slprintf(p, q - p, "56-bit ");
1362 + } else if (opt->mppe_40) {
1363 + slprintf(p, q - p, "40-bit ");
1366 + if (opt->mppe_stateless)
1367 + slprintf(p, q - p, "stateless");
1369 + slprintf(p, q - p, "stateful");
1370 + } else if (opt->mppc)
1371 + slprintf(p, q - p, "MPPC");
1377 + return "Stac LZS";
1379 case CI_DEFLATE_DRAFT:
1380 if (opt2 != NULL && opt2->deflate_size != opt->deflate_size)
1381 @@ -1444,12 +1935,12 @@ ccp_up(f)
1382 } else if (ANY_COMPRESS(*ho))
1383 notice("%s transmit compression enabled", method_name(ho, NULL));
1386 + if (go->mppe || go->mppc) {
1387 BZERO(mppe_recv_key, MPPE_MAX_KEY_LEN);
1388 BZERO(mppe_send_key, MPPE_MAX_KEY_LEN);
1389 continue_networks(f->unit); /* Bring up IP et al */
1396 @@ -1472,7 +1963,7 @@ ccp_down(f)
1397 lcp_close(f->unit, "MPPE disabled");
1405 @@ -1532,24 +2023,28 @@ ccp_printpkt(p, plen, printer, arg)
1408 if (optlen >= CILEN_MPPE) {
1411 - MPPE_CI_TO_OPTS(&p[2], mppe_opts);
1412 - printer(arg, "mppe %s %s %s %s %s %s%s",
1413 - (p[2] & MPPE_H_BIT)? "+H": "-H",
1414 - (p[5] & MPPE_M_BIT)? "+M": "-M",
1415 - (p[5] & MPPE_S_BIT)? "+S": "-S",
1416 - (p[5] & MPPE_L_BIT)? "+L": "-L",
1417 + printer(arg, "mppe %s %s %s %s %s %s",
1418 + (p[2] & MPPE_STATELESS)? "+H": "-H",
1419 + (p[5] & MPPE_56BIT)? "+M": "-M",
1420 + (p[5] & MPPE_128BIT)? "+S": "-S",
1421 + (p[5] & MPPE_40BIT)? "+L": "-L",
1422 (p[5] & MPPE_D_BIT)? "+D": "-D",
1423 - (p[5] & MPPE_C_BIT)? "+C": "-C",
1424 - (mppe_opts & MPPE_OPT_UNKNOWN)? " +U": "");
1425 - if (mppe_opts & MPPE_OPT_UNKNOWN)
1426 + (p[5] & MPPE_MPPC)? "+C": "-C");
1427 + if ((p[5] & ~(MPPE_56BIT | MPPE_128BIT | MPPE_40BIT |
1428 + MPPE_D_BIT | MPPE_MPPC)) ||
1429 + (p[2] & ~MPPE_STATELESS))
1430 printer(arg, " (%.2x %.2x %.2x %.2x)",
1431 p[2], p[3], p[4], p[5]);
1438 + if (optlen >= CILEN_LZS) {
1439 + printer(arg, "lzs %.2x %.2x %.2x", p[2], p[3], p[4]);
1444 case CI_DEFLATE_DRAFT:
1445 if (optlen >= CILEN_DEFLATE) {
1446 @@ -1635,6 +2130,7 @@ ccp_datainput(unit, pkt, len)
1447 error("Lost compression sync: disabling compression");
1448 ccp_close(unit, "Lost compression sync");
1450 + /* My module dosn't need this. J.D., 2003-07-06 */
1452 * If we were doing MPPE, we must also take the link down.
1454 @@ -1642,9 +2138,18 @@ ccp_datainput(unit, pkt, len)
1455 error("Too many MPPE errors, closing LCP");
1456 lcp_close(unit, "Too many MPPE errors");
1462 + * When LZS or MPPE/MPPC is negotiated we just send CCP_RESETREQ
1463 + * and don't wait for CCP_RESETACK
1465 + if ((ccp_gotoptions[f->unit].method == CI_LZS) ||
1466 + (ccp_gotoptions[f->unit].method == CI_MPPE)) {
1467 + fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0);
1471 * Send a reset-request to reset the peer's compressor.
1472 * We don't do that if we are still waiting for an
1473 * acknowledgement to a previous reset-request.
1474 @@ -1675,4 +2180,3 @@ ccp_rack_timeout(arg)
1476 ccp_localstate[f->unit] &= ~RACK_PENDING;
1481 @@ -37,9 +37,17 @@ typedef struct ccp_options {
1482 bool predictor_2; /* do Predictor-2? */
1483 bool deflate_correct; /* use correct code for deflate? */
1484 bool deflate_draft; /* use draft RFC code for deflate? */
1485 + bool lzs; /* do Stac LZS? */
1486 + bool mppc; /* do MPPC? */
1487 bool mppe; /* do MPPE? */
1488 + bool mppe_40; /* allow 40 bit encryption? */
1489 + bool mppe_56; /* allow 56 bit encryption? */
1490 + bool mppe_128; /* allow 128 bit encryption? */
1491 + bool mppe_stateless; /* allow stateless encryption */
1492 u_short bsd_bits; /* # bits/code for BSD Compress */
1493 u_short deflate_size; /* lg(window size) for Deflate */
1494 + u_short lzs_mode; /* LZS check mode */
1495 + u_short lzs_hists; /* number of LZS histories */
1496 short method; /* code for chosen compression method */
1499 --- a/pppd/chap_ms.c
1500 +++ b/pppd/chap_ms.c
1501 @@ -897,13 +897,17 @@ set_mppe_enc_types(int policy, int types
1503 * Disable undesirable encryption types. Note that we don't ENABLE
1504 * any encryption types, to avoid overriding manual configuration.
1506 + * It seems that 56 bit keys are unsupported in MS-RADIUS (see RFC 2548)
1509 case MPPE_ENC_TYPES_RC4_40:
1510 - ccp_wantoptions[0].mppe &= ~MPPE_OPT_128; /* disable 128-bit */
1511 + ccp_wantoptions[0].mppe_128 = 0; /* disable 128-bit */
1512 + ccp_wantoptions[0].mppe_56 = 0; /* disable 56-bit */
1514 case MPPE_ENC_TYPES_RC4_128:
1515 - ccp_wantoptions[0].mppe &= ~MPPE_OPT_40; /* disable 40-bit */
1516 + ccp_wantoptions[0].mppe_56 = 0; /* disable 56-bit */
1517 + ccp_wantoptions[0].mppe_40 = 0; /* disable 40-bit */