Commit in reactos/drivers/lib/ip on MAIN
makefile+2-11.6 -> 1.7
network/ports.c+60added 1.1
transport/datagram/datagram.c+13-151.3 -> 1.4
+75-16
1 added + 2 modified, total 3 files
Added port allocation.
Datagram: only match a sender if a sender match was specified.

reactos/drivers/lib/ip
makefile 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- makefile	7 Nov 2004 20:37:20 -0000	1.6
+++ makefile	14 Nov 2004 21:28:21 -0000	1.7
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.6 2004/11/07 20:37:20 arty Exp $
+# $Id: makefile,v 1.7 2004/11/14 21:28:21 arty Exp $
 
 PATH_TO_TOP = ../../..
 
@@ -32,6 +32,7 @@
 	network/loopback.o \
 	network/memtrack.o \
 	network/neighbor.o \
+	network/ports.o \
 	network/prefix.o \
 	network/receive.o \
 	network/route.o \

reactos/drivers/lib/ip/network
ports.c added at 1.1
diff -N ports.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ports.c	14 Nov 2004 21:28:21 -0000	1.1
@@ -0,0 +1,60 @@
+/*
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS TCP/IP protocol driver
+ * FILE:        tcpip/ports.c
+ * PURPOSE:     Port allocation
+ * PROGRAMMERS: arty (ayerkes@speakeasy.net)
+ * REVISIONS:
+ *   arty 20041114 Created
+ */
+
+#include "precomp.h"
+
+VOID PortsStartup( PPORT_SET PortSet, 
+		   UINT StartingPort,
+		   UINT PortsToManage ) {
+    PortSet->StartingPort = StartingPort;
+    PortSet->PortsToOversee = PortsToManage;
+    PortSet->ProtoBitBuffer = 
+	PoolAllocateBuffer( (PortSet->PortsToOversee + 7) / 8 );
+    RtlInitializeBitMap( &PortSet->ProtoBitmap, 
+			 PortSet->ProtoBitBuffer,
+			 PortSet->PortsToOversee );
+    ExInitializeFastMutex( &PortSet->Mutex );
+}
+
+VOID PortsShutdown( PPORT_SET PortSet ) {
+    PoolFreeBuffer( PortSet->ProtoBitBuffer );
+}
+
+VOID DeallocatePort( PPORT_SET PortSet, ULONG Port ) {
+    RtlClearBits( &PortSet->ProtoBitmap, 
+		  PortSet->StartingPort + Port, 1 );
+}
+
+BOOLEAN AllocatePort( PPORT_SET PortSet, ULONG Port ) {
+    BOOLEAN Clear;
+
+    Port -= PortSet->StartingPort;
+
+    ExAcquireFastMutex( &PortSet->Mutex );
+    Clear = RtlAreBitsClear( &PortSet->ProtoBitmap, Port, 1 );
+    if( Clear ) RtlSetBits( &PortSet->ProtoBitmap, Port, 1 );
+    ExReleaseFastMutex( &PortSet->Mutex );
+
+    return Clear;
+}
+
+ULONG AllocateAnyPort( PPORT_SET PortSet ) {
+    ULONG AllocatedPort;
+
+    ExAcquireFastMutex( &PortSet->Mutex );
+    AllocatedPort = RtlFindClearBits( &PortSet->ProtoBitmap, 1, 0 );
+    if( AllocatedPort != (ULONG)-1 ) {
+	RtlSetBits( &PortSet->ProtoBitmap, AllocatedPort, 1 );
+	AllocatedPort += PortSet->StartingPort;
+    }
+    ExReleaseFastMutex( &PortSet->Mutex );
+
+    return AllocatedPort;
+}

reactos/drivers/lib/ip/transport/datagram
datagram.c 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- datagram.c	7 Nov 2004 20:37:21 -0000	1.3
+++ datagram.c	14 Nov 2004 21:28:21 -0000	1.4
@@ -67,19 +67,18 @@
       while ((CurrentEntry != &AddrFile->ReceiveQueue) && (!Found))
         {
           Current = CONTAINING_RECORD(CurrentEntry, DATAGRAM_RECEIVE_REQUEST, ListEntry);
-	  if (AddrIsEqual(Address, &Current->RemoteAddress))
+
+	  if (!Current->RemotePort ||
+	      AddrIsEqual(Address, &Current->RemoteAddress)) {
             Found = TRUE;
-    
-          if (Found)
-            {
-              /* FIXME: Maybe we should check if the buffer of this
-                 receive request is large enough and if not, search
-                 for another */
-    
-              /* Remove the request from the queue */
-              RemoveEntryList(&Current->ListEntry);
-              break;
-            }
+	    /* FIXME: Maybe we should check if the buffer of this
+	       receive request is large enough and if not, search
+	       for another */
+	    
+	    /* Remove the request from the queue */
+	    RemoveEntryList(&Current->ListEntry);
+	    break;
+	  }
           CurrentEntry = CurrentEntry->Flink;
         }
 
@@ -95,9 +94,8 @@
 			 DataSize );
   
           /* Complete the receive request */
-          (*Current->Complete)(Current->Context, STATUS_SUCCESS, DataSize);
-    
-          exFreePool(Current);
+          Current->Complete(Current->Context, STATUS_SUCCESS, DataSize);
+	  exFreePool( Current );
         }
     }
   else if (AddrFile->RegisteredReceiveDatagramHandler)
CVSspam 0.2.8