Reactos

[IPHLPAPI_WINETEST][IPHLPAPI] Sync iphlpapi_winetest to wine-10.0 (#8309)

- [IPHLPAPI_WINETEST] Sync to wine-10.0
- [IPHLPAPI] Add stubs for Vista+ functions so these functions can link properly when DLL_EXPORT_VERSION >= 0x600

authored by

Carl J. Bialorucki and committed by
GitHub
fe497a2b 70406e0c

+2585 -1031
+26
dll/win32/iphlpapi/iphlpapi.spec
··· 12 12 @ stdcall AllocateAndGetUdpTableFromStack(ptr long long long) 13 13 @ stdcall CancelIPChangeNotify(ptr) 14 14 @ stub CancelSecurityHealthChangeNotify 15 + @ stdcall -stub -version=0x600+ ConvertGuidToStringA(ptr ptr long) 16 + @ stdcall -stub -version=0x600+ ConvertGuidToStringW(ptr ptr long) 17 + @ stdcall -stub -version=0x600+ ConvertInterfaceAliasToLuid(wstr ptr) 18 + @ stdcall -stub -version=0x600+ ConvertInterfaceGuidToLuid(ptr ptr) 19 + @ stdcall -stub -version=0x600+ ConvertInterfaceIndexToLuid(long ptr) 20 + @ stdcall -stub -version=0x600+ ConvertInterfaceLuidToAlias(ptr ptr long) 21 + @ stdcall -stub -version=0x600+ ConvertInterfaceLuidToGuid(ptr ptr) 22 + @ stdcall -stub -version=0x600+ ConvertInterfaceLuidToIndex(ptr ptr) 23 + @ stdcall -stub -version=0x600+ ConvertInterfaceLuidToNameA(ptr ptr long) 24 + @ stdcall -stub -version=0x600+ ConvertInterfaceLuidToNameW(ptr ptr long) 25 + @ stdcall -stub -version=0x600+ ConvertInterfaceNameToLuidA(str ptr) 26 + @ stdcall -stub -version=0x600+ ConvertInterfaceNameToLuidW(wstr ptr) 27 + @ stdcall -stub -version=0x600+ ConvertLengthToIpv4Mask(long ptr) 28 + @ stdcall -stub -version=0x600+ ConvertStringToGuidW(wstr ptr) 15 29 @ stdcall CreateIpForwardEntry(ptr) 16 30 @ stdcall CreateIpNetEntry(ptr) 17 31 @ stdcall CreateProxyArpEntry(long long long) ··· 23 37 @ stdcall EnableRouter(ptr ptr) 24 38 @ stdcall FlushIpNetTable(long) 25 39 @ stub FlushIpNetTableFromStack 40 + @ stdcall -stub -version=0x600+ FreeMibTable(ptr) 26 41 @ stdcall GetAdapterIndex(wstr ptr) 27 42 @ stdcall GetAdapterOrderMap() 28 43 @ stdcall GetAdaptersAddresses(long long ptr ptr ptr) ··· 32 47 @ stub GetBestInterfaceFromStack 33 48 @ stdcall GetBestRoute(long long long) 34 49 @ stub GetBestRouteFromStack 50 + @ stdcall -stub -version=0x600+ GetCurrentThreadCompartmentId() 35 51 @ stdcall GetExtendedTcpTable(ptr ptr long long long long) 36 52 @ stdcall GetExtendedUdpTable(ptr ptr long long long long) 37 53 @ stdcall GetFriendlyIfIndex(long) ··· 40 56 @ stub GetIcmpStatsFromStack 41 57 @ stub GetIcmpStatsFromStackEx 42 58 @ stdcall GetIfEntry(ptr) 59 + @ stdcall -stub -version=0x600+ GetIfEntry2(ptr) 60 + @ stdcall -stub -version=0xA00+ GetIfEntry2Ex(long ptr) 43 61 @ stub GetIfEntryFromStack 44 62 @ stdcall GetIfTable(ptr ptr long) 63 + @ stdcall -stub -version=0x600+ GetIfTable2(ptr) 64 + @ stdcall -stub -version=0x600+ GetIfTable2Ex(long ptr) 45 65 @ stub GetIfTableFromStack 46 66 @ stub GetIgmpList 47 67 @ stdcall GetInterfaceInfo(ptr ptr) ··· 49 69 @ stub GetIpAddrTableFromStack 50 70 @ stdcall GetIpErrorString(long ptr ptr) 51 71 @ stdcall GetIpForwardTable(ptr ptr long) 72 + @ stdcall -stub -version=0x600+ GetIpForwardTable2(long ptr) 52 73 @ stub GetIpForwardTableFromStack 53 74 @ stdcall GetIpNetTable(ptr ptr long) 75 + @ stdcall -stub -version=0x600+ GetIpNetTable2(long ptr) 54 76 @ stub GetIpNetTableFromStack 55 77 @ stdcall GetIpStatistics(ptr) 56 78 @ stdcall GetIpStatisticsEx(ptr long) ··· 78 100 @ stub GetUdpStatsFromStackEx 79 101 @ stdcall GetUdpTable(ptr ptr long) 80 102 @ stub GetUdpTableFromStack 103 + @ stdcall -stub -version=0x600+ GetUnicastIpAddressEntry(ptr) 104 + @ stdcall -stub -version=0x600+ GetUnicastIpAddressTable(long ptr) 81 105 @ stdcall GetUniDirectionalAdapterInfo(ptr ptr) 82 106 @ stdcall Icmp6CreateFile() 83 107 @ stdcall Icmp6ParseReplies(ptr long) ··· 87 111 @ stdcall IcmpParseReplies(ptr long) 88 112 @ stdcall IcmpSendEcho2(ptr ptr ptr ptr long ptr long ptr ptr long long) 89 113 @ stdcall IcmpSendEcho(ptr long ptr long ptr ptr long long) 114 + @ stdcall -stub -version=0x600+ if_indextoname(long ptr) 115 + @ stdcall -stub -version=0x600+ if_nametoindex(str) 90 116 @ stub InternalCreateIpForwardEntry 91 117 @ stub InternalCreateIpNetEntry 92 118 @ stub InternalDeleteIpForwardEntry
+24 -2
modules/rostests/winetests/iphlpapi/CMakeLists.txt
··· 1 1 2 - add_definitions(-D__ROS_LONG64__) 2 + include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/wine) 3 3 4 4 add_executable(iphlpapi_winetest iphlpapi.c testlist.c) 5 5 target_link_libraries(iphlpapi_winetest wine) 6 6 set_module_type(iphlpapi_winetest win32cui) 7 - add_importlibs(iphlpapi_winetest ws2_32 msvcrt kernel32 ntdll) 7 + add_importlibs(iphlpapi_winetest iphlpapi ws2_32 msvcrt kernel32 ntdll) 8 8 add_rostests_file(TARGET iphlpapi_winetest) 9 + 10 + if(MSVC) 11 + target_compile_options(iphlpapi_winetest PRIVATE 12 + /wd4024 13 + /wd4047 14 + /wd4133 15 + /wd4477) 16 + endif() 17 + 18 + if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR 19 + CMAKE_C_COMPILER_ID STREQUAL "Clang") 20 + target_compile_options(iphlpapi_winetest PRIVATE 21 + -Wno-format 22 + -Wno-int-conversion 23 + -Wno-incompatible-pointer-types) 24 + endif() 25 + 26 + target_compile_definitions(iphlpapi_winetest PRIVATE 27 + WINETEST_USE_DBGSTR_LONGLONG 28 + __WINE_WINSOCKAPI_STDLIB_H 29 + strcasecmp=_stricmp) 30 +
+2535 -1029
modules/rostests/winetests/iphlpapi/iphlpapi.c
··· 28 28 * 29 29 * The Name field of the IP_ADAPTER_INDEX_MAP entries returned by 30 30 * GetInterfaceInfo is declared as a wide string, but the bytes are actually 31 - * an ASCII string on some versions of the IP helper API under Win9x. This was 31 + * an ANSI string on some versions of the IP helper API under Win9x. This was 32 32 * apparently an MS bug, it's corrected in later versions. 33 33 * 34 34 * The DomainName field of FIXED_INFO isn't NULL-terminated on Win98. ··· 38 38 #include "winsock2.h" 39 39 #include "windef.h" 40 40 #include "winbase.h" 41 + #include "winternl.h" 41 42 #include "ws2tcpip.h" 43 + #include "windns.h" 42 44 #include "iphlpapi.h" 45 + #include "icmpapi.h" 43 46 #include "iprtrmib.h" 44 47 #include "netioapi.h" 45 48 #include "wine/test.h" 46 49 #include <stdio.h> 47 50 #include <stdlib.h> 51 + #ifdef __REACTOS__ 52 + #include <versionhelpers.h> 53 + const IN6_ADDR in6addr_loopback = {{ IN6ADDR_LOOPBACK_INIT }}; 54 + #endif 48 55 49 56 #define ICMP_MINLEN 8 /* copied from dlls/iphlpapi/ip_icmp.h file */ 50 57 51 58 static HMODULE hLibrary = NULL; 52 59 53 - static DWORD (WINAPI *pGetNumberOfInterfaces)(PDWORD); 54 - static DWORD (WINAPI *pGetIpAddrTable)(PMIB_IPADDRTABLE,PULONG,BOOL); 55 - static DWORD (WINAPI *pGetIfEntry)(PMIB_IFROW); 56 - static DWORD (WINAPI *pGetIfEntry2)(PMIB_IF_ROW2); 57 - static DWORD (WINAPI *pGetFriendlyIfIndex)(DWORD); 58 - static DWORD (WINAPI *pGetIfTable)(PMIB_IFTABLE,PULONG,BOOL); 59 - static DWORD (WINAPI *pGetIfTable2)(PMIB_IF_TABLE2*); 60 - static DWORD (WINAPI *pGetIpForwardTable)(PMIB_IPFORWARDTABLE,PULONG,BOOL); 61 - static DWORD (WINAPI *pGetIpNetTable)(PMIB_IPNETTABLE,PULONG,BOOL); 62 - static DWORD (WINAPI *pGetInterfaceInfo)(PIP_INTERFACE_INFO,PULONG); 63 - static DWORD (WINAPI *pGetAdaptersInfo)(PIP_ADAPTER_INFO,PULONG); 64 - static DWORD (WINAPI *pGetNetworkParams)(PFIXED_INFO,PULONG); 65 - static DWORD (WINAPI *pGetIcmpStatistics)(PMIB_ICMP); 66 - static DWORD (WINAPI *pGetIpStatistics)(PMIB_IPSTATS); 67 - static DWORD (WINAPI *pGetTcpStatistics)(PMIB_TCPSTATS); 68 - static DWORD (WINAPI *pGetUdpStatistics)(PMIB_UDPSTATS); 69 - static DWORD (WINAPI *pGetIcmpStatisticsEx)(PMIB_ICMP_EX,DWORD); 70 - static DWORD (WINAPI *pGetIpStatisticsEx)(PMIB_IPSTATS,DWORD); 71 - static DWORD (WINAPI *pGetTcpStatisticsEx)(PMIB_TCPSTATS,DWORD); 72 - static DWORD (WINAPI *pGetUdpStatisticsEx)(PMIB_UDPSTATS,DWORD); 73 - static DWORD (WINAPI *pGetTcpTable)(PMIB_TCPTABLE,PDWORD,BOOL); 74 - static DWORD (WINAPI *pGetUdpTable)(PMIB_UDPTABLE,PDWORD,BOOL); 75 - static DWORD (WINAPI *pGetPerAdapterInfo)(ULONG,PIP_PER_ADAPTER_INFO,PULONG); 76 - static DWORD (WINAPI *pGetAdaptersAddresses)(ULONG,ULONG,PVOID,PIP_ADAPTER_ADDRESSES,PULONG); 77 - static DWORD (WINAPI *pNotifyAddrChange)(PHANDLE,LPOVERLAPPED); 78 - static BOOL (WINAPI *pCancelIPChangeNotify)(LPOVERLAPPED); 60 + static DWORD (WINAPI *pAllocateAndGetTcpExTableFromStack)(void**,BOOL,HANDLE,DWORD,DWORD); 61 + static DWORD (WINAPI *pGetTcp6Table)(PMIB_TCP6TABLE,PDWORD,BOOL); 62 + static DWORD (WINAPI *pGetUdp6Table)(PMIB_UDP6TABLE,PDWORD,BOOL); 63 + static DWORD (WINAPI *pGetUnicastIpAddressEntry)(MIB_UNICASTIPADDRESS_ROW*); 64 + static DWORD (WINAPI *pGetUnicastIpAddressTable)(ADDRESS_FAMILY,MIB_UNICASTIPADDRESS_TABLE**); 79 65 static DWORD (WINAPI *pGetExtendedTcpTable)(PVOID,PDWORD,BOOL,ULONG,TCP_TABLE_CLASS,ULONG); 80 66 static DWORD (WINAPI *pGetExtendedUdpTable)(PVOID,PDWORD,BOOL,ULONG,UDP_TABLE_CLASS,ULONG); 81 - static DWORD (WINAPI *pSetTcpEntry)(PMIB_TCPROW); 82 - static HANDLE(WINAPI *pIcmpCreateFile)(VOID); 83 - static DWORD (WINAPI *pIcmpSendEcho)(HANDLE,IPAddr,LPVOID,WORD,PIP_OPTION_INFORMATION,LPVOID,DWORD,DWORD); 84 67 static DWORD (WINAPI *pCreateSortedAddressPairs)(const PSOCKADDR_IN6,ULONG,const PSOCKADDR_IN6,ULONG,ULONG, 85 68 PSOCKADDR_IN6_PAIR*,ULONG*); 69 + static DWORD (WINAPI *pConvertLengthToIpv4Mask)(ULONG,ULONG*); 70 + static DWORD (WINAPI *pParseNetworkString)(const WCHAR*,DWORD,NET_ADDRESS_INFO*,USHORT*,BYTE*); 71 + static DWORD (WINAPI *pNotifyUnicastIpAddressChange)(ADDRESS_FAMILY, PUNICAST_IPADDRESS_CHANGE_CALLBACK, 72 + PVOID, BOOLEAN, HANDLE *); 73 + static DWORD (WINAPI *pCancelMibChangeNotify2)(HANDLE); 74 + 75 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 76 + static DWORD (WINAPI *pConvertInterfaceAliasToLuid)(const WCHAR*,NET_LUID*); 77 + static DWORD (WINAPI *pConvertInterfaceLuidToAlias)(NET_LUID*,WCHAR*,SIZE_T); 78 + static DWORD (WINAPI *pConvertGuidToStringA)(const GUID*,char*,DWORD); 79 + static DWORD (WINAPI *pConvertGuidToStringW)(const GUID*,WCHAR*,DWORD); 80 + static DWORD (WINAPI *pConvertStringToGuidW)(const WCHAR*,GUID*); 81 + static DWORD (WINAPI *pGetIfEntry2)(PMIB_IF_ROW2); 82 + static DWORD (WINAPI *pGetIfTable2)(PMIB_IF_TABLE2*); 83 + static DWORD (WINAPI *pGetIfTable2Ex)(MIB_IF_TABLE_LEVEL,MIB_IF_TABLE2**); 84 + static DWORD (WINAPI *pGetIpForwardTable2)(ADDRESS_FAMILY,MIB_IPFORWARD_TABLE2**); 85 + static DWORD (WINAPI *pGetIpNetTable2)(ADDRESS_FAMILY,MIB_IPNET_TABLE2**); 86 86 static void (WINAPI *pFreeMibTable)(void*); 87 87 static DWORD (WINAPI *pConvertInterfaceGuidToLuid)(const GUID*,NET_LUID*); 88 88 static DWORD (WINAPI *pConvertInterfaceIndexToLuid)(NET_IFINDEX,NET_LUID*); 89 89 static DWORD (WINAPI *pConvertInterfaceLuidToGuid)(const NET_LUID*,GUID*); 90 90 static DWORD (WINAPI *pConvertInterfaceLuidToIndex)(const NET_LUID*,NET_IFINDEX*); 91 - static DWORD (WINAPI *pConvertInterfaceLuidToNameW)(const NET_LUID*,WCHAR*,SIZE_T); 92 91 static DWORD (WINAPI *pConvertInterfaceLuidToNameA)(const NET_LUID*,char*,SIZE_T); 92 + static DWORD (WINAPI *pConvertInterfaceLuidToNameW)(const NET_LUID*,WCHAR*,SIZE_T); 93 93 static DWORD (WINAPI *pConvertInterfaceNameToLuidA)(const char*,NET_LUID*); 94 94 static DWORD (WINAPI *pConvertInterfaceNameToLuidW)(const WCHAR*,NET_LUID*); 95 + static NET_IF_COMPARTMENT_ID (WINAPI *pGetCurrentThreadCompartmentId)(); 96 + static char* (WINAPI *pif_indextoname)(NET_IFINDEX,char*); 97 + static IF_INDEX (WINAPI *pif_nametoindex)(const char*); 98 + 99 + #define ConvertInterfaceAliasToLuid pConvertInterfaceAliasToLuid 100 + #define ConvertInterfaceLuidToAlias pConvertInterfaceLuidToAlias 101 + #define ConvertGuidToStringA pConvertGuidToStringA 102 + #define ConvertGuidToStringW pConvertGuidToStringW 103 + #define ConvertStringToGuidW pConvertStringToGuidW 104 + #define GetIfEntry2 pGetIfEntry2 105 + #define GetIfTable2 pGetIfTable2 106 + #define GetIfTable2Ex pGetIfTable2Ex 107 + #define GetIpForwardTable2 pGetIpForwardTable2 108 + #define GetIpNetTable2 pGetIpNetTable2 109 + #define FreeMibTable pFreeMibTable 110 + #define ConvertInterfaceGuidToLuid pConvertInterfaceGuidToLuid 111 + #define ConvertInterfaceIndexToLuid pConvertInterfaceIndexToLuid 112 + #define ConvertInterfaceLuidToGuid pConvertInterfaceLuidToGuid 113 + #define ConvertInterfaceLuidToIndex pConvertInterfaceLuidToIndex 114 + #define ConvertInterfaceLuidToNameA pConvertInterfaceLuidToNameA 115 + #define ConvertInterfaceLuidToNameW pConvertInterfaceLuidToNameW 116 + #define ConvertInterfaceNameToLuidA pConvertInterfaceNameToLuidA 117 + #define ConvertInterfaceNameToLuidW pConvertInterfaceNameToLuidW 118 + #define GetCurrentThreadCompartmentId pGetCurrentThreadCompartmentId 119 + #define if_indextoname pif_indextoname 120 + #define if_nametoindex pif_nametoindex 121 + 122 + /* Wine mistakes */ 123 + #define GetUnicastIpAddressTable pGetUnicastIpAddressTable 124 + #define ConvertLengthToIpv4Mask pConvertLengthToIpv4Mask 125 + #else 126 + DWORD WINAPI ConvertGuidToStringA( const GUID *, char *, DWORD ); 127 + DWORD WINAPI ConvertGuidToStringW( const GUID *, WCHAR *, DWORD ); 128 + DWORD WINAPI ConvertStringToGuidW( const WCHAR *, GUID * ); 129 + #endif 95 130 96 131 static void loadIPHlpApi(void) 97 132 { 98 133 hLibrary = LoadLibraryA("iphlpapi.dll"); 99 134 if (hLibrary) { 100 - pGetNumberOfInterfaces = (void *)GetProcAddress(hLibrary, "GetNumberOfInterfaces"); 101 - pGetIpAddrTable = (void *)GetProcAddress(hLibrary, "GetIpAddrTable"); 102 - pGetIfEntry = (void *)GetProcAddress(hLibrary, "GetIfEntry"); 103 - pGetIfEntry2 = (void *)GetProcAddress(hLibrary, "GetIfEntry2"); 104 - pGetFriendlyIfIndex = (void *)GetProcAddress(hLibrary, "GetFriendlyIfIndex"); 105 - pGetIfTable = (void *)GetProcAddress(hLibrary, "GetIfTable"); 106 - pGetIfTable2 = (void *)GetProcAddress(hLibrary, "GetIfTable2"); 107 - pGetIpForwardTable = (void *)GetProcAddress(hLibrary, "GetIpForwardTable"); 108 - pGetIpNetTable = (void *)GetProcAddress(hLibrary, "GetIpNetTable"); 109 - pGetInterfaceInfo = (void *)GetProcAddress(hLibrary, "GetInterfaceInfo"); 110 - pGetAdaptersInfo = (void *)GetProcAddress(hLibrary, "GetAdaptersInfo"); 111 - pGetNetworkParams = (void *)GetProcAddress(hLibrary, "GetNetworkParams"); 112 - pGetIcmpStatistics = (void *)GetProcAddress(hLibrary, "GetIcmpStatistics"); 113 - pGetIpStatistics = (void *)GetProcAddress(hLibrary, "GetIpStatistics"); 114 - pGetTcpStatistics = (void *)GetProcAddress(hLibrary, "GetTcpStatistics"); 115 - pGetUdpStatistics = (void *)GetProcAddress(hLibrary, "GetUdpStatistics"); 116 - pGetIcmpStatisticsEx = (void *)GetProcAddress(hLibrary, "GetIcmpStatisticsEx"); 117 - pGetIpStatisticsEx = (void *)GetProcAddress(hLibrary, "GetIpStatisticsEx"); 118 - pGetTcpStatisticsEx = (void *)GetProcAddress(hLibrary, "GetTcpStatisticsEx"); 119 - pGetUdpStatisticsEx = (void *)GetProcAddress(hLibrary, "GetUdpStatisticsEx"); 120 - pGetTcpTable = (void *)GetProcAddress(hLibrary, "GetTcpTable"); 121 - pGetUdpTable = (void *)GetProcAddress(hLibrary, "GetUdpTable"); 122 - pGetPerAdapterInfo = (void *)GetProcAddress(hLibrary, "GetPerAdapterInfo"); 123 - pGetAdaptersAddresses = (void *)GetProcAddress(hLibrary, "GetAdaptersAddresses"); 124 - pNotifyAddrChange = (void *)GetProcAddress(hLibrary, "NotifyAddrChange"); 125 - pCancelIPChangeNotify = (void *)GetProcAddress(hLibrary, "CancelIPChangeNotify"); 135 + pAllocateAndGetTcpExTableFromStack = (void *)GetProcAddress(hLibrary, "AllocateAndGetTcpExTableFromStack"); 136 + pGetTcp6Table = (void *)GetProcAddress(hLibrary, "GetTcp6Table"); 137 + pGetUdp6Table = (void *)GetProcAddress(hLibrary, "GetUdp6Table"); 138 + pGetUnicastIpAddressEntry = (void *)GetProcAddress(hLibrary, "GetUnicastIpAddressEntry"); 139 + pGetUnicastIpAddressTable = (void *)GetProcAddress(hLibrary, "GetUnicastIpAddressTable"); 126 140 pGetExtendedTcpTable = (void *)GetProcAddress(hLibrary, "GetExtendedTcpTable"); 127 141 pGetExtendedUdpTable = (void *)GetProcAddress(hLibrary, "GetExtendedUdpTable"); 128 - pSetTcpEntry = (void *)GetProcAddress(hLibrary, "SetTcpEntry"); 129 - pIcmpCreateFile = (void *)GetProcAddress(hLibrary, "IcmpCreateFile"); 130 - pIcmpSendEcho = (void *)GetProcAddress(hLibrary, "IcmpSendEcho"); 131 142 pCreateSortedAddressPairs = (void *)GetProcAddress(hLibrary, "CreateSortedAddressPairs"); 132 - pFreeMibTable = (void *)GetProcAddress(hLibrary, "FreeMibTable"); 133 - pConvertInterfaceGuidToLuid = (void *)GetProcAddress(hLibrary, "ConvertInterfaceGuidToLuid"); 134 - pConvertInterfaceIndexToLuid = (void *)GetProcAddress(hLibrary, "ConvertInterfaceIndexToLuid"); 135 - pConvertInterfaceLuidToGuid = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToGuid"); 136 - pConvertInterfaceLuidToIndex = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToIndex"); 137 - pConvertInterfaceLuidToNameA = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToNameA"); 138 - pConvertInterfaceLuidToNameW = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToNameW"); 139 - pConvertInterfaceNameToLuidA = (void *)GetProcAddress(hLibrary, "ConvertInterfaceNameToLuidA"); 140 - pConvertInterfaceNameToLuidW = (void *)GetProcAddress(hLibrary, "ConvertInterfaceNameToLuidW"); 143 + pConvertLengthToIpv4Mask = (void *)GetProcAddress(hLibrary, "ConvertLengthToIpv4Mask"); 144 + pParseNetworkString = (void *)GetProcAddress(hLibrary, "ParseNetworkString"); 145 + pNotifyUnicastIpAddressChange = (void *)GetProcAddress(hLibrary, "NotifyUnicastIpAddressChange"); 146 + pCancelMibChangeNotify2 = (void *)GetProcAddress(hLibrary, "CancelMibChangeNotify2"); 147 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 148 + ConvertInterfaceAliasToLuid = (void *)GetProcAddress(hLibrary, "ConvertInterfaceAliasToLuid"); 149 + ConvertInterfaceLuidToAlias = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToAlias"); 150 + ConvertGuidToStringA = (void *)GetProcAddress(hLibrary, "ConvertGuidToStringA"); 151 + ConvertGuidToStringW = (void *)GetProcAddress(hLibrary, "ConvertGuidToStringW"); 152 + ConvertStringToGuidW = (void *)GetProcAddress(hLibrary, "ConvertStringToGuidW"); 153 + GetIfEntry2 = (void *)GetProcAddress(hLibrary, "GetIfEntry2"); 154 + GetIfTable2 = (void *)GetProcAddress(hLibrary, "GetIfTable2"); 155 + GetIfTable2Ex = (void *)GetProcAddress(hLibrary, "GetIfTable2Ex"); 156 + GetIpForwardTable2 = (void *)GetProcAddress(hLibrary, "GetIpForwardTable2"); 157 + GetIpNetTable2 = (void *)GetProcAddress(hLibrary, "GetIpNetTable2"); 158 + FreeMibTable = (void *)GetProcAddress(hLibrary, "FreeMibTable"); 159 + ConvertInterfaceGuidToLuid = (void *)GetProcAddress(hLibrary, "ConvertInterfaceGuidToLuid"); 160 + ConvertInterfaceIndexToLuid = (void *)GetProcAddress(hLibrary, "ConvertInterfaceIndexToLuid"); 161 + ConvertInterfaceLuidToGuid = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToGuid"); 162 + ConvertInterfaceLuidToIndex = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToIndex"); 163 + ConvertInterfaceLuidToNameA = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToNameA"); 164 + ConvertInterfaceLuidToNameW = (void *)GetProcAddress(hLibrary, "ConvertInterfaceLuidToNameW"); 165 + ConvertInterfaceNameToLuidA = (void *)GetProcAddress(hLibrary, "ConvertInterfaceNameToLuidA"); 166 + ConvertInterfaceNameToLuidW = (void *)GetProcAddress(hLibrary, "ConvertInterfaceNameToLuidW"); 167 + GetCurrentThreadCompartmentId = (void *)GetProcAddress(hLibrary, "GetCurrentThreadCompartmentId"); 168 + if_indextoname = (void *)GetProcAddress(hLibrary, "if_indextoname"); 169 + if_nametoindex = (void *)GetProcAddress(hLibrary, "if_nametoindex"); 170 + 171 + /* If we can't get FreeMibTable(), use free(). */ 172 + if (!FreeMibTable) 173 + FreeMibTable = (void (WINAPI *)(void *))free; 174 + #endif 141 175 } 142 176 } 143 177 ··· 149 183 /* replacement for inet_ntoa */ 150 184 static const char *ntoa( DWORD ip ) 151 185 { 152 - static char buffer[40]; 186 + static char buffers[4][16]; 187 + static int i = -1; 153 188 154 189 ip = htonl(ip); 155 - sprintf( buffer, "%u.%u.%u.%u", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff ); 156 - return buffer; 190 + i = (i + 1) % ARRAY_SIZE(buffers); 191 + sprintf( buffers[i], "%lu.%lu.%lu.%lu", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff ); 192 + return buffers[i]; 157 193 } 158 194 159 - static inline const char* debugstr_longlong(ULONGLONG ll) 195 + static const char *ntoa6( IN6_ADDR *ip ) 160 196 { 161 - static char string[17]; 162 - if (sizeof(ll) > sizeof(unsigned long) && ll >> 32) 163 - sprintf(string, "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll); 164 - else 165 - sprintf(string, "%lx", (unsigned long)ll); 166 - return string; 197 + static char buffers[4][40]; 198 + static int i = -1; 199 + unsigned short *p = ip->u.Word; 200 + 201 + i = (i + 1) % ARRAY_SIZE(buffers); 202 + sprintf( buffers[i], "%x:%x:%x:%x:%x:%x:%x:%x", 203 + htons(p[0]), htons(p[1]), htons(p[2]), htons(p[3]), htons(p[4]), htons(p[5]), htons(p[6]), htons(p[7]) ); 204 + return buffers[i]; 205 + } 206 + 207 + static DWORD ipv4_addr( BYTE b1, BYTE b2, BYTE b3, BYTE b4 ) 208 + { 209 + return htonl( (b1 << 24) | (b2 << 16) | (b3 << 8) | b4 ); 167 210 } 168 211 169 212 /* ··· 176 219 177 220 static void testGetNumberOfInterfaces(void) 178 221 { 179 - if (pGetNumberOfInterfaces) { 180 222 DWORD apiReturn, numInterfaces; 181 223 182 224 /* Crashes on Vista */ 183 225 if (0) { 184 - apiReturn = pGetNumberOfInterfaces(NULL); 185 - if (apiReturn == ERROR_NOT_SUPPORTED) 186 - return; 187 - ok(apiReturn == ERROR_INVALID_PARAMETER, 188 - "GetNumberOfInterfaces(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n", 189 - apiReturn); 226 + apiReturn = GetNumberOfInterfaces(NULL); 227 + if (apiReturn == ERROR_NOT_SUPPORTED) 228 + return; 229 + ok(apiReturn == ERROR_INVALID_PARAMETER, 230 + "GetNumberOfInterfaces(NULL) returned %ld, expected ERROR_INVALID_PARAMETER\n", 231 + apiReturn); 190 232 } 191 233 192 - apiReturn = pGetNumberOfInterfaces(&numInterfaces); 193 - if (apiReturn == ERROR_NOT_SUPPORTED) { 194 - skip("GetNumberOfInterfaces is not supported\n"); 195 - return; 196 - } 234 + apiReturn = GetNumberOfInterfaces(&numInterfaces); 197 235 ok(apiReturn == NO_ERROR, 198 - "GetNumberOfInterfaces returned %d, expected 0\n", apiReturn); 199 - } 236 + "GetNumberOfInterfaces returned %ld, expected 0\n", apiReturn); 200 237 } 201 238 202 239 static void testGetIfEntry(DWORD index) 203 240 { 204 - if (pGetIfEntry) { 205 241 DWORD apiReturn; 206 242 MIB_IFROW row; 207 243 208 244 memset(&row, 0, sizeof(row)); 209 - apiReturn = pGetIfEntry(NULL); 245 + apiReturn = GetIfEntry(NULL); 210 246 if (apiReturn == ERROR_NOT_SUPPORTED) { 211 247 skip("GetIfEntry is not supported\n"); 212 248 return; 213 249 } 214 250 ok(apiReturn == ERROR_INVALID_PARAMETER, 215 - "GetIfEntry(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n", 251 + "GetIfEntry(NULL) returned %ld, expected ERROR_INVALID_PARAMETER\n", 216 252 apiReturn); 217 253 row.dwIndex = -1; /* hope that's always bogus! */ 218 - apiReturn = pGetIfEntry(&row); 254 + apiReturn = GetIfEntry(&row); 219 255 ok(apiReturn == ERROR_INVALID_DATA || 220 256 apiReturn == ERROR_FILE_NOT_FOUND /* Vista */, 221 - "GetIfEntry(bogus row) returned %d, expected ERROR_INVALID_DATA or ERROR_FILE_NOT_FOUND\n", 257 + "GetIfEntry(bogus row) returned %ld, expected ERROR_INVALID_DATA or ERROR_FILE_NOT_FOUND\n", 222 258 apiReturn); 223 259 row.dwIndex = index; 224 - apiReturn = pGetIfEntry(&row); 260 + apiReturn = GetIfEntry(&row); 225 261 ok(apiReturn == NO_ERROR, 226 - "GetIfEntry returned %d, expected NO_ERROR\n", apiReturn); 227 - } 262 + "GetIfEntry returned %ld, expected NO_ERROR\n", apiReturn); 228 263 } 229 264 230 265 static void testGetIpAddrTable(void) 231 266 { 232 - if (pGetIpAddrTable) { 233 267 DWORD apiReturn; 234 268 ULONG dwSize = 0; 235 269 236 - apiReturn = pGetIpAddrTable(NULL, NULL, FALSE); 270 + apiReturn = GetIpAddrTable(NULL, NULL, FALSE); 237 271 if (apiReturn == ERROR_NOT_SUPPORTED) { 238 - skip("GetIpAddrTable is not supported\n"); 239 - return; 272 + skip("GetIpAddrTable is not supported\n"); 273 + return; 240 274 } 241 275 ok(apiReturn == ERROR_INVALID_PARAMETER, 242 - "GetIpAddrTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n", 243 - apiReturn); 244 - apiReturn = pGetIpAddrTable(NULL, &dwSize, FALSE); 276 + "GetIpAddrTable(NULL, NULL, FALSE) returned %ld, expected ERROR_INVALID_PARAMETER\n", 277 + apiReturn); 278 + apiReturn = GetIpAddrTable(NULL, &dwSize, FALSE); 245 279 ok(apiReturn == ERROR_INSUFFICIENT_BUFFER, 246 - "GetIpAddrTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n", 247 - apiReturn); 280 + "GetIpAddrTable(NULL, &dwSize, FALSE) returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n", 281 + apiReturn); 248 282 if (apiReturn == ERROR_INSUFFICIENT_BUFFER) { 249 - PMIB_IPADDRTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize); 283 + PMIB_IPADDRTABLE buf = malloc(dwSize); 250 284 251 - apiReturn = pGetIpAddrTable(buf, &dwSize, FALSE); 252 - ok(apiReturn == NO_ERROR, 253 - "GetIpAddrTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n", 254 - apiReturn); 255 - if (apiReturn == NO_ERROR && buf->dwNumEntries) 256 - { 257 - int i; 258 - testGetIfEntry(buf->table[0].dwIndex); 259 - for (i = 0; i < buf->dwNumEntries; i++) 285 + apiReturn = GetIpAddrTable(buf, &dwSize, FALSE); 286 + ok(apiReturn == NO_ERROR, 287 + "GetIpAddrTable(buf, &dwSize, FALSE) returned %ld, expected NO_ERROR\n", 288 + apiReturn); 289 + if (apiReturn == NO_ERROR && buf->dwNumEntries) 260 290 { 261 - ok (buf->table[i].wType != 0, "Test[%d]: expected wType > 0\n", i); 262 - trace("Entry[%d]: addr %s, dwIndex %u, wType 0x%x\n", i, 263 - ntoa(buf->table[i].dwAddr), buf->table[i].dwIndex, buf->table[i].wType); 291 + int i; 292 + testGetIfEntry(buf->table[0].dwIndex); 293 + for (i = 0; i < buf->dwNumEntries; i++) 294 + { 295 + ok (buf->table[i].wType != 0, "Test[%d]: expected wType > 0\n", i); 296 + ok (buf->table[i].dwBCastAddr == 1, "Test[%d]: got %08lx\n", i, buf->table[i].dwBCastAddr); 297 + ok (buf->table[i].dwReasmSize == 0xffff, "Test[%d]: got %08lx\n", i, buf->table[i].dwReasmSize); 298 + trace("Entry[%d]: addr %s, dwIndex %lu, wType 0x%x\n", i, 299 + ntoa(buf->table[i].dwAddr), buf->table[i].dwIndex, buf->table[i].wType); 300 + } 264 301 } 265 - } 266 - HeapFree(GetProcessHeap(), 0, buf); 302 + free(buf); 267 303 } 268 - } 269 304 } 270 305 271 306 static void testGetIfTable(void) 272 307 { 273 - if (pGetIfTable) { 274 308 DWORD apiReturn; 275 309 ULONG dwSize = 0; 276 310 277 - apiReturn = pGetIfTable(NULL, NULL, FALSE); 311 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 312 + if (!GetIfEntry2) 313 + skip("Missing APIs!\n"); 314 + #endif 315 + apiReturn = GetIfTable(NULL, NULL, FALSE); 278 316 if (apiReturn == ERROR_NOT_SUPPORTED) { 279 - skip("GetIfTable is not supported\n"); 280 - return; 317 + skip("GetIfTable is not supported\n"); 318 + return; 281 319 } 282 320 ok(apiReturn == ERROR_INVALID_PARAMETER, 283 - "GetIfTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n", 284 - apiReturn); 285 - apiReturn = pGetIfTable(NULL, &dwSize, FALSE); 321 + "GetIfTable(NULL, NULL, FALSE) returned %ld, expected ERROR_INVALID_PARAMETER\n", 322 + apiReturn); 323 + apiReturn = GetIfTable(NULL, &dwSize, FALSE); 286 324 ok(apiReturn == ERROR_INSUFFICIENT_BUFFER, 287 - "GetIfTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n", 288 - apiReturn); 325 + "GetIfTable(NULL, &dwSize, FALSE) returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n", 326 + apiReturn); 289 327 if (apiReturn == ERROR_INSUFFICIENT_BUFFER) { 290 - PMIB_IFTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize); 328 + PMIB_IFTABLE buf = malloc(dwSize); 291 329 292 - apiReturn = pGetIfTable(buf, &dwSize, FALSE); 293 - ok(apiReturn == NO_ERROR, 294 - "GetIfTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n\n", 295 - apiReturn); 330 + apiReturn = GetIfTable(buf, &dwSize, FALSE); 331 + ok(apiReturn == NO_ERROR, 332 + "GetIfTable(buf, &dwSize, FALSE) returned %ld, expected NO_ERROR\n\n", 333 + apiReturn); 296 334 297 - if (apiReturn == NO_ERROR && winetest_debug > 1) 298 - { 299 - DWORD i, j; 300 - char name[MAX_INTERFACE_NAME_LEN]; 335 + if (apiReturn == NO_ERROR) 336 + { 337 + char descr[MAX_INTERFACE_NAME_LEN]; 338 + WCHAR name[MAX_INTERFACE_NAME_LEN]; 339 + DWORD i, index; 340 + 341 + if (winetest_debug > 1) trace( "interface table: %lu entries\n", buf->dwNumEntries ); 342 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 343 + if (GetIfEntry2) { 344 + #endif 345 + for (i = 0; i < buf->dwNumEntries; i++) 346 + { 347 + MIB_IFROW *row = &buf->table[i]; 348 + MIB_IF_ROW2 row2; 349 + GUID *guid; 301 350 302 - trace( "interface table: %u entries\n", buf->dwNumEntries ); 303 - for (i = 0; i < buf->dwNumEntries; i++) 304 - { 305 - MIB_IFROW *row = &buf->table[i]; 306 - WideCharToMultiByte( CP_ACP, 0, row->wszName, -1, name, MAX_INTERFACE_NAME_LEN, NULL, NULL ); 307 - trace( "%u: '%s' type %u mtu %u speed %u phys", 308 - row->dwIndex, name, row->dwType, row->dwMtu, row->dwSpeed ); 309 - for (j = 0; j < row->dwPhysAddrLen; j++) 310 - printf( " %02x", row->bPhysAddr[j] ); 311 - printf( "\n" ); 312 - trace( " in: bytes %u upkts %u nupkts %u disc %u err %u unk %u\n", 313 - row->dwInOctets, row->dwInUcastPkts, row->dwInNUcastPkts, 314 - row->dwInDiscards, row->dwInErrors, row->dwInUnknownProtos ); 315 - trace( " out: bytes %u upkts %u nupkts %u disc %u err %u\n", 316 - row->dwOutOctets, row->dwOutUcastPkts, row->dwOutNUcastPkts, 317 - row->dwOutDiscards, row->dwOutErrors ); 318 - } 319 - } 320 - HeapFree(GetProcessHeap(), 0, buf); 351 + if (winetest_debug > 1) 352 + { 353 + trace( "%lu: '%s' type %lu mtu %lu speed %lu\n", 354 + row->dwIndex, debugstr_w(row->wszName), row->dwType, row->dwMtu, row->dwSpeed ); 355 + trace( " in: bytes %lu upkts %lu nupkts %lu disc %lu err %lu unk %lu\n", 356 + row->dwInOctets, row->dwInUcastPkts, row->dwInNUcastPkts, 357 + row->dwInDiscards, row->dwInErrors, row->dwInUnknownProtos ); 358 + trace( " out: bytes %lu upkts %lu nupkts %lu disc %lu err %lu\n", 359 + row->dwOutOctets, row->dwOutUcastPkts, row->dwOutNUcastPkts, 360 + row->dwOutDiscards, row->dwOutErrors ); 361 + } 362 + apiReturn = GetAdapterIndex( row->wszName, &index ); 363 + ok( !apiReturn, "got %ld\n", apiReturn ); 364 + ok( index == row->dwIndex || 365 + broken( index != row->dwIndex && index ), /* Win8 can have identical guids for two different ifaces */ 366 + "got %ld vs %ld\n", index, row->dwIndex ); 367 + memset( &row2, 0, sizeof(row2) ); 368 + row2.InterfaceIndex = row->dwIndex; 369 + GetIfEntry2( &row2 ); 370 + WideCharToMultiByte( CP_ACP, 0, row2.Description, -1, descr, sizeof(descr), NULL, NULL ); 371 + ok( !strcmp( (char *)row->bDescr, descr ), "got %s vs %s\n", row->bDescr, descr ); 372 + guid = &row2.InterfaceGuid; 373 + #ifdef __REACTOS__ 374 + _snwprintf( name, ARRAY_SIZE(name), L"\\DEVICE\\TCPIP_{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", 375 + guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], 376 + guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5], 377 + guid->Data4[6], guid->Data4[7]); 378 + #else 379 + swprintf( name, ARRAY_SIZE(name), L"\\DEVICE\\TCPIP_{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", 380 + guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], 381 + guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5], 382 + guid->Data4[6], guid->Data4[7]); 383 + #endif 384 + ok( !wcscmp( row->wszName, name ), "got %s vs %s\n", debugstr_w( row->wszName ), debugstr_w( name ) ); 385 + } 386 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 387 + } 388 + #endif 389 + } 390 + free(buf); 321 391 } 322 - } 323 392 } 324 393 325 394 static void testGetIpForwardTable(void) 326 395 { 327 - if (pGetIpForwardTable) { 328 - DWORD apiReturn; 329 - ULONG dwSize = 0; 396 + DWORD err, i, j; 397 + ULONG size = 0; 398 + MIB_IPFORWARDTABLE *buf; 399 + MIB_IPFORWARD_TABLE2 *table2; 400 + MIB_UNICASTIPADDRESS_TABLE *unicast; 401 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 402 + if (!GetIpForwardTable2 || !GetUnicastIpAddressTable || !ConvertLengthToIpv4Mask) { 403 + skip("Missing APIs!\n"); 404 + return; 405 + } 406 + #endif 407 + 408 + err = GetIpForwardTable( NULL, NULL, FALSE ); 409 + ok( err == ERROR_INVALID_PARAMETER, "got %ld\n", err ); 410 + 411 + err = GetIpForwardTable( NULL, &size, FALSE ); 412 + ok( err == ERROR_INSUFFICIENT_BUFFER, "got %ld\n", err ); 413 + 414 + buf = malloc( size ); 415 + err = GetIpForwardTable( buf, &size, FALSE ); 416 + ok( !err, "got %ld\n", err ); 417 + 418 + err = GetIpForwardTable2( AF_INET, &table2 ); 419 + ok( !err, "got %ld\n", err ); 420 + ok( buf->dwNumEntries == table2->NumEntries, "got %ld vs %ld\n", 421 + buf->dwNumEntries, table2->NumEntries ); 422 + 423 + err = GetUnicastIpAddressTable( AF_INET, &unicast ); 424 + ok( !err, "got %ld\n", err ); 425 + 426 + trace( "IP forward table: %lu entries\n", buf->dwNumEntries ); 427 + for (i = 0; i < buf->dwNumEntries; i++) 428 + { 429 + MIB_IPFORWARDROW *row = buf->table + i; 430 + MIB_IPFORWARD_ROW2 *row2 = table2->Table + i; 431 + DWORD mask, next_hop; 432 + 433 + winetest_push_context( "%ld", i ); 330 434 331 - apiReturn = pGetIpForwardTable(NULL, NULL, FALSE); 332 - if (apiReturn == ERROR_NOT_SUPPORTED) { 333 - skip("GetIpForwardTable is not supported\n"); 334 - return; 335 - } 336 - ok(apiReturn == ERROR_INVALID_PARAMETER, 337 - "GetIpForwardTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n", 338 - apiReturn); 339 - apiReturn = pGetIpForwardTable(NULL, &dwSize, FALSE); 340 - ok(apiReturn == ERROR_INSUFFICIENT_BUFFER, 341 - "GetIpForwardTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n", 342 - apiReturn); 343 - if (apiReturn == ERROR_INSUFFICIENT_BUFFER) { 344 - PMIB_IPFORWARDTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize); 435 + trace( "dest %s mask %s gw %s if %lu type %lu proto %lu\n", 436 + ntoa( row->dwForwardDest ), ntoa( row->dwForwardMask ), 437 + ntoa( row->dwForwardNextHop ), row->dwForwardIfIndex, 438 + row->dwForwardType, row->dwForwardProto ); 439 + ok( row->dwForwardDest == row2->DestinationPrefix.Prefix.Ipv4.sin_addr.s_addr, 440 + "got %08lx vs %08lx\n", row->dwForwardDest, row2->DestinationPrefix.Prefix.Ipv4.sin_addr.s_addr ); 441 + ConvertLengthToIpv4Mask( row2->DestinationPrefix.PrefixLength, &mask ); 442 + ok( row->dwForwardMask == mask, "got %08lx vs %08lx\n", row->dwForwardMask, mask ); 443 + ok( row->dwForwardPolicy == 0, "got %ld\n", row->dwForwardPolicy ); 345 444 346 - apiReturn = pGetIpForwardTable(buf, &dwSize, FALSE); 347 - ok(apiReturn == NO_ERROR, 348 - "GetIpForwardTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n", 349 - apiReturn); 445 + next_hop = row2->NextHop.Ipv4.sin_addr.s_addr; 446 + if (!next_hop) /* for direct addresses, dwForwardNextHop is set to the address of the appropriate interface */ 447 + { 448 + for (j = 0; j < unicast->NumEntries; j++) 449 + { 450 + if (unicast->Table[j].InterfaceLuid.Value == row2->InterfaceLuid.Value) 451 + { 452 + next_hop = unicast->Table[j].Address.Ipv4.sin_addr.s_addr; 453 + break; 454 + } 455 + } 456 + } 457 + ok( row->dwForwardNextHop == next_hop, "got %08lx vs %08lx\n", row->dwForwardNextHop, next_hop ); 350 458 351 - if (apiReturn == NO_ERROR && winetest_debug > 1) 352 - { 353 - DWORD i; 459 + ok( row->dwForwardIfIndex == row2->InterfaceIndex, "got %ld vs %ld\n", row->dwForwardIfIndex, row2->InterfaceIndex ); 460 + if (!row2->NextHop.Ipv4.sin_addr.s_addr) 461 + ok( buf->table[i].dwForwardType == MIB_IPROUTE_TYPE_DIRECT, "got %ld\n", buf->table[i].dwForwardType ); 462 + else 463 + ok( buf->table[i].dwForwardType == MIB_IPROUTE_TYPE_INDIRECT, "got %ld\n", buf->table[i].dwForwardType ); 464 + ok( row->dwForwardProto == row2->Protocol, "got %ld vs %d\n", row->dwForwardProto, row2->Protocol ); 465 + ok( row->dwForwardAge == row2->Age || row->dwForwardAge + 1 == row2->Age, 466 + "got %ld vs %ld\n", row->dwForwardAge, row2->Age ); 467 + ok( row->dwForwardNextHopAS == 0, "got %08lx\n", row->dwForwardNextHopAS ); 468 + /* FIXME: need to add the interface's metric from GetIpInterfaceTable() */ 469 + ok( row->dwForwardMetric1 >= row2->Metric, "got %ld vs %ld\n", row->dwForwardMetric1, row2->Metric ); 470 + ok( row->dwForwardMetric2 == 0, "got %ld\n", row->dwForwardMetric2 ); 471 + ok( row->dwForwardMetric3 == 0, "got %ld\n", row->dwForwardMetric3 ); 472 + ok( row->dwForwardMetric4 == 0, "got %ld\n", row->dwForwardMetric4 ); 473 + ok( row->dwForwardMetric5 == 0, "got %ld\n", row->dwForwardMetric5 ); 354 474 355 - trace( "IP forward table: %u entries\n", buf->dwNumEntries ); 356 - for (i = 0; i < buf->dwNumEntries; i++) 357 - { 358 - char buffer[100]; 359 - sprintf( buffer, "dest %s", ntoa( buf->table[i].dwForwardDest )); 360 - sprintf( buffer + strlen(buffer), " mask %s", ntoa( buf->table[i].dwForwardMask )); 361 - trace( "%u: %s gw %s if %u type %u\n", i, buffer, 362 - ntoa( buf->table[i].dwForwardNextHop ), 363 - buf->table[i].dwForwardIfIndex, U1(buf->table[i]).dwForwardType ); 364 - } 365 - } 366 - HeapFree(GetProcessHeap(), 0, buf); 475 + winetest_pop_context(); 367 476 } 368 - } 477 + FreeMibTable( unicast ); 478 + FreeMibTable( table2 ); 479 + free( buf ); 369 480 } 370 481 371 482 static void testGetIpNetTable(void) 372 483 { 373 - if (pGetIpNetTable) { 374 - DWORD apiReturn; 484 + DWORD apiReturn, ret, prev_idx; 485 + BOOL igmp3_found, ssdp_found; 486 + DWORD igmp3_addr, ssdp_addr; 487 + MIB_IPNET_TABLE2 *table2; 375 488 ULONG dwSize = 0; 489 + unsigned int i; 490 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 491 + if (!GetIpNetTable2) 492 + skip("Missing APIs!\n"); 493 + #endif 494 + 495 + igmp3_addr = ipv4_addr( 224, 0, 0, 22 ); 496 + ssdp_addr = ipv4_addr( 239, 255, 255, 250 ); 376 497 377 - apiReturn = pGetIpNetTable(NULL, NULL, FALSE); 498 + apiReturn = GetIpNetTable(NULL, NULL, FALSE); 378 499 if (apiReturn == ERROR_NOT_SUPPORTED) { 379 - skip("GetIpNetTable is not supported\n"); 380 - return; 500 + skip("GetIpNetTable is not supported\n"); 501 + return; 381 502 } 382 503 ok(apiReturn == ERROR_INVALID_PARAMETER, 383 - "GetIpNetTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n", 384 - apiReturn); 385 - apiReturn = pGetIpNetTable(NULL, &dwSize, FALSE); 504 + "GetIpNetTable(NULL, NULL, FALSE) returned %ld, expected ERROR_INVALID_PARAMETER\n", 505 + apiReturn); 506 + apiReturn = GetIpNetTable(NULL, &dwSize, FALSE); 386 507 ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_INSUFFICIENT_BUFFER, 387 - "GetIpNetTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_NO_DATA or ERROR_INSUFFICIENT_BUFFER\n", 388 - apiReturn); 508 + "GetIpNetTable(NULL, &dwSize, FALSE) returned %ld, expected ERROR_NO_DATA or ERROR_INSUFFICIENT_BUFFER\n", 509 + apiReturn); 389 510 if (apiReturn == ERROR_NO_DATA) 390 - ; /* empty ARP table's okay */ 511 + ; /* empty ARP table's okay */ 391 512 else if (apiReturn == ERROR_INSUFFICIENT_BUFFER) { 392 - PMIB_IPNETTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize); 513 + PMIB_IPNETTABLE buf = malloc(dwSize); 514 + 515 + memset(buf, 0xcc, dwSize); 516 + apiReturn = GetIpNetTable(buf, &dwSize, TRUE); 517 + ok((apiReturn == NO_ERROR && buf->dwNumEntries) || (apiReturn == ERROR_NO_DATA && !buf->dwNumEntries), 518 + "got apiReturn %lu, dwSize %lu, buf->dwNumEntries %lu.\n", 519 + apiReturn, dwSize, buf->dwNumEntries); 520 + 521 + if (apiReturn == NO_ERROR) 522 + { 523 + for (i = 0; i < buf->dwNumEntries - 1; ++i) 524 + { 525 + ok( buf->table[i].dwIndex <= buf->table[i + 1].dwIndex, 526 + "Entries are not sorted by index, i %u.\n", i ); 527 + if (buf->table[i].dwIndex == buf->table[i + 1].dwIndex) 528 + ok(ntohl(buf->table[i].dwAddr) <= ntohl(buf->table[i + 1].dwAddr), 529 + "Entries are not sorted by address, i %u.\n", i ); 530 + } 393 531 394 - apiReturn = pGetIpNetTable(buf, &dwSize, FALSE); 395 - ok(apiReturn == NO_ERROR || 396 - apiReturn == ERROR_NO_DATA, /* empty ARP table's okay */ 397 - "GetIpNetTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n", 398 - apiReturn); 532 + igmp3_found = ssdp_found = FALSE; 533 + prev_idx = ~0u; 534 + for (i = 0; i < buf->dwNumEntries; ++i) 535 + { 536 + if (buf->table[i].dwIndex != prev_idx) 537 + { 538 + if (prev_idx != ~0u) 539 + { 540 + ok( igmp3_found, "%s not found, iface index %lu.\n", ntoa( igmp3_addr ), prev_idx); 541 + ok( ssdp_found || broken(!ssdp_found) /* 239.255.255.250 is always present since Win10 */, 542 + "%s not found.\n", ntoa( ssdp_addr )); 543 + } 544 + prev_idx = buf->table[i].dwIndex; 545 + igmp3_found = ssdp_found = FALSE; 546 + } 547 + if (buf->table[i].dwAddr == igmp3_addr) 548 + igmp3_found = TRUE; 549 + else if (buf->table[i].dwAddr == ssdp_addr) 550 + ssdp_found = TRUE; 551 + } 552 + #if defined(__REACTOS__) 553 + if (LOBYTE(LOWORD(GetVersion())) >= 6) 554 + #endif 555 + ok( igmp3_found, "%s not found.\n", ntoa( igmp3_addr )); 556 + ok( ssdp_found || broken(!ssdp_found) /* 239.255.255.250 is always present since Win10 */, 557 + "%s not found.\n", ntoa( ssdp_addr )); 558 + 559 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 560 + if(GetIpNetTable2) { 561 + #endif 562 + ret = GetIpNetTable2( AF_INET, &table2 ); 563 + ok( !ret, "got ret %lu.\n", ret ); 564 + for (i = 0; i < table2->NumEntries; ++i) 565 + { 566 + MIB_IPNET_ROW2 *row = &table2->Table[i]; 567 + if (row->Address.Ipv4.sin_addr.s_addr == igmp3_addr 568 + || row->Address.Ipv4.sin_addr.s_addr == ssdp_addr) 569 + { 570 + ok( row->State == NlnsPermanent, "got state %d.\n", row->State ); 571 + ok( !row->IsRouter, "IsRouter is set.\n" ); 572 + ok( !row->IsUnreachable, "IsUnreachable is set.\n" ); 573 + } 574 + } 575 + FreeMibTable( table2 ); 576 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 577 + } 578 + #endif 579 + } 399 580 400 - if (apiReturn == NO_ERROR && winetest_debug > 1) 401 - { 402 - DWORD i, j; 581 + if (apiReturn == NO_ERROR && winetest_debug > 1) 582 + { 583 + DWORD i, j; 403 584 404 - trace( "IP net table: %u entries\n", buf->dwNumEntries ); 405 - for (i = 0; i < buf->dwNumEntries; i++) 406 - { 407 - trace( "%u: idx %u type %u addr %s phys", 408 - i, buf->table[i].dwIndex, U(buf->table[i]).dwType, ntoa( buf->table[i].dwAddr )); 409 - for (j = 0; j < buf->table[i].dwPhysAddrLen; j++) 410 - printf( " %02x", buf->table[i].bPhysAddr[j] ); 411 - printf( "\n" ); 412 - } 413 - } 414 - HeapFree(GetProcessHeap(), 0, buf); 585 + trace( "IP net table: %lu entries\n", buf->dwNumEntries ); 586 + for (i = 0; i < buf->dwNumEntries; i++) 587 + { 588 + trace( "%lu: idx %lu type %lu addr %s phys", 589 + i, buf->table[i].dwIndex, buf->table[i].dwType, ntoa( buf->table[i].dwAddr )); 590 + for (j = 0; j < buf->table[i].dwPhysAddrLen; j++) 591 + printf( " %02x", buf->table[i].bPhysAddr[j] ); 592 + printf( "\n" ); 593 + } 594 + } 595 + free(buf); 415 596 } 416 - } 417 597 } 418 598 419 599 static void testGetIcmpStatistics(void) 420 600 { 421 - if (pGetIcmpStatistics) { 422 601 DWORD apiReturn; 423 602 MIB_ICMP stats; 424 603 425 604 /* Crashes on Vista */ 426 605 if (0) { 427 - apiReturn = pGetIcmpStatistics(NULL); 428 - if (apiReturn == ERROR_NOT_SUPPORTED) 429 - return; 430 - ok(apiReturn == ERROR_INVALID_PARAMETER, 431 - "GetIcmpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n", 432 - apiReturn); 606 + apiReturn = GetIcmpStatistics(NULL); 607 + if (apiReturn == ERROR_NOT_SUPPORTED) 608 + return; 609 + ok(apiReturn == ERROR_INVALID_PARAMETER, 610 + "GetIcmpStatistics(NULL) returned %ld, expected ERROR_INVALID_PARAMETER\n", 611 + apiReturn); 433 612 } 434 613 435 - apiReturn = pGetIcmpStatistics(&stats); 614 + apiReturn = GetIcmpStatistics(&stats); 436 615 if (apiReturn == ERROR_NOT_SUPPORTED) 437 616 { 438 - skip("GetIcmpStatistics is not supported\n"); 439 - return; 617 + skip("GetIcmpStatistics is not supported\n"); 618 + return; 440 619 } 441 620 ok(apiReturn == NO_ERROR, 442 - "GetIcmpStatistics returned %d, expected NO_ERROR\n", apiReturn); 621 + "GetIcmpStatistics returned %ld, expected NO_ERROR\n", apiReturn); 443 622 if (apiReturn == NO_ERROR && winetest_debug > 1) 444 623 { 445 624 trace( "ICMP stats: %8s %8s\n", "in", "out" ); 446 - trace( " dwMsgs: %8u %8u\n", stats.stats.icmpInStats.dwMsgs, stats.stats.icmpOutStats.dwMsgs ); 447 - trace( " dwErrors: %8u %8u\n", stats.stats.icmpInStats.dwErrors, stats.stats.icmpOutStats.dwErrors ); 448 - trace( " dwDestUnreachs: %8u %8u\n", stats.stats.icmpInStats.dwDestUnreachs, stats.stats.icmpOutStats.dwDestUnreachs ); 449 - trace( " dwTimeExcds: %8u %8u\n", stats.stats.icmpInStats.dwTimeExcds, stats.stats.icmpOutStats.dwTimeExcds ); 450 - trace( " dwParmProbs: %8u %8u\n", stats.stats.icmpInStats.dwParmProbs, stats.stats.icmpOutStats.dwParmProbs ); 451 - trace( " dwSrcQuenchs: %8u %8u\n", stats.stats.icmpInStats.dwSrcQuenchs, stats.stats.icmpOutStats.dwSrcQuenchs ); 452 - trace( " dwRedirects: %8u %8u\n", stats.stats.icmpInStats.dwRedirects, stats.stats.icmpOutStats.dwRedirects ); 453 - trace( " dwEchos: %8u %8u\n", stats.stats.icmpInStats.dwEchos, stats.stats.icmpOutStats.dwEchos ); 454 - trace( " dwEchoReps: %8u %8u\n", stats.stats.icmpInStats.dwEchoReps, stats.stats.icmpOutStats.dwEchoReps ); 455 - trace( " dwTimestamps: %8u %8u\n", stats.stats.icmpInStats.dwTimestamps, stats.stats.icmpOutStats.dwTimestamps ); 456 - trace( " dwTimestampReps: %8u %8u\n", stats.stats.icmpInStats.dwTimestampReps, stats.stats.icmpOutStats.dwTimestampReps ); 457 - trace( " dwAddrMasks: %8u %8u\n", stats.stats.icmpInStats.dwAddrMasks, stats.stats.icmpOutStats.dwAddrMasks ); 458 - trace( " dwAddrMaskReps: %8u %8u\n", stats.stats.icmpInStats.dwAddrMaskReps, stats.stats.icmpOutStats.dwAddrMaskReps ); 625 + trace( " dwMsgs: %8lu %8lu\n", stats.stats.icmpInStats.dwMsgs, stats.stats.icmpOutStats.dwMsgs ); 626 + trace( " dwErrors: %8lu %8lu\n", stats.stats.icmpInStats.dwErrors, stats.stats.icmpOutStats.dwErrors ); 627 + trace( " dwDestUnreachs: %8lu %8lu\n", stats.stats.icmpInStats.dwDestUnreachs, stats.stats.icmpOutStats.dwDestUnreachs ); 628 + trace( " dwTimeExcds: %8lu %8lu\n", stats.stats.icmpInStats.dwTimeExcds, stats.stats.icmpOutStats.dwTimeExcds ); 629 + trace( " dwParmProbs: %8lu %8lu\n", stats.stats.icmpInStats.dwParmProbs, stats.stats.icmpOutStats.dwParmProbs ); 630 + trace( " dwSrcQuenchs: %8lu %8lu\n", stats.stats.icmpInStats.dwSrcQuenchs, stats.stats.icmpOutStats.dwSrcQuenchs ); 631 + trace( " dwRedirects: %8lu %8lu\n", stats.stats.icmpInStats.dwRedirects, stats.stats.icmpOutStats.dwRedirects ); 632 + trace( " dwEchos: %8lu %8lu\n", stats.stats.icmpInStats.dwEchos, stats.stats.icmpOutStats.dwEchos ); 633 + trace( " dwEchoReps: %8lu %8lu\n", stats.stats.icmpInStats.dwEchoReps, stats.stats.icmpOutStats.dwEchoReps ); 634 + trace( " dwTimestamps: %8lu %8lu\n", stats.stats.icmpInStats.dwTimestamps, stats.stats.icmpOutStats.dwTimestamps ); 635 + trace( " dwTimestampReps: %8lu %8lu\n", stats.stats.icmpInStats.dwTimestampReps, stats.stats.icmpOutStats.dwTimestampReps ); 636 + trace( " dwAddrMasks: %8lu %8lu\n", stats.stats.icmpInStats.dwAddrMasks, stats.stats.icmpOutStats.dwAddrMasks ); 637 + trace( " dwAddrMaskReps: %8lu %8lu\n", stats.stats.icmpInStats.dwAddrMaskReps, stats.stats.icmpOutStats.dwAddrMaskReps ); 459 638 } 460 - } 461 639 } 462 640 463 641 static void testGetIpStatistics(void) 464 642 { 465 - if (pGetIpStatistics) { 466 643 DWORD apiReturn; 467 644 MIB_IPSTATS stats; 468 645 469 - apiReturn = pGetIpStatistics(NULL); 646 + apiReturn = GetIpStatistics(NULL); 470 647 if (apiReturn == ERROR_NOT_SUPPORTED) { 471 - skip("GetIpStatistics is not supported\n"); 472 - return; 648 + skip("GetIpStatistics is not supported\n"); 649 + return; 473 650 } 474 651 ok(apiReturn == ERROR_INVALID_PARAMETER, 475 - "GetIpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n", 476 - apiReturn); 477 - apiReturn = pGetIpStatistics(&stats); 652 + "GetIpStatistics(NULL) returned %ld, expected ERROR_INVALID_PARAMETER\n", 653 + apiReturn); 654 + apiReturn = GetIpStatistics(&stats); 478 655 ok(apiReturn == NO_ERROR, 479 - "GetIpStatistics returned %d, expected NO_ERROR\n", apiReturn); 656 + "GetIpStatistics returned %ld, expected NO_ERROR\n", apiReturn); 480 657 if (apiReturn == NO_ERROR && winetest_debug > 1) 481 658 { 482 659 trace( "IP stats:\n" ); 483 - trace( " dwForwarding: %u\n", U(stats).dwForwarding ); 484 - trace( " dwDefaultTTL: %u\n", stats.dwDefaultTTL ); 485 - trace( " dwInReceives: %u\n", stats.dwInReceives ); 486 - trace( " dwInHdrErrors: %u\n", stats.dwInHdrErrors ); 487 - trace( " dwInAddrErrors: %u\n", stats.dwInAddrErrors ); 488 - trace( " dwForwDatagrams: %u\n", stats.dwForwDatagrams ); 489 - trace( " dwInUnknownProtos: %u\n", stats.dwInUnknownProtos ); 490 - trace( " dwInDiscards: %u\n", stats.dwInDiscards ); 491 - trace( " dwInDelivers: %u\n", stats.dwInDelivers ); 492 - trace( " dwOutRequests: %u\n", stats.dwOutRequests ); 493 - trace( " dwRoutingDiscards: %u\n", stats.dwRoutingDiscards ); 494 - trace( " dwOutDiscards: %u\n", stats.dwOutDiscards ); 495 - trace( " dwOutNoRoutes: %u\n", stats.dwOutNoRoutes ); 496 - trace( " dwReasmTimeout: %u\n", stats.dwReasmTimeout ); 497 - trace( " dwReasmReqds: %u\n", stats.dwReasmReqds ); 498 - trace( " dwReasmOks: %u\n", stats.dwReasmOks ); 499 - trace( " dwReasmFails: %u\n", stats.dwReasmFails ); 500 - trace( " dwFragOks: %u\n", stats.dwFragOks ); 501 - trace( " dwFragFails: %u\n", stats.dwFragFails ); 502 - trace( " dwFragCreates: %u\n", stats.dwFragCreates ); 503 - trace( " dwNumIf: %u\n", stats.dwNumIf ); 504 - trace( " dwNumAddr: %u\n", stats.dwNumAddr ); 505 - trace( " dwNumRoutes: %u\n", stats.dwNumRoutes ); 660 + trace( " dwForwarding: %lu\n", stats.dwForwarding ); 661 + trace( " dwDefaultTTL: %lu\n", stats.dwDefaultTTL ); 662 + trace( " dwInReceives: %lu\n", stats.dwInReceives ); 663 + trace( " dwInHdrErrors: %lu\n", stats.dwInHdrErrors ); 664 + trace( " dwInAddrErrors: %lu\n", stats.dwInAddrErrors ); 665 + trace( " dwForwDatagrams: %lu\n", stats.dwForwDatagrams ); 666 + trace( " dwInUnknownProtos: %lu\n", stats.dwInUnknownProtos ); 667 + trace( " dwInDiscards: %lu\n", stats.dwInDiscards ); 668 + trace( " dwInDelivers: %lu\n", stats.dwInDelivers ); 669 + trace( " dwOutRequests: %lu\n", stats.dwOutRequests ); 670 + trace( " dwRoutingDiscards: %lu\n", stats.dwRoutingDiscards ); 671 + trace( " dwOutDiscards: %lu\n", stats.dwOutDiscards ); 672 + trace( " dwOutNoRoutes: %lu\n", stats.dwOutNoRoutes ); 673 + trace( " dwReasmTimeout: %lu\n", stats.dwReasmTimeout ); 674 + trace( " dwReasmReqds: %lu\n", stats.dwReasmReqds ); 675 + trace( " dwReasmOks: %lu\n", stats.dwReasmOks ); 676 + trace( " dwReasmFails: %lu\n", stats.dwReasmFails ); 677 + trace( " dwFragOks: %lu\n", stats.dwFragOks ); 678 + trace( " dwFragFails: %lu\n", stats.dwFragFails ); 679 + trace( " dwFragCreates: %lu\n", stats.dwFragCreates ); 680 + trace( " dwNumIf: %lu\n", stats.dwNumIf ); 681 + trace( " dwNumAddr: %lu\n", stats.dwNumAddr ); 682 + trace( " dwNumRoutes: %lu\n", stats.dwNumRoutes ); 506 683 } 507 - } 508 684 } 509 685 510 686 static void testGetTcpStatistics(void) 511 687 { 512 - if (pGetTcpStatistics) { 513 688 DWORD apiReturn; 514 689 MIB_TCPSTATS stats; 515 690 516 - apiReturn = pGetTcpStatistics(NULL); 691 + apiReturn = GetTcpStatistics(NULL); 517 692 if (apiReturn == ERROR_NOT_SUPPORTED) { 518 - skip("GetTcpStatistics is not supported\n"); 519 - return; 693 + skip("GetTcpStatistics is not supported\n"); 694 + return; 520 695 } 521 696 ok(apiReturn == ERROR_INVALID_PARAMETER, 522 - "GetTcpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n", 523 - apiReturn); 524 - apiReturn = pGetTcpStatistics(&stats); 697 + "GetTcpStatistics(NULL) returned %ld, expected ERROR_INVALID_PARAMETER\n", 698 + apiReturn); 699 + apiReturn = GetTcpStatistics(&stats); 525 700 ok(apiReturn == NO_ERROR, 526 - "GetTcpStatistics returned %d, expected NO_ERROR\n", apiReturn); 701 + "GetTcpStatistics returned %ld, expected NO_ERROR\n", apiReturn); 527 702 if (apiReturn == NO_ERROR && winetest_debug > 1) 528 703 { 529 704 trace( "TCP stats:\n" ); 530 - trace( " dwRtoAlgorithm: %u\n", U(stats).dwRtoAlgorithm ); 531 - trace( " dwRtoMin: %u\n", stats.dwRtoMin ); 532 - trace( " dwRtoMax: %u\n", stats.dwRtoMax ); 533 - trace( " dwMaxConn: %u\n", stats.dwMaxConn ); 534 - trace( " dwActiveOpens: %u\n", stats.dwActiveOpens ); 535 - trace( " dwPassiveOpens: %u\n", stats.dwPassiveOpens ); 536 - trace( " dwAttemptFails: %u\n", stats.dwAttemptFails ); 537 - trace( " dwEstabResets: %u\n", stats.dwEstabResets ); 538 - trace( " dwCurrEstab: %u\n", stats.dwCurrEstab ); 539 - trace( " dwInSegs: %u\n", stats.dwInSegs ); 540 - trace( " dwOutSegs: %u\n", stats.dwOutSegs ); 541 - trace( " dwRetransSegs: %u\n", stats.dwRetransSegs ); 542 - trace( " dwInErrs: %u\n", stats.dwInErrs ); 543 - trace( " dwOutRsts: %u\n", stats.dwOutRsts ); 544 - trace( " dwNumConns: %u\n", stats.dwNumConns ); 705 + trace( " dwRtoAlgorithm: %lu\n", stats.dwRtoAlgorithm ); 706 + trace( " dwRtoMin: %lu\n", stats.dwRtoMin ); 707 + trace( " dwRtoMax: %lu\n", stats.dwRtoMax ); 708 + trace( " dwMaxConn: %lu\n", stats.dwMaxConn ); 709 + trace( " dwActiveOpens: %lu\n", stats.dwActiveOpens ); 710 + trace( " dwPassiveOpens: %lu\n", stats.dwPassiveOpens ); 711 + trace( " dwAttemptFails: %lu\n", stats.dwAttemptFails ); 712 + trace( " dwEstabResets: %lu\n", stats.dwEstabResets ); 713 + trace( " dwCurrEstab: %lu\n", stats.dwCurrEstab ); 714 + trace( " dwInSegs: %lu\n", stats.dwInSegs ); 715 + trace( " dwOutSegs: %lu\n", stats.dwOutSegs ); 716 + trace( " dwRetransSegs: %lu\n", stats.dwRetransSegs ); 717 + trace( " dwInErrs: %lu\n", stats.dwInErrs ); 718 + trace( " dwOutRsts: %lu\n", stats.dwOutRsts ); 719 + trace( " dwNumConns: %lu\n", stats.dwNumConns ); 545 720 } 546 - } 547 721 } 548 722 549 723 static void testGetUdpStatistics(void) 550 724 { 551 - if (pGetUdpStatistics) { 552 725 DWORD apiReturn; 553 726 MIB_UDPSTATS stats; 554 727 555 - apiReturn = pGetUdpStatistics(NULL); 728 + apiReturn = GetUdpStatistics(NULL); 556 729 if (apiReturn == ERROR_NOT_SUPPORTED) { 557 - skip("GetUdpStatistics is not supported\n"); 558 - return; 730 + skip("GetUdpStatistics is not supported\n"); 731 + return; 559 732 } 560 733 ok(apiReturn == ERROR_INVALID_PARAMETER, 561 - "GetUdpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n", 562 - apiReturn); 563 - apiReturn = pGetUdpStatistics(&stats); 734 + "GetUdpStatistics(NULL) returned %ld, expected ERROR_INVALID_PARAMETER\n", 735 + apiReturn); 736 + apiReturn = GetUdpStatistics(&stats); 564 737 ok(apiReturn == NO_ERROR, 565 - "GetUdpStatistics returned %d, expected NO_ERROR\n", apiReturn); 738 + "GetUdpStatistics returned %ld, expected NO_ERROR\n", apiReturn); 566 739 if (apiReturn == NO_ERROR && winetest_debug > 1) 567 740 { 568 741 trace( "UDP stats:\n" ); 569 - trace( " dwInDatagrams: %u\n", stats.dwInDatagrams ); 570 - trace( " dwNoPorts: %u\n", stats.dwNoPorts ); 571 - trace( " dwInErrors: %u\n", stats.dwInErrors ); 572 - trace( " dwOutDatagrams: %u\n", stats.dwOutDatagrams ); 573 - trace( " dwNumAddrs: %u\n", stats.dwNumAddrs ); 742 + trace( " dwInDatagrams: %lu\n", stats.dwInDatagrams ); 743 + trace( " dwNoPorts: %lu\n", stats.dwNoPorts ); 744 + trace( " dwInErrors: %lu\n", stats.dwInErrors ); 745 + trace( " dwOutDatagrams: %lu\n", stats.dwOutDatagrams ); 746 + trace( " dwNumAddrs: %lu\n", stats.dwNumAddrs ); 574 747 } 575 - } 576 748 } 577 749 578 750 static void testGetIcmpStatisticsEx(void) ··· 580 752 DWORD apiReturn; 581 753 MIB_ICMP_EX stats; 582 754 583 - if (!pGetIcmpStatisticsEx) 584 - { 585 - win_skip( "GetIcmpStatisticsEx not available\n" ); 586 - return; 587 - } 588 - 589 755 /* Crashes on Vista */ 590 756 if (1) { 591 - apiReturn = pGetIcmpStatisticsEx(NULL, AF_INET); 757 + apiReturn = GetIcmpStatisticsEx(NULL, AF_INET); 592 758 ok(apiReturn == ERROR_INVALID_PARAMETER, 593 - "GetIcmpStatisticsEx(NULL, AF_INET) returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn); 759 + "GetIcmpStatisticsEx(NULL, AF_INET) returned %ld, expected ERROR_INVALID_PARAMETER\n", apiReturn); 594 760 } 595 761 596 - apiReturn = pGetIcmpStatisticsEx(&stats, AF_BAN); 762 + apiReturn = GetIcmpStatisticsEx(&stats, AF_BAN); 597 763 ok(apiReturn == ERROR_INVALID_PARAMETER, 598 - "GetIcmpStatisticsEx(&stats, AF_BAN) returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn); 764 + "GetIcmpStatisticsEx(&stats, AF_BAN) returned %ld, expected ERROR_INVALID_PARAMETER\n", apiReturn); 599 765 600 - apiReturn = pGetIcmpStatisticsEx(&stats, AF_INET); 601 - ok(apiReturn == NO_ERROR, "GetIcmpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn); 766 + apiReturn = GetIcmpStatisticsEx(&stats, AF_INET); 767 + ok(apiReturn == NO_ERROR, "GetIcmpStatisticsEx returned %ld, expected NO_ERROR\n", apiReturn); 602 768 if (apiReturn == NO_ERROR && winetest_debug > 1) 603 769 { 604 770 INT i; 605 771 trace( "ICMP IPv4 Ex stats: %8s %8s\n", "in", "out" ); 606 - trace( " dwMsgs: %8u %8u\n", stats.icmpInStats.dwMsgs, stats.icmpOutStats.dwMsgs ); 607 - trace( " dwErrors: %8u %8u\n", stats.icmpInStats.dwErrors, stats.icmpOutStats.dwErrors ); 772 + trace( " dwMsgs: %8lu %8lu\n", stats.icmpInStats.dwMsgs, stats.icmpOutStats.dwMsgs ); 773 + trace( " dwErrors: %8lu %8lu\n", stats.icmpInStats.dwErrors, stats.icmpOutStats.dwErrors ); 608 774 for (i = 0; i < 256; i++) 609 - trace( " rgdwTypeCount[%3i]: %8u %8u\n", i, stats.icmpInStats.rgdwTypeCount[i], stats.icmpOutStats.rgdwTypeCount[i] ); 775 + trace( " rgdwTypeCount[%3i]: %8lu %8lu\n", i, stats.icmpInStats.rgdwTypeCount[i], stats.icmpOutStats.rgdwTypeCount[i] ); 610 776 } 611 777 612 - apiReturn = pGetIcmpStatisticsEx(&stats, AF_INET6); 778 + apiReturn = GetIcmpStatisticsEx(&stats, AF_INET6); 613 779 ok(apiReturn == NO_ERROR || broken(apiReturn == ERROR_NOT_SUPPORTED), 614 - "GetIcmpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn); 780 + "GetIcmpStatisticsEx returned %ld, expected NO_ERROR\n", apiReturn); 615 781 if (apiReturn == NO_ERROR && winetest_debug > 1) 616 782 { 617 783 INT i; 618 784 trace( "ICMP IPv6 Ex stats: %8s %8s\n", "in", "out" ); 619 - trace( " dwMsgs: %8u %8u\n", stats.icmpInStats.dwMsgs, stats.icmpOutStats.dwMsgs ); 620 - trace( " dwErrors: %8u %8u\n", stats.icmpInStats.dwErrors, stats.icmpOutStats.dwErrors ); 785 + trace( " dwMsgs: %8lu %8lu\n", stats.icmpInStats.dwMsgs, stats.icmpOutStats.dwMsgs ); 786 + trace( " dwErrors: %8lu %8lu\n", stats.icmpInStats.dwErrors, stats.icmpOutStats.dwErrors ); 621 787 for (i = 0; i < 256; i++) 622 - trace( " rgdwTypeCount[%3i]: %8u %8u\n", i, stats.icmpInStats.rgdwTypeCount[i], stats.icmpOutStats.rgdwTypeCount[i] ); 788 + trace( " rgdwTypeCount[%3i]: %8lu %8lu\n", i, stats.icmpInStats.rgdwTypeCount[i], stats.icmpOutStats.rgdwTypeCount[i] ); 623 789 } 624 790 } 625 791 ··· 628 794 DWORD apiReturn; 629 795 MIB_IPSTATS stats; 630 796 631 - if (!pGetIpStatisticsEx) 632 - { 633 - win_skip( "GetIpStatisticsEx not available\n" ); 634 - return; 635 - } 636 - 637 - apiReturn = pGetIpStatisticsEx(NULL, AF_INET); 797 + apiReturn = GetIpStatisticsEx(NULL, AF_INET); 638 798 ok(apiReturn == ERROR_INVALID_PARAMETER, 639 - "GetIpStatisticsEx(NULL, AF_INET) returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn); 799 + "GetIpStatisticsEx(NULL, AF_INET) returned %ld, expected ERROR_INVALID_PARAMETER\n", apiReturn); 640 800 641 - apiReturn = pGetIpStatisticsEx(&stats, AF_BAN); 801 + apiReturn = GetIpStatisticsEx(&stats, AF_BAN); 642 802 ok(apiReturn == ERROR_INVALID_PARAMETER, 643 - "GetIpStatisticsEx(&stats, AF_BAN) returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn); 803 + "GetIpStatisticsEx(&stats, AF_BAN) returned %ld, expected ERROR_INVALID_PARAMETER\n", apiReturn); 644 804 645 - apiReturn = pGetIpStatisticsEx(&stats, AF_INET); 646 - ok(apiReturn == NO_ERROR, "GetIpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn); 805 + apiReturn = GetIpStatisticsEx(&stats, AF_INET); 806 + ok(apiReturn == NO_ERROR, "GetIpStatisticsEx returned %ld, expected NO_ERROR\n", apiReturn); 647 807 if (apiReturn == NO_ERROR && winetest_debug > 1) 648 808 { 649 809 trace( "IP IPv4 Ex stats:\n" ); 650 - trace( " dwForwarding: %u\n", U(stats).dwForwarding ); 651 - trace( " dwDefaultTTL: %u\n", stats.dwDefaultTTL ); 652 - trace( " dwInReceives: %u\n", stats.dwInReceives ); 653 - trace( " dwInHdrErrors: %u\n", stats.dwInHdrErrors ); 654 - trace( " dwInAddrErrors: %u\n", stats.dwInAddrErrors ); 655 - trace( " dwForwDatagrams: %u\n", stats.dwForwDatagrams ); 656 - trace( " dwInUnknownProtos: %u\n", stats.dwInUnknownProtos ); 657 - trace( " dwInDiscards: %u\n", stats.dwInDiscards ); 658 - trace( " dwInDelivers: %u\n", stats.dwInDelivers ); 659 - trace( " dwOutRequests: %u\n", stats.dwOutRequests ); 660 - trace( " dwRoutingDiscards: %u\n", stats.dwRoutingDiscards ); 661 - trace( " dwOutDiscards: %u\n", stats.dwOutDiscards ); 662 - trace( " dwOutNoRoutes: %u\n", stats.dwOutNoRoutes ); 663 - trace( " dwReasmTimeout: %u\n", stats.dwReasmTimeout ); 664 - trace( " dwReasmReqds: %u\n", stats.dwReasmReqds ); 665 - trace( " dwReasmOks: %u\n", stats.dwReasmOks ); 666 - trace( " dwReasmFails: %u\n", stats.dwReasmFails ); 667 - trace( " dwFragOks: %u\n", stats.dwFragOks ); 668 - trace( " dwFragFails: %u\n", stats.dwFragFails ); 669 - trace( " dwFragCreates: %u\n", stats.dwFragCreates ); 670 - trace( " dwNumIf: %u\n", stats.dwNumIf ); 671 - trace( " dwNumAddr: %u\n", stats.dwNumAddr ); 672 - trace( " dwNumRoutes: %u\n", stats.dwNumRoutes ); 810 + trace( " dwForwarding: %lu\n", stats.dwForwarding ); 811 + trace( " dwDefaultTTL: %lu\n", stats.dwDefaultTTL ); 812 + trace( " dwInReceives: %lu\n", stats.dwInReceives ); 813 + trace( " dwInHdrErrors: %lu\n", stats.dwInHdrErrors ); 814 + trace( " dwInAddrErrors: %lu\n", stats.dwInAddrErrors ); 815 + trace( " dwForwDatagrams: %lu\n", stats.dwForwDatagrams ); 816 + trace( " dwInUnknownProtos: %lu\n", stats.dwInUnknownProtos ); 817 + trace( " dwInDiscards: %lu\n", stats.dwInDiscards ); 818 + trace( " dwInDelivers: %lu\n", stats.dwInDelivers ); 819 + trace( " dwOutRequests: %lu\n", stats.dwOutRequests ); 820 + trace( " dwRoutingDiscards: %lu\n", stats.dwRoutingDiscards ); 821 + trace( " dwOutDiscards: %lu\n", stats.dwOutDiscards ); 822 + trace( " dwOutNoRoutes: %lu\n", stats.dwOutNoRoutes ); 823 + trace( " dwReasmTimeout: %lu\n", stats.dwReasmTimeout ); 824 + trace( " dwReasmReqds: %lu\n", stats.dwReasmReqds ); 825 + trace( " dwReasmOks: %lu\n", stats.dwReasmOks ); 826 + trace( " dwReasmFails: %lu\n", stats.dwReasmFails ); 827 + trace( " dwFragOks: %lu\n", stats.dwFragOks ); 828 + trace( " dwFragFails: %lu\n", stats.dwFragFails ); 829 + trace( " dwFragCreates: %lu\n", stats.dwFragCreates ); 830 + trace( " dwNumIf: %lu\n", stats.dwNumIf ); 831 + trace( " dwNumAddr: %lu\n", stats.dwNumAddr ); 832 + trace( " dwNumRoutes: %lu\n", stats.dwNumRoutes ); 673 833 } 674 834 675 - apiReturn = pGetIpStatisticsEx(&stats, AF_INET6); 835 + apiReturn = GetIpStatisticsEx(&stats, AF_INET6); 676 836 ok(apiReturn == NO_ERROR || broken(apiReturn == ERROR_NOT_SUPPORTED), 677 - "GetIpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn); 837 + "GetIpStatisticsEx returned %ld, expected NO_ERROR\n", apiReturn); 678 838 if (apiReturn == NO_ERROR && winetest_debug > 1) 679 839 { 680 840 trace( "IP IPv6 Ex stats:\n" ); 681 - trace( " dwForwarding: %u\n", U(stats).dwForwarding ); 682 - trace( " dwDefaultTTL: %u\n", stats.dwDefaultTTL ); 683 - trace( " dwInReceives: %u\n", stats.dwInReceives ); 684 - trace( " dwInHdrErrors: %u\n", stats.dwInHdrErrors ); 685 - trace( " dwInAddrErrors: %u\n", stats.dwInAddrErrors ); 686 - trace( " dwForwDatagrams: %u\n", stats.dwForwDatagrams ); 687 - trace( " dwInUnknownProtos: %u\n", stats.dwInUnknownProtos ); 688 - trace( " dwInDiscards: %u\n", stats.dwInDiscards ); 689 - trace( " dwInDelivers: %u\n", stats.dwInDelivers ); 690 - trace( " dwOutRequests: %u\n", stats.dwOutRequests ); 691 - trace( " dwRoutingDiscards: %u\n", stats.dwRoutingDiscards ); 692 - trace( " dwOutDiscards: %u\n", stats.dwOutDiscards ); 693 - trace( " dwOutNoRoutes: %u\n", stats.dwOutNoRoutes ); 694 - trace( " dwReasmTimeout: %u\n", stats.dwReasmTimeout ); 695 - trace( " dwReasmReqds: %u\n", stats.dwReasmReqds ); 696 - trace( " dwReasmOks: %u\n", stats.dwReasmOks ); 697 - trace( " dwReasmFails: %u\n", stats.dwReasmFails ); 698 - trace( " dwFragOks: %u\n", stats.dwFragOks ); 699 - trace( " dwFragFails: %u\n", stats.dwFragFails ); 700 - trace( " dwFragCreates: %u\n", stats.dwFragCreates ); 701 - trace( " dwNumIf: %u\n", stats.dwNumIf ); 702 - trace( " dwNumAddr: %u\n", stats.dwNumAddr ); 703 - trace( " dwNumRoutes: %u\n", stats.dwNumRoutes ); 841 + trace( " dwForwarding: %lu\n", stats.dwForwarding ); 842 + trace( " dwDefaultTTL: %lu\n", stats.dwDefaultTTL ); 843 + trace( " dwInReceives: %lu\n", stats.dwInReceives ); 844 + trace( " dwInHdrErrors: %lu\n", stats.dwInHdrErrors ); 845 + trace( " dwInAddrErrors: %lu\n", stats.dwInAddrErrors ); 846 + trace( " dwForwDatagrams: %lu\n", stats.dwForwDatagrams ); 847 + trace( " dwInUnknownProtos: %lu\n", stats.dwInUnknownProtos ); 848 + trace( " dwInDiscards: %lu\n", stats.dwInDiscards ); 849 + trace( " dwInDelivers: %lu\n", stats.dwInDelivers ); 850 + trace( " dwOutRequests: %lu\n", stats.dwOutRequests ); 851 + trace( " dwRoutingDiscards: %lu\n", stats.dwRoutingDiscards ); 852 + trace( " dwOutDiscards: %lu\n", stats.dwOutDiscards ); 853 + trace( " dwOutNoRoutes: %lu\n", stats.dwOutNoRoutes ); 854 + trace( " dwReasmTimeout: %lu\n", stats.dwReasmTimeout ); 855 + trace( " dwReasmReqds: %lu\n", stats.dwReasmReqds ); 856 + trace( " dwReasmOks: %lu\n", stats.dwReasmOks ); 857 + trace( " dwReasmFails: %lu\n", stats.dwReasmFails ); 858 + trace( " dwFragOks: %lu\n", stats.dwFragOks ); 859 + trace( " dwFragFails: %lu\n", stats.dwFragFails ); 860 + trace( " dwFragCreates: %lu\n", stats.dwFragCreates ); 861 + trace( " dwNumIf: %lu\n", stats.dwNumIf ); 862 + trace( " dwNumAddr: %lu\n", stats.dwNumAddr ); 863 + trace( " dwNumRoutes: %lu\n", stats.dwNumRoutes ); 704 864 } 705 865 } 706 866 ··· 709 869 DWORD apiReturn; 710 870 MIB_TCPSTATS stats; 711 871 712 - if (!pGetTcpStatisticsEx) 713 - { 714 - win_skip( "GetTcpStatisticsEx not available\n" ); 715 - return; 716 - } 717 - 718 - apiReturn = pGetTcpStatisticsEx(NULL, AF_INET); 872 + apiReturn = GetTcpStatisticsEx(NULL, AF_INET); 719 873 ok(apiReturn == ERROR_INVALID_PARAMETER, 720 - "GetTcpStatisticsEx(NULL, AF_INET); returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn); 874 + "GetTcpStatisticsEx(NULL, AF_INET); returned %ld, expected ERROR_INVALID_PARAMETER\n", apiReturn); 721 875 722 - apiReturn = pGetTcpStatisticsEx(&stats, AF_BAN); 876 + apiReturn = GetTcpStatisticsEx(&stats, AF_BAN); 723 877 ok(apiReturn == ERROR_INVALID_PARAMETER || apiReturn == ERROR_NOT_SUPPORTED, 724 - "GetTcpStatisticsEx(&stats, AF_BAN) returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn); 878 + "GetTcpStatisticsEx(&stats, AF_BAN) returned %ld, expected ERROR_INVALID_PARAMETER\n", apiReturn); 725 879 726 - apiReturn = pGetTcpStatisticsEx(&stats, AF_INET); 727 - ok(apiReturn == NO_ERROR, "GetTcpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn); 880 + apiReturn = GetTcpStatisticsEx(&stats, AF_INET); 881 + ok(apiReturn == NO_ERROR, "GetTcpStatisticsEx returned %ld, expected NO_ERROR\n", apiReturn); 728 882 if (apiReturn == NO_ERROR && winetest_debug > 1) 729 883 { 730 884 trace( "TCP IPv4 Ex stats:\n" ); 731 - trace( " dwRtoAlgorithm: %u\n", U(stats).dwRtoAlgorithm ); 732 - trace( " dwRtoMin: %u\n", stats.dwRtoMin ); 733 - trace( " dwRtoMax: %u\n", stats.dwRtoMax ); 734 - trace( " dwMaxConn: %u\n", stats.dwMaxConn ); 735 - trace( " dwActiveOpens: %u\n", stats.dwActiveOpens ); 736 - trace( " dwPassiveOpens: %u\n", stats.dwPassiveOpens ); 737 - trace( " dwAttemptFails: %u\n", stats.dwAttemptFails ); 738 - trace( " dwEstabResets: %u\n", stats.dwEstabResets ); 739 - trace( " dwCurrEstab: %u\n", stats.dwCurrEstab ); 740 - trace( " dwInSegs: %u\n", stats.dwInSegs ); 741 - trace( " dwOutSegs: %u\n", stats.dwOutSegs ); 742 - trace( " dwRetransSegs: %u\n", stats.dwRetransSegs ); 743 - trace( " dwInErrs: %u\n", stats.dwInErrs ); 744 - trace( " dwOutRsts: %u\n", stats.dwOutRsts ); 745 - trace( " dwNumConns: %u\n", stats.dwNumConns ); 885 + trace( " dwRtoAlgorithm: %lu\n", stats.dwRtoAlgorithm ); 886 + trace( " dwRtoMin: %lu\n", stats.dwRtoMin ); 887 + trace( " dwRtoMax: %lu\n", stats.dwRtoMax ); 888 + trace( " dwMaxConn: %lu\n", stats.dwMaxConn ); 889 + trace( " dwActiveOpens: %lu\n", stats.dwActiveOpens ); 890 + trace( " dwPassiveOpens: %lu\n", stats.dwPassiveOpens ); 891 + trace( " dwAttemptFails: %lu\n", stats.dwAttemptFails ); 892 + trace( " dwEstabResets: %lu\n", stats.dwEstabResets ); 893 + trace( " dwCurrEstab: %lu\n", stats.dwCurrEstab ); 894 + trace( " dwInSegs: %lu\n", stats.dwInSegs ); 895 + trace( " dwOutSegs: %lu\n", stats.dwOutSegs ); 896 + trace( " dwRetransSegs: %lu\n", stats.dwRetransSegs ); 897 + trace( " dwInErrs: %lu\n", stats.dwInErrs ); 898 + trace( " dwOutRsts: %lu\n", stats.dwOutRsts ); 899 + trace( " dwNumConns: %lu\n", stats.dwNumConns ); 746 900 } 747 901 748 - apiReturn = pGetTcpStatisticsEx(&stats, AF_INET6); 749 - todo_wine ok(apiReturn == NO_ERROR || broken(apiReturn == ERROR_NOT_SUPPORTED), 750 - "GetTcpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn); 902 + apiReturn = GetTcpStatisticsEx(&stats, AF_INET6); 903 + ok(apiReturn == NO_ERROR || broken(apiReturn == ERROR_NOT_SUPPORTED), 904 + "GetTcpStatisticsEx returned %ld, expected NO_ERROR\n", apiReturn); 751 905 if (apiReturn == NO_ERROR && winetest_debug > 1) 752 906 { 753 907 trace( "TCP IPv6 Ex stats:\n" ); 754 - trace( " dwRtoAlgorithm: %u\n", U(stats).dwRtoAlgorithm ); 755 - trace( " dwRtoMin: %u\n", stats.dwRtoMin ); 756 - trace( " dwRtoMax: %u\n", stats.dwRtoMax ); 757 - trace( " dwMaxConn: %u\n", stats.dwMaxConn ); 758 - trace( " dwActiveOpens: %u\n", stats.dwActiveOpens ); 759 - trace( " dwPassiveOpens: %u\n", stats.dwPassiveOpens ); 760 - trace( " dwAttemptFails: %u\n", stats.dwAttemptFails ); 761 - trace( " dwEstabResets: %u\n", stats.dwEstabResets ); 762 - trace( " dwCurrEstab: %u\n", stats.dwCurrEstab ); 763 - trace( " dwInSegs: %u\n", stats.dwInSegs ); 764 - trace( " dwOutSegs: %u\n", stats.dwOutSegs ); 765 - trace( " dwRetransSegs: %u\n", stats.dwRetransSegs ); 766 - trace( " dwInErrs: %u\n", stats.dwInErrs ); 767 - trace( " dwOutRsts: %u\n", stats.dwOutRsts ); 768 - trace( " dwNumConns: %u\n", stats.dwNumConns ); 908 + trace( " dwRtoAlgorithm: %lu\n", stats.dwRtoAlgorithm ); 909 + trace( " dwRtoMin: %lu\n", stats.dwRtoMin ); 910 + trace( " dwRtoMax: %lu\n", stats.dwRtoMax ); 911 + trace( " dwMaxConn: %lu\n", stats.dwMaxConn ); 912 + trace( " dwActiveOpens: %lu\n", stats.dwActiveOpens ); 913 + trace( " dwPassiveOpens: %lu\n", stats.dwPassiveOpens ); 914 + trace( " dwAttemptFails: %lu\n", stats.dwAttemptFails ); 915 + trace( " dwEstabResets: %lu\n", stats.dwEstabResets ); 916 + trace( " dwCurrEstab: %lu\n", stats.dwCurrEstab ); 917 + trace( " dwInSegs: %lu\n", stats.dwInSegs ); 918 + trace( " dwOutSegs: %lu\n", stats.dwOutSegs ); 919 + trace( " dwRetransSegs: %lu\n", stats.dwRetransSegs ); 920 + trace( " dwInErrs: %lu\n", stats.dwInErrs ); 921 + trace( " dwOutRsts: %lu\n", stats.dwOutRsts ); 922 + trace( " dwNumConns: %lu\n", stats.dwNumConns ); 769 923 } 770 924 } 771 925 ··· 774 928 DWORD apiReturn; 775 929 MIB_UDPSTATS stats; 776 930 777 - if (!pGetUdpStatisticsEx) 778 - { 779 - win_skip( "GetUdpStatisticsEx not available\n" ); 780 - return; 781 - } 782 - 783 - apiReturn = pGetUdpStatisticsEx(NULL, AF_INET); 931 + apiReturn = GetUdpStatisticsEx(NULL, AF_INET); 784 932 ok(apiReturn == ERROR_INVALID_PARAMETER, 785 - "GetUdpStatisticsEx(NULL, AF_INET); returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn); 933 + "GetUdpStatisticsEx(NULL, AF_INET); returned %ld, expected ERROR_INVALID_PARAMETER\n", apiReturn); 786 934 787 - apiReturn = pGetUdpStatisticsEx(&stats, AF_BAN); 935 + apiReturn = GetUdpStatisticsEx(&stats, AF_BAN); 788 936 ok(apiReturn == ERROR_INVALID_PARAMETER || apiReturn == ERROR_NOT_SUPPORTED, 789 - "GetUdpStatisticsEx(&stats, AF_BAN) returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn); 937 + "GetUdpStatisticsEx(&stats, AF_BAN) returned %ld, expected ERROR_INVALID_PARAMETER\n", apiReturn); 790 938 791 - apiReturn = pGetUdpStatisticsEx(&stats, AF_INET); 792 - ok(apiReturn == NO_ERROR, "GetUdpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn); 939 + apiReturn = GetUdpStatisticsEx(&stats, AF_INET); 940 + ok(apiReturn == NO_ERROR, "GetUdpStatisticsEx returned %ld, expected NO_ERROR\n", apiReturn); 793 941 if (apiReturn == NO_ERROR && winetest_debug > 1) 794 942 { 795 943 trace( "UDP IPv4 Ex stats:\n" ); 796 - trace( " dwInDatagrams: %u\n", stats.dwInDatagrams ); 797 - trace( " dwNoPorts: %u\n", stats.dwNoPorts ); 798 - trace( " dwInErrors: %u\n", stats.dwInErrors ); 799 - trace( " dwOutDatagrams: %u\n", stats.dwOutDatagrams ); 800 - trace( " dwNumAddrs: %u\n", stats.dwNumAddrs ); 944 + trace( " dwInDatagrams: %lu\n", stats.dwInDatagrams ); 945 + trace( " dwNoPorts: %lu\n", stats.dwNoPorts ); 946 + trace( " dwInErrors: %lu\n", stats.dwInErrors ); 947 + trace( " dwOutDatagrams: %lu\n", stats.dwOutDatagrams ); 948 + trace( " dwNumAddrs: %lu\n", stats.dwNumAddrs ); 801 949 } 802 950 803 - apiReturn = pGetUdpStatisticsEx(&stats, AF_INET6); 951 + apiReturn = GetUdpStatisticsEx(&stats, AF_INET6); 804 952 ok(apiReturn == NO_ERROR || broken(apiReturn == ERROR_NOT_SUPPORTED), 805 - "GetUdpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn); 953 + "GetUdpStatisticsEx returned %ld, expected NO_ERROR\n", apiReturn); 806 954 if (apiReturn == NO_ERROR && winetest_debug > 1) 807 955 { 808 956 trace( "UDP IPv6 Ex stats:\n" ); 809 - trace( " dwInDatagrams: %u\n", stats.dwInDatagrams ); 810 - trace( " dwNoPorts: %u\n", stats.dwNoPorts ); 811 - trace( " dwInErrors: %u\n", stats.dwInErrors ); 812 - trace( " dwOutDatagrams: %u\n", stats.dwOutDatagrams ); 813 - trace( " dwNumAddrs: %u\n", stats.dwNumAddrs ); 957 + trace( " dwInDatagrams: %lu\n", stats.dwInDatagrams ); 958 + trace( " dwNoPorts: %lu\n", stats.dwNoPorts ); 959 + trace( " dwInErrors: %lu\n", stats.dwInErrors ); 960 + trace( " dwOutDatagrams: %lu\n", stats.dwOutDatagrams ); 961 + trace( " dwNumAddrs: %lu\n", stats.dwNumAddrs ); 814 962 } 815 963 } 816 964 817 965 static void testGetTcpTable(void) 818 966 { 819 - if (pGetTcpTable) { 820 967 DWORD apiReturn; 821 968 ULONG dwSize = 0; 822 969 823 - apiReturn = pGetTcpTable(NULL, &dwSize, FALSE); 970 + apiReturn = GetTcpTable(NULL, &dwSize, FALSE); 824 971 if (apiReturn == ERROR_NOT_SUPPORTED) { 825 - skip("GetTcpTable is not supported\n"); 826 - return; 972 + skip("GetTcpTable is not supported\n"); 973 + return; 827 974 } 828 - ok(apiReturn == ERROR_INSUFFICIENT_BUFFER || 829 - broken(apiReturn == ERROR_NO_DATA), /* win95 */ 830 - "GetTcpTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n", 831 - apiReturn); 975 + ok(apiReturn == ERROR_INSUFFICIENT_BUFFER, 976 + "GetTcpTable(NULL, &dwSize, FALSE) returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n", 977 + apiReturn); 832 978 if (apiReturn == ERROR_INSUFFICIENT_BUFFER) { 833 - PMIB_TCPTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize); 979 + PMIB_TCPTABLE buf = malloc(dwSize); 834 980 835 - apiReturn = pGetTcpTable(buf, &dwSize, FALSE); 836 - ok(apiReturn == NO_ERROR, 837 - "GetTcpTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n", 838 - apiReturn); 981 + apiReturn = GetTcpTable(buf, &dwSize, FALSE); 982 + ok(apiReturn == NO_ERROR, 983 + "GetTcpTable(buf, &dwSize, FALSE) returned %ld, expected NO_ERROR\n", 984 + apiReturn); 839 985 840 - if (apiReturn == NO_ERROR && winetest_debug > 1) 841 - { 842 - DWORD i; 843 - trace( "TCP table: %u entries\n", buf->dwNumEntries ); 844 - for (i = 0; i < buf->dwNumEntries; i++) 845 - { 846 - char buffer[40]; 847 - sprintf( buffer, "local %s:%u", 848 - ntoa(buf->table[i].dwLocalAddr), ntohs(buf->table[i].dwLocalPort) ); 849 - trace( "%u: %s remote %s:%u state %u\n", 850 - i, buffer, ntoa( buf->table[i].dwRemoteAddr ), 851 - ntohs(buf->table[i].dwRemotePort), U(buf->table[i]).dwState ); 852 - } 853 - } 854 - HeapFree(GetProcessHeap(), 0, buf); 986 + if (apiReturn == NO_ERROR && winetest_debug > 1) 987 + { 988 + DWORD i; 989 + trace( "TCP table: %lu entries\n", buf->dwNumEntries ); 990 + for (i = 0; i < buf->dwNumEntries; i++) 991 + { 992 + trace( "%lu: local %s:%u remote %s:%u state %lu\n", i, 993 + ntoa(buf->table[i].dwLocalAddr), ntohs(buf->table[i].dwLocalPort), 994 + ntoa(buf->table[i].dwRemoteAddr), ntohs(buf->table[i].dwRemotePort), 995 + buf->table[i].dwState ); 996 + } 997 + } 998 + free(buf); 855 999 } 856 - } 857 1000 } 858 1001 859 1002 static void testGetUdpTable(void) 860 1003 { 861 - if (pGetUdpTable) { 862 1004 DWORD apiReturn; 863 1005 ULONG dwSize = 0; 864 1006 865 - apiReturn = pGetUdpTable(NULL, &dwSize, FALSE); 1007 + apiReturn = GetUdpTable(NULL, &dwSize, FALSE); 866 1008 if (apiReturn == ERROR_NOT_SUPPORTED) { 867 - skip("GetUdpTable is not supported\n"); 868 - return; 1009 + skip("GetUdpTable is not supported\n"); 1010 + return; 869 1011 } 870 1012 ok(apiReturn == ERROR_INSUFFICIENT_BUFFER, 871 - "GetUdpTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n", 872 - apiReturn); 1013 + "GetUdpTable(NULL, &dwSize, FALSE) returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n", 1014 + apiReturn); 873 1015 if (apiReturn == ERROR_INSUFFICIENT_BUFFER) { 874 - PMIB_UDPTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize); 1016 + PMIB_UDPTABLE buf = malloc(dwSize); 875 1017 876 - apiReturn = pGetUdpTable(buf, &dwSize, FALSE); 877 - ok(apiReturn == NO_ERROR, 878 - "GetUdpTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n", 879 - apiReturn); 1018 + apiReturn = GetUdpTable(buf, &dwSize, FALSE); 1019 + ok(apiReturn == NO_ERROR, 1020 + "GetUdpTable(buf, &dwSize, FALSE) returned %ld, expected NO_ERROR\n", 1021 + apiReturn); 880 1022 881 - if (apiReturn == NO_ERROR && winetest_debug > 1) 882 - { 883 - DWORD i; 884 - trace( "UDP table: %u entries\n", buf->dwNumEntries ); 885 - for (i = 0; i < buf->dwNumEntries; i++) 886 - trace( "%u: %s:%u\n", 887 - i, ntoa( buf->table[i].dwLocalAddr ), ntohs(buf->table[i].dwLocalPort) ); 888 - } 889 - HeapFree(GetProcessHeap(), 0, buf); 1023 + if (apiReturn == NO_ERROR && winetest_debug > 1) 1024 + { 1025 + DWORD i; 1026 + trace( "UDP table: %lu entries\n", buf->dwNumEntries ); 1027 + for (i = 0; i < buf->dwNumEntries; i++) 1028 + trace( "%lu: %s:%u\n", 1029 + i, ntoa( buf->table[i].dwLocalAddr ), ntohs(buf->table[i].dwLocalPort) ); 1030 + } 1031 + free(buf); 890 1032 } 891 - } 892 1033 } 893 1034 894 1035 static void testSetTcpEntry(void) ··· 899 1040 memset(&row, 0, sizeof(row)); 900 1041 if(0) /* This test crashes in OS >= VISTA */ 901 1042 { 902 - ret = pSetTcpEntry(NULL); 903 - ok( ret == ERROR_INVALID_PARAMETER, "got %u, expected %u\n", ret, ERROR_INVALID_PARAMETER); 1043 + ret = SetTcpEntry(NULL); 1044 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu, expected %u\n", ret, ERROR_INVALID_PARAMETER); 904 1045 } 905 1046 906 - ret = pSetTcpEntry(&row); 1047 + ret = SetTcpEntry(&row); 907 1048 if (ret == ERROR_NETWORK_ACCESS_DENIED) 908 1049 { 909 1050 win_skip("SetTcpEntry failed with access error. Skipping test.\n"); 910 1051 return; 911 1052 } 912 - todo_wine ok( ret == ERROR_INVALID_PARAMETER, "got %u, expected %u\n", ret, ERROR_INVALID_PARAMETER); 1053 + todo_wine ok( ret == ERROR_INVALID_PARAMETER, "got %lu, expected %u\n", ret, ERROR_INVALID_PARAMETER); 913 1054 914 - U(row).dwState = MIB_TCP_STATE_DELETE_TCB; 915 - ret = pSetTcpEntry(&row); 1055 + row.dwState = MIB_TCP_STATE_DELETE_TCB; 1056 + ret = SetTcpEntry(&row); 916 1057 todo_wine ok( ret == ERROR_MR_MID_NOT_FOUND || broken(ret == ERROR_INVALID_PARAMETER), 917 - "got %u, expected %u\n", ret, ERROR_MR_MID_NOT_FOUND); 1058 + "got %lu, expected %u\n", ret, ERROR_MR_MID_NOT_FOUND); 1059 + } 1060 + 1061 + static BOOL icmp_send_echo_test_apc_expect; 1062 + static void WINAPI icmp_send_echo_test_apc_xp(void *context) 1063 + { 1064 + ok(icmp_send_echo_test_apc_expect, "Unexpected APC execution\n"); 1065 + ok(context == (void*)0xdeadc0de, "Wrong context: %p\n", context); 1066 + icmp_send_echo_test_apc_expect = FALSE; 1067 + } 1068 + 1069 + static void WINAPI icmp_send_echo_test_apc(void *context, IO_STATUS_BLOCK *io_status, ULONG reserved) 1070 + { 1071 + icmp_send_echo_test_apc_xp(context); 1072 + ok(io_status->Status == 0, "Got IO Status 0x%08lx\n", io_status->Status); 1073 + ok(io_status->Information == sizeof(ICMP_ECHO_REPLY) + 32 /* sizeof(senddata) */, 1074 + "Got IO Information %Iu\n", io_status->Information); 918 1075 } 919 1076 920 1077 static void testIcmpSendEcho(void) 921 1078 { 1079 + /* The APC's signature is different pre-Vista */ 1080 + const PIO_APC_ROUTINE apc = broken(LOBYTE(LOWORD(GetVersion())) < 6) 1081 + ? (PIO_APC_ROUTINE)icmp_send_echo_test_apc_xp 1082 + : icmp_send_echo_test_apc; 922 1083 HANDLE icmp; 923 1084 char senddata[32], replydata[sizeof(senddata) + sizeof(ICMP_ECHO_REPLY)]; 1085 + char replydata2[sizeof(replydata) + sizeof(IO_STATUS_BLOCK)]; 924 1086 DWORD ret, error, replysz = sizeof(replydata); 925 1087 IPAddr address; 1088 + ICMP_ECHO_REPLY *reply; 1089 + HANDLE event; 1090 + INT i; 926 1091 927 - if (!pIcmpSendEcho || !pIcmpCreateFile) 928 - { 929 - win_skip( "IcmpSendEcho or IcmpCreateFile not available\n" ); 930 - return; 931 - } 932 1092 memset(senddata, 0, sizeof(senddata)); 933 1093 934 1094 address = htonl(INADDR_LOOPBACK); 935 1095 SetLastError(0xdeadbeef); 936 - ret = pIcmpSendEcho(INVALID_HANDLE_VALUE, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000); 1096 + ret = IcmpSendEcho(INVALID_HANDLE_VALUE, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000); 937 1097 error = GetLastError(); 938 1098 ok (!ret, "IcmpSendEcho succeeded unexpectedly\n"); 939 - todo_wine 940 1099 ok (error == ERROR_INVALID_PARAMETER 941 1100 || broken(error == ERROR_INVALID_HANDLE) /* <= 2003 */, 942 - "expected 87, got %d\n", error); 1101 + "expected 87, got %ld\n", error); 943 1102 944 - icmp = pIcmpCreateFile(); 945 - if (icmp == INVALID_HANDLE_VALUE) 946 - { 947 - error = GetLastError(); 948 - if (error == ERROR_ACCESS_DENIED) 949 - { 950 - skip ("ICMP is not available.\n"); 951 - return; 952 - } 953 - } 954 - ok (icmp != INVALID_HANDLE_VALUE, "IcmpCreateFile failed unexpectedly with error %d\n", GetLastError()); 1103 + address = htonl(INADDR_LOOPBACK); 1104 + SetLastError(0xdeadbeef); 1105 + ret = IcmpSendEcho2(INVALID_HANDLE_VALUE, NULL, NULL, NULL, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000); 1106 + error = GetLastError(); 1107 + ok (!ret, "IcmpSendEcho2 succeeded unexpectedly\n"); 1108 + ok (error == ERROR_INVALID_PARAMETER 1109 + || broken(error == ERROR_INVALID_HANDLE) /* <= 2003 */, 1110 + "expected 87, got %ld\n", error); 1111 + 1112 + icmp = IcmpCreateFile(); 1113 + ok (icmp != INVALID_HANDLE_VALUE, "IcmpCreateFile failed unexpectedly with error %ld\n", GetLastError()); 955 1114 956 1115 address = 0; 957 1116 SetLastError(0xdeadbeef); 958 - ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000); 1117 + ret = IcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000); 959 1118 error = GetLastError(); 960 1119 ok (!ret, "IcmpSendEcho succeeded unexpectedly\n"); 961 1120 ok (error == ERROR_INVALID_NETNAME 962 1121 || broken(error == IP_BAD_DESTINATION) /* <= 2003 */, 963 - "expected 1214, got %d\n", error); 1122 + "expected 1214, got %ld\n", error); 964 1123 965 1124 address = htonl(INADDR_LOOPBACK); 966 1125 if (0) /* crashes in XP */ 967 1126 { 968 - ret = pIcmpSendEcho(icmp, address, NULL, sizeof(senddata), NULL, replydata, replysz, 1000); 1127 + ret = IcmpSendEcho(icmp, address, NULL, sizeof(senddata), NULL, replydata, replysz, 1000); 969 1128 ok (!ret, "IcmpSendEcho succeeded unexpectedly\n"); 970 1129 } 971 1130 972 1131 SetLastError(0xdeadbeef); 973 - ret = pIcmpSendEcho(icmp, address, senddata, 0, NULL, replydata, replysz, 1000); 1132 + ret = IcmpSendEcho(icmp, address, senddata, 0, NULL, replydata, replysz, 1000); 974 1133 error = GetLastError(); 975 - ok (ret, "IcmpSendEcho failed unexpectedly with error %d\n", error); 1134 + if (!ret && error == ERROR_ACCESS_DENIED) 1135 + { 1136 + skip( "ICMP is not available.\n" ); 1137 + return; 1138 + } 1139 + ok (ret, "IcmpSendEcho failed unexpectedly with error %ld\n", error); 976 1140 977 1141 SetLastError(0xdeadbeef); 978 - ret = pIcmpSendEcho(icmp, address, NULL, 0, NULL, replydata, replysz, 1000); 1142 + ret = IcmpSendEcho(icmp, address, NULL, 0, NULL, replydata, replysz, 1000); 979 1143 error = GetLastError(); 980 - ok (ret, "IcmpSendEcho failed unexpectedly with error %d\n", error); 1144 + ok (ret, "IcmpSendEcho failed unexpectedly with error %ld\n", error); 981 1145 982 - if (0) /* crashes in wine, remove IF when fixed */ 983 - { 984 1146 SetLastError(0xdeadbeef); 985 - ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, NULL, replysz, 1000); 1147 + ret = IcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, NULL, replysz, 1000); 986 1148 error = GetLastError(); 987 1149 ok (!ret, "IcmpSendEcho succeeded unexpectedly\n"); 988 - ok (error == ERROR_INVALID_PARAMETER, "expected 87, got %d\n", error); 989 - } 1150 + ok (error == ERROR_INVALID_PARAMETER, "expected 87, got %ld\n", error); 990 1151 991 1152 SetLastError(0xdeadbeef); 992 - ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, 0, 1000); 1153 + ret = IcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, 0, 1000); 993 1154 error = GetLastError(); 994 1155 ok (!ret, "IcmpSendEcho succeeded unexpectedly\n"); 995 - todo_wine 996 1156 ok (error == ERROR_INVALID_PARAMETER 997 1157 || broken(error == ERROR_INSUFFICIENT_BUFFER) /* <= 2003 */, 998 - "expected 87, got %d\n", error); 1158 + "expected 87, got %ld\n", error); 999 1159 1000 1160 SetLastError(0xdeadbeef); 1001 - ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, NULL, 0, 1000); 1161 + ret = IcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, NULL, 0, 1000); 1002 1162 error = GetLastError(); 1003 1163 ok (!ret, "IcmpSendEcho succeeded unexpectedly\n"); 1004 - todo_wine 1005 1164 ok (error == ERROR_INVALID_PARAMETER 1006 1165 || broken(error == ERROR_INSUFFICIENT_BUFFER) /* <= 2003 */, 1007 - "expected 87, got %d\n", error); 1166 + "expected 87, got %ld\n", error); 1008 1167 1009 1168 SetLastError(0xdeadbeef); 1010 1169 replysz = sizeof(replydata) - 1; 1011 - ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000); 1170 + ret = IcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000); 1012 1171 error = GetLastError(); 1013 - todo_wine { 1014 1172 ok (!ret, "IcmpSendEcho succeeded unexpectedly\n"); 1015 1173 ok (error == IP_GENERAL_FAILURE 1016 1174 || broken(error == IP_BUF_TOO_SMALL) /* <= 2003 */, 1017 - "expected 11050, got %d\n", error); 1018 - } 1175 + "expected 11050, got %ld\n", error); 1019 1176 1020 1177 SetLastError(0xdeadbeef); 1021 1178 replysz = sizeof(ICMP_ECHO_REPLY); 1022 - ret = pIcmpSendEcho(icmp, address, senddata, 0, NULL, replydata, replysz, 1000); 1179 + ret = IcmpSendEcho(icmp, address, senddata, 0, NULL, replydata, replysz, 1000); 1023 1180 error = GetLastError(); 1024 - todo_wine 1025 - ok (ret, "IcmpSendEcho failed unexpectedly with error %d\n", error); 1181 + ok (ret, "IcmpSendEcho failed unexpectedly with error %ld\n", error); 1026 1182 1027 1183 SetLastError(0xdeadbeef); 1028 1184 replysz = sizeof(ICMP_ECHO_REPLY) + ICMP_MINLEN; 1029 - ret = pIcmpSendEcho(icmp, address, senddata, ICMP_MINLEN, NULL, replydata, replysz, 1000); 1185 + ret = IcmpSendEcho(icmp, address, senddata, ICMP_MINLEN, NULL, replydata, replysz, 1000); 1030 1186 error = GetLastError(); 1031 - ok (ret, "IcmpSendEcho failed unexpectedly with error %d\n", error); 1187 + ok (ret, "IcmpSendEcho failed unexpectedly with error %ld\n", error); 1032 1188 1033 1189 SetLastError(0xdeadbeef); 1034 1190 replysz = sizeof(ICMP_ECHO_REPLY) + ICMP_MINLEN; 1035 - ret = pIcmpSendEcho(icmp, address, senddata, ICMP_MINLEN + 1, NULL, replydata, replysz, 1000); 1191 + ret = IcmpSendEcho(icmp, address, senddata, ICMP_MINLEN + 1, NULL, replydata, replysz, 1000); 1036 1192 error = GetLastError(); 1037 - todo_wine 1038 1193 ok (!ret, "IcmpSendEcho succeeded unexpectedly\n"); 1039 - todo_wine 1040 1194 ok (error == IP_GENERAL_FAILURE 1041 1195 || broken(error == IP_BUF_TOO_SMALL) /* <= 2003 */, 1042 - "expected 11050, got %d\n", error); 1196 + "expected 11050, got %ld\n", error); 1043 1197 1044 1198 SetLastError(0xdeadbeef); 1045 - ret = pIcmpSendEcho(icmp, address, senddata, ICMP_MINLEN, NULL, replydata, replysz - 1, 1000); 1199 + ret = IcmpSendEcho(icmp, address, senddata, ICMP_MINLEN, NULL, replydata, replysz - 1, 1000); 1046 1200 error = GetLastError(); 1047 1201 ok (!ret, "IcmpSendEcho succeeded unexpectedly\n"); 1048 - todo_wine 1049 1202 ok (error == IP_GENERAL_FAILURE 1050 1203 || broken(error == IP_BUF_TOO_SMALL) /* <= 2003 */, 1051 - "expected 11050, got %d\n", error); 1204 + "expected 11050, got %ld\n", error); 1052 1205 1053 1206 /* in windows >= vista the timeout can't be invalid */ 1054 1207 SetLastError(0xdeadbeef); 1055 1208 replysz = sizeof(replydata); 1056 - ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 0); 1209 + ret = IcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 0); 1057 1210 error = GetLastError(); 1058 - if (!ret) ok(error == ERROR_INVALID_PARAMETER, "expected 87, got %d\n", error); 1211 + if (!ret) ok(error == ERROR_INVALID_PARAMETER, "expected 87, got %ld\n", error); 1059 1212 1060 1213 SetLastError(0xdeadbeef); 1061 - ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, -1); 1214 + ret = IcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, -1); 1062 1215 error = GetLastError(); 1063 - if (!ret) ok(error == ERROR_INVALID_PARAMETER, "expected 87, got %d\n", error); 1216 + if (!ret) ok(error == ERROR_INVALID_PARAMETER, "expected 87, got %ld\n", error); 1064 1217 1065 1218 /* real ping test */ 1066 1219 SetLastError(0xdeadbeef); 1067 1220 address = htonl(INADDR_LOOPBACK); 1068 - ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000); 1221 + ret = IcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000); 1069 1222 error = GetLastError(); 1070 - if (ret) 1223 + if (!ret) 1224 + { 1225 + skip ("Failed to ping with error %ld, is lo interface down?.\n", error); 1226 + } 1227 + else if (winetest_debug > 1) 1071 1228 { 1072 1229 PICMP_ECHO_REPLY pong = (PICMP_ECHO_REPLY) replydata; 1073 1230 trace ("send addr : %s\n", ntoa(address)); 1074 1231 trace ("reply addr : %s\n", ntoa(pong->Address)); 1075 - trace ("reply size : %u\n", replysz); 1076 - trace ("roundtrip : %u ms\n", pong->RoundTripTime); 1077 - trace ("status : %u\n", pong->Status); 1232 + trace ("reply size : %lu\n", replysz); 1233 + trace ("roundtrip : %lu ms\n", pong->RoundTripTime); 1234 + trace ("status : %lu\n", pong->Status); 1078 1235 trace ("recv size : %u\n", pong->DataSize); 1079 1236 trace ("ttl : %u\n", pong->Options.Ttl); 1080 1237 trace ("flags : 0x%x\n", pong->Options.Flags); 1081 1238 } 1239 + 1240 + /* check reply data */ 1241 + SetLastError(0xdeadbeef); 1242 + address = htonl(INADDR_LOOPBACK); 1243 + for (i = 0; i < ARRAY_SIZE(senddata); i++) senddata[i] = i & 0xff; 1244 + ret = IcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000); 1245 + error = GetLastError(); 1246 + reply = (ICMP_ECHO_REPLY *)replydata; 1247 + ok(ret, "IcmpSendEcho failed unexpectedly\n"); 1248 + ok(error == NO_ERROR, "Expect last error:0x%08x, got:0x%08lx\n", NO_ERROR, error); 1249 + ok(INADDR_LOOPBACK == ntohl(reply->Address), "Address mismatch, expect:%s, got: %s\n", ntoa(INADDR_LOOPBACK), 1250 + ntoa(reply->Address)); 1251 + ok(reply->Status == IP_SUCCESS, "Expect status:0x%08x, got:0x%08lx\n", IP_SUCCESS, reply->Status); 1252 + ok(reply->DataSize == sizeof(senddata), "Got size:%d\n", reply->DataSize); 1253 + ok(!memcmp(senddata, reply->Data, min(sizeof(senddata), reply->DataSize)), "Data mismatch\n"); 1254 + 1255 + 1256 + /* 1257 + * IcmpSendEcho2 1258 + */ 1259 + address = 0; 1260 + replysz = sizeof(replydata2); 1261 + memset(senddata, 0, sizeof(senddata)); 1262 + 1263 + SetLastError(0xdeadbeef); 1264 + ret = IcmpSendEcho2(icmp, NULL, NULL, NULL, address, senddata, sizeof(senddata), NULL, replydata2, replysz, 1000); 1265 + error = GetLastError(); 1266 + ok(!ret, "IcmpSendEcho2 succeeded unexpectedly\n"); 1267 + ok(error == ERROR_INVALID_NETNAME 1268 + || broken(error == IP_BAD_DESTINATION) /* <= 2003 */, 1269 + "expected 1214, got %ld\n", error); 1270 + 1271 + event = CreateEventW(NULL, FALSE, FALSE, NULL); 1272 + ok(event != NULL, "CreateEventW failed unexpectedly with error %ld\n", GetLastError()); 1273 + 1274 + SetLastError(0xdeadbeef); 1275 + ret = IcmpSendEcho2(icmp, event, NULL, NULL, address, senddata, sizeof(senddata), NULL, replydata2, replysz, 1000); 1276 + error = GetLastError(); 1277 + ok(!ret, "IcmpSendEcho2 returned success unexpectedly\n"); 1278 + ok(error == ERROR_INVALID_NETNAME 1279 + || broken(error == ERROR_IO_PENDING) /* <= 2003 */, 1280 + "Got last error: 0x%08lx\n", error); 1281 + if (error == ERROR_IO_PENDING) 1282 + { 1283 + ret = WaitForSingleObjectEx(event, 2000, TRUE); 1284 + ok(ret == WAIT_OBJECT_0, "WaitForSingleObjectEx failed unexpectedly with %lu\n", ret); 1285 + } 1286 + 1287 + address = htonl(INADDR_LOOPBACK); 1288 + SetLastError(0xdeadbeef); 1289 + ret = IcmpSendEcho2(icmp, NULL, NULL, NULL, address, senddata, sizeof(senddata), NULL, NULL, replysz, 1000); 1290 + error = GetLastError(); 1291 + ok(!ret, "IcmpSendEcho2 succeeded unexpectedly\n"); 1292 + ok(error == ERROR_INVALID_PARAMETER 1293 + || broken(error == ERROR_NOACCESS) /* <= 2003 */, 1294 + "expected 87, got %ld\n", error); 1295 + 1296 + SetLastError(0xdeadbeef); 1297 + ret = IcmpSendEcho2(icmp, event, NULL, NULL, address, senddata, sizeof(senddata), NULL, NULL, replysz, 1000); 1298 + error = GetLastError(); 1299 + ok(!ret, "IcmpSendEcho2 succeeded unexpectedly\n"); 1300 + ok(error == ERROR_INVALID_PARAMETER 1301 + || broken(error == ERROR_NOACCESS) /* <= 2003 */, 1302 + "expected 87, got %ld\n", error); 1303 + ok(WaitForSingleObjectEx(event, 0, TRUE) == WAIT_TIMEOUT, "Event was unexpectedly signalled.\n"); 1304 + 1305 + SetLastError(0xdeadbeef); 1306 + ret = IcmpSendEcho2(icmp, NULL, NULL, NULL, address, senddata, sizeof(senddata), NULL, replydata2, 0, 1000); 1307 + error = GetLastError(); 1308 + ok(!ret, "IcmpSendEcho2 succeeded unexpectedly\n"); 1309 + ok(error == ERROR_INVALID_PARAMETER 1310 + || broken(error == ERROR_INSUFFICIENT_BUFFER) /* <= 2003 */, 1311 + "expected 87, got %ld\n", error); 1312 + 1313 + SetLastError(0xdeadbeef); 1314 + ret = IcmpSendEcho2(icmp, event, NULL, NULL, address, senddata, sizeof(senddata), NULL, replydata2, 0, 1000); 1315 + error = GetLastError(); 1316 + ok(!ret, "IcmpSendEcho2 succeeded unexpectedly\n"); 1317 + ok(error == ERROR_INVALID_PARAMETER 1318 + || broken(error == ERROR_INSUFFICIENT_BUFFER) /* <= 2003 */, 1319 + "expected 87, got %ld\n", error); 1320 + ok(WaitForSingleObjectEx(event, 0, TRUE) == WAIT_TIMEOUT, "Event was unexpectedly signalled.\n"); 1321 + 1322 + SetLastError(0xdeadbeef); 1323 + ret = IcmpSendEcho2(icmp, NULL, NULL, NULL, address, senddata, sizeof(senddata), NULL, NULL, 0, 1000); 1324 + error = GetLastError(); 1325 + ok(!ret, "IcmpSendEcho2 succeeded unexpectedly\n"); 1326 + ok(error == ERROR_INVALID_PARAMETER 1327 + || broken(error == ERROR_INSUFFICIENT_BUFFER) /* <= 2003 */, 1328 + "expected 87, got %ld\n", error); 1329 + 1330 + SetLastError(0xdeadbeef); 1331 + ret = IcmpSendEcho2(icmp, event, NULL, NULL, address, senddata, sizeof(senddata), NULL, NULL, 0, 1000); 1332 + error = GetLastError(); 1333 + ok(!ret, "IcmpSendEcho2 succeeded unexpectedly\n"); 1334 + ok(error == ERROR_INVALID_PARAMETER 1335 + || broken(error == ERROR_INSUFFICIENT_BUFFER) /* <= 2003 */, 1336 + "expected 87, got %ld\n", error); 1337 + ok(WaitForSingleObjectEx(event, 0, TRUE) == WAIT_TIMEOUT, "Event was unexpectedly signalled.\n"); 1338 + 1339 + /* synchronous tests */ 1340 + #ifdef __REACTOS__ 1341 + if (LOBYTE(LOWORD(GetVersion())) >= 6) { 1342 + #endif 1343 + SetLastError(0xdeadbeef); 1344 + address = htonl(INADDR_LOOPBACK); 1345 + replysz = sizeof(ICMP_ECHO_REPLY) + sizeof(IO_STATUS_BLOCK); 1346 + ret = IcmpSendEcho2(icmp, NULL, NULL, NULL, address, senddata, 0, NULL, replydata2, replysz, 1000); 1347 + ok(ret, "IcmpSendEcho2 failed unexpectedly with error %ld\n", GetLastError()); 1348 + 1349 + SetLastError(0xdeadbeef); 1350 + ret = IcmpSendEcho2(icmp, NULL, NULL, NULL, address, NULL, 0, NULL, replydata2, replysz, 1000); 1351 + ok(ret, "IcmpSendEcho2 failed unexpectedly with error %ld\n", GetLastError()); 1352 + 1353 + SetLastError(0xdeadbeef); 1354 + ret = IcmpSendEcho2(icmp, NULL, NULL, NULL, address, senddata, 0, NULL, replydata2, replysz, 1000); 1355 + ok(ret, "IcmpSendEcho2 failed unexpectedly with error %ld\n", GetLastError()); 1356 + 1357 + SetLastError(0xdeadbeef); 1358 + replysz = sizeof(ICMP_ECHO_REPLY) + sizeof(IO_STATUS_BLOCK) + ICMP_MINLEN; 1359 + ret = IcmpSendEcho2(icmp, NULL, NULL, NULL, address, senddata, ICMP_MINLEN, NULL, replydata2, replysz, 1000); 1360 + ok(ret, "IcmpSendEcho2 failed unexpectedly with error %ld\n", GetLastError()); 1361 + 1362 + SetLastError(0xdeadbeef); 1363 + replysz = sizeof(replydata2); 1364 + ret = IcmpSendEcho2(icmp, NULL, NULL, NULL, address, senddata, sizeof(senddata), NULL, replydata2, replysz, 1000); 1365 + if (!ret) 1366 + { 1367 + error = GetLastError(); 1368 + skip("Failed to ping with error %ld, is lo interface down?\n", error); 1369 + } 1370 + else if (winetest_debug > 1) 1371 + { 1372 + reply = (ICMP_ECHO_REPLY*)replydata2; 1373 + trace("send addr : %s\n", ntoa(address)); 1374 + trace("reply addr : %s\n", ntoa(reply->Address)); 1375 + trace("reply size : %lu\n", replysz); 1376 + trace("roundtrip : %lu ms\n", reply->RoundTripTime); 1377 + trace("status : %lu\n", reply->Status); 1378 + trace("recv size : %u\n", reply->DataSize); 1379 + trace("ttl : %u\n", reply->Options.Ttl); 1380 + trace("flags : 0x%x\n", reply->Options.Flags); 1381 + } 1382 + 1383 + SetLastError(0xdeadbeef); 1384 + for (i = 0; i < ARRAY_SIZE(senddata); i++) senddata[i] = i & 0xff; 1385 + ret = IcmpSendEcho2(icmp, NULL, NULL, NULL, address, senddata, sizeof(senddata), NULL, replydata2, replysz, 1000); 1386 + error = GetLastError(); 1387 + reply = (ICMP_ECHO_REPLY*)replydata2; 1388 + ok(ret, "IcmpSendEcho2 failed unexpectedly\n"); 1389 + ok(error == NO_ERROR, "Expect last error: 0x%08x, got: 0x%08lx\n", NO_ERROR, error); 1390 + ok(ntohl(reply->Address) == INADDR_LOOPBACK, "Address mismatch, expect: %s, got: %s\n", ntoa(INADDR_LOOPBACK), 1391 + ntoa(reply->Address)); 1392 + ok(reply->Status == IP_SUCCESS, "Expect status: 0x%08x, got: 0x%08lx\n", IP_SUCCESS, reply->Status); 1393 + ok(reply->DataSize == sizeof(senddata), "Got size: %d\n", reply->DataSize); 1394 + ok(!memcmp(senddata, reply->Data, min(sizeof(senddata), reply->DataSize)), "Data mismatch\n"); 1395 + #ifdef __REACTOS__ 1396 + } 1397 + #endif 1398 + 1399 + /* asynchronous tests with event */ 1400 + SetLastError(0xdeadbeef); 1401 + replysz = sizeof(replydata2); 1402 + address = htonl(INADDR_LOOPBACK); 1403 + memset(senddata, 0, sizeof(senddata)); 1404 + ret = IcmpSendEcho2(icmp, event, NULL, NULL, address, senddata, sizeof(senddata), NULL, replydata2, replysz, 1000); 1405 + error = GetLastError(); 1406 + if (!ret && error != ERROR_IO_PENDING) 1407 + { 1408 + skip("Failed to ping with error %ld, is lo interface down?\n", error); 1409 + } 1082 1410 else 1083 1411 { 1084 - skip ("Failed to ping with error %d, is lo interface down?.\n", error); 1412 + ok(!ret, "IcmpSendEcho2 returned success unexpectedly\n"); 1413 + ok(error == ERROR_IO_PENDING, "Expect last error: 0x%08x, got: 0x%08lx\n", ERROR_IO_PENDING, error); 1414 + ret = WaitForSingleObjectEx(event, 2000, TRUE); 1415 + ok(ret == WAIT_OBJECT_0, "WaitForSingleObjectEx failed unexpectedly with %lu\n", ret); 1416 + reply = (ICMP_ECHO_REPLY*)replydata2; 1417 + ok(ntohl(reply->Address) == INADDR_LOOPBACK, "Address mismatch, expect: %s, got: %s\n", ntoa(INADDR_LOOPBACK), 1418 + ntoa(reply->Address)); 1419 + #ifdef __REACTOS__ 1420 + if (LOBYTE(LOWORD(GetVersion())) >= 6) { 1421 + #endif 1422 + ok(reply->Status == IP_SUCCESS, "Expect status: 0x%08x, got: 0x%08lx\n", IP_SUCCESS, reply->Status); 1423 + ok(reply->DataSize == sizeof(senddata), "Got size: %d\n", reply->DataSize); 1424 + #ifdef __REACTOS__ 1425 + } 1426 + #endif 1427 + if (winetest_debug > 1) 1428 + { 1429 + reply = (ICMP_ECHO_REPLY*)replydata2; 1430 + trace("send addr : %s\n", ntoa(address)); 1431 + trace("reply addr : %s\n", ntoa(reply->Address)); 1432 + trace("reply size : %lu\n", replysz); 1433 + trace("roundtrip : %lu ms\n", reply->RoundTripTime); 1434 + trace("status : %lu\n", reply->Status); 1435 + trace("recv size : %u\n", reply->DataSize); 1436 + trace("ttl : %u\n", reply->Options.Ttl); 1437 + trace("flags : 0x%x\n", reply->Options.Flags); 1438 + } 1439 + } 1440 + 1441 + SetLastError(0xdeadbeef); 1442 + for (i = 0; i < ARRAY_SIZE(senddata); i++) senddata[i] = i & 0xff; 1443 + ret = IcmpSendEcho2(icmp, event, NULL, NULL, address, senddata, sizeof(senddata), NULL, replydata2, replysz, 1000); 1444 + error = GetLastError(); 1445 + ok(!ret, "IcmpSendEcho2 returned success unexpectedly\n"); 1446 + ok(error == ERROR_IO_PENDING, "Expect last error: 0x%08x, got: 0x%08lx\n", ERROR_IO_PENDING, error); 1447 + ret = WaitForSingleObjectEx(event, 2000, TRUE); 1448 + ok(ret == WAIT_OBJECT_0, "WaitForSingleObjectEx failed unexpectedly with %lu\n", ret); 1449 + reply = (ICMP_ECHO_REPLY*)replydata2; 1450 + ok(ntohl(reply->Address) == INADDR_LOOPBACK, "Address mismatch, expect: %s, got: %s\n", ntoa(INADDR_LOOPBACK), 1451 + ntoa(reply->Address)); 1452 + #ifdef __REACTOS__ 1453 + if (LOBYTE(LOWORD(GetVersion())) >= 6) { 1454 + #endif 1455 + ok(reply->Status == IP_SUCCESS, "Expect status: 0x%08x, got: 0x%08lx\n", IP_SUCCESS, reply->Status); 1456 + ok(reply->DataSize == sizeof(senddata), "Got size: %d\n", reply->DataSize); 1457 + #ifdef __REACTOS__ 1458 + } 1459 + #endif 1460 + /* pre-Vista, reply->Data is an offset; otherwise it's a pointer, so hardcode the offset */ 1461 + ok(!memcmp(senddata, reply + 1, min(sizeof(senddata), reply->DataSize)), "Data mismatch\n"); 1462 + 1463 + CloseHandle(event); 1464 + 1465 + /* asynchronous tests with APC */ 1466 + SetLastError(0xdeadbeef); 1467 + replysz = sizeof(replydata2) + 10; 1468 + address = htonl(INADDR_LOOPBACK); 1469 + for (i = 0; i < ARRAY_SIZE(senddata); i++) senddata[i] = ~i & 0xff; 1470 + icmp_send_echo_test_apc_expect = TRUE; 1471 + /* 1472 + NOTE: Supplying both event and apc has varying behavior across Windows versions, so not tested. 1473 + */ 1474 + #if defined(__REACTOS__) && defined(_MSC_VER) 1475 + /* The call to IcmpSendEcho2() below with the invalid APC context causes 1476 + * stack corruption on WS03 and ReactOS when compiled with MSVC but not GCC. */ 1477 + if (LOBYTE(LOWORD(GetVersion())) >= 6) { 1478 + #endif 1479 + ret = IcmpSendEcho2(icmp, NULL, apc, (void*)0xdeadc0de, address, senddata, sizeof(senddata), NULL, replydata2, replysz, 1000); 1480 + error = GetLastError(); 1481 + ok(!ret, "IcmpSendEcho2 returned success unexpectedly\n"); 1482 + ok(error == ERROR_IO_PENDING, "Expect last error: 0x%08x, got: 0x%08lx\n", ERROR_IO_PENDING, error); 1483 + SleepEx(200, TRUE); 1484 + SleepEx(0, TRUE); 1485 + ok(icmp_send_echo_test_apc_expect == FALSE, "APC was not executed!\n"); 1486 + reply = (ICMP_ECHO_REPLY*)replydata2; 1487 + ok(ntohl(reply->Address) == INADDR_LOOPBACK, "Address mismatch, expect: %s, got: %s\n", ntoa(INADDR_LOOPBACK), 1488 + ntoa(reply->Address)); 1489 + ok(reply->Status == IP_SUCCESS, "Expect status: 0x%08x, got: 0x%08lx\n", IP_SUCCESS, reply->Status); 1490 + ok(reply->DataSize == sizeof(senddata), "Got size: %d\n", reply->DataSize); 1491 + /* pre-Vista, reply->Data is an offset; otherwise it's a pointer, so hardcode the offset */ 1492 + ok(!memcmp(senddata, reply + 1, min(sizeof(senddata), reply->DataSize)), "Data mismatch\n"); 1493 + #if defined(__REACTOS__) && defined(_MSC_VER) 1494 + } 1495 + #endif 1496 + 1497 + IcmpCloseHandle(icmp); 1498 + } 1499 + 1500 + static void testIcmpParseReplies( void ) 1501 + { 1502 + ICMP_ECHO_REPLY reply = { 0 }; 1503 + DWORD ret; 1504 + 1505 + SetLastError( 0xdeadbeef ); 1506 + ret = IcmpParseReplies( &reply, sizeof(reply) ); 1507 + ok( ret == 0, "ret %ld\n", ret ); 1508 + ok( GetLastError() == 0, "gle %ld\n", GetLastError() ); 1509 + 1510 + reply.Status = 12345; 1511 + SetLastError( 0xdeadbeef ); 1512 + ret = IcmpParseReplies( &reply, sizeof(reply) ); 1513 + ok( ret == 0, "ret %ld\n", ret ); 1514 + ok( GetLastError() == 12345, "gle %ld\n", GetLastError() ); 1515 + ok( reply.Status == 12345, "status %ld\n", reply.Status ); 1516 + 1517 + reply.Reserved = 1; 1518 + SetLastError( 0xdeadbeef ); 1519 + ret = IcmpParseReplies( &reply, sizeof(reply) ); 1520 + ok( ret == 1, "ret %ld\n", ret ); 1521 + ok( GetLastError() == 0xdeadbeef, "gle %ld\n", GetLastError() ); 1522 + ok( reply.Status == 12345, "status %ld\n", reply.Status ); 1523 + ok( !reply.Reserved, "reserved %d\n", reply.Reserved ); 1524 + 1525 + #if defined(__REACTOS__) && defined(_MSC_VER) 1526 + /* This crashes on WS03 when compiled with MSVC. It does work on ReactOS. */ 1527 + if (LOBYTE(LOWORD(GetVersion())) >= 6) { 1528 + #endif 1529 + reply.Reserved = 3; 1530 + SetLastError( 0xdeadbeef ); 1531 + ret = IcmpParseReplies( &reply, sizeof(reply) ); 1532 + ok( ret == 3, "ret %ld\n", ret ); 1533 + ok( GetLastError() == 0xdeadbeef, "gle %ld\n", GetLastError() ); 1534 + ok( reply.Status == 12345, "status %ld\n", reply.Status ); 1535 + ok( !reply.Reserved, "reserved %d\n", reply.Reserved ); 1536 + #if defined(__REACTOS__) && defined(_MSC_VER) 1085 1537 } 1538 + #endif 1086 1539 } 1087 1540 1088 - /* 1089 - still-to-be-tested NT4-onward functions: 1090 - CreateIpForwardEntry 1091 - DeleteIpForwardEntry 1092 - CreateIpNetEntry 1093 - DeleteIpNetEntry 1094 - GetFriendlyIfIndex 1095 - GetRTTAndHopCount 1096 - SetIfEntry 1097 - SetIpForwardEntry 1098 - SetIpNetEntry 1099 - SetIpStatistics 1100 - SetIpTTL 1101 - */ 1102 1541 static void testWinNT4Functions(void) 1103 1542 { 1104 1543 testGetNumberOfInterfaces(); ··· 1118 1557 testGetUdpTable(); 1119 1558 testSetTcpEntry(); 1120 1559 testIcmpSendEcho(); 1560 + testIcmpParseReplies(); 1121 1561 } 1122 1562 1123 1563 static void testGetInterfaceInfo(void) 1124 1564 { 1125 - if (pGetInterfaceInfo) { 1126 1565 DWORD apiReturn; 1127 - ULONG len = 0; 1566 + ULONG len = 0, i; 1128 1567 1129 - apiReturn = pGetInterfaceInfo(NULL, NULL); 1568 + apiReturn = GetInterfaceInfo(NULL, NULL); 1130 1569 if (apiReturn == ERROR_NOT_SUPPORTED) { 1131 - skip("GetInterfaceInfo is not supported\n"); 1132 - return; 1570 + skip("GetInterfaceInfo is not supported\n"); 1571 + return; 1133 1572 } 1134 1573 ok(apiReturn == ERROR_INVALID_PARAMETER, 1135 - "GetInterfaceInfo returned %d, expected ERROR_INVALID_PARAMETER\n", 1136 - apiReturn); 1137 - apiReturn = pGetInterfaceInfo(NULL, &len); 1574 + "GetInterfaceInfo returned %ld, expected ERROR_INVALID_PARAMETER\n", 1575 + apiReturn); 1576 + apiReturn = GetInterfaceInfo(NULL, &len); 1138 1577 ok(apiReturn == ERROR_INSUFFICIENT_BUFFER, 1139 - "GetInterfaceInfo returned %d, expected ERROR_INSUFFICIENT_BUFFER\n", 1140 - apiReturn); 1578 + "GetInterfaceInfo returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n", 1579 + apiReturn); 1141 1580 if (apiReturn == ERROR_INSUFFICIENT_BUFFER) { 1142 - PIP_INTERFACE_INFO buf = HeapAlloc(GetProcessHeap(), 0, len); 1581 + PIP_INTERFACE_INFO buf = malloc(len); 1143 1582 1144 - apiReturn = pGetInterfaceInfo(buf, &len); 1145 - ok(apiReturn == NO_ERROR, 1146 - "GetInterfaceInfo(buf, &dwSize) returned %d, expected NO_ERROR\n", 1147 - apiReturn); 1148 - HeapFree(GetProcessHeap(), 0, buf); 1583 + apiReturn = GetInterfaceInfo(buf, &len); 1584 + ok(apiReturn == NO_ERROR, 1585 + "GetInterfaceInfo(buf, &dwSize) returned %ld, expected NO_ERROR\n", 1586 + apiReturn); 1587 + 1588 + for (i = 0; i < buf->NumAdapters; i++) 1589 + { 1590 + MIB_IFROW row = { .dwIndex = buf->Adapter[i].Index }; 1591 + GetIfEntry( &row ); 1592 + #ifdef __REACTOS__ 1593 + if (LOBYTE(LOWORD(GetVersion())) >= 6) { 1594 + #endif 1595 + ok( !wcscmp( buf->Adapter[i].Name, row.wszName ), "got %s vs %s\n", 1596 + debugstr_w( buf->Adapter[i].Name ), debugstr_w( row.wszName ) ); 1597 + #ifdef __REACTOS__ 1598 + } 1599 + #endif 1600 + ok( row.dwType != IF_TYPE_SOFTWARE_LOOPBACK, "got loopback\n" ); 1601 + } 1602 + free(buf); 1149 1603 } 1150 - } 1151 1604 } 1152 1605 1153 1606 static void testGetAdaptersInfo(void) 1154 1607 { 1155 - if (pGetAdaptersInfo) { 1156 - DWORD apiReturn; 1608 + IP_ADAPTER_INFO *ptr, *buf; 1609 + NET_LUID luid; 1610 + GUID guid; 1611 + char name[ARRAY_SIZE(ptr->AdapterName)]; 1612 + DWORD err; 1157 1613 ULONG len = 0; 1614 + MIB_IFROW row; 1615 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 1616 + if(!ConvertInterfaceIndexToLuid || !ConvertInterfaceLuidToGuid) { 1617 + skip("Missing APIs!\n"); 1618 + return; 1619 + } 1620 + #endif 1158 1621 1159 - apiReturn = pGetAdaptersInfo(NULL, NULL); 1160 - if (apiReturn == ERROR_NOT_SUPPORTED) { 1161 - skip("GetAdaptersInfo is not supported\n"); 1162 - return; 1163 - } 1164 - ok(apiReturn == ERROR_INVALID_PARAMETER, 1165 - "GetAdaptersInfo returned %d, expected ERROR_INVALID_PARAMETER\n", 1166 - apiReturn); 1167 - apiReturn = pGetAdaptersInfo(NULL, &len); 1168 - ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_BUFFER_OVERFLOW, 1169 - "GetAdaptersInfo returned %d, expected ERROR_NO_DATA or ERROR_BUFFER_OVERFLOW\n", 1170 - apiReturn); 1171 - if (apiReturn == ERROR_NO_DATA) 1172 - ; /* no adapter's, that's okay */ 1173 - else if (apiReturn == ERROR_BUFFER_OVERFLOW) { 1174 - PIP_ADAPTER_INFO ptr, buf = HeapAlloc(GetProcessHeap(), 0, len); 1622 + err = GetAdaptersInfo( NULL, NULL ); 1623 + ok( err == ERROR_INVALID_PARAMETER, "got %ld\n", err ); 1624 + err = GetAdaptersInfo( NULL, &len ); 1625 + ok( err == ERROR_NO_DATA || err == ERROR_BUFFER_OVERFLOW, "got %ld\n", err ); 1626 + if (err == ERROR_NO_DATA) return; 1175 1627 1176 - apiReturn = pGetAdaptersInfo(buf, &len); 1177 - ok(apiReturn == NO_ERROR, 1178 - "GetAdaptersInfo(buf, &dwSize) returned %d, expected NO_ERROR\n", 1179 - apiReturn); 1180 - ptr = buf; 1181 - while (ptr) { 1182 - ok(ptr->IpAddressList.IpAddress.String[0], "A valid IP must be present\n"); 1183 - ok(ptr->IpAddressList.IpMask.String[0], "A valid mask must be present\n"); 1184 - trace("Adapter '%s', IP %s, Mask %s\n", ptr->AdapterName, 1185 - ptr->IpAddressList.IpAddress.String, ptr->IpAddressList.IpMask.String); 1628 + buf = malloc( len ); 1629 + err = GetAdaptersInfo( buf, &len ); 1630 + ok( !err, "got %ld\n", err ); 1631 + ptr = buf; 1632 + while (ptr) 1633 + { 1634 + trace( "adapter '%s', address %s/%s gateway %s/%s\n", ptr->AdapterName, 1635 + ptr->IpAddressList.IpAddress.String, ptr->IpAddressList.IpMask.String, 1636 + ptr->GatewayList.IpAddress.String, ptr->GatewayList.IpMask.String ); 1637 + row.dwIndex = ptr->Index; 1638 + GetIfEntry( &row ); 1639 + ConvertInterfaceIndexToLuid( ptr->Index, &luid ); 1640 + ConvertInterfaceLuidToGuid( &luid, &guid ); 1641 + sprintf( name, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", 1642 + guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], 1643 + guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], 1644 + guid.Data4[6], guid.Data4[7] ); 1645 + ok( !strcmp( ptr->AdapterName, name ), "expected '%s' got '%s'\n", ptr->AdapterName, name ); 1646 + ok( !strcmp( ptr->Description, (char *)row.bDescr ), "got %s vs %s\n", ptr->Description, (char *)row.bDescr ); 1647 + ok( ptr->AddressLength == row.dwPhysAddrLen, "got %d vs %ld\n", ptr->AddressLength, row.dwPhysAddrLen ); 1648 + ok( !memcmp(ptr->Address, row.bPhysAddr, ptr->AddressLength ), "mismatch\n" ); 1649 + ok( ptr->Type == row.dwType, "got %d vs %ld\n", ptr->Type, row.dwType ); 1650 + ok( ptr->Type != MIB_IF_TYPE_LOOPBACK, "shouldn't get loopback\n" ); 1651 + ok( ptr->IpAddressList.IpAddress.String[0], "A valid IP address must be present\n" ); 1652 + ok( ptr->IpAddressList.IpMask.String[0], "A valid mask must be present\n" ); 1653 + ok( ptr->GatewayList.IpAddress.String[0], "A valid IP address must be present\n" ); 1654 + ok( ptr->GatewayList.IpMask.String[0], "A valid mask must be present\n" ); 1186 1655 ptr = ptr->Next; 1187 - } 1188 - HeapFree(GetProcessHeap(), 0, buf); 1189 1656 } 1190 - } 1657 + free( buf ); 1191 1658 } 1192 1659 1193 1660 static void testGetNetworkParams(void) 1194 1661 { 1195 - if (pGetNetworkParams) { 1196 1662 DWORD apiReturn; 1197 1663 ULONG len = 0; 1198 1664 1199 - apiReturn = pGetNetworkParams(NULL, NULL); 1665 + apiReturn = GetNetworkParams(NULL, NULL); 1200 1666 if (apiReturn == ERROR_NOT_SUPPORTED) { 1201 - skip("GetNetworkParams is not supported\n"); 1202 - return; 1667 + skip("GetNetworkParams is not supported\n"); 1668 + return; 1203 1669 } 1204 1670 ok(apiReturn == ERROR_INVALID_PARAMETER, 1205 - "GetNetworkParams returned %d, expected ERROR_INVALID_PARAMETER\n", 1206 - apiReturn); 1207 - apiReturn = pGetNetworkParams(NULL, &len); 1671 + "GetNetworkParams returned %ld, expected ERROR_INVALID_PARAMETER\n", 1672 + apiReturn); 1673 + apiReturn = GetNetworkParams(NULL, &len); 1208 1674 ok(apiReturn == ERROR_BUFFER_OVERFLOW, 1209 - "GetNetworkParams returned %d, expected ERROR_BUFFER_OVERFLOW\n", 1210 - apiReturn); 1675 + "GetNetworkParams returned %ld, expected ERROR_BUFFER_OVERFLOW\n", 1676 + apiReturn); 1211 1677 if (apiReturn == ERROR_BUFFER_OVERFLOW) { 1212 - PFIXED_INFO buf = HeapAlloc(GetProcessHeap(), 0, len); 1678 + PFIXED_INFO buf = malloc(len); 1679 + 1680 + apiReturn = GetNetworkParams(buf, &len); 1681 + ok(apiReturn == NO_ERROR, 1682 + "GetNetworkParams(buf, &dwSize) returned %ld, expected NO_ERROR\n", 1683 + apiReturn); 1684 + free(buf); 1685 + } 1686 + } 1687 + 1688 + static void testGetBestInterface(void) 1689 + { 1690 + DWORD apiReturn; 1691 + DWORD bestIfIndex; 1692 + 1693 + apiReturn = GetBestInterface( INADDR_ANY, &bestIfIndex ); 1694 + trace( "GetBestInterface([0.0.0.0], {%lu}) = %lu\n", bestIfIndex, apiReturn ); 1695 + if (apiReturn == ERROR_NOT_SUPPORTED) 1696 + { 1697 + skip( "GetBestInterface is not supported\n" ); 1698 + return; 1699 + } 1700 + 1701 + apiReturn = GetBestInterface( INADDR_LOOPBACK, NULL ); 1702 + ok( apiReturn == ERROR_INVALID_PARAMETER, 1703 + "GetBestInterface([127.0.0.1], NULL) returned %lu, expected %d\n", 1704 + apiReturn, ERROR_INVALID_PARAMETER ); 1705 + 1706 + apiReturn = GetBestInterface( INADDR_LOOPBACK, &bestIfIndex ); 1707 + ok( apiReturn == NO_ERROR, 1708 + "GetBestInterface([127.0.0.1], {%lu}) returned %lu, expected %d\n", 1709 + bestIfIndex, apiReturn, NO_ERROR ); 1710 + } 1711 + 1712 + static void testGetBestInterfaceEx(void) 1713 + { 1714 + DWORD apiReturn; 1715 + DWORD bestIfIndex = 0; 1716 + struct sockaddr_in destAddr; 1717 + 1718 + memset(&destAddr, 0, sizeof(struct sockaddr_in)); 1719 + destAddr.sin_family = AF_INET; 1720 + destAddr.sin_addr.S_un.S_addr = INADDR_ANY; 1721 + apiReturn = GetBestInterfaceEx( (struct sockaddr *)&destAddr, &bestIfIndex ); 1722 + trace( "GetBestInterfaceEx([0.0.0.0], {%lu}) = %lu\n", bestIfIndex, apiReturn ); 1723 + if (apiReturn == ERROR_NOT_SUPPORTED) 1724 + { 1725 + skip( "GetBestInterfaceEx not supported\n" ); 1726 + return; 1727 + } 1728 + 1729 + apiReturn = GetBestInterfaceEx( NULL, NULL ); 1730 + ok( apiReturn == ERROR_INVALID_PARAMETER, 1731 + "GetBestInterfaceEx(NULL, NULL) returned %lu, expected %d\n", 1732 + apiReturn, ERROR_INVALID_PARAMETER ); 1733 + 1734 + apiReturn = GetBestInterfaceEx( NULL, &bestIfIndex ); 1735 + ok( apiReturn == ERROR_INVALID_PARAMETER, 1736 + "GetBestInterfaceEx(NULL, {%lu}) returned %lu, expected %d\n", 1737 + bestIfIndex, apiReturn, ERROR_INVALID_PARAMETER ); 1738 + 1739 + memset(&destAddr, 0, sizeof(struct sockaddr_in)); 1740 + apiReturn = GetBestInterfaceEx( (struct sockaddr *)&destAddr, NULL ); 1741 + ok( apiReturn == ERROR_INVALID_PARAMETER, 1742 + "GetBestInterfaceEx(<AF_UNSPEC>, NULL) returned %lu, expected %d\n", 1743 + apiReturn, ERROR_INVALID_PARAMETER ); 1744 + 1745 + memset(&destAddr, -1, sizeof(struct sockaddr_in)); 1746 + apiReturn = GetBestInterfaceEx( (struct sockaddr *)&destAddr, NULL ); 1747 + ok( apiReturn == ERROR_INVALID_PARAMETER, 1748 + "GetBestInterfaceEx(<INVALID>, NULL) returned %lu, expected %d\n", 1749 + apiReturn, ERROR_INVALID_PARAMETER ); 1750 + 1751 + memset(&destAddr, 0, sizeof(struct sockaddr_in)); 1752 + destAddr.sin_family = AF_INET; 1753 + destAddr.sin_addr.S_un.S_addr = INADDR_LOOPBACK; 1754 + apiReturn = GetBestInterfaceEx( (struct sockaddr *)&destAddr, NULL ); 1755 + ok( apiReturn == ERROR_INVALID_PARAMETER, 1756 + "GetBestInterfaceEx([127.0.0.1], NULL) returned %lu, expected %d\n", 1757 + apiReturn, ERROR_INVALID_PARAMETER ); 1758 + 1759 + memset(&destAddr, 0, sizeof(struct sockaddr_in)); 1760 + destAddr.sin_family = AF_INET; 1761 + destAddr.sin_addr.S_un.S_addr = INADDR_LOOPBACK; 1762 + apiReturn = GetBestInterfaceEx( (struct sockaddr *)&destAddr, &bestIfIndex ); 1763 + ok( apiReturn == NO_ERROR, 1764 + "GetBestInterfaceEx([127.0.0.1], {%lu}) returned %lu, expected %d\n", 1765 + bestIfIndex, apiReturn, ERROR_INVALID_PARAMETER ); 1766 + } 1767 + 1768 + static void testGetBestRoute(void) 1769 + { 1770 + DWORD apiReturn; 1771 + MIB_IPFORWARDROW bestRoute; 1213 1772 1214 - apiReturn = pGetNetworkParams(buf, &len); 1215 - ok(apiReturn == NO_ERROR, 1216 - "GetNetworkParams(buf, &dwSize) returned %d, expected NO_ERROR\n", 1217 - apiReturn); 1218 - HeapFree(GetProcessHeap(), 0, buf); 1773 + apiReturn = GetBestRoute( INADDR_ANY, 0, &bestRoute ); 1774 + trace( "GetBestRoute([0.0.0.0], 0, [...]) = %lu\n", apiReturn ); 1775 + if (apiReturn == ERROR_NOT_SUPPORTED) 1776 + { 1777 + skip( "GetBestRoute is not supported\n" ); 1778 + return; 1219 1779 } 1220 - } 1780 + 1781 + apiReturn = GetBestRoute( INADDR_ANY, 0, NULL ); 1782 + ok( apiReturn == ERROR_INVALID_PARAMETER, 1783 + "GetBestRoute([0.0.0.0], 0, NULL) returned %lu, expected %d\n", 1784 + apiReturn, ERROR_INVALID_PARAMETER ); 1785 + 1786 + apiReturn = GetBestRoute( INADDR_LOOPBACK, 0, &bestRoute ); 1787 + ok( apiReturn == NO_ERROR, 1788 + "GetBestRoute([127.0.0.1], 0, NULL) returned %lu, expected %d\n", 1789 + apiReturn, NO_ERROR ); 1221 1790 } 1222 1791 1223 1792 /* 1224 1793 still-to-be-tested 98-onward functions: 1225 - GetBestInterface 1226 - GetBestRoute 1227 1794 IpReleaseAddress 1228 1795 IpRenewAddress 1229 1796 */ ··· 1232 1799 testGetInterfaceInfo(); 1233 1800 testGetAdaptersInfo(); 1234 1801 testGetNetworkParams(); 1802 + testGetBestInterface(); 1803 + testGetBestInterfaceEx(); 1804 + testGetBestRoute(); 1235 1805 return 0; 1236 1806 } 1237 1807 ··· 1240 1810 DWORD ret, needed; 1241 1811 void *buffer; 1242 1812 1243 - if (!pGetPerAdapterInfo) return; 1244 - ret = pGetPerAdapterInfo(1, NULL, NULL); 1245 - if (ret == ERROR_NOT_SUPPORTED) { 1246 - skip("GetPerAdapterInfo is not supported\n"); 1247 - return; 1248 - } 1249 - ok( ret == ERROR_INVALID_PARAMETER, "got %u instead of ERROR_INVALID_PARAMETER\n", ret ); 1813 + ret = GetPerAdapterInfo(1, NULL, NULL); 1814 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu instead of ERROR_INVALID_PARAMETER\n", ret ); 1250 1815 needed = 0xdeadbeef; 1251 - ret = pGetPerAdapterInfo(1, NULL, &needed); 1816 + ret = GetPerAdapterInfo(1, NULL, &needed); 1252 1817 if (ret == ERROR_NO_DATA) return; /* no such adapter */ 1253 - ok( ret == ERROR_BUFFER_OVERFLOW, "got %u instead of ERROR_BUFFER_OVERFLOW\n", ret ); 1818 + ok( ret == ERROR_BUFFER_OVERFLOW, "got %lu instead of ERROR_BUFFER_OVERFLOW\n", ret ); 1254 1819 ok( needed != 0xdeadbeef, "needed not set\n" ); 1255 - buffer = HeapAlloc( GetProcessHeap(), 0, needed ); 1256 - ret = pGetPerAdapterInfo(1, buffer, &needed); 1257 - ok( ret == NO_ERROR, "got %u instead of NO_ERROR\n", ret ); 1258 - HeapFree( GetProcessHeap(), 0, buffer ); 1820 + buffer = malloc( needed ); 1821 + ret = GetPerAdapterInfo(1, buffer, &needed); 1822 + ok( ret == NO_ERROR, "got %lu instead of NO_ERROR\n", ret ); 1823 + free( buffer ); 1259 1824 } 1260 1825 1261 1826 static void testNotifyAddrChange(void) ··· 1265 1830 HANDLE handle; 1266 1831 BOOL success; 1267 1832 1268 - if (!pNotifyAddrChange) 1269 - { 1270 - win_skip("NotifyAddrChange not present\n"); 1833 + #ifdef __REACTOS__ 1834 + if (IsReactOS()) { 1835 + skip("FIXME: testNotifyAddrChange() hangs on ReactOS! (works on Windows)\n"); 1271 1836 return; 1272 1837 } 1273 - if (!pCancelIPChangeNotify) 1274 - { 1275 - win_skip("CancelIPChangeNotify not present\n"); 1276 - return; 1277 - } 1278 - 1838 + #endif 1279 1839 handle = NULL; 1280 1840 ZeroMemory(&overlapped, sizeof(overlapped)); 1281 - ret = pNotifyAddrChange(&handle, &overlapped); 1282 - if (ret == ERROR_NOT_SUPPORTED) 1283 - { 1284 - win_skip("NotifyAddrChange is not supported\n"); 1285 - return; 1286 - } 1287 - ok(ret == ERROR_IO_PENDING, "NotifyAddrChange returned %d, expected ERROR_IO_PENDING\n", ret); 1841 + ret = NotifyAddrChange(&handle, &overlapped); 1842 + ok(ret == ERROR_IO_PENDING, "NotifyAddrChange returned %ld, expected ERROR_IO_PENDING\n", ret); 1288 1843 ret = GetLastError(); 1289 - todo_wine ok(ret == ERROR_IO_PENDING, "GetLastError returned %d, expected ERROR_IO_PENDING\n", ret); 1290 - success = pCancelIPChangeNotify(&overlapped); 1291 - todo_wine ok(success == TRUE, "CancelIPChangeNotify returned FALSE, expected TRUE\n"); 1844 + ok(ret == ERROR_IO_PENDING, "GetLastError returned %ld, expected ERROR_IO_PENDING\n", ret); 1845 + success = CancelIPChangeNotify(&overlapped); 1846 + ok(success == TRUE, "CancelIPChangeNotify returned FALSE, expected TRUE\n"); 1847 + success = GetOverlappedResult( handle, &overlapped, &bytes, TRUE ); 1848 + ok( !success && GetLastError() == ERROR_OPERATION_ABORTED, "got bret %d, err %lu.\n", success, GetLastError() ); 1292 1849 1293 1850 ZeroMemory(&overlapped, sizeof(overlapped)); 1294 - success = pCancelIPChangeNotify(&overlapped); 1851 + success = CancelIPChangeNotify(&overlapped); 1295 1852 ok(success == FALSE, "CancelIPChangeNotify returned TRUE, expected FALSE\n"); 1296 1853 1297 1854 handle = NULL; 1298 1855 ZeroMemory(&overlapped, sizeof(overlapped)); 1299 1856 overlapped.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); 1300 - ret = pNotifyAddrChange(&handle, &overlapped); 1301 - ok(ret == ERROR_IO_PENDING, "NotifyAddrChange returned %d, expected ERROR_IO_PENDING\n", ret); 1302 - todo_wine ok(handle != INVALID_HANDLE_VALUE, "NotifyAddrChange returned invalid file handle\n"); 1857 + ret = NotifyAddrChange(&handle, &overlapped); 1858 + ok(ret == ERROR_IO_PENDING, "NotifyAddrChange returned %ld, expected ERROR_IO_PENDING\n", ret); 1859 + ok(handle != INVALID_HANDLE_VALUE, "NotifyAddrChange returned invalid file handle\n"); 1303 1860 success = GetOverlappedResult(handle, &overlapped, &bytes, FALSE); 1304 1861 ok(success == FALSE, "GetOverlappedResult returned TRUE, expected FALSE\n"); 1305 1862 ret = GetLastError(); 1306 - ok(ret == ERROR_IO_INCOMPLETE, "GetLastError returned %d, expected ERROR_IO_INCOMPLETE\n", ret); 1307 - success = pCancelIPChangeNotify(&overlapped); 1308 - todo_wine ok(success == TRUE, "CancelIPChangeNotify returned FALSE, expected TRUE\n"); 1863 + ok(ret == ERROR_IO_INCOMPLETE, "GetLastError returned %ld, expected ERROR_IO_INCOMPLETE\n", ret); 1864 + success = CancelIPChangeNotify(&overlapped); 1865 + ok(success == TRUE, "CancelIPChangeNotify returned FALSE, expected TRUE\n"); 1866 + success = GetOverlappedResult( handle, &overlapped, &bytes, TRUE ); 1867 + ok( !success && GetLastError() == ERROR_OPERATION_ABORTED, "got bret %d, err %lu.\n", success, GetLastError() ); 1309 1868 1310 1869 if (winetest_interactive) 1311 1870 { ··· 1314 1873 overlapped.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); 1315 1874 trace("Testing asynchronous ipv4 address change notification. Please " 1316 1875 "change the ipv4 address of one of your network interfaces\n"); 1317 - ret = pNotifyAddrChange(&handle, &overlapped); 1318 - ok(ret == ERROR_IO_PENDING, "NotifyAddrChange returned %d, expected NO_ERROR\n", ret); 1876 + ret = NotifyAddrChange(&handle, &overlapped); 1877 + ok(ret == ERROR_IO_PENDING, "NotifyAddrChange returned %ld, expected NO_ERROR\n", ret); 1319 1878 success = GetOverlappedResult(handle, &overlapped, &bytes, TRUE); 1320 1879 ok(success == TRUE, "GetOverlappedResult returned FALSE, expected TRUE\n"); 1321 1880 } ··· 1325 1884 { 1326 1885 trace("Testing synchronous ipv4 address change notification. Please " 1327 1886 "change the ipv4 address of one of your network interfaces\n"); 1328 - ret = pNotifyAddrChange(NULL, NULL); 1329 - todo_wine ok(ret == NO_ERROR, "NotifyAddrChange returned %d, expected NO_ERROR\n", ret); 1887 + ret = NotifyAddrChange(NULL, NULL); 1888 + ok(ret == NO_ERROR, "NotifyAddrChange returned %ld, expected NO_ERROR\n", ret); 1330 1889 } 1331 1890 } 1332 1891 ··· 1351 1910 1352 1911 static void test_GetAdaptersAddresses(void) 1353 1912 { 1913 + BOOL dns_eligible_found = FALSE; 1354 1914 ULONG ret, size, osize, i; 1355 1915 IP_ADAPTER_ADDRESSES *aa, *ptr; 1356 1916 IP_ADAPTER_UNICAST_ADDRESS *ua; 1357 1917 1358 - if (!pGetAdaptersAddresses) 1359 - { 1360 - win_skip("GetAdaptersAddresses not present\n"); 1361 - return; 1362 - } 1363 - 1364 - ret = pGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, NULL); 1365 - ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", ret); 1918 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 1919 + if (!ConvertInterfaceLuidToGuid) 1920 + skip("Missing APIs!\n"); 1921 + #endif 1922 + ret = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, NULL); 1923 + ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %lu\n", ret); 1366 1924 1367 1925 /* size should be ignored and overwritten if buffer is NULL */ 1368 1926 size = 0x7fffffff; 1369 - ret = pGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &size); 1370 - ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %u\n", ret); 1927 + ret = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &size); 1928 + ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %lu\n", ret); 1371 1929 if (ret != ERROR_BUFFER_OVERFLOW) return; 1372 1930 1373 - ptr = HeapAlloc(GetProcessHeap(), 0, size); 1374 - ret = pGetAdaptersAddresses(AF_UNSPEC, 0, NULL, ptr, &size); 1375 - ok(!ret, "expected ERROR_SUCCESS got %u\n", ret); 1376 - HeapFree(GetProcessHeap(), 0, ptr); 1931 + /* GAA_FLAG_SKIP_FRIENDLY_NAME is ignored */ 1932 + osize = 0x7fffffff; 1933 + ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_FRIENDLY_NAME, NULL, NULL, &osize); 1934 + ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %lu\n", ret); 1935 + #ifdef __REACTOS__ 1936 + if (LOBYTE(LOWORD(GetVersion())) >= 6) 1937 + #endif 1938 + ok(osize == size, "expected %ld, got %ld\n", size, osize); 1939 + 1940 + ptr = malloc(size); 1941 + ret = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, ptr, &size); 1942 + ok(!ret, "expected ERROR_SUCCESS got %lu\n", ret); 1943 + free(ptr); 1377 1944 1378 1945 /* higher size must not be changed to lower size */ 1379 1946 size *= 2; 1380 1947 osize = size; 1381 - ptr = HeapAlloc(GetProcessHeap(), 0, osize); 1382 - ret = pGetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX, NULL, ptr, &osize); 1383 - ok(!ret, "expected ERROR_SUCCESS got %u\n", ret); 1384 - ok(osize == size, "expected %d, got %d\n", size, osize); 1948 + ptr = malloc(osize); 1949 + ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_SKIP_FRIENDLY_NAME, NULL, ptr, &osize); 1950 + while (ret == ERROR_BUFFER_OVERFLOW) 1951 + { 1952 + size = osize * 2; 1953 + osize = size; 1954 + ptr = realloc(ptr, osize); 1955 + ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_SKIP_FRIENDLY_NAME, NULL, ptr, &osize); 1956 + } 1957 + ok(!ret, "expected ERROR_SUCCESS got %lu\n", ret); 1958 + ok(osize == size, "expected %ld, got %ld\n", size, osize); 1385 1959 1386 1960 for (aa = ptr; !ret && aa; aa = aa->Next) 1387 1961 { 1388 - char temp[128]; 1962 + char temp[128], buf[39]; 1389 1963 IP_ADAPTER_PREFIX *prefix; 1964 + DWORD status; 1965 + GUID guid; 1390 1966 1391 - ok(S(U(*aa)).Length == sizeof(IP_ADAPTER_ADDRESSES_LH) || 1392 - S(U(*aa)).Length == sizeof(IP_ADAPTER_ADDRESSES_XP), 1393 - "Unknown structure size of %u bytes\n", S(U(*aa)).Length); 1967 + ok(aa->Length == sizeof(IP_ADAPTER_ADDRESSES_LH) || 1968 + aa->Length == sizeof(IP_ADAPTER_ADDRESSES_XP), 1969 + "Unknown structure size of %lu bytes\n", aa->Length); 1394 1970 ok(aa->DnsSuffix != NULL, "DnsSuffix is not a valid pointer\n"); 1395 1971 ok(aa->Description != NULL, "Description is not a valid pointer\n"); 1396 1972 ok(aa->FriendlyName != NULL, "FriendlyName is not a valid pointer\n"); 1397 1973 1398 - trace("\n"); 1399 - trace("Length: %u\n", S(U(*aa)).Length); 1400 - trace("IfIndex: %u\n", S(U(*aa)).IfIndex); 1401 - trace("Next: %p\n", aa->Next); 1402 - trace("AdapterName: %s\n", aa->AdapterName); 1403 - trace("FirstUnicastAddress: %p\n", aa->FirstUnicastAddress); 1974 + for (i = 0; i < aa->PhysicalAddressLength; i++) 1975 + sprintf(temp + i * 3, "%02X-", aa->PhysicalAddress[i]); 1976 + temp[i ? i * 3 - 1 : 0] = '\0'; 1977 + trace("idx %lu name %s %s dns %s descr %s phys %s mtu %lu flags %08lx type %lu\n", 1978 + aa->IfIndex, aa->AdapterName, 1979 + wine_dbgstr_w(aa->FriendlyName), wine_dbgstr_w(aa->DnsSuffix), 1980 + wine_dbgstr_w(aa->Description), temp, aa->Mtu, aa->Flags, aa->IfType ); 1404 1981 ua = aa->FirstUnicastAddress; 1405 1982 while (ua) 1406 1983 { 1984 + ok(ua->Length == sizeof(IP_ADAPTER_UNICAST_ADDRESS_LH) || 1985 + ua->Length == sizeof(IP_ADAPTER_UNICAST_ADDRESS_XP), 1986 + "Unknown structure size of %lu bytes\n", ua->Length); 1407 1987 ok(ua->PrefixOrigin != IpPrefixOriginOther, 1408 1988 "bad address config value %d\n", ua->PrefixOrigin); 1409 1989 ok(ua->SuffixOrigin != IpSuffixOriginOther, ··· 1419 1999 /* Is the address ok in the network (not duplicated)? */ 1420 2000 ok(ua->DadState != IpDadStateInvalid && ua->DadState != IpDadStateDuplicate, 1421 2001 "bad address duplication value %d\n", ua->DadState); 1422 - trace("\tLength: %u\n", S(U(*ua)).Length); 1423 - trace("\tFlags: 0x%08x\n", S(U(*ua)).Flags); 1424 - trace("\tNext: %p\n", ua->Next); 1425 - trace("\tAddress.lpSockaddr: %p\n", ua->Address.lpSockaddr); 1426 - trace("\tAddress.iSockaddrLength: %d\n", ua->Address.iSockaddrLength); 1427 - trace("\tPrefixOrigin: %u\n", ua->PrefixOrigin); 1428 - trace("\tSuffixOrigin: %u\n", ua->SuffixOrigin); 1429 - trace("\tDadState: %u\n", ua->DadState); 1430 - trace("\tValidLifetime: %u seconds\n", ua->ValidLifetime); 1431 - trace("\tPreferredLifetime: %u seconds\n", ua->PreferredLifetime); 1432 - trace("\tLeaseLifetime: %u seconds\n", ua->LeaseLifetime); 1433 - trace("\n"); 2002 + trace(" flags %08lx origin %u/%u state %u lifetime %lu/%lu/%lu prefix %u\n", 2003 + ua->Flags, ua->PrefixOrigin, ua->SuffixOrigin, ua->DadState, 2004 + ua->ValidLifetime, ua->PreferredLifetime, ua->LeaseLifetime, 2005 + ua->Length < sizeof(IP_ADAPTER_UNICAST_ADDRESS_LH) ? 0 : ua->OnLinkPrefixLength); 2006 + 2007 + if (ua->Flags & IP_ADAPTER_ADDRESS_DNS_ELIGIBLE) 2008 + dns_eligible_found = TRUE; 2009 + 2010 + #ifdef __REACTOS__ 2011 + if (LOBYTE(LOWORD(GetVersion())) >= 6) { 2012 + #endif 2013 + if(ua->Address.lpSockaddr->sa_family == AF_INET) 2014 + ok(aa->Ipv4Enabled == TRUE, "expected Ipv4Enabled flag to be set in interface %ls\n", aa->FriendlyName); 2015 + else if(ua->Address.lpSockaddr->sa_family == AF_INET6) 2016 + ok(aa->Ipv6Enabled == TRUE, "expected Ipv6Enabled flag to be set in interface %ls\n", aa->FriendlyName); 2017 + #ifdef __REACTOS__ 2018 + } 2019 + #endif 2020 + 1434 2021 ua = ua->Next; 1435 2022 } 1436 - trace("FirstAnycastAddress: %p\n", aa->FirstAnycastAddress); 1437 - trace("FirstMulticastAddress: %p\n", aa->FirstMulticastAddress); 1438 - trace("FirstDnsServerAddress: %p\n", aa->FirstDnsServerAddress); 1439 - trace("DnsSuffix: %s %p\n", wine_dbgstr_w(aa->DnsSuffix), aa->DnsSuffix); 1440 - trace("Description: %s %p\n", wine_dbgstr_w(aa->Description), aa->Description); 1441 - trace("FriendlyName: %s %p\n", wine_dbgstr_w(aa->FriendlyName), aa->FriendlyName); 1442 - trace("PhysicalAddressLength: %u\n", aa->PhysicalAddressLength); 1443 - for (i = 0; i < aa->PhysicalAddressLength; i++) 1444 - sprintf(temp + i * 3, "%02X-", aa->PhysicalAddress[i]); 1445 - temp[i ? i * 3 - 1 : 0] = '\0'; 1446 - trace("PhysicalAddress: %s\n", temp); 1447 - trace("Flags: 0x%08x\n", aa->Flags); 1448 - trace("Mtu: %u\n", aa->Mtu); 1449 - trace("IfType: %u\n", aa->IfType); 1450 - trace("OperStatus: %u\n", aa->OperStatus); 1451 - trace("Ipv6IfIndex: %u\n", aa->Ipv6IfIndex); 1452 - for (i = 0, temp[0] = '\0'; i < sizeof(aa->ZoneIndices) / sizeof(aa->ZoneIndices[0]); i++) 1453 - sprintf(temp + strlen(temp), "%d ", aa->ZoneIndices[i]); 1454 - trace("ZoneIndices: %s\n", temp); 1455 - trace("FirstPrefix: %p\n", aa->FirstPrefix); 2023 + for (i = 0, temp[0] = '\0'; i < ARRAY_SIZE(aa->ZoneIndices); i++) 2024 + sprintf(temp + strlen(temp), "%ld ", aa->ZoneIndices[i]); 2025 + trace("status %u index %lu zone %s\n", aa->OperStatus, aa->Ipv6IfIndex, temp ); 1456 2026 prefix = aa->FirstPrefix; 1457 2027 while (prefix) 1458 2028 { 1459 - trace("\tLength: %u\n", S(U(*prefix)).Length); 1460 - trace("\tFlags: 0x%08x\n", S(U(*prefix)).Flags); 1461 - trace("\tNext: %p\n", prefix->Next); 1462 - trace("\tAddress.lpSockaddr: %p\n", prefix->Address.lpSockaddr); 1463 - trace("\tAddress.iSockaddrLength: %d\n", prefix->Address.iSockaddrLength); 1464 - trace("\tPrefixLength: %u\n", prefix->PrefixLength); 1465 - trace("\n"); 2029 + trace( " prefix %u/%lu flags %08lx\n", prefix->Address.iSockaddrLength, 2030 + prefix->PrefixLength, prefix->Flags ); 1466 2031 prefix = prefix->Next; 1467 2032 } 1468 2033 1469 - if (S(U(*aa)).Length < sizeof(IP_ADAPTER_ADDRESSES_LH)) continue; 1470 - #ifndef __REACTOS__ 1471 - trace("TransmitLinkSpeed: %s\n", debugstr_longlong(aa->TransmitLinkSpeed)); 1472 - trace("ReceiveLinkSpeed: %s\n", debugstr_longlong(aa->ReceiveLinkSpeed)); 1473 - trace("FirstWinsServerAddress:%p\n", aa->FirstWinsServerAddress); 1474 - trace("FirstGatewayAddress: %p\n", aa->FirstGatewayAddress); 1475 - trace("Ipv4Metric: %u\n", aa->Ipv4Metric); 1476 - trace("Ipv6Metric: %u\n", aa->Ipv6Metric); 1477 - trace("Luid: %p\n", &aa->Luid); 1478 - trace("Dhcpv4Server: %p\n", &aa->Dhcpv4Server); 1479 - trace("CompartmentId: %u\n", aa->CompartmentId); 1480 - trace("NetworkGuid: %s\n", wine_dbgstr_guid((GUID*) &aa->NetworkGuid)); 1481 - trace("ConnectionType: %u\n", aa->ConnectionType); 1482 - trace("TunnelType: %u\n", aa->TunnelType); 1483 - trace("Dhcpv6Server: %p\n", &aa->Dhcpv6Server); 1484 - trace("Dhcpv6ClientDuidLength:%u\n", aa->Dhcpv6ClientDuidLength); 1485 - trace("Dhcpv6ClientDuid: %p\n", aa->Dhcpv6ClientDuid); 1486 - trace("Dhcpv6Iaid: %u\n", aa->Dhcpv6Iaid); 1487 - trace("FirstDnsSuffix: %p\n", aa->FirstDnsSuffix); 1488 - trace("\n"); 2034 + if (aa->Length < sizeof(IP_ADAPTER_ADDRESSES_LH)) continue; 2035 + trace("speed %s/%s metrics %lu/%lu guid %s type %u/%u\n", 2036 + wine_dbgstr_longlong(aa->TransmitLinkSpeed), 2037 + wine_dbgstr_longlong(aa->ReceiveLinkSpeed), 2038 + aa->Ipv4Metric, aa->Ipv6Metric, wine_dbgstr_guid((GUID*) &aa->NetworkGuid), 2039 + aa->ConnectionType, aa->TunnelType); 2040 + 2041 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 2042 + if (ConvertInterfaceLuidToGuid) { 2043 + #endif 2044 + status = ConvertInterfaceLuidToGuid(&aa->Luid, &guid); 2045 + ok(!status, "got %lu\n", status); 2046 + sprintf(buf, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", 2047 + guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], 2048 + guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], 2049 + guid.Data4[6], guid.Data4[7]); 2050 + ok(!strcasecmp(aa->AdapterName, buf), "expected '%s' got '%s'\n", aa->AdapterName, buf); 2051 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 2052 + } 1489 2053 #endif 1490 2054 } 1491 - HeapFree(GetProcessHeap(), 0, ptr); 2055 + ok(dns_eligible_found, "Did not find any dns eligible addresses.\n"); 2056 + free(ptr); 2057 + } 2058 + 2059 + static DWORD get_extended_tcp_table( ULONG family, TCP_TABLE_CLASS class, void **table ) 2060 + { 2061 + DWORD ret, size = 0; 2062 + 2063 + *table = NULL; 2064 + ret = pGetExtendedTcpTable( NULL, &size, TRUE, family, class, 0 ); 2065 + if (ret != ERROR_INSUFFICIENT_BUFFER) return ret; 2066 + 2067 + *table = malloc( size ); 2068 + ret = pGetExtendedTcpTable( *table, &size, TRUE, family, class, 0 ); 2069 + while (ret == ERROR_INSUFFICIENT_BUFFER) 2070 + { 2071 + *table = realloc( *table, size ); 2072 + ret = pGetExtendedTcpTable( *table, &size, TRUE, family, class, 0 ); 2073 + } 2074 + return ret; 1492 2075 } 1493 2076 1494 2077 static void test_GetExtendedTcpTable(void) 1495 2078 { 1496 - DWORD ret, size; 2079 + DWORD ret; 1497 2080 MIB_TCPTABLE *table; 1498 2081 MIB_TCPTABLE_OWNER_PID *table_pid; 1499 2082 MIB_TCPTABLE_OWNER_MODULE *table_module; ··· 1504 2087 return; 1505 2088 } 1506 2089 ret = pGetExtendedTcpTable( NULL, NULL, TRUE, AF_INET, TCP_TABLE_BASIC_ALL, 0 ); 1507 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2090 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2091 + 2092 + ret = get_extended_tcp_table( AF_INET, TCP_TABLE_BASIC_ALL, (void **)&table ); 2093 + ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); 2094 + free( table ); 2095 + 2096 + ret = get_extended_tcp_table( AF_INET, TCP_TABLE_BASIC_LISTENER, (void **)&table ); 2097 + ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); 2098 + free( table ); 2099 + 2100 + ret = get_extended_tcp_table( AF_INET, TCP_TABLE_OWNER_PID_ALL, (void **)&table_pid ); 2101 + ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); 2102 + free( table_pid ); 2103 + 2104 + ret = get_extended_tcp_table( AF_INET, TCP_TABLE_OWNER_PID_LISTENER, (void **)&table_pid ); 2105 + ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); 2106 + free( table_pid ); 2107 + 2108 + ret = get_extended_tcp_table( AF_INET, TCP_TABLE_OWNER_MODULE_ALL, (void **)&table_module ); 2109 + ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); 2110 + free( table_module ); 2111 + 2112 + ret = get_extended_tcp_table( AF_INET, TCP_TABLE_OWNER_MODULE_LISTENER, (void **)&table_module ); 2113 + ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); 2114 + free( table_module ); 2115 + } 2116 + 2117 + /* Test that the TCP_TABLE_OWNER_PID_ALL table contains an entry for a socket 2118 + we make, and associates it with our process. */ 2119 + static void test_GetExtendedTcpTable_owner( int family ) 2120 + { 2121 + SOCKET sock; 2122 + int port; 2123 + DWORD i, ret; 2124 + void *raw_table = NULL; 1508 2125 1509 - size = 0; 1510 - ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_BASIC_ALL, 0 ); 1511 - ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret ); 2126 + #ifdef __REACTOS__ 2127 + if (LOBYTE(LOWORD(GetVersion())) < 6) { 2128 + skip("This test is invalid for this NT version.\n"); 2129 + return; 2130 + } 2131 + #endif 2132 + winetest_push_context( "%s", family == AF_INET ? "AF_INET" : "AF_INET6" ); 1512 2133 1513 - table = HeapAlloc( GetProcessHeap(), 0, size ); 1514 - ret = pGetExtendedTcpTable( table, &size, TRUE, AF_INET, TCP_TABLE_BASIC_ALL, 0 ); 1515 - ok( ret == ERROR_SUCCESS, "got %u\n", ret ); 1516 - HeapFree( GetProcessHeap(), 0, table ); 2134 + sock = socket( family, SOCK_STREAM, IPPROTO_TCP ); 2135 + ok( sock != INVALID_SOCKET, "socket error %d\n", WSAGetLastError() ); 2136 + 2137 + if (family == AF_INET) 2138 + { 2139 + struct sockaddr_in addr = { 0 }; 2140 + int addr_len = sizeof(addr); 2141 + 2142 + addr.sin_family = AF_INET; 2143 + addr.sin_addr.s_addr = htonl( INADDR_LOOPBACK ); 2144 + addr.sin_port = 0; 2145 + 2146 + ret = bind( sock, (struct sockaddr *)&addr, addr_len ); 2147 + ok( !ret, "bind error %d\n", WSAGetLastError() ); 2148 + ret = getsockname( sock, (struct sockaddr *)&addr, &addr_len ); 2149 + ok( !ret, "getsockname error %d\n", WSAGetLastError() ); 2150 + 2151 + port = addr.sin_port; 2152 + } 2153 + else 2154 + { 2155 + struct sockaddr_in6 addr = { 0 }; 2156 + int addr_len = sizeof(addr); 2157 + 2158 + addr.sin6_family = AF_INET6; 2159 + addr.sin6_addr = in6addr_loopback; 2160 + addr.sin6_port = 0; 2161 + 2162 + ret = bind( sock, (struct sockaddr *)&addr, addr_len ); 2163 + ok( !ret, "bind error %d\n", WSAGetLastError() ); 2164 + ret = getsockname( sock, (struct sockaddr *)&addr, &addr_len ); 2165 + ok( !ret, "getsockname error %d\n", WSAGetLastError() ); 2166 + 2167 + port = addr.sin6_port; 2168 + } 2169 + 2170 + listen( sock, 1 ); 2171 + 2172 + ret = get_extended_tcp_table( family, TCP_TABLE_OWNER_PID_ALL, &raw_table ); 2173 + if (ret != ERROR_SUCCESS) 2174 + { 2175 + skip( "error %lu getting TCP table\n", ret ); 2176 + goto done; 2177 + } 2178 + 2179 + if (family == AF_INET) 2180 + { 2181 + MIB_TCPTABLE_OWNER_PID *table = raw_table; 2182 + BOOL found_it = FALSE; 2183 + for (i = 0; i < table->dwNumEntries; i++) 2184 + { 2185 + MIB_TCPROW_OWNER_PID *row = &table->table[i]; 2186 + if (row->dwLocalPort == port && row->dwLocalAddr == htonl( INADDR_LOOPBACK )) 2187 + { 2188 + ok( row->dwState == MIB_TCP_STATE_LISTEN, "unexpected socket state %ld\n", row->dwState ); 2189 + ok( row->dwOwningPid == GetCurrentProcessId(), "unexpected socket owner %04lx\n", row->dwOwningPid ); 2190 + found_it = TRUE; 2191 + break; 2192 + } 2193 + } 2194 + ok( found_it, "no table entry for socket\n" ); 2195 + } 2196 + else 2197 + { 2198 + MIB_TCP6TABLE_OWNER_PID *table = raw_table; 2199 + BOOL found_it = FALSE; 2200 + for (i = 0; i < table->dwNumEntries; i++) 2201 + { 2202 + MIB_TCP6ROW_OWNER_PID *row = &table->table[i]; 2203 + if (row->dwLocalPort == port && IN6_IS_ADDR_LOOPBACK( (IN6_ADDR*)&row->ucLocalAddr )) 2204 + { 2205 + ok( row->dwState == MIB_TCP_STATE_LISTEN, "unexpected socket state %ld\n", row->dwState ); 2206 + ok( row->dwOwningPid == GetCurrentProcessId(), "unexpected socket owner %04lx\n", row->dwOwningPid ); 2207 + found_it = TRUE; 2208 + break; 2209 + } 2210 + } 2211 + ok( found_it, "no table entry for socket\n" ); 2212 + } 2213 + 2214 + done: 2215 + closesocket( sock ); 2216 + free( raw_table ); 2217 + 2218 + winetest_pop_context(); 2219 + } 2220 + 2221 + static void test_AllocateAndGetTcpExTableFromStack(void) 2222 + { 2223 + DWORD ret; 2224 + MIB_TCPTABLE_OWNER_PID *table_ex = NULL; 1517 2225 1518 - size = 0; 1519 - ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_BASIC_LISTENER, 0 ); 1520 - ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret ); 2226 + if (!pAllocateAndGetTcpExTableFromStack) 2227 + { 2228 + win_skip("AllocateAndGetTcpExTableFromStack not available\n"); 2229 + return; 2230 + } 1521 2231 1522 - table = HeapAlloc( GetProcessHeap(), 0, size ); 1523 - ret = pGetExtendedTcpTable( table, &size, TRUE, AF_INET, TCP_TABLE_BASIC_LISTENER, 0 ); 1524 - ok( ret == ERROR_SUCCESS, "got %u\n", ret ); 1525 - HeapFree( GetProcessHeap(), 0, table ); 2232 + if (0) 2233 + { 2234 + /* crashes on native */ 2235 + ret = pAllocateAndGetTcpExTableFromStack( NULL, FALSE, INVALID_HANDLE_VALUE, 0, 0 ); 2236 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2237 + ret = pAllocateAndGetTcpExTableFromStack( (void **)&table_ex, FALSE, INVALID_HANDLE_VALUE, 0, AF_INET ); 2238 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2239 + ret = pAllocateAndGetTcpExTableFromStack( NULL, FALSE, GetProcessHeap(), 0, AF_INET ); 2240 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2241 + } 1526 2242 1527 - size = 0; 1528 - ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0 ); 1529 - ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret ); 2243 + ret = pAllocateAndGetTcpExTableFromStack( (void **)&table_ex, FALSE, GetProcessHeap(), 0, 0 ); 2244 + ok( ret == ERROR_INVALID_PARAMETER || broken(ret == ERROR_NOT_SUPPORTED) /* win2k */, "got %lu\n", ret ); 1530 2245 1531 - table_pid = HeapAlloc( GetProcessHeap(), 0, size ); 1532 - ret = pGetExtendedTcpTable( table_pid, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0 ); 1533 - ok( ret == ERROR_SUCCESS, "got %u\n", ret ); 1534 - HeapFree( GetProcessHeap(), 0, table_pid ); 2246 + ret = pAllocateAndGetTcpExTableFromStack( (void **)&table_ex, FALSE, GetProcessHeap(), 0, AF_INET ); 2247 + ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); 1535 2248 1536 - size = 0; 1537 - ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_LISTENER, 0 ); 1538 - ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret ); 2249 + if (ret == NO_ERROR && winetest_debug > 1) 2250 + { 2251 + DWORD i; 2252 + trace( "AllocateAndGetTcpExTableFromStack table: %lu entries\n", table_ex->dwNumEntries ); 2253 + for (i = 0; i < table_ex->dwNumEntries; i++) 2254 + { 2255 + char remote_ip[16]; 1539 2256 1540 - table_pid = HeapAlloc( GetProcessHeap(), 0, size ); 1541 - ret = pGetExtendedTcpTable( table_pid, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_LISTENER, 0 ); 1542 - ok( ret == ERROR_SUCCESS, "got %u\n", ret ); 1543 - HeapFree( GetProcessHeap(), 0, table_pid ); 2257 + strcpy(remote_ip, ntoa(table_ex->table[i].dwRemoteAddr)); 2258 + trace( "%lu: local %s:%u remote %s:%u state %lu pid %lu\n", i, 2259 + ntoa(table_ex->table[i].dwLocalAddr), ntohs(table_ex->table[i].dwLocalPort), 2260 + remote_ip, ntohs(table_ex->table[i].dwRemotePort), 2261 + table_ex->table[i].dwState, table_ex->table[i].dwOwningPid ); 2262 + } 2263 + } 2264 + HeapFree(GetProcessHeap(), 0, table_ex); 1544 2265 1545 - size = 0; 1546 - ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_MODULE_ALL, 0 ); 1547 - ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret ); 2266 + ret = pAllocateAndGetTcpExTableFromStack( (void **)&table_ex, FALSE, GetProcessHeap(), 0, AF_INET6 ); 2267 + ok( ret == ERROR_NOT_SUPPORTED, "got %lu\n", ret ); 2268 + } 1548 2269 1549 - table_module = HeapAlloc( GetProcessHeap(), 0, size ); 1550 - ret = pGetExtendedTcpTable( table_module, &size, TRUE, AF_INET, TCP_TABLE_OWNER_MODULE_ALL, 0 ); 1551 - ok( ret == ERROR_SUCCESS, "got %u\n", ret ); 1552 - HeapFree( GetProcessHeap(), 0, table_module ); 2270 + static DWORD get_extended_udp_table( ULONG family, UDP_TABLE_CLASS class, void **table ) 2271 + { 2272 + DWORD ret, size = 0; 1553 2273 1554 - size = 0; 1555 - ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_MODULE_LISTENER, 0 ); 1556 - ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret ); 2274 + *table = NULL; 2275 + ret = pGetExtendedUdpTable( NULL, &size, TRUE, family, class, 0 ); 2276 + if (ret != ERROR_INSUFFICIENT_BUFFER) return ret; 1557 2277 1558 - table_module = HeapAlloc( GetProcessHeap(), 0, size ); 1559 - ret = pGetExtendedTcpTable( table_module, &size, TRUE, AF_INET, TCP_TABLE_OWNER_MODULE_LISTENER, 0 ); 1560 - ok( ret == ERROR_SUCCESS, "got %u\n", ret ); 1561 - HeapFree( GetProcessHeap(), 0, table_module ); 2278 + *table = malloc( size ); 2279 + ret = pGetExtendedUdpTable( *table, &size, TRUE, family, class, 0 ); 2280 + while (ret == ERROR_INSUFFICIENT_BUFFER) 2281 + { 2282 + *table = realloc( *table, size ); 2283 + ret = pGetExtendedUdpTable( *table, &size, TRUE, family, class, 0 ); 2284 + } 2285 + return ret; 1562 2286 } 1563 2287 1564 2288 static void test_GetExtendedUdpTable(void) 1565 2289 { 1566 - DWORD ret, size; 2290 + DWORD ret; 1567 2291 MIB_UDPTABLE *table; 1568 2292 MIB_UDPTABLE_OWNER_PID *table_pid; 1569 2293 MIB_UDPTABLE_OWNER_MODULE *table_module; ··· 1574 2298 return; 1575 2299 } 1576 2300 ret = pGetExtendedUdpTable( NULL, NULL, TRUE, AF_INET, UDP_TABLE_BASIC, 0 ); 1577 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2301 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2302 + 2303 + ret = get_extended_udp_table( AF_INET, UDP_TABLE_BASIC, (void **)&table ); 2304 + ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); 2305 + free( table ); 2306 + 2307 + ret = get_extended_udp_table( AF_INET, UDP_TABLE_OWNER_PID, (void **)&table_pid ); 2308 + ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); 2309 + free( table_pid ); 2310 + 2311 + ret = get_extended_udp_table( AF_INET, UDP_TABLE_OWNER_MODULE, (void **)&table_module ); 2312 + ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); 2313 + free( table_module ); 2314 + } 2315 + 2316 + /* Test that the UDP_TABLE_OWNER_PID table contains an entry for a socket we 2317 + make, and associates it with our process. */ 2318 + static void test_GetExtendedUdpTable_owner( int family ) 2319 + { 2320 + SOCKET sock; 2321 + int port; 2322 + DWORD i, ret; 2323 + void *raw_table = NULL; 1578 2324 1579 - size = 0; 1580 - ret = pGetExtendedUdpTable( NULL, &size, TRUE, AF_INET, UDP_TABLE_BASIC, 0 ); 1581 - ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret ); 2325 + #ifdef __REACTOS__ 2326 + if (LOBYTE(LOWORD(GetVersion())) < 6) { 2327 + skip("This test is invalid for this NT version.\n"); 2328 + return; 2329 + } 2330 + #endif 2331 + winetest_push_context( "%s", family == AF_INET ? "AF_INET" : "AF_INET6" ); 1582 2332 1583 - table = HeapAlloc( GetProcessHeap(), 0, size ); 1584 - ret = pGetExtendedUdpTable( table, &size, TRUE, AF_INET, UDP_TABLE_BASIC, 0 ); 1585 - ok( ret == ERROR_SUCCESS, "got %u\n", ret ); 1586 - HeapFree( GetProcessHeap(), 0, table ); 2333 + sock = socket( family, SOCK_DGRAM, IPPROTO_UDP ); 2334 + ok( sock != INVALID_SOCKET, "socket error %d\n", WSAGetLastError() ); 2335 + 2336 + if (family == AF_INET) 2337 + { 2338 + struct sockaddr_in addr = { 0 }; 2339 + int addr_len = sizeof(addr); 2340 + 2341 + addr.sin_family = AF_INET; 2342 + addr.sin_addr.s_addr = htonl( INADDR_LOOPBACK ); 2343 + addr.sin_port = 0; 1587 2344 1588 - size = 0; 1589 - ret = pGetExtendedUdpTable( NULL, &size, TRUE, AF_INET, UDP_TABLE_OWNER_PID, 0 ); 1590 - ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret ); 2345 + ret = bind( sock, (struct sockaddr *)&addr, addr_len ); 2346 + ok( !ret, "bind error %d\n", WSAGetLastError() ); 2347 + ret = getsockname( sock, (struct sockaddr *)&addr, &addr_len ); 2348 + ok( !ret, "getsockname error %d\n", WSAGetLastError() ); 2349 + 2350 + port = addr.sin_port; 2351 + } 2352 + else 2353 + { 2354 + struct sockaddr_in6 addr = { 0 }; 2355 + int addr_len = sizeof(addr); 2356 + 2357 + addr.sin6_family = AF_INET6; 2358 + addr.sin6_addr = in6addr_loopback; 2359 + addr.sin6_port = 0; 2360 + 2361 + ret = bind( sock, (struct sockaddr *)&addr, addr_len ); 2362 + ok( !ret, "bind error %d\n", WSAGetLastError() ); 2363 + ret = getsockname( sock, (struct sockaddr *)&addr, &addr_len ); 2364 + ok( !ret, "getsockname error %d\n", WSAGetLastError() ); 2365 + 2366 + port = addr.sin6_port; 2367 + } 2368 + 2369 + ret = get_extended_udp_table( family, UDP_TABLE_OWNER_PID, &raw_table ); 2370 + if (ret != ERROR_SUCCESS) 2371 + { 2372 + skip( "error %lu getting UDP table\n", ret ); 2373 + goto done; 2374 + } 1591 2375 1592 - table_pid = HeapAlloc( GetProcessHeap(), 0, size ); 1593 - ret = pGetExtendedUdpTable( table_pid, &size, TRUE, AF_INET, UDP_TABLE_OWNER_PID, 0 ); 1594 - ok( ret == ERROR_SUCCESS, "got %u\n", ret ); 1595 - HeapFree( GetProcessHeap(), 0, table_pid ); 2376 + if (family == AF_INET) 2377 + { 2378 + MIB_UDPTABLE_OWNER_PID *table = raw_table; 2379 + BOOL found_it = FALSE; 2380 + for (i = 0; i < table->dwNumEntries; i++) 2381 + { 2382 + MIB_UDPROW_OWNER_PID *row = &table->table[i]; 2383 + if (row->dwLocalPort == port && row->dwLocalAddr == htonl( INADDR_LOOPBACK )) 2384 + { 2385 + ok( row->dwOwningPid == GetCurrentProcessId(), "unexpected socket owner %04lx\n", row->dwOwningPid ); 2386 + found_it = TRUE; 2387 + break; 2388 + } 2389 + } 2390 + ok( found_it, "no table entry for socket\n" ); 2391 + } 2392 + else 2393 + { 2394 + MIB_UDP6TABLE_OWNER_PID *table = raw_table; 2395 + BOOL found_it = FALSE; 2396 + for (i = 0; i < table->dwNumEntries; i++) 2397 + { 2398 + MIB_UDP6ROW_OWNER_PID *row = &table->table[i]; 2399 + if (row->dwLocalPort == port && IN6_IS_ADDR_LOOPBACK( (IN6_ADDR*)&row->ucLocalAddr )) 2400 + { 2401 + ok( row->dwOwningPid == GetCurrentProcessId(), "unexpected socket owner %04lx\n", row->dwOwningPid ); 2402 + found_it = TRUE; 2403 + break; 2404 + } 2405 + } 2406 + ok( found_it, "no table entry for socket\n" ); 2407 + } 1596 2408 1597 - size = 0; 1598 - ret = pGetExtendedUdpTable( NULL, &size, TRUE, AF_INET, UDP_TABLE_OWNER_MODULE, 0 ); 1599 - ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret ); 2409 + done: 2410 + closesocket( sock ); 2411 + free( raw_table ); 1600 2412 1601 - table_module = HeapAlloc( GetProcessHeap(), 0, size ); 1602 - ret = pGetExtendedUdpTable( table_module, &size, TRUE, AF_INET, UDP_TABLE_OWNER_MODULE, 0 ); 1603 - ok( ret == ERROR_SUCCESS, "got %u\n", ret ); 1604 - HeapFree( GetProcessHeap(), 0, table_module ); 2413 + winetest_pop_context(); 1605 2414 } 1606 2415 1607 2416 static void test_CreateSortedAddressPairs(void) ··· 1625 2434 1626 2435 pair_count = 0xdeadbeef; 1627 2436 ret = pCreateSortedAddressPairs( NULL, 0, dst, 1, 0, NULL, &pair_count ); 1628 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 1629 - ok( pair_count == 0xdeadbeef, "got %u\n", pair_count ); 2437 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2438 + ok( pair_count == 0xdeadbeef, "got %lu\n", pair_count ); 1630 2439 1631 2440 pair = (SOCKADDR_IN6_PAIR *)0xdeadbeef; 1632 2441 pair_count = 0xdeadbeef; 1633 2442 ret = pCreateSortedAddressPairs( NULL, 0, NULL, 1, 0, &pair, &pair_count ); 1634 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2443 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 1635 2444 ok( pair == (SOCKADDR_IN6_PAIR *)0xdeadbeef, "got %p\n", pair ); 1636 - ok( pair_count == 0xdeadbeef, "got %u\n", pair_count ); 2445 + ok( pair_count == 0xdeadbeef, "got %lu\n", pair_count ); 1637 2446 1638 2447 pair = NULL; 1639 2448 pair_count = 0xdeadbeef; 1640 2449 ret = pCreateSortedAddressPairs( NULL, 0, dst, 1, 0, &pair, &pair_count ); 1641 - ok( ret == NO_ERROR, "got %u\n", ret ); 2450 + ok( ret == NO_ERROR, "got %lu\n", ret ); 1642 2451 ok( pair != NULL, "pair not set\n" ); 1643 - ok( pair_count >= 1, "got %u\n", pair_count ); 2452 + ok( pair_count >= 1, "got %lu\n", pair_count ); 1644 2453 ok( pair[0].SourceAddress != NULL, "src address not set\n" ); 1645 2454 ok( pair[0].DestinationAddress != NULL, "dst address not set\n" ); 1646 - pFreeMibTable( pair ); 2455 + FreeMibTable( pair ); 1647 2456 1648 2457 dst[1].sin6_family = AF_INET6; 1649 2458 dst[1].sin6_addr.u.Word[5] = 0xffff; ··· 1653 2462 pair = NULL; 1654 2463 pair_count = 0xdeadbeef; 1655 2464 ret = pCreateSortedAddressPairs( NULL, 0, dst, 2, 0, &pair, &pair_count ); 1656 - ok( ret == NO_ERROR, "got %u\n", ret ); 2465 + ok( ret == NO_ERROR, "got %lu\n", ret ); 1657 2466 ok( pair != NULL, "pair not set\n" ); 1658 - ok( pair_count >= 2, "got %u\n", pair_count ); 2467 + ok( pair_count >= 2, "got %lu\n", pair_count ); 1659 2468 ok( pair[0].SourceAddress != NULL, "src address not set\n" ); 1660 2469 ok( pair[0].DestinationAddress != NULL, "dst address not set\n" ); 1661 2470 ok( pair[1].SourceAddress != NULL, "src address not set\n" ); 1662 2471 ok( pair[1].DestinationAddress != NULL, "dst address not set\n" ); 1663 - pFreeMibTable( pair ); 2472 + FreeMibTable( pair ); 2473 + } 2474 + 2475 + static IP_ADAPTER_ADDRESSES *get_adapters( ULONG flags ) 2476 + { 2477 + ULONG err, size = 4096; 2478 + IP_ADAPTER_ADDRESSES *tmp, *ret; 2479 + 2480 + if (!(ret = malloc( size ))) return NULL; 2481 + err = GetAdaptersAddresses( AF_UNSPEC, flags, NULL, ret, &size ); 2482 + while (err == ERROR_BUFFER_OVERFLOW) 2483 + { 2484 + if (!(tmp = realloc( ret, size ))) break; 2485 + ret = tmp; 2486 + err = GetAdaptersAddresses( AF_UNSPEC, flags, NULL, ret, &size ); 2487 + } 2488 + if (err == ERROR_SUCCESS) return ret; 2489 + free( ret ); 2490 + return NULL; 1664 2491 } 1665 2492 1666 2493 static DWORD get_interface_index(void) 1667 2494 { 1668 - DWORD size = 0, ret = 0; 2495 + DWORD ret = 0; 1669 2496 IP_ADAPTER_ADDRESSES *buf, *aa; 1670 2497 1671 - if (pGetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size ) != ERROR_BUFFER_OVERFLOW) 1672 - return 0; 2498 + buf = get_adapters( 0 ); 2499 + if (!buf) return 0; 1673 2500 1674 - buf = HeapAlloc( GetProcessHeap(), 0, size ); 1675 - pGetAdaptersAddresses( AF_UNSPEC, 0, NULL, buf, &size ); 1676 2501 for (aa = buf; aa; aa = aa->Next) 1677 2502 { 1678 2503 if (aa->IfType == IF_TYPE_ETHERNET_CSMACD) ··· 1681 2506 break; 1682 2507 } 1683 2508 } 1684 - HeapFree( GetProcessHeap(), 0, buf ); 2509 + free( buf ); 1685 2510 return ret; 1686 2511 } 1687 2512 2513 + static void convert_luid_to_name( NET_LUID *luid, WCHAR *expect_nameW, int len ) 2514 + { 2515 + struct 2516 + { 2517 + const WCHAR *prefix; 2518 + DWORD type; 2519 + } prefixes[] = 2520 + { 2521 + { L"other", IF_TYPE_OTHER }, 2522 + { L"ethernet", IF_TYPE_ETHERNET_CSMACD }, 2523 + { L"tokenring", IF_TYPE_ISO88025_TOKENRING }, 2524 + { L"ppp", IF_TYPE_PPP }, 2525 + { L"loopback", IF_TYPE_SOFTWARE_LOOPBACK }, 2526 + { L"atm", IF_TYPE_ATM }, 2527 + { L"wireless", IF_TYPE_IEEE80211 }, 2528 + { L"tunnel", IF_TYPE_TUNNEL }, 2529 + { L"ieee1394", IF_TYPE_IEEE1394 } 2530 + }; 2531 + DWORD i; 2532 + const WCHAR *prefix = NULL; 2533 + 2534 + for (i = 0; i < ARRAY_SIZE(prefixes); i++) 2535 + { 2536 + if (prefixes[i].type == luid->Info.IfType) 2537 + { 2538 + prefix = prefixes[i].prefix; 2539 + break; 2540 + } 2541 + } 2542 + #ifdef __REACTOS__ 2543 + if (prefix) 2544 + _snwprintf( expect_nameW, len, L"%s_%d", prefix, luid->Info.NetLuidIndex ); 2545 + else 2546 + _snwprintf( expect_nameW, len, L"iftype%d_%d", luid->Info.IfType, luid->Info.NetLuidIndex ); 2547 + #else 2548 + if (prefix) 2549 + swprintf( expect_nameW, len, L"%s_%d", prefix, luid->Info.NetLuidIndex ); 2550 + else 2551 + swprintf( expect_nameW, len, L"iftype%d_%d", luid->Info.IfType, luid->Info.NetLuidIndex ); 2552 + #endif 2553 + } 2554 + 1688 2555 static void test_interface_identifier_conversion(void) 1689 2556 { 1690 - DWORD ret; 2557 + DWORD ret, i; 1691 2558 NET_LUID luid; 1692 2559 GUID guid; 1693 2560 SIZE_T len; 1694 2561 WCHAR nameW[IF_MAX_STRING_SIZE + 1]; 1695 - char nameA[IF_MAX_STRING_SIZE + 1]; 2562 + WCHAR alias[IF_MAX_STRING_SIZE + 1]; 2563 + WCHAR expect_nameW[IF_MAX_STRING_SIZE + 1]; 2564 + char nameA[IF_MAX_STRING_SIZE + 1], *name; 2565 + char expect_nameA[IF_MAX_STRING_SIZE + 1]; 1696 2566 NET_IFINDEX index; 2567 + MIB_IF_TABLE2 *table; 1697 2568 1698 - if (!pConvertInterfaceIndexToLuid) 1699 - { 1700 - win_skip( "ConvertInterfaceIndexToLuid not available\n" ); 2569 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 2570 + if (!ConvertInterfaceIndexToLuid || !ConvertInterfaceLuidToIndex || 2571 + !ConvertInterfaceLuidToGuid || !ConvertInterfaceGuidToLuid || 2572 + !ConvertInterfaceLuidToNameW || !ConvertInterfaceLuidToNameA || 2573 + !ConvertInterfaceNameToLuidW || !ConvertInterfaceNameToLuidA || 2574 + !pConvertInterfaceAliasToLuid || !pConvertInterfaceLuidToAlias || 2575 + !GetIfTable2 || !if_nametoindex || !if_indextoname) { 2576 + skip("Missing APIs!\n"); 1701 2577 return; 1702 2578 } 1703 - if (!(index = get_interface_index())) 2579 + #endif 2580 + ret = GetIfTable2( &table ); 2581 + ok( !ret, "got %ld\n", ret ); 2582 + 2583 + for (i = 0; i < table->NumEntries; i++) 1704 2584 { 1705 - skip( "no suitable interface found\n" ); 1706 - return; 1707 - } 2585 + MIB_IF_ROW2 *row = table->Table + i; 1708 2586 1709 - /* ConvertInterfaceIndexToLuid */ 1710 - ret = pConvertInterfaceIndexToLuid( 0, NULL ); 1711 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2587 + /* ConvertInterfaceIndexToLuid */ 2588 + memset( &luid, 0xff, sizeof(luid) ); 2589 + ret = ConvertInterfaceIndexToLuid( 0, &luid ); 2590 + ok( ret == ERROR_FILE_NOT_FOUND, "got %lu\n", ret ); 2591 + ok( !luid.Info.Reserved, "got %x\n", luid.Info.Reserved ); 2592 + ok( !luid.Info.NetLuidIndex, "got %u\n", luid.Info.NetLuidIndex ); 2593 + ok( !luid.Info.IfType, "got %u\n", luid.Info.IfType ); 1712 2594 1713 - memset( &luid, 0xff, sizeof(luid) ); 1714 - ret = pConvertInterfaceIndexToLuid( 0, &luid ); 1715 - ok( ret == ERROR_FILE_NOT_FOUND, "got %u\n", ret ); 1716 - ok( !luid.Info.Reserved, "got %x\n", luid.Info.Reserved ); 1717 - ok( !luid.Info.NetLuidIndex, "got %u\n", luid.Info.NetLuidIndex ); 1718 - ok( !luid.Info.IfType, "got %u\n", luid.Info.IfType ); 2595 + luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; 2596 + ret = ConvertInterfaceIndexToLuid( row->InterfaceIndex, &luid ); 2597 + ok( !ret, "got %lu\n", ret ); 2598 + ok( luid.Value == row->InterfaceLuid.Value, "mismatch\n" ); 1719 2599 1720 - luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; 1721 - ret = pConvertInterfaceIndexToLuid( index, &luid ); 1722 - ok( !ret, "got %u\n", ret ); 1723 - ok( !luid.Info.Reserved, "got %x\n", luid.Info.Reserved ); 1724 - ok( luid.Info.NetLuidIndex != 0xdead, "index not set\n" ); 1725 - ok( luid.Info.IfType == IF_TYPE_ETHERNET_CSMACD, "got %u\n", luid.Info.IfType ); 2600 + /* ConvertInterfaceLuidToIndex */ 2601 + ret = ConvertInterfaceLuidToIndex( &luid, NULL ); 2602 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 1726 2603 1727 - /* ConvertInterfaceLuidToIndex */ 1728 - ret = pConvertInterfaceLuidToIndex( NULL, NULL ); 1729 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2604 + ret = ConvertInterfaceLuidToIndex( &luid, &index ); 2605 + ok( !ret, "got %lu\n", ret ); 2606 + ok( index == row->InterfaceIndex, "mismatch\n" ); 1730 2607 1731 - ret = pConvertInterfaceLuidToIndex( NULL, &index ); 1732 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2608 + /* ConvertInterfaceLuidToGuid */ 2609 + memset( &guid, 0xff, sizeof(guid) ); 2610 + ret = ConvertInterfaceLuidToGuid( NULL, &guid ); 2611 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2612 + ok( guid.Data1 == 0xffffffff, "got %s\n", debugstr_guid(&guid) ); 1733 2613 1734 - ret = pConvertInterfaceLuidToIndex( &luid, NULL ); 1735 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2614 + ret = ConvertInterfaceLuidToGuid( &luid, NULL ); 2615 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 1736 2616 1737 - ret = pConvertInterfaceLuidToIndex( &luid, &index ); 1738 - ok( !ret, "got %u\n", ret ); 2617 + memset( &guid, 0, sizeof(guid) ); 2618 + ret = ConvertInterfaceLuidToGuid( &luid, &guid ); 2619 + ok( !ret, "got %lu\n", ret ); 2620 + ok( IsEqualGUID( &guid, &row->InterfaceGuid ), "mismatch\n" ); 1739 2621 1740 - /* ConvertInterfaceLuidToGuid */ 1741 - ret = pConvertInterfaceLuidToGuid( NULL, NULL ); 1742 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2622 + /* ConvertInterfaceGuidToLuid */ 2623 + luid.Info.NetLuidIndex = 1; 2624 + ret = ConvertInterfaceGuidToLuid( NULL, &luid ); 2625 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2626 + ok( luid.Info.NetLuidIndex == 1, "got %u\n", luid.Info.NetLuidIndex ); 1743 2627 1744 - memset( &guid, 0xff, sizeof(guid) ); 1745 - ret = pConvertInterfaceLuidToGuid( NULL, &guid ); 1746 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 1747 - ok( guid.Data1 == 0xffffffff, "got %x\n", guid.Data1 ); 2628 + ret = ConvertInterfaceGuidToLuid( &guid, NULL ); 2629 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 1748 2630 1749 - ret = pConvertInterfaceLuidToGuid( &luid, NULL ); 1750 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2631 + luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; 2632 + ret = ConvertInterfaceGuidToLuid( &guid, &luid ); 2633 + ok( !ret, "got %lu\n", ret ); 2634 + ok( luid.Value == row->InterfaceLuid.Value || 2635 + broken( luid.Value != row->InterfaceLuid.Value), /* Win8 can have identical guids for two different ifaces */ 2636 + "mismatch\n" ); 2637 + if (luid.Value != row->InterfaceLuid.Value) continue; 1751 2638 1752 - memset( &guid, 0, sizeof(guid) ); 1753 - ret = pConvertInterfaceLuidToGuid( &luid, &guid ); 1754 - ok( !ret, "got %u\n", ret ); 1755 - ok( guid.Data1, "got %x\n", guid.Data1 ); 2639 + /* ConvertInterfaceLuidToNameW */ 2640 + ret = ConvertInterfaceLuidToNameW( &luid, NULL, 0 ); 2641 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 1756 2642 1757 - /* ConvertInterfaceGuidToLuid */ 1758 - ret = pConvertInterfaceGuidToLuid( NULL, NULL ); 1759 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2643 + ret = ConvertInterfaceLuidToNameW( &luid, nameW, 0 ); 2644 + ok( ret == ERROR_NOT_ENOUGH_MEMORY, "got %lu\n", ret ); 1760 2645 1761 - luid.Info.NetLuidIndex = 1; 1762 - ret = pConvertInterfaceGuidToLuid( NULL, &luid ); 1763 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 1764 - ok( luid.Info.NetLuidIndex == 1, "got %u\n", luid.Info.NetLuidIndex ); 2646 + nameW[0] = 0; 2647 + len = ARRAY_SIZE(nameW); 2648 + ret = ConvertInterfaceLuidToNameW( &luid, nameW, len ); 2649 + ok( !ret, "got %lu\n", ret ); 2650 + convert_luid_to_name( &luid, expect_nameW, len ); 2651 + ok( !wcscmp( nameW, expect_nameW ), "got %s vs %s\n", debugstr_w( nameW ), debugstr_w( expect_nameW ) ); 1765 2652 1766 - ret = pConvertInterfaceGuidToLuid( &guid, NULL ); 1767 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2653 + /* ConvertInterfaceLuidToNameA */ 2654 + ret = ConvertInterfaceLuidToNameA( &luid, NULL, 0 ); 2655 + ok( ret == ERROR_NOT_ENOUGH_MEMORY, "got %lu\n", ret ); 1768 2656 1769 - luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; 1770 - ret = pConvertInterfaceGuidToLuid( &guid, &luid ); 1771 - ok( !ret, "got %u\n", ret ); 1772 - ok( !luid.Info.Reserved, "got %x\n", luid.Info.Reserved ); 1773 - ok( luid.Info.NetLuidIndex != 0xdead, "index not set\n" ); 1774 - ok( luid.Info.IfType == IF_TYPE_ETHERNET_CSMACD, "got %u\n", luid.Info.IfType ); 2657 + ret = ConvertInterfaceLuidToNameA( &luid, nameA, 0 ); 2658 + ok( ret == ERROR_NOT_ENOUGH_MEMORY, "got %lu\n", ret ); 1775 2659 1776 - /* ConvertInterfaceLuidToNameW */ 1777 - ret = pConvertInterfaceLuidToNameW( NULL, NULL, 0 ); 1778 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2660 + nameA[0] = 0; 2661 + len = ARRAY_SIZE(nameA); 2662 + ret = ConvertInterfaceLuidToNameA( &luid, nameA, len ); 2663 + ok( !ret, "got %lu\n", ret ); 2664 + ok( nameA[0], "name not set\n" ); 1779 2665 1780 - ret = pConvertInterfaceLuidToNameW( &luid, NULL, 0 ); 1781 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2666 + /* ConvertInterfaceNameToLuidW */ 2667 + luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; 2668 + ret = ConvertInterfaceNameToLuidW( NULL, &luid ); 2669 + ok( ret == ERROR_INVALID_NAME, "got %lu\n", ret ); 2670 + ok( !luid.Info.Reserved, "got %x\n", luid.Info.Reserved ); 2671 + ok( luid.Info.NetLuidIndex != 0xdead, "index not set\n" ); 2672 + ok( !luid.Info.IfType, "got %u\n", luid.Info.IfType ); 1782 2673 1783 - ret = pConvertInterfaceLuidToNameW( NULL, nameW, 0 ); 1784 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2674 + ret = ConvertInterfaceNameToLuidW( nameW, NULL ); 2675 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 1785 2676 1786 - ret = pConvertInterfaceLuidToNameW( &luid, nameW, 0 ); 1787 - ok( ret == ERROR_NOT_ENOUGH_MEMORY, "got %u\n", ret ); 2677 + luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; 2678 + ret = ConvertInterfaceNameToLuidW( nameW, &luid ); 2679 + ok( !ret, "got %lu\n", ret ); 2680 + ok( luid.Value == row->InterfaceLuid.Value, "mismatch\n" ); 1788 2681 1789 - nameW[0] = 0; 1790 - len = sizeof(nameW)/sizeof(nameW[0]); 1791 - ret = pConvertInterfaceLuidToNameW( &luid, nameW, len ); 1792 - ok( !ret, "got %u\n", ret ); 1793 - ok( nameW[0], "name not set\n" ); 2682 + /* ConvertInterfaceNameToLuidA */ 2683 + luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; 2684 + ret = ConvertInterfaceNameToLuidA( NULL, &luid ); 2685 + ok( ret == ERROR_INVALID_NAME, "got %lu\n", ret ); 2686 + #if defined(__REACTOS__) && defined(_MSC_VER) 2687 + ok( luid.Info.Reserved == 0xffdead, "reserved set\n" ); 2688 + ok( luid.Info.NetLuidIndex == 0xffdead, "index set\n" ); 2689 + #else 2690 + ok( luid.Info.Reserved == 0xdead, "reserved set\n" ); 2691 + ok( luid.Info.NetLuidIndex == 0xdead, "index set\n" ); 2692 + #endif 2693 + ok( luid.Info.IfType == 0xdead, "type set\n" ); 1794 2694 1795 - /* ConvertInterfaceLuidToNameA */ 1796 - ret = pConvertInterfaceLuidToNameA( NULL, NULL, 0 ); 1797 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2695 + ret = ConvertInterfaceNameToLuidA( nameA, NULL ); 2696 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 1798 2697 1799 - ret = pConvertInterfaceLuidToNameA( &luid, NULL, 0 ); 1800 - ok( ret == ERROR_NOT_ENOUGH_MEMORY, "got %u\n", ret ); 2698 + luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; 2699 + ret = ConvertInterfaceNameToLuidA( nameA, &luid ); 2700 + ok( !ret, "got %lu\n", ret ); 2701 + ok( luid.Value == row->InterfaceLuid.Value, "mismatch\n" ); 1801 2702 1802 - ret = pConvertInterfaceLuidToNameA( NULL, nameA, 0 ); 1803 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2703 + /* ConvertInterfaceAliasToLuid */ 2704 + ret = ConvertInterfaceAliasToLuid( row->Alias, &luid ); 2705 + ok( !ret, "got %lu\n", ret ); 2706 + ok( luid.Value == row->InterfaceLuid.Value, "mismatch\n" ); 1804 2707 1805 - ret = pConvertInterfaceLuidToNameA( &luid, nameA, 0 ); 1806 - ok( ret == ERROR_NOT_ENOUGH_MEMORY, "got %u\n", ret ); 2708 + /* ConvertInterfaceLuidToAlias */ 2709 + ret = ConvertInterfaceLuidToAlias( &row->InterfaceLuid, alias, ARRAY_SIZE(alias) ); 2710 + ok( !ret, "got %lu\n", ret ); 2711 + ok( !wcscmp( alias, row->Alias ), "got %s vs %s\n", wine_dbgstr_w( alias ), wine_dbgstr_w( row->Alias ) ); 1807 2712 1808 - nameA[0] = 0; 1809 - len = sizeof(nameA)/sizeof(nameA[0]); 1810 - ret = pConvertInterfaceLuidToNameA( &luid, nameA, len ); 1811 - ok( !ret, "got %u\n", ret ); 1812 - ok( nameA[0], "name not set\n" ); 2713 + index = if_nametoindex( nameA ); 2714 + ok( index == row->InterfaceIndex, "Got index %lu for %s, expected %lu\n", index, nameA, row->InterfaceIndex ); 2715 + /* Wargaming.net Game Center passes a GUID-like string. */ 2716 + index = if_nametoindex( "{00000001-0000-0000-0000-000000000000}" ); 2717 + ok( !index, "Got unexpected index %lu\n", index ); 2718 + index = if_nametoindex( wine_dbgstr_guid( &guid ) ); 2719 + ok( !index, "Got unexpected index %lu for input %s\n", index, wine_dbgstr_guid( &guid ) ); 1813 2720 1814 - /* ConvertInterfaceNameToLuidW */ 1815 - ret = pConvertInterfaceNameToLuidW( NULL, NULL ); 1816 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2721 + /* if_indextoname */ 2722 + nameA[0] = 0; 2723 + name = if_indextoname( row->InterfaceIndex, nameA ); 2724 + ConvertInterfaceLuidToNameA( &row->InterfaceLuid, expect_nameA, ARRAY_SIZE(expect_nameA) ); 2725 + ok( name == nameA, "mismatch\n" ); 2726 + ok( !strcmp( nameA, expect_nameA ), "mismatch\n" ); 2727 + } 2728 + FreeMibTable( table ); 2729 + } 1817 2730 1818 - luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; 1819 - ret = pConvertInterfaceNameToLuidW( NULL, &luid ); 1820 - ok( ret == ERROR_INVALID_NAME, "got %u\n", ret ); 1821 - ok( !luid.Info.Reserved, "got %x\n", luid.Info.Reserved ); 1822 - ok( luid.Info.NetLuidIndex != 0xdead, "index not set\n" ); 1823 - ok( !luid.Info.IfType, "got %u\n", luid.Info.IfType ); 2731 + static void test_interface_identifier_conversion_failure(void) 2732 + { 2733 + DWORD ret; 2734 + WCHAR nameW[IF_MAX_STRING_SIZE + 1]; 2735 + char nameA[IF_MAX_STRING_SIZE + 1], *name; 2736 + NET_IFINDEX index; 2737 + NET_LUID luid; 2738 + GUID guid; 2739 + static const GUID guid_zero; 2740 + static const GUID guid_ones = { 0xffffffffUL, 0xffff, 0xffff, { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }; 1824 2741 1825 - ret = pConvertInterfaceNameToLuidW( nameW, NULL ); 1826 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2742 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 2743 + if (!ConvertInterfaceIndexToLuid || !ConvertInterfaceLuidToIndex || 2744 + !ConvertInterfaceLuidToGuid || !ConvertInterfaceGuidToLuid || 2745 + !ConvertInterfaceLuidToNameW || !ConvertInterfaceLuidToNameA || 2746 + !ConvertInterfaceNameToLuidW || !ConvertInterfaceNameToLuidA || 2747 + !if_nametoindex || !if_indextoname) { 2748 + skip("Missing APIs!\n"); 2749 + return; 2750 + } 2751 + #endif 2752 + /* ConvertInterfaceIndexToLuid */ 2753 + ret = ConvertInterfaceIndexToLuid( 0, NULL ); 2754 + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", ret ); 1827 2755 1828 - luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; 1829 - ret = pConvertInterfaceNameToLuidW( nameW, &luid ); 1830 - ok( !ret, "got %u\n", ret ); 1831 - ok( !luid.Info.Reserved, "got %x\n", luid.Info.Reserved ); 1832 - ok( luid.Info.NetLuidIndex != 0xdead, "index not set\n" ); 1833 - ok( luid.Info.IfType == IF_TYPE_ETHERNET_CSMACD, "got %u\n", luid.Info.IfType ); 2756 + ret = ConvertInterfaceIndexToLuid( -1, &luid ); 2757 + ok( ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %lu\n", ret ); 2758 + 2759 + /* ConvertInterfaceLuidToIndex */ 2760 + ret = ConvertInterfaceLuidToIndex( NULL, NULL ); 2761 + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", ret ); 2762 + 2763 + ret = ConvertInterfaceLuidToIndex( NULL, &index ); 2764 + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", ret ); 2765 + 2766 + luid.Value = -1; 2767 + index = -1; 2768 + ret = ConvertInterfaceLuidToIndex( &luid, &index ); 2769 + ok( ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %lu\n", ret ); 2770 + ok( index == 0, "index shall be zero (got %lu)\n", index ); 2771 + 2772 + /* ConvertInterfaceLuidToGuid */ 2773 + ret = ConvertInterfaceLuidToGuid( NULL, NULL ); 2774 + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", ret ); 2775 + 2776 + luid.Value = -1; 2777 + memcpy( &guid, &guid_ones, sizeof(guid) ); 2778 + ret = ConvertInterfaceLuidToGuid( &luid, &guid ); 2779 + ok( ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %lu\n", ret ); 2780 + ok( memcmp( &guid, &guid_zero, sizeof(guid) ) == 0, "guid shall be nil\n" ); 2781 + 2782 + /* ConvertInterfaceGuidToLuid */ 2783 + ret = ConvertInterfaceGuidToLuid( NULL, NULL ); 2784 + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", ret ); 2785 + 2786 + /* ConvertInterfaceLuidToNameW */ 2787 + ret = ConvertInterfaceLuidToNameW( NULL, NULL, 0 ); 2788 + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", ret ); 2789 + 2790 + memset( nameW, 0, sizeof(nameW) ); 2791 + ret = ConvertInterfaceLuidToNameW( NULL, nameW, 0 ); 2792 + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", ret ); 2793 + ok( !nameW[0], "nameW shall not change\n" ); 2794 + 2795 + /* ConvertInterfaceLuidToNameA */ 2796 + ret = ConvertInterfaceLuidToNameA( NULL, NULL, 0 ); 2797 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2798 + 2799 + memset( nameA, 0, sizeof(nameA) ); 2800 + ret = ConvertInterfaceLuidToNameA( NULL, nameA, 0 ); 2801 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2802 + ok( !nameA[0], "nameA shall not change\n" ); 2803 + 2804 + /* ConvertInterfaceNameToLuidW */ 2805 + ret = ConvertInterfaceNameToLuidW( NULL, NULL ); 2806 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 1834 2807 1835 2808 /* ConvertInterfaceNameToLuidA */ 1836 - ret = pConvertInterfaceNameToLuidA( NULL, NULL ); 1837 - ok( ret == ERROR_INVALID_NAME, "got %u\n", ret ); 2809 + ret = ConvertInterfaceNameToLuidA( NULL, NULL ); 2810 + ok( ret == ERROR_INVALID_NAME, "got %lu\n", ret ); 1838 2811 1839 - luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; 1840 - ret = pConvertInterfaceNameToLuidA( NULL, &luid ); 1841 - ok( ret == ERROR_INVALID_NAME, "got %u\n", ret ); 1842 - ok( luid.Info.Reserved == 0xdead, "reserved set\n" ); 1843 - ok( luid.Info.NetLuidIndex == 0xdead, "index set\n" ); 1844 - ok( luid.Info.IfType == 0xdead, "type set\n" ); 2812 + /* if_nametoindex */ 2813 + index = if_nametoindex( NULL ); 2814 + ok( !index, "Got unexpected index %lu\n", index ); 1845 2815 1846 - ret = pConvertInterfaceNameToLuidA( nameA, NULL ); 1847 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2816 + /* if_indextoname */ 2817 + name = if_indextoname( 0, NULL ); 2818 + ok( name == NULL, "expected NULL, got %s\n", name ); 1848 2819 1849 - luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; 1850 - ret = pConvertInterfaceNameToLuidA( nameA, &luid ); 1851 - ok( !ret, "got %u\n", ret ); 1852 - ok( !luid.Info.Reserved, "got %x\n", luid.Info.Reserved ); 1853 - ok( luid.Info.NetLuidIndex != 0xdead, "index not set\n" ); 1854 - ok( luid.Info.IfType == IF_TYPE_ETHERNET_CSMACD, "got %u\n", luid.Info.IfType ); 2820 + name = if_indextoname( 0, nameA ); 2821 + ok( name == NULL, "expected NULL, got %p\n", name ); 2822 + 2823 + name = if_indextoname( ~0u, nameA ); 2824 + ok( name == NULL, "expected NULL, got %p\n", name ); 1855 2825 } 1856 2826 1857 2827 static void test_GetIfEntry2(void) ··· 1860 2830 MIB_IF_ROW2 row; 1861 2831 NET_IFINDEX index; 1862 2832 1863 - if (!pGetIfEntry2) 1864 - { 1865 - win_skip( "GetIfEntry2 not available\n" ); 2833 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 2834 + if (!GetIfEntry2) { 2835 + skip("Missing APIs!\n"); 1866 2836 return; 1867 2837 } 2838 + #endif 1868 2839 if (!(index = get_interface_index())) 1869 2840 { 1870 2841 skip( "no suitable interface found\n" ); 1871 2842 return; 1872 2843 } 1873 2844 1874 - ret = pGetIfEntry2( NULL ); 1875 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2845 + ret = GetIfEntry2( NULL ); 2846 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 1876 2847 1877 2848 memset( &row, 0, sizeof(row) ); 1878 - ret = pGetIfEntry2( &row ); 1879 - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); 2849 + ret = GetIfEntry2( &row ); 2850 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 1880 2851 1881 2852 memset( &row, 0, sizeof(row) ); 1882 2853 row.InterfaceIndex = index; 1883 - ret = pGetIfEntry2( &row ); 1884 - ok( ret == NO_ERROR, "got %u\n", ret ); 1885 - ok( row.InterfaceIndex == index, "got %u\n", index ); 2854 + ret = GetIfEntry2( &row ); 2855 + ok( ret == NO_ERROR, "got %lu\n", ret ); 2856 + ok( row.InterfaceIndex == index, "got %lu\n", index ); 1886 2857 } 1887 2858 1888 2859 static void test_GetIfTable2(void) ··· 1890 2861 DWORD ret; 1891 2862 MIB_IF_TABLE2 *table; 1892 2863 1893 - if (!pGetIfTable2) 1894 - { 1895 - win_skip( "GetIfTable2 not available\n" ); 2864 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 2865 + if (!GetIfTable2) { 2866 + skip("Missing APIs!\n"); 1896 2867 return; 1897 2868 } 2869 + #endif 2870 + table = NULL; 2871 + ret = GetIfTable2( &table ); 2872 + ok( ret == NO_ERROR, "got %lu\n", ret ); 2873 + ok( table != NULL, "table not set\n" ); 2874 + FreeMibTable( table ); 2875 + } 1898 2876 2877 + static void test_GetIfTable2Ex(void) 2878 + { 2879 + DWORD ret; 2880 + MIB_IF_TABLE2 *table; 2881 + 2882 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 2883 + if (!GetIfTable2Ex) { 2884 + skip("Missing APIs!\n"); 2885 + return; 2886 + } 2887 + #endif 1899 2888 table = NULL; 1900 - ret = pGetIfTable2( &table ); 1901 - ok( ret == NO_ERROR, "got %u\n", ret ); 2889 + ret = GetIfTable2Ex( MibIfTableNormal, &table ); 2890 + ok( ret == NO_ERROR, "got %lu\n", ret ); 1902 2891 ok( table != NULL, "table not set\n" ); 1903 - pFreeMibTable( table ); 2892 + FreeMibTable( table ); 2893 + 2894 + table = NULL; 2895 + ret = GetIfTable2Ex( MibIfTableRaw, &table ); 2896 + ok( ret == NO_ERROR, "got %lu\n", ret ); 2897 + ok( table != NULL, "table not set\n" ); 2898 + FreeMibTable( table ); 2899 + 2900 + table = NULL; 2901 + ret = GetIfTable2Ex( MibIfTableNormalWithoutStatistics, &table ); 2902 + ok( ret == NO_ERROR || broken(ret == ERROR_INVALID_PARAMETER), "got %lu\n", ret ); 2903 + ok( table != NULL || broken(!table), "table not set\n" ); 2904 + FreeMibTable( table ); 2905 + 2906 + table = NULL; 2907 + ret = GetIfTable2Ex( 3, &table ); 2908 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2909 + ok( !table, "table should not be set\n" ); 2910 + FreeMibTable( table ); 2911 + } 2912 + 2913 + static void test_GetUnicastIpAddressEntry(void) 2914 + { 2915 + IP_ADAPTER_ADDRESSES *aa, *ptr; 2916 + MIB_UNICASTIPADDRESS_ROW row; 2917 + DWORD ret; 2918 + 2919 + if (!pGetUnicastIpAddressEntry) 2920 + { 2921 + win_skip( "GetUnicastIpAddressEntry not available\n" ); 2922 + return; 2923 + } 2924 + 2925 + ret = pGetUnicastIpAddressEntry( NULL ); 2926 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2927 + 2928 + memset( &row, 0, sizeof(row) ); 2929 + ret = pGetUnicastIpAddressEntry( &row ); 2930 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2931 + 2932 + memset( &row, 0, sizeof(row) ); 2933 + row.Address.Ipv4.sin_family = AF_INET; 2934 + row.Address.Ipv4.sin_port = 0; 2935 + row.Address.Ipv4.sin_addr.S_un.S_addr = 0x01020304; 2936 + ret = pGetUnicastIpAddressEntry( &row ); 2937 + ok( ret == ERROR_FILE_NOT_FOUND, "got %lu\n", ret ); 2938 + 2939 + memset( &row, 0, sizeof(row) ); 2940 + row.InterfaceIndex = 123; 2941 + ret = pGetUnicastIpAddressEntry( &row ); 2942 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 2943 + 2944 + memset( &row, 0, sizeof(row) ); 2945 + row.InterfaceIndex = get_interface_index(); 2946 + row.Address.Ipv4.sin_family = AF_INET; 2947 + row.Address.Ipv4.sin_port = 0; 2948 + row.Address.Ipv4.sin_addr.S_un.S_addr = 0x01020304; 2949 + ret = pGetUnicastIpAddressEntry( &row ); 2950 + ok( ret == ERROR_NOT_FOUND, "got %lu\n", ret ); 2951 + 2952 + memset( &row, 0, sizeof(row) ); 2953 + row.InterfaceIndex = 123; 2954 + row.Address.Ipv4.sin_family = AF_INET; 2955 + row.Address.Ipv4.sin_port = 0; 2956 + row.Address.Ipv4.sin_addr.S_un.S_addr = 0x01020304; 2957 + ret = pGetUnicastIpAddressEntry( &row ); 2958 + ok( ret == ERROR_FILE_NOT_FOUND, "got %lu\n", ret ); 2959 + 2960 + ptr = get_adapters( GAA_FLAG_INCLUDE_ALL_INTERFACES ); 2961 + ok(ptr != NULL, "can't get adapters\n"); 2962 + 2963 + for (aa = ptr; !ret && aa; aa = aa->Next) 2964 + { 2965 + IP_ADAPTER_UNICAST_ADDRESS *ua; 2966 + 2967 + ua = aa->FirstUnicastAddress; 2968 + while (ua) 2969 + { 2970 + /* test with luid */ 2971 + memset( &row, 0, sizeof(row) ); 2972 + memcpy(&row.InterfaceLuid, &aa->Luid, sizeof(aa->Luid)); 2973 + memcpy(&row.Address, ua->Address.lpSockaddr, ua->Address.iSockaddrLength); 2974 + ret = pGetUnicastIpAddressEntry( &row ); 2975 + ok( ret == NO_ERROR, "got %lu\n", ret ); 2976 + 2977 + /* test with index */ 2978 + memset( &row, 0, sizeof(row) ); 2979 + row.InterfaceIndex = aa->IfIndex; 2980 + memcpy(&row.Address, ua->Address.lpSockaddr, ua->Address.iSockaddrLength); 2981 + ret = pGetUnicastIpAddressEntry( &row ); 2982 + ok( ret == NO_ERROR, "got %lu\n", ret ); 2983 + if (ret == NO_ERROR) 2984 + { 2985 + ok(row.InterfaceLuid.Info.Reserved == aa->Luid.Info.Reserved, "Expected %d, got %d\n", 2986 + aa->Luid.Info.Reserved, row.InterfaceLuid.Info.Reserved); 2987 + ok(row.InterfaceLuid.Info.NetLuidIndex == aa->Luid.Info.NetLuidIndex, "Expected %d, got %d\n", 2988 + aa->Luid.Info.NetLuidIndex, row.InterfaceLuid.Info.NetLuidIndex); 2989 + ok(row.InterfaceLuid.Info.IfType == aa->Luid.Info.IfType, "Expected %d, got %d\n", 2990 + aa->Luid.Info.IfType, row.InterfaceLuid.Info.IfType); 2991 + ok(row.InterfaceIndex == aa->IfIndex, "Expected %ld, got %ld\n", 2992 + aa->IfIndex, row.InterfaceIndex); 2993 + ok(row.PrefixOrigin == ua->PrefixOrigin, "Expected %d, got %d\n", 2994 + ua->PrefixOrigin, row.PrefixOrigin); 2995 + ok(row.SuffixOrigin == ua->SuffixOrigin, "Expected %d, got %d\n", 2996 + ua->SuffixOrigin, row.SuffixOrigin); 2997 + ok(row.ValidLifetime == ua->ValidLifetime, "Expected %ld, got %ld\n", 2998 + ua->ValidLifetime, row.ValidLifetime); 2999 + ok(row.PreferredLifetime == ua->PreferredLifetime, "Expected %ld, got %ld\n", 3000 + ua->PreferredLifetime, row.PreferredLifetime); 3001 + ok(row.OnLinkPrefixLength == ua->OnLinkPrefixLength, "Expected %d, got %d\n", 3002 + ua->OnLinkPrefixLength, row.OnLinkPrefixLength); 3003 + ok(row.SkipAsSource == 0, "Expected 0, got %d\n", row.SkipAsSource); 3004 + ok(row.DadState == ua->DadState, "Expected %d, got %d\n", ua->DadState, row.DadState); 3005 + if (row.Address.si_family == AF_INET6) 3006 + ok(row.ScopeId.Value == row.Address.Ipv6.sin6_scope_id, "Expected %ld, got %ld\n", 3007 + row.Address.Ipv6.sin6_scope_id, row.ScopeId.Value); 3008 + ok(row.CreationTimeStamp.QuadPart, "CreationTimeStamp is 0\n"); 3009 + } 3010 + ua = ua->Next; 3011 + } 3012 + } 3013 + free(ptr); 3014 + } 3015 + 3016 + static void test_GetUnicastIpAddressTable(void) 3017 + { 3018 + MIB_UNICASTIPADDRESS_TABLE *table; 3019 + DWORD ret; 3020 + ULONG i; 3021 + 3022 + if (!pGetUnicastIpAddressTable) 3023 + { 3024 + win_skip( "GetUnicastIpAddressTable not available\n" ); 3025 + return; 3026 + } 3027 + 3028 + ret = pGetUnicastIpAddressTable(AF_UNSPEC, NULL); 3029 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 3030 + 3031 + ret = pGetUnicastIpAddressTable(AF_BAN, &table); 3032 + ok( ret == ERROR_INVALID_PARAMETER, "got %lu\n", ret ); 3033 + 3034 + ret = pGetUnicastIpAddressTable(AF_INET, &table); 3035 + ok( ret == NO_ERROR, "got %lu\n", ret ); 3036 + trace("GetUnicastIpAddressTable(AF_INET): NumEntries %lu\n", table->NumEntries); 3037 + FreeMibTable( table ); 3038 + 3039 + ret = pGetUnicastIpAddressTable(AF_INET6, &table); 3040 + ok( ret == NO_ERROR, "got %lu\n", ret ); 3041 + trace("GetUnicastIpAddressTable(AF_INET6): NumEntries %lu\n", table->NumEntries); 3042 + FreeMibTable( table ); 3043 + 3044 + ret = pGetUnicastIpAddressTable(AF_UNSPEC, &table); 3045 + ok( ret == NO_ERROR, "got %lu\n", ret ); 3046 + trace("GetUnicastIpAddressTable(AF_UNSPEC): NumEntries %lu\n", table->NumEntries); 3047 + for (i = 0; i < table->NumEntries && winetest_debug > 1; i++) 3048 + { 3049 + trace("Index %lu:\n", i); 3050 + trace("Address.si_family: %u\n", table->Table[i].Address.si_family); 3051 + trace("InterfaceLuid.Info.Reserved: %u\n", table->Table[i].InterfaceLuid.Info.Reserved); 3052 + trace("InterfaceLuid.Info.NetLuidIndex: %u\n", table->Table[i].InterfaceLuid.Info.NetLuidIndex); 3053 + trace("InterfaceLuid.Info.IfType: %u\n", table->Table[i].InterfaceLuid.Info.IfType); 3054 + trace("InterfaceIndex: %lu\n", table->Table[i].InterfaceIndex); 3055 + trace("PrefixOrigin: %u\n", table->Table[i].PrefixOrigin); 3056 + trace("SuffixOrigin: %u\n", table->Table[i].SuffixOrigin); 3057 + trace("ValidLifetime: %lu seconds\n", table->Table[i].ValidLifetime); 3058 + trace("PreferredLifetime: %lu seconds\n", table->Table[i].PreferredLifetime); 3059 + trace("OnLinkPrefixLength: %u\n", table->Table[i].OnLinkPrefixLength); 3060 + trace("SkipAsSource: %u\n", table->Table[i].SkipAsSource); 3061 + trace("DadState: %u\n", table->Table[i].DadState); 3062 + trace("ScopeId.Value: %lu\n", table->Table[i].ScopeId.Value); 3063 + trace("CreationTimeStamp: %08lx%08lx\n", table->Table[i].CreationTimeStamp.HighPart, table->Table[i].CreationTimeStamp.LowPart); 3064 + } 3065 + 3066 + FreeMibTable( table ); 3067 + } 3068 + 3069 + static void test_ConvertLengthToIpv4Mask(void) 3070 + { 3071 + DWORD ret; 3072 + DWORD n; 3073 + ULONG mask; 3074 + ULONG expected; 3075 + 3076 + if (!pConvertLengthToIpv4Mask) 3077 + { 3078 + win_skip( "ConvertLengthToIpv4Mask not available\n" ); 3079 + return; 3080 + } 3081 + 3082 + for (n = 0; n <= 32; n++) 3083 + { 3084 + mask = 0xdeadbeef; 3085 + if (n > 0) 3086 + expected = htonl( ~0u << (32 - n) ); 3087 + else 3088 + expected = 0; 3089 + 3090 + ret = pConvertLengthToIpv4Mask( n, &mask ); 3091 + ok( ret == NO_ERROR, "ConvertLengthToIpv4Mask returned 0x%08lx, expected 0x%08x\n", ret, NO_ERROR ); 3092 + ok( mask == expected, "ConvertLengthToIpv4Mask mask value 0x%08lx, expected 0x%08lx\n", mask, expected ); 3093 + } 3094 + 3095 + /* Testing for out of range. In this case both mask and return are changed to indicate error. */ 3096 + mask = 0xdeadbeef; 3097 + ret = pConvertLengthToIpv4Mask( 33, &mask ); 3098 + ok( ret == ERROR_INVALID_PARAMETER, "ConvertLengthToIpv4Mask returned 0x%08lx, expected 0x%08x\n", ret, ERROR_INVALID_PARAMETER ); 3099 + ok( mask == INADDR_NONE, "ConvertLengthToIpv4Mask mask value 0x%08lx, expected 0x%08x\n", mask, INADDR_NONE ); 3100 + } 3101 + 3102 + static void test_GetTcp6Table(void) 3103 + { 3104 + DWORD ret; 3105 + ULONG size = 0; 3106 + PMIB_TCP6TABLE buf; 3107 + 3108 + if (!pGetTcp6Table) 3109 + { 3110 + win_skip("GetTcp6Table not available\n"); 3111 + return; 3112 + } 3113 + 3114 + ret = pGetTcp6Table(NULL, &size, FALSE); 3115 + if (ret == ERROR_NOT_SUPPORTED) 3116 + { 3117 + skip("GetTcp6Table is not supported\n"); 3118 + return; 3119 + } 3120 + ok(ret == ERROR_INSUFFICIENT_BUFFER, 3121 + "GetTcp6Table(NULL, &size, FALSE) returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n", ret); 3122 + if (ret != ERROR_INSUFFICIENT_BUFFER) return; 3123 + 3124 + buf = malloc(size); 3125 + 3126 + ret = pGetTcp6Table(buf, &size, FALSE); 3127 + ok(ret == NO_ERROR, 3128 + "GetTcp6Table(buf, &size, FALSE) returned %ld, expected NO_ERROR\n", ret); 3129 + 3130 + if (ret == NO_ERROR && winetest_debug > 1) 3131 + { 3132 + DWORD i; 3133 + trace("TCP6 table: %lu entries\n", buf->dwNumEntries); 3134 + for (i = 0; i < buf->dwNumEntries; i++) 3135 + { 3136 + trace("%lu: local %s%%%u:%u remote %s%%%u:%u state %u\n", i, 3137 + ntoa6(&buf->table[i].LocalAddr), ntohs(buf->table[i].dwLocalScopeId), 3138 + ntohs(buf->table[i].dwLocalPort), ntoa6(&buf->table[i].RemoteAddr), 3139 + ntohs(buf->table[i].dwRemoteScopeId), ntohs(buf->table[i].dwRemotePort), 3140 + buf->table[i].State); 3141 + } 3142 + } 3143 + 3144 + free(buf); 3145 + } 3146 + 3147 + static void test_GetUdp6Table(void) 3148 + { 3149 + DWORD apiReturn; 3150 + ULONG dwSize = 0; 3151 + 3152 + if (!pGetUdp6Table) { 3153 + win_skip("GetUdp6Table not available\n"); 3154 + return; 3155 + } 3156 + 3157 + apiReturn = pGetUdp6Table(NULL, &dwSize, FALSE); 3158 + if (apiReturn == ERROR_NOT_SUPPORTED) { 3159 + skip("GetUdp6Table is not supported\n"); 3160 + return; 3161 + } 3162 + ok(apiReturn == ERROR_INSUFFICIENT_BUFFER, 3163 + "GetUdp6Table(NULL, &dwSize, FALSE) returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n", 3164 + apiReturn); 3165 + if (apiReturn == ERROR_INSUFFICIENT_BUFFER) { 3166 + PMIB_UDP6TABLE buf = malloc(dwSize); 3167 + 3168 + apiReturn = pGetUdp6Table(buf, &dwSize, FALSE); 3169 + ok(apiReturn == NO_ERROR, 3170 + "GetUdp6Table(buf, &dwSize, FALSE) returned %ld, expected NO_ERROR\n", 3171 + apiReturn); 3172 + 3173 + if (apiReturn == NO_ERROR && winetest_debug > 1) 3174 + { 3175 + DWORD i; 3176 + trace( "UDP6 table: %lu entries\n", buf->dwNumEntries ); 3177 + for (i = 0; i < buf->dwNumEntries; i++) 3178 + trace( "%lu: %s%%%u:%u\n", 3179 + i, ntoa6(&buf->table[i].dwLocalAddr), ntohs(buf->table[i].dwLocalScopeId), ntohs(buf->table[i].dwLocalPort) ); 3180 + } 3181 + free(buf); 3182 + } 3183 + } 3184 + 3185 + static void test_ParseNetworkString(void) 3186 + { 3187 + struct 3188 + { 3189 + char str[32]; 3190 + IN_ADDR addr; 3191 + DWORD ret; 3192 + } 3193 + ipv4_address_tests[] = 3194 + { 3195 + {"1.2.3.4", {{{1, 2, 3, 4}}}}, 3196 + #if defined(__REACTOS__) && defined(_MSC_VER) && _MSC_VER < 1930 3197 + {"1.2.3.4a", {0}, ERROR_INVALID_PARAMETER}, 3198 + {"1.2.3.0x4a", {0}, ERROR_INVALID_PARAMETER}, 3199 + {"1.2.3", {0}, ERROR_INVALID_PARAMETER}, 3200 + {"a1.2.3.4", {0}, ERROR_INVALID_PARAMETER}, 3201 + {"0xdeadbeef", {0}, ERROR_INVALID_PARAMETER}, 3202 + {"1.2.3.4:22", {0}, ERROR_INVALID_PARAMETER}, 3203 + {"::1", {0}, ERROR_INVALID_PARAMETER}, 3204 + {"winehq.org", {0}, ERROR_INVALID_PARAMETER}, 3205 + #else 3206 + {"1.2.3.4a", {}, ERROR_INVALID_PARAMETER}, 3207 + {"1.2.3.0x4a", {}, ERROR_INVALID_PARAMETER}, 3208 + {"1.2.3", {}, ERROR_INVALID_PARAMETER}, 3209 + {"a1.2.3.4", {}, ERROR_INVALID_PARAMETER}, 3210 + {"0xdeadbeef", {}, ERROR_INVALID_PARAMETER}, 3211 + {"1.2.3.4:22", {}, ERROR_INVALID_PARAMETER}, 3212 + {"::1", {}, ERROR_INVALID_PARAMETER}, 3213 + {"winehq.org", {}, ERROR_INVALID_PARAMETER}, 3214 + #endif 3215 + }; 3216 + struct 3217 + { 3218 + char str[32]; 3219 + IN_ADDR addr; 3220 + DWORD port; 3221 + DWORD ret; 3222 + } 3223 + ipv4_service_tests[] = 3224 + { 3225 + {"1.2.3.4:22", {{{1, 2, 3, 4}}}, 22}, 3226 + #if defined(__REACTOS__) && defined(_MSC_VER) && _MSC_VER < 1930 3227 + {"winehq.org:22", {0}, 0, ERROR_INVALID_PARAMETER}, 3228 + {"1.2.3.4", {0}, 0, ERROR_INVALID_PARAMETER}, 3229 + {"1.2.3.4:0", {0}, 0, ERROR_INVALID_PARAMETER}, 3230 + {"1.2.3.4:65536", {0}, 0, ERROR_INVALID_PARAMETER}, 3231 + #else 3232 + {"winehq.org:22", {}, 0, ERROR_INVALID_PARAMETER}, 3233 + {"1.2.3.4", {}, 0, ERROR_INVALID_PARAMETER}, 3234 + {"1.2.3.4:0", {}, 0, ERROR_INVALID_PARAMETER}, 3235 + {"1.2.3.4:65536", {}, 0, ERROR_INVALID_PARAMETER}, 3236 + #endif 3237 + }; 3238 + WCHAR wstr[IP6_ADDRESS_STRING_BUFFER_LENGTH] = {'1','2','7','.','0','.','0','.','1',':','2','2',0}; 3239 + NET_ADDRESS_INFO info; 3240 + USHORT port; 3241 + BYTE prefix_len; 3242 + DWORD ret; 3243 + int i; 3244 + 3245 + if (!pParseNetworkString) 3246 + { 3247 + win_skip("ParseNetworkString not available\n"); 3248 + return; 3249 + } 3250 + 3251 + ret = pParseNetworkString(wstr, -1, NULL, NULL, NULL); 3252 + ok(ret == ERROR_SUCCESS, "expected success, got %ld\n", ret); 3253 + 3254 + ret = pParseNetworkString(NULL, NET_STRING_IPV4_SERVICE, &info, NULL, NULL); 3255 + ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", ret); 3256 + 3257 + for (i = 0; i < ARRAY_SIZE(ipv4_address_tests); i++) 3258 + { 3259 + MultiByteToWideChar(CP_ACP, 0, ipv4_address_tests[i].str, sizeof(ipv4_address_tests[i].str), 3260 + wstr, ARRAY_SIZE(wstr)); 3261 + memset(&info, 0x99, sizeof(info)); 3262 + port = 0x9999; 3263 + prefix_len = 0x99; 3264 + 3265 + ret = pParseNetworkString(wstr, NET_STRING_IPV4_ADDRESS, &info, &port, &prefix_len); 3266 + 3267 + ok(ret == ipv4_address_tests[i].ret, 3268 + "%s gave error %ld\n", ipv4_address_tests[i].str, ret); 3269 + ok(info.Format == ret ? NET_ADDRESS_FORMAT_UNSPECIFIED : NET_ADDRESS_IPV4, 3270 + "%s gave format %d\n", ipv4_address_tests[i].str, info.Format); 3271 + ok(info.Ipv4Address.sin_addr.S_un.S_addr == (ret ? 0x99999999 : ipv4_address_tests[i].addr.S_un.S_addr), 3272 + "%s gave address %d.%d.%d.%d\n", ipv4_address_tests[i].str, 3273 + info.Ipv4Address.sin_addr.S_un.S_un_b.s_b1, info.Ipv4Address.sin_addr.S_un.S_un_b.s_b2, 3274 + info.Ipv4Address.sin_addr.S_un.S_un_b.s_b3, info.Ipv4Address.sin_addr.S_un.S_un_b.s_b4); 3275 + ok(info.Ipv4Address.sin_port == (ret ? 0x9999 : 0), 3276 + "%s gave port %d\n", ipv4_service_tests[i].str, ntohs(info.Ipv4Address.sin_port)); 3277 + ok(port == (ret ? 0x9999 : 0), 3278 + "%s gave port %d\n", ipv4_service_tests[i].str, port); 3279 + ok(prefix_len == (ret ? 0x99 : 255), 3280 + "%s gave prefix length %d\n", ipv4_service_tests[i].str, prefix_len); 3281 + } 3282 + 3283 + for (i = 0; i < ARRAY_SIZE(ipv4_service_tests); i++) 3284 + { 3285 + MultiByteToWideChar(CP_ACP, 0, ipv4_service_tests[i].str, sizeof(ipv4_service_tests[i].str), 3286 + wstr, ARRAY_SIZE(wstr)); 3287 + memset(&info, 0x99, sizeof(info)); 3288 + port = 0x9999; 3289 + prefix_len = 0x99; 3290 + 3291 + ret = pParseNetworkString(wstr, NET_STRING_IPV4_SERVICE, &info, &port, &prefix_len); 3292 + 3293 + ok(ret == ipv4_service_tests[i].ret, 3294 + "%s gave error %ld\n", ipv4_service_tests[i].str, ret); 3295 + ok(info.Format == ret ? NET_ADDRESS_FORMAT_UNSPECIFIED : NET_ADDRESS_IPV4, 3296 + "%s gave format %d\n", ipv4_address_tests[i].str, info.Format); 3297 + ok(info.Ipv4Address.sin_addr.S_un.S_addr == (ret ? 0x99999999 : ipv4_service_tests[i].addr.S_un.S_addr), 3298 + "%s gave address %d.%d.%d.%d\n", ipv4_service_tests[i].str, 3299 + info.Ipv4Address.sin_addr.S_un.S_un_b.s_b1, info.Ipv4Address.sin_addr.S_un.S_un_b.s_b2, 3300 + info.Ipv4Address.sin_addr.S_un.S_un_b.s_b3, info.Ipv4Address.sin_addr.S_un.S_un_b.s_b4); 3301 + ok(ntohs(info.Ipv4Address.sin_port) == (ret ? 0x9999 : ipv4_service_tests[i].port), 3302 + "%s gave port %d\n", ipv4_service_tests[i].str, ntohs(info.Ipv4Address.sin_port)); 3303 + ok(port == (ret ? 0x9999 : ipv4_service_tests[i].port), 3304 + "%s gave port %d\n", ipv4_service_tests[i].str, port); 3305 + ok(prefix_len == (ret ? 0x99 : 255), 3306 + "%s gave prefix length %d\n", ipv4_service_tests[i].str, prefix_len); 3307 + } 3308 + } 3309 + 3310 + static void WINAPI test_ipaddtess_change_callback(PVOID context, PMIB_UNICASTIPADDRESS_ROW row, 3311 + MIB_NOTIFICATION_TYPE notification_type) 3312 + { 3313 + BOOL *callback_called = context; 3314 + 3315 + *callback_called = TRUE; 3316 + 3317 + ok(notification_type == MibInitialNotification, "Unexpected notification_type %#x.\n", 3318 + notification_type); 3319 + ok(!row, "Unexpected row %p.\n", row); 3320 + } 3321 + 3322 + static void test_NotifyUnicastIpAddressChange(void) 3323 + { 3324 + BOOL callback_called; 3325 + HANDLE handle; 3326 + DWORD ret; 3327 + 3328 + if (!pNotifyUnicastIpAddressChange) 3329 + { 3330 + win_skip("NotifyUnicastIpAddressChange not available.\n"); 3331 + return; 3332 + } 3333 + 3334 + callback_called = FALSE; 3335 + ret = pNotifyUnicastIpAddressChange(AF_INET, test_ipaddtess_change_callback, 3336 + &callback_called, TRUE, &handle); 3337 + ok(ret == NO_ERROR, "Unexpected ret %#lx.\n", ret); 3338 + ok(callback_called, "Callback was not called.\n"); 3339 + 3340 + ret = pCancelMibChangeNotify2(handle); 3341 + ok(ret == NO_ERROR, "Unexpected ret %#lx.\n", ret); 3342 + ok(!CloseHandle(handle), "CloseHandle() succeeded.\n"); 3343 + } 3344 + 3345 + static void test_ConvertGuidToString( void ) 3346 + { 3347 + DWORD err; 3348 + char bufA[39]; 3349 + WCHAR bufW[39]; 3350 + GUID guid = { 0xa, 0xb, 0xc, { 0xd, 0, 0xe, 0xf } }, guid2; 3351 + 3352 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 3353 + if (!ConvertGuidToStringA || !ConvertGuidToStringW) { 3354 + skip("Missing APIs!\n"); 3355 + return; 3356 + } 3357 + #endif 3358 + err = ConvertGuidToStringA( &guid, bufA, 38 ); 3359 + ok( err, "got %ld\n", err ); 3360 + err = ConvertGuidToStringA( &guid, bufA, 39 ); 3361 + ok( !err, "got %ld\n", err ); 3362 + ok( !strcmp( bufA, "{0000000A-000B-000C-0D00-0E0F00000000}" ), "got %s\n", bufA ); 3363 + 3364 + err = ConvertGuidToStringW( &guid, bufW, 38 ); 3365 + ok( err, "got %ld\n", err ); 3366 + err = ConvertGuidToStringW( &guid, bufW, 39 ); 3367 + ok( !err, "got %ld\n", err ); 3368 + ok( !wcscmp( bufW, L"{0000000A-000B-000C-0D00-0E0F00000000}" ), "got %s\n", debugstr_w( bufW ) ); 3369 + 3370 + err = ConvertStringToGuidW( bufW, &guid2 ); 3371 + ok( !err, "got %ld\n", err ); 3372 + ok( IsEqualGUID( &guid, &guid2 ), "guid mismatch\n" ); 3373 + 3374 + err = ConvertStringToGuidW( L"foo", &guid2 ); 3375 + ok( err == ERROR_INVALID_PARAMETER, "got %ld\n", err ); 3376 + } 3377 + 3378 + static void test_compartments(void) 3379 + { 3380 + NET_IF_COMPARTMENT_ID id; 3381 + 3382 + #if defined(__REACTOS__) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA) 3383 + if (!GetCurrentThreadCompartmentId) { 3384 + skip("Missing APIs!\n"); 3385 + return; 3386 + } 3387 + #endif 3388 + id = GetCurrentThreadCompartmentId(); 3389 + ok(id == NET_IF_COMPARTMENT_ID_PRIMARY, "got %u\n", id); 1904 3390 } 1905 3391 1906 3392 START_TEST(iphlpapi) 1907 3393 { 3394 + WSADATA wsa_data; 3395 + WSAStartup(MAKEWORD(2, 2), &wsa_data); 1908 3396 1909 3397 loadIPHlpApi(); 1910 3398 if (hLibrary) { ··· 1921 3409 testWin2KFunctions(); 1922 3410 test_GetAdaptersAddresses(); 1923 3411 test_GetExtendedTcpTable(); 3412 + test_GetExtendedTcpTable_owner(AF_INET); 3413 + test_GetExtendedTcpTable_owner(AF_INET6); 1924 3414 test_GetExtendedUdpTable(); 3415 + test_GetExtendedUdpTable_owner(AF_INET); 3416 + test_GetExtendedUdpTable_owner(AF_INET6); 3417 + test_AllocateAndGetTcpExTableFromStack(); 1925 3418 test_CreateSortedAddressPairs(); 1926 3419 test_interface_identifier_conversion(); 3420 + test_interface_identifier_conversion_failure(); 1927 3421 test_GetIfEntry2(); 1928 3422 test_GetIfTable2(); 3423 + test_GetIfTable2Ex(); 3424 + test_GetUnicastIpAddressEntry(); 3425 + test_GetUnicastIpAddressTable(); 3426 + test_ConvertLengthToIpv4Mask(); 3427 + test_GetTcp6Table(); 3428 + test_GetUdp6Table(); 3429 + test_ParseNetworkString(); 3430 + test_NotifyUnicastIpAddressChange(); 3431 + test_ConvertGuidToString(); 3432 + test_compartments(); 1929 3433 freeIPHlpApi(); 1930 3434 } 3435 + 3436 + WSACleanup(); 1931 3437 }