2 * ccp.c - PPP Compression Control Protocol.
4 * Copyright (c) 1994 The Australian National University.
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation is hereby granted, provided that the above copyright
9 * notice appears in all copies. This software is provided without any
10 * warranty, express or implied. The Australian National University
11 * makes no representations about the suitability of this software for
14 * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
15 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
17 * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
20 * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
21 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
23 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
24 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
28 #define RCSID "$Id: ccp.c,v 1.40 2002/10/27 11:46:24 fcusack Exp $"
36 #include <net/ppp-comp.h>
39 #include "chap_ms.h" /* mppe_xxxx_key */
40 #include "lcp.h" /* lcp_close(), lcp_fsm */
43 static const char rcsid[] = RCSID;
46 * Unfortunately there is a bug in zlib which means that using a
47 * size of 8 (window size = 256) for Deflate compression will cause
48 * buffer overruns and kernel crashes in the deflate module.
49 * Until this is fixed we only accept sizes in the range 9 .. 15.
50 * Thanks to James Carlson for pointing this out.
52 #define DEFLATE_MIN_WORKS 9
55 * Command-line options.
57 static int setbsdcomp __P((char **));
58 static int setdeflate __P((char **));
59 static char bsd_value[8];
60 static char deflate_value[8];
66 bool refuse_mppe_stateful = 1; /* Allow stateful mode? */
69 static option_t ccp_option_list[] = {
70 { "noccp", o_bool, &ccp_protent.enabled_flag,
71 "Disable CCP negotiation" },
72 { "-ccp", o_bool, &ccp_protent.enabled_flag,
73 "Disable CCP negotiation", OPT_ALIAS },
75 { "bsdcomp", o_special, (void *)setbsdcomp,
76 "Request BSD-Compress packet compression",
77 OPT_PRIO | OPT_A2STRVAL | OPT_STATIC, bsd_value },
78 { "nobsdcomp", o_bool, &ccp_wantoptions[0].bsd_compress,
79 "don't allow BSD-Compress", OPT_PRIOSUB | OPT_A2CLR,
80 &ccp_allowoptions[0].bsd_compress },
81 { "-bsdcomp", o_bool, &ccp_wantoptions[0].bsd_compress,
82 "don't allow BSD-Compress", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
83 &ccp_allowoptions[0].bsd_compress },
85 { "deflate", o_special, (void *)setdeflate,
86 "request Deflate compression",
87 OPT_PRIO | OPT_A2STRVAL | OPT_STATIC, deflate_value },
88 { "nodeflate", o_bool, &ccp_wantoptions[0].deflate,
89 "don't allow Deflate compression", OPT_PRIOSUB | OPT_A2CLR,
90 &ccp_allowoptions[0].deflate },
91 { "-deflate", o_bool, &ccp_wantoptions[0].deflate,
92 "don't allow Deflate compression", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
93 &ccp_allowoptions[0].deflate },
95 { "nodeflatedraft", o_bool, &ccp_wantoptions[0].deflate_draft,
96 "don't use draft deflate #", OPT_A2COPY,
97 &ccp_allowoptions[0].deflate_draft },
99 { "predictor1", o_bool, &ccp_wantoptions[0].predictor_1,
100 "request Predictor-1", OPT_PRIO | 1 },
101 { "nopredictor1", o_bool, &ccp_wantoptions[0].predictor_1,
102 "don't allow Predictor-1", OPT_PRIOSUB | OPT_A2CLR,
103 &ccp_allowoptions[0].predictor_1 },
104 { "-predictor1", o_bool, &ccp_wantoptions[0].predictor_1,
105 "don't allow Predictor-1", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
106 &ccp_allowoptions[0].predictor_1 },
109 /* MPPE options are symmetrical ... we only set wantoptions here */
110 { "require-mppe", o_bool, &ccp_wantoptions[0].mppe,
111 "require MPPE encryption",
112 OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 },
113 { "+mppe", o_bool, &ccp_wantoptions[0].mppe,
114 "require MPPE encryption",
115 OPT_ALIAS | OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 },
116 { "nomppe", o_bool, &ccp_wantoptions[0].mppe,
117 "don't allow MPPE encryption", OPT_PRIO },
118 { "-mppe", o_bool, &ccp_wantoptions[0].mppe,
119 "don't allow MPPE encryption", OPT_ALIAS | OPT_PRIO },
121 /* We use ccp_allowoptions[0].mppe as a junk var ... it is reset later */
122 { "require-mppe-40", o_bool, &ccp_allowoptions[0].mppe,
123 "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40,
124 &ccp_wantoptions[0].mppe },
125 { "+mppe-40", o_bool, &ccp_allowoptions[0].mppe,
126 "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40,
127 &ccp_wantoptions[0].mppe },
128 { "nomppe-40", o_bool, &ccp_allowoptions[0].mppe,
129 "don't allow MPPE 40-bit encryption",
130 OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40, &ccp_wantoptions[0].mppe },
131 { "-mppe-40", o_bool, &ccp_allowoptions[0].mppe,
132 "don't allow MPPE 40-bit encryption",
133 OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40,
134 &ccp_wantoptions[0].mppe },
136 { "require-mppe-128", o_bool, &ccp_allowoptions[0].mppe,
137 "require MPPE 128-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_128,
138 &ccp_wantoptions[0].mppe },
139 { "+mppe-128", o_bool, &ccp_allowoptions[0].mppe,
140 "require MPPE 128-bit encryption",
141 OPT_ALIAS | OPT_PRIO | OPT_A2OR | MPPE_OPT_128,
142 &ccp_wantoptions[0].mppe },
143 { "nomppe-128", o_bool, &ccp_allowoptions[0].mppe,
144 "don't allow MPPE 128-bit encryption",
145 OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128, &ccp_wantoptions[0].mppe },
146 { "-mppe-128", o_bool, &ccp_allowoptions[0].mppe,
147 "don't allow MPPE 128-bit encryption",
148 OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128,
149 &ccp_wantoptions[0].mppe },
151 /* strange one; we always request stateless, but will we allow stateful? */
152 { "mppe-stateful", o_bool, &refuse_mppe_stateful,
153 "allow MPPE stateful mode", OPT_PRIO },
154 { "nomppe-stateful", o_bool, &refuse_mppe_stateful,
155 "disallow MPPE stateful mode", OPT_PRIO | 1 },
162 * Protocol entry points from main code.
164 static void ccp_init __P((int unit));
165 static void ccp_open __P((int unit));
166 static void ccp_close __P((int unit, char *));
167 static void ccp_lowerup __P((int unit));
168 static void ccp_lowerdown __P((int));
169 static void ccp_input __P((int unit, u_char *pkt, int len));
170 static void ccp_protrej __P((int unit));
171 static int ccp_printpkt __P((u_char *pkt, int len,
172 void (*printer) __P((void *, char *, ...)),
174 static void ccp_datainput __P((int unit, u_char *pkt, int len));
176 struct protent ccp_protent = {
196 fsm ccp_fsm[NUM_PPP];
197 ccp_options ccp_wantoptions[NUM_PPP]; /* what to request the peer to use */
198 ccp_options ccp_gotoptions[NUM_PPP]; /* what the peer agreed to do */
199 ccp_options ccp_allowoptions[NUM_PPP]; /* what we'll agree to do */
200 ccp_options ccp_hisoptions[NUM_PPP]; /* what we agreed to do */
203 * Callbacks for fsm code.
205 static void ccp_resetci __P((fsm *));
206 static int ccp_cilen __P((fsm *));
207 static void ccp_addci __P((fsm *, u_char *, int *));
208 static int ccp_ackci __P((fsm *, u_char *, int));
209 static int ccp_nakci __P((fsm *, u_char *, int));
210 static int ccp_rejci __P((fsm *, u_char *, int));
211 static int ccp_reqci __P((fsm *, u_char *, int *, int));
212 static void ccp_up __P((fsm *));
213 static void ccp_down __P((fsm *));
214 static int ccp_extcode __P((fsm *, int, int, u_char *, int));
215 static void ccp_rack_timeout __P((void *));
216 static char *method_name __P((ccp_options *, ccp_options *));
218 static fsm_callbacks ccp_callbacks = {
237 * Do we want / did we get any compression?
239 #define ANY_COMPRESS(opt) ((opt).deflate || (opt).bsd_compress \
240 || (opt).predictor_1 || (opt).predictor_2 \
244 * Local state (mainly for handling reset-reqs and reset-acks).
246 static int ccp_localstate[NUM_PPP];
247 #define RACK_PENDING 1 /* waiting for reset-ack */
248 #define RREQ_REPEAT 2 /* send another reset-req if no reset-ack */
250 #define RACKTIMEOUT 1 /* second */
252 static int all_rejected[NUM_PPP]; /* we rejected all peer's options */
265 abits = rbits = strtol(str, &endp, 0);
266 if (endp != str && *endp == ',') {
268 abits = strtol(str, &endp, 0);
270 if (*endp != 0 || endp == str) {
271 option_error("invalid parameter '%s' for bsdcomp option", *argv);
274 if ((rbits != 0 && (rbits < BSD_MIN_BITS || rbits > BSD_MAX_BITS))
275 || (abits != 0 && (abits < BSD_MIN_BITS || abits > BSD_MAX_BITS))) {
276 option_error("bsdcomp option values must be 0 or %d .. %d",
277 BSD_MIN_BITS, BSD_MAX_BITS);
281 ccp_wantoptions[0].bsd_compress = 1;
282 ccp_wantoptions[0].bsd_bits = rbits;
284 ccp_wantoptions[0].bsd_compress = 0;
286 ccp_allowoptions[0].bsd_compress = 1;
287 ccp_allowoptions[0].bsd_bits = abits;
289 ccp_allowoptions[0].bsd_compress = 0;
290 slprintf(bsd_value, sizeof(bsd_value),
291 rbits == abits? "%d": "%d,%d", rbits, abits);
304 abits = rbits = strtol(str, &endp, 0);
305 if (endp != str && *endp == ',') {
307 abits = strtol(str, &endp, 0);
309 if (*endp != 0 || endp == str) {
310 option_error("invalid parameter '%s' for deflate option", *argv);
313 if ((rbits != 0 && (rbits < DEFLATE_MIN_SIZE || rbits > DEFLATE_MAX_SIZE))
314 || (abits != 0 && (abits < DEFLATE_MIN_SIZE
315 || abits > DEFLATE_MAX_SIZE))) {
316 option_error("deflate option values must be 0 or %d .. %d",
317 DEFLATE_MIN_SIZE, DEFLATE_MAX_SIZE);
320 if (rbits == DEFLATE_MIN_SIZE || abits == DEFLATE_MIN_SIZE) {
321 if (rbits == DEFLATE_MIN_SIZE)
322 rbits = DEFLATE_MIN_WORKS;
323 if (abits == DEFLATE_MIN_SIZE)
324 abits = DEFLATE_MIN_WORKS;
325 warn("deflate option value of %d changed to %d to avoid zlib bug",
326 DEFLATE_MIN_SIZE, DEFLATE_MIN_WORKS);
329 ccp_wantoptions[0].deflate = 1;
330 ccp_wantoptions[0].deflate_size = rbits;
332 ccp_wantoptions[0].deflate = 0;
334 ccp_allowoptions[0].deflate = 1;
335 ccp_allowoptions[0].deflate_size = abits;
337 ccp_allowoptions[0].deflate = 0;
338 slprintf(deflate_value, sizeof(deflate_value),
339 rbits == abits? "%d": "%d,%d", rbits, abits);
345 * ccp_init - initialize CCP.
351 fsm *f = &ccp_fsm[unit];
354 f->protocol = PPP_CCP;
355 f->callbacks = &ccp_callbacks;
358 memset(&ccp_wantoptions[unit], 0, sizeof(ccp_options));
359 memset(&ccp_gotoptions[unit], 0, sizeof(ccp_options));
360 memset(&ccp_allowoptions[unit], 0, sizeof(ccp_options));
361 memset(&ccp_hisoptions[unit], 0, sizeof(ccp_options));
363 ccp_wantoptions[0].deflate = 1;
364 ccp_wantoptions[0].deflate_size = DEFLATE_MAX_SIZE;
365 ccp_wantoptions[0].deflate_correct = 1;
366 ccp_wantoptions[0].deflate_draft = 1;
367 ccp_allowoptions[0].deflate = 1;
368 ccp_allowoptions[0].deflate_size = DEFLATE_MAX_SIZE;
369 ccp_allowoptions[0].deflate_correct = 1;
370 ccp_allowoptions[0].deflate_draft = 1;
372 ccp_wantoptions[0].bsd_compress = 1;
373 ccp_wantoptions[0].bsd_bits = BSD_MAX_BITS;
374 ccp_allowoptions[0].bsd_compress = 1;
375 ccp_allowoptions[0].bsd_bits = BSD_MAX_BITS;
377 ccp_allowoptions[0].predictor_1 = 1;
381 * ccp_open - CCP is allowed to come up.
387 fsm *f = &ccp_fsm[unit];
389 if (f->state != OPENED)
390 ccp_flags_set(unit, 1, 0);
393 * Find out which compressors the kernel supports before
394 * deciding whether to open in silent mode.
397 if (!ANY_COMPRESS(ccp_gotoptions[unit]))
398 f->flags |= OPT_SILENT;
404 * ccp_close - Terminate CCP.
407 ccp_close(unit, reason)
411 ccp_flags_set(unit, 0, 0);
412 fsm_close(&ccp_fsm[unit], reason);
416 * ccp_lowerup - we may now transmit CCP packets.
422 fsm_lowerup(&ccp_fsm[unit]);
426 * ccp_lowerdown - we may not transmit CCP packets.
432 fsm_lowerdown(&ccp_fsm[unit]);
436 * ccp_input - process a received CCP packet.
439 ccp_input(unit, p, len)
444 fsm *f = &ccp_fsm[unit];
448 * Check for a terminate-request so we can print a message.
451 fsm_input(f, p, len);
452 if (oldstate == OPENED && p[0] == TERMREQ && f->state != OPENED) {
453 notice("Compression disabled by peer.");
455 if (ccp_gotoptions[unit].mppe) {
456 error("MPPE disabled, closing LCP");
457 lcp_close(unit, "MPPE disabled by peer");
463 * If we get a terminate-ack and we're not asking for compression,
466 if (oldstate == REQSENT && p[0] == TERMACK
467 && !ANY_COMPRESS(ccp_gotoptions[unit]))
468 ccp_close(unit, "No compression negotiated");
472 * Handle a CCP-specific code.
475 ccp_extcode(f, code, id, p, len)
483 if (f->state != OPENED)
485 /* send a reset-ack, which the transmitter will see and
486 reset its compression state. */
487 fsm_sdata(f, CCP_RESETACK, id, NULL, 0);
491 if (ccp_localstate[f->unit] & RACK_PENDING && id == f->reqid) {
492 ccp_localstate[f->unit] &= ~(RACK_PENDING | RREQ_REPEAT);
493 UNTIMEOUT(ccp_rack_timeout, f);
505 * ccp_protrej - peer doesn't talk CCP.
511 ccp_flags_set(unit, 0, 0);
512 fsm_lowerdown(&ccp_fsm[unit]);
515 if (ccp_gotoptions[unit].mppe) {
516 error("MPPE required but peer negotiation failed");
517 lcp_close(unit, "MPPE required but peer negotiation failed");
524 * ccp_resetci - initialize at start of negotiation.
530 ccp_options *go = &ccp_gotoptions[f->unit];
531 u_char opt_buf[CCP_MAX_OPTION_LENGTH];
533 *go = ccp_wantoptions[f->unit];
534 all_rejected[f->unit] = 0;
538 ccp_options *ao = &ccp_allowoptions[f->unit];
539 int auth_mschap_bits = auth_done[f->unit];
543 * Start with a basic sanity check: mschap[v2] auth must be in
544 * exactly one direction. RFC 3079 says that the keys are
545 * 'derived from the credentials of the peer that initiated the call',
546 * however the PPP protocol doesn't have such a concept, and pppd
547 * cannot get this info externally. Instead we do the best we can.
548 * NB: If MPPE is required, all other compression opts are invalid.
549 * So, we return right away if we can't do it.
552 /* Leave only the mschap auth bits set */
553 auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER |
554 CHAP_MS2_WITHPEER | CHAP_MS2_PEER);
555 /* Count the mschap auths */
556 auth_mschap_bits >>= CHAP_MS_SHIFT;
559 numbits += auth_mschap_bits & 1;
560 auth_mschap_bits >>= 1;
561 } while (auth_mschap_bits);
563 error("MPPE required, but auth done in both directions.");
564 lcp_close(f->unit, "MPPE required but not available");
568 error("MPPE required, but MS-CHAP[v2] auth not performed.");
569 lcp_close(f->unit, "MPPE required but not available");
573 /* LM auth not supported for MPPE */
574 if (auth_done[f->unit] & (CHAP_MS_WITHPEER | CHAP_MS_PEER)) {
575 /* This might be noise */
576 if (go->mppe & MPPE_OPT_40) {
577 notice("Disabling 40-bit MPPE; MS-CHAP LM not supported");
578 go->mppe &= ~MPPE_OPT_40;
579 ccp_wantoptions[f->unit].mppe &= ~MPPE_OPT_40;
583 /* Last check: can we actually negotiate something? */
584 if (!(go->mppe & (MPPE_OPT_40 | MPPE_OPT_128))) {
585 /* Could be misconfig, could be 40-bit disabled above. */
586 error("MPPE required, but both 40-bit and 128-bit disabled.");
587 lcp_close(f->unit, "MPPE required but not available");
593 /* MPPE is not compatible with other compression types */
594 ao->bsd_compress = go->bsd_compress = 0;
595 ao->predictor_1 = go->predictor_1 = 0;
596 ao->predictor_2 = go->predictor_2 = 0;
597 ao->deflate = go->deflate = 0;
602 * Check whether the kernel knows about the various
603 * compression methods we might request.
607 opt_buf[0] = CI_MPPE;
608 opt_buf[1] = CILEN_MPPE;
609 MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
610 /* Key material unimportant here. */
611 if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0) {
612 error("MPPE required, but kernel has no support.");
613 lcp_close(f->unit, "MPPE required but not available");
617 if (go->bsd_compress) {
618 opt_buf[0] = CI_BSD_COMPRESS;
619 opt_buf[1] = CILEN_BSD_COMPRESS;
620 opt_buf[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, BSD_MIN_BITS);
621 if (ccp_test(f->unit, opt_buf, CILEN_BSD_COMPRESS, 0) <= 0)
622 go->bsd_compress = 0;
625 if (go->deflate_correct) {
626 opt_buf[0] = CI_DEFLATE;
627 opt_buf[1] = CILEN_DEFLATE;
628 opt_buf[2] = DEFLATE_MAKE_OPT(DEFLATE_MIN_WORKS);
629 opt_buf[3] = DEFLATE_CHK_SEQUENCE;
630 if (ccp_test(f->unit, opt_buf, CILEN_DEFLATE, 0) <= 0)
631 go->deflate_correct = 0;
633 if (go->deflate_draft) {
634 opt_buf[0] = CI_DEFLATE_DRAFT;
635 opt_buf[1] = CILEN_DEFLATE;
636 opt_buf[2] = DEFLATE_MAKE_OPT(DEFLATE_MIN_WORKS);
637 opt_buf[3] = DEFLATE_CHK_SEQUENCE;
638 if (ccp_test(f->unit, opt_buf, CILEN_DEFLATE, 0) <= 0)
639 go->deflate_draft = 0;
641 if (!go->deflate_correct && !go->deflate_draft)
644 if (go->predictor_1) {
645 opt_buf[0] = CI_PREDICTOR_1;
646 opt_buf[1] = CILEN_PREDICTOR_1;
647 if (ccp_test(f->unit, opt_buf, CILEN_PREDICTOR_1, 0) <= 0)
650 if (go->predictor_2) {
651 opt_buf[0] = CI_PREDICTOR_2;
652 opt_buf[1] = CILEN_PREDICTOR_2;
653 if (ccp_test(f->unit, opt_buf, CILEN_PREDICTOR_2, 0) <= 0)
659 * ccp_cilen - Return total length of our configuration info.
665 ccp_options *go = &ccp_gotoptions[f->unit];
667 return (go->bsd_compress? CILEN_BSD_COMPRESS: 0)
668 + (go->deflate? CILEN_DEFLATE: 0)
669 + (go->predictor_1? CILEN_PREDICTOR_1: 0)
670 + (go->predictor_2? CILEN_PREDICTOR_2: 0)
671 + (go->mppe? CILEN_MPPE: 0);
675 * ccp_addci - put our requests in a packet.
678 ccp_addci(f, p, lenp)
684 ccp_options *go = &ccp_gotoptions[f->unit];
688 * Add the compression types that we can receive, in decreasing
689 * preference order. Get the kernel to allocate the first one
690 * in case it gets Acked.
694 u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
696 p[0] = opt_buf[0] = CI_MPPE;
697 p[1] = opt_buf[1] = CILEN_MPPE;
698 MPPE_OPTS_TO_CI(go->mppe, &p[2]);
699 MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
700 BCOPY(mppe_recv_key, &opt_buf[CILEN_MPPE], MPPE_MAX_KEY_LEN);
701 res = ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0);
705 /* This shouldn't happen, we've already tested it! */
706 lcp_close(f->unit, "MPPE required but not available in kernel");
710 p[0] = go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT;
711 p[1] = CILEN_DEFLATE;
712 p[2] = DEFLATE_MAKE_OPT(go->deflate_size);
713 p[3] = DEFLATE_CHK_SEQUENCE;
715 if (go->deflate_size < DEFLATE_MIN_WORKS) {
719 res = ccp_test(f->unit, p, CILEN_DEFLATE, 0);
723 } else if (res < 0) {
728 p[2] = DEFLATE_MAKE_OPT(go->deflate_size);
730 if (p != p0 && go->deflate_correct && go->deflate_draft) {
731 p[0] = CI_DEFLATE_DRAFT;
732 p[1] = CILEN_DEFLATE;
733 p[2] = p[2 - CILEN_DEFLATE];
734 p[3] = DEFLATE_CHK_SEQUENCE;
738 if (go->bsd_compress) {
739 p[0] = CI_BSD_COMPRESS;
740 p[1] = CILEN_BSD_COMPRESS;
741 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits);
743 p += CILEN_BSD_COMPRESS; /* not the first option */
746 if (go->bsd_bits < BSD_MIN_BITS) {
747 go->bsd_compress = 0;
750 res = ccp_test(f->unit, p, CILEN_BSD_COMPRESS, 0);
752 p += CILEN_BSD_COMPRESS;
754 } else if (res < 0) {
755 go->bsd_compress = 0;
759 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits);
763 /* XXX Should Predictor 2 be preferable to Predictor 1? */
764 if (go->predictor_1) {
765 p[0] = CI_PREDICTOR_1;
766 p[1] = CILEN_PREDICTOR_1;
767 if (p == p0 && ccp_test(f->unit, p, CILEN_PREDICTOR_1, 0) <= 0) {
770 p += CILEN_PREDICTOR_1;
773 if (go->predictor_2) {
774 p[0] = CI_PREDICTOR_2;
775 p[1] = CILEN_PREDICTOR_2;
776 if (p == p0 && ccp_test(f->unit, p, CILEN_PREDICTOR_2, 0) <= 0) {
779 p += CILEN_PREDICTOR_2;
783 go->method = (p > p0)? p0[0]: -1;
789 * ccp_ackci - process a received configure-ack, and return
790 * 1 iff the packet was OK.
798 ccp_options *go = &ccp_gotoptions[f->unit];
803 u_char opt_buf[CILEN_MPPE];
805 opt_buf[0] = CI_MPPE;
806 opt_buf[1] = CILEN_MPPE;
807 MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
808 if (len < CILEN_MPPE || memcmp(opt_buf, p, CILEN_MPPE))
812 /* XXX Cope with first/fast ack */
818 if (len < CILEN_DEFLATE
819 || p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
820 || p[1] != CILEN_DEFLATE
821 || p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
822 || p[3] != DEFLATE_CHK_SEQUENCE)
825 len -= CILEN_DEFLATE;
826 /* XXX Cope with first/fast ack */
829 if (go->deflate_correct && go->deflate_draft) {
830 if (len < CILEN_DEFLATE
831 || p[0] != CI_DEFLATE_DRAFT
832 || p[1] != CILEN_DEFLATE
833 || p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
834 || p[3] != DEFLATE_CHK_SEQUENCE)
837 len -= CILEN_DEFLATE;
840 if (go->bsd_compress) {
841 if (len < CILEN_BSD_COMPRESS
842 || p[0] != CI_BSD_COMPRESS || p[1] != CILEN_BSD_COMPRESS
843 || p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits))
845 p += CILEN_BSD_COMPRESS;
846 len -= CILEN_BSD_COMPRESS;
847 /* XXX Cope with first/fast ack */
848 if (p == p0 && len == 0)
851 if (go->predictor_1) {
852 if (len < CILEN_PREDICTOR_1
853 || p[0] != CI_PREDICTOR_1 || p[1] != CILEN_PREDICTOR_1)
855 p += CILEN_PREDICTOR_1;
856 len -= CILEN_PREDICTOR_1;
857 /* XXX Cope with first/fast ack */
858 if (p == p0 && len == 0)
861 if (go->predictor_2) {
862 if (len < CILEN_PREDICTOR_2
863 || p[0] != CI_PREDICTOR_2 || p[1] != CILEN_PREDICTOR_2)
865 p += CILEN_PREDICTOR_2;
866 len -= CILEN_PREDICTOR_2;
867 /* XXX Cope with first/fast ack */
868 if (p == p0 && len == 0)
878 * ccp_nakci - process received configure-nak.
879 * Returns 1 iff the nak was OK.
887 ccp_options *go = &ccp_gotoptions[f->unit];
888 ccp_options no; /* options we've seen already */
889 ccp_options try; /* options to ask for next time */
891 memset(&no, 0, sizeof(no));
895 if (go->mppe && len >= CILEN_MPPE
896 && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
899 * Peer wants us to use a different strength or other setting.
900 * Fail if we aren't willing to use his suggestion.
902 MPPE_CI_TO_OPTS(&p[2], try.mppe);
903 if ((try.mppe & MPPE_OPT_STATEFUL) && refuse_mppe_stateful)
905 else if ((go->mppe & try.mppe) != try.mppe)
906 /* Peer must have set options we didn't request (suggest) */
910 error("MPPE required but peer negotiation failed");
911 lcp_close(f->unit, "MPPE required but peer negotiation failed");
915 if (go->deflate && len >= CILEN_DEFLATE
916 && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
917 && p[1] == CILEN_DEFLATE) {
920 * Peer wants us to use a different code size or something.
921 * Stop asking for Deflate if we don't understand his suggestion.
923 if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL
924 || DEFLATE_SIZE(p[2]) < DEFLATE_MIN_WORKS
925 || p[3] != DEFLATE_CHK_SEQUENCE)
927 else if (DEFLATE_SIZE(p[2]) < go->deflate_size)
928 try.deflate_size = DEFLATE_SIZE(p[2]);
930 len -= CILEN_DEFLATE;
931 if (go->deflate_correct && go->deflate_draft
932 && len >= CILEN_DEFLATE && p[0] == CI_DEFLATE_DRAFT
933 && p[1] == CILEN_DEFLATE) {
935 len -= CILEN_DEFLATE;
939 if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
940 && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
943 * Peer wants us to use a different number of bits
944 * or a different version.
946 if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION)
947 try.bsd_compress = 0;
948 else if (BSD_NBITS(p[2]) < go->bsd_bits)
949 try.bsd_bits = BSD_NBITS(p[2]);
950 p += CILEN_BSD_COMPRESS;
951 len -= CILEN_BSD_COMPRESS;
955 * Predictor-1 and 2 have no options, so they can't be Naked.
957 * There may be remaining options but we ignore them.
960 if (f->state != OPENED)
966 * ccp_rejci - reject some of our suggested compression methods.
974 ccp_options *go = &ccp_gotoptions[f->unit];
975 ccp_options try; /* options to request next time */
980 * Cope with empty configure-rejects by ceasing to send
981 * configure-requests.
983 if (len == 0 && all_rejected[f->unit])
987 if (go->mppe && len >= CILEN_MPPE
988 && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
989 error("MPPE required but peer refused");
990 lcp_close(f->unit, "MPPE required but peer refused");
995 if (go->deflate && len >= CILEN_DEFLATE
996 && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
997 && p[1] == CILEN_DEFLATE) {
998 if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
999 || p[3] != DEFLATE_CHK_SEQUENCE)
1000 return 0; /* Rej is bad */
1001 if (go->deflate_correct)
1002 try.deflate_correct = 0;
1004 try.deflate_draft = 0;
1006 len -= CILEN_DEFLATE;
1007 if (go->deflate_correct && go->deflate_draft
1008 && len >= CILEN_DEFLATE && p[0] == CI_DEFLATE_DRAFT
1009 && p[1] == CILEN_DEFLATE) {
1010 if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
1011 || p[3] != DEFLATE_CHK_SEQUENCE)
1012 return 0; /* Rej is bad */
1013 try.deflate_draft = 0;
1015 len -= CILEN_DEFLATE;
1017 if (!try.deflate_correct && !try.deflate_draft)
1020 if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
1021 && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
1022 if (p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits))
1024 try.bsd_compress = 0;
1025 p += CILEN_BSD_COMPRESS;
1026 len -= CILEN_BSD_COMPRESS;
1028 if (go->predictor_1 && len >= CILEN_PREDICTOR_1
1029 && p[0] == CI_PREDICTOR_1 && p[1] == CILEN_PREDICTOR_1) {
1030 try.predictor_1 = 0;
1031 p += CILEN_PREDICTOR_1;
1032 len -= CILEN_PREDICTOR_1;
1034 if (go->predictor_2 && len >= CILEN_PREDICTOR_2
1035 && p[0] == CI_PREDICTOR_2 && p[1] == CILEN_PREDICTOR_2) {
1036 try.predictor_2 = 0;
1037 p += CILEN_PREDICTOR_2;
1038 len -= CILEN_PREDICTOR_2;
1044 if (f->state != OPENED)
1051 * ccp_reqci - processed a received configure-request.
1052 * Returns CONFACK, CONFNAK or CONFREJ and the packet modified
1056 ccp_reqci(f, p, lenp, dont_nak)
1062 int ret, newret, res;
1064 int len, clen, type, nb;
1065 ccp_options *ho = &ccp_hisoptions[f->unit];
1066 ccp_options *ao = &ccp_allowoptions[f->unit];
1068 bool seen_ci_mppe = 0;
1075 memset(ho, 0, sizeof(ccp_options));
1076 ho->method = (len > 0)? p[0]: -1;
1080 if (len < 2 || p[1] < 2 || p[1] > len) {
1092 if (!ao->mppe || clen != CILEN_MPPE) {
1097 MPPE_CI_TO_OPTS(&p[2], ho->mppe);
1099 /* Nak if anything unsupported or unknown are set. */
1100 if (ho->mppe & MPPE_OPT_UNSUPPORTED) {
1102 ho->mppe &= ~MPPE_OPT_UNSUPPORTED;
1104 if (ho->mppe & MPPE_OPT_UNKNOWN) {
1106 ho->mppe &= ~MPPE_OPT_UNKNOWN;
1109 /* Check state opt */
1110 if (ho->mppe & MPPE_OPT_STATEFUL) {
1111 if (refuse_mppe_stateful) {
1113 * We can Nak and request stateless, but it's a
1114 * lot easier to just assume the peer will request
1115 * it if he can do it; stateful mode is bad over
1116 * the Internet -- which is where we expect MPPE.
1125 /* Find out which of {S,L} are set. */
1126 if ((ho->mppe & MPPE_OPT_128)
1127 && (ho->mppe & MPPE_OPT_40)) {
1128 /* Both are set, negotiate the strongest. */
1130 if (ao->mppe & MPPE_OPT_128)
1131 ho->mppe &= ~MPPE_OPT_40;
1132 else if (ao->mppe & MPPE_OPT_40)
1133 ho->mppe &= ~MPPE_OPT_128;
1138 } else if (ho->mppe & MPPE_OPT_128) {
1139 if (!(ao->mppe & MPPE_OPT_128)) {
1143 } else if (ho->mppe & MPPE_OPT_40) {
1144 if (!(ao->mppe & MPPE_OPT_40)) {
1149 /* Neither are set. */
1154 /* rebuild the opts */
1155 MPPE_OPTS_TO_CI(ho->mppe, &p[2]);
1156 if (newret == CONFACK) {
1157 u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
1160 BCOPY(p, opt_buf, CILEN_MPPE);
1161 BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
1163 if (ccp_test(f->unit, opt_buf,
1164 CILEN_MPPE + MPPE_MAX_KEY_LEN, 1) <= 0) {
1165 /* This shouldn't happen, we've already tested it! */
1166 error("MPPE required, but kernel has no support.");
1167 lcp_close(f->unit, "MPPE required but not available");
1172 * We need to decrease the interface MTU by MPPE_PAD
1173 * because MPPE frames **grow**. The kernel [must]
1174 * allocate MPPE_PAD extra bytes in xmit buffers.
1176 mtu = netif_get_mtu(f->unit);
1178 netif_set_mtu(f->unit, mtu - MPPE_PAD);
1186 case CI_DEFLATE_DRAFT:
1187 if (!ao->deflate || clen != CILEN_DEFLATE
1188 || (!ao->deflate_correct && type == CI_DEFLATE)
1189 || (!ao->deflate_draft && type == CI_DEFLATE_DRAFT)) {
1195 ho->deflate_size = nb = DEFLATE_SIZE(p[2]);
1196 if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL
1197 || p[3] != DEFLATE_CHK_SEQUENCE
1198 || nb > ao->deflate_size || nb < DEFLATE_MIN_WORKS) {
1201 p[2] = DEFLATE_MAKE_OPT(ao->deflate_size);
1202 p[3] = DEFLATE_CHK_SEQUENCE;
1203 /* fall through to test this #bits below */
1209 * Check whether we can do Deflate with the window
1210 * size they want. If the window is too big, reduce
1211 * it until the kernel can cope and nak with that.
1212 * We only check this for the first option.
1216 res = ccp_test(f->unit, p, CILEN_DEFLATE, 1);
1218 break; /* it's OK now */
1219 if (res < 0 || nb == DEFLATE_MIN_WORKS || dont_nak) {
1221 p[2] = DEFLATE_MAKE_OPT(ho->deflate_size);
1226 p[2] = DEFLATE_MAKE_OPT(nb);
1231 case CI_BSD_COMPRESS:
1232 if (!ao->bsd_compress || clen != CILEN_BSD_COMPRESS) {
1237 ho->bsd_compress = 1;
1238 ho->bsd_bits = nb = BSD_NBITS(p[2]);
1239 if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION
1240 || nb > ao->bsd_bits || nb < BSD_MIN_BITS) {
1243 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, ao->bsd_bits);
1244 /* fall through to test this #bits below */
1250 * Check whether we can do BSD-Compress with the code
1251 * size they want. If the code size is too big, reduce
1252 * it until the kernel can cope and nak with that.
1253 * We only check this for the first option.
1257 res = ccp_test(f->unit, p, CILEN_BSD_COMPRESS, 1);
1260 if (res < 0 || nb == BSD_MIN_BITS || dont_nak) {
1262 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION,
1268 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, nb);
1273 case CI_PREDICTOR_1:
1274 if (!ao->predictor_1 || clen != CILEN_PREDICTOR_1) {
1279 ho->predictor_1 = 1;
1281 && ccp_test(f->unit, p, CILEN_PREDICTOR_1, 1) <= 0) {
1286 case CI_PREDICTOR_2:
1287 if (!ao->predictor_2 || clen != CILEN_PREDICTOR_2) {
1292 ho->predictor_2 = 1;
1294 && ccp_test(f->unit, p, CILEN_PREDICTOR_2, 1) <= 0) {
1304 if (newret == CONFNAK && dont_nak)
1306 if (!(newret == CONFACK || (newret == CONFNAK && ret == CONFREJ))) {
1307 /* we're returning this option */
1308 if (newret == CONFREJ && ret == CONFNAK)
1312 BCOPY(p, retp, clen);
1320 if (ret != CONFACK) {
1321 if (ret == CONFREJ && *lenp == retp - p0)
1322 all_rejected[f->unit] = 1;
1327 if (ret == CONFREJ && ao->mppe && !seen_ci_mppe) {
1328 error("MPPE required but peer negotiation failed");
1329 lcp_close(f->unit, "MPPE required but peer negotiation failed");
1336 * Make a string name for a compression method (or 2).
1339 method_name(opt, opt2)
1340 ccp_options *opt, *opt2;
1342 static char result[64];
1344 if (!ANY_COMPRESS(*opt))
1346 switch (opt->method) {
1351 char *q = result + sizeof(result); /* 1 past result */
1353 slprintf(p, q - p, "MPPE ");
1355 if (opt->mppe & MPPE_OPT_128) {
1356 slprintf(p, q - p, "128-bit ");
1359 if (opt->mppe & MPPE_OPT_40) {
1360 slprintf(p, q - p, "40-bit ");
1363 if (opt->mppe & MPPE_OPT_STATEFUL)
1364 slprintf(p, q - p, "stateful");
1366 slprintf(p, q - p, "stateless");
1372 case CI_DEFLATE_DRAFT:
1373 if (opt2 != NULL && opt2->deflate_size != opt->deflate_size)
1374 slprintf(result, sizeof(result), "Deflate%s (%d/%d)",
1375 (opt->method == CI_DEFLATE_DRAFT? "(old#)": ""),
1376 opt->deflate_size, opt2->deflate_size);
1378 slprintf(result, sizeof(result), "Deflate%s (%d)",
1379 (opt->method == CI_DEFLATE_DRAFT? "(old#)": ""),
1382 case CI_BSD_COMPRESS:
1383 if (opt2 != NULL && opt2->bsd_bits != opt->bsd_bits)
1384 slprintf(result, sizeof(result), "BSD-Compress (%d/%d)",
1385 opt->bsd_bits, opt2->bsd_bits);
1387 slprintf(result, sizeof(result), "BSD-Compress (%d)",
1390 case CI_PREDICTOR_1:
1391 return "Predictor 1";
1392 case CI_PREDICTOR_2:
1393 return "Predictor 2";
1395 slprintf(result, sizeof(result), "Method %d", opt->method);
1401 * CCP has come up - inform the kernel driver and log a message.
1407 ccp_options *go = &ccp_gotoptions[f->unit];
1408 ccp_options *ho = &ccp_hisoptions[f->unit];
1411 ccp_flags_set(f->unit, 1, 1);
1412 if (ANY_COMPRESS(*go)) {
1413 if (ANY_COMPRESS(*ho)) {
1414 if (go->method == ho->method) {
1415 notice("%s compression enabled", method_name(go, ho));
1417 strlcpy(method1, method_name(go, NULL), sizeof(method1));
1418 notice("%s / %s compression enabled",
1419 method1, method_name(ho, NULL));
1422 notice("%s receive compression enabled", method_name(go, NULL));
1423 } else if (ANY_COMPRESS(*ho))
1424 notice("%s transmit compression enabled", method_name(ho, NULL));
1427 BZERO(mppe_recv_key, MPPE_MAX_KEY_LEN);
1428 BZERO(mppe_send_key, MPPE_MAX_KEY_LEN);
1429 continue_networks(f->unit); /* Bring up IP et al */
1435 * CCP has gone down - inform the kernel driver.
1441 if (ccp_localstate[f->unit] & RACK_PENDING)
1442 UNTIMEOUT(ccp_rack_timeout, f);
1443 ccp_localstate[f->unit] = 0;
1444 ccp_flags_set(f->unit, 1, 0);
1446 if (ccp_gotoptions[f->unit].mppe) {
1447 ccp_gotoptions[f->unit].mppe = 0;
1448 if (lcp_fsm[f->unit].state == OPENED) {
1449 /* If LCP is not already going down, make sure it does. */
1450 error("MPPE disabled");
1451 lcp_close(f->unit, "MPPE disabled");
1458 * Print the contents of a CCP packet.
1460 static char *ccp_codenames[] = {
1461 "ConfReq", "ConfAck", "ConfNak", "ConfRej",
1462 "TermReq", "TermAck", "CodeRej",
1463 NULL, NULL, NULL, NULL, NULL, NULL,
1464 "ResetReq", "ResetAck",
1468 ccp_printpkt(p, plen, printer, arg)
1471 void (*printer) __P((void *, char *, ...));
1474 u_char *p0, *optend;
1479 if (plen < HEADERLEN)
1483 len = (p[2] << 8) + p[3];
1484 if (len < HEADERLEN || len > plen)
1487 if (code >= 1 && code <= sizeof(ccp_codenames) / sizeof(char *)
1488 && ccp_codenames[code-1] != NULL)
1489 printer(arg, " %s", ccp_codenames[code-1]);
1491 printer(arg, " code=0x%x", code);
1492 printer(arg, " id=0x%x", id);
1501 /* print list of possible compression methods */
1505 if (optlen < 2 || optlen > len)
1509 optend = p + optlen;
1513 if (optlen >= CILEN_MPPE) {
1516 MPPE_CI_TO_OPTS(&p[2], mppe_opts);
1517 printer(arg, "mppe %s %s %s %s %s %s%s",
1518 (p[2] & MPPE_H_BIT)? "+H": "-H",
1519 (p[5] & MPPE_M_BIT)? "+M": "-M",
1520 (p[5] & MPPE_S_BIT)? "+S": "-S",
1521 (p[5] & MPPE_L_BIT)? "+L": "-L",
1522 (p[5] & MPPE_D_BIT)? "+D": "-D",
1523 (p[5] & MPPE_C_BIT)? "+C": "-C",
1524 (mppe_opts & MPPE_OPT_UNKNOWN)? " +U": "");
1525 if (mppe_opts & MPPE_OPT_UNKNOWN)
1526 printer(arg, " (%.2x %.2x %.2x %.2x)",
1527 p[2], p[3], p[4], p[5]);
1533 case CI_DEFLATE_DRAFT:
1534 if (optlen >= CILEN_DEFLATE) {
1535 printer(arg, "deflate%s %d",
1536 (code == CI_DEFLATE_DRAFT? "(old#)": ""),
1537 DEFLATE_SIZE(p[2]));
1538 if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL)
1539 printer(arg, " method %d", DEFLATE_METHOD(p[2]));
1540 if (p[3] != DEFLATE_CHK_SEQUENCE)
1541 printer(arg, " check %d", p[3]);
1545 case CI_BSD_COMPRESS:
1546 if (optlen >= CILEN_BSD_COMPRESS) {
1547 printer(arg, "bsd v%d %d", BSD_VERSION(p[2]),
1549 p += CILEN_BSD_COMPRESS;
1552 case CI_PREDICTOR_1:
1553 if (optlen >= CILEN_PREDICTOR_1) {
1554 printer(arg, "predictor 1");
1555 p += CILEN_PREDICTOR_1;
1558 case CI_PREDICTOR_2:
1559 if (optlen >= CILEN_PREDICTOR_2) {
1560 printer(arg, "predictor 2");
1561 p += CILEN_PREDICTOR_2;
1566 printer(arg, " %.2x", *p++);
1573 if (len > 0 && *p >= ' ' && *p < 0x7f) {
1574 print_string((char *)p, len, printer, arg);
1581 /* dump out the rest of the packet in hex */
1583 printer(arg, " %.2x", *p++);
1589 * We have received a packet that the decompressor failed to
1590 * decompress. Here we would expect to issue a reset-request, but
1591 * Motorola has a patent on resetting the compressor as a result of
1592 * detecting an error in the decompressed data after decompression.
1593 * (See US patent 5,130,993; international patent publication number
1594 * WO 91/10289; Australian patent 73296/91.)
1596 * So we ask the kernel whether the error was detected after
1597 * decompression; if it was, we take CCP down, thus disabling
1598 * compression :-(, otherwise we issue the reset-request.
1601 ccp_datainput(unit, pkt, len)
1609 if (f->state == OPENED) {
1610 if (ccp_fatal_error(unit)) {
1612 * Disable compression by taking CCP down.
1614 error("Lost compression sync: disabling compression");
1615 ccp_close(unit, "Lost compression sync");
1618 * If we were doing MPPE, we must also take the link down.
1620 if (ccp_gotoptions[unit].mppe) {
1621 error("Too many MPPE errors, closing LCP");
1622 lcp_close(unit, "Too many MPPE errors");
1627 * Send a reset-request to reset the peer's compressor.
1628 * We don't do that if we are still waiting for an
1629 * acknowledgement to a previous reset-request.
1631 if (!(ccp_localstate[f->unit] & RACK_PENDING)) {
1632 fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0);
1633 TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT);
1634 ccp_localstate[f->unit] |= RACK_PENDING;
1636 ccp_localstate[f->unit] |= RREQ_REPEAT;
1642 * Timeout waiting for reset-ack.
1645 ccp_rack_timeout(arg)
1650 if (f->state == OPENED && ccp_localstate[f->unit] & RREQ_REPEAT) {
1651 fsm_sdata(f, CCP_RESETREQ, f->reqid, NULL, 0);
1652 TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT);
1653 ccp_localstate[f->unit] &= ~RREQ_REPEAT;
1655 ccp_localstate[f->unit] &= ~RACK_PENDING;