]> git.ozlabs.org Git - ppp.git/blobdiff - linux/mppe/ppp_mppe_compress.c
tidy up shell scripting, common radvd path in examples
[ppp.git] / linux / mppe / ppp_mppe_compress.c
index 2e98e180be2dc8e09cc973cf3192697d645211ff..6024edbab7d488c247ecf40aca35d8d2059a1357 100644 (file)
@@ -1,11 +1,9 @@
 /*
- *  ==FILEVERSION 20020521==
- *
  * ppp_mppe_compress.c - interface MPPE to the PPP code.
- * This version is for use with Linux kernel 2.2.19+ and 2.4.x.
+ * This version is for use with Linux kernel 2.2.19+, 2.4.18+ and 2.6.2+.
  *
  * By Frank Cusack <frank@google.com>.
- * Copyright (c) 2002 Google, Inc.
+ * Copyright (c) 2002,2003,2004 Google, Inc.
  * All rights reserved.
  *
  * Permission to use, copy, modify, and distribute this software and its
  * notice appears in all copies.  This software is provided without any
  * warranty, express or implied.
  *
+ * Changelog:
+ *      2/15/04 - TS: added #include <version.h> and testing for Kernel
+ *                    version before using 
+ *                    MOD_DEC_USAGE_COUNT/MOD_INC_USAGE_COUNT which are
+ *                    deprecated in 2.6
  */
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/version.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/slab.h>
@@ -170,7 +174,11 @@ mppe_alloc(unsigned char *options, int optlen)
     if (state == NULL)
        return NULL;
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
+    try_module_get(THIS_MODULE);
+#else
     MOD_INC_USE_COUNT;
+#endif
     memset(state, 0, sizeof(*state));
 
     /* Save keys. */
@@ -194,7 +202,11 @@ mppe_free(void *arg)
 
     if (state) {
        kfree(state);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
+       module_put(THIS_MODULE);
+#else
        MOD_DEC_USE_COUNT;
+#endif
     }
 }
 
@@ -333,6 +345,9 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf,
     obuf += PPP_HDRLEN;
 
     state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE;
+    if (state->debug >= 7)
+       printk(KERN_DEBUG "mppe_compress[%d]: ccount %d\n", state->unit,
+              state->ccount);
     obuf[0] = state->ccount >> 8;
     obuf[1] = state->ccount & 0xff;
 
@@ -423,6 +438,9 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf,
     osize = isize - MPPE_OVHD - 2;
 
     ccount = MPPE_CCOUNT(ibuf);
+    if (state->debug >= 7)
+       printk(KERN_DEBUG "mppe_decompress[%d]: ccount %d\n", state->unit,
+              ccount);
 
     /* sanity checks -- terminate with extreme prejudice */
     if (!(MPPE_BITS(ibuf) & MPPE_BIT_ENCRYPTED)) {