diff --git a/lib/Net/SIP/Util.pm b/lib/Net/SIP/Util.pm index 99f089d..9a4d7d4 100644 --- a/lib/Net/SIP/Util.pm +++ b/lib/Net/SIP/Util.pm @@ -70,8 +70,16 @@ BEGIN { *AF_INET6 = sub() { -1 }; } - *CAN_IPV6 = $mod6 ? sub() { 1 } : sub() { 0 }; - Socket->import(qw(unpack_sockaddr_in6 pack_sockaddr_in6)) if $mod6; + if ($mod6) { + my $ipv6_disabled; + *CAN_IPV6 = sub() { + $ipv6_disabled = $_[0] if @_ == 1; + return $ipv6_disabled; + }; + Socket->import(qw(unpack_sockaddr_in6 pack_sockaddr_in6)); + } else { + *CAN_IPV6 = sub() { 0 } + } } our @EXPORT = qw(INETSOCK); diff --git a/lib/Net/SIP/Util.pod b/lib/Net/SIP/Util.pod index 275c2ba..39e6dff 100644 --- a/lib/Net/SIP/Util.pod +++ b/lib/Net/SIP/Util.pod @@ -300,4 +300,9 @@ This checks if the given IP address is a valid IPv6 address. This checks if the given IP address is a valid IPv4 or IPv6 address and returns the address family if this is an IP address. +=item CAN_IPV6([bool]) -> ipv6_available + +This checks if IPv6 is supported by Perl. +Use can also be explicitly disabled this way by calling C. + =back