diff --git a/lib/SNMP/Info/LLDP.pm b/lib/SNMP/Info/LLDP.pm index 5129df0f..e3860cce 100644 --- a/lib/SNMP/Info/LLDP.pm +++ b/lib/SNMP/Info/LLDP.pm @@ -55,10 +55,13 @@ $VERSION = '3.70'; ); %FUNCS = ( - # LLDP-MIB::lldpLocManAddrTable 'lldp_lman_addr' => 'lldpLocManAddrIfId', + # LLDP-MIB::LldpLocPortEntry + 'lldp_lport_id' => 'lldpLocPortId', + 'lldp_lport_desc' => 'lldpLocPortDesc', + # LLDP-MIB::lldpRemTable 'lldp_rem_id_type' => 'lldpRemChassisIdSubtype', 'lldp_rem_id' => 'lldpRemChassisId', @@ -92,6 +95,8 @@ $VERSION = '3.70'; 'lldp_rem_sysname' => \&SNMP::Info::munge_null, 'lldp_rem_sysdesc' => \&SNMP::Info::munge_null, 'lldp_rem_port_desc' => \&SNMP::Info::munge_null, + 'lldp_lport_id' => \&SNMP::Info::munge_null, + 'lldp_lport_desc' => \&SNMP::Info::munge_null, 'lldp_sys_cap' => \&SNMP::Info::munge_bits, 'lldp_rem_sys_cap' => \&SNMP::Info::munge_bits, 'lldp_rem_cap_spt' => \&SNMP::Info::munge_bits, @@ -146,7 +151,11 @@ sub lldp_if { # ifAlias because using cross ref with description is correct # behavior according to the LLDP-MIB. Some devices (eg H3C gear) # seem to use ifAlias though. - my $lldp_desc = $lldp->lldpLocPortDesc($port); + # snmp::info #372 -> to make things even more complex some devices + # have different behaviour depending on os version (nx-os 6 vs 7) + # so we made this a function to allow overrides in more specific + # modules + my $lldp_desc = $lldp->lldp_lport_desc($port); my $desc = $lldp_desc->{$port}; # If cross reference is successful use it, otherwise stick with diff --git a/lib/SNMP/Info/Layer3/Nexus.pm b/lib/SNMP/Info/Layer3/Nexus.pm index 2d4c83f5..0e02f27a 100644 --- a/lib/SNMP/Info/Layer3/Nexus.pm +++ b/lib/SNMP/Info/Layer3/Nexus.pm @@ -40,7 +40,7 @@ our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE); @SNMP::Info::Layer3::Nexus::ISA = qw/ SNMP::Info::Layer3::CiscoSwitch Exporter - /; +/; @SNMP::Info::Layer3::Nexus::EXPORT_OK = qw//; @@ -53,14 +53,14 @@ $VERSION = '3.70'; # The @ISA order should be reverse of these orders. %MIBS = ( - %SNMP::Info::Layer3::CiscoSwitch::MIBS, - 'CISCO-ENTITY-VENDORTYPE-OID-MIB' => 'cevMIBObjects', - 'CISCO-CONTEXT-MAPPING-MIB' => 'cContextMappingMIBObjects', + %SNMP::Info::Layer3::CiscoSwitch::MIBS, + 'CISCO-ENTITY-VENDORTYPE-OID-MIB' => 'cevMIBObjects', + 'CISCO-CONTEXT-MAPPING-MIB' => 'cContextMappingMIBObjects', ); %GLOBALS = ( - %SNMP::Info::Layer3::CiscoSwitch::GLOBALS, - 'mac' => 'dot1dBaseBridgeAddress', + %SNMP::Info::Layer3::CiscoSwitch::GLOBALS, + 'mac' => 'dot1dBaseBridgeAddress', ); %FUNCS = ( @@ -137,6 +137,21 @@ sub model { return $model; } +# nx-os 6 seems to swap the data of lldpLocPortDesc with that of +# lldpLocPortId, so remap it to make the main lldp module happy. +# nx-os 7 behaves as expected. +sub lldp_lport_desc { + my $nexus = shift; + my $osver = $nexus->os_ver(); + + if (defined ($osver)) { + if ($osver =~ /^6.*/) { + return $nexus->SUPER::lldp_lport_id(); + } + } + return $nexus->SUPER::lldp_lport_desc(); +} + # Reported version 6.x of NX-OS doesn't use the IPv4 address as index # override methods in ipAddrTable sub ip_table { @@ -377,6 +392,12 @@ Gives broadcast address for IP table entry. (C) +=item $nexus->lldp_lport_desc() + +On nx-os 6 only this will return data from C instead of +the expected C. For all other nx-os versions uses the +function from L. + =back =head2 Globals imported from SNMP::Info::Layer3::CiscoSwitch