From 77d5f04f22fce0f4ba5108e21f8070d90b891177 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 18 Nov 2018 16:17:50 +0100 Subject: [PATCH] [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 222f3d56a30..4d9d31e8cd7 100644 --- a/drivers/network/tcpip/include/info.h +++ b/drivers/network/tcpip/include/info.h @@ -8,6 +8,10 @@ #pragma once #include +/* FIXME */ +#define DWORD ULONG +#include +#include #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 3dbe574a634..242b8112d94 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 182af705646..280b894aae7 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; -- 2.17.1