mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[TCPIP] Fix returned IP address when querying TCP connections
This gives something like that now: https://twitter.com/HeisSpiter/status/1065706156331606017 :-) CORE-15363
This commit is contained in:
parent
2403dea9b4
commit
500a5151ea
1 changed files with 28 additions and 15 deletions
|
@ -177,43 +177,56 @@ TDI_STATUS InfoTdiQueryGetIPSnmpInfo( TDIEntityID ID,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ntohs(n) ((((n) & 0xff) << 8) | (((n) & 0xff00) >> 8))
|
||||||
|
|
||||||
TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile,
|
TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile,
|
||||||
PNDIS_BUFFER Buffer,
|
PNDIS_BUFFER Buffer,
|
||||||
PUINT BufferSize)
|
PUINT BufferSize)
|
||||||
{
|
{
|
||||||
MIB_TCPROW TcpRow;
|
MIB_TCPROW TcpRow;
|
||||||
PADDRESS_FILE EndPoint;
|
TDI_STATUS Status = TDI_SUCCESS;
|
||||||
TDI_STATUS Status = TDI_INVALID_REQUEST;
|
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_INFO, ("Called.\n"));
|
TI_DbgPrint(DEBUG_INFO, ("Called.\n"));
|
||||||
|
|
||||||
EndPoint = NULL;
|
|
||||||
TcpRow.State = 0; /* FIXME */
|
TcpRow.State = 0; /* FIXME */
|
||||||
|
|
||||||
if (AddrFile->Listener != NULL)
|
|
||||||
{
|
|
||||||
EndPoint = AddrFile->Listener->AddressFile;
|
|
||||||
TcpRow.State = MIB_TCP_STATE_LISTEN;
|
|
||||||
}
|
|
||||||
else if (AddrFile->Connection != NULL)
|
|
||||||
EndPoint = AddrFile->Connection->AddressFile;
|
|
||||||
|
|
||||||
TcpRow.dwLocalAddr = AddrFile->Address.Address.IPv4Address;
|
TcpRow.dwLocalAddr = AddrFile->Address.Address.IPv4Address;
|
||||||
TcpRow.dwLocalPort = AddrFile->Port;
|
TcpRow.dwLocalPort = AddrFile->Port;
|
||||||
|
|
||||||
if (EndPoint != NULL)
|
if (AddrFile->Listener != NULL)
|
||||||
{
|
{
|
||||||
|
PADDRESS_FILE EndPoint;
|
||||||
|
|
||||||
|
EndPoint = AddrFile->Listener->AddressFile;
|
||||||
|
|
||||||
|
TcpRow.State = MIB_TCP_STATE_LISTEN;
|
||||||
TcpRow.dwRemoteAddr = EndPoint->Address.Address.IPv4Address;
|
TcpRow.dwRemoteAddr = EndPoint->Address.Address.IPv4Address;
|
||||||
TcpRow.dwRemotePort = EndPoint->Port;
|
TcpRow.dwRemotePort = EndPoint->Port;
|
||||||
}
|
}
|
||||||
|
else if (AddrFile->Connection != NULL &&
|
||||||
|
AddrFile->Connection->SocketContext != NULL)
|
||||||
|
{
|
||||||
|
TA_IP_ADDRESS EndPoint;
|
||||||
|
|
||||||
|
Status = TCPGetSockAddress(AddrFile->Connection, (PTRANSPORT_ADDRESS)&EndPoint, TRUE);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ASSERT(EndPoint.TAAddressCount >= 1);
|
||||||
|
ASSERT(EndPoint.Address[0].AddressLength == TDI_ADDRESS_LENGTH_IP);
|
||||||
|
TcpRow.dwRemoteAddr = EndPoint.Address[0].Address[0].in_addr;
|
||||||
|
TcpRow.dwRemotePort = ntohs(EndPoint.Address[0].Address[0].sin_port);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TcpRow.dwRemoteAddr = 0;
|
TcpRow.dwRemoteAddr = 0;
|
||||||
TcpRow.dwRemotePort = 0;
|
TcpRow.dwRemotePort = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = InfoCopyOut( (PCHAR)&TcpRow, sizeof(TcpRow),
|
if (NT_SUCCESS(Status))
|
||||||
Buffer, BufferSize );
|
{
|
||||||
|
Status = InfoCopyOut( (PCHAR)&TcpRow, sizeof(TcpRow),
|
||||||
|
Buffer, BufferSize );
|
||||||
|
}
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_INFO, ("Returning %08x\n", Status));
|
TI_DbgPrint(DEBUG_INFO, ("Returning %08x\n", Status));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue