Update copyrights.
This commit is contained in:
parent
a460c4bfc1
commit
70894b2feb
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# VTun - Virtual Tunnel over TCP/IP network.
|
# VTun - Virtual Tunnel over TCP/IP network.
|
||||||
#
|
#
|
||||||
# Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
# Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
#
|
#
|
||||||
# VTun has been derived from VPPP package by Maxim Krasnyansky.
|
# VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
#
|
#
|
||||||
@ -15,7 +15,7 @@
|
|||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# $Id: Makefile.in,v 1.11.2.2 2008/01/07 22:12:57 mtbishop Exp $
|
# $Id: Makefile.in,v 1.11.2.3 2008/01/07 22:35:55 mtbishop Exp $
|
||||||
#
|
#
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
CFLAGS = @CFLAGS@ @CPPFLAGS@
|
CFLAGS = @CFLAGS@ @CPPFLAGS@
|
||||||
|
63
README
Normal file
63
README
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
|
This product includes software developed by the OpenSSL Project
|
||||||
|
for use in the OpenSSL Toolkit. (http://www.openssl.org/).
|
||||||
|
|
||||||
|
Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved.
|
||||||
|
|
||||||
|
Compilation and Installation:
|
||||||
|
|
||||||
|
In order to compile VTun you need several software packages.
|
||||||
|
Required packages:
|
||||||
|
- Good C compiler (gcc, egcs, etc)
|
||||||
|
- Lexical Analyzer (flex, lex)
|
||||||
|
- YACC (yacc, bison, byacc)
|
||||||
|
- Universal TUN/TAP driver http://vtun.sourceforge.net/tun
|
||||||
|
- OpenSSL encryption library http://www.openssl.org
|
||||||
|
|
||||||
|
Optional packages:
|
||||||
|
- Zlib compression library http://www.gzip.org/zlib/
|
||||||
|
- LZO compression library http://www.oberhumer.com/opensource/lzo/
|
||||||
|
- SOCKS library:
|
||||||
|
Socks5 by NEC (recommended) http://www.socks.nec.com
|
||||||
|
Dante Socks4/5 http://www.inet.no/dante
|
||||||
|
|
||||||
|
To configure VTun run:
|
||||||
|
./configure
|
||||||
|
Optional support:
|
||||||
|
--disable-lzo compile without LZO compression support
|
||||||
|
--disable-zlib compile without ZLIB compression support
|
||||||
|
--disable-shaper compile without Traffic shaping support
|
||||||
|
--enable-socks compile with SOCKS support
|
||||||
|
|
||||||
|
Configure automatically searches for all required library and header
|
||||||
|
files. However you might need to specify location of the files which
|
||||||
|
could not be found in default location:
|
||||||
|
SSL(Crypto) library:
|
||||||
|
--with-ssl-lib=/path/to/library (libcrypto.a)
|
||||||
|
--with-ssl-headers=/path/to/headers (md5.h blowfish.h)
|
||||||
|
|
||||||
|
LZO library:
|
||||||
|
--with-lzo-lib=/path/to/library (liblzo.a)
|
||||||
|
--with-lzo-headers=/path/to/headers (lzo1x.h)
|
||||||
|
|
||||||
|
SOCKS library:
|
||||||
|
--with-socks-lib=/path/to/library (libsocks.a or libsocks5.a)
|
||||||
|
|
||||||
|
To compile and install run:
|
||||||
|
make install
|
||||||
|
|
||||||
|
Read manual page for 'vtund' and the config file example for
|
||||||
|
configuration and other suggestions.
|
||||||
|
|
||||||
|
VTun has the mailing list vtun-users@lists.sourceforge.net
|
||||||
|
To receive information about mailing list and how to subscribe to it,
|
||||||
|
send an e-mail to vtun-users-request@lists.sourceforge.net with the
|
||||||
|
word 'help' in the Subject.
|
||||||
|
|
||||||
|
If you have any suggestions, ideas, wishes send them to
|
||||||
|
vtun-users@lists.sourceforge.net
|
||||||
|
|
||||||
|
Vtun (c) Maxim Krasnyansky
|
||||||
|
Maintained loosely by Bishop Clark <bishop@platypus.bc.ca>
|
4
auth.c
4
auth.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: auth.c,v 1.9.2.2 2008/01/07 22:12:48 mtbishop Exp $
|
* $Id: auth.c,v 1.9.2.3 2008/01/07 22:35:18 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
4
auth.h
4
auth.h
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: auth.h,v 1.3.2.1 2007/06/29 05:25:47 mtbishop Exp $
|
* $Id: auth.h,v 1.3.2.2 2008/01/07 22:35:19 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define VTUN_CHAL_SIZE 16
|
#define VTUN_CHAL_SIZE 16
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: cfg_file.l,v 1.4.2.1 2007/06/29 05:25:49 mtbishop Exp $
|
* $Id: cfg_file.l,v 1.4.2.2 2008/01/07 22:35:21 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: cfg_file.y,v 1.8.2.1 2007/06/29 05:25:51 mtbishop Exp $
|
* $Id: cfg_file.y,v 1.8.2.2 2008/01/07 22:35:22 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: cfg_kwords.h,v 1.6.2.1 2007/06/29 05:25:53 mtbishop Exp $
|
* $Id: cfg_kwords.h,v 1.6.2.2 2008/01/07 22:35:26 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int lineno;
|
extern int lineno;
|
||||||
|
4
client.c
4
client.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: client.c,v 1.11.2.1 2007/06/29 05:25:57 mtbishop Exp $
|
* $Id: client.c,v 1.11.2.2 2008/01/07 22:35:27 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
4
compat.h
4
compat.h
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: compat.h,v 1.3.2.1 2007/06/29 05:25:59 mtbishop Exp $
|
* $Id: compat.h,v 1.3.2.2 2008/01/07 22:35:29 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _VTUN_COMPAT_H
|
#ifndef _VTUN_COMPAT_H
|
||||||
#define _VTUN_COMPAT_H
|
#define _VTUN_COMPAT_H
|
||||||
|
4
driver.h
4
driver.h
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: driver.h,v 1.4.2.1 2007/06/29 05:26:03 mtbishop Exp $
|
* $Id: driver.h,v 1.4.2.2 2008/01/07 22:35:30 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _DRIVER_H
|
#ifndef _DRIVER_H
|
||||||
#define _DRIVER_H
|
#define _DRIVER_H
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: tun_dev.c,v 1.5.2.1 2007/06/29 05:26:53 mtbishop Exp $
|
* $Id: tun_dev.c,v 1.5.2.2 2008/01/07 22:36:10 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: pipe_dev.c,v 1.4.2.1 2007/06/29 05:26:55 mtbishop Exp $
|
* $Id: pipe_dev.c,v 1.4.2.2 2008/01/07 22:36:12 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: pty_dev.c,v 1.4.2.1 2007/06/29 05:26:57 mtbishop Exp $
|
* $Id: pty_dev.c,v 1.4.2.2 2008/01/07 22:36:13 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: tap_dev.c,v 1.5.2.1 2007/06/29 05:26:59 mtbishop Exp $
|
* $Id: tap_dev.c,v 1.5.2.2 2008/01/07 22:36:15 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: tcp_proto.c,v 1.7.2.1 2007/06/29 05:27:02 mtbishop Exp $
|
* $Id: tcp_proto.c,v 1.7.2.2 2008/01/07 22:36:16 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: tun_dev.c,v 1.5.2.1 2007/06/29 05:27:06 mtbishop Exp $
|
* $Id: tun_dev.c,v 1.5.2.2 2008/01/07 22:36:18 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: udp_proto.c,v 1.10.2.1 2007/06/29 05:27:09 mtbishop Exp $
|
* $Id: udp_proto.c,v 1.10.2.2 2008/01/07 22:36:19 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
761
lfd_encrypt.c
Normal file
761
lfd_encrypt.c
Normal file
@ -0,0 +1,761 @@
|
|||||||
|
/*
|
||||||
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
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<christ@insynq.com> with
|
||||||
|
* several improvements and modifications by me.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The current lfd_encrypt module is based on code attributed above and
|
||||||
|
* uses new code written by Dale Fountain <dpf-vtun@fountainbay.com> to
|
||||||
|
* allow multiple ciphers, modes, and key sizes. Feb 2004.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "vtun.h"
|
||||||
|
#include "linkfd.h"
|
||||||
|
#include "lib.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_SSL
|
||||||
|
|
||||||
|
/* OpenSSL includes */
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
#include <openssl/md5.h>
|
||||||
|
#include <openssl/blowfish.h>
|
||||||
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* #define LFD_ENCRYPT_DEBUG
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ENC_BUF_SIZE VTUN_FRAME_SIZE + 128
|
||||||
|
#define ENC_KEY_SIZE 16
|
||||||
|
|
||||||
|
BF_KEY key;
|
||||||
|
char * enc_buf;
|
||||||
|
char * dec_buf;
|
||||||
|
|
||||||
|
#define CIPHER_INIT 0
|
||||||
|
#define CIPHER_CODE 1
|
||||||
|
#define CIPHER_SEQUENCE 2
|
||||||
|
#define CIPHER_REQ_INIT 3
|
||||||
|
|
||||||
|
struct vtun_host *phost;
|
||||||
|
|
||||||
|
extern int send_a_packet;
|
||||||
|
|
||||||
|
/* out of sync packet threshold before forcing a re-init */
|
||||||
|
#define MAX_GIBBERISH 10
|
||||||
|
#define MIN_GIBBERISH 1
|
||||||
|
#define MAX_GIBBERISH_TIME 2
|
||||||
|
int gibberish;
|
||||||
|
time_t gib_time_start;
|
||||||
|
|
||||||
|
int cipher_enc_state;
|
||||||
|
int cipher_dec_state;
|
||||||
|
int cipher;
|
||||||
|
int blocksize;
|
||||||
|
int keysize;
|
||||||
|
int enc_init_first_time;
|
||||||
|
int dec_init_first_time;
|
||||||
|
unsigned long sequence_num;
|
||||||
|
char * pkey;
|
||||||
|
char * iv_buf;
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX ctx_enc; /* encrypt */
|
||||||
|
EVP_CIPHER_CTX ctx_dec; /* decrypt */
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX ctx_enc_ecb; /* sideband ecb encrypt */
|
||||||
|
EVP_CIPHER_CTX ctx_dec_ecb; /* sideband ecb decrypt */
|
||||||
|
|
||||||
|
int prep_key(char **key, int size, struct vtun_host *host)
|
||||||
|
{
|
||||||
|
int tmplen, halflen;
|
||||||
|
char *hashkey;
|
||||||
|
|
||||||
|
if ( !(hashkey = malloc(size)) )
|
||||||
|
{
|
||||||
|
vtun_syslog(LOG_ERR,"Can't allocate buffer for key hash");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memset(hashkey,0,size);
|
||||||
|
|
||||||
|
if (size == 32)
|
||||||
|
{
|
||||||
|
tmplen = strlen(host->passwd);
|
||||||
|
if (tmplen != 0) halflen = tmplen>>1;
|
||||||
|
else halflen = 0;
|
||||||
|
MD5(host->passwd, halflen, hashkey);
|
||||||
|
MD5((host->passwd)+halflen, tmplen-halflen, hashkey+16);
|
||||||
|
}
|
||||||
|
else if (size == 16)
|
||||||
|
{
|
||||||
|
MD5(host->passwd,strlen(host->passwd), hashkey);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* don't know what to do */
|
||||||
|
free(hashkey);
|
||||||
|
*key = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*key = hashkey;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void free_key (char *key)
|
||||||
|
{
|
||||||
|
free(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
int alloc_encrypt(struct vtun_host *host)
|
||||||
|
{
|
||||||
|
int sb_init = 0;
|
||||||
|
int var_key = 0;
|
||||||
|
const EVP_CIPHER *cipher_type;
|
||||||
|
char tmpstr[64];
|
||||||
|
char cipher_name[32];
|
||||||
|
EVP_CIPHER_CTX *pctx_enc;
|
||||||
|
EVP_CIPHER_CTX *pctx_dec;
|
||||||
|
|
||||||
|
enc_init_first_time = 1;
|
||||||
|
dec_init_first_time = 1;
|
||||||
|
|
||||||
|
if( !(enc_buf = lfd_alloc(ENC_BUF_SIZE)) ){
|
||||||
|
vtun_syslog(LOG_ERR,"Can't allocate buffer for encryptor");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if( !(dec_buf = lfd_alloc(ENC_BUF_SIZE)) ){
|
||||||
|
vtun_syslog(LOG_ERR,"Can't allocate buffer for decryptor");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
RAND_bytes((char *)&sequence_num, 4);
|
||||||
|
gibberish = 0;
|
||||||
|
gib_time_start = 0;
|
||||||
|
phost = host;
|
||||||
|
cipher = host->cipher;
|
||||||
|
switch(cipher)
|
||||||
|
{
|
||||||
|
case VTUN_ENC_AES256OFB:
|
||||||
|
case VTUN_ENC_AES256CFB:
|
||||||
|
case VTUN_ENC_AES256CBC:
|
||||||
|
blocksize = 16;
|
||||||
|
keysize = 32;
|
||||||
|
sb_init = 1;
|
||||||
|
cipher_type = EVP_aes_256_ecb();
|
||||||
|
pctx_enc = &ctx_enc_ecb;
|
||||||
|
pctx_dec = &ctx_dec_ecb;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_AES256ECB:
|
||||||
|
blocksize = 16;
|
||||||
|
keysize = 32;
|
||||||
|
pctx_enc = &ctx_enc;
|
||||||
|
pctx_dec = &ctx_dec;
|
||||||
|
cipher_type = EVP_aes_256_ecb();
|
||||||
|
strcpy(cipher_name,"AES-256-ECB");
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_AES128OFB:
|
||||||
|
case VTUN_ENC_AES128CFB:
|
||||||
|
case VTUN_ENC_AES128CBC:
|
||||||
|
blocksize = 16;
|
||||||
|
keysize = 16;
|
||||||
|
sb_init=1;
|
||||||
|
cipher_type = EVP_aes_128_ecb();
|
||||||
|
pctx_enc = &ctx_enc_ecb;
|
||||||
|
pctx_dec = &ctx_dec_ecb;
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_AES128ECB:
|
||||||
|
blocksize = 16;
|
||||||
|
keysize = 16;
|
||||||
|
pctx_enc = &ctx_enc;
|
||||||
|
pctx_dec = &ctx_dec;
|
||||||
|
cipher_type = EVP_aes_128_ecb();
|
||||||
|
strcpy(cipher_name,"AES-128-ECB");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_BF256OFB:
|
||||||
|
case VTUN_ENC_BF256CFB:
|
||||||
|
case VTUN_ENC_BF256CBC:
|
||||||
|
blocksize = 8;
|
||||||
|
keysize = 32;
|
||||||
|
var_key = 1;
|
||||||
|
sb_init = 1;
|
||||||
|
cipher_type = EVP_bf_ecb();
|
||||||
|
pctx_enc = &ctx_enc_ecb;
|
||||||
|
pctx_dec = &ctx_dec_ecb;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_BF256ECB:
|
||||||
|
blocksize = 8;
|
||||||
|
keysize = 32;
|
||||||
|
var_key = 1;
|
||||||
|
pctx_enc = &ctx_enc;
|
||||||
|
pctx_dec = &ctx_dec;
|
||||||
|
cipher_type = EVP_bf_ecb();
|
||||||
|
strcpy(cipher_name,"Blowfish-256-ECB");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_BF128OFB:
|
||||||
|
case VTUN_ENC_BF128CFB:
|
||||||
|
case VTUN_ENC_BF128CBC:
|
||||||
|
blocksize = 8;
|
||||||
|
keysize = 16;
|
||||||
|
var_key = 1;
|
||||||
|
sb_init = 1;
|
||||||
|
cipher_type = EVP_bf_ecb();
|
||||||
|
pctx_enc = &ctx_enc_ecb;
|
||||||
|
pctx_dec = &ctx_dec_ecb;
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_BF128ECB: /* blowfish 128 ecb is the default */
|
||||||
|
default:
|
||||||
|
blocksize = 8;
|
||||||
|
keysize = 16;
|
||||||
|
var_key = 1;
|
||||||
|
pctx_enc = &ctx_enc;
|
||||||
|
pctx_dec = &ctx_dec;
|
||||||
|
cipher_type = EVP_bf_ecb();
|
||||||
|
strcpy(cipher_name,"Blowfish-128-ECB");
|
||||||
|
break;
|
||||||
|
} /* switch(host->cipher) */
|
||||||
|
|
||||||
|
if (prep_key(&pkey, keysize, host) != 0) return -1;
|
||||||
|
EVP_CIPHER_CTX_init(pctx_enc);
|
||||||
|
EVP_CIPHER_CTX_init(pctx_dec);
|
||||||
|
EVP_EncryptInit_ex(pctx_enc, cipher_type, NULL, NULL, NULL);
|
||||||
|
EVP_DecryptInit_ex(pctx_dec, cipher_type, NULL, NULL, NULL);
|
||||||
|
if (var_key)
|
||||||
|
{
|
||||||
|
EVP_CIPHER_CTX_set_key_length(pctx_enc, keysize);
|
||||||
|
EVP_CIPHER_CTX_set_key_length(pctx_dec, keysize);
|
||||||
|
}
|
||||||
|
EVP_EncryptInit_ex(pctx_enc, NULL, NULL, pkey, NULL);
|
||||||
|
EVP_DecryptInit_ex(pctx_dec, NULL, NULL, pkey, NULL);
|
||||||
|
EVP_CIPHER_CTX_set_padding(pctx_enc, 0);
|
||||||
|
EVP_CIPHER_CTX_set_padding(pctx_dec, 0);
|
||||||
|
if (sb_init)
|
||||||
|
{
|
||||||
|
cipher_enc_state=CIPHER_INIT;
|
||||||
|
cipher_dec_state=CIPHER_INIT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cipher_enc_state=CIPHER_CODE;
|
||||||
|
cipher_dec_state=CIPHER_CODE;
|
||||||
|
sprintf(tmpstr,"%s encryption initialized", cipher_name);
|
||||||
|
vtun_syslog(LOG_INFO, tmpstr);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int free_encrypt()
|
||||||
|
{
|
||||||
|
free_key(pkey); pkey = NULL;
|
||||||
|
|
||||||
|
lfd_free(enc_buf); enc_buf = NULL;
|
||||||
|
lfd_free(dec_buf); dec_buf = NULL;
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx_enc);
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx_dec);
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx_enc_ecb);
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx_dec_ecb);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int encrypt_buf(int len, char *in, char **out)
|
||||||
|
{
|
||||||
|
register int pad, p, msg_len;
|
||||||
|
int outlen;
|
||||||
|
char *in_ptr, *out_ptr = enc_buf;
|
||||||
|
|
||||||
|
msg_len = send_msg(len, in, out);
|
||||||
|
in = *out;
|
||||||
|
in_ptr = in+msg_len;
|
||||||
|
memcpy(out_ptr,in,msg_len);
|
||||||
|
out_ptr += msg_len;
|
||||||
|
|
||||||
|
send_ib_mesg(&len, &in_ptr);
|
||||||
|
if (!len) return 0;
|
||||||
|
/* ( len % blocksize ) */
|
||||||
|
p = (len & (blocksize-1)); pad = blocksize - p;
|
||||||
|
|
||||||
|
memset(in_ptr+len, pad, pad);
|
||||||
|
outlen=len+pad;
|
||||||
|
if (pad == blocksize)
|
||||||
|
RAND_bytes(in_ptr+len, blocksize-1);
|
||||||
|
EVP_EncryptUpdate(&ctx_enc, out_ptr, &outlen, in_ptr, len+pad);
|
||||||
|
*out = enc_buf;
|
||||||
|
|
||||||
|
sequence_num++;
|
||||||
|
|
||||||
|
return outlen+msg_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int decrypt_buf(int len, char *in, char **out)
|
||||||
|
{
|
||||||
|
register int pad;
|
||||||
|
char *tmp_ptr, *in_ptr, *out_ptr = dec_buf;
|
||||||
|
int outlen;
|
||||||
|
|
||||||
|
len = recv_msg(len, in, out);
|
||||||
|
in = *out;
|
||||||
|
in_ptr = in;
|
||||||
|
|
||||||
|
outlen=len;
|
||||||
|
if (!len) return 0;
|
||||||
|
EVP_DecryptUpdate(&ctx_dec, out_ptr, &outlen, in_ptr, len);
|
||||||
|
recv_ib_mesg(&outlen, &out_ptr);
|
||||||
|
if (!outlen) return 0;
|
||||||
|
tmp_ptr = out_ptr + outlen; tmp_ptr--;
|
||||||
|
pad = *tmp_ptr;
|
||||||
|
if (pad < 1 || pad > blocksize) {
|
||||||
|
vtun_syslog(LOG_INFO, "decrypt_buf: bad pad length");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*out = out_ptr;
|
||||||
|
return outlen - pad;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cipher_enc_init(char * iv)
|
||||||
|
{
|
||||||
|
int var_key = 0;
|
||||||
|
const EVP_CIPHER *cipher_type;
|
||||||
|
char tmpstr[64];
|
||||||
|
char cipher_name[32];
|
||||||
|
|
||||||
|
switch(cipher)
|
||||||
|
{
|
||||||
|
case VTUN_ENC_AES256OFB:
|
||||||
|
cipher_type = EVP_aes_256_ofb();
|
||||||
|
strcpy(cipher_name, "AES-256-OFB");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_AES256CFB:
|
||||||
|
cipher_type = EVP_aes_256_cfb();
|
||||||
|
strcpy(cipher_name, "AES-256-CFB");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_AES256CBC:
|
||||||
|
cipher_type = EVP_aes_256_cbc();
|
||||||
|
strcpy(cipher_name, "AES-256-CBC");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_AES128OFB:
|
||||||
|
cipher_type = EVP_aes_128_ofb();
|
||||||
|
strcpy(cipher_name, "AES-128-OFB");
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_AES128CFB:
|
||||||
|
cipher_type = EVP_aes_128_cfb();
|
||||||
|
strcpy(cipher_name, "AES-128-CFB");
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_AES128CBC:
|
||||||
|
cipher_type = EVP_aes_128_cbc();
|
||||||
|
strcpy(cipher_name, "AES-128-CBC");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_BF256OFB:
|
||||||
|
var_key = 1;
|
||||||
|
cipher_type = EVP_bf_ofb();
|
||||||
|
strcpy(cipher_name, "Blowfish-256-OFB");
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_BF256CFB:
|
||||||
|
var_key = 1;
|
||||||
|
cipher_type = EVP_bf_cfb();
|
||||||
|
strcpy(cipher_name, "Blowfish-256-CFB");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_BF256CBC:
|
||||||
|
var_key = 1;
|
||||||
|
cipher_type = EVP_bf_cbc();
|
||||||
|
strcpy(cipher_name, "Blowfish-256-CBC");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_BF128OFB:
|
||||||
|
var_key = 1;
|
||||||
|
cipher_type = EVP_bf_ofb();
|
||||||
|
strcpy(cipher_name, "Blowfish-128-OFB");
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_BF128CFB:
|
||||||
|
var_key = 1;
|
||||||
|
cipher_type = EVP_bf_cfb();
|
||||||
|
strcpy(cipher_name, "Blowfish-128-CFB");
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_BF128CBC:
|
||||||
|
var_key = 1;
|
||||||
|
cipher_type = EVP_bf_cbc();
|
||||||
|
strcpy(cipher_name, "Blowfish-128-CBC");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* if we're here, something weird's going on */
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
} /* switch(cipher) */
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX_init(&ctx_enc);
|
||||||
|
EVP_EncryptInit_ex(&ctx_enc, cipher_type, NULL, NULL, NULL);
|
||||||
|
if (var_key)
|
||||||
|
EVP_CIPHER_CTX_set_key_length(&ctx_enc, keysize);
|
||||||
|
EVP_EncryptInit_ex(&ctx_enc, NULL, NULL, pkey, NULL);
|
||||||
|
EVP_EncryptInit_ex(&ctx_enc, NULL, NULL, NULL, iv);
|
||||||
|
EVP_CIPHER_CTX_set_padding(&ctx_enc, 0);
|
||||||
|
if (enc_init_first_time)
|
||||||
|
{
|
||||||
|
sprintf(tmpstr,"%s encryption initialized", cipher_name);
|
||||||
|
vtun_syslog(LOG_INFO, tmpstr);
|
||||||
|
enc_init_first_time = 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cipher_dec_init(char * iv)
|
||||||
|
{
|
||||||
|
int var_key = 0;
|
||||||
|
const EVP_CIPHER *cipher_type;
|
||||||
|
char tmpstr[64];
|
||||||
|
char cipher_name[32];
|
||||||
|
|
||||||
|
switch(cipher)
|
||||||
|
{
|
||||||
|
case VTUN_ENC_AES256OFB:
|
||||||
|
cipher_type = EVP_aes_256_ofb();
|
||||||
|
strcpy(cipher_name, "AES-256-OFB");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_AES256CFB:
|
||||||
|
cipher_type = EVP_aes_256_cfb();
|
||||||
|
strcpy(cipher_name, "AES-256-CFB");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_AES256CBC:
|
||||||
|
cipher_type = EVP_aes_256_cbc();
|
||||||
|
strcpy(cipher_name, "AES-256-CBC");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_AES128OFB:
|
||||||
|
cipher_type = EVP_aes_128_ofb();
|
||||||
|
strcpy(cipher_name, "AES-128-OFB");
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_AES128CFB:
|
||||||
|
cipher_type = EVP_aes_128_cfb();
|
||||||
|
strcpy(cipher_name, "AES-128-CFB");
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_AES128CBC:
|
||||||
|
cipher_type = EVP_aes_128_cbc();
|
||||||
|
strcpy(cipher_name, "AES-128-CBC");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_BF256OFB:
|
||||||
|
var_key = 1;
|
||||||
|
cipher_type = EVP_bf_ofb();
|
||||||
|
strcpy(cipher_name, "Blowfish-256-OFB");
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_BF256CFB:
|
||||||
|
var_key = 1;
|
||||||
|
cipher_type = EVP_bf_cfb();
|
||||||
|
strcpy(cipher_name, "Blowfish-256-CFB");
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_BF256CBC:
|
||||||
|
var_key = 1;
|
||||||
|
cipher_type = EVP_bf_cbc();
|
||||||
|
strcpy(cipher_name, "Blowfish-256-CBC");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VTUN_ENC_BF128OFB:
|
||||||
|
var_key = 1;
|
||||||
|
cipher_type = EVP_bf_ofb();
|
||||||
|
strcpy(cipher_name, "Blowfish-128-OFB");
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_BF128CFB:
|
||||||
|
var_key = 1;
|
||||||
|
cipher_type = EVP_bf_cfb();
|
||||||
|
strcpy(cipher_name, "Blowfish-128-CFB");
|
||||||
|
break;
|
||||||
|
case VTUN_ENC_BF128CBC:
|
||||||
|
var_key = 1;
|
||||||
|
cipher_type = EVP_bf_cbc();
|
||||||
|
strcpy(cipher_name, "Blowfish-128-CBC");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* if we're here, something weird's going on */
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
} /* switch(cipher) */
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX_init(&ctx_dec);
|
||||||
|
EVP_DecryptInit_ex(&ctx_dec, cipher_type, NULL, NULL, NULL);
|
||||||
|
if (var_key)
|
||||||
|
EVP_CIPHER_CTX_set_key_length(&ctx_dec, keysize);
|
||||||
|
EVP_DecryptInit_ex(&ctx_dec, NULL, NULL, pkey, NULL);
|
||||||
|
EVP_DecryptInit_ex(&ctx_dec, NULL, NULL, NULL, iv);
|
||||||
|
EVP_CIPHER_CTX_set_padding(&ctx_dec, 0);
|
||||||
|
if (dec_init_first_time)
|
||||||
|
{
|
||||||
|
sprintf(tmpstr,"%s decryption initialized", cipher_name);
|
||||||
|
vtun_syslog(LOG_INFO, tmpstr);
|
||||||
|
dec_init_first_time = 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int send_msg(int len, char *in, char **out)
|
||||||
|
{
|
||||||
|
char * iv; char * in_ptr;
|
||||||
|
int outlen;
|
||||||
|
|
||||||
|
switch(cipher_enc_state)
|
||||||
|
{
|
||||||
|
case CIPHER_INIT:
|
||||||
|
in_ptr = in - blocksize*2;
|
||||||
|
iv = malloc(blocksize);
|
||||||
|
RAND_bytes(iv, blocksize);
|
||||||
|
strncpy(in_ptr,"ivec",4);
|
||||||
|
in_ptr += 4;
|
||||||
|
memcpy(in_ptr,iv,blocksize);
|
||||||
|
in_ptr += blocksize;
|
||||||
|
cipher_enc_init(iv);
|
||||||
|
|
||||||
|
memset(iv,0,blocksize); free(iv); iv = NULL;
|
||||||
|
RAND_bytes(in_ptr, in - in_ptr);
|
||||||
|
|
||||||
|
in_ptr = in - blocksize*2;
|
||||||
|
outlen = blocksize*2;
|
||||||
|
EVP_EncryptUpdate(&ctx_enc_ecb, in_ptr,
|
||||||
|
&outlen, in_ptr, blocksize*2);
|
||||||
|
*out = in_ptr;
|
||||||
|
len = outlen;
|
||||||
|
cipher_enc_state = CIPHER_SEQUENCE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CIPHER_CODE:
|
||||||
|
default:
|
||||||
|
*out = in;
|
||||||
|
len = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int recv_msg(int len, char *in, char **out)
|
||||||
|
{
|
||||||
|
char * iv; char * in_ptr;
|
||||||
|
int outlen;
|
||||||
|
|
||||||
|
switch(cipher_dec_state)
|
||||||
|
{
|
||||||
|
case CIPHER_INIT:
|
||||||
|
in_ptr = in;
|
||||||
|
iv = malloc(blocksize);
|
||||||
|
outlen = blocksize*2;
|
||||||
|
EVP_DecryptUpdate(&ctx_dec_ecb, in_ptr, &outlen, in_ptr, blocksize*2);
|
||||||
|
|
||||||
|
if ( !strncmp(in_ptr, "ivec", 4) )
|
||||||
|
{
|
||||||
|
memcpy(iv, in_ptr+4, blocksize);
|
||||||
|
cipher_dec_init(iv);
|
||||||
|
|
||||||
|
*out = in_ptr + blocksize*2;
|
||||||
|
len -= blocksize*2;
|
||||||
|
cipher_dec_state = CIPHER_SEQUENCE;
|
||||||
|
gibberish = 0;
|
||||||
|
gib_time_start = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
len = 0;
|
||||||
|
*out = in;
|
||||||
|
gibberish++;
|
||||||
|
if (gibberish == 1) gib_time_start = time(NULL);
|
||||||
|
|
||||||
|
if (gibberish == MIN_GIBBERISH)
|
||||||
|
{
|
||||||
|
cipher_enc_state = CIPHER_REQ_INIT;
|
||||||
|
send_a_packet = 1;
|
||||||
|
#ifdef LFD_ENCRYPT_DEBUG
|
||||||
|
vtun_syslog(LOG_INFO,
|
||||||
|
"Min. gibberish threshold reached");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (gibberish >= MAX_GIBBERISH ||
|
||||||
|
difftime(time(NULL), gib_time_start) >= MAX_GIBBERISH_TIME)
|
||||||
|
{
|
||||||
|
gibberish = 0;
|
||||||
|
gib_time_start = 0;
|
||||||
|
send_a_packet = 1;
|
||||||
|
|
||||||
|
#ifdef LFD_ENCRYPT_DEBUG
|
||||||
|
vtun_syslog(LOG_INFO,
|
||||||
|
"Max. gibberish threshold reached");
|
||||||
|
#endif
|
||||||
|
if (cipher_enc_state != CIPHER_INIT)
|
||||||
|
{
|
||||||
|
cipher_enc_state = CIPHER_INIT;
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx_enc);
|
||||||
|
#ifdef LFD_ENCRYPT_DEBUG
|
||||||
|
vtun_syslog(LOG_INFO,
|
||||||
|
"Forcing local encryptor re-init");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
memset(iv,0,blocksize); free(iv); iv = NULL;
|
||||||
|
memset(in_ptr,0,blocksize*2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CIPHER_CODE:
|
||||||
|
default:
|
||||||
|
*out = in;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Send In-Band Message */
|
||||||
|
int send_ib_mesg(int *len, char **in)
|
||||||
|
{
|
||||||
|
char *in_ptr = *in;
|
||||||
|
|
||||||
|
/* To simplify matters, I assume that blocksize
|
||||||
|
will not be less than 8 bytes */
|
||||||
|
if (cipher_enc_state == CIPHER_SEQUENCE)
|
||||||
|
{
|
||||||
|
in_ptr -= blocksize;
|
||||||
|
memset(in_ptr,0,blocksize);
|
||||||
|
strncpy(in_ptr,"seq#",4);
|
||||||
|
in_ptr+=4;
|
||||||
|
*((unsigned long *)in_ptr) = htonl(sequence_num);
|
||||||
|
in_ptr-=4;
|
||||||
|
|
||||||
|
*in = in_ptr;
|
||||||
|
*len += blocksize;
|
||||||
|
}
|
||||||
|
else if (cipher_enc_state == CIPHER_REQ_INIT)
|
||||||
|
{
|
||||||
|
in_ptr -= blocksize;
|
||||||
|
memset(in_ptr,0,blocksize);
|
||||||
|
strncpy(in_ptr,"rsyn",4);
|
||||||
|
in_ptr+=4;
|
||||||
|
*((unsigned long *)in_ptr) = htonl(sequence_num);
|
||||||
|
in_ptr-=4;
|
||||||
|
|
||||||
|
*in = in_ptr;
|
||||||
|
*len += blocksize;
|
||||||
|
#ifdef LFD_ENCRYPT_DEBUG
|
||||||
|
vtun_syslog(LOG_INFO, "Requesting remote encryptor re-init");
|
||||||
|
#endif
|
||||||
|
cipher_enc_state = CIPHER_SEQUENCE;
|
||||||
|
send_a_packet = 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Receive In-Band Message */
|
||||||
|
int recv_ib_mesg(int *len, char **in)
|
||||||
|
{
|
||||||
|
char *in_ptr = *in;
|
||||||
|
|
||||||
|
if (cipher_dec_state == CIPHER_SEQUENCE)
|
||||||
|
{
|
||||||
|
/* To simplify matters, I assume that blocksize
|
||||||
|
will not be less than 8 bytes */
|
||||||
|
if ( !strncmp(in_ptr, "seq#", 4) )
|
||||||
|
{
|
||||||
|
*in += blocksize;
|
||||||
|
*len -= blocksize;
|
||||||
|
}
|
||||||
|
else if ( !strncmp(in_ptr, "rsyn", 4) )
|
||||||
|
{
|
||||||
|
*in += blocksize;
|
||||||
|
*len -= blocksize;
|
||||||
|
|
||||||
|
if (cipher_enc_state != CIPHER_INIT)
|
||||||
|
{
|
||||||
|
cipher_enc_state = CIPHER_INIT;
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx_enc);
|
||||||
|
}
|
||||||
|
#ifdef LFD_ENCRYPT_DEBUG
|
||||||
|
vtun_syslog(LOG_INFO, "Remote requests encryptor re-init");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*len = 0;
|
||||||
|
|
||||||
|
if (cipher_dec_state != CIPHER_INIT &&
|
||||||
|
cipher_enc_state != CIPHER_REQ_INIT &&
|
||||||
|
cipher_enc_state != CIPHER_INIT)
|
||||||
|
{
|
||||||
|
EVP_CIPHER_CTX_cleanup (&ctx_dec);
|
||||||
|
cipher_dec_state = CIPHER_INIT;
|
||||||
|
cipher_enc_state = CIPHER_REQ_INIT;
|
||||||
|
}
|
||||||
|
#ifdef LFD_ENCRYPT_DEBUG
|
||||||
|
vtun_syslog(LOG_INFO, "Local decryptor out of sync");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Module structure.
|
||||||
|
*/
|
||||||
|
struct lfd_mod lfd_encrypt = {
|
||||||
|
"Encryptor",
|
||||||
|
alloc_encrypt,
|
||||||
|
encrypt_buf,
|
||||||
|
NULL,
|
||||||
|
decrypt_buf,
|
||||||
|
NULL,
|
||||||
|
free_encrypt,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
#else /* HAVE_SSL */
|
||||||
|
|
||||||
|
int no_encrypt(struct vtun_host *host)
|
||||||
|
{
|
||||||
|
vtun_syslog(LOG_INFO, "Encryption is not supported");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct lfd_mod lfd_encrypt = {
|
||||||
|
"Encryptor",
|
||||||
|
no_encrypt, NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* HAVE_SSL */
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: lfd_legacy_encrypt.c,v 1.1.4.1 2008/01/07 22:12:53 mtbishop Exp $
|
* $Id: lfd_legacy_encrypt.c,v 1.1.4.2 2008/01/07 22:35:33 mtbishop Exp $
|
||||||
* Code added wholesale temporarily from lfd_encrypt 1.2.2.8
|
* Code added wholesale temporarily from lfd_encrypt 1.2.2.8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: lfd_lzo.c,v 1.5.2.2 2007/06/29 05:26:06 mtbishop Exp $
|
* $Id: lfd_lzo.c,v 1.5.2.3 2008/01/07 22:35:35 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* LZO compression module */
|
/* LZO compression module */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: lfd_shaper.c,v 1.7.2.1 2007/06/29 05:26:10 mtbishop Exp $
|
* $Id: lfd_shaper.c,v 1.7.2.2 2008/01/07 22:35:36 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: lfd_zlib.c,v 1.5.2.1 2007/06/29 05:26:13 mtbishop Exp $
|
* $Id: lfd_zlib.c,v 1.5.2.2 2008/01/07 22:35:38 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ZLIB compression module */
|
/* ZLIB compression module */
|
||||||
|
4
lib.c
4
lib.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: lib.c,v 1.9.2.1 2007/06/29 05:26:15 mtbishop Exp $
|
* $Id: lib.c,v 1.9.2.2 2008/01/07 22:35:40 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
4
lib.h
4
lib.h
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: lib.h,v 1.7.2.1 2007/06/29 05:26:17 mtbishop Exp $
|
* $Id: lib.h,v 1.7.2.2 2008/01/07 22:35:41 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _VTUN_LIB_H
|
#ifndef _VTUN_LIB_H
|
||||||
#define _VTUN_LIB_H
|
#define _VTUN_LIB_H
|
||||||
|
4
linkfd.c
4
linkfd.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: linkfd.c,v 1.13.2.2 2008/01/07 22:12:54 mtbishop Exp $
|
* $Id: linkfd.c,v 1.13.2.3 2008/01/07 22:35:43 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
4
linkfd.h
4
linkfd.h
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: linkfd.h,v 1.4.2.2 2008/01/07 22:12:56 mtbishop Exp $
|
* $Id: linkfd.h,v 1.4.2.3 2008/01/07 22:35:45 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LINKFD_H
|
#ifndef _LINKFD_H
|
||||||
|
28
linux/tap_dev.c
Normal file
28
linux/tap_dev.c
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
|
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: tap_dev.c,v 1.4.2.1 2008/01/07 22:36:21 mtbishop Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This is an empty file. All functionality formerly here is moved
|
||||||
|
to the tun_dev.c file. This file exists to prevent the automangle
|
||||||
|
tools from moving a tap_dev.c from the generic directory - which
|
||||||
|
we can't use - in place of this missing file.
|
||||||
|
*/
|
132
linux/tun_dev.c
Normal file
132
linux/tun_dev.c
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
|
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: tun_dev.c,v 1.4.2.1 2008/01/07 22:36:22 mtbishop Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <linux/if.h>
|
||||||
|
|
||||||
|
#include "vtun.h"
|
||||||
|
#include "lib.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate TUN device, returns opened fd.
|
||||||
|
* Stores dev name in the first arg(must be large enough).
|
||||||
|
*/
|
||||||
|
static int tun_open_common0(char *dev, int istun)
|
||||||
|
{
|
||||||
|
char tunname[14];
|
||||||
|
int i, fd, err;
|
||||||
|
|
||||||
|
if( *dev ) {
|
||||||
|
sprintf(tunname, "/dev/%s", dev);
|
||||||
|
return open(tunname, O_RDWR);
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(tunname, "/dev/%s", istun ? "tun" : "tap");
|
||||||
|
err = 0;
|
||||||
|
for(i=0; i < 255; i++){
|
||||||
|
sprintf(tunname + 8, "%d", i);
|
||||||
|
/* Open device */
|
||||||
|
if( (fd=open(tunname, O_RDWR)) > 0 ) {
|
||||||
|
strcpy(dev, tunname + 5);
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
else if (errno != ENOENT)
|
||||||
|
err = errno;
|
||||||
|
else if (i) /* don't try all 256 devices */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (err)
|
||||||
|
errno = err;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LINUX_IF_TUN_H /* New driver support */
|
||||||
|
#include <linux/if_tun.h>
|
||||||
|
|
||||||
|
#ifndef OTUNSETNOCSUM
|
||||||
|
/* pre 2.4.6 compatibility */
|
||||||
|
#define OTUNSETNOCSUM (('T'<< 8) | 200)
|
||||||
|
#define OTUNSETDEBUG (('T'<< 8) | 201)
|
||||||
|
#define OTUNSETIFF (('T'<< 8) | 202)
|
||||||
|
#define OTUNSETPERSIST (('T'<< 8) | 203)
|
||||||
|
#define OTUNSETOWNER (('T'<< 8) | 204)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int tun_open_common(char *dev, int istun)
|
||||||
|
{
|
||||||
|
struct ifreq ifr;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
if ((fd = open("/dev/net/tun", O_RDWR)) < 0)
|
||||||
|
return tun_open_common0(dev, istun);
|
||||||
|
|
||||||
|
memset(&ifr, 0, sizeof(ifr));
|
||||||
|
ifr.ifr_flags = (istun ? IFF_TUN : IFF_TAP) | IFF_NO_PI;
|
||||||
|
if (*dev)
|
||||||
|
strncpy(ifr.ifr_name, dev, IFNAMSIZ);
|
||||||
|
|
||||||
|
if (ioctl(fd, TUNSETIFF, (void *) &ifr) < 0) {
|
||||||
|
if (errno == EBADFD) {
|
||||||
|
/* Try old ioctl */
|
||||||
|
if (ioctl(fd, OTUNSETIFF, (void *) &ifr) < 0)
|
||||||
|
goto failed;
|
||||||
|
} else
|
||||||
|
goto failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(dev, ifr.ifr_name);
|
||||||
|
return fd;
|
||||||
|
|
||||||
|
failed:
|
||||||
|
close(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
# define tun_open_common(dev, type) tun_open_common0(dev, type)
|
||||||
|
|
||||||
|
#endif /* New driver support */
|
||||||
|
|
||||||
|
int tun_open(char *dev) { return tun_open_common(dev, 1); }
|
||||||
|
int tap_open(char *dev) { return tun_open_common(dev, 0); }
|
||||||
|
|
||||||
|
int tun_close(int fd, char *dev) { return close(fd); }
|
||||||
|
int tap_close(int fd, char *dev) { return close(fd); }
|
||||||
|
|
||||||
|
/* Read/write frames from TUN device */
|
||||||
|
int tun_write(int fd, char *buf, int len) { return write(fd, buf, len); }
|
||||||
|
int tap_write(int fd, char *buf, int len) { return write(fd, buf, len); }
|
||||||
|
|
||||||
|
int tun_read(int fd, char *buf, int len) { return read(fd, buf, len); }
|
||||||
|
int tap_read(int fd, char *buf, int len) { return read(fd, buf, len); }
|
4
llist.c
4
llist.c
@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: llist.c,v 1.3.2.1 2007/06/29 05:26:23 mtbishop Exp $
|
* $Id: llist.c,v 1.3.2.2 2008/01/07 22:35:47 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
4
llist.h
4
llist.h
@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: llist.h,v 1.3.2.1 2007/06/29 05:26:25 mtbishop Exp $
|
* $Id: llist.h,v 1.3.2.2 2008/01/07 22:35:48 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _VTUN_LLIST_H
|
#ifndef _VTUN_LLIST_H
|
||||||
|
4
lock.c
4
lock.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: lock.c,v 1.6.2.1 2007/06/29 05:26:27 mtbishop Exp $
|
* $Id: lock.c,v 1.6.2.2 2008/01/07 22:35:50 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
4
lock.h
4
lock.h
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: lock.h,v 1.3.2.1 2007/06/29 05:26:29 mtbishop Exp $
|
* $Id: lock.h,v 1.3.2.2 2008/01/07 22:35:51 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _VTUN_LOCK_H
|
#ifndef _VTUN_LOCK_H
|
||||||
|
4
main.c
4
main.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: main.c,v 1.9.2.1 2007/06/29 05:26:31 mtbishop Exp $
|
* $Id: main.c,v 1.9.2.2 2008/01/07 22:35:53 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
4
netlib.c
4
netlib.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: netlib.c,v 1.11.2.1 2007/06/29 05:26:35 mtbishop Exp $
|
* $Id: netlib.c,v 1.11.2.2 2008/01/07 22:35:56 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
4
netlib.h
4
netlib.h
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: netlib.h,v 1.5.2.1 2007/06/29 05:26:37 mtbishop Exp $
|
* $Id: netlib.h,v 1.5.2.2 2008/01/07 22:35:58 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _VTUN_NETDEV_H
|
#ifndef _VTUN_NETDEV_H
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: tun_dev.c,v 1.6.2.1 2007/06/29 05:27:13 mtbishop Exp $
|
* $Id: tun_dev.c,v 1.6.2.2 2008/01/07 22:36:24 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@name vtun-3.0.1
|
@name vtun-3.0.2
|
||||||
|
|
||||||
@owner root
|
@owner root
|
||||||
@group wheel
|
@group wheel
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
PKG="vtun"
|
PKG="vtun"
|
||||||
NAME="VTun - Virtual tunnels over TCP/IP"
|
NAME="VTun - Virtual tunnels over TCP/IP"
|
||||||
VERSION="3.0.1"
|
VERSION="3.0.2"
|
||||||
ARCH="i386"
|
ARCH="i386"
|
||||||
VENDOR="Bishop Clark"
|
VENDOR="Bishop Clark"
|
||||||
EMAIL="bishop@platypus.bc.ca"
|
EMAIL="bishop@platypus.bc.ca"
|
||||||
CATEGORY="system"
|
CATEGORY="system"
|
||||||
CLASSES="none"
|
CLASSES="none"
|
||||||
PSTAMP="20070606"
|
PSTAMP="20080107"
|
||||||
BASEDIR="/usr/local/"
|
BASEDIR="/usr/local/"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# $Id: vtun.spec,v 1.24.2.4 2007/06/29 05:27:15 mtbishop Exp $
|
# $Id: vtun.spec,v 1.24.2.5 2008/01/07 22:36:28 mtbishop Exp $
|
||||||
|
|
||||||
# By default, builds without socks-support.
|
# By default, builds without socks-support.
|
||||||
# To build with socks-support, issue:
|
# To build with socks-support, issue:
|
||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
# define variables here for older RPM versions.
|
# define variables here for older RPM versions.
|
||||||
%define name vtun
|
%define name vtun
|
||||||
%define version 3.0.1
|
%define version 3.0.2
|
||||||
%define release 1
|
%define release 1
|
||||||
|
|
||||||
# expansion of the previous part.
|
# expansion of the previous part.
|
||||||
|
4
server.c
4
server.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: server.c,v 1.9.2.1 2007/06/29 05:26:39 mtbishop Exp $
|
* $Id: server.c,v 1.9.2.2 2008/01/07 22:36:01 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: tap_dev.c,v 1.4.2.1 2007/06/29 05:27:20 mtbishop Exp $
|
* $Id: tap_dev.c,v 1.4.2.2 2008/01/07 22:36:30 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: tun_dev.c,v 1.5.2.1 2007/06/29 05:27:23 mtbishop Exp $
|
* $Id: tun_dev.c,v 1.5.2.2 2008/01/07 22:36:31 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
4
tunnel.c
4
tunnel.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: tunnel.c,v 1.14.2.1 2007/06/29 05:26:41 mtbishop Exp $
|
* $Id: tunnel.c,v 1.14.2.2 2008/01/07 22:36:03 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
4
vtun.h
4
vtun.h
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: vtun.h,v 1.12.2.2 2008/01/07 22:12:59 mtbishop Exp $
|
* $Id: vtun.h,v 1.12.2.3 2008/01/07 22:36:07 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _VTUN_H
|
#ifndef _VTUN_H
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
VTun - Virtual Tunnel over TCP/IP network.
|
VTun - Virtual Tunnel over TCP/IP network.
|
||||||
|
|
||||||
Copyright (C) 1998-2000 Maxim Krasnyansky <max_mk@yahoo.com>
|
Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
|
|
||||||
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
VTun has been derived from VPPP package by Maxim Krasnyansky.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: vtun_socks.h,v 1.3.2.1 2007/06/29 05:26:51 mtbishop Exp $
|
* $Id: vtun_socks.h,v 1.3.2.2 2008/01/07 22:36:08 mtbishop Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _VTUN_SOCKS_H
|
#ifndef _VTUN_SOCKS_H
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#
|
#
|
||||||
# VTun - Virtual Tunnel over TCP/IP network.
|
# VTun - Virtual Tunnel over TCP/IP network.
|
||||||
# Copyright (C) 1998-2001 Maxim Krasnyansky <max_mk@yahoo.com>
|
# Copyright (C) 1998-2008 Maxim Krasnyansky <max_mk@yahoo.com>
|
||||||
#
|
#
|
||||||
# Cleanup of English and spelling by
|
# Cleanup of English and spelling by
|
||||||
# Ted Rolle <ted@acacia.datacomm.com>
|
# Ted Rolle <ted@acacia.datacomm.com>
|
||||||
#
|
#
|
||||||
# Configuration file example
|
# Configuration file example
|
||||||
# $Id: vtund.conf,v 1.4.2.1 2007/06/29 05:26:45 mtbishop Exp $
|
# $Id: vtund.conf,v 1.4.2.2 2008/01/07 22:36:05 mtbishop Exp $
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Lines which begin with '#' are comments
|
# Lines which begin with '#' are comments
|
||||||
|
Loading…
Reference in New Issue
Block a user