From eb5a492eb9904fd648b814eb81f242a3e8e13d29 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 12 Apr 2012 10:10:51 +0100 Subject: [PATCH] [3297786] LLDP INDEX munged to ignore TimeMark component (David Baldwin) --- ChangeLog | 1 + Info/LLDP.pm | 35 +++++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 578d83d5..f86b0074 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ version 2.07 () * [3085411] Activate L3 properties for Netgear GSM7224v2 (phishphreek) * [3085413] SNMP OIDs for Netgear Serial and OS Ver (phishphreek) * [3286549] Dell LLDP Support (Nico Giefing) + * [3297786] LLDP INDEX munged to ignore TimeMark component (David Baldwin) [BUG FIXES] diff --git a/Info/LLDP.pm b/Info/LLDP.pm index a0dafae8..48d46fd4 100644 --- a/Info/LLDP.pm +++ b/Info/LLDP.pm @@ -103,7 +103,7 @@ sub lldp_if { foreach my $key ( keys %$addr ) { my @aOID = split( '\.', $key ); my $port = $aOID[1]; - $lldp_if{$key} = $port; + $lldp_if{_lldp_rem_index($key)} = $port; } return \%lldp_if; } @@ -169,7 +169,7 @@ sub lldp_port { $port = defined $1 ? "$2.$3" : "$3"; } - $lldp_port{$key} = $port; + $lldp_port{_lldp_rem_index($key)} = $port; } return \%lldp_port; } @@ -191,14 +191,15 @@ sub lldp_id { # May need to format other types in the future if ( $type =~ /mac/ ) { $id = join( ':', map { sprintf "%02x", $_ } unpack( 'C*', $id ) ); - }elsif ($type eq 'networkAddress'){ - if ( length(unpack('H*', $id)) == 10 ){ - # IP address (first octet is sign, I guess) - my @octets = (map { sprintf "%02x",$_ } unpack('C*', $id))[1..4]; - $id = join '.', map { hex($_) } @octets; - } - } - $lldp_id{$key} = $id; + } + elsif ($type eq 'networkAddress') { + if ( length(unpack('H*', $id)) == 10 ) { + # IP address (first octet is sign, I guess) + my @octets = (map { sprintf "%02x",$_ } unpack('C*', $id))[1..4]; + $id = join '.', map { hex($_) } @octets; + } + } + $lldp_id{_lldp_rem_index( $key )} = $id; } return \%lldp_id; } @@ -221,6 +222,16 @@ sub lldp_id { # return; #} +# Break up the lldpRemTable INDEX into time mark and common index returning +# index +sub _lldp_rem_index { + my $idx = shift; + my @oids = split( /\./, $idx ); + # print "DBGoids: $idx\n"; + my $timemark = shift @oids; + return join( '.', @oids ); +} + # Break up the lldpRemManAddrTable INDEX into common index, protocol, # and address. sub _lldp_addr_index { @@ -391,7 +402,7 @@ to a hash. =item $lldp->lldp_id() -Returns the string value used to identify the chassis component associated +Returns the string value used to identify the chassis component associated with the remote system. (C) @@ -429,7 +440,7 @@ the remote system. =item $lldp->lldp_rem_id() -Returns the string value used to identify the chassis component associated +Returns the string value used to identify the chassis component associated with the remote system. (C)