ReactOS  0.4.13-dev-540-g8f04a09
netstat.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS netstat utility
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: base/applications/network/netstat/netstat.c
5  * PURPOSE: display IP stack statistics
6  * COPYRIGHT: Copyright 2005 Ged Murphy <gedmurphy@gmail.com>
7  */
8 /*
9  * TODO:
10  * sort function return values.
11  * implement -b, -o and -v
12  * clean up GetIpHostName
13  * command line parser needs more work
14  */
15 
16 #define WIN32_NO_STATUS
17 #include <stdarg.h>
18 #include <windef.h>
19 #include <winbase.h>
20 #define _INC_WINDOWS
21 #include <winsock2.h>
22 #include <wchar.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <iphlpapi.h>
26 
27 #include <conutils.h>
28 
29 #include "netstat.h"
30 #include "resource.h"
31 
33 DWORD Interval; /* time to pause between printing output */
34 
35 /* TCP endpoint states */
37  L"???",
38  L"CLOSED",
39  L"LISTENING",
40  L"SYN_SENT",
41  L"SYN_RCVD",
42  L"ESTABLISHED",
43  L"FIN_WAIT1",
44  L"FIN_WAIT2",
45  L"CLOSE_WAIT",
46  L"CLOSING",
47  L"LAST_ACK",
48  L"TIME_WAIT",
49  L"DELETE_TCB"
50 };
51 
52 /*
53  * format message string and display output
54  */
56 {
57  if (ErrorCode == ERROR_SUCCESS)
58  return;
59 
62 }
63 
64 /*
65  *
66  * Parse command line parameters and set any options
67  *
68  */
69 BOOL ParseCmdline(int argc, wchar_t* argv[])
70 {
71  LPWSTR Proto;
72  WCHAR c;
73  INT i;
74 
75  if ((argc == 1) || (iswdigit(*argv[1])))
76  bNoOptions = TRUE;
77 
78  /* Parse command line for options we have been given. */
79  for (i = 1; i < argc; i++)
80  {
81  if ((argc > 1) && (argv[i][0] == L'-' || argv[i][0] == L'/'))
82  {
83  while ((c = *++argv[i]) != L'\0')
84  {
85  switch (towlower(c))
86  {
87  case L'a':
89  break;
90  case L'b':
92  break;
93  case L'e':
95  break;
96  case L'n':
98  break;
99  case L'p':
101  Proto = argv[i+1];
102  if (!_wcsicmp(L"IP", Proto))
103  Protocol = IP;
104  else if (!_wcsicmp(L"ICMP", Proto))
105  Protocol = ICMP;
106  else if (!_wcsicmp(L"TCP", Proto))
107  Protocol = TCP;
108  else if (!_wcsicmp(L"UDP", Proto))
109  Protocol = UDP;
110  else
111  {
113  return EXIT_FAILURE;
114  }
115  break;
116  case L'r':
118  break;
119  case L's':
121  break;
122  case L'o':
124  break;
125  case L'v':
126  // FIXME!
127  ConPuts(StdOut, L"got v\n");
129  break;
130  default :
132  return EXIT_FAILURE;
133  }
134  }
135  }
136  else if (iswdigit(*argv[i]) != 0)
137  {
138  if (swscanf(argv[i], L"%lu", &Interval) != EOF)
139  bLoopOutput = TRUE;
140  else
141  return EXIT_FAILURE;
142  }
143 // else
144 // {
145 // ConResPrintf(StdOut, IDS_USAGE);
146 // return EXIT_FAILURE;
147 // }
148  }
149 
150  return EXIT_SUCCESS;
151 }
152 
153 /*
154  * Display table header
155  */
157 {
159  if (bDoShowProcessId)
161  else
162  ConPuts(StdOut, L"\n");
163 }
164 
165 /*
166  * Simulate Microsofts netstat utility output
167  */
169 {
170  if (bNoOptions)
171  {
173  ShowTcpTable();
174  return EXIT_SUCCESS;
175  }
176 
177  if (bDoShowRouteTable)
178  {
179  /* mingw doesn't have lib for _tsystem */
180  if (system("route print") == -1)
181  {
183  return EXIT_FAILURE;
184  }
185  return EXIT_SUCCESS;
186  }
187 
188  if (bDoShowEthStats)
189  {
191  return EXIT_SUCCESS;
192  }
193 
194  if (bDoShowProtoCons)
195  {
196  switch (Protocol)
197  {
198  case IP:
199  if (bDoShowProtoStats)
200  {
202  return EXIT_SUCCESS;
203  }
204  break;
205  case ICMP:
206  if (bDoShowProtoStats)
207  {
209  return EXIT_SUCCESS;
210  }
211  break;
212  case TCP:
213  if (bDoShowProtoStats)
217  ShowTcpTable();
218  break;
219  case UDP:
220  if (bDoShowProtoStats)
224  ShowUdpTable();
225  break;
226  default :
227  break;
228  }
229  }
230  else if (bDoShowProtoStats)
231  {
236  return EXIT_SUCCESS;
237  }
238  else
239  {
242  ShowTcpTable();
243  if (bDoShowAllCons)
244  ShowUdpTable();
245  }
246  return EXIT_SUCCESS;
247 }
248 
250 {
251  PMIB_IPSTATS pIpStats;
252  DWORD dwRetVal;
253 
254  pIpStats = (MIB_IPSTATS*) HeapAlloc(GetProcessHeap(), 0, sizeof(MIB_IPSTATS));
255 
256  if ((dwRetVal = GetIpStatistics(pIpStats)) == NO_ERROR)
257  {
276  }
277  else
278  {
279  DoFormatMessage(dwRetVal);
280  }
281 
282  HeapFree(GetProcessHeap(), 0, pIpStats);
283 }
284 
286 {
287  PMIB_ICMP pIcmpStats;
288  DWORD dwRetVal;
289 
290  pIcmpStats = (MIB_ICMP*) HeapAlloc(GetProcessHeap(), 0, sizeof(MIB_ICMP));
291 
292  if ((dwRetVal = GetIcmpStatistics(pIcmpStats)) == NO_ERROR)
293  {
297  pIcmpStats->stats.icmpInStats.dwMsgs, pIcmpStats->stats.icmpOutStats.dwMsgs);
299  pIcmpStats->stats.icmpInStats.dwErrors, pIcmpStats->stats.icmpOutStats.dwErrors);
303  pIcmpStats->stats.icmpInStats.dwTimeExcds, pIcmpStats->stats.icmpOutStats.dwTimeExcds);
305  pIcmpStats->stats.icmpInStats.dwParmProbs, pIcmpStats->stats.icmpOutStats.dwParmProbs);
307  pIcmpStats->stats.icmpInStats.dwSrcQuenchs, pIcmpStats->stats.icmpOutStats.dwSrcQuenchs);
309  pIcmpStats->stats.icmpInStats.dwRedirects, pIcmpStats->stats.icmpOutStats.dwRedirects);
311  pIcmpStats->stats.icmpInStats.dwEchos, pIcmpStats->stats.icmpOutStats.dwEchos);
313  pIcmpStats->stats.icmpInStats.dwEchoReps, pIcmpStats->stats.icmpOutStats.dwEchoReps);
315  pIcmpStats->stats.icmpInStats.dwTimestamps, pIcmpStats->stats.icmpOutStats.dwTimestamps);
319  pIcmpStats->stats.icmpInStats.dwAddrMasks, pIcmpStats->stats.icmpOutStats.dwAddrMasks);
322  }
323  else
324  {
325  DoFormatMessage(dwRetVal);
326  }
327 
328  HeapFree(GetProcessHeap(), 0, pIcmpStats);
329 
330 }
331 
333 {
334  PMIB_TCPSTATS pTcpStats;
335  DWORD dwRetVal;
336 
337  pTcpStats = (MIB_TCPSTATS*) HeapAlloc(GetProcessHeap(), 0, sizeof(MIB_TCPSTATS));
338 
339  if ((dwRetVal = GetTcpStatistics(pTcpStats)) == NO_ERROR)
340  {
350  }
351  else
352  {
353  DoFormatMessage(dwRetVal);
354  }
355 
356  HeapFree(GetProcessHeap(), 0, pTcpStats);
357 }
358 
360 {
361  PMIB_UDPSTATS pUdpStats;
362  DWORD dwRetVal;
363 
364  pUdpStats = (MIB_UDPSTATS*) HeapAlloc(GetProcessHeap(), 0, sizeof(MIB_UDPSTATS));
365 
366  if ((dwRetVal = GetUdpStatistics(pUdpStats)) == NO_ERROR)
367  {
373  }
374  else
375  {
376  DoFormatMessage(dwRetVal);
377  }
378 
379  HeapFree(GetProcessHeap(), 0, pUdpStats);
380 }
381 
383 {
384  PMIB_IFTABLE pIfTable;
385  DWORD dwSize = 0;
386  DWORD dwRetVal = 0;
387 
388  pIfTable = (MIB_IFTABLE*) HeapAlloc(GetProcessHeap(), 0, sizeof(MIB_IFTABLE));
389 
390  if (GetIfTable(pIfTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER)
391  {
392  HeapFree(GetProcessHeap(), 0, pIfTable);
393  pIfTable = (MIB_IFTABLE*) HeapAlloc(GetProcessHeap(), 0, dwSize);
394 
395  if ((dwRetVal = GetIfTable(pIfTable, &dwSize, 0)) == NO_ERROR)
396  {
400  pIfTable->table[0].dwInOctets, pIfTable->table[0].dwOutOctets);
402  pIfTable->table[0].dwInUcastPkts, pIfTable->table[0].dwOutUcastPkts);
404  pIfTable->table[0].dwInNUcastPkts, pIfTable->table[0].dwOutNUcastPkts);
406  pIfTable->table[0].dwInDiscards, pIfTable->table[0].dwOutDiscards);
408  pIfTable->table[0].dwInErrors, pIfTable->table[0].dwOutErrors);
410  pIfTable->table[0].dwInUnknownProtos);
411  }
412  else
413  {
414  DoFormatMessage(dwRetVal);
415  }
416  }
417  HeapFree(GetProcessHeap(), 0, pIfTable);
418 }
419 
421 {
422  PMIB_TCPTABLE_OWNER_PID tcpTable;
423  DWORD error, dwSize;
424  DWORD i;
425  CHAR HostIp[HOSTNAMELEN], HostPort[PORTNAMELEN];
426  CHAR RemoteIp[HOSTNAMELEN], RemotePort[PORTNAMELEN];
427  CHAR Host[ADDRESSLEN];
429  CHAR PID[64];
430 
431  /* Get the table of TCP endpoints */
432  dwSize = sizeof (MIB_TCPTABLE_OWNER_PID);
433  /* Should also work when we get new connections between 2 GetTcpTable()
434  * calls: */
435  do
436  {
439  if ( error != NO_ERROR )
440  HeapFree(GetProcessHeap(), 0, tcpTable);
441  }
442  while ( error == ERROR_INSUFFICIENT_BUFFER );
443 
444  if (error != NO_ERROR)
445  {
449  }
450 
451  /* Dump the TCP table */
452  for (i = 0; i < tcpTable->dwNumEntries; i++)
453  {
454  /* If we aren't showing all connections, only display established, close wait
455  * and time wait. This is the default output for netstat */
456  if (bDoShowAllCons || (tcpTable->table[i].dwState == MIB_TCP_STATE_ESTAB)
457  || (tcpTable->table[i].dwState == MIB_TCP_STATE_CLOSE_WAIT)
458  || (tcpTable->table[i].dwState == MIB_TCP_STATE_TIME_WAIT))
459  {
460  /* I've split this up so it's easier to follow */
461  GetIpHostName(TRUE, tcpTable->table[i].dwLocalAddr, HostIp, HOSTNAMELEN);
462  GetPortName(tcpTable->table[i].dwLocalPort, "tcp", HostPort, PORTNAMELEN);
463  sprintf(Host, "%s:%s", HostIp, HostPort);
464 
465  if (tcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
466  {
467  sprintf(Remote, "%s:0", HostIp);
468  }
469  else
470  {
471  GetIpHostName(FALSE, tcpTable->table[i].dwRemoteAddr, RemoteIp, HOSTNAMELEN);
472  GetPortName(tcpTable->table[i].dwRemotePort, "tcp", RemotePort, PORTNAMELEN);
473  sprintf(Remote, "%s:%s", RemoteIp, RemotePort);
474  }
475 
476  if (bDoShowProcessId)
477  {
478  sprintf(PID, "%ld", tcpTable->table[i].dwOwningPid);
479  }
480  else
481  {
482  PID[0] = 0;
483  }
484 
485  ConPrintf(StdOut, L" %-6s %-22s %-22s %-11s %s\n", L"TCP",
486  Host, Remote, TcpState[tcpTable->table[i].dwState], PID);
487  }
488  }
489  HeapFree(GetProcessHeap(), 0, tcpTable);
490 }
491 
493 {
495  DWORD error, dwSize;
496  DWORD i;
497  CHAR HostIp[HOSTNAMELEN], HostPort[PORTNAMELEN];
498  CHAR Host[ADDRESSLEN];
499  CHAR PID[64];
500 
501  /* Get the table of UDP endpoints */
502  dwSize = 0;
505  {
509  }
512  if (error)
513  {
518  }
519 
520  /* Dump the UDP table */
521  for (i = 0; i < udpTable->dwNumEntries; i++)
522  {
523 
524  /* I've split this up so it's easier to follow */
526  GetPortName(udpTable->table[i].dwLocalPort, "tcp", HostPort, PORTNAMELEN);
527 
528  sprintf(Host, "%s:%s", HostIp, HostPort);
529 
530  if (bDoShowProcessId)
531  {
532  sprintf(PID, "%ld", udpTable->table[i].dwOwningPid);
533  }
534  else
535  {
536  PID[0] = 0;
537  }
538 
539  ConPrintf(StdOut, L" %-6s %-22s %-34s %s\n", L"UDP", Host, L"*:*", PID);
540  }
541 
543 }
544 
545 /*
546  * Translate port numbers into their text equivalent if there is one
547  */
548 PCHAR
549 GetPortName(UINT Port, PCSTR Proto, CHAR Name[], INT NameLen)
550 {
551  struct servent *pServent;
552 
553  if (bDoShowNumbers)
554  {
555  sprintf(Name, "%d", htons((WORD)Port));
556  return Name;
557  }
558  /* Try to translate to a name */
559  if ((pServent = getservbyport(Port, Proto)))
560  strcpy(Name, pServent->s_name );
561  else
562  sprintf(Name, "%d", htons((WORD)Port));
563  return Name;
564 }
565 
566 /*
567  * convert addresses into dotted decimal or hostname
568  */
569 PCHAR
570 GetIpHostName(BOOL Local, UINT IpAddr, CHAR Name[], int NameLen)
571 {
572 // struct hostent *phostent;
573  UINT nIpAddr;
574 
575  /* display dotted decimal */
576  nIpAddr = htonl(IpAddr);
577  if (bDoShowNumbers) {
578  sprintf(Name, "%d.%d.%d.%d",
579  (nIpAddr >> 24) & 0xFF,
580  (nIpAddr >> 16) & 0xFF,
581  (nIpAddr >> 8) & 0xFF,
582  (nIpAddr) & 0xFF);
583  return Name;
584  }
585 
586  Name[0] = '\0';
587 
588  /* try to resolve the name */
589  if (!IpAddr) {
590  if (!Local) {
591  sprintf(Name, "%d.%d.%d.%d",
592  (nIpAddr >> 24) & 0xFF,
593  (nIpAddr >> 16) & 0xFF,
594  (nIpAddr >> 8) & 0xFF,
595  (nIpAddr) & 0xFF);
596  } else {
597  if (gethostname(Name, NameLen) != 0)
599  }
600  } else if (IpAddr == 0x0100007f) {
601  if (Local) {
602  if (gethostname(Name, NameLen) != 0)
604  } else {
605  strncpy(Name, "localhost", 10);
606  }
607 // } else if (phostent = gethostbyaddr((char*)&ipaddr, sizeof(nipaddr), PF_INET)) {
608 // strcpy(name, phostent->h_name);
609  } else {
610  sprintf(Name, "%d.%d.%d.%d",
611  ((nIpAddr >> 24) & 0x000000FF),
612  ((nIpAddr >> 16) & 0x000000FF),
613  ((nIpAddr >> 8) & 0x000000FF),
614  ((nIpAddr) & 0x000000FF));
615  }
616  return Name;
617 }
618 
619 /*
620  *
621  * Parse command line parameters and set any options
622  * Run display output, looping over set intervals if a number is given
623  *
624  */
625 int wmain(int argc, wchar_t *argv[])
626 {
627  WSADATA wsaData;
628 
629  /* Initialize the Console Standard Streams */
631 
632  if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
633  {
635  return -1;
636  }
637 
638  if (ParseCmdline(argc, argv))
639  return -1;
640 
641  if (bLoopOutput)
642  {
643  while (1)
644  {
645  if (DisplayOutput())
646  return -1;
647  Sleep(Interval*1000);
648  }
649  }
650 
651  if (DisplayOutput())
652  return -1;
653  else
654  return 0;
655 }
struct _MIB_IPSTATS MIB_IPSTATS
signed char * PCHAR
Definition: retypes.h:7
DWORD dwAttemptFails
Definition: tcpmib.h:181
#define IDS_ICMP_SRC_QUENCHES
Definition: resource.h:41
#define IDS_IP_DISCARD_OUT_PACK
Definition: resource.h:27
#define IDS_IP_REASSEMBLE_SUCCESS
Definition: resource.h:30
DWORD dwEchos
Definition: ipmib.h:183
MIB_IFROW table[1]
Definition: ifmib.h:66
BOOL bDoShowProtoCons
Definition: netstat.h:13
DWORD dwInOctets
Definition: ifmib.h:47
CPPORT Port[4]
Definition: headless.c:34
static int argc
Definition: ServiceArgs.c:12
const uint16_t * PCWSTR
Definition: typedefs.h:55
BOOL bDoShowProcessId
Definition: netstat.h:16
#define TRUE
Definition: types.h:120
#define IDS_ICMP_THEADER
Definition: resource.h:9
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
DWORD dwInUcastPkts
Definition: ifmib.h:48
MIBICMPSTATS icmpInStats
Definition: ipmib.h:193
DWORD dwTimestamps
Definition: ipmib.h:185
DWORD dwInReceives
Definition: ipmib.h:148
#define IDS_DISPLAY_PROCESS
Definition: resource.h:5
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD dwReasmReqds
Definition: ipmib.h:160
#define error(str)
Definition: mkdosfs.c:1605
DWORD dwInNUcastPkts
Definition: ifmib.h:49
Definition: netstat.c:32
#define htonl(x)
Definition: module.h:212
#define IDS_ICMP_REDIRECT
Definition: resource.h:42
#define MAKEWORD(a, b)
Definition: typedefs.h:247
VOID ShowIpStatistics(VOID)
Definition: netstat.c:249
DWORD dwInDiscards
Definition: ipmib.h:153
#define IDS_ICMP_PARAM_PROBLEM
Definition: resource.h:40
DWORD dwTimeExcds
Definition: ipmib.h:179
DWORD dwEchoReps
Definition: ipmib.h:184
struct _MIB_TCPTABLE_OWNER_PID MIB_TCPTABLE_OWNER_PID
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
char CHAR
Definition: xmlstorage.h:175
#define iswdigit(_c)
Definition: ctype.h:667
#define IDS_IP4_STAT_HEADER
Definition: resource.h:7
DWORD dwInDiscards
Definition: ifmib.h:50
#define IDS_IP_DATAG_FRAG_CREATE
Definition: resource.h:34
VOID ShowUdpTable(VOID)
Definition: netstat.c:492
#define IDS_ETHERNET_BYTES
Definition: resource.h:67
DWORD dwLocalAddr
Definition: udpmib.h:28
struct _MIB_TCPSTATS MIB_TCPSTATS
#define IDS_IP_REC_PACK_DELIVER
Definition: resource.h:24
#define IDS_USAGE
Definition: resource.h:3
DWORD dwInHdrErrors
Definition: ipmib.h:149
BOOL bDoShowNumbers
Definition: netstat.h:12
#define argv
Definition: mplay32.c:18
DWORD dwInDelivers
Definition: ipmib.h:154
#define NO_ERROR
Definition: dderror.h:5
#define IDS_ICMP4_STAT_HEADER
Definition: resource.h:8
#define IDS_ICMP_ECHO_REPLY
Definition: resource.h:44
#define IDS_ETHERNET_UNKNOWN
Definition: resource.h:72
int32_t INT
Definition: typedefs.h:56
#define IDS_ACTIVE_CONNECT
Definition: resource.h:6
DWORD dwForwDatagrams
Definition: ipmib.h:151
#define IDS_ETHERNET_UNICAST_PACKET
Definition: resource.h:68
DWORD dwInUnknownProtos
Definition: ifmib.h:52
DWORD WINAPI GetIpStatistics(PMIB_IPSTATS pStats)
#define IDS_IP_OUT_PACKET_NO_ROUTE
Definition: resource.h:28
struct _MIB_UDPSTATS MIB_UDPSTATS
struct _MIB_UDPTABLE_OWNER_PID * PMIB_UDPTABLE_OWNER_PID
VOID ShowUdpStatistics(VOID)
Definition: netstat.c:359
DWORD dwInUnknownProtos
Definition: ipmib.h:152
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
#define IDS_UDP_DATAG_SEND
Definition: resource.h:63
#define IDS_ICMP_TIMESTAMP_REPLY
Definition: resource.h:46
MIBICMPINFO stats
Definition: ipmib.h:199
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD dwNumEntries
Definition: udpmib.h:34
ProtoType
Definition: netstat.c:32
#define ConInitStdStreams()
Definition: stream.h:122
#define IDS_TCP_SEG_RETRANSMIT
Definition: resource.h:57
#define IDS_IP_ROUTE_DISCARD
Definition: resource.h:26
#define IDS_IP_DATAG_FWD
Definition: resource.h:21
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD dwErrors
Definition: ipmib.h:177
#define IDS_ERROR_UDP_ENDPOINT_TABLE
Definition: resource.h:16
INT WSAAPI gethostname(OUT char FAR *name, IN INT namelen)
Definition: getxbyxx.c:397
DWORD dwOutDiscards
Definition: ipmib.h:157
DWORD dwOutDiscards
Definition: ifmib.h:56
DWORD dwInDatagrams
Definition: udpmib.h:78
DWORD dwInSegs
Definition: tcpmib.h:184
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
struct NameRec_ * Name
Definition: cdprocs.h:464
DWORD dwFragCreates
Definition: ipmib.h:165
#define IDS_IP_REC_PACK_DISCARD
Definition: resource.h:23
DWORD dwOutDatagrams
Definition: udpmib.h:81
BOOL bDoDispSeqComp
Definition: netstat.h:17
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
smooth NULL
Definition: ftsmooth.c:416
DWORD dwRoutingDiscards
Definition: ipmib.h:156
#define IDS_DISPLAY_THEADER
Definition: resource.h:4
#define IDS_ICMP_ADDRESSS_MASK_REPLY
Definition: resource.h:48
DWORD dwTimestampReps
Definition: ipmib.h:186
DWORD dwOutSegs
Definition: tcpmib.h:185
int __cdecl system(_In_opt_z_ const char *_Command)
#define IDS_IP_DATAG_FRAG_FAILURE
Definition: resource.h:33
DWORD dwCurrEstab
Definition: tcpmib.h:183
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
VOID ShowEthernetStatistics(VOID)
Definition: netstat.c:382
DWORD dwNoPorts
Definition: udpmib.h:79
VOID ShowTcpStatistics(VOID)
Definition: netstat.c:332
#define IDS_ICMP_ERROR
Definition: resource.h:37
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
BOOL bDoShowEthStats
Definition: netstat.h:11
DWORD dwParmProbs
Definition: ipmib.h:180
DWORD Interval
Definition: netstat.c:33
#define IDS_ICMP_MSG
Definition: resource.h:36
DWORD dwReasmOks
Definition: ipmib.h:161
#define IDS_TCP_RESET_CONNECT
Definition: resource.h:53
DWORD dwOutRequests
Definition: ipmib.h:155
#define PORTNAMELEN
Definition: netstat.h:4
DWORD WINAPI GetUdpStatistics(PMIB_UDPSTATS pStats)
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
#define GetProcessHeap()
Definition: compat.h:395
MIB_UDPROW table[1]
Definition: udpmib.h:35
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL ParseCmdline(int argc, wchar_t *argv[])
Definition: netstat.c:69
#define IDS_ETHERNET_NON_UNICAST_PACKET
Definition: resource.h:69
DWORD dwEstabResets
Definition: tcpmib.h:182
#define IDS_UDP_DATAG_RECEIVE
Definition: resource.h:60
#define IDS_ICMP_ECHO
Definition: resource.h:43
#define IDS_IP_DATAG_FRAG_SUCCESS
Definition: resource.h:32
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD WINAPI GetIcmpStatistics(PMIB_ICMP pStats)
#define IDS_ETHERNET_ERROR
Definition: resource.h:71
VOID DisplayTableHeader(VOID)
Definition: netstat.c:156
DWORD dwReasmFails
Definition: ipmib.h:162
struct _MIB_IFTABLE MIB_IFTABLE
PCHAR GetIpHostName(BOOL Local, UINT IpAddr, CHAR Name[], int NameLen)
Definition: netstat.c:570
DWORD dwOutNoRoutes
Definition: ipmib.h:158
DWORD dwRetransSegs
Definition: tcpmib.h:186
const GLubyte * c
Definition: glext.h:8905
#define IDS_ETHERNET_THEADER
Definition: resource.h:66
char * s_name
Definition: winsock.h:159
unsigned short WORD
Definition: ntddk_ex.h:93
Definition: netstat.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDS_IP_ADDR_REC_ERROR
Definition: resource.h:20
#define EXIT_FAILURE
Definition: jerror.c:33
INT ConMsgPuts(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId)
Definition: outstream.c:837
#define StdErr
Definition: stream.h:77
#define IDS_IP_REASSEMBLE_FAILURE
Definition: resource.h:31
DWORD dwOutUcastPkts
Definition: ifmib.h:54
DWORD dwInErrors
Definition: ifmib.h:51
#define IDS_IP_UNKNOWN_PRO_REC
Definition: resource.h:22
DWORD dwInErrors
Definition: udpmib.h:80
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
#define IDS_UDP_NO_PORT
Definition: resource.h:61
static const WCHAR L[]
Definition: oid.c:1250
#define IDS_ETHERNET_INTERFACE_STAT
Definition: resource.h:65
Definition: netstat.c:32
DWORD dwRedirects
Definition: ipmib.h:182
enum ProtoType Protocol
BOOL bDoShowProtoStats
Definition: netstat.h:15
DWORD dwPassiveOpens
Definition: tcpmib.h:180
DWORD dwAddrMasks
Definition: ipmib.h:187
static PMIB_UDPTABLE udpTable
Definition: main.c:1188
DWORD dwInAddrErrors
Definition: ipmib.h:150
#define IDS_TCP_FAIL_CONNECT
Definition: resource.h:52
#define IDS_TCP_SEG_RECEIVE
Definition: resource.h:55
#define IDS_ERROR_ROUTE
Definition: resource.h:13
#define IDS_ICMP_TIMESTAMP
Definition: resource.h:45
MIBICMPSTATS icmpOutStats
Definition: ipmib.h:194
#define IDS_UDP_RECEIVE_ERROR
Definition: resource.h:62
BOOL bDoShowAllCons
Definition: netstat.h:9
int wmain(int argc, wchar_t *argv[])
Definition: netstat.c:625
#define IDS_ETHERNET_DISCARD
Definition: resource.h:70
struct _MIB_TCPTABLE_OWNER_PID * PMIB_TCPTABLE_OWNER_PID
DWORD dwOutOctets
Definition: ifmib.h:53
BOOL bNoOptions
Definition: netstat.h:8
DWORD dwSrcQuenchs
Definition: ipmib.h:181
#define IDS_TCP_SEG_SENT
Definition: resource.h:56
#define IDS_IP_PACK_REC
Definition: resource.h:18
#define IDS_ERROR_TCP_SNAPSHOT
Definition: resource.h:14
DWORD WINAPI GetExtendedUdpTable(PVOID pUdpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, UDP_TABLE_CLASS TableClass, ULONG Reserved)
#define IDS_TCP_CURRENT_CONNECT
Definition: resource.h:54
struct _MIB_ICMP MIB_ICMP
#define IDS_UDP_IP4_HEADER
Definition: resource.h:59
Definition: netstat.c:32
unsigned int UINT
Definition: ndis.h:50
#define IDS_ERROR_UDP_ENDPOINT
Definition: resource.h:15
#define IDS_TCP_ACTIVE_OPEN
Definition: resource.h:50
#define IDS_TCP4_HEADER
Definition: resource.h:10
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define IDS_ERROR_WSA_START
Definition: resource.h:12
#define IDS_IP_HEAD_REC_ERROR
Definition: resource.h:19
DWORD dwFragOks
Definition: ipmib.h:163
DWORD WINAPI GetExtendedTcpTable(PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, TCP_TABLE_CLASS TableClass, ULONG Reserved)
#define EOF
Definition: stdio.h:24
#define StdOut
Definition: stream.h:76
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define c
Definition: ke_i.h:80
DWORD dwDestUnreachs
Definition: ipmib.h:178
VOID DoFormatMessage(DWORD ErrorCode)
Definition: netstat.c:55
DWORD dwAddrMaskReps
Definition: ipmib.h:188
#define AF_INET
Definition: tcpip.h:117
#define towlower(c)
Definition: wctype.h:97
DWORD dwLocalPort
Definition: udpmib.h:29
#define ADDRESSLEN
Definition: netstat.h:5
#define IDS_IP_OUT_REQUEST
Definition: resource.h:25
#define IDS_IP_REASSEMBLE_REQUIRED
Definition: resource.h:29
BOOL DisplayOutput(VOID)
Definition: netstat.c:168
const char * PCSTR
Definition: typedefs.h:51
BOOL bLoopOutput
Definition: netstat.h:18
DWORD dwFragFails
Definition: ipmib.h:164
#define IDS_TCP_PASS_OPEN
Definition: resource.h:51
VOID ShowIcmpStatistics(VOID)
Definition: netstat.c:285
void exit(int exitcode)
Definition: _exit.c:33
WCHAR * LPWSTR
Definition: xmlstorage.h:184
PCHAR GetPortName(UINT Port, PCSTR Proto, CHAR Name[], INT NameLen)
Definition: netstat.c:549
#define htons(x)
Definition: module.h:213
PSERVENT WSAAPI getservbyport(IN int port, IN const char FAR *proto)
Definition: getxbyxx.c:431
_Check_return_ _CRTIMP int __cdecl swscanf(_In_z_ const wchar_t *_Src, _In_z_ _Scanf_format_string_ const wchar_t *_Format,...)
DWORD dwOutErrors
Definition: ifmib.h:57
BOOL bDoShowRouteTable
Definition: netstat.h:14
VOID ShowTcpTable(VOID)
Definition: netstat.c:420
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
PCWSTR TcpState[]
Definition: netstat.c:36
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
DWORD dwActiveOpens
Definition: tcpmib.h:179
#define IDS_ICMP_TIME_EXCEED
Definition: resource.h:39
#define IDS_ICMP_ADDRESSS_MASK
Definition: resource.h:47
#define IDS_ICMP_DEST_UNREACH
Definition: resource.h:38
#define HOSTNAMELEN
Definition: netstat.h:3
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50
DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS pStats)
DWORD dwMsgs
Definition: ipmib.h:176
MIB_TCPROW_OWNER_PID table[1]
Definition: tcpmib.h:115
DWORD dwOutNUcastPkts
Definition: ifmib.h:55
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL bDoShowProcName
Definition: netstat.h:10