--- gvpe/src/device-tincd.C 2003/10/14 15:48:15 1.3 +++ gvpe/src/device-tincd.C 2003/10/16 13:37:10 1.5 @@ -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 @@ -95,6 +96,7 @@ #elif IF_freebsd # include "tincd/freebsd/device.c" #elif IF_netbsd +#define IF_istun 1 # include "tincd/netbsd/device.c" #elif IF_solaris # include "tincd/solaris/device.c" @@ -103,13 +105,19 @@ #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 () { @@ -151,13 +159,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)); }