ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/device-tincd.C
(Generate patch)

Comparing gvpe/src/device-tincd.C (file contents):
Revision 1.4 by pcg, Thu Oct 16 02:41:21 2003 UTC vs.
Revision 1.5 by pcg, Thu Oct 16 13:37:10 2003 UTC

94#if IF_linux 94#if IF_linux
95# include "tincd/linux/device.c" 95# include "tincd/linux/device.c"
96#elif IF_freebsd 96#elif IF_freebsd
97# include "tincd/freebsd/device.c" 97# include "tincd/freebsd/device.c"
98#elif IF_netbsd 98#elif IF_netbsd
99#define IF_istun 1
99# include "tincd/netbsd/device.c" 100# include "tincd/netbsd/device.c"
100#elif IF_solaris 101#elif IF_solaris
101# include "tincd/solaris/device.c" 102# include "tincd/solaris/device.c"
102#elif IF_cygwin 103#elif IF_cygwin
103# include "tincd/cygwin/device.c" 104# include "tincd/cygwin/device.c"
104#elif IF_mingw 105#elif IF_mingw
105# include "tincd/mingw/device.c" 106# include "tincd/mingw/device.c"
106#elif IF_darwin 107#elif IF_darwin
108#define IF_istun 1
107# include "tincd/darwin/device.c" 109# include "tincd/darwin/device.c"
108#elif IF_raw_socket 110#elif IF_raw_socket
111#define IF_istun 1
109# include "tincd/raw_socket/device.c" 112# include "tincd/raw_socket/device.c"
110#else 113#else
111# error No interface implementation for your IFTYPE/IFSUBTYPE combination. 114# error No interface implementation for your IFTYPE/IFSUBTYPE combination.
115#endif
116
117#if IF_istun
118# include "ether_emu.C"
112#endif 119#endif
113 120
114const char * 121const char *
115tap_device::info () 122tap_device::info ()
116{ 123{
150 slog (L_ERR, _("can't read from to %s %s: %s"), info (), DEFAULT_DEVICE, 157 slog (L_ERR, _("can't read from to %s %s: %s"), info (), DEFAULT_DEVICE,
151 strerror (errno)); 158 strerror (errno));
152 return 0; 159 return 0;
153 } 160 }
154 161
162#if IF_istun
163 // assume ipv4
164 (*pkt)[12] = 0x08;
165 (*pkt)[13] = 0x00;
166
167 if (!ether_emu.tun_to_tap (pkt))
168 {
169 delete pkt;
170 return 0;
171 }
172#endif
173
155 return pkt; 174 return pkt;
156} 175}
157 176
158void 177void
159tap_device::send (tap_packet *pkt) 178tap_device::send (tap_packet *pkt)
160{ 179{
180 if (
181#if IF_istun
182 ether_emu.tap_to_tun (pkt) &&
183#endif
161 if (!write_packet (reinterpret_cast<vpn_packet_t *>(pkt))) 184 !write_packet (reinterpret_cast<vpn_packet_t *>(pkt)))
162 slog (L_ERR, _("can't write to %s %s: %s"), info (), DEFAULT_DEVICE, 185 slog (L_ERR, _("can't write to %s %s: %s"), info (), DEFAULT_DEVICE,
163 strerror (errno)); 186 strerror (errno));
164} 187}
165 188
166 189

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines