diff options
-rw-r--r-- | src/deviceConfig.hpp | 11 | ||||
-rw-r--r-- | src/linux/tunDevice.cpp | 6 | ||||
-rw-r--r-- | src/ovpn/tunDevice.h | 4 |
3 files changed, 10 insertions, 11 deletions
diff --git a/src/deviceConfig.hpp b/src/deviceConfig.hpp index 22fb5d8..efec0bb 100644 --- a/src/deviceConfig.hpp +++ b/src/deviceConfig.hpp @@ -40,6 +40,12 @@ class DeviceConfig public: DeviceConfig(const char* dev_name ,const char* dev_type, const char* ifcfg_lp, const char* ifcfg_rnmp) { + guess_type(dev_name, dev_type); + } + +private: + void guess_type(const char* dev_name, const char* dev_type) + { type_ = TYPE_UNDEF; if(dev_type) { if(!strncmp(dev_type, "tun", 3)) @@ -47,17 +53,14 @@ public: else if(!strncmp(dev_type, "tap", 3)) type_ = TYPE_TAP; } - else if(dev_name) - { + else if(dev_name) { if(!strncmp(dev_name, "tun", 3)) type_ = TYPE_TUN; else if(!strncmp(dev_name, "tap", 3)) type_ = TYPE_TAP; } - } -private: device_type_t type_; friend class TunDevice; diff --git a/src/linux/tunDevice.cpp b/src/linux/tunDevice.cpp index 24bad02..446df4f 100644 --- a/src/linux/tunDevice.cpp +++ b/src/linux/tunDevice.cpp @@ -117,10 +117,10 @@ int TunDevice::write(u_int8_t* buf, u_int32_t len) struct iphdr *hdr = reinterpret_cast<struct iphdr *>(buf); tpi.flags = 0; - if(hdr->version == 6) - tpi.proto = htons(ETH_P_IPV6); - else + if(hdr->version == 4) tpi.proto = htons(ETH_P_IP); + else + tpi.proto = htons(ETH_P_IPV6); iov[0].iov_base = &tpi; iov[0].iov_len = sizeof(tpi); diff --git a/src/ovpn/tunDevice.h b/src/ovpn/tunDevice.h index ba41cce..5886b7d 100644 --- a/src/ovpn/tunDevice.h +++ b/src/ovpn/tunDevice.h @@ -38,10 +38,6 @@ class TunDevice { public: - static const u_int32_t TYPE_UNDEF = 0; - static const u_int32_t TYPE_TUN = 1; - static const u_int32_t TYPE_TAP = 2; - TunDevice(const char* dev,const char* dev_type, const char* ifcfg_lp, const char* ifcfg_rnmp); ~TunDevice(); |