diff --git a/Info/LLDP.pm b/Info/LLDP.pm index c8d2a9c6..1e89c36d 100644 --- a/Info/LLDP.pm +++ b/Info/LLDP.pm @@ -99,20 +99,26 @@ sub lldp_if { my $addr = $lldp->lldp_rem_pid($partial) || {}; my $i_descr = $lldp->i_description() || {}; + my $i_alias = $lldp->i_alias() || {}; my %r_i_descr = reverse %$i_descr; + my %r_i_alias = reverse %$i_alias; my %lldp_if; foreach my $key ( keys %$addr ) { my @aOID = split( '\.', $key ); my $port = $aOID[1]; next unless $port; - # Local LLDP port may not equate to ifIndex - # Cross reference lldpLocPortDesc with ifDescr to get ifIndex + # Local LLDP port may not equate to ifIndex, see LldpPortNumber TEXTUAL-CONVENTION in LLDP-MIB. + # Cross reference lldpLocPortDesc with ifDescr and ifAlias to get ifIndex, + # prefer ifDescr over 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); my $desc = $lldp_desc->{$port}; # If cross reference is successful use it, otherwise stick with lldpRemLocalPortNum if ( exists $r_i_descr{$desc} ) { $port = $r_i_descr{$desc}; + } elsif ( exists $r_i_alias{$desc} ) { + $port = $r_i_alias{$desc}; } $lldp_if{$key} = $port; @@ -411,9 +417,9 @@ with the remote system. =item $lldp->lldp_if() -Returns the mapping to the SNMP Interface Table. Trys to cross reference -(C) with (C) to get (C), if unable -defaults to (C). +Returns the mapping to the SNMP Interface Table. Triess to cross reference +(C) with (C) and (C) to get (C), +if unable defaults to (C). =item $lldp->lldp_ip()