| 1 | # SNMP::Info::Layer1::Asante | ||
| 2 | # | ||
| 3 | # Copyright (c) 2008 Max Baker changes from version 0.8 and beyond. | ||
| 4 | # | ||
| 5 | # Copyright (c) 2002,2003 Regents of the University of California | ||
| 6 | # All rights reserved. | ||
| 7 | # | ||
| 8 | # Redistribution and use in source and binary forms, with or without | ||
| 9 | # modification, are permitted provided that the following conditions are met: | ||
| 10 | # | ||
| 11 | # * Redistributions of source code must retain the above copyright notice, | ||
| 12 | # this list of conditions and the following disclaimer. | ||
| 13 | # * Redistributions in binary form must reproduce the above copyright | ||
| 14 | # notice, this list of conditions and the following disclaimer in the | ||
| 15 | # documentation and/or other materials provided with the distribution. | ||
| 16 | # * Neither the name of the University of California, Santa Cruz nor the | ||
| 17 | # names of its contributors may be used to endorse or promote products | ||
| 18 | # derived from this software without specific prior written permission. | ||
| 19 | # | ||
| 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
| 24 | # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 30 | # POSSIBILITY OF SUCH DAMAGE. | ||
| 31 | |||
| 32 | package SNMP::Info::Layer1::Asante; | ||
| 33 | |||
| 34 | use strict; | ||
| 35 | use warnings; | ||
| 36 | use Exporter; | ||
| 37 | use SNMP::Info::Layer1; | ||
| 38 | |||
| 39 | @SNMP::Info::Layer1::Asante::ISA = qw/SNMP::Info::Layer1 Exporter/; | ||
| 40 | @SNMP::Info::Layer1::Asante::EXPORT_OK = qw//; | ||
| 41 | |||
| 42 | our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE); | ||
| 43 | |||
| 44 | $VERSION = '3.985003'; | ||
| 45 | |||
| 46 | # Set for No CDP | ||
| 47 | %GLOBALS = ( %SNMP::Info::Layer1::GLOBALS, ); | ||
| 48 | |||
| 49 | %FUNCS = ( | ||
| 50 | %SNMP::Info::Layer1::FUNCS, | ||
| 51 | 'asante_port' => 'ePortIndex', | ||
| 52 | 'asante_group' => 'ePortGrpIndex', | ||
| 53 | 'i_type' => 'ePortGrpIndex', | ||
| 54 | 'asante_up' => 'ePortStateLinkStatus', | ||
| 55 | ); | ||
| 56 | |||
| 57 | %MIBS = ( %SNMP::Info::Layer1::MIBS, 'ASANTE-AH1012-MIB' => 'asante' ); | ||
| 58 | |||
| 59 | %MUNGE = ( %SNMP::Info::Layer1::MUNGE, ); | ||
| 60 | |||
| 61 | sub interfaces { | ||
| 62 | my $asante = shift; | ||
| 63 | my $partial = shift; | ||
| 64 | |||
| 65 | my $rptr_port = $asante->rptr_port($partial) || {}; | ||
| 66 | |||
| 67 | my %interfaces; | ||
| 68 | |||
| 69 | foreach my $port ( keys %$rptr_port ) { | ||
| 70 | $interfaces{$port} = $port; | ||
| 71 | } | ||
| 72 | |||
| 73 | return \%interfaces; | ||
| 74 | } | ||
| 75 | |||
| 76 | sub os { | ||
| 77 | return 'asante'; | ||
| 78 | } | ||
| 79 | |||
| 80 | sub os_ver { | ||
| 81 | my $asante = shift; | ||
| 82 | my $descr = $asante->description(); | ||
| 83 | |||
| 84 | if ( defined ($descr) && $descr =~ /software v(\d+\.\d+)/ ) { | ||
| 85 | return $1; | ||
| 86 | } | ||
| 87 | return; | ||
| 88 | } | ||
| 89 | |||
| 90 | sub vendor { | ||
| 91 | return 'asante'; | ||
| 92 | } | ||
| 93 | |||
| 94 | sub model { | ||
| 95 | my $asante = shift; | ||
| 96 | |||
| 97 | my $id = $asante->id(); | ||
| 98 | my $model = SNMP::translateObj($id); | ||
| 99 | |||
| 100 | return $model; | ||
| 101 | } | ||
| 102 | |||
| 103 | sub i_up { | ||
| 104 | my $asante = shift; | ||
| 105 | my $partial = shift; | ||
| 106 | |||
| 107 | my $asante_up = $asante->asante_up($partial) || {}; | ||
| 108 | |||
| 109 | my $i_up = {}; | ||
| 110 | foreach my $port ( keys %$asante_up ) { | ||
| 111 | my $up = $asante_up->{$port}; | ||
| 112 | $i_up->{$port} = 'down' if $up =~ /off/; | ||
| 113 | $i_up->{$port} = 'up' if $up =~ /on/; | ||
| 114 | } | ||
| 115 | |||
| 116 | return $i_up; | ||
| 117 | } | ||
| 118 | |||
| 119 | sub i_speed { | ||
| 120 | my $asante = shift; | ||
| 121 | my $partial = shift; | ||
| 122 | |||
| 123 | my $i_speed = $asante->orig_i_speed($partial) || {}; | ||
| 124 | |||
| 125 | my %i_speed; | ||
| 126 | |||
| 127 | $i_speed{"1.2"} = $i_speed->{1}; | ||
| 128 | |||
| 129 | return \%i_speed; | ||
| 130 | } | ||
| 131 | |||
| 132 | sub i_mac { | ||
| 133 | my $asante = shift; | ||
| 134 | my $partial = shift; | ||
| 135 | |||
| 136 | my $i_mac = $asante->orig_i_mac($partial) || {}; | ||
| 137 | |||
| 138 | my %i_mac; | ||
| 139 | |||
| 140 | $i_mac{"1.2"} = $i_mac->{1}; | ||
| 141 | |||
| 142 | return \%i_mac; | ||
| 143 | } | ||
| 144 | |||
| 145 | sub i_description { | ||
| 146 | return; | ||
| 147 | } | ||
| 148 | |||
| 149 | sub i_name { | ||
| 150 | my $asante = shift; | ||
| 151 | my $partial = shift; | ||
| 152 | |||
| 153 | my $i_name = $asante->orig_i_description($partial) || {}; | ||
| 154 | |||
| 155 | my %i_name; | ||
| 156 | |||
| 157 | $i_name{"1.2"} = $i_name->{1}; | ||
| 158 | |||
| 159 | return \%i_name; | ||
| 160 | } | ||
| 161 | |||
| 162 | 1; | ||
| 163 | |||
| 164 | __END__ |