Fix option -m to return all IPs of a hostname

version3
David Schweikert 8 years ago
parent 8481d7432a
commit cc8043b7a6

@ -1,6 +1,7 @@
Unreleased Unreleased
* (feature) Support kernel-timestamping of received packets (#46) * (feature) Support kernel-timestamping of received packets (#46)
* (feature) Simplify restrictions: only -i >= 1 and -p >= 10 are enforced now * (feature) Simplify restrictions: only -i >= 1 and -p >= 10 are enforced now
* (bugfix) Fix option -m to return all IPs of a hostname
* (bugfix) Fix compatibility issue with AIX (#69, @blentzgh) * (bugfix) Fix compatibility issue with AIX (#69, @blentzgh)
* (bugfix) Fix -q not suppressing some ICMP error messages (#83) * (bugfix) Fix -q not suppressing some ICMP error messages (#83)

@ -26,7 +26,7 @@ Usage: fping [options] [targets...]
-H n Set the IP TTL value (Time To Live hops) -H n Set the IP TTL value (Time To Live hops)
-i n interval between sending ping packets (in millisec) (default 25) -i n interval between sending ping packets (in millisec) (default 25)
${I_HELP} -l loop sending pings forever ${I_HELP} -l loop sending pings forever
-m ping multiple interfaces on target host -m use all IPs of provided hostnames (e.g. IPv4 and IPv6), use with -A
-M set the Don't Fragment flag -M set the Don't Fragment flag
-n show targets by name (-d is equivalent) -n show targets by name (-d is equivalent)
-N output compatible for netdata (-l -Q are required) -N output compatible for netdata (-l -Q are required)

@ -125,7 +125,8 @@ Ctrl-C; statistics about responses for each target are then displayed.
=item B<-m> =item B<-m>
Send pings to each of a target host's multiple interfaces. Send pings to each of a target host's multiple IP addresses (use of option '-A'
is recommended).
=item B<-M> =item B<-M>

@ -2074,12 +2074,12 @@ void add_name( char *name )
return; return;
} }
// NOTE: we could/should loop with res on all addresses like this: /* NOTE: we could/should loop with res on all addresses like this:
// for (res = res0; res; res = res->ai_next) { * for (res = res0; res; res = res->ai_next) {
// We don't do it yet, however, because is is an incompatible change * We don't do it yet, however, because is is an incompatible change
// (need to implement a separate option for this) * (need to implement a separate option for this)
*/
for (res = res0; res; res = 0) { for (res = res0; res; res = res->ai_next) {
/* name_flag: addr -> name lookup requested) */ /* name_flag: addr -> name lookup requested) */
if(!name_flag) { if(!name_flag) {
printname = name; printname = name;
@ -2090,13 +2090,16 @@ void add_name( char *name )
sizeof(namebuf)/sizeof(char), NULL, 0, 0); sizeof(namebuf)/sizeof(char), NULL, 0, 0);
if (ret) { if (ret) {
if(!quiet_flag) { if(!quiet_flag) {
print_warning("%s: %s\n", name, gai_strerror(ret_ga)); ret = getnameinfo(res->ai_addr, res->ai_addrlen, namebuf,
sizeof(namebuf)/sizeof(char), NULL, 0, 0);
print_warning("%s: can't reverse-lookup (%s)\n", name, gai_strerror(ret_ga));
} }
num_noaddress++; printname = name;
return;
} }
else {
printname = namebuf; printname = namebuf;
} }
}
/* addr_flag: name -> addr lookup requested */ /* addr_flag: name -> addr lookup requested */
if(addr_flag) { if(addr_flag) {
@ -2105,10 +2108,9 @@ void add_name( char *name )
sizeof(addrbuf)/sizeof(char), NULL, 0, NI_NUMERICHOST); sizeof(addrbuf)/sizeof(char), NULL, 0, NI_NUMERICHOST);
if (ret) { if (ret) {
if(!quiet_flag) { if(!quiet_flag) {
print_warning("%s: %s\n", name, gai_strerror(ret_ga)); print_warning("%s: can't forward-lookup address (%s)\n", name, gai_strerror(ret_ga));
} }
num_noaddress++; continue;
return;
} }
if(name_flag) { if(name_flag) {
@ -2124,7 +2126,9 @@ void add_name( char *name )
add_addr(name, printname, res->ai_addr, res->ai_addrlen); add_addr(name, printname, res->ai_addr, res->ai_addrlen);
} }
return; if(!multif_flag) {
break;
}
} }
} /* add_name() */ } /* add_name() */
@ -2618,7 +2622,7 @@ void usage(int is_error)
fprintf(out, " -I if bind to a particular interface\n"); fprintf(out, " -I if bind to a particular interface\n");
#endif #endif
fprintf(out, " -l loop sending pings forever\n" ); fprintf(out, " -l loop sending pings forever\n" );
fprintf(out, " -m ping multiple interfaces on target host\n" ); fprintf(out, " -m use all IPs of provided hostnames (e.g. IPv4 and IPv6), use with -A\n" );
fprintf(out, " -M set the Don't Fragment flag\n" ); fprintf(out, " -M set the Don't Fragment flag\n" );
fprintf(out, " -n show targets by name (-d is equivalent)\n" ); fprintf(out, " -n show targets by name (-d is equivalent)\n" );
fprintf(out, " -N output compatible for netdata (-l -Q are required)\n" ); fprintf(out, " -N output compatible for netdata (-l -Q are required)\n" );

Loading…
Cancel
Save