Removed some unneeded imports.
[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 "windef.h"
39 #include "winbase.h"
40 #include "iphlpapi.h"
41 #include "iprtrmib.h"
42 #include "wine/test.h"
43 #include <stdio.h>
44 #include <stdlib.h>
45
46 static HMODULE hLibrary = NULL;
47
48 typedef DWORD (WINAPI *GetNumberOfInterfacesFunc)(PDWORD);
49 typedef DWORD (WINAPI *GetIpAddrTableFunc)(PMIB_IPADDRTABLE,PULONG,BOOL);
50 typedef DWORD (WINAPI *GetIfEntryFunc)(PMIB_IFROW);
51 typedef DWORD (WINAPI *GetFriendlyIfIndexFunc)(DWORD);
52 typedef DWORD (WINAPI *GetIfTableFunc)(PMIB_IFTABLE,PULONG,BOOL);
53 typedef DWORD (WINAPI *GetIpForwardTableFunc)(PMIB_IPFORWARDTABLE,PULONG,BOOL);
54 typedef DWORD (WINAPI *GetIpNetTableFunc)(PMIB_IPNETTABLE,PULONG,BOOL);
55 typedef DWORD (WINAPI *GetInterfaceInfoFunc)(PIP_INTERFACE_INFO,PULONG);
56 typedef DWORD (WINAPI *GetAdaptersInfoFunc)(PIP_ADAPTER_INFO,PULONG);
57 typedef DWORD (WINAPI *GetNetworkParamsFunc)(PFIXED_INFO,PULONG);
58 typedef DWORD (WINAPI *GetIcmpStatisticsFunc)(PMIB_ICMP);
59 typedef DWORD (WINAPI *GetIpStatisticsFunc)(PMIB_IPSTATS);
60 typedef DWORD (WINAPI *GetTcpStatisticsFunc)(PMIB_TCPSTATS);
61 typedef DWORD (WINAPI *GetUdpStatisticsFunc)(PMIB_UDPSTATS);
62 typedef DWORD (WINAPI *GetTcpTableFunc)(PMIB_TCPTABLE,PDWORD,BOOL);
63 typedef DWORD (WINAPI *GetUdpTableFunc)(PMIB_UDPTABLE,PDWORD,BOOL);
64
65 static GetNumberOfInterfacesFunc gGetNumberOfInterfaces = NULL;
66 static GetIpAddrTableFunc gGetIpAddrTable = NULL;
67 static GetIfEntryFunc gGetIfEntry = NULL;
68 static GetFriendlyIfIndexFunc gGetFriendlyIfIndex = NULL;
69 static GetIfTableFunc gGetIfTable = NULL;
70 static GetIpForwardTableFunc gGetIpForwardTable = NULL;
71 static GetIpNetTableFunc gGetIpNetTable = NULL;
72 static GetInterfaceInfoFunc gGetInterfaceInfo = NULL;
73 static GetAdaptersInfoFunc gGetAdaptersInfo = NULL;
74 static GetNetworkParamsFunc gGetNetworkParams = NULL;
75 static GetIcmpStatisticsFunc gGetIcmpStatistics = NULL;
76 static GetIpStatisticsFunc gGetIpStatistics = NULL;
77 static GetTcpStatisticsFunc gGetTcpStatistics = NULL;
78 static GetUdpStatisticsFunc gGetUdpStatistics = NULL;
79 static GetTcpTableFunc gGetTcpTable = NULL;
80 static GetUdpTableFunc gGetUdpTable = NULL;
81
82 static void loadIPHlpApi(void)
83 {
84   hLibrary = LoadLibraryA("iphlpapi.dll");
85   if (hLibrary) {
86     gGetNumberOfInterfaces = (GetNumberOfInterfacesFunc)GetProcAddress(
87      hLibrary, "GetNumberOfInterfaces");
88     gGetIpAddrTable = (GetIpAddrTableFunc)GetProcAddress(
89      hLibrary, "GetIpAddrTable");
90     gGetIfEntry = (GetIfEntryFunc)GetProcAddress(
91      hLibrary, "GetIfEntry");
92     gGetFriendlyIfIndex = (GetFriendlyIfIndexFunc)GetProcAddress(
93      hLibrary, "GetFriendlyIfIndex");
94     gGetIfTable = (GetIfTableFunc)GetProcAddress(
95      hLibrary, "GetIfTable");
96     gGetIpForwardTable = (GetIpForwardTableFunc)GetProcAddress(
97      hLibrary, "GetIpForwardTable");
98     gGetIpNetTable = (GetIpNetTableFunc)GetProcAddress(
99      hLibrary, "GetIpNetTable");
100     gGetInterfaceInfo = (GetInterfaceInfoFunc)GetProcAddress(
101      hLibrary, "GetInterfaceInfo");
102     gGetAdaptersInfo = (GetAdaptersInfoFunc)GetProcAddress(
103      hLibrary, "GetAdaptersInfo");
104     gGetNetworkParams = (GetNetworkParamsFunc)GetProcAddress(
105      hLibrary, "GetNetworkParams");
106     gGetIcmpStatistics = (GetIcmpStatisticsFunc)GetProcAddress(
107      hLibrary, "GetIcmpStatistics");
108     gGetIpStatistics = (GetIpStatisticsFunc)GetProcAddress(
109      hLibrary, "GetIpStatistics");
110     gGetTcpStatistics = (GetTcpStatisticsFunc)GetProcAddress(
111      hLibrary, "GetTcpStatistics");
112     gGetUdpStatistics = (GetUdpStatisticsFunc)GetProcAddress(
113      hLibrary, "GetUdpStatistics");
114     gGetTcpTable = (GetTcpTableFunc)GetProcAddress(
115      hLibrary, "GetTcpTable");
116     gGetUdpTable = (GetUdpTableFunc)GetProcAddress(
117      hLibrary, "GetUdpTable");
118   }
119 }
120
121 static void freeIPHlpApi(void)
122 {
123   if (hLibrary) {
124     gGetNumberOfInterfaces = NULL;
125     gGetIpAddrTable = NULL;
126     gGetIfEntry = NULL;
127     gGetFriendlyIfIndex = NULL;
128     gGetIfTable = NULL;
129     gGetIpForwardTable = NULL;
130     gGetIpNetTable = NULL;
131     gGetInterfaceInfo = NULL;
132     gGetAdaptersInfo = NULL;
133     gGetNetworkParams = NULL;
134     gGetIcmpStatistics = NULL;
135     gGetIpStatistics = NULL;
136     gGetTcpStatistics = NULL;
137     gGetUdpStatistics = NULL;
138     gGetTcpTable = NULL;
139     gGetUdpTable = NULL;
140     FreeLibrary(hLibrary);
141     hLibrary = NULL;
142   }
143 }
144
145 /*
146 still-to-be-tested 98-only functions:
147 GetUniDirectionalAdapterInfo
148 */
149 static void testWin98OnlyFunctions(void)
150 {
151 }
152
153 static void testGetNumberOfInterfaces(void)
154 {
155   if (gGetNumberOfInterfaces) {
156     DWORD apiReturn = gGetNumberOfInterfaces(NULL), numInterfaces;
157
158     if (apiReturn == ERROR_NOT_SUPPORTED)
159       return;
160     ok(apiReturn == ERROR_INVALID_PARAMETER, 
161      "GetNumberOfInterfaces(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
162      apiReturn);
163     apiReturn = gGetNumberOfInterfaces(&numInterfaces);
164     ok(apiReturn == NO_ERROR,
165      "GetNumberOfInterfaces returned %d, expected 0\n", apiReturn);
166   }
167 }
168
169 static void testGetIfEntry(DWORD index)
170 {
171   if (gGetIfEntry) {
172     DWORD apiReturn;
173     MIB_IFROW row;
174
175     memset(&row, 0, sizeof(row));
176     apiReturn = gGetIfEntry(NULL);
177     if (apiReturn == ERROR_NOT_SUPPORTED)
178       return;
179     ok(apiReturn == ERROR_INVALID_PARAMETER,
180      "GetIfEntry(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
181      apiReturn);
182     row.dwIndex = -1; /* hope that's always bogus! */
183     apiReturn = gGetIfEntry(&row);
184     ok(apiReturn == ERROR_INVALID_DATA,
185      "GetIfEntry(bogus row) returned %d, expected ERROR_INVALID_DATA\n",
186      apiReturn);
187     row.dwIndex = index;
188     apiReturn = gGetIfEntry(&row);
189     ok(apiReturn == NO_ERROR, 
190      "GetIfEntry returned %d, expected NO_ERROR\n", apiReturn);
191   }
192 }
193
194 static void testGetIpAddrTable(void)
195 {
196   if (gGetIpAddrTable) {
197     DWORD apiReturn;
198     ULONG dwSize = 0;
199
200     apiReturn = gGetIpAddrTable(NULL, NULL, FALSE);
201     if (apiReturn == ERROR_NOT_SUPPORTED)
202       return;
203     ok(apiReturn == ERROR_INVALID_PARAMETER,
204      "GetIpAddrTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
205      apiReturn);
206     apiReturn = gGetIpAddrTable(NULL, &dwSize, FALSE);
207     ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
208      "GetIpAddrTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
209      apiReturn);
210     if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
211       PMIB_IPADDRTABLE buf = (PMIB_IPADDRTABLE)malloc(dwSize);
212
213       apiReturn = gGetIpAddrTable(buf, &dwSize, FALSE);
214       ok(apiReturn == NO_ERROR,
215        "GetIpAddrTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
216        apiReturn);
217       if (apiReturn == NO_ERROR && buf->dwNumEntries)
218         testGetIfEntry(buf->table[0].dwIndex);
219       free(buf);
220     }
221   }
222 }
223
224 static void testGetIfTable(void)
225 {
226   if (gGetIfTable) {
227     DWORD apiReturn;
228     ULONG dwSize = 0;
229
230     apiReturn = gGetIfTable(NULL, NULL, FALSE);
231     if (apiReturn == ERROR_NOT_SUPPORTED)
232       return;
233     ok(apiReturn == ERROR_INVALID_PARAMETER,
234      "GetIfTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
235      apiReturn);
236     apiReturn = gGetIfTable(NULL, &dwSize, FALSE);
237     ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
238      "GetIfTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
239      apiReturn);
240     if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
241       PMIB_IFTABLE buf = (PMIB_IFTABLE)malloc(dwSize);
242
243       apiReturn = gGetIfTable(buf, &dwSize, FALSE);
244       ok(apiReturn == NO_ERROR,
245        "GetIfTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n\n",
246        apiReturn);
247       free(buf);
248     }
249   }
250 }
251
252 static void testGetIpForwardTable(void)
253 {
254   if (gGetIpForwardTable) {
255     DWORD apiReturn;
256     ULONG dwSize = 0;
257
258     apiReturn = gGetIpForwardTable(NULL, NULL, FALSE);
259     if (apiReturn == ERROR_NOT_SUPPORTED)
260       return;
261     ok(apiReturn == ERROR_INVALID_PARAMETER,
262      "GetIpForwardTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
263      apiReturn);
264     apiReturn = gGetIpForwardTable(NULL, &dwSize, FALSE);
265     ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
266      "GetIpForwardTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
267      apiReturn);
268     if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
269       PMIB_IPFORWARDTABLE buf = (PMIB_IPFORWARDTABLE)malloc(dwSize);
270
271       apiReturn = gGetIpForwardTable(buf, &dwSize, FALSE);
272       ok(apiReturn == NO_ERROR,
273        "GetIpForwardTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
274        apiReturn);
275       free(buf);
276     }
277   }
278 }
279
280 static void testGetIpNetTable(void)
281 {
282   if (gGetIpNetTable) {
283     DWORD apiReturn;
284     ULONG dwSize = 0;
285
286     apiReturn = gGetIpNetTable(NULL, NULL, FALSE);
287     if (apiReturn == ERROR_NOT_SUPPORTED)
288       return;
289     ok(apiReturn == ERROR_INVALID_PARAMETER,
290      "GetIpNetTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
291      apiReturn);
292     apiReturn = gGetIpNetTable(NULL, &dwSize, FALSE);
293     ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_INSUFFICIENT_BUFFER,
294      "GetIpNetTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_NO_DATA or ERROR_INSUFFICIENT_BUFFER\n",
295      apiReturn);
296     if (apiReturn == ERROR_NO_DATA)
297       ; /* empty ARP table's okay */
298     else if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
299       PMIB_IPNETTABLE buf = (PMIB_IPNETTABLE)malloc(dwSize);
300
301       apiReturn = gGetIpNetTable(buf, &dwSize, FALSE);
302       ok(apiReturn == NO_ERROR,
303        "GetIpNetTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
304        apiReturn);
305       free(buf);
306     }
307   }
308 }
309
310 static void testGetIcmpStatistics(void)
311 {
312   if (gGetIcmpStatistics) {
313     DWORD apiReturn;
314     MIB_ICMP stats;
315
316     apiReturn = gGetIcmpStatistics(NULL);
317     if (apiReturn == ERROR_NOT_SUPPORTED)
318       return;
319     ok(apiReturn == ERROR_INVALID_PARAMETER,
320      "GetIcmpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
321      apiReturn);
322     apiReturn = gGetIcmpStatistics(&stats);
323     ok(apiReturn == NO_ERROR,
324      "GetIcmpStatistics returned %d, expected NO_ERROR\n", apiReturn);
325   }
326 }
327
328 static void testGetIpStatistics(void)
329 {
330   if (gGetIpStatistics) {
331     DWORD apiReturn;
332     MIB_IPSTATS stats;
333
334     apiReturn = gGetIpStatistics(NULL);
335     if (apiReturn == ERROR_NOT_SUPPORTED)
336       return;
337     ok(apiReturn == ERROR_INVALID_PARAMETER,
338      "GetIpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
339      apiReturn);
340     apiReturn = gGetIpStatistics(&stats);
341     ok(apiReturn == NO_ERROR,
342       "GetIpStatistics returned %d, expected NO_ERROR\n", apiReturn);
343   }
344 }
345
346 static void testGetTcpStatistics(void)
347 {
348   if (gGetTcpStatistics) {
349     DWORD apiReturn;
350     MIB_TCPSTATS stats;
351
352     apiReturn = gGetTcpStatistics(NULL);
353     if (apiReturn == ERROR_NOT_SUPPORTED)
354       return;
355     ok(apiReturn == ERROR_INVALID_PARAMETER,
356      "GetTcpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
357      apiReturn);
358     apiReturn = gGetTcpStatistics(&stats);
359     ok(apiReturn == NO_ERROR,
360       "GetTcpStatistics returned %d, expected NO_ERROR\n", apiReturn);
361   }
362 }
363
364 static void testGetUdpStatistics(void)
365 {
366   if (gGetUdpStatistics) {
367     DWORD apiReturn;
368     MIB_UDPSTATS stats;
369
370     apiReturn = gGetUdpStatistics(NULL);
371     if (apiReturn == ERROR_NOT_SUPPORTED)
372       return;
373     ok(apiReturn == ERROR_INVALID_PARAMETER,
374      "GetUdpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
375      apiReturn);
376     apiReturn = gGetUdpStatistics(&stats);
377     ok(apiReturn == NO_ERROR,
378      "GetUdpStatistics returned %d, expected NO_ERROR\n", apiReturn);
379   }
380 }
381
382 static void testGetTcpTable(void)
383 {
384   if (gGetTcpTable) {
385     DWORD apiReturn;
386     ULONG dwSize = 0;
387
388     apiReturn = gGetTcpTable(NULL, NULL, FALSE);
389     if (apiReturn == ERROR_NOT_SUPPORTED)
390       return;
391     ok(apiReturn == ERROR_INVALID_PARAMETER,
392      "GetTcpTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
393      apiReturn);
394     apiReturn = gGetTcpTable(NULL, &dwSize, FALSE);
395     ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
396      "GetTcpTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
397      apiReturn);
398     if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
399       PMIB_TCPTABLE buf = (PMIB_TCPTABLE)malloc(dwSize);
400
401       apiReturn = gGetTcpTable(buf, &dwSize, FALSE);
402       ok(apiReturn == NO_ERROR,
403        "GetTcpTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
404        apiReturn);
405       free(buf);
406     }
407   }
408 }
409
410 static void testGetUdpTable(void)
411 {
412   if (gGetUdpTable) {
413     DWORD apiReturn;
414     ULONG dwSize = 0;
415
416     apiReturn = gGetUdpTable(NULL, NULL, FALSE);
417     if (apiReturn == ERROR_NOT_SUPPORTED)
418       return;
419     ok(apiReturn == ERROR_INVALID_PARAMETER,
420      "GetUdpTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
421      apiReturn);
422     apiReturn = gGetUdpTable(NULL, &dwSize, FALSE);
423     ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
424      "GetUdpTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
425      apiReturn);
426     if (apiReturn != ERROR_INSUFFICIENT_BUFFER) {
427       PMIB_UDPTABLE buf = (PMIB_UDPTABLE)malloc(dwSize);
428
429       apiReturn = gGetUdpTable(buf, &dwSize, FALSE);
430       ok(apiReturn == NO_ERROR,
431        "GetUdpTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
432        apiReturn);
433       free(buf);
434     }
435   }
436 }
437
438 /*
439 still-to-be-tested NT4-onward functions:
440 CreateIpForwardEntry
441 DeleteIpForwardEntry
442 CreateIpNetEntry
443 DeleteIpNetEntry
444 GetFriendlyIfIndex
445 GetRTTAndHopCount
446 SetIfEntry
447 SetIpForwardEntry
448 SetIpNetEntry
449 SetIpStatistics
450 SetIpTTL
451 SetTcpEntry
452 */
453 static void testWinNT4Functions(void)
454 {
455   testGetNumberOfInterfaces();
456   testGetIpAddrTable();
457   testGetIfTable();
458   testGetIpForwardTable();
459   testGetIpNetTable();
460   testGetIcmpStatistics();
461   testGetIpStatistics();
462   testGetTcpStatistics();
463   testGetUdpStatistics();
464   testGetTcpTable();
465   testGetUdpTable();
466 }
467
468 static void testGetInterfaceInfo(void)
469 {
470   if (gGetInterfaceInfo) {
471     DWORD apiReturn;
472     ULONG len = 0;
473
474     apiReturn = gGetInterfaceInfo(NULL, NULL);
475     if (apiReturn == ERROR_NOT_SUPPORTED)
476       return;
477     ok(apiReturn == ERROR_INVALID_PARAMETER,
478      "GetInterfaceInfo returned %d, expected ERROR_INVALID_PARAMETER\n",
479      apiReturn);
480     apiReturn = gGetInterfaceInfo(NULL, &len);
481     ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
482      "GetInterfaceInfo returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
483      apiReturn);
484     if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
485       PIP_INTERFACE_INFO buf = (PIP_INTERFACE_INFO)malloc(len);
486
487       apiReturn = gGetInterfaceInfo(buf, &len);
488       ok(apiReturn == NO_ERROR,
489        "GetInterfaceInfo(buf, &dwSize) returned %d, expected NO_ERROR\n",
490        apiReturn);
491       free(buf);
492     }
493   }
494 }
495
496 static void testGetAdaptersInfo(void)
497 {
498   if (gGetAdaptersInfo) {
499     DWORD apiReturn;
500     ULONG len = 0;
501
502     apiReturn = gGetAdaptersInfo(NULL, NULL);
503     if (apiReturn == ERROR_NOT_SUPPORTED)
504       return;
505     ok(apiReturn == ERROR_INVALID_PARAMETER,
506      "GetAdaptersInfo returned %d, expected ERROR_INVALID_PARAMETER\n",
507      apiReturn);
508     apiReturn = gGetAdaptersInfo(NULL, &len);
509     ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_BUFFER_OVERFLOW,
510      "GetAdaptersInfo returned %d, expected ERROR_NO_DATA or ERROR_BUFFER_OVERFLOW\n",
511      apiReturn);
512     if (apiReturn == ERROR_NO_DATA)
513       ; /* no adapter's, that's okay */
514     else if (apiReturn == ERROR_BUFFER_OVERFLOW) {
515       PIP_ADAPTER_INFO buf = (PIP_ADAPTER_INFO)malloc(len);
516
517       apiReturn = gGetAdaptersInfo(buf, &len);
518       ok(apiReturn == NO_ERROR,
519        "GetAdaptersInfo(buf, &dwSize) returned %d, expected NO_ERROR\n",
520        apiReturn);
521       free(buf);
522     }
523   }
524 }
525
526 static void testGetNetworkParams(void)
527 {
528   if (gGetNetworkParams) {
529     DWORD apiReturn;
530     ULONG len = 0;
531
532     apiReturn = gGetNetworkParams(NULL, NULL);
533     if (apiReturn == ERROR_NOT_SUPPORTED)
534       return;
535     ok(apiReturn == ERROR_INVALID_PARAMETER,
536      "GetNetworkParams returned %d, expected ERROR_INVALID_PARAMETER\n",
537      apiReturn);
538     apiReturn = gGetNetworkParams(NULL, &len);
539     ok(apiReturn == ERROR_BUFFER_OVERFLOW,
540      "GetNetworkParams returned %d, expected ERROR_BUFFER_OVERFLOW\n",
541      apiReturn);
542     if (apiReturn == ERROR_BUFFER_OVERFLOW) {
543       PFIXED_INFO buf = (PFIXED_INFO)malloc(len);
544
545       apiReturn = gGetNetworkParams(buf, &len);
546       ok(apiReturn == NO_ERROR,
547        "GetNetworkParams(buf, &dwSize) returned %d, expected NO_ERROR\n",
548        apiReturn);
549       free(buf);
550     }
551   }
552 }
553
554 /*
555 still-to-be-tested 98-onward functions:
556 GetBestInterface
557 GetBestRoute
558 IpReleaseAddress
559 IpRenewAddress
560 */
561 static void testWin98Functions(void)
562 {
563   testGetInterfaceInfo();
564   testGetAdaptersInfo();
565   testGetNetworkParams();
566 }
567
568 /*
569 still-to-be-tested 2K-onward functions:
570 AddIPAddress
571 CreateProxyArpEntry
572 DeleteIPAddress
573 DeleteProxyArpEntry
574 EnableRouter
575 FlushIpNetTable
576 GetAdapterIndex
577 GetPerAdapterInfo
578 NotifyAddrChange
579 NotifyRouteChange
580 SendARP
581 UnenableRouter
582 */
583 static void testWin2KFunctions(void)
584 {
585 }
586
587 START_TEST(iphlpapi)
588 {
589
590   loadIPHlpApi();
591   if (hLibrary) {
592     testWin98OnlyFunctions();
593     testWinNT4Functions();
594     testWin98Functions();
595     testWin2KFunctions();
596     freeIPHlpApi();
597   }
598 }