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,
29 static char rcsid[] = "$Id: ccp.c,v 1.17 1996/07/01 01:11:36 paulus Exp $";
34 #include <sys/ioctl.h>
35 #include <net/ppp-comp.h>
42 * Protocol entry points from main code.
44 static void ccp_init __P((int unit));
45 static void ccp_open __P((int unit));
46 static void ccp_close __P((int unit, char *));
47 static void ccp_lowerup __P((int unit));
48 static void ccp_lowerdown __P((int));
49 static void ccp_input __P((int unit, u_char *pkt, int len));
50 static void ccp_protrej __P((int unit));
51 static int ccp_printpkt __P((u_char *pkt, int len,
52 void (*printer) __P((void *, char *, ...)),
54 static void ccp_datainput __P((int unit, u_char *pkt, int len));
56 struct protent ccp_protent = {
75 ccp_options ccp_wantoptions[NUM_PPP]; /* what to request the peer to use */
76 ccp_options ccp_gotoptions[NUM_PPP]; /* what the peer agreed to do */
77 ccp_options ccp_allowoptions[NUM_PPP]; /* what we'll agree to do */
78 ccp_options ccp_hisoptions[NUM_PPP]; /* what we agreed to do */
81 * Callbacks for fsm code.
83 static void ccp_resetci __P((fsm *));
84 static int ccp_cilen __P((fsm *));
85 static void ccp_addci __P((fsm *, u_char *, int *));
86 static int ccp_ackci __P((fsm *, u_char *, int));
87 static int ccp_nakci __P((fsm *, u_char *, int));
88 static int ccp_rejci __P((fsm *, u_char *, int));
89 static int ccp_reqci __P((fsm *, u_char *, int *, int));
90 static void ccp_up __P((fsm *));
91 static void ccp_down __P((fsm *));
92 static int ccp_extcode __P((fsm *, int, int, u_char *, int));
93 static void ccp_rack_timeout __P(());
94 static char *method_name __P((ccp_options *, ccp_options *));
96 static fsm_callbacks ccp_callbacks = {
115 * Do we want / did we get any compression?
117 #define ANY_COMPRESS(opt) ((opt).deflate || (opt).bsd_compress \
118 || (opt).predictor_1 || (opt).predictor_2)
121 * Local state (mainly for handling reset-reqs and reset-acks).
123 static int ccp_localstate[NUM_PPP];
124 #define RACK_PENDING 1 /* waiting for reset-ack */
125 #define RREQ_REPEAT 2 /* send another reset-req if no reset-ack */
127 #define RACKTIMEOUT 1 /* second */
129 static int all_rejected[NUM_PPP]; /* we rejected all peer's options */
132 * ccp_init - initialize CCP.
138 fsm *f = &ccp_fsm[unit];
141 f->protocol = PPP_CCP;
142 f->callbacks = &ccp_callbacks;
145 memset(&ccp_wantoptions[unit], 0, sizeof(ccp_options));
146 memset(&ccp_gotoptions[unit], 0, sizeof(ccp_options));
147 memset(&ccp_allowoptions[unit], 0, sizeof(ccp_options));
148 memset(&ccp_hisoptions[unit], 0, sizeof(ccp_options));
150 ccp_wantoptions[0].deflate = 1;
151 ccp_wantoptions[0].deflate_size = DEFLATE_MAX_SIZE;
152 ccp_allowoptions[0].deflate = 1;
153 ccp_allowoptions[0].deflate_size = DEFLATE_MAX_SIZE;
155 ccp_wantoptions[0].bsd_compress = 1;
156 ccp_wantoptions[0].bsd_bits = BSD_MAX_BITS;
157 ccp_allowoptions[0].bsd_compress = 1;
158 ccp_allowoptions[0].bsd_bits = BSD_MAX_BITS;
160 ccp_allowoptions[0].predictor_1 = 1;
164 * ccp_open - CCP is allowed to come up.
170 fsm *f = &ccp_fsm[unit];
172 if (f->state != OPENED)
173 ccp_flags_set(unit, 1, 0);
176 * Find out which compressors the kernel supports before
177 * deciding whether to open in silent mode.
180 if (!ANY_COMPRESS(ccp_gotoptions[unit]))
181 f->flags |= OPT_SILENT;
187 * ccp_close - Terminate CCP.
190 ccp_close(unit, reason)
194 ccp_flags_set(unit, 0, 0);
195 fsm_close(&ccp_fsm[unit], reason);
199 * ccp_lowerup - we may now transmit CCP packets.
205 fsm_lowerup(&ccp_fsm[unit]);
209 * ccp_lowerdown - we may not transmit CCP packets.
215 fsm_lowerdown(&ccp_fsm[unit]);
219 * ccp_input - process a received CCP packet.
222 ccp_input(unit, p, len)
227 fsm *f = &ccp_fsm[unit];
231 * Check for a terminate-request so we can print a message.
234 fsm_input(f, p, len);
235 if (oldstate == OPENED && p[0] == TERMREQ && f->state != OPENED)
236 syslog(LOG_NOTICE, "Compression disabled by peer.");
239 * If we get a terminate-ack and we're not asking for compression,
242 if (oldstate == REQSENT && p[0] == TERMACK
243 && !ANY_COMPRESS(ccp_gotoptions[unit]))
244 ccp_close(unit, "No compression negotiated");
248 * Handle a CCP-specific code.
251 ccp_extcode(f, code, id, p, len)
259 if (f->state != OPENED)
261 /* send a reset-ack, which the transmitter will see and
262 reset its compression state. */
263 fsm_sdata(f, CCP_RESETACK, id, NULL, 0);
267 if (ccp_localstate[f->unit] & RACK_PENDING && id == f->reqid) {
268 ccp_localstate[f->unit] &= ~(RACK_PENDING | RREQ_REPEAT);
269 UNTIMEOUT(ccp_rack_timeout, (caddr_t) f);
281 * ccp_protrej - peer doesn't talk CCP.
287 ccp_flags_set(unit, 0, 0);
288 fsm_lowerdown(&ccp_fsm[unit]);
292 * ccp_resetci - initialize at start of negotiation.
298 ccp_options *go = &ccp_gotoptions[f->unit];
301 *go = ccp_wantoptions[f->unit];
302 all_rejected[f->unit] = 0;
305 * Check whether the kernel knows about the various
306 * compression methods we might request.
308 if (go->bsd_compress) {
309 opt_buf[0] = CI_BSD_COMPRESS;
310 opt_buf[1] = CILEN_BSD_COMPRESS;
311 opt_buf[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, BSD_MIN_BITS);
312 if (ccp_test(f->unit, opt_buf, CILEN_BSD_COMPRESS, 0) <= 0)
313 go->bsd_compress = 0;
316 opt_buf[0] = CI_DEFLATE;
317 opt_buf[1] = CILEN_DEFLATE;
318 opt_buf[2] = DEFLATE_MAKE_OPT(DEFLATE_MIN_SIZE);
319 opt_buf[3] = DEFLATE_CHK_SEQUENCE;
320 if (ccp_test(f->unit, opt_buf, CILEN_DEFLATE, 0) <= 0)
323 if (go->predictor_1) {
324 opt_buf[0] = CI_PREDICTOR_1;
325 opt_buf[1] = CILEN_PREDICTOR_1;
326 if (ccp_test(f->unit, opt_buf, CILEN_PREDICTOR_1, 0) <= 0)
329 if (go->predictor_2) {
330 opt_buf[0] = CI_PREDICTOR_2;
331 opt_buf[1] = CILEN_PREDICTOR_2;
332 if (ccp_test(f->unit, opt_buf, CILEN_PREDICTOR_2, 0) <= 0)
338 * ccp_cilen - Return total length of our configuration info.
344 ccp_options *go = &ccp_gotoptions[f->unit];
346 return (go->bsd_compress? CILEN_BSD_COMPRESS: 0)
347 + (go->deflate? CILEN_DEFLATE: 0)
348 + (go->predictor_1? CILEN_PREDICTOR_1: 0)
349 + (go->predictor_2? CILEN_PREDICTOR_2: 0);
353 * ccp_addci - put our requests in a packet.
356 ccp_addci(f, p, lenp)
362 ccp_options *go = &ccp_gotoptions[f->unit];
366 * Add the compression types that we can receive, in decreasing
367 * preference order. Get the kernel to allocate the first one
368 * in case it gets Acked.
372 p[1] = CILEN_DEFLATE;
373 p[2] = DEFLATE_MAKE_OPT(go->deflate_size);
374 p[3] = DEFLATE_CHK_SEQUENCE;
376 res = ccp_test(f->unit, p, CILEN_DEFLATE, 0);
381 if (res < 0 || go->deflate_size <= DEFLATE_MIN_SIZE) {
386 p[2] = DEFLATE_MAKE_OPT(go->deflate_size);
389 if (go->bsd_compress) {
390 p[0] = CI_BSD_COMPRESS;
391 p[1] = CILEN_BSD_COMPRESS;
392 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits);
394 p += CILEN_BSD_COMPRESS; /* not the first option */
397 res = ccp_test(f->unit, p, CILEN_BSD_COMPRESS, 0);
399 p += CILEN_BSD_COMPRESS;
402 if (res < 0 || go->bsd_bits <= BSD_MIN_BITS) {
403 go->bsd_compress = 0;
407 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits);
411 /* XXX Should Predictor 2 be preferable to Predictor 1? */
412 if (go->predictor_1) {
413 p[0] = CI_PREDICTOR_1;
414 p[1] = CILEN_PREDICTOR_1;
415 if (p == p0 && ccp_test(f->unit, p, CILEN_PREDICTOR_1, 0) <= 0) {
418 p += CILEN_PREDICTOR_1;
421 if (go->predictor_2) {
422 p[0] = CI_PREDICTOR_2;
423 p[1] = CILEN_PREDICTOR_2;
424 if (p == p0 && ccp_test(f->unit, p, CILEN_PREDICTOR_2, 0) <= 0) {
427 p += CILEN_PREDICTOR_2;
431 go->method = (p > p0)? p0[0]: -1;
437 * ccp_ackci - process a received configure-ack, and return
438 * 1 iff the packet was OK.
446 ccp_options *go = &ccp_gotoptions[f->unit];
450 if (len < CILEN_DEFLATE
451 || p[0] != CI_DEFLATE || p[1] != CILEN_DEFLATE
452 || p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
453 || p[3] != DEFLATE_CHK_SEQUENCE)
456 len -= CILEN_DEFLATE;
457 /* XXX Cope with first/fast ack */
461 if (go->bsd_compress) {
462 if (len < CILEN_BSD_COMPRESS
463 || p[0] != CI_BSD_COMPRESS || p[1] != CILEN_BSD_COMPRESS
464 || p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits))
466 p += CILEN_BSD_COMPRESS;
467 len -= CILEN_BSD_COMPRESS;
468 /* XXX Cope with first/fast ack */
469 if (p == p0 && len == 0)
472 if (go->predictor_1) {
473 if (len < CILEN_PREDICTOR_1
474 || p[0] != CI_PREDICTOR_1 || p[1] != CILEN_PREDICTOR_1)
476 p += CILEN_PREDICTOR_1;
477 len -= CILEN_PREDICTOR_1;
478 /* XXX Cope with first/fast ack */
479 if (p == p0 && len == 0)
482 if (go->predictor_2) {
483 if (len < CILEN_PREDICTOR_2
484 || p[0] != CI_PREDICTOR_2 || p[1] != CILEN_PREDICTOR_2)
486 p += CILEN_PREDICTOR_2;
487 len -= CILEN_PREDICTOR_2;
488 /* XXX Cope with first/fast ack */
489 if (p == p0 && len == 0)
499 * ccp_nakci - process received configure-nak.
500 * Returns 1 iff the nak was OK.
508 ccp_options *go = &ccp_gotoptions[f->unit];
509 ccp_options no; /* options we've seen already */
510 ccp_options try; /* options to ask for next time */
512 memset(&no, 0, sizeof(no));
515 if (go->deflate && len >= CILEN_DEFLATE
516 && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
519 * Peer wants us to use a different code size or something.
520 * Stop asking for Deflate if we don't understand his suggestion.
522 if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL
523 || DEFLATE_SIZE(p[2]) < DEFLATE_MIN_SIZE
524 || p[3] != DEFLATE_CHK_SEQUENCE)
526 else if (DEFLATE_SIZE(p[2]) < go->deflate_size)
527 go->deflate_size = DEFLATE_SIZE(p[2]);
529 len -= CILEN_DEFLATE;
532 if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
533 && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
536 * Peer wants us to use a different number of bits
537 * or a different version.
539 if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION)
540 try.bsd_compress = 0;
541 else if (BSD_NBITS(p[2]) < go->bsd_bits)
542 try.bsd_bits = BSD_NBITS(p[2]);
543 p += CILEN_BSD_COMPRESS;
544 len -= CILEN_BSD_COMPRESS;
548 * Predictor-1 and 2 have no options, so they can't be Naked.
550 * XXX What should we do with any remaining options?
556 if (f->state != OPENED)
562 * ccp_rejci - reject some of our suggested compression methods.
570 ccp_options *go = &ccp_gotoptions[f->unit];
571 ccp_options try; /* options to request next time */
576 * Cope with empty configure-rejects by ceasing to send
577 * configure-requests.
579 if (len == 0 && all_rejected[f->unit])
582 if (go->deflate && len >= CILEN_DEFLATE
583 && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
584 if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
585 || p[3] != DEFLATE_CHK_SEQUENCE)
586 return 0; /* Rej is bad */
589 len -= CILEN_DEFLATE;
591 if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
592 && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
593 if (p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits))
595 try.bsd_compress = 0;
596 p += CILEN_BSD_COMPRESS;
597 len -= CILEN_BSD_COMPRESS;
599 if (go->predictor_1 && len >= CILEN_PREDICTOR_1
600 && p[0] == CI_PREDICTOR_1 && p[1] == CILEN_PREDICTOR_1) {
602 p += CILEN_PREDICTOR_1;
603 len -= CILEN_PREDICTOR_1;
605 if (go->predictor_2 && len >= CILEN_PREDICTOR_2
606 && p[0] == CI_PREDICTOR_2 && p[1] == CILEN_PREDICTOR_2) {
608 p += CILEN_PREDICTOR_2;
609 len -= CILEN_PREDICTOR_2;
615 if (f->state != OPENED)
622 * ccp_reqci - processed a received configure-request.
623 * Returns CONFACK, CONFNAK or CONFREJ and the packet modified
627 ccp_reqci(f, p, lenp, dont_nak)
633 int ret, newret, res;
635 int len, clen, type, nb;
636 ccp_options *ho = &ccp_hisoptions[f->unit];
637 ccp_options *ao = &ccp_allowoptions[f->unit];
643 memset(ho, 0, sizeof(ccp_options));
644 ho->method = (len > 0)? p[0]: -1;
648 if (len < 2 || p[1] < 2 || p[1] > len) {
659 if (!ao->deflate || clen != CILEN_DEFLATE) {
665 ho->deflate_size = nb = DEFLATE_SIZE(p[2]);
666 if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL
667 || p[3] != DEFLATE_CHK_SEQUENCE
668 || nb > ao->deflate_size || nb < DEFLATE_MIN_SIZE) {
671 p[2] = DEFLATE_MAKE_OPT(ao->deflate_size);
672 p[3] = DEFLATE_CHK_SEQUENCE;
678 * Check whether we can do Deflate with the window
679 * size they want. If the window is too big, reduce
680 * it until the kernel can cope and nak with that.
681 * We only check this for the first option.
685 res = ccp_test(f->unit, p, CILEN_DEFLATE, 1);
687 break; /* it's OK now */
688 if (res < 0 || nb == DEFLATE_MIN_SIZE || dont_nak) {
690 p[2] = DEFLATE_MAKE_OPT(ho->deflate_size);
695 p[2] = DEFLATE_MAKE_OPT(nb);
700 case CI_BSD_COMPRESS:
701 if (!ao->bsd_compress || clen != CILEN_BSD_COMPRESS) {
706 ho->bsd_compress = 1;
707 ho->bsd_bits = nb = BSD_NBITS(p[2]);
708 if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION
709 || nb > ao->bsd_bits || nb < BSD_MIN_BITS) {
712 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, ao->bsd_bits);
717 * Check whether we can do BSD-Compress with the code
718 * size they want. If the code size is too big, reduce
719 * it until the kernel can cope and nak with that.
720 * We only check this for the first option.
724 res = ccp_test(f->unit, p, CILEN_BSD_COMPRESS, 1);
727 if (res < 0 || nb == BSD_MIN_BITS || dont_nak) {
729 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION,
735 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, nb);
741 if (!ao->predictor_1 || clen != CILEN_PREDICTOR_1) {
748 && ccp_test(f->unit, p, CILEN_PREDICTOR_1, 1) <= 0) {
754 if (!ao->predictor_2 || clen != CILEN_PREDICTOR_2) {
761 && ccp_test(f->unit, p, CILEN_PREDICTOR_2, 1) <= 0) {
771 if (newret == CONFNAK && dont_nak)
773 if (!(newret == CONFACK || newret == CONFNAK && ret == CONFREJ)) {
774 /* we're returning this option */
775 if (newret == CONFREJ && ret == CONFNAK)
779 BCOPY(p, retp, clen);
787 if (ret != CONFACK) {
788 if (ret == CONFREJ && *lenp == retp - p0)
789 all_rejected[f->unit] = 1;
797 * Make a string name for a compression method (or 2).
800 method_name(opt, opt2)
801 ccp_options *opt, *opt2;
803 static char result[64];
805 if (!ANY_COMPRESS(*opt))
807 switch (opt->method) {
809 if (opt2 != NULL && opt2->deflate_size != opt->deflate_size)
810 sprintf(result, "Deflate (%d/%d)", opt->deflate_size,
813 sprintf(result, "Deflate (%d)", opt->deflate_size);
815 case CI_BSD_COMPRESS:
816 if (opt2 != NULL && opt2->bsd_bits != opt->bsd_bits)
817 sprintf(result, "BSD-Compress (%d/%d)", opt->bsd_bits,
820 sprintf(result, "BSD-Compress (%d)", opt->bsd_bits);
823 return "Predictor 1";
825 return "Predictor 2";
827 sprintf(result, "Method %d", opt->method);
833 * CCP has come up - inform the kernel driver and log a message.
839 ccp_options *go = &ccp_gotoptions[f->unit];
840 ccp_options *ho = &ccp_hisoptions[f->unit];
843 ccp_flags_set(f->unit, 1, 1);
844 if (ANY_COMPRESS(*go)) {
845 if (ANY_COMPRESS(*ho)) {
846 if (go->method == ho->method) {
847 syslog(LOG_NOTICE, "%s compression enabled",
848 method_name(go, ho));
850 strcpy(method1, method_name(go, NULL));
851 syslog(LOG_NOTICE, "%s / %s compression enabled",
852 method1, method_name(ho, NULL));
855 syslog(LOG_NOTICE, "%s receive compression enabled",
856 method_name(go, NULL));
858 syslog(LOG_NOTICE, "%s transmit compression enabled",
859 method_name(ho, NULL));
863 * CCP has gone down - inform the kernel driver.
869 if (ccp_localstate[f->unit] & RACK_PENDING)
870 UNTIMEOUT(ccp_rack_timeout, (caddr_t) f);
871 ccp_localstate[f->unit] = 0;
872 ccp_flags_set(f->unit, 1, 0);
876 * Print the contents of a CCP packet.
878 static char *ccp_codenames[] = {
879 "ConfReq", "ConfAck", "ConfNak", "ConfRej",
880 "TermReq", "TermAck", "CodeRej",
881 NULL, NULL, NULL, NULL, NULL, NULL,
882 "ResetReq", "ResetAck",
886 ccp_printpkt(p, plen, printer, arg)
889 void (*printer) __P((void *, char *, ...));
897 if (plen < HEADERLEN)
901 len = (p[2] << 8) + p[3];
902 if (len < HEADERLEN || len > plen)
905 if (code >= 1 && code <= sizeof(ccp_codenames) / sizeof(char *)
906 && ccp_codenames[code-1] != NULL)
907 printer(arg, " %s", ccp_codenames[code-1]);
909 printer(arg, " code=0x%x", code);
910 printer(arg, " id=0x%x", id);
919 /* print list of possible compression methods */
923 if (optlen < 2 || optlen > len)
930 if (optlen >= CILEN_DEFLATE) {
931 printer(arg, "deflate %d", DEFLATE_SIZE(p[2]));
932 if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL)
933 printer(arg, " method %d", DEFLATE_METHOD(p[2]));
934 if (p[3] != DEFLATE_CHK_SEQUENCE)
935 printer(arg, " check %d", p[3]);
939 case CI_BSD_COMPRESS:
940 if (optlen >= CILEN_BSD_COMPRESS) {
941 printer(arg, "bsd v%d %d", BSD_VERSION(p[2]),
943 p += CILEN_BSD_COMPRESS;
947 if (optlen >= CILEN_PREDICTOR_1) {
948 printer(arg, "predictor 1");
949 p += CILEN_PREDICTOR_1;
953 if (optlen >= CILEN_PREDICTOR_2) {
954 printer(arg, "predictor 2");
955 p += CILEN_PREDICTOR_2;
960 printer(arg, " %.2x", *p++);
967 if (len > 0 && *p >= ' ' && *p < 0x7f) {
968 print_string(p, len, printer, arg);
975 /* dump out the rest of the packet in hex */
977 printer(arg, " %.2x", *p++);
983 * We have received a packet that the decompressor failed to
984 * decompress. Here we would expect to issue a reset-request, but
985 * Motorola has a patent on resetting the compressor as a result of
986 * detecting an error in the decompressed data after decompression.
987 * (See US patent 5,130,993; international patent publication number
988 * WO 91/10289; Australian patent 73296/91.)
990 * So we ask the kernel whether the error was detected after
991 * decompression; if it was, we take CCP down, thus disabling
992 * compression :-(, otherwise we issue the reset-request.
995 ccp_datainput(unit, pkt, len)
1003 if (f->state == OPENED) {
1004 if (ccp_fatal_error(unit)) {
1006 * Disable compression by taking CCP down.
1008 syslog(LOG_ERR, "Lost compression sync: disabling compression");
1009 ccp_close(unit, "Lost compression sync");
1012 * Send a reset-request to reset the peer's compressor.
1013 * We don't do that if we are still waiting for an
1014 * acknowledgement to a previous reset-request.
1016 if (!(ccp_localstate[f->unit] & RACK_PENDING)) {
1017 fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0);
1018 TIMEOUT(ccp_rack_timeout, (caddr_t) f, RACKTIMEOUT);
1019 ccp_localstate[f->unit] |= RACK_PENDING;
1021 ccp_localstate[f->unit] |= RREQ_REPEAT;
1027 * Timeout waiting for reset-ack.
1030 ccp_rack_timeout(arg)
1033 fsm *f = (fsm *) arg;
1035 if (f->state == OPENED && ccp_localstate[f->unit] & RREQ_REPEAT) {
1036 fsm_sdata(f, CCP_RESETREQ, f->reqid, NULL, 0);
1037 TIMEOUT(ccp_rack_timeout, (caddr_t) f, RACKTIMEOUT);
1038 ccp_localstate[f->unit] &= ~RREQ_REPEAT;
1040 ccp_localstate[f->unit] &= ~RACK_PENDING;