vtun-3.0.4/0000755003736300373630000000000012774030165012073 5ustar bishopbishopvtun-3.0.4/packages/0000755003736300373630000000000012774030165013651 5ustar bishopbishopvtun-3.0.4/packages/vtun.bsd.pkg0000644003736300373630000000115212767320456016125 0ustar bishopbishop@name vtun-3.0.4 @owner root @group wheel @cwd /usr/local @mode 644 man/man8/vtun.8 man/man8/vtund.8 man/man5/vtund.conf.5 @exec if [ -f %D/etc/vtund.conf ]; then echo "Saving vtund.conf to vtund.conf.backup";cp %D/etc/vtund.conf %D/etc/vtund.conf.backup; fi @exec install -c -d -m 755 -o root -g 0 %D/var/run @exec install -c -d -m 755 -o root -g 0 %D/var/log/vtund @exec install -c -d -m 755 -o root -g 0 %D/var/lock/vtund @unexec [ ! -f %D/etc/vtund.conf.backup ] && echo "Saving vtund.conf to vtund.conf.backup"; cp %D/etc/vtund.conf %D/etc/vtund.conf.backup; @mode 600 etc/vtund.conf @mode 755 sbin/vtund vtun-3.0.4/packages/vtun.desc0000644003736300373630000000102110537207332015474 0ustar bishopbishopVTun - Virtual Tunnels over TCP/IP. VTun provides a method for creating Virtual Tunnels over TCP/IP networks and allows one to shape, compress, encrypt traffic in those tunnels. Supported types of tunnels are: PPP, IP, Ethernet and most other serial protocols and programs. VTun is easily and highly configurable: it can be used for various network tasks like VPN, Mobile IP, Shaped Internet access, IP address saving, etc. It is completely a user space implementation and does not require modification to any kernel parts. vtun-3.0.4/packages/vtun.solaris.info0000644003736300373630000000031612767320462017201 0ustar bishopbishopPKG="vtun" NAME="VTun - Virtual tunnels over TCP/IP" VERSION="3.0.4" ARCH="i386" VENDOR="Bishop Clark" EMAIL="bishop@platypus.bc.ca" CATEGORY="system" CLASSES="none" PSTAMP="20160917" BASEDIR="/usr/local/" vtun-3.0.4/packages/vtun.solaris.pkg0000644003736300373630000000077107116565456017042 0ustar bishopbishop# !BASEDIR=/usr/local # i pkginfo=vtun.solaris.info i version=vtun.desc # !search $BASEDIR !default 755 root root d none sbin d none var d none var/run d none var/log/vtund d none var/lock/vtund d none man d none man/man8 d none man/man5 d none etc !search $BASEDIR/sbin $BASEDIR/etc $BASEDIR/man/man8 $BASEDIR/man/man5 !default 644 root root f none man/man8/vtund.8 f none man/man5/vtund.conf.5 s none man/man8/vtun.8=vtund.8 f none etc/vtund.conf 0600 root root f none sbin/vtund 0755 root root vtun-3.0.4/packages/vtun.spec0000644003736300373630000002514012767320466015533 0ustar bishopbishop# $Id: vtun.spec,v 1.24.2.11 2016/09/17 20:01:58 mtbishop Exp $ # By default, builds without socks-support. # To build with socks-support, issue: # rpm --define "_with_socks yes" ... # 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.4 %define release 1 # expansion of the previous part. # get the distro mark (eg rh70) %define _dis %(rpm -qf /etc/issue 2>/dev/null|sed 's/-release.*//;s/redhat/rh/;s/mandrake/mdk/;s/fedora/fc/;s/openlinux/ol/;s/whitebox/wb/') %define _tro %(rpm -qf --qf "%%{version}" /etc/issue | sed 's/\\.//g' ) %define rc_dir_suse /etc/init.d %define lock_dir_suse /var/lock/subsys/vtunnel %define log_dir_suse /var/log/vtunnel # now apply the components # If anyone can find system that strangers understand, that still # enables one SRPM to build for 17 distros, I'm open to suggestions. %define _requires %{expand:%%{?_requires_%{_dis}%{_tro}:%%_requires_%{_dis}%{_tro}}%%{!?_requires_%{_dis}%{_tro}:%%{?_requires_%{_dis}:%%_requires_%{_dis}}%%{!?_requires_%{_dis}:%{_requires_}}}} %define _buildreq %{expand:%%{?_buildreq_%{_dis}%{_tro}:%%_buildreq_%{_dis}%{_tro}}%%{!?_buildreq_%{_dis}%{_tro}:%%{?_buildreq_%{_dis}:%%_buildreq_%{_dis}}%%{!?_buildreq_%{_dis}:%{_buildreq_}}}} %define rc_dir %{expand:%%{?rc_dir_%{_dis}%{_tro}:%%rc_dir_%{_dis}%{_tro}}%%{!?rc_dir_%{_dis}%{_tro}:%%{?rc_dir_%{_dis}:%%rc_dir_%{_dis}}%%{!?rc_dir_%{_dis}:/etc/rc.d/init.d}}} %define lock_dir %{expand:%%{?lock_dir_%{_dis}%{_tro}:%%lock_dir_%{_dis}%{_tro}}%%{!?lock_dir_%{_dis}%{_tro}:%%{?lock_dir_%{_dis}:%%lock_dir_%{_dis}}%%{!?lock_dir_%{_dis}:/var/lock/vtund}}} %define log_dir %{expand:%%{?log_dir_%{_dis}%{_tro}:%%log_dir_%{_dis}%{_tro}}%%{!?log_dir_%{_dis}%{_tro}:%%{?log_dir_%{_dis}:%%log_dir_%{_dis}}%%{!?log_dir_%{_dis}:/var/log/vtund}}} Name: %{name} Version: %{version} Release: %{release} License: GPL2 Group: System Environment/Daemons Url: http://vtun.sourceforge.net/ Source0: http://prdownloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz Summary: Virtual tunnel over TCP/IP networks. Summary(pl): Wirtualne tunele poprzez sieci TCP/IP Vendor: Maxim Krasnyansky Packager: Bishop Clark (LC957) # Remember this is ignored for recent distros (Backward Compatibility is dumb) BuildRoot: %{?_tmppath:%{_tmppath}}%{!?_tmppath:%{tmpdir}}/%{name}-%{version}-root-%(id -u -n) Obsoletes: vppp BuildRequires: autoconf BuildRequires: bison BuildRequires: flex BuildRequires: autoconf BuildRequires: automake Requires: xinetd # must specify like so to get the right package for gcc (eg ecgs) 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} %{?_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} %{?_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} %{?_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} %{?_with_lzo2:lzo2-devel} %{!?_with_lzo2:%{!?_without_lzo: lzo-devel}} %define _requires_rhel %_requires_fc %define _buildreq_rhel %_buildreq_fc %define _requires_centos %_requires_fc %define _buildreq_centos %_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} %description VTun provides a method for creating Virtual Tunnels over TCP/IP networks and allows one to shape, compress, encrypt traffic in those tunnels. Supported types of tunnels are: PPP, IP, Ethernet and most other serial protocols and programs. VTun is easily and highly configurable: it can be used for various network tasks like VPN, Mobile IP, Shaped Internet access, IP address saving, etc. It is completely a user space implementation and does not require modification to any kernel parts. This package is built with%{!?_with_socks:out} SOCKS-support. %{?_without_lzo:This package is built without LZO support.} %{?_without_ssl:This package is built without OpenSSL support. The VTun} %{?_without_ssl:Development Team does not support a no-SSL configuration.} %description -l pl VTun umożliwia tworzenie Wirtualnych Tunelu poprzez sieci TCP/IP wraz z przydzielaniem pasma, kompresją, szyfrowaniem danych w tunelach. Wspierane typy tuneli to: PPP, IP, Ethernet i większość pozostałych protokołów szeregowych. %prep %setup -n %{name}-%{version} %{__aclocal} %{__autoconf} %configure \ --prefix=%{_exec_prefix} \ --sysconfdir=/etc \ --localstatedir=%{_var} \ %{?_without_ssl: --disable-ssl} \ %{?_without_lzo: --disable-lzo} \ %{?_with_socks: --enable-socks} %build %if "%_dis" == "suse" %{__make} LOCK_DIR=%{lock_dir} STAT_DIR=/var/log/vtunnel %else %{__make} %{?_smp_mflags} %endif %install [ $RPM_BUILD_ROOT != / ] && rm -rf $RPM_BUILD_ROOT %__install -d $RPM_BUILD_ROOT%{rc_dir} %if "%_dis" == "suse" install scripts/vtund.rc.suse $RPM_BUILD_ROOT%{rc_dir}/vtund %else install scripts/vtund.rc.red_hat $RPM_BUILD_ROOT%{rc_dir}/vtund %endif make install SBIN_DIR=$RPM_BUILD_ROOT%{_sbindir} \ MAN_DIR=$RPM_BUILD_ROOT%{_mandir} \ ETC_DIR=$RPM_BUILD_ROOT/etc \ VAR_DIR=$RPM_BUILD_ROOT%{_var} \ LOCK_DIR=$RPM_BUILD_ROOT%{lock_dir} \ INSTALL_OWNER= %__install -d $RPM_BUILD_ROOT/etc/xinetd.d %__sed 's:/usr/local:%{_prefix}:' scripts/vtund.xinetd \ > $RPM_BUILD_ROOT/etc/xinetd.d/vtun %if "%_dis" == "suse" # SuSE RC.CONFIG templates install -d $RPM_BUILD_ROOT/var/adm/fillup-templates install -m 644 scripts/vtund.rc.suse.config $RPM_BUILD_ROOT/var/adm/fillup-templates/rc.config.vtund # rcvtund ln -sf ../..%{rc_dir}/vtund $RPM_BUILD_ROOT/usr/sbin/rcvtund %endif %post %if "%_dis" == "suse" #rc config echo "Updating etc/rc.config..." if [ -x bin/fillup ] ; then bin/fillup -q -d = etc/rc.config var/adm/fillup-templates/rc.config.vtund else echo "ERROR: fillup not found. This should not happen. Please compare" echo "etc/rc.config and var/adm/fillup-templates/rc.config.vtund and" echo "update by hand." fi sbin/insserv etc/init.d/vtund %endif %clean [ $RPM_BUILD_ROOT != / ] && rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %doc ChangeLog Credits FAQ README README.LZO README.Setup README.Shaper TODO vtund.conf %doc TODO vtund.conf %config(noreplace) %{_sysconfdir}/vtund.conf %config(noreplace) %{_sysconfdir}/xinetd.d/vtun %config %{rc_dir}/vtund %{_sbindir}/vtund %attr(755,root,root) %dir %{log_dir} %attr(755,root,root) %dir %{lock_dir} %{_mandir}/man5/vtund.conf.5* %{_mandir}/man8/vtun.8* %{_mandir}/man8/vtund.8* %if "%_dis" == "suse" %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. * Wed Feb 23 2005 Bishop Clark (LC957) 2.9.91-4 - added XOS macros. - s/rhas4/rhel4/ in hopes, although I haven't seen it yet. * Thu Oct 07 2004 Bishop Clark (LC957) 2.9.91-3 - macros support --with/out conditional command line - premliminary support for RHAS4 (FC2) - AES requires Openssl 097 or higher. * Wed Sep 14 2004 Bishop Clark (LC957) 2.9.91-2 - no change from 1.0.2, just bumping the package number to force a rebuild. * Fri Aug 27 2004 Bishop Clark (LC957) 2.9.91-1 - xinetd prototype file - Nickolai 'kolya' Zeldovich's mlockall() patch - Added upper time bound to packet-based resync to reduce resync delay * Tue Aug 3 2004 Bishop Clark (LC957) 2.9.90-2 - incorporation of some of PLD fixes - move to more macros and less if/thens - one ugly SPEC for 18 happy distros. * Sun Mar 14 2004 Bishop Clark (LC957) 2.9.90-1 - new 3.0.0 pre-release. - better ciphers and a persist-keep bugfix. * Sun Mar 23 2003 Bishop Clark (LC957) 2.6-1.1 - alter packaging to accomodate MDKs non-standard devel pkg names * Tue Mar 18 2003 Bishop Clark (LC957) 2.6-1 - new release * Sat Aug 17 2002 Bishop Clark (LC957) 2.5-5 - fix GROUP for amanda's genhdlist and Michael Van Donselaar * Tue Jun 5 2002 Bishop Clark (LC957) 2.5-4 - Deprecated redundant directory creation in install - More undisputed patches by Willems Luc for SuSE support - Update of one SuSE config file, addition of another as per Willems Luc * Mon Jan 21 2002 Bishop Clark (LC957) 2.5-3 - Macros updating as per 2.5 for better cross-distro build - Added NO_USE_LZO compile option as per Willems Luc - very initial SuSE 7.3 support as per Willems Luc - removed packaging of vtun->vtund symlink in man8 as per build behaviour - re-edited as per Jan 14 2002 edits * Mon Jan 14 2002 Bishop Clark (LC957) 2.5-2 - noreplace to vtund.conf to prevent Freshen from clobbering config. - added buildrequires to prevent failed builds. * Mon May 29 2000 Michael Tokarev - Allow to build as non-root (using new INSTALL_OWNER option) - Added vtund.conf.5 manpage - Allow compressed manpages - Added cleanup of old $RPM_BUILD_ROOT at beginning of %%install stage * Sat Mar 04 2000 Dag Wieers - Added USE_SOCKS compile option. - Added Prefix-header * Sat Jan 29 2000 Dag Wieers - Replaced SSLeay-dependency by openssl-dependency - Replaced README.Config by README.Setup - Added TODO * Tue Nov 23 1999 Dag Wieers - Added Url and Obsoletes-headers - Added ChangeLog ;) - Changed summary vtun-3.0.4/lfd_legacy_encrypt.c0000644003736300373630000000717112774025127016104 0ustar bishopbishop/* VTun - Virtual Tunnel over TCP/IP network. Copyright (C) 1998-2016 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. */ /* * $Id: lfd_legacy_encrypt.c,v 1.1.4.4 2016/10/01 21:27:51 mtbishop Exp $ * Code added wholesale temporarily from lfd_encrypt 1.2.2.8 */ /* Encryption module uses software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/) Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. */ /* * This lfd_encrypt module uses MD5 to create 128 bits encryption * keys and BlowFish for actual data encryption. * It is based on code written by Chris Todd with * several improvements and modifications. */ #include "config.h" #include #include #include #include #include #include #include "vtun.h" #include "linkfd.h" #include "lib.h" #ifdef HAVE_SSL #ifndef __APPLE_CC__ /* OpenSSL includes */ #include #include #else /* YAY - We're MAC OS */ #include #include #endif /* __APPLE_CC__ */ #define ENC_BUF_SIZE VTUN_FRAME_SIZE + 16 #define ENC_KEY_SIZE 16 static BF_KEY key; static char * enc_buf; static int alloc_legacy_encrypt(struct vtun_host *host) { if( !(enc_buf = lfd_alloc(ENC_BUF_SIZE)) ){ vtun_syslog(LOG_ERR,"Can't allocate buffer for legacy encryptor"); return -1; } BF_set_key(&key, ENC_KEY_SIZE, MD5(host->passwd,strlen(host->passwd),NULL)); vtun_syslog(LOG_INFO, "BlowFish legacy encryption initialized"); return 0; } static int free_legacy_encrypt() { lfd_free(enc_buf); enc_buf = NULL; return 0; } static int legacy_encrypt_buf(int len, char *in, char **out) { register int pad, p; register char *in_ptr = in, *out_ptr = enc_buf; /* 8 - ( len % 8 ) */ pad = (~len & 0x07) + 1; p = 8 - pad; memset(out_ptr, 0, pad); *out_ptr = (char) pad; memcpy(out_ptr + pad, in_ptr, p); BF_ecb_encrypt(out_ptr, out_ptr, &key, BF_ENCRYPT); out_ptr += 8; in_ptr += p; len = len - p; for (p=0; p < len; p += 8) BF_ecb_encrypt(in_ptr + p, out_ptr + p, &key, BF_ENCRYPT); *out = enc_buf; return len + 8; } static int legacy_decrypt_buf(int len, char *in, char **out) { register int p; for (p = 0; p < len; p += 8) BF_ecb_encrypt(in + p, in + p, &key, BF_DECRYPT); p = *in; if (p < 1 || p > 8) { vtun_syslog(LOG_INFO, "legacy_decrypt_buf: bad pad length"); return 0; } *out = in + p; return len - p; } /* * Module structure. */ struct lfd_mod lfd_legacy_encrypt = { "Encryptor", alloc_legacy_encrypt, legacy_encrypt_buf, NULL, legacy_decrypt_buf, NULL, free_legacy_encrypt, NULL, NULL }; #else /* HAVE_SSL */ static int no_legacy_encrypt(struct vtun_host *host) { vtun_syslog(LOG_INFO, "Encryption is not supported"); return -1; } struct lfd_mod lfd_legacy_encrypt = { "Encryptor", no_legacy_encrypt, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; #endif /* HAVE_SSL */ vtun-3.0.4/server.c0000644003736300373630000001145412774025127013554 0ustar bishopbishop/* VTun - Virtual Tunnel over TCP/IP network. Copyright (C) 1998-2016 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. */ /* * $Id: server.c,v 1.9.2.5 2016/10/01 21:27:51 mtbishop Exp $ */ #include "config.h" #include #include #include #include #include #include #include #include #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_NETINET_TCP_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #include "vtun.h" #include "lib.h" #include "lock.h" #include "auth.h" #include "compat.h" #include "netlib.h" static volatile sig_atomic_t server_term; static void sig_term(int sig) { vtun_syslog(LOG_INFO,"Terminated"); server_term = VTUN_SIG_TERM; } static void connection(int sock) { struct sockaddr_in my_addr, cl_addr; struct vtun_host *host; struct sigaction sa; char *ip; int opt; opt = sizeof(struct sockaddr_in); if( getpeername(sock, (struct sockaddr *) &cl_addr, &opt) ){ vtun_syslog(LOG_ERR, "Can't get peer name"); exit(1); } opt = sizeof(struct sockaddr_in); if( getsockname(sock, (struct sockaddr *) &my_addr, &opt) < 0 ){ vtun_syslog(LOG_ERR, "Can't get local socket address"); exit(1); } ip = strdup(inet_ntoa(cl_addr.sin_addr)); io_init(); if( (host=auth_server(sock)) ){ sa.sa_handler=SIG_IGN; sa.sa_flags=SA_NOCLDWAIT;; sigaction(SIGHUP,&sa,NULL); vtun_syslog(LOG_INFO,"Session %s[%s:%d] opened", host->host, ip, ntohs(cl_addr.sin_port) ); host->rmt_fd = sock; host->sopt.laddr = strdup(inet_ntoa(my_addr.sin_addr)); host->sopt.lport = vtun.bind_addr.port; host->sopt.raddr = strdup(ip); host->sopt.rport = ntohs(cl_addr.sin_port); /* Start tunnel */ tunnel(host); vtun_syslog(LOG_INFO,"Session %s closed", host->host); /* Unlock host. (locked in auth_server) */ unlock_host(host); } else { vtun_syslog(LOG_INFO,"Denied connection from %s:%d", ip, ntohs(cl_addr.sin_port) ); } close(sock); exit(0); } #ifdef HAVE_WORKING_FORK static void listener(void) { struct sigaction sa; struct sockaddr_in my_addr, cl_addr; int s, s1, opt; memset(&my_addr, 0, sizeof(my_addr)); my_addr.sin_family = AF_INET; /* Set listen address */ if( generic_addr(&my_addr, &vtun.bind_addr) < 0) { vtun_syslog(LOG_ERR, "Can't fill in listen socket"); exit(1); } if( (s=socket(AF_INET,SOCK_STREAM,0))== -1 ){ vtun_syslog(LOG_ERR,"Can't create socket"); exit(1); } opt=1; setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); if( bind(s,(struct sockaddr *)&my_addr,sizeof(my_addr)) ){ vtun_syslog(LOG_ERR,"Can't bind to the socket"); exit(1); } if( listen(s, 10) ){ vtun_syslog(LOG_ERR,"Can't listen on the socket"); exit(1); } memset(&sa,0,sizeof(sa)); sa.sa_flags = SA_NOCLDWAIT; sa.sa_handler=sig_term; sigaction(SIGTERM,&sa,NULL); sigaction(SIGINT,&sa,NULL); server_term = 0; set_title("waiting for connections on port %d", vtun.bind_addr.port); while( (!server_term) || (server_term == VTUN_SIG_HUP) ){ opt=sizeof(cl_addr); if( (s1=accept(s,(struct sockaddr *)&cl_addr,&opt)) < 0 ) continue; switch( fork() ){ case 0: close(s); connection(s1); break; case -1: vtun_syslog(LOG_ERR, "Couldn't fork()"); default: close(s1); break; } } } #endif void server(int sock) { struct sigaction sa; sa.sa_handler=SIG_IGN; sa.sa_flags=SA_NOCLDWAIT;; sigaction(SIGINT,&sa,NULL); sigaction(SIGQUIT,&sa,NULL); sigaction(SIGCHLD,&sa,NULL); sigaction(SIGPIPE,&sa,NULL); sigaction(SIGUSR1,&sa,NULL); vtun_syslog(LOG_INFO,"VTUN server ver %s (%s)", VTUN_VER, vtun.svr_type == VTUN_INETD ? "inetd" : "stand" ); switch( vtun.svr_type ){ case VTUN_STAND_ALONE: #ifdef HAVE_WORKING_FORK listener(); #else vtun_syslog(LOG_ERR,"Standalone server is not supported: fork() not available"); #endif break; case VTUN_INETD: connection(sock); break; } } vtun-3.0.4/tunnel.c0000644003736300373630000001412512774025127013551 0ustar bishopbishop/* VTun - Virtual Tunnel over TCP/IP network. Copyright (C) 1998-2016 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. */ /* * $Id: tunnel.c,v 1.14.2.4 2016/10/01 21:27:51 mtbishop Exp $ */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif #ifdef HAVE_NETINET_IP_H #include #endif #ifdef HAVE_NETINET_TCP_H #include #endif #include "vtun.h" #include "linkfd.h" #include "lib.h" #include "netlib.h" #include "driver.h" int (*dev_write)(int fd, char *buf, int len); int (*dev_read)(int fd, char *buf, int len); int (*proto_write)(int fd, char *buf, int len); int (*proto_read)(int fd, char *buf); /* Initialize and start the tunnel. Returns: -1 - critical error 0 - normal close or noncritical error */ int tunnel(struct vtun_host *host) { int null_fd, pid, opt; int fd[2]={-1, -1}; char dev[VTUN_DEV_LEN]=""; int interface_already_open = 0; if ( (host->persist == VTUN_PERSIST_KEEPIF) && (host->loc_fd >= 0) ) interface_already_open = 1; /* Initialize device. */ if( host->dev ){ strncpy(dev, host->dev, VTUN_DEV_LEN); dev[VTUN_DEV_LEN-1]='\0'; } if( ! interface_already_open ){ switch( host->flags & VTUN_TYPE_MASK ){ case VTUN_TTY: if( (fd[0]=pty_open(dev)) < 0 ){ vtun_syslog(LOG_ERR,"Can't allocate pseudo tty. %s(%d)", strerror(errno), errno); return -1; } break; case VTUN_PIPE: if( pipe_open(fd) < 0 ){ vtun_syslog(LOG_ERR,"Can't create pipe. %s(%d)", strerror(errno), errno); return -1; } break; case VTUN_ETHER: if( (fd[0]=tap_open(dev)) < 0 ){ vtun_syslog(LOG_ERR,"Can't allocate tap device %s. %s(%d)", dev, strerror(errno), errno); return -1; } break; case VTUN_TUN: if( (fd[0]=tun_open(dev)) < 0 ){ vtun_syslog(LOG_ERR,"Can't allocate tun device %s. %s(%d)", dev, strerror(errno), errno); return -1; } break; } host->loc_fd = fd[0]; } host->sopt.dev = strdup(dev); /* Initialize protocol. */ switch( host->flags & VTUN_PROT_MASK ){ case VTUN_TCP: opt=1; setsockopt(host->rmt_fd,SOL_SOCKET,SO_KEEPALIVE,&opt,sizeof(opt) ); opt=1; setsockopt(host->rmt_fd,IPPROTO_TCP,TCP_NODELAY,&opt,sizeof(opt) ); proto_write = tcp_write; proto_read = tcp_read; break; case VTUN_UDP: if( (opt = udp_session(host)) == -1){ vtun_syslog(LOG_ERR,"Can't establish UDP session"); close(fd[1]); if( ! ( host->persist == VTUN_PERSIST_KEEPIF ) ) close(fd[0]); return 0; } proto_write = udp_write; proto_read = udp_read; break; } #ifdef HAVE_WORKING_FORK switch( (pid=fork()) ){ case -1: vtun_syslog(LOG_ERR,"Couldn't fork()"); if( ! ( host->persist == VTUN_PERSIST_KEEPIF ) ) close(fd[0]); close(fd[1]); return 0; case 0: /* do this only the first time when in persist = keep mode */ if( ! interface_already_open ){ switch( host->flags & VTUN_TYPE_MASK ){ case VTUN_TTY: /* Open pty slave (becomes controlling terminal) */ if( (fd[1] = open(dev, O_RDWR)) < 0){ vtun_syslog(LOG_ERR,"Couldn't open slave pty"); exit(0); } /* Fall through */ case VTUN_PIPE: null_fd = open("/dev/null", O_RDWR); close(fd[0]); close(0); dup(fd[1]); close(1); dup(fd[1]); close(fd[1]); /* Route stderr to /dev/null */ close(2); dup(null_fd); close(null_fd); break; case VTUN_ETHER: case VTUN_TUN: break; } } /* Run list of up commands */ set_title("%s running up commands", host->host); llist_trav(&host->up, run_cmd, &host->sopt); exit(0); } #else vtun_syslog(LOG_ERR,"Couldn't run up commands: fork() not available"); #endif switch( host->flags & VTUN_TYPE_MASK ){ case VTUN_TTY: set_title("%s tty", host->host); dev_read = pty_read; dev_write = pty_write; break; case VTUN_PIPE: /* Close second end of the pipe */ close(fd[1]); set_title("%s pipe", host->host); dev_read = pipe_read; dev_write = pipe_write; break; case VTUN_ETHER: set_title("%s ether %s", host->host, dev); dev_read = tap_read; dev_write = tap_write; break; case VTUN_TUN: set_title("%s tun %s", host->host, dev); dev_read = tun_read; dev_write = tun_write; break; } opt = linkfd(host); #ifdef HAVE_WORKING_FORK set_title("%s running down commands", host->host); llist_trav(&host->down, run_cmd, &host->sopt); #else vtun_syslog(LOG_ERR,"Couldn't run down commands: fork() not available"); #endif if(! ( host->persist == VTUN_PERSIST_KEEPIF ) ) { set_title("%s closing", host->host); /* Gracefully destroy interface */ switch( host->flags & VTUN_TYPE_MASK ){ case VTUN_TUN: tun_close(fd[0], dev); break; case VTUN_ETHER: tap_close(fd[0], dev); break; } close(host->loc_fd); } /* Close all other fds */ close(host->rmt_fd); close(fd[1]); return opt; } vtun-3.0.4/FAQ0000644003736300373630000001621510537207332012427 0ustar bishopbishopVTun - Frequently Asked Questions 1. General Questions 1.1 What is VTun ? VTun is the easiest way to create Virtual Tunnels over TCP/IP networks with traffic shaping, compression, and encryption. It supports IP, PPP, SLIP, Ethernet and other tunnel types. VTun is easily and highly configurable, it can be used for various network tasks. 1.2 What does VTun stand for ? Virtual TUNnel. 1.3 Whom do I contact for support ? Please send your suggestions, questions and problem descriptions to VTun mailing list vtun@office.satix.net 1.4 Is VTun Y2K compliant? YES. 1.5 Where can I download VTun package ? You can download complete VTun package from the following web sites: Primary: http://vtun.sourceforge.net Mirrors: http://vtun.saol.com http://vtun.speedway.net http://vtun.euronet.be 1.6 Can I establish VTun tunnel with Windows machine ? Unfortunately there is no VTun client for Windows yet. We a looking for a guru who will port VTun to Windows. 1.7 Can I establish VTun tunnel with Cisco ? No. VTun doesn't support tunneling with Cisco. 1.8 Does VTun support PPTP, L2TP, IPsec ? VTun uses it's own simple and efficient protocol with TCP or UDP. It doesn't support PPTP, L2TP, IPsec. 1.9 What platforms are supported by VTun ? VTun was developed on Linux and then ported to several other OS: Linux (any glibc based distribution) Solaris FreeBSD, OpenBSD, NetBSD and other BSD clones. 1.10 Does VTun server support multiple clients ? Sure. Number of the clients is limited only by the capabilities of your machine. 1.11 How many tunnels can VTun handle ? Number of the tunnels is limited only by the capabilities of your machine. 1.12 What do I need to run VTun ? You should install and configure VTun package and read documentation. Usually you'll need: Universal TUN/TAP device driver (http://vtun.sourceforge.net/tun) PPP driver and pppd. 1.13 What hardware do I need to run VTun ? Hardware requirements depends on your configuration: 486DX2/66/16Mb will handle simple tunnels without compression and encryption. P200/64Mb will handle several medium speed tunnels with compression and encryption without any problem. Celeron 400/64Mb, perfectly encrypts and compresses high speed channels like 2Mbits. Real life examples: PII466/128Mb was compressing several 3-4Mbits tunnels. AlphaXL 266/64Mb was compressing and shaping about 10-50 tunnels from 64Kbit to 512Kbit. P200MMX/64Mb with about 100 tunnels over loopback. 1.14 VTun supports many tunnel types, which type should I use ? Well, it is not very easy to answer this question in the FAQ. Please read documentation which comes with VTun package and visit VTun web site http://vtun.sourceforge.net 1.15 Where can I find configuration recommendations and examples ? VTun package contains several config file samples. Please read README.Setup 1.16 Why ZLIB compression does not work with UDP protocol ? UDP doesn't not provide reliable transport, and some frames could be lost on unreliable links. VTun does not have any retransmition or recovery algorithm for the lost UDP frames, because retransmition will be handled by Upper layers. You should use LZO compression with UDP protocol. 1.17 Why PPP tunnel is unstable over UDP ? Explanation is the same as with above case. Use TCP for PPP tunnels or use TUN instead of PPP, since tun device is completely the same with ppp device for the kernel. 1.18 Why do routes specified after 'ppp' command in config file produce errors and don't install correctly ? Actually there is no straight way to determine when pppd has established connection with the other end. VTun execute those route commands right after the launch of pppd and if PPP link is not established, route commands will fail. Since version 2.0b3, VTun delays 10 seconds before issuing the route commands, which should fix almost all cases. I'll think about more elegant way to fix this problem. 1.19 How secure is VTun ? Well. VTun doesn't try to be the MOST secure tunneling software in the world, it tries to be fast, stable, rich of features, easy to use and secure enough instead. VTun uses Challenge Based Authentication and doesn't transfer passwords in clear text. Encryption module uses MD5 for 128 bits key generation and BlowFish algorithm for actual data encryption. There could be some weaknesses in key generation method, we will try to address them in future releases. 1.20 Who has developed so nice and cool software ? Thanks :). You can find list of VTun team members on the web site or in the 'Credits' file in VTun package. 1.21 I don't like VTun where can I send complains ? You can send them to /dev/null. 1.22 Where can I get more information about VTun ? VTun package contains: Manual page for vtund. Manual page for configuration file. Fully documented config file. Several README files. 1.23 Can I use vtun over SSH ? Yes, via the port forwarding feature of ssh. Don't enable vtun's encryption as ssh does its own encryption. Also, make sure to select the tcp protocol as SSH can forward tcp but not udp. An example session might look something like this: home$ ssh -L 5000:localhost:5000 work.megacorp.com (authenticate if necessary) work$ vtund -s home_tunnel_config ... home$ vtund home_tunnel_config localhost 1.24 Is it possible to establish a vtun link from a client behind NAT or a firewall? Yes it is, but you need to use TCP protocol. 2. Error Messages 2.1 Why do I see no vtund log and error messages ? On several Unices, FreeBSD for example, syslog doesn't log message with INFO priority, by default. You should add "*.info;" to the line with /var/log/messages in /etc/syslog.conf. 2.2 Why do I get "Input/output error" pppd error message ? This usually means that vtund on other side has dropped connection, check logs on other side. 2.3 Why do I get "couldn't find any suitable secret (password)" pppd error message ? New versions of pppd use authentication by default. Just add "noauth" option to ppp command. 2.4 Why do I get "XXXX returned error Y" error message ? Usually this means that you use incorrect syntax for that command. Also please read question 1.19 about routes and pppd. 2.5 Why do I get "Serial line is looped back" pppd error message ? Sometimes pppd incorrectly decides that pseudo terminal is looped back. Just add "nomagic" option to ppp command. 2.6 Why do I get "Can't allocate tun device" or "Can't allocate tap device" error messages ? This error means that Universal TUN/TAP driver module is not loaded or you do not have correct /dev/tunXX or /dev/tapXX device nodes. Make sure you have installed and configured Universal TUN/TAP device driver (http://vtun.sourceforge.net/tun) 2.7 Why do I get "LZO compression is not supported" error message ? This error means that LZO compression is not compiled in. You will have to download binary VTun package or recompile vtund with LZO support. 2.8 Why do I get "expecting WORD at line xxx" error message ? This usually means that you are using a password that contain only numerical characters. VTun passwords must be alpha characters or a mixture of alpha and numerical characters. If you have any unanswered question please send it to the mailing list vtun-users@lists.sourceforge.net vtun-3.0.4/install-sh0000755003736300373630000001124407067441601014101 0ustar bishopbishop#! /bin/sh # # install - install a program, script, or datafile # This comes from X11R5. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. # # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" tranformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 vtun-3.0.4/lfd_shaper.c0000644003736300373630000000714212774025127014354 0ustar bishopbishop/* VTun - Virtual Tunnel over TCP/IP network. Copyright (C) 1998-2016 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. */ /* * $Id: lfd_shaper.c,v 1.7.2.4 2016/10/01 21:27:51 mtbishop Exp $ */ #include "config.h" #include #include #include #include #include #include "vtun.h" #include "linkfd.h" #include "lib.h" /* * Shaper module. */ #ifdef HAVE_SHAPER static unsigned long bytes, max_speed; static struct timeval curr_time, last_time; /* * Initialization function. */ static int shaper_init(struct vtun_host *host) { /* Calculate max speed bytes/sec */ max_speed = host->spd_out / 8 * 1024; /* Compensation for delays, nanosleep and so on */ max_speed += 400; bytes = 0; vtun_syslog(LOG_INFO,"Traffic shaping(speed %dK) initialized.", host->spd_out); return 0; } /* Shaper counter */ static int shaper_counter(int len, char *in, char **out) { /* Just count incoming bytes */ bytes += len; *out = in; return len; } /* Convert tv struct to milisec */ static unsigned long inline tv2ms(struct timeval tv) { register unsigned long ms = (tv.tv_sec * 1000)+(tv.tv_usec / 1000); return ms ? ms : 1; } #ifndef timersub /* Some includes doesn't contain this macro */ #define timersub(a, b, result) \ do { \ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ if ((result)->tv_usec < 0) { \ --(result)->tv_sec; \ (result)->tv_usec += 1000000; \ } \ } while (0) #endif /* * Main shaper function. * Compute current speed in bytes/sec and if it is * higher than maximal speed stop accepting input * until the speed become lower or equal to maximal. */ static int shaper_avail(void) { static struct timeval tv; register unsigned long speed; /* Let me know if you have faster and better time source. */ gettimeofday(&curr_time,NULL); timersub(&curr_time,&last_time,&tv); /* Calculate current speed bytes/sec. * (tv2ms never returns 0) */ speed = bytes * 1000 / tv2ms(tv); if( speed > max_speed ){ /* * Sleep about 1 microsec(actual sleep might be longer). * This is actually the hack to reduce CPU usage. * Without this delay we will consume 100% CPU. */ static struct timespec ts = {0,1000}; nanosleep(&ts,NULL); /* Don't accept input */ return 0; } if( curr_time.tv_sec > last_time.tv_sec ){ last_time = curr_time; bytes = 0; } /* Accept input */ return 1; } struct lfd_mod lfd_shaper = { "Shaper", shaper_init, shaper_counter, shaper_avail, NULL, NULL, NULL, NULL, NULL }; #else /* HAVE_SHAPER */ static int no_shaper(struct vtun_host *host) { vtun_syslog(LOG_INFO, "Traffic shaping is not supported"); return -1; } struct lfd_mod lfd_shaper = { "Shaper", no_shaper, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; #endif /* HAVE_SHAPER */ vtun-3.0.4/lock.c0000644003736300373630000000773512774025127013205 0ustar bishopbishop/* VTun - Virtual Tunnel over TCP/IP network. Copyright (C) 1998-2016 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. */ /* * $Id: lock.c,v 1.6.2.3 2016/10/01 21:27:51 mtbishop Exp $ */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include "vtun.h" #include "linkfd.h" #include "lib.h" #include "lock.h" int create_lock(char * file) { char tmp_file[255], str[20]; int fd, pid, ret; pid = getpid(); ret = 0; /* Create temp file */ sprintf(tmp_file, "%s_%d_tmp\n", file, pid); if( (fd = open(tmp_file, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0 ){ vtun_syslog(LOG_ERR, "Can't create temp lock file %s", file); return -1; } pid = sprintf(str, "%d\n", pid); if( write(fd, str, pid) == pid ){ /* Create lock file */ if( link(tmp_file, file) < 0 ){ /* Oops, already locked */ ret = -1; } } else { vtun_syslog(LOG_ERR, "Can't write to %s", tmp_file); ret = -1; } close(fd); /* Remove temp file */ unlink(tmp_file); return ret; } pid_t read_lock(char * file) { char str[20]; int fd, pid; /* Read PID from existing lock */ if( (fd = open(file, O_RDONLY)) < 0) return -1; pid = read(fd,str,sizeof(str)); close(fd); if( pid <= 0 ) return -1; str[sizeof(str)-1]='\0'; pid = strtol(str, NULL, 10); if( !pid || errno == ERANGE ){ /* Broken lock file */ if( unlink(file) < 0 ) vtun_syslog(LOG_ERR, "Unable to remove broken lock %s", file); return -1; } /* Check if process is still alive */ if( kill(pid, 0) < 0 && errno == ESRCH ){ /* Process is dead. Remove stale lock. */ if( unlink(file) < 0 ) vtun_syslog(LOG_ERR, "Unable to remove stale lock %s", file); return -1; } return pid; } int lock_host(struct vtun_host * host) { char lock_file[255]; struct timespec tm; int pid, i; if( host->multi == VTUN_MULTI_ALLOW ) return 0; sprintf(lock_file, "%s/%s", VTUN_LOCK_DIR, host->host); /* Check if lock already exists. */ if( (pid = read_lock(lock_file)) > 0 ){ /* Old process is alive */ switch( host->multi ){ case VTUN_MULTI_KILL: vtun_syslog(LOG_INFO, "Killing old connection (process %d)", pid); if( kill(pid, SIGTERM) < 0 && errno != ESRCH ){ vtun_syslog(LOG_ERR, "Can't kill process %d. %s",pid,strerror(errno)); return -1; } /* Give it a time(up to 5 secs) to terminate */ for(i=0; i < 10 && !kill(pid, 0); i++ ){ tm.tv_sec = 0; tm.tv_nsec = 500000000; nanosleep(&tm, NULL); } /* Make sure it's dead */ if( !kill(pid, SIGKILL) ){ vtun_syslog(LOG_ERR, "Process %d ignored TERM, killed with KILL", pid); /* Remove lock */ if( unlink(lock_file) < 0 ) vtun_syslog(LOG_ERR, "Unable to remove lock %s", lock_file); } break; case VTUN_MULTI_DENY: return -1; } } return create_lock(lock_file); } void unlock_host(struct vtun_host *host) { char lock_file[255]; if( host->multi == VTUN_MULTI_ALLOW ) return; sprintf(lock_file, "%s/%s", VTUN_LOCK_DIR, host->host); if( unlink(lock_file) < 0 ) vtun_syslog(LOG_ERR, "Unable to remove lock %s", lock_file); } vtun-3.0.4/vtund.80000644003736300373630000000613412767320421013327 0ustar bishopbishop.\" Manual page for vtund .\" $Id: vtund.8,v 1.6.2.3 2016/09/17 20:01:21 mtbishop Exp $ .\" SH section heading .\" SS subsection heading .\" LP paragraph .\" IP indented paragraph .\" TP hanging label .TH VTUND 8 .SH NAME vtund \- VTun(Virtual Tunnel) daemon. .SH SYNOPSIS .B vtund < .I -s > [ .I -i ] [ .I -n ] [ .I -f file ] [ .I -P port ] .LP .B vtund [ .I -f file ] [ .I -P port ] [ .I -p ] [ .I -q ] [ .I -m ] [ .I -t timeout ] [ .I -n ] < .I session > < .I server address > .SH DESCRIPTION .LP VTun provides the method for creating Virtual Tunnels over TCP/IP networks and allows to shape, compress, encrypt traffic in that tunnels. .LP Supported type of tunnels are: PPP, IP, Ethernet and most of other serial protocols and programs. .LP VTun is easily and highly configurable, it can be used for various network task like VPN, Mobile IP, Shaped Internet access, IP address saving, etc. .LP It is completely user space implementation and does not require modification to any kernel parts. .SH OPTIONS .TP .I -f file Read config information from the .I file (full path required). By default vtund uses /etc/vtund.conf .TP .I -n Do not become daemon (required on no-MMU systems). .SS Server mode: .TP .I -s Run as the server (not available on no-MMU systems). .TP .I -i Run as the inetd server. .TP .I -P port Listen for connection on the specified .I port By default vtund listens on TCP port 5000. This options is equivalent to the 'port' option of config file. .SS Client mode: .TP .I -P port Connect to the server on the specified .I port By default vtund connects to TCP port 5000. This options is equivalent to the 'port' option of config file. .TP .I -p Reconnect to the server after connection termination. By default vtund will exit if connection has been terminated. This options is equivalent to the 'persist' option of config file. .TP .I -q Inhibit the printing of connection messages. .TP .I -m Force memory pages to be locked memory-resident to prevent potential VM deadlock. Useful with NFS traffic. This option has no config file equivalent. .TP .I -t timeout Connect .I timeout Default is 30 seconds. This options is equivalent to the 'timeout' option of config file. .TP .I session Session name from the config file. .TP .I server Address of the server to connect to. Either IP address or domain name can be specified. .SH FILES .TP .B /etc/vtund.conf Main configuration file with sessions and other information. See vtund.conf example provided with distribution and vtund.conf(5) for more information. .TP .B /var/lock/vtund/ Session lock files. .TP .B /var/log/vtund/ Connection statistic log files. .br Format: Date Uncomp_In Uncomp_Out Comp_In Comp_Out .SH SIGNALS .TP .B SIGHUP Server mode: Causes vtund to reread the config file. .br Client mode: Causes vtund to reestablish the connection. .TP .B SIGUSR1 This signal causes vtund to reset statistic counters. .SH SEE ALSO .TP vtund.conf(5) .SH NOTES .LP This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/) .SH AUTHORS Maxim Krasnyansky vtun-3.0.4/config.sub0000755003736300373630000006737407422221614014072 0ustar bishopbishop#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. timestamp='2001-11-08' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | c4x | clipper \ | d10v | d30v | dsp16xx \ | fr30 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | m32r | m68000 | m68k | m88k | mcore \ | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el | mips64vr4300 \ | mips64vr4300el | mips64vr5000 | mips64vr5000el \ | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \ | mipsisa32 \ | mn10200 | mn10300 \ | ns16k | ns32k \ | openrisc \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[34] | sh[34]eb | shbe | shle \ | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic80 | tron \ | v850 \ | we32k \ | x86 | xscale | xstormy16 \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alphapca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armv*-* \ | avr-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c54x-* \ | clipper-* | cray2-* | cydra-* \ | d10v-* | d30v-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | m32r-* \ | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \ | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* \ | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ | v850-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* | xstormy16-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | ymp) basic_machine=ymp-cray os=-unicos ;; cray2) basic_machine=cray2-cray os=-unicos ;; [cjt]90) basic_machine=${basic_machine}-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mipsel*-linux*) basic_machine=mipsel-unknown os=-linux-gnu ;; mips*-linux*) basic_machine=mips-unknown os=-linux-gnu ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; mmix*) basic_machine=mmix-knuth os=-mmixware ;; monitor) basic_machine=m68k-rom68k os=-coff ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i686-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=t3e-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; windows32) basic_machine=i386-pc os=-windows32-msvcrt ;; xmp) basic_machine=xmp-cray os=-unicos ;; xps | xps100) basic_machine=xps100-honeywell ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; mips) if [ x$os = x-linux-gnu ]; then basic_machine=mips-unknown else basic_machine=mips-mips fi ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh3eb | sh4eb) basic_machine=sh-unknown ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; c4x*) basic_machine=c4x-none os=-coff ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto*) os=-nto-qnx ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: vtun-3.0.4/llist.h0000644003736300373630000000244712774025127013404 0ustar bishopbishop /* VTun - Virtual Tunnel over TCP/IP network. Copyright (C) 1998-2016 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. */ /* * $Id: llist.h,v 1.3.2.3 2016/10/01 21:27:51 mtbishop Exp $ */ #ifndef _VTUN_LLIST_H #define _VTUN_LLIST_H struct llist_element { struct llist_element * next; void * data; }; typedef struct llist_element llist_elm; typedef struct { llist_elm * head; llist_elm * tail; } llist; void llist_init(llist *l); int llist_add(llist *l, void *d); int llist_empty(llist *l); void * llist_trav(llist *l, int (*f)(void *d, void *u), void *u); int llist_copy(llist *l, llist *t, void* (*f)(void *d, void *u), void *u); void * llist_free(llist *l, int (*f)(void *d, void *u), void *u); #endif /* _VTUN_LLIST_H */ vtun-3.0.4/cfg_file.l0000644003736300373630000000756612774025127014026 0ustar bishopbishop%{ /* VTun - Virtual Tunnel over TCP/IP network. Copyright (C) 1998-2016 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. */ /* * $Id: cfg_file.l,v 1.4.2.3 2016/10/01 21:27:51 mtbishop Exp $ */ #include "config.h" #include #include "vtun.h" #include "cfg_file.tab.h" #include "cfg_kwords.h" /* static buffer for strings */ char str_buf[255]; int find_keyword(struct kword *kw, char *str); #define ECHO {;} #define YY_DECL int yylex(void) /* Push and pop parser state */ static int stack[16]; static int ptr = 0; #define PUSH_STATE() \ do { \ if( ptr == 16 ){ \ yyerror("To many pushes to parser's state stack"); \ return K_ERROR; \ } \ stack[ptr++] = YY_START; \ } while(0) #define POP_STATE() \ do { \ if( !ptr ){ \ yyerror("To many pops from parser's state stack"); \ return K_ERROR; \ } \ BEGIN(stack[--ptr]); \ } while(0) int cfg_error(const char *ftm, ...); int yyerror(char *str); %} num [0-9]+ dnum {num}:{num} word [A-Za-z0-9\-\_+=\!\$\#\%\&\*\^\@@\\\~\.]+ wordnm {word}:{num} kword [A-Za-z0-9\_\-]+ comment \#.*\n fname [A-Za-z0-9\_\.\-]+ path (\/{fname})+ string \".*\" %x OPTION PARAM %% <*>[ \t] ; /* Skip spaces and tabs (All stages) */ <*>\n { lineno++; } /* (All stages) */ {comment} { lineno++; } /* Skip comments */ {kword} { int kw = find_keyword(cfg_keyword,yytext); if( kw != -1 ) return kw; /* Keyword not found, means host definition. */ yylval.str = yytext; return K_HOST; } {word} { yylval.str = yytext; return K_ERROR; } <*>\{ { PUSH_STATE(); BEGIN(OPTION); return *yytext; } <*>\} { POP_STATE(); return *yytext; }