diff options
author | Christian Pointner <equinox@anytun.org> | 2009-02-22 03:53:14 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2009-02-22 03:53:14 +0000 |
commit | 2fbd48f9f927dbd93974e8e6d985815331a12b15 (patch) | |
tree | 1dfd1cd14f1ab125d0ec114fefb089fa763cb0ca /src | |
parent | added extended logging capability (diff) |
fixed build on Windows (after logging chances)
Diffstat (limited to 'src')
-rw-r--r-- | src/anytun.cpp | 10 | ||||
-rw-r--r-- | src/anytun.suo | bin | 62464 -> 64000 bytes | |||
-rw-r--r-- | src/anytun.vcproj | 16 | ||||
-rw-r--r-- | src/logTargets.cpp | 24 | ||||
-rw-r--r-- | src/logTargets.h | 8 | ||||
-rw-r--r-- | src/win32/tunDevice.cpp | 2 |
6 files changed, 39 insertions, 21 deletions
diff --git a/src/anytun.cpp b/src/anytun.cpp index d954eae..1fb1fd8 100644 --- a/src/anytun.cpp +++ b/src/anytun.cpp @@ -362,8 +362,16 @@ int main(int argc, char* argv[]) { try { +#ifndef _MSC_VER cLog.addTarget("syslog:7,anytun,daemon"); - cLog.msg(Log::PRIO_DEBUG) << "anytun started..."; +#else + #ifdef WIN_SERVICE + cLog.addTarget("eventlog:7,anytun"); + #else + cLog.addTarget("stdout:7"); + #endif +#endif + cLog.msg(Log::PRIO_NOTICE) << "anytun started..."; /// std::cout << "anytun - secure anycast tunneling protocol" << std::endl; bool result = gOpt.parse(argc, argv); diff --git a/src/anytun.suo b/src/anytun.suo Binary files differindex 8b70223..05fc354 100644 --- a/src/anytun.suo +++ b/src/anytun.suo diff --git a/src/anytun.vcproj b/src/anytun.vcproj index 3b0727f..16cb37f 100644 --- a/src/anytun.vcproj +++ b/src/anytun.vcproj @@ -42,7 +42,7 @@ Name="VCCLCompilerTool"
AdditionalOptions="/I "C:\Program Files\boost\boost_1_35_0\""
Optimization="0"
- PreprocessorDefinitions="LOG_STDOUT;USE_SSL_CRYPTO;NO_DAEMON;NO_EXEC;NO_SIGNALCONTROLLER;WIN32_LEAN_AND_MEAN"
+ PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;USE_SSL_CRYPTO;NO_DAEMON;NO_EXEC;NO_SIGNALCONTROLLER;WIN32_LEAN_AND_MEAN"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -116,7 +116,7 @@ />
<Tool
Name="VCCLCompilerTool"
- PreprocessorDefinitions="USE_SSL_CRYPTO;NO_DAEMON;NO_EXEC;NO_SIGNALCONTROLLER;WIN32_LEAN_AND_MEAN"
+ PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;USE_SSL_CRYPTO;NO_DAEMON;NO_EXEC;NO_SIGNALCONTROLLER;WIN32_LEAN_AND_MEAN"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@@ -190,7 +190,7 @@ Name="VCCLCompilerTool"
AdditionalOptions="/I "C:\Program Files\boost\boost_1_35_0\""
Optimization="0"
- PreprocessorDefinitions="WIN_SERVICE;LOG_WINEVENTLOG;USE_SSL_CRYPTO;NO_DAEMON;NO_EXEC;NO_SIGNALCONTROLLER;WIN32_LEAN_AND_MEAN"
+ PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;USE_SSL_CRYPTO;NO_DAEMON;NO_EXEC;NO_SIGNALCONTROLLER;WIN32_LEAN_AND_MEAN"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -265,7 +265,7 @@ />
<Tool
Name="VCCLCompilerTool"
- PreprocessorDefinitions="WIN_SERVICE;LOG_EVENTLOG;USE_SSL_CRYPTO;NO_DAEMON;NO_EXEC;NO_SIGNALCONTROLLER;WIN32_LEAN_AND_MEAN"
+ PreprocessorDefinitions="LOG_FILE;LOG_STDOUT;LOG_WINEVENTLOG;WIN_SERVICE;USE_SSL_CRYPTO;NO_DAEMON;NO_EXEC;NO_SIGNALCONTROLLER;WIN32_LEAN_AND_MEAN"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@@ -389,6 +389,10 @@ >
</File>
<File
+ RelativePath=".\logTargets.h"
+ >
+ </File>
+ <File
RelativePath=".\networkAddress.h"
>
</File>
@@ -541,6 +545,10 @@ >
</File>
<File
+ RelativePath=".\logTargets.cpp"
+ >
+ </File>
+ <File
RelativePath=".\networkAddress.cpp"
>
</File>
diff --git a/src/logTargets.cpp b/src/logTargets.cpp index 82bb6fd..ac41c0b 100644 --- a/src/logTargets.cpp +++ b/src/logTargets.cpp @@ -141,7 +141,7 @@ LogTarget* LogTargetList::add(target_type_t type, int prio, std::string conf) } case TARGET_WINEVENTLOG: { #ifdef LOG_WINEVENTLOG - if(!LogTargetSyslog::duplicateAllowed() && targets.count(TARGET_WINEVENTLOG)) + if(!LogTargetWinEventlog::duplicateAllowed() && targets.count(TARGET_WINEVENTLOG)) throw std::runtime_error(targetTypeToString(TARGET_WINEVENTLOG) + " logtarget is supported only once"); return targets.insert(TargetsMap::value_type(TARGET_WINEVENTLOG, new LogTargetWinEventlog(prio, conf)))->second; @@ -403,11 +403,11 @@ void LogTargetWinEventlog::log(std::string msg, int prio) CHAR buffer[STERROR_TEXT_MAX]; StringCchPrintfA(buffer, STERROR_TEXT_MAX, "%s", msg.c_str()); lpszStrings[0] = buffer; - if(log.h_event_source) - ReportEventA(log.h_event_source_, Log::prioToEventLogType(prio), 0, prio, NULL, 1, 0, lpszStrings, NULL); + if(h_event_source) + ReportEventA(h_event_source, prioToEventLogType(prio), 0, prio, NULL, 1, 0, lpszStrings, NULL); } -LogTargetEventlog& LogTargetWinEventlog::setLogName(std::string l) +LogTargetWinEventlog& LogTargetWinEventlog::setLogName(std::string l) { logname = l; if(opened) @@ -419,14 +419,14 @@ LogTargetEventlog& LogTargetWinEventlog::setLogName(std::string l) WORD LogTargetWinEventlog::prioToEventLogType(int prio) { switch(prio) { - case PRIO_EMERG: return EVENTLOG_ERROR_TYPE; - case PRIO_ALERT: return EVENTLOG_ERROR_TYPE; - case PRIO_CRIT: return EVENTLOG_ERROR_TYPE; - case PRIO_ERR: return EVENTLOG_ERROR_TYPE; - case PRIO_WARNING: return EVENTLOG_WARNING_TYPE; - case PRIO_NOTICE: return EVENTLOG_INFORMATION_TYPE; - case PRIO_INFO: return EVENTLOG_SUCCESS; - case PRIO_DEBUG: return EVENTLOG_INFORMATION_TYPE; + case Log::PRIO_EMERG: return EVENTLOG_ERROR_TYPE; + case Log::PRIO_ALERT: return EVENTLOG_ERROR_TYPE; + case Log::PRIO_CRIT: return EVENTLOG_ERROR_TYPE; + case Log::PRIO_ERR: return EVENTLOG_ERROR_TYPE; + case Log::PRIO_WARNING: return EVENTLOG_WARNING_TYPE; + case Log::PRIO_NOTICE: return EVENTLOG_INFORMATION_TYPE; + case Log::PRIO_INFO: return EVENTLOG_SUCCESS; + case Log::PRIO_DEBUG: return EVENTLOG_INFORMATION_TYPE; default: return EVENTLOG_ERROR_TYPE; } } diff --git a/src/logTargets.h b/src/logTargets.h index 4f249d4..a7e9b60 100644 --- a/src/logTargets.h +++ b/src/logTargets.h @@ -43,6 +43,8 @@ #include <fstream> #endif +#include "datatypes.h" + class LogTarget { public: @@ -178,6 +180,8 @@ private: class LogTargetWinEventlog : public LogTarget { public: + static WORD prioToEventLogType(int prio); + LogTargetWinEventlog(int prio, std::string conf); ~LogTargetWinEventlog(); @@ -187,11 +191,9 @@ public: static bool duplicateAllowed() { return false; }; LogTargetWinEventlog& setLogName(std::string l); - std::string getLogName() const { return logname; } + std::string getLogName() const { return logname; }; private: - static WORD prioToEventLogType(int prio); - std::string logname; HANDLE h_event_source; }; diff --git a/src/win32/tunDevice.cpp b/src/win32/tunDevice.cpp index 538269e..9d95b30 100644 --- a/src/win32/tunDevice.cpp +++ b/src/win32/tunDevice.cpp @@ -277,7 +277,7 @@ void TunDevice::do_ifconfig() } u_long mtu; - err = performIoControl(TAP_IOCTL_CONFIG_DHCP_MASQ, &mtu, sizeof(mtu), &mtu, sizeof(mtu)); + err = performIoControl(TAP_IOCTL_GET_MTU, &mtu, sizeof(mtu), &mtu, sizeof(mtu)); if(err != ERROR_SUCCESS) { CloseHandle(handle_); std::stringstream msg; |