Commit in reactos/drivers/lib/ip/network on MAIN
neighbor.c+1-11.5 -> 1.6
route.c-131.3 -> 1.4
router.c+17-211.6 -> 1.7
+18-35
3 modified files
Removed RouteFriendlyAddRoute.  Not needed.
Router now chooses a route correctly:
- Only choose a route if the prefix length is greater than or equal to the
  netmask. for the target route.  (We still choose the most specific route).
- Changed NBAddNeighbor to NBFindOrCreateNeighbor in 
  RouteAddRouteToDestination because it triggers an ARP probe.  Setting the
  ARP cache state initially to PROBE skips the first ARP query and runs a 
  bit afoul of the cache entry state machine.

reactos/drivers/lib/ip/network
neighbor.c 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- neighbor.c	25 Nov 2004 23:56:58 -0000	1.5
+++ neighbor.c	26 Nov 2004 20:32:54 -0000	1.6
@@ -129,7 +129,7 @@
         /* FIXME: Probe state */
         TI_DbgPrint(DEBUG_NCACHE, ("NCE probe state.\n"));
         break;
-	
+
     default:
         /* Should not happen since the event timer is not used in the other states */
         TI_DbgPrint(MIN_TRACE, ("Invalid NCE state (%d).\n", NCE->State));

reactos/drivers/lib/ip/network
route.c 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- route.c	25 Nov 2004 23:56:58 -0000	1.3
+++ route.c	26 Nov 2004 20:32:54 -0000	1.4
@@ -607,17 +607,4 @@
     TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
 }
 
-NTSTATUS
-RouteFriendlyAddRoute( PIPROUTE_ENTRY ire ) {
-    KIRQL OldIrql;
-    
-
-    /* Find IF */
-    TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
-    //RouteAddRouteToDestination(&Dest,Nte,If,Nce);
-    TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
-
-    return STATUS_SUCCESS;
-}
-
 /* EOF */

reactos/drivers/lib/ip/network
router.c 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- router.c	26 Nov 2004 06:55:17 -0000	1.6
+++ router.c	26 Nov 2004 20:32:54 -0000	1.7
@@ -227,7 +227,7 @@
     PLIST_ENTRY NextEntry;
     PFIB_ENTRY Current;
     UCHAR State, BestState = 0;
-    UINT Length, BestLength = 0;
+    UINT Length, BestLength = 0, MaskLength;
     PNEIGHBOR_CACHE_ENTRY NCE, BestNCE = NULL;
 
     TI_DbgPrint(DEBUG_ROUTER, ("Called. Destination (0x%X)\n", Destination));
@@ -244,25 +244,18 @@
         NCE   = Current->Router;
         State = NCE->State;
 
-	if (Destination)
-	    Length = CommonPrefixLength(Destination, &NCE->Address);
-	else
-	    Length = 0;
+	Length = CommonPrefixLength(Destination, &Current->NetworkAddress);
+	MaskLength = AddrCountPrefixBits(&Current->Netmask);
+
+	TI_DbgPrint(DEBUG_ROUTER,("This-Route: %s (Sharing %d bits)\n", 
+				  A2S(&NCE->Address), Length));
 	
-	if (BestNCE) {
-	    if ((State  > BestState)  || 
-		((State == BestState) &&
-		 (Length > BestLength))) {
-		/* This seems to be a better router */
-		BestNCE    = NCE;
-		BestLength = Length;
-		BestState  = State;
-	    }
-	} else {
-	    /* First suitable router found, save it */
+	if(Length >= MaskLength && Length > BestLength) {
+	    /* This seems to be a better router */
 	    BestNCE    = NCE;
 	    BestLength = Length;
 	    BestState  = State;
+	    TI_DbgPrint(DEBUG_ROUTER,("Route selected\n"));
 	}
 
         CurrentEntry = NextEntry;
@@ -270,6 +263,12 @@
 
     TcpipReleaseSpinLock(&FIBLock, OldIrql);
 
+    if( BestNCE ) {
+	TI_DbgPrint(DEBUG_ROUTER,("Routing to %s\n", A2S(&BestNCE->Address)));
+    } else {
+	TI_DbgPrint(DEBUG_ROUTER,("Packet won't be routed\n"));
+    }
+
     return BestNCE;
 }
 
@@ -349,11 +348,8 @@
     PFIB_ENTRY FIBE;
 
     /* The NCE references RouterAddress. The NCE is referenced for us */
-    NCE = NBAddNeighbor(Interface,
-                        RouterAddress,
-                        NULL,
-                        Interface->AddressLength,
-                        NUD_PROBE);
+    NCE = NBFindOrCreateNeighbor(Interface, RouterAddress);
+
     if (!NCE) {
         /* Not enough free resources */
         return NULL;
CVSspam 0.2.8