mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:53:06 +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 ) )
|
if ( !SocketAcquireStateLock( FCB ) )
|
||||||
return LostSocket( Irp );
|
return LostSocket( Irp );
|
||||||
|
|
||||||
if ( !(BindReq = LockRequest( Irp, IrpSp )) )
|
if ( !(BindReq = LockRequest( Irp, IrpSp )) )
|
||||||
return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0 );
|
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",
|
AFD_DbgPrint(MID_TRACE,("Socket Address (K) %x (U) %x\n",
|
||||||
&ListenReceive->Address,
|
&ListenReceive->Address,
|
||||||
Qelt->ConnInfo->RemoteAddress));
|
Qelt->ConnInfo->RemoteAddress));
|
||||||
|
DbgPrint("[SatisfyPreAccept] Called\n");
|
||||||
DbgPrint("[SatisfyPreAccept] Giving SEQ %d to userland\n", Qelt->Seq);
|
DbgPrint("[SatisfyPreAccept] Giving SEQ %d to userland\n", Qelt->Seq);
|
||||||
DbgPrint("[SatisfyPreAccept] Socket Address (K) %x (U) %x\n",
|
DbgPrint("[SatisfyPreAccept] Socket Address (K) %x (U) %x\n",
|
||||||
&ListenReceive->Address,
|
&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",
|
DbgPrint("IPAddr->Address[0].Address[0].sin_addr %x\n",
|
||||||
IPAddr->Address[0].Address[0].in_addr);
|
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.Information = ((PCHAR)&IPAddr[1]) - ((PCHAR)ListenReceive);
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
(void)IoSetCancelRoutine(Irp, NULL);
|
(void)IoSetCancelRoutine(Irp, NULL);
|
||||||
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
|
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
|
||||||
|
|
||||||
|
DbgPrint("[SatisfyPreAccept] Leaving\n");
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,8 +196,7 @@ static NTSTATUS NTAPI ListenComplete
|
||||||
Status = TdiBuildNullConnectionInfo( &Qelt->ConnInfo, AddressType );
|
Status = TdiBuildNullConnectionInfo( &Qelt->ConnInfo, AddressType );
|
||||||
if( NT_SUCCESS(Status) )
|
if( NT_SUCCESS(Status) )
|
||||||
{
|
{
|
||||||
TaCopyTransportAddressInPlace
|
TaCopyTransportAddressInPlace( Qelt->ConnInfo->RemoteAddress,
|
||||||
( Qelt->ConnInfo->RemoteAddress,
|
|
||||||
FCB->ListenIrp.ConnectionReturnInfo->RemoteAddress );
|
FCB->ListenIrp.ConnectionReturnInfo->RemoteAddress );
|
||||||
InsertTailList( &FCB->PendingConnections, &Qelt->ListEntry );
|
InsertTailList( &FCB->PendingConnections, &Qelt->ListEntry );
|
||||||
}
|
}
|
||||||
|
@ -203,9 +206,9 @@ static NTSTATUS NTAPI ListenComplete
|
||||||
if ( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_PREACCEPT] ) &&
|
if ( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_PREACCEPT] ) &&
|
||||||
!IsListEmpty( &FCB->PendingConnections ) )
|
!IsListEmpty( &FCB->PendingConnections ) )
|
||||||
{
|
{
|
||||||
PLIST_ENTRY PendingIrp =
|
PLIST_ENTRY PendingIrp = RemoveHeadList( &FCB->PendingIrpList[FUNCTION_PREACCEPT] );
|
||||||
RemoveHeadList( &FCB->PendingIrpList[FUNCTION_PREACCEPT] );
|
|
||||||
PLIST_ENTRY PendingConn = FCB->PendingConnections.Flink;
|
PLIST_ENTRY PendingConn = FCB->PendingConnections.Flink;
|
||||||
|
|
||||||
SatisfyPreAccept( CONTAINING_RECORD( PendingIrp, IRP,
|
SatisfyPreAccept( CONTAINING_RECORD( PendingIrp, IRP,
|
||||||
Tail.Overlay.ListEntry ),
|
Tail.Overlay.ListEntry ),
|
||||||
CONTAINING_RECORD( PendingConn, AFD_TDI_OBJECT_QELT,
|
CONTAINING_RECORD( PendingConn, AFD_TDI_OBJECT_QELT,
|
||||||
|
@ -213,10 +216,12 @@ static NTSTATUS NTAPI ListenComplete
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Launch new accept socket */
|
/* Launch new accept socket */
|
||||||
|
DbgPrint("[AFD, ListenComplete] Getting warm connection socket\n");
|
||||||
Status = WarmSocketForConnection( FCB );
|
Status = WarmSocketForConnection( FCB );
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
DbgPrint("[AFD, ListenComplete] Done getting warm connection socket\n");
|
||||||
Status = TdiBuildNullConnectionInfoInPlace(FCB->ListenIrp.ConnectionCallInfo,
|
Status = TdiBuildNullConnectionInfoInPlace(FCB->ListenIrp.ConnectionCallInfo,
|
||||||
FCB->LocalAddress->Address[0].AddressType);
|
FCB->LocalAddress->Address[0].AddressType);
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
ASSERT(Status == STATUS_SUCCESS);
|
||||||
|
@ -225,6 +230,7 @@ static NTSTATUS NTAPI ListenComplete
|
||||||
FCB->LocalAddress->Address[0].AddressType);
|
FCB->LocalAddress->Address[0].AddressType);
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
ASSERT(Status == STATUS_SUCCESS);
|
||||||
|
|
||||||
|
DbgPrint("[AFD, ListenComplete] callings TdiListen\n");
|
||||||
Status = TdiListen( &FCB->ListenIrp.InFlightRequest,
|
Status = TdiListen( &FCB->ListenIrp.InFlightRequest,
|
||||||
FCB->Connection.Object,
|
FCB->Connection.Object,
|
||||||
&FCB->ListenIrp.ConnectionCallInfo,
|
&FCB->ListenIrp.ConnectionCallInfo,
|
||||||
|
@ -262,8 +268,8 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
PAFD_FCB FCB = FileObject->FsContext;
|
PAFD_FCB FCB = FileObject->FsContext;
|
||||||
PAFD_LISTEN_DATA ListenReq;
|
PAFD_LISTEN_DATA ListenReq;
|
||||||
|
|
||||||
AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB));
|
AFD_DbgPrint(MID_TRACE,("Called on 0x%x\n", FCB));
|
||||||
DbgPrint("[AfdListenSocket] Called on %x\n", FCB);
|
DbgPrint("[AfdListenSocket] Called on 0x%x\n", FCB);
|
||||||
|
|
||||||
if( !SocketAcquireStateLock( FCB ) )
|
if( !SocketAcquireStateLock( FCB ) )
|
||||||
return LostSocket( Irp );
|
return LostSocket( Irp );
|
||||||
|
@ -282,12 +288,11 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
FCB->DelayedAccept = ListenReq->UseDelayedAcceptance;
|
FCB->DelayedAccept = ListenReq->UseDelayedAcceptance;
|
||||||
|
|
||||||
AFD_DbgPrint(MID_TRACE,("ADDRESSFILE: %x\n", FCB->AddressFile.Handle));
|
AFD_DbgPrint(MID_TRACE,("ADDRESSFILE: %x\n", FCB->AddressFile.Handle));
|
||||||
DbgPrint("[AfdListenSocket] ADDRESSFILE: %x\n", FCB->AddressFile.Handle);
|
|
||||||
|
|
||||||
Status = WarmSocketForConnection( FCB );
|
Status = WarmSocketForConnection( FCB );
|
||||||
|
|
||||||
AFD_DbgPrint(MID_TRACE,("Status from warmsocket %x\n", Status));
|
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) )
|
if ( !NT_SUCCESS(Status) )
|
||||||
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
|
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
|
||||||
|
@ -322,7 +327,7 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
|
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 );
|
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
|
||||||
}
|
}
|
||||||
|
@ -380,14 +385,18 @@ NTSTATUS AfdAccept( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
PAFD_DEVICE_EXTENSION DeviceExt =
|
PAFD_DEVICE_EXTENSION DeviceExt =
|
||||||
(PAFD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
(PAFD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
PAFD_FCB FCB = FileObject->FsContext;
|
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||||
PAFD_ACCEPT_DATA AcceptData = Irp->AssociatedIrp.SystemBuffer;
|
PAFD_ACCEPT_DATA AcceptData = Irp->AssociatedIrp.SystemBuffer;
|
||||||
PLIST_ENTRY PendingConn;
|
PLIST_ENTRY PendingConn;
|
||||||
|
|
||||||
AFD_DbgPrint(MID_TRACE,("Called\n"));
|
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;
|
for( PendingConn = FCB->PendingConnections.Flink;
|
||||||
PendingConn != &FCB->PendingConnections;
|
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 );
|
return UnlockAndMaybeComplete( FCB, STATUS_UNSUCCESSFUL, Irp, 0 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ AfdGetDisconnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
PIO_STACK_LOCATION IrpSp)
|
PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
PAFD_FCB FCB = FileObject->FsContext;
|
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||||
UINT BufferSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
|
UINT BufferSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
|
||||||
|
|
||||||
if (!SocketAcquireStateLock(FCB)) return LostSocket(Irp);
|
if (!SocketAcquireStateLock(FCB)) return LostSocket(Irp);
|
||||||
|
@ -75,7 +75,7 @@ AfdSetDisconnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
PIO_STACK_LOCATION IrpSp)
|
PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
PAFD_FCB FCB = FileObject->FsContext;
|
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||||
PVOID DisconnectOptions = LockRequest(Irp, IrpSp);
|
PVOID DisconnectOptions = LockRequest(Irp, IrpSp);
|
||||||
UINT DisconnectOptionsSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
|
UINT DisconnectOptionsSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
|
||||||
|
|
||||||
|
@ -93,7 +93,9 @@ AfdSetDisconnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
}
|
}
|
||||||
|
|
||||||
FCB->DisconnectOptions = ExAllocatePool(PagedPool, DisconnectOptionsSize);
|
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,
|
RtlCopyMemory(FCB->DisconnectOptions,
|
||||||
DisconnectOptions,
|
DisconnectOptions,
|
||||||
|
@ -110,8 +112,8 @@ AfdSetDisconnectOptionsSize(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
PIO_STACK_LOCATION IrpSp)
|
PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
PAFD_FCB FCB = FileObject->FsContext;
|
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||||
PUINT DisconnectOptionsSize = LockRequest(Irp, IrpSp);
|
PUINT DisconnectOptionsSize = (PUINT)LockRequest(Irp, IrpSp);
|
||||||
UINT BufferSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
|
UINT BufferSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
|
||||||
|
|
||||||
if (!SocketAcquireStateLock(FCB)) return LostSocket(Irp);
|
if (!SocketAcquireStateLock(FCB)) return LostSocket(Irp);
|
||||||
|
@ -130,7 +132,9 @@ AfdSetDisconnectOptionsSize(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
}
|
}
|
||||||
|
|
||||||
FCB->DisconnectOptions = ExAllocatePool(PagedPool, *DisconnectOptionsSize);
|
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;
|
FCB->DisconnectOptionsSize = *DisconnectOptionsSize;
|
||||||
|
|
||||||
|
@ -142,7 +146,7 @@ AfdGetDisconnectData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
PIO_STACK_LOCATION IrpSp)
|
PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
PAFD_FCB FCB = FileObject->FsContext;
|
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||||
UINT BufferSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
|
UINT BufferSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
|
||||||
|
|
||||||
if (!SocketAcquireStateLock(FCB)) return LostSocket(Irp);
|
if (!SocketAcquireStateLock(FCB)) return LostSocket(Irp);
|
||||||
|
@ -185,7 +189,9 @@ AfdSetDisconnectData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
}
|
}
|
||||||
|
|
||||||
FCB->DisconnectData = ExAllocatePool(PagedPool, DisconnectDataSize);
|
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,
|
RtlCopyMemory(FCB->DisconnectData,
|
||||||
DisconnectData,
|
DisconnectData,
|
||||||
|
@ -222,7 +228,9 @@ AfdSetDisconnectDataSize(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
}
|
}
|
||||||
|
|
||||||
FCB->DisconnectData = ExAllocatePool(PagedPool, *DisconnectDataSize);
|
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;
|
FCB->DisconnectDataSize = *DisconnectDataSize;
|
||||||
|
|
||||||
|
@ -299,6 +307,8 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
AFD_DbgPrint(MID_TRACE,("About to allocate the new FCB\n"));
|
AFD_DbgPrint(MID_TRACE,("About to allocate the new FCB\n"));
|
||||||
|
|
||||||
FCB = ExAllocatePool(NonPagedPool, sizeof(AFD_FCB));
|
FCB = ExAllocatePool(NonPagedPool, sizeof(AFD_FCB));
|
||||||
|
RtlZeroMemory(FCB, sizeof(AFD_FCB));
|
||||||
|
|
||||||
if( FCB == NULL )
|
if( FCB == NULL )
|
||||||
{
|
{
|
||||||
Irp->IoStatus.Status = STATUS_NO_MEMORY;
|
Irp->IoStatus.Status = STATUS_NO_MEMORY;
|
||||||
|
@ -337,6 +347,7 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
FCB->TdiDeviceName.MaximumLength = FCB->TdiDeviceName.Length;
|
FCB->TdiDeviceName.MaximumLength = FCB->TdiDeviceName.Length;
|
||||||
FCB->TdiDeviceName.Buffer =
|
FCB->TdiDeviceName.Buffer =
|
||||||
ExAllocatePool( NonPagedPool, FCB->TdiDeviceName.Length );
|
ExAllocatePool( NonPagedPool, FCB->TdiDeviceName.Length );
|
||||||
|
RtlZeroMemory(FCB->TdiDeviceName.Buffer, FCB->TdiDeviceName.Length);
|
||||||
|
|
||||||
if( !FCB->TdiDeviceName.Buffer )
|
if( !FCB->TdiDeviceName.Buffer )
|
||||||
{
|
{
|
||||||
|
@ -393,7 +404,7 @@ AfdCleanupSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
PIO_STACK_LOCATION IrpSp)
|
PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
PAFD_FCB FCB = FileObject->FsContext;
|
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||||
PLIST_ENTRY CurrentEntry, NextEntry;
|
PLIST_ENTRY CurrentEntry, NextEntry;
|
||||||
UINT Function;
|
UINT Function;
|
||||||
PIRP CurrentIrp;
|
PIRP CurrentIrp;
|
||||||
|
@ -431,7 +442,7 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
PIO_STACK_LOCATION IrpSp)
|
PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
PAFD_FCB FCB = FileObject->FsContext;
|
PAFD_FCB FCB = (PAFD_FCB)FileObject->FsContext;
|
||||||
UINT i;
|
UINT i;
|
||||||
PAFD_IN_FLIGHT_REQUEST InFlightRequest[IN_FLIGHT_REQUESTS];
|
PAFD_IN_FLIGHT_REQUEST InFlightRequest[IN_FLIGHT_REQUESTS];
|
||||||
PAFD_TDI_OBJECT_QELT Qelt;
|
PAFD_TDI_OBJECT_QELT Qelt;
|
||||||
|
@ -448,9 +459,6 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
DbgPrint("[AFD, AfdCloseSocket] Setting closed state\n");
|
DbgPrint("[AFD, AfdCloseSocket] Setting closed state\n");
|
||||||
|
|
||||||
FCB->State = SOCKET_STATE_CLOSED;
|
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[0] = &FCB->ListenIrp;
|
||||||
InFlightRequest[1] = &FCB->ReceiveIrp;
|
InFlightRequest[1] = &FCB->ReceiveIrp;
|
||||||
|
@ -689,7 +697,9 @@ AfdDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AFD_DbgPrint(MID_TRACE,("AfdDispatch: %d\n", IrpSp->MajorFunction));
|
AFD_DbgPrint(MID_TRACE,("AfdDispatch: %d\n", IrpSp->MajorFunction));
|
||||||
if( IrpSp->MajorFunction != IRP_MJ_CREATE) {
|
|
||||||
|
if( IrpSp->MajorFunction != IRP_MJ_CREATE)
|
||||||
|
{
|
||||||
AFD_DbgPrint(MID_TRACE,("FO %x, IrpSp->FO %x\n",
|
AFD_DbgPrint(MID_TRACE,("FO %x, IrpSp->FO %x\n",
|
||||||
FileObject, IrpSp->FileObject));
|
FileObject, IrpSp->FileObject));
|
||||||
ASSERT(FileObject == IrpSp->FileObject);
|
ASSERT(FileObject == IrpSp->FileObject);
|
||||||
|
@ -721,7 +731,8 @@ AfdDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
|
|
||||||
case IRP_MJ_DEVICE_CONTROL:
|
case IRP_MJ_DEVICE_CONTROL:
|
||||||
{
|
{
|
||||||
switch( IrpSp->Parameters.DeviceIoControl.IoControlCode ) {
|
switch( IrpSp->Parameters.DeviceIoControl.IoControlCode )
|
||||||
|
{
|
||||||
case IOCTL_AFD_BIND:
|
case IOCTL_AFD_BIND:
|
||||||
return AfdBindSocket( DeviceObject, Irp, IrpSp );
|
return AfdBindSocket( DeviceObject, Irp, IrpSp );
|
||||||
|
|
||||||
|
@ -848,14 +859,14 @@ AfdDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Status = STATUS_NOT_IMPLEMENTED;
|
Status = STATUS_NOT_IMPLEMENTED;
|
||||||
AFD_DbgPrint(MIN_TRACE,
|
AFD_DbgPrint(MIN_TRACE, ("Irp: Unknown Major code was %x\n",
|
||||||
("Irp: Unknown Major code was %x\n",
|
|
||||||
IrpSp->MajorFunction));
|
IrpSp->MajorFunction));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AFD_DbgPrint(MID_TRACE, ("Returning %x\n", Status));
|
AFD_DbgPrint(MID_TRACE, ("Returning %x\n", Status));
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,8 @@ static BOOLEAN CantReadMore( PAFD_FCB FCB ) {
|
||||||
static VOID RefillSocketBuffer( PAFD_FCB FCB ) {
|
static VOID RefillSocketBuffer( PAFD_FCB FCB ) {
|
||||||
NTSTATUS Status;
|
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"));
|
AFD_DbgPrint(MID_TRACE,("Replenishing buffer\n"));
|
||||||
|
|
||||||
Status = TdiReceive( &FCB->ReceiveIrp.InFlightRequest,
|
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->PollState |= AFD_EVENT_RECEIVE;
|
||||||
FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS;
|
FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS;
|
||||||
PollReeval( FCB->DeviceExt, FCB->FileObject );
|
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"));
|
AFD_DbgPrint(MID_TRACE,("Signalling\n"));
|
||||||
FCB->PollState |= AFD_EVENT_RECEIVE;
|
FCB->PollState |= AFD_EVENT_RECEIVE;
|
||||||
FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS;
|
FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS;
|
||||||
|
|
|
@ -287,8 +287,8 @@ AfdEventSelect( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
Status = ObReferenceObjectByHandle( (PVOID)EventSelectInfo->
|
Status = ObReferenceObjectByHandle( (PVOID)EventSelectInfo->
|
||||||
EventObject,
|
EventObject,
|
||||||
FILE_ALL_ACCESS,
|
FILE_ALL_ACCESS,
|
||||||
NULL,
|
ExEventObjectType,
|
||||||
KernelMode,
|
UserMode,
|
||||||
(PVOID *)&FCB->EventSelect,
|
(PVOID *)&FCB->EventSelect,
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
|
|
|
@ -328,8 +328,7 @@ AfdConnectedSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
|
|
||||||
if (SpaceAvail < SendReq->BufferArray[i].len)
|
if (SpaceAvail < SendReq->BufferArray[i].len)
|
||||||
{
|
{
|
||||||
if (FCB->Send.BytesUsed + TotalBytesCopied +
|
if (TotalBytesCopied + SendReq->BufferArray[i].len > FCB->Send.Size)
|
||||||
SendReq->BufferArray[i].len > FCB->Send.Size)
|
|
||||||
{
|
{
|
||||||
UnlockBuffers( SendReq->BufferArray, SendReq->BufferCount, FALSE );
|
UnlockBuffers( SendReq->BufferArray, SendReq->BufferCount, FALSE );
|
||||||
|
|
||||||
|
|
|
@ -229,8 +229,7 @@ VOID NTAPI DispCancelListenRequest(
|
||||||
/* Try canceling the request */
|
/* Try canceling the request */
|
||||||
Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
|
Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
|
||||||
|
|
||||||
if (TCPAbortListenForSocket(Connection->AddressFile->Listener,
|
if (TCPAbortListenForSocket(Connection->AddressFile->Listener, Connection))
|
||||||
Connection))
|
|
||||||
{
|
{
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
IRPFinish(Irp, STATUS_CANCELLED);
|
IRPFinish(Irp, STATUS_CANCELLED);
|
||||||
|
@ -277,6 +276,7 @@ NTSTATUS DispTdiAssociateAddress(
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, DispTdiAssociateAddress] Called\n"));
|
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, DispTdiAssociateAddress] Called\n"));
|
||||||
|
DbgPrint("[TCPIP, DispTdiAssociateAddress] Called\n");
|
||||||
|
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
|
@ -354,6 +354,9 @@ NTSTATUS DispTdiAssociateAddress(
|
||||||
|
|
||||||
LockObjectAtDpcLevel(AddrFile);
|
LockObjectAtDpcLevel(AddrFile);
|
||||||
|
|
||||||
|
DbgPrint("[TCPIP, DispTdiAssociateAddress] Associating AddressFile = 0x%x with Connection = 0x%x\n",
|
||||||
|
AddrFile, Connection);
|
||||||
|
|
||||||
/* Add connection endpoint to the address file */
|
/* Add connection endpoint to the address file */
|
||||||
ReferenceObject(Connection);
|
ReferenceObject(Connection);
|
||||||
if (AddrFile->Connection == NULL)
|
if (AddrFile->Connection == NULL)
|
||||||
|
@ -374,9 +377,101 @@ NTSTATUS DispTdiAssociateAddress(
|
||||||
|
|
||||||
ObDereferenceObject(FileObject);
|
ObDereferenceObject(FileObject);
|
||||||
|
|
||||||
|
DbgPrint("[TCPIP, DispTdiAssociateAddress] Leaving\n");
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
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(
|
NTSTATUS DispTdiConnect(
|
||||||
PIRP Irp)
|
PIRP Irp)
|
||||||
|
@ -441,90 +536,6 @@ done:
|
||||||
return Status;
|
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(
|
NTSTATUS DispTdiDisconnect(
|
||||||
PIRP Irp)
|
PIRP Irp)
|
||||||
/*
|
/*
|
||||||
|
@ -650,6 +661,8 @@ NTSTATUS DispTdiListen(
|
||||||
if ( NT_SUCCESS(Status) && !Connection->AddressFile->Listener )
|
if ( NT_SUCCESS(Status) && !Connection->AddressFile->Listener )
|
||||||
{
|
{
|
||||||
Connection->AddressFile->Listener = TCPAllocateConnectionEndpoint( NULL );
|
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 )
|
if ( !Connection->AddressFile->Listener )
|
||||||
Status = STATUS_NO_MEMORY;
|
Status = STATUS_NO_MEMORY;
|
||||||
|
|
|
@ -256,6 +256,8 @@ NTSTATUS FileOpenAddress(
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlZeroMemory(AddrFile, sizeof(ADDRESS_FILE));
|
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->RefCount = 1;
|
||||||
AddrFile->Free = AddrFileFree;
|
AddrFile->Free = AddrFileFree;
|
||||||
|
@ -395,19 +397,23 @@ NTSTATUS FileCloseAddress(
|
||||||
|
|
||||||
LockObject(AddrFile, &OldIrql);
|
LockObject(AddrFile, &OldIrql);
|
||||||
|
|
||||||
|
DbgPrint("[TCPIP, FileCloseAddress] AddrFile->RefCount = %d before TCPClose\n", AddrFile->RefCount);
|
||||||
|
|
||||||
/* We have to close this listener because we started it */
|
/* We have to close this listener because we started it */
|
||||||
if ( AddrFile->Listener )
|
if ( AddrFile->Listener )
|
||||||
{
|
{
|
||||||
AddrFile->Listener->AddressFile = NULL;
|
AddrFile->Listener->AddressFile = NULL;
|
||||||
|
|
||||||
|
//DbgPrint("[TCPIP, FileCloseAddress] Calling TCPClose( 0x%x )\n", AddrFile->Listener);
|
||||||
TCPClose( AddrFile->Listener );
|
TCPClose( AddrFile->Listener );
|
||||||
}
|
}
|
||||||
|
|
||||||
DbgPrint("[TCPIP, FileCloseAddress] AddrFile->RefCount = %d\n", AddrFile->RefCount);
|
|
||||||
|
|
||||||
UnlockObject(AddrFile, OldIrql);
|
UnlockObject(AddrFile, OldIrql);
|
||||||
|
|
||||||
DereferenceObject(AddrFile);
|
DereferenceObject(AddrFile);
|
||||||
|
|
||||||
|
DbgPrint("[TCPIP, FileCloseAddress] AddrFile->RefCount = %d after TCPClose\n", AddrFile->RefCount);
|
||||||
|
|
||||||
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
|
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
|
||||||
DbgPrint("[TCPIP, FileCloseAddress] Leaving\n");
|
DbgPrint("[TCPIP, FileCloseAddress] Leaving\n");
|
||||||
|
|
||||||
|
@ -440,6 +446,7 @@ NTSTATUS FileOpenConnection(
|
||||||
|
|
||||||
Status = TCPSocket( Connection, AF_INET, SOCK_STREAM, IPPROTO_TCP );
|
Status = TCPSocket( Connection, AF_INET, SOCK_STREAM, IPPROTO_TCP );
|
||||||
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DereferenceObject( Connection );
|
DereferenceObject( Connection );
|
||||||
|
|
|
@ -125,7 +125,8 @@ NTSTATUS TiCreateFileObject(
|
||||||
/* Allocate resources here. We release them again if something failed */
|
/* Allocate resources here. We release them again if something failed */
|
||||||
Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(TRANSPORT_CONTEXT),
|
Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(TRANSPORT_CONTEXT),
|
||||||
TRANS_CONTEXT_TAG);
|
TRANS_CONTEXT_TAG);
|
||||||
if (!Context) {
|
if (!Context)
|
||||||
|
{
|
||||||
TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
|
TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
|
@ -139,9 +140,9 @@ NTSTATUS TiCreateFileObject(
|
||||||
/* Branch to the right handler */
|
/* Branch to the right handler */
|
||||||
if (EaInfo &&
|
if (EaInfo &&
|
||||||
(EaInfo->EaNameLength == TDI_TRANSPORT_ADDRESS_LENGTH) &&
|
(EaInfo->EaNameLength == TDI_TRANSPORT_ADDRESS_LENGTH) &&
|
||||||
(RtlCompareMemory
|
(RtlCompareMemory(&EaInfo->EaName, TdiTransportAddress,
|
||||||
(&EaInfo->EaName, TdiTransportAddress,
|
TDI_TRANSPORT_ADDRESS_LENGTH) == TDI_TRANSPORT_ADDRESS_LENGTH))
|
||||||
TDI_TRANSPORT_ADDRESS_LENGTH) == TDI_TRANSPORT_ADDRESS_LENGTH)) {
|
{
|
||||||
/* This is a request to open an address */
|
/* This is a request to open an address */
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,15 +154,18 @@ NTSTATUS TiCreateFileObject(
|
||||||
if ((EaInfo->EaValueLength < sizeof(TA_IP_ADDRESS)) ||
|
if ((EaInfo->EaValueLength < sizeof(TA_IP_ADDRESS)) ||
|
||||||
(Address->TAAddressCount != 1) ||
|
(Address->TAAddressCount != 1) ||
|
||||||
(Address->Address[0].AddressLength < TDI_ADDRESS_LENGTH_IP) ||
|
(Address->Address[0].AddressLength < TDI_ADDRESS_LENGTH_IP) ||
|
||||||
(Address->Address[0].AddressType != TDI_ADDRESS_TYPE_IP)) {
|
(Address->Address[0].AddressType != TDI_ADDRESS_TYPE_IP))
|
||||||
|
{
|
||||||
TI_DbgPrint(MIN_TRACE, ("Parameters are invalid:\n"));
|
TI_DbgPrint(MIN_TRACE, ("Parameters are invalid:\n"));
|
||||||
TI_DbgPrint(MIN_TRACE, ("AddressCount: %d\n", Address->TAAddressCount));
|
TI_DbgPrint(MIN_TRACE, ("AddressCount: %d\n", Address->TAAddressCount));
|
||||||
if( Address->TAAddressCount == 1 ) {
|
if( Address->TAAddressCount == 1 )
|
||||||
|
{
|
||||||
TI_DbgPrint(MIN_TRACE, ("AddressLength: %\n",
|
TI_DbgPrint(MIN_TRACE, ("AddressLength: %\n",
|
||||||
Address->Address[0].AddressLength));
|
Address->Address[0].AddressLength));
|
||||||
TI_DbgPrint(MIN_TRACE, ("AddressType: %\n",
|
TI_DbgPrint(MIN_TRACE, ("AddressType: %\n",
|
||||||
Address->Address[0].AddressType));
|
Address->Address[0].AddressType));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
@ -175,36 +179,44 @@ NTSTATUS TiCreateFileObject(
|
||||||
Protocol = IPPROTO_UDP;
|
Protocol = IPPROTO_UDP;
|
||||||
else if (DeviceObject == IPDeviceObject)
|
else if (DeviceObject == IPDeviceObject)
|
||||||
Protocol = IPPROTO_RAW;
|
Protocol = IPPROTO_RAW;
|
||||||
else if (DeviceObject == RawIPDeviceObject) {
|
else if (DeviceObject == RawIPDeviceObject)
|
||||||
|
{
|
||||||
Status = TiGetProtocolNumber(&IrpSp->FileObject->FileName, &Protocol);
|
Status = TiGetProtocolNumber(&IrpSp->FileObject->FileName, &Protocol);
|
||||||
if (!NT_SUCCESS(Status)) {
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
TI_DbgPrint(MIN_TRACE, ("Raw IP protocol number is invalid.\n"));
|
TI_DbgPrint(MIN_TRACE, ("Raw IP protocol number is invalid.\n"));
|
||||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
TI_DbgPrint(MIN_TRACE, ("Invalid device object at (0x%X).\n", DeviceObject));
|
TI_DbgPrint(MIN_TRACE, ("Invalid device object at (0x%X).\n", DeviceObject));
|
||||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = FileOpenAddress(&Request, Address, Protocol, NULL);
|
Status = FileOpenAddress(&Request, Address, Protocol, NULL);
|
||||||
if (NT_SUCCESS(Status)) {
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
IrpSp->FileObject->FsContext2 = (PVOID)TDI_TRANSPORT_ADDRESS_FILE;
|
IrpSp->FileObject->FsContext2 = (PVOID)TDI_TRANSPORT_ADDRESS_FILE;
|
||||||
Context->Handle.AddressHandle = Request.Handle.AddressHandle;
|
Context->Handle.AddressHandle = Request.Handle.AddressHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (EaInfo &&
|
}
|
||||||
|
else if (EaInfo &&
|
||||||
(EaInfo->EaNameLength == TDI_CONNECTION_CONTEXT_LENGTH) &&
|
(EaInfo->EaNameLength == TDI_CONNECTION_CONTEXT_LENGTH) &&
|
||||||
(RtlCompareMemory
|
(RtlCompareMemory
|
||||||
(&EaInfo->EaName, TdiConnectionContext,
|
(&EaInfo->EaName, TdiConnectionContext,
|
||||||
TDI_CONNECTION_CONTEXT_LENGTH) ==
|
TDI_CONNECTION_CONTEXT_LENGTH) ==
|
||||||
TDI_CONNECTION_CONTEXT_LENGTH)) {
|
TDI_CONNECTION_CONTEXT_LENGTH))
|
||||||
|
{
|
||||||
/* This is a request to open a connection endpoint */
|
/* This is a request to open a connection endpoint */
|
||||||
|
|
||||||
/* Parameter checks */
|
/* Parameter checks */
|
||||||
|
|
||||||
if (EaInfo->EaValueLength < sizeof(PVOID)) {
|
if (EaInfo->EaValueLength < sizeof(PVOID))
|
||||||
|
{
|
||||||
TI_DbgPrint(MIN_TRACE, ("Parameters are invalid.\n"));
|
TI_DbgPrint(MIN_TRACE, ("Parameters are invalid.\n"));
|
||||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
@ -212,7 +224,8 @@ NTSTATUS TiCreateFileObject(
|
||||||
|
|
||||||
/* Can only do connection oriented communication using TCP */
|
/* Can only do connection oriented communication using TCP */
|
||||||
|
|
||||||
if (DeviceObject != TCPDeviceObject) {
|
if (DeviceObject != TCPDeviceObject)
|
||||||
|
{
|
||||||
TI_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
|
TI_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
|
||||||
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
@ -223,14 +236,18 @@ NTSTATUS TiCreateFileObject(
|
||||||
/* Open connection endpoint file object */
|
/* Open connection endpoint file object */
|
||||||
|
|
||||||
Status = FileOpenConnection(&Request, ClientContext);
|
Status = FileOpenConnection(&Request, ClientContext);
|
||||||
if (NT_SUCCESS(Status)) {
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
IrpSp->FileObject->FsContext2 = (PVOID)TDI_CONNECTION_FILE;
|
IrpSp->FileObject->FsContext2 = (PVOID)TDI_CONNECTION_FILE;
|
||||||
Context->Handle.ConnectionContext = Request.Handle.ConnectionContext;
|
Context->Handle.ConnectionContext = Request.Handle.ConnectionContext;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* This is a request to open a control connection */
|
/* This is a request to open a control connection */
|
||||||
Status = FileOpenControlChannel(&Request);
|
Status = FileOpenControlChannel(&Request);
|
||||||
if (NT_SUCCESS(Status)) {
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
IrpSp->FileObject->FsContext2 = (PVOID)TDI_CONTROL_CHANNEL_FILE;
|
IrpSp->FileObject->FsContext2 = (PVOID)TDI_CONTROL_CHANNEL_FILE;
|
||||||
Context->Handle.ControlChannel = Request.Handle.ControlChannel;
|
Context->Handle.ControlChannel = Request.Handle.ControlChannel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ FlushAllQueues(PCONNECTION_ENDPOINT Connection, NTSTATUS Status)
|
||||||
|
|
||||||
ReferenceObject(Connection);
|
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)))
|
while ((Entry = ExInterlockedRemoveHeadList(&Connection->ReceiveRequest, &Connection->Lock)))
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,9 @@ FlushAllQueues(PCONNECTION_ENDPOINT Connection, NTSTATUS Status)
|
||||||
Bucket->Status = Status;
|
Bucket->Status = Status;
|
||||||
Bucket->Information = 0;
|
Bucket->Information = 0;
|
||||||
|
|
||||||
//DereferenceObject(Bucket->AssociatedEndpoint);
|
DbgPrint("[IP, FlushAllQueues] Flushing Listen request for Connection = 0x%x\n", Bucket->AssociatedEndpoint);
|
||||||
|
|
||||||
|
DereferenceObject(Bucket->AssociatedEndpoint);
|
||||||
CompleteBucket(Connection, Bucket, TRUE);
|
CompleteBucket(Connection, Bucket, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,9 +181,6 @@ TCPAcceptEventHandler(void *arg, struct tcp_pcb *newpcb)
|
||||||
Bucket->Status = Status;
|
Bucket->Status = Status;
|
||||||
Bucket->Information = 0;
|
Bucket->Information = 0;
|
||||||
|
|
||||||
DbgPrint("[IP, TCPAcceptEventHandler] Associated with: 0x%x\n",
|
|
||||||
Bucket->AssociatedEndpoint->SocketContext);
|
|
||||||
|
|
||||||
DbgPrint("[IP, TCPAcceptEventHandler] Completing accept event %x\n", Status);
|
DbgPrint("[IP, TCPAcceptEventHandler] Completing accept event %x\n", Status);
|
||||||
|
|
||||||
if (Status == STATUS_SUCCESS)
|
if (Status == STATUS_SUCCESS)
|
||||||
|
@ -194,7 +193,6 @@ TCPAcceptEventHandler(void *arg, struct tcp_pcb *newpcb)
|
||||||
LockObject(Bucket->AssociatedEndpoint, &OldIrql);
|
LockObject(Bucket->AssociatedEndpoint, &OldIrql);
|
||||||
|
|
||||||
/* free previously created socket context (we don't use it, we use newpcb) */
|
/* free previously created socket context (we don't use it, we use newpcb) */
|
||||||
//LibTCPClose(Bucket->AssociatedEndpoint->SocketContext);
|
|
||||||
OldSocketContext = Bucket->AssociatedEndpoint->SocketContext;
|
OldSocketContext = Bucket->AssociatedEndpoint->SocketContext;
|
||||||
Bucket->AssociatedEndpoint->SocketContext = newpcb;
|
Bucket->AssociatedEndpoint->SocketContext = newpcb;
|
||||||
|
|
||||||
|
|
|
@ -81,11 +81,11 @@ NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
||||||
LockObject(Connection, &OldIrql);
|
LockObject(Connection, &OldIrql);
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("[IP, TCPSocket] Called: Connection %x, Family %d, Type %d, "
|
TI_DbgPrint(DEBUG_TCP,("[IP, TCPSocket] Called: Connection %x, Family %d, Type %d, "
|
||||||
"Proto %d\n",
|
"Proto %d, sizeof(CONNECTION_ENDPOINT) = %d\n",
|
||||||
Connection, Family, Type, Proto));
|
Connection, Family, Type, Proto, sizeof(CONNECTION_ENDPOINT)));
|
||||||
DbgPrint("[IP, TCPSocket] Called: Connection %x, Family %d, Type %d, "
|
DbgPrint("[IP, TCPSocket] Called: Connection 0x%x, Family %d, Type %d, "
|
||||||
"Proto %d\n",
|
"Proto %d, sizeof(CONNECTION_ENDPOINT) = %d\n",
|
||||||
Connection, Family, Type, Proto);
|
Connection, Family, Type, Proto, sizeof(CONNECTION_ENDPOINT));
|
||||||
|
|
||||||
Connection->SocketContext = LibTCPSocket(Connection);
|
Connection->SocketContext = LibTCPSocket(Connection);
|
||||||
if (Connection->SocketContext)
|
if (Connection->SocketContext)
|
||||||
|
@ -93,6 +93,8 @@ NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
||||||
else
|
else
|
||||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
|
DbgPrint("[IP, TCPSocket] Connection->SocketContext = 0x%x\n", Connection->SocketContext);
|
||||||
|
|
||||||
UnlockObject(Connection, OldIrql);
|
UnlockObject(Connection, OldIrql);
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_TCP,("[IP, TCPSocket] Leaving. Status = 0x%x\n", Status));
|
TI_DbgPrint(DEBUG_TCP,("[IP, TCPSocket] Leaving. Status = 0x%x\n", Status));
|
||||||
|
@ -101,6 +103,37 @@ NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
||||||
return Status;
|
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)
|
VOID TCPReceive(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Receives and queues TCP data
|
* FUNCTION: Receives and queues TCP data
|
||||||
|
@ -333,34 +366,6 @@ NTSTATUS TCPDisconnect
|
||||||
return Status;
|
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
|
NTSTATUS TCPReceiveData
|
||||||
( PCONNECTION_ENDPOINT Connection,
|
( PCONNECTION_ENDPOINT Connection,
|
||||||
PNDIS_BUFFER Buffer,
|
PNDIS_BUFFER Buffer,
|
||||||
|
|
|
@ -252,6 +252,8 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||||
IP_STATS_INC(ip.recv);
|
IP_STATS_INC(ip.recv);
|
||||||
snmp_inc_ipinreceives();
|
snmp_inc_ipinreceives();
|
||||||
|
|
||||||
|
DbgPrint("ip_input: called\n");
|
||||||
|
|
||||||
/* identify the IP header */
|
/* identify the IP header */
|
||||||
iphdr = (struct ip_hdr *)p->payload;
|
iphdr = (struct ip_hdr *)p->payload;
|
||||||
if (IPH_V(iphdr) != 4) {
|
if (IPH_V(iphdr) != 4) {
|
||||||
|
@ -488,7 +490,7 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||||
if (raw_input(p, inp) == 0)
|
if (raw_input(p, inp) == 0)
|
||||||
#endif /* LWIP_RAW */
|
#endif /* LWIP_RAW */
|
||||||
{
|
{
|
||||||
|
DbgPrint("ip_input: choosing protocol\n");
|
||||||
switch (IPH_PROTO(iphdr)) {
|
switch (IPH_PROTO(iphdr)) {
|
||||||
#if LWIP_UDP
|
#if LWIP_UDP
|
||||||
case IP_PROTO_UDP:
|
case IP_PROTO_UDP:
|
||||||
|
@ -502,6 +504,7 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||||
#if LWIP_TCP
|
#if LWIP_TCP
|
||||||
case IP_PROTO_TCP:
|
case IP_PROTO_TCP:
|
||||||
snmp_inc_ipindelivers();
|
snmp_inc_ipindelivers();
|
||||||
|
DbgPrint("ip_input: sending data to tcp_input\n");
|
||||||
tcp_input(p, inp);
|
tcp_input(p, inp);
|
||||||
break;
|
break;
|
||||||
#endif /* LWIP_TCP */
|
#endif /* LWIP_TCP */
|
||||||
|
|
|
@ -139,7 +139,7 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
|
||||||
{
|
{
|
||||||
err_t err;
|
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 (rst_on_unacked_data && (pcb->state != LISTEN)) {
|
||||||
if ((pcb->refused_data != NULL) || (pcb->rcv_wnd != TCP_WND)) {
|
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;
|
break;
|
||||||
case LISTEN:
|
case LISTEN:
|
||||||
err = ERR_OK;
|
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);
|
tcp_pcb_remove(&tcp_listen_pcbs.pcbs, pcb);
|
||||||
memp_free(MEMP_TCP_PCB_LISTEN, pcb);
|
memp_free(MEMP_TCP_PCB_LISTEN, pcb);
|
||||||
pcb = NULL;
|
pcb = NULL;
|
||||||
|
@ -487,6 +488,8 @@ tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog)
|
||||||
|
|
||||||
LWIP_UNUSED_ARG(backlog);
|
LWIP_UNUSED_ARG(backlog);
|
||||||
LWIP_ERROR("tcp_listen: pcb already connected", pcb->state == CLOSED, return NULL);
|
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? */
|
/* already listening? */
|
||||||
if (pcb->state == LISTEN) {
|
if (pcb->state == LISTEN) {
|
||||||
|
|
|
@ -108,8 +108,6 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
||||||
iphdr = (struct ip_hdr *)p->payload;
|
iphdr = (struct ip_hdr *)p->payload;
|
||||||
tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4);
|
tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4);
|
||||||
|
|
||||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_input: called\n"));
|
|
||||||
|
|
||||||
#if TCP_INPUT_DEBUG
|
#if TCP_INPUT_DEBUG
|
||||||
tcp_debug_print(tcphdr);
|
tcp_debug_print(tcphdr);
|
||||||
#endif
|
#endif
|
||||||
|
@ -177,22 +175,25 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
||||||
flags = TCPH_FLAGS(tcphdr);
|
flags = TCPH_FLAGS(tcphdr);
|
||||||
tcplen = p->tot_len + ((flags & (TCP_FIN | TCP_SYN)) ? 1 : 0);
|
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
|
/* Demultiplex an incoming segment. First, we check if it is destined
|
||||||
for an active connection. */
|
for an active connection. */
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
|
|
||||||
|
|
||||||
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next)
|
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 != CLOSED", pcb->state != CLOSED);
|
||||||
LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT);
|
LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT);
|
||||||
LWIP_ASSERT("tcp_input: active pcb->state != LISTEN", pcb->state != LISTEN);
|
LWIP_ASSERT("tcp_input: active pcb->state != LISTEN", pcb->state != LISTEN);
|
||||||
|
|
||||||
if (pcb->remote_port == tcphdr->src &&
|
if (pcb->remote_port == tcphdr->src &&
|
||||||
pcb->local_port == tcphdr->dest &&
|
pcb->local_port == tcphdr->dest &&
|
||||||
ip_addr_cmp(&(pcb->remote_ip), ¤t_iphdr_src) &&
|
ip_addr_cmp(&(pcb->remote_ip), ¤t_iphdr_src) &&
|
||||||
ip_addr_cmp(&(pcb->local_ip), ¤t_iphdr_dest))
|
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
|
/* Move this PCB to the front of the list so that subsequent
|
||||||
lookups will be faster (we exploit locality in TCP segment
|
lookups will be faster (we exploit locality in TCP segment
|
||||||
arrivals). */
|
arrivals). */
|
||||||
|
@ -909,6 +910,8 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||||
u16_t new_tot_len;
|
u16_t new_tot_len;
|
||||||
int found_dupack = 0;
|
int found_dupack = 0;
|
||||||
|
|
||||||
|
LWIP_DEBUGF(TCP_DEBUG, ("tcp_receive: called\n"));
|
||||||
|
|
||||||
if (flags & TCP_ACK) {
|
if (flags & TCP_ACK) {
|
||||||
right_wnd_edge = pcb->snd_wnd + pcb->snd_wl2;
|
right_wnd_edge = pcb->snd_wnd + pcb->snd_wl2;
|
||||||
|
|
||||||
|
@ -1534,6 +1537,8 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||||
tcp_ack_now(pcb);
|
tcp_ack_now(pcb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LWIP_DEBUGF(TCP_DEBUG, ("tcp_receive: done\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -128,7 +128,7 @@ static
|
||||||
err_t
|
err_t
|
||||||
InternalAcceptEventHandler(void *arg, struct tcp_pcb *newpcb, err_t err)
|
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);
|
arg, newpcb, (unsigned int)err);
|
||||||
|
|
||||||
/* Make sure the socket didn't get closed */
|
/* Make sure the socket didn't get closed */
|
||||||
|
@ -198,8 +198,12 @@ LibTCPSocketCallback(void *arg)
|
||||||
|
|
||||||
ASSERT(msg);
|
ASSERT(msg);
|
||||||
|
|
||||||
|
DbgPrint("[lwIP, LibTCPSocketCallback] Called\n");
|
||||||
|
|
||||||
msg->NewPcb = tcp_new();
|
msg->NewPcb = tcp_new();
|
||||||
|
|
||||||
|
DbgPrint("[lwIP, LibTCPSocketCallback] Assigned new pcb = 0x%x\n", msg->NewPcb);
|
||||||
|
|
||||||
if (msg->NewPcb)
|
if (msg->NewPcb)
|
||||||
{
|
{
|
||||||
tcp_arg((struct tcp_pcb*)msg->NewPcb, msg->Arg);
|
tcp_arg((struct tcp_pcb*)msg->NewPcb, msg->Arg);
|
||||||
|
@ -215,6 +219,8 @@ LibTCPSocket(void *arg)
|
||||||
struct socket_callback_msg *msg = ExAllocatePool(NonPagedPool, sizeof(struct socket_callback_msg));
|
struct socket_callback_msg *msg = ExAllocatePool(NonPagedPool, sizeof(struct socket_callback_msg));
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|
||||||
|
DbgPrint("[lwIP, LibTCPSocket] Called\n");
|
||||||
|
|
||||||
if (msg)
|
if (msg)
|
||||||
{
|
{
|
||||||
KeInitializeEvent(&msg->Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&msg->Event, NotificationEvent, FALSE);
|
||||||
|
@ -227,13 +233,17 @@ LibTCPSocket(void *arg)
|
||||||
else
|
else
|
||||||
ret = NULL;
|
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);
|
ExFreePool(msg);
|
||||||
|
|
||||||
return (struct tcp_pcb*)ret;
|
return (struct tcp_pcb*)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DbgPrint("[lwIP, LibTCPSocket] Done\n");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +357,7 @@ LibTCPListen(struct tcp_pcb *pcb, u8_t backlog)
|
||||||
struct listen_callback_msg *msg;
|
struct listen_callback_msg *msg;
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|
||||||
DbgPrint("[lwIP, LibTCPListen] Called\n");
|
DbgPrint("[lwIP, LibTCPListen] Called on pcb = 0x%x\n", pcb);
|
||||||
|
|
||||||
if (!pcb)
|
if (!pcb)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -366,7 +376,8 @@ LibTCPListen(struct tcp_pcb *pcb, u8_t backlog)
|
||||||
else
|
else
|
||||||
ret = NULL;
|
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");
|
DbgPrint("[lwIP, LibTCPListen] Done\n");
|
||||||
|
|
||||||
|
@ -617,7 +628,7 @@ LibTCPClose(struct tcp_pcb *pcb)
|
||||||
struct close_callback_msg *msg;
|
struct close_callback_msg *msg;
|
||||||
err_t ret;
|
err_t ret;
|
||||||
|
|
||||||
DbgPrint("[lwIP, LibTCPClose] Called\n");
|
DbgPrint("[lwIP, LibTCPClose] Called on pcb = 0x%x\n", pcb);
|
||||||
|
|
||||||
if (!pcb)
|
if (!pcb)
|
||||||
{
|
{
|
||||||
|
@ -627,6 +638,8 @@ LibTCPClose(struct tcp_pcb *pcb)
|
||||||
|
|
||||||
DbgPrint("[lwIP, LibTCPClose] Removing pcb callbacks\n");
|
DbgPrint("[lwIP, LibTCPClose] Removing pcb callbacks\n");
|
||||||
|
|
||||||
|
DbgPrint("[lwIP, LibTCPClose] pcb->state = %s\n", tcp_state_str[pcb->state]);
|
||||||
|
|
||||||
tcp_arg(pcb, NULL);
|
tcp_arg(pcb, NULL);
|
||||||
tcp_recv(pcb, NULL);
|
tcp_recv(pcb, NULL);
|
||||||
tcp_sent(pcb, NULL);
|
tcp_sent(pcb, NULL);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue