Use munge_mac() to unpack MACs
This commit is contained in:
@@ -255,8 +255,7 @@ sub lldp_port {
|
|||||||
|
|
||||||
# May need to format other types in the future, i.e. Network address
|
# May need to format other types in the future, i.e. Network address
|
||||||
if ( $type =~ /mac/ ) {
|
if ( $type =~ /mac/ ) {
|
||||||
$port = join( ':',
|
$port = SNMP::Info::munge_mac($port)
|
||||||
map { sprintf "%02x", $_ } unpack( 'C*', $port ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,7 +290,7 @@ 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 = SNMP::Info::munge_mac($id)
|
||||||
}
|
}
|
||||||
elsif ( $type eq 'networkAddress' ) {
|
elsif ( $type eq 'networkAddress' ) {
|
||||||
if ( length( unpack( 'H*', $id ) ) == 10 ) {
|
if ( length( unpack( 'H*', $id ) ) == 10 ) {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ sub setup : Tests(setup) {
|
|||||||
{'0.6.1' => 'C2960 Software (C2960-LANBASEK9-M), Version 12.2(37)SE'},
|
{'0.6.1' => 'C2960 Software (C2960-LANBASEK9-M), Version 12.2(37)SE'},
|
||||||
'lldp_rem_sysname' => {'0.6.1' => 'My C2960'},
|
'lldp_rem_sysname' => {'0.6.1' => 'My C2960'},
|
||||||
'lldp_rem_id_type' => {'0.6.1' => 'macAddress'},
|
'lldp_rem_id_type' => {'0.6.1' => 'macAddress'},
|
||||||
'lldp_rem_id' => {'0.6.1' => pack("H*", 'ABCD123456')},
|
'lldp_rem_id' => {'0.6.1' => pack("H*", 'ABCD12345678')},
|
||||||
'lldp_rem_cap_spt' => {'0.6.1' => pack("H*", '2800')},
|
'lldp_rem_cap_spt' => {'0.6.1' => pack("H*", '2800')},
|
||||||
'lldp_rem_media_cap_spt' => {'0.6.1' => pack("H*", '4C')},
|
'lldp_rem_media_cap_spt' => {'0.6.1' => pack("H*", '4C')},
|
||||||
}
|
}
|
||||||
@@ -286,10 +286,10 @@ sub lldp_port : Tests(10) {
|
|||||||
$test->{info}{store} = {
|
$test->{info}{store} = {
|
||||||
lldp_rem_pid_type => {'0.16.1' => 'macAddress'},
|
lldp_rem_pid_type => {'0.16.1' => 'macAddress'},
|
||||||
lldp_rem_desc => {'0.16.1' => ''},
|
lldp_rem_desc => {'0.16.1' => ''},
|
||||||
lldp_rem_pid => {'0.16.1' => pack("H*", '2345678ABC')},
|
lldp_rem_pid => {'0.16.1' => pack("H*", '2345678ABCDE')},
|
||||||
};
|
};
|
||||||
|
|
||||||
$expected = {'0.16.1' => '23:45:67:8a:bc'};
|
$expected = {'0.16.1' => '23:45:67:8a:bc:de'};
|
||||||
|
|
||||||
cmp_deeply($test->{info}->lldp_port(), $expected,
|
cmp_deeply($test->{info}->lldp_port(), $expected,
|
||||||
q(Remote port type 'macAddress' no 'lldpRemPortDesc' uses 'lldpRemPortId'));
|
q(Remote port type 'macAddress' no 'lldpRemPortDesc' uses 'lldpRemPortId'));
|
||||||
@@ -330,7 +330,7 @@ sub lldp_id : Tests(4) {
|
|||||||
|
|
||||||
can_ok($test->{info}, 'lldp_id');
|
can_ok($test->{info}, 'lldp_id');
|
||||||
|
|
||||||
my $expected = {'0.6.1' => 'ab:cd:12:34:56'};
|
my $expected = {'0.6.1' => 'ab:cd:12:34:56:78'};
|
||||||
|
|
||||||
cmp_deeply($test->{info}->lldp_id(),
|
cmp_deeply($test->{info}->lldp_id(),
|
||||||
$expected, q(Remote LLDP ID type 'macAddress' has expected value));
|
$expected, q(Remote LLDP ID type 'macAddress' has expected value));
|
||||||
|
|||||||
Reference in New Issue
Block a user