--- gvpe/src/device-tincd.C 2003/10/16 02:41:21 1.4 +++ gvpe/src/device-tincd.C 2003/10/16 13:37:52 1.6 @@ -93,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 () { @@ -152,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)); }