| 1 | # SNMP::Info::Layer2::Centillion | ||
| 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::Layer2::Centillion; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | use SNMP::Info; | ||
| 36 | use SNMP::Info::NortelStack; | ||
| 37 | use SNMP::Info::SONMP; | ||
| 38 | |||
| 39 | @SNMP::Info::Layer2::Centillion::ISA | ||
| 40 | = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::NortelStack SNMP::Info::SONMP Exporter/; | ||
| 41 | @SNMP::Info::Layer2::Centillion::EXPORT_OK = qw//; | ||
| 42 | |||
| 43 | our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE); | ||
| 44 | |||
| 45 | $VERSION = '3.985003'; | ||
| 46 | |||
| 47 | %MIBS = ( | ||
| 48 | %SNMP::Info::MIBS, | ||
| 49 | %SNMP::Info::Bridge::MIBS, | ||
| 50 | %SNMP::Info::NortelStack::MIBS, | ||
| 51 | %SNMP::Info::SONMP::MIBS, | ||
| 52 | 'CENTILLION-DOT3-EXTENSIONS-MIB' => 'cnDot3ExtnTable', | ||
| 53 | 'S5-COMMON-STATS-MIB' => 's5CmStat', | ||
| 54 | 'CENTILLION-VLAN-MIB' => 'cnVlanENETMgt', | ||
| 55 | 'CENTILLION-CONFIG-MIB' => 'sysTFTPStart', | ||
| 56 | ); | ||
| 57 | |||
| 58 | %GLOBALS = ( | ||
| 59 | %SNMP::Info::GLOBALS, | ||
| 60 | %SNMP::Info::Bridge::GLOBALS, | ||
| 61 | %SNMP::Info::NortelStack::GLOBALS, | ||
| 62 | %SNMP::Info::SONMP::GLOBALS, | ||
| 63 | 'tftp_action' => 'sysTFTPStart', | ||
| 64 | 'tftp_host' => 'sysTFTPIpAddress', | ||
| 65 | 'tftp_file' => 'sysTFTPFileName', | ||
| 66 | 'tftp_type' => 'sysTFTPFileType', | ||
| 67 | 'tftp_result' => 'sysTFTPResult', | ||
| 68 | ); | ||
| 69 | |||
| 70 | %FUNCS = ( | ||
| 71 | %SNMP::Info::FUNCS, | ||
| 72 | %SNMP::Info::Bridge::FUNCS, | ||
| 73 | %SNMP::Info::NortelStack::FUNCS, | ||
| 74 | %SNMP::Info::SONMP::FUNCS, | ||
| 75 | |||
| 76 | # CENTILLION-DOT3-EXTENSIONS-MIB::cnDot3ExtnTable | ||
| 77 | 'centillion_p_index' => 'cnDot3ExtnIfIndex', | ||
| 78 | 'centillion_p_duplex' => 'cnDot3ExtnIfOperConnectionType', | ||
| 79 | 'centillion_p_duplex_admin' => 'cnDot3ExtnIfAdminConnectionType', | ||
| 80 | |||
| 81 | # S5-COMMON-STATS-MIB::s5CmSNodeTable | ||
| 82 | 'fw_mac' => 's5CmSNodeMacAddr', | ||
| 83 | 'fw_port' => 's5CmSNodeIfIndx', | ||
| 84 | |||
| 85 | # CENTILLION-VLAN-MIB::cnVlanPortMemberTable | ||
| 86 | 'centillion_i_vlan_index' => 'cnVlanPortMemberIfIndex', | ||
| 87 | 'centillion_i_vlan' => 'cnVlanPortMemberVID', | ||
| 88 | 'centillion_i_vlan_type' => 'cnVlanPortMemberIngressType', | ||
| 89 | ); | ||
| 90 | |||
| 91 | %MUNGE = ( | ||
| 92 | |||
| 93 | # Inherit all the built in munging | ||
| 94 | %SNMP::Info::MUNGE, | ||
| 95 | %SNMP::Info::Bridge::MUNGE, | ||
| 96 | %SNMP::Info::NortelStack::MUNGE, | ||
| 97 | %SNMP::Info::SONMP::MUNGE, | ||
| 98 | ); | ||
| 99 | |||
| 100 | sub os { | ||
| 101 | return 'centillion'; | ||
| 102 | } | ||
| 103 | |||
| 104 | sub vendor { | ||
| 105 | return 'nortel'; | ||
| 106 | } | ||
| 107 | |||
| 108 | sub i_ignore { | ||
| 109 | my $centillion = shift; | ||
| 110 | my $descr = $centillion->i_description(); | ||
| 111 | |||
| 112 | my %i_ignore; | ||
| 113 | foreach my $if ( keys %$descr ) { | ||
| 114 | my $type = $descr->{$if}; | ||
| 115 | |||
| 116 | # Skip virtual interfaces | ||
| 117 | $i_ignore{$if}++ if $type =~ /(VE|VID|vc|lp)/i; | ||
| 118 | } | ||
| 119 | return \%i_ignore; | ||
| 120 | } | ||
| 121 | |||
| 122 | sub interfaces { | ||
| 123 | my $centillion = shift; | ||
| 124 | my $i_index = $centillion->i_index(); | ||
| 125 | my $i_descr = $centillion->i_description(); | ||
| 126 | |||
| 127 | my %if; | ||
| 128 | foreach my $iid ( keys %$i_index ) { | ||
| 129 | my $index = $i_index->{$iid}; | ||
| 130 | next unless defined $index; | ||
| 131 | my $descr = $i_descr->{$iid}; | ||
| 132 | |||
| 133 | # Skip ATM and virtual interfaces | ||
| 134 | next if $descr =~ /(VE|VID|vc|lp)/i; | ||
| 135 | |||
| 136 | # Index numbers are deterministic slot * 256 + port | ||
| 137 | my $port = $index % 256; | ||
| 138 | my $slot = int( $index / 256 ); | ||
| 139 | my $slotport = "$slot.$port"; | ||
| 140 | |||
| 141 | $slotport = "$descr" if $descr =~ /(mcp)/i; | ||
| 142 | |||
| 143 | $if{$index} = $slotport; | ||
| 144 | } | ||
| 145 | |||
| 146 | return \%if; | ||
| 147 | } | ||
| 148 | |||
| 149 | sub i_duplex { | ||
| 150 | my $centillion = shift; | ||
| 151 | |||
| 152 | my $port_index = $centillion->centillion_p_index(); | ||
| 153 | my $port_duplex = $centillion->centillion_p_duplex(); | ||
| 154 | |||
| 155 | my %i_duplex; | ||
| 156 | foreach my $iid ( keys %$port_index ) { | ||
| 157 | my $index = $port_index->{$iid}; | ||
| 158 | next unless defined $index; | ||
| 159 | my $duplex = $port_duplex->{$iid}; | ||
| 160 | next unless defined $duplex; | ||
| 161 | |||
| 162 | $duplex = 'half' if $duplex =~ /half/i; | ||
| 163 | $duplex = 'full' if $duplex =~ /full/i; | ||
| 164 | $i_duplex{$index} = $duplex; | ||
| 165 | } | ||
| 166 | return \%i_duplex; | ||
| 167 | } | ||
| 168 | |||
| 169 | sub i_duplex_admin { | ||
| 170 | my $centillion = shift; | ||
| 171 | |||
| 172 | my $port_index = $centillion->centillion_p_index(); | ||
| 173 | my $port_admin = $centillion->centillion_p_duplex_admin(); | ||
| 174 | |||
| 175 | my %i_duplex_admin; | ||
| 176 | foreach my $iid ( keys %$port_index ) { | ||
| 177 | my $index = $port_index->{$iid}; | ||
| 178 | next unless defined $index; | ||
| 179 | my $duplex = $port_admin->{$iid}; | ||
| 180 | next unless defined $duplex; | ||
| 181 | |||
| 182 | $duplex = 'half' if $duplex =~ /half/i; | ||
| 183 | $duplex = 'full' if $duplex =~ /full/i; | ||
| 184 | $duplex = 'auto' if $duplex =~ /auto/i; | ||
| 185 | $i_duplex_admin{$index} = $duplex; | ||
| 186 | } | ||
| 187 | return \%i_duplex_admin; | ||
| 188 | } | ||
| 189 | |||
| 190 | sub i_vlan { | ||
| 191 | my $centillion = shift; | ||
| 192 | |||
| 193 | my $cn_vlan_index = $centillion->centillion_i_vlan_index(); | ||
| 194 | my $cn_vlan = $centillion->centillion_i_vlan(); | ||
| 195 | |||
| 196 | my %i_vlan; | ||
| 197 | foreach my $iid ( keys %$cn_vlan_index ) { | ||
| 198 | my $index = $cn_vlan_index->{$iid}; | ||
| 199 | next unless defined $index; | ||
| 200 | my $vlan = $cn_vlan->{$iid}; | ||
| 201 | next unless defined $vlan; | ||
| 202 | |||
| 203 | $i_vlan{$index} = $vlan; | ||
| 204 | } | ||
| 205 | return \%i_vlan; | ||
| 206 | } | ||
| 207 | |||
| 208 | sub model { | ||
| 209 | my $centillion = shift; | ||
| 210 | my $id = $centillion->id(); | ||
| 211 | return unless defined $id; | ||
| 212 | my $model = &SNMP::translateObj($id); | ||
| 213 | return $id unless defined $model; | ||
| 214 | $model =~ s/^sreg-//i; | ||
| 215 | |||
| 216 | return '5000BH' if ( $model =~ /5000BH/ ); | ||
| 217 | return '5005BH' if ( $model =~ /5005BH/ ); | ||
| 218 | return 'C100' if ( $model =~ /Centillion100/ ); | ||
| 219 | return 'C50N' if ( $model =~ /Centillion50N/ ); | ||
| 220 | return 'C50T' if ( $model =~ /Centillion50T/ ); | ||
| 221 | return $model; | ||
| 222 | } | ||
| 223 | |||
| 224 | sub bp_index { | ||
| 225 | my $centillion = shift; | ||
| 226 | my $index = $centillion->fw_port(); | ||
| 227 | |||
| 228 | my %bp_index; | ||
| 229 | foreach my $iid ( keys %$index ) { | ||
| 230 | my $b_index = $index->{$iid}; | ||
| 231 | next unless defined $b_index; | ||
| 232 | |||
| 233 | #Index value is the same as ifIndex | ||
| 234 | $bp_index{$b_index} = $b_index; | ||
| 235 | } | ||
| 236 | |||
| 237 | return \%bp_index; | ||
| 238 | } | ||
| 239 | |||
| 240 | sub index_factor { | ||
| 241 | return 256; | ||
| 242 | } | ||
| 243 | |||
| 244 | sub slot_offset { | ||
| 245 | return 0; | ||
| 246 | } | ||
| 247 | |||
| 248 | sub fw_mac { | ||
| 249 | my $centillion = shift; | ||
| 250 | my $partial = shift; | ||
| 251 | |||
| 252 | return $centillion->SUPER::fw_mac($partial); | ||
| 253 | } | ||
| 254 | |||
| 255 | sub fw_port { | ||
| 256 | my $centillion = shift; | ||
| 257 | my $partial = shift; | ||
| 258 | |||
| 259 | return $centillion->SUPER::fw_port($partial); | ||
| 260 | } | ||
| 261 | |||
| 262 | 1; | ||
| 263 | __END__ |