4 * Copyright (C) 2003 Juan Lang
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * Some observations that an automated test can't produce:
23 * An adapter index is a key for an adapter. That is, if an index is returned
24 * from one API, that same index may be used successfully in another API, as
25 * long as the adapter remains present.
26 * If the adapter is removed and reinserted, however, the index may change (and
27 * indeed it does change on Win2K).
29 * The Name field of the IP_ADAPTER_INDEX_MAP entries returned by
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
32 * apparently an MS bug, it's corrected in later versions.
34 * The DomainName field of FIXED_INFO isn't NULL-terminated on Win98.
43 #include "wine/test.h"
47 static HMODULE hLibrary
= NULL
;
49 static DWORD (WINAPI
*pGetNumberOfInterfaces
)(PDWORD
);
50 static DWORD (WINAPI
*pGetIpAddrTable
)(PMIB_IPADDRTABLE
,PULONG
,BOOL
);
51 static DWORD (WINAPI
*pGetIfEntry
)(PMIB_IFROW
);
52 static DWORD (WINAPI
*pGetFriendlyIfIndex
)(DWORD
);
53 static DWORD (WINAPI
*pGetIfTable
)(PMIB_IFTABLE
,PULONG
,BOOL
);
54 static DWORD (WINAPI
*pGetIpForwardTable
)(PMIB_IPFORWARDTABLE
,PULONG
,BOOL
);
55 static DWORD (WINAPI
*pGetIpNetTable
)(PMIB_IPNETTABLE
,PULONG
,BOOL
);
56 static DWORD (WINAPI
*pGetInterfaceInfo
)(PIP_INTERFACE_INFO
,PULONG
);
57 static DWORD (WINAPI
*pGetAdaptersInfo
)(PIP_ADAPTER_INFO
,PULONG
);
58 static DWORD (WINAPI
*pGetNetworkParams
)(PFIXED_INFO
,PULONG
);
59 static DWORD (WINAPI
*pGetIcmpStatistics
)(PMIB_ICMP
);
60 static DWORD (WINAPI
*pGetIpStatistics
)(PMIB_IPSTATS
);
61 static DWORD (WINAPI
*pGetTcpStatistics
)(PMIB_TCPSTATS
);
62 static DWORD (WINAPI
*pGetUdpStatistics
)(PMIB_UDPSTATS
);
63 static DWORD (WINAPI
*pGetIcmpStatisticsEx
)(PMIB_ICMP_EX
,DWORD
);
64 static DWORD (WINAPI
*pGetIpStatisticsEx
)(PMIB_IPSTATS
,DWORD
);
65 static DWORD (WINAPI
*pGetTcpStatisticsEx
)(PMIB_TCPSTATS
,DWORD
);
66 static DWORD (WINAPI
*pGetUdpStatisticsEx
)(PMIB_UDPSTATS
,DWORD
);
67 static DWORD (WINAPI
*pGetTcpTable
)(PMIB_TCPTABLE
,PDWORD
,BOOL
);
68 static DWORD (WINAPI
*pGetUdpTable
)(PMIB_UDPTABLE
,PDWORD
,BOOL
);
69 static DWORD (WINAPI
*pGetPerAdapterInfo
)(ULONG
,PIP_PER_ADAPTER_INFO
,PULONG
);
70 static DWORD (WINAPI
*pGetAdaptersAddresses
)(ULONG
,ULONG
,PVOID
,PIP_ADAPTER_ADDRESSES
,PULONG
);
71 static DWORD (WINAPI
*pNotifyAddrChange
)(PHANDLE
,LPOVERLAPPED
);
72 static BOOL (WINAPI
*pCancelIPChangeNotify
)(LPOVERLAPPED
);
73 static DWORD (WINAPI
*pGetExtendedTcpTable
)(PVOID
,PDWORD
,BOOL
,ULONG
,TCP_TABLE_CLASS
,ULONG
);
74 static DWORD (WINAPI
*pSetTcpEntry
)(PMIB_TCPROW
);
76 static void loadIPHlpApi(void)
78 hLibrary
= LoadLibraryA("iphlpapi.dll");
80 pGetNumberOfInterfaces
= (void *)GetProcAddress(hLibrary
, "GetNumberOfInterfaces");
81 pGetIpAddrTable
= (void *)GetProcAddress(hLibrary
, "GetIpAddrTable");
82 pGetIfEntry
= (void *)GetProcAddress(hLibrary
, "GetIfEntry");
83 pGetFriendlyIfIndex
= (void *)GetProcAddress(hLibrary
, "GetFriendlyIfIndex");
84 pGetIfTable
= (void *)GetProcAddress(hLibrary
, "GetIfTable");
85 pGetIpForwardTable
= (void *)GetProcAddress(hLibrary
, "GetIpForwardTable");
86 pGetIpNetTable
= (void *)GetProcAddress(hLibrary
, "GetIpNetTable");
87 pGetInterfaceInfo
= (void *)GetProcAddress(hLibrary
, "GetInterfaceInfo");
88 pGetAdaptersInfo
= (void *)GetProcAddress(hLibrary
, "GetAdaptersInfo");
89 pGetNetworkParams
= (void *)GetProcAddress(hLibrary
, "GetNetworkParams");
90 pGetIcmpStatistics
= (void *)GetProcAddress(hLibrary
, "GetIcmpStatistics");
91 pGetIpStatistics
= (void *)GetProcAddress(hLibrary
, "GetIpStatistics");
92 pGetTcpStatistics
= (void *)GetProcAddress(hLibrary
, "GetTcpStatistics");
93 pGetUdpStatistics
= (void *)GetProcAddress(hLibrary
, "GetUdpStatistics");
94 pGetIcmpStatisticsEx
= (void *)GetProcAddress(hLibrary
, "GetIcmpStatisticsEx");
95 pGetIpStatisticsEx
= (void *)GetProcAddress(hLibrary
, "GetIpStatisticsEx");
96 pGetTcpStatisticsEx
= (void *)GetProcAddress(hLibrary
, "GetTcpStatisticsEx");
97 pGetUdpStatisticsEx
= (void *)GetProcAddress(hLibrary
, "GetUdpStatisticsEx");
98 pGetTcpTable
= (void *)GetProcAddress(hLibrary
, "GetTcpTable");
99 pGetUdpTable
= (void *)GetProcAddress(hLibrary
, "GetUdpTable");
100 pGetPerAdapterInfo
= (void *)GetProcAddress(hLibrary
, "GetPerAdapterInfo");
101 pGetAdaptersAddresses
= (void *)GetProcAddress(hLibrary
, "GetAdaptersAddresses");
102 pNotifyAddrChange
= (void *)GetProcAddress(hLibrary
, "NotifyAddrChange");
103 pCancelIPChangeNotify
= (void *)GetProcAddress(hLibrary
, "CancelIPChangeNotify");
104 pGetExtendedTcpTable
= (void *)GetProcAddress(hLibrary
, "GetExtendedTcpTable");
105 pSetTcpEntry
= (void *)GetProcAddress(hLibrary
, "SetTcpEntry");
109 static void freeIPHlpApi(void)
111 FreeLibrary(hLibrary
);
114 /* replacement for inet_ntoa */
115 static const char *ntoa( DWORD ip
)
117 static char buffer
[40];
120 sprintf( buffer
, "%u.%u.%u.%u", (ip
>> 24) & 0xff, (ip
>> 16) & 0xff, (ip
>> 8) & 0xff, ip
& 0xff );
125 still-to-be-tested 98-only functions:
126 GetUniDirectionalAdapterInfo
128 static void testWin98OnlyFunctions(void)
132 static void testGetNumberOfInterfaces(void)
134 if (pGetNumberOfInterfaces
) {
135 DWORD apiReturn
, numInterfaces
;
137 /* Crashes on Vista */
139 apiReturn
= pGetNumberOfInterfaces(NULL
);
140 if (apiReturn
== ERROR_NOT_SUPPORTED
)
142 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
143 "GetNumberOfInterfaces(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
147 apiReturn
= pGetNumberOfInterfaces(&numInterfaces
);
148 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
149 skip("GetNumberOfInterfaces is not supported\n");
152 ok(apiReturn
== NO_ERROR
,
153 "GetNumberOfInterfaces returned %d, expected 0\n", apiReturn
);
157 static void testGetIfEntry(DWORD index
)
163 memset(&row
, 0, sizeof(row
));
164 apiReturn
= pGetIfEntry(NULL
);
165 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
166 skip("GetIfEntry is not supported\n");
169 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
170 "GetIfEntry(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
172 row
.dwIndex
= -1; /* hope that's always bogus! */
173 apiReturn
= pGetIfEntry(&row
);
174 ok(apiReturn
== ERROR_INVALID_DATA
||
175 apiReturn
== ERROR_FILE_NOT_FOUND
/* Vista */,
176 "GetIfEntry(bogus row) returned %d, expected ERROR_INVALID_DATA or ERROR_FILE_NOT_FOUND\n",
179 apiReturn
= pGetIfEntry(&row
);
180 ok(apiReturn
== NO_ERROR
,
181 "GetIfEntry returned %d, expected NO_ERROR\n", apiReturn
);
185 static void testGetIpAddrTable(void)
187 if (pGetIpAddrTable
) {
191 apiReturn
= pGetIpAddrTable(NULL
, NULL
, FALSE
);
192 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
193 skip("GetIpAddrTable is not supported\n");
196 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
197 "GetIpAddrTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
199 apiReturn
= pGetIpAddrTable(NULL
, &dwSize
, FALSE
);
200 ok(apiReturn
== ERROR_INSUFFICIENT_BUFFER
,
201 "GetIpAddrTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
203 if (apiReturn
== ERROR_INSUFFICIENT_BUFFER
) {
204 PMIB_IPADDRTABLE buf
= HeapAlloc(GetProcessHeap(), 0, dwSize
);
206 apiReturn
= pGetIpAddrTable(buf
, &dwSize
, FALSE
);
207 ok(apiReturn
== NO_ERROR
,
208 "GetIpAddrTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
210 if (apiReturn
== NO_ERROR
&& buf
->dwNumEntries
)
211 testGetIfEntry(buf
->table
[0].dwIndex
);
212 HeapFree(GetProcessHeap(), 0, buf
);
217 static void testGetIfTable(void)
223 apiReturn
= pGetIfTable(NULL
, NULL
, FALSE
);
224 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
225 skip("GetIfTable is not supported\n");
228 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
229 "GetIfTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
231 apiReturn
= pGetIfTable(NULL
, &dwSize
, FALSE
);
232 ok(apiReturn
== ERROR_INSUFFICIENT_BUFFER
,
233 "GetIfTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
235 if (apiReturn
== ERROR_INSUFFICIENT_BUFFER
) {
236 PMIB_IFTABLE buf
= HeapAlloc(GetProcessHeap(), 0, dwSize
);
238 apiReturn
= pGetIfTable(buf
, &dwSize
, FALSE
);
239 ok(apiReturn
== NO_ERROR
,
240 "GetIfTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n\n",
243 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
246 char name
[MAX_INTERFACE_NAME_LEN
];
248 trace( "interface table: %u entries\n", buf
->dwNumEntries
);
249 for (i
= 0; i
< buf
->dwNumEntries
; i
++)
251 MIB_IFROW
*row
= &buf
->table
[i
];
252 WideCharToMultiByte( CP_ACP
, 0, row
->wszName
, -1, name
, MAX_INTERFACE_NAME_LEN
, NULL
, NULL
);
253 trace( "%u: '%s' type %u mtu %u speed %u phys",
254 row
->dwIndex
, name
, row
->dwType
, row
->dwMtu
, row
->dwSpeed
);
255 for (j
= 0; j
< row
->dwPhysAddrLen
; j
++)
256 printf( " %02x", row
->bPhysAddr
[j
] );
258 trace( " in: bytes %u upkts %u nupkts %u disc %u err %u unk %u\n",
259 row
->dwInOctets
, row
->dwInUcastPkts
, row
->dwInNUcastPkts
,
260 row
->dwInDiscards
, row
->dwInErrors
, row
->dwInUnknownProtos
);
261 trace( " out: bytes %u upkts %u nupkts %u disc %u err %u\n",
262 row
->dwOutOctets
, row
->dwOutUcastPkts
, row
->dwOutNUcastPkts
,
263 row
->dwOutDiscards
, row
->dwOutErrors
);
266 HeapFree(GetProcessHeap(), 0, buf
);
271 static void testGetIpForwardTable(void)
273 if (pGetIpForwardTable
) {
277 apiReturn
= pGetIpForwardTable(NULL
, NULL
, FALSE
);
278 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
279 skip("GetIpForwardTable is not supported\n");
282 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
283 "GetIpForwardTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
285 apiReturn
= pGetIpForwardTable(NULL
, &dwSize
, FALSE
);
286 ok(apiReturn
== ERROR_INSUFFICIENT_BUFFER
,
287 "GetIpForwardTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
289 if (apiReturn
== ERROR_INSUFFICIENT_BUFFER
) {
290 PMIB_IPFORWARDTABLE buf
= HeapAlloc(GetProcessHeap(), 0, dwSize
);
292 apiReturn
= pGetIpForwardTable(buf
, &dwSize
, FALSE
);
293 ok(apiReturn
== NO_ERROR
,
294 "GetIpForwardTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
297 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
301 trace( "IP forward table: %u entries\n", buf
->dwNumEntries
);
302 for (i
= 0; i
< buf
->dwNumEntries
; i
++)
305 sprintf( buffer
, "dest %s", ntoa( buf
->table
[i
].dwForwardDest
));
306 sprintf( buffer
+ strlen(buffer
), " mask %s", ntoa( buf
->table
[i
].dwForwardMask
));
307 trace( "%u: %s gw %s if %u type %u\n", i
, buffer
,
308 ntoa( buf
->table
[i
].dwForwardNextHop
),
309 buf
->table
[i
].dwForwardIfIndex
, U1(buf
->table
[i
]).dwForwardType
);
312 HeapFree(GetProcessHeap(), 0, buf
);
317 static void testGetIpNetTable(void)
319 if (pGetIpNetTable
) {
323 apiReturn
= pGetIpNetTable(NULL
, NULL
, FALSE
);
324 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
325 skip("GetIpNetTable is not supported\n");
328 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
329 "GetIpNetTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
331 apiReturn
= pGetIpNetTable(NULL
, &dwSize
, FALSE
);
332 ok(apiReturn
== ERROR_NO_DATA
|| apiReturn
== ERROR_INSUFFICIENT_BUFFER
,
333 "GetIpNetTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_NO_DATA or ERROR_INSUFFICIENT_BUFFER\n",
335 if (apiReturn
== ERROR_NO_DATA
)
336 ; /* empty ARP table's okay */
337 else if (apiReturn
== ERROR_INSUFFICIENT_BUFFER
) {
338 PMIB_IPNETTABLE buf
= HeapAlloc(GetProcessHeap(), 0, dwSize
);
340 apiReturn
= pGetIpNetTable(buf
, &dwSize
, FALSE
);
341 ok(apiReturn
== NO_ERROR
||
342 apiReturn
== ERROR_NO_DATA
, /* empty ARP table's okay */
343 "GetIpNetTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
346 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
350 trace( "IP net table: %u entries\n", buf
->dwNumEntries
);
351 for (i
= 0; i
< buf
->dwNumEntries
; i
++)
353 trace( "%u: idx %u type %u addr %s phys",
354 i
, buf
->table
[i
].dwIndex
, U(buf
->table
[i
]).dwType
, ntoa( buf
->table
[i
].dwAddr
));
355 for (j
= 0; j
< buf
->table
[i
].dwPhysAddrLen
; j
++)
356 printf( " %02x", buf
->table
[i
].bPhysAddr
[j
] );
360 HeapFree(GetProcessHeap(), 0, buf
);
365 static void testGetIcmpStatistics(void)
367 if (pGetIcmpStatistics
) {
371 /* Crashes on Vista */
373 apiReturn
= pGetIcmpStatistics(NULL
);
374 if (apiReturn
== ERROR_NOT_SUPPORTED
)
376 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
377 "GetIcmpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
381 apiReturn
= pGetIcmpStatistics(&stats
);
382 if (apiReturn
== ERROR_NOT_SUPPORTED
)
384 skip("GetIcmpStatistics is not supported\n");
387 ok(apiReturn
== NO_ERROR
,
388 "GetIcmpStatistics returned %d, expected NO_ERROR\n", apiReturn
);
389 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
391 trace( "ICMP stats: %8s %8s\n", "in", "out" );
392 trace( " dwMsgs: %8u %8u\n", stats
.stats
.icmpInStats
.dwMsgs
, stats
.stats
.icmpOutStats
.dwMsgs
);
393 trace( " dwErrors: %8u %8u\n", stats
.stats
.icmpInStats
.dwErrors
, stats
.stats
.icmpOutStats
.dwErrors
);
394 trace( " dwDestUnreachs: %8u %8u\n", stats
.stats
.icmpInStats
.dwDestUnreachs
, stats
.stats
.icmpOutStats
.dwDestUnreachs
);
395 trace( " dwTimeExcds: %8u %8u\n", stats
.stats
.icmpInStats
.dwTimeExcds
, stats
.stats
.icmpOutStats
.dwTimeExcds
);
396 trace( " dwParmProbs: %8u %8u\n", stats
.stats
.icmpInStats
.dwParmProbs
, stats
.stats
.icmpOutStats
.dwParmProbs
);
397 trace( " dwSrcQuenchs: %8u %8u\n", stats
.stats
.icmpInStats
.dwSrcQuenchs
, stats
.stats
.icmpOutStats
.dwSrcQuenchs
);
398 trace( " dwRedirects: %8u %8u\n", stats
.stats
.icmpInStats
.dwRedirects
, stats
.stats
.icmpOutStats
.dwRedirects
);
399 trace( " dwEchos: %8u %8u\n", stats
.stats
.icmpInStats
.dwEchos
, stats
.stats
.icmpOutStats
.dwEchos
);
400 trace( " dwEchoReps: %8u %8u\n", stats
.stats
.icmpInStats
.dwEchoReps
, stats
.stats
.icmpOutStats
.dwEchoReps
);
401 trace( " dwTimestamps: %8u %8u\n", stats
.stats
.icmpInStats
.dwTimestamps
, stats
.stats
.icmpOutStats
.dwTimestamps
);
402 trace( " dwTimestampReps: %8u %8u\n", stats
.stats
.icmpInStats
.dwTimestampReps
, stats
.stats
.icmpOutStats
.dwTimestampReps
);
403 trace( " dwAddrMasks: %8u %8u\n", stats
.stats
.icmpInStats
.dwAddrMasks
, stats
.stats
.icmpOutStats
.dwAddrMasks
);
404 trace( " dwAddrMaskReps: %8u %8u\n", stats
.stats
.icmpInStats
.dwAddrMaskReps
, stats
.stats
.icmpOutStats
.dwAddrMaskReps
);
409 static void testGetIpStatistics(void)
411 if (pGetIpStatistics
) {
415 apiReturn
= pGetIpStatistics(NULL
);
416 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
417 skip("GetIpStatistics is not supported\n");
420 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
421 "GetIpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
423 apiReturn
= pGetIpStatistics(&stats
);
424 ok(apiReturn
== NO_ERROR
,
425 "GetIpStatistics returned %d, expected NO_ERROR\n", apiReturn
);
426 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
428 trace( "IP stats:\n" );
429 trace( " dwForwarding: %u\n", U(stats
).dwForwarding
);
430 trace( " dwDefaultTTL: %u\n", stats
.dwDefaultTTL
);
431 trace( " dwInReceives: %u\n", stats
.dwInReceives
);
432 trace( " dwInHdrErrors: %u\n", stats
.dwInHdrErrors
);
433 trace( " dwInAddrErrors: %u\n", stats
.dwInAddrErrors
);
434 trace( " dwForwDatagrams: %u\n", stats
.dwForwDatagrams
);
435 trace( " dwInUnknownProtos: %u\n", stats
.dwInUnknownProtos
);
436 trace( " dwInDiscards: %u\n", stats
.dwInDiscards
);
437 trace( " dwInDelivers: %u\n", stats
.dwInDelivers
);
438 trace( " dwOutRequests: %u\n", stats
.dwOutRequests
);
439 trace( " dwRoutingDiscards: %u\n", stats
.dwRoutingDiscards
);
440 trace( " dwOutDiscards: %u\n", stats
.dwOutDiscards
);
441 trace( " dwOutNoRoutes: %u\n", stats
.dwOutNoRoutes
);
442 trace( " dwReasmTimeout: %u\n", stats
.dwReasmTimeout
);
443 trace( " dwReasmReqds: %u\n", stats
.dwReasmReqds
);
444 trace( " dwReasmOks: %u\n", stats
.dwReasmOks
);
445 trace( " dwReasmFails: %u\n", stats
.dwReasmFails
);
446 trace( " dwFragOks: %u\n", stats
.dwFragOks
);
447 trace( " dwFragFails: %u\n", stats
.dwFragFails
);
448 trace( " dwFragCreates: %u\n", stats
.dwFragCreates
);
449 trace( " dwNumIf: %u\n", stats
.dwNumIf
);
450 trace( " dwNumAddr: %u\n", stats
.dwNumAddr
);
451 trace( " dwNumRoutes: %u\n", stats
.dwNumRoutes
);
456 static void testGetTcpStatistics(void)
458 if (pGetTcpStatistics
) {
462 apiReturn
= pGetTcpStatistics(NULL
);
463 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
464 skip("GetTcpStatistics is not supported\n");
467 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
468 "GetTcpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
470 apiReturn
= pGetTcpStatistics(&stats
);
471 ok(apiReturn
== NO_ERROR
,
472 "GetTcpStatistics returned %d, expected NO_ERROR\n", apiReturn
);
473 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
475 trace( "TCP stats:\n" );
476 trace( " dwRtoAlgorithm: %u\n", U(stats
).dwRtoAlgorithm
);
477 trace( " dwRtoMin: %u\n", stats
.dwRtoMin
);
478 trace( " dwRtoMax: %u\n", stats
.dwRtoMax
);
479 trace( " dwMaxConn: %u\n", stats
.dwMaxConn
);
480 trace( " dwActiveOpens: %u\n", stats
.dwActiveOpens
);
481 trace( " dwPassiveOpens: %u\n", stats
.dwPassiveOpens
);
482 trace( " dwAttemptFails: %u\n", stats
.dwAttemptFails
);
483 trace( " dwEstabResets: %u\n", stats
.dwEstabResets
);
484 trace( " dwCurrEstab: %u\n", stats
.dwCurrEstab
);
485 trace( " dwInSegs: %u\n", stats
.dwInSegs
);
486 trace( " dwOutSegs: %u\n", stats
.dwOutSegs
);
487 trace( " dwRetransSegs: %u\n", stats
.dwRetransSegs
);
488 trace( " dwInErrs: %u\n", stats
.dwInErrs
);
489 trace( " dwOutRsts: %u\n", stats
.dwOutRsts
);
490 trace( " dwNumConns: %u\n", stats
.dwNumConns
);
495 static void testGetUdpStatistics(void)
497 if (pGetUdpStatistics
) {
501 apiReturn
= pGetUdpStatistics(NULL
);
502 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
503 skip("GetUdpStatistics is not supported\n");
506 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
507 "GetUdpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
509 apiReturn
= pGetUdpStatistics(&stats
);
510 ok(apiReturn
== NO_ERROR
,
511 "GetUdpStatistics returned %d, expected NO_ERROR\n", apiReturn
);
512 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
514 trace( "UDP stats:\n" );
515 trace( " dwInDatagrams: %u\n", stats
.dwInDatagrams
);
516 trace( " dwNoPorts: %u\n", stats
.dwNoPorts
);
517 trace( " dwInErrors: %u\n", stats
.dwInErrors
);
518 trace( " dwOutDatagrams: %u\n", stats
.dwOutDatagrams
);
519 trace( " dwNumAddrs: %u\n", stats
.dwNumAddrs
);
524 static void testGetIcmpStatisticsEx(void)
529 if (!pGetIcmpStatisticsEx
)
531 skip( "GetIcmpStatisticsEx not available\n" );
535 /* Crashes on Vista */
537 apiReturn
= pGetIcmpStatisticsEx(NULL
, AF_INET
);
538 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
539 "GetIcmpStatisticsEx(NULL, AF_INET) returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn
);
542 apiReturn
= pGetIcmpStatisticsEx(&stats
, AF_INET
);
543 ok(apiReturn
== NO_ERROR
, "GetIcmpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn
);
544 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
547 trace( "ICMP Ex stats: %8s %8s\n", "in", "out" );
548 trace( " dwMsgs: %8u %8u\n", stats
.icmpInStats
.dwMsgs
, stats
.icmpOutStats
.dwMsgs
);
549 trace( " dwErrors: %8u %8u\n", stats
.icmpInStats
.dwErrors
, stats
.icmpOutStats
.dwErrors
);
550 for (i
= 0; i
< 256; i
++)
551 trace( " rgdwTypeCount[%3i]: %8u %8u\n", i
, stats
.icmpInStats
.rgdwTypeCount
[i
], stats
.icmpOutStats
.rgdwTypeCount
[i
] );
554 apiReturn
= pGetIcmpStatisticsEx(&stats
, AF_INET6
);
555 ok(apiReturn
== NO_ERROR
|| broken(apiReturn
== ERROR_NOT_SUPPORTED
),
556 "GetIcmpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn
);
557 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
560 trace( "ICMP Ex stats: %8s %8s\n", "in", "out" );
561 trace( " dwMsgs: %8u %8u\n", stats
.icmpInStats
.dwMsgs
, stats
.icmpOutStats
.dwMsgs
);
562 trace( " dwErrors: %8u %8u\n", stats
.icmpInStats
.dwErrors
, stats
.icmpOutStats
.dwErrors
);
563 for (i
= 0; i
< 256; i
++)
564 trace( " rgdwTypeCount[%3i]: %8u %8u\n", i
, stats
.icmpInStats
.rgdwTypeCount
[i
], stats
.icmpOutStats
.rgdwTypeCount
[i
] );
568 static void testGetIpStatisticsEx(void)
573 if (!pGetIpStatisticsEx
)
575 skip( "GetIpStatisticsEx not available\n" );
579 apiReturn
= pGetIpStatisticsEx(NULL
, AF_INET
);
580 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
581 "GetIpStatisticsEx(NULL, AF_INET) returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn
);
583 apiReturn
= pGetIpStatisticsEx(&stats
, AF_INET
);
584 ok(apiReturn
== NO_ERROR
, "GetIpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn
);
585 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
587 trace( "IP Ex stats:\n" );
588 trace( " dwForwarding: %u\n", U(stats
).dwForwarding
);
589 trace( " dwDefaultTTL: %u\n", stats
.dwDefaultTTL
);
590 trace( " dwInReceives: %u\n", stats
.dwInReceives
);
591 trace( " dwInHdrErrors: %u\n", stats
.dwInHdrErrors
);
592 trace( " dwInAddrErrors: %u\n", stats
.dwInAddrErrors
);
593 trace( " dwForwDatagrams: %u\n", stats
.dwForwDatagrams
);
594 trace( " dwInUnknownProtos: %u\n", stats
.dwInUnknownProtos
);
595 trace( " dwInDiscards: %u\n", stats
.dwInDiscards
);
596 trace( " dwInDelivers: %u\n", stats
.dwInDelivers
);
597 trace( " dwOutRequests: %u\n", stats
.dwOutRequests
);
598 trace( " dwRoutingDiscards: %u\n", stats
.dwRoutingDiscards
);
599 trace( " dwOutDiscards: %u\n", stats
.dwOutDiscards
);
600 trace( " dwOutNoRoutes: %u\n", stats
.dwOutNoRoutes
);
601 trace( " dwReasmTimeout: %u\n", stats
.dwReasmTimeout
);
602 trace( " dwReasmReqds: %u\n", stats
.dwReasmReqds
);
603 trace( " dwReasmOks: %u\n", stats
.dwReasmOks
);
604 trace( " dwReasmFails: %u\n", stats
.dwReasmFails
);
605 trace( " dwFragOks: %u\n", stats
.dwFragOks
);
606 trace( " dwFragFails: %u\n", stats
.dwFragFails
);
607 trace( " dwFragCreates: %u\n", stats
.dwFragCreates
);
608 trace( " dwNumIf: %u\n", stats
.dwNumIf
);
609 trace( " dwNumAddr: %u\n", stats
.dwNumAddr
);
610 trace( " dwNumRoutes: %u\n", stats
.dwNumRoutes
);
613 apiReturn
= pGetIpStatisticsEx(&stats
, AF_INET6
);
614 ok(apiReturn
== NO_ERROR
|| broken(apiReturn
== ERROR_NOT_SUPPORTED
),
615 "GetIpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn
);
616 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
618 trace( "IP Ex stats:\n" );
619 trace( " dwForwarding: %u\n", U(stats
).dwForwarding
);
620 trace( " dwDefaultTTL: %u\n", stats
.dwDefaultTTL
);
621 trace( " dwInReceives: %u\n", stats
.dwInReceives
);
622 trace( " dwInHdrErrors: %u\n", stats
.dwInHdrErrors
);
623 trace( " dwInAddrErrors: %u\n", stats
.dwInAddrErrors
);
624 trace( " dwForwDatagrams: %u\n", stats
.dwForwDatagrams
);
625 trace( " dwInUnknownProtos: %u\n", stats
.dwInUnknownProtos
);
626 trace( " dwInDiscards: %u\n", stats
.dwInDiscards
);
627 trace( " dwInDelivers: %u\n", stats
.dwInDelivers
);
628 trace( " dwOutRequests: %u\n", stats
.dwOutRequests
);
629 trace( " dwRoutingDiscards: %u\n", stats
.dwRoutingDiscards
);
630 trace( " dwOutDiscards: %u\n", stats
.dwOutDiscards
);
631 trace( " dwOutNoRoutes: %u\n", stats
.dwOutNoRoutes
);
632 trace( " dwReasmTimeout: %u\n", stats
.dwReasmTimeout
);
633 trace( " dwReasmReqds: %u\n", stats
.dwReasmReqds
);
634 trace( " dwReasmOks: %u\n", stats
.dwReasmOks
);
635 trace( " dwReasmFails: %u\n", stats
.dwReasmFails
);
636 trace( " dwFragOks: %u\n", stats
.dwFragOks
);
637 trace( " dwFragFails: %u\n", stats
.dwFragFails
);
638 trace( " dwFragCreates: %u\n", stats
.dwFragCreates
);
639 trace( " dwNumIf: %u\n", stats
.dwNumIf
);
640 trace( " dwNumAddr: %u\n", stats
.dwNumAddr
);
641 trace( " dwNumRoutes: %u\n", stats
.dwNumRoutes
);
645 static void testGetTcpStatisticsEx(void)
650 if (!pGetTcpStatisticsEx
)
652 skip( "GetTcpStatisticsEx not available\n" );
656 apiReturn
= pGetTcpStatisticsEx(NULL
, AF_INET
);
657 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
658 "GetTcpStatisticsEx(NULL, AF_INET); returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn
);
660 apiReturn
= pGetTcpStatisticsEx(&stats
, AF_INET
);
661 ok(apiReturn
== NO_ERROR
, "GetTcpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn
);
662 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
664 trace( "TCP stats:\n" );
665 trace( " dwRtoAlgorithm: %u\n", U(stats
).dwRtoAlgorithm
);
666 trace( " dwRtoMin: %u\n", stats
.dwRtoMin
);
667 trace( " dwRtoMax: %u\n", stats
.dwRtoMax
);
668 trace( " dwMaxConn: %u\n", stats
.dwMaxConn
);
669 trace( " dwActiveOpens: %u\n", stats
.dwActiveOpens
);
670 trace( " dwPassiveOpens: %u\n", stats
.dwPassiveOpens
);
671 trace( " dwAttemptFails: %u\n", stats
.dwAttemptFails
);
672 trace( " dwEstabResets: %u\n", stats
.dwEstabResets
);
673 trace( " dwCurrEstab: %u\n", stats
.dwCurrEstab
);
674 trace( " dwInSegs: %u\n", stats
.dwInSegs
);
675 trace( " dwOutSegs: %u\n", stats
.dwOutSegs
);
676 trace( " dwRetransSegs: %u\n", stats
.dwRetransSegs
);
677 trace( " dwInErrs: %u\n", stats
.dwInErrs
);
678 trace( " dwOutRsts: %u\n", stats
.dwOutRsts
);
679 trace( " dwNumConns: %u\n", stats
.dwNumConns
);
682 apiReturn
= pGetTcpStatisticsEx(&stats
, AF_INET6
);
683 ok(apiReturn
== NO_ERROR
|| broken(apiReturn
== ERROR_NOT_SUPPORTED
),
684 "GetTcpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn
);
685 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
687 trace( "TCP stats:\n" );
688 trace( " dwRtoAlgorithm: %u\n", U(stats
).dwRtoAlgorithm
);
689 trace( " dwRtoMin: %u\n", stats
.dwRtoMin
);
690 trace( " dwRtoMax: %u\n", stats
.dwRtoMax
);
691 trace( " dwMaxConn: %u\n", stats
.dwMaxConn
);
692 trace( " dwActiveOpens: %u\n", stats
.dwActiveOpens
);
693 trace( " dwPassiveOpens: %u\n", stats
.dwPassiveOpens
);
694 trace( " dwAttemptFails: %u\n", stats
.dwAttemptFails
);
695 trace( " dwEstabResets: %u\n", stats
.dwEstabResets
);
696 trace( " dwCurrEstab: %u\n", stats
.dwCurrEstab
);
697 trace( " dwInSegs: %u\n", stats
.dwInSegs
);
698 trace( " dwOutSegs: %u\n", stats
.dwOutSegs
);
699 trace( " dwRetransSegs: %u\n", stats
.dwRetransSegs
);
700 trace( " dwInErrs: %u\n", stats
.dwInErrs
);
701 trace( " dwOutRsts: %u\n", stats
.dwOutRsts
);
702 trace( " dwNumConns: %u\n", stats
.dwNumConns
);
706 static void testGetUdpStatisticsEx(void)
711 if (!pGetUdpStatisticsEx
)
713 skip( "GetUdpStatisticsEx not available\n" );
717 apiReturn
= pGetUdpStatisticsEx(NULL
, AF_INET
);
718 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
719 "GetUdpStatisticsEx(NULL, AF_INET); returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn
);
721 apiReturn
= pGetUdpStatisticsEx(&stats
, AF_INET
);
722 ok(apiReturn
== NO_ERROR
, "GetUdpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn
);
723 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
725 trace( "UDP stats:\n" );
726 trace( " dwInDatagrams: %u\n", stats
.dwInDatagrams
);
727 trace( " dwNoPorts: %u\n", stats
.dwNoPorts
);
728 trace( " dwInErrors: %u\n", stats
.dwInErrors
);
729 trace( " dwOutDatagrams: %u\n", stats
.dwOutDatagrams
);
730 trace( " dwNumAddrs: %u\n", stats
.dwNumAddrs
);
733 apiReturn
= pGetUdpStatisticsEx(&stats
, AF_INET6
);
734 ok(apiReturn
== NO_ERROR
|| broken(apiReturn
== ERROR_NOT_SUPPORTED
),
735 "GetUdpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn
);
736 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
738 trace( "UDP stats:\n" );
739 trace( " dwInDatagrams: %u\n", stats
.dwInDatagrams
);
740 trace( " dwNoPorts: %u\n", stats
.dwNoPorts
);
741 trace( " dwInErrors: %u\n", stats
.dwInErrors
);
742 trace( " dwOutDatagrams: %u\n", stats
.dwOutDatagrams
);
743 trace( " dwNumAddrs: %u\n", stats
.dwNumAddrs
);
747 static void testGetTcpTable(void)
753 apiReturn
= pGetTcpTable(NULL
, &dwSize
, FALSE
);
754 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
755 skip("GetTcpTable is not supported\n");
758 ok(apiReturn
== ERROR_INSUFFICIENT_BUFFER
||
759 broken(apiReturn
== ERROR_NO_DATA
), /* win95 */
760 "GetTcpTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
762 if (apiReturn
== ERROR_INSUFFICIENT_BUFFER
) {
763 PMIB_TCPTABLE buf
= HeapAlloc(GetProcessHeap(), 0, dwSize
);
765 apiReturn
= pGetTcpTable(buf
, &dwSize
, FALSE
);
766 ok(apiReturn
== NO_ERROR
,
767 "GetTcpTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
770 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
773 trace( "TCP table: %u entries\n", buf
->dwNumEntries
);
774 for (i
= 0; i
< buf
->dwNumEntries
; i
++)
777 sprintf( buffer
, "local %s:%u",
778 ntoa(buf
->table
[i
].dwLocalAddr
), ntohs(buf
->table
[i
].dwLocalPort
) );
779 trace( "%u: %s remote %s:%u state %u\n",
780 i
, buffer
, ntoa( buf
->table
[i
].dwRemoteAddr
),
781 ntohs(buf
->table
[i
].dwRemotePort
), U(buf
->table
[i
]).dwState
);
784 HeapFree(GetProcessHeap(), 0, buf
);
789 static void testGetUdpTable(void)
795 apiReturn
= pGetUdpTable(NULL
, &dwSize
, FALSE
);
796 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
797 skip("GetUdpTable is not supported\n");
800 ok(apiReturn
== ERROR_INSUFFICIENT_BUFFER
,
801 "GetUdpTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
803 if (apiReturn
== ERROR_INSUFFICIENT_BUFFER
) {
804 PMIB_UDPTABLE buf
= HeapAlloc(GetProcessHeap(), 0, dwSize
);
806 apiReturn
= pGetUdpTable(buf
, &dwSize
, FALSE
);
807 ok(apiReturn
== NO_ERROR
,
808 "GetUdpTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
811 if (apiReturn
== NO_ERROR
&& winetest_debug
> 1)
814 trace( "UDP table: %u entries\n", buf
->dwNumEntries
);
815 for (i
= 0; i
< buf
->dwNumEntries
; i
++)
816 trace( "%u: %s:%u\n",
817 i
, ntoa( buf
->table
[i
].dwLocalAddr
), ntohs(buf
->table
[i
].dwLocalPort
) );
819 HeapFree(GetProcessHeap(), 0, buf
);
824 static void testSetTcpEntry(void)
829 memset(&row
, 0, sizeof(row
));
830 if(0) /* This test crashes in OS >= VISTA */
832 ret
= pSetTcpEntry(NULL
);
833 ok( ret
== ERROR_INVALID_PARAMETER
, "got %u, expected %u\n", ret
, ERROR_INVALID_PARAMETER
);
836 ret
= pSetTcpEntry(&row
);
837 todo_wine
ok( ret
== ERROR_INVALID_PARAMETER
, "got %u, expected %u\n", ret
, ERROR_INVALID_PARAMETER
);
839 U(row
).dwState
= MIB_TCP_STATE_DELETE_TCB
;
840 ret
= pSetTcpEntry(&row
);
841 todo_wine
ok( ret
== ERROR_MR_MID_NOT_FOUND
|| broken(ret
== ERROR_INVALID_PARAMETER
),
842 "got %u, expected %u\n", ret
, ERROR_MR_MID_NOT_FOUND
);
846 still-to-be-tested NT4-onward functions:
859 static void testWinNT4Functions(void)
861 testGetNumberOfInterfaces();
862 testGetIpAddrTable();
864 testGetIpForwardTable();
866 testGetIcmpStatistics();
867 testGetIpStatistics();
868 testGetTcpStatistics();
869 testGetUdpStatistics();
870 testGetIcmpStatisticsEx();
871 testGetIpStatisticsEx();
872 testGetTcpStatisticsEx();
873 testGetUdpStatisticsEx();
879 static void testGetInterfaceInfo(void)
881 if (pGetInterfaceInfo
) {
885 apiReturn
= pGetInterfaceInfo(NULL
, NULL
);
886 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
887 skip("GetInterfaceInfo is not supported\n");
890 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
891 "GetInterfaceInfo returned %d, expected ERROR_INVALID_PARAMETER\n",
893 apiReturn
= pGetInterfaceInfo(NULL
, &len
);
894 ok(apiReturn
== ERROR_INSUFFICIENT_BUFFER
,
895 "GetInterfaceInfo returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
897 if (apiReturn
== ERROR_INSUFFICIENT_BUFFER
) {
898 PIP_INTERFACE_INFO buf
= HeapAlloc(GetProcessHeap(), 0, len
);
900 apiReturn
= pGetInterfaceInfo(buf
, &len
);
901 ok(apiReturn
== NO_ERROR
,
902 "GetInterfaceInfo(buf, &dwSize) returned %d, expected NO_ERROR\n",
904 HeapFree(GetProcessHeap(), 0, buf
);
909 static void testGetAdaptersInfo(void)
911 if (pGetAdaptersInfo
) {
915 apiReturn
= pGetAdaptersInfo(NULL
, NULL
);
916 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
917 skip("GetAdaptersInfo is not supported\n");
920 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
921 "GetAdaptersInfo returned %d, expected ERROR_INVALID_PARAMETER\n",
923 apiReturn
= pGetAdaptersInfo(NULL
, &len
);
924 ok(apiReturn
== ERROR_NO_DATA
|| apiReturn
== ERROR_BUFFER_OVERFLOW
,
925 "GetAdaptersInfo returned %d, expected ERROR_NO_DATA or ERROR_BUFFER_OVERFLOW\n",
927 if (apiReturn
== ERROR_NO_DATA
)
928 ; /* no adapter's, that's okay */
929 else if (apiReturn
== ERROR_BUFFER_OVERFLOW
) {
930 PIP_ADAPTER_INFO buf
= HeapAlloc(GetProcessHeap(), 0, len
);
932 apiReturn
= pGetAdaptersInfo(buf
, &len
);
933 ok(apiReturn
== NO_ERROR
,
934 "GetAdaptersInfo(buf, &dwSize) returned %d, expected NO_ERROR\n",
936 HeapFree(GetProcessHeap(), 0, buf
);
941 static void testGetNetworkParams(void)
943 if (pGetNetworkParams
) {
947 apiReturn
= pGetNetworkParams(NULL
, NULL
);
948 if (apiReturn
== ERROR_NOT_SUPPORTED
) {
949 skip("GetNetworkParams is not supported\n");
952 ok(apiReturn
== ERROR_INVALID_PARAMETER
,
953 "GetNetworkParams returned %d, expected ERROR_INVALID_PARAMETER\n",
955 apiReturn
= pGetNetworkParams(NULL
, &len
);
956 ok(apiReturn
== ERROR_BUFFER_OVERFLOW
,
957 "GetNetworkParams returned %d, expected ERROR_BUFFER_OVERFLOW\n",
959 if (apiReturn
== ERROR_BUFFER_OVERFLOW
) {
960 PFIXED_INFO buf
= HeapAlloc(GetProcessHeap(), 0, len
);
962 apiReturn
= pGetNetworkParams(buf
, &len
);
963 ok(apiReturn
== NO_ERROR
,
964 "GetNetworkParams(buf, &dwSize) returned %d, expected NO_ERROR\n",
966 HeapFree(GetProcessHeap(), 0, buf
);
972 still-to-be-tested 98-onward functions:
978 static DWORD CALLBACK
testWin98Functions(void *p
)
980 testGetInterfaceInfo();
981 testGetAdaptersInfo();
982 testGetNetworkParams();
986 static void testGetPerAdapterInfo(void)
991 if (!pGetPerAdapterInfo
) return;
992 ret
= pGetPerAdapterInfo(1, NULL
, NULL
);
993 if (ret
== ERROR_NOT_SUPPORTED
) {
994 skip("GetPerAdapterInfo is not supported\n");
997 ok( ret
== ERROR_INVALID_PARAMETER
, "got %u instead of ERROR_INVALID_PARAMETER\n", ret
);
999 ret
= pGetPerAdapterInfo(1, NULL
, &needed
);
1000 if (ret
== ERROR_NO_DATA
) return; /* no such adapter */
1001 ok( ret
== ERROR_BUFFER_OVERFLOW
, "got %u instead of ERROR_BUFFER_OVERFLOW\n", ret
);
1002 ok( needed
!= 0xdeadbeef, "needed not set\n" );
1003 buffer
= HeapAlloc( GetProcessHeap(), 0, needed
);
1004 ret
= pGetPerAdapterInfo(1, buffer
, &needed
);
1005 ok( ret
== NO_ERROR
, "got %u instead of NO_ERROR\n", ret
);
1006 HeapFree( GetProcessHeap(), 0, buffer
);
1009 static void testNotifyAddrChange(void)
1012 OVERLAPPED overlapped
;
1016 if (!pNotifyAddrChange
)
1018 win_skip("NotifyAddrChange not present\n");
1021 if (!pCancelIPChangeNotify
)
1023 win_skip("CancelIPChangeNotify not present\n");
1028 ZeroMemory(&overlapped
, sizeof(overlapped
));
1029 ret
= pNotifyAddrChange(&handle
, &overlapped
);
1030 if (ret
== ERROR_NOT_SUPPORTED
)
1032 win_skip("NotifyAddrChange is not supported\n");
1035 ok(ret
== ERROR_IO_PENDING
, "NotifyAddrChange returned %d, expected ERROR_IO_PENDING\n", ret
);
1036 ret
= GetLastError();
1037 todo_wine
ok(ret
== ERROR_IO_PENDING
, "GetLastError returned %d, expected ERROR_IO_PENDING\n", ret
);
1038 success
= pCancelIPChangeNotify(&overlapped
);
1039 todo_wine
ok(success
== TRUE
, "CancelIPChangeNotify returned FALSE, expected TRUE\n");
1041 ZeroMemory(&overlapped
, sizeof(overlapped
));
1042 success
= pCancelIPChangeNotify(&overlapped
);
1043 ok(success
== FALSE
, "CancelIPChangeNotify returned TRUE, expected FALSE\n");
1046 ZeroMemory(&overlapped
, sizeof(overlapped
));
1047 overlapped
.hEvent
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
1048 ret
= pNotifyAddrChange(&handle
, &overlapped
);
1049 ok(ret
== ERROR_IO_PENDING
, "NotifyAddrChange returned %d, expected ERROR_IO_PENDING\n", ret
);
1050 todo_wine
ok(handle
!= INVALID_HANDLE_VALUE
, "NotifyAddrChange returned invalid file handle\n");
1051 success
= GetOverlappedResult(handle
, &overlapped
, &bytes
, FALSE
);
1052 ok(success
== FALSE
, "GetOverlappedResult returned TRUE, expected FALSE\n");
1053 ret
= GetLastError();
1054 ok(ret
== ERROR_IO_INCOMPLETE
, "GetLastError returned %d, expected ERROR_IO_INCOMPLETE\n", ret
);
1055 success
= pCancelIPChangeNotify(&overlapped
);
1056 todo_wine
ok(success
== TRUE
, "CancelIPChangeNotify returned FALSE, expected TRUE\n");
1058 if (winetest_interactive
)
1061 ZeroMemory(&overlapped
, sizeof(overlapped
));
1062 overlapped
.hEvent
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
1063 trace("Testing asynchronous ipv4 address change notification. Please "
1064 "change the ipv4 address of one of your network interfaces\n");
1065 ret
= pNotifyAddrChange(&handle
, &overlapped
);
1066 ok(ret
== ERROR_IO_PENDING
, "NotifyAddrChange returned %d, expected NO_ERROR\n", ret
);
1067 success
= GetOverlappedResult(handle
, &overlapped
, &bytes
, TRUE
);
1068 ok(success
== TRUE
, "GetOverlappedResult returned FALSE, expected TRUE\n");
1071 /* test synchronous functionality */
1072 if (winetest_interactive
)
1074 trace("Testing synchronous ipv4 address change notification. Please "
1075 "change the ipv4 address of one of your network interfaces\n");
1076 ret
= pNotifyAddrChange(NULL
, NULL
);
1077 todo_wine
ok(ret
== NO_ERROR
, "NotifyAddrChange returned %d, expected NO_ERROR\n", ret
);
1082 still-to-be-tested 2K-onward functions:
1090 NotifyRouteChange + CancelIPChangeNotify
1094 static void testWin2KFunctions(void)
1096 testGetPerAdapterInfo();
1097 testNotifyAddrChange();
1100 static void test_GetAdaptersAddresses(void)
1103 IP_ADAPTER_ADDRESSES
*aa
, *ptr
;
1104 IP_ADAPTER_UNICAST_ADDRESS
*ua
;
1106 if (!pGetAdaptersAddresses
)
1108 win_skip("GetAdaptersAddresses not present\n");
1112 ret
= pGetAdaptersAddresses(AF_UNSPEC
, 0, NULL
, NULL
, NULL
);
1113 ok(ret
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER got %u\n", ret
);
1115 /* size should be ignored and overwritten if buffer is NULL */
1117 ret
= pGetAdaptersAddresses(AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1118 ok(ret
== ERROR_BUFFER_OVERFLOW
, "expected ERROR_BUFFER_OVERFLOW, got %u\n", ret
);
1119 if (ret
!= ERROR_BUFFER_OVERFLOW
) return;
1121 ptr
= HeapAlloc(GetProcessHeap(), 0, size
);
1122 ret
= pGetAdaptersAddresses(AF_UNSPEC
, 0, NULL
, ptr
, &size
);
1123 ok(!ret
, "expected ERROR_SUCCESS got %u\n", ret
);
1125 for (aa
= ptr
; !ret
&& aa
; aa
= aa
->Next
)
1127 ok(aa
->DnsSuffix
!= NULL
, "DnsSuffix is not a valid pointer\n");
1128 ok(aa
->Description
!= NULL
, "Description is not a valid pointer\n");
1129 ok(aa
->FriendlyName
!= NULL
, "FriendlyName is not a valid pointer\n");
1131 if (winetest_debug
<= 1)
1134 trace("Length: %u\n", S(U(*aa
)).Length
);
1135 trace("IfIndex: %u\n", S(U(*aa
)).IfIndex
);
1136 trace("Next: %p\n", aa
->Next
);
1137 trace("AdapterName: %s\n", aa
->AdapterName
);
1138 trace("FirstUnicastAddress: %p\n", aa
->FirstUnicastAddress
);
1139 ua
= aa
->FirstUnicastAddress
;
1142 trace("\tLength: %u\n", S(U(*ua
)).Length
);
1143 trace("\tFlags: 0x%08x\n", S(U(*ua
)).Flags
);
1144 trace("\tNext: %p\n", ua
->Next
);
1145 trace("\tAddress.lpSockaddr: %p\n", ua
->Address
.lpSockaddr
);
1146 trace("\tAddress.iSockaddrLength: %d\n", ua
->Address
.iSockaddrLength
);
1147 trace("\tPrefixOrigin: %u\n", ua
->PrefixOrigin
);
1148 trace("\tSuffixOrigin: %u\n", ua
->SuffixOrigin
);
1149 trace("\tDadState: %u\n", ua
->DadState
);
1150 trace("\tValidLifetime: 0x%08x\n", ua
->ValidLifetime
);
1151 trace("\tPreferredLifetime: 0x%08x\n", ua
->PreferredLifetime
);
1152 trace("\tLeaseLifetime: 0x%08x\n", ua
->LeaseLifetime
);
1156 trace("FirstAnycastAddress: %p\n", aa
->FirstAnycastAddress
);
1157 trace("FirstMulticastAddress: %p\n", aa
->FirstMulticastAddress
);
1158 trace("FirstDnsServerAddress: %p\n", aa
->FirstDnsServerAddress
);
1159 trace("DnsSuffix: %p\n", aa
->DnsSuffix
);
1160 trace("Description: %p\n", aa
->Description
);
1161 trace("FriendlyName: %p\n", aa
->FriendlyName
);
1162 trace("PhysicalAddress: %02x\n", aa
->PhysicalAddress
[0]);
1163 trace("PhysicalAddressLength: %u\n", aa
->PhysicalAddressLength
);
1164 trace("Flags: 0x%08x\n", aa
->Flags
);
1165 trace("Mtu: %u\n", aa
->Mtu
);
1166 trace("IfType: %u\n", aa
->IfType
);
1167 trace("OperStatus: %u\n", aa
->OperStatus
);
1170 HeapFree(GetProcessHeap(), 0, ptr
);
1173 static void test_GetExtendedTcpTable(void)
1176 MIB_TCPTABLE
*table
;
1177 MIB_TCPTABLE_OWNER_PID
*table_pid
;
1179 if (!pGetExtendedTcpTable
)
1181 win_skip("GetExtendedTcpTable not available\n");
1184 ret
= pGetExtendedTcpTable( NULL
, NULL
, TRUE
, AF_INET
, TCP_TABLE_BASIC_ALL
, 0 );
1185 ok( ret
== ERROR_INVALID_PARAMETER
, "got %u\n", ret
);
1188 ret
= pGetExtendedTcpTable( NULL
, &size
, TRUE
, AF_INET
, TCP_TABLE_BASIC_ALL
, 0 );
1189 ok( ret
== ERROR_INSUFFICIENT_BUFFER
, "got %u\n", ret
);
1191 table
= HeapAlloc( GetProcessHeap(), 0, size
);
1192 ret
= pGetExtendedTcpTable( table
, &size
, TRUE
, AF_INET
, TCP_TABLE_BASIC_ALL
, 0 );
1193 ok( ret
== ERROR_SUCCESS
, "got %u\n", ret
);
1194 HeapFree( GetProcessHeap(), 0, table
);
1197 ret
= pGetExtendedTcpTable( NULL
, &size
, TRUE
, AF_INET
, TCP_TABLE_OWNER_PID_ALL
, 0 );
1198 ok( ret
== ERROR_INSUFFICIENT_BUFFER
, "got %u\n", ret
);
1200 table_pid
= HeapAlloc( GetProcessHeap(), 0, size
);
1201 ret
= pGetExtendedTcpTable( table_pid
, &size
, TRUE
, AF_INET
, TCP_TABLE_OWNER_PID_ALL
, 0 );
1202 ok( ret
== ERROR_SUCCESS
, "got %u\n", ret
);
1203 HeapFree( GetProcessHeap(), 0, table_pid
);
1206 START_TEST(iphlpapi
)
1213 testWin98OnlyFunctions();
1214 testWinNT4Functions();
1216 /* run testGetXXXX in two threads at once to make sure we don't crash in that case */
1217 thread
= CreateThread(NULL
, 0, testWin98Functions
, NULL
, 0, NULL
);
1218 testWin98Functions(NULL
);
1219 WaitForSingleObject(thread
, INFINITE
);
1221 testWin2KFunctions();
1222 test_GetAdaptersAddresses();
1223 test_GetExtendedTcpTable();