NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
{
- BufferedLength = CopyPacketToBuffer(LookaheadBuffer, Packet, 0, Adapter->NdisMiniportBlock.CurrentLookahead);
+ BufferedLength = CopyPacketToBuffer(LookaheadBuffer, Packet, 0, Adapter->NdisMiniportBlock.CurrentLookahead +
+ Adapter->MediumHeaderSize);
+ Adapter->NdisMiniportBlock.IndicatedPacket[KeGetCurrentProcessorNumber()] = Packet;
}
KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
ExFreePool(LookaheadBuffer);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+ {
+ Adapter->NdisMiniportBlock.IndicatedPacket[KeGetCurrentProcessorNumber()] = NULL;
+ }
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+
return NDIS_STATUS_SUCCESS;
}
} else {
if (Adapter->NdisMiniportBlock.ScatterGatherListSize != 0)
{
- NDIS_DbgPrint(MAX_TRACE, ("Using Scatter/Gather DMA\n"));
+ NDIS_DbgPrint(MIN_TRACE, ("Using Scatter/Gather DMA\n"));
NdisQueryPacket(Packet,
NULL,
/* FIXME: Interrupts must be disabled for adapter */
/* XXX sd - why is that true? */
- if (Packet == Adapter->NdisMiniportBlock.IndicatedPacket[KeGetCurrentProcessorNumber()]) {
+ if (Adapter->NdisMiniportBlock.IndicatedPacket[KeGetCurrentProcessorNumber()]) {
NDIS_DbgPrint(MAX_TRACE, ("LoopPacket\n"));
/* NDIS is responsible for looping this packet */
NdisCopyFromPacketToPacket(Packet,
- ByteOffset,
- BytesToTransfer,
+ ByteOffset + Adapter->MediumHeaderSize,
+ BytesToTransfer + Adapter->MediumHeaderSize,
Adapter->NdisMiniportBlock.IndicatedPacket[KeGetCurrentProcessorNumber()],
0,
BytesTransferred);
*Status = NDIS_STATUS_SUCCESS;
}
+PADAPTER_BINDING
+NTAPI
+LocateAdapterBindingByName(IN PPROTOCOL_BINDING ProtocolBinding, IN PNDIS_STRING AdapterName)
+{
+ PLIST_ENTRY CurrentEntry;
+ PADAPTER_BINDING AdapterBinding;
+ KIRQL OldIrql;
+
+ KeAcquireSpinLock(&ProtocolBinding->Lock, &OldIrql);
+
+ CurrentEntry = ProtocolBinding->AdapterListHead.Flink;
+
+ while (CurrentEntry != &ProtocolBinding->AdapterListHead)
+ {
+ AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, ProtocolListEntry);
+
+ if (RtlCompareUnicodeString(AdapterName, &AdapterBinding->Adapter->NdisMiniportBlock.MiniportName, TRUE) == 0)
+ {
+ KeReleaseSpinLock(&ProtocolBinding->Lock, OldIrql);
+ return AdapterBinding;
+ }
+
+ CurrentEntry = CurrentEntry->Flink;
+ }
+
+ KeReleaseSpinLock(&ProtocolBinding->Lock, OldIrql);
+
+ return NULL;
+}
+
VOID
NTAPI
-ndisBindMiniportsToProtocol(OUT PNDIS_STATUS Status, IN PNDIS_PROTOCOL_CHARACTERISTICS ProtocolCharacteristics)
+ndisBindMiniportsToProtocol(OUT PNDIS_STATUS Status, IN PPROTOCOL_BINDING Protocol)
{
/*
* bind the protocol to all of its miniports
WCHAR *DataPtr;
HANDLE DriverKeyHandle = NULL;
PKEY_VALUE_PARTIAL_INFORMATION KeyInformation = NULL;
+ PNDIS_PROTOCOL_CHARACTERISTICS ProtocolCharacteristics = &Protocol->Chars;
RegistryPathStr = ExAllocatePoolWithTag(PagedPool, sizeof(SERVICES_KEY) + ProtocolCharacteristics->Name.Length + sizeof(LINKAGE_KEY), NDIS_TAG + __LINE__);
if(!RegistryPathStr)
}
}
+ /* Assume success for now */
+ *Status = NDIS_STATUS_SUCCESS;
+
for (DataPtr = (WCHAR *)KeyInformation->Data;
*DataPtr != 0;
DataPtr += wcslen(DataPtr) + 1)
RtlInitUnicodeString(&DeviceName, DataPtr); /* we know this is 0-term */
+ /* Make sure the adapter has started */
+ if (!MiniLocateDevice(&DeviceName))
+ {
+ /* It wasn't in the global miniport list, so skip the bind entry */
+ continue;
+ }
+
+ /* Make sure this device isn't already bound to this protocol */
+ if (LocateAdapterBindingByName(Protocol, &DeviceName))
+ {
+ /* It was already in this protocol's bound adapter list, so skip the bind entry */
+ continue;
+ }
+
/*
* RegistryPath should be:
* \Registry\Machine\System\CurrentControlSet\Services\Nic1\Parameters\Tcpip
{
BIND_HANDLER BindHandler = ProtocolCharacteristics->BindAdapterHandler;
if(BindHandler)
+ {
BindHandler(Status, BindContext, &DeviceName, &RegistryPath, 0);
+ NDIS_DbgPrint(MIN_TRACE, ("%wZ's BindAdapter handler returned 0x%x for %wZ\n", &ProtocolCharacteristics->Name, *Status, &DeviceName));
+ }
else
NDIS_DbgPrint(MIN_TRACE, ("No protocol bind handler specified\n"));
}
}
- *Status = NDIS_STATUS_SUCCESS;
ExFreePool(KeyInformation);
}
PPROTOCOL_BINDING Protocol;
NTSTATUS NtStatus;
UINT MinSize;
+ PNET_PNP_EVENT PnPEvent;
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
*NdisProtocolHandle = Protocol;
- ndisBindMiniportsToProtocol(Status, &Protocol->Chars);
+ ndisBindMiniportsToProtocol(Status, Protocol);
+
+ /* Should we only send this if ndisBindMiniportsToProtocol succeeds? */
+ PnPEvent = ProSetupPnPEvent(NetEventBindsComplete, NULL, 0);
+ if (PnPEvent)
+ {
+ if (Protocol->Chars.PnPEventHandler)
+ {
+ /* We call this with a NULL binding context because it affects all bindings */
+ NtStatus = (*Protocol->Chars.PnPEventHandler)(NULL,
+ PnPEvent);
+
+ /* FIXME: We don't support this yet */
+ ASSERT(NtStatus != NDIS_STATUS_PENDING);
+ }
+
+ ExFreePool(PnPEvent);
+ }
if (*Status == NDIS_STATUS_SUCCESS) {
ExInterlockedInsertTailList(&ProtocolListHead, &Protocol->ListEntry, &ProtocolListLock);
NTAPI
NdisReEnumerateProtocolBindings(IN NDIS_HANDLE NdisProtocolHandle)
{
- PPROTOCOL_BINDING Protocol = NdisProtocolHandle;
NDIS_STATUS NdisStatus;
- ndisBindMiniportsToProtocol(&NdisStatus, &Protocol->Chars);
+ ndisBindMiniportsToProtocol(&NdisStatus, NdisProtocolHandle);
}