Author: cmihail
Date: Wed Jun 1 13:27:35 2011
New Revision: 52042
URL:
http://svn.reactos.org/svn/reactos?rev=52042&view=rev
Log:
[TCPIP]
[FORMATTING]
This is just a code formatting phase. I reordered some of the code and put some debugging
DbgPrint-s in order to help understand the control and data flow. Working on trying to
stop the system from crashing when server socket gets closed.
Modified:
branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/bind.c
branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/connect.c
branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/listen.c
branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/main.c
branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/tdi.c
branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/dispatch.c
branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/fileobjs.c
branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/accept.c
branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c
branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/core/tcp.c
branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c
Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/bind.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/bind.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/bind.c [iso-8859-1] Wed Jun 1
13:27:35 2011
@@ -13,17 +13,20 @@
#include "tdiconn.h"
#include "debug.h"
-NTSTATUS WarmSocketForBind( PAFD_FCB FCB ) {
+NTSTATUS WarmSocketForBind( PAFD_FCB FCB )
+{
NTSTATUS Status;
AFD_DbgPrint(MID_TRACE,("Called (AF %d)\n",
FCB->LocalAddress->Address[0].AddressType));
- if( !FCB->TdiDeviceName.Length || !FCB->TdiDeviceName.Buffer ) {
+ if( !FCB->TdiDeviceName.Length || !FCB->TdiDeviceName.Buffer )
+ {
AFD_DbgPrint(MID_TRACE,("Null Device\n"));
return STATUS_NO_SUCH_DEVICE;
}
- if( !FCB->LocalAddress ) {
+ if( !FCB->LocalAddress )
+ {
AFD_DbgPrint(MID_TRACE,("No local address\n"));
return STATUS_INVALID_PARAMETER;
}
@@ -54,7 +57,8 @@
NTSTATUS NTAPI
AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
- PIO_STACK_LOCATION IrpSp) {
+ PIO_STACK_LOCATION IrpSp)
+{
NTSTATUS Status = STATUS_SUCCESS;
PFILE_OBJECT FileObject = IrpSp->FileObject;
PAFD_FCB FCB = FileObject->FsContext;
@@ -62,41 +66,44 @@
AFD_DbgPrint(MID_TRACE,("Called\n"));
- if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
- if( !(BindReq = LockRequest( Irp, IrpSp )) )
- return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY,
- Irp, 0 );
+ if ( !SocketAcquireStateLock( FCB ) )
+ return LostSocket( Irp );
+ if ( !(BindReq = LockRequest( Irp, IrpSp )) )
+ return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0 );
- if( FCB->LocalAddress ) ExFreePool( FCB->LocalAddress );
- FCB->LocalAddress = TaCopyTransportAddress( &BindReq->Address );
+ if ( FCB->LocalAddress ) ExFreePool( FCB->LocalAddress );
+ FCB->LocalAddress = TaCopyTransportAddress( &BindReq->Address );
- if( FCB->LocalAddress )
- Status = TdiBuildConnectionInfo( &FCB->AddressFrom,
- FCB->LocalAddress );
+ if (FCB->LocalAddress)
+ Status = TdiBuildConnectionInfo( &FCB->AddressFrom,
+ FCB->LocalAddress );
- if( NT_SUCCESS(Status) )
- Status = WarmSocketForBind( FCB );
+ if (NT_SUCCESS(Status))
+ Status = WarmSocketForBind( FCB );
+
AFD_DbgPrint(MID_TRACE,("FCB->Flags %x\n", FCB->Flags));
- if( !NT_SUCCESS(Status) )
+ if (!NT_SUCCESS(Status))
return UnlockAndMaybeComplete(FCB, Status, Irp, 0);
- if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS ) {
- AFD_DbgPrint(MID_TRACE,("Calling TdiReceiveDatagram\n"));
+ if (FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS)
+ {
+ AFD_DbgPrint(MID_TRACE,("Calling TdiReceiveDatagram\n"));
- Status = TdiReceiveDatagram
- ( &FCB->ReceiveIrp.InFlightRequest,
- FCB->AddressFile.Object,
- 0,
- FCB->Recv.Window,
- FCB->Recv.Size,
- FCB->AddressFrom,
- &FCB->ReceiveIrp.Iosb,
- PacketSocketRecvComplete,
- FCB );
+ Status = TdiReceiveDatagram
+ ( &FCB->ReceiveIrp.InFlightRequest,
+ FCB->AddressFile.Object,
+ 0,
+ FCB->Recv.Window,
+ FCB->Recv.Size,
+ FCB->AddressFrom,
+ &FCB->ReceiveIrp.Iosb,
+ PacketSocketRecvComplete,
+ FCB );
- /* We don't want to wait for this read to complete. */
- if( Status == STATUS_PENDING ) Status = STATUS_SUCCESS;
+ /* We don't want to wait for this read to complete. */
+ if (Status == STATUS_PENDING)
+ Status = STATUS_SUCCESS;
}
if (NT_SUCCESS(Status))
Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/connect.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/connect.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/connect.c [iso-8859-1] Wed Jun
1 13:27:35 2011
@@ -185,7 +185,8 @@
}
-NTSTATUS WarmSocketForConnection( PAFD_FCB FCB ) {
+NTSTATUS WarmSocketForConnection( PAFD_FCB FCB )
+{
NTSTATUS Status;
if( !FCB->TdiDeviceName.Length || !FCB->TdiDeviceName.Buffer )
@@ -198,7 +199,8 @@
&FCB->Connection.Handle,
&FCB->Connection.Object );
- if( NT_SUCCESS(Status) ) {
+ if( NT_SUCCESS(Status) )
+ {
Status = TdiAssociateAddressFile( FCB->AddressFile.Handle,
FCB->Connection.Object );
}
@@ -206,7 +208,8 @@
return Status;
}
-NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB ) {
+NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB )
+{
NTSTATUS Status;
ASSERT(!FCB->Recv.Window);
Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/listen.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/listen.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/listen.c [iso-8859-1] Wed Jun
1 13:27:35 2011
@@ -163,8 +163,8 @@
AFD_DbgPrint(MID_TRACE,("Completing listen request.\n"));
AFD_DbgPrint(MID_TRACE,("IoStatus was %x\n",
FCB->ListenIrp.Iosb.Status));
- DbgPrint("[ListenComplete] Completing listen request.\n");
- DbgPrint("[ListenComplete] IoStatus was %x\n",
FCB->ListenIrp.Iosb.Status);
+ DbgPrint("[AFD, ListenComplete] Completing listen request.\n");
+ DbgPrint("[AFD, ListenComplete] IoStatus was %x\n",
FCB->ListenIrp.Iosb.Status);
Qelt = ExAllocatePool( NonPagedPool, sizeof(*Qelt) );
if( !Qelt )
@@ -182,7 +182,7 @@
FCB->ListenIrp.
ConnectionReturnInfo->RemoteAddress));
- DbgPrint("[ListenComplete] Address Type: %d (RA %x)\n",
+ DbgPrint("[AFD, ListenComplete] Address Type: %d (RA %x)\n",
AddressType,
FCB->ListenIrp.
ConnectionReturnInfo->RemoteAddress);
@@ -250,7 +250,8 @@
AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB));
DbgPrint("[AfdListenSocket] Called on %x\n", FCB);
- if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
+ if( !SocketAcquireStateLock( FCB ) )
+ return LostSocket( Irp );
if( !(ListenReq = LockRequest( Irp, IrpSp )) )
return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0);
@@ -273,16 +274,16 @@
AFD_DbgPrint(MID_TRACE,("Status from warmsocket %x\n", Status));
DbgPrint("[AfdListenSocket] Status from warmsocket %x\n", Status);
- if( !NT_SUCCESS(Status) ) return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
-
- Status = TdiBuildNullConnectionInfo
- ( &FCB->ListenIrp.ConnectionCallInfo,
+ if ( !NT_SUCCESS(Status) )
+ return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
+
+ Status = TdiBuildNullConnectionInfo(&FCB->ListenIrp.ConnectionCallInfo,
FCB->LocalAddress->Address[0].AddressType );
- if (!NT_SUCCESS(Status)) return UnlockAndMaybeComplete(FCB, Status, Irp, 0);
-
- Status = TdiBuildNullConnectionInfo
- ( &FCB->ListenIrp.ConnectionReturnInfo,
+ if (!NT_SUCCESS(Status))
+ return UnlockAndMaybeComplete(FCB, Status, Irp, 0);
+
+ Status = TdiBuildNullConnectionInfo(&FCB->ListenIrp.ConnectionReturnInfo,
FCB->LocalAddress->Address[0].AddressType );
if (!NT_SUCCESS(Status))
@@ -302,14 +303,15 @@
ListenComplete,
FCB );
- if( Status == STATUS_PENDING )
- Status = STATUS_SUCCESS;
+ if (Status == STATUS_PENDING)
+ Status = STATUS_SUCCESS;
if (NT_SUCCESS(Status))
FCB->NeedsNewListen = FALSE;
AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
DbgPrint("[AfdListenSocket] Returning %x\n", Status);
+
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
}
@@ -360,7 +362,8 @@
}
NTSTATUS AfdAccept( PDEVICE_OBJECT DeviceObject, PIRP Irp,
- PIO_STACK_LOCATION IrpSp ) {
+ PIO_STACK_LOCATION IrpSp )
+{
NTSTATUS Status = STATUS_SUCCESS;
PFILE_OBJECT FileObject = IrpSp->FileObject;
PAFD_DEVICE_EXTENSION DeviceExt =
@@ -449,11 +452,11 @@
(PVOID *)&NewFileObject,
NULL );
- if( !NT_SUCCESS(Status) )
- return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
-
- ASSERT(NewFileObject != FileObject);
- ASSERT(NewFileObject->FsContext != FCB);
+ if( !NT_SUCCESS(Status) )
+ return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
+
+ ASSERT(NewFileObject != FileObject);
+ ASSERT(NewFileObject->FsContext != FCB);
/* We have a pending connection ... complete this irp right away */
Status = SatisfyAccept( DeviceExt, Irp, NewFileObject, PendingConnObj );
Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/main.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/main.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/main.c [iso-8859-1] Wed Jun 1
13:27:35 2011
@@ -25,13 +25,17 @@
#endif /* DBG */
-void OskitDumpBuffer( PCHAR Data, UINT Len ) {
+void OskitDumpBuffer( PCHAR Data, UINT Len )
+{
unsigned int i;
- for( i = 0; i < Len; i++ ) {
- if( i && !(i & 0xf) ) DbgPrint( "\n" );
- if( !(i & 0xf) ) DbgPrint( "%08x: ", (UINT)(Data + i) );
- DbgPrint( " %02x", Data[i] & 0xff );
+ for( i = 0; i < Len; i++ )
+ {
+ if( i && !(i & 0xf) )
+ DbgPrint( "\n" );
+ if( !(i & 0xf) )
+ DbgPrint( "%08x: ", (UINT)(Data + i) );
+ DbgPrint( " %02x", Data[i] & 0xff );
}
DbgPrint("\n");
}
@@ -239,7 +243,8 @@
static NTSTATUS NTAPI
AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
- PIO_STACK_LOCATION IrpSp) {
+ PIO_STACK_LOCATION IrpSp)
+{
PAFD_FCB FCB;
PFILE_OBJECT FileObject;
PAFD_DEVICE_EXTENSION DeviceExt;
@@ -263,25 +268,27 @@
EaInfo = Irp->AssociatedIrp.SystemBuffer;
- if( EaInfo ) {
- ConnectInfo = (PAFD_CREATE_PACKET)(EaInfo->EaName + EaInfo->EaNameLength + 1);
- EaInfoValue = (PWCHAR)(((PCHAR)ConnectInfo) + sizeof(AFD_CREATE_PACKET));
-
- EaLength = sizeof(FILE_FULL_EA_INFORMATION) +
- EaInfo->EaNameLength +
- EaInfo->EaValueLength;
-
- AFD_DbgPrint(MID_TRACE,("EaInfo: %x, EaInfoValue: %x\n",
- EaInfo, EaInfoValue));
+ if( EaInfo )
+ {
+ ConnectInfo = (PAFD_CREATE_PACKET)(EaInfo->EaName + EaInfo->EaNameLength +
1);
+ EaInfoValue = (PWCHAR)(((PCHAR)ConnectInfo) + sizeof(AFD_CREATE_PACKET));
+
+ EaLength = sizeof(FILE_FULL_EA_INFORMATION) +
+ EaInfo->EaNameLength +
+ EaInfo->EaValueLength;
+
+ AFD_DbgPrint(MID_TRACE,("EaInfo: %x, EaInfoValue: %x\n",
+ EaInfo, EaInfoValue));
}
AFD_DbgPrint(MID_TRACE,("About to allocate the new FCB\n"));
FCB = ExAllocatePool(NonPagedPool, sizeof(AFD_FCB));
- if( FCB == NULL ) {
- Irp->IoStatus.Status = STATUS_NO_MEMORY;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_NO_MEMORY;
+ if( FCB == NULL )
+ {
+ Irp->IoStatus.Status = STATUS_NO_MEMORY;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_NO_MEMORY;
}
AFD_DbgPrint(MID_TRACE,("Initializing the new FCB @ %x (FileObject %x Flags
%x)\n", FCB, FileObject, ConnectInfo ? ConnectInfo->EndpointFlags : 0));
@@ -299,8 +306,9 @@
KeInitializeMutex( &FCB->Mutex, 0 );
- for( i = 0; i < MAX_FUNCTIONS; i++ ) {
- InitializeListHead( &FCB->PendingIrpList[i] );
+ for( i = 0; i < MAX_FUNCTIONS; i++ )
+ {
+ InitializeListHead( &FCB->PendingIrpList[i] );
}
InitializeListHead( &FCB->DatagramList );
@@ -308,46 +316,53 @@
AFD_DbgPrint(MID_TRACE,("%x: Checking command channel\n", FCB));
- if( ConnectInfo ) {
- FCB->TdiDeviceName.Length = ConnectInfo->SizeOfTransportName;
- FCB->TdiDeviceName.MaximumLength = FCB->TdiDeviceName.Length;
- FCB->TdiDeviceName.Buffer =
- ExAllocatePool( NonPagedPool, FCB->TdiDeviceName.Length );
-
- if( !FCB->TdiDeviceName.Buffer ) {
- ExFreePool(FCB);
- AFD_DbgPrint(MID_TRACE,("Could not copy target string\n"));
- Irp->IoStatus.Status = STATUS_NO_MEMORY;
- IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
- return STATUS_NO_MEMORY;
- }
-
- RtlCopyMemory( FCB->TdiDeviceName.Buffer,
- ConnectInfo->TransportName,
- FCB->TdiDeviceName.Length );
-
- AFD_DbgPrint(MID_TRACE,("Success: %s %wZ\n",
- EaInfo->EaName, &FCB->TdiDeviceName));
- } else {
- AFD_DbgPrint(MID_TRACE,("Success: Control connection\n"));
+ if( ConnectInfo )
+ {
+ FCB->TdiDeviceName.Length = ConnectInfo->SizeOfTransportName;
+ FCB->TdiDeviceName.MaximumLength = FCB->TdiDeviceName.Length;
+ FCB->TdiDeviceName.Buffer =
+ ExAllocatePool( NonPagedPool, FCB->TdiDeviceName.Length );
+
+ if( !FCB->TdiDeviceName.Buffer )
+ {
+ ExFreePool(FCB);
+ AFD_DbgPrint(MID_TRACE,("Could not copy target string\n"));
+ Irp->IoStatus.Status = STATUS_NO_MEMORY;
+ IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
+ return STATUS_NO_MEMORY;
+ }
+
+ RtlCopyMemory( FCB->TdiDeviceName.Buffer,
+ ConnectInfo->TransportName,
+ FCB->TdiDeviceName.Length );
+
+ AFD_DbgPrint(MID_TRACE,("Success: %s %wZ\n",
+ EaInfo->EaName, &FCB->TdiDeviceName));
+ }
+ else
+ {
+ AFD_DbgPrint(MID_TRACE,("Success: Control connection\n"));
}
FileObject->FsContext = FCB;
/* It seems that UDP sockets are writable from inception */
- if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS ) {
+ if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS )
+ {
AFD_DbgPrint(MID_TRACE,("Packet oriented socket\n"));
- /* A datagram socket is always sendable */
- FCB->PollState |= AFD_EVENT_SEND;
- FCB->PollStatus[FD_WRITE_BIT] = STATUS_SUCCESS;
- PollReeval( FCB->DeviceExt, FCB->FileObject );
- }
-
- if( !NT_SUCCESS(Status) ) {
- if( FCB->TdiDeviceName.Buffer ) ExFreePool( FCB->TdiDeviceName.Buffer );
- ExFreePool( FCB );
- FileObject->FsContext = NULL;
+ /* A datagram socket is always sendable */
+ FCB->PollState |= AFD_EVENT_SEND;
+ FCB->PollStatus[FD_WRITE_BIT] = STATUS_SUCCESS;
+ PollReeval( FCB->DeviceExt, FCB->FileObject );
+ }
+
+ if( !NT_SUCCESS(Status) )
+ {
+ if( FCB->TdiDeviceName.Buffer )
+ ExFreePool( FCB->TdiDeviceName.Buffer );
+ ExFreePool( FCB );
+ FileObject->FsContext = NULL;
}
Irp->IoStatus.Status = Status;
@@ -413,12 +428,14 @@
InFlightRequest[3] = &FCB->ConnectIrp;
/* Cancel our pending requests */
- for( i = 0; i < IN_FLIGHT_REQUESTS; i++ ) {
- if( InFlightRequest[i]->InFlightRequest ) {
- AFD_DbgPrint(MID_TRACE,("Cancelling in flight irp %d (%x)\n",
- i, InFlightRequest[i]->InFlightRequest));
+ for( i = 0; i < IN_FLIGHT_REQUESTS; i++ )
+ {
+ if( InFlightRequest[i]->InFlightRequest )
+ {
+ AFD_DbgPrint(MID_TRACE,("Cancelling in flight irp %d (%x)\n",
+ i, InFlightRequest[i]->InFlightRequest));
IoCancelIrp(InFlightRequest[i]->InFlightRequest);
- }
+ }
}
KillSelectsForFCB( FCB->DeviceExt, FileObject, FALSE );
@@ -432,13 +449,13 @@
ExFreePool( FCB->Context );
if( FCB->Recv.Window )
- ExFreePool( FCB->Recv.Window );
+ ExFreePool( FCB->Recv.Window );
if( FCB->Send.Window )
- ExFreePool( FCB->Send.Window );
+ ExFreePool( FCB->Send.Window );
if( FCB->AddressFrom )
- ExFreePool( FCB->AddressFrom );
+ ExFreePool( FCB->AddressFrom );
if( FCB->ConnectInfo )
ExFreePool( FCB->ConnectInfo );
@@ -456,16 +473,16 @@
ExFreePool( FCB->DisconnectOptions );
if( FCB->LocalAddress )
- ExFreePool( FCB->LocalAddress );
+ ExFreePool( FCB->LocalAddress );
if( FCB->RemoteAddress )
- ExFreePool( FCB->RemoteAddress );
+ ExFreePool( FCB->RemoteAddress );
if( FCB->Connection.Object )
- ObDereferenceObject(FCB->Connection.Object);
+ ObDereferenceObject(FCB->Connection.Object);
if( FCB->AddressFile.Object )
- ObDereferenceObject(FCB->AddressFile.Object);
+ ObDereferenceObject(FCB->AddressFile.Object);
if( FCB->AddressFile.Handle != INVALID_HANDLE_VALUE )
{
@@ -484,7 +501,7 @@
}
if( FCB->TdiDeviceName.Buffer )
- ExFreePool(FCB->TdiDeviceName.Buffer);
+ ExFreePool(FCB->TdiDeviceName.Buffer);
ExFreePool(FCB);
@@ -499,7 +516,8 @@
static NTSTATUS NTAPI
AfdDisconnect(PDEVICE_OBJECT DeviceObject, PIRP Irp,
- PIO_STACK_LOCATION IrpSp) {
+ PIO_STACK_LOCATION IrpSp)
+{
PFILE_OBJECT FileObject = IrpSp->FileObject;
PAFD_FCB FCB = FileObject->FsContext;
PAFD_DISCONNECT_INFO DisReq;
@@ -549,7 +567,8 @@
FCB->ConnectInfo,
ConnectionReturnInfo);
- if (NT_SUCCESS(Status)) {
+ if (NT_SUCCESS(Status))
+ {
FCB->FilledDisconnectData = MIN(FCB->DisconnectDataSize,
ConnectionReturnInfo->UserDataLength);
if (FCB->FilledDisconnectData)
{
@@ -572,7 +591,8 @@
FCB->PollState |= AFD_EVENT_DISCONNECT;
FCB->PollStatus[FD_CLOSE_BIT] = STATUS_SUCCESS;
PollReeval( FCB->DeviceExt, FCB->FileObject );
- } else
+ }
+ else
Status = STATUS_INVALID_PARAMETER;
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/tdi.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/tdi.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/tdi.c [iso-8859-1] Wed Jun 1
13:27:35 2011
@@ -128,21 +128,27 @@
0, /* Create options */
EaInfo, /* EA buffer */
EaLength); /* EA length */
- if (NT_SUCCESS(Status)) {
+ if (NT_SUCCESS(Status))
+ {
Status = ObReferenceObjectByHandle(*Handle, /* Handle to
open file */
GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE,
/* Access mode */
IoFileObjectType, /* Object type
*/
KernelMode, /* Access mode
*/
(PVOID*)Object, /* Pointer to
object */
NULL); /* Handle
information */
- if (!NT_SUCCESS(Status)) {
+ if (!NT_SUCCESS(Status))
+ {
AFD_DbgPrint(MIN_TRACE, ("ObReferenceObjectByHandle() failed with status
(0x%X).\n", Status));
ZwClose(*Handle);
- } else {
+ }
+ else
+ {
AFD_DbgPrint(MAX_TRACE, ("Got handle (0x%X) Object (0x%X)\n",
*Handle, *Object));
}
- } else {
+ }
+ else
+ {
AFD_DbgPrint(MIN_TRACE, ("ZwCreateFile() failed with status (0x%X)\n",
Status));
}
@@ -329,14 +335,16 @@
AFD_DbgPrint(MAX_TRACE, ("Called\n"));
- if (!ConnectionObject) {
+ if (!ConnectionObject)
+ {
AFD_DbgPrint(MIN_TRACE, ("Bad connection object.\n"));
*Irp = NULL;
return STATUS_INVALID_PARAMETER;
}
DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
- if (!DeviceObject) {
+ if (!DeviceObject)
+ {
AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
*Irp = NULL;
return STATUS_INVALID_PARAMETER;
@@ -387,13 +395,15 @@
AFD_DbgPrint(MAX_TRACE, ("Called. AddressHandle (0x%X) ConnectionObject
(0x%X)\n",
AddressHandle, ConnectionObject));
- if (!ConnectionObject) {
+ if (!ConnectionObject)
+ {
AFD_DbgPrint(MIN_TRACE, ("Bad connection object.\n"));
return STATUS_INVALID_PARAMETER;
}
DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
- if (!DeviceObject) {
+ if (!DeviceObject)
+ {
AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
return STATUS_INVALID_PARAMETER;
}
@@ -442,16 +452,19 @@
PDEVICE_OBJECT DeviceObject;
NTSTATUS Status;
- AFD_DbgPrint(MAX_TRACE, ("Called\n"));
-
- if (!ConnectionObject) {
+ AFD_DbgPrint(MAX_TRACE, ("[AFD, TDIListen] Called\n"));
+ DbgPrint("[AFD, TDIListen] Called\n");
+
+ if (!ConnectionObject)
+ {
AFD_DbgPrint(MIN_TRACE, ("Bad connection object.\n"));
*Irp = NULL;
return STATUS_INVALID_PARAMETER;
}
DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
- if (!DeviceObject) {
+ if (!DeviceObject)
+ {
AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
*Irp = NULL;
return STATUS_INVALID_PARAMETER;
@@ -475,6 +488,8 @@
*ReturnConnectionInfo); /* Return connection information */
Status = TdiCall(*Irp, DeviceObject, NULL /* Don't wait for completion */, Iosb);
+
+ DbgPrint("[AFD, TDIListen] Done. Status = 0x%x\n", Status);
return Status;
}
Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/dispatch.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1] Wed
Jun 1 13:27:35 2011
@@ -13,19 +13,21 @@
#include <pseh/pseh2.h>
-NTSTATUS IRPFinish( PIRP Irp, NTSTATUS Status ) {
+NTSTATUS IRPFinish( PIRP Irp, NTSTATUS Status )
+{
KIRQL OldIrql;
Irp->IoStatus.Status = Status;
- if( Status == STATUS_PENDING )
- IoMarkIrpPending( Irp );
- else {
+ if (Status == STATUS_PENDING)
+ IoMarkIrpPending( Irp );
+ else
+ {
IoAcquireCancelSpinLock(&OldIrql);
- (void)IoSetCancelRoutine( Irp, NULL );
+ (void)IoSetCancelRoutine( Irp, NULL );
IoReleaseCancelSpinLock(OldIrql);
- IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
+ IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
}
return Status;
@@ -56,7 +58,8 @@
IoAcquireCancelSpinLock(&OldIrql);
- if (!Irp->Cancel && !TransContext->CancelIrps) {
+ if (!Irp->Cancel && !TransContext->CancelIrps)
+ {
(void)IoSetCancelRoutine(Irp, CancelRoutine);
IoReleaseCancelSpinLock(OldIrql);
@@ -144,38 +147,41 @@
#endif
/* Try canceling the request */
- switch(MinorFunction) {
- case TDI_SEND:
- case TDI_RECEIVE:
- DequeuedIrp = TCPRemoveIRP( TranContext->Handle.ConnectionContext, Irp );
- break;
-
- case TDI_SEND_DATAGRAM:
- if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
- TI_DbgPrint(MIN_TRACE, ("TDI_SEND_DATAGRAM, but no address
file.\n"));
+ switch(MinorFunction)
+ {
+ case TDI_SEND:
+ case TDI_RECEIVE:
+ DequeuedIrp = TCPRemoveIRP( TranContext->Handle.ConnectionContext, Irp );
break;
- }
-
- DequeuedIrp = DGRemoveIRP(TranContext->Handle.AddressHandle, Irp);
- break;
-
- case TDI_RECEIVE_DATAGRAM:
- if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
- TI_DbgPrint(MIN_TRACE, ("TDI_RECEIVE_DATAGRAM, but no address
file.\n"));
+
+ case TDI_SEND_DATAGRAM:
+ if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE)
+ {
+ TI_DbgPrint(MIN_TRACE, ("TDI_SEND_DATAGRAM, but no address
file.\n"));
+ break;
+ }
+
+ DequeuedIrp = DGRemoveIRP(TranContext->Handle.AddressHandle, Irp);
break;
- }
-
- DequeuedIrp = DGRemoveIRP(TranContext->Handle.AddressHandle, Irp);
- break;
-
- case TDI_CONNECT:
- DequeuedIrp = TCPRemoveIRP(TranContext->Handle.ConnectionContext, Irp);
- break;
-
- default:
- TI_DbgPrint(MIN_TRACE, ("Unknown IRP. MinorFunction (0x%X).\n",
MinorFunction));
- ASSERT(FALSE);
- break;
+
+ case TDI_RECEIVE_DATAGRAM:
+ if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE)
+ {
+ TI_DbgPrint(MIN_TRACE, ("TDI_RECEIVE_DATAGRAM, but no address
file.\n"));
+ break;
+ }
+
+ DequeuedIrp = DGRemoveIRP(TranContext->Handle.AddressHandle, Irp);
+ break;
+
+ case TDI_CONNECT:
+ DequeuedIrp = TCPRemoveIRP(TranContext->Handle.ConnectionContext, Irp);
+ break;
+
+ default:
+ TI_DbgPrint(MIN_TRACE, ("Unknown IRP. MinorFunction (0x%X).\n",
MinorFunction));
+ ASSERT(FALSE);
+ break;
}
if (DequeuedIrp)
@@ -256,99 +262,107 @@
* Status of operation
*/
{
- PTDI_REQUEST_KERNEL_ASSOCIATE Parameters;
- PTRANSPORT_CONTEXT TranContext;
- PIO_STACK_LOCATION IrpSp;
- PCONNECTION_ENDPOINT Connection;
- PFILE_OBJECT FileObject;
- PADDRESS_FILE AddrFile = NULL;
- NTSTATUS Status;
- KIRQL OldIrql;
-
- TI_DbgPrint(DEBUG_IRP, ("[TCPIP, DispTdiAssociateAddress] Called\n"));
-
- IrpSp = IoGetCurrentIrpStackLocation(Irp);
-
- /* Get associated connection endpoint file object. Quit if none exists */
-
- TranContext = IrpSp->FileObject->FsContext;
- if (!TranContext) {
- TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
- return STATUS_INVALID_PARAMETER;
- }
-
- Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
- if (!Connection) {
- TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
- return STATUS_INVALID_PARAMETER;
- }
-
- Parameters = (PTDI_REQUEST_KERNEL_ASSOCIATE)&IrpSp->Parameters;
-
- Status = ObReferenceObjectByHandle(
- Parameters->AddressHandle,
- 0,
- IoFileObjectType,
- KernelMode,
- (PVOID*)&FileObject,
- NULL);
- if (!NT_SUCCESS(Status)) {
- TI_DbgPrint(MID_TRACE, ("Bad address file object handle (0x%X): %x.\n",
- Parameters->AddressHandle, Status));
- return STATUS_INVALID_PARAMETER;
- }
-
- LockObject(Connection, &OldIrql);
-
- if (Connection->AddressFile) {
+ PTDI_REQUEST_KERNEL_ASSOCIATE Parameters;
+ PTRANSPORT_CONTEXT TranContext;
+ PIO_STACK_LOCATION IrpSp;
+ PCONNECTION_ENDPOINT Connection;
+ PFILE_OBJECT FileObject;
+ PADDRESS_FILE AddrFile = NULL;
+ NTSTATUS Status;
+ KIRQL OldIrql;
+
+ TI_DbgPrint(DEBUG_IRP, ("[TCPIP, DispTdiAssociateAddress] Called\n"));
+
+ IrpSp = IoGetCurrentIrpStackLocation(Irp);
+
+ /* Get associated connection endpoint file object. Quit if none exists */
+
+ TranContext = IrpSp->FileObject->FsContext;
+ if (!TranContext)
+ {
+ TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
+ if (!Connection)
+ {
+ TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ Parameters = (PTDI_REQUEST_KERNEL_ASSOCIATE)&IrpSp->Parameters;
+
+ Status = ObReferenceObjectByHandle(
+ Parameters->AddressHandle,
+ 0,
+ IoFileObjectType,
+ KernelMode,
+ (PVOID*)&FileObject,
+ NULL);
+
+ if (!NT_SUCCESS(Status))
+ {
+ TI_DbgPrint(MID_TRACE, ("Bad address file object handle (0x%X):
%x.\n",
+ Parameters->AddressHandle, Status));
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ LockObject(Connection, &OldIrql);
+
+ if (Connection->AddressFile)
+ {
+ ObDereferenceObject(FileObject);
+ UnlockObject(Connection, OldIrql);
+ TI_DbgPrint(MID_TRACE, ("An address file is already asscociated.\n"));
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE)
+ {
+ ObDereferenceObject(FileObject);
+ UnlockObject(Connection, OldIrql);
+ TI_DbgPrint(MID_TRACE, ("Bad address file object. Magic (0x%X).\n",
+ FileObject->FsContext2));
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Get associated address file object. Quit if none exists */
+
+ TranContext = FileObject->FsContext;
+ if (!TranContext)
+ {
+ ObDereferenceObject(FileObject);
+ UnlockObject(Connection, OldIrql);
+ TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
+ if (!AddrFile)
+ {
+ UnlockObject(Connection, OldIrql);
+ ObDereferenceObject(FileObject);
+ TI_DbgPrint(MID_TRACE, ("No address file object.\n"));
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ LockObjectAtDpcLevel(AddrFile);
+
+ ReferenceObject(AddrFile);
+ Connection->AddressFile = AddrFile;
+
+ /* Add connection endpoint to the address file */
+ ReferenceObject(Connection);
+ AddrFile->Connection = Connection;
+
+ /* FIXME: Maybe do this in DispTdiDisassociateAddress() instead? */
ObDereferenceObject(FileObject);
+
+ UnlockObjectFromDpcLevel(AddrFile);
UnlockObject(Connection, OldIrql);
- TI_DbgPrint(MID_TRACE, ("An address file is already asscociated.\n"));
- return STATUS_INVALID_PARAMETER;
- }
-
- if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
- ObDereferenceObject(FileObject);
- UnlockObject(Connection, OldIrql);
- TI_DbgPrint(MID_TRACE, ("Bad address file object. Magic (0x%X).\n",
- FileObject->FsContext2));
- return STATUS_INVALID_PARAMETER;
- }
-
- /* Get associated address file object. Quit if none exists */
-
- TranContext = FileObject->FsContext;
- if (!TranContext) {
- ObDereferenceObject(FileObject);
- UnlockObject(Connection, OldIrql);
- TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
- return STATUS_INVALID_PARAMETER;
- }
-
- AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
- if (!AddrFile) {
- UnlockObject(Connection, OldIrql);
- ObDereferenceObject(FileObject);
- TI_DbgPrint(MID_TRACE, ("No address file object.\n"));
- return STATUS_INVALID_PARAMETER;
- }
-
- LockObjectAtDpcLevel(AddrFile);
-
- ReferenceObject(AddrFile);
- Connection->AddressFile = AddrFile;
-
- /* Add connection endpoint to the address file */
- ReferenceObject(Connection);
- AddrFile->Connection = Connection;
-
- /* FIXME: Maybe do this in DispTdiDisassociateAddress() instead? */
- ObDereferenceObject(FileObject);
-
- UnlockObjectFromDpcLevel(AddrFile);
- UnlockObject(Connection, OldIrql);
-
- return Status;
+
+ return Status;
}
@@ -394,7 +408,8 @@
Irp,
DispCancelRequest);
- if (NT_SUCCESS(Status)) {
+ if (NT_SUCCESS(Status))
+ {
Status = TCPConnect(
TranContext->Handle.ConnectionContext,
Parameters->RequestConnectionInformation,
@@ -505,7 +520,8 @@
}
Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
- if (!Connection) {
+ if (!Connection)
+ {
TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
Status = STATUS_INVALID_PARAMETER;
goto done;
@@ -541,103 +557,107 @@
* Status of operation
*/
{
- PCONNECTION_ENDPOINT Connection;
- PTDI_REQUEST_KERNEL Parameters;
- PTRANSPORT_CONTEXT TranContext;
- PIO_STACK_LOCATION IrpSp;
- NTSTATUS Status = STATUS_SUCCESS;
- KIRQL OldIrql;
-
- TI_DbgPrint(DEBUG_IRP, ("[TCPIP, DispTdiListen] Called\n"));
-
- IrpSp = IoGetCurrentIrpStackLocation(Irp);
-
- /* Get associated connection endpoint file object. Quit if none exists */
-
- TranContext = IrpSp->FileObject->FsContext;
- if (TranContext == NULL)
- {
- TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
- Status = STATUS_INVALID_PARAMETER;
- goto done;
- }
-
- Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
- if (Connection == NULL)
- {
- TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
- Status = STATUS_INVALID_PARAMETER;
- goto done;
- }
-
- Parameters = (PTDI_REQUEST_KERNEL)&IrpSp->Parameters;
-
- Status = DispPrepareIrpForCancel
- (TranContext->Handle.ConnectionContext,
- Irp,
- (PDRIVER_CANCEL)DispCancelListenRequest);
-
- LockObject(Connection, &OldIrql);
-
- if (Connection->AddressFile == NULL)
- {
- TI_DbgPrint(MID_TRACE, ("No associated address file\n"));
- UnlockObject(Connection, OldIrql);
- Status = STATUS_INVALID_PARAMETER;
- goto done;
- }
-
- LockObjectAtDpcLevel(Connection->AddressFile);
-
- /* Listening will require us to create a listening socket and store it in
- * the address file. It will be signalled, and attempt to complete an irp
- * when a new connection arrives. */
- /* The important thing to note here is that the irp we'll complete belongs
- * to the socket to be accepted onto, not the listener */
- if( NT_SUCCESS(Status) && !Connection->AddressFile->Listener ) {
- Connection->AddressFile->Listener =
- TCPAllocateConnectionEndpoint( NULL );
-
- if( !Connection->AddressFile->Listener )
- Status = STATUS_NO_MEMORY;
-
- if( NT_SUCCESS(Status) ) {
- ReferenceObject(Connection->AddressFile);
- Connection->AddressFile->Listener->AddressFile =
- Connection->AddressFile;
-
- Status = TCPSocket( Connection->AddressFile->Listener,
- Connection->AddressFile->Family,
- SOCK_STREAM,
- Connection->AddressFile->Protocol );
- }
-
- if( NT_SUCCESS(Status) )
- Status = TCPListen( Connection->AddressFile->Listener, 1024 );
- /* BACKLOG */
- }
-
- if( NT_SUCCESS(Status) ) {
- Status = TCPAccept
- ( (PTDI_REQUEST)Parameters,
- Connection->AddressFile->Listener,
- Connection,
- DispDataRequestComplete,
- Irp );
- }
-
- UnlockObjectFromDpcLevel(Connection->AddressFile);
- UnlockObject(Connection, OldIrql);
+ PCONNECTION_ENDPOINT Connection;
+ PTDI_REQUEST_KERNEL Parameters;
+ PTRANSPORT_CONTEXT TranContext;
+ PIO_STACK_LOCATION IrpSp;
+ NTSTATUS Status = STATUS_SUCCESS;
+ KIRQL OldIrql;
+
+ TI_DbgPrint(DEBUG_IRP, ("[TCPIP, DispTdiListen] Called\n"));
+ DbgPrint("[TCPIP, DispTdiListen] Called\n");
+
+ IrpSp = IoGetCurrentIrpStackLocation(Irp);
+
+ /* Get associated connection endpoint file object. Quit if none exists */
+
+ TranContext = IrpSp->FileObject->FsContext;
+ if (TranContext == NULL)
+ {
+ TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
+ Status = STATUS_INVALID_PARAMETER;
+ goto done;
+ }
+
+ Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
+ if (Connection == NULL)
+ {
+ TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
+ Status = STATUS_INVALID_PARAMETER;
+ goto done;
+ }
+
+ Parameters = (PTDI_REQUEST_KERNEL)&IrpSp->Parameters;
+
+ Status = DispPrepareIrpForCancel
+ (TranContext->Handle.ConnectionContext,
+ Irp,
+ (PDRIVER_CANCEL)DispCancelListenRequest);
+
+ LockObject(Connection, &OldIrql);
+
+ if (Connection->AddressFile == NULL)
+ {
+ TI_DbgPrint(MID_TRACE, ("No associated address file\n"));
+ UnlockObject(Connection, OldIrql);
+ Status = STATUS_INVALID_PARAMETER;
+ goto done;
+ }
+
+ LockObjectAtDpcLevel(Connection->AddressFile);
+
+ /* Listening will require us to create a listening socket and store it in
+ * the address file. It will be signalled, and attempt to complete an irp
+ * when a new connection arrives. */
+ /* The important thing to note here is that the irp we'll complete belongs
+ * to the socket to be accepted onto, not the listener */
+ if( NT_SUCCESS(Status) && !Connection->AddressFile->Listener )
+ {
+ Connection->AddressFile->Listener = TCPAllocateConnectionEndpoint( NULL );
+
+ if( !Connection->AddressFile->Listener )
+ Status = STATUS_NO_MEMORY;
+
+ if( NT_SUCCESS(Status) )
+ {
+ ReferenceObject(Connection->AddressFile);
+ Connection->AddressFile->Listener->AddressFile =
Connection->AddressFile;
+
+ Status = TCPSocket( Connection->AddressFile->Listener,
+ Connection->AddressFile->Family,
+ SOCK_STREAM,
+ Connection->AddressFile->Protocol );
+ }
+
+ if ( NT_SUCCESS(Status) )
+ Status = TCPListen( Connection->AddressFile->Listener, 1024 );
+ /* BACKLOG */
+ }
+
+ if (NT_SUCCESS(Status))
+ {
+ Status = TCPAccept( (PTDI_REQUEST)Parameters,
+ Connection->AddressFile->Listener,
+ Connection,
+ DispDataRequestComplete,
+ Irp );
+ }
+
+ UnlockObjectFromDpcLevel(Connection->AddressFile);
+ UnlockObject(Connection, OldIrql);
done:
- if (Status != STATUS_PENDING) {
- DispDataRequestComplete(Irp, Status, 0);
- } else
- IoMarkIrpPending(Irp);
-
- TI_DbgPrint(MID_TRACE,("[TCPIP, DispTdiListen] Leaving %x\n", Status));
-
- return Status;
+ if (Status != STATUS_PENDING)
+ {
+ DispDataRequestComplete(Irp, Status, 0);
+ }
+ else
+ IoMarkIrpPending(Irp);
+
+ TI_DbgPrint(MID_TRACE,("[TCPIP, DispTdiListen] Leaving %x\n", Status));
+ DbgPrint("[TCPIP, DispTdiListen] Leaving %x\n", Status);
+
+ return Status;
}
Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/fileobjs.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/fileobjs.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/fileobjs.c [iso-8859-1] Wed
Jun 1 13:27:35 2011
@@ -413,15 +413,18 @@
NTSTATUS Status;
PCONNECTION_ENDPOINT Connection;
- TI_DbgPrint(MID_TRACE, ("Called.\n"));
+ TI_DbgPrint(MID_TRACE, ("[TCPIP, FileOpenConnection] Called\n"));
+ //DbgPrint("[TCPIP, FileOpenConnection] Called\n");
Connection = TCPAllocateConnectionEndpoint( ClientContext );
- if( !Connection ) return STATUS_NO_MEMORY;
+ if (!Connection)
+ return STATUS_NO_MEMORY;
Status = TCPSocket( Connection, AF_INET, SOCK_STREAM, IPPROTO_TCP );
- if( !NT_SUCCESS(Status) ) {
+ if (!NT_SUCCESS(Status))
+ {
DereferenceObject( Connection );
return Status;
}
@@ -429,7 +432,8 @@
/* Return connection endpoint file object */
Request->Handle.ConnectionContext = Connection;
- TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
+ TI_DbgPrint(MAX_TRACE, ("[TCPIP, FileOpenConnection] Leaving\n"));
+ //DbgPrint("[TCPIP, FileOpenConnection] Leaving\n");
return STATUS_SUCCESS;
}
Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/accept.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/accept.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/accept.c [iso-8859-1] Wed
Jun 1 13:27:35 2011
@@ -58,6 +58,7 @@
LockObject(Connection, &OldIrql);
TI_DbgPrint(DEBUG_TCP,("[IP, TCPListen] Called\n"));
+ DbgPrint("[IP, TCPListen] Called\n");
TI_DbgPrint(DEBUG_TCP, ("Connection->SocketContext %x\n",
Connection->SocketContext));
@@ -78,6 +79,7 @@
UnlockObject(Connection, OldIrql);
TI_DbgPrint(DEBUG_TCP,("[IP, TCPListen] Leaving. Status = %x\n", Status));
+ DbgPrint("[IP, TCPListen] Leaving. Status = %x\n", Status);
return Status;
}
@@ -89,6 +91,8 @@
PTDI_BUCKET Bucket;
KIRQL OldIrql;
BOOLEAN Found = FALSE;
+
+ DbgPrint("[IP, TCPAbortListenForSocket] Called\n");
LockObject(Listener, &OldIrql);
@@ -110,6 +114,9 @@
}
UnlockObject(Listener, OldIrql);
+
+ DbgPrint("[IP, TCPAbortListenForSocket] Leaving. Status = %s\n",
+ Found == TRUE ? "TRUE" : "FALSE");
return Found;
}
Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] Wed Jun
1 13:27:35 2011
@@ -83,6 +83,9 @@
TI_DbgPrint(DEBUG_TCP,("[IP, TCPSocket] Called: Connection %x, Family %d, Type
%d, "
"Proto %d\n",
Connection, Family, Type, Proto));
+ DbgPrint("[IP, TCPSocket] Called: Connection %x, Family %d, Type %d, "
+ "Proto %d\n",
+ Connection, Family, Type, Proto);
Connection->SocketContext = LibTCPSocket(Connection);
if (Connection->SocketContext)
@@ -93,6 +96,7 @@
UnlockObject(Connection, OldIrql);
TI_DbgPrint(DEBUG_TCP,("[IP, TCPSocket] Leaving. Status = 0x%x\n",
Status));
+ DbgPrint("[IP, TCPSocket] Leaving. Status = 0x%x\n", Status);
return Status;
}
Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/core/tcp.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/core/tcp.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/core/tcp.c [iso-8859-1] Wed Jun 1
13:27:35 2011
@@ -138,6 +138,8 @@
tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
{
err_t err;
+
+ LWIP_DEBUGF(TCP_DEBUG, ("tcp_close_shutdown: called on pcb %x\n", pcb));
if (rst_on_unacked_data && (pcb->state != LISTEN)) {
if ((pcb->refused_data != NULL) || (pcb->rcv_wnd != TCP_WND)) {
Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] Wed Jun 1
13:27:35 2011
@@ -58,7 +58,7 @@
err_t
InternalSendEventHandler(void *arg, struct tcp_pcb *pcb, u16_t space)
{
- DbgPrint("[InternalSendEventHandler] SendEvent (0x%x, 0x%x, %d)\n",
+ DbgPrint("[lwIP, InternalSendEventHandler] SendEvent (0x%x, 0x%x, %d)\n",
arg, pcb, (unsigned int)space);
/* Make sure the socket didn't get closed */
@@ -75,7 +75,7 @@
{
u32_t len;
- DbgPrint("[InternalRecvEventHandler] RecvEvent (0x%x, 0x%x, 0x%x, %d)\n",
+ DbgPrint("[lwIP, InternalRecvEventHandler] RecvEvent (0x%x, 0x%x, 0x%x,
%d)\n",
arg, pcb, p, (unsigned int)err);
/* Make sure the socket didn't get closed */
@@ -91,7 +91,7 @@
}
else
{
- DbgPrint("[InternalRecvEventHandler] RECV - p:0x%x p->payload:0x%x
p->len:%d p->tot_len:%d\n",
+ DbgPrint("[lwIP, InternalRecvEventHandler] RECV - p:0x%x p->payload:0x%x
p->len:%d p->tot_len:%d\n",
p, p->payload, p->len, p->tot_len);
if (err == ERR_OK)
@@ -124,14 +124,14 @@
err_t
InternalAcceptEventHandler(void *arg, struct tcp_pcb *newpcb, err_t err)
{
- DbgPrint("[InternalAcceptEventHandler] AcceptEvent (0x%x, 0x%x, %d)\n",
+ DbgPrint("[lwIP, InternalAcceptEventHandler] AcceptEvent (0x%x, 0x%x,
%d)\n",
arg, newpcb, (unsigned int)err);
/* Make sure the socket didn't get closed */
if (!arg)
return ERR_ABRT;
- DbgPrint("[InternalAcceptEventHandler] newpcb->state = %s\n",
+ DbgPrint("[lwIP, InternalAcceptEventHandler] newpcb->state = %s\n",
tcp_state_str[newpcb->state]);
TCPAcceptEventHandler(arg, newpcb);
@@ -147,7 +147,7 @@
err_t
InternalConnectEventHandler(void *arg, struct tcp_pcb *pcb, err_t err)
{
- DbgPrint("[InternalConnectEventHandler] ConnectEvent(0x%x, 0x%x, %d)\n",
+ DbgPrint("[lwIP, InternalConnectEventHandler] ConnectEvent(0x%x, 0x%x,
%d)\n",
arg, pcb, (unsigned int)err);
/* Make sure the socket didn't get closed */
@@ -165,7 +165,8 @@
void
InternalErrorEventHandler(void *arg, err_t err)
{
- DbgPrint("ErrorEvent(0x%x, %d)\n", arg, (unsigned int)err);
+ DbgPrint("[lwIP, InternalErrorEventHandler] ErrorEvent(0x%x, %d)\n",
+ arg, (unsigned int)err);
/* Make sure the socket didn't get closed */
if (!arg) return;
@@ -197,8 +198,8 @@
if (msg->NewPcb)
{
- tcp_arg(msg->NewPcb, msg->Arg);
- tcp_err(msg->NewPcb, InternalErrorEventHandler);
+ tcp_arg((struct tcp_pcb*)msg->NewPcb, msg->Arg);
+ tcp_err((struct tcp_pcb*)msg->NewPcb, InternalErrorEventHandler);
}
KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE);
@@ -222,11 +223,11 @@
else
ret = NULL;
- DbgPrint("LibTCPSocket(0x%x) = 0x%x\n", arg, ret);
+ DbgPrint("[lwIP, LibTCPSocket] (0x%x) = 0x%x\n", arg, ret);
ExFreePool(msg);
- return ret;
+ return (struct tcp_pcb*)ret;
}
return NULL;
@@ -267,6 +268,8 @@
if (!pcb)
return ERR_CLSD;
+
+ DbgPrint("[lwIP, LibTCPBind] Called\n");
msg = ExAllocatePool(NonPagedPool, sizeof(struct bind_callback_msg));
if (msg)
@@ -283,7 +286,9 @@
else
ret = ERR_CLSD;
- DbgPrint("LibTCPBind(0x%x)\n", pcb);
+ DbgPrint("[lwIP, LibTCPBind] pcb = 0x%x\n", pcb);
+
+ DbgPrint("[lwIP, LibTCPBind] Done\n");
ExFreePool(msg);
@@ -314,6 +319,8 @@
void *p;
ASSERT(msg);
+
+ DbgPrint("[lwIP, LibTCPListenCallback] Called\n");
p = msg->Pcb->callback_arg;
msg->NewPcb = tcp_listen_with_backlog(msg->Pcb, msg->Backlog);
@@ -324,6 +331,8 @@
tcp_accept(msg->NewPcb, InternalAcceptEventHandler);
tcp_err(msg->NewPcb, InternalErrorEventHandler);
}
+
+ DbgPrint("[lwIP, LibTCPListenCallback] Done\n");
KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE);
}
@@ -333,6 +342,8 @@
{
struct listen_callback_msg *msg;
void *ret;
+
+ DbgPrint("[lwIP, LibTCPListen] Called\n");
if (!pcb)
return NULL;
@@ -351,7 +362,9 @@
else
ret = NULL;
- DbgPrint("LibTCPListen(0x%x,0x%x)\n", pcb, ret);
+ DbgPrint("[lwIP, LibTCPListen] pcb = 0x%x \n", pcb);
+
+ DbgPrint("[lwIP, LibTCPListen] Done\n");
ExFreePool(msg);
@@ -453,7 +466,7 @@
{
struct connect_callback_msg *msg = arg;
- DbgPrint("[LibTCPConnectCallback] Called\n");
+ DbgPrint("[lwIP, LibTCPConnectCallback] Called\n");
ASSERT(arg);
@@ -463,7 +476,7 @@
KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE);
- DbgPrint("[LibTCPConnectCallback] Done\n");
+ DbgPrint("[lwIP, LibTCPConnectCallback] Done\n");
}
err_t
@@ -471,6 +484,8 @@
{
struct connect_callback_msg *msg;
err_t ret;
+
+ DbgPrint("[lwIP, LibTCPConnect] Called\n");
if (!pcb)
return ERR_CLSD;
@@ -491,8 +506,10 @@
ret = ERR_CLSD;
ExFreePool(msg);
-
- DbgPrint("LibTCPConnect(0x%x)\n", pcb);
+
+ DbgPrint("[lwIP, LibTCPConnect] pcb = 0x%x\n", pcb);
+
+ DbgPrint("[lwIP, LibTCPConnect] Done\n");
return ret;
}
@@ -528,21 +545,35 @@
{
struct close_callback_msg *msg;
err_t ret;
+
+ DbgPrint("[lwIP, LibTCPClose] Called\n");
if (!pcb)
+ {
+ DbgPrint("[lwIP, LibTCPClose] Done... NO pcb\n");
return ERR_CLSD;
+ }
+
+ DbgPrint("[lwIP, LibTCPClose] Removing pcb callbacks\n");
tcp_arg(pcb, NULL);
tcp_recv(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_err(pcb, NULL);
tcp_accept(pcb, NULL);
+
+ DbgPrint("[lwIP, LibTCPClose] Attempting to allocate memory for msg\n");
msg = ExAllocatePool(NonPagedPool, sizeof(struct close_callback_msg));
if (msg)
{
+ DbgPrint("[lwIP, LibTCPClose] Initializing msg->Event\n");
KeInitializeEvent(&msg->Event, NotificationEvent, FALSE);
+
+ DbgPrint("[lwIP, LibTCPClose] Initializing msg->pcb = 0x%x\n",
pcb);
msg->Pcb = pcb;
+
+ DbgPrint("[lwIP, LibTCPClose] Attempting to call
LibTCPCloseCallback\n");
tcpip_callback_with_block(LibTCPCloseCallback, msg, 1);
@@ -553,10 +584,14 @@
ExFreePool(msg);
- DbgPrint("LibTCPClose(0x%x)\n", pcb);
+ DbgPrint("[lwIP, LibTCPClose] pcb = 0x%x\n", pcb);
+
+ DbgPrint("[lwIP, LibTCPClose] Done\n");
return ret;
}
+
+ DbgPrint("[lwIP, LibTCPClose] Failed to allocate memory\n");
return ERR_MEM;
}
@@ -564,7 +599,7 @@
void
LibTCPAccept(struct tcp_pcb *pcb, struct tcp_pcb *listen_pcb, void *arg)
{
- DbgPrint("[LibTCPAccept] (pcb, arg) = (0x%x, 0x%x)\n", pcb, arg);
+ DbgPrint("[lwIP, LibTCPAccept] Called. (pcb, arg) = (0x%x, 0x%x)\n", pcb,
arg);
ASSERT(arg);
@@ -575,13 +610,13 @@
tcp_accepted(listen_pcb);
- DbgPrint("[LibTCPAccept] Done\n");
+ DbgPrint("[lwIP, LibTCPAccept] Done\n");
}
err_t
LibTCPGetHostName(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t *port)
{
- DbgPrint("[LibTCPGetHostName] pcb = (0x%x)\n", pcb);
+ DbgPrint("[lwIP, LibTCPGetHostName] Called. pcb = (0x%x)\n", pcb);
if (!pcb)
return ERR_CLSD;
@@ -589,7 +624,9 @@
*ipaddr = pcb->local_ip;
*port = pcb->local_port;
- DbgPrint("Got host port: %d\n", *port);
+ DbgPrint("[lwIP, LibTCPGetHostName] Got host port: %d\n", *port);
+
+ DbgPrint("[lwIP, LibTCPGetHostName] Done\n");
return ERR_OK;
}
@@ -597,7 +634,7 @@
err_t
LibTCPGetPeerName(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t *port)
{
- DbgPrint("[LibTCPGetPeerName] pcb = (0x%x)\n", pcb);
+ DbgPrint("[lwIP, LibTCPGetPeerName] pcb = (0x%x)\n", pcb);
if (!pcb)
return ERR_CLSD;
@@ -605,7 +642,7 @@
*ipaddr = pcb->remote_ip;
*port = pcb->remote_port;
- DbgPrint("[LibTCPGetPeerName] Got remote port: %d\n", *port);
+ DbgPrint("[lwIP, LibTCPGetPeerName] Got remote port: %d\n", *port);
return ERR_OK;
}