| 1 | # SNMP::Info::Layer3::Contivity | ||
| 2 | # | ||
| 3 | # Copyright (c) 2010 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::Layer3::Contivity; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | use SNMP::Info::Layer3; | ||
| 36 | |||
| 37 | @SNMP::Info::Layer3::Contivity::ISA | ||
| 38 | = qw/SNMP::Info::Layer3 Exporter/; | ||
| 39 | @SNMP::Info::Layer3::Contivity::EXPORT_OK = qw//; | ||
| 40 | |||
| 41 | our ($VERSION, %GLOBALS, %FUNCS, %MIBS, %MUNGE); | ||
| 42 | |||
| 43 | $VERSION = '3.985003'; | ||
| 44 | |||
| 45 | %MIBS = ( | ||
| 46 | %SNMP::Info::Layer3::MIBS, | ||
| 47 | ); | ||
| 48 | |||
| 49 | %GLOBALS = ( | ||
| 50 | %SNMP::Info::Layer3::GLOBALS, | ||
| 51 | ); | ||
| 52 | |||
| 53 | %FUNCS = ( | ||
| 54 | %SNMP::Info::Layer3::FUNCS, | ||
| 55 | ); | ||
| 56 | |||
| 57 | %MUNGE = ( | ||
| 58 | %SNMP::Info::Layer3::MUNGE, | ||
| 59 | ); | ||
| 60 | |||
| 61 | sub layers { | ||
| 62 | return '00000100'; | ||
| 63 | } | ||
| 64 | |||
| 65 | sub vendor { | ||
| 66 | return 'avaya'; | ||
| 67 | } | ||
| 68 | |||
| 69 | sub model { | ||
| 70 | my $contivity = shift; | ||
| 71 | my $e_model = $contivity->e_model() || {}; | ||
| 72 | |||
| 73 | my $model = $e_model->{1} || undef; | ||
| 74 | |||
| 75 | return $1 if ( defined $model and $model =~ /(CES\d+|NVR\d+)/i ); | ||
| 76 | return; | ||
| 77 | } | ||
| 78 | |||
| 79 | sub os { | ||
| 80 | return 'contivity'; | ||
| 81 | } | ||
| 82 | |||
| 83 | sub os_ver { | ||
| 84 | my $contivity = shift; | ||
| 85 | my $descr = $contivity->description(); | ||
| 86 | return unless defined $descr; | ||
| 87 | |||
| 88 | if ( $descr =~ m/V(\d+_\d+\.\d+)/i ) { | ||
| 89 | return $1; | ||
| 90 | } | ||
| 91 | return; | ||
| 92 | } | ||
| 93 | |||
| 94 | sub mac { | ||
| 95 | my $contivity = shift; | ||
| 96 | my $i_mac = $contivity->i_mac(); | ||
| 97 | |||
| 98 | # Return Interface MAC | ||
| 99 | foreach my $entry ( sort keys %$i_mac ) { | ||
| 100 | my $sn = $i_mac->{$entry}; | ||
| 101 | next unless $sn; | ||
| 102 | return $sn; | ||
| 103 | } | ||
| 104 | return; | ||
| 105 | } | ||
| 106 | |||
| 107 | sub serial { | ||
| 108 | my $contivity = shift; | ||
| 109 | my $e_serial = $contivity->e_serial() || {}; | ||
| 110 | |||
| 111 | my $serial = $e_serial->{1} || undef; | ||
| 112 | |||
| 113 | return $1 if ( defined $serial and $serial =~ /(\d+)/ ); | ||
| 114 | return; | ||
| 115 | } | ||
| 116 | |||
| 117 | sub interfaces { | ||
| 118 | my $contivity = shift; | ||
| 119 | my $partial = shift; | ||
| 120 | |||
| 121 | my $description = $contivity->i_description($partial) || {}; | ||
| 122 | |||
| 123 | my %interfaces = (); | ||
| 124 | foreach my $iid ( keys %$description ) { | ||
| 125 | my $desc = $description->{$iid}; | ||
| 126 | |||
| 127 | # Skip everything except Ethernet interfaces | ||
| 128 | next unless ( defined $desc and $desc =~ /fe/i ); | ||
| 129 | |||
| 130 | $interfaces{$iid} = $desc; | ||
| 131 | } | ||
| 132 | return \%interfaces; | ||
| 133 | } | ||
| 134 | |||
| 135 | sub i_name { | ||
| 136 | my $contivity = shift; | ||
| 137 | my $partial = shift; | ||
| 138 | |||
| 139 | my $i_name2 = $contivity->orig_i_name($partial) || {}; | ||
| 140 | |||
| 141 | my %i_name; | ||
| 142 | foreach my $iid ( keys %$i_name2 ) { | ||
| 143 | my $name = $i_name2->{$iid}; | ||
| 144 | |||
| 145 | #Skip everything except Ethernet interfaces | ||
| 146 | next unless ( defined $name and $name =~ /fe/i ); | ||
| 147 | |||
| 148 | $name = $1 if $name =~ /(fei\.\d+\.\d+)/; | ||
| 149 | |||
| 150 | $i_name{$iid} = $name; | ||
| 151 | } | ||
| 152 | return \%i_name; | ||
| 153 | } | ||
| 154 | |||
| 155 | 1; | ||
| 156 | __END__ |