Author: cgutman
Date: Sat Oct 4 16:31:36 2008
New Revision: 36648
URL:
http://svn.reactos.org/svn/reactos?rev=36648&view=rev
Log:
- Properly implement MiniIndicateReceivePacket
Modified:
branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c
Modified: branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
==============================================================================
--- branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c [iso-8859-1]
(original)
+++ branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c [iso-8859-1] Sat Oct
4 16:31:36 2008
@@ -235,60 +235,43 @@
VOID NTAPI
MiniIndicateReceivePacket(
- IN NDIS_HANDLE Miniport,
+ IN NDIS_HANDLE MiniportAdapterHandle,
IN PPNDIS_PACKET PacketArray,
IN UINT NumberOfPackets)
/*
* FUNCTION: receives miniport packet array indications
* ARGUMENTS:
- * Miniport: Miniport handle for the adapter
+ * MiniportAdapterHandle: Miniport handle for the adapter
* PacketArray: pointer to a list of packet pointers to indicate
* NumberOfPackets: number of packets to indicate
- * NOTES:
- * - This currently is a big temporary hack. In the future this should
- * call ProtocolReceivePacket() on each bound protocol if it exists.
- * For now it just mimics NdisMEthIndicateReceive.
- */
-{
+ *
+ */
+{
+ PLOGICAL_ADAPTER Adapter = MiniportAdapterHandle;
+ PLIST_ENTRY CurrentEntry;
+ PADAPTER_BINDING AdapterBinding;
+ KIRQL OldIrql;
UINT i;
- for(i = 0; i < NumberOfPackets; i++)
- {
- PCHAR PacketBuffer = 0;
- UINT PacketLength = 0;
- PNDIS_BUFFER NdisBuffer = 0;
-
-#define PACKET_TAG (('k' << 24) + ('P' << 16) + ('D'
<< 8) + 'N')
-
- NdisAllocateMemoryWithTag((PVOID)&PacketBuffer, 1518, PACKET_TAG);
- if(!PacketBuffer)
- {
- NDIS_DbgPrint(MIN_TRACE, ("insufficient resources\n"));
- return;
- }
-
- NdisQueryPacket(PacketArray[i], NULL, NULL, &NdisBuffer, NULL);
-
- while(NdisBuffer)
- {
- PNDIS_BUFFER CurrentBuffer;
- PVOID BufferVa;
- UINT BufferLen;
-
- NdisQueryBuffer(NdisBuffer, &BufferVa, &BufferLen);
- memcpy(PacketBuffer + PacketLength, BufferVa, BufferLen);
- PacketLength += BufferLen;
-
- CurrentBuffer = NdisBuffer;
- NdisGetNextBuffer(CurrentBuffer, &NdisBuffer);
- }
-
- NDIS_DbgPrint(MID_TRACE, ("indicating a %d-byte packet\n",
PacketLength));
-
- MiniIndicateData(Miniport, NULL, PacketBuffer, 14, PacketBuffer+14,
PacketLength-14, PacketLength-14);
-
- NdisFreeMemory(PacketBuffer, 0, 0);
- }
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+
+ CurrentEntry = Adapter->ProtocolListHead.Flink;
+
+ while (CurrentEntry != &Adapter->ProtocolListHead)
+ {
+ AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING,
AdapterListEntry);
+
+ for (i = 0; i < NumberOfPackets; i++)
+ {
+ (*AdapterBinding->ProtocolBinding->Chars.ReceivePacketHandler)(
+ AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
+ PacketArray[i]);
+ }
+
+ CurrentEntry = CurrentEntry->Flink;
+ }
+
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
}