mirror of
https://github.com/reactos/reactos.git
synced 2025-05-31 23:18:39 +00:00
[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. svn path=/branches/GSoC_2011/TcpIpDriver/; revision=52042
This commit is contained in:
parent
04c4235e97
commit
b3c222f739
11 changed files with 462 additions and 340 deletions
|
@ -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 WarmSocketForBind( PAFD_FCB FCB ) {
|
|||
|
||||
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 @@ AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
|
||||
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))
|
||||
|
|
|
@ -185,7 +185,8 @@ AfdSetConnectDataSize(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS WarmSocketForConnection( PAFD_FCB FCB ) {
|
||||
NTSTATUS WarmSocketForConnection( PAFD_FCB FCB )
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
if( !FCB->TdiDeviceName.Length || !FCB->TdiDeviceName.Buffer )
|
||||
|
@ -198,7 +199,8 @@ NTSTATUS WarmSocketForConnection( PAFD_FCB FCB ) {
|
|||
&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 @@ NTSTATUS WarmSocketForConnection( PAFD_FCB FCB ) {
|
|||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB ) {
|
||||
NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB )
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
ASSERT(!FCB->Recv.Window);
|
||||
|
|
|
@ -163,8 +163,8 @@ static NTSTATUS NTAPI ListenComplete
|
|||
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 @@ static NTSTATUS NTAPI ListenComplete
|
|||
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 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
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 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
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 );
|
||||
if ( !NT_SUCCESS(Status) )
|
||||
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
|
||||
|
||||
Status = TdiBuildNullConnectionInfo
|
||||
( &FCB->ListenIrp.ConnectionCallInfo,
|
||||
Status = TdiBuildNullConnectionInfo(&FCB->ListenIrp.ConnectionCallInfo,
|
||||
FCB->LocalAddress->Address[0].AddressType );
|
||||
|
||||
if (!NT_SUCCESS(Status)) return UnlockAndMaybeComplete(FCB, Status, Irp, 0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return UnlockAndMaybeComplete(FCB, Status, Irp, 0);
|
||||
|
||||
Status = TdiBuildNullConnectionInfo
|
||||
( &FCB->ListenIrp.ConnectionReturnInfo,
|
||||
Status = TdiBuildNullConnectionInfo(&FCB->ListenIrp.ConnectionReturnInfo,
|
||||
FCB->LocalAddress->Address[0].AddressType );
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -302,14 +303,15 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
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 AfdWaitForListen( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
}
|
||||
|
||||
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 @@ NTSTATUS AfdAccept( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
(PVOID *)&NewFileObject,
|
||||
NULL );
|
||||
|
||||
if( !NT_SUCCESS(Status) )
|
||||
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
|
||||
if( !NT_SUCCESS(Status) )
|
||||
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
|
||||
|
||||
ASSERT(NewFileObject != FileObject);
|
||||
ASSERT(NewFileObject->FsContext != FCB);
|
||||
ASSERT(NewFileObject != FileObject);
|
||||
ASSERT(NewFileObject->FsContext != FCB);
|
||||
|
||||
/* We have a pending connection ... complete this irp right away */
|
||||
Status = SatisfyAccept( DeviceExt, Irp, NewFileObject, PendingConnObj );
|
||||
|
|
|
@ -25,13 +25,17 @@ DWORD DebugTraceLevel = 0;
|
|||
|
||||
#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 @@ AfdGetTdiHandles(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
|
||||
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 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
|
||||
EaInfo = Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
if( EaInfo ) {
|
||||
ConnectInfo = (PAFD_CREATE_PACKET)(EaInfo->EaName + EaInfo->EaNameLength + 1);
|
||||
EaInfoValue = (PWCHAR)(((PCHAR)ConnectInfo) + sizeof(AFD_CREATE_PACKET));
|
||||
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;
|
||||
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,("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 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
|
||||
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 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
|
||||
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( 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;
|
||||
}
|
||||
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 );
|
||||
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"));
|
||||
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 );
|
||||
/* 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;
|
||||
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 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
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 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
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 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
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 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
}
|
||||
|
||||
if( FCB->TdiDeviceName.Buffer )
|
||||
ExFreePool(FCB->TdiDeviceName.Buffer);
|
||||
ExFreePool(FCB->TdiDeviceName.Buffer);
|
||||
|
||||
ExFreePool(FCB);
|
||||
|
||||
|
@ -499,7 +516,8 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
|
||||
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 @@ AfdDisconnect(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
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 @@ AfdDisconnect(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
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 );
|
||||
|
|
|
@ -128,21 +128,27 @@ static NTSTATUS TdiOpenDevice(
|
|||
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 @@ NTSTATUS TdiConnect(
|
|||
|
||||
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 @@ NTSTATUS TdiAssociateAddressFile(
|
|||
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 @@ NTSTATUS TdiListen
|
|||
PDEVICE_OBJECT DeviceObject;
|
||||
NTSTATUS Status;
|
||||
|
||||
AFD_DbgPrint(MAX_TRACE, ("Called\n"));
|
||||
AFD_DbgPrint(MAX_TRACE, ("[AFD, TDIListen] Called\n"));
|
||||
DbgPrint("[AFD, TDIListen] 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;
|
||||
|
@ -476,6 +489,8 @@ NTSTATUS TdiListen
|
|||
|
||||
Status = TdiCall(*Irp, DeviceObject, NULL /* Don't wait for completion */, Iosb);
|
||||
|
||||
DbgPrint("[AFD, TDIListen] Done. Status = 0x%x\n", Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ NTSTATUS DispPrepareIrpForCancel(
|
|||
|
||||
IoAcquireCancelSpinLock(&OldIrql);
|
||||
|
||||
if (!Irp->Cancel && !TransContext->CancelIrps) {
|
||||
if (!Irp->Cancel && !TransContext->CancelIrps)
|
||||
{
|
||||
(void)IoSetCancelRoutine(Irp, CancelRoutine);
|
||||
IoReleaseCancelSpinLock(OldIrql);
|
||||
|
||||
|
@ -144,38 +147,41 @@ VOID NTAPI DispCancelRequest(
|
|||
#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_SEND_DATAGRAM:
|
||||
if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE)
|
||||
{
|
||||
TI_DbgPrint(MIN_TRACE, ("TDI_SEND_DATAGRAM, but no address file.\n"));
|
||||
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"));
|
||||
DequeuedIrp = DGRemoveIRP(TranContext->Handle.AddressHandle, 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"));
|
||||
break;
|
||||
}
|
||||
|
||||
case TDI_CONNECT:
|
||||
DequeuedIrp = TCPRemoveIRP(TranContext->Handle.ConnectionContext, Irp);
|
||||
break;
|
||||
DequeuedIrp = DGRemoveIRP(TranContext->Handle.AddressHandle, Irp);
|
||||
break;
|
||||
|
||||
default:
|
||||
TI_DbgPrint(MIN_TRACE, ("Unknown IRP. MinorFunction (0x%X).\n", MinorFunction));
|
||||
ASSERT(FALSE);
|
||||
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 @@ NTSTATUS DispTdiAssociateAddress(
|
|||
* 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;
|
||||
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"));
|
||||
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, DispTdiAssociateAddress] Called\n"));
|
||||
|
||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
/* Get associated connection endpoint file object. Quit if none exists */
|
||||
/* 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
Status = ObReferenceObjectByHandle(
|
||||
Parameters->AddressHandle,
|
||||
0,
|
||||
IoFileObjectType,
|
||||
KernelMode,
|
||||
(PVOID*)&FileObject,
|
||||
NULL);
|
||||
|
||||
LockObject(Connection, &OldIrql);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
TI_DbgPrint(MID_TRACE, ("Bad address file object handle (0x%X): %x.\n",
|
||||
Parameters->AddressHandle, Status));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Connection->AddressFile) {
|
||||
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 @@ NTSTATUS DispTdiConnect(
|
|||
Irp,
|
||||
DispCancelRequest);
|
||||
|
||||
if (NT_SUCCESS(Status)) {
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = TCPConnect(
|
||||
TranContext->Handle.ConnectionContext,
|
||||
Parameters->RequestConnectionInformation,
|
||||
|
@ -505,7 +520,8 @@ NTSTATUS DispTdiDisconnect(
|
|||
}
|
||||
|
||||
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 @@ NTSTATUS DispTdiListen(
|
|||
* Status of operation
|
||||
*/
|
||||
{
|
||||
PCONNECTION_ENDPOINT Connection;
|
||||
PTDI_REQUEST_KERNEL Parameters;
|
||||
PTRANSPORT_CONTEXT TranContext;
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
KIRQL 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"));
|
||||
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, DispTdiListen] Called\n"));
|
||||
DbgPrint("[TCPIP, DispTdiListen] Called\n");
|
||||
|
||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
/* Get associated connection endpoint file object. Quit if none exists */
|
||||
/* Get associated connection endpoint file object. Quit if none exists */
|
||||
|
||||
TranContext = IrpSp->FileObject->FsContext;
|
||||
if (TranContext == NULL)
|
||||
TranContext = IrpSp->FileObject->FsContext;
|
||||
if (TranContext == NULL)
|
||||
{
|
||||
TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
goto done;
|
||||
TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
goto done;
|
||||
}
|
||||
|
||||
Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
|
||||
if (Connection == NULL)
|
||||
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;
|
||||
TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
goto done;
|
||||
}
|
||||
|
||||
Parameters = (PTDI_REQUEST_KERNEL)&IrpSp->Parameters;
|
||||
Parameters = (PTDI_REQUEST_KERNEL)&IrpSp->Parameters;
|
||||
|
||||
Status = DispPrepareIrpForCancel
|
||||
(TranContext->Handle.ConnectionContext,
|
||||
Irp,
|
||||
(PDRIVER_CANCEL)DispCancelListenRequest);
|
||||
Status = DispPrepareIrpForCancel
|
||||
(TranContext->Handle.ConnectionContext,
|
||||
Irp,
|
||||
(PDRIVER_CANCEL)DispCancelListenRequest);
|
||||
|
||||
LockObject(Connection, &OldIrql);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
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 );
|
||||
/* 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( !Connection->AddressFile->Listener )
|
||||
Status = STATUS_NO_MEMORY;
|
||||
|
||||
if( NT_SUCCESS(Status) ) {
|
||||
ReferenceObject(Connection->AddressFile);
|
||||
Connection->AddressFile->Listener->AddressFile =
|
||||
Connection->AddressFile;
|
||||
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 );
|
||||
}
|
||||
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 = TCPListen( Connection->AddressFile->Listener, 1024 );
|
||||
/* BACKLOG */
|
||||
}
|
||||
|
||||
if( NT_SUCCESS(Status) ) {
|
||||
Status = TCPAccept
|
||||
( (PTDI_REQUEST)Parameters,
|
||||
Connection->AddressFile->Listener,
|
||||
Connection,
|
||||
DispDataRequestComplete,
|
||||
Irp );
|
||||
}
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = TCPAccept( (PTDI_REQUEST)Parameters,
|
||||
Connection->AddressFile->Listener,
|
||||
Connection,
|
||||
DispDataRequestComplete,
|
||||
Irp );
|
||||
}
|
||||
|
||||
UnlockObjectFromDpcLevel(Connection->AddressFile);
|
||||
UnlockObject(Connection, OldIrql);
|
||||
UnlockObjectFromDpcLevel(Connection->AddressFile);
|
||||
UnlockObject(Connection, OldIrql);
|
||||
|
||||
done:
|
||||
if (Status != STATUS_PENDING) {
|
||||
DispDataRequestComplete(Irp, Status, 0);
|
||||
} else
|
||||
IoMarkIrpPending(Irp);
|
||||
if (Status != STATUS_PENDING)
|
||||
{
|
||||
DispDataRequestComplete(Irp, Status, 0);
|
||||
}
|
||||
else
|
||||
IoMarkIrpPending(Irp);
|
||||
|
||||
TI_DbgPrint(MID_TRACE,("[TCPIP, DispTdiListen] Leaving %x\n", Status));
|
||||
TI_DbgPrint(MID_TRACE,("[TCPIP, DispTdiListen] Leaving %x\n", Status));
|
||||
DbgPrint("[TCPIP, DispTdiListen] Leaving %x\n", Status);
|
||||
|
||||
return Status;
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -413,15 +413,18 @@ NTSTATUS FileOpenConnection(
|
|||
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 @@ NTSTATUS FileOpenConnection(
|
|||
/* 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;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ NTSTATUS TCPListen( PCONNECTION_ENDPOINT Connection, UINT Backlog )
|
|||
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 @@ NTSTATUS TCPListen( PCONNECTION_ENDPOINT Connection, UINT Backlog )
|
|||
UnlockObject(Connection, OldIrql);
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("[IP, TCPListen] Leaving. Status = %x\n", Status));
|
||||
DbgPrint("[IP, TCPListen] Leaving. Status = %x\n", Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -90,6 +92,8 @@ BOOLEAN TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener,
|
|||
KIRQL OldIrql;
|
||||
BOOLEAN Found = FALSE;
|
||||
|
||||
DbgPrint("[IP, TCPAbortListenForSocket] Called\n");
|
||||
|
||||
LockObject(Listener, &OldIrql);
|
||||
|
||||
ListEntry = Listener->ListenRequest.Flink;
|
||||
|
@ -111,6 +115,9 @@ BOOLEAN TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener,
|
|||
|
||||
UnlockObject(Listener, OldIrql);
|
||||
|
||||
DbgPrint("[IP, TCPAbortListenForSocket] Leaving. Status = %s\n",
|
||||
Found == TRUE ? "TRUE" : "FALSE");
|
||||
|
||||
return Found;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,9 @@ NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
|||
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 @@ NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -139,6 +139,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)) {
|
||||
/* Not all data received by application, send RST to tell the remote
|
||||
|
|
|
@ -58,7 +58,7 @@ static
|
|||
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 @@ InternalRecvEventHandler(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t e
|
|||
{
|
||||
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 @@ InternalRecvEventHandler(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t e
|
|||
}
|
||||
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 @@ static
|
|||
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 @@ static
|
|||
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 @@ static
|
|||
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 @@ LibTCPSocketCallback(void *arg)
|
|||
|
||||
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 @@ LibTCPSocket(void *arg)
|
|||
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 @@ LibTCPBind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||
|
||||
if (!pcb)
|
||||
return ERR_CLSD;
|
||||
|
||||
DbgPrint("[lwIP, LibTCPBind] Called\n");
|
||||
|
||||
msg = ExAllocatePool(NonPagedPool, sizeof(struct bind_callback_msg));
|
||||
if (msg)
|
||||
|
@ -283,7 +286,9 @@ LibTCPBind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||
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 @@ LibTCPListenCallback(void *arg)
|
|||
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 @@ LibTCPListenCallback(void *arg)
|
|||
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 @@ LibTCPListen(struct tcp_pcb *pcb, u8_t backlog)
|
|||
{
|
||||
struct listen_callback_msg *msg;
|
||||
void *ret;
|
||||
|
||||
DbgPrint("[lwIP, LibTCPListen] Called\n");
|
||||
|
||||
if (!pcb)
|
||||
return NULL;
|
||||
|
@ -351,7 +362,9 @@ LibTCPListen(struct tcp_pcb *pcb, u8_t backlog)
|
|||
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 @@ LibTCPConnectCallback(void *arg)
|
|||
{
|
||||
struct connect_callback_msg *msg = arg;
|
||||
|
||||
DbgPrint("[LibTCPConnectCallback] Called\n");
|
||||
DbgPrint("[lwIP, LibTCPConnectCallback] Called\n");
|
||||
|
||||
ASSERT(arg);
|
||||
|
||||
|
@ -463,7 +476,7 @@ LibTCPConnectCallback(void *arg)
|
|||
|
||||
KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE);
|
||||
|
||||
DbgPrint("[LibTCPConnectCallback] Done\n");
|
||||
DbgPrint("[lwIP, LibTCPConnectCallback] Done\n");
|
||||
}
|
||||
|
||||
err_t
|
||||
|
@ -471,6 +484,8 @@ LibTCPConnect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||
{
|
||||
struct connect_callback_msg *msg;
|
||||
err_t ret;
|
||||
|
||||
DbgPrint("[lwIP, LibTCPConnect] Called\n");
|
||||
|
||||
if (!pcb)
|
||||
return ERR_CLSD;
|
||||
|
@ -491,8 +506,10 @@ LibTCPConnect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||
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 @@ LibTCPClose(struct tcp_pcb *pcb)
|
|||
{
|
||||
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 @@ LibTCPClose(struct tcp_pcb *pcb)
|
|||
|
||||
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 @@ LibTCPClose(struct tcp_pcb *pcb)
|
|||
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 @@ LibTCPAccept(struct tcp_pcb *pcb, struct tcp_pcb *listen_pcb, void *arg)
|
|||
|
||||
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 @@ LibTCPGetHostName(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t *port)
|
|||
*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 @@ LibTCPGetHostName(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t *port)
|
|||
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 @@ LibTCPGetPeerName(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t *port)
|
|||
*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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue