X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=linux%2Fbsd_comp.c;h=a52c32357d510260e1a37edfe0c40180492c2f92;hp=bb523bd240e91242caec2bad24fa4a6ac298b5df;hb=720f112b7dc1bc416c3dd1be41bc9d290d5ef7dc;hpb=3da550efb3dc7c6dfb697792f5cc8bc7c0f776e3;ds=sidebyside diff --git a/linux/bsd_comp.c b/linux/bsd_comp.c index bb523bd..a52c323 100644 --- a/linux/bsd_comp.c +++ b/linux/bsd_comp.c @@ -37,19 +37,20 @@ */ /* - * This version is for use with contigious buffers on Linux-derived systems. + * This version is for use with contiguous buffers on Linux-derived systems. * - * ==FILEVERSION 5== + * ==FILEVERSION 960924== * * NOTE TO MAINTAINERS: - * If you modify this file at all, increment the number above. + * If you modify this file at all, please set the number above to the + * date of the modification as YYMMDD (year month day). * bsd_comp.c is shipped with a PPP distribution as well as with * the kernel; if everyone increases the FILEVERSION number above, * then scripts can do the right thing when deciding whether to * install a new bsd_comp.c file. Don't change the format of that * line otherwise, so the installation script can recognize it. * - * $Id: bsd_comp.c,v 1.3 1996/01/18 03:12:47 paulus Exp $ + * From: bsd_comp.c,v 1.3 1994/12/08 01:59:58 paulus Exp */ #ifndef MODULE @@ -58,7 +59,6 @@ #include -#include #include #include #include @@ -77,8 +77,9 @@ #include #include #include +#include -#include +#include #include #include @@ -92,9 +93,9 @@ #include #endif -#include -#include -#include +#include +#include +#include #undef PACKETPTR #define PACKETPTR 1 @@ -141,14 +142,16 @@ struct bsd_dict { union { /* hash value */ unsigned long fcode; struct { -#ifndef BIG_ENDIAN_BITFIELD /* Little endian order */ +#if defined(__LITTLE_ENDIAN) /* Little endian order */ unsigned short prefix; /* preceding code */ unsigned char suffix; /* last character of new code */ unsigned char pad; -#else /* Big endian order */ +#elif defined(__BIG_ENDIAN) /* Big endian order */ unsigned char pad; unsigned char suffix; /* last character of new code */ unsigned short prefix; /* preceding code */ +#else +#error Endianness not defined... #endif } hs; } f; @@ -249,7 +252,6 @@ bsd_clear(struct bsd_db *db) db->n_bits = BSD_INIT_BITS; db->bytes_out = 0; db->in_count = 0; - db->incomp_count = 0; db->ratio = 0; db->checkpoint = CHECK_GAP; } @@ -501,9 +503,7 @@ static int bsd_init (void *state, unsigned char *options, struct bsd_db *db = state; int indx; - if ((opt_len < CILEN_BSD_COMPRESS) - || (options[0] != CI_BSD_COMPRESS) - || (options[1] != CILEN_BSD_COMPRESS) + if ((opt_len != 3) || (options[0] != CI_BSD_COMPRESS) || (options[1] != 3) || (BSD_VERSION(options[2]) != BSD_CURRENT_VERSION) || (BSD_NBITS(options[2]) != db->maxbits) || (decomp && db->lens == NULL)) @@ -686,7 +686,7 @@ static int bsd_compress (void *state, unsigned char *rptr, unsigned char *obuf, /* Skip the input header */ rptr += PPP_HDRLEN; isize -= PPP_HDRLEN; - ilen = ++isize; /* This is off by one, but that is what is in draft! */ + ilen = ++isize; /* Low byte of protocol is counted as input */ while (--ilen > 0) { @@ -775,7 +775,7 @@ nomatch: OUTPUT(ent); /* output the last code */ - db->bytes_out += olen; /* Do not count bytes from here */ + db->bytes_out += olen - PPP_HDRLEN - BSD_OVHD; db->uncomp_bytes += isize; db->in_count += isize; ++db->uncomp_count;