https://git.reactos.org/?p=reactos.git;a=commitdiff;h=91b013d3877d9f3a08c21c...
commit 91b013d3877d9f3a08c21ce3cdec1950a34220f9 Author: Pierre Schweitzer pierre@reactos.org AuthorDate: Fri Nov 23 22:49:53 2018 +0100 Commit: Pierre Schweitzer pierre@reactos.org CommitDate: Fri Nov 23 22:51:35 2018 +0100
[TCPIP] When enumerating sockets, retrieve their state and return it
This fixes netstat not having any state when enumerating connections. Basically, now, our netstat produces stuff like: https://twitter.com/HeisSpiter/status/1065871999266955264 --- drivers/network/tcpip/include/tcp.h | 2 ++ drivers/network/tcpip/tcpip/ninfo.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/network/tcpip/include/tcp.h b/drivers/network/tcpip/include/tcp.h index 20147c77d7..6bb8280d5a 100644 --- a/drivers/network/tcpip/include/tcp.h +++ b/drivers/network/tcpip/include/tcp.h @@ -216,3 +216,5 @@ VOID CompleteBucket(PCONNECTION_ENDPOINT Connection, PTDI_BUCKET Bucket, const B
void LibTCPDumpPcb(PVOID SocketContext); + +NTSTATUS TCPGetSocketStatus(PCONNECTION_ENDPOINT Connection, PULONG State); diff --git a/drivers/network/tcpip/tcpip/ninfo.c b/drivers/network/tcpip/tcpip/ninfo.c index 42894767ea..d45b4bb1e5 100644 --- a/drivers/network/tcpip/tcpip/ninfo.c +++ b/drivers/network/tcpip/tcpip/ninfo.c @@ -188,7 +188,6 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile,
TI_DbgPrint(DEBUG_INFO, ("Called.\n"));
- TcpRow.State = 0; /* FIXME */ TcpRow.dwLocalAddr = AddrFile->Address.Address.IPv4Address; TcpRow.dwLocalPort = AddrFile->Port;
@@ -215,9 +214,13 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile, TcpRow.dwRemoteAddr = EndPoint.Address[0].Address[0].in_addr; TcpRow.dwRemotePort = ntohs(EndPoint.Address[0].Address[0].sin_port); } + + Status = TCPGetSocketStatus(AddrFile->Connection, (PULONG)&TcpRow.State); + ASSERT(NT_SUCCESS(Status)); } else { + TcpRow.State = 0; TcpRow.dwRemoteAddr = 0; TcpRow.dwRemotePort = 0; }