From 719f14984b5d614b7ee52493bf07d6ced99adad4 Mon Sep 17 00:00:00 2001 From: Max Kosmach Date: Mon, 28 Jul 2014 15:47:01 +0400 Subject: [PATCH] Add Ubiquiti UniFi AP support --- Info.pm | 1 + Info/Layer2/Ubiquiti.pm | 181 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 Info/Layer2/Ubiquiti.pm diff --git a/Info.pm b/Info.pm index a7deebf8..464d4f83 100644 --- a/Info.pm +++ b/Info.pm @@ -1495,6 +1495,7 @@ sub device_type { 6527 => 'SNMP::Info::Layer3::Timetra', 8072 => 'SNMP::Info::Layer3::NetSNMP', 9303 => 'SNMP::Info::Layer3::PacketFront', + 10002 => 'SNMP::Info::Layer2::Ubiquiti', 12325 => 'SNMP::Info::Layer3::Pf', 14179 => 'SNMP::Info::Layer2::Airespace', 14525 => 'SNMP::Info::Layer2::Trapeze', diff --git a/Info/Layer2/Ubiquiti.pm b/Info/Layer2/Ubiquiti.pm new file mode 100644 index 00000000..de4e1edc --- /dev/null +++ b/Info/Layer2/Ubiquiti.pm @@ -0,0 +1,181 @@ +# SNMP::Info::Layer2::Ubiquiti +# $Id$ +# + +package SNMP::Info::Layer2::Ubiquiti; + +use strict; +use Exporter; +use SNMP::Info::IEEE802dot11; +use SNMP::Info::Layer2; + +@SNMP::Info::Layer2::Ubiquiti::ISA + = qw/SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer2::Ubiquiti::EXPORT_OK = qw//; + +use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; + +$VERSION = '3.18'; + +%MIBS = ( + %SNMP::Info::Layer2::MIBS, + %SNMP::Info::IEEE802dot11::MIBS, + +); + +%GLOBALS + = ( %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::IEEE802dot11::GLOBALS, ); + +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, + %SNMP::Info::IEEE802dot11::FUNCS, + +); + +%MUNGE = ( %SNMP::Info::Layer2::MUNGE, %SNMP::Info::IEEE802dot11::MUNGE, ); + +sub os { + return 'Ubiquiti'; +} + +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; + return $ver; + if ( $ver =~ /([\d\.]+)/ ) { + return $1; + } + } + + return; +} + +sub vendor { + return 'Ubiquiti Networks, Inc.'; +} + +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 $prod; + } + return; +} + + +1; +__END__ + +=head1 NAME + +SNMP::Info::Layer2::Ubiquiti - SNMP Interface to Ubiquiti Access Points + +=head1 AUTHOR + +Max Kosmach + +=head1 SYNOPSIS + + # Let SNMP::Info determine the correct subclass for you. + my $ubnt = new SNMP::Info( + AutoSpecify => 1, + Debug => 1, + DestHost => 'myswitch', + Community => 'public', + Version => 2 + ) + or die "Can't connect to DestHost.\n"; + + my $class = $ubnt->class(); + print "SNMP::Info determined this device to fall under subclass : $class\n"; + +=head1 DESCRIPTION + +Provides abstraction to the configuration information obtainable from +Ubiquiti Access Point through SNMP. + +For speed or debugging purposes you can call the subclass directly, but not +after determining a more specific class using the method above. + + my $ubnt = new SNMP::Info::Layer2::Ubiquiti(...); + +=head2 Inherited Classes + +=over + +=item SNMP::Info::Layer2 + +=item SNMP::Info::IEEE802dot11 + +=back + +=head2 Required MIBs + +=over + +None. + +=back + +=head2 Inherited MIBs + +See L for its MIB requirements. + +See L for its MIB requirements. + +=head1 GLOBALS + +These are methods that return scalar value from SNMP + +=over + +=item $ubnt->vendor() + +Returns 'Ubiquiti Networks, Inc.' + +=item $ubnt->model() + +Returns the model extracted from C. + +=item $ubnt->os() + +Returns 'Ubiquiti' + +=item $ubnt->os_ver() + +Returns the software version extracted from C. + +=back + +=head2 Global Methods imported from SNMP::Info::Layer2 + +See L for details. + +=head2 Global Methods imported from SNMP::Info::IEEE802dot11 + +See L for details. + +=head1 TABLE METHODS + +These are methods that return tables of information in the form of a reference +to a hash. + +=head2 Table Methods imported from SNMP::Info::Layer2 + +See L for details. + +=head2 Table Methods imported from SNMP::Info::IEEE802dot11 + +See L for details. + +=cut