https://git.reactos.org/?p=reactos.git;a=commitdiff;h=77d5f04f22fce0f4ba510…
commit 77d5f04f22fce0f4ba5108e21f8070d90b891177
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Nov 18 16:17:50 2018 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sun Nov 18 16:30:45 2018 +0100
[TCPIP] Implement returning TCP connections
CORE-5401
---
drivers/network/tcpip/include/info.h | 8 ++++++++
drivers/network/tcpip/tcpip/info.c | 5 +++++
drivers/network/tcpip/tcpip/ninfo.c | 39 ++++++++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+)
diff --git a/drivers/network/tcpip/include/info.h b/drivers/network/tcpip/include/info.h
index 222f3d56a3..4d9d31e8cd 100644
--- a/drivers/network/tcpip/include/info.h
+++ b/drivers/network/tcpip/include/info.h
@@ -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);
diff --git a/drivers/network/tcpip/tcpip/info.c b/drivers/network/tcpip/tcpip/info.c
index 3dbe574a63..242b8112d9 100644
--- a/drivers/network/tcpip/tcpip/info.c
+++ b/drivers/network/tcpip/tcpip/info.c
@@ -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;
diff --git a/drivers/network/tcpip/tcpip/ninfo.c b/drivers/network/tcpip/tcpip/ninfo.c
index 182af70564..280b894aae 100644
--- a/drivers/network/tcpip/tcpip/ninfo.c
+++ b/drivers/network/tcpip/tcpip/ninfo.c
@@ -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;