Deleted Added
sdiff udiff text old ( 32439 ) new ( 32663 )
full compact
1/*
2 * Input/Output VJ Compressed packets
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * $Id: vjcomp.c,v 1.15 1998/01/11 17:50:46 brian Exp $
21 *
22 * TODO:
23 */
24#include <sys/types.h>
25#include <netinet/in.h>
26#include <netinet/in_systm.h>
27#include <netinet/ip.h>
28
29#include <stdio.h>
30#include <string.h>
31
32#include "command.h"
33#include "mbuf.h"
34#include "log.h"
35#include "timer.h"
36#include "fsm.h"
37#include "lcpproto.h"
38#include "slcompress.h"
39#include "hdlc.h"
40#include "ipcp.h"
41#include "vjcomp.h"
42
43#define MAX_VJHEADER 16 /* Maximum size of compressed header */
44
45static struct slcompress cslc;
46
47void
48VjInit(int max_state)
49{
50 sl_compress_init(&cslc, max_state);
51}
52
53void

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

97 /*
98 * Uncompressed packet does NOT change its size, so that we can use mbuf
99 * space for uncompression job.
100 */
101 bufp = MBUF_CTOP(bp);
102 len = sl_uncompress_tcp(&bufp, len, type, &cslc);
103 if (len <= 0) {
104 pfree(bp);
105 bp = NULL;
106 }
107 return (bp);
108 }
109
110 /*
111 * Handle compressed packet. 1) Read upto MAX_VJHEADER bytes into work
112 * space. 2) Try to uncompress it. 3) Compute amount of necesary space. 4)
113 * Copy unread data info there.
114 */
115 if (len > MAX_VJHEADER)
116 len = MAX_VJHEADER;
117 rlen = len;
118 bufp = work + MAX_HDR;
119 bp = mbread(bp, bufp, rlen);
120 len = sl_uncompress_tcp(&bufp, olen, type, &cslc);
121 if (len <= 0) {
122 pfree(bp);
123 return NULL;
124 }
125 len -= olen;
126 len += rlen;
127 nbp = mballoc(len, MB_VJCOMP);
128 memcpy(MBUF_CTOP(nbp), bufp, len);
129 nbp->next = bp;
130 return (nbp);
131}

--- 33 unchanged lines hidden ---