Author: cwittich Date: Sat Jun 27 11:38:02 2009 New Revision: 41635
URL: http://svn.reactos.org/svn/reactos?rev=41635&view=rev Log: tabs -> spaces use more consistent indentation
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/accept.c trunk/reactos/lib/drivers/ip/transport/tcp/event.c trunk/reactos/lib/drivers/ip/transport/tcp/if.c trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/accept.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/tc... ============================================================================== --- trunk/reactos/lib/drivers/ip/transport/tcp/accept.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/tcp/accept.c [iso-8859-1] Sat Jun 27 11:38:02 2009 @@ -11,8 +11,8 @@ #include "precomp.h"
NTSTATUS TCPServiceListeningSocket( PCONNECTION_ENDPOINT Listener, - PCONNECTION_ENDPOINT Connection, - PTDI_REQUEST_KERNEL Request ) { + PCONNECTION_ENDPOINT Connection, + PTDI_REQUEST_KERNEL Request ) { NTSTATUS Status; SOCKADDR_IN OutAddr; OSK_UINT OutAddrLen; @@ -24,37 +24,37 @@ * by WSAAccept -- The returned address will be passed on to * userland after we complete this irp */ WhoIsConnecting = (PTDI_CONNECTION_INFORMATION) - Request->ReturnConnectionInformation; + Request->ReturnConnectionInformation;
Status = TCPTranslateError - ( OskitTCPAccept( Listener->SocketContext, - &Connection->SocketContext, - &OutAddr, - sizeof(OutAddr), - &OutAddrLen, - Request->RequestFlags & TDI_QUERY_ACCEPT ? 0 : 1 ) ); + ( OskitTCPAccept( Listener->SocketContext, + &Connection->SocketContext, + &OutAddr, + sizeof(OutAddr), + &OutAddrLen, + Request->RequestFlags & TDI_QUERY_ACCEPT ? 0 : 1 ) );
TI_DbgPrint(DEBUG_TCP,("Status %x\n", Status));
if( NT_SUCCESS(Status) && Status != STATUS_PENDING ) { - RequestAddressReturn = WhoIsConnecting->RemoteAddress; + RequestAddressReturn = WhoIsConnecting->RemoteAddress;
- TI_DbgPrint(DEBUG_TCP,("Copying address to %x (Who %x)\n", - RequestAddressReturn, WhoIsConnecting)); + TI_DbgPrint(DEBUG_TCP,("Copying address to %x (Who %x)\n", + RequestAddressReturn, WhoIsConnecting));
RequestAddressReturn->TAAddressCount = 1; - RequestAddressReturn->Address[0].AddressLength = OutAddrLen; + RequestAddressReturn->Address[0].AddressLength = OutAddrLen;
/* BSD uses the first byte of the sockaddr struct as a length. * Since windows doesn't do that we strip it */ - RequestAddressReturn->Address[0].AddressType = - (OutAddr.sin_family >> 8) & 0xff; + RequestAddressReturn->Address[0].AddressType = + (OutAddr.sin_family >> 8) & 0xff;
- RtlCopyMemory( &RequestAddressReturn->Address[0].Address, - ((PCHAR)&OutAddr) + sizeof(USHORT), - sizeof(RequestAddressReturn->Address[0].Address[0]) ); + RtlCopyMemory( &RequestAddressReturn->Address[0].Address, + ((PCHAR)&OutAddr) + sizeof(USHORT), + sizeof(RequestAddressReturn->Address[0].Address[0]) );
- TI_DbgPrint(DEBUG_TCP,("Done copying\n")); + TI_DbgPrint(DEBUG_TCP,("Done copying\n")); }
TI_DbgPrint(DEBUG_TCP,("Status %x\n", Status)); @@ -71,7 +71,7 @@ TI_DbgPrint(DEBUG_TCP,("TCPListen started\n"));
TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext %x\n", - Connection->SocketContext)); + Connection->SocketContext));
ASSERT(Connection); ASSERT_KM_POINTER(Connection->SocketContext); @@ -81,16 +81,16 @@
AddressToBind.sin_family = AF_INET; memcpy( &AddressToBind.sin_addr, - &Connection->AddressFile->Address.Address.IPv4Address, - sizeof(AddressToBind.sin_addr) ); + &Connection->AddressFile->Address.Address.IPv4Address, + sizeof(AddressToBind.sin_addr) ); AddressToBind.sin_port = Connection->AddressFile->Port;
TI_DbgPrint(DEBUG_TCP,("AddressToBind - %x:%x\n", AddressToBind.sin_addr, AddressToBind.sin_port));
Status = TCPTranslateError( OskitTCPBind( Connection->SocketContext, - Connection, - &AddressToBind, - sizeof(AddressToBind) ) ); + Connection, + &AddressToBind, + sizeof(AddressToBind) ) );
if (NT_SUCCESS(Status)) Status = TCPTranslateError( OskitTCPListen( Connection->SocketContext, Backlog ) ); @@ -103,7 +103,7 @@ }
VOID TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener, - PCONNECTION_ENDPOINT Connection ) { + PCONNECTION_ENDPOINT Connection ) { PLIST_ENTRY ListEntry; PTDI_BUCKET Bucket;
@@ -111,50 +111,50 @@
ListEntry = Listener->ListenRequest.Flink; while ( ListEntry != &Listener->ListenRequest ) { - Bucket = CONTAINING_RECORD(ListEntry, TDI_BUCKET, Entry); + Bucket = CONTAINING_RECORD(ListEntry, TDI_BUCKET, Entry);
- if( Bucket->AssociatedEndpoint == Connection ) { - RemoveEntryList( &Bucket->Entry ); - exFreePool( Bucket ); - break; - } + if( Bucket->AssociatedEndpoint == Connection ) { + RemoveEntryList( &Bucket->Entry ); + exFreePool( Bucket ); + break; + }
- ListEntry = ListEntry->Flink; + ListEntry = ListEntry->Flink; }
TcpipRecursiveMutexLeave( &TCPLock ); }
-NTSTATUS TCPAccept -( PTDI_REQUEST Request, - PCONNECTION_ENDPOINT Listener, - PCONNECTION_ENDPOINT Connection, - PTCP_COMPLETION_ROUTINE Complete, - PVOID Context ) { - NTSTATUS Status; - PTDI_BUCKET Bucket; +NTSTATUS TCPAccept ( PTDI_REQUEST Request, + PCONNECTION_ENDPOINT Listener, + PCONNECTION_ENDPOINT Connection, + PTCP_COMPLETION_ROUTINE Complete, + PVOID Context ) +{ + NTSTATUS Status; + PTDI_BUCKET Bucket;
- TI_DbgPrint(DEBUG_TCP,("TCPAccept started\n")); + TI_DbgPrint(DEBUG_TCP,("TCPAccept started\n"));
- TcpipRecursiveMutexEnter( &TCPLock, TRUE ); + TcpipRecursiveMutexEnter( &TCPLock, TRUE );
- Status = TCPServiceListeningSocket( Listener, Connection, - (PTDI_REQUEST_KERNEL)Request ); + Status = TCPServiceListeningSocket( Listener, Connection, + (PTDI_REQUEST_KERNEL)Request );
- if( Status == STATUS_PENDING ) { - Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) ); + if( Status == STATUS_PENDING ) { + Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
- if( Bucket ) { - Bucket->AssociatedEndpoint = Connection; - Bucket->Request.RequestNotifyObject = Complete; - Bucket->Request.RequestContext = Context; - InsertHeadList( &Listener->ListenRequest, &Bucket->Entry ); - } else - Status = STATUS_NO_MEMORY; - } + if( Bucket ) { + Bucket->AssociatedEndpoint = Connection; + Bucket->Request.RequestNotifyObject = Complete; + Bucket->Request.RequestContext = Context; + InsertHeadList( &Listener->ListenRequest, &Bucket->Entry ); + } else + Status = STATUS_NO_MEMORY; + }
- TcpipRecursiveMutexLeave( &TCPLock ); + TcpipRecursiveMutexLeave( &TCPLock );
- TI_DbgPrint(DEBUG_TCP,("TCPAccept finished %x\n", Status)); - return Status; + TI_DbgPrint(DEBUG_TCP,("TCPAccept finished %x\n", Status)); + return Status; }
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/event.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/tc... ============================================================================== --- trunk/reactos/lib/drivers/ip/transport/tcp/event.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/tcp/event.c [iso-8859-1] Sat Jun 27 11:38:02 2009 @@ -11,46 +11,46 @@ #include "precomp.h"
int TCPSocketState(void *ClientData, - void *WhichSocket, - void *WhichConnection, - OSK_UINT NewState ) { + void *WhichSocket, + void *WhichConnection, + OSK_UINT NewState ) { PCONNECTION_ENDPOINT Connection = WhichConnection;
TI_DbgPrint(MID_TRACE,("Flags: %c%c%c%c\n", - NewState & SEL_CONNECT ? 'C' : 'c', - NewState & SEL_READ ? 'R' : 'r', - NewState & SEL_FIN ? 'F' : 'f', - NewState & SEL_ACCEPT ? 'A' : 'a')); + NewState & SEL_CONNECT ? 'C' : 'c', + NewState & SEL_READ ? 'R' : 'r', + NewState & SEL_FIN ? 'F' : 'f', + NewState & SEL_ACCEPT ? 'A' : 'a'));
TI_DbgPrint(DEBUG_TCP,("Called: NewState %x (Conn %x) (Change %x)\n", - NewState, Connection, - Connection ? Connection->State ^ NewState : - NewState)); + NewState, Connection, + Connection ? Connection->State ^ NewState : + NewState));
if( !Connection ) { - TI_DbgPrint(DEBUG_TCP,("Socket closing.\n")); - Connection = FileFindConnectionByContext( WhichSocket ); - if( !Connection ) - return 0; - else - TI_DbgPrint(DEBUG_TCP,("Found socket %x\n", Connection)); + TI_DbgPrint(DEBUG_TCP,("Socket closing.\n")); + Connection = FileFindConnectionByContext( WhichSocket ); + if( !Connection ) + return 0; + else + TI_DbgPrint(DEBUG_TCP,("Found socket %x\n", Connection)); }
TI_DbgPrint(MID_TRACE,("Connection signalled: %d\n", - Connection->Signalled)); + Connection->Signalled));
Connection->SignalState |= NewState; if( !Connection->Signalled ) { - Connection->Signalled = TRUE; - InsertTailList( &SignalledConnections, &Connection->SignalList ); + Connection->Signalled = TRUE; + InsertTailList( &SignalledConnections, &Connection->SignalList ); }
return 0; }
void TCPPacketSendComplete( PVOID Context, - PNDIS_PACKET NdisPacket, - NDIS_STATUS NdisStatus ) { + PNDIS_PACKET NdisPacket, + NDIS_STATUS NdisStatus ) { TI_DbgPrint(DEBUG_TCP,("called %x\n", NdisPacket)); FreeNdisPacket(NdisPacket); TI_DbgPrint(DEBUG_TCP,("done\n")); @@ -66,32 +66,32 @@ PIPv4_HEADER Header;
if( *data == 0x45 ) { /* IPv4 */ - Header = (PIPv4_HEADER)data; - LocalAddress.Type = IP_ADDRESS_V4; - LocalAddress.Address.IPv4Address = Header->SrcAddr; - RemoteAddress.Type = IP_ADDRESS_V4; - RemoteAddress.Address.IPv4Address = Header->DstAddr; + Header = (PIPv4_HEADER)data; + LocalAddress.Type = IP_ADDRESS_V4; + LocalAddress.Address.IPv4Address = Header->SrcAddr; + RemoteAddress.Type = IP_ADDRESS_V4; + RemoteAddress.Address.IPv4Address = Header->DstAddr; } else { - TI_DbgPrint(MIN_TRACE,("Outgoing packet is not IPv4\n")); - OskitDumpBuffer( data, len ); - return OSK_EINVAL; + TI_DbgPrint(MIN_TRACE,("Outgoing packet is not IPv4\n")); + OskitDumpBuffer( data, len ); + return OSK_EINVAL; }
if(!(NCE = RouteGetRouteToDestination( &RemoteAddress ))) { - TI_DbgPrint(MIN_TRACE,("No route to %s\n", A2S(&RemoteAddress))); - return OSK_EADDRNOTAVAIL; + TI_DbgPrint(MIN_TRACE,("No route to %s\n", A2S(&RemoteAddress))); + return OSK_EADDRNOTAVAIL; }
NdisStatus = AllocatePacketWithBuffer( &Packet.NdisPacket, NULL, - MaxLLHeaderSize + len ); + MaxLLHeaderSize + len );
if (NdisStatus != NDIS_STATUS_SUCCESS) { - TI_DbgPrint(DEBUG_TCP, ("Error from NDIS: %08x\n", NdisStatus)); - return OSK_ENOBUFS; + TI_DbgPrint(DEBUG_TCP, ("Error from NDIS: %08x\n", NdisStatus)); + return OSK_ENOBUFS; }
GetDataPtr( Packet.NdisPacket, MaxLLHeaderSize, - (PCHAR *)&Packet.Header, &Packet.ContigSize ); + (PCHAR *)&Packet.Header, &Packet.ContigSize );
RtlCopyMemory( Packet.Header, data, len );
@@ -110,44 +110,44 @@ }
int TCPSleep( void *ClientData, void *token, int priority, char *msg, - int tmio ) { + int tmio ) { PSLEEPING_THREAD SleepingThread; LARGE_INTEGER Timeout;
TI_DbgPrint(DEBUG_TCP, - ("Called TSLEEP: tok = %x, pri = %d, wmesg = %s, tmio = %x\n", - token, priority, msg, tmio)); + ("Called TSLEEP: tok = %x, pri = %d, wmesg = %s, tmio = %x\n", + token, priority, msg, tmio));
SleepingThread = exAllocatePool( NonPagedPool, sizeof( *SleepingThread ) ); if( SleepingThread ) { - KeInitializeEvent( &SleepingThread->Event, NotificationEvent, FALSE ); - SleepingThread->SleepToken = token; - - /* We're going to sleep and need to release the lock, otherwise + KeInitializeEvent( &SleepingThread->Event, NotificationEvent, FALSE ); + SleepingThread->SleepToken = token; + + /* We're going to sleep and need to release the lock, otherwise it's impossible to re-enter oskittcp to deliver the event that's going to wake us */ - TcpipRecursiveMutexLeave( &TCPLock ); - - TcpipAcquireFastMutex( &SleepingThreadsLock ); - InsertTailList( &SleepingThreadsList, &SleepingThread->Entry ); - TcpipReleaseFastMutex( &SleepingThreadsLock ); + TcpipRecursiveMutexLeave( &TCPLock ); + + TcpipAcquireFastMutex( &SleepingThreadsLock ); + InsertTailList( &SleepingThreadsList, &SleepingThread->Entry ); + TcpipReleaseFastMutex( &SleepingThreadsLock );
Timeout.QuadPart = Int32x32To64(tmio, -10000);
- TI_DbgPrint(DEBUG_TCP,("Waiting on %x\n", token)); - KeWaitForSingleObject( &SleepingThread->Event, - Executive, - KernelMode, - TRUE, - (tmio != 0) ? &Timeout : NULL ); - - TcpipAcquireFastMutex( &SleepingThreadsLock ); - RemoveEntryList( &SleepingThread->Entry ); - TcpipReleaseFastMutex( &SleepingThreadsLock ); - - TcpipRecursiveMutexEnter( &TCPLock, TRUE ); - - exFreePool( SleepingThread ); + TI_DbgPrint(DEBUG_TCP,("Waiting on %x\n", token)); + KeWaitForSingleObject( &SleepingThread->Event, + Executive, + KernelMode, + TRUE, + (tmio != 0) ? &Timeout : NULL ); + + TcpipAcquireFastMutex( &SleepingThreadsLock ); + RemoveEntryList( &SleepingThread->Entry ); + TcpipReleaseFastMutex( &SleepingThreadsLock ); + + TcpipRecursiveMutexEnter( &TCPLock, TRUE ); + + exFreePool( SleepingThread ); } else return OSK_ENOBUFS;
@@ -162,13 +162,13 @@ TcpipAcquireFastMutex( &SleepingThreadsLock ); Entry = SleepingThreadsList.Flink; while( Entry != &SleepingThreadsList ) { - SleepingThread = CONTAINING_RECORD(Entry, SLEEPING_THREAD, Entry); - TI_DbgPrint(DEBUG_TCP,("Sleeper @ %x\n", SleepingThread)); - if( SleepingThread->SleepToken == token ) { - TI_DbgPrint(DEBUG_TCP,("Setting event to wake %x\n", token)); - KeSetEvent( &SleepingThread->Event, IO_NETWORK_INCREMENT, FALSE ); - } - Entry = Entry->Flink; + SleepingThread = CONTAINING_RECORD(Entry, SLEEPING_THREAD, Entry); + TI_DbgPrint(DEBUG_TCP,("Sleeper @ %x\n", SleepingThread)); + if( SleepingThread->SleepToken == token ) { + TI_DbgPrint(DEBUG_TCP,("Setting event to wake %x\n", token)); + KeSetEvent( &SleepingThread->Event, IO_NETWORK_INCREMENT, FALSE ); + } + Entry = Entry->Flink; } TcpipReleaseFastMutex( &SleepingThreadsLock ); } @@ -219,7 +219,7 @@ }
void *TCPMalloc( void *ClientData, - OSK_UINT Bytes, OSK_PCHAR File, OSK_UINT Line ) { + OSK_UINT Bytes, OSK_PCHAR File, OSK_UINT Line ) { void *v; ULONG Signature;
@@ -231,84 +231,84 @@
Found = 0; for ( i = 0; i < ArrayUsed && ! Found; i++ ) { - Found = ( Sizes[i] == Bytes ); - if ( Found ) { - Counts[i]++; - } + Found = ( Sizes[i] == Bytes ); + if ( Found ) { + Counts[i]++; + } } if ( ! Found ) { - if ( ArrayAllocated <= ArrayUsed ) { - NewSize = ( 0 == ArrayAllocated ? 16 : 2 * ArrayAllocated ); - NewArray = exAllocatePool( NonPagedPool, 2 * NewSize * sizeof( OSK_UINT ) ); - if ( NULL != NewArray ) { - if ( 0 != ArrayAllocated ) { - memcpy( NewArray, Sizes, - ArrayAllocated * sizeof( OSK_UINT ) ); - exFreePool( Sizes ); - memcpy( NewArray + NewSize, Counts, - ArrayAllocated * sizeof( OSK_UINT ) ); - exFreePool( Counts ); - } - Sizes = NewArray; - Counts = NewArray + NewSize; - ArrayAllocated = NewSize; - } else if ( 0 != ArrayAllocated ) { - exFreePool( Sizes ); - exFreePool( Counts ); - ArrayAllocated = 0; - } - } - if ( ArrayUsed < ArrayAllocated ) { - Sizes[ArrayUsed] = Bytes; - Counts[ArrayUsed] = 1; - ArrayUsed++; - } + if ( ArrayAllocated <= ArrayUsed ) { + NewSize = ( 0 == ArrayAllocated ? 16 : 2 * ArrayAllocated ); + NewArray = exAllocatePool( NonPagedPool, 2 * NewSize * sizeof( OSK_UINT ) ); + if ( NULL != NewArray ) { + if ( 0 != ArrayAllocated ) { + memcpy( NewArray, Sizes, + ArrayAllocated * sizeof( OSK_UINT ) ); + exFreePool( Sizes ); + memcpy( NewArray + NewSize, Counts, + ArrayAllocated * sizeof( OSK_UINT ) ); + exFreePool( Counts ); + } + Sizes = NewArray; + Counts = NewArray + NewSize; + ArrayAllocated = NewSize; + } else if ( 0 != ArrayAllocated ) { + exFreePool( Sizes ); + exFreePool( Counts ); + ArrayAllocated = 0; + } + } + if ( ArrayUsed < ArrayAllocated ) { + Sizes[ArrayUsed] = Bytes; + Counts[ArrayUsed] = 1; + ArrayUsed++; + } }
if ( 0 == (++AllocationCount % MEM_PROFILE) ) { - TI_DbgPrint(DEBUG_TCP, ("Memory allocation size profile:\n")); - for ( i = 0; i < ArrayUsed; i++ ) { - TI_DbgPrint(DEBUG_TCP, - ("Size %4u Count %5u\n", Sizes[i], Counts[i])); - } - TI_DbgPrint(DEBUG_TCP, ("End of memory allocation size profile\n")); + TI_DbgPrint(DEBUG_TCP, ("Memory allocation size profile:\n")); + for ( i = 0; i < ArrayUsed; i++ ) { + TI_DbgPrint(DEBUG_TCP, + ("Size %4u Count %5u\n", Sizes[i], Counts[i])); + } + TI_DbgPrint(DEBUG_TCP, ("End of memory allocation size profile\n")); } #endif /* MEM_PROFILE */
if ( SMALL_SIZE == Bytes ) { - v = ExAllocateFromNPagedLookasideList( &SmallLookasideList ); - Signature = SIGNATURE_SMALL; + v = ExAllocateFromNPagedLookasideList( &SmallLookasideList ); + Signature = SIGNATURE_SMALL; } else if ( LARGE_SIZE == Bytes ) { - v = ExAllocateFromNPagedLookasideList( &LargeLookasideList ); - Signature = SIGNATURE_LARGE; + v = ExAllocateFromNPagedLookasideList( &LargeLookasideList ); + Signature = SIGNATURE_LARGE; } else { - v = ExAllocatePool( NonPagedPool, Bytes + sizeof(ULONG) ); - Signature = SIGNATURE_OTHER; + v = ExAllocatePool( NonPagedPool, Bytes + sizeof(ULONG) ); + Signature = SIGNATURE_OTHER; } if( v ) { - *((ULONG *) v) = Signature; - v = (void *)((char *) v + sizeof(ULONG)); - TrackWithTag( FOURCC('f','b','s','d'), v, (PCHAR)File, Line ); + *((ULONG *) v) = Signature; + v = (void *)((char *) v + sizeof(ULONG)); + TrackWithTag( FOURCC('f','b','s','d'), v, (PCHAR)File, Line ); }
return v; }
void TCPFree( void *ClientData, - void *data, OSK_PCHAR File, OSK_UINT Line ) { + void *data, OSK_PCHAR File, OSK_UINT Line ) { ULONG Signature;
UntrackFL( (PCHAR)File, Line, data, FOURCC('f','b','s','d') ); data = (void *)((char *) data - sizeof(ULONG)); Signature = *((ULONG *) data); if ( SIGNATURE_SMALL == Signature ) { - ExFreeToNPagedLookasideList( &SmallLookasideList, data ); + ExFreeToNPagedLookasideList( &SmallLookasideList, data ); } else if ( SIGNATURE_LARGE == Signature ) { - ExFreeToNPagedLookasideList( &LargeLookasideList, data ); + ExFreeToNPagedLookasideList( &LargeLookasideList, data ); } else if ( SIGNATURE_OTHER == Signature ) { - ExFreePool( data ); + ExFreePool( data ); } else { - ASSERT( FALSE ); + ASSERT( FALSE ); } }
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/if.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/tc... ============================================================================== --- trunk/reactos/lib/drivers/ip/transport/tcp/if.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/tcp/if.c [iso-8859-1] Sat Jun 27 11:38:02 2009 @@ -49,13 +49,13 @@
ifaddr->ifa_addr = (struct sockaddr *)addr_in; Status = GetInterfaceIPv4Address( IF, - ADE_UNICAST, - (PULONG)&addr_in->sin_addr.s_addr ); + ADE_UNICAST, + (PULONG)&addr_in->sin_addr.s_addr );
ASSERT(NT_SUCCESS(Status));
TI_DbgPrint(DEBUG_TCPIF,("interface %x : addr %x\n", - IF, addr_in->sin_addr.s_addr)); + IF, addr_in->sin_addr.s_addr));
ifaddr->ifa_flags = 0; /* XXX what goes here? */ ifaddr->ifa_refcnt = 0; /* Anachronistic */ @@ -68,10 +68,10 @@ }
POSK_IFADDR TCPFindInterface( void *ClientData, - OSK_UINT AddrType, - OSK_UINT FindType, - OSK_SOCKADDR *ReqAddr, - OSK_IFADDR *Interface ) { + OSK_UINT AddrType, + OSK_UINT FindType, + OSK_SOCKADDR *ReqAddr, + OSK_IFADDR *Interface ) { PIP_INTERFACE IF; IP_ADDRESS Destination; struct sockaddr_in *addr_in = (struct sockaddr_in *)ReqAddr; @@ -80,8 +80,8 @@ TI_DbgPrint(DEBUG_TCPIF,("called for type %d\n", FindType));
if( !ReqAddr ) { - TI_DbgPrint(DEBUG_TCPIF,("no addr or no ifaddr (%x)\n", ReqAddr)); - return NULL; + TI_DbgPrint(DEBUG_TCPIF,("no addr or no ifaddr (%x)\n", ReqAddr)); + return NULL; }
Destination.Type = IP_ADDRESS_V4; @@ -95,7 +95,7 @@ InterfaceData = TCPGetInterfaceData(IF);
addr_in = (struct sockaddr_in *) - InterfaceData->ifa_addr; + InterfaceData->ifa_addr;
TI_DbgPrint(DEBUG_TCPIF,("returning addr %x\n", addr_in->sin_addr.s_addr));
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/tc... ============================================================================== --- trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] Sat Jun 27 11:38:02 2009 @@ -22,7 +22,7 @@ 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 @@
/* 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 @@ }
if( NewState & SEL_ACCEPT ) { - /* 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")); - - while( !IsListEmpty( &Connection->ListenRequest ) ) { - PIO_STACK_LOCATION IrpSp; - - Entry = RemoveHeadList( &Connection->ListenRequest ); - Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry ); - Complete = Bucket->Request.RequestNotifyObject; - - 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,("Socket: Status: %x\n")); - - if( Status == STATUS_PENDING ) { - InsertHeadList( &Connection->ListenRequest, &Bucket->Entry ); - break; - } else { - Complete( Bucket->Request.RequestContext, Status, 0 ); - exFreePool( Bucket ); - } - } + /* 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")); + + while( !IsListEmpty( &Connection->ListenRequest ) ) { + PIO_STACK_LOCATION IrpSp; + + Entry = RemoveHeadList( &Connection->ListenRequest ); + Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry ); + Complete = Bucket->Request.RequestNotifyObject; + + 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,("Socket: Status: %x\n")); + + 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")); - - while( !IsListEmpty( &Connection->ReceiveRequest ) ) { - OSK_UINT RecvLen = 0, Received = 0; - PVOID RecvBuffer = 0; - - Entry = RemoveHeadList( &Connection->ReceiveRequest ); - Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry ); - Complete = Bucket->Request.RequestNotifyObject; - - Irp = Bucket->Request.RequestContext; - Mdl = Irp->MdlAddress; - - TI_DbgPrint(DEBUG_TCP, - ("Getting the user buffer from %x\n", Mdl)); - - NdisQueryBuffer( Mdl, &RecvBuffer, &RecvLen ); - - 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)); - - Status = TCPTranslateError - ( OskitTCPRecv( Connection->SocketContext, - RecvBuffer, - RecvLen, - &Received, - 0 ) ); - - 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)); - - 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 ); - } - } + TI_DbgPrint(DEBUG_TCP,("Readable: irp list %s\n", + IsListEmpty(&Connection->ReceiveRequest) ? + "empty" : "nonempty")); + + while( !IsListEmpty( &Connection->ReceiveRequest ) ) { + OSK_UINT RecvLen = 0, Received = 0; + PVOID RecvBuffer = 0; + + Entry = RemoveHeadList( &Connection->ReceiveRequest ); + Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry ); + Complete = Bucket->Request.RequestNotifyObject; + + Irp = Bucket->Request.RequestContext; + Mdl = Irp->MdlAddress; + + TI_DbgPrint(DEBUG_TCP, + ("Getting the user buffer from %x\n", Mdl)); + + NdisQueryBuffer( Mdl, &RecvBuffer, &RecvLen ); + + 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)); + + Status = TCPTranslateError + ( OskitTCPRecv( Connection->SocketContext, + RecvBuffer, + RecvLen, + &Received, + 0 ) ); + + 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)); + + 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->SendRequest) ? - "empty" : "nonempty")); - - while( !IsListEmpty( &Connection->SendRequest ) ) { - OSK_UINT SendLen = 0, Sent = 0; - PVOID SendBuffer = 0; - - Entry = RemoveHeadList( &Connection->SendRequest ); - Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry ); - Complete = Bucket->Request.RequestNotifyObject; - - Irp = Bucket->Request.RequestContext; - Mdl = Irp->MdlAddress; - - TI_DbgPrint(DEBUG_TCP, - ("Getting the user buffer from %x\n", Mdl)); - - NdisQueryBuffer( Mdl, &SendBuffer, &SendLen ); - - 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)); - - Status = TCPTranslateError - ( OskitTCPSend( Connection->SocketContext, - SendBuffer, - SendLen, - &Sent, - 0 ) ); - - 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)); - - 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 ); - } - } + TI_DbgPrint(DEBUG_TCP,("Writeable: irp list %s\n", + IsListEmpty(&Connection->SendRequest) ? + "empty" : "nonempty")); + + while( !IsListEmpty( &Connection->SendRequest ) ) { + OSK_UINT SendLen = 0, Sent = 0; + PVOID SendBuffer = 0; + + Entry = RemoveHeadList( &Connection->SendRequest ); + Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry ); + Complete = Bucket->Request.RequestNotifyObject; + + Irp = Bucket->Request.RequestContext; + Mdl = Irp->MdlAddress; + + TI_DbgPrint(DEBUG_TCP, + ("Getting the user buffer from %x\n", Mdl)); + + NdisQueryBuffer( Mdl, &SendBuffer, &SendLen ); + + 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)); + + Status = TCPTranslateError + ( OskitTCPSend( Connection->SocketContext, + SendBuffer, + SendLen, + &Sent, + 0 ) ); + + 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)); + + 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 ) { @@ -230,9 +230,9 @@
/* We have to notify oskittcp of the abortion */ DisType.Type = TDI_DISCONNECT_RELEASE | TDI_DISCONNECT_ABORT; - DisType.Context = Connection; - DisType.Irp = (PIRP)Bucket->Request.RequestContext; - DisType.FileObject = IrpSp->FileObject; + DisType.Context = Connection; + DisType.Irp = (PIRP)Bucket->Request.RequestContext; + DisType.FileObject = IrpSp->FileObject;
ChewCreate(NULL, sizeof(DISCONNECT_TYPE), DispDoDisconnect, &DisType); @@ -249,9 +249,9 @@
/* We have to notify oskittcp of the abortion */ DisType.Type = TDI_DISCONNECT_RELEASE; - DisType.Context = Connection; - DisType.Irp = (PIRP)Bucket->Request.RequestContext; - DisType.FileObject = IrpSp->FileObject; + DisType.Context = Connection; + DisType.Irp = (PIRP)Bucket->Request.RequestContext; + DisType.FileObject = IrpSp->FileObject;
ChewCreate(NULL, sizeof(DISCONNECT_TYPE), DispDoDisconnect, &DisType); @@ -265,7 +265,7 @@
/* We have to notify oskittcp of the abortion */ TCPAbortListenForSocket(Connection->AddressFile->Listener, - Connection); + Connection);
Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 ); } @@ -288,18 +288,18 @@ 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));
@@ -319,29 +319,29 @@ }
VOID TCPFreeConnectionEndpoint( PCONNECTION_ENDPOINT Connection ) { - TI_DbgPrint(DEBUG_TCP, ("Freeing TCP Endpoint\n")); + TI_DbgPrint(DEBUG_TCP, ("Freeing TCP Endpoint\n")); exFreePool( 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 );
@@ -358,14 +358,14 @@ */ { 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();
@@ -374,28 +374,28 @@
/* 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 );
@@ -486,13 +486,13 @@ 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 ); @@ -502,13 +502,13 @@ 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();
@@ -528,7 +528,7 @@ LARGE_INTEGER WaitForThread;
if (!TCPInitialized) - return STATUS_SUCCESS; + return STATUS_SUCCESS;
WaitForThread.QuadPart = -2500000; /* 250 ms */ KeSetEvent(&TimerLoopEvent, IO_NO_INCREMENT, FALSE); @@ -579,27 +579,27 @@ IP_ADDRESS RemoteAddress; USHORT RemotePort; PTDI_BUCKET Bucket; - PNEIGHBOR_CACHE_ENTRY NCE; + PNEIGHBOR_CACHE_ENTRY NCE;
TI_DbgPrint(DEBUG_TCP,("TCPConnect: Called\n"));
Status = AddrBuildAddress - ((PTRANSPORT_ADDRESS)ConnInfo->RemoteAddress, - &RemoteAddress, - &RemotePort); - - if (!(NCE = RouteGetRouteToDestination(&RemoteAddress))) - { - return STATUS_NETWORK_UNREACHABLE; - } + ((PTRANSPORT_ADDRESS)ConnInfo->RemoteAddress, + &RemoteAddress, + &RemotePort); + + if (!(NCE = RouteGetRouteToDestination(&RemoteAddress))) + { + return STATUS_NETWORK_UNREACHABLE; + }
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
- if (Connection->State & SEL_FIN) - { - TcpipRecursiveMutexLeave( &TCPLock ); - return STATUS_REMOTE_DISCONNECT; - } + if (Connection->State & SEL_FIN) + { + TcpipRecursiveMutexLeave( &TCPLock ); + return STATUS_REMOTE_DISCONNECT; + }
/* Freed in TCPSocketState */ TI_DbgPrint(DEBUG_TCP, @@ -608,43 +608,43 @@ 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; AddressToBind = AddressToConnect; - AddressToBind.sin_addr.s_addr = NCE->Interface->Unicast.Address.IPv4Address; + AddressToBind.sin_addr.s_addr = NCE->Interface->Unicast.Address.IPv4Address;
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) ) ); - - if (Status == STATUS_PENDING) - { - Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) ); - if( !Bucket ) return STATUS_NO_MEMORY; - - Bucket->Request.RequestNotifyObject = (PVOID)Complete; - Bucket->Request.RequestContext = Context; - - InsertHeadList( &Connection->ConnectRequest, &Bucket->Entry ); - } + ( OskitTCPConnect( Connection->SocketContext, + Connection, + &AddressToConnect, + sizeof(AddressToConnect) ) ); + + if (Status == STATUS_PENDING) + { + Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) ); + if( !Bucket ) return STATUS_NO_MEMORY; + + Bucket->Request.RequestNotifyObject = (PVOID)Complete; + Bucket->Request.RequestContext = Context; + + InsertHeadList( &Connection->ConnectRequest, &Bucket->Entry ); + } }
TcpipRecursiveMutexLeave( &TCPLock ); @@ -668,20 +668,20 @@ 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 );
@@ -731,48 +731,48 @@
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
- /* Closing */ - if (Connection->State & SEL_FIN) - { - TcpipRecursiveMutexLeave( &TCPLock ); - *BytesReceived = 0; - return STATUS_REMOTE_DISCONNECT; - } + /* Closing */ + if (Connection->State & SEL_FIN) + { + TcpipRecursiveMutexLeave( &TCPLock ); + *BytesReceived = 0; + return STATUS_REMOTE_DISCONNECT; + }
NdisQueryBuffer( Buffer, &DataBuffer, &DataLen );
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; - } - - Bucket->Request.RequestNotifyObject = Complete; - Bucket->Request.RequestContext = Context; - *BytesReceived = 0; - - InsertTailList( &Connection->ReceiveRequest, &Bucket->Entry ); - Status = STATUS_PENDING; - TI_DbgPrint(DEBUG_TCP,("Queued read irp\n")); + /* 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; + + InsertTailList( &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 ); @@ -803,46 +803,46 @@
TI_DbgPrint(DEBUG_TCP,("Connection = %x\n", Connection)); TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext = %x\n", - Connection->SocketContext)); - - /* Closing */ - if (Connection->State & SEL_FIN) - { - TcpipRecursiveMutexLeave( &TCPLock ); - *BytesSent = 0; - return STATUS_REMOTE_DISCONNECT; - } + Connection->SocketContext)); + + /* Closing */ + if (Connection->State & SEL_FIN) + { + TcpipRecursiveMutexLeave( &TCPLock ); + *BytesSent = 0; + return STATUS_REMOTE_DISCONNECT; + }
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; - } - - Bucket->Request.RequestNotifyObject = Complete; - Bucket->Request.RequestContext = Context; - *BytesSent = 0; - - InsertTailList( &Connection->SendRequest, &Bucket->Entry ); - TI_DbgPrint(DEBUG_TCP,("Queued write irp\n")); + /* 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; + + InsertTailList( &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 ); - + TI_DbgPrint(DEBUG_TCP,("Status %x\n", Status));
return Status; @@ -854,8 +854,8 @@
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; @@ -908,19 +908,19 @@ 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 ); - if( Bucket->Request.RequestContext == Irp ) - { - RemoveEntryList( &Bucket->Entry ); - exFreePool( Bucket ); - break; - } - } + { + 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; + } + } }
TcpipReleaseSpinLock( &Endpoint->Lock, OldIrql );