netstat: Implement -a option.

This commit is contained in:
André Hentschel 2013-01-07 23:26:55 +01:00 committed by Alexandre Julliard
parent a422d6b382
commit 6158a5ccf3
1 changed files with 10 additions and 6 deletions

View File

@ -145,7 +145,7 @@ static WCHAR *NETSTAT_host_name(UINT ip, WCHAR name[])
return name;
}
static void NETSTAT_tcp_header(void)
static void NETSTAT_conn_header(void)
{
WCHAR local[22], remote[22], state[22];
NETSTAT_wprintf(fmtnn, NETSTAT_load_message(IDS_TCP_ACTIVE_CONN));
@ -175,8 +175,6 @@ static void NETSTAT_tcp_table(void)
if (err) return;
NETSTAT_tcp_header();
for (i = 0; i < table->dwNumEntries; i++)
{
if ((table->table[i].u.dwState == MIB_TCP_STATE_CLOSE_WAIT) ||
@ -213,8 +211,6 @@ static void NETSTAT_udp_table(void)
if (err) return;
NETSTAT_tcp_header();
for (i = 0; i < table->dwNumEntries; i++)
{
NETSTAT_host_name(table->table[i].dwLocalAddr, HostIp);
@ -252,6 +248,7 @@ int wmain(int argc, WCHAR *argv[])
if (argc == 1)
{
/* No options */
NETSTAT_conn_header();
NETSTAT_tcp_table();
return 0;
}
@ -260,21 +257,28 @@ int wmain(int argc, WCHAR *argv[])
{
switch (argv[1][1])
{
case 'a':
NETSTAT_conn_header();
NETSTAT_tcp_table();
NETSTAT_udp_table();
return 0;
case 'p':
argv++; argc--;
if (argc == 1) return 1;
switch (NETSTAT_get_protocol(argv[1]))
{
case PROT_TCP:
NETSTAT_conn_header();
NETSTAT_tcp_table();
break;
case PROT_UDP:
NETSTAT_conn_header();
NETSTAT_udp_table();
break;
default:
WINE_FIXME("Protocol not yet implemented: %s\n", debugstr_w(argv[1]));
}
break;
return 0;
default:
WINE_FIXME("Unknown option: %s\n", debugstr_w(argv[1]));
return 1;