# HG changeset patch # User Ivo Smits # Date 1385222334 -3600 # Node ID 4ff8003d09735b80cd0de8aead4df3b5d5a012d7 # Parent 15d651dec8e99eb87f08e0a1ff23ad69b3a1d407 Fix for OpenBSD tun/tap initialization diff -r 15d651dec8e9 -r 4ff8003d0973 src/common.c --- a/src/common.c Sat Nov 16 14:55:14 2013 +0100 +++ b/src/common.c Sat Nov 23 16:58:54 2013 +0100 @@ -216,7 +216,7 @@ if (envval = getconf("TUN_MODE")) tunmode = atoi(envval); session->use_pi = 0; if (tunmode && (envval = getconf("USE_PI"))) session->use_pi = atoi(envval); -#if defined linux +#if defined(__linux__) struct ifreq ifr; //required for tun/tap setup memset(&ifr, 0, sizeof(ifr)); if ((ttfd = open("/dev/net/tun", O_RDWR)) < 0) return errorexitp("Could not open tun/tap device file"); @@ -243,8 +243,12 @@ if (tunmode) { int i = IFF_POINTOPOINT | IFF_MULTICAST; ioctl(ttfd, TUNSIFMODE, &i); +#if defined(__OpenBSD__) + if (!session->use_pi) session->use_pi = 2; +#else i = session->use_pi ? 1 : 0; ioctl(ttfd, TUNSIFHEAD, &i); +#endif } #endif if (envval = getconf("TUN_UP_SCRIPT")) system(envval);