Fixed header dependencies to be fully compatible with the Windows
[wine/multimedia.git] / dlls / iphlpapi / iphlpapi_main.c
blob411ceacfd0a88bf25b083a6f3d3ae15a14a7037a
1 /*
2 * iphlpapi dll implementation
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include <stdarg.h>
24 #include <stdlib.h>
25 #include <sys/types.h>
26 #ifdef HAVE_NETINET_IN_H
27 # include <netinet/in.h>
28 #endif
29 #ifdef HAVE_ARPA_NAMESER_H
30 # include <arpa/nameser.h>
31 #endif
32 #ifdef HAVE_RESOLV_H
33 # include <resolv.h>
34 #endif
36 #include "windef.h"
37 #include "winbase.h"
38 #include "iphlpapi.h"
39 #include "ifenum.h"
40 #include "ipstats.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
46 /******************************************************************
47 * AddIPAddress (IPHLPAPI.@)
50 * PARAMS
52 * Address [In]
53 * IpMask [In]
54 * IfIndex [In]
55 * NTEContext [In/Out]
56 * NTEInstance [In/Out]
58 * RETURNS
60 * DWORD
63 DWORD WINAPI AddIPAddress(IPAddr Address, IPMask IpMask, DWORD IfIndex, PULONG NTEContext, PULONG NTEInstance)
65 FIXME(":stub\n");
66 /* marking Win2K+ functions not supported */
67 return ERROR_NOT_SUPPORTED;
71 /******************************************************************
72 * CreateIpForwardEntry (IPHLPAPI.@)
75 * PARAMS
77 * pRoute [In/Out]
79 * RETURNS
81 * DWORD
84 DWORD WINAPI CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute)
86 /* could use SIOCADDRT, not sure I want to */
87 FIXME(":stub\n");
88 return (DWORD) 0;
92 /******************************************************************
93 * CreateIpNetEntry (IPHLPAPI.@)
96 * PARAMS
98 * pArpEntry [In/Out]
100 * RETURNS
102 * DWORD
105 DWORD WINAPI CreateIpNetEntry(PMIB_IPNETROW pArpEntry)
107 /* could use SIOCSARP on systems that support it, not sure I want to */
108 FIXME(":stub\n");
109 return (DWORD) 0;
113 /******************************************************************
114 * CreateProxyArpEntry (IPHLPAPI.@)
117 * PARAMS
119 * dwAddress [In]
120 * dwMask [In]
121 * dwIfIndex [In]
123 * RETURNS
125 * DWORD
128 DWORD WINAPI CreateProxyArpEntry(DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
130 FIXME(":stub\n");
131 /* marking Win2K+ functions not supported */
132 return ERROR_NOT_SUPPORTED;
136 /******************************************************************
137 * DeleteIPAddress (IPHLPAPI.@)
140 * PARAMS
142 * NTEContext [In]
144 * RETURNS
146 * DWORD
149 DWORD WINAPI DeleteIPAddress(ULONG NTEContext)
151 FIXME(":stub\n");
152 /* marking Win2K+ functions not supported */
153 return ERROR_NOT_SUPPORTED;
157 /******************************************************************
158 * DeleteIpForwardEntry (IPHLPAPI.@)
161 * PARAMS
163 * pRoute [In/Out]
165 * RETURNS
167 * DWORD
170 DWORD WINAPI DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute)
172 /* could use SIOCDELRT, not sure I want to */
173 FIXME(":stub\n");
174 return (DWORD) 0;
178 /******************************************************************
179 * DeleteIpNetEntry (IPHLPAPI.@)
182 * PARAMS
184 * pArpEntry [In/Out]
186 * RETURNS
188 * DWORD
191 DWORD WINAPI DeleteIpNetEntry(PMIB_IPNETROW pArpEntry)
193 /* could use SIOCDARP on systems that support it, not sure I want to */
194 FIXME(":stub\n");
195 return (DWORD) 0;
199 /******************************************************************
200 * DeleteProxyArpEntry (IPHLPAPI.@)
203 * PARAMS
205 * dwAddress [In]
206 * dwMask [In]
207 * dwIfIndex [In]
209 * RETURNS
211 * DWORD
214 DWORD WINAPI DeleteProxyArpEntry(DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
216 FIXME(":stub\n");
217 /* marking Win2K+ functions not supported */
218 return ERROR_NOT_SUPPORTED;
222 /******************************************************************
223 * EnableRouter (IPHLPAPI.@)
226 * PARAMS
228 * pHandle [In/Out]
229 * pOverlapped [In/Out]
231 * RETURNS
233 * DWORD
236 DWORD WINAPI EnableRouter(HANDLE * pHandle, OVERLAPPED * pOverlapped)
238 FIXME(":stub\n");
239 /* could echo "1" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
240 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
241 marking Win2K+ functions not supported */
242 return ERROR_NOT_SUPPORTED;
246 /******************************************************************
247 * FlushIpNetTable (IPHLPAPI.@)
250 * PARAMS
252 * dwIfIndex [In]
254 * RETURNS
256 * DWORD
259 DWORD WINAPI FlushIpNetTable(DWORD dwIfIndex)
261 FIXME(":stub\n");
262 /* this flushes the arp cache of the given index
263 marking Win2K+ functions not supported */
264 return ERROR_NOT_SUPPORTED;
268 /******************************************************************
269 * GetAdapterIndex (IPHLPAPI.@)
272 * PARAMS
274 * AdapterName [In/Out]
275 * IfIndex [In/Out]
277 * RETURNS
279 * DWORD
282 DWORD WINAPI GetAdapterIndex(LPWSTR AdapterName, PULONG IfIndex)
284 FIXME(":stub\n");
285 /* marking Win2K+ functions not supported */
286 return ERROR_NOT_SUPPORTED;
290 /******************************************************************
291 * GetAdaptersInfo (IPHLPAPI.@)
294 * PARAMS
296 * pAdapterInfo [In/Out]
297 * pOutBufLen [In/Out]
299 * RETURNS
301 * DWORD
304 DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
306 DWORD ret;
308 if (!pOutBufLen)
309 ret = ERROR_INVALID_PARAMETER;
310 else {
311 DWORD numNonLoopbackInterfaces = getNumNonLoopbackInterfaces();
313 if (numNonLoopbackInterfaces > 0) {
314 /* this calculation assumes only one address in the IP_ADDR_STRING lists.
315 that's okay, because:
316 - we don't get multiple addresses per adapter anyway
317 - we don't know about per-adapter gateways
318 - we don't know about DHCP or WINS (and these must be single anyway) */
319 ULONG size = sizeof(IP_ADAPTER_INFO) * numNonLoopbackInterfaces;
321 if (!pAdapterInfo || *pOutBufLen < size) {
322 *pOutBufLen = size;
323 ret = ERROR_BUFFER_OVERFLOW;
325 else {
326 InterfaceIndexTable *table = getNonLoopbackInterfaceIndexTable();
328 if (table) {
329 size = sizeof(IP_ADAPTER_INFO) * table->numIndexes;
330 if (*pOutBufLen < size) {
331 *pOutBufLen = size;
332 ret = ERROR_INSUFFICIENT_BUFFER;
334 else {
335 DWORD ndx;
337 memset(pAdapterInfo, 0, size);
338 for (ndx = 0; ndx < table->numIndexes; ndx++) {
339 PIP_ADAPTER_INFO ptr = &pAdapterInfo[ndx];
340 DWORD addrLen = sizeof(ptr->Address), type;
342 /* on Win98 this is left empty, but whatever */
343 strncpy(ptr->AdapterName,
344 getInterfaceNameByIndex(table->indexes[ndx]),
345 sizeof(ptr->AdapterName));
346 ptr->AdapterName[MAX_ADAPTER_NAME_LENGTH] = '\0';
347 getInterfacePhysicalByIndex(table->indexes[ndx], &addrLen,
348 ptr->Address, &type);
349 /* MS defines address length and type as UINT in some places and
350 DWORD in others, **sigh**. Don't want to assume that PUINT and
351 PDWORD are equiv (64-bit?) */
352 ptr->AddressLength = addrLen;
353 ptr->Type = type;
354 ptr->Index = table->indexes[ndx];
355 toIPAddressString(getInterfaceIPAddrByIndex(table->indexes[ndx]),
356 ptr->IpAddressList.IpAddress.String);
357 toIPAddressString(getInterfaceMaskByIndex(table->indexes[ndx]),
358 ptr->IpAddressList.IpMask.String);
359 if (ndx < table->numIndexes + 1)
360 ptr->Next = (ndx == table->numIndexes - 1) ? NULL : &pAdapterInfo[ndx + 1];
362 ret = NO_ERROR;
364 free(table);
366 else
367 ret = ERROR_OUTOFMEMORY;
370 else
371 ret = ERROR_NO_DATA;
373 return ret;
377 /******************************************************************
378 * GetBestInterface (IPHLPAPI.@)
381 * PARAMS
383 * dwDestAddr [In]
384 * pdwBestIfIndex [In/Out]
386 * RETURNS
388 * DWORD
391 DWORD WINAPI GetBestInterface(IPAddr dwDestAddr, PDWORD pdwBestIfIndex)
393 FIXME(":stub\n");
394 return (DWORD) 0;
398 /******************************************************************
399 * GetBestRoute (IPHLPAPI.@)
402 * PARAMS
404 * dwDestAddr [In]
405 * dwSourceAddr [In]
406 * OUT [In]
408 * RETURNS
410 * DWORD
413 DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDROW pBestRoute)
415 FIXME(":stub\n");
416 return (DWORD) 0;
420 /******************************************************************
421 * GetFriendlyIfIndex (IPHLPAPI.@)
424 * PARAMS
426 * IfIndex [In]
428 * RETURNS
430 * DWORD
433 DWORD WINAPI GetFriendlyIfIndex(DWORD IfIndex)
435 /* windows doesn't validate these, either, just makes sure the top byte is
436 cleared. I assume my ipshared module never gives an index with the top
437 byte set. */
438 return IfIndex;
442 /******************************************************************
443 * GetIcmpStatistics (IPHLPAPI.@)
446 * PARAMS
448 * pStats [In/Out]
450 * RETURNS
452 * DWORD
455 DWORD WINAPI GetIcmpStatistics(PMIB_ICMP pStats)
457 return getICMPStats(pStats);
461 /******************************************************************
462 * GetIfEntry (IPHLPAPI.@)
465 * PARAMS
467 * pIfRow [In/Out]
469 * RETURNS
471 * DWORD
474 DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
476 DWORD ret;
477 const char *name;
479 if (!pIfRow)
480 return ERROR_INVALID_PARAMETER;
482 name = getInterfaceNameByIndex(pIfRow->dwIndex);
483 if (name) {
484 ret = getInterfaceEntryByName(name, pIfRow);
485 if (ret == NO_ERROR)
486 ret = getInterfaceStatsByName(name, pIfRow);
488 else
489 ret = ERROR_INVALID_DATA;
490 return ret;
494 /******************************************************************
495 * GetIfTable (IPHLPAPI.@)
498 * PARAMS
500 * pIfTable [In/Out]
501 * pdwSize [In/Out]
502 * bOrder [In]
504 * RETURNS
506 * DWORD
509 DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
511 DWORD ret;
513 if (!pdwSize)
514 ret = ERROR_INVALID_PARAMETER;
515 else {
516 DWORD numInterfaces = getNumInterfaces();
517 ULONG size = sizeof(MIB_IFTABLE) + (numInterfaces - 1) * sizeof(MIB_IFROW);
519 if (!pIfTable || *pdwSize < size) {
520 *pdwSize = size;
521 ret = ERROR_INSUFFICIENT_BUFFER;
523 else {
524 InterfaceIndexTable *table = getInterfaceIndexTable();
526 if (table) {
527 size = sizeof(MIB_IFTABLE) + (table->numIndexes - 1) *
528 sizeof(MIB_IFROW);
529 if (*pdwSize < size) {
530 *pdwSize = size;
531 ret = ERROR_INSUFFICIENT_BUFFER;
533 else {
534 DWORD ndx;
536 if (bOrder)
537 FIXME(":order not implemented");
538 pIfTable->dwNumEntries = 0;
539 for (ndx = 0; ndx < table->numIndexes; ndx++) {
540 pIfTable->table[ndx].dwIndex = table->indexes[ndx];
541 GetIfEntry(&pIfTable->table[ndx]);
542 pIfTable->dwNumEntries++;
544 ret = NO_ERROR;
546 free(table);
548 else
549 ret = ERROR_OUTOFMEMORY;
552 return ret;
556 /******************************************************************
557 * GetInterfaceInfo (IPHLPAPI.@)
560 * PARAMS
562 * pIfTable [In/Out]
563 * dwOutBufLen [In/Out]
565 * RETURNS
567 * DWORD
570 DWORD WINAPI GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen)
572 DWORD ret;
574 if (!dwOutBufLen)
575 ret = ERROR_INVALID_PARAMETER;
576 else {
577 DWORD numInterfaces = getNumInterfaces();
578 ULONG size = sizeof(IP_INTERFACE_INFO) + (numInterfaces - 1) *
579 sizeof(IP_ADAPTER_INDEX_MAP);
581 if (!pIfTable || *dwOutBufLen < size) {
582 *dwOutBufLen = size;
583 ret = ERROR_INSUFFICIENT_BUFFER;
585 else {
586 InterfaceIndexTable *table = getInterfaceIndexTable();
588 if (table) {
589 size = sizeof(IP_INTERFACE_INFO) + (table->numIndexes - 1) *
590 sizeof(IP_ADAPTER_INDEX_MAP);
591 if (*dwOutBufLen < size) {
592 *dwOutBufLen = size;
593 ret = ERROR_INSUFFICIENT_BUFFER;
595 else {
596 DWORD ndx;
598 pIfTable->NumAdapters = 0;
599 for (ndx = 0; ndx < table->numIndexes; ndx++) {
600 const char *walker, *name;
601 WCHAR *assigner;
603 pIfTable->Adapter[ndx].Index = table->indexes[ndx];
604 name = getInterfaceNameByIndex(table->indexes[ndx]);
605 for (walker = name, assigner = pIfTable->Adapter[ndx].Name;
606 walker && *walker &&
607 assigner - pIfTable->Adapter[ndx].Name < MAX_ADAPTER_NAME - 1;
608 walker++, assigner++)
609 *assigner = *walker;
610 *assigner = 0;
611 pIfTable->NumAdapters++;
613 ret = NO_ERROR;
615 free(table);
617 else
618 ret = ERROR_OUTOFMEMORY;
621 return ret;
625 /******************************************************************
626 * GetIpAddrTable (IPHLPAPI.@)
629 * PARAMS
631 * pIpAddrTable [In/Out]
632 * pdwSize [In/Out]
633 * bOrder [In]
635 * RETURNS
637 * DWORD
640 DWORD WINAPI GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder)
642 DWORD ret;
644 if (!pdwSize)
645 ret = ERROR_INVALID_PARAMETER;
646 else {
647 DWORD numInterfaces = getNumInterfaces();
648 ULONG size = sizeof(MIB_IPADDRTABLE) + (numInterfaces - 1) *
649 sizeof(MIB_IPADDRROW);
651 if (!pIpAddrTable || *pdwSize < size) {
652 *pdwSize = size;
653 ret = ERROR_INSUFFICIENT_BUFFER;
655 else {
656 InterfaceIndexTable *table = getInterfaceIndexTable();
658 if (table) {
659 size = sizeof(MIB_IPADDRTABLE) + (table->numIndexes - 1) *
660 sizeof(MIB_IPADDRROW);
661 if (*pdwSize < size) {
662 *pdwSize = size;
663 ret = ERROR_INSUFFICIENT_BUFFER;
665 else {
666 DWORD ndx;
668 if (bOrder)
669 FIXME(":order not implemented");
670 pIpAddrTable->dwNumEntries = 0;
671 for (ndx = 0; ndx < table->numIndexes; ndx++) {
672 pIpAddrTable->table[ndx].dwIndex = table->indexes[ndx];
673 pIpAddrTable->table[ndx].dwAddr =
674 getInterfaceIPAddrByIndex(table->indexes[ndx]);
675 pIpAddrTable->table[ndx].dwMask =
676 getInterfaceMaskByIndex(table->indexes[ndx]);
677 pIpAddrTable->table[ndx].dwBCastAddr =
678 getInterfaceBCastAddrByIndex(table->indexes[ndx]);
679 /* FIXME: hardcoded reasm size, not sure where to get it */
680 pIpAddrTable->table[ndx].dwReasmSize = 65535;
681 pIpAddrTable->table[ndx].unused1 = 0;
682 pIpAddrTable->table[ndx].wType = 0; /* aka unused2 */
683 pIpAddrTable->dwNumEntries++;
685 ret = NO_ERROR;
687 free(table);
689 else
690 ret = ERROR_OUTOFMEMORY;
693 return ret;
697 /******************************************************************
698 * GetIpForwardTable (IPHLPAPI.@)
701 * PARAMS
703 * pIpForwardTable [In/Out]
704 * pdwSize [In/Out]
705 * bOrder [In]
707 * RETURNS
709 * DWORD
712 DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSize, BOOL bOrder)
714 DWORD ret;
716 if (!pdwSize)
717 ret = ERROR_INVALID_PARAMETER;
718 else {
719 DWORD numRoutes = getNumRoutes();
720 ULONG sizeNeeded = sizeof(MIB_IPFORWARDTABLE) + (numRoutes - 1) *
721 sizeof(MIB_IPFORWARDROW);
723 if (!pIpForwardTable || *pdwSize < sizeNeeded) {
724 *pdwSize = sizeNeeded;
725 ret = ERROR_INSUFFICIENT_BUFFER;
727 else {
728 RouteTable *table = getRouteTable();
729 if (table) {
730 sizeNeeded = sizeof(MIB_IPFORWARDTABLE) + (table->numRoutes - 1) *
731 sizeof(MIB_IPFORWARDROW);
732 if (*pdwSize < sizeNeeded) {
733 *pdwSize = sizeNeeded;
734 ret = ERROR_INSUFFICIENT_BUFFER;
736 else {
737 DWORD ndx;
739 if (bOrder)
740 FIXME(":order not implemented");
741 pIpForwardTable->dwNumEntries = table->numRoutes;
742 for (ndx = 0; ndx < numRoutes; ndx++) {
743 pIpForwardTable->table[ndx].dwForwardIfIndex =
744 table->routes[ndx].ifIndex;
745 pIpForwardTable->table[ndx].dwForwardDest =
746 table->routes[ndx].dest;
747 pIpForwardTable->table[ndx].dwForwardMask =
748 table->routes[ndx].mask;
749 pIpForwardTable->table[ndx].dwForwardPolicy = 0;
750 pIpForwardTable->table[ndx].dwForwardNextHop =
751 table->routes[ndx].gateway;
752 /* FIXME: this type is appropriate for local interfaces; may not
753 always be appropriate */
754 pIpForwardTable->table[ndx].dwForwardType = MIB_IPROUTE_TYPE_DIRECT;
755 /* FIXME: other protos might be appropriate, e.g. the default route
756 is typically set with MIB_IPPROTO_NETMGMT instead */
757 pIpForwardTable->table[ndx].dwForwardProto = MIB_IPPROTO_LOCAL;
758 /* punt on age and AS */
759 pIpForwardTable->table[ndx].dwForwardAge = 0;
760 pIpForwardTable->table[ndx].dwForwardNextHopAS = 0;
761 pIpForwardTable->table[ndx].dwForwardMetric1 =
762 table->routes[ndx].metric;
763 /* rest of the metrics are 0.. */
764 pIpForwardTable->table[ndx].dwForwardMetric2 = 0;
765 pIpForwardTable->table[ndx].dwForwardMetric3 = 0;
766 pIpForwardTable->table[ndx].dwForwardMetric4 = 0;
767 pIpForwardTable->table[ndx].dwForwardMetric5 = 0;
769 ret = NO_ERROR;
771 free(table);
773 else
774 ret = ERROR_OUTOFMEMORY;
777 return ret;
781 /******************************************************************
782 * GetIpNetTable (IPHLPAPI.@)
785 * PARAMS
787 * pIpNetTable [In/Out]
788 * pdwSize [In/Out]
789 * bOrder [In]
791 * RETURNS
793 * DWORD
796 DWORD WINAPI GetIpNetTable(PMIB_IPNETTABLE pIpNetTable, PULONG pdwSize, BOOL bOrder)
798 DWORD ret;
800 if (!pdwSize)
801 ret = ERROR_INVALID_PARAMETER;
802 else {
803 DWORD numEntries = getNumArpEntries();
804 ULONG size = sizeof(MIB_IPNETTABLE) + (numEntries - 1) *
805 sizeof(MIB_IPNETROW);
807 if (!pIpNetTable || *pdwSize < size) {
808 *pdwSize = size;
809 ret = ERROR_INSUFFICIENT_BUFFER;
811 else {
812 PMIB_IPNETTABLE table = getArpTable();
814 if (table) {
815 size = sizeof(MIB_IPNETTABLE) + (table->dwNumEntries - 1) *
816 sizeof(MIB_IPNETROW);
817 if (*pdwSize < size) {
818 *pdwSize = size;
819 ret = ERROR_INSUFFICIENT_BUFFER;
821 else {
822 if (bOrder)
823 FIXME(":order not implemented");
824 memcpy(pIpNetTable, table, size);
825 ret = NO_ERROR;
827 free(table);
829 else
830 ret = ERROR_OUTOFMEMORY;
833 return ret;
837 /******************************************************************
838 * GetIpStatistics (IPHLPAPI.@)
841 * PARAMS
843 * pStats [In/Out]
845 * RETURNS
847 * DWORD
850 DWORD WINAPI GetIpStatistics(PMIB_IPSTATS pStats)
852 return getIPStats(pStats);
856 /******************************************************************
857 * GetNetworkParams (IPHLPAPI.@)
860 * PARAMS
862 * pFixedInfo [In/Out]
863 * pOutBufLen [In/Out]
865 * RETURNS
867 * DWORD
870 DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
872 DWORD size;
874 if (!pOutBufLen)
875 return ERROR_INVALID_PARAMETER;
877 size = sizeof(FIXED_INFO) + min(1, (_res.nscount - 1) *
878 sizeof(IP_ADDR_STRING));
879 if (!pFixedInfo || *pOutBufLen < size) {
880 *pOutBufLen = size;
881 return ERROR_BUFFER_OVERFLOW;
884 memset(pFixedInfo, 0, size);
885 size = sizeof(pFixedInfo->HostName);
886 GetComputerNameExA(ComputerNameDnsHostname, pFixedInfo->HostName, &size);
887 size = sizeof(pFixedInfo->DomainName);
888 GetComputerNameExA(ComputerNameDnsDomain, pFixedInfo->DomainName, &size);
889 if (_res.nscount > 0) {
890 PIP_ADDR_STRING ptr;
891 int i;
893 for (i = 0, ptr = &pFixedInfo->DnsServerList; i < _res.nscount;
894 i++, ptr = ptr->Next) {
895 toIPAddressString(_res.nsaddr_list[i].sin_addr.s_addr,
896 ptr->IpAddress.String);
897 ptr->Next = (PIP_ADDR_STRING)((PBYTE)ptr + sizeof(IP_ADDRESS_STRING));
900 /* FIXME: can check whether routing's enabled in /proc/sys/net/ipv4/ip_forward
901 I suppose could also check for a listener on port 53 to set EnableDns */
902 return NO_ERROR;
906 /******************************************************************
907 * GetNumberOfInterfaces (IPHLPAPI.@)
910 * PARAMS
912 * pdwNumIf [In/Out]
914 * RETURNS
916 * DWORD
919 DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf)
921 DWORD ret;
923 if (!pdwNumIf)
924 ret = ERROR_INVALID_PARAMETER;
925 else {
926 *pdwNumIf = getNumInterfaces();
927 ret = NO_ERROR;
929 return ret;
933 /******************************************************************
934 * GetPerAdapterInfo (IPHLPAPI.@)
937 * PARAMS
939 * IfIndex [In]
940 * pPerAdapterInfo [In/Out]
941 * pOutBufLen [In/Out]
943 * RETURNS
945 * DWORD
948 DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
950 FIXME(":stub\n");
951 /* marking Win2K+ functions not supported */
952 return ERROR_NOT_SUPPORTED;
956 /******************************************************************
957 * GetRTTAndHopCount (IPHLPAPI.@)
960 * PARAMS
962 * DestIpAddress [In]
963 * HopCount [In/Out]
964 * MaxHops [In]
965 * RTT [In/Out]
967 * RETURNS
969 * BOOL
972 BOOL WINAPI GetRTTAndHopCount(IPAddr DestIpAddress, PULONG HopCount, ULONG MaxHops, PULONG RTT)
974 FIXME(":stub\n");
975 return (BOOL) 0;
979 /******************************************************************
980 * GetTcpStatistics (IPHLPAPI.@)
983 * PARAMS
985 * pStats [In/Out]
987 * RETURNS
989 * DWORD
992 DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS pStats)
994 return getTCPStats(pStats);
998 /******************************************************************
999 * GetTcpTable (IPHLPAPI.@)
1002 * PARAMS
1004 * pTcpTable [In/Out]
1005 * pdwSize [In/Out]
1006 * bOrder [In]
1008 * RETURNS
1010 * DWORD
1013 DWORD WINAPI GetTcpTable(PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder)
1015 DWORD ret;
1017 if (!pdwSize)
1018 ret = ERROR_INVALID_PARAMETER;
1019 else {
1020 DWORD numEntries = getNumTcpEntries();
1021 ULONG size = sizeof(MIB_TCPTABLE) + (numEntries - 1) * sizeof(MIB_TCPROW);
1023 if (!pTcpTable || *pdwSize < size) {
1024 *pdwSize = size;
1025 ret = ERROR_INSUFFICIENT_BUFFER;
1027 else {
1028 PMIB_TCPTABLE table = getTcpTable();
1030 if (table) {
1031 size = sizeof(MIB_TCPTABLE) + (table->dwNumEntries - 1) *
1032 sizeof(MIB_TCPROW);
1033 if (*pdwSize < size) {
1034 *pdwSize = size;
1035 ret = ERROR_INSUFFICIENT_BUFFER;
1037 else {
1038 if (bOrder)
1039 FIXME(":order not implemented");
1040 memcpy(pTcpTable, table, size);
1041 ret = NO_ERROR;
1043 free(table);
1045 else
1046 ret = ERROR_OUTOFMEMORY;
1049 return ret;
1053 /******************************************************************
1054 * GetUdpStatistics (IPHLPAPI.@)
1057 * PARAMS
1059 * pStats [In/Out]
1061 * RETURNS
1063 * DWORD
1066 DWORD WINAPI GetUdpStatistics(PMIB_UDPSTATS pStats)
1068 return getUDPStats(pStats);
1072 /******************************************************************
1073 * GetUdpTable (IPHLPAPI.@)
1076 * PARAMS
1078 * pUdpTable [In/Out]
1079 * pdwSize [In/Out]
1080 * bOrder [In]
1082 * RETURNS
1084 * DWORD
1087 DWORD WINAPI GetUdpTable(PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder)
1089 DWORD ret;
1091 if (!pdwSize)
1092 ret = ERROR_INVALID_PARAMETER;
1093 else {
1094 DWORD numEntries = getNumUdpEntries();
1095 ULONG size = sizeof(MIB_UDPTABLE) + (numEntries - 1) * sizeof(MIB_UDPROW);
1097 if (!pUdpTable || *pdwSize < size) {
1098 *pdwSize = size;
1099 ret = ERROR_INSUFFICIENT_BUFFER;
1101 else {
1102 PMIB_UDPTABLE table = getUdpTable();
1104 if (table) {
1105 size = sizeof(MIB_UDPTABLE) + (table->dwNumEntries - 1) *
1106 sizeof(MIB_UDPROW);
1107 if (*pdwSize < size) {
1108 *pdwSize = size;
1109 ret = ERROR_INSUFFICIENT_BUFFER;
1111 else {
1112 if (bOrder)
1113 FIXME(":order not implemented");
1114 memcpy(pUdpTable, table, size);
1115 ret = NO_ERROR;
1117 free(table);
1119 else
1120 ret = ERROR_OUTOFMEMORY;
1123 return ret;
1127 /******************************************************************
1128 * GetUniDirectionalAdapterInfo (IPHLPAPI.@)
1131 * PARAMS
1133 * pIPIfInfo [In/Out]
1134 * dwOutBufLen [In/Out]
1136 * RETURNS
1138 * DWORD
1141 DWORD WINAPI GetUniDirectionalAdapterInfo(PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo, PULONG dwOutBufLen)
1143 /* a unidirectional adapter?? not bloody likely! */
1144 return ERROR_NOT_SUPPORTED;
1148 /******************************************************************
1149 * IpReleaseAddress (IPHLPAPI.@)
1152 * PARAMS
1154 * AdapterInfo [In/Out]
1156 * RETURNS
1158 * DWORD
1161 DWORD WINAPI IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
1163 /* not a stub, never going to support this (and I never mark an adapter as
1164 DHCP enabled, see GetAdaptersInfo, so this should never get called) */
1165 return ERROR_NOT_SUPPORTED;
1169 /******************************************************************
1170 * IpRenewAddress (IPHLPAPI.@)
1173 * PARAMS
1175 * AdapterInfo [In/Out]
1177 * RETURNS
1179 * DWORD
1182 DWORD WINAPI IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
1184 /* not a stub, never going to support this (and I never mark an adapter as
1185 DHCP enabled, see GetAdaptersInfo, so this should never get called) */
1186 return ERROR_NOT_SUPPORTED;
1190 /******************************************************************
1191 * NotifyAddrChange (IPHLPAPI.@)
1194 * PARAMS
1196 * Handle [In/Out]
1197 * overlapped [In/Out]
1199 * RETURNS
1201 * DWORD
1204 DWORD WINAPI NotifyAddrChange(PHANDLE Handle, LPOVERLAPPED overlapped)
1206 FIXME(":stub\n");
1207 /* marking Win2K+ functions not supported */
1208 return ERROR_NOT_SUPPORTED;
1212 /******************************************************************
1213 * NotifyRouteChange (IPHLPAPI.@)
1216 * PARAMS
1218 * Handle [In/Out]
1219 * overlapped [In/Out]
1221 * RETURNS
1223 * DWORD
1226 DWORD WINAPI NotifyRouteChange(PHANDLE Handle, LPOVERLAPPED overlapped)
1228 FIXME(":stub\n");
1229 /* marking Win2K+ functions not supported */
1230 return ERROR_NOT_SUPPORTED;
1234 /******************************************************************
1235 * SendARP (IPHLPAPI.@)
1238 * PARAMS
1240 * DestIP [In]
1241 * SrcIP [In]
1242 * pMacAddr [In/Out]
1243 * PhyAddrLen [In/Out]
1245 * RETURNS
1247 * DWORD
1250 DWORD WINAPI SendARP(IPAddr DestIP, IPAddr SrcIP, PULONG pMacAddr, PULONG PhyAddrLen)
1252 FIXME(":stub\n");
1253 /* marking Win2K+ functions not supported */
1254 return ERROR_NOT_SUPPORTED;
1258 /******************************************************************
1259 * SetIfEntry (IPHLPAPI.@)
1262 * PARAMS
1264 * pIfRow [In/Out]
1266 * RETURNS
1268 * DWORD
1271 DWORD WINAPI SetIfEntry(PMIB_IFROW pIfRow)
1273 /* this is supposed to set an administratively interface up or down.
1274 Could do SIOCSIFFLAGS and set/clear IFF_UP, but, not sure I want to, and
1275 this sort of down is indistinguishable from other sorts of down (e.g. no
1276 link). */
1277 FIXME(":stub\n");
1278 return ERROR_NOT_SUPPORTED;
1282 /******************************************************************
1283 * SetIpForwardEntry (IPHLPAPI.@)
1286 * PARAMS
1288 * pRoute [In/Out]
1290 * RETURNS
1292 * DWORD
1295 DWORD WINAPI SetIpForwardEntry(PMIB_IPFORWARDROW pRoute)
1297 /* this is to add a route entry, how's it distinguishable from
1298 CreateIpForwardEntry?
1299 could use SIOCADDRT, not sure I want to */
1300 FIXME(":stub\n");
1301 return (DWORD) 0;
1305 /******************************************************************
1306 * SetIpNetEntry (IPHLPAPI.@)
1309 * PARAMS
1311 * pArpEntry [In/Out]
1313 * RETURNS
1315 * DWORD
1318 DWORD WINAPI SetIpNetEntry(PMIB_IPNETROW pArpEntry)
1320 /* same as CreateIpNetEntry here, could use SIOCSARP, not sure I want to */
1321 FIXME(":stub\n");
1322 return (DWORD) 0;
1326 /******************************************************************
1327 * SetIpStatistics (IPHLPAPI.@)
1330 * PARAMS
1332 * pIpStats [In/Out]
1334 * RETURNS
1336 * DWORD
1339 DWORD WINAPI SetIpStatistics(PMIB_IPSTATS pIpStats)
1341 FIXME(":stub\n");
1342 return (DWORD) 0;
1346 /******************************************************************
1347 * SetIpTTL (IPHLPAPI.@)
1350 * PARAMS
1352 * nTTL [In]
1354 * RETURNS
1356 * DWORD
1359 DWORD WINAPI SetIpTTL(UINT nTTL)
1361 /* could echo nTTL > /proc/net/sys/net/ipv4/ip_default_ttl, not sure I
1362 want to. Could map EACCESS to ERROR_ACCESS_DENIED, I suppose */
1363 FIXME(":stub\n");
1364 return (DWORD) 0;
1368 /******************************************************************
1369 * SetTcpEntry (IPHLPAPI.@)
1372 * PARAMS
1374 * pTcpRow [In/Out]
1376 * RETURNS
1378 * DWORD
1381 DWORD WINAPI SetTcpEntry(PMIB_TCPROW pTcpRow)
1383 FIXME(":stub\n");
1384 return (DWORD) 0;
1388 /******************************************************************
1389 * UnenableRouter (IPHLPAPI.@)
1392 * PARAMS
1394 * pOverlapped [In/Out]
1395 * lpdwEnableCount [In/Out]
1397 * RETURNS
1399 * DWORD
1402 DWORD WINAPI UnenableRouter(OVERLAPPED * pOverlapped, LPDWORD lpdwEnableCount)
1404 FIXME(":stub\n");
1405 /* could echo "0" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
1406 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
1407 marking Win2K+ functions not supported */
1408 return ERROR_NOT_SUPPORTED;