NDIS_STATUS Status)
{
PNDISUIO_ADAPTER_CONTEXT AdapterContext = ProtocolBindingContext;
-
+
DPRINT("Asynchronous adapter send completed\n");
-
+
/* Store the final status and signal the event */
AdapterContext->AsyncStatus = Status;
KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
PNDIS_PACKET Packet;
NDIS_STATUS Status;
UINT BytesTransferred;
-
+
DPRINT("Received a %d byte packet\n", PacketSize);
/* Discard if nobody is waiting for it */
if (AdapterContext->OpenCount == 0)
return NDIS_STATUS_NOT_ACCEPTED;
-
+
/* Allocate a buffer to hold the packet data and header */
PacketBuffer = ExAllocatePool(NonPagedPool, PacketSize + HeaderBufferSize);
if (!PacketBuffer)
return NDIS_STATUS_NOT_ACCEPTED;
}
}
-
+
/* Copy the header data */
RtlCopyMemory(PacketBuffer, HeaderBuffer, HeaderBufferSize);
-
- /* Free the packet descriptor and buffers
+
+ /* Free the packet descriptor and buffers
but not the pool because we still need it */
CleanupAndFreePacket(Packet, FALSE);
/* Initialize the packet entry and copy in packet data */
PacketEntry->PacketLength = BytesTransferred + HeaderBufferSize;
RtlCopyMemory(PacketEntry->PacketData, PacketBuffer, PacketEntry->PacketLength);
-
+
/* Free the old buffer */
ExFreePool(PacketBuffer);
ExInterlockedInsertTailList(&AdapterContext->PacketList,
&PacketEntry->ListEntry,
&AdapterContext->Spinlock);
-
+
/* Signal the read event */
KeSetEvent(&AdapterContext->PacketReadEvent,
IO_NETWORK_INCREMENT,
PNDISUIO_OPEN_ENTRY OpenEntry;
PNDISUIO_PACKET_ENTRY PacketEntry;
NDIS_STATUS Status;
-
+
DPRINT("Unbinding adapter %wZ\n", &AdapterContext->DeviceName);
-
+
/* FIXME: We don't do anything with outstanding reads */
/* Remove the adapter context from the global list */
KeAcquireSpinLock(&GlobalAdapterListLock, &OldIrql);
RemoveEntryList(&AdapterContext->ListEntry);
KeReleaseSpinLock(&GlobalAdapterListLock, OldIrql);
-
+
/* Free the device name string */
RtlFreeUnicodeString(&AdapterContext->DeviceName);
/* Remove the open entry pointer */
ASSERT(OpenEntry == OpenEntry->FileObject->FsContext2);
OpenEntry->FileObject->FsContext2 = NULL;
-
+
/* Move to the next entry */
CurrentEntry = CurrentEntry->Flink;
/* If this fails, we have a refcount mismatch somewhere */
ASSERT(AdapterContext->OpenCount == 0);
-
+
/* Free all pending packet entries */
CurrentEntry = AdapterContext->PacketList.Flink;
while (CurrentEntry != &AdapterContext->PacketList)
/* Free the packet entry */
ExFreePool(PacketEntry);
}
-
+
/* Send the close request */
NdisCloseAdapter(&Status,
AdapterContext->BindingHandle);
-
+
/* Wait for a pending close */
if (Status == NDIS_STATUS_PENDING)
{
NULL);
Status = AdapterContext->AsyncStatus;
}
-
+
/* Free the context */
ExFreePool(AdapterContext);
-
+
return Status;
}
/* Copy the device name into the adapter context */
RtlCopyMemory(AdapterContext->DeviceName.Buffer, DeviceName->Buffer, DeviceName->Length);
-
+
DPRINT("Binding adapter %wZ\n", &AdapterContext->DeviceName);
/* Create the buffer pool */
DeviceName,
0,
NULL);
-
+
/* Wait for a pending open */
if (Status == NDIS_STATUS_PENDING)
{
NULL);
Status = AdapterContext->AsyncStatus;
}
-
+
/* Check the final status */
if (Status != NDIS_STATUS_SUCCESS)
{
ExFreePool(AdapterContext);
return Status;
}
-
+
/* Get the MAC options */
Request.RequestType = NdisRequestQueryInformation;
Request.DATA.QUERY_INFORMATION.Oid = OID_GEN_MAC_OPTIONS;
NULL);
Status = AdapterContext->AsyncStatus;
}
-
+
/* Check the final status */
if (Status != NDIS_STATUS_SUCCESS)
{
ExFreePool(AdapterContext);
return Status;
}
-
+
/* Add the adapter context to the global list */
ExInterlockedInsertTailList(&GlobalAdapterList,
&AdapterContext->ListEntry,
NDIS_HANDLE ProtocolBindingContext,
NDIS_HANDLE UnbindContext)
{
- /* This is forced unbind. UnbindAdapterByContext() will take care of
+ /* This is forced unbind. UnbindAdapterByContext() will take care of
* invalidating file handles pointer to this adapter for us */
*Status = UnbindAdapterByContext(ProtocolBindingContext);
}