summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-03-04 17:01:56 +0000
committerChristian Pointner <equinox@anytun.org>2009-03-04 17:01:56 +0000
commit70b82e9a450dacd0d4092d15e67a9d0a6c466f6c (patch)
treea684856b5765dbf5ad330dcfad4ddf55f693986d /src
parentfixed build on FreeBSD (diff)
fixes for FreeBSD
Diffstat (limited to 'src')
-rw-r--r--src/bsd/tun.c34
-rwxr-xr-xsrc/configure8
2 files changed, 29 insertions, 13 deletions
diff --git a/src/bsd/tun.c b/src/bsd/tun.c
index d5697c5..ed3eb27 100644
--- a/src/bsd/tun.c
+++ b/src/bsd/tun.c
@@ -164,8 +164,8 @@ int tun_init_post(tun_device_t* dev)
struct tuninfo ti;
- if (ioctl(dev->fd_, TUNGIFINFO, &ti) < 0) {
- log_printf(ERROR, "can't enable multicast for interface");
+ if(ioctl(dev->fd_, TUNGIFINFO, &ti) < 0) {
+ log_printf(ERROR, "can't enable multicast for interface: %s", strerror(errno));
return -1;
}
@@ -173,15 +173,15 @@ int tun_init_post(tun_device_t* dev)
if(dev->type_ == TYPE_TUN)
ti.flags &= ~IFF_POINTOPOINT;
- if (ioctl(dev->fd_, TUNSIFINFO, &ti) < 0) {
- log_printf(ERROR, "can't enable multicast for interface");
+ if(ioctl(dev->fd_, TUNSIFINFO, &ti) < 0) {
+ log_printf(ERROR, "can't enable multicast for interface: %s", strerror(errno));
return -1;
}
return 0;
}
#elif defined(__GNUC__) && defined(__FreeBSD__)
- #warning this device has never been tested on FreeBSD and might not work
+
int tun_init_post(tun_device_t* dev)
{
if(!dev)
@@ -191,10 +191,26 @@ int tun_init_post(tun_device_t* dev)
if(dev->type_ == TYPE_TAP)
dev->with_pi_ = 0;
- int arg = 0;
- ioctl(dev->fd_, TUNSLMODE, &arg);
- arg = 1;
- ioctl(dev->fd_, TUNSIFHEAD, &arg);
+ if(dev->type_ == TYPE_TUN) {
+ int arg = 0;
+ if(ioctl(dev->fd_, TUNSLMODE, &arg) < 0) {
+ log_printf(ERROR, "can't disable link-layer mode for interface: %s", strerror(errno));
+ return -1;
+ }
+
+ arg = 1;
+ if(ioctl(dev->fd_, TUNSIFHEAD, &arg) < 0) {
+ log_printf(ERROR, "can't enable multi-af mode for interface: %s", strerror(errno));
+ return -1;
+ }
+
+ arg = IFF_BROADCAST;
+ arg |= IFF_MULTICAST;
+ if(ioctl(dev->fd_, TUNSIFMODE, &arg) < 0) {
+ log_printf(ERROR, "can't enable multicast for interface: %s", strerror(errno));
+ return -1;
+ }
+ }
return 0;
}
diff --git a/src/configure b/src/configure
index 9d13a5b..d88e333 100755
--- a/src/configure
+++ b/src/configure
@@ -92,7 +92,7 @@ do
V4_MAPPED=0
;;
--enable-v4-mapped)
- V4_MAPPED=1
+ V4_MAPPED=2
;;
--help)
print_usage
@@ -109,17 +109,17 @@ done
rm -f include.mk
case $TARGET in
Linux)
- rm -rf tun.c
+ rm -f tun.c
ln -sf linux/tun.c
echo "loading Linux specific TUN Device"
;;
OpenBSD|FreeBSD|NetBSD)
- rm -rf tun.c
+ rm -f tun.c
ln -sf bsd/tun.c
echo "loading BSD specific TUN Device"
CFLAGS=$CFLAGS' -I/usr/local/include'
LDFLAGS=$LDFLAGS' -L/usr/local/lib'
- if [ "x$TARGET" = "xOpenBSD" ]; then
+ if [ $V4_MAPPED -ne 2 ]; then
V4_MAPPED=0
fi
;;