]> git.ozlabs.org Git - ppp.git/blobdiff - linux/mppe/ppp_mppe_compress.c
ECP patches from Frank Cusack:
[ppp.git] / linux / mppe / ppp_mppe_compress.c
index 8b62ba734370af7876e1065042f92c88fb0e44c8..0a757686de4ce1c83c23b9f78c8f8154b5ad4a3d 100644 (file)
@@ -1,8 +1,8 @@
 /*
- *  ==FILEVERSION 20020320==
+ *  ==FILEVERSION 20020521==
  *
  * ppp_mppe_compress.c - interface MPPE to the PPP code.
- * This version is for use with Linux kernel 2.2.x (ppp driver 2.3.x).
+ * This version is for use with Linux kernel 2.2.19+ and 2.4.x.
  *
  * By Frank Cusack <frank@google.com>.
  * Copyright (c) 2002 Google, Inc.
@@ -19,7 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 
 #include <linux/ppp_defs.h>
@@ -62,13 +62,8 @@ typedef struct ppp_mppe_state {
 #define MPPE_CCOUNT(p) ((((p)[4] & 0x0f) << 8) + (p)[5])
 #define MPPE_CCOUNT_SPACE 0x1000       /* The size of the ccount space */
 
-/*
- * MPPE overhead/packet.
- * Note that we use this differently than other compressors.
- */
 #define MPPE_OVHD      2               /* MPPE overhead/packet */
-/* Max bogon factor we will tolerate */
-#define SANITY_MAX     1600
+#define SANITY_MAX     1600            /* Max bogon factor we will tolerate */
 
 static void    GetNewKeyFromSHA __P((unsigned char *StartKey,
                                      unsigned char *SessionKey,
@@ -236,17 +231,17 @@ mppe_init(void *arg, unsigned char *options, int optlen, int unit, int debug,
 
     if (debug) {
        int i;
-       char mkey[sizeof(state->master_key) * 3 + 1];
-       char skey[sizeof(state->session_key) * 3 + 1];
+       char mkey[sizeof(state->master_key) * 2 + 1];
+       char skey[sizeof(state->session_key) * 2 + 1];
 
        printk(KERN_DEBUG "%s[%d]: initialized with %d-bit %s mode\n", debugstr,
               unit, (state->keylen == 16)? 128: 40,
               (state->stateful)? "stateful": "stateless");
 
        for (i = 0; i < sizeof(state->master_key); i++)
-           sprintf(mkey + i * 2, "%.2x ", state->master_key[i]);
+           sprintf(mkey + i * 2, "%.2x", state->master_key[i]);
        for (i = 0; i < sizeof(state->session_key); i++)
-           sprintf(skey + i * 2, "%.2x ", state->session_key[i]);
+           sprintf(skey + i * 2, "%.2x", state->session_key[i]);
        printk(KERN_DEBUG "%s[%d]: keys: master: %s initial session: %s\n",
               debugstr, unit, mkey, skey);
     }
@@ -544,6 +539,7 @@ mppe_incomp(void *arg, unsigned char *ibuf, int icnt)
 {
     ppp_mppe_state *state = (ppp_mppe_state *) arg;
 
+/* XXX */
     if (state->debug &&
        (PPP_PROTOCOL(ibuf) >= 0x0021 && PPP_PROTOCOL(ibuf) <= 0x00fa))
        printk(KERN_DEBUG "mppe_incomp[%d]: incompressible (unencrypted) data! "
@@ -559,7 +555,7 @@ mppe_incomp(void *arg, unsigned char *ibuf, int icnt)
  * Module interface table
  *************************************************************/
 
-/* These are in ppp.c */
+/* These are in ppp.c (2.2.x) or ppp_generic.c (2.4.x) */
 extern int  ppp_register_compressor   (struct compressor *cp);
 extern void ppp_unregister_compressor (struct compressor *cp);
 
@@ -583,7 +579,19 @@ struct compressor ppp_mppe = {
     mppe_comp_stats,   /* decomp_stat */
 };
 
-__initfunc(int ppp_mppe_install(void))
+/* 2.2 compatibility defines */
+#ifndef __init
+#define __init
+#endif
+#ifndef __exit
+#define __exit
+#endif
+#ifndef MODULE_LICENSE
+#define MODULE_LICENSE(license)
+#endif
+
+int __init
+ppp_mppe_init(void)
 {  
     int answer = ppp_register_compressor(&ppp_mppe);
 
@@ -592,20 +600,12 @@ __initfunc(int ppp_mppe_install(void))
     return answer;
 }
 
-#ifdef MODULE
-
-int
-init_module(void)
-{
-    return ppp_mppe_install();
-}
-     
-void
-cleanup_module(void)
+void __exit
+ppp_mppe_cleanup(void)
 {
-    if (MOD_IN_USE)
-       printk(KERN_INFO "PPP MPPE Compression module busy\n");
-    else
-       ppp_unregister_compressor(&ppp_mppe);
+    ppp_unregister_compressor(&ppp_mppe);
 }
-#endif
+
+module_init(ppp_mppe_init);
+module_exit(ppp_mppe_cleanup);
+MODULE_LICENSE("BSD without advertisement clause");