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.20 1997/04/30 05:50:40 paulus Exp $";
34 #include <sys/ioctl.h>
35 #include <sys/types.h>
36 #include <net/ppp_defs.h>
37 #include <net/ppp-comp.h>
44 * Protocol entry points from main code.
46 static void ccp_init __P((int unit));
47 static void ccp_open __P((int unit));
48 static void ccp_close __P((int unit, char *));
49 static void ccp_lowerup __P((int unit));
50 static void ccp_lowerdown __P((int));
51 static void ccp_input __P((int unit, u_char *pkt, int len));
52 static void ccp_protrej __P((int unit));
53 static int ccp_printpkt __P((u_char *pkt, int len,
54 void (*printer) __P((void *, char *, ...)),
56 static void ccp_datainput __P((int unit, u_char *pkt, int len));
58 struct protent ccp_protent = {
77 ccp_options ccp_wantoptions[NUM_PPP]; /* what to request the peer to use */
78 ccp_options ccp_gotoptions[NUM_PPP]; /* what the peer agreed to do */
79 ccp_options ccp_allowoptions[NUM_PPP]; /* what we'll agree to do */
80 ccp_options ccp_hisoptions[NUM_PPP]; /* what we agreed to do */
83 * Callbacks for fsm code.
85 static void ccp_resetci __P((fsm *));
86 static int ccp_cilen __P((fsm *));
87 static void ccp_addci __P((fsm *, u_char *, int *));
88 static int ccp_ackci __P((fsm *, u_char *, int));
89 static int ccp_nakci __P((fsm *, u_char *, int));
90 static int ccp_rejci __P((fsm *, u_char *, int));
91 static int ccp_reqci __P((fsm *, u_char *, int *, int));
92 static void ccp_up __P((fsm *));
93 static void ccp_down __P((fsm *));
94 static int ccp_extcode __P((fsm *, int, int, u_char *, int));
95 static void ccp_rack_timeout __P((void *));
96 static char *method_name __P((ccp_options *, ccp_options *));
98 static fsm_callbacks ccp_callbacks = {
117 * Do we want / did we get any compression?
119 #define ANY_COMPRESS(opt) ((opt).deflate || (opt).bsd_compress \
120 || (opt).predictor_1 || (opt).predictor_2)
123 * Local state (mainly for handling reset-reqs and reset-acks).
125 static int ccp_localstate[NUM_PPP];
126 #define RACK_PENDING 1 /* waiting for reset-ack */
127 #define RREQ_REPEAT 2 /* send another reset-req if no reset-ack */
129 #define RACKTIMEOUT 1 /* second */
131 static int all_rejected[NUM_PPP]; /* we rejected all peer's options */
134 * ccp_init - initialize CCP.
140 fsm *f = &ccp_fsm[unit];
143 f->protocol = PPP_CCP;
144 f->callbacks = &ccp_callbacks;
147 memset(&ccp_wantoptions[unit], 0, sizeof(ccp_options));
148 memset(&ccp_gotoptions[unit], 0, sizeof(ccp_options));
149 memset(&ccp_allowoptions[unit], 0, sizeof(ccp_options));
150 memset(&ccp_hisoptions[unit], 0, sizeof(ccp_options));
152 ccp_wantoptions[0].deflate = 1;
153 ccp_wantoptions[0].deflate_size = DEFLATE_MAX_SIZE;
154 ccp_allowoptions[0].deflate = 1;
155 ccp_allowoptions[0].deflate_size = DEFLATE_MAX_SIZE;
157 ccp_wantoptions[0].bsd_compress = 1;
158 ccp_wantoptions[0].bsd_bits = BSD_MAX_BITS;
159 ccp_allowoptions[0].bsd_compress = 1;
160 ccp_allowoptions[0].bsd_bits = BSD_MAX_BITS;
162 ccp_allowoptions[0].predictor_1 = 1;
166 * ccp_open - CCP is allowed to come up.
172 fsm *f = &ccp_fsm[unit];
174 if (f->state != OPENED)
175 ccp_flags_set(unit, 1, 0);
178 * Find out which compressors the kernel supports before
179 * deciding whether to open in silent mode.
182 if (!ANY_COMPRESS(ccp_gotoptions[unit]))
183 f->flags |= OPT_SILENT;
189 * ccp_close - Terminate CCP.
192 ccp_close(unit, reason)
196 ccp_flags_set(unit, 0, 0);
197 fsm_close(&ccp_fsm[unit], reason);
201 * ccp_lowerup - we may now transmit CCP packets.
207 fsm_lowerup(&ccp_fsm[unit]);
211 * ccp_lowerdown - we may not transmit CCP packets.
217 fsm_lowerdown(&ccp_fsm[unit]);
221 * ccp_input - process a received CCP packet.
224 ccp_input(unit, p, len)
229 fsm *f = &ccp_fsm[unit];
233 * Check for a terminate-request so we can print a message.
236 fsm_input(f, p, len);
237 if (oldstate == OPENED && p[0] == TERMREQ && f->state != OPENED)
238 syslog(LOG_NOTICE, "Compression disabled by peer.");
241 * If we get a terminate-ack and we're not asking for compression,
244 if (oldstate == REQSENT && p[0] == TERMACK
245 && !ANY_COMPRESS(ccp_gotoptions[unit]))
246 ccp_close(unit, "No compression negotiated");
250 * Handle a CCP-specific code.
253 ccp_extcode(f, code, id, p, len)
261 if (f->state != OPENED)
263 /* send a reset-ack, which the transmitter will see and
264 reset its compression state. */
265 fsm_sdata(f, CCP_RESETACK, id, NULL, 0);
269 if (ccp_localstate[f->unit] & RACK_PENDING && id == f->reqid) {
270 ccp_localstate[f->unit] &= ~(RACK_PENDING | RREQ_REPEAT);
271 UNTIMEOUT(ccp_rack_timeout, f);
283 * ccp_protrej - peer doesn't talk CCP.
289 ccp_flags_set(unit, 0, 0);
290 fsm_lowerdown(&ccp_fsm[unit]);
294 * ccp_resetci - initialize at start of negotiation.
300 ccp_options *go = &ccp_gotoptions[f->unit];
303 *go = ccp_wantoptions[f->unit];
304 all_rejected[f->unit] = 0;
307 * Check whether the kernel knows about the various
308 * compression methods we might request.
310 if (go->bsd_compress) {
311 opt_buf[0] = CI_BSD_COMPRESS;
312 opt_buf[1] = CILEN_BSD_COMPRESS;
313 opt_buf[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, BSD_MIN_BITS);
314 if (ccp_test(f->unit, opt_buf, CILEN_BSD_COMPRESS, 0) <= 0)
315 go->bsd_compress = 0;
318 opt_buf[0] = CI_DEFLATE;
319 opt_buf[1] = CILEN_DEFLATE;
320 opt_buf[2] = DEFLATE_MAKE_OPT(DEFLATE_MIN_SIZE);
321 opt_buf[3] = DEFLATE_CHK_SEQUENCE;
322 if (ccp_test(f->unit, opt_buf, CILEN_DEFLATE, 0) <= 0)
325 if (go->predictor_1) {
326 opt_buf[0] = CI_PREDICTOR_1;
327 opt_buf[1] = CILEN_PREDICTOR_1;
328 if (ccp_test(f->unit, opt_buf, CILEN_PREDICTOR_1, 0) <= 0)
331 if (go->predictor_2) {
332 opt_buf[0] = CI_PREDICTOR_2;
333 opt_buf[1] = CILEN_PREDICTOR_2;
334 if (ccp_test(f->unit, opt_buf, CILEN_PREDICTOR_2, 0) <= 0)
340 * ccp_cilen - Return total length of our configuration info.
346 ccp_options *go = &ccp_gotoptions[f->unit];
348 return (go->bsd_compress? CILEN_BSD_COMPRESS: 0)
349 + (go->deflate? CILEN_DEFLATE: 0)
350 + (go->predictor_1? CILEN_PREDICTOR_1: 0)
351 + (go->predictor_2? CILEN_PREDICTOR_2: 0);
355 * ccp_addci - put our requests in a packet.
358 ccp_addci(f, p, lenp)
364 ccp_options *go = &ccp_gotoptions[f->unit];
368 * Add the compression types that we can receive, in decreasing
369 * preference order. Get the kernel to allocate the first one
370 * in case it gets Acked.
374 p[1] = CILEN_DEFLATE;
375 p[2] = DEFLATE_MAKE_OPT(go->deflate_size);
376 p[3] = DEFLATE_CHK_SEQUENCE;
378 res = ccp_test(f->unit, p, CILEN_DEFLATE, 0);
383 if (res < 0 || go->deflate_size <= DEFLATE_MIN_SIZE) {
388 p[2] = DEFLATE_MAKE_OPT(go->deflate_size);
391 if (go->bsd_compress) {
392 p[0] = CI_BSD_COMPRESS;
393 p[1] = CILEN_BSD_COMPRESS;
394 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits);
396 p += CILEN_BSD_COMPRESS; /* not the first option */
399 res = ccp_test(f->unit, p, CILEN_BSD_COMPRESS, 0);
401 p += CILEN_BSD_COMPRESS;
404 if (res < 0 || go->bsd_bits <= BSD_MIN_BITS) {
405 go->bsd_compress = 0;
409 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits);
413 /* XXX Should Predictor 2 be preferable to Predictor 1? */
414 if (go->predictor_1) {
415 p[0] = CI_PREDICTOR_1;
416 p[1] = CILEN_PREDICTOR_1;
417 if (p == p0 && ccp_test(f->unit, p, CILEN_PREDICTOR_1, 0) <= 0) {
420 p += CILEN_PREDICTOR_1;
423 if (go->predictor_2) {
424 p[0] = CI_PREDICTOR_2;
425 p[1] = CILEN_PREDICTOR_2;
426 if (p == p0 && ccp_test(f->unit, p, CILEN_PREDICTOR_2, 0) <= 0) {
429 p += CILEN_PREDICTOR_2;
433 go->method = (p > p0)? p0[0]: -1;
439 * ccp_ackci - process a received configure-ack, and return
440 * 1 iff the packet was OK.
448 ccp_options *go = &ccp_gotoptions[f->unit];
452 if (len < CILEN_DEFLATE
453 || p[0] != CI_DEFLATE || p[1] != CILEN_DEFLATE
454 || p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
455 || p[3] != DEFLATE_CHK_SEQUENCE)
458 len -= CILEN_DEFLATE;
459 /* XXX Cope with first/fast ack */
463 if (go->bsd_compress) {
464 if (len < CILEN_BSD_COMPRESS
465 || p[0] != CI_BSD_COMPRESS || p[1] != CILEN_BSD_COMPRESS
466 || p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits))
468 p += CILEN_BSD_COMPRESS;
469 len -= CILEN_BSD_COMPRESS;
470 /* XXX Cope with first/fast ack */
471 if (p == p0 && len == 0)
474 if (go->predictor_1) {
475 if (len < CILEN_PREDICTOR_1
476 || p[0] != CI_PREDICTOR_1 || p[1] != CILEN_PREDICTOR_1)
478 p += CILEN_PREDICTOR_1;
479 len -= CILEN_PREDICTOR_1;
480 /* XXX Cope with first/fast ack */
481 if (p == p0 && len == 0)
484 if (go->predictor_2) {
485 if (len < CILEN_PREDICTOR_2
486 || p[0] != CI_PREDICTOR_2 || p[1] != CILEN_PREDICTOR_2)
488 p += CILEN_PREDICTOR_2;
489 len -= CILEN_PREDICTOR_2;
490 /* XXX Cope with first/fast ack */
491 if (p == p0 && len == 0)
501 * ccp_nakci - process received configure-nak.
502 * Returns 1 iff the nak was OK.
510 ccp_options *go = &ccp_gotoptions[f->unit];
511 ccp_options no; /* options we've seen already */
512 ccp_options try; /* options to ask for next time */
514 memset(&no, 0, sizeof(no));
517 if (go->deflate && len >= CILEN_DEFLATE
518 && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
521 * Peer wants us to use a different code size or something.
522 * Stop asking for Deflate if we don't understand his suggestion.
524 if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL
525 || DEFLATE_SIZE(p[2]) < DEFLATE_MIN_SIZE
526 || p[3] != DEFLATE_CHK_SEQUENCE)
528 else if (DEFLATE_SIZE(p[2]) < go->deflate_size)
529 go->deflate_size = DEFLATE_SIZE(p[2]);
531 len -= CILEN_DEFLATE;
534 if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
535 && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
538 * Peer wants us to use a different number of bits
539 * or a different version.
541 if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION)
542 try.bsd_compress = 0;
543 else if (BSD_NBITS(p[2]) < go->bsd_bits)
544 try.bsd_bits = BSD_NBITS(p[2]);
545 p += CILEN_BSD_COMPRESS;
546 len -= CILEN_BSD_COMPRESS;
550 * Predictor-1 and 2 have no options, so they can't be Naked.
552 * XXX What should we do with any remaining options?
558 if (f->state != OPENED)
564 * ccp_rejci - reject some of our suggested compression methods.
572 ccp_options *go = &ccp_gotoptions[f->unit];
573 ccp_options try; /* options to request next time */
578 * Cope with empty configure-rejects by ceasing to send
579 * configure-requests.
581 if (len == 0 && all_rejected[f->unit])
584 if (go->deflate && len >= CILEN_DEFLATE
585 && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
586 if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
587 || p[3] != DEFLATE_CHK_SEQUENCE)
588 return 0; /* Rej is bad */
591 len -= CILEN_DEFLATE;
593 if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
594 && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
595 if (p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits))
597 try.bsd_compress = 0;
598 p += CILEN_BSD_COMPRESS;
599 len -= CILEN_BSD_COMPRESS;
601 if (go->predictor_1 && len >= CILEN_PREDICTOR_1
602 && p[0] == CI_PREDICTOR_1 && p[1] == CILEN_PREDICTOR_1) {
604 p += CILEN_PREDICTOR_1;
605 len -= CILEN_PREDICTOR_1;
607 if (go->predictor_2 && len >= CILEN_PREDICTOR_2
608 && p[0] == CI_PREDICTOR_2 && p[1] == CILEN_PREDICTOR_2) {
610 p += CILEN_PREDICTOR_2;
611 len -= CILEN_PREDICTOR_2;
617 if (f->state != OPENED)
624 * ccp_reqci - processed a received configure-request.
625 * Returns CONFACK, CONFNAK or CONFREJ and the packet modified
629 ccp_reqci(f, p, lenp, dont_nak)
635 int ret, newret, res;
637 int len, clen, type, nb;
638 ccp_options *ho = &ccp_hisoptions[f->unit];
639 ccp_options *ao = &ccp_allowoptions[f->unit];
645 memset(ho, 0, sizeof(ccp_options));
646 ho->method = (len > 0)? p[0]: -1;
650 if (len < 2 || p[1] < 2 || p[1] > len) {
661 if (!ao->deflate || clen != CILEN_DEFLATE) {
667 ho->deflate_size = nb = DEFLATE_SIZE(p[2]);
668 if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL
669 || p[3] != DEFLATE_CHK_SEQUENCE
670 || nb > ao->deflate_size || nb < DEFLATE_MIN_SIZE) {
673 p[2] = DEFLATE_MAKE_OPT(ao->deflate_size);
674 p[3] = DEFLATE_CHK_SEQUENCE;
680 * Check whether we can do Deflate with the window
681 * size they want. If the window is too big, reduce
682 * it until the kernel can cope and nak with that.
683 * We only check this for the first option.
687 res = ccp_test(f->unit, p, CILEN_DEFLATE, 1);
689 break; /* it's OK now */
690 if (res < 0 || nb == DEFLATE_MIN_SIZE || dont_nak) {
692 p[2] = DEFLATE_MAKE_OPT(ho->deflate_size);
697 p[2] = DEFLATE_MAKE_OPT(nb);
702 case CI_BSD_COMPRESS:
703 if (!ao->bsd_compress || clen != CILEN_BSD_COMPRESS) {
708 ho->bsd_compress = 1;
709 ho->bsd_bits = nb = BSD_NBITS(p[2]);
710 if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION
711 || nb > ao->bsd_bits || nb < BSD_MIN_BITS) {
714 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, ao->bsd_bits);
719 * Check whether we can do BSD-Compress with the code
720 * size they want. If the code size is too big, reduce
721 * it until the kernel can cope and nak with that.
722 * We only check this for the first option.
726 res = ccp_test(f->unit, p, CILEN_BSD_COMPRESS, 1);
729 if (res < 0 || nb == BSD_MIN_BITS || dont_nak) {
731 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION,
737 p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, nb);
743 if (!ao->predictor_1 || clen != CILEN_PREDICTOR_1) {
750 && ccp_test(f->unit, p, CILEN_PREDICTOR_1, 1) <= 0) {
756 if (!ao->predictor_2 || clen != CILEN_PREDICTOR_2) {
763 && ccp_test(f->unit, p, CILEN_PREDICTOR_2, 1) <= 0) {
773 if (newret == CONFNAK && dont_nak)
775 if (!(newret == CONFACK || (newret == CONFNAK && ret == CONFREJ))) {
776 /* we're returning this option */
777 if (newret == CONFREJ && ret == CONFNAK)
781 BCOPY(p, retp, clen);
789 if (ret != CONFACK) {
790 if (ret == CONFREJ && *lenp == retp - p0)
791 all_rejected[f->unit] = 1;
799 * Make a string name for a compression method (or 2).
802 method_name(opt, opt2)
803 ccp_options *opt, *opt2;
805 static char result[64];
807 if (!ANY_COMPRESS(*opt))
809 switch (opt->method) {
811 if (opt2 != NULL && opt2->deflate_size != opt->deflate_size)
812 sprintf(result, "Deflate (%d/%d)", opt->deflate_size,
815 sprintf(result, "Deflate (%d)", opt->deflate_size);
817 case CI_BSD_COMPRESS:
818 if (opt2 != NULL && opt2->bsd_bits != opt->bsd_bits)
819 sprintf(result, "BSD-Compress (%d/%d)", opt->bsd_bits,
822 sprintf(result, "BSD-Compress (%d)", opt->bsd_bits);
825 return "Predictor 1";
827 return "Predictor 2";
829 sprintf(result, "Method %d", opt->method);
835 * CCP has come up - inform the kernel driver and log a message.
841 ccp_options *go = &ccp_gotoptions[f->unit];
842 ccp_options *ho = &ccp_hisoptions[f->unit];
845 ccp_flags_set(f->unit, 1, 1);
846 if (ANY_COMPRESS(*go)) {
847 if (ANY_COMPRESS(*ho)) {
848 if (go->method == ho->method) {
849 syslog(LOG_NOTICE, "%s compression enabled",
850 method_name(go, ho));
852 strcpy(method1, method_name(go, NULL));
853 syslog(LOG_NOTICE, "%s / %s compression enabled",
854 method1, method_name(ho, NULL));
857 syslog(LOG_NOTICE, "%s receive compression enabled",
858 method_name(go, NULL));
859 } else if (ANY_COMPRESS(*ho))
860 syslog(LOG_NOTICE, "%s transmit compression enabled",
861 method_name(ho, NULL));
865 * CCP has gone down - inform the kernel driver.
871 if (ccp_localstate[f->unit] & RACK_PENDING)
872 UNTIMEOUT(ccp_rack_timeout, f);
873 ccp_localstate[f->unit] = 0;
874 ccp_flags_set(f->unit, 1, 0);
878 * Print the contents of a CCP packet.
880 static char *ccp_codenames[] = {
881 "ConfReq", "ConfAck", "ConfNak", "ConfRej",
882 "TermReq", "TermAck", "CodeRej",
883 NULL, NULL, NULL, NULL, NULL, NULL,
884 "ResetReq", "ResetAck",
888 ccp_printpkt(p, plen, printer, arg)
891 void (*printer) __P((void *, char *, ...));
899 if (plen < HEADERLEN)
903 len = (p[2] << 8) + p[3];
904 if (len < HEADERLEN || len > plen)
907 if (code >= 1 && code <= sizeof(ccp_codenames) / sizeof(char *)
908 && ccp_codenames[code-1] != NULL)
909 printer(arg, " %s", ccp_codenames[code-1]);
911 printer(arg, " code=0x%x", code);
912 printer(arg, " id=0x%x", id);
921 /* print list of possible compression methods */
925 if (optlen < 2 || optlen > len)
932 if (optlen >= CILEN_DEFLATE) {
933 printer(arg, "deflate %d", DEFLATE_SIZE(p[2]));
934 if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL)
935 printer(arg, " method %d", DEFLATE_METHOD(p[2]));
936 if (p[3] != DEFLATE_CHK_SEQUENCE)
937 printer(arg, " check %d", p[3]);
941 case CI_BSD_COMPRESS:
942 if (optlen >= CILEN_BSD_COMPRESS) {
943 printer(arg, "bsd v%d %d", BSD_VERSION(p[2]),
945 p += CILEN_BSD_COMPRESS;
949 if (optlen >= CILEN_PREDICTOR_1) {
950 printer(arg, "predictor 1");
951 p += CILEN_PREDICTOR_1;
955 if (optlen >= CILEN_PREDICTOR_2) {
956 printer(arg, "predictor 2");
957 p += CILEN_PREDICTOR_2;
962 printer(arg, " %.2x", *p++);
969 if (len > 0 && *p >= ' ' && *p < 0x7f) {
970 print_string(p, len, printer, arg);
977 /* dump out the rest of the packet in hex */
979 printer(arg, " %.2x", *p++);
985 * We have received a packet that the decompressor failed to
986 * decompress. Here we would expect to issue a reset-request, but
987 * Motorola has a patent on resetting the compressor as a result of
988 * detecting an error in the decompressed data after decompression.
989 * (See US patent 5,130,993; international patent publication number
990 * WO 91/10289; Australian patent 73296/91.)
992 * So we ask the kernel whether the error was detected after
993 * decompression; if it was, we take CCP down, thus disabling
994 * compression :-(, otherwise we issue the reset-request.
997 ccp_datainput(unit, pkt, len)
1005 if (f->state == OPENED) {
1006 if (ccp_fatal_error(unit)) {
1008 * Disable compression by taking CCP down.
1010 syslog(LOG_ERR, "Lost compression sync: disabling compression");
1011 ccp_close(unit, "Lost compression sync");
1014 * Send a reset-request to reset the peer's compressor.
1015 * We don't do that if we are still waiting for an
1016 * acknowledgement to a previous reset-request.
1018 if (!(ccp_localstate[f->unit] & RACK_PENDING)) {
1019 fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0);
1020 TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT);
1021 ccp_localstate[f->unit] |= RACK_PENDING;
1023 ccp_localstate[f->unit] |= RREQ_REPEAT;
1029 * Timeout waiting for reset-ack.
1032 ccp_rack_timeout(arg)
1037 if (f->state == OPENED && ccp_localstate[f->unit] & RREQ_REPEAT) {
1038 fsm_sdata(f, CCP_RESETREQ, f->reqid, NULL, 0);
1039 TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT);
1040 ccp_localstate[f->unit] &= ~RREQ_REPEAT;
1042 ccp_localstate[f->unit] &= ~RACK_PENDING;