From 4a8b0ef2ec0b03ef70b3b38a6e809587cd953d6c Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 4 Feb 2009 01:23:54 +0000 Subject: added fix for new ifconfig method from uanytun --- src/bsd/tunDevice.cpp | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/bsd/tunDevice.cpp b/src/bsd/tunDevice.cpp index f55462f..29fe971 100644 --- a/src/bsd/tunDevice.cpp +++ b/src/bsd/tunDevice.cpp @@ -130,6 +130,8 @@ void TunDevice::init_post() } ti.flags |= IFF_MULTICAST; + if(conf_.type_ == TYPE_TUN) + ti.flags &= ~IFF_POINTOPOINT; if (ioctl(fd_, TUNSIFINFO, &ti) < 0) { ::close(fd_); @@ -226,30 +228,22 @@ int TunDevice::write(u_int8_t* buf, u_int32_t len) void TunDevice::do_ifconfig() { std::ostringstream command; - command << "/sbin/ifconfig " << actual_name_ << " " << conf_.addr_.toString(); + command << "/sbin/ifconfig " << actual_name_ << " " << conf_.addr_.toString() + << " netmask " << conf_.netmask_.toString() << " mtu " << conf_.mtu_; - - // TODO: figure out how to configure the interface BSD -// if(conf_.type_ == TYPE_TAP) -// command << " netmask "; -// else -// command << " "; - -// command << conf_.netmask_.toString() << " mtu " << conf_.mtu_; - -// if(conf_.type_ == TYPE_TUN) -// command << " netmask 255.255.255.255 up"; -// else { -// #if defined(__GNUC__) && defined(__OpenBSD__) -// command << " link0"; -// #elif defined(__GNUC__) && defined(__FreeBSD__) -// command << " up"; -// #elif defined(__GNUC__) && defined(__NetBSD__) -// command << ""; -// #else -// #error This Device works just for OpenBSD, FreeBSD or NetBSD -// #endif -// } + if(conf_.type_ == TYPE_TUN) + command << " up"; + else { +#if defined(__GNUC__) && defined(__OpenBSD__) + command << " link0"; +#elif defined(__GNUC__) && defined(__FreeBSD__) + command << " up"; +#elif defined(__GNUC__) && defined(__NetBSD__) + command << ""; +#else + #error This Device works just for OpenBSD, FreeBSD or NetBSD +#endif + } int result = system(command.str().c_str()); if(result == -1) -- cgit v1.2.3