diff --git a/ChangeLog b/ChangeLog index 6c0326c..ab8a038 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ Unreleased * (bugfix) Fix compatibility issue with AIX (#69, @blentzgh) * (bugfix) Fix -q not suppressing some ICMP error messages (#83) * (bugfix) Fix -M expecting an argument, when it shouldn't + * (bugfix) Fix option -H (ttl) for IPv6 + * (bugfix) Fix option -M (don't fragment) for IPv6 + * (bugfix) Fix option -O (ToS) for IPv6 2017-01-11 David Schweikert * Version 3.15 diff --git a/ci/test-07-options-i-m.pl b/ci/test-07-options-i-m.pl index 9a22d13..06e2ece 100755 --- a/ci/test-07-options-i-m.pl +++ b/ci/test-07-options-i-m.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl -w use Test::Command tests => 7; +use Test::More; # -i n interval between sending ping packets (in millisec) (default 25) # -l loop sending pings forever @@ -24,11 +25,14 @@ $cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% l } # fping -M -{ -my $cmd = Test::Command->new(cmd => "fping -M 127.0.0.1"); -$cmd->exit_is_num(0); -$cmd->stdout_is_eq("127.0.0.1 is alive\n"); -$cmd->stderr_is_eq(""); +SKIP: { + if($^O eq 'darwin') { + skip '-M option not supported on macOS', 3; + } + my $cmd = Test::Command->new(cmd => "fping -M 127.0.0.1"); + $cmd->exit_is_num(0); + $cmd->stdout_is_eq("127.0.0.1 is alive\n"); + $cmd->stderr_is_eq(""); } # fping -m -> test-14-internet-hosts diff --git a/ci/test-14-ping-internet-hosts.pl b/ci/test-14-ping-internet-hosts.pl index 12dfe5f..ebb6d35 100755 --- a/ci/test-14-ping-internet-hosts.pl +++ b/ci/test-14-ping-internet-hosts.pl @@ -72,9 +72,12 @@ $cmd->stderr_is_eq(""); } # fping -M -{ -my $cmd = Test::Command->new(cmd => "fping -r 0 -b 10000 -M 8.8.8.8"); -$cmd->exit_is_num(1); -$cmd->stdout_is_eq("8.8.8.8 is unreachable\n"); -$cmd->stderr_is_eq("8.8.8.8: error while sending ping: Message too long\n"); +SKIP: { + if($^O eq 'darwin') { + skip '-M option not supported on macOS', 3; + } + my $cmd = Test::Command->new(cmd => "fping -r 0 -b 10000 -M 8.8.8.8"); + $cmd->exit_is_num(1); + $cmd->stdout_is_eq("8.8.8.8 is unreachable\n"); + $cmd->stderr_is_eq("8.8.8.8: error while sending ping: Message too long\n"); } diff --git a/src/fping.c b/src/fping.c index 0713241..6f3666f 100644 --- a/src/fping.c +++ b/src/fping.c @@ -393,7 +393,11 @@ int main( int argc, char **argv ) #ifdef IP_MTU_DISCOVER { int val = IP_PMTUDISC_DO; +#ifndef IPV6 if (setsockopt(s, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val))) { +#else + if (setsockopt(s, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &val, sizeof(val))) { +#endif perror("setsockopt IP_MTU_DISCOVER"); } } @@ -571,7 +575,11 @@ int main( int argc, char **argv ) case 'O': if (sscanf(optarg,"%i",&tos)){ +#ifndef IPV6 if ( setsockopt(s, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))) { +#else + if ( setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos))) { +#endif perror("setting type of service octet IP_TOS"); } } @@ -724,7 +732,11 @@ int main( int argc, char **argv ) /* set the TTL, if the -H option was set (otherwise ttl will be = 0) */ if(ttl > 0) { +#ifndef IPV6 if (setsockopt(s, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl))) { +#else + if (setsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl))) { +#endif perror("setting time to live"); } }