| 1 | # SNMP::Info::Airespace | ||
| 2 | # | ||
| 3 | # Copyright (c) 2008 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::Airespace; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | use SNMP::Info; | ||
| 36 | |||
| 37 | @SNMP::Info::Airespace::ISA = qw/SNMP::Info Exporter/; | ||
| 38 | @SNMP::Info::Airespace::EXPORT_OK = qw//; | ||
| 39 | |||
| 40 | our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE); | ||
| 41 | |||
| 42 | $VERSION = '3.985003'; | ||
| 43 | |||
| 44 | %MIBS = ( | ||
| 45 | %SNMP::Info::MIBS, | ||
| 46 | 'AIRESPACE-WIRELESS-MIB' => 'bsnAPName', | ||
| 47 | 'AIRESPACE-SWITCHING-MIB' => 'agentInventorySerialNumber', | ||
| 48 | ); | ||
| 49 | |||
| 50 | %GLOBALS = ( | ||
| 51 | %SNMP::Info::GLOBALS, | ||
| 52 | 'airespace_type' => 'agentInventoryMachineType', | ||
| 53 | 'airespace_model' => 'agentInventoryMachineModel', | ||
| 54 | 'airespace_serial' => 'agentInventorySerialNumber', | ||
| 55 | 'airespace_maint_ver' => 'agentInventoryMaintenanceLevel', | ||
| 56 | 'airespace_mac' => 'agentInventoryBurnedInMacAddress', | ||
| 57 | 'airespace_os' => 'agentInventoryOperatingSystem', | ||
| 58 | 'airespace_vendor' => 'agentInventoryManufacturerName', | ||
| 59 | 'airespace_prod_name' => 'agentInventoryProductName', | ||
| 60 | 'os_ver' => 'agentInventoryProductVersion', | ||
| 61 | 'airespace_bssid_mode' => 'agentNetworkBroadcastSsidMode', | ||
| 62 | 'airespace_mc_mode' => 'agentNetworkMulticastMode', | ||
| 63 | 'airespace_lwapp_mode' => 'agentSwitchLwappTransportMode', | ||
| 64 | 'airespace_ul_mode' => 'agentTransferUploadMode', | ||
| 65 | 'airespace_ul_ip' => 'agentTransferUploadServerIP', | ||
| 66 | 'airespace_ul_path' => 'agentTransferUploadPath', | ||
| 67 | 'airespace_ul_file' => 'agentTransferUploadFilename', | ||
| 68 | 'airespace_ul_type' => 'agentTransferUploadDataType', | ||
| 69 | 'airespace_ul_start' => 'agentTransferUploadStart', | ||
| 70 | 'airespace_ul_status' => 'agentTransferUploadStatus', | ||
| 71 | ); | ||
| 72 | |||
| 73 | %FUNCS = ( | ||
| 74 | %SNMP::Info::FUNCS, | ||
| 75 | |||
| 76 | # AIRESPACE-WIRELESS-MIB::bsnDot11EssTable | ||
| 77 | 'airespace_ess_idx' => 'bsnDot11EssIndex', | ||
| 78 | 'airespace_ess_ssid' => 'bsnDot11EssSsid', | ||
| 79 | 'airespace_ess_macflt' => 'bsnDot11EssMacFiltering', | ||
| 80 | 'airespace_ess_status' => 'bsnDot11EssAdminStatus', | ||
| 81 | 'airespace_ess_sec_auth' => 'bsnDot11EssSecurityAuthType', | ||
| 82 | 'airespace_ess_radio_pol' => 'bsnDot11EssRadioPolicy', | ||
| 83 | 'airespace_ess_qos' => 'bsnDot11EssQualityOfService', | ||
| 84 | 'airespace_ess_ifname' => 'bsnDot11EssInterfaceName', | ||
| 85 | 'airespace_ess_aclname' => 'bsnDot11EssAclName', | ||
| 86 | 'airespace_ess_bcast' => 'bsnDot11EssBroadcastSsid', | ||
| 87 | |||
| 88 | # AIRESPACE-WIRELESS-MIB::bsnAPTable | ||
| 89 | 'airespace_ap_mac' => 'bsnAPDot3MacAddress', | ||
| 90 | 'airespace_ap_name' => 'bsnAPName', | ||
| 91 | 'airespace_ap_ip' => 'bsnApIpAddress', | ||
| 92 | 'airespace_ap_loc' => 'bsnAPLocation', | ||
| 93 | 'airespace_ap_sw' => 'bsnAPSoftwareVersion', | ||
| 94 | 'airespace_ap_fw' => 'bsnAPBootVersion', | ||
| 95 | 'airespace_ap_model' => 'bsnAPModel', | ||
| 96 | 'airespace_ap_serial' => 'bsnAPSerialNumber', | ||
| 97 | 'airespace_ap_type' => 'bsnAPType', | ||
| 98 | 'airespace_ap_status' => 'bsnAPAdminStatus', | ||
| 99 | 'airespace_ap_ethermac' => 'bsnAPEthernetMacAddress', | ||
| 100 | |||
| 101 | # AIRESPACE-WIRELESS-MIB::bsnAPIfTable | ||
| 102 | 'airespace_apif_slot' => 'bsnAPIfSlotId', | ||
| 103 | 'airespace_apif_type' => 'bsnAPIfType', | ||
| 104 | 'airespace_apif_ch_num' => 'bsnAPIfPhyChannelNumber', | ||
| 105 | 'airespace_apif_power' => 'bsnAPIfPhyTxPowerLevel', | ||
| 106 | 'airespace_apif' => 'bsnAPIfOperStatus', | ||
| 107 | 'airespace_apif_oride' => 'bsnAPIfWlanOverride', | ||
| 108 | 'airespace_apif_admin' => 'bsnAPIfAdminStatus', | ||
| 109 | 'airespace_apif_a_pwr' => 'bsnAPIfAbsolutePowerList', | ||
| 110 | |||
| 111 | # AIRESPACE-WIRELESS-MIB::bsnMobileStationTable | ||
| 112 | 'airespace_sta_mac' => 'bsnMobileStationAPMacAddr', | ||
| 113 | 'fw_mac' => 'bsnMobileStationMacAddress', | ||
| 114 | 'airespace_sta_slot' => 'bsnMobileStationAPIfSlotId', | ||
| 115 | 'airespace_sta_ess_idx' => 'bsnMobileStationEssIndex', | ||
| 116 | 'airespace_sta_ssid' => 'bsnMobileStationSsid', | ||
| 117 | 'airespace_sta_delete' => 'bsnMobileStationDeleteAction', | ||
| 118 | 'airespace_sta_ip' => 'bsnMobileStationIpAddress', | ||
| 119 | 'airespace_sta_vlan' => 'bsnMobileStationVlanId', | ||
| 120 | 'airespace_sta_if' => 'bsnMobileStationInterface', | ||
| 121 | |||
| 122 | # AIRESPACE-WIRELESS-MIB::bsnUsersTable | ||
| 123 | 'airespace_user_name' => 'bsnUserName', | ||
| 124 | 'airespace_user_pw' => 'bsnUserPassword', | ||
| 125 | 'airespace_user_ess_idx' => 'bsnUserEssIndex', | ||
| 126 | 'airespace_user_access' => 'bsnUserAccessMode', | ||
| 127 | 'airespace_user_type' => 'bsnUserType', | ||
| 128 | 'airespace_user_ifname' => 'bsnUserInterfaceName', | ||
| 129 | 'airespace_user_rstat' => 'bsnUserRowStatus', | ||
| 130 | |||
| 131 | # AIRESPACE-WIRELESS-MIB::bsnBlackListClientTable | ||
| 132 | 'airespace_bl_mac' => 'bsnBlackListClientMacAddress', | ||
| 133 | 'airespace_bl_descr' => 'bsnBlackListClientDescription', | ||
| 134 | 'airespace_bl_rstat' => 'bsnBlackListClientRowStatus', | ||
| 135 | |||
| 136 | # AIRESPACE-WIRELESS-MIB::bsnAPIfWlanOverrideTable | ||
| 137 | 'airespace_oride_id' => 'bsnAPIfWlanOverrideId', | ||
| 138 | 'airespace_oride_ssid' => 'bsnAPIfWlanOverrideSsid', | ||
| 139 | |||
| 140 | # AIRESPACE-SWITCHING-MIB::agentInterfaceConfigTable | ||
| 141 | 'airespace_if_name' => 'agentInterfaceName', | ||
| 142 | 'airespace_if_vlan' => 'agentInterfaceVlanId', | ||
| 143 | 'airespace_if_type' => 'agentInterfaceType', | ||
| 144 | 'airespace_if_mac' => 'agentInterfaceMacAddress', | ||
| 145 | 'airespace_if_ip' => 'agentInterfaceIPAddress', | ||
| 146 | 'airespace_if_mask' => 'agentInterfaceIPNetmask', | ||
| 147 | 'airespace_if_acl' => 'agentInterfaceAclName', | ||
| 148 | 'airespace_if_rstat' => 'agentInterfaceRowStatus', | ||
| 149 | |||
| 150 | # AIRESPACE-SWITCHING-MIB::agentPortConfigTable | ||
| 151 | 'airespace_duplex_admin' => 'agentPortPhysicalMode', | ||
| 152 | 'airespace_duplex' => 'agentPortPhysicalStatus', | ||
| 153 | |||
| 154 | # This needs to be cleaned up, but for now we pretend to | ||
| 155 | # have the CISCO-DOT11-MIB for signal strengths, etc. | ||
| 156 | 'cd11_sigstrength' => 'bsnMobileStationRSSI', # kinda | ||
| 157 | 'cd11_sigqual' => 'bsnMobileStationSnr', # kinda | ||
| 158 | 'cd11_rxbyte' => 'bsnMobileStationBytesReceived', | ||
| 159 | 'cd11_txbyte' => 'bsnMobileStationBytesSent', | ||
| 160 | 'cd11_rxpkt' => 'bsnMobileStationPacketsReceived', | ||
| 161 | 'cd11_txpkt' => 'bsnMobileStationPacketsSent', | ||
| 162 | 'cd11_ssid' => 'bsnMobileStationSsid', | ||
| 163 | ); | ||
| 164 | |||
| 165 | %MUNGE = ( | ||
| 166 | %SNMP::Info::MUNGE, | ||
| 167 | 'airespace_ap_mac' => \&SNMP::Info::munge_mac, | ||
| 168 | 'airespace_ap_ethermac' => \&SNMP::Info::munge_mac, | ||
| 169 | 'fw_port' => \&SNMP::Info::munge_mac, | ||
| 170 | 'airespace_bl_mac' => \&SNMP::Info::munge_mac, | ||
| 171 | 'airespace_if_mac' => \&SNMP::Info::munge_mac, | ||
| 172 | 'airespace_sta_mac' => \&SNMP::Info::munge_mac, | ||
| 173 | 'cd11_rxpkt' => \&munge_64bits, | ||
| 174 | 'cd11_txpkt' => \&munge_64bits, | ||
| 175 | ); | ||
| 176 | |||
| 177 | sub layers { | ||
| 178 | return '00000111'; | ||
| 179 | } | ||
| 180 | |||
| 181 | sub serial { | ||
| 182 | my $airespace = shift; | ||
| 183 | my $sn = $airespace->airespace_serial(); | ||
| 184 | return unless defined $sn; | ||
| 185 | |||
| 186 | return $sn; | ||
| 187 | } | ||
| 188 | |||
| 189 | # Wirless switches do not support ifMIB requirements to get MAC | ||
| 190 | # and port status | ||
| 191 | |||
| 192 | sub i_index { | ||
| 193 | my $airespace = shift; | ||
| 194 | my $partial = shift; | ||
| 195 | |||
| 196 | my $i_index = $airespace->orig_i_index($partial) || {}; | ||
| 197 | my $ap_index = $airespace->airespace_apif_slot($partial) || {}; | ||
| 198 | my $if_index = $airespace->airespace_if_name($partial) || {}; | ||
| 199 | |||
| 200 | my %if_index; | ||
| 201 | foreach my $iid ( keys %$i_index ) { | ||
| 202 | my $index = $i_index->{$iid}; | ||
| 203 | next unless defined $index; | ||
| 204 | |||
| 205 | $if_index{$iid} = $index; | ||
| 206 | } | ||
| 207 | |||
| 208 | # Get Attached APs as Interfaces | ||
| 209 | foreach my $ap_id ( keys %$ap_index ) { | ||
| 210 | |||
| 211 | if ( $ap_id =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)\.(\d+)/ ) { | ||
| 212 | my $mac = join( ':', | ||
| 213 | map { sprintf( "%02x", $_ ) } split( /\./, $1 ) ); | ||
| 214 | my $slot = $2; | ||
| 215 | next unless ( ( defined $mac ) and ( defined $slot ) ); | ||
| 216 | |||
| 217 | $if_index{$ap_id} = "$mac.$slot"; | ||
| 218 | } | ||
| 219 | } | ||
| 220 | |||
| 221 | # Get Switch Interfaces from Interface Config Table | ||
| 222 | foreach my $if_id ( keys %$if_index ) { | ||
| 223 | my $name = $if_index->{$if_id}; | ||
| 224 | next unless defined $name; | ||
| 225 | |||
| 226 | $if_index{$if_id} = $name; | ||
| 227 | } | ||
| 228 | |||
| 229 | return \%if_index; | ||
| 230 | } | ||
| 231 | |||
| 232 | sub interfaces { | ||
| 233 | my $airespace = shift; | ||
| 234 | my $partial = shift; | ||
| 235 | |||
| 236 | my $i_index = $airespace->i_index($partial) || {}; | ||
| 237 | |||
| 238 | my %if; | ||
| 239 | foreach my $iid ( keys %$i_index ) { | ||
| 240 | my $index = $i_index->{$iid}; | ||
| 241 | next unless defined $index; | ||
| 242 | |||
| 243 | if ( $index =~ /^\d+$/ ) { | ||
| 244 | $if{$iid} = "1.$index"; | ||
| 245 | } | ||
| 246 | |||
| 247 | else { | ||
| 248 | $if{$iid} = $index; | ||
| 249 | } | ||
| 250 | } | ||
| 251 | return \%if; | ||
| 252 | } | ||
| 253 | |||
| 254 | sub i_name { | ||
| 255 | my $airespace = shift; | ||
| 256 | my $partial = shift; | ||
| 257 | |||
| 258 | my $i_index = $airespace->i_index($partial) || {}; | ||
| 259 | my $i_name = $airespace->orig_i_name($partial) || {}; | ||
| 260 | my $ap_name = $airespace->airespace_ap_name($partial) || {}; | ||
| 261 | |||
| 262 | my %i_name; | ||
| 263 | foreach my $iid ( keys %$i_index ) { | ||
| 264 | my $index = $i_index->{$iid}; | ||
| 265 | next unless defined $index; | ||
| 266 | |||
| 267 | if ( $index =~ /^\d+$/ ) { | ||
| 268 | my $name = $i_name->{$iid}; | ||
| 269 | next unless defined $name; | ||
| 270 | $i_name{$iid} = $name; | ||
| 271 | } | ||
| 272 | |||
| 273 | elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { | ||
| 274 | my $idx = $iid; | ||
| 275 | $idx =~ s/\.\d+$//; | ||
| 276 | my $name = $ap_name->{$idx}; | ||
| 277 | next unless defined $name; | ||
| 278 | $i_name{$iid} = $name; | ||
| 279 | } | ||
| 280 | |||
| 281 | else { | ||
| 282 | $i_name{$iid} = $index; | ||
| 283 | } | ||
| 284 | } | ||
| 285 | return \%i_name; | ||
| 286 | } | ||
| 287 | |||
| 288 | sub i_description { | ||
| 289 | my $airespace = shift; | ||
| 290 | my $partial = shift; | ||
| 291 | |||
| 292 | my $i_index = $airespace->i_index($partial) || {}; | ||
| 293 | my $i_descr = $airespace->orig_i_description($partial) || {}; | ||
| 294 | my $ap_loc = $airespace->airespace_ap_loc($partial) || {}; | ||
| 295 | |||
| 296 | my %descr; | ||
| 297 | foreach my $iid ( keys %$i_index ) { | ||
| 298 | my $index = $i_index->{$iid}; | ||
| 299 | next unless defined $index; | ||
| 300 | |||
| 301 | if ( $index =~ /^\d+$/ ) { | ||
| 302 | my $descr = $i_descr->{$iid}; | ||
| 303 | next unless defined $descr; | ||
| 304 | $descr{$iid} = $descr; | ||
| 305 | } | ||
| 306 | |||
| 307 | elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { | ||
| 308 | my $idx = $iid; | ||
| 309 | $idx =~ s/\.\d+$//; | ||
| 310 | my $name = $ap_loc->{$idx}; | ||
| 311 | next unless defined $name; | ||
| 312 | $descr{$iid} = $name; | ||
| 313 | } | ||
| 314 | |||
| 315 | else { | ||
| 316 | $descr{$iid} = $index; | ||
| 317 | } | ||
| 318 | } | ||
| 319 | return \%descr; | ||
| 320 | } | ||
| 321 | |||
| 322 | sub i_type { | ||
| 323 | my $airespace = shift; | ||
| 324 | my $partial = shift; | ||
| 325 | |||
| 326 | my $i_index = $airespace->i_index($partial) || {}; | ||
| 327 | my $i_descr = $airespace->orig_i_type($partial) || {}; | ||
| 328 | my $apif_type = $airespace->airespace_apif_type($partial) || {}; | ||
| 329 | my $if_type = $airespace->airespace_if_type($partial) || {}; | ||
| 330 | |||
| 331 | my %i_type; | ||
| 332 | foreach my $iid ( keys %$i_index ) { | ||
| 333 | my $index = $i_index->{$iid}; | ||
| 334 | next unless defined $index; | ||
| 335 | |||
| 336 | if ( $index =~ /^\d+$/ ) { | ||
| 337 | my $descr = $i_descr->{$iid}; | ||
| 338 | next unless defined $descr; | ||
| 339 | $i_type{$iid} = $descr; | ||
| 340 | } | ||
| 341 | |||
| 342 | elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { | ||
| 343 | my $type = $apif_type->{$iid}; | ||
| 344 | next unless defined $type; | ||
| 345 | $i_type{$iid} = $type; | ||
| 346 | } | ||
| 347 | |||
| 348 | else { | ||
| 349 | my $type = $if_type->{$iid}; | ||
| 350 | $i_type{$iid} = $type; | ||
| 351 | } | ||
| 352 | } | ||
| 353 | return \%i_type; | ||
| 354 | } | ||
| 355 | |||
| 356 | sub i_up { | ||
| 357 | my $airespace = shift; | ||
| 358 | my $partial = shift; | ||
| 359 | |||
| 360 | my $i_index = $airespace->i_index($partial) || {}; | ||
| 361 | my $i_up = $airespace->orig_i_up($partial) || {}; | ||
| 362 | my $apif_up = $airespace->airespace_apif($partial) || {}; | ||
| 363 | |||
| 364 | my %i_up; | ||
| 365 | foreach my $iid ( keys %$i_index ) { | ||
| 366 | my $index = $i_index->{$iid}; | ||
| 367 | next unless defined $index; | ||
| 368 | |||
| 369 | if ( $index =~ /^\d+$/ ) { | ||
| 370 | my $stat = $i_up->{$iid}; | ||
| 371 | next unless defined $stat; | ||
| 372 | $i_up{$iid} = $stat; | ||
| 373 | } | ||
| 374 | |||
| 375 | elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { | ||
| 376 | my $stat = $apif_up->{$iid}; | ||
| 377 | next unless defined $stat; | ||
| 378 | $i_up{$iid} = $stat; | ||
| 379 | } | ||
| 380 | |||
| 381 | else { | ||
| 382 | next; | ||
| 383 | } | ||
| 384 | } | ||
| 385 | return \%i_up; | ||
| 386 | } | ||
| 387 | |||
| 388 | sub i_up_admin { | ||
| 389 | my $airespace = shift; | ||
| 390 | my $partial = shift; | ||
| 391 | |||
| 392 | my $i_index = $airespace->i_index($partial) || {}; | ||
| 393 | my $i_up = $airespace->orig_i_up($partial) || {}; | ||
| 394 | my $apif_up = $airespace->airespace_apif_admin($partial) || {}; | ||
| 395 | |||
| 396 | my %i_up_admin; | ||
| 397 | foreach my $iid ( keys %$i_index ) { | ||
| 398 | my $index = $i_index->{$iid}; | ||
| 399 | next unless defined $index; | ||
| 400 | |||
| 401 | if ( $index =~ /^\d+$/ ) { | ||
| 402 | my $stat = $i_up->{$iid}; | ||
| 403 | next unless defined $stat; | ||
| 404 | $i_up_admin{$iid} = $stat; | ||
| 405 | } | ||
| 406 | |||
| 407 | elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { | ||
| 408 | my $stat = $apif_up->{$iid}; | ||
| 409 | next unless defined $stat; | ||
| 410 | $i_up_admin{$iid} = $stat; | ||
| 411 | } | ||
| 412 | |||
| 413 | else { | ||
| 414 | next; | ||
| 415 | } | ||
| 416 | } | ||
| 417 | return \%i_up_admin; | ||
| 418 | } | ||
| 419 | |||
| 420 | sub i_mac { | ||
| 421 | my $airespace = shift; | ||
| 422 | my $partial = shift; | ||
| 423 | |||
| 424 | my $i_index = $airespace->i_index($partial) || {}; | ||
| 425 | my $i_mac = $airespace->orig_i_mac($partial) || {}; | ||
| 426 | my $if_mac = $airespace->airespace_if_mac($partial) || {}; | ||
| 427 | |||
| 428 | my %i_mac; | ||
| 429 | foreach my $iid ( keys %$i_index ) { | ||
| 430 | my $index = $i_index->{$iid}; | ||
| 431 | next unless defined $index; | ||
| 432 | |||
| 433 | if ( $index =~ /^\d+$/ ) { | ||
| 434 | my $mac = $i_mac->{$iid}; | ||
| 435 | next unless defined $mac; | ||
| 436 | $i_mac{$iid} = $mac; | ||
| 437 | } | ||
| 438 | elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { | ||
| 439 | $index =~ s/\.\d+$//; | ||
| 440 | next unless defined $index; | ||
| 441 | $i_mac{$iid} = $index; | ||
| 442 | } | ||
| 443 | # Some switch interfaces have MACs, virtuals report 00:00:00:00:00:00 | ||
| 444 | else { | ||
| 445 | my $mac = $if_mac->{$iid}; | ||
| 446 | next unless defined $mac; | ||
| 447 | next if $mac =~ /00:00:00:00:00:00/; | ||
| 448 | $i_mac{$iid} = $mac; | ||
| 449 | } | ||
| 450 | } | ||
| 451 | return \%i_mac; | ||
| 452 | } | ||
| 453 | |||
| 454 | sub i_vlan { | ||
| 455 | my $airespace = shift; | ||
| 456 | my $partial = shift; | ||
| 457 | |||
| 458 | my $if_vlan = $airespace->airespace_if_vlan($partial) || {}; | ||
| 459 | |||
| 460 | my %i_vlan; | ||
| 461 | foreach my $iid ( keys %$if_vlan ) { | ||
| 462 | my $vlan = $if_vlan->{$iid}; | ||
| 463 | next unless defined $vlan; | ||
| 464 | |||
| 465 | $i_vlan{$iid} = $vlan; | ||
| 466 | } | ||
| 467 | |||
| 468 | return \%i_vlan; | ||
| 469 | } | ||
| 470 | |||
| 471 | sub i_duplex { | ||
| 472 | my $airespace = shift; | ||
| 473 | my $partial = shift; | ||
| 474 | |||
| 475 | my $ap_duplex = $airespace->airespace_duplex($partial) || {}; | ||
| 476 | |||
| 477 | my %i_duplex; | ||
| 478 | foreach my $if ( keys %$ap_duplex ) { | ||
| 479 | my $duplex = $ap_duplex->{$if}; | ||
| 480 | next unless defined $duplex; | ||
| 481 | |||
| 482 | $duplex = 'half' if $duplex =~ /half/i; | ||
| 483 | $duplex = 'full' if $duplex =~ /full/i; | ||
| 484 | $duplex = 'auto' if $duplex =~ /auto/i; | ||
| 485 | $i_duplex{$if} = $duplex; | ||
| 486 | } | ||
| 487 | return \%i_duplex; | ||
| 488 | } | ||
| 489 | |||
| 490 | sub i_duplex_admin { | ||
| 491 | my $airespace = shift; | ||
| 492 | my $partial = shift; | ||
| 493 | |||
| 494 | my $ap_duplex_admin = $airespace->airespace_duplex_admin($partial) || {}; | ||
| 495 | |||
| 496 | my %i_duplex_admin; | ||
| 497 | foreach my $if ( keys %$ap_duplex_admin ) { | ||
| 498 | my $duplex = $ap_duplex_admin->{$if}; | ||
| 499 | next unless defined $duplex; | ||
| 500 | |||
| 501 | $duplex = 'half' if $duplex =~ /half/i; | ||
| 502 | $duplex = 'full' if $duplex =~ /full/i; | ||
| 503 | $duplex = 'auto' if $duplex =~ /auto/i; | ||
| 504 | $i_duplex_admin{$if} = $duplex; | ||
| 505 | } | ||
| 506 | return \%i_duplex_admin; | ||
| 507 | } | ||
| 508 | |||
| 509 | sub ip_index { | ||
| 510 | my $airespace = shift; | ||
| 511 | my $partial = shift; | ||
| 512 | |||
| 513 | my $ip_index = $airespace->SUPER::ip_index($partial) || {}; | ||
| 514 | my $if_ip = $airespace->airespace_if_ip() || {}; | ||
| 515 | |||
| 516 | my %ip_index; | ||
| 517 | foreach my $ip ( keys %$ip_index ) { | ||
| 518 | my $iid = $ip_index->{$ip}; | ||
| 519 | next unless defined $iid; | ||
| 520 | |||
| 521 | $ip_index{$ip} = $iid; | ||
| 522 | } | ||
| 523 | |||
| 524 | foreach my $iid ( keys %$if_ip ) { | ||
| 525 | my $ip = $if_ip->{$iid}; | ||
| 526 | next unless defined $ip; | ||
| 527 | next if ( defined $partial and $partial !~ /$ip/ ); | ||
| 528 | |||
| 529 | $ip_index{$ip} = $iid; | ||
| 530 | } | ||
| 531 | |||
| 532 | return \%ip_index; | ||
| 533 | } | ||
| 534 | |||
| 535 | sub ip_netmask { | ||
| 536 | my $airespace = shift; | ||
| 537 | my $partial = shift; | ||
| 538 | |||
| 539 | my $ip_mask = $airespace->SUPER::ip_netmask($partial) || {}; | ||
| 540 | my $if_ip = $airespace->airespace_if_ip() || {}; | ||
| 541 | my $if_mask = $airespace->airespace_if_mask() || {}; | ||
| 542 | |||
| 543 | my %ip_netmask; | ||
| 544 | foreach my $ip ( keys %$ip_mask ) { | ||
| 545 | my $mask = $ip_mask->{$ip}; | ||
| 546 | next unless defined $mask; | ||
| 547 | |||
| 548 | $ip_netmask{$ip} = $mask; | ||
| 549 | } | ||
| 550 | |||
| 551 | foreach my $iid ( keys %$if_mask ) { | ||
| 552 | my $ip = $if_ip->{$iid}; | ||
| 553 | next unless defined $ip; | ||
| 554 | next if ( defined $partial and $partial !~ /$ip/ ); | ||
| 555 | my $mask = $if_mask->{$iid}; | ||
| 556 | next unless defined $mask; | ||
| 557 | |||
| 558 | $ip_netmask{$ip} = $mask; | ||
| 559 | } | ||
| 560 | |||
| 561 | return \%ip_netmask; | ||
| 562 | } | ||
| 563 | |||
| 564 | # Wireless switches do not support the standard Bridge MIB | ||
| 565 | sub bp_index { | ||
| 566 | my $airespace = shift; | ||
| 567 | my $partial = shift; | ||
| 568 | |||
| 569 | my $i_index = $airespace->i_index($partial) || {}; | ||
| 570 | |||
| 571 | my %bp_index; | ||
| 572 | foreach my $iid ( keys %$i_index ) { | ||
| 573 | my $index = $i_index->{$iid}; | ||
| 574 | next unless defined $index; | ||
| 575 | |||
| 576 | $bp_index{$index} = $iid; | ||
| 577 | } | ||
| 578 | |||
| 579 | return \%bp_index; | ||
| 580 | } | ||
| 581 | |||
| 582 | sub fw_mac { | ||
| 583 | my $airespace = shift; | ||
| 584 | my $partial = shift; | ||
| 585 | |||
| 586 | return $airespace->SUPER::fw_mac($partial); | ||
| 587 | } | ||
| 588 | |||
| 589 | sub fw_port { | ||
| 590 | my $airespace = shift; | ||
| 591 | my $partial = shift; | ||
| 592 | |||
| 593 | my $sta_mac = $airespace->airespace_sta_mac($partial) || {}; | ||
| 594 | my $sta_slot = $airespace->airespace_sta_slot($partial) || {}; | ||
| 595 | |||
| 596 | my %fw_port; | ||
| 597 | foreach my $iid ( keys %$sta_mac ) { | ||
| 598 | my $mac = $sta_mac->{$iid}; | ||
| 599 | next unless defined $mac; | ||
| 600 | my $slot = $sta_slot->{$iid}; | ||
| 601 | next unless defined $slot; | ||
| 602 | |||
| 603 | $fw_port{$iid} = "$mac.$slot"; | ||
| 604 | } | ||
| 605 | |||
| 606 | return \%fw_port; | ||
| 607 | } | ||
| 608 | |||
| 609 | # Wireless controllers have no Q-BRIDGE-MIB forwarding table, but the mobile | ||
| 610 | # station table says which VLAN each client was placed on. Keyed by the same | ||
| 611 | # index as fw_mac() and fw_port() so Netdisco macsuck can pair them up. | ||
| 612 | sub qb_fw_vlan { | ||
| 613 | my $airespace = shift; | ||
| 614 | my $partial = shift; | ||
| 615 | |||
| 616 | my $sta_vlan = $airespace->airespace_sta_vlan($partial) || {}; | ||
| 617 | |||
| 618 | my %qb_fw_vlan; | ||
| 619 | foreach my $iid ( keys %$sta_vlan ) { | ||
| 620 | my $vlan = $sta_vlan->{$iid}; | ||
| 621 | |||
| 622 | # 0 means "no VLAN known"; leave it out so callers fall back to 0 | ||
| 623 | next unless defined $vlan and $vlan =~ /^\d+$/ and $vlan > 0; | ||
| 624 | |||
| 625 | $qb_fw_vlan{$iid} = $vlan; | ||
| 626 | } | ||
| 627 | |||
| 628 | return \%qb_fw_vlan; | ||
| 629 | } | ||
| 630 | |||
| 631 | # A wireless controller has no VLAN table to walk, yet the mobile station | ||
| 632 | # table names the interface of every client next to its VLAN ID. That is the | ||
| 633 | # only place the controller says which name goes with which VLAN. | ||
| 634 | sub airespace_vlan_names { | ||
| 635 | my $airespace = shift; | ||
| 636 | |||
| 637 | my $sta_vlan = $airespace->airespace_sta_vlan() || {}; | ||
| 638 | my $sta_if = $airespace->airespace_sta_if() || {}; | ||
| 639 | |||
| 640 | # how many clients report each name on each VLAN | ||
| 641 | my %seen; | ||
| 642 | foreach my $iid ( keys %$sta_vlan ) { | ||
| 643 | my $vlan = $sta_vlan->{$iid}; | ||
| 644 | next unless defined $vlan and $vlan =~ /^\d+$/ and $vlan > 0; | ||
| 645 | |||
| 646 | my $name = $sta_if->{$iid}; | ||
| 647 | next unless defined $name; | ||
| 648 | $name =~ s/^\s+|\s+$//g; | ||
| 649 | next unless length $name; | ||
| 650 | |||
| 651 | ++$seen{$vlan}{$name}; | ||
| 652 | } | ||
| 653 | |||
| 654 | # clients on one VLAN can report different names: the most common wins, | ||
| 655 | # and ties go alphabetically so every walk gives the same answer | ||
| 656 | my %vlan_names; | ||
| 657 | foreach my $vlan ( keys %seen ) { | ||
| 658 | my $count = $seen{$vlan}; | ||
| 659 | my ($best) = sort { $count->{$b} <=> $count->{$a} or $a cmp $b } | ||
| 660 | keys %$count; | ||
| 661 | $vlan_names{$vlan} = $best; | ||
| 662 | } | ||
| 663 | |||
| 664 | return \%vlan_names; | ||
| 665 | } | ||
| 666 | |||
| 667 | sub i_ssidlist { | ||
| 668 | my $airespace = shift; | ||
| 669 | my $partial = shift; | ||
| 670 | |||
| 671 | my $apif_override = $airespace->airespace_apif_oride($partial) || {}; | ||
| 672 | my $apif_type = $airespace->airespace_apif_type($partial) || {}; | ||
| 673 | my $ssids = $airespace->airespace_ess_ssid() || {}; | ||
| 674 | my $ssid_policy = $airespace->airespace_ess_radio_pol() || {}; | ||
| 675 | my $ssid_status = $airespace->airespace_ess_status() || {}; | ||
| 676 | my $ovride_ssids = $airespace->airespace_oride_ssid($partial) || {}; | ||
| 677 | |||
| 678 | my %i_ssidlist; | ||
| 679 | foreach my $iid ( keys %$apif_override ) { | ||
| 680 | my $override = $apif_override->{$iid}; | ||
| 681 | next unless defined $override; | ||
| 682 | |||
| 683 | next unless $override =~ /disable/i; | ||
| 684 | my $ap_type = $apif_type->{$iid}; | ||
| 685 | next unless defined $ap_type; | ||
| 686 | $ap_type =~ s/dot11//; | ||
| 687 | |||
| 688 | foreach my $idx ( keys %$ssids ) { | ||
| 689 | my $ssid = $ssids->{$idx}; | ||
| 690 | next unless defined $ssid; | ||
| 691 | my $status = $ssid_status->{$idx}; | ||
| 692 | next unless defined $status; | ||
| 693 | next if ( $status =~ /disable/ ); | ||
| 694 | my $policy = $ssid_policy->{$idx}; | ||
| 695 | next unless $policy =~ /$ap_type/ or $policy =~ /all/; | ||
| 696 | |||
| 697 | $i_ssidlist{"$iid.$idx"} = $ssid; | ||
| 698 | } | ||
| 699 | next; | ||
| 700 | } | ||
| 701 | |||
| 702 | foreach my $iid ( keys %$ovride_ssids ) { | ||
| 703 | my $ssid = $ovride_ssids->{$iid}; | ||
| 704 | next unless $ssid; | ||
| 705 | |||
| 706 | $i_ssidlist{$iid} = $ssid; | ||
| 707 | } | ||
| 708 | |||
| 709 | return \%i_ssidlist; | ||
| 710 | } | ||
| 711 | |||
| 712 | sub i_ssidbcast { | ||
| 713 | my $airespace = shift; | ||
| 714 | my $partial = shift; | ||
| 715 | |||
| 716 | my $ssidlist = $airespace->i_ssidlist($partial) || {}; | ||
| 717 | my $bc_mode = $airespace->airespace_bssid_mode() || 'enable'; | ||
| 718 | my $ess_bc_mode = $airespace->airespace_ess_bcast() || {}; | ||
| 719 | my $ssids = $airespace->airespace_ess_ssid() || {}; | ||
| 720 | my %ssid_index = reverse %$ssids; | ||
| 721 | |||
| 722 | my %bcmap = qw/enable 1 disable 0/; | ||
| 723 | my $broadcast = $bcmap{$bc_mode}; | ||
| 724 | |||
| 725 | my %i_ssidbcast; | ||
| 726 | foreach my $iid ( keys %$ssidlist ) { | ||
| 727 | if (!$broadcast) { | ||
| 728 | $i_ssidbcast{$iid} = $broadcast; | ||
| 729 | next; | ||
| 730 | } | ||
| 731 | else { | ||
| 732 | my $ssid = $ssidlist->{$iid}; | ||
| 733 | my $ssid_idx = $ssid_index{$ssid}; | ||
| 734 | my $bc = $ess_bc_mode->{$ssid_idx}; | ||
| 735 | $i_ssidbcast{$iid} = $bcmap{$bc}; | ||
| 736 | } | ||
| 737 | } | ||
| 738 | |||
| 739 | return \%i_ssidbcast; | ||
| 740 | } | ||
| 741 | |||
| 742 | # Secret decoder ring for BSSID: https://supportforums.cisco.com/docs/DOC-2935 | ||
| 743 | # We need radio base MAC, SSID index, radio band, and whether AP is | ||
| 744 | # VxWorks or IOS based then we can do the arithmetic | ||
| 745 | # DOC-2935 now lives at https://community.cisco.com/t5/wireless-mobility-knowledge-base/a-different-mac-address-is-shown-than-the-actual-mac-address-of/ta-p/3131579 | ||
| 746 | |||
| 747 | sub i_ssidmac { | ||
| 748 | my $airespace = shift; | ||
| 749 | my $partial = shift; | ||
| 750 | |||
| 751 | my $ssidlist = $airespace->i_ssidlist($partial) || {}; | ||
| 752 | my $apif_type = $airespace->airespace_apif_type() || {}; | ||
| 753 | my $ap_ios = $airespace->bsnAPIOSVersion() || {}; | ||
| 754 | |||
| 755 | my %i_ssidmac; | ||
| 756 | foreach my $oid ( keys %$ssidlist ) { | ||
| 757 | |||
| 758 | my @parts = split( /\./, $oid ); | ||
| 759 | my $ssid_idx = pop(@parts); | ||
| 760 | my $slot = pop(@parts); | ||
| 761 | my $last = pop(@parts); | ||
| 762 | |||
| 763 | my $iid = $oid; | ||
| 764 | |||
| 765 | # Get radio band | ||
| 766 | $iid =~ s/\.\d+$//; | ||
| 767 | my $ap_type = $apif_type->{$iid}; | ||
| 768 | |||
| 769 | # Determine if IOS based | ||
| 770 | $iid =~ s/\.\d+$//; | ||
| 771 | my $ios = $ap_ios->{$iid} || ''; | ||
| 772 | |||
| 773 | # 17 can be used as index for 3rd Party AP's. We only have one | ||
| 774 | # hexadecimal digit to work with so skip if outside the range | ||
| 775 | if ( $ssid_idx > 0 and $ssid_idx < 17 ) { | ||
| 776 | |||
| 777 | # Four cases: | ||
| 778 | # IOS and 2.4Ghz count up, starts at zero | ||
| 779 | if ( $ios and $ap_type =~ /b$/ ) { | ||
| 780 | $last = $last + ( $ssid_idx - 1 ); | ||
| 781 | } | ||
| 782 | |||
| 783 | # IOS and 5Ghz - count down from maximum of 16 | ||
| 784 | elsif ( $ios and $ap_type =~ /a$/ ) { | ||
| 785 | $last = $last + ( 16 - $ssid_idx ); | ||
| 786 | } | ||
| 787 | |||
| 788 | # VxWorks and 5Ghz - count up, starts at zero | ||
| 789 | elsif ( !$ios and $ap_type =~ /a$/ ) { | ||
| 790 | $last = $last + ( $ssid_idx - 1 ); | ||
| 791 | } | ||
| 792 | |||
| 793 | # VxWorks and 2.4Ghz - count down from maximum of 16 | ||
| 794 | else { | ||
| 795 | $last = $last + ( 16 - $ssid_idx ); | ||
| 796 | } | ||
| 797 | } | ||
| 798 | |||
| 799 | push( @parts, $last ); | ||
| 800 | my $bssid = join( ':', map { sprintf( "%02x", $_ ) } @parts ); | ||
| 801 | $i_ssidmac{$oid} = $bssid; | ||
| 802 | } | ||
| 803 | |||
| 804 | return \%i_ssidmac; | ||
| 805 | } | ||
| 806 | |||
| 807 | sub i_80211channel { | ||
| 808 | my $airespace = shift; | ||
| 809 | my $partial = shift; | ||
| 810 | |||
| 811 | my $ch_list = $airespace->airespace_apif_ch_num($partial) || {}; | ||
| 812 | |||
| 813 | my %i_80211channel; | ||
| 814 | foreach my $iid ( keys %$ch_list ) { | ||
| 815 | my $ch = $ch_list->{$iid}; | ||
| 816 | $ch =~ s/ch//; | ||
| 817 | $i_80211channel{$iid} = $ch; | ||
| 818 | } | ||
| 819 | |||
| 820 | return \%i_80211channel; | ||
| 821 | } | ||
| 822 | |||
| 823 | sub dot11_cur_tx_pwr_mw { | ||
| 824 | my $airespace = shift; | ||
| 825 | my $partial = shift; | ||
| 826 | my $cur = $airespace->airespace_apif_power($partial); | ||
| 827 | my $pwr_abs = $airespace->airespace_apif_a_pwr($partial); | ||
| 828 | |||
| 829 | my $dot11_cur_tx_pwr_mw = {}; | ||
| 830 | foreach my $idx ( keys %$cur ) { | ||
| 831 | my $pwr = $cur->{$idx}; | ||
| 832 | if ( $pwr >= 1 && $pwr <= 8 ) { | ||
| 833 | |||
| 834 | my @pwr_list = split(/,/, $pwr_abs->{$idx} ); | ||
| 835 | $dot11_cur_tx_pwr_mw->{$idx} = $pwr_list[$pwr-1]; | ||
| 836 | |||
| 837 | } | ||
| 838 | else { | ||
| 839 | next; | ||
| 840 | } | ||
| 841 | } | ||
| 842 | return $dot11_cur_tx_pwr_mw; | ||
| 843 | } | ||
| 844 | |||
| 845 | # Pseudo ENTITY-MIB methods | ||
| 846 | |||
| 847 | sub e_index { | ||
| 848 | my $airespace = shift; | ||
| 849 | |||
| 850 | my $ap_model = $airespace->airespace_ap_model() || {}; | ||
| 851 | |||
| 852 | my %e_index; | ||
| 853 | |||
| 854 | # Chassis | ||
| 855 | $e_index{1} = 1; | ||
| 856 | |||
| 857 | # We're going to hack an index to capture APs | ||
| 858 | foreach my $idx ( keys %$ap_model ) { | ||
| 859 | |||
| 860 | # Create the integer index by joining the last three octets of the MAC. | ||
| 861 | # Hopefully, this will be unique since the manufacturer should be | ||
| 862 | # limited to Airespace and Cisco. We can't use the entire MAC since | ||
| 863 | # we would exceed the intger size limit. | ||
| 864 | if ( $idx =~ /(\d+\.\d+\.\d+)$/ ) { | ||
| 865 | my $index = int( | ||
| 866 | join( '', map { sprintf "%03d", $_ } split /\./, $1 ) ); | ||
| 867 | $e_index{$idx} = $index; | ||
| 868 | } | ||
| 869 | } | ||
| 870 | return \%e_index; | ||
| 871 | } | ||
| 872 | |||
| 873 | sub e_class { | ||
| 874 | my $airespace = shift; | ||
| 875 | |||
| 876 | my $e_idx = $airespace->e_index() || {}; | ||
| 877 | |||
| 878 | my %e_class; | ||
| 879 | foreach my $iid ( keys %$e_idx ) { | ||
| 880 | if ( $iid eq 1 ) { | ||
| 881 | $e_class{$iid} = 'chassis'; | ||
| 882 | } | ||
| 883 | |||
| 884 | # This isn't a valid PhysicalClass, but we're hacking this anyway | ||
| 885 | else { | ||
| 886 | $e_class{$iid} = 'ap'; | ||
| 887 | } | ||
| 888 | } | ||
| 889 | return \%e_class; | ||
| 890 | } | ||
| 891 | |||
| 892 | sub e_name { | ||
| 893 | my $airespace = shift; | ||
| 894 | |||
| 895 | my $ap_name = $airespace->airespace_ap_name() || {}; | ||
| 896 | |||
| 897 | my %e_name; | ||
| 898 | |||
| 899 | # Chassis | ||
| 900 | $e_name{1} = 'WLAN Controller'; | ||
| 901 | |||
| 902 | # APs | ||
| 903 | foreach my $iid ( keys %$ap_name ) { | ||
| 904 | $e_name{$iid} = 'AP'; | ||
| 905 | } | ||
| 906 | return \%e_name; | ||
| 907 | } | ||
| 908 | |||
| 909 | sub e_descr { | ||
| 910 | my $airespace = shift; | ||
| 911 | |||
| 912 | my $ap_model = $airespace->airespace_ap_model() || {}; | ||
| 913 | my $ap_name = $airespace->airespace_ap_name() || {}; | ||
| 914 | my $ap_loc = $airespace->airespace_ap_loc() || {}; | ||
| 915 | |||
| 916 | my %e_descr; | ||
| 917 | |||
| 918 | # Chassis | ||
| 919 | $e_descr{1} = $airespace->airespace_prod_name(); | ||
| 920 | |||
| 921 | # APs | ||
| 922 | foreach my $iid ( keys %$ap_name ) { | ||
| 923 | my $name = $ap_name->{$iid}; | ||
| 924 | next unless defined $name; | ||
| 925 | my $model = $ap_model->{$iid} || 'AP'; | ||
| 926 | my $loc = $ap_loc->{$iid} || 'unknown'; | ||
| 927 | |||
| 928 | $e_descr{$iid} = "$model: $name ($loc)"; | ||
| 929 | } | ||
| 930 | return \%e_descr; | ||
| 931 | } | ||
| 932 | |||
| 933 | sub e_model { | ||
| 934 | my $airespace = shift; | ||
| 935 | |||
| 936 | my $ap_model = $airespace->airespace_ap_model() || {}; | ||
| 937 | |||
| 938 | my %e_model; | ||
| 939 | |||
| 940 | # Chassis | ||
| 941 | $e_model{1} = $airespace->airespace_model(); | ||
| 942 | |||
| 943 | # APs | ||
| 944 | foreach my $iid ( keys %$ap_model ) { | ||
| 945 | my $model = $ap_model->{$iid}; | ||
| 946 | next unless defined $model; | ||
| 947 | |||
| 948 | $e_model{$iid} = $model; | ||
| 949 | } | ||
| 950 | return \%e_model; | ||
| 951 | } | ||
| 952 | |||
| 953 | sub e_type { | ||
| 954 | my $airespace = shift; | ||
| 955 | |||
| 956 | my $ap_type = $airespace->airespace_ap_type() || {}; | ||
| 957 | |||
| 958 | my %e_type; | ||
| 959 | |||
| 960 | # Chassis | ||
| 961 | $e_type{1} = $airespace->airespace_type(); | ||
| 962 | |||
| 963 | # APs | ||
| 964 | foreach my $iid ( keys %$ap_type ) { | ||
| 965 | my $type = $ap_type->{$iid}; | ||
| 966 | next unless defined $type; | ||
| 967 | |||
| 968 | $e_type{$iid} = $type; | ||
| 969 | } | ||
| 970 | return \%e_type; | ||
| 971 | } | ||
| 972 | |||
| 973 | sub e_fwver { | ||
| 974 | my $airespace = shift; | ||
| 975 | |||
| 976 | my $ap_fw = $airespace->airespace_ap_fw() || {}; | ||
| 977 | |||
| 978 | my %e_fwver; | ||
| 979 | |||
| 980 | # Chassis | ||
| 981 | $e_fwver{1} = $airespace->airespace_maint_ver(); | ||
| 982 | |||
| 983 | # APs | ||
| 984 | foreach my $iid ( keys %$ap_fw ) { | ||
| 985 | my $fw = $ap_fw->{$iid}; | ||
| 986 | next unless defined $fw; | ||
| 987 | |||
| 988 | $e_fwver{$iid} = $fw; | ||
| 989 | } | ||
| 990 | return \%e_fwver; | ||
| 991 | } | ||
| 992 | |||
| 993 | sub e_vendor { | ||
| 994 | my $airespace = shift; | ||
| 995 | |||
| 996 | my $e_idx = $airespace->e_index() || {}; | ||
| 997 | |||
| 998 | my %e_vendor; | ||
| 999 | foreach my $iid ( keys %$e_idx ) { | ||
| 1000 | $e_vendor{$iid} = 'cisco'; | ||
| 1001 | } | ||
| 1002 | return \%e_vendor; | ||
| 1003 | } | ||
| 1004 | |||
| 1005 | sub e_serial { | ||
| 1006 | my $airespace = shift; | ||
| 1007 | |||
| 1008 | my $ap_serial = $airespace->airespace_ap_serial() || {}; | ||
| 1009 | |||
| 1010 | my %e_serial; | ||
| 1011 | |||
| 1012 | # Chassis | ||
| 1013 | $e_serial{1} = $airespace->airespace_serial(); | ||
| 1014 | |||
| 1015 | # APs | ||
| 1016 | foreach my $iid ( keys %$ap_serial ) { | ||
| 1017 | my $serial = $ap_serial->{$iid}; | ||
| 1018 | next unless defined $serial; | ||
| 1019 | |||
| 1020 | $e_serial{$iid} = $serial; | ||
| 1021 | } | ||
| 1022 | return \%e_serial; | ||
| 1023 | } | ||
| 1024 | |||
| 1025 | sub e_pos { | ||
| 1026 | my $airespace = shift; | ||
| 1027 | |||
| 1028 | my $e_idx = $airespace->e_index() || {}; | ||
| 1029 | |||
| 1030 | my %e_pos; | ||
| 1031 | my $pos = 0; | ||
| 1032 | foreach my $iid ( sort keys %$e_idx ) { | ||
| 1033 | if ( $iid eq 1 ) { | ||
| 1034 | $e_pos{$iid} = -1; | ||
| 1035 | next; | ||
| 1036 | } | ||
| 1037 | else { | ||
| 1038 | $pos++; | ||
| 1039 | $e_pos{$iid} = $pos; | ||
| 1040 | } | ||
| 1041 | } | ||
| 1042 | return \%e_pos; | ||
| 1043 | } | ||
| 1044 | |||
| 1045 | sub e_swver { | ||
| 1046 | my $airespace = shift; | ||
| 1047 | |||
| 1048 | my $ap_sw = $airespace->airespace_ap_sw() || {}; | ||
| 1049 | |||
| 1050 | my %e_swver; | ||
| 1051 | |||
| 1052 | # Chassis | ||
| 1053 | $e_swver{1} = $airespace->airespace_os(); | ||
| 1054 | |||
| 1055 | # APs | ||
| 1056 | foreach my $iid ( keys %$ap_sw ) { | ||
| 1057 | my $sw = $ap_sw->{$iid}; | ||
| 1058 | next unless defined $sw; | ||
| 1059 | |||
| 1060 | $e_swver{$iid} = $sw; | ||
| 1061 | } | ||
| 1062 | return \%e_swver; | ||
| 1063 | } | ||
| 1064 | |||
| 1065 | sub e_parent { | ||
| 1066 | my $airespace = shift; | ||
| 1067 | |||
| 1068 | my $e_idx = $airespace->e_index() || {}; | ||
| 1069 | |||
| 1070 | my %e_parent; | ||
| 1071 | foreach my $iid ( sort keys %$e_idx ) { | ||
| 1072 | if ( $iid eq 1 ) { | ||
| 1073 | $e_parent{$iid} = 0; | ||
| 1074 | next; | ||
| 1075 | } | ||
| 1076 | else { | ||
| 1077 | $e_parent{$iid} = 1; | ||
| 1078 | } | ||
| 1079 | } | ||
| 1080 | return \%e_parent; | ||
| 1081 | } | ||
| 1082 | |||
| 1083 | # arpnip: | ||
| 1084 | # | ||
| 1085 | # This is the controller snooping on the MAC->IP mappings. | ||
| 1086 | # Pretending this is arpnip data allows us to get MAC->IP | ||
| 1087 | # mappings even for stations that only communicate locally. | ||
| 1088 | # Also use the controller's knowledge of the APs' MAC and | ||
| 1089 | # IP addresses to augment the data. | ||
| 1090 | |||
| 1091 | sub at_paddr { | ||
| 1092 | my $airespace = shift; | ||
| 1093 | my $mac2ip = $airespace->airespace_sta_ip(); | ||
| 1094 | my $apethermac = $airespace->airespace_ap_ethermac(); | ||
| 1095 | |||
| 1096 | my $ret = {}; | ||
| 1097 | foreach my $idx ( keys %$mac2ip ) { | ||
| 1098 | next if ( $mac2ip->{ $idx } eq '0.0.0.0' ); | ||
| 1099 | my $mac = join( ":", map { sprintf "%02x", $_ } split /\./, $idx ); | ||
| 1100 | $ret->{$idx} = $mac; | ||
| 1101 | } | ||
| 1102 | foreach my $idx ( keys %$apethermac ) { | ||
| 1103 | $ret->{$idx} = $apethermac->{$idx}; | ||
| 1104 | } | ||
| 1105 | return $ret; | ||
| 1106 | } | ||
| 1107 | |||
| 1108 | sub at_netaddr { | ||
| 1109 | my $airespace = shift; | ||
| 1110 | my $mac2ip = $airespace->airespace_sta_ip(); | ||
| 1111 | my $ap2ip = $airespace->airespace_ap_ip(); | ||
| 1112 | |||
| 1113 | my $ret = {}; | ||
| 1114 | foreach my $idx ( keys %$mac2ip ) { | ||
| 1115 | next if ( $mac2ip->{ $idx } eq '0.0.0.0' ); | ||
| 1116 | $ret->{$idx} = $mac2ip->{ $idx }; | ||
| 1117 | } | ||
| 1118 | foreach my $idx ( keys %$ap2ip ) { | ||
| 1119 | $ret->{$idx} = $ap2ip->{ $idx }; | ||
| 1120 | } | ||
| 1121 | return $ret; | ||
| 1122 | } | ||
| 1123 | |||
| 1124 | sub munge_64bits { | ||
| 1125 | # The controller sometimes hands off a ridiculous value for packets. | ||
| 1126 | # Just truncate it to 32 bits. | ||
| 1127 | my $value = shift; | ||
| 1128 | return $value & 0xffffffff; | ||
| 1129 | } | ||
| 1130 | |||
| 1131 | 1; | ||
| 1132 | __END__ |