From 0e75c44cb8da0ea641ee6db4d83c0033f8ba6b26 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 7 Oct 2021 12:01:02 +0100 Subject: [PATCH] #401 add DLink layers always 2+3 --- lib/SNMP/Info/Layer3/DLink.pm | 14 ++++++++++++++ xt/lib/Test/SNMP/Info/Layer3/DLink.pm | 12 +++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/SNMP/Info/Layer3/DLink.pm b/lib/SNMP/Info/Layer3/DLink.pm index f1c2acc3..aaf244ac 100644 --- a/lib/SNMP/Info/Layer3/DLink.pm +++ b/lib/SNMP/Info/Layer3/DLink.pm @@ -74,6 +74,16 @@ $VERSION = '3.80'; %MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); +sub layers { + my $dlink = shift; + + my $layers = $dlink->SUPER::layers(); + substr $layers, 5, 1, "1"; + substr $layers, 6, 1, "1"; + + return $layers; +} + sub model { my $dlink=shift; my $id = $dlink->id(); @@ -233,6 +243,10 @@ These are methods that return scalar value from SNMP =over +=item $dlink->layers() + +Makes sure to always report layer 2 and 3. + =item $dlink->model() Returns the ID or else description. diff --git a/xt/lib/Test/SNMP/Info/Layer3/DLink.pm b/xt/lib/Test/SNMP/Info/Layer3/DLink.pm index 78c37b59..86bf8ef2 100644 --- a/xt/lib/Test/SNMP/Info/Layer3/DLink.pm +++ b/xt/lib/Test/SNMP/Info/Layer3/DLink.pm @@ -47,7 +47,7 @@ sub setup : Tests(setup) { # Start with a common cache that will serve most tests my $cache_data = { - '_layers' => 4, + '_layers' => 6, '_description' => 'DGS-3620-28SC Gigabit Ethernet Switch', '_i_name' => 1, @@ -60,6 +60,16 @@ sub setup : Tests(setup) { $test->{info}->cache($cache_data); } +sub layers : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'layers'); + is($test->{info}->layers(), '00000110', q(Original layers unmodified)); + + $test->{info}->clear_cache(); + is($test->{info}->layers(), undef, q(No data returns undef layers)); +} + sub interfaces : Tests(1) { my $test = shift;