summaryrefslogtreecommitdiff
path: root/src/linux/tunDevice.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-10-04 18:42:37 +0000
committerChristian Pointner <equinox@anytun.org>2009-10-04 18:42:37 +0000
commitd9dad6eee3cdca8aade318d4e91ee1aa3d79d3f6 (patch)
tree3ba7301530710d97d1d980ae6782273a7e002cc1 /src/linux/tunDevice.cpp
parentcleaned new exec script function (diff)
got rid of remaining system()
Diffstat (limited to 'src/linux/tunDevice.cpp')
-rw-r--r--src/linux/tunDevice.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/linux/tunDevice.cpp b/src/linux/tunDevice.cpp
index b34ae9d..d9019e0 100644
--- a/src/linux/tunDevice.cpp
+++ b/src/linux/tunDevice.cpp
@@ -31,6 +31,7 @@
#include <string.h>
#include <sstream>
+#include <boost/assign.hpp>
#include <fcntl.h>
#include <sys/ioctl.h>
@@ -46,6 +47,7 @@
#include "threadUtils.hpp"
#include "log.h"
#include "anytunError.h"
+#include "sysExec.h"
TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifcfg_addr, u_int16_t ifcfg_prefix) : conf_(dev_name, dev_type, ifcfg_addr, ifcfg_prefix, 1400)
{
@@ -155,19 +157,8 @@ void TunDevice::init_post()
void TunDevice::do_ifconfig()
{
- std::ostringstream command;
- command << "/sbin/ifconfig " << actual_name_ << " " << conf_.addr_.toString()
- << " netmask " << conf_.netmask_.toString() << " mtu " << conf_.mtu_;
-
- int result = system(command.str().c_str());
- if(result == -1)
- cLog.msg(Log::PRIO_ERROR) << "Execution of ifconfig failed: " << AnytunErrno(errno);
- else {
- if(WIFEXITED(result))
- cLog.msg(Log::PRIO_NOTICE) << "ifconfig returned " << WEXITSTATUS(result);
- else if(WIFSIGNALED(result))
- cLog.msg(Log::PRIO_NOTICE) << "ifconfig terminated after signal " << WTERMSIG(result);
- else
- cLog.msg(Log::PRIO_ERROR) << "Execution of ifconfig: unkown error";
- }
+ std::ostringstream mtu_ss;
+ mtu_ss << conf_.mtu_;
+ StringVector args = boost::assign::list_of(actual_name_)(conf_.addr_.toString())("netmask")(conf_.netmask_.toString())("mtu")(mtu_ss.str());
+ anytun_exec("/sbin/ifconfig", args);
}