mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
Reformat. No changes (yet). Preemptive strike.
svn path=/trunk/; revision=39686
This commit is contained in:
parent
16df5c0cb7
commit
6de6188c1a
1 changed files with 239 additions and 239 deletions
|
@ -22,7 +22,7 @@ RECURSIVE_MUTEX TCPLock;
|
|||
PORT_SET TCPPorts;
|
||||
|
||||
static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
|
||||
ULONG NewState ) {
|
||||
ULONG NewState ) {
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PTCP_COMPLETION_ROUTINE Complete;
|
||||
PTDI_BUCKET Bucket;
|
||||
|
@ -35,7 +35,7 @@ static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
|
|||
|
||||
/* Things that can happen when we try the initial connection */
|
||||
if( NewState & SEL_CONNECT ) {
|
||||
while( !IsListEmpty( &Connection->ConnectRequest ) ) {
|
||||
while( !IsListEmpty( &Connection->ConnectRequest ) ) {
|
||||
Entry = RemoveHeadList( &Connection->ConnectRequest );
|
||||
TI_DbgPrint(DEBUG_TCP, ("Connect Event\n"));
|
||||
|
||||
|
@ -58,162 +58,162 @@ static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
|
|||
}
|
||||
|
||||
if( NewState & SEL_ACCEPT ) {
|
||||
/* Handle readable on a listening socket --
|
||||
* TODO: Implement filtering
|
||||
*/
|
||||
/* Handle readable on a listening socket --
|
||||
* TODO: Implement filtering
|
||||
*/
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("Accepting new connection on %x (Queue: %s)\n",
|
||||
Connection,
|
||||
IsListEmpty(&Connection->ListenRequest) ?
|
||||
"empty" : "nonempty"));
|
||||
TI_DbgPrint(DEBUG_TCP,("Accepting new connection on %x (Queue: %s)\n",
|
||||
Connection,
|
||||
IsListEmpty(&Connection->ListenRequest) ?
|
||||
"empty" : "nonempty"));
|
||||
|
||||
while( !IsListEmpty( &Connection->ListenRequest ) ) {
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
while( !IsListEmpty( &Connection->ListenRequest ) ) {
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
|
||||
Entry = RemoveHeadList( &Connection->ListenRequest );
|
||||
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
|
||||
Complete = Bucket->Request.RequestNotifyObject;
|
||||
Entry = RemoveHeadList( &Connection->ListenRequest );
|
||||
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
|
||||
Complete = Bucket->Request.RequestNotifyObject;
|
||||
|
||||
Irp = Bucket->Request.RequestContext;
|
||||
IrpSp = IoGetCurrentIrpStackLocation( Irp );
|
||||
Irp = Bucket->Request.RequestContext;
|
||||
IrpSp = IoGetCurrentIrpStackLocation( Irp );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("Getting the socket\n"));
|
||||
Status = TCPServiceListeningSocket
|
||||
( Connection->AddressFile->Listener,
|
||||
Bucket->AssociatedEndpoint,
|
||||
(PTDI_REQUEST_KERNEL)&IrpSp->Parameters );
|
||||
TI_DbgPrint(DEBUG_TCP,("Getting the socket\n"));
|
||||
Status = TCPServiceListeningSocket
|
||||
( Connection->AddressFile->Listener,
|
||||
Bucket->AssociatedEndpoint,
|
||||
(PTDI_REQUEST_KERNEL)&IrpSp->Parameters );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("Socket: Status: %x\n"));
|
||||
TI_DbgPrint(DEBUG_TCP,("Socket: Status: %x\n"));
|
||||
|
||||
if( Status == STATUS_PENDING ) {
|
||||
InsertHeadList( &Connection->ListenRequest, &Bucket->Entry );
|
||||
break;
|
||||
} else {
|
||||
Complete( Bucket->Request.RequestContext, Status, 0 );
|
||||
exFreePool( Bucket );
|
||||
}
|
||||
}
|
||||
if( Status == STATUS_PENDING ) {
|
||||
InsertHeadList( &Connection->ListenRequest, &Bucket->Entry );
|
||||
break;
|
||||
} else {
|
||||
Complete( Bucket->Request.RequestContext, Status, 0 );
|
||||
exFreePool( Bucket );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Things that happen after we're connected */
|
||||
if( NewState & SEL_READ ) {
|
||||
TI_DbgPrint(DEBUG_TCP,("Readable: irp list %s\n",
|
||||
IsListEmpty(&Connection->ReceiveRequest) ?
|
||||
"empty" : "nonempty"));
|
||||
TI_DbgPrint(DEBUG_TCP,("Readable: irp list %s\n",
|
||||
IsListEmpty(&Connection->ReceiveRequest) ?
|
||||
"empty" : "nonempty"));
|
||||
|
||||
while( !IsListEmpty( &Connection->ReceiveRequest ) ) {
|
||||
OSK_UINT RecvLen = 0, Received = 0;
|
||||
OSK_PCHAR RecvBuffer = 0;
|
||||
while( !IsListEmpty( &Connection->ReceiveRequest ) ) {
|
||||
OSK_UINT RecvLen = 0, Received = 0;
|
||||
OSK_PCHAR RecvBuffer = 0;
|
||||
|
||||
Entry = RemoveHeadList( &Connection->ReceiveRequest );
|
||||
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
|
||||
Complete = Bucket->Request.RequestNotifyObject;
|
||||
Entry = RemoveHeadList( &Connection->ReceiveRequest );
|
||||
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
|
||||
Complete = Bucket->Request.RequestNotifyObject;
|
||||
|
||||
Irp = Bucket->Request.RequestContext;
|
||||
Mdl = Irp->MdlAddress;
|
||||
Irp = Bucket->Request.RequestContext;
|
||||
Mdl = Irp->MdlAddress;
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Getting the user buffer from %x\n", Mdl));
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Getting the user buffer from %x\n", Mdl));
|
||||
|
||||
NdisQueryBuffer( Mdl, &RecvBuffer, &RecvLen );
|
||||
NdisQueryBuffer( Mdl, &RecvBuffer, &RecvLen );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Reading %d bytes to %x\n", RecvLen, RecvBuffer));
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Reading %d bytes to %x\n", RecvLen, RecvBuffer));
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP, ("Connection: %x\n", Connection));
|
||||
TI_DbgPrint
|
||||
(DEBUG_TCP,
|
||||
("Connection->SocketContext: %x\n",
|
||||
Connection->SocketContext));
|
||||
TI_DbgPrint(DEBUG_TCP, ("RecvBuffer: %x\n", RecvBuffer));
|
||||
TI_DbgPrint(DEBUG_TCP, ("Connection: %x\n", Connection));
|
||||
TI_DbgPrint
|
||||
(DEBUG_TCP,
|
||||
("Connection->SocketContext: %x\n",
|
||||
Connection->SocketContext));
|
||||
TI_DbgPrint(DEBUG_TCP, ("RecvBuffer: %x\n", RecvBuffer));
|
||||
|
||||
Status = TCPTranslateError
|
||||
( OskitTCPRecv( Connection->SocketContext,
|
||||
RecvBuffer,
|
||||
RecvLen,
|
||||
&Received,
|
||||
0 ) );
|
||||
Status = TCPTranslateError
|
||||
( OskitTCPRecv( Connection->SocketContext,
|
||||
RecvBuffer,
|
||||
RecvLen,
|
||||
&Received,
|
||||
0 ) );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("TCP Bytes: %d\n", Received));
|
||||
TI_DbgPrint(DEBUG_TCP,("TCP Bytes: %d\n", Received));
|
||||
|
||||
if( Status == STATUS_SUCCESS ) {
|
||||
TI_DbgPrint(DEBUG_TCP,("Received %d bytes with status %x\n",
|
||||
Received, Status));
|
||||
if( Status == STATUS_SUCCESS ) {
|
||||
TI_DbgPrint(DEBUG_TCP,("Received %d bytes with status %x\n",
|
||||
Received, Status));
|
||||
|
||||
Complete( Bucket->Request.RequestContext,
|
||||
STATUS_SUCCESS, Received );
|
||||
exFreePool( Bucket );
|
||||
} else if( Status == STATUS_PENDING ) {
|
||||
InsertHeadList
|
||||
( &Connection->ReceiveRequest, &Bucket->Entry );
|
||||
break;
|
||||
} else {
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Completing Receive request: %x %x\n",
|
||||
Bucket->Request, Status));
|
||||
Complete( Bucket->Request.RequestContext, Status, 0 );
|
||||
exFreePool( Bucket );
|
||||
}
|
||||
}
|
||||
Complete( Bucket->Request.RequestContext,
|
||||
STATUS_SUCCESS, Received );
|
||||
exFreePool( Bucket );
|
||||
} else if( Status == STATUS_PENDING ) {
|
||||
InsertHeadList
|
||||
( &Connection->ReceiveRequest, &Bucket->Entry );
|
||||
break;
|
||||
} else {
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Completing Receive request: %x %x\n",
|
||||
Bucket->Request, Status));
|
||||
Complete( Bucket->Request.RequestContext, Status, 0 );
|
||||
exFreePool( Bucket );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( NewState & SEL_WRITE ) {
|
||||
TI_DbgPrint(DEBUG_TCP,("Writeable: irp list %s\n",
|
||||
IsListEmpty(&Connection->ReceiveRequest) ?
|
||||
"empty" : "nonempty"));
|
||||
TI_DbgPrint(DEBUG_TCP,("Writeable: irp list %s\n",
|
||||
IsListEmpty(&Connection->ReceiveRequest) ?
|
||||
"empty" : "nonempty"));
|
||||
|
||||
while( !IsListEmpty( &Connection->SendRequest ) ) {
|
||||
OSK_UINT SendLen = 0, Sent = 0;
|
||||
OSK_PCHAR SendBuffer = 0;
|
||||
while( !IsListEmpty( &Connection->SendRequest ) ) {
|
||||
OSK_UINT SendLen = 0, Sent = 0;
|
||||
OSK_PCHAR SendBuffer = 0;
|
||||
|
||||
Entry = RemoveHeadList( &Connection->SendRequest );
|
||||
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
|
||||
Complete = Bucket->Request.RequestNotifyObject;
|
||||
Entry = RemoveHeadList( &Connection->SendRequest );
|
||||
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
|
||||
Complete = Bucket->Request.RequestNotifyObject;
|
||||
|
||||
Irp = Bucket->Request.RequestContext;
|
||||
Mdl = Irp->MdlAddress;
|
||||
Irp = Bucket->Request.RequestContext;
|
||||
Mdl = Irp->MdlAddress;
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Getting the user buffer from %x\n", Mdl));
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Getting the user buffer from %x\n", Mdl));
|
||||
|
||||
NdisQueryBuffer( Mdl, &SendBuffer, &SendLen );
|
||||
NdisQueryBuffer( Mdl, &SendBuffer, &SendLen );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Writing %d bytes to %x\n", SendLen, SendBuffer));
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Writing %d bytes to %x\n", SendLen, SendBuffer));
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP, ("Connection: %x\n", Connection));
|
||||
TI_DbgPrint
|
||||
(DEBUG_TCP,
|
||||
("Connection->SocketContext: %x\n",
|
||||
Connection->SocketContext));
|
||||
TI_DbgPrint(DEBUG_TCP, ("Connection: %x\n", Connection));
|
||||
TI_DbgPrint
|
||||
(DEBUG_TCP,
|
||||
("Connection->SocketContext: %x\n",
|
||||
Connection->SocketContext));
|
||||
|
||||
Status = TCPTranslateError
|
||||
( OskitTCPSend( Connection->SocketContext,
|
||||
SendBuffer,
|
||||
SendLen,
|
||||
&Sent,
|
||||
0 ) );
|
||||
Status = TCPTranslateError
|
||||
( OskitTCPSend( Connection->SocketContext,
|
||||
SendBuffer,
|
||||
SendLen,
|
||||
&Sent,
|
||||
0 ) );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("TCP Bytes: %d\n", Sent));
|
||||
TI_DbgPrint(DEBUG_TCP,("TCP Bytes: %d\n", Sent));
|
||||
|
||||
if( Status == STATUS_SUCCESS ) {
|
||||
TI_DbgPrint(DEBUG_TCP,("Sent %d bytes with status %x\n",
|
||||
Sent, Status));
|
||||
if( Status == STATUS_SUCCESS ) {
|
||||
TI_DbgPrint(DEBUG_TCP,("Sent %d bytes with status %x\n",
|
||||
Sent, Status));
|
||||
|
||||
Complete( Bucket->Request.RequestContext,
|
||||
STATUS_SUCCESS, Sent );
|
||||
exFreePool( Bucket );
|
||||
} else if( Status == STATUS_PENDING ) {
|
||||
InsertHeadList
|
||||
( &Connection->SendRequest, &Bucket->Entry );
|
||||
break;
|
||||
} else {
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Completing Send request: %x %x\n",
|
||||
Bucket->Request, Status));
|
||||
Complete( Bucket->Request.RequestContext, Status, 0 );
|
||||
exFreePool( Bucket );
|
||||
}
|
||||
}
|
||||
Complete( Bucket->Request.RequestContext,
|
||||
STATUS_SUCCESS, Sent );
|
||||
exFreePool( Bucket );
|
||||
} else if( Status == STATUS_PENDING ) {
|
||||
InsertHeadList
|
||||
( &Connection->SendRequest, &Bucket->Entry );
|
||||
break;
|
||||
} else {
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Completing Send request: %x %x\n",
|
||||
Bucket->Request, Status));
|
||||
Complete( Bucket->Request.RequestContext, Status, 0 );
|
||||
exFreePool( Bucket );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( NewState & SEL_FIN ) {
|
||||
|
@ -221,7 +221,7 @@ static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
|
|||
NTSTATUS IrpStatus[4];
|
||||
UINT i;
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
|
||||
TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
|
||||
|
||||
ListsToErase[0] = &Connection->ReceiveRequest;
|
||||
IrpStatus [0] = STATUS_SUCCESS;
|
||||
|
@ -230,7 +230,7 @@ static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
|
|||
ListsToErase[2] = &Connection->ConnectRequest;
|
||||
IrpStatus [2] = STATUS_UNSUCCESSFUL;
|
||||
ListsToErase[3] = 0;
|
||||
IrpStatus [3] = 0;
|
||||
IrpStatus [3] = 0;
|
||||
|
||||
for( i = 0; ListsToErase[i]; i++ ) {
|
||||
while( !IsListEmpty( ListsToErase[i] ) ) {
|
||||
|
@ -238,7 +238,7 @@ static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
|
|||
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
|
||||
Complete = Bucket->Request.RequestNotifyObject;
|
||||
Complete( Bucket->Request.RequestContext, IrpStatus[i], 0 );
|
||||
exFreePool( Bucket );
|
||||
exFreePool( Bucket );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -251,18 +251,18 @@ VOID DrainSignals() {
|
|||
PLIST_ENTRY ListEntry;
|
||||
|
||||
while( !IsListEmpty( &SignalledConnections ) ) {
|
||||
ListEntry = RemoveHeadList( &SignalledConnections );
|
||||
Connection = CONTAINING_RECORD( ListEntry, CONNECTION_ENDPOINT,
|
||||
SignalList );
|
||||
HandleSignalledConnection( Connection, Connection->SignalState );
|
||||
ListEntry = RemoveHeadList( &SignalledConnections );
|
||||
Connection = CONTAINING_RECORD( ListEntry, CONNECTION_ENDPOINT,
|
||||
SignalList );
|
||||
HandleSignalledConnection( Connection, Connection->SignalState );
|
||||
}
|
||||
}
|
||||
|
||||
PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint( PVOID ClientContext ) {
|
||||
PCONNECTION_ENDPOINT Connection =
|
||||
exAllocatePool(NonPagedPool, sizeof(CONNECTION_ENDPOINT));
|
||||
exAllocatePool(NonPagedPool, sizeof(CONNECTION_ENDPOINT));
|
||||
if (!Connection)
|
||||
return Connection;
|
||||
return Connection;
|
||||
|
||||
TI_DbgPrint(DEBUG_CPOINT, ("Connection point file object allocated at (0x%X).\n", Connection));
|
||||
|
||||
|
@ -287,24 +287,24 @@ VOID TCPFreeConnectionEndpoint( PCONNECTION_ENDPOINT Connection ) {
|
|||
}
|
||||
|
||||
NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
||||
UINT Family, UINT Type, UINT Proto ) {
|
||||
UINT Family, UINT Type, UINT Proto ) {
|
||||
NTSTATUS Status;
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("Called: Connection %x, Family %d, Type %d, "
|
||||
"Proto %d\n",
|
||||
Connection, Family, Type, Proto));
|
||||
"Proto %d\n",
|
||||
Connection, Family, Type, Proto));
|
||||
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
Status = TCPTranslateError( OskitTCPSocket( Connection,
|
||||
&Connection->SocketContext,
|
||||
Family,
|
||||
Type,
|
||||
Proto ) );
|
||||
&Connection->SocketContext,
|
||||
Family,
|
||||
Type,
|
||||
Proto ) );
|
||||
|
||||
ASSERT_KM_POINTER(Connection->SocketContext);
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext %x\n",
|
||||
Connection->SocketContext));
|
||||
Connection->SocketContext));
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
|
@ -321,14 +321,14 @@ VOID TCPReceive(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
|
|||
*/
|
||||
{
|
||||
TI_DbgPrint(DEBUG_TCP,("Sending packet %d (%d) to oskit\n",
|
||||
IPPacket->TotalSize,
|
||||
IPPacket->HeaderSize));
|
||||
IPPacket->TotalSize,
|
||||
IPPacket->HeaderSize));
|
||||
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
|
||||
OskitTCPReceiveDatagram( IPPacket->Header,
|
||||
IPPacket->TotalSize,
|
||||
IPPacket->HeaderSize );
|
||||
IPPacket->TotalSize,
|
||||
IPPacket->HeaderSize );
|
||||
|
||||
DrainSignals();
|
||||
|
||||
|
@ -337,28 +337,28 @@ VOID TCPReceive(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
|
|||
|
||||
/* event.c */
|
||||
int TCPSocketState( void *ClientData,
|
||||
void *WhichSocket,
|
||||
void *WhichConnection,
|
||||
OSK_UINT NewState );
|
||||
void *WhichSocket,
|
||||
void *WhichConnection,
|
||||
OSK_UINT NewState );
|
||||
|
||||
int TCPPacketSend( void *ClientData,
|
||||
OSK_PCHAR Data,
|
||||
OSK_UINT Len );
|
||||
OSK_PCHAR Data,
|
||||
OSK_UINT Len );
|
||||
|
||||
POSK_IFADDR TCPFindInterface( void *ClientData,
|
||||
OSK_UINT AddrType,
|
||||
OSK_UINT FindType,
|
||||
OSK_SOCKADDR *ReqAddr );
|
||||
OSK_UINT AddrType,
|
||||
OSK_UINT FindType,
|
||||
OSK_SOCKADDR *ReqAddr );
|
||||
|
||||
NTSTATUS TCPMemStartup( void );
|
||||
void *TCPMalloc( void *ClientData,
|
||||
OSK_UINT bytes, OSK_PCHAR file, OSK_UINT line );
|
||||
OSK_UINT bytes, OSK_PCHAR file, OSK_UINT line );
|
||||
void TCPFree( void *ClientData,
|
||||
void *data, OSK_PCHAR file, OSK_UINT line );
|
||||
void *data, OSK_PCHAR file, OSK_UINT line );
|
||||
void TCPMemShutdown( void );
|
||||
|
||||
int TCPSleep( void *ClientData, void *token, int priority, char *msg,
|
||||
int tmio );
|
||||
int tmio );
|
||||
|
||||
void TCPWakeup( void *ClientData, void *token );
|
||||
|
||||
|
@ -449,13 +449,13 @@ NTSTATUS TCPStartup(VOID)
|
|||
InitializeListHead( &SignalledConnections );
|
||||
Status = TCPMemStartup();
|
||||
if ( ! NT_SUCCESS(Status) ) {
|
||||
return Status;
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = PortsStartup( &TCPPorts, 1, 0xfffe );
|
||||
if( !NT_SUCCESS(Status) ) {
|
||||
TCPMemShutdown();
|
||||
return Status;
|
||||
TCPMemShutdown();
|
||||
return Status;
|
||||
}
|
||||
|
||||
RegisterOskitTCPEventHandlers( &EventHandlers );
|
||||
|
@ -465,13 +465,13 @@ NTSTATUS TCPStartup(VOID)
|
|||
IPRegisterProtocol(IPPROTO_TCP, TCPReceive);
|
||||
|
||||
ExInitializeNPagedLookasideList(
|
||||
&TCPSegmentList, /* Lookaside list */
|
||||
NULL, /* Allocate routine */
|
||||
NULL, /* Free routine */
|
||||
0, /* Flags */
|
||||
sizeof(TCP_SEGMENT), /* Size of each entry */
|
||||
TAG('T','C','P','S'), /* Tag */
|
||||
0); /* Depth */
|
||||
&TCPSegmentList, /* Lookaside list */
|
||||
NULL, /* Allocate routine */
|
||||
NULL, /* Free routine */
|
||||
0, /* Flags */
|
||||
sizeof(TCP_SEGMENT), /* Size of each entry */
|
||||
TAG('T','C','P','S'), /* Tag */
|
||||
0); /* Depth */
|
||||
|
||||
StartTimer();
|
||||
|
||||
|
@ -491,7 +491,7 @@ NTSTATUS TCPShutdown(VOID)
|
|||
LARGE_INTEGER WaitForThread;
|
||||
|
||||
if (!TCPInitialized)
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
WaitForThread.QuadPart = -2500000; /* 250 ms */
|
||||
KeSetEvent(&TimerLoopEvent, IO_NO_INCREMENT, FALSE);
|
||||
|
@ -557,9 +557,9 @@ NTSTATUS TCPConnect
|
|||
InsertHeadList( &Connection->ConnectRequest, &Bucket->Entry );
|
||||
|
||||
Status = AddrBuildAddress
|
||||
((PTRANSPORT_ADDRESS)ConnInfo->RemoteAddress,
|
||||
&RemoteAddress,
|
||||
&RemotePort);
|
||||
((PTRANSPORT_ADDRESS)ConnInfo->RemoteAddress,
|
||||
&RemoteAddress,
|
||||
&RemotePort);
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,
|
||||
("Connecting to address %x:%x\n",
|
||||
|
@ -567,9 +567,9 @@ NTSTATUS TCPConnect
|
|||
RemotePort));
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
TI_DbgPrint(DEBUG_TCP, ("Could not AddrBuildAddress in TCPConnect\n"));
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
return Status;
|
||||
TI_DbgPrint(DEBUG_TCP, ("Could not AddrBuildAddress in TCPConnect\n"));
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
return Status;
|
||||
}
|
||||
|
||||
AddressToConnect.sin_family = AF_INET;
|
||||
|
@ -577,21 +577,21 @@ NTSTATUS TCPConnect
|
|||
|
||||
Status = TCPTranslateError
|
||||
( OskitTCPBind( Connection->SocketContext,
|
||||
Connection,
|
||||
&AddressToBind,
|
||||
sizeof(AddressToBind) ) );
|
||||
Connection,
|
||||
&AddressToBind,
|
||||
sizeof(AddressToBind) ) );
|
||||
|
||||
if (NT_SUCCESS(Status)) {
|
||||
memcpy( &AddressToConnect.sin_addr,
|
||||
&RemoteAddress.Address.IPv4Address,
|
||||
sizeof(AddressToConnect.sin_addr) );
|
||||
&RemoteAddress.Address.IPv4Address,
|
||||
sizeof(AddressToConnect.sin_addr) );
|
||||
AddressToConnect.sin_port = RemotePort;
|
||||
|
||||
Status = TCPTranslateError
|
||||
( OskitTCPConnect( Connection->SocketContext,
|
||||
Connection,
|
||||
&AddressToConnect,
|
||||
sizeof(AddressToConnect) ) );
|
||||
( OskitTCPConnect( Connection->SocketContext,
|
||||
Connection,
|
||||
&AddressToConnect,
|
||||
sizeof(AddressToConnect) ) );
|
||||
}
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
@ -615,20 +615,20 @@ NTSTATUS TCPDisconnect
|
|||
switch( Flags & (TDI_DISCONNECT_ABORT | TDI_DISCONNECT_RELEASE) ) {
|
||||
case 0:
|
||||
case TDI_DISCONNECT_ABORT:
|
||||
Flags = 0;
|
||||
break;
|
||||
Flags = 0;
|
||||
break;
|
||||
|
||||
case TDI_DISCONNECT_ABORT | TDI_DISCONNECT_RELEASE:
|
||||
Flags = 2;
|
||||
break;
|
||||
Flags = 2;
|
||||
break;
|
||||
|
||||
case TDI_DISCONNECT_RELEASE:
|
||||
Flags = 1;
|
||||
break;
|
||||
Flags = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
Status = TCPTranslateError
|
||||
( OskitTCPShutdown( Connection->SocketContext, Flags ) );
|
||||
( OskitTCPShutdown( Connection->SocketContext, Flags ) );
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
|
@ -683,35 +683,35 @@ NTSTATUS TCPReceiveData
|
|||
TI_DbgPrint(DEBUG_TCP,("TCP>|< Got an MDL %x (%x:%d)\n", Buffer, DataBuffer, DataLen));
|
||||
|
||||
Status = TCPTranslateError
|
||||
( OskitTCPRecv
|
||||
( Connection->SocketContext,
|
||||
DataBuffer,
|
||||
DataLen,
|
||||
&Received,
|
||||
ReceiveFlags ) );
|
||||
( OskitTCPRecv
|
||||
( Connection->SocketContext,
|
||||
DataBuffer,
|
||||
DataLen,
|
||||
&Received,
|
||||
ReceiveFlags ) );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("OskitTCPReceive: %x, %d\n", Status, Received));
|
||||
|
||||
/* Keep this request around ... there was no data yet */
|
||||
if( Status == STATUS_PENDING ) {
|
||||
/* Freed in TCPSocketState */
|
||||
Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
|
||||
if( !Bucket ) {
|
||||
TI_DbgPrint(DEBUG_TCP,("Failed to allocate bucket\n"));
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
/* Freed in TCPSocketState */
|
||||
Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
|
||||
if( !Bucket ) {
|
||||
TI_DbgPrint(DEBUG_TCP,("Failed to allocate bucket\n"));
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
Bucket->Request.RequestNotifyObject = Complete;
|
||||
Bucket->Request.RequestContext = Context;
|
||||
*BytesReceived = 0;
|
||||
Bucket->Request.RequestNotifyObject = Complete;
|
||||
Bucket->Request.RequestContext = Context;
|
||||
*BytesReceived = 0;
|
||||
|
||||
InsertHeadList( &Connection->ReceiveRequest, &Bucket->Entry );
|
||||
Status = STATUS_PENDING;
|
||||
TI_DbgPrint(DEBUG_TCP,("Queued read irp\n"));
|
||||
InsertHeadList( &Connection->ReceiveRequest, &Bucket->Entry );
|
||||
Status = STATUS_PENDING;
|
||||
TI_DbgPrint(DEBUG_TCP,("Queued read irp\n"));
|
||||
} else {
|
||||
TI_DbgPrint(DEBUG_TCP,("Got status %x, bytes %d\n", Status, Received));
|
||||
*BytesReceived = Received;
|
||||
TI_DbgPrint(DEBUG_TCP,("Got status %x, bytes %d\n", Status, Received));
|
||||
*BytesReceived = Received;
|
||||
}
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
@ -742,34 +742,34 @@ NTSTATUS TCPSendData
|
|||
|
||||
TI_DbgPrint(DEBUG_TCP,("Connection = %x\n", Connection));
|
||||
TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext = %x\n",
|
||||
Connection->SocketContext));
|
||||
Connection->SocketContext));
|
||||
|
||||
Status = TCPTranslateError
|
||||
( OskitTCPSend( Connection->SocketContext,
|
||||
(OSK_PCHAR)BufferData, SendLength,
|
||||
&Sent, 0 ) );
|
||||
( OskitTCPSend( Connection->SocketContext,
|
||||
(OSK_PCHAR)BufferData, SendLength,
|
||||
&Sent, 0 ) );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("OskitTCPSend: %x, %d\n", Status, Sent));
|
||||
|
||||
/* Keep this request around ... there was no data yet */
|
||||
if( Status == STATUS_PENDING ) {
|
||||
/* Freed in TCPSocketState */
|
||||
Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
|
||||
if( !Bucket ) {
|
||||
TI_DbgPrint(DEBUG_TCP,("Failed to allocate bucket\n"));
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
/* Freed in TCPSocketState */
|
||||
Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
|
||||
if( !Bucket ) {
|
||||
TI_DbgPrint(DEBUG_TCP,("Failed to allocate bucket\n"));
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
Bucket->Request.RequestNotifyObject = Complete;
|
||||
Bucket->Request.RequestContext = Context;
|
||||
*BytesSent = 0;
|
||||
Bucket->Request.RequestNotifyObject = Complete;
|
||||
Bucket->Request.RequestContext = Context;
|
||||
*BytesSent = 0;
|
||||
|
||||
InsertHeadList( &Connection->SendRequest, &Bucket->Entry );
|
||||
TI_DbgPrint(DEBUG_TCP,("Queued write irp\n"));
|
||||
InsertHeadList( &Connection->SendRequest, &Bucket->Entry );
|
||||
TI_DbgPrint(DEBUG_TCP,("Queued write irp\n"));
|
||||
} else {
|
||||
TI_DbgPrint(DEBUG_TCP,("Got status %x, bytes %d\n", Status, Sent));
|
||||
*BytesSent = Sent;
|
||||
TI_DbgPrint(DEBUG_TCP,("Got status %x, bytes %d\n", Status, Sent));
|
||||
*BytesSent = Sent;
|
||||
}
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
@ -785,8 +785,8 @@ VOID TCPTimeout(VOID) {
|
|||
|
||||
UINT TCPAllocatePort( UINT HintPort ) {
|
||||
if( HintPort ) {
|
||||
if( AllocatePort( &TCPPorts, HintPort ) ) return HintPort;
|
||||
else {
|
||||
if( AllocatePort( &TCPPorts, HintPort ) ) return HintPort;
|
||||
else {
|
||||
TI_DbgPrint
|
||||
(MID_TRACE,("We got a hint port but couldn't allocate it\n"));
|
||||
return (UINT)-1;
|
||||
|
@ -838,17 +838,17 @@ VOID TCPRemoveIRP( PCONNECTION_ENDPOINT Endpoint, PIRP Irp ) {
|
|||
TcpipAcquireSpinLock( &Endpoint->Lock, &OldIrql );
|
||||
|
||||
for( i = 0; i < 4; i++ ) {
|
||||
for( Entry = ListHead[i]->Flink;
|
||||
Entry != ListHead[i];
|
||||
Entry = Entry->Flink ) {
|
||||
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
|
||||
for( Entry = ListHead[i]->Flink;
|
||||
Entry != ListHead[i];
|
||||
Entry = Entry->Flink ) {
|
||||
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
|
||||
|
||||
if( Bucket->Request.RequestContext == Irp ) {
|
||||
RemoveEntryList( &Bucket->Entry );
|
||||
exFreePool( Bucket );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( Bucket->Request.RequestContext == Irp ) {
|
||||
RemoveEntryList( &Bucket->Entry );
|
||||
exFreePool( Bucket );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TcpipReleaseSpinLock( &Endpoint->Lock, OldIrql );
|
||||
|
|
Loading…
Reference in a new issue