summaryrefslogtreecommitdiff
path: root/src/bsd
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2008-05-12 20:43:19 +0000
committerChristian Pointner <equinox@anytun.org>2008-05-12 20:43:19 +0000
commit9ce26c637dc5f8af9134829c2f31627bf4bd2856 (patch)
tree9a7e57cb7293d1593a758dd204658cf1820ee104 /src/bsd
parentfixed some thread safety bugs (diff)
added do_ifconfig for bsd device
Diffstat (limited to 'src/bsd')
-rw-r--r--src/bsd/tunDevice.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/bsd/tunDevice.cpp b/src/bsd/tunDevice.cpp
index e8a2849..f8b6795 100644
--- a/src/bsd/tunDevice.cpp
+++ b/src/bsd/tunDevice.cpp
@@ -49,7 +49,7 @@
#include <iostream>
-TunDevice::TunDevice(const char* dev_name, const char* dev_type, const char* ifcfg_lp, const char* ifcfg_rnmp) : conf_(dev_name, dev_type, ifcfg_lp, ifcfg_rnmp)
+TunDevice::TunDevice(const char* dev_name, const char* dev_type, const char* ifcfg_lp, const char* ifcfg_rnmp) : conf_(dev_name, dev_type, ifcfg_lp, ifcfg_rnmp, 1400)
{
std::string device_file = "/dev/";
bool dynamic = true;
@@ -164,7 +164,7 @@ void TunDevice::init_post()
}
#else
- #error Target not supported
+ #error This Device works just for OpenBSD, FreeBSD or NetBSD
#endif
int TunDevice::fix_return(int ret, size_t type_length)
@@ -246,19 +246,29 @@ const char* TunDevice::getTypeString()
void TunDevice::do_ifconfig()
{
-// std::string command("/sbin/ifconfig ");
-// command.append(actual_name_);
-// command.append(" ");
-// command.append(conf_.local_.toString());
-// command.append(" ");
+ std::ostringstream command;
+ command << "/sbin/ifconfig " << actual_name_ << " " << conf_.local_.toString();
-// if(conf_.type_ == TYPE_TUN)
-// command.append("pointopoint ");
-// else
-// command.append("netmask ");
+ if(conf_.type_ == TYPE_TAP)
+ command << " netmask ";
+ else
+ command << " ";
+
+ command << conf_.remote_netmask_.toString() << " mtu " << conf_.mtu_;
-// command.append(conf_.remote_netmask_.toString());
-// command.append(" mtu 1400");
+ 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
+ }
-// system(command.c_str());
+ system(command.str().c_str());
}