mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 15:12:05 +00:00
[TCPIP]
[FORMATTING] Backup copy and formatting. svn path=/branches/GSoC_2011/TcpIpDriver/; revision=52381
This commit is contained in:
parent
c2770feda9
commit
4b7e0f11d0
16 changed files with 527 additions and 441 deletions
|
@ -69,6 +69,7 @@ AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
|
||||
if ( !SocketAcquireStateLock( FCB ) )
|
||||
return LostSocket( Irp );
|
||||
|
||||
if ( !(BindReq = LockRequest( Irp, IrpSp )) )
|
||||
return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0 );
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ static NTSTATUS SatisfyPreAccept( PIRP Irp, PAFD_TDI_OBJECT_QELT Qelt )
|
|||
AFD_DbgPrint(MID_TRACE,("Socket Address (K) %x (U) %x\n",
|
||||
&ListenReceive->Address,
|
||||
Qelt->ConnInfo->RemoteAddress));
|
||||
|
||||
DbgPrint("[SatisfyPreAccept] Called\n");
|
||||
DbgPrint("[SatisfyPreAccept] Giving SEQ %d to userland\n", Qelt->Seq);
|
||||
DbgPrint("[SatisfyPreAccept] Socket Address (K) %x (U) %x\n",
|
||||
&ListenReceive->Address,
|
||||
|
@ -97,12 +97,16 @@ static NTSTATUS SatisfyPreAccept( PIRP Irp, PAFD_TDI_OBJECT_QELT Qelt )
|
|||
DbgPrint("IPAddr->Address[0].Address[0].sin_addr %x\n",
|
||||
IPAddr->Address[0].Address[0].in_addr);
|
||||
|
||||
if( Irp->MdlAddress ) UnlockRequest( Irp, IoGetCurrentIrpStackLocation( Irp ) );
|
||||
if ( Irp->MdlAddress )
|
||||
UnlockRequest( Irp, IoGetCurrentIrpStackLocation( Irp ) );
|
||||
|
||||
Irp->IoStatus.Information = ((PCHAR)&IPAddr[1]) - ((PCHAR)ListenReceive);
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
(void)IoSetCancelRoutine(Irp, NULL);
|
||||
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
|
||||
|
||||
DbgPrint("[SatisfyPreAccept] Leaving\n");
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -192,8 +196,7 @@ static NTSTATUS NTAPI ListenComplete
|
|||
Status = TdiBuildNullConnectionInfo( &Qelt->ConnInfo, AddressType );
|
||||
if( NT_SUCCESS(Status) )
|
||||
{
|
||||
TaCopyTransportAddressInPlace
|
||||
( Qelt->ConnInfo->RemoteAddress,
|
||||
TaCopyTransportAddressInPlace( Qelt->ConnInfo->RemoteAddress,
|
||||
FCB->ListenIrp.ConnectionReturnInfo->RemoteAddress );
|
||||
InsertTailList( &FCB->PendingConnections, &Qelt->ListEntry );
|
||||
}
|
||||
|
@ -203,20 +206,22 @@ static NTSTATUS NTAPI ListenComplete
|
|||
if ( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_PREACCEPT] ) &&
|
||||
!IsListEmpty( &FCB->PendingConnections ) )
|
||||
{
|
||||
PLIST_ENTRY PendingIrp =
|
||||
RemoveHeadList( &FCB->PendingIrpList[FUNCTION_PREACCEPT] );
|
||||
PLIST_ENTRY PendingIrp = RemoveHeadList( &FCB->PendingIrpList[FUNCTION_PREACCEPT] );
|
||||
PLIST_ENTRY PendingConn = FCB->PendingConnections.Flink;
|
||||
SatisfyPreAccept( CONTAINING_RECORD( PendingIrp, IRP,
|
||||
|
||||
SatisfyPreAccept( CONTAINING_RECORD( PendingIrp, IRP,
|
||||
Tail.Overlay.ListEntry ),
|
||||
CONTAINING_RECORD( PendingConn, AFD_TDI_OBJECT_QELT,
|
||||
ListEntry ) );
|
||||
}
|
||||
|
||||
/* Launch new accept socket */
|
||||
DbgPrint("[AFD, ListenComplete] Getting warm connection socket\n");
|
||||
Status = WarmSocketForConnection( FCB );
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("[AFD, ListenComplete] Done getting warm connection socket\n");
|
||||
Status = TdiBuildNullConnectionInfoInPlace(FCB->ListenIrp.ConnectionCallInfo,
|
||||
FCB->LocalAddress->Address[0].AddressType);
|
||||
ASSERT(Status == STATUS_SUCCESS);
|
||||
|
@ -225,6 +230,7 @@ static NTSTATUS NTAPI ListenComplete
|
|||
FCB->LocalAddress->Address[0].AddressType);
|
||||
ASSERT(Status == STATUS_SUCCESS);
|
||||
|
||||
DbgPrint("[AFD, ListenComplete] callings TdiListen\n");
|
||||
Status = TdiListen( &FCB->ListenIrp.InFlightRequest,
|
||||
FCB->Connection.Object,
|
||||
&FCB->ListenIrp.ConnectionCallInfo,
|
||||
|
@ -262,8 +268,8 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
PAFD_FCB FCB = FileObject->FsContext;
|
||||
PAFD_LISTEN_DATA ListenReq;
|
||||
|
||||
AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB));
|
||||
DbgPrint("[AfdListenSocket] Called on %x\n", FCB);
|
||||
AFD_DbgPrint(MID_TRACE,("Called on 0x%x\n", FCB));
|
||||
DbgPrint("[AfdListenSocket] Called on 0x%x\n", FCB);
|
||||
|
||||
if( !SocketAcquireStateLock( FCB ) )
|
||||
return LostSocket( Irp );
|
||||
|
@ -282,12 +288,11 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
FCB->DelayedAccept = ListenReq->UseDelayedAcceptance;
|
||||
|
||||
AFD_DbgPrint(MID_TRACE,("ADDRESSFILE: %x\n", FCB->AddressFile.Handle));
|
||||
DbgPrint("[AfdListenSocket] ADDRESSFILE: %x\n", FCB->AddressFile.Handle);
|
||||
|
||||
Status = WarmSocketForConnection( FCB );
|
||||
|
||||
AFD_DbgPrint(MID_TRACE,("Status from warmsocket %x\n", Status));
|
||||
DbgPrint("[AfdListenSocket] Status from warmsocket %x\n", Status);
|
||||
DbgPrint("[AfdListenSocket] Status from warmsocket 0x%x\n", Status);
|
||||
|
||||
if ( !NT_SUCCESS(Status) )
|
||||
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
|
||||
|
@ -322,7 +327,7 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
Status = STATUS_SUCCESS;
|
||||
|
||||
AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
|
||||
DbgPrint("[AfdListenSocket] Returning %x\n", Status);
|
||||
DbgPrint("[AfdListenSocket] Returning 0x%x\n", Status);
|
||||
|
||||
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
|
||||
}
|
||||
|
@ -380,14 +385,18 @@ NTSTATUS AfdAccept( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||
PAFD_DEVICE_EXTENSION DeviceExt =
|
||||
(PAFD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
PAFD_FCB FCB = FileObject->FsContext;
|
||||
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||
PAFD_ACCEPT_DATA AcceptData = Irp->AssociatedIrp.SystemBuffer;
|
||||
PLIST_ENTRY PendingConn;
|
||||
|
||||
AFD_DbgPrint(MID_TRACE,("Called\n"));
|
||||
DbgPrint("[AfdAccept] Called\n");
|
||||
DbgPrint("[AfdAccept] Called...\n");
|
||||
|
||||
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
|
||||
if (!SocketAcquireStateLock(FCB))
|
||||
{
|
||||
DbgPrint("[AfdAccept] Lost socket\n");
|
||||
return LostSocket( Irp );
|
||||
}
|
||||
|
||||
for( PendingConn = FCB->PendingConnections.Flink;
|
||||
PendingConn != &FCB->PendingConnections;
|
||||
|
@ -446,7 +455,7 @@ NTSTATUS AfdAccept( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
}
|
||||
}
|
||||
|
||||
DbgPrint("[AfdAccept] Done");
|
||||
DbgPrint("[AfdAccept] Done\n");
|
||||
|
||||
return UnlockAndMaybeComplete( FCB, STATUS_UNSUCCESSFUL, Irp, 0 );
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ AfdGetDisconnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
PIO_STACK_LOCATION IrpSp)
|
||||
{
|
||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||
PAFD_FCB FCB = FileObject->FsContext;
|
||||
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||
UINT BufferSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
|
||||
|
||||
if (!SocketAcquireStateLock(FCB)) return LostSocket(Irp);
|
||||
|
@ -75,7 +75,7 @@ AfdSetDisconnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
PIO_STACK_LOCATION IrpSp)
|
||||
{
|
||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||
PAFD_FCB FCB = FileObject->FsContext;
|
||||
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||
PVOID DisconnectOptions = LockRequest(Irp, IrpSp);
|
||||
UINT DisconnectOptionsSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
|
||||
|
||||
|
@ -93,7 +93,9 @@ AfdSetDisconnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
}
|
||||
|
||||
FCB->DisconnectOptions = ExAllocatePool(PagedPool, DisconnectOptionsSize);
|
||||
if (!FCB->DisconnectOptions) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0);
|
||||
|
||||
if (!FCB->DisconnectOptions)
|
||||
return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0);
|
||||
|
||||
RtlCopyMemory(FCB->DisconnectOptions,
|
||||
DisconnectOptions,
|
||||
|
@ -110,8 +112,8 @@ AfdSetDisconnectOptionsSize(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
PIO_STACK_LOCATION IrpSp)
|
||||
{
|
||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||
PAFD_FCB FCB = FileObject->FsContext;
|
||||
PUINT DisconnectOptionsSize = LockRequest(Irp, IrpSp);
|
||||
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||
PUINT DisconnectOptionsSize = (PUINT)LockRequest(Irp, IrpSp);
|
||||
UINT BufferSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
|
||||
|
||||
if (!SocketAcquireStateLock(FCB)) return LostSocket(Irp);
|
||||
|
@ -130,7 +132,9 @@ AfdSetDisconnectOptionsSize(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
}
|
||||
|
||||
FCB->DisconnectOptions = ExAllocatePool(PagedPool, *DisconnectOptionsSize);
|
||||
if (!FCB->DisconnectOptions) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0);
|
||||
|
||||
if (!FCB->DisconnectOptions)
|
||||
return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0);
|
||||
|
||||
FCB->DisconnectOptionsSize = *DisconnectOptionsSize;
|
||||
|
||||
|
@ -142,7 +146,7 @@ AfdGetDisconnectData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
PIO_STACK_LOCATION IrpSp)
|
||||
{
|
||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||
PAFD_FCB FCB = FileObject->FsContext;
|
||||
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||
UINT BufferSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
|
||||
|
||||
if (!SocketAcquireStateLock(FCB)) return LostSocket(Irp);
|
||||
|
@ -185,7 +189,9 @@ AfdSetDisconnectData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
}
|
||||
|
||||
FCB->DisconnectData = ExAllocatePool(PagedPool, DisconnectDataSize);
|
||||
if (!FCB->DisconnectData) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0);
|
||||
|
||||
if (!FCB->DisconnectData)
|
||||
return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0);
|
||||
|
||||
RtlCopyMemory(FCB->DisconnectData,
|
||||
DisconnectData,
|
||||
|
@ -222,7 +228,9 @@ AfdSetDisconnectDataSize(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
}
|
||||
|
||||
FCB->DisconnectData = ExAllocatePool(PagedPool, *DisconnectDataSize);
|
||||
if (!FCB->DisconnectData) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0);
|
||||
|
||||
if (!FCB->DisconnectData)
|
||||
return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0);
|
||||
|
||||
FCB->DisconnectDataSize = *DisconnectDataSize;
|
||||
|
||||
|
@ -299,6 +307,8 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
AFD_DbgPrint(MID_TRACE,("About to allocate the new FCB\n"));
|
||||
|
||||
FCB = ExAllocatePool(NonPagedPool, sizeof(AFD_FCB));
|
||||
RtlZeroMemory(FCB, sizeof(AFD_FCB));
|
||||
|
||||
if( FCB == NULL )
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_NO_MEMORY;
|
||||
|
@ -337,6 +347,7 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
FCB->TdiDeviceName.MaximumLength = FCB->TdiDeviceName.Length;
|
||||
FCB->TdiDeviceName.Buffer =
|
||||
ExAllocatePool( NonPagedPool, FCB->TdiDeviceName.Length );
|
||||
RtlZeroMemory(FCB->TdiDeviceName.Buffer, FCB->TdiDeviceName.Length);
|
||||
|
||||
if( !FCB->TdiDeviceName.Buffer )
|
||||
{
|
||||
|
@ -393,7 +404,7 @@ AfdCleanupSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
PIO_STACK_LOCATION IrpSp)
|
||||
{
|
||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||
PAFD_FCB FCB = FileObject->FsContext;
|
||||
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||
PLIST_ENTRY CurrentEntry, NextEntry;
|
||||
UINT Function;
|
||||
PIRP CurrentIrp;
|
||||
|
@ -431,7 +442,7 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
PIO_STACK_LOCATION IrpSp)
|
||||
{
|
||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||
PAFD_FCB FCB = FileObject->FsContext;
|
||||
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||
UINT i;
|
||||
PAFD_IN_FLIGHT_REQUEST InFlightRequest[IN_FLIGHT_REQUESTS];
|
||||
PAFD_TDI_OBJECT_QELT Qelt;
|
||||
|
@ -448,9 +459,6 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
DbgPrint("[AFD, AfdCloseSocket] Setting closed state\n");
|
||||
|
||||
FCB->State = SOCKET_STATE_CLOSED;
|
||||
FCB->PollState = AFD_EVENT_CLOSE;
|
||||
FCB->PollStatus[FD_CLOSE_BIT] = STATUS_SUCCESS; //I think we can return success here
|
||||
PollReeval( FCB->DeviceExt, FCB->FileObject );
|
||||
|
||||
InFlightRequest[0] = &FCB->ListenIrp;
|
||||
InFlightRequest[1] = &FCB->ReceiveIrp;
|
||||
|
@ -689,173 +697,176 @@ AfdDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
#endif
|
||||
|
||||
AFD_DbgPrint(MID_TRACE,("AfdDispatch: %d\n", IrpSp->MajorFunction));
|
||||
if( IrpSp->MajorFunction != IRP_MJ_CREATE) {
|
||||
AFD_DbgPrint(MID_TRACE,("FO %x, IrpSp->FO %x\n",
|
||||
FileObject, IrpSp->FileObject));
|
||||
ASSERT(FileObject == IrpSp->FileObject);
|
||||
|
||||
if( IrpSp->MajorFunction != IRP_MJ_CREATE)
|
||||
{
|
||||
AFD_DbgPrint(MID_TRACE,("FO %x, IrpSp->FO %x\n",
|
||||
FileObject, IrpSp->FileObject));
|
||||
ASSERT(FileObject == IrpSp->FileObject);
|
||||
}
|
||||
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
switch(IrpSp->MajorFunction)
|
||||
{
|
||||
/* opening and closing handles to the device */
|
||||
case IRP_MJ_CREATE:
|
||||
/* Mostly borrowed from the named pipe file system */
|
||||
return AfdCreateSocket(DeviceObject, Irp, IrpSp);
|
||||
/* opening and closing handles to the device */
|
||||
case IRP_MJ_CREATE:
|
||||
/* Mostly borrowed from the named pipe file system */
|
||||
return AfdCreateSocket(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IRP_MJ_CLOSE:
|
||||
/* Ditto the borrowing */
|
||||
return AfdCloseSocket(DeviceObject, Irp, IrpSp);
|
||||
case IRP_MJ_CLOSE:
|
||||
/* Ditto the borrowing */
|
||||
return AfdCloseSocket(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IRP_MJ_CLEANUP:
|
||||
return AfdCleanupSocket(DeviceObject, Irp, IrpSp);
|
||||
case IRP_MJ_CLEANUP:
|
||||
return AfdCleanupSocket(DeviceObject, Irp, IrpSp);
|
||||
|
||||
/* write data */
|
||||
case IRP_MJ_WRITE:
|
||||
return AfdConnectedSocketWriteData( DeviceObject, Irp, IrpSp, TRUE );
|
||||
/* write data */
|
||||
case IRP_MJ_WRITE:
|
||||
return AfdConnectedSocketWriteData( DeviceObject, Irp, IrpSp, TRUE );
|
||||
|
||||
/* read data */
|
||||
case IRP_MJ_READ:
|
||||
return AfdConnectedSocketReadData( DeviceObject, Irp, IrpSp, TRUE );
|
||||
/* read data */
|
||||
case IRP_MJ_READ:
|
||||
return AfdConnectedSocketReadData( DeviceObject, Irp, IrpSp, TRUE );
|
||||
|
||||
case IRP_MJ_DEVICE_CONTROL:
|
||||
{
|
||||
switch( IrpSp->Parameters.DeviceIoControl.IoControlCode ) {
|
||||
case IOCTL_AFD_BIND:
|
||||
return AfdBindSocket( DeviceObject, Irp, IrpSp );
|
||||
case IRP_MJ_DEVICE_CONTROL:
|
||||
{
|
||||
switch( IrpSp->Parameters.DeviceIoControl.IoControlCode )
|
||||
{
|
||||
case IOCTL_AFD_BIND:
|
||||
return AfdBindSocket( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_CONNECT:
|
||||
return AfdStreamSocketConnect( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_CONNECT:
|
||||
return AfdStreamSocketConnect( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_START_LISTEN:
|
||||
return AfdListenSocket( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_START_LISTEN:
|
||||
return AfdListenSocket( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_RECV:
|
||||
return AfdConnectedSocketReadData( DeviceObject, Irp, IrpSp,
|
||||
FALSE );
|
||||
case IOCTL_AFD_RECV:
|
||||
return AfdConnectedSocketReadData( DeviceObject, Irp, IrpSp,
|
||||
FALSE );
|
||||
|
||||
case IOCTL_AFD_SELECT:
|
||||
return AfdSelect( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_SELECT:
|
||||
return AfdSelect( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_EVENT_SELECT:
|
||||
return AfdEventSelect( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_EVENT_SELECT:
|
||||
return AfdEventSelect( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_ENUM_NETWORK_EVENTS:
|
||||
return AfdEnumEvents( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_ENUM_NETWORK_EVENTS:
|
||||
return AfdEnumEvents( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_RECV_DATAGRAM:
|
||||
return AfdPacketSocketReadData( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_RECV_DATAGRAM:
|
||||
return AfdPacketSocketReadData( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_SEND:
|
||||
return AfdConnectedSocketWriteData( DeviceObject, Irp, IrpSp,
|
||||
FALSE );
|
||||
case IOCTL_AFD_SEND:
|
||||
return AfdConnectedSocketWriteData( DeviceObject, Irp, IrpSp,
|
||||
FALSE );
|
||||
|
||||
case IOCTL_AFD_SEND_DATAGRAM:
|
||||
return AfdPacketSocketWriteData( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_SEND_DATAGRAM:
|
||||
return AfdPacketSocketWriteData( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_GET_INFO:
|
||||
return AfdGetInfo( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_GET_INFO:
|
||||
return AfdGetInfo( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_SET_INFO:
|
||||
return AfdSetInfo( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_SET_INFO:
|
||||
return AfdSetInfo( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_GET_CONTEXT_SIZE:
|
||||
return AfdGetContextSize( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_GET_CONTEXT_SIZE:
|
||||
return AfdGetContextSize( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_GET_CONTEXT:
|
||||
return AfdGetContext( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_GET_CONTEXT:
|
||||
return AfdGetContext( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_SET_CONTEXT:
|
||||
return AfdSetContext( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_SET_CONTEXT:
|
||||
return AfdSetContext( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_WAIT_FOR_LISTEN:
|
||||
return AfdWaitForListen( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_WAIT_FOR_LISTEN:
|
||||
return AfdWaitForListen( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_ACCEPT:
|
||||
return AfdAccept( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_ACCEPT:
|
||||
return AfdAccept( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_DISCONNECT:
|
||||
return AfdDisconnect( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_DISCONNECT:
|
||||
return AfdDisconnect( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_GET_SOCK_NAME:
|
||||
return AfdGetSockName( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_GET_SOCK_NAME:
|
||||
return AfdGetSockName( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_GET_PEER_NAME:
|
||||
return AfdGetPeerName( DeviceObject, Irp, IrpSp );
|
||||
case IOCTL_AFD_GET_PEER_NAME:
|
||||
return AfdGetPeerName( DeviceObject, Irp, IrpSp );
|
||||
|
||||
case IOCTL_AFD_GET_CONNECT_DATA:
|
||||
return AfdGetConnectData(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_GET_CONNECT_DATA:
|
||||
return AfdGetConnectData(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_SET_CONNECT_DATA:
|
||||
return AfdSetConnectData(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_SET_CONNECT_DATA:
|
||||
return AfdSetConnectData(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_SET_DISCONNECT_DATA:
|
||||
return AfdSetDisconnectData(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_SET_DISCONNECT_DATA:
|
||||
return AfdSetDisconnectData(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_GET_DISCONNECT_DATA:
|
||||
return AfdGetDisconnectData(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_GET_DISCONNECT_DATA:
|
||||
return AfdGetDisconnectData(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_SET_CONNECT_DATA_SIZE:
|
||||
return AfdSetConnectDataSize(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_SET_CONNECT_DATA_SIZE:
|
||||
return AfdSetConnectDataSize(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_SET_DISCONNECT_DATA_SIZE:
|
||||
return AfdSetDisconnectDataSize(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_SET_DISCONNECT_DATA_SIZE:
|
||||
return AfdSetDisconnectDataSize(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_SET_CONNECT_OPTIONS:
|
||||
return AfdSetConnectOptions(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_SET_CONNECT_OPTIONS:
|
||||
return AfdSetConnectOptions(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_SET_DISCONNECT_OPTIONS:
|
||||
return AfdSetDisconnectOptions(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_SET_DISCONNECT_OPTIONS:
|
||||
return AfdSetDisconnectOptions(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_GET_CONNECT_OPTIONS:
|
||||
return AfdGetConnectOptions(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_GET_CONNECT_OPTIONS:
|
||||
return AfdGetConnectOptions(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_GET_DISCONNECT_OPTIONS:
|
||||
return AfdGetDisconnectOptions(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_GET_DISCONNECT_OPTIONS:
|
||||
return AfdGetDisconnectOptions(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_SET_CONNECT_OPTIONS_SIZE:
|
||||
return AfdSetConnectOptionsSize(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_SET_CONNECT_OPTIONS_SIZE:
|
||||
return AfdSetConnectOptionsSize(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_SET_DISCONNECT_OPTIONS_SIZE:
|
||||
return AfdSetDisconnectOptionsSize(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_SET_DISCONNECT_OPTIONS_SIZE:
|
||||
return AfdSetDisconnectOptionsSize(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_GET_TDI_HANDLES:
|
||||
return AfdGetTdiHandles(DeviceObject, Irp, IrpSp);
|
||||
case IOCTL_AFD_GET_TDI_HANDLES:
|
||||
return AfdGetTdiHandles(DeviceObject, Irp, IrpSp);
|
||||
|
||||
case IOCTL_AFD_DEFER_ACCEPT:
|
||||
DbgPrint("IOCTL_AFD_DEFER_ACCEPT is UNIMPLEMENTED!\n");
|
||||
break;
|
||||
case IOCTL_AFD_DEFER_ACCEPT:
|
||||
DbgPrint("IOCTL_AFD_DEFER_ACCEPT is UNIMPLEMENTED!\n");
|
||||
break;
|
||||
|
||||
case IOCTL_AFD_GET_PENDING_CONNECT_DATA:
|
||||
DbgPrint("IOCTL_AFD_GET_PENDING_CONNECT_DATA is UNIMPLEMENTED!\n");
|
||||
break;
|
||||
case IOCTL_AFD_GET_PENDING_CONNECT_DATA:
|
||||
DbgPrint("IOCTL_AFD_GET_PENDING_CONNECT_DATA is UNIMPLEMENTED!\n");
|
||||
break;
|
||||
|
||||
case IOCTL_AFD_VALIDATE_GROUP:
|
||||
DbgPrint("IOCTL_AFD_VALIDATE_GROUP is UNIMPLEMENTED!\n");
|
||||
break;
|
||||
case IOCTL_AFD_VALIDATE_GROUP:
|
||||
DbgPrint("IOCTL_AFD_VALIDATE_GROUP is UNIMPLEMENTED!\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = STATUS_NOT_SUPPORTED;
|
||||
DbgPrint("Unknown IOCTL (0x%x)\n",
|
||||
IrpSp->Parameters.DeviceIoControl.IoControlCode);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Status = STATUS_NOT_SUPPORTED;
|
||||
DbgPrint("Unknown IOCTL (0x%x)\n",
|
||||
IrpSp->Parameters.DeviceIoControl.IoControlCode);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* unsupported operations */
|
||||
default:
|
||||
{
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
AFD_DbgPrint(MIN_TRACE,
|
||||
("Irp: Unknown Major code was %x\n",
|
||||
IrpSp->MajorFunction));
|
||||
break;
|
||||
}
|
||||
/* unsupported operations */
|
||||
default:
|
||||
{
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
AFD_DbgPrint(MIN_TRACE, ("Irp: Unknown Major code was %x\n",
|
||||
IrpSp->MajorFunction));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AFD_DbgPrint(MID_TRACE, ("Returning %x\n", Status));
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
|
|
|
@ -49,7 +49,8 @@ static BOOLEAN CantReadMore( PAFD_FCB FCB ) {
|
|||
static VOID RefillSocketBuffer( PAFD_FCB FCB ) {
|
||||
NTSTATUS Status;
|
||||
|
||||
if( !FCB->ReceiveIrp.InFlightRequest ) {
|
||||
if( !FCB->ReceiveIrp.InFlightRequest &&
|
||||
!(FCB->PollState & (AFD_EVENT_CLOSE | AFD_EVENT_ABORT)) ) {
|
||||
AFD_DbgPrint(MID_TRACE,("Replenishing buffer\n"));
|
||||
|
||||
Status = TdiReceive( &FCB->ReceiveIrp.InFlightRequest,
|
||||
|
@ -216,7 +217,8 @@ static NTSTATUS ReceiveActivity( PAFD_FCB FCB, PIRP Irp ) {
|
|||
}
|
||||
}
|
||||
|
||||
if( FCB->Recv.Content - FCB->Recv.BytesUsed ) {
|
||||
if( FCB->Recv.Content - FCB->Recv.BytesUsed &&
|
||||
IsListEmpty(&FCB->PendingIrpList[FUNCTION_RECV]) ) {
|
||||
FCB->PollState |= AFD_EVENT_RECEIVE;
|
||||
FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS;
|
||||
PollReeval( FCB->DeviceExt, FCB->FileObject );
|
||||
|
@ -576,7 +578,7 @@ PacketSocketRecvComplete(
|
|||
}
|
||||
}
|
||||
|
||||
if( !IsListEmpty( &FCB->DatagramList ) ) {
|
||||
if( !IsListEmpty( &FCB->DatagramList ) && IsListEmpty(&FCB->PendingIrpList[FUNCTION_RECV]) ) {
|
||||
AFD_DbgPrint(MID_TRACE,("Signalling\n"));
|
||||
FCB->PollState |= AFD_EVENT_RECEIVE;
|
||||
FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS;
|
||||
|
|
|
@ -287,8 +287,8 @@ AfdEventSelect( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
Status = ObReferenceObjectByHandle( (PVOID)EventSelectInfo->
|
||||
EventObject,
|
||||
FILE_ALL_ACCESS,
|
||||
NULL,
|
||||
KernelMode,
|
||||
ExEventObjectType,
|
||||
UserMode,
|
||||
(PVOID *)&FCB->EventSelect,
|
||||
NULL );
|
||||
|
||||
|
|
|
@ -328,8 +328,7 @@ AfdConnectedSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
|
||||
if (SpaceAvail < SendReq->BufferArray[i].len)
|
||||
{
|
||||
if (FCB->Send.BytesUsed + TotalBytesCopied +
|
||||
SendReq->BufferArray[i].len > FCB->Send.Size)
|
||||
if (TotalBytesCopied + SendReq->BufferArray[i].len > FCB->Send.Size)
|
||||
{
|
||||
UnlockBuffers( SendReq->BufferArray, SendReq->BufferCount, FALSE );
|
||||
|
||||
|
|
|
@ -229,8 +229,7 @@ VOID NTAPI DispCancelListenRequest(
|
|||
/* Try canceling the request */
|
||||
Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
|
||||
|
||||
if (TCPAbortListenForSocket(Connection->AddressFile->Listener,
|
||||
Connection))
|
||||
if (TCPAbortListenForSocket(Connection->AddressFile->Listener, Connection))
|
||||
{
|
||||
Irp->IoStatus.Information = 0;
|
||||
IRPFinish(Irp, STATUS_CANCELLED);
|
||||
|
@ -267,16 +266,17 @@ NTSTATUS DispTdiAssociateAddress(
|
|||
* Status of operation
|
||||
*/
|
||||
{
|
||||
PTDI_REQUEST_KERNEL_ASSOCIATE Parameters;
|
||||
PTRANSPORT_CONTEXT TranContext;
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
PCONNECTION_ENDPOINT Connection, LastConnection;
|
||||
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, LastConnection;
|
||||
PFILE_OBJECT FileObject;
|
||||
PADDRESS_FILE AddrFile = NULL;
|
||||
NTSTATUS Status;
|
||||
KIRQL OldIrql;
|
||||
|
||||
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, DispTdiAssociateAddress] Called\n"));
|
||||
DbgPrint("[TCPIP, DispTdiAssociateAddress] Called\n");
|
||||
|
||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
|
@ -354,17 +354,20 @@ NTSTATUS DispTdiAssociateAddress(
|
|||
|
||||
LockObjectAtDpcLevel(AddrFile);
|
||||
|
||||
/* Add connection endpoint to the address file */
|
||||
ReferenceObject(Connection);
|
||||
if (AddrFile->Connection == NULL)
|
||||
AddrFile->Connection = Connection;
|
||||
else
|
||||
{
|
||||
LastConnection = AddrFile->Connection;
|
||||
while (LastConnection->Next != NULL)
|
||||
LastConnection = LastConnection->Next;
|
||||
LastConnection->Next = Connection;
|
||||
}
|
||||
DbgPrint("[TCPIP, DispTdiAssociateAddress] Associating AddressFile = 0x%x with Connection = 0x%x\n",
|
||||
AddrFile, Connection);
|
||||
|
||||
/* Add connection endpoint to the address file */
|
||||
ReferenceObject(Connection);
|
||||
if (AddrFile->Connection == NULL)
|
||||
AddrFile->Connection = Connection;
|
||||
else
|
||||
{
|
||||
LastConnection = AddrFile->Connection;
|
||||
while (LastConnection->Next != NULL)
|
||||
LastConnection = LastConnection->Next;
|
||||
LastConnection->Next = Connection;
|
||||
}
|
||||
|
||||
ReferenceObject(AddrFile);
|
||||
Connection->AddressFile = AddrFile;
|
||||
|
@ -374,9 +377,101 @@ NTSTATUS DispTdiAssociateAddress(
|
|||
|
||||
ObDereferenceObject(FileObject);
|
||||
|
||||
DbgPrint("[TCPIP, DispTdiAssociateAddress] Leaving\n");
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS DispTdiDisassociateAddress(
|
||||
PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: TDI_DISASSOCIATE_ADDRESS handler
|
||||
* ARGUMENTS:
|
||||
* Irp = Pointer to an I/O request packet
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
*/
|
||||
{
|
||||
PCONNECTION_ENDPOINT Connection, LastConnection;
|
||||
PTRANSPORT_CONTEXT TranContext;
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
KIRQL OldIrql;
|
||||
NTSTATUS Status;
|
||||
|
||||
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
|
||||
DbgPrint("[TCPIP, DispTdiDisassociateAddress] 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;
|
||||
}
|
||||
|
||||
LockObject(Connection, &OldIrql);
|
||||
|
||||
if (!Connection->AddressFile)
|
||||
{
|
||||
UnlockObject(Connection, OldIrql);
|
||||
TI_DbgPrint(MID_TRACE, ("No address file is asscociated.\n"));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
LockObjectAtDpcLevel(Connection->AddressFile);
|
||||
|
||||
/* Unlink this connection from the address file */
|
||||
if (Connection->AddressFile->Connection == Connection)
|
||||
{
|
||||
Connection->AddressFile->Connection = Connection->Next;
|
||||
DereferenceObject(Connection);
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
LastConnection = Connection->AddressFile->Connection;
|
||||
while (LastConnection->Next != Connection && LastConnection->Next != NULL)
|
||||
LastConnection = LastConnection->Next;
|
||||
if (LastConnection->Next == Connection)
|
||||
{
|
||||
LastConnection->Next = Connection->Next;
|
||||
DereferenceObject(Connection);
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
UnlockObjectFromDpcLevel(Connection->AddressFile);
|
||||
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
DbgPrint("[TCPIP, DispTdiDisassociateAddress] Dissasociating AddressFile = 0x%x from Connection = 0x%x\n",
|
||||
Connection->AddressFile, Connection);
|
||||
/* Remove the address file from this connection */
|
||||
DereferenceObject(Connection->AddressFile);
|
||||
Connection->AddressFile = NULL;
|
||||
}
|
||||
|
||||
UnlockObject(Connection, OldIrql);
|
||||
|
||||
DbgPrint("[TCPIP, DispTdiDisassociateAddress] Leaving. Status = 0x%x\n", Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS DispTdiConnect(
|
||||
PIRP Irp)
|
||||
|
@ -441,90 +536,6 @@ done:
|
|||
return Status;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS DispTdiDisassociateAddress(
|
||||
PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: TDI_DISASSOCIATE_ADDRESS handler
|
||||
* ARGUMENTS:
|
||||
* Irp = Pointer to an I/O request packet
|
||||
* RETURNS:
|
||||
* Status of operation
|
||||
*/
|
||||
{
|
||||
PCONNECTION_ENDPOINT Connection, LastConnection;
|
||||
PTRANSPORT_CONTEXT TranContext;
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
KIRQL OldIrql;
|
||||
NTSTATUS Status;
|
||||
|
||||
TI_DbgPrint(DEBUG_IRP, ("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;
|
||||
}
|
||||
|
||||
LockObject(Connection, &OldIrql);
|
||||
|
||||
if (!Connection->AddressFile) {
|
||||
UnlockObject(Connection, OldIrql);
|
||||
TI_DbgPrint(MID_TRACE, ("No address file is asscociated.\n"));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
LockObjectAtDpcLevel(Connection->AddressFile);
|
||||
|
||||
/* Unlink this connection from the address file */
|
||||
if (Connection->AddressFile->Connection == Connection)
|
||||
{
|
||||
Connection->AddressFile->Connection = Connection->Next;
|
||||
DereferenceObject(Connection);
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
LastConnection = Connection->AddressFile->Connection;
|
||||
while (LastConnection->Next != Connection && LastConnection->Next != NULL)
|
||||
LastConnection = LastConnection->Next;
|
||||
if (LastConnection->Next == Connection)
|
||||
{
|
||||
LastConnection->Next = Connection->Next;
|
||||
DereferenceObject(Connection);
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
UnlockObjectFromDpcLevel(Connection->AddressFile);
|
||||
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
/* Remove the address file from this connection */
|
||||
DereferenceObject(Connection->AddressFile);
|
||||
Connection->AddressFile = NULL;
|
||||
}
|
||||
|
||||
UnlockObject(Connection, OldIrql);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS DispTdiDisconnect(
|
||||
PIRP Irp)
|
||||
/*
|
||||
|
@ -650,6 +661,8 @@ NTSTATUS DispTdiListen(
|
|||
if ( NT_SUCCESS(Status) && !Connection->AddressFile->Listener )
|
||||
{
|
||||
Connection->AddressFile->Listener = TCPAllocateConnectionEndpoint( NULL );
|
||||
DbgPrint("[TCPIP, DispTdiListen] Connection = 0x%x, Connection->AddressFile->Listener = 0x%x\n",
|
||||
Connection, Connection->AddressFile->Listener);
|
||||
|
||||
if ( !Connection->AddressFile->Listener )
|
||||
Status = STATUS_NO_MEMORY;
|
||||
|
@ -657,7 +670,7 @@ NTSTATUS DispTdiListen(
|
|||
if ( NT_SUCCESS(Status) )
|
||||
{
|
||||
Connection->AddressFile->Listener->AddressFile =
|
||||
Connection->AddressFile;
|
||||
Connection->AddressFile;
|
||||
|
||||
Status = TCPSocket( Connection->AddressFile->Listener,
|
||||
Connection->AddressFile->Family,
|
||||
|
|
|
@ -256,6 +256,8 @@ NTSTATUS FileOpenAddress(
|
|||
}
|
||||
|
||||
RtlZeroMemory(AddrFile, sizeof(ADDRESS_FILE));
|
||||
DbgPrint("[TCPIP, FileOpenAddress] Allocated AddressFile = 0x%x, sizeof(ADDRESS_FILE) = %d\n",
|
||||
AddrFile, sizeof(ADDRESS_FILE));
|
||||
|
||||
AddrFile->RefCount = 1;
|
||||
AddrFile->Free = AddrFileFree;
|
||||
|
@ -395,19 +397,23 @@ NTSTATUS FileCloseAddress(
|
|||
|
||||
LockObject(AddrFile, &OldIrql);
|
||||
|
||||
DbgPrint("[TCPIP, FileCloseAddress] AddrFile->RefCount = %d before TCPClose\n", AddrFile->RefCount);
|
||||
|
||||
/* We have to close this listener because we started it */
|
||||
if ( AddrFile->Listener )
|
||||
{
|
||||
AddrFile->Listener->AddressFile = NULL;
|
||||
|
||||
//DbgPrint("[TCPIP, FileCloseAddress] Calling TCPClose( 0x%x )\n", AddrFile->Listener);
|
||||
TCPClose( AddrFile->Listener );
|
||||
}
|
||||
|
||||
DbgPrint("[TCPIP, FileCloseAddress] AddrFile->RefCount = %d\n", AddrFile->RefCount);
|
||||
|
||||
UnlockObject(AddrFile, OldIrql);
|
||||
|
||||
DereferenceObject(AddrFile);
|
||||
|
||||
DbgPrint("[TCPIP, FileCloseAddress] AddrFile->RefCount = %d after TCPClose\n", AddrFile->RefCount);
|
||||
|
||||
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
|
||||
DbgPrint("[TCPIP, FileCloseAddress] Leaving\n");
|
||||
|
||||
|
@ -440,6 +446,7 @@ NTSTATUS FileOpenConnection(
|
|||
|
||||
Status = TCPSocket( Connection, AF_INET, SOCK_STREAM, IPPROTO_TCP );
|
||||
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DereferenceObject( Connection );
|
||||
|
|
|
@ -105,144 +105,161 @@ NTSTATUS TiCreateFileObject(
|
|||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
PFILE_FULL_EA_INFORMATION EaInfo;
|
||||
PTRANSPORT_CONTEXT Context;
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
PTA_IP_ADDRESS Address;
|
||||
TDI_REQUEST Request;
|
||||
PVOID ClientContext;
|
||||
NTSTATUS Status;
|
||||
ULONG Protocol;
|
||||
PFILE_FULL_EA_INFORMATION EaInfo;
|
||||
PTRANSPORT_CONTEXT Context;
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
PTA_IP_ADDRESS Address;
|
||||
TDI_REQUEST Request;
|
||||
PVOID ClientContext;
|
||||
NTSTATUS Status;
|
||||
ULONG Protocol;
|
||||
|
||||
TI_DbgPrint(DEBUG_IRP, ("Called. DeviceObject is at (0x%X), IRP is at (0x%X).\n", DeviceObject, Irp));
|
||||
TI_DbgPrint(DEBUG_IRP, ("Called. DeviceObject is at (0x%X), IRP is at (0x%X).\n", DeviceObject, Irp));
|
||||
|
||||
EaInfo = Irp->AssociatedIrp.SystemBuffer;
|
||||
EaInfo = Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
/* Parameter check */
|
||||
/* No EA information means that we're opening for SET/QUERY_INFORMATION
|
||||
* style calls. */
|
||||
/* Parameter check */
|
||||
/* No EA information means that we're opening for SET/QUERY_INFORMATION
|
||||
* style calls. */
|
||||
|
||||
/* Allocate resources here. We release them again if something failed */
|
||||
Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(TRANSPORT_CONTEXT),
|
||||
TRANS_CONTEXT_TAG);
|
||||
if (!Context) {
|
||||
TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
Context->CancelIrps = FALSE;
|
||||
|
||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
IrpSp->FileObject->FsContext = Context;
|
||||
Request.RequestContext = Irp;
|
||||
|
||||
/* Branch to the right handler */
|
||||
if (EaInfo &&
|
||||
(EaInfo->EaNameLength == TDI_TRANSPORT_ADDRESS_LENGTH) &&
|
||||
(RtlCompareMemory
|
||||
(&EaInfo->EaName, TdiTransportAddress,
|
||||
TDI_TRANSPORT_ADDRESS_LENGTH) == TDI_TRANSPORT_ADDRESS_LENGTH)) {
|
||||
/* This is a request to open an address */
|
||||
|
||||
|
||||
/* XXX This should probably be done in IoCreateFile() */
|
||||
/* Parameter checks */
|
||||
|
||||
Address = (PTA_IP_ADDRESS)(EaInfo->EaName + EaInfo->EaNameLength + 1); //0-term
|
||||
|
||||
if ((EaInfo->EaValueLength < sizeof(TA_IP_ADDRESS)) ||
|
||||
(Address->TAAddressCount != 1) ||
|
||||
(Address->Address[0].AddressLength < TDI_ADDRESS_LENGTH_IP) ||
|
||||
(Address->Address[0].AddressType != TDI_ADDRESS_TYPE_IP)) {
|
||||
TI_DbgPrint(MIN_TRACE, ("Parameters are invalid:\n"));
|
||||
TI_DbgPrint(MIN_TRACE, ("AddressCount: %d\n", Address->TAAddressCount));
|
||||
if( Address->TAAddressCount == 1 ) {
|
||||
TI_DbgPrint(MIN_TRACE, ("AddressLength: %\n",
|
||||
Address->Address[0].AddressLength));
|
||||
TI_DbgPrint(MIN_TRACE, ("AddressType: %\n",
|
||||
Address->Address[0].AddressType));
|
||||
}
|
||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
/* Allocate resources here. We release them again if something failed */
|
||||
Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(TRANSPORT_CONTEXT),
|
||||
TRANS_CONTEXT_TAG);
|
||||
if (!Context)
|
||||
{
|
||||
TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
/* Open address file object */
|
||||
Context->CancelIrps = FALSE;
|
||||
|
||||
/* Protocol depends on device object so find the protocol */
|
||||
if (DeviceObject == TCPDeviceObject)
|
||||
Protocol = IPPROTO_TCP;
|
||||
else if (DeviceObject == UDPDeviceObject)
|
||||
Protocol = IPPROTO_UDP;
|
||||
else if (DeviceObject == IPDeviceObject)
|
||||
Protocol = IPPROTO_RAW;
|
||||
else if (DeviceObject == RawIPDeviceObject) {
|
||||
Status = TiGetProtocolNumber(&IrpSp->FileObject->FileName, &Protocol);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
TI_DbgPrint(MIN_TRACE, ("Raw IP protocol number is invalid.\n"));
|
||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
IrpSp->FileObject->FsContext = Context;
|
||||
Request.RequestContext = Irp;
|
||||
|
||||
/* Branch to the right handler */
|
||||
if (EaInfo &&
|
||||
(EaInfo->EaNameLength == TDI_TRANSPORT_ADDRESS_LENGTH) &&
|
||||
(RtlCompareMemory(&EaInfo->EaName, TdiTransportAddress,
|
||||
TDI_TRANSPORT_ADDRESS_LENGTH) == TDI_TRANSPORT_ADDRESS_LENGTH))
|
||||
{
|
||||
/* This is a request to open an address */
|
||||
|
||||
|
||||
/* XXX This should probably be done in IoCreateFile() */
|
||||
/* Parameter checks */
|
||||
|
||||
Address = (PTA_IP_ADDRESS)(EaInfo->EaName + EaInfo->EaNameLength + 1); //0-term
|
||||
|
||||
if ((EaInfo->EaValueLength < sizeof(TA_IP_ADDRESS)) ||
|
||||
(Address->TAAddressCount != 1) ||
|
||||
(Address->Address[0].AddressLength < TDI_ADDRESS_LENGTH_IP) ||
|
||||
(Address->Address[0].AddressType != TDI_ADDRESS_TYPE_IP))
|
||||
{
|
||||
TI_DbgPrint(MIN_TRACE, ("Parameters are invalid:\n"));
|
||||
TI_DbgPrint(MIN_TRACE, ("AddressCount: %d\n", Address->TAAddressCount));
|
||||
if( Address->TAAddressCount == 1 )
|
||||
{
|
||||
TI_DbgPrint(MIN_TRACE, ("AddressLength: %\n",
|
||||
Address->Address[0].AddressLength));
|
||||
TI_DbgPrint(MIN_TRACE, ("AddressType: %\n",
|
||||
Address->Address[0].AddressType));
|
||||
}
|
||||
|
||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Open address file object */
|
||||
|
||||
/* Protocol depends on device object so find the protocol */
|
||||
if (DeviceObject == TCPDeviceObject)
|
||||
Protocol = IPPROTO_TCP;
|
||||
else if (DeviceObject == UDPDeviceObject)
|
||||
Protocol = IPPROTO_UDP;
|
||||
else if (DeviceObject == IPDeviceObject)
|
||||
Protocol = IPPROTO_RAW;
|
||||
else if (DeviceObject == RawIPDeviceObject)
|
||||
{
|
||||
Status = TiGetProtocolNumber(&IrpSp->FileObject->FileName, &Protocol);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
TI_DbgPrint(MIN_TRACE, ("Raw IP protocol number is invalid.\n"));
|
||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TI_DbgPrint(MIN_TRACE, ("Invalid device object at (0x%X).\n", DeviceObject));
|
||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = FileOpenAddress(&Request, Address, Protocol, NULL);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
IrpSp->FileObject->FsContext2 = (PVOID)TDI_TRANSPORT_ADDRESS_FILE;
|
||||
Context->Handle.AddressHandle = Request.Handle.AddressHandle;
|
||||
}
|
||||
|
||||
}
|
||||
else if (EaInfo &&
|
||||
(EaInfo->EaNameLength == TDI_CONNECTION_CONTEXT_LENGTH) &&
|
||||
(RtlCompareMemory
|
||||
(&EaInfo->EaName, TdiConnectionContext,
|
||||
TDI_CONNECTION_CONTEXT_LENGTH) ==
|
||||
TDI_CONNECTION_CONTEXT_LENGTH))
|
||||
{
|
||||
/* This is a request to open a connection endpoint */
|
||||
|
||||
/* Parameter checks */
|
||||
|
||||
if (EaInfo->EaValueLength < sizeof(PVOID))
|
||||
{
|
||||
TI_DbgPrint(MIN_TRACE, ("Parameters are invalid.\n"));
|
||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Can only do connection oriented communication using TCP */
|
||||
|
||||
if (DeviceObject != TCPDeviceObject)
|
||||
{
|
||||
TI_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
|
||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ClientContext = *((PVOID*)(EaInfo->EaName + EaInfo->EaNameLength));
|
||||
|
||||
/* Open connection endpoint file object */
|
||||
|
||||
Status = FileOpenConnection(&Request, ClientContext);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
IrpSp->FileObject->FsContext2 = (PVOID)TDI_CONNECTION_FILE;
|
||||
Context->Handle.ConnectionContext = Request.Handle.ConnectionContext;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is a request to open a control connection */
|
||||
Status = FileOpenControlChannel(&Request);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
IrpSp->FileObject->FsContext2 = (PVOID)TDI_CONTROL_CHANNEL_FILE;
|
||||
Context->Handle.ControlChannel = Request.Handle.ControlChannel;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
} else {
|
||||
TI_DbgPrint(MIN_TRACE, ("Invalid device object at (0x%X).\n", DeviceObject));
|
||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = FileOpenAddress(&Request, Address, Protocol, NULL);
|
||||
if (NT_SUCCESS(Status)) {
|
||||
IrpSp->FileObject->FsContext2 = (PVOID)TDI_TRANSPORT_ADDRESS_FILE;
|
||||
Context->Handle.AddressHandle = Request.Handle.AddressHandle;
|
||||
}
|
||||
TI_DbgPrint(DEBUG_IRP, ("Leaving. Status = (0x%X).\n", Status));
|
||||
|
||||
} else if (EaInfo &&
|
||||
(EaInfo->EaNameLength == TDI_CONNECTION_CONTEXT_LENGTH) &&
|
||||
(RtlCompareMemory
|
||||
(&EaInfo->EaName, TdiConnectionContext,
|
||||
TDI_CONNECTION_CONTEXT_LENGTH) ==
|
||||
TDI_CONNECTION_CONTEXT_LENGTH)) {
|
||||
/* This is a request to open a connection endpoint */
|
||||
|
||||
/* Parameter checks */
|
||||
|
||||
if (EaInfo->EaValueLength < sizeof(PVOID)) {
|
||||
TI_DbgPrint(MIN_TRACE, ("Parameters are invalid.\n"));
|
||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Can only do connection oriented communication using TCP */
|
||||
|
||||
if (DeviceObject != TCPDeviceObject) {
|
||||
TI_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
|
||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ClientContext = *((PVOID*)(EaInfo->EaName + EaInfo->EaNameLength));
|
||||
|
||||
/* Open connection endpoint file object */
|
||||
|
||||
Status = FileOpenConnection(&Request, ClientContext);
|
||||
if (NT_SUCCESS(Status)) {
|
||||
IrpSp->FileObject->FsContext2 = (PVOID)TDI_CONNECTION_FILE;
|
||||
Context->Handle.ConnectionContext = Request.Handle.ConnectionContext;
|
||||
}
|
||||
} else {
|
||||
/* This is a request to open a control connection */
|
||||
Status = FileOpenControlChannel(&Request);
|
||||
if (NT_SUCCESS(Status)) {
|
||||
IrpSp->FileObject->FsContext2 = (PVOID)TDI_CONTROL_CHANNEL_FILE;
|
||||
Context->Handle.ControlChannel = Request.Handle.ControlChannel;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||
|
||||
TI_DbgPrint(DEBUG_IRP, ("Leaving. Status = (0x%X).\n", Status));
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
return Status;
|
||||
Irp->IoStatus.Status = Status;
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ BOOLEAN TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener,
|
|||
{
|
||||
Bucket = CONTAINING_RECORD(ListEntry, TDI_BUCKET, Entry);
|
||||
|
||||
if( Bucket->AssociatedEndpoint == Connection )
|
||||
if (Bucket->AssociatedEndpoint == Connection)
|
||||
{
|
||||
DereferenceObject(Bucket->AssociatedEndpoint);
|
||||
RemoveEntryList( &Bucket->Entry );
|
||||
|
|
|
@ -77,7 +77,7 @@ FlushAllQueues(PCONNECTION_ENDPOINT Connection, NTSTATUS Status)
|
|||
|
||||
ReferenceObject(Connection);
|
||||
|
||||
DbgPrint("Flushing recv/all with status: 0x%x\n", Status);
|
||||
DbgPrint("[IP, FlushAllQueues] Flushing recv/all with status: 0x%x\n", Status);
|
||||
|
||||
while ((Entry = ExInterlockedRemoveHeadList(&Connection->ReceiveRequest, &Connection->Lock)))
|
||||
{
|
||||
|
@ -102,8 +102,10 @@ FlushAllQueues(PCONNECTION_ENDPOINT Connection, NTSTATUS Status)
|
|||
|
||||
Bucket->Status = Status;
|
||||
Bucket->Information = 0;
|
||||
|
||||
DbgPrint("[IP, FlushAllQueues] Flushing Listen request for Connection = 0x%x\n", Bucket->AssociatedEndpoint);
|
||||
|
||||
//DereferenceObject(Bucket->AssociatedEndpoint);
|
||||
DereferenceObject(Bucket->AssociatedEndpoint);
|
||||
CompleteBucket(Connection, Bucket, TRUE);
|
||||
}
|
||||
|
||||
|
@ -179,9 +181,6 @@ TCPAcceptEventHandler(void *arg, struct tcp_pcb *newpcb)
|
|||
Bucket->Status = Status;
|
||||
Bucket->Information = 0;
|
||||
|
||||
DbgPrint("[IP, TCPAcceptEventHandler] Associated with: 0x%x\n",
|
||||
Bucket->AssociatedEndpoint->SocketContext);
|
||||
|
||||
DbgPrint("[IP, TCPAcceptEventHandler] Completing accept event %x\n", Status);
|
||||
|
||||
if (Status == STATUS_SUCCESS)
|
||||
|
@ -194,7 +193,6 @@ TCPAcceptEventHandler(void *arg, struct tcp_pcb *newpcb)
|
|||
LockObject(Bucket->AssociatedEndpoint, &OldIrql);
|
||||
|
||||
/* free previously created socket context (we don't use it, we use newpcb) */
|
||||
//LibTCPClose(Bucket->AssociatedEndpoint->SocketContext);
|
||||
OldSocketContext = Bucket->AssociatedEndpoint->SocketContext;
|
||||
Bucket->AssociatedEndpoint->SocketContext = newpcb;
|
||||
|
||||
|
|
|
@ -81,11 +81,11 @@ NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
|||
LockObject(Connection, &OldIrql);
|
||||
|
||||
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);
|
||||
"Proto %d, sizeof(CONNECTION_ENDPOINT) = %d\n",
|
||||
Connection, Family, Type, Proto, sizeof(CONNECTION_ENDPOINT)));
|
||||
DbgPrint("[IP, TCPSocket] Called: Connection 0x%x, Family %d, Type %d, "
|
||||
"Proto %d, sizeof(CONNECTION_ENDPOINT) = %d\n",
|
||||
Connection, Family, Type, Proto, sizeof(CONNECTION_ENDPOINT));
|
||||
|
||||
Connection->SocketContext = LibTCPSocket(Connection);
|
||||
if (Connection->SocketContext)
|
||||
|
@ -93,6 +93,8 @@ NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
|||
else
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
DbgPrint("[IP, TCPSocket] Connection->SocketContext = 0x%x\n", Connection->SocketContext);
|
||||
|
||||
UnlockObject(Connection, OldIrql);
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("[IP, TCPSocket] Leaving. Status = 0x%x\n", Status));
|
||||
|
@ -101,6 +103,37 @@ NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
|||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS TCPClose
|
||||
( PCONNECTION_ENDPOINT Connection )
|
||||
{
|
||||
KIRQL OldIrql;
|
||||
PVOID Socket;
|
||||
|
||||
LockObject(Connection, &OldIrql);
|
||||
Socket = Connection->SocketContext;
|
||||
Connection->SocketContext = NULL;
|
||||
|
||||
DbgPrint("[IP, TCPClose] Called\n");
|
||||
|
||||
/* We should not be associated to an address file at this point */
|
||||
ASSERT(!Connection->AddressFile);
|
||||
|
||||
/* Don't try to close again if the other side closed us already */
|
||||
if (Socket)
|
||||
{
|
||||
FlushAllQueues(Connection, STATUS_CANCELLED);
|
||||
LibTCPClose(Socket);
|
||||
}
|
||||
|
||||
UnlockObject(Connection, OldIrql);
|
||||
|
||||
DereferenceObject(Connection);
|
||||
|
||||
DbgPrint("[IP, TCPClose] Leaving. Connection->RefCount = %d\n", Connection->RefCount);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID TCPReceive(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
|
||||
/*
|
||||
* FUNCTION: Receives and queues TCP data
|
||||
|
@ -333,34 +366,6 @@ NTSTATUS TCPDisconnect
|
|||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS TCPClose
|
||||
( PCONNECTION_ENDPOINT Connection )
|
||||
{
|
||||
KIRQL OldIrql;
|
||||
PVOID Socket;
|
||||
|
||||
LockObject(Connection, &OldIrql);
|
||||
Socket = Connection->SocketContext;
|
||||
Connection->SocketContext = NULL;
|
||||
|
||||
/* We should not be associated to an address file at this point */
|
||||
ASSERT(!Connection->AddressFile);
|
||||
|
||||
/* Don't try to close again if the other side closed us already */
|
||||
if (Socket)
|
||||
{
|
||||
FlushAllQueues(Connection, STATUS_CANCELLED);
|
||||
|
||||
LibTCPClose(Socket);
|
||||
}
|
||||
|
||||
UnlockObject(Connection, OldIrql);
|
||||
|
||||
DereferenceObject(Connection);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS TCPReceiveData
|
||||
( PCONNECTION_ENDPOINT Connection,
|
||||
PNDIS_BUFFER Buffer,
|
||||
|
|
|
@ -252,6 +252,8 @@ ip_input(struct pbuf *p, struct netif *inp)
|
|||
IP_STATS_INC(ip.recv);
|
||||
snmp_inc_ipinreceives();
|
||||
|
||||
DbgPrint("ip_input: called\n");
|
||||
|
||||
/* identify the IP header */
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
if (IPH_V(iphdr) != 4) {
|
||||
|
@ -488,7 +490,7 @@ ip_input(struct pbuf *p, struct netif *inp)
|
|||
if (raw_input(p, inp) == 0)
|
||||
#endif /* LWIP_RAW */
|
||||
{
|
||||
|
||||
DbgPrint("ip_input: choosing protocol\n");
|
||||
switch (IPH_PROTO(iphdr)) {
|
||||
#if LWIP_UDP
|
||||
case IP_PROTO_UDP:
|
||||
|
@ -502,6 +504,7 @@ ip_input(struct pbuf *p, struct netif *inp)
|
|||
#if LWIP_TCP
|
||||
case IP_PROTO_TCP:
|
||||
snmp_inc_ipindelivers();
|
||||
DbgPrint("ip_input: sending data to tcp_input\n");
|
||||
tcp_input(p, inp);
|
||||
break;
|
||||
#endif /* LWIP_TCP */
|
||||
|
|
|
@ -139,7 +139,7 @@ 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));
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_close_shutdown: called on pcb 0x%x\n", pcb));
|
||||
|
||||
if (rst_on_unacked_data && (pcb->state != LISTEN)) {
|
||||
if ((pcb->refused_data != NULL) || (pcb->rcv_wnd != TCP_WND)) {
|
||||
|
@ -181,6 +181,7 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
|
|||
break;
|
||||
case LISTEN:
|
||||
err = ERR_OK;
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_close_shutdown: Remove pcb from listen list and free\n"));
|
||||
tcp_pcb_remove(&tcp_listen_pcbs.pcbs, pcb);
|
||||
memp_free(MEMP_TCP_PCB_LISTEN, pcb);
|
||||
pcb = NULL;
|
||||
|
@ -487,6 +488,8 @@ tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog)
|
|||
|
||||
LWIP_UNUSED_ARG(backlog);
|
||||
LWIP_ERROR("tcp_listen: pcb already connected", pcb->state == CLOSED, return NULL);
|
||||
DbgPrint("tcp_listen_with_backlog: sizeof(tcp_pcb_listen) = %d, %d\n",
|
||||
sizeof(struct tcp_pcb_listen), (((sizeof(struct tcp_pcb_listen)) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1)));
|
||||
|
||||
/* already listening? */
|
||||
if (pcb->state == LISTEN) {
|
||||
|
|
|
@ -108,8 +108,6 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
|||
iphdr = (struct ip_hdr *)p->payload;
|
||||
tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4);
|
||||
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_input: called\n"));
|
||||
|
||||
#if TCP_INPUT_DEBUG
|
||||
tcp_debug_print(tcphdr);
|
||||
#endif
|
||||
|
@ -177,22 +175,25 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
|||
flags = TCPH_FLAGS(tcphdr);
|
||||
tcplen = p->tot_len + ((flags & (TCP_FIN | TCP_SYN)) ? 1 : 0);
|
||||
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_input: called %"U16_F" -> %"U16_F"\n", tcphdr->src, tcphdr->dest));
|
||||
|
||||
/* Demultiplex an incoming segment. First, we check if it is destined
|
||||
for an active connection. */
|
||||
prev = NULL;
|
||||
|
||||
|
||||
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next)
|
||||
{
|
||||
LWIP_ASSERT("tcp_input: active pcb->state != CLOSED", pcb->state != CLOSED);
|
||||
LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT);
|
||||
LWIP_ASSERT("tcp_input: active pcb->state != LISTEN", pcb->state != LISTEN);
|
||||
|
||||
if (pcb->remote_port == tcphdr->src &&
|
||||
pcb->local_port == tcphdr->dest &&
|
||||
ip_addr_cmp(&(pcb->remote_ip), ¤t_iphdr_src) &&
|
||||
ip_addr_cmp(&(pcb->local_ip), ¤t_iphdr_dest))
|
||||
{
|
||||
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_input: active pcb -> (localport, remoteport) = %"U16_F" -> %"U16_F"\n", pcb->local_port, pcb->remote_port));
|
||||
DbgPrint("tcp_input: pcb = 0x%x\n", pcb);
|
||||
/* Move this PCB to the front of the list so that subsequent
|
||||
lookups will be faster (we exploit locality in TCP segment
|
||||
arrivals). */
|
||||
|
@ -909,6 +910,8 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||
u16_t new_tot_len;
|
||||
int found_dupack = 0;
|
||||
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_receive: called\n"));
|
||||
|
||||
if (flags & TCP_ACK) {
|
||||
right_wnd_edge = pcb->snd_wnd + pcb->snd_wl2;
|
||||
|
||||
|
@ -1534,6 +1537,8 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||
tcp_ack_now(pcb);
|
||||
}
|
||||
}
|
||||
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_receive: done\n"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -128,7 +128,7 @@ static
|
|||
err_t
|
||||
InternalAcceptEventHandler(void *arg, struct tcp_pcb *newpcb, err_t err)
|
||||
{
|
||||
DbgPrint("[lwIP, InternalAcceptEventHandler] AcceptEvent (0x%x, 0x%x, %d)\n",
|
||||
DbgPrint("[lwIP, InternalAcceptEventHandler] AcceptEvent arg = 0x%x, newpcb = 0x%x, err = %d\n",
|
||||
arg, newpcb, (unsigned int)err);
|
||||
|
||||
/* Make sure the socket didn't get closed */
|
||||
|
@ -197,8 +197,12 @@ LibTCPSocketCallback(void *arg)
|
|||
struct socket_callback_msg *msg = arg;
|
||||
|
||||
ASSERT(msg);
|
||||
|
||||
DbgPrint("[lwIP, LibTCPSocketCallback] Called\n");
|
||||
|
||||
msg->NewPcb = tcp_new();
|
||||
|
||||
DbgPrint("[lwIP, LibTCPSocketCallback] Assigned new pcb = 0x%x\n", msg->NewPcb);
|
||||
|
||||
if (msg->NewPcb)
|
||||
{
|
||||
|
@ -214,6 +218,8 @@ LibTCPSocket(void *arg)
|
|||
{
|
||||
struct socket_callback_msg *msg = ExAllocatePool(NonPagedPool, sizeof(struct socket_callback_msg));
|
||||
void *ret;
|
||||
|
||||
DbgPrint("[lwIP, LibTCPSocket] Called\n");
|
||||
|
||||
if (msg)
|
||||
{
|
||||
|
@ -227,12 +233,16 @@ LibTCPSocket(void *arg)
|
|||
else
|
||||
ret = NULL;
|
||||
|
||||
DbgPrint("[lwIP, LibTCPSocket] (0x%x) = 0x%x\n", arg, ret);
|
||||
DbgPrint("[lwIP, LibTCPSocket] Connection( 0x%x )->SocketContext = pcb( 0x%x )\n", arg, ret);
|
||||
|
||||
DbgPrint("[lwIP, LibTCPSocket] Done\n");
|
||||
|
||||
ExFreePool(msg);
|
||||
|
||||
return (struct tcp_pcb*)ret;
|
||||
}
|
||||
|
||||
DbgPrint("[lwIP, LibTCPSocket] Done\n");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -347,7 +357,7 @@ LibTCPListen(struct tcp_pcb *pcb, u8_t backlog)
|
|||
struct listen_callback_msg *msg;
|
||||
void *ret;
|
||||
|
||||
DbgPrint("[lwIP, LibTCPListen] Called\n");
|
||||
DbgPrint("[lwIP, LibTCPListen] Called on pcb = 0x%x\n", pcb);
|
||||
|
||||
if (!pcb)
|
||||
return NULL;
|
||||
|
@ -366,7 +376,8 @@ LibTCPListen(struct tcp_pcb *pcb, u8_t backlog)
|
|||
else
|
||||
ret = NULL;
|
||||
|
||||
DbgPrint("[lwIP, LibTCPListen] pcb = 0x%x \n", pcb);
|
||||
DbgPrint("[lwIP, LibTCPListen] pcb = 0x%x, newpcb = 0x%x, sizeof(pcb) = %d \n",
|
||||
pcb, ret, sizeof(struct tcp_pcb));
|
||||
|
||||
DbgPrint("[lwIP, LibTCPListen] Done\n");
|
||||
|
||||
|
@ -617,7 +628,7 @@ LibTCPClose(struct tcp_pcb *pcb)
|
|||
struct close_callback_msg *msg;
|
||||
err_t ret;
|
||||
|
||||
DbgPrint("[lwIP, LibTCPClose] Called\n");
|
||||
DbgPrint("[lwIP, LibTCPClose] Called on pcb = 0x%x\n", pcb);
|
||||
|
||||
if (!pcb)
|
||||
{
|
||||
|
@ -626,7 +637,9 @@ LibTCPClose(struct tcp_pcb *pcb)
|
|||
}
|
||||
|
||||
DbgPrint("[lwIP, LibTCPClose] Removing pcb callbacks\n");
|
||||
|
||||
|
||||
DbgPrint("[lwIP, LibTCPClose] pcb->state = %s\n", tcp_state_str[pcb->state]);
|
||||
|
||||
tcp_arg(pcb, NULL);
|
||||
tcp_recv(pcb, NULL);
|
||||
tcp_sent(pcb, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue