From a1199f6ff0bb5d214c2c4c2d8d0c37b5c5949073 Mon Sep 17 00:00:00 2001 From: Eric Miller <> Date: Fri, 20 Oct 2006 18:27:16 +0000 Subject: [PATCH] Initial commit --- Info/IEEE802dot11.pm | 321 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 Info/IEEE802dot11.pm diff --git a/Info/IEEE802dot11.pm b/Info/IEEE802dot11.pm new file mode 100644 index 00000000..51c2c4d8 --- /dev/null +++ b/Info/IEEE802dot11.pm @@ -0,0 +1,321 @@ +# SNMP::Info::IEEE802dot11 +# Eric Miller +# $Id$ +# +# Copyright (c) 2006 Eric Miller +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package SNMP::Info::IEEE802dot11; +$VERSION = '1.05'; +use strict; + +use Exporter; + +@SNMP::Info::IEEE802dot11::ISA = qw/Exporter/; +@SNMP::Info::IEEE802dot11::EXPORT_OK = qw//; + +use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; + +%MIBS = ( + 'IEEE802dot11-MIB' => 'dot11DesiredSSID', + ); + +%GLOBALS = ( + ); + +%FUNCS = ( + # dot11PhyOFDMTable + 'dot11_cur_freq' => 'dot11CurrentFrequency', + # dot11PhyDSSSTable + 'dot11_cur_ch' => 'dot11CurrentChannel', + # dot11PhyOperationTable + 'dot11_phy_type' => 'dot11PHYType', + 'dot11_reg_dom' => 'dot11CurrentRegDomain', + # dot11ResourceInfoTable + 'dot11_prod_ver' => 'dot11manufacturerProductVersion', + 'dot11_prod_name' => 'dot11manufacturerProductName', + 'dot11_man_name' => 'dot11manufacturerName', + # dot11OperationTable + 'dot11_mac' => 'dot11MACAddress', + # dot11StationConfigTable + 'dot11_bss_type' => 'dot11DesiredBSSType', + 'i_ssidlist' => 'dot11DesiredSSID', + 'dot11_pwr_mode' => 'dot11PowerManagementMode', + 'dot11_sta_id' => 'dot11StationID', + ); + +%MUNGE = ( + 'dot11_mac' => \&SNMP::Info::munge_mac, + 'dot11_sta_id' => \&SNMP::Info::munge_mac, + ); + +sub vendor { + my $dot11 = shift; + + my $names = $dot11->dot11_man_name(); + + foreach my $iid (keys %$names){ + my $vendor = $names->{$iid}; + next unless defined $vendor; + if ( $vendor =~ /^(\S+)/ ) { + return lc($1); + } + } + + return undef; +} + +sub model { + my $dot11 = shift; + + my $names = $dot11->dot11_prod_name(); + + foreach my $iid (keys %$names){ + my $prod = $names->{$iid}; + next unless defined $prod; + return lc($prod); + } + return undef; +} + +sub os_ver { + my $dot11 = shift; + + my $versions = $dot11->dot11_prod_ver(); + + foreach my $iid (keys %$versions){ + my $ver = $versions->{$iid}; + next unless defined $ver; + if ( $ver =~ /([\d\.]+)/ ) { + return $1; + } + } + + return undef; +} + +sub i_80211channel { + my $dot11 = shift; + + my $phy_type = $dot11->dot11_phy_type() || {}; + my $cur_freq = $dot11->dot11_cur_freq() || {}; + my $cur_ch = $dot11->dot11_cur_ch() || {}; + + my %i_80211channel; + foreach my $iid (keys %$phy_type){ + my $type = $phy_type->{$iid}; + next unless defined $type; + if ($type =~ /dsss/) { + my $ch = $cur_ch->{$iid}; + next unless defined $ch; + $i_80211channel{$iid} = $ch; + } + elsif ($type =~ /ofdm/) { + my $ch = $cur_freq->{$iid}; + next unless defined $ch; + $i_80211channel{$iid} = $ch; + } + else { + next; + } + } + + return \%i_80211channel; +} + +1; + +__END__ + +=head1 NAME + +SNMP::Info::IEEE802dot11 - SNMP Interface to data from IEEE802dot11-MIB + +=head1 AUTHOR + +Eric Miller + +=head1 SYNOPSIS + + my $dot11 = new SNMP::Info( + AutoSpecify => 1, + Debug => 1, + DestHost => 'myswitch', + Community => 'public', + Version => 2 + ) + + or die "Can't connect to DestHost.\n"; + + my $class = $dot11->class(); + print " Using device sub class : $class\n"; + +=head1 DESCRIPTION + +SNMP::Info::IEEE802dot11 is a subclass of SNMP::Info that provides an interface +to C. This MIB is used in standards based 802.11 wireless +devices. + +Use or create a subclass of SNMP::Info that inherits this one. +Do not use directly. + +=head2 Inherited Classes + +=over + +None. + +=back + +=head2 Required MIBs + +=over + +=item IEEE802dot11-MIB + +=back + +=head1 GLOBALS + +These are methods that return scalar value from SNMP + +=over + +=item $dot11->vendor() + +Trys to discover the vendor from dot11_man_name() - returns lower case +of the first word in the first instance found. + +=item $dot11->model() + +Trys to discover the model from dot11_prod_name() - returns lower case +of the first instance found. + +=item $dot11->os_ver() + +Trys to discover the operating system version from dot11_prod_ver() - returns +string of numeric and decimals in the first instance found. + +=back + +=head1 TABLE ENTRIES + +These are methods that return tables of information in the form of a reference +to a hash. + +=over + +=item $dot11->i_ssidlist() + +Returns reference to hash. SSID's recognized by the radio interface. + +(B) + +=item $dot11->i_80211channel() + +Returns reference to hash. Current operating frequency channel of the radio +interface. + +=back + +=head2 Dot11 Phy OFDM Table (B) + +=over + +=item $dot11->dot11_cur_freq() + +(B) + +=back + +=head2 Dot11 Phy DSSS Table (B) + +=over + +=item $dot11->dot11_cur_ch() + +(B) + +=back + +=head2 Dot11 Phy Operation Table (B) + +=over + +=item $dot11->dot11_phy_type() + +(B) + +=item $dot11->dot11_reg_dom() + +(B) + +=back + +=head2 Dot11 Resource Information Table (B) + +=over + +=item $dot11->dot11_prod_ver() + +(B) + +=item $dot11->dot11_prod_name() + +(B) + +=item $dot11->dot11_man_name() + +(B) + +=back + +=head2 Dot11 Operation Table (B) + +=over + +=item $dot11->dot11_mac() + +(B) + +=back + +=head2 Dot11 Station Configuration Table (B) + +=over + +=item $dot11->dot11_bss_type() + +(B) + +=item $dot11->dot11_pwr_mode() + +(B) + +=item $dot11->dot11_sta_id() + +(B) + +=cut