Author: cgutman
Date: Sun Oct 12 20:07:37 2008
New Revision: 36741
URL:
http://svn.reactos.org/svn/reactos?rev=36741&view=rev
Log:
- Merge aicom-network-fixes up to r36740
Added:
trunk/reactos/drivers/network/ndis/ndis/object.c
- copied unchanged from r36740,
branches/aicom-network-fixes/drivers/network/ndis/ndis/object.c
trunk/reactos/drivers/network/ndis/ndis/workitem.c
- copied unchanged from r36740,
branches/aicom-network-fixes/drivers/network/ndis/ndis/workitem.c
Modified:
trunk/reactos/drivers/network/dd/ne2000/include/ne2000.h
trunk/reactos/drivers/network/dd/ne2000/ne2000/main.c
trunk/reactos/drivers/network/dd/pcnet/pcnet.c
trunk/reactos/drivers/network/ndis/ndis/miniport.c
trunk/reactos/drivers/network/ndis/ndis/protocol.c
trunk/reactos/drivers/network/tcpip/datalink/lan.c
trunk/reactos/include/ddk/ndis.h
trunk/reactos/lib/drivers/ip/network/neighbor.c
trunk/reactos/lib/drivers/ip/network/transmit.c
Modified: trunk/reactos/drivers/network/dd/ne2000/include/ne2000.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/ne2000/…
==============================================================================
--- trunk/reactos/drivers/network/dd/ne2000/include/ne2000.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/dd/ne2000/include/ne2000.h [iso-8859-1] Sun Oct 12
20:07:37 2008
@@ -175,6 +175,7 @@
/* Flags used for driver cleanup */
BOOLEAN IOPortRangeRegistered;
BOOLEAN InterruptRegistered;
+ BOOLEAN ShutdownHandlerRegistered;
} NIC_ADAPTER, *PNIC_ADAPTER;
/* Global driver information */
Modified: trunk/reactos/drivers/network/dd/ne2000/ne2000/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/ne2000/…
==============================================================================
--- trunk/reactos/drivers/network/dd/ne2000/ne2000/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/dd/ne2000/ne2000/main.c [iso-8859-1] Sun Oct 12 20:07:37
2008
@@ -140,10 +140,13 @@
0x20,
Adapter->IOBase);
+ if (Adapter->ShutdownHandlerRegistered)
+ NdisMDeregisterAdapterShutdownHandler(Adapter->MiniportAdapterHandle);
+
/* Remove adapter from global adapter list */
if ((&Adapter->ListEntry)->Blink != NULL) {
RemoveEntryList(&Adapter->ListEntry);
- }
+ }
/* Free adapter context area */
NdisFreeMemory(Adapter, sizeof(NIC_ADAPTER), 0);
@@ -200,6 +203,14 @@
}
}
+VOID
+STDCALL
+MiniportShutdown(PVOID Context)
+{
+ #ifndef NOCARD
+ NICStop((PNIC_ADAPTER)Context);
+ #endif
+}
static NDIS_STATUS STDCALL MiniportInitialize(
OUT PNDIS_STATUS OpenErrorStatus,
@@ -411,6 +422,12 @@
/* Start the NIC */
NICStart(Adapter);
#endif
+
+ /* Register the shutdown handler */
+ NdisMRegisterAdapterShutdownHandler(MiniportAdapterHandle, Adapter,
MiniportShutdown);
+
+ Adapter->ShutdownHandlerRegistered = TRUE;
+
/* Add adapter to the global adapter list */
InsertTailList(&DriverInfo.AdapterListHead, &Adapter->ListEntry);
Modified: trunk/reactos/drivers/network/dd/pcnet/pcnet.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/pcnet/p…
==============================================================================
--- trunk/reactos/drivers/network/dd/pcnet/pcnet.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/dd/pcnet/pcnet.c [iso-8859-1] Sun Oct 12 20:07:37 2008
@@ -573,6 +573,9 @@
/* deregister i/o port range */
NdisMDeregisterIoPortRange(Adapter->MiniportAdapterHandle,
Adapter->IoBaseAddress, NUMBER_OF_PORTS, (PVOID)Adapter->PortOffset);
+ /* deregister the shutdown routine */
+ NdisMDeregisterAdapterShutdownHandler(Adapter->MiniportAdapterHandle);
+
/* free shared memory */
MiFreeSharedMemory(Adapter);
@@ -780,6 +783,18 @@
return TRUE;
}
#endif
+
+VOID
+STDCALL
+MiniportShutdown( PVOID Context )
+{
+ PADAPTER Adapter = Context;
+
+ DPRINT("Stopping the chip\n");
+
+ NdisRawWritePortUshort(Adapter->PortOffset + RAP, CSR0);
+ NdisRawWritePortUshort(Adapter->PortOffset + RDP, CSR0_STOP);
+}
static NDIS_STATUS
STDCALL
@@ -952,6 +967,8 @@
ASSERT(0);
#endif
+ NdisMRegisterAdapterShutdownHandler(Adapter->MiniportAdapterHandle, Adapter,
MiniportShutdown);
+
DPRINT("returning 0x%x\n", Status);
*OpenErrorStatus = Status;
return Status;
Modified: trunk/reactos/drivers/network/ndis/ndis/miniport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/miniport.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/miniport.c [iso-8859-1] Sun Oct 12 20:07:37
2008
@@ -182,26 +182,6 @@
AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING,
AdapterListEntry);
NDIS_DbgPrint(DEBUG_MINIPORT, ("AdapterBinding = %x\n", AdapterBinding));
-#ifdef DBG
- if(!AdapterBinding)
- {
- NDIS_DbgPrint(MIN_TRACE, ("AdapterBinding was null\n"));
- break;
- }
-
- if(!AdapterBinding->ProtocolBinding)
- {
- NDIS_DbgPrint(MIN_TRACE, ("AdapterBinding->ProtocolBinding was
null\n"));
- break;
- }
-
- if(!AdapterBinding->ProtocolBinding->Chars.ReceiveHandler)
- {
- NDIS_DbgPrint(MIN_TRACE,
("AdapterBinding->ProtocolBinding->Chars.ReceiveHandler was null\n"));
- break;
- }
-#endif
-
NDIS_DbgPrint
(MID_TRACE,
("XXX (%x) %x %x %x %x %x %x %x XXX\n",
@@ -235,60 +215,46 @@
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);
+
+ if (AdapterBinding->ProtocolBinding->Chars.ReceivePacketHandler)
+ {
+ for (i = 0; i < NumberOfPackets; i++)
+ {
+ (*AdapterBinding->ProtocolBinding->Chars.ReceivePacketHandler)(
+ AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
+ PacketArray[i]);
+ }
+ }
+
+ CurrentEntry = CurrentEntry->Flink;
+ }
+
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
}
@@ -298,7 +264,13 @@
IN NDIS_STATUS Status,
IN BOOLEAN AddressingReset)
{
- UNIMPLEMENTED
+ PLOGICAL_ADAPTER Adapter = MiniportAdapterHandle;
+ KIRQL OldIrql;
+ NDIS_DbgPrint(MIN_TRACE, ("FIXME: MiniResetComplete is partially
implemented\n"));
+ NdisMIndicateStatus(Adapter, NDIS_STATUS_RESET_END, NULL, 0);
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+ Adapter->MiniportBusy = FALSE;
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
}
@@ -631,11 +603,23 @@
return NDIS_STATUS_PENDING;
}
+ NdisMIndicateStatus(Adapter, NDIS_STATUS_RESET_START, NULL, 0);
+ NdisMIndicateStatusComplete(Adapter);
+
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
Status =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext,
AddressingReset);
KeLowerIrql(OldIrql);
+
+ if (Status != NDIS_STATUS_PENDING) {
+ NdisMIndicateStatus(Adapter, NDIS_STATUS_RESET_END, NULL, 0);
+ NdisMIndicateStatusComplete(Adapter);
+ } else {
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+ Adapter->MiniportBusy = TRUE;
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+ }
return Status;
}
@@ -678,37 +662,52 @@
* Status of operation
*/
{
- PNDIS_MINIPORT_WORK_ITEM Item;
+ PNDIS_MINIPORT_WORK_ITEM MiniportWorkItem;
+ PNDIS_WORK_ITEM NdisWorkItem;
+ PWORK_QUEUE_ITEM WorkQueueItem;
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
ASSERT(Adapter);
ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);
- Item = ExAllocatePool(NonPagedPool, sizeof(NDIS_MINIPORT_WORK_ITEM));
- if (Item == NULL)
+ MiniportWorkItem = ExAllocatePool(NonPagedPool, sizeof(NDIS_MINIPORT_WORK_ITEM));
+ if (!MiniportWorkItem)
{
NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
return NDIS_STATUS_RESOURCES;
}
- Item->WorkItemType = WorkItemType;
- Item->WorkItemContext = WorkItemContext;
+ NdisWorkItem = ExAllocatePool(NonPagedPool, sizeof(NDIS_WORK_ITEM));
+ if (!NdisWorkItem)
+ {
+ ExFreePool(MiniportWorkItem);
+ return NDIS_STATUS_RESOURCES;
+ }
+
+ MiniportWorkItem->WorkItemType = WorkItemType;
+ MiniportWorkItem->WorkItemContext = WorkItemContext;
/* safe due to adapter lock held */
- Item->Link.Next = NULL;
+ MiniportWorkItem->Link.Next = NULL;
if (!Adapter->WorkQueueHead)
{
- Adapter->WorkQueueHead = Item;
- Adapter->WorkQueueTail = Item;
+ Adapter->WorkQueueHead = MiniportWorkItem;
+ Adapter->WorkQueueTail = MiniportWorkItem;
}
else
{
- Adapter->WorkQueueTail->Link.Next = (PSINGLE_LIST_ENTRY)Item;
- Adapter->WorkQueueTail = Item;
- }
-
- KeInsertQueueDpc(&Adapter->NdisMiniportBlock.DeferredDpc, NULL, NULL);
+ Adapter->WorkQueueTail->Link.Next = (PSINGLE_LIST_ENTRY)MiniportWorkItem;
+ Adapter->WorkQueueTail = MiniportWorkItem;
+ }
+
+ WorkQueueItem = (PWORK_QUEUE_ITEM)NdisWorkItem->WrapperReserved;
+
+ NdisWorkItem->Context = Adapter;
+
+ ExInitializeWorkItem(WorkQueueItem, MiniportWorker, NdisWorkItem);
+
+ ExQueueWorkItem(WorkQueueItem, CriticalWorkQueue);
return NDIS_STATUS_SUCCESS;
}
@@ -733,30 +732,38 @@
* Status of operation
*/
{
- PNDIS_MINIPORT_WORK_ITEM Item;
+ PNDIS_MINIPORT_WORK_ITEM MiniportWorkItem;
+ PNDIS_WORK_ITEM NdisWorkItem;
+ PWORK_QUEUE_ITEM WorkQueueItem;
+
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
if (Adapter->MiniportBusy) {
NDIS_DbgPrint(MID_TRACE, ("Waiting for miniport to become free.\n"));
- KeInsertQueueDpc(&Adapter->NdisMiniportBlock.DeferredDpc, NULL, NULL);
+ NdisWorkItem = ExAllocatePool(NonPagedPool, sizeof(NDIS_WORK_ITEM));
+ if (!NdisWorkItem) return NDIS_STATUS_RESOURCES;
+ WorkQueueItem = (PWORK_QUEUE_ITEM)NdisWorkItem->WrapperReserved;
+ NdisWorkItem->Context = Adapter;
+ ExInitializeWorkItem(WorkQueueItem, MiniportWorker, NdisWorkItem);
+ ExQueueWorkItem(WorkQueueItem, CriticalWorkQueue);
return NDIS_STATUS_FAILURE;
}
- Item = Adapter->WorkQueueHead;
-
- if (Item)
+ MiniportWorkItem = Adapter->WorkQueueHead;
+
+ if (MiniportWorkItem)
{
/* safe due to adapter lock held */
- Adapter->WorkQueueHead = (PNDIS_MINIPORT_WORK_ITEM)Item->Link.Next;
-
- if (Item == Adapter->WorkQueueTail)
+ Adapter->WorkQueueHead =
(PNDIS_MINIPORT_WORK_ITEM)MiniportWorkItem->Link.Next;
+
+ if (MiniportWorkItem == Adapter->WorkQueueTail)
Adapter->WorkQueueTail = NULL;
- *WorkItemType = Item->WorkItemType;
- *WorkItemContext = Item->WorkItemContext;
-
- ExFreePool(Item);
+ *WorkItemType = MiniportWorkItem->WorkItemType;
+ *WorkItemContext = MiniportWorkItem->WorkItemContext;
+
+ ExFreePool(MiniportWorkItem);
Adapter->MiniportBusy = TRUE;
@@ -953,6 +960,9 @@
break;
case NdisWorkItemResetRequested:
+ NdisMIndicateStatus(Adapter, NDIS_STATUS_RESET_START, NULL, 0);
+ NdisMIndicateStatusComplete(Adapter);
+
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
NdisStatus =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext,
@@ -1010,38 +1020,6 @@
ExFreePool(WorkItem);
}
-
-
-VOID NTAPI MiniportDpc(
- IN PKDPC Dpc,
- IN PVOID DeferredContext,
- IN PVOID SystemArgument1,
- IN PVOID SystemArgument2)
-/*
- * FUNCTION: Deferred routine to handle serialization
- * ARGUMENTS:
- * Dpc = Pointer to DPC object
- * DeferredContext = Pointer to context information (LOGICAL_ADAPTER)
- * SystemArgument1 = Unused
- * SystemArgument2 = Unused
- */
-{
- PNDIS_WORK_ITEM NdisWorkItem;
- PWORK_QUEUE_ITEM WorkItem;
-
- NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
-
- NdisWorkItem = ExAllocatePool(NonPagedPool, sizeof(NDIS_WORK_ITEM));
- if (!NdisWorkItem) return;
-
- WorkItem = (PWORK_QUEUE_ITEM)NdisWorkItem->WrapperReserved;
-
- NdisWorkItem->Context = DeferredContext;
-
- ExInitializeWorkItem(WorkItem, MiniportWorker, NdisWorkItem);
-
- ExQueueWorkItem(WorkItem, CriticalWorkQueue);
-}
VOID
@@ -1150,8 +1128,10 @@
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
- if(Adapter->BugcheckContext->ShutdownHandler)
+ if(Adapter->BugcheckContext->ShutdownHandler) {
KeDeregisterBugCheckCallback(Adapter->BugcheckContext->CallbackRecord);
+ IoUnregisterShutdownNotification(Adapter->NdisMiniportBlock.DeviceObject);
+ }
}
@@ -1319,12 +1299,9 @@
*/
{
PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportHandle;
- PMINIPORT_BUGCHECK_CONTEXT BugcheckContext = Adapter->BugcheckContext;
+ PMINIPORT_BUGCHECK_CONTEXT BugcheckContext;
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
-
- if(BugcheckContext)
- return;
BugcheckContext = ExAllocatePool(NonPagedPool, sizeof(MINIPORT_BUGCHECK_CONTEXT));
if(!BugcheckContext)
@@ -1337,11 +1314,19 @@
BugcheckContext->DriverContext = ShutdownContext;
BugcheckContext->CallbackRecord = ExAllocatePool(NonPagedPool,
sizeof(KBUGCHECK_CALLBACK_RECORD));
+ if (!BugcheckContext->CallbackRecord) {
+ ExFreePool(BugcheckContext);
+ return;
+ }
+
+ Adapter->BugcheckContext = BugcheckContext;
KeInitializeCallbackRecord(BugcheckContext->CallbackRecord);
KeRegisterBugCheckCallback(BugcheckContext->CallbackRecord, NdisIBugcheckCallback,
BugcheckContext, sizeof(BugcheckContext), (PUCHAR)"Ndis Miniport");
+
+ IoRegisterShutdownNotification(Adapter->NdisMiniportBlock.DeviceObject);
}
@@ -1671,13 +1656,18 @@
ZwClose(WrapperContext.RegistryHandle);
- if (NdisStatus != NDIS_STATUS_SUCCESS ||
- SelectedMediumIndex >= MEDIA_ARRAY_SIZE)
+ if (NdisStatus != NDIS_STATUS_SUCCESS)
{
NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() failed for an
adapter.\n"));
ExInterlockedRemoveEntryList( &Adapter->ListEntry, &AdapterListLock );
- if (NdisStatus == NDIS_STATUS_SUCCESS) NdisStatus = NDIS_STATUS_FAILURE;
return NdisStatus;
+ }
+
+ if (SelectedMediumIndex >= MEDIA_ARRAY_SIZE)
+ {
+ NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() failed for an
adapter\n"));
+ ExInterlockedRemoveEntryList( &Adapter->ListEntry, &AdapterListLock );
+ return NDIS_STATUS_UNSUPPORTED_MEDIA;
}
Adapter->NdisMiniportBlock.MediaType = MediaArray[SelectedMediumIndex];
@@ -1768,6 +1758,8 @@
RemoveEntryList(&Adapter->ListEntry);
KeReleaseSpinLock(&AdapterListLock, OldIrql);
+ KeCancelTimer(&Adapter->NdisMiniportBlock.WakeUpDpcTimer.Timer);
+
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.HaltHandler)(Adapter);
if (Adapter->LookaheadBuffer)
@@ -1789,7 +1781,27 @@
Adapter->NdisMiniportBlock.OldPnPDeviceState =
Adapter->NdisMiniportBlock.PnPDeviceState;
Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStopped;
- KeCancelTimer(&Adapter->NdisMiniportBlock.WakeUpDpcTimer.Timer);
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+NdisIShutdown(
+ IN PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ PLOGICAL_ADAPTER Adapter = DeviceObject->DeviceExtension;
+ PMINIPORT_BUGCHECK_CONTEXT Context = Adapter->BugcheckContext;
+ ADAPTER_SHUTDOWN_HANDLER ShutdownHandler = Context->ShutdownHandler;
+
+ ASSERT(ShutdownHandler);
+
+ ShutdownHandler(Context->DriverContext);
+
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = 0;
+
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
@@ -1979,7 +1991,6 @@
KeInitializeTimer(&Adapter->NdisMiniportBlock.WakeUpDpcTimer.Timer);
KeInitializeDpc(&Adapter->NdisMiniportBlock.WakeUpDpcTimer.Dpc, MiniportHangDpc,
Adapter);
- KeInitializeDpc(&Adapter->NdisMiniportBlock.DeferredDpc, MiniportDpc, Adapter);
DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
@@ -2088,6 +2099,7 @@
*MiniportPtr = Miniport;
Miniport->DriverObject->MajorFunction[IRP_MJ_PNP] = NdisIDispatchPnp;
+ Miniport->DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = NdisIShutdown;
Miniport->DriverObject->DriverExtension->AddDevice = NdisIAddDevice;
return NDIS_STATUS_SUCCESS;
Modified: trunk/reactos/drivers/network/ndis/ndis/protocol.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/protocol.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/protocol.c [iso-8859-1] Sun Oct 12 20:07:37
2008
@@ -215,14 +215,18 @@
if ((Adapter->NdisMiniportBlock.MacOptions & NDIS_MAC_OPTION_NO_LOOPBACK)
&&
MiniAdapterHasAddress(Adapter, Packet))
{
- NDIS_DbgPrint(MID_TRACE, ("Queuing packet.\n"));
-
- MiniQueueWorkItem(Adapter, NdisWorkItemSendLoopback, (PVOID)Packet);
- KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, SpinOldIrql);
- return NDIS_STATUS_PENDING;
+ if(Adapter->MiniportBusy) {
+ MiniQueueWorkItem(Adapter, NdisWorkItemSendLoopback, Packet);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, SpinOldIrql);
+ return NDIS_STATUS_PENDING;
+ }
+
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, SpinOldIrql);
+
+ return ProIndicatePacket(Adapter, Packet);
} else {
if(Adapter->MiniportBusy) {
- MiniQueueWorkItem(Adapter, NdisWorkItemSend, (PVOID)Packet);
+ MiniQueueWorkItem(Adapter, NdisWorkItemSend, Packet);
KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, SpinOldIrql);
return NDIS_STATUS_PENDING;
}
@@ -794,13 +798,13 @@
/* Put protocol binding struct on global list */
ExInterlockedInsertTailList(&ProtocolListHead, &Protocol->ListEntry,
&ProtocolListLock);
}
-
- /*
else if(*Status != NDIS_STATUS_PENDING)
{
- // what to do here?
+ ExFreePool(Protocol);
+ ExFreePool(KeyInformation);
+ *NdisProtocolHandle = NULL;
+ return;
}
- */
}
ExFreePool(KeyInformation);
Modified: trunk/reactos/drivers/network/tcpip/datalink/lan.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/data…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/datalink/lan.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/datalink/lan.c [iso-8859-1] Sun Oct 12 20:07:37
2008
@@ -201,6 +201,8 @@
TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
+ Adapter->NdisStatus = Status;
+
KeSetEvent(&Adapter->Event, 0, FALSE);
}
@@ -235,7 +237,13 @@
* Status = Status of the operation
*/
{
- TI_DbgPrint(MID_TRACE, ("Called.\n"));
+ PLAN_ADAPTER Adapter = (PLAN_ADAPTER)BindingContext;
+
+ TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
+
+ Adapter->NdisStatus = Status;
+
+ KeSetEvent(&Adapter->Event, 0, FALSE);
}
@@ -517,19 +525,44 @@
VOID STDCALL ProtocolStatus(
NDIS_HANDLE BindingContext,
- NDIS_STATUS GenerelStatus,
+ NDIS_STATUS GeneralStatus,
PVOID StatusBuffer,
UINT StatusBufferSize)
/*
* FUNCTION: Called by NDIS when the underlying driver has changed state
* ARGUMENTS:
* BindingContext = Pointer to a device context (LAN_ADAPTER)
- * GenerelStatus = A generel status code
+ * GeneralStatus = A general status code
* StatusBuffer = Pointer to a buffer with medium-specific data
* StatusBufferSize = Number of bytes in StatusBuffer
*/
{
+ PLAN_ADAPTER Adapter = BindingContext;
+
TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
+
+ switch(GeneralStatus)
+ {
+ case NDIS_STATUS_MEDIA_CONNECT:
+ DbgPrint("NDIS_STATUS_MEDIA_CONNECT\n");
+ break;
+
+ case NDIS_STATUS_MEDIA_DISCONNECT:
+ DbgPrint("NDIS_STATUS_MEDIA_DISCONNECT\n");
+ break;
+
+ case NDIS_STATUS_RESET_START:
+ Adapter->State = LAN_STATE_RESETTING;
+ break;
+
+ case NDIS_STATUS_RESET_END:
+ Adapter->State = LAN_STATE_STARTED;
+ break;
+
+ default:
+ DbgPrint("Unhandled status: %x", GeneralStatus);
+ break;
+ }
}
Modified: trunk/reactos/include/ddk/ndis.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/ndis.h?rev=367…
==============================================================================
--- trunk/reactos/include/ddk/ndis.h [iso-8859-1] (original)
+++ trunk/reactos/include/ddk/ndis.h [iso-8859-1] Sun Oct 12 20:07:37 2008
@@ -841,6 +841,19 @@
typedef struct _NDIS_PACKET_EXTENSION {
PVOID NdisPacketInfo[MaxPerPacketInfo];
} NDIS_PACKET_EXTENSION, *PNDIS_PACKET_EXTENSION;
+
+typedef struct _NDIS_OBJECT_HEADER {
+ UCHAR Type;
+ UCHAR Revision;
+ USHORT Size;
+} NDIS_OBJECT_HEADER, *PNDIS_OBJECT_HEADER;
+
+typedef struct _NDIS_GENERIC_OBJECT {
+ NDIS_OBJECT_HEADER Header;
+ PVOID Caller;
+ PVOID CallersCaller;
+ PDRIVER_OBJECT DriverObject;
+} NDIS_GENERIC_OBJECT, *PNDIS_GENERIC_OBJECT;
/*
* PNDIS_PACKET
Modified: trunk/reactos/lib/drivers/ip/network/neighbor.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/nei…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/neighbor.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/neighbor.c [iso-8859-1] Sun Oct 12 20:07:37 2008
@@ -412,11 +412,13 @@
TI_DbgPrint(MID_TRACE,("Packet targeted at broadcast addr\n"));
NCE = NBAddNeighbor(Interface, Address, NULL,
Interface->AddressLength, NUD_CONNECTED);
+ if (!NCE) return NULL;
NCE->EventTimer = 0;
NCE->EventCount = 0;
} else {
NCE = NBAddNeighbor(Interface, Address, NULL,
Interface->AddressLength, NUD_INCOMPLETE);
+ if (!NCE) return NULL;
NCE->EventTimer = 1;
NCE->EventCount = 0;
}
Modified: trunk/reactos/lib/drivers/ip/network/transmit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/tra…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/transmit.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/transmit.c [iso-8859-1] Sun Oct 12 20:07:37 2008
@@ -204,9 +204,7 @@
/* Prepare next fragment for transmission and send it */
PrepareNextFragment(IFC);
- IPSendFragment(IFC->NdisPacket, NCE, IFC);
-
- return STATUS_SUCCESS;
+ return IPSendFragment(IFC->NdisPacket, NCE, IFC);
}
NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE,