From a22721f395b246e1236ab66b8d5ff9e4419bd8c7 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Sun, 25 Jun 2006 11:33:29 +0000 Subject: [PATCH] Equal darwin and freebsd, fix bsd open_tun to return fd --- tun.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tun.c b/tun.c index 5a8cffa..bc9d69a 100644 --- a/tun.c +++ b/tun.c @@ -107,6 +107,9 @@ open_tun(const char *tun_device) warn("open_tun: %s: %s", tun_name, strerror(errno)); return -1; } + + printf("Opened %s\n", tun_name); + return tun_fd; } else { for (i = 0; i < TUN_MAX_TRY; i++) { snprintf(tun_name, sizeof(tun_name), "/dev/tun%d", i); @@ -139,10 +142,10 @@ close_tun(int tun_fd) int write_tun(int tun_fd, char *data, int len) { -#ifdef FREEBSD +#if defined (FREEBSD) || defined (DARWIN) data += 4; len -= 4; -#else /* !FREEBSD */ +#else /* !FREEBSD/DARWIN */ #ifdef LINUX data[0] = 0x00; data[1] = 0x00; @@ -166,7 +169,7 @@ write_tun(int tun_fd, char *data, int len) int read_tun(int tun_fd, char *buf, int len) { -#ifdef FREEBSD +#if defined (FREEBSD) || defined (DARWIN) // FreeBSD has no header return read(tun_fd, buf + 4, len - 4) + 4; #else /* !FREEBSD */