| 1 | # SNMP::Info::Layer3::Force10 | ||
| 2 | # | ||
| 3 | # Copyright (c) 2012 William Bulley | ||
| 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 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::Force10; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | |||
| 36 | use SNMP::Info::Layer3; | ||
| 37 | use SNMP::Info::MAU; | ||
| 38 | |||
| 39 | @SNMP::Info::Layer3::Force10::ISA = qw/SNMP::Info::MAU | ||
| 40 | SNMP::Info::Layer3 Exporter/; | ||
| 41 | @SNMP::Info::Layer3::Force10::EXPORT_OK = qw//; | ||
| 42 | |||
| 43 | our ($VERSION, $DEBUG, %GLOBALS, %MIBS, %FUNCS, %MUNGE); | ||
| 44 | |||
| 45 | $VERSION = '3.985003'; | ||
| 46 | |||
| 47 | %MIBS = ( | ||
| 48 | %SNMP::Info::Layer3::MIBS, | ||
| 49 | %SNMP::Info::MAU::MIBS, | ||
| 50 | 'F10-PRODUCTS-MIB' => 'f10ESeriesProducts', | ||
| 51 | ); | ||
| 52 | |||
| 53 | %GLOBALS = ( | ||
| 54 | %SNMP::Info::Layer3::GLOBALS, | ||
| 55 | %SNMP::Info::MAU::GLOBALS, | ||
| 56 | ); | ||
| 57 | |||
| 58 | %FUNCS = ( | ||
| 59 | %SNMP::Info::Layer3::FUNCS, | ||
| 60 | %SNMP::Info::MAU::FUNCS, | ||
| 61 | ); | ||
| 62 | |||
| 63 | %MUNGE = ( | ||
| 64 | %SNMP::Info::Layer3::MUNGE, | ||
| 65 | %SNMP::Info::MAU::MUNGE, | ||
| 66 | ); | ||
| 67 | |||
| 68 | # use MAU-MIB for admin. duplex and admin. speed | ||
| 69 | *SNMP::Info::Layer3::Force10::i_duplex_admin | ||
| 70 | = \&SNMP::Info::MAU::mau_i_duplex_admin; | ||
| 71 | *SNMP::Info::Layer3::Force10::i_speed_admin | ||
| 72 | = \&SNMP::Info::MAU::mau_i_speed_admin; | ||
| 73 | |||
| 74 | sub vendor { | ||
| 75 | return 'force10'; | ||
| 76 | } | ||
| 77 | |||
| 78 | sub os { | ||
| 79 | return 'ftos'; | ||
| 80 | } | ||
| 81 | |||
| 82 | sub os_ver { | ||
| 83 | my $force10 = shift; | ||
| 84 | my $descr = $force10->description(); | ||
| 85 | my $os_ver = undef; | ||
| 86 | |||
| 87 | $os_ver = $1 if ( $descr =~ /\s+Application\s+Software\s+Version:\s+(\S+)/s ); | ||
| 88 | |||
| 89 | return $os_ver; | ||
| 90 | } | ||
| 91 | |||
| 92 | sub model { | ||
| 93 | my $force10 = shift; | ||
| 94 | my $id = $force10->id(); | ||
| 95 | |||
| 96 | my $model = &SNMP::translateObj($id); | ||
| 97 | return $id unless defined $model; | ||
| 98 | |||
| 99 | return $model; | ||
| 100 | } | ||
| 101 | |||
| 102 | sub v_name { | ||
| 103 | my $force10 = shift; | ||
| 104 | my $partial = shift; | ||
| 105 | |||
| 106 | return $force10->qb_v_name($partial); | ||
| 107 | } | ||
| 108 | |||
| 109 | # ------------------- stub for now----------------- | ||
| 110 | sub i_vlan { | ||
| 111 | my $force10 = shift; | ||
| 112 | my $partial = shift; | ||
| 113 | |||
| 114 | my $i_vlan = {}; | ||
| 115 | |||
| 116 | return $i_vlan; | ||
| 117 | } | ||
| 118 | |||
| 119 | # Apparently index doesn't use VLAN ID, so override the HOA private | ||
| 120 | # method here to correct the mapping | ||
| 121 | sub _vlan_hoa { | ||
| 122 | my $force10 = shift; | ||
| 123 | my ( $v_ports, $partial ) = @_; | ||
| 124 | |||
| 125 | my $index = $force10->bp_index(); | ||
| 126 | my $v_index = $force10->v_index(); | ||
| 127 | |||
| 128 | my $vlan_hoa = {}; | ||
| 129 | foreach my $idx ( sort keys %{$v_ports} ) { | ||
| 130 | next unless ( defined $v_ports->{$idx} ); | ||
| 131 | my $portlist = $v_ports->{$idx}; # is an array reference | ||
| 132 | my $ret = []; | ||
| 133 | my $vlan_ndx = $idx; | ||
| 134 | |||
| 135 | # Strip TimeFilter if we're using VlanCurrentTable | ||
| 136 | ( $vlan_ndx = $idx ) =~ s/^\d+\.//; | ||
| 137 | |||
| 138 | # Convert portlist bit array to bp_index array | ||
| 139 | for ( my $i = 0; $i <= $#$portlist; $i++ ) { | ||
| 140 | push( @{$ret}, $i + 1 ) if ( @$portlist[$i] ); | ||
| 141 | } | ||
| 142 | |||
| 143 | #Create HoA ifIndex -> VLAN array | ||
| 144 | foreach my $port ( @{$ret} ) { | ||
| 145 | my $ifindex = $index->{$port}; | ||
| 146 | next unless ( defined($ifindex) ); # shouldn't happen | ||
| 147 | next if ( defined $partial and $ifindex !~ /^$partial$/ ); | ||
| 148 | my $vlan_tag = $v_index->{$vlan_ndx}; | ||
| 149 | |||
| 150 | # FIXME: would be preferable to use | ||
| 151 | # the mapping from Q-BRIDGE-MIB::dot1qVlanFdbId | ||
| 152 | my $mod = $vlan_tag % 4096; | ||
| 153 | |||
| 154 | push ( @{ $vlan_hoa->{$ifindex} }, ($mod) ); | ||
| 155 | } | ||
| 156 | } | ||
| 157 | return $vlan_hoa; | ||
| 158 | } | ||
| 159 | |||
| 160 | 1; | ||
| 161 | |||
| 162 | __END__ |