2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
4 * FILE: transport/tcp/tcp.c
5 * PURPOSE: Transmission Control Protocol
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * Art Yerkes (arty@users.sf.net)
9 * CSH 01/08-2000 Created
10 * arty 12/21/2004 Added accept
15 LONG TCP_IPIdentification
= 0;
16 static BOOLEAN TCPInitialized
= FALSE
;
17 static NPAGED_LOOKASIDE_LIST TCPSegmentList
;
18 LIST_ENTRY SignalledConnections
;
19 LIST_ENTRY SleepingThreadsList
;
20 FAST_MUTEX SleepingThreadsLock
;
21 RECURSIVE_MUTEX TCPLock
;
24 static VOID
HandleSignalledConnection( PCONNECTION_ENDPOINT Connection
,
26 NTSTATUS Status
= STATUS_SUCCESS
;
27 PTCP_COMPLETION_ROUTINE Complete
;
33 TI_DbgPrint(MID_TRACE
,("Handling signalled state on %x (%x)\n",
34 Connection
, Connection
->SocketContext
));
36 /* Things that can happen when we try the initial connection */
37 if( NewState
& SEL_CONNECT
) {
38 while( !IsListEmpty( &Connection
->ConnectRequest
) ) {
39 Connection
->State
|= NewState
;
40 Entry
= RemoveHeadList( &Connection
->ConnectRequest
);
41 TI_DbgPrint(DEBUG_TCP
, ("Connect Event\n"));
43 Bucket
= CONTAINING_RECORD( Entry
, TDI_BUCKET
, Entry
);
44 Complete
= Bucket
->Request
.RequestNotifyObject
;
45 TI_DbgPrint(DEBUG_TCP
,
46 ("Completing Request %x\n", Bucket
->Request
));
48 if( (NewState
& (SEL_CONNECT
| SEL_FIN
)) ==
49 (SEL_CONNECT
| SEL_FIN
) )
50 Status
= STATUS_CONNECTION_REFUSED
;
52 Status
= STATUS_SUCCESS
;
54 Complete( Bucket
->Request
.RequestContext
, Status
, 0 );
56 /* Frees the bucket allocated in TCPConnect */
57 PoolFreeBuffer( Bucket
);
61 if( NewState
& SEL_ACCEPT
) {
62 /* Handle readable on a listening socket --
63 * TODO: Implement filtering
66 TI_DbgPrint(DEBUG_TCP
,("Accepting new connection on %x (Queue: %s)\n",
68 IsListEmpty(&Connection
->ListenRequest
) ?
69 "empty" : "nonempty"));
71 while( !IsListEmpty( &Connection
->ListenRequest
) ) {
72 PIO_STACK_LOCATION IrpSp
;
74 Entry
= RemoveHeadList( &Connection
->ListenRequest
);
75 Bucket
= CONTAINING_RECORD( Entry
, TDI_BUCKET
, Entry
);
76 Complete
= Bucket
->Request
.RequestNotifyObject
;
78 Irp
= Bucket
->Request
.RequestContext
;
79 IrpSp
= IoGetCurrentIrpStackLocation( Irp
);
81 TI_DbgPrint(DEBUG_TCP
,("Getting the socket\n"));
82 Status
= TCPServiceListeningSocket
83 ( Connection
->AddressFile
->Listener
,
84 Bucket
->AssociatedEndpoint
,
85 (PTDI_REQUEST_KERNEL
)&IrpSp
->Parameters
);
87 TI_DbgPrint(DEBUG_TCP
,("Socket: Status: %x\n"));
89 if( Status
== STATUS_PENDING
) {
90 InsertHeadList( &Connection
->ListenRequest
, &Bucket
->Entry
);
93 Complete( Bucket
->Request
.RequestContext
, Status
, 0 );
97 /* Things that happen after we're connected */
98 if( NewState
& SEL_READ
) {
99 TI_DbgPrint(DEBUG_TCP
,("Readable: irp list %s\n",
100 IsListEmpty(&Connection
->ReceiveRequest
) ?
101 "empty" : "nonempty"));
103 while( !IsListEmpty( &Connection
->ReceiveRequest
) ) {
104 OSK_UINT RecvLen
= 0, Received
= 0;
105 OSK_PCHAR RecvBuffer
= 0;
107 Entry
= RemoveHeadList( &Connection
->ReceiveRequest
);
108 Bucket
= CONTAINING_RECORD( Entry
, TDI_BUCKET
, Entry
);
109 Complete
= Bucket
->Request
.RequestNotifyObject
;
111 Irp
= Bucket
->Request
.RequestContext
;
112 Mdl
= Irp
->MdlAddress
;
114 TI_DbgPrint(DEBUG_TCP
,
115 ("Getting the user buffer from %x\n", Mdl
));
117 NdisQueryBuffer( Mdl
, &RecvBuffer
, &RecvLen
);
119 TI_DbgPrint(DEBUG_TCP
,
120 ("Reading %d bytes to %x\n", RecvLen
, RecvBuffer
));
122 TI_DbgPrint(DEBUG_TCP
, ("Connection: %x\n", Connection
));
125 ("Connection->SocketContext: %x\n",
126 Connection
->SocketContext
));
127 TI_DbgPrint(DEBUG_TCP
, ("RecvBuffer: %x\n", RecvBuffer
));
129 Status
= TCPTranslateError
130 ( OskitTCPRecv( Connection
->SocketContext
,
136 TI_DbgPrint(DEBUG_TCP
,("TCP Bytes: %d\n", Received
));
138 if( Status
== STATUS_SUCCESS
) {
139 TI_DbgPrint(DEBUG_TCP
,("Received %d bytes with status %x\n",
142 Complete( Bucket
->Request
.RequestContext
,
143 STATUS_SUCCESS
, Received
);
144 } else if( Status
== STATUS_PENDING
) {
146 ( &Connection
->ReceiveRequest
, &Bucket
->Entry
);
149 TI_DbgPrint(DEBUG_TCP
,
150 ("Completing Receive request: %x %x\n",
151 Bucket
->Request
, Status
));
152 Complete( Bucket
->Request
.RequestContext
, Status
, 0 );
157 if( NewState
& SEL_FIN
) {
158 PLIST_ENTRY ListsToErase
[4];
159 NTSTATUS IrpStatus
[4];
162 TI_DbgPrint(DEBUG_TCP
, ("EOF From socket\n"));
164 ListsToErase
[0] = &Connection
->ReceiveRequest
;
165 IrpStatus
[0] = STATUS_SUCCESS
;
166 ListsToErase
[1] = &Connection
->ListenRequest
;
167 IrpStatus
[1] = STATUS_UNSUCCESSFUL
;
168 ListsToErase
[2] = &Connection
->ConnectRequest
;
169 IrpStatus
[2] = STATUS_UNSUCCESSFUL
;
172 for( i
= 0; ListsToErase
[i
]; i
++ ) {
173 while( !IsListEmpty( ListsToErase
[i
] ) ) {
174 Entry
= RemoveHeadList( ListsToErase
[i
] );
175 Bucket
= CONTAINING_RECORD( Entry
, TDI_BUCKET
, Entry
);
176 Complete
= Bucket
->Request
.RequestNotifyObject
;
177 Complete( Bucket
->Request
.RequestContext
, STATUS_SUCCESS
, 0 );
182 Connection
->Signalled
= FALSE
;
185 VOID
DrainSignals() {
186 PCONNECTION_ENDPOINT Connection
;
187 PLIST_ENTRY ListEntry
;
189 while( !IsListEmpty( &SignalledConnections
) ) {
190 ListEntry
= RemoveHeadList( &SignalledConnections
);
191 Connection
= CONTAINING_RECORD( ListEntry
, CONNECTION_ENDPOINT
,
193 HandleSignalledConnection( Connection
, Connection
->SignalState
);
197 PCONNECTION_ENDPOINT
TCPAllocateConnectionEndpoint( PVOID ClientContext
) {
198 PCONNECTION_ENDPOINT Connection
=
199 ExAllocatePool(NonPagedPool
, sizeof(CONNECTION_ENDPOINT
));
203 TI_DbgPrint(DEBUG_CPOINT
, ("Connection point file object allocated at (0x%X).\n", Connection
));
205 RtlZeroMemory(Connection
, sizeof(CONNECTION_ENDPOINT
));
207 /* Initialize spin lock that protects the connection endpoint file object */
208 TcpipInitializeSpinLock(&Connection
->Lock
);
209 InitializeListHead(&Connection
->ConnectRequest
);
210 InitializeListHead(&Connection
->ListenRequest
);
211 InitializeListHead(&Connection
->ReceiveRequest
);
213 /* Save client context pointer */
214 Connection
->ClientContext
= ClientContext
;
219 VOID
TCPFreeConnectionEndpoint( PCONNECTION_ENDPOINT Connection
) {
220 TI_DbgPrint(MAX_TRACE
,("FIXME: Cancel all pending requests\n"));
221 /* XXX Cancel all pending requests */
222 ExFreePool( Connection
);
225 NTSTATUS
TCPSocket( PCONNECTION_ENDPOINT Connection
,
226 UINT Family
, UINT Type
, UINT Proto
) {
229 TI_DbgPrint(DEBUG_TCP
,("Called: Connection %x, Family %d, Type %d, "
231 Connection
, Family
, Type
, Proto
));
233 TcpipRecursiveMutexEnter( &TCPLock
, TRUE
);
234 Status
= TCPTranslateError( OskitTCPSocket( Connection
,
235 &Connection
->SocketContext
,
240 ASSERT_KM_POINTER(Connection
->SocketContext
);
242 TI_DbgPrint(DEBUG_TCP
,("Connection->SocketContext %x\n",
243 Connection
->SocketContext
));
245 TcpipRecursiveMutexLeave( &TCPLock
);
250 VOID
TCPReceive(PIP_INTERFACE Interface
, PIP_PACKET IPPacket
)
252 * FUNCTION: Receives and queues TCP data
254 * IPPacket = Pointer to an IP packet that was received
256 * This is the low level interface for receiving TCP data
259 TI_DbgPrint(DEBUG_TCP
,("Sending packet %d (%d) to oskit\n",
261 IPPacket
->HeaderSize
));
263 TcpipRecursiveMutexEnter( &TCPLock
, TRUE
);
265 OskitTCPReceiveDatagram( IPPacket
->Header
,
267 IPPacket
->HeaderSize
);
271 TcpipRecursiveMutexLeave( &TCPLock
);
275 int TCPSocketState( void *ClientData
,
277 void *WhichConnection
,
280 int TCPPacketSend( void *ClientData
,
284 POSK_IFADDR
TCPFindInterface( void *ClientData
,
287 OSK_SOCKADDR
*ReqAddr
);
289 NTSTATUS
TCPMemStartup( void );
290 void *TCPMalloc( void *ClientData
,
291 OSK_UINT bytes
, OSK_PCHAR file
, OSK_UINT line
);
292 void TCPFree( void *ClientData
,
293 void *data
, OSK_PCHAR file
, OSK_UINT line
);
294 void TCPMemShutdown( void );
296 int TCPSleep( void *ClientData
, void *token
, int priority
, char *msg
,
299 void TCPWakeup( void *ClientData
, void *token
);
301 OSKITTCP_EVENT_HANDLERS EventHandlers
= {
302 NULL
, /* Client Data */
303 TCPSocketState
, /* SocketState */
304 TCPPacketSend
, /* PacketSend */
305 TCPFindInterface
, /* FindInterface */
306 TCPMalloc
, /* Malloc */
308 TCPSleep
, /* Sleep */
309 TCPWakeup
/* Wakeup */
312 static KEVENT TimerLoopEvent
;
313 static HANDLE TimerThreadHandle
;
316 * We are running 2 timers here, one with a 200ms interval (fast) and the other
317 * with a 500ms interval (slow). So we need to time out at 200, 400, 500, 600,
318 * 800, 1000 and process the "fast" events at 200, 400, 600, 800, 1000 and the
319 * "slow" events at 500 and 1000.
322 TimerThread(PVOID Context
)
324 LARGE_INTEGER Timeout
;
326 unsigned Current
, NextFast
, NextSlow
, Next
;
333 if (Next
== NextFast
) {
336 if (Next
== NextSlow
) {
339 Next
= min(NextFast
, NextSlow
);
340 Timeout
.QuadPart
= (LONGLONG
) (Next
- Current
) * -1000000; /* 100 ms */
341 Status
= KeWaitForSingleObject(&TimerLoopEvent
, Executive
, KernelMode
,
343 if (STATUS_SUCCESS
== Status
) {
344 PsTerminateSystemThread(STATUS_SUCCESS
);
346 ASSERT(STATUS_TIMEOUT
== Status
);
348 TcpipRecursiveMutexEnter( &TCPLock
, TRUE
);
349 TimerOskitTCP( Next
== NextFast
, Next
== NextSlow
);
350 if (Next
== NextSlow
) {
353 TcpipRecursiveMutexLeave( &TCPLock
);
368 KeInitializeEvent(&TimerLoopEvent
, NotificationEvent
, FALSE
);
369 PsCreateSystemThread(&TimerThreadHandle
, THREAD_ALL_ACCESS
, 0, 0, 0,
374 NTSTATUS
TCPStartup(VOID
)
376 * FUNCTION: Initializes the TCP subsystem
378 * Status of operation
383 TcpipRecursiveMutexInit( &TCPLock
);
384 ExInitializeFastMutex( &SleepingThreadsLock
);
385 InitializeListHead( &SleepingThreadsList
);
386 InitializeListHead( &SignalledConnections
);
387 Status
= TCPMemStartup();
388 if ( ! NT_SUCCESS(Status
) ) {
392 PortsStartup( &TCPPorts
, 1, 0xfffe );
394 RegisterOskitTCPEventHandlers( &EventHandlers
);
397 /* Register this protocol with IP layer */
398 IPRegisterProtocol(IPPROTO_TCP
, TCPReceive
);
400 ExInitializeNPagedLookasideList(
401 &TCPSegmentList
, /* Lookaside list */
402 NULL
, /* Allocate routine */
403 NULL
, /* Free routine */
405 sizeof(TCP_SEGMENT
), /* Size of each entry */
406 TAG('T','C','P','S'), /* Tag */
411 TCPInitialized
= TRUE
;
413 return STATUS_SUCCESS
;
417 NTSTATUS
TCPShutdown(VOID
)
419 * FUNCTION: Shuts down the TCP subsystem
421 * Status of operation
424 LARGE_INTEGER WaitForThread
;
427 return STATUS_SUCCESS
;
429 WaitForThread
.QuadPart
= -2500000; /* 250 ms */
430 KeSetEvent(&TimerLoopEvent
, IO_NO_INCREMENT
, FALSE
);
431 ZwWaitForSingleObject(TimerThreadHandle
, FALSE
, &WaitForThread
);
433 /* Deregister this protocol with IP layer */
434 IPRegisterProtocol(IPPROTO_TCP
, NULL
);
436 ExDeleteNPagedLookasideList(&TCPSegmentList
);
438 TCPInitialized
= FALSE
;
442 PortsShutdown( &TCPPorts
);
446 return STATUS_SUCCESS
;
449 NTSTATUS
TCPTranslateError( int OskitError
) {
450 NTSTATUS Status
= STATUS_UNSUCCESSFUL
;
452 switch( OskitError
) {
453 case 0: Status
= STATUS_SUCCESS
; break;
454 case OSK_EADDRNOTAVAIL
:
455 case OSK_EAFNOSUPPORT
: Status
= STATUS_INVALID_CONNECTION
; break;
456 case OSK_ECONNREFUSED
:
457 case OSK_ECONNRESET
: Status
= STATUS_REMOTE_NOT_LISTENING
; break;
458 case OSK_EINPROGRESS
:
459 case OSK_EAGAIN
: Status
= STATUS_PENDING
; break;
460 default: Status
= STATUS_INVALID_CONNECTION
; break;
463 TI_DbgPrint(DEBUG_TCP
,("Error %d -> %x\n", OskitError
, Status
));
468 ( PCONNECTION_ENDPOINT Connection
,
469 PTDI_CONNECTION_INFORMATION ConnInfo
,
470 PTDI_CONNECTION_INFORMATION ReturnInfo
,
471 PTCP_COMPLETION_ROUTINE Complete
,
474 SOCKADDR_IN AddressToConnect
= { 0 }, AddressToBind
= { 0 };
475 IP_ADDRESS RemoteAddress
;
479 DbgPrint("TCPConnect: Called\n");
481 Bucket
= ExAllocatePool( NonPagedPool
, sizeof(*Bucket
) );
482 if( !Bucket
) return STATUS_NO_MEMORY
;
484 TcpipRecursiveMutexEnter( &TCPLock
, TRUE
);
486 /* Freed in TCPSocketState */
487 Bucket
->Request
.RequestNotifyObject
= (PVOID
)Complete
;
488 Bucket
->Request
.RequestContext
= Context
;
490 InsertHeadList( &Connection
->ConnectRequest
, &Bucket
->Entry
);
492 Status
= AddrBuildAddress
493 ((PTRANSPORT_ADDRESS
)ConnInfo
->RemoteAddress
,
497 DbgPrint("Connecting to address %x:%x\n",
498 RemoteAddress
.Address
.IPv4Address
,
501 if (!NT_SUCCESS(Status
)) {
502 TI_DbgPrint(DEBUG_TCP
, ("Could not AddrBuildAddress in TCPConnect\n"));
506 AddressToConnect
.sin_family
= AF_INET
;
507 AddressToBind
= AddressToConnect
;
509 OskitTCPBind( Connection
->SocketContext
,
512 sizeof(AddressToBind
) );
514 memcpy( &AddressToConnect
.sin_addr
,
515 &RemoteAddress
.Address
.IPv4Address
,
516 sizeof(AddressToConnect
.sin_addr
) );
517 AddressToConnect
.sin_port
= RemotePort
;
519 Status
= TCPTranslateError
520 ( OskitTCPConnect( Connection
->SocketContext
,
523 sizeof(AddressToConnect
) ) );
525 TcpipRecursiveMutexLeave( &TCPLock
);
527 if( Status
== OSK_EINPROGRESS
)
528 return STATUS_PENDING
;
533 NTSTATUS TCPDisconnect
534 ( PCONNECTION_ENDPOINT Connection
,
536 PTDI_CONNECTION_INFORMATION ConnInfo
,
537 PTDI_CONNECTION_INFORMATION ReturnInfo
,
538 PTCP_COMPLETION_ROUTINE Complete
,
542 TI_DbgPrint(DEBUG_TCP
,("started\n"));
544 TcpipRecursiveMutexEnter( &TCPLock
, TRUE
);
546 switch( Flags
& (TDI_DISCONNECT_ABORT
| TDI_DISCONNECT_RELEASE
) ) {
548 case TDI_DISCONNECT_ABORT
:
552 case TDI_DISCONNECT_ABORT
| TDI_DISCONNECT_RELEASE
:
556 case TDI_DISCONNECT_RELEASE
:
561 Status
= TCPTranslateError
562 ( OskitTCPShutdown( Connection
->SocketContext
, Flags
) );
564 TcpipRecursiveMutexLeave( &TCPLock
);
566 TI_DbgPrint(DEBUG_TCP
,("finished %x\n", Status
));
572 ( PCONNECTION_ENDPOINT Connection
) {
575 TI_DbgPrint(DEBUG_TCP
,("TCPClose started\n"));
577 TcpipRecursiveMutexEnter( &TCPLock
, TRUE
);
579 Status
= TCPTranslateError( OskitTCPClose( Connection
->SocketContext
) );
581 /* Make our code remove all pending IRPs */
582 Connection
->State
|= SEL_FIN
;
585 TcpipRecursiveMutexLeave( &TCPLock
);
587 TI_DbgPrint(DEBUG_TCP
,("TCPClose finished %x\n", Status
));
592 NTSTATUS TCPReceiveData
593 ( PCONNECTION_ENDPOINT Connection
,
596 PULONG BytesReceived
,
598 PTCP_COMPLETION_ROUTINE Complete
,
600 OSK_PCHAR DataBuffer
;
601 UINT DataLen
, Received
= 0;
605 TI_DbgPrint(DEBUG_TCP
,("Called for %d bytes (on socket %x)\n",
606 ReceiveLength
, Connection
->SocketContext
));
608 ASSERT_KM_POINTER(Connection
->SocketContext
);
610 TcpipRecursiveMutexEnter( &TCPLock
, TRUE
);
612 NdisQueryBuffer( Buffer
, &DataBuffer
, &DataLen
);
614 TI_DbgPrint(DEBUG_TCP
,("TCP>|< Got an MDL %x (%x:%d)\n", Buffer
, DataBuffer
, DataLen
));
616 Status
= TCPTranslateError
618 ( Connection
->SocketContext
,
624 TI_DbgPrint(DEBUG_TCP
,("OskitTCPReceive: %x, %d\n", Status
, Received
));
626 /* Keep this request around ... there was no data yet */
627 if( Status
== STATUS_PENDING
) {
628 /* Freed in TCPSocketState */
629 Bucket
= ExAllocatePool( NonPagedPool
, sizeof(*Bucket
) );
631 TI_DbgPrint(DEBUG_TCP
,("Failed to allocate bucket\n"));
632 TcpipRecursiveMutexLeave( &TCPLock
);
633 return STATUS_NO_MEMORY
;
636 Bucket
->Request
.RequestNotifyObject
= Complete
;
637 Bucket
->Request
.RequestContext
= Context
;
640 InsertHeadList( &Connection
->ReceiveRequest
, &Bucket
->Entry
);
641 Status
= STATUS_PENDING
;
642 TI_DbgPrint(DEBUG_TCP
,("Queued read irp\n"));
644 TI_DbgPrint(DEBUG_TCP
,("Got status %x, bytes %d\n", Status
, Received
));
645 *BytesReceived
= Received
;
648 TcpipRecursiveMutexLeave( &TCPLock
);
650 TI_DbgPrint(DEBUG_TCP
,("Status %x\n", Status
));
656 ( PCONNECTION_ENDPOINT Connection
,
663 ASSERT_KM_POINTER(Connection
->SocketContext
);
665 TcpipRecursiveMutexEnter( &TCPLock
, TRUE
);
667 TI_DbgPrint(DEBUG_TCP
,("Connection = %x\n", Connection
));
668 TI_DbgPrint(DEBUG_TCP
,("Connection->SocketContext = %x\n",
669 Connection
->SocketContext
));
671 Status
= OskitTCPSend( Connection
->SocketContext
,
672 (OSK_PCHAR
)BufferData
, PacketSize
,
673 (PUINT
)DataUsed
, 0 );
675 TcpipRecursiveMutexLeave( &TCPLock
);
680 VOID
TCPTimeout(VOID
) {
681 /* Now handled by TimerThread */
684 UINT
TCPAllocatePort( UINT HintPort
) {
686 if( AllocatePort( &TCPPorts
, HintPort
) ) return HintPort
;
689 (MID_TRACE
,("We got a hint port but couldn't allocate it\n"));
692 } else return AllocatePortFromRange( &TCPPorts
, 1024, 5000 );
695 VOID
TCPFreePort( UINT Port
) {
696 DeallocatePort( &TCPPorts
, Port
);
699 NTSTATUS TCPGetPeerAddress
700 ( PCONNECTION_ENDPOINT Connection
,
701 PTRANSPORT_ADDRESS Address
) {
702 OSK_UINT LocalAddress
, RemoteAddress
;
703 OSK_UI16 LocalPort
, RemotePort
;
704 PTA_IP_ADDRESS AddressIP
= (PTA_IP_ADDRESS
)Address
;
706 TcpipRecursiveMutexEnter( &TCPLock
, TRUE
);
709 ( Connection
->SocketContext
,
710 &LocalAddress
, &LocalPort
,
711 &RemoteAddress
, &RemotePort
);
713 AddressIP
->TAAddressCount
= 1;
714 AddressIP
->Address
[0].AddressLength
= TDI_ADDRESS_LENGTH_IP
;
715 AddressIP
->Address
[0].AddressType
= TDI_ADDRESS_TYPE_IP
;
716 AddressIP
->Address
[0].Address
[0].sin_port
= RemotePort
;
717 AddressIP
->Address
[0].Address
[0].in_addr
= RemoteAddress
;
719 TcpipRecursiveMutexLeave( &TCPLock
);
721 return STATUS_SUCCESS
;
724 VOID
TCPRemoveIRP( PCONNECTION_ENDPOINT Endpoint
, PIRP Irp
) {
726 PLIST_ENTRY ListHead
[4];
731 ListHead
[0] = &Endpoint
->ReceiveRequest
;
732 ListHead
[1] = &Endpoint
->ConnectRequest
;
733 ListHead
[2] = &Endpoint
->ListenRequest
;
736 TcpipAcquireSpinLock( &Endpoint
->Lock
, &OldIrql
);
738 for( i
= 0; ListHead
[i
]; i
++ ) {
739 for( Entry
= ListHead
[i
]->Flink
;
740 Entry
!= ListHead
[i
];
741 Entry
= Entry
->Flink
) {
742 Bucket
= CONTAINING_RECORD( Entry
, TDI_BUCKET
, Entry
);
744 if( Bucket
->Request
.RequestContext
== Irp
) {
745 RemoveEntryList( &Bucket
->Entry
);
751 TcpipReleaseSpinLock( &Endpoint
->Lock
, OldIrql
);