Commit in reactos/drivers/net on MAIN
ndis/ndis/protocol.c+9-111.20 -> 1.21
         /miniport.c+7-21.40 -> 1.41
tcpip/datalink/lan.c+3-11.26 -> 1.27
+19-14
3 modified files
Patch to correct multiple adapter bind from protocols.  There were two
bugs here:
1) The loop in protocol.c was wrong and was rewritten by Andrew Munger
   with help from Thomas Weidenmueller
2) MiniLocateAdapter never zeroed Adapter if the adapter didn't match,
   and never actually ever matched a name.  It always returned the
   last adapter in the list (spotted and fixed after the above fixes).

reactos/drivers/net/ndis/ndis
protocol.c 1.20 -> 1.21
diff -u -r1.20 -r1.21
--- protocol.c	15 Aug 2004 23:12:33 -0000	1.20
+++ protocol.c	21 Nov 2004 04:20:38 -0000	1.21
@@ -395,7 +395,7 @@
     IN  NDIS_HANDLE         MacReceiveContext,
     IN  UINT                ByteOffset,
     IN  UINT                BytesToTransfer,
-    IN  OUT	PNDIS_PACKET    Packet,
+    IN  OUT PNDIS_PACKET    Packet,
     OUT PUINT               BytesTransferred)
 /*
  * FUNCTION: Forwards a request to copy received data into a protocol-supplied packet
@@ -661,8 +661,8 @@
   UINT MinSize;
   HANDLE DriverKeyHandle = NULL;
   PKEY_VALUE_PARTIAL_INFORMATION KeyInformation = NULL;
-  UINT DataOffset = 0;
-
+  WCHAR *CurrentStr;
+  
   NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
 
   /* first validate the PROTOCOL_CHARACTERISTICS */
@@ -807,8 +807,7 @@
       }
   }
 
-  DataOffset = 0;
-  while((KeyInformation->Data)[DataOffset])
+    for(CurrentStr = (WCHAR*)&KeyInformation->Data[0]; *CurrentStr != '\0'; CurrentStr += wcslen(CurrentStr) + 1)
     {
       /* BindContext is for tracking pending binding operations */
       VOID *BindContext = 0;
@@ -817,7 +816,7 @@
       WCHAR *RegistryPathStr = NULL;
       ULONG PathLength = 0;
 
-      RtlInitUnicodeString(&DeviceName, (WCHAR *)KeyInformation->Data);	/* we know this is 0-term */
+      RtlInitUnicodeString(&DeviceName, CurrentStr);   /* we know this is 0-term */
 
       /*
        * RegistryPath should be:
@@ -828,7 +827,7 @@
        */
 
       PathLength = sizeof(SERVICES_KEY) +                               /* \Registry\Machine\System\CurrentControlSet\Services\ */
-          wcslen( ((WCHAR *)KeyInformation->Data)+8 ) * sizeof(WCHAR) + /* Adapter1  (extracted from \Device\Adapter1)          */
+          wcslen( CurrentStr+8 ) * sizeof(WCHAR) +			/* Adapter1  (extracted from \Device\Adapter1)          */
           sizeof(PARAMETERS_KEY) +                                      /* \Parameters\                                         */
           ProtocolCharacteristics->Name.Length;                         /* Tcpip                                                */
 
@@ -843,7 +842,7 @@
         }
 
       wcscpy(RegistryPathStr, SERVICES_KEY);
-      wcscat(RegistryPathStr, (((WCHAR *)(KeyInformation->Data)) +8 ));
+      wcscat(RegistryPathStr, CurrentStr +8 );
       wcscat(RegistryPathStr, PARAMETERS_KEY);
       wcsncat(RegistryPathStr, ProtocolCharacteristics->Name.Buffer, ProtocolCharacteristics->Name.Length / sizeof(WCHAR) );
 
@@ -873,6 +872,7 @@
         {
           /* Put protocol binding struct on global list */
           ExInterlockedInsertTailList(&ProtocolListHead, &Protocol->ListEntry, &ProtocolListLock);
+	  NDIS_DbgPrint(MAX_TRACE, ("Added to global list.\n"));
         }
 
       /*
@@ -881,10 +881,8 @@
           // what to do here?
         }
        */
-
-      DataOffset += wcslen((WCHAR *)KeyInformation->Data);
     }
-
+  NDIS_DbgPrint(MAX_TRACE, ("Leaving..\n"));
   *Status             = NDIS_STATUS_SUCCESS;
 }
 

reactos/drivers/net/ndis/ndis
miniport.c 1.40 -> 1.41
diff -u -r1.40 -r1.41
--- miniport.c	21 Nov 2004 03:02:57 -0000	1.40
+++ miniport.c	21 Nov 2004 04:20:38 -0000	1.41
@@ -546,6 +546,7 @@
   KIRQL OldIrql;
   PLIST_ENTRY CurrentEntry;
   PLOGICAL_ADAPTER Adapter = 0;
+  UNICODE_STRING ToCompare;
 
   ASSERT(AdapterName);
 
@@ -569,15 +570,19 @@
 
               ASSERT(Adapter);
 
-              NDIS_DbgPrint(DEBUG_MINIPORT, ("AdapterName = %wZ\n", &AdapterName));
+              NDIS_DbgPrint(DEBUG_MINIPORT, ("AdapterName = %wZ\n", AdapterName));
               NDIS_DbgPrint(DEBUG_MINIPORT, ("DeviceName = %wZ\n", &Adapter->DeviceName));
+	      ToCompare = *AdapterName;
+	      if( ToCompare.Length > Adapter->DeviceName.Length )
+		  ToCompare.Length = Adapter->DeviceName.Length;
 
-              if (RtlCompareUnicodeString(AdapterName, &Adapter->DeviceName, TRUE) == 0) 
+              if (RtlCompareUnicodeString(&ToCompare, &Adapter->DeviceName, TRUE) == 0) 
                 {
                   ReferenceObject(Adapter);
                   break;
                 }
 
+	      Adapter = 0;
               CurrentEntry = CurrentEntry->Flink;
             }
         } while (0);

reactos/drivers/net/tcpip/datalink
lan.c 1.26 -> 1.27
diff -u -r1.26 -r1.27
--- lan.c	16 Nov 2004 18:07:57 -0000	1.26
+++ lan.c	21 Nov 2004 04:20:38 -0000	1.27
@@ -387,6 +387,8 @@
     {
 	if (NdisStatus == NDIS_STATUS_SUCCESS)
         {
+	    ASSERT(PacketSize <= Adapter->MTU);
+
             NdisTransferData(&NdisStatus, Adapter->NdisHandle,
                              MacReceiveContext, 0, PacketSize, 
 			     NdisPacket, &BytesTransferred);
@@ -470,7 +472,7 @@
 {
 	/* XXX confirm that this is still true, or re-word the following comment */
 	/* we get to ignore BindContext because we will never pend an operation with NDIS */
-	TI_DbgPrint(DEBUG_DATALINK, ("Called with registry path %wZ\n", SystemSpecific1));
+	TI_DbgPrint(DEBUG_DATALINK, ("Called with registry path %wZ for %wZ\n", SystemSpecific1, DeviceName));
 	*Status = LANRegisterAdapter(DeviceName, SystemSpecific1);
 }
 
CVSspam 0.2.8