Add support for other CDP/LLDP binary formatted values (ID 1909147)

This commit is contained in:
Carlos Vicente
2009-03-10 16:57:37 +00:00
parent 5f0e73bcb4
commit 690bc6bfa0
2 changed files with 28 additions and 10 deletions

View File

@@ -191,7 +191,13 @@ 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;
}
return \%lldp_id;