diff --git a/lib/SNMP/Info/Layer3/DLink.pm b/lib/SNMP/Info/Layer3/DLink.pm index f3f19672..8c286263 100644 --- a/lib/SNMP/Info/Layer3/DLink.pm +++ b/lib/SNMP/Info/Layer3/DLink.pm @@ -91,6 +91,16 @@ sub model { } } +# ifDescr is the same for all interfaces in a class, but the ifName is +# unique, so let's use that for port name. +sub interfaces { + my $dlink = shift; + my $partial = shift; + + my $interfaces = $dlink->orig_i_name($partial); + return $interfaces; +} + sub vendor { return 'dlink'; diff --git a/xt/lib/Test/SNMP/Info/Layer3/DLink.pm b/xt/lib/Test/SNMP/Info/Layer3/DLink.pm index c27f8c51..78c37b59 100644 --- a/xt/lib/Test/SNMP/Info/Layer3/DLink.pm +++ b/xt/lib/Test/SNMP/Info/Layer3/DLink.pm @@ -49,12 +49,27 @@ sub setup : Tests(setup) { my $cache_data = { '_layers' => 4, '_description' => 'DGS-3620-28SC Gigabit Ethernet Switch', + '_i_name' => 1, # SWDGS3620PRIMGMT-MIB::dlink-Dgs3620Prod-Dgs3620-28SC '_id' => '.1.3.6.1.4.1.171.10.118.2', - 'store' => {}, + 'store' => { + i_name => { 1 => 'One', 2 => 'Two' }, + }, }; $test->{info}->cache($cache_data); } +sub interfaces : Tests(1) { + my $test = shift; + + my $expected_data = { + 1 => 'One', + 2 => 'Two', + }; + + cmp_deeply($test->{info}->interfaces(), + $expected_data, 'Call to interfaces() returns ifName'); +} + 1;