https://git.reactos.org/?p=reactos.git;a=commitdiff;h=655e66bdbd139742a7c74…
commit 655e66bdbd139742a7c747caab3a30c06faa5f4c
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Tue Nov 27 08:27:00 2018 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Tue Nov 27 21:36:41 2018 +0100
[TCPIP] Define a enum to select which information to return
---
drivers/network/tcpip/include/info.h | 10 ++++++++--
drivers/network/tcpip/tcpip/info.c | 8 ++++----
drivers/network/tcpip/tcpip/ninfo.c | 21 ++++++++++++++++-----
3 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/drivers/network/tcpip/include/info.h b/drivers/network/tcpip/include/info.h
index 358a8b0a5a..8866a01c5c 100644
--- a/drivers/network/tcpip/include/info.h
+++ b/drivers/network/tcpip/include/info.h
@@ -80,6 +80,12 @@ typedef union TDI_INFO {
TDI_PROVIDER_STATISTICS ProviderStats;
} TDI_INFO, *PTDI_INFO;
+typedef enum TDI_TCPUDP_CLASS_INFO {
+ TcpUdpClassBasic,
+ TcpUdpClassOwnerPid,
+ TcpUdpClassOwner
+} TDI_TCPUDP_CLASS_INFO, *PTDI_TCPUDP_CLASS_INFO;
+
TDI_STATUS InfoCopyOut( PCHAR DataOut, UINT SizeOut,
PNDIS_BUFFER ClientBuf, PUINT ClientBufSize );
@@ -117,12 +123,12 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF,
TDI_STATUS InfoTdiQueryGetConnectionTcpTable( PADDRESS_FILE AddrFile,
PNDIS_BUFFER Buffer,
PUINT BufferSize,
- BOOLEAN Extended);
+ TDI_TCPUDP_CLASS_INFO Class);
TDI_STATUS InfoTdiQueryGetConnectionUdpTable( PADDRESS_FILE AddrFile,
PNDIS_BUFFER Buffer,
PUINT BufferSize,
- BOOLEAN Extended);
+ TDI_TCPUDP_CLASS_INFO Class);
TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF,
PVOID Buffer,
diff --git a/drivers/network/tcpip/tcpip/info.c b/drivers/network/tcpip/tcpip/info.c
index b64e8619ed..674fb96049 100644
--- a/drivers/network/tcpip/tcpip/info.c
+++ b/drivers/network/tcpip/tcpip/info.c
@@ -268,12 +268,12 @@ TDI_STATUS InfoTdiQueryInformationEx(
return InfoTdiQueryGetAddrTable(ID->toi_entity, Buffer,
BufferSize);
else if (ID->toi_entity.tei_entity == CO_TL_ENTITY)
if ((EntityListContext = GetContext(ID->toi_entity)))
- return InfoTdiQueryGetConnectionTcpTable(EntityListContext,
Buffer, BufferSize, TRUE);
+ return InfoTdiQueryGetConnectionTcpTable(EntityListContext,
Buffer, BufferSize, TcpUdpClassOwnerPid);
else
return TDI_INVALID_PARAMETER;
else if (ID->toi_entity.tei_entity == CL_TL_ENTITY)
if ((EntityListContext = GetContext(ID->toi_entity)))
- return InfoTdiQueryGetConnectionUdpTable(EntityListContext,
Buffer, BufferSize, TRUE);
+ return InfoTdiQueryGetConnectionUdpTable(EntityListContext,
Buffer, BufferSize, TcpUdpClassOwnerPid);
else
return TDI_INVALID_PARAMETER;
else
@@ -297,12 +297,12 @@ TDI_STATUS InfoTdiQueryInformationEx(
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, FALSE);
+ return InfoTdiQueryGetConnectionTcpTable(EntityListContext,
Buffer, BufferSize, TcpUdpClassBasic);
else
return TDI_INVALID_PARAMETER;
else if (ID->toi_entity.tei_entity == CL_TL_ENTITY)
if ((EntityListContext = GetContext(ID->toi_entity)))
- return InfoTdiQueryGetConnectionUdpTable(EntityListContext,
Buffer, BufferSize, FALSE);
+ return InfoTdiQueryGetConnectionUdpTable(EntityListContext,
Buffer, BufferSize, TcpUdpClassBasic);
else
return TDI_INVALID_PARAMETER;
else
diff --git a/drivers/network/tcpip/tcpip/ninfo.c b/drivers/network/tcpip/tcpip/ninfo.c
index 5b7c706b8f..267c43f1d9 100644
--- a/drivers/network/tcpip/tcpip/ninfo.c
+++ b/drivers/network/tcpip/tcpip/ninfo.c
@@ -182,7 +182,7 @@ TDI_STATUS InfoTdiQueryGetIPSnmpInfo( TDIEntityID ID,
TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile,
PNDIS_BUFFER Buffer,
PUINT BufferSize,
- BOOLEAN Extended)
+ TDI_TCPUDP_CLASS_INFO Class)
{
SIZE_T Size;
MIB_TCPROW_OWNER_PID TcpRow;
@@ -191,12 +191,13 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE
AddrFile,
TI_DbgPrint(DEBUG_INFO, ("Called.\n"));
TcpRow.dwOwningPid = (DWORD)AddrFile->ProcessId;
- if (Extended)
+ if (Class == TcpUdpClassOwnerPid)
{
Size = sizeof(MIB_TCPROW_OWNER_PID);
}
else
{
+ ASSERT(Class != TcpUdpClassOwner);
Size = sizeof(MIB_TCPROW);
}
@@ -255,20 +256,30 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE
AddrFile,
TDI_STATUS InfoTdiQueryGetConnectionUdpTable(PADDRESS_FILE AddrFile,
PNDIS_BUFFER Buffer,
PUINT BufferSize,
- BOOLEAN Extended)
+ TDI_TCPUDP_CLASS_INFO Class)
{
+ SIZE_T Size;
MIB_UDPROW_OWNER_PID UdpRow;
TDI_STATUS Status = TDI_INVALID_REQUEST;
TI_DbgPrint(DEBUG_INFO, ("Called.\n"));
+ if (Class == TcpUdpClassOwnerPid)
+ {
+ Size = sizeof(MIB_UDPROW_OWNER_PID);
+ }
+ else
+ {
+ ASSERT(Class != TcpUdpClassOwner);
+ Size = sizeof(MIB_UDPROW);
+ }
+
UdpRow.dwLocalAddr = AddrFile->Address.Address.IPv4Address;
UdpRow.dwLocalPort = AddrFile->Port;
UdpRow.dwOwningPid = (DWORD)AddrFile->ProcessId;
Status = InfoCopyOut( (PCHAR)&UdpRow,
- (Extended ? sizeof(MIB_UDPROW_OWNER_PID) : sizeof(MIB_UDPROW)),
- Buffer, BufferSize );
+ Size, Buffer, BufferSize );
TI_DbgPrint(DEBUG_INFO, ("Returning %08x\n", Status));