Subject: | constant IP_TTL conflicts with Socket.pm constant of the same name |
Discovered when running make test:
t/01_trace.t .. Constant subroutine Net::Traceroute::PurePerl::IP_TTL
redefined at [/path/to/]constant.pm line [#].
The PurePerl.pm module utilizes Socket.pm, which exports the constant
named IP_TTL. Since PurePerl.pm also defines this constant we get a
redefine warning. One way to fix this might be to import only a subset
of names we need From Socket. Alternatively and probably easier is to
just rename PurePerl.pm's constant. Suggested patch:
@ -19,7 +19,7 @@
use constant IPPROTO_IP => 0; # from netinet/in.h
# Windows winsock2 uses 4 for IP_TTL instead of 2
-use constant IP_TTL => ( $^O eq "MSWin32" ) ? 4 : 2;
+use constant SOCKOPT_IP_TTL => ( $^O eq "MSWin32" ) ? 4 : 2;
use constant IP_HEADERS => 20; # Length of IP headers
use constant ICMP_HEADERS => 8; # Length of ICMP headers
@@ -764,7 +764,7 @@
}
setsockopt( $self->{'_trace_socket'},
- IPPROTO_IP, IP_TTL, pack( 'C', $hop ) );
+ IPPROTO_IP, SOCKOPT_IP_TTL, pack( 'C', $hop ) );
$self->debug_print( 2, "Set TTL to $hop\n" );
if ( $self->protocol eq 'udp' ) {
John