Add support for other CDP/LLDP binary formatted values (ID 1909147)
This commit is contained in:
@@ -191,7 +191,13 @@ sub lldp_id {
|
|||||||
# May need to format other types in the future
|
# May need to format other types in the future
|
||||||
if ( $type =~ /mac/ ) {
|
if ( $type =~ /mac/ ) {
|
||||||
$id = join( ':', map { sprintf "%02x", $_ } unpack( 'C*', $id ) );
|
$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;
|
$lldp_id{$key} = $id;
|
||||||
}
|
}
|
||||||
return \%lldp_id;
|
return \%lldp_id;
|
||||||
|
|||||||
@@ -112,12 +112,12 @@ $VERSION = '2.00';
|
|||||||
);
|
);
|
||||||
|
|
||||||
%MUNGE = (
|
%MUNGE = (
|
||||||
|
|
||||||
# Inherit all the built in munging
|
# Inherit all the built in munging
|
||||||
%SNMP::Info::Layer3::MUNGE,
|
%SNMP::Info::Layer3::MUNGE,
|
||||||
%SNMP::Info::MAU::MUNGE,
|
%SNMP::Info::MAU::MUNGE,
|
||||||
%SNMP::Info::LLDP::MUNGE,
|
%SNMP::Info::LLDP::MUNGE,
|
||||||
%SNMP::Info::CDP::MUNGE
|
%SNMP::Info::CDP::MUNGE,
|
||||||
|
'c_id' => \&munge_hp_c_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
%MODEL_MAP = (
|
%MODEL_MAP = (
|
||||||
@@ -553,7 +553,6 @@ sub c_port {
|
|||||||
foreach my $iid ( keys %$lldp ) {
|
foreach my $iid ( keys %$lldp ) {
|
||||||
my $port = $lldp->{$iid};
|
my $port = $lldp->{$iid};
|
||||||
next unless defined $port;
|
next unless defined $port;
|
||||||
|
|
||||||
$c_port{$iid} = $port;
|
$c_port{$iid} = $port;
|
||||||
}
|
}
|
||||||
return \%c_port;
|
return \%c_port;
|
||||||
@@ -570,19 +569,32 @@ sub c_id {
|
|||||||
foreach my $iid ( keys %$cdp ) {
|
foreach my $iid ( keys %$cdp ) {
|
||||||
my $id = $cdp->{$iid};
|
my $id = $cdp->{$iid};
|
||||||
next unless defined $id;
|
next unless defined $id;
|
||||||
|
|
||||||
$c_id{$iid} = $id;
|
$c_id{$iid} = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $iid ( keys %$lldp ) {
|
foreach my $iid ( keys %$lldp ) {
|
||||||
my $id = $lldp->{$iid};
|
my $id = $lldp->{$iid};
|
||||||
next unless defined $id;
|
next unless defined $id;
|
||||||
|
|
||||||
$c_id{$iid} = $id;
|
$c_id{$iid} = $id;
|
||||||
}
|
}
|
||||||
return \%c_id;
|
return \%c_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub munge_hp_c_id {
|
||||||
|
my ($v) = @_;
|
||||||
|
if ( length(unpack('H*', $v)) == 12 ){
|
||||||
|
return join(':',map { sprintf "%02x", $_ } unpack('C*', $v));
|
||||||
|
}if ( length(unpack('H*', $v)) == 10 ){
|
||||||
|
# IP address (first octet is sign, I guess)
|
||||||
|
my @octets = (map { sprintf "%02x",$_ } unpack('C*', $v))[1..4];
|
||||||
|
return join '.', map { hex($_) } @octets;
|
||||||
|
}else{
|
||||||
|
return $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub c_platform {
|
sub c_platform {
|
||||||
my $hp = shift;
|
my $hp = shift;
|
||||||
my $partial = shift;
|
my $partial = shift;
|
||||||
|
|||||||
Reference in New Issue
Block a user