summaryrefslogtreecommitdiff
path: root/src/linux/tunDevice.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2008-11-26 10:47:14 +0000
committerChristian Pointner <equinox@anytun.org>2008-11-26 10:47:14 +0000
commitf5afa7efbc1ff915e733e8d1474777de80534345 (patch)
tree0e698a8e0ce8792f58f6d965d58334c26621b20c /src/linux/tunDevice.cpp
parentanyrtpproxy: options parser support ipv6 now (diff)
cleaned tunDevice code
Diffstat (limited to 'src/linux/tunDevice.cpp')
-rw-r--r--src/linux/tunDevice.cpp31
1 files changed, 6 insertions, 25 deletions
diff --git a/src/linux/tunDevice.cpp b/src/linux/tunDevice.cpp
index 4a61432..c743229 100644
--- a/src/linux/tunDevice.cpp
+++ b/src/linux/tunDevice.cpp
@@ -46,7 +46,7 @@
#include "threadUtils.hpp"
-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)
+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)
{
fd_ = ::open(DEFAULT_DEVICE, O_RDWR);
if(fd_ < 0) {
@@ -74,8 +74,8 @@ TunDevice::TunDevice(const char* dev_name, const char* dev_type, const char* ifc
else
throw std::runtime_error("unable to recognize type of device (tun or tap)");
- if(dev_name)
- strncpy(ifr.ifr_name, dev_name, IFNAMSIZ);
+ if(dev_name != "")
+ strncpy(ifr.ifr_name, dev_name.c_str(), IFNAMSIZ);
if(!ioctl(fd_, TUNSETIFF, &ifr)) {
actual_name_ = ifr.ifr_name;
@@ -90,7 +90,7 @@ TunDevice::TunDevice(const char* dev_name, const char* dev_type, const char* ifc
throw std::runtime_error(msg);
}
- if(ifcfg_lp && ifcfg_rnmp)
+ if(ifcfg_lp != "" && ifcfg_rnmp != "")
do_ifconfig();
}
@@ -155,28 +155,9 @@ int TunDevice::write(u_int8_t* buf, u_int32_t len)
return(::write(fd_, buf, len));
}
-const char* TunDevice::getActualName()
+void TunDevice::init_post()
{
- return actual_name_.c_str();
-}
-
-device_type_t TunDevice::getType()
-{
- return conf_.type_;
-}
-
-const char* TunDevice::getTypeString()
-{
- if(fd_ < 0)
- return NULL;
-
- switch(conf_.type_)
- {
- case TYPE_UNDEF: return "undef"; break;
- case TYPE_TUN: return "tun"; break;
- case TYPE_TAP: return "tap"; break;
- }
- return NULL;
+// nothing to be done here
}
void TunDevice::do_ifconfig()