[TCPIP] Implement returning TCP connections
authorPierre Schweitzer <pierre@reactos.org>
Sun, 18 Nov 2018 15:17:50 +0000 (16:17 +0100)
committerPierre Schweitzer <pierre@reactos.org>
Sun, 18 Nov 2018 15:30:45 +0000 (16:30 +0100)
CORE-5401

drivers/network/tcpip/include/info.h
drivers/network/tcpip/tcpip/info.c
drivers/network/tcpip/tcpip/ninfo.c

index 222f3d5..4d9d31e 100644 (file)
@@ -8,6 +8,10 @@
 #pragma once
 
 #include <tcpioctl.h>
+/* FIXME */
+#define DWORD ULONG
+#include <in6addr.h>
+#include <tcpmib.h>
 
 #define MAX_PHYSADDR_LEN 8
 #define MAX_IFDESCR_LEN  256
@@ -109,6 +113,10 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF,
                                       PNDIS_BUFFER Buffer,
                                       PUINT BufferSize );
 
+TDI_STATUS InfoTdiQueryGetConnectionTcpTable( PADDRESS_FILE AddrFile,
+                                              PNDIS_BUFFER Buffer,
+                                              PUINT BufferSize);
+
 TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF,
                            PVOID Buffer,
                            UINT BufferSize);
index 3dbe574..242b811 100644 (file)
@@ -285,6 +285,11 @@ TDI_STATUS InfoTdiQueryInformationEx(
                          return InfoTdiQueryGetRouteTable(EntityListContext, Buffer, BufferSize);
                      else
                          return TDI_INVALID_PARAMETER;
+                 else if (ID->toi_entity.tei_entity == CO_TL_ENTITY)
+                     if ((EntityListContext = GetContext(ID->toi_entity)))
+                         return InfoTdiQueryGetConnectionTcpTable(EntityListContext, Buffer, BufferSize);
+                     else
+                         return TDI_INVALID_PARAMETER;
                  else
                      return TDI_INVALID_PARAMETER;
 
index 182af70..280b894 100644 (file)
@@ -177,6 +177,45 @@ TDI_STATUS InfoTdiQueryGetIPSnmpInfo( TDIEntityID ID,
     return Status;
 }
 
+TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile,
+                                   PNDIS_BUFFER Buffer,
+                                   PUINT BufferSize)
+{
+    MIB_TCPROW TcpRow;
+    PADDRESS_FILE EndPoint;
+    TDI_STATUS Status = TDI_INVALID_REQUEST;
+
+    TI_DbgPrint(DEBUG_INFO, ("Called.\n"));
+
+    EndPoint = NULL;
+    if (AddrFile->Connection != NULL)
+        EndPoint = AddrFile->Connection->AddressFile;
+    else if (AddrFile->Listener != NULL)
+        EndPoint = AddrFile->Listener->AddressFile;
+
+    TcpRow.State = 0; /* FIXME */
+    TcpRow.dwLocalAddr = AddrFile->Address.Address.IPv4Address;
+    TcpRow.dwLocalPort = AddrFile->Port;
+
+    if (EndPoint != NULL)
+    {
+        TcpRow.dwRemoteAddr = EndPoint->Address.Address.IPv4Address;
+        TcpRow.dwRemotePort = EndPoint->Port;
+    }
+    else
+    {
+        TcpRow.dwRemoteAddr = 0;
+        TcpRow.dwRemotePort = 0;
+    }
+
+    Status = InfoCopyOut( (PCHAR)&TcpRow, sizeof(TcpRow),
+                         Buffer, BufferSize );
+
+    TI_DbgPrint(DEBUG_INFO, ("Returning %08x\n", Status));
+
+    return Status;
+}
+
 TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF, PVOID Buffer, UINT BufferSize)
 {
     IP_ADDRESS Address, Netmask, Router;