diff --git a/lfd_lzo.c b/lfd_lzo.c new file mode 100644 index 0000000..e5ae613 --- /dev/null +++ b/lfd_lzo.c @@ -0,0 +1,159 @@ +/* + VTun - Virtual Tunnel over TCP/IP network. + + Copyright (C) 1998-2000 Maxim Krasnyansky + + VTun has been derived from VPPP package by Maxim Krasnyansky. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + */ + +/* + * lfd_lzo.c,v 1.1.1.2.2.7.2.1 2006/11/16 04:03:00 mtbishop Exp + */ + +/* LZO compression module */ + +#include "config.h" + +#include +#include +#include +#include + +#include "vtun.h" +#include "linkfd.h" +#include "lib.h" + +#ifdef HAVE_LZO + +#include "lzo1x.h" +#include "lzoutil.h" + +static lzo_byte *zbuf; +static lzo_voidp wmem; +static int zbuf_size = VTUN_FRAME_SIZE * VTUN_FRAME_SIZE / 64 + 16 + 3; + +/* Pointer to compress function */ +int (*lzo1x_compress)(const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem); +/* + * Initialize compressor/decompressor. + * Allocate the buffers. + */ + +int alloc_lzo(struct vtun_host *host) +{ + int zlevel = host->zlevel ? host->zlevel : 1; + int mem; + + switch( zlevel ){ + case 9: + lzo1x_compress = lzo1x_999_compress; + mem = LZO1X_999_MEM_COMPRESS; + break; + default: + lzo1x_compress = lzo1x_1_15_compress; + mem = LZO1X_1_15_MEM_COMPRESS; + break; + } + + if( lzo_init() != LZO_E_OK ){ + vtun_syslog(LOG_ERR,"Can't initialize compressor"); + return 1; + } + if( !(zbuf = lfd_alloc(zbuf_size)) ){ + vtun_syslog(LOG_ERR,"Can't allocate buffer for the compressor"); + return 1; + } + if( !(wmem = lzo_malloc(mem)) ){ + vtun_syslog(LOG_ERR,"Can't allocate buffer for the compressor"); + return 1; + } + + vtun_syslog(LOG_INFO, "LZO compression[level %d] initialized", zlevel); + + return 0; +} + +/* + * Deinitialize compressor/decompressor. + * Free the buffer. + */ + +int free_lzo() +{ + lfd_free(zbuf); zbuf = NULL; + lzo_free(wmem); wmem = NULL; + return 0; +} + +/* + * This functions _MUST_ consume all incoming bytes in one pass, + * that's why we expand buffer dynamicly. + */ +int comp_lzo(int len, char *in, char **out) +{ + unsigned int zlen = 0; + int err; + + if( (err=lzo1x_compress((void *)in,len,zbuf,&zlen,wmem)) != LZO_E_OK ){ + vtun_syslog(LOG_ERR,"Compress error %d",err); + return -1; + } + + *out = (void *)zbuf; + return zlen; +} + +int decomp_lzo(int len, char *in, char **out) +{ + unsigned int zlen = 0; + int err; + + if( (err=lzo1x_decompress((void *)in,len,zbuf,&zlen,wmem)) != LZO_E_OK ){ + vtun_syslog(LOG_ERR,"Decompress error %d",err); + return -1; + } + + *out = (void *) zbuf; + return zlen; +} + +struct lfd_mod lfd_lzo = { + "LZO", + alloc_lzo, + comp_lzo, + NULL, + decomp_lzo, + NULL, + free_lzo, + NULL, + NULL +}; + +#else /* HAVE_LZO */ + +int no_lzo(struct vtun_host *host) +{ + vtun_syslog(LOG_INFO, "LZO compression is not supported"); + return -1; +} + +struct lfd_mod lfd_lzo = { + "LZO", + no_lzo, NULL, NULL, NULL, NULL, NULL, NULL, NULL +}; + +#endif /* HAVE_LZO */ + + diff --git a/packages/vtun.bsd.pkg b/packages/vtun.bsd.pkg index 8b65147..66465a3 100644 --- a/packages/vtun.bsd.pkg +++ b/packages/vtun.bsd.pkg @@ -1,4 +1,4 @@ -@name vtun-3.0.0 +@name vtun-3.0.1 @owner root @group wheel diff --git a/packages/vtun.solaris.info b/packages/vtun.solaris.info index 68a4a32..52fd00e 100644 --- a/packages/vtun.solaris.info +++ b/packages/vtun.solaris.info @@ -1,10 +1,10 @@ PKG="vtun" NAME="VTun - Virtual tunnels over TCP/IP" -VERSION="3.0.0" +VERSION="3.0.1" ARCH="i386" VENDOR="Bishop Clark" EMAIL="bishop@platypus.bc.ca" CATEGORY="system" CLASSES="none" -PSTAMP="20061211" +PSTAMP="20070606" BASEDIR="/usr/local/" diff --git a/packages/vtun.spec b/packages/vtun.spec index 90e8f8c..bbca051 100644 --- a/packages/vtun.spec +++ b/packages/vtun.spec @@ -1,16 +1,20 @@ -# $Id: vtun.spec,v 1.24.2.2 2006/12/11 14:09:34 mtbishop Exp $ +# $Id: vtun.spec,v 1.24.2.3 2007/06/06 08:48:19 mtbishop Exp $ # By default, builds without socks-support. # To build with socks-support, issue: # rpm --define "_with_socks yes" ... -# By default, builds with LZO support (available for any RPM system) +# By default, builds with LZO 1 support (available for any RPM system) # To disable LZO, issue: # rpm --define "_without_lzo yes" ... +# +# Enabling LZO2 only fixes the RPM builddeps, so far; configure still +# exercises some license. +# rpm --with lzo2 # define variables here for older RPM versions. %define name vtun -%define version 3.0.0 +%define version 3.0.1 %define release 1 # expansion of the previous part. @@ -55,22 +59,27 @@ BuildRequires: %{_bindir}/gcc # please check the FAQ for this question, and mail Bishop if there is # no FAQ entry. -%define _buildreq_ zlib-devel %{!?_without_ssl:openssl-devel >= 0.9.7} %{!?_without_lzo: lzo-devel} +%define _buildreq_ zlib-devel %{!?_without_ssl:openssl-devel >= 0.9.7} %{?_with_lzo2:lzo2-devel} %{!?_with_lzo2:%{!?_without_lzo: lzo-devel}} %define _requires_ tun # Caldera has funny zlib -%define _buildreq_ol libz-devel %{!?_without_ssl:openssl-devel >= 0.9.7} %{!?_without_lzo:lzo-devel} +%define _buildreq_ol libz-devel %{!?_without_ssl:openssl-devel >= 0.9.7} %{?_with_lzo2:lzo2-devel} %{!?_with_lzo2:%{!?_without_lzo: lzo-devel}} # Mandrake has unpredictable devel package names -%define _buildreq_mdk zlib1-devel %{!?_without_ssl:libopenssl0-devel >= 0.9.7} %{!?_without_lzo: liblzo1-devel} +%define _buildreq_mdk zlib1-devel %{!?_without_ssl:libopenssl0-devel >= 0.9.7} %{?_with_lzo2:liblzo2-devel} %{!?_with_lzo2:%{!?_without_lzo: liblzo1-devel}} # normally, NOT depending on the tun package encourages other apps to # clobber the modules.conf file. In this case, the reverse is true, # since FCx actually includes all the necessary entries. So no tun. # We avoid a %null value by stating one redundantly. %define _requires_fc zlib -%define _buildreq_fc zlib-devel %{!?_without_ssl:openssl-devel} %{!?_without_lzo: lzo-devel} -%define _requires_rhel4 %_requires_fc -%define _buildreq_rhel4 %_buildreq_fc +%define _buildreq_fc zlib-devel %{!?_without_ssl:openssl-devel} %{?_with_lzo2:lzo2-devel} %{!?_with_lzo2:%{!?_without_lzo: lzo-devel}} +%define _requires_rhel %_requires_fc +%define _buildreq_rhel %_buildreq_fc + +# SuSE doesn't permit lzo and lzo2 to be installed simultaneously so +# we do not need to care so much. +%define _buildreq_suse zlib-devel %{!?_without_ssl:openssl-devel >= 0.9.7} %{!?_without_lzo: lzo-devel} +%define _requires_suse zlib %{!?_without_lzo: lzo} Requires: %{_requires} BuildRequires: %{_buildreq} @@ -175,16 +184,19 @@ sbin/insserv etc/init.d/vtund %attr(755,root,root) %dir %{log_dir} %attr(755,root,root) %dir %{lock_dir} %{_mandir}/man8/vtund.8* -#%{_mandir}/man8/vtun.8* %{_mandir}/man5/vtund.conf.5* /etc/xinetd.d/vtun %if "%_dis" == "suse" +%{_mandir}/man8/vtun.8* %attr(755,root,root) %{_sbindir}/rcvtund /var/adm/fillup-templates/rc.config.vtund %endif #date +"%a %b %d %Y" %changelog +* Tue Mar 27 2007 Bishop Clark (LC957) 3.0.1-1 +- new code drop (more LZO2 work) + * Mon Dec 11 2006 Bishop Clark (LC957) 3.0.0-1 - new code drop - s/Copyright/License/, deprecated parameter.