7 modified files
reactos/drivers/net/tcpip/include
diff -u -r1.4.2.1 -r1.4.2.2
--- route.h 29 Mar 2004 07:01:36 -0000 1.4.2.1
+++ route.h 29 Mar 2004 20:21:15 -0000 1.4.2.2
@@ -55,10 +55,6 @@
NTSTATUS RouteShutdown(
VOID);
-UINT CountRouteNodes( PROUTE_CACHE_NODE Node );
-
-UINT CopyRouteNodes( PROUTE_CACHE_NODE None, PROUTE_CACHE_NODE Target );
-
UINT RouteGetRouteToDestination(
PIP_ADDRESS Destination,
PNET_TABLE_ENTRY NTE,
reactos/drivers/net/tcpip/include
diff -u -r1.3 -r1.3.18.1
--- router.h 4 Jul 2001 20:40:23 -0000 1.3
+++ router.h 29 Mar 2004 20:21:15 -0000 1.3.18.1
@@ -17,7 +17,6 @@
OBJECT_FREE_ROUTINE Free; /* Routine used to free resources for the object */
PIP_ADDRESS NetworkAddress; /* Address of network */
PIP_ADDRESS Netmask; /* Netmask of network */
- PNET_TABLE_ENTRY NTE; /* Pointer to NTE to use */
PNEIGHBOR_CACHE_ENTRY Router; /* Pointer to NCE of router to use */
UINT Metric; /* Cost of this route */
} FIB_ENTRY, *PFIB_ENTRY;
@@ -34,7 +33,6 @@
PFIB_ENTRY RouterAddRoute(
PIP_ADDRESS NetworkAddress,
PIP_ADDRESS Netmask,
- PNET_TABLE_ENTRY NTE,
PNEIGHBOR_CACHE_ENTRY Router,
UINT Metric);
@@ -58,6 +56,10 @@
NTSTATUS RouterShutdown(
VOID);
+UINT CountFIBs();
+
+UINT CopyFIBs( PFIB_ENTRY Target );
+
#endif /* __ROUTER_H */
/* EOF */
reactos/drivers/net/tcpip/network
diff -u -r1.9.4.1 -r1.9.4.2
--- ip.c 29 Mar 2004 07:01:36 -0000 1.9.4.1
+++ ip.c 29 Mar 2004 20:21:15 -0000 1.9.4.2
@@ -792,13 +792,13 @@
/* Reference objects for forward information base */
ReferenceObject(Current->Address);
ReferenceObject(Current->PLE->Prefix);
- ReferenceObject(Current);
+ ReferenceObject(NCE);
+
/* NCE is already referenced */
- if (!RouterAddRoute(Current->Address, Current->PLE->Prefix, Current, NCE, 1)) {
+ if (!RouterAddRoute(Current->Address, Current->PLE->Prefix, NCE, 1)) {
TI_DbgPrint(MIN_TRACE, ("Could not add route due to insufficient resources.\n"));
DereferenceObject(Current->Address);
DereferenceObject(Current->PLE->Prefix);
- DereferenceObject(Current);
DereferenceObject(NCE);
}
reactos/drivers/net/tcpip/network
diff -u -r1.5.2.1 -r1.5.2.2
--- route.c 29 Mar 2004 07:01:37 -0000 1.5.2.1
+++ route.c 29 Mar 2004 20:21:15 -0000 1.5.2.2
@@ -6,6 +6,11 @@
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
* NOTES: The route cache is implemented as a binary search
* tree to obtain fast searches
+ *
+ * This data is not authoritative. It is a searchable cache that allows
+ * quick access to route information to selected hosts. This information
+ * should always defer to the FIB.
+ *
* REVISIONS:
* CSH 01/08-2000 Created
*/
@@ -63,22 +68,6 @@
return 0;
}
-UINT CopyRouteNodes( PROUTE_CACHE_NODE Node, PROUTE_CACHE_NODE Target ) {
- UINT NodeCount, Result = 0;
-
- if( !Node ) Node = RouteCache;
-
- if( IsInternalRCN(Node) ) {
- RtlCopyMemory(Target,Node,sizeof(*Target));
- Target++;
- NodeCount = CopyRouteNodes( Node->Left, Target );
- Target += NodeCount; Result += NodeCount;
- NodeCount = CopyRouteNodes( Node->Right, Target );
- Target += NodeCount; Result += NodeCount;
- }
-
- return Result;
-}
VOID FreeRCN(
PVOID Object)
/*
reactos/drivers/net/tcpip/network
diff -u -r1.5.16.1 -r1.5.16.2
--- router.c 29 Mar 2004 07:01:37 -0000 1.5.16.1
+++ router.c 29 Mar 2004 20:21:15 -0000 1.5.16.2
@@ -4,6 +4,10 @@
* FILE: network/router.c
* PURPOSE: IP routing subsystem
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * NOTES:
+ * This file holds authoritative routing information.
+ * Information queries on the route table should be handled here.
+ * This information should always override the route cache info.
* REVISIONS:
* CSH 01/08-2000 Created
*/
@@ -50,7 +54,6 @@
DereferenceObject(FIBE->NetworkAddress);
DereferenceObject(FIBE->Netmask);
DereferenceObject(FIBE->Router);
- DereferenceObject(FIBE->NTE);
#ifdef DBG
FIBE->RefCount--;
@@ -81,7 +84,7 @@
CurrentEntry = FIBListHead.Flink;
while (CurrentEntry != &FIBListHead) {
NextEntry = CurrentEntry->Flink;
- Current = CONTAINING_RECORD(CurrentEntry, FIB_ENTRY, ListEntry);
+ Current = CONTAINING_RECORD(CurrentEntry, FIB_ENTRY, ListEntry);
/* Destroy the FIB entry */
DestroyFIBE(Current);
CurrentEntry = NextEntry;
@@ -89,6 +92,43 @@
}
+UINT CountFIBs() {
+ 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;
+ CurrentEntry = NextEntry;
+ FibCount++;
+ }
+
+ return FibCount;
+}
+
+
+UINT CopyFIBs( 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;
+ CurrentEntry = NextEntry;
+ FibCount++;
+ }
+
+ return FibCount;
+}
+
+
UINT CommonPrefixLength(
PIP_ADDRESS Address1,
PIP_ADDRESS Address2)
@@ -273,7 +313,6 @@
PFIB_ENTRY RouterAddRoute(
PIP_ADDRESS NetworkAddress,
PIP_ADDRESS Netmask,
- PNET_TABLE_ENTRY NTE,
PNEIGHBOR_CACHE_ENTRY Router,
UINT Metric)
/*
@@ -281,24 +320,23 @@
* ARGUMENTS:
* NetworkAddress = Pointer to address of network
* Netmask = Pointer to netmask of network
- * NTE = Pointer to NTE to use
* Router = Pointer to NCE of router to use
* Metric = Cost of this route
* RETURNS:
* Pointer to FIB entry if the route was added, NULL if not
* NOTES:
- * The FIB entry references the NetworkAddress, Netmask, NTE and
+ * The FIB entry references the NetworkAddress, Netmask and
* the NCE of the router. The caller is responsible for providing
* these references
*/
{
PFIB_ENTRY FIBE;
- TI_DbgPrint(DEBUG_ROUTER, ("Called. NetworkAddress (0x%X) Netmask (0x%X) NTE (0x%X) "
- "Router (0x%X) Metric (%d).\n", NetworkAddress, Netmask, NTE, Router, Metric));
+ TI_DbgPrint(DEBUG_ROUTER, ("Called. NetworkAddress (0x%X) Netmask (0x%X) "
+ "Router (0x%X) Metric (%d).\n", NetworkAddress, Netmask, Router, Metric));
- TI_DbgPrint(DEBUG_ROUTER, ("NetworkAddress (%s) Netmask (%s) NTE (%s) Router (%s).\n",
- A2S(NetworkAddress), A2S(Netmask), A2S(NTE->Address), A2S(Router->Address)));
+ TI_DbgPrint(DEBUG_ROUTER, ("NetworkAddress (%s) Netmask (%s) Router (%s).\n",
+ A2S(NetworkAddress), A2S(Netmask), A2S(Router->Address)));
FIBE = ExAllocatePool(NonPagedPool, sizeof(FIB_ENTRY));
if (!FIBE) {
@@ -306,13 +344,11 @@
return NULL;
}
- INIT_TAG(NTE, TAG('N','T','E',' '));
INIT_TAG(Router, TAG('R','O','U','T'));
FIBE->Free = FreeFIB;
FIBE->NetworkAddress = NetworkAddress;
FIBE->Netmask = Netmask;
- FIBE->NTE = NTE;
FIBE->Router = Router;
FIBE->Metric = Metric;
@@ -478,7 +514,7 @@
ReferenceObject(pNetworkAddress);
ReferenceObject(pNetmask);
- FIBE = RouterAddRoute(pNetworkAddress, pNetmask, NTE, NCE, 1);
+ FIBE = RouterAddRoute(pNetworkAddress, pNetmask, NCE, 1);
if (!FIBE) {
/* Not enough free resources */
NBRemoveNeighbor(NCE);
reactos/drivers/net/tcpip/tcpip
diff -u -r1.5.2.1 -r1.5.2.2
--- info.c 29 Mar 2004 07:01:37 -0000 1.5.2.1
+++ info.c 29 Mar 2004 20:21:15 -0000 1.5.2.2
@@ -42,7 +42,7 @@
TI_DbgPrint(MAX_TRACE, ("Entity %d is an IF. Found %d\n",
i, Count));
}
-
+
EntityList[EntityCount].tei_entity = IF_ENTITY;
EntityList[EntityCount].tei_instance = Count;
EntityList[EntityCount].context = Interface;
reactos/drivers/net/tcpip/tcpip
diff -u -r1.1.2.1 -r1.1.2.2
--- ninfo.c 29 Mar 2004 07:01:37 -0000 1.1.2.1
+++ ninfo.c 29 Mar 2004 20:21:15 -0000 1.1.2.2
@@ -75,10 +75,10 @@
PLIST_ENTRY CurrentIFEntry;
TDI_STATUS Status;
KIRQL OldIrql;
- UINT RtCount = CountRouteNodes( NULL ),
+ UINT RtCount = CountFIBs(),
Size = sizeof( IPROUTE_ENTRY ) * RtCount;
- PROUTE_CACHE_NODE RCache =
- ExAllocatePool( NonPagedPool, sizeof( ROUTE_CACHE_NODE ) * RtCount ),
+ PFIB_ENTRY RCache =
+ ExAllocatePool( NonPagedPool, sizeof( FIB_ENTRY ) * RtCount ),
RCacheCur = RCache;
PIPROUTE_ENTRY RouteEntries = ExAllocatePool( NonPagedPool, Size ),
RtCurrent = RouteEntries;
@@ -94,76 +94,51 @@
RtlZeroMemory( RouteEntries, Size );
- RtCount = CopyRouteNodes( NULL, RCache );
+ RtCount = CopyFIBs( RCache );
while( RtCurrent < RouteEntries + RtCount ) {
-#if 0
- /* We'll see what we're getting where easier this way */
- RtCurrent->Dest = FOURCC('d','e','s','t');
- RtCurrent->Index = FOURCC('i','n','d','x');
- RtCurrent->Metric1 = FOURCC('m','e','t','1');
- RtCurrent->Metric2 = FOURCC('m','e','t','2');
- RtCurrent->Metric3 = FOURCC('m','e','t','3');
- RtCurrent->Metric4 = FOURCC('m','e','t','4');
- RtCurrent->Gw = FOURCC('g','a','t','e');
- RtCurrent->Type = FOURCC('t','y','p','e');
- RtCurrent->Proto = FOURCC('p','r','o','t');
- RtCurrent->Age = FOURCC('a','g','e',' ');
- RtCurrent->Mask = FOURCC('m','a','s','k');
- RtCurrent->Metric5 = FOURCC('m','e','t','5');
- RtCurrent->Info = FOURCC('i','n','f','o');
-#endif
-
/* Copy Desitnation */
- RtlCopyMemory( &RtCurrent->Dest,
- &RCacheCur->Destination.Address.IPv4Address,
- sizeof(RtCurrent->Dest) );
- RtlCopyMemory( &RtCurrent->Gw,
- &RCacheCur->NTE->Address,
- sizeof(RtCurrent->Gw) );
-
- KeAcquireSpinLock(&EntityListLock, &OldIrql);
- for( RtCurrent->Index = EntityCount;
- RtCurrent->Index < EntityMax &&
- RCacheCur->NTE->Interface !=
- EntityList[RtCurrent->Index].context;
- RtCurrent->Index++ );
- KeReleaseSpinLock(&EntityListLock, OldIrql);
-
- if( RCacheCur->NTE && RCacheCur->NTE->PLE )
- RtCurrent->Mask =
- ~((1 << (32 - RCacheCur->NTE->PLE->PrefixLength)) - 1);
- else
- TI_DbgPrint
- (MIN_TRACE,
- ("RCacheCur->NTE : %08x, RCacheCur->NTE->PLE : %08x\n",
- RCacheCur->NTE, RCacheCur->NTE->PLE));
-
- RtCurrent->Metric1 = 1 /* Need to store + get this */;
- RtCurrent->Type = 2 /* PF_INET */;
-
- TI_DbgPrint
- (MAX_TRACE,("RouteEntry %d:\n", RtCurrent - RouteEntries ));
- TI_DbgPrint(MAX_TRACE,("Source Data:\n"));
- TI_DbgPrint(MAX_TRACE,("Destination: %08x\n",
- RCacheCur->Destination.Address.IPv4Address));
- TI_DbgPrint(MAX_TRACE,("NTE: %08x\n"));
- TI_DbgPrint(MAX_TRACE,("NCE: %08x\n"));
- TI_DbgPrint(MAX_TRACE,("Target Data:\n"));
- TI_DbgPrint(MAX_TRACE,("Dest: %08x\n", RtCurrent->Dest));
- TI_DbgPrint(MAX_TRACE,("Index: %08x\n", RtCurrent->Index));
- TI_DbgPrint(MAX_TRACE,("Metric1: %08x\n", RtCurrent->Metric1));
- TI_DbgPrint(MAX_TRACE,("Metric2: %08x\n", RtCurrent->Metric2));
- TI_DbgPrint(MAX_TRACE,("Metric3: %08x\n", RtCurrent->Metric3));
- TI_DbgPrint(MAX_TRACE,("Metric4: %08x\n", RtCurrent->Metric4));
- TI_DbgPrint(MAX_TRACE,("Gw: %08x\n", RtCurrent->Gw));
- TI_DbgPrint(MAX_TRACE,("Type: %08x\n", RtCurrent->Type));
- TI_DbgPrint(MAX_TRACE,("Proto: %08x\n", RtCurrent->Proto));
- TI_DbgPrint(MAX_TRACE,("Age: %08x\n", RtCurrent->Age));
- TI_DbgPrint(MAX_TRACE,("Mask: %08x\n", RtCurrent->Mask));
- TI_DbgPrint(MAX_TRACE,("Metric5: %08x\n", RtCurrent->Metric5));
- TI_DbgPrint(MAX_TRACE,("Info: %08x\n", RtCurrent->Info));
-
+ if( RCacheCur->NetworkAddress && RCacheCur->Netmask &&
+ RCacheCur->Router && RCacheCur->Router->Address ) {
+ TI_DbgPrint(MAX_TRACE, ("%d: NA %08x NM %08x GW %08x MT %d\n",
+ RtCurrent - RouteEntries,
+ RCacheCur->NetworkAddress->Address,
+ RCacheCur->Netmask->Address,
+ RCacheCur->Router->Address->Address,
+ RCacheCur->Metric));
+
+ RtlCopyMemory( &RtCurrent->Dest,
+ &RCacheCur->NetworkAddress->Address,
+ sizeof(RtCurrent->Dest) );
+ RtlCopyMemory( &RtCurrent->Mask,
+ &RCacheCur->Netmask->Address,
+ sizeof(RtCurrent->Mask) );
+ /* Currently, this address is stuffed into the pointer.
+ * That probably is not intended. */
+ RtlCopyMemory( &RtCurrent->Gw,
+ &RCacheCur->Router->Address->Address,
+ sizeof(RtCurrent->Gw) );
+ RtCurrent->Metric1 = RCacheCur->Metric;
+ RtCurrent->Type = 2 /* PF_INET */;
+
+ KeAcquireSpinLock(&EntityListLock, &OldIrql);
+ for( RtCurrent->Index = EntityCount - 1;
+ RtCurrent->Index >= 0 &&
+ RCacheCur->Router->Interface !=
+ EntityList[RtCurrent->Index].context;
+ RtCurrent->Index-- );
+ RtCurrent->Index = EntityList[RtCurrent->Index].tei_instance;
+ KeReleaseSpinLock(&EntityListLock, OldIrql);
+ } else {
+ TI_DbgPrint(MAX_TRACE, ("%d: BAD: NA %08x NM %08x GW %08x MT %d\n",
+ RtCurrent - RouteEntries,
+ RCacheCur->NetworkAddress,
+ RCacheCur->Netmask,
+ RCacheCur->Router,
+ RCacheCur->Router ?
+ RCacheCur->Router->Address : 0,
+ RCacheCur->Metric));
+ }
RtCurrent++; RCacheCur++;
}
CVSspam 0.2.8