Info/Layer2/Trapeze.pm untested

filter: Statementstmt 0.0% 0 / 349 Branchbran 0.0% 0 / 98 Conditioncond 0.0% 0 / 83 MC/DCmcdc 0.0% 0 / 42 Subroutinesub 0.0% 0 / 39 Podpod 0.0% 0 / 35 totaltotal 0.0% 0 / 646 CC 50 SCAR 28.0
CC
50
Cov
0%
i_description
42.0
i_up_admin
42.0
i_ssidlist
42.0
CRAP 16.5
1 # SNMP::Info::Layer2::Trapeze
2 #
3 # Copyright (c) 2012 Eric Miller
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
7 #
8 # * Redistributions of source code must retain the above copyright notice,
9 # this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # * Neither the name of the University of California, Santa Cruz nor the
14 # names of its contributors may be used to endorse or promote products
15 # derived from this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
28  
29 package SNMP::Info::Layer2::Trapeze;
30  
31 use strict;
32 use warnings;
33 use Exporter;
34 use SNMP::Info::Layer2;
35  
36 @SNMP::Info::Layer2::Trapeze::ISA
37 = qw/SNMP::Info::Layer2 Exporter/;
38 @SNMP::Info::Layer2::Trapeze::EXPORT_OK = qw//;
39  
40 our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE);
41  
42 $VERSION = '3.985003';
43  
44 %MIBS = (
45 %SNMP::Info::Layer2::MIBS,
46 'TRAPEZE-NETWORKS-REGISTRATION-DEVICES-MIB' => 'wirelessLANController',
47 'TRAPEZE-NETWORKS-AP-STATUS-MIB' => 'trpzApStatNumAps',
48 'TRAPEZE-NETWORKS-CLIENT-SESSION-MIB' => 'trpzClSessTotalSessions',
49 'TRAPEZE-NETWORKS-SYSTEM-MIB' => 'trpzSysCpuAverageLoad',
50 'TRAPEZE-NETWORKS-BASIC-MIB' => 'trpzVersionString',
51 'TRAPEZE-NETWORKS-AP-CONFIG-MIB' => 'trpzApConfServProfBeaconEnabled',
52 );
53  
54 %GLOBALS = (
55 %SNMP::Info::Layer2::GLOBALS,
56 'os_ver' => 'trpzVersionString',
57 'tr_serial' => 'trpzSerialNumber',
58 'mac' => 'dot1dBaseBridgeAddress',
59 );
60  
61 %FUNCS = (
62 %SNMP::Info::Layer2::FUNCS,
63 # TRAPEZE-NETWORKS-AP-STATUS-MIB::trpzApStatApStatusTable
64 'trapeze_ap_mac' => 'trpzApStatApStatusBaseMac',
65 'trapeze_ap_name' => 'trpzApStatApStatusApName',
66 'trapeze_ap_ip' => 'trpzApStatApStatusIpAddress',
67 #'trapeze_ap_loc' => 'bsnAPLocation',
68 'trapeze_ap_sw' => 'trpzApStatApStatusSoftwareVer',
69 'trapeze_ap_fw' => 'trpzApStatApStatusBootVer',
70 'trapeze_ap_model' => 'trpzApStatApStatusModel',
71 'trapeze_ap_type' => 'trpzApStatApStatusModel',
72 'trapeze_ap_status' => 'trpzApStatApStatusApState',
73 'trapeze_ap_vendor' => 'trpzApStatApStatusManufacturerId',
74 'trapeze_ap_num' => 'trpzApStatApStatusApNum',
75 'trapeze_ap_dapnum' => 'trpzApStatApStatusPortOrDapNum',
76  
77 # TRAPEZE-NETWORKS-AP-STATUS-MIB::trpzApStatRadioStatusTable
78 'trapeze_apif_mac' => 'trpzApStatRadioStatusBaseMac',
79 'trapeze_apif_type' => 'trpzApStatRadioStatusRadioPhyType',
80 'trapeze_apif_ch_num' => 'trpzApStatRadioStatusCurrentChannelNum',
81 'trapeze_apif_power' => 'trpzApStatRadioStatusCurrentPowerLevel',
82 'trapeze_apif_admin' => 'trpzApStatRadioStatusRadioMode',
83  
84 # TRAPEZE-NETWORKS-AP-STATUS-MIB::trpzApStatRadioServiceTable
85 'trapeze_apif_prof' => 'trpzApStatRadioServServiceProfileName',
86  
87 # TRAPEZE-NETWORKS-AP-CONFIG-MIB::trpzApConfServiceProfileTable
88 'trapeze_ess_bcast' => 'trpzApConfServProfBeaconEnabled',
89  
90 # TRAPEZE-NETWORKS-AP-CONFIG-MIB::trpzApConfRadioConfigTable
91 'trapeze_apcr_txpwr' => 'trpzApConfRadioConfigTxPower',
92 'trapeze_apcr_ch' => 'trpzApConfRadioConfigChannel',
93 'trapeze_apcr_mode' => 'trpzApConfRadioConfigRadioMode',
94  
95 # TRAPEZE-NETWORKS-AP-CONFIG-MIB::trpzApConfApConfigTable
96 'trapeze_apc_descr' => 'trpzApConfApConfigDescription',
97 'trapeze_apc_loc' => 'trpzApConfApConfigLocation',
98 'trapeze_apc_name' => 'trpzApConfApConfigApName',
99 'trapeze_apc_model' => 'trpzApConfApConfigApModelName',
100 'trapeze_apc_serial' => 'trpzApConfApConfigApSerialNum',
101  
102 # TRAPEZE-NETWORKS-CLIENT-SESSION-MIB::trpzClSessClientSessionTable
103 'trapeze_sta_slot' => 'trpzClSessClientSessRadioNum',
104 'trapeze_sta_serial' => 'trpzClSessClientSessApSerialNum',
105 'trapeze_sta_ssid' => 'trpzClSessClientSessSsid',
106 'trapeze_sta_ip' => 'trpzClSessClientSessIpAddress',
107  
108 # TRAPEZE-NETWORKS-AP-STATUS-MIB::trpzApStatRadioServiceTable
109 'trapeze_apif_bssid' => 'trpzApStatRadioServBssid',
110  
111 # TRAPEZE-NETWORKS-CLIENT-SESSION-MIB::trpzClSessClientSessionStatisticsTable
112 # Pretend to have the CISCO-DOT11-MIB for signal strengths, etc.
113 'cd11_sigstrength' => 'trpzClSessClientSessStatsLastRssi',
114 'cd11_sigqual' => 'trpzClSessClientSessStatsLastSNR',
115 'cd11_txrate' => 'trpzClSessClientSessStatsLastRate',
116 # These are supposed to be there...
117 'cd11_rxbyte' => 'trpzClSessClientSessStatsUniOctetIn',
118 'cd11_txbyte' => 'trpzClSessClientSessStatsUniOctetOut',
119 'cd11_rxpkt' => 'trpzClSessClientSessStatsUniPktIn',
120 'cd11_txpkt' => 'trpzClSessClientSessStatsUniPktOut',
121 );
122  
123 %MUNGE = (
124 %SNMP::Info::Layer2::MUNGE,
125 'trapeze_apif_mac' => \&SNMP::Info::munge_mac,
126 'trapeze_apif_bssid' => \&SNMP::Info::munge_mac,
127 );
128  
129 sub layers {
130 return '00000111';
131 }
132  
133 sub os {
134 return 'trapeze';
135 }
136  
137 sub vendor {
138 return 'juniper';
139 }
140  
141 sub serial {
142 my $trapeze = shift;
143 my $ser = $trapeze->trpzSerialNumber();
144 # my $ser = $trapeze->tr_serial();
145  
146 return $ser;
147 }
148  
149 sub model {
150 my $trapeze = shift;
151 my $id = $trapeze->id();
152  
153 unless ( defined $id ) {
154 print
155 "SNMP::Info::Layer2::Trapeze::model() - Device does not support sysObjectID\n"
156 if $trapeze->debug();
157 return;
158 }
159  
160 my $model = &SNMP::translateObj($id);
161  
162 return $id unless defined $model;
163  
164 $model =~ s/^wirelessLANController//i;
165 return $model;
166 }
167  
168 sub _ap_serial {
169 my $trapeze = shift;
170 my $partial = shift;
171  
172 my $names = $trapeze->trapeze_ap_name($partial) || {};
173  
174 my %ap_serial;
175 foreach my $iid ( keys %$names ) {
176 next unless $iid;
177  
178 my $serial = join( '', map { sprintf "%c", $_ } split /\./, $iid );
179 # Remove any control characters to include nulls
180 $serial =~ s/[\c@-\c_]//g;
181  
182 $ap_serial{$iid} = "$serial";
183 }
184 return \%ap_serial;
185 }
186  
187 # Wireless switches do not support ifMIB requirements to get MAC
188 # and port status
189  
190 sub i_index {
191 my $trapeze = shift;
192 my $partial = shift;
193  
194 my $i_index = $trapeze->orig_i_index($partial) || {};
195 my $ap_index = $trapeze->trapeze_apif_mac($partial) || {};
196  
197 my %if_index;
198 foreach my $iid ( keys %$i_index ) {
199 my $index = $i_index->{$iid};
200 next unless defined $index;
201  
202 $if_index{$iid} = $index;
203 }
204  
205 # Get Attached APs as Interfaces
206 foreach my $ap_id ( keys %$ap_index ) {
207
208 my $mac = $ap_index->{$ap_id};
209 next unless ($mac);
210  
211 $if_index{$ap_id} = $mac;
212 }
213  
214 return \%if_index;
215 }
216  
217 sub interfaces {
218 my $trapeze = shift;
219 my $partial = shift;
220  
221 my $i_index = $trapeze->i_index($partial) || {};
222 my $descriptions = $trapeze->SUPER::i_description($partial) || {};
223  
224 my %if;
225 foreach my $iid ( keys %$i_index ) {
226 my $desc = $descriptions->{$iid} || $i_index->{$iid};
227 next unless defined $desc;
228  
229 $if{$iid} = $desc;
230 }
231  
232 return \%if;
233 }
234  
235 sub i_description {
236 my $trapeze = shift;
237 my $partial = shift;
238  
239 my $i_index = $trapeze->i_index($partial) || {};
240 my $i_desc = $trapeze->orig_i_description($partial) || {};
241 my $ap_name = $trapeze->trapeze_ap_name($partial) || {};
242  
243 my %i_name;
244 foreach my $iid ( keys %$i_index ) {
245 my $index = $i_index->{$iid};
246 next unless defined $index;
247  
248 if ( $index =~ /^\d+$/ ) {
249 my $name = $i_desc->{$iid};
250 next unless defined $name;
251 $i_name{$iid} = $name;
252 }
253  
254 elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
255 my $idx = $iid;
256 $idx =~ s/\.(\d+)$//;
257 my $radio = $1;
258 $radio--;
259 my $name = $ap_name->{$idx};
260 next unless defined $name;
261 $i_name{$iid} = "Radio-$radio: $name";
262 }
263  
264 else {
265 $i_name{$iid} = $index;
266 }
267 }
268 return \%i_name;
269 }
270  
271 sub i_name {
272 my $trapeze = shift;
273 my $partial = shift;
274  
275 return $trapeze->i_description($partial);
276 }
277  
278 sub i_type {
279 my $trapeze = shift;
280 my $partial = shift;
281  
282 my $i_index = $trapeze->i_index($partial) || {};
283 my $i_type = $trapeze->orig_i_type($partial) || {};
284  
285 my %i_type;
286 foreach my $iid ( keys %$i_index ) {
287 my $index = $i_index->{$iid};
288 next unless defined $index;
289  
290 if ( $index =~ /^\d+$/ ) {
291 my $type = $i_type->{$iid};
292 next unless defined $type;
293 $i_type{$iid} = $type;
294 }
295  
296 elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
297 # Match to an ifType
298 $i_type{$iid} = 'capwapWtpVirtualRadio';
299 }
300  
301 else {
302 next;
303 }
304 }
305 return \%i_type;
306 }
307  
308 sub i_up {
309 my $trapeze = shift;
310 my $partial = shift;
311  
312 return $trapeze->i_up_admin($partial);
313 }
314  
315 sub i_up_admin {
316 my $trapeze = shift;
317 my $partial = shift;
318  
319 my $i_index = $trapeze->i_index($partial) || {};
320 my $i_up = $trapeze->orig_i_up($partial) || {};
321 my $apif_up = $trapeze->trapeze_apif_admin($partial) || {};
322  
323 my %i_up_admin;
324 foreach my $iid ( keys %$i_index ) {
325 my $index = $i_index->{$iid};
326 next unless defined $index;
327  
328 if ( $index =~ /^\d+$/ ) {
329 my $stat = $i_up->{$iid};
330 next unless defined $stat;
331 $i_up_admin{$iid} = $stat;
332 }
333  
334 elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
335 my $stat = $apif_up->{$iid};
336 next unless defined $stat;
337 $i_up_admin{$iid} = $stat;
338 }
339  
340 else {
341 next;
342 }
343 }
344 return \%i_up_admin;
345 }
346  
347 sub i_mac {
348 my $trapeze = shift;
349 my $partial = shift;
350  
351 my $i_index = $trapeze->i_index($partial) || {};
352 my $i_mac = $trapeze->orig_i_mac($partial) || {};
353  
354 my %i_mac;
355 foreach my $iid ( keys %$i_index ) {
356 my $index = $i_index->{$iid};
357 next unless defined $index;
358  
359 if ( $index =~ /^\d+$/ ) {
360 my $mac = $i_mac->{$iid};
361 next unless defined $mac;
362 $i_mac{$iid} = $mac;
363 }
364  
365 # Don't grab AP MACs - we want the AP to show up on edge switch
366 # ports
367  
368 else {
369 next;
370 }
371 }
372 return \%i_mac;
373 }
374  
375 # Wireless switches do not support the standard Bridge MIB for client devices
376 sub bp_index {
377 my $trapeze = shift;
378 my $partial = shift;
379  
380 my $i_index = $trapeze->i_index($partial) || {};
381  
382 my %bp_index;
383 foreach my $iid ( keys %$i_index ) {
384 my $index = $i_index->{$iid};
385 next unless defined $index;
386  
387 $bp_index{$index} = $iid;
388 }
389 return \%bp_index;
390 }
391  
392 sub fw_mac {
393 my $trapeze = shift;
394 my $partial = shift;
395  
396 my $serials = $trapeze->trapeze_sta_serial($partial) || {};
397  
398 my %fw_mac;
399 foreach my $iid ( keys %$serials ) {
400 next unless $iid;
401  
402 my $mac = join( ':', map { sprintf "%02x", $_ } split /\./, $iid );
403 next unless $mac =~ /^([0-9A-F][0-9A-F]:){5}[0-9A-F][0-9A-F]$/i;
404
405 $fw_mac{$iid} = $mac;
406 }
407 return \%fw_mac;
408 }
409  
410 sub fw_port {
411 my $trapeze = shift;
412 my $partial = shift;
413  
414 my $slots = $trapeze->trapeze_sta_slot($partial) || {};
415 my $serials = $trapeze->trapeze_sta_serial($partial) || {};
416 my $ap_serials = $trapeze->_ap_serial($partial) || {};
417 my %serial_iid = reverse %$ap_serials;
418  
419 my %fw_port;
420 foreach my $iid ( keys %$slots ) {
421 my $slot = $slots->{$iid};
422 next unless defined $slot;
423 $slot =~ s/radio-//i;
424
425 my $serial = $serials->{$iid};
426 next unless defined $serial;
427 my $index = $serial_iid{$serial};
428 next unless defined $index;
429
430 $fw_port{$iid} = "$index.$slot";
431 }
432 return \%fw_port;
433 }
434  
435 sub i_ssidlist {
436 my $trapeze = shift;
437 my $partial = shift;
438  
439 my $apif_bssid = $trapeze->trapeze_apif_bssid($partial) || {};
440 my $i_index = $trapeze->i_index($partial) || {};
441  
442 my %i_ssidlist;
443 foreach my $iid ( keys %$i_index ) {
444  
445 # Skip non-radio interfaces
446 next if $iid =~ /^\d+$/;
447  
448 foreach my $idx ( keys %$apif_bssid ) {
449 next unless ( $idx =~ /^$iid\./ );
450 my $bssid_mac = $apif_bssid->{$idx};
451 next unless $bssid_mac;
452  
453 # Give the SSID a numeric value based upon tail of BSSID
454 my $id;
455 if ( $bssid_mac =~ /:([0-9A-F]{1,2})$/i ) {
456 $id = hex $1;
457 }
458 next unless ( defined $id and $id =~ /\d+/ );
459 my $ssid_oid = $idx;
460 $ssid_oid =~ s/^$iid\.//;
461  
462 my $ssid
463 = join( '', map { sprintf "%c", $_ } split /\./, $ssid_oid );
464  
465 # Remove any control characters including nulls
466 $ssid =~ s/[\c@-\c_]//g;
467 $i_ssidlist{"$iid.$id"} = $ssid;
468 }
469 }
470 return \%i_ssidlist;
471 }
472  
473  
474 # Can't find in MIB
475 #
476 #sub i_ssidbcast {
477 #
478 #}
479  
480 sub i_80211channel {
481 my $trapeze = shift;
482 my $partial = shift;
483  
484 my $ch_list = $trapeze->trapeze_apif_ch_num($partial) || {};
485  
486 my %i_80211channel;
487 foreach my $iid ( keys %$ch_list ) {
488 my $ch = $ch_list->{$iid};
489 next unless $ch =~ /\d+/;
490 $i_80211channel{$iid} = $ch;
491 }
492 return \%i_80211channel;
493 }
494  
495 sub dot11_cur_tx_pwr_mw {
496 my $trapeze = shift;
497 my $partial = shift;
498  
499 my $cur = $trapeze->trapeze_apif_power($partial);
500  
501 my $dot11_cur_tx_pwr_mw = {};
502 foreach my $idx ( keys %$cur ) {
503 my $pwr_dbm = $cur->{$idx};
504 next unless $pwr_dbm;
505 #Convert to milliWatts = 10(dBm/10)
506 my $pwr = int (10 ** ($pwr_dbm / 10));
507
508 $dot11_cur_tx_pwr_mw->{$idx} = $pwr;
509 }
510 return $dot11_cur_tx_pwr_mw;
511 }
512  
513 # Pseudo ENTITY-MIB methods
514  
515 sub e_index {
516 my $trapeze = shift;
517  
518 # Try new first, fall back to depreciated
519 my $ap_num = $trapeze->trapeze_ap_num() || $trapeze->trapeze_ap_dapnum() || {};
520  
521 my %e_index;
522  
523 # Chassis
524 $e_index{1} = 1;
525  
526 # We're going to hack an index to capture APs
527 foreach my $idx ( keys %$ap_num ) {
528 my $number = $ap_num->{$idx};
529 next unless $number =~ /\d+/;
530  
531 $e_index{$idx} = $number;
532 }
533 return \%e_index;
534 }
535  
536 sub e_class {
537 my $trapeze = shift;
538  
539 my $e_idx = $trapeze->e_index() || {};
540  
541 my %e_class;
542 foreach my $iid ( keys %$e_idx ) {
543 if ( $iid eq "1" ) {
544 $e_class{$iid} = 'chassis';
545 }
546  
547 # This isn't a valid PhysicalClass, but we're hacking this anyway
548 else {
549 $e_class{$iid} = 'ap';
550 }
551 }
552 return \%e_class;
553 }
554  
555 sub e_name {
556 my $trapeze = shift;
557  
558 my $ap_name = $trapeze->trapeze_ap_name() || {};
559  
560 my %e_name;
561  
562 # Chassis
563 $e_name{1} = 'WLAN Controller';
564  
565 # APs
566 foreach my $iid ( keys %$ap_name ) {
567 $e_name{$iid} = 'AP';
568 }
569 return \%e_name;
570 }
571  
572 sub e_descr {
573 my $trapeze = shift;
574  
575 my $ap_model = $trapeze->trapeze_ap_model() || {};
576 my $ap_name = $trapeze->trapeze_ap_name() || {};
577  
578 my %e_descr;
579  
580 # Chassis
581 $e_descr{1} = $trapeze->model();
582  
583 # APs
584 foreach my $iid ( keys %$ap_name ) {
585 my $name = $ap_name->{$iid};
586 next unless defined $name;
587 my $model = $ap_model->{$iid} || 'AP';
588  
589 $e_descr{$iid} = "$model: $name";
590 }
591 return \%e_descr;
592 }
593  
594 sub e_model {
595 my $trapeze = shift;
596  
597 my $ap_model = $trapeze->trapeze_ap_model() || {};
598  
599 my %e_model;
600  
601 # Chassis
602 $e_model{1} = $trapeze->model();
603  
604 # APs
605 foreach my $iid ( keys %$ap_model ) {
606 my $model = $ap_model->{$iid};
607 next unless defined $model;
608  
609 $e_model{$iid} = $model;
610 }
611 return \%e_model;
612 }
613  
614 sub e_type {
615 my $trapeze = shift;
616  
617 return $trapeze->e_model();
618 }
619  
620 sub e_fwver {
621 my $trapeze = shift;
622  
623 my $ap_fw = $trapeze->trapeze_ap_fw() || {};
624  
625 my %e_fwver;
626 # APs
627 foreach my $iid ( keys %$ap_fw ) {
628 my $fw = $ap_fw->{$iid};
629 next unless defined $fw;
630  
631 $e_fwver{$iid} = $fw;
632 }
633 return \%e_fwver;
634 }
635  
636 sub e_vendor {
637 my $trapeze = shift;
638  
639 my $vendors = $trapeze->trapeze_ap_vendor() || {};
640  
641 my %e_vendor;
642  
643 # Chassis
644 $e_vendor{1} = 'avaya';
645  
646 # APs
647 foreach my $iid ( keys %$vendors ) {
648 my $vendor = $vendors->{$iid};
649 next unless defined $vendor;
650  
651 $e_vendor{$iid} = $vendor;
652 }
653 return \%e_vendor;
654 }
655  
656 sub e_serial {
657 my $trapeze = shift;
658  
659 my $ap_serial = $trapeze->_ap_serial() || {};
660  
661 my %e_serial;
662  
663 # Chassis
664 $e_serial{1} = $trapeze->serial() || '';
665  
666 # APs
667 foreach my $iid ( keys %$ap_serial ) {
668 my $serial = $ap_serial->{$iid};
669 next unless defined $serial;
670  
671 $e_serial{$iid} = $serial;
672 }
673 return \%e_serial;
674 }
675  
676 sub e_pos {
677 my $trapeze = shift;
678  
679 my $e_idx = $trapeze->e_index() || {};
680  
681 my %e_pos;
682 my $pos = 0;
683 foreach my $iid ( sort keys %$e_idx ) {
684 if ( $iid eq "1" ) {
685 $e_pos{$iid} = -1;
686 next;
687 }
688 else {
689 $pos++;
690 $e_pos{$iid} = $pos;
691 }
692 }
693 return \%e_pos;
694 }
695  
696 sub e_swver {
697 my $trapeze = shift;
698  
699 my $ap_sw = $trapeze->trapeze_ap_sw() || {};
700  
701 my %e_swver;
702  
703 # Chassis
704 $e_swver{1} = $trapeze->os_ver();
705  
706 # APs
707 foreach my $iid ( keys %$ap_sw ) {
708 my $sw = $ap_sw->{$iid};
709 next unless defined $sw;
710  
711 $e_swver{$iid} = $sw;
712 }
713 return \%e_swver;
714 }
715  
716 sub e_parent {
717 my $trapeze = shift;
718  
719 my $e_idx = $trapeze->e_index() || {};
720  
721 my %e_parent;
722 foreach my $iid ( sort keys %$e_idx ) {
723 if ( $iid eq "1" ) {
724 $e_parent{$iid} = 0;
725 next;
726 }
727 else {
728 $e_parent{$iid} = 1;
729 }
730 }
731 return \%e_parent;
732 }
733  
734 # arpnip:
735 #
736 # This is the controller snooping on the MAC->IP mappings.
737 # Pretending this is arpnip data allows us to get MAC->IP
738 # mappings even for stations that only communicate locally.
739  
740 sub at_paddr {
741 my $trapeze = shift;
742  
743 my $mac2ip = $trapeze->trapeze_sta_ip();
744  
745 my $ret = {};
746 foreach my $idx ( keys %$mac2ip ) {
747 next if ( $mac2ip->{ $idx } eq '0.0.0.0' );
748 my $mac = join( ":", map { sprintf "%02x", $_ } split /\./, $idx );
749 $ret->{$idx} = $mac;
750 }
751 return $ret;
752 }
753  
754 sub at_netaddr {
755 my $trapeze = shift;
756  
757 my $mac2ip = $trapeze->trapeze_sta_ip();
758  
759 my $ret = {};
760 foreach my $idx ( keys %$mac2ip ) {
761 next if ( $mac2ip->{ $idx } eq '0.0.0.0' );
762 $ret->{$idx} = $mac2ip->{ $idx };
763 }
764 return $ret;
765 }
766  
767 # Client MAC
768 sub cd11_mac {
769 my $trapeze = shift;
770 my $cd11_sigstrength = $trapeze->cd11_sigstrength();
771  
772 my $ret = {};
773 foreach my $idx ( keys %$cd11_sigstrength ) {
774 my $mac = join( ":", map { sprintf "%02x", $_ } split /\./, $idx );
775 $ret->{$idx} = $mac
776 }
777 return $ret;
778 }
779  
780  
781 1;
782 __END__