mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[TCPIP] Implement enumerating TCP connections with owner PID
This commit is contained in:
parent
935978ee57
commit
411504b5f4
3 changed files with 30 additions and 13 deletions
|
@ -116,7 +116,8 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF,
|
|||
|
||||
TDI_STATUS InfoTdiQueryGetConnectionTcpTable( PADDRESS_FILE AddrFile,
|
||||
PNDIS_BUFFER Buffer,
|
||||
PUINT BufferSize);
|
||||
PUINT BufferSize,
|
||||
BOOLEAN Extended);
|
||||
|
||||
TDI_STATUS InfoTdiQueryGetConnectionUdpTable( PADDRESS_FILE AddrFile,
|
||||
PNDIS_BUFFER Buffer,
|
||||
|
|
|
@ -260,14 +260,19 @@ TDI_STATUS InfoTdiQueryInformationEx(
|
|||
return TDI_INVALID_PARAMETER;
|
||||
|
||||
case IP_MIB_ADDRTABLE_ENTRY_ID:
|
||||
if (ID->toi_entity.tei_entity != CL_NL_ENTITY &&
|
||||
ID->toi_entity.tei_entity != CO_NL_ENTITY)
|
||||
return TDI_INVALID_PARAMETER;
|
||||
|
||||
if (ID->toi_type != INFO_TYPE_PROVIDER)
|
||||
return TDI_INVALID_PARAMETER;
|
||||
|
||||
return InfoTdiQueryGetAddrTable(ID->toi_entity, Buffer, BufferSize);
|
||||
if (ID->toi_entity.tei_entity == CL_NL_ENTITY ||
|
||||
ID->toi_entity.tei_entity == CO_NL_ENTITY)
|
||||
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);
|
||||
else
|
||||
return TDI_INVALID_PARAMETER;
|
||||
else
|
||||
return TDI_INVALID_PARAMETER;
|
||||
|
||||
case IP_MIB_ARPTABLE_ENTRY_ID:
|
||||
if (ID->toi_type != INFO_TYPE_PROVIDER)
|
||||
|
@ -287,7 +292,7 @@ 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);
|
||||
return InfoTdiQueryGetConnectionTcpTable(EntityListContext, Buffer, BufferSize, FALSE);
|
||||
else
|
||||
return TDI_INVALID_PARAMETER;
|
||||
else if (ID->toi_entity.tei_entity == CL_TL_ENTITY)
|
||||
|
|
|
@ -181,15 +181,26 @@ TDI_STATUS InfoTdiQueryGetIPSnmpInfo( TDIEntityID ID,
|
|||
|
||||
TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile,
|
||||
PNDIS_BUFFER Buffer,
|
||||
PUINT BufferSize)
|
||||
PUINT BufferSize,
|
||||
BOOLEAN Extended)
|
||||
{
|
||||
MIB_TCPROW TcpRow;
|
||||
SIZE_T Size;
|
||||
MIB_TCPROW_OWNER_PID TcpRow;
|
||||
TDI_STATUS Status = TDI_SUCCESS;
|
||||
|
||||
TI_DbgPrint(DEBUG_INFO, ("Called.\n"));
|
||||
|
||||
TcpRow.dwLocalAddr = AddrFile->Address.Address.IPv4Address;
|
||||
TcpRow.dwLocalPort = AddrFile->Port;
|
||||
TcpRow.dwOwningPid = (DWORD)AddrFile->ProcessId;
|
||||
if (Extended)
|
||||
{
|
||||
Size = sizeof(MIB_TCPROW_OWNER_PID);
|
||||
}
|
||||
else
|
||||
{
|
||||
Size = sizeof(MIB_TCPROW);
|
||||
}
|
||||
|
||||
if (AddrFile->Listener != NULL)
|
||||
{
|
||||
|
@ -197,7 +208,7 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile,
|
|||
|
||||
EndPoint = AddrFile->Listener->AddressFile;
|
||||
|
||||
TcpRow.State = MIB_TCP_STATE_LISTEN;
|
||||
TcpRow.dwState = MIB_TCP_STATE_LISTEN;
|
||||
TcpRow.dwRemoteAddr = EndPoint->Address.Address.IPv4Address;
|
||||
TcpRow.dwRemotePort = EndPoint->Port;
|
||||
}
|
||||
|
@ -215,19 +226,19 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile,
|
|||
TcpRow.dwRemotePort = ntohs(EndPoint.Address[0].Address[0].sin_port);
|
||||
}
|
||||
|
||||
Status = TCPGetSocketStatus(AddrFile->Connection, (PULONG)&TcpRow.State);
|
||||
Status = TCPGetSocketStatus(AddrFile->Connection, &TcpRow.dwState);
|
||||
ASSERT(NT_SUCCESS(Status));
|
||||
}
|
||||
else
|
||||
{
|
||||
TcpRow.State = 0;
|
||||
TcpRow.dwState = 0;
|
||||
TcpRow.dwRemoteAddr = 0;
|
||||
TcpRow.dwRemotePort = 0;
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = InfoCopyOut( (PCHAR)&TcpRow, sizeof(TcpRow),
|
||||
Status = InfoCopyOut( (PCHAR)&TcpRow, Size,
|
||||
Buffer, BufferSize );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue