mirror of
https://git.freebsd.org/ports.git
synced 2025-05-14 08:11:50 -04:00
This perl module allows to change default timeout backoff and validates new value with its set_backoff() function. This function contains obvious copy-paste error from previous functions set_timeout()/set_retries() that deal with integer values. So, set_backoff() erroneously check the value to be integer but it should accept fractional numbers, too. This change corrects the check eliminating int($backoff) call. Corrected code compares new value with 1.0 just like old one but catches possible warning on argument being non-numeric (non-floating point) and rejects non-numeric allowing fractional numbers. The change makes it possible to use the following within mrtg configuration file: SnmpOptions: backoff => 1.1 PR: 249015 Approved by: demon (maintainer)
73 lines
2.7 KiB
Perl
73 lines
2.7 KiB
Perl
--- lib/SNMP_Session.pm.orig 2008-11-21 05:25:17 UTC
|
|
+++ lib/SNMP_Session.pm
|
|
@@ -146,8 +146,8 @@ BEGIN {
|
|
|
|
if (eval {local $SIG{__DIE__};require Socket6;} &&
|
|
eval {local $SIG{__DIE__};require IO::Socket::INET6; IO::Socket::INET6->VERSION("1.26");}) {
|
|
- import Socket6;
|
|
- $ipv6_addr_len = length(pack_sockaddr_in6(161, inet_pton(AF_INET6(), "::1")));
|
|
+ Socket6->import(qw(inet_pton inet_ntop getaddrinfo));
|
|
+ $ipv6_addr_len = length(Socket6::pack_sockaddr_in6(161, inet_pton(AF_INET6(), "::1")));
|
|
$SNMP_Session::ipv6available = 1;
|
|
}
|
|
eval 'local $SIG{__DIE__};local $SIG{__WARN__};$dont_wait_flags = MSG_DONTWAIT();';
|
|
@@ -194,8 +194,11 @@ sub set_retries {
|
|
}
|
|
sub set_backoff {
|
|
my ($session, $backoff) = @_;
|
|
+ my ($_good, $_warn);
|
|
+
|
|
+ { local $SIG{__WARN__} = sub { $_warn = $_[0] }; $_good = $backoff >= 1.0; }
|
|
croak ("backoff ($backoff) must be a number >= 1.0")
|
|
- unless $backoff == int ($backoff) && $backoff >= 1.0;
|
|
+ unless $_good && !$_warn;
|
|
$session->{'backoff'} = $backoff;
|
|
}
|
|
|
|
@@ -549,7 +552,7 @@ sub pretty_address {
|
|
# complaining about AF_INET6 when Socket6 is not available
|
|
|
|
if( (defined $ipv6_addr_len) && (length $addr == $ipv6_addr_len)) {
|
|
- ($port,$addrunpack) = unpack_sockaddr_in6 ($addr);
|
|
+ ($port,$addrunpack) = Socket6::unpack_sockaddr_in6 ($addr);
|
|
$addrstr = inet_ntop (AF_INET6(), $addrunpack);
|
|
} else {
|
|
($port,$addrunpack) = unpack_sockaddr_in ($addr);
|
|
@@ -605,7 +608,7 @@ use Carp;
|
|
BEGIN {
|
|
if($SNMP_Session::ipv6available) {
|
|
import IO::Socket::INET6;
|
|
- import Socket6;
|
|
+ Socket6->import(qw(inet_pton inet_ntop getaddrinfo));
|
|
}
|
|
}
|
|
|
|
@@ -825,8 +828,8 @@ sub sa_equal_p ($$$) {
|
|
($p2,$a2) = unpack_sockaddr_in ($sa2);
|
|
} elsif($this->{'sockfamily'} == AF_INET6()) {
|
|
# IPv6 addresses
|
|
- ($p1,$a1) = unpack_sockaddr_in6 ($sa1);
|
|
- ($p2,$a2) = unpack_sockaddr_in6 ($sa2);
|
|
+ ($p1,$a1) = Socket6::unpack_sockaddr_in6 ($sa1);
|
|
+ ($p2,$a2) = Socket6::unpack_sockaddr_in6 ($sa2);
|
|
} else {
|
|
return 0;
|
|
}
|
|
@@ -899,7 +902,7 @@ sub receive_trap {
|
|
return undef unless $remote_addr;
|
|
|
|
if( (defined $ipv6_addr_len) && (length $remote_addr == $ipv6_addr_len)) {
|
|
- ($port,$iaddr) = unpack_sockaddr_in6($remote_addr);
|
|
+ ($port,$iaddr) = Socket6::unpack_sockaddr_in6($remote_addr);
|
|
} else {
|
|
($port,$iaddr) = unpack_sockaddr_in($remote_addr);
|
|
}
|
|
@@ -948,7 +951,7 @@ sub receive_request {
|
|
return undef unless $remote_addr;
|
|
|
|
if( (defined $ipv6_addr_len) && (length $remote_addr == $ipv6_addr_len)) {
|
|
- ($port,$iaddr) = unpack_sockaddr_in6($remote_addr);
|
|
+ ($port,$iaddr) = Socket6::unpack_sockaddr_in6($remote_addr);
|
|
} else {
|
|
($port,$iaddr) = unpack_sockaddr_in($remote_addr);
|
|
}
|