mirror of
https://github.com/reactos/reactos
synced 2025-10-07 08:52:45 +02:00
Compare commits
6 Commits
0.4.15-rel
...
netstat_cr
Author | SHA1 | Date | |
---|---|---|---|
|
71142b486c | ||
|
f09d9d9ad1 | ||
|
c39e0a5be4 | ||
|
62ed5f18a3 | ||
|
5db7c3b5d2 | ||
|
15f9460824 |
@@ -1,16 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS netstat utility
|
* PROJECT: ReactOS netstat utility
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: base/applications/network/netstat/netstat.c
|
|
||||||
* PURPOSE: display IP stack statistics
|
* PURPOSE: display IP stack statistics
|
||||||
* COPYRIGHT: Copyright 2005 Ged Murphy <gedmurphy@gmail.com>
|
* COPYRIGHT: Copyright 2005 Ged Murphy <gedmurphy@gmail.com>
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* TODO:
|
||||||
* sort function return values.
|
|
||||||
* implement -b, -t and -v
|
* implement -b, -t and -v
|
||||||
* clean up GetIpHostName
|
* clean up GetIpHostName
|
||||||
* command line parser needs more work
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -62,9 +59,19 @@ VOID DoFormatMessage(DWORD ErrorCode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
* Display table header
|
||||||
|
*/
|
||||||
|
VOID DisplayTableHeader(VOID)
|
||||||
|
{
|
||||||
|
ConResPuts(StdOut, IDS_DISPLAY_THEADER);
|
||||||
|
if (bDoShowProcessId)
|
||||||
|
ConResPuts(StdOut, IDS_DISPLAY_PROCESS);
|
||||||
|
else
|
||||||
|
ConPuts(StdOut, L"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
* Parse command line parameters and set any options
|
* Parse command line parameters and set any options
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
BOOL ParseCmdline(int argc, wchar_t* argv[])
|
BOOL ParseCmdline(int argc, wchar_t* argv[])
|
||||||
{
|
{
|
||||||
@@ -103,6 +110,13 @@ BOOL ParseCmdline(int argc, wchar_t* argv[])
|
|||||||
break;
|
break;
|
||||||
case L'p':
|
case L'p':
|
||||||
bDoShowProtoCons = TRUE;
|
bDoShowProtoCons = TRUE;
|
||||||
|
if (i+1 >= argc)
|
||||||
|
{
|
||||||
|
ConResPuts(StdOut, IDS_ACTIVE_CONNECT);
|
||||||
|
DisplayTableHeader();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
Proto = argv[i+1];
|
Proto = argv[i+1];
|
||||||
if (!_wcsicmp(L"IP", Proto))
|
if (!_wcsicmp(L"IP", Proto))
|
||||||
Protocol = IP;
|
Protocol = IP;
|
||||||
@@ -113,10 +127,7 @@ BOOL ParseCmdline(int argc, wchar_t* argv[])
|
|||||||
else if (!_wcsicmp(L"UDP", Proto))
|
else if (!_wcsicmp(L"UDP", Proto))
|
||||||
Protocol = UDP;
|
Protocol = UDP;
|
||||||
else
|
else
|
||||||
{
|
goto StopParsingAndShowUsageHelp;
|
||||||
ConResPuts(StdErr, IDS_USAGE);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case L'r':
|
case L'r':
|
||||||
bDoShowRouteTable = TRUE;
|
bDoShowRouteTable = TRUE;
|
||||||
@@ -134,6 +145,7 @@ BOOL ParseCmdline(int argc, wchar_t* argv[])
|
|||||||
bDoDispSeqComp = TRUE;
|
bDoDispSeqComp = TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
StopParsingAndShowUsageHelp:
|
||||||
ConResPuts(StdErr, IDS_USAGE);
|
ConResPuts(StdErr, IDS_USAGE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -146,28 +158,11 @@ BOOL ParseCmdline(int argc, wchar_t* argv[])
|
|||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// ConResPrintf(StdErr, IDS_USAGE);
|
|
||||||
// return FALSE;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Display table header
|
|
||||||
*/
|
|
||||||
VOID DisplayTableHeader(VOID)
|
|
||||||
{
|
|
||||||
ConResPuts(StdOut, IDS_DISPLAY_THEADER);
|
|
||||||
if (bDoShowProcessId)
|
|
||||||
ConResPuts(StdOut, IDS_DISPLAY_PROCESS);
|
|
||||||
else
|
|
||||||
ConPuts(StdOut, L"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simulate Microsofts netstat utility output
|
* Simulate Microsofts netstat utility output
|
||||||
*/
|
*/
|
||||||
@@ -323,7 +318,6 @@ VOID ShowIcmpStatistics(VOID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, pIcmpStats);
|
HeapFree(GetProcessHeap(), 0, pIcmpStats);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ShowTcpStatistics(VOID)
|
VOID ShowTcpStatistics(VOID)
|
||||||
@@ -511,7 +505,6 @@ BOOL ShowUdpTable(VOID)
|
|||||||
/* Dump the UDP table */
|
/* Dump the UDP table */
|
||||||
for (i = 0; i < udpTable->dwNumEntries; i++)
|
for (i = 0; i < udpTable->dwNumEntries; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* I've split this up so it's easier to follow */
|
/* I've split this up so it's easier to follow */
|
||||||
GetIpHostName(TRUE, udpTable->table[i].dwLocalAddr, HostIp, sizeof(HostIp));
|
GetIpHostName(TRUE, udpTable->table[i].dwLocalAddr, HostIp, sizeof(HostIp));
|
||||||
GetPortName(udpTable->table[i].dwLocalPort, "udp", HostPort, sizeof(HostPort));
|
GetPortName(udpTable->table[i].dwLocalPort, "udp", HostPort, sizeof(HostPort));
|
||||||
@@ -609,10 +602,8 @@ GetIpHostName(BOOL Local, UINT IpAddr, CHAR Name[], INT NameLen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Parse command line parameters and set any options
|
* Parse command line parameters and set any options
|
||||||
* Run display output, looping over set intervals if a number is given
|
* Run display output, looping over set interval if a number is given
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
int wmain(int argc, wchar_t *argv[])
|
int wmain(int argc, wchar_t *argv[])
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user