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.3 by pcg, Tue Oct 14 15:48:15 2003 UTC vs.
Revision 1.6 by pcg, Thu Oct 16 13:37:52 2003 UTC

1/* 1/*
2 device-tincd.C -- include one of the tincd low level implementations. 2 device-tincd.C -- include one of the tincd low level implementations.
3 Copyright (C) 2003 Marc Lehmann <pcg@goof.com>
3 4
4 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version. 8 (at your option) any later version.
90 91
91#define netname conf.ifname 92#define netname conf.ifname
92 93
93#if IF_linux 94#if IF_linux
94# include "tincd/linux/device.c" 95# include "tincd/linux/device.c"
96
95#elif IF_freebsd 97#elif IF_freebsd
96# include "tincd/freebsd/device.c" 98# include "tincd/freebsd/device.c"
99
97#elif IF_netbsd 100#elif IF_netbsd
101#define IF_istun 1
98# include "tincd/netbsd/device.c" 102# include "tincd/netbsd/device.c"
103
104#elif IF_openbsd
105#define IF_istun 1
106# include "tincd/openbsd/device.c"
107
99#elif IF_solaris 108#elif IF_solaris
100# include "tincd/solaris/device.c" 109# include "tincd/solaris/device.c"
110
101#elif IF_cygwin 111#elif IF_cygwin
102# include "tincd/cygwin/device.c" 112# include "tincd/cygwin/device.c"
113
103#elif IF_mingw 114#elif IF_mingw
104# include "tincd/mingw/device.c" 115# include "tincd/mingw/device.c"
116
105#elif IF_darwin 117#elif IF_darwin
118#define IF_istun 1
106# include "tincd/darwin/device.c" 119# include "tincd/darwin/device.c"
120
107#elif IF_raw_socket 121#elif IF_raw_socket
122#define IF_istun 1
108# include "tincd/raw_socket/device.c" 123# include "tincd/raw_socket/device.c"
124
109#else 125#else
110# error No interface implementation for your IFTYPE/IFSUBTYPE combination. 126# error No interface implementation for your IFTYPE/IFSUBTYPE combination.
127#endif
128
129#if IF_istun
130# include "ether_emu.C"
111#endif 131#endif
112 132
113const char * 133const char *
114tap_device::info () 134tap_device::info ()
115{ 135{
149 slog (L_ERR, _("can't read from to %s %s: %s"), info (), DEFAULT_DEVICE, 169 slog (L_ERR, _("can't read from to %s %s: %s"), info (), DEFAULT_DEVICE,
150 strerror (errno)); 170 strerror (errno));
151 return 0; 171 return 0;
152 } 172 }
153 173
174#if IF_istun
175 // assume ipv4
176 (*pkt)[12] = 0x08;
177 (*pkt)[13] = 0x00;
178
179 if (!ether_emu.tun_to_tap (pkt))
180 {
181 delete pkt;
182 return 0;
183 }
184#endif
185
154 return pkt; 186 return pkt;
155} 187}
156 188
157void 189void
158tap_device::send (tap_packet *pkt) 190tap_device::send (tap_packet *pkt)
159{ 191{
192 if (
193#if IF_istun
194 ether_emu.tap_to_tun (pkt) &&
195#endif
160 if (!write_packet (reinterpret_cast<vpn_packet_t *>(pkt))) 196 !write_packet (reinterpret_cast<vpn_packet_t *>(pkt)))
161 slog (L_ERR, _("can't write to %s %s: %s"), info (), DEFAULT_DEVICE, 197 slog (L_ERR, _("can't write to %s %s: %s"), info (), DEFAULT_DEVICE,
162 strerror (errno)); 198 strerror (errno));
163} 199}
164 200
165 201

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines