Route on Windows

Route on Windows tentatively complete, Mac/Linux TODO
This commit is contained in:
aleks-f
2012-11-06 22:17:17 -06:00
parent 325a98a91f
commit 15d27daea6
8 changed files with 1563 additions and 1343 deletions

View File

@@ -43,6 +43,7 @@
#if defined(POCO_OS_FAMILY_WINDOWS)
#if defined(POCO_WIN32_UTF8)
#include "Poco/UnicodeConverter.h"
#include "Poco/Error.h"
#endif
#include <iphlpapi.h>
#include <ipifcons.h>
@@ -892,24 +893,6 @@ IPAddress getBroadcastAddress(PIP_ADAPTER_PREFIX pPrefix, const IPAddress& addr,
}
std::string getErrorMessage(DWORD errorCode)
{
std::string errMsg;
DWORD dwFlg = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
LPWSTR lpMsgBuf = 0;
if (FormatMessageW(dwFlg, 0, errorCode, 0, (LPWSTR) & lpMsgBuf, 0, NULL))
UnicodeConverter::toUTF8(lpMsgBuf, errMsg);
#else
LPTSTR lpMsgBuf = 0;
if (FormatMessageA(dwFlg, 0, errorCode, 0, (LPTSTR) & lpMsgBuf, 0, NULL))
errMsg = lpMsgBuf;
#endif
LocalFree(lpMsgBuf);
return errMsg;
}
NetworkInterface::Type fromNative(DWORD type)
{
switch (type)
@@ -957,7 +940,7 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
else if (ERROR_NO_DATA == dwRetVal) // no network interfaces found
return result;
else if (NO_ERROR != dwRetVal) // error occurred
throw SystemException(format("An error occurred while trying to obtain list of network interfaces: [%s]", getErrorMessage(dwRetVal)));
throw SystemException(format("An error occurred while trying to obtain list of network interfaces: [%s]", Error::getMessage(dwRetVal)));
else
break;
} while ((ERROR_BUFFER_OVERFLOW == dwRetVal) && (++iterations <= 2));