summaryrefslogtreecommitdiff
path: root/src/linux/tunDevice.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-02-22 06:38:56 +0000
committerChristian Pointner <equinox@anytun.org>2009-02-22 06:38:56 +0000
commitaee185758d5a494dd5a5b6349d1a82febb30dca0 (patch)
treef051438fb9916af1d0e7d5c5f4fb35bd54dbd835 /src/linux/tunDevice.cpp
parentadded signal controller (console control handler) to windows (diff)
fixed signalController on unix
added anytunError
Diffstat (limited to 'src/linux/tunDevice.cpp')
-rw-r--r--src/linux/tunDevice.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/linux/tunDevice.cpp b/src/linux/tunDevice.cpp
index 8ab7ff8..7c7e8ff 100644
--- a/src/linux/tunDevice.cpp
+++ b/src/linux/tunDevice.cpp
@@ -45,6 +45,7 @@
#include "tunDevice.h"
#include "threadUtils.hpp"
#include "log.h"
+#include "anytunError.hpp"
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)
{
@@ -60,17 +61,14 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc
with_pi_ = false;
}
else
- throw std::runtime_error("unable to recognize type of device (tun or tap)");
+ AnytunError::throwErr() << "unable to recognize type of device (tun or tap)";
if(dev_name != "")
strncpy(ifr.ifr_name, dev_name.c_str(), IFNAMSIZ);
fd_ = ::open(DEFAULT_DEVICE, O_RDWR);
- if(fd_ < 0) {
- std::stringstream msg;
- msg << "can't open device file (" << DEFAULT_DEVICE << "): " << LogErrno(errno);
- throw std::runtime_error(msg.str());
- }
+ if(fd_ < 0)
+ AnytunError::throwErr() << "can't open device file (" << DEFAULT_DEVICE << "): " << LogErrno(errno);
if(!ioctl(fd_, TUNSETIFF, &ifr)) {
actual_name_ = ifr.ifr_name;
@@ -78,9 +76,7 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc
actual_name_ = ifr.ifr_name;
} else {
::close(fd_);
- std::stringstream msg;
- msg << "tun/tap device ioctl failed: " << LogErrno(errno);
- throw std::runtime_error(msg.str());
+ AnytunError::throwErr() << "tun/tap device ioctl failed: " << LogErrno(errno);
}
actual_node_ = DEFAULT_DEVICE;