Author: cgutman
Date: Sat May 16 05:24:21 2009
New Revision: 40933
URL:
http://svn.reactos.org/svn/reactos?rev=40933&view=rev
Log:
- Set up the TCP interface data as needed in TCPFindInterface
Modified:
trunk/reactos/drivers/network/tcpip/include/tcp.h
trunk/reactos/lib/drivers/ip/network/ip.c
trunk/reactos/lib/drivers/ip/transport/tcp/if.c
Modified: trunk/reactos/drivers/network/tcpip/include/tcp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/tcp.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/tcp.h [iso-8859-1] Sat May 16 05:24:21
2009
@@ -158,10 +158,6 @@
NTSTATUS TCPClose( PCONNECTION_ENDPOINT Connection );
-PVOID TCPPrepareInterface( PIP_INTERFACE IF );
-
-VOID TCPDisposeInterfaceData( PVOID Data );
-
NTSTATUS TCPTranslateError( int OskitError );
VOID TCPTimeout();
Modified: trunk/reactos/lib/drivers/ip/network/ip.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/ip.…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] Sat May 16 05:24:21 2009
@@ -219,6 +219,13 @@
TcpipInitializeSpinLock(&IF->Lock);
+ IF->TCPContext = exAllocatePool
+ ( NonPagedPool, sizeof(OSK_IFADDR) + 2 * sizeof( struct sockaddr_in ) );
+ if (!IF->TCPContext) {
+ exFreePool(IF);
+ return NULL;
+ }
+
#ifdef __NTDRIVER__
InsertTDIInterfaceEntity( IF );
#endif
@@ -241,6 +248,7 @@
RemoveTDIInterfaceEntity( IF );
#endif
+ exFreePool(IF->TCPContext);
exFreePool(IF);
}
@@ -263,9 +271,6 @@
TI_DbgPrint(MIN_TRACE, ("Could not add route due to insufficient
resources.\n"));
return;
}
-
- /* Allow TCP to hang some configuration on this interface */
- IF->TCPContext = TCPPrepareInterface( IF );
}
BOOLEAN IPRegisterInterface(
@@ -317,11 +322,6 @@
NCE = NBLocateNeighbor(&IF->Unicast);
if (NCE)
{
- if ( IF->TCPContext ) {
- TCPDisposeInterfaceData( IF->TCPContext );
- IF->TCPContext = NULL;
- }
-
TI_DbgPrint(DEBUG_IP,("Removing interface Addr %s\n",
A2S(&IF->Unicast)));
TI_DbgPrint(DEBUG_IP,(" Mask %s\n",
A2S(&IF->Netmask)));
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/if.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/t…
==============================================================================
--- 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 May 16 05:24:21 2009
@@ -30,17 +30,20 @@
* parameters.
*/
-PVOID TCPPrepareInterface( PIP_INTERFACE IF ) {
+POSK_IFADDR TCPGetInterfaceData( PIP_INTERFACE IF ) {
NTSTATUS Status;
- POSK_IFADDR ifaddr = exAllocatePool
- ( NonPagedPool, sizeof(*ifaddr) + 2 * sizeof( struct sockaddr_in ) );
- if( !ifaddr ) return NULL;
+ POSK_IFADDR ifaddr = IF->TCPContext;
+ ASSERT(ifaddr);
+
+ RtlZeroMemory(ifaddr, sizeof(OSK_IFADDR) + 2 * sizeof( struct sockaddr_in ));
+
struct sockaddr_in *addr_in = (struct sockaddr_in *)&ifaddr[1];
struct sockaddr_in *dstaddr_in = (struct sockaddr_in *)&addr_in[1];
TI_DbgPrint(DEBUG_TCPIF,("Called\n"));
ifaddr->ifa_dstaddr = (struct sockaddr *)dstaddr_in;
+
/* XXX - Point-to-point interfaces not supported yet */
memset( &ifaddr->ifa_dstaddr, 0, sizeof( struct sockaddr ) );
@@ -49,10 +52,9 @@
ADE_UNICAST,
(PULONG)&addr_in->sin_addr.s_addr );
- if( !NT_SUCCESS(Status) )
- addr_in->sin_addr.s_addr = 0;
+ ASSERT(NT_SUCCESS(Status));
- TI_DbgPrint(DEBUG_TCPIF,("Prepare interface %x : addr %x\n",
+ TI_DbgPrint(DEBUG_TCPIF,("interface %x : addr %x\n",
IF, addr_in->sin_addr.s_addr));
ifaddr->ifa_flags = 0; /* XXX what goes here? */
@@ -65,10 +67,6 @@
return ifaddr;
}
-VOID TCPDisposeInterfaceData( PVOID Ptr ) {
- exFreePool( Ptr );
-}
-
POSK_IFADDR TCPFindInterface( void *ClientData,
OSK_UINT AddrType,
OSK_UINT FindType,
@@ -77,6 +75,7 @@
PIP_INTERFACE IF;
IP_ADDRESS Destination;
struct sockaddr_in *addr_in = (struct sockaddr_in *)ReqAddr;
+ POSK_IFADDR InterfaceData;
TI_DbgPrint(DEBUG_TCPIF,("called for type %d\n", FindType));
@@ -91,19 +90,15 @@
TI_DbgPrint(DEBUG_TCPIF,("Address is %x\n", addr_in->sin_addr.s_addr));
IF = FindOnLinkInterface(&Destination);
+ if (!IF) return NULL;
- if (!IF || !IF->TCPContext) {
- /* TCPContext can be NULL if we don't have an IP address yet */
- TI_DbgPrint(DEBUG_TCPIF, ("No interface or TCP context (%x) (%x)\n",
- IF, IF ? IF->TCPContext : 0));
- return NULL;
- }
+ InterfaceData = TCPGetInterfaceData(IF);
addr_in = (struct sockaddr_in *)
- ((POSK_IFADDR)IF->TCPContext)->ifa_addr;
+ InterfaceData->ifa_addr;
TI_DbgPrint(DEBUG_TCPIF,("returning addr %x\n",
addr_in->sin_addr.s_addr));
- return IF->TCPContext;
+ return InterfaceData;
}