| 1 | # -*- mode: perl -*- | ||||||||||||||||||||||||||||||||||
| 2 | # ============================================================================ | ||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||
| 4 | package Net::SNMP::Transport; | ||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||
| 6 | # $Id: Transport.pm,v 3.0 2009/09/09 15:05:33 dtown Rel $ | ||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | # Base object for the Net::SNMP Transport Domain objects. | ||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | # Copyright (c) 2004-2009 David M. Town <dtown@cpan.org> | ||||||||||||||||||||||||||||||||||
| 11 | # All rights reserved. | ||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | # This program is free software; you may redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||
| 14 | # under the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | # ============================================================================ | ||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | ## Version of the Net::SNMP::Transport module | ||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | 2 | our $VERSION = v3.0.0; | |||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | ## Handle importing/exporting of symbols | ||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | use base qw( Exporter ); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | 2 | our @EXPORT_OK = qw( TRUE FALSE DEBUG_INFO ); | |||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||
| 30 | 2 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||
| 31 | domains => [ | ||||||||||||||||||||||||||||||||||
| 32 | qw( DOMAIN_UDP DOMAIN_UDPIPV4 DOMAIN_UDPIPV6 DOMAIN_UDPIPV6Z | ||||||||||||||||||||||||||||||||||
| 33 | DOMAIN_TCPIPV4 DOMAIN_TCPIPV6 DOMAIN_TCPIPV6Z ) | ||||||||||||||||||||||||||||||||||
| 34 | ], | ||||||||||||||||||||||||||||||||||
| 35 | msgsize => [ qw( MSG_SIZE_DEFAULT MSG_SIZE_MINIMUM MSG_SIZE_MAXIMUM ) ], | ||||||||||||||||||||||||||||||||||
| 36 | ports => [ qw( SNMP_PORT SNMP_TRAP_PORT ) ], | ||||||||||||||||||||||||||||||||||
| 37 | retries => [ qw( RETRIES_DEFAULT RETRIES_MINIMUM RETRIES_MAXIMUM ) ], | ||||||||||||||||||||||||||||||||||
| 38 | timeout => [ qw( TIMEOUT_DEFAULT TIMEOUT_MINIMUM TIMEOUT_MAXIMUM ) ], | ||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||
| 41 | 2 | Exporter::export_ok_tags( qw( domains msgsize ports retries timeout ) ); | |||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | 2 | $EXPORT_TAGS{ALL} = [ @EXPORT_OK ]; | |||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | ## Transport Layer Domain definitions | ||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | # RFC 3417 Transport Mappings for SNMP | ||||||||||||||||||||||||||||||||||
| 48 | # Presuhn, Case, McCloghrie, Rose, and Waldbusser; December 2002 | ||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | sub DOMAIN_UDP { '1.3.6.1.6.1.1' } # snmpUDPDomain | ||||||||||||||||||||||||||||||||
|
Subroutine
DOMAIN_UDP: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||
| 52 | # RFC 3419 Textual Conventions for Transport Addresses | ||||||||||||||||||||||||||||||||||
| 53 | # Consultant, Schoenwaelder, and Braunschweig; December 2002 | ||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||
| 55 | 10 | ▶ | sub DOMAIN_UDPIPV4 { '1.3.6.1.2.1.100.1.1' } # transportDomainUdpIpv4 | ||||||||||||||||||||||||||||||||
|
Subroutine
DOMAIN_UDPIPV4: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 56 | 10 | ▶ | sub DOMAIN_UDPIPV6 { '1.3.6.1.2.1.100.1.2' } # transportDomainUdpIpv6 | ||||||||||||||||||||||||||||||||
|
Subroutine
DOMAIN_UDPIPV6: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 57 | 2 | ▶ | sub DOMAIN_UDPIPV6Z { '1.3.6.1.2.1.100.1.4' } # transportDomainUdpIpv6z | ||||||||||||||||||||||||||||||||
|
Subroutine
DOMAIN_UDPIPV6Z: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 58 | 8 | ▶ | sub DOMAIN_TCPIPV4 { '1.3.6.1.2.1.100.1.5' } # transportDomainTcpIpv4 | ||||||||||||||||||||||||||||||||
|
Subroutine
DOMAIN_TCPIPV4: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 59 | 10 | ▶ | sub DOMAIN_TCPIPV6 { '1.3.6.1.2.1.100.1.6' } # transportDomainTcpIpv6 | ||||||||||||||||||||||||||||||||
|
Subroutine
DOMAIN_TCPIPV6: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 60 | 2 | ▶ | sub DOMAIN_TCPIPV6Z { '1.3.6.1.2.1.100.1.8' } # transportDomainTcpIpv6z | ||||||||||||||||||||||||||||||||
|
Subroutine
DOMAIN_TCPIPV6Z: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||
| 62 | ## SNMP well-known ports | ||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | 2 | ▶ | sub SNMP_PORT { 161 } | ||||||||||||||||||||||||||||||||
|
Subroutine
SNMP_PORT: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub SNMP_TRAP_PORT { 162 } | ||||||||||||||||||||||||||||||||
|
Subroutine
SNMP_TRAP_PORT: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||
| 67 | ## RFC 3411 - snmpEngineMaxMessageSize::=INTEGER (484..2147483647) | ||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub MSG_SIZE_DEFAULT { 484 } | ||||||||||||||||||||||||||||||||
|
Subroutine
MSG_SIZE_DEFAULT: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub MSG_SIZE_MINIMUM { 484 } | ||||||||||||||||||||||||||||||||
|
Subroutine
MSG_SIZE_MINIMUM: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub MSG_SIZE_MAXIMUM { 65535 } # 2147483647 is not reasonable | ||||||||||||||||||||||||||||||||
|
Subroutine
MSG_SIZE_MAXIMUM: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | sub RETRIES_DEFAULT { 1 } | ||||||||||||||||||||||||||||||||
|
Subroutine
RETRIES_DEFAULT: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub RETRIES_MINIMUM { 0 } | ||||||||||||||||||||||||||||||||
|
Subroutine
RETRIES_MINIMUM: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub RETRIES_MAXIMUM { 20 } | ||||||||||||||||||||||||||||||||
|
Subroutine
RETRIES_MAXIMUM: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||
| 77 | 2 | ▶ | sub TIMEOUT_DEFAULT { 5.0 } | ||||||||||||||||||||||||||||||||
|
Subroutine
TIMEOUT_DEFAULT: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub TIMEOUT_MINIMUM { 1.0 } | ||||||||||||||||||||||||||||||||
|
Subroutine
TIMEOUT_MINIMUM: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub TIMEOUT_MAXIMUM { 60.0 } | ||||||||||||||||||||||||||||||||
|
Subroutine
TIMEOUT_MAXIMUM: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||
| 81 | ## Truth values | ||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | 4 | ▶ | sub TRUE { 0x01 } | ||||||||||||||||||||||||||||||||
|
Subroutine
TRUE: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 84 | 2 | ▶ | sub FALSE { 0x00 } | ||||||||||||||||||||||||||||||||
|
Subroutine
FALSE: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||
| 86 | ## Shared socket array indexes | ||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub _SHARED_SOCKET { 0 } # Shared Socket object | ||||||||||||||||||||||||||||||||
|
Subroutine
_SHARED_SOCKET: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub _SHARED_REFC { 1 } # Reference count | ||||||||||||||||||||||||||||||||
|
Subroutine
_SHARED_REFC: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub _SHARED_MAXSIZE { 2 } # Shared maxMsgSize | ||||||||||||||||||||||||||||||||
|
Subroutine
_SHARED_MAXSIZE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||
| 92 | ## Package variables | ||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||
| 94 | 2 | our $DEBUG = FALSE; # Debug flag | |||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||
| 96 | 2 | our $AUTOLOAD; # Used by the AUTOLOAD method | |||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||
| 98 | 2 | our $SOCKETS = {}; # List of shared sockets | |||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||
| 100 | # [public methods] ----------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||
| 102 | { | ||||||||||||||||||||||||||||||||||
| 103 | 2 | my $domains = { | |||||||||||||||||||||||||||||||||
| 104 | 'udp/?(?:ip)?v?4?', DOMAIN_UDPIPV4, | ||||||||||||||||||||||||||||||||||
| 105 | quotemeta DOMAIN_UDP, DOMAIN_UDPIPV4, | ||||||||||||||||||||||||||||||||||
| 106 | quotemeta DOMAIN_UDPIPV4, DOMAIN_UDPIPV4, | ||||||||||||||||||||||||||||||||||
| 107 | 'udp/?(?:ip)?v?6', DOMAIN_UDPIPV6, | ||||||||||||||||||||||||||||||||||
| 108 | quotemeta DOMAIN_UDPIPV6, DOMAIN_UDPIPV6, | ||||||||||||||||||||||||||||||||||
| 109 | quotemeta DOMAIN_UDPIPV6Z, DOMAIN_UDPIPV6, | ||||||||||||||||||||||||||||||||||
| 110 | 'tcp/?(?:ip)?v?4?', DOMAIN_TCPIPV4, | ||||||||||||||||||||||||||||||||||
| 111 | quotemeta DOMAIN_TCPIPV4, DOMAIN_TCPIPV4, | ||||||||||||||||||||||||||||||||||
| 112 | 'tcp/?(?:ip)?v?6', DOMAIN_TCPIPV6, | ||||||||||||||||||||||||||||||||||
| 113 | quotemeta DOMAIN_TCPIPV6, DOMAIN_TCPIPV6, | ||||||||||||||||||||||||||||||||||
| 114 | quotemeta DOMAIN_TCPIPV6Z, DOMAIN_TCPIPV6, | ||||||||||||||||||||||||||||||||||
| 115 | }; | ||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||
| 117 | sub new | ||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=16 SCAR=49.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 119 | 2 | my ($class, %argv) = @_; | |||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||
| 121 | 2 | my $domain = DOMAIN_UDPIPV4; | |||||||||||||||||||||||||||||||||
| 122 | 2 | my $error = q{}; | |||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||
| 124 | # See if a Transport Layer Domain argument has been passed. | ||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||
| 126 | 2 | for (keys %argv) { | |||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||
| 128 | 1 | ▶ | if (/^-?domain$/i) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||
| 130 | 0 | my $key = $argv{$_}; | |||||||||||||||||||||||||||||||||
| 131 | 0 | $domain = undef; | |||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||
| 133 | 0 | for (keys %{$domains}) { | |||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ($key =~ /^$_$/i) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 135 | 0 | $domain = $domains->{$_}; | |||||||||||||||||||||||||||||||||
| 136 | 0 | last; | |||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if (!defined $domain) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 141 | $error = err_msg( | ||||||||||||||||||||||||||||||||||
| 142 | 0 | 'The transport domain "%s" is unknown', $argv{$_} | |||||||||||||||||||||||||||||||||
| 143 | ); | ||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | return wantarray ? (undef, $error) : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||
| 147 | 0 | $argv{$_} = $domain; | |||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||
| 152 | # Return the appropriate object based on the Transport Domain. To | ||||||||||||||||||||||||||||||||||
| 153 | # avoid consuming unnecessary resources, only load the appropriate | ||||||||||||||||||||||||||||||||||
| 154 | # module when requested. Some modules require non-core modules and | ||||||||||||||||||||||||||||||||||
| 155 | # if these modules are not present, we gracefully return an error. | ||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||
| 157 | 2 | ▶ | if ($domain eq DOMAIN_UDPIPV6) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if (defined ($error = load_module('Net::SNMP::Transport::IPv6::UDP'))) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 160 | { | ||||||||||||||||||||||||||||||||||
| 161 | 0 | $error = 'UDP/IPv6 support is unavailable ' . $error; | |||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | return wantarray ? (undef, $error) : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||
| 164 | 0 | return Net::SNMP::Transport::IPv6::UDP->new(%argv); | |||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||
| 166 | } elsif ($domain eq DOMAIN_TCPIPV6) { | ||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if (defined ($error = load_module('Net::SNMP::Transport::IPv6::TCP'))) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||||||||
| 170 | 0 | $error = 'TCP/IPv6 support is unavailable ' . $error; | |||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | return wantarray ? (undef, $error) : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||
| 173 | 0 | return Net::SNMP::Transport::IPv6::TCP->new(%argv); | |||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||
| 175 | } elsif ($domain eq DOMAIN_TCPIPV4) { | ||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if (defined ($error = load_module('Net::SNMP::Transport::IPv4::TCP'))) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 178 | { | ||||||||||||||||||||||||||||||||||
| 179 | 0 | $error = 'TCP/IPv4 support is unavailable ' . $error; | |||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | return wantarray ? (undef, $error) : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||
| 182 | 0 | return Net::SNMP::Transport::IPv4::TCP->new(%argv); | |||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||
| 186 | # Load the default Transport Domain module without eval protection. | ||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||
| 188 | 2 | require Net::SNMP::Transport::IPv4::UDP; | |||||||||||||||||||||||||||||||||
| 189 | 2 | return Net::SNMP::Transport::IPv4::UDP->new(%argv); | |||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||
| 194 | sub max_msg_size | ||||||||||||||||||||||||||||||||||
| 195 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
max_msg_size: not called CC=5 SCAR=32.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 196 | 0 | my ($this, $size) = @_; | |||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if (@_ < 2) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 199 | 0 | return $this->{_max_msg_size}; | |||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||
| 202 | 0 | $this->_error_clear(); | |||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if ($size !~ m/^\d+$/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 205 | 0 | return $this->_error( | |||||||||||||||||||||||||||||||||
| 206 | 'The maxMsgSize value "%s" is expected in positive numeric format', | ||||||||||||||||||||||||||||||||||
| 207 | $size | ||||||||||||||||||||||||||||||||||
| 208 | ); | ||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ($size < MSG_SIZE_MINIMUM || $size > MSG_SIZE_MAXIMUM) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$size < MSG_SIZE_MINIMUM() or $size > MSG_SIZE_MAXIMUM()
MC/DC0%0/2
$size < MSG_SIZE_MINIMUM() or $size > MSG_SIZE_MAXIMUM()
$size < MSG_SIZE_MINIMUM()
$size > MSG_SIZE_MAXIMUM()
Truth table0%0/3
A or B
A= $size < MSG_SIZE_MINIMUM()B= $size > MSG_SIZE_MAXIMUM()
| |||||||||||||||||||||||||||||||||||
| 212 | 0 | return $this->_error( | |||||||||||||||||||||||||||||||||
| 213 | 'The maxMsgSize value %s is out of range (%d..%d)', | ||||||||||||||||||||||||||||||||||
| 214 | $size, MSG_SIZE_MINIMUM, MSG_SIZE_MAXIMUM | ||||||||||||||||||||||||||||||||||
| 215 | ); | ||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||
| 218 | # Adjust the share maximum size if necessary. | ||||||||||||||||||||||||||||||||||
| 219 | 0 | $this->_shared_max_size($size); | |||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||
| 221 | 0 | return $this->{_max_msg_size} = $size; | |||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||
| 224 | sub timeout | ||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
timeout: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 226 | 0 | my ($this, $timeout) = @_; | |||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if (@_ < 2) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 229 | 0 | return $this->{_timeout}; | |||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||
| 232 | 0 | $this->_error_clear(); | |||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | if ($timeout !~ m/^\d+(?:\.\d+)?$/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 235 | 0 | return $this->_error( | |||||||||||||||||||||||||||||||||
| 236 | 'The timeout value "%s" is expected in positive numeric format', | ||||||||||||||||||||||||||||||||||
| 237 | $timeout | ||||||||||||||||||||||||||||||||||
| 238 | ); | ||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if ($timeout < TIMEOUT_MINIMUM || $timeout > TIMEOUT_MAXIMUM) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$timeout < TIMEOUT_MINIMUM() or $timeout > TIMEOUT_MAXIMUM()
MC/DC0%0/2
$timeout < TIMEOUT_MINIMUM() or $timeout > TIMEOUT_MAXIMUM()
$timeout < TIMEOUT_MINIMUM()
$timeout > TIMEOUT_MAXIMUM()
Truth table0%0/3
A or B
A= $timeout < TIMEOUT_MINIMUM()B= $timeout > TIMEOUT_MAXIMUM()
| |||||||||||||||||||||||||||||||||||
| 242 | 0 | return $this->_error( | |||||||||||||||||||||||||||||||||
| 243 | 'The timeout value %s is out of range (%d..%d)', | ||||||||||||||||||||||||||||||||||
| 244 | $timeout, TIMEOUT_MINIMUM, TIMEOUT_MAXIMUM | ||||||||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||
| 248 | 0 | return $this->{_timeout} = $timeout; | |||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||
| 251 | sub retries | ||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
retries: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 253 | 0 | my ($this, $retries) = @_; | |||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | if (@_ < 2) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 256 | 0 | return $this->{_retries}; | |||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||
| 259 | 0 | $this->_error_clear(); | |||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if ($retries !~ m/^\d+$/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 262 | 0 | return $this->_error( | |||||||||||||||||||||||||||||||||
| 263 | 'The retries value "%s" is expected in positive numeric format', | ||||||||||||||||||||||||||||||||||
| 264 | $retries | ||||||||||||||||||||||||||||||||||
| 265 | ); | ||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if ($retries < RETRIES_MINIMUM || $retries > RETRIES_MAXIMUM) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$retries < RETRIES_MINIMUM() or $retries > RETRIES_MAXIMUM()
MC/DC0%0/2
$retries < RETRIES_MINIMUM() or $retries > RETRIES_MAXIMUM()
$retries < RETRIES_MINIMUM()
$retries > RETRIES_MAXIMUM()
Truth table0%0/3
A or B
A= $retries < RETRIES_MINIMUM()B= $retries > RETRIES_MAXIMUM()
| |||||||||||||||||||||||||||||||||||
| 269 | 0 | return $this->_error( | |||||||||||||||||||||||||||||||||
| 270 | 'The retries value %s is out of range (%d..%d)', | ||||||||||||||||||||||||||||||||||
| 271 | $retries, RETRIES_MINIMUM, RETRIES_MAXIMUM | ||||||||||||||||||||||||||||||||||
| 272 | ); | ||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||
| 275 | 0 | return $this->{_retries} = $retries; | |||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||
| 278 | sub agent_addr | ||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
agent_addr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 280 | 0 | return '0.0.0.0'; | |||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||
| 283 | sub connectionless | ||||||||||||||||||||||||||||||||||
| 284 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
connectionless: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 285 | 4 | return TRUE; | |||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||
| 288 | sub debug | ||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | return (@_ == 2) ? $DEBUG = ($_[1]) ? TRUE : FALSE : $DEBUG; | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||
| 293 | sub domain | ||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
domain: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 295 | 0 | return '0.0'; | |||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||
| 298 | sub error | ||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | return $_[0]->{_error} || q{}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0]{'_error'} || ''
MC/DC0%0/1
$_[0]{'_error'} || ''
$_[0]{'_error'}
Truth table0%0/2
A
A= $_[0]{'_error'}
| |||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||
| 303 | sub fileno | ||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
fileno: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | return defined($_[0]->{_socket}) ? $_[0]->{_socket}->fileno() : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||
| 308 | sub socket | ||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
socket: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 310 | 0 | return $_[0]->{_socket}; | |||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||
| 313 | sub type | ||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 315 | 0 | return '<unknown>'; # unknown(0) | |||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||
| 318 | sub sock_name | ||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
sock_name: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | if (defined $_[0]->{_socket}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | return $_[0]->{_socket}->sockname() || $_[0]->{_sock_name}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_[0]{'_socket'}->sockname || $_[0]{'_sock_name'}
MC/DC0%0/2
$_[0]{'_socket'}->sockname || $_[0]{'_sock_name'}
$_[0]{'_socket'}->sockname
$_[0]{'_sock_name'}
Truth table0%0/3
A || B
A= $_[0]{'_socket'}->socknameB= $_[0]{'_sock_name'}
| |||||||||||||||||||||||||||||||||||
| 322 | } else { | ||||||||||||||||||||||||||||||||||
| 323 | 0 | return $_[0]->{_sock_name}; | |||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||
| 327 | sub sock_hostname | ||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
sock_hostname: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | return $_[0]->{_sock_hostname} || $_[0]->sock_address(); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_[0]{'_sock_hostname'} || $_[0]->sock_address
MC/DC0%0/2
$_[0]{'_sock_hostname'} || $_[0]->sock_address
$_[0]{'_sock_hostname'}
$_[0]->sock_address
Truth table0%0/3
A || B
A= $_[0]{'_sock_hostname'}B= $_[0]->sock_address
| |||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||
| 332 | sub sock_address | ||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
sock_address: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 334 | 0 | return $_[0]->_address($_[0]->sock_name()); | |||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||
| 337 | sub sock_addr | ||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
sock_addr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 339 | 0 | return $_[0]->_addr($_[0]->sock_name()); | |||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||
| 342 | sub sock_port | ||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
sock_port: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 344 | 0 | return $_[0]->_port($_[0]->sock_name()); | |||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||
| 347 | sub sock_taddress | ||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
sock_taddress: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 349 | 0 | return $_[0]->_taddress($_[0]->sock_name()); | |||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||
| 352 | sub sock_taddr | ||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
sock_taddr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 354 | 0 | return $_[0]->_taddr($_[0]->sock_name()); | |||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||
| 357 | sub sock_tdomain | ||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
sock_tdomain: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 359 | 0 | return $_[0]->_tdomain($_[0]->sock_name()); | |||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||
| 362 | sub dest_name | ||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
dest_name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 364 | 0 | return $_[0]->{_dest_name}; | |||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||
| 367 | sub dest_hostname | ||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
dest_hostname: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | return $_[0]->{_dest_hostname} || $_[0]->dest_address(); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_[0]{'_dest_hostname'} || $_[0]->dest_address
MC/DC0%0/2
$_[0]{'_dest_hostname'} || $_[0]->dest_address
$_[0]{'_dest_hostname'}
$_[0]->dest_address
Truth table0%0/3
A || B
A= $_[0]{'_dest_hostname'}B= $_[0]->dest_address
| |||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||
| 372 | sub dest_address | ||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
dest_address: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 374 | 0 | return $_[0]->_address($_[0]->dest_name()); | |||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||
| 377 | sub dest_addr | ||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
dest_addr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 379 | 0 | return $_[0]->_addr($_[0]->dest_name()); | |||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||
| 382 | sub dest_port | ||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
dest_port: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 384 | 0 | return $_[0]->_port($_[0]->dest_name()); | |||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||
| 387 | sub dest_taddress | ||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
dest_taddress: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 389 | 0 | return $_[0]->_taddress($_[0]->dest_name()); | |||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||
| 392 | sub dest_taddr | ||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
dest_taddr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 394 | 0 | return $_[0]->_taddr($_[0]->dest_name()); | |||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||
| 397 | sub dest_tdomain | ||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
dest_tdomain: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 399 | 0 | return $_[0]->_tdomain($_[0]->dest_name()); | |||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||
| 402 | sub peer_name | ||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
peer_name: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | if (defined $_[0]->{_socket}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | return $_[0]->{_socket}->peername() || $_[0]->dest_name(); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_[0]{'_socket'}->peername || $_[0]->dest_name
MC/DC0%0/2
$_[0]{'_socket'}->peername || $_[0]->dest_name
$_[0]{'_socket'}->peername
$_[0]->dest_name
Truth table0%0/3
A || B
A= $_[0]{'_socket'}->peernameB= $_[0]->dest_name
| |||||||||||||||||||||||||||||||||||
| 406 | } else { | ||||||||||||||||||||||||||||||||||
| 407 | 0 | return $_[0]->dest_name(); | |||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||
| 411 | sub peer_hostname | ||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
peer_hostname: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 413 | 0 | return $_[0]->peer_address(); | |||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||
| 416 | sub peer_address | ||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
peer_address: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 418 | 0 | return $_[0]->_address($_[0]->peer_name()); | |||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||
| 421 | sub peer_addr | ||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
peer_addr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 423 | 0 | return $_[0]->_addr($_[0]->peer_name()); | |||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||
| 426 | sub peer_port | ||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
peer_port: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 428 | 0 | return $_[0]->_port($_[0]->peer_name()); | |||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||
| 431 | sub peer_taddress | ||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
peer_taddress: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 433 | 0 | return $_[0]->_taddress($_[0]->peer_name()); | |||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||
| 436 | sub peer_taddr | ||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
peer_taddr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 438 | 0 | return $_[0]->_taddr($_[0]->peer_name()); | |||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||
| 441 | sub peer_tdomain | ||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
peer_tdomain: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 443 | 0 | return $_[0]->_tdomain($_[0]->peer_name()); | |||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||
| 446 | sub AUTOLOAD | ||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||
| 448 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | return if $AUTOLOAD =~ /::DESTROY$/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||
| 452 | 0 | $AUTOLOAD =~ s/.*://; | |||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if (ref $this) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if (defined($this->{_socket}) && ($this->{_socket}->can($AUTOLOAD))) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $this->{"_socket"} and $this->{"_socket"}->can($Net::SNMP::Transport::AUTOLOAD)
MC/DC0%0/2
defined $this->{"_socket"} and $this->{"_socket"}->can($Net::SNMP::Transport::AUTOLOAD)
defined $this->{"_socket"}
$this->{"_socket"}->can($Net::SNMP::Transport::AUTOLOAD)
Truth table0%0/3
A and B
A= defined $this->{"_socket"}B= $this->{"_socket"}->can($Net::SNMP::Transport::AUTOLOAD)
| |||||||||||||||||||||||||||||||||||
| 456 | 0 | return $this->{_socket}->$AUTOLOAD(@_); | |||||||||||||||||||||||||||||||||
| 457 | } else { | ||||||||||||||||||||||||||||||||||
| 458 | 0 | $this->_error_clear(); | |||||||||||||||||||||||||||||||||
| 459 | 0 | return $this->_error( | |||||||||||||||||||||||||||||||||
| 460 | 'The method "%s" is not supported by this Transport Domain', | ||||||||||||||||||||||||||||||||||
| 461 | $AUTOLOAD | ||||||||||||||||||||||||||||||||||
| 462 | ); | ||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||
| 464 | } else { | ||||||||||||||||||||||||||||||||||
| 465 | 0 | require Carp; | |||||||||||||||||||||||||||||||||
| 466 | 0 | Carp::croak(sprintf 'The function "%s" is not supported', $AUTOLOAD); | |||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||
| 469 | # Never get here. | ||||||||||||||||||||||||||||||||||
| 470 | 0 | return; | |||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||
| 473 | sub DESTROY | ||||||||||||||||||||||||||||||||||
| 474 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=5 SCAR=21.7
| |||||||||||||||||||||||||||||||||||
| 475 | 2 | my ($this) = @_; | |||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||
| 477 | # Connection-oriented transports do not share sockets. | ||||||||||||||||||||||||||||||||||
| 478 | 2 | ▶ | return if !$this->connectionless(); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||
| 480 | # If the shared socket structure exists, decrement the reference count | ||||||||||||||||||||||||||||||||||
| 481 | # and clear the shared socket structure if it is no longer being used. | ||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||
| 483 | 2 | ▶ | if (defined($this->{_sock_name}) && exists $SOCKETS->{$this->{_sock_name}}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $this->{"_sock_name"} and exists $$Net::SNMP::Transport::SOCKETS{$this->{"_sock_name"}}
MC/DC0%0/2
defined $this->{"_sock_name"} and exists $$Net::SNMP::Transport::SOCKETS{$this->{"_sock_name"}}
defined $this->{"_sock_name"}
exists $$Net::SNMP::Transport::SOCKETS{$this->{"_sock_name"}}
Truth table33%1/3
A and B
A= defined $this->{"_sock_name"}B= exists $$Net::SNMP::Transport::SOCKETS{$this->{"_sock_name"}}
| |||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | if (--$SOCKETS->{$this->{_sock_name}}->[_SHARED_REFC] < 1) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 485 | 0 | delete $SOCKETS->{$this->{_sock_name}}; | |||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||
| 489 | 2 | return; | |||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||
| 492 | ## Obsolete methods - previous deprecated | ||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||
| 494 | sub OBSOLETE | ||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
OBSOLETE: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 496 | 0 | my ($this, $method) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||
| 498 | 0 | require Carp; | |||||||||||||||||||||||||||||||||
| 499 | 0 | Carp::croak( | |||||||||||||||||||||||||||||||||
| 500 | sprintf '%s() is obsolete, use %s() instead', (caller 1)[3], $method | ||||||||||||||||||||||||||||||||||
| 501 | ); | ||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||
| 503 | # Never get here. | ||||||||||||||||||||||||||||||||||
| 504 | 0 | return $this->${\$method}(@_); | |||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | sub name { return $_[0]->OBSOLETE('type'); } | ||||||||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | sub srcaddr { return $_[0]->OBSOLETE('sock_addr'); } | ||||||||||||||||||||||||||||||||
|
Subroutine
srcaddr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | sub srcport { return $_[0]->OBSOLETE('sock_port'); } | ||||||||||||||||||||||||||||||||
|
Subroutine
srcport: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | sub srchost { return $_[0]->OBSOLETE('sock_address'); } | ||||||||||||||||||||||||||||||||
|
Subroutine
srchost: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | sub srcname { return $_[0]->OBSOLETE('sock_address'); } | ||||||||||||||||||||||||||||||||
|
Subroutine
srcname: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | sub dstaddr { return $_[0]->OBSOLETE('dest_addr'); } | ||||||||||||||||||||||||||||||||
|
Subroutine
dstaddr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | sub dstport { return $_[0]->OBSOLETE('dest_port'); } | ||||||||||||||||||||||||||||||||
|
Subroutine
dstport: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | sub dsthost { return $_[0]->OBSOLETE('dest_address'); } | ||||||||||||||||||||||||||||||||
|
Subroutine
dsthost: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | sub dstname { return $_[0]->OBSOLETE('dest_hostname'); } | ||||||||||||||||||||||||||||||||
|
Subroutine
dstname: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | sub recvaddr { return $_[0]->OBSOLETE('peer_addr'); } | ||||||||||||||||||||||||||||||||
|
Subroutine
recvaddr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | sub recvport { return $_[0]->OBSOLETE('peer_port'); } | ||||||||||||||||||||||||||||||||
|
Subroutine
recvport: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | sub recvhost { return $_[0]->OBSOLETE('peer_address'); } | ||||||||||||||||||||||||||||||||
|
Subroutine
recvhost: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||
| 532 | # [private methods] ---------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||
| 534 | sub _new | ||||||||||||||||||||||||||||||||||
| 535 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_new: called CC=41 SCAR=69.8
| |||||||||||||||||||||||||||||||||||
| 536 | 2 | my ($class, %argv) = @_; | |||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||
| 538 | 2 | my $this = bless { | |||||||||||||||||||||||||||||||||
| 539 | '_dest_hostname' => 'localhost', # Destination hostname | ||||||||||||||||||||||||||||||||||
| 540 | '_dest_name' => undef, # Destination sockaddr | ||||||||||||||||||||||||||||||||||
| 541 | '_error' => undef, # Error message | ||||||||||||||||||||||||||||||||||
| 542 | '_max_msg_size' => $class->_msg_size_default(), # maxMsgSize | ||||||||||||||||||||||||||||||||||
| 543 | '_retries' => RETRIES_DEFAULT, # Number of retries | ||||||||||||||||||||||||||||||||||
| 544 | '_socket' => undef, # Socket object | ||||||||||||||||||||||||||||||||||
| 545 | '_sock_hostname' => q{}, # Socket hostname | ||||||||||||||||||||||||||||||||||
| 546 | '_sock_name' => undef, # Socket sockaddr | ||||||||||||||||||||||||||||||||||
| 547 | '_timeout' => TIMEOUT_DEFAULT, # Timeout period (secs) | ||||||||||||||||||||||||||||||||||
| 548 | }, $class; | ||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||
| 550 | # Default the values for the "name (sockaddr) hashes". | ||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||
| 552 | 2 | my $sock_nh = { port => 0, addr => $this->_addr_any() }; | |||||||||||||||||||||||||||||||||
| 553 | 2 | my $dest_nh = { port => SNMP_PORT, addr => $this->_addr_loopback() }; | |||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||
| 555 | # Validate the "port" arguments first to allow for a consistency | ||||||||||||||||||||||||||||||||||
| 556 | # check with any values passed with the "address" arguments. | ||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||
| 558 | 2 | my ($dest_port, $sock_port, $listen) = (undef, undef, 0); | |||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||
| 560 | 2 | for (keys %argv) { | |||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||
| 562 | 1 | ▶ | if (/^-?debug$/i) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 563 | 0 | $this->debug(delete $argv{$_}); | |||||||||||||||||||||||||||||||||
| 564 | } elsif (/^-?(?:de?st|peer)?port$/i) { | ||||||||||||||||||||||||||||||||||
| 565 | 0 | $this->_service_resolve(delete($argv{$_}), $dest_nh); | |||||||||||||||||||||||||||||||||
| 566 | 0 | $dest_port = $dest_nh->{port}; | |||||||||||||||||||||||||||||||||
| 567 | } elsif (/^-?(?:src|sock|local)port$/i) { | ||||||||||||||||||||||||||||||||||
| 568 | 1 | $this->_service_resolve(delete($argv{$_}), $sock_nh); | |||||||||||||||||||||||||||||||||
| 569 | 1 | $sock_port = $sock_nh->{port}; | |||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||
| 572 | 1 | ▶ | if (defined $this->{_error}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | return wantarray ? (undef, $this->{_error}) : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||
| 577 | # Validate the rest of the arguments. | ||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||
| 579 | 2 | for (keys %argv) { | |||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | if (/^-?domain$/i) { | ||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | if ($argv{$_} ne $this->domain()) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 583 | $this->_error( | ||||||||||||||||||||||||||||||||||
| 584 | 'The domain value "%s" was expected, but "%s" was found', | ||||||||||||||||||||||||||||||||||
| 585 | 0 | $this->domain(), $argv{$_} | |||||||||||||||||||||||||||||||||
| 586 | ); | ||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||
| 588 | ▶ | } elsif ((/^-?hostname$/i) || (/^-?(?:de?st|peer)?addr$/i)) { | |||||||||||||||||||||||||||||||||
|
Condition0%0/3
/^-?hostname$/i or /^-?(?:de?st|peer)?addr$/i
MC/DC0%0/2
/^-?hostname$/i or /^-?(?:de?st|peer)?addr$/i
/^-?hostname$/i
/^-?(?:de?st|peer)?addr$/i
Truth table0%0/3
A or B
A= /^-?hostname$/iB= /^-?(?:de?st|peer)?addr$/i
| |||||||||||||||||||||||||||||||||||
| 589 | $this->_hostname_resolve( | ||||||||||||||||||||||||||||||||||
| 590 | 0 | $this->{_dest_hostname} = $argv{$_}, $dest_nh | |||||||||||||||||||||||||||||||||
| 591 | ); | ||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | if (defined($dest_port) && ($dest_port != $dest_nh->{port})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $dest_port and $dest_port != $dest_nh->{"port"}
MC/DC0%0/2
defined $dest_port and $dest_port != $dest_nh->{"port"}
defined $dest_port
$dest_port != $dest_nh->{"port"}
Truth table0%0/3
A and B
A= defined $dest_portB= $dest_port != $dest_nh->{"port"}
| |||||||||||||||||||||||||||||||||||
| 593 | $this->_error( | ||||||||||||||||||||||||||||||||||
| 594 | 'Inconsistent %s port information was specified (%d != %d)', | ||||||||||||||||||||||||||||||||||
| 595 | $this->type(), $dest_port, $dest_nh->{port} | ||||||||||||||||||||||||||||||||||
| 596 | 0 | ); | |||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||
| 598 | } elsif (/^-?(?:src|sock|local)addr$/i) { | ||||||||||||||||||||||||||||||||||
| 599 | $this->_hostname_resolve( | ||||||||||||||||||||||||||||||||||
| 600 | 0 | $this->{_sock_hostname} = $argv{$_}, $sock_nh | |||||||||||||||||||||||||||||||||
| 601 | ); | ||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | if (defined($sock_port) && ($sock_port != $sock_nh->{port})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $sock_port and $sock_port != $sock_nh->{"port"}
MC/DC0%0/2
defined $sock_port and $sock_port != $sock_nh->{"port"}
defined $sock_port
$sock_port != $sock_nh->{"port"}
Truth table0%0/3
A and B
A= defined $sock_portB= $sock_port != $sock_nh->{"port"}
| |||||||||||||||||||||||||||||||||||
| 603 | $this->_error( | ||||||||||||||||||||||||||||||||||
| 604 | 'Inconsistent %s port information was specified (%d != %d)', | ||||||||||||||||||||||||||||||||||
| 605 | $this->type(), $sock_port, $sock_nh->{port} | ||||||||||||||||||||||||||||||||||
| 606 | 0 | ); | |||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||
| 608 | } elsif (/^-?listen$/i) { | ||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | if (($argv{$_} !~ /^\d+$/) || ($argv{$_} < 1)) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not $argv{$_} =~ /^\d+$/ or $argv{$_} < 1
MC/DC0%0/2
not $argv{$_} =~ /^\d+$/ or $argv{$_} < 1
not $argv{$_} =~ /^\d+$/
$argv{$_} < 1
Truth table0%0/3
not(A) or B
A= not $argv{$_} =~ /^\d+$/B= $argv{$_} < 1
| |||||||||||||||||||||||||||||||||||
| 610 | $this->_error( | ||||||||||||||||||||||||||||||||||
| 611 | 'The listen queue size value "%s" was expected in positive ' . | ||||||||||||||||||||||||||||||||||
| 612 | 0 | 'non-zero numeric format', $argv{$_} | |||||||||||||||||||||||||||||||||
| 613 | ); | ||||||||||||||||||||||||||||||||||
| 614 | } elsif (!$this->connectionless()) { | ||||||||||||||||||||||||||||||||||
| 615 | 0 | $listen = $argv{$_}; | |||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||
| 617 | ▶ | } elsif ((/^-?maxmsgsize$/i) || (/^-?mtu$/i)) { | |||||||||||||||||||||||||||||||||
|
Condition0%0/3
/^-?maxmsgsize$/i or /^-?mtu$/i
MC/DC0%0/2
/^-?maxmsgsize$/i or /^-?mtu$/i
/^-?maxmsgsize$/i
/^-?mtu$/i
Truth table0%0/3
A or B
A= /^-?maxmsgsize$/iB= /^-?mtu$/i
| |||||||||||||||||||||||||||||||||||
| 618 | 0 | $this->max_msg_size($argv{$_}); | |||||||||||||||||||||||||||||||||
| 619 | } elsif (/^-?retries$/i) { | ||||||||||||||||||||||||||||||||||
| 620 | 0 | $this->retries($argv{$_}); | |||||||||||||||||||||||||||||||||
| 621 | } elsif (/^-?timeout$/i) { | ||||||||||||||||||||||||||||||||||
| 622 | 0 | $this->timeout($argv{$_}); | |||||||||||||||||||||||||||||||||
| 623 | } else { | ||||||||||||||||||||||||||||||||||
| 624 | 0 | $this->_error('The argument "%s" is unknown', $_); | |||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | if (defined $this->{_error}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | return wantarray ? (undef, $this->{_error}) : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||
| 633 | # Pack the socket name (sockaddr) information. | ||||||||||||||||||||||||||||||||||
| 634 | 2 | $this->{_sock_name} = $this->_name_pack($sock_nh); | |||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||
| 636 | # Pack the destination name (sockaddr) information. | ||||||||||||||||||||||||||||||||||
| 637 | 2 | $this->{_dest_name} = $this->_name_pack($dest_nh); | |||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||
| 639 | # For all connection-oriented transports and for each unique source | ||||||||||||||||||||||||||||||||||
| 640 | # address for connectionless transports, create a new socket. | ||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||
| 642 | 2 | ▶ | if (!$this->connectionless() || !exists $SOCKETS->{$this->{_sock_name}}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$this->connectionless && exists $$Net::SNMP::Transport::SOCKETS{$this->{'_sock_name'}}
MC/DC0%0/2
$this->connectionless && exists $$Net::SNMP::Transport::SOCKETS{$this->{'_sock_name'}}
$this->connectionless
exists $$Net::SNMP::Transport::SOCKETS{$this->{'_sock_name'}}
Truth table33%1/3
A && B
A= $this->connectionlessB= exists $$Net::SNMP::Transport::SOCKETS{$this->{'_sock_name'}}
| |||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||
| 644 | # Create a new IO::Socket object. | ||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||
| 646 | 2 | ▶ | if (!defined ($this->{_socket} = $this->_socket_create())) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 647 | 0 | $this->_perror('Failed to open %s socket', $this->type()); | |||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | return wantarray ? (undef, $this->{_error}) : undef | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||
| 651 | 0 | DEBUG_INFO('opened %s socket [%d]', $this->type(), $this->fileno()); | |||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||
| 653 | # Bind the socket. | ||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | if (!defined $this->{_socket}->bind($this->{_sock_name})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 656 | 0 | $this->_perror('Failed to bind %s socket', $this->type()); | |||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | return wantarray ? (undef, $this->{_error}) : undef | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||
| 660 | # For connection-oriented transports, we either listen or connect. | ||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | if (!$this->connectionless()) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||
| 664 | 0 | ▶ | if ($listen) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | if (!defined $this->{_socket}->listen($listen)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 666 | 0 | $this->_perror('Failed to listen on %s socket', $this->type()); | |||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | return wantarray ? (undef, $this->{_error}) : undef | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||
| 669 | } else { | ||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | if (!defined $this->{_socket}->connect($this->{_dest_name})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 671 | 0 | $this->_perror( | |||||||||||||||||||||||||||||||||
| 672 | q{Failed to connect to remote host '%s'}, | ||||||||||||||||||||||||||||||||||
| 673 | $this->dest_hostname() | ||||||||||||||||||||||||||||||||||
| 674 | ); | ||||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | return wantarray ? (undef, $this->{_error}) : undef | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||
| 680 | # Flag the socket as non-blocking outside of socket creation or | ||||||||||||||||||||||||||||||||||
| 681 | # the object instantiation fails on some systems (e.g. MSWin32). | ||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||
| 683 | 0 | $this->{_socket}->blocking(FALSE); | |||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||
| 685 | # Add the socket to the global socket list with a reference | ||||||||||||||||||||||||||||||||||
| 686 | # count to track when to close the socket and the maxMsgSize | ||||||||||||||||||||||||||||||||||
| 687 | # associated with this new object for connectionless transports. | ||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||
| 689 | 0 | ▶ | if ($this->connectionless()) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 690 | $SOCKETS->{$this->{_sock_name}} = [ | ||||||||||||||||||||||||||||||||||
| 691 | $this->{_socket}, # Shared Socket object | ||||||||||||||||||||||||||||||||||
| 692 | 1, # Reference count | ||||||||||||||||||||||||||||||||||
| 693 | $this->{_max_msg_size}, # Shared maximum message size | ||||||||||||||||||||||||||||||||||
| 694 | 0 | ]; | |||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||
| 697 | } else { | ||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||
| 699 | # Bump up the reference count. | ||||||||||||||||||||||||||||||||||
| 700 | 0 | $SOCKETS->{$this->{_sock_name}}->[_SHARED_REFC]++; | |||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||
| 702 | # Assign the socket to the object. | ||||||||||||||||||||||||||||||||||
| 703 | 0 | $this->{_socket} = $SOCKETS->{$this->{_sock_name}}->[_SHARED_SOCKET]; | |||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||
| 705 | # Adjust the shared maxMsgSize if necessary. | ||||||||||||||||||||||||||||||||||
| 706 | 0 | $this->_shared_max_size($this->{_max_msg_size}); | |||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||
| 708 | 0 | DEBUG_INFO('reused %s socket [%d]', $this->type(), $this->fileno()); | |||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||
| 712 | # Return the object and empty error message (in list context) | ||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | return wantarray ? ($this, q{}) : $this; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||
| 716 | sub _service_resolve | ||||||||||||||||||||||||||||||||||
| 717 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_service_resolve: called CC=7 SCAR=31.6
| |||||||||||||||||||||||||||||||||||
| 718 | 1 | my ($this, $serv, $nh) = @_; | |||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||
| 720 | 1 | $nh->{port} = undef; | |||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||
| 722 | 1 | ▶ | if ($serv !~ /^\d+$/) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | my $port = ($serv =~ s/\((\d+)\)$//) ? ($1 > 65535) ? undef : $1 : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | $nh->{port} = getservbyname($serv, $this->_protocol_name()) || $port; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
getservbyname($serv, $this->_protocol_name) || $port
MC/DC0%0/2
getservbyname($serv, $this->_protocol_name) || $port
getservbyname($serv, $this->_protocol_name)
$port
Truth table0%0/3
A || B
A= getservbyname($serv, $this->_protocol_name)B= $port
| |||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | if (!defined $nh->{port}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 726 | 0 | return $this->_error( | |||||||||||||||||||||||||||||||||
| 727 | 'Unable to resolve the %s service name "%s"', $this->type(), $_[1] | ||||||||||||||||||||||||||||||||||
| 728 | ); | ||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||
| 730 | } elsif ($serv > 65535) { | ||||||||||||||||||||||||||||||||||
| 731 | 0 | return $this->_error( | |||||||||||||||||||||||||||||||||
| 732 | 'The %s port number %s is out of range (0..65535)', | ||||||||||||||||||||||||||||||||||
| 733 | $this->type(), $serv | ||||||||||||||||||||||||||||||||||
| 734 | ); | ||||||||||||||||||||||||||||||||||
| 735 | } else { | ||||||||||||||||||||||||||||||||||
| 736 | 1 | $nh->{port} = $serv; | |||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||
| 739 | 1 | return $nh->{port}; | |||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||
| 742 | sub _protocol | ||||||||||||||||||||||||||||||||||
| 743 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_protocol: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 744 | 2 | return (getprotobyname $_[0]->_protocol_name())[2]; | |||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||
| 747 | sub _shared_max_size | ||||||||||||||||||||||||||||||||||
| 748 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_shared_max_size: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||
| 749 | 0 | my ($this, $size) = @_; | |||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||
| 751 | # Connection-oriented transports do not share sockets. | ||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | if (!$this->connectionless()) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 753 | 0 | return $this->{_max_msg_size}; | |||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | if (@_ == 2) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||
| 758 | # Handle calls during object creation. | ||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | if (!defined $this->{_sock_name}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 760 | 0 | return $this->{_max_msg_size}; | |||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||
| 763 | # Update the shared maxMsgSize if the passed | ||||||||||||||||||||||||||||||||||
| 764 | # value is greater than the current size. | ||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||
| 766 | 0 | ▶ | if ($size > $SOCKETS->{$this->{_sock_name}}->[_SHARED_MAXSIZE]) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 767 | 0 | $SOCKETS->{$this->{_sock_name}}->[_SHARED_MAXSIZE] = $size; | |||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||
| 772 | 0 | return $SOCKETS->{$this->{_sock_name}}->[_SHARED_MAXSIZE]; | |||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||
| 775 | sub _msg_size_default | ||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_msg_size_default: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 777 | 0 | return MSG_SIZE_DEFAULT; | |||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||
| 780 | sub _error | ||||||||||||||||||||||||||||||||||
| 781 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_error: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 782 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||
| 784 | 0 | ▶ | if (!defined $this->{_error}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 785 | 0 | ▶ | $this->{_error} = (@_ > 1) ? sprintf(shift(@_), @_) : $_[0]; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | if ($this->debug()) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 787 | printf "error: [%d] %s(): %s\n", | ||||||||||||||||||||||||||||||||||
| 788 | 0 | (caller 0)[2], (caller 1)[3], $this->{_error}; | |||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||
| 792 | 0 | return; | |||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||
| 795 | sub strerror | ||||||||||||||||||||||||||||||||||
| 796 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
strerror: not called CC=6 SCAR=33.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 797 | 0 | ▶ | if ($! =~ /^Unknown error/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | return sprintf '%s', $^E if ($^E); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 799 | 0 | require Errno; | |||||||||||||||||||||||||||||||||
| 800 | 0 | ▶ | for (keys (%!)) { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||
| 801 | 0 | ▶ | if ($!{$_}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 802 | 0 | return sprintf 'Error %s', $_; | |||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||
| 805 | 0 | return sprintf '%s (%d)', $!, $!; | |||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||
| 808 | 0 | ▶ | return $! ? sprintf('%s', $!) : 'No error'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||
| 811 | sub _perror | ||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_perror: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||
| 813 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||
| 815 | 0 | ▶ | if (!defined $this->{_error}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 816 | 0 | ▶ | $this->{_error} = ((@_ > 1) ? sprintf(shift(@_), @_) : $_[0]) || q{}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
(@_ > 1 ? sprintf(shift @_, @_) : $_[0]) || ''
MC/DC0%0/1
(@_ > 1 ? sprintf(shift @_, @_) : $_[0]) || ''
(@_ > 1 ? sprintf(shift @_, @_) : $_[0])
Truth table0%0/2
A
A= (@_ > 1 ? sprintf(shift @_, @_) : $_[0])
| |||||||||||||||||||||||||||||||||||
| 817 | 0 | ▶ | $this->{_error} .= (($this->{_error}) ? ': ' : q{}) . strerror(); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 818 | 0 | ▶ | if ($this->debug()) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 819 | printf "error: [%d] %s(): %s\n", | ||||||||||||||||||||||||||||||||||
| 820 | 0 | (caller 0)[2], (caller 1)[3], $this->{_error}; | |||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||
| 824 | 0 | return; | |||||||||||||||||||||||||||||||||
| 825 | } | ||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||
| 827 | sub _error_clear | ||||||||||||||||||||||||||||||||||
| 828 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_error_clear: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 829 | 0 | $! = 0; | |||||||||||||||||||||||||||||||||
| 830 | 0 | return $_[0]->{_error} = undef; | |||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||
| 833 | { | ||||||||||||||||||||||||||||||||||
| 834 | 2 | my %modules; | |||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||
| 836 | sub load_module | ||||||||||||||||||||||||||||||||||
| 837 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
load_module: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 838 | 0 | my ($module) = @_; | |||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||
| 840 | # We attempt to load the required module under the protection of an | ||||||||||||||||||||||||||||||||||
| 841 | # eval statement. If there is a failure, typically it is due to a | ||||||||||||||||||||||||||||||||||
| 842 | # missing module required by the requested module and we attempt to | ||||||||||||||||||||||||||||||||||
| 843 | # simplify the error message by just listing that module. We also | ||||||||||||||||||||||||||||||||||
| 844 | # need to track failures since require() only produces an error on | ||||||||||||||||||||||||||||||||||
| 845 | # the first attempt to load the module. | ||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||
| 847 | # NOTE: Contrary to our typical convention, a return value of "undef" | ||||||||||||||||||||||||||||||||||
| 848 | # actually means success and a defined value means error. | ||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||
| 850 | 0 | ▶ | return $modules{$module} if exists $modules{$module}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||
| 852 | 0 | ▶ | if (!eval "require $module") { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 853 | 0 | ▶ | if ($@ =~ /locate (\S+\.pm)/) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 854 | 0 | $modules{$module} = err_msg('(Required module %s not found)', $1); | |||||||||||||||||||||||||||||||||
| 855 | } elsif ($@ =~ /(.*)\n/) { | ||||||||||||||||||||||||||||||||||
| 856 | 0 | $modules{$module} = err_msg('(%s)', $1); | |||||||||||||||||||||||||||||||||
| 857 | } else { | ||||||||||||||||||||||||||||||||||
| 858 | 0 | $modules{$module} = err_msg('(%s)', $@); | |||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||
| 860 | } else { | ||||||||||||||||||||||||||||||||||
| 861 | 0 | $modules{$module} = undef; | |||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||
| 864 | 0 | return $modules{$module}; | |||||||||||||||||||||||||||||||||
| 865 | } | ||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||
| 868 | sub err_msg | ||||||||||||||||||||||||||||||||||
| 869 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
err_msg: not called CC=3 SCAR=22.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | my $msg = (@_ > 1) ? sprintf(shift(@_), @_) : $_[0]; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||
| 872 | 0 | ▶ | if ($DEBUG) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 873 | 0 | printf "error: [%d] %s(): %s\n", (caller 0)[2], (caller 1)[3], $msg; | |||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||
| 876 | 0 | return $msg; | |||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||
| 879 | sub DEBUG_INFO | ||||||||||||||||||||||||||||||||||
| 880 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
DEBUG_INFO: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 881 | 0 | ▶ | return $DEBUG if (!$DEBUG); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||
| 883 | 0 | ▶ | return printf | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 884 | sprintf('debug: [%d] %s(): ', (caller 0)[2], (caller 1)[3]) . | ||||||||||||||||||||||||||||||||||
| 885 | ((@_ > 1) ? shift(@_) : '%s') . | ||||||||||||||||||||||||||||||||||
| 886 | "\n", | ||||||||||||||||||||||||||||||||||
| 887 | @_; | ||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||
| 890 | # ============================================================================ | ||||||||||||||||||||||||||||||||||
| 891 | 2 | 1; # [end Net::SNMP::Transport] | |||||||||||||||||||||||||||||||||