# HG changeset patch # User ivo # Date 1286996864 -7200 # Node ID fd7c60905b139f1bcf55136edf4142b6648f279a # Parent cf9b44b46be530d0df049603d864c22b527ffe41 BSD support diff -r cf9b44b46be5 -r fd7c60905b13 build.sh --- a/build.sh Fri Oct 08 23:29:56 2010 +0000 +++ b/build.sh Wed Oct 13 21:07:44 2010 +0200 @@ -24,7 +24,7 @@ echo Done. export CPATH=./include/ -export LIBRARY_PATH=./lib/ +export LIBRARY_PATH=/usr/local/lib/:./lib/ echo Building combined binary... gcc -c -DCOMBINED_BINARY src/proto.raw.c -o obj/proto.raw.o @@ -48,7 +48,7 @@ ##echo Building frontends... ##gcc -o out/quicktun.debian src/run.debian.c -ldl -if [ -x /usr/bin/dpkg-deb ]; then +if [ -x /usr/bin/dpkg-deb -a -x /usr/bin/fakeroot ]; then echo Building debian binary... gcc -c -DCOMBINED_BINARY -DDEBIAN_BINARY src/run.combined.c -o obj/run.debian.o gcc -o out/quicktun.debian obj/common.o obj/run.debian.o obj/proto.raw.o obj/proto.nacl0.o obj/proto.nacltai.o obj/crypto_scalarmult_curve25519.o -lnacl diff -r cf9b44b46be5 -r fd7c60905b13 src/common.c --- a/src/common.c Fri Oct 08 23:29:56 2010 +0000 +++ b/src/common.c Wed Oct 13 21:07:44 2010 +0200 @@ -31,12 +31,18 @@ #include #endif #include -#include -#include -#include +#include +#include #include #include #include +#ifdef linux + #include + #include +#else + #define ETH_FRAME_LEN 1514 + #include +#endif #define MAX_PACKET_LEN (ETH_FRAME_LEN+4) //Some space for optional packet information @@ -132,15 +138,20 @@ int init_tuntap() { char* envval; - fprintf(stderr, "Initializing tap device...\n"); + fprintf(stderr, "Initializing tun/tap device...\n"); int ttfd; //Tap device file descriptor - 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 tap device file"); - if (envval = getconf("INTERFACE")) strcpy(ifr.ifr_name, envval); - ifr.ifr_flags = getconf("TUN_MODE") ? IFF_TUN : IFF_TAP; - ifr.ifr_flags |= getconf("USE_PI") ? 0 : IFF_NO_PI; - if (ioctl(ttfd, TUNSETIFF, (void *)&ifr) < 0) return errorexitp("TUNSETIFF ioctl failed"); +#ifdef 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"); + if (envval = getconf("INTERFACE")) strcpy(ifr.ifr_name, envval); + ifr.ifr_flags = getconf("TUN_MODE") ? IFF_TUN : IFF_TAP; + ifr.ifr_flags |= getconf("USE_PI") ? 0 : IFF_NO_PI; + if (ioctl(ttfd, TUNSETIFF, (void *)&ifr) < 0) return errorexitp("TUNSETIFF ioctl failed"); +#else + if (!(envval = getconf("INTERFACE"))) envval = "/dev/tun0"; + if ((ttfd = open(envval, O_RDWR)) < 0) return errorexitp("Could not open tun device file"); +#endif return ttfd; }