diff options
author | Christian Pointner <equinox@anytun.org> | 2009-01-15 16:28:12 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2009-01-15 16:28:12 +0000 |
commit | 1c5626cd8a3dd28d7d09e01d6d3b95f49f10e421 (patch) | |
tree | e251b16e72d99ea7696d222c24fb13fd13812890 /src/bsd | |
parent | improved Makefile (clean now for -j *) (diff) |
log class can now easily use errno and gpg_err
Diffstat (limited to 'src/bsd')
-rw-r--r-- | src/bsd/tunDevice.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/bsd/tunDevice.cpp b/src/bsd/tunDevice.cpp index 31e986c..ce2a413 100644 --- a/src/bsd/tunDevice.cpp +++ b/src/bsd/tunDevice.cpp @@ -46,10 +46,9 @@ #include "tunDevice.h" #include "threadUtils.hpp" +#include "log.h" #define DEVICE_FILE_MAX 255 -#include <iostream> - TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifcfg_lp, std::string ifcfg_rnmp) : conf_(dev_name, dev_type, ifcfg_lp, ifcfg_rnmp, 1400) { std::string device_file = "/dev/"; @@ -84,19 +83,12 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc fd_ = ::open(device_file.c_str(), O_RDWR); if(fd_ < 0) { - std::string msg; + std::stringstream msg; if(dynamic) - msg = "can't open device file dynamically: no unused node left"; - else { - msg = "can't open device file ("; - msg.append(device_file); - msg.append("): "); - char buf[STERROR_TEXT_MAX]; - buf[0] = 0; - strerror_r(errno, buf, STERROR_TEXT_MAX); - msg.append(buf); - } - throw std::runtime_error(msg); + msg << "can't open device file dynamically: no unused node left"; + else + msg << "can't open device file (" << device_file << "): " << LogErrno(errno); + throw std::runtime_error(msg.str()); } if(dynamic) { |