| 1 | # SNMP::Info::Layer2::Orinoco | ||
| 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::Orinoco; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | use SNMP::Info::IEEE802dot11; | ||
| 36 | use SNMP::Info::Layer2; | ||
| 37 | |||
| 38 | @SNMP::Info::Layer2::Orinoco::ISA | ||
| 39 | = qw/SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/; | ||
| 40 | @SNMP::Info::Layer2::Orinoco::EXPORT_OK = qw//; | ||
| 41 | |||
| 42 | our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE); | ||
| 43 | |||
| 44 | $VERSION = '3.985003'; | ||
| 45 | |||
| 46 | %MIBS = ( | ||
| 47 | %SNMP::Info::Layer2::MIBS, | ||
| 48 | %SNMP::Info::IEEE802dot11::MIBS, | ||
| 49 | ); | ||
| 50 | |||
| 51 | %GLOBALS | ||
| 52 | = ( %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::IEEE802dot11::GLOBALS, ); | ||
| 53 | |||
| 54 | %FUNCS = ( | ||
| 55 | %SNMP::Info::Layer2::FUNCS, | ||
| 56 | %SNMP::Info::IEEE802dot11::FUNCS, | ||
| 57 | ); | ||
| 58 | |||
| 59 | %MUNGE = ( %SNMP::Info::Layer2::MUNGE, %SNMP::Info::IEEE802dot11::MUNGE, ); | ||
| 60 | |||
| 61 | sub os { | ||
| 62 | return 'orinoco'; | ||
| 63 | } | ||
| 64 | |||
| 65 | sub os_ver { | ||
| 66 | my $orinoco = shift; | ||
| 67 | |||
| 68 | my $descr = $orinoco->description(); | ||
| 69 | return unless defined $descr; | ||
| 70 | |||
| 71 | if ( $descr =~ m/V(\d+\.\d+)/ ) { | ||
| 72 | return $1; | ||
| 73 | } | ||
| 74 | if ( $descr =~ m/v(\d+\.\d+\.\d+)/ ) { | ||
| 75 | return $1; | ||
| 76 | } | ||
| 77 | |||
| 78 | return; | ||
| 79 | } | ||
| 80 | |||
| 81 | sub os_bin { | ||
| 82 | my $orinoco = shift; | ||
| 83 | |||
| 84 | my $descr = $orinoco->description(); | ||
| 85 | return unless defined $descr; | ||
| 86 | |||
| 87 | if ( $descr =~ m/V(\d+\.\d+)$/ ) { | ||
| 88 | return $1; | ||
| 89 | } | ||
| 90 | if ( $descr =~ m/v(\d+\.\d+\.\d+)$/ ) { | ||
| 91 | return $1; | ||
| 92 | } | ||
| 93 | |||
| 94 | return; | ||
| 95 | } | ||
| 96 | |||
| 97 | sub vendor { | ||
| 98 | return 'proxim'; | ||
| 99 | } | ||
| 100 | |||
| 101 | sub model { | ||
| 102 | my $orinoco = shift; | ||
| 103 | |||
| 104 | my $descr = $orinoco->description(); | ||
| 105 | return unless defined $descr; | ||
| 106 | |||
| 107 | return $1 if ( $descr =~ /(AP-\d+)/ ); | ||
| 108 | return 'WavePOINT-II' if ( $descr =~ /WavePOINT-II/ ); | ||
| 109 | return 'Outdoor Router' if ( $descr =~ /Wireless Router/ ); | ||
| 110 | |||
| 111 | return; | ||
| 112 | } | ||
| 113 | |||
| 114 | sub serial { | ||
| 115 | my $orinoco = shift; | ||
| 116 | |||
| 117 | my $descr = $orinoco->description(); | ||
| 118 | return unless defined $descr; | ||
| 119 | |||
| 120 | $descr = $1 if $descr =~ /SN-(\S+)/; | ||
| 121 | return $descr; | ||
| 122 | } | ||
| 123 | |||
| 124 | sub i_ignore { | ||
| 125 | my $orinoco = shift; | ||
| 126 | my $partial = shift; | ||
| 127 | |||
| 128 | my $descr = $orinoco->i_description($partial) || {}; | ||
| 129 | |||
| 130 | my %i_ignore; | ||
| 131 | foreach my $if ( keys %$descr ) { | ||
| 132 | my $type = $descr->{$if}; | ||
| 133 | |||
| 134 | # Skip virtual interfaces | ||
| 135 | $i_ignore{$if}++ if $type =~ /(lo|empty|PCMCIA)/i; | ||
| 136 | } | ||
| 137 | return \%i_ignore; | ||
| 138 | } | ||
| 139 | |||
| 140 | sub interfaces { | ||
| 141 | my $orinoco = shift; | ||
| 142 | my $partial = shift; | ||
| 143 | |||
| 144 | my $interfaces = $orinoco->i_index($partial) || {}; | ||
| 145 | my $descriptions = $orinoco->i_description($partial) || {}; | ||
| 146 | |||
| 147 | my %interfaces = (); | ||
| 148 | foreach my $iid ( keys %$interfaces ) { | ||
| 149 | my $desc = $descriptions->{$iid}; | ||
| 150 | next unless defined $desc; | ||
| 151 | next if $desc =~ /(lo|empty|PCMCIA)/i; | ||
| 152 | |||
| 153 | $desc = 'AMD' if $desc =~ /AMD/; | ||
| 154 | |||
| 155 | $interfaces{$iid} = $desc; | ||
| 156 | } | ||
| 157 | return \%interfaces; | ||
| 158 | } | ||
| 159 | |||
| 160 | 1; | ||
| 161 | __END__ |