--- gvpe/src/device-tincd.C 2003/10/14 03:59:32 1.2 +++ gvpe/src/device-tincd.C 2003/10/16 13:37:52 1.6 @@ -1,5 +1,6 @@ /* device-tincd.C -- include one of the tincd low level implementations. + Copyright (C) 2003 Marc Lehmann This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +30,12 @@ #include "conf.h" +// following headers used by cygwin (maybe others) +#include "netcompat.h" +#include + +#define xstrdup(strd) strdup(str) + /* make the tincd sources feel comfortable in our environment. */ /* this was reasonably easy to do. */ #define routing_mode 1 @@ -86,24 +93,43 @@ #if IF_linux # include "tincd/linux/device.c" + #elif IF_freebsd # include "tincd/freebsd/device.c" + #elif IF_netbsd +#define IF_istun 1 # include "tincd/netbsd/device.c" + +#elif IF_openbsd +#define IF_istun 1 +# include "tincd/openbsd/device.c" + #elif IF_solaris # include "tincd/solaris/device.c" + #elif IF_cygwin # include "tincd/cygwin/device.c" + #elif IF_mingw # include "tincd/mingw/device.c" + #elif IF_darwin +#define IF_istun 1 # include "tincd/darwin/device.c" + #elif IF_raw_socket +#define IF_istun 1 # include "tincd/raw_socket/device.c" + #else # error No interface implementation for your IFTYPE/IFSUBTYPE combination. #endif +#if IF_istun +# include "ether_emu.C" +#endif + const char * tap_device::info () { @@ -145,13 +171,29 @@ return 0; } +#if IF_istun + // assume ipv4 + (*pkt)[12] = 0x08; + (*pkt)[13] = 0x00; + + if (!ether_emu.tun_to_tap (pkt)) + { + delete pkt; + return 0; + } +#endif + return pkt; } void tap_device::send (tap_packet *pkt) { - if (!write_packet (reinterpret_cast(pkt))) + if ( +#if IF_istun + ether_emu.tap_to_tun (pkt) && +#endif + !write_packet (reinterpret_cast(pkt))) slog (L_ERR, _("can't write to %s %s: %s"), info (), DEFAULT_DEVICE, strerror (errno)); }