https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f29016dabe924c5077ba5…
commit f29016dabe924c5077ba507330210e2c2b093e2b
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Nov 18 20:51:54 2018 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sun Nov 18 20:51:54 2018 +0100
[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 | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/network/tcpip/tcpip/ninfo.c b/drivers/network/tcpip/tcpip/ninfo.c
index f57e183566..54e9be4955 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)
+ 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.State = 0; /* FIXME */
TcpRow.dwLocalAddr = AddrFile->Address.Address.IPv4Address;
TcpRow.dwLocalPort = AddrFile->Port;