Deleted Added
full compact
deflate.c (46686) deflate.c (47695)
1/*-
2 * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: deflate.c,v 1.12 1999/03/11 01:49:15 brian Exp $
26 * $Id: deflate.c,v 1.13 1999/05/08 11:06:25 brian Exp $
27 */
28
29#include <sys/types.h>
30
31#include <stdio.h>
32#include <stdlib.h>
33#include <termios.h>
34#include <zlib.h>

--- 42 unchanged lines hidden (view full) ---

77 int olen, ilen, len, res, flush;
78 struct mbuf *mo_head, *mo, *mi_head, *mi;
79
80 ilen = mbuf_Length(mp);
81 log_Printf(LogDEBUG, "DeflateOutput: Proto %02x (%d bytes)\n", *proto, ilen);
82 log_DumpBp(LogDEBUG, "DeflateOutput: Compress packet:", mp);
83
84 /* Stuff the protocol in front of the input */
27 */
28
29#include <sys/types.h>
30
31#include <stdio.h>
32#include <stdlib.h>
33#include <termios.h>
34#include <zlib.h>

--- 42 unchanged lines hidden (view full) ---

77 int olen, ilen, len, res, flush;
78 struct mbuf *mo_head, *mo, *mi_head, *mi;
79
80 ilen = mbuf_Length(mp);
81 log_Printf(LogDEBUG, "DeflateOutput: Proto %02x (%d bytes)\n", *proto, ilen);
82 log_DumpBp(LogDEBUG, "DeflateOutput: Compress packet:", mp);
83
84 /* Stuff the protocol in front of the input */
85 mi_head = mi = mbuf_Alloc(2, MB_HDLCOUT);
85 mi_head = mi = mbuf_Alloc(2, MB_CCPOUT);
86 mi->next = mp;
87 rp = MBUF_CTOP(mi);
88 if (*proto < 0x100) { /* Compress the protocol */
89 rp[0] = *proto & 0377;
90 mi->cnt = 1;
91 } else { /* Don't compress the protocol */
92 rp[0] = *proto >> 8;
93 rp[1] = *proto & 0377;
94 mi->cnt = 2;
95 }
96
97 /* Allocate the initial output mbuf */
86 mi->next = mp;
87 rp = MBUF_CTOP(mi);
88 if (*proto < 0x100) { /* Compress the protocol */
89 rp[0] = *proto & 0377;
90 mi->cnt = 1;
91 } else { /* Don't compress the protocol */
92 rp[0] = *proto >> 8;
93 rp[1] = *proto & 0377;
94 mi->cnt = 2;
95 }
96
97 /* Allocate the initial output mbuf */
98 mo_head = mo = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_HDLCOUT);
98 mo_head = mo = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_CCPOUT);
99 mo->cnt = 2;
100 wp = MBUF_CTOP(mo);
101 *wp++ = state->seqno >> 8;
102 *wp++ = state->seqno & 0377;
103 log_Printf(LogDEBUG, "DeflateOutput: Seq %d\n", state->seqno);
104 state->seqno++;
105
106 /* Set up the deflation context */

--- 23 unchanged lines hidden (view full) ---

130 mi = mi->next;
131 state->cx.next_in = MBUF_CTOP(mi);
132 state->cx.avail_in = mi->cnt;
133 if (mi->next == NULL)
134 flush = Z_SYNC_FLUSH;
135 }
136
137 if (state->cx.avail_out == 0) {
99 mo->cnt = 2;
100 wp = MBUF_CTOP(mo);
101 *wp++ = state->seqno >> 8;
102 *wp++ = state->seqno & 0377;
103 log_Printf(LogDEBUG, "DeflateOutput: Seq %d\n", state->seqno);
104 state->seqno++;
105
106 /* Set up the deflation context */

--- 23 unchanged lines hidden (view full) ---

130 mi = mi->next;
131 state->cx.next_in = MBUF_CTOP(mi);
132 state->cx.avail_in = mi->cnt;
133 if (mi->next == NULL)
134 flush = Z_SYNC_FLUSH;
135 }
136
137 if (state->cx.avail_out == 0) {
138 mo->next = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_HDLCOUT);
138 mo->next = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_CCPOUT);
139 olen += (mo->cnt = DEFLATE_CHUNK_LEN);
140 mo = mo->next;
141 mo->cnt = 0;
142 state->cx.next_out = MBUF_CTOP(mo);
143 state->cx.avail_out = DEFLATE_CHUNK_LEN;
144 }
145 }
146

