|
|
|
@ -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 per_recv_flag, report_all_rtts_flag, name_flag, addr_flag, backoff_flag, rdns_flag;
|
|
|
|
|
int multif_flag, timeout_flag, fast_reachable;
|
|
|
|
|
int tos_flag = 0;
|
|
|
|
|
int print_tos_flag = 0;
|
|
|
|
|
int outage_flag = 0;
|
|
|
|
|
int timestamp_flag = 0;
|
|
|
|
|
int timestamp_format_flag = 0;
|
|
|
|
@ -543,6 +545,7 @@ int main(int argc, char **argv)
|
|
|
|
|
{ "netdata", 'N', OPTPARSE_NONE },
|
|
|
|
|
{ "outage", 'o', OPTPARSE_NONE },
|
|
|
|
|
{ "tos", 'O', OPTPARSE_REQUIRED },
|
|
|
|
|
{ "print-tos", '0', OPTPARSE_NONE },
|
|
|
|
|
{ "period", 'p', OPTPARSE_REQUIRED },
|
|
|
|
|
{ "quiet", 'q', OPTPARSE_NONE },
|
|
|
|
|
{ "squiet", 'Q', OPTPARSE_REQUIRED },
|
|
|
|
@ -566,16 +569,20 @@ int main(int argc, char **argv)
|
|
|
|
|
while ((c = optparse_long(&optparse_state, longopts, NULL)) != EOF) {
|
|
|
|
|
switch (c) {
|
|
|
|
|
case '0':
|
|
|
|
|
if(strstr(optparse_state.optlongname, "timestamp-format") != NULL) {
|
|
|
|
|
if(strcmp(optparse_state.optarg, "ctime") == 0) {
|
|
|
|
|
timestamp_format_flag = 1;
|
|
|
|
|
}else if(strcmp(optparse_state.optarg, "iso") == 0) {
|
|
|
|
|
timestamp_format_flag = 2;
|
|
|
|
|
}else if(strcmp(optparse_state.optarg, "rfc3339") == 0) {
|
|
|
|
|
timestamp_format_flag = 3;
|
|
|
|
|
}else{
|
|
|
|
|
if (strstr(optparse_state.optlongname, "timestamp-format") != NULL) {
|
|
|
|
|
if(strcmp(optparse_state.optarg, "ctime") == 0) {
|
|
|
|
|
timestamp_format_flag = 1;
|
|
|
|
|
}else if(strcmp(optparse_state.optarg, "iso") == 0) {
|
|
|
|
|
timestamp_format_flag = 2;
|
|
|
|
|
}else if(strcmp(optparse_state.optarg, "rfc3339") == 0) {
|
|
|
|
|
timestamp_format_flag = 3;
|
|
|
|
|
}else{
|
|
|
|
|
usage(1);
|
|
|
|
|
}
|
|
|
|
|
} else if (strstr(optparse_state.optlongname, "print-tos") != NULL) {
|
|
|
|
|
print_tos_flag = 1;
|
|
|
|
|
} else {
|
|
|
|
|
usage(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '4':
|
|
|
|
@ -879,6 +886,7 @@ int main(int argc, char **argv)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
tos_flag = 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
usage(1);
|
|
|
|
@ -2153,14 +2161,16 @@ int decode_icmp_ipv4(
|
|
|
|
|
char *reply_buf,
|
|
|
|
|
size_t reply_buf_len,
|
|
|
|
|
unsigned short *id,
|
|
|
|
|
unsigned short *seq)
|
|
|
|
|
unsigned short *seq,
|
|
|
|
|
int *ip_header_tos)
|
|
|
|
|
{
|
|
|
|
|
struct icmp *icp;
|
|
|
|
|
struct ip *ip;
|
|
|
|
|
int hlen = 0;
|
|
|
|
|
|
|
|
|
|
if (!using_sock_dgram4) {
|
|
|
|
|
struct ip *ip = (struct ip *)reply_buf;
|
|
|
|
|
ip = (struct ip *)reply_buf;
|
|
|
|
|
|
|
|
|
|
if (!using_sock_dgram4) {
|
|
|
|
|
#if defined(__alpha__) && __STDC__ && !defined(__GLIBC__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
|
|
|
|
/* The alpha headers are decidedly broken.
|
|
|
|
|
* 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;
|
|
|
|
|
*seq = ntohs(icp->icmp_seq);
|
|
|
|
|
*ip_header_tos = ip->ip_tos;
|
|
|
|
|
|
|
|
|
|
return hlen;
|
|
|
|
|
}
|
|
|
|
@ -2360,6 +2371,7 @@ int wait_for_reply(int64_t wait_time)
|
|
|
|
|
SEQMAP_VALUE *seqmap_value;
|
|
|
|
|
unsigned short id;
|
|
|
|
|
unsigned short seq;
|
|
|
|
|
int ip_header_tos;
|
|
|
|
|
|
|
|
|
|
/* Receive packet */
|
|
|
|
|
result = receive_packet(wait_time, /* max. wait time, in ns */
|
|
|
|
@ -2386,7 +2398,8 @@ int wait_for_reply(int64_t wait_time)
|
|
|
|
|
buffer,
|
|
|
|
|
sizeof(buffer),
|
|
|
|
|
&id,
|
|
|
|
|
&seq);
|
|
|
|
|
&seq,
|
|
|
|
|
&ip_header_tos);
|
|
|
|
|
if (ip_hlen < 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
@ -2486,8 +2499,12 @@ int wait_for_reply(int64_t wait_time)
|
|
|
|
|
if (verbose_flag || alive_flag) {
|
|
|
|
|
printf("%s", h->host);
|
|
|
|
|
|
|
|
|
|
if (verbose_flag)
|
|
|
|
|
if (verbose_flag) {
|
|
|
|
|
printf(" is alive");
|
|
|
|
|
if (tos_flag && print_tos_flag) {
|
|
|
|
|
printf(" (TOS %d)", ip_header_tos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (elapsed_flag)
|
|
|
|
|
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, " -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, " --print-tos show tos value (-O are required)");
|
|
|
|
|
exit(is_error);
|
|
|
|
|
}
|
|
|
|
|