├── ABOUT-NLS ├── AUTHORS ├── COPYING ├── ChangeLog ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── TODO ├── autogen.sh ├── config.h.in ├── config.rpath ├── configure ├── configure.ac ├── debian ├── Makefile ├── Makefile.am ├── Makefile.in ├── README.Debian ├── changelog ├── control ├── copyright ├── dirs ├── if-up ├── rules ├── vpe.dirs └── vpe.files ├── doc ├── GNUmakefile ├── Makefile.am ├── Makefile.in ├── Makefile.maint ├── complex-example │ ├── README │ ├── gvpe.conf │ ├── if-up │ └── node-up ├── gvpe.5 ├── gvpe.5.pod ├── gvpe.8 ├── gvpe.8.pod ├── gvpe.conf.5 ├── gvpe.conf.5.pod ├── gvpe.osdep.5.pod ├── gvpe.protocol.7 ├── gvpe.protocol.7.pod ├── gvpe.texi ├── gvpe.texi.pod ├── gvpectrl.8 ├── gvpectrl.8.pod └── pod2texi ├── lib ├── Makefile.am ├── Makefile.in ├── alloca.c ├── dropin.c ├── dropin.h ├── getopt.c ├── getopt.h ├── getopt1.c ├── gettext.h ├── pidfile.c └── pidfile.h ├── m4 ├── ChangeLog ├── Makefile.am.in ├── Makefile.in ├── README ├── aclocal-include.m4 ├── codeset.m4 ├── gettext.m4 ├── glibc21.m4 ├── iconv.m4 ├── intdiv0.m4 ├── inttypes-pri.m4 ├── inttypes.m4 ├── inttypes_h.m4 ├── isc-posix.m4 ├── lcmessage.m4 ├── lib-ld.m4 ├── lib-link.m4 ├── lib-prefix.m4 ├── openssl.m4 ├── progtest.m4 ├── stdint_h.m4 ├── tuntap.m4 ├── uintmax_t.m4 └── ulonglong.m4 ├── mkdistro ├── po ├── ChangeLog ├── Makefile.in.in ├── Makevars ├── Makevars.template ├── POTFILES.in ├── Rules-quot ├── boldquot.sed ├── en@boldquot.header ├── en@quot.header ├── insert-header.sin ├── quot.sed └── remove-potcdate.sin └── src ├── Makefile.am ├── Makefile.in ├── callback.h ├── callback.pl ├── conf.C ├── conf.h ├── connection.C ├── connection.h ├── device-cygwin.C ├── device-darwin.C ├── device-linux.C ├── device-tincd.C ├── device.C ├── device.h ├── ether_emu.C ├── ev_cpp.C ├── ev_cpp.h ├── global.h ├── gvpe.C ├── gvpectrl.C ├── lzf ├── lzf.h ├── lzfP.h ├── lzf_c.c └── lzf_d.c ├── netcompat.h ├── rohc ├── Makefile.am ├── c_ip.c ├── c_udp.c ├── c_udp_lite.c ├── c_uncompressed.c ├── c_util.c ├── c_util.h ├── comp.c ├── comp.h ├── d_ip.c ├── d_ip.h ├── d_udp.c ├── d_udp.h ├── d_udp_lite.c ├── d_udp_lite.h ├── d_uncompressed.c ├── d_uncompressed.h ├── d_util.c ├── d_util.h ├── decomp.c ├── decomp.h ├── feedback.c ├── feedback.h └── rohc.h ├── slog.C ├── slog.h ├── sockinfo.C ├── sockinfo.h ├── tincd ├── apply ├── bsd │ └── device.c ├── cygwin │ └── device.c ├── darwin │ └── device.c ├── fixit ├── freebsd │ └── device.c ├── linux │ └── device.c ├── mingw │ ├── common.h │ └── device.c ├── netbsd │ └── device.c ├── openbsd │ └── device.c ├── raw_socket │ └── device.c ├── solaris │ └── device.c └── uml_socket │ └── device.c ├── util.C ├── util.h ├── vpn.C ├── vpn.h ├── vpn_dns.C └── vpn_tcp.C /AUTHORS: -------------------------------------------------------------------------------- 1 | Gvpe Author: 2 | 3 | Marc Lehmann 4 | 5 | Although the actual gvpe code was completely rewritten, some configure 6 | macros and were taken from the tinc package, by Guus Sliepen 7 | and Ivo Timmermans . 8 | 9 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | This file is unused, see the NEWS file for changes (and add documentation 2 | for any changes there). 3 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to get Makefile.in 2 | 3 | AUTOMAKE_OPTIONS = gnu 4 | 5 | SUBDIRS = m4 lib src doc po 6 | 7 | ACLOCAL_AMFLAGS = -I m4 8 | 9 | EXTRA_DIST = config.rpath mkinstalldirs depcomp TODO \ 10 | libev/ev.c libev/ev.h libev/libev.m4 libev/ev++.h \ 11 | libev/ev_epoll.c libev/ev_kqueue.c libev/ev_poll.c libev/ev_select.c \ 12 | libev/ev_vars.h libev/ev_win32.c libev/ev_wrap.h 13 | 14 | CVS_CREATED = ABOUT-NLS configure aclocal.m4 config.h.in config.guess \ 15 | config.sub install-sh missing mkinstalldirs \ 16 | stamp-h.in m4/Makefile.am po/Makefile.in.in \ 17 | po/vpe.pot po/*.sed po/*.header po/*.sin po/Rules-quot \ 18 | src/.libs intl depcomp 19 | 20 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | TODO items: 2 | 3 | :establish_connection_cb might call send_connect_request 4 | which might call :establish_connection_cb recursively. 5 | 6 | #4 0x000000000040af01 in time_watcher::trigger (this=0x52e198) at callback.h:141 7 | #5 0x0000000000403e7a in vpn::send_connect_request (this=0x51a6e0, id=5436496) at iom.h:154 8 | #6 0x000000000040e2b7 in connection::establish_connection_cb (this=0x52dff0, w=@0x52e198) at connection.C:764 9 | #7 0x000000000040fa59 in callback1::proxy::call (this=0x52e2a0, obj=0x52e2a0, meth= 10 | (void ( struct callback1::object::*)(time_watcher &,)) 531452, a1=@0x52f450) at callback.h:122 11 | #8 0x000000000040af01 in time_watcher::trigger (this=0x52e198) at callback.h:141 12 | #9 0x0000000000403e7a in vpn::send_connect_request (this=0x51a6e0, id=5436496) at iom.h:154 13 | #10 0x000000000040e2b7 in connection::establish_connection_cb (this=0x52dff0, w=@0x52e198) at connection.C:764 14 | #11 0x000000000040fa59 in callback1::proxy::call (this=0x52e2a0, obj=0x52e2a0, meth= 15 | (void ( struct callback1::object::*)(time_watcher &,)) 531452, a1=@0x52f450) at callback.h:122 16 | #12 0x000000000040af01 in time_watcher::trigger (this=0x52e198) at callback.h:141 17 | #13 0x0000000000403e7a in vpn::send_connect_request (this=0x51a6e0, id=5436496) at iom.h:154 18 | #14 0x000000000040e2b7 in connection::establish_connection_cb (this=0x52dff0, w=@0x52e198) at connection.C:764 19 | #15 0x000000000040fa59 in callback1::proxy::call (this=0x52e2a0, obj=0x52e2a0, meth= 20 | (void ( struct callback1::object::*)(time_watcher &,)) 531452, a1=@0x52f450) at callback.h:122 21 | #16 0x000000000040af01 in time_watcher::trigger (this=0x52e198) at callback.h:141 22 | #17 0x0000000000403e7a in vpn::send_connect_request (this=0x51a6e0, id=5436496) at iom.h:154 23 | #18 0x000000000040e2b7 in connection::establish_connection_cb (this=0x52dff0, w=@0x52e198) at connection.C:764 24 | #19 0x000000000040fa59 in callback1::proxy::call (this=0x52e2a0, obj=0x52e2a0, meth= 25 | (void ( struct callback1::object::*)(time_watcher &,)) 531452, a1=@0x52f450) at callback.h:122 26 | #20 0x000000000040af01 in time_watcher::trigger (this=0x52e198) at callback.h:141 27 | #21 0x0000000000403e7a in vpn::send_connect_request (this=0x51a6e0, id=5436496) at iom.h:154 28 | #22 0x000000000040e2b7 in connection::establish_connection_cb (this=0x52dff0, w=@0x52e198) at connection.C:764 29 | #23 0x000000000040fa59 in callback1::proxy::call (this=0x52e2a0, obj=0x52e2a0, meth= 30 | (void ( struct callback1::object::*)(time_watcher &,)) 531452, a1=@0x52f450) at callback.h:122 31 | #24 0x000000000040af01 in time_watcher::trigger (this=0x52e198) at callback.h:141 32 | #25 0x0000000000403e7a in vpn::send_connect_request (this=0x51a6e0, id=5436496) at iom.h:154 33 | #26 0x000000000040e2b7 in connection::establish_connection_cb (this=0x52dff0, w=@0x52e198) at connection.C:764 34 | #27 0x000000000040fa59 in callback1::proxy::call (this=0x52e2a0, obj=0x52e2a0, meth= 35 | (void ( struct callback1::object::*)(time_watcher &,)) 531452, a1=@0x52f450) at callback.h:122 36 | #28 0x000000000040af01 in time_watcher::trigger (this=0x52e198) at callback.h:141 37 | #29 0x0000000000403e7a in vpn::send_connect_request (this=0x51a6e0, id=5436496) at iom.h:154 38 | #30 0x000000000040e2b7 in connection::establish_connection_cb (this=0x52dff0, w=@0x52e198) at connection.C:764 39 | 40 | 41 | - kill -USR1 should not reconnect but just refresh with pinging 42 | - mac=xxxxx config directive, to allow windows etc. 43 | - on shell xyz 44 | - add a general vpn introduction to the manual 45 | - reformat the texinfo manual to look less manpagish 46 | - use gnutls instead of openssl 47 | 48 | - vped => starts without error message but fails to connect 49 | - should tets own hostkey for validity 50 | - re-bind() on HUP 51 | - Feb 26 18:48:31 (none) modprobe: modprobe: Can't locate module  (^E^H( 52 | 53 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | AUTOCONF_REQUIRED_VERSION=2.57 4 | AUTOMAKE_REQUIRED_VERSION=1.7 5 | INTLTOOL_REQUIRED_VERSION=0.17 6 | 7 | if ! [ -e libev/ev++.h ]; then 8 | cat <= $2 > /dev/null; then 28 | echo "yes (version $1)" 29 | else 30 | echo "Too old (found version $1)!" 31 | # DIE=1 32 | fi 33 | } 34 | 35 | DIE=0 36 | 37 | echo -n "checking for autoconf >= $AUTOCONF_REQUIRED_VERSION ... " 38 | if (autoconf --version) < /dev/null > /dev/null 2>&1; then 39 | VER=`autoconf --version \ 40 | | grep -iw autoconf | sed "s/.* \([0-9.]*\)[-a-z0-9]*$/\1/"` 41 | check_version $VER $AUTOCONF_REQUIRED_VERSION 42 | else 43 | echo 44 | echo " You must have autoconf installed to compile $PROJECT." 45 | echo " Download the appropriate package for your distribution," 46 | echo " or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" 47 | DIE=1; 48 | fi 49 | 50 | echo -n "checking for automake >= $AUTOMAKE_REQUIRED_VERSION ... " 51 | if (automake-1.7 --version) < /dev/null > /dev/null 2>&1; then 52 | AUTOMAKE=automake-1.7 53 | ACLOCAL=aclocal-1.7 54 | else 55 | echo 56 | echo " You must have automake 1.7 installed to compile $PROJECT." 57 | # DIE=1 58 | fi 59 | 60 | if test x$AUTOMAKE != x; then 61 | VER=`$AUTOMAKE --version \ 62 | | grep automake | sed "s/.* \([0-9.]*\)[-a-z0-9]*$/\1/"` 63 | check_version $VER $AUTOMAKE_REQUIRED_VERSION 64 | fi 65 | 66 | : <= $INTLTOOL_REQUIRED_VERSION ... " 68 | if (intltoolize --version) < /dev/null > /dev/null 2>&1; then 69 | VER=`intltoolize --version \ 70 | | grep intltoolize | sed "s/.* \([0-9.]*\)/\1/"` 71 | check_version $VER $INTLTOOL_REQUIRED_VERSION 72 | else 73 | echo 74 | echo " You must have intltool installed to compile $PROJECT." 75 | echo " Get the latest version from" 76 | echo " ftp://ftp.gnome.org/pub/GNOME/sources/intltool/" 77 | DIE=1 78 | fi 79 | EOF 80 | 81 | if test "$DIE" -eq 1; then 82 | echo 83 | echo "Please install/upgrade the missing tools and call me again." 84 | echo 85 | exit 1 86 | fi 87 | 88 | if test -z "$*"; then 89 | echo 90 | echo "I am going to run ./configure with no arguments - if you wish " 91 | echo "to pass any to it, please specify them on the $0 command line." 92 | echo 93 | fi 94 | 95 | $ACLOCAL -I m4 96 | 97 | # optionally feature autoheader 98 | (autoheader --version) < /dev/null > /dev/null 2>&1 && autoheader 99 | 100 | (cd m4 && make -f Makefile.am.in Makefile.am) 101 | touch doc/gvpe.texi 102 | $AUTOMAKE -f --add-missing 103 | rm doc/gvpe.texi 104 | autoconf 105 | autoheader 106 | 107 | #intltoolize --copy --force --automake 108 | 109 | cd $ORIGDIR 110 | 111 | if [ -e reconf ]; then 112 | ./reconf "$@" 113 | elif $srcdir/configure --enable-maintainer-mode "$@"; then 114 | echo 115 | echo "Now type 'make' to compile $PROJECT." 116 | else 117 | echo 118 | echo "Configure failed or did not finish!" 119 | fi 120 | 121 | -------------------------------------------------------------------------------- /debian/Makefile: -------------------------------------------------------------------------------- 1 | # Generated automatically from Makefile.in by configure. 2 | # Makefile.in generated automatically by automake 1.4 from Makefile.am 3 | 4 | # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. 5 | # This Makefile.in is free software; the Free Software Foundation 6 | # gives unlimited permission to copy and/or distribute it, 7 | # with or without modifications, as long as this notice is preserved. 8 | 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 11 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12 | # PARTICULAR PURPOSE. 13 | 14 | 15 | SHELL = /bin/sh 16 | 17 | srcdir = . 18 | top_srcdir = .. 19 | prefix = /usr 20 | exec_prefix = ${prefix} 21 | 22 | bindir = ${exec_prefix}/bin 23 | sbindir = ${exec_prefix}/sbin 24 | libexecdir = ${exec_prefix}/libexec 25 | datadir = ${prefix}/share 26 | sysconfdir = /etc 27 | sharedstatedir = ${prefix}/com 28 | localstatedir = /var 29 | libdir = ${exec_prefix}/lib 30 | infodir = ${prefix}/share/info 31 | mandir = ${prefix}/share/man 32 | includedir = ${prefix}/include 33 | oldincludedir = /usr/include 34 | 35 | DESTDIR = 36 | 37 | pkgdatadir = $(datadir)/vpe 38 | pkglibdir = $(libdir)/vpe 39 | pkgincludedir = $(includedir)/vpe 40 | 41 | top_builddir = .. 42 | 43 | ACLOCAL = aclocal -I m4 44 | AUTOCONF = autoconf 45 | AUTOMAKE = automake 46 | AUTOHEADER = autoheader 47 | 48 | INSTALL = /usr/bin/install -c 49 | INSTALL_PROGRAM = ${INSTALL} $(AM_INSTALL_PROGRAM_FLAGS) 50 | INSTALL_DATA = ${INSTALL} -m 644 51 | INSTALL_SCRIPT = ${INSTALL_PROGRAM} 52 | transform = s,x,x, 53 | 54 | NORMAL_INSTALL = : 55 | PRE_INSTALL = : 56 | POST_INSTALL = : 57 | NORMAL_UNINSTALL = : 58 | PRE_UNINSTALL = : 59 | POST_UNINSTALL = : 60 | host_alias = i586-pc-linux-gnu 61 | host_triplet = i586-pc-linux-gnu 62 | AS = @AS@ 63 | AWK = mawk 64 | CATALOGS = es.gmo nl.gmo 65 | CATOBJEXT = .gmo 66 | CC = gcc 67 | CPP = gcc -E 68 | DATADIRNAME = share 69 | DLLTOOL = @DLLTOOL@ 70 | GENCAT = 71 | GMOFILES = es.gmo nl.gmo 72 | GMSGFMT = /usr/bin/msgfmt 73 | GT_NO = 74 | GT_YES = #YES# 75 | HAVE_TUNTAP = 76 | INCLUDE_LOCALE_H = #include 77 | INSTOBJEXT = .mo 78 | INTLDEPS = 79 | INTLLIBS = 80 | INTLOBJS = 81 | LIBTOOL = @LIBTOOL@ 82 | LINUX_IF_TUN_H = 83 | LN_S = ln -s 84 | MAKEINFO = makeinfo 85 | MKINSTALLDIRS = ./mkinstalldirs 86 | MSGFMT = /usr/bin/msgfmt 87 | OBJDUMP = @OBJDUMP@ 88 | PACKAGE = vpe 89 | PERL = perl 90 | POFILES = es.po nl.po 91 | POSUB = po 92 | RANLIB = ranlib 93 | USE_INCLUDED_LIBINTL = no 94 | USE_NLS = yes 95 | VERSION = 1.0-cvs 96 | l = 97 | 98 | EXTRA_DIST = README.Debian changelog conffiles control copyright dirs docs info init.d rules 99 | 100 | mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs 101 | CONFIG_HEADER = ../config.h 102 | CONFIG_CLEAN_FILES = 103 | DIST_COMMON = Makefile.am Makefile.in 104 | 105 | 106 | DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) 107 | 108 | TAR = tar 109 | GZIP_ENV = --best 110 | all: all-redirect 111 | .SUFFIXES: 112 | $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 113 | cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps debian/Makefile 114 | 115 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 116 | cd $(top_builddir) \ 117 | && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status 118 | 119 | tags: TAGS 120 | TAGS: 121 | 122 | 123 | distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) 124 | 125 | subdir = debian 126 | 127 | distdir: $(DISTFILES) 128 | @for file in $(DISTFILES); do \ 129 | d=$(srcdir); \ 130 | if test -d $$d/$$file; then \ 131 | cp -pr $$d/$$file $(distdir)/$$file; \ 132 | else \ 133 | test -f $(distdir)/$$file \ 134 | || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ 135 | || cp -p $$d/$$file $(distdir)/$$file || :; \ 136 | fi; \ 137 | done 138 | info-am: 139 | info: info-am 140 | dvi-am: 141 | dvi: dvi-am 142 | check-am: all-am 143 | check: check-am 144 | installcheck-am: 145 | installcheck: installcheck-am 146 | install-exec-am: 147 | install-exec: install-exec-am 148 | 149 | install-data-am: 150 | install-data: install-data-am 151 | 152 | install-am: all-am 153 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 154 | install: install-am 155 | uninstall-am: 156 | uninstall: uninstall-am 157 | all-am: Makefile 158 | all-redirect: all-am 159 | install-strip: 160 | $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install 161 | installdirs: 162 | 163 | 164 | mostlyclean-generic: 165 | 166 | clean-generic: 167 | 168 | distclean-generic: 169 | -rm -f Makefile $(CONFIG_CLEAN_FILES) 170 | -rm -f config.cache config.log stamp-h stamp-h[0-9]* 171 | 172 | maintainer-clean-generic: 173 | mostlyclean-am: mostlyclean-generic 174 | 175 | mostlyclean: mostlyclean-am 176 | 177 | clean-am: clean-generic mostlyclean-am 178 | 179 | clean: clean-am 180 | 181 | distclean-am: distclean-generic clean-am 182 | -rm -f libtool 183 | 184 | distclean: distclean-am 185 | 186 | maintainer-clean-am: maintainer-clean-generic distclean-am 187 | @echo "This command is intended for maintainers to use;" 188 | @echo "it deletes files that may require special tools to rebuild." 189 | 190 | maintainer-clean: maintainer-clean-am 191 | 192 | .PHONY: tags distdir info-am info dvi-am dvi check check-am \ 193 | installcheck-am installcheck install-exec-am install-exec \ 194 | install-data-am install-data install-am install uninstall-am uninstall \ 195 | all-redirect all-am all installdirs mostlyclean-generic \ 196 | distclean-generic clean-generic maintainer-clean-generic clean \ 197 | mostlyclean distclean maintainer-clean 198 | 199 | 200 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 201 | # Otherwise a system limit (for SysV at least) may be exceeded. 202 | .NOEXPORT: 203 | -------------------------------------------------------------------------------- /debian/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = changelog copyright dirs rules README.Debian 2 | -------------------------------------------------------------------------------- /debian/README.Debian: -------------------------------------------------------------------------------- 1 | vpe for Debian 2 | ---------------------- 3 | 4 | The system startup script for vpe, /etc/init.d/vpe, uses the file 5 | /etc/vpe/vped.conf as configuration file 6 | 7 | -- Paul Bettinger , Mon, 10 Mar 2003, 12:38:45 +0200 8 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | vpe (0.1-2.0) unstable; urgency=low 2 | 3 | * updating debian files. 4 | * change to protcol 2.0 5 | 6 | -- Paul Bettinger Mon, 10 Mar 2003 12:38:45 +0200 7 | 8 | vpe (0.1-1.0) unstable; urgency=low 9 | 10 | * Initial Release. 11 | 12 | -- Paul Bettinger Tue, 25 Feb 2003 00:13:56 +0200 13 | 14 | 15 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: vpe 2 | Section: net 3 | Priority: optional 4 | Maintainer: Paul Bettinger 5 | Standards-Version: 3.5.6 6 | Build-Depends: libssl-dev, autoconf (>= 2.12), automake, debhelper, libtool, gettext, texi2html, zlib1g-dev 7 | 8 | Package: vpe 9 | Architecture: any 10 | Depends: debconf, ${shlibs:Depends} 11 | Description: Virtual Private Network daemon 12 | vpe is a daemon with which you can create a virtual private network 13 | (VPN). One daemon can handle multiple connections, so you can 14 | create an entire (moderately sized) VPN with only one daemon per 15 | participating computer. 16 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by Paul Bettinger on 2 | Tue Feb 25 2003 00:13:56 +0200. 3 | 4 | It was downloaded from cvs 5 | 6 | Upstream Author(s): 7 | Marc Lehmann 8 | 9 | Copyright: GPL version 2. On Debian GNU/Linux systems, the complete 10 | text of the GNU General Public License can be found in 11 | /usr/share/common-licenses/GPL. 12 | -------------------------------------------------------------------------------- /debian/dirs: -------------------------------------------------------------------------------- 1 | etc/vpe 2 | etc/vpe/hostkeys 3 | etc/vpe/pubkeys 4 | -------------------------------------------------------------------------------- /debian/if-up: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Sample if-up 4 | 5 | # Some environment variables will be set: 6 | # 7 | # CONFBASE=/etc/vpe # the configuration directory prefix 8 | # IFNAME=vpn0 # the network interface (ifname) 9 | # MAC=fe:fd:80:00:00:01 # the mac-address to use for the interface 10 | # NODENAME=cerebro # the selected nodename (-n switch) 11 | # NODEID=1 # the numerical node id 12 | # MTU=1436 # the tunnel packet overhead (set mtu to 1500-$OVERHEAD) 13 | 14 | # with the --fw switch, outputs mac/net pairs for your firewall use: 15 | # if-up --fw | while read mac net; do 16 | # iptables -t filter -A INPUT -i vpn0 -p all -m mac --mac-source \! $mac -s $net -j DROP 17 | # done 18 | 19 | ipn() { 20 | local id="$1"; shift 21 | local mac=fe:fd:80:00:00:$(printf "%02x" $id) 22 | if [ -n "$FW" ]; then 23 | for net in "$@"; do 24 | echo "$mac $net" 25 | done 26 | else 27 | local ip="$1"; shift 28 | if [ "$id" == $NODEID ]; then 29 | [ -n "$ADDR_ONLY" ] && ip addr add $ip broadcast 10.255.255.255 dev $IFNAME 30 | elif [ -z "$ADDR_ONLY" ]; then 31 | ip neighbour add $ip lladdr $mac nud permanent dev $IFNAME 32 | for route in "$@"; do 33 | ip route add $route via $ip dev vpn0 34 | done 35 | fi 36 | fi 37 | } 38 | 39 | ipns() { 40 | ipn 1 10.0.0.20 41 | ipn 2 10.0.0.5 10.0.0.0/28 129.13.162.92 129.13.162.93 213.69.218.222 42 | ipn 3 10.0.0.17 43 | ipn 4 10.0.0.18 44 | ipn 5 10.0.0.19 45 | ipn 6 10.0.0.21 10.0.2.0/26 129.13.162.17 46 | ipn 7 10.0.0.22 10.1.2.0/24 47 | ipn 8 10.0.0.23 48 | ipn 9 10.0.0.24 10.13.0.0/16 49 | ipn 10 10.0.0.25 50 | ipn 11 10.0.0.26 51 | ipn 12 10.0.0.27 10.0.2.64/26 52 | ipn 13 10.0.0.28 53 | ipn 14 10.0.0.29 10.1.1.0/24 54 | } 55 | 56 | if [ "$1" == "--fw" ]; then 57 | FW=1 58 | 59 | ipns 60 | else 61 | exec >/var/log/vpe.if-up 2>&1 62 | set -x 63 | 64 | [ $NODENAME = "ruth" ] && ip link set $IFNAME down # hack 65 | 66 | ip link set $IFNAME address $MAC mtu $MTU up 67 | ADDR_ONLY=1 ipns # set addr only 68 | 69 | ip route add 10.0.0.0/8 dev $IFNAME 70 | ip route add 10.0.0.0/27 dev $IFNAME 71 | 72 | ipns # set routes 73 | 74 | echo 0 >/proc/sys/net/ipv4/conf/vpn0/proxy_arp 75 | 76 | if [ $NODENAME = doom ]; then 77 | ip addr add 129.13.162.92 dev $IFNAME 78 | ip route add 129.13.0.0/16 via 10.0.0.17 dev $IFNAME 79 | ip route flush table 101 80 | ip route add table 101 default src 129.13.162.92 via 10.0.0.17 81 | 82 | ip addr add 213.69.218.222 dev $IFNAME 83 | ip route add 213.69.218.192/27 via 10.0.0.19 dev $IFNAME 84 | ip route flush table 103 85 | ip route add table 103 default src 213.69.218.222 via 10.0.0.19 86 | 87 | elif [ $NODENAME = marco ]; then 88 | ip addr add 129.13.162.17 dev $IFNAME 89 | ip route add 129.13.162.95 dev ppp0 90 | ip route add 129.13.76.0/23 dev ppp0 91 | ip route add src 129.13.162.17 129.13.0.0/16 via 10.0.0.17 dev $IFNAME 92 | 93 | fi 94 | 95 | [ $NODENAME != fwkw ] && ip route add 10.0.0.0/24 via 10.0.0.29 dev $IFNAME 96 | fi 97 | 98 | 99 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # Sample debian/rules that uses debhelper. 3 | # GNU copyright 1997 to 1999 by Joey Hess. 4 | 5 | # Uncomment this to turn on verbose mode. 6 | #export DH_VERBOSE=1 7 | 8 | # This is the debhelper compatability version to use. 9 | export DH_COMPAT=3 10 | 11 | ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) 12 | CFLAGS += -g3 -O0 -fno-inline 13 | LDFLAGS += -g3 14 | else 15 | CFLAGS += -g -O2 16 | LDFLAGS += -g 17 | endif 18 | 19 | ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) 20 | STRIP = yes 21 | endif 22 | 23 | 24 | build: build-stamp 25 | build-stamp: 26 | dh_testdir 27 | 28 | # # If the Makefile.in.in file in po/ already contains DESTDIR support, skip the patching. 29 | cd `pwd`/po ; ( \ 30 | if ! grep DESTDIR Makefile.in.in > /dev/null ; then \ 31 | patch -Ns -p0 < `pwd`/../debian/po-Makefile.in.in.diff || true ;\ 32 | fi ;\ 33 | ) 34 | CC=gcc-2.95 CPP=cpp-2.95 ./configure --prefix=/usr --mandir=\$${prefix}/share/man \ 35 | --infodir=\$${prefix}/share/info --sysconfdir=/etc \ 36 | --localstatedir=/var --enable-hmac-length=4 --enable-trust \ 37 | --enable-rand-length=0 --enable-cipher=bf --enable-digest=md4 38 | $(MAKE) 39 | 40 | touch build-stamp 41 | 42 | clean: 43 | dh_testdir 44 | dh_testroot 45 | rm -f build-stamp 46 | 47 | -$(MAKE) distclean 48 | 49 | dh_clean 50 | 51 | install: build 52 | dh_testdir 53 | dh_testroot 54 | dh_clean -k 55 | dh_installdirs 56 | 57 | $(MAKE) install DESTDIR=`pwd`/debian/tmp 58 | 59 | # Build architecture-independent files here. 60 | binary-indep: build install 61 | # We have nothing to do by default. 62 | 63 | # Build architecture-dependent files here. 64 | binary-arch: build install 65 | dh_testdir 66 | dh_testroot 67 | #dh_movefiles 68 | #install -o root -g root -m 755 debian/init.d debian/vpe/etc/init.d/vpe 69 | dh_installmanpages 70 | dh_installinfo 71 | dh_installchangelogs ChangeLog 72 | dh_link 73 | @ if [ "$(STRIP)" = "yes" ] ; then \ 74 | dh_strip ;\ 75 | fi 76 | dh_compress 77 | dh_fixperms 78 | dh_installdeb 79 | dh_shlibdeps 80 | dh_gencontrol 81 | dh_md5sums 82 | dh_builddeb 83 | 84 | binary: binary-indep binary-arch 85 | .PHONY: build clean binary-indep binary-arch binary install 86 | -------------------------------------------------------------------------------- /debian/vpe.dirs: -------------------------------------------------------------------------------- 1 | usr/sbin 2 | usr/bin 3 | etc/vpe 4 | 5 | -------------------------------------------------------------------------------- /debian/vpe.files: -------------------------------------------------------------------------------- 1 | usr/sbin/vped 2 | usr/bin/vpectrl 3 | usr/share/man 4 | etc 5 | usr/share/info 6 | -------------------------------------------------------------------------------- /doc/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Having a separate GNUmakefile lets me use features of GNU make 2 | # to generate the man pages. 3 | # This makefile is used only if you run GNU Make. 4 | # It is necessary if you want to build targets usually of interest 5 | # only to the maintainer. 6 | 7 | have-Makefile := $(shell test -f Makefile && echo yes) 8 | 9 | # If the user runs GNU make but has not yet run ./configure, 10 | # give them a diagnostic. 11 | ifeq ($(have-Makefile),yes) 12 | 13 | include Makefile 14 | include $(srcdir)/Makefile.maint 15 | 16 | else 17 | 18 | all: 19 | @echo There seems to be no Makefile in this directory. 20 | @echo "You must run ./configure before running \`make'." 21 | @exit 1 22 | 23 | endif 24 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to get Makefile.in 2 | 3 | info_TEXINFOS = gvpe.texi 4 | 5 | man_MANS = gvpe.5 gvpe.8 gvpectrl.8 gvpe.conf.5 gvpe.protocol.7 gvpe.osdep.5 6 | 7 | PERL = @PERL@ 8 | MAINTAINERCLEANFILES = gvpe.texi gvpe.5 gvpe.8 gvpectrl.8 gvpe.conf.5 gvpe.protocol.7 gvpe.osdep.5 9 | 10 | EXTRA_DIST = $(man_MANS) gvpe.texi \ 11 | Makefile.maint pod2texi \ 12 | gvpe.texi.pod gvpe.5.pod gvpe.8.pod gvpectrl.8.pod gvpe.conf.5.pod gvpe.protocol.7.pod gvpe.osdep.5.pod \ 13 | complex-example/README complex-example/if-up complex-example/node-up complex-example/gvpe.conf 14 | 15 | 16 | # Use `ginstall' in the definition of man_MANS to avoid 17 | # confusion with the `install' target. The install rule transforms `ginstall' 18 | # to install before applying any user-specified name transformations. 19 | transform = s/ginstall/install/; @program_transform_name@ 20 | 21 | # For additional rules usually of interest only to the maintainer, 22 | # see GNUmakefile and Makefile.maint. 23 | 24 | -------------------------------------------------------------------------------- /doc/Makefile.maint: -------------------------------------------------------------------------------- 1 | # This -*- Makefile -*- uses features of GNU make. 2 | # It is included via GNUmakefile. 3 | 4 | # The following one line summaries were extracted from the 5 | # original man pages using this bit of sh code: 6 | # for i in *.1; do echo "$i: "|tr -d '\012'; \ 7 | # grep -A1 SH.NAME $i|sed '/SH NAME/d;s/^[^ ][^ ]* .- //'; done 8 | 9 | # Depend on configure.in to get version number changes. 10 | $(dyn_MANS): $(top_srcdir)/configure.in 11 | 12 | # Depend on the source file containing the --help text. 13 | # Filter out irregular cases. 14 | regular-men = $(filter-out $(irregular-men),$(dyn_MANS)) 15 | $(regular-men): %.8: $(top_srcdir)/src/%.c 16 | 17 | executable = $(patsubst %/install,%/ginstall, ../src/$(basename $@)) 18 | 19 | %.5: %.5.pod Makefile.maint 20 | pod2man -n$(shell perl -e '$$ARGV[0] =~ s/\.\d$$//; print uc $$ARGV[0]' $@) -qnone -r$(VERSION) -s5 -c "GNU Virtual Private Ethernet" $< >$@ 21 | 22 | %.7: %.7.pod Makefile.maint 23 | pod2man -n$(shell perl -e '$$ARGV[0] =~ s/\.\d$$//; print uc $$ARGV[0]' $@) -qnone -r$(VERSION) -s7 -c "GNU Virtual Private Ethernet" $< >$@ 24 | 25 | %.8: %.8.pod Makefile.maint 26 | pod2man -n$(shell perl -e '$$ARGV[0] =~ s/\.\d$$//; print uc $$ARGV[0]' $@) -qnone -r$(VERSION) -s8 -c "GNU Virtual Private Ethernet" $< >$@ 27 | 28 | gvpe.texi: gvpe.texi.pod pod2texi 29 | ./pod2texi gvpe.texi 30 | 31 | ../README: gvpe.5.pod 32 | pod2text -q\\\" -a gvpe.5.pod >../README 33 | 34 | -------------------------------------------------------------------------------- /doc/complex-example/README: -------------------------------------------------------------------------------- 1 | These files are configuration files for "our" internal network. 2 | 3 | It is highly non-trivial, so don't use this configuration as the basis of 4 | your network unless you know what you are doing. 5 | 6 | It features: around 30 hosts, many of them have additional networks behind 7 | them and use an assortment of different tunneling protocols. The vpn is 8 | fully routed, no arp is used at all. 9 | 10 | The public IP addresses of connecting nodes are automatically registered 11 | via dns on the node ruth, using a node-up/node-down script. 12 | 13 | And last not least: the if-up script can generate information to be used 14 | in firewall rules (IP-net/MAC-address pairs) so ensure packet integrity so 15 | you can use your iptables etc. firewall to filter by IP address only. 16 | -------------------------------------------------------------------------------- /doc/complex-example/gvpe.conf: -------------------------------------------------------------------------------- 1 | # sample configfile 2 | # the config file must be exactly(!) the same on all nodes 3 | 4 | rekey = 54321 # the rekeying interval 5 | keepalive = 300 # the keepalive interval 6 | on ruth keepalive = 120 # ruth is important and demands lower keepalives 7 | on surfer keepalive = 40 8 | mtu = 1492 # the mtu (minimum mtu of attached host) 9 | ifname = vpn0 # the tunnel interface name to use 10 | ifpersist = no # the tun device should be persistent 11 | inherit-tos = yes # should tunnel packets inherit tos flags? 12 | compress = yes # wether compression should be used (NYI) 13 | connect = ondemand # connect to this host always/never or ondemand 14 | router-priority = 1 # route for everybody - if necessary 15 | 16 | loglevel = notice # info logs connects, notice only important messages 17 | on mobil loglevel = info 18 | on doom loglevel = info 19 | on ruth loglevel = info 20 | 21 | udp-port = 407 # the udp port to use for sending/receiving packets 22 | tcp-port = 443 # the tcp port to listen for connections (we use https over proxy) 23 | ip-proto = 50 # (ab)use the ipsec protocol as rawip 24 | icmp-type = 0 # (ab)use echo replies for tunneling 25 | enable-udp = yes # udp is spoken almost everywhere 26 | enable-tcp = no # tcp is not spoken everywhere 27 | enable-rawip = no # rawip is not spoken everywhere 28 | enable-icmp = no # most hosts don't bother to icmp 29 | 30 | # every "node =" introduces a new node in the network 31 | # the options following it don't set defaults but are 32 | # node-specific. 33 | 34 | # marc@lap 35 | node = mobil 36 | 37 | # marc@home 38 | node = doom 39 | enable-rawip = yes 40 | enable-tcp = yes 41 | 42 | # marc@uni 43 | node = ruth 44 | enable-rawip = yes 45 | enable-tcp = yes 46 | enable-icmp = yes 47 | hostname = 200.100.162.95 48 | connect = always 49 | router-priority = 30 50 | on ruth node-up = node-up 51 | on ruth node-down = node-up 52 | 53 | # marc@mu 54 | node = frank 55 | enable-rawip = yes 56 | hostname = 44.88.167.250 57 | router-priority = 20 58 | connect = always 59 | 60 | # nethype 61 | node = rain 62 | enable-rawip = yes 63 | hostname = 145.253.105.130 64 | router-priority = 10 65 | connect = always 66 | 67 | # marco@home 68 | node = marco 69 | enable-rawip = yes 70 | 71 | # stefan@ka 72 | node = wappla 73 | connect = never 74 | 75 | # stefan@lap 76 | node = stefan 77 | udp-port = 408 78 | connect = never 79 | 80 | # paul@wg 81 | node = n8geil 82 | on ruth enable-icmp = yes 83 | on n8geil enable-icmp = yes 84 | enable-udp = no 85 | 86 | # paul@lap 87 | node = syrr 88 | 89 | # paul@lu 90 | node = donomos 91 | 92 | # marco@hn 93 | node = core 94 | 95 | # elmex@home 96 | node = elmex 97 | enable-rawip = yes 98 | hostname = 100.251.143.181 99 | 100 | # stefan@kwc.at 101 | node = fwkw 102 | connect = never 103 | on stefan connect = always 104 | on wappla connect = always 105 | hostname = 182.73.81.146 106 | 107 | # elmex@home 108 | node = jungfrau 109 | enable-rawip = yes 110 | 111 | # uni main router 112 | node = surfer 113 | enable-rawip = yes 114 | enable-tcp = no 115 | enable-icmp = yes 116 | hostname = 200.100.162.79 117 | connect = always 118 | router-priority = 40 119 | 120 | # jkneer@marvin 121 | node = marvin 122 | enable-rawip = yes 123 | enable-udp = no 124 | 125 | # jkneer@entrophy 126 | node = entrophy 127 | enable-udp = no 128 | enable-tcp = yes 129 | 130 | # mr. primitive 131 | node = voyager 132 | enable-udp = no 133 | enable-tcp = no 134 | on voyager enable-tcp = yes 135 | on voyager enable-udp = yes 136 | 137 | # v-server (barbados.dn-systems.de) 138 | #node = vserver 139 | #enable-udp = yes 140 | #hostname = 193.108.181.74 141 | 142 | -------------------------------------------------------------------------------- /doc/complex-example/if-up: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Some environment variables will be set: 4 | # 5 | # CONFBASE=/etc/vpe # the configuration directory prefix 6 | # IFNAME=vpn0 # the network interface (ifname) 7 | # MAC=fe:fd:80:00:00:01 # the mac-address to use for the interface 8 | # NODENAME=cerebro # the selected nodename (-n switch) 9 | # NODEID=1 # the numerical node id 10 | # MTU=1436 # the tunnel packet overhead (set mtu to 1500-$OVERHEAD) 11 | 12 | # this if-up script is rather full-featured, and is used to 13 | # generate a fully-routed (no arp traffic) vpn. the main portion 14 | # consists of "ipn" calls (see below). 15 | 16 | # some hosts require additional specific configuration, this is handled 17 | # using if statements near the end of the script. 18 | 19 | # with the --fw switch, outputs mac/net pairs for your firewall use: 20 | # if-up --fw | while read mac net; do 21 | # iptables -t filter -A INPUT -i vpn0 -p all -m mac --mac-source \! $mac -s $net -j DROP 22 | # done 23 | 24 | ipn() { 25 | local id="$1"; shift 26 | local mac=fe:fd:80:00:00:$(printf "%02x" $id) 27 | if [ -n "$FW" ]; then 28 | for net in "$@"; do 29 | echo "$mac $net" 30 | done 31 | else 32 | local ip="$1"; shift 33 | if [ "$id" == $NODEID ]; then 34 | [ -n "$ADDR_ONLY" ] && ip addr add $ip broadcast 10.255.255.255 dev $IFNAME 35 | elif [ -z "$ADDR_ONLY" ]; then 36 | ip neighbour add $ip lladdr $mac nud permanent dev $IFNAME 37 | for route in "$@"; do 38 | ip route add $route via $ip dev vpn0 39 | done 40 | fi 41 | fi 42 | } 43 | 44 | ipns() { 45 | # this contains the generic routing information for the vpn 46 | # each call to ipn has the following parameters: 47 | # ipn [ ...] 48 | # the second line (ipn 2) means: 49 | # the second node (doom in the config file) has the ip address 10.0.0.5, 50 | # which is the gateway for the 10.0/28 network and three additional ip 51 | # addresses 52 | 53 | ipn 1 10.0.0.20 54 | ipn 2 10.0.0.5 10.0.0.0/28 #200.100.162.92 200.100.162.93 100.99.218.222 55 | ipn 3 10.0.0.17 56 | ipn 4 10.0.0.18 57 | ipn 5 10.0.0.19 10.3.0.0/16 58 | ipn 6 10.0.0.21 10.0.2.0/26 #200.100.162.17 59 | ipn 7 10.0.0.22 10.1.2.0/24 # wappla, off 60 | ipn 8 10.0.0.23 # stefan, off 61 | ipn 9 10.0.0.24 10.13.0.0/16 62 | ipn 10 10.0.0.25 63 | ipn 11 10.0.0.26 64 | ipn 12 10.0.0.27 10.0.2.64/26 65 | ipn 13 10.0.0.28 10.0.3.0/24 66 | ipn 14 10.0.0.29 10.1.1.0/24 # fwkw, off 67 | # mind the gateway ip gap 68 | ipn 15 10.9.0.30 10.0.4.0/24 69 | ipn 16 10.9.0.31 70 | ipn 17 10.9.0.32 10.42.0.0/16 71 | ipn 18 10.9.0.33 72 | ipn 19 10.9.0.34 73 | #ipn 20 10.9.0.35 74 | } 75 | 76 | if [ "$1" == "--fw" ]; then 77 | FW=1 78 | 79 | ipns 80 | else 81 | exec >/var/log/vpe.if-up 2>&1 82 | set -x 83 | 84 | [ $NODENAME = "ruth" ] && ip link set $IFNAME down # hack 85 | 86 | # first set the link up and initialize the interface ip 87 | # address. 88 | ip link set $IFNAME address $MAC 89 | ip link set $IFNAME mtu $MTU up 90 | ADDR_ONLY=1 ipns # set addr only 91 | 92 | # now initialize the main vpn routes (10.0/8) 93 | # the second route is a hack to to reach some funnily-connected 94 | # machines. 95 | ip route add 10.0.0.0/8 dev $IFNAME 96 | ip route add 10.0.0.0/27 dev $IFNAME 97 | 98 | ipns # set the interface routes 99 | 100 | # now for something completely different, ehr, something not 101 | # easily doable with ipn, namely some extra specific highly complicated 102 | # and non-regular setups for some machines. 103 | if [ $NODENAME = doom ]; then 104 | ip addr add 200.100.162.92 dev $IFNAME 105 | ip route add 200.100.0.0/16 via 10.0.0.17 dev $IFNAME 106 | ip route flush table 101 107 | ip route add table 101 default src 200.100.162.92 via 10.0.0.17 dev $IFNAME 108 | 109 | ip addr add 100.99.218.222 dev $IFNAME 110 | ip route add 100.99.218.192/27 via 10.0.0.19 dev $IFNAME 111 | ip route flush table 103 112 | ip route add table 103 default src 100.99.218.222 via 10.0.0.19 113 | 114 | elif [ $NODENAME = marco ]; then 115 | ip addr add 200.100.162.17 dev $IFNAME 116 | 117 | for addr in 79 89 90 91 92 93 94 95; do 118 | ip route add 200.100.162.$addr dev ppp0 119 | done 120 | ip route add 200.100.76.0/23 dev ppp0 121 | ip route add src 200.100.162.17 200.100.0.0/16 via 10.0.0.17 dev $IFNAME 122 | 123 | elif [ $NODENAME = ruth ]; then 124 | ip route add 200.100.162.17 via 10.0.0.21 dev vpn0 125 | ip route add 200.100.162.92 via 10.0.0.5 dev vpn0 126 | ip route add 200.100.162.93 via 10.0.0.5 dev vpn0 127 | 128 | fi 129 | 130 | # and this is the second part of the 10.0/27 hack. don't ask. 131 | [ $NODENAME != fwkw ] && ip route add 10.0.0.0/24 via 10.0.0.29 dev $IFNAME 132 | fi 133 | 134 | 135 | -------------------------------------------------------------------------------- /doc/complex-example/node-up: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Some environment variables will be set (in addition the ones 4 | # set in if-up, too): 5 | # 6 | # DESTNODE=doom # others nodename 7 | # DESTID=5 # others node id 8 | # DESTIP=188.13.66.8 # others ip 9 | # DESTPORT=407 # others port 10 | # STATE=up/down # node-up gets UP, node-down script gets DOWN 11 | 12 | if [ $STATE = up ]; then 13 | { 14 | echo update delete $DESTNODE.lowttl.example.com. a 15 | echo update delete $DESTNODE-last.lowttl.example.com. a 16 | echo update add $DESTNODE.lowttl.example.com. 1 in a $DESTIP 17 | echo update add $DESTNODE-last.lowttl.example.com. 1 in a $DESTIP 18 | echo 19 | } | nsupdate -d -k $CONFBASE:marc.example.net. 20 | else 21 | { 22 | echo update delete $DESTNODE.lowttl.example.com. a 23 | echo update delete $DESTNODE-last.lowttl.example.com. a 24 | echo update add $DESTNODE-last.lowttl.example.com. 1 in a $DESTIP 25 | echo 26 | } | nsupdate -d -k $CONFBASE:marc.example.net. 27 | fi 28 | 29 | -------------------------------------------------------------------------------- /doc/gvpe.8.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | C - GNU Virtual Private Ethernet Daemon 4 | 5 | =head1 SYNOPSIS 6 | 7 | C [B<-cDlL>] [B<--config=>I] [B<--no-detach>] [B<-l=>I] 8 | [B<--kill>[B<=>I]] [B<--mlock>] [B<--help>] [B<--version>] 9 | I [I] 10 | 11 | =head1 DESCRIPTION 12 | 13 | See the gvpe(5) man page for an introduction to the gvpe suite. 14 | 15 | This is the manual page for gvpe, the virtual private ethernet daemon. 16 | When started, C will read it's configuration file to determine the 17 | network topology, and other configuration information, assuming the role 18 | of node I 19 | 20 | It will then create/connect to the tun/tap device and set up a socket for 21 | incoming connections. Then a C script will be executed to further 22 | configure the virtual network device. If that succeeds, it will detach 23 | from the controlling terminal and continue in the background, accepting 24 | and setting up connections to other gvpe daemons that are part of the 25 | same virtual private ethernet. 26 | 27 | The optional arguments after the node name have to be of the form: 28 | 29 | [I.]var=value 30 | 31 | If the argument has a prefix of C 32 | (i.e. C) then it will be parsed after all the 33 | config directives for that node, if not, it is parsed before the first 34 | node directive in the config file, and can be used to set global options 35 | or default variables. 36 | 37 | For example, to start C in the foreground, with log-level C on 38 | the node C, with TCP enabled and HTTP-Proxy host and Port set, use 39 | this: 40 | 41 | gvpe -D -l info laptop \ 42 | http-proxy-host=10.0.0.18 http-proxy-port=3128 \ 43 | laptop.enable-tcp=yes 44 | 45 | =head1 OPTIONS 46 | 47 | =over 4 48 | 49 | =item B<-c>, B<--config=>I 50 | 51 | Read configuration options from I 52 | 53 | =item B<-d>, B<--l=>I 54 | 55 | Set logging level to I (one of: noise, trace, debug, info, notice, 56 | warn, error, critical). 57 | 58 | =item B<--help> 59 | 60 | Display short list of options. 61 | 62 | =item B<-D>, B<--no-detach> 63 | 64 | Don't fork and detach but stay in foreground and log messages to stderr in 65 | addition to syslog. 66 | 67 | =item B<-L>, B<--mlock> 68 | 69 | Lock C into main memory. This will prevent sensitive data like 70 | shared private keys to be written to the system swap files/partitions. 71 | 72 | =item B<--version> 73 | 74 | Output version information and exit. 75 | 76 | =back 77 | 78 | =head1 SIGNALS 79 | 80 | =over 4 81 | 82 | =item HUP 83 | 84 | Closes/resets all connections, resets the retry time and will start connecting 85 | again (it will NOT re-read the config file). This is useful e.g. in a 86 | C script. 87 | 88 | =item TERM 89 | 90 | Closes/resets all connections and exits. 91 | 92 | =item USR1 93 | 94 | Dump current network status into the syslog (at loglevel C, so make 95 | sure your loglevel allows this). 96 | 97 | =back 98 | 99 | =head1 FILES 100 | 101 | =over 4 102 | 103 | =item C 104 | 105 | The configuration file for C. 106 | 107 | =item C 108 | 109 | Script which is executed as soon as the virtual network device has been 110 | allocated. Purpose is to further configure that device. 111 | 112 | =item C 113 | 114 | Script which is executed whenever a node connects to this node. This can 115 | be used for example to run nsupdate. 116 | 117 | =item C 118 | 119 | Script which is executed whenever a connection to another node is lost. 120 | for example to run nsupdate. 121 | 122 | =item C 123 | 124 | The directory containing the public keys for every node, usually 125 | autogenerated by executing C. 126 | 127 | =item C 128 | 129 | The PID of the currently running C is stored in this file. 130 | 131 | =back 132 | 133 | =head1 BUGS 134 | 135 | The cryptography in gvpe has not been thoroughly checked by many people 136 | yet. Use it at your own risk! 137 | 138 | If you find any bugs, report them to C. 139 | 140 | =head1 SEE ALSO 141 | 142 | gvpe(5) for an introduction, gvpe.conf(5), gvpectrl(8). 143 | 144 | The GVPE mailing list, at L or 145 | C. 146 | 147 | GVPE comes with ABSOLUTELY NO WARRANTY. This is free software, and you are 148 | welcome to redistribute it under certain conditions; see the file COPYING 149 | for details. 150 | 151 | =head1 AUTHOR 152 | 153 | Marc Lehmann C<< >>. 154 | 155 | And thanks to many others for their contributions to gvpe, especially the 156 | tincd authors, who inspired me to write this program (after scavenging 157 | their source code ;). 158 | 159 | -------------------------------------------------------------------------------- /doc/gvpe.conf.5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/doc/gvpe.conf.5 -------------------------------------------------------------------------------- /doc/gvpe.protocol.7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/doc/gvpe.protocol.7 -------------------------------------------------------------------------------- /doc/gvpectrl.8.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | C - GNU Virtual Private Ethernet Control Program 4 | 5 | =head1 SYNOPSIS 6 | 7 | C [B<-ckgs>] [B<--config=>I] [B<--generate-keys>] [B<--help>] 8 | [B<--kill>[B<=>I]] [B<--show-config>] [B<--version>] 9 | 10 | =head1 DESCRIPTION 11 | 12 | This is the control program for the C, the virtual private ethernet daemon. 13 | 14 | =head1 OPTIONS 15 | 16 | =over 4 17 | 18 | =item B<-c>, B<--config=>I 19 | 20 | Read configuration options from I. 21 | 22 | =item B<-g>, B<--generate-keys> 23 | 24 | Generate public/private RSA key-pair and exit. 25 | 26 | =item B<-q>, B<--quiet> 27 | 28 | Suppresses messages the author finds nonessential for scripting purposes. 29 | 30 | =item B<--help> 31 | 32 | Display short list of options. 33 | 34 | =item B<--kill>[B<=>I] 35 | 36 | Attempt to kill a running C (optionally with the specified 37 | I instead of C) and exit. 38 | 39 | =item B<--show-config> 40 | 41 | Show a summary of the configuration, and how gvpe interprets it. Can also be very useful 42 | when designing firewall scripts. 43 | 44 | =item B<--version> 45 | 46 | Output version information and exit. 47 | 48 | =back 49 | 50 | =head1 BUGS 51 | 52 | If you find any bugs, report them to C. 53 | 54 | =head1 SEE ALSO 55 | 56 | gvpe(5), gvpe.conf(5), gvpe(8). 57 | 58 | GVPE comes with ABSOLUTELY NO WARRANTY. This is free software, and you are 59 | welcome to redistribute it under certain conditions; see the file COPYING 60 | for details. 61 | 62 | =head1 AUTHOR 63 | 64 | Marc Lehmann C<< >>. 65 | 66 | -------------------------------------------------------------------------------- /doc/pod2texi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # TODO: texinfo fails on @cindex in title elements etc. *sigh* 4 | 5 | use Pod::POM; 6 | 7 | sub escape_texi($) { 8 | local $_ = shift; 9 | s/([\@\{\}])/\@$1/g; 10 | s/\n+/ /g; 11 | $_; 12 | } 13 | 14 | sub example { 15 | my $text = $_[0]; 16 | $text =~ s/\n+$//; 17 | $text =~ s/([\@\{\}])/\@$1/g; 18 | 19 | "\n\n\@example\n" 20 | . $text 21 | . "\n\@end example\n\n"; 22 | } 23 | 24 | my @nodes; # nodelist 25 | my @ctx; # curstack 26 | 27 | sub out { 28 | $ctx[-1]{out} .= join "", @_; 29 | } 30 | 31 | sub TEX::view_seq_code { "\@t{$_[1]}" } 32 | sub TEX::view_seq_file { "\@file{$_[1]}" } 33 | sub TEX::view_seq_bold { "\@strong{$_[1]}" } 34 | sub TEX::view_seq_italic { "\@emph{$_[1]}" } 35 | 36 | sub TEX::view_seq_space { escape_texi $_[1] } 37 | sub TEX::view_seq_text { escape_texi $_[1] } 38 | 39 | sub TEX::view_seq_link { $_[1] } 40 | sub TEX::view_seq_index { 41 | "\n\@cindex $_[1]\n$_[1]" 42 | } 43 | 44 | *TXT::view_seq_code = 45 | *TXT::view_seq_bold = 46 | *TXT::view_seq_italic = 47 | *TXT::view_seq_space = 48 | *TXT::view_seq_text = 49 | *TXT::view_seq_link = 50 | *TXT::view_seq_index = sub { $_[1] }; 51 | 52 | my %ignore = ( 53 | "SEE ALSO" => 1, 54 | "AUTHOR" => 1, 55 | ); 56 | 57 | sub parse_pod { 58 | my ($data) = @_; 59 | local $out; 60 | 61 | local $Pod::POM::DEFAULT_VIEW = TEX::; 62 | 63 | my $parser = new Pod::POM; 64 | my $pod = $parser->parse_text ($data) 65 | or die; 66 | 67 | my $walker; $walker = sub { 68 | my $n = $_[0]; 69 | my $t = $n->type; 70 | 71 | if ($t eq "text") { 72 | out $n->text . "\n\@refill\n"; 73 | 74 | } elsif ($t eq "pod") { 75 | $walker->($_) for $n->content; 76 | 77 | } elsif ($t eq "verbatim") { 78 | out example $n->text; 79 | 80 | } elsif ($t eq "head1") { 81 | 82 | return if $ignore{$n->title}; 83 | 84 | out "\n\@section " . $n->title . "\n"; 85 | $walker->($_) for $n->content; 86 | out "\n"; 87 | 88 | } elsif ($t eq "head2") { 89 | out "\n\n\@subsection " . $n->title . "\n"; 90 | $walker->($_) for $n->content; 91 | 92 | } elsif ($t eq "over") { 93 | out "\n\n\@itemize\n"; 94 | $walker->($_) for $n->content; 95 | out "\@end itemize\n\n"; 96 | 97 | } elsif ($t eq "item") { 98 | out "\n\n\@item\n" . $n->title . "\n\n"; 99 | 100 | if ($n->title->present (TXT::) =~ /^\s*([a-zA-Z0-9\-\_]+)\s*=/) { 101 | out "\@cindex $1\n"; 102 | } 103 | $walker->($_) for $n->content; 104 | 105 | } elsif ($t eq "begin") { 106 | local $Pod::POM::DEFAULT_VIEW = Pod::POM::View::Pod; 107 | my $format = $n->format; 108 | 109 | if ($format =~ /texinfo\s+header/) { 110 | $header = $n->content; 111 | } elsif ($format =~ /texinfo\s+footer/) { 112 | $footer = $n->content; 113 | } else { 114 | out $n->content; 115 | } 116 | 117 | } elsif ($t eq "for") { 118 | my $text = $n->text; 119 | 120 | if ($text =~ /^menu-begin/) { 121 | out "\n\@menu\n"; 122 | 123 | push @ctx, {}; # dummy node 124 | 125 | } elsif ($text =~ /^menu-item (.*?)::\s+(.*)/) { 126 | my ($name, $desc) = ($1, $2); 127 | 128 | push @{ $ctx[-2]{menu} }, [$name, $desc]; 129 | $ctx[-2]{width} = length $name if $ctx[-2]{width} < length $name; 130 | 131 | my $ctx = { 132 | name => $name, 133 | up => $ctx[-2]{name}, 134 | }; 135 | push @nodes, $ctx; 136 | $ctx[-1] = $ctx; 137 | 138 | } elsif ($text =~ /^menu-end/) { 139 | pop @ctx; 140 | 141 | for (@{ $ctx[-1]{menu} }) { 142 | out sprintf "* %-*s %s\n", $ctx[-1]{width} + 2, "$_->[0]::", $_->[1]; 143 | } 144 | 145 | out "\@end menu\n"; 146 | 147 | } elsif ($text =~ /^include (\S+) (.*)/) { 148 | my ($type, $path) = ($1, $2); 149 | 150 | open my $x, "<$path" or die "$path: $!"; 151 | my $data = do { local $/; <$x> }; 152 | 153 | if ($type eq "pod") { 154 | out parse_pod ($data); 155 | } elsif ($type eq "text") { 156 | out $data; 157 | } elsif ($type eq "example") { 158 | out example $data; 159 | } 160 | 161 | } else { 162 | die "UNKNOWN for command <$text>\n"; 163 | } 164 | 165 | } else { 166 | die "UNKNOWN NODE $t\n"; 167 | } 168 | }; 169 | 170 | $walker->($pod); 171 | } 172 | 173 | @ctx = @nodes = { 174 | up => "(dir)", 175 | name => "Top", 176 | }; 177 | 178 | parse_pod do { local $/; <> }; 179 | 180 | print $header; 181 | 182 | for (0 .. $#nodes) { 183 | my $node = $nodes[$_]; 184 | my $prev = $_ > 0 ? $nodes[$_-1] : undef; 185 | my $next = $nodes[$_+1]; 186 | my $chapter = $node->{name} eq "Top" ? "Introduction" : $node->{name}; 187 | 188 | print "\@node $node->{name},$next->{name},$prev->{name},$node->{up}\n\n", 189 | "\@chapter $chapter\n", 190 | "$node->{out}\n\n"; 191 | } 192 | 193 | print $footer; 194 | 195 | -------------------------------------------------------------------------------- /lib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES = libgvpe.a 2 | 3 | INCLUDES = @INCLUDES@ -I. -I$(top_builddir) 4 | 5 | libgvpe_a_SOURCES = pidfile.c getopt.c getopt1.c dropin.c 6 | 7 | libgvpe_a_LIBADD = @LIBOBJS@ @ALLOCA@ 8 | libgvpe_a_DEPENDENCIES = $(libgvpe_a_LIBADD) 9 | 10 | noinst_HEADERS = pidfile.h getopt.h dropin.h gettext.h 11 | 12 | -------------------------------------------------------------------------------- /lib/dropin.c: -------------------------------------------------------------------------------- 1 | /* 2 | dropin.c -- a set of drop-in replacements for libc functions 3 | Copyright (C) 2000,2001 Ivo Timmermans , 4 | 2000,2001 Guus Sliepen 5 | 2003 Marc Lehmann 6 | 7 | This file is part of GVPE. 8 | 9 | GVPE is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with gvpe; if not, write to the Free Software 21 | Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #include "config.h" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | #ifndef HAVE_DAEMON 37 | /* 38 | Replacement for the daemon() function. 39 | 40 | The daemon() function is for programs wishing to detach themselves 41 | from the controlling terminal and run in the background as system 42 | daemons. 43 | 44 | Unless the argument nochdir is non-zero, daemon() changes the 45 | current working directory to the root (``/''). 46 | 47 | Unless the argument noclose is non-zero, daemon() will redirect 48 | standard input, standard output and standard error to /dev/null. 49 | */ 50 | int daemon(int nochdir, int noclose) 51 | { 52 | pid_t pid; 53 | int fd; 54 | 55 | pid = fork(); 56 | 57 | /* Check if forking failed */ 58 | if(pid < 0) { 59 | perror("fork"); 60 | exit(-1); 61 | } 62 | 63 | /* If we are the parent, terminate */ 64 | if(pid) 65 | exit(0); 66 | 67 | /* Detach by becoming the new process group leader */ 68 | if(setsid() < 0) { 69 | perror("setsid"); 70 | return -1; 71 | } 72 | 73 | /* Change working directory to the root (to avoid keeping mount 74 | points busy) */ 75 | if(!nochdir) { 76 | chdir("/"); 77 | } 78 | 79 | /* Redirect stdin/out/err to /dev/null */ 80 | if(!noclose) { 81 | fd = open("/dev/null", O_RDWR); 82 | 83 | if(fd < 0) { 84 | perror("opening /dev/null"); 85 | return -1; 86 | } else { 87 | dup2(fd, 0); 88 | dup2(fd, 1); 89 | dup2(fd, 2); 90 | } 91 | } 92 | 93 | return 0; 94 | } 95 | #endif 96 | 97 | #ifndef HAVE_GET_CURRENT_DIR_NAME 98 | /* 99 | Replacement for the GNU get_current_dir_name function: 100 | 101 | get_current_dir_name will malloc(3) an array big enough to hold the 102 | current directory name. If the environment variable PWD is set, and 103 | its value is correct, then that value will be returned. 104 | */ 105 | char *get_current_dir_name(void) 106 | { 107 | size_t size; 108 | char *buf; 109 | char *r; 110 | 111 | /* Start with 100 bytes. If this turns out to be insufficient to 112 | contain the working directory, double the size. */ 113 | size = 100; 114 | buf = malloc(size); 115 | 116 | errno = 0; /* Success */ 117 | r = getcwd(buf, size); 118 | 119 | /* getcwd returns NULL and sets errno to ERANGE if the bufferspace 120 | is insufficient to contain the entire working directory. */ 121 | while(r == NULL && errno == ERANGE) { 122 | free(buf); 123 | size <<= 1; /* double the size */ 124 | buf = malloc(size); 125 | r = getcwd(buf, size); 126 | } 127 | 128 | return buf; 129 | } 130 | #endif 131 | 132 | #ifndef HAVE_ASPRINTF 133 | int asprintf(char **buf, const char *fmt, ...) 134 | { 135 | int status; 136 | va_list ap; 137 | int len; 138 | 139 | len = 4096; 140 | *buf = malloc(len); 141 | 142 | va_start(ap, fmt); 143 | status = vsnprintf(*buf, len, fmt, ap); 144 | va_end(ap); 145 | 146 | if(status >= 0) 147 | *buf = realloc(*buf, status); 148 | 149 | if(status > len - 1) { 150 | len = status; 151 | va_start(ap, fmt); 152 | status = vsnprintf(*buf, len, fmt, ap); 153 | va_end(ap); 154 | } 155 | 156 | return status; 157 | } 158 | #endif 159 | -------------------------------------------------------------------------------- /lib/dropin.h: -------------------------------------------------------------------------------- 1 | /* 2 | dropin.h -- header file for dropin.c 3 | Copyright (C) 2000,2001 Ivo Timmermans , 4 | 2000,2001 Guus Sliepen 5 | 6 | This file is part of GVPE. 7 | 8 | GVPE is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with gvpe; if not, write to the Free Software 20 | Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef __DROPIN_H__ 24 | #define __DROPIN_H__ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #ifndef HAVE_DAEMON 31 | extern int daemon(int, int); 32 | #endif 33 | 34 | #ifndef HAVE_GET_CURRENT_DIR_NAME 35 | extern char *get_current_dir_name(void); 36 | #endif 37 | 38 | #ifndef HAVE_ASPRINTF 39 | extern int asprintf(char **, const char *, ...); 40 | #endif 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* __DROPIN_H__ */ 47 | -------------------------------------------------------------------------------- /lib/getopt.h: -------------------------------------------------------------------------------- 1 | /* Declarations for getopt. 2 | Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc. 3 | 4 | NOTE: The canonical source of this file is maintained with the GNU C Library. 5 | Bugs can be reported to bug-glibc@prep.ai.mit.edu. 6 | 7 | This file is part of GVPE. 8 | 9 | GVPE is free software; you can redistribute it and/or modify it 10 | under the terms of the GNU General Public License as published by the 11 | Free Software Foundation; either version 2, or (at your option) any 12 | later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with gvpe; if not, write to the Free Software 21 | Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef _GETOPT_H 25 | #define _GETOPT_H 1 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* For communication from `getopt' to the caller. 32 | When `getopt' finds an option that takes an argument, 33 | the argument value is returned here. 34 | Also, when `ordering' is RETURN_IN_ORDER, 35 | each non-option ARGV-element is returned here. */ 36 | 37 | extern char *optarg; 38 | 39 | /* Index in ARGV of the next element to be scanned. 40 | This is used for communication to and from the caller 41 | and for communication between successive calls to `getopt'. 42 | 43 | On entry to `getopt', zero means this is the first call; initialize. 44 | 45 | When `getopt' returns -1, this is the index of the first of the 46 | non-option elements that the caller should itself scan. 47 | 48 | Otherwise, `optind' communicates from one call to the next 49 | how much of ARGV has been scanned so far. */ 50 | 51 | extern int optind; 52 | 53 | /* Callers store zero here to inhibit the error message `getopt' prints 54 | for unrecognized options. */ 55 | 56 | extern int opterr; 57 | 58 | /* Set to an option character which was unrecognized. */ 59 | 60 | extern int optopt; 61 | 62 | /* Describe the long-named options requested by the application. 63 | The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector 64 | of `struct option' terminated by an element containing a name which is 65 | zero. 66 | 67 | The field `has_arg' is: 68 | no_argument (or 0) if the option does not take an argument, 69 | required_argument (or 1) if the option requires an argument, 70 | optional_argument (or 2) if the option takes an optional argument. 71 | 72 | If the field `flag' is not NULL, it points to a variable that is set 73 | to the value given in the field `val' when the option is found, but 74 | left unchanged if the option is not found. 75 | 76 | To have a long-named option do something other than set an `int' to 77 | a compiled-in constant, such as set a value from `optarg', set the 78 | option's `flag' field to zero and its `val' field to a nonzero 79 | value (the equivalent single-letter option character, if there is 80 | one). For long options that have a zero `flag' field, `getopt' 81 | returns the contents of the `val' field. */ 82 | 83 | struct option 84 | { 85 | #if defined (__STDC__) && __STDC__ 86 | const char *name; 87 | #else 88 | char *name; 89 | #endif 90 | /* has_arg can't be an enum because some compilers complain about 91 | type mismatches in all the code that assumes it is an int. */ 92 | int has_arg; 93 | int *flag; 94 | int val; 95 | }; 96 | 97 | /* Names for the values of the `has_arg' field of `struct option'. */ 98 | 99 | #define no_argument 0 100 | #define required_argument 1 101 | #define optional_argument 2 102 | 103 | #if defined (__STDC__) && __STDC__ 104 | #ifdef __GNU_LIBRARY__ 105 | /* Many other libraries have conflicting prototypes for getopt, with 106 | differences in the consts, in stdlib.h. To avoid compilation 107 | errors, only prototype getopt for the GNU C library. */ 108 | extern int getopt (int argc, char *const *argv, const char *shortopts); 109 | #else /* not __GNU_LIBRARY__ */ 110 | #endif /* __GNU_LIBRARY__ */ 111 | extern int getopt_long (int argc, char *const *argv, const char *shortopts, 112 | const struct option *longopts, int *longind); 113 | extern int getopt_long_only (int argc, char *const *argv, 114 | const char *shortopts, 115 | const struct option *longopts, int *longind); 116 | 117 | /* Internal only. Users should not call this directly. */ 118 | extern int _getopt_internal (int argc, char *const *argv, 119 | const char *shortopts, 120 | const struct option *longopts, int *longind, 121 | int long_only); 122 | #else /* not __STDC__ */ 123 | extern int getopt_long (); 124 | extern int getopt_long_only (); 125 | 126 | extern int _getopt_internal (); 127 | #endif /* __STDC__ */ 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | 133 | #endif /* _GETOPT_H */ 134 | -------------------------------------------------------------------------------- /lib/getopt1.c: -------------------------------------------------------------------------------- 1 | /* getopt_long and getopt_long_only entry points for GNU getopt. 2 | Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc. 3 | 4 | NOTE: The canonical source of this file is maintained with the GNU C Library. 5 | Bugs can be reported to bug-glibc@prep.ai.mit.edu. 6 | 7 | This file is part of GVPE. 8 | 9 | GVPE is free software; you can redistribute it and/or modify it 10 | under the terms of the GNU General Public License as published by the 11 | Free Software Foundation; either version 2, or (at your option) any 12 | later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with gvpe; if not, write to the Free Software 21 | Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifdef HAVE_CONFIG_H 25 | #include 26 | #endif 27 | 28 | #include "getopt.h" 29 | 30 | #if !defined (__STDC__) || !__STDC__ 31 | /* This is a separate conditional since some stdc systems 32 | reject `defined (const)'. */ 33 | #ifndef const 34 | #define const 35 | #endif 36 | #endif 37 | 38 | #include 39 | 40 | /* Comment out all this code if we are using the GNU C Library, and are not 41 | actually compiling the library itself. This code is part of the GNU C 42 | Library, but also included in many other GNU distributions. Compiling 43 | and linking in this code is a waste when using the GNU C library 44 | (especially if it is a shared library). Rather than having every GNU 45 | program understand `configure --with-gnu-libc' and omit the object files, 46 | it is simpler to just do this in the source for each such file. */ 47 | 48 | #define GETOPT_INTERFACE_VERSION 2 49 | #if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 50 | #include 51 | #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION 52 | #define ELIDE_CODE 53 | #endif 54 | #endif 55 | 56 | #ifndef ELIDE_CODE 57 | 58 | 59 | /* This needs to come after some library #include 60 | to get __GNU_LIBRARY__ defined. */ 61 | #ifdef __GNU_LIBRARY__ 62 | #include 63 | #endif 64 | 65 | #ifndef NULL 66 | #define NULL 0 67 | #endif 68 | 69 | int 70 | getopt_long (argc, argv, options, long_options, opt_index) 71 | int argc; 72 | char *const *argv; 73 | const char *options; 74 | const struct option *long_options; 75 | int *opt_index; 76 | { 77 | return _getopt_internal (argc, argv, options, long_options, opt_index, 0); 78 | } 79 | 80 | /* Like getopt_long, but '-' as well as '--' can indicate a long option. 81 | If an option that starts with '-' (not '--') doesn't match a long option, 82 | but does match a short option, it is parsed as a short option 83 | instead. */ 84 | 85 | int 86 | getopt_long_only (argc, argv, options, long_options, opt_index) 87 | int argc; 88 | char *const *argv; 89 | const char *options; 90 | const struct option *long_options; 91 | int *opt_index; 92 | { 93 | return _getopt_internal (argc, argv, options, long_options, opt_index, 1); 94 | } 95 | 96 | 97 | #endif /* Not ELIDE_CODE. */ 98 | 99 | #ifdef TEST 100 | 101 | #include 102 | 103 | int 104 | main (argc, argv) 105 | int argc; 106 | char **argv; 107 | { 108 | int c; 109 | int digit_optind = 0; 110 | 111 | while (1) 112 | { 113 | int this_option_optind = optind ? optind : 1; 114 | int option_index = 0; 115 | static struct option long_options[] = 116 | { 117 | {"add", 1, 0, 0}, 118 | {"append", 0, 0, 0}, 119 | {"delete", 1, 0, 0}, 120 | {"verbose", 0, 0, 0}, 121 | {"create", 0, 0, 0}, 122 | {"file", 1, 0, 0}, 123 | {0, 0, 0, 0} 124 | }; 125 | 126 | c = getopt_long (argc, argv, "abc:d:0123456789", 127 | long_options, &option_index); 128 | if (c == -1) 129 | break; 130 | 131 | switch (c) 132 | { 133 | case 0: 134 | printf ("option %s", long_options[option_index].name); 135 | if (optarg) 136 | printf (" with arg %s", optarg); 137 | printf ("\n"); 138 | break; 139 | 140 | case '0': 141 | case '1': 142 | case '2': 143 | case '3': 144 | case '4': 145 | case '5': 146 | case '6': 147 | case '7': 148 | case '8': 149 | case '9': 150 | if (digit_optind != 0 && digit_optind != this_option_optind) 151 | printf ("digits occur in two different argv-elements.\n"); 152 | digit_optind = this_option_optind; 153 | printf ("option %c\n", c); 154 | break; 155 | 156 | case 'a': 157 | printf ("option a\n"); 158 | break; 159 | 160 | case 'b': 161 | printf ("option b\n"); 162 | break; 163 | 164 | case 'c': 165 | printf ("option c with value `%s'\n", optarg); 166 | break; 167 | 168 | case 'd': 169 | printf ("option d with value `%s'\n", optarg); 170 | break; 171 | 172 | case '?': 173 | break; 174 | 175 | default: 176 | printf ("?? getopt returned character code 0%o ??\n", c); 177 | } 178 | } 179 | 180 | if (optind < argc) 181 | { 182 | printf ("non-option ARGV-elements: "); 183 | while (optind < argc) 184 | printf ("%s ", argv[optind++]); 185 | printf ("\n"); 186 | } 187 | 188 | exit (0); 189 | } 190 | 191 | #endif /* TEST */ 192 | -------------------------------------------------------------------------------- /lib/gettext.h: -------------------------------------------------------------------------------- 1 | /* Convenience header for conditional use of GNU . 2 | Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc. 3 | 4 | This file is part of GVPE. 5 | 6 | GVPE is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU Library General Public License as published 8 | by the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Library General Public License for more details. 15 | 16 | You should have received a copy of the GNU Library General Public 17 | License along with gvpe; if not, write to the Free Software 18 | Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef _LIBGETTEXT_H 22 | #define _LIBGETTEXT_H 1 23 | 24 | #if __cplusplus 25 | # include CLOCALE 26 | #else 27 | # include 28 | #endif 29 | 30 | /* NLS can be disabled through the configure --disable-nls option. */ 31 | #if ENABLE_NLS 32 | 33 | /* Get declarations of GNU message catalog functions. */ 34 | # include 35 | 36 | /* Shorthand notation */ 37 | 38 | # define _(Text) gettext (Text) 39 | 40 | #else 41 | 42 | /* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which 43 | chokes if dcgettext is defined as a macro. So include it now, to make 44 | later inclusions of a NOP. We don't include 45 | as well because people using "gettext.h" will not include , 46 | and also including would fail on SunOS 4, whereas 47 | is OK. */ 48 | #if defined(__sun) 49 | # include 50 | #endif 51 | 52 | /* Disabled NLS. 53 | The casts to 'const char *' serve the purpose of producing warnings 54 | for invalid uses of the value returned from these functions. 55 | On pre-ANSI systems without 'const', the config.h file is supposed to 56 | contain "#define const". */ 57 | # define gettext(Msgid) ((const char *) (Msgid)) 58 | # define dgettext(Domainname, Msgid) ((const char *) (Msgid)) 59 | # define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) 60 | # define ngettext(Msgid1, Msgid2, N) \ 61 | ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) 62 | # define dngettext(Domainname, Msgid1, Msgid2, N) \ 63 | ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) 64 | # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ 65 | ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) 66 | # define textdomain(Domainname) ((const char *) (Domainname)) 67 | # define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) 68 | # define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) 69 | 70 | # define _(Text) Text 71 | //# define setlocale(Category, Locale) ((const char *) (Locale)) 72 | 73 | #endif 74 | 75 | /* A pseudo function call that serves as a marker for the automated 76 | extraction of messages, but does not call gettext(). The run-time 77 | translation is done at a different place in the code. 78 | The argument, String, should be a literal string. Concatenated strings 79 | and other string expressions won't work. 80 | The macro's expansion is not parenthesized, so that it is suitable as 81 | initializer for static 'char[]' or 'const char[]' variables. */ 82 | #define gettext_noop(String) String 83 | 84 | #define N_(Text) Text 85 | 86 | #endif /* _LIBGETTEXT_H */ 87 | -------------------------------------------------------------------------------- /lib/pidfile.c: -------------------------------------------------------------------------------- 1 | /* 2 | pidfile.c - interact with pidfiles 3 | Copyright (c) 1995 Martin Schulze 4 | 5 | This file is part of the sysklogd package, a kernel and system log daemon. 6 | 7 | This file is part of GVPE. 8 | 9 | GVPE is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with gvpe; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA 22 | */ 23 | 24 | /* 25 | * Sat Aug 19 13:24:33 MET DST 1995: Martin Schulze 26 | * First version (v0.2) released 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | /* read_pid 41 | * 42 | * Reads the specified pidfile and returns the read pid. 43 | * 0 is returned if either there's no pidfile, it's empty 44 | * or no pid can be read. 45 | */ 46 | int read_pid (char *pidfile) 47 | { 48 | FILE *f; 49 | int pid; 50 | 51 | if (!(f=fopen(pidfile,"r"))) 52 | return 0; 53 | fscanf(f,"%d", &pid); 54 | fclose(f); 55 | return pid; 56 | } 57 | 58 | /* check_pid 59 | * 60 | * Reads the pid using read_pid and looks up the pid in the process 61 | * table (using /proc) to determine if the process already exists. If 62 | * so 1 is returned, otherwise 0. 63 | */ 64 | int check_pid (char *pidfile) 65 | { 66 | int pid = read_pid(pidfile); 67 | 68 | /* Amazing ! _I_ am already holding the pid file... */ 69 | if ((!pid) || (pid == getpid ())) 70 | return 0; 71 | 72 | /* 73 | * The 'standard' method of doing this is to try and do a 'fake' kill 74 | * of the process. If an ESRCH error is returned the process cannot 75 | * be found -- GW 76 | */ 77 | /* But... errno is usually changed only on error.. */ 78 | errno = 0; 79 | if (kill(pid, 0) && errno == ESRCH) 80 | return(0); 81 | 82 | return pid; 83 | } 84 | 85 | /* write_pid 86 | * 87 | * Writes the pid to the specified file. If that fails 0 is 88 | * returned, otherwise the pid. 89 | */ 90 | int write_pid (char *pidfile) 91 | { 92 | FILE *f; 93 | int fd; 94 | int pid; 95 | 96 | if ( ((fd = open(pidfile, O_RDWR|O_CREAT, 0644)) == -1) 97 | || ((f = fdopen(fd, "r+")) == NULL) ) { 98 | fprintf(stderr, "Can't open or create %s.\n", pidfile ? pidfile : "(null)"); 99 | return 0; 100 | } 101 | 102 | #ifdef HAVE_FLOCK 103 | if (flock(fd, LOCK_EX|LOCK_NB) == -1) { 104 | fscanf(f, "%d", &pid); 105 | fclose(f); 106 | printf("Can't lock, lock is held by pid %d.\n", pid); 107 | return 0; 108 | } 109 | #endif 110 | 111 | pid = getpid(); 112 | if (!fprintf(f,"%d\n", pid)) { 113 | printf("Can't write pid , %s.\n", strerror(errno)); 114 | close(fd); 115 | return 0; 116 | } 117 | fflush(f); 118 | 119 | #ifdef HAVE_FLOCK 120 | if (flock(fd, LOCK_UN) == -1) { 121 | printf("Can't unlock pidfile %s, %s.\n", pidfile, strerror(errno)); 122 | close(fd); 123 | return 0; 124 | } 125 | #endif 126 | close(fd); 127 | 128 | return pid; 129 | } 130 | 131 | /* remove_pid 132 | * 133 | * Remove the the specified file. The result from unlink(2) 134 | * is returned 135 | */ 136 | int remove_pid (char *pidfile) 137 | { 138 | return unlink (pidfile); 139 | } 140 | 141 | -------------------------------------------------------------------------------- /lib/pidfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | pidfile.h - interact with pidfiles 3 | Copyright (c) 1995 Martin Schulze 4 | 5 | This file is part of the sysklogd package, a kernel and system log daemon. 6 | 7 | This file is part of GVPE. 8 | 9 | GVPE is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with gvpe; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 22 | */ 23 | 24 | #if __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* read_pid 29 | * 30 | * Reads the specified pidfile and returns the read pid. 31 | * 0 is returned if either there's no pidfile, it's empty 32 | * or no pid can be read. 33 | */ 34 | int read_pid (char *pidfile); 35 | 36 | /* check_pid 37 | * 38 | * Reads the pid using read_pid and looks up the pid in the process 39 | * table (using /proc) to determine if the process already exists. If 40 | * so 1 is returned, otherwise 0. 41 | */ 42 | int check_pid (char *pidfile); 43 | 44 | /* write_pid 45 | * 46 | * Writes the pid to the specified file. If that fails 0 is 47 | * returned, otherwise the pid. 48 | */ 49 | int write_pid (char *pidfile); 50 | 51 | /* remove_pid 52 | * 53 | * Remove the the specified file. The result from unlink(2) 54 | * is returned 55 | */ 56 | int remove_pid (char *pidfile); 57 | 58 | #if __cplusplus 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /m4/ChangeLog: -------------------------------------------------------------------------------- 1 | 2003-02-20 gettextize 2 | 3 | * iconv.m4: New file, from gettext-0.11.5. 4 | * intdiv0.m4: New file, from gettext-0.11.5. 5 | * isc-posix.m4: New file, from gettext-0.11.5. 6 | * lib-ld.m4: New file, from gettext-0.11.5. 7 | * lib-link.m4: New file, from gettext-0.11.5. 8 | * lib-prefix.m4: New file, from gettext-0.11.5. 9 | * Makefile.am (EXTRA_DIST): Add the new files. 10 | 11 | -------------------------------------------------------------------------------- /m4/Makefile.am.in: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in -*-Makefile-*- 2 | 3 | ##m4-files-begin 4 | ##m4-files-end 5 | 6 | Makefile.am: Makefile.am.in 7 | rm -f $@ $@t 8 | sed -n '1,/^##m4-files-begin/p' $< > $@t 9 | ( echo EXTRA_DIST = README Makefile.am.in; \ 10 | find . -type f -name '*.m4' -print |sed 's,^\./,,' |sort ) \ 11 | |fmt | (tr '\012' @; echo) \ 12 | |sed 's/@$$/%/;s/@/ \\@/g' |tr @% '\012\012' \ 13 | >> $@t 14 | sed -n '/^##m4-files-end/,$$p' $< >> $@t 15 | chmod a-w $@t 16 | mv $@t $@ 17 | -------------------------------------------------------------------------------- /m4/README: -------------------------------------------------------------------------------- 1 | These files are used by a program called aclocal (part of the GNU automake 2 | package). aclocal uses these files to create aclocal.m4 which is in turn 3 | used by autoconf to create the configure script at the the top level in 4 | this distribution. 5 | 6 | The Makefile.am file in this directory is automatically generated 7 | from the template file, Makefile.am.in. The generation will fail 8 | if you don't have all the right tools. 9 | -------------------------------------------------------------------------------- /m4/aclocal-include.m4: -------------------------------------------------------------------------------- 1 | # aclocal-include.m4 2 | # 3 | # This macro adds the name macrodir to the set of directories 4 | # that `aclocal' searches for macros. 5 | 6 | # serial 1 7 | 8 | dnl AM_ACLOCAL_INCLUDE(macrodir) 9 | AC_DEFUN([AM_ACLOCAL_INCLUDE], 10 | [ 11 | test -n "$ACLOCAL_FLAGS" && ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS" 12 | 13 | for k in $1 ; do ACLOCAL="$ACLOCAL -I $k" ; done 14 | ]) 15 | -------------------------------------------------------------------------------- /m4/codeset.m4: -------------------------------------------------------------------------------- 1 | # codeset.m4 serial AM1 (gettext-0.10.40) 2 | dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | dnl From Bruno Haible. 10 | 11 | AC_DEFUN([AM_LANGINFO_CODESET], 12 | [ 13 | AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset, 14 | [AC_TRY_LINK([#include ], 15 | [char* cs = nl_langinfo(CODESET);], 16 | am_cv_langinfo_codeset=yes, 17 | am_cv_langinfo_codeset=no) 18 | ]) 19 | if test $am_cv_langinfo_codeset = yes; then 20 | AC_DEFINE(HAVE_LANGINFO_CODESET, 1, 21 | [Define if you have and nl_langinfo(CODESET).]) 22 | fi 23 | ]) 24 | -------------------------------------------------------------------------------- /m4/glibc21.m4: -------------------------------------------------------------------------------- 1 | # glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40) 2 | dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | # Test for the GNU C Library, version 2.1 or newer. 10 | # From Bruno Haible. 11 | 12 | AC_DEFUN([jm_GLIBC21], 13 | [ 14 | AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer, 15 | ac_cv_gnu_library_2_1, 16 | [AC_EGREP_CPP([Lucky GNU user], 17 | [ 18 | #include 19 | #ifdef __GNU_LIBRARY__ 20 | #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) 21 | Lucky GNU user 22 | #endif 23 | #endif 24 | ], 25 | ac_cv_gnu_library_2_1=yes, 26 | ac_cv_gnu_library_2_1=no) 27 | ] 28 | ) 29 | AC_SUBST(GLIBC21) 30 | GLIBC21="$ac_cv_gnu_library_2_1" 31 | ] 32 | ) 33 | -------------------------------------------------------------------------------- /m4/iconv.m4: -------------------------------------------------------------------------------- 1 | # iconv.m4 serial AM4 (gettext-0.11.3) 2 | dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | dnl From Bruno Haible. 10 | 11 | AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], 12 | [ 13 | dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. 14 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 15 | AC_REQUIRE([AC_LIB_RPATH]) 16 | 17 | dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV 18 | dnl accordingly. 19 | AC_LIB_LINKFLAGS_BODY([iconv]) 20 | ]) 21 | 22 | AC_DEFUN([AM_ICONV_LINK], 23 | [ 24 | dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and 25 | dnl those with the standalone portable GNU libiconv installed). 26 | 27 | dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV 28 | dnl accordingly. 29 | AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) 30 | 31 | dnl Add $INCICONV to CPPFLAGS before performing the following checks, 32 | dnl because if the user has installed libiconv and not disabled its use 33 | dnl via --without-libiconv-prefix, he wants to use it. The first 34 | dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. 35 | am_save_CPPFLAGS="$CPPFLAGS" 36 | AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) 37 | 38 | AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ 39 | am_cv_func_iconv="no, consider installing GNU libiconv" 40 | am_cv_lib_iconv=no 41 | AC_TRY_LINK([#include 42 | #include ], 43 | [iconv_t cd = iconv_open("",""); 44 | iconv(cd,NULL,NULL,NULL,NULL); 45 | iconv_close(cd);], 46 | am_cv_func_iconv=yes) 47 | if test "$am_cv_func_iconv" != yes; then 48 | am_save_LIBS="$LIBS" 49 | LIBS="$LIBS $LIBICONV" 50 | AC_TRY_LINK([#include 51 | #include ], 52 | [iconv_t cd = iconv_open("",""); 53 | iconv(cd,NULL,NULL,NULL,NULL); 54 | iconv_close(cd);], 55 | am_cv_lib_iconv=yes 56 | am_cv_func_iconv=yes) 57 | LIBS="$am_save_LIBS" 58 | fi 59 | ]) 60 | if test "$am_cv_func_iconv" = yes; then 61 | AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) 62 | fi 63 | if test "$am_cv_lib_iconv" = yes; then 64 | AC_MSG_CHECKING([how to link with libiconv]) 65 | AC_MSG_RESULT([$LIBICONV]) 66 | else 67 | dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV 68 | dnl either. 69 | CPPFLAGS="$am_save_CPPFLAGS" 70 | LIBICONV= 71 | LTLIBICONV= 72 | fi 73 | AC_SUBST(LIBICONV) 74 | AC_SUBST(LTLIBICONV) 75 | ]) 76 | 77 | AC_DEFUN([AM_ICONV], 78 | [ 79 | AM_ICONV_LINK 80 | if test "$am_cv_func_iconv" = yes; then 81 | AC_MSG_CHECKING([for iconv declaration]) 82 | AC_CACHE_VAL(am_cv_proto_iconv, [ 83 | AC_TRY_COMPILE([ 84 | #include 85 | #include 86 | extern 87 | #ifdef __cplusplus 88 | "C" 89 | #endif 90 | #if defined(__STDC__) || defined(__cplusplus) 91 | size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); 92 | #else 93 | size_t iconv(); 94 | #endif 95 | ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") 96 | am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) 97 | am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` 98 | AC_MSG_RESULT([$]{ac_t:- 99 | }[$]am_cv_proto_iconv) 100 | AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, 101 | [Define as const if the declaration of iconv() needs const.]) 102 | fi 103 | ]) 104 | -------------------------------------------------------------------------------- /m4/intdiv0.m4: -------------------------------------------------------------------------------- 1 | # intdiv0.m4 serial 1 (gettext-0.11.3) 2 | dnl Copyright (C) 2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | dnl From Bruno Haible. 10 | 11 | AC_DEFUN([gt_INTDIV0], 12 | [ 13 | AC_REQUIRE([AC_PROG_CC])dnl 14 | AC_REQUIRE([AC_CANONICAL_HOST])dnl 15 | 16 | AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], 17 | gt_cv_int_divbyzero_sigfpe, 18 | [ 19 | AC_TRY_RUN([ 20 | #include 21 | #include 22 | 23 | static void 24 | #ifdef __cplusplus 25 | sigfpe_handler (int sig) 26 | #else 27 | sigfpe_handler (sig) int sig; 28 | #endif 29 | { 30 | /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ 31 | exit (sig != SIGFPE); 32 | } 33 | 34 | int x = 1; 35 | int y = 0; 36 | int z; 37 | int nan; 38 | 39 | int main () 40 | { 41 | signal (SIGFPE, sigfpe_handler); 42 | /* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ 43 | #if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) 44 | signal (SIGTRAP, sigfpe_handler); 45 | #endif 46 | /* Linux/SPARC yields signal SIGILL. */ 47 | #if defined (__sparc__) && defined (__linux__) 48 | signal (SIGILL, sigfpe_handler); 49 | #endif 50 | 51 | z = x / y; 52 | nan = y / y; 53 | exit (1); 54 | } 55 | ], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no, 56 | [ 57 | # Guess based on the CPU. 58 | case "$host_cpu" in 59 | alpha* | i[34567]86 | m68k | s390*) 60 | gt_cv_int_divbyzero_sigfpe="guessing yes";; 61 | *) 62 | gt_cv_int_divbyzero_sigfpe="guessing no";; 63 | esac 64 | ]) 65 | ]) 66 | case "$gt_cv_int_divbyzero_sigfpe" in 67 | *yes) value=1;; 68 | *) value=0;; 69 | esac 70 | AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value, 71 | [Define if integer division by zero raises signal SIGFPE.]) 72 | ]) 73 | -------------------------------------------------------------------------------- /m4/inttypes-pri.m4: -------------------------------------------------------------------------------- 1 | # inttypes-pri.m4 serial 1 (gettext-0.11.4) 2 | dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | dnl From Bruno Haible. 10 | 11 | # Define PRI_MACROS_BROKEN if exists and defines the PRI* 12 | # macros to non-string values. This is the case on AIX 4.3.3. 13 | 14 | AC_DEFUN([gt_INTTYPES_PRI], 15 | [ 16 | AC_REQUIRE([gt_HEADER_INTTYPES_H]) 17 | if test $gt_cv_header_inttypes_h = yes; then 18 | AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], 19 | gt_cv_inttypes_pri_broken, 20 | [ 21 | AC_TRY_COMPILE([#include 22 | #ifdef PRId32 23 | char *p = PRId32; 24 | #endif 25 | ], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes) 26 | ]) 27 | fi 28 | if test "$gt_cv_inttypes_pri_broken" = yes; then 29 | AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1, 30 | [Define if exists and defines unusable PRI* macros.]) 31 | fi 32 | ]) 33 | -------------------------------------------------------------------------------- /m4/inttypes.m4: -------------------------------------------------------------------------------- 1 | # inttypes.m4 serial 1 (gettext-0.11.4) 2 | dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | dnl From Paul Eggert. 10 | 11 | # Define HAVE_INTTYPES_H if exists and doesn't clash with 12 | # . 13 | 14 | AC_DEFUN([gt_HEADER_INTTYPES_H], 15 | [ 16 | AC_CACHE_CHECK([for inttypes.h], gt_cv_header_inttypes_h, 17 | [ 18 | AC_TRY_COMPILE( 19 | [#include 20 | #include ], 21 | [], gt_cv_header_inttypes_h=yes, gt_cv_header_inttypes_h=no) 22 | ]) 23 | if test $gt_cv_header_inttypes_h = yes; then 24 | AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1, 25 | [Define if exists and doesn't clash with .]) 26 | fi 27 | ]) 28 | -------------------------------------------------------------------------------- /m4/inttypes_h.m4: -------------------------------------------------------------------------------- 1 | # inttypes_h.m4 serial 4 (gettext-0.11.4) 2 | dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | dnl From Paul Eggert. 10 | 11 | # Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, 12 | # doesn't clash with , and declares uintmax_t. 13 | 14 | AC_DEFUN([jm_AC_HEADER_INTTYPES_H], 15 | [ 16 | AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h, 17 | [AC_TRY_COMPILE( 18 | [#include 19 | #include ], 20 | [uintmax_t i = (uintmax_t) -1;], 21 | jm_ac_cv_header_inttypes_h=yes, 22 | jm_ac_cv_header_inttypes_h=no)]) 23 | if test $jm_ac_cv_header_inttypes_h = yes; then 24 | AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1, 25 | [Define if exists, doesn't clash with , 26 | and declares uintmax_t. ]) 27 | fi 28 | ]) 29 | -------------------------------------------------------------------------------- /m4/isc-posix.m4: -------------------------------------------------------------------------------- 1 | # isc-posix.m4 serial 2 (gettext-0.11.2) 2 | dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | # This file is not needed with autoconf-2.53 and newer. Remove it in 2005. 10 | 11 | # This test replaces the one in autoconf. 12 | # Currently this macro should have the same name as the autoconf macro 13 | # because gettext's gettext.m4 (distributed in the automake package) 14 | # still uses it. Otherwise, the use in gettext.m4 makes autoheader 15 | # give these diagnostics: 16 | # configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX 17 | # configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX 18 | 19 | undefine([AC_ISC_POSIX]) 20 | 21 | AC_DEFUN([AC_ISC_POSIX], 22 | [ 23 | dnl This test replaces the obsolescent AC_ISC_POSIX kludge. 24 | AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) 25 | ] 26 | ) 27 | -------------------------------------------------------------------------------- /m4/lcmessage.m4: -------------------------------------------------------------------------------- 1 | # lcmessage.m4 serial 3 (gettext-0.11.3) 2 | dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | dnl 9 | dnl This file can can be used in projects which are not available under 10 | dnl the GNU General Public License or the GNU Library General Public 11 | dnl License but which still want to provide support for the GNU gettext 12 | dnl functionality. 13 | dnl Please note that the actual code of the GNU gettext library is covered 14 | dnl by the GNU Library General Public License, and the rest of the GNU 15 | dnl gettext package package is covered by the GNU General Public License. 16 | dnl They are *not* in the public domain. 17 | 18 | dnl Authors: 19 | dnl Ulrich Drepper , 1995. 20 | 21 | # Check whether LC_MESSAGES is available in . 22 | 23 | AC_DEFUN([AM_LC_MESSAGES], 24 | [ 25 | AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, 26 | [AC_TRY_LINK([#include ], [return LC_MESSAGES], 27 | am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) 28 | if test $am_cv_val_LC_MESSAGES = yes; then 29 | AC_DEFINE(HAVE_LC_MESSAGES, 1, 30 | [Define if your file defines LC_MESSAGES.]) 31 | fi 32 | ]) 33 | -------------------------------------------------------------------------------- /m4/lib-ld.m4: -------------------------------------------------------------------------------- 1 | # lib-ld.m4 serial 1 (gettext-0.11) 2 | dnl Copyright (C) 1996-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | dnl Subroutines of libtool.m4, 10 | dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision 11 | dnl with libtool.m4. 12 | 13 | dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. 14 | AC_DEFUN([AC_LIB_PROG_LD_GNU], 15 | [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, 16 | [# I'd rather use --version here, but apparently some GNU ld's only accept -v. 17 | if $LD -v 2>&1 &5; then 18 | acl_cv_prog_gnu_ld=yes 19 | else 20 | acl_cv_prog_gnu_ld=no 21 | fi]) 22 | with_gnu_ld=$acl_cv_prog_gnu_ld 23 | ]) 24 | 25 | dnl From libtool-1.4. Sets the variable LD. 26 | AC_DEFUN([AC_LIB_PROG_LD], 27 | [AC_ARG_WITH(gnu-ld, 28 | [ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], 29 | test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) 30 | AC_REQUIRE([AC_PROG_CC])dnl 31 | AC_REQUIRE([AC_CANONICAL_HOST])dnl 32 | ac_prog=ld 33 | if test "$GCC" = yes; then 34 | # Check if gcc -print-prog-name=ld gives a path. 35 | AC_MSG_CHECKING([for ld used by GCC]) 36 | case $host in 37 | *-*-mingw*) 38 | # gcc leaves a trailing carriage return which upsets mingw 39 | ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; 40 | *) 41 | ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; 42 | esac 43 | case $ac_prog in 44 | # Accept absolute paths. 45 | [[\\/]* | [A-Za-z]:[\\/]*)] 46 | [re_direlt='/[^/][^/]*/\.\./'] 47 | # Canonicalize the path of ld 48 | ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` 49 | while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do 50 | ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` 51 | done 52 | test -z "$LD" && LD="$ac_prog" 53 | ;; 54 | "") 55 | # If it fails, then pretend we aren't using GCC. 56 | ac_prog=ld 57 | ;; 58 | *) 59 | # If it is relative, then search for the first ld in PATH. 60 | with_gnu_ld=unknown 61 | ;; 62 | esac 63 | elif test "$with_gnu_ld" = yes; then 64 | AC_MSG_CHECKING([for GNU ld]) 65 | else 66 | AC_MSG_CHECKING([for non-GNU ld]) 67 | fi 68 | AC_CACHE_VAL(acl_cv_path_LD, 69 | [if test -z "$LD"; then 70 | IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" 71 | for ac_dir in $PATH; do 72 | test -z "$ac_dir" && ac_dir=. 73 | if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then 74 | acl_cv_path_LD="$ac_dir/$ac_prog" 75 | # Check to see if the program is GNU ld. I'd rather use --version, 76 | # but apparently some GNU ld's only accept -v. 77 | # Break only if it was the GNU/non-GNU ld that we prefer. 78 | if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then 79 | test "$with_gnu_ld" != no && break 80 | else 81 | test "$with_gnu_ld" != yes && break 82 | fi 83 | fi 84 | done 85 | IFS="$ac_save_ifs" 86 | else 87 | acl_cv_path_LD="$LD" # Let the user override the test with a path. 88 | fi]) 89 | LD="$acl_cv_path_LD" 90 | if test -n "$LD"; then 91 | AC_MSG_RESULT($LD) 92 | else 93 | AC_MSG_RESULT(no) 94 | fi 95 | test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) 96 | AC_LIB_PROG_LD_GNU 97 | ]) 98 | -------------------------------------------------------------------------------- /m4/lib-prefix.m4: -------------------------------------------------------------------------------- 1 | # lib-prefix.m4 serial 1 (gettext-0.11) 2 | dnl Copyright (C) 2001-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | dnl From Bruno Haible. 10 | 11 | dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed 12 | dnl to access previously installed libraries. The basic assumption is that 13 | dnl a user will want packages to use other packages he previously installed 14 | dnl with the same --prefix option. 15 | dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate 16 | dnl libraries, but is otherwise very convenient. 17 | AC_DEFUN([AC_LIB_PREFIX], 18 | [ 19 | AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) 20 | AC_REQUIRE([AC_PROG_CC]) 21 | AC_REQUIRE([AC_CANONICAL_HOST]) 22 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 23 | dnl By default, look in $includedir and $libdir. 24 | use_additional=yes 25 | AC_LIB_WITH_FINAL_PREFIX([ 26 | eval additional_includedir=\"$includedir\" 27 | eval additional_libdir=\"$libdir\" 28 | ]) 29 | AC_ARG_WITH([lib-prefix], 30 | [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib 31 | --without-lib-prefix don't search for libraries in includedir and libdir], 32 | [ 33 | if test "X$withval" = "Xno"; then 34 | use_additional=no 35 | else 36 | if test "X$withval" = "X"; then 37 | AC_LIB_WITH_FINAL_PREFIX([ 38 | eval additional_includedir=\"$includedir\" 39 | eval additional_libdir=\"$libdir\" 40 | ]) 41 | else 42 | additional_includedir="$withval/include" 43 | additional_libdir="$withval/lib" 44 | fi 45 | fi 46 | ]) 47 | if test $use_additional = yes; then 48 | dnl Potentially add $additional_includedir to $CPPFLAGS. 49 | dnl But don't add it 50 | dnl 1. if it's the standard /usr/include, 51 | dnl 2. if it's already present in $CPPFLAGS, 52 | dnl 3. if it's /usr/local/include and we are using GCC on Linux, 53 | dnl 4. if it doesn't exist as a directory. 54 | if test "X$additional_includedir" != "X/usr/include"; then 55 | haveit= 56 | for x in $CPPFLAGS; do 57 | AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 58 | if test "X$x" = "X-I$additional_includedir"; then 59 | haveit=yes 60 | break 61 | fi 62 | done 63 | if test -z "$haveit"; then 64 | if test "X$additional_includedir" = "X/usr/local/include"; then 65 | if test -n "$GCC"; then 66 | case $host_os in 67 | linux*) haveit=yes;; 68 | esac 69 | fi 70 | fi 71 | if test -z "$haveit"; then 72 | if test -d "$additional_includedir"; then 73 | dnl Really add $additional_includedir to $CPPFLAGS. 74 | CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" 75 | fi 76 | fi 77 | fi 78 | fi 79 | dnl Potentially add $additional_libdir to $LDFLAGS. 80 | dnl But don't add it 81 | dnl 1. if it's the standard /usr/lib, 82 | dnl 2. if it's already present in $LDFLAGS, 83 | dnl 3. if it's /usr/local/lib and we are using GCC on Linux, 84 | dnl 4. if it doesn't exist as a directory. 85 | if test "X$additional_libdir" != "X/usr/lib"; then 86 | haveit= 87 | for x in $LDFLAGS; do 88 | AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 89 | if test "X$x" = "X-L$additional_libdir"; then 90 | haveit=yes 91 | break 92 | fi 93 | done 94 | if test -z "$haveit"; then 95 | if test "X$additional_libdir" = "X/usr/local/lib"; then 96 | if test -n "$GCC"; then 97 | case $host_os in 98 | linux*) haveit=yes;; 99 | esac 100 | fi 101 | fi 102 | if test -z "$haveit"; then 103 | if test -d "$additional_libdir"; then 104 | dnl Really add $additional_libdir to $LDFLAGS. 105 | LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" 106 | fi 107 | fi 108 | fi 109 | fi 110 | fi 111 | ]) 112 | 113 | dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, 114 | dnl acl_final_exec_prefix, containing the values to which $prefix and 115 | dnl $exec_prefix will expand at the end of the configure script. 116 | AC_DEFUN([AC_LIB_PREPARE_PREFIX], 117 | [ 118 | dnl Unfortunately, prefix and exec_prefix get only finally determined 119 | dnl at the end of configure. 120 | if test "X$prefix" = "XNONE"; then 121 | acl_final_prefix="$ac_default_prefix" 122 | else 123 | acl_final_prefix="$prefix" 124 | fi 125 | if test "X$exec_prefix" = "XNONE"; then 126 | acl_final_exec_prefix='${prefix}' 127 | else 128 | acl_final_exec_prefix="$exec_prefix" 129 | fi 130 | acl_save_prefix="$prefix" 131 | prefix="$acl_final_prefix" 132 | eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" 133 | prefix="$acl_save_prefix" 134 | ]) 135 | 136 | dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the 137 | dnl variables prefix and exec_prefix bound to the values they will have 138 | dnl at the end of the configure script. 139 | AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], 140 | [ 141 | acl_save_prefix="$prefix" 142 | prefix="$acl_final_prefix" 143 | acl_save_exec_prefix="$exec_prefix" 144 | exec_prefix="$acl_final_exec_prefix" 145 | $1 146 | exec_prefix="$acl_save_exec_prefix" 147 | prefix="$acl_save_prefix" 148 | ]) 149 | -------------------------------------------------------------------------------- /m4/openssl.m4: -------------------------------------------------------------------------------- 1 | dnl Check to find the OpenSSL headers/libraries 2 | 3 | AC_DEFUN(tinc_OPENSSL, 4 | [ 5 | tinc_ac_save_CPPFLAGS="$CPPFLAGS" 6 | 7 | AC_ARG_WITH(openssl-include, 8 | [ --with-openssl-include=DIR OpenSSL headers directory (without trailing /openssl)], 9 | [openssl_include="$withval" 10 | CFLAGS="$CFLAGS -I$withval" 11 | CPPFLAGS="$CPPFLAGS -I$withval"] 12 | ) 13 | 14 | AC_ARG_WITH(openssl-lib, 15 | [ --with-openssl-lib=DIR OpenSSL library directory], 16 | [openssl_lib="$withval" 17 | LIBS="$LIBS -L$withval"] 18 | ) 19 | 20 | AC_CHECK_HEADERS(openssl/evp.h openssl/rsa.h openssl/rand.h openssl/err.h openssl/sha.h openssl/pem.h, 21 | [], 22 | [AC_MSG_ERROR([OpenSSL header files not found.]); break] 23 | ) 24 | 25 | CPPFLAGS="$tinc_ac_save_CPPFLAGS" 26 | 27 | AC_CHECK_LIB(crypto, SHA1_Init, 28 | [LIBS="$LIBS -lcrypto"], 29 | [AC_MSG_ERROR([OpenSSL libraries not found.])] 30 | ) 31 | 32 | AC_CHECK_FUNCS([RAND_pseudo_bytes OPENSSL_add_all_algorithms_noconf OpenSSL_add_all_algorithms SSLeay_add_all_algorithms]) 33 | 34 | AC_CHECK_FUNC(dlopen, 35 | [], 36 | [AC_CHECK_LIB(dl, dlopen, 37 | [LIBS="$LIBS -ldl"], 38 | [AC_MSG_ERROR([OpenSSL depends on libdl.])] 39 | )] 40 | ) 41 | 42 | AC_CHECK_FUNC(inflate, 43 | [], 44 | [AC_CHECK_LIB(z, inflate, 45 | [LIBS="$LIBS -lz"], 46 | [AC_MSG_ERROR([OpenSSL depends on libz.])] 47 | )] 48 | ) 49 | ]) 50 | -------------------------------------------------------------------------------- /m4/progtest.m4: -------------------------------------------------------------------------------- 1 | # progtest.m4 serial 2 (gettext-0.10.40) 2 | dnl Copyright (C) 1996-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | dnl 9 | dnl This file can can be used in projects which are not available under 10 | dnl the GNU General Public License or the GNU Library General Public 11 | dnl License but which still want to provide support for the GNU gettext 12 | dnl functionality. 13 | dnl Please note that the actual code of the GNU gettext library is covered 14 | dnl by the GNU Library General Public License, and the rest of the GNU 15 | dnl gettext package package is covered by the GNU General Public License. 16 | dnl They are *not* in the public domain. 17 | 18 | dnl Authors: 19 | dnl Ulrich Drepper , 1996. 20 | 21 | # Search path for a program which passes the given test. 22 | 23 | dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, 24 | dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) 25 | AC_DEFUN([AM_PATH_PROG_WITH_TEST], 26 | [# Extract the first word of "$2", so it can be a program name with args. 27 | set dummy $2; ac_word=[$]2 28 | AC_MSG_CHECKING([for $ac_word]) 29 | AC_CACHE_VAL(ac_cv_path_$1, 30 | [case "[$]$1" in 31 | /*) 32 | ac_cv_path_$1="[$]$1" # Let the user override the test with a path. 33 | ;; 34 | *) 35 | IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" 36 | for ac_dir in ifelse([$5], , $PATH, [$5]); do 37 | test -z "$ac_dir" && ac_dir=. 38 | if test -f $ac_dir/$ac_word; then 39 | if [$3]; then 40 | ac_cv_path_$1="$ac_dir/$ac_word" 41 | break 42 | fi 43 | fi 44 | done 45 | IFS="$ac_save_ifs" 46 | dnl If no 4th arg is given, leave the cache variable unset, 47 | dnl so AC_PATH_PROGS will keep looking. 48 | ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" 49 | ])dnl 50 | ;; 51 | esac])dnl 52 | $1="$ac_cv_path_$1" 53 | if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then 54 | AC_MSG_RESULT([$]$1) 55 | else 56 | AC_MSG_RESULT(no) 57 | fi 58 | AC_SUBST($1)dnl 59 | ]) 60 | -------------------------------------------------------------------------------- /m4/stdint_h.m4: -------------------------------------------------------------------------------- 1 | # stdint_h.m4 serial 2 (gettext-0.11.4) 2 | dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | dnl From Paul Eggert. 10 | 11 | # Define HAVE_STDINT_H_WITH_UINTMAX if exists, 12 | # doesn't clash with , and declares uintmax_t. 13 | 14 | AC_DEFUN([jm_AC_HEADER_STDINT_H], 15 | [ 16 | AC_CACHE_CHECK([for stdint.h], jm_ac_cv_header_stdint_h, 17 | [AC_TRY_COMPILE( 18 | [#include 19 | #include ], 20 | [uintmax_t i = (uintmax_t) -1;], 21 | jm_ac_cv_header_stdint_h=yes, 22 | jm_ac_cv_header_stdint_h=no)]) 23 | if test $jm_ac_cv_header_stdint_h = yes; then 24 | AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1, 25 | [Define if exists, doesn't clash with , 26 | and declares uintmax_t. ]) 27 | fi 28 | ]) 29 | -------------------------------------------------------------------------------- /m4/tuntap.m4: -------------------------------------------------------------------------------- 1 | dnl Check to find out whether the running kernel has support for TUN/TAP 2 | 3 | AC_DEFUN(tinc_TUNTAP, 4 | [ 5 | AC_ARG_WITH(kernel, 6 | [ --with-kernel=dir give the directory with kernel sources] 7 | [ (default: /usr/src/linux)], 8 | kerneldir="$withval", 9 | kerneldir="/usr/src/linux" 10 | ) 11 | 12 | AC_CACHE_CHECK([for linux/if_tun.h], tinc_cv_linux_if_tun_h, 13 | [ 14 | AC_TRY_COMPILE([#include "$kerneldir/include/linux/if_tun.h"], 15 | [int a = IFF_TAP;], 16 | if_tun_h="\"$kerneldir/include/linux/if_tun.h\"", 17 | [AC_TRY_COMPILE([#include ], 18 | [int a = IFF_TAP;], 19 | if_tun_h="default", 20 | if_tun_h="no" 21 | )] 22 | ) 23 | 24 | if test $if_tun_h = no; then 25 | tinc_cv_linux_if_tun_h=none 26 | else 27 | tinc_cv_linux_if_tun_h="$if_tun_h" 28 | fi 29 | ]) 30 | 31 | if test $tinc_cv_linux_if_tun_h != none; then 32 | AC_DEFINE(HAVE_TUNTAP, 1, [Universal tun/tap driver present]) 33 | if test $tinc_cv_linux_if_tun_h != default; then 34 | AC_DEFINE_UNQUOTED(LINUX_IF_TUN_H, $tinc_cv_linux_if_tun_h, [Location of if_tun.h]) 35 | fi 36 | fi 37 | AC_SUBST(LINUX_IF_TUN_H) 38 | AC_SUBST(HAVE_TUNTAP) 39 | ]) 40 | -------------------------------------------------------------------------------- /m4/uintmax_t.m4: -------------------------------------------------------------------------------- 1 | # uintmax_t.m4 serial 6 (gettext-0.11) 2 | dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | dnl From Paul Eggert. 10 | 11 | AC_PREREQ(2.13) 12 | 13 | # Define uintmax_t to `unsigned long' or `unsigned long long' 14 | # if does not exist. 15 | 16 | AC_DEFUN([jm_AC_TYPE_UINTMAX_T], 17 | [ 18 | AC_REQUIRE([jm_AC_HEADER_INTTYPES_H]) 19 | AC_REQUIRE([jm_AC_HEADER_STDINT_H]) 20 | if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then 21 | AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG]) 22 | test $ac_cv_type_unsigned_long_long = yes \ 23 | && ac_type='unsigned long long' \ 24 | || ac_type='unsigned long' 25 | AC_DEFINE_UNQUOTED(uintmax_t, $ac_type, 26 | [Define to unsigned long or unsigned long long 27 | if and don't define.]) 28 | fi 29 | ]) 30 | -------------------------------------------------------------------------------- /m4/ulonglong.m4: -------------------------------------------------------------------------------- 1 | # ulonglong.m4 serial 2 (fileutils-4.0.32, gettext-0.10.40) 2 | dnl Copyright (C) 1999-2002 Free Software Foundation, Inc. 3 | dnl This file is free software, distributed under the terms of the GNU 4 | dnl General Public License. As a special exception to the GNU General 5 | dnl Public License, this file may be distributed as part of a program 6 | dnl that contains a configuration script generated by Autoconf, under 7 | dnl the same distribution terms as the rest of that program. 8 | 9 | dnl From Paul Eggert. 10 | 11 | AC_DEFUN([jm_AC_TYPE_UNSIGNED_LONG_LONG], 12 | [ 13 | AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long, 14 | [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;], 15 | [unsigned long long ullmax = (unsigned long long) -1; 16 | return ull << i | ull >> i | ullmax / ull | ullmax % ull;], 17 | ac_cv_type_unsigned_long_long=yes, 18 | ac_cv_type_unsigned_long_long=no)]) 19 | if test $ac_cv_type_unsigned_long_long = yes; then 20 | AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1, 21 | [Define if you have the unsigned long long type.]) 22 | fi 23 | ]) 24 | -------------------------------------------------------------------------------- /mkdistro: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TARGET="dist-$1" 4 | 5 | autoconf 6 | autoheader 7 | automake 8 | #./configure 9 | 10 | CONFIGURE="--prefix=/opt/gvpe --sysconfdir=/etc --localstatedir=/var --enable-tcp --enable-http-proxy" 11 | 12 | eval $(grep VERSION= configure) 13 | 14 | mkdir -p $TARGET 15 | 16 | BASE=/tmp 17 | MAKE=make 18 | ARCH="$1" 19 | 20 | case "$ARCH" in 21 | gnu-linux ) 22 | HOST=root@localhost 23 | CONFIGURE="$CONFIGURE --enable-icmp" 24 | ;; 25 | freebsd ) 26 | HOST=root@192.168.108.6 27 | CONFIGURE="$CONFIGURE --enable-icmp" 28 | MAKE=gmake 29 | ARCH="$ARCH-x86" 30 | ;; 31 | openbsd ) 32 | HOST=root@192.168.108.7 33 | CONFIGURE="$CONFIGURE --enable-icmp" 34 | ARCH="$ARCH-x86" 35 | ;; 36 | netbsd ) 37 | HOST=root@192.168.108.5 38 | CONFIGURE="$CONFIGURE --enable-icmp --with-openssl-include=/usr/local/ssl/include --with-openssl-lib=/usr/local/ssl/lib" 39 | ARCH="$ARCH-x86" 40 | ;; 41 | darwin ) 42 | HOST=root@imac.laendle 43 | BASE=/Users/schmorp 44 | CONFIGURE="$CONFIGURE --enable-icmp --with-openssl-include=$BASE/include --with-libintl-prefix=/sw" 45 | MAKE="make LIBS='$BASE/lib/libcrypto.a -L/sw/lib -lintl'" 46 | ARCH="$ARCH-x86" 47 | ;; 48 | cygwin ) 49 | HOST=vm 50 | CONFIGURE="$CONFIGURE --enable-icmp" 51 | ;; 52 | * ) 53 | exit 1 54 | ;; 55 | esac 56 | 57 | make distdir="$TARGET/gvpe" distdir 58 | rsync -avzPessh $TARGET/gvpe $HOST:$BASE/. --delete 59 | rm -rf $TARGET/gvpe 60 | 61 | echo "$CONFIGURE" >$TARGET/configure 62 | 63 | ssh $HOST " 64 | set -x 65 | cd $BASE/gvpe || exit 1; 66 | ./configure $CONFIGURE || exit 2; 67 | rm -rf $BASE/dist; 68 | $MAKE all || exit 3; 69 | $MAKE prefix=$BASE/dist install || exit 4; 70 | strip $BASE/dist/sbin/gvpe $BASE/dist/bin/gvpectrl; 71 | strip $BASE/dist/sbin/gvpe.exe $BASE/dist/bin/gvpectrl.exe; 72 | echo gvpectrl; 73 | ldd $BASE/dist/bin/gvpectrl; 74 | echo gvpe; 75 | ldd $BASE/dist/sbin/gvpe; 76 | uname -a 77 | true; 78 | " 2>&1 | tee $TARGET/buildlog || exit 1 79 | 80 | mkdir -p $TARGET/opt 81 | rsync -avzPessh $HOST:$BASE/dist/. $TARGET/opt/. --delete 82 | ( 83 | cd $TARGET || exit 99 84 | mkdir opt/doc 85 | mkdir opt/doc/gvpe 86 | mv buildlog opt/doc/gvpe/README.buildlog 87 | mv configure opt/doc/gvpe/README.configure 88 | chmod u=rwX,go=rX -R opt 89 | ) 90 | 91 | mkdir -p bindist 92 | tar cCf $TARGET - . | gzip -9 >bindist/gvpe-$VERSION-$ARCH.tar.gz 93 | rm -rf $TARGET 94 | 95 | -------------------------------------------------------------------------------- /po/ChangeLog: -------------------------------------------------------------------------------- 1 | 2003-02-21 gettextize 2 | 3 | * Makefile.in.in: New file, from gettext-0.11.5. 4 | 5 | -------------------------------------------------------------------------------- /po/Makevars: -------------------------------------------------------------------------------- 1 | # Makefile variables for PO directory in any package using GNU gettext. 2 | 3 | # Usually the message domain is the same as the package name. 4 | DOMAIN = $(PACKAGE) 5 | 6 | # These two variables depend on the location of this directory. 7 | subdir = po 8 | top_builddir = .. 9 | 10 | # These options get passed to xgettext. 11 | XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ 12 | 13 | # This is the copyright holder that gets inserted into the header of the 14 | # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 15 | # package. (Note that the msgstr strings, extracted from the package's 16 | # sources, belong to the copyright holder of the package.) Translators are 17 | # expected to transfer the copyright for their translations to this person 18 | # or entity, or to disclaim their copyright. The empty string stands for 19 | # the public domain; in this case the translators are expected to disclaim 20 | # their copyright. 21 | COPYRIGHT_HOLDER = Marc Lehmann 22 | 23 | # This is the list of locale categories, beyond LC_MESSAGES, for which the 24 | # message catalogs shall be used. It is usually empty. 25 | EXTRA_LOCALE_CATEGORIES = 26 | -------------------------------------------------------------------------------- /po/Makevars.template: -------------------------------------------------------------------------------- 1 | # Makefile variables for PO directory in any package using GNU gettext. 2 | 3 | # Usually the message domain is the same as the package name. 4 | DOMAIN = $(PACKAGE) 5 | 6 | # These two variables depend on the location of this directory. 7 | subdir = po 8 | top_builddir = .. 9 | 10 | # These options get passed to xgettext. 11 | XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ 12 | 13 | # This is the copyright holder that gets inserted into the header of the 14 | # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 15 | # package. (Note that the msgstr strings, extracted from the package's 16 | # sources, belong to the copyright holder of the package.) Translators are 17 | # expected to transfer the copyright for their translations to this person 18 | # or entity, or to disclaim their copyright. The empty string stands for 19 | # the public domain; in this case the translators are expected to disclaim 20 | # their copyright. 21 | COPYRIGHT_HOLDER = Free Software Foundation, Inc. 22 | 23 | # This is the list of locale categories, beyond LC_MESSAGES, for which the 24 | # message catalogs shall be used. It is usually empty. 25 | EXTRA_LOCALE_CATEGORIES = 26 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | lib/pidfile.c 2 | src/tincd/cygwin/device.c 3 | src/tincd/darwin/device.c 4 | src/tincd/freebsd/device.c 5 | src/tincd/linux/device.c 6 | src/tincd/mingw/common.h 7 | src/tincd/mingw/device.c 8 | src/tincd/netbsd/device.c 9 | src/tincd/openbsd/device.c 10 | src/tincd/raw_socket/device.c 11 | src/tincd/solaris/device.c 12 | src/tincd/uml_socket/device.c 13 | src/callback.h 14 | src/conf.C 15 | src/conf.h 16 | src/connection.C 17 | src/connection.h 18 | src/device-cygwin.C 19 | src/device-linux.C 20 | src/device-tincd.C 21 | src/device-darwin.C 22 | src/device.C 23 | src/device.h 24 | src/ether_emu.C 25 | src/global.h 26 | src/gvpe.C 27 | src/gvpectrl.C 28 | src/lzf/lzf.h 29 | src/lzf/lzfP.h 30 | src/lzf/lzf_c.c 31 | src/lzf/lzf_d.c 32 | src/netcompat.h 33 | src/slog.C 34 | src/slog.h 35 | src/sockinfo.C 36 | src/sockinfo.h 37 | src/util.C 38 | src/util.h 39 | src/vpn.C 40 | src/vpn.h 41 | src/vpn_dns.C 42 | src/vpn_tcp.C 43 | -------------------------------------------------------------------------------- /po/Rules-quot: -------------------------------------------------------------------------------- 1 | # Special Makefile rules for English message catalogs with quotation marks. 2 | 3 | DISTFILES.common.extra1 = quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot 4 | 5 | .SUFFIXES: .insert-header .po-update-en 6 | 7 | en@quot.po-update: en@quot.po-update-en 8 | en@boldquot.po-update: en@boldquot.po-update-en 9 | 10 | .insert-header.po-update-en: 11 | @lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \ 12 | if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \ 13 | tmpdir=`pwd`; \ 14 | echo "$$lang:"; \ 15 | ll=`echo $$lang | sed -e 's/@.*//'`; \ 16 | LC_ALL=C; export LC_ALL; \ 17 | cd $(srcdir); \ 18 | if $(MSGINIT) -i $(DOMAIN).pot --no-translator -l $$ll -o - 2>/dev/null | sed -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | $(MSGFILTER) sed -f `echo $$lang | sed -e 's/.*@//'`.sed 2>/dev/null > $$tmpdir/$$lang.new.po; then \ 19 | if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ 20 | rm -f $$tmpdir/$$lang.new.po; \ 21 | else \ 22 | if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ 23 | :; \ 24 | else \ 25 | echo "creation of $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ 26 | exit 1; \ 27 | fi; \ 28 | fi; \ 29 | else \ 30 | echo "creation of $$lang.po failed!" 1>&2; \ 31 | rm -f $$tmpdir/$$lang.new.po; \ 32 | fi 33 | 34 | en@quot.insert-header: insert-header.sin 35 | sed -e '/^#/d' -e 's/HEADER/en@quot.header/g' $(srcdir)/insert-header.sin > en@quot.insert-header 36 | 37 | en@boldquot.insert-header: insert-header.sin 38 | sed -e '/^#/d' -e 's/HEADER/en@boldquot.header/g' $(srcdir)/insert-header.sin > en@boldquot.insert-header 39 | 40 | mostlyclean: mostlyclean-quot 41 | mostlyclean-quot: 42 | rm -f *.insert-header 43 | -------------------------------------------------------------------------------- /po/boldquot.sed: -------------------------------------------------------------------------------- 1 | s/"\([^"]*\)"/“\1”/g 2 | s/`\([^`']*\)'/‘\1’/g 3 | s/ '\([^`']*\)' / ‘\1’ /g 4 | s/ '\([^`']*\)'$/ ‘\1’/g 5 | s/^'\([^`']*\)' /‘\1’ /g 6 | s/“”/""/g 7 | s/“/“/g 8 | s/”/”/g 9 | s/‘/‘/g 10 | s/’/’/g 11 | -------------------------------------------------------------------------------- /po/en@boldquot.header: -------------------------------------------------------------------------------- 1 | # All this catalog "translates" are quotation characters. 2 | # The msgids must be ASCII and therefore cannot contain real quotation 3 | # characters, only substitutes like grave accent (0x60), apostrophe (0x27) 4 | # and double quote (0x22). These substitutes look strange; see 5 | # http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html 6 | # 7 | # This catalog translates grave accent (0x60) and apostrophe (0x27) to 8 | # left single quotation mark (U+2018) and right single quotation mark (U+2019). 9 | # It also translates pairs of apostrophe (0x27) to 10 | # left single quotation mark (U+2018) and right single quotation mark (U+2019) 11 | # and pairs of quotation mark (0x22) to 12 | # left double quotation mark (U+201C) and right double quotation mark (U+201D). 13 | # 14 | # When output to an UTF-8 terminal, the quotation characters appear perfectly. 15 | # When output to an ISO-8859-1 terminal, the single quotation marks are 16 | # transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to 17 | # grave/acute accent (by libiconv), and the double quotation marks are 18 | # transliterated to 0x22. 19 | # When output to an ASCII terminal, the single quotation marks are 20 | # transliterated to apostrophes, and the double quotation marks are 21 | # transliterated to 0x22. 22 | # 23 | # This catalog furthermore displays the text between the quotation marks in 24 | # bold face, assuming the VT100/XTerm escape sequences. 25 | # 26 | -------------------------------------------------------------------------------- /po/en@quot.header: -------------------------------------------------------------------------------- 1 | # All this catalog "translates" are quotation characters. 2 | # The msgids must be ASCII and therefore cannot contain real quotation 3 | # characters, only substitutes like grave accent (0x60), apostrophe (0x27) 4 | # and double quote (0x22). These substitutes look strange; see 5 | # http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html 6 | # 7 | # This catalog translates grave accent (0x60) and apostrophe (0x27) to 8 | # left single quotation mark (U+2018) and right single quotation mark (U+2019). 9 | # It also translates pairs of apostrophe (0x27) to 10 | # left single quotation mark (U+2018) and right single quotation mark (U+2019) 11 | # and pairs of quotation mark (0x22) to 12 | # left double quotation mark (U+201C) and right double quotation mark (U+201D). 13 | # 14 | # When output to an UTF-8 terminal, the quotation characters appear perfectly. 15 | # When output to an ISO-8859-1 terminal, the single quotation marks are 16 | # transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to 17 | # grave/acute accent (by libiconv), and the double quotation marks are 18 | # transliterated to 0x22. 19 | # When output to an ASCII terminal, the single quotation marks are 20 | # transliterated to apostrophes, and the double quotation marks are 21 | # transliterated to 0x22. 22 | # 23 | -------------------------------------------------------------------------------- /po/insert-header.sin: -------------------------------------------------------------------------------- 1 | # Sed script that inserts the file called HEADER before the header entry. 2 | # 3 | # At each occurrence of a line starting with "msgid ", we execute the following 4 | # commands. At the first occurrence, insert the file. At the following 5 | # occurrences, do nothing. The distinction between the first and the following 6 | # occurrences is achieved by looking at the hold space. 7 | /^msgid /{ 8 | x 9 | # Test if the hold space is empty. 10 | s/m/m/ 11 | ta 12 | # Yes it was empty. First occurrence. Read the file. 13 | r HEADER 14 | # Output the file's contents by reading the next line. But don't lose the 15 | # current line while doing this. 16 | g 17 | N 18 | bb 19 | :a 20 | # The hold space was nonempty. Following occurrences. Do nothing. 21 | x 22 | :b 23 | } 24 | -------------------------------------------------------------------------------- /po/quot.sed: -------------------------------------------------------------------------------- 1 | s/"\([^"]*\)"/“\1”/g 2 | s/`\([^`']*\)'/‘\1’/g 3 | s/ '\([^`']*\)' / ‘\1’ /g 4 | s/ '\([^`']*\)'$/ ‘\1’/g 5 | s/^'\([^`']*\)' /‘\1’ /g 6 | s/“”/""/g 7 | -------------------------------------------------------------------------------- /po/remove-potcdate.sin: -------------------------------------------------------------------------------- 1 | # Sed script that remove the POT-Creation-Date line in the header entry 2 | # from a POT file. 3 | # 4 | # The distinction between the first and the following occurrences of the 5 | # pattern is achieved by looking at the hold space. 6 | /^"POT-Creation-Date: .*"$/{ 7 | x 8 | # Test if the hold space is empty. 9 | s/P/P/ 10 | ta 11 | # Yes it was empty. First occurrence. Remove the line. 12 | g 13 | d 14 | bb 15 | :a 16 | # The hold space was nonempty. Following occurrences. Do nothing. 17 | x 18 | :b 19 | } 20 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Produce this file with automake to get Makefile.in 2 | 3 | #SUBDIRS = rohc 4 | 5 | sbin_PROGRAMS = gvpe 6 | bin_PROGRAMS = gvpectrl 7 | 8 | EXTRA_DIST = device-linux.C device-cygwin.C device-tincd.C device-darwin.C callback.pl \ 9 | tincd/apply tincd/fixit \ 10 | tincd/cygwin/device.c tincd/darwin/device.c tincd/freebsd/device.c \ 11 | tincd/linux/device.c tincd/mingw/common.h tincd/mingw/device.c tincd/netbsd/device.c \ 12 | tincd/openbsd/device.c tincd/raw_socket/device.c tincd/solaris/device.c \ 13 | tincd/uml_socket/device.c tincd/bsd/device.c \ 14 | ether_emu.C lzf/lzf_c.c lzf/lzf_d.c 15 | 16 | INCLUDES = -I$(top_builddir) -I$(top_srcdir)/lib -I$(top_srcdir)/libev @INCLUDES@ 17 | 18 | LIBS = @LIBS@ @LIBINTL@ 19 | 20 | if ROHC 21 | ROHCLIB = rohc/librohc.a 22 | else 23 | ROHCLIB = 24 | endif 25 | 26 | COMMON = global.h conf.h conf.C util.h util.C \ 27 | slog.h slog.C netcompat.h ev_cpp.h ev_cpp.C 28 | 29 | gvpe_SOURCES = gvpe.C vpn.h vpn.C vpn_tcp.C vpn_dns.C \ 30 | sockinfo.h sockinfo.C \ 31 | lzf/lzf.h lzf/lzfP.h \ 32 | connection.h connection.C callback.h device.h device.C \ 33 | $(COMMON) 34 | gvpe_LDADD = $(top_builddir)/lib/libgvpe.a $(ROHCLIB) 35 | gvpe_LDFLAGS = @LDFLAGS_DAEMON@ 36 | 37 | gvpectrl_SOURCES = gvpectrl.C $(COMMON) 38 | gvpectrl_LDADD = $(top_builddir)/lib/libgvpe.a 39 | 40 | localedir = $(datadir)/locale 41 | 42 | DEFINES = -DPKGLIBDIR=$(pkglibdir) -DCONFDIR=\"$(sysconfdir)\" \ 43 | -DLOCALEDIR=\"$(localedir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" \ 44 | -DIFTYPE_@IFTYPE@=1 -DIF_@IFSUBTYPE@=1 45 | 46 | AM_CFLAGS = $(DEFINES) 47 | AM_CXXFLAGS = $(DEFINES) 48 | 49 | dist-hook: 50 | rm -f `find . -type l` 51 | 52 | -------------------------------------------------------------------------------- /src/callback.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | 5 | print < 13 | * 14 | * This file is part of GVPE. 15 | * 16 | * This program is free software; you can redistribute it and/or modify it 17 | * under the terms of the GNU General Public License as published by the 18 | * Free Software Foundation; either version 3 of the License, or (at your 19 | * option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, but 22 | * WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 24 | * Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License along 27 | * with this program; if not, see . 28 | * 29 | * Additional permission under GNU GPL version 3 section 7 30 | * 31 | * If you modify this Program, or any covered work, by linking or 32 | * combining it with the OpenSSL project's OpenSSL library (or a modified 33 | * version of that library), containing parts covered by the terms of the 34 | * OpenSSL or SSLeay licenses, the licensors of this Program grant you 35 | * additional permission to convey the resulting work. Corresponding 36 | * Source for a non-source form of such a combination shall include the 37 | * source code for the parts of OpenSSL used as well as that of the 38 | * covered work. 39 | */ 40 | 41 | #ifndef CALLBACK_H__ 42 | #define CALLBACK_H__ 43 | 44 | #define CALLBACK_H_VERSION 3 45 | 46 | template 47 | struct callback; 48 | 49 | EOF 50 | 51 | for my $a (0..10) { 52 | my $CLASS = join "", map ", class A$_", 1..$a; 53 | my $TYPE = join ", ", map "A$_", 1..$a; 54 | my $ARG = join ", ", map "a$_", 1..$a; 55 | my $TYPEARG = join ", ", map "A$_ a$_", 1..$a; 56 | my $TYPEDEFS = join " ", map "typedef A$_ arg$_\_type;", 1..$a; 57 | my $TYPEvoid = $TYPE ? $TYPE : "void"; 58 | my $_ARG = $ARG ? ", $ARG" : ""; 59 | my $_TYPE = $TYPE ? ", $TYPE" : ""; 60 | my $_TYPEARG = $TYPEARG ? ", $TYPEARG" : ""; 61 | my $_TTYPE = $a ? join "", map ", typename T::arg$_\_type", 1..$a : ""; 62 | 63 | print < 65 | struct callback 66 | { 67 | typedef R (*ptr_type)(void *self$_TYPE); 68 | 69 | template 70 | void set (K *object) 71 | { 72 | self = object; 73 | func = thunk; 74 | } 75 | 76 | R call ($TYPEARG) const 77 | { 78 | return func (self$_ARG); 79 | } 80 | 81 | R operator ()($TYPEARG) const 82 | { 83 | return call ($ARG); 84 | } 85 | 86 | private: 87 | 88 | void *self; 89 | ptr_type func; 90 | 91 | template 92 | static R thunk (void *self$_TYPEARG) 93 | { 94 | klass *obj = static_cast(self); 95 | return (obj->*method) ($ARG); 96 | } 97 | }; 98 | 99 | EOF 100 | } 101 | 102 | print < 4 | 5 | This file is part of GVPE. 6 | 7 | GVPE is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, see . 19 | 20 | Additional permission under GNU GPL version 3 section 7 21 | 22 | If you modify this Program, or any covered work, by linking or 23 | combining it with the OpenSSL project's OpenSSL library (or a modified 24 | version of that library), containing parts covered by the terms of the 25 | OpenSSL or SSLeay licenses, the licensors of this Program grant you 26 | additional permission to convey the resulting work. Corresponding 27 | Source for a non-source form of such a combination shall include the 28 | source code for the parts of OpenSSL used as well as that of the 29 | covered work. 30 | */ 31 | 32 | // uses the kernel driver at: 33 | // http://www-user.rhrk.uni-kl.de/~nissler/tuntap/ 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #include "conf.h" 47 | 48 | // following headers used by cygwin (maybe others) 49 | #include "netcompat.h" 50 | #include 51 | 52 | #define DEFAULT_DEVICE "/dev/tap0" 53 | 54 | const char * 55 | tap_device::info () 56 | { 57 | return _("darwin tap driver"); 58 | } 59 | 60 | const char * 61 | tap_device::if_up () 62 | { 63 | return "/sbin/ifconfig $IFNAME ether $MAC mtu $MTU"; 64 | } 65 | 66 | tap_device::tap_device () 67 | { 68 | const char *device = conf.ifname ? conf.ifname : DEFAULT_DEVICE; 69 | 70 | if ((fd = open (device, O_RDWR | O_NONBLOCK)) < 0) 71 | { 72 | slog (L_ERR, _("could not open device %s: %s"), device, strerror (errno)); 73 | exit (EXIT_FAILURE); 74 | } 75 | 76 | slog (L_DEBUG, _("interface %s on %s initialized"), info (), device); 77 | 78 | strcpy (ifrname, rindex(device, '/') ? rindex(device, '/') + 1 : device); 79 | } 80 | 81 | tap_device::~tap_device () 82 | { 83 | close (fd); 84 | } 85 | 86 | tap_packet * 87 | tap_device::recv () 88 | { 89 | tap_packet *pkt = new tap_packet; 90 | 91 | pkt->len = read (fd, &((*pkt)[0]), MAX_MTU); 92 | 93 | if (pkt->len <= 0) 94 | { 95 | delete pkt; 96 | slog (L_ERR, _("error while reading from %s %s: %s"), 97 | info (), DEFAULT_DEVICE, strerror (errno)); 98 | return 0; 99 | } 100 | 101 | return pkt; 102 | } 103 | 104 | void 105 | tap_device::send (tap_packet *pkt) 106 | { 107 | if (write (fd, &((*pkt)[0]), pkt->len) < 0) 108 | slog (L_ERR, _("can't write to %s %s: %s"), info (), DEFAULT_DEVICE, 109 | strerror (errno)); 110 | } 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /src/device-linux.C: -------------------------------------------------------------------------------- 1 | /* 2 | device-linux.C -- Interaction with Linux tun/tap device 3 | Copyright (C) 2003-2008 Marc Lehmann 4 | 5 | This file is part of GVPE. 6 | 7 | GVPE is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, see . 19 | 20 | Additional permission under GNU GPL version 3 section 7 21 | 22 | If you modify this Program, or any covered work, by linking or 23 | combining it with the OpenSSL project's OpenSSL library (or a modified 24 | version of that library), containing parts covered by the terms of the 25 | OpenSSL or SSLeay licenses, the licensors of this Program grant you 26 | additional permission to convey the resulting work. Corresponding 27 | Source for a non-source form of such a combination shall include the 28 | source code for the parts of OpenSSL used as well as that of the 29 | covered work. 30 | */ 31 | 32 | #include "config.h" 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #include 47 | 48 | #ifdef LINUX_IF_TUN_H 49 | # include LINUX_IF_TUN_H 50 | #else 51 | #include 52 | #endif 53 | #define DEFAULT_DEVICE "/dev/net/tun" 54 | 55 | #include "gettext.h" 56 | 57 | #include "conf.h" 58 | 59 | #if TEST_ETHEREMU 60 | # define IF_istun 61 | # include "ether_emu.C" 62 | #endif 63 | 64 | const char * 65 | tap_device::info () 66 | { 67 | return _("Linux tun/tap device"); 68 | } 69 | 70 | const char * 71 | tap_device::if_up () 72 | { 73 | return "/sbin/ifconfig $IFNAME hw ether $MAC mtu $MTU"; 74 | } 75 | 76 | tap_device::tap_device () 77 | { 78 | struct ifreq ifr; 79 | 80 | device = (char *)DEFAULT_DEVICE; 81 | 82 | fd = open (device, O_RDWR); 83 | 84 | if (fd < 0) 85 | { 86 | slog (L_ERR, _("could not open device %s: %s"), device, strerror (errno)); 87 | exit (EXIT_FAILURE); 88 | } 89 | 90 | memset (&ifr, 0, sizeof (ifr)); 91 | #if TEST_ETHEREMU 92 | ifr.ifr_flags = IFF_TUN | IFF_NO_PI; 93 | #else 94 | ifr.ifr_flags = IFF_TAP | IFF_NO_PI; 95 | #endif 96 | 97 | if (conf.ifname) 98 | strncpy (ifr.ifr_name, conf.ifname, IFNAMSIZ); 99 | else 100 | ifr.ifr_name[0] = 0; 101 | 102 | if (!ioctl (fd, TUNSETIFF, &ifr)) 103 | { 104 | strncpy (ifrname, ifr.ifr_name, IFNAMSIZ); 105 | ifrname [IFNAMSIZ] = 0; 106 | } 107 | else 108 | { 109 | slog (L_CRIT, _("unable to configure tun/tap interface, exiting: %s"), strerror (errno)); 110 | exit (EXIT_FAILURE); 111 | } 112 | 113 | #if 0 114 | does not work 115 | id2mac (THISNODE->id, &ifr.ifr_hwaddr.sa_data); 116 | if (ioctl (fd, SIOCSIFHWADDR, &ifr)) 117 | { 118 | slog (L_ERR, _("cannot set MAC address for device %s, exiting: %s"), ifrname, strerror (errno)); 119 | exit (EXIT_FAILURE); 120 | } 121 | #endif 122 | 123 | if (ioctl (fd, TUNSETPERSIST, conf.ifpersist ? 1 : 0)) 124 | slog (L_WARN, _("cannot set persistency mode for device %s: %s"), ifrname, strerror (errno)); 125 | 126 | slog (L_DEBUG, _("%s is a %s"), device, info ()); 127 | } 128 | 129 | tap_device::~tap_device () 130 | { 131 | close (fd); 132 | } 133 | 134 | tap_packet * 135 | tap_device::recv () 136 | { 137 | tap_packet *pkt = new tap_packet; 138 | 139 | #if TEST_ETHEREMU 140 | pkt->len = read (fd, &((*pkt)[14]), MAX_MTU - 14); 141 | #else 142 | pkt->len = read (fd, &((*pkt)[0]), MAX_MTU); 143 | #endif 144 | 145 | if (pkt->len <= 0) 146 | { 147 | delete pkt; 148 | slog (L_ERR, _("error while reading from %s %s: %s"), 149 | info (), DEFAULT_DEVICE, strerror (errno)); 150 | return 0; 151 | } 152 | 153 | #if TEST_ETHEREMU 154 | pkt->len += 14; 155 | 156 | // assume ipv4 157 | (*pkt)[12] = 0x08; 158 | (*pkt)[13] = 0x00; 159 | 160 | if (!ether_emu.tun_to_tap (pkt)) 161 | { 162 | delete pkt; 163 | return 0; 164 | } 165 | #endif 166 | 167 | return pkt; 168 | } 169 | 170 | void 171 | tap_device::send (tap_packet *pkt) 172 | { 173 | #if TEST_ETHEREMU 174 | if (ether_emu.tap_to_tun (pkt) && 175 | write (fd, &((*pkt)[14]), pkt->len - 14) < 0) 176 | #else 177 | if (write (fd, &((*pkt)[0]), pkt->len) < 0) 178 | #endif 179 | slog (L_ERR, _("can't write to %s %s: %s"), info (), DEFAULT_DEVICE, 180 | strerror (errno)); 181 | } 182 | 183 | -------------------------------------------------------------------------------- /src/device.C: -------------------------------------------------------------------------------- 1 | /* 2 | device.C -- include the correct low-level implementation. 3 | Copyright (C) 2003-2008 Marc Lehmann 4 | 5 | This file is part of GVPE. 6 | 7 | GVPE is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, see . 19 | 20 | Additional permission under GNU GPL version 3 section 7 21 | 22 | If you modify this Program, or any covered work, by linking or 23 | combining it with the OpenSSL project's OpenSSL library (or a modified 24 | version of that library), containing parts covered by the terms of the 25 | OpenSSL or SSLeay licenses, the licensors of this Program grant you 26 | additional permission to convey the resulting work. Corresponding 27 | Source for a non-source form of such a combination shall include the 28 | source code for the parts of OpenSSL used as well as that of the 29 | covered work. 30 | */ 31 | 32 | #include "config.h" 33 | 34 | #include 35 | #include 36 | 37 | #include "slog.h" 38 | #include "device.h" 39 | 40 | static void *pkt_cachep[PKTCACHESIZE]; 41 | static int pkt_cachen = 0; 42 | 43 | void * 44 | net_packet::operator new(size_t s) 45 | { 46 | if (s > sizeof (data_packet)) 47 | { 48 | slog (L_ERR, _("FATAL: allocation for network packet larger than max supported packet size (%d > %d)."), 49 | s, sizeof (data_packet)); 50 | abort (); 51 | } 52 | 53 | if (pkt_cachen) 54 | return pkt_cachep[--pkt_cachen]; 55 | else 56 | { 57 | void *p = malloc (sizeof (data_packet)); 58 | memset (p, 0, sizeof (data_packet)); 59 | return p; 60 | } 61 | } 62 | 63 | void 64 | net_packet::operator delete(void *p) 65 | { 66 | if (p) 67 | { 68 | if (pkt_cachen < PKTCACHESIZE) 69 | { 70 | memset (p, 0, sizeof (data_packet)); 71 | pkt_cachep[pkt_cachen++] = p; 72 | } 73 | else 74 | free (p); 75 | } 76 | } 77 | 78 | #if IFTYPE_tincd 79 | # include "device-tincd.C" 80 | #elif IFTYPE_native && IF_linux 81 | # include "device-linux.C" 82 | #elif IFTYPE_native && IF_cygwin 83 | # include "device-cygwin.C" 84 | #elif IFTYPE_native && IF_darwin 85 | # include "device-darwin.C" 86 | #else 87 | # error No interface implementation for your IFTYPE/IFSUBTYPE combination. 88 | #endif 89 | 90 | 91 | -------------------------------------------------------------------------------- /src/device.h: -------------------------------------------------------------------------------- 1 | /* 2 | device.h -- generic header for device.c 3 | Copyright (C) 2003-2008 Marc Lehmann 4 | 5 | This file is part of GVPE. 6 | 7 | GVPE is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, see . 19 | 20 | Additional permission under GNU GPL version 3 section 7 21 | 22 | If you modify this Program, or any covered work, by linking or 23 | combining it with the OpenSSL project's OpenSSL library (or a modified 24 | version of that library), containing parts covered by the terms of the 25 | OpenSSL or SSLeay licenses, the licensors of this Program grant you 26 | additional permission to convey the resulting work. Corresponding 27 | Source for a non-source form of such a combination shall include the 28 | source code for the parts of OpenSSL used as well as that of the 29 | covered work. 30 | */ 31 | 32 | #ifndef GVPE_DEVICE_H__ 33 | #define GVPE_DEVICE_H__ 34 | 35 | #include "config.h" 36 | 37 | #define IFNAMESIZE 256 // be conservative 38 | 39 | #include "global.h" 40 | #include "util.h" 41 | 42 | struct net_packet 43 | { 44 | u32 len; // actually u16, but padding... 45 | 46 | u8 &operator[] (u16 offset) const; 47 | u8 *at (u16 offset) const; 48 | 49 | void unshift_hdr (u16 hdrsize) 50 | { 51 | memmove ((void *)&(*this)[hdrsize], (void *)&(*this)[0], len); 52 | len += hdrsize; 53 | } 54 | 55 | void skip_hdr (u16 hdrsize) 56 | { 57 | len -= hdrsize; 58 | memmove ((void *)&(*this)[0], (void *)&(*this)[hdrsize], len); 59 | } 60 | 61 | void set (const net_packet &pkt) 62 | { 63 | len = pkt.len; 64 | memcpy (&((*this)[0]), &(pkt[0]), len); 65 | } 66 | 67 | bool is_ipv4 () const 68 | { 69 | return (*this)[12] == 0x08 && (*this)[13] == 0x00 // IP 70 | && ((*this)[14] & 0xf0) == 0x40; // IPv4 71 | } 72 | 73 | u32 &ipv4_src () const 74 | { 75 | return *(u32 *)&(*this)[26]; 76 | } 77 | 78 | u32 &ipv4_dst () const 79 | { 80 | return *(u32 *)&(*this)[30]; 81 | } 82 | 83 | bool is_arp () const 84 | { 85 | return (*this)[12] == 0x08 && (*this)[13] == 0x06 // 0806 protocol 86 | && (*this)[14] == 0x00 && (*this)[15] == 0x01 // 0001 hw_format 87 | && (*this)[16] == 0x08 && (*this)[17] == 0x00 // 0800 prot_format 88 | && (*this)[18] == 0x06 && (*this)[19] == 0x04; // 06 hw_len 04 prot_len 89 | } 90 | 91 | void *operator new (size_t s); 92 | void operator delete (void *p); 93 | }; 94 | 95 | struct data_packet : net_packet 96 | { 97 | u8 data_[MAXSIZE]; 98 | }; 99 | 100 | inline 101 | u8 &net_packet::operator[] (u16 offset) const 102 | { 103 | return ((data_packet *)this)->data_[offset]; 104 | } 105 | 106 | inline 107 | u8 *net_packet::at (u16 offset) const 108 | { 109 | return &((*this)[offset]); 110 | } 111 | 112 | struct tap_packet : net_packet 113 | { 114 | mac dst; 115 | mac src; 116 | u8 data[MAXSIZE - 12]; 117 | }; 118 | 119 | struct tap_device 120 | { 121 | int fd; 122 | 123 | // network interface name or identifier 124 | char ifrname[IFNAMESIZE + 1]; 125 | 126 | char *device; 127 | 128 | tap_device (); 129 | ~tap_device (); 130 | 131 | //bool open (); 132 | //void close (); 133 | 134 | const char *interface () { return ifrname; } 135 | const char *info (); 136 | const char *if_up (); 137 | 138 | tap_packet *recv (); 139 | void send (tap_packet *pkt); 140 | }; 141 | 142 | //extern tap_device *tap_device (); 143 | 144 | #endif 145 | 146 | -------------------------------------------------------------------------------- /src/ether_emu.C: -------------------------------------------------------------------------------- 1 | /* 2 | ether_emu.C -- ethernet "emulator" library 3 | Copyright (C) 2003-2008 Marc Lehmann 4 | 5 | This file is part of GVPE. 6 | 7 | GVPE is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, see . 19 | 20 | Additional permission under GNU GPL version 3 section 7 21 | 22 | If you modify this Program, or any covered work, by linking or 23 | combining it with the OpenSSL project's OpenSSL library (or a modified 24 | version of that library), containing parts covered by the terms of the 25 | OpenSSL or SSLeay licenses, the licensors of this Program grant you 26 | additional permission to convey the resulting work. Corresponding 27 | Source for a non-source form of such a combination shall include the 28 | source code for the parts of OpenSSL used as well as that of the 29 | covered work. 30 | */ 31 | 32 | #include "config.h" 33 | 34 | #include 35 | 36 | #include "vpn.h" 37 | 38 | extern struct vpn network; 39 | 40 | struct ether_emu : map 41 | { 42 | typedef map ipv4map; 43 | ipv4map ipv4; 44 | 45 | bool tun_to_tap (tap_packet *pkt); 46 | bool tap_to_tun (tap_packet *pkt); 47 | 48 | void set_ipv4 (u32 ip, int dst) 49 | { 50 | (ipv4.insert (pair(ip, dst)).first)->second = dst; 51 | } 52 | }; 53 | 54 | static struct ether_emu ether_emu; 55 | 56 | bool 57 | ether_emu::tun_to_tap (tap_packet *pkt) 58 | { 59 | int dst; 60 | 61 | if (pkt->is_ipv4 ()) 62 | { 63 | // update arp cache for _local_ hosts 64 | set_ipv4 (pkt->ipv4_src (), THISNODE->id); 65 | 66 | ipv4map::iterator i = ipv4.find (pkt->ipv4_dst ()); 67 | 68 | if (i == ipv4.end ()) 69 | { 70 | u32 ip_src = pkt->ipv4_src (); 71 | u32 ip_dst = pkt->ipv4_dst (); 72 | 73 | // throw away current packet and make it an arp request 74 | (*pkt)[12] = 0x08; (*pkt)[13] = 0x06; 75 | (*pkt)[14] = 0x00; (*pkt)[15] = 0x01; // hw 76 | (*pkt)[16] = 0x08; (*pkt)[17] = 0x00; // prot 77 | (*pkt)[18] = 0x06; // hw_len 78 | (*pkt)[19] = 0x04; // prot_len 79 | (*pkt)[20] = 0x00; (*pkt)[21] = 0x01; // op 80 | 81 | id2mac (THISNODE->id, &(*pkt)[22]); 82 | *(u32 *)&(*pkt)[28] = ip_src; 83 | id2mac (0, &(*pkt)[32]); 84 | *(u32 *)&(*pkt)[38] = ip_dst; 85 | 86 | pkt->len = 42; 87 | 88 | dst = 0; 89 | } 90 | else 91 | dst = i->second; 92 | } 93 | else 94 | dst = 0; // broadcast non-ip 95 | 96 | id2mac (THISNODE->id, pkt->src); 97 | id2mac (dst, pkt->dst); 98 | 99 | return true; 100 | } 101 | 102 | bool 103 | ether_emu::tap_to_tun (tap_packet *pkt) 104 | { 105 | if (pkt->is_arp ()) 106 | { 107 | u32 ip_src = *(u32 *)&(*pkt)[28]; 108 | 109 | // always update with all info we can get. in this case, the arp sender. 110 | set_ipv4 (ip_src, mac2id (&(*pkt)[22])); 111 | 112 | //TODO: remove cache dumper 113 | //for (ipv4map::iterator i = ipv4.begin (); i != ipv4.end (); ++i) printf ("%08lx => %d\n", i->first, i->second); 114 | 115 | if ((*pkt)[20] == 0x00 && (*pkt)[21] == 0x01) // arp request 116 | { 117 | // send a reply, if applicable 118 | u32 ip_dst = *(u32 *)&(*pkt)[38]; 119 | ipv4map::iterator i = ipv4.find (ip_dst); 120 | 121 | // TODO: look up list of local networks and answer for them 122 | if (i != ipv4.end () && i->second == THISNODE->id) 123 | { 124 | // create an arp reply 125 | tap_packet *rep = new tap_packet; 126 | 127 | id2mac (THISNODE->id, rep->src); 128 | memcpy (rep->dst, pkt->src, sizeof (mac)); 129 | 130 | (*rep)[12] = 0x08; (*rep)[13] = 0x06; 131 | (*rep)[14] = 0x00; (*rep)[15] = 0x01; // hw 132 | (*rep)[16] = 0x08; (*rep)[17] = 0x00; // prot 133 | (*rep)[18] = 0x06; // hw_len 134 | (*rep)[19] = 0x04; // prot_len 135 | (*rep)[20] = 0x00; (*rep)[21] = 0x02; // op 136 | 137 | id2mac (THISNODE->id, &(*rep)[22]); 138 | *(u32 *)&(*rep)[28] = ip_dst; 139 | memcpy (&(*rep)[32], &(*pkt)[22], sizeof (mac)); 140 | *(u32 *)&(*rep)[38] = ip_src; 141 | 142 | rep->len = 42; 143 | 144 | network.inject_data_packet (rep, mac2id (rep->dst)); 145 | 146 | delete rep; 147 | } 148 | } 149 | else if ((*pkt)[20] == 0x00 && (*pkt)[21] == 0x02) // arp reply 150 | set_ipv4 (*(u32 *)&(*pkt)[28], mac2id (&(*pkt)[22])); 151 | 152 | return false; 153 | } 154 | else if (pkt->is_ipv4 ()) 155 | { 156 | // update arp cache 157 | set_ipv4 (pkt->ipv4_src (), mac2id (pkt->src)); 158 | set_ipv4 (pkt->ipv4_dst (), mac2id (pkt->dst)); 159 | } 160 | 161 | return true; 162 | } 163 | 164 | -------------------------------------------------------------------------------- /src/ev_cpp.C: -------------------------------------------------------------------------------- 1 | #include "ev_cpp.h" 2 | #include "ev.c" 3 | 4 | -------------------------------------------------------------------------------- /src/ev_cpp.h: -------------------------------------------------------------------------------- 1 | #define EV_COMPAT3 0 2 | #define EV_CHILD_ENABLE 1 3 | #define EV_USE_STDEXCEPT 0 4 | #define EV_CONFIG_H 5 | 6 | #define EV_FEATURES 1+2+32+64 7 | 8 | #define EV_IO_ENABLE 1 9 | #define EV_TIMER_ENABLE 1 10 | #define EV_ASYNC_ENABLE 1 11 | 12 | #include "ev++.h" 13 | -------------------------------------------------------------------------------- /src/global.h: -------------------------------------------------------------------------------- 1 | /* 2 | global.h -- global variables and constants 3 | Copyright (C) 2003-2008 Marc Lehmann 4 | 5 | This file is part of GVPE. 6 | 7 | GVPE is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, see . 19 | 20 | Additional permission under GNU GPL version 3 section 7 21 | 22 | If you modify this Program, or any covered work, by linking or 23 | combining it with the OpenSSL project's OpenSSL library (or a modified 24 | version of that library), containing parts covered by the terms of the 25 | OpenSSL or SSLeay licenses, the licensors of this Program grant you 26 | additional permission to convey the resulting work. Corresponding 27 | Source for a non-source form of such a combination shall include the 28 | source code for the parts of OpenSSL used as well as that of the 29 | covered work. 30 | */ 31 | 32 | #ifndef GLOBAL_H__ 33 | #define GLOBAL_H__ 34 | 35 | #include "config.h" 36 | 37 | #include 38 | 39 | /* Protocol version. Different major versions are incompatible, 40 | * different minor versions probably are compatible ;) 41 | */ 42 | 43 | #define PROTOCOL_MAJOR 0 44 | #define PROTOCOL_MINOR 1 45 | 46 | #define RSA_KEYBITS 1280 // must be >= 1280 and divisible by 8 47 | #define RSA_KEYLEN ((RSA_KEYBITS) >> 3) 48 | #define RSA_OVERHEAD (41 + 1) // well, no define for OAEP in openssl 49 | 50 | #define RSA_HASH EVP_ripemd160 ()// speed don't matter, boy, safety does.. I need sha256 :( 51 | #define RSA_HASHLEN (160 >> 3) 52 | #define RSA_RESLEN RSA_HASHLEN 53 | 54 | #define RSA_IDLEN 16 // how many bytes are used to identify the challenge 55 | #define RSA_TTL 120 // challenge bytes timeout after n seconds 56 | 57 | #define CIPHER ENABLE_CIPHER () 58 | #define CIPHER_KEYLEN (EVP_CIPHER_key_length (CIPHER)) 59 | #define DIGEST ENABLE_DIGEST () 60 | #define HMAC_KEYLEN (256 >> 3) // number of bits used for the HMAC key (also change CHG_HMAC_KEY) 61 | 62 | #define WINDOWSIZE 512 // sliding window size 63 | #define MAX_SEQNO (0xfffffff0U - WINDOWSIZE * 8) 64 | 65 | #define CHG_SEQNO 0 // where the seqno starts within the rsa challenge 66 | #define CHG_CIPHER_KEY 4 // where the key starts within the rsa challenge 67 | #define CHG_HMAC_KEY 86 // where the key starts within the rsa challenge (256 bits at the end!) 68 | 69 | // hdr seq len hmac MAC MAC 70 | #define VPE_OVERHEAD (4 + 4 + 4 + RAND_SIZE + HMACLENGTH - 6 - 6) 71 | #define IP_OVERHEAD 20 // size of a (normal) ip header 72 | #define GRE_OVERHEAD (IP_OVERHEAD + 4) 73 | #define ICMP_OVERHEAD (IP_OVERHEAD + 4) 74 | #define UDP_OVERHEAD (IP_OVERHEAD + 20) // size of a (normal) ip + udp header (wrong, but don't care) 75 | #define TCP_OVERHEAD (IP_OVERHEAD + 22) // size of a (normal) ip + tcp header + packetlength 76 | #define MAX_OVERHEAD UDP_OVERHEAD // the max. overhead of any protocol (ok, tcp doesn't count) 77 | #define ETH_OVERHEAD 14 // the size of an ethernet header 78 | #define MAXSIZE (MAX_MTU + VPE_OVERHEAD) // slightly too large, but who cares 79 | 80 | #define PKTCACHESIZE 16 // the size of the memory pool for packets 81 | 82 | extern char *confbase; // directory in which all config files are 83 | extern char *thisnode; // config for current node (TODO: remove) 84 | 85 | template static inline T min (T a, U b) { return a < (T)b ? a : (T)b; } 86 | template static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } 87 | template static inline T max (T a, U b) { return a > (T)b ? a : (T)b; } 88 | template static inline void max_it (T &a, U b) { a = a > (T)b ? a : (T)b; } 89 | 90 | template static inline T clamp (T v, U a, V b) { return v < (T)a ? a : v >(T)b ? b : v; } 91 | 92 | template static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; } 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /src/lzf/lzf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Marc Alexander Lehmann 3 | * 4 | * Redistribution and use in source and binary forms, with or without modifica- 5 | * tion, are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 15 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- 16 | * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- 18 | * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- 22 | * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 23 | * OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | * Alternatively, the contents of this file may be used under the terms of 26 | * the GNU General Public License ("GPL") version 2 or any later version, 27 | * in which case the provisions of the GPL are applicable instead of 28 | * the above. If you wish to allow the use of your version of this file 29 | * only under the terms of the GPL and not to allow others to use your 30 | * version of this file under the BSD license, indicate your decision 31 | * by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL. If you do not delete the 33 | * provisions above, a recipient may use your version of this file under 34 | * either the BSD or the GPL. 35 | */ 36 | 37 | #ifndef LZF_H 38 | #define LZF_H 39 | 40 | /*********************************************************************** 41 | ** 42 | ** lzf -- an extremely fast/free compression/decompression-method 43 | ** http://liblzf.plan9.de/ 44 | ** 45 | ** This algorithm is believed to be patent-free. 46 | ** 47 | ***********************************************************************/ 48 | 49 | #define LZF_VERSION 0x0105 /* 1.5 */ 50 | 51 | /* 52 | * Compress in_len bytes stored at the memory block starting at 53 | * in_data and write the result to out_data, up to a maximum length 54 | * of out_len bytes. 55 | * 56 | * If the output buffer is not large enough or any error occurs 57 | * return 0, otherwise return the number of bytes used (which might 58 | * be considerably larger than in_len, so it makes sense to always 59 | * use out_len == in_len - 1), to ensure _some_ compression, and store 60 | * the data uncompressed otherwise. 61 | * 62 | * lzf_compress might use different algorithms on different systems and 63 | * even different runs, thus might result in different compressed strings 64 | * depending on the phase of the moon or similar factors. However, all 65 | * these strings are architecture-independent and will result in the 66 | * original data when decompressed using lzf_decompress. 67 | * 68 | * The buffers must not be overlapping. 69 | * 70 | * If the option LZF_STATE_ARG is enabled, an extra argument must be 71 | * supplied which is not reflected in this header file. Refer to lzfP.h 72 | * and lzf_c.c. 73 | * 74 | */ 75 | unsigned int 76 | lzf_compress (const void *const in_data, unsigned int in_len, 77 | void *out_data, unsigned int out_len); 78 | 79 | /* 80 | * Decompress data compressed with some version of the lzf_compress 81 | * function and stored at location in_data and length in_len. The result 82 | * will be stored at out_data up to a maximum of out_len characters. 83 | * 84 | * If the output buffer is not large enough to hold the decompressed 85 | * data, a 0 is returned and errno is set to E2BIG. Otherwise the number 86 | * of decompressed bytes (i.e. the original length of the data) is 87 | * returned. 88 | * 89 | * If an error in the compressed data is detected, a zero is returned and 90 | * errno is set to EINVAL. 91 | * 92 | * This function is very fast, about as fast as a copying loop. 93 | */ 94 | unsigned int 95 | lzf_decompress (const void *const in_data, unsigned int in_len, 96 | void *out_data, unsigned int out_len); 97 | 98 | #endif 99 | 100 | -------------------------------------------------------------------------------- /src/lzf/lzf_d.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Marc Alexander Lehmann 3 | * 4 | * Redistribution and use in source and binary forms, with or without modifica- 5 | * tion, are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 15 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- 16 | * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- 18 | * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- 22 | * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 23 | * OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | * Alternatively, the contents of this file may be used under the terms of 26 | * the GNU General Public License ("GPL") version 2 or any later version, 27 | * in which case the provisions of the GPL are applicable instead of 28 | * the above. If you wish to allow the use of your version of this file 29 | * only under the terms of the GPL and not to allow others to use your 30 | * version of this file under the BSD license, indicate your decision 31 | * by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL. If you do not delete the 33 | * provisions above, a recipient may use your version of this file under 34 | * either the BSD or the GPL. 35 | */ 36 | 37 | #include "lzfP.h" 38 | 39 | #if AVOID_ERRNO 40 | # define SET_ERRNO(n) 41 | #else 42 | # include 43 | # define SET_ERRNO(n) errno = (n) 44 | #endif 45 | 46 | #if (__i386 || __amd64) && __GNUC__ >= 3 47 | # define lzf_movsb(dst, src, len) \ 48 | asm ("rep movsb" \ 49 | : "=D" (dst), "=S" (src), "=c" (len) \ 50 | : "0" (dst), "1" (src), "2" (len)); 51 | #endif 52 | 53 | unsigned int 54 | lzf_decompress (const void *const in_data, unsigned int in_len, 55 | void *out_data, unsigned int out_len) 56 | { 57 | u8 const *ip = (const u8 *)in_data; 58 | u8 *op = (u8 *)out_data; 59 | u8 const *const in_end = ip + in_len; 60 | u8 *const out_end = op + out_len; 61 | 62 | do 63 | { 64 | unsigned int ctrl = *ip++; 65 | 66 | if (ctrl < (1 << 5)) /* literal run */ 67 | { 68 | ctrl++; 69 | 70 | if (op + ctrl > out_end) 71 | { 72 | SET_ERRNO (E2BIG); 73 | return 0; 74 | } 75 | 76 | #if CHECK_INPUT 77 | if (ip + ctrl > in_end) 78 | { 79 | SET_ERRNO (EINVAL); 80 | return 0; 81 | } 82 | #endif 83 | 84 | #ifdef lzf_movsb 85 | lzf_movsb (op, ip, ctrl); 86 | #else 87 | do 88 | *op++ = *ip++; 89 | while (--ctrl); 90 | #endif 91 | } 92 | else /* back reference */ 93 | { 94 | unsigned int len = ctrl >> 5; 95 | 96 | u8 *ref = op - ((ctrl & 0x1f) << 8) - 1; 97 | 98 | #if CHECK_INPUT 99 | if (ip >= in_end) 100 | { 101 | SET_ERRNO (EINVAL); 102 | return 0; 103 | } 104 | #endif 105 | if (len == 7) 106 | { 107 | len += *ip++; 108 | #if CHECK_INPUT 109 | if (ip >= in_end) 110 | { 111 | SET_ERRNO (EINVAL); 112 | return 0; 113 | } 114 | #endif 115 | } 116 | 117 | ref -= *ip++; 118 | 119 | if (op + len + 2 > out_end) 120 | { 121 | SET_ERRNO (E2BIG); 122 | return 0; 123 | } 124 | 125 | if (ref < (u8 *)out_data) 126 | { 127 | SET_ERRNO (EINVAL); 128 | return 0; 129 | } 130 | 131 | #ifdef lzf_movsb 132 | len += 2; 133 | lzf_movsb (op, ref, len); 134 | #else 135 | *op++ = *ref++; 136 | *op++ = *ref++; 137 | 138 | do 139 | *op++ = *ref++; 140 | while (--len); 141 | #endif 142 | } 143 | } 144 | while (ip < in_end); 145 | 146 | return op - (u8 *)out_data; 147 | } 148 | 149 | -------------------------------------------------------------------------------- /src/netcompat.h: -------------------------------------------------------------------------------- 1 | /* 2 | netcompat.h -- network compatibility header 3 | Copyright (C) 2003-2008 Marc Lehmann 4 | 5 | This file is part of GVPE. 6 | 7 | GVPE is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, see . 19 | 20 | Additional permission under GNU GPL version 3 section 7 21 | 22 | If you modify this Program, or any covered work, by linking or 23 | combining it with the OpenSSL project's OpenSSL library (or a modified 24 | version of that library), containing parts covered by the terms of the 25 | OpenSSL or SSLeay licenses, the licensors of this Program grant you 26 | additional permission to convey the resulting work. Corresponding 27 | Source for a non-source form of such a combination shall include the 28 | source code for the parts of OpenSSL used as well as that of the 29 | covered work. 30 | */ 31 | 32 | #ifndef GVPE_NETCOMPAT_H 33 | #define GVPE_NETCOMPAT_H 34 | 35 | #include 36 | #include 37 | #ifdef HAVE_NETINET_IN_H 38 | # include 39 | #endif 40 | #ifdef HAVE_ARPA_INET_H 41 | # include 42 | #endif 43 | #include 44 | #ifdef HAVE_NETINET_IN_SYSTM_H 45 | # include 46 | #endif 47 | #ifdef HAVE_NETINET_IP_H 48 | # include 49 | #endif 50 | 51 | #ifndef IPTOS_MINCOST 52 | # define IPTOS_MINCOST 0x02 53 | #endif 54 | #ifndef IPTOS_RELIABILITY 55 | # define IPTOS_RELIABILITY 0x04 56 | #endif 57 | #ifndef IPTOS_THROUGHPUT 58 | # define IPTOS_THROUGHPUT 0x08 59 | #endif 60 | #ifndef IPTOS_LOWDELAY 61 | # define IPTOS_LOWDELAY 0x10 62 | #endif 63 | 64 | #ifndef IPTOS_TOS_MASK 65 | # define IPTOS_TOS_MASK (IPTOS_LOWDELAY | IPTOS_THROUGHPUT | IPTOS_RELIABILITY | IPTOS_MINCOST) 66 | #endif 67 | 68 | #if !defined(SOL_IP) && defined(IPPROTO_IP) 69 | # define SOL_IP IPPROTO_IP 70 | #endif 71 | 72 | #ifndef IPPROTO_GRE 73 | # define IPPROTO_GRE 47 74 | #endif 75 | 76 | #ifndef ICMP_ECHOREPLY 77 | # define ICMP_ECHOREPLY 0 78 | #endif 79 | 80 | #ifndef HAVE_SOCKLEN_T 81 | typedef int socklen_t; 82 | #endif 83 | 84 | #if ENABLE_ICMP 85 | # include 86 | struct icmp_header { 87 | u8 type; 88 | u8 code; 89 | u16 checksum; 90 | union { 91 | struct { 92 | u16 id; 93 | u16 sequence; 94 | } echo; 95 | u32 gateway; 96 | struct { 97 | u16 unused; 98 | u16 mtu; 99 | } frag; 100 | } un; 101 | }; 102 | #endif 103 | 104 | #endif 105 | 106 | -------------------------------------------------------------------------------- /src/rohc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Produce this file with automake to get Makefile.in 2 | 3 | if ROHC 4 | 5 | noinst_LIBRARIES = librohc.a 6 | 7 | librohc_a_SOURCES = \ 8 | c_util.c comp.c \ 9 | c_ip.c c_udp.c c_udp_lite.c c_uncompressed.c \ 10 | d_util.c decomp.c \ 11 | d_ip.c d_udp.c d_udp_lite.c d_uncompressed.c \ 12 | feedback.c 13 | 14 | noinst_HEADERS = \ 15 | rohc.h \ 16 | c_util.h comp.h \ 17 | d_ip.h d_udp.h d_udp_lite.h d_uncompressed.h \ 18 | d_util.h decomp.h \ 19 | feedback.h 20 | 21 | endif 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/rohc/c_ip.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/c_ip.c -------------------------------------------------------------------------------- /src/rohc/c_udp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/c_udp.c -------------------------------------------------------------------------------- /src/rohc/c_udp_lite.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/c_udp_lite.c -------------------------------------------------------------------------------- /src/rohc/c_uncompressed.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/c_uncompressed.c -------------------------------------------------------------------------------- /src/rohc/c_util.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/c_util.c -------------------------------------------------------------------------------- /src/rohc/c_util.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/c_util.h -------------------------------------------------------------------------------- /src/rohc/comp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/comp.c -------------------------------------------------------------------------------- /src/rohc/comp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/comp.h -------------------------------------------------------------------------------- /src/rohc/d_ip.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/d_ip.c -------------------------------------------------------------------------------- /src/rohc/d_ip.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/d_ip.h -------------------------------------------------------------------------------- /src/rohc/d_udp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/d_udp.c -------------------------------------------------------------------------------- /src/rohc/d_udp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/d_udp.h -------------------------------------------------------------------------------- /src/rohc/d_udp_lite.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/d_udp_lite.c -------------------------------------------------------------------------------- /src/rohc/d_udp_lite.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/d_udp_lite.h -------------------------------------------------------------------------------- /src/rohc/d_uncompressed.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/d_uncompressed.c -------------------------------------------------------------------------------- /src/rohc/d_uncompressed.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/d_uncompressed.h -------------------------------------------------------------------------------- /src/rohc/d_util.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/d_util.c -------------------------------------------------------------------------------- /src/rohc/d_util.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/d_util.h -------------------------------------------------------------------------------- /src/rohc/decomp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/decomp.c -------------------------------------------------------------------------------- /src/rohc/decomp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/decomp.h -------------------------------------------------------------------------------- /src/rohc/feedback.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/feedback.c -------------------------------------------------------------------------------- /src/rohc/feedback.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/feedback.h -------------------------------------------------------------------------------- /src/rohc/rohc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enki/gvpe/5b897498c4ae39a3e5b1824f9fa192e3848022c6/src/rohc/rohc.h -------------------------------------------------------------------------------- /src/slog.C: -------------------------------------------------------------------------------- 1 | /* 2 | slog.C -- logging 3 | Copyright (C) 2003-2008 Marc Lehmann 4 | 5 | This file is part of GVPE. 6 | 7 | GVPE is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, see . 19 | 20 | Additional permission under GNU GPL version 3 section 7 21 | 22 | If you modify this Program, or any covered work, by linking or 23 | combining it with the OpenSSL project's OpenSSL library (or a modified 24 | version of that library), containing parts covered by the terms of the 25 | OpenSSL or SSLeay licenses, the licensors of this Program grant you 26 | additional permission to convey the resulting work. Corresponding 27 | Source for a non-source form of such a combination shall include the 28 | source code for the parts of OpenSSL used as well as that of the 29 | covered work. 30 | */ 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | 40 | #include "slog.h" 41 | 42 | loglevel log_level = L_INFO; 43 | const char *log_identity = ""; 44 | static int logto = LOGTO_STDERR; 45 | 46 | loglevel 47 | string_to_loglevel (const char *s) 48 | { 49 | if (!strcmp (s, "noise")) return L_NOISE; 50 | if (!strcmp (s, "trace")) return L_TRACE; 51 | if (!strcmp (s, "debug")) return L_DEBUG; 52 | if (!strcmp (s, "info")) return L_INFO; 53 | if (!strcmp (s, "notice")) return L_NOTICE; 54 | if (!strcmp (s, "warn")) return L_WARN; 55 | if (!strcmp (s, "error")) return L_ERR; 56 | if (!strcmp (s, "critical")) return L_CRIT; 57 | 58 | return L_NONE; 59 | } 60 | 61 | void 62 | log_to (int mask) 63 | { 64 | if (logto & LOGTO_SYSLOG) 65 | closelog (); 66 | 67 | logto = mask; 68 | 69 | if (logto & LOGTO_SYSLOG) 70 | openlog (log_identity, LOG_CONS | LOG_PID, LOG_DAEMON); 71 | } 72 | 73 | void 74 | slog_ (const loglevel l, const char *m, ...) 75 | { 76 | if (l >= log_level) 77 | { 78 | va_list ap; 79 | va_start (ap, m); 80 | char *msg = new char [2048]; 81 | 82 | vsnprintf (msg, 2048, m, ap); 83 | 84 | if (logto & LOGTO_SYSLOG) 85 | { 86 | int lvl = l == L_TRACE ? LOG_DEBUG 87 | : l == L_DEBUG ? LOG_DEBUG 88 | : l == L_INFO ? LOG_INFO 89 | : l == L_NOTICE ? LOG_NOTICE 90 | : l == L_ERR ? LOG_ERR 91 | : l == L_CRIT ? LOG_CRIT 92 | : LOG_ERR; 93 | 94 | syslog (lvl, "%s", msg); 95 | } 96 | 97 | if (logto & LOGTO_STDERR) 98 | { 99 | write (2, msg, strlen (msg)); 100 | write (2, "\n", 1); 101 | } 102 | 103 | delete msg; 104 | } 105 | } 106 | 107 | void 108 | fatal (const char *m) 109 | { 110 | slog (L_CRIT, m); 111 | exit (EXIT_FAILURE); 112 | } 113 | 114 | void 115 | require_failed (const char *file, int line, const char *info) 116 | { 117 | slog (L_CRIT, "FATAL: This program encountered a SHOULD NOT HAPPEN condition and will exit:"); 118 | slog (L_CRIT, "FATAL+ %s:%d '%s' is false", file, line, info); 119 | slog (L_CRIT, "FATAL+ This might indicates a bug in this program, a bug in your libraries,"); 120 | slog (L_CRIT, "FATAL+ your system setup or operating system. Or it might indicate a very"); 121 | slog (L_CRIT, "FATAL+ unusual, unanticipated operating condition, library version mismatch"); 122 | slog (L_CRIT, "FATAL+ or similar problem. If it's not obvious to you what was causing it,"); 123 | slog (L_CRIT, "FATAL+ then please report this to the program author(s)."); 124 | exit (126); 125 | } 126 | 127 | -------------------------------------------------------------------------------- /src/slog.h: -------------------------------------------------------------------------------- 1 | /* 2 | slog.h -- logging 3 | Copyright (C) 2003-2008 Marc Lehmann 4 | 5 | This file is part of GVPE. 6 | 7 | GVPE is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, see . 19 | 20 | Additional permission under GNU GPL version 3 section 7 21 | 22 | If you modify this Program, or any covered work, by linking or 23 | combining it with the OpenSSL project's OpenSSL library (or a modified 24 | version of that library), containing parts covered by the terms of the 25 | OpenSSL or SSLeay licenses, the licensors of this Program grant you 26 | additional permission to convey the resulting work. Corresponding 27 | Source for a non-source form of such a combination shall include the 28 | source code for the parts of OpenSSL used as well as that of the 29 | covered work. 30 | */ 31 | 32 | #ifndef SLOG_H__ 33 | #define SLOG_H__ 34 | 35 | enum loglevel { 36 | L_NONE, 37 | L_NOISE, 38 | L_TRACE, 39 | L_DEBUG, 40 | L_INFO, 41 | L_NOTICE, 42 | L_WARN, 43 | L_ERR, 44 | L_CRIT 45 | }; 46 | 47 | enum { 48 | LOGTO_SYSLOG = 1, 49 | LOGTO_STDERR = 2 50 | }; 51 | 52 | extern loglevel log_level; 53 | extern const char *log_identity; 54 | 55 | extern loglevel string_to_loglevel (const char *s); 56 | #define UNKNOWN_LOGLEVEL _("unknown loglevel, try 'noise', 'debug', 'info', 'notice', 'warn', 'error' or 'critical'") 57 | 58 | inline void set_loglevel (const loglevel l) 59 | { 60 | log_level = l; 61 | } 62 | 63 | inline loglevel get_loglevel () 64 | { 65 | return log_level; 66 | } 67 | 68 | inline void set_identity (const char *identname) 69 | { 70 | log_identity = identname; 71 | } 72 | 73 | inline const char *get_identity () 74 | { 75 | return log_identity; 76 | } 77 | 78 | extern void log_to (int mask); 79 | 80 | extern void slog_ (const loglevel l, const char *m, ...); 81 | 82 | #if __GNUC__ > 2 83 | # define slog(l, ...) do { if ((l) >= log_level) slog_ (l, __VA_ARGS__); } while (0) 84 | #else 85 | # define slog slog_ 86 | #endif 87 | 88 | extern void fatal (const char *m); 89 | extern void require_failed (const char *file, int line, const char *info); 90 | 91 | #define require(expr) if (!(expr)) require_failed (__FILE__, __LINE__, #expr) 92 | 93 | #endif 94 | 95 | -------------------------------------------------------------------------------- /src/sockinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | sockinfo.h -- socket address management 3 | Copyright (C) 2003-2008 Marc Lehmann 4 | 5 | This file is part of GVPE. 6 | 7 | GVPE is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, see . 19 | 20 | Additional permission under GNU GPL version 3 section 7 21 | 22 | If you modify this Program, or any covered work, by linking or 23 | combining it with the OpenSSL project's OpenSSL library (or a modified 24 | version of that library), containing parts covered by the terms of the 25 | OpenSSL or SSLeay licenses, the licensors of this Program grant you 26 | additional permission to convey the resulting work. Corresponding 27 | Source for a non-source form of such a combination shall include the 28 | source code for the parts of OpenSSL used as well as that of the 29 | covered work. 30 | */ 31 | 32 | #ifndef GVPE_SOCKINFO_H__ 33 | #define GVPE_SOCKINFO_H__ 34 | 35 | #include "netcompat.h" 36 | 37 | #include "conf.h" 38 | 39 | // encapsulate one or more network addresses. this structure 40 | // gets transferred over the wire, so be careful with endianness etc. 41 | struct sockinfo 42 | { 43 | u32 host; 44 | u16 port; 45 | u8 prot; 46 | u8 pad1; 47 | 48 | void set (const sockaddr_in *sa, u8 prot_); 49 | void set (const conf_node *conf, u8 prot_); 50 | void set (const char *hostname, u16 port_, u8 prot_); 51 | 52 | // return the supported protocols 53 | u8 supported_protocols (conf_node *conf = 0); 54 | bool upgrade_protocol (u8 prot_, conf_node *conf = 0); 55 | 56 | operator const char *() const; 57 | 58 | const sockaddr *sav4 () const; 59 | const socklen_t salenv4 () const 60 | { 61 | return sizeof (sockaddr_in); 62 | } 63 | 64 | const char *ntoa () const; 65 | 66 | bool valid () const 67 | { 68 | return prot != 0 && host != 0; 69 | } 70 | 71 | sockinfo() { prot = 0; } 72 | 73 | sockinfo(const char *hostname, u16 port, u8 prot) { set (hostname, port, prot); } 74 | sockinfo(const sockaddr_in &sa, u8 prot) { set (&sa, prot); } 75 | sockinfo(const conf_node *conf, u8 prot) { set (conf, prot); } 76 | }; 77 | 78 | bool operator == (const sockinfo &a, const sockinfo &b); 79 | bool operator < (const sockinfo &a, const sockinfo &b); 80 | 81 | inline bool operator != (const sockinfo &a, const sockinfo &b) 82 | { 83 | return !(a == b); 84 | } 85 | 86 | #endif 87 | 88 | -------------------------------------------------------------------------------- /src/tincd/apply: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | perl -i ./fixit */device.c 4 | -------------------------------------------------------------------------------- /src/tincd/darwin/device.c: -------------------------------------------------------------------------------- 1 | /* 2 | device.c -- Interaction with MacOS/X tun device 3 | Copyright (C) 2001-2003 Ivo Timmermans , 4 | 2001-2003 Guus Sliepen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | $Id: device.c,v 1.1 2003-10-14 03:22:09 pcg Exp $ 21 | */ 22 | 23 | 24 | 25 | #define DEFAULT_DEVICE "/dev/tun0" 26 | 27 | int device_fd = -1; 28 | char *device; 29 | char *iface; 30 | char *device_info; 31 | int device_total_in = 0; 32 | int device_total_out = 0; 33 | 34 | bool setup_device(void) 35 | { 36 | cp(); 37 | 38 | if(!get_config_string(lookup_config(config_tree, "Device"), &device)) 39 | device = DEFAULT_DEVICE; 40 | 41 | if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) 42 | iface = rindex(device, '/') ? rindex(device, '/') + 1 : device; 43 | 44 | if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) { 45 | logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno)); 46 | return false; 47 | } 48 | 49 | device_info = _("MacOS/X tun device"); 50 | 51 | logger(LOG_INFO, _("%s is a %s"), device, device_info); 52 | 53 | return true; 54 | } 55 | 56 | void close_device(void) 57 | { 58 | cp(); 59 | 60 | close(device_fd); 61 | } 62 | 63 | bool read_packet(vpn_packet_t *packet) 64 | { 65 | int lenin; 66 | 67 | cp(); 68 | 69 | if((lenin = read(device_fd, packet->data + 14, MTU - 14)) <= 0) { 70 | logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, 71 | device, strerror(errno)); 72 | return false; 73 | } 74 | 75 | packet->data[12] = 0x08; 76 | packet->data[13] = 0x00; 77 | 78 | packet->len = lenin + 14; 79 | 80 | device_total_in += packet->len; 81 | 82 | ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), 83 | packet->len, device_info); 84 | 85 | return true; 86 | } 87 | 88 | bool write_packet(vpn_packet_t *packet) 89 | { 90 | cp(); 91 | 92 | ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"), 93 | packet->len, device_info); 94 | 95 | if(write(device_fd, packet->data + 14, packet->len - 14) < 0) { 96 | logger(LOG_ERR, _("Error while writing to %s %s: %s"), device_info, 97 | device, strerror(errno)); 98 | return false; 99 | } 100 | 101 | device_total_out += packet->len; 102 | 103 | return true; 104 | } 105 | 106 | void dump_device_stats(void) 107 | { 108 | cp(); 109 | 110 | logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device); 111 | logger(LOG_DEBUG, _(" total bytes in: %10d"), device_total_in); 112 | logger(LOG_DEBUG, _(" total bytes out: %10d"), device_total_out); 113 | } 114 | -------------------------------------------------------------------------------- /src/tincd/fixit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | while (<>) { 4 | if (/^#include \"(.*)"/) { 5 | warn "skipping local include $1"; 6 | } else { 7 | print; 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /src/tincd/freebsd/device.c: -------------------------------------------------------------------------------- 1 | /* 2 | device.c -- Interaction with FreeBSD tap device 3 | Copyright (C) 2001-2003 Ivo Timmermans , 4 | 2001-2003 Guus Sliepen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | $Id: device.c,v 1.1 2003-10-14 03:22:09 pcg Exp $ 21 | */ 22 | 23 | 24 | 25 | #define DEFAULT_DEVICE "/dev/tap0" 26 | 27 | int device_fd = -1; 28 | char *device; 29 | char *iface; 30 | char *device_info; 31 | int device_total_in = 0; 32 | int device_total_out = 0; 33 | 34 | bool setup_device(void) 35 | { 36 | cp(); 37 | 38 | if(!get_config_string(lookup_config(config_tree, "Device"), &device)) 39 | device = DEFAULT_DEVICE; 40 | 41 | if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) 42 | iface = rindex(device, '/') ? rindex(device, '/') + 1 : device; 43 | 44 | if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) { 45 | logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno)); 46 | return false; 47 | } 48 | 49 | device_info = _("FreeBSD tap device"); 50 | 51 | logger(LOG_INFO, _("%s is a %s"), device, device_info); 52 | 53 | return true; 54 | } 55 | 56 | void close_device(void) 57 | { 58 | cp(); 59 | 60 | close(device_fd); 61 | } 62 | 63 | bool read_packet(vpn_packet_t *packet) 64 | { 65 | int lenin; 66 | 67 | cp(); 68 | 69 | if((lenin = read(device_fd, packet->data, MTU)) <= 0) { 70 | logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, 71 | device, strerror(errno)); 72 | return false; 73 | } 74 | 75 | packet->len = lenin; 76 | 77 | device_total_in += packet->len; 78 | 79 | ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), 80 | packet->len, device_info); 81 | 82 | return true; 83 | } 84 | 85 | bool write_packet(vpn_packet_t *packet) 86 | { 87 | cp(); 88 | 89 | ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"), 90 | packet->len, device_info); 91 | 92 | if(write(device_fd, packet->data, packet->len) < 0) { 93 | logger(LOG_ERR, _("Error while writing to %s %s: %s"), device_info, 94 | device, strerror(errno)); 95 | return false; 96 | } 97 | 98 | device_total_out += packet->len; 99 | 100 | return true; 101 | } 102 | 103 | void dump_device_stats(void) 104 | { 105 | cp(); 106 | 107 | logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device); 108 | logger(LOG_DEBUG, _(" total bytes in: %10d"), device_total_in); 109 | logger(LOG_DEBUG, _(" total bytes out: %10d"), device_total_out); 110 | } 111 | -------------------------------------------------------------------------------- /src/tincd/mingw/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TAP-Win32 -- A kernel driver to provide virtual tap device functionality 3 | * on Windows. Originally derived from the CIPE-Win32 4 | * project by Damion K. Wilson, with extensive modifications by 5 | * James Yonan. 6 | * 7 | * All source code which derives from the CIPE-Win32 project is 8 | * Copyright (C) Damion K. Wilson, 2003, and is released under the 9 | * GPL version 2 (see below). 10 | * 11 | * All other source code is Copyright (C) James Yonan, 2003-2004, 12 | * and is released under the GPL version 2 (see below). 13 | * 14 | * This program is free software; you can redistribute it and/or modify 15 | * it under the terms of the GNU General Public License as published by 16 | * the Free Software Foundation; either version 2 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * This program is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | * GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License 25 | * along with this program (see the file COPYING included with this 26 | * distribution); if not, write to the Free Software Foundation, Inc., 27 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 28 | */ 29 | 30 | //=============================================== 31 | // This file is included both by OpenVPN and 32 | // the TAP-Win32 driver and contains definitions 33 | // common to both. 34 | //=============================================== 35 | 36 | //============= 37 | // TAP IOCTLs 38 | //============= 39 | 40 | #define TAP_CONTROL_CODE(request,method) \ 41 | CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS) 42 | 43 | #define TAP_IOCTL_GET_MAC TAP_CONTROL_CODE (1, METHOD_BUFFERED) 44 | #define TAP_IOCTL_GET_VERSION TAP_CONTROL_CODE (2, METHOD_BUFFERED) 45 | #define TAP_IOCTL_GET_MTU TAP_CONTROL_CODE (3, METHOD_BUFFERED) 46 | #define TAP_IOCTL_GET_INFO TAP_CONTROL_CODE (4, METHOD_BUFFERED) 47 | #define TAP_IOCTL_CONFIG_POINT_TO_POINT TAP_CONTROL_CODE (5, METHOD_BUFFERED) 48 | #define TAP_IOCTL_SET_MEDIA_STATUS TAP_CONTROL_CODE (6, METHOD_BUFFERED) 49 | #define TAP_IOCTL_CONFIG_DHCP_MASQ TAP_CONTROL_CODE (7, METHOD_BUFFERED) 50 | #define TAP_IOCTL_GET_LOG_LINE TAP_CONTROL_CODE (8, METHOD_BUFFERED) 51 | #define TAP_IOCTL_CONFIG_DHCP_SET_OPT TAP_CONTROL_CODE (9, METHOD_BUFFERED) 52 | 53 | //================= 54 | // Registry keys 55 | //================= 56 | 57 | #define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}" 58 | 59 | #define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}" 60 | 61 | //====================== 62 | // Filesystem prefixes 63 | //====================== 64 | 65 | #define USERMODEDEVICEDIR "\\\\.\\Global\\" 66 | #define SYSDEVICEDIR "\\Device\\" 67 | #define USERDEVICEDIR "\\DosDevices\\Global\\" 68 | #define TAPSUFFIX ".tap" 69 | 70 | //========================================================= 71 | // TAP_COMPONENT_ID -- This string defines the TAP driver 72 | // type -- different component IDs can reside in the system 73 | // simultaneously. 74 | //========================================================= 75 | 76 | #define TAP_COMPONENT_ID "tap0801" 77 | -------------------------------------------------------------------------------- /src/tincd/netbsd/device.c: -------------------------------------------------------------------------------- 1 | /* 2 | device.c -- Interaction with NetBSD tun device 3 | Copyright (C) 2001-2003 Ivo Timmermans , 4 | 2001-2003 Guus Sliepen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | $Id: device.c,v 1.1 2003-10-14 03:22:09 pcg Exp $ 21 | */ 22 | 23 | 24 | 25 | #define DEFAULT_DEVICE "/dev/tun0" 26 | 27 | #define DEVICE_TYPE_ETHERTAP 0 28 | #define DEVICE_TYPE_TUNTAP 1 29 | 30 | int device_fd = -1; 31 | char *device; 32 | char *iface; 33 | char *device_info; 34 | 35 | int device_total_in = 0; 36 | int device_total_out = 0; 37 | 38 | bool setup_device(void) 39 | { 40 | cp(); 41 | 42 | if(!get_config_string(lookup_config(config_tree, "Device"), &device)) 43 | device = DEFAULT_DEVICE; 44 | 45 | if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) 46 | iface = rindex(device, '/') ? rindex(device, '/') + 1 : device; 47 | if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) { 48 | logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno)); 49 | return false; 50 | } 51 | 52 | device_info = _("NetBSD tun device"); 53 | 54 | logger(LOG_INFO, _("%s is a %s"), device, device_info); 55 | 56 | return true; 57 | } 58 | 59 | void close_device(void) 60 | { 61 | cp(); 62 | 63 | close(device_fd); 64 | } 65 | 66 | bool read_packet(vpn_packet_t *packet) 67 | { 68 | int lenin; 69 | 70 | cp(); 71 | 72 | if((lenin = read(device_fd, packet->data + 14, MTU - 14)) <= 0) { 73 | logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, 74 | device, strerror(errno)); 75 | return false; 76 | } 77 | 78 | packet->data[12] = 0x08; 79 | packet->data[13] = 0x00; 80 | 81 | packet->len = lenin + 14; 82 | 83 | device_total_in += packet->len; 84 | 85 | ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len, 86 | device_info); 87 | 88 | return true; 89 | } 90 | 91 | bool write_packet(vpn_packet_t *packet) 92 | { 93 | cp(); 94 | 95 | ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"), 96 | packet->len, device_info); 97 | 98 | if(write(device_fd, packet->data + 14, packet->len - 14) < 0) { 99 | logger(LOG_ERR, _("Can't write to %s %s: %s"), device_info, device, 100 | strerror(errno)); 101 | return false; 102 | } 103 | 104 | device_total_out += packet->len; 105 | 106 | return true; 107 | } 108 | 109 | void dump_device_stats(void) 110 | { 111 | cp(); 112 | 113 | logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device); 114 | logger(LOG_DEBUG, _(" total bytes in: %10d"), device_total_in); 115 | logger(LOG_DEBUG, _(" total bytes out: %10d"), device_total_out); 116 | } 117 | -------------------------------------------------------------------------------- /src/tincd/openbsd/device.c: -------------------------------------------------------------------------------- 1 | /* 2 | device.c -- Interaction with OpenBSD tun device 3 | Copyright (C) 2001-2003 Ivo Timmermans , 4 | 2001-2003 Guus Sliepen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | $Id: device.c,v 1.1 2003-10-14 03:22:09 pcg Exp $ 21 | */ 22 | 23 | #include 24 | 25 | 26 | #define DEFAULT_DEVICE "/dev/tun0" 27 | 28 | #define DEVICE_TYPE_ETHERTAP 0 29 | #define DEVICE_TYPE_TUNTAP 1 30 | 31 | int device_fd = -1; 32 | char *device; 33 | char *iface; 34 | char *device_info; 35 | 36 | int device_total_in = 0; 37 | int device_total_out = 0; 38 | 39 | bool setup_device(void) 40 | { 41 | cp(); 42 | 43 | if(!get_config_string(lookup_config(config_tree, "Device"), &device)) 44 | device = DEFAULT_DEVICE; 45 | 46 | if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) 47 | iface = rindex(device, '/') ? rindex(device, '/') + 1 : device; 48 | if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) { 49 | logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno)); 50 | return false; 51 | } 52 | 53 | device_info = _("OpenBSD tun device"); 54 | 55 | logger(LOG_INFO, _("%s is a %s"), device, device_info); 56 | 57 | return true; 58 | } 59 | 60 | void close_device(void) 61 | { 62 | cp(); 63 | 64 | close(device_fd); 65 | } 66 | 67 | bool read_packet(vpn_packet_t *packet) 68 | { 69 | int lenin; 70 | u_int32_t type; 71 | struct iovec vector[2] = {{&type, sizeof(type)}, {packet->data + 14, MTU - 14}}; 72 | 73 | cp(); 74 | 75 | if((lenin = readv(device_fd, vector, 2)) <= 0) { 76 | logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, 77 | device, strerror(errno)); 78 | return false; 79 | } 80 | 81 | switch (ntohl(type)) { 82 | case AF_INET: 83 | packet->data[12] = 0x8; 84 | packet->data[13] = 0x0; 85 | break; 86 | 87 | case AF_INET6: 88 | packet->data[12] = 0x86; 89 | packet->data[13] = 0xDD; 90 | break; 91 | 92 | default: 93 | ifdebug(TRAFFIC) logger(LOG_ERR, 94 | _ ("Unknown address family %d while reading packet from %s %s"), 95 | ntohl(type), device_info, device); 96 | return false; 97 | } 98 | 99 | packet->len = lenin + 10; 100 | 101 | device_total_in += packet->len; 102 | 103 | ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len, 104 | device_info); 105 | 106 | return true; 107 | } 108 | 109 | bool write_packet(vpn_packet_t *packet) 110 | { 111 | u_int32_t type; 112 | struct iovec vector[2]; 113 | int af; 114 | 115 | cp(); 116 | 117 | ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"), 118 | packet->len, device_info); 119 | 120 | af = (packet->data[12] << 8) + packet->data[13]; 121 | 122 | switch (af) { 123 | case 0x800: 124 | type = htonl(AF_INET); 125 | break; 126 | case 0x86DD: 127 | type = htonl(AF_INET6); 128 | break; 129 | default: 130 | ifdebug(TRAFFIC) logger(LOG_ERR, 131 | _("Unknown address family %d while writing packet to %s %s"), 132 | af, device_info, device); 133 | return false; 134 | } 135 | 136 | vector[0].iov_base = &type; 137 | vector[0].iov_len = sizeof(type); 138 | vector[1].iov_base = packet->data + 14; 139 | vector[1].iov_len = packet->len - 14; 140 | 141 | if(writev(device_fd, vector, 2) < 0) { 142 | logger(LOG_ERR, _("Can't write to %s %s: %s"), device_info, device, 143 | strerror(errno)); 144 | return false; 145 | } 146 | 147 | device_total_out += packet->len; 148 | 149 | return true; 150 | } 151 | 152 | void dump_device_stats(void) 153 | { 154 | cp(); 155 | 156 | logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device); 157 | logger(LOG_DEBUG, _(" total bytes in: %10d"), device_total_in); 158 | logger(LOG_DEBUG, _(" total bytes out: %10d"), device_total_out); 159 | } 160 | -------------------------------------------------------------------------------- /src/tincd/raw_socket/device.c: -------------------------------------------------------------------------------- 1 | /* 2 | device.c -- raw socket 3 | Copyright (C) 2002-2004 Ivo Timmermans , 4 | 2002-2004 Guus Sliepen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | $Id: device.c,v 1.2 2005-03-17 23:59:38 pcg Exp $ 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | int device_fd = -1; 27 | char *device; 28 | char *iface; 29 | char ifrname[IFNAMSIZ]; 30 | char *device_info; 31 | 32 | static int device_total_in = 0; 33 | static int device_total_out = 0; 34 | 35 | bool setup_device(void) 36 | { 37 | struct ifreq ifr; 38 | struct sockaddr_ll sa; 39 | 40 | cp(); 41 | 42 | if(!get_config_string 43 | (lookup_config(config_tree, "Interface"), &iface)) 44 | iface = "eth0"; 45 | 46 | if(!get_config_string(lookup_config(config_tree, "Device"), &device)) 47 | device = iface; 48 | 49 | device_info = _("raw socket"); 50 | 51 | if((device_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) { 52 | logger(LOG_ERR, _("Could not open %s: %s"), device_info, 53 | strerror(errno)); 54 | return false; 55 | } 56 | 57 | memset(&ifr, 0, sizeof(ifr)); 58 | strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ); 59 | if(ioctl(device_fd, SIOCGIFINDEX, &ifr)) { 60 | close(device_fd); 61 | logger(LOG_ERR, _("Can't find interface %s: %s"), iface, 62 | strerror(errno)); 63 | return false; 64 | } 65 | 66 | memset(&sa, '0', sizeof(sa)); 67 | sa.sll_family = AF_PACKET; 68 | sa.sll_protocol = htons(ETH_P_ALL); 69 | sa.sll_ifindex = ifr.ifr_ifindex; 70 | 71 | if(bind(device_fd, (struct sockaddr *) &sa, (socklen_t) sizeof(sa))) { 72 | logger(LOG_ERR, _("Could not bind %s to %s: %s"), device, iface, strerror(errno)); 73 | return false; 74 | } 75 | 76 | logger(LOG_INFO, _("%s is a %s"), device, device_info); 77 | 78 | return true; 79 | } 80 | 81 | void close_device(void) 82 | { 83 | cp(); 84 | 85 | close(device_fd); 86 | } 87 | 88 | bool read_packet(vpn_packet_t *packet) 89 | { 90 | int lenin; 91 | 92 | cp(); 93 | 94 | if((lenin = read(device_fd, packet->data, MTU)) <= 0) { 95 | logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, 96 | device, strerror(errno)); 97 | return false; 98 | } 99 | 100 | packet->len = lenin; 101 | 102 | device_total_in += packet->len; 103 | 104 | ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len, 105 | device_info); 106 | 107 | return true; 108 | } 109 | 110 | bool write_packet(vpn_packet_t *packet) 111 | { 112 | cp(); 113 | 114 | ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"), 115 | packet->len, device_info); 116 | 117 | if(write(device_fd, packet->data, packet->len) < 0) { 118 | logger(LOG_ERR, _("Can't write to %s %s: %s"), device_info, device, 119 | strerror(errno)); 120 | return false; 121 | } 122 | 123 | device_total_out += packet->len; 124 | 125 | return true; 126 | } 127 | 128 | void dump_device_stats(void) 129 | { 130 | cp(); 131 | 132 | logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device); 133 | logger(LOG_DEBUG, _(" total bytes in: %10d"), device_total_in); 134 | logger(LOG_DEBUG, _(" total bytes out: %10d"), device_total_out); 135 | } 136 | -------------------------------------------------------------------------------- /src/tincd/solaris/device.c: -------------------------------------------------------------------------------- 1 | /* 2 | device.c -- Interaction with Solaris tun device 3 | Copyright (C) 2001-2004 Ivo Timmermans , 4 | 2001-2004 Guus Sliepen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | $Id: device.c,v 1.2 2005-03-17 23:59:38 pcg Exp $ 21 | */ 22 | 23 | 24 | #include "system.h" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #define DEFAULT_DEVICE "/dev/tun" 31 | 32 | int device_fd = -1; 33 | char *device = NULL; 34 | char *iface = NULL; 35 | char *device_info = NULL; 36 | 37 | static int device_total_in = 0; 38 | static int device_total_out = 0; 39 | 40 | bool setup_device(void) 41 | { 42 | int ip_fd = -1, if_fd = -1; 43 | int ppa; 44 | char *ptr; 45 | 46 | cp(); 47 | 48 | if(!get_config_string(lookup_config(config_tree, "Device"), &device)) 49 | device = DEFAULT_DEVICE; 50 | 51 | if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) { 52 | logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno)); 53 | return false; 54 | } 55 | 56 | ppa = 0; 57 | 58 | ptr = device; 59 | while(*ptr && !isdigit((int) *ptr)) 60 | ptr++; 61 | ppa = atoi(ptr); 62 | 63 | if((ip_fd = open("/dev/ip", O_RDWR, 0)) < 0) { 64 | logger(LOG_ERR, _("Could not open /dev/ip: %s"), strerror(errno)); 65 | return false; 66 | } 67 | 68 | /* Assign a new PPA and get its unit number. */ 69 | if((ppa = ioctl(device_fd, TUNNEWPPA, ppa)) < 0) { 70 | logger(LOG_ERR, _("Can't assign new interface: %s"), strerror(errno)); 71 | return false; 72 | } 73 | 74 | if((if_fd = open(device, O_RDWR, 0)) < 0) { 75 | logger(LOG_ERR, _("Could not open %s twice: %s"), device, 76 | strerror(errno)); 77 | return false; 78 | } 79 | 80 | if(ioctl(if_fd, I_PUSH, "ip") < 0) { 81 | logger(LOG_ERR, _("Can't push IP module: %s"), strerror(errno)); 82 | return false; 83 | } 84 | 85 | /* Assign ppa according to the unit number returned by tun device */ 86 | if(ioctl(if_fd, IF_UNITSEL, (char *) &ppa) < 0) { 87 | logger(LOG_ERR, _("Can't set PPA %d: %s"), ppa, strerror(errno)); 88 | return false; 89 | } 90 | 91 | if(ioctl(ip_fd, I_LINK, if_fd) < 0) { 92 | logger(LOG_ERR, _("Can't link TUN device to IP: %s"), strerror(errno)); 93 | return false; 94 | } 95 | 96 | if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) 97 | asprintf(&iface, "tun%d", ppa); 98 | 99 | device_info = _("Solaris tun device"); 100 | 101 | logger(LOG_INFO, _("%s is a %s"), device, device_info); 102 | 103 | return true; 104 | } 105 | 106 | void close_device(void) 107 | { 108 | cp(); 109 | 110 | close(device_fd); 111 | } 112 | 113 | bool read_packet(vpn_packet_t *packet) 114 | { 115 | int lenin; 116 | 117 | cp(); 118 | 119 | if((lenin = read(device_fd, packet->data + 14, MTU - 14)) <= 0) { 120 | logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, 121 | device, strerror(errno)); 122 | return false; 123 | } 124 | 125 | switch(packet->data[14] >> 4) { 126 | case 4: 127 | packet->data[12] = 0x08; 128 | packet->data[13] = 0x00; 129 | break; 130 | case 6: 131 | packet->data[12] = 0x86; 132 | packet->data[13] = 0xDD; 133 | break; 134 | default: 135 | ifdebug(TRAFFIC) logger(LOG_ERR, 136 | _ ("Unknown IP version %d while reading packet from %s %s"), 137 | packet->data[14] >> 4, device_info, device); 138 | return false; 139 | } 140 | 141 | packet->len = lenin + 14; 142 | 143 | device_total_in += packet->len; 144 | 145 | ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len, 146 | device_info); 147 | 148 | return true; 149 | } 150 | 151 | bool write_packet(vpn_packet_t *packet) 152 | { 153 | cp(); 154 | 155 | ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"), 156 | packet->len, device_info); 157 | 158 | if(write(device_fd, packet->data + 14, packet->len - 14) < 0) { 159 | logger(LOG_ERR, _("Can't write to %s %s: %s"), device_info, 160 | device, strerror(errno)); 161 | return false; 162 | } 163 | 164 | device_total_out += packet->len; 165 | 166 | return true; 167 | } 168 | 169 | void dump_device_stats(void) 170 | { 171 | cp(); 172 | 173 | logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device); 174 | logger(LOG_DEBUG, _(" total bytes in: %10d"), device_total_in); 175 | logger(LOG_DEBUG, _(" total bytes out: %10d"), device_total_out); 176 | } 177 | -------------------------------------------------------------------------------- /src/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | util.h -- process management and other utility functions 3 | Copyright (C) 1998-2002 Ivo Timmermans 4 | 2000-2002 Guus Sliepen 5 | 2003-2011 Marc Lehmann 6 | 7 | This file is part of GVPE. 8 | 9 | GVPE is free software; you can redistribute it and/or modify it 10 | under the terms of the GNU General Public License as published by the 11 | Free Software Foundation; either version 3 of the License, or (at your 12 | option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 | Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License along 20 | with this program; if not, see . 21 | 22 | Additional permission under GNU GPL version 3 section 7 23 | 24 | If you modify this Program, or any covered work, by linking or 25 | combining it with the OpenSSL project's OpenSSL library (or a modified 26 | version of that library), containing parts covered by the terms of the 27 | OpenSSL or SSLeay licenses, the licensors of this Program grant you 28 | additional permission to convey the resulting work. Corresponding 29 | Source for a non-source form of such a combination shall include the 30 | source code for the parts of OpenSSL used as well as that of the 31 | covered work. 32 | */ 33 | 34 | #ifndef UTIL_H__ 35 | #define UTIL_H__ 36 | 37 | #include 38 | #include 39 | 40 | #include 41 | 42 | #include "gettext.h" 43 | 44 | #include "slog.h" 45 | #include "ev_cpp.h" 46 | #include "callback.h" 47 | 48 | typedef ev_tstamp tstamp; 49 | 50 | /* 51 | * check for an existing gvpe for this net, and write pid to pidfile 52 | */ 53 | extern int write_pidfile (void); 54 | 55 | /* 56 | * kill older gvpe 57 | */ 58 | extern int kill_other (int signal); 59 | 60 | /* 61 | * Detach from current terminal, write pidfile, kill parent 62 | */ 63 | extern int detach (int do_detach); 64 | 65 | /* 66 | * check wether the given path is an absolute pathname 67 | */ 68 | #define ABSOLUTE_PATH(c) ((c)[0] == '/') 69 | 70 | /*****************************************************************************/ 71 | 72 | typedef u8 mac[6]; 73 | 74 | extern void id2mac (unsigned int id, void *m); 75 | 76 | #define mac2id(p) ((p)[0] & 0x01 ? 0 : ((p)[4] << 8) | (p)[5]) 77 | 78 | struct sliding_window 79 | { 80 | u32 v[(WINDOWSIZE + 31) / 32]; 81 | u32 seq; 82 | 83 | void reset (u32 seqno) 84 | { 85 | memset (v, -1, sizeof v); 86 | seq = seqno; 87 | } 88 | 89 | // 0 == ok, 1 == far history, 2 == duplicate in-window, 3 == far future 90 | int seqno_classify (u32 seqno) 91 | { 92 | if (seqno <= seq - WINDOWSIZE) 93 | return 1; 94 | else if (seqno > seq + WINDOWSIZE * 16) 95 | return 3; 96 | else 97 | { 98 | while (seqno > seq) 99 | { 100 | seq++; 101 | 102 | u32 s = seq % WINDOWSIZE; 103 | u32 *cell = v + (s >> 5); 104 | u32 mask = 1 << (s & 31); 105 | 106 | *cell &= ~mask; 107 | } 108 | 109 | u32 s = seqno % WINDOWSIZE; 110 | u32 *cell = v + (s >> 5); 111 | u32 mask = 1 << (s & 31); 112 | 113 | if (*cell & mask) 114 | return 2; 115 | else 116 | { 117 | *cell |= mask; 118 | return 0; 119 | } 120 | } 121 | } 122 | }; 123 | 124 | typedef callback run_script_cb; 125 | 126 | // run a shell script (or actually an external program). 127 | pid_t run_script (const run_script_cb &cb, bool wait); 128 | 129 | #if ENABLE_HTTP_PROXY 130 | u8 *base64_encode (const u8 *data, unsigned int len); 131 | #endif 132 | 133 | /*****************************************************************************/ 134 | 135 | typedef u8 rsaclear[RSA_KEYLEN - RSA_OVERHEAD]; // challenge data; 136 | typedef u8 rsacrypt[RSA_KEYLEN]; // encrypted challenge 137 | 138 | static inline void 139 | rsa_encrypt (RSA *key, const rsaclear &chg, rsacrypt &encr) 140 | { 141 | if (RSA_public_encrypt (sizeof chg, 142 | (unsigned char *)&chg, (unsigned char *)&encr, 143 | key, RSA_PKCS1_OAEP_PADDING) < 0) 144 | fatal ("RSA_public_encrypt error"); 145 | } 146 | 147 | static inline bool 148 | rsa_decrypt (RSA *key, const rsacrypt &encr, rsaclear &chg) 149 | { 150 | return RSA_private_decrypt (sizeof encr, 151 | (unsigned char *)&encr, (unsigned char *)&chg, 152 | key, RSA_PKCS1_OAEP_PADDING) > 0; 153 | } 154 | 155 | /*****************************************************************************/ 156 | 157 | void async (callback work_cb, callback done_cb); 158 | 159 | #endif 160 | 161 | -------------------------------------------------------------------------------- /src/vpn.h: -------------------------------------------------------------------------------- 1 | /* 2 | vpn.h -- header for vpn.C 3 | Copyright (C) 2003-2008 Marc Lehmann 4 | 5 | This file is part of GVPE. 6 | 7 | GVPE is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, see . 19 | 20 | Additional permission under GNU GPL version 3 section 7 21 | 22 | If you modify this Program, or any covered work, by linking or 23 | combining it with the OpenSSL project's OpenSSL library (or a modified 24 | version of that library), containing parts covered by the terms of the 25 | OpenSSL or SSLeay licenses, the licensors of this Program grant you 26 | additional permission to convey the resulting work. Corresponding 27 | Source for a non-source form of such a combination shall include the 28 | source code for the parts of OpenSSL used as well as that of the 29 | covered work. 30 | */ 31 | 32 | #ifndef GVPE_VPN_H__ 33 | #define GVPE_VPN_H__ 34 | 35 | #include "global.h" 36 | #include "conf.h" 37 | #include "device.h" 38 | #include "connection.h" 39 | 40 | struct vpn 41 | { 42 | int udpv4_fd , tcpv4_fd, ipv4_fd , icmpv4_fd , dnsv4_fd; 43 | int udpv4_tos, ipv4_tos, icmpv4_tos, dnsv4_tos; 44 | 45 | int events; 46 | 47 | enum { 48 | EVENT_RECONNECT = 1, 49 | EVENT_SHUTDOWN = 2, 50 | }; 51 | 52 | void event_cb (ev::timer &w, int revents); ev::timer event; 53 | 54 | tap_device *tap; 55 | 56 | typedef vector conns_vector; 57 | conns_vector conns; 58 | 59 | // called when any conenction has been established 60 | void connection_established (connection *c); 61 | 62 | // return true if src can connect directly to dst 63 | bool can_direct (conf_node *src, conf_node *dst) const; 64 | connection *find_router_for (const connection *dst); 65 | 66 | void reconnect_all (); 67 | void shutdown_all (); 68 | 69 | void tap_ev (ev::io &w, int revents); ev::io tap_ev_watcher; 70 | void inject_data_packet (tap_packet *pkt, int dst); 71 | 72 | void send_connect_request (connection *c); 73 | 74 | void recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi); 75 | bool send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos = 0); 76 | 77 | #if ENABLE_TCP 78 | void tcpv4_ev (ev::io &w, int revents); ev::io tcpv4_ev_watcher; 79 | bool send_tcpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos); 80 | #endif 81 | 82 | #if ENABLE_ICMP 83 | void icmpv4_ev (ev::io &w, int revents); ev::io icmpv4_ev_watcher; 84 | bool send_icmpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos); 85 | #endif 86 | 87 | #if ENABLE_DNS 88 | vector dns_sndpq; 89 | sockinfo dns_forwarder; 90 | 91 | void dnsv4_ev (ev::io &w, int revents); ev::io dnsv4_ev_watcher; 92 | void dnsv4_server (struct dns_packet &pkt); 93 | void dnsv4_client (struct dns_packet &pkt); 94 | 95 | bool send_dnsv4_packet (vpn_packet *pkt, const sockinfo &si, int tos); 96 | #endif 97 | 98 | void udpv4_ev (ev::io &w, int revents); ev::io udpv4_ev_watcher; 99 | bool send_udpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos); 100 | 101 | void ipv4_ev (ev::io &w, int revents); ev::io ipv4_ev_watcher; 102 | bool send_ipv4_packet (vpn_packet *pkt, const sockinfo &si, int tos); 103 | 104 | vpn (); 105 | ~vpn (); 106 | 107 | int setup_socket (u8 prot, int family, int type, int proto); 108 | int setup (); 109 | 110 | void dump_status (); 111 | 112 | void script_init_env (); 113 | const char *script_if_init (); 114 | const char *script_if_up (); 115 | }; 116 | 117 | extern vpn network; // THE vpn 118 | 119 | #endif 120 | 121 | --------------------------------------------------------------------------------