| 1 | # SNMP::Info::Layer2::ZyXEL_DSLAM | ||
| 2 | # | ||
| 3 | # Copyright (c) 2008 Max Baker | ||
| 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::ZyXEL_DSLAM; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | use SNMP::Info::Layer2; | ||
| 36 | |||
| 37 | @SNMP::Info::Layer2::ZyXEL_DSLAM::ISA = qw/SNMP::Info::Layer2 Exporter/; | ||
| 38 | @SNMP::Info::Layer2::ZyXEL_DSLAM::EXPORT_OK = qw//; | ||
| 39 | |||
| 40 | our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE); | ||
| 41 | |||
| 42 | $VERSION = '3.985003'; | ||
| 43 | |||
| 44 | # Set for No CDP | ||
| 45 | %GLOBALS = ( %SNMP::Info::Layer2::GLOBALS ); | ||
| 46 | |||
| 47 | %FUNCS = ( | ||
| 48 | %SNMP::Info::Layer2::FUNCS, | ||
| 49 | 'ip_addresses' => 'ipAdEntAddr', | ||
| 50 | 'i_name' => 'ifDescr', | ||
| 51 | 'i_description' => 'adslLineConfProfile', | ||
| 52 | ); | ||
| 53 | |||
| 54 | %MIBS | ||
| 55 | = ( %SNMP::Info::Layer2::MIBS, 'ADSL-LINE-MIB' => 'adslLineConfProfile' ); | ||
| 56 | |||
| 57 | %MUNGE = ( %SNMP::Info::Layer2::MUNGE ); | ||
| 58 | |||
| 59 | sub layers { | ||
| 60 | my $zyxel = shift; | ||
| 61 | my $layers = $zyxel->SUPER::layers(); | ||
| 62 | return $layers if defined $layers; | ||
| 63 | |||
| 64 | # If these don't claim to have any layers, so we'll give them 1+2 | ||
| 65 | return '00000011'; | ||
| 66 | } | ||
| 67 | |||
| 68 | sub vendor { | ||
| 69 | return 'zyxel'; | ||
| 70 | } | ||
| 71 | |||
| 72 | sub os { | ||
| 73 | return 'zyxel'; | ||
| 74 | } | ||
| 75 | |||
| 76 | sub os_ver { | ||
| 77 | my $zyxel = shift; | ||
| 78 | my $descr = $zyxel->description(); | ||
| 79 | |||
| 80 | if ( defined ($descr) && $descr =~ m/version (\S+) / ) { | ||
| 81 | return $1; | ||
| 82 | } | ||
| 83 | return; | ||
| 84 | } | ||
| 85 | |||
| 86 | sub model { | ||
| 87 | my $zyxel = shift; | ||
| 88 | |||
| 89 | my $desc = $zyxel->description(); | ||
| 90 | |||
| 91 | if (defined $desc) { | ||
| 92 | if ($desc =~ /8-port ADSL Module\(Annex A\)/) { | ||
| 93 | return "AAM1008-61"; | ||
| 94 | } | ||
| 95 | elsif ($desc =~ /8-port ADSL Module\(Annex B\)/) { | ||
| 96 | return "AAM1008-63"; | ||
| 97 | } | ||
| 98 | } | ||
| 99 | return; | ||
| 100 | } | ||
| 101 | |||
| 102 | sub ip { | ||
| 103 | my $zyxel = shift; | ||
| 104 | my $ip_hash = $zyxel->ip_addresses(); | ||
| 105 | my $found_ip; | ||
| 106 | |||
| 107 | # Since hashes are random add sort so we get the same address each time | ||
| 108 | # if there happens to be more than one. Will return highest numbered address | ||
| 109 | foreach my $ip ( sort keys %{$ip_hash} ) { | ||
| 110 | $found_ip = $ip | ||
| 111 | if ( defined $ip | ||
| 112 | and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ ); | ||
| 113 | } | ||
| 114 | return $found_ip; | ||
| 115 | } | ||
| 116 | 1; | ||
| 117 | __END__ |