mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-30 00:46:05 +03:00
#43: Fixed write function, downstream tunneling works now on win32
This commit is contained in:
parent
540f411474
commit
568c4b18f4
15
src/tun.c
15
src/tun.c
@ -275,10 +275,21 @@ write_tun(int tun_fd, char *data, size_t len)
|
|||||||
#endif /* !LINUX */
|
#endif /* !LINUX */
|
||||||
#endif /* FREEBSD */
|
#endif /* FREEBSD */
|
||||||
|
|
||||||
|
#ifndef WINDOWS32
|
||||||
if (write(tun_fd, data, len) != len) {
|
if (write(tun_fd, data, len) != len) {
|
||||||
warn("write_tun");
|
warn("write_tun");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#else /* WINDOWS32 */
|
||||||
|
{
|
||||||
|
DWORD written;
|
||||||
|
WriteFile((HANDLE) tun_fd, data, len, &written, NULL);
|
||||||
|
if (written != len) {
|
||||||
|
warn("write_tun");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,9 +298,9 @@ read_tun(int tun_fd, char *buf, size_t len)
|
|||||||
{
|
{
|
||||||
#if defined (FREEBSD) || defined (DARWIN) || defined(NETBSD) || defined(WINDOWS32)
|
#if defined (FREEBSD) || defined (DARWIN) || defined(NETBSD) || defined(WINDOWS32)
|
||||||
/* FreeBSD/Darwin/NetBSD has no header */
|
/* FreeBSD/Darwin/NetBSD has no header */
|
||||||
return read(tun_fd, buf + 4, len - 4) + 4;
|
return READ(tun_fd, buf + 4, len - 4) + 4;
|
||||||
#else /* !FREEBSD */
|
#else /* !FREEBSD */
|
||||||
return read(tun_fd, buf, len);
|
return READ(tun_fd, buf, len);
|
||||||
#endif /* !FREEBSD */
|
#endif /* !FREEBSD */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user