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,12 +1097,22 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
|||
ifIndex = pAddress->Ipv6IfIndex;
|
||||
#elif (_WIN32_WINNT >= 0x0501) && (NTDDI_VERSION >= 0x05010100) // Win XP SP1
|
||||
#if defined (IP_ADAPTER_IPV6_ENABLED) // Vista
|
||||
if ((pAddress->Flags & IP_ADAPTER_IPV6_ENABLED) &&
|
||||
(osvi.dwMajorVersion >= 5) &&
|
||||
(osvi.dwMinorVersion >= 1) &&
|
||||
(osvi.dwBuildNumber >=1))
|
||||
if(osvi.dwMajorVersion>=6)//vista
|
||||
{
|
||||
ifIndex = pAddress->Ipv6IfIndex;
|
||||
if ((pAddress->Flags & IP_ADAPTER_IPV6_ENABLED) &&
|
||||
(osvi.dwMajorVersion >= 5) &&
|
||||
(osvi.dwMinorVersion >= 1) &&
|
||||
(osvi.dwBuildNumber >=1))
|
||||
{
|
||||
ifIndex = pAddress->Ipv6IfIndex;
|
||||
}
|
||||
}
|
||||
else if ((osvi.dwMajorVersion >= 5) &&
|
||||
(osvi.dwMinorVersion >= 1) &&
|
||||
(osvi.dwBuildNumber >= 1))
|
||||
{
|
||||
ifIndex = pAddress->Ipv6IfIndex;
|
||||
}
|
||||
}
|
||||
#else // !defined(IP_ADAPTER_IPV6_ENABLED)
|
||||
if ((osvi.dwMajorVersion >= 5) &&
|
||||
|
@ -1116,7 +1126,14 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
|||
#endif // POCO_HAVE_IPv6
|
||||
|
||||
#if defined (IP_ADAPTER_IPV4_ENABLED)
|
||||
if (pAddress->Flags & IP_ADAPTER_IPV4_ENABLED)
|
||||
if(osvi.dwMajorVersion>=6)
|
||||
{//vista
|
||||
if (pAddress->Flags & IP_ADAPTER_IPV4_ENABLED)
|
||||
{
|
||||
ifIndex = pAddress->IfIndex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ifIndex = pAddress->IfIndex;
|
||||
}
|
||||
|
@ -1205,8 +1222,15 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
|||
#elif (_WIN32_WINNT >= 0x0501) && (NTDDI_VERSION >= 0x05010100) // Win XP SP1
|
||||
ULONG prefixLength = 0;
|
||||
#if (_WIN32_WINNT >= 0x0600) // Vista and newer
|
||||
prefixLength = pUniAddr->OnLinkPrefixLength;
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address);
|
||||
if (osvi.dwMajorVersion >= 6)
|
||||
{
|
||||
prefixLength = pUniAddr->OnLinkPrefixLength;
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address);
|
||||
}
|
||||
else
|
||||
{
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address, &prefixLength);
|
||||
}
|
||||
#else
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address, &prefixLength);
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче