Fix Avaya detection in lldp_port()
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
SNMP::Info - Friendly OO-style interface to Network devices using SNMP.
|
SNMP::Info - Friendly OO-style interface to Network devices using SNMP.
|
||||||
|
|
||||||
|
version 3.19
|
||||||
|
|
||||||
|
[BUG FIXES]
|
||||||
|
|
||||||
|
* Fix Avaya detection lldp_port()
|
||||||
|
|
||||||
version 3.18 (2014-07-02)
|
version 3.18 (2014-07-02)
|
||||||
|
|
||||||
[ENHANCEMENTS]
|
[ENHANCEMENTS]
|
||||||
|
|||||||
25
Info/LLDP.pm
25
Info/LLDP.pm
@@ -123,7 +123,8 @@ sub lldp_if {
|
|||||||
# If cross reference is successful use it, otherwise stick with lldpRemLocalPortNum
|
# If cross reference is successful use it, otherwise stick with lldpRemLocalPortNum
|
||||||
if ( $desc && exists $r_i_descr{$desc} ) {
|
if ( $desc && exists $r_i_descr{$desc} ) {
|
||||||
$port = $r_i_descr{$desc};
|
$port = $r_i_descr{$desc};
|
||||||
} elsif ( $desc && exists $r_i_alias{$desc} ) {
|
}
|
||||||
|
elsif ( $desc && exists $r_i_alias{$desc} ) {
|
||||||
$port = $r_i_alias{$desc};
|
$port = $r_i_alias{$desc};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,13 +171,14 @@ sub lldp_port {
|
|||||||
my $pdesc = $lldp->lldp_rem_desc($partial) || {};
|
my $pdesc = $lldp->lldp_rem_desc($partial) || {};
|
||||||
my $pid = $lldp->lldp_rem_pid($partial) || {};
|
my $pid = $lldp->lldp_rem_pid($partial) || {};
|
||||||
my $ptype = $lldp->lldp_rem_pid_type($partial) || {};
|
my $ptype = $lldp->lldp_rem_pid_type($partial) || {};
|
||||||
my $vendor = $lldp->vendor();
|
my $desc = $lldp->lldp_rem_sysdesc($partial) || {};
|
||||||
|
|
||||||
my %lldp_port;
|
my %lldp_port;
|
||||||
foreach my $key ( sort keys %$pid ) {
|
foreach my $key ( sort keys %$pid ) {
|
||||||
my $port = $pdesc->{$key};
|
my $port = $pdesc->{$key};
|
||||||
my $type = $ptype->{$key};
|
my $type = $ptype->{$key};
|
||||||
if ( $type and $type eq 'interfaceName' ) {
|
if ( $type and $type eq 'interfaceName' ) {
|
||||||
|
|
||||||
# If the pid claims to be an interface name,
|
# If the pid claims to be an interface name,
|
||||||
# believe it.
|
# believe it.
|
||||||
$port = $pid->{$key};
|
$port = $pid->{$key};
|
||||||
@@ -195,8 +197,12 @@ sub lldp_port {
|
|||||||
|
|
||||||
# Avaya/Nortel lldpRemPortDesc doesn't match ifDescr, but we can still
|
# Avaya/Nortel lldpRemPortDesc doesn't match ifDescr, but we can still
|
||||||
# figure out slot.port based upon lldpRemPortDesc
|
# figure out slot.port based upon lldpRemPortDesc
|
||||||
if ( $vendor eq 'avaya' && $port =~ /^(Unit\s+(\d+)\s+)?Port\s+(\d+)$/ ) {
|
if ( defined $desc->{$key}
|
||||||
$port = defined $1 ? "$2.$3" : "$3";
|
&& $desc->{$key}
|
||||||
|
=~ /^Ethernet\s(?:Routing\s)?Switch\s\d|^Virtual\sServices\sPlatform\s\d/
|
||||||
|
&& $port =~ /^(Unit\s+(\d+)\s+)?Port\s+(\d+)$/ )
|
||||||
|
{
|
||||||
|
$port = defined $1 ? "$2.$3" : "1.$3";
|
||||||
}
|
}
|
||||||
|
|
||||||
$lldp_port{$key} = $port;
|
$lldp_port{$key} = $port;
|
||||||
@@ -224,8 +230,11 @@ sub lldp_id {
|
|||||||
}
|
}
|
||||||
elsif ( $type eq 'networkAddress' ) {
|
elsif ( $type eq 'networkAddress' ) {
|
||||||
if ( length( unpack( 'H*', $id ) ) == 10 ) {
|
if ( length( unpack( 'H*', $id ) ) == 10 ) {
|
||||||
|
|
||||||
# IP address (first octet is sign, I guess)
|
# IP address (first octet is sign, I guess)
|
||||||
my @octets = (map { sprintf "%02x",$_ } unpack('C*', $id))[1..4];
|
my @octets
|
||||||
|
= ( map { sprintf "%02x", $_ } unpack( 'C*', $id ) )
|
||||||
|
[ 1 .. 4 ];
|
||||||
$id = join '.', map { hex($_) } @octets;
|
$id = join '.', map { hex($_) } @octets;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,7 +268,11 @@ sub lldp_cap {
|
|||||||
# be able to enumerate for us, so we have to get it from the MIB
|
# be able to enumerate for us, so we have to get it from the MIB
|
||||||
# and enumerate ourselves
|
# and enumerate ourselves
|
||||||
my $oid = SNMP::translateObj( 'lldpRemSysCapEnabled', 0, 1 ) || '';
|
my $oid = SNMP::translateObj( 'lldpRemSysCapEnabled', 0, 1 ) || '';
|
||||||
my $enums = ((ref {} eq ref $SNMP::MIB{$oid}{'enums'}) ? $SNMP::MIB{$oid}{'enums'} : {});
|
my $enums = (
|
||||||
|
( ref {} eq ref $SNMP::MIB{$oid}{'enums'} )
|
||||||
|
? $SNMP::MIB{$oid}{'enums'}
|
||||||
|
: {}
|
||||||
|
);
|
||||||
my %r_enums = reverse %$enums;
|
my %r_enums = reverse %$enums;
|
||||||
|
|
||||||
my %lldp_cap;
|
my %lldp_cap;
|
||||||
|
|||||||
Reference in New Issue
Block a user