9 modified files
reactos/lib/iphlpapi
diff -u -r1.3 -r1.4
--- Makefile.in 5 Mar 2004 04:50:01 -0000 1.3
+++ Makefile.in 26 Nov 2004 00:32:59 -0000 1.4
@@ -4,7 +4,7 @@
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = iphlpapi.dll
-IMPORTS = advapi32 kernel32
+IMPORTS = advapi32 kernel32 rtl
DELAYIMPORTS =
EXTRALIBS =
reactos/lib/iphlpapi
diff -u -r1.2 -r1.3
--- Makefile.ros-template 29 May 2004 21:24:44 -0000 1.2
+++ Makefile.ros-template 26 Nov 2004 00:32:59 -0000 1.3
@@ -1,4 +1,4 @@
-# $Id: Makefile.ros-template,v 1.2 2004/05/29 21:24:44 hbirr Exp $
+# $Id: Makefile.ros-template,v 1.3 2004/11/26 00:32:59 arty Exp $
TARGET_NAME = iphlpapi
@@ -6,7 +6,7 @@
TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__
-TARGET_SDKLIBS = @IMPORTS@ libwine.a advapi32.a kernel32.a ws2_32.a wine_uuid.a ntdll.a
+TARGET_SDKLIBS = @IMPORTS@ libwine.a advapi32.a kernel32.a ws2_32.a wine_uuid.a ntdll.a rtl.a
TARGET_BASE = $(TARGET_BASE_LIB_IPHLPAPI)
reactos/lib/iphlpapi
diff -u -r1.8 -r1.9
--- ifenum_reactos.c 21 Jun 2004 02:21:16 -0000 1.8
+++ ifenum_reactos.c 26 Nov 2004 00:32:59 -0000 1.9
@@ -128,7 +128,7 @@
DWORD allocationSizeForEntityArray = entrySize * MAX_TDI_ENTITIES,
arraySize = entrySize * MAX_TDI_ENTITIES;
- DPRINT("TdiGetSetOfThings(tcpFile %x,toiClass %x,toiType %x,toiId %x,"
+ DbgPrint("TdiGetSetOfThings(tcpFile %x,toiClass %x,toiType %x,toiId %x,"
"teiEntity %x,fixedPart %d,entrySize %d)\n",
(int)tcpFile,
(int)toiClass,
@@ -161,9 +161,8 @@
0,
&allocationSizeForEntityArray,
NULL );
-
+
if( !NT_SUCCESS(status) ) {
- DPRINT("TdiGetSetOfThings() => %08x\n", (int)status);
return status;
}
reactos/lib/iphlpapi
diff -u -r1.4 -r1.5
--- iphlpapi_main.c 25 Feb 2004 20:29:15 -0000 1.4
+++ iphlpapi_main.c 26 Nov 2004 00:32:59 -0000 1.5
@@ -1236,7 +1236,7 @@
if (!pIpNetTable || *pdwSize < size) {
*pdwSize = size;
ret = ERROR_INSUFFICIENT_BUFFER;
- }
+ }
else {
PMIB_IPNETTABLE table = getArpTable();
reactos/lib/iphlpapi
diff -u -r1.4 -r1.5
--- iphlpapi_private.h 5 Mar 2004 04:50:01 -0000 1.4
+++ iphlpapi_private.h 26 Nov 2004 00:32:59 -0000 1.5
@@ -102,12 +102,12 @@
int GetLongestChildKeyName( HANDLE RegHandle );
LONG OpenChildKeyRead( HANDLE RegHandle,
- PCHAR ChildKeyName,
+ PWCHAR ChildKeyName,
PHKEY ReturnHandle );
-PCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n );
-void ConsumeChildKeyName( PCHAR Name );
-PCHAR QueryRegistryValueString( HANDLE RegHandle, PCHAR ValueName );
-void ConsumeRegValueString( PCHAR NameServer );
+PWCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n );
+void ConsumeChildKeyName( PWCHAR Name );
+PWCHAR QueryRegistryValueString( HANDLE RegHandle, PWCHAR ValueName );
+void ConsumeRegValueString( PWCHAR NameServer );
#include <w32api.h>
/* This is here until we switch to version 2.5 of the mingw headers */
reactos/lib/iphlpapi
diff -u -r1.6 -r1.7
--- ipstats_reactos.c 9 Nov 2004 03:22:17 -0000 1.6
+++ ipstats_reactos.c 26 Nov 2004 00:32:59 -0000 1.7
@@ -19,6 +19,7 @@
* tcpip.sys
*/
+#include <roscfg.h>
#include <stdio.h>
#include "iphlpapi_private.h"
reactos/lib/iphlpapi
diff -u -r1.9 -r1.10
--- makefile 25 Feb 2004 07:41:50 -0000 1.9
+++ makefile 26 Nov 2004 00:32:59 -0000 1.10
@@ -8,10 +8,10 @@
TARGET_BASE = 0x777c0000
-TARGET_CFLAGS += -DYDEBUG -DUNICODE -D_UNICODE -D__USE_W32API -D__REACTOS__ -Wall -Werror
+TARGET_CFLAGS += -DYDEBUG -DUNICODE -D_UNICODE -D__USE_W32API -D__REACTOS__ -Wall -Werror -DDBG
# -D_WIN32_WINNT=0x0500
-TARGET_SDKLIBS = ntdll.a kernel32.a ws2_32.a
+TARGET_SDKLIBS = rtl.a ntdll.a kernel32.a ws2_32.a
DEP_OBJECTS = $(TARGET_OBJECTS)
reactos/lib/iphlpapi
diff -u -r1.5 -r1.6
--- registry.c 25 Feb 2004 20:29:15 -0000 1.5
+++ registry.c 26 Nov 2004 00:32:59 -0000 1.6
@@ -6,18 +6,18 @@
LONG Status;
DWORD MaxAdapterName;
- Status = RegQueryInfoKeyA(RegHandle,
- NULL,
- NULL,
- NULL,
- NULL,
- &MaxAdapterName,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL);
+ Status = RegQueryInfoKeyW(RegHandle,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &MaxAdapterName,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
if (Status == ERROR_SUCCESS)
return MaxAdapterName + 1;
else
@@ -25,23 +25,23 @@
}
LONG OpenChildKeyRead( HANDLE RegHandle,
- PCHAR ChildKeyName,
- PHKEY ReturnHandle ) {
- return RegOpenKeyExA( RegHandle,
- ChildKeyName,
- 0,
- KEY_READ,
- ReturnHandle );
+ PWCHAR ChildKeyName,
+ PHKEY ReturnHandle ) {
+ return RegOpenKeyExW( RegHandle,
+ ChildKeyName,
+ 0,
+ KEY_READ,
+ ReturnHandle );
}
/*
* Yields a malloced value that must be freed.
*/
-PCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n ) {
+PWCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n ) {
LONG Status;
int MaxAdapterName = GetLongestChildKeyName( RegHandle );
- PCHAR Value;
+ PWCHAR Value;
DWORD ValueLen;
if (MaxAdapterName == -1) {
@@ -50,9 +50,9 @@
}
ValueLen = MaxAdapterName;
- Value = (PCHAR)HeapAlloc( GetProcessHeap(), 0, MaxAdapterName );
- Status = RegEnumKeyExA( RegHandle, n, Value, &ValueLen,
- NULL, NULL, NULL, NULL );
+ Value = (PWCHAR)HeapAlloc( GetProcessHeap(), 0, MaxAdapterName );
+ Status = RegEnumKeyExW( RegHandle, n, Value, &ValueLen,
+ NULL, NULL, NULL, NULL );
if (Status != ERROR_SUCCESS)
return 0;
else {
@@ -61,27 +61,26 @@
}
}
-void ConsumeChildKeyName( PCHAR Name ) {
+void ConsumeChildKeyName( PWCHAR Name ) {
if (Name) HeapFree( GetProcessHeap(), 0, Name );
}
-PCHAR QueryRegistryValueString( HANDLE RegHandle, PCHAR ValueName ) {
- PCHAR Name;
+PWCHAR QueryRegistryValueString( HANDLE RegHandle, PWCHAR ValueName ) {
+ PWCHAR Name;
DWORD ReturnedSize = 0;
- if (RegQueryValueExA( RegHandle, ValueName, NULL, NULL, NULL,
- &ReturnedSize ) != 0)
+ if (RegQueryValueExW( RegHandle, ValueName, NULL, NULL, NULL,
+ &ReturnedSize ) != 0) {
return 0;
- else {
- Name = malloc( (ReturnedSize + 1) * sizeof(WCHAR) );
- RegQueryValueExA( RegHandle, ValueName, NULL, NULL, (PVOID)Name,
- &ReturnedSize );
- Name[ReturnedSize] = 0;
+ } else {
+ Name = malloc( ReturnedSize );
+ RegQueryValueExW( RegHandle, ValueName, NULL, NULL, (PVOID)Name,
+ &ReturnedSize );
return Name;
}
}
-void ConsumeRegValueString( PCHAR Value ) {
+void ConsumeRegValueString( PWCHAR Value ) {
if (Value) free(Value);
}
reactos/lib/iphlpapi
diff -u -r1.5 -r1.6
--- resinfo_reactos.c 20 Aug 2004 15:19:38 -0000 1.5
+++ resinfo_reactos.c 26 Nov 2004 00:32:59 -0000 1.6
@@ -1,8 +1,9 @@
/*
- * iphlpapi dll implementation -- Auxiliary icmp functions
+ * iphlpapi dll implementation -- Setting and storing route information
*
- * These are stubs for functions that provide a simple ICMP probing API. They
- * will be operating system specific when implemented.
+ * 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
@@ -46,20 +47,238 @@
#include "iphlpapi.h"
#include "wine/debug.h"
-WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
+typedef struct _NAME_SERVER_LIST_PRIVATE {
+ UINT NumServers;
+ UINT CurrentName;
+ PIP_ADDRESS_STRING AddrString;
+} NAME_SERVER_LIST_PRIVATE, *PNAME_SERVER_LIST_PRIVATE;
+
+PVOID STDCALL
+RtlAllocateHeap (
+ HANDLE Heap,
+ ULONG Flags,
+ ULONG Size
+ );
+
+BOOLEAN
+STDCALL
+RtlFreeHeap (
+ HANDLE Heap,
+ ULONG Flags,
+ PVOID Address
+ );
+
+NTSTATUS
+STDCALL
+RtlUnicodeToMultiByteN (
+ PCHAR MbString,
+ ULONG MbSize,
+ PULONG ResultSize,
+ PWCHAR UnicodeString,
+ ULONG UnicodeSize
+ );
+
+typedef VOID (*EnumNameServersFunc)( PWCHAR Interface,
+ PWCHAR NameServer,
+ PVOID Data );
+typedef VOID (*EnumInterfacesFunc)( HKEY ChildKeyHandle,
+ PWCHAR ChildKeyName,
+ PVOID Data );
+
+/*
+ * EnumInterfaces
+ *
+ * Call the enumeration function for each name server.
+ */
+
+static void EnumInterfaces( PVOID Data, EnumInterfacesFunc cb ) {
+ HKEY RegHandle, TcpipHandle;
+ HKEY ChildKeyHandle = 0;
+ PWCHAR RegKeyToEnumerate =
+ L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces";
+ PWCHAR RegKeyForTcpip =
+ L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters";
+ 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 );
+ }
+}
+
+/*
+ * 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(ch - LastNameStart + 1);
+ if (NameServer) {
+ memcpy(NameServer,NameServerString + LastNameStart,
+ (ch - LastNameStart));
+ 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(ch - LastNameStart + 1);
+ memcpy(NameServer,NameServerString + LastNameStart,
+ (ch - LastNameStart));
+ NameServer[ch - LastNameStart] = 0;
+ cb( Interface, NameServer, Data );
+ free(NameServer);
+ }
+ ConsumeRegValueString(NameServerString);
+ }
+}
+
+static void CreateNameServerListEnumNamesFuncCount( PWCHAR Interface,
+ PWCHAR Server,
+ PVOID _Data ) {
+ PNAME_SERVER_LIST_PRIVATE Data = (PNAME_SERVER_LIST_PRIVATE)_Data;
+ Data->NumServers++;
+}
+
+static void CreateNameServerListEnumIfFuncCount( HKEY 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;
+ RtlUnicodeToMultiByteN((PCHAR)&Data->AddrString[Data->CurrentName],
+ sizeof(Data->AddrString[0]),
+ NULL,
+ Server,
+ wcslen(Server));
+ Data->CurrentName++;
+}
+
+static void CreateNameServerListEnumIfFunc( HKEY 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);
+}
PIPHLP_RES_INFO getResInfo() {
- PIPHLP_RES_INFO InfoPtr =
- (PIPHLP_RES_INFO)HeapAlloc( GetProcessHeap(), 0,
- sizeof(PIPHLP_RES_INFO) );
- if( InfoPtr ) {
- InfoPtr->riCount = 0;
- InfoPtr->riAddressList = NULL;
+ DWORD result = ERROR_SUCCESS, dwSize, i, ServerCount, ExtraServer;
+ HKEY hKey;
+ LONG errCode;
+ PWCHAR Str;
+ IP_ADDR_STRING AddrString;
+ NAME_SERVER_LIST_PRIVATE PrivateNSEnum = { 0 };
+ PIPHLP_RES_INFO ResInfo;
+ struct sockaddr_in *AddrList;
+
+ ServerCount = CountNameServers( &PrivateNSEnum );
+
+ errCode = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
+ "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\"
+ "Parameters", 0, KEY_READ, &hKey);
+ if (errCode != ERROR_SUCCESS) {
+ RegCloseKey( hKey );
+ return NULL;
+ }
+
+ Str = QueryRegistryValueString( hKey, L"NameServer" );
+ ExtraServer = Str ? 1 : 0;
+
+ ServerCount += ExtraServer;
+
+ PrivateNSEnum.NumServers = ServerCount;
+ PrivateNSEnum.AddrString =
+ (PIP_ADDRESS_STRING)
+ RtlAllocateHeap( GetProcessHeap(), 0,
+ ServerCount * sizeof(IP_ADDRESS_STRING) );
+
+ ResInfo =
+ (PIPHLP_RES_INFO)RtlAllocateHeap
+ ( GetProcessHeap(), 0,
+ sizeof(IPHLP_RES_INFO) +
+ (ServerCount * sizeof(struct sockaddr_in)) );
+
+ if( !ResInfo ) {
+ RtlFreeHeap( GetProcessHeap(), 0, PrivateNSEnum.AddrString );
+ RegCloseKey( hKey );
+ return NULL;
+ }
+
+ ResInfo->riCount = ServerCount;
+ AddrList = (struct sockaddr_in *)
+ (((PCHAR)ResInfo) + sizeof(IPHLP_RES_INFO));
+ ResInfo->riAddressList = AddrList;
+
+ MakeNameServerList( &PrivateNSEnum );
+
+ if( ExtraServer ) {
+ ULONG ResultSize;
+
+ for( ResultSize = 0; Str[ResultSize]; ResultSize++ )
+ ((PCHAR)&AddrString)[ResultSize] = Str[ResultSize];
+
+ ((PCHAR)&AddrString)[ResultSize] = 0;
+ ResInfo->riAddressList[0].sin_family = AF_INET;
+ ResInfo->riAddressList[0].sin_addr.s_addr =
+ inet_addr( (PCHAR)&AddrString );
+ ResInfo->riAddressList[0].sin_port = 0;
+ ConsumeRegValueString( Str );
+ }
+
+ for( i = ExtraServer; i < ServerCount; i++ ) {
+ /* Hmm seems that dns servers are always AF_INET but ... */
+ ResInfo->riAddressList[i].sin_family = AF_INET;
+ ResInfo->riAddressList[i].sin_addr.s_addr =
+ inet_addr( (PCHAR)&PrivateNSEnum.AddrString[i - ExtraServer] );
+ ResInfo->riAddressList[i].sin_port = 0;
}
+
+ RtlFreeHeap( GetProcessHeap(), 0, PrivateNSEnum.AddrString );
+ RegCloseKey( hKey );
- return InfoPtr;
+ return ResInfo;
}
VOID disposeResInfo( PIPHLP_RES_INFO InfoPtr ) {
- HeapFree( GetProcessHeap(), 0, InfoPtr );
+ RtlFreeHeap( GetProcessHeap(), 0, InfoPtr );
}
CVSspam 0.2.8