Changes to Info.pm to support devices that don't return sysServices.0

This commit is contained in:
Jeroen van Ingen
2010-07-26 11:32:48 +00:00
parent 262fa5a3cd
commit c28bbd5728

25
Info.pm
View File

@@ -1165,13 +1165,22 @@ sub device_type {
my $objtype = "SNMP::Info"; my $objtype = "SNMP::Info";
my $layers = $info->layers(); my $layers = $info->layers() || '00000000';
# if we dont have sysServices, we dont have anything else either probably.
return unless ( defined $layers and length($layers) );
my $desc = $info->description() || 'undef'; my $desc = $info->description() || 'undef';
$desc =~ s/[\r\n\l]+/ /g; $desc =~ s/[\r\n\l]+/ /g;
# Some devices don't implement sysServices, but do return a description.
# In that case, log a warning and continue.
if ( !$layers ) {
if ($desc ne 'undef') {
carp("Device doesn't implement sysServices but did return sysDescr. Might give unexpected results.\n") if $info->debug();
} else {
# No sysServices, no sysDescr
return undef;
}
}
my $id = $info->id() || 'undef'; my $id = $info->id() || 'undef';
# Hash for generic fallback to a device class if unable to determine using # Hash for generic fallback to a device class if unable to determine using
@@ -1433,6 +1442,14 @@ sub device_type {
$objtype = 'SNMP::Info::Layer3::CiscoFWSM' $objtype = 'SNMP::Info::Layer3::CiscoFWSM'
if ( $desc =~ /Cisco Firewall Services Module/i ); if ( $desc =~ /Cisco Firewall Services Module/i );
# Generic device classification based upon sysObjectID
if ( defined($id) ) {
if ( defined $l3sysoidmap{$id} ) {
$objtype = $l3sysoidmap{$id};
} elsif ( defined $l2sysoidmap{$id}) {
$objtype = $l2sysoidmap{$id};
}
}
} }
return $objtype; return $objtype;