From: Art Yerkes Date: Wed, 25 Feb 2004 07:41:50 +0000 (+0000) Subject: Iphlpapi is now fully merged. Further changes should be synced with wine. X-Git-Tag: backups/videoprt_pnp_14032004@12472~298 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=5c85402724124820625750943cc7cff52eb2fbce Iphlpapi is now fully merged. Further changes should be synced with wine. svn path=/trunk/; revision=8367 --- diff --git a/reactos/lib/iphlpapi/Makefile.in b/reactos/lib/iphlpapi/Makefile.in new file mode 100644 index 00000000000..3e256027c4b --- /dev/null +++ b/reactos/lib/iphlpapi/Makefile.in @@ -0,0 +1,28 @@ +EXTRADEFS = +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +MODULE = iphlpapi.dll +IMPORTS = advapi32 kernel32 +DELAYIMPORTS = +EXTRALIBS = + +C_SRCS = \ + icmp_reactos.c \ + ifenum_reactos.c \ + ipstats_reactos.c \ + iphlpapi_main.c \ + iphlpv6_reactos.c \ + media.c \ + registry.c \ + resinfo_reactos.c \ + route.c + +RC_SRCS = iphlpapi.rc +RC_BINSRC = iphlpapi.rc +RC_BINARIES = + +@MAKE_DLL_RULES@ + +### Dependencies: diff --git a/reactos/lib/iphlpapi/Makefile.ros-template b/reactos/lib/iphlpapi/Makefile.ros-template new file mode 100644 index 00000000000..622389c6314 --- /dev/null +++ b/reactos/lib/iphlpapi/Makefile.ros-template @@ -0,0 +1,21 @@ +# $Id: Makefile.ros-template,v 1.1 2004/02/25 07:41:50 arty Exp $ + +TARGET_NAME = iphlpapi + +TARGET_OBJECTS = @C_SRCS@ + +TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__ + +TARGET_SDKLIBS = @IMPORTS@ libwine.a advapi32.a kernel32.a ws2_32.a wine_uuid.a ntdll.a + +TARGET_BASE = 0x77300000 + +TARGET_RC_SRCS = @RC_SRCS@ +TARGET_RC_BINSRC = @RC_BINSRC@ +TARGET_RC_BINARIES = @RC_BINARIES@ + +default: all + +DEP_OBJECTS = $(TARGET_OBJECTS) + +include $(TOOLS_PATH)/depend.mk diff --git a/reactos/lib/iphlpapi/debug.h b/reactos/lib/iphlpapi/debug.h index 457916728a5..d2492dcf3af 100644 --- a/reactos/lib/iphlpapi/debug.h +++ b/reactos/lib/iphlpapi/debug.h @@ -49,15 +49,6 @@ extern DWORD DebugTraceLevel; #endif /* DBG */ - -#define assert(x) ASSERT(x) -#define assert_irql(x) ASSERT_IRQL(x) - - -#define UNIMPLEMENTED \ - WSH_DbgPrint(MIN_TRACE, ("(%s:%d)(%s) is unimplemented, \ - please try again later.\n", __FILE__, __LINE__, __FUNCTION__)); - #define CHECKPOINT \ WSH_DbgPrint(MIN_TRACE, ("\n")); diff --git a/reactos/lib/iphlpapi/icmp.c b/reactos/lib/iphlpapi/icmp.c index 29fa0f857a0..cd404213c61 100644 --- a/reactos/lib/iphlpapi/icmp.c +++ b/reactos/lib/iphlpapi/icmp.c @@ -1,6 +1,27 @@ -#ifdef HAVE_CONFIG_H +/* + * iphlpapi dll implementation -- Auxiliary icmp functions + * + * These are stubs for functions that provide a simple ICMP probing API. They + * will be operating system specific when implemented. + * + * Copyright (C) 2004 Art Yerkes + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "config.h" -#endif +#include "iphlpapi_private.h" #include #include @@ -18,67 +39,55 @@ # include #endif -#ifdef __REACTOS__ -# include -# include -# include -# include -# include -# include -# include -# include "iphlpapiextra.h" -#else -# include "windef.h" -# include "winbase.h" -# include "winreg.h" -#endif - +#include "windef.h" +#include "winbase.h" +#include "winreg.h" +#include "resinfo.h" #include "iphlpapi.h" -#include "ifenum.h" -#include "ipstats.h" -#include "iphlp_res.h" #include "wine/debug.h" +WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi); + /* * @unimplemented */ DWORD -STDCALL +WINAPI IcmpParseReplies( LPVOID ReplyBuffer, DWORD ReplySize ) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } /* * @unimplemented */ -HANDLE STDCALL IcmpCreateFile( +HANDLE WINAPI IcmpCreateFile( VOID ) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } /* * @unimplemented */ -BOOL STDCALL IcmpCloseHandle( +BOOL WINAPI IcmpCloseHandle( HANDLE IcmpHandle ) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } /* * @unimplemented */ -DWORD STDCALL IcmpSendEcho( +DWORD WINAPI IcmpSendEcho( HANDLE IcmpHandle, IPAddr DestinationAddress, LPVOID RequestData, @@ -89,7 +98,7 @@ DWORD STDCALL IcmpSendEcho( DWORD Timeout ) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } @@ -97,7 +106,7 @@ DWORD STDCALL IcmpSendEcho( * @unimplemented */ DWORD -STDCALL +WINAPI IcmpSendEcho2( HANDLE IcmpHandle, HANDLE Event, @@ -112,6 +121,6 @@ IcmpSendEcho2( DWORD Timeout ) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } diff --git a/reactos/lib/iphlpapi/icmp_reactos.c b/reactos/lib/iphlpapi/icmp_reactos.c new file mode 100644 index 00000000000..8d59ac26cda --- /dev/null +++ b/reactos/lib/iphlpapi/icmp_reactos.c @@ -0,0 +1,127 @@ +/* + * iphlpapi dll implementation -- Auxiliary ICMP functions. + * + * These are stubs for functions that set routing information on the target + * operating system. They are grouped here because their implementation will + * vary widely by operating system. + * + * Copyright (C) 2004 Art Yerkes + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" +#include "iphlpapi_private.h" + +#include +#include +#include +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif +#ifdef HAVE_ARPA_NAMESER_H +# include +#endif +#ifdef HAVE_RESOLV_H +# include +#endif + +#include "windef.h" +#include "winbase.h" +#include "winreg.h" +#include "resinfo.h" +#include "iphlpapi.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi); + +/* + * @unimplemented + */ +DWORD +STDCALL +IcmpParseReplies( + LPVOID ReplyBuffer, + DWORD ReplySize + ) +{ + UNIMPLEMENTED + return 0L; +} + +/* + * @unimplemented + */ +HANDLE STDCALL IcmpCreateFile( + VOID + ) +{ + UNIMPLEMENTED + return 0L; +} + +/* + * @unimplemented + */ +BOOL STDCALL IcmpCloseHandle( + HANDLE IcmpHandle + ) +{ + UNIMPLEMENTED + return 0L; +} + +/* + * @unimplemented + */ +DWORD STDCALL IcmpSendEcho( + HANDLE IcmpHandle, + IPAddr DestinationAddress, + LPVOID RequestData, + WORD RequestSize, + PIP_OPTION_INFORMATION RequestOptions, + LPVOID ReplyBuffer, + DWORD ReplySize, + DWORD Timeout + ) +{ + UNIMPLEMENTED + return 0L; +} + +/* + * @unimplemented + */ +DWORD +STDCALL +IcmpSendEcho2( + HANDLE IcmpHandle, + HANDLE Event, + FARPROC ApcRoutine, + PVOID ApcContext, + IPAddr DestinationAddress, + LPVOID RequestData, + WORD RequestSize, + PIP_OPTION_INFORMATION RequestOptions, + LPVOID ReplyBuffer, + DWORD ReplySize, + DWORD Timeout + ) +{ + UNIMPLEMENTED + return 0L; +} diff --git a/reactos/lib/iphlpapi/ifenum.h b/reactos/lib/iphlpapi/ifenum.h index 406fa0f5ada..e37d4451c59 100644 --- a/reactos/lib/iphlpapi/ifenum.h +++ b/reactos/lib/iphlpapi/ifenum.h @@ -139,4 +139,7 @@ DWORD getInterfaceEntryByIndex(DWORD index, PMIB_IFROW entry); */ char *toIPAddressString(unsigned int addr, char string[16]); +/* Inserts a route into the route table. */ +DWORD createIpForwardEntryOS(PMIB_IPFORWARDROW pRoute); + #endif /* ndef WINE_IFENUM_H_ */ diff --git a/reactos/lib/iphlpapi/ifenum_reactos.c b/reactos/lib/iphlpapi/ifenum_reactos.c index 9956b5e585e..d58c0ebc905 100644 --- a/reactos/lib/iphlpapi/ifenum_reactos.c +++ b/reactos/lib/iphlpapi/ifenum_reactos.c @@ -37,7 +37,7 @@ * functions into iphlpv6.c (arty) */ -#include "ipprivate.h" +#include "iphlpapi_private.h" #include "ifenum.h" /* Globals */ @@ -45,6 +45,10 @@ const PWCHAR TcpFileName = L"\\Device\\Tcp"; /* Functions */ +/* I'm a bit skittish about maintaining this info in memory, as I'd rather + * not add any mutex or critical section blockers to these functions. I've + * encountered far too many windows functions that contribute to deadlock + * by not announcing themselves. */ void interfaceMapInit(void) { /* For now, nothing */ @@ -212,19 +216,18 @@ VOID tdiFreeThingSet( PVOID things ) { } NTSTATUS tdiGetMibForIfEntity -( HANDLE tcpFile, DWORD entityId, IFEntrySafelySized *entry ) { +( HANDLE tcpFile, TDIEntityID *ent, IFEntrySafelySized *entry ) { TCP_REQUEST_QUERY_INFORMATION_EX req = TCP_REQUEST_QUERY_INFORMATION_INIT; NTSTATUS status = STATUS_SUCCESS; DWORD returnSize; DPRINT("TdiGetMibForIfEntity(tcpFile %x,entityId %x)\n", - (int)tcpFile, (int)entityId); + (int)tcpFile, (int)ent->tei_instance); req.ID.toi_class = INFO_CLASS_PROTOCOL; req.ID.toi_type = INFO_TYPE_PROVIDER; req.ID.toi_id = IF_MIB_STATS_ID; - req.ID.toi_entity.tei_entity = IF_ENTITY; - req.ID.toi_entity.tei_instance = entityId; + req.ID.toi_entity = *ent; status = DeviceIoControl( tcpFile, IOCTL_TCP_QUERY_INFORMATION_EX, @@ -245,23 +248,22 @@ NTSTATUS tdiGetMibForIfEntity " if_type ........................ %x\n" " if_mtu ......................... %d\n" " if_speed ....................... %x\n" - " if_physaddrlen ................. %d\n" - " if_physaddr .................... %02x:%02x:%02x:%02x:%02x:%02x\n", - " if_descr ....................... %s\n" - "} status %08x\n", - (int)entry->offset.ent.if_index, - (int)entry->offset.ent.if_type, - (int)entry->offset.ent.if_mtu, - (int)entry->offset.ent.if_speed, - (int)entry->offset.ent.if_physaddrlen, - entry->offset.ent.if_physaddr[0] & 0xff, - entry->offset.ent.if_physaddr[1] & 0xff, - entry->offset.ent.if_physaddr[2] & 0xff, - entry->offset.ent.if_physaddr[3] & 0xff, - entry->offset.ent.if_physaddr[4] & 0xff, - entry->offset.ent.if_physaddr[5] & 0xff, - entry->offset.ent.if_descr, - (int)status); + " if_physaddrlen ................. %d\n", + entry->ent.if_index, + entry->ent.if_type, + entry->ent.if_mtu, + entry->ent.if_speed, + entry->ent.if_physaddrlen); + DPRINT(" if_physaddr .................... %02x:%02x:%02x:%02x:%02x:%02x\n", + " if_descr ....................... %s\n", + entry->ent.if_physaddr[0] & 0xff, + entry->ent.if_physaddr[1] & 0xff, + entry->ent.if_physaddr[2] & 0xff, + entry->ent.if_physaddr[3] & 0xff, + entry->ent.if_physaddr[4] & 0xff, + entry->ent.if_physaddr[5] & 0xff, + entry->ent.if_descr); + DPRINT("} status %08x\n",status); return status; } @@ -301,11 +303,11 @@ static BOOL isLoopback( HANDLE tcpFile, TDIEntityID *loop_maybe ) { IFEntrySafelySized entryInfo; tdiGetMibForIfEntity( tcpFile, - loop_maybe->tei_instance, + loop_maybe, &entryInfo ); - return !entryInfo.offset.ent.if_type || - entryInfo.offset.ent.if_type == IFENT_SOFTWARE_LOOPBACK; + return !entryInfo.ent.if_type || + entryInfo.ent.if_type == IFENT_SOFTWARE_LOOPBACK; } NTSTATUS tdiGetEntityType( HANDLE tcpFile, TDIEntityID *ent, PULONG type ) { @@ -336,6 +338,63 @@ NTSTATUS tdiGetEntityType( HANDLE tcpFile, TDIEntityID *ent, PULONG type ) { return status; } +static NTSTATUS getInterfaceInfoSet( HANDLE tcpFile, + IFInfo **infoSet, + PDWORD numInterfaces ) { + DWORD numEntities; + TDIEntityID *entIDSet = 0; + NTSTATUS status = tdiGetEntityIDSet( tcpFile, &entIDSet, &numEntities ); + IFInfo *infoSetInt = 0; + BOOL interfaceInfoComplete; + int curInterf = 0, i; + + if( NT_SUCCESS(status) ) + infoSetInt = HeapAlloc( GetProcessHeap(), 0, + sizeof(IFInfo) * numEntities ); + + if( infoSetInt ) { + for( i = 0; i < numEntities; i++ ) { + if( isInterface( &entIDSet[i] ) ) { + status = tdiGetMibForIfEntity + ( tcpFile, + &entIDSet[i], + &infoSetInt[curInterf].if_info ); + if( NT_SUCCESS(status) ) { + DWORD numAddrs; + IPAddrEntry *addrs; + TDIEntityID ip_ent; + int j,k; + + interfaceInfoComplete = FALSE; + for( j = 0; NT_SUCCESS(status); j++ ) { + status = getNthIpEntity( tcpFile, j, &ip_ent ); + if( NT_SUCCESS(status) ) + status = tdiGetIpAddrsForIpEntity + ( tcpFile, &ip_ent, &addrs, &numAddrs ); + for( k = 0; k < numAddrs && NT_SUCCESS(status); k++ ) { + if( addrs[k].iae_index == + infoSetInt[curInterf].if_info.ent.if_index ) { + memcpy( &infoSetInt[curInterf].ip_addr, + &addrs[k], + sizeof( addrs[k] ) ); + interfaceInfoComplete = TRUE; + break; + } + } + if( interfaceInfoComplete ) break; + } + } + if( NT_SUCCESS(status) ) curInterf++; + } + } + } + + *infoSet = infoSetInt; + *numInterfaces = curInterf; + + return STATUS_SUCCESS; +} + static DWORD getNumInterfacesInt(BOOL onlyLoopback) { DWORD numEntities, numInterfaces = 0; @@ -413,48 +472,70 @@ DWORD getNthInterfaceEntity( HANDLE tcpFile, DWORD index, TDIEntityID *ent ) { return STATUS_UNSUCCESSFUL; } } + +NTSTATUS getInterfaceInfoByIndex( HANDLE tcpFile, DWORD index, IFInfo *info ) { + IFInfo *ifInfo; + DWORD numInterfaces; + NTSTATUS status = getInterfaceInfoSet( tcpFile, &ifInfo, &numInterfaces ); + int i; + + if( NT_SUCCESS(status) ) + for( i = 0; i < numInterfaces; i++ ) { + if( ifInfo[i].if_info.ent.if_index == index ) { + memcpy( info, &ifInfo[i], sizeof(*info) ); + break; + } + } + + if( NT_SUCCESS(status) ) + return i < numInterfaces ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL; + else + return status; +} + +NTSTATUS getInterfaceInfoByName( HANDLE tcpFile, char *name, IFInfo *info ) { + IFInfo *ifInfo; + DWORD numInterfaces; + int i; + NTSTATUS status = getInterfaceInfoSet( tcpFile, &ifInfo, &numInterfaces ); + + if( NT_SUCCESS(status) ) + for( i = 0; i < numInterfaces; i++ ) { + if( !strcmp(ifInfo[i].if_info.ent.if_descr, name) ) { + memcpy( info, &ifInfo[i], sizeof(*info) ); + break; + } + } + + if( NT_SUCCESS(status) ) + return i < numInterfaces ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL; + else + return status; +} /* Note that the result of this operation must be freed later */ const char *getInterfaceNameByIndex(DWORD index) { - TDIEntityID ent; - IFEntrySafelySized entityInfo; - HANDLE tcpFile = INVALID_HANDLE_VALUE; - NTSTATUS status = STATUS_SUCCESS; - PCHAR interfaceName = 0; - char simple_name_buf[100]; - char *adapter_name; - - status = openTcpFile( &tcpFile ); - if( !NT_SUCCESS(status) ) { - DPRINT("failed %08x\n", status ); - return 0; - } - - status = getNthInterfaceEntity( tcpFile, index, &ent ); - - if( !NT_SUCCESS(status) ) { - DPRINT("failed %08x\n", status ); - return 0; - } + IFInfo ifInfo; + HANDLE tcpFile; + char *interfaceName = 0, *adapter_name = 0; + NTSTATUS status = openTcpFile( &tcpFile ); - status = tdiGetMibForIfEntity( tcpFile, - ent.tei_instance, - &entityInfo ); if( NT_SUCCESS(status) ) { - adapter_name = entityInfo.offset.ent.if_descr; - } else { - sprintf( simple_name_buf, "eth%x", - (int)ent.tei_instance ); - adapter_name = simple_name_buf; + status = getInterfaceInfoByIndex( tcpFile, index, &ifInfo ); + + if( NT_SUCCESS(status) ) { + adapter_name = ifInfo.if_info.ent.if_descr; + + interfaceName = HeapAlloc( GetProcessHeap(), 0, + strlen(adapter_name) + 1 ); + strcpy( interfaceName, adapter_name ); + + closeTcpFile( tcpFile ); + } } - interfaceName = HeapAlloc( GetProcessHeap(), 0, - strlen(adapter_name) + 1 ); - strcpy( interfaceName, adapter_name ); - closeTcpFile( tcpFile ); - return interfaceName; } @@ -464,63 +545,58 @@ void consumeInterfaceName(const char *name) { DWORD getInterfaceIndexByName(const char *name, PDWORD index) { - DWORD ret = STATUS_SUCCESS; - int numInterfaces = getNumInterfaces(); - const char *iname = 0; - int i; + IFInfo ifInfo; HANDLE tcpFile; + NTSTATUS status = openTcpFile( &tcpFile ); - ret = openTcpFile( &tcpFile ); - - if( !NT_SUCCESS(ret) ) { - DPRINT("Failure: %08x\n", ret); - return ret; - } - - for( i = 0; i < numInterfaces; i++ ) { - iname = getInterfaceNameByIndex( i ); - if( !strcmp(iname, name) ) { - *index = i; + if( NT_SUCCESS(status) ) { + status = getInterfaceInfoByName( tcpFile, (char *)name, &ifInfo ); + + if( NT_SUCCESS(status) ) { + *index = ifInfo.if_info.ent.if_index; + closeTcpFile( tcpFile ); } - HeapFree( GetProcessHeap(), 0, (char *)iname ); } - closeTcpFile( tcpFile ); - - return ret; + return status; } InterfaceIndexTable *getInterfaceIndexTableInt( BOOL nonLoopbackOnly ) { - HANDLE tcpFile; DWORD numInterfaces, curInterface = 0; int i; - InterfaceIndexTable *ret; - TDIEntityID *entitySet; - DWORD numEntities; - NTSTATUS status; - - numInterfaces = getNumInterfaces(); - TRACE("getInterfaceIndexTable: numInterfaces: %d\n", numInterfaces); - ret = (InterfaceIndexTable *)calloc(1, - sizeof(InterfaceIndexTable) + (numInterfaces - 1) * sizeof(DWORD)); - if (ret) { - ret->numAllocated = numInterfaces; - } - - status = openTcpFile( &tcpFile ); - tdiGetEntityIDSet( tcpFile, &entitySet, &numEntities ); - - for( i = 0; i < numEntities; i++ ) { - if( isInterface( &entitySet[i] ) && - (!nonLoopbackOnly || !isLoopback( tcpFile, &entitySet[i] )) ) { - ret->indexes[curInterface++] = entitySet[i].tei_instance; + IFInfo *ifInfo; + InterfaceIndexTable *ret = 0; + HANDLE tcpFile; + NTSTATUS status = openTcpFile( &tcpFile ); + + if( NT_SUCCESS(status) ) { + status = getInterfaceInfoSet( tcpFile, &ifInfo, &numInterfaces ); + + if( NT_SUCCESS(status) ) { + ret = (InterfaceIndexTable *) + calloc(1, + sizeof(InterfaceIndexTable) + + (numInterfaces - 1) * sizeof(DWORD)); + + if (ret) { + ret->numAllocated = numInterfaces; + + for( i = 0; i < numInterfaces; i++ ) { + if( !nonLoopbackOnly || + !isLoopback( tcpFile, &ifInfo[i].entity_id ) ) { + ret->indexes[curInterface++] = + ifInfo[i].if_info.ent.if_index; + } + } + + ret->numIndexes = curInterface; + } + + tdiFreeThingSet( ifInfo ); } + closeTcpFile( tcpFile ); } - - tdiFreeThingSet( entitySet ); - closeTcpFile( tcpFile ); - ret->numIndexes = curInterface; - + return ret; } @@ -537,175 +613,167 @@ DWORD getInterfaceIPAddrByName(const char *name) return INADDR_ANY; } -DWORD getInterfaceIPAddrByIndex(DWORD index) -{ - return INADDR_ANY; +NTSTATUS getIPAddrEntryForIf(HANDLE tcpFile, + char *name, + DWORD index, + IFInfo *ifInfo) { + NTSTATUS status = + name ? + getInterfaceInfoByName( tcpFile, name, ifInfo ) : + getInterfaceInfoByIndex( tcpFile, index, ifInfo ); + return status; } -DWORD getInterfaceBCastAddrByName(const char *name) -{ - return INADDR_ANY; +DWORD getAddrByIndexOrName( char *name, DWORD index, IPHLPAddrType addrType ) { + IFInfo ifInfo; + HANDLE tcpFile = INVALID_HANDLE_VALUE; + NTSTATUS status = STATUS_SUCCESS; + DWORD addrOut = INADDR_ANY; + + status = openTcpFile( &tcpFile ); + + if( NT_SUCCESS(status) ) { + status = getIPAddrEntryForIf( tcpFile, name, index, &ifInfo ); + if( NT_SUCCESS(status) ) { + switch( addrType ) { + case IPAAddr: addrOut = ifInfo.ip_addr.iae_addr; break; + case IPABcast: addrOut = ifInfo.ip_addr.iae_bcastaddr; break; + case IPAMask: addrOut = ifInfo.ip_addr.iae_mask; break; + case IFMtu: addrOut = ifInfo.if_info.ent.if_mtu; break; + case IFStatus: addrOut = ifInfo.if_info.ent.if_operstatus; break; + } + } + closeTcpFile( &tcpFile ); + } + + return addrOut; +} + +DWORD getInterfaceIPAddrByIndex(DWORD index) { + return getAddrByIndexOrName( 0, index, IPAAddr ); } -DWORD getInterfaceBCastAddrByIndex(DWORD index) -{ - return INADDR_ANY; +DWORD getInterfaceBCastAddrByName(const char *name) { + return getAddrByIndexOrName( (char *)name, 0, IPABcast ); } -DWORD getInterfaceMaskByName(const char *name) -{ - DWORD ret = INADDR_NONE; - return ret; +DWORD getInterfaceBCastAddrByIndex(DWORD index) { + return getAddrByIndexOrName( 0, index, IPABcast ); } -DWORD getInterfaceMaskByIndex(DWORD index) -{ - DWORD ret = INADDR_NONE; - return ret; +DWORD getInterfaceMaskByName(const char *name) { + return getAddrByIndexOrName( (char *)name, 0, IPAMask ); +} + +DWORD getInterfaceMaskByIndex(DWORD index) { + return getAddrByIndexOrName( 0, index, IPAMask ); +} + +void getInterfacePhysicalFromInfo( IFInfo *info, + PDWORD len, PBYTE addr, PDWORD type ) { + *len = info->if_info.ent.if_physaddrlen; + memcpy( addr, info->if_info.ent.if_physaddr, *len ); + *type = info->if_info.ent.if_type; } DWORD getInterfacePhysicalByName(const char *name, PDWORD len, PBYTE addr, - PDWORD type) + PDWORD type) { - DWORD ret; - DWORD addrLen; - - if (!name || !len || !addr || !type) - return ERROR_INVALID_PARAMETER; + HANDLE tcpFile; + IFInfo info; + NTSTATUS status = openTcpFile( &tcpFile ); - if (addrLen > *len) { - ret = ERROR_INSUFFICIENT_BUFFER; - *len = addrLen; - } - else { - /* zero out remaining bytes for broken implementations */ - memset(addr + addrLen, 0, *len - addrLen); - *len = addrLen; - ret = NO_ERROR; - } + if( NT_SUCCESS(status) ) { + status = getInterfaceInfoByName( tcpFile, (char *)name, &info ); + if( NT_SUCCESS(status) ) + getInterfacePhysicalFromInfo( &info, len, addr, type ); + closeTcpFile( tcpFile ); + } - ret = ERROR_NO_MORE_FILES; - return ret; + return status; } DWORD getInterfacePhysicalByIndex(DWORD index, PDWORD len, PBYTE addr, PDWORD type) { - const char *name = getInterfaceNameByIndex(index); + HANDLE tcpFile; + IFInfo info; + NTSTATUS status = openTcpFile( &tcpFile ); - if (name) - return getInterfacePhysicalByName(name, len, addr, type); - else - return ERROR_INVALID_DATA; -} + if( NT_SUCCESS(status) ) { + status = getInterfaceInfoByIndex( tcpFile, index, &info ); + if( NT_SUCCESS(status) ) + getInterfacePhysicalFromInfo( &info, len, addr, type ); + closeTcpFile( tcpFile ); + } -DWORD getInterfaceMtuByName(const char *name, PDWORD mtu) -{ - *mtu = 0; - return ERROR_SUCCESS; + return status; } -DWORD getInterfaceMtuByIndex(DWORD index, PDWORD mtu) -{ - const char *name = getInterfaceNameByIndex(index); - - if (name) - return getInterfaceMtuByName(name, mtu); - else - return ERROR_INVALID_DATA; +DWORD getInterfaceMtuByName(const char *name, PDWORD mtu) { + *mtu = getAddrByIndexOrName( (char *)name, 0, IFMtu ); + return STATUS_SUCCESS; } -DWORD getInterfaceStatusByName(const char *name, PDWORD status) -{ - DWORD ret; - - if (!name) - return ERROR_INVALID_PARAMETER; - if (!status) - return ERROR_INVALID_PARAMETER; +DWORD getInterfaceMtuByIndex(DWORD index, PDWORD mtu) { + *mtu = getAddrByIndexOrName( 0, index, IFMtu ); + return STATUS_SUCCESS; +} - ret = ERROR_NO_MORE_FILES; - return ret; +DWORD getInterfaceStatusByName(const char *name, PDWORD status) { + *status = getAddrByIndexOrName( (char *)name, 0, IFStatus ); + return STATUS_SUCCESS; } DWORD getInterfaceStatusByIndex(DWORD index, PDWORD status) { - const char *name = getInterfaceNameByIndex(index); - - if (name) - return getInterfaceStatusByName(name, status); - else - return ERROR_INVALID_DATA; + *status = getAddrByIndexOrName( 0, index, IFStatus ); + return STATUS_SUCCESS; } DWORD getInterfaceEntryByName(const char *name, PMIB_IFROW entry) { - BYTE addr[MAX_INTERFACE_PHYSADDR]; - DWORD ret, len = sizeof(addr), type; - - if (!name) - return ERROR_INVALID_PARAMETER; - if (!entry) - return ERROR_INVALID_PARAMETER; - - if (getInterfacePhysicalByName(name, &len, addr, &type) == NO_ERROR) { - WCHAR *assigner; - const char *walker; - - memset(entry, 0, sizeof(MIB_IFROW)); - for (assigner = entry->wszName, walker = name; *walker; - walker++, assigner++) - *assigner = *walker; - *assigner = 0; - getInterfaceIndexByName(name, &entry->dwIndex); - entry->dwPhysAddrLen = len; - memcpy(entry->bPhysAddr, addr, len); - memset(entry->bPhysAddr + len, 0, sizeof(entry->bPhysAddr) - len); - entry->dwType = type; - /* FIXME: how to calculate real speed? */ - getInterfaceMtuByName(name, &entry->dwMtu); - /* lie, there's no "administratively down" here */ - entry->dwAdminStatus = MIB_IF_ADMIN_STATUS_UP; - getInterfaceStatusByName(name, &entry->dwOperStatus); - /* punt on dwLastChange? */ - entry->dwDescrLen = min(strlen(name), MAX_INTERFACE_DESCRIPTION - 1); - memcpy(entry->bDescr, name, entry->dwDescrLen); - entry->bDescr[entry->dwDescrLen] = '\0'; - entry->dwDescrLen++; - ret = NO_ERROR; - } - else - ret = ERROR_INVALID_DATA; - return ret; + HANDLE tcpFile; + IFInfo info; + NTSTATUS status = openTcpFile( &tcpFile ); + + DPRINT("Called.\n"); + + if( NT_SUCCESS(status) ) { + status = getInterfaceInfoByName( tcpFile, (char *)name, &info ); + + if( NT_SUCCESS(status) ) { + memcpy( &entry->wszName[MAX_INTERFACE_NAME_LEN], + &info.if_info, + sizeof(info.if_info) ); + } + + closeTcpFile( tcpFile ); + } + + return status; } DWORD getInterfaceEntryByIndex(DWORD index, PMIB_IFROW entry) { HANDLE tcpFile; + IFInfo info; NTSTATUS status = openTcpFile( &tcpFile ); - TDIEntityID entity; DPRINT("Called.\n"); - if( !NT_SUCCESS(status) ) { - DPRINT("Failed: %08x\n", status); - return status; - } - - status = getNthInterfaceEntity( tcpFile, index, &entity ); - - if( !NT_SUCCESS(status) ) { - DPRINT("Failed: %08x\n", status); + if( NT_SUCCESS(status) ) { + status = getInterfaceInfoByIndex( tcpFile, index, &info ); + + if( NT_SUCCESS(status) ) { + memcpy( &entry->wszName[MAX_INTERFACE_NAME_LEN], + &info.if_info, + sizeof(info.if_info) ); + } + closeTcpFile( tcpFile ); - return status; } - status = tdiGetMibForIfEntity( tcpFile, - entity.tei_instance, - (IFEntrySafelySized *) - &entry->wszName[MAX_INTERFACE_NAME_LEN] ); - - closeTcpFile( tcpFile ); return status; } @@ -721,3 +789,48 @@ char *toIPAddressString(unsigned int addr, char string[16]) } return string; } + +DWORD createIpForwardEntryOS( PMIB_IPFORWARDROW pRoute ) { + HANDLE tcpFile = INVALID_HANDLE_VALUE; + NTSTATUS status = openTcpFile( &tcpFile ); + TCP_REQUEST_SET_INFORMATION_EX_SAFELY_SIZED req = + TCP_REQUEST_SET_INFORMATION_INIT; + IPRouteEntry *rte; + TDIEntityID id; + DWORD returnSize = 0; + + DPRINT("Called.\n"); + + if( NT_SUCCESS(status) ) + status = getNthIpEntity( tcpFile, 0, &id ); + + if( NT_SUCCESS(status) ) { + req.Req.ID.toi_class = INFO_CLASS_PROTOCOL; + req.Req.ID.toi_type = INFO_TYPE_PROVIDER; + req.Req.ID.toi_id = IP_MIB_ROUTETABLE_ENTRY_ID; + req.Req.ID.toi_entity = id; + req.Req.BufferSize = sizeof(*rte); + rte = + (IPRouteEntry *)&req.Req.Buffer[0]; + + rte->ire_dest = pRoute->dwForwardDest; + rte->ire_index = pRoute->dwForwardIfIndex; + rte->ire_metric = pRoute->dwForwardMetric1; + rte->ire_gw = pRoute->dwForwardNextHopAS; + rte->ire_mask = pRoute->dwForwardMask; + + status = DeviceIoControl( tcpFile, + IOCTL_TCP_SET_INFORMATION_EX, + &req, + sizeof(req), + NULL, + 0, + &returnSize, + NULL ); + } + + if( tcpFile != INVALID_HANDLE_VALUE ) + closeTcpFile( tcpFile ); + + return status; +} diff --git a/reactos/lib/iphlpapi/iphlp_res.h b/reactos/lib/iphlpapi/iphlp_res.h deleted file mode 100644 index 81d41b27de7..00000000000 --- a/reactos/lib/iphlpapi/iphlp_res.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _IPHLP_RES_H -#define _IPHLP_RES_H - -typedef struct _IPHLP_RES_INFO { - DWORD riCount; - LPSOCKADDR riAddressList; -} IPHLP_RES_INFO, *PIPHLP_RES_INFO; - -PIPHLP_RES_INFO getResInfo(); -VOID disposeResInfo( PIPHLP_RES_INFO InfoPtr ); - -#endif/*_IPHLP_RES_H*/ diff --git a/reactos/lib/iphlpapi/iphlpapi.c b/reactos/lib/iphlpapi/iphlpapi.c deleted file mode 100644 index d5ee736cb62..00000000000 --- a/reactos/lib/iphlpapi/iphlpapi.c +++ /dev/null @@ -1,1295 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Winsock 2 IP Helper API DLL - * FILE: iphlpapi.c - * PURPOSE: DLL entry - * PROGRAMMERS: Robert Dickenson (robd@reactos.org) - * REVISIONS: - * RDD August 18, 2002 Created - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "ipprivate.h" -#include "ipregprivate.h" -#include "debug.h" -//#include "trace.h" - -#ifdef __GNUC__ -#define EXPORT STDCALL -#else -#define EXPORT CALLBACK -#endif - -#ifdef DBG - -/* See debug.h for debug/trace constants */ -DWORD DebugTraceLevel = MAX_TRACE; - -#endif /* DBG */ - -/* To make the linker happy */ -//VOID STDCALL KeBugCheck (ULONG BugCheckCode) {} - - -BOOL -EXPORT -DllMain(HANDLE hInstDll, - ULONG dwReason, - PVOID Reserved) -{ - //WSH_DbgPrint(MIN_TRACE, ("DllMain of iphlpapi.dll\n")); - - switch (dwReason) { - case DLL_PROCESS_ATTACH: - /* Don't need thread attach notifications - so disable them to improve performance */ - DisableThreadLibraryCalls(hInstDll); - break; - - case DLL_THREAD_ATTACH: - break; - - case DLL_THREAD_DETACH: - break; - - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - - -/* - * @unimplemented - */ -DWORD -STDCALL -AddIPAddress(IPAddr Address, IPMask IpMask, DWORD IfIndex, PULONG NTEContext, PULONG NTEInstance) -{ - UNIMPLEMENTED - return 0L; -} - - -/* - * @unimplemented - */ -DWORD -STDCALL -SetIpNetEntry(PMIB_IPNETROW pArpEntry) -{ - UNIMPLEMENTED - return 0L; -} - - -/* - * @unimplemented - */ -DWORD -STDCALL -CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute) -{ - UNIMPLEMENTED - return 0L; -} - - -/* - * @unimplemented - */ -DWORD -STDCALL -GetAdapterIndex(LPWSTR AdapterName, PULONG IfIndex) -{ - return 0; -} - - -/* - * @unimplemented - */ -DWORD -STDCALL -GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen) -{ - LONG lErr; - DWORD dwSize; - DWORD dwIndex; - BYTE* pNextMemFree = (BYTE*) pAdapterInfo; - ULONG uUsedMemory = 0; - PIP_ADAPTER_INFO pPrevAdapter = NULL; - PIP_ADAPTER_INFO pCurrentAdapter = NULL; - HKEY hAdapters; - HKEY hAdapter; - HKEY hIpConfig; - wchar_t* strAdapter; - wchar_t* strTemp1; - wchar_t* strTemp2; - DWORD dwAdapterLen; - char strTemp[MAX_ADAPTER_NAME_LENGTH + 4]; - - if(pAdapterInfo == NULL && pOutBufLen == NULL) - return ERROR_INVALID_PARAMETER; - ZeroMemory(pAdapterInfo, *pOutBufLen); - - lErr = RegOpenKeyExW(HKEY_LOCAL_MACHINE, - L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Adapters", 0, KEY_READ, &hAdapters); - if(lErr != ERROR_SUCCESS) - return lErr; - - // Determine the size of the largest name of any adapter and the number of adapters. - lErr = RegQueryInfoKeyW(hAdapters, NULL, NULL, NULL, NULL, &dwAdapterLen, NULL, NULL, NULL, NULL, NULL, NULL); - if(lErr != ERROR_SUCCESS) - { - RegCloseKey(hAdapters); - return lErr; - } - dwAdapterLen++; // RegQueryInfoKeyW return value does not include terminating null. - - strAdapter = (wchar_t*) malloc(dwAdapterLen * sizeof(wchar_t)); - - // Enumerate all adapters in SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Adapters. - for(dwIndex = 0; ; dwIndex++) - { - dwSize = dwAdapterLen; // Reset size of the strAdapterLen buffer. - lErr = RegEnumKeyExW(hAdapters, dwIndex, strAdapter, &dwSize, NULL, NULL, NULL, NULL); - if(lErr == ERROR_NO_MORE_ITEMS) - break; - - // TODO Skip NdisWanIP??? - if(wcsstr(strAdapter, L"NdisWanIp") != 0) - continue; - - lErr = RegOpenKeyExW(hAdapters, strAdapter, 0, KEY_READ, &hAdapter); - if(lErr != ERROR_SUCCESS) - continue; - - // Read the IpConfig value. - lErr = RegQueryValueExW(hAdapter, L"IpConfig", NULL, NULL, NULL, &dwSize); - if(lErr != ERROR_SUCCESS) - continue; - - strTemp1 = (wchar_t*) malloc(dwSize); - strTemp2 = (wchar_t*) malloc(dwSize + 35 * sizeof(wchar_t)); - lErr = RegQueryValueExW(hAdapter, L"IpConfig", NULL, NULL, (BYTE*) strTemp1, &dwSize); - if(lErr != ERROR_SUCCESS) - { - free(strTemp1); - free(strTemp2); - continue; - } - swprintf(strTemp2, L"SYSTEM\\CurrentControlSet\\Services\\%s", strTemp1); - - // Open the IpConfig key. - lErr = RegOpenKeyExW(HKEY_LOCAL_MACHINE, strTemp2, 0, KEY_READ, &hIpConfig); - if(lErr != ERROR_SUCCESS) - { - free(strTemp1); - free(strTemp2); - continue; - } - free((void*) strTemp1); - free((void*) strTemp2); - - - // Fill IP_ADAPTER_INFO block. - pCurrentAdapter = (IP_ADAPTER_INFO*) pNextMemFree; - pNextMemFree += sizeof(IP_ADAPTER_INFO); - uUsedMemory += sizeof(IP_ADAPTER_INFO); - if(uUsedMemory > *pOutBufLen) - return ERROR_BUFFER_OVERFLOW; // TODO return the needed size - - // struct _IP_ADAPTER_INFO* Next - if(pPrevAdapter != NULL) - pPrevAdapter->Next = pCurrentAdapter; - // TODO DWORD ComboIndex - // char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4] - wcstombs(strTemp, strAdapter, MAX_ADAPTER_NAME_LENGTH + 4); - strcpy(pCurrentAdapter->AdapterName, strTemp); - // TODO char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4] - // TODO UINT AddressLength - // TODO BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH] - // TODO DWORD Index - // TODO UINT Type - // TODO UINT DhcpEnabled - // TODO PIP_ADDR_STRING CurrentIpAddress - // IP_ADDR_STRING IpAddressList - dwSize = 16; lErr = RegQueryValueExW(hIpConfig, L"IPAddress", NULL, NULL, (BYTE*) &pCurrentAdapter->IpAddressList.IpAddress, &dwSize); - dwSize = 16; lErr = RegQueryValueExW(hIpConfig, L"SubnetMask", NULL, NULL, (BYTE*) &pCurrentAdapter->IpAddressList.IpMask, &dwSize); - if(strstr(pCurrentAdapter->IpAddressList.IpAddress.String, "0.0.0.0") != 0) - { - dwSize = 16; lErr = RegQueryValueExW(hIpConfig, L"DhcpIPAddress", NULL, NULL, (BYTE*) &pCurrentAdapter->IpAddressList.IpAddress, &dwSize); - dwSize = 16; lErr = RegQueryValueExW(hIpConfig, L"DhcpSubnetMask", NULL, NULL, (BYTE*) &pCurrentAdapter->IpAddressList.IpMask, &dwSize); - } - // TODO IP_ADDR_STRING GatewayList - // IP_ADDR_STRING DhcpServer - dwSize = 16; lErr = RegQueryValueExW(hIpConfig, L"DhcpServer", NULL, NULL, (BYTE*) &pCurrentAdapter->DhcpServer.IpAddress, &dwSize); - dwSize = 16; lErr = RegQueryValueExW(hIpConfig, L"DhcpSubnetMask", NULL, NULL, (BYTE*) &pCurrentAdapter->DhcpServer.IpMask, &dwSize); - // TODO BOOL HaveWins - // TODO IP_ADDR_STRING PrimaryWinsServer - // TODO IP_ADDR_STRING SecondaryWinsServer - // TODO time_t LeaseObtained - // TODO time_t LeaseExpires - - pPrevAdapter = pCurrentAdapter; - RegCloseKey(hAdapter); - RegCloseKey(hIpConfig); - } - - // Cleanup - free(strAdapter); - RegCloseKey(hAdapters); - - return ERROR_SUCCESS; -} - - -//////////////////////////////////////////////////////////////////////////////// - -/* - * @implemented - */ -DWORD -STDCALL -GetNumberOfInterfaces(OUT PDWORD pdwNumIf) -{ - DWORD result = NO_ERROR; - HKEY hKey; - LONG errCode; - int i = 0; - - if (pdwNumIf == NULL) return ERROR_INVALID_PARAMETER; - *pdwNumIf = 0; - errCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Linkage", 0, KEY_READ, &hKey); - if (errCode == ERROR_SUCCESS) { - DWORD dwSize; - errCode = RegQueryValueExW(hKey, L"Bind", NULL, NULL, NULL, &dwSize); - if (errCode == ERROR_SUCCESS) { - wchar_t* pData = (wchar_t*)malloc(dwSize * sizeof(wchar_t)); - errCode = RegQueryValueExW(hKey, L"Bind", NULL, NULL, (LPBYTE)pData, &dwSize); - if (errCode == ERROR_SUCCESS) { - wchar_t* pStr = pData; - for (i = 0; *pStr != L'\0'; i++) { - pStr = pStr + wcslen(pStr) + 1; // next string - } - } - free(pData); - } - RegCloseKey(hKey); - *pdwNumIf = i; - } else { - result = errCode; - } - return result; -} - - -/* - * @implemented - */ -DWORD -STDCALL -GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG pOutBufLen) -{ - DWORD result = ERROR_SUCCESS; - DWORD dwSize; - DWORD dwOutBufLen; - DWORD dwNumIf; - HKEY hKey; - LONG errCode; - int i = 0; - - if ((errCode = GetNumberOfInterfaces(&dwNumIf)) != NO_ERROR) { - _tprintf(_T("GetInterfaceInfo() failed with code 0x%08X - Use FormatMessage to obtain the message string for the returned error\n"), (int)errCode); - return errCode; - } - if (dwNumIf == 0) return ERROR_NO_DATA; // No adapter information exists for the local computer - if (pOutBufLen == NULL) return ERROR_INVALID_PARAMETER; - dwOutBufLen = sizeof(IP_INTERFACE_INFO) + dwNumIf * sizeof(IP_ADAPTER_INDEX_MAP); - if (*pOutBufLen < dwOutBufLen || pIfTable == NULL) { - *pOutBufLen = dwOutBufLen; - return ERROR_INSUFFICIENT_BUFFER; - } - memset(pIfTable, 0, dwOutBufLen); - pIfTable->NumAdapters = dwNumIf - 1; - errCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Linkage", 0, KEY_READ, &hKey); - if (errCode == ERROR_SUCCESS) { - errCode = RegQueryValueExW(hKey, L"Bind", NULL, NULL, NULL, &dwSize); - if (errCode == ERROR_SUCCESS) { - wchar_t* pData = (wchar_t*)malloc(dwSize * sizeof(wchar_t)); - errCode = RegQueryValueExW(hKey, L"Bind", NULL, NULL, (LPBYTE)pData, &dwSize); - if (errCode == ERROR_SUCCESS) { - wchar_t* pStr = pData; - for (i = 0; i < pIfTable->NumAdapters && *pStr != L'\0'; pStr += wcslen(pStr) + 1) { - if (wcsstr(pStr, L"\\Device\\NdisWanIp") == 0) { - wcsncpy(pIfTable->Adapter[i].Name, pStr, MAX_ADAPTER_NAME); - pIfTable->Adapter[i].Index = i; - i++; - } - } - - } - free(pData); - } - RegCloseKey(hKey); - } else { - result = errCode; - } - return result; -} - -/* - * EnumNameServers - */ - -static void EnumNameServers( HANDLE RegHandle, PWCHAR Interface, - PVOID Data, EnumNameServersFunc cb ) { - PWCHAR NameServerString = QueryRegistryValueString(RegHandle, L"NameServer"); - /* Now, count the non-empty comma separated */ - if (NameServerString) { - DWORD ch; - DWORD LastNameStart = 0; - for (ch = 0; NameServerString[ch]; ch++) { - if (NameServerString[ch] == ',') { - if (ch - LastNameStart > 0) { /* Skip empty entries */ - PWCHAR NameServer = malloc(sizeof(WCHAR) * (ch - LastNameStart + 1)); - if (NameServer) { - memcpy(NameServer,NameServerString + LastNameStart, - (ch - LastNameStart) * sizeof(WCHAR)); - NameServer[ch - LastNameStart] = 0; - cb( Interface, NameServer, Data ); - free(NameServer); - } - } - LastNameStart = ch + 1; /* The first one after the comma */ - } - } - if (ch - LastNameStart > 0) { /* A last name? */ - PWCHAR NameServer = malloc(sizeof(WCHAR) * (ch - LastNameStart + 1)); - memcpy(NameServer,NameServerString + LastNameStart, - (ch - LastNameStart) * sizeof(WCHAR)); - NameServer[ch - LastNameStart] = 0; - cb( Interface, NameServer, Data ); - free(NameServer); - } - ConsumeRegValueString(NameServerString); - } -} - -/* - * EnumInterfaces - * - * Call the enumeration function for each name server. - */ - -static void EnumInterfaces( PVOID Data, EnumInterfacesFunc cb ) { - HKEY RegHandle; - HKEY ChildKeyHandle = 0; - PWCHAR RegKeyToEnumerate = - L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces"; - PWCHAR ChildKeyName = 0; - DWORD CurrentInterface; - - if (OpenChildKeyRead(HKEY_LOCAL_MACHINE,RegKeyToEnumerate,&RegHandle)) { - return; - } - - for (CurrentInterface = 0; TRUE; CurrentInterface++) { - ChildKeyName = GetNthChildKeyName( RegHandle, CurrentInterface ); - if (!ChildKeyName) break; - if (OpenChildKeyRead(RegHandle,ChildKeyName, - &ChildKeyHandle) == 0) { - cb( ChildKeyHandle, ChildKeyName, Data ); - RegCloseKey( ChildKeyHandle ); - } - ConsumeChildKeyName( ChildKeyName ); - } -} - -static void CreateNameServerListEnumNamesFuncCount( PWCHAR Interface, - PWCHAR Server, - PVOID _Data ) { - PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data; - Data->NumServers++; -} - -static void CreateNameServerListEnumIfFuncCount( HANDLE RegHandle, - PWCHAR InterfaceName, - PVOID _Data ) { - PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data; - EnumNameServers(RegHandle,InterfaceName,Data, - CreateNameServerListEnumNamesFuncCount); -} - -static void CreateNameServerListEnumNamesFunc( PWCHAR Interface, - PWCHAR Server, - PVOID _Data ) { - PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data; - wcstombs(Data->AddrString[Data->CurrentName].IpAddress.String, - Server, - sizeof(IP_ADDRESS_STRING)); - strcpy(Data->AddrString[Data->CurrentName].IpMask.String,"0.0.0.0"); - Data->AddrString[Data->CurrentName].Context = 0; - if (Data->CurrentName < Data->NumServers - 1) { - Data->AddrString[Data->CurrentName].Next = - &Data->AddrString[Data->CurrentName+1]; - } else - Data->AddrString[Data->CurrentName].Next = 0; - - Data->CurrentName++; -} - -static void CreateNameServerListEnumIfFunc( HANDLE RegHandle, - PWCHAR InterfaceName, - PVOID _Data ) { - PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data; - EnumNameServers(RegHandle,InterfaceName,Data, - CreateNameServerListEnumNamesFunc); -} - -static int CountNameServers( PNAME_SERVER_LIST_PRIVATE PrivateData ) { - EnumInterfaces(PrivateData,CreateNameServerListEnumIfFuncCount); - return PrivateData->NumServers; -} - -static void MakeNameServerList( PNAME_SERVER_LIST_PRIVATE PrivateData ) { - EnumInterfaces(PrivateData,CreateNameServerListEnumIfFunc); -} - -/* - * @implemented - */ -DWORD -STDCALL -GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen) -{ - DWORD result = ERROR_SUCCESS; - DWORD dwSize; - HKEY hKey; - LONG errCode; - NAME_SERVER_LIST_PRIVATE PrivateNSEnum = { 0 }; - - CountNameServers( &PrivateNSEnum ); - - if (pOutBufLen == NULL) return ERROR_INVALID_PARAMETER; - - if (*pOutBufLen < sizeof(FIXED_INFO)) - { - *pOutBufLen = sizeof(FIXED_INFO) + - ((PrivateNSEnum.NumServers - 1) * sizeof(IP_ADDR_STRING)); - return ERROR_BUFFER_OVERFLOW; - } - if (pFixedInfo == NULL) return ERROR_INVALID_PARAMETER; - memset(pFixedInfo, 0, sizeof(FIXED_INFO)); - - errCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE, - L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", 0, KEY_READ, &hKey); - if (errCode == ERROR_SUCCESS) - { - dwSize = sizeof(pFixedInfo->HostName); - errCode = RegQueryValueExA(hKey, "Hostname", NULL, NULL, (LPBYTE)&pFixedInfo->HostName, &dwSize); - dwSize = sizeof(pFixedInfo->DomainName); - errCode = RegQueryValueExA(hKey, "Domain", NULL, NULL, (LPBYTE)&pFixedInfo->DomainName, &dwSize); - if (errCode != ERROR_SUCCESS) - { - dwSize = sizeof(pFixedInfo->DomainName); - errCode = RegQueryValueExA(hKey, "DhcpDomain", NULL, NULL, (LPBYTE)&pFixedInfo->DomainName, &dwSize); - } - dwSize = sizeof(pFixedInfo->EnableRouting); - errCode = RegQueryValueExW(hKey, L"IPEnableRouter", NULL, NULL, (LPBYTE)&pFixedInfo->EnableRouting, &dwSize); - RegCloseKey(hKey); - - /* Get the number of name servers */ - PIP_ADDR_STRING AddressAfterFixedInfo; - AddressAfterFixedInfo = (PIP_ADDR_STRING)&pFixedInfo[1]; - DWORD NumberOfServersAllowed = 0, CurrentServer = 0; - - while( &AddressAfterFixedInfo[NumberOfServersAllowed] < - (PIP_ADDR_STRING)(((PCHAR)pFixedInfo) + *pOutBufLen) ) - NumberOfServersAllowed++; - - NumberOfServersAllowed++; /* One struct is built in */ - - /* Since the first part of the struct is built in, we have to do some - fiddling */ - PrivateNSEnum.AddrString = - malloc(NumberOfServersAllowed * sizeof(IP_ADDR_STRING)); - if (PrivateNSEnum.NumServers > NumberOfServersAllowed) - PrivateNSEnum.NumServers = NumberOfServersAllowed; - MakeNameServerList( &PrivateNSEnum ); - - /* Now we have the name servers, place the first one in the struct, - and follow it with the rest */ - if (!PrivateNSEnum.NumServers) - RtlZeroMemory( &pFixedInfo->DnsServerList, - sizeof(pFixedInfo->DnsServerList) ); - else - memcpy( &pFixedInfo->DnsServerList, &PrivateNSEnum.AddrString[0], - sizeof(PrivateNSEnum.AddrString[0]) ); - - if (PrivateNSEnum.NumServers > 1) { - pFixedInfo->CurrentDnsServer = &pFixedInfo->DnsServerList; - memcpy( &AddressAfterFixedInfo[0], - &PrivateNSEnum.AddrString[1], - sizeof(IP_ADDR_STRING) * (PrivateNSEnum.NumServers - 1) ); - } else if (PrivateNSEnum.NumServers == 0) { - pFixedInfo->CurrentDnsServer = &pFixedInfo->DnsServerList; - } else { - pFixedInfo->CurrentDnsServer = 0; - } - - for( CurrentServer = 0; - PrivateNSEnum.NumServers && - CurrentServer < PrivateNSEnum.NumServers - 1; - CurrentServer++ ) { - pFixedInfo->CurrentDnsServer->Next = &AddressAfterFixedInfo[CurrentServer]; - pFixedInfo->CurrentDnsServer = &AddressAfterFixedInfo[CurrentServer]; - pFixedInfo->CurrentDnsServer->Next = 0; - } - - /* For now, set the first server as the current server, if there are any */ - if( PrivateNSEnum.NumServers ) { - pFixedInfo->CurrentDnsServer = &pFixedInfo->DnsServerList; - } - - free(PrivateNSEnum.AddrString); - } - else - { - WSH_DbgPrint( MIN_TRACE, - ("Open Tcpip parameters key: error %08x\n", errCode )); - result = ERROR_NO_DATA; // No adapter information exists for the local computer - } - - errCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters", 0, KEY_READ, &hKey); - if (errCode == ERROR_SUCCESS) - { - dwSize = sizeof(pFixedInfo->ScopeId); - errCode = RegQueryValueExA(hKey, "ScopeId", NULL, NULL, (LPBYTE)&pFixedInfo->ScopeId, &dwSize); - if (errCode != ERROR_SUCCESS) - { - dwSize = sizeof(pFixedInfo->ScopeId); - errCode = RegQueryValueExA(hKey, "DhcpScopeId", NULL, NULL, (LPBYTE)&pFixedInfo->ScopeId, &dwSize); - } - dwSize = sizeof(pFixedInfo->NodeType); - errCode = RegQueryValueExW(hKey, L"NodeType", NULL, NULL, (LPBYTE)&pFixedInfo->NodeType, &dwSize); - if (errCode != ERROR_SUCCESS) - { - dwSize = sizeof(pFixedInfo->NodeType); - errCode = RegQueryValueExA(hKey, "DhcpNodeType", NULL, NULL, (LPBYTE)&pFixedInfo->NodeType, &dwSize); - } - dwSize = sizeof(pFixedInfo->EnableProxy); - errCode = RegQueryValueExW(hKey, L"EnableProxy", NULL, NULL, (LPBYTE)&pFixedInfo->EnableProxy, &dwSize); - dwSize = sizeof(pFixedInfo->EnableDns); - errCode = RegQueryValueExW(hKey, L"EnableDNS", NULL, NULL, (LPBYTE)&pFixedInfo->EnableDns, &dwSize); - RegCloseKey(hKey); - } - else - { - WSH_DbgPrint(MIN_TRACE, - ("iphlpapi: Ignoring lack of netbios data for now.\n")); -#if 0 - result = ERROR_NO_DATA; // No adapter information exists for the local computer -#endif - } - - return result; -} - - -/* - * @unimplemented - */ -DWORD -STDCALL -GetTcpStatistics(PMIB_TCPSTATS pStats) -{ - DWORD result = NO_ERROR; - - result = ERROR_NO_DATA; - - return result; -} - - -/* - * @unimplemented - */ -DWORD -STDCALL -GetTcpTable(PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder) -{ - DWORD result = NO_ERROR; - - result = ERROR_NO_DATA; - - return result; -} - - -/* - * @unimplemented - */ -DWORD -STDCALL -GetUdpStatistics(PMIB_UDPSTATS pStats) -{ - DWORD result = NO_ERROR; - - result = ERROR_NO_DATA; - - return result; -} - - -/* - * @unimplemented - */ -DWORD -STDCALL -GetUdpTable(PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder) -{ - DWORD result = NO_ERROR; - - result = ERROR_NO_DATA; - - return result; -} - - -/* - * @unimplemented - */ -DWORD -STDCALL -FlushIpNetTable(DWORD dwIfIndex) -{ - DWORD result = NO_ERROR; - - return result; -} - -/****************************************************************** - * GetIfEntry (IPHLPAPI.@) - * - * - * PARAMS - * - * pIfRow [In/Out] - * - * RETURNS - * - * DWORD - * - */ -DWORD -STDCALL -GetIfEntry(PMIB_IFROW pIfRow) -{ - DWORD result = NO_ERROR; - - return result; -} - - -/****************************************************************** - * GetIfTable (IPHLPAPI.@) - * - * - * PARAMS - * - * pIfTable [In/Out] - * pdwSize [In/Out] - * bOrder [In] - * - * RETURNS - * - * DWORD - * - */ -DWORD -STDCALL -GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder) -{ - DWORD result = NO_ERROR; - - return result; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, - BOOL bOrder) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetIpNetTable(PMIB_IPNETTABLE pIpNetTable, PULONG pdwSize, - BOOL bOrder) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, - PULONG pdwSize, BOOL bOrder) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetIpStatistics(PMIB_IPSTATS pStats) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetIpStatisticsEx(PMIB_IPSTATS pStats, DWORD dwFamily) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetIcmpStatistics(PMIB_ICMP pStats) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetTcpStatisticsEx(PMIB_TCPSTATS pStats, DWORD dwFamily) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetUdpStatisticsEx(PMIB_UDPSTATS pStats, DWORD dwFamily) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL SetIfEntry(PMIB_IFROW pIfRow) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL SetIpForwardEntry(PMIB_IPFORWARDROW pRoute) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL SetIpStatistics(PMIB_IPSTATS pIpStats) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL SetIpTTL(UINT nTTL) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL CreateIpNetEntry(PMIB_IPNETROW pArpEntry) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL DeleteIpNetEntry(PMIB_IPNETROW pArpEntry) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL CreateProxyArpEntry(DWORD dwAddress, DWORD dwMask, - DWORD dwIfIndex) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL DeleteProxyArpEntry(DWORD dwAddress, DWORD dwMask, - DWORD dwIfIndex) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL SetTcpEntry(PMIB_TCPROW pTcpRow) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetUniDirectionalAdapterInfo( - PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo, PULONG dwOutBufLen) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetBestInterface(IPAddr dwDestAddr, PDWORD pdwBestIfIndex) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, - PMIB_IPFORWARDROW pBestRoute) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL NotifyAddrChange(PHANDLE Handle, LPOVERLAPPED overlapped) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL NotifyRouteChange(PHANDLE Handle, LPOVERLAPPED overlapped) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL DeleteIPAddress(ULONG NTEContext) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetPerAdapterInfo(ULONG IfIndex, - PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL SendARP(IPAddr DestIP, IPAddr SrcIP, PULONG pMacAddr, - PULONG PhyAddrLen) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -BOOL STDCALL GetRTTAndHopCount(IPAddr DestIpAddress, PULONG HopCount, - ULONG MaxHops, PULONG RTT) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetFriendlyIfIndex(DWORD IfIndex) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL EnableRouter(HANDLE* pHandle, OVERLAPPED* pOverlapped) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL UnenableRouter(OVERLAPPED* pOverlapped, LPDWORD lpdwEnableCount) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetIcmpStatisticsEx(PMIB_ICMP_EX pStats,DWORD dwFamily) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL NhpAllocateAndGetInterfaceInfoFromStack(IP_INTERFACE_NAME_INFO **ppTable,PDWORD pdwCount,BOOL bOrder,HANDLE hHeap,DWORD dwFlags) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetBestInterfaceEx(struct sockaddr *pDestAddr,PDWORD pdwBestIfIndex) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -BOOL STDCALL CancelIPChangeNotify(LPOVERLAPPED notifyOverlapped) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -PIP_ADAPTER_ORDER_MAP STDCALL GetAdapterOrderMap(VOID) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetAdaptersAddresses(ULONG Family,DWORD Flags,PVOID Reserved,PIP_ADAPTER_ADDRESSES pAdapterAddresses,PULONG pOutBufLen) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL DisableMediaSense(HANDLE *pHandle,OVERLAPPED *pOverLapped) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL RestoreMediaSense(OVERLAPPED* pOverlapped,LPDWORD lpdwEnableCount) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL GetIpErrorString(IP_STATUS ErrorCode,PWCHAR Buffer,PDWORD Size) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -HANDLE STDCALL IcmpCreateFile( - VOID - ) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -HANDLE STDCALL Icmp6CreateFile( - VOID - ) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -BOOL STDCALL IcmpCloseHandle( - HANDLE IcmpHandle - ) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL IcmpSendEcho( - HANDLE IcmpHandle, - IPAddr DestinationAddress, - LPVOID RequestData, - WORD RequestSize, - PIP_OPTION_INFORMATION RequestOptions, - LPVOID ReplyBuffer, - DWORD ReplySize, - DWORD Timeout - ) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD -STDCALL -IcmpSendEcho2( - HANDLE IcmpHandle, - HANDLE Event, - FARPROC ApcRoutine, - PVOID ApcContext, - IPAddr DestinationAddress, - LPVOID RequestData, - WORD RequestSize, - PIP_OPTION_INFORMATION RequestOptions, - LPVOID ReplyBuffer, - DWORD ReplySize, - DWORD Timeout - ) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD -STDCALL -Icmp6SendEcho2( - HANDLE IcmpHandle, - HANDLE Event, - FARPROC ApcRoutine, - PVOID ApcContext, - struct sockaddr_in6 *SourceAddress, - struct sockaddr_in6 *DestinationAddress, - LPVOID RequestData, - WORD RequestSize, - PIP_OPTION_INFORMATION RequestOptions, - LPVOID ReplyBuffer, - DWORD ReplySize, - DWORD Timeout - ) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD -STDCALL -IcmpParseReplies( - LPVOID ReplyBuffer, - DWORD ReplySize - ) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD -STDCALL -Icmp6ParseReplies( - LPVOID ReplyBuffer, - DWORD ReplySize - ) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL AllocateAndGetIfTableFromStack(PMIB_IFTABLE *ppIfTable, - BOOL bOrder, HANDLE heap, DWORD flags) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL AllocateAndGetIpAddrTableFromStack(PMIB_IPADDRTABLE *ppIpAddrTable, - BOOL bOrder, HANDLE heap, DWORD flags) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE * - ppIpForwardTable, BOOL bOrder, HANDLE heap, DWORD flags) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable, - BOOL bOrder, HANDLE heap, DWORD flags) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL AllocateAndGetTcpTableFromStack(PMIB_TCPTABLE *ppTcpTable, - BOOL bOrder, HANDLE heap, DWORD flags) -{ - UNIMPLEMENTED - return 0L; -} - -/* - * @unimplemented - */ -DWORD STDCALL AllocateAndGetUdpTableFromStack(PMIB_UDPTABLE *ppUdpTable, - BOOL bOrder, HANDLE heap, DWORD flags) -{ - UNIMPLEMENTED - return 0L; -} diff --git a/reactos/lib/iphlpapi/iphlpapi.def b/reactos/lib/iphlpapi/iphlpapi.def deleted file mode 100644 index 57c00a8ad9e..00000000000 --- a/reactos/lib/iphlpapi/iphlpapi.def +++ /dev/null @@ -1,158 +0,0 @@ -; IPHLPAPI.DLL - ReactOS Sockets 2 IP Helper API DLL - -LIBRARY iphlpapi.dll - -EXPORTS -AddIPAddress@20 -SetIpNetEntry@4 -CreateIpForwardEntry@4 -GetAdaptersInfo@8 -GetNetworkParams@8 -GetNumberOfInterfaces@4 -GetIfEntry@4 -GetIfTable@12 -GetInterfaceInfo@8 -GetTcpStatistics@4 -GetTcpTable@12 -GetUdpStatistics@4 -GetUdpTable@12 -FlushIpNetTable@4 -;IpHlpDllEntry -;AllocateAndGetArpEntTableFromStack=AllocateAndGetArpEntTableFromStack -AllocateAndGetIfTableFromStack=AllocateAndGetIfTableFromStack@16 -AllocateAndGetIpAddrTableFromStack=AllocateAndGetIpAddrTableFromStack@16 -AllocateAndGetIpForwardTableFromStack=AllocateAndGetIpForwardTableFromStack@16 -AllocateAndGetIpNetTableFromStack=AllocateAndGetIpNetTableFromStack@16 -;AllocateAndGetTcpExTableFromStack -AllocateAndGetTcpTableFromStack=AllocateAndGetTcpTableFromStack@16 -;AllocateAndGetUdpExTableFromStack -AllocateAndGetUdpTableFromStack=AllocateAndGetUdpTableFromStack@16 -CreateIpNetEntry@4 -CreateProxyArpEntry@12 -DeleteIPAddress@4 -DeleteIpForwardEntry@4 -DeleteIpNetEntry@4 -DeleteProxyArpEntry@12 -DisableMediaSense@8 -EnableRouter@8 -;FlushIpNetTableFromStack -GetAdapterIndex@8 -GetAdapterOrderMap@0 -GetAdaptersAddresses@20 -GetBestInterface@8 -GetBestInterfaceEx@8 -;GetBestInterfaceFromStack -GetBestRoute@12 -;GetBestRouteFromStack -GetFriendlyIfIndex@4 -GetIcmpStatistics@4 -GetIcmpStatisticsEx@8 -;GetIcmpStatsFromStack -;GetIcmpStatsFromStackEx -;GetIfEntryFromStack -;GetIfTableFromStack -;GetIgmpList -GetIpAddrTable@12 -;GetIpAddrTableFromStack -GetIpErrorString@12 -GetIpForwardTable@12 -;GetIpForwardTableFromStack -GetIpNetTable@12 -;GetIpNetTableFromStack -GetIpStatistics@4 -GetIpStatisticsEx@8 -;GetIpStatsFromStack -;GetIpStatsFromStackEx -GetPerAdapterInfo@12 -GetRTTAndHopCount@16 -GetTcpStatisticsEx@8 -;GetTcpStatsFromStack -;GetTcpStatsFromStackEx -;GetTcpTableFromStack -GetUdpStatisticsEx@8 -;GetUdpStatsFromStack -;GetUdpStatsFromStackEx -;GetUdpTableFromStack -GetUniDirectionalAdapterInfo@8 -Icmp6CreateFile@0 -Icmp6ParseReplies@8 -Icmp6SendEcho2@48 -IcmpCloseHandle@4 -IcmpCreateFile@0 -IcmpParseReplies@8 -IcmpSendEcho@32 -IcmpSendEcho2@44 -;InternalCreateIpForwardEntry -;InternalCreateIpNetEntry -;InternalDeleteIpForwardEntry -;InternalDeleteIpNetEntry -;InternalGetIfTable -;InternalGetIpAddrTable -;InternalGetIpForwardTable -;InternalGetIpNetTable -;InternalGetTcpTable -;InternalGetUdpTable -;InternalSetIfEntry -;InternalSetIpForwardEntry -;InternalSetIpNetEntry -;InternalSetIpStats -;InternalSetTcpEntry -IpReleaseAddress@4 -IpRenewAddress@4 -;IsLocalAddress -;NTPTimeToNTFileTime -;NTTimeToNTPTime -;NhGetGuidFromInterfaceName -;NhGetInterfaceNameFromDeviceGuid -;NhGetInterfaceNameFromGuid -NhpAllocateAndGetInterfaceInfoFromStack@20 -;NhpGetInterfaceIndexFromStack -NotifyAddrChange@8 -NotifyRouteChange@8 -;NotifyRouteChangeEx -RestoreMediaSense@8 -;RtlIpv4AddressToStringExA -;RtlIpv4AddressToStringExW -;RtlIpv4StringToAddressExA -;RtlIpv4StringToAddressExW -;RtlIpv6AddressToStringExA -;RtlIpv6AddressToStringExW -;RtlIpv6StringToAddressExA -;RtlIpv6StringToAddressExW -SendARP@16 -;SetAdapterIpAddress -;SetBlockRoutes -SetIfEntry@4 -;SetIfEntryToStack -SetIpForwardEntry@4 -;SetIpForwardEntryToStack -;SetIpMultihopRouteEntryToStack -;SetIpNetEntryToStack -;SetIpRouteEntryToStack -SetIpStatistics@4 -;SetIpStatsToStack -SetIpTTL@4 -;SetProxyArpEntryToStack -;SetRouteWithRef -SetTcpEntry@4 -;SetTcpEntryToStack -UnenableRouter@8 -;@_PfAddFiltersToInterface@24 -;@_PfAddGlobalFilterToInterface@8 -;@_PfBindInterfaceToIPAddress@12 -;@_PfBindInterfaceToIndex@16 -;@_PfCreateInterface@24 -;@_PfDeleteInterface@4 -;@_PfDeleteLog@0 -;@_PfGetInterfaceStatistics@16 -;@_PfMakeLog@4 -;@_PfRebindFilters@8 -;@_PfRemoveFilterHandles@12 -;@_PfRemoveFiltersFromInterface@20 -;@_PfRemoveGlobalFilterFromInterface@8 -;@_PfSetLogBuffer@28 -;@_PfTestPacket@20 -;@_PfUnBindInterface@4 -;do_echo_rep -;do_echo_req -;register_icmp diff --git a/reactos/lib/iphlpapi/iphlpapi.edf b/reactos/lib/iphlpapi/iphlpapi.edf deleted file mode 100644 index 7c42cd373e1..00000000000 --- a/reactos/lib/iphlpapi/iphlpapi.edf +++ /dev/null @@ -1,159 +0,0 @@ -; IPHLPAPI.DLL - ReactOS Sockets 2 IP Helper API DLL - -LIBRARY iphlpapi.dll - -EXPORTS -AddIPAddress=AddIPAddress@20 -SetIpNetEntry=SetIpNetEntry@4 -CreateIpForwardEntry=CreateIpForwardEntry@4 -GetAdaptersInfo=GetAdaptersInfo@8 -GetNetworkParams=GetNetworkParams@8 -GetNumberOfInterfaces=GetNumberOfInterfaces@4 -GetIfEntry=GetIfEntry@4 -GetIfTable=GetIfTable@12 -GetInterfaceInfo=GetInterfaceInfo@8 -GetTcpStatistics=GetTcpStatistics@4 -GetTcpTable=GetTcpTable@12 -GetUdpStatistics=GetUdpStatistics@4 -GetUdpTable=GetUdpTable@12 -FlushIpNetTable=FlushIpNetTable@4 -;IpHlpDllEntry -;AllocateAndGetArpEntTableFromStack -AllocateAndGetIfTableFromStack=AllocateAndGetIfTableFromStack@16 -AllocateAndGetIpAddrTableFromStack=AllocateAndGetIpAddrTableFromStack@16 -AllocateAndGetIpForwardTableFromStack=AllocateAndGetIpForwardTableFromStack@16 -AllocateAndGetIpNetTableFromStack=AllocateAndGetIpNetTableFromStack@16 -;AllocateAndGetTcpExTableFromStack -AllocateAndGetTcpTableFromStack=AllocateAndGetTcpTableFromStack@16 -;AllocateAndGetUdpExTableFromStack -AllocateAndGetUdpTableFromStack=AllocateAndGetUdpTableFromStack@16 -CreateIpNetEntry=CreateIpNetEntry@4 -CreateProxyArpEntry=CreateProxyArpEntry@12 -DeleteIPAddress=DeleteIPAddress@4 -DeleteIpForwardEntry=DeleteIpForwardEntry@4 -DeleteIpNetEntry=DeleteIpNetEntry@4 -DeleteProxyArpEntry=DeleteProxyArpEntry@12 -DisableMediaSense=DisableMediaSense@8 -EnableRouter=EnableRouter@8 -;FlushIpNetTableFromStack -GetAdapterIndex=GetAdapterIndex@8 -GetAdapterOrderMap=GetAdapterOrderMap@0 -GetAdaptersAddresses=GetAdaptersAddresses@20 -GetBestInterface=GetBestInterface@8 -GetBestInterfaceEx=GetBestInterfaceEx@8 -;GetBestInterfaceFromStack -GetBestRoute=GetBestRoute@12 -;GetBestRouteFromStack -GetFriendlyIfIndex=GetFriendlyIfIndex@4 -GetIcmpStatistics=GetIcmpStatistics@4 -GetIcmpStatisticsEx=GetIcmpStatisticsEx@8 -;GetIcmpStatsFromStack -;GetIcmpStatsFromStackEx -;GetIfEntryFromStack -;GetIfTableFromStack -;GetIgmpList -GetIpAddrTable=GetIpAddrTable@12 -;GetIpAddrTableFromStack -GetIpErrorString=GetIpErrorString@12 -GetIpForwardTable=GetIpForwardTable@12 -;GetIpForwardTableFromStack -GetIpNetTable=GetIpNetTable@12 -;GetIpNetTableFromStack -GetIpStatistics=GetIpStatistics@4 -GetIpStatisticsEx=GetIpStatisticsEx@8 -;GetIpStatsFromStack -;GetIpStatsFromStackEx -GetPerAdapterInfo=GetPerAdapterInfo@12 -GetRTTAndHopCount=GetRTTAndHopCount@16 -GetTcpStatisticsEx=GetTcpStatisticsEx@8 -;GetTcpStatsFromStack -;GetTcpStatsFromStackEx -;GetTcpTableFromStack -GetUdpStatisticsEx=GetUdpStatisticsEx@8 -;GetUdpStatsFromStack -;GetUdpStatsFromStackEx -;GetUdpTableFromStack -GetUniDirectionalAdapterInfo=GetUniDirectionalAdapterInfo@8 -Icmp6CreateFile=Icmp6CreateFile@0 -Icmp6ParseReplies=Icmp6ParseReplies@8 -Icmp6SendEcho2=Icmp6SendEcho2@48 -IcmpCloseHandle=IcmpCloseHandle@4 -IcmpCreateFile=IcmpCreateFile@0 -IcmpParseReplies=IcmpParseReplies@8 -IcmpSendEcho=IcmpSendEcho@32 -IcmpSendEcho2=IcmpSendEcho2@44 -;InternalCreateIpForwardEntry -;InternalCreateIpNetEntry -;InternalDeleteIpForwardEntry -;InternalDeleteIpNetEntry -;InternalGetIfTable -;InternalGetIpAddrTable -;InternalGetIpForwardTable -;InternalGetIpNetTable -;InternalGetTcpTable -;InternalGetUdpTable -;InternalSetIfEntry -;InternalSetIpForwardEntry -;InternalSetIpNetEntry -;InternalSetIpStats -;InternalSetTcpEntry -IpReleaseAddress=IpReleaseAddress@4 -IpRenewAddress=IpRenewAddress@4 -;IsLocalAddress -;NTPTimeToNTFileTime -;NTTimeToNTPTime -;NhGetGuidFromInterfaceName -;NhGetInterfaceNameFromDeviceGuid -;NhGetInterfaceNameFromGuid -NhpAllocateAndGetInterfaceInfoFromStack=NhpAllocateAndGetInterfaceInfoFromStack@20 -;NhpGetInterfaceIndexFromStack -NotifyAddrChange=NotifyAddrChange@8 -NotifyRouteChange=NotifyRouteChange@8 -;NotifyRouteChangeEx -RestoreMediaSense=RestoreMediaSense@8 -;RtlIpv4AddressToStringExA -;RtlIpv4AddressToStringExW -;RtlIpv4StringToAddressExA -;RtlIpv4StringToAddressExW -;RtlIpv6AddressToStringExA -;RtlIpv6AddressToStringExW -;RtlIpv6StringToAddressExA -;RtlIpv6StringToAddressExW -SendARP=SendARP@16 -;SetAdapterIpAddress -;SetBlockRoutes -SetIfEntry=SetIfEntry@4 -;SetIfEntryToStack -SetIpForwardEntry=SetIpForwardEntry@4 -;SetIpForwardEntryToStack -;SetIpMultihopRouteEntryToStack -;SetIpNetEntryToStack -;SetIpRouteEntryToStack -SetIpStatistics=SetIpStatistics@4 -;SetIpStatsToStack -SetIpTTL=SetIpTTL@4 -;SetProxyArpEntryToStack -;SetRouteWithRef -SetTcpEntry=SetTcpEntry@4 -;SetTcpEntryToStack -UnenableRouter=UnenableRouter@8 -;_PfAddFiltersToInterface@24 -;_PfAddGlobalFilterToInterface@8 -;_PfBindInterfaceToIPAddress@12 -;_PfBindInterfaceToIndex@16 -;_PfCreateInterface@24 -;_PfDeleteInterface@4 -;_PfDeleteLog@0 -;_PfGetInterfaceStatistics@16 -;_PfMakeLog@4 -;_PfRebindFilters@8 -;_PfRemoveFilterHandles@12 -;_PfRemoveFiltersFromInterface@20 -;_PfRemoveGlobalFilterFromInterface@8 -;_PfSetLogBuffer@28 -;_PfTestPacket@20 -;_PfUnBindInterface@4 -;do_echo_rep -;do_echo_req -;register_icmp -; EOF diff --git a/reactos/lib/iphlpapi/iphlpapi.spec b/reactos/lib/iphlpapi/iphlpapi.spec new file mode 100644 index 00000000000..a9797ac6689 --- /dev/null +++ b/reactos/lib/iphlpapi/iphlpapi.spec @@ -0,0 +1,117 @@ +@ stdcall AddIPAddress( long long long ptr ptr ) +@ stub AllocateAndGetArpEntTableFromStack +@ stdcall AllocateAndGetIfTableFromStack( ptr long long long ) +@ stdcall AllocateAndGetIpAddrTableFromStack( ptr long long long ) +@ stdcall AllocateAndGetIpForwardTableFromStack( ptr long long long ) +@ stdcall AllocateAndGetIpNetTableFromStack( ptr long long long ) +@ stdcall AllocateAndGetTcpTableFromStack( ptr long long long ) +@ stdcall AllocateAndGetUdpTableFromStack( ptr long long long ) +@ stdcall CreateIpForwardEntry( ptr ) +@ stdcall CreateIpNetEntry( ptr ) +@ stdcall CreateProxyArpEntry( long long long ) +@ stdcall DeleteIPAddress( long ) +@ stdcall DeleteIpForwardEntry( ptr ) +@ stdcall DeleteIpNetEntry( ptr ) +@ stdcall DeleteProxyArpEntry( long long long ) +@ stdcall EnableRouter( ptr ptr ) +@ stdcall FlushIpNetTable( long ) +@ stub FlushIpNetTableFromStack +@ stdcall GetAdapterIndex( wstr ptr ) +@ stub GetAdapterOrderMap +@ stdcall GetAdaptersInfo( ptr ptr ) +@ stdcall GetBestInterface( long ptr ) +@ stub GetBestInterfaceFromStack +@ stdcall GetBestRoute( long long long ) +@ stub GetBestRouteFromStack +@ stdcall GetFriendlyIfIndex( long ) +@ stdcall GetIcmpStatistics( ptr ) +@ stub GetIcmpStatsFromStack +@ stdcall GetIfEntry( ptr ) +@ stub GetIfEntryFromStack +@ stdcall GetIfTable( ptr ptr long ) +@ stub GetIfTableFromStack +@ stub GetIgmpList +@ stdcall GetInterfaceInfo( ptr ptr ) +@ stdcall GetIpAddrTable( ptr ptr long ) +@ stub GetIpAddrTableFromStack +@ stdcall GetIpForwardTable( ptr ptr long ) +@ stub GetIpForwardTableFromStack +@ stdcall GetIpNetTable( ptr ptr long ) +@ stub GetIpNetTableFromStack +@ stdcall GetIpStatistics( ptr ) +@ stub GetIpStatsFromStack +@ stdcall GetNetworkParams( ptr ptr ) +@ stdcall GetNumberOfInterfaces( ptr ) +@ stdcall GetPerAdapterInfo( long ptr ptr ) +@ stdcall GetRTTAndHopCount( long ptr long ptr ) +@ stdcall GetTcpStatistics( ptr ) +@ stub GetTcpStatsFromStack +@ stdcall GetTcpTable( ptr ptr long ) +@ stub GetTcpTableFromStack +@ stdcall GetUdpStatistics( ptr ) +@ stub GetUdpStatsFromStack +@ stdcall GetUdpTable( ptr ptr long ) +@ stub GetUdpTableFromStack +@ stdcall GetUniDirectionalAdapterInfo( ptr ptr ) +@ stub InternalCreateIpForwardEntry +@ stub InternalCreateIpNetEntry +@ stub InternalDeleteIpForwardEntry +@ stub InternalDeleteIpNetEntry +@ stub InternalGetIfTable +@ stub InternalGetIpAddrTable +@ stub InternalGetIpForwardTable +@ stub InternalGetIpNetTable +@ stub InternalGetTcpTable +@ stub InternalGetUdpTable +@ stub InternalSetIfEntry +@ stub InternalSetIpForwardEntry +@ stub InternalSetIpNetEntry +@ stub InternalSetIpStats +@ stub InternalSetTcpEntry +@ stdcall IpReleaseAddress( ptr ) +@ stdcall IpRenewAddress( ptr ) +@ stub IsLocalAddress +@ stub NTPTimeToNTFileTime +@ stub NTTimeToNTPTime +@ stub NhGetGuidFromInterfaceName +@ stub NhGetInterfaceNameFromGuid +@ stub NhpAllocateAndGetInterfaceInfoFromStack +@ stub NhpGetInterfaceIndexFromStack +@ stdcall NotifyAddrChange( ptr ptr ) +@ stdcall NotifyRouteChange( ptr ptr ) +@ stub NotifyRouteChangeEx +@ stub _PfAddFiltersToInterface@24 +@ stub _PfAddGlobalFilterToInterface@8 +@ stub _PfBindInterfaceToIPAddress@12 +@ stub _PfBindInterfaceToIndex@16 +@ stub _PfCreateInterface@24 +@ stub _PfDeleteInterface@4 +@ stub _PfDeleteLog@0 +@ stub _PfGetInterfaceStatistics@16 +@ stub _PfMakeLog@4 +@ stub _PfRebindFilters@8 +@ stub _PfRemoveFilterHandles@12 +@ stub _PfRemoveFiltersFromInterface@20 +@ stub _PfRemoveGlobalFilterFromInterface@8 +@ stub _PfSetLogBuffer@28 +@ stub _PfTestPacket@20 +@ stub _PfUnBindInterface@4 +@ stdcall SendARP( long long ptr ptr ) +@ stub SetAdapterIpAddress +@ stub SetBlockRoutes +@ stdcall SetIfEntry( ptr ) +@ stub SetIfEntryToStack +@ stdcall SetIpForwardEntry( ptr ) +@ stub SetIpForwardEntryToStack +@ stub SetIpMultihopRouteEntryToStack +@ stdcall SetIpNetEntry( ptr ) +@ stub SetIpNetEntryToStack +@ stub SetIpRouteEntryToStack +@ stdcall SetIpStatistics( ptr ) +@ stub SetIpStatsToStack +@ stdcall SetIpTTL( long ) +@ stub SetProxyArpEntryToStack +@ stub SetRouteWithRef +@ stdcall SetTcpEntry( ptr ) +@ stub SetTcpEntryToStack +@ stdcall UnenableRouter( ptr ptr ) diff --git a/reactos/lib/iphlpapi/iphlpapi_main.c b/reactos/lib/iphlpapi/iphlpapi_main.c index 8a93ef03087..9888e845151 100644 --- a/reactos/lib/iphlpapi/iphlpapi_main.c +++ b/reactos/lib/iphlpapi/iphlpapi_main.c @@ -18,9 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif +#include "iphlpapi_private.h" #include #include @@ -38,28 +37,16 @@ # include #endif -#ifdef __REACTOS__ -# include -# include -# include -# include -# include -# include -# include -# include "iphlpapiextra.h" -# include "wine/debug.h" -#else -# include "windef.h" -# include "winbase.h" -# include "winreg.h" -# include "debug.h" -#endif -#include +#include "windef.h" +#include "winbase.h" +#include "winreg.h" #include "iphlpapi.h" #include "ifenum.h" #include "ipstats.h" -#include "iphlp_res.h" +#include "resinfo.h" +#include "route.h" +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi); @@ -350,10 +337,7 @@ DWORD WINAPI AllocateAndGetUdpTableFromStack(PMIB_UDPTABLE *ppUdpTable, */ DWORD WINAPI CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute) { - TRACE("pRoute %p\n", pRoute); - /* could use SIOCADDRT, not sure I want to */ - FIXME(":stub\n"); - return (DWORD) 0; + return createIpForwardEntry( pRoute ); } @@ -441,10 +425,7 @@ DWORD WINAPI DeleteIPAddress(ULONG NTEContext) */ DWORD WINAPI DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute) { - TRACE("pRoute %p\n", pRoute); - /* could use SIOCDELRT, not sure I want to */ - FIXME(":stub\n"); - return (DWORD) 0; + return deleteIpForwardEntry( pRoute ); } @@ -847,7 +828,7 @@ DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow) if (name) { ret = getInterfaceEntryByIndex(pIfRow->dwIndex, pIfRow); if (ret == NO_ERROR) - ret = getInterfaceStatsByIndex(pIfRow->dwIndex, pIfRow); + ret = getInterfaceStatsByName(name, pIfRow); consumeInterfaceName(name); } else @@ -1355,8 +1336,6 @@ DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen) if (!resInfo) return ERROR_OUTOFMEMORY; - TRACE("resInfo->riCount = %d\n", resInfo->riCount); - size = sizeof(FIXED_INFO) + (resInfo->riCount > 0 ? (resInfo->riCount - 1) * sizeof(IP_ADDR_STRING) : 0); if (!pFixedInfo || *pOutBufLen < size) { @@ -1379,8 +1358,10 @@ DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen) for (i = 0, ptr = &pFixedInfo->DnsServerList; i < resInfo->riCount && ptr; i++, ptr = ptr->Next) { + struct sockaddr_in *addr_v4 = + (struct sockaddr_in *)&resInfo->riAddressList[i]; toIPAddressString - (((PSOCKADDR_IN)&resInfo->riAddressList[i])->sin_addr.s_addr, + (addr_v4->sin_addr.s_addr, ptr->IpAddress.String); if (i == resInfo->riCount - 1) ptr->Next = NULL; @@ -1916,12 +1897,7 @@ DWORD WINAPI SetIfEntry(PMIB_IFROW pIfRow) */ DWORD WINAPI SetIpForwardEntry(PMIB_IPFORWARDROW pRoute) { - TRACE("pRoute %p\n", pRoute); - /* this is to add a route entry, how's it distinguishable from - CreateIpForwardEntry? - could use SIOCADDRT, not sure I want to */ - FIXME(":stub\n"); - return (DWORD) 0; + return setIpForwardEntry( pRoute ); } @@ -2039,9 +2015,9 @@ DWORD WINAPI UnenableRouter(OVERLAPPED * pOverlapped, LPDWORD lpdwEnableCount) /* * @unimplemented */ -DWORD STDCALL GetIpErrorString(IP_STATUS ErrorCode,PWCHAR Buffer,PDWORD Size) +DWORD WINAPI GetIpErrorString(IP_STATUS ErrorCode,PWCHAR Buffer,PDWORD Size) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } @@ -2049,54 +2025,55 @@ DWORD STDCALL GetIpErrorString(IP_STATUS ErrorCode,PWCHAR Buffer,PDWORD Size) /* * @unimplemented */ -PIP_ADAPTER_ORDER_MAP STDCALL GetAdapterOrderMap(VOID) +PIP_ADAPTER_ORDER_MAP WINAPI GetAdapterOrderMap(VOID) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } /* * @unimplemented */ -DWORD STDCALL GetAdaptersAddresses(ULONG Family,DWORD Flags,PVOID Reserved,PIP_ADAPTER_ADDRESSES pAdapterAddresses,PULONG pOutBufLen) +DWORD WINAPI GetAdaptersAddresses(ULONG Family,DWORD Flags,PVOID Reserved,PIP_ADAPTER_ADDRESSES pAdapterAddresses,PULONG pOutBufLen) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } /* * @unimplemented */ -BOOL STDCALL CancelIPChangeNotify(LPOVERLAPPED notifyOverlapped) +BOOL WINAPI CancelIPChangeNotify(LPOVERLAPPED notifyOverlapped) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } /* * @unimplemented */ -DWORD STDCALL GetBestInterfaceEx(struct sockaddr *pDestAddr,PDWORD pdwBestIfIndex) +DWORD WINAPI GetBestInterfaceEx(struct sockaddr *pDestAddr,PDWORD pdwBestIfIndex) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } /* * @unimplemented */ -DWORD STDCALL NhpAllocateAndGetInterfaceInfoFromStack(IP_INTERFACE_NAME_INFO **ppTable,PDWORD pdwCount,BOOL bOrder,HANDLE hHeap,DWORD dwFlags) +DWORD WINAPI NhpAllocateAndGetInterfaceInfoFromStack(IP_INTERFACE_NAME_INFO **ppTable,PDWORD pdwCount,BOOL bOrder,HANDLE hHeap,DWORD dwFlags) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } /* * @unimplemented */ -DWORD STDCALL GetIcmpStatisticsEx(PMIB_ICMP_EX pStats,DWORD dwFamily) +DWORD WINAPI GetIcmpStatisticsEx(PMIB_ICMP_EX pStats,DWORD dwFamily) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } + diff --git a/reactos/lib/iphlpapi/iphlpv6.c b/reactos/lib/iphlpapi/iphlpv6.c index 6c6472b5488..f624bf8678d 100644 --- a/reactos/lib/iphlpapi/iphlpv6.c +++ b/reactos/lib/iphlpapi/iphlpv6.c @@ -1,6 +1,28 @@ -#ifdef HAVE_CONFIG_H +/* + * iphlpapi dll implementation -- Auxiliary IPv6 stubs + * + * These are stubs for functions that provide and set IPv6 information on the + * target operating system. They are grouped here because their + * implementation will vary widely by operating system. + * + * Copyright (C) 2004 Art Yerkes + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "config.h" -#endif +#include "iphlpapi_private.h" #include #include @@ -18,36 +40,23 @@ # include #endif -#ifdef __REACTOS__ -# include -# include -# include -# include -# include -# include -# include -# include -# include "iphlpapiextra.h" -#else -# include "windef.h" -# include "winbase.h" -# include "winreg.h" -#endif - +#include "windef.h" +#include "winbase.h" +#include "winreg.h" +#include "resinfo.h" #include "iphlpapi.h" -#include "ifenum.h" -#include "ipstats.h" -#include "iphlp_res.h" #include "wine/debug.h" +WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi); + /* * @unimplemented */ -HANDLE STDCALL Icmp6CreateFile( +HANDLE WINAPI Icmp6CreateFile( VOID ) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } @@ -55,7 +64,7 @@ HANDLE STDCALL Icmp6CreateFile( * @unimplemented */ DWORD -STDCALL +WINAPI Icmp6SendEcho2( HANDLE IcmpHandle, HANDLE Event, @@ -71,7 +80,7 @@ Icmp6SendEcho2( DWORD Timeout ) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } @@ -79,13 +88,13 @@ Icmp6SendEcho2( * @unimplemented */ DWORD -STDCALL +WINAPI Icmp6ParseReplies( LPVOID ReplyBuffer, DWORD ReplySize ) { - UNIMPLEMENTED + FIXME(":stub\n"); return 0L; } diff --git a/reactos/lib/iphlpapi/ipprivate.h b/reactos/lib/iphlpapi/ipprivate.h deleted file mode 100644 index bd4955caeea..00000000000 --- a/reactos/lib/iphlpapi/ipprivate.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef IPPRIVATE_H -#define IPPRIVATE_H - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#ifdef HAVE_NETINET_IN_H -# include -#endif -#ifdef HAVE_ARPA_INET_H -# include -#endif -#ifdef HAVE_ARPA_NAMESER_H -# include -#endif -#ifdef HAVE_RESOLV_H -# include -#endif - -#define NTOS_MODE_USER -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "iphlpapiextra.h" -#include "ipregprivate.h" -#include "iphlpapi.h" -#include "ifenum.h" -#include "ipstats.h" -#include "iphlp_res.h" -#include "wine/debug.h" - -#undef TRACE -#define TRACE(fmt,args...) DbgPrint("(%s:%d - %s) " fmt, __FILE__, __LINE__, __FUNCTION__, ## args) - -#include "net/tdiinfo.h" -#include "tcpioctl.h" - -#ifndef ETH_ALEN -#define ETH_ALEN 6 -#endif - -#ifndef INADDR_NONE -#define INADDR_NONE (~0U) -#endif - -#ifndef IFENT_SOFTWARE_LOOPBACK -#define IFENT_SOFTWARE_LOOPBACK 24 /* This is an SNMP constant from rfc1213 */ -#endif/*IFENT_SOFTWARE_LOOPBACK*/ - -#define INDEX_IS_LOOPBACK 0x00800000 - -/* Type declarations */ - -#ifndef IFNAMSIZ -#define IFNAMSIZ 0x20 -#endif/*IFNAMSIZ*/ - -#define TCP_REQUEST_QUERY_INFORMATION_INIT { { { 0 } } } - -/* No caddr_t in reactos headers */ -typedef char *caddr_t; - -typedef union _IFEntrySafelySized { - PCHAR MaxSize[sizeof(DWORD) + - sizeof(IFEntry) + - MAX_ADAPTER_DESCRIPTION_LENGTH + 1]; - struct { - DWORD ProperlyOffsetTheStructure; - IFEntry ent; - } offset; -} IFEntrySafelySized; - -/** Prototypes **/ -NTSTATUS openTcpFile(PHANDLE tcpFile); -VOID closeTcpFile(HANDLE tcpFile); -NTSTATUS tdiGetEntityIDSet( HANDLE tcpFile, TDIEntityID **entitySet, - PDWORD numEntities ); -VOID tdiFreeThingSet( PVOID things ); - -#endif/*IPPRIVATE_H*/ diff --git a/reactos/lib/iphlpapi/ipregprivate.h b/reactos/lib/iphlpapi/ipregprivate.h deleted file mode 100644 index a9e370c2eab..00000000000 --- a/reactos/lib/iphlpapi/ipregprivate.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef IPREGPRIVATE_H -#define IPREGPRIVATE_H - -int GetLongestChildKeyName( HANDLE RegHandle ); -LONG OpenChildKeyRead( HANDLE RegHandle, - PCHAR ChildKeyName, - PHKEY ReturnHandle ); -PCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n ); -void ConsumeChildKeyName( PCHAR Name ); -PCHAR QueryRegistryValueString( HANDLE RegHandle, PCHAR ValueName ); -void ConsumeRegValueString( PCHAR NameServer ); - -#endif/*IPREGPRIVATE_H*/ diff --git a/reactos/lib/iphlpapi/ipstats_reactos.c b/reactos/lib/iphlpapi/ipstats_reactos.c index 34a072375a1..4f5e6da9a0e 100644 --- a/reactos/lib/iphlpapi/ipstats_reactos.c +++ b/reactos/lib/iphlpapi/ipstats_reactos.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2003 Juan Lang +/* Copyright (C) 2003 Art Yerkes + * A reimplementation of ifenum.c by Juan Lang * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -14,11 +15,11 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * This file implements statistics getting using the /proc filesystem exported - * by Linux, and maybe other OSes. + * This file is implemented on the IOCTL_TCP_QUERY_INFORMATION_EX ioctl on + * tcpip.sys */ -#include "ipprivate.h" +#include "iphlpapi_private.h" #include "ipstats.h" #include "ifenum.h" @@ -101,10 +102,9 @@ NTSTATUS getNthIpEntity( HANDLE tcpFile, DWORD index, TDIEntityID *ent ) { } } - DPRINT("Index %d is entity #%d - %04x:%08x\n", index, i, - entitySet[i].tei_entity, entitySet[i].tei_instance ); - if( numRoutes == index && i < numEntities ) { + DPRINT("Index %d is entity #%d - %04x:%08x\n", index, i, + entitySet[i].tei_entity, entitySet[i].tei_instance ); memcpy( ent, &entitySet[i], sizeof(*ent) ); tdiFreeThingSet( entitySet ); return STATUS_SUCCESS; @@ -169,27 +169,41 @@ NTSTATUS tdiGetMibForIpEntity } NTSTATUS tdiGetRoutesForIpEntity -( HANDLE tcpFile, TDIEntityID *ent, int numRoutes, IPRouteEntry *routes ) { - TCP_REQUEST_QUERY_INFORMATION_EX req = TCP_REQUEST_QUERY_INFORMATION_INIT; +( HANDLE tcpFile, TDIEntityID *ent, IPRouteEntry **routes, PDWORD numRoutes ) { NTSTATUS status = STATUS_SUCCESS; - DWORD returnSize; DPRINT("TdiGetRoutesForIpEntity(tcpFile %x,entityId %x)\n", (DWORD)tcpFile, ent->tei_instance); - req.ID.toi_class = INFO_CLASS_PROTOCOL; - req.ID.toi_type = INFO_TYPE_PROVIDER; - req.ID.toi_id = IP_MIB_ROUTETABLE_ENTRY_ID; - req.ID.toi_entity = *ent; + status = tdiGetSetOfThings( tcpFile, + INFO_CLASS_PROTOCOL, + INFO_TYPE_PROVIDER, + IP_MIB_ROUTETABLE_ENTRY_ID, + ent->tei_entity, + 0, + sizeof(IPRouteEntry), + (PVOID *)routes, + numRoutes); - status = DeviceIoControl( tcpFile, - IOCTL_TCP_QUERY_INFORMATION_EX, - &req, - sizeof(req), - routes, - sizeof(*routes) * numRoutes, - &returnSize, - NULL ); + return status; +} + +NTSTATUS tdiGetIpAddrsForIpEntity +( HANDLE tcpFile, TDIEntityID *ent, IPAddrEntry **addrs, PDWORD numAddrs ) { + NTSTATUS status; + + DPRINT("TdiGetIpAddrsForIpEntity(tcpFile %x,entityId %x)\n", + (DWORD)tcpFile, ent->tei_instance); + + status = tdiGetSetOfThings( tcpFile, + INFO_CLASS_PROTOCOL, + INFO_TYPE_PROVIDER, + IP_MIB_ADDRTABLE_ENTRY_ID, + ent->tei_entity, + 0, + sizeof(IPAddrEntry), + (PVOID *)addrs, + numAddrs ); return status; } @@ -444,9 +458,6 @@ RouteTable *getRouteTable(void) getNthIpEntity( tcpFile, i, &ent ); tdiGetMibForIpEntity( tcpFile, &ent, &snmpInfo ); - route_set = HeapAlloc( GetProcessHeap(), 0, - sizeof( IPRouteEntry ) * - snmpInfo.ipsi_numroutes ); DPRINT( "%d routes in instance %d\n", snmpInfo.ipsi_numroutes, i ); @@ -456,7 +467,7 @@ RouteTable *getRouteTable(void) return 0; } - tdiGetRoutesForIpEntity( tcpFile, &ent, numRoutes, route_set ); + tdiGetRoutesForIpEntity( tcpFile, &ent, &route_set, &numRoutes ); DPRINT("Route set returned\n"); #if 0 @@ -479,6 +490,8 @@ RouteTable *getRouteTable(void) route_set[j].ire_metric; } + if( route_set ) tdiFreeThingSet( route_set ); + routesAdded += snmpInfo.ipsi_numroutes; } diff --git a/reactos/lib/iphlpapi/makefile b/reactos/lib/iphlpapi/makefile index 8871cad628e..ea2bf2c5cbd 100644 --- a/reactos/lib/iphlpapi/makefile +++ b/reactos/lib/iphlpapi/makefile @@ -2,20 +2,17 @@ PATH_TO_TOP = ../.. -TARGET_TYPE = dynlink +TARGET_TYPE = winedll TARGET_NAME = iphlpapi TARGET_BASE = 0x777c0000 -TARGET_CFLAGS += -DYDEBUG -DUNICODE -D_UNICODE -D__USE_W32API -D__REACTOS__ -D_WIN32_WINNT=0x0500 -Wall -#-Werror +TARGET_CFLAGS += -DYDEBUG -DUNICODE -D_UNICODE -D__USE_W32API -D__REACTOS__ -Wall -Werror +# -D_WIN32_WINNT=0x0500 TARGET_SDKLIBS = ntdll.a kernel32.a ws2_32.a -TARGET_OBJECTS = iphlpapi_main.o icmp.o iphlpv6.o media.o registry.o \ - ifenum_reactos.o ipstats_reactos.o resinfo_reactos.o - DEP_OBJECTS = $(TARGET_OBJECTS) include $(PATH_TO_TOP)/rules.mak diff --git a/reactos/lib/iphlpapi/media.c b/reactos/lib/iphlpapi/media.c index bd6a7c74966..ceb78b6245b 100644 --- a/reactos/lib/iphlpapi/media.c +++ b/reactos/lib/iphlpapi/media.c @@ -1,43 +1,23 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#ifdef HAVE_NETINET_IN_H -# include -#endif -#ifdef HAVE_ARPA_INET_H -# include -#endif -#ifdef HAVE_ARPA_NAMESER_H -# include -#endif -#ifdef HAVE_RESOLV_H -# include -#endif - -#ifdef __REACTOS__ -# include -# include -# include -# include -# include -# include -# include -# include "iphlpapiextra.h" -#else -# include "windef.h" -# include "winbase.h" -# include "winreg.h" -#endif - -#include "iphlpapi.h" -#include "ifenum.h" -#include "ipstats.h" -#include "iphlp_res.h" -#include "wine/debug.h" +/* + * iphlpapi dll implementation -- physical media stubs + * + * Copyright (C) 2004 Art Yerkes + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "iphlpapi_private.h" /* * @unimplemented diff --git a/reactos/lib/iphlpapi/merge-notes.txt b/reactos/lib/iphlpapi/merge-notes.txt index 71f318919b1..8be72a710e7 100644 --- a/reactos/lib/iphlpapi/merge-notes.txt +++ b/reactos/lib/iphlpapi/merge-notes.txt @@ -3,11 +3,14 @@ Wine uses: Software\\Wine\\Wine\\Config\\Network -- Wins support is todo so this part isn't so important. -- Overall, workable Wine uses ansi functions + +-- Done -- GetNetworkParams -- -- Make workable interface for _res -- Wine based on real _res -- Reactos based on my enumerator funcs +-- Done -- Prints route info on windows ROUTE PRINT: iphlpapi_main.c:137 - ppIfTable 0104bd80, bOrder 1, heap 0xa0000000, flags 0x00000001 @@ -34,3 +37,20 @@ iphlpapi_main.c:1151 - pIpForwardTable a0001d68, pdwSize 0104bd00, bOrder 1 - GetIpForwardTable again iphlpapi_main.c:1214 - returning 122 iphlpapi_main.c:225 - returning 122 + +Overall architecture of the ifenum and ipstats functions. + +Right now, I rely heavily on a couple of enumeration functions. +What I need to do is consolidate them and reduce traffic on the ioctl. + +There are two things I need to do: + +1. Lookup an interface by index (or name) +2. Get the IP info + +I have too many functions that loop over various things. + +What I need are the get** functions from ipstats (which I think are ok) +And then to change the detritus in ifenum to be all based on +getInterfaceIndexTable and getInterfaceMibByIndex, getInterfaceMibByName + diff --git a/reactos/lib/iphlpapi/registry.c b/reactos/lib/iphlpapi/registry.c index 99ae679931d..614bbdec492 100644 --- a/reactos/lib/iphlpapi/registry.c +++ b/reactos/lib/iphlpapi/registry.c @@ -1,8 +1,4 @@ -#include -#include -#include -#include -#include "ipregprivate.h" +#include "iphlpapi_private.h" #include "debug.h" diff --git a/reactos/lib/iphlpapi/resinfo.c b/reactos/lib/iphlpapi/resinfo.c new file mode 100644 index 00000000000..39c213bda03 --- /dev/null +++ b/reactos/lib/iphlpapi/resinfo.c @@ -0,0 +1,61 @@ +/* + * iphlpapi dll implementation -- Setting and storing route information + * + * These are stubs for functions that set routing information on the target + * operating system. They are grouped here because their implementation will + * vary widely by operating system. + * + * Copyright (C) 2004 Art Yerkes + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" +#include "iphlpapi_private.h" + +#include +#include +#include +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif +#ifdef HAVE_ARPA_NAMESER_H +# include +#endif +#ifdef HAVE_RESOLV_H +# include +#endif + +#include "windef.h" +#include "winbase.h" +#include "winreg.h" +#include "resinfo.h" +#include "iphlpapi.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi); + +IPHLP_RES_INFO ResInfo; + +PIPHLP_RES_INFO getResInfo() { + ResInfo.riCount = _res.nscount; + ResInfo.riAddressList = _res.nsaddr_list; + return &ResInfo; +} + +VOID disposeResInfo( PIPHLP_RES_INFO InfoPtr ) { +} diff --git a/reactos/lib/iphlpapi/resinfo.h b/reactos/lib/iphlpapi/resinfo.h new file mode 100644 index 00000000000..be71202c582 --- /dev/null +++ b/reactos/lib/iphlpapi/resinfo.h @@ -0,0 +1,35 @@ +/* + * iphlpapi dll implementation -- Resolver information helper function + * prototypes + * + * Copyright (C) 2004 Art Yerkes + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _IPHLP_RES_H +#define _IPHLP_RES_H + +typedef struct _IPHLP_RES_INFO { + DWORD riCount; + struct sockaddr_in *riAddressList; +} IPHLP_RES_INFO, *PIPHLP_RES_INFO; + +/* Get resolver info. This currently is limited to a list of IP addresses + * that name our DNS server list. */ +PIPHLP_RES_INFO getResInfo(); +/* Release any resources used in acquiring the resolver information */ +VOID disposeResInfo( PIPHLP_RES_INFO InfoPtr ); + +#endif/*_IPHLP_RES_H*/ diff --git a/reactos/lib/iphlpapi/resinfo_reactos.c b/reactos/lib/iphlpapi/resinfo_reactos.c index ec85a600b60..39f6aaf14ae 100644 --- a/reactos/lib/iphlpapi/resinfo_reactos.c +++ b/reactos/lib/iphlpapi/resinfo_reactos.c @@ -1,6 +1,27 @@ -#ifdef HAVE_CONFIG_H +/* + * iphlpapi dll implementation -- Auxiliary icmp functions + * + * These are stubs for functions that provide a simple ICMP probing API. They + * will be operating system specific when implemented. + * + * Copyright (C) 2004 Art Yerkes + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "config.h" -#endif +#include "iphlpapi_private.h" #include #include @@ -21,20 +42,12 @@ #include "windef.h" #include "winbase.h" #include "winreg.h" - -#ifdef __REACTOS__ -# include /* ULONGLONG */ -# include /* Enables NSPAPI */ -# include /* SOCKET_ADDRESS */ -# include /* IP_ADAPTER_ADDRESSES */ -#endif - +#include "resinfo.h" #include "iphlpapi.h" -#include "ifenum.h" -#include "ipstats.h" -#include "iphlp_res.h" #include "wine/debug.h" +WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi); + PIPHLP_RES_INFO getResInfo() { PIPHLP_RES_INFO InfoPtr = (PIPHLP_RES_INFO)HeapAlloc( GetProcessHeap(), 0, diff --git a/reactos/lib/iphlpapi/route.c b/reactos/lib/iphlpapi/route.c new file mode 100644 index 00000000000..1d67b9ff98a --- /dev/null +++ b/reactos/lib/iphlpapi/route.c @@ -0,0 +1,69 @@ +/* + * iphlpapi dll implementation -- Setting and storing route information + * + * These are stubs for functions that set routing information on the target + * operating system. They are grouped here because their implementation will + * vary widely by operating system. + * + * Copyright (C) 2004 Art Yerkes + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" +#include "iphlpapi_private.h" + +#include +#include +#include +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif +#ifdef HAVE_ARPA_NAMESER_H +# include +#endif +#ifdef HAVE_RESOLV_H +# include +#endif + +#include "windef.h" +#include "winbase.h" +#include "winreg.h" +#include "resinfo.h" +#include "iphlpapi.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi); + +DWORD createIpForwardEntry( PMIB_IPFORWARDROW pRoute ) { + TRACE("pRoute %p\n", pRoute); + /* could use SIOCADDRT, not sure I want to */ + FIXME(":stub\n"); + return (DWORD) 0; +} + +DWORD setIpForwardEntry( PMIB_IPFORWARDROW pRoute ) { + FIXME(":stub\n"); + return (DWORD) 0; +} + +DWORD deleteIpForwardEntry( PMIB_IPFORWARDROW pRoute ) { + TRACE("pRoute %p\n", pRoute); + /* could use SIOCDELRT, not sure I want to */ + FIXME(":stub\n"); + return (DWORD) 0; +} diff --git a/reactos/lib/iphlpapi/route.h b/reactos/lib/iphlpapi/route.h new file mode 100644 index 00000000000..61e83c733be --- /dev/null +++ b/reactos/lib/iphlpapi/route.h @@ -0,0 +1,29 @@ +/* + * iphlpapi dll implementation -- Route function prototypes. + * + * Copyright (C) 2004 Art Yerkes + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef WINE_IPHLP_ROUTE_H_ +#define WINE_IPHLP_ROUTE_H_ + +/* Create a route entry. */ + +DWORD createIpForwardEntry( PMIB_IPFORWARDROW Route ); +DWORD setIpForwardEntry( PMIB_IPFORWARDROW Route ); +DWORD deleteIpForwardEntry( PMIB_IPFORWARDROW Route ); + +#endif/*WINE_IPHLP_ROUTE_H_*/