summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/if_ppp.h4
-rw-r--r--include/linux/if_pppvar.h10
-rw-r--r--include/linux/ppp-comp.h9
-rw-r--r--linux/if_ppp.h4
-rw-r--r--linux/if_pppvar.h10
-rw-r--r--linux/ppp-comp.h9
-rw-r--r--linux/ppp.c98
-rw-r--r--linux/ppp_deflate.c704
8 files changed, 421 insertions, 427 deletions
diff --git a/include/linux/if_ppp.h b/include/linux/if_ppp.h
index ed9dc07..22aa277 100644
--- a/include/linux/if_ppp.h
+++ b/include/linux/if_ppp.h
@@ -21,7 +21,7 @@
*/
/*
- * ==FILEVERSION 970627==
+ * ==FILEVERSION 971001==
*
* NOTE TO MAINTAINERS:
* If you modify this file at all, please set the above date.
@@ -47,7 +47,7 @@
#define PPP_MTU 1500 /* Default MTU (size of Info field) */
#define PPP_MAXMRU 65000 /* Largest MRU we allow */
-#define PPP_VERSION "2.3.1"
+#define PPP_VERSION "2.3.2"
#define PPP_MAGIC 0x5002 /* Magic value for the ppp structure */
#define PROTO_IPX 0x002b /* protocol numbers */
#define PROTO_DNA_RT 0x0027 /* DNA Routing */
diff --git a/include/linux/if_pppvar.h b/include/linux/if_pppvar.h
index 3714be0..c1fe88a 100644
--- a/include/linux/if_pppvar.h
+++ b/include/linux/if_pppvar.h
@@ -42,7 +42,7 @@
*/
/*
- * ==FILEVERSION 970626==
+ * ==FILEVERSION 971001==
*
* NOTE TO MAINTAINERS:
* If you modify this file at all, please set the above date.
@@ -72,7 +72,7 @@ struct ppp_buffer {
__s32 count; /* Count of characters in bufr */
__s32 head; /* index to head of list */
__s32 tail; /* index to tail of list */
- __u32 locked; /* Buffer is being sent */
+ unsigned long locked; /* Buffer is being sent */
__s32 type; /* Type of the buffer */
/* =0, device read buffer */
/* =1, device write buffer */
@@ -94,7 +94,7 @@ struct ppp {
struct ppp *next; /* unit with next index */
/* Bitmapped flag fields. */
- __u32 inuse; /* are we allocated? */
+ unsigned long inuse; /* are we allocated? */
__u8 escape; /* 0x20 if prev char was PPP_ESC*/
__u8 toss; /* toss this frame */
@@ -123,7 +123,8 @@ struct ppp {
struct ppp_buffer *s1buf; /* Pointer to daemon buffer */
struct ppp_buffer *s2buf; /* Pointer to device buffer */
- __u32 last_xmit; /* time of last transmission */
+ unsigned long last_xmit; /* time of last transmission */
+ unsigned long last_recv; /* time last packet received */
/* These are pointers to the malloc()ed frame buffers.
These buffers are used while processing a packet. If a packet
@@ -142,7 +143,6 @@ struct ppp {
/* Statistic information */
struct pppstat stats; /* statistic information */
- struct ppp_idle ddinfo; /* demand dial information */
/* PPP compression protocol information */
__u32 sc_bytessent; /* count of octets sent */
diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
index 19e1e4b..cc56636 100644
--- a/include/linux/ppp-comp.h
+++ b/include/linux/ppp-comp.h
@@ -24,11 +24,11 @@
* OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
* OR MODIFICATIONS.
*
- * From: ppp-comp.h,v 1.7 1995/05/01 01:43:37 paulus Exp
+ * $Id: ppp-comp.h,v 1.6 1997/11/27 06:04:44 paulus Exp $
*/
/*
- * ==FILEVERSION 970501==
+ * ==FILEVERSION 971024==
*
* NOTE TO MAINTAINERS:
* If you modify this file at all, please set the above date.
@@ -120,9 +120,8 @@ struct compressor {
* Don't you just lurve software patents.
*/
-#define DECOMP_OK 0 /* no error occured */
-#define DECOMP_ERROR 1 /* error detected before decomp. */
-#define DECOMP_FATALERROR 2 /* error detected after decomp. */
+#define DECOMP_ERROR -1 /* error detected before decomp. */
+#define DECOMP_FATALERROR -2 /* error detected after decomp. */
/*
* CCP codes.
diff --git a/linux/if_ppp.h b/linux/if_ppp.h
index ed9dc07..22aa277 100644
--- a/linux/if_ppp.h
+++ b/linux/if_ppp.h
@@ -21,7 +21,7 @@
*/
/*
- * ==FILEVERSION 970627==
+ * ==FILEVERSION 971001==
*
* NOTE TO MAINTAINERS:
* If you modify this file at all, please set the above date.
@@ -47,7 +47,7 @@
#define PPP_MTU 1500 /* Default MTU (size of Info field) */
#define PPP_MAXMRU 65000 /* Largest MRU we allow */
-#define PPP_VERSION "2.3.1"
+#define PPP_VERSION "2.3.2"
#define PPP_MAGIC 0x5002 /* Magic value for the ppp structure */
#define PROTO_IPX 0x002b /* protocol numbers */
#define PROTO_DNA_RT 0x0027 /* DNA Routing */
diff --git a/linux/if_pppvar.h b/linux/if_pppvar.h
index 3714be0..c1fe88a 100644
--- a/linux/if_pppvar.h
+++ b/linux/if_pppvar.h
@@ -42,7 +42,7 @@
*/
/*
- * ==FILEVERSION 970626==
+ * ==FILEVERSION 971001==
*
* NOTE TO MAINTAINERS:
* If you modify this file at all, please set the above date.
@@ -72,7 +72,7 @@ struct ppp_buffer {
__s32 count; /* Count of characters in bufr */
__s32 head; /* index to head of list */
__s32 tail; /* index to tail of list */
- __u32 locked; /* Buffer is being sent */
+ unsigned long locked; /* Buffer is being sent */
__s32 type; /* Type of the buffer */
/* =0, device read buffer */
/* =1, device write buffer */
@@ -94,7 +94,7 @@ struct ppp {
struct ppp *next; /* unit with next index */
/* Bitmapped flag fields. */
- __u32 inuse; /* are we allocated? */
+ unsigned long inuse; /* are we allocated? */
__u8 escape; /* 0x20 if prev char was PPP_ESC*/
__u8 toss; /* toss this frame */
@@ -123,7 +123,8 @@ struct ppp {
struct ppp_buffer *s1buf; /* Pointer to daemon buffer */
struct ppp_buffer *s2buf; /* Pointer to device buffer */
- __u32 last_xmit; /* time of last transmission */
+ unsigned long last_xmit; /* time of last transmission */
+ unsigned long last_recv; /* time last packet received */
/* These are pointers to the malloc()ed frame buffers.
These buffers are used while processing a packet. If a packet
@@ -142,7 +143,6 @@ struct ppp {
/* Statistic information */
struct pppstat stats; /* statistic information */
- struct ppp_idle ddinfo; /* demand dial information */
/* PPP compression protocol information */
__u32 sc_bytessent; /* count of octets sent */
diff --git a/linux/ppp-comp.h b/linux/ppp-comp.h
index 19e1e4b..cc56636 100644
--- a/linux/ppp-comp.h
+++ b/linux/ppp-comp.h
@@ -24,11 +24,11 @@
* OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
* OR MODIFICATIONS.
*
- * From: ppp-comp.h,v 1.7 1995/05/01 01:43:37 paulus Exp
+ * $Id: ppp-comp.h,v 1.6 1997/11/27 06:04:44 paulus Exp $
*/
/*
- * ==FILEVERSION 970501==
+ * ==FILEVERSION 971024==
*
* NOTE TO MAINTAINERS:
* If you modify this file at all, please set the above date.
@@ -120,9 +120,8 @@ struct compressor {
* Don't you just lurve software patents.
*/
-#define DECOMP_OK 0 /* no error occured */
-#define DECOMP_ERROR 1 /* error detected before decomp. */
-#define DECOMP_FATALERROR 2 /* error detected after decomp. */
+#define DECOMP_ERROR -1 /* error detected before decomp. */
+#define DECOMP_FATALERROR -2 /* error detected after decomp. */
/*
* CCP codes.
diff --git a/linux/ppp.c b/linux/ppp.c
index 38472f9..06f39c6 100644
--- a/linux/ppp.c
+++ b/linux/ppp.c
@@ -2,11 +2,12 @@
*
* Michael Callahan <callahan@maths.ox.ac.uk>
* Al Longyear <longyear@netcom.com>
+ * Paul Mackerras <Paul.Mackerras@cs.anu.edu.au>
*
* Dynamic PPP devices by Jim Freeman <jfree@caldera.com>.
* ppp_tty_receive ``noisy-raise-bug'' fixed by Ove Ewerlid <ewerlid@syscon.uu.se>
*
- * ==FILEVERSION 970626==
+ * ==FILEVERSION 971016==
*
* NOTE TO MAINTAINERS:
* If you modify this file at all, please set the number above to the
@@ -47,17 +48,7 @@
#define CHECK_CHARACTERS 1
#define PPP_COMPRESS 1
-#ifndef PPP_MAX_DEV
-#define PPP_MAX_DEV 256
-#endif
-
-/* $Id: ppp.c,v 1.13 1997/07/14 03:50:50 paulus Exp $
- * Added dynamic allocation of channels to eliminate
- * compiled-in limits on the number of channels.
- *
- * Dynamic channel allocation code Copyright 1995 Caldera, Inc.,
- * released under the GNU General Public License Version 2.
- */
+/* $Id: ppp.c,v 1.14 1997/11/27 06:04:45 paulus Exp $ */
#include <linux/version.h>
#include <linux/module.h>
@@ -185,7 +176,7 @@ extern inline void ppp_stuff_char (struct ppp *ppp,
register __u8 chr);
extern inline int lock_buffer (register struct ppp_buffer *buf);
static int ppp_dev_xmit_ip (struct ppp *ppp, struct ppp_buffer *buf,
- __u8 *data, int len);
+ __u8 *data, int len, enum NPmode npmode);
static int rcv_proto_ip (struct ppp *, __u16, __u8 *, int);
static int rcv_proto_ipx (struct ppp *, __u16, __u8 *, int);
@@ -205,20 +196,14 @@ static int rcv_proto_ccp (struct ppp *, __u16, __u8 *, int);
#define OPTIMIZE_FLAG_TIME 0
#endif
-#ifndef PPP_MAX_DEV
-#define PPP_MAX_DEV 256
-#endif
-
/*
* Parameters which may be changed via insmod.
*/
static int flag_time = OPTIMIZE_FLAG_TIME;
-static int max_dev = PPP_MAX_DEV;
#if LINUX_VERSION_CODE >= VERSION(2,1,19)
MODULE_PARM(flag_time, "i");
-MODULE_PARM(max_dev, "i");
#endif
/*
@@ -455,7 +440,7 @@ ppp_init_dev (struct device *dev)
dev->rebuild_header = ppp_dev_rebuild;
#endif
- dev->hard_header_len = PPP_HARD_HDR_LEN;
+ dev->hard_header_len = PPP_HDRLEN;
/* device INFO */
dev->mtu = PPP_MTU;
@@ -518,14 +503,11 @@ ppp_init_ctrl_blk (register struct ppp *ppp)
ppp->read_wait = NULL;
ppp->write_wait = NULL;
ppp->last_xmit = jiffies - flag_time;
+ ppp->last_recv = jiffies;
/* clear statistics */
memset(&ppp->stats, 0, sizeof (struct pppstat));
- memset(&ppp->estats, 0, sizeof(struct enet_statistics));
-
- /* Reset the demand dial information */
- ppp->ddinfo.xmit_idle= /* time since last NP packet sent */
- ppp->ddinfo.recv_idle=jiffies; /* time since last NP packet received */
+ memset(&ppp->estats, 0, sizeof(ppp->estats));
/* PPP compression data */
ppp->sc_xc_state =
@@ -622,7 +604,7 @@ ppp_free_buf (struct ppp_buffer *ptr)
extern inline int
lock_buffer (register struct ppp_buffer *buf)
{
- register int state;
+ unsigned long state;
unsigned long flags;
/*
* Save the current state and if free then set it to the "busy" state
@@ -795,7 +777,7 @@ ppp_release (struct ppp *ppp)
dev = ppp2dev (ppp);
if (ppp->flags & SC_DEBUG)
- printk(KERN_DEBUG "ppp%s released\n", ppp->name);
+ printk(KERN_DEBUG "%s released\n", ppp->name);
ppp_ccp_closed (ppp);
@@ -1038,9 +1020,7 @@ ppp_tty_wakeup_code (struct ppp *ppp, struct tty_struct *tty,
* transmission block.
*/
ppp2dev (ppp)->tbusy = 0;
- if (ppp2dev (ppp) -> flags & IFF_UP) {
- mark_bh (NET_BH);
- }
+ mark_bh (NET_BH);
/*
* Wake up the transmission queue for all completion events.
*/
@@ -1220,6 +1200,7 @@ ppp_tty_receive (struct tty_struct *tty, const __u8 * data,
*/
if (ppp->flags & SC_LOG_RAWIN)
ppp_print_buffer ("receive buffer", data, count);
+
/*
* Collect the character and error condition for the character. Set the toss
* flag for the first character error.
@@ -1242,6 +1223,7 @@ ppp_tty_receive (struct tty_struct *tty, const __u8 * data,
}
++flags;
}
+
/*
* Set the flags for d7 being 0/1 and parity being even/odd so that
* the normal processing would have all flags set at the end of the
@@ -1360,6 +1342,7 @@ ppp_doframe (struct ppp *ppp)
CHECK_PPP(0);
CHECK_BUF_MAGIC(ppp->rbuf);
+
/*
* If there is a pending error from the receiver then log it and discard
* the damaged frame.
@@ -1533,7 +1516,7 @@ ppp_rcv_rx (struct ppp *ppp, __u16 proto, __u8 * data, int count)
skb->free = 1;
#endif
- ppp->ddinfo.recv_idle = jiffies;
+ ppp->last_recv = jiffies;
netif_rx (skb);
return 1;
}
@@ -1849,8 +1832,8 @@ ppp_tty_read (struct tty_struct *tty, struct file *file, __u8 * buf,
if (!ppp)
return -EIO;
- if (ppp->magic != PPP_MAGIC)
- return -EIO;
+ /* if (ppp->magic != PPP_MAGIC)
+ return -EIO; */
CHECK_PPP (-ENXIO);
@@ -2031,7 +2014,7 @@ ppp_dev_xmit_lower (struct ppp *ppp, struct ppp_buffer *buf,
if (non_ip || flag_time == 0)
ins_char (buf, PPP_FLAG);
else {
- if (jiffies - ppp->last_xmit > flag_time)
+ if (jiffies - ppp->last_xmit >= flag_time)
ins_char (buf, PPP_FLAG);
}
ppp->last_xmit = jiffies;
@@ -2195,7 +2178,7 @@ ppp_tty_write (struct tty_struct *tty, struct file *file, const __u8 * data,
{
struct ppp *ppp = tty2ppp (tty);
__u8 *new_data;
- int proto;
+ int error;
/*
* Verify the pointers.
@@ -2231,9 +2214,10 @@ ppp_tty_write (struct tty_struct *tty, struct file *file, const __u8 * data,
/*
* Retrieve the user's buffer
*/
- if (copy_from_user (new_data, data, count)) {
+ COPY_FROM_USER (error, new_data, data, count);
+ if (error) {
kfree (new_data);
- return -EFAULT;
+ return error;
}
/*
* lock this PPP unit so we will be the only writer;
@@ -2266,14 +2250,14 @@ ppp_tty_write (struct tty_struct *tty, struct file *file, const __u8 * data,
/*
* Send the data
*/
- if (proto == PPP_IP) {
+ if (PPP_PROTOCOL(new_data) == PPP_IP) {
/*
* IP frames can be sent by pppd when we're doing
* demand-dialling. We send them via ppp_dev_xmit_ip
* to make sure that VJ compression happens properly.
*/
ppp_dev_xmit_ip(ppp, ppp->tbuf, new_data + PPP_HDRLEN,
- count - PPP_HDRLEN);
+ count - PPP_HDRLEN, NPMODE_PASS);
} else {
ppp_dev_xmit_frame (ppp, ppp->tbuf, new_data, count);
@@ -2530,11 +2514,10 @@ ppp_tty_ioctl (struct tty_struct *tty, struct file * file,
case PPPIOCGIDLE:
{
struct ppp_idle cur_ddinfo;
- __u32 cur_jiffies = jiffies;
/* change absolute times to relative times. */
- cur_ddinfo.xmit_idle = (cur_jiffies - ppp->ddinfo.xmit_idle) / HZ;
- cur_ddinfo.recv_idle = (cur_jiffies - ppp->ddinfo.recv_idle) / HZ;
+ cur_ddinfo.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
+ cur_ddinfo.recv_idle = (jiffies - ppp->last_recv) / HZ;
COPY_TO_USER (error,
(void *) param3,
&cur_ddinfo,
@@ -2653,6 +2636,8 @@ ppp_tty_ioctl (struct tty_struct *tty, struct file * file,
if (ppp->flags & SC_DEBUG)
printk(KERN_DEBUG "ppp: set np %d to %d\n",
npi.protocol, npi.mode);
+ ppp2dev(ppp)->tbusy = 0;
+ mark_bh(NET_BH);
}
break;
/*
@@ -2767,6 +2752,7 @@ ppp_tty_poll (struct tty_struct *tty, struct file *filp, poll_table * wait)
poll_wait(&ppp->write_wait, wait);
/* Must lock the user buffer area while checking. */
+ CHECK_BUF_MAGIC(ppp->ubuf);
if(test_and_set_bit(0, &ppp->ubuf->locked) == 0) {
if(ppp->ubuf->head != ppp->ubuf->tail)
mask |= POLLIN | POLLRDNORM;
@@ -2801,8 +2787,10 @@ ppp_dev_open (struct device *dev)
{
struct ppp *ppp = dev2ppp (dev);
+#if 0
/* reset POINTOPOINT every time, since dev_close zaps it! */
dev->flags |= IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
+#endif
if (ppp2tty (ppp) == NULL) {
if (ppp->flags & SC_DEBUG)
@@ -2984,14 +2972,14 @@ ppp_dev_ioctl (struct device *dev, struct ifreq *ifr, int cmd)
static int
ppp_dev_xmit_ip (struct ppp *ppp, struct ppp_buffer *buf,
- __u8 *data, int len)
+ __u8 *data, int len, enum NPmode npmode)
{
int proto = PPP_IP;
__u8 *hdr;
/*
* Branch on the type of processing for the IP frame.
*/
- switch (ppp->sc_npmode[NP_IP]) {
+ switch (npmode) {
case NPMODE_PASS:
break;
@@ -3052,7 +3040,7 @@ ppp_dev_xmit_ip (struct ppp *ppp, struct ppp_buffer *buf,
hdr[2] = 0;
hdr[3] = proto;
- return ppp_dev_xmit_frame (ppp, ppp->wbuf, hdr, len);
+ return ppp_dev_xmit_frame (ppp, buf, hdr, len);
}
/*
@@ -3149,7 +3137,7 @@ ppp_dev_xmit (sk_buff *skb, struct device *dev)
if (ppp->tbuf->locked || lock_buffer (ppp->wbuf) != 0) {
dev->tbusy = 1;
if (ppp->flags & SC_DEBUG)
- printk(KERN_DEBUG "dev_xmit blocked, t=%d w=%d\n",
+ printk(KERN_DEBUG "dev_xmit blocked, t=%lu w=%lu\n",
ppp->tbuf->locked, ppp->wbuf->locked);
return 1;
}
@@ -3163,7 +3151,8 @@ ppp_dev_xmit (sk_buff *skb, struct device *dev)
break;
case ETH_P_IP:
- answer = ppp_dev_xmit_ip (ppp, ppp->wbuf, data, len);
+ answer = ppp_dev_xmit_ip (ppp, ppp->wbuf, data, len,
+ ppp->sc_npmode[NP_IP]);
break;
default: /* All others have no support at this time. */
@@ -3176,7 +3165,6 @@ ppp_dev_xmit (sk_buff *skb, struct device *dev)
if (answer == 0) {
/* packet queued OK */
dev_kfree_skb (skb, FREE_WRITE);
- ppp->ddinfo.xmit_idle = jiffies;
} else {
ppp->wbuf->locked = 0;
if (answer < 0) {
@@ -3200,10 +3188,14 @@ ppp_dev_stats (struct device *dev)
{
struct ppp *ppp = dev2ppp (dev);
- ppp->estats.rx_packets = ppp->stats.ppp_ipackets;
- ppp->estats.rx_errors = ppp->stats.ppp_ierrors;
- ppp->estats.tx_packets = ppp->stats.ppp_opackets;
- ppp->estats.tx_errors = ppp->stats.ppp_oerrors;
+ ppp->estats.rx_packets = ppp->stats.ppp_ipackets;
+ ppp->estats.rx_errors = ppp->stats.ppp_ierrors;
+ ppp->estats.tx_packets = ppp->stats.ppp_opackets;
+ ppp->estats.tx_errors = ppp->stats.ppp_oerrors;
+#if LINUX_VERSION_CODE >= VERSION(2,1,25)
+ ppp->estats.rx_bytes = ppp->stats.ppp_ibytes;
+ ppp->estats.tx_bytes = ppp->stats.ppp_obytes;
+#endif
return &ppp->estats;
}
@@ -3257,7 +3249,7 @@ ppp_alloc (void)
/* try to find an free device */
if_num = 0;
for (ppp = ppp_list; ppp != 0; ppp = ppp->next) {
- if (!set_bit(0, &ppp->inuse))
+ if (!test_and_set_bit(0, &ppp->inuse))
return ppp;
++if_num;
}
diff --git a/linux/ppp_deflate.c b/linux/ppp_deflate.c
index edd1cd9..bd22342 100644
--- a/linux/ppp_deflate.c
+++ b/linux/ppp_deflate.c
@@ -1,5 +1,5 @@
/*
- * ==FILEVERSION 970522==
+ * ==FILEVERSION 971001==
*
* ppp_deflate.c - interface the zlib procedures for Deflate compression
* and decompression (as used by gzip) to the PPP code.
@@ -86,7 +86,7 @@ struct ppp_deflate_state {
static void *zalloc __P((void *, unsigned int items, unsigned int size));
static void *zalloc_init __P((void *, unsigned int items,
unsigned int size));
-static void zfree __P((void *, void *ptr, unsigned int nb));
+static void zfree __P((void *, void *ptr));
static void *z_comp_alloc __P((unsigned char *options, int opt_len));
static void *z_decomp_alloc __P((unsigned char *options, int opt_len));
static void z_comp_free __P((void *state));
@@ -108,27 +108,32 @@ static void z_decomp_reset __P((void *state));
static void z_comp_stats __P((void *state, struct compstat *stats));
struct chunk_header {
- unsigned size; /* amount of space following header */
- int valloced; /* allocated with valloc, not kmalloc */
+ int valloced; /* allocated with valloc, not kmalloc */
+ int guard; /* check for overwritten header */
};
+#define GUARD_MAGIC 0x77a8011a
#define MIN_VMALLOC 2048 /* use kmalloc for blocks < this */
/*
* Space allocation and freeing routines for use by zlib routines.
*/
void
-zfree(arg, ptr, nbytes)
+zfree(arg, ptr)
void *arg;
void *ptr;
- unsigned int nbytes;
{
- struct chunk_header *hdr = ((struct chunk_header *)ptr) - 1;
+ struct chunk_header *hdr = ((struct chunk_header *)ptr) - 1;
- if (hdr->valloced)
- vfree(hdr);
- else
- kfree(hdr);
+ if (hdr->guard != GUARD_MAGIC) {
+ printk(KERN_WARNING "zfree: header corrupted (%x %x) at %p\n",
+ hdr->valloced, hdr->guard, hdr);
+ return;
+ }
+ if (hdr->valloced)
+ vfree(hdr);
+ else
+ kfree(hdr);
}
void *
@@ -136,16 +141,16 @@ zalloc(arg, items, size)
void *arg;
unsigned int items, size;
{
- struct chunk_header *hdr;
- unsigned nbytes;
-
- nbytes = items * size + sizeof(*hdr);
- hdr = kmalloc(nbytes, GFP_ATOMIC);
- if (hdr == 0)
- return 0;
- hdr->size = nbytes;
- hdr->valloced = 0;
- return (void *) (hdr + 1);
+ struct chunk_header *hdr;
+ unsigned nbytes;
+
+ nbytes = items * size + sizeof(*hdr);
+ hdr = kmalloc(nbytes, GFP_ATOMIC);
+ if (hdr == 0)
+ return 0;
+ hdr->valloced = 0;
+ hdr->guard = GUARD_MAGIC;
+ return (void *) (hdr + 1);
}
void *
@@ -153,32 +158,32 @@ zalloc_init(arg, items, size)
void *arg;
unsigned int items, size;
{
- struct chunk_header *hdr;
- unsigned nbytes;
-
- nbytes = items * size + sizeof(*hdr);
- if (nbytes >= MIN_VMALLOC)
- hdr = vmalloc(nbytes);
- else
- hdr = kmalloc(nbytes, GFP_KERNEL);
- if (hdr == 0)
- return 0;
- hdr->size = nbytes;
- hdr->valloced = nbytes >= MIN_VMALLOC;
- return (void *) (hdr + 1);
+ struct chunk_header *hdr;
+ unsigned nbytes;
+
+ nbytes = items * size + sizeof(*hdr);
+ if (nbytes >= MIN_VMALLOC)
+ hdr = vmalloc(nbytes);
+ else
+ hdr = kmalloc(nbytes, GFP_KERNEL);
+ if (hdr == 0)
+ return 0;
+ hdr->valloced = nbytes >= MIN_VMALLOC;
+ hdr->guard = GUARD_MAGIC;
+ return (void *) (hdr + 1);
}
static void
z_comp_free(arg)
void *arg;
{
- struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
+ struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
- if (state) {
- deflateEnd(&state->strm);
- kfree(state);
- MOD_DEC_USE_COUNT;
- }
+ if (state) {
+ deflateEnd(&state->strm);
+ kfree(state);
+ MOD_DEC_USE_COUNT;
+ }
}
/*
@@ -189,36 +194,38 @@ z_comp_alloc(options, opt_len)
unsigned char *options;
int opt_len;
{
- struct ppp_deflate_state *state;
- int w_size;
-
- if (opt_len != CILEN_DEFLATE || options[0] != CI_DEFLATE
- || options[1] != CILEN_DEFLATE
- || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
- || options[3] != DEFLATE_CHK_SEQUENCE)
- return NULL;
- w_size = DEFLATE_SIZE(options[2]);
- if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
- return NULL;
-
- state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL);
- if (state == NULL)
- return NULL;
-
- MOD_INC_USE_COUNT;
- memset (state, 0, sizeof (struct ppp_deflate_state));
- state->strm.next_in = NULL;
- state->strm.zalloc = zalloc;
- state->strm.zalloc_init = zalloc_init;
- state->strm.zfree = zfree;
- state->w_size = w_size;
-
- if (deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION, DEFLATE_METHOD_VAL,
- -w_size, 8, Z_DEFAULT_STRATEGY, DEFLATE_OVHD+2) != Z_OK) {
- z_comp_free(state);
- return NULL;
- }
- return (void *) state;
+ struct ppp_deflate_state *state;
+ int w_size;
+
+ if (opt_len != CILEN_DEFLATE || options[0] != CI_DEFLATE
+ || options[1] != CILEN_DEFLATE
+ || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
+ || options[3] != DEFLATE_CHK_SEQUENCE)
+ return NULL;
+ w_size = DEFLATE_SIZE(options[2]);
+ if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
+ return NULL;
+
+ state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL);
+ if (state == NULL)
+ return NULL;
+
+ MOD_INC_USE_COUNT;
+ memset (state, 0, sizeof (struct ppp_deflate_state));
+ state->strm.next_in = NULL;
+ state->strm.zalloc = zalloc_init;
+ state->strm.zfree = zfree;
+ state->w_size = w_size;
+
+ if (deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION,
+ DEFLATE_METHOD_VAL, -w_size, 8, Z_DEFAULT_STRATEGY)
+ != Z_OK) {
+ z_comp_free(state);
+ return NULL;
+ }
+
+ state->strm.zalloc = zalloc;
+ return (void *) state;
}
static int
@@ -227,32 +234,32 @@ z_comp_init(arg, options, opt_len, unit, hdrlen, debug)
unsigned char *options;
int opt_len, unit, hdrlen, debug;
{
- struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
+ struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
- if (opt_len < CILEN_DEFLATE || options[0] != CI_DEFLATE
- || options[1] != CILEN_DEFLATE
- || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
- || DEFLATE_SIZE(options[2]) != state->w_size
- || options[3] != DEFLATE_CHK_SEQUENCE)
- return 0;
+ if (opt_len < CILEN_DEFLATE || options[0] != CI_DEFLATE
+ || options[1] != CILEN_DEFLATE
+ || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
+ || DEFLATE_SIZE(options[2]) != state->w_size
+ || options[3] != DEFLATE_CHK_SEQUENCE)
+ return 0;
- state->seqno = 0;
- state->unit = unit;
- state->debug = debug;
+ state->seqno = 0;
+ state->unit = unit;
+ state->debug = debug;
- deflateReset(&state->strm);
+ deflateReset(&state->strm);
- return 1;
+ return 1;
}
static void
z_comp_reset(arg)
void *arg;
{
- struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
+ struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
- state->seqno = 0;
- deflateReset(&state->strm);
+ state->seqno = 0;
+ deflateReset(&state->strm);
}
int
@@ -262,81 +269,79 @@ z_compress(arg, rptr, obuf, isize, osize)
unsigned char *obuf; /* compressed packet (out) */
int isize, osize;
{
- struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
- int r, proto, off, olen;
- unsigned char *wptr;
-
- /*
- * Check that the protocol is in the range we handle.
- */
- proto = PPP_PROTOCOL(rptr);
- if (proto > 0x3fff || proto == 0xfd || proto == 0xfb)
- return 0;
-
- /* Don't generate compressed packets which are larger than
- the uncompressed packet. */
- if (osize > isize)
- osize = isize;
-
- wptr = obuf;
-
- /*
- * Copy over the PPP header and store the 2-byte sequence number.
- */
- wptr[0] = PPP_ADDRESS(rptr);
- wptr[1] = PPP_CONTROL(rptr);
- wptr[2] = PPP_COMP >> 8;
- wptr[3] = PPP_COMP;
- wptr += PPP_HDRLEN;
- wptr[0] = state->seqno >> 8;
- wptr[1] = state->seqno;
- wptr += 2;
- state->strm.next_out = wptr;
- state->strm.avail_out = osize - (PPP_HDRLEN + 2);
- ++state->seqno;
-
- off = (proto > 0xff) ? 2 : 3; /* skip 1st proto byte if 0 */
- rptr += off;
- state->strm.next_in = rptr;
- state->strm.avail_in = (isize - off);
-
- olen = 0;
- for (;;) {
- r = deflate(&state->strm, Z_PACKET_FLUSH);
- if (r != Z_OK) {
- if (state->debug)
- printk(KERN_DEBUG "z_compress: deflate returned %d (%s)\n",
- r, (state->strm.msg? state->strm.msg: ""));
- break;
+ struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
+ int r, proto, off, olen;
+ unsigned char *wptr;
+
+ /*
+ * Check that the protocol is in the range we handle.
+ */
+ proto = PPP_PROTOCOL(rptr);
+ if (proto > 0x3fff || proto == 0xfd || proto == 0xfb)
+ return 0;
+
+ /* Don't generate compressed packets which are larger than
+ the uncompressed packet. */
+ if (osize > isize)
+ osize = isize;
+
+ wptr = obuf;
+
+ /*
+ * Copy over the PPP header and store the 2-byte sequence number.
+ */
+ wptr[0] = PPP_ADDRESS(rptr);
+ wptr[1] = PPP_CONTROL(rptr);
+ wptr[2] = PPP_COMP >> 8;
+ wptr[3] = PPP_COMP;
+ wptr += PPP_HDRLEN;
+ wptr[0] = state->seqno >> 8;
+ wptr[1] = state->seqno;
+ wptr += 2;
+ state->strm.next_out = wptr;
+ state->strm.avail_out = osize - (PPP_HDRLEN + 2);
+ ++state->seqno;
+
+ off = (proto > 0xff) ? 2 : 3; /* skip 1st proto byte if 0 */
+ rptr += off;
+ state->strm.next_in = rptr;
+ state->strm.avail_in = (isize - off);
+
+ olen = 0;
+ for (;;) {
+ r = deflate(&state->strm, Z_PACKET_FLUSH);
+ if (r != Z_OK) {
+ if (state->debug)
+ printk(KERN_DEBUG "z_compress: deflate returned %d (%s)\n",
+ r, (state->strm.msg? state->strm.msg: ""));
+ break;
+ }
+ if (state->strm.avail_out == 0) {
+ olen += osize;
+ state->strm.next_out = NULL;
+ state->strm.avail_out = 1000000;
+ } else {
+ break; /* all done */
+ }
}
- if (state->strm.avail_out == 0) {
- olen += osize;
- state->strm.next_out = NULL;
- state->strm.avail_out = 1000000;
+ if (olen < osize)
+ olen += osize - state->strm.avail_out;
+
+ /*
+ * See if we managed to reduce the size of the packet.
+ */
+ if (olen < isize) {
+ state->stats.comp_bytes += olen;
+ state->stats.comp_packets++;
} else {
- break; /* all done */
+ state->stats.inc_bytes += isize;
+ state->stats.inc_packets++;
+ olen = 0;
}
- }
- if (olen < osize)
- olen += osize - state->strm.avail_out;
-
- /*
- * See if we managed to reduce the size of the packet.
- * If the compressor just gave us a single zero byte, it means
- * the packet was incompressible.
- */
- if (olen < isize && !(olen == PPP_HDRLEN + 3 && *wptr == 0)) {
- state->stats.comp_bytes += olen;
- state->stats.comp_packets++;
- } else {
- state->stats.inc_bytes += isize;
- state->stats.inc_packets++;
- olen = 0;
- }
- state->stats.unc_bytes += isize;
- state->stats.unc_packets++;
+ state->stats.unc_bytes += isize;
+ state->stats.unc_packets++;
- return olen;
+ return olen;
}
static void
@@ -344,22 +349,22 @@ z_comp_stats(arg, stats)
void *arg;
struct compstat *stats;
{
- struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
+ struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
- *stats = state->stats;
+ *stats = state->stats;
}
static void
z_decomp_free(arg)
void *arg;
{
- struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
+ struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
- if (state) {
- inflateEnd(&state->strm);
- kfree(state);
- MOD_DEC_USE_COUNT;
- }
+ if (state) {
+ inflateEnd(&state->strm);
+ kfree(state);
+ MOD_DEC_USE_COUNT;
+ }
}
/*
@@ -370,35 +375,36 @@ z_decomp_alloc(options, opt_len)
unsigned char *options;
int opt_len;
{
- struct ppp_deflate_state *state;
- int w_size;
-
- if (opt_len != CILEN_DEFLATE || options[0] != CI_DEFLATE
- || options[1] != CILEN_DEFLATE
- || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
- || options[3] != DEFLATE_CHK_SEQUENCE)
- return NULL;
- w_size = DEFLATE_SIZE(options[2]);
- if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
- return NULL;
-
- state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL);
- if (state == NULL)
- return NULL;
-
- MOD_INC_USE_COUNT;
- memset (state, 0, sizeof (struct ppp_deflate_state));
- state->w_size = w_size;
- state->strm.next_out = NULL;
- state->strm.zalloc = zalloc;
- state->strm.zalloc_init = zalloc_init;
- state->strm.zfree = zfree;
-
- if (inflateInit2(&state->strm, -w_size) != Z_OK) {
- z_decomp_free(state);
- return NULL;
- }
- return (void *) state;
+ struct ppp_deflate_state *state;
+ int w_size;
+
+ if (opt_len != CILEN_DEFLATE || options[0] != CI_DEFLATE
+ || options[1] != CILEN_DEFLATE
+ || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
+ || options[3] != DEFLATE_CHK_SEQUENCE)
+ return NULL;
+ w_size = DEFLATE_SIZE(options[2]);
+ if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
+ return NULL;
+
+ state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL);
+ if (state == NULL)
+ return NULL;
+
+ MOD_INC_USE_COUNT;
+ memset (state, 0, sizeof (struct ppp_deflate_state));
+ state->w_size = w_size;
+ state->strm.next_out = NULL;
+ state->strm.zalloc = zalloc_init;
+ state->strm.zfree = zfree;
+
+ if (inflateInit2(&state->strm, -w_size) != Z_OK) {
+ z_decomp_free(state);
+ return NULL;
+ }
+
+ state->strm.zalloc = zalloc;
+ return (void *) state;
}
static int
@@ -407,33 +413,33 @@ z_decomp_init(arg, options, opt_len, unit, hdrlen, mru, debug)
unsigned char *options;
int opt_len, unit, hdrlen, mru, debug;
{
- struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
+ struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
- if (opt_len < CILEN_DEFLATE || options[0] != CI_DEFLATE
- || options[1] != CILEN_DEFLATE
- || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
- || DEFLATE_SIZE(options[2]) != state->w_size
- || options[3] != DEFLATE_CHK_SEQUENCE)
- return 0;
+ if (opt_len < CILEN_DEFLATE || options[0] != CI_DEFLATE
+ || options[1] != CILEN_DEFLATE
+ || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
+ || DEFLATE_SIZE(options[2]) != state->w_size
+ || options[3] != DEFLATE_CHK_SEQUENCE)
+ return 0;
- state->seqno = 0;
- state->unit = unit;
- state->debug = debug;
- state->mru = mru;
+ state->seqno = 0;
+ state->unit = unit;
+ state->debug = debug;
+ state->mru = mru;
- inflateReset(&state->strm);
+ inflateReset(&state->strm);
- return 1;
+ return 1;
}
static void
z_decomp_reset(arg)
void *arg;
{
- struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
+ struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
- state->seqno = 0;
- inflateReset(&state->strm);
+ state->seqno = 0;
+ inflateReset(&state->strm);
}
/*
@@ -460,97 +466,97 @@ z_decompress(arg, ibuf, isize, obuf, osize)
unsigned char *obuf;
int osize;
{
- struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
- int olen, seq, r;
- int decode_proto, overflow;
- unsigned char overflow_buf[1];
-
- if (isize <= PPP_HDRLEN + DEFLATE_OVHD) {
- if (state->debug)
- printk(KERN_DEBUG "z_decompress%d: short packet (len=%d)\n",
- state->unit, isize);
- return DECOMP_ERROR;
- }
-
- /* Check the sequence number. */
- seq = (ibuf[PPP_HDRLEN] << 8) + ibuf[PPP_HDRLEN+1];
- if (seq != state->seqno) {
- if (state->debug)
- printk(KERN_DEBUG "z_decompress%d: bad seq # %d, expected %d\n",
- state->unit, seq, state->seqno);
- return DECOMP_ERROR;
- }
- ++state->seqno;
-
- /*
- * Fill in the first part of the PPP header. The protocol field
- * comes from the decompressed data.
- */
- obuf[0] = PPP_ADDRESS(ibuf);
- obuf[1] = PPP_CONTROL(ibuf);
- obuf[2] = 0;
-
- /*
- * Set up to call inflate. We set avail_out to 1 initially so we can
- * look at the first byte of the output and decide whether we have
- * a 1-byte or 2-byte protocol field.
- */
- state->strm.next_in = ibuf + PPP_HDRLEN + DEFLATE_OVHD;
- state->strm.avail_in = isize - (PPP_HDRLEN + DEFLATE_OVHD);
- state->strm.next_out = obuf + 3;
- state->strm.avail_out = 1;
- decode_proto = 1;
- overflow = 0;
-
- /*
- * Call inflate, supplying more input or output as needed.
- */
- for (;;) {
- r = inflate(&state->strm, Z_PACKET_FLUSH);
- if (r != Z_OK) {
- if (state->debug)
- printk(KERN_DEBUG "z_decompress%d: inflate returned %d (%s)\n",
- state->unit, r, (state->strm.msg? state->strm.msg: ""));
- return DECOMP_FATALERROR;
+ struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
+ int olen, seq, r;
+ int decode_proto, overflow;
+ unsigned char overflow_buf[1];
+
+ if (isize <= PPP_HDRLEN + DEFLATE_OVHD) {
+ if (state->debug)
+ printk(KERN_DEBUG "z_decompress%d: short pkt (%d)\n",
+ state->unit, isize);
+ return DECOMP_ERROR;
}
- if (state->strm.avail_out != 0)
- break; /* all done */
- if (decode_proto) {
- state->strm.avail_out = osize - PPP_HDRLEN;
- if ((obuf[3] & 1) == 0) {
- /* 2-byte protocol field */
- obuf[2] = obuf[3];
- --state->strm.next_out;
- ++state->strm.avail_out;
- }
- decode_proto = 0;
- } else if (!overflow) {
- /*
- * We've filled up the output buffer; the only way to
- * find out whether inflate has any more characters left
- * is to give it another byte of output space.
- */
- state->strm.next_out = overflow_buf;
- state->strm.avail_out = 1;
- overflow = 1;
- } else {
- if (state->debug)
- printk(KERN_DEBUG "z_decompress%d: ran out of mru\n",
- state->unit);
- return DECOMP_FATALERROR;
+
+ /* Check the sequence number. */
+ seq = (ibuf[PPP_HDRLEN] << 8) + ibuf[PPP_HDRLEN+1];
+ if (seq != state->seqno) {
+ if (state->debug)
+ printk(KERN_DEBUG "z_decompress%d: bad seq # %d, expected %d\n",
+ state->unit, seq, state->seqno);
+ return DECOMP_ERROR;
+ }
+ ++state->seqno;
+
+ /*
+ * Fill in the first part of the PPP header. The protocol field
+ * comes from the decompressed data.
+ */
+ obuf[0] = PPP_ADDRESS(ibuf);
+ obuf[1] = PPP_CONTROL(ibuf);
+ obuf[2] = 0;
+
+ /*
+ * Set up to call inflate. We set avail_out to 1 initially so we can
+ * look at the first byte of the output and decide whether we have
+ * a 1-byte or 2-byte protocol field.
+ */
+ state->strm.next_in = ibuf + PPP_HDRLEN + DEFLATE_OVHD;
+ state->strm.avail_in = isize - (PPP_HDRLEN + DEFLATE_OVHD);
+ state->strm.next_out = obuf + 3;
+ state->strm.avail_out = 1;
+ decode_proto = 1;
+ overflow = 0;
+
+ /*
+ * Call inflate, supplying more input or output as needed.
+ */
+ for (;;) {
+ r = inflate(&state->strm, Z_PACKET_FLUSH);
+ if (r != Z_OK) {
+ if (state->debug)
+ printk(KERN_DEBUG "z_decompress%d: inflate returned %d (%s)\n",
+ state->unit, r, (state->strm.msg? state->strm.msg: ""));
+ return DECOMP_FATALERROR;
+ }
+ if (state->strm.avail_out != 0)
+ break; /* all done */
+ if (decode_proto) {
+ state->strm.avail_out = osize - PPP_HDRLEN;
+ if ((obuf[3] & 1) == 0) {
+ /* 2-byte protocol field */
+ obuf[2] = obuf[3];
+ --state->strm.next_out;
+ ++state->strm.avail_out;
+ }
+ decode_proto = 0;
+ } else if (!overflow) {
+ /*
+ * We've filled up the output buffer; the only way to
+ * find out whether inflate has any more characters
+ * left is to give it another byte of output space.
+ */
+ state->strm.next_out = overflow_buf;
+ state->strm.avail_out = 1;
+ overflow = 1;
+ } else {
+ if (state->debug)
+ printk(KERN_DEBUG "z_decompress%d: ran out of mru\n",
+ state->unit);
+ return DECOMP_FATALERROR;
+ }
}
- }
- if (decode_proto)
- return DECOMP_ERROR;
+ if (decode_proto)
+ return DECOMP_ERROR;
- olen = osize + overflow - state->strm.avail_out;
- state->stats.unc_bytes += olen;
- state->stats.unc_packets++;
- state->stats.comp_bytes += isize;
- state->stats.comp_packets++;
+ olen = osize + overflow - state->strm.avail_out;
+ state->stats.unc_bytes += olen;
+ state->stats.unc_packets++;
+ state->stats.comp_bytes += isize;
+ state->stats.comp_packets++;
- return olen;
+ return olen;
}
/*
@@ -562,48 +568,46 @@ z_incomp(arg, ibuf, icnt)
unsigned char *ibuf;
int icnt;
{
- struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
- int proto, r;
-
- /*
- * Check that the protocol is one we handle.
- */
- proto = PPP_PROTOCOL(ibuf);
- if (proto > 0x3fff || proto == 0xfd || proto == 0xfb)
- return;
-
- ++state->seqno;
-
- /*
- * Iterate through the message blocks, adding the characters in them
- * to the decompressor's history. For the first block, we start
- * at the either the 1st or 2nd byte of the protocol field,
- * depending on whether the protocol value is compressible.
- */
- state->strm.next_in = ibuf + 3;
- state->strm.avail_in = icnt - 3;
- if (proto > 0xff) {
- --state->strm.next_in;
- ++state->strm.avail_in;
- }
-
- r = inflateIncomp(&state->strm);
- if (r != Z_OK) {
- /* gak! */
- if (state->debug) {
- printk(KERN_DEBUG "z_incomp%d: inflateIncomp returned %d (%s)\n",
- state->unit, r, (state->strm.msg? state->strm.msg: ""));
+ struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
+ int proto, r;
+
+ /*
+ * Check that the protocol is one we handle.
+ */
+ proto = PPP_PROTOCOL(ibuf);
+ if (proto > 0x3fff || proto == 0xfd || proto == 0xfb)
+ return;
+
+ ++state->seqno;
+
+ /*
+ * We start at the either the 1st or 2nd byte of the protocol field,
+ * depending on whether the protocol value is compressible.
+ */
+ state->strm.next_in = ibuf + 3;
+ state->strm.avail_in = icnt - 3;
+ if (proto > 0xff) {
+ --state->strm.next_in;
+ ++state->strm.avail_in;
+ }
+
+ r = inflateIncomp(&state->strm);
+ if (r != Z_OK) {
+ /* gak! */
+ if (state->debug) {
+ printk(KERN_DEBUG "z_incomp%d: inflateIncomp returned %d (%s)\n",
+ state->unit, r, (state->strm.msg? state->strm.msg: ""));
+ }
+ return;
}
- return;
- }
-
- /*
- * Update stats.
- */
- state->stats.inc_bytes += icnt;
- state->stats.inc_packets++;
- state->stats.unc_bytes += icnt;
- state->stats.unc_packets++;
+
+ /*
+ * Update stats.
+ */
+ state->stats.inc_bytes += icnt;
+ state->stats.inc_packets++;
+ state->stats.unc_bytes += icnt;
+ state->stats.unc_packets++;
}
/*************************************************************
@@ -618,20 +622,20 @@ extern void ppp_unregister_compressor (struct compressor *cp);
* Procedures exported to if_ppp.c.
*/
struct compressor ppp_deflate = {
- CI_DEFLATE, /* compress_proto */
- z_comp_alloc, /* comp_alloc */
- z_comp_free, /* comp_free */
- z_comp_init, /* comp_init */
- z_comp_reset, /* comp_reset */
- z_compress, /* compress */
- z_comp_stats, /* comp_stat */
- z_decomp_alloc, /* decomp_alloc */
- z_decomp_free, /* decomp_free */
- z_decomp_init, /* decomp_init */
- z_decomp_reset, /* decomp_reset */
- z_decompress, /* decompress */
- z_incomp, /* incomp */
- z_comp_stats, /* decomp_stat */
+ CI_DEFLATE, /* compress_proto */
+ z_comp_alloc, /* comp_alloc */
+ z_comp_free, /* comp_free */
+ z_comp_init, /* comp_init */
+ z_comp_reset, /* comp_reset */
+ z_compress, /* compress */
+ z_comp_stats, /* comp_stat */
+ z_decomp_alloc, /* decomp_alloc */
+ z_decomp_free, /* decomp_free */
+ z_decomp_init, /* decomp_init */
+ z_decomp_reset, /* decomp_reset */
+ z_decompress, /* decompress */
+ z_incomp, /* incomp */
+ z_comp_stats, /* decomp_stat */
};
#ifdef MODULE