summaryrefslogtreecommitdiff
path: root/net/pppd/patches/patch-bg
blob: b4b00b376267de99751f970e377fa179b56705cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
$NetBSD: patch-bg,v 1.1.1.1 2005/01/02 02:51:44 cube Exp $

--- pppdump/deflate.c.orig	2004-02-02 04:36:46.000000000 +0100
+++ pppdump/deflate.c
@@ -41,9 +41,16 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
+#include "pppdump.h"
+#ifdef __NetBSD__
+#include <net/ppp_defs.h>
+#include <net/ppp-comp.h>
+#include <zlib.h>
+#else
 #include "ppp_defs.h"
 #include "ppp-comp.h"
 #include "zlib.h"
+#endif
 
 #if DO_DEFLATE
 
@@ -71,9 +78,8 @@ static void	*z_decomp_alloc __P((u_char 
 static void	z_decomp_free __P((void *state));
 static int	z_decomp_init __P((void *state, u_char *options, int opt_len,
 				     int unit, int hdrlen, int mru, int debug));
-static void	z_incomp __P((void *state, u_char *dmsg, int len));
-static int	z_decompress __P((void *state, u_char *cmp, int inlen,
-				    u_char *dmp, int *outlenp));
+static void	z_incomp __P((void *state, PACKETPTR mi));
+static int	z_decompress __P((void *state, PACKETPTR mi, PACKETPTR *mo));
 static void	z_decomp_reset __P((void *state));
 static void	z_comp_stats __P((void *state, struct compstat *stats));
 
@@ -82,6 +88,12 @@ static void	z_comp_stats __P((void *stat
  */
 struct compressor ppp_deflate = {
     CI_DEFLATE,			/* compress_proto */
+    NULL,			/* comp_alloc */
+    NULL,			/* comp_free */
+    NULL,			/* comp_init */
+    NULL,			/* comp_reset */
+    NULL,			/* comp_compress */
+    NULL,			/* comp_stat */
     z_decomp_alloc,		/* decomp_alloc */
     z_decomp_free,		/* decomp_free */
     z_decomp_init,		/* decomp_init */
@@ -230,17 +242,17 @@ z_decomp_reset(arg)
  * compression, even though they are detected by inspecting the input.
  */
 static int
-z_decompress(arg, mi, inlen, mo, outlenp)
+z_decompress(arg, mi, mo)
     void *arg;
-    u_char *mi, *mo;
-    int inlen, *outlenp;
+    PACKETPTR mi;
+    PACKETPTR *mo;
 {
     struct deflate_state *state = (struct deflate_state *) arg;
     u_char *rptr, *wptr;
-    int rlen, olen, ospace;
-    int seq, i, flush, r, decode_proto;
+    int rlen, olen;
+    int seq, r;
 
-    rptr = mi;
+    rptr = mi->buf;
     if (*rptr == 0)
 	++rptr;
     ++rptr;
@@ -261,9 +273,9 @@ z_decompress(arg, mi, inlen, mo, outlenp
     /*
      * Set up to call inflate.
      */
-    wptr = mo;
+    wptr = (*mo)->buf;
     state->strm.next_in = rptr;
-    state->strm.avail_in = mi + inlen - rptr;
+    state->strm.avail_in = mi->buf + mi->len - rptr;
     rlen = state->strm.avail_in + PPP_HDRLEN + DEFLATE_OVHD;
     state->strm.next_out = wptr;
     state->strm.avail_out = state->mru + 2;
@@ -278,7 +290,7 @@ z_decompress(arg, mi, inlen, mo, outlenp
 	return DECOMP_FATALERROR;
     }
     olen = state->mru + 2 - state->strm.avail_out;
-    *outlenp = olen;
+    (*mo)->len = olen;
 
     if ((wptr[0] & 1) != 0)
 	++olen;			/* for suppressed protocol high byte */
@@ -302,10 +314,9 @@ z_decompress(arg, mi, inlen, mo, outlenp
  * Incompressible data has arrived - add it to the history.
  */
 static void
-z_incomp(arg, mi, mlen)
+z_incomp(arg, mi)
     void *arg;
-    u_char *mi;
-    int mlen;
+    PACKETPTR mi;
 {
     struct deflate_state *state = (struct deflate_state *) arg;
     u_char *rptr;
@@ -314,7 +325,7 @@ z_incomp(arg, mi, mlen)
     /*
      * Check that the protocol is one we handle.
      */
-    rptr = mi;
+    rptr = mi->buf;
     proto = rptr[0];
     if ((proto & 1) == 0)
 	proto = (proto << 8) + rptr[1];
@@ -325,7 +336,7 @@ z_incomp(arg, mi, mlen)
 
     if (rptr[0] == 0)
 	++rptr;
-    rlen = mi + mlen - rptr;
+    rlen = mi->buf + mi->len - rptr;
     state->strm.next_in = rptr;
     state->strm.avail_in = rlen;
     r = inflateIncomp(&state->strm);