diff options
author | Christian Pointner <equinox@anytun.org> | 2009-01-20 13:21:53 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2009-01-20 13:21:53 +0000 |
commit | 765b3fc896c38feebd5c5b9ddc63a613fe533054 (patch) | |
tree | 7d437440f1642889252b5adf1ebf6d98b7eebe89 | |
parent | recv also throws runtime error on windows when an icmp unreachable message ar... (diff) |
added actual node to tundevice (currently only for windows)
-rw-r--r-- | src/anytun.cpp | 3 | ||||
-rw-r--r-- | src/tunDevice.h | 2 | ||||
-rw-r--r-- | src/win32/tunDevice.cpp | 9 |
3 files changed, 9 insertions, 5 deletions
diff --git a/src/anytun.cpp b/src/anytun.cpp index b938604..b33ddcd 100644 --- a/src/anytun.cpp +++ b/src/anytun.cpp @@ -363,8 +363,7 @@ int main(int argc, char* argv[]) #endif TunDevice dev(gOpt.getDevName(), gOpt.getDevType(), gOpt.getIfconfigParamLocal(), gOpt.getIfconfigParamRemoteNetmask()); - cLog.msg(Log::PRIO_NOTICE) << "dev created (opened)"; - cLog.msg(Log::PRIO_NOTICE) << "dev opened - actual name is '" << dev.getActualName() << "'"; + cLog.msg(Log::PRIO_NOTICE) << "dev opened - name '" << dev.getActualName() << "', node '" << dev.getActualNode() << "'"; cLog.msg(Log::PRIO_NOTICE) << "dev type is '" << dev.getTypeString() << "'"; #ifndef NO_EXEC if(gOpt.getPostUpScript() != "") { diff --git a/src/tunDevice.h b/src/tunDevice.h index a5e0a09..d680662 100644 --- a/src/tunDevice.h +++ b/src/tunDevice.h @@ -50,6 +50,7 @@ public: int write(u_int8_t* buf, u_int32_t len); std::string getActualName() { return actual_name_; } + std::string getActualNode() { return actual_node_; } device_type_t getType() { return conf_.type_; } std::string getTypeString() { @@ -88,6 +89,7 @@ private: DeviceConfig conf_; bool with_pi_; std::string actual_name_; + std::string actual_node_; }; #endif diff --git a/src/win32/tunDevice.cpp b/src/win32/tunDevice.cpp index 70aa4a4..82e31cb 100644 --- a/src/win32/tunDevice.cpp +++ b/src/win32/tunDevice.cpp @@ -40,6 +40,8 @@ #include <windows.h> #include <winioctl.h> +#define REG_STRING_LENGTH 1024 + 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) { handle_ = INVALID_HANDLE_VALUE; @@ -56,8 +58,8 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc bool found = false; DWORD len; - char adapterid[1024]; - char adaptername[1024]; + char adapterid[REG_STRING_LENGTH]; + char adaptername[REG_STRING_LENGTH]; for(int i=0; ; ++i) { len = sizeof(adapterid); if(RegEnumKeyEx(key, i, adapterid, &len, 0, 0, 0, NULL)) @@ -98,7 +100,8 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc } conf_.type_ = TYPE_TAP; - actual_name_ = adapterid; + actual_node_ = adapterid; + actual_name_ = adaptername; int status = true; if(!DeviceIoControl(handle_, TAP_IOCTL_SET_MEDIA_STATUS, &status, sizeof(status), &status, sizeof(status), &len, NULL)) { |