From f29016dabe924c5077ba507330210e2c2b093e2b Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 18 Nov 2018 20:51:54 +0100 Subject: [PATCH] [TCPIP] Properly handle listening sockets We first check if a socket is listening before checking whether it has connections. This allows properly returning listening address. Furthermore, if it's listening, properly return status so that it displays nice in netstat. Result: https://twitter.com/HeisSpiter/status/1064245622323200000 :-) --- drivers/network/tcpip/tcpip/ninfo.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/network/tcpip/tcpip/ninfo.c b/drivers/network/tcpip/tcpip/ninfo.c index f57e183566d..54e9be4955c 100644 --- a/drivers/network/tcpip/tcpip/ninfo.c +++ b/drivers/network/tcpip/tcpip/ninfo.c @@ -188,12 +188,16 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile, 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 */ + + 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.dwLocalPort = AddrFile->Port;