X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=netbsd-1.1%2Fbsd-comp.c;h=f4f298455de9244359b25cbe025ac1a49714267e;hp=a86183beb1b0b2245f0c7e4c70d7f72abb1cd7ab;hb=f201866a877a11896aa9deffe7343670d756ea6d;hpb=7005827d79039deaac4646047fb08992e47d6b59 diff --git a/netbsd-1.1/bsd-comp.c b/netbsd-1.1/bsd-comp.c index a86183b..f4f2984 100644 --- a/netbsd-1.1/bsd-comp.c +++ b/netbsd-1.1/bsd-comp.c @@ -1,4 +1,4 @@ -/* $Id: bsd-comp.c,v 1.1 1995/12/11 05:17:05 paulus Exp $ */ +/* $Id: bsd-comp.c,v 1.6 1996/08/28 06:31:58 paulus Exp $ */ /* Because this code is derived from the 4.3BSD compress source: * @@ -41,12 +41,11 @@ /* * This version is for use with mbufs on BSD-derived systems. - * - * $Id: bsd-comp.c,v 1.1 1995/12/11 05:17:05 paulus Exp $ */ #include #include +#include #include #include #include @@ -188,6 +187,12 @@ struct compressor ppp_bsd_compress = { #define RATIO_SCALE (1<>RATIO_SCALE_LOG) +static void bsd_clear __P((struct bsd_db *)); +static int bsd_check __P((struct bsd_db *)); +static void *bsd_alloc __P((u_char *, int, int)); +static int bsd_init __P((struct bsd_db *, u_char *, int, int, int, int, + int, int)); + /* * clear the dictionary */ @@ -201,7 +206,6 @@ bsd_clear(db) db->ratio = 0; db->bytes_out = 0; db->in_count = 0; - db->incomp_count = 0; db->checkpoint = CHECK_GAP; } @@ -309,7 +313,7 @@ bsd_alloc(options, opt_len, decomp) u_int newlen, hsize, hshift, maxmaxcode; struct bsd_db *db; - if (opt_len != CILEN_BSD_COMPRESS || options[0] != CI_BSD_COMPRESS + if (opt_len < CILEN_BSD_COMPRESS || options[0] != CI_BSD_COMPRESS || options[1] != CILEN_BSD_COMPRESS || BSD_VERSION(options[2]) != BSD_CURRENT_VERSION) return NULL; @@ -407,11 +411,11 @@ bsd_init(db, options, opt_len, unit, hdrlen, mru, debug, decomp) { int i; - if (opt_len != CILEN_BSD_COMPRESS || options[0] != CI_BSD_COMPRESS + if (opt_len < CILEN_BSD_COMPRESS || options[0] != CI_BSD_COMPRESS || options[1] != CILEN_BSD_COMPRESS || BSD_VERSION(options[2]) != BSD_CURRENT_VERSION || BSD_NBITS(options[2]) != db->maxbits - || decomp && db->lens == NULL) + || (decomp && db->lens == NULL)) return 0; if (decomp) { @@ -481,11 +485,10 @@ bsd_compress(state, mret, mp, slen, maxolen) struct bsd_dict *dictp; u_char c; int hval, disp, ent, ilen; - struct mbuf *np; u_char *rptr, *wptr; u_char *cp_end; int olen; - struct mbuf *m, **mnp; + struct mbuf *m; #define PUTBYTE(v) { \ ++olen; \ @@ -710,7 +713,6 @@ bsd_incomp(state, dmsg) if (ent < 0x21 || ent > 0xf9) return; - db->incomp_count++; db->seqno++; ilen = 1; /* count the protocol as 1 byte */ rptr += PPP_HDRLEN; @@ -831,7 +833,6 @@ bsd_decompress(state, cmp, dmpp) struct mbuf *m, *dmp, *mret; int adrs, ctrl, ilen; int space, codelen, extra; - struct mbuf *last; /* * Save the address/control from the PPP header @@ -941,7 +942,7 @@ bsd_decompress(state, cmp, dmpp) } if (incode > max_ent + 2 || incode > db->maxmaxcode - || incode > max_ent && oldcode == CLEAR) { + || (incode > max_ent && oldcode == CLEAR)) { m_freem(mret); if (db->debug) { printf("bsd_decomp%d: bad code 0x%x oldcode=0x%x ",