Author: cgutman
Date: Fri Oct 9 07:18:35 2009
New Revision: 43339
URL:
http://svn.reactos.org/svn/reactos?rev=43339&view=rev
Log:
- Fix some typos from my last commit
- Remove more hacks from iphlpapi
Modified:
trunk/reactos/dll/win32/iphlpapi/ipstats_reactos.c
trunk/reactos/dll/win32/iphlpapi/route_reactos.c
trunk/reactos/drivers/network/tcpip/include/info.h
trunk/reactos/drivers/network/tcpip/include/router.h
trunk/reactos/drivers/network/tcpip/tcpip/info.c
trunk/reactos/drivers/network/tcpip/tcpip/ninfo.c
trunk/reactos/lib/drivers/ip/network/router.c
Modified: trunk/reactos/dll/win32/iphlpapi/ipstats_reactos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/iphlpapi/ipstats…
==============================================================================
--- trunk/reactos/dll/win32/iphlpapi/ipstats_reactos.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/iphlpapi/ipstats_reactos.c [iso-8859-1] Fri Oct 9 07:18:35
2009
@@ -423,7 +423,6 @@
{
RouteTable *out_route_table;
DWORD numRoutes = getNumRoutes(), routesAdded = 0;
- IPSNMPInfo snmpInfo;
TDIEntityID ent;
HANDLE tcpFile;
NTSTATUS status = openTcpFile( &tcpFile );
@@ -444,31 +443,28 @@
out_route_table->numRoutes = numRoutes;
- for( i = 0; routesAdded < numRoutes; i++ ) {
+ for( i = 0; routesAdded < out_route_table->numRoutes; i++ ) {
int j;
IPRouteEntry *route_set;
getNthIpEntity( tcpFile, i, &ent );
- tdiGetMibForIpEntity( tcpFile, &ent, &snmpInfo );
-
- TRACE( "%d routes in instance %d\n", snmpInfo.ipsi_numroutes, i );
tdiGetRoutesForIpEntity( tcpFile, &ent, &route_set, &numRoutes );
-
+
if( !route_set ) {
closeTcpFile( tcpFile );
HeapFree( GetProcessHeap(), 0, out_route_table );
return 0;
}
- TRACE("Route set returned\n");
+ TRACE( "%d routes in instance %d\n", numRoutes, i );
#if 0
HexDump( route_set,
sizeof( IPRouteEntry ) *
snmpInfo.ipsi_numroutes );
#endif
- for( j = 0; j < snmpInfo.ipsi_numroutes; j++ ) {
+ for( j = 0; j < numRoutes; j++ ) {
int routeNum = j + routesAdded;
out_route_table->routes[routeNum].dest =
route_set[j].ire_dest;
@@ -484,7 +480,7 @@
if( route_set ) tdiFreeThingSet( route_set );
- routesAdded += snmpInfo.ipsi_numroutes;
+ routesAdded += numRoutes;
}
closeTcpFile( tcpFile );
Modified: trunk/reactos/dll/win32/iphlpapi/route_reactos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/iphlpapi/route_r…
==============================================================================
--- trunk/reactos/dll/win32/iphlpapi/route_reactos.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/iphlpapi/route_reactos.c [iso-8859-1] Fri Oct 9 07:18:35
2009
@@ -64,14 +64,14 @@
TRACE("Called.\n");
if( NT_SUCCESS(status) ) {
- status = getNthIpEntity( tcpFile, 0, &id );
+ status = getNthIpEntity( tcpFile, pRoute->dwForwardIfIndex, &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_ARPTABLE_ENTRY_ID;
req.Req.ID.toi_entity.tei_instance = id.tei_instance;
- req.Req.ID.toi_entity.tei_instance = CL_NL_ENTITY;
+ req.Req.ID.toi_entity.tei_entity = CL_NL_ENTITY;
req.Req.BufferSize = sizeof(*rte);
rte =
(IPRouteEntry *)&req.Req.Buffer[0];
@@ -129,7 +129,7 @@
TRACE("Called.\n");
if( NT_SUCCESS(status) ) {
- status = getNthIpEntity( tcpFile, 0, &id );
+ status = getNthIpEntity( tcpFile, pRoute->dwForwardIfIndex, &id );
if( NT_SUCCESS(status) ) {
req.Req.ID.toi_class = INFO_CLASS_PROTOCOL;
Modified: trunk/reactos/drivers/network/tcpip/include/info.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/info.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/info.h [iso-8859-1] Fri Oct 9 07:18:35
2009
@@ -152,13 +152,15 @@
PUINT BufferSize);
TDI_STATUS InfoTdiQueryGetIPSnmpInfo( TDIEntityID ID,
+ PIP_INTERFACE IF,
PNDIS_BUFFER Buffer,
PUINT BufferSize );
-TDI_STATUS InfoTdiQueryGetRouteTable( PNDIS_BUFFER Buffer,
+TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF,
+ PNDIS_BUFFER Buffer,
PUINT BufferSize );
-TDI_STATUS InfoTdiSetRoute(PIPROUTE_ENTRY Route);
+TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF, PIPROUTE_ENTRY Route);
TDI_STATUS InfoTdiQueryGetArptableMIB(TDIEntityID ID,
PIP_INTERFACE Interface,
Modified: trunk/reactos/drivers/network/tcpip/include/router.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/router.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/router.h [iso-8859-1] Fri Oct 9 07:18:35
2009
@@ -43,9 +43,9 @@
NTSTATUS RouterShutdown(
VOID);
-UINT CountFIBs(VOID);
+UINT CountFIBs(PIP_INTERFACE IF);
-UINT CopyFIBs( PFIB_ENTRY Target );
+UINT CopyFIBs( PIP_INTERFACE IF, PFIB_ENTRY Target );
#endif /* __ROUTER_H */
Modified: trunk/reactos/drivers/network/tcpip/tcpip/info.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/info.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/info.c [iso-8859-1] Fri Oct 9 07:18:35
2009
@@ -188,7 +188,10 @@
return TDI_INVALID_PARAMETER;
else if (ID->toi_entity.tei_entity == CL_NL_ENTITY ||
ID->toi_entity.tei_entity == CO_NL_ENTITY)
- return InfoTdiQueryGetIPSnmpInfo(ID->toi_entity, Buffer,
BufferSize);
+ if ((EntityListContext = GetContext(ID->toi_entity)))
+ return InfoTdiQueryGetIPSnmpInfo(ID->toi_entity,
EntityListContext, Buffer, BufferSize);
+ else
+ return TDI_INVALID_PARAMETER;
else
return TDI_INVALID_PARAMETER;
@@ -214,7 +217,10 @@
return TDI_INVALID_PARAMETER;
else if (ID->toi_entity.tei_entity == CO_NL_ENTITY ||
ID->toi_entity.tei_entity == CL_NL_ENTITY)
- return InfoTdiQueryGetRouteTable(Buffer, BufferSize);
+ if ((EntityListContext = GetContext(ID->toi_entity)))
+ return InfoTdiQueryGetRouteTable(EntityListContext, Buffer,
BufferSize);
+ else
+ return TDI_INVALID_PARAMETER;
else
return TDI_INVALID_PARAMETER;
@@ -251,20 +257,25 @@
* Status of operation
*/
{
+ PVOID EntityListContext;
+
switch (ID->toi_class)
{
case INFO_CLASS_PROTOCOL:
switch (ID->toi_id)
{
case IP_MIB_ARPTABLE_ENTRY_ID:
- if (ID->toi_id != INFO_TYPE_PROVIDER)
+ if (ID->toi_type != INFO_TYPE_PROVIDER)
return TDI_INVALID_PARAMETER;
if (ID->toi_entity.tei_entity != CL_NL_ENTITY &&
ID->toi_entity.tei_entity != CO_NL_ENTITY)
return TDI_INVALID_PARAMETER;
- return InfoTdiSetRoute((PIPROUTE_ENTRY)Buffer);
+ if ((EntityListContext = GetContext(ID->toi_entity)))
+ return InfoTdiSetRoute(EntityListContext, (PIPROUTE_ENTRY)Buffer);
+ else
+ return TDI_INVALID_PARAMETER;
default:
return TDI_INVALID_REQUEST;
Modified: trunk/reactos/drivers/network/tcpip/tcpip/ninfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/ninfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/ninfo.c [iso-8859-1] Fri Oct 9 07:18:35
2009
@@ -16,16 +16,17 @@
/* Get IPRouteEntry s for each of the routes in the system */
-TDI_STATUS InfoTdiQueryGetRouteTable( PNDIS_BUFFER Buffer, PUINT BufferSize ) {
+TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF, PNDIS_BUFFER Buffer, PUINT
BufferSize ) {
TDI_STATUS Status;
KIRQL OldIrql;
- UINT RtCount = CountFIBs();
+ UINT RtCount = CountFIBs(IF);
UINT Size = sizeof( IPROUTE_ENTRY ) * RtCount;
PFIB_ENTRY RCache =
exAllocatePool( NonPagedPool, sizeof( FIB_ENTRY ) * RtCount ),
RCacheCur = RCache;
PIPROUTE_ENTRY RouteEntries = exAllocatePool( NonPagedPool, Size ),
RtCurrent = RouteEntries;
+ UINT i;
TI_DbgPrint(DEBUG_INFO, ("Called, routes = %d, RCache = %08x\n",
RtCount, RCache));
@@ -38,7 +39,7 @@
RtlZeroMemory( RouteEntries, Size );
- RtCount = CopyFIBs( RCache );
+ RtCount = CopyFIBs( IF, RCache );
while( RtCurrent < RouteEntries + RtCount ) {
ASSERT(RCacheCur->Router);
@@ -66,13 +67,15 @@
RtCurrent->Metric1 ));
TcpipAcquireSpinLock(&EntityListLock, &OldIrql);
- for( RtCurrent->Index = EntityCount;
- RtCurrent->Index > 0 &&
- RCacheCur->Router->Interface !=
- EntityList[RtCurrent->Index - 1].context;
- RtCurrent->Index-- );
-
- RtCurrent->Index = EntityList[RtCurrent->Index - 1].tei_instance;
+ for (i = 0; i < EntityCount; i++)
+ if (EntityList[i].context == IF)
+ break;
+
+ if (i < EntityCount)
+ RtCurrent->Index = EntityList[i].tei_instance;
+ else
+ RtCurrent->Index = 0;
+
TcpipReleaseSpinLock(&EntityListLock, OldIrql);
RtCurrent++; RCacheCur++;
@@ -146,11 +149,12 @@
}
TDI_STATUS InfoTdiQueryGetIPSnmpInfo( TDIEntityID ID,
+ PIP_INTERFACE IF,
PNDIS_BUFFER Buffer,
PUINT BufferSize ) {
IPSNMP_INFO SnmpInfo;
UINT IfCount = CountInterfaces();
- UINT RouteCount = CountFIBs();
+ UINT RouteCount = CountFIBs(IF);
TDI_STATUS Status = TDI_INVALID_REQUEST;
TI_DbgPrint(DEBUG_INFO, ("Called.\n"));
@@ -169,10 +173,9 @@
return Status;
}
-TDI_STATUS InfoTdiSetRoute(PIPROUTE_ENTRY Route)
+TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF, PIPROUTE_ENTRY Route)
{
IP_ADDRESS Address, Netmask, Router;
- PNEIGHBOR_CACHE_ENTRY NCE;
AddrInitIPv4( &Address, Route->Dest );
AddrInitIPv4( &Netmask, Route->Mask );
@@ -180,13 +183,8 @@
if( Route->Type == IP_ROUTE_TYPE_ADD ) { /* Add the route */
TI_DbgPrint(DEBUG_INFO,("Adding route (%s)\n", A2S(&Address)));
- /* Find the existing route this belongs to */
- NCE = RouterGetRoute( &Router );
- if (!NCE) return TDI_INVALID_PARAMETER;
-
- /* Really add the route */
if (!RouterCreateRoute( &Address, &Netmask, &Router,
- NCE->Interface, Route->Metric1))
+ IF, Route->Metric1))
return TDI_NO_RESOURCES;
return TDI_SUCCESS;
Modified: trunk/reactos/lib/drivers/ip/network/router.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/rou…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/router.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/router.c [iso-8859-1] Fri Oct 9 07:18:35 2009
@@ -99,37 +99,41 @@
}
-UINT CountFIBs() {
+UINT CountFIBs(PIP_INTERFACE IF) {
UINT FibCount = 0;
PLIST_ENTRY CurrentEntry;
PLIST_ENTRY NextEntry;
-
- /* Search the list and remove every FIB entry we find */
- CurrentEntry = FIBListHead.Flink;
- while (CurrentEntry != &FIBListHead) {
- NextEntry = CurrentEntry->Flink;
+ PFIB_ENTRY Current;
+
+ CurrentEntry = FIBListHead.Flink;
+ while (CurrentEntry != &FIBListHead) {
+ NextEntry = CurrentEntry->Flink;
+ Current = CONTAINING_RECORD(CurrentEntry, FIB_ENTRY, ListEntry);
+ if (Current->Router->Interface == IF)
+ FibCount++;
CurrentEntry = NextEntry;
- FibCount++;
}
return FibCount;
}
-UINT CopyFIBs( PFIB_ENTRY Target ) {
+UINT CopyFIBs( PIP_INTERFACE IF, PFIB_ENTRY Target ) {
UINT FibCount = 0;
PLIST_ENTRY CurrentEntry;
PLIST_ENTRY NextEntry;
PFIB_ENTRY Current;
- /* Search the list and remove every FIB entry we find */
CurrentEntry = FIBListHead.Flink;
while (CurrentEntry != &FIBListHead) {
NextEntry = CurrentEntry->Flink;
Current = CONTAINING_RECORD(CurrentEntry, FIB_ENTRY, ListEntry);
- Target[FibCount] = *Current;
+ if (Current->Router->Interface == IF)
+ {
+ Target[FibCount] = *Current;
+ FibCount++;
+ }
CurrentEntry = NextEntry;
- FibCount++;
}
return FibCount;