Lines 200-205
static double tmin = 999999999.0; /* minimum round trip time */
Link Here
|
200 |
static double tmax = 0.0; /* maximum round trip time */ |
200 |
static double tmax = 0.0; /* maximum round trip time */ |
201 |
static double tsum = 0.0; /* sum of all times, for doing average */ |
201 |
static double tsum = 0.0; /* sum of all times, for doing average */ |
202 |
static double tsumsq = 0.0; /* sum of all times squared, for std. dev. */ |
202 |
static double tsumsq = 0.0; /* sum of all times squared, for std. dev. */ |
|
|
203 |
struct tv32 tv32_offset; |
203 |
|
204 |
|
204 |
/* nonzero if we've been told to finish up */ |
205 |
/* nonzero if we've been told to finish up */ |
205 |
static volatile sig_atomic_t finish_up; |
206 |
static volatile sig_atomic_t finish_up; |
Lines 638-644
main(int argc, char *const *argv)
Link Here
|
638 |
for (i = TIMEVAL_LEN; i < datalen; ++i) |
639 |
for (i = TIMEVAL_LEN; i < datalen; ++i) |
639 |
*datap++ = i; |
640 |
*datap++ = i; |
640 |
|
641 |
|
641 |
ident = getpid() & 0xFFFF; |
642 |
ident = arc4random() & 0xFFFF; |
642 |
|
643 |
|
643 |
hold = 1; |
644 |
hold = 1; |
644 |
if (options & F_SO_DEBUG) { |
645 |
if (options & F_SO_DEBUG) { |
Lines 829-834
main(int argc, char *const *argv)
Link Here
|
829 |
(void)printf("PING %s: %d data bytes\n", hostname, datalen); |
830 |
(void)printf("PING %s: %d data bytes\n", hostname, datalen); |
830 |
} |
831 |
} |
831 |
|
832 |
|
|
|
833 |
arc4random_buf(&tv32_offset, sizeof(tv32_offset)); |
834 |
|
832 |
/* |
835 |
/* |
833 |
* Use sigaction() instead of signal() to get unambiguous semantics, |
836 |
* Use sigaction() instead of signal() to get unambiguous semantics, |
834 |
* in particular with SA_RESTART not set. |
837 |
* in particular with SA_RESTART not set. |
Lines 1029-1039
pinger(void)
Link Here
|
1029 |
if ((options & F_TIME) || timing) { |
1032 |
if ((options & F_TIME) || timing) { |
1030 |
(void)gettimeofday(&now, NULL); |
1033 |
(void)gettimeofday(&now, NULL); |
1031 |
|
1034 |
|
1032 |
tv32.tv32_sec = htonl(now.tv_sec); |
1035 |
tv32.tv32_sec = htonl(now.tv_sec + tv32_offset.tv32_sec); |
1033 |
tv32.tv32_usec = htonl(now.tv_usec); |
1036 |
tv32.tv32_usec = htonl(now.tv_usec + tv32_offset.tv32_usec); |
1034 |
if (options & F_TIME) |
1037 |
if (options & F_TIME) |
1035 |
icp->icmp_otime = htonl((now.tv_sec % (24*60*60)) |
1038 |
icp->icmp_otime = htonl((now.tv_sec + tv32_offset.tv32_sec % (24*60*60)) |
1036 |
* 1000 + now.tv_usec / 1000); |
1039 |
* 1000 + now.tv_usec + tv32_offset.tv32_usec / 1000); |
1037 |
if (timing) |
1040 |
if (timing) |
1038 |
bcopy((void *)&tv32, |
1041 |
bcopy((void *)&tv32, |
1039 |
(void *)&outpack[ICMP_MINLEN + phdr_len], |
1042 |
(void *)&outpack[ICMP_MINLEN + phdr_len], |
Lines 1124-1131
pr_pack(char *buf, int cc, struct sockaddr_in *from, struct timeval *tv)
Link Here
|
1124 |
sizeof(tv1)) { |
1127 |
sizeof(tv1)) { |
1125 |
/* Copy to avoid alignment problems: */ |
1128 |
/* Copy to avoid alignment problems: */ |
1126 |
memcpy(&tv32, tp, sizeof(tv32)); |
1129 |
memcpy(&tv32, tp, sizeof(tv32)); |
1127 |
tv1.tv_sec = ntohl(tv32.tv32_sec); |
1130 |
tv1.tv_sec = ntohl(tv32.tv32_sec) - tv32_offset.tv32_sec; |
1128 |
tv1.tv_usec = ntohl(tv32.tv32_usec); |
1131 |
tv1.tv_usec = ntohl(tv32.tv32_usec) - tv32_offset.tv32_usec; |
1129 |
tvsub(tv, &tv1); |
1132 |
tvsub(tv, &tv1); |
1130 |
triptime = ((double)tv->tv_sec) * 1000.0 + |
1133 |
triptime = ((double)tv->tv_sec) * 1000.0 + |
1131 |
((double)tv->tv_usec) / 1000.0; |
1134 |
((double)tv->tv_usec) / 1000.0; |
1132 |
- |
|
|