|
|
@ -355,6 +355,8 @@ int verbose_flag, quiet_flag, stats_flag, unreachable_flag, alive_flag;
|
|
|
|
int elapsed_flag, version_flag, count_flag, loop_flag, netdata_flag;
|
|
|
|
int elapsed_flag, version_flag, count_flag, loop_flag, netdata_flag;
|
|
|
|
int per_recv_flag, report_all_rtts_flag, name_flag, addr_flag, backoff_flag, rdns_flag;
|
|
|
|
int per_recv_flag, report_all_rtts_flag, name_flag, addr_flag, backoff_flag, rdns_flag;
|
|
|
|
int multif_flag, timeout_flag, fast_reachable;
|
|
|
|
int multif_flag, timeout_flag, fast_reachable;
|
|
|
|
|
|
|
|
int tos_flag = 0;
|
|
|
|
|
|
|
|
int print_tos_flag = 0;
|
|
|
|
int outage_flag = 0;
|
|
|
|
int outage_flag = 0;
|
|
|
|
int timestamp_flag = 0;
|
|
|
|
int timestamp_flag = 0;
|
|
|
|
int timestamp_format_flag = 0;
|
|
|
|
int timestamp_format_flag = 0;
|
|
|
@ -543,6 +545,7 @@ int main(int argc, char **argv)
|
|
|
|
{ "netdata", 'N', OPTPARSE_NONE },
|
|
|
|
{ "netdata", 'N', OPTPARSE_NONE },
|
|
|
|
{ "outage", 'o', OPTPARSE_NONE },
|
|
|
|
{ "outage", 'o', OPTPARSE_NONE },
|
|
|
|
{ "tos", 'O', OPTPARSE_REQUIRED },
|
|
|
|
{ "tos", 'O', OPTPARSE_REQUIRED },
|
|
|
|
|
|
|
|
{ "print-tos", '0', OPTPARSE_NONE },
|
|
|
|
{ "period", 'p', OPTPARSE_REQUIRED },
|
|
|
|
{ "period", 'p', OPTPARSE_REQUIRED },
|
|
|
|
{ "quiet", 'q', OPTPARSE_NONE },
|
|
|
|
{ "quiet", 'q', OPTPARSE_NONE },
|
|
|
|
{ "squiet", 'Q', OPTPARSE_REQUIRED },
|
|
|
|
{ "squiet", 'Q', OPTPARSE_REQUIRED },
|
|
|
@ -576,6 +579,10 @@ int main(int argc, char **argv)
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
usage(1);
|
|
|
|
usage(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (strstr(optparse_state.optlongname, "print-tos") != NULL) {
|
|
|
|
|
|
|
|
print_tos_flag = 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
usage(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case '4':
|
|
|
|
case '4':
|
|
|
@ -879,6 +886,7 @@ int main(int argc, char **argv)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
tos_flag = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
usage(1);
|
|
|
|
usage(1);
|
|
|
@ -2153,14 +2161,16 @@ int decode_icmp_ipv4(
|
|
|
|
char *reply_buf,
|
|
|
|
char *reply_buf,
|
|
|
|
size_t reply_buf_len,
|
|
|
|
size_t reply_buf_len,
|
|
|
|
unsigned short *id,
|
|
|
|
unsigned short *id,
|
|
|
|
unsigned short *seq)
|
|
|
|
unsigned short *seq,
|
|
|
|
|
|
|
|
int *ip_header_tos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct icmp *icp;
|
|
|
|
struct icmp *icp;
|
|
|
|
|
|
|
|
struct ip *ip;
|
|
|
|
int hlen = 0;
|
|
|
|
int hlen = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (!using_sock_dgram4) {
|
|
|
|
ip = (struct ip *)reply_buf;
|
|
|
|
struct ip *ip = (struct ip *)reply_buf;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!using_sock_dgram4) {
|
|
|
|
#if defined(__alpha__) && __STDC__ && !defined(__GLIBC__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
|
|
|
#if defined(__alpha__) && __STDC__ && !defined(__GLIBC__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
|
|
|
/* The alpha headers are decidedly broken.
|
|
|
|
/* The alpha headers are decidedly broken.
|
|
|
|
* Using an ANSI compiler, it provides ip_vhl instead of ip_hl and
|
|
|
|
* Using an ANSI compiler, it provides ip_vhl instead of ip_hl and
|
|
|
@ -2250,6 +2260,7 @@ int decode_icmp_ipv4(
|
|
|
|
|
|
|
|
|
|
|
|
*id = icp->icmp_id;
|
|
|
|
*id = icp->icmp_id;
|
|
|
|
*seq = ntohs(icp->icmp_seq);
|
|
|
|
*seq = ntohs(icp->icmp_seq);
|
|
|
|
|
|
|
|
*ip_header_tos = ip->ip_tos;
|
|
|
|
|
|
|
|
|
|
|
|
return hlen;
|
|
|
|
return hlen;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2360,6 +2371,7 @@ int wait_for_reply(int64_t wait_time)
|
|
|
|
SEQMAP_VALUE *seqmap_value;
|
|
|
|
SEQMAP_VALUE *seqmap_value;
|
|
|
|
unsigned short id;
|
|
|
|
unsigned short id;
|
|
|
|
unsigned short seq;
|
|
|
|
unsigned short seq;
|
|
|
|
|
|
|
|
int ip_header_tos;
|
|
|
|
|
|
|
|
|
|
|
|
/* Receive packet */
|
|
|
|
/* Receive packet */
|
|
|
|
result = receive_packet(wait_time, /* max. wait time, in ns */
|
|
|
|
result = receive_packet(wait_time, /* max. wait time, in ns */
|
|
|
@ -2386,7 +2398,8 @@ int wait_for_reply(int64_t wait_time)
|
|
|
|
buffer,
|
|
|
|
buffer,
|
|
|
|
sizeof(buffer),
|
|
|
|
sizeof(buffer),
|
|
|
|
&id,
|
|
|
|
&id,
|
|
|
|
&seq);
|
|
|
|
&seq,
|
|
|
|
|
|
|
|
&ip_header_tos);
|
|
|
|
if (ip_hlen < 0) {
|
|
|
|
if (ip_hlen < 0) {
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2486,8 +2499,12 @@ int wait_for_reply(int64_t wait_time)
|
|
|
|
if (verbose_flag || alive_flag) {
|
|
|
|
if (verbose_flag || alive_flag) {
|
|
|
|
printf("%s", h->host);
|
|
|
|
printf("%s", h->host);
|
|
|
|
|
|
|
|
|
|
|
|
if (verbose_flag)
|
|
|
|
if (verbose_flag) {
|
|
|
|
printf(" is alive");
|
|
|
|
printf(" is alive");
|
|
|
|
|
|
|
|
if (tos_flag && print_tos_flag) {
|
|
|
|
|
|
|
|
printf(" (TOS %d)", ip_header_tos);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (elapsed_flag)
|
|
|
|
if (elapsed_flag)
|
|
|
|
printf(" (%s ms)", sprint_tm(this_reply));
|
|
|
|
printf(" (%s ms)", sprint_tm(this_reply));
|
|
|
@ -3057,5 +3074,6 @@ void usage(int is_error)
|
|
|
|
fprintf(out, " -v, --version show version\n");
|
|
|
|
fprintf(out, " -v, --version show version\n");
|
|
|
|
fprintf(out, " -x, --reachable=N shows if >=N hosts are reachable or not\n");
|
|
|
|
fprintf(out, " -x, --reachable=N shows if >=N hosts are reachable or not\n");
|
|
|
|
fprintf(out, " -X, --fast-reachable=N exits true immediately when N hosts are found\n");
|
|
|
|
fprintf(out, " -X, --fast-reachable=N exits true immediately when N hosts are found\n");
|
|
|
|
|
|
|
|
fprintf(out, " --print-tos show tos value (-O are required)");
|
|
|
|
exit(is_error);
|
|
|
|
exit(is_error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|