[TCPIP DRIVER]
[reactos.git] / lib / drivers / ip / network / ip.c
index a24cd4e..c1d83ba 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "precomp.h"
 
+#define __LWIP_INET_H__
+#include "lwip/netifapi.h"
+
 
 LIST_ENTRY InterfaceListHead;
 KSPIN_LOCK InterfaceListLock;
@@ -21,6 +24,12 @@ BOOLEAN IpWorkItemQueued = FALSE;
 
 IP_PROTOCOL_HANDLER ProtocolTable[IP_PROTOCOL_TABLE_SIZE];
 
+VOID
+TCPRegisterInterface(PIP_INTERFACE IF);
+
+VOID
+TCPUnregisterInterface(PIP_INTERFACE IF);
+
 VOID DontFreePacket(
     PVOID Object)
 /*
@@ -63,9 +72,21 @@ PIP_PACKET IPInitializePacket(
 }
 
 
-void NTAPI IPTimeout( PVOID Context ) {
-    IpWorkItemQueued = FALSE;
-
+VOID NTAPI IPTimeoutDpcFn(PKDPC Dpc,
+                          PVOID DeferredContext,
+                          PVOID SystemArgument1,
+                          PVOID SystemArgument2)
+/*
+ * FUNCTION: Timeout DPC
+ * ARGUMENTS:
+ *     Dpc             = Pointer to our DPC object
+ *     DeferredContext = Pointer to context information (unused)
+ *     SystemArgument1 = Unused
+ *     SystemArgument2 = Unused
+ * NOTES:
+ *     This routine is dispatched once in a while to do maintainance jobs
+ */
+{
     /* Check if datagram fragments have taken too long to assemble */
     IPDatagramReassemblyTimeout();
 
@@ -162,13 +183,14 @@ PIP_INTERFACE IPCreateInterface(
 
     TcpipInitializeSpinLock(&IF->Lock);
 
-    IF->TCPContext = ExAllocatePoolWithTag
-       ( NonPagedPool, sizeof(OSK_IFADDR) + 3 * sizeof( struct sockaddr_in ),
-          OSKITTCP_CONTEXT_TAG );
+    IF->TCPContext = ExAllocatePool
+       ( NonPagedPool, sizeof(struct netif));
     if (!IF->TCPContext) {
         ExFreePoolWithTag(IF, IP_INTERFACE_TAG);
         return NULL;
     }
+    
+    TCPRegisterInterface(IF);
 
 #ifdef __NTDRIVER__
     InsertTDIInterfaceEntity( IF );
@@ -191,8 +213,10 @@ VOID IPDestroyInterface(
 #ifdef __NTDRIVER__
     RemoveTDIInterfaceEntity( IF );
 #endif
+    
+    TCPUnregisterInterface(IF);
 
-    ExFreePoolWithTag(IF->TCPContext, OSKITTCP_CONTEXT_TAG);
+    ExFreePool(IF->TCPContext);
     ExFreePoolWithTag(IF, IP_INTERFACE_TAG);
 }
 
@@ -219,6 +243,8 @@ VOID IPAddInterfaceRoute( PIP_INTERFACE IF ) {
      * other computers */
     if (IF != Loopback)
        ARPTransmit(NULL, NULL, IF);
+    
+    TCPUpdateInterfaceIPInformation(IF);
 }
 
 BOOLEAN IPRegisterInterface(