mirror of
https://github.com/reactos/reactos.git
synced 2025-05-07 18:56:48 +00:00
Fixed DNS lookup in ping.
Fixed output format. Patch by Andrew Munger (WaxDragon) svn path=/trunk/; revision=13224
This commit is contained in:
parent
a23df2bed0
commit
fcfa663724
1 changed files with 13 additions and 15 deletions
|
@ -331,7 +331,7 @@ BOOL Setup(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (phe != NULL) {
|
if (phe != NULL) {
|
||||||
CopyMemory(&Target.sin_addr, phe->h_addr_list, phe->h_length);
|
CopyMemory(&Target.sin_addr, phe->h_addr, phe->h_length);
|
||||||
} else {
|
} else {
|
||||||
Target.sin_addr.s_addr = Addr;
|
Target.sin_addr.s_addr = Addr;
|
||||||
}
|
}
|
||||||
|
@ -391,19 +391,9 @@ VOID TimeToMsString(LPSTR String, LARGE_INTEGER Time)
|
||||||
LARGE_INTEGER LargeTime;
|
LARGE_INTEGER LargeTime;
|
||||||
|
|
||||||
LargeTime.QuadPart = Time.QuadPart / TicksPerMs.QuadPart;
|
LargeTime.QuadPart = Time.QuadPart / TicksPerMs.QuadPart;
|
||||||
|
|
||||||
_i64toa(LargeTime.QuadPart, Convstr, 10);
|
_i64toa(LargeTime.QuadPart, Convstr, 10);
|
||||||
strcpy(String, Convstr);
|
strcpy(String, Convstr);
|
||||||
strcat(String, ",");
|
|
||||||
|
|
||||||
LargeTime.QuadPart = (Time.QuadPart % TicksPerMs.QuadPart) / TicksPerUs.QuadPart;
|
|
||||||
_i64toa(LargeTime.QuadPart, Convstr, 10);
|
|
||||||
Length = strlen(Convstr);
|
|
||||||
if (Length < 4) {
|
|
||||||
for (i = 0; i < 4 - Length; i++)
|
|
||||||
strcat(String, "0");
|
|
||||||
}
|
|
||||||
|
|
||||||
strcat(String, Convstr);
|
|
||||||
strcat(String, "ms");
|
strcat(String, "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,6 +407,7 @@ BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
|
||||||
CHAR Time[100];
|
CHAR Time[100];
|
||||||
LARGE_INTEGER RelativeTime;
|
LARGE_INTEGER RelativeTime;
|
||||||
LARGE_INTEGER LargeTime;
|
LARGE_INTEGER LargeTime;
|
||||||
|
CHAR Sign[1];
|
||||||
|
|
||||||
IpHeader = (PIPv4_HEADER)buffer;
|
IpHeader = (PIPv4_HEADER)buffer;
|
||||||
|
|
||||||
|
@ -449,10 +440,17 @@ BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
|
||||||
|
|
||||||
RelativeTime.QuadPart = (LargeTime.QuadPart - Icmp->Timestamp.QuadPart);
|
RelativeTime.QuadPart = (LargeTime.QuadPart - Icmp->Timestamp.QuadPart);
|
||||||
|
|
||||||
TimeToMsString(Time, RelativeTime);
|
if ((RelativeTime.QuadPart / TicksPerMs.QuadPart) < 1) {
|
||||||
|
strcpy(Sign, "<");
|
||||||
|
strcpy(Time, "1ms");
|
||||||
|
} else {
|
||||||
|
strcpy(Sign, "=");
|
||||||
|
TimeToMsString(Time, RelativeTime);
|
||||||
|
}
|
||||||
|
|
||||||
printf("Reply from %s: bytes=%d time=%s TTL=%d\n", inet_ntoa(from->sin_addr),
|
|
||||||
size - IphLength - sizeof(ICMP_ECHO_PACKET), Time, IpHeader->TTL);
|
printf("Reply from %s: bytes=%d time%s%s TTL=%d\n", inet_ntoa(from->sin_addr),
|
||||||
|
size - IphLength - sizeof(ICMP_ECHO_PACKET), Sign, Time, IpHeader->TTL);
|
||||||
if (RelativeTime.QuadPart < MinRTT.QuadPart) {
|
if (RelativeTime.QuadPart < MinRTT.QuadPart) {
|
||||||
MinRTT.QuadPart = RelativeTime.QuadPart;
|
MinRTT.QuadPart = RelativeTime.QuadPart;
|
||||||
MinRTTSet = TRUE;
|
MinRTTSet = TRUE;
|
||||||
|
|
Loading…
Reference in a new issue