]> git.ozlabs.org Git - ppp.git/blobdiff - linux/bsd_comp.c
minor bugfixes
[ppp.git] / linux / bsd_comp.c
index bab6561e3100cd1517481fc7141d83eccd07aec9..b2e2a7f616d8852d64d216e80fdf9ae14c84de22 100644 (file)
 /*
  * This version is for use with contiguous buffers on Linux-derived systems.
  *
- *  ==FILEVERSION 4==
+ *  ==FILEVERSION 970227==
  *
  *  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
 #error This file must be compiled as a module.
 #endif
 
+#include <linux/version.h>
 #include <linux/module.h>
-
-#include <endian.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/types.h>
 #include <linux/fcntl.h>
 #include <linux/interrupt.h>
 #include <linux/ptrace.h>
+#include <linux/malloc.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/malloc.h>
+
+#undef VERSION
+/* a nice define to generate linux version numbers */
+#define VERSION(major,minor,patch) (((((major)<<8)+(minor))<<8)+(patch))
+
+#if LINUX_VERSION_CODE >= VERSION(2,1,4)
+#include <linux/vmalloc.h>
+#endif
+
 #include <linux/tty.h>
 #include <linux/errno.h>
 #include <linux/sched.h>       /* to get the struct task_struct */
@@ -76,7 +85,7 @@
 
 #include <asm/system.h>
 #include <asm/bitops.h>
-#include <asm/segment.h>
+#include <asm/byteorder.h>
 
 #include <linux/if.h>
 
 
 #include <linux/ppp_defs.h>
 
-#ifdef NEW_SKBUFF
-#include <linux/netprotocol.h>
-#endif
-
-#include <linux/ip.h>
-#include <linux/tcp.h>
-#include <linux/if_arp.h>
-
 #undef   PACKETPTR
 #define  PACKETPTR 1
 #include <linux/ppp-comp.h>
@@ -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;
 }
@@ -684,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)
       {
@@ -773,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;