summaryrefslogtreecommitdiff
path: root/src/linux
diff options
context:
space:
mode:
Diffstat (limited to 'src/linux')
-rw-r--r--src/linux/tunDevice.cpp31
-rw-r--r--src/linux/tunDevice.h65
2 files changed, 6 insertions, 90 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()
diff --git a/src/linux/tunDevice.h b/src/linux/tunDevice.h
deleted file mode 100644
index 05457b0..0000000
--- a/src/linux/tunDevice.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * anytun
- *
- * The secure anycast tunneling protocol (satp) defines a protocol used
- * for communication between any combination of unicast and anycast
- * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel
- * mode and allows tunneling of every ETHER TYPE protocol (e.g.
- * ethernet, ip, arp ...). satp directly includes cryptography and
- * message authentication based on the methodes used by SRTP. It is
- * intended to deliver a generic, scaleable and secure solution for
- * tunneling and relaying of packets of any protocol.
- *
- *
- * Copyright (C) 2007-2008 Othmar Gsenger, Erwin Nindl,
- * Christian Pointner <satp@wirdorange.org>
- *
- * 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.
- *
- * Anytun is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with anytun. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _TUNDEVICE_H_
-#define _TUNDEVICE_H_
-
-#include "buffer.h"
-#include "deviceConfig.hpp"
-#include "threadUtils.hpp"
-
-class TunDevice
-{
-public:
- TunDevice(const char* dev,const char* dev_type, const char* ifcfg_lp, const char* ifcfg_rnmp);
- ~TunDevice();
-
- int read(u_int8_t* buf, u_int32_t len);
- int write(u_int8_t* buf, u_int32_t len);
-
- const char* getActualName();
- device_type_t getType();
- const char* getTypeString();
-
-private:
- void operator=(const TunDevice &src);
- TunDevice(const TunDevice &src);
-
- void do_ifconfig();
- int fix_return(int ret, size_t pi_length);
-
- int fd_;
- DeviceConfig conf_;
- bool with_pi_;
- std::string actual_name_;
-};
-
-#endif