| 1 | # SNMP::Info::Layer3::C9800 | ||
| 2 | # | ||
| 3 | # Copyright (c) 2026 The SNMP::Info Developers | ||
| 4 | # All rights reserved. | ||
| 5 | |||
| 6 | package SNMP::Info::Layer3::C9800; | ||
| 7 | |||
| 8 | use strict; | ||
| 9 | use warnings; | ||
| 10 | use Exporter; | ||
| 11 | use SNMP::Info::CiscoStats; | ||
| 12 | use SNMP::Info::CiscoVTP; | ||
| 13 | use SNMP::Info::Entity; | ||
| 14 | use SNMP::Info::EtherLike; | ||
| 15 | use SNMP::Info::LLDP; | ||
| 16 | use SNMP::Info::Layer2::Airespace; | ||
| 17 | |||
| 18 | our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE); | ||
| 19 | |||
| 20 | @SNMP::Info::Layer3::C9800::ISA = qw/ | ||
| 21 | SNMP::Info::Layer2::Airespace | ||
| 22 | SNMP::Info::CiscoVTP | ||
| 23 | SNMP::Info::CiscoStats | ||
| 24 | SNMP::Info::LLDP | ||
| 25 | SNMP::Info::EtherLike | ||
| 26 | Exporter | ||
| 27 | /; | ||
| 28 | |||
| 29 | @SNMP::Info::Layer3::C9800::EXPORT_OK = qw//; | ||
| 30 | |||
| 31 | $VERSION = '3.985003'; | ||
| 32 | |||
| 33 | %MIBS = ( | ||
| 34 | %SNMP::Info::Layer2::Airespace::MIBS, | ||
| 35 | %SNMP::Info::CiscoVTP::MIBS, | ||
| 36 | %SNMP::Info::CiscoStats::MIBS, | ||
| 37 | %SNMP::Info::LLDP::MIBS, | ||
| 38 | %SNMP::Info::EtherLike::MIBS, | ||
| 39 | %SNMP::Info::Entity::MIBS, | ||
| 40 | 'CISCO-LWAPP-CDP-MIB' => 'clcCdpApCacheNeighInterface', | ||
| 41 | ); | ||
| 42 | |||
| 43 | %GLOBALS = ( | ||
| 44 | %SNMP::Info::Layer2::Airespace::GLOBALS, | ||
| 45 | %SNMP::Info::CiscoVTP::GLOBALS, | ||
| 46 | %SNMP::Info::CiscoStats::GLOBALS, | ||
| 47 | %SNMP::Info::LLDP::GLOBALS, | ||
| 48 | %SNMP::Info::EtherLike::GLOBALS, | ||
| 49 | 'c9800_os_ver' => '.1.3.6.1.2.1.16.19.2.0', | ||
| 50 | 'serial1' => | ||
| 51 | '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0 | ||
| 52 | ); | ||
| 53 | |||
| 54 | # CiscoVTP after Layer2::Airespace: v_name is vtpVlanName, the controller's | ||
| 55 | # VLANs, not Q-BRIDGE dot1qVlanStaticName, which the 9800 leaves empty | ||
| 56 | %FUNCS = ( | ||
| 57 | %SNMP::Info::Layer2::Airespace::FUNCS, | ||
| 58 | %SNMP::Info::CiscoVTP::FUNCS, | ||
| 59 | %SNMP::Info::CiscoStats::FUNCS, | ||
| 60 | %SNMP::Info::LLDP::FUNCS, | ||
| 61 | %SNMP::Info::EtherLike::FUNCS, | ||
| 62 | # CISCO-LWAPP-AP-MIB::cLApRadioWlanInfoTable | ||
| 63 | 'c9800_radio_wlan_ssid' => 'cLApRadioWlanSsid', | ||
| 64 | 'c9800_radio_wlan_bssid' => 'cLApRadioWlanBssid', | ||
| 65 | 'c9800_entity_descr' => 'entPhysicalDescr', | ||
| 66 | 'c9800_entity_class' => 'entPhysicalClass', | ||
| 67 | 'c9800_entity_name' => 'entPhysicalName', | ||
| 68 | 'c9800_entity_model' => 'entPhysicalModelName', | ||
| 69 | 'c9800_entity_type' => 'entPhysicalVendorType', | ||
| 70 | 'c9800_entity_fwver' => 'entPhysicalFirmwareRev', | ||
| 71 | 'c9800_entity_vendor' => 'entPhysicalMfgName', | ||
| 72 | 'c9800_entity_serial' => 'entPhysicalSerialNum', | ||
| 73 | 'c9800_entity_pos' => 'entPhysicalParentRelPos', | ||
| 74 | 'c9800_entity_swver' => 'entPhysicalSoftwareRev', | ||
| 75 | 'c9800_entity_parent' => 'entPhysicalContainedIn', | ||
| 76 | 'c9800_cdp_name' => 'clcCdpApCacheNeighName', | ||
| 77 | 'c9800_cdp_address' => 'clcCdpApCacheNeighAddress', | ||
| 78 | 'c9800_cdp_interface' => 'clcCdpApCacheNeighInterface', | ||
| 79 | 'c9800_ap_vlan' => 'bsnAPGroupVlanName', | ||
| 80 | 'c9800_ap_ios_ver' => 'bsnAPIOSVersion', | ||
| 81 | 'c9800_ap_oper' => 'bsnAPOperationStatus', | ||
| 82 | 'c9800_ap_primary' => 'bsnAPPrimaryMwarName', | ||
| 83 | 'c9800_ap_secondary' => 'bsnAPSecondaryMwarName', | ||
| 84 | # CISCO-LWAPP-AP-MIB::cLApTable | ||
| 85 | 'c9800_ap_site_tag' => 'cLApSiteTagName', | ||
| 86 | 'c9800_ap_rf_tag' => 'cLApRfTagName', | ||
| 87 | 'c9800_ap_policy_tag' => 'cLApPolicyTagName', | ||
| 88 | 'c9800_ap_tag_source' => 'cLApTagSource', | ||
| 89 | ); | ||
| 90 | |||
| 91 | %MUNGE = ( | ||
| 92 | %SNMP::Info::Layer2::Airespace::MUNGE, | ||
| 93 | %SNMP::Info::CiscoVTP::MUNGE, | ||
| 94 | %SNMP::Info::CiscoStats::MUNGE, | ||
| 95 | %SNMP::Info::LLDP::MUNGE, | ||
| 96 | %SNMP::Info::EtherLike::MUNGE, | ||
| 97 | 'c9800_radio_wlan_bssid' => \&SNMP::Info::munge_mac, | ||
| 98 | 'c9800_cdp_address' => \&SNMP::Info::munge_ip, | ||
| 99 | 'c9800_entity_type' => \&SNMP::Info::munge_e_type, | ||
| 100 | ); | ||
| 101 | |||
| 102 | sub serial { | ||
| 103 | my $c9800 = shift; | ||
| 104 | my $descr = $c9800->c9800_entity_descr() || {}; | ||
| 105 | my $serials = $c9800->c9800_entity_serial() || {}; | ||
| 106 | |||
| 107 | my @chassis_serials = map { $serials->{$_} } | ||
| 108 | grep { | ||
| 109 | defined $descr->{$_} | ||
| 110 | && $descr->{$_} =~ /chassis/i | ||
| 111 | && defined $serials->{$_} | ||
| 112 | && $serials->{$_} ne '' | ||
| 113 | } sort { $a <=> $b } keys %{$descr}; | ||
| 114 | |||
| 115 | return unless @chassis_serials; | ||
| 116 | return join ' ', @chassis_serials; | ||
| 117 | } | ||
| 118 | |||
| 119 | sub os_ver { | ||
| 120 | my $c9800 = shift; | ||
| 121 | my $os_ver = $c9800->c9800_os_ver(); | ||
| 122 | return $os_ver if defined $os_ver && $os_ver ne ''; | ||
| 123 | |||
| 124 | return SNMP::Info::CiscoStats::os_ver($c9800); | ||
| 125 | } | ||
| 126 | |||
| 127 | sub os { | ||
| 128 | my $c9800 = shift; | ||
| 129 | return SNMP::Info::CiscoStats::os($c9800); | ||
| 130 | } | ||
| 131 | |||
| 132 | # FlexConnect clients sit on VLANs the controller never defines, so the | ||
| 133 | # controller's VTP table misses them. Take those names from the client table, | ||
| 134 | # but never replace a name someone gave the VLAN: only a gap, or the default | ||
| 135 | # a switch invents ("VLAN0415"). | ||
| 136 | sub v_name { | ||
| 137 | my $c9800 = shift; | ||
| 138 | my $partial = shift; | ||
| 139 | |||
| 140 | my $v_name = { %{ $c9800->SUPER::v_name($partial) || {} } }; | ||
| 141 | my $names = $c9800->airespace_vlan_names() || {}; | ||
| 142 | my %key_for = map { ( ( split /\./ )[-1] => $_ ) } keys %$v_name; | ||
| 143 | |||
| 144 | foreach my $vlan ( keys %$names ) { | ||
| 145 | my $key = $key_for{$vlan} // $vlan; | ||
| 146 | next if defined $partial and $partial ne $key; | ||
| 147 | |||
| 148 | my $have = $v_name->{$key}; | ||
| 149 | next | ||
| 150 | if defined $have | ||
| 151 | and length $have | ||
| 152 | and $have !~ /^VLAN\s?0*\Q$vlan\E$/i; | ||
| 153 | |||
| 154 | $v_name->{$key} = $names->{$vlan}; | ||
| 155 | } | ||
| 156 | |||
| 157 | return $v_name; | ||
| 158 | } | ||
| 159 | |||
| 160 | # VTP keys are domain.vlan, client-only VLANs are the bare VLAN ID | ||
| 161 | sub v_index { | ||
| 162 | my $c9800 = shift; | ||
| 163 | my $partial = shift; | ||
| 164 | |||
| 165 | my $v_name = $c9800->v_name($partial) || {}; | ||
| 166 | my %v_index = map { ( $_ => ( split /\./ )[-1] ) } keys %$v_name; | ||
| 167 | return \%v_index; | ||
| 168 | } | ||
| 169 | |||
| 170 | sub i_vlan { | ||
| 171 | my $c9800 = shift; | ||
| 172 | my $partial = shift; | ||
| 173 | |||
| 174 | return { | ||
| 175 | %{ $c9800->SUPER::i_vlan($partial) || {} }, | ||
| 176 | %{ SNMP::Info::CiscoVTP::i_vlan( $c9800, $partial ) || {} }, | ||
| 177 | }; | ||
| 178 | } | ||
| 179 | |||
| 180 | sub i_vlan_membership { | ||
| 181 | my $c9800 = shift; | ||
| 182 | my $partial = shift; | ||
| 183 | |||
| 184 | return { | ||
| 185 | %{ $c9800->SUPER::i_vlan_membership($partial) || {} }, | ||
| 186 | %{ SNMP::Info::CiscoVTP::i_vlan_membership( $c9800, $partial ) || {} | ||
| 187 | }, | ||
| 188 | }; | ||
| 189 | } | ||
| 190 | |||
| 191 | sub i_vlan_membership_untagged { | ||
| 192 | my $c9800 = shift; | ||
| 193 | my $partial = shift; | ||
| 194 | |||
| 195 | return { | ||
| 196 | %{ $c9800->SUPER::i_vlan_membership_untagged($partial) || {} }, | ||
| 197 | %{ SNMP::Info::CiscoVTP::i_vlan_membership_untagged( $c9800, | ||
| 198 | $partial ) | ||
| 199 | || {} | ||
| 200 | }, | ||
| 201 | }; | ||
| 202 | } | ||
| 203 | |||
| 204 | # Bridge, reached through Layer2::Airespace, comes before CiscoVTP in method | ||
| 205 | # resolution, so these would otherwise use Q-BRIDGE-MIB, which the 9800 lacks | ||
| 206 | sub i_untagged { | ||
| 207 | my $c9800 = shift; | ||
| 208 | return SNMP::Info::CiscoVTP::i_untagged( $c9800, @_ ); | ||
| 209 | } | ||
| 210 | |||
| 211 | sub set_i_pvid { | ||
| 212 | my $c9800 = shift; | ||
| 213 | return SNMP::Info::CiscoVTP::set_i_pvid( $c9800, @_ ); | ||
| 214 | } | ||
| 215 | |||
| 216 | sub set_i_vlan { | ||
| 217 | my $c9800 = shift; | ||
| 218 | return SNMP::Info::CiscoVTP::set_i_vlan( $c9800, @_ ); | ||
| 219 | } | ||
| 220 | |||
| 221 | sub set_i_untagged { | ||
| 222 | my $c9800 = shift; | ||
| 223 | return SNMP::Info::CiscoVTP::set_i_untagged( $c9800, @_ ); | ||
| 224 | } | ||
| 225 | |||
| 226 | sub set_add_i_vlan_tagged { | ||
| 227 | my $c9800 = shift; | ||
| 228 | return SNMP::Info::CiscoVTP::set_add_i_vlan_tagged( $c9800, @_ ); | ||
| 229 | } | ||
| 230 | |||
| 231 | sub set_remove_i_vlan_tagged { | ||
| 232 | my $c9800 = shift; | ||
| 233 | return SNMP::Info::CiscoVTP::set_remove_i_vlan_tagged( $c9800, @_ ); | ||
| 234 | } | ||
| 235 | |||
| 236 | sub _validate_vlan_param { | ||
| 237 | my $c9800 = shift; | ||
| 238 | return SNMP::Info::CiscoVTP::_validate_vlan_param( $c9800, @_ ); | ||
| 239 | } | ||
| 240 | |||
| 241 | sub i_duplex { | ||
| 242 | my $c9800 = shift; | ||
| 243 | my $partial = shift; | ||
| 244 | |||
| 245 | my %i_duplex = %{ $c9800->SUPER::i_duplex($partial) || {} }; | ||
| 246 | my $el_index = $c9800->el_index($partial) || {}; | ||
| 247 | my $el_duplex = $c9800->el_duplex($partial) || {}; | ||
| 248 | |||
| 249 | foreach my $el_port ( keys %$el_duplex ) { | ||
| 250 | my $iid = $el_index->{$el_port}; | ||
| 251 | my $duplex = $el_duplex->{$el_port}; | ||
| 252 | next unless defined $iid and defined $duplex; | ||
| 253 | next unless $duplex =~ /^(half|full)$/; | ||
| 254 | |||
| 255 | $i_duplex{$iid} = $duplex; | ||
| 256 | } | ||
| 257 | |||
| 258 | return \%i_duplex; | ||
| 259 | } | ||
| 260 | |||
| 261 | # The 9800 leaves bsnDot11EssSsid empty; the radio WLAN table is keyed | ||
| 262 | # like the AP radio ports with the WLAN index appended | ||
| 263 | sub i_ssidlist { | ||
| 264 | my $c9800 = shift; | ||
| 265 | my $partial = shift; | ||
| 266 | |||
| 267 | my $ssids = $c9800->c9800_radio_wlan_ssid($partial) || {}; | ||
| 268 | my %i_ssidlist = map { ( $_ => $ssids->{$_} ) } | ||
| 269 | grep { defined $ssids->{$_} and length $ssids->{$_} } keys %$ssids; | ||
| 270 | return \%i_ssidlist; | ||
| 271 | } | ||
| 272 | |||
| 273 | sub i_ssidmac { | ||
| 274 | my $c9800 = shift; | ||
| 275 | my $partial = shift; | ||
| 276 | |||
| 277 | return $c9800->c9800_radio_wlan_bssid($partial) || {}; | ||
| 278 | } | ||
| 279 | |||
| 280 | sub i_ssidbcast { | ||
| 281 | my $c9800 = shift; | ||
| 282 | my $partial = shift; | ||
| 283 | |||
| 284 | my $ssidlist = $c9800->i_ssidlist($partial) || {}; | ||
| 285 | my $ess_bcast = $c9800->airespace_ess_bcast() || {}; | ||
| 286 | my %bcmap = qw/enable 1 disable 0/; | ||
| 287 | |||
| 288 | my %i_ssidbcast; | ||
| 289 | foreach my $iid ( keys %$ssidlist ) { | ||
| 290 | |||
| 291 | # assumes bsnDot11EssIndex equals cLWlanIndex, as on 17.12 and 17.18 | ||
| 292 | my $wlan = ( split /\./, $iid )[-1]; | ||
| 293 | my $bc = $ess_bcast->{$wlan}; | ||
| 294 | next unless defined $bc and exists $bcmap{$bc}; | ||
| 295 | |||
| 296 | $i_ssidbcast{$iid} = $bcmap{$bc}; | ||
| 297 | } | ||
| 298 | return \%i_ssidbcast; | ||
| 299 | } | ||
| 300 | |||
| 301 | sub interfaces { | ||
| 302 | my $c9800 = shift; | ||
| 303 | my $partial = shift; | ||
| 304 | |||
| 305 | my $interfaces = $c9800->SUPER::interfaces($partial) || {}; | ||
| 306 | my $indexes = $c9800->i_index($partial) || {}; | ||
| 307 | my $descriptions = $c9800->orig_i_description($partial) || {}; | ||
| 308 | |||
| 309 | foreach my $iid (keys %{$indexes}) { | ||
| 310 | next unless defined $indexes->{$iid} && $indexes->{$iid} =~ /^\d+$/; | ||
| 311 | next unless defined $descriptions->{$iid} && $descriptions->{$iid} ne ''; | ||
| 312 | |||
| 313 | $interfaces->{$iid} = $descriptions->{$iid}; | ||
| 314 | } | ||
| 315 | |||
| 316 | return $interfaces; | ||
| 317 | } | ||
| 318 | |||
| 319 | sub _cdp_connections { | ||
| 320 | my $c9800 = shift; | ||
| 321 | my $names = $c9800->c9800_cdp_name() || {}; | ||
| 322 | my $addresses = $c9800->c9800_cdp_address() || {}; | ||
| 323 | my $interfaces = $c9800->c9800_cdp_interface() || {}; | ||
| 324 | |||
| 325 | my %neighbors; | ||
| 326 | foreach my $cdp_iid ( sort keys %{$names} ) { | ||
| 327 | my $ap_iid = $cdp_iid; | ||
| 328 | next unless $ap_iid =~ s/\.\d+$//; | ||
| 329 | |||
| 330 | my @parts = grep { defined && $_ ne '' } | ||
| 331 | ($names->{$cdp_iid}, $interfaces->{$cdp_iid}); | ||
| 332 | push @parts, '(' . $addresses->{$cdp_iid} . ')' | ||
| 333 | if defined $addresses->{$cdp_iid} | ||
| 334 | && $addresses->{$cdp_iid} ne ''; | ||
| 335 | next unless @parts; | ||
| 336 | |||
| 337 | push @{$neighbors{$ap_iid}}, join ' ', @parts; | ||
| 338 | } | ||
| 339 | |||
| 340 | my %connections; | ||
| 341 | foreach my $ap_iid (keys %neighbors) { | ||
| 342 | my %seen; | ||
| 343 | $connections{$ap_iid} = join ', ', | ||
| 344 | grep { !$seen{$_}++ } @{$neighbors{$ap_iid}}; | ||
| 345 | } | ||
| 346 | return \%connections; | ||
| 347 | } | ||
| 348 | |||
| 349 | sub _ap_detail_strings { | ||
| 350 | my $c9800 = shift; | ||
| 351 | my $ips = $c9800->airespace_ap_ip() || {}; | ||
| 352 | my $dot3_macs = $c9800->airespace_ap_mac() || {}; | ||
| 353 | my $ether_macs = $c9800->airespace_ap_ethermac() || {}; | ||
| 354 | my $connections = $c9800->_cdp_connections(); | ||
| 355 | |||
| 356 | my %details; | ||
| 357 | foreach my $iid ( | ||
| 358 | keys %{$ips}, keys %{$dot3_macs}, keys %{$ether_macs}, | ||
| 359 | keys %{$connections} | ||
| 360 | ) { | ||
| 361 | my @parts; | ||
| 362 | push @parts, "IP $ips->{$iid}" if $ips->{$iid}; | ||
| 363 | push @parts, "Dot3 MAC $dot3_macs->{$iid}" if $dot3_macs->{$iid}; | ||
| 364 | push @parts, "Ethernet MAC $ether_macs->{$iid}" | ||
| 365 | if $ether_macs->{$iid}; | ||
| 366 | push @parts, "Connected via $connections->{$iid}" | ||
| 367 | if $connections->{$iid}; | ||
| 368 | $details{$iid} = join '; ', @parts if @parts; | ||
| 369 | } | ||
| 370 | return \%details; | ||
| 371 | } | ||
| 372 | |||
| 373 | # Tags are an AP-level setting, so they only go on the AP module and not on | ||
| 374 | # every radio port of that AP. | ||
| 375 | sub _ap_tag_strings { | ||
| 376 | my $c9800 = shift; | ||
| 377 | my $policy = $c9800->c9800_ap_policy_tag() || {}; | ||
| 378 | my $site = $c9800->c9800_ap_site_tag() || {}; | ||
| 379 | my $rf = $c9800->c9800_ap_rf_tag() || {}; | ||
| 380 | |||
| 381 | my %tags; | ||
| 382 | foreach my $iid (keys %{$policy}, keys %{$site}, keys %{$rf}) { | ||
| 383 | my @parts; | ||
| 384 | push @parts, "Policy tag $policy->{$iid}" if $policy->{$iid}; | ||
| 385 | push @parts, "Site tag $site->{$iid}" if $site->{$iid}; | ||
| 386 | push @parts, "RF tag $rf->{$iid}" if $rf->{$iid}; | ||
| 387 | $tags{$iid} = join '; ', @parts if @parts; | ||
| 388 | } | ||
| 389 | return \%tags; | ||
| 390 | } | ||
| 391 | |||
| 392 | sub _debug_ap_details { | ||
| 393 | my $c9800 = shift; | ||
| 394 | return unless $c9800->debug(); | ||
| 395 | return if $c9800->{_c9800_ap_details_logged}++; | ||
| 396 | |||
| 397 | my $names = $c9800->airespace_ap_name() || {}; | ||
| 398 | my $ips = $c9800->airespace_ap_ip() || {}; | ||
| 399 | my $serials = $c9800->airespace_ap_serial() || {}; | ||
| 400 | my $models = $c9800->airespace_ap_model() || {}; | ||
| 401 | my $vlans = $c9800->c9800_ap_vlan() || {}; | ||
| 402 | my $versions = $c9800->c9800_ap_ios_ver() || {}; | ||
| 403 | my $dot3_macs = $c9800->airespace_ap_mac() || {}; | ||
| 404 | my $ether_macs = $c9800->airespace_ap_ethermac() || {}; | ||
| 405 | my $locations = $c9800->airespace_ap_loc() || {}; | ||
| 406 | my $admin = $c9800->airespace_ap_status() || {}; | ||
| 407 | my $oper = $c9800->c9800_ap_oper() || {}; | ||
| 408 | my $primary = $c9800->c9800_ap_primary() || {}; | ||
| 409 | my $secondary = $c9800->c9800_ap_secondary() || {}; | ||
| 410 | my $policy_tag = $c9800->c9800_ap_policy_tag() || {}; | ||
| 411 | my $site_tag = $c9800->c9800_ap_site_tag() || {}; | ||
| 412 | my $rf_tag = $c9800->c9800_ap_rf_tag() || {}; | ||
| 413 | my $tag_source = $c9800->c9800_ap_tag_source() || {}; | ||
| 414 | |||
| 415 | foreach my $iid (sort keys %{$names}) { | ||
| 416 | my @values = ( | ||
| 417 | "name=" . ($names->{$iid} // ''), | ||
| 418 | "ip=" . ($ips->{$iid} // ''), | ||
| 419 | "serial=" . ($serials->{$iid} // ''), | ||
| 420 | "model=" . ($models->{$iid} // ''), | ||
| 421 | "vlan=" . ($vlans->{$iid} // ''), | ||
| 422 | "version=" . ($versions->{$iid} // ''), | ||
| 423 | "dot3_mac=" . ($dot3_macs->{$iid} // ''), | ||
| 424 | "ether_mac=" . ($ether_macs->{$iid} // ''), | ||
| 425 | "location=" . ($locations->{$iid} // ''), | ||
| 426 | "admin=" . ($admin->{$iid} // ''), | ||
| 427 | "oper=" . ($oper->{$iid} // ''), | ||
| 428 | "primary=" . ($primary->{$iid} // ''), | ||
| 429 | "secondary=" . ($secondary->{$iid} // ''), | ||
| 430 | "policy_tag=" . ($policy_tag->{$iid} // ''), | ||
| 431 | "site_tag=" . ($site_tag->{$iid} // ''), | ||
| 432 | "rf_tag=" . ($rf_tag->{$iid} // ''), | ||
| 433 | "tag_source=" . ($tag_source->{$iid} // ''), | ||
| 434 | ); | ||
| 435 | print " SNMP::Info::Layer3::C9800 AP $iid " | ||
| 436 | . join(' ', @values) . "\n"; | ||
| 437 | } | ||
| 438 | } | ||
| 439 | |||
| 440 | sub i_description { | ||
| 441 | my $c9800 = shift; | ||
| 442 | my $partial = shift; | ||
| 443 | |||
| 444 | my $descriptions = $c9800->SUPER::i_description($partial) || {}; | ||
| 445 | my $indexes = $c9800->i_index($partial) || {}; | ||
| 446 | my $details = $c9800->_ap_detail_strings(); | ||
| 447 | $c9800->_debug_ap_details(); | ||
| 448 | |||
| 449 | foreach my $iid (keys %{$indexes}) { | ||
| 450 | my $ap_iid = $iid; | ||
| 451 | next unless $ap_iid =~ s/\.\d+$//; | ||
| 452 | |||
| 453 | next unless $details->{$ap_iid}; | ||
| 454 | |||
| 455 | my $prefix = $descriptions->{$iid}; | ||
| 456 | $descriptions->{$iid} = defined $prefix && $prefix ne '' | ||
| 457 | ? "$prefix; $details->{$ap_iid}" | ||
| 458 | : $details->{$ap_iid}; | ||
| 459 | } | ||
| 460 | |||
| 461 | return $descriptions; | ||
| 462 | } | ||
| 463 | |||
| 464 | sub _merged_entity_table { | ||
| 465 | my ($c9800, $entity_method, $ap_method) = @_; | ||
| 466 | |||
| 467 | my $entities = $c9800->$entity_method() || {}; | ||
| 468 | my $ap_sub = SNMP::Info::Airespace->can($ap_method); | ||
| 469 | my $aps = $ap_sub->($c9800) || {}; | ||
| 470 | my $ap_indexes = SNMP::Info::Airespace::e_index($c9800) || {}; | ||
| 471 | |||
| 472 | my %ap_entities = map { $_ => $aps->{$_} } | ||
| 473 | grep { $_ ne 1 && exists $aps->{$_} } keys %{$ap_indexes}; | ||
| 474 | return {%{$entities}, %ap_entities}; | ||
| 475 | } | ||
| 476 | |||
| 477 | sub e_index { | ||
| 478 | my $c9800 = shift; | ||
| 479 | |||
| 480 | my $descriptions = $c9800->c9800_entity_descr() || {}; | ||
| 481 | my $aps = SNMP::Info::Airespace::e_index($c9800) || {}; | ||
| 482 | my %indexes = map { $_ => $_ } keys %{$descriptions}; | ||
| 483 | |||
| 484 | delete $aps->{1}; | ||
| 485 | return {%indexes, %{$aps}}; | ||
| 486 | } | ||
| 487 | |||
| 488 | sub e_class { | ||
| 489 | return shift->_merged_entity_table('c9800_entity_class', 'e_class'); | ||
| 490 | } | ||
| 491 | |||
| 492 | sub e_name { | ||
| 493 | return shift->_merged_entity_table('c9800_entity_name', 'e_name'); | ||
| 494 | } | ||
| 495 | |||
| 496 | sub e_descr { | ||
| 497 | my $c9800 = shift; | ||
| 498 | my $descriptions = $c9800->_merged_entity_table( | ||
| 499 | 'c9800_entity_descr', 'e_descr'); | ||
| 500 | my $details = $c9800->_ap_detail_strings(); | ||
| 501 | my $tags = $c9800->_ap_tag_strings(); | ||
| 502 | $c9800->_debug_ap_details(); | ||
| 503 | |||
| 504 | foreach my $iid (keys %{$descriptions}) { | ||
| 505 | $descriptions->{$iid} .= "; $details->{$iid}" if $details->{$iid}; | ||
| 506 | $descriptions->{$iid} .= "; $tags->{$iid}" if $tags->{$iid}; | ||
| 507 | } | ||
| 508 | return $descriptions; | ||
| 509 | } | ||
| 510 | |||
| 511 | sub e_model { | ||
| 512 | return shift->_merged_entity_table('c9800_entity_model', 'e_model'); | ||
| 513 | } | ||
| 514 | |||
| 515 | sub e_type { | ||
| 516 | return shift->_merged_entity_table('c9800_entity_type', 'e_type'); | ||
| 517 | } | ||
| 518 | |||
| 519 | sub e_fwver { | ||
| 520 | return shift->_merged_entity_table('c9800_entity_fwver', 'e_fwver'); | ||
| 521 | } | ||
| 522 | |||
| 523 | sub e_vendor { | ||
| 524 | return shift->_merged_entity_table('c9800_entity_vendor', 'e_vendor'); | ||
| 525 | } | ||
| 526 | |||
| 527 | sub e_serial { | ||
| 528 | return shift->_merged_entity_table('c9800_entity_serial', 'e_serial'); | ||
| 529 | } | ||
| 530 | |||
| 531 | sub e_pos { | ||
| 532 | return shift->_merged_entity_table('c9800_entity_pos', 'e_pos'); | ||
| 533 | } | ||
| 534 | |||
| 535 | sub e_swver { | ||
| 536 | return shift->_merged_entity_table('c9800_entity_swver', 'e_swver'); | ||
| 537 | } | ||
| 538 | |||
| 539 | sub e_parent { | ||
| 540 | return shift->_merged_entity_table('c9800_entity_parent', 'e_parent'); | ||
| 541 | } | ||
| 542 | |||
| 543 | 1; | ||
| 544 | __END__ |