Skip to content

Commit 437e3b8

Browse files
committed
fix output for local connections
svn path=/trunk/; revision=20279
1 parent c9b00ba commit 437e3b8

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

reactos/apps/utils/net/netstat/netstat.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ BOOL ParseCmdline(int argc, char* argv[])
125125
case 'a' :
126126
bDoShowAllCons = TRUE;
127127
break;
128+
case 'b' :
129+
bDoShowProcName = TRUE;
130+
break;
128131
case 'e' :
129132
bDoShowEthStats = TRUE;
130133
break;
@@ -198,9 +201,9 @@ BOOL DisplayOutput()
198201

199202
if (bDoShowRouteTable)
200203
{
204+
/* mingw doesn't have lib for _tsystem */
201205
if (system("route print") == -1)
202206
{
203-
//mingw doesn't have lib for _tsystem
204207
_tprintf(_T("cannot find 'route.exe'\n"));
205208
return EXIT_FAILURE;
206209
}
@@ -574,7 +577,7 @@ GetIpHostName(BOOL Local, UINT IpAddr, CHAR Name[], int NameLen)
574577
return Name;
575578
}
576579

577-
Name[0] = L'\0';
580+
Name[0] = _T('\0');
578581

579582
// Try to translate to a name
580583
if (!IpAddr) {
@@ -585,11 +588,12 @@ GetIpHostName(BOOL Local, UINT IpAddr, CHAR Name[], int NameLen)
585588
(nIpAddr >> 8) & 0xFF,
586589
(nIpAddr) & 0xFF);
587590
} else {
588-
//gethostname(name, namelen);
591+
gethostname(Name, NameLen);
589592
}
590593
} else if (IpAddr == 0x0100007f) {
591594
if (Local) {
592-
//gethostname(name, namelen);
595+
if (gethostname(Name, NameLen) != 0)
596+
DoFormatMessage(WSAGetLastError());
593597
} else {
594598
strcpy(Name, "localhost");
595599
}
@@ -627,7 +631,6 @@ VOID Usage()
627631

628632

629633

630-
631634
/*
632635
*
633636
* Parse command line parameters and set any options
@@ -636,6 +639,14 @@ VOID Usage()
636639
*/
637640
int main(int argc, char *argv[])
638641
{
642+
WSADATA wsaData;
643+
644+
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
645+
{
646+
_tprintf(_T("WSAStartup() failed : %d\n"), WSAGetLastError());
647+
return -1;
648+
}
649+
639650
if (ParseCmdline(argc, argv))
640651
return -1;
641652

reactos/apps/utils/net/netstat/netstat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/* command line options */
88
BOOL bNoOptions = FALSE; // print default
99
BOOL bDoShowAllCons = FALSE; // -a
10+
BOOL bDoShowProcName = FALSE; // -b
1011
BOOL bDoShowEthStats = FALSE; // -e
1112
BOOL bDoShowNumbers = FALSE; // -n
1213
BOOL bDoShowProtoCons = FALSE; // -p

0 commit comments

Comments
 (0)