Author: arty
Date: Fri Nov 23 16:52:56 2007
New Revision: 30693
URL:
http://svn.reactos.org/svn/reactos?rev=30693&view=rev
Log:
tcpip:
Factor out common datagram receive code.
Actually implement datagram cancellation.
afd:
Reorganize IRP cancellation and simplify socket shutdown.
Fix datagram recv with no address differently (and better).
Overall: fix hang after ping.
Modified:
trunk/reactos/drivers/network/afd/afd/lock.c
trunk/reactos/drivers/network/afd/afd/main.c
trunk/reactos/drivers/network/afd/afd/read.c
trunk/reactos/drivers/network/afd/afd/write.c
trunk/reactos/drivers/network/afd/include/afd.h
trunk/reactos/drivers/network/tcpip/include/datagram.h
trunk/reactos/drivers/network/tcpip/include/rawip.h
trunk/reactos/drivers/network/tcpip/include/titypes.h
trunk/reactos/drivers/network/tcpip/include/udp.h
trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c
trunk/reactos/drivers/network/tcpip/tcpip/main.c
trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c
trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c
trunk/reactos/lib/drivers/ip/transport/udp/udp.c
Modified: trunk/reactos/drivers/network/afd/afd/lock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/lo…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/lock.c (original)
+++ trunk/reactos/drivers/network/afd/afd/lock.c Fri Nov 23 16:52:56 2007
@@ -46,7 +46,7 @@
BOOLEAN Write, BOOLEAN LockAddress ) {
UINT i;
/* Copy the buffer array so we don't lose it */
- UINT Lock = (LockAddress && AddressLen) ? 2 : 0;
+ UINT Lock = LockAddress ? 2 : 0;
UINT Size = sizeof(AFD_WSABUF) * (Count + Lock);
PAFD_WSABUF NewBuf = ExAllocatePool( PagedPool, Size * 2 );
PMDL NewMdl;
@@ -65,6 +65,9 @@
NewBuf[Count].buf = (PVOID)AddressLen;
NewBuf[Count].len = sizeof(*AddressLen);
Count++;
+ } else if( LockAddress ) {
+ RtlZeroMemory(NewBuf, sizeof(*NewBuf) * 2);
+ Count += 2;
}
} _SEH_HANDLE {
AFD_DbgPrint(MIN_TRACE,("Access violation copying buffer info "
Modified: trunk/reactos/drivers/network/afd/afd/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/ma…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/main.c (original)
+++ trunk/reactos/drivers/network/afd/afd/main.c Fri Nov 23 16:52:56 2007
@@ -152,50 +152,7 @@
}
VOID DestroySocket( PAFD_FCB FCB ) {
- UINT i;
- BOOLEAN ReturnEarly = FALSE;
- PAFD_IN_FLIGHT_REQUEST InFlightRequest[IN_FLIGHT_REQUESTS];
-
AFD_DbgPrint(MIN_TRACE,("Called (%x)\n", FCB));
-
- if( !SocketAcquireStateLock( FCB ) ) return;
-
- FCB->State = SOCKET_STATE_CLOSED;
-
- InFlightRequest[0] = &FCB->ListenIrp;
- InFlightRequest[1] = &FCB->ReceiveIrp;
- InFlightRequest[2] = &FCB->SendIrp;
-
- /* Return early here because we might be called in the mean time. */
- if( FCB->Critical ||
- FCB->ListenIrp.InFlightRequest ||
- FCB->ReceiveIrp.InFlightRequest ||
- FCB->SendIrp.InFlightRequest ) {
- AFD_DbgPrint(MIN_TRACE,("Leaving socket alive (%x %x %x)\n",
- FCB->ListenIrp.InFlightRequest,
- FCB->ReceiveIrp.InFlightRequest,
- FCB->SendIrp.InFlightRequest));
- ReturnEarly = TRUE;
- }
-
- /* After PoolReeval, this FCB should not be involved in any outstanding
- * poll requests */
-
- /* Cancel our pending requests */
- for( i = 0; i < IN_FLIGHT_REQUESTS; i++ ) {
- NTSTATUS Status = STATUS_NO_SUCH_FILE;
- if( InFlightRequest[i]->InFlightRequest ) {
- AFD_DbgPrint(MID_TRACE,("Cancelling in flight irp %d (%x)\n",
- i, InFlightRequest[i]->InFlightRequest));
- InFlightRequest[i]->InFlightRequest->IoStatus.Status = Status;
- InFlightRequest[i]->InFlightRequest->IoStatus.Information = 0;
- IoCancelIrp( InFlightRequest[i]->InFlightRequest );
- }
- }
-
- SocketStateUnlock( FCB );
-
- if( ReturnEarly ) return;
if( FCB->Recv.Window )
ExFreePool( FCB->Recv.Window );
@@ -218,8 +175,12 @@
AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
PIO_STACK_LOCATION IrpSp)
{
+ UINT i;
+ AFD_IN_FLIGHT_REQUEST InFlightRequest[IN_FLIGHT_REQUESTS];
PFILE_OBJECT FileObject = IrpSp->FileObject;
PAFD_FCB FCB = FileObject->FsContext;
+
+ if (!SocketAcquireStateLock(FCB)) return LostSocket(Irp, FALSE);
AFD_DbgPrint(MID_TRACE,
("AfdClose(DeviceObject %p Irp %p)\n", DeviceObject, Irp));
@@ -233,15 +194,56 @@
if( FCB->EventSelect ) ObDereferenceObject( FCB->EventSelect );
FileObject->FsContext = NULL;
+
+ FCB->State = SOCKET_STATE_CLOSED;
+ SocketStateUnlock(FCB);
+
+ InFlightRequest[0] = FCB->ListenIrp;
+ InFlightRequest[1] = FCB->ReceiveIrp;
+ InFlightRequest[2] = FCB->SendIrp;
+
+ /* Return early here because we might be called in the mean time. */
+ if( !(FCB->Critical ||
+ FCB->ListenIrp.InFlightRequest ||
+ FCB->ReceiveIrp.InFlightRequest ||
+ FCB->SendIrp.InFlightRequest) ) {
+ AFD_DbgPrint(MIN_TRACE,("Leaving socket alive (%x %x %x)\n",
+ FCB->ListenIrp.InFlightRequest,
+ FCB->ReceiveIrp.InFlightRequest,
+ FCB->SendIrp.InFlightRequest));
+ SocketStateUnlock(FCB);
+ DestroySocket(FCB);
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ }
+ else
+ {
+ /* After PoolReeval, this FCB should not be involved in any outstanding
+ * poll requests */
+
+ /* Cancel our pending requests */
+ for( i = 0; i < IN_FLIGHT_REQUESTS; i++ ) {
+ NTSTATUS Status = STATUS_NO_SUCH_FILE;
+ if( InFlightRequest[i].InFlightRequest ) {
+ AFD_DbgPrint(MID_TRACE,("Cancelling in flight irp %d (%x)\n",
+ i, InFlightRequest[i].InFlightRequest));
+ InFlightRequest[i].InFlightRequest->IoStatus.Status = Status;
+ InFlightRequest[i].InFlightRequest->IoStatus.Information = 0;
+ IoCancelIrp( InFlightRequest[i].InFlightRequest );
+ }
+ }
+
+ FCB->PendingClose = Irp;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ }
+
DestroySocket( FCB );
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
AFD_DbgPrint(MID_TRACE, ("Returning success.\n"));
- return STATUS_SUCCESS;
+ return Irp->IoStatus.Status;
}
static NTSTATUS STDCALL
Modified: trunk/reactos/drivers/network/afd/afd/read.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/re…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/read.c (original)
+++ trunk/reactos/drivers/network/afd/afd/read.c Fri Nov 23 16:52:56 2007
@@ -231,7 +231,6 @@
if( FCB->State == SOCKET_STATE_CLOSED ) {
AFD_DbgPrint(MIN_TRACE,("!!! CLOSED SOCK GOT A RECEIVE COMPLETE
!!!\n"));
SocketStateUnlock( FCB );
- DestroySocket( FCB );
return STATUS_SUCCESS;
} else if( FCB->State == SOCKET_STATE_LISTENING ) {
AFD_DbgPrint(MIN_TRACE,("!!! LISTENER GOT A RECEIVE COMPLETE !!!\n"));
@@ -435,13 +434,12 @@
AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB));
+ FCB->ReceiveIrp.InFlightRequest = NULL;
+
if( !SocketAcquireStateLock( FCB ) ) return STATUS_UNSUCCESSFUL;
-
- FCB->ReceiveIrp.InFlightRequest = NULL;
if( FCB->State == SOCKET_STATE_CLOSED ) {
SocketStateUnlock( FCB );
- DestroySocket( FCB );
return STATUS_SUCCESS;
}
Modified: trunk/reactos/drivers/network/afd/afd/write.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/wr…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/write.c (original)
+++ trunk/reactos/drivers/network/afd/afd/write.c Fri Nov 23 16:52:56 2007
@@ -47,7 +47,6 @@
if( FCB->State == SOCKET_STATE_CLOSED ) {
SocketStateUnlock( FCB );
- DestroySocket( FCB );
return STATUS_SUCCESS;
}
@@ -178,12 +177,6 @@
FCB->SendIrp.InFlightRequest = NULL;
/* Request is not in flight any longer */
- if( FCB->State == SOCKET_STATE_CLOSED ) {
- SocketStateUnlock( FCB );
- DestroySocket( FCB );
- return STATUS_SUCCESS;
- }
-
SocketStateUnlock( FCB );
return STATUS_SUCCESS;
Modified: trunk/reactos/drivers/network/afd/include/afd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/includ…
==============================================================================
--- trunk/reactos/drivers/network/afd/include/afd.h (original)
+++ trunk/reactos/drivers/network/afd/include/afd.h Fri Nov 23 16:52:56 2007
@@ -147,6 +147,7 @@
PVOID Context;
DWORD PollState;
UINT ContextSize;
+ PIRP PendingClose;
LIST_ENTRY PendingIrpList[MAX_FUNCTIONS];
LIST_ENTRY DatagramList;
LIST_ENTRY PendingConnections;
Modified: trunk/reactos/drivers/network/tcpip/include/datagram.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/datagram.h (original)
+++ trunk/reactos/drivers/network/tcpip/include/datagram.h Fri Nov 23 16:52:56 2007
@@ -9,6 +9,21 @@
#include <titypes.h>
+NTSTATUS DGReceiveDatagram(
+ PADDRESS_FILE AddrFile,
+ PTDI_CONNECTION_INFORMATION ConnInfo,
+ PCHAR Buffer,
+ ULONG ReceiveLength,
+ ULONG ReceiveFlags,
+ PTDI_CONNECTION_INFORMATION ReturnInfo,
+ PULONG BytesReceived,
+ PDATAGRAM_COMPLETION_ROUTINE Complete,
+ PVOID Context,
+ PIRP Irp);
+
+VOID DGRemoveIRP(
+ PADDRESS_FILE AddrFile,
+ PIRP Irp);
VOID DGDeliverData(
PADDRESS_FILE AddrFile,
Modified: trunk/reactos/drivers/network/tcpip/include/rawip.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/rawip.h (original)
+++ trunk/reactos/drivers/network/tcpip/include/rawip.h Fri Nov 23 16:52:56 2007
@@ -6,8 +6,6 @@
*/
#ifndef __RAWIP_H
#define __RAWIP_H
-
-
NTSTATUS RawIPSendDatagram(
PADDRESS_FILE AddrFile,
Modified: trunk/reactos/drivers/network/tcpip/include/titypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/titypes.h (original)
+++ trunk/reactos/drivers/network/tcpip/include/titypes.h Fri Nov 23 16:52:56 2007
@@ -113,6 +113,7 @@
typedef DATAGRAM_COMPLETION_ROUTINE PDATAGRAM_COMPLETION_ROUTINE;
typedef struct _DATAGRAM_RECEIVE_REQUEST {
+ struct _ADDRESS_FILE *AddressFile; /* AddressFile on behalf of */
LIST_ENTRY ListEntry; /* Entry on list */
IP_ADDRESS RemoteAddress; /* Remote address we receive from (NULL means
any) */
USHORT RemotePort; /* Remote port we receive from (0 means any)
*/
@@ -123,6 +124,7 @@
PVOID Context; /* Pointer to context information */
DATAGRAM_COMPLETION_ROUTINE UserComplete; /* Completion routine */
PVOID UserContext; /* Pointer to context information */
+ PIRP Irp; /* IRP on behalf of */
} DATAGRAM_RECEIVE_REQUEST, *PDATAGRAM_RECEIVE_REQUEST;
/* Datagram build routine prototype */
Modified: trunk/reactos/drivers/network/tcpip/include/udp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/udp.h (original)
+++ trunk/reactos/drivers/network/tcpip/include/udp.h Fri Nov 23 16:52:56 2007
@@ -50,17 +50,6 @@
ULONG DataSize,
PULONG DataUsed );
-NTSTATUS UDPReceiveDatagram(
- PADDRESS_FILE AddrFile,
- PTDI_CONNECTION_INFORMATION ConnInfo,
- PCHAR Buffer,
- ULONG ReceiveLength,
- ULONG ReceiveFlags,
- PTDI_CONNECTION_INFORMATION ReturnInfo,
- PULONG BytesReceived,
- PDATAGRAM_COMPLETION_ROUTINE Complete,
- PVOID Context);
-
VOID UDPReceive(
PIP_INTERFACE Interface,
PIP_PACKET IPPacket);
Modified: trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c Fri Nov 23 16:52:56 2007
@@ -53,34 +53,6 @@
return IRPFinish(Irp, STATUS_CANCELLED);
}
-
-
-VOID DispCancelComplete(
- PVOID Context)
-/*
- * FUNCTION: Completes a cancel request
- * ARGUMENTS:
- * Context = Pointer to context information (FILE_OBJECT)
- */
-{
- /*KIRQL OldIrql;*/
- PFILE_OBJECT FileObject;
- PTRANSPORT_CONTEXT TranContext;
-
- TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
-
- FileObject = (PFILE_OBJECT)Context;
- TranContext = (PTRANSPORT_CONTEXT)FileObject->FsContext;
-
- /* Set the cleanup event */
- KeSetEvent(&TranContext->CleanupEvent, 0, FALSE);
-
- /* We are expected to release the cancel spin lock */
- /*IoReleaseCancelSpinLock(OldIrql);*/
-
- TI_DbgPrint(DEBUG_IRP, ("Leaving.\n"));
-}
-
VOID DispDataRequestComplete(
PVOID Context,
@@ -156,8 +128,14 @@
TI_DbgPrint(DEBUG_IRP, ("PostCancel: DoDisconnect done\n"));
DispDataRequestComplete(DisType->Irp, STATUS_CANCELLED, 0);
-
- DispCancelComplete(DisType->FileObject);
+}
+
+VOID DispDoPacketCancel( PVOID Data ) {
+ TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
+ PIRP *IrpP = (PIRP *)Data, Irp = *IrpP;
+ Irp->IoStatus.Status = STATUS_CANCELLED;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
VOID NTAPI DispCancelRequest(
@@ -176,6 +154,7 @@
UCHAR MinorFunction;
DISCONNECT_TYPE DisType;
PVOID WorkItem;
+ PADDRESS_FILE AddrFile;
/*NTSTATUS Status = STATUS_SUCCESS;*/
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
@@ -209,26 +188,26 @@
if( !ChewCreate( &WorkItem, sizeof(DISCONNECT_TYPE),
DispDoDisconnect, &DisType ) )
ASSERT(0);
- break;
+ return;
case TDI_SEND_DATAGRAM:
+ AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
Irp->IoStatus.Status = STATUS_CANCELLED;
if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
TI_DbgPrint(MIN_TRACE, ("TDI_SEND_DATAGRAM, but no address
file.\n"));
break;
}
-
- /*DGCancelSendRequest(TranContext->Handle.AddressHandle, Irp);*/
+ /* Nothing to do. We don't keep them around. */
break;
case TDI_RECEIVE_DATAGRAM:
+ AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
Irp->IoStatus.Status = STATUS_CANCELLED;
if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
TI_DbgPrint(MIN_TRACE, ("TDI_RECEIVE_DATAGRAM, but no address
file.\n"));
break;
}
-
- /*DGCancelReceiveRequest(TranContext->Handle.AddressHandle, Irp);*/
+ DGRemoveIRP(AddrFile, Irp);
break;
default:
@@ -236,11 +215,9 @@
break;
}
- if( Irp->IoStatus.Status == STATUS_PENDING )
- IoMarkIrpPending(Irp);
-
IoReleaseCancelSpinLock(Irp->CancelIrql);
-
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
}
@@ -284,9 +261,6 @@
IoReleaseCancelSpinLock(Irp->CancelIrql);
DispDataRequestComplete(Irp, STATUS_CANCELLED, 0);
-
- DispCancelComplete(FileObject);
-
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
}
@@ -822,7 +796,6 @@
return Status;
}
-
NTSTATUS DispTdiReceiveDatagram(
PIRP Irp)
/*
@@ -839,6 +812,7 @@
TDI_REQUEST Request;
NTSTATUS Status;
ULONG BytesReceived;
+ PADDRESS_FILE AddrFile;
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
@@ -852,6 +826,8 @@
return STATUS_INVALID_ADDRESS;
}
+ AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
+
/* Initialize a receive request */
Request.Handle.AddressHandle = TranContext->Handle.AddressHandle;
Request.RequestNotifyObject = DispDataRequestComplete;
@@ -871,20 +847,21 @@
&DataBuffer,
&BufferSize );
- Status = UDPReceiveDatagram(
- Request.Handle.AddressHandle,
- DgramInfo->ReceiveDatagramInformation,
- DataBuffer,
- DgramInfo->ReceiveLength,
- DgramInfo->ReceiveFlags,
- DgramInfo->ReturnDatagramInformation,
- &BytesReceived,
- (PDATAGRAM_COMPLETION_ROUTINE)DispDataRequestComplete,
- Irp);
- if (Status != STATUS_PENDING) {
- DispDataRequestComplete(Irp, Status, BytesReceived);
- } else
- IoMarkIrpPending(Irp);
+ Status = DGReceiveDatagram(
+ AddrFile,
+ DgramInfo->ReceiveDatagramInformation,
+ DataBuffer,
+ DgramInfo->ReceiveLength,
+ DgramInfo->ReceiveFlags,
+ DgramInfo->ReturnDatagramInformation,
+ &BytesReceived,
+ (PDATAGRAM_COMPLETION_ROUTINE)DispDataRequestComplete,
+ Irp,
+ Irp);
+ if (Status != STATUS_PENDING) {
+ DispDataRequestComplete(Irp, Status, BytesReceived);
+ } else
+ IoMarkIrpPending(Irp);
}
TI_DbgPrint(DEBUG_IRP, ("Leaving. Status is (0x%X)\n", Status));
Modified: trunk/reactos/drivers/network/tcpip/tcpip/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/main.c (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/main.c Fri Nov 23 16:52:56 2007
@@ -146,7 +146,6 @@
}
CP
Context->CancelIrps = FALSE;
- KeInitializeEvent(&Context->CleanupEvent, NotificationEvent, FALSE);
CP
IrpSp = IoGetCurrentIrpStackLocation(Irp);
IrpSp->FileObject->FsContext = Context;
@@ -274,20 +273,11 @@
{
PIRP Irp;
PIO_STACK_LOCATION IrpSp;
- PTRANSPORT_CONTEXT TranContext;
- KIRQL OldIrql;
Irp = (PIRP)Context;
IrpSp = IoGetCurrentIrpStackLocation(Irp);
- TranContext = (PTRANSPORT_CONTEXT)IrpSp->FileObject->FsContext;
Irp->IoStatus.Status = Status;
-
- IoAcquireCancelSpinLock(&OldIrql);
-
- KeSetEvent(&TranContext->CleanupEvent, 0, FALSE);
-
- IoReleaseCancelSpinLock(OldIrql);
}
@@ -321,7 +311,6 @@
IoAcquireCancelSpinLock(&OldIrql);
Context->CancelIrps = TRUE;
- KeResetEvent(&Context->CleanupEvent);
IoReleaseCancelSpinLock(OldIrql);
@@ -355,12 +344,6 @@
return STATUS_INVALID_PARAMETER;
}
-
- if (Status != STATUS_PENDING)
- TiCleanupFileObjectComplete(Irp, Status);
-
- KeWaitForSingleObject(&Context->CleanupEvent,
- UserRequest, KernelMode, FALSE, NULL);
return Irp->IoStatus.Status;
}
Modified: trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/d…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c (original)
+++ trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c Fri Nov 23 16:52:56 2007
@@ -9,6 +9,36 @@
*/
#include "precomp.h"
+
+VOID DGRemoveIRP(
+ PADDRESS_FILE AddrFile,
+ PIRP Irp)
+{
+ PLIST_ENTRY ListEntry;
+ PDATAGRAM_RECEIVE_REQUEST ReceiveRequest;
+
+ TI_DbgPrint(MAX_TRACE, ("Called (Cancel IRP %08x for file %08x).\n",
+ Irp, AddrFile));
+
+ for( ListEntry = AddrFile->ReceiveQueue.Flink;
+ ListEntry != &AddrFile->ReceiveQueue;
+ ListEntry = ListEntry->Flink )
+ {
+ ReceiveRequest = CONTAINING_RECORD
+ (ListEntry, DATAGRAM_RECEIVE_REQUEST, ListEntry);
+
+ TI_DbgPrint(MAX_TRACE, ("Request: %08x?\n", ReceiveRequest));
+
+ if (ReceiveRequest->Irp == Irp)
+ {
+ RemoveEntryList(&ReceiveRequest->ListEntry);
+ exFreePool(ReceiveRequest);
+ break;
+ }
+ }
+
+ TI_DbgPrint(MAX_TRACE, ("Done.\n"));
+}
VOID DGDeliverData(
PADDRESS_FILE AddrFile,
@@ -153,3 +183,110 @@
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
}
+
+VOID DGReceiveComplete(PVOID Context, NTSTATUS Status, ULONG Count) {
+ PDATAGRAM_RECEIVE_REQUEST ReceiveRequest =
+ (PDATAGRAM_RECEIVE_REQUEST)Context;
+ TI_DbgPrint(MAX_TRACE,("Called (%08x:%08x)\n", Status, Count));
+ ReceiveRequest->UserComplete( ReceiveRequest->UserContext, Status, Count );
+ exFreePool( ReceiveRequest );
+ TI_DbgPrint(MAX_TRACE,("Done\n"));
+}
+
+NTSTATUS DGReceiveDatagram(
+ PADDRESS_FILE AddrFile,
+ PTDI_CONNECTION_INFORMATION ConnInfo,
+ PCHAR BufferData,
+ ULONG ReceiveLength,
+ ULONG ReceiveFlags,
+ PTDI_CONNECTION_INFORMATION ReturnInfo,
+ PULONG BytesReceived,
+ PDATAGRAM_COMPLETION_ROUTINE Complete,
+ PVOID Context,
+ PIRP Irp)
+/*
+ * FUNCTION: Attempts to receive an DG datagram from a remote address
+ * ARGUMENTS:
+ * Request = Pointer to TDI request
+ * ConnInfo = Pointer to connection information
+ * Buffer = Pointer to NDIS buffer chain to store received data
+ * ReceiveLength = Maximum size to use of buffer, 0 if all can be used
+ * ReceiveFlags = Receive flags (None, Normal, Peek)
+ * ReturnInfo = Pointer to structure for return information
+ * BytesReceive = Pointer to structure for number of bytes received
+ * RETURNS:
+ * Status of operation
+ * NOTES:
+ * This is the high level interface for receiving DG datagrams
+ */
+{
+ KIRQL OldIrql;
+ NTSTATUS Status;
+ PDATAGRAM_RECEIVE_REQUEST ReceiveRequest;
+
+ TI_DbgPrint(MAX_TRACE, ("Called.\n"));
+
+ TcpipAcquireSpinLock(&AddrFile->Lock, &OldIrql);
+
+ if (AF_IS_VALID(AddrFile))
+ {
+ ReceiveRequest = exAllocatePool(NonPagedPool, sizeof(DATAGRAM_RECEIVE_REQUEST));
+ if (ReceiveRequest)
+ {
+ /* Initialize a receive request */
+
+ /* Extract the remote address filter from the request (if any) */
+ if ((ConnInfo->RemoteAddressLength != 0) &&
+ (ConnInfo->RemoteAddress))
+ {
+ Status = AddrGetAddress(ConnInfo->RemoteAddress,
+ &ReceiveRequest->RemoteAddress,
+ &ReceiveRequest->RemotePort);
+ if (!NT_SUCCESS(Status))
+ {
+ TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
+ exFreePool(ReceiveRequest);
+ return Status;
+ }
+ }
+ else
+ {
+ ReceiveRequest->RemotePort = 0;
+ }
+ ReceiveRequest->ReturnInfo = ReturnInfo;
+ ReceiveRequest->Buffer = BufferData;
+ ReceiveRequest->BufferSize = ReceiveLength;
+ ReceiveRequest->UserComplete = Complete;
+ ReceiveRequest->UserContext = Context;
+ ReceiveRequest->Complete =
+ (PDATAGRAM_COMPLETION_ROUTINE)DGReceiveComplete;
+ ReceiveRequest->Context = ReceiveRequest;
+ ReceiveRequest->AddressFile = AddrFile;
+ ReceiveRequest->Irp = Irp;
+
+ /* Queue receive request */
+ InsertTailList(&AddrFile->ReceiveQueue, &ReceiveRequest->ListEntry);
+ AF_SET_PENDING(AddrFile, AFF_RECEIVE);
+
+ TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
+
+ TI_DbgPrint(MAX_TRACE, ("Leaving (pending %08x).\n", ReceiveRequest));
+
+ return STATUS_PENDING;
+ }
+ else
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ }
+ }
+ else
+ {
+ Status = STATUS_INVALID_ADDRESS;
+ }
+
+ TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
+
+ TI_DbgPrint(MAX_TRACE, ("Leaving with errors (0x%X).\n", Status));
+
+ return Status;
+}
Modified: trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/r…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c (original)
+++ trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c Fri Nov 23 16:52:56 2007
@@ -228,110 +228,6 @@
return STATUS_SUCCESS;
}
-VOID RawIpReceiveComplete(PVOID Context, NTSTATUS Status, ULONG Count) {
- PDATAGRAM_RECEIVE_REQUEST ReceiveRequest =
- (PDATAGRAM_RECEIVE_REQUEST)Context;
- TI_DbgPrint(MAX_TRACE,("Called\n"));
- ReceiveRequest->UserComplete( ReceiveRequest->UserContext, Status, Count );
- exFreePool( ReceiveRequest );
- TI_DbgPrint(MAX_TRACE,("Done\n"));
-}
-
-NTSTATUS RawIPReceiveDatagram(
- PADDRESS_FILE AddrFile,
- PTDI_CONNECTION_INFORMATION ConnInfo,
- PCHAR BufferData,
- ULONG ReceiveLength,
- ULONG ReceiveFlags,
- PTDI_CONNECTION_INFORMATION ReturnInfo,
- PULONG BytesReceived,
- PDATAGRAM_COMPLETION_ROUTINE Complete,
- PVOID Context)
-/*
- * FUNCTION: Attempts to receive an RawIp datagram from a remote address
- * ARGUMENTS:
- * Request = Pointer to TDI request
- * ConnInfo = Pointer to connection information
- * Buffer = Pointer to NDIS buffer chain to store received data
- * ReceiveLength = Maximum size to use of buffer, 0 if all can be used
- * ReceiveFlags = Receive flags (None, Normal, Peek)
- * ReturnInfo = Pointer to structure for return information
- * BytesReceive = Pointer to structure for number of bytes received
- * RETURNS:
- * Status of operation
- * NOTES:
- * This is the high level interface for receiving RawIp datagrams
- */
-{
- KIRQL OldIrql;
- NTSTATUS Status;
- PDATAGRAM_RECEIVE_REQUEST ReceiveRequest;
-
- TI_DbgPrint(MAX_TRACE, ("Called.\n"));
-
- TcpipAcquireSpinLock(&AddrFile->Lock, &OldIrql);
-
- if (AF_IS_VALID(AddrFile))
- {
- ReceiveRequest = exAllocatePool(NonPagedPool, sizeof(DATAGRAM_RECEIVE_REQUEST));
- if (ReceiveRequest)
- {
- /* Initialize a receive request */
-
- /* Extract the remote address filter from the request (if any) */
- if ((ConnInfo->RemoteAddressLength != 0) &&
- (ConnInfo->RemoteAddress))
- {
- Status = AddrGetAddress(ConnInfo->RemoteAddress,
- &ReceiveRequest->RemoteAddress,
- &ReceiveRequest->RemotePort);
- if (!NT_SUCCESS(Status))
- {
- TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
- exFreePool(ReceiveRequest);
- return Status;
- }
- }
- else
- {
- ReceiveRequest->RemotePort = 0;
- }
- ReceiveRequest->ReturnInfo = ReturnInfo;
- ReceiveRequest->Buffer = BufferData;
- ReceiveRequest->BufferSize = ReceiveLength;
- ReceiveRequest->UserComplete = Complete;
- ReceiveRequest->UserContext = Context;
- ReceiveRequest->Complete =
- (PDATAGRAM_COMPLETION_ROUTINE)RawIpReceiveComplete;
- ReceiveRequest->Context = ReceiveRequest;
-
- /* Queue receive request */
- InsertTailList(&AddrFile->ReceiveQueue, &ReceiveRequest->ListEntry);
- AF_SET_PENDING(AddrFile, AFF_RECEIVE);
-
- TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
-
- TI_DbgPrint(MAX_TRACE, ("Leaving (pending).\n"));
-
- return STATUS_PENDING;
- }
- else
- {
- Status = STATUS_INSUFFICIENT_RESOURCES;
- }
- }
- else
- {
- Status = STATUS_INVALID_ADDRESS;
- }
-
- TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
-
- TI_DbgPrint(MAX_TRACE, ("Leaving with errors (0x%X).\n", Status));
-
- return Status;
-}
-
VOID RawIpReceive(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
/*
Modified: trunk/reactos/lib/drivers/ip/transport/udp/udp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/u…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/udp/udp.c (original)
+++ trunk/reactos/lib/drivers/ip/transport/udp/udp.c Fri Nov 23 16:52:56 2007
@@ -201,110 +201,6 @@
IPSendDatagram( &Packet, NCE, UDPSendPacketComplete, NULL );
return STATUS_SUCCESS;
-}
-
-VOID UDPReceiveComplete(PVOID Context, NTSTATUS Status, ULONG Count) {
- PDATAGRAM_RECEIVE_REQUEST ReceiveRequest =
- (PDATAGRAM_RECEIVE_REQUEST)Context;
- TI_DbgPrint(MAX_TRACE,("Called\n"));
- ReceiveRequest->UserComplete( ReceiveRequest->UserContext, Status, Count );
- exFreePool( ReceiveRequest );
- TI_DbgPrint(MAX_TRACE,("Done\n"));
-}
-
-NTSTATUS UDPReceiveDatagram(
- PADDRESS_FILE AddrFile,
- PTDI_CONNECTION_INFORMATION ConnInfo,
- PCHAR BufferData,
- ULONG ReceiveLength,
- ULONG ReceiveFlags,
- PTDI_CONNECTION_INFORMATION ReturnInfo,
- PULONG BytesReceived,
- PDATAGRAM_COMPLETION_ROUTINE Complete,
- PVOID Context)
-/*
- * FUNCTION: Attempts to receive an UDP datagram from a remote address
- * ARGUMENTS:
- * Request = Pointer to TDI request
- * ConnInfo = Pointer to connection information
- * Buffer = Pointer to NDIS buffer chain to store received data
- * ReceiveLength = Maximum size to use of buffer, 0 if all can be used
- * ReceiveFlags = Receive flags (None, Normal, Peek)
- * ReturnInfo = Pointer to structure for return information
- * BytesReceive = Pointer to structure for number of bytes received
- * RETURNS:
- * Status of operation
- * NOTES:
- * This is the high level interface for receiving UDP datagrams
- */
-{
- KIRQL OldIrql;
- NTSTATUS Status;
- PDATAGRAM_RECEIVE_REQUEST ReceiveRequest;
-
- TI_DbgPrint(MAX_TRACE, ("Called.\n"));
-
- TcpipAcquireSpinLock(&AddrFile->Lock, &OldIrql);
-
- if (AF_IS_VALID(AddrFile))
- {
- ReceiveRequest = exAllocatePool(NonPagedPool, sizeof(DATAGRAM_RECEIVE_REQUEST));
- if (ReceiveRequest)
- {
- /* Initialize a receive request */
-
- /* Extract the remote address filter from the request (if any) */
- if ((ConnInfo->RemoteAddressLength != 0) &&
- (ConnInfo->RemoteAddress))
- {
- Status = AddrGetAddress(ConnInfo->RemoteAddress,
- &ReceiveRequest->RemoteAddress,
- &ReceiveRequest->RemotePort);
- if (!NT_SUCCESS(Status))
- {
- TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
- exFreePool(ReceiveRequest);
- return Status;
- }
- }
- else
- {
- ReceiveRequest->RemotePort = 0;
- }
- ReceiveRequest->ReturnInfo = ReturnInfo;
- ReceiveRequest->Buffer = BufferData;
- ReceiveRequest->BufferSize = ReceiveLength;
- ReceiveRequest->UserComplete = Complete;
- ReceiveRequest->UserContext = Context;
- ReceiveRequest->Complete =
- (PDATAGRAM_COMPLETION_ROUTINE)UDPReceiveComplete;
- ReceiveRequest->Context = ReceiveRequest;
-
- /* Queue receive request */
- InsertTailList(&AddrFile->ReceiveQueue, &ReceiveRequest->ListEntry);
- AF_SET_PENDING(AddrFile, AFF_RECEIVE);
-
- TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
-
- TI_DbgPrint(MAX_TRACE, ("Leaving (pending).\n"));
-
- return STATUS_PENDING;
- }
- else
- {
- Status = STATUS_INSUFFICIENT_RESOURCES;
- }
- }
- else
- {
- Status = STATUS_INVALID_ADDRESS;
- }
-
- TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
-
- TI_DbgPrint(MAX_TRACE, ("Leaving with errors (0x%X).\n", Status));
-
- return Status;
}