| 1 | # SNMP::Info::RapidCityLegacy | ||
| 2 | # | ||
| 3 | # Copyright (c) 2014 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::RapidCityLegacy; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | use SNMP::Info; | ||
| 36 | use SNMP::Info::RapidCity (); | ||
| 37 | |||
| 38 | @SNMP::Info::RapidCityLegacy::ISA = qw/SNMP::Info Exporter/; | ||
| 39 | @SNMP::Info::RapidCityLegacy::EXPORT_OK = qw//; | ||
| 40 | |||
| 41 | our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE); | ||
| 42 | |||
| 43 | $VERSION = '3.985003'; | ||
| 44 | |||
| 45 | %MIBS = ( 'RAPID-CITY' => 'rapidCity' ); | ||
| 46 | |||
| 47 | %GLOBALS = ( | ||
| 48 | 'rc_virt_ip' => 'rcSysVirtualIpAddr', | ||
| 49 | 'rc_virt_mask' => 'rcSysVirtualNetMask', | ||
| 50 | |||
| 51 | # From RAPID-CITY::rcMlt (IST) | ||
| 52 | 'rc_ist_status' => 'rcMltIstSessionStatus', | ||
| 53 | 'rc_ist_peer' => 'rcMltIstPeerIp', | ||
| 54 | 'rc_ist_vlan' => 'rcMltIstVlanId', | ||
| 55 | ); | ||
| 56 | |||
| 57 | %FUNCS = ( | ||
| 58 | |||
| 59 | # From RAPID-CITY::rc2kCpuEthernetPortTable | ||
| 60 | 'rc_cpu_ifindex' => 'rc2kCpuEthernetPortIfIndex', | ||
| 61 | 'rc_cpu_admin' => 'rc2kCpuEthernetPortAdminStatus', | ||
| 62 | 'rc_cpu_oper' => 'rc2kCpuEthernetPortOperStatus', | ||
| 63 | 'rc_cpu_ip' => 'rc2kCpuEthernetPortAddr', | ||
| 64 | 'rc_cpu_mask' => 'rc2kCpuEthernetPortMask', | ||
| 65 | 'rc_cpu_auto' => 'rc2kCpuEthernetPortAutoNegotiate', | ||
| 66 | 'rc_cpu_duplex_admin' => 'rc2kCpuEthernetPortAdminDuplex', | ||
| 67 | 'rc_cpu_duplex' => 'rc2kCpuEthernetPortOperDuplex', | ||
| 68 | 'rc_cpu_speed_admin' => 'rc2kCpuEthernetPortAdminSpeed', | ||
| 69 | 'rc_cpu_speed_oper' => 'rc2kCpuEthernetPortOperSpeed', | ||
| 70 | 'rc_cpu_mac' => 'rc2kCpuEthernetPortMgmtMacAddr', | ||
| 71 | |||
| 72 | # From RAPID-CITY::rcVlanPortTable | ||
| 73 | 'rc_i_vlan' => 'rcVlanPortVlanIds', | ||
| 74 | |||
| 75 | # From RAPID-CITY::rcCardTable | ||
| 76 | 'rc_c_type' => 'rcCardType', | ||
| 77 | 'rc_c_serial' => 'rcCardSerialNumber', | ||
| 78 | 'rc_c_rev' => 'rcCardHardwareRevision', | ||
| 79 | 'rc_c_part' => 'rcCardPartNumber', | ||
| 80 | |||
| 81 | # From RAPID-CITY::rc2kCardTable | ||
| 82 | 'rc2k_c_btype' => 'rc2kCardBackType', | ||
| 83 | 'rc2k_c_bdesc' => 'rc2kCardBackDescription', | ||
| 84 | 'rc2k_c_bserial' => 'rc2kCardBackSerialNum', | ||
| 85 | 'rc2k_c_brev' => 'rc2kCardBackHwVersion', | ||
| 86 | 'rc2k_c_bpart' => 'rc2kCardBackPartNumber', | ||
| 87 | 'rc2k_c_bdate' => 'rc2kCardBackDateCode', | ||
| 88 | 'rc2k_c_bdev' => 'rc2kCardBackDeviations', | ||
| 89 | |||
| 90 | # From RAPID-CITY::rc2kMdaCardTable | ||
| 91 | 'rc2k_mda_type' => 'rc2kMdaCardType', | ||
| 92 | 'rc2k_mda_desc' => 'rc2kMdaCardDescription', | ||
| 93 | 'rc2k_mda_serial' => 'rc2kMdaCardSerialNum', | ||
| 94 | 'rc2k_mda_rev' => 'rc2kMdaCardHwVersion', | ||
| 95 | 'rc2k_mda_part' => 'rc2kMdaCardPartNumber', | ||
| 96 | 'rc2k_mda_date' => 'rc2kMdaCardDateCode', | ||
| 97 | 'rc2k_mda_dev' => 'rc2kMdaCardDeviations', | ||
| 98 | |||
| 99 | # From RAPID-CITY::rcBridgeSpbmMacTable | ||
| 100 | 'rc_spbm_fw_port' => 'rcBridgeSpbmMacCPort', | ||
| 101 | 'rc_spbm_fw_status' => 'rcBridgeSpbmMacStatus', | ||
| 102 | 'rc_spbm_fw_vlan' => 'rcBridgeSpbmMacCVlanId', | ||
| 103 | ); | ||
| 104 | |||
| 105 | %MUNGE = ( 'rc_cpu_mac' => \&SNMP::Info::munge_mac ); | ||
| 106 | |||
| 107 | # The core reads rcPortTable only; these add the CPU Ethernet rows of the | ||
| 108 | # 8600 Series. The mixin's @ISA stops at SNMP::Info, so SUPER:: would not | ||
| 109 | # reach the core. | ||
| 110 | sub i_duplex { | ||
| 111 | my $rapidcity = shift; | ||
| 112 | my $partial = shift; | ||
| 113 | |||
| 114 | my $i_duplex = SNMP::Info::RapidCity::i_duplex( $rapidcity, $partial ); | ||
| 115 | my $rc_cpu_duplex = $rapidcity->rc_cpu_duplex($partial) || {}; | ||
| 116 | |||
| 117 | # Get CPU Ethernet Interfaces for 8600 Series | ||
| 118 | foreach my $iid ( keys %$rc_cpu_duplex ) { | ||
| 119 | my $c_duplex = $rc_cpu_duplex->{$iid}; | ||
| 120 | next unless defined $c_duplex; | ||
| 121 | |||
| 122 | $i_duplex->{$iid} = $c_duplex; | ||
| 123 | } | ||
| 124 | |||
| 125 | return $i_duplex; | ||
| 126 | } | ||
| 127 | |||
| 128 | sub i_duplex_admin { | ||
| 129 | my $rapidcity = shift; | ||
| 130 | my $partial = shift; | ||
| 131 | |||
| 132 | my $i_duplex_admin | ||
| 133 | = SNMP::Info::RapidCity::i_duplex_admin( $rapidcity, $partial ); | ||
| 134 | my $rc_cpu_auto = $rapidcity->rc_cpu_auto($partial) || {}; | ||
| 135 | my $rc_cpu_duplex_admin = $rapidcity->rc_cpu_duplex_admin($partial) || {}; | ||
| 136 | |||
| 137 | # Get CPU Ethernet Interfaces for 8600 Series | ||
| 138 | foreach my $iid ( keys %$rc_cpu_duplex_admin ) { | ||
| 139 | my $c_duplex = $rc_cpu_duplex_admin->{$iid}; | ||
| 140 | next unless defined $c_duplex; | ||
| 141 | my $c_auto = $rc_cpu_auto->{$iid}; | ||
| 142 | |||
| 143 | my $string = 'other'; | ||
| 144 | $string = 'half' if ( $c_duplex =~ /half/i and $c_auto =~ /false/i ); | ||
| 145 | $string = 'full' if ( $c_duplex =~ /full/i and $c_auto =~ /false/i ); | ||
| 146 | $string = 'auto' if $c_auto =~ /true/i; | ||
| 147 | |||
| 148 | $i_duplex_admin->{$iid} = $string; | ||
| 149 | } | ||
| 150 | |||
| 151 | return $i_duplex_admin; | ||
| 152 | } | ||
| 153 | |||
| 154 | # Adds the IST of the 8600 and ERS families to the core's virtual IST | ||
| 155 | sub _rc_peer_link_flavors { | ||
| 156 | return ( | ||
| 157 | vist => [ 'rc_vist', 'rcVirtualIst' ], | ||
| 158 | ist => [ 'rc_ist', 'rcMltIst' ], | ||
| 159 | ); | ||
| 160 | } | ||
| 161 | |||
| 162 | # break up the rcBridgeSpbmMacEntry INDEX into ISID and MAC Address. | ||
| 163 | sub _spbm_fdbtable_index { | ||
| 164 | my $idx = shift; | ||
| 165 | my @values = split( /\./, $idx ); | ||
| 166 | my $isid = shift(@values); | ||
| 167 | return ( $isid, join( ':', map { sprintf "%02x", $_ } @values ) ); | ||
| 168 | } | ||
| 169 | |||
| 170 | sub rc_spbm_fw_mac { | ||
| 171 | my $rapidcity = shift; | ||
| 172 | my $partial = shift; | ||
| 173 | |||
| 174 | my $spbm_fw_ports = $rapidcity->rc_spbm_fw_port($partial); | ||
| 175 | my $spbm_fw_mac = {}; | ||
| 176 | foreach my $idx ( keys %$spbm_fw_ports ) { | ||
| 177 | my ( $isid, $mac ) = _spbm_fdbtable_index($idx); | ||
| 178 | $spbm_fw_mac->{$idx} = $mac; | ||
| 179 | } | ||
| 180 | return $spbm_fw_mac; | ||
| 181 | } | ||
| 182 | |||
| 183 | sub rc_spbm_fw_isid { | ||
| 184 | my $rapidcity = shift; | ||
| 185 | my $partial = shift; | ||
| 186 | |||
| 187 | my $spbm_fw_ports = $rapidcity->rc_spbm_fw_port($partial); | ||
| 188 | my $spbm_fw_isid = {}; | ||
| 189 | foreach my $idx ( keys %$spbm_fw_ports ) { | ||
| 190 | my ( $isid, $mac ) = _spbm_fdbtable_index($idx); | ||
| 191 | $spbm_fw_isid->{$idx} = $isid; | ||
| 192 | } | ||
| 193 | return $spbm_fw_isid; | ||
| 194 | } | ||
| 195 | |||
| 196 | 1; | ||
| 197 | |||
| 198 | __END__ |