X-Git-Url: https://git.syn-net.org/debian/?a=blobdiff_plain;f=src%2Flinux%2FtunDevice.cpp;h=57b1c7c5c11fb91f524b653716093eaf76411a66;hb=7af29a758723cc25f12f46de0e54bae7ccd3be50;hp=b34ae9db46849fe666608904fe9de9fec7b86307;hpb=058ae090a970436caec3b3059e9e18b310dd6b0d;p=anytun.git diff --git a/src/linux/tunDevice.cpp b/src/linux/tunDevice.cpp index b34ae9d..57b1c7c 100644 --- a/src/linux/tunDevice.cpp +++ b/src/linux/tunDevice.cpp @@ -11,14 +11,15 @@ * tunneling and relaying of packets of any protocol. * * - * Copyright (C) 2007-2008 Othmar Gsenger, Erwin Nindl, + * Copyright (C) 2007-2009 Othmar Gsenger, Erwin Nindl, * Christian Pointner * * This file is part of Anytun. * * Anytun is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. * * Anytun is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -31,6 +32,7 @@ #include #include +#include #include #include @@ -46,6 +48,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 +158,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); }