Info/Layer2/NWSS2300.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::NWSS2300
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::NWSS2300;
30  
31 use strict;
32 use warnings;
33 use Exporter;
34 use SNMP::Info::Layer2;
35  
36 @SNMP::Info::Layer2::NWSS2300::ISA
37 = qw/SNMP::Info::Layer2 Exporter/;
38 @SNMP::Info::Layer2::NWSS2300::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 'NTWS-REGISTRATION-DEVICES-MIB' => 'ntwsSwitch2380',
47 'NTWS-AP-STATUS-MIB' => 'ntwsApStatNumAps',
48 'NTWS-CLIENT-SESSION-MIB' => 'ntwsClSessTotalSessions',
49 'NTWS-SYSTEM-MIB' => 'ntwsSysCpuAverageLoad',
50 'NTWS-BASIC-MIB' => 'ntwsVersionString',
51 'NTWS-AP-CONFIG-MIB' => 'ntwsApConfServProfBeaconEnabled',
52 );
53  
54 %GLOBALS = (
55 %SNMP::Info::Layer2::GLOBALS,
56 'os_ver' => 'ntwsVersionString',
57 'nws_serial' => 'ntwsSerialNumber',
58 'mac' => 'dot1dBaseBridgeAddress',
59 );
60  
61 %FUNCS = (
62 %SNMP::Info::Layer2::FUNCS,
63  
64 # NTWS-AP-STATUS-MIB::ntwsApStatApStatusTable
65 'nwss2300_ap_mac' => 'ntwsApStatApStatusBaseMac',
66 'nwss2300_ap_name' => 'ntwsApStatApStatusApName',
67 'nwss2300_ap_ip' => 'ntwsApStatApStatusIpAddress',
68 #'nwss2300_ap_loc' => 'bsnAPLocation',
69 'nwss2300_ap_sw' => 'ntwsApStatApStatusSoftwareVer',
70 'nwss2300_ap_fw' => 'ntwsApStatApStatusBootVer',
71 'nwss2300_ap_model' => 'ntwsApStatApStatusModel',
72 'nwss2300_ap_type' => 'ntwsApStatApStatusModel',
73 'nwss2300_ap_status' => 'ntwsApStatApStatusApState',
74 'nwss2300_ap_vendor' => 'ntwsApStatApStatusManufacturerId',
75 'nwss2300_ap_num' => 'ntwsApStatApStatusApNum',
76 'nwss2300_ap_dapnum' => 'ntwsApStatApStatusPortOrDapNum',
77  
78 # NTWS-AP-STATUS-MIB::ntwsApStatRadioStatusTable
79 'nwss2300_apif_mac' => 'ntwsApStatRadioStatusBaseMac',
80 'nwss2300_apif_type' => 'ntwsApStatRadioStatusRadioPhyType',
81 'nwss2300_apif_ch_num' => 'ntwsApStatRadioStatusCurrentChannelNum',
82 'nwss2300_apif_power' => 'ntwsApStatRadioStatusCurrentPowerLevel',
83 'nwss2300_apif_admin' => 'ntwsApStatRadioStatusRadioMode',
84  
85 # NTWS-AP-STATUS-MIB::ntwsApStatRadioServiceTable
86 'nwss2300_apif_prof' => 'ntwsApStatRadioServServiceProfileName',
87  
88 # NTWS-AP-CONFIG-MIB::ntwsApConfServiceProfileTable
89 'nwss2300_ess_bcast' => 'ntwsApConfServProfBeaconEnabled',
90  
91 # NTWS-AP-CONFIG-MIB::ntwsApConfRadioConfigTable
92 'nwss2300_apcr_txpwr' => 'ntwsApConfRadioConfigTxPower',
93 'nwss2300_apcr_ch' => 'ntwsApConfRadioConfigChannel',
94 'nwss2300_apcr_mode' => 'ntwsApConfRadioConfigRadioMode',
95  
96 # NTWS-AP-CONFIG-MIB::ntwsApConfApConfigTable
97 'nwss2300_apc_descr' => 'ntwsApConfApConfigDescription',
98 'nwss2300_apc_loc' => 'ntwsApConfApConfigLocation',
99 'nwss2300_apc_name' => 'ntwsApConfApConfigApName',
100 'nwss2300_apc_model' => 'ntwsApConfApConfigApModelName',
101 'nwss2300_apc_serial' => 'ntwsApConfApConfigApSerialNum',
102  
103 # NTWS-CLIENT-SESSION-MIB::ntwsClSessClientSessionTable
104 'nwss2300_sta_slot' => 'ntwsClSessClientSessRadioNum',
105 'nwss2300_sta_serial' => 'ntwsClSessClientSessApSerialNum',
106 'nwss2300_sta_ssid' => 'ntwsClSessClientSessSsid',
107 'nwss2300_sta_ip' => 'ntwsClSessClientSessIpAddress',
108  
109 # NTWS-AP-STATUS-MIB::ntwsApStatRadioServiceTable
110 'nwss2300_apif_bssid' => 'ntwsApStatRadioServBssid',
111  
112 # NTWS-CLIENT-SESSION-MIB::ntwsClSessClientSessionStatisticsTable
113 # Pretend to have the CISCO-DOT11-MIB for signal strengths, etc.
114 'cd11_sigstrength' => 'ntwsClSessClientSessStatsLastRssi',
115 'cd11_sigqual' => 'ntwsClSessClientSessStatsLastSNR',
116 'cd11_txrate' => 'ntwsClSessClientSessStatsLastRate',
117 # These are supposed to be there...
118 'cd11_rxbyte' => 'ntwsClSessClientSessStatsUniOctetIn',
119 'cd11_txbyte' => 'ntwsClSessClientSessStatsUniOctetOut',
120 'cd11_rxpkt' => 'ntwsClSessClientSessStatsUniPktIn',
121 'cd11_txpkt' => 'ntwsClSessClientSessStatsUniPktOut',
122 );
123  
124 %MUNGE = (
125 %SNMP::Info::Layer2::MUNGE,
126 'nwss2300_apif_mac' => \&SNMP::Info::munge_mac,
127 'nwss2300_apif_bssid' => \&SNMP::Info::munge_mac,
128 );
129  
130 sub layers {
131 return '00000111';
132 }
133  
134 sub os {
135 return 'trapeze';
136 }
137  
138 sub vendor {
139 return 'avaya';
140 }
141  
142 sub serial {
143 my $nwss2300 = shift;
144 my $ser = $nwss2300->ntwsSerialNumber();
145 # my $ser = $nwss2300->nws_serial();
146  
147 return $ser;
148 }
149  
150 sub model {
151 my $nwss2300 = shift;
152 my $id = $nwss2300->id();
153  
154 unless ( defined $id ) {
155 print
156 " SNMP::Info::Layer2::NWSS2300::model() - Device does not support sysObjectID\n"
157 if $nwss2300->debug();
158 return;
159 }
160  
161 my $model = &SNMP::translateObj($id);
162  
163 return $id unless defined $model;
164  
165 $model =~ s/^ntwsSwitch//i;
166 return $model;
167 }
168  
169 sub _ap_serial {
170 my $nwss2300 = shift;
171 my $partial = shift;
172  
173 my $names = $nwss2300->nwss2300_ap_name($partial) || {};
174  
175 my %ap_serial;
176 foreach my $iid ( keys %$names ) {
177 next unless $iid;
178  
179 my $serial = join( '', map { sprintf "%c", $_ } split /\./, $iid );
180 # Remove any control characters to include nulls
181 $serial =~ s/[\c@-\c_]//g;
182  
183 $ap_serial{$iid} = "$serial";
184 }
185 return \%ap_serial;
186 }
187  
188 # Wireless switches do not support ifMIB requirements to get MAC
189 # and port status
190  
191 sub i_index {
192 my $nwss2300 = shift;
193 my $partial = shift;
194  
195 my $i_index = $nwss2300->orig_i_index($partial) || {};
196 my $ap_index = $nwss2300->nwss2300_apif_mac($partial) || {};
197  
198 my %if_index;
199 foreach my $iid ( keys %$i_index ) {
200 my $index = $i_index->{$iid};
201 next unless defined $index;
202  
203 $if_index{$iid} = $index;
204 }
205  
206 # Get Attached APs as Interfaces
207 foreach my $ap_id ( keys %$ap_index ) {
208
209 my $mac = $ap_index->{$ap_id};
210 next unless ($mac);
211  
212 $if_index{$ap_id} = $mac;
213 }
214  
215 return \%if_index;
216 }
217  
218 sub interfaces {
219 my $nwss2300 = shift;
220 my $partial = shift;
221  
222 my $i_index = $nwss2300->i_index($partial) || {};
223 my $descriptions = $nwss2300->SUPER::i_description($partial) || {};
224  
225 my %if;
226 foreach my $iid ( keys %$i_index ) {
227 my $desc = $descriptions->{$iid} || $i_index->{$iid};
228 next unless defined $desc;
229  
230 $if{$iid} = $desc;
231 }
232  
233 return \%if;
234 }
235  
236 sub i_description {
237 my $nwss2300 = shift;
238 my $partial = shift;
239  
240 my $i_index = $nwss2300->i_index($partial) || {};
241 my $i_desc = $nwss2300->orig_i_description($partial) || {};
242 my $ap_name = $nwss2300->nwss2300_ap_name($partial) || {};
243  
244 my %i_name;
245 foreach my $iid ( keys %$i_index ) {
246 my $index = $i_index->{$iid};
247 next unless defined $index;
248  
249 if ( $index =~ /^\d+$/ ) {
250 my $name = $i_desc->{$iid};
251 next unless defined $name;
252 $i_name{$iid} = $name;
253 }
254  
255 elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
256 my $idx = $iid;
257 $idx =~ s/\.(\d+)$//;
258 my $radio = $1;
259 $radio--;
260 my $name = $ap_name->{$idx};
261 next unless defined $name;
262 $i_name{$iid} = "Radio-$radio: $name";
263 }
264  
265 else {
266 $i_name{$iid} = $index;
267 }
268 }
269 return \%i_name;
270 }
271  
272 sub i_name {
273 my $nwss2300 = shift;
274 my $partial = shift;
275  
276 return $nwss2300->i_description($partial);
277 }
278  
279 sub i_type {
280 my $nwss2300 = shift;
281 my $partial = shift;
282  
283 my $i_index = $nwss2300->i_index($partial) || {};
284 my $i_type = $nwss2300->orig_i_type($partial) || {};
285  
286 my %i_type;
287 foreach my $iid ( keys %$i_index ) {
288 my $index = $i_index->{$iid};
289 next unless defined $index;
290  
291 if ( $index =~ /^\d+$/ ) {
292 my $type = $i_type->{$iid};
293 next unless defined $type;
294 $i_type{$iid} = $type;
295 }
296  
297 elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
298 # Match to an ifType
299 $i_type{$iid} = 'capwapWtpVirtualRadio';
300 }
301  
302 else {
303 next;
304 }
305 }
306 return \%i_type;
307 }
308  
309 sub i_up {
310 my $nwss2300 = shift;
311 my $partial = shift;
312  
313 return $nwss2300->i_up_admin($partial);
314 }
315  
316 sub i_up_admin {
317 my $nwss2300 = shift;
318 my $partial = shift;
319  
320 my $i_index = $nwss2300->i_index($partial) || {};
321 my $i_up = $nwss2300->orig_i_up($partial) || {};
322 my $apif_up = $nwss2300->nwss2300_apif_admin($partial) || {};
323  
324 my %i_up_admin;
325 foreach my $iid ( keys %$i_index ) {
326 my $index = $i_index->{$iid};
327 next unless defined $index;
328  
329 if ( $index =~ /^\d+$/ ) {
330 my $stat = $i_up->{$iid};
331 next unless defined $stat;
332 $i_up_admin{$iid} = $stat;
333 }
334  
335 elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
336 my $stat = $apif_up->{$iid};
337 next unless defined $stat;
338 $i_up_admin{$iid} = $stat;
339 }
340  
341 else {
342 next;
343 }
344 }
345 return \%i_up_admin;
346 }
347  
348 sub i_mac {
349 my $nwss2300 = shift;
350 my $partial = shift;
351  
352 my $i_index = $nwss2300->i_index($partial) || {};
353 my $i_mac = $nwss2300->orig_i_mac($partial) || {};
354  
355 my %i_mac;
356 foreach my $iid ( keys %$i_index ) {
357 my $index = $i_index->{$iid};
358 next unless defined $index;
359  
360 if ( $index =~ /^\d+$/ ) {
361 my $mac = $i_mac->{$iid};
362 next unless defined $mac;
363 $i_mac{$iid} = $mac;
364 }
365  
366 # Don't grab AP MACs - we want the AP to show up on edge switch
367 # ports
368  
369 else {
370 next;
371 }
372 }
373 return \%i_mac;
374 }
375  
376 # Wireless switches do not support the standard Bridge MIB for client devices
377 sub bp_index {
378 my $nwss2300 = shift;
379 my $partial = shift;
380  
381 my $i_index = $nwss2300->i_index($partial) || {};
382  
383 my %bp_index;
384 foreach my $iid ( keys %$i_index ) {
385 my $index = $i_index->{$iid};
386 next unless defined $index;
387  
388 $bp_index{$index} = $iid;
389 }
390 return \%bp_index;
391 }
392  
393 sub fw_mac {
394 my $nwss2300 = shift;
395 my $partial = shift;
396  
397 my $serials = $nwss2300->nwss2300_sta_serial($partial) || {};
398  
399 my %fw_mac;
400 foreach my $iid ( keys %$serials ) {
401 next unless $iid;
402  
403 my $mac = join( ':', map { sprintf "%02x", $_ } split /\./, $iid );
404 next unless $mac =~ /^([0-9A-F][0-9A-F]:){5}[0-9A-F][0-9A-F]$/i;
405
406 $fw_mac{$iid} = $mac;
407 }
408 return \%fw_mac;
409 }
410  
411 sub fw_port {
412 my $nwss2300 = shift;
413 my $partial = shift;
414  
415 my $slots = $nwss2300->nwss2300_sta_slot($partial) || {};
416 my $serials = $nwss2300->nwss2300_sta_serial($partial) || {};
417 my $ap_serials = $nwss2300->_ap_serial($partial) || {};
418 my %serial_iid = reverse %$ap_serials;
419  
420 my %fw_port;
421 foreach my $iid ( keys %$slots ) {
422 my $slot = $slots->{$iid};
423 next unless defined $slot;
424 $slot =~ s/radio-//i;
425
426 my $serial = $serials->{$iid};
427 next unless defined $serial;
428 my $index = $serial_iid{$serial};
429 next unless defined $index;
430
431 $fw_port{$iid} = "$index.$slot";
432 }
433 return \%fw_port;
434 }
435  
436 sub i_ssidlist {
437 my $nwss2300 = shift;
438 my $partial = shift;
439  
440 my $apif_bssid = $nwss2300->nwss2300_apif_bssid($partial) || {};
441 my $i_index = $nwss2300->i_index($partial) || {};
442  
443 my %i_ssidlist;
444 foreach my $iid ( keys %$i_index ) {
445  
446 # Skip non-radio interfaces
447 next if $iid =~ /^\d+$/;
448  
449 foreach my $idx ( keys %$apif_bssid ) {
450 next unless ( $idx =~ /^$iid\./ );
451 my $bssid_mac = $apif_bssid->{$idx};
452 next unless $bssid_mac;
453  
454 # Give the SSID a numeric value based upon tail of BSSID
455 my $id;
456 if ( $bssid_mac =~ /:([0-9A-F]{1,2})$/i ) {
457 $id = hex $1;
458 }
459 next unless ( defined $id and $id =~ /\d+/ );
460 my $ssid_oid = $idx;
461 $ssid_oid =~ s/^$iid\.//;
462  
463 my $ssid
464 = join( '', map { sprintf "%c", $_ } split /\./, $ssid_oid );
465  
466 # Remove any control characters including nulls
467 $ssid =~ s/[\c@-\c_]//g;
468 $i_ssidlist{"$iid.$id"} = $ssid;
469 }
470 }
471 return \%i_ssidlist;
472 }
473  
474  
475 # Can't find in MIB
476 #
477 #sub i_ssidbcast {
478 #
479 #}
480  
481 sub i_80211channel {
482 my $nwss2300 = shift;
483 my $partial = shift;
484  
485 my $ch_list = $nwss2300->nwss2300_apif_ch_num($partial) || {};
486  
487 my %i_80211channel;
488 foreach my $iid ( keys %$ch_list ) {
489 my $ch = $ch_list->{$iid};
490 next unless $ch =~ /\d+/;
491 $i_80211channel{$iid} = $ch;
492 }
493 return \%i_80211channel;
494 }
495  
496 sub dot11_cur_tx_pwr_mw {
497 my $nwss2300 = shift;
498 my $partial = shift;
499  
500 my $cur = $nwss2300->nwss2300_apif_power($partial);
501  
502 my $dot11_cur_tx_pwr_mw = {};
503 foreach my $idx ( keys %$cur ) {
504 my $pwr_dbm = $cur->{$idx};
505 next unless $pwr_dbm;
506 #Convert to milliWatts = 10(dBm/10)
507 my $pwr = int (10 ** ($pwr_dbm / 10));
508
509 $dot11_cur_tx_pwr_mw->{$idx} = $pwr;
510 }
511 return $dot11_cur_tx_pwr_mw;
512 }
513  
514 # Pseudo ENTITY-MIB methods
515  
516 sub e_index {
517 my $nwss2300 = shift;
518  
519 # Try new first, fall back to depreciated
520 my $ap_num = $nwss2300->nwss2300_ap_num() || $nwss2300->nwss2300_ap_dapnum() || {};
521  
522 my %e_index;
523  
524 # Chassis
525 $e_index{1} = 1;
526  
527 # We're going to hack an index to capture APs
528 foreach my $idx ( keys %$ap_num ) {
529 my $number = $ap_num->{$idx};
530 next unless $number =~ /\d+/;
531  
532 $e_index{$idx} = $number;
533 }
534 return \%e_index;
535 }
536  
537 sub e_class {
538 my $nwss2300 = shift;
539  
540 my $e_idx = $nwss2300->e_index() || {};
541  
542 my %e_class;
543 foreach my $iid ( keys %$e_idx ) {
544 if ( $iid eq "1" ) {
545 $e_class{$iid} = 'chassis';
546 }
547  
548 # This isn't a valid PhysicalClass, but we're hacking this anyway
549 else {
550 $e_class{$iid} = 'ap';
551 }
552 }
553 return \%e_class;
554 }
555  
556 sub e_name {
557 my $nwss2300 = shift;
558  
559 my $ap_name = $nwss2300->nwss2300_ap_name() || {};
560  
561 my %e_name;
562  
563 # Chassis
564 $e_name{1} = 'WLAN Controller';
565  
566 # APs
567 foreach my $iid ( keys %$ap_name ) {
568 $e_name{$iid} = 'AP';
569 }
570 return \%e_name;
571 }
572  
573 sub e_descr {
574 my $nwss2300 = shift;
575  
576 my $ap_model = $nwss2300->nwss2300_ap_model() || {};
577 my $ap_name = $nwss2300->nwss2300_ap_name() || {};
578  
579 my %e_descr;
580  
581 # Chassis
582 $e_descr{1} = $nwss2300->model();
583  
584 # APs
585 foreach my $iid ( keys %$ap_name ) {
586 my $name = $ap_name->{$iid};
587 next unless defined $name;
588 my $model = $ap_model->{$iid} || 'AP';
589  
590 $e_descr{$iid} = "$model: $name";
591 }
592 return \%e_descr;
593 }
594  
595 sub e_model {
596 my $nwss2300 = shift;
597  
598 my $ap_model = $nwss2300->nwss2300_ap_model() || {};
599  
600 my %e_model;
601  
602 # Chassis
603 $e_model{1} = $nwss2300->model();
604  
605 # APs
606 foreach my $iid ( keys %$ap_model ) {
607 my $model = $ap_model->{$iid};
608 next unless defined $model;
609  
610 $e_model{$iid} = $model;
611 }
612 return \%e_model;
613 }
614  
615 sub e_type {
616 my $nwss2300 = shift;
617  
618 return $nwss2300->e_model();
619 }
620  
621 sub e_fwver {
622 my $nwss2300 = shift;
623  
624 my $ap_fw = $nwss2300->nwss2300_ap_fw() || {};
625  
626 my %e_fwver;
627 # APs
628 foreach my $iid ( keys %$ap_fw ) {
629 my $fw = $ap_fw->{$iid};
630 next unless defined $fw;
631  
632 $e_fwver{$iid} = $fw;
633 }
634 return \%e_fwver;
635 }
636  
637 sub e_vendor {
638 my $nwss2300 = shift;
639  
640 my $vendors = $nwss2300->nwss2300_ap_vendor() || {};
641  
642 my %e_vendor;
643  
644 # Chassis
645 $e_vendor{1} = 'avaya';
646  
647 # APs
648 foreach my $iid ( keys %$vendors ) {
649 my $vendor = $vendors->{$iid};
650 next unless defined $vendor;
651  
652 $e_vendor{$iid} = $vendor;
653 }
654 return \%e_vendor;
655 }
656  
657 sub e_serial {
658 my $nwss2300 = shift;
659  
660 my $ap_serial = $nwss2300->_ap_serial() || {};
661  
662 my %e_serial;
663  
664 # Chassis
665 $e_serial{1} = $nwss2300->serial() || '';
666  
667 # APs
668 foreach my $iid ( keys %$ap_serial ) {
669 my $serial = $ap_serial->{$iid};
670 next unless defined $serial;
671  
672 $e_serial{$iid} = $serial;
673 }
674 return \%e_serial;
675 }
676  
677 sub e_pos {
678 my $nwss2300 = shift;
679  
680 my $e_idx = $nwss2300->e_index() || {};
681  
682 my %e_pos;
683 my $pos = 0;
684 foreach my $iid ( sort keys %$e_idx ) {
685 if ( $iid eq "1" ) {
686 $e_pos{$iid} = -1;
687 next;
688 }
689 else {
690 $pos++;
691 $e_pos{$iid} = $pos;
692 }
693 }
694 return \%e_pos;
695 }
696  
697 sub e_swver {
698 my $nwss2300 = shift;
699  
700 my $ap_sw = $nwss2300->nwss2300_ap_sw() || {};
701  
702 my %e_swver;
703  
704 # Chassis
705 $e_swver{1} = $nwss2300->os_ver();
706  
707 # APs
708 foreach my $iid ( keys %$ap_sw ) {
709 my $sw = $ap_sw->{$iid};
710 next unless defined $sw;
711  
712 $e_swver{$iid} = $sw;
713 }
714 return \%e_swver;
715 }
716  
717 sub e_parent {
718 my $nwss2300 = shift;
719  
720 my $e_idx = $nwss2300->e_index() || {};
721  
722 my %e_parent;
723 foreach my $iid ( sort keys %$e_idx ) {
724 if ( $iid eq "1" ) {
725 $e_parent{$iid} = 0;
726 next;
727 }
728 else {
729 $e_parent{$iid} = 1;
730 }
731 }
732 return \%e_parent;
733 }
734  
735 # arpnip:
736 #
737 # This is the controller snooping on the MAC->IP mappings.
738 # Pretending this is arpnip data allows us to get MAC->IP
739 # mappings even for stations that only communicate locally.
740  
741 sub at_paddr {
742 my $nwss2300 = shift;
743  
744 my $mac2ip = $nwss2300->nwss2300_sta_ip();
745  
746 my $ret = {};
747 foreach my $idx ( keys %$mac2ip ) {
748 next if ( $mac2ip->{ $idx } eq '0.0.0.0' );
749 my $mac = join( ":", map { sprintf "%02x", $_ } split /\./, $idx );
750 $ret->{$idx} = $mac;
751 }
752 return $ret;
753 }
754  
755 sub at_netaddr {
756 my $nwss2300 = shift;
757  
758 my $mac2ip = $nwss2300->nwss2300_sta_ip();
759  
760 my $ret = {};
761 foreach my $idx ( keys %$mac2ip ) {
762 next if ( $mac2ip->{ $idx } eq '0.0.0.0' );
763 $ret->{$idx} = $mac2ip->{ $idx };
764 }
765 return $ret;
766 }
767  
768 # Client MAC
769 sub cd11_mac {
770 my $nwss2300 = shift;
771 my $cd11_sigstrength = $nwss2300->cd11_sigstrength();
772  
773 my $ret = {};
774 foreach my $idx ( keys %$cd11_sigstrength ) {
775 my $mac = join( ":", map { sprintf "%02x", $_ } split /\./, $idx );
776 $ret->{$idx} = $mac
777 }
778 return $ret;
779 }
780  
781  
782 1;
783 __END__