| 1 |
|
| # SNMP::Info::Layer3::Enterasys - SNMP Interface to Enterasys devices |
| 2 |
|
| # |
| 3 |
|
| # Copyright (c) 2008 Eric Miller |
| 4 |
|
| # All rights reserved. |
| 5 |
|
| # |
| 6 |
|
| # Redistribution and use in source and binary forms, with or without |
| 7 |
|
| # modification, are permitted provided that the following conditions are met: |
| 8 |
|
| # |
| 9 |
|
| # * Redistributions of source code must retain the above copyright notice, |
| 10 |
|
| # this list of conditions and the following disclaimer. |
| 11 |
|
| # * Redistributions in binary form must reproduce the above copyright |
| 12 |
|
| # notice, this list of conditions and the following disclaimer in the |
| 13 |
|
| # documentation and/or other materials provided with the distribution. |
| 14 |
|
| # * Neither the name of the University of California, Santa Cruz nor the |
| 15 |
|
| # names of its contributors may be used to endorse or promote products |
| 16 |
|
| # derived from this software without specific prior written permission. |
| 17 |
|
| # |
| 18 |
|
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 |
|
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 |
|
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 |
|
| # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 22 |
|
| # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 |
|
| # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 |
|
| # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 |
|
| # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 |
|
| # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 |
|
| # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 |
|
| # POSSIBILITY OF SUCH DAMAGE. |
| 29 |
|
| |
| 30 |
|
| package SNMP::Info::Layer3::Enterasys; |
| 31 |
|
| |
| 32 |
|
| use strict; |
| 33 |
|
| use warnings; |
| 34 |
|
| use Exporter; |
| 35 |
|
| use SNMP::Info::MAU; |
| 36 |
|
| use SNMP::Info::CDP; |
| 37 |
|
| use SNMP::Info::Layer3; |
| 38 |
|
| |
| 39 |
|
| @SNMP::Info::Layer3::Enterasys::ISA = qw/SNMP::Info::MAU |
| 40 |
|
| SNMP::Info::CDP SNMP::Info::Layer3 |
| 41 |
|
| Exporter/; |
| 42 |
|
| @SNMP::Info::Layer3::Enterasys::EXPORT_OK = qw//; |
| 43 |
|
| |
| 44 |
|
| our ($VERSION, $DEBUG, %GLOBALS, %FUNCS, $INIT, %MIBS, %MUNGE); |
| 45 |
|
| |
| 46 |
|
| $VERSION = '3.985003'; |
| 47 |
|
| |
| 48 |
|
| %MIBS = ( |
| 49 |
|
| %SNMP::Info::Layer3::MIBS, %SNMP::Info::CDP::MIBS, |
| 50 |
|
| %SNMP::Info::MAU::MIBS, |
| 51 |
|
| 'ENTERASYS-OIDS-MIB' => 'etsysOidDevice', |
| 52 |
|
| ); |
| 53 |
|
| |
| 54 |
|
| %GLOBALS = ( |
| 55 |
|
| %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::CDP::GLOBALS, |
| 56 |
|
| %SNMP::Info::MAU::GLOBALS, |
| 57 |
|
| 'mac' => 'dot1dBaseBridgeAddress', |
| 58 |
|
| ); |
| 59 |
|
| |
| 60 |
|
| %FUNCS = ( |
| 61 |
|
| %SNMP::Info::Layer3::FUNCS, %SNMP::Info::CDP::FUNCS, |
| 62 |
|
| %SNMP::Info::MAU::FUNCS, |
| 63 |
|
| ); |
| 64 |
|
| |
| 65 |
|
| %MUNGE = ( |
| 66 |
|
| %SNMP::Info::Layer3::MUNGE, %SNMP::Info::CDP::MUNGE, |
| 67 |
|
| %SNMP::Info::MAU::MUNGE, |
| 68 |
|
| ); |
| 69 |
|
| |
| 70 |
|
| sub model { |
| 71 |
|
| my $enterasys = shift; |
| 72 |
|
| my $id = $enterasys->id(); |
| 73 |
|
| |
| 74 |
|
| unless ( defined $id ) { |
| 75 |
|
| print |
| 76 |
|
| " SNMP::Info::Layer3::Enterasys::model() - Device does not support sysObjectID\n" |
| 77 |
|
| if $enterasys->debug(); |
| 78 |
|
| return; |
| 79 |
|
| } |
| 80 |
|
| |
| 81 |
|
| my $model = &SNMP::translateObj($id); |
| 82 |
|
| |
| 83 |
|
| $model =~ s/^etsysOidDev//i; |
| 84 |
|
| $model =~ s/^etsysOidPhy//i; |
| 85 |
|
| return $id unless defined $model; |
| 86 |
|
| |
| 87 |
|
| return $model; |
| 88 |
|
| } |
| 89 |
|
| |
| 90 |
|
| sub vendor { |
| 91 |
|
| return 'enterasys'; |
| 92 |
|
| } |
| 93 |
|
| |
| 94 |
|
| sub os { |
| 95 |
|
| return 'enterasys'; |
| 96 |
|
| } |
| 97 |
|
| |
| 98 |
|
| sub os_ver { |
| 99 |
|
| my $enterasys = shift; |
| 100 |
|
| my $descr = $enterasys->description(); |
| 101 |
|
| return unless defined $descr; |
| 102 |
|
| |
| 103 |
|
| if ( $descr =~ m/\bRev ([\d.]*)/ ) { |
| 104 |
|
| return $1; |
| 105 |
|
| } |
| 106 |
|
| |
| 107 |
|
| return; |
| 108 |
|
| } |
| 109 |
|
| |
| 110 |
|
| # Use ifName as it is used for CDP and LLDP. |
| 111 |
|
| sub interfaces { |
| 112 |
|
| my $enterasys = shift; |
| 113 |
|
| my $partial = shift; |
| 114 |
|
| |
| 115 |
|
| # We need the original ifName, SUPER:: would give us a method definition |
| 116 |
|
| # in a higher class, we could use orig_ but just call the MIB leaf since |
| 117 |
|
| # that's what we really want anyway. |
| 118 |
|
| return $enterasys->ifName($partial) |
| 119 |
|
| || $enterasys->i_description($partial); |
| 120 |
|
| } |
| 121 |
|
| |
| 122 |
|
| sub i_ignore { |
| 123 |
|
| my $enterasys = shift; |
| 124 |
|
| my $partial = shift; |
| 125 |
|
| |
| 126 |
|
| my $interfaces = $enterasys->i_type($partial) || {}; |
| 127 |
|
| |
| 128 |
|
| my %i_ignore; |
| 129 |
|
| foreach my $if ( keys %$interfaces ) { |
| 130 |
|
| if ( $interfaces->{$if} =~ /(rs232|tunnel|loopback|\blo\b|null)/i ) { |
| 131 |
|
| $i_ignore{$if}++; |
| 132 |
|
| } |
| 133 |
|
| } |
| 134 |
|
| return \%i_ignore; |
| 135 |
|
| } |
| 136 |
|
| |
| 137 |
|
| sub i_duplex { |
| 138 |
|
| my $enterasys = shift; |
| 139 |
|
| my $partial = shift; |
| 140 |
|
| |
| 141 |
|
| return $enterasys->mau_i_duplex($partial); |
| 142 |
|
| } |
| 143 |
|
| |
| 144 |
|
| sub i_duplex_admin { |
| 145 |
|
| my $enterasys = shift; |
| 146 |
|
| my $partial = shift; |
| 147 |
|
| |
| 148 |
|
| return $enterasys->mau_i_duplex_admin($partial); |
| 149 |
|
| } |
| 150 |
|
| |
| 151 |
|
| # TimeFilter implementation continuously increments when walked |
| 152 |
|
| # and we may never reach the end of the table. This behavior can be |
| 153 |
|
| # modified with the "set snmp timefilter break disable" command, |
| 154 |
|
| # unfortunately it is not the default. Query with a partial value of zero |
| 155 |
|
| # which means no time filter for tables with and index containing a |
| 156 |
|
| # TimeFilter |
| 157 |
|
| |
| 158 |
|
| sub qb_fdb_index { |
| 159 |
|
| my $bridge = shift; |
| 160 |
|
| |
| 161 |
|
| my $qb_fdb_ids = $bridge->dot1qVlanFdbId(0) || {}; |
| 162 |
|
| |
| 163 |
|
| return $bridge->_qb_fdb_vlan_map($qb_fdb_ids); |
| 164 |
|
| } |
| 165 |
|
| |
| 166 |
|
| sub i_vlan_membership { |
| 167 |
|
| my $bridge = shift; |
| 168 |
|
| my $partial = shift; |
| 169 |
|
| |
| 170 |
|
| # dot1qVlanCurrentTable TimeFilter index |
| 171 |
|
| my $v_ports = $bridge->qb_cv_egress(0) || $bridge->qb_v_egress(); |
| 172 |
|
| |
| 173 |
|
| return $bridge->_vlan_hoa($v_ports, $partial); |
| 174 |
|
| } |
| 175 |
|
| |
| 176 |
|
| sub i_vlan_membership_untagged { |
| 177 |
|
| my $bridge = shift; |
| 178 |
|
| my $partial = shift; |
| 179 |
|
| |
| 180 |
|
| # dot1qVlanCurrentTable TimeFilter index |
| 181 |
|
| my $v_ports = $bridge->qb_cv_untagged(0) || $bridge->qb_v_untagged(); |
| 182 |
|
| |
| 183 |
|
| return $bridge->_vlan_hoa($v_ports, $partial); |
| 184 |
|
| } |
| 185 |
|
| |
| 186 |
|
| sub lldp_ip { |
| 187 |
|
| my $enterasys = shift; |
| 188 |
|
| my $partial = shift || 0; |
| 189 |
|
| |
| 190 |
|
| return $enterasys->SUPER::lldp_ip($partial); |
| 191 |
|
| } |
| 192 |
|
| |
| 193 |
|
| # [3564920] LLDP-MIB::lldpLocPortDesc isn't always unique, |
| 194 |
|
| # use LLDP-MIB::lldpLocPortId this cross references to ifName |
| 195 |
|
| sub lldp_if { |
| 196 |
|
| my $lldp = shift; |
| 197 |
|
| my $partial = shift || 0; |
| 198 |
|
| |
| 199 |
|
| my $addr = $lldp->lldp_rem_pid($partial) || {}; |
| 200 |
|
| my $i_descr = $lldp->ifName() || {}; |
| 201 |
|
| my %r_i_descr = reverse %$i_descr; |
| 202 |
|
| |
| 203 |
|
| my %lldp_if; |
| 204 |
|
| foreach my $key ( keys %$addr ) { |
| 205 |
|
| my @aOID = split( '\.', $key ); |
| 206 |
|
| my $port = $aOID[1]; |
| 207 |
|
| next unless $port; |
| 208 |
|
| # Local LLDP port may not equate to ifIndex |
| 209 |
|
| # Cross reference lldpLocPortId with ifName to get ifIndex |
| 210 |
|
| my $lldp_desc = $lldp->lldpLocPortId($port); |
| 211 |
|
| my $desc = $lldp_desc->{$port}; |
| 212 |
|
| # If cross reference is successful use it, otherwise stick with lldpRemLocalPortNum |
| 213 |
|
| if ( exists $r_i_descr{$desc} ) { |
| 214 |
|
| $port = $r_i_descr{$desc}; |
| 215 |
|
| } |
| 216 |
|
| |
| 217 |
|
| $lldp_if{$key} = $port; |
| 218 |
|
| } |
| 219 |
|
| return \%lldp_if; |
| 220 |
|
| } |
| 221 |
|
| |
| 222 |
|
| sub lldp_port { |
| 223 |
|
| my $enterasys = shift; |
| 224 |
|
| my $partial = shift || 0; |
| 225 |
|
| |
| 226 |
|
| return $enterasys->SUPER::lldp_port($partial); |
| 227 |
|
| } |
| 228 |
|
| |
| 229 |
|
| sub lldp_id { |
| 230 |
|
| my $enterasys = shift; |
| 231 |
|
| my $partial = shift || 0; |
| 232 |
|
| |
| 233 |
|
| return $enterasys->SUPER::lldp_id($partial); |
| 234 |
|
| } |
| 235 |
|
| |
| 236 |
|
| sub lldp_platform { |
| 237 |
|
| my $enterasys = shift; |
| 238 |
|
| my $partial = shift || 0; |
| 239 |
|
| |
| 240 |
|
| return $enterasys->SUPER::lldp_rem_sysdesc($partial); |
| 241 |
|
| } |
| 242 |
|
| |
| 243 |
|
| 1; |
| 244 |
|
| __END__ |