| 1 | package Cisco::SNMP::Line; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | ################################################## | ||||||||||||||||||||||||||||
| 4 | # AUTHOR = Michael Vincent | ||||||||||||||||||||||||||||
| 5 | # www.VinsWorld.com | ||||||||||||||||||||||||||||
| 6 | ################################################## | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Net::SNMP qw(:asn1); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use Cisco::SNMP; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 3 | our $VERSION = $Cisco::SNMP::VERSION; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 3 | our @ISA = qw(Cisco::SNMP); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | ################################################## | ||||||||||||||||||||||||||||
| 19 | # Start Public Module | ||||||||||||||||||||||||||||
| 20 | ################################################## | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub _trmsrvOID { | ||||||||||||||||||||||||||
|
Subroutine
_trmsrvOID: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 23 | 0 | return '1.3.6.1.4.1.9.2.9'; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub _lineOID { | ||||||||||||||||||||||||||
|
Subroutine
_lineOID: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 27 | 0 | return _trmsrvOID . '.2.1'; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 6 | ▶ | sub lineOIDs { | ||||||||||||||||||||||||||
|
Subroutine
lineOIDs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | 6 | return qw(Active Type Autobaud SpeedIn SpeedOut Flow Modem | |||||||||||||||||||||||||||
| 32 | Location Term ScrLen ScrWid Esc Tmo Sestmo Rotary Uses Nses | ||||||||||||||||||||||||||||
| 33 | User Noise Number TimeActive); | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub _sessOID { | ||||||||||||||||||||||||||
|
Subroutine
_sessOID: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 37 | 0 | return _trmsrvOID . '.3.1'; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 6 | ▶ | sub sessOIDs { | ||||||||||||||||||||||||||
|
Subroutine
sessOIDs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 6 | return qw(Type Direction Address Name Current Idle Line); | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub line_clear { | ||||||||||||||||||||||||||
|
Subroutine
line_clear: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | my $session = $self->{_SESSION_}; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | my %params; | |||||||||||||||||||||||||||
| 50 | my %args; | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ( @_ == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | ( $params{lines} ) = @_; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | if (not defined( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | $params{lines} = Cisco::SNMP::_get_range( $params{lines} ) | ||||||||||||||||||||||||||||
| 55 | ) | ||||||||||||||||||||||||||||
| 56 | ) { | ||||||||||||||||||||||||||||
| 57 | 0 | return undef; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | } else { | ||||||||||||||||||||||||||||
| 60 | 0 | %args = @_; | |||||||||||||||||||||||||||
| 61 | 0 | for ( keys(%args) ) { | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ( (/^-?range$/i) || (/^-?line(?:s)?$/i) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
/^-?range$/i or /^-?line(?:s)?$/i
MC/DC0%0/2
/^-?range$/i or /^-?line(?:s)?$/i
/^-?range$/i
/^-?line(?:s)?$/i
Truth table0%0/3
A or B
A= /^-?range$/iB= /^-?line(?:s)?$/i
| |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if (not defined( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | $params{lines} = Cisco::SNMP::_get_range( $args{$_} ) | ||||||||||||||||||||||||||||
| 65 | ) | ||||||||||||||||||||||||||||
| 66 | ) { | ||||||||||||||||||||||||||||
| 67 | 0 | return undef; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ( not defined $params{lines} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | $params{lines} | ||||||||||||||||||||||||||||
| 75 | 0 | = Cisco::SNMP::_snmpwalk( $session, _lineOID() . '.20' ); | |||||||||||||||||||||||||||
| 76 | 0 | ▶ | if ( not defined $params{lines} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | $Cisco::SNMP::LASTERROR = "Cannot get lines to clear"; | |||||||||||||||||||||||||||
| 78 | 0 | return undef; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | my @lines; | |||||||||||||||||||||||||||
| 83 | 0 | for ( @{$params{lines}} ) { | |||||||||||||||||||||||||||
| 84 | 0 | ▶ | if (defined $session->set_request( _trmsrvOID . '.10.0', INTEGER, $_ ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | ) { | ||||||||||||||||||||||||||||
| 86 | 0 | push @lines, $_; | |||||||||||||||||||||||||||
| 87 | } else { | ||||||||||||||||||||||||||||
| 88 | 0 | $Cisco::SNMP::LASTERROR = "Failed to clear line $_"; | |||||||||||||||||||||||||||
| 89 | 0 | return undef; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | 0 | return \@lines; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub line_info { | ||||||||||||||||||||||||||
|
Subroutine
line_info: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 97 | 0 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | my $session = $self->{_SESSION_}; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | my %ret; | |||||||||||||||||||||||||||
| 102 | 0 | my @LINEKEYS = lineOIDs(); | |||||||||||||||||||||||||||
| 103 | 0 | for my $oid ( 0 .. $#LINEKEYS ) { | |||||||||||||||||||||||||||
| 104 | 0 | $ret{$LINEKEYS[$oid]} = Cisco::SNMP::_snmpwalk( $session, | |||||||||||||||||||||||||||
| 105 | _lineOID() . '.' . ( $oid + 1 ) ); | ||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if ( not defined $ret{$LINEKEYS[$oid]} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 0 | $Cisco::SNMP::LASTERROR | |||||||||||||||||||||||||||
| 108 | = "Cannot get line `$LINEKEYS[$oid]' info"; | ||||||||||||||||||||||||||||
| 109 | 0 | return undef; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | my %LineTypes = ( | |||||||||||||||||||||||||||
| 114 | 2 => 'CON', | ||||||||||||||||||||||||||||
| 115 | 3 => 'TRM', | ||||||||||||||||||||||||||||
| 116 | 4 => 'LNP', | ||||||||||||||||||||||||||||
| 117 | 5 => 'VTY', | ||||||||||||||||||||||||||||
| 118 | 6 => 'AUX' | ||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||
| 120 | 0 | my %LineModem = ( | |||||||||||||||||||||||||||
| 121 | 2 => 'none', | ||||||||||||||||||||||||||||
| 122 | 3 => 'callin', | ||||||||||||||||||||||||||||
| 123 | 4 => 'callout', | ||||||||||||||||||||||||||||
| 124 | 5 => 'cts-reqd', | ||||||||||||||||||||||||||||
| 125 | 6 => 'ri-is-cd', | ||||||||||||||||||||||||||||
| 126 | 7 => 'inout' | ||||||||||||||||||||||||||||
| 127 | ); | ||||||||||||||||||||||||||||
| 128 | 0 | my %LineFlow = ( | |||||||||||||||||||||||||||
| 129 | 2 => 'none', | ||||||||||||||||||||||||||||
| 130 | 3 => 'sw-in', | ||||||||||||||||||||||||||||
| 131 | 4 => 'sw-out', | ||||||||||||||||||||||||||||
| 132 | 5 => 'sw-both', | ||||||||||||||||||||||||||||
| 133 | 6 => 'hw-in', | ||||||||||||||||||||||||||||
| 134 | 7 => 'hw-out', | ||||||||||||||||||||||||||||
| 135 | 8 => 'hw-both' | ||||||||||||||||||||||||||||
| 136 | ); | ||||||||||||||||||||||||||||
| 137 | 0 | my %LineInfo; | |||||||||||||||||||||||||||
| 138 | 0 | for my $lines ( 0 .. $#{$ret{$LINEKEYS[19]}} ) { | |||||||||||||||||||||||||||
| 139 | 0 | my %LineInfoHash; | |||||||||||||||||||||||||||
| 140 | 0 | for ( 0 .. $#LINEKEYS ) { | |||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ( $_ == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 142 | $LineInfoHash{$LINEKEYS[$_]} | ||||||||||||||||||||||||||||
| 143 | = exists $LineTypes{$ret{$LINEKEYS[$_]}->[$lines]} | ||||||||||||||||||||||||||||
| 144 | ? $LineTypes{$ret{$LINEKEYS[$_]}->[$lines]} | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | : $ret{$LINEKEYS[$_]}->[$lines]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | } elsif ( $_ == 5 ) { | ||||||||||||||||||||||||||||
| 147 | $LineInfoHash{$LINEKEYS[$_]} | ||||||||||||||||||||||||||||
| 148 | = exists $LineFlow{$ret{$LINEKEYS[$_]}->[$lines]} | ||||||||||||||||||||||||||||
| 149 | ? $LineFlow{$ret{$LINEKEYS[$_]}->[$lines]} | ||||||||||||||||||||||||||||
| 150 | 0 | ▶ | : $ret{$LINEKEYS[$_]}->[$lines]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | } elsif ( $_ == 6 ) { | ||||||||||||||||||||||||||||
| 152 | $LineInfoHash{$LINEKEYS[$_]} | ||||||||||||||||||||||||||||
| 153 | = exists $LineModem{$ret{$LINEKEYS[$_]}->[$lines]} | ||||||||||||||||||||||||||||
| 154 | ? $LineModem{$ret{$LINEKEYS[$_]}->[$lines]} | ||||||||||||||||||||||||||||
| 155 | 0 | ▶ | : $ret{$LINEKEYS[$_]}->[$lines]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | } else { | ||||||||||||||||||||||||||||
| 157 | 0 | $LineInfoHash{$LINEKEYS[$_]} = $ret{$LINEKEYS[$_]}->[$lines]; | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | 0 | $LineInfo{$ret{$LINEKEYS[19]}->[$lines]} = \%LineInfoHash; | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | 0 | return bless \%LineInfo, $class; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 3 | for ( lineOIDs() ) { | |||||||||||||||||||||||||||
| 166 | 63 | Cisco::SNMP::_mk_accessors_hash_1( 'line', $_ ); | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | sub line_sessions { | ||||||||||||||||||||||||||
|
Subroutine
line_sessions: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||
| 170 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 171 | 0 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 0 | my $session = $self->{_SESSION_}; | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | my %ret; | |||||||||||||||||||||||||||
| 176 | 0 | my @SESSIONKEYS = sessOIDs(); | |||||||||||||||||||||||||||
| 177 | 0 | for my $oid ( 0 .. $#SESSIONKEYS ) { | |||||||||||||||||||||||||||
| 178 | 0 | $ret{$SESSIONKEYS[$oid]} = Cisco::SNMP::_snmpwalk( $session, | |||||||||||||||||||||||||||
| 179 | _sessOID() . '.' . ( $oid + 1 ) ); | ||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ( not defined $ret{$SESSIONKEYS[$oid]} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 0 | $Cisco::SNMP::LASTERROR | |||||||||||||||||||||||||||
| 182 | = "Cannot get session `$SESSIONKEYS[$oid]' info"; | ||||||||||||||||||||||||||||
| 183 | 0 | return undef; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | my %SessionTypes = ( | |||||||||||||||||||||||||||
| 188 | 1 => 'unknown', | ||||||||||||||||||||||||||||
| 189 | 2 => 'PAD', | ||||||||||||||||||||||||||||
| 190 | 3 => 'stream', | ||||||||||||||||||||||||||||
| 191 | 4 => 'rlogin', | ||||||||||||||||||||||||||||
| 192 | 5 => 'telnet', | ||||||||||||||||||||||||||||
| 193 | 6 => 'TCP', | ||||||||||||||||||||||||||||
| 194 | 7 => 'LAT', | ||||||||||||||||||||||||||||
| 195 | 8 => 'MOP', | ||||||||||||||||||||||||||||
| 196 | 9 => 'SLIP', | ||||||||||||||||||||||||||||
| 197 | 10 => 'XRemote', | ||||||||||||||||||||||||||||
| 198 | 11 => 'rshell' | ||||||||||||||||||||||||||||
| 199 | ); | ||||||||||||||||||||||||||||
| 200 | 0 | my %SessionDir = ( | |||||||||||||||||||||||||||
| 201 | 1 => 'unknown', | ||||||||||||||||||||||||||||
| 202 | 2 => 'IN', | ||||||||||||||||||||||||||||
| 203 | 3 => 'OUT' | ||||||||||||||||||||||||||||
| 204 | ); | ||||||||||||||||||||||||||||
| 205 | 0 | my %SessionInfo; | |||||||||||||||||||||||||||
| 206 | 0 | for my $sess ( 0 .. $#{$ret{$SESSIONKEYS[6]}} ) { | |||||||||||||||||||||||||||
| 207 | 0 | my %SessionInfoHash; | |||||||||||||||||||||||||||
| 208 | 0 | for ( 0 .. $#SESSIONKEYS ) { | |||||||||||||||||||||||||||
| 209 | 0 | ▶ | if ( $_ == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 210 | $SessionInfoHash{$SESSIONKEYS[$_]} | ||||||||||||||||||||||||||||
| 211 | = exists( $SessionTypes{$ret{$SESSIONKEYS[$_]}->[$sess]} ) | ||||||||||||||||||||||||||||
| 212 | ? $SessionTypes{$ret{$SESSIONKEYS[$_]}->[$sess]} | ||||||||||||||||||||||||||||
| 213 | 0 | ▶ | : $ret{$SESSIONKEYS[$_]}->[$sess]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | } elsif ( $_ == 1 ) { | ||||||||||||||||||||||||||||
| 215 | $SessionInfoHash{$SESSIONKEYS[$_]} | ||||||||||||||||||||||||||||
| 216 | = exists( $SessionDir{$ret{$SESSIONKEYS[$_]}->[$sess]} ) | ||||||||||||||||||||||||||||
| 217 | ? $SessionDir{$ret{$SESSIONKEYS[$_]}->[$sess]} | ||||||||||||||||||||||||||||
| 218 | 0 | ▶ | : $ret{$SESSIONKEYS[$_]}->[$sess]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | } else { | ||||||||||||||||||||||||||||
| 220 | $SessionInfoHash{$SESSIONKEYS[$_]} | ||||||||||||||||||||||||||||
| 221 | 0 | = $ret{$SESSIONKEYS[$_]}->[$sess]; | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | 0 | push @{$SessionInfo{$ret{$SESSIONKEYS[6]}->[$sess]}}, | |||||||||||||||||||||||||||
| 225 | \%SessionInfoHash; | ||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | 0 | return bless \%SessionInfo, $class; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 3 | for ( sessOIDs() ) { | |||||||||||||||||||||||||||
| 231 | 21 | Cisco::SNMP::_mk_accessors_hash_2( 'line', 'sess', $_ ); | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 0 | ▶ | sub line_message { | ||||||||||||||||||||||||||
|
Subroutine
line_message: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 235 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 0 | my $session = $self->{_SESSION_}; | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | my %params = ( | |||||||||||||||||||||||||||
| 240 | message => 'Test Message.', | ||||||||||||||||||||||||||||
| 241 | lines => [-1] | ||||||||||||||||||||||||||||
| 242 | ); | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 0 | my %args; | |||||||||||||||||||||||||||
| 245 | 0 | ▶ | if ( @_ == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | 0 | ( $params{message} ) = @_; | |||||||||||||||||||||||||||
| 247 | } else { | ||||||||||||||||||||||||||||
| 248 | 0 | %args = @_; | |||||||||||||||||||||||||||
| 249 | 0 | for ( keys(%args) ) { | |||||||||||||||||||||||||||
| 250 | 0 | ▶ | if (/^-?message$/i) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 251 | 0 | $params{message} = $args{$_}; | |||||||||||||||||||||||||||
| 252 | } elsif (/^-?line(?:s)?$/i) { | ||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if (not defined( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | $params{lines} = Cisco::SNMP::_get_range( $args{$_} ) | ||||||||||||||||||||||||||||
| 255 | ) | ||||||||||||||||||||||||||||
| 256 | ) { | ||||||||||||||||||||||||||||
| 257 | 0 | return undef; | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 0 | my $response; | |||||||||||||||||||||||||||
| 264 | my @lines; | ||||||||||||||||||||||||||||
| 265 | 0 | for ( @{$params{lines}} ) { | |||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | # Lines | ||||||||||||||||||||||||||||
| 268 | 0 | my $response | |||||||||||||||||||||||||||
| 269 | = $session->set_request( _trmsrvOID() . '.4.0', INTEGER, $_ ); | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | # Interval (reissue) | ||||||||||||||||||||||||||||
| 272 | 0 | $response | |||||||||||||||||||||||||||
| 273 | = $session->set_request( _trmsrvOID() . '.5.0', INTEGER, 0 ); | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | # Duration | ||||||||||||||||||||||||||||
| 276 | 0 | $response | |||||||||||||||||||||||||||
| 277 | = $session->set_request( _trmsrvOID() . '.6.0', INTEGER, 0 ); | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | # Text (256 chars) | ||||||||||||||||||||||||||||
| 280 | $response = $session->set_request( _trmsrvOID() . '.7.0', | ||||||||||||||||||||||||||||
| 281 | 0 | OCTET_STRING, $params{message} ); | |||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | # Temp Banner (1=no 2=append) | ||||||||||||||||||||||||||||
| 284 | 0 | $response | |||||||||||||||||||||||||||
| 285 | = $session->set_request( _trmsrvOID() . '.8.0', INTEGER, 1 ); | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | # Send | ||||||||||||||||||||||||||||
| 288 | 0 | $response | |||||||||||||||||||||||||||
| 289 | = $session->set_request( _trmsrvOID() . '.9.0', INTEGER, 1 ); | ||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if ( defined $response ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 291 | 0 | push @lines, $_; | |||||||||||||||||||||||||||
| 292 | } else { | ||||||||||||||||||||||||||||
| 293 | 0 | $Cisco::SNMP::LASTERROR = "Failed to send message to line $_"; | |||||||||||||||||||||||||||
| 294 | 0 | return undef; | |||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | # clear message | ||||||||||||||||||||||||||||
| 299 | 0 | $session->set_request( _trmsrvOID() . '.7.0', OCTET_STRING, "" ); | |||||||||||||||||||||||||||
| 300 | 0 | ▶ | if ( $lines[0] == -1 ) { $lines[0] = "ALL" } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | 0 | return \@lines; | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sub line_numberof { | ||||||||||||||||||||||||||
|
Subroutine
line_numberof: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 305 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 0 | my $session = $self->{_SESSION_}; | |||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 0 | my $response; | |||||||||||||||||||||||||||
| 310 | 0 | ▶ | if (not defined( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | $response | ||||||||||||||||||||||||||||
| 312 | = $session->get_request( -varbindlist => [_trmsrvOID . '.1.0'] ) | ||||||||||||||||||||||||||||
| 313 | ) | ||||||||||||||||||||||||||||
| 314 | ) { | ||||||||||||||||||||||||||||
| 315 | 0 | $Cisco::SNMP::LASTERROR = "Cannot get number of lines"; | |||||||||||||||||||||||||||
| 316 | 0 | return undef; | |||||||||||||||||||||||||||
| 317 | } else { | ||||||||||||||||||||||||||||
| 318 | 0 | return $response->{_trmsrvOID() . '.1.0'}; | |||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | # get_ direct | ||||||||||||||||||||||||||||
| 325 | 3 | my @OIDS = lineOIDs(); | |||||||||||||||||||||||||||
| 326 | 3 | for my $o ( 0 .. $#OIDS ) { | |||||||||||||||||||||||||||
| 327 | 63 | ▶ | *{"get_line" . $OIDS[$o]} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=15.9
| |||||||||||||||||||||||||||||
| 328 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 329 | 0 | my ($val) = @_; | |||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if ( not defined $val ) { $val = 0 } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 332 | 0 | my $s = $self->session; | |||||||||||||||||||||||||||
| 333 | 0 | my $r = $s->get_request( | |||||||||||||||||||||||||||
| 334 | varbindlist => [_lineOID() . '.' . ( $o + 1 ) . '.' . $val] ); | ||||||||||||||||||||||||||||
| 335 | 0 | return $r->{_lineOID() . '.' . ( $o + 1 ) . '.' . $val}; | |||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | 63 | } | |||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | 3 | @OIDS = sessOIDs(); | |||||||||||||||||||||||||||
| 340 | 3 | for my $o ( 0 .. $#OIDS ) { | |||||||||||||||||||||||||||
| 341 | 21 | ▶ | *{"get_sess" . $OIDS[$o]} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=23.2
| |||||||||||||||||||||||||||||
| 342 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 343 | 0 | my ( $val1, $val2 ) = @_; | |||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 0 | ▶ | if ( not defined $val1 ) { $val1 = 0 } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 346 | 0 | ▶ | if ( not defined $val2 ) { $val2 = 0 } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 347 | 0 | my $s = $self->session; | |||||||||||||||||||||||||||
| 348 | 0 | my $r = $s->get_request( varbindlist => | |||||||||||||||||||||||||||
| 349 | [_sessOID() . '.' . ( $o + 1 ) . '.' . "$val1.$val2"] ); | ||||||||||||||||||||||||||||
| 350 | 0 | return $r->{_sessOID() . '.' . ( $o + 1 ) . '.' . "$val1.$val2"}; | |||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||
| 352 | 21 | } | |||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | ################################################## | ||||||||||||||||||||||||||||
| 355 | # End Public Module | ||||||||||||||||||||||||||||
| 356 | ################################################## | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 3 | 1; | |||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | __END__ | ||||||||||||||||||||||||||||