vjcomp.c (32439) | vjcomp.c (32663) |
---|---|
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 * | 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.14 1997/12/03 10:23:54 brian Exp $ | 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" | 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 "defs.h" | |
36#include "timer.h" 37#include "fsm.h" 38#include "lcpproto.h" 39#include "slcompress.h" 40#include "hdlc.h" 41#include "ipcp.h" 42#include "vjcomp.h" 43 44#define MAX_VJHEADER 16 /* Maximum size of compressed header */ 45 | 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 |
46struct slcompress cslc; | 45static struct slcompress cslc; |
47 48void 49VjInit(int max_state) 50{ 51 sl_compress_init(&cslc, max_state); 52} 53 54void --- 43 unchanged lines hidden (view full) --- 98 /* 99 * Uncompressed packet does NOT change its size, so that we can use mbuf 100 * space for uncompression job. 101 */ 102 bufp = MBUF_CTOP(bp); 103 len = sl_uncompress_tcp(&bufp, len, type, &cslc); 104 if (len <= 0) { 105 pfree(bp); | 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); |
106 bp = NULLBUFF; | 105 bp = NULL; |
107 } 108 return (bp); 109 } 110 111 /* 112 * Handle compressed packet. 1) Read upto MAX_VJHEADER bytes into work 113 * space. 2) Try to uncompress it. 3) Compute amount of necesary space. 4) 114 * Copy unread data info there. 115 */ 116 if (len > MAX_VJHEADER) 117 len = MAX_VJHEADER; 118 rlen = len; 119 bufp = work + MAX_HDR; 120 bp = mbread(bp, bufp, rlen); 121 len = sl_uncompress_tcp(&bufp, olen, type, &cslc); 122 if (len <= 0) { 123 pfree(bp); | 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); |
124 return NULLBUFF; | 123 return NULL; |
125 } 126 len -= olen; 127 len += rlen; 128 nbp = mballoc(len, MB_VJCOMP); 129 memcpy(MBUF_CTOP(nbp), bufp, len); 130 nbp->next = bp; 131 return (nbp); 132} --- 33 unchanged lines hidden --- | 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 --- |