make NetworkInterface working under XP
on >= Vista NetworkInterface works, but if you try under XP you have ifIndex always not setted: if you compile with XP SP1 defines you get code working on >=XP
This commit is contained in:
Родитель
9bf743d4ac
Коммит
63b74d4f93
|
@ -1097,6 +1097,8 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||||
ifIndex = pAddress->Ipv6IfIndex;
|
ifIndex = pAddress->Ipv6IfIndex;
|
||||||
#elif (_WIN32_WINNT >= 0x0501) && (NTDDI_VERSION >= 0x05010100) // Win XP SP1
|
#elif (_WIN32_WINNT >= 0x0501) && (NTDDI_VERSION >= 0x05010100) // Win XP SP1
|
||||||
#if defined (IP_ADAPTER_IPV6_ENABLED) // Vista
|
#if defined (IP_ADAPTER_IPV6_ENABLED) // Vista
|
||||||
|
if(osvi.dwMajorVersion>=6)//vista
|
||||||
|
{
|
||||||
if ((pAddress->Flags & IP_ADAPTER_IPV6_ENABLED) &&
|
if ((pAddress->Flags & IP_ADAPTER_IPV6_ENABLED) &&
|
||||||
(osvi.dwMajorVersion >= 5) &&
|
(osvi.dwMajorVersion >= 5) &&
|
||||||
(osvi.dwMinorVersion >= 1) &&
|
(osvi.dwMinorVersion >= 1) &&
|
||||||
|
@ -1104,6 +1106,14 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||||
{
|
{
|
||||||
ifIndex = pAddress->Ipv6IfIndex;
|
ifIndex = pAddress->Ipv6IfIndex;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if ((osvi.dwMajorVersion >= 5) &&
|
||||||
|
(osvi.dwMinorVersion >= 1) &&
|
||||||
|
(osvi.dwBuildNumber >= 1))
|
||||||
|
{
|
||||||
|
ifIndex = pAddress->Ipv6IfIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
#else // !defined(IP_ADAPTER_IPV6_ENABLED)
|
#else // !defined(IP_ADAPTER_IPV6_ENABLED)
|
||||||
if ((osvi.dwMajorVersion >= 5) &&
|
if ((osvi.dwMajorVersion >= 5) &&
|
||||||
(osvi.dwMinorVersion >= 1) &&
|
(osvi.dwMinorVersion >= 1) &&
|
||||||
|
@ -1116,10 +1126,17 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||||
#endif // POCO_HAVE_IPv6
|
#endif // POCO_HAVE_IPv6
|
||||||
|
|
||||||
#if defined (IP_ADAPTER_IPV4_ENABLED)
|
#if defined (IP_ADAPTER_IPV4_ENABLED)
|
||||||
|
if(osvi.dwMajorVersion>=6)
|
||||||
|
{//vista
|
||||||
if (pAddress->Flags & IP_ADAPTER_IPV4_ENABLED)
|
if (pAddress->Flags & IP_ADAPTER_IPV4_ENABLED)
|
||||||
{
|
{
|
||||||
ifIndex = pAddress->IfIndex;
|
ifIndex = pAddress->IfIndex;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ifIndex = pAddress->IfIndex;
|
||||||
|
}
|
||||||
#else // !IP_ADAPTER_IPV4_ENABLED
|
#else // !IP_ADAPTER_IPV4_ENABLED
|
||||||
ifIndex = pAddress->IfIndex;
|
ifIndex = pAddress->IfIndex;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1205,8 +1222,15 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||||
#elif (_WIN32_WINNT >= 0x0501) && (NTDDI_VERSION >= 0x05010100) // Win XP SP1
|
#elif (_WIN32_WINNT >= 0x0501) && (NTDDI_VERSION >= 0x05010100) // Win XP SP1
|
||||||
ULONG prefixLength = 0;
|
ULONG prefixLength = 0;
|
||||||
#if (_WIN32_WINNT >= 0x0600) // Vista and newer
|
#if (_WIN32_WINNT >= 0x0600) // Vista and newer
|
||||||
|
if (osvi.dwMajorVersion >= 6)
|
||||||
|
{
|
||||||
prefixLength = pUniAddr->OnLinkPrefixLength;
|
prefixLength = pUniAddr->OnLinkPrefixLength;
|
||||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address);
|
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address, &prefixLength);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address, &prefixLength);
|
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address, &prefixLength);
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче