Mercurial > hg > quicktun
changeset 54:4ff8003d0973
Fix for OpenBSD tun/tap initialization
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Sat, 23 Nov 2013 16:58:54 +0100 |
parents | 15d651dec8e9 |
children | 5685fad38195 |
files | src/common.c |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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);