diff --git a/reactos/drivers/lib/ip/makefile b/reactos/drivers/lib/ip/makefile index c4d0028a398..b84ae014b23 100644 --- a/reactos/drivers/lib/ip/makefile +++ b/reactos/drivers/lib/ip/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.3 2004/09/30 22:04:13 arty Exp $ +# $Id: makefile,v 1.4 2004/10/07 15:04:45 arty Exp $ PATH_TO_TOP = ../../.. @@ -11,6 +11,7 @@ TARGET_PCH = $(PATH_TO_TOP)/drivers/lib/ip/include/precomp.h # -DMEMTRACK TARGET_CFLAGS = \ -D__USE_W32API \ + -DMEMTRACK \ -Wall -Werror \ -Iinclude \ -I../../net/tcpip/include \ diff --git a/reactos/drivers/lib/ip/network/ip.c b/reactos/drivers/lib/ip/network/ip.c index 17432291ef3..8a6d632226a 100644 --- a/reactos/drivers/lib/ip/network/ip.c +++ b/reactos/drivers/lib/ip/network/ip.c @@ -11,8 +11,6 @@ #include "precomp.h" -KTIMER IPTimer; -KDPC IPTimeoutDpc; LIST_ENTRY InterfaceListHead; KSPIN_LOCK InterfaceListLock; LIST_ENTRY NetTableListHead; @@ -21,6 +19,7 @@ UINT MaxLLHeaderSize; /* Largest maximum header size */ UINT MinLLFrameSize; /* Largest minimum frame size */ BOOLEAN IPInitialized = FALSE; NPAGED_LOOKASIDE_LIST IPPacketList; +/* Work around calling timer at Dpc level */ IP_PROTOCOL_HANDLER ProtocolTable[IP_PROTOCOL_TABLE_SIZE]; @@ -607,29 +606,13 @@ PADDRESS_ENTRY IPGetDefaultADE( return NULL; } - -VOID STDCALL IPTimeout( - PKDPC Dpc, - PVOID DeferredContext, - PVOID SystemArgument1, - PVOID SystemArgument2) -/* - * FUNCTION: Timeout DPC - * ARGUMENTS: - * Dpc = Pointer to our DPC object - * DeferredContext = Pointer to context information (unused) - * SystemArgument1 = Unused - * SystemArgument2 = Unused - * NOTES: - * This routine is dispatched once in a while to do maintainance jobs - */ -{ +void STDCALL IPTimeout( PVOID Context ) { /* Check if datagram fragments have taken too long to assemble */ IPDatagramReassemblyTimeout(); - + /* Clean possible outdated cached neighbor addresses */ NBTimeout(); - + /* Call upper layer timeout routines */ TCPTimeout(); } @@ -936,11 +919,10 @@ NTSTATUS IPStartup(PUNICODE_STRING RegistryPath) */ { UINT i; - LARGE_INTEGER DueTime; TI_DbgPrint(MAX_TRACE, ("Called.\n")); - MaxLLHeaderSize = 0; + MaxLLHeaderSize = 0; MinLLFrameSize = 0; /* Initialize lookaside lists */ @@ -1007,16 +989,6 @@ NTSTATUS IPStartup(PUNICODE_STRING RegistryPath) InitPLE(); - /* Initialize our periodic timer and its associated DPC object. When the - timer expires, the IPTimeout deferred procedure call (DPC) is queued */ - KeInitializeDpc(&IPTimeoutDpc, IPTimeout, NULL); - KeInitializeTimer(&IPTimer); - - /* Start the periodic timer with an initial and periodic - relative expiration time of IP_TIMEOUT milliseconds */ - DueTime.QuadPart = -(LONGLONG)IP_TIMEOUT * 10000; - KeSetTimerEx(&IPTimer, DueTime, IP_TIMEOUT, &IPTimeoutDpc); - IPInitialized = TRUE; return STATUS_SUCCESS; @@ -1036,9 +1008,6 @@ NTSTATUS IPShutdown( if (!IPInitialized) return STATUS_SUCCESS; - /* Cancel timer */ - KeCancelTimer(&IPTimer); - /* Shutdown neighbor cache subsystem */ NBShutdown(); diff --git a/reactos/drivers/lib/ip/network/neighbor.c b/reactos/drivers/lib/ip/network/neighbor.c index 51e41f62639..a13674f7872 100644 --- a/reactos/drivers/lib/ip/network/neighbor.c +++ b/reactos/drivers/lib/ip/network/neighbor.c @@ -91,8 +91,7 @@ VOID NCETimeout( } -VOID NBTimeout( - VOID) +VOID NBTimeout(VOID) /* * FUNCTION: Neighbor address cache timeout handler * NOTES: @@ -123,8 +122,7 @@ VOID NBTimeout( } } -VOID NBStartup( - VOID) +VOID NBStartup(VOID) /* * FUNCTION: Starts the neighbor cache */ @@ -140,8 +138,7 @@ VOID NBStartup( } } -VOID NBShutdown( - VOID) +VOID NBShutdown(VOID) /* * FUNCTION: Shuts down the neighbor cache */ @@ -198,8 +195,7 @@ VOID NBShutdown( TI_DbgPrint(MAX_TRACE, ("Leaving.\n")); } -VOID NBSendSolicit( - PNEIGHBOR_CACHE_ENTRY NCE) +VOID NBSendSolicit(PNEIGHBOR_CACHE_ENTRY NCE) /* * FUNCTION: Sends a neighbor solicitation message * ARGUMENTS: @@ -272,13 +268,16 @@ PNEIGHBOR_CACHE_ENTRY NBAddNeighbor( ULONG HashValue; KIRQL OldIrql; - TI_DbgPrint(DEBUG_NCACHE, ("Called. Interface (0x%X) Address (0x%X) " - "LinkAddress (0x%X) LinkAddressLength (%d) State (0x%X)\n", - Interface, Address, LinkAddress, LinkAddressLength, State)); + TI_DbgPrint + (DEBUG_NCACHE, + ("Called. Interface (0x%X) Address (0x%X) " + "LinkAddress (0x%X) LinkAddressLength (%d) State (0x%X)\n", + Interface, Address, LinkAddress, LinkAddressLength, State)); ASSERT(Address->Type == IP_ADDRESS_V4); - NCE = ExAllocatePool(NonPagedPool, sizeof(NEIGHBOR_CACHE_ENTRY) + LinkAddressLength); + NCE = ExAllocatePool + (NonPagedPool, sizeof(NEIGHBOR_CACHE_ENTRY) + LinkAddressLength); if (NCE == NULL) { TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n")); diff --git a/reactos/drivers/net/tcpip/include/ip.h b/reactos/drivers/net/tcpip/include/ip.h index b7e1e6bba33..71eff3bb74c 100644 --- a/reactos/drivers/net/tcpip/include/ip.h +++ b/reactos/drivers/net/tcpip/include/ip.h @@ -238,11 +238,7 @@ PADDRESS_ENTRY IPLocateADE( PADDRESS_ENTRY IPGetDefaultADE( UINT AddressType); -VOID STDCALL IPTimeout( - PKDPC Dpc, - PVOID DeferredContext, - PVOID SystemArgument1, - PVOID SystemArgument2); +VOID STDCALL IPTimeout( PVOID Context ); VOID IPDispatchProtocol( PNET_TABLE_ENTRY NTE, diff --git a/reactos/drivers/net/tcpip/tcpip/main.c b/reactos/drivers/net/tcpip/tcpip/main.c index e26e145d510..b8c3e1ce680 100644 --- a/reactos/drivers/net/tcpip/tcpip/main.c +++ b/reactos/drivers/net/tcpip/tcpip/main.c @@ -9,7 +9,7 @@ */ #include "precomp.h" -//#define NDEBUG +#define NDEBUG #ifndef NDEBUG DWORD DebugTraceLevel = 0x7fffffff; @@ -29,6 +29,10 @@ ULONG EntityCount = 0; ULONG EntityMax = 0; UDP_STATISTICS UDPStats; +KTIMER IPTimer; +KDPC IPTimeoutDpc; +KSPIN_LOCK IpWorkLock; +WORK_QUEUE_ITEM IpWorkItem; VOID TiWriteErrorLog( PDRIVER_OBJECT DriverContext, @@ -45,7 +49,8 @@ VOID TiWriteErrorLog( * ErrorCode = An error code to put in the log entry * UniqueErrorValue = UniqueErrorValue in the error log packet * FinalStatus = FinalStatus in the error log packet - * String = If not NULL, a pointer to a string to put in log entry + * String = If not NULL, a pointer to a string to put in log + * entry * DumpDataCount = Number of ULONGs of dump data * DumpData = Pointer to dump data for the log entry */ @@ -649,6 +654,8 @@ VOID STDCALL TiUnload( } KeReleaseSpinLock(&AddressFileListLock, OldIrql); #endif + /* Cancel timer */ + KeCancelTimer(&IPTimer); /* Unregister loopback adapter */ LoopUnregisterAdapter(NULL); @@ -696,6 +703,24 @@ VOID STDCALL TiUnload( TI_DbgPrint(MAX_TRACE, ("Leaving.\n")); } +VOID STDCALL IPTimeoutDpcFn( + PKDPC Dpc, + PVOID DeferredContext, + PVOID SystemArgument1, + PVOID SystemArgument2) +/* + * FUNCTION: Timeout DPC + * ARGUMENTS: + * Dpc = Pointer to our DPC object + * DeferredContext = Pointer to context information (unused) + * SystemArgument1 = Unused + * SystemArgument2 = Unused + * NOTES: + * This routine is dispatched once in a while to do maintainance jobs + */ +{ + ExQueueWorkItem( &IpWorkItem, CriticalWorkQueue ); +} NTSTATUS #ifndef _MSC_VER @@ -717,6 +742,7 @@ DriverEntry( UNICODE_STRING strDeviceName; UNICODE_STRING strNdisDeviceName; NDIS_STATUS NdisStatus; + LARGE_INTEGER DueTime; TI_DbgPrint(MAX_TRACE, ("Called.\n")); @@ -817,9 +843,6 @@ DriverEntry( InitializeListHead(&InterfaceListHead); KeInitializeSpinLock(&InterfaceListLock); - /* Initialize the lan worker */ - LANStartup(); - /* Initialize network level protocol subsystem */ IPStartup(RegistryPath); @@ -829,6 +852,9 @@ DriverEntry( UDPStartup(); TCPStartup(); + /* Initialize the lan worker */ + LANStartup(); + /* Register protocol with NDIS */ /* This used to be IP_DEVICE_NAME but the DDK says it has to match your entry in the SCM */ RtlInitUnicodeString(&strNdisDeviceName, TCPIP_PROTOCOL_NAME); @@ -869,6 +895,17 @@ DriverEntry( DriverObject->DriverUnload = TiUnload; + /* Initialize our periodic timer and its associated DPC object. When the + timer expires, the IPTimeout deferred procedure call (DPC) is queued */ + ExInitializeWorkItem( &IpWorkItem, IPTimeout, NULL ); + KeInitializeDpc(&IPTimeoutDpc, IPTimeoutDpcFn, NULL); + KeInitializeTimer(&IPTimer); + + /* Start the periodic timer with an initial and periodic + relative expiration time of IP_TIMEOUT milliseconds */ + DueTime.QuadPart = -(LONGLONG)IP_TIMEOUT * 10000; + KeSetTimerEx(&IPTimer, DueTime, IP_TIMEOUT, &IPTimeoutDpc); + PREPARE_TESTS return STATUS_SUCCESS;