Some improvements I've been sitting on.
[reactos.git] / reactos / drivers / lib / ip / transport / tcp / tcp.c
1 /*
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)
8 * REVISIONS:
9 * CSH 01/08-2000 Created
10 * arty 12/21/2004 Added accept
11 */
12
13 #include "precomp.h"
14
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;
22 PORT_SET TCPPorts;
23
24 static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
25 ULONG NewState ) {
26 NTSTATUS Status = STATUS_SUCCESS;
27 PTCP_COMPLETION_ROUTINE Complete;
28 PTDI_BUCKET Bucket;
29 PLIST_ENTRY Entry;
30 PIRP Irp;
31 PMDL Mdl;
32
33 TI_DbgPrint(MID_TRACE,("Handling signalled state on %x (%x)\n",
34 Connection, Connection->SocketContext));
35
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"));
42
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));
47
48 if( (NewState & (SEL_CONNECT | SEL_FIN)) ==
49 (SEL_CONNECT | SEL_FIN) )
50 Status = STATUS_CONNECTION_REFUSED;
51 else
52 Status = STATUS_SUCCESS;
53
54 Complete( Bucket->Request.RequestContext, Status, 0 );
55
56 /* Frees the bucket allocated in TCPConnect */
57 PoolFreeBuffer( Bucket );
58 }
59 }
60
61 if( NewState & SEL_ACCEPT ) {
62 /* Handle readable on a listening socket --
63 * TODO: Implement filtering
64 */
65
66 TI_DbgPrint(DEBUG_TCP,("Accepting new connection on %x (Queue: %s)\n",
67 Connection,
68 IsListEmpty(&Connection->ListenRequest) ?
69 "empty" : "nonempty"));
70
71 while( !IsListEmpty( &Connection->ListenRequest ) ) {
72 PIO_STACK_LOCATION IrpSp;
73
74 Entry = RemoveHeadList( &Connection->ListenRequest );
75 Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
76 Complete = Bucket->Request.RequestNotifyObject;
77
78 Irp = Bucket->Request.RequestContext;
79 IrpSp = IoGetCurrentIrpStackLocation( Irp );
80
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 );
86
87 TI_DbgPrint(DEBUG_TCP,("Socket: Status: %x\n"));
88
89 if( Status == STATUS_PENDING ) {
90 InsertHeadList( &Connection->ListenRequest, &Bucket->Entry );
91 break;
92 } else
93 Complete( Bucket->Request.RequestContext, Status, 0 );
94 }
95 }
96
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"));
102
103 while( !IsListEmpty( &Connection->ReceiveRequest ) ) {
104 OSK_UINT RecvLen = 0, Received = 0;
105 OSK_PCHAR RecvBuffer = 0;
106
107 Entry = RemoveHeadList( &Connection->ReceiveRequest );
108 Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
109 Complete = Bucket->Request.RequestNotifyObject;
110
111 Irp = Bucket->Request.RequestContext;
112 Mdl = Irp->MdlAddress;
113
114 TI_DbgPrint(DEBUG_TCP,
115 ("Getting the user buffer from %x\n", Mdl));
116
117 NdisQueryBuffer( Mdl, &RecvBuffer, &RecvLen );
118
119 TI_DbgPrint(DEBUG_TCP,
120 ("Reading %d bytes to %x\n", RecvLen, RecvBuffer));
121
122 TI_DbgPrint(DEBUG_TCP, ("Connection: %x\n", Connection));
123 TI_DbgPrint
124 (DEBUG_TCP,
125 ("Connection->SocketContext: %x\n",
126 Connection->SocketContext));
127 TI_DbgPrint(DEBUG_TCP, ("RecvBuffer: %x\n", RecvBuffer));
128
129 Status = TCPTranslateError
130 ( OskitTCPRecv( Connection->SocketContext,
131 RecvBuffer,
132 RecvLen,
133 &Received,
134 0 ) );
135
136 TI_DbgPrint(DEBUG_TCP,("TCP Bytes: %d\n", Received));
137
138 if( Status == STATUS_SUCCESS ) {
139 TI_DbgPrint(DEBUG_TCP,("Received %d bytes with status %x\n",
140 Received, Status));
141
142 Complete( Bucket->Request.RequestContext,
143 STATUS_SUCCESS, Received );
144 } else if( Status == STATUS_PENDING ) {
145 InsertHeadList
146 ( &Connection->ReceiveRequest, &Bucket->Entry );
147 break;
148 } else {
149 TI_DbgPrint(DEBUG_TCP,
150 ("Completing Receive request: %x %x\n",
151 Bucket->Request, Status));
152 Complete( Bucket->Request.RequestContext, Status, 0 );
153 }
154 }
155 }
156
157 if( NewState & SEL_FIN ) {
158 PLIST_ENTRY ListsToErase[4];
159 NTSTATUS IrpStatus[4];
160 UINT i;
161
162 TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
163
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;
170 ListsToErase[3] = 0;
171
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 );
178 }
179 }
180 }
181
182 Connection->Signalled = FALSE;
183 }
184
185 VOID DrainSignals() {
186 PCONNECTION_ENDPOINT Connection;
187 PLIST_ENTRY ListEntry;
188
189 while( !IsListEmpty( &SignalledConnections ) ) {
190 ListEntry = RemoveHeadList( &SignalledConnections );
191 Connection = CONTAINING_RECORD( ListEntry, CONNECTION_ENDPOINT,
192 SignalList );
193 HandleSignalledConnection( Connection, Connection->SignalState );
194 }
195 }
196
197 PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint( PVOID ClientContext ) {
198 PCONNECTION_ENDPOINT Connection =
199 ExAllocatePool(NonPagedPool, sizeof(CONNECTION_ENDPOINT));
200 if (!Connection)
201 return Connection;
202
203 TI_DbgPrint(DEBUG_CPOINT, ("Connection point file object allocated at (0x%X).\n", Connection));
204
205 RtlZeroMemory(Connection, sizeof(CONNECTION_ENDPOINT));
206
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);
212
213 /* Save client context pointer */
214 Connection->ClientContext = ClientContext;
215
216 return Connection;
217 }
218
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 );
223 }
224
225 NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
226 UINT Family, UINT Type, UINT Proto ) {
227 NTSTATUS Status;
228
229 TI_DbgPrint(DEBUG_TCP,("Called: Connection %x, Family %d, Type %d, "
230 "Proto %d\n",
231 Connection, Family, Type, Proto));
232
233 TcpipRecursiveMutexEnter( &TCPLock, TRUE );
234 Status = TCPTranslateError( OskitTCPSocket( Connection,
235 &Connection->SocketContext,
236 Family,
237 Type,
238 Proto ) );
239
240 ASSERT_KM_POINTER(Connection->SocketContext);
241
242 TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext %x\n",
243 Connection->SocketContext));
244
245 TcpipRecursiveMutexLeave( &TCPLock );
246
247 return Status;
248 }
249
250 VOID TCPReceive(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
251 /*
252 * FUNCTION: Receives and queues TCP data
253 * ARGUMENTS:
254 * IPPacket = Pointer to an IP packet that was received
255 * NOTES:
256 * This is the low level interface for receiving TCP data
257 */
258 {
259 TI_DbgPrint(DEBUG_TCP,("Sending packet %d (%d) to oskit\n",
260 IPPacket->TotalSize,
261 IPPacket->HeaderSize));
262
263 TcpipRecursiveMutexEnter( &TCPLock, TRUE );
264
265 OskitTCPReceiveDatagram( IPPacket->Header,
266 IPPacket->TotalSize,
267 IPPacket->HeaderSize );
268
269 DrainSignals();
270
271 TcpipRecursiveMutexLeave( &TCPLock );
272 }
273
274 /* event.c */
275 int TCPSocketState( void *ClientData,
276 void *WhichSocket,
277 void *WhichConnection,
278 OSK_UINT NewState );
279
280 int TCPPacketSend( void *ClientData,
281 OSK_PCHAR Data,
282 OSK_UINT Len );
283
284 POSK_IFADDR TCPFindInterface( void *ClientData,
285 OSK_UINT AddrType,
286 OSK_UINT FindType,
287 OSK_SOCKADDR *ReqAddr );
288
289 void *TCPMalloc( void *ClientData,
290 OSK_UINT bytes, OSK_PCHAR file, OSK_UINT line );
291 void TCPFree( void *ClientData,
292 void *data, OSK_PCHAR file, OSK_UINT line );
293
294 int TCPSleep( void *ClientData, void *token, int priority, char *msg,
295 int tmio );
296
297 void TCPWakeup( void *ClientData, void *token );
298
299 OSKITTCP_EVENT_HANDLERS EventHandlers = {
300 NULL, /* Client Data */
301 TCPSocketState, /* SocketState */
302 TCPPacketSend, /* PacketSend */
303 TCPFindInterface, /* FindInterface */
304 TCPMalloc, /* Malloc */
305 TCPFree, /* Free */
306 TCPSleep, /* Sleep */
307 TCPWakeup /* Wakeup */
308 };
309
310 NTSTATUS TCPStartup(VOID)
311 /*
312 * FUNCTION: Initializes the TCP subsystem
313 * RETURNS:
314 * Status of operation
315 */
316 {
317 TcpipRecursiveMutexInit( &TCPLock );
318 ExInitializeFastMutex( &SleepingThreadsLock );
319 InitializeListHead( &SleepingThreadsList );
320 InitializeListHead( &SignalledConnections );
321
322 PortsStartup( &TCPPorts, 1, 0xfffe );
323
324 RegisterOskitTCPEventHandlers( &EventHandlers );
325 InitOskitTCP();
326
327 /* Register this protocol with IP layer */
328 IPRegisterProtocol(IPPROTO_TCP, TCPReceive);
329
330 ExInitializeNPagedLookasideList(
331 &TCPSegmentList, /* Lookaside list */
332 NULL, /* Allocate routine */
333 NULL, /* Free routine */
334 0, /* Flags */
335 sizeof(TCP_SEGMENT), /* Size of each entry */
336 TAG('T','C','P','S'), /* Tag */
337 0); /* Depth */
338
339 TCPInitialized = TRUE;
340
341 return STATUS_SUCCESS;
342 }
343
344
345 NTSTATUS TCPShutdown(VOID)
346 /*
347 * FUNCTION: Shuts down the TCP subsystem
348 * RETURNS:
349 * Status of operation
350 */
351 {
352 if (!TCPInitialized)
353 return STATUS_SUCCESS;
354
355 /* Deregister this protocol with IP layer */
356 IPRegisterProtocol(IPPROTO_TCP, NULL);
357
358 ExDeleteNPagedLookasideList(&TCPSegmentList);
359
360 TCPInitialized = FALSE;
361
362 DeinitOskitTCP();
363
364 PortsShutdown( &TCPPorts );
365
366 return STATUS_SUCCESS;
367 }
368
369 NTSTATUS TCPTranslateError( int OskitError ) {
370 NTSTATUS Status = STATUS_UNSUCCESSFUL;
371
372 switch( OskitError ) {
373 case 0: Status = STATUS_SUCCESS; break;
374 case OSK_EADDRNOTAVAIL:
375 case OSK_EAFNOSUPPORT: Status = STATUS_INVALID_CONNECTION; break;
376 case OSK_ECONNREFUSED:
377 case OSK_ECONNRESET: Status = STATUS_REMOTE_NOT_LISTENING; break;
378 case OSK_EINPROGRESS:
379 case OSK_EAGAIN: Status = STATUS_PENDING; break;
380 default: Status = STATUS_INVALID_CONNECTION; break;
381 }
382
383 TI_DbgPrint(DEBUG_TCP,("Error %d -> %x\n", OskitError, Status));
384 return Status;
385 }
386
387 NTSTATUS TCPConnect
388 ( PCONNECTION_ENDPOINT Connection,
389 PTDI_CONNECTION_INFORMATION ConnInfo,
390 PTDI_CONNECTION_INFORMATION ReturnInfo,
391 PTCP_COMPLETION_ROUTINE Complete,
392 PVOID Context ) {
393 NTSTATUS Status;
394 SOCKADDR_IN AddressToConnect = { 0 }, AddressToBind = { 0 };
395 IP_ADDRESS RemoteAddress;
396 USHORT RemotePort;
397 PTDI_BUCKET Bucket;
398
399 DbgPrint("TCPConnect: Called\n");
400
401 Bucket = ExAllocatePool( NonPagedPool, sizeof(*Bucket) );
402 if( !Bucket ) return STATUS_NO_MEMORY;
403
404 TcpipRecursiveMutexEnter( &TCPLock, TRUE );
405
406 /* Freed in TCPSocketState */
407 Bucket->Request.RequestNotifyObject = (PVOID)Complete;
408 Bucket->Request.RequestContext = Context;
409
410 InsertHeadList( &Connection->ConnectRequest, &Bucket->Entry );
411
412 Status = AddrBuildAddress
413 ((PTRANSPORT_ADDRESS)ConnInfo->RemoteAddress,
414 &RemoteAddress,
415 &RemotePort);
416
417 DbgPrint("Connecting to address %x:%x\n",
418 RemoteAddress.Address.IPv4Address,
419 RemotePort);
420
421 if (!NT_SUCCESS(Status)) {
422 TI_DbgPrint(DEBUG_TCP, ("Could not AddrBuildAddress in TCPConnect\n"));
423 return Status;
424 }
425
426 AddressToConnect.sin_family = AF_INET;
427 AddressToBind = AddressToConnect;
428
429 OskitTCPBind( Connection->SocketContext,
430 Connection,
431 &AddressToBind,
432 sizeof(AddressToBind) );
433
434 memcpy( &AddressToConnect.sin_addr,
435 &RemoteAddress.Address.IPv4Address,
436 sizeof(AddressToConnect.sin_addr) );
437 AddressToConnect.sin_port = RemotePort;
438
439 Status = TCPTranslateError
440 ( OskitTCPConnect( Connection->SocketContext,
441 Connection,
442 &AddressToConnect,
443 sizeof(AddressToConnect) ) );
444
445 TcpipRecursiveMutexLeave( &TCPLock );
446
447 if( Status == OSK_EINPROGRESS )
448 return STATUS_PENDING;
449 else
450 return Status;
451 }
452
453 NTSTATUS TCPDisconnect
454 ( PCONNECTION_ENDPOINT Connection,
455 UINT Flags,
456 PTDI_CONNECTION_INFORMATION ConnInfo,
457 PTDI_CONNECTION_INFORMATION ReturnInfo,
458 PTCP_COMPLETION_ROUTINE Complete,
459 PVOID Context ) {
460 NTSTATUS Status;
461
462 TI_DbgPrint(DEBUG_TCP,("started\n"));
463
464 TcpipRecursiveMutexEnter( &TCPLock, TRUE );
465
466 switch( Flags & (TDI_DISCONNECT_ABORT | TDI_DISCONNECT_RELEASE) ) {
467 case 0:
468 case TDI_DISCONNECT_ABORT:
469 Flags = 0;
470 break;
471
472 case TDI_DISCONNECT_ABORT | TDI_DISCONNECT_RELEASE:
473 Flags = 2;
474 break;
475
476 case TDI_DISCONNECT_RELEASE:
477 Flags = 1;
478 break;
479 }
480
481 Status = TCPTranslateError
482 ( OskitTCPShutdown( Connection->SocketContext, Flags ) );
483
484 TcpipRecursiveMutexLeave( &TCPLock );
485
486 TI_DbgPrint(DEBUG_TCP,("finished %x\n", Status));
487
488 return Status;
489 }
490
491 NTSTATUS TCPClose
492 ( PCONNECTION_ENDPOINT Connection ) {
493 NTSTATUS Status;
494
495 TI_DbgPrint(DEBUG_TCP,("TCPClose started\n"));
496
497 TcpipRecursiveMutexEnter( &TCPLock, TRUE );
498
499 Status = TCPTranslateError( OskitTCPClose( Connection->SocketContext ) );
500
501 /* Make our code remove all pending IRPs */
502 Connection->State |= SEL_FIN;
503 DrainSignals();
504
505 TcpipRecursiveMutexLeave( &TCPLock );
506
507 TI_DbgPrint(DEBUG_TCP,("TCPClose finished %x\n", Status));
508
509 return Status;
510 }
511
512 NTSTATUS TCPReceiveData
513 ( PCONNECTION_ENDPOINT Connection,
514 PNDIS_BUFFER Buffer,
515 ULONG ReceiveLength,
516 PULONG BytesReceived,
517 ULONG ReceiveFlags,
518 PTCP_COMPLETION_ROUTINE Complete,
519 PVOID Context ) {
520 OSK_PCHAR DataBuffer;
521 UINT DataLen, Received = 0;
522 NTSTATUS Status;
523 PTDI_BUCKET Bucket;
524
525 TI_DbgPrint(DEBUG_TCP,("Called for %d bytes (on socket %x)\n",
526 ReceiveLength, Connection->SocketContext));
527
528 ASSERT_KM_POINTER(Connection->SocketContext);
529
530 TcpipRecursiveMutexEnter( &TCPLock, TRUE );
531
532 NdisQueryBuffer( Buffer, &DataBuffer, &DataLen );
533
534 TI_DbgPrint(DEBUG_TCP,("TCP>|< Got an MDL %x (%x:%d)\n", Buffer, DataBuffer, DataLen));
535
536 Status = TCPTranslateError
537 ( OskitTCPRecv
538 ( Connection->SocketContext,
539 DataBuffer,
540 DataLen,
541 &Received,
542 ReceiveFlags ) );
543
544 TI_DbgPrint(DEBUG_TCP,("OskitTCPReceive: %x, %d\n", Status, Received));
545
546 /* Keep this request around ... there was no data yet */
547 if( Status == STATUS_PENDING ) {
548 /* Freed in TCPSocketState */
549 Bucket = ExAllocatePool( NonPagedPool, sizeof(*Bucket) );
550 if( !Bucket ) {
551 TI_DbgPrint(DEBUG_TCP,("Failed to allocate bucket\n"));
552 TcpipRecursiveMutexLeave( &TCPLock );
553 return STATUS_NO_MEMORY;
554 }
555
556 Bucket->Request.RequestNotifyObject = Complete;
557 Bucket->Request.RequestContext = Context;
558 *BytesReceived = 0;
559
560 InsertHeadList( &Connection->ReceiveRequest, &Bucket->Entry );
561 Status = STATUS_PENDING;
562 TI_DbgPrint(DEBUG_TCP,("Queued read irp\n"));
563 } else {
564 TI_DbgPrint(DEBUG_TCP,("Got status %x, bytes %d\n", Status, Received));
565 *BytesReceived = Received;
566 }
567
568 TcpipRecursiveMutexLeave( &TCPLock );
569
570 TI_DbgPrint(DEBUG_TCP,("Status %x\n", Status));
571
572 return Status;
573 }
574
575 NTSTATUS TCPSendData
576 ( PCONNECTION_ENDPOINT Connection,
577 PCHAR BufferData,
578 ULONG PacketSize,
579 PULONG DataUsed,
580 ULONG Flags) {
581 NTSTATUS Status;
582
583 ASSERT_KM_POINTER(Connection->SocketContext);
584
585 TcpipRecursiveMutexEnter( &TCPLock, TRUE );
586
587 TI_DbgPrint(DEBUG_TCP,("Connection = %x\n", Connection));
588 TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext = %x\n",
589 Connection->SocketContext));
590
591 Status = OskitTCPSend( Connection->SocketContext,
592 (OSK_PCHAR)BufferData, PacketSize,
593 (PUINT)DataUsed, 0 );
594
595 TcpipRecursiveMutexLeave( &TCPLock );
596
597 return Status;
598 }
599
600 VOID TCPTimeout(VOID) {
601 static int Times = 0;
602 TcpipRecursiveMutexEnter( &TCPLock, TRUE );
603 if( (Times++ % 5) == 0 ) {
604 TimerOskitTCP();
605 }
606 DrainSignals();
607 TcpipRecursiveMutexLeave( &TCPLock );
608 }
609
610 UINT TCPAllocatePort( UINT HintPort ) {
611 if( HintPort ) {
612 if( AllocatePort( &TCPPorts, HintPort ) ) return HintPort;
613 else {
614 TI_DbgPrint
615 (MID_TRACE,("We got a hint port but couldn't allocate it\n"));
616 return (UINT)-1;
617 }
618 } else return AllocatePortFromRange( &TCPPorts, 1024, 5000 );
619 }
620
621 VOID TCPFreePort( UINT Port ) {
622 DeallocatePort( &TCPPorts, Port );
623 }
624
625 NTSTATUS TCPGetPeerAddress
626 ( PCONNECTION_ENDPOINT Connection,
627 PTRANSPORT_ADDRESS Address ) {
628 OSK_UINT LocalAddress, RemoteAddress;
629 OSK_UI16 LocalPort, RemotePort;
630 PTA_IP_ADDRESS AddressIP = (PTA_IP_ADDRESS)Address;
631
632 TcpipRecursiveMutexEnter( &TCPLock, TRUE );
633
634 OskitTCPGetAddress
635 ( Connection->SocketContext,
636 &LocalAddress, &LocalPort,
637 &RemoteAddress, &RemotePort );
638
639 AddressIP->TAAddressCount = 1;
640 AddressIP->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
641 AddressIP->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
642 AddressIP->Address[0].Address[0].sin_port = RemotePort;
643 AddressIP->Address[0].Address[0].in_addr = RemoteAddress;
644
645 TcpipRecursiveMutexLeave( &TCPLock );
646
647 return STATUS_SUCCESS;
648 }
649
650 /* EOF */