diff --git a/ChangeLog b/ChangeLog index d954f4e..32801d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +------------------------------------------------------------------------ +r1494 | guus | 2007-01-05 06:44:01 +0100 (vr, 05 jan 2007) | 2 lines + +rename() cannot replace existing files on Windows. + +------------------------------------------------------------------------ +r1493 | guus | 2007-01-05 05:49:02 +0100 (vr, 05 jan 2007) | 4 lines + +Fix generic BSD tun device to write only the actual packet length. +Due to a copy&paste bug, it tried to write a packet with the maximum size. +This was not a problem until the maximum size was increased to support VLANs. + +------------------------------------------------------------------------ +r1492 | guus | 2007-01-04 16:28:36 +0100 (do, 04 jan 2007) | 2 lines + +Tapreader socket should be bound to localhost only. + +------------------------------------------------------------------------ +r1491 | guus | 2007-01-03 19:18:54 +0100 (wo, 03 jan 2007) | 5 lines + +Use a ringbuffer in shared memory to transfer packets from the tapreader thread to the main thread. +It's a wonder it ever worked before. The socket that is created is not of a +datagram type, therefore packet boundaries were not preserved, which becomes +a problem as soon as the TAP-Win32 device receives packets in fast succession. + +------------------------------------------------------------------------ +r1490 | guus | 2006-12-18 18:38:05 +0100 (ma, 18 dec 2006) | 2 lines + +Releasing 1.0.6. + ------------------------------------------------------------------------ r1489 | guus | 2006-12-18 12:41:53 +0100 (ma, 18 dec 2006) | 2 lines diff --git a/Makefile.in b/Makefile.in index 2b6d5eb..842e857 100644 --- a/Makefile.in +++ b/Makefile.in @@ -35,7 +35,7 @@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure ABOUT-NLS AUTHORS COPYING ChangeLog \ - INSTALL NEWS THANKS TODO config.guess config.rpath config.sub \ + INSTALL NEWS THANKS config.guess config.rpath config.sub \ depcomp install-sh missing mkinstalldirs ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/attribute.m4 \ diff --git a/NEWS b/NEWS index 04bd25f..fc13420 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +Version 1.0.7 Jan 5 2007 + + * Fixed a bug that caused slow network speeds on Windows. + + * Fixed a bug that caused tinc unable to write packets to the tun device on + OpenBSD. + Version 1.0.6 Dec 18 2006 * More flexible detection of the LZO libraries when compiling. diff --git a/README b/README index dead56f..d4eb084 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -This is the README file for tinc version 1.0.6. Installation +This is the README file for tinc version 1.0.7. Installation instructions may be found in the INSTALL file. tinc is Copyright (C) 1998-2006 by: @@ -55,7 +55,7 @@ should be changed into "Device", and "Device" should be changed into Compatibility ------------- -Version 1.0.6 is compatible with 1.0pre8, 1.0 and later, but not with older +Version 1.0.7 is compatible with 1.0pre8, 1.0 and later, but not with older versions of tinc. diff --git a/TODO b/TODO deleted file mode 100644 index d6a6df4..0000000 --- a/TODO +++ /dev/null @@ -1,3 +0,0 @@ -TODO LIST - -* Think of new things to do. diff --git a/configure b/configure index 5a65fc3..f0cf540 100755 --- a/configure +++ b/configure @@ -2107,7 +2107,7 @@ fi # Define the identity of the package. PACKAGE=tinc - VERSION=1.0.6 + VERSION=1.0.7 cat >>confdefs.h <<_ACEOF diff --git a/configure.in b/configure.in index 7a43320..8444ee3 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,7 @@ dnl $Id: configure.in 1488 2006-12-16 16:53:58Z guus $ AC_PREREQ(2.61) AC_INIT AC_CONFIG_SRCDIR([src/tincd.c]) -AM_INIT_AUTOMAKE(tinc, 1.0.6) +AM_INIT_AUTOMAKE(tinc, 1.0.7) AC_CONFIG_HEADERS([config.h]) AM_MAINTAINER_MODE diff --git a/debian/changelog b/debian/changelog index f9ba0e8..449684f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +tinc (1.0.7-1) unstable; urgency=low + + * New upstream release. + + -- Guus Sliepen Fri, 5 Jan 2007 15:55:42 +0100 + tinc (1.0.6-1) unstable; urgency=low * New upstream release. diff --git a/doc/sample-config.tar.gz b/doc/sample-config.tar.gz index 1f3ee64..bc44372 100644 Binary files a/doc/sample-config.tar.gz and b/doc/sample-config.tar.gz differ diff --git a/doc/tinc.info b/doc/tinc.info index cd713be..33f03a6 100644 --- a/doc/tinc.info +++ b/doc/tinc.info @@ -5,7 +5,7 @@ START-INFO-DIR-ENTRY * tinc: (tinc). The tinc Manual. END-INFO-DIR-ENTRY - This is the info manual for tinc version 1.0.6, a Virtual Private + This is the info manual for tinc version 1.0.7, a Virtual Private Network daemon. Copyright (C) 1998-2006 Ivo Timmermans, Guus Sliepen diff --git a/po/nl.gmo b/po/nl.gmo index 16bc2fc..2af40ee 100644 Binary files a/po/nl.gmo and b/po/nl.gmo differ diff --git a/po/nl.po b/po/nl.po index ac9d88e..198f800 100644 --- a/po/nl.po +++ b/po/nl.po @@ -1,13 +1,13 @@ # Dutch messages for tinc -# Copyright (C) 1999-2006 Ivo Timmermans, Guus Sliepen. +# Copyright (C) 1999-2007 Ivo Timmermans, Guus Sliepen. # Ivo Timmermans , 1999-2006. -# Guus Sliepen , 2000-2006. +# Guus Sliepen , 2000-2007. msgid "" msgstr "" "Project-Id-Version: tinc 1.0-svn\n" "Report-Msgid-Bugs-To: tinc-devel@tinc-vpn.org\n" -"POT-Creation-Date: 2006-12-18 13:32+0100\n" -"PO-Revision-Date: 2006-11-11 16:26+0100\n" +"POT-Creation-Date: 2007-01-05 14:14+0100\n" +"PO-Revision-Date: 2007-01-05 14:14+0100\n" "Last-Translator: Guus Sliepen \n" "Language-Team: Dutch\n" "MIME-Version: 1.0\n" @@ -291,9 +291,9 @@ msgstr "Instellen prioriteit uitgaand pakket op %d" #: src/net_socket.c:158 src/tincd.c:435 src/tincd.c:472 src/process.c:198 #: src/process.c:231 src/process.c:428 src/bsd/device.c:93 #: src/bsd/device.c:112 src/cygwin/device.c:140 src/cygwin/device.c:171 -#: src/mingw/device.c:66 src/mingw/device.c:75 src/mingw/device.c:80 -#: src/mingw/device.c:236 src/mingw/device.c:243 src/mingw/device.c:248 -#: src/mingw/device.c:255 src/mingw/device.c:264 src/mingw/device.c:271 +#: src/mingw/device.c:73 src/mingw/device.c:82 src/mingw/device.c:87 +#: src/mingw/device.c:256 src/mingw/device.c:263 src/mingw/device.c:268 +#: src/mingw/device.c:275 src/mingw/device.c:284 src/mingw/device.c:291 #: src/uml_socket/device.c:89 src/uml_socket/device.c:103 #: src/uml_socket/device.c:130 src/uml_socket/device.c:194 #, c-format @@ -982,14 +982,14 @@ msgstr "%s versie %s (gemaakt %s %s, protocol %d)\n" #: src/tincd.c:411 #, c-format msgid "" -"Copyright (C) 1998-2006 Ivo Timmermans, Guus Sliepen and others.\n" +"Copyright (C) 1998-2007 Ivo Timmermans, Guus Sliepen and others.\n" "See the AUTHORS file for a complete list.\n" "\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "and you are welcome to redistribute it under certain conditions;\n" "see the file COPYING for details.\n" msgstr "" -"Copyright (C) 1998-2006 Ivo Timmermans, Guus Sliepen en anderen.\n" +"Copyright (C) 1998-2007 Ivo Timmermans, Guus Sliepen en anderen.\n" "Zie het bestand AUTHORS voor een volledige lijst.\n" "\n" "tinc wordt gedistribueerd ZONDER ENIGE GARANTIE. Dit is vrije " @@ -1368,22 +1368,22 @@ msgstr "%s is een %s" #: src/linux/device.c:133 src/linux/device.c:144 src/linux/device.c:155 #: src/solaris/device.c:125 src/bsd/device.c:152 src/bsd/device.c:181 -#: src/bsd/device.c:210 src/cygwin/device.c:239 src/mingw/device.c:103 -#: src/mingw/device.c:303 src/raw_socket/device.c:102 +#: src/bsd/device.c:210 src/cygwin/device.c:239 src/mingw/device.c:110 +#: src/mingw/device.c:323 src/raw_socket/device.c:102 #: src/uml_socket/device.c:239 #, c-format msgid "Error while reading from %s %s: %s" msgstr "Fout tijdens lezen van %s %s: %s" #: src/linux/device.c:166 src/solaris/device.c:150 src/bsd/device.c:224 -#: src/cygwin/device.c:248 src/mingw/device.c:312 src/raw_socket/device.c:111 +#: src/cygwin/device.c:248 src/mingw/device.c:333 src/raw_socket/device.c:111 #: src/uml_socket/device.c:249 #, c-format msgid "Read packet of %d bytes from %s" msgstr "Pakket van %d bytes gelezen van %s" #: src/linux/device.c:176 src/solaris/device.c:160 src/bsd/device.c:234 -#: src/cygwin/device.c:260 src/mingw/device.c:325 src/raw_socket/device.c:121 +#: src/cygwin/device.c:260 src/mingw/device.c:346 src/raw_socket/device.c:121 #: src/uml_socket/device.c:267 #, c-format msgid "Writing packet of %d bytes to %s" @@ -1397,21 +1397,21 @@ msgid "Can't write to %s %s: %s" msgstr "Kan niet schrijven naar %s %s: %s" #: src/linux/device.c:215 src/solaris/device.c:178 src/bsd/device.c:296 -#: src/cygwin/device.c:277 src/mingw/device.c:342 src/raw_socket/device.c:139 +#: src/cygwin/device.c:277 src/mingw/device.c:363 src/raw_socket/device.c:139 #: src/uml_socket/device.c:288 #, c-format msgid "Statistics for %s %s:" msgstr "Statistieken voor %s %s:" #: src/linux/device.c:216 src/solaris/device.c:179 src/bsd/device.c:297 -#: src/cygwin/device.c:278 src/mingw/device.c:343 src/raw_socket/device.c:140 +#: src/cygwin/device.c:278 src/mingw/device.c:364 src/raw_socket/device.c:140 #: src/uml_socket/device.c:289 #, c-format msgid " total bytes in: %10d" msgstr " totaal aantal bytes in: %10d" #: src/linux/device.c:217 src/solaris/device.c:180 src/bsd/device.c:298 -#: src/cygwin/device.c:279 src/mingw/device.c:344 src/raw_socket/device.c:141 +#: src/cygwin/device.c:279 src/mingw/device.c:365 src/raw_socket/device.c:141 #: src/uml_socket/device.c:290 #, c-format msgid " total bytes out: %10d" @@ -1475,7 +1475,7 @@ msgid "Unknown address family %x while reading packet from %s %s" msgstr "Onbekende adresfamilie %x tijdens ontvangst pakket van %s %s" #: src/bsd/device.c:240 src/bsd/device.c:277 src/cygwin/device.c:264 -#: src/mingw/device.c:329 +#: src/mingw/device.c:350 #, c-format msgid "Error while writing to %s %s: %s" msgstr "Fout tijdens schrijven naar %s %s: %s" @@ -1485,12 +1485,12 @@ msgstr "Fout tijdens schrijven naar %s %s: %s" msgid "Unknown address family %x while writing packet to %s %s" msgstr "Onbekende adresfamiliy %x tijdens versturen pakket naar %s %s" -#: src/cygwin/device.c:71 src/mingw/device.c:147 +#: src/cygwin/device.c:71 src/mingw/device.c:157 #, c-format msgid "Unable to read registry: %s" msgstr "Kon registry niet lezen: %s" -#: src/cygwin/device.c:123 src/mingw/device.c:198 +#: src/cygwin/device.c:123 src/mingw/device.c:208 msgid "No Windows tap device found!" msgstr "Geen Windows tap apparaat gevonden!" @@ -1499,7 +1499,7 @@ msgstr "Geen Windows tap apparaat gevonden!" msgid "Could not open Windows tap device %s (%s) for writing: %s" msgstr "Kon Windows tap apparaat %s (%s) niet openen om te schrijven: %s" -#: src/cygwin/device.c:158 src/mingw/device.c:223 +#: src/cygwin/device.c:158 src/mingw/device.c:233 #, c-format msgid "Could not get MAC address from Windows tap device %s (%s): %s" msgstr "Kon MAC adres niet achterhalen van Windows tap apparaat %s (%s): %s" @@ -1517,20 +1517,20 @@ msgstr "Taplezer is geforked en draait." msgid "Tap reader failed!" msgstr "Taplezer faalde!" -#: src/cygwin/device.c:214 src/mingw/device.c:282 +#: src/cygwin/device.c:214 src/mingw/device.c:302 msgid "Windows tap device" msgstr "Windows tap apparaat" -#: src/cygwin/device.c:216 src/mingw/device.c:284 +#: src/cygwin/device.c:216 src/mingw/device.c:304 #, c-format msgid "%s (%s) is a %s" msgstr "%s (%s) is een %s" -#: src/mingw/device.c:84 +#: src/mingw/device.c:91 msgid "Tap reader running" msgstr "Taplezer draait" -#: src/mingw/device.c:216 +#: src/mingw/device.c:226 #, c-format msgid "%s (%s) is not a usable Windows tap device: %s" msgstr "%s (%s) is geen bruikbaar Windows tap apparaat: %s" diff --git a/po/tinc.pot b/po/tinc.pot index f9c2d4a..1348e4a 100644 --- a/po/tinc.pot +++ b/po/tinc.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: tinc-devel@tinc-vpn.org\n" -"POT-Creation-Date: 2006-12-18 13:32+0100\n" +"POT-Creation-Date: 2007-01-05 14:14+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -283,9 +283,9 @@ msgstr "" #: src/net_socket.c:158 src/tincd.c:435 src/tincd.c:472 src/process.c:198 #: src/process.c:231 src/process.c:428 src/bsd/device.c:93 #: src/bsd/device.c:112 src/cygwin/device.c:140 src/cygwin/device.c:171 -#: src/mingw/device.c:66 src/mingw/device.c:75 src/mingw/device.c:80 -#: src/mingw/device.c:236 src/mingw/device.c:243 src/mingw/device.c:248 -#: src/mingw/device.c:255 src/mingw/device.c:264 src/mingw/device.c:271 +#: src/mingw/device.c:73 src/mingw/device.c:82 src/mingw/device.c:87 +#: src/mingw/device.c:256 src/mingw/device.c:263 src/mingw/device.c:268 +#: src/mingw/device.c:275 src/mingw/device.c:284 src/mingw/device.c:291 #: src/uml_socket/device.c:89 src/uml_socket/device.c:103 #: src/uml_socket/device.c:130 src/uml_socket/device.c:194 #, c-format @@ -944,7 +944,7 @@ msgstr "" #: src/tincd.c:411 #, c-format msgid "" -"Copyright (C) 1998-2006 Ivo Timmermans, Guus Sliepen and others.\n" +"Copyright (C) 1998-2007 Ivo Timmermans, Guus Sliepen and others.\n" "See the AUTHORS file for a complete list.\n" "\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" @@ -1308,22 +1308,22 @@ msgstr "" #: src/linux/device.c:133 src/linux/device.c:144 src/linux/device.c:155 #: src/solaris/device.c:125 src/bsd/device.c:152 src/bsd/device.c:181 -#: src/bsd/device.c:210 src/cygwin/device.c:239 src/mingw/device.c:103 -#: src/mingw/device.c:303 src/raw_socket/device.c:102 +#: src/bsd/device.c:210 src/cygwin/device.c:239 src/mingw/device.c:110 +#: src/mingw/device.c:323 src/raw_socket/device.c:102 #: src/uml_socket/device.c:239 #, c-format msgid "Error while reading from %s %s: %s" msgstr "" #: src/linux/device.c:166 src/solaris/device.c:150 src/bsd/device.c:224 -#: src/cygwin/device.c:248 src/mingw/device.c:312 src/raw_socket/device.c:111 +#: src/cygwin/device.c:248 src/mingw/device.c:333 src/raw_socket/device.c:111 #: src/uml_socket/device.c:249 #, c-format msgid "Read packet of %d bytes from %s" msgstr "" #: src/linux/device.c:176 src/solaris/device.c:160 src/bsd/device.c:234 -#: src/cygwin/device.c:260 src/mingw/device.c:325 src/raw_socket/device.c:121 +#: src/cygwin/device.c:260 src/mingw/device.c:346 src/raw_socket/device.c:121 #: src/uml_socket/device.c:267 #, c-format msgid "Writing packet of %d bytes to %s" @@ -1337,21 +1337,21 @@ msgid "Can't write to %s %s: %s" msgstr "" #: src/linux/device.c:215 src/solaris/device.c:178 src/bsd/device.c:296 -#: src/cygwin/device.c:277 src/mingw/device.c:342 src/raw_socket/device.c:139 +#: src/cygwin/device.c:277 src/mingw/device.c:363 src/raw_socket/device.c:139 #: src/uml_socket/device.c:288 #, c-format msgid "Statistics for %s %s:" msgstr "" #: src/linux/device.c:216 src/solaris/device.c:179 src/bsd/device.c:297 -#: src/cygwin/device.c:278 src/mingw/device.c:343 src/raw_socket/device.c:140 +#: src/cygwin/device.c:278 src/mingw/device.c:364 src/raw_socket/device.c:140 #: src/uml_socket/device.c:289 #, c-format msgid " total bytes in: %10d" msgstr "" #: src/linux/device.c:217 src/solaris/device.c:180 src/bsd/device.c:298 -#: src/cygwin/device.c:279 src/mingw/device.c:344 src/raw_socket/device.c:141 +#: src/cygwin/device.c:279 src/mingw/device.c:365 src/raw_socket/device.c:141 #: src/uml_socket/device.c:290 #, c-format msgid " total bytes out: %10d" @@ -1415,7 +1415,7 @@ msgid "Unknown address family %x while reading packet from %s %s" msgstr "" #: src/bsd/device.c:240 src/bsd/device.c:277 src/cygwin/device.c:264 -#: src/mingw/device.c:329 +#: src/mingw/device.c:350 #, c-format msgid "Error while writing to %s %s: %s" msgstr "" @@ -1425,12 +1425,12 @@ msgstr "" msgid "Unknown address family %x while writing packet to %s %s" msgstr "" -#: src/cygwin/device.c:71 src/mingw/device.c:147 +#: src/cygwin/device.c:71 src/mingw/device.c:157 #, c-format msgid "Unable to read registry: %s" msgstr "" -#: src/cygwin/device.c:123 src/mingw/device.c:198 +#: src/cygwin/device.c:123 src/mingw/device.c:208 msgid "No Windows tap device found!" msgstr "" @@ -1439,7 +1439,7 @@ msgstr "" msgid "Could not open Windows tap device %s (%s) for writing: %s" msgstr "" -#: src/cygwin/device.c:158 src/mingw/device.c:223 +#: src/cygwin/device.c:158 src/mingw/device.c:233 #, c-format msgid "Could not get MAC address from Windows tap device %s (%s): %s" msgstr "" @@ -1457,20 +1457,20 @@ msgstr "" msgid "Tap reader failed!" msgstr "" -#: src/cygwin/device.c:214 src/mingw/device.c:282 +#: src/cygwin/device.c:214 src/mingw/device.c:302 msgid "Windows tap device" msgstr "" -#: src/cygwin/device.c:216 src/mingw/device.c:284 +#: src/cygwin/device.c:216 src/mingw/device.c:304 #, c-format msgid "%s (%s) is a %s" msgstr "" -#: src/mingw/device.c:84 +#: src/mingw/device.c:91 msgid "Tap reader running" msgstr "" -#: src/mingw/device.c:216 +#: src/mingw/device.c:226 #, c-format msgid "%s (%s) is not a usable Windows tap device: %s" msgstr "" diff --git a/src/bsd/device.c b/src/bsd/device.c index 8649d89..5bd253c 100644 --- a/src/bsd/device.c +++ b/src/bsd/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction BSD tun/tap device Copyright (C) 2001-2005 Ivo Timmermans, - 2001-2006 Guus Sliepen + 2001-2007 Guus Sliepen 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 @@ -245,7 +245,7 @@ bool write_packet(vpn_packet_t *packet) case DEVICE_TYPE_TUNIFHEAD: { u_int32_t type; - struct iovec vector[2] = {{&type, sizeof(type)}, {packet->data + 14, MTU - 14}}; + struct iovec vector[2] = {{&type, sizeof(type)}, {packet->data + 14, packet->len - 14}}; int af; af = (packet->data[12] << 8) + packet->data[13]; diff --git a/src/graph.c b/src/graph.c index 259d715..10b3656 100644 --- a/src/graph.c +++ b/src/graph.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: graph.c 1476 2006-12-12 14:54:39Z guus $ + $Id: graph.c 1494 2007-01-05 05:44:01Z guus $ */ /* We need to generate two trees from the graph: @@ -374,6 +374,9 @@ void dump_graph(void) pclose(file); } else { fclose(file); +#ifdef HAVE_MINGW + unlink(filename); +#endif rename(tmpname, filename); free(tmpname); } diff --git a/src/mingw/device.c b/src/mingw/device.c index 388e9d5..c9fdc27 100644 --- a/src/mingw/device.c +++ b/src/mingw/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction with Windows tap driver in a MinGW environment Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2006 Guus Sliepen + 2002-2007 Guus Sliepen 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 @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c 1452 2006-04-26 13:52:58Z guus $ + $Id: device.c 1496 2007-01-05 13:18:36Z guus $ */ #include "system.h" @@ -45,16 +45,23 @@ static int device_total_out = 0; extern char *myport; +static struct packetbuf { + uint8_t data[MTU]; + length_t len; +} *bufs; + +static int nbufs = 64; + DWORD WINAPI tapreader(void *bla) { int sock, err, status; struct addrinfo *ai; struct addrinfo hint = { .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_DGRAM, - .ai_protocol = IPPROTO_UDP, + .ai_socktype = SOCK_STREAM, + .ai_protocol = IPPROTO_TCP, .ai_flags = 0, }; - char buf[MTU]; + unsigned char bufno = 0; long len; OVERLAPPED overlapped; @@ -67,7 +74,7 @@ DWORD WINAPI tapreader(void *bla) { return -1; } - sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); + sock = socket(ai->ai_family, SOCK_STREAM, IPPROTO_TCP); freeaddrinfo(ai); @@ -92,7 +99,7 @@ DWORD WINAPI tapreader(void *bla) { overlapped.OffsetHigh = 0; ResetEvent(overlapped.hEvent); - status = ReadFile(device_handle, buf, sizeof(buf), &len, &overlapped); + status = ReadFile(device_handle, bufs[bufno].data, MTU, &len, &overlapped); if(!status) { if(GetLastError() == ERROR_IO_PENDING) { @@ -106,8 +113,11 @@ DWORD WINAPI tapreader(void *bla) { } } - if(send(sock, buf, len, 0) <= 0) + bufs[bufno].len = len; + if(send(sock, &bufno, 1, 0) <= 0) return -1; + if(++bufno >= nbufs) + bufno = 0; } } @@ -131,8 +141,8 @@ bool setup_device(void) struct addrinfo *ai; struct addrinfo hint = { .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_DGRAM, - .ai_protocol = IPPROTO_UDP, + .ai_socktype = SOCK_STREAM, + .ai_protocol = IPPROTO_TCP, .ai_flags = 0, }; @@ -228,6 +238,16 @@ bool setup_device(void) overwrite_mac = 1; } + /* Set up ringbuffer */ + + get_config_int(lookup_config(config_tree, "RingBufferSize"), &nbufs); + if(nbufs <= 1) + nbufs = 1; + else if(nbufs > 256) + nbufs = 256; + + bufs = xmalloc_and_zero(nbufs * sizeof *bufs); + /* Create a listening socket */ err = getaddrinfo(NULL, myport, &hint, &ai); @@ -237,7 +257,7 @@ bool setup_device(void) return false; } - sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); + sock = socket(ai->ai_family, SOCK_STREAM, IPPROTO_TCP); if(sock < 0) { logger(LOG_ERR, _("System call `%s' failed: %s"), "socket", strerror(errno)); @@ -295,17 +315,18 @@ void close_device(void) bool read_packet(vpn_packet_t *packet) { - int lenin; + unsigned char bufno; cp(); - if((lenin = recv(device_fd, packet->data, MTU, 0)) <= 0) { + if((recv(device_fd, &bufno, 1, 0)) <= 0) { logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, device, strerror(errno)); return false; } - packet->len = lenin; + packet->len = bufs[bufno].len; + memcpy(packet->data, bufs[bufno].data, bufs[bufno].len); device_total_in += packet->len; diff --git a/src/tincd.c b/src/tincd.c index b902af4..d0d15c3 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -1,7 +1,7 @@ /* tincd.c -- the main file for tincd Copyright (C) 1998-2005 Ivo Timmermans - 2000-2006 Guus Sliepen + 2000-2007 Guus Sliepen 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 @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: tincd.c 1474 2006-11-29 17:18:39Z guus $ + $Id: tincd.c 1496 2007-01-05 13:18:36Z guus $ */ #include "system.h" @@ -408,7 +408,7 @@ int main(int argc, char **argv) if(show_version) { printf(_("%s version %s (built %s %s, protocol %d)\n"), PACKAGE, VERSION, __DATE__, __TIME__, PROT_CURRENT); - printf(_("Copyright (C) 1998-2006 Ivo Timmermans, Guus Sliepen and others.\n" + printf(_("Copyright (C) 1998-2007 Ivo Timmermans, Guus Sliepen and others.\n" "See the AUTHORS file for a complete list.\n\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "and you are welcome to redistribute it under certain conditions;\n"