iphlpapi/tests: Fix compilation on systems that don't support nameless unions.
[wine] / dlls / iphlpapi / tests / iphlpapi.c
1 /*
2  * iphlpapi dll test
3  *
4  * Copyright (C) 2003 Juan Lang
5  *
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.
10  *
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.
15  *
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
19  */
20
21 /*
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).
28  *
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.
33  *
34  * The DomainName field of FIXED_INFO isn't NULL-terminated on Win98.
35  */
36
37 #include <stdarg.h>
38 #include "winsock2.h"
39 #include "windef.h"
40 #include "winbase.h"
41 #include "iphlpapi.h"
42 #include "iprtrmib.h"
43 #include "wine/test.h"
44 #include <stdio.h>
45 #include <stdlib.h>
46
47 static HMODULE hLibrary = NULL;
48
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 *pGetTcpTable)(PMIB_TCPTABLE,PDWORD,BOOL);
64 static DWORD (WINAPI *pGetUdpTable)(PMIB_UDPTABLE,PDWORD,BOOL);
65 static DWORD (WINAPI *pGetPerAdapterInfo)(ULONG,PIP_PER_ADAPTER_INFO,PULONG);
66 static DWORD (WINAPI *pGetAdaptersAddresses)(ULONG,ULONG,PVOID,PIP_ADAPTER_ADDRESSES,PULONG);
67 static DWORD (WINAPI *pNotifyAddrChange)(PHANDLE,LPOVERLAPPED);
68 static BOOL  (WINAPI *pCancelIPChangeNotify)(LPOVERLAPPED);
69 static DWORD (WINAPI *pGetExtendedTcpTable)(PVOID,PDWORD,BOOL,ULONG,TCP_TABLE_CLASS,ULONG);
70 static DWORD (WINAPI *pSetTcpEntry)(PMIB_TCPROW);
71
72 static void loadIPHlpApi(void)
73 {
74   hLibrary = LoadLibraryA("iphlpapi.dll");
75   if (hLibrary) {
76     pGetNumberOfInterfaces = (void *)GetProcAddress(hLibrary, "GetNumberOfInterfaces");
77     pGetIpAddrTable = (void *)GetProcAddress(hLibrary, "GetIpAddrTable");
78     pGetIfEntry = (void *)GetProcAddress(hLibrary, "GetIfEntry");
79     pGetFriendlyIfIndex = (void *)GetProcAddress(hLibrary, "GetFriendlyIfIndex");
80     pGetIfTable = (void *)GetProcAddress(hLibrary, "GetIfTable");
81     pGetIpForwardTable = (void *)GetProcAddress(hLibrary, "GetIpForwardTable");
82     pGetIpNetTable = (void *)GetProcAddress(hLibrary, "GetIpNetTable");
83     pGetInterfaceInfo = (void *)GetProcAddress(hLibrary, "GetInterfaceInfo");
84     pGetAdaptersInfo = (void *)GetProcAddress(hLibrary, "GetAdaptersInfo");
85     pGetNetworkParams = (void *)GetProcAddress(hLibrary, "GetNetworkParams");
86     pGetIcmpStatistics = (void *)GetProcAddress(hLibrary, "GetIcmpStatistics");
87     pGetIpStatistics = (void *)GetProcAddress(hLibrary, "GetIpStatistics");
88     pGetTcpStatistics = (void *)GetProcAddress(hLibrary, "GetTcpStatistics");
89     pGetUdpStatistics = (void *)GetProcAddress(hLibrary, "GetUdpStatistics");
90     pGetTcpTable = (void *)GetProcAddress(hLibrary, "GetTcpTable");
91     pGetUdpTable = (void *)GetProcAddress(hLibrary, "GetUdpTable");
92     pGetPerAdapterInfo = (void *)GetProcAddress(hLibrary, "GetPerAdapterInfo");
93     pGetAdaptersAddresses = (void *)GetProcAddress(hLibrary, "GetAdaptersAddresses");
94     pNotifyAddrChange = (void *)GetProcAddress(hLibrary, "NotifyAddrChange");
95     pCancelIPChangeNotify = (void *)GetProcAddress(hLibrary, "CancelIPChangeNotify");
96     pGetExtendedTcpTable = (void *)GetProcAddress(hLibrary, "GetExtendedTcpTable");
97     pSetTcpEntry = (void *)GetProcAddress(hLibrary, "SetTcpEntry");
98   }
99 }
100
101 static void freeIPHlpApi(void)
102 {
103     FreeLibrary(hLibrary);
104 }
105
106 /* replacement for inet_ntoa */
107 static const char *ntoa( DWORD ip )
108 {
109     static char buffer[40];
110
111     ip = htonl(ip);
112     sprintf( buffer, "%u.%u.%u.%u", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff );
113     return buffer;
114 }
115
116 /*
117 still-to-be-tested 98-only functions:
118 GetUniDirectionalAdapterInfo
119 */
120 static void testWin98OnlyFunctions(void)
121 {
122 }
123
124 static void testGetNumberOfInterfaces(void)
125 {
126   if (pGetNumberOfInterfaces) {
127     DWORD apiReturn, numInterfaces;
128
129     /* Crashes on Vista */
130     if (0) {
131       apiReturn = pGetNumberOfInterfaces(NULL);
132       if (apiReturn == ERROR_NOT_SUPPORTED)
133         return;
134       ok(apiReturn == ERROR_INVALID_PARAMETER,
135        "GetNumberOfInterfaces(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
136        apiReturn);
137     }
138
139     apiReturn = pGetNumberOfInterfaces(&numInterfaces);
140     if (apiReturn == ERROR_NOT_SUPPORTED) {
141       skip("GetNumberOfInterfaces is not supported\n");
142       return;
143     }
144     ok(apiReturn == NO_ERROR,
145      "GetNumberOfInterfaces returned %d, expected 0\n", apiReturn);
146   }
147 }
148
149 static void testGetIfEntry(DWORD index)
150 {
151   if (pGetIfEntry) {
152     DWORD apiReturn;
153     MIB_IFROW row;
154
155     memset(&row, 0, sizeof(row));
156     apiReturn = pGetIfEntry(NULL);
157     if (apiReturn == ERROR_NOT_SUPPORTED) {
158       skip("GetIfEntry is not supported\n");
159       return;
160     }
161     ok(apiReturn == ERROR_INVALID_PARAMETER,
162      "GetIfEntry(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
163      apiReturn);
164     row.dwIndex = -1; /* hope that's always bogus! */
165     apiReturn = pGetIfEntry(&row);
166     ok(apiReturn == ERROR_INVALID_DATA ||
167      apiReturn == ERROR_FILE_NOT_FOUND /* Vista */,
168      "GetIfEntry(bogus row) returned %d, expected ERROR_INVALID_DATA or ERROR_FILE_NOT_FOUND\n",
169      apiReturn);
170     row.dwIndex = index;
171     apiReturn = pGetIfEntry(&row);
172     ok(apiReturn == NO_ERROR, 
173      "GetIfEntry returned %d, expected NO_ERROR\n", apiReturn);
174   }
175 }
176
177 static void testGetIpAddrTable(void)
178 {
179   if (pGetIpAddrTable) {
180     DWORD apiReturn;
181     ULONG dwSize = 0;
182
183     apiReturn = pGetIpAddrTable(NULL, NULL, FALSE);
184     if (apiReturn == ERROR_NOT_SUPPORTED) {
185       skip("GetIpAddrTable is not supported\n");
186       return;
187     }
188     ok(apiReturn == ERROR_INVALID_PARAMETER,
189      "GetIpAddrTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
190      apiReturn);
191     apiReturn = pGetIpAddrTable(NULL, &dwSize, FALSE);
192     ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
193      "GetIpAddrTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
194      apiReturn);
195     if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
196       PMIB_IPADDRTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
197
198       apiReturn = pGetIpAddrTable(buf, &dwSize, FALSE);
199       ok(apiReturn == NO_ERROR,
200        "GetIpAddrTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
201        apiReturn);
202       if (apiReturn == NO_ERROR && buf->dwNumEntries)
203         testGetIfEntry(buf->table[0].dwIndex);
204       HeapFree(GetProcessHeap(), 0, buf);
205     }
206   }
207 }
208
209 static void testGetIfTable(void)
210 {
211   if (pGetIfTable) {
212     DWORD apiReturn;
213     ULONG dwSize = 0;
214
215     apiReturn = pGetIfTable(NULL, NULL, FALSE);
216     if (apiReturn == ERROR_NOT_SUPPORTED) {
217       skip("GetIfTable is not supported\n");
218       return;
219     }
220     ok(apiReturn == ERROR_INVALID_PARAMETER,
221      "GetIfTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
222      apiReturn);
223     apiReturn = pGetIfTable(NULL, &dwSize, FALSE);
224     ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
225      "GetIfTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
226      apiReturn);
227     if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
228       PMIB_IFTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
229
230       apiReturn = pGetIfTable(buf, &dwSize, FALSE);
231       ok(apiReturn == NO_ERROR,
232        "GetIfTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n\n",
233        apiReturn);
234
235       if (apiReturn == NO_ERROR && winetest_debug > 1)
236       {
237           DWORD i, j;
238           char name[MAX_INTERFACE_NAME_LEN];
239
240           trace( "interface table: %u entries\n", buf->dwNumEntries );
241           for (i = 0; i < buf->dwNumEntries; i++)
242           {
243               MIB_IFROW *row = &buf->table[i];
244               WideCharToMultiByte( CP_ACP, 0, row->wszName, -1, name, MAX_INTERFACE_NAME_LEN, NULL, NULL );
245               trace( "%u: '%s' type %u mtu %u speed %u phys",
246                      row->dwIndex, name, row->dwType, row->dwMtu, row->dwSpeed );
247               for (j = 0; j < row->dwPhysAddrLen; j++)
248                   printf( " %02x", row->bPhysAddr[j] );
249               printf( "\n" );
250               trace( "        in: bytes %u upkts %u nupkts %u disc %u err %u unk %u\n",
251                      row->dwInOctets, row->dwInUcastPkts, row->dwInNUcastPkts,
252                      row->dwInDiscards, row->dwInErrors, row->dwInUnknownProtos );
253               trace( "        out: bytes %u upkts %u nupkts %u disc %u err %u\n",
254                      row->dwOutOctets, row->dwOutUcastPkts, row->dwOutNUcastPkts,
255                      row->dwOutDiscards, row->dwOutErrors );
256           }
257       }
258       HeapFree(GetProcessHeap(), 0, buf);
259     }
260   }
261 }
262
263 static void testGetIpForwardTable(void)
264 {
265   if (pGetIpForwardTable) {
266     DWORD apiReturn;
267     ULONG dwSize = 0;
268
269     apiReturn = pGetIpForwardTable(NULL, NULL, FALSE);
270     if (apiReturn == ERROR_NOT_SUPPORTED) {
271       skip("GetIpForwardTable is not supported\n");
272       return;
273     }
274     ok(apiReturn == ERROR_INVALID_PARAMETER,
275      "GetIpForwardTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
276      apiReturn);
277     apiReturn = pGetIpForwardTable(NULL, &dwSize, FALSE);
278     ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
279      "GetIpForwardTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
280      apiReturn);
281     if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
282       PMIB_IPFORWARDTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
283
284       apiReturn = pGetIpForwardTable(buf, &dwSize, FALSE);
285       ok(apiReturn == NO_ERROR,
286        "GetIpForwardTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
287        apiReturn);
288
289       if (apiReturn == NO_ERROR && winetest_debug > 1)
290       {
291           DWORD i;
292
293           trace( "IP forward table: %u entries\n", buf->dwNumEntries );
294           for (i = 0; i < buf->dwNumEntries; i++)
295           {
296               char buffer[40];
297               sprintf( buffer, "dest %s", ntoa( buf->table[i].dwForwardDest ));
298               sprintf( buffer + strlen(buffer), " mask %s", ntoa( buf->table[i].dwForwardMask ));
299               trace( "%u: %s gw %s if %u type %u\n", i, buffer,
300                      ntoa( buf->table[i].dwForwardNextHop ),
301                      buf->table[i].dwForwardIfIndex, U1(buf->table[i]).dwForwardType );
302           }
303       }
304       HeapFree(GetProcessHeap(), 0, buf);
305     }
306   }
307 }
308
309 static void testGetIpNetTable(void)
310 {
311   if (pGetIpNetTable) {
312     DWORD apiReturn;
313     ULONG dwSize = 0;
314
315     apiReturn = pGetIpNetTable(NULL, NULL, FALSE);
316     if (apiReturn == ERROR_NOT_SUPPORTED) {
317       skip("GetIpNetTable is not supported\n");
318       return;
319     }
320     ok(apiReturn == ERROR_INVALID_PARAMETER,
321      "GetIpNetTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
322      apiReturn);
323     apiReturn = pGetIpNetTable(NULL, &dwSize, FALSE);
324     ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_INSUFFICIENT_BUFFER,
325      "GetIpNetTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_NO_DATA or ERROR_INSUFFICIENT_BUFFER\n",
326      apiReturn);
327     if (apiReturn == ERROR_NO_DATA)
328       ; /* empty ARP table's okay */
329     else if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
330       PMIB_IPNETTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
331
332       apiReturn = pGetIpNetTable(buf, &dwSize, FALSE);
333       ok(apiReturn == NO_ERROR ||
334          apiReturn == ERROR_NO_DATA, /* empty ARP table's okay */
335        "GetIpNetTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
336        apiReturn);
337
338       if (apiReturn == NO_ERROR && winetest_debug > 1)
339       {
340           DWORD i, j;
341
342           trace( "IP net table: %u entries\n", buf->dwNumEntries );
343           for (i = 0; i < buf->dwNumEntries; i++)
344           {
345               trace( "%u: idx %u type %u addr %s phys",
346                      i, buf->table[i].dwIndex, U(buf->table[i]).dwType, ntoa( buf->table[i].dwAddr ));
347               for (j = 0; j < buf->table[i].dwPhysAddrLen; j++)
348                   printf( " %02x", buf->table[i].bPhysAddr[j] );
349               printf( "\n" );
350           }
351       }
352       HeapFree(GetProcessHeap(), 0, buf);
353     }
354   }
355 }
356
357 static void testGetIcmpStatistics(void)
358 {
359   if (pGetIcmpStatistics) {
360     DWORD apiReturn;
361     MIB_ICMP stats;
362
363     /* Crashes on Vista */
364     if (0) {
365       apiReturn = pGetIcmpStatistics(NULL);
366       if (apiReturn == ERROR_NOT_SUPPORTED)
367         return;
368       ok(apiReturn == ERROR_INVALID_PARAMETER,
369        "GetIcmpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
370        apiReturn);
371     }
372
373     apiReturn = pGetIcmpStatistics(&stats);
374     if (apiReturn == ERROR_NOT_SUPPORTED)
375     {
376       skip("GetIcmpStatistics is not supported\n");
377       return;
378     }
379     ok(apiReturn == NO_ERROR,
380      "GetIcmpStatistics returned %d, expected NO_ERROR\n", apiReturn);
381     if (apiReturn == NO_ERROR && winetest_debug > 1)
382     {
383         trace( "ICMP stats:          %8s %8s\n", "in", "out" );
384         trace( "    dwMsgs:          %8u %8u\n", stats.stats.icmpInStats.dwMsgs, stats.stats.icmpOutStats.dwMsgs );
385         trace( "    dwErrors:        %8u %8u\n", stats.stats.icmpInStats.dwErrors, stats.stats.icmpOutStats.dwErrors );
386         trace( "    dwDestUnreachs:  %8u %8u\n", stats.stats.icmpInStats.dwDestUnreachs, stats.stats.icmpOutStats.dwDestUnreachs );
387         trace( "    dwTimeExcds:     %8u %8u\n", stats.stats.icmpInStats.dwTimeExcds, stats.stats.icmpOutStats.dwTimeExcds );
388         trace( "    dwParmProbs:     %8u %8u\n", stats.stats.icmpInStats.dwParmProbs, stats.stats.icmpOutStats.dwParmProbs );
389         trace( "    dwSrcQuenchs:    %8u %8u\n", stats.stats.icmpInStats.dwSrcQuenchs, stats.stats.icmpOutStats.dwSrcQuenchs );
390         trace( "    dwRedirects:     %8u %8u\n", stats.stats.icmpInStats.dwRedirects, stats.stats.icmpOutStats.dwRedirects );
391         trace( "    dwEchos:         %8u %8u\n", stats.stats.icmpInStats.dwEchos, stats.stats.icmpOutStats.dwEchos );
392         trace( "    dwEchoReps:      %8u %8u\n", stats.stats.icmpInStats.dwEchoReps, stats.stats.icmpOutStats.dwEchoReps );
393         trace( "    dwTimestamps:    %8u %8u\n", stats.stats.icmpInStats.dwTimestamps, stats.stats.icmpOutStats.dwTimestamps );
394         trace( "    dwTimestampReps: %8u %8u\n", stats.stats.icmpInStats.dwTimestampReps, stats.stats.icmpOutStats.dwTimestampReps );
395         trace( "    dwAddrMasks:     %8u %8u\n", stats.stats.icmpInStats.dwAddrMasks, stats.stats.icmpOutStats.dwAddrMasks );
396         trace( "    dwAddrMaskReps:  %8u %8u\n", stats.stats.icmpInStats.dwAddrMaskReps, stats.stats.icmpOutStats.dwAddrMaskReps );
397     }
398   }
399 }
400
401 static void testGetIpStatistics(void)
402 {
403   if (pGetIpStatistics) {
404     DWORD apiReturn;
405     MIB_IPSTATS stats;
406
407     apiReturn = pGetIpStatistics(NULL);
408     if (apiReturn == ERROR_NOT_SUPPORTED) {
409       skip("GetIpStatistics is not supported\n");
410       return;
411     }
412     ok(apiReturn == ERROR_INVALID_PARAMETER,
413      "GetIpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
414      apiReturn);
415     apiReturn = pGetIpStatistics(&stats);
416     ok(apiReturn == NO_ERROR,
417       "GetIpStatistics returned %d, expected NO_ERROR\n", apiReturn);
418     if (apiReturn == NO_ERROR && winetest_debug > 1)
419     {
420         trace( "IP stats:\n" );
421         trace( "    dwForwarding:      %u\n", U(stats).dwForwarding );
422         trace( "    dwDefaultTTL:      %u\n", stats.dwDefaultTTL );
423         trace( "    dwInReceives:      %u\n", stats.dwInReceives );
424         trace( "    dwInHdrErrors:     %u\n", stats.dwInHdrErrors );
425         trace( "    dwInAddrErrors:    %u\n", stats.dwInAddrErrors );
426         trace( "    dwForwDatagrams:   %u\n", stats.dwForwDatagrams );
427         trace( "    dwInUnknownProtos: %u\n", stats.dwInUnknownProtos );
428         trace( "    dwInDiscards:      %u\n", stats.dwInDiscards );
429         trace( "    dwInDelivers:      %u\n", stats.dwInDelivers );
430         trace( "    dwOutRequests:     %u\n", stats.dwOutRequests );
431         trace( "    dwRoutingDiscards: %u\n", stats.dwRoutingDiscards );
432         trace( "    dwOutDiscards:     %u\n", stats.dwOutDiscards );
433         trace( "    dwOutNoRoutes:     %u\n", stats.dwOutNoRoutes );
434         trace( "    dwReasmTimeout:    %u\n", stats.dwReasmTimeout );
435         trace( "    dwReasmReqds:      %u\n", stats.dwReasmReqds );
436         trace( "    dwReasmOks:        %u\n", stats.dwReasmOks );
437         trace( "    dwReasmFails:      %u\n", stats.dwReasmFails );
438         trace( "    dwFragOks:         %u\n", stats.dwFragOks );
439         trace( "    dwFragFails:       %u\n", stats.dwFragFails );
440         trace( "    dwFragCreates:     %u\n", stats.dwFragCreates );
441         trace( "    dwNumIf:           %u\n", stats.dwNumIf );
442         trace( "    dwNumAddr:         %u\n", stats.dwNumAddr );
443         trace( "    dwNumRoutes:       %u\n", stats.dwNumRoutes );
444     }
445   }
446 }
447
448 static void testGetTcpStatistics(void)
449 {
450   if (pGetTcpStatistics) {
451     DWORD apiReturn;
452     MIB_TCPSTATS stats;
453
454     apiReturn = pGetTcpStatistics(NULL);
455     if (apiReturn == ERROR_NOT_SUPPORTED) {
456       skip("GetTcpStatistics is not supported\n");
457       return;
458     }
459     ok(apiReturn == ERROR_INVALID_PARAMETER,
460      "GetTcpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
461      apiReturn);
462     apiReturn = pGetTcpStatistics(&stats);
463     ok(apiReturn == NO_ERROR,
464       "GetTcpStatistics returned %d, expected NO_ERROR\n", apiReturn);
465     if (apiReturn == NO_ERROR && winetest_debug > 1)
466     {
467         trace( "TCP stats:\n" );
468         trace( "    dwRtoAlgorithm: %u\n", U(stats).dwRtoAlgorithm );
469         trace( "    dwRtoMin:       %u\n", stats.dwRtoMin );
470         trace( "    dwRtoMax:       %u\n", stats.dwRtoMax );
471         trace( "    dwMaxConn:      %u\n", stats.dwMaxConn );
472         trace( "    dwActiveOpens:  %u\n", stats.dwActiveOpens );
473         trace( "    dwPassiveOpens: %u\n", stats.dwPassiveOpens );
474         trace( "    dwAttemptFails: %u\n", stats.dwAttemptFails );
475         trace( "    dwEstabResets:  %u\n", stats.dwEstabResets );
476         trace( "    dwCurrEstab:    %u\n", stats.dwCurrEstab );
477         trace( "    dwInSegs:       %u\n", stats.dwInSegs );
478         trace( "    dwOutSegs:      %u\n", stats.dwOutSegs );
479         trace( "    dwRetransSegs:  %u\n", stats.dwRetransSegs );
480         trace( "    dwInErrs:       %u\n", stats.dwInErrs );
481         trace( "    dwOutRsts:      %u\n", stats.dwOutRsts );
482         trace( "    dwNumConns:     %u\n", stats.dwNumConns );
483     }
484   }
485 }
486
487 static void testGetUdpStatistics(void)
488 {
489   if (pGetUdpStatistics) {
490     DWORD apiReturn;
491     MIB_UDPSTATS stats;
492
493     apiReturn = pGetUdpStatistics(NULL);
494     if (apiReturn == ERROR_NOT_SUPPORTED) {
495       skip("GetUdpStatistics is not supported\n");
496       return;
497     }
498     ok(apiReturn == ERROR_INVALID_PARAMETER,
499      "GetUdpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
500      apiReturn);
501     apiReturn = pGetUdpStatistics(&stats);
502     ok(apiReturn == NO_ERROR,
503      "GetUdpStatistics returned %d, expected NO_ERROR\n", apiReturn);
504     if (apiReturn == NO_ERROR && winetest_debug > 1)
505     {
506         trace( "UDP stats:\n" );
507         trace( "    dwInDatagrams:  %u\n", stats.dwInDatagrams );
508         trace( "    dwNoPorts:      %u\n", stats.dwNoPorts );
509         trace( "    dwInErrors:     %u\n", stats.dwInErrors );
510         trace( "    dwOutDatagrams: %u\n", stats.dwOutDatagrams );
511         trace( "    dwNumAddrs:     %u\n", stats.dwNumAddrs );
512     }
513   }
514 }
515
516 static void testGetTcpTable(void)
517 {
518   if (pGetTcpTable) {
519     DWORD apiReturn;
520     ULONG dwSize = 0;
521
522     apiReturn = pGetTcpTable(NULL, &dwSize, FALSE);
523     if (apiReturn == ERROR_NOT_SUPPORTED) {
524       skip("GetTcpTable is not supported\n");
525       return;
526     }
527     ok(apiReturn == ERROR_INSUFFICIENT_BUFFER ||
528        broken(apiReturn == ERROR_NO_DATA), /* win95 */
529      "GetTcpTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
530      apiReturn);
531     if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
532       PMIB_TCPTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
533
534       apiReturn = pGetTcpTable(buf, &dwSize, FALSE);
535       ok(apiReturn == NO_ERROR,
536        "GetTcpTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
537        apiReturn);
538
539       if (apiReturn == NO_ERROR && winetest_debug > 1)
540       {
541           DWORD i;
542           trace( "TCP table: %u entries\n", buf->dwNumEntries );
543           for (i = 0; i < buf->dwNumEntries; i++)
544           {
545               char buffer[40];
546               sprintf( buffer, "local %s:%u",
547                        ntoa(buf->table[i].dwLocalAddr), ntohs(buf->table[i].dwLocalPort) );
548               trace( "%u: %s remote %s:%u state %u\n",
549                      i, buffer, ntoa( buf->table[i].dwRemoteAddr ),
550                      ntohs(buf->table[i].dwRemotePort), U(buf->table[i]).dwState );
551           }
552       }
553       HeapFree(GetProcessHeap(), 0, buf);
554     }
555   }
556 }
557
558 static void testGetUdpTable(void)
559 {
560   if (pGetUdpTable) {
561     DWORD apiReturn;
562     ULONG dwSize = 0;
563
564     apiReturn = pGetUdpTable(NULL, &dwSize, FALSE);
565     if (apiReturn == ERROR_NOT_SUPPORTED) {
566       skip("GetUdpTable is not supported\n");
567       return;
568     }
569     ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
570      "GetUdpTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
571      apiReturn);
572     if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
573       PMIB_UDPTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
574
575       apiReturn = pGetUdpTable(buf, &dwSize, FALSE);
576       ok(apiReturn == NO_ERROR,
577        "GetUdpTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
578        apiReturn);
579
580       if (apiReturn == NO_ERROR && winetest_debug > 1)
581       {
582           DWORD i;
583           trace( "UDP table: %u entries\n", buf->dwNumEntries );
584           for (i = 0; i < buf->dwNumEntries; i++)
585               trace( "%u: %s:%u\n",
586                      i, ntoa( buf->table[i].dwLocalAddr ), ntohs(buf->table[i].dwLocalPort) );
587       }
588       HeapFree(GetProcessHeap(), 0, buf);
589     }
590   }
591 }
592
593 static void testSetTcpEntry(void)
594 {
595     DWORD ret;
596     MIB_TCPROW row;
597
598     memset(&row, 0, sizeof(row));
599     if(0) /* This test crashes in OS >= VISTA */
600     {
601         ret = pSetTcpEntry(NULL);
602         ok( ret == ERROR_INVALID_PARAMETER, "got %u, expected %u\n", ret, ERROR_INVALID_PARAMETER);
603     }
604
605     ret = pSetTcpEntry(&row);
606     todo_wine ok( ret == ERROR_INVALID_PARAMETER, "got %u, expected %u\n", ret, ERROR_INVALID_PARAMETER);
607
608     U(row).dwState = MIB_TCP_STATE_DELETE_TCB;
609     ret = pSetTcpEntry(&row);
610     todo_wine ok( ret == ERROR_MR_MID_NOT_FOUND || broken(ret == ERROR_INVALID_PARAMETER),
611        "got %u, expected %u\n", ret, ERROR_MR_MID_NOT_FOUND);
612 }
613
614 /*
615 still-to-be-tested NT4-onward functions:
616 CreateIpForwardEntry
617 DeleteIpForwardEntry
618 CreateIpNetEntry
619 DeleteIpNetEntry
620 GetFriendlyIfIndex
621 GetRTTAndHopCount
622 SetIfEntry
623 SetIpForwardEntry
624 SetIpNetEntry
625 SetIpStatistics
626 SetIpTTL
627 */
628 static void testWinNT4Functions(void)
629 {
630   testGetNumberOfInterfaces();
631   testGetIpAddrTable();
632   testGetIfTable();
633   testGetIpForwardTable();
634   testGetIpNetTable();
635   testGetIcmpStatistics();
636   testGetIpStatistics();
637   testGetTcpStatistics();
638   testGetUdpStatistics();
639   testGetTcpTable();
640   testGetUdpTable();
641   testSetTcpEntry();
642 }
643
644 static void testGetInterfaceInfo(void)
645 {
646   if (pGetInterfaceInfo) {
647     DWORD apiReturn;
648     ULONG len = 0;
649
650     apiReturn = pGetInterfaceInfo(NULL, NULL);
651     if (apiReturn == ERROR_NOT_SUPPORTED) {
652       skip("GetInterfaceInfo is not supported\n");
653       return;
654     }
655     ok(apiReturn == ERROR_INVALID_PARAMETER,
656      "GetInterfaceInfo returned %d, expected ERROR_INVALID_PARAMETER\n",
657      apiReturn);
658     apiReturn = pGetInterfaceInfo(NULL, &len);
659     ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
660      "GetInterfaceInfo returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
661      apiReturn);
662     if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
663       PIP_INTERFACE_INFO buf = HeapAlloc(GetProcessHeap(), 0, len);
664
665       apiReturn = pGetInterfaceInfo(buf, &len);
666       ok(apiReturn == NO_ERROR,
667        "GetInterfaceInfo(buf, &dwSize) returned %d, expected NO_ERROR\n",
668        apiReturn);
669       HeapFree(GetProcessHeap(), 0, buf);
670     }
671   }
672 }
673
674 static void testGetAdaptersInfo(void)
675 {
676   if (pGetAdaptersInfo) {
677     DWORD apiReturn;
678     ULONG len = 0;
679
680     apiReturn = pGetAdaptersInfo(NULL, NULL);
681     if (apiReturn == ERROR_NOT_SUPPORTED) {
682       skip("GetAdaptersInfo is not supported\n");
683       return;
684     }
685     ok(apiReturn == ERROR_INVALID_PARAMETER,
686      "GetAdaptersInfo returned %d, expected ERROR_INVALID_PARAMETER\n",
687      apiReturn);
688     apiReturn = pGetAdaptersInfo(NULL, &len);
689     ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_BUFFER_OVERFLOW,
690      "GetAdaptersInfo returned %d, expected ERROR_NO_DATA or ERROR_BUFFER_OVERFLOW\n",
691      apiReturn);
692     if (apiReturn == ERROR_NO_DATA)
693       ; /* no adapter's, that's okay */
694     else if (apiReturn == ERROR_BUFFER_OVERFLOW) {
695       PIP_ADAPTER_INFO buf = HeapAlloc(GetProcessHeap(), 0, len);
696
697       apiReturn = pGetAdaptersInfo(buf, &len);
698       ok(apiReturn == NO_ERROR,
699        "GetAdaptersInfo(buf, &dwSize) returned %d, expected NO_ERROR\n",
700        apiReturn);
701       HeapFree(GetProcessHeap(), 0, buf);
702     }
703   }
704 }
705
706 static void testGetNetworkParams(void)
707 {
708   if (pGetNetworkParams) {
709     DWORD apiReturn;
710     ULONG len = 0;
711
712     apiReturn = pGetNetworkParams(NULL, NULL);
713     if (apiReturn == ERROR_NOT_SUPPORTED) {
714       skip("GetNetworkParams is not supported\n");
715       return;
716     }
717     ok(apiReturn == ERROR_INVALID_PARAMETER,
718      "GetNetworkParams returned %d, expected ERROR_INVALID_PARAMETER\n",
719      apiReturn);
720     apiReturn = pGetNetworkParams(NULL, &len);
721     ok(apiReturn == ERROR_BUFFER_OVERFLOW,
722      "GetNetworkParams returned %d, expected ERROR_BUFFER_OVERFLOW\n",
723      apiReturn);
724     if (apiReturn == ERROR_BUFFER_OVERFLOW) {
725       PFIXED_INFO buf = HeapAlloc(GetProcessHeap(), 0, len);
726
727       apiReturn = pGetNetworkParams(buf, &len);
728       ok(apiReturn == NO_ERROR,
729        "GetNetworkParams(buf, &dwSize) returned %d, expected NO_ERROR\n",
730        apiReturn);
731       HeapFree(GetProcessHeap(), 0, buf);
732     }
733   }
734 }
735
736 /*
737 still-to-be-tested 98-onward functions:
738 GetBestInterface
739 GetBestRoute
740 IpReleaseAddress
741 IpRenewAddress
742 */
743 static DWORD CALLBACK testWin98Functions(void *p)
744 {
745   testGetInterfaceInfo();
746   testGetAdaptersInfo();
747   testGetNetworkParams();
748   return 0;
749 }
750
751 static void testGetPerAdapterInfo(void)
752 {
753     DWORD ret, needed;
754     void *buffer;
755
756     if (!pGetPerAdapterInfo) return;
757     ret = pGetPerAdapterInfo(1, NULL, NULL);
758     if (ret == ERROR_NOT_SUPPORTED) {
759       skip("GetPerAdapterInfo is not supported\n");
760       return;
761     }
762     ok( ret == ERROR_INVALID_PARAMETER, "got %u instead of ERROR_INVALID_PARAMETER\n", ret );
763     needed = 0xdeadbeef;
764     ret = pGetPerAdapterInfo(1, NULL, &needed);
765     if (ret == ERROR_NO_DATA) return;  /* no such adapter */
766     ok( ret == ERROR_BUFFER_OVERFLOW, "got %u instead of ERROR_BUFFER_OVERFLOW\n", ret );
767     ok( needed != 0xdeadbeef, "needed not set\n" );
768     buffer = HeapAlloc( GetProcessHeap(), 0, needed );
769     ret = pGetPerAdapterInfo(1, buffer, &needed);
770     ok( ret == NO_ERROR, "got %u instead of NO_ERROR\n", ret );
771     HeapFree( GetProcessHeap(), 0, buffer );
772 }
773
774 static void testNotifyAddrChange(void)
775 {
776     DWORD ret, bytes;
777     OVERLAPPED overlapped;
778     HANDLE handle;
779     BOOL success;
780
781     if (!pNotifyAddrChange)
782     {
783         win_skip("NotifyAddrChange not present\n");
784         return;
785     }
786     if (!pCancelIPChangeNotify)
787     {
788         win_skip("CancelIPChangeNotify not present\n");
789         return;
790     }
791
792     handle = NULL;
793     ZeroMemory(&overlapped, sizeof(overlapped));
794     ret = pNotifyAddrChange(&handle, &overlapped);
795     if (ret == ERROR_NOT_SUPPORTED)
796     {
797         win_skip("NotifyAddrChange is not supported\n");
798         return;
799     }
800     ok(ret == ERROR_IO_PENDING, "NotifyAddrChange returned %d, expected ERROR_IO_PENDING\n", ret);
801     ret = GetLastError();
802     todo_wine ok(ret == ERROR_IO_PENDING, "GetLastError returned %d, expected ERROR_IO_PENDING\n", ret);
803     success = pCancelIPChangeNotify(&overlapped);
804     todo_wine ok(success == TRUE, "CancelIPChangeNotify returned FALSE, expected TRUE\n");
805
806     ZeroMemory(&overlapped, sizeof(overlapped));
807     success = pCancelIPChangeNotify(&overlapped);
808     ok(success == FALSE, "CancelIPChangeNotify returned TRUE, expected FALSE\n");
809
810     handle = NULL;
811     ZeroMemory(&overlapped, sizeof(overlapped));
812     overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
813     ret = pNotifyAddrChange(&handle, &overlapped);
814     ok(ret == ERROR_IO_PENDING, "NotifyAddrChange returned %d, expected ERROR_IO_PENDING\n", ret);
815     todo_wine ok(handle != INVALID_HANDLE_VALUE, "NotifyAddrChange returned invalid file handle\n");
816     success = GetOverlappedResult(handle, &overlapped, &bytes, FALSE);
817     ok(success == FALSE, "GetOverlappedResult returned TRUE, expected FALSE\n");
818     ret = GetLastError();
819     ok(ret == ERROR_IO_INCOMPLETE, "GetLastError returned %d, expected ERROR_IO_INCOMPLETE\n", ret);
820     success = pCancelIPChangeNotify(&overlapped);
821     todo_wine ok(success == TRUE, "CancelIPChangeNotify returned FALSE, expected TRUE\n");
822
823     if (winetest_interactive)
824     {
825         handle = NULL;
826         ZeroMemory(&overlapped, sizeof(overlapped));
827         overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
828         trace("Testing asynchronous ipv4 address change notification. Please "
829               "change the ipv4 address of one of your network interfaces\n");
830         ret = pNotifyAddrChange(&handle, &overlapped);
831         ok(ret == ERROR_IO_PENDING, "NotifyAddrChange returned %d, expected NO_ERROR\n", ret);
832         success = GetOverlappedResult(handle, &overlapped, &bytes, TRUE);
833         ok(success == TRUE, "GetOverlappedResult returned FALSE, expected TRUE\n");
834     }
835
836     /* test synchronous functionality */
837     if (winetest_interactive)
838     {
839         trace("Testing synchronous ipv4 address change notification. Please "
840               "change the ipv4 address of one of your network interfaces\n");
841         ret = pNotifyAddrChange(NULL, NULL);
842         todo_wine ok(ret == NO_ERROR, "NotifyAddrChange returned %d, expected NO_ERROR\n", ret);
843     }
844 }
845
846 /*
847 still-to-be-tested 2K-onward functions:
848 AddIPAddress
849 CreateProxyArpEntry
850 DeleteIPAddress
851 DeleteProxyArpEntry
852 EnableRouter
853 FlushIpNetTable
854 GetAdapterIndex
855 NotifyRouteChange + CancelIPChangeNotify
856 SendARP
857 UnenableRouter
858 */
859 static void testWin2KFunctions(void)
860 {
861     testGetPerAdapterInfo();
862     testNotifyAddrChange();
863 }
864
865 static void test_GetAdaptersAddresses(void)
866 {
867     ULONG ret, size;
868     IP_ADAPTER_ADDRESSES *aa, *ptr;
869     IP_ADAPTER_UNICAST_ADDRESS *ua;
870
871     if (!pGetAdaptersAddresses)
872     {
873         win_skip("GetAdaptersAddresses not present\n");
874         return;
875     }
876
877     ret = pGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, NULL);
878     ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", ret);
879
880     /* size should be ignored and overwritten if buffer is NULL */
881     size = 0x7fffffff;
882     ret = pGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &size);
883     ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %u\n", ret);
884     if (ret != ERROR_BUFFER_OVERFLOW) return;
885
886     ptr = HeapAlloc(GetProcessHeap(), 0, size);
887     ret = pGetAdaptersAddresses(AF_UNSPEC, 0, NULL, ptr, &size);
888     ok(!ret, "expected ERROR_SUCCESS got %u\n", ret);
889
890     for (aa = ptr; !ret && aa; aa = aa->Next)
891     {
892         ok(aa->DnsSuffix != NULL, "DnsSuffix is not a valid pointer\n");
893         ok(aa->Description != NULL, "Description is not a valid pointer\n");
894         ok(aa->FriendlyName != NULL, "FriendlyName is not a valid pointer\n");
895
896         if (winetest_debug <= 1)
897             continue;
898
899         trace("Length:                %u\n", S(U(*aa)).Length);
900         trace("IfIndex:               %u\n", S(U(*aa)).IfIndex);
901         trace("Next:                  %p\n", aa->Next);
902         trace("AdapterName:           %s\n", aa->AdapterName);
903         trace("FirstUnicastAddress:   %p\n", aa->FirstUnicastAddress);
904         ua = aa->FirstUnicastAddress;
905         while (ua)
906         {
907             trace("\tLength:                  %u\n", S(U(*ua)).Length);
908             trace("\tFlags:                   0x%08x\n", S(U(*ua)).Flags);
909             trace("\tNext:                    %p\n", ua->Next);
910             trace("\tAddress.lpSockaddr:      %p\n", ua->Address.lpSockaddr);
911             trace("\tAddress.iSockaddrLength: %d\n", ua->Address.iSockaddrLength);
912             trace("\tPrefixOrigin:            %u\n", ua->PrefixOrigin);
913             trace("\tSuffixOrigin:            %u\n", ua->SuffixOrigin);
914             trace("\tDadState:                %u\n", ua->DadState);
915             trace("\tValidLifetime:           0x%08x\n", ua->ValidLifetime);
916             trace("\tPreferredLifetime:       0x%08x\n", ua->PreferredLifetime);
917             trace("\tLeaseLifetime:           0x%08x\n", ua->LeaseLifetime);
918             trace("\n");
919             ua = ua->Next;
920         }
921         trace("FirstAnycastAddress:   %p\n", aa->FirstAnycastAddress);
922         trace("FirstMulticastAddress: %p\n", aa->FirstMulticastAddress);
923         trace("FirstDnsServerAddress: %p\n", aa->FirstDnsServerAddress);
924         trace("DnsSuffix:             %p\n", aa->DnsSuffix);
925         trace("Description:           %p\n", aa->Description);
926         trace("FriendlyName:          %p\n", aa->FriendlyName);
927         trace("PhysicalAddress:       %02x\n", aa->PhysicalAddress[0]);
928         trace("PhysicalAddressLength: %u\n", aa->PhysicalAddressLength);
929         trace("Flags:                 0x%08x\n", aa->Flags);
930         trace("Mtu:                   %u\n", aa->Mtu);
931         trace("IfType:                %u\n", aa->IfType);
932         trace("OperStatus:            %u\n", aa->OperStatus);
933         trace("\n");
934     }
935     HeapFree(GetProcessHeap(), 0, ptr);
936 }
937
938 static void test_GetExtendedTcpTable(void)
939 {
940     DWORD ret, size;
941     MIB_TCPTABLE *table;
942     MIB_TCPTABLE_OWNER_PID *table_pid;
943
944     if (!pGetExtendedTcpTable)
945     {
946         win_skip("GetExtendedTcpTable not available\n");
947         return;
948     }
949     ret = pGetExtendedTcpTable( NULL, NULL, TRUE, AF_INET, TCP_TABLE_BASIC_ALL, 0 );
950     ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
951
952     size = 0;
953     ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_BASIC_ALL, 0 );
954     ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret );
955
956     table = HeapAlloc( GetProcessHeap(), 0, size );
957     ret = pGetExtendedTcpTable( table, &size, TRUE, AF_INET, TCP_TABLE_BASIC_ALL, 0 );
958     ok( ret == ERROR_SUCCESS, "got %u\n", ret );
959     HeapFree( GetProcessHeap(), 0, table );
960
961     size = 0;
962     ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0 );
963     ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret );
964
965     table_pid = HeapAlloc( GetProcessHeap(), 0, size );
966     ret = pGetExtendedTcpTable( table_pid, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0 );
967     ok( ret == ERROR_SUCCESS, "got %u\n", ret );
968     HeapFree( GetProcessHeap(), 0, table_pid );
969 }
970
971 START_TEST(iphlpapi)
972 {
973
974   loadIPHlpApi();
975   if (hLibrary) {
976     HANDLE thread;
977
978     testWin98OnlyFunctions();
979     testWinNT4Functions();
980
981     /* run testGetXXXX in two threads at once to make sure we don't crash in that case */
982     thread = CreateThread(NULL, 0, testWin98Functions, NULL, 0, NULL);
983     testWin98Functions(NULL);
984     WaitForSingleObject(thread, INFINITE);
985
986     testWin2KFunctions();
987     test_GetAdaptersAddresses();
988     test_GetExtendedTcpTable();
989     freeIPHlpApi();
990   }
991 }