mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-24 00:49:46 +02:00
Route on Windows
Route on Windows tentatively complete, Mac/Linux TODO
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user