Info/Layer3/Aironet.pm untested

filter: Statementstmt 0.0% 0 / 81 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 122 CC 9 SCAR 18.5
CC
9
Cov
0%
os_ver
12.0
fw_mac
12.0
bp_index
6.0
CRAP 6.4
1 # SNMP::Info::Layer3::Aironet
2 #
3 # Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
4 #
5 # Copyright (c) 2002,2003 Regents of the University of California
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 #
11 # * Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # * Neither the name of the University of California, Santa Cruz nor the
17 # names of its contributors may be used to endorse or promote products
18 # derived from this software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 # POSSIBILITY OF SUCH DAMAGE.
31  
32 package SNMP::Info::Layer3::Aironet;
33  
34 use strict;
35 use warnings;
36 use Exporter;
37 use SNMP::Info::Layer3;
38  
39 @SNMP::Info::Layer3::Aironet::ISA = qw/SNMP::Info::Layer3 Exporter/;
40 @SNMP::Info::Layer3::Aironet::EXPORT_OK = qw//;
41  
42 our ($VERSION, %MIBS, %FUNCS, %GLOBALS, %MUNGE);
43  
44 $VERSION = '3.985003';
45  
46 %MIBS = (
47 %SNMP::Info::Layer3::MIBS,
48 'AWCVX-MIB' => 'awcIfTable',
49 'IEEE802dot11-MIB' => 'dot11StationID',
50 );
51  
52 %GLOBALS = (
53 %SNMP::Info::Layer3::GLOBALS,
54 'mac' => 'dot11StationID.2',
55  
56 # AWC Ethernet Table
57 'awc_duplex' => 'awcEtherDuplex.0',
58 );
59  
60 %FUNCS = (
61 %SNMP::Info::Layer3::FUNCS,
62 'i_mac2' => 'ifPhysAddress',
63 'i_mtu2' => 'ifMtu',
64 'i_ssid' => 'dot11DesiredSSID',
65  
66 # Bridge-mib overrides
67 'fw_mac2' => 'dot1dTpFdbAddress',
68 'fw_port2' => 'dot1dTpFdbPort',
69 'bp_index2' => 'dot1dBasePortIfIndex',
70  
71 # AWC Interface Table (awcIfTable)
72 'awc_default_mac' => 'awcIfDefaultPhysAddress',
73 'awc_mac' => 'awcIfPhysAddress',
74 'awc_ip' => 'awcIfIpAddress',
75 'awc_netmask' => 'awcIfIpNetMask',
76 'awc_msdu' => 'awcIfMSDUMaxLength',
77 );
78  
79 %MUNGE = (
80  
81 # Inherit all the built in munging
82 %SNMP::Info::Layer3::MUNGE,
83 'i_mac2' => \&SNMP::Info::munge_mac,
84 'awc_mac' => \&SNMP::Info::munge_mac,
85 'fw_mac2' => \&SNMP::Info::munge_mac,
86 );
87  
88 sub os {
89 return 'aironet';
90 }
91  
92 sub os_ver {
93 my $aironet = shift;
94 my $descr = $aironet->description() || '';
95  
96 # CAP340 11.21, AP4800-E 11.21
97 if ( $descr =~ /AP\d{3,4}(-\D+)?\s+(\d{2}\.\d{2})/ ) {
98 return $2;
99 }
100  
101 if ( $descr =~ /Series\s*AP\s+(\d{2}\.\d{2})/ ) {
102 return $1;
103 }
104  
105 return;
106 }
107  
108 # Override wireless port with static info
109 sub bp_index {
110 my $aironet = shift;
111 my $interfaces = $aironet->interfaces();
112 my $bp_index = $aironet->bp_index2();
113  
114 foreach my $iid ( keys %$interfaces ) {
115 my $port = $interfaces->{$iid};
116  
117 # Hardwire the wireless port to the transparent bridge port
118 if ( $port =~ /awc/ ) {
119 $bp_index->{0} = $iid;
120 }
121 }
122  
123 return $bp_index;
124 }
125  
126 # Add the static table to the forwarding table
127 sub fw_mac {
128 my $aironet = shift;
129 my $fw_mac = $aironet->fw_mac2();
130 my $fw_port = $aironet->fw_port2();
131 my $bs_mac = $aironet->bs_mac();
132  
133 # remove port 0 forwarding table entries, only port 0 static entries
134 foreach my $fw ( keys %$fw_mac ) {
135 my $port = $fw_port->{$fw};
136 next unless defined $port;
137 delete $fw_mac->{$fw} if $port == 0;
138 }
139  
140 foreach my $bs ( keys %$bs_mac ) {
141 my $entry = $bs;
142 $entry =~ s/\.0$//;
143 $fw_mac->{$entry} = $bs_mac->{$bs};
144 }
145  
146 return $fw_mac;
147 }
148  
149 # Add the static table to the forwarding table
150 sub fw_port {
151 my $aironet = shift;
152 my $fw_port = $aironet->fw_port2();
153 my $bs_port = $aironet->bs_port();
154  
155 foreach my $bs ( keys %$bs_port ) {
156 my $entry = $bs;
157 $entry =~ s/\.0$//;
158 $fw_port->{$entry} = $bs_port->{$bs};
159 }
160  
161 return $fw_port;
162 }
163  
164 sub i_duplex {
165 my $aironet = shift;
166 my $interfaces = $aironet->interfaces();
167 my $awc_duplex = $aironet->awc_duplex();
168  
169 my %i_duplex;
170  
171 foreach my $iid ( keys %$interfaces ) {
172 my $name = $interfaces->{$iid};
173  
174 if ( $name =~ /fec/ ) {
175 $i_duplex{$iid} = $awc_duplex;
176 }
177 }
178  
179 return \%i_duplex;
180 }
181  
182 sub i_mac {
183 my $aironet = shift;
184  
185 my $i_mac = $aironet->i_mac2();
186 my $awc_mac = $aironet->awc_mac();
187  
188 foreach my $iid ( keys %$awc_mac ) {
189 next unless defined $i_mac->{$iid};
190 $i_mac->{$iid} = $awc_mac->{$iid};
191 }
192  
193 return $i_mac;
194 }
195  
196 sub i_ignore {
197 my $aironet = shift;
198 my $interfaces = $aironet->interfaces();
199  
200 my %i_ignore;
201 foreach my $if ( keys %$interfaces ) {
202 $i_ignore{$if}++ if ( $interfaces->{$if} =~ /(rptr|lo)/ );
203 }
204  
205 return \%i_ignore;
206 }
207  
208 sub vendor {
209 return 'cisco';
210 }
211  
212 1;
213 __END__