… | |
… | |
91 | |
91 | |
92 | #define netname conf.ifname |
92 | #define netname conf.ifname |
93 | |
93 | |
94 | #if IF_linux |
94 | #if IF_linux |
95 | # include "tincd/linux/device.c" |
95 | # include "tincd/linux/device.c" |
|
|
96 | |
96 | #elif IF_freebsd |
97 | #elif IF_freebsd |
97 | # include "tincd/freebsd/device.c" |
98 | # include "tincd/freebsd/device.c" |
|
|
99 | |
98 | #elif IF_netbsd |
100 | #elif IF_netbsd |
|
|
101 | #define IF_istun 1 |
99 | # 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 | |
100 | #elif IF_solaris |
108 | #elif IF_solaris |
101 | # include "tincd/solaris/device.c" |
109 | # include "tincd/solaris/device.c" |
|
|
110 | |
102 | #elif IF_cygwin |
111 | #elif IF_cygwin |
103 | # include "tincd/cygwin/device.c" |
112 | # include "tincd/cygwin/device.c" |
|
|
113 | |
104 | #elif IF_mingw |
114 | #elif IF_mingw |
105 | # include "tincd/mingw/device.c" |
115 | # include "tincd/mingw/device.c" |
|
|
116 | |
106 | #elif IF_darwin |
117 | #elif IF_darwin |
|
|
118 | #define IF_istun 1 |
107 | # include "tincd/darwin/device.c" |
119 | # include "tincd/darwin/device.c" |
|
|
120 | |
108 | #elif IF_raw_socket |
121 | #elif IF_raw_socket |
|
|
122 | #define IF_istun 1 |
109 | # include "tincd/raw_socket/device.c" |
123 | # include "tincd/raw_socket/device.c" |
|
|
124 | |
110 | #else |
125 | #else |
111 | # 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" |
112 | #endif |
131 | #endif |
113 | |
132 | |
114 | const char * |
133 | const char * |
115 | tap_device::info () |
134 | tap_device::info () |
116 | { |
135 | { |
… | |
… | |
150 | 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, |
151 | strerror (errno)); |
170 | strerror (errno)); |
152 | return 0; |
171 | return 0; |
153 | } |
172 | } |
154 | |
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 | |
155 | return pkt; |
186 | return pkt; |
156 | } |
187 | } |
157 | |
188 | |
158 | void |
189 | void |
159 | tap_device::send (tap_packet *pkt) |
190 | tap_device::send (tap_packet *pkt) |
160 | { |
191 | { |
|
|
192 | if ( |
|
|
193 | #if IF_istun |
|
|
194 | ether_emu.tap_to_tun (pkt) && |
|
|
195 | #endif |
161 | if (!write_packet (reinterpret_cast<vpn_packet_t *>(pkt))) |
196 | !write_packet (reinterpret_cast<vpn_packet_t *>(pkt))) |
162 | 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, |
163 | strerror (errno)); |
198 | strerror (errno)); |
164 | } |
199 | } |
165 | |
200 | |
166 | |
201 | |