--- 82 unchanged lines hidden (view full) ---

229 ccp_SendResetReq(&ccp->fsm);
230 return NULL;
231 }
232 }
233 state->seqno++;
234 state->uncomp_rec = 0;
235
236 /* Allocate an output mbuf */
139 olen += (mo->cnt = DEFLATE_CHUNK_LEN);
140 mo = mo->next;
141 mo->cnt = 0;
142 state->cx.next_out = MBUF_CTOP(mo);
143 state->cx.avail_out = DEFLATE_CHUNK_LEN;
144 }
145 }
146

--- 82 unchanged lines hidden (view full) ---

229 ccp_SendResetReq(&ccp->fsm);
230 return NULL;
231 }
232 }
233 state->seqno++;
234 state->uncomp_rec = 0;
235
236 /* Allocate an output mbuf */
237 mo_head = mo = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_IPIN);
237 mo_head = mo = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_CCPIN);
238
239 /* Our proto starts with 0 if it's compressed */
240 wp = MBUF_CTOP(mo);
241 wp[0] = '\0';
242
243 /*
244 * We set avail_out to 1 initially so we can look at the first
245 * byte of the output and decide whether we have a compressed

--- 40 unchanged lines hidden (view full) ---

286 wp[0] = wp[1];
287 state->cx.next_out--;
288 state->cx.avail_out = DEFLATE_CHUNK_LEN-1;
289 } else
290 state->cx.avail_out = DEFLATE_CHUNK_LEN-2;
291 first = 0;
292 } else {
293 olen += (mo->cnt = DEFLATE_CHUNK_LEN);
238
239 /* Our proto starts with 0 if it's compressed */
240 wp = MBUF_CTOP(mo);
241 wp[0] = '\0';
242
243 /*
244 * We set avail_out to 1 initially so we can look at the first
245 * byte of the output and decide whether we have a compressed

--- 40 unchanged lines hidden (view full) ---

286 wp[0] = wp[1];
287 state->cx.next_out--;
288 state->cx.avail_out = DEFLATE_CHUNK_LEN-1;
289 } else
290 state->cx.avail_out = DEFLATE_CHUNK_LEN-2;
291 first = 0;
292 } else {
293 olen += (mo->cnt = DEFLATE_CHUNK_LEN);
294 mo->next = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_IPIN);
294 mo->next = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_CCPIN);
295 mo = mo->next;
296 state->cx.next_out = MBUF_CTOP(mo);
297 state->cx.avail_out = DEFLATE_CHUNK_LEN;
298 }
299 }
300 }
301
302 if (mi != NULL)

--- 42 unchanged lines hidden (view full) ---

345 short len;
346
347 log_Printf(LogDEBUG, "DeflateDictSetup: Got seq %d\n", state->seqno);
348
349 /*
350 * Stuff an ``uncompressed data'' block header followed by the
351 * protocol in front of the input
352 */
295 mo = mo->next;
296 state->cx.next_out = MBUF_CTOP(mo);
297 state->cx.avail_out = DEFLATE_CHUNK_LEN;
298 }
299 }
300 }
301
302 if (mi != NULL)

--- 42 unchanged lines hidden (view full) ---

345 short len;
346
347 log_Printf(LogDEBUG, "DeflateDictSetup: Got seq %d\n", state->seqno);
348
349 /*
350 * Stuff an ``uncompressed data'' block header followed by the
351 * protocol in front of the input
352 */
353 mi_head = mbuf_Alloc(7, MB_HDLCOUT);
353 mi_head = mbuf_Alloc(7, MB_CCPOUT);
354 mi_head->next = mi;
355 len = mbuf_Length(mi);
356 mi = mi_head;
357 rp = MBUF_CTOP(mi);
358 if (proto < 0x100) { /* Compress the protocol */
359 rp[5] = proto & 0377;
360 mi->cnt = 6;
361 len++;

--- 233 unchanged lines hidden ---
354 mi_head->next = mi;
355 len = mbuf_Length(mi);
356 mi = mi_head;
357 rp = MBUF_CTOP(mi);
358 if (proto < 0x100) { /* Compress the protocol */
359 rp[5] = proto & 0377;
360 mi->cnt = 6;
361 len++;

--- 233 unchanged lines hidden ---