Lines 152-157
Link Here
|
152 |
#define DEFDATALEN ICMP6ECHOTMLEN |
152 |
#define DEFDATALEN ICMP6ECHOTMLEN |
153 |
#define MAXDATALEN MAXPACKETLEN - IP6LEN - ICMP6ECHOLEN |
153 |
#define MAXDATALEN MAXPACKETLEN - IP6LEN - ICMP6ECHOLEN |
154 |
#define NROUTES 9 /* number of record route slots */ |
154 |
#define NROUTES 9 /* number of record route slots */ |
|
|
155 |
#define MAXWAIT 10000 /* max ms to wait for response */ |
156 |
#define MAXALARM (60 * 60) /* max seconds for alarm timeout */ |
155 |
|
157 |
|
156 |
#define A(bit) rcvd_tbl[(bit)>>3] /* identify byte in array */ |
158 |
#define A(bit) rcvd_tbl[(bit)>>3] /* identify byte in array */ |
157 |
#define B(bit) (1 << ((bit) & 0x07)) /* identify bit in byte */ |
159 |
#define B(bit) (1 << ((bit) & 0x07)) /* identify bit in byte */ |
Lines 188-193
Link Here
|
188 |
#define F_MISSED 0x800000 |
190 |
#define F_MISSED 0x800000 |
189 |
#define F_DONTFRAG 0x1000000 |
191 |
#define F_DONTFRAG 0x1000000 |
190 |
#define F_NOUSERDATA (F_NODEADDR | F_FQDN | F_FQDNOLD | F_SUPTYPES) |
192 |
#define F_NOUSERDATA (F_NODEADDR | F_FQDN | F_FQDNOLD | F_SUPTYPES) |
|
|
193 |
#define F_WAITTIME 0x2000000 |
191 |
u_int options; |
194 |
u_int options; |
192 |
|
195 |
|
193 |
#define IN6LEN sizeof(struct in6_addr) |
196 |
#define IN6LEN sizeof(struct in6_addr) |
Lines 228-233
Link Here
|
228 |
long nrepeats; /* number of duplicates */ |
231 |
long nrepeats; /* number of duplicates */ |
229 |
long ntransmitted; /* sequence # for outbound packets = #sent */ |
232 |
long ntransmitted; /* sequence # for outbound packets = #sent */ |
230 |
int interval = 1000; /* interval between packets in ms */ |
233 |
int interval = 1000; /* interval between packets in ms */ |
|
|
234 |
int waittime = MAXWAIT; /* timeout for each packet */ |
235 |
long nrcvtimeout = 0; /* # of packets we got back after waittime */ |
231 |
|
236 |
|
232 |
/* timing */ |
237 |
/* timing */ |
233 |
int timing; /* flag to do timing */ |
238 |
int timing; /* flag to do timing */ |
Lines 312-317
Link Here
|
312 |
char *policy_out = NULL; |
317 |
char *policy_out = NULL; |
313 |
#endif |
318 |
#endif |
314 |
double t; |
319 |
double t; |
|
|
320 |
u_long alarmtimeout; |
315 |
size_t rthlen; |
321 |
size_t rthlen; |
316 |
#ifdef IPV6_USE_MIN_MTU |
322 |
#ifdef IPV6_USE_MIN_MTU |
317 |
int mflag = 0; |
323 |
int mflag = 0; |
Lines 321-327
Link Here
|
321 |
memset(&smsghdr, 0, sizeof(smsghdr)); |
327 |
memset(&smsghdr, 0, sizeof(smsghdr)); |
322 |
memset(&smsgiov, 0, sizeof(smsgiov)); |
328 |
memset(&smsgiov, 0, sizeof(smsgiov)); |
323 |
|
329 |
|
324 |
preload = 0; |
330 |
alarmtimeout = preload = 0; |
325 |
datap = &outpack[ICMP6ECHOLEN + ICMP6ECHOTMLEN]; |
331 |
datap = &outpack[ICMP6ECHOLEN + ICMP6ECHOTMLEN]; |
326 |
#ifndef IPSEC |
332 |
#ifndef IPSEC |
327 |
#define ADDOPTS |
333 |
#define ADDOPTS |
Lines 333-339
Link Here
|
333 |
#endif /*IPSEC_POLICY_IPSEC*/ |
339 |
#endif /*IPSEC_POLICY_IPSEC*/ |
334 |
#endif |
340 |
#endif |
335 |
while ((ch = getopt(argc, argv, |
341 |
while ((ch = getopt(argc, argv, |
336 |
"a:b:c:DdfHg:h:I:i:l:mnNop:qrRS:s:tvwW" ADDOPTS)) != -1) { |
342 |
"a:b:c:DdfHg:h:I:i:l:mnNop:qrRS:s:tvwWx:X:" ADDOPTS)) != -1) { |
337 |
#undef ADDOPTS |
343 |
#undef ADDOPTS |
338 |
switch (ch) { |
344 |
switch (ch) { |
339 |
case 'a': |
345 |
case 'a': |
Lines 541-546
Link Here
|
541 |
options &= ~F_NOUSERDATA; |
547 |
options &= ~F_NOUSERDATA; |
542 |
options |= F_FQDNOLD; |
548 |
options |= F_FQDNOLD; |
543 |
break; |
549 |
break; |
|
|
550 |
case 'x': |
551 |
t = strtod(optarg, &e); |
552 |
if (*e || e == optarg || t > (double)INT_MAX) |
553 |
err(EX_USAGE, "invalid timing interval: `%s'", |
554 |
optarg); |
555 |
options |= F_WAITTIME; |
556 |
waittime = (int)t; |
557 |
break; |
558 |
case 'X': |
559 |
alarmtimeout = strtoul(optarg, &e, 0); |
560 |
if ((alarmtimeout < 1) || (alarmtimeout == ULONG_MAX)) |
561 |
errx(EX_USAGE, "invalid timeout: `%s'", |
562 |
optarg); |
563 |
if (alarmtimeout > MAXALARM) |
564 |
errx(EX_USAGE, "invalid timeout: `%s' > %d", |
565 |
optarg, MAXALARM); |
566 |
alarm((int)alarmtimeout); |
567 |
break; |
544 |
#ifdef IPSEC |
568 |
#ifdef IPSEC |
545 |
#ifdef IPSEC_POLICY_IPSEC |
569 |
#ifdef IPSEC_POLICY_IPSEC |
546 |
case 'P': |
570 |
case 'P': |
Lines 1057-1062
Link Here
|
1057 |
err(EX_OSERR, "sigaction SIGINFO"); |
1081 |
err(EX_OSERR, "sigaction SIGINFO"); |
1058 |
seeninfo = 0; |
1082 |
seeninfo = 0; |
1059 |
#endif |
1083 |
#endif |
|
|
1084 |
if (alarmtimeout > 0) { |
1085 |
if (sigaction(SIGALRM, &si_sa, 0) == -1) |
1086 |
err(EX_OSERR, "sigaction SIGALRM"); |
1087 |
} |
1060 |
if (options & F_FLOOD) { |
1088 |
if (options & F_FLOOD) { |
1061 |
intvl.tv_sec = 0; |
1089 |
intvl.tv_sec = 0; |
1062 |
intvl.tv_usec = 10000; |
1090 |
intvl.tv_usec = 10000; |
Lines 1157-1173
Link Here
|
1157 |
/* |
1185 |
/* |
1158 |
* If we're not transmitting any more packets, |
1186 |
* If we're not transmitting any more packets, |
1159 |
* change the timer to wait two round-trip times |
1187 |
* change the timer to wait two round-trip times |
1160 |
* if we've received any packets or ten seconds |
1188 |
* if we've received any packets or (waittime) |
1161 |
* if we haven't. |
1189 |
* milliseconds if we haven't. |
1162 |
*/ |
1190 |
*/ |
1163 |
#define MAXWAIT 10 |
|
|
1164 |
intvl.tv_usec = 0; |
1191 |
intvl.tv_usec = 0; |
1165 |
if (nreceived) { |
1192 |
if (nreceived) { |
1166 |
intvl.tv_sec = 2 * tmax / 1000; |
1193 |
intvl.tv_sec = 2 * tmax / 1000; |
1167 |
if (intvl.tv_sec == 0) |
1194 |
if (intvl.tv_sec == 0) |
1168 |
intvl.tv_sec = 1; |
1195 |
intvl.tv_sec = 1; |
1169 |
} else |
1196 |
} else { |
1170 |
intvl.tv_sec = MAXWAIT; |
1197 |
intvl.tv_sec = waittime / 1000; |
|
|
1198 |
intvl.tv_usec = waittime % 1000 * 1000; |
1199 |
} |
1171 |
} |
1200 |
} |
1172 |
gettimeofday(&last, NULL); |
1201 |
gettimeofday(&last, NULL); |
1173 |
if (ntransmitted - nreceived - 1 > nmissedmax) { |
1202 |
if (ntransmitted - nreceived - 1 > nmissedmax) { |
Lines 1181-1186
Link Here
|
1181 |
si_sa.sa_flags = 0; |
1210 |
si_sa.sa_flags = 0; |
1182 |
si_sa.sa_handler = SIG_IGN; |
1211 |
si_sa.sa_handler = SIG_IGN; |
1183 |
sigaction(SIGINT, &si_sa, 0); |
1212 |
sigaction(SIGINT, &si_sa, 0); |
|
|
1213 |
sigaction(SIGALRM, &si_sa, 0); |
1184 |
summary(); |
1214 |
summary(); |
1185 |
|
1215 |
|
1186 |
if (res != NULL) |
1216 |
if (res != NULL) |
Lines 1198-1203
Link Here
|
1198 |
|
1228 |
|
1199 |
switch (sig) { |
1229 |
switch (sig) { |
1200 |
case SIGINT: |
1230 |
case SIGINT: |
|
|
1231 |
case SIGALRM: |
1201 |
seenint++; |
1232 |
seenint++; |
1202 |
break; |
1233 |
break; |
1203 |
#ifdef SIGINFO |
1234 |
#ifdef SIGINFO |
Lines 1521-1526
Link Here
|
1521 |
if (options & F_QUIET) |
1552 |
if (options & F_QUIET) |
1522 |
return; |
1553 |
return; |
1523 |
|
1554 |
|
|
|
1555 |
if (options & F_WAITTIME && triptime > waittime) { |
1556 |
++nrcvtimeout; |
1557 |
return; |
1558 |
} |
1559 |
|
1524 |
if (options & F_FLOOD) |
1560 |
if (options & F_FLOOD) |
1525 |
(void)write(STDOUT_FILENO, &BSPACE, 1); |
1561 |
(void)write(STDOUT_FILENO, &BSPACE, 1); |
1526 |
else { |
1562 |
else { |
Lines 2216-2221
Link Here
|
2216 |
((((double)ntransmitted - nreceived) * 100.0) / |
2252 |
((((double)ntransmitted - nreceived) * 100.0) / |
2217 |
ntransmitted)); |
2253 |
ntransmitted)); |
2218 |
} |
2254 |
} |
|
|
2255 |
if (nrcvtimeout) |
2256 |
printf(", %ld packets out of wait time", nrcvtimeout); |
2219 |
(void)putchar('\n'); |
2257 |
(void)putchar('\n'); |
2220 |
if (nreceived && timing) { |
2258 |
if (nreceived && timing) { |
2221 |
/* Only display average to microseconds */ |
2259 |
/* Only display average to microseconds */ |
Lines 2741-2746
Link Here
|
2741 |
#endif |
2779 |
#endif |
2742 |
"\n" |
2780 |
"\n" |
2743 |
" [-p pattern] [-S sourceaddr] [-s packetsize] " |
2781 |
" [-p pattern] [-S sourceaddr] [-s packetsize] " |
2744 |
"[hops ...] host\n"); |
2782 |
"[-x waittime]\n" |
|
|
2783 |
" [-X timeout] [hops ...] host\n"); |
2745 |
exit(1); |
2784 |
exit(1); |
2746 |
} |
2785 |
} |