108 lines
3.0 KiB
Diff
108 lines
3.0 KiB
Diff
|
diff -Naur A/lib/Net/SNMP/Transport/IPv6.pm B/lib/Net/SNMP/Transport/IPv6.pm
|
||
|
--- A/lib/Net/SNMP/Transport/IPv6.pm 2010-09-10 02:02:45.000000000 +0200
|
||
|
+++ B/lib/Net/SNMP/Transport/IPv6.pm 2023-06-14 09:27:57.736399948 +0200
|
||
|
@@ -19,9 +19,9 @@
|
||
|
|
||
|
use Net::SNMP::Transport qw( DEBUG_INFO );
|
||
|
|
||
|
-use Socket6 0.23 qw(
|
||
|
- PF_INET6 AF_INET6 in6addr_any in6addr_loopback getaddrinfo
|
||
|
- pack_sockaddr_in6_all unpack_sockaddr_in6_all inet_pton inet_ntop
|
||
|
+use Socket qw(
|
||
|
+ PF_INET6 AF_INET6 IN6ADDR_ANY IN6ADDR_LOOPBACK getaddrinfo
|
||
|
+ pack_sockaddr_in6 unpack_sockaddr_in6 inet_pton inet_ntop
|
||
|
);
|
||
|
|
||
|
## Version of the Net::SNMP::Transport::IPv6 module
|
||
|
@@ -89,12 +89,12 @@
|
||
|
|
||
|
sub _addr_any
|
||
|
{
|
||
|
- return in6addr_any;
|
||
|
+ return IN6ADDR_ANY;
|
||
|
}
|
||
|
|
||
|
sub _addr_loopback
|
||
|
{
|
||
|
- return in6addr_loopback;
|
||
|
+ return IN6ADDR_LOOPBACK;
|
||
|
}
|
||
|
|
||
|
sub _hostname_resolve
|
||
|
@@ -117,23 +117,22 @@
|
||
|
|
||
|
# Resolve the address.
|
||
|
|
||
|
- my @info = getaddrinfo(($_[1] = $host), q{}, PF_INET6);
|
||
|
+ my ($err, $info) = getaddrinfo(($_[1] = $host), q{}, {'family' => PF_INET6});
|
||
|
|
||
|
- if (@info >= 5) {
|
||
|
+ if (! $err) {
|
||
|
if ($host =~ s/(.*)%.*$/$1/) { # <address>%<ifName>
|
||
|
$_[1] = $1;
|
||
|
}
|
||
|
- while (@info >= 5) {
|
||
|
- if ($info[0] == PF_INET6) {
|
||
|
- $nh->{flowinfo} = $this->_flowinfo($info[3]);
|
||
|
- $nh->{scope_id} ||= $this->_scope_id($info[3]);
|
||
|
- return $nh->{addr} = $this->_addr($info[3]);
|
||
|
+ while (! $err) {
|
||
|
+ if ($info->{'family'} == PF_INET6) {
|
||
|
+ $nh->{flowinfo} = $this->_flowinfo($info->{'addr'});
|
||
|
+ $nh->{scope_id} ||= $this->_scope_id($info->{'addr'});
|
||
|
+ return $nh->{addr} = $this->_addr($info->{'addr'});
|
||
|
}
|
||
|
- DEBUG_INFO('family = %d, sin = %s', $info[0], unpack 'H*', $info[3]);
|
||
|
- splice @info, 0, 5;
|
||
|
+ DEBUG_INFO('family = %d, sin = %s', $info->{'family'}, unpack 'H*', $info->{'addr'});
|
||
|
}
|
||
|
} else {
|
||
|
- DEBUG_INFO('getaddrinfo(): %s', $info[0]);
|
||
|
+ DEBUG_INFO('getaddrinfo(): %s', $info->{'family'});
|
||
|
if ((my @host = split /:/, $host) == 2) { # <hostname>:<service>
|
||
|
$_[1] = sprintf '[%s]:%s', @host;
|
||
|
return $this->_hostname_resolve($_[1], $nh);
|
||
|
@@ -156,9 +155,9 @@
|
||
|
|
||
|
sub _name_pack
|
||
|
{
|
||
|
- return pack_sockaddr_in6_all(
|
||
|
- $_[1]->{port}, $_[1]->{flowinfo} || 0,
|
||
|
- $_[1]->{addr}, $_[1]->{scope_id} || 0
|
||
|
+ return pack_sockaddr_in6(
|
||
|
+ $_[1]->{port}, $_[1]->{addr},
|
||
|
+ $_[1]->{scope_id} || 0, $_[1]->{flowinfo} || 0
|
||
|
);
|
||
|
}
|
||
|
|
||
|
@@ -169,12 +168,12 @@
|
||
|
|
||
|
sub _addr
|
||
|
{
|
||
|
- return (unpack_sockaddr_in6_all($_[1]))[2];
|
||
|
+ return (unpack_sockaddr_in6($_[1]))[1];
|
||
|
}
|
||
|
|
||
|
sub _port
|
||
|
{
|
||
|
- return (unpack_sockaddr_in6_all($_[1]))[0];
|
||
|
+ return (unpack_sockaddr_in6($_[1]))[0];
|
||
|
}
|
||
|
|
||
|
sub _taddress
|
||
|
@@ -193,12 +192,12 @@
|
||
|
|
||
|
sub _scope_id
|
||
|
{
|
||
|
- return (unpack_sockaddr_in6_all($_[1]))[3];
|
||
|
+ return (unpack_sockaddr_in6($_[1]))[2];
|
||
|
}
|
||
|
|
||
|
sub _flowinfo
|
||
|
{
|
||
|
- return (unpack_sockaddr_in6_all($_[1]))[1];
|
||
|
+ return (unpack_sockaddr_in6($_[1]))[3];
|
||
|
}
|
||
|
|
||
|
# ============================================================================
|