ReactOS 0.4.16-dev-959-g2ec3a19
ping.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Tim Crawford
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22/*
23 * PROJECT: ReactOS Ping Command
24 * LICENSE: MIT
25 * FILE: base/applications/network/ping/ping.c
26 * PURPOSE: Network test utility
27 * PROGRAMMERS: Tim Crawford <crawfxrd@gmail.com>
28 */
29
30#include <stdlib.h>
31
32#define WIN32_LEAN_AND_MEAN
33
34#define WIN32_NO_STATUS
35#include <windef.h>
36#include <winbase.h>
37#include <winsock2.h>
38#include <ws2tcpip.h>
39#include <iphlpapi.h>
40#include <icmpapi.h>
41
42#include <conutils.h>
43
44#include "resource.h"
45
46#define NDEBUG
47#include <debug.h>
48
49#define SIZEOF_ICMP_ERROR 8
50#define SIZEOF_IO_STATUS_BLOCK 8
51#define DEFAULT_TIMEOUT 1000
52#define MAX_SEND_SIZE 65500
53
54static BOOL ParseCmdLine(int argc, PWSTR argv[]);
56static void Ping(void);
57static void PrintStats(void);
58static BOOL WINAPI ConsoleCtrlHandler(DWORD ControlType);
59
61static ULONG Timeout = 4000;
62static int Family = AF_UNSPEC;
63static ULONG RequestSize = 32;
64static ULONG PingCount = 4;
68static WCHAR Address[46];
71
72static ULONG RTTMax = 0;
73static ULONG RTTMin = 0;
74static ULONG RTTTotal = 0;
75static ULONG EchosSent = 0;
78
80
81int
83{
84 WSADATA wsaData;
85 ULONG i;
86 DWORD StrLen = 46;
87 int Status;
88
89 /* Initialize the Console Standard Streams */
91
92 IpOptions.Ttl = 128;
93
94 if (!ParseCmdLine(argc, argv))
95 return 1;
96
98 {
99 DPRINT("Failed to set control handler: %lu\n", GetLastError());
100 return 1;
101 }
102
103 Status = WSAStartup(MAKEWORD(2, 2), &wsaData);
104 if (Status != 0)
105 {
107 return 1;
108 }
109
111 {
112 WSACleanup();
113 return 1;
114 }
115
116 if (WSAAddressToStringW(Target->ai_addr, (DWORD)Target->ai_addrlen, NULL, Address, &StrLen) != 0)
117 {
118 DPRINT("WSAAddressToStringW failed: %d\n", WSAGetLastError());
120 WSACleanup();
121 return 1;
122 }
123
124 if (Family == AF_INET6)
126 else
128
129
131 {
132 DPRINT("IcmpCreateFile failed: %lu\n", GetLastError());
134 WSACleanup();
135 return 1;
136 }
137
138 if (*CanonName)
140 else
142
144
145 Ping();
146
147 i = 1;
148 while (i < PingCount)
149 {
150 Sleep(1000);
151 Ping();
152
153 if (!PingForever)
154 i++;
155 }
156
157 PrintStats();
158
161 WSACleanup();
162
163 return 0;
164}
165
166static
167BOOL
169{
170 int i;
171
172 if (argc < 2)
173 {
175 return FALSE;
176 }
177
178 for (i = 1; i < argc; i++)
179 {
180 if (argv[i][0] == L'-' || argv[i][0] == L'/')
181 {
182 switch (argv[i][1])
183 {
184 case L't':
186 break;
187
188 case L'a':
190 break;
191
192 case L'n':
193 {
194 if (i + 1 < argc)
195 {
197 PingCount = wcstoul(argv[++i], NULL, 0);
198 if (PingCount == 0)
199 {
201 return FALSE;
202 }
203 }
204 else
205 {
207 return FALSE;
208 }
209 break;
210 }
211
212 case L'l':
213 {
214 if (i + 1 < argc)
215 {
216 RequestSize = wcstoul(argv[++i], NULL, 0);
218 {
220 return FALSE;
221 }
222 }
223 else
224 {
226 return FALSE;
227 }
228 break;
229 }
230
231 case L'f':
232 {
233 if (Family == AF_INET6)
234 {
236 return FALSE;
237 }
238
239 Family = AF_INET;
241 break;
242 }
243
244 case L'i':
245 {
246 if (i + 1 < argc)
247 {
248 ULONG Ttl = wcstoul(argv[++i], NULL, 0);
249
250 if ((Ttl == 0) || (Ttl > UCHAR_MAX))
251 {
253 return FALSE;
254 }
255
256 IpOptions.Ttl = (UCHAR)Ttl;
257 }
258 else
259 {
261 return FALSE;
262 }
263 break;
264 }
265
266 case L'v':
267 {
268 if (Family == AF_INET6)
269 {
271 return FALSE;
272 }
273
274 Family = AF_INET;
275
276 if (i + 1 < argc)
277 {
278 /* This option has been deprecated. Don't do anything. */
279 i++;
280 }
281 else
282 {
284 return FALSE;
285 }
286
287 break;
288 }
289
290 case L'w':
291 {
292 if (i + 1 < argc)
293 {
294 Timeout = wcstoul(argv[++i], NULL, 0);
297 }
298 else
299 {
301 return FALSE;
302 }
303 break;
304 }
305
306 case L'R':
307 {
308 if (Family == AF_INET)
309 {
311 return FALSE;
312 }
313
315
316 /* This option has been deprecated. Don't do anything. */
317 break;
318 }
319
320 case L'4':
321 {
322 if (Family == AF_INET6)
323 {
325 return FALSE;
326 }
327
328 Family = AF_INET;
329 break;
330 }
331
332 case L'6':
333 {
334 if (Family == AF_INET)
335 {
337 return FALSE;
338 }
339
341 break;
342 }
343
344 case L'?':
346 return FALSE;
347
348 default:
351 return FALSE;
352 }
353 }
354 else
355 {
356 if (TargetName != NULL)
357 {
359 return FALSE;
360 }
361
362 TargetName = argv[i];
363 }
364 }
365
366 if (TargetName == NULL)
367 {
369 return FALSE;
370 }
371
372 return TRUE;
373}
374
375static
376BOOL
378{
380 int Status;
381
382 ZeroMemory(&hints, sizeof(hints));
383 hints.ai_family = Family;
384 hints.ai_flags = AI_NUMERICHOST;
385
387 if (Status != 0)
388 {
389 hints.ai_flags = AI_CANONNAME;
390
392 if (Status != 0)
393 {
395 return FALSE;
396 }
397
398 wcsncpy(CanonName, Target->ai_canonname, wcslen(Target->ai_canonname));
399 }
400 else if (ResolveAddress)
401 {
402 Status = GetNameInfoW(Target->ai_addr, Target->ai_addrlen,
404 NULL, 0,
406 if (Status != 0)
407 {
408 DPRINT("GetNameInfoW failed: %d\n", WSAGetLastError());
409 }
410 }
411
412 Family = Target->ai_family;
413
414 return TRUE;
415}
416
417static
418void
419Ping(void)
420{
422 PVOID SendBuffer = NULL;
423 DWORD ReplySize = 0;
425
426 if (RequestSize != 0)
427 {
428 SendBuffer = malloc(RequestSize);
429 if (SendBuffer == NULL)
430 {
432 exit(1);
433 }
434
435 /* Windows ping utility fills the optional data field with
436 * ASCII characters from 'a' to 'w', wrapping back around
437 * until SendBuffer is full. */
438 for (ULONG i = 0; i < RequestSize; i++)
439 ((PUCHAR)SendBuffer)[i] = (UCHAR)('a' + (i % ('w' - 'a' + 1)));
440 }
441
442 if (Family == AF_INET6)
443 {
444 ReplySize += sizeof(ICMPV6_ECHO_REPLY);
445 }
446 else
447 {
448#ifdef _WIN64
449 ReplySize += sizeof(ICMP_ECHO_REPLY32);
450#else
451 ReplySize += sizeof(ICMP_ECHO_REPLY);
452#endif
453 }
454
456
457 ReplyBuffer = malloc(ReplySize);
458 if (ReplyBuffer == NULL)
459 {
461 free(SendBuffer);
462 exit(1);
463 }
464
465 ZeroMemory(ReplyBuffer, ReplySize);
466
467 EchosSent++;
468
469 if (Family == AF_INET6)
470 {
471 struct sockaddr_in6 Source;
472
473 ZeroMemory(&Source, sizeof(Source));
474 Source.sin6_family = AF_INET6;
475
477 &Source,
478 (struct sockaddr_in6 *)Target->ai_addr,
479 SendBuffer, (USHORT)RequestSize, &IpOptions,
480 ReplyBuffer, ReplySize, Timeout);
481 }
482 else
483 {
485 ((PSOCKADDR_IN)Target->ai_addr)->sin_addr.s_addr,
486 SendBuffer, (USHORT)RequestSize, &IpOptions,
487 ReplyBuffer, ReplySize, Timeout);
488 }
489
490 /* TODO: Compare ReplyBuffer data to SendBuffer. */
491 free(SendBuffer);
492
493 if (Status == 0)
494 {
496 switch (Status)
497 {
498 case IP_REQ_TIMED_OUT:
500 break;
501
502 default:
504 break;
505 }
506 }
507 else
508 {
509 SOCKADDR_IN6 SockAddrIn6;
510 SOCKADDR_IN SockAddrIn;
511 PSOCKADDR SockAddr;
513
515
516 ZeroMemory(&SockAddrIn, sizeof(SockAddrIn));
517 ZeroMemory(&SockAddrIn6, sizeof(SockAddrIn6));
518
519 if (Family == AF_INET6)
520 {
521 PICMPV6_ECHO_REPLY pEchoReply;
522 PIPV6_ADDRESS_EX Ipv6Addr;
523
524 pEchoReply = (PICMPV6_ECHO_REPLY)ReplyBuffer;
525
526 Ipv6Addr = (PIPV6_ADDRESS_EX)&pEchoReply->Address;
527 SockAddrIn6.sin6_family = AF_INET6;
528 CopyMemory(SockAddrIn6.sin6_addr.u.Word, Ipv6Addr->sin6_addr, sizeof(SockAddrIn6.sin6_addr));
529 //SockAddrIn6.sin6_addr = Ipv6Addr->sin6_addr;
530 SockAddr = (PSOCKADDR)&SockAddrIn6;
531 Size = sizeof(SOCKADDR_IN6);
532
533 GetNameInfoW(SockAddr,
534 Size,
535 Address,
537 NULL,
538 0,
540
542
543 switch (pEchoReply->Status)
544 {
545 case IP_SUCCESS:
546 {
548
549 if (pEchoReply->RoundTripTime == 0)
551 else
553
554 if (pEchoReply->RoundTripTime < RTTMin || RTTMin == 0)
555 RTTMin = pEchoReply->RoundTripTime;
556
557 if (pEchoReply->RoundTripTime > RTTMax || RTTMax == 0)
558 RTTMax = pEchoReply->RoundTripTime;
559
560 ConPuts(StdOut, L"\n");
561
562 RTTTotal += pEchoReply->RoundTripTime;
563 break;
564 }
565
568 break;
569
572 break;
573
576 break;
577
578 default:
580 break;
581 }
582 }
583 else
584 {
585#ifdef _WIN64
586 PICMP_ECHO_REPLY32 pEchoReply;
587#else
588 PICMP_ECHO_REPLY pEchoReply;
589#endif
590 IPAddr *IP4Addr;
591
592#ifdef _WIN64
593 pEchoReply = (PICMP_ECHO_REPLY32)ReplyBuffer;
594#else
595 pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer;
596#endif
597
598 IP4Addr = (IPAddr *)&pEchoReply->Address;
599 SockAddrIn.sin_family = AF_INET;
600 SockAddrIn.sin_addr.S_un.S_addr = *IP4Addr;
601 SockAddr = (PSOCKADDR)&SockAddrIn;
602 Size = sizeof(SOCKADDR_IN);
603
604 GetNameInfoW(SockAddr,
605 Size,
606 Address,
608 NULL,
609 0,
611
613
614 switch (pEchoReply->Status)
615 {
616 case IP_SUCCESS:
617 {
619
620 ConResPrintf(StdOut, IDS_REPLY_BYTES, pEchoReply->DataSize);
621
622 if (pEchoReply->RoundTripTime == 0)
624 else
625 ConResPrintf(StdOut, IDS_REPLY_TIME_MS, pEchoReply->RoundTripTime);
626
627 ConResPrintf(StdOut, IDS_REPLY_TTL, pEchoReply->Options.Ttl);
628
629 if (pEchoReply->RoundTripTime < RTTMin || RTTMin == 0)
630 RTTMin = pEchoReply->RoundTripTime;
631
632 if (pEchoReply->RoundTripTime > RTTMax || RTTMax == 0)
633 RTTMax = pEchoReply->RoundTripTime;
634
635 RTTTotal += pEchoReply->RoundTripTime;
636 break;
637 }
638
641 break;
642
645 break;
646
649 break;
650
651 default:
652 ConResPrintf(StdOut, IDS_REPLY_STATUS, pEchoReply->Status);
653 break;
654 }
655 }
656 }
657
659}
660
661static
662void
664{
665 ULONG EchosLost = EchosSent - EchosReceived;
666 ULONG PercentLost = (ULONG)((EchosLost / (double)EchosSent) * 100.0);
667
669
670 if (EchosSuccessful > 0)
671 {
672 ULONG RTTAverage = RTTTotal / EchosSuccessful;
674 }
675}
676
677static
678BOOL
679WINAPI
681{
682 switch (ControlType)
683 {
684 case CTRL_C_EVENT:
685 PrintStats();
687 return FALSE;
688
689 case CTRL_BREAK_EVENT:
690 PrintStats();
692 return TRUE;
693
694 case CTRL_CLOSE_EVENT:
695 PrintStats();
696 return FALSE;
697
698 default:
699 return FALSE;
700 }
701}
static int argc
Definition: ServiceArgs.c:12
INT WSAAPI GetNameInfoW(IN CONST SOCKADDR *pSockaddr, IN socklen_t SockaddrLength, OUT PWCHAR pNodeBuffer, IN DWORD NodeBufferSize, OUT PWCHAR pServiceBuffer, IN DWORD ServiceBufferSize, IN INT Flags)
Definition: addrinfo.c:873
#define FreeAddrInfoW(a)
Definition: addrinfo.c:21
INT WSAAPI GetAddrInfoW(IN PCWSTR pszNodeName, IN PCWSTR pszServiceName, IN const ADDRINFOW *ptHints, OUT PADDRINFOW *pptResult)
Definition: addrinfo.c:509
#define IDS_USAGE
Definition: resource.h:3
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define ConInitStdStreams()
Definition: fc.c:13
#define StdOut
Definition: fc.c:14
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
#define StdErr
Definition: fc.c:15
#define IDS_APPROXIMATE_RTT
Definition: resource.h:30
#define IDS_STATISTICS
Definition: resource.h:29
#define IDS_BAD_VALUE
Definition: resource.h:11
#define IDS_CTRL_BREAK
Definition: resource.h:4
#define IDS_TTL_EXPIRED
Definition: resource.h:27
#define IDS_REPLY_TIME_0MS
Definition: resource.h:21
#define IDS_DEST_HOST_UNREACHABLE
Definition: resource.h:24
#define IDS_REQUEST_TIMED_OUT
Definition: resource.h:26
#define IDS_WINSOCK_FAIL
Definition: resource.h:31
#define IDS_TRANSMIT_FAILED
Definition: resource.h:28
#define IDS_REPLY_STATUS
Definition: resource.h:23
#define IDS_NO_RESOURCES
Definition: resource.h:6
#define IDS_MISSING_ADDRESS
Definition: resource.h:7
#define IDS_DEST_NET_UNREACHABLE
Definition: resource.h:25
#define IDS_BAD_PARAMETER
Definition: resource.h:10
#define IDS_MISSING_VALUE
Definition: resource.h:8
#define IDS_UNKNOWN_HOST
Definition: resource.h:13
#define IDS_REPLY_TTL
Definition: resource.h:22
#define IDS_REPLY_BYTES
Definition: resource.h:19
#define IDS_PINGING_HOSTNAME
Definition: resource.h:15
#define IDS_CTRL_C
Definition: resource.h:5
#define IDS_PING_SIZE
Definition: resource.h:17
#define IDS_REPLY_FROM
Definition: resource.h:18
#define IDS_WRONG_FAMILY
Definition: resource.h:12
#define IDS_REPLY_TIME_MS
Definition: resource.h:20
#define IDS_PINGING_ADDRESS
Definition: resource.h:14
#define IDS_BAD_OPTION
Definition: resource.h:9
wcsncpy
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI IcmpCloseHandle(_In_ HANDLE IcmpHandle)
Definition: icmp.c:202
DWORD WINAPI IcmpSendEcho2(_In_ HANDLE IcmpHandle, _In_opt_ HANDLE Event, _In_opt_ PIO_APC_ROUTINE ApcRoutine, _In_opt_ PVOID ApcContext, _In_ IPAddr DestinationAddress, _In_ LPVOID RequestData, _In_ WORD RequestSize, _In_opt_ PIP_OPTION_INFORMATION RequestOptions, _Out_ LPVOID ReplyBuffer, _In_ DWORD ReplySize, _In_ DWORD Timeout)
Definition: icmp.c:285
HANDLE WINAPI Icmp6CreateFile(void)
Definition: icmp.c:15
HANDLE WINAPI IcmpCreateFile(void)
Definition: icmp.c:219
DWORD WINAPI Icmp6SendEcho2(_In_ HANDLE IcmpHandle, _In_opt_ HANDLE Event, _In_opt_ PIO_APC_ROUTINE ApcRoutine, _In_opt_ PVOID ApcContext, _In_ struct sockaddr_in6 *SourceAddress, _In_ struct sockaddr_in6 *DestinationAddress, _In_ LPVOID RequestData, _In_ WORD RequestSize, _In_ PIP_OPTION_INFORMATION RequestOptions, _Out_ LPVOID ReplyBuffer, _In_ DWORD ReplySize, _In_ DWORD Timeout)
Definition: icmp.c:77
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add)
Definition: console.c:2109
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
#define AF_INET
Definition: tcpip.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_ PFLT_PORT _In_ ULONG _Out_writes_bytes_opt_ ReplyLength PVOID ReplyBuffer
Definition: fltkernel.h:1902
Status
Definition: gdiplustypes.h:25
GLenum target
Definition: glext.h:7315
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
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define UCHAR_MAX
Definition: limits.h:25
#define UINT_MAX
Definition: intsafe.h:152
#define IP_DEST_NET_UNREACHABLE
Definition: ipexport.h:115
ICMPV6_ECHO_REPLY_LH ICMPV6_ECHO_REPLY
Definition: ipexport.h:194
#define IP_DEST_HOST_UNREACHABLE
Definition: ipexport.h:116
struct _IPV6_ADDRESS_EX * PIPV6_ADDRESS_EX
struct icmp_echo_reply * PICMP_ECHO_REPLY
struct icmp_echo_reply ICMP_ECHO_REPLY
#define IP_REQ_TIMED_OUT
Definition: ipexport.h:123
#define IP_FLAG_DF
Definition: ipexport.h:53
#define IP_TTL_EXPIRED_TRANSIT
Definition: ipexport.h:126
#define IP_SUCCESS
Definition: ipexport.h:113
ICMPV6_ECHO_REPLY_LH * PICMPV6_ECHO_REPLY
Definition: ipexport.h:195
int socklen_t
Definition: tcp.c:35
#define argv
Definition: mplay32.c:18
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
ULONG IPAddr
Definition: pfhook.h:35
#define SIZEOF_ICMP_ERROR
Definition: ping.c:49
static WCHAR Address[46]
Definition: ping.c:68
#define SIZEOF_IO_STATUS_BLOCK
Definition: ping.c:50
static ULONG Timeout
Definition: ping.c:61
static BOOL PingForever
Definition: ping.c:65
static ULONG RTTMin
Definition: ping.c:73
static BOOL ResolveAddress
Definition: ping.c:70
static ULONG EchosSent
Definition: ping.c:75
static ULONG RequestSize
Definition: ping.c:63
static ULONG RTTMax
Definition: ping.c:72
static HANDLE hIcmpFile
Definition: ping.c:60
static void Ping(void)
Definition: ping.c:419
static WCHAR CanonName[NI_MAXHOST]
Definition: ping.c:69
static IP_OPTION_INFORMATION IpOptions
Definition: ping.c:79
static ULONG RTTTotal
Definition: ping.c:74
static PCWSTR TargetName
Definition: ping.c:67
#define DEFAULT_TIMEOUT
Definition: ping.c:51
static ULONG EchosSuccessful
Definition: ping.c:77
static ULONG EchosReceived
Definition: ping.c:76
static BOOL WINAPI ConsoleCtrlHandler(DWORD ControlType)
Definition: ping.c:680
#define MAX_SEND_SIZE
Definition: ping.c:52
static ULONG PingCount
Definition: ping.c:64
static BOOL ParseCmdLine(int argc, PWSTR argv[])
Definition: ping.c:168
static void PrintStats(void)
Definition: ping.c:663
static int Family
Definition: ping.c:62
int wmain()
INT WSAAPI WSAAddressToStringW(IN LPSOCKADDR lpsaAddress, IN DWORD dwAddressLength, IN LPWSAPROTOCOL_INFOW lpProtocolInfo, OUT LPWSTR lpszAddressString, IN OUT LPDWORD lpdwAddressStringLength)
Definition: rnr.c:128
#define exit(n)
Definition: config.h:202
#define DPRINT
Definition: sndvol32.h:73
#define _countof(array)
Definition: sndvol32.h:70
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80
USHORT sin6_addr[8]
Definition: ipexport.h:173
IPV6_ADDRESS_EX Address
Definition: ipexport.h:189
unsigned int RoundTripTime
Definition: ipexport.h:191
USHORT Word[8]
Definition: in6addr.h:6
union in6_addr::@3083 u
unsigned char Flags
Definition: ipexport.h:35
unsigned char Ttl
Definition: ipexport.h:33
ADDRESS_FAMILY sin6_family
Definition: ws2ipdef.h:179
IN6_ADDR sin6_addr
Definition: ws2ipdef.h:182
struct in_addr sin_addr
Definition: winsock.h:512
short sin_family
Definition: winsock.h:510
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
static bool ResolveTarget()
Definition: tracert.cpp:176
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define MAKEWORD(a, b)
Definition: typedefs.h:248
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
#define ZeroMemory
Definition: winbase.h:1743
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CopyMemory
Definition: winbase.h:1741
#define CTRL_C_EVENT
Definition: wincon.h:68
#define CTRL_BREAK_EVENT
Definition: wincon.h:69
#define CTRL_CLOSE_EVENT
Definition: wincon.h:70
#define WINAPI
Definition: msvc.h:6
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:112
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60
struct sockaddr_in SOCKADDR_IN
Definition: winsock.h:487
struct sockaddr * PSOCKADDR
Definition: winsock.h:485
#define AF_INET6
Definition: winsock.h:369
#define AF_UNSPEC
Definition: winsock.h:344
#define NI_NAMEREQD
Definition: ws2def.h:355
#define AI_NUMERICHOST
Definition: ws2def.h:295
#define NI_NUMERICHOST
Definition: ws2def.h:354
#define AI_CANONNAME
Definition: ws2def.h:294
#define NI_MAXHOST
Definition: ws2def.h:359
SOCKADDR_IN6_LH SOCKADDR_IN6
Definition: ws2ipdef.h:199
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